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 the receiving worker receives the data. When you need synchronized workers in anspmdblock or communicating job, such as when you close a shared resource, usespmdBarrierafter callingspmdSendandspmdReceive.
Extended Capabilities
Version History
Introduced in R2022b
See Also
spmdBarrier | spmdIndex | spmdProbe | spmdReceive | spmdSendReceive | spmdSize