Mercurial > hg > CbC > CbC_gcc
annotate libgomp/env.c @ 136:4627f235cf2a
fix c-next example
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 08 Nov 2018 14:11:56 +0900 |
parents | 84e7813d76e9 |
children | 1830386684a0 |
rev | line source |
---|---|
131 | 1 /* Copyright (C) 2005-2018 Free Software Foundation, Inc. |
0 | 2 Contributed by Richard Henderson <rth@redhat.com>. |
3 | |
111 | 4 This file is part of the GNU Offloading and Multi Processing Library |
5 (libgomp). | |
0 | 6 |
7 Libgomp is free software; you can redistribute it and/or modify it | |
8 under the terms of the GNU General Public License as published by | |
9 the Free Software Foundation; either version 3, or (at your option) | |
10 any later version. | |
11 | |
12 Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY | |
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
14 FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
15 more details. | |
16 | |
17 Under Section 7 of GPL version 3, you are granted additional | |
18 permissions described in the GCC Runtime Library Exception, version | |
19 3.1, as published by the Free Software Foundation. | |
20 | |
21 You should have received a copy of the GNU General Public License and | |
22 a copy of the GCC Runtime Library Exception along with this program; | |
23 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see | |
24 <http://www.gnu.org/licenses/>. */ | |
25 | |
111 | 26 /* This file defines the OpenMP internal control variables and arranges |
0 | 27 for them to be initialized from environment variables at startup. */ |
28 | |
111 | 29 #define _GNU_SOURCE |
0 | 30 #include "libgomp.h" |
111 | 31 #include "gomp-constants.h" |
32 #include <limits.h> | |
33 #ifndef LIBGOMP_OFFLOADED_ONLY | |
0 | 34 #include "libgomp_f.h" |
111 | 35 #include "oacc-int.h" |
0 | 36 #include <ctype.h> |
37 #include <stdlib.h> | |
111 | 38 #include <stdio.h> |
39 #ifdef HAVE_INTTYPES_H | |
40 # include <inttypes.h> /* For PRIu64. */ | |
41 #endif | |
0 | 42 #ifdef STRING_WITH_STRINGS |
43 # include <string.h> | |
44 # include <strings.h> | |
45 #else | |
46 # ifdef HAVE_STRING_H | |
47 # include <string.h> | |
48 # else | |
49 # ifdef HAVE_STRINGS_H | |
50 # include <strings.h> | |
51 # endif | |
52 # endif | |
53 #endif | |
54 #include <errno.h> | |
111 | 55 #include "thread-stacksize.h" |
0 | 56 |
57 #ifndef HAVE_STRTOULL | |
58 # define strtoull(ptr, eptr, base) strtoul (ptr, eptr, base) | |
59 #endif | |
111 | 60 #endif /* LIBGOMP_OFFLOADED_ONLY */ |
61 | |
62 #include "secure_getenv.h" | |
0 | 63 |
64 struct gomp_task_icv gomp_global_icv = { | |
65 .nthreads_var = 1, | |
111 | 66 .thread_limit_var = UINT_MAX, |
0 | 67 .run_sched_var = GFS_DYNAMIC, |
111 | 68 .run_sched_chunk_size = 1, |
69 .default_device_var = 0, | |
0 | 70 .dyn_var = false, |
111 | 71 .nest_var = false, |
72 .bind_var = omp_proc_bind_false, | |
73 .target_data = NULL | |
0 | 74 }; |
75 | |
76 unsigned long gomp_max_active_levels_var = INT_MAX; | |
111 | 77 bool gomp_cancel_var = false; |
78 int gomp_max_task_priority_var = 0; | |
0 | 79 #ifndef HAVE_SYNC_BUILTINS |
111 | 80 gomp_mutex_t gomp_managed_threads_lock; |
0 | 81 #endif |
82 unsigned long gomp_available_cpus = 1, gomp_managed_threads = 1; | |
83 unsigned long long gomp_spin_count_var, gomp_throttled_spin_count_var; | |
111 | 84 unsigned long *gomp_nthreads_var_list, gomp_nthreads_var_list_len; |
85 char *gomp_bind_var_list; | |
86 unsigned long gomp_bind_var_list_len; | |
87 void **gomp_places_list; | |
88 unsigned long gomp_places_list_len; | |
89 int gomp_debug_var; | |
90 unsigned int gomp_num_teams_var; | |
91 char *goacc_device_type; | |
92 int goacc_device_num; | |
131 | 93 int goacc_default_dims[GOMP_DIM_MAX]; |
111 | 94 |
95 #ifndef LIBGOMP_OFFLOADED_ONLY | |
0 | 96 |
97 /* Parse the OMP_SCHEDULE environment variable. */ | |
98 | |
99 static void | |
100 parse_schedule (void) | |
101 { | |
102 char *env, *end; | |
103 unsigned long value; | |
104 | |
105 env = getenv ("OMP_SCHEDULE"); | |
106 if (env == NULL) | |
107 return; | |
108 | |
109 while (isspace ((unsigned char) *env)) | |
110 ++env; | |
111 if (strncasecmp (env, "static", 6) == 0) | |
112 { | |
113 gomp_global_icv.run_sched_var = GFS_STATIC; | |
114 env += 6; | |
115 } | |
116 else if (strncasecmp (env, "dynamic", 7) == 0) | |
117 { | |
118 gomp_global_icv.run_sched_var = GFS_DYNAMIC; | |
119 env += 7; | |
120 } | |
121 else if (strncasecmp (env, "guided", 6) == 0) | |
122 { | |
123 gomp_global_icv.run_sched_var = GFS_GUIDED; | |
124 env += 6; | |
125 } | |
126 else if (strncasecmp (env, "auto", 4) == 0) | |
127 { | |
128 gomp_global_icv.run_sched_var = GFS_AUTO; | |
129 env += 4; | |
130 } | |
131 else | |
132 goto unknown; | |
133 | |
134 while (isspace ((unsigned char) *env)) | |
135 ++env; | |
136 if (*env == '\0') | |
111 | 137 { |
138 gomp_global_icv.run_sched_chunk_size | |
139 = gomp_global_icv.run_sched_var != GFS_STATIC; | |
140 return; | |
141 } | |
0 | 142 if (*env++ != ',') |
143 goto unknown; | |
144 while (isspace ((unsigned char) *env)) | |
145 ++env; | |
146 if (*env == '\0') | |
147 goto invalid; | |
148 | |
149 errno = 0; | |
150 value = strtoul (env, &end, 10); | |
151 if (errno) | |
152 goto invalid; | |
153 | |
154 while (isspace ((unsigned char) *end)) | |
155 ++end; | |
156 if (*end != '\0') | |
157 goto invalid; | |
158 | |
159 if ((int)value != value) | |
160 goto invalid; | |
161 | |
111 | 162 if (value == 0 && gomp_global_icv.run_sched_var != GFS_STATIC) |
163 value = 1; | |
164 gomp_global_icv.run_sched_chunk_size = value; | |
0 | 165 return; |
166 | |
167 unknown: | |
168 gomp_error ("Unknown value for environment variable OMP_SCHEDULE"); | |
169 return; | |
170 | |
171 invalid: | |
172 gomp_error ("Invalid value for chunk size in " | |
173 "environment variable OMP_SCHEDULE"); | |
174 return; | |
175 } | |
176 | |
177 /* Parse an unsigned long environment variable. Return true if one was | |
111 | 178 present and it was successfully parsed. If SECURE, use secure_getenv to the |
179 environment variable. */ | |
0 | 180 |
181 static bool | |
111 | 182 parse_unsigned_long_1 (const char *name, unsigned long *pvalue, bool allow_zero, |
183 bool secure) | |
0 | 184 { |
185 char *env, *end; | |
186 unsigned long value; | |
187 | |
111 | 188 env = (secure ? secure_getenv (name) : getenv (name)); |
0 | 189 if (env == NULL) |
190 return false; | |
191 | |
192 while (isspace ((unsigned char) *env)) | |
193 ++env; | |
194 if (*env == '\0') | |
195 goto invalid; | |
196 | |
197 errno = 0; | |
198 value = strtoul (env, &end, 10); | |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
199 if (errno || (long) value <= 0 - allow_zero) |
0 | 200 goto invalid; |
201 | |
202 while (isspace ((unsigned char) *end)) | |
203 ++end; | |
204 if (*end != '\0') | |
205 goto invalid; | |
206 | |
207 *pvalue = value; | |
208 return true; | |
209 | |
210 invalid: | |
211 gomp_error ("Invalid value for environment variable %s", name); | |
212 return false; | |
213 } | |
214 | |
111 | 215 /* As parse_unsigned_long_1, but always use getenv. */ |
216 | |
217 static bool | |
218 parse_unsigned_long (const char *name, unsigned long *pvalue, bool allow_zero) | |
219 { | |
220 return parse_unsigned_long_1 (name, pvalue, allow_zero, false); | |
221 } | |
222 | |
223 /* Parse a positive int environment variable. Return true if one was | |
224 present and it was successfully parsed. If SECURE, use secure_getenv to the | |
225 environment variable. */ | |
226 | |
227 static bool | |
228 parse_int_1 (const char *name, int *pvalue, bool allow_zero, bool secure) | |
229 { | |
230 unsigned long value; | |
231 if (!parse_unsigned_long_1 (name, &value, allow_zero, secure)) | |
232 return false; | |
233 if (value > INT_MAX) | |
234 { | |
235 gomp_error ("Invalid value for environment variable %s", name); | |
236 return false; | |
237 } | |
238 *pvalue = (int) value; | |
239 return true; | |
240 } | |
241 | |
242 /* As parse_int_1, but use getenv. */ | |
243 | |
244 static bool | |
245 parse_int (const char *name, int *pvalue, bool allow_zero) | |
246 { | |
247 return parse_int_1 (name, pvalue, allow_zero, false); | |
248 } | |
249 | |
250 /* As parse_int_1, but use getenv_secure. */ | |
251 | |
252 static bool | |
253 parse_int_secure (const char *name, int *pvalue, bool allow_zero) | |
254 { | |
255 return parse_int_1 (name, pvalue, allow_zero, true); | |
256 } | |
257 | |
258 /* Parse an unsigned long list environment variable. Return true if one was | |
259 present and it was successfully parsed. */ | |
260 | |
261 static bool | |
262 parse_unsigned_long_list (const char *name, unsigned long *p1stvalue, | |
263 unsigned long **pvalues, | |
264 unsigned long *pnvalues) | |
265 { | |
266 char *env, *end; | |
267 unsigned long value, *values = NULL; | |
268 | |
269 env = getenv (name); | |
270 if (env == NULL) | |
271 return false; | |
272 | |
273 while (isspace ((unsigned char) *env)) | |
274 ++env; | |
275 if (*env == '\0') | |
276 goto invalid; | |
277 | |
278 errno = 0; | |
279 value = strtoul (env, &end, 10); | |
280 if (errno || (long) value <= 0) | |
281 goto invalid; | |
282 | |
283 while (isspace ((unsigned char) *end)) | |
284 ++end; | |
285 if (*end != '\0') | |
286 { | |
287 if (*end == ',') | |
288 { | |
289 unsigned long nvalues = 0, nalloced = 0; | |
290 | |
291 do | |
292 { | |
293 env = end + 1; | |
294 if (nvalues == nalloced) | |
295 { | |
296 unsigned long *n; | |
297 nalloced = nalloced ? nalloced * 2 : 16; | |
298 n = realloc (values, nalloced * sizeof (unsigned long)); | |
299 if (n == NULL) | |
300 { | |
301 free (values); | |
302 gomp_error ("Out of memory while trying to parse" | |
303 " environment variable %s", name); | |
304 return false; | |
305 } | |
306 values = n; | |
307 if (nvalues == 0) | |
308 values[nvalues++] = value; | |
309 } | |
310 | |
311 while (isspace ((unsigned char) *env)) | |
312 ++env; | |
313 if (*env == '\0') | |
314 goto invalid; | |
315 | |
316 errno = 0; | |
317 value = strtoul (env, &end, 10); | |
318 if (errno || (long) value <= 0) | |
319 goto invalid; | |
320 | |
321 values[nvalues++] = value; | |
322 while (isspace ((unsigned char) *end)) | |
323 ++end; | |
324 if (*end == '\0') | |
325 break; | |
326 if (*end != ',') | |
327 goto invalid; | |
328 } | |
329 while (1); | |
330 *p1stvalue = values[0]; | |
331 *pvalues = values; | |
332 *pnvalues = nvalues; | |
333 return true; | |
334 } | |
335 goto invalid; | |
336 } | |
337 | |
338 *p1stvalue = value; | |
339 return true; | |
340 | |
341 invalid: | |
342 free (values); | |
343 gomp_error ("Invalid value for environment variable %s", name); | |
344 return false; | |
345 } | |
346 | |
347 /* Parse environment variable set to a boolean or list of omp_proc_bind_t | |
348 enum values. Return true if one was present and it was successfully | |
349 parsed. */ | |
350 | |
351 static bool | |
352 parse_bind_var (const char *name, char *p1stvalue, | |
353 char **pvalues, unsigned long *pnvalues) | |
354 { | |
355 char *env; | |
356 char value = omp_proc_bind_false, *values = NULL; | |
357 int i; | |
358 static struct proc_bind_kinds | |
359 { | |
360 const char name[7]; | |
361 const char len; | |
362 omp_proc_bind_t kind; | |
363 } kinds[] = | |
364 { | |
365 { "false", 5, omp_proc_bind_false }, | |
366 { "true", 4, omp_proc_bind_true }, | |
367 { "master", 6, omp_proc_bind_master }, | |
368 { "close", 5, omp_proc_bind_close }, | |
369 { "spread", 6, omp_proc_bind_spread } | |
370 }; | |
371 | |
372 env = getenv (name); | |
373 if (env == NULL) | |
374 return false; | |
375 | |
376 while (isspace ((unsigned char) *env)) | |
377 ++env; | |
378 if (*env == '\0') | |
379 goto invalid; | |
380 | |
381 for (i = 0; i < 5; i++) | |
382 if (strncasecmp (env, kinds[i].name, kinds[i].len) == 0) | |
383 { | |
384 value = kinds[i].kind; | |
385 env += kinds[i].len; | |
386 break; | |
387 } | |
388 if (i == 5) | |
389 goto invalid; | |
390 | |
391 while (isspace ((unsigned char) *env)) | |
392 ++env; | |
393 if (*env != '\0') | |
394 { | |
395 if (*env == ',') | |
396 { | |
397 unsigned long nvalues = 0, nalloced = 0; | |
398 | |
399 if (value == omp_proc_bind_false | |
400 || value == omp_proc_bind_true) | |
401 goto invalid; | |
402 | |
403 do | |
404 { | |
405 env++; | |
406 if (nvalues == nalloced) | |
407 { | |
408 char *n; | |
409 nalloced = nalloced ? nalloced * 2 : 16; | |
410 n = realloc (values, nalloced); | |
411 if (n == NULL) | |
412 { | |
413 free (values); | |
414 gomp_error ("Out of memory while trying to parse" | |
415 " environment variable %s", name); | |
416 return false; | |
417 } | |
418 values = n; | |
419 if (nvalues == 0) | |
420 values[nvalues++] = value; | |
421 } | |
422 | |
423 while (isspace ((unsigned char) *env)) | |
424 ++env; | |
425 if (*env == '\0') | |
426 goto invalid; | |
427 | |
428 for (i = 2; i < 5; i++) | |
429 if (strncasecmp (env, kinds[i].name, kinds[i].len) == 0) | |
430 { | |
431 value = kinds[i].kind; | |
432 env += kinds[i].len; | |
433 break; | |
434 } | |
435 if (i == 5) | |
436 goto invalid; | |
437 | |
438 values[nvalues++] = value; | |
439 while (isspace ((unsigned char) *env)) | |
440 ++env; | |
441 if (*env == '\0') | |
442 break; | |
443 if (*env != ',') | |
444 goto invalid; | |
445 } | |
446 while (1); | |
447 *p1stvalue = values[0]; | |
448 *pvalues = values; | |
449 *pnvalues = nvalues; | |
450 return true; | |
451 } | |
452 goto invalid; | |
453 } | |
454 | |
455 *p1stvalue = value; | |
456 return true; | |
457 | |
458 invalid: | |
459 free (values); | |
460 gomp_error ("Invalid value for environment variable %s", name); | |
461 return false; | |
462 } | |
463 | |
464 static bool | |
465 parse_one_place (char **envp, bool *negatep, unsigned long *lenp, | |
466 long *stridep) | |
467 { | |
468 char *env = *envp, *start; | |
469 void *p = gomp_places_list ? gomp_places_list[gomp_places_list_len] : NULL; | |
470 unsigned long len = 1; | |
471 long stride = 1; | |
472 int pass; | |
473 bool any_negate = false; | |
474 *negatep = false; | |
475 while (isspace ((unsigned char) *env)) | |
476 ++env; | |
477 if (*env == '!') | |
478 { | |
479 *negatep = true; | |
480 ++env; | |
481 while (isspace ((unsigned char) *env)) | |
482 ++env; | |
483 } | |
484 if (*env != '{') | |
485 return false; | |
486 ++env; | |
487 while (isspace ((unsigned char) *env)) | |
488 ++env; | |
489 start = env; | |
490 for (pass = 0; pass < (any_negate ? 2 : 1); pass++) | |
491 { | |
492 env = start; | |
493 do | |
494 { | |
495 unsigned long this_num, this_len = 1; | |
496 long this_stride = 1; | |
497 bool this_negate = (*env == '!'); | |
498 if (this_negate) | |
499 { | |
500 if (gomp_places_list) | |
501 any_negate = true; | |
502 ++env; | |
503 while (isspace ((unsigned char) *env)) | |
504 ++env; | |
505 } | |
506 | |
507 errno = 0; | |
508 this_num = strtoul (env, &env, 10); | |
509 if (errno) | |
510 return false; | |
511 while (isspace ((unsigned char) *env)) | |
512 ++env; | |
513 if (*env == ':') | |
514 { | |
515 ++env; | |
516 while (isspace ((unsigned char) *env)) | |
517 ++env; | |
518 errno = 0; | |
519 this_len = strtoul (env, &env, 10); | |
520 if (errno || this_len == 0) | |
521 return false; | |
522 while (isspace ((unsigned char) *env)) | |
523 ++env; | |
524 if (*env == ':') | |
525 { | |
526 ++env; | |
527 while (isspace ((unsigned char) *env)) | |
528 ++env; | |
529 errno = 0; | |
530 this_stride = strtol (env, &env, 10); | |
531 if (errno) | |
532 return false; | |
533 while (isspace ((unsigned char) *env)) | |
534 ++env; | |
535 } | |
536 } | |
537 if (this_negate && this_len != 1) | |
538 return false; | |
539 if (gomp_places_list && pass == this_negate) | |
540 { | |
541 if (this_negate) | |
542 { | |
543 if (!gomp_affinity_remove_cpu (p, this_num)) | |
544 return false; | |
545 } | |
546 else if (!gomp_affinity_add_cpus (p, this_num, this_len, | |
547 this_stride, false)) | |
548 return false; | |
549 } | |
550 if (*env == '}') | |
551 break; | |
552 if (*env != ',') | |
553 return false; | |
554 ++env; | |
555 } | |
556 while (1); | |
557 } | |
558 | |
559 ++env; | |
560 while (isspace ((unsigned char) *env)) | |
561 ++env; | |
562 if (*env == ':') | |
563 { | |
564 ++env; | |
565 while (isspace ((unsigned char) *env)) | |
566 ++env; | |
567 errno = 0; | |
568 len = strtoul (env, &env, 10); | |
569 if (errno || len == 0 || len >= 65536) | |
570 return false; | |
571 while (isspace ((unsigned char) *env)) | |
572 ++env; | |
573 if (*env == ':') | |
574 { | |
575 ++env; | |
576 while (isspace ((unsigned char) *env)) | |
577 ++env; | |
578 errno = 0; | |
579 stride = strtol (env, &env, 10); | |
580 if (errno) | |
581 return false; | |
582 while (isspace ((unsigned char) *env)) | |
583 ++env; | |
584 } | |
585 } | |
586 if (*negatep && len != 1) | |
587 return false; | |
588 *envp = env; | |
589 *lenp = len; | |
590 *stridep = stride; | |
591 return true; | |
592 } | |
593 | |
594 static bool | |
595 parse_places_var (const char *name, bool ignore) | |
596 { | |
597 char *env = getenv (name), *end; | |
598 bool any_negate = false; | |
599 int level = 0; | |
600 unsigned long count = 0; | |
601 if (env == NULL) | |
602 return false; | |
603 | |
604 while (isspace ((unsigned char) *env)) | |
605 ++env; | |
606 if (*env == '\0') | |
607 goto invalid; | |
608 | |
609 if (strncasecmp (env, "threads", 7) == 0) | |
610 { | |
611 env += 7; | |
612 level = 1; | |
613 } | |
614 else if (strncasecmp (env, "cores", 5) == 0) | |
615 { | |
616 env += 5; | |
617 level = 2; | |
618 } | |
619 else if (strncasecmp (env, "sockets", 7) == 0) | |
620 { | |
621 env += 7; | |
622 level = 3; | |
623 } | |
624 if (level) | |
625 { | |
626 count = ULONG_MAX; | |
627 while (isspace ((unsigned char) *env)) | |
628 ++env; | |
629 if (*env != '\0') | |
630 { | |
631 if (*env++ != '(') | |
632 goto invalid; | |
633 while (isspace ((unsigned char) *env)) | |
634 ++env; | |
635 | |
636 errno = 0; | |
637 count = strtoul (env, &end, 10); | |
638 if (errno) | |
639 goto invalid; | |
640 env = end; | |
641 while (isspace ((unsigned char) *env)) | |
642 ++env; | |
643 if (*env != ')') | |
644 goto invalid; | |
645 ++env; | |
646 while (isspace ((unsigned char) *env)) | |
647 ++env; | |
648 if (*env != '\0') | |
649 goto invalid; | |
650 } | |
651 | |
652 if (ignore) | |
653 return false; | |
654 | |
655 return gomp_affinity_init_level (level, count, false); | |
656 } | |
657 | |
658 count = 0; | |
659 end = env; | |
660 do | |
661 { | |
662 bool negate; | |
663 unsigned long len; | |
664 long stride; | |
665 if (!parse_one_place (&end, &negate, &len, &stride)) | |
666 goto invalid; | |
667 if (negate) | |
668 { | |
669 if (!any_negate) | |
670 count++; | |
671 any_negate = true; | |
672 } | |
673 else | |
674 count += len; | |
675 if (count > 65536) | |
676 goto invalid; | |
677 if (*end == '\0') | |
678 break; | |
679 if (*end != ',') | |
680 goto invalid; | |
681 end++; | |
682 } | |
683 while (1); | |
684 | |
685 if (ignore) | |
686 return false; | |
687 | |
688 gomp_places_list_len = 0; | |
689 gomp_places_list = gomp_affinity_alloc (count, false); | |
690 if (gomp_places_list == NULL) | |
691 return false; | |
692 | |
693 do | |
694 { | |
695 bool negate; | |
696 unsigned long len; | |
697 long stride; | |
698 gomp_affinity_init_place (gomp_places_list[gomp_places_list_len]); | |
699 if (!parse_one_place (&env, &negate, &len, &stride)) | |
700 goto invalid; | |
701 if (negate) | |
702 { | |
703 void *p; | |
704 for (count = 0; count < gomp_places_list_len; count++) | |
705 if (gomp_affinity_same_place | |
706 (gomp_places_list[count], | |
707 gomp_places_list[gomp_places_list_len])) | |
708 break; | |
709 if (count == gomp_places_list_len) | |
710 { | |
711 gomp_error ("Trying to remove a non-existing place from list " | |
712 "of places"); | |
713 goto invalid; | |
714 } | |
715 p = gomp_places_list[count]; | |
716 memmove (&gomp_places_list[count], | |
717 &gomp_places_list[count + 1], | |
718 (gomp_places_list_len - count - 1) * sizeof (void *)); | |
719 --gomp_places_list_len; | |
720 gomp_places_list[gomp_places_list_len] = p; | |
721 } | |
722 else if (len == 1) | |
723 ++gomp_places_list_len; | |
724 else | |
725 { | |
726 for (count = 0; count < len - 1; count++) | |
727 if (!gomp_affinity_copy_place | |
728 (gomp_places_list[gomp_places_list_len + count + 1], | |
729 gomp_places_list[gomp_places_list_len + count], | |
730 stride)) | |
731 goto invalid; | |
732 gomp_places_list_len += len; | |
733 } | |
734 if (*env == '\0') | |
735 break; | |
736 env++; | |
737 } | |
738 while (1); | |
739 | |
740 if (gomp_places_list_len == 0) | |
741 { | |
742 gomp_error ("All places have been removed"); | |
743 goto invalid; | |
744 } | |
745 if (!gomp_affinity_finalize_place_list (false)) | |
746 goto invalid; | |
747 return true; | |
748 | |
749 invalid: | |
750 free (gomp_places_list); | |
751 gomp_places_list = NULL; | |
752 gomp_places_list_len = 0; | |
753 gomp_error ("Invalid value for environment variable %s", name); | |
754 return false; | |
755 } | |
756 | |
0 | 757 /* Parse the OMP_STACKSIZE environment varible. Return true if one was |
758 present and it was successfully parsed. */ | |
759 | |
760 static bool | |
761 parse_stacksize (const char *name, unsigned long *pvalue) | |
762 { | |
763 char *env, *end; | |
764 unsigned long value, shift = 10; | |
765 | |
766 env = getenv (name); | |
767 if (env == NULL) | |
768 return false; | |
769 | |
770 while (isspace ((unsigned char) *env)) | |
771 ++env; | |
772 if (*env == '\0') | |
773 goto invalid; | |
774 | |
775 errno = 0; | |
776 value = strtoul (env, &end, 10); | |
777 if (errno) | |
778 goto invalid; | |
779 | |
780 while (isspace ((unsigned char) *end)) | |
781 ++end; | |
782 if (*end != '\0') | |
783 { | |
784 switch (tolower ((unsigned char) *end)) | |
785 { | |
786 case 'b': | |
787 shift = 0; | |
788 break; | |
789 case 'k': | |
790 break; | |
791 case 'm': | |
792 shift = 20; | |
793 break; | |
794 case 'g': | |
795 shift = 30; | |
796 break; | |
797 default: | |
798 goto invalid; | |
799 } | |
800 ++end; | |
801 while (isspace ((unsigned char) *end)) | |
802 ++end; | |
803 if (*end != '\0') | |
804 goto invalid; | |
805 } | |
806 | |
807 if (((value << shift) >> shift) != value) | |
808 goto invalid; | |
809 | |
810 *pvalue = value << shift; | |
811 return true; | |
812 | |
813 invalid: | |
814 gomp_error ("Invalid value for environment variable %s", name); | |
815 return false; | |
816 } | |
817 | |
818 /* Parse the GOMP_SPINCOUNT environment varible. Return true if one was | |
819 present and it was successfully parsed. */ | |
820 | |
821 static bool | |
822 parse_spincount (const char *name, unsigned long long *pvalue) | |
823 { | |
824 char *env, *end; | |
825 unsigned long long value, mult = 1; | |
826 | |
827 env = getenv (name); | |
828 if (env == NULL) | |
829 return false; | |
830 | |
831 while (isspace ((unsigned char) *env)) | |
832 ++env; | |
833 if (*env == '\0') | |
834 goto invalid; | |
835 | |
836 if (strncasecmp (env, "infinite", 8) == 0 | |
837 || strncasecmp (env, "infinity", 8) == 0) | |
838 { | |
839 value = ~0ULL; | |
840 end = env + 8; | |
841 goto check_tail; | |
842 } | |
843 | |
844 errno = 0; | |
845 value = strtoull (env, &end, 10); | |
846 if (errno) | |
847 goto invalid; | |
848 | |
849 while (isspace ((unsigned char) *end)) | |
850 ++end; | |
851 if (*end != '\0') | |
852 { | |
853 switch (tolower ((unsigned char) *end)) | |
854 { | |
855 case 'k': | |
856 mult = 1000LL; | |
857 break; | |
858 case 'm': | |
859 mult = 1000LL * 1000LL; | |
860 break; | |
861 case 'g': | |
862 mult = 1000LL * 1000LL * 1000LL; | |
863 break; | |
864 case 't': | |
865 mult = 1000LL * 1000LL * 1000LL * 1000LL; | |
866 break; | |
867 default: | |
868 goto invalid; | |
869 } | |
870 ++end; | |
871 check_tail: | |
872 while (isspace ((unsigned char) *end)) | |
873 ++end; | |
874 if (*end != '\0') | |
875 goto invalid; | |
876 } | |
877 | |
878 if (value > ~0ULL / mult) | |
879 value = ~0ULL; | |
880 else | |
881 value *= mult; | |
882 | |
883 *pvalue = value; | |
884 return true; | |
885 | |
886 invalid: | |
887 gomp_error ("Invalid value for environment variable %s", name); | |
888 return false; | |
889 } | |
890 | |
891 /* Parse a boolean value for environment variable NAME and store the | |
892 result in VALUE. */ | |
893 | |
894 static void | |
895 parse_boolean (const char *name, bool *value) | |
896 { | |
897 const char *env; | |
898 | |
899 env = getenv (name); | |
900 if (env == NULL) | |
901 return; | |
902 | |
903 while (isspace ((unsigned char) *env)) | |
904 ++env; | |
905 if (strncasecmp (env, "true", 4) == 0) | |
906 { | |
907 *value = true; | |
908 env += 4; | |
909 } | |
910 else if (strncasecmp (env, "false", 5) == 0) | |
911 { | |
912 *value = false; | |
913 env += 5; | |
914 } | |
915 else | |
916 env = "X"; | |
917 while (isspace ((unsigned char) *env)) | |
918 ++env; | |
919 if (*env != '\0') | |
920 gomp_error ("Invalid value for environment variable %s", name); | |
921 } | |
922 | |
923 /* Parse the OMP_WAIT_POLICY environment variable and store the | |
924 result in gomp_active_wait_policy. */ | |
925 | |
926 static int | |
927 parse_wait_policy (void) | |
928 { | |
929 const char *env; | |
930 int ret = -1; | |
931 | |
932 env = getenv ("OMP_WAIT_POLICY"); | |
933 if (env == NULL) | |
934 return -1; | |
935 | |
936 while (isspace ((unsigned char) *env)) | |
937 ++env; | |
938 if (strncasecmp (env, "active", 6) == 0) | |
939 { | |
940 ret = 1; | |
941 env += 6; | |
942 } | |
943 else if (strncasecmp (env, "passive", 7) == 0) | |
944 { | |
945 ret = 0; | |
946 env += 7; | |
947 } | |
948 else | |
949 env = "X"; | |
950 while (isspace ((unsigned char) *env)) | |
951 ++env; | |
952 if (*env == '\0') | |
953 return ret; | |
954 gomp_error ("Invalid value for environment variable OMP_WAIT_POLICY"); | |
955 return -1; | |
956 } | |
957 | |
958 /* Parse the GOMP_CPU_AFFINITY environment varible. Return true if one was | |
959 present and it was successfully parsed. */ | |
960 | |
961 static bool | |
111 | 962 parse_affinity (bool ignore) |
0 | 963 { |
111 | 964 char *env, *end, *start; |
965 int pass; | |
0 | 966 unsigned long cpu_beg, cpu_end, cpu_stride; |
111 | 967 size_t count = 0, needed; |
0 | 968 |
969 env = getenv ("GOMP_CPU_AFFINITY"); | |
970 if (env == NULL) | |
971 return false; | |
972 | |
111 | 973 start = env; |
974 for (pass = 0; pass < 2; pass++) | |
0 | 975 { |
111 | 976 env = start; |
977 if (pass == 1) | |
978 { | |
979 if (ignore) | |
980 return false; | |
0 | 981 |
111 | 982 gomp_places_list_len = 0; |
983 gomp_places_list = gomp_affinity_alloc (count, true); | |
984 if (gomp_places_list == NULL) | |
985 return false; | |
986 } | |
987 do | |
988 { | |
989 while (isspace ((unsigned char) *env)) | |
990 ++env; | |
0 | 991 |
111 | 992 errno = 0; |
993 cpu_beg = strtoul (env, &end, 0); | |
994 if (errno || cpu_beg >= 65536) | |
0 | 995 goto invalid; |
111 | 996 cpu_end = cpu_beg; |
997 cpu_stride = 1; | |
0 | 998 |
999 env = end; | |
111 | 1000 if (*env == '-') |
0 | 1001 { |
111 | 1002 errno = 0; |
1003 cpu_end = strtoul (++env, &end, 0); | |
1004 if (errno || cpu_end >= 65536 || cpu_end < cpu_beg) | |
0 | 1005 goto invalid; |
1006 | |
1007 env = end; | |
111 | 1008 if (*env == ':') |
1009 { | |
1010 errno = 0; | |
1011 cpu_stride = strtoul (++env, &end, 0); | |
1012 if (errno || cpu_stride == 0 || cpu_stride >= 65536) | |
1013 goto invalid; | |
0 | 1014 |
111 | 1015 env = end; |
1016 } | |
0 | 1017 } |
1018 | |
111 | 1019 needed = (cpu_end - cpu_beg) / cpu_stride + 1; |
1020 if (pass == 0) | |
1021 count += needed; | |
1022 else | |
1023 { | |
1024 while (needed--) | |
1025 { | |
1026 void *p = gomp_places_list[gomp_places_list_len]; | |
1027 gomp_affinity_init_place (p); | |
1028 if (gomp_affinity_add_cpus (p, cpu_beg, 1, 0, true)) | |
1029 ++gomp_places_list_len; | |
1030 cpu_beg += cpu_stride; | |
1031 } | |
1032 } | |
0 | 1033 |
111 | 1034 while (isspace ((unsigned char) *env)) |
1035 ++env; | |
0 | 1036 |
111 | 1037 if (*env == ',') |
1038 env++; | |
1039 else if (*env == '\0') | |
1040 break; | |
1041 } | |
1042 while (1); | |
0 | 1043 } |
1044 | |
111 | 1045 if (gomp_places_list_len == 0) |
1046 { | |
1047 free (gomp_places_list); | |
1048 gomp_places_list = NULL; | |
1049 return false; | |
1050 } | |
0 | 1051 return true; |
1052 | |
1053 invalid: | |
1054 gomp_error ("Invalid value for enviroment variable GOMP_CPU_AFFINITY"); | |
1055 return false; | |
1056 } | |
1057 | |
111 | 1058 static void |
1059 parse_acc_device_type (void) | |
1060 { | |
1061 const char *env = getenv ("ACC_DEVICE_TYPE"); | |
1062 | |
1063 if (env && *env != '\0') | |
1064 goacc_device_type = strdup (env); | |
1065 else | |
1066 goacc_device_type = NULL; | |
1067 } | |
1068 | |
1069 static void | |
131 | 1070 parse_gomp_openacc_dim (void) |
1071 { | |
1072 /* The syntax is the same as for the -fopenacc-dim compilation option. */ | |
1073 const char *var_name = "GOMP_OPENACC_DIM"; | |
1074 const char *env_var = getenv (var_name); | |
1075 if (!env_var) | |
1076 return; | |
1077 | |
1078 const char *pos = env_var; | |
1079 int i; | |
1080 for (i = 0; *pos && i != GOMP_DIM_MAX; i++) | |
1081 { | |
1082 if (i && *pos++ != ':') | |
1083 break; | |
1084 | |
1085 if (*pos == ':') | |
1086 continue; | |
1087 | |
1088 const char *eptr; | |
1089 errno = 0; | |
1090 long val = strtol (pos, (char **)&eptr, 10); | |
1091 if (errno || val < 0 || (unsigned)val != val) | |
1092 break; | |
1093 | |
1094 goacc_default_dims[i] = (int)val; | |
1095 pos = eptr; | |
1096 } | |
1097 } | |
1098 | |
1099 static void | |
111 | 1100 handle_omp_display_env (unsigned long stacksize, int wait_policy) |
1101 { | |
1102 const char *env; | |
1103 bool display = false; | |
1104 bool verbose = false; | |
1105 int i; | |
1106 | |
1107 env = getenv ("OMP_DISPLAY_ENV"); | |
1108 if (env == NULL) | |
1109 return; | |
1110 | |
1111 while (isspace ((unsigned char) *env)) | |
1112 ++env; | |
1113 if (strncasecmp (env, "true", 4) == 0) | |
1114 { | |
1115 display = true; | |
1116 env += 4; | |
1117 } | |
1118 else if (strncasecmp (env, "false", 5) == 0) | |
1119 { | |
1120 display = false; | |
1121 env += 5; | |
1122 } | |
1123 else if (strncasecmp (env, "verbose", 7) == 0) | |
1124 { | |
1125 display = true; | |
1126 verbose = true; | |
1127 env += 7; | |
1128 } | |
1129 else | |
1130 env = "X"; | |
1131 while (isspace ((unsigned char) *env)) | |
1132 ++env; | |
1133 if (*env != '\0') | |
1134 gomp_error ("Invalid value for environment variable OMP_DISPLAY_ENV"); | |
1135 | |
1136 if (!display) | |
1137 return; | |
1138 | |
1139 fputs ("\nOPENMP DISPLAY ENVIRONMENT BEGIN\n", stderr); | |
1140 | |
1141 fputs (" _OPENMP = '201511'\n", stderr); | |
1142 fprintf (stderr, " OMP_DYNAMIC = '%s'\n", | |
1143 gomp_global_icv.dyn_var ? "TRUE" : "FALSE"); | |
1144 fprintf (stderr, " OMP_NESTED = '%s'\n", | |
1145 gomp_global_icv.nest_var ? "TRUE" : "FALSE"); | |
1146 | |
1147 fprintf (stderr, " OMP_NUM_THREADS = '%lu", gomp_global_icv.nthreads_var); | |
1148 for (i = 1; i < gomp_nthreads_var_list_len; i++) | |
1149 fprintf (stderr, ",%lu", gomp_nthreads_var_list[i]); | |
1150 fputs ("'\n", stderr); | |
1151 | |
1152 fprintf (stderr, " OMP_SCHEDULE = '"); | |
1153 switch (gomp_global_icv.run_sched_var) | |
1154 { | |
1155 case GFS_RUNTIME: | |
1156 fputs ("RUNTIME", stderr); | |
1157 break; | |
1158 case GFS_STATIC: | |
1159 fputs ("STATIC", stderr); | |
1160 break; | |
1161 case GFS_DYNAMIC: | |
1162 fputs ("DYNAMIC", stderr); | |
1163 break; | |
1164 case GFS_GUIDED: | |
1165 fputs ("GUIDED", stderr); | |
1166 break; | |
1167 case GFS_AUTO: | |
1168 fputs ("AUTO", stderr); | |
1169 break; | |
1170 } | |
1171 fputs ("'\n", stderr); | |
1172 | |
1173 fputs (" OMP_PROC_BIND = '", stderr); | |
1174 switch (gomp_global_icv.bind_var) | |
1175 { | |
1176 case omp_proc_bind_false: | |
1177 fputs ("FALSE", stderr); | |
1178 break; | |
1179 case omp_proc_bind_true: | |
1180 fputs ("TRUE", stderr); | |
1181 break; | |
1182 case omp_proc_bind_master: | |
1183 fputs ("MASTER", stderr); | |
1184 break; | |
1185 case omp_proc_bind_close: | |
1186 fputs ("CLOSE", stderr); | |
1187 break; | |
1188 case omp_proc_bind_spread: | |
1189 fputs ("SPREAD", stderr); | |
1190 break; | |
1191 } | |
1192 for (i = 1; i < gomp_bind_var_list_len; i++) | |
1193 switch (gomp_bind_var_list[i]) | |
1194 { | |
1195 case omp_proc_bind_master: | |
1196 fputs (",MASTER", stderr); | |
1197 break; | |
1198 case omp_proc_bind_close: | |
1199 fputs (",CLOSE", stderr); | |
1200 break; | |
1201 case omp_proc_bind_spread: | |
1202 fputs (",SPREAD", stderr); | |
1203 break; | |
1204 } | |
1205 fputs ("'\n", stderr); | |
1206 fputs (" OMP_PLACES = '", stderr); | |
1207 for (i = 0; i < gomp_places_list_len; i++) | |
1208 { | |
1209 fputs ("{", stderr); | |
1210 gomp_affinity_print_place (gomp_places_list[i]); | |
1211 fputs (i + 1 == gomp_places_list_len ? "}" : "},", stderr); | |
1212 } | |
1213 fputs ("'\n", stderr); | |
1214 | |
1215 fprintf (stderr, " OMP_STACKSIZE = '%lu'\n", stacksize); | |
1216 | |
1217 /* GOMP's default value is actually neither active nor passive. */ | |
1218 fprintf (stderr, " OMP_WAIT_POLICY = '%s'\n", | |
1219 wait_policy > 0 ? "ACTIVE" : "PASSIVE"); | |
1220 fprintf (stderr, " OMP_THREAD_LIMIT = '%u'\n", | |
1221 gomp_global_icv.thread_limit_var); | |
1222 fprintf (stderr, " OMP_MAX_ACTIVE_LEVELS = '%lu'\n", | |
1223 gomp_max_active_levels_var); | |
1224 | |
1225 fprintf (stderr, " OMP_CANCELLATION = '%s'\n", | |
1226 gomp_cancel_var ? "TRUE" : "FALSE"); | |
1227 fprintf (stderr, " OMP_DEFAULT_DEVICE = '%d'\n", | |
1228 gomp_global_icv.default_device_var); | |
1229 fprintf (stderr, " OMP_MAX_TASK_PRIORITY = '%d'\n", | |
1230 gomp_max_task_priority_var); | |
1231 | |
1232 if (verbose) | |
1233 { | |
1234 fputs (" GOMP_CPU_AFFINITY = ''\n", stderr); | |
1235 fprintf (stderr, " GOMP_STACKSIZE = '%lu'\n", stacksize); | |
1236 #ifdef HAVE_INTTYPES_H | |
1237 fprintf (stderr, " GOMP_SPINCOUNT = '%"PRIu64"'\n", | |
1238 (uint64_t) gomp_spin_count_var); | |
1239 #else | |
1240 fprintf (stderr, " GOMP_SPINCOUNT = '%lu'\n", | |
1241 (unsigned long) gomp_spin_count_var); | |
1242 #endif | |
1243 } | |
1244 | |
1245 fputs ("OPENMP DISPLAY ENVIRONMENT END\n", stderr); | |
1246 } | |
1247 | |
1248 | |
0 | 1249 static void __attribute__((constructor)) |
1250 initialize_env (void) | |
1251 { | |
111 | 1252 unsigned long thread_limit_var, stacksize = GOMP_DEFAULT_STACKSIZE; |
0 | 1253 int wait_policy; |
1254 | |
1255 /* Do a compile time check that mkomp_h.pl did good job. */ | |
1256 omp_check_defines (); | |
1257 | |
1258 parse_schedule (); | |
1259 parse_boolean ("OMP_DYNAMIC", &gomp_global_icv.dyn_var); | |
1260 parse_boolean ("OMP_NESTED", &gomp_global_icv.nest_var); | |
111 | 1261 parse_boolean ("OMP_CANCELLATION", &gomp_cancel_var); |
1262 parse_int ("OMP_DEFAULT_DEVICE", &gomp_global_icv.default_device_var, true); | |
1263 parse_int ("OMP_MAX_TASK_PRIORITY", &gomp_max_task_priority_var, true); | |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1264 parse_unsigned_long ("OMP_MAX_ACTIVE_LEVELS", &gomp_max_active_levels_var, |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1265 true); |
111 | 1266 if (parse_unsigned_long ("OMP_THREAD_LIMIT", &thread_limit_var, false)) |
1267 { | |
1268 gomp_global_icv.thread_limit_var | |
1269 = thread_limit_var > INT_MAX ? UINT_MAX : thread_limit_var; | |
1270 } | |
1271 parse_int_secure ("GOMP_DEBUG", &gomp_debug_var, true); | |
0 | 1272 #ifndef HAVE_SYNC_BUILTINS |
111 | 1273 gomp_mutex_init (&gomp_managed_threads_lock); |
0 | 1274 #endif |
1275 gomp_init_num_threads (); | |
1276 gomp_available_cpus = gomp_global_icv.nthreads_var; | |
111 | 1277 if (!parse_unsigned_long_list ("OMP_NUM_THREADS", |
1278 &gomp_global_icv.nthreads_var, | |
1279 &gomp_nthreads_var_list, | |
1280 &gomp_nthreads_var_list_len)) | |
0 | 1281 gomp_global_icv.nthreads_var = gomp_available_cpus; |
111 | 1282 bool ignore = false; |
1283 if (parse_bind_var ("OMP_PROC_BIND", | |
1284 &gomp_global_icv.bind_var, | |
1285 &gomp_bind_var_list, | |
1286 &gomp_bind_var_list_len) | |
1287 && gomp_global_icv.bind_var == omp_proc_bind_false) | |
1288 ignore = true; | |
1289 /* Make sure OMP_PLACES and GOMP_CPU_AFFINITY env vars are always | |
1290 parsed if present in the environment. If OMP_PROC_BIND was set | |
1291 explictly to false, don't populate places list though. If places | |
1292 list was successfully set from OMP_PLACES, only parse but don't process | |
1293 GOMP_CPU_AFFINITY. If OMP_PROC_BIND was not set in the environment, | |
1294 default to OMP_PROC_BIND=true if OMP_PLACES or GOMP_CPU_AFFINITY | |
1295 was successfully parsed into a places list, otherwise to | |
1296 OMP_PROC_BIND=false. */ | |
1297 if (parse_places_var ("OMP_PLACES", ignore)) | |
1298 { | |
1299 if (gomp_global_icv.bind_var == omp_proc_bind_false) | |
1300 gomp_global_icv.bind_var = true; | |
1301 ignore = true; | |
1302 } | |
1303 if (parse_affinity (ignore)) | |
1304 { | |
1305 if (gomp_global_icv.bind_var == omp_proc_bind_false) | |
1306 gomp_global_icv.bind_var = true; | |
1307 ignore = true; | |
1308 } | |
1309 if (gomp_global_icv.bind_var != omp_proc_bind_false) | |
0 | 1310 gomp_init_affinity (); |
1311 wait_policy = parse_wait_policy (); | |
1312 if (!parse_spincount ("GOMP_SPINCOUNT", &gomp_spin_count_var)) | |
1313 { | |
1314 /* Using a rough estimation of 100000 spins per msec, | |
1315 use 5 min blocking for OMP_WAIT_POLICY=active, | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1316 3 msec blocking when OMP_WAIT_POLICY is not specificed |
0 | 1317 and 0 when OMP_WAIT_POLICY=passive. |
1318 Depending on the CPU speed, this can be e.g. 5 times longer | |
1319 or 5 times shorter. */ | |
1320 if (wait_policy > 0) | |
1321 gomp_spin_count_var = 30000000000LL; | |
1322 else if (wait_policy < 0) | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1323 gomp_spin_count_var = 300000LL; |
0 | 1324 } |
1325 /* gomp_throttled_spin_count_var is used when there are more libgomp | |
1326 managed threads than available CPUs. Use very short spinning. */ | |
1327 if (wait_policy > 0) | |
1328 gomp_throttled_spin_count_var = 1000LL; | |
1329 else if (wait_policy < 0) | |
1330 gomp_throttled_spin_count_var = 100LL; | |
1331 if (gomp_throttled_spin_count_var > gomp_spin_count_var) | |
1332 gomp_throttled_spin_count_var = gomp_spin_count_var; | |
1333 | |
1334 /* Not strictly environment related, but ordering constructors is tricky. */ | |
1335 pthread_attr_init (&gomp_thread_attr); | |
1336 pthread_attr_setdetachstate (&gomp_thread_attr, PTHREAD_CREATE_DETACHED); | |
1337 | |
1338 if (parse_stacksize ("OMP_STACKSIZE", &stacksize) | |
111 | 1339 || parse_stacksize ("GOMP_STACKSIZE", &stacksize) |
1340 || GOMP_DEFAULT_STACKSIZE) | |
0 | 1341 { |
1342 int err; | |
1343 | |
1344 err = pthread_attr_setstacksize (&gomp_thread_attr, stacksize); | |
1345 | |
1346 #ifdef PTHREAD_STACK_MIN | |
1347 if (err == EINVAL) | |
1348 { | |
1349 if (stacksize < PTHREAD_STACK_MIN) | |
1350 gomp_error ("Stack size less than minimum of %luk", | |
1351 PTHREAD_STACK_MIN / 1024ul | |
1352 + (PTHREAD_STACK_MIN % 1024 != 0)); | |
1353 else | |
1354 gomp_error ("Stack size larger than system limit"); | |
1355 } | |
1356 else | |
1357 #endif | |
1358 if (err != 0) | |
1359 gomp_error ("Stack size change failed: %s", strerror (err)); | |
1360 } | |
1361 | |
111 | 1362 handle_omp_display_env (stacksize, wait_policy); |
0 | 1363 |
111 | 1364 /* OpenACC. */ |
0 | 1365 |
111 | 1366 if (!parse_int ("ACC_DEVICE_NUM", &goacc_device_num, true)) |
1367 goacc_device_num = 0; | |
0 | 1368 |
111 | 1369 parse_acc_device_type (); |
131 | 1370 parse_gomp_openacc_dim (); |
0 | 1371 |
111 | 1372 goacc_runtime_initialize (); |
0 | 1373 } |
111 | 1374 #endif /* LIBGOMP_OFFLOADED_ONLY */ |