LLVM OpenMP
kmp_settings.cpp
Go to the documentation of this file.
1/*
2 * kmp_settings.cpp -- Initialize environment variables
3 */
4
5//===----------------------------------------------------------------------===//
6//
7// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
8// See https://llvm.org/LICENSE.txt for license information.
9// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
10//
11//===----------------------------------------------------------------------===//
12
13#include "kmp.h"
14#include "kmp_affinity.h"
15#include "kmp_atomic.h"
16#if KMP_USE_HIER_SCHED
17#include "kmp_dispatch_hier.h"
18#endif
19#include "kmp_environment.h"
20#include "kmp_i18n.h"
21#include "kmp_io.h"
22#include "kmp_itt.h"
23#include "kmp_lock.h"
24#include "kmp_settings.h"
25#include "kmp_str.h"
26#include "kmp_traits.h"
27#include "kmp_wrapper_getpid.h"
28#include <ctype.h> // toupper()
29#if OMPD_SUPPORT
30#include "ompd-specific.h"
31#endif
32
33static int __kmp_env_toPrint(char const *name, int flag);
34
35bool __kmp_env_format = 0; // 0 - old format; 1 - new format
36
37// -----------------------------------------------------------------------------
38// Helper string functions. Subject to move to kmp_str.
39
40#ifdef USE_LOAD_BALANCE
41static double __kmp_convert_to_double(char const *s) {
42 double result;
43
44 if (KMP_SSCANF(s, "%lf", &result) < 1) {
45 result = 0.0;
46 }
47
48 return result;
49}
50#endif
51
52#ifdef KMP_DEBUG
53static unsigned int __kmp_readstr_with_sentinel(char *dest, char const *src,
54 size_t len, char sentinel) {
55 unsigned int i;
56 for (i = 0; i < len; i++) {
57 if ((*src == '\0') || (*src == sentinel)) {
58 break;
59 }
60 *(dest++) = *(src++);
61 }
62 *dest = '\0';
63 return i;
64}
65#endif
66
67static int __kmp_match_with_sentinel(char const *a, char const *b, size_t len,
68 char sentinel) {
69 size_t l = 0;
70
71 if (a == NULL)
72 a = "";
73 if (b == NULL)
74 b = "";
75 while (*a && *b && *b != sentinel) {
76 char ca = *a, cb = *b;
77
78 if (ca >= 'a' && ca <= 'z')
79 ca -= 'a' - 'A';
80 if (cb >= 'a' && cb <= 'z')
81 cb -= 'a' - 'A';
82 if (ca != cb)
83 return FALSE;
84 ++l;
85 ++a;
86 ++b;
87 }
88 return l >= len;
89}
90
91// Expected usage:
92// token is the token to check for.
93// buf is the string being parsed.
94// *end returns the char after the end of the token.
95// it is not modified unless a match occurs.
96//
97// Example 1:
98//
99// if (__kmp_match_str("token", buf, *end) {
100// <do something>
101// buf = end;
102// }
103//
104// Example 2:
105//
106// if (__kmp_match_str("token", buf, *end) {
107// char *save = **end;
108// **end = sentinel;
109// <use any of the __kmp*_with_sentinel() functions>
110// **end = save;
111// buf = end;
112// }
113
114static int __kmp_match_str(char const *token, char const *buf,
115 const char **end) {
116
117 KMP_ASSERT(token != NULL);
118 KMP_ASSERT(buf != NULL);
119 KMP_ASSERT(end != NULL);
120
121 while (*token && *buf) {
122 char ct = *token, cb = *buf;
123
124 if (ct >= 'a' && ct <= 'z')
125 ct -= 'a' - 'A';
126 if (cb >= 'a' && cb <= 'z')
127 cb -= 'a' - 'A';
128 if (ct != cb)
129 return FALSE;
130 ++token;
131 ++buf;
132 }
133 if (*token) {
134 return FALSE;
135 }
136 *end = buf;
137 return TRUE;
138}
139
140#if KMP_OS_DARWIN
141static size_t __kmp_round4k(size_t size) {
142 size_t _4k = 4 * 1024;
143 if (size & (_4k - 1)) {
144 size &= ~(_4k - 1);
145 if (size <= KMP_SIZE_T_MAX - _4k) {
146 size += _4k; // Round up if there is no overflow.
147 }
148 }
149 return size;
150} // __kmp_round4k
151#endif
152
153static int __kmp_strcasecmp_with_sentinel(char const *a, char const *b,
154 char sentinel) {
155 if (a == NULL)
156 a = "";
157 if (b == NULL)
158 b = "";
159 while (*a && *b && *b != sentinel) {
160 char ca = *a, cb = *b;
161
162 if (ca >= 'a' && ca <= 'z')
163 ca -= 'a' - 'A';
164 if (cb >= 'a' && cb <= 'z')
165 cb -= 'a' - 'A';
166 if (ca != cb)
167 return (int)(unsigned char)*a - (int)(unsigned char)*b;
168 ++a;
169 ++b;
170 }
171 return *a ? (*b && *b != sentinel)
172 ? (int)(unsigned char)*a - (int)(unsigned char)*b
173 : 1
174 : (*b && *b != sentinel) ? -1
175 : 0;
176}
177
178// =============================================================================
179// Table structures and helper functions.
180
185
186typedef void (*kmp_stg_parse_func_t)(char const *name, char const *value,
187 void *data);
188typedef void (*kmp_stg_print_func_t)(kmp_str_buf_t *buffer, char const *name,
189 void *data);
190
192 char const *name; // Name of setting (environment variable).
193 kmp_stg_parse_func_t parse; // Parser function.
194 kmp_stg_print_func_t print; // Print function.
195 void *data; // Data passed to parser and printer.
196 int set; // Variable set during this "session"
197 // (__kmp_env_initialize() or kmp_set_defaults() call).
198 int defined; // Variable set in any "session".
199}; // struct __kmp_setting
200
202 size_t factor; // Default factor: 1 for KMP_STACKSIZE, 1024 for others.
203 kmp_setting_t **rivals; // Array of pointers to rivals (including itself).
204}; // struct __kmp_stg_ss_data
205
207 int omp; // 0 -- KMP_LIBRARY, 1 -- OMP_WAIT_POLICY.
208 kmp_setting_t **rivals; // Array of pointers to rivals (including itself).
209}; // struct __kmp_stg_wp_data
210
212 int force; // 0 -- KMP_DETERMINISTIC_REDUCTION, 1 -- KMP_FORCE_REDUCTION.
213 kmp_setting_t **rivals; // Array of pointers to rivals (including itself).
214}; // struct __kmp_stg_fr_data
215
216static int __kmp_stg_check_rivals( // 0 -- Ok, 1 -- errors found.
217 char const *name, // Name of variable.
218 char const *value, // Value of the variable.
219 kmp_setting_t **rivals // List of rival settings (must include current one).
220);
221
222// Helper struct that trims heading/trailing white spaces
225 kmp_trimmed_str_t(const char *str) {
227 size_t len = KMP_STRLEN(str);
228 if (len == 0)
229 return;
230 const char *begin = str;
231 const char *end = str + KMP_STRLEN(str) - 1;
232 SKIP_WS(begin);
233 while (begin < end && *end == ' ')
234 end--;
236 }
238 const char *get() { return buf.str; }
239};
240
241// -----------------------------------------------------------------------------
242// Helper parse functions.
243
244static void __kmp_stg_parse_bool(char const *name, char const *value,
245 int *out) {
247 *out = TRUE;
248 } else if (__kmp_str_match_false(value)) {
249 *out = FALSE;
250 } else {
251 __kmp_msg(kmp_ms_warning, KMP_MSG(BadBoolValue, name, value),
252 KMP_HNT(ValidBoolValues), __kmp_msg_null);
253 }
254} // __kmp_stg_parse_bool
255
256// placed here in order to use __kmp_round4k static function
258 // if system stack size is too big then limit the size for worker threads
259#if KMP_OS_AIX
260 if (*val > KMP_DEFAULT_STKSIZE * 2) // Use 2 times, 16 is too large for AIX.
262#else
263 if (*val > KMP_DEFAULT_STKSIZE * 16) // just a heuristics...
264 *val = KMP_DEFAULT_STKSIZE * 16;
265#endif
268 if (*val > KMP_MAX_STKSIZE)
269 *val = KMP_MAX_STKSIZE; // dead code currently, but may work in future
270#if KMP_OS_DARWIN
271 *val = __kmp_round4k(*val);
272#endif // KMP_OS_DARWIN
273}
274
275static void __kmp_stg_parse_size(char const *name, char const *value,
276 size_t size_min, size_t size_max,
277 int *is_specified, size_t *out,
278 size_t factor) {
279 char const *msg = NULL;
280#if KMP_OS_DARWIN
281 size_min = __kmp_round4k(size_min);
282 size_max = __kmp_round4k(size_max);
283#endif // KMP_OS_DARWIN
284 if (value) {
285 if (is_specified != NULL) {
286 *is_specified = 1;
287 }
288 __kmp_str_to_size(value, out, factor, &msg);
289 if (msg == NULL) {
290 if (*out > size_max) {
291 *out = size_max;
292 msg = KMP_I18N_STR(ValueTooLarge);
293 } else if (*out < size_min) {
294 *out = size_min;
295 msg = KMP_I18N_STR(ValueTooSmall);
296 } else {
297#if KMP_OS_DARWIN
298 size_t round4k = __kmp_round4k(*out);
299 if (*out != round4k) {
300 *out = round4k;
301 msg = KMP_I18N_STR(NotMultiple4K);
302 }
303#endif
304 }
305 } else {
306 // If integer overflow occurred, * out == KMP_SIZE_T_MAX. Cut it to
307 // size_max silently.
308 if (*out < size_min) {
309 *out = size_max;
310 } else if (*out > size_max) {
311 *out = size_max;
312 }
313 }
314 if (msg != NULL) {
315 // Message is not empty. Print warning.
319 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
320 KMP_INFORM(Using_str_Value, name, buf.str);
322 }
323 }
324} // __kmp_stg_parse_size
325
326static void __kmp_stg_parse_str(char const *name, char const *value,
327 char **out) {
328 __kmp_str_free(out);
329 *out = __kmp_str_format("%s", value);
330} // __kmp_stg_parse_str
331
333 char const
334 *name, // I: Name of environment variable (used in warning messages).
335 char const *value, // I: Value of environment variable to parse.
336 int min, // I: Minimum allowed value.
337 int max, // I: Maximum allowed value.
338 int *out // O: Output (parsed) value.
339) {
340 char const *msg = NULL;
341 kmp_uint64 uint = *out;
342 __kmp_str_to_uint(value, &uint, &msg);
343 if (msg == NULL) {
344 if (uint < (unsigned int)min) {
345 msg = KMP_I18N_STR(ValueTooSmall);
346 uint = min;
347 } else if (uint > (unsigned int)max) {
348 msg = KMP_I18N_STR(ValueTooLarge);
349 uint = max;
350 }
351 } else {
352 // If overflow occurred msg contains error message and uint is very big. Cut
353 // tmp it to INT_MAX.
354 if (uint < (unsigned int)min) {
355 uint = min;
356 } else if (uint > (unsigned int)max) {
357 uint = max;
358 }
359 }
360 if (msg != NULL) {
361 // Message is not empty. Print warning.
363 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
365 __kmp_str_buf_print(&buf, "%" KMP_UINT64_SPEC "", uint);
366 KMP_INFORM(Using_uint64_Value, name, buf.str);
368 }
369 __kmp_type_convert(uint, out);
370} // __kmp_stg_parse_int
371
372#if KMP_DEBUG_ADAPTIVE_LOCKS
373static void __kmp_stg_parse_file(char const *name, char const *value,
374 const char *suffix, char **out) {
375 char buffer[256];
376 char *t;
377 int hasSuffix;
378 __kmp_str_free(out);
379 t = (char *)strrchr(value, '.');
380 hasSuffix = t && __kmp_str_eqf(t, suffix);
381 t = __kmp_str_format("%s%s", value, hasSuffix ? "" : suffix);
382 __kmp_expand_file_name(buffer, sizeof(buffer), t);
383 __kmp_str_free(&t);
384 *out = __kmp_str_format("%s", buffer);
385} // __kmp_stg_parse_file
386#endif
387
388#ifdef KMP_DEBUG
389static char *par_range_to_print = NULL;
390
391static void __kmp_stg_parse_par_range(char const *name, char const *value,
392 int *out_range, char *out_routine,
393 char *out_file, int *out_lb,
394 int *out_ub) {
395 const char *par_range_value;
396 size_t len = KMP_STRLEN(value) + 1;
397 par_range_to_print = (char *)KMP_INTERNAL_MALLOC(len + 1);
398 KMP_STRNCPY_S(par_range_to_print, len + 1, value, len + 1);
399 __kmp_par_range = +1;
400 __kmp_par_range_lb = 0;
401 __kmp_par_range_ub = INT_MAX;
402 for (;;) {
403 unsigned int len;
404 if (!value || *value == '\0') {
405 break;
406 }
407 if (!__kmp_strcasecmp_with_sentinel("routine", value, '=')) {
408 par_range_value = strchr(value, '=') + 1;
409 if (!par_range_value)
410 goto par_range_error;
411 value = par_range_value;
412 len = __kmp_readstr_with_sentinel(out_routine, value,
413 KMP_PAR_RANGE_ROUTINE_LEN - 1, ',');
414 if (len == 0) {
415 goto par_range_error;
416 }
417 value = strchr(value, ',');
418 if (value != NULL) {
419 value++;
420 }
421 continue;
422 }
423 if (!__kmp_strcasecmp_with_sentinel("filename", value, '=')) {
424 par_range_value = strchr(value, '=') + 1;
425 if (!par_range_value)
426 goto par_range_error;
427 value = par_range_value;
428 len = __kmp_readstr_with_sentinel(out_file, value,
429 KMP_PAR_RANGE_FILENAME_LEN - 1, ',');
430 if (len == 0) {
431 goto par_range_error;
432 }
433 value = strchr(value, ',');
434 if (value != NULL) {
435 value++;
436 }
437 continue;
438 }
439 if ((!__kmp_strcasecmp_with_sentinel("range", value, '=')) ||
440 (!__kmp_strcasecmp_with_sentinel("incl_range", value, '='))) {
441 par_range_value = strchr(value, '=') + 1;
442 if (!par_range_value)
443 goto par_range_error;
444 value = par_range_value;
445 if (KMP_SSCANF(value, "%d:%d", out_lb, out_ub) != 2) {
446 goto par_range_error;
447 }
448 *out_range = +1;
449 value = strchr(value, ',');
450 if (value != NULL) {
451 value++;
452 }
453 continue;
454 }
455 if (!__kmp_strcasecmp_with_sentinel("excl_range", value, '=')) {
456 par_range_value = strchr(value, '=') + 1;
457 if (!par_range_value)
458 goto par_range_error;
459 value = par_range_value;
460 if (KMP_SSCANF(value, "%d:%d", out_lb, out_ub) != 2) {
461 goto par_range_error;
462 }
463 *out_range = -1;
464 value = strchr(value, ',');
465 if (value != NULL) {
466 value++;
467 }
468 continue;
469 }
470 par_range_error:
471 KMP_WARNING(ParRangeSyntax, name);
472 __kmp_par_range = 0;
473 break;
474 }
475} // __kmp_stg_parse_par_range
476#endif
477
479 int nth = 32;
480
481 /* MIN( MAX( 32, 4 * $OMP_NUM_THREADS, 4 * omp_get_num_procs() ),
482 * __kmp_max_nth) */
483 if (nth < (4 * req_nproc))
484 nth = (4 * req_nproc);
485 if (nth < (4 * __kmp_xproc))
486 nth = (4 * __kmp_xproc);
487
488 // If hidden helper task is enabled, we initialize the thread capacity with
489 // extra __kmp_hidden_helper_threads_num.
492 }
493
494 if (nth > __kmp_max_nth)
495 nth = __kmp_max_nth;
496
497 return nth;
498}
499
500int __kmp_default_tp_capacity(int req_nproc, int max_nth,
501 int all_threads_specified) {
502 int nth = 128;
503
504 if (all_threads_specified)
505 return max_nth;
506 /* MIN( MAX (128, 4 * $OMP_NUM_THREADS, 4 * omp_get_num_procs() ),
507 * __kmp_max_nth ) */
508 if (nth < (4 * req_nproc))
509 nth = (4 * req_nproc);
510 if (nth < (4 * __kmp_xproc))
511 nth = (4 * __kmp_xproc);
512
513 if (nth > __kmp_max_nth)
514 nth = __kmp_max_nth;
515
516 return nth;
517}
518
519// -----------------------------------------------------------------------------
520// Helper print functions.
521
522static void __kmp_stg_print_bool(kmp_str_buf_t *buffer, char const *name,
523 int value) {
524 if (__kmp_env_format) {
526 } else {
527 __kmp_str_buf_print(buffer, " %s=%s\n", name, value ? "true" : "false");
528 }
529} // __kmp_stg_print_bool
530
531static void __kmp_stg_print_int(kmp_str_buf_t *buffer, char const *name,
532 int value) {
533 if (__kmp_env_format) {
535 } else {
536 __kmp_str_buf_print(buffer, " %s=%d\n", name, value);
537 }
538} // __kmp_stg_print_int
539
540static void __kmp_stg_print_uint64(kmp_str_buf_t *buffer, char const *name,
542 if (__kmp_env_format) {
544 } else {
545 __kmp_str_buf_print(buffer, " %s=%" KMP_UINT64_SPEC "\n", name, value);
546 }
547} // __kmp_stg_print_uint64
548
549static void __kmp_stg_print_str(kmp_str_buf_t *buffer, char const *name,
550 char const *value) {
551 if (__kmp_env_format) {
553 } else {
554 __kmp_str_buf_print(buffer, " %s=%s\n", name, value);
555 }
556} // __kmp_stg_print_str
557
558static void __kmp_stg_print_size(kmp_str_buf_t *buffer, char const *name,
559 size_t value) {
560 if (__kmp_env_format) {
563 __kmp_str_buf_print(buffer, "'\n");
564 } else {
565 __kmp_str_buf_print(buffer, " %s=", name);
567 __kmp_str_buf_print(buffer, "\n");
568 return;
569 }
570} // __kmp_stg_print_size
571
572// =============================================================================
573// Parse and print functions.
574
575// -----------------------------------------------------------------------------
576// KMP_DEVICE_THREAD_LIMIT, KMP_ALL_THREADS
577
579 char const *value, void *data) {
580 kmp_setting_t **rivals = (kmp_setting_t **)data;
581 int rc;
582 if (strcmp(name, "KMP_ALL_THREADS") == 0) {
583 KMP_INFORM(EnvVarDeprecated, name, "KMP_DEVICE_THREAD_LIMIT");
584 }
585 rc = __kmp_stg_check_rivals(name, value, rivals);
586 if (rc) {
587 return;
588 }
589 if (!__kmp_strcasecmp_with_sentinel("all", value, 0)) {
592 } else {
595 }
596 K_DIAG(1, ("__kmp_max_nth == %d\n", __kmp_max_nth));
597
598} // __kmp_stg_parse_device_thread_limit
599
601 char const *name, void *data) {
603} // __kmp_stg_print_device_thread_limit
604
605// -----------------------------------------------------------------------------
606// OMP_THREAD_LIMIT
607static void __kmp_stg_parse_thread_limit(char const *name, char const *value,
608 void *data) {
610 K_DIAG(1, ("__kmp_cg_max_nth == %d\n", __kmp_cg_max_nth));
611
612} // __kmp_stg_parse_thread_limit
613
615 char const *name, void *data) {
617} // __kmp_stg_print_thread_limit
618
619// -----------------------------------------------------------------------------
620// OMP_NUM_TEAMS
621static void __kmp_stg_parse_nteams(char const *name, char const *value,
622 void *data) {
624 K_DIAG(1, ("__kmp_nteams == %d\n", __kmp_nteams));
625} // __kmp_stg_parse_nteams
626
627static void __kmp_stg_print_nteams(kmp_str_buf_t *buffer, char const *name,
628 void *data) {
630} // __kmp_stg_print_nteams
631
632// -----------------------------------------------------------------------------
633// OMP_TEAMS_THREAD_LIMIT
634static void __kmp_stg_parse_teams_th_limit(char const *name, char const *value,
635 void *data) {
638 K_DIAG(1, ("__kmp_teams_thread_limit == %d\n", __kmp_teams_thread_limit));
639} // __kmp_stg_parse_teams_th_limit
640
642 char const *name, void *data) {
644} // __kmp_stg_print_teams_th_limit
645
646// -----------------------------------------------------------------------------
647// KMP_TEAMS_THREAD_LIMIT
649 char const *value, void *data) {
651} // __kmp_stg_teams_thread_limit
652
654 char const *name, void *data) {
656} // __kmp_stg_print_teams_thread_limit
657
658// -----------------------------------------------------------------------------
659// KMP_USE_YIELD
660static void __kmp_stg_parse_use_yield(char const *name, char const *value,
661 void *data) {
664} // __kmp_stg_parse_use_yield
665
666static void __kmp_stg_print_use_yield(kmp_str_buf_t *buffer, char const *name,
667 void *data) {
669} // __kmp_stg_print_use_yield
670
671// -----------------------------------------------------------------------------
672// KMP_BLOCKTIME
673
674static void __kmp_stg_parse_blocktime(char const *name, char const *value,
675 void *data) {
676 const char *buf = value;
677 const char *next;
678 const int ms_mult = 1000;
679 int multiplier = 1;
680 int num;
681
682 // Read integer blocktime value
683 SKIP_WS(buf);
684 if ((*buf >= '0') && (*buf <= '9')) {
685 next = buf;
686 SKIP_DIGITS(next);
688 KMP_ASSERT(num >= 0);
689 buf = next;
690 SKIP_WS(buf);
691 } else {
692 num = -1;
693 }
694
695 // Read units: note that __kmp_dflt_blocktime units is now us
696 next = buf;
697 if (*buf == '\0' || __kmp_match_str("ms", buf, &next)) {
698 // units are in ms; convert
699 __kmp_dflt_blocktime = ms_mult * num;
701 multiplier = ms_mult;
702 } else if (__kmp_match_str("us", buf, &next)) {
703 // units are in us
706 } else if (__kmp_match_str("infinite", buf, &next) ||
707 __kmp_match_str("infinity", buf, &next)) {
708 // units are in ms
711 multiplier = ms_mult;
712 } else {
713 KMP_WARNING(StgInvalidValue, name, value);
714 // default units are in ms
715 __kmp_dflt_blocktime = ms_mult * num;
717 multiplier = ms_mult;
718 }
719
720 if (num < 0 && __kmp_dflt_blocktime < 0) { // num out of range
722 __kmp_msg(kmp_ms_warning, KMP_MSG(InvalidValue, name, value),
724 // Inform in appropriate units
725 KMP_INFORM(Using_int_Value, name, __kmp_dflt_blocktime / multiplier);
726 __kmp_env_blocktime = FALSE; // Revert to default as if var not set.
727 } else if (num > 0 && __kmp_dflt_blocktime < 0) { // overflow
730 KMP_INFORM(MaxValueUsing, name, __kmp_dflt_blocktime / multiplier);
731 __kmp_env_blocktime = TRUE; // KMP_BLOCKTIME was specified.
732 } else {
737 KMP_INFORM(MinValueUsing, name, __kmp_dflt_blocktime / multiplier);
742 KMP_INFORM(MaxValueUsing, name, __kmp_dflt_blocktime / multiplier);
743 }
744 __kmp_env_blocktime = TRUE; // KMP_BLOCKTIME was specified.
745 }
746#if KMP_USE_MONITOR
747 // calculate number of monitor thread wakeup intervals corresponding to
748 // blocktime.
749 __kmp_monitor_wakeups =
750 KMP_WAKEUPS_FROM_BLOCKTIME(__kmp_dflt_blocktime, __kmp_monitor_wakeups);
751 __kmp_bt_intervals =
752 KMP_INTERVALS_FROM_BLOCKTIME(__kmp_dflt_blocktime, __kmp_monitor_wakeups);
753#endif
754 K_DIAG(1, ("__kmp_env_blocktime == %d\n", __kmp_env_blocktime));
756 K_DIAG(1, ("__kmp_dflt_blocktime == %d\n", __kmp_dflt_blocktime));
757 }
758} // __kmp_stg_parse_blocktime
759
760static void __kmp_stg_print_blocktime(kmp_str_buf_t *buffer, char const *name,
761 void *data) {
762 int num = __kmp_dflt_blocktime;
763 if (__kmp_blocktime_units == 'm') {
764 num = num / 1000;
765 }
766 if (__kmp_env_format) {
768 } else {
769 __kmp_str_buf_print(buffer, " %s=", name);
770 }
771 __kmp_str_buf_print(buffer, "%d", num);
773} // __kmp_stg_print_blocktime
774
775// -----------------------------------------------------------------------------
776// KMP_DUPLICATE_LIB_OK
777
779 char const *value, void *data) {
780 /* actually this variable is not supported, put here for compatibility with
781 earlier builds and for static/dynamic combination */
783} // __kmp_stg_parse_duplicate_lib_ok
784
786 char const *name, void *data) {
788} // __kmp_stg_print_duplicate_lib_ok
789
790// -----------------------------------------------------------------------------
791// KMP_INHERIT_FP_CONTROL
792
793#if KMP_ARCH_X86 || KMP_ARCH_X86_64
794
795static void __kmp_stg_parse_inherit_fp_control(char const *name,
796 char const *value, void *data) {
797 __kmp_stg_parse_bool(name, value, &__kmp_inherit_fp_control);
798} // __kmp_stg_parse_inherit_fp_control
799
800static void __kmp_stg_print_inherit_fp_control(kmp_str_buf_t *buffer,
801 char const *name, void *data) {
802#if KMP_DEBUG
803 __kmp_stg_print_bool(buffer, name, __kmp_inherit_fp_control);
804#endif /* KMP_DEBUG */
805} // __kmp_stg_print_inherit_fp_control
806
807#endif /* KMP_ARCH_X86 || KMP_ARCH_X86_64 */
808
809// Used for OMP_WAIT_POLICY
810static char const *blocktime_str = NULL;
811static char const *use_yield_str = NULL;
812
813// -----------------------------------------------------------------------------
814// KMP_LIBRARY, OMP_WAIT_POLICY
815
816static void __kmp_stg_parse_wait_policy(char const *name, char const *value,
817 void *data) {
818
820 int rc;
821
823 if (rc) {
824 return;
825 }
826
827 if (wait->omp) {
828 if (__kmp_str_match("ACTIVE", 1, value)) {
830 if (blocktime_str == NULL) {
831 // KMP_BLOCKTIME not specified, so set default to "infinite".
833 }
834 if (use_yield_str == NULL) {
835 // KMP_USE_YIELD not specified, so set default to 2.
836 __kmp_use_yield = 2;
837 }
838 } else if (__kmp_str_match("PASSIVE", 1, value)) {
840 __kmp_wpolicy_passive = true; /* allow sleep while active tasking */
841 if (blocktime_str == NULL) {
842 // KMP_BLOCKTIME not specified, so set default to 0.
844 }
845 } else {
846 KMP_WARNING(StgInvalidValue, name, value);
847 }
848 } else {
849 if (__kmp_str_match("serial", 1, value)) { /* S */
851 } else if (__kmp_str_match("throughput", 2, value)) { /* TH */
853 if (blocktime_str == NULL) {
854 // KMP_BLOCKTIME not specified, so set default to 0.
856 }
857 } else if (__kmp_str_match("turnaround", 2, value)) { /* TU */
859 } else if (__kmp_str_match("dedicated", 1, value)) { /* D */
861 } else if (__kmp_str_match("multiuser", 1, value)) { /* M */
863 if (blocktime_str == NULL) {
864 // KMP_BLOCKTIME not specified, so set default to 0.
866 }
867 } else {
868 KMP_WARNING(StgInvalidValue, name, value);
869 }
870 }
871} // __kmp_stg_parse_wait_policy
872
873static void __kmp_stg_print_wait_policy(kmp_str_buf_t *buffer, char const *name,
874 void *data) {
875
877 char const *value = NULL;
878
879 if (wait->omp) {
880 switch (__kmp_library) {
881 case library_turnaround: {
882 value = "ACTIVE";
883 } break;
884 case library_throughput: {
885 value = "PASSIVE";
886 } break;
887 case library_none:
888 case library_serial: {
889 value = NULL;
890 } break;
891 }
892 } else {
893 switch (__kmp_library) {
894 case library_serial: {
895 value = "serial";
896 } break;
897 case library_turnaround: {
898 value = "turnaround";
899 } break;
900 case library_throughput: {
901 value = "throughput";
902 } break;
903 case library_none: {
904 value = NULL;
905 } break;
906 }
907 }
908 if (value != NULL) {
910 }
911
912} // __kmp_stg_print_wait_policy
913
914#if KMP_USE_MONITOR
915// -----------------------------------------------------------------------------
916// KMP_MONITOR_STACKSIZE
917
918static void __kmp_stg_parse_monitor_stacksize(char const *name,
919 char const *value, void *data) {
921 NULL, &__kmp_monitor_stksize, 1);
922} // __kmp_stg_parse_monitor_stacksize
923
924static void __kmp_stg_print_monitor_stacksize(kmp_str_buf_t *buffer,
925 char const *name, void *data) {
926 if (__kmp_env_format) {
927 if (__kmp_monitor_stksize > 0)
929 else
931 } else {
932 __kmp_str_buf_print(buffer, " %s", name);
933 }
934 if (__kmp_monitor_stksize > 0) {
935 __kmp_str_buf_print_size(buffer, __kmp_monitor_stksize);
936 } else {
937 __kmp_str_buf_print(buffer, ": %s\n", KMP_I18N_STR(NotDefined));
938 }
939 if (__kmp_env_format && __kmp_monitor_stksize) {
940 __kmp_str_buf_print(buffer, "'\n");
941 }
942} // __kmp_stg_print_monitor_stacksize
943#endif // KMP_USE_MONITOR
944
945// -----------------------------------------------------------------------------
946// KMP_SETTINGS
947
948static void __kmp_stg_parse_settings(char const *name, char const *value,
949 void *data) {
951} // __kmp_stg_parse_settings
952
953static void __kmp_stg_print_settings(kmp_str_buf_t *buffer, char const *name,
954 void *data) {
956} // __kmp_stg_print_settings
957
958// -----------------------------------------------------------------------------
959// KMP_STACKPAD
960
961static void __kmp_stg_parse_stackpad(char const *name, char const *value,
962 void *data) {
963 __kmp_stg_parse_int(name, // Env var name
964 value, // Env var value
965 KMP_MIN_STKPADDING, // Min value
966 KMP_MAX_STKPADDING, // Max value
967 &__kmp_stkpadding // Var to initialize
968 );
969} // __kmp_stg_parse_stackpad
970
971static void __kmp_stg_print_stackpad(kmp_str_buf_t *buffer, char const *name,
972 void *data) {
974} // __kmp_stg_print_stackpad
975
976// -----------------------------------------------------------------------------
977// KMP_STACKOFFSET
978
979static void __kmp_stg_parse_stackoffset(char const *name, char const *value,
980 void *data) {
981 __kmp_stg_parse_size(name, // Env var name
982 value, // Env var value
983 KMP_MIN_STKOFFSET, // Min value
984 KMP_MAX_STKOFFSET, // Max value
985 NULL, //
986 &__kmp_stkoffset, // Var to initialize
987 1);
988} // __kmp_stg_parse_stackoffset
989
990static void __kmp_stg_print_stackoffset(kmp_str_buf_t *buffer, char const *name,
991 void *data) {
993} // __kmp_stg_print_stackoffset
994
995// -----------------------------------------------------------------------------
996// KMP_STACKSIZE, OMP_STACKSIZE, GOMP_STACKSIZE
997
998static void __kmp_stg_parse_stacksize(char const *name, char const *value,
999 void *data) {
1000
1002 int rc;
1003
1004 rc = __kmp_stg_check_rivals(name, value, stacksize->rivals);
1005 if (rc) {
1006 return;
1007 }
1008 __kmp_stg_parse_size(name, // Env var name
1009 value, // Env var value
1010 __kmp_sys_min_stksize, // Min value
1011 KMP_MAX_STKSIZE, // Max value
1013 &__kmp_stksize, // Var to initialize
1014 stacksize->factor);
1015
1016} // __kmp_stg_parse_stacksize
1017
1018// This function is called for printing both KMP_STACKSIZE (factor is 1) and
1019// OMP_STACKSIZE (factor is 1024). Currently it is not possible to print
1020// OMP_STACKSIZE value in bytes. We can consider adding this possibility by a
1021// customer request in future.
1022static void __kmp_stg_print_stacksize(kmp_str_buf_t *buffer, char const *name,
1023 void *data) {
1025 if (__kmp_env_format) {
1028 ? __kmp_stksize / stacksize->factor
1029 : __kmp_stksize);
1030 __kmp_str_buf_print(buffer, "'\n");
1031 } else {
1032 __kmp_str_buf_print(buffer, " %s=", name);
1034 ? __kmp_stksize / stacksize->factor
1035 : __kmp_stksize);
1036 __kmp_str_buf_print(buffer, "\n");
1037 }
1038} // __kmp_stg_print_stacksize
1039
1040// -----------------------------------------------------------------------------
1041// KMP_VERSION
1042
1043static void __kmp_stg_parse_version(char const *name, char const *value,
1044 void *data) {
1046} // __kmp_stg_parse_version
1047
1048static void __kmp_stg_print_version(kmp_str_buf_t *buffer, char const *name,
1049 void *data) {
1051} // __kmp_stg_print_version
1052
1053// -----------------------------------------------------------------------------
1054// KMP_WARNINGS
1055
1056static void __kmp_stg_parse_warnings(char const *name, char const *value,
1057 void *data) {
1060 // AC: only 0/1 values documented, so reset to explicit to distinguish from
1061 // default setting
1063 }
1064} // __kmp_stg_parse_warnings
1065
1066static void __kmp_stg_print_warnings(kmp_str_buf_t *buffer, char const *name,
1067 void *data) {
1068 // AC: TODO: change to print_int? (needs documentation change)
1070} // __kmp_stg_print_warnings
1071
1072// -----------------------------------------------------------------------------
1073// KMP_NESTING_MODE
1074
1075static void __kmp_stg_parse_nesting_mode(char const *name, char const *value,
1076 void *data) {
1078#if KMP_HWLOC_ENABLED
1079 if (__kmp_nesting_mode > 0)
1080 __kmp_affinity_top_method = affinity_top_method_hwloc;
1081#endif // KMP_HWLOC_ENABLED
1082} // __kmp_stg_parse_nesting_mode
1083
1085 char const *name, void *data) {
1086 if (__kmp_env_format) {
1088 } else {
1089 __kmp_str_buf_print(buffer, " %s", name);
1090 }
1091 __kmp_str_buf_print(buffer, "=%d\n", __kmp_nesting_mode);
1092} // __kmp_stg_print_nesting_mode
1093
1094// -----------------------------------------------------------------------------
1095// OMP_NESTED, OMP_NUM_THREADS
1096
1097static void __kmp_stg_parse_nested(char const *name, char const *value,
1098 void *data) {
1099 int nested;
1100 KMP_INFORM(EnvVarDeprecated, name, "OMP_MAX_ACTIVE_LEVELS");
1101 __kmp_stg_parse_bool(name, value, &nested);
1102 if (nested) {
1105 } else { // nesting explicitly turned off
1108 }
1109} // __kmp_stg_parse_nested
1110
1111static void __kmp_stg_print_nested(kmp_str_buf_t *buffer, char const *name,
1112 void *data) {
1113 if (__kmp_env_format) {
1115 } else {
1116 __kmp_str_buf_print(buffer, " %s", name);
1117 }
1118 __kmp_str_buf_print(buffer, ": deprecated; max-active-levels-var=%d\n",
1120} // __kmp_stg_print_nested
1121
1122static void __kmp_parse_nested_num_threads(const char *var, const char *env,
1123 kmp_nested_nthreads_t *nth_array) {
1124 const char *next = env;
1125 const char *scan = next;
1126
1127 int total = 0; // Count elements that were set. It'll be used as an array size
1128 int prev_comma = FALSE; // For correct processing sequential commas
1129
1130 // Count the number of values in the env. var string
1131 for (;;) {
1132 SKIP_WS(next);
1133
1134 if (*next == '\0') {
1135 break;
1136 }
1137 // Next character is not an integer or not a comma => end of list
1138 if (((*next < '0') || (*next > '9')) && (*next != ',')) {
1139 KMP_WARNING(NthSyntaxError, var, env);
1140 return;
1141 }
1142 // The next character is ','
1143 if (*next == ',') {
1144 // ',' is the first character
1145 if (total == 0 || prev_comma) {
1146 total++;
1147 }
1148 prev_comma = TRUE;
1149 next++; // skip ','
1150 SKIP_WS(next);
1151 }
1152 // Next character is a digit
1153 if (*next >= '0' && *next <= '9') {
1154 prev_comma = FALSE;
1155 SKIP_DIGITS(next);
1156 total++;
1157 const char *tmp = next;
1158 SKIP_WS(tmp);
1159 if ((*next == ' ' || *next == '\t') && (*tmp >= '0' && *tmp <= '9')) {
1160 KMP_WARNING(NthSpacesNotAllowed, var, env);
1161 return;
1162 }
1163 }
1164 }
1165 if (!__kmp_dflt_max_active_levels_set && total > 1)
1167 if (total <= 0) {
1168 KMP_WARNING(NthSyntaxError, var, env);
1169 return;
1170 }
1171
1172 // Check if the nested nthreads array exists
1173 if (!nth_array->nth) {
1174 // Allocate an array of double size
1175 nth_array->nth = (int *)KMP_INTERNAL_MALLOC(sizeof(int) * total * 2);
1176 if (nth_array->nth == NULL) {
1177 KMP_FATAL(MemoryAllocFailed);
1178 }
1179 nth_array->size = total * 2;
1180 } else {
1181 if (nth_array->size < total) {
1182 // Increase the array size
1183 do {
1184 nth_array->size *= 2;
1185 } while (nth_array->size < total);
1186
1187 nth_array->nth = (int *)KMP_INTERNAL_REALLOC(
1188 nth_array->nth, sizeof(int) * nth_array->size);
1189 if (nth_array->nth == NULL) {
1190 KMP_FATAL(MemoryAllocFailed);
1191 }
1192 }
1193 }
1194 nth_array->used = total;
1195 int i = 0;
1196
1197 prev_comma = FALSE;
1198 total = 0;
1199 // Save values in the array
1200 for (;;) {
1201 SKIP_WS(scan);
1202 if (*scan == '\0') {
1203 break;
1204 }
1205 // The next character is ','
1206 if (*scan == ',') {
1207 // ',' in the beginning of the list
1208 if (total == 0) {
1209 // The value is supposed to be equal to __kmp_avail_proc but it is
1210 // unknown at the moment.
1211 // So let's put a placeholder (#threads = 0) to correct it later.
1212 nth_array->nth[i++] = 0;
1213 total++;
1214 } else if (prev_comma) {
1215 // Num threads is inherited from the previous level
1216 nth_array->nth[i] = nth_array->nth[i - 1];
1217 i++;
1218 total++;
1219 }
1220 prev_comma = TRUE;
1221 scan++; // skip ','
1222 SKIP_WS(scan);
1223 }
1224 // Next character is a digit
1225 if (*scan >= '0' && *scan <= '9') {
1226 int num;
1227 const char *buf = scan;
1228 char const *msg = NULL;
1229 prev_comma = FALSE;
1230 SKIP_DIGITS(scan);
1231 total++;
1232
1233 num = __kmp_str_to_int(buf, *scan);
1234 if (num < KMP_MIN_NTH) {
1235 msg = KMP_I18N_STR(ValueTooSmall);
1236 num = KMP_MIN_NTH;
1237 } else if (num > __kmp_sys_max_nth) {
1238 msg = KMP_I18N_STR(ValueTooLarge);
1239 num = __kmp_sys_max_nth;
1240 }
1241 if (msg != NULL) {
1242 // Message is not empty. Print warning.
1243 KMP_WARNING(ParseSizeIntWarn, var, env, msg);
1244 KMP_INFORM(Using_int_Value, var, num);
1245 }
1246 nth_array->nth[i++] = num;
1247 }
1248 }
1249}
1250
1251static void __kmp_stg_parse_num_threads(char const *name, char const *value,
1252 void *data) {
1253 // TODO: Remove this option. OMP_NUM_THREADS is a list of positive integers!
1254 if (!__kmp_strcasecmp_with_sentinel("all", value, 0)) {
1255 // The array of 1 element
1256 if (!__kmp_nested_nth.nth) {
1257 __kmp_nested_nth.nth = (int *)KMP_INTERNAL_MALLOC(sizeof(int));
1258 __kmp_nested_nth.size = 1;
1259 }
1260 __kmp_nested_nth.used = 1;
1263 } else {
1265 if (__kmp_nested_nth.nth) {
1269 }
1270 }
1271 }
1272 K_DIAG(1, ("__kmp_dflt_team_nth == %d\n", __kmp_dflt_team_nth));
1273} // __kmp_stg_parse_num_threads
1274
1275#if OMP_TASKGRAPH_EXPERIMENTAL
1276static void __kmp_stg_parse_max_tdgs(char const *name, char const *value,
1277 void *data) {
1278 __kmp_stg_parse_int(name, value, 0, INT_MAX, &__kmp_max_tdgs);
1279} // __kmp_stg_parse_max_tdgs
1280
1281static void __kmp_std_print_max_tdgs(kmp_str_buf_t *buffer, char const *name,
1282 void *data) {
1283 __kmp_stg_print_int(buffer, name, __kmp_max_tdgs);
1284} // __kmp_std_print_max_tdgs
1285
1286static void __kmp_stg_parse_tdg_dot(char const *name, char const *value,
1287 void *data) {
1288 __kmp_stg_parse_bool(name, value, &__kmp_tdg_dot);
1289} // __kmp_stg_parse_tdg_dot
1290
1291static void __kmp_stg_print_tdg_dot(kmp_str_buf_t *buffer, char const *name,
1292 void *data) {
1293 __kmp_stg_print_bool(buffer, name, __kmp_tdg_dot);
1294} // __kmp_stg_print_tdg_dot
1295#endif
1296
1298 char const *value,
1299 void *data) {
1301 // If the number of hidden helper threads is zero, we disable hidden helper
1302 // task
1305 } else {
1306 // Since the main thread of hidden helper team does not participate
1307 // in tasks execution let's increment the number of threads by one
1308 // so that requested number of threads do actual job.
1310 }
1311} // __kmp_stg_parse_num_hidden_helper_threads
1312
1314 char const *name,
1315 void *data) {
1318 } else {
1320 // Let's exclude the main thread of hidden helper team and print
1321 // number of worker threads those do actual job.
1323 }
1324} // __kmp_stg_print_num_hidden_helper_threads
1325
1327 char const *value, void *data) {
1329#if !KMP_OS_LINUX
1331 K_DIAG(1,
1332 ("__kmp_stg_parse_use_hidden_helper: Disable hidden helper task on "
1333 "non-Linux platform although it is enabled by user explicitly.\n"));
1334#endif
1335} // __kmp_stg_parse_use_hidden_helper
1336
1338 char const *name, void *data) {
1340} // __kmp_stg_print_use_hidden_helper
1341
1342static void __kmp_stg_print_num_threads(kmp_str_buf_t *buffer, char const *name,
1343 void *data) {
1344 if (__kmp_env_format) {
1346 } else {
1347 __kmp_str_buf_print(buffer, " %s", name);
1348 }
1349 if (__kmp_nested_nth.used) {
1352 for (int i = 0; i < __kmp_nested_nth.used; i++) {
1354 if (i < __kmp_nested_nth.used - 1) {
1355 __kmp_str_buf_print(&buf, ",");
1356 }
1357 }
1358 __kmp_str_buf_print(buffer, "='%s'\n", buf.str);
1360 } else {
1361 __kmp_str_buf_print(buffer, ": %s\n", KMP_I18N_STR(NotDefined));
1362 }
1363} // __kmp_stg_print_num_threads
1364
1365// -----------------------------------------------------------------------------
1366// OpenMP 3.0: KMP_TASKING, OMP_MAX_ACTIVE_LEVELS,
1367
1368static void __kmp_stg_parse_tasking(char const *name, char const *value,
1369 void *data) {
1371 (int *)&__kmp_tasking_mode);
1372 // KMP_TASKING=1 (task barrier) doesn't work anymore, change to task_teams (2)
1374 KMP_WARNING(StgInvalidValue, name, value);
1376 }
1377} // __kmp_stg_parse_tasking
1378
1379static void __kmp_stg_print_tasking(kmp_str_buf_t *buffer, char const *name,
1380 void *data) {
1382} // __kmp_stg_print_tasking
1383
1384static void __kmp_stg_parse_task_stealing(char const *name, char const *value,
1385 void *data) {
1388} // __kmp_stg_parse_task_stealing
1389
1391 char const *name, void *data) {
1393} // __kmp_stg_print_task_stealing
1394
1396 char const *value, void *data) {
1397 kmp_uint64 tmp_dflt = 0;
1398 char const *msg = NULL;
1400 // Don't overwrite __kmp_dflt_max_active_levels if we get an invalid setting
1401 __kmp_str_to_uint(value, &tmp_dflt, &msg);
1402 if (msg != NULL) { // invalid setting; print warning and ignore
1403 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
1404 } else if (tmp_dflt > KMP_MAX_ACTIVE_LEVELS_LIMIT) {
1405 // invalid setting; print warning and ignore
1406 msg = KMP_I18N_STR(ValueTooLarge);
1407 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
1408 } else { // valid setting
1411 }
1412 }
1413} // __kmp_stg_parse_max_active_levels
1414
1416 char const *name, void *data) {
1418} // __kmp_stg_print_max_active_levels
1419
1420// -----------------------------------------------------------------------------
1421// OpenMP 4.0: OMP_DEFAULT_DEVICE
1422static void __kmp_stg_parse_default_device(char const *name, char const *value,
1423 void *data) {
1425 value, /*device_num_min=*/0, KMP_MAX_DEFAULT_DEVICE_LIMIT, name);
1426} // __kmp_stg_parse_default_device
1427
1429 char const *name, void *data) {
1431} // __kmp_stg_print_default_device
1432
1433// -----------------------------------------------------------------------------
1434// OpenMP 5.0: OMP_TARGET_OFFLOAD
1435static void __kmp_stg_parse_target_offload(char const *name, char const *value,
1436 void *data) {
1437 kmp_trimmed_str_t value_str(value);
1438 const char *scan = value_str.get();
1440
1441 if (*scan == '\0')
1442 return;
1443
1444 if (!__kmp_strcasecmp_with_sentinel("mandatory", scan, 0)) {
1446 } else if (!__kmp_strcasecmp_with_sentinel("disabled", scan, 0)) {
1448 } else if (!__kmp_strcasecmp_with_sentinel("default", scan, 0)) {
1450 } else {
1451 KMP_WARNING(SyntaxErrorUsing, name, "DEFAULT");
1452 }
1453} // __kmp_stg_parse_target_offload
1454
1456 char const *name, void *data) {
1457 const char *value = NULL;
1459 value = "DEFAULT";
1461 value = "MANDATORY";
1463 value = "DISABLED";
1465 if (__kmp_env_format) {
1467 } else {
1468 __kmp_str_buf_print(buffer, " %s", name);
1469 }
1470 __kmp_str_buf_print(buffer, "=%s\n", value);
1471} // __kmp_stg_print_target_offload
1472
1473// -----------------------------------------------------------------------------
1474// OpenMP 4.5: OMP_MAX_TASK_PRIORITY
1476 char const *value, void *data) {
1479} // __kmp_stg_parse_max_task_priority
1480
1482 char const *name, void *data) {
1484} // __kmp_stg_print_max_task_priority
1485
1486// KMP_TASKLOOP_MIN_TASKS
1487// taskloop threshold to switch from recursive to linear tasks creation
1489 char const *value, void *data) {
1490 int tmp = 0;
1491 __kmp_stg_parse_int(name, value, 0, INT_MAX, &tmp);
1493} // __kmp_stg_parse_taskloop_min_tasks
1494
1496 char const *name, void *data) {
1498} // __kmp_stg_print_taskloop_min_tasks
1499
1500// -----------------------------------------------------------------------------
1501// KMP_DISP_NUM_BUFFERS
1502static void __kmp_stg_parse_disp_buffers(char const *name, char const *value,
1503 void *data) {
1504 if (TCR_4(__kmp_init_serial)) {
1505 KMP_WARNING(EnvSerialWarn, name);
1506 return;
1507 } // read value before serial initialization only
1510} // __kmp_stg_parse_disp_buffers
1511
1513 char const *name, void *data) {
1515} // __kmp_stg_print_disp_buffers
1516
1517// -----------------------------------------------------------------------------
1518// KMP_HOT_TEAMS_MAX_LEVEL, KMP_HOT_TEAMS_MODE
1519
1520static void __kmp_stg_parse_hot_teams_level(char const *name, char const *value,
1521 void *data) {
1523 KMP_WARNING(EnvParallelWarn, name);
1524 return;
1525 } // read value before first parallel only
1527
1528} // __kmp_stg_parse_hot_teams_level
1529
1531 char const *name, void *data) {
1533} // __kmp_stg_print_hot_teams_level
1534
1535static void __kmp_stg_parse_hot_teams_mode(char const *name, char const *value,
1536 void *data) {
1538 KMP_WARNING(EnvParallelWarn, name);
1539 return;
1540 } // read value before first parallel only
1543} // __kmp_stg_parse_hot_teams_mode
1544
1546 char const *name, void *data) {
1548} // __kmp_stg_print_hot_teams_mode
1549
1550// -----------------------------------------------------------------------------
1551// KMP_HANDLE_SIGNALS
1552
1553#if KMP_HANDLE_SIGNALS
1554
1555static void __kmp_stg_parse_handle_signals(char const *name, char const *value,
1556 void *data) {
1557 __kmp_stg_parse_bool(name, value, &__kmp_handle_signals);
1558} // __kmp_stg_parse_handle_signals
1559
1560static void __kmp_stg_print_handle_signals(kmp_str_buf_t *buffer,
1561 char const *name, void *data) {
1562 __kmp_stg_print_bool(buffer, name, __kmp_handle_signals);
1563} // __kmp_stg_print_handle_signals
1564
1565#endif // KMP_HANDLE_SIGNALS
1566
1567// -----------------------------------------------------------------------------
1568// KMP_X_DEBUG, KMP_DEBUG, KMP_DEBUG_BUF_*, KMP_DIAG
1569
1570#ifdef KMP_DEBUG
1571
1572#define KMP_STG_X_DEBUG(x) \
1573 static void __kmp_stg_parse_##x##_debug(char const *name, char const *value, \
1574 void *data) { \
1575 __kmp_stg_parse_int(name, value, 0, INT_MAX, &kmp_##x##_debug); \
1576 } /* __kmp_stg_parse_x_debug */ \
1577 static void __kmp_stg_print_##x##_debug(kmp_str_buf_t *buffer, \
1578 char const *name, void *data) { \
1579 __kmp_stg_print_int(buffer, name, kmp_##x##_debug); \
1580 } /* __kmp_stg_print_x_debug */
1581
1582KMP_STG_X_DEBUG(a)
1583KMP_STG_X_DEBUG(b)
1584KMP_STG_X_DEBUG(c)
1585KMP_STG_X_DEBUG(d)
1586KMP_STG_X_DEBUG(e)
1587KMP_STG_X_DEBUG(f)
1588
1589#undef KMP_STG_X_DEBUG
1590
1591static void __kmp_stg_parse_debug(char const *name, char const *value,
1592 void *data) {
1593 int debug = 0;
1594 __kmp_stg_parse_int(name, value, 0, INT_MAX, &debug);
1595 if (kmp_a_debug < debug) {
1596 kmp_a_debug = debug;
1597 }
1598 if (kmp_b_debug < debug) {
1599 kmp_b_debug = debug;
1600 }
1601 if (kmp_c_debug < debug) {
1602 kmp_c_debug = debug;
1603 }
1604 if (kmp_d_debug < debug) {
1605 kmp_d_debug = debug;
1606 }
1607 if (kmp_e_debug < debug) {
1608 kmp_e_debug = debug;
1609 }
1610 if (kmp_f_debug < debug) {
1611 kmp_f_debug = debug;
1612 }
1613} // __kmp_stg_parse_debug
1614
1615static void __kmp_stg_parse_debug_buf(char const *name, char const *value,
1616 void *data) {
1618 // !!! TODO: Move buffer initialization of this file! It may works
1619 // incorrectly if KMP_DEBUG_BUF is parsed before KMP_DEBUG_BUF_LINES or
1620 // KMP_DEBUG_BUF_CHARS.
1621 if (__kmp_debug_buf) {
1622 int i;
1624
1625 /* allocate and initialize all entries in debug buffer to empty */
1626 __kmp_debug_buffer = (char *)__kmp_page_allocate(elements * sizeof(char));
1627 for (i = 0; i < elements; i += __kmp_debug_buf_chars)
1628 __kmp_debug_buffer[i] = '\0';
1629
1631 }
1632 K_DIAG(1, ("__kmp_debug_buf = %d\n", __kmp_debug_buf));
1633} // __kmp_stg_parse_debug_buf
1634
1635static void __kmp_stg_print_debug_buf(kmp_str_buf_t *buffer, char const *name,
1636 void *data) {
1638} // __kmp_stg_print_debug_buf
1639
1640static void __kmp_stg_parse_debug_buf_atomic(char const *name,
1641 char const *value, void *data) {
1643} // __kmp_stg_parse_debug_buf_atomic
1644
1645static void __kmp_stg_print_debug_buf_atomic(kmp_str_buf_t *buffer,
1646 char const *name, void *data) {
1648} // __kmp_stg_print_debug_buf_atomic
1649
1650static void __kmp_stg_parse_debug_buf_chars(char const *name, char const *value,
1651 void *data) {
1654} // __kmp_stg_debug_parse_buf_chars
1655
1656static void __kmp_stg_print_debug_buf_chars(kmp_str_buf_t *buffer,
1657 char const *name, void *data) {
1659} // __kmp_stg_print_debug_buf_chars
1660
1661static void __kmp_stg_parse_debug_buf_lines(char const *name, char const *value,
1662 void *data) {
1665} // __kmp_stg_parse_debug_buf_lines
1666
1667static void __kmp_stg_print_debug_buf_lines(kmp_str_buf_t *buffer,
1668 char const *name, void *data) {
1670} // __kmp_stg_print_debug_buf_lines
1671
1672static void __kmp_stg_parse_diag(char const *name, char const *value,
1673 void *data) {
1674 __kmp_stg_parse_int(name, value, 0, INT_MAX, &kmp_diag);
1675} // __kmp_stg_parse_diag
1676
1677static void __kmp_stg_print_diag(kmp_str_buf_t *buffer, char const *name,
1678 void *data) {
1679 __kmp_stg_print_int(buffer, name, kmp_diag);
1680} // __kmp_stg_print_diag
1681
1682#endif // KMP_DEBUG
1683
1684// -----------------------------------------------------------------------------
1685// KMP_ALIGN_ALLOC
1686
1687static void __kmp_stg_parse_align_alloc(char const *name, char const *value,
1688 void *data) {
1689 __kmp_stg_parse_size(name, value, CACHE_LINE, INT_MAX, NULL,
1690 &__kmp_align_alloc, 1);
1691 // Must be power of 2
1693 KMP_WARNING(StgInvalidValue, name, value);
1695 }
1696} // __kmp_stg_parse_align_alloc
1697
1698static void __kmp_stg_print_align_alloc(kmp_str_buf_t *buffer, char const *name,
1699 void *data) {
1701} // __kmp_stg_print_align_alloc
1702
1703// -----------------------------------------------------------------------------
1704// KMP_PLAIN_BARRIER, KMP_FORKJOIN_BARRIER, KMP_REDUCTION_BARRIER
1705
1706// TODO: Remove __kmp_barrier_branch_bit_env_name varibale, remove loops from
1707// parse and print functions, pass required info through data argument.
1708
1710 char const *value, void *data) {
1711 const char *var;
1712
1713 /* ---------- Barrier branch bit control ------------ */
1714 for (int i = bs_plain_barrier; i < bs_last_barrier; i++) {
1716 if ((strcmp(var, name) == 0) && (value != 0)) {
1717 char *comma;
1718
1719 comma = CCAST(char *, strchr(value, ','));
1722 /* is there a specified release parameter? */
1723 if (comma == NULL) {
1725 } else {
1727 (kmp_uint32)__kmp_str_to_int(comma + 1, 0);
1731 KMP_MSG(BarrReleaseValueInvalid, name, comma + 1),
1734 }
1735 }
1738 KMP_WARNING(BarrGatherValueInvalid, name, value);
1739 KMP_INFORM(Using_uint_Value, name, __kmp_barrier_gather_bb_dflt);
1741 }
1742 }
1743 K_DIAG(1, ("%s == %d,%d\n", __kmp_barrier_branch_bit_env_name[i],
1746 }
1747} // __kmp_stg_parse_barrier_branch_bit
1748
1750 char const *name, void *data) {
1751 const char *var;
1752 for (int i = bs_plain_barrier; i < bs_last_barrier; i++) {
1754 if (strcmp(var, name) == 0) {
1755 if (__kmp_env_format) {
1757 } else {
1758 __kmp_str_buf_print(buffer, " %s='",
1760 }
1761 __kmp_str_buf_print(buffer, "%d,%d'\n",
1764 }
1765 }
1766} // __kmp_stg_print_barrier_branch_bit
1767
1768// ----------------------------------------------------------------------------
1769// KMP_PLAIN_BARRIER_PATTERN, KMP_FORKJOIN_BARRIER_PATTERN,
1770// KMP_REDUCTION_BARRIER_PATTERN
1771
1772// TODO: Remove __kmp_barrier_pattern_name variable, remove loops from parse and
1773// print functions, pass required data to functions through data argument.
1774
1775static void __kmp_stg_parse_barrier_pattern(char const *name, char const *value,
1776 void *data) {
1777 const char *var;
1778 /* ---------- Barrier method control ------------ */
1779
1780 static int dist_req = 0, non_dist_req = 0;
1781 static bool warn = 1;
1782 for (int i = bs_plain_barrier; i < bs_last_barrier; i++) {
1784
1785 if ((strcmp(var, name) == 0) && (value != 0)) {
1786 int j;
1787 char *comma = CCAST(char *, strchr(value, ','));
1788
1789 /* handle first parameter: gather pattern */
1790 for (j = bp_linear_bar; j < bp_last_bar; j++) {
1792 ',')) {
1793 if (j == bp_dist_bar) {
1794 dist_req++;
1795 } else {
1796 non_dist_req++;
1797 }
1799 break;
1800 }
1801 }
1802 if (j == bp_last_bar) {
1803 KMP_WARNING(BarrGatherValueInvalid, name, value);
1804 KMP_INFORM(Using_str_Value, name,
1806 }
1807
1808 /* handle second parameter: release pattern */
1809 if (comma != NULL) {
1810 for (j = bp_linear_bar; j < bp_last_bar; j++) {
1811 if (__kmp_str_match(__kmp_barrier_pattern_name[j], 1, comma + 1)) {
1812 if (j == bp_dist_bar) {
1813 dist_req++;
1814 } else {
1815 non_dist_req++;
1816 }
1818 break;
1819 }
1820 }
1821 if (j == bp_last_bar) {
1823 KMP_MSG(BarrReleaseValueInvalid, name, comma + 1),
1825 KMP_INFORM(Using_str_Value, name,
1827 }
1828 }
1829 }
1830 }
1831 if (dist_req != 0) {
1832 // set all barriers to dist
1833 if ((non_dist_req != 0) && warn) {
1834 KMP_INFORM(BarrierPatternOverride, name,
1836 warn = 0;
1837 }
1838 for (int i = bs_plain_barrier; i < bs_last_barrier; i++) {
1843 }
1844 }
1845} // __kmp_stg_parse_barrier_pattern
1846
1848 char const *name, void *data) {
1849 const char *var;
1850 for (int i = bs_plain_barrier; i < bs_last_barrier; i++) {
1852 if (strcmp(var, name) == 0) {
1855 if (__kmp_env_format) {
1857 } else {
1858 __kmp_str_buf_print(buffer, " %s='",
1860 }
1864 }
1865 }
1866} // __kmp_stg_print_barrier_pattern
1867
1868// -----------------------------------------------------------------------------
1869// KMP_ABORT_DELAY
1870
1871static void __kmp_stg_parse_abort_delay(char const *name, char const *value,
1872 void *data) {
1873 // Units of KMP_DELAY_ABORT are seconds, units of __kmp_abort_delay is
1874 // milliseconds.
1875 int delay = __kmp_abort_delay / 1000;
1876 __kmp_stg_parse_int(name, value, 0, INT_MAX / 1000, &delay);
1877 __kmp_abort_delay = delay * 1000;
1878} // __kmp_stg_parse_abort_delay
1879
1880static void __kmp_stg_print_abort_delay(kmp_str_buf_t *buffer, char const *name,
1881 void *data) {
1883} // __kmp_stg_print_abort_delay
1884
1885// -----------------------------------------------------------------------------
1886// KMP_CPUINFO_FILE
1887
1888static void __kmp_stg_parse_cpuinfo_file(char const *name, char const *value,
1889 void *data) {
1890#if KMP_AFFINITY_SUPPORTED
1891 __kmp_stg_parse_str(name, value, &__kmp_cpuinfo_file);
1892 K_DIAG(1, ("__kmp_cpuinfo_file == %s\n", __kmp_cpuinfo_file));
1893#endif
1894} //__kmp_stg_parse_cpuinfo_file
1895
1897 char const *name, void *data) {
1898#if KMP_AFFINITY_SUPPORTED
1899 if (__kmp_env_format) {
1901 } else {
1902 __kmp_str_buf_print(buffer, " %s", name);
1903 }
1904 if (__kmp_cpuinfo_file) {
1905 __kmp_str_buf_print(buffer, "='%s'\n", __kmp_cpuinfo_file);
1906 } else {
1907 __kmp_str_buf_print(buffer, ": %s\n", KMP_I18N_STR(NotDefined));
1908 }
1909#endif
1910} //__kmp_stg_print_cpuinfo_file
1911
1912// -----------------------------------------------------------------------------
1913// KMP_FORCE_REDUCTION, KMP_DETERMINISTIC_REDUCTION
1914
1915static void __kmp_stg_parse_force_reduction(char const *name, char const *value,
1916 void *data) {
1918 int rc;
1919
1920 rc = __kmp_stg_check_rivals(name, value, reduction->rivals);
1921 if (rc) {
1922 return;
1923 }
1924 if (reduction->force) {
1925 if (value != 0) {
1926 if (__kmp_str_match("critical", 0, value))
1928 else if (__kmp_str_match("atomic", 0, value))
1930 else if (__kmp_str_match("tree", 0, value))
1932 else {
1933 KMP_FATAL(UnknownForceReduction, name, value);
1934 }
1935 }
1936 } else {
1938 if (__kmp_determ_red) {
1940 } else {
1942 }
1943 }
1944 K_DIAG(1, ("__kmp_force_reduction_method == %d\n",
1946} // __kmp_stg_parse_force_reduction
1947
1949 char const *name, void *data) {
1950
1952 if (reduction->force) {
1954 __kmp_stg_print_str(buffer, name, "critical");
1956 __kmp_stg_print_str(buffer, name, "atomic");
1958 __kmp_stg_print_str(buffer, name, "tree");
1959 } else {
1960 if (__kmp_env_format) {
1962 } else {
1963 __kmp_str_buf_print(buffer, " %s", name);
1964 }
1965 __kmp_str_buf_print(buffer, ": %s\n", KMP_I18N_STR(NotDefined));
1966 }
1967 } else {
1969 }
1970
1971} // __kmp_stg_print_force_reduction
1972
1973// -----------------------------------------------------------------------------
1974// KMP_STORAGE_MAP
1975
1976static void __kmp_stg_parse_storage_map(char const *name, char const *value,
1977 void *data) {
1978 if (__kmp_str_match("verbose", 1, value)) {
1982
1983 } else {
1986 }
1987} // __kmp_stg_parse_storage_map
1988
1989static void __kmp_stg_print_storage_map(kmp_str_buf_t *buffer, char const *name,
1990 void *data) {
1992 __kmp_stg_print_str(buffer, name, "verbose");
1993 } else {
1995 }
1996} // __kmp_stg_print_storage_map
1997
1998// -----------------------------------------------------------------------------
1999// KMP_ALL_THREADPRIVATE
2000
2002 char const *value, void *data) {
2006} // __kmp_stg_parse_all_threadprivate
2007
2009 char const *name, void *data) {
2011}
2012
2013// -----------------------------------------------------------------------------
2014// KMP_FOREIGN_THREADS_THREADPRIVATE
2015
2017 char const *value,
2018 void *data) {
2020} // __kmp_stg_parse_foreign_threads_threadprivate
2021
2023 char const *name,
2024 void *data) {
2026} // __kmp_stg_print_foreign_threads_threadprivate
2027
2028// -----------------------------------------------------------------------------
2029// KMP_AFFINITY, GOMP_CPU_AFFINITY, KMP_TOPOLOGY_METHOD
2030
2031static inline const char *
2033 switch (type) {
2036 return "unknown";
2037#if KMP_ARCH_X86 || KMP_ARCH_X86_64
2038 case KMP_HW_CORE_TYPE_ATOM:
2039 return "intel_atom";
2040 case KMP_HW_CORE_TYPE_CORE:
2041 return "intel_core";
2042#endif
2043 }
2044 KMP_ASSERT2(false, "Unhandled kmp_hw_core_type_t enumeration");
2046}
2047
2048#if KMP_AFFINITY_SUPPORTED
2049// Parse the proc id list. Return TRUE if successful, FALSE otherwise.
2050static int __kmp_parse_affinity_proc_id_list(const char *var, const char *env,
2051 const char **nextEnv,
2052 char **proclist) {
2053 const char *scan = env;
2054 const char *next = scan;
2055 int empty = TRUE;
2056
2057 *proclist = NULL;
2058
2059 for (;;) {
2060 int start, end, stride;
2061
2062 SKIP_WS(scan);
2063 next = scan;
2064 if (*next == '\0') {
2065 break;
2066 }
2067
2068 if (*next == '{') {
2069 int num;
2070 next++; // skip '{'
2071 SKIP_WS(next);
2072 scan = next;
2073
2074 // Read the first integer in the set.
2075 if ((*next < '0') || (*next > '9')) {
2076 KMP_WARNING(AffSyntaxError, var);
2077 return FALSE;
2078 }
2079 SKIP_DIGITS(next);
2080 num = __kmp_str_to_int(scan, *next);
2081 KMP_ASSERT(num >= 0);
2082
2083 for (;;) {
2084 // Check for end of set.
2085 SKIP_WS(next);
2086 if (*next == '}') {
2087 next++; // skip '}'
2088 break;
2089 }
2090
2091 // Skip optional comma.
2092 if (*next == ',') {
2093 next++;
2094 }
2095 SKIP_WS(next);
2096
2097 // Read the next integer in the set.
2098 scan = next;
2099 if ((*next < '0') || (*next > '9')) {
2100 KMP_WARNING(AffSyntaxError, var);
2101 return FALSE;
2102 }
2103
2104 SKIP_DIGITS(next);
2105 num = __kmp_str_to_int(scan, *next);
2106 KMP_ASSERT(num >= 0);
2107 }
2108 empty = FALSE;
2109
2110 SKIP_WS(next);
2111 if (*next == ',') {
2112 next++;
2113 }
2114 scan = next;
2115 continue;
2116 }
2117
2118 // Next character is not an integer => end of list
2119 if ((*next < '0') || (*next > '9')) {
2120 if (empty) {
2121 KMP_WARNING(AffSyntaxError, var);
2122 return FALSE;
2123 }
2124 break;
2125 }
2126
2127 // Read the first integer.
2128 SKIP_DIGITS(next);
2129 start = __kmp_str_to_int(scan, *next);
2130 KMP_ASSERT(start >= 0);
2131 SKIP_WS(next);
2132
2133 // If this isn't a range, then go on.
2134 if (*next != '-') {
2135 empty = FALSE;
2136
2137 // Skip optional comma.
2138 if (*next == ',') {
2139 next++;
2140 }
2141 scan = next;
2142 continue;
2143 }
2144
2145 // This is a range. Skip over the '-' and read in the 2nd int.
2146 next++; // skip '-'
2147 SKIP_WS(next);
2148 scan = next;
2149 if ((*next < '0') || (*next > '9')) {
2150 KMP_WARNING(AffSyntaxError, var);
2151 return FALSE;
2152 }
2153 SKIP_DIGITS(next);
2154 end = __kmp_str_to_int(scan, *next);
2155 KMP_ASSERT(end >= 0);
2156
2157 // Check for a stride parameter
2158 stride = 1;
2159 SKIP_WS(next);
2160 if (*next == ':') {
2161 // A stride is specified. Skip over the ':" and read the 3rd int.
2162 int sign = +1;
2163 next++; // skip ':'
2164 SKIP_WS(next);
2165 scan = next;
2166 if (*next == '-') {
2167 sign = -1;
2168 next++;
2169 SKIP_WS(next);
2170 scan = next;
2171 }
2172 if ((*next < '0') || (*next > '9')) {
2173 KMP_WARNING(AffSyntaxError, var);
2174 return FALSE;
2175 }
2176 SKIP_DIGITS(next);
2177 stride = __kmp_str_to_int(scan, *next);
2178 KMP_ASSERT(stride >= 0);
2179 stride *= sign;
2180 }
2181
2182 // Do some range checks.
2183 if (stride == 0) {
2184 KMP_WARNING(AffZeroStride, var);
2185 return FALSE;
2186 }
2187 if (stride > 0) {
2188 if (start > end) {
2189 KMP_WARNING(AffStartGreaterEnd, var, start, end);
2190 return FALSE;
2191 }
2192 } else {
2193 if (start < end) {
2194 KMP_WARNING(AffStrideLessZero, var, start, end);
2195 return FALSE;
2196 }
2197 }
2198 if ((end - start) / stride > 65536) {
2199 KMP_WARNING(AffRangeTooBig, var, end, start, stride);
2200 return FALSE;
2201 }
2202
2203 empty = FALSE;
2204
2205 // Skip optional comma.
2206 SKIP_WS(next);
2207 if (*next == ',') {
2208 next++;
2209 }
2210 scan = next;
2211 }
2212
2213 *nextEnv = next;
2214
2215 {
2216 ptrdiff_t len = next - env;
2217 char *retlist = (char *)KMP_INTERNAL_MALLOC((len + 1) * sizeof(char));
2218 KMP_MEMCPY_S(retlist, (len + 1) * sizeof(char), env, len * sizeof(char));
2219 retlist[len] = '\0';
2220 *proclist = retlist;
2221 }
2222 return TRUE;
2223}
2224
2225// If KMP_AFFINITY is specified without a type, then
2226// __kmp_affinity_notype should point to its setting.
2227static kmp_setting_t *__kmp_affinity_notype = NULL;
2228
2229static void __kmp_parse_affinity_env(char const *name, char const *value,
2230 kmp_affinity_t *out_affinity) {
2231 char *buffer = NULL; // Copy of env var value.
2232 char *buf = NULL; // Buffer for strtok_r() function.
2233 char *next = NULL; // end of token / start of next.
2234 const char *start; // start of current token (for err msgs)
2235 int count = 0; // Counter of parsed integer numbers.
2236 int number[2]; // Parsed numbers.
2237
2238 // Guards.
2239 int type = 0;
2240 int proclist = 0;
2241 int verbose = 0;
2242 int warnings = 0;
2243 int respect = 0;
2244 int gran = 0;
2245 int dups = 0;
2246 int reset = 0;
2247 bool set = false;
2248
2249 KMP_ASSERT(value != NULL);
2250
2251 if (TCR_4(__kmp_init_middle)) {
2252 KMP_WARNING(EnvMiddleWarn, name);
2254 return;
2255 }
2257
2258 buffer =
2259 __kmp_str_format("%s", value); // Copy env var to keep original intact.
2260 buf = buffer;
2261 SKIP_WS(buf);
2262
2263// Helper macros.
2264
2265// If we see a parse error, emit a warning and scan to the next ",".
2266//
2267// FIXME - there's got to be a better way to print an error
2268// message, hopefully without overwriting peices of buf.
2269#define EMIT_WARN(skip, errlist) \
2270 { \
2271 char ch; \
2272 if (skip) { \
2273 SKIP_TO(next, ','); \
2274 } \
2275 ch = *next; \
2276 *next = '\0'; \
2277 KMP_WARNING errlist; \
2278 *next = ch; \
2279 if (skip) { \
2280 if (ch == ',') \
2281 next++; \
2282 } \
2283 buf = next; \
2284 }
2285
2286#define _set_param(_guard, _var, _val) \
2287 { \
2288 if (_guard == 0) { \
2289 _var = _val; \
2290 } else { \
2291 EMIT_WARN(FALSE, (AffParamDefined, name, start)); \
2292 } \
2293 ++_guard; \
2294 }
2295
2296#define set_type(val) _set_param(type, out_affinity->type, val)
2297#define set_verbose(val) _set_param(verbose, out_affinity->flags.verbose, val)
2298#define set_warnings(val) \
2299 _set_param(warnings, out_affinity->flags.warnings, val)
2300#define set_respect(val) _set_param(respect, out_affinity->flags.respect, val)
2301#define set_dups(val) _set_param(dups, out_affinity->flags.dups, val)
2302#define set_proclist(val) _set_param(proclist, out_affinity->proclist, val)
2303#define set_reset(val) _set_param(reset, out_affinity->flags.reset, val)
2304
2305#define set_gran(val, levels) \
2306 { \
2307 if (gran == 0) { \
2308 out_affinity->gran = val; \
2309 out_affinity->gran_levels = levels; \
2310 } else { \
2311 EMIT_WARN(FALSE, (AffParamDefined, name, start)); \
2312 } \
2313 ++gran; \
2314 }
2315
2316 KMP_DEBUG_ASSERT((__kmp_nested_proc_bind.bind_types != NULL) &&
2317 (__kmp_nested_proc_bind.used > 0));
2318
2319 while (*buf != '\0') {
2320 start = next = buf;
2321
2322 if (__kmp_match_str("none", buf, CCAST(const char **, &next))) {
2323 set_type(affinity_none);
2325 buf = next;
2326 } else if (__kmp_match_str("scatter", buf, CCAST(const char **, &next))) {
2327 set_type(affinity_scatter);
2329 buf = next;
2330 } else if (__kmp_match_str("compact", buf, CCAST(const char **, &next))) {
2331 set_type(affinity_compact);
2333 buf = next;
2334 } else if (__kmp_match_str("logical", buf, CCAST(const char **, &next))) {
2335 set_type(affinity_logical);
2337 buf = next;
2338 } else if (__kmp_match_str("physical", buf, CCAST(const char **, &next))) {
2339 set_type(affinity_physical);
2341 buf = next;
2342 } else if (__kmp_match_str("explicit", buf, CCAST(const char **, &next))) {
2343 set_type(affinity_explicit);
2345 buf = next;
2346 } else if (__kmp_match_str("balanced", buf, CCAST(const char **, &next))) {
2347 set_type(affinity_balanced);
2349 buf = next;
2350 } else if (__kmp_match_str("disabled", buf, CCAST(const char **, &next))) {
2351 set_type(affinity_disabled);
2353 buf = next;
2354 } else if (__kmp_match_str("verbose", buf, CCAST(const char **, &next))) {
2355 set_verbose(TRUE);
2356 buf = next;
2357 } else if (__kmp_match_str("noverbose", buf, CCAST(const char **, &next))) {
2358 set_verbose(FALSE);
2359 buf = next;
2360 } else if (__kmp_match_str("warnings", buf, CCAST(const char **, &next))) {
2361 set_warnings(TRUE);
2362 buf = next;
2363 } else if (__kmp_match_str("nowarnings", buf,
2364 CCAST(const char **, &next))) {
2365 set_warnings(FALSE);
2366 buf = next;
2367 } else if (__kmp_match_str("respect", buf, CCAST(const char **, &next))) {
2368 set_respect(TRUE);
2369 buf = next;
2370 } else if (__kmp_match_str("norespect", buf, CCAST(const char **, &next))) {
2371 set_respect(FALSE);
2372 buf = next;
2373 } else if (__kmp_match_str("reset", buf, CCAST(const char **, &next))) {
2374 set_reset(TRUE);
2375 buf = next;
2376 } else if (__kmp_match_str("noreset", buf, CCAST(const char **, &next))) {
2377 set_reset(FALSE);
2378 buf = next;
2379 } else if (__kmp_match_str("duplicates", buf,
2380 CCAST(const char **, &next)) ||
2381 __kmp_match_str("dups", buf, CCAST(const char **, &next))) {
2382 set_dups(TRUE);
2383 buf = next;
2384 } else if (__kmp_match_str("noduplicates", buf,
2385 CCAST(const char **, &next)) ||
2386 __kmp_match_str("nodups", buf, CCAST(const char **, &next))) {
2387 set_dups(FALSE);
2388 buf = next;
2389 } else if (__kmp_match_str("granularity", buf,
2390 CCAST(const char **, &next)) ||
2391 __kmp_match_str("gran", buf, CCAST(const char **, &next))) {
2392 SKIP_WS(next);
2393 if (*next != '=') {
2394 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2395 continue;
2396 }
2397 next++; // skip '='
2398 SKIP_WS(next);
2399
2400 buf = next;
2401
2402 // Have to try core_type and core_efficiency matches first since "core"
2403 // will register as core granularity with "extra chars"
2404 if (__kmp_match_str("core_type", buf, CCAST(const char **, &next))) {
2405 set_gran(KMP_HW_CORE, -1);
2406 out_affinity->flags.core_types_gran = 1;
2407 buf = next;
2408 set = true;
2409 } else if (__kmp_match_str("core_efficiency", buf,
2410 CCAST(const char **, &next)) ||
2411 __kmp_match_str("core_eff", buf,
2412 CCAST(const char **, &next))) {
2413 set_gran(KMP_HW_CORE, -1);
2414 out_affinity->flags.core_effs_gran = 1;
2415 buf = next;
2416 set = true;
2417 }
2418 if (!set) {
2419 // Try any hardware topology type for granularity
2421 const char *name = __kmp_hw_get_keyword(type);
2422 if (__kmp_match_str(name, buf, CCAST(const char **, &next))) {
2423 set_gran(type, -1);
2424 buf = next;
2425 set = true;
2426 break;
2427 }
2428 }
2429 }
2430 if (!set) {
2431 // Support older names for different granularity layers
2432 if (__kmp_match_str("fine", buf, CCAST(const char **, &next))) {
2433 set_gran(KMP_HW_THREAD, -1);
2434 buf = next;
2435 set = true;
2436 } else if (__kmp_match_str("package", buf,
2437 CCAST(const char **, &next))) {
2438 set_gran(KMP_HW_SOCKET, -1);
2439 buf = next;
2440 set = true;
2441 } else if (__kmp_match_str("node", buf, CCAST(const char **, &next))) {
2442 set_gran(KMP_HW_NUMA, -1);
2443 buf = next;
2444 set = true;
2445#if KMP_GROUP_AFFINITY
2446 } else if (__kmp_match_str("group", buf, CCAST(const char **, &next))) {
2447 set_gran(KMP_HW_PROC_GROUP, -1);
2448 buf = next;
2449 set = true;
2450#endif /* KMP_GROUP AFFINITY */
2451 } else if ((*buf >= '0') && (*buf <= '9')) {
2452 int n;
2453 next = buf;
2454 SKIP_DIGITS(next);
2455 n = __kmp_str_to_int(buf, *next);
2456 KMP_ASSERT(n >= 0);
2457 buf = next;
2458 set_gran(KMP_HW_UNKNOWN, n);
2459 set = true;
2460 } else {
2461 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2462 continue;
2463 }
2464 }
2465 } else if (__kmp_match_str("proclist", buf, CCAST(const char **, &next))) {
2466 char *temp_proclist;
2467
2468 SKIP_WS(next);
2469 if (*next != '=') {
2470 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2471 continue;
2472 }
2473 next++; // skip '='
2474 SKIP_WS(next);
2475 if (*next != '[') {
2476 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2477 continue;
2478 }
2479 next++; // skip '['
2480 buf = next;
2481 if (!__kmp_parse_affinity_proc_id_list(
2482 name, buf, CCAST(const char **, &next), &temp_proclist)) {
2483 // warning already emitted.
2484 SKIP_TO(next, ']');
2485 if (*next == ']')
2486 next++;
2487 SKIP_TO(next, ',');
2488 if (*next == ',')
2489 next++;
2490 buf = next;
2491 continue;
2492 }
2493 if (*next != ']') {
2494 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2495 continue;
2496 }
2497 next++; // skip ']'
2498 set_proclist(temp_proclist);
2499 } else if ((*buf >= '0') && (*buf <= '9')) {
2500 // Parse integer numbers -- permute and offset.
2501 int n;
2502 next = buf;
2503 SKIP_DIGITS(next);
2504 n = __kmp_str_to_int(buf, *next);
2505 KMP_ASSERT(n >= 0);
2506 buf = next;
2507 if (count < 2) {
2508 number[count] = n;
2509 } else {
2510 KMP_WARNING(AffManyParams, name, start);
2511 }
2512 ++count;
2513 } else {
2514 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2515 continue;
2516 }
2517
2518 SKIP_WS(next);
2519 if (*next == ',') {
2520 next++;
2521 SKIP_WS(next);
2522 } else if (*next != '\0') {
2523 const char *temp = next;
2524 EMIT_WARN(TRUE, (ParseExtraCharsWarn, name, temp));
2525 continue;
2526 }
2527 buf = next;
2528 } // while
2529
2530#undef EMIT_WARN
2531#undef _set_param
2532#undef set_type
2533#undef set_verbose
2534#undef set_warnings
2535#undef set_respect
2536#undef set_granularity
2537#undef set_reset
2538
2539 __kmp_str_free(&buffer);
2540
2541 if (proclist) {
2542 if (!type) {
2543 KMP_WARNING(AffProcListNoType, name);
2544 out_affinity->type = affinity_explicit;
2546 } else if (out_affinity->type != affinity_explicit) {
2547 KMP_WARNING(AffProcListNotExplicit, name);
2548 KMP_ASSERT(out_affinity->proclist != NULL);
2549 KMP_INTERNAL_FREE(out_affinity->proclist);
2550 out_affinity->proclist = NULL;
2551 }
2552 }
2553 switch (out_affinity->type) {
2554 case affinity_logical:
2555 case affinity_physical: {
2556 if (count > 0) {
2557 out_affinity->offset = number[0];
2558 }
2559 if (count > 1) {
2560 KMP_WARNING(AffManyParamsForLogic, name, number[1]);
2561 }
2562 } break;
2563 case affinity_balanced: {
2564 if (count > 0) {
2565 out_affinity->compact = number[0];
2566 }
2567 if (count > 1) {
2568 out_affinity->offset = number[1];
2569 }
2570
2571 if (__kmp_affinity.gran == KMP_HW_UNKNOWN) {
2572 int verbose = out_affinity->flags.verbose;
2573 int warnings = out_affinity->flags.warnings;
2574#if KMP_MIC_SUPPORTED
2575 if (__kmp_mic_type != non_mic) {
2576 if (verbose || warnings) {
2577 KMP_WARNING(AffGranUsing, out_affinity->env_var, "fine");
2578 }
2579 out_affinity->gran = KMP_HW_THREAD;
2580 } else
2581#endif
2582 {
2583 if (verbose || warnings) {
2584 KMP_WARNING(AffGranUsing, out_affinity->env_var, "core");
2585 }
2586 out_affinity->gran = KMP_HW_CORE;
2587 }
2588 }
2589 } break;
2590 case affinity_scatter:
2591 case affinity_compact: {
2592 if (count > 0) {
2593 out_affinity->compact = number[0];
2594 }
2595 if (count > 1) {
2596 out_affinity->offset = number[1];
2597 }
2598 } break;
2599 case affinity_explicit: {
2600 if (out_affinity->proclist == NULL) {
2601 KMP_WARNING(AffNoProcList, name);
2602 out_affinity->type = affinity_none;
2603 }
2604 if (count > 0) {
2605 KMP_WARNING(AffNoParam, name, "explicit");
2606 }
2607 } break;
2608 case affinity_none: {
2609 if (count > 0) {
2610 KMP_WARNING(AffNoParam, name, "none");
2611 }
2612 } break;
2613 case affinity_disabled: {
2614 if (count > 0) {
2615 KMP_WARNING(AffNoParam, name, "disabled");
2616 }
2617 } break;
2618 case affinity_default: {
2619 if (count > 0) {
2620 KMP_WARNING(AffNoParam, name, "default");
2621 }
2622 } break;
2623 default: {
2624 KMP_ASSERT(0);
2625 }
2626 }
2627} // __kmp_parse_affinity_env
2628
2629static void __kmp_stg_parse_affinity(char const *name, char const *value,
2630 void *data) {
2631 kmp_setting_t **rivals = (kmp_setting_t **)data;
2632 int rc;
2633
2634 rc = __kmp_stg_check_rivals(name, value, rivals);
2635 if (rc) {
2636 return;
2637 }
2638
2639 __kmp_parse_affinity_env(name, value, &__kmp_affinity);
2640
2641} // __kmp_stg_parse_affinity
2642static void __kmp_stg_parse_hh_affinity(char const *name, char const *value,
2643 void *data) {
2644 __kmp_parse_affinity_env(name, value, &__kmp_hh_affinity);
2645 // Warn about unused parts of hidden helper affinity settings if specified.
2646 if (__kmp_hh_affinity.flags.reset) {
2647 KMP_WARNING(AffInvalidParam, name, "reset");
2648 }
2649 if (__kmp_hh_affinity.flags.respect != affinity_respect_mask_default) {
2650 KMP_WARNING(AffInvalidParam, name, "respect");
2651 }
2652}
2653
2654static void __kmp_print_affinity_env(kmp_str_buf_t *buffer, char const *name,
2655 const kmp_affinity_t &affinity) {
2656 bool is_hh_affinity = (&affinity == &__kmp_hh_affinity);
2657 if (__kmp_env_format) {
2659 } else {
2660 __kmp_str_buf_print(buffer, " %s='", name);
2661 }
2662 if (affinity.flags.verbose) {
2663 __kmp_str_buf_print(buffer, "%s,", "verbose");
2664 } else {
2665 __kmp_str_buf_print(buffer, "%s,", "noverbose");
2666 }
2667 if (affinity.flags.warnings) {
2668 __kmp_str_buf_print(buffer, "%s,", "warnings");
2669 } else {
2670 __kmp_str_buf_print(buffer, "%s,", "nowarnings");
2671 }
2672 if (KMP_AFFINITY_CAPABLE()) {
2673 // Hidden helper affinity does not affect global reset
2674 // or respect flags. That is still solely controlled by KMP_AFFINITY.
2675 if (!is_hh_affinity) {
2676 if (affinity.flags.respect) {
2677 __kmp_str_buf_print(buffer, "%s,", "respect");
2678 } else {
2679 __kmp_str_buf_print(buffer, "%s,", "norespect");
2680 }
2681 if (affinity.flags.reset) {
2682 __kmp_str_buf_print(buffer, "%s,", "reset");
2683 } else {
2684 __kmp_str_buf_print(buffer, "%s,", "noreset");
2685 }
2686 }
2687 __kmp_str_buf_print(buffer, "granularity=");
2688 if (affinity.flags.core_types_gran)
2689 __kmp_str_buf_print(buffer, "core_type,");
2690 else if (affinity.flags.core_effs_gran) {
2691 __kmp_str_buf_print(buffer, "core_eff,");
2692 } else {
2694 buffer, "%s,", __kmp_hw_get_keyword(affinity.gran, /*plural=*/false));
2695 }
2696 }
2697 if (!KMP_AFFINITY_CAPABLE()) {
2698 __kmp_str_buf_print(buffer, "%s", "disabled");
2699 } else {
2700 int compact = affinity.compact;
2701 int offset = affinity.offset;
2702 switch (affinity.type) {
2703 case affinity_none:
2704 __kmp_str_buf_print(buffer, "%s", "none");
2705 break;
2706 case affinity_physical:
2707 __kmp_str_buf_print(buffer, "%s,%d", "physical", offset);
2708 break;
2709 case affinity_logical:
2710 __kmp_str_buf_print(buffer, "%s,%d", "logical", offset);
2711 break;
2712 case affinity_compact:
2713 __kmp_str_buf_print(buffer, "%s,%d,%d", "compact", compact, offset);
2714 break;
2715 case affinity_scatter:
2716 __kmp_str_buf_print(buffer, "%s,%d,%d", "scatter", compact, offset);
2717 break;
2718 case affinity_explicit:
2719 __kmp_str_buf_print(buffer, "%s=[%s],%s", "proclist", affinity.proclist,
2720 "explicit");
2721 break;
2722 case affinity_balanced:
2723 __kmp_str_buf_print(buffer, "%s,%d,%d", "balanced", compact, offset);
2724 break;
2725 case affinity_disabled:
2726 __kmp_str_buf_print(buffer, "%s", "disabled");
2727 break;
2728 case affinity_default:
2729 __kmp_str_buf_print(buffer, "%s", "default");
2730 break;
2731 default:
2732 __kmp_str_buf_print(buffer, "%s", "<unknown>");
2733 break;
2734 }
2735 }
2736 __kmp_str_buf_print(buffer, "'\n");
2737} //__kmp_stg_print_affinity
2738
2739static void __kmp_stg_print_affinity(kmp_str_buf_t *buffer, char const *name,
2740 void *data) {
2741 __kmp_print_affinity_env(buffer, name, __kmp_affinity);
2742}
2743static void __kmp_stg_print_hh_affinity(kmp_str_buf_t *buffer, char const *name,
2744 void *data) {
2745 __kmp_print_affinity_env(buffer, name, __kmp_hh_affinity);
2746}
2747
2748#ifdef KMP_GOMP_COMPAT
2749
2750static void __kmp_stg_parse_gomp_cpu_affinity(char const *name,
2751 char const *value, void *data) {
2752 const char *next = NULL;
2753 char *temp_proclist;
2754 kmp_setting_t **rivals = (kmp_setting_t **)data;
2755 int rc;
2756
2757 rc = __kmp_stg_check_rivals(name, value, rivals);
2758 if (rc) {
2759 return;
2760 }
2761
2762 if (TCR_4(__kmp_init_middle)) {
2763 KMP_WARNING(EnvMiddleWarn, name);
2765 return;
2766 }
2767
2769
2770 if (__kmp_parse_affinity_proc_id_list(name, value, &next, &temp_proclist)) {
2771 SKIP_WS(next);
2772 if (*next == '\0') {
2773 // GOMP_CPU_AFFINITY => granularity=fine,explicit,proclist=...
2774 __kmp_affinity.proclist = temp_proclist;
2775 __kmp_affinity.type = affinity_explicit;
2776 __kmp_affinity.gran = KMP_HW_THREAD;
2778 } else {
2779 KMP_WARNING(AffSyntaxError, name);
2780 if (temp_proclist != NULL) {
2781 KMP_INTERNAL_FREE((void *)temp_proclist);
2782 }
2783 }
2784 } else {
2785 // Warning already emitted
2786 __kmp_affinity.type = affinity_none;
2788 }
2789} // __kmp_stg_parse_gomp_cpu_affinity
2790
2791#endif /* KMP_GOMP_COMPAT */
2792
2793/*-----------------------------------------------------------------------------
2794The OMP_PLACES proc id list parser. Here is the grammar:
2795
2796place_list := place
2797place_list := place , place_list
2798place := num
2799place := place : num
2800place := place : num : signed
2801place := { subplacelist }
2802place := ! place // (lowest priority)
2803subplace_list := subplace
2804subplace_list := subplace , subplace_list
2805subplace := num
2806subplace := num : num
2807subplace := num : num : signed
2808signed := num
2809signed := + signed
2810signed := - signed
2811-----------------------------------------------------------------------------*/
2812
2813// Return TRUE if successful parse, FALSE otherwise
2814static int __kmp_parse_subplace_list(const char *var, const char **scan) {
2815 const char *next;
2816
2817 for (;;) {
2818 int start, count, stride;
2819
2820 //
2821 // Read in the starting proc id
2822 //
2823 SKIP_WS(*scan);
2824 if ((**scan < '0') || (**scan > '9')) {
2825 return FALSE;
2826 }
2827 next = *scan;
2828 SKIP_DIGITS(next);
2829 start = __kmp_str_to_int(*scan, *next);
2830 KMP_ASSERT(start >= 0);
2831 *scan = next;
2832
2833 // valid follow sets are ',' ':' and '}'
2834 SKIP_WS(*scan);
2835 if (**scan == '}') {
2836 break;
2837 }
2838 if (**scan == ',') {
2839 (*scan)++; // skip ','
2840 continue;
2841 }
2842 if (**scan != ':') {
2843 return FALSE;
2844 }
2845 (*scan)++; // skip ':'
2846
2847 // Read count parameter
2848 SKIP_WS(*scan);
2849 if ((**scan < '0') || (**scan > '9')) {
2850 return FALSE;
2851 }
2852 next = *scan;
2853 SKIP_DIGITS(next);
2854 count = __kmp_str_to_int(*scan, *next);
2855 KMP_ASSERT(count >= 0);
2856 *scan = next;
2857
2858 // valid follow sets are ',' ':' and '}'
2859 SKIP_WS(*scan);
2860 if (**scan == '}') {
2861 break;
2862 }
2863 if (**scan == ',') {
2864 (*scan)++; // skip ','
2865 continue;
2866 }
2867 if (**scan != ':') {
2868 return FALSE;
2869 }
2870 (*scan)++; // skip ':'
2871
2872 // Read stride parameter
2873 int sign = +1;
2874 for (;;) {
2875 SKIP_WS(*scan);
2876 if (**scan == '+') {
2877 (*scan)++; // skip '+'
2878 continue;
2879 }
2880 if (**scan == '-') {
2881 sign *= -1;
2882 (*scan)++; // skip '-'
2883 continue;
2884 }
2885 break;
2886 }
2887 SKIP_WS(*scan);
2888 if ((**scan < '0') || (**scan > '9')) {
2889 return FALSE;
2890 }
2891 next = *scan;
2892 SKIP_DIGITS(next);
2893 stride = __kmp_str_to_int(*scan, *next);
2894 KMP_ASSERT(stride >= 0);
2895 *scan = next;
2896 stride *= sign;
2897
2898 // valid follow sets are ',' and '}'
2899 SKIP_WS(*scan);
2900 if (**scan == '}') {
2901 break;
2902 }
2903 if (**scan == ',') {
2904 (*scan)++; // skip ','
2905 continue;
2906 }
2907 return FALSE;
2908 }
2909 return TRUE;
2910}
2911
2912// Return TRUE if successful parse, FALSE otherwise
2913static int __kmp_parse_place(const char *var, const char **scan) {
2914 const char *next;
2915
2916 // valid follow sets are '{' '!' and num
2917 SKIP_WS(*scan);
2918 if (**scan == '{') {
2919 (*scan)++; // skip '{'
2920 if (!__kmp_parse_subplace_list(var, scan)) {
2921 return FALSE;
2922 }
2923 if (**scan != '}') {
2924 return FALSE;
2925 }
2926 (*scan)++; // skip '}'
2927 } else if (**scan == '!') {
2928 (*scan)++; // skip '!'
2929 return __kmp_parse_place(var, scan); //'!' has lower precedence than ':'
2930 } else if ((**scan >= '0') && (**scan <= '9')) {
2931 next = *scan;
2932 SKIP_DIGITS(next);
2933 int proc = __kmp_str_to_int(*scan, *next);
2934 KMP_ASSERT(proc >= 0);
2935 *scan = next;
2936 } else {
2937 return FALSE;
2938 }
2939 return TRUE;
2940}
2941
2942// Return TRUE if successful parse, FALSE otherwise
2943static int __kmp_parse_place_list(const char *var, const char *env,
2944 char **place_list) {
2945 const char *scan = env;
2946 const char *next = scan;
2947
2948 for (;;) {
2949 int count, stride;
2950
2951 if (!__kmp_parse_place(var, &scan)) {
2952 return FALSE;
2953 }
2954
2955 // valid follow sets are ',' ':' and EOL
2956 SKIP_WS(scan);
2957 if (*scan == '\0') {
2958 break;
2959 }
2960 if (*scan == ',') {
2961 scan++; // skip ','
2962 continue;
2963 }
2964 if (*scan != ':') {
2965 return FALSE;
2966 }
2967 scan++; // skip ':'
2968
2969 // Read count parameter
2970 SKIP_WS(scan);
2971 if ((*scan < '0') || (*scan > '9')) {
2972 return FALSE;
2973 }
2974 next = scan;
2975 SKIP_DIGITS(next);
2976 count = __kmp_str_to_int(scan, *next);
2977 KMP_ASSERT(count >= 0);
2978 scan = next;
2979
2980 // valid follow sets are ',' ':' and EOL
2981 SKIP_WS(scan);
2982 if (*scan == '\0') {
2983 break;
2984 }
2985 if (*scan == ',') {
2986 scan++; // skip ','
2987 continue;
2988 }
2989 if (*scan != ':') {
2990 return FALSE;
2991 }
2992 scan++; // skip ':'
2993
2994 // Read stride parameter
2995 int sign = +1;
2996 for (;;) {
2997 SKIP_WS(scan);
2998 if (*scan == '+') {
2999 scan++; // skip '+'
3000 continue;
3001 }
3002 if (*scan == '-') {
3003 sign *= -1;
3004 scan++; // skip '-'
3005 continue;
3006 }
3007 break;
3008 }
3009 SKIP_WS(scan);
3010 if ((*scan < '0') || (*scan > '9')) {
3011 return FALSE;
3012 }
3013 next = scan;
3014 SKIP_DIGITS(next);
3015 stride = __kmp_str_to_int(scan, *next);
3016 KMP_ASSERT(stride >= 0);
3017 scan = next;
3018 stride *= sign;
3019
3020 // valid follow sets are ',' and EOL
3021 SKIP_WS(scan);
3022 if (*scan == '\0') {
3023 break;
3024 }
3025 if (*scan == ',') {
3026 scan++; // skip ','
3027 continue;
3028 }
3029
3030 return FALSE;
3031 }
3032
3033 {
3034 ptrdiff_t len = scan - env;
3035 char *retlist = (char *)KMP_INTERNAL_MALLOC((len + 1) * sizeof(char));
3036 KMP_MEMCPY_S(retlist, (len + 1) * sizeof(char), env, len * sizeof(char));
3037 retlist[len] = '\0';
3038 *place_list = retlist;
3039 }
3040 return TRUE;
3041}
3042
3043static inline void __kmp_places_set(enum affinity_type type, kmp_hw_t kind) {
3044 __kmp_affinity.type = type;
3045 __kmp_affinity.gran = kind;
3046 __kmp_affinity.flags.dups = FALSE;
3047 __kmp_affinity.flags.omp_places = TRUE;
3048}
3049
3050static void __kmp_places_syntax_error_fallback(char const *name,
3051 kmp_hw_t kind) {
3052 const char *str = __kmp_hw_get_catalog_string(kind, /*plural=*/true);
3053 KMP_WARNING(SyntaxErrorUsing, name, str);
3054 __kmp_places_set(affinity_compact, kind);
3055 if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_default)
3056 __kmp_nested_proc_bind.bind_types[0] = proc_bind_true;
3057}
3058
3059static void __kmp_stg_parse_places(char const *name, char const *value,
3060 void *data) {
3061 struct kmp_place_t {
3062 const char *name;
3063 kmp_hw_t type;
3064 };
3065 int count;
3066 bool set = false;
3067 const char *scan = value;
3068 const char *next = scan;
3069 kmp_place_t std_places[] = {{"threads", KMP_HW_THREAD},
3070 {"cores", KMP_HW_CORE},
3071 {"numa_domains", KMP_HW_NUMA},
3072 {"ll_caches", KMP_HW_LLC},
3073 {"sockets", KMP_HW_SOCKET}};
3074 kmp_setting_t **rivals = (kmp_setting_t **)data;
3075 int rc;
3076
3077 rc = __kmp_stg_check_rivals(name, value, rivals);
3078 if (rc) {
3079 return;
3080 }
3081
3082 // Standard choices
3083 for (size_t i = 0; i < sizeof(std_places) / sizeof(std_places[0]); ++i) {
3084 const kmp_place_t &place = std_places[i];
3085 if (__kmp_match_str(place.name, scan, &next)) {
3086 scan = next;
3087 __kmp_places_set(affinity_compact, place.type);
3088 set = true;
3089 // Parse core attribute if it exists
3090 if (KMP_HW_MAX_NUM_CORE_TYPES > 1) {
3091 SKIP_WS(scan);
3092 if (*scan == ':') {
3093 if (place.type != KMP_HW_CORE) {
3094 __kmp_places_syntax_error_fallback(name, place.type);
3095 return;
3096 }
3097 scan++; // skip ':'
3098 SKIP_WS(scan);
3099#if KMP_ARCH_X86 || KMP_ARCH_X86_64
3100 if (__kmp_match_str("intel_core", scan, &next)) {
3101 __kmp_affinity.core_attr_gran.core_type = KMP_HW_CORE_TYPE_CORE;
3102 __kmp_affinity.core_attr_gran.valid = 1;
3103 scan = next;
3104 } else if (__kmp_match_str("intel_atom", scan, &next)) {
3105 __kmp_affinity.core_attr_gran.core_type = KMP_HW_CORE_TYPE_ATOM;
3106 __kmp_affinity.core_attr_gran.valid = 1;
3107 scan = next;
3108 } else
3109#endif
3110 if (__kmp_match_str("eff", scan, &next)) {
3111 int eff;
3112 if (!isdigit(*next)) {
3113 __kmp_places_syntax_error_fallback(name, place.type);
3114 return;
3115 }
3116 scan = next;
3117 SKIP_DIGITS(next);
3118 eff = __kmp_str_to_int(scan, *next);
3119 if (eff < 0) {
3120 __kmp_places_syntax_error_fallback(name, place.type);
3121 return;
3122 }
3123 if (eff >= KMP_HW_MAX_NUM_CORE_EFFS)
3124 eff = KMP_HW_MAX_NUM_CORE_EFFS - 1;
3125 __kmp_affinity.core_attr_gran.core_eff = eff;
3126 __kmp_affinity.core_attr_gran.valid = 1;
3127 scan = next;
3128 }
3129 if (!__kmp_affinity.core_attr_gran.valid) {
3130 __kmp_places_syntax_error_fallback(name, place.type);
3131 return;
3132 }
3133 }
3134 }
3135 break;
3136 }
3137 }
3138 // Implementation choices for OMP_PLACES based on internal types
3139 if (!set) {
3141 const char *name = __kmp_hw_get_keyword(type, true);
3142 if (__kmp_match_str("unknowns", scan, &next))
3143 continue;
3144 if (__kmp_match_str(name, scan, &next)) {
3145 scan = next;
3146 __kmp_places_set(affinity_compact, type);
3147 set = true;
3148 break;
3149 }
3150 }
3151 }
3152 // Implementation choices for OMP_PLACES based on core attributes
3153 if (!set) {
3154 if (__kmp_match_str("core_types", scan, &next)) {
3155 scan = next;
3156 if (*scan != '\0') {
3157 KMP_WARNING(ParseExtraCharsWarn, name, scan);
3158 }
3159 __kmp_places_set(affinity_compact, KMP_HW_CORE);
3160 __kmp_affinity.flags.core_types_gran = 1;
3161 set = true;
3162 } else if (__kmp_match_str("core_effs", scan, &next) ||
3163 __kmp_match_str("core_efficiencies", scan, &next)) {
3164 scan = next;
3165 if (*scan != '\0') {
3166 KMP_WARNING(ParseExtraCharsWarn, name, scan);
3167 }
3168 __kmp_places_set(affinity_compact, KMP_HW_CORE);
3169 __kmp_affinity.flags.core_effs_gran = 1;
3170 set = true;
3171 }
3172 }
3173 // Explicit place list
3174 if (!set) {
3175 if (__kmp_affinity.proclist != NULL) {
3176 KMP_INTERNAL_FREE((void *)__kmp_affinity.proclist);
3177 __kmp_affinity.proclist = NULL;
3178 }
3179 if (__kmp_parse_place_list(name, value, &__kmp_affinity.proclist)) {
3180 __kmp_places_set(affinity_explicit, KMP_HW_THREAD);
3181 } else {
3182 // Syntax error fallback
3183 __kmp_places_syntax_error_fallback(name, KMP_HW_CORE);
3184 }
3185 if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_default) {
3186 __kmp_nested_proc_bind.bind_types[0] = proc_bind_true;
3187 }
3188 return;
3189 }
3190
3191 kmp_hw_t gran = __kmp_affinity.gran;
3192 if (__kmp_affinity.gran != KMP_HW_UNKNOWN) {
3193 gran = __kmp_affinity.gran;
3194 } else {
3195 gran = KMP_HW_CORE;
3196 }
3197
3198 if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_default) {
3199 __kmp_nested_proc_bind.bind_types[0] = proc_bind_true;
3200 }
3201
3202 SKIP_WS(scan);
3203 if (*scan == '\0') {
3204 return;
3205 }
3206
3207 // Parse option count parameter in parentheses
3208 if (*scan != '(') {
3209 __kmp_places_syntax_error_fallback(name, gran);
3210 return;
3211 }
3212 scan++; // skip '('
3213
3214 SKIP_WS(scan);
3215 next = scan;
3216 SKIP_DIGITS(next);
3217 count = __kmp_str_to_int(scan, *next);
3218 KMP_ASSERT(count >= 0);
3219 scan = next;
3220
3221 SKIP_WS(scan);
3222 if (*scan != ')') {
3223 __kmp_places_syntax_error_fallback(name, gran);
3224 return;
3225 }
3226 scan++; // skip ')'
3227
3228 SKIP_WS(scan);
3229 if (*scan != '\0') {
3230 KMP_WARNING(ParseExtraCharsWarn, name, scan);
3231 }
3233}
3234
3235static void __kmp_stg_print_places(kmp_str_buf_t *buffer, char const *name,
3236 void *data) {
3237 enum affinity_type type = __kmp_affinity.type;
3238 const char *proclist = __kmp_affinity.proclist;
3239 kmp_hw_t gran = __kmp_affinity.gran;
3240
3241 if (__kmp_env_format) {
3243 } else {
3244 __kmp_str_buf_print(buffer, " %s", name);
3245 }
3246 if ((__kmp_nested_proc_bind.used == 0) ||
3247 (__kmp_nested_proc_bind.bind_types == NULL) ||
3248 (__kmp_nested_proc_bind.bind_types[0] == proc_bind_false)) {
3249 __kmp_str_buf_print(buffer, ": %s\n", KMP_I18N_STR(NotDefined));
3250 } else if (type == affinity_explicit) {
3251 if (proclist != NULL) {
3252 __kmp_str_buf_print(buffer, "='%s'\n", proclist);
3253 } else {
3254 __kmp_str_buf_print(buffer, ": %s\n", KMP_I18N_STR(NotDefined));
3255 }
3256 } else if (type == affinity_compact) {
3257 int num;
3258 if (__kmp_affinity.num_masks > 0) {
3259 num = __kmp_affinity.num_masks;
3260 } else if (__kmp_affinity_num_places > 0) {
3262 } else {
3263 num = 0;
3264 }
3265 if (gran != KMP_HW_UNKNOWN) {
3266 // If core_types or core_effs, just print and return
3267 if (__kmp_affinity.flags.core_types_gran) {
3268 __kmp_str_buf_print(buffer, "='%s'\n", "core_types");
3269 return;
3270 }
3271 if (__kmp_affinity.flags.core_effs_gran) {
3272 __kmp_str_buf_print(buffer, "='%s'\n", "core_effs");
3273 return;
3274 }
3275
3276 // threads, cores, sockets, cores:<attribute>, etc.
3277 const char *name = __kmp_hw_get_keyword(gran, true);
3278 __kmp_str_buf_print(buffer, "='%s", name);
3279
3280 // Add core attributes if it exists
3281 if (__kmp_affinity.core_attr_gran.valid) {
3283 (kmp_hw_core_type_t)__kmp_affinity.core_attr_gran.core_type;
3284 int eff = __kmp_affinity.core_attr_gran.core_eff;
3285 if (ct != KMP_HW_CORE_TYPE_UNKNOWN) {
3286 const char *ct_name = __kmp_hw_get_core_type_keyword(ct);
3287 __kmp_str_buf_print(buffer, ":%s", ct_name);
3288 } else if (eff >= 0 && eff < KMP_HW_MAX_NUM_CORE_EFFS) {
3289 __kmp_str_buf_print(buffer, ":eff%d", eff);
3290 }
3291 }
3292
3293 // Add the '(#)' part if it exists
3294 if (num > 0)
3295 __kmp_str_buf_print(buffer, "(%d)", num);
3296 __kmp_str_buf_print(buffer, "'\n");
3297 } else {
3298 __kmp_str_buf_print(buffer, ": %s\n", KMP_I18N_STR(NotDefined));
3299 }
3300 } else {
3301 __kmp_str_buf_print(buffer, ": %s\n", KMP_I18N_STR(NotDefined));
3302 }
3303}
3304
3305static void __kmp_stg_parse_topology_method(char const *name, char const *value,
3306 void *data) {
3307 if (__kmp_str_match("all", 1, value)) {
3308 __kmp_affinity_top_method = affinity_top_method_all;
3309 }
3310#if KMP_HWLOC_ENABLED
3311 else if (__kmp_str_match("hwloc", 1, value)) {
3312 __kmp_affinity_top_method = affinity_top_method_hwloc;
3313 }
3314#endif // KMP_HWLOC_ENABLED
3315#if KMP_ARCH_X86 || KMP_ARCH_X86_64
3316 else if (__kmp_str_match("cpuid_leaf31", 12, value) ||
3317 __kmp_str_match("cpuid 1f", 8, value) ||
3318 __kmp_str_match("cpuid 31", 8, value) ||
3319 __kmp_str_match("cpuid1f", 7, value) ||
3320 __kmp_str_match("cpuid31", 7, value) ||
3321 __kmp_str_match("leaf 1f", 7, value) ||
3322 __kmp_str_match("leaf 31", 7, value) ||
3323 __kmp_str_match("leaf1f", 6, value) ||
3324 __kmp_str_match("leaf31", 6, value)) {
3325 __kmp_affinity_top_method = affinity_top_method_x2apicid_1f;
3326 } else if (__kmp_str_match("x2apic id", 9, value) ||
3327 __kmp_str_match("x2apic_id", 9, value) ||
3328 __kmp_str_match("x2apic-id", 9, value) ||
3329 __kmp_str_match("x2apicid", 8, value) ||
3330 __kmp_str_match("cpuid leaf 11", 13, value) ||
3331 __kmp_str_match("cpuid_leaf_11", 13, value) ||
3332 __kmp_str_match("cpuid-leaf-11", 13, value) ||
3333 __kmp_str_match("cpuid leaf11", 12, value) ||
3334 __kmp_str_match("cpuid_leaf11", 12, value) ||
3335 __kmp_str_match("cpuid-leaf11", 12, value) ||
3336 __kmp_str_match("cpuidleaf 11", 12, value) ||
3337 __kmp_str_match("cpuidleaf_11", 12, value) ||
3338 __kmp_str_match("cpuidleaf-11", 12, value) ||
3339 __kmp_str_match("cpuidleaf11", 11, value) ||
3340 __kmp_str_match("cpuid 11", 8, value) ||
3341 __kmp_str_match("cpuid_11", 8, value) ||
3342 __kmp_str_match("cpuid-11", 8, value) ||
3343 __kmp_str_match("cpuid11", 7, value) ||
3344 __kmp_str_match("leaf 11", 7, value) ||
3345 __kmp_str_match("leaf_11", 7, value) ||
3346 __kmp_str_match("leaf-11", 7, value) ||
3347 __kmp_str_match("leaf11", 6, value)) {
3348 __kmp_affinity_top_method = affinity_top_method_x2apicid;
3349 } else if (__kmp_str_match("apic id", 7, value) ||
3350 __kmp_str_match("apic_id", 7, value) ||
3351 __kmp_str_match("apic-id", 7, value) ||
3352 __kmp_str_match("apicid", 6, value) ||
3353 __kmp_str_match("cpuid leaf 4", 12, value) ||
3354 __kmp_str_match("cpuid_leaf_4", 12, value) ||
3355 __kmp_str_match("cpuid-leaf-4", 12, value) ||
3356 __kmp_str_match("cpuid leaf4", 11, value) ||
3357 __kmp_str_match("cpuid_leaf4", 11, value) ||
3358 __kmp_str_match("cpuid-leaf4", 11, value) ||
3359 __kmp_str_match("cpuidleaf 4", 11, value) ||
3360 __kmp_str_match("cpuidleaf_4", 11, value) ||
3361 __kmp_str_match("cpuidleaf-4", 11, value) ||
3362 __kmp_str_match("cpuidleaf4", 10, value) ||
3363 __kmp_str_match("cpuid 4", 7, value) ||
3364 __kmp_str_match("cpuid_4", 7, value) ||
3365 __kmp_str_match("cpuid-4", 7, value) ||
3366 __kmp_str_match("cpuid4", 6, value) ||
3367 __kmp_str_match("leaf 4", 6, value) ||
3368 __kmp_str_match("leaf_4", 6, value) ||
3369 __kmp_str_match("leaf-4", 6, value) ||
3370 __kmp_str_match("leaf4", 5, value)) {
3371 __kmp_affinity_top_method = affinity_top_method_apicid;
3372 }
3373#endif /* KMP_ARCH_X86 || KMP_ARCH_X86_64 */
3374 else if (__kmp_str_match("/proc/cpuinfo", 2, value) ||
3375 __kmp_str_match("cpuinfo", 5, value)) {
3376 __kmp_affinity_top_method = affinity_top_method_cpuinfo;
3377 }
3378#if KMP_GROUP_AFFINITY
3379 else if (__kmp_str_match("group", 1, value)) {
3380 KMP_WARNING(StgDeprecatedValue, name, value, "all");
3381 __kmp_affinity_top_method = affinity_top_method_group;
3382 }
3383#endif /* KMP_GROUP_AFFINITY */
3384 else if (__kmp_str_match("flat", 1, value)) {
3385 __kmp_affinity_top_method = affinity_top_method_flat;
3386 } else {
3387 KMP_WARNING(StgInvalidValue, name, value);
3388 }
3389} // __kmp_stg_parse_topology_method
3390
3391static void __kmp_stg_print_topology_method(kmp_str_buf_t *buffer,
3392 char const *name, void *data) {
3393 char const *value = NULL;
3394
3395 switch (__kmp_affinity_top_method) {
3396 case affinity_top_method_default:
3397 value = "default";
3398 break;
3399
3400 case affinity_top_method_all:
3401 value = "all";
3402 break;
3403
3404#if KMP_ARCH_X86 || KMP_ARCH_X86_64
3405 case affinity_top_method_x2apicid_1f:
3406 value = "x2APIC id leaf 0x1f";
3407 break;
3408
3409 case affinity_top_method_x2apicid:
3410 value = "x2APIC id leaf 0xb";
3411 break;
3412
3413 case affinity_top_method_apicid:
3414 value = "APIC id";
3415 break;
3416#endif /* KMP_ARCH_X86 || KMP_ARCH_X86_64 */
3417
3418#if KMP_HWLOC_ENABLED
3419 case affinity_top_method_hwloc:
3420 value = "hwloc";
3421 break;
3422#endif // KMP_HWLOC_ENABLED
3423
3424 case affinity_top_method_cpuinfo:
3425 value = "cpuinfo";
3426 break;
3427
3428#if KMP_GROUP_AFFINITY
3429 case affinity_top_method_group:
3430 value = "group";
3431 break;
3432#endif /* KMP_GROUP_AFFINITY */
3433
3434 case affinity_top_method_flat:
3435 value = "flat";
3436 break;
3437 }
3438
3439 if (value != NULL) {
3440 __kmp_stg_print_str(buffer, name, value);
3441 }
3442} // __kmp_stg_print_topology_method
3443
3444// KMP_TEAMS_PROC_BIND
3445struct kmp_proc_bind_info_t {
3446 const char *name;
3447 kmp_proc_bind_t proc_bind;
3448};
3449static kmp_proc_bind_info_t proc_bind_table[] = {
3450 {"spread", proc_bind_spread},
3451 {"true", proc_bind_spread},
3452 {"close", proc_bind_close},
3453 // teams-bind = false means "replicate the primary thread's affinity"
3454 {"false", proc_bind_primary},
3455 {"primary", proc_bind_primary}};
3456static void __kmp_stg_parse_teams_proc_bind(char const *name, char const *value,
3457 void *data) {
3458 int valid;
3459 const char *end;
3460 valid = 0;
3461 for (size_t i = 0; i < sizeof(proc_bind_table) / sizeof(proc_bind_table[0]);
3462 ++i) {
3463 if (__kmp_match_str(proc_bind_table[i].name, value, &end)) {
3464 __kmp_teams_proc_bind = proc_bind_table[i].proc_bind;
3465 valid = 1;
3466 break;
3467 }
3468 }
3469 if (!valid) {
3470 KMP_WARNING(StgInvalidValue, name, value);
3471 }
3472}
3473static void __kmp_stg_print_teams_proc_bind(kmp_str_buf_t *buffer,
3474 char const *name, void *data) {
3475 const char *value = KMP_I18N_STR(NotDefined);
3476 for (size_t i = 0; i < sizeof(proc_bind_table) / sizeof(proc_bind_table[0]);
3477 ++i) {
3478 if (__kmp_teams_proc_bind == proc_bind_table[i].proc_bind) {
3479 value = proc_bind_table[i].name;
3480 break;
3481 }
3482 }
3483 __kmp_stg_print_str(buffer, name, value);
3484}
3485#endif /* KMP_AFFINITY_SUPPORTED */
3486
3487// OMP_PROC_BIND / bind-var is functional on all 4.0 builds, including OS X*
3488// OMP_PLACES / place-partition-var is not.
3489static void __kmp_stg_parse_proc_bind(char const *name, char const *value,
3490 void *data) {
3491 kmp_setting_t **rivals = (kmp_setting_t **)data;
3492 int rc;
3493
3494 rc = __kmp_stg_check_rivals(name, value, rivals);
3495 if (rc) {
3496 return;
3497 }
3498
3499 // In OMP 4.0 OMP_PROC_BIND is a vector of proc_bind types.
3500 KMP_DEBUG_ASSERT((__kmp_nested_proc_bind.bind_types != NULL) &&
3501 (__kmp_nested_proc_bind.used > 0));
3502
3503 const char *buf = value;
3504 const char *next;
3505
3506 SKIP_WS(buf);
3507
3508 next = buf;
3509 if (__kmp_match_str("disabled", buf, &next)) {
3510 buf = next;
3511 SKIP_WS(buf);
3512#if KMP_AFFINITY_SUPPORTED
3513 __kmp_affinity.type = affinity_disabled;
3514#endif /* KMP_AFFINITY_SUPPORTED */
3515 __kmp_nested_proc_bind.used = 1;
3517 } else if (__kmp_match_str("false", buf, &next)) {
3518 buf = next;
3519 SKIP_WS(buf);
3520#if KMP_AFFINITY_SUPPORTED
3521 __kmp_affinity.type = affinity_none;
3522#endif /* KMP_AFFINITY_SUPPORTED */
3523 __kmp_nested_proc_bind.used = 1;
3525 } else if (__kmp_match_str("true", buf, &next)) {
3526 buf = next;
3527 SKIP_WS(buf);
3528 __kmp_nested_proc_bind.used = 1;
3529 __kmp_nested_proc_bind.bind_types[0] = proc_bind_true;
3530 } else {
3531 // Count the number of values in the env var string
3532 const char *scan;
3533 int nelem = 1;
3534 for (scan = buf; *scan != '\0'; scan++) {
3535 if (*scan == ',') {
3536 nelem++;
3537 }
3538 }
3539
3540 // Create / expand the nested proc_bind array as needed
3541 if (__kmp_nested_proc_bind.size < nelem) {
3542 __kmp_nested_proc_bind.bind_types =
3544 __kmp_nested_proc_bind.bind_types,
3545 sizeof(kmp_proc_bind_t) * nelem);
3546 if (__kmp_nested_proc_bind.bind_types == NULL) {
3547 KMP_FATAL(MemoryAllocFailed);
3548 }
3549 __kmp_nested_proc_bind.size = nelem;
3550 }
3551 __kmp_nested_proc_bind.used = nelem;
3552
3553 if (nelem > 1 && !__kmp_dflt_max_active_levels_set)
3555
3556 // Save values in the nested proc_bind array
3557 int i = 0;
3558 for (;;) {
3559 enum kmp_proc_bind_t bind;
3560
3561 if (__kmp_match_str("master", buf, &next) ||
3562 __kmp_match_str("primary", buf, &next)) {
3563 buf = next;
3564 SKIP_WS(buf);
3565 bind = proc_bind_primary;
3566 } else if (__kmp_match_str("close", buf, &next)) {
3567 buf = next;
3568 SKIP_WS(buf);
3569 bind = proc_bind_close;
3570 } else if (__kmp_match_str("spread", buf, &next)) {
3571 buf = next;
3572 SKIP_WS(buf);
3573 bind = proc_bind_spread;
3574 } else {
3575 KMP_WARNING(StgInvalidValue, name, value);
3577 __kmp_nested_proc_bind.used = 1;
3578 return;
3579 }
3580
3581 __kmp_nested_proc_bind.bind_types[i++] = bind;
3582 if (i >= nelem) {
3583 break;
3584 }
3585 if (*buf != ',') {
3586 KMP_WARNING(ParseExtraCharsWarn, name, buf);
3587 while (*buf != ',')
3588 buf++;
3589 }
3590 buf++;
3591 SKIP_WS(buf);
3592 }
3593 SKIP_WS(buf);
3594 }
3595 if (*buf != '\0') {
3596 KMP_WARNING(ParseExtraCharsWarn, name, buf);
3597 }
3598}
3599
3600static void __kmp_stg_print_proc_bind(kmp_str_buf_t *buffer, char const *name,
3601 void *data) {
3602 int nelem = __kmp_nested_proc_bind.used;
3603 if (__kmp_env_format) {
3605 } else {
3606 __kmp_str_buf_print(buffer, " %s", name);
3607 }
3608 if (nelem == 0) {
3609 __kmp_str_buf_print(buffer, ": %s\n", KMP_I18N_STR(NotDefined));
3610 } else {
3611 int i;
3612 __kmp_str_buf_print(buffer, "='", name);
3613 for (i = 0; i < nelem; i++) {
3614 switch (__kmp_nested_proc_bind.bind_types[i]) {
3615 case proc_bind_false:
3616 __kmp_str_buf_print(buffer, "false");
3617 break;
3618
3619 case proc_bind_true:
3620 __kmp_str_buf_print(buffer, "true");
3621 break;
3622
3623 case proc_bind_primary:
3624 __kmp_str_buf_print(buffer, "primary");
3625 break;
3626
3627 case proc_bind_close:
3628 __kmp_str_buf_print(buffer, "close");
3629 break;
3630
3631 case proc_bind_spread:
3632 __kmp_str_buf_print(buffer, "spread");
3633 break;
3634
3635 case proc_bind_intel:
3636 __kmp_str_buf_print(buffer, "intel");
3637 break;
3638
3639 case proc_bind_default:
3640 __kmp_str_buf_print(buffer, "default");
3641 break;
3642 }
3643 if (i < nelem - 1) {
3644 __kmp_str_buf_print(buffer, ",");
3645 }
3646 }
3647 __kmp_str_buf_print(buffer, "'\n");
3648 }
3649}
3650
3652 char const *value, void *data) {
3654}
3656 char const *name, void *data) {
3658}
3659static void __kmp_stg_parse_affinity_format(char const *name, char const *value,
3660 void *data) {
3661 size_t length = KMP_STRLEN(value);
3663 length);
3664}
3666 char const *name, void *data) {
3667 if (__kmp_env_format) {
3669 } else {
3670 __kmp_str_buf_print(buffer, " %s='", name);
3671 }
3673}
3674
3675/*-----------------------------------------------------------------------------
3676OMP_ALLOCATOR sets default allocator. Here is the grammar:
3677
3678<allocator> |= <predef-allocator> | <predef-mem-space> |
3679 <predef-mem-space>:<traits>
3680<traits> |= <trait>=<value> | <trait>=<value>,<traits>
3681<predef-allocator> |= omp_default_mem_alloc | omp_large_cap_mem_alloc |
3682 omp_const_mem_alloc | omp_high_bw_mem_alloc |
3683 omp_low_lat_mem_alloc | omp_cgroup_mem_alloc |
3684 omp_pteam_mem_alloc | omp_thread_mem_alloc
3685<predef-mem-space> |= omp_default_mem_space | omp_large_cap_mem_space |
3686 omp_const_mem_space | omp_high_bw_mem_space |
3687 omp_low_lat_mem_space
3688<trait> |= sync_hint | alignment | access | pool_size | fallback |
3689 fb_data | pinned | partition
3690<value> |= one of the allowed values of trait |
3691 non-negative integer | <predef-allocator>
3692-----------------------------------------------------------------------------*/
3693
3694static void __kmp_stg_parse_allocator(char const *name, char const *value,
3695 void *data) {
3696 const char *buf = value;
3697 const char *next, *scan, *start;
3698 char *key;
3701 bool is_memspace = false;
3702 int ntraits = 0, count = 0;
3703
3704 SKIP_WS(buf);
3705 next = buf;
3706 const char *delim = strchr(buf, ':');
3707 const char *predef_mem_space = strstr(buf, "mem_space");
3708
3709 bool is_memalloc = (!predef_mem_space && !delim) ? true : false;
3710
3711 // Count the number of traits in the env var string
3712 if (delim) {
3713 ntraits = 1;
3714 for (scan = buf; *scan != '\0'; scan++) {
3715 if (*scan == ',')
3716 ntraits++;
3717 }
3718 }
3719 omp_alloctrait_t *traits =
3720 (omp_alloctrait_t *)KMP_ALLOCA(ntraits * sizeof(omp_alloctrait_t));
3721
3722// Helper macros
3723#define IS_POWER_OF_TWO(n) (((n) & ((n)-1)) == 0)
3724
3725#define GET_NEXT(sentinel) \
3726 { \
3727 SKIP_WS(next); \
3728 if (*next == sentinel) \
3729 next++; \
3730 SKIP_WS(next); \
3731 scan = next; \
3732 }
3733
3734#define SKIP_PAIR(key) \
3735 { \
3736 char const str_delimiter[] = {',', 0}; \
3737 char *value = __kmp_str_token(CCAST(char *, scan), str_delimiter, \
3738 CCAST(char **, &next)); \
3739 KMP_WARNING(StgInvalidValue, key, value); \
3740 ntraits--; \
3741 SKIP_WS(next); \
3742 scan = next; \
3743 }
3744
3745#define SET_KEY() \
3746 { \
3747 char const str_delimiter[] = {'=', 0}; \
3748 key = __kmp_str_token(CCAST(char *, start), str_delimiter, \
3749 CCAST(char **, &next)); \
3750 scan = next; \
3751 }
3752
3753 scan = next;
3754 while (*next != '\0') {
3755 if (is_memalloc ||
3756 __kmp_match_str("fb_data", scan, &next)) { // allocator check
3757 start = scan;
3758 GET_NEXT('=');
3759 // check HBW and LCAP first as the only non-default supported
3760 if (__kmp_match_str("omp_high_bw_mem_alloc", scan, &next)) {
3761 SKIP_WS(next);
3762 if (is_memalloc) {
3765 return;
3766 } else {
3767 KMP_WARNING(OmpNoAllocator, "omp_high_bw_mem_alloc");
3768 }
3769 } else {
3770 traits[count].key = omp_atk_fb_data;
3772 }
3773 } else if (__kmp_match_str("omp_large_cap_mem_alloc", scan, &next)) {
3774 SKIP_WS(next);
3775 if (is_memalloc) {
3778 return;
3779 } else {
3780 KMP_WARNING(OmpNoAllocator, "omp_large_cap_mem_alloc");
3781 }
3782 } else {
3783 traits[count].key = omp_atk_fb_data;
3785 }
3786 } else if (__kmp_match_str("omp_default_mem_alloc", scan, &next)) {
3787 // default requested
3788 SKIP_WS(next);
3789 if (!is_memalloc) {
3790 traits[count].key = omp_atk_fb_data;
3792 }
3793 } else if (__kmp_match_str("omp_const_mem_alloc", scan, &next)) {
3794 SKIP_WS(next);
3795 if (is_memalloc) {
3796 KMP_WARNING(OmpNoAllocator, "omp_const_mem_alloc");
3797 } else {
3798 traits[count].key = omp_atk_fb_data;
3800 }
3801 } else if (__kmp_match_str("omp_low_lat_mem_alloc", scan, &next)) {
3802 SKIP_WS(next);
3803 if (is_memalloc) {
3804 KMP_WARNING(OmpNoAllocator, "omp_low_lat_mem_alloc");
3805 } else {
3806 traits[count].key = omp_atk_fb_data;
3808 }
3809 } else if (__kmp_match_str("omp_cgroup_mem_alloc", scan, &next)) {
3810 SKIP_WS(next);
3811 if (is_memalloc) {
3812 KMP_WARNING(OmpNoAllocator, "omp_cgroup_mem_alloc");
3813 } else {
3814 traits[count].key = omp_atk_fb_data;
3816 }
3817 } else if (__kmp_match_str("omp_pteam_mem_alloc", scan, &next)) {
3818 SKIP_WS(next);
3819 if (is_memalloc) {
3820 KMP_WARNING(OmpNoAllocator, "omp_pteam_mem_alloc");
3821 } else {
3822 traits[count].key = omp_atk_fb_data;
3824 }
3825 } else if (__kmp_match_str("omp_thread_mem_alloc", scan, &next)) {
3826 SKIP_WS(next);
3827 if (is_memalloc) {
3828 KMP_WARNING(OmpNoAllocator, "omp_thread_mem_alloc");
3829 } else {
3830 traits[count].key = omp_atk_fb_data;
3832 }
3833 } else {
3834 if (!is_memalloc) {
3835 SET_KEY();
3836 SKIP_PAIR(key);
3837 continue;
3838 }
3839 }
3840 if (is_memalloc) {
3842 if (next == buf || *next != '\0') {
3843 // either no match or extra symbols present after the matched token
3844 KMP_WARNING(StgInvalidValue, name, value);
3845 }
3846 return;
3847 } else {
3848 ++count;
3849 if (count == ntraits)
3850 break;
3851 GET_NEXT(',');
3852 }
3853 } else { // memspace
3854 if (!is_memspace) {
3855 if (__kmp_match_str("omp_default_mem_space", scan, &next)) {
3856 SKIP_WS(next);
3858 } else if (__kmp_match_str("omp_large_cap_mem_space", scan, &next)) {
3859 SKIP_WS(next);
3861 } else if (__kmp_match_str("omp_const_mem_space", scan, &next)) {
3862 SKIP_WS(next);
3864 } else if (__kmp_match_str("omp_high_bw_mem_space", scan, &next)) {
3865 SKIP_WS(next);
3867 } else if (__kmp_match_str("omp_low_lat_mem_space", scan, &next)) {
3868 SKIP_WS(next);
3870 } else {
3872 if (next == buf || *next != '\0') {
3873 // either no match or extra symbols present after the matched token
3874 KMP_WARNING(StgInvalidValue, name, value);
3875 }
3876 return;
3877 }
3878 is_memspace = true;
3879 }
3880 if (delim) { // traits
3881 GET_NEXT(':');
3882 start = scan;
3883 if (__kmp_match_str("sync_hint", scan, &next)) {
3884 GET_NEXT('=');
3885 traits[count].key = omp_atk_sync_hint;
3886 if (__kmp_match_str("contended", scan, &next)) {
3887 traits[count].value = omp_atv_contended;
3888 } else if (__kmp_match_str("uncontended", scan, &next)) {
3890 } else if (__kmp_match_str("serialized", scan, &next)) {
3891 traits[count].value = omp_atv_serialized;
3892 } else if (__kmp_match_str("private", scan, &next)) {
3893 traits[count].value = omp_atv_private;
3894 } else {
3895 SET_KEY();
3896 SKIP_PAIR(key);
3897 continue;
3898 }
3899 } else if (__kmp_match_str("alignment", scan, &next)) {
3900 GET_NEXT('=');
3901 if (!isdigit(*next)) {
3902 SET_KEY();
3903 SKIP_PAIR(key);
3904 continue;
3905 }
3906 SKIP_DIGITS(next);
3907 int n = __kmp_str_to_int(scan, ',');
3908 if (n < 0 || !IS_POWER_OF_TWO(n)) {
3909 SET_KEY();
3910 SKIP_PAIR(key);
3911 continue;
3912 }
3913 traits[count].key = omp_atk_alignment;
3914 traits[count].value = n;
3915 } else if (__kmp_match_str("access", scan, &next)) {
3916 GET_NEXT('=');
3917 traits[count].key = omp_atk_access;
3918 if (__kmp_match_str("all", scan, &next)) {
3919 traits[count].value = omp_atv_all;
3920 } else if (__kmp_match_str("cgroup", scan, &next)) {
3921 traits[count].value = omp_atv_cgroup;
3922 } else if (__kmp_match_str("pteam", scan, &next)) {
3923 traits[count].value = omp_atv_pteam;
3924 } else if (__kmp_match_str("thread", scan, &next)) {
3925 traits[count].value = omp_atv_thread;
3926 } else {
3927 SET_KEY();
3928 SKIP_PAIR(key);
3929 continue;
3930 }
3931 } else if (__kmp_match_str("pool_size", scan, &next)) {
3932 GET_NEXT('=');
3933 if (!isdigit(*next)) {
3934 SET_KEY();
3935 SKIP_PAIR(key);
3936 continue;
3937 }
3938 SKIP_DIGITS(next);
3939 int n = __kmp_str_to_int(scan, ',');
3940 if (n < 0) {
3941 SET_KEY();
3942 SKIP_PAIR(key);
3943 continue;
3944 }
3945 traits[count].key = omp_atk_pool_size;
3946 traits[count].value = n;
3947 } else if (__kmp_match_str("fallback", scan, &next)) {
3948 GET_NEXT('=');
3949 traits[count].key = omp_atk_fallback;
3950 if (__kmp_match_str("default_mem_fb", scan, &next)) {
3952 } else if (__kmp_match_str("null_fb", scan, &next)) {
3953 traits[count].value = omp_atv_null_fb;
3954 } else if (__kmp_match_str("abort_fb", scan, &next)) {
3955 traits[count].value = omp_atv_abort_fb;
3956 } else if (__kmp_match_str("allocator_fb", scan, &next)) {
3958 } else {
3959 SET_KEY();
3960 SKIP_PAIR(key);
3961 continue;
3962 }
3963 } else if (__kmp_match_str("pinned", scan, &next)) {
3964 GET_NEXT('=');
3965 traits[count].key = omp_atk_pinned;
3966 if (__kmp_str_match_true(next)) {
3967 traits[count].value = omp_atv_true;
3968 } else if (__kmp_str_match_false(next)) {
3969 traits[count].value = omp_atv_false;
3970 } else {
3971 SET_KEY();
3972 SKIP_PAIR(key);
3973 continue;
3974 }
3975 } else if (__kmp_match_str("partition", scan, &next)) {
3976 GET_NEXT('=');
3977 traits[count].key = omp_atk_partition;
3978 if (__kmp_match_str("environment", scan, &next)) {
3980 } else if (__kmp_match_str("nearest", scan, &next)) {
3981 traits[count].value = omp_atv_nearest;
3982 } else if (__kmp_match_str("blocked", scan, &next)) {
3983 traits[count].value = omp_atv_blocked;
3984 } else if (__kmp_match_str("interleaved", scan, &next)) {
3986 } else {
3987 SET_KEY();
3988 SKIP_PAIR(key);
3989 continue;
3990 }
3991 } else {
3992 SET_KEY();
3993 SKIP_PAIR(key);
3994 continue;
3995 }
3996 SKIP_WS(next);
3997 ++count;
3998 if (count == ntraits)
3999 break;
4000 GET_NEXT(',');
4001 } // traits
4002 } // memspace
4003 } // while
4004 al = __kmpc_init_allocator(__kmp_get_gtid(), ms, ntraits, traits);
4006}
4007
4008static void __kmp_stg_print_allocator(kmp_str_buf_t *buffer, char const *name,
4009 void *data) {
4011 __kmp_stg_print_str(buffer, name, "omp_default_mem_alloc");
4013 __kmp_stg_print_str(buffer, name, "omp_high_bw_mem_alloc");
4015 __kmp_stg_print_str(buffer, name, "omp_large_cap_mem_alloc");
4017 __kmp_stg_print_str(buffer, name, "omp_const_mem_alloc");
4019 __kmp_stg_print_str(buffer, name, "omp_low_lat_mem_alloc");
4021 __kmp_stg_print_str(buffer, name, "omp_cgroup_mem_alloc");
4023 __kmp_stg_print_str(buffer, name, "omp_pteam_mem_alloc");
4025 __kmp_stg_print_str(buffer, name, "omp_thread_mem_alloc");
4026 }
4027}
4028
4029// -----------------------------------------------------------------------------
4030// OMP_DYNAMIC
4031
4032static void __kmp_stg_parse_omp_dynamic(char const *name, char const *value,
4033 void *data) {
4034 __kmp_stg_parse_bool(name, value, &(__kmp_global.g.g_dynamic));
4035} // __kmp_stg_parse_omp_dynamic
4036
4037static void __kmp_stg_print_omp_dynamic(kmp_str_buf_t *buffer, char const *name,
4038 void *data) {
4039 __kmp_stg_print_bool(buffer, name, __kmp_global.g.g_dynamic);
4040} // __kmp_stg_print_omp_dynamic
4041
4043 char const *value, void *data) {
4045 KMP_WARNING(EnvParallelWarn, name);
4047 return;
4048 }
4049#ifdef USE_LOAD_BALANCE
4050 else if (__kmp_str_match("load balance", 2, value) ||
4051 __kmp_str_match("load_balance", 2, value) ||
4052 __kmp_str_match("load-balance", 2, value) ||
4053 __kmp_str_match("loadbalance", 2, value) ||
4054 __kmp_str_match("balance", 1, value)) {
4055 __kmp_global.g.g_dynamic_mode = dynamic_load_balance;
4056 }
4057#endif /* USE_LOAD_BALANCE */
4058 else if (__kmp_str_match("thread limit", 1, value) ||
4059 __kmp_str_match("thread_limit", 1, value) ||
4060 __kmp_str_match("thread-limit", 1, value) ||
4061 __kmp_str_match("threadlimit", 1, value) ||
4062 __kmp_str_match("limit", 2, value)) {
4063 __kmp_global.g.g_dynamic_mode = dynamic_thread_limit;
4064 } else if (__kmp_str_match("random", 1, value)) {
4065 __kmp_global.g.g_dynamic_mode = dynamic_random;
4066 } else {
4067 KMP_WARNING(StgInvalidValue, name, value);
4068 }
4069} //__kmp_stg_parse_kmp_dynamic_mode
4070
4072 char const *name, void *data) {
4073#if KMP_DEBUG
4074 if (__kmp_global.g.g_dynamic_mode == dynamic_default) {
4075 __kmp_str_buf_print(buffer, " %s: %s \n", name, KMP_I18N_STR(NotDefined));
4076 }
4077#ifdef USE_LOAD_BALANCE
4078 else if (__kmp_global.g.g_dynamic_mode == dynamic_load_balance) {
4079 __kmp_stg_print_str(buffer, name, "load balance");
4080 }
4081#endif /* USE_LOAD_BALANCE */
4082 else if (__kmp_global.g.g_dynamic_mode == dynamic_thread_limit) {
4083 __kmp_stg_print_str(buffer, name, "thread limit");
4084 } else if (__kmp_global.g.g_dynamic_mode == dynamic_random) {
4085 __kmp_stg_print_str(buffer, name, "random");
4086 } else {
4087 KMP_ASSERT(0);
4088 }
4089#endif /* KMP_DEBUG */
4090} // __kmp_stg_print_kmp_dynamic_mode
4091
4092#ifdef USE_LOAD_BALANCE
4093
4094// -----------------------------------------------------------------------------
4095// KMP_LOAD_BALANCE_INTERVAL
4096
4097static void __kmp_stg_parse_ld_balance_interval(char const *name,
4098 char const *value, void *data) {
4099 double interval = __kmp_convert_to_double(value);
4100 if (interval >= 0) {
4101 __kmp_load_balance_interval = interval;
4102 } else {
4103 KMP_WARNING(StgInvalidValue, name, value);
4104 }
4105} // __kmp_stg_parse_load_balance_interval
4106
4107static void __kmp_stg_print_ld_balance_interval(kmp_str_buf_t *buffer,
4108 char const *name, void *data) {
4109#if KMP_DEBUG
4110 __kmp_str_buf_print(buffer, " %s=%8.6f\n", name,
4111 __kmp_load_balance_interval);
4112#endif /* KMP_DEBUG */
4113} // __kmp_stg_print_load_balance_interval
4114
4115#endif /* USE_LOAD_BALANCE */
4116
4117// -----------------------------------------------------------------------------
4118// KMP_INIT_AT_FORK
4119
4120static void __kmp_stg_parse_init_at_fork(char const *name, char const *value,
4121 void *data) {
4125 }
4126} // __kmp_stg_parse_init_at_fork
4127
4129 char const *name, void *data) {
4131} // __kmp_stg_print_init_at_fork
4132
4133// -----------------------------------------------------------------------------
4134// KMP_SCHEDULE
4135
4136static void __kmp_stg_parse_schedule(char const *name, char const *value,
4137 void *data) {
4138
4139 if (value != NULL) {
4140 size_t length = KMP_STRLEN(value);
4141 if (length > INT_MAX) {
4142 KMP_WARNING(LongValue, name);
4143 } else {
4144 const char *semicolon;
4145 if (value[length - 1] == '"' || value[length - 1] == '\'')
4146 KMP_WARNING(UnbalancedQuotes, name);
4147 do {
4148 char sentinel;
4149
4150 semicolon = strchr(value, ';');
4151 if (*value && semicolon != value) {
4152 const char *comma = strchr(value, ',');
4153
4154 if (comma) {
4155 ++comma;
4156 sentinel = ',';
4157 } else
4158 sentinel = ';';
4159 if (!__kmp_strcasecmp_with_sentinel("static", value, sentinel)) {
4160 if (!__kmp_strcasecmp_with_sentinel("greedy", comma, ';')) {
4162 continue;
4163 } else if (!__kmp_strcasecmp_with_sentinel("balanced", comma,
4164 ';')) {
4166 continue;
4167 }
4168 } else if (!__kmp_strcasecmp_with_sentinel("guided", value,
4169 sentinel)) {
4170 if (!__kmp_strcasecmp_with_sentinel("iterative", comma, ';')) {
4172 continue;
4173 } else if (!__kmp_strcasecmp_with_sentinel("analytical", comma,
4174 ';')) {
4175 /* analytical not allowed for too many threads */
4177 continue;
4178 }
4179 }
4180 KMP_WARNING(InvalidClause, name, value);
4181 } else
4182 KMP_WARNING(EmptyClause, name);
4183 } while ((value = semicolon ? semicolon + 1 : NULL));
4184 }
4185 }
4186
4187} // __kmp_stg_parse__schedule
4188
4189static void __kmp_stg_print_schedule(kmp_str_buf_t *buffer, char const *name,
4190 void *data) {
4191 if (__kmp_env_format) {
4193 } else {
4194 __kmp_str_buf_print(buffer, " %s='", name);
4195 }
4197 __kmp_str_buf_print(buffer, "%s", "static,greedy");
4198 } else if (__kmp_static == kmp_sch_static_balanced) {
4199 __kmp_str_buf_print(buffer, "%s", "static,balanced");
4200 }
4202 __kmp_str_buf_print(buffer, ";%s'\n", "guided,iterative");
4204 __kmp_str_buf_print(buffer, ";%s'\n", "guided,analytical");
4205 }
4206} // __kmp_stg_print_schedule
4207
4208// -----------------------------------------------------------------------------
4209// OMP_SCHEDULE
4210
4211static inline void __kmp_omp_schedule_restore() {
4212#if KMP_USE_HIER_SCHED
4213 __kmp_hier_scheds.deallocate();
4214#endif
4215 __kmp_chunk = 0;
4217}
4218
4219// if parse_hier = true:
4220// Parse [HW,][modifier:]kind[,chunk]
4221// else:
4222// Parse [modifier:]kind[,chunk]
4223static const char *__kmp_parse_single_omp_schedule(const char *name,
4224 const char *value,
4225 bool parse_hier = false) {
4226 /* get the specified scheduling style */
4227 const char *ptr = value;
4228 const char *delim;
4229 int chunk = 0;
4231 if (*ptr == '\0')
4232 return NULL;
4233 delim = ptr;
4234 while (*delim != ',' && *delim != ':' && *delim != '\0')
4235 delim++;
4236#if KMP_USE_HIER_SCHED
4238 if (parse_hier) {
4239 if (*delim == ',') {
4240 if (!__kmp_strcasecmp_with_sentinel("L1", ptr, ',')) {
4242 } else if (!__kmp_strcasecmp_with_sentinel("L2", ptr, ',')) {
4244 } else if (!__kmp_strcasecmp_with_sentinel("L3", ptr, ',')) {
4246 } else if (!__kmp_strcasecmp_with_sentinel("NUMA", ptr, ',')) {
4248 }
4249 }
4250 if (layer != kmp_hier_layer_e::LAYER_THREAD && *delim != ',') {
4251 // If there is no comma after the layer, then this schedule is invalid
4252 KMP_WARNING(StgInvalidValue, name, value);
4254 return NULL;
4255 } else if (layer != kmp_hier_layer_e::LAYER_THREAD) {
4256 ptr = ++delim;
4257 while (*delim != ',' && *delim != ':' && *delim != '\0')
4258 delim++;
4259 }
4260 }
4261#endif // KMP_USE_HIER_SCHED
4262 // Read in schedule modifier if specified
4263 enum sched_type sched_modifier = (enum sched_type)0;
4264 if (*delim == ':') {
4265 if (!__kmp_strcasecmp_with_sentinel("monotonic", ptr, *delim)) {
4267 ptr = ++delim;
4268 while (*delim != ',' && *delim != ':' && *delim != '\0')
4269 delim++;
4270 } else if (!__kmp_strcasecmp_with_sentinel("nonmonotonic", ptr, *delim)) {
4272 ptr = ++delim;
4273 while (*delim != ',' && *delim != ':' && *delim != '\0')
4274 delim++;
4275 } else if (!parse_hier) {
4276 // If there is no proper schedule modifier, then this schedule is invalid
4277 KMP_WARNING(StgInvalidValue, name, value);
4279 return NULL;
4280 }
4281 }
4282 // Read in schedule kind (required)
4283 if (!__kmp_strcasecmp_with_sentinel("dynamic", ptr, *delim))
4285 else if (!__kmp_strcasecmp_with_sentinel("guided", ptr, *delim))
4287 // AC: TODO: probably remove TRAPEZOIDAL (OMP 3.0 does not allow it)
4288 else if (!__kmp_strcasecmp_with_sentinel("auto", ptr, *delim))
4290 else if (!__kmp_strcasecmp_with_sentinel("trapezoidal", ptr, *delim))
4292 else if (!__kmp_strcasecmp_with_sentinel("static", ptr, *delim))
4294#if KMP_STATIC_STEAL_ENABLED
4295 else if (!__kmp_strcasecmp_with_sentinel("static_steal", ptr, *delim)) {
4296 // replace static_steal with dynamic to better cope with ordered loops
4299 }
4300#endif
4301 else {
4302 // If there is no proper schedule kind, then this schedule is invalid
4303 KMP_WARNING(StgInvalidValue, name, value);
4305 return NULL;
4306 }
4307
4308 // Read in schedule chunk size if specified
4309 if (*delim == ',') {
4310 ptr = delim + 1;
4311 SKIP_WS(ptr);
4312 if (!isdigit(*ptr)) {
4313 // If there is no chunk after comma, then this schedule is invalid
4314 KMP_WARNING(StgInvalidValue, name, value);
4316 return NULL;
4317 }
4318 SKIP_DIGITS(ptr);
4319 // auto schedule should not specify chunk size
4320 if (sched == kmp_sch_auto) {
4321 __kmp_msg(kmp_ms_warning, KMP_MSG(IgnoreChunk, name, delim),
4323 } else {
4324 if (sched == kmp_sch_static)
4326 chunk = __kmp_str_to_int(delim + 1, *ptr);
4327 if (chunk < 1) {
4328 chunk = KMP_DEFAULT_CHUNK;
4329 __kmp_msg(kmp_ms_warning, KMP_MSG(InvalidChunk, name, delim),
4331 KMP_INFORM(Using_int_Value, name, __kmp_chunk);
4332 // AC: next block commented out until KMP_DEFAULT_CHUNK != KMP_MIN_CHUNK
4333 // (to improve code coverage :)
4334 // The default chunk size is 1 according to standard, thus making
4335 // KMP_MIN_CHUNK not 1 we would introduce mess:
4336 // wrong chunk becomes 1, but it will be impossible to explicitly set
4337 // to 1 because it becomes KMP_MIN_CHUNK...
4338 // } else if ( chunk < KMP_MIN_CHUNK ) {
4339 // chunk = KMP_MIN_CHUNK;
4340 } else if (chunk > KMP_MAX_CHUNK) {
4341 chunk = KMP_MAX_CHUNK;
4342 __kmp_msg(kmp_ms_warning, KMP_MSG(LargeChunk, name, delim),
4344 KMP_INFORM(Using_int_Value, name, chunk);
4345 }
4346 }
4347 } else {
4348 ptr = delim;
4349 }
4350
4351 SCHEDULE_SET_MODIFIERS(sched, sched_modifier);
4352
4353#if KMP_USE_HIER_SCHED
4354 if (layer != kmp_hier_layer_e::LAYER_THREAD) {
4355 __kmp_hier_scheds.append(sched, chunk, layer);
4356 } else
4357#endif
4358 {
4359 __kmp_chunk = chunk;
4361 }
4362 return ptr;
4363}
4364
4365static void __kmp_stg_parse_omp_schedule(char const *name, char const *value,
4366 void *data) {
4367 size_t length;
4368 const char *ptr = value;
4369 if (ptr) {
4370 SKIP_WS(ptr);
4372 if (length) {
4373 if (value[length - 1] == '"' || value[length - 1] == '\'')
4374 KMP_WARNING(UnbalancedQuotes, name);
4375/* get the specified scheduling style */
4376#if KMP_USE_HIER_SCHED
4377 if (!__kmp_strcasecmp_with_sentinel("EXPERIMENTAL", ptr, ' ')) {
4378 SKIP_TOKEN(ptr);
4379 SKIP_WS(ptr);
4380 while ((ptr = __kmp_parse_single_omp_schedule(name, ptr, true))) {
4381 while (*ptr == ' ' || *ptr == '\t' || *ptr == ':')
4382 ptr++;
4383 if (*ptr == '\0')
4384 break;
4385 }
4386 } else
4387#endif
4389 } else
4390 KMP_WARNING(EmptyString, name);
4391 }
4392#if KMP_USE_HIER_SCHED
4393 __kmp_hier_scheds.sort();
4394#endif
4395 K_DIAG(1, ("__kmp_static == %d\n", __kmp_static))
4396 K_DIAG(1, ("__kmp_guided == %d\n", __kmp_guided))
4397 K_DIAG(1, ("__kmp_sched == %d\n", __kmp_sched))
4398 K_DIAG(1, ("__kmp_chunk == %d\n", __kmp_chunk))
4399} // __kmp_stg_parse_omp_schedule
4400
4402 char const *name, void *data) {
4403 if (__kmp_env_format) {
4405 } else {
4406 __kmp_str_buf_print(buffer, " %s='", name);
4407 }
4410 __kmp_str_buf_print(buffer, "monotonic:");
4412 __kmp_str_buf_print(buffer, "nonmonotonic:");
4413 }
4414 if (__kmp_chunk) {
4415 switch (sched) {
4417 __kmp_str_buf_print(buffer, "%s,%d'\n", "dynamic", __kmp_chunk);
4418 break;
4421 __kmp_str_buf_print(buffer, "%s,%d'\n", "guided", __kmp_chunk);
4422 break;
4424 __kmp_str_buf_print(buffer, "%s,%d'\n", "trapezoidal", __kmp_chunk);
4425 break;
4426 case kmp_sch_static:
4430 __kmp_str_buf_print(buffer, "%s,%d'\n", "static", __kmp_chunk);
4431 break;
4433 __kmp_str_buf_print(buffer, "%s,%d'\n", "static_steal", __kmp_chunk);
4434 break;
4435 case kmp_sch_auto:
4436 __kmp_str_buf_print(buffer, "%s,%d'\n", "auto", __kmp_chunk);
4437 break;
4438 default:
4439 KMP_ASSERT2(false, "Unhandled sched_type enumeration");
4441 break;
4442 }
4443 } else {
4444 switch (sched) {
4446 __kmp_str_buf_print(buffer, "%s'\n", "dynamic");
4447 break;
4450 __kmp_str_buf_print(buffer, "%s'\n", "guided");
4451 break;
4453 __kmp_str_buf_print(buffer, "%s'\n", "trapezoidal");
4454 break;
4455 case kmp_sch_static:
4459 __kmp_str_buf_print(buffer, "%s'\n", "static");
4460 break;
4462 __kmp_str_buf_print(buffer, "%s'\n", "static_steal");
4463 break;
4464 case kmp_sch_auto:
4465 __kmp_str_buf_print(buffer, "%s'\n", "auto");
4466 break;
4467 default:
4468 KMP_ASSERT2(false, "Unhandled sched_type enumeration");
4470 break;
4471 }
4472 }
4473} // __kmp_stg_print_omp_schedule
4474
4475#if KMP_USE_HIER_SCHED
4476// -----------------------------------------------------------------------------
4477// KMP_DISP_HAND_THREAD
4478static void __kmp_stg_parse_kmp_hand_thread(char const *name, char const *value,
4479 void *data) {
4481} // __kmp_stg_parse_kmp_hand_thread
4482
4483static void __kmp_stg_print_kmp_hand_thread(kmp_str_buf_t *buffer,
4484 char const *name, void *data) {
4486} // __kmp_stg_print_kmp_hand_thread
4487#endif
4488
4489// -----------------------------------------------------------------------------
4490// KMP_FORCE_MONOTONIC_DYNAMIC_SCHEDULE
4492 char const *value, void *data) {
4494} // __kmp_stg_parse_kmp_force_monotonic
4495
4497 char const *name, void *data) {
4499} // __kmp_stg_print_kmp_force_monotonic
4500
4501// -----------------------------------------------------------------------------
4502// KMP_ATOMIC_MODE
4503
4504static void __kmp_stg_parse_atomic_mode(char const *name, char const *value,
4505 void *data) {
4506 // Modes: 0 -- do not change default; 1 -- Intel perf mode, 2 -- GOMP
4507 // compatibility mode.
4508 int mode = 0;
4509 int max = 1;
4510#ifdef KMP_GOMP_COMPAT
4511 max = 2;
4512#endif /* KMP_GOMP_COMPAT */
4513 __kmp_stg_parse_int(name, value, 0, max, &mode);
4514 // TODO; parse_int is not very suitable for this case. In case of overflow it
4515 // is better to use
4516 // 0 rather that max value.
4517 if (mode > 0) {
4519 }
4520} // __kmp_stg_parse_atomic_mode
4521
4522static void __kmp_stg_print_atomic_mode(kmp_str_buf_t *buffer, char const *name,
4523 void *data) {
4525} // __kmp_stg_print_atomic_mode
4526
4527// -----------------------------------------------------------------------------
4528// KMP_CONSISTENCY_CHECK
4529
4531 char const *value, void *data) {
4532 if (TCR_4(__kmp_init_serial)) {
4533 KMP_WARNING(EnvSerialWarn, name);
4534 return;
4535 } // read value before serial initialization only
4536 if (!__kmp_strcasecmp_with_sentinel("all", value, 0)) {
4537 // Note, this will not work from kmp_set_defaults because th_cons stack was
4538 // not allocated
4539 // for existed thread(s) thus the first __kmp_push_<construct> will break
4540 // with assertion.
4541 // TODO: allocate th_cons if called from kmp_set_defaults.
4543 } else if (!__kmp_strcasecmp_with_sentinel("none", value, 0)) {
4545 } else {
4546 KMP_WARNING(StgInvalidValue, name, value);
4547 }
4548} // __kmp_stg_parse_consistency_check
4549
4551 char const *name, void *data) {
4552#if KMP_DEBUG
4553 const char *value = NULL;
4554
4556 value = "all";
4557 } else {
4558 value = "none";
4559 }
4560
4561 if (value != NULL) {
4562 __kmp_stg_print_str(buffer, name, value);
4563 }
4564#endif /* KMP_DEBUG */
4565} // __kmp_stg_print_consistency_check
4566
4567#if USE_ITT_BUILD
4568// -----------------------------------------------------------------------------
4569// KMP_ITT_PREPARE_DELAY
4570
4571#if USE_ITT_NOTIFY
4572
4573static void __kmp_stg_parse_itt_prepare_delay(char const *name,
4574 char const *value, void *data) {
4575 // Experimental code: KMP_ITT_PREPARE_DELAY specifies numbert of loop
4576 // iterations.
4577 int delay = 0;
4578 __kmp_stg_parse_int(name, value, 0, INT_MAX, &delay);
4579 __kmp_itt_prepare_delay = delay;
4580} // __kmp_str_parse_itt_prepare_delay
4581
4582static void __kmp_stg_print_itt_prepare_delay(kmp_str_buf_t *buffer,
4583 char const *name, void *data) {
4584 __kmp_stg_print_uint64(buffer, name, __kmp_itt_prepare_delay);
4585
4586} // __kmp_str_print_itt_prepare_delay
4587
4588#endif // USE_ITT_NOTIFY
4589#endif /* USE_ITT_BUILD */
4590
4591// -----------------------------------------------------------------------------
4592// KMP_MALLOC_POOL_INCR
4593
4595 char const *value, void *data) {
4598 1);
4599} // __kmp_stg_parse_malloc_pool_incr
4600
4602 char const *name, void *data) {
4604
4605} // _kmp_stg_print_malloc_pool_incr
4606
4607#ifdef KMP_DEBUG
4608
4609// -----------------------------------------------------------------------------
4610// KMP_PAR_RANGE
4611
4612static void __kmp_stg_parse_par_range_env(char const *name, char const *value,
4613 void *data) {
4614 __kmp_stg_parse_par_range(name, value, &__kmp_par_range,
4615 __kmp_par_range_routine, __kmp_par_range_filename,
4616 &__kmp_par_range_lb, &__kmp_par_range_ub);
4617} // __kmp_stg_parse_par_range_env
4618
4619static void __kmp_stg_print_par_range_env(kmp_str_buf_t *buffer,
4620 char const *name, void *data) {
4621 if (__kmp_par_range != 0) {
4622 __kmp_stg_print_str(buffer, name, par_range_to_print);
4623 }
4624} // __kmp_stg_print_par_range_env
4625
4626#endif
4627
4628// -----------------------------------------------------------------------------
4629// KMP_GTID_MODE
4630
4631static void __kmp_stg_parse_gtid_mode(char const *name, char const *value,
4632 void *data) {
4633 // Modes:
4634 // 0 -- do not change default
4635 // 1 -- sp search
4636 // 2 -- use "keyed" TLS var, i.e.
4637 // pthread_getspecific(Linux* OS/OS X*) or TlsGetValue(Windows* OS)
4638 // 3 -- __declspec(thread) TLS var in tdata section
4639 int mode = 0;
4640 int max = 2;
4641#ifdef KMP_TDATA_GTID
4642 max = 3;
4643#endif /* KMP_TDATA_GTID */
4644 __kmp_stg_parse_int(name, value, 0, max, &mode);
4645 // TODO; parse_int is not very suitable for this case. In case of overflow it
4646 // is better to use 0 rather that max value.
4647 if (mode == 0) {
4649 } else {
4652 }
4653} // __kmp_str_parse_gtid_mode
4654
4655static void __kmp_stg_print_gtid_mode(kmp_str_buf_t *buffer, char const *name,
4656 void *data) {
4658 __kmp_stg_print_int(buffer, name, 0);
4659 } else {
4661 }
4662} // __kmp_stg_print_gtid_mode
4663
4664// -----------------------------------------------------------------------------
4665// KMP_NUM_LOCKS_IN_BLOCK
4666
4667static void __kmp_stg_parse_lock_block(char const *name, char const *value,
4668 void *data) {
4670} // __kmp_str_parse_lock_block
4671
4672static void __kmp_stg_print_lock_block(kmp_str_buf_t *buffer, char const *name,
4673 void *data) {
4675} // __kmp_stg_print_lock_block
4676
4677// -----------------------------------------------------------------------------
4678// KMP_LOCK_KIND
4679
4680#if KMP_USE_DYNAMIC_LOCK
4681#define KMP_STORE_LOCK_SEQ(a) (__kmp_user_lock_seq = lockseq_##a)
4682#else
4683#define KMP_STORE_LOCK_SEQ(a)
4684#endif
4685
4686static void __kmp_stg_parse_lock_kind(char const *name, char const *value,
4687 void *data) {
4689 KMP_WARNING(EnvLockWarn, name);
4690 return;
4691 }
4692
4693 if (__kmp_str_match("tas", 2, value) ||
4694 __kmp_str_match("test and set", 2, value) ||
4695 __kmp_str_match("test_and_set", 2, value) ||
4696 __kmp_str_match("test-and-set", 2, value) ||
4697 __kmp_str_match("test andset", 2, value) ||
4698 __kmp_str_match("test_andset", 2, value) ||
4699 __kmp_str_match("test-andset", 2, value) ||
4700 __kmp_str_match("testand set", 2, value) ||
4701 __kmp_str_match("testand_set", 2, value) ||
4702 __kmp_str_match("testand-set", 2, value) ||
4703 __kmp_str_match("testandset", 2, value)) {
4705 KMP_STORE_LOCK_SEQ(tas);
4706 }
4707#if KMP_USE_FUTEX
4708 else if (__kmp_str_match("futex", 1, value)) {
4709 if (__kmp_futex_determine_capable()) {
4710 __kmp_user_lock_kind = lk_futex;
4711 KMP_STORE_LOCK_SEQ(futex);
4712 } else {
4713 KMP_WARNING(FutexNotSupported, name, value);
4714 }
4715 }
4716#endif
4717 else if (__kmp_str_match("ticket", 2, value)) {
4719 KMP_STORE_LOCK_SEQ(ticket);
4720 } else if (__kmp_str_match("queuing", 1, value) ||
4721 __kmp_str_match("queue", 1, value)) {
4723 KMP_STORE_LOCK_SEQ(queuing);
4724 } else if (__kmp_str_match("drdpa ticket", 1, value) ||
4725 __kmp_str_match("drdpa_ticket", 1, value) ||
4726 __kmp_str_match("drdpa-ticket", 1, value) ||
4727 __kmp_str_match("drdpaticket", 1, value) ||
4728 __kmp_str_match("drdpa", 1, value)) {
4730 KMP_STORE_LOCK_SEQ(drdpa);
4731 }
4732#if KMP_USE_ADAPTIVE_LOCKS
4733 else if (__kmp_str_match("adaptive", 1, value)) {
4734 if (__kmp_cpuinfo.flags.rtm) { // ??? Is cpuinfo available here?
4735 __kmp_user_lock_kind = lk_adaptive;
4736 KMP_STORE_LOCK_SEQ(adaptive);
4737 } else {
4738 KMP_WARNING(AdaptiveNotSupported, name, value);
4740 KMP_STORE_LOCK_SEQ(queuing);
4741 }
4742 }
4743#endif // KMP_USE_ADAPTIVE_LOCKS
4744#if KMP_USE_DYNAMIC_LOCK && KMP_USE_TSX
4745 else if (__kmp_str_match("rtm_queuing", 1, value)) {
4746 if (__kmp_cpuinfo.flags.rtm) {
4747 __kmp_user_lock_kind = lk_rtm_queuing;
4748 KMP_STORE_LOCK_SEQ(rtm_queuing);
4749 } else {
4750 KMP_WARNING(AdaptiveNotSupported, name, value);
4752 KMP_STORE_LOCK_SEQ(queuing);
4753 }
4754 } else if (__kmp_str_match("rtm_spin", 1, value)) {
4755 if (__kmp_cpuinfo.flags.rtm) {
4756 __kmp_user_lock_kind = lk_rtm_spin;
4757 KMP_STORE_LOCK_SEQ(rtm_spin);
4758 } else {
4759 KMP_WARNING(AdaptiveNotSupported, name, value);
4761 KMP_STORE_LOCK_SEQ(queuing);
4762 }
4763 } else if (__kmp_str_match("hle", 1, value)) {
4764 __kmp_user_lock_kind = lk_hle;
4765 KMP_STORE_LOCK_SEQ(hle);
4766 }
4767#endif
4768 else {
4769 KMP_WARNING(StgInvalidValue, name, value);
4770 }
4771}
4772
4773static void __kmp_stg_print_lock_kind(kmp_str_buf_t *buffer, char const *name,
4774 void *data) {
4775 const char *value = NULL;
4776
4777 switch (__kmp_user_lock_kind) {
4778 case lk_default:
4779 value = "default";
4780 break;
4781
4782 case lk_tas:
4783 value = "tas";
4784 break;
4785
4786#if KMP_USE_FUTEX
4787 case lk_futex:
4788 value = "futex";
4789 break;
4790#endif
4791
4792#if KMP_USE_DYNAMIC_LOCK && KMP_USE_TSX
4793 case lk_rtm_queuing:
4794 value = "rtm_queuing";
4795 break;
4796
4797 case lk_rtm_spin:
4798 value = "rtm_spin";
4799 break;
4800
4801 case lk_hle:
4802 value = "hle";
4803 break;
4804#endif
4805
4806 case lk_ticket:
4807 value = "ticket";
4808 break;
4809
4810 case lk_queuing:
4811 value = "queuing";
4812 break;
4813
4814 case lk_drdpa:
4815 value = "drdpa";
4816 break;
4817#if KMP_USE_ADAPTIVE_LOCKS
4818 case lk_adaptive:
4819 value = "adaptive";
4820 break;
4821#endif
4822 }
4823
4824 if (value != NULL) {
4825 __kmp_stg_print_str(buffer, name, value);
4826 }
4827}
4828
4829// -----------------------------------------------------------------------------
4830// KMP_SPIN_BACKOFF_PARAMS
4831
4832// KMP_SPIN_BACKOFF_PARAMS=max_backoff[,min_tick] (max backoff size, min tick
4833// for machine pause)
4835 const char *value, void *data) {
4836 const char *next = value;
4837
4838 int total = 0; // Count elements that were set. It'll be used as an array size
4839 int prev_comma = FALSE; // For correct processing sequential commas
4840 int i;
4841
4842 kmp_uint32 max_backoff = __kmp_spin_backoff_params.max_backoff;
4843 kmp_uint32 min_tick = __kmp_spin_backoff_params.min_tick;
4844
4845 // Run only 3 iterations because it is enough to read two values or find a
4846 // syntax error
4847 for (i = 0; i < 3; i++) {
4848 SKIP_WS(next);
4849
4850 if (*next == '\0') {
4851 break;
4852 }
4853 // Next character is not an integer or not a comma OR number of values > 2
4854 // => end of list
4855 if (((*next < '0' || *next > '9') && *next != ',') || total > 2) {
4856 KMP_WARNING(EnvSyntaxError, name, value);
4857 return;
4858 }
4859 // The next character is ','
4860 if (*next == ',') {
4861 // ',' is the first character
4862 if (total == 0 || prev_comma) {
4863 total++;
4864 }
4865 prev_comma = TRUE;
4866 next++; // skip ','
4867 SKIP_WS(next);
4868 }
4869 // Next character is a digit
4870 if (*next >= '0' && *next <= '9') {
4871 int num;
4872 const char *buf = next;
4873 char const *msg = NULL;
4874 prev_comma = FALSE;
4875 SKIP_DIGITS(next);
4876 total++;
4877
4878 const char *tmp = next;
4879 SKIP_WS(tmp);
4880 if ((*next == ' ' || *next == '\t') && (*tmp >= '0' && *tmp <= '9')) {
4881 KMP_WARNING(EnvSpacesNotAllowed, name, value);
4882 return;
4883 }
4884
4885 num = __kmp_str_to_int(buf, *next);
4886 if (num <= 0) { // The number of retries should be > 0
4887 msg = KMP_I18N_STR(ValueTooSmall);
4888 num = 1;
4889 }
4890 if (msg != NULL) {
4891 // Message is not empty. Print warning.
4892 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
4893 KMP_INFORM(Using_int_Value, name, num);
4894 }
4895 if (total == 1) {
4896 max_backoff = num;
4897 } else if (total == 2) {
4898 min_tick = num;
4899 }
4900 }
4901 }
4902 if (total <= 0) {
4903 KMP_WARNING(EnvSyntaxError, name, value);
4904 return;
4905 }
4906 __kmp_spin_backoff_params.max_backoff = max_backoff;
4907 __kmp_spin_backoff_params.min_tick = min_tick;
4908}
4909
4911 char const *name, void *data) {
4912 if (__kmp_env_format) {
4914 } else {
4915 __kmp_str_buf_print(buffer, " %s='", name);
4916 }
4917 __kmp_str_buf_print(buffer, "%d,%d'\n", __kmp_spin_backoff_params.max_backoff,
4918 __kmp_spin_backoff_params.min_tick);
4919}
4920
4921#if KMP_USE_ADAPTIVE_LOCKS
4922
4923// -----------------------------------------------------------------------------
4924// KMP_ADAPTIVE_LOCK_PROPS, KMP_SPECULATIVE_STATSFILE
4925
4926// Parse out values for the tunable parameters from a string of the form
4927// KMP_ADAPTIVE_LOCK_PROPS=max_soft_retries[,max_badness]
4928static void __kmp_stg_parse_adaptive_lock_props(const char *name,
4929 const char *value, void *data) {
4930 int max_retries = 0;
4931 int max_badness = 0;
4932
4933 const char *next = value;
4934
4935 int total = 0; // Count elements that were set. It'll be used as an array size
4936 int prev_comma = FALSE; // For correct processing sequential commas
4937 int i;
4938
4939 // Save values in the structure __kmp_speculative_backoff_params
4940 // Run only 3 iterations because it is enough to read two values or find a
4941 // syntax error
4942 for (i = 0; i < 3; i++) {
4943 SKIP_WS(next);
4944
4945 if (*next == '\0') {
4946 break;
4947 }
4948 // Next character is not an integer or not a comma OR number of values > 2
4949 // => end of list
4950 if (((*next < '0' || *next > '9') && *next != ',') || total > 2) {
4951 KMP_WARNING(EnvSyntaxError, name, value);
4952 return;
4953 }
4954 // The next character is ','
4955 if (*next == ',') {
4956 // ',' is the first character
4957 if (total == 0 || prev_comma) {
4958 total++;
4959 }
4960 prev_comma = TRUE;
4961 next++; // skip ','
4962 SKIP_WS(next);
4963 }
4964 // Next character is a digit
4965 if (*next >= '0' && *next <= '9') {
4966 int num;
4967 const char *buf = next;
4968 char const *msg = NULL;
4969 prev_comma = FALSE;
4970 SKIP_DIGITS(next);
4971 total++;
4972
4973 const char *tmp = next;
4974 SKIP_WS(tmp);
4975 if ((*next == ' ' || *next == '\t') && (*tmp >= '0' && *tmp <= '9')) {
4976 KMP_WARNING(EnvSpacesNotAllowed, name, value);
4977 return;
4978 }
4979
4980 num = __kmp_str_to_int(buf, *next);
4981 if (num < 0) { // The number of retries should be >= 0
4982 msg = KMP_I18N_STR(ValueTooSmall);
4983 num = 1;
4984 }
4985 if (msg != NULL) {
4986 // Message is not empty. Print warning.
4987 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
4988 KMP_INFORM(Using_int_Value, name, num);
4989 }
4990 if (total == 1) {
4991 max_retries = num;
4992 } else if (total == 2) {
4993 max_badness = num;
4994 }
4995 }
4996 }
4997 if (total <= 0) {
4998 KMP_WARNING(EnvSyntaxError, name, value);
4999 return;
5000 }
5001 __kmp_adaptive_backoff_params.max_soft_retries = max_retries;
5002 __kmp_adaptive_backoff_params.max_badness = max_badness;
5003}
5004
5005static void __kmp_stg_print_adaptive_lock_props(kmp_str_buf_t *buffer,
5006 char const *name, void *data) {
5007 if (__kmp_env_format) {
5009 } else {
5010 __kmp_str_buf_print(buffer, " %s='", name);
5011 }
5012 __kmp_str_buf_print(buffer, "%d,%d'\n",
5013 __kmp_adaptive_backoff_params.max_soft_retries,
5014 __kmp_adaptive_backoff_params.max_badness);
5015} // __kmp_stg_print_adaptive_lock_props
5016
5017#if KMP_DEBUG_ADAPTIVE_LOCKS
5018
5019static void __kmp_stg_parse_speculative_statsfile(char const *name,
5020 char const *value,
5021 void *data) {
5022 __kmp_stg_parse_file(name, value, "",
5023 CCAST(char **, &__kmp_speculative_statsfile));
5024} // __kmp_stg_parse_speculative_statsfile
5025
5026static void __kmp_stg_print_speculative_statsfile(kmp_str_buf_t *buffer,
5027 char const *name,
5028 void *data) {
5029 if (__kmp_str_match("-", 0, __kmp_speculative_statsfile)) {
5030 __kmp_stg_print_str(buffer, name, "stdout");
5031 } else {
5032 __kmp_stg_print_str(buffer, name, __kmp_speculative_statsfile);
5033 }
5034
5035} // __kmp_stg_print_speculative_statsfile
5036
5037#endif // KMP_DEBUG_ADAPTIVE_LOCKS
5038
5039#endif // KMP_USE_ADAPTIVE_LOCKS
5040
5041// -----------------------------------------------------------------------------
5042// KMP_HW_SUBSET (was KMP_PLACE_THREADS)
5043// 2s16c,2t => 2S16C,2T => 2S16C \0 2T
5044
5045// Return KMP_HW_SUBSET preferred hardware type in case a token is ambiguously
5046// short. The original KMP_HW_SUBSET environment variable had single letters:
5047// s, c, t for sockets, cores, threads repsectively.
5049 size_t num_possible) {
5050 for (size_t i = 0; i < num_possible; ++i) {
5051 if (possible[i] == KMP_HW_THREAD)
5052 return KMP_HW_THREAD;
5053 else if (possible[i] == KMP_HW_CORE)
5054 return KMP_HW_CORE;
5055 else if (possible[i] == KMP_HW_SOCKET)
5056 return KMP_HW_SOCKET;
5057 }
5058 return KMP_HW_UNKNOWN;
5059}
5060
5061// Return hardware type from string or HW_UNKNOWN if string cannot be parsed
5062// This algorithm is very forgiving to the user in that, the instant it can
5063// reduce the search space to one, it assumes that is the topology level the
5064// user wanted, even if it is misspelled later in the token.
5065static kmp_hw_t __kmp_stg_parse_hw_subset_name(char const *token) {
5066 size_t index, num_possible, token_length;
5067 kmp_hw_t possible[KMP_HW_LAST];
5068 const char *end;
5069
5070 // Find the end of the hardware token string
5071 end = token;
5072 token_length = 0;
5073 while (isalnum(*end) || *end == '_') {
5074 token_length++;
5075 end++;
5076 }
5077
5078 // Set the possibilities to all hardware types
5079 num_possible = 0;
5080 KMP_FOREACH_HW_TYPE(type) { possible[num_possible++] = type; }
5081
5082 // Eliminate hardware types by comparing the front of the token
5083 // with hardware names
5084 // In most cases, the first letter in the token will indicate exactly
5085 // which hardware type is parsed, e.g., 'C' = Core
5086 index = 0;
5087 while (num_possible > 1 && index < token_length) {
5088 size_t n = num_possible;
5089 char token_char = (char)toupper(token[index]);
5090 for (size_t i = 0; i < n; ++i) {
5091 const char *s;
5092 kmp_hw_t type = possible[i];
5093 s = __kmp_hw_get_keyword(type, false);
5094 if (index < KMP_STRLEN(s)) {
5095 char c = (char)toupper(s[index]);
5096 // Mark hardware types for removal when the characters do not match
5097 if (c != token_char) {
5098 possible[i] = KMP_HW_UNKNOWN;
5099 num_possible--;
5100 }
5101 }
5102 }
5103 // Remove hardware types that this token cannot be
5104 size_t start = 0;
5105 for (size_t i = 0; i < n; ++i) {
5106 if (possible[i] != KMP_HW_UNKNOWN) {
5107 kmp_hw_t temp = possible[i];
5108 possible[i] = possible[start];
5109 possible[start] = temp;
5110 start++;
5111 }
5112 }
5113 KMP_ASSERT(start == num_possible);
5114 index++;
5115 }
5116
5117 // Attempt to break a tie if user has very short token
5118 // (e.g., is 'T' tile or thread?)
5119 if (num_possible > 1)
5120 return __kmp_hw_subset_break_tie(possible, num_possible);
5121 if (num_possible == 1)
5122 return possible[0];
5123 return KMP_HW_UNKNOWN;
5124}
5125
5126// The longest observable sequence of items can only be HW_LAST length
5127// The input string is usually short enough, let's use 512 limit for now
5128#define MAX_T_LEVEL KMP_HW_LAST
5129#define MAX_STR_LEN 512
5130static void __kmp_stg_parse_hw_subset(char const *name, char const *value,
5131 void *data) {
5132 // Value example: 1s,5c@3,2T
5133 // Which means "use 1 socket, 5 cores with offset 3, 2 threads per core"
5134 kmp_setting_t **rivals = (kmp_setting_t **)data;
5135 if (strcmp(name, "KMP_PLACE_THREADS") == 0) {
5136 KMP_INFORM(EnvVarDeprecated, name, "KMP_HW_SUBSET");
5137 }
5138 if (__kmp_stg_check_rivals(name, value, rivals)) {
5139 return;
5140 }
5141
5142 char *components[MAX_T_LEVEL];
5143 char const *digits = "0123456789";
5144 char input[MAX_STR_LEN];
5145 size_t len = 0, mlen = MAX_STR_LEN;
5146 int level = 0;
5147 bool absolute = false;
5148 // Canonicalize the string (remove spaces, unify delimiters, etc.)
5149 char *pos = CCAST(char *, value);
5150 while (*pos && mlen) {
5151 if (*pos != ' ') { // skip spaces
5152 if (len == 0 && *pos == ':') {
5153 absolute = true;
5154 } else {
5155 input[len] = (char)(toupper(*pos));
5156 if (input[len] == 'X')
5157 input[len] = ','; // unify delimiters of levels
5158 if (input[len] == 'O' && strchr(digits, *(pos + 1)))
5159 input[len] = '@'; // unify delimiters of offset
5160 len++;
5161 }
5162 }
5163 mlen--;
5164 pos++;
5165 }
5166 if (len == 0 || mlen == 0) {
5167 goto err; // contents is either empty or too long
5168 }
5169 input[len] = '\0';
5170 // Split by delimiter
5171 pos = input;
5172 components[level++] = pos;
5173 while ((pos = strchr(pos, ','))) {
5174 if (level >= MAX_T_LEVEL)
5175 goto err; // too many components provided
5176 *pos = '\0'; // modify input and avoid more copying
5177 components[level++] = ++pos; // expect something after ","
5178 }
5179
5181 if (absolute)
5182 __kmp_hw_subset->set_absolute();
5183
5184 // Check each component
5185 for (int i = 0; i < level; ++i) {
5186 int core_level = 0;
5187 char *core_components[MAX_T_LEVEL];
5188 // Split possible core components by '&' delimiter
5189 pos = components[i];
5190 core_components[core_level++] = pos;
5191 while ((pos = strchr(pos, '&'))) {
5192 if (core_level >= MAX_T_LEVEL)
5193 goto err; // too many different core types
5194 *pos = '\0'; // modify input and avoid more copying
5195 core_components[core_level++] = ++pos; // expect something after '&'
5196 }
5197
5198 for (int j = 0; j < core_level; ++j) {
5199 char *offset_ptr;
5200 char *attr_ptr;
5201 int offset = 0;
5202 kmp_hw_attr_t attr;
5203 int num;
5204 // components may begin with an optional count of the number of resources
5205 if (isdigit(*core_components[j])) {
5206 num = atoi(core_components[j]);
5207 if (num <= 0) {
5208 goto err; // only positive integers are valid for count
5209 }
5210 pos = core_components[j] + strspn(core_components[j], digits);
5211 } else if (*core_components[j] == '*') {
5213 pos = core_components[j] + 1;
5214 } else {
5216 pos = core_components[j];
5217 }
5218
5219 offset_ptr = strchr(core_components[j], '@');
5220 attr_ptr = strchr(core_components[j], ':');
5221
5222 if (offset_ptr) {
5223 offset = atoi(offset_ptr + 1); // save offset
5224 *offset_ptr = '\0'; // cut the offset from the component
5225 }
5226 if (attr_ptr) {
5227 attr.clear();
5228 // save the attribute
5229#if KMP_ARCH_X86 || KMP_ARCH_X86_64
5230 if (__kmp_str_match("intel_core", -1, attr_ptr + 1)) {
5231 attr.set_core_type(KMP_HW_CORE_TYPE_CORE);
5232 } else if (__kmp_str_match("intel_atom", -1, attr_ptr + 1)) {
5233 attr.set_core_type(KMP_HW_CORE_TYPE_ATOM);
5234 } else
5235#endif
5236 if (__kmp_str_match("eff", 3, attr_ptr + 1)) {
5237 const char *number = attr_ptr + 1;
5238 // skip the eff[iciency] token
5239 while (isalpha(*number))
5240 number++;
5241 if (!isdigit(*number)) {
5242 goto err;
5243 }
5244 int efficiency = atoi(number);
5245 attr.set_core_eff(efficiency);
5246 } else {
5247 goto err;
5248 }
5249 *attr_ptr = '\0'; // cut the attribute from the component
5250 }
5251 // detect the component type
5253 if (type == KMP_HW_UNKNOWN) {
5254 goto err;
5255 }
5256 // Only the core type can have attributes
5257 if (attr && type != KMP_HW_CORE)
5258 goto err;
5259 // Must allow core be specified more than once
5260 if (type != KMP_HW_CORE && __kmp_hw_subset->specified(type)) {
5261 goto err;
5262 }
5263 __kmp_hw_subset->push_back(num, type, offset, attr);
5264 }
5265 }
5266 return;
5267err:
5268 KMP_WARNING(AffHWSubsetInvalid, name, value);
5269 if (__kmp_hw_subset) {
5271 __kmp_hw_subset = nullptr;
5272 }
5273 return;
5274}
5275
5276static void __kmp_stg_print_hw_subset(kmp_str_buf_t *buffer, char const *name,
5277 void *data) {
5279 int depth;
5280 if (!__kmp_hw_subset)
5281 return;
5283 if (__kmp_env_format)
5285 else
5286 __kmp_str_buf_print(buffer, " %s='", name);
5287
5288 depth = __kmp_hw_subset->get_depth();
5289 for (int i = 0; i < depth; ++i) {
5290 const auto &item = __kmp_hw_subset->at(i);
5291 if (i > 0)
5292 __kmp_str_buf_print(&buf, "%c", ',');
5293 for (int j = 0; j < item.num_attrs; ++j) {
5294 __kmp_str_buf_print(&buf, "%s%d%s", (j > 0 ? "&" : ""), item.num[j],
5295 __kmp_hw_get_keyword(item.type));
5296 if (item.attr[j].is_core_type_valid())
5298 &buf, ":%s",
5299 __kmp_hw_get_core_type_keyword(item.attr[j].get_core_type()));
5300 if (item.attr[j].is_core_eff_valid())
5301 __kmp_str_buf_print(&buf, ":eff%d", item.attr[j].get_core_eff());
5302 if (item.offset[j])
5303 __kmp_str_buf_print(&buf, "@%d", item.offset[j]);
5304 }
5305 }
5306 __kmp_str_buf_print(buffer, "%s'\n", buf.str);
5308}
5309
5310#if USE_ITT_BUILD
5311// -----------------------------------------------------------------------------
5312// KMP_FORKJOIN_FRAMES
5313
5314static void __kmp_stg_parse_forkjoin_frames(char const *name, char const *value,
5315 void *data) {
5316 __kmp_stg_parse_bool(name, value, &__kmp_forkjoin_frames);
5317} // __kmp_stg_parse_forkjoin_frames
5318
5319static void __kmp_stg_print_forkjoin_frames(kmp_str_buf_t *buffer,
5320 char const *name, void *data) {
5321 __kmp_stg_print_bool(buffer, name, __kmp_forkjoin_frames);
5322} // __kmp_stg_print_forkjoin_frames
5323
5324// -----------------------------------------------------------------------------
5325// KMP_FORKJOIN_FRAMES_MODE
5326
5327static void __kmp_stg_parse_forkjoin_frames_mode(char const *name,
5328 char const *value,
5329 void *data) {
5330 __kmp_stg_parse_int(name, value, 0, 3, &__kmp_forkjoin_frames_mode);
5331} // __kmp_stg_parse_forkjoin_frames
5332
5333static void __kmp_stg_print_forkjoin_frames_mode(kmp_str_buf_t *buffer,
5334 char const *name, void *data) {
5335 __kmp_stg_print_int(buffer, name, __kmp_forkjoin_frames_mode);
5336} // __kmp_stg_print_forkjoin_frames
5337#endif /* USE_ITT_BUILD */
5338
5339// -----------------------------------------------------------------------------
5340// KMP_ENABLE_TASK_THROTTLING
5341
5342static void __kmp_stg_parse_task_throttling(char const *name, char const *value,
5343 void *data) {
5345} // __kmp_stg_parse_task_throttling
5346
5348 char const *name, void *data) {
5350} // __kmp_stg_print_task_throttling
5351
5352#if KMP_HAVE_MWAIT || KMP_HAVE_UMWAIT
5353// -----------------------------------------------------------------------------
5354// KMP_USER_LEVEL_MWAIT
5355
5356static void __kmp_stg_parse_user_level_mwait(char const *name,
5357 char const *value, void *data) {
5358 __kmp_stg_parse_bool(name, value, &__kmp_user_level_mwait);
5359} // __kmp_stg_parse_user_level_mwait
5360
5361static void __kmp_stg_print_user_level_mwait(kmp_str_buf_t *buffer,
5362 char const *name, void *data) {
5363 __kmp_stg_print_bool(buffer, name, __kmp_user_level_mwait);
5364} // __kmp_stg_print_user_level_mwait
5365
5366// -----------------------------------------------------------------------------
5367// KMP_MWAIT_HINTS
5368
5369static void __kmp_stg_parse_mwait_hints(char const *name, char const *value,
5370 void *data) {
5371 __kmp_stg_parse_int(name, value, 0, INT_MAX, &__kmp_mwait_hints);
5372} // __kmp_stg_parse_mwait_hints
5373
5374static void __kmp_stg_print_mwait_hints(kmp_str_buf_t *buffer, char const *name,
5375 void *data) {
5376 __kmp_stg_print_int(buffer, name, __kmp_mwait_hints);
5377} // __kmp_stg_print_mwait_hints
5378
5379#endif // KMP_HAVE_MWAIT || KMP_HAVE_UMWAIT
5380
5381#if KMP_HAVE_UMWAIT
5382// -----------------------------------------------------------------------------
5383// KMP_TPAUSE
5384// 0 = don't use TPAUSE, 1 = use C0.1 state, 2 = use C0.2 state
5385
5386static void __kmp_stg_parse_tpause(char const *name, char const *value,
5387 void *data) {
5388 __kmp_stg_parse_int(name, value, 0, INT_MAX, &__kmp_tpause_state);
5389 if (__kmp_tpause_state != 0) {
5390 // The actual hint passed to tpause is: 0 for C0.2 and 1 for C0.1
5391 if (__kmp_tpause_state == 2) // use C0.2
5392 __kmp_tpause_hint = 0; // default was set to 1 for C0.1
5393 }
5394} // __kmp_stg_parse_tpause
5395
5396static void __kmp_stg_print_tpause(kmp_str_buf_t *buffer, char const *name,
5397 void *data) {
5398 __kmp_stg_print_int(buffer, name, __kmp_tpause_state);
5399} // __kmp_stg_print_tpause
5400#endif // KMP_HAVE_UMWAIT
5401
5402// -----------------------------------------------------------------------------
5403// OMP_DISPLAY_ENV
5404
5405static void __kmp_stg_parse_omp_display_env(char const *name, char const *value,
5406 void *data) {
5407 if (__kmp_str_match("VERBOSE", 1, value)) {
5409 } else {
5411 }
5412} // __kmp_stg_parse_omp_display_env
5413
5415 char const *name, void *data) {
5417 __kmp_stg_print_str(buffer, name, "VERBOSE");
5418 } else {
5420 }
5421} // __kmp_stg_print_omp_display_env
5422
5424 char const *value, void *data) {
5426 KMP_WARNING(EnvParallelWarn, name);
5427 return;
5428 } // read value before first parallel only
5430} // __kmp_stg_parse_omp_cancellation
5431
5433 char const *name, void *data) {
5435} // __kmp_stg_print_omp_cancellation
5436
5437#if OMPT_SUPPORT
5438int __kmp_tool = 1;
5439
5440static void __kmp_stg_parse_omp_tool(char const *name, char const *value,
5441 void *data) {
5442 __kmp_stg_parse_bool(name, value, &__kmp_tool);
5443} // __kmp_stg_parse_omp_tool
5444
5445static void __kmp_stg_print_omp_tool(kmp_str_buf_t *buffer, char const *name,
5446 void *data) {
5447 if (__kmp_env_format) {
5448 KMP_STR_BUF_PRINT_BOOL_EX(name, __kmp_tool, "enabled", "disabled");
5449 } else {
5450 __kmp_str_buf_print(buffer, " %s=%s\n", name,
5451 __kmp_tool ? "enabled" : "disabled");
5452 }
5453} // __kmp_stg_print_omp_tool
5454
5455char *__kmp_tool_libraries = NULL;
5456
5457static void __kmp_stg_parse_omp_tool_libraries(char const *name,
5458 char const *value, void *data) {
5459 __kmp_stg_parse_str(name, value, &__kmp_tool_libraries);
5460} // __kmp_stg_parse_omp_tool_libraries
5461
5462static void __kmp_stg_print_omp_tool_libraries(kmp_str_buf_t *buffer,
5463 char const *name, void *data) {
5464 if (__kmp_tool_libraries)
5465 __kmp_stg_print_str(buffer, name, __kmp_tool_libraries);
5466 else {
5467 if (__kmp_env_format) {
5469 } else {
5470 __kmp_str_buf_print(buffer, " %s", name);
5471 }
5472 __kmp_str_buf_print(buffer, ": %s\n", KMP_I18N_STR(NotDefined));
5473 }
5474} // __kmp_stg_print_omp_tool_libraries
5475
5476char *__kmp_tool_verbose_init = NULL;
5477
5478static void __kmp_stg_parse_omp_tool_verbose_init(char const *name,
5479 char const *value,
5480 void *data) {
5481 __kmp_stg_parse_str(name, value, &__kmp_tool_verbose_init);
5482} // __kmp_stg_parse_omp_tool_libraries
5483
5484static void __kmp_stg_print_omp_tool_verbose_init(kmp_str_buf_t *buffer,
5485 char const *name,
5486 void *data) {
5487 if (__kmp_tool_verbose_init)
5488 __kmp_stg_print_str(buffer, name, __kmp_tool_verbose_init);
5489 else {
5490 if (__kmp_env_format) {
5492 } else {
5493 __kmp_str_buf_print(buffer, " %s", name);
5494 }
5495 __kmp_str_buf_print(buffer, ": %s\n", KMP_I18N_STR(NotDefined));
5496 }
5497} // __kmp_stg_print_omp_tool_verbose_init
5498
5499#endif
5500
5501// Table.
5502
5504
5505 {"KMP_ALL_THREADS", __kmp_stg_parse_device_thread_limit, NULL, NULL, 0, 0},
5507 NULL, 0, 0},
5509 NULL, 0, 0},
5510 {"KMP_DUPLICATE_LIB_OK", __kmp_stg_parse_duplicate_lib_ok,
5513 NULL, 0, 0},
5514 {"KMP_DEVICE_THREAD_LIMIT", __kmp_stg_parse_device_thread_limit,
5516#if KMP_USE_MONITOR
5517 {"KMP_MONITOR_STACKSIZE", __kmp_stg_parse_monitor_stacksize,
5518 __kmp_stg_print_monitor_stacksize, NULL, 0, 0},
5519#endif
5520 {"KMP_SETTINGS", __kmp_stg_parse_settings, __kmp_stg_print_settings, NULL,
5521 0, 0},
5522 {"KMP_STACKOFFSET", __kmp_stg_parse_stackoffset,
5523 __kmp_stg_print_stackoffset, NULL, 0, 0},
5525 NULL, 0, 0},
5526 {"KMP_STACKPAD", __kmp_stg_parse_stackpad, __kmp_stg_print_stackpad, NULL,
5527 0, 0},
5528 {"KMP_VERSION", __kmp_stg_parse_version, __kmp_stg_print_version, NULL, 0,
5529 0},
5530 {"KMP_WARNINGS", __kmp_stg_parse_warnings, __kmp_stg_print_warnings, NULL,
5531 0, 0},
5532
5533 {"KMP_NESTING_MODE", __kmp_stg_parse_nesting_mode,
5534 __kmp_stg_print_nesting_mode, NULL, 0, 0},
5535 {"OMP_NESTED", __kmp_stg_parse_nested, __kmp_stg_print_nested, NULL, 0, 0},
5536 {"OMP_NUM_THREADS", __kmp_stg_parse_num_threads,
5537 __kmp_stg_print_num_threads, NULL, 0, 0},
5539 NULL, 0, 0},
5540
5541 {"KMP_TASKING", __kmp_stg_parse_tasking, __kmp_stg_print_tasking, NULL, 0,
5542 0},
5543 {"KMP_TASK_STEALING_CONSTRAINT", __kmp_stg_parse_task_stealing,
5544 __kmp_stg_print_task_stealing, NULL, 0, 0},
5545 {"OMP_MAX_ACTIVE_LEVELS", __kmp_stg_parse_max_active_levels,
5547 {"OMP_DEFAULT_DEVICE", __kmp_stg_parse_default_device,
5548 __kmp_stg_print_default_device, NULL, 0, 0},
5549 {"OMP_TARGET_OFFLOAD", __kmp_stg_parse_target_offload,
5550 __kmp_stg_print_target_offload, NULL, 0, 0},
5551 {"OMP_MAX_TASK_PRIORITY", __kmp_stg_parse_max_task_priority,
5553 {"KMP_TASKLOOP_MIN_TASKS", __kmp_stg_parse_taskloop_min_tasks,
5555 {"OMP_THREAD_LIMIT", __kmp_stg_parse_thread_limit,
5556 __kmp_stg_print_thread_limit, NULL, 0, 0},
5557 {"KMP_TEAMS_THREAD_LIMIT", __kmp_stg_parse_teams_thread_limit,
5559 {"OMP_NUM_TEAMS", __kmp_stg_parse_nteams, __kmp_stg_print_nteams, NULL, 0,
5560 0},
5561 {"OMP_TEAMS_THREAD_LIMIT", __kmp_stg_parse_teams_th_limit,
5562 __kmp_stg_print_teams_th_limit, NULL, 0, 0},
5563 {"OMP_WAIT_POLICY", __kmp_stg_parse_wait_policy,
5564 __kmp_stg_print_wait_policy, NULL, 0, 0},
5565 {"KMP_DISP_NUM_BUFFERS", __kmp_stg_parse_disp_buffers,
5566 __kmp_stg_print_disp_buffers, NULL, 0, 0},
5567 {"KMP_HOT_TEAMS_MAX_LEVEL", __kmp_stg_parse_hot_teams_level,
5569 {"KMP_HOT_TEAMS_MODE", __kmp_stg_parse_hot_teams_mode,
5570 __kmp_stg_print_hot_teams_mode, NULL, 0, 0},
5571
5572#if KMP_HANDLE_SIGNALS
5573 {"KMP_HANDLE_SIGNALS", __kmp_stg_parse_handle_signals,
5574 __kmp_stg_print_handle_signals, NULL, 0, 0},
5575#endif
5576
5577#if KMP_ARCH_X86 || KMP_ARCH_X86_64
5578 {"KMP_INHERIT_FP_CONTROL", __kmp_stg_parse_inherit_fp_control,
5579 __kmp_stg_print_inherit_fp_control, NULL, 0, 0},
5580#endif /* KMP_ARCH_X86 || KMP_ARCH_X86_64 */
5581
5582#ifdef KMP_GOMP_COMPAT
5583 {"GOMP_STACKSIZE", __kmp_stg_parse_stacksize, NULL, NULL, 0, 0},
5584#endif
5585
5586#ifdef KMP_DEBUG
5587 {"KMP_A_DEBUG", __kmp_stg_parse_a_debug, __kmp_stg_print_a_debug, NULL, 0,
5588 0},
5589 {"KMP_B_DEBUG", __kmp_stg_parse_b_debug, __kmp_stg_print_b_debug, NULL, 0,
5590 0},
5591 {"KMP_C_DEBUG", __kmp_stg_parse_c_debug, __kmp_stg_print_c_debug, NULL, 0,
5592 0},
5593 {"KMP_D_DEBUG", __kmp_stg_parse_d_debug, __kmp_stg_print_d_debug, NULL, 0,
5594 0},
5595 {"KMP_E_DEBUG", __kmp_stg_parse_e_debug, __kmp_stg_print_e_debug, NULL, 0,
5596 0},
5597 {"KMP_F_DEBUG", __kmp_stg_parse_f_debug, __kmp_stg_print_f_debug, NULL, 0,
5598 0},
5599 {"KMP_DEBUG", __kmp_stg_parse_debug, NULL, /* no print */ NULL, 0, 0},
5600 {"KMP_DEBUG_BUF", __kmp_stg_parse_debug_buf, __kmp_stg_print_debug_buf,
5601 NULL, 0, 0},
5602 {"KMP_DEBUG_BUF_ATOMIC", __kmp_stg_parse_debug_buf_atomic,
5603 __kmp_stg_print_debug_buf_atomic, NULL, 0, 0},
5604 {"KMP_DEBUG_BUF_CHARS", __kmp_stg_parse_debug_buf_chars,
5605 __kmp_stg_print_debug_buf_chars, NULL, 0, 0},
5606 {"KMP_DEBUG_BUF_LINES", __kmp_stg_parse_debug_buf_lines,
5607 __kmp_stg_print_debug_buf_lines, NULL, 0, 0},
5608 {"KMP_DIAG", __kmp_stg_parse_diag, __kmp_stg_print_diag, NULL, 0, 0},
5609
5610 {"KMP_PAR_RANGE", __kmp_stg_parse_par_range_env,
5611 __kmp_stg_print_par_range_env, NULL, 0, 0},
5612#endif // KMP_DEBUG
5613
5614 {"KMP_ALIGN_ALLOC", __kmp_stg_parse_align_alloc,
5615 __kmp_stg_print_align_alloc, NULL, 0, 0},
5616
5617 {"KMP_PLAIN_BARRIER", __kmp_stg_parse_barrier_branch_bit,
5619 {"KMP_PLAIN_BARRIER_PATTERN", __kmp_stg_parse_barrier_pattern,
5621 {"KMP_FORKJOIN_BARRIER", __kmp_stg_parse_barrier_branch_bit,
5623 {"KMP_FORKJOIN_BARRIER_PATTERN", __kmp_stg_parse_barrier_pattern,
5625#if KMP_FAST_REDUCTION_BARRIER
5626 {"KMP_REDUCTION_BARRIER", __kmp_stg_parse_barrier_branch_bit,
5628 {"KMP_REDUCTION_BARRIER_PATTERN", __kmp_stg_parse_barrier_pattern,
5630#endif
5631
5632 {"KMP_ABORT_DELAY", __kmp_stg_parse_abort_delay,
5633 __kmp_stg_print_abort_delay, NULL, 0, 0},
5634 {"KMP_CPUINFO_FILE", __kmp_stg_parse_cpuinfo_file,
5635 __kmp_stg_print_cpuinfo_file, NULL, 0, 0},
5636 {"KMP_FORCE_REDUCTION", __kmp_stg_parse_force_reduction,
5638 {"KMP_DETERMINISTIC_REDUCTION", __kmp_stg_parse_force_reduction,
5640 {"KMP_STORAGE_MAP", __kmp_stg_parse_storage_map,
5641 __kmp_stg_print_storage_map, NULL, 0, 0},
5642 {"KMP_ALL_THREADPRIVATE", __kmp_stg_parse_all_threadprivate,
5644 {"KMP_FOREIGN_THREADS_THREADPRIVATE",
5647
5648#if KMP_AFFINITY_SUPPORTED
5649 {"KMP_AFFINITY", __kmp_stg_parse_affinity, __kmp_stg_print_affinity, NULL,
5650 0, 0},
5651 {"KMP_HIDDEN_HELPER_AFFINITY", __kmp_stg_parse_hh_affinity,
5652 __kmp_stg_print_hh_affinity, NULL, 0, 0},
5653#ifdef KMP_GOMP_COMPAT
5654 {"GOMP_CPU_AFFINITY", __kmp_stg_parse_gomp_cpu_affinity, NULL,
5655 /* no print */ NULL, 0, 0},
5656#endif /* KMP_GOMP_COMPAT */
5658 NULL, 0, 0},
5659 {"KMP_TEAMS_PROC_BIND", __kmp_stg_parse_teams_proc_bind,
5660 __kmp_stg_print_teams_proc_bind, NULL, 0, 0},
5661 {"OMP_PLACES", __kmp_stg_parse_places, __kmp_stg_print_places, NULL, 0, 0},
5662 {"KMP_TOPOLOGY_METHOD", __kmp_stg_parse_topology_method,
5663 __kmp_stg_print_topology_method, NULL, 0, 0},
5664
5665#else
5666
5667 // KMP_AFFINITY is not supported on OS X*, nor is OMP_PLACES.
5668 // OMP_PROC_BIND and proc-bind-var are supported, however.
5670 NULL, 0, 0},
5671
5672#endif // KMP_AFFINITY_SUPPORTED
5673 {"OMP_DISPLAY_AFFINITY", __kmp_stg_parse_display_affinity,
5675 {"OMP_AFFINITY_FORMAT", __kmp_stg_parse_affinity_format,
5677 {"KMP_INIT_AT_FORK", __kmp_stg_parse_init_at_fork,
5678 __kmp_stg_print_init_at_fork, NULL, 0, 0},
5679 {"KMP_SCHEDULE", __kmp_stg_parse_schedule, __kmp_stg_print_schedule, NULL,
5680 0, 0},
5682 NULL, 0, 0},
5683#if KMP_USE_HIER_SCHED
5684 {"KMP_DISP_HAND_THREAD", __kmp_stg_parse_kmp_hand_thread,
5685 __kmp_stg_print_kmp_hand_thread, NULL, 0, 0},
5686#endif
5687 {"KMP_FORCE_MONOTONIC_DYNAMIC_SCHEDULE",
5689 NULL, 0, 0},
5690 {"KMP_ATOMIC_MODE", __kmp_stg_parse_atomic_mode,
5691 __kmp_stg_print_atomic_mode, NULL, 0, 0},
5692 {"KMP_CONSISTENCY_CHECK", __kmp_stg_parse_consistency_check,
5694
5695#if USE_ITT_BUILD && USE_ITT_NOTIFY
5696 {"KMP_ITT_PREPARE_DELAY", __kmp_stg_parse_itt_prepare_delay,
5697 __kmp_stg_print_itt_prepare_delay, NULL, 0, 0},
5698#endif /* USE_ITT_BUILD && USE_ITT_NOTIFY */
5699 {"KMP_MALLOC_POOL_INCR", __kmp_stg_parse_malloc_pool_incr,
5702 NULL, 0, 0},
5704 NULL, 0, 0},
5705 {"KMP_DYNAMIC_MODE", __kmp_stg_parse_kmp_dynamic_mode,
5707
5708#ifdef USE_LOAD_BALANCE
5709 {"KMP_LOAD_BALANCE_INTERVAL", __kmp_stg_parse_ld_balance_interval,
5710 __kmp_stg_print_ld_balance_interval, NULL, 0, 0},
5711#endif
5712
5713 {"KMP_NUM_LOCKS_IN_BLOCK", __kmp_stg_parse_lock_block,
5714 __kmp_stg_print_lock_block, NULL, 0, 0},
5716 NULL, 0, 0},
5717 {"KMP_SPIN_BACKOFF_PARAMS", __kmp_stg_parse_spin_backoff_params,
5719#if KMP_USE_ADAPTIVE_LOCKS
5720 {"KMP_ADAPTIVE_LOCK_PROPS", __kmp_stg_parse_adaptive_lock_props,
5721 __kmp_stg_print_adaptive_lock_props, NULL, 0, 0},
5722#if KMP_DEBUG_ADAPTIVE_LOCKS
5723 {"KMP_SPECULATIVE_STATSFILE", __kmp_stg_parse_speculative_statsfile,
5724 __kmp_stg_print_speculative_statsfile, NULL, 0, 0},
5725#endif
5726#endif // KMP_USE_ADAPTIVE_LOCKS
5728 NULL, 0, 0},
5730 NULL, 0, 0},
5731#if USE_ITT_BUILD
5732 {"KMP_FORKJOIN_FRAMES", __kmp_stg_parse_forkjoin_frames,
5733 __kmp_stg_print_forkjoin_frames, NULL, 0, 0},
5734 {"KMP_FORKJOIN_FRAMES_MODE", __kmp_stg_parse_forkjoin_frames_mode,
5735 __kmp_stg_print_forkjoin_frames_mode, NULL, 0, 0},
5736#endif
5737 {"KMP_ENABLE_TASK_THROTTLING", __kmp_stg_parse_task_throttling,
5739
5740 {"OMP_DISPLAY_ENV", __kmp_stg_parse_omp_display_env,
5742 {"OMP_CANCELLATION", __kmp_stg_parse_omp_cancellation,
5745 NULL, 0, 0},
5746 {"LIBOMP_USE_HIDDEN_HELPER_TASK", __kmp_stg_parse_use_hidden_helper,
5748 {"LIBOMP_NUM_HIDDEN_HELPER_THREADS",
5751#if OMP_TASKGRAPH_EXPERIMENTAL
5752 {"KMP_MAX_TDGS", __kmp_stg_parse_max_tdgs, __kmp_std_print_max_tdgs, NULL,
5753 0, 0},
5754 {"KMP_TDG_DOT", __kmp_stg_parse_tdg_dot, __kmp_stg_print_tdg_dot, NULL, 0,
5755 0},
5756#endif
5757
5758#if OMPT_SUPPORT
5759 {"OMP_TOOL", __kmp_stg_parse_omp_tool, __kmp_stg_print_omp_tool, NULL, 0,
5760 0},
5761 {"OMP_TOOL_LIBRARIES", __kmp_stg_parse_omp_tool_libraries,
5762 __kmp_stg_print_omp_tool_libraries, NULL, 0, 0},
5763 {"OMP_TOOL_VERBOSE_INIT", __kmp_stg_parse_omp_tool_verbose_init,
5764 __kmp_stg_print_omp_tool_verbose_init, NULL, 0, 0},
5765#endif
5766
5767#if KMP_HAVE_MWAIT || KMP_HAVE_UMWAIT
5768 {"KMP_USER_LEVEL_MWAIT", __kmp_stg_parse_user_level_mwait,
5769 __kmp_stg_print_user_level_mwait, NULL, 0, 0},
5770 {"KMP_MWAIT_HINTS", __kmp_stg_parse_mwait_hints,
5771 __kmp_stg_print_mwait_hints, NULL, 0, 0},
5772#endif
5773
5774#if KMP_HAVE_UMWAIT
5775 {"KMP_TPAUSE", __kmp_stg_parse_tpause, __kmp_stg_print_tpause, NULL, 0, 0},
5776#endif
5777 {"", NULL, NULL, NULL, 0, 0}}; // settings
5778
5779static int const __kmp_stg_count =
5780 sizeof(__kmp_stg_table) / sizeof(kmp_setting_t);
5781
5782static inline kmp_setting_t *__kmp_stg_find(char const *name) {
5783
5784 int i;
5785 if (name != NULL) {
5786 for (i = 0; i < __kmp_stg_count; ++i) {
5787 if (strcmp(__kmp_stg_table[i].name, name) == 0) {
5788 return &__kmp_stg_table[i];
5789 }
5790 }
5791 }
5792 return NULL;
5793
5794} // __kmp_stg_find
5795
5796static int __kmp_stg_cmp(void const *_a, void const *_b) {
5797 const kmp_setting_t *a = RCAST(const kmp_setting_t *, _a);
5798 const kmp_setting_t *b = RCAST(const kmp_setting_t *, _b);
5799
5800 // Process KMP_AFFINITY last.
5801 // It needs to come after OMP_PLACES and GOMP_CPU_AFFINITY.
5802 if (strcmp(a->name, "KMP_AFFINITY") == 0) {
5803 if (strcmp(b->name, "KMP_AFFINITY") == 0) {
5804 return 0;
5805 }
5806 return 1;
5807 } else if (strcmp(b->name, "KMP_AFFINITY") == 0) {
5808 return -1;
5809 }
5810 return strcmp(a->name, b->name);
5811} // __kmp_stg_cmp
5812
5813static void __kmp_stg_init(void) {
5814
5815 static int initialized = 0;
5816
5817 if (!initialized) {
5818
5819 // Sort table.
5820 qsort(__kmp_stg_table, __kmp_stg_count - 1, sizeof(kmp_setting_t),
5822
5823 { // Initialize *_STACKSIZE data.
5824 kmp_setting_t *kmp_stacksize =
5825 __kmp_stg_find("KMP_STACKSIZE"); // 1st priority.
5826#ifdef KMP_GOMP_COMPAT
5827 kmp_setting_t *gomp_stacksize =
5828 __kmp_stg_find("GOMP_STACKSIZE"); // 2nd priority.
5829#endif
5830 kmp_setting_t *omp_stacksize =
5831 __kmp_stg_find("OMP_STACKSIZE"); // 3rd priority.
5832
5833 // !!! volatile keyword is Intel(R) C Compiler bug CQ49908 workaround.
5834 // !!! Compiler does not understand rivals is used and optimizes out
5835 // assignments
5836 // !!! rivals[ i ++ ] = ...;
5837 static kmp_setting_t *volatile rivals[4];
5838 static kmp_stg_ss_data_t kmp_data = {1, CCAST(kmp_setting_t **, rivals)};
5839#ifdef KMP_GOMP_COMPAT
5840 static kmp_stg_ss_data_t gomp_data = {1024,
5841 CCAST(kmp_setting_t **, rivals)};
5842#endif
5843 static kmp_stg_ss_data_t omp_data = {1024,
5844 CCAST(kmp_setting_t **, rivals)};
5845 int i = 0;
5846
5847 rivals[i++] = kmp_stacksize;
5848#ifdef KMP_GOMP_COMPAT
5849 if (gomp_stacksize != NULL) {
5850 rivals[i++] = gomp_stacksize;
5851 }
5852#endif
5853 rivals[i++] = omp_stacksize;
5854 rivals[i++] = NULL;
5855
5856 kmp_stacksize->data = &kmp_data;
5857#ifdef KMP_GOMP_COMPAT
5858 if (gomp_stacksize != NULL) {
5859 gomp_stacksize->data = &gomp_data;
5860 }
5861#endif
5862 omp_stacksize->data = &omp_data;
5863 }
5864
5865 { // Initialize KMP_LIBRARY and OMP_WAIT_POLICY data.
5866 kmp_setting_t *kmp_library =
5867 __kmp_stg_find("KMP_LIBRARY"); // 1st priority.
5868 kmp_setting_t *omp_wait_policy =
5869 __kmp_stg_find("OMP_WAIT_POLICY"); // 2nd priority.
5870
5871 // !!! volatile keyword is Intel(R) C Compiler bug CQ49908 workaround.
5872 static kmp_setting_t *volatile rivals[3];
5873 static kmp_stg_wp_data_t kmp_data = {0, CCAST(kmp_setting_t **, rivals)};
5874 static kmp_stg_wp_data_t omp_data = {1, CCAST(kmp_setting_t **, rivals)};
5875 int i = 0;
5876
5877 rivals[i++] = kmp_library;
5878 if (omp_wait_policy != NULL) {
5879 rivals[i++] = omp_wait_policy;
5880 }
5881 rivals[i++] = NULL;
5882
5883 kmp_library->data = &kmp_data;
5884 if (omp_wait_policy != NULL) {
5885 omp_wait_policy->data = &omp_data;
5886 }
5887 }
5888
5889 { // Initialize KMP_DEVICE_THREAD_LIMIT and KMP_ALL_THREADS
5890 kmp_setting_t *kmp_device_thread_limit =
5891 __kmp_stg_find("KMP_DEVICE_THREAD_LIMIT"); // 1st priority.
5892 kmp_setting_t *kmp_all_threads =
5893 __kmp_stg_find("KMP_ALL_THREADS"); // 2nd priority.
5894
5895 // !!! volatile keyword is Intel(R) C Compiler bug CQ49908 workaround.
5896 static kmp_setting_t *volatile rivals[3];
5897 int i = 0;
5898
5899 rivals[i++] = kmp_device_thread_limit;
5900 rivals[i++] = kmp_all_threads;
5901 rivals[i++] = NULL;
5902
5903 kmp_device_thread_limit->data = CCAST(kmp_setting_t **, rivals);
5904 kmp_all_threads->data = CCAST(kmp_setting_t **, rivals);
5905 }
5906
5907 { // Initialize KMP_HW_SUBSET and KMP_PLACE_THREADS
5908 // 1st priority
5909 kmp_setting_t *kmp_hw_subset = __kmp_stg_find("KMP_HW_SUBSET");
5910 // 2nd priority
5911 kmp_setting_t *kmp_place_threads = __kmp_stg_find("KMP_PLACE_THREADS");
5912
5913 // !!! volatile keyword is Intel(R) C Compiler bug CQ49908 workaround.
5914 static kmp_setting_t *volatile rivals[3];
5915 int i = 0;
5916
5917 rivals[i++] = kmp_hw_subset;
5918 rivals[i++] = kmp_place_threads;
5919 rivals[i++] = NULL;
5920
5921 kmp_hw_subset->data = CCAST(kmp_setting_t **, rivals);
5922 kmp_place_threads->data = CCAST(kmp_setting_t **, rivals);
5923 }
5924
5925#if KMP_AFFINITY_SUPPORTED
5926 { // Initialize KMP_AFFINITY, GOMP_CPU_AFFINITY, and OMP_PROC_BIND data.
5927 kmp_setting_t *kmp_affinity =
5928 __kmp_stg_find("KMP_AFFINITY"); // 1st priority.
5929 KMP_DEBUG_ASSERT(kmp_affinity != NULL);
5930
5931#ifdef KMP_GOMP_COMPAT
5932 kmp_setting_t *gomp_cpu_affinity =
5933 __kmp_stg_find("GOMP_CPU_AFFINITY"); // 2nd priority.
5934 KMP_DEBUG_ASSERT(gomp_cpu_affinity != NULL);
5935#endif
5936
5937 kmp_setting_t *omp_proc_bind =
5938 __kmp_stg_find("OMP_PROC_BIND"); // 3rd priority.
5939 KMP_DEBUG_ASSERT(omp_proc_bind != NULL);
5940
5941 // !!! volatile keyword is Intel(R) C Compiler bug CQ49908 workaround.
5942 static kmp_setting_t *volatile rivals[4];
5943 int i = 0;
5944
5945 rivals[i++] = kmp_affinity;
5946
5947#ifdef KMP_GOMP_COMPAT
5948 rivals[i++] = gomp_cpu_affinity;
5949 gomp_cpu_affinity->data = CCAST(kmp_setting_t **, rivals);
5950#endif
5951
5952 rivals[i++] = omp_proc_bind;
5953 omp_proc_bind->data = CCAST(kmp_setting_t **, rivals);
5954 rivals[i++] = NULL;
5955
5956 static kmp_setting_t *volatile places_rivals[4];
5957 i = 0;
5958
5959 kmp_setting_t *omp_places = __kmp_stg_find("OMP_PLACES"); // 3rd priority.
5960 KMP_DEBUG_ASSERT(omp_places != NULL);
5961
5962 places_rivals[i++] = kmp_affinity;
5963#ifdef KMP_GOMP_COMPAT
5964 places_rivals[i++] = gomp_cpu_affinity;
5965#endif
5966 places_rivals[i++] = omp_places;
5967 omp_places->data = CCAST(kmp_setting_t **, places_rivals);
5968 places_rivals[i++] = NULL;
5969 }
5970#else
5971// KMP_AFFINITY not supported, so OMP_PROC_BIND has no rivals.
5972// OMP_PLACES not supported yet.
5973#endif // KMP_AFFINITY_SUPPORTED
5974
5975 { // Initialize KMP_DETERMINISTIC_REDUCTION and KMP_FORCE_REDUCTION data.
5976 kmp_setting_t *kmp_force_red =
5977 __kmp_stg_find("KMP_FORCE_REDUCTION"); // 1st priority.
5978 kmp_setting_t *kmp_determ_red =
5979 __kmp_stg_find("KMP_DETERMINISTIC_REDUCTION"); // 2nd priority.
5980
5981 // !!! volatile keyword is Intel(R) C Compiler bug CQ49908 workaround.
5982 static kmp_setting_t *volatile rivals[3];
5983 static kmp_stg_fr_data_t force_data = {1,
5984 CCAST(kmp_setting_t **, rivals)};
5985 static kmp_stg_fr_data_t determ_data = {0,
5986 CCAST(kmp_setting_t **, rivals)};
5987 int i = 0;
5988
5989 rivals[i++] = kmp_force_red;
5990 if (kmp_determ_red != NULL) {
5991 rivals[i++] = kmp_determ_red;
5992 }
5993 rivals[i++] = NULL;
5994
5995 kmp_force_red->data = &force_data;
5996 if (kmp_determ_red != NULL) {
5997 kmp_determ_red->data = &determ_data;
5998 }
5999 }
6000
6001 initialized = 1;
6002 }
6003
6004 // Reset flags.
6005 int i;
6006 for (i = 0; i < __kmp_stg_count; ++i) {
6007 __kmp_stg_table[i].set = 0;
6008 }
6009
6010} // __kmp_stg_init
6011
6012static void __kmp_stg_parse(char const *name, char const *value) {
6013 // On Windows* OS there are some nameless variables like "C:=C:\" (yeah,
6014 // really nameless, they are presented in environment block as
6015 // "=C:=C\\\x00=D:=D:\\\x00...", so let us skip them.
6016 if (name[0] == 0) {
6017 return;
6018 }
6019
6020 if (value != NULL) {
6021 kmp_setting_t *setting = __kmp_stg_find(name);
6022 if (setting != NULL) {
6023 setting->parse(name, value, setting->data);
6024 setting->defined = 1;
6025 }
6026 }
6027
6028} // __kmp_stg_parse
6029
6030static int __kmp_stg_check_rivals( // 0 -- Ok, 1 -- errors found.
6031 char const *name, // Name of variable.
6032 char const *value, // Value of the variable.
6033 kmp_setting_t **rivals // List of rival settings (must include current one).
6034) {
6035
6036 if (rivals == NULL) {
6037 return 0;
6038 }
6039
6040 // Loop thru higher priority settings (listed before current).
6041 int i = 0;
6042 for (; strcmp(rivals[i]->name, name) != 0; i++) {
6043 KMP_DEBUG_ASSERT(rivals[i] != NULL);
6044
6045#if KMP_AFFINITY_SUPPORTED
6046 if (rivals[i] == __kmp_affinity_notype) {
6047 // If KMP_AFFINITY is specified without a type name,
6048 // it does not rival OMP_PROC_BIND or GOMP_CPU_AFFINITY.
6049 continue;
6050 }
6051#endif
6052
6053 if (rivals[i]->set) {
6054 KMP_WARNING(StgIgnored, name, rivals[i]->name);
6055 return 1;
6056 }
6057 }
6058
6059 ++i; // Skip current setting.
6060 return 0;
6061
6062} // __kmp_stg_check_rivals
6063
6064static int __kmp_env_toPrint(char const *name, int flag) {
6065 int rc = 0;
6066 kmp_setting_t *setting = __kmp_stg_find(name);
6067 if (setting != NULL) {
6068 rc = setting->defined;
6069 if (flag >= 0) {
6070 setting->defined = flag;
6071 }
6072 }
6073 return rc;
6074}
6075
6076#if defined(KMP_DEBUG) && KMP_AFFINITY_SUPPORTED
6077static void __kmp_print_affinity_settings(const kmp_affinity_t *affinity) {
6078 K_DIAG(1, ("%s:\n", affinity->env_var));
6079 K_DIAG(1, (" type : %d\n", affinity->type));
6080 K_DIAG(1, (" compact : %d\n", affinity->compact));
6081 K_DIAG(1, (" offset : %d\n", affinity->offset));
6082 K_DIAG(1, (" verbose : %u\n", affinity->flags.verbose));
6083 K_DIAG(1, (" warnings : %u\n", affinity->flags.warnings));
6084 K_DIAG(1, (" respect : %u\n", affinity->flags.respect));
6085 K_DIAG(1, (" reset : %u\n", affinity->flags.reset));
6086 K_DIAG(1, (" dups : %u\n", affinity->flags.dups));
6087 K_DIAG(1, (" gran : %d\n", (int)affinity->gran));
6088 KMP_DEBUG_ASSERT(affinity->type != affinity_default);
6089}
6090#endif
6091
6093
6094 char const *value;
6095
6096 /* OMP_NUM_THREADS */
6097 value = __kmp_env_blk_var(block, "OMP_NUM_THREADS");
6098 if (value) {
6100 }
6101
6102 /* KMP_BLOCKTIME */
6103 value = __kmp_env_blk_var(block, "KMP_BLOCKTIME");
6104 if (value) {
6105 int gtid, tid;
6106 kmp_info_t *thread;
6107
6108 gtid = __kmp_entry_gtid();
6109 tid = __kmp_tid_from_gtid(gtid);
6110 thread = __kmp_thread_from_gtid(gtid);
6112 }
6113
6114 /* OMP_NESTED */
6115 value = __kmp_env_blk_var(block, "OMP_NESTED");
6116 if (value) {
6118 }
6119
6120 /* OMP_DYNAMIC */
6121 value = __kmp_env_blk_var(block, "OMP_DYNAMIC");
6122 if (value) {
6123 ompc_set_dynamic(__kmp_global.g.g_dynamic);
6124 }
6125}
6126
6127void __kmp_env_initialize(char const *string) {
6128
6129 kmp_env_blk_t block;
6130 int i;
6131
6133
6134 // Hack!!!
6135 if (string == NULL) {
6136 // __kmp_max_nth = __kmp_sys_max_nth;
6139 }
6140 __kmp_env_blk_init(&block, string);
6141
6142 // update the set flag on all entries that have an env var
6143 for (i = 0; i < block.count; ++i) {
6144 if ((block.vars[i].name == NULL) || (*block.vars[i].name == '\0')) {
6145 continue;
6146 }
6147 if (block.vars[i].value == NULL) {
6148 continue;
6149 }
6150 kmp_setting_t *setting = __kmp_stg_find(block.vars[i].name);
6151 if (setting != NULL) {
6152 setting->set = 1;
6153 }
6154 }
6155
6156 // We need to know if blocktime and use_yield were set when processing
6157 // OMP_WAIT_POLICY
6158 blocktime_str = __kmp_env_blk_var(&block, "KMP_BLOCKTIME");
6159 use_yield_str = __kmp_env_blk_var(&block, "KMP_USE_YIELD");
6160
6161 // Special case. If we parse environment, not a string, process KMP_WARNINGS
6162 // first.
6163 if (string == NULL) {
6164 char const *name = "KMP_WARNINGS";
6165 char const *value = __kmp_env_blk_var(&block, name);
6167 }
6168
6169#if KMP_AFFINITY_SUPPORTED
6170 // Special case. KMP_AFFINITY is not a rival to other affinity env vars
6171 // if no affinity type is specified. We want to allow
6172 // KMP_AFFINITY=[no],verbose/[no]warnings/etc. to be enabled when
6173 // specifying the affinity type via GOMP_CPU_AFFINITY or the OMP 4.0
6174 // affinity mechanism.
6175 __kmp_affinity_notype = NULL;
6176 char const *aff_str = __kmp_env_blk_var(&block, "KMP_AFFINITY");
6177 if (aff_str != NULL) {
6178 // Check if the KMP_AFFINITY type is specified in the string.
6179 // We just search the string for "compact", "scatter", etc.
6180 // without really parsing the string. The syntax of the
6181 // KMP_AFFINITY env var is such that none of the affinity
6182 // type names can appear anywhere other that the type
6183 // specifier, even as substrings.
6184 //
6185 // I can't find a case-insensitive version of strstr on Windows* OS.
6186 // Use the case-sensitive version for now. AIX does the same.
6187
6188#if KMP_OS_WINDOWS || KMP_OS_AIX
6189#define FIND strstr
6190#else
6191#define FIND strcasestr
6192#endif
6193
6194 if ((FIND(aff_str, "none") == NULL) &&
6195 (FIND(aff_str, "physical") == NULL) &&
6196 (FIND(aff_str, "logical") == NULL) &&
6197 (FIND(aff_str, "compact") == NULL) &&
6198 (FIND(aff_str, "scatter") == NULL) &&
6199 (FIND(aff_str, "explicit") == NULL) &&
6200 (FIND(aff_str, "balanced") == NULL) &&
6201 (FIND(aff_str, "disabled") == NULL)) {
6202 __kmp_affinity_notype = __kmp_stg_find("KMP_AFFINITY");
6203 } else {
6204 // A new affinity type is specified.
6205 // Reset the affinity flags to their default values,
6206 // in case this is called from kmp_set_defaults().
6207 __kmp_affinity.type = affinity_default;
6208 __kmp_affinity.gran = KMP_HW_UNKNOWN;
6209 __kmp_affinity_top_method = affinity_top_method_default;
6210 __kmp_affinity.flags.respect = affinity_respect_mask_default;
6211 }
6212#undef FIND
6213
6214 // Also reset the affinity flags if OMP_PROC_BIND is specified.
6215 aff_str = __kmp_env_blk_var(&block, "OMP_PROC_BIND");
6216 if (aff_str != NULL) {
6217 __kmp_affinity.type = affinity_default;
6218 __kmp_affinity.gran = KMP_HW_UNKNOWN;
6219 __kmp_affinity_top_method = affinity_top_method_default;
6220 __kmp_affinity.flags.respect = affinity_respect_mask_default;
6221 }
6222 }
6223
6224#endif /* KMP_AFFINITY_SUPPORTED */
6225
6226 // Set up the nested proc bind type vector.
6227 if (__kmp_nested_proc_bind.bind_types == NULL) {
6228 __kmp_nested_proc_bind.bind_types =
6230 if (__kmp_nested_proc_bind.bind_types == NULL) {
6231 KMP_FATAL(MemoryAllocFailed);
6232 }
6233 __kmp_nested_proc_bind.size = 1;
6234 __kmp_nested_proc_bind.used = 1;
6235#if KMP_AFFINITY_SUPPORTED
6237#else
6238 // default proc bind is false if affinity not supported
6240#endif
6241 }
6242
6243 // Set up the affinity format ICV
6244 // Grab the default affinity format string from the message catalog
6245 kmp_msg_t m =
6246 __kmp_msg_format(kmp_i18n_msg_AffFormatDefault, "%P", "%i", "%n", "%A");
6248
6249 if (__kmp_affinity_format == NULL) {
6251 (char *)KMP_INTERNAL_MALLOC(sizeof(char) * KMP_AFFINITY_FORMAT_SIZE);
6252 }
6254 __kmp_str_free(&m.str);
6255
6256 // Now process all of the settings.
6257 for (i = 0; i < block.count; ++i) {
6258 __kmp_stg_parse(block.vars[i].name, block.vars[i].value);
6259 }
6260
6261 // If user locks have been allocated yet, don't reset the lock vptr table.
6262 if (!__kmp_init_user_locks) {
6265 }
6266#if KMP_USE_DYNAMIC_LOCK
6267 __kmp_init_dynamic_user_locks();
6268#else
6270#endif
6271 } else {
6272 KMP_DEBUG_ASSERT(string != NULL); // kmp_set_defaults() was called
6274// Binds lock functions again to follow the transition between different
6275// KMP_CONSISTENCY_CHECK values. Calling this again is harmless as long
6276// as we do not allow lock kind changes after making a call to any
6277// user lock functions (true).
6278#if KMP_USE_DYNAMIC_LOCK
6279 __kmp_init_dynamic_user_locks();
6280#else
6282#endif
6283 }
6284
6285#if KMP_AFFINITY_SUPPORTED
6286
6287 if (!TCR_4(__kmp_init_middle)) {
6288#if KMP_HWLOC_ENABLED
6289 // Force using hwloc when either tiles or numa nodes requested within
6290 // KMP_HW_SUBSET or granularity setting and no other topology method
6291 // is requested
6292 if (__kmp_hw_subset &&
6293 __kmp_affinity_top_method == affinity_top_method_default)
6294 if (__kmp_hw_subset->specified(KMP_HW_NUMA) ||
6295 __kmp_hw_subset->specified(KMP_HW_TILE) ||
6296 __kmp_affinity.gran == KMP_HW_TILE ||
6297 __kmp_affinity.gran == KMP_HW_NUMA)
6298 __kmp_affinity_top_method = affinity_top_method_hwloc;
6299 // Force using hwloc when tiles or numa nodes requested for OMP_PLACES
6300 if (__kmp_affinity.gran == KMP_HW_NUMA ||
6301 __kmp_affinity.gran == KMP_HW_TILE)
6302 __kmp_affinity_top_method = affinity_top_method_hwloc;
6303#endif // KMP_HWLOC_ENABLED
6304 // Determine if the machine/OS is actually capable of supporting
6305 // affinity.
6306 const char *var = "KMP_AFFINITY";
6307 KMPAffinity::pick_api();
6308#if KMP_HWLOC_ENABLED
6309 // If Hwloc topology discovery was requested but affinity was also disabled,
6310 // then tell user that Hwloc request is being ignored and use default
6311 // topology discovery method.
6312 if (__kmp_affinity_top_method == affinity_top_method_hwloc &&
6313 __kmp_affinity_dispatch->get_api_type() != KMPAffinity::HWLOC) {
6314 KMP_WARNING(AffIgnoringHwloc, var);
6315 __kmp_affinity_top_method = affinity_top_method_all;
6316 }
6317#endif // KMP_HWLOC_ENABLED
6318 if (__kmp_affinity.type == affinity_disabled) {
6319 KMP_AFFINITY_DISABLE();
6320 } else if (!KMP_AFFINITY_CAPABLE()) {
6321 __kmp_affinity_dispatch->determine_capable(var);
6322 if (!KMP_AFFINITY_CAPABLE()) {
6323 if (__kmp_affinity.flags.verbose ||
6324 (__kmp_affinity.flags.warnings &&
6325 (__kmp_affinity.type != affinity_default) &&
6326 (__kmp_affinity.type != affinity_none) &&
6327 (__kmp_affinity.type != affinity_disabled))) {
6328 KMP_WARNING(AffNotSupported, var);
6329 }
6330 __kmp_affinity.type = affinity_disabled;
6331 __kmp_affinity.flags.respect = FALSE;
6332 __kmp_affinity.gran = KMP_HW_THREAD;
6333 }
6334 }
6335
6336 if (__kmp_affinity.type == affinity_disabled) {
6338 } else if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_true) {
6339 // OMP_PROC_BIND=true maps to OMP_PROC_BIND=spread.
6341 }
6342
6343 if (KMP_AFFINITY_CAPABLE()) {
6344
6345#if KMP_GROUP_AFFINITY
6346 // This checks to see if the initial affinity mask is equal
6347 // to a single windows processor group. If it is, then we do
6348 // not respect the initial affinity mask and instead, use the
6349 // entire machine.
6350 bool exactly_one_group = false;
6351 if (__kmp_num_proc_groups > 1) {
6352 int group;
6353 bool within_one_group;
6354 // Get the initial affinity mask and determine if it is
6355 // contained within a single group.
6356 kmp_affin_mask_t *init_mask;
6357 KMP_CPU_ALLOC(init_mask);
6358 __kmp_get_system_affinity(init_mask, TRUE);
6359 group = __kmp_get_proc_group(init_mask);
6360 within_one_group = (group >= 0);
6361 // If the initial affinity is within a single group,
6362 // then determine if it is equal to that single group.
6363 if (within_one_group) {
6364 DWORD num_bits_in_group = __kmp_GetActiveProcessorCount(group);
6365 DWORD num_bits_in_mask = 0;
6366 for (int bit = init_mask->begin(); bit != init_mask->end();
6367 bit = init_mask->next(bit))
6368 num_bits_in_mask++;
6369 exactly_one_group = (num_bits_in_group == num_bits_in_mask);
6370 }
6371 KMP_CPU_FREE(init_mask);
6372 }
6373
6374 // Handle the Win 64 group affinity stuff if there are multiple
6375 // processor groups, or if the user requested it, and OMP 4.0
6376 // affinity is not in effect.
6377 if (__kmp_num_proc_groups > 1 &&
6378 __kmp_affinity.type == affinity_default &&
6379 __kmp_nested_proc_bind.bind_types[0] == proc_bind_default) {
6380 // Do not respect the initial processor affinity mask if it is assigned
6381 // exactly one Windows Processor Group since this is interpreted as the
6382 // default OS assignment. Not respecting the mask allows the runtime to
6383 // use all the logical processors in all groups.
6384 if (__kmp_affinity.flags.respect == affinity_respect_mask_default &&
6385 exactly_one_group) {
6386 __kmp_affinity.flags.respect = FALSE;
6387 }
6388 // Use compact affinity with anticipation of pinning to at least the
6389 // group granularity since threads can only be bound to one group.
6390 if (__kmp_affinity.type == affinity_default) {
6391 __kmp_affinity.type = affinity_compact;
6393 }
6394 if (__kmp_hh_affinity.type == affinity_default)
6395 __kmp_hh_affinity.type = affinity_compact;
6396 if (__kmp_affinity_top_method == affinity_top_method_default)
6397 __kmp_affinity_top_method = affinity_top_method_all;
6398 if (__kmp_affinity.gran == KMP_HW_UNKNOWN)
6399 __kmp_affinity.gran = KMP_HW_PROC_GROUP;
6400 if (__kmp_hh_affinity.gran == KMP_HW_UNKNOWN)
6401 __kmp_hh_affinity.gran = KMP_HW_PROC_GROUP;
6402 } else
6403
6404#endif /* KMP_GROUP_AFFINITY */
6405
6406 {
6407 if (__kmp_affinity.flags.respect == affinity_respect_mask_default) {
6408#if KMP_GROUP_AFFINITY
6409 if (__kmp_num_proc_groups > 1 && exactly_one_group) {
6410 __kmp_affinity.flags.respect = FALSE;
6411 } else
6412#endif /* KMP_GROUP_AFFINITY */
6413 {
6414 __kmp_affinity.flags.respect = TRUE;
6415 }
6416 }
6417 if ((__kmp_nested_proc_bind.bind_types[0] != proc_bind_intel) &&
6418 (__kmp_nested_proc_bind.bind_types[0] != proc_bind_default)) {
6419 if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_false)
6420 __kmp_affinity.type = affinity_none;
6421 if (__kmp_affinity.type == affinity_default) {
6422 __kmp_affinity.type = affinity_compact;
6423 __kmp_affinity.flags.dups = FALSE;
6424 }
6425 } else if (__kmp_affinity.type == affinity_default) {
6426#if KMP_MIC_SUPPORTED
6427 if (__kmp_mic_type != non_mic) {
6429 } else
6430#endif
6431 {
6433 }
6434#if KMP_MIC_SUPPORTED
6435 if (__kmp_mic_type != non_mic) {
6436 __kmp_affinity.type = affinity_scatter;
6437 } else
6438#endif
6439 {
6440 __kmp_affinity.type = affinity_none;
6441 }
6442 }
6443 if (__kmp_hh_affinity.type == affinity_default)
6444 __kmp_hh_affinity.type = affinity_none;
6445 if ((__kmp_affinity.gran == KMP_HW_UNKNOWN) &&
6446 (__kmp_affinity.gran_levels < 0)) {
6447#if KMP_MIC_SUPPORTED
6448 if (__kmp_mic_type != non_mic) {
6449 __kmp_affinity.gran = KMP_HW_THREAD;
6450 } else
6451#endif
6452 {
6453 __kmp_affinity.gran = KMP_HW_CORE;
6454 }
6455 }
6456 if ((__kmp_hh_affinity.gran == KMP_HW_UNKNOWN) &&
6457 (__kmp_hh_affinity.gran_levels < 0)) {
6458#if KMP_MIC_SUPPORTED
6459 if (__kmp_mic_type != non_mic) {
6460 __kmp_hh_affinity.gran = KMP_HW_THREAD;
6461 } else
6462#endif
6463 {
6464 __kmp_hh_affinity.gran = KMP_HW_CORE;
6465 }
6466 }
6467 if (__kmp_affinity_top_method == affinity_top_method_default) {
6468 __kmp_affinity_top_method = affinity_top_method_all;
6469 }
6470 }
6471 } else {
6472 // If affinity is disabled, then still need to assign topology method
6473 // to attempt machine detection and affinity types
6474 if (__kmp_affinity_top_method == affinity_top_method_default)
6475 __kmp_affinity_top_method = affinity_top_method_all;
6476 if (__kmp_affinity.type == affinity_default)
6477 __kmp_affinity.type = affinity_disabled;
6478 if (__kmp_hh_affinity.type == affinity_default)
6479 __kmp_hh_affinity.type = affinity_disabled;
6480 }
6481
6482#ifdef KMP_DEBUG
6483 for (const kmp_affinity_t *affinity : __kmp_affinities)
6484 __kmp_print_affinity_settings(affinity);
6486 K_DIAG(1, ("__kmp_nested_proc_bind.bind_types[0] == %d\n",
6487 __kmp_nested_proc_bind.bind_types[0]));
6488#endif
6489 }
6490
6491#endif /* KMP_AFFINITY_SUPPORTED */
6492
6493 // Post-initialization step: some env. vars need their value's further
6494 // processing
6495 if (string != NULL) { // kmp_set_defaults() was called
6497 }
6498
6499 __kmp_env_blk_free(&block);
6500
6501 KMP_MB();
6502
6503} // __kmp_env_initialize
6504
6506
6507 kmp_env_blk_t block;
6508 int i;
6509 kmp_str_buf_t buffer;
6510
6512 __kmp_str_buf_init(&buffer);
6513
6514 __kmp_env_blk_init(&block, NULL);
6515 __kmp_env_blk_sort(&block);
6516
6517 // Print real environment values.
6518 __kmp_str_buf_print(&buffer, "\n%s\n\n", KMP_I18N_STR(UserSettings));
6519 for (i = 0; i < block.count; ++i) {
6520 char const *name = block.vars[i].name;
6521 char const *value = block.vars[i].value;
6522 if ((KMP_STRLEN(name) > 4 && strncmp(name, "KMP_", 4) == 0) ||
6523 strncmp(name, "OMP_", 4) == 0
6524#ifdef KMP_GOMP_COMPAT
6525 || strncmp(name, "GOMP_", 5) == 0
6526#endif // KMP_GOMP_COMPAT
6527 ) {
6528 __kmp_str_buf_print(&buffer, " %s=%s\n", name, value);
6529 }
6530 }
6531 __kmp_str_buf_print(&buffer, "\n");
6532
6533 // Print internal (effective) settings.
6534 __kmp_str_buf_print(&buffer, "%s\n\n", KMP_I18N_STR(EffectiveSettings));
6535 for (int i = 0; i < __kmp_stg_count; ++i) {
6536 if (__kmp_stg_table[i].print != NULL) {
6537 __kmp_stg_table[i].print(&buffer, __kmp_stg_table[i].name,
6539 }
6540 }
6541
6542 __kmp_printf("%s", buffer.str);
6543
6544 __kmp_env_blk_free(&block);
6545 __kmp_str_buf_free(&buffer);
6546
6547 __kmp_printf("\n");
6548
6549} // __kmp_env_print
6550
6554
6555void __kmp_display_env_impl(int display_env, int display_env_verbose) {
6556 kmp_env_blk_t block;
6557 kmp_str_buf_t buffer;
6558
6559 __kmp_env_format = 1;
6560
6562 __kmp_str_buf_init(&buffer);
6563
6564 __kmp_env_blk_init(&block, NULL);
6565 __kmp_env_blk_sort(&block);
6566
6567 __kmp_str_buf_print(&buffer, "\n%s\n", KMP_I18N_STR(DisplayEnvBegin));
6568 __kmp_str_buf_print(&buffer, " _OPENMP='%d'\n", __kmp_openmp_version);
6569
6570 for (int i = 0; i < __kmp_stg_count; ++i) {
6571 if (__kmp_stg_table[i].print != NULL &&
6572 ((display_env && strncmp(__kmp_stg_table[i].name, "OMP_", 4) == 0) ||
6573 display_env_verbose)) {
6574 __kmp_stg_table[i].print(&buffer, __kmp_stg_table[i].name,
6576 }
6577 }
6578
6579 __kmp_str_buf_print(&buffer, "%s\n", KMP_I18N_STR(DisplayEnvEnd));
6580 __kmp_str_buf_print(&buffer, "\n");
6581
6582 __kmp_printf("%s", buffer.str);
6583
6584 __kmp_env_blk_free(&block);
6585 __kmp_str_buf_free(&buffer);
6586
6587 __kmp_printf("\n");
6588}
6589
6590#if OMPD_SUPPORT
6591// Dump environment variables for OMPD
6592void __kmp_env_dump() {
6593
6594 kmp_env_blk_t block;
6595 kmp_str_buf_t buffer, env, notdefined;
6596
6598 __kmp_str_buf_init(&buffer);
6599 __kmp_str_buf_init(&env);
6600 __kmp_str_buf_init(&notdefined);
6601
6602 __kmp_env_blk_init(&block, NULL);
6603 __kmp_env_blk_sort(&block);
6604
6605 __kmp_str_buf_print(&notdefined, ": %s", KMP_I18N_STR(NotDefined));
6606
6607 for (int i = 0; i < __kmp_stg_count; ++i) {
6608 if (__kmp_stg_table[i].print == NULL)
6609 continue;
6610 __kmp_str_buf_clear(&env);
6611 __kmp_stg_table[i].print(&env, __kmp_stg_table[i].name,
6613 if (env.used < 4) // valid definition must have indents (3) and a new line
6614 continue;
6615 if (strstr(env.str, notdefined.str))
6616 // normalize the string
6617 __kmp_str_buf_print(&buffer, "%s=undefined\n", __kmp_stg_table[i].name);
6618 else
6619 __kmp_str_buf_cat(&buffer, env.str + 3, env.used - 3);
6620 }
6621
6622 ompd_env_block = (char *)__kmp_allocate(buffer.used + 1);
6623 KMP_MEMCPY(ompd_env_block, buffer.str, buffer.used + 1);
6624 ompd_env_block_size = (ompd_size_t)KMP_STRLEN(ompd_env_block);
6625
6626 __kmp_env_blk_free(&block);
6627 __kmp_str_buf_free(&buffer);
6628 __kmp_str_buf_free(&env);
6629 __kmp_str_buf_free(&notdefined);
6630}
6631#endif // OMPD_SUPPORT
6632
6633// end of file
char buf[BUFFER_SIZE]
int result[2]
static kmp_hw_subset_t * allocate()
static void deallocate(kmp_hw_subset_t *subset)
static const int USE_ALL
static int parse_single_device(kmp_str_ref spec, int device_num_min, int device_num_max, const char *dbg_name=nullptr)
int __kmp_atomic_mode
sched_type
Describes the loop schedule to be used for a parallel for loop.
Definition kmp.h:340
@ kmp_sch_auto
auto
Definition kmp.h:347
@ kmp_sch_static
static unspecialized
Definition kmp.h:343
@ kmp_sch_modifier_monotonic
Set if the monotonic schedule modifier was present.
Definition kmp.h:428
@ kmp_sch_default
default scheduling algorithm
Definition kmp.h:448
@ kmp_sch_modifier_nonmonotonic
Set if the nonmonotonic schedule modifier was present.
Definition kmp.h:430
@ kmp_sch_guided_chunked
guided unspecialized
Definition kmp.h:345
@ kmp_sch_dynamic_chunked
Definition kmp.h:344
@ kmp_sch_guided_analytical_chunked
Definition kmp.h:355
@ kmp_sch_static_balanced
Definition kmp.h:352
@ kmp_sch_static_greedy
Definition kmp.h:351
@ kmp_sch_static_chunked
Definition kmp.h:342
@ kmp_sch_trapezoidal
Definition kmp.h:348
@ kmp_sch_guided_iterative_chunked
Definition kmp.h:354
@ kmp_sch_static_steal
Definition kmp.h:357
__itt_string_handle * name
Definition ittnotify.h:3305
void
Definition ittnotify.h:3324
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp __itt_timestamp ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain ITT_FORMAT p const __itt_domain __itt_string_handle unsigned long long ITT_FORMAT lu const __itt_domain __itt_string_handle unsigned long long ITT_FORMAT lu const __itt_domain __itt_id __itt_string_handle __itt_metadata_type size_t void * data
void const char const char int ITT_FORMAT __itt_group_sync s
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp __itt_timestamp end
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int initialized
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp begin
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t count
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp __itt_timestamp ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain ITT_FORMAT p const __itt_domain __itt_string_handle unsigned long long ITT_FORMAT lu const __itt_domain __itt_string_handle unsigned long long ITT_FORMAT lu const __itt_domain __itt_id __itt_string_handle __itt_metadata_type size_t void ITT_FORMAT p const __itt_domain __itt_id __itt_string_handle const wchar_t size_t length
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp __itt_timestamp ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain ITT_FORMAT p const __itt_domain __itt_string_handle unsigned long long value
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t mode
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t size
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp __itt_timestamp ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain ITT_FORMAT p const __itt_domain __itt_string_handle unsigned long long ITT_FORMAT lu const __itt_domain __itt_string_handle unsigned long long ITT_FORMAT lu const __itt_domain __itt_id __itt_string_handle __itt_metadata_type type
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp __itt_timestamp ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain ITT_FORMAT p const __itt_domain __itt_string_handle unsigned long long ITT_FORMAT lu const __itt_domain __itt_string_handle unsigned long long ITT_FORMAT lu const __itt_domain __itt_id __itt_string_handle * key
int __kmp_memkind_available
omp_memspace_handle_t const omp_default_mem_space
int __kmp_hot_teams_max_level
void * omp_memspace_handle_t
Definition kmp.h:1055
void * omp_allocator_handle_t
Definition kmp.h:1073
#define KMP_HW_MAX_NUM_CORE_EFFS
Definition kmp.h:619
int __kmp_generate_warnings
volatile int __kmp_init_user_locks
int __kmp_debug_buf_lines
omp_allocator_handle_t __kmpc_init_allocator(int gtid, omp_memspace_handle_t, int ntraits, omp_alloctrait_t traits[])
int __kmp_cg_max_nth
int __kmp_abort_delay
kmp_proc_bind_t __kmp_teams_proc_bind
#define KMP_INTERNAL_MALLOC(sz)
Definition kmp.h:103
#define KMP_DEFAULT_CHUNK
Definition kmp.h:1305
void ompc_set_dynamic(int flag)
int __kmp_version
#define KMP_MAX_STKSIZE
Definition kmp.h:1207
#define KMP_MAX_STKPADDING
Definition kmp.h:1240
int __kmp_display_env_verbose
omp_allocator_handle_t const omp_cgroup_mem_alloc
kmp_global_t __kmp_global
@ omp_atk_fallback
Definition kmp.h:1016
@ omp_atk_pinned
Definition kmp.h:1018
@ omp_atk_access
Definition kmp.h:1014
@ omp_atk_alignment
Definition kmp.h:1013
@ omp_atk_pool_size
Definition kmp.h:1015
@ omp_atk_fb_data
Definition kmp.h:1017
@ omp_atk_partition
Definition kmp.h:1019
@ omp_atk_sync_hint
Definition kmp.h:1012
size_t __kmp_align_alloc
#define KMP_MAX_BLOCKTIME
Definition kmp.h:1245
int __kmp_teams_max_nth
#define KMP_MAX_CHUNK
Definition kmp.h:1304
kmp_int32 __kmp_use_yield
@ tgt_mandatory
Definition kmp.h:4522
@ tgt_disabled
Definition kmp.h:4520
@ tgt_default
Definition kmp.h:4521
char const * __kmp_barrier_pattern_name[bp_last_bar]
int __kmp_dflt_team_nth_ub
#define KMP_MIN_STKOFFSET
Definition kmp.h:1231
#define KMP_INTERNAL_REALLOC(p, sz)
Definition kmp.h:105
#define SKIP_TO(_x, _c)
Definition kmp.h:281
int __kmp_dflt_max_active_levels
int __kmp_xproc
int __kmp_debug_buf
omp_memspace_handle_t const omp_low_lat_mem_space
int __kmp_storage_map_verbose_specified
#define KMP_FOREACH_HW_TYPE(type)
Definition kmp.h:626
kmp_bar_pat_e __kmp_barrier_gather_pattern[bs_last_barrier]
kmp_tasking_mode_t __kmp_tasking_mode
char * __kmp_affinity_format
int __kmp_dflt_blocktime
omp_allocator_handle_t __kmp_def_allocator
int __kmp_omp_cancellation
size_t __kmp_stksize
kmp_nested_proc_bind_t __kmp_nested_proc_bind
kmp_nested_nthreads_t __kmp_nested_nth
int __kmp_max_nth
omp_allocator_handle_t const omp_default_mem_alloc
int __kmp_chunk
@ omp_atv_cgroup
Definition kmp.h:1039
@ omp_atv_all
Definition kmp.h:1048
@ omp_atv_interleaved
Definition kmp.h:1047
@ omp_atv_false
Definition kmp.h:1029
@ omp_atv_environment
Definition kmp.h:1044
@ omp_atv_serialized
Definition kmp.h:1033
@ omp_atv_blocked
Definition kmp.h:1046
@ omp_atv_thread
Definition kmp.h:1037
@ omp_atv_default_mem_fb
Definition kmp.h:1040
@ omp_atv_allocator_fb
Definition kmp.h:1043
@ omp_atv_pteam
Definition kmp.h:1038
@ omp_atv_contended
Definition kmp.h:1031
@ omp_atv_null_fb
Definition kmp.h:1041
@ omp_atv_nearest
Definition kmp.h:1045
@ omp_atv_uncontended
Definition kmp.h:1032
@ omp_atv_true
Definition kmp.h:1030
@ omp_atv_private
Definition kmp.h:1035
@ omp_atv_abort_fb
Definition kmp.h:1042
kmp_target_offload_kind_t __kmp_target_offload
int __kmp_debug_buf_chars
#define KMP_MAX_TASK_PRIORITY_LIMIT
Definition kmp.h:1321
#define SCHEDULE_HAS_MONOTONIC(s)
Definition kmp.h:436
#define KMP_MIN_NTH
Definition kmp.h:1181
#define KMP_MAX_BRANCH_BITS
Definition kmp.h:1315
int __kmp_adjust_gtid_mode
int __kmp_env_blocktime
#define __kmp_entry_gtid()
Definition kmp.h:3594
static int __kmp_tid_from_gtid(int gtid)
Definition kmp.h:3612
int __kmp_display_env
kmp_int32 __kmp_use_yield_exp_set
omp_allocator_handle_t const omp_large_cap_mem_alloc
const char * __kmp_hw_get_catalog_string(kmp_hw_t type, bool plural=false)
omp_allocator_handle_t const omp_low_lat_mem_alloc
#define KMP_DEFAULT_STKSIZE
Definition kmp.h:1223
volatile int __kmp_init_middle
omp_allocator_handle_t const omp_high_bw_mem_alloc
int __kmp_storage_map_verbose
int __kmp_allThreadsSpecified
enum sched_type __kmp_static
const char * __kmp_hw_get_keyword(kmp_hw_t type, bool plural=false)
int __kmp_affinity_num_places
int __kmp_duplicate_library_ok
#define KMP_MAX_STKOFFSET
Definition kmp.h:1232
omp_memspace_handle_t const omp_const_mem_space
kmp_uint32 __kmp_barrier_release_branch_bits[bs_last_barrier]
kmp_int32 __kmp_default_device
omp_memspace_handle_t const omp_large_cap_mem_space
int __kmp_force_monotonic
enum sched_type __kmp_sched
uintptr_t omp_uintptr_t
Definition kmp.h:1009
int __kmp_enable_task_throttling
kmp_uint32 __kmp_barrier_gather_bb_dflt
kmp_uint32 __kmp_barrier_release_bb_dflt
int __kmp_task_stealing_constraint
int __kmp_need_register_atfork
int __kmp_dispatch_num_buffers
#define SCHEDULE_WITHOUT_MODIFIERS(s)
Definition kmp.h:433
int __kmp_nesting_mode
bool __kmp_dflt_max_active_levels_set
char * __kmp_debug_buffer
omp_memspace_handle_t const omp_high_bw_mem_space
int __kmp_nteams
int __kmp_storage_map
omp_allocator_handle_t const omp_const_mem_alloc
volatile int __kmp_init_parallel
omp_allocator_handle_t const omp_pteam_mem_alloc
int __kmp_sys_max_nth
int __kmp_need_register_atfork_specified
kmp_int32 __kmp_enable_hidden_helper
#define KMP_DEFAULT_BLOCKTIME
Definition kmp.h:1249
#define __kmp_allocate(size)
Definition kmp.h:3747
#define KMP_DEBUG_BUF_LINES_MIN
Definition kmp.h:3317
static const size_t KMP_AFFINITY_FORMAT_SIZE
Definition kmp.h:951
#define TRUE
Definition kmp.h:1341
enum library_type __kmp_library
#define FALSE
Definition kmp.h:1340
int __kmp_tp_capacity
int __kmp_settings
@ tskm_extra_barrier
Definition kmp.h:2439
@ tskm_max
Definition kmp.h:2441
@ tskm_task_teams
Definition kmp.h:2440
int __kmp_env_consistency_check
kmp_uint64 __kmp_taskloop_min_tasks
char const * __kmp_barrier_branch_bit_env_name[bs_last_barrier]
#define SCHEDULE_HAS_NONMONOTONIC(s)
Definition kmp.h:437
int __kmp_determ_red
int __kmp_hot_teams_mode
size_t __kmp_sys_min_stksize
char __kmp_blocktime_units
void ompc_set_nested(int flag)
kmp_uint32 __kmp_barrier_gather_branch_bits[bs_last_barrier]
size_t __kmp_stkoffset
size_t __kmp_malloc_pool_incr
#define KMP_INTERNAL_FREE(p)
Definition kmp.h:104
int __kmp_threads_capacity
int __kmp_foreign_tp
bool __kmp_wpolicy_passive
@ bs_plain_barrier
Definition kmp.h:2153
@ bs_last_barrier
Definition kmp.h:2159
#define KMP_MAX_DEFAULT_DEVICE_LIMIT
Definition kmp.h:1319
int __kmp_display_affinity
enum sched_type __kmp_guided
#define SKIP_WS(_x)
Definition kmp.h:265
#define __kmp_get_gtid()
Definition kmp.h:3593
PACKED_REDUCTION_METHOD_T __kmp_force_reduction_method
#define KMP_MIN_MALLOC_POOL_INCR
Definition kmp.h:1227
omp_allocator_handle_t const omp_thread_mem_alloc
#define KMP_MAX_MALLOC_POOL_INCR
Definition kmp.h:1228
#define __kmp_page_allocate(size)
Definition kmp.h:3748
#define SKIP_DIGITS(_x)
Definition kmp.h:270
kmp_int32 __kmp_max_task_priority
int __kmp_teams_thread_limit
int __kmp_stkpadding
int __kmp_dflt_team_nth
#define KMP_DEBUG_BUF_CHARS_MIN
Definition kmp.h:3320
void ompc_set_num_threads(int arg)
char const * __kmp_barrier_pattern_env_name[bs_last_barrier]
std::atomic< int > __kmp_debug_count
kmp_proc_bind_t
Definition kmp.h:930
@ proc_bind_false
Definition kmp.h:931
@ proc_bind_true
Definition kmp.h:932
@ proc_bind_close
Definition kmp.h:934
@ proc_bind_intel
Definition kmp.h:936
@ proc_bind_primary
Definition kmp.h:933
@ proc_bind_spread
Definition kmp.h:935
@ proc_bind_default
Definition kmp.h:937
kmp_hw_t
Definition kmp.h:591
@ KMP_HW_UNKNOWN
Definition kmp.h:592
@ KMP_HW_NUMA
Definition kmp.h:595
@ KMP_HW_SOCKET
Definition kmp.h:593
@ KMP_HW_CORE
Definition kmp.h:603
@ KMP_HW_PROC_GROUP
Definition kmp.h:594
@ KMP_HW_TILE
Definition kmp.h:599
@ KMP_HW_THREAD
Definition kmp.h:604
@ KMP_HW_LAST
Definition kmp.h:605
@ KMP_HW_LLC
Definition kmp.h:597
static kmp_info_t * __kmp_thread_from_gtid(int gtid)
Definition kmp.h:3627
#define KMP_MIN_DISP_NUM_BUFF
Definition kmp.h:1307
void __kmp_expand_file_name(char *result, size_t rlen, char *pattern)
int __kmp_gtid_mode
#define KMP_MIN_BLOCKTIME
Definition kmp.h:1244
#define SCHEDULE_SET_MODIFIERS(s, m)
Definition kmp.h:443
kmp_hw_core_type_t
Definition kmp.h:608
@ KMP_HW_MAX_NUM_CORE_TYPES
Definition kmp.h:615
@ KMP_HW_CORE_TYPE_UNKNOWN
Definition kmp.h:609
#define KMP_MIN_STKPADDING
Definition kmp.h:1239
@ library_none
Definition kmp.h:488
@ library_turnaround
Definition kmp.h:490
@ library_throughput
Definition kmp.h:491
@ library_serial
Definition kmp.h:489
volatile int __kmp_init_serial
@ critical_reduce_block
Definition kmp.h:519
@ tree_reduce_block
Definition kmp.h:521
@ reduction_method_not_defined
Definition kmp.h:518
@ atomic_reduce_block
Definition kmp.h:520
#define KMP_MAX_DISP_NUM_BUFF
Definition kmp.h:1309
kmp_int32 __kmp_hidden_helper_threads_num
#define KMP_MAX_ACTIVE_LEVELS_LIMIT
Definition kmp.h:1317
static void __kmp_type_convert(T1 src, T2 *dest)
Definition kmp.h:4878
enum kmp_bar_pat kmp_bar_pat_e
#define SKIP_TOKEN(_x)
Definition kmp.h:275
int __kmp_debug_buf_atomic
kmp_bar_pat_e __kmp_barrier_release_pattern[bs_last_barrier]
int __kmp_env_stksize
@ bp_dist_bar
Definition kmp.h:2175
@ bp_linear_bar
Definition kmp.h:2168
@ bp_last_bar
Definition kmp.h:2176
@ dynamic_thread_limit
Definition kmp.h:309
@ dynamic_default
Definition kmp.h:304
@ dynamic_random
Definition kmp.h:308
bool __kmp_hwloc_available
union KMP_ALIGN_CACHE kmp_info kmp_info_t
omp_allocator_handle_t const omp_null_allocator
void __kmp_aux_set_blocktime(int arg, kmp_info_t *thread, int tid)
kmp_hw_subset_t * __kmp_hw_subset
KMP_ARCH_X86 KMP_ARCH_X86 KMP_ARCH_X86 KMP_ARCH_X86 KMP_ARCH_X86 KMP_ARCH_X86 KMP_ARCH_X86 KMP_ARCH_X86 KMP_ARCH_X86<<, 2i, 1, KMP_ARCH_X86) ATOMIC_CMPXCHG(fixed2, shr, kmp_int16, 16, > KMP_ARCH_X86 KMP_ARCH_X86 kmp_uint32
#define K_DIAG(d, x)
Definition kmp_debug.h:163
#define KMP_ASSERT(cond)
Definition kmp_debug.h:59
#define KMP_DEBUG_ASSERT(cond)
Definition kmp_debug.h:61
#define KMP_ASSERT2(cond, msg)
Definition kmp_debug.h:60
unsigned long long kmp_uint64
kmp_hier_sched_env_t __kmp_hier_scheds
kmp_hier_layer_e
@ LAYER_THREAD
@ LAYER_NUMA
@ LAYER_L1
@ LAYER_L2
@ LAYER_L3
int __kmp_dispatch_hand_threading
char const * __kmp_env_blk_var(kmp_env_blk_t *block, char const *name)
void __kmp_env_blk_sort(kmp_env_blk_t *block)
void __kmp_env_blk_init(kmp_env_blk_t *block, char const *bulk)
void __kmp_env_blk_free(kmp_env_blk_t *block)
struct __kmp_env_blk kmp_env_blk_t
kmp_msg_t __kmp_msg_null
Definition kmp_i18n.cpp:36
static void __kmp_msg(kmp_msg_severity_t severity, kmp_msg_t message, va_list ap)
Definition kmp_i18n.cpp:787
kmp_msg_t __kmp_msg_format(unsigned id_arg,...)
Definition kmp_i18n.cpp:624
#define KMP_INFORM(...)
Definition kmp_i18n.h:142
#define KMP_WARNING(...)
Definition kmp_i18n.h:144
#define KMP_MSG(...)
Definition kmp_i18n.h:121
struct kmp_msg kmp_msg_t
Definition kmp_i18n.h:108
@ kmp_ms_warning
Definition kmp_i18n.h:130
#define KMP_I18N_STR(id)
Definition kmp_i18n.h:46
#define KMP_FATAL(...)
Definition kmp_i18n.h:146
#define KMP_HNT(...)
Definition kmp_i18n.h:122
void __kmp_printf(char const *format,...)
Definition kmp_io.cpp:186
kmp_backoff_t __kmp_spin_backoff_params
enum kmp_lock_kind __kmp_user_lock_kind
void __kmp_set_user_lock_vptrs(kmp_lock_kind_t user_lock_kind)
int __kmp_num_locks_in_block
@ lk_default
Definition kmp_lock.h:587
@ lk_ticket
Definition kmp_lock.h:597
@ lk_drdpa
Definition kmp_lock.h:599
@ lk_queuing
Definition kmp_lock.h:598
@ lk_tas
Definition kmp_lock.h:588
#define KMP_SIZE_T_MAX
Definition kmp_os.h:196
#define KMP_BUILTIN_UNREACHABLE
Definition kmp_os.h:1321
@ kmp_warnings_off
Definition kmp_os.h:1245
@ kmp_warnings_explicit
Definition kmp_os.h:1247
#define RCAST(type, var)
Definition kmp_os.h:294
#define CACHE_LINE
Definition kmp_os.h:342
#define KMP_INT_MAX
Definition kmp_os.h:218
#define CCAST(type, var)
Definition kmp_os.h:293
#define KMP_MB()
Definition kmp_os.h:1070
#define TCR_4(a)
Definition kmp_os.h:1141
#define KMP_ALLOCA
#define KMP_STRNCPY_S(dst, bsz, src, cnt)
#define KMP_STRCPY_S(dst, bsz, src)
#define KMP_SSCANF
#define KMP_MEMCPY
#define KMP_MEMCPY_S(dst, bsz, src, cnt)
static void __kmp_strncpy_truncate(char *buffer, size_t buf_size, char const *src, size_t src_size)
#define KMP_STRLEN
static void __kmp_stg_parse_nteams(char const *name, char const *value, void *data)
static void __kmp_stg_print_cpuinfo_file(kmp_str_buf_t *buffer, char const *name, void *data)
static kmp_setting_t __kmp_stg_table[]
static void __kmp_stg_parse_max_active_levels(char const *name, char const *value, void *data)
static const char * __kmp_parse_single_omp_schedule(const char *name, const char *value, bool parse_hier=false)
static void __kmp_stg_parse_nested(char const *name, char const *value, void *data)
static void __kmp_stg_print_barrier_pattern(kmp_str_buf_t *buffer, char const *name, void *data)
static void __kmp_stg_parse_gtid_mode(char const *name, char const *value, void *data)
static void __kmp_stg_print_force_reduction(kmp_str_buf_t *buffer, char const *name, void *data)
static void __kmp_stg_print_warnings(kmp_str_buf_t *buffer, char const *name, void *data)
void __kmp_env_print_2()
#define KMP_STORE_LOCK_SEQ(a)
static char const * blocktime_str
static void __kmp_stg_print_max_task_priority(kmp_str_buf_t *buffer, char const *name, void *data)
static void __kmp_stg_print_use_yield(kmp_str_buf_t *buffer, char const *name, void *data)
#define IS_POWER_OF_TWO(n)
static void __kmp_stg_print_taskloop_min_tasks(kmp_str_buf_t *buffer, char const *name, void *data)
static void __kmp_stg_print_wait_policy(kmp_str_buf_t *buffer, char const *name, void *data)
static void __kmp_stg_parse_align_alloc(char const *name, char const *value, void *data)
static void __kmp_stg_parse_init_at_fork(char const *name, char const *value, void *data)
static void __kmp_stg_print_affinity_format(kmp_str_buf_t *buffer, char const *name, void *data)
struct __kmp_stg_wp_data kmp_stg_wp_data_t
static void __kmp_stg_parse_lock_block(char const *name, char const *value, void *data)
static void __kmp_stg_parse_stackpad(char const *name, char const *value, void *data)
static void __kmp_stg_parse_target_offload(char const *name, char const *value, void *data)
static void __kmp_stg_parse_kmp_dynamic_mode(char const *name, char const *value, void *data)
static void __kmp_stg_parse_affinity_format(char const *name, char const *value, void *data)
#define SKIP_PAIR(key)
static void __kmp_stg_parse_omp_schedule(char const *name, char const *value, void *data)
static void __kmp_stg_parse_num_threads(char const *name, char const *value, void *data)
static void __kmp_stg_print_settings(kmp_str_buf_t *buffer, char const *name, void *data)
static void __kmp_stg_parse_teams_th_limit(char const *name, char const *value, void *data)
static void __kmp_stg_parse_use_yield(char const *name, char const *value, void *data)
static void __kmp_stg_parse_schedule(char const *name, char const *value, void *data)
static void __kmp_stg_print_proc_bind(kmp_str_buf_t *buffer, char const *name, void *data)
static void __kmp_stg_parse_omp_display_env(char const *name, char const *value, void *data)
static void __kmp_stg_parse_duplicate_lib_ok(char const *name, char const *value, void *data)
static kmp_hw_t __kmp_hw_subset_break_tie(const kmp_hw_t *possible, size_t num_possible)
static void __kmp_stg_print_storage_map(kmp_str_buf_t *buffer, char const *name, void *data)
static void __kmp_stg_parse_kmp_force_monotonic(char const *name, char const *value, void *data)
static void __kmp_stg_print_align_alloc(kmp_str_buf_t *buffer, char const *name, void *data)
static void __kmp_stg_print_display_affinity(kmp_str_buf_t *buffer, char const *name, void *data)
static void __kmp_stg_parse_consistency_check(char const *name, char const *value, void *data)
static void __kmp_stg_print_num_hidden_helper_threads(kmp_str_buf_t *buffer, char const *name, void *data)
int __kmp_default_tp_capacity(int req_nproc, int max_nth, int all_threads_specified)
static void __kmp_stg_print_all_threadprivate(kmp_str_buf_t *buffer, char const *name, void *data)
static void __kmp_stg_print_omp_display_env(kmp_str_buf_t *buffer, char const *name, void *data)
void(* kmp_stg_parse_func_t)(char const *name, char const *value, void *data)
static void __kmp_stg_print_version(kmp_str_buf_t *buffer, char const *name, void *data)
static void __kmp_stg_print_task_throttling(kmp_str_buf_t *buffer, char const *name, void *data)
static int const __kmp_stg_count
static void __kmp_stg_parse_allocator(char const *name, char const *value, void *data)
int __kmp_initial_threads_capacity(int req_nproc)
static void __kmp_stg_print_uint64(kmp_str_buf_t *buffer, char const *name, kmp_uint64 value)
static void __kmp_stg_print_use_hidden_helper(kmp_str_buf_t *buffer, char const *name, void *data)
static void __kmp_stg_parse_stacksize(char const *name, char const *value, void *data)
static void __kmp_stg_parse_abort_delay(char const *name, char const *value, void *data)
static void __kmp_stg_parse_device_thread_limit(char const *name, char const *value, void *data)
static void __kmp_stg_parse_storage_map(char const *name, char const *value, void *data)
static int __kmp_strcasecmp_with_sentinel(char const *a, char const *b, char sentinel)
static void __kmp_stg_parse_all_threadprivate(char const *name, char const *value, void *data)
static void __kmp_stg_parse_omp_cancellation(char const *name, char const *value, void *data)
static void __kmp_stg_parse_lock_kind(char const *name, char const *value, void *data)
static void __kmp_stg_print_omp_cancellation(kmp_str_buf_t *buffer, char const *name, void *data)
static void __kmp_stg_print_abort_delay(kmp_str_buf_t *buffer, char const *name, void *data)
static void __kmp_stg_parse_hw_subset(char const *name, char const *value, void *data)
void __kmp_check_stksize(size_t *val)
struct __kmp_stg_ss_data kmp_stg_ss_data_t
static void __kmp_stg_parse_proc_bind(char const *name, char const *value, void *data)
static void __kmp_stg_print_stacksize(kmp_str_buf_t *buffer, char const *name, void *data)
static void __kmp_stg_parse_size(char const *name, char const *value, size_t size_min, size_t size_max, int *is_specified, size_t *out, size_t factor)
struct __kmp_stg_fr_data kmp_stg_fr_data_t
static void __kmp_stg_parse_omp_dynamic(char const *name, char const *value, void *data)
#define MAX_STR_LEN
static void __kmp_stg_print_atomic_mode(kmp_str_buf_t *buffer, char const *name, void *data)
static void __kmp_stg_parse_version(char const *name, char const *value, void *data)
static void __kmp_stg_print_bool(kmp_str_buf_t *buffer, char const *name, int value)
static void __kmp_stg_print_int(kmp_str_buf_t *buffer, char const *name, int value)
static void __kmp_stg_parse_disp_buffers(char const *name, char const *value, void *data)
static void __kmp_stg_print_allocator(kmp_str_buf_t *buffer, char const *name, void *data)
static void __kmp_stg_parse_task_throttling(char const *name, char const *value, void *data)
static void __kmp_stg_print_thread_limit(kmp_str_buf_t *buffer, char const *name, void *data)
static void __kmp_stg_print_hot_teams_level(kmp_str_buf_t *buffer, char const *name, void *data)
#define SET_KEY()
static void __kmp_stg_print_teams_th_limit(kmp_str_buf_t *buffer, char const *name, void *data)
void __kmp_env_initialize(char const *string)
static void __kmp_stg_parse_task_stealing(char const *name, char const *value, void *data)
static void __kmp_stg_print_stackoffset(kmp_str_buf_t *buffer, char const *name, void *data)
struct __kmp_setting kmp_setting_t
static void __kmp_stg_print_schedule(kmp_str_buf_t *buffer, char const *name, void *data)
static void __kmp_stg_print_malloc_pool_incr(kmp_str_buf_t *buffer, char const *name, void *data)
static void __kmp_stg_print_nested(kmp_str_buf_t *buffer, char const *name, void *data)
static void __kmp_stg_parse_taskloop_min_tasks(char const *name, char const *value, void *data)
static void __kmp_stg_print_omp_dynamic(kmp_str_buf_t *buffer, char const *name, void *data)
static void __kmp_stg_parse_hot_teams_level(char const *name, char const *value, void *data)
static char const * use_yield_str
static void __kmp_stg_print_hw_subset(kmp_str_buf_t *buffer, char const *name, void *data)
static void __kmp_stg_print_str(kmp_str_buf_t *buffer, char const *name, char const *value)
void __kmp_display_env_impl(int display_env, int display_env_verbose)
static void __kmp_stg_print_num_threads(kmp_str_buf_t *buffer, char const *name, void *data)
static void __kmp_stg_parse_nesting_mode(char const *name, char const *value, void *data)
static int __kmp_match_str(char const *token, char const *buf, const char **end)
static void __kmp_stg_print_spin_backoff_params(kmp_str_buf_t *buffer, char const *name, void *data)
static void __kmp_stg_print_lock_kind(kmp_str_buf_t *buffer, char const *name, void *data)
static void __kmp_stg_parse_wait_policy(char const *name, char const *value, void *data)
static void __kmp_stg_print_hot_teams_mode(kmp_str_buf_t *buffer, char const *name, void *data)
static void __kmp_stg_print_lock_block(kmp_str_buf_t *buffer, char const *name, void *data)
static void __kmp_stg_print_default_device(kmp_str_buf_t *buffer, char const *name, void *data)
static void __kmp_aux_env_initialize(kmp_env_blk_t *block)
static void __kmp_stg_print_duplicate_lib_ok(kmp_str_buf_t *buffer, char const *name, void *data)
static void __kmp_stg_print_foreign_threads_threadprivate(kmp_str_buf_t *buffer, char const *name, void *data)
static void __kmp_stg_print_kmp_dynamic_mode(kmp_str_buf_t *buffer, char const *name, void *data)
static void __kmp_stg_parse_spin_backoff_params(const char *name, const char *value, void *data)
static void __kmp_stg_print_barrier_branch_bit(kmp_str_buf_t *buffer, char const *name, void *data)
static void __kmp_stg_parse_num_hidden_helper_threads(char const *name, char const *value, void *data)
static void __kmp_stg_print_disp_buffers(kmp_str_buf_t *buffer, char const *name, void *data)
static void __kmp_stg_print_target_offload(kmp_str_buf_t *buffer, char const *name, void *data)
static void __kmp_stg_parse_blocktime(char const *name, char const *value, void *data)
static void __kmp_stg_print_nesting_mode(kmp_str_buf_t *buffer, char const *name, void *data)
static void __kmp_stg_print_consistency_check(kmp_str_buf_t *buffer, char const *name, void *data)
static void __kmp_stg_init(void)
static void __kmp_stg_parse_teams_thread_limit(char const *name, char const *value, void *data)
static void __kmp_stg_print_task_stealing(kmp_str_buf_t *buffer, char const *name, void *data)
static void __kmp_parse_nested_num_threads(const char *var, const char *env, kmp_nested_nthreads_t *nth_array)
static void __kmp_stg_parse_atomic_mode(char const *name, char const *value, void *data)
static void __kmp_stg_parse_max_task_priority(char const *name, char const *value, void *data)
static void __kmp_stg_print_init_at_fork(kmp_str_buf_t *buffer, char const *name, void *data)
void(* kmp_stg_print_func_t)(kmp_str_buf_t *buffer, char const *name, void *data)
bool __kmp_env_format
static void __kmp_stg_print_tasking(kmp_str_buf_t *buffer, char const *name, void *data)
static kmp_setting_t * __kmp_stg_find(char const *name)
#define GET_NEXT(sentinel)
static int __kmp_stg_cmp(void const *_a, void const *_b)
static void __kmp_stg_print_kmp_force_monotonic(kmp_str_buf_t *buffer, char const *name, void *data)
static void __kmp_stg_print_gtid_mode(kmp_str_buf_t *buffer, char const *name, void *data)
static int __kmp_match_with_sentinel(char const *a, char const *b, size_t len, char sentinel)
static void __kmp_stg_parse_foreign_threads_threadprivate(char const *name, char const *value, void *data)
static void __kmp_stg_parse_str(char const *name, char const *value, char **out)
static void __kmp_stg_parse_display_affinity(char const *name, char const *value, void *data)
static void __kmp_stg_parse_malloc_pool_incr(char const *name, char const *value, void *data)
static void __kmp_stg_parse_hot_teams_mode(char const *name, char const *value, void *data)
static void __kmp_stg_parse_bool(char const *name, char const *value, int *out)
static void __kmp_stg_parse_stackoffset(char const *name, char const *value, void *data)
static void __kmp_stg_parse_tasking(char const *name, char const *value, void *data)
static void __kmp_stg_print_omp_schedule(kmp_str_buf_t *buffer, char const *name, void *data)
static void __kmp_stg_print_teams_thread_limit(kmp_str_buf_t *buffer, char const *name, void *data)
static void __kmp_stg_print_stackpad(kmp_str_buf_t *buffer, char const *name, void *data)
static void __kmp_stg_parse_barrier_pattern(char const *name, char const *value, void *data)
#define MAX_T_LEVEL
static void __kmp_stg_parse_settings(char const *name, char const *value, void *data)
static void __kmp_stg_parse_cpuinfo_file(char const *name, char const *value, void *data)
static int __kmp_stg_check_rivals(char const *name, char const *value, kmp_setting_t **rivals)
static void __kmp_stg_parse_thread_limit(char const *name, char const *value, void *data)
static void __kmp_stg_print_blocktime(kmp_str_buf_t *buffer, char const *name, void *data)
static void __kmp_stg_print_nteams(kmp_str_buf_t *buffer, char const *name, void *data)
static kmp_hw_t __kmp_stg_parse_hw_subset_name(char const *token)
static void __kmp_stg_print_size(kmp_str_buf_t *buffer, char const *name, size_t value)
static void __kmp_stg_parse_int(char const *name, char const *value, int min, int max, int *out)
static void __kmp_stg_parse(char const *name, char const *value)
static int __kmp_env_toPrint(char const *name, int flag)
static void __kmp_omp_schedule_restore()
static void __kmp_stg_print_device_thread_limit(kmp_str_buf_t *buffer, char const *name, void *data)
static void __kmp_stg_parse_barrier_branch_bit(char const *name, char const *value, void *data)
static void __kmp_stg_parse_force_reduction(char const *name, char const *value, void *data)
static void __kmp_stg_parse_default_device(char const *name, char const *value, void *data)
static void __kmp_stg_print_max_active_levels(kmp_str_buf_t *buffer, char const *name, void *data)
static const char * __kmp_hw_get_core_type_keyword(kmp_hw_core_type_t type)
static void __kmp_stg_parse_use_hidden_helper(char const *name, char const *value, void *data)
static void __kmp_stg_parse_warnings(char const *name, char const *value, void *data)
void __kmp_env_print()
#define KMP_STR_BUF_PRINT_BOOL_EX(n, v, t, f)
#define KMP_STR_BUF_PRINT_NAME
#define KMP_STR_BUF_PRINT_STR
#define KMP_STR_BUF_PRINT_UINT64
#define KMP_STR_BUF_PRINT_BOOL
#define KMP_STR_BUF_PRINT_NAME_EX(x)
#define KMP_STR_BUF_PRINT_INT
int __kmp_str_to_int(char const *str, char sentinel)
Definition kmp_str.cpp:642
void __kmp_str_to_uint(char const *str, kmp_uint64 *out, char const **error)
Definition kmp_str.cpp:807
void __kmp_str_to_size(char const *str, size_t *out, size_t dfactor, char const **error)
Definition kmp_str.cpp:706
void __kmp_str_buf_clear(kmp_str_buf_t *buffer)
Definition kmp_str.cpp:71
int __kmp_str_eqf(char const *lhs, char const *rhs)
Definition kmp_str.cpp:404
int __kmp_str_match(char const *target, int len, char const *data)
Definition kmp_str.cpp:505
int __kmp_basic_str_to_int(char const *str, size_t maxlen)
Definition kmp_str.cpp:622
void __kmp_str_buf_free(kmp_str_buf_t *buffer)
Definition kmp_str.cpp:123
char * __kmp_str_format(char const *format,...)
Definition kmp_str.cpp:448
int __kmp_str_match_true(char const *data)
Definition kmp_str.cpp:552
void __kmp_str_buf_cat(kmp_str_buf_t *buffer, char const *str, size_t len)
Definition kmp_str.cpp:134
int __kmp_str_buf_print(kmp_str_buf_t *buffer, char const *format,...)
Definition kmp_str.cpp:221
int __kmp_str_match_false(char const *data)
Definition kmp_str.cpp:543
void __kmp_str_free(char **str)
Definition kmp_str.cpp:494
void __kmp_str_buf_print_size(kmp_str_buf_t *buf, size_t size)
Definition kmp_str.cpp:232
struct kmp_str_buf kmp_str_buf_t
Definition kmp_str.h:39
#define __kmp_str_buf_init(b)
Definition kmp_str.h:41
#define i
Definition kmp_stub.cpp:87
int const __kmp_openmp_version
int a
dest
Definition check.py:82
volatile int flag
#define delay(t)
Definition ompt-signal.h:6
kmp_env_var_t * vars
kmp_stg_print_func_t print
kmp_stg_parse_func_t parse
char const * name
kmp_setting_t ** rivals
kmp_setting_t ** rivals
kmp_setting_t ** rivals
void set_core_type(kmp_hw_core_type_t type)
void set_core_eff(int eff)
char * str
Definition kmp_i18n.h:105
char * str
Definition kmp_str.h:34
kmp_str_buf_t buf
const char * get()
kmp_trimmed_str_t(const char *str)
omp_alloctrait_key_t key
Definition kmp.h:1069
omp_uintptr_t value
Definition kmp.h:1070
static int err