A communication mismatch error was encountered: The other lab became idle during labReceive.

6 次查看(过去 30 天)
I use spmd to have two parallel tasks and I use labsend and labreceive methods to transfer data between these tasks,but I get the following Error: A communication mismatch error was encountered: The other lab became idle during labReceive. what should I do to solve this error? Is there a better way to have parallel tasks? please help me.

回答(1 个)

Edric Ellis
Edric Ellis 2014-10-14
This error essentially tells you that the other worker (or "lab") got to the end of the spmd block before it sent any data. A simple example might be the following:
spmd
if labindex == 1
labReceive(2);
end
end
In this case, lab 1 is waiting for a message to be sent by lab 2 - but lab 2 never sends anything before getting to the end of the spmd block.
In general, to avoid errors like this, you must ensure that all your labSend and labReceive calls are matched up under all circumstances.
  1 个评论
fahimeh
fahimeh 2014-10-15
In the code when ever I use labsend in one worker,use labReceive in another worker,like below:
if labindex==1
labReceive(2);
else
labeSend(1);
end
But I get the Error that explain. Is it correct or not?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by