In general: start with non-blocking calls, standard mode
In general, it is reasonable to start programming with non-blocking calls and standard mode. Non-blocking calls can eliminate the possibility of deadlock and reduce synchronization overhead. Standard mode gives generally good performance.
Blocking calls:
- use if you want tasks to synchronize
- use if wait immediately follows send or receive
- start with synchronous, then switch to standard mode
Blocking calls may be required if the programmer wishes the tasks to synchronize. Also, if the program requires a send or receive to be immediately followed by a Wait, it is more efficient to use a blocking call. If using blocking calls, it may be advantageous to start in synchronous mode, and then switch to standard mode. Testing in synchronous mode will ensure that the program does not depend on the presence of sufficient system buffering space.
Evaluate performance, analyze code
- if non-blocking receives are posted early, might consider ready mode
- if there is too much synchronization overhead on sends, could switch to buffered mode
The next step is to analyze the code and evaluate its performance. If non-blocking receives are posted early, well in advance of the corresponding sends, it might be advantageous to use ready mode. To make things safer, the receiving task should probably notify the sender after the receives have been posted. After receiving the notification, the sender can proceed with the sends.
If there is too much synchronization overhead on the sending task, especially for large messages, buffered mode may be more efficient.