Mercurial > gnulib
annotate lib/nproc.c @ 40231:9b3c79fdfe0b
strtod: fix clash with strtold
Problem reported for RHEL 5 by Jesse Caldwell (Bug#34817).
* lib/strtod.c (compute_minus_zero, minus_zero):
Simplify by remving the macro / external variable,
and having just a function. User changed. This avoids
the need for an external variable that might clash.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Mon, 11 Mar 2019 16:40:29 -0700 |
parents | b06060465f09 |
children |
rev | line source |
---|---|
11431 | 1 /* Detect the number of processors. |
2 | |
40057
b06060465f09
maint: Run 'make update-copyright'
Paul Eggert <eggert@cs.ucla.edu>
parents:
19595
diff
changeset
|
3 Copyright (C) 2009-2019 Free Software Foundation, Inc. |
11431 | 4 |
5 This program is free software; you can redistribute it and/or modify | |
6 it under the terms of the GNU General Public License as published by | |
7 the Free Software Foundation; either version 2, or (at your option) | |
8 any later version. | |
9 | |
10 This program is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 GNU General Public License for more details. | |
14 | |
15 You should have received a copy of the GNU General Public License | |
19190 | 16 along with this program; if not, see <https://www.gnu.org/licenses/>. */ |
11431 | 17 |
12231
03fb041aaee1
Make num_processors more flexible and consistent.
Bruno Haible <bruno@clisp.org>
parents:
12179
diff
changeset
|
18 /* Written by Glen Lenker and Bruno Haible. */ |
11431 | 19 |
20 #include <config.h> | |
21 #include "nproc.h" | |
22 | |
18712
69b9a0733c37
nproc: adjust handling of OpenMP environment variables
Pádraig Brady <P@draigBrady.com>
parents:
18711
diff
changeset
|
23 #include <limits.h> |
12231
03fb041aaee1
Make num_processors more flexible and consistent.
Bruno Haible <bruno@clisp.org>
parents:
12179
diff
changeset
|
24 #include <stdlib.h> |
11431 | 25 #include <unistd.h> |
26 | |
13884 | 27 #if HAVE_PTHREAD_GETAFFINITY_NP && 0 |
12231
03fb041aaee1
Make num_processors more flexible and consistent.
Bruno Haible <bruno@clisp.org>
parents:
12179
diff
changeset
|
28 # include <pthread.h> |
03fb041aaee1
Make num_processors more flexible and consistent.
Bruno Haible <bruno@clisp.org>
parents:
12179
diff
changeset
|
29 # include <sched.h> |
03fb041aaee1
Make num_processors more flexible and consistent.
Bruno Haible <bruno@clisp.org>
parents:
12179
diff
changeset
|
30 #endif |
03fb041aaee1
Make num_processors more flexible and consistent.
Bruno Haible <bruno@clisp.org>
parents:
12179
diff
changeset
|
31 #if HAVE_SCHED_GETAFFINITY_LIKE_GLIBC || HAVE_SCHED_GETAFFINITY_NP |
03fb041aaee1
Make num_processors more flexible and consistent.
Bruno Haible <bruno@clisp.org>
parents:
12179
diff
changeset
|
32 # include <sched.h> |
03fb041aaee1
Make num_processors more flexible and consistent.
Bruno Haible <bruno@clisp.org>
parents:
12179
diff
changeset
|
33 #endif |
03fb041aaee1
Make num_processors more flexible and consistent.
Bruno Haible <bruno@clisp.org>
parents:
12179
diff
changeset
|
34 |
12176
4c3269eff85a
Implement nproc for NetBSD, OpenBSD.
Bruno Haible <bruno@clisp.org>
parents:
11431
diff
changeset
|
35 #include <sys/types.h> |
4c3269eff85a
Implement nproc for NetBSD, OpenBSD.
Bruno Haible <bruno@clisp.org>
parents:
11431
diff
changeset
|
36 |
12177
9ceaaf0610a5
Implement nproc for HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
12176
diff
changeset
|
37 #if HAVE_SYS_PSTAT_H |
9ceaaf0610a5
Implement nproc for HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
12176
diff
changeset
|
38 # include <sys/pstat.h> |
9ceaaf0610a5
Implement nproc for HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
12176
diff
changeset
|
39 #endif |
9ceaaf0610a5
Implement nproc for HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
12176
diff
changeset
|
40 |
12178 | 41 #if HAVE_SYS_SYSMP_H |
42 # include <sys/sysmp.h> | |
43 #endif | |
44 | |
12176
4c3269eff85a
Implement nproc for NetBSD, OpenBSD.
Bruno Haible <bruno@clisp.org>
parents:
11431
diff
changeset
|
45 #if HAVE_SYS_PARAM_H |
4c3269eff85a
Implement nproc for NetBSD, OpenBSD.
Bruno Haible <bruno@clisp.org>
parents:
11431
diff
changeset
|
46 # include <sys/param.h> |
4c3269eff85a
Implement nproc for NetBSD, OpenBSD.
Bruno Haible <bruno@clisp.org>
parents:
11431
diff
changeset
|
47 #endif |
4c3269eff85a
Implement nproc for NetBSD, OpenBSD.
Bruno Haible <bruno@clisp.org>
parents:
11431
diff
changeset
|
48 |
4c3269eff85a
Implement nproc for NetBSD, OpenBSD.
Bruno Haible <bruno@clisp.org>
parents:
11431
diff
changeset
|
49 #if HAVE_SYS_SYSCTL_H |
4c3269eff85a
Implement nproc for NetBSD, OpenBSD.
Bruno Haible <bruno@clisp.org>
parents:
11431
diff
changeset
|
50 # include <sys/sysctl.h> |
4c3269eff85a
Implement nproc for NetBSD, OpenBSD.
Bruno Haible <bruno@clisp.org>
parents:
11431
diff
changeset
|
51 #endif |
4c3269eff85a
Implement nproc for NetBSD, OpenBSD.
Bruno Haible <bruno@clisp.org>
parents:
11431
diff
changeset
|
52 |
19595
beb2ad957aca
Simplify code. Drop support for Borland C++ on Windows.
Bruno Haible <bruno@clisp.org>
parents:
19484
diff
changeset
|
53 #if defined _WIN32 && ! defined __CYGWIN__ |
12179
70f69bf8b898
Implement nproc for mingw.
Bruno Haible <bruno@clisp.org>
parents:
12178
diff
changeset
|
54 # define WIN32_LEAN_AND_MEAN |
70f69bf8b898
Implement nproc for mingw.
Bruno Haible <bruno@clisp.org>
parents:
12178
diff
changeset
|
55 # include <windows.h> |
70f69bf8b898
Implement nproc for mingw.
Bruno Haible <bruno@clisp.org>
parents:
12178
diff
changeset
|
56 #endif |
70f69bf8b898
Implement nproc for mingw.
Bruno Haible <bruno@clisp.org>
parents:
12178
diff
changeset
|
57 |
12231
03fb041aaee1
Make num_processors more flexible and consistent.
Bruno Haible <bruno@clisp.org>
parents:
12179
diff
changeset
|
58 #include "c-ctype.h" |
03fb041aaee1
Make num_processors more flexible and consistent.
Bruno Haible <bruno@clisp.org>
parents:
12179
diff
changeset
|
59 |
18711
545a79f1cab7
nproc: support nested OMP_NUM_THREADS, and OMP_THREAD_LIMIT
Pádraig Brady <P@draigBrady.com>
parents:
18626
diff
changeset
|
60 #include "minmax.h" |
545a79f1cab7
nproc: support nested OMP_NUM_THREADS, and OMP_THREAD_LIMIT
Pádraig Brady <P@draigBrady.com>
parents:
18626
diff
changeset
|
61 |
12176
4c3269eff85a
Implement nproc for NetBSD, OpenBSD.
Bruno Haible <bruno@clisp.org>
parents:
11431
diff
changeset
|
62 #define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0])) |
4c3269eff85a
Implement nproc for NetBSD, OpenBSD.
Bruno Haible <bruno@clisp.org>
parents:
11431
diff
changeset
|
63 |
12728 | 64 /* Return the number of processors available to the current process, based |
65 on a modern system call that returns the "affinity" between the current | |
66 process and each CPU. Return 0 if unknown or if such a system call does | |
67 not exist. */ | |
68 static unsigned long | |
69 num_processors_via_affinity_mask (void) | |
70 { | |
71 /* glibc >= 2.3.3 with NPTL and NetBSD 5 have pthread_getaffinity_np, | |
72 but with different APIs. Also it requires linking with -lpthread. | |
73 Therefore this code is not enabled. | |
74 glibc >= 2.3.4 has sched_getaffinity whereas NetBSD 5 has | |
75 sched_getaffinity_np. */ | |
13884 | 76 #if HAVE_PTHREAD_GETAFFINITY_NP && defined __GLIBC__ && 0 |
12728 | 77 { |
78 cpu_set_t set; | |
79 | |
80 if (pthread_getaffinity_np (pthread_self (), sizeof (set), &set) == 0) | |
81 { | |
82 unsigned long count; | |
83 | |
84 # ifdef CPU_COUNT | |
85 /* glibc >= 2.6 has the CPU_COUNT macro. */ | |
86 count = CPU_COUNT (&set); | |
87 # else | |
88 size_t i; | |
89 | |
90 count = 0; | |
91 for (i = 0; i < CPU_SETSIZE; i++) | |
92 if (CPU_ISSET (i, &set)) | |
93 count++; | |
94 # endif | |
95 if (count > 0) | |
96 return count; | |
97 } | |
98 } | |
13884 | 99 #elif HAVE_PTHREAD_GETAFFINITY_NP && defined __NetBSD__ && 0 |
12728 | 100 { |
101 cpuset_t *set; | |
102 | |
103 set = cpuset_create (); | |
104 if (set != NULL) | |
105 { | |
106 unsigned long count = 0; | |
107 | |
108 if (pthread_getaffinity_np (pthread_self (), cpuset_size (set), set) | |
109 == 0) | |
110 { | |
111 cpuid_t i; | |
112 | |
113 for (i = 0;; i++) | |
114 { | |
115 int ret = cpuset_isset (i, set); | |
116 if (ret < 0) | |
117 break; | |
118 if (ret > 0) | |
119 count++; | |
120 } | |
121 } | |
122 cpuset_destroy (set); | |
123 if (count > 0) | |
124 return count; | |
125 } | |
126 } | |
127 #elif HAVE_SCHED_GETAFFINITY_LIKE_GLIBC /* glibc >= 2.3.4 */ | |
128 { | |
129 cpu_set_t set; | |
130 | |
131 if (sched_getaffinity (0, sizeof (set), &set) == 0) | |
132 { | |
133 unsigned long count; | |
134 | |
135 # ifdef CPU_COUNT | |
136 /* glibc >= 2.6 has the CPU_COUNT macro. */ | |
137 count = CPU_COUNT (&set); | |
138 # else | |
139 size_t i; | |
140 | |
141 count = 0; | |
142 for (i = 0; i < CPU_SETSIZE; i++) | |
143 if (CPU_ISSET (i, &set)) | |
144 count++; | |
145 # endif | |
146 if (count > 0) | |
147 return count; | |
148 } | |
149 } | |
150 #elif HAVE_SCHED_GETAFFINITY_NP /* NetBSD >= 5 */ | |
151 { | |
152 cpuset_t *set; | |
153 | |
154 set = cpuset_create (); | |
155 if (set != NULL) | |
156 { | |
157 unsigned long count = 0; | |
158 | |
159 if (sched_getaffinity_np (getpid (), cpuset_size (set), set) == 0) | |
160 { | |
161 cpuid_t i; | |
162 | |
163 for (i = 0;; i++) | |
164 { | |
165 int ret = cpuset_isset (i, set); | |
166 if (ret < 0) | |
167 break; | |
168 if (ret > 0) | |
169 count++; | |
170 } | |
171 } | |
172 cpuset_destroy (set); | |
173 if (count > 0) | |
174 return count; | |
175 } | |
176 } | |
177 #endif | |
178 | |
19595
beb2ad957aca
Simplify code. Drop support for Borland C++ on Windows.
Bruno Haible <bruno@clisp.org>
parents:
19484
diff
changeset
|
179 #if defined _WIN32 && ! defined __CYGWIN__ |
12728 | 180 { /* This works on native Windows platforms. */ |
181 DWORD_PTR process_mask; | |
182 DWORD_PTR system_mask; | |
183 | |
184 if (GetProcessAffinityMask (GetCurrentProcess (), | |
185 &process_mask, &system_mask)) | |
186 { | |
187 DWORD_PTR mask = process_mask; | |
188 unsigned long count = 0; | |
189 | |
190 for (; mask != 0; mask = mask >> 1) | |
191 if (mask & 1) | |
192 count++; | |
193 if (count > 0) | |
194 return count; | |
195 } | |
196 } | |
197 #endif | |
198 | |
199 return 0; | |
200 } | |
201 | |
18713
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
202 |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
203 /* Return the total number of processors. Here QUERY must be one of |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
204 NPROC_ALL, NPROC_CURRENT. The result is guaranteed to be at least 1. */ |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
205 static unsigned long int |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
206 num_processors_ignoring_omp (enum nproc_query query) |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
207 { |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
208 /* On systems with a modern affinity mask system call, we have |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
209 sysconf (_SC_NPROCESSORS_CONF) |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
210 >= sysconf (_SC_NPROCESSORS_ONLN) |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
211 >= num_processors_via_affinity_mask () |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
212 The first number is the number of CPUs configured in the system. |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
213 The second number is the number of CPUs available to the scheduler. |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
214 The third number is the number of CPUs available to the current process. |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
215 |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
216 Note! On Linux systems with glibc, the first and second number come from |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
217 the /sys and /proc file systems (see |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
218 glibc/sysdeps/unix/sysv/linux/getsysstats.c). |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
219 In some situations these file systems are not mounted, and the sysconf |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
220 call returns 1, which does not reflect the reality. */ |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
221 |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
222 if (query == NPROC_CURRENT) |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
223 { |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
224 /* Try the modern affinity mask system call. */ |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
225 { |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
226 unsigned long nprocs = num_processors_via_affinity_mask (); |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
227 |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
228 if (nprocs > 0) |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
229 return nprocs; |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
230 } |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
231 |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
232 #if defined _SC_NPROCESSORS_ONLN |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
233 { /* This works on glibc, Mac OS X 10.5, FreeBSD, AIX, OSF/1, Solaris, |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
234 Cygwin, Haiku. */ |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
235 long int nprocs = sysconf (_SC_NPROCESSORS_ONLN); |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
236 if (nprocs > 0) |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
237 return nprocs; |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
238 } |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
239 #endif |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
240 } |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
241 else /* query == NPROC_ALL */ |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
242 { |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
243 #if defined _SC_NPROCESSORS_CONF |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
244 { /* This works on glibc, Mac OS X 10.5, FreeBSD, AIX, OSF/1, Solaris, |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
245 Cygwin, Haiku. */ |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
246 long int nprocs = sysconf (_SC_NPROCESSORS_CONF); |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
247 |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
248 # if __GLIBC__ >= 2 && defined __linux__ |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
249 /* On Linux systems with glibc, this information comes from the /sys and |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
250 /proc file systems (see glibc/sysdeps/unix/sysv/linux/getsysstats.c). |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
251 In some situations these file systems are not mounted, and the |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
252 sysconf call returns 1. But we wish to guarantee that |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
253 num_processors (NPROC_ALL) >= num_processors (NPROC_CURRENT). */ |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
254 if (nprocs == 1) |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
255 { |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
256 unsigned long nprocs_current = num_processors_via_affinity_mask (); |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
257 |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
258 if (nprocs_current > 0) |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
259 nprocs = nprocs_current; |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
260 } |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
261 # endif |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
262 |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
263 if (nprocs > 0) |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
264 return nprocs; |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
265 } |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
266 #endif |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
267 } |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
268 |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
269 #if HAVE_PSTAT_GETDYNAMIC |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
270 { /* This works on HP-UX. */ |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
271 struct pst_dynamic psd; |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
272 if (pstat_getdynamic (&psd, sizeof psd, 1, 0) >= 0) |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
273 { |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
274 /* The field psd_proc_cnt contains the number of active processors. |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
275 In newer releases of HP-UX 11, the field psd_max_proc_cnt includes |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
276 deactivated processors. */ |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
277 if (query == NPROC_CURRENT) |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
278 { |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
279 if (psd.psd_proc_cnt > 0) |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
280 return psd.psd_proc_cnt; |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
281 } |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
282 else |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
283 { |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
284 if (psd.psd_max_proc_cnt > 0) |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
285 return psd.psd_max_proc_cnt; |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
286 } |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
287 } |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
288 } |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
289 #endif |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
290 |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
291 #if HAVE_SYSMP && defined MP_NAPROCS && defined MP_NPROCS |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
292 { /* This works on IRIX. */ |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
293 /* MP_NPROCS yields the number of installed processors. |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
294 MP_NAPROCS yields the number of processors available to unprivileged |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
295 processes. */ |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
296 int nprocs = |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
297 sysmp (query == NPROC_CURRENT && getpid () != 0 |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
298 ? MP_NAPROCS |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
299 : MP_NPROCS); |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
300 if (nprocs > 0) |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
301 return nprocs; |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
302 } |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
303 #endif |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
304 |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
305 /* Finally, as fallback, use the APIs that don't distinguish between |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
306 NPROC_CURRENT and NPROC_ALL. */ |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
307 |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
308 #if HAVE_SYSCTL && defined HW_NCPU |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
309 { /* This works on Mac OS X, FreeBSD, NetBSD, OpenBSD. */ |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
310 int nprocs; |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
311 size_t len = sizeof (nprocs); |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
312 static int mib[2] = { CTL_HW, HW_NCPU }; |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
313 |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
314 if (sysctl (mib, ARRAY_SIZE (mib), &nprocs, &len, NULL, 0) == 0 |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
315 && len == sizeof (nprocs) |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
316 && 0 < nprocs) |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
317 return nprocs; |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
318 } |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
319 #endif |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
320 |
19595
beb2ad957aca
Simplify code. Drop support for Borland C++ on Windows.
Bruno Haible <bruno@clisp.org>
parents:
19484
diff
changeset
|
321 #if defined _WIN32 && ! defined __CYGWIN__ |
18713
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
322 { /* This works on native Windows platforms. */ |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
323 SYSTEM_INFO system_info; |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
324 GetSystemInfo (&system_info); |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
325 if (0 < system_info.dwNumberOfProcessors) |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
326 return system_info.dwNumberOfProcessors; |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
327 } |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
328 #endif |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
329 |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
330 return 1; |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
331 } |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
332 |
18711
545a79f1cab7
nproc: support nested OMP_NUM_THREADS, and OMP_THREAD_LIMIT
Pádraig Brady <P@draigBrady.com>
parents:
18626
diff
changeset
|
333 /* Parse OMP environment variables without dependence on OMP. |
18712
69b9a0733c37
nproc: adjust handling of OpenMP environment variables
Pádraig Brady <P@draigBrady.com>
parents:
18711
diff
changeset
|
334 Return 0 for invalid values. */ |
18711
545a79f1cab7
nproc: support nested OMP_NUM_THREADS, and OMP_THREAD_LIMIT
Pádraig Brady <P@draigBrady.com>
parents:
18626
diff
changeset
|
335 static unsigned long int |
545a79f1cab7
nproc: support nested OMP_NUM_THREADS, and OMP_THREAD_LIMIT
Pádraig Brady <P@draigBrady.com>
parents:
18626
diff
changeset
|
336 parse_omp_threads (char const* threads) |
545a79f1cab7
nproc: support nested OMP_NUM_THREADS, and OMP_THREAD_LIMIT
Pádraig Brady <P@draigBrady.com>
parents:
18626
diff
changeset
|
337 { |
545a79f1cab7
nproc: support nested OMP_NUM_THREADS, and OMP_THREAD_LIMIT
Pádraig Brady <P@draigBrady.com>
parents:
18626
diff
changeset
|
338 unsigned long int ret = 0; |
545a79f1cab7
nproc: support nested OMP_NUM_THREADS, and OMP_THREAD_LIMIT
Pádraig Brady <P@draigBrady.com>
parents:
18626
diff
changeset
|
339 |
545a79f1cab7
nproc: support nested OMP_NUM_THREADS, and OMP_THREAD_LIMIT
Pádraig Brady <P@draigBrady.com>
parents:
18626
diff
changeset
|
340 if (threads == NULL) |
545a79f1cab7
nproc: support nested OMP_NUM_THREADS, and OMP_THREAD_LIMIT
Pádraig Brady <P@draigBrady.com>
parents:
18626
diff
changeset
|
341 return ret; |
545a79f1cab7
nproc: support nested OMP_NUM_THREADS, and OMP_THREAD_LIMIT
Pádraig Brady <P@draigBrady.com>
parents:
18626
diff
changeset
|
342 |
545a79f1cab7
nproc: support nested OMP_NUM_THREADS, and OMP_THREAD_LIMIT
Pádraig Brady <P@draigBrady.com>
parents:
18626
diff
changeset
|
343 /* The OpenMP spec says that the value assigned to the environment variables |
545a79f1cab7
nproc: support nested OMP_NUM_THREADS, and OMP_THREAD_LIMIT
Pádraig Brady <P@draigBrady.com>
parents:
18626
diff
changeset
|
344 "may have leading and trailing white space". */ |
545a79f1cab7
nproc: support nested OMP_NUM_THREADS, and OMP_THREAD_LIMIT
Pádraig Brady <P@draigBrady.com>
parents:
18626
diff
changeset
|
345 while (*threads != '\0' && c_isspace (*threads)) |
545a79f1cab7
nproc: support nested OMP_NUM_THREADS, and OMP_THREAD_LIMIT
Pádraig Brady <P@draigBrady.com>
parents:
18626
diff
changeset
|
346 threads++; |
545a79f1cab7
nproc: support nested OMP_NUM_THREADS, and OMP_THREAD_LIMIT
Pádraig Brady <P@draigBrady.com>
parents:
18626
diff
changeset
|
347 |
18712
69b9a0733c37
nproc: adjust handling of OpenMP environment variables
Pádraig Brady <P@draigBrady.com>
parents:
18711
diff
changeset
|
348 /* Convert it from positive decimal to 'unsigned long'. */ |
18711
545a79f1cab7
nproc: support nested OMP_NUM_THREADS, and OMP_THREAD_LIMIT
Pádraig Brady <P@draigBrady.com>
parents:
18626
diff
changeset
|
349 if (c_isdigit (*threads)) |
545a79f1cab7
nproc: support nested OMP_NUM_THREADS, and OMP_THREAD_LIMIT
Pádraig Brady <P@draigBrady.com>
parents:
18626
diff
changeset
|
350 { |
545a79f1cab7
nproc: support nested OMP_NUM_THREADS, and OMP_THREAD_LIMIT
Pádraig Brady <P@draigBrady.com>
parents:
18626
diff
changeset
|
351 char *endptr = NULL; |
545a79f1cab7
nproc: support nested OMP_NUM_THREADS, and OMP_THREAD_LIMIT
Pádraig Brady <P@draigBrady.com>
parents:
18626
diff
changeset
|
352 unsigned long int value = strtoul (threads, &endptr, 10); |
545a79f1cab7
nproc: support nested OMP_NUM_THREADS, and OMP_THREAD_LIMIT
Pádraig Brady <P@draigBrady.com>
parents:
18626
diff
changeset
|
353 |
545a79f1cab7
nproc: support nested OMP_NUM_THREADS, and OMP_THREAD_LIMIT
Pádraig Brady <P@draigBrady.com>
parents:
18626
diff
changeset
|
354 if (endptr != NULL) |
545a79f1cab7
nproc: support nested OMP_NUM_THREADS, and OMP_THREAD_LIMIT
Pádraig Brady <P@draigBrady.com>
parents:
18626
diff
changeset
|
355 { |
545a79f1cab7
nproc: support nested OMP_NUM_THREADS, and OMP_THREAD_LIMIT
Pádraig Brady <P@draigBrady.com>
parents:
18626
diff
changeset
|
356 while (*endptr != '\0' && c_isspace (*endptr)) |
545a79f1cab7
nproc: support nested OMP_NUM_THREADS, and OMP_THREAD_LIMIT
Pádraig Brady <P@draigBrady.com>
parents:
18626
diff
changeset
|
357 endptr++; |
545a79f1cab7
nproc: support nested OMP_NUM_THREADS, and OMP_THREAD_LIMIT
Pádraig Brady <P@draigBrady.com>
parents:
18626
diff
changeset
|
358 if (*endptr == '\0') |
18712
69b9a0733c37
nproc: adjust handling of OpenMP environment variables
Pádraig Brady <P@draigBrady.com>
parents:
18711
diff
changeset
|
359 return value; |
18711
545a79f1cab7
nproc: support nested OMP_NUM_THREADS, and OMP_THREAD_LIMIT
Pádraig Brady <P@draigBrady.com>
parents:
18626
diff
changeset
|
360 /* Also accept the first value in a nesting level, |
545a79f1cab7
nproc: support nested OMP_NUM_THREADS, and OMP_THREAD_LIMIT
Pádraig Brady <P@draigBrady.com>
parents:
18626
diff
changeset
|
361 since we can't determine the nesting level from env vars. */ |
545a79f1cab7
nproc: support nested OMP_NUM_THREADS, and OMP_THREAD_LIMIT
Pádraig Brady <P@draigBrady.com>
parents:
18626
diff
changeset
|
362 else if (*endptr == ',') |
18712
69b9a0733c37
nproc: adjust handling of OpenMP environment variables
Pádraig Brady <P@draigBrady.com>
parents:
18711
diff
changeset
|
363 return value; |
18711
545a79f1cab7
nproc: support nested OMP_NUM_THREADS, and OMP_THREAD_LIMIT
Pádraig Brady <P@draigBrady.com>
parents:
18626
diff
changeset
|
364 } |
545a79f1cab7
nproc: support nested OMP_NUM_THREADS, and OMP_THREAD_LIMIT
Pádraig Brady <P@draigBrady.com>
parents:
18626
diff
changeset
|
365 } |
545a79f1cab7
nproc: support nested OMP_NUM_THREADS, and OMP_THREAD_LIMIT
Pádraig Brady <P@draigBrady.com>
parents:
18626
diff
changeset
|
366 |
545a79f1cab7
nproc: support nested OMP_NUM_THREADS, and OMP_THREAD_LIMIT
Pádraig Brady <P@draigBrady.com>
parents:
18626
diff
changeset
|
367 return ret; |
545a79f1cab7
nproc: support nested OMP_NUM_THREADS, and OMP_THREAD_LIMIT
Pádraig Brady <P@draigBrady.com>
parents:
18626
diff
changeset
|
368 } |
545a79f1cab7
nproc: support nested OMP_NUM_THREADS, and OMP_THREAD_LIMIT
Pádraig Brady <P@draigBrady.com>
parents:
18626
diff
changeset
|
369 |
11431 | 370 unsigned long int |
12231
03fb041aaee1
Make num_processors more flexible and consistent.
Bruno Haible <bruno@clisp.org>
parents:
12179
diff
changeset
|
371 num_processors (enum nproc_query query) |
11431 | 372 { |
18712
69b9a0733c37
nproc: adjust handling of OpenMP environment variables
Pádraig Brady <P@draigBrady.com>
parents:
18711
diff
changeset
|
373 unsigned long int omp_env_limit = ULONG_MAX; |
69b9a0733c37
nproc: adjust handling of OpenMP environment variables
Pádraig Brady <P@draigBrady.com>
parents:
18711
diff
changeset
|
374 |
12231
03fb041aaee1
Make num_processors more flexible and consistent.
Bruno Haible <bruno@clisp.org>
parents:
12179
diff
changeset
|
375 if (query == NPROC_CURRENT_OVERRIDABLE) |
03fb041aaee1
Make num_processors more flexible and consistent.
Bruno Haible <bruno@clisp.org>
parents:
12179
diff
changeset
|
376 { |
18711
545a79f1cab7
nproc: support nested OMP_NUM_THREADS, and OMP_THREAD_LIMIT
Pádraig Brady <P@draigBrady.com>
parents:
18626
diff
changeset
|
377 unsigned long int omp_env_threads; |
545a79f1cab7
nproc: support nested OMP_NUM_THREADS, and OMP_THREAD_LIMIT
Pádraig Brady <P@draigBrady.com>
parents:
18626
diff
changeset
|
378 /* Honor the OpenMP environment variables, recognized also by all |
545a79f1cab7
nproc: support nested OMP_NUM_THREADS, and OMP_THREAD_LIMIT
Pádraig Brady <P@draigBrady.com>
parents:
18626
diff
changeset
|
379 programs that are based on OpenMP. */ |
545a79f1cab7
nproc: support nested OMP_NUM_THREADS, and OMP_THREAD_LIMIT
Pádraig Brady <P@draigBrady.com>
parents:
18626
diff
changeset
|
380 omp_env_threads = parse_omp_threads (getenv ("OMP_NUM_THREADS")); |
18712
69b9a0733c37
nproc: adjust handling of OpenMP environment variables
Pádraig Brady <P@draigBrady.com>
parents:
18711
diff
changeset
|
381 omp_env_limit = parse_omp_threads (getenv ("OMP_THREAD_LIMIT")); |
69b9a0733c37
nproc: adjust handling of OpenMP environment variables
Pádraig Brady <P@draigBrady.com>
parents:
18711
diff
changeset
|
382 if (! omp_env_limit) |
69b9a0733c37
nproc: adjust handling of OpenMP environment variables
Pádraig Brady <P@draigBrady.com>
parents:
18711
diff
changeset
|
383 omp_env_limit = ULONG_MAX; |
69b9a0733c37
nproc: adjust handling of OpenMP environment variables
Pádraig Brady <P@draigBrady.com>
parents:
18711
diff
changeset
|
384 |
18711
545a79f1cab7
nproc: support nested OMP_NUM_THREADS, and OMP_THREAD_LIMIT
Pádraig Brady <P@draigBrady.com>
parents:
18626
diff
changeset
|
385 if (omp_env_threads) |
18712
69b9a0733c37
nproc: adjust handling of OpenMP environment variables
Pádraig Brady <P@draigBrady.com>
parents:
18711
diff
changeset
|
386 return MIN (omp_env_threads, omp_env_limit); |
12231
03fb041aaee1
Make num_processors more flexible and consistent.
Bruno Haible <bruno@clisp.org>
parents:
12179
diff
changeset
|
387 |
03fb041aaee1
Make num_processors more flexible and consistent.
Bruno Haible <bruno@clisp.org>
parents:
12179
diff
changeset
|
388 query = NPROC_CURRENT; |
03fb041aaee1
Make num_processors more flexible and consistent.
Bruno Haible <bruno@clisp.org>
parents:
12179
diff
changeset
|
389 } |
03fb041aaee1
Make num_processors more flexible and consistent.
Bruno Haible <bruno@clisp.org>
parents:
12179
diff
changeset
|
390 /* Here query is one of NPROC_ALL, NPROC_CURRENT. */ |
18713
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
391 { |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
392 unsigned long nprocs = num_processors_ignoring_omp (query); |
6ad5b6914d35
nproc: Refactor large function.
Bruno Haible <bruno@clisp.org>
parents:
18712
diff
changeset
|
393 return MIN (nprocs, omp_env_limit); |
12231
03fb041aaee1
Make num_processors more flexible and consistent.
Bruno Haible <bruno@clisp.org>
parents:
12179
diff
changeset
|
394 } |
11431 | 395 } |