Is there a way to provide a variable to a worker of a parpool?

10 visualizaciones (últimos 30 días)
Bobby Brown
Bobby Brown el 28 de Jun. de 2016
Respondida: Sean de Wolski el 28 de Jun. de 2016
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 comentario
Brendan Hamm
Brendan Hamm el 28 de Jun. de 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.

Iniciar sesión para comentar.

Respuestas (1)

Sean de Wolski
Sean de Wolski el 28 de Jun. de 2016

Categorías

Más información sobre Parallel Computing Fundamentals en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by