Home > database >  Why does geometryFromEdges give a parse error when used in parfor on a thread-based pool?
Why does geometryFromEdges give a parse error when used in parfor on a thread-based pool?

Time:02-03

I want to solve multiple PDEs in parallel on threads using the Parallel Computing Toolbox in Matlab. I have the following code:

delete(gcp('nocreate'));
parpool('threads')

parfor i = 1:1
    model = createpde();
     R1 = [3,4,0,1,1,0,1,1,0,0]';
     sf = 'R1';
     ns = char('R1');
     ns = ns';
     gm = R1;
     g = decsg(gm,sf,ns);
     geometryFromEdges(model, g);
end

This results in the following error:

Error using pde.EquationModel/geometryFromEdges The specified superclass 'pde.GeometricModel' contains a parse error, cannot be found on MATLAB's search path, or is shadowed by another file with the same name.

Error in codeFile (line 4) parfor i = 1:1

When I change the parfor into a for, the code runs (and consequently I am able to numerically solve PDEs). The problem does not happen when I leave out parpool('threads'), and the parallel computations are done on processes.

I have already restored the default Matlab paths, the solution suggested for this type of error.

What could the problem be?

CodePudding user response:

MATLAB only supports a subset of functions in thread-based parallel computation, less than is supported in process-based parallel computation. You can find the list here. It appears that geometryFromEdges isn't one of them.

  • Related