Follow-Up: Savannah bugs #48534 #48535. Hi, I have two problems with the function num_processors in libgnu's nproc.c.
FIRST PROBLEM num_processors (NPROC_CURRENT_OVERRIDABLE) returns the value of OMP_NUM_THREADS. However, if a thread limit is defined, it should return the minimum of OMP_NUM_THREADS and OMP_THREAD_LIMIT. OMP_THREAD_LIMIT=1 OMP_NUM_THREADS=2 ./run-my-program - What I get: 2 - What I expect: 1 - Reason: The effective number of threads cannot exceed the thread limit. SECOND PROBLEM num_processors (NPROC_CURRENT_OVERRIDABLE) parses the environment variable OMP_NUM_THREADS for an integer. However, according to OpenMP documentation it may be a list of integers. In that case, the function ignores the value of OMP_NUM_THREADS. See https://gcc.gnu.org/onlinedocs/libgomp/OMP_005fNUM_005fTHREADS.html OMP_NUM_THREADS=2,2,1 ./run-my-program - What I get: 4 - What I expect: 2 or 1 depending on the current OpenMP nesting level Best Oliver