getting results after a code with a smpd block

2 Ansichten (letzte 30 Tage)
Ruddi Rodriguez Garcia
Ruddi Rodriguez Garcia am 5 Mär. 2018
Beantwortet: Edric Ellis am 6 Mär. 2018
Hello, I have a question about how to use smpd. I am doing a stochastics simulation.I am runing it in a mahcine with 4 cores. The main script call a function as:
smpd
function [output1,ouput2]=myfun();
end
where myfun is my main code.
So for each output I got a composite var for example (output1, compossite 1x4).
Then to get the values of the var I can use a loop to go through every worker or I can just collect without loop as:
output1c = output1 (1,1);
output2c = output1 (1,2);
output3c = output1 (1,3);
output4c = output1 (1,4);
where output(1,2,3,4)c are the variables that I used as results .
My questions are:
1- Since smpd run the same code in each worker, the 4 output(1,2,3,4)c are independents aoutputs of the same code ?
2- Some times happen that If I run the same code different times I got the same result,since I have a stochastic code every run should be different , I found that is a problem of collecting the results from the workers, could be possible that the workers kept the old results and I not deleting properly , I am using, clear all.
Thank you very much , and I am sorry if I am not clear enough

Antworten (1)

Edric Ellis
Edric Ellis am 6 Mär. 2018
  1. Yes, each output is the result of an independent run of myfun
  2. Be aware that MATLAB intializes the random state in a deterministic way. See this documentation page for more details.

Kategorien

Mehr zu Parallel for-Loops (parfor) finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by