Error in ProcessorCount() under linux (dependency on value of OMP_NUM_THREADS)
There is a mistake in the implementation of ProcessorCount() under linux.
By default the linux implementation calls the command-line program “nproc” to determine the number of cores available. However “nproc’s” behaviour depends on the value of environment variable OMP_NUM_THREADS. So for example
$ nproc
12
$ OMP_NUM_THREADS=1 nproc
1
For determining the run-time number of cores, depending on the build configuration-time value of this variable is certainly not appropriate. And an OpenMP variable ought not to affect the cores available for MPI or process concurrency. (Also it is inconsistent with the other mechanisms such as schedtool. )
Possibly adding nproc's “–all” flag.
$ OMP_NUM_THREADS=1 nproc --all
12
might help, but I see from the comments that behaviour under containers is important and I don't know what "--all" does under that environment.