0

I am looking to utilize the labSend, labReceive functionality with spmd in MATLAB to execute perform the following:

  1. Lab1, run a global optimization routine and pass an intermediate result to Lab2
  2. Lab2, wait for the intermediate result from Lab1 (using labProbe), once received use this result and begin a new optimization routine.
  3. Lab3,4,..., n wait for the previous result from Lab_n-1, once received use this result and begin a new optimization routine.

Problem:

  Warning: An incoming message was discarded from lab 1 (tag: 1)
  Warning: An incoming message was discarded from lab 1 (tag: 1)
  Warning: An incoming message was discarded from lab 1 (tag: 1)
  Warning: An incoming message was discarded from lab 1 (tag: 1)
  Warning: An incoming message was discarded from lab 1 (tag: 1)

Data from labSend:

0.4907    0.3328    0.3625    0.5843    0.3159    0.5065    0.5100    0.4984    0.3336    0.5055  
0.5216    0.5268    0.5002    0.4828    0.4907    0.3328    0.3625    0.5843    0.3159    0.5065
0.5100    0.4984    0.3336    0.5055    0.5216    0.5268    0.5002    0.4828    0.5010

which is in order with 0.4907 being the first message sent via labSend.

Last value received from labReceive:

0.5055

meaning the last 5 messages from labSend were ignored.

Now, the spmd routine is asynchronous as it 1) has to wait for the intermediate result of the previous lab and 2) the optimization routine speeds up as it progresses (searching a smaller domain)

Therefore, the previous labs may send multiple messages before lab_n has the chance to process them (executing something else).

Question:

Is there a way to immediately process (receive) data from Lab1 if I am looking at Lab2 and just store it somewhere? Or is there a way to process only the most recent message? and ignore any queued messages?

Thanks for your help!

Clark
  • 133
  • 4
  • "Now, the spmd routine is asynchronous as it 1) has to wait for the intermediate result of the previous lab and" Isn't that exactly the definition of synchronous communication? – Daniel May 08 '20 at 19:38
  • 1
    @Daniel I guess it's synced in a sense that I won't let lab2 kick off until I get the first lab1 result, but subsequently lab1 can send results to lab2 while lab2 is in the middle of executing an inner optimization loop and won't update lab1 results until that loop is completed – Clark May 08 '20 at 19:44
  • 1
    That is a tricky one and I am not sure if I would even use `labsend` and `labreceive`, consider this from the documentation: "This function might or might not return before the corresponding labReceive completes in the receiving worker.". You might block all but your last lab if you are unlucky, all waiting for the last one. To check for alternatives, is the data you are actually sending va labsend/labreceive "large" or would it be acceptable not to use direct lab 2 lab communication but rather send it twice? – Daniel May 08 '20 at 19:59
  • @Daniel Its somewhat of a 1-way communication, i.e. Lab2 will never send data to Lab1, Lab3 will receive data from Lab2 and Lab1 (directly from Lab1 or indirectly through Lab2). The complete data set would be an NxD matrix where N is the number of labs and D is the problem dimension, with lab N needing the entire set. I'm attempting to find an approximate 'future' optimum using the intermediate results of the previous labs without waiting for them to fully complete – Clark May 08 '20 at 20:32
  • @Daniel ```labBarrier``` seems promising. Quick testing looks to allow a 'forced' re-sync during the execution, so fingers crossed – Clark May 08 '20 at 20:51

0 Answers0