parallel computing with scheduler Comsol-Matlab

17 views (last 30 days)
Erik
Erik on 21 May 2011
[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
Edric Ellis
Edric Ellis on 24 May 2011
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
Erik
Erik on 24 May 2011
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)

Sarah Wait Zaranek
Sarah Wait Zaranek on 24 May 2011
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
Erik
Erik on 24 May 2011
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.
Sarah Wait Zaranek
Sarah Wait Zaranek on 25 May 2011
I don't know, unfortunately. support@comsol.com might be able to help.

Sign in to comment.


Peng Jia
Peng Jia on 1 Sep 2011
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
Erik
Erik on 1 Sep 2011
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.


Erik
Erik on 1 Sep 2011
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.

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!