Saving data from SPMD loop to client

6 views (last 30 days)
Manuel
Manuel on 7 Jul 2012
Hi All,
I'm running an smpd loop like
for c=1:NumLabs
all_data{c}.X = rand(100,100);
end
matlabpool NumLabs
smpd (NumLabs)
temp_X = all_data{labindex}.X
out = function(temp_X);
end
matlabpool close
How can I access the data stored in the composite object 'out' after closing the matlab pool? Is it possible to attach 'out' to "all_data{labindex}.out" in a way that its usable after closing the pool?
Thanks, Manuel.

Answers (2)

Edric Ellis
Edric Ellis on 9 Jul 2012
After the SPMD block, 'out' is a 'Composite'. By indexing into the Composite, you ring the values back to the client. To bring a single value back, you can do this:
one_value = out{1};
If you want to bring all the values back, you could do something like this:
out_client = out(:);

Manuel
Manuel on 9 Jul 2012
Thanks, Edric.
I realize I wasn't very clear. I would like to use the information in out AFTER I close the matlab pool (out is not directly reachable, so I can't do out{1} or out(:)).
Best,
Manuel
  2 Comments
Edric Ellis
Edric Ellis on 10 Jul 2012
Hi Manuel, You need to do "out_client = out(:);" before closing matlabpool, and then "out_client" will be stored on the client.
Edric Ellis
Edric Ellis on 10 Jul 2012
For example:
matlabpool local 2
spmd
x = rand();
end
x_client = x(:);
matlabpool close
celldisp(x_client)

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!