Is there a way to provide a variable to a worker of a parpool?
9 views (last 30 days)
Show older comments
Hi,
Is there a way to provide a variable, or a set of variables to a particular worker and/or all workers of a parpool from the parent script that's generated the parpool?
What i'm looking for is something like this
*Some processing to calculate a number of variables.
ParallelPool = parpool(16);
*Pass the variables and their values just created to a particular worker and/or all workers
pctRunOnAll ParallelScript
Thanks
1 Comment
Brendan Hamm
on 28 Jun 2016
It sounds like what you want to do is use a Composite array.
% Create Random Data
A = rand(1);
B = rand(2);
% Open pool
parpool('local',2) % gcp('nocreate') % <-second option if you have pool open
% Create a Composite variable and assign its elements.
C = Composite(2);
C{1} = A;
C{2} = B;
spmd
disp(C) % display results
end
As you can see when I refer to C I get a different answer from each worker.
Answers (1)
Sean de Wolski
on 28 Jun 2016
You want a parallel.pool.Constant. https://www.mathworks.com/help/distcomp/parallel.pool.constant.html
0 Comments
See Also
Categories
Find more on Parallel Computing Fundamentals in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!