spmdReceive
Syntax
Description
receives data
B = spmdReceiveB sent to the current worker from any worker in the current spmd block or communicating job.
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
spmdReceive to these workers, the function has no effect.
When a worker runs spmdReceive, the function blocks the execution
of other commands until the worker receives the data.
To use spmdReceive, 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.
receives data from any
worker.B = spmdReceive('any')
Examples
Input Arguments
Output 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 receives data using
spmdReceivemight finish execution after 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 | spmdSendReceive | spmdSend