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: labReceive goes to sleep
Replies: 1   Last Post: Dec 18, 2012 3:01 AM

Advanced Search

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

Posts: 691
Registered: 12/7/04
Re: labReceive goes to sleep
Posted: Dec 18, 2012 3:01 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"jaesung Park" <jpark@nephilaadvisors.com> writes:

> The good news is that I found the solution. I suspected that the
> labReceive does not respond promptly and goes to sleep until all
> workers are done when the function is called without specific
> source. So I made the master worker to loop over the slave workers
> probing to see if there is any data ready to receive and call the
> labReceive with the specific source information. I tested this and it
> certainly works fine without any delay. Please see the additional code
> I put below.
>
> fprintf('[%1.1f] {%d} starts listening\n',toc(ticid),labindex);
> who = -1;
> is_data_available = 0;
> while ~is_data_available
> for i=2:numlabs
> is_data_available = labProbe(i);
> if is_data_available who = i;
> fprintf('%d is ready to send\n',who);
> break;
> end
> end end
> [data_large, source, tag] = labReceive(who);
>
>
> The bad news is that this is clearly a bug in the labReceive function
> in the Parallel toolbox. Please check and fix he bug for the case when
> there is not specific source is an argument. And please keep me posted
> with the progress. Thank you so much.


Our current tests for labReceive with no specified source do not
indicate any problems. I did however notice a bug in your original
pseudo-code reproduction whereby you weren't using the tag in your call
to labSend. I filled in a dummy implementation of your initial example
as below, and this works correctly for me.

spmd
if labindex == 1
seenExitCount = 0;
while seenExitCount < (numlabs-1)
[data, source, tag] = labReceive;
fprintf( 1, 'Received %d from %d.\n', numel(data), source );
processed_data = -data;
pause(1);
labSend(processed_data, source, tag);
if numel(data) > 1
fprintf( 1, 'Seen exit flag from %d.\n', source );
seenExitCount = seenExitCount + 1;
end
end
else
% each worker chooses how many iterations to run
N = randi([1, labindex]);
for ii = 1:N
pause(labindex/numlabs);
if ii == N
% last iteration
computed_data = rand(1,2);
else
% ordinary iteration
computed_data = rand();
end
fprintf( 1, 'About to send %d.\n', numel( computed_data ) );
processed_data = labSendReceive(1,1,computed_data, 1);
end
end
end

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.