aiaccel.job.utils.get_rank#

aiaccel.job.utils.get_rank(default: int = 0) → int[source]#

Return the process rank obtained from a supported environment variable.

The environment variables are checked in the following order: GLOBAL_RANK, RANK, OMPI_COMM_WORLD_RANK, PMI_RANK, MV2_COMM_WORLD_RANK, and SLURM_PROCID. Variables whose values cannot be converted to integers are ignored.

Parameters:

default (int, optional) – Value to return when none of the supported environment variables contains a valid integer. Defaults to 0.

Returns:

The first valid process rank found, or default if none is available.

Return type:

int