spmdBarrier
Syntax
Description
spmdBarrier stops all workers in the current spmd block or communicating job from executing code until every worker calls
spmdBarrier.
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
spmdBarrier to these workers, the function has no effect.
Use spmdBarrier to synchronize workers, for example, when workers
use shared resources such as a file handle.
If only one worker is running on the current spmd block, execution continues
immediately. To determine the number of workers running the current spmd block, use the
spmdSize
function. The spmdSize function returns a value of 1
outside of an spmd block or communicating job.
Examples
Extended Capabilities
Version History
Introduced in R2022b
See Also
spmdBroadcast | spmdIndex | spmdReceive | spmdSend | spmdSendReceive