parallel computing with scheduler Comsol-Matlab

[EDIT: 20110524 02:40 CDT - reformat, clarify - WDR]
I've made a function JSC.m which I am able to call like this:
JSC('TE',1001,500E-9,70E-9,30E-9)
- and it works fine, I get the output I want.
Now this is pretty time consuming which is why I want to evaluate it in parallel for different inputs using the cluster available to me. So I've made this code:
sched = findResource('scheduler','type','local');
job1 = createJob(sched);
createTask(job1, @JSC, 1, {{'TE',1001,500E-9,70E-9,30E-9} {'TE',1001,500E-9,70E-9,40E-9} {'TE',1001,500E-9,70E-9,50E-9} {'TE',1001,500E-9,70E-9,60E-9}});
submit(job1);
waitForState(job1,'finished');
results = getAllOutputArguments(job1)
But it just returns results = Empty cell array: 4-by-0 Now this job scheduling works fine for rand.m for example:
sched = findResource('scheduler','type','local');
job1 = createJob(sched);
createTask(job1, @rand, 1, {{3,3} {3,3} {3,3} {3,3}});
submit(job1);
waitForState(job1,'finished');
results = getAllOutputArguments(job1);
results{1:4}
returns 4 3-by-3 matrices.
The only difference between rand.m and my JSC.m as I see it, is that it is linked with Comsol, so there is some Comsol code inside it. But why is it able to evaluate it with a normal function call, but not when I use a cluster?
I can post the code for JSC.m if necessary.

4 Comments

Do any of the tasks have the "Error" property set? something like
job1.Tasks(1).Error
should show you...
Thank you, here's the output:
>> job1.Tasks(1).Error
ans =
MException object with properties:
identifier: 'MATLAB:UndefinedFunction'
message: 'Undefined function or method 'flreport' for input arguments of type 'char'.'
stack: [7x1 struct]
cause: {}
The first line of the function JSC.m is
flreport('off')
so Matlab doesn't recognize it. I'm guessing that the extra workers the scheduler spawns are Matlab copies which are not linked to Comsol... but I've no clue how to fix that.
Using the "local" scheduler, the workers are running the same installation of MATLAB as your desktop copy. Do have to perform any initialisation to get Comsol to work? You may need to replicate that on the workers. You could add initialisation to "jobStartup" - see http://www.mathworks.com/help/toolbox/distcomp/jobstartup.html
I have a desktop shortcut called "Comsol Matlab" which launches Matlab connected via Livelink to Comsol. So maybe in "jobStartup" I can add a line that starts up the Livelink to Comsol?

Sign in to comment.

Answers (3)

COMSOL helped me with a similar issue about a year ago. Their answer is below. I would encourage you to contact them. They were very helpful.
"There is a command available for the livelink for MATLAB that allow the user to connect MATLAB with a COSMOL server. The command name is MPHSTART and it is available with the hotfix patch available for version 4.0a : http://www.comsol.com/support/updates/comsol40ap/
Note that if the user is using MATLAB in Distributed Computing Server and call COMSOL function on different node of the server, a COMSOL server will need to be started on each node."

2 Comments

Thank you for your answer, I forgot to mention, I'm using Comsol 3.5a so mphstart doesn't work. I don't know if there's a similar command that works in 3.5a.
I don't know, unfortunately. support@comsol.com might be able to help.

Sign in to comment.

Hi Erik,
I'm pulling my hair off my head now because of the same issue as yours. Have you solved this headache? I'm using 3.5a too and can not do dist. cmp. with Matlab. If you have already solved this problem please let me know. And could you share your JSC.m? I'm a stanger to COMSOL, so I'd like to learn from you guys. Thanks.
Best.
Peng

1 Comment

I didn't find a solution. I ended up just splitting up my simulation in small bits and starting a job for each of them.
Apparently, when the cluster spawns new workers for a parallel problem, they are not linked with Comsol so Comsol commands won't work.
It might just be a problem with the cluster at my university.

Sign in to comment.

I didn't find a solution. I ended up just splitting up my simulation in small bits and starting a job for each of them. Apparently, when the cluster spawns new workers for a parallel problem, they are not linked with Comsol so Comsol commands won't work. It might just be a problem with the cluster at my university.

Asked:

on 21 May 2011

Community Treasure Hunt

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

Start Hunting!