Re: Converting sequential MATLAB code to a parallel form



"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:

parfor ii=1:1, ~isempty( getCurrentTask() ), end % or use SPMD in R2008b
ans =
1
~isempty( getCurrentTask() )
ans =
0

Cheers,

Edric.
.



Relevant Pages

  • Re: C to MATLAB from scratch.Where to start?
    ... My question is about the reverse conversion from .m to C/C++, ... Start from scratch. ... Matlab doesn't handle trivial program elemnts like for loops very well. ... m code to some extent is ambiguious, the automatic C compiler ...
    (comp.soft-sys.matlab)
  • Converting between java-matlab
    ... the running of my algorithm. ... In matlab, I can use two solutions to add the next element ... which requires no further matlab conversion. ... scans the vector but we all know how matlab cycles are NOT ...
    (comp.soft-sys.matlab)
  • matlab to MMA, need some help converting this code.
    ... does anyone know both mathematica AND matlab? ... nice to see line by line explanation of the conversion. ... % store data for first time point ... % calculate which reaction is next ...
    (sci.math.symbolic)
  • Comparing CSVs in from 2 files
    ... I'm really new to Matlab so don't laugh if this question is ... so trivial that it makes you sick. ... matlab that compares 2 x,y,z csv data files to make sure they are ... If one of the values is wrong after going through the conversion I ...
    (comp.soft-sys.matlab)
  • Re: Help: how can I use a workspace structure as a constant in a Simulink model?
    ... all of them invove writing some m-code to manipulate your structure into a format acceptable to Simulink. ... Write a function/script that you call manually before running the simulation that converts your data into a matrix format suitable for input to the Inport block. ... Write an S-function to do the conversion at each time step. ...
    (comp.soft-sys.matlab)

Loading