labBroadcast
(Not recommended) Send data to all workers in an spmd
block
labBroadcast
is not recommended. Use spmdBroadcast
instead. For more information, see Version History.
Description
sends the data B
= labBroadcast(source
,A
)A
to every worker in the current spmd
block or communicating job.
Tip
When you offload computations using parfor
and
parfeval
, each computation is run by only one worker at a time.
These workers are independent and do not communicate with each other. If you use
labBroadcast
on these workers, the function has no effect.
The data is broadcast from the worker with labindex
equal to
source
.
If source
is equal to labindex
,
B
is equal to A
. numlabs
is
equal to 1
outside of an spmd
block or communicating
job.
Examples
Input Arguments
Output Arguments
Tips
A worker that calls labBroadcast
may return before other workers.
When you need synchronized workers in an spmd
block or communicating job,
such as when you close a shared resource, use labBarrier
after calling labBroadcast
.