Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
custom function call doesn't work, using parallel toolbox

Subject: custom function call doesn't work, using parallel toolbox

From: Kai Song

Date: 4 Jun, 2009 01:41:01

Message: 1 of 4

Hi,

I have successfully tested the parallel toolbox by following the tutorial. In the tutorial, it runs rand() function as follow:
T = createTask(j,@rand,1,{3,3})

However, when I give a locally defined function handle to createTask(), I can't get any results. Here is my code:
mult=@(x,y)x*y;
T = createTask(j,mult,1,{3,4});

The job can be successively submitted, but the result is as follow:
result =

   Empty cell array: 1-by-0



Does anyone know why the function handle doesn't work?

Thanks in advance,

Kai

Subject: custom function call doesn't work, using parallel toolbox

From: Edric M Ellis

Date: 4 Jun, 2009 07:33:04

Message: 2 of 4

"Kai Song" <ksong@lbl.gov> writes:

> I have successfully tested the parallel toolbox by following the tutorial. In the tutorial, it runs rand() function as follow:
> T = createTask(j,@rand,1,{3,3})
>
> However, when I give a locally defined function handle to createTask(), I can't get any results. Here is my code:
> mult=@(x,y)x*y;
> T = createTask(j,mult,1,{3,4});
>
> The job can be successively submitted, but the result is as follow:
> result =
>
> Empty cell array: 1-by-0
>
> Does anyone know why the function handle doesn't work?

I would expect that to work. Can you check the task T to see if there was an
error? "display(T)" should show you.

Here's what I tried:

>> s = findResource( 'scheduler', 'Type', 'local' );
>> j = s.createJob;
>> mult = @(x,y) x*y;
>> t = j.createTask( mult, 1, {3, 4} );
>> j.submit; j.wait; j.getAllOutputArguments

ans =

    [12]

Cheers,

Edric.

Subject: custom function call doesn't work, using parallel toolbox

From: Kai Song

Date: 4 Jun, 2009 22:17:02

Message: 3 of 4

Hi Edric,

Thanks for your response. I thought it should work too. Here is the Error message I got:

           ErrorIdentifier : MATLAB:UndefinedFunction
           ErrorMessage : Undefined function handle.

I think the reason is I am using a actual scheduler, torque-pbs. @(x,y)x*y is not defined on the server side, so the worker daemon is confused what to do with it.

This seems like I have to add a path for where I defined the local function. however, I don't know how to let the worker daemon do it on the fly....

Do you know how to let all the nodes in the cluster see my locally defined function?

Thanks..

Kai
 

Subject: custom function call doesn't work, using parallel toolbox

From: Edric M Ellis

Date: 5 Jun, 2009 07:27:00

Message: 4 of 4

"Kai Song" <ksong@lbl.gov> writes:

> Thanks for your response. I thought it should work too. Here is the Error
> message I got:
>
> ErrorIdentifier : MATLAB:UndefinedFunction
> ErrorMessage : Undefined function handle.
>
> I think the reason is I am using a actual scheduler, torque-pbs. @(x,y)x*y is
> not defined on the server side, so the worker daemon is confused what to do
> with it.

Hmm, I just tried the example I posted previously using our testing Torque
scheduler here, and it worked as I expected. The anonymous function "@(x,y) x*y"
shouldn't need any additional stuff on the MATLAB path. However, if you need to
run other functions, you need to look into FileDependencies and/or
PathDependencies.

By the way, here's the output I got with R2009a:

>> s = findResource( 'scheduler', 'Configuration', 'torqueconfig1' );
>> s

s =

PBS Scheduler Information
=========================

                      Type : Torque
               ClusterSize : Inf
              DataLocation : /home/eellis/Jobs
       HasSharedFilesystem : true

- Assigned Jobs

           Number Pending : 0
           Number Queued : 0
           Number Running : 0
           Number Finished : 2

- PBS Specific Properties

         ClusterMatlabRoot : /mathworks/UK/devel/R2009ad/matlab
                ServerName : ukdev01glnxa64.mathworks.co.uk
           SubmitArguments :
          ResourceTemplate : -l nodes=^N^
>> j = s.createJob;
>> mult = @(x,y) x*y;
>> t = j.createTask( mult, 1, {3, 4} );
>> j.submit; j.wait; j.getAllOutputArguments

ans =

    [12]

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us