Transparency violation error when using 'parfor'
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Eric Hong
am 14 Aug. 2015
Kommentiert: Walter Roberson
am 26 Aug. 2015
I am trying to take advantage of multiple processor with the following codes:
mfile_name = run_sims_func();
parfor i=1:length(mfile_name)
run(mfile_name{i});
end
I understand everything should be known or defined to Matlab to use 'parfor', but I don't know why the cell array of script names is considered undefined or unknown.
I have a function 'run_sims_func()' which creates a script in the same directory of 'run_sims_main.m' based on some other information. The cell array of the script names is returned to the main function as shown below:
mfile_name = run_sims_func();
For example,
mfile_name = {'eric.m';'hong.m'};
Then, I want to run them simultaneously with 'parfor' command as attempted below:
parfor i=1:length(mfile_name)
run(mfile_name{i});
end
Then I get the subject error. Surely enough, if I just use 'for', then it works just fine.
Why is this and how can I get it work?
Your help will save me ^_^
Thank you in advance,
Eric
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 14 Aug. 2015
scripts are essentially not compatible with parfor if the scripts create any variables or use any values from the workspace that the parfor is executing in.
If you can, convert the scripts to functions and pass any necessary values into the functions, and instead of using run() use a cell array of function handles.
6 Kommentare
Walter Roberson
am 26 Aug. 2015
Are you possibly writing them somewhere on your path instead of into your current directory?
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Parallel for-Loops (parfor) finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!