INNER CODE UNIT · Rust
get_ncpus
ngless-toolkit/ngless · src/batch.rs:21
pub fn get_ncpus() -> Option<usize> {
[
"OMP_NUM_THREADS",
"NSLOTS",
"LSB_DJOB_NUMPROC",
"SLURM_CPUS_PER_TASK",
]
.iter()
.find_map(|var| get_int_from_env(var))
}
/// The batch array-job index, from `LSB_JOBINDEX` (LSF) or `SGE_TASK_ID` (SGE), in that order
/// (mirrors `getJobIndex = getLSFjobIndex <|> getGEjobIndex`). Haskell reads it as an arbitrary
/// precision `Integer`; `i64` is more than enough for any real array-job index.
pub fn get_job_index() -> Option<i64> {
get_int_from_env("LSB_JOBINDEX").or_else(|| get_int_from_env("SGE_TASK_ID"))
}