Function detect_scheduler_cpus

Function Documentation

inline int detect_scheduler_cpus()

Check HPC job scheduler environment for allocated CPU count.

Checks common scheduler env vars in priority order: SLURM_CPUS_PER_TASK, PBS_NUM_PPN, PBS_NP, NSLOTS, LSB_DJOB_NUMPROC These represent the allocated resources, which are the correct ceiling on HPC systems (not the total hardware cores).

Returns:

Allocated CPU count, or 0 if no scheduler detected