The Math Forum

Search All of the Math Forum:

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

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

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

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: 721
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 " <> writes:
> Edric M Ellis <> wrote in message <>...
>> "Mark " <> writes:

>> >> You could use 'parfevalOnAll':
>> >>
>> >>
>> >>

>> > 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.



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

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.