Is it possible to use pctRunOnAll as a batch?

1 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Parallel Computing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by