Re: Converting sequential MATLAB code to a parallel form
- From: Edric M Ellis <eellis@xxxxxxxxxxxxx>
- Date: 14 Oct 2008 15:08:54 +0100
"Paul Lewis" <paul.c.lewis@xxxxxxxx> writes:
I am in the process of converting a portion of an existing sequential MATLAB
program to a parallel form. I am having a limited amount of success. Note:
one of the high level goals of this conversion experiment is to have the code
succesfully execute no matter the dstributed configuration of the MATLAB
environment.
[ ... snip ... ]
The converted code executes correctly in a sequential mode, and in a parallel
local mode with 1 to 4 labs, but fails in the parallel remote mode with the
error:
??? Error using ==> parallel_function>make_general_channel/channel general at 843 undefined function handle.
.
.
.
warning: Class ':all:' is an unknown object class. Element(s) of this class in array '' have been converted to structures.
warning: Could not find appropriate function on path loading function handle C:\Documents and Settings\lewispc\My
Documents\MATLAB\SABER\MATLAB\@battlespace_data\compute intercept data.m>makeF%1/F% warning: Element(s) of array '' do not match the current constructor
definition for class 'interceptor'. The element(s) have been converted
to structures.
warning: Class ':all:' is an unknown object class. Element(s) of this class in array '' have been converted to structures.
Paul,
This is a rather cryptic error message - but I think it indicates that the
M-code you have available on your desktop machine isn't visible to the remote
workers.
When you run with a matlabpool, we attempt to synchronise the MATLAB path
between the desktop client and the workers. In this case, it looks like you're
referencing object definitions that live on your C:\ drive - which will not be
automatically available to remote workers.
There are several ways that you can proceed - either you can place your M-code
on a shared drive that the workers can see (in which case, the automatic path
synchronisation should be sufficient); you could manually copy your M-code to
the workers and use PathDependencies (or "pctRunOnAll addpath <path>"); or you
could use FileDependencies to have your M-code automatically copied to the
workers when you open a matlabpool.
3. Should I be using dfeval instead?
4. Do I really have to go all the way to setting up my own jobs/tasks to do
this in parallel?
No, I think it's just a path issue (and you'd have precisely the same thing to
deal with using dfeval or jobs/tasks).
5. Is there any quick/easy way to determine if code is being executed in a
parallel mode (i.e., something like issequential, isparallel, or a task count
which is valid in all modes including those where no distributed computing is
set up)?
There are a couple of things you can do: probably the simplest is
"~isempty( getCurrentTask() )", like so:
ans =parfor ii=1:1, ~isempty( getCurrentTask() ), end % or use SPMD in R2008b
1
ans =~isempty( getCurrentTask() )
0
Cheers,
Edric.
.
- References:
- Converting sequential MATLAB code to a parallel form
- From: Paul Lewis
- Converting sequential MATLAB code to a parallel form
- Prev by Date: Re: Matrix output dimensions
- Next by Date: Re: String's array
- Previous by thread: Converting sequential MATLAB code to a parallel form
- Next by thread: Converting sequential MATLAB code to a parallel form
- Index(es):
Relevant Pages
|
Loading