[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Two problems with result of num_processors (NPROC_CURRENT_OVERRIDABLE)
From: |
Oliver Heimlich |
Subject: |
Two problems with result of num_processors (NPROC_CURRENT_OVERRIDABLE) |
Date: |
Mon, 28 Nov 2016 15:34:24 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.4.0 |
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
- Two problems with result of num_processors (NPROC_CURRENT_OVERRIDABLE),
Oliver Heimlich <=