Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Execute a command on each node of cluster once on startup
Replies: 1   Last Post: Jun 24, 2014 2:39 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View  
Edric Ellis

Posts: 697
Registered: 12/7/04
Re: Execute a command on each node of cluster once on startup
Posted: Jun 24, 2014 2:39 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Mark " <mtompkins@firmusgrp.com> writes:
> Edric M Ellis <eellis@mathworks.com> wrote in message <ytwa993fwno.fsf@uk-eellis-deb7-64.dhcp.mathworks.com>...
>> "Mark " <mtompkins@firmusgrp.com> writes:
>>

>> >> You could use 'parfevalOnAll':
>> >>
>> >> http://www.mathworks.com/help/distcomp/parfevalonall.html
>> >>

>> > Thanks for your reply. I looked at this however as I understand it
>> > this would happen at the worker level not the node level. So if one
>> > physical node has 12 workers, this would result in 12 instances of the
>> > function call on the same physical (i.e. single) node.
>> >
>> > While it might achieve the desired result, having 12 calls just
>> > doesn't seem like the proper approach.

>>
>> Yes, PARFEVALONALL would execute on each worker process, not on each
>> host. To do that, you'd need to do some more work - there's nothing
>> built-in. It's probably simplest to use SPMD, something like this:
>>
>> spmd
>> [status, myHostName] = system('hostname');
>> assert(status == 0);
>> % get all worker hostnames as a cell array
>> allHostNames = gcat({myHostName});
>>
>> % find first occurrence of my hostname
>> leadWorkerIndex = find(strcmp(myHostName, allHostNames), 1, 'first');
>>
>> if labindex == leadWorkerIndex
>> % I am the lead worker on this host
>> % do stuff...
>> end
>> end
>>

> Interesting approach. As there would be multiple hosts I'd have to do
> this process for each 'hostname'. I also think this is likely the only
> option currently available to me from within Matlab.


Actually, that SPMD block operates on all hosts in parallel. For
instance, if you had 4 workers across two hosts 'host-a' and 'host-b',
then the result of the GCAT operation on all workers is

{'host-a', 'host-a', 'host-b', 'host-b'}

and then labs 1 and 3 will discover that they are 'lead' workers and
execute the body of the IF block.

Cheers,

Edric.



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.