labindex
(Not recommended) Index of the current worker in an spmd
block
labindex
is not recommended. Use spmdIndex
instead. For more information, see Version History.
Syntax
Description
returns the
index of the worker currently executing the function in an id
= labindexspmd
block.
When workers run an spmd
block or a communicating job begins execution, a
unique index is assigned to each worker. The value of labindex
is an
integer between 1
and numlabs
.
A worker gets the same id
inside every spmd
block for the duration of a given parallel pool.
Examples
Tips
In an spmd
block, because you have access to all workers individually
and control what gets executed on them, each worker has a unique
labindex
.
However, inside a parfor
-loop, labindex
always
returns a value of 1 on all workers in all iterations.