Using third party software within parfor loop

4 Ansichten (letzte 30 Tage)
Dags
Dags am 18 Jan. 2018
Kommentiert: Dags am 18 Jan. 2018
I wrote a set of nested for loops to conduct a parameter sweep in a third party software (Lumerical, it's an FDTD package) in Matlab. This code works perfectly well, but I can't seem to get the parallel version to work. My guess is that Matlab is having issues assigning workers in the parallel case, but I'm having issues resolving this. I've copied my code for the loop below and the line in the function I use to execute each Lumerical simulation. Does anyone have any suggestions for how to resolve this?
parfor ph = 1:PH
for p = 1:P
for bi = 1:BI
for pii = 1:PI
for r =1:R
poolobj = gcp;
addAttachedFiles(poolobj, FDTD_exec_pillars_parfor.m);
pitch = [PillarHeight(ph), Pitch(p), BackgroundIndex(bi),...
PillarIndex(pii), Radius(r)];
Transdata = FDTD_exec_pillars_parfor(pitch);
cellframe2(ph,p,bi,pii,r) = Transdata;
end
end
end
end
end
% Path used to execute simulation in FDTD package within function FDTD_exec_pillars_parfor
[x1,y1]=system('"C:\Program Files\Lumerical\FDTD\bin\fdtd-solutions.exe" -run NOMAD_script.lsf');
error message:
"Error: MATLAB cannot determine whether "FDTD_exec_pillars_parfor" refers to a
function or variable.
See Parallel for Loops in MATLAB, "Unambiguous Variable Names"."
This error message appeared after I added the two poolobj lines in attempt to resolve this error:
"An UndefinedFunction error was thrown on the workers for 'FDTD_exec_pillars_parfor'.
This might be because the file containing 'FDTD_exec_pillars_parfor' is not
accessible on the workers. Use addAttachedFiles(pool, files) to specify the required
files to be attached. See the documentation for 'parallel.Pool/addAttachedFiles' for
more details.
Caused by:
Undefined function 'FDTD_exec_pillars_parfor' for input arguments of type
'double'"

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 18 Jan. 2018
addAttachedFiles(poolobj, 'FDTD_exec_pillars_parfor.m');
You were missing the quotation marks.
  1 Kommentar
Dags
Dags am 18 Jan. 2018
Wow, after all that debugging. Thank you! That one hurt.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

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

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by