[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #55643] Function "nproc" just reports the envi
From: |
Kai Torben Ohlhus |
Subject: |
[Octave-bug-tracker] [bug #55643] Function "nproc" just reports the environment variable OMP_NUM_THREADS not the "current number of available processors". |
Date: |
Tue, 5 Feb 2019 04:36:35 -0500 (EST) |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.81 Safari/537.36 |
Follow-up Comment #9, bug #55643 (project octave):
Okay, I got confused by nproc and I am pretty sure Octave behaves correctly.
Without Octave on my system
$ nproc
4
$ nproc --all
4
$ OMP_NUM_THREADS=30 nproc
30
$ OMP_NUM_THREADS=30 nproc --all
4
Octave 4.2.2 (distro):
$ /usr/bin/octave --eval 'nproc'
ans = 1
$ /usr/bin/octave --eval 'nproc all'
ans = 4
$ /usr/bin/octave --eval 'nproc current'
ans = 1
$ /usr/bin/octave --eval 'nproc overridable'
ans = 1
$ OMP_NUM_THREADS=30 /usr/bin/octave --eval 'nproc'
ans = 1
$ OMP_NUM_THREADS=30 /usr/bin/octave --eval 'nproc all'
ans = 4
$ OMP_NUM_THREADS=30 /usr/bin/octave --eval 'nproc current'
ans = 1
$ OMP_NUM_THREADS=30 /usr/bin/octave --eval 'nproc overridable'
ans = 30
Octave 50.0.90 (self compiled):
$ octave --eval 'nproc'
ans = 4
$ octave --eval 'nproc all'
ans = 4
$ octave --eval 'nproc current'
ans = 4
$ octave --eval 'nproc overridable'
ans = 4
$ OMP_NUM_THREADS=30 octave --eval 'nproc'
ans = 4
$ OMP_NUM_THREADS=30 octave --eval 'nproc all'
ans = 4
$ OMP_NUM_THREADS=30 octave --eval 'nproc current'
ans = 4
$ OMP_NUM_THREADS=30 octave --eval 'nproc overridable'
ans = 30
A solution might be to return "nproc all" by default or a better documentation
what is returned: that is the minimum of OMP_NUM_THREADS and the detected
number of processors. The question is, does Octave regard OMP_NUM_THREADS for
all of its computations?
File "libgnu/nproc.c":
unsigned long int
num_processors (enum nproc_query query)
{
unsigned long int omp_env_limit = ULONG_MAX;
if (query == NPROC_CURRENT_OVERRIDABLE)
{
unsigned long int omp_env_threads;
/* Honor the OpenMP environment variables, recognized also by all
programs that are based on OpenMP. */
omp_env_threads = parse_omp_threads (getenv ("OMP_NUM_THREADS"));
omp_env_limit = parse_omp_threads (getenv ("OMP_THREAD_LIMIT"));
if (! omp_env_limit)
omp_env_limit = ULONG_MAX;
if (omp_env_threads)
return MIN (omp_env_threads, omp_env_limit);
query = NPROC_CURRENT;
}
/* Here query is one of NPROC_ALL, NPROC_CURRENT. */
{
unsigned long nprocs = num_processors_ignoring_omp (query);
return MIN (nprocs, omp_env_limit);
}
}
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?55643>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [Octave-bug-tracker] [bug #55643] Missing some of my processor cores (nproc), Oliver Mössinger, 2019/02/04
- [Octave-bug-tracker] [bug #55643] Missing some of my processor cores (nproc), Kai Torben Ohlhus, 2019/02/04
- [Octave-bug-tracker] [bug #55643] Missing some of my processor cores (nproc), Markus Mützel, 2019/02/04
- [Octave-bug-tracker] [bug #55643] Missing some of my processor cores (nproc), Guillaume, 2019/02/04
- [Octave-bug-tracker] [bug #55643] Missing some of my processor cores (nproc), John W. Eaton, 2019/02/04
- [Octave-bug-tracker] [bug #55643] Missing some of my processor cores (nproc), Mike Miller, 2019/02/04
- [Octave-bug-tracker] [bug #55643] Missing some of my processor cores (nproc), Oliver Mössinger, 2019/02/05
- [Octave-bug-tracker] [bug #55643] Missing some of my processor cores (nproc), Oliver Mössinger, 2019/02/05
- [Octave-bug-tracker] [bug #55643] Function "nproc" just reports the environment variable OMP_NUM_THREADS not the "current number of available processors"., Kai Torben Ohlhus, 2019/02/05
- [Octave-bug-tracker] [bug #55643] Function "nproc" just reports the environment variable OMP_NUM_THREADS not the "current number of available processors".,
Kai Torben Ohlhus <=
- [Octave-bug-tracker] [bug #55643] Function "nproc" just reports the environment variable OMP_NUM_THREADS not the "current number of available processors"., Mike Miller, 2019/02/05
- [Octave-bug-tracker] [bug #55643] nproc reports fewer available cores on OpenSUSE (via sched_setaffinity), Mike Miller, 2019/02/05
- [Octave-bug-tracker] [bug #55643] nproc reports fewer available cores on OpenSUSE (via sched_setaffinity), Mike Miller, 2019/02/25