Send data to all workers or receive data sent to all workers
shared_data = labBroadcast(srcWkrIdx,data)
shared_data = labBroadcast(srcWkrIdx)
The data being broadcast. This argument is required only for the worker that is broadcasting. The absence of this argument indicates that a worker is receiving.
The broadcast data as it is received on all other workers.
shared_data = labBroadcast(srcWkrIdx,data) sends
data to all executing workers. The
data is broadcast from the worker with
labindex == srcWkrIdx, and is received by all other workers.
shared_data = labBroadcast(srcWkrIdx) receives
on each executing worker the specified
was sent from the worker whose
labindex is not
then you do not include the
data argument. This
indicates that the function is to receive data, not broadcast it.
The received data,
shared_data, is identical on
This function blocks execution until the worker's involvement
in the collective broadcast operation is complete. Because some workers
may complete their call to
others have started, use
you need to guarantee that all workers are at the same point in a
In this case, the broadcaster is the worker whose
srcWkrIdx = 1; if labindex == srcWkrIdx data = randn(10); shared_data = labBroadcast(srcWkrIdx,data); else shared_data = labBroadcast(srcWkrIdx); end