Is it possible to use pctRunOnAll as a batch?

1 回表示 (過去 30 日間)
Bobby Brown
Bobby Brown 2016 年 7 月 18 日
回答済み: Edric Ellis 2016 年 7 月 18 日
Hi,
I have a script that will only allow me to parallel it if i use pctRunOnAll because it uses a simulation plugin that only likes one instantiation and does not like parfor. As a pctRunONAll, it works fine.
I want to get this parallel work to operate in a batch in the background. Is it possible to combine pctRunOnAll with a batch?
Am i able to do this?
j = batch(pctRunOnAll 'script1', 'matlabpool', 10, 'CaptureDiary', true);
Thanks Bobby

回答 (1 件)

Edric Ellis
Edric Ellis 2016 年 7 月 18 日
While you can use pctRunOnAll with batch, it's a little awkward. Here's what you need to do:
j = batch(@pctRunOnAll, 0, {'script1'}, 'Pool', 10, 'CaptureDiary', true)
Here we're using the form of batch which takes a function handle - in this case @pctRunOnAll. Then, we must specify the number of output arguments from that function - which is 0, and then the input arguments as a cell array, {'script1'}.
One other option you might wish to explore is wrapping up your task inside a function, and then you can use parfeval to run multiple iterations. This is also compatible with batch.

カテゴリ

Help Center および File ExchangeParallel Computing についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by