spmdSend
Description
spmdSend(
sends data A,destination)A from the current worker in an spmd block or communicating job to the workers specified by
destination.
When you offload computations using parfor and
parfeval, only one worker at a time runs each computation. These
workers are independent and do not communicate with each other. If you apply
spmdSend to these workers, the function has no effect.
To use spmdSend, the number of workers running the current spmd
block must be greater than 1. To get the number of workers running the
current spmd block, use the spmdSize
function.
Examples
Input Arguments
Tips
Tags have many uses, for example:
Use tags to save memory by only loading arrays on workers when you need the data.
Use tags to create code that does not depend on the index of the sending worker.
A worker that sends data using
spmdSendmight finish execution before other workers in thespmdblock. When you need synchronized workers in anspmdblock or communicating job, such as when you close a shared resource, usespmdBarrierafter callingspmdSendandspmdReceive.When using
spmdSendandspmdReceive, data transfer between workers is non-overtaking. This means that if a worker sends multiple data to the same destination, and the receiving worker usesspmdReceivewithout specifying tags, MATLAB® delivers the data in the order you send them.
Extended Capabilities
Version History
Introduced in R2022b
See Also
spmdBarrier | spmdIndex | spmdProbe | spmdReceive | spmdSendReceive | spmdSize