14 #include "kmp_affinity.h"
15 #include "kmp_atomic.h"
16 #if KMP_USE_HIER_SCHED
17 #include "kmp_dispatch_hier.h"
19 #include "kmp_environment.h"
24 #include "kmp_settings.h"
26 #include "kmp_wrapper_getpid.h"
29 static int __kmp_env_toPrint(
char const *name,
int flag);
31 bool __kmp_env_format = 0;
36 #ifdef USE_LOAD_BALANCE
37 static double __kmp_convert_to_double(
char const *s) {
40 if (KMP_SSCANF(s,
"%lf", &result) < 1) {
49 static unsigned int __kmp_readstr_with_sentinel(
char *dest,
char const *src,
50 size_t len,
char sentinel) {
52 for (i = 0; i < len; i++) {
53 if ((*src ==
'\0') || (*src == sentinel)) {
63 static int __kmp_match_with_sentinel(
char const *a,
char const *b,
size_t len,
71 while (*a && *b && *b != sentinel) {
72 char ca = *a, cb = *b;
74 if (ca >=
'a' && ca <=
'z')
76 if (cb >=
'a' && cb <=
'z')
110 static int __kmp_match_str(
char const *token,
char const *buf,
113 KMP_ASSERT(token != NULL);
114 KMP_ASSERT(buf != NULL);
115 KMP_ASSERT(end != NULL);
117 while (*token && *buf) {
118 char ct = *token, cb = *buf;
120 if (ct >=
'a' && ct <=
'z')
122 if (cb >=
'a' && cb <=
'z')
137 static size_t __kmp_round4k(
size_t size) {
138 size_t _4k = 4 * 1024;
139 if (size & (_4k - 1)) {
141 if (size <= KMP_SIZE_T_MAX - _4k) {
153 int __kmp_convert_to_milliseconds(
char const *data) {
154 int ret, nvalues, factor;
160 if (__kmp_str_match(
"infinit", -1, data))
164 nvalues = KMP_SSCANF(data,
"%lf%c%c", &value, &mult, &extra);
190 factor = 1000 * 60 * 60;
194 factor = 1000 * 24 * 60 * 60;
200 if (value >= ((INT_MAX - 1) / factor))
203 ret = (int)(value * (
double)factor);
208 static int __kmp_strcasecmp_with_sentinel(
char const *a,
char const *b,
214 while (*a && *b && *b != sentinel) {
215 char ca = *a, cb = *b;
217 if (ca >=
'a' && ca <=
'z')
219 if (cb >=
'a' && cb <=
'z')
222 return (
int)(
unsigned char)*a - (
int)(
unsigned char)*b;
227 ? (*b && *b != sentinel)
228 ? (
int)(
unsigned char)*a - (
int)(
unsigned char)*b
230 : (*b && *b != sentinel) ? -1 : 0;
236 typedef struct __kmp_setting kmp_setting_t;
237 typedef struct __kmp_stg_ss_data kmp_stg_ss_data_t;
238 typedef struct __kmp_stg_wp_data kmp_stg_wp_data_t;
239 typedef struct __kmp_stg_fr_data kmp_stg_fr_data_t;
241 typedef void (*kmp_stg_parse_func_t)(
char const *name,
char const *value,
243 typedef void (*kmp_stg_print_func_t)(kmp_str_buf_t *buffer,
char const *name,
246 struct __kmp_setting {
248 kmp_stg_parse_func_t parse;
249 kmp_stg_print_func_t print;
256 struct __kmp_stg_ss_data {
258 kmp_setting_t **rivals;
261 struct __kmp_stg_wp_data {
263 kmp_setting_t **rivals;
266 struct __kmp_stg_fr_data {
268 kmp_setting_t **rivals;
271 static int __kmp_stg_check_rivals(
274 kmp_setting_t **rivals
280 static void __kmp_stg_parse_bool(
char const *name,
char const *value,
282 if (__kmp_str_match_true(value)) {
284 }
else if (__kmp_str_match_false(value)) {
287 __kmp_msg(kmp_ms_warning, KMP_MSG(BadBoolValue, name, value),
288 KMP_HNT(ValidBoolValues), __kmp_msg_null);
293 void __kmp_check_stksize(
size_t *val) {
295 if (*val > KMP_DEFAULT_STKSIZE * 16)
296 *val = KMP_DEFAULT_STKSIZE * 16;
297 if (*val < KMP_MIN_STKSIZE)
298 *val = KMP_MIN_STKSIZE;
299 if (*val > KMP_MAX_STKSIZE)
300 *val = KMP_MAX_STKSIZE;
302 *val = __kmp_round4k(*val);
306 static void __kmp_stg_parse_size(
char const *name,
char const *value,
307 size_t size_min,
size_t size_max,
308 int *is_specified,
size_t *out,
310 char const *msg = NULL;
312 size_min = __kmp_round4k(size_min);
313 size_max = __kmp_round4k(size_max);
316 if (is_specified != NULL) {
319 __kmp_str_to_size(value, out, factor, &msg);
321 if (*out > size_max) {
323 msg = KMP_I18N_STR(ValueTooLarge);
324 }
else if (*out < size_min) {
326 msg = KMP_I18N_STR(ValueTooSmall);
329 size_t round4k = __kmp_round4k(*out);
330 if (*out != round4k) {
332 msg = KMP_I18N_STR(NotMultiple4K);
339 if (*out < size_min) {
341 }
else if (*out > size_max) {
348 __kmp_str_buf_init(&buf);
349 __kmp_str_buf_print_size(&buf, *out);
350 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
351 KMP_INFORM(Using_str_Value, name, buf.str);
352 __kmp_str_buf_free(&buf);
357 static void __kmp_stg_parse_str(
char const *name,
char const *value,
360 *out = __kmp_str_format(
"%s", value);
363 static void __kmp_stg_parse_int(
371 char const *msg = NULL;
372 kmp_uint64 uint = *out;
373 __kmp_str_to_uint(value, &uint, &msg);
375 if (uint < (
unsigned int)min) {
376 msg = KMP_I18N_STR(ValueTooSmall);
378 }
else if (uint > (
unsigned int)max) {
379 msg = KMP_I18N_STR(ValueTooLarge);
385 if (uint < (
unsigned int)min) {
387 }
else if (uint > (
unsigned int)max) {
394 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
395 __kmp_str_buf_init(&buf);
396 __kmp_str_buf_print(&buf,
"%" KMP_UINT64_SPEC
"", uint);
397 KMP_INFORM(Using_uint64_Value, name, buf.str);
398 __kmp_str_buf_free(&buf);
400 __kmp_type_convert(uint, out);
403 #if KMP_DEBUG_ADAPTIVE_LOCKS
404 static void __kmp_stg_parse_file(
char const *name,
char const *value,
405 const char *suffix,
char **out) {
410 t = (
char *)strrchr(value,
'.');
411 hasSuffix = t && __kmp_str_eqf(t, suffix);
412 t = __kmp_str_format(
"%s%s", value, hasSuffix ?
"" : suffix);
413 __kmp_expand_file_name(buffer,
sizeof(buffer), t);
415 *out = __kmp_str_format(
"%s", buffer);
420 static char *par_range_to_print = NULL;
422 static void __kmp_stg_parse_par_range(
char const *name,
char const *value,
423 int *out_range,
char *out_routine,
424 char *out_file,
int *out_lb,
426 size_t len = KMP_STRLEN(value) + 1;
427 par_range_to_print = (
char *)KMP_INTERNAL_MALLOC(len + 1);
428 KMP_STRNCPY_S(par_range_to_print, len + 1, value, len + 1);
429 __kmp_par_range = +1;
430 __kmp_par_range_lb = 0;
431 __kmp_par_range_ub = INT_MAX;
434 if (*value ==
'\0') {
437 if (!__kmp_strcasecmp_with_sentinel(
"routine", value,
'=')) {
438 value = strchr(value,
'=') + 1;
439 len = __kmp_readstr_with_sentinel(out_routine, value,
440 KMP_PAR_RANGE_ROUTINE_LEN - 1,
',');
442 goto par_range_error;
444 value = strchr(value,
',');
450 if (!__kmp_strcasecmp_with_sentinel(
"filename", value,
'=')) {
451 value = strchr(value,
'=') + 1;
452 len = __kmp_readstr_with_sentinel(out_file, value,
453 KMP_PAR_RANGE_FILENAME_LEN - 1,
',');
455 goto par_range_error;
457 value = strchr(value,
',');
463 if ((!__kmp_strcasecmp_with_sentinel(
"range", value,
'=')) ||
464 (!__kmp_strcasecmp_with_sentinel(
"incl_range", value,
'='))) {
465 value = strchr(value,
'=') + 1;
466 if (KMP_SSCANF(value,
"%d:%d", out_lb, out_ub) != 2) {
467 goto par_range_error;
470 value = strchr(value,
',');
476 if (!__kmp_strcasecmp_with_sentinel(
"excl_range", value,
'=')) {
477 value = strchr(value,
'=') + 1;
478 if (KMP_SSCANF(value,
"%d:%d", out_lb, out_ub) != 2) {
479 goto par_range_error;
482 value = strchr(value,
',');
489 KMP_WARNING(ParRangeSyntax, name);
496 int __kmp_initial_threads_capacity(
int req_nproc) {
501 if (nth < (4 * req_nproc))
502 nth = (4 * req_nproc);
503 if (nth < (4 * __kmp_xproc))
504 nth = (4 * __kmp_xproc);
508 if (__kmp_enable_hidden_helper) {
509 nth += __kmp_hidden_helper_threads_num;
512 if (nth > __kmp_max_nth)
518 int __kmp_default_tp_capacity(
int req_nproc,
int max_nth,
519 int all_threads_specified) {
522 if (all_threads_specified)
526 if (nth < (4 * req_nproc))
527 nth = (4 * req_nproc);
528 if (nth < (4 * __kmp_xproc))
529 nth = (4 * __kmp_xproc);
531 if (nth > __kmp_max_nth)
540 static void __kmp_stg_print_bool(kmp_str_buf_t *buffer,
char const *name,
542 if (__kmp_env_format) {
543 KMP_STR_BUF_PRINT_BOOL;
545 __kmp_str_buf_print(buffer,
" %s=%s\n", name, value ?
"true" :
"false");
549 static void __kmp_stg_print_int(kmp_str_buf_t *buffer,
char const *name,
551 if (__kmp_env_format) {
552 KMP_STR_BUF_PRINT_INT;
554 __kmp_str_buf_print(buffer,
" %s=%d\n", name, value);
558 static void __kmp_stg_print_uint64(kmp_str_buf_t *buffer,
char const *name,
560 if (__kmp_env_format) {
561 KMP_STR_BUF_PRINT_UINT64;
563 __kmp_str_buf_print(buffer,
" %s=%" KMP_UINT64_SPEC
"\n", name, value);
567 static void __kmp_stg_print_str(kmp_str_buf_t *buffer,
char const *name,
569 if (__kmp_env_format) {
570 KMP_STR_BUF_PRINT_STR;
572 __kmp_str_buf_print(buffer,
" %s=%s\n", name, value);
576 static void __kmp_stg_print_size(kmp_str_buf_t *buffer,
char const *name,
578 if (__kmp_env_format) {
579 KMP_STR_BUF_PRINT_NAME_EX(name);
580 __kmp_str_buf_print_size(buffer, value);
581 __kmp_str_buf_print(buffer,
"'\n");
583 __kmp_str_buf_print(buffer,
" %s=", name);
584 __kmp_str_buf_print_size(buffer, value);
585 __kmp_str_buf_print(buffer,
"\n");
596 static void __kmp_stg_parse_device_thread_limit(
char const *name,
597 char const *value,
void *data) {
598 kmp_setting_t **rivals = (kmp_setting_t **)data;
600 if (strcmp(name,
"KMP_ALL_THREADS") == 0) {
601 KMP_INFORM(EnvVarDeprecated, name,
"KMP_DEVICE_THREAD_LIMIT");
603 rc = __kmp_stg_check_rivals(name, value, rivals);
607 if (!__kmp_strcasecmp_with_sentinel(
"all", value, 0)) {
608 __kmp_max_nth = __kmp_xproc;
609 __kmp_allThreadsSpecified = 1;
611 __kmp_stg_parse_int(name, value, 1, __kmp_sys_max_nth, &__kmp_max_nth);
612 __kmp_allThreadsSpecified = 0;
614 K_DIAG(1, (
"__kmp_max_nth == %d\n", __kmp_max_nth));
618 static void __kmp_stg_print_device_thread_limit(kmp_str_buf_t *buffer,
619 char const *name,
void *data) {
620 __kmp_stg_print_int(buffer, name, __kmp_max_nth);
625 static void __kmp_stg_parse_thread_limit(
char const *name,
char const *value,
627 __kmp_stg_parse_int(name, value, 1, __kmp_sys_max_nth, &__kmp_cg_max_nth);
628 K_DIAG(1, (
"__kmp_cg_max_nth == %d\n", __kmp_cg_max_nth));
632 static void __kmp_stg_print_thread_limit(kmp_str_buf_t *buffer,
633 char const *name,
void *data) {
634 __kmp_stg_print_int(buffer, name, __kmp_cg_max_nth);
639 static void __kmp_stg_parse_teams_thread_limit(
char const *name,
640 char const *value,
void *data) {
641 __kmp_stg_parse_int(name, value, 1, __kmp_sys_max_nth, &__kmp_teams_max_nth);
644 static void __kmp_stg_print_teams_thread_limit(kmp_str_buf_t *buffer,
645 char const *name,
void *data) {
646 __kmp_stg_print_int(buffer, name, __kmp_teams_max_nth);
651 static void __kmp_stg_parse_use_yield(
char const *name,
char const *value,
653 __kmp_stg_parse_int(name, value, 0, 2, &__kmp_use_yield);
654 __kmp_use_yield_exp_set = 1;
657 static void __kmp_stg_print_use_yield(kmp_str_buf_t *buffer,
char const *name,
659 __kmp_stg_print_int(buffer, name, __kmp_use_yield);
665 static void __kmp_stg_parse_blocktime(
char const *name,
char const *value,
667 __kmp_dflt_blocktime = __kmp_convert_to_milliseconds(value);
668 if (__kmp_dflt_blocktime < 0) {
669 __kmp_dflt_blocktime = KMP_DEFAULT_BLOCKTIME;
670 __kmp_msg(kmp_ms_warning, KMP_MSG(InvalidValue, name, value),
672 KMP_INFORM(Using_int_Value, name, __kmp_dflt_blocktime);
673 __kmp_env_blocktime = FALSE;
675 if (__kmp_dflt_blocktime < KMP_MIN_BLOCKTIME) {
676 __kmp_dflt_blocktime = KMP_MIN_BLOCKTIME;
677 __kmp_msg(kmp_ms_warning, KMP_MSG(SmallValue, name, value),
679 KMP_INFORM(MinValueUsing, name, __kmp_dflt_blocktime);
680 }
else if (__kmp_dflt_blocktime > KMP_MAX_BLOCKTIME) {
681 __kmp_dflt_blocktime = KMP_MAX_BLOCKTIME;
682 __kmp_msg(kmp_ms_warning, KMP_MSG(LargeValue, name, value),
684 KMP_INFORM(MaxValueUsing, name, __kmp_dflt_blocktime);
686 __kmp_env_blocktime = TRUE;
691 __kmp_monitor_wakeups =
692 KMP_WAKEUPS_FROM_BLOCKTIME(__kmp_dflt_blocktime, __kmp_monitor_wakeups);
694 KMP_INTERVALS_FROM_BLOCKTIME(__kmp_dflt_blocktime, __kmp_monitor_wakeups);
696 K_DIAG(1, (
"__kmp_env_blocktime == %d\n", __kmp_env_blocktime));
697 if (__kmp_env_blocktime) {
698 K_DIAG(1, (
"__kmp_dflt_blocktime == %d\n", __kmp_dflt_blocktime));
702 static void __kmp_stg_print_blocktime(kmp_str_buf_t *buffer,
char const *name,
704 __kmp_stg_print_int(buffer, name, __kmp_dflt_blocktime);
710 static void __kmp_stg_parse_duplicate_lib_ok(
char const *name,
711 char const *value,
void *data) {
714 __kmp_stg_parse_bool(name, value, &__kmp_duplicate_library_ok);
717 static void __kmp_stg_print_duplicate_lib_ok(kmp_str_buf_t *buffer,
718 char const *name,
void *data) {
719 __kmp_stg_print_bool(buffer, name, __kmp_duplicate_library_ok);
725 #if KMP_ARCH_X86 || KMP_ARCH_X86_64
727 static void __kmp_stg_parse_inherit_fp_control(
char const *name,
728 char const *value,
void *data) {
729 __kmp_stg_parse_bool(name, value, &__kmp_inherit_fp_control);
732 static void __kmp_stg_print_inherit_fp_control(kmp_str_buf_t *buffer,
733 char const *name,
void *data) {
735 __kmp_stg_print_bool(buffer, name, __kmp_inherit_fp_control);
742 static char const *blocktime_str = NULL;
747 static void __kmp_stg_parse_wait_policy(
char const *name,
char const *value,
750 kmp_stg_wp_data_t *wait = (kmp_stg_wp_data_t *)data;
753 rc = __kmp_stg_check_rivals(name, value, wait->rivals);
759 if (__kmp_str_match(
"ACTIVE", 1, value)) {
760 __kmp_library = library_turnaround;
761 if (blocktime_str == NULL) {
763 __kmp_dflt_blocktime = KMP_MAX_BLOCKTIME;
765 }
else if (__kmp_str_match(
"PASSIVE", 1, value)) {
766 __kmp_library = library_throughput;
767 if (blocktime_str == NULL) {
769 __kmp_dflt_blocktime = 0;
772 KMP_WARNING(StgInvalidValue, name, value);
775 if (__kmp_str_match(
"serial", 1, value)) {
776 __kmp_library = library_serial;
777 }
else if (__kmp_str_match(
"throughput", 2, value)) {
778 __kmp_library = library_throughput;
779 if (blocktime_str == NULL) {
781 __kmp_dflt_blocktime = 0;
783 }
else if (__kmp_str_match(
"turnaround", 2, value)) {
784 __kmp_library = library_turnaround;
785 }
else if (__kmp_str_match(
"dedicated", 1, value)) {
786 __kmp_library = library_turnaround;
787 }
else if (__kmp_str_match(
"multiuser", 1, value)) {
788 __kmp_library = library_throughput;
789 if (blocktime_str == NULL) {
791 __kmp_dflt_blocktime = 0;
794 KMP_WARNING(StgInvalidValue, name, value);
799 static void __kmp_stg_print_wait_policy(kmp_str_buf_t *buffer,
char const *name,
802 kmp_stg_wp_data_t *wait = (kmp_stg_wp_data_t *)data;
803 char const *value = NULL;
806 switch (__kmp_library) {
807 case library_turnaround: {
810 case library_throughput: {
815 switch (__kmp_library) {
816 case library_serial: {
819 case library_turnaround: {
820 value =
"turnaround";
822 case library_throughput: {
823 value =
"throughput";
828 __kmp_stg_print_str(buffer, name, value);
837 static void __kmp_stg_parse_monitor_stacksize(
char const *name,
838 char const *value,
void *data) {
839 __kmp_stg_parse_size(name, value, __kmp_sys_min_stksize, KMP_MAX_STKSIZE,
840 NULL, &__kmp_monitor_stksize, 1);
843 static void __kmp_stg_print_monitor_stacksize(kmp_str_buf_t *buffer,
844 char const *name,
void *data) {
845 if (__kmp_env_format) {
846 if (__kmp_monitor_stksize > 0)
847 KMP_STR_BUF_PRINT_NAME_EX(name);
849 KMP_STR_BUF_PRINT_NAME;
851 __kmp_str_buf_print(buffer,
" %s", name);
853 if (__kmp_monitor_stksize > 0) {
854 __kmp_str_buf_print_size(buffer, __kmp_monitor_stksize);
856 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
858 if (__kmp_env_format && __kmp_monitor_stksize) {
859 __kmp_str_buf_print(buffer,
"'\n");
867 static void __kmp_stg_parse_settings(
char const *name,
char const *value,
869 __kmp_stg_parse_bool(name, value, &__kmp_settings);
872 static void __kmp_stg_print_settings(kmp_str_buf_t *buffer,
char const *name,
874 __kmp_stg_print_bool(buffer, name, __kmp_settings);
880 static void __kmp_stg_parse_stackpad(
char const *name,
char const *value,
882 __kmp_stg_parse_int(name,
890 static void __kmp_stg_print_stackpad(kmp_str_buf_t *buffer,
char const *name,
892 __kmp_stg_print_int(buffer, name, __kmp_stkpadding);
898 static void __kmp_stg_parse_stackoffset(
char const *name,
char const *value,
900 __kmp_stg_parse_size(name,
909 static void __kmp_stg_print_stackoffset(kmp_str_buf_t *buffer,
char const *name,
911 __kmp_stg_print_size(buffer, name, __kmp_stkoffset);
917 static void __kmp_stg_parse_stacksize(
char const *name,
char const *value,
920 kmp_stg_ss_data_t *stacksize = (kmp_stg_ss_data_t *)data;
923 rc = __kmp_stg_check_rivals(name, value, stacksize->rivals);
927 __kmp_stg_parse_size(name,
929 __kmp_sys_min_stksize,
941 static void __kmp_stg_print_stacksize(kmp_str_buf_t *buffer,
char const *name,
943 kmp_stg_ss_data_t *stacksize = (kmp_stg_ss_data_t *)data;
944 if (__kmp_env_format) {
945 KMP_STR_BUF_PRINT_NAME_EX(name);
946 __kmp_str_buf_print_size(buffer, (__kmp_stksize % 1024)
947 ? __kmp_stksize / stacksize->factor
949 __kmp_str_buf_print(buffer,
"'\n");
951 __kmp_str_buf_print(buffer,
" %s=", name);
952 __kmp_str_buf_print_size(buffer, (__kmp_stksize % 1024)
953 ? __kmp_stksize / stacksize->factor
955 __kmp_str_buf_print(buffer,
"\n");
962 static void __kmp_stg_parse_version(
char const *name,
char const *value,
964 __kmp_stg_parse_bool(name, value, &__kmp_version);
967 static void __kmp_stg_print_version(kmp_str_buf_t *buffer,
char const *name,
969 __kmp_stg_print_bool(buffer, name, __kmp_version);
975 static void __kmp_stg_parse_warnings(
char const *name,
char const *value,
977 __kmp_stg_parse_bool(name, value, &__kmp_generate_warnings);
978 if (__kmp_generate_warnings != kmp_warnings_off) {
981 __kmp_generate_warnings = kmp_warnings_explicit;
985 static void __kmp_stg_print_warnings(kmp_str_buf_t *buffer,
char const *name,
988 __kmp_stg_print_bool(buffer, name, __kmp_generate_warnings);
994 static void __kmp_stg_parse_nested(
char const *name,
char const *value,
997 KMP_INFORM(EnvVarDeprecated, name,
"OMP_MAX_ACTIVE_LEVELS");
998 __kmp_stg_parse_bool(name, value, &nested);
1000 if (!__kmp_dflt_max_active_levels_set)
1001 __kmp_dflt_max_active_levels = KMP_MAX_ACTIVE_LEVELS_LIMIT;
1003 __kmp_dflt_max_active_levels = 1;
1004 __kmp_dflt_max_active_levels_set =
true;
1008 static void __kmp_stg_print_nested(kmp_str_buf_t *buffer,
char const *name,
1010 if (__kmp_env_format) {
1011 KMP_STR_BUF_PRINT_NAME;
1013 __kmp_str_buf_print(buffer,
" %s", name);
1015 __kmp_str_buf_print(buffer,
": deprecated; max-active-levels-var=%d\n",
1016 __kmp_dflt_max_active_levels);
1019 static void __kmp_parse_nested_num_threads(
const char *var,
const char *env,
1020 kmp_nested_nthreads_t *nth_array) {
1021 const char *next = env;
1022 const char *scan = next;
1025 int prev_comma = FALSE;
1031 if (*next ==
'\0') {
1035 if (((*next <
'0') || (*next >
'9')) && (*next !=
',')) {
1036 KMP_WARNING(NthSyntaxError, var, env);
1042 if (total == 0 || prev_comma) {
1050 if (*next >=
'0' && *next <=
'9') {
1054 const char *tmp = next;
1056 if ((*next ==
' ' || *next ==
'\t') && (*tmp >=
'0' && *tmp <=
'9')) {
1057 KMP_WARNING(NthSpacesNotAllowed, var, env);
1062 if (!__kmp_dflt_max_active_levels_set && total > 1)
1063 __kmp_dflt_max_active_levels = KMP_MAX_ACTIVE_LEVELS_LIMIT;
1064 KMP_DEBUG_ASSERT(total > 0);
1066 KMP_WARNING(NthSyntaxError, var, env);
1071 if (!nth_array->nth) {
1073 nth_array->nth = (
int *)KMP_INTERNAL_MALLOC(
sizeof(
int) * total * 2);
1074 if (nth_array->nth == NULL) {
1075 KMP_FATAL(MemoryAllocFailed);
1077 nth_array->size = total * 2;
1079 if (nth_array->size < total) {
1082 nth_array->size *= 2;
1083 }
while (nth_array->size < total);
1085 nth_array->nth = (
int *)KMP_INTERNAL_REALLOC(
1086 nth_array->nth,
sizeof(
int) * nth_array->size);
1087 if (nth_array->nth == NULL) {
1088 KMP_FATAL(MemoryAllocFailed);
1092 nth_array->used = total;
1100 if (*scan ==
'\0') {
1110 nth_array->nth[i++] = 0;
1112 }
else if (prev_comma) {
1114 nth_array->nth[i] = nth_array->nth[i - 1];
1123 if (*scan >=
'0' && *scan <=
'9') {
1125 const char *buf = scan;
1126 char const *msg = NULL;
1131 num = __kmp_str_to_int(buf, *scan);
1132 if (num < KMP_MIN_NTH) {
1133 msg = KMP_I18N_STR(ValueTooSmall);
1135 }
else if (num > __kmp_sys_max_nth) {
1136 msg = KMP_I18N_STR(ValueTooLarge);
1137 num = __kmp_sys_max_nth;
1141 KMP_WARNING(ParseSizeIntWarn, var, env, msg);
1142 KMP_INFORM(Using_int_Value, var, num);
1144 nth_array->nth[i++] = num;
1149 static void __kmp_stg_parse_num_threads(
char const *name,
char const *value,
1152 if (!__kmp_strcasecmp_with_sentinel(
"all", value, 0)) {
1154 __kmp_nested_nth.nth = (
int *)KMP_INTERNAL_MALLOC(
sizeof(
int));
1155 __kmp_nested_nth.size = __kmp_nested_nth.used = 1;
1156 __kmp_nested_nth.nth[0] = __kmp_dflt_team_nth = __kmp_dflt_team_nth_ub =
1159 __kmp_parse_nested_num_threads(name, value, &__kmp_nested_nth);
1160 if (__kmp_nested_nth.nth) {
1161 __kmp_dflt_team_nth = __kmp_nested_nth.nth[0];
1162 if (__kmp_dflt_team_nth_ub < __kmp_dflt_team_nth) {
1163 __kmp_dflt_team_nth_ub = __kmp_dflt_team_nth;
1167 K_DIAG(1, (
"__kmp_dflt_team_nth == %d\n", __kmp_dflt_team_nth));
1170 static void __kmp_stg_parse_num_hidden_helper_threads(
char const *name,
1173 __kmp_stg_parse_int(name, value, 0, 16, &__kmp_hidden_helper_threads_num);
1176 if (__kmp_hidden_helper_threads_num == 0) {
1177 __kmp_enable_hidden_helper = FALSE;
1181 static void __kmp_stg_print_num_hidden_helper_threads(kmp_str_buf_t *buffer,
1184 __kmp_stg_print_int(buffer, name, __kmp_hidden_helper_threads_num);
1187 static void __kmp_stg_parse_use_hidden_helper(
char const *name,
1188 char const *value,
void *data) {
1189 __kmp_stg_parse_bool(name, value, &__kmp_enable_hidden_helper);
1191 __kmp_enable_hidden_helper = FALSE;
1193 (
"__kmp_stg_parse_use_hidden_helper: Disable hidden helper task on "
1194 "non-Linux platform although it is enabled by user explicitly.\n"));
1198 static void __kmp_stg_print_use_hidden_helper(kmp_str_buf_t *buffer,
1199 char const *name,
void *data) {
1200 __kmp_stg_print_bool(buffer, name, __kmp_enable_hidden_helper);
1203 static void __kmp_stg_print_num_threads(kmp_str_buf_t *buffer,
char const *name,
1205 if (__kmp_env_format) {
1206 KMP_STR_BUF_PRINT_NAME;
1208 __kmp_str_buf_print(buffer,
" %s", name);
1210 if (__kmp_nested_nth.used) {
1212 __kmp_str_buf_init(&buf);
1213 for (
int i = 0; i < __kmp_nested_nth.used; i++) {
1214 __kmp_str_buf_print(&buf,
"%d", __kmp_nested_nth.nth[i]);
1215 if (i < __kmp_nested_nth.used - 1) {
1216 __kmp_str_buf_print(&buf,
",");
1219 __kmp_str_buf_print(buffer,
"='%s'\n", buf.str);
1220 __kmp_str_buf_free(&buf);
1222 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
1229 static void __kmp_stg_parse_tasking(
char const *name,
char const *value,
1231 __kmp_stg_parse_int(name, value, 0, (
int)tskm_max,
1232 (
int *)&__kmp_tasking_mode);
1235 static void __kmp_stg_print_tasking(kmp_str_buf_t *buffer,
char const *name,
1237 __kmp_stg_print_int(buffer, name, __kmp_tasking_mode);
1240 static void __kmp_stg_parse_task_stealing(
char const *name,
char const *value,
1242 __kmp_stg_parse_int(name, value, 0, 1,
1243 (
int *)&__kmp_task_stealing_constraint);
1246 static void __kmp_stg_print_task_stealing(kmp_str_buf_t *buffer,
1247 char const *name,
void *data) {
1248 __kmp_stg_print_int(buffer, name, __kmp_task_stealing_constraint);
1251 static void __kmp_stg_parse_max_active_levels(
char const *name,
1252 char const *value,
void *data) {
1253 kmp_uint64 tmp_dflt = 0;
1254 char const *msg = NULL;
1255 if (!__kmp_dflt_max_active_levels_set) {
1257 __kmp_str_to_uint(value, &tmp_dflt, &msg);
1259 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
1260 }
else if (tmp_dflt > KMP_MAX_ACTIVE_LEVELS_LIMIT) {
1262 msg = KMP_I18N_STR(ValueTooLarge);
1263 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
1265 __kmp_type_convert(tmp_dflt, &(__kmp_dflt_max_active_levels));
1266 __kmp_dflt_max_active_levels_set =
true;
1271 static void __kmp_stg_print_max_active_levels(kmp_str_buf_t *buffer,
1272 char const *name,
void *data) {
1273 __kmp_stg_print_int(buffer, name, __kmp_dflt_max_active_levels);
1278 static void __kmp_stg_parse_default_device(
char const *name,
char const *value,
1280 __kmp_stg_parse_int(name, value, 0, KMP_MAX_DEFAULT_DEVICE_LIMIT,
1281 &__kmp_default_device);
1284 static void __kmp_stg_print_default_device(kmp_str_buf_t *buffer,
1285 char const *name,
void *data) {
1286 __kmp_stg_print_int(buffer, name, __kmp_default_device);
1291 static void __kmp_stg_parse_target_offload(
char const *name,
char const *value,
1293 const char *next = value;
1294 const char *scan = next;
1296 __kmp_target_offload = tgt_default;
1301 if (!__kmp_strcasecmp_with_sentinel(
"mandatory", scan, 0)) {
1302 __kmp_target_offload = tgt_mandatory;
1303 }
else if (!__kmp_strcasecmp_with_sentinel(
"disabled", scan, 0)) {
1304 __kmp_target_offload = tgt_disabled;
1305 }
else if (!__kmp_strcasecmp_with_sentinel(
"default", scan, 0)) {
1306 __kmp_target_offload = tgt_default;
1308 KMP_WARNING(SyntaxErrorUsing, name,
"DEFAULT");
1313 static void __kmp_stg_print_target_offload(kmp_str_buf_t *buffer,
1314 char const *name,
void *data) {
1315 const char *value = NULL;
1316 if (__kmp_target_offload == tgt_default)
1318 else if (__kmp_target_offload == tgt_mandatory)
1319 value =
"MANDATORY";
1320 else if (__kmp_target_offload == tgt_disabled)
1322 KMP_DEBUG_ASSERT(value);
1323 if (__kmp_env_format) {
1324 KMP_STR_BUF_PRINT_NAME;
1326 __kmp_str_buf_print(buffer,
" %s", name);
1328 __kmp_str_buf_print(buffer,
"=%s\n", value);
1333 static void __kmp_stg_parse_max_task_priority(
char const *name,
1334 char const *value,
void *data) {
1335 __kmp_stg_parse_int(name, value, 0, KMP_MAX_TASK_PRIORITY_LIMIT,
1336 &__kmp_max_task_priority);
1339 static void __kmp_stg_print_max_task_priority(kmp_str_buf_t *buffer,
1340 char const *name,
void *data) {
1341 __kmp_stg_print_int(buffer, name, __kmp_max_task_priority);
1346 static void __kmp_stg_parse_taskloop_min_tasks(
char const *name,
1347 char const *value,
void *data) {
1349 __kmp_stg_parse_int(name, value, 0, INT_MAX, &tmp);
1350 __kmp_taskloop_min_tasks = tmp;
1353 static void __kmp_stg_print_taskloop_min_tasks(kmp_str_buf_t *buffer,
1354 char const *name,
void *data) {
1355 __kmp_stg_print_uint64(buffer, name, __kmp_taskloop_min_tasks);
1360 static void __kmp_stg_parse_disp_buffers(
char const *name,
char const *value,
1362 if (TCR_4(__kmp_init_serial)) {
1363 KMP_WARNING(EnvSerialWarn, name);
1366 __kmp_stg_parse_int(name, value, 1, KMP_MAX_NTH, &__kmp_dispatch_num_buffers);
1369 static void __kmp_stg_print_disp_buffers(kmp_str_buf_t *buffer,
1370 char const *name,
void *data) {
1371 __kmp_stg_print_int(buffer, name, __kmp_dispatch_num_buffers);
1374 #if KMP_NESTED_HOT_TEAMS
1378 static void __kmp_stg_parse_hot_teams_level(
char const *name,
char const *value,
1380 if (TCR_4(__kmp_init_parallel)) {
1381 KMP_WARNING(EnvParallelWarn, name);
1384 __kmp_stg_parse_int(name, value, 0, KMP_MAX_ACTIVE_LEVELS_LIMIT,
1385 &__kmp_hot_teams_max_level);
1388 static void __kmp_stg_print_hot_teams_level(kmp_str_buf_t *buffer,
1389 char const *name,
void *data) {
1390 __kmp_stg_print_int(buffer, name, __kmp_hot_teams_max_level);
1393 static void __kmp_stg_parse_hot_teams_mode(
char const *name,
char const *value,
1395 if (TCR_4(__kmp_init_parallel)) {
1396 KMP_WARNING(EnvParallelWarn, name);
1399 __kmp_stg_parse_int(name, value, 0, KMP_MAX_ACTIVE_LEVELS_LIMIT,
1400 &__kmp_hot_teams_mode);
1403 static void __kmp_stg_print_hot_teams_mode(kmp_str_buf_t *buffer,
1404 char const *name,
void *data) {
1405 __kmp_stg_print_int(buffer, name, __kmp_hot_teams_mode);
1413 #if KMP_HANDLE_SIGNALS
1415 static void __kmp_stg_parse_handle_signals(
char const *name,
char const *value,
1417 __kmp_stg_parse_bool(name, value, &__kmp_handle_signals);
1420 static void __kmp_stg_print_handle_signals(kmp_str_buf_t *buffer,
1421 char const *name,
void *data) {
1422 __kmp_stg_print_bool(buffer, name, __kmp_handle_signals);
1432 #define KMP_STG_X_DEBUG(x) \
1433 static void __kmp_stg_parse_##x##_debug(char const *name, char const *value, \
1435 __kmp_stg_parse_int(name, value, 0, INT_MAX, &kmp_##x##_debug); \
1437 static void __kmp_stg_print_##x##_debug(kmp_str_buf_t *buffer, \
1438 char const *name, void *data) { \
1439 __kmp_stg_print_int(buffer, name, kmp_##x##_debug); \
1449 #undef KMP_STG_X_DEBUG
1451 static void __kmp_stg_parse_debug(
char const *name,
char const *value,
1454 __kmp_stg_parse_int(name, value, 0, INT_MAX, &debug);
1455 if (kmp_a_debug < debug) {
1456 kmp_a_debug = debug;
1458 if (kmp_b_debug < debug) {
1459 kmp_b_debug = debug;
1461 if (kmp_c_debug < debug) {
1462 kmp_c_debug = debug;
1464 if (kmp_d_debug < debug) {
1465 kmp_d_debug = debug;
1467 if (kmp_e_debug < debug) {
1468 kmp_e_debug = debug;
1470 if (kmp_f_debug < debug) {
1471 kmp_f_debug = debug;
1475 static void __kmp_stg_parse_debug_buf(
char const *name,
char const *value,
1477 __kmp_stg_parse_bool(name, value, &__kmp_debug_buf);
1481 if (__kmp_debug_buf) {
1483 int elements = __kmp_debug_buf_lines * __kmp_debug_buf_chars;
1486 __kmp_debug_buffer = (
char *)__kmp_page_allocate(elements *
sizeof(
char));
1487 for (i = 0; i < elements; i += __kmp_debug_buf_chars)
1488 __kmp_debug_buffer[i] =
'\0';
1490 __kmp_debug_count = 0;
1492 K_DIAG(1, (
"__kmp_debug_buf = %d\n", __kmp_debug_buf));
1495 static void __kmp_stg_print_debug_buf(kmp_str_buf_t *buffer,
char const *name,
1497 __kmp_stg_print_bool(buffer, name, __kmp_debug_buf);
1500 static void __kmp_stg_parse_debug_buf_atomic(
char const *name,
1501 char const *value,
void *data) {
1502 __kmp_stg_parse_bool(name, value, &__kmp_debug_buf_atomic);
1505 static void __kmp_stg_print_debug_buf_atomic(kmp_str_buf_t *buffer,
1506 char const *name,
void *data) {
1507 __kmp_stg_print_bool(buffer, name, __kmp_debug_buf_atomic);
1510 static void __kmp_stg_parse_debug_buf_chars(
char const *name,
char const *value,
1512 __kmp_stg_parse_int(name, value, KMP_DEBUG_BUF_CHARS_MIN, INT_MAX,
1513 &__kmp_debug_buf_chars);
1516 static void __kmp_stg_print_debug_buf_chars(kmp_str_buf_t *buffer,
1517 char const *name,
void *data) {
1518 __kmp_stg_print_int(buffer, name, __kmp_debug_buf_chars);
1521 static void __kmp_stg_parse_debug_buf_lines(
char const *name,
char const *value,
1523 __kmp_stg_parse_int(name, value, KMP_DEBUG_BUF_LINES_MIN, INT_MAX,
1524 &__kmp_debug_buf_lines);
1527 static void __kmp_stg_print_debug_buf_lines(kmp_str_buf_t *buffer,
1528 char const *name,
void *data) {
1529 __kmp_stg_print_int(buffer, name, __kmp_debug_buf_lines);
1532 static void __kmp_stg_parse_diag(
char const *name,
char const *value,
1534 __kmp_stg_parse_int(name, value, 0, INT_MAX, &kmp_diag);
1537 static void __kmp_stg_print_diag(kmp_str_buf_t *buffer,
char const *name,
1539 __kmp_stg_print_int(buffer, name, kmp_diag);
1547 static void __kmp_stg_parse_align_alloc(
char const *name,
char const *value,
1549 __kmp_stg_parse_size(name, value, CACHE_LINE, INT_MAX, NULL,
1550 &__kmp_align_alloc, 1);
1553 static void __kmp_stg_print_align_alloc(kmp_str_buf_t *buffer,
char const *name,
1555 __kmp_stg_print_size(buffer, name, __kmp_align_alloc);
1564 static void __kmp_stg_parse_barrier_branch_bit(
char const *name,
1565 char const *value,
void *data) {
1569 for (
int i = bs_plain_barrier; i < bs_last_barrier; i++) {
1570 var = __kmp_barrier_branch_bit_env_name[i];
1571 if ((strcmp(var, name) == 0) && (value != 0)) {
1574 comma = CCAST(
char *, strchr(value,
','));
1575 __kmp_barrier_gather_branch_bits[i] =
1576 (kmp_uint32)__kmp_str_to_int(value,
',');
1578 if (comma == NULL) {
1579 __kmp_barrier_release_branch_bits[i] = __kmp_barrier_release_bb_dflt;
1581 __kmp_barrier_release_branch_bits[i] =
1582 (kmp_uint32)__kmp_str_to_int(comma + 1, 0);
1584 if (__kmp_barrier_release_branch_bits[i] > KMP_MAX_BRANCH_BITS) {
1585 __kmp_msg(kmp_ms_warning,
1586 KMP_MSG(BarrReleaseValueInvalid, name, comma + 1),
1588 __kmp_barrier_release_branch_bits[i] = __kmp_barrier_release_bb_dflt;
1591 if (__kmp_barrier_gather_branch_bits[i] > KMP_MAX_BRANCH_BITS) {
1592 KMP_WARNING(BarrGatherValueInvalid, name, value);
1593 KMP_INFORM(Using_uint_Value, name, __kmp_barrier_gather_bb_dflt);
1594 __kmp_barrier_gather_branch_bits[i] = __kmp_barrier_gather_bb_dflt;
1597 K_DIAG(1, (
"%s == %d,%d\n", __kmp_barrier_branch_bit_env_name[i],
1598 __kmp_barrier_gather_branch_bits[i],
1599 __kmp_barrier_release_branch_bits[i]))
1603 static void __kmp_stg_print_barrier_branch_bit(kmp_str_buf_t *buffer,
1604 char const *name,
void *data) {
1606 for (
int i = bs_plain_barrier; i < bs_last_barrier; i++) {
1607 var = __kmp_barrier_branch_bit_env_name[i];
1608 if (strcmp(var, name) == 0) {
1609 if (__kmp_env_format) {
1610 KMP_STR_BUF_PRINT_NAME_EX(__kmp_barrier_branch_bit_env_name[i]);
1612 __kmp_str_buf_print(buffer,
" %s='",
1613 __kmp_barrier_branch_bit_env_name[i]);
1615 __kmp_str_buf_print(buffer,
"%d,%d'\n",
1616 __kmp_barrier_gather_branch_bits[i],
1617 __kmp_barrier_release_branch_bits[i]);
1629 static void __kmp_stg_parse_barrier_pattern(
char const *name,
char const *value,
1634 for (
int i = bs_plain_barrier; i < bs_last_barrier; i++) {
1635 var = __kmp_barrier_pattern_env_name[i];
1637 if ((strcmp(var, name) == 0) && (value != 0)) {
1639 char *comma = CCAST(
char *, strchr(value,
','));
1642 for (j = bp_linear_bar; j < bp_last_bar; j++) {
1643 if (__kmp_match_with_sentinel(__kmp_barrier_pattern_name[j], value, 1,
1645 __kmp_barrier_gather_pattern[i] = (kmp_bar_pat_e)j;
1649 if (j == bp_last_bar) {
1650 KMP_WARNING(BarrGatherValueInvalid, name, value);
1651 KMP_INFORM(Using_str_Value, name,
1652 __kmp_barrier_pattern_name[bp_linear_bar]);
1656 if (comma != NULL) {
1657 for (j = bp_linear_bar; j < bp_last_bar; j++) {
1658 if (__kmp_str_match(__kmp_barrier_pattern_name[j], 1, comma + 1)) {
1659 __kmp_barrier_release_pattern[i] = (kmp_bar_pat_e)j;
1663 if (j == bp_last_bar) {
1664 __kmp_msg(kmp_ms_warning,
1665 KMP_MSG(BarrReleaseValueInvalid, name, comma + 1),
1667 KMP_INFORM(Using_str_Value, name,
1668 __kmp_barrier_pattern_name[bp_linear_bar]);
1675 static void __kmp_stg_print_barrier_pattern(kmp_str_buf_t *buffer,
1676 char const *name,
void *data) {
1678 for (
int i = bs_plain_barrier; i < bs_last_barrier; i++) {
1679 var = __kmp_barrier_pattern_env_name[i];
1680 if (strcmp(var, name) == 0) {
1681 int j = __kmp_barrier_gather_pattern[i];
1682 int k = __kmp_barrier_release_pattern[i];
1683 if (__kmp_env_format) {
1684 KMP_STR_BUF_PRINT_NAME_EX(__kmp_barrier_pattern_env_name[i]);
1686 __kmp_str_buf_print(buffer,
" %s='",
1687 __kmp_barrier_pattern_env_name[i]);
1689 __kmp_str_buf_print(buffer,
"%s,%s'\n", __kmp_barrier_pattern_name[j],
1690 __kmp_barrier_pattern_name[k]);
1698 static void __kmp_stg_parse_abort_delay(
char const *name,
char const *value,
1702 int delay = __kmp_abort_delay / 1000;
1703 __kmp_stg_parse_int(name, value, 0, INT_MAX / 1000, &delay);
1704 __kmp_abort_delay = delay * 1000;
1707 static void __kmp_stg_print_abort_delay(kmp_str_buf_t *buffer,
char const *name,
1709 __kmp_stg_print_int(buffer, name, __kmp_abort_delay);
1715 static void __kmp_stg_parse_cpuinfo_file(
char const *name,
char const *value,
1717 #if KMP_AFFINITY_SUPPORTED
1718 __kmp_stg_parse_str(name, value, &__kmp_cpuinfo_file);
1719 K_DIAG(1, (
"__kmp_cpuinfo_file == %s\n", __kmp_cpuinfo_file));
1723 static void __kmp_stg_print_cpuinfo_file(kmp_str_buf_t *buffer,
1724 char const *name,
void *data) {
1725 #if KMP_AFFINITY_SUPPORTED
1726 if (__kmp_env_format) {
1727 KMP_STR_BUF_PRINT_NAME;
1729 __kmp_str_buf_print(buffer,
" %s", name);
1731 if (__kmp_cpuinfo_file) {
1732 __kmp_str_buf_print(buffer,
"='%s'\n", __kmp_cpuinfo_file);
1734 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
1742 static void __kmp_stg_parse_force_reduction(
char const *name,
char const *value,
1744 kmp_stg_fr_data_t *reduction = (kmp_stg_fr_data_t *)data;
1747 rc = __kmp_stg_check_rivals(name, value, reduction->rivals);
1751 if (reduction->force) {
1753 if (__kmp_str_match(
"critical", 0, value))
1754 __kmp_force_reduction_method = critical_reduce_block;
1755 else if (__kmp_str_match(
"atomic", 0, value))
1756 __kmp_force_reduction_method = atomic_reduce_block;
1757 else if (__kmp_str_match(
"tree", 0, value))
1758 __kmp_force_reduction_method = tree_reduce_block;
1760 KMP_FATAL(UnknownForceReduction, name, value);
1764 __kmp_stg_parse_bool(name, value, &__kmp_determ_red);
1765 if (__kmp_determ_red) {
1766 __kmp_force_reduction_method = tree_reduce_block;
1768 __kmp_force_reduction_method = reduction_method_not_defined;
1771 K_DIAG(1, (
"__kmp_force_reduction_method == %d\n",
1772 __kmp_force_reduction_method));
1775 static void __kmp_stg_print_force_reduction(kmp_str_buf_t *buffer,
1776 char const *name,
void *data) {
1778 kmp_stg_fr_data_t *reduction = (kmp_stg_fr_data_t *)data;
1779 if (reduction->force) {
1780 if (__kmp_force_reduction_method == critical_reduce_block) {
1781 __kmp_stg_print_str(buffer, name,
"critical");
1782 }
else if (__kmp_force_reduction_method == atomic_reduce_block) {
1783 __kmp_stg_print_str(buffer, name,
"atomic");
1784 }
else if (__kmp_force_reduction_method == tree_reduce_block) {
1785 __kmp_stg_print_str(buffer, name,
"tree");
1787 if (__kmp_env_format) {
1788 KMP_STR_BUF_PRINT_NAME;
1790 __kmp_str_buf_print(buffer,
" %s", name);
1792 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
1795 __kmp_stg_print_bool(buffer, name, __kmp_determ_red);
1803 static void __kmp_stg_parse_storage_map(
char const *name,
char const *value,
1805 if (__kmp_str_match(
"verbose", 1, value)) {
1806 __kmp_storage_map = TRUE;
1807 __kmp_storage_map_verbose = TRUE;
1808 __kmp_storage_map_verbose_specified = TRUE;
1811 __kmp_storage_map_verbose = FALSE;
1812 __kmp_stg_parse_bool(name, value, &__kmp_storage_map);
1816 static void __kmp_stg_print_storage_map(kmp_str_buf_t *buffer,
char const *name,
1818 if (__kmp_storage_map_verbose || __kmp_storage_map_verbose_specified) {
1819 __kmp_stg_print_str(buffer, name,
"verbose");
1821 __kmp_stg_print_bool(buffer, name, __kmp_storage_map);
1828 static void __kmp_stg_parse_all_threadprivate(
char const *name,
1829 char const *value,
void *data) {
1830 __kmp_stg_parse_int(name, value,
1831 __kmp_allThreadsSpecified ? __kmp_max_nth : 1,
1832 __kmp_max_nth, &__kmp_tp_capacity);
1835 static void __kmp_stg_print_all_threadprivate(kmp_str_buf_t *buffer,
1836 char const *name,
void *data) {
1837 __kmp_stg_print_int(buffer, name, __kmp_tp_capacity);
1843 static void __kmp_stg_parse_foreign_threads_threadprivate(
char const *name,
1846 __kmp_stg_parse_bool(name, value, &__kmp_foreign_tp);
1849 static void __kmp_stg_print_foreign_threads_threadprivate(kmp_str_buf_t *buffer,
1852 __kmp_stg_print_bool(buffer, name, __kmp_foreign_tp);
1858 #if KMP_AFFINITY_SUPPORTED
1860 static int __kmp_parse_affinity_proc_id_list(
const char *var,
const char *env,
1861 const char **nextEnv,
1863 const char *scan = env;
1864 const char *next = scan;
1870 int start, end, stride;
1874 if (*next ==
'\0') {
1885 if ((*next <
'0') || (*next >
'9')) {
1886 KMP_WARNING(AffSyntaxError, var);
1890 num = __kmp_str_to_int(scan, *next);
1891 KMP_ASSERT(num >= 0);
1909 if ((*next <
'0') || (*next >
'9')) {
1910 KMP_WARNING(AffSyntaxError, var);
1915 num = __kmp_str_to_int(scan, *next);
1916 KMP_ASSERT(num >= 0);
1929 if ((*next <
'0') || (*next >
'9')) {
1931 KMP_WARNING(AffSyntaxError, var);
1939 start = __kmp_str_to_int(scan, *next);
1940 KMP_ASSERT(start >= 0);
1959 if ((*next <
'0') || (*next >
'9')) {
1960 KMP_WARNING(AffSyntaxError, var);
1964 end = __kmp_str_to_int(scan, *next);
1965 KMP_ASSERT(end >= 0);
1982 if ((*next <
'0') || (*next >
'9')) {
1983 KMP_WARNING(AffSyntaxError, var);
1987 stride = __kmp_str_to_int(scan, *next);
1988 KMP_ASSERT(stride >= 0);
1994 KMP_WARNING(AffZeroStride, var);
1999 KMP_WARNING(AffStartGreaterEnd, var, start, end);
2004 KMP_WARNING(AffStrideLessZero, var, start, end);
2008 if ((end - start) / stride > 65536) {
2009 KMP_WARNING(AffRangeTooBig, var, end, start, stride);
2026 ptrdiff_t len = next - env;
2027 char *retlist = (
char *)__kmp_allocate((len + 1) *
sizeof(char));
2028 KMP_MEMCPY_S(retlist, (len + 1) *
sizeof(
char), env, len *
sizeof(
char));
2029 retlist[len] =
'\0';
2030 *proclist = retlist;
2037 static kmp_setting_t *__kmp_affinity_notype = NULL;
2039 static void __kmp_parse_affinity_env(
char const *name,
char const *value,
2040 enum affinity_type *out_type,
2041 char **out_proclist,
int *out_verbose,
2042 int *out_warn,
int *out_respect,
2043 enum affinity_gran *out_gran,
2044 int *out_gran_levels,
int *out_dups,
2045 int *out_compact,
int *out_offset) {
2046 char *buffer = NULL;
2062 KMP_ASSERT(value != NULL);
2064 if (TCR_4(__kmp_init_middle)) {
2065 KMP_WARNING(EnvMiddleWarn, name);
2066 __kmp_env_toPrint(name, 0);
2069 __kmp_env_toPrint(name, 1);
2072 __kmp_str_format(
"%s", value);
2082 #define EMIT_WARN(skip, errlist) \
2086 SKIP_TO(next, ','); \
2090 KMP_WARNING errlist; \
2099 #define _set_param(_guard, _var, _val) \
2101 if (_guard == 0) { \
2104 EMIT_WARN(FALSE, (AffParamDefined, name, start)); \
2109 #define set_type(val) _set_param(type, *out_type, val)
2110 #define set_verbose(val) _set_param(verbose, *out_verbose, val)
2111 #define set_warnings(val) _set_param(warnings, *out_warn, val)
2112 #define set_respect(val) _set_param(respect, *out_respect, val)
2113 #define set_dups(val) _set_param(dups, *out_dups, val)
2114 #define set_proclist(val) _set_param(proclist, *out_proclist, val)
2116 #define set_gran(val, levels) \
2120 *out_gran_levels = levels; \
2122 EMIT_WARN(FALSE, (AffParamDefined, name, start)); \
2127 KMP_DEBUG_ASSERT((__kmp_nested_proc_bind.bind_types != NULL) &&
2128 (__kmp_nested_proc_bind.used > 0));
2130 while (*buf !=
'\0') {
2133 if (__kmp_match_str(
"none", buf, CCAST(
const char **, &next))) {
2134 set_type(affinity_none);
2135 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
2137 }
else if (__kmp_match_str(
"scatter", buf, CCAST(
const char **, &next))) {
2138 set_type(affinity_scatter);
2139 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2141 }
else if (__kmp_match_str(
"compact", buf, CCAST(
const char **, &next))) {
2142 set_type(affinity_compact);
2143 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2145 }
else if (__kmp_match_str(
"logical", buf, CCAST(
const char **, &next))) {
2146 set_type(affinity_logical);
2147 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2149 }
else if (__kmp_match_str(
"physical", buf, CCAST(
const char **, &next))) {
2150 set_type(affinity_physical);
2151 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2153 }
else if (__kmp_match_str(
"explicit", buf, CCAST(
const char **, &next))) {
2154 set_type(affinity_explicit);
2155 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2157 }
else if (__kmp_match_str(
"balanced", buf, CCAST(
const char **, &next))) {
2158 set_type(affinity_balanced);
2159 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2161 }
else if (__kmp_match_str(
"disabled", buf, CCAST(
const char **, &next))) {
2162 set_type(affinity_disabled);
2163 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
2165 }
else if (__kmp_match_str(
"verbose", buf, CCAST(
const char **, &next))) {
2168 }
else if (__kmp_match_str(
"noverbose", buf, CCAST(
const char **, &next))) {
2171 }
else if (__kmp_match_str(
"warnings", buf, CCAST(
const char **, &next))) {
2174 }
else if (__kmp_match_str(
"nowarnings", buf,
2175 CCAST(
const char **, &next))) {
2176 set_warnings(FALSE);
2178 }
else if (__kmp_match_str(
"respect", buf, CCAST(
const char **, &next))) {
2181 }
else if (__kmp_match_str(
"norespect", buf, CCAST(
const char **, &next))) {
2184 }
else if (__kmp_match_str(
"duplicates", buf,
2185 CCAST(
const char **, &next)) ||
2186 __kmp_match_str(
"dups", buf, CCAST(
const char **, &next))) {
2189 }
else if (__kmp_match_str(
"noduplicates", buf,
2190 CCAST(
const char **, &next)) ||
2191 __kmp_match_str(
"nodups", buf, CCAST(
const char **, &next))) {
2194 }
else if (__kmp_match_str(
"granularity", buf,
2195 CCAST(
const char **, &next)) ||
2196 __kmp_match_str(
"gran", buf, CCAST(
const char **, &next))) {
2199 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2206 if (__kmp_match_str(
"fine", buf, CCAST(
const char **, &next))) {
2207 set_gran(affinity_gran_fine, -1);
2209 }
else if (__kmp_match_str(
"thread", buf, CCAST(
const char **, &next))) {
2210 set_gran(affinity_gran_thread, -1);
2212 }
else if (__kmp_match_str(
"core", buf, CCAST(
const char **, &next))) {
2213 set_gran(affinity_gran_core, -1);
2216 }
else if (__kmp_match_str(
"tile", buf, CCAST(
const char **, &next))) {
2217 set_gran(affinity_gran_tile, -1);
2220 }
else if (__kmp_match_str(
"package", buf, CCAST(
const char **, &next))) {
2221 set_gran(affinity_gran_package, -1);
2223 }
else if (__kmp_match_str(
"node", buf, CCAST(
const char **, &next))) {
2224 set_gran(affinity_gran_node, -1);
2226 #if KMP_GROUP_AFFINITY
2227 }
else if (__kmp_match_str(
"group", buf, CCAST(
const char **, &next))) {
2228 set_gran(affinity_gran_group, -1);
2231 }
else if ((*buf >=
'0') && (*buf <=
'9')) {
2235 n = __kmp_str_to_int(buf, *next);
2238 set_gran(affinity_gran_default, n);
2240 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2243 }
else if (__kmp_match_str(
"proclist", buf, CCAST(
const char **, &next))) {
2244 char *temp_proclist;
2248 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2254 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2259 if (!__kmp_parse_affinity_proc_id_list(
2260 name, buf, CCAST(
const char **, &next), &temp_proclist)) {
2272 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2276 set_proclist(temp_proclist);
2277 }
else if ((*buf >=
'0') && (*buf <=
'9')) {
2282 n = __kmp_str_to_int(buf, *next);
2288 KMP_WARNING(AffManyParams, name, start);
2292 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2300 }
else if (*next !=
'\0') {
2301 const char *temp = next;
2302 EMIT_WARN(TRUE, (ParseExtraCharsWarn, name, temp));
2314 #undef set_granularity
2316 __kmp_str_free(&buffer);
2320 KMP_WARNING(AffProcListNoType, name);
2321 *out_type = affinity_explicit;
2322 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2323 }
else if (*out_type != affinity_explicit) {
2324 KMP_WARNING(AffProcListNotExplicit, name);
2325 KMP_ASSERT(*out_proclist != NULL);
2326 KMP_INTERNAL_FREE(*out_proclist);
2327 *out_proclist = NULL;
2330 switch (*out_type) {
2331 case affinity_logical:
2332 case affinity_physical: {
2334 *out_offset = number[0];
2337 KMP_WARNING(AffManyParamsForLogic, name, number[1]);
2340 case affinity_balanced: {
2342 *out_compact = number[0];
2345 *out_offset = number[1];
2348 if (__kmp_affinity_gran == affinity_gran_default) {
2349 #if KMP_MIC_SUPPORTED
2350 if (__kmp_mic_type != non_mic) {
2351 if (__kmp_affinity_verbose || __kmp_affinity_warnings) {
2352 KMP_WARNING(AffGranUsing,
"KMP_AFFINITY",
"fine");
2354 __kmp_affinity_gran = affinity_gran_fine;
2358 if (__kmp_affinity_verbose || __kmp_affinity_warnings) {
2359 KMP_WARNING(AffGranUsing,
"KMP_AFFINITY",
"core");
2361 __kmp_affinity_gran = affinity_gran_core;
2365 case affinity_scatter:
2366 case affinity_compact: {
2368 *out_compact = number[0];
2371 *out_offset = number[1];
2374 case affinity_explicit: {
2375 if (*out_proclist == NULL) {
2376 KMP_WARNING(AffNoProcList, name);
2377 __kmp_affinity_type = affinity_none;
2380 KMP_WARNING(AffNoParam, name,
"explicit");
2383 case affinity_none: {
2385 KMP_WARNING(AffNoParam, name,
"none");
2388 case affinity_disabled: {
2390 KMP_WARNING(AffNoParam, name,
"disabled");
2393 case affinity_default: {
2395 KMP_WARNING(AffNoParam, name,
"default");
2398 default: { KMP_ASSERT(0); }
2402 static void __kmp_stg_parse_affinity(
char const *name,
char const *value,
2404 kmp_setting_t **rivals = (kmp_setting_t **)data;
2407 rc = __kmp_stg_check_rivals(name, value, rivals);
2412 __kmp_parse_affinity_env(name, value, &__kmp_affinity_type,
2413 &__kmp_affinity_proclist, &__kmp_affinity_verbose,
2414 &__kmp_affinity_warnings,
2415 &__kmp_affinity_respect_mask, &__kmp_affinity_gran,
2416 &__kmp_affinity_gran_levels, &__kmp_affinity_dups,
2417 &__kmp_affinity_compact, &__kmp_affinity_offset);
2421 static void __kmp_stg_print_affinity(kmp_str_buf_t *buffer,
char const *name,
2423 if (__kmp_env_format) {
2424 KMP_STR_BUF_PRINT_NAME_EX(name);
2426 __kmp_str_buf_print(buffer,
" %s='", name);
2428 if (__kmp_affinity_verbose) {
2429 __kmp_str_buf_print(buffer,
"%s,",
"verbose");
2431 __kmp_str_buf_print(buffer,
"%s,",
"noverbose");
2433 if (__kmp_affinity_warnings) {
2434 __kmp_str_buf_print(buffer,
"%s,",
"warnings");
2436 __kmp_str_buf_print(buffer,
"%s,",
"nowarnings");
2438 if (KMP_AFFINITY_CAPABLE()) {
2439 if (__kmp_affinity_respect_mask) {
2440 __kmp_str_buf_print(buffer,
"%s,",
"respect");
2442 __kmp_str_buf_print(buffer,
"%s,",
"norespect");
2444 switch (__kmp_affinity_gran) {
2445 case affinity_gran_default:
2446 __kmp_str_buf_print(buffer,
"%s",
"granularity=default,");
2448 case affinity_gran_fine:
2449 __kmp_str_buf_print(buffer,
"%s",
"granularity=fine,");
2451 case affinity_gran_thread:
2452 __kmp_str_buf_print(buffer,
"%s",
"granularity=thread,");
2454 case affinity_gran_core:
2455 __kmp_str_buf_print(buffer,
"%s",
"granularity=core,");
2457 case affinity_gran_package:
2458 __kmp_str_buf_print(buffer,
"%s",
"granularity=package,");
2460 case affinity_gran_node:
2461 __kmp_str_buf_print(buffer,
"%s",
"granularity=node,");
2463 #if KMP_GROUP_AFFINITY
2464 case affinity_gran_group:
2465 __kmp_str_buf_print(buffer,
"%s",
"granularity=group,");
2470 if (!KMP_AFFINITY_CAPABLE()) {
2471 __kmp_str_buf_print(buffer,
"%s",
"disabled");
2473 switch (__kmp_affinity_type) {
2475 __kmp_str_buf_print(buffer,
"%s",
"none");
2477 case affinity_physical:
2478 __kmp_str_buf_print(buffer,
"%s,%d",
"physical", __kmp_affinity_offset);
2480 case affinity_logical:
2481 __kmp_str_buf_print(buffer,
"%s,%d",
"logical", __kmp_affinity_offset);
2483 case affinity_compact:
2484 __kmp_str_buf_print(buffer,
"%s,%d,%d",
"compact", __kmp_affinity_compact,
2485 __kmp_affinity_offset);
2487 case affinity_scatter:
2488 __kmp_str_buf_print(buffer,
"%s,%d,%d",
"scatter", __kmp_affinity_compact,
2489 __kmp_affinity_offset);
2491 case affinity_explicit:
2492 __kmp_str_buf_print(buffer,
"%s=[%s],%s",
"proclist",
2493 __kmp_affinity_proclist,
"explicit");
2495 case affinity_balanced:
2496 __kmp_str_buf_print(buffer,
"%s,%d,%d",
"balanced",
2497 __kmp_affinity_compact, __kmp_affinity_offset);
2499 case affinity_disabled:
2500 __kmp_str_buf_print(buffer,
"%s",
"disabled");
2502 case affinity_default:
2503 __kmp_str_buf_print(buffer,
"%s",
"default");
2506 __kmp_str_buf_print(buffer,
"%s",
"<unknown>");
2509 __kmp_str_buf_print(buffer,
"'\n");
2512 #ifdef KMP_GOMP_COMPAT
2514 static void __kmp_stg_parse_gomp_cpu_affinity(
char const *name,
2515 char const *value,
void *data) {
2516 const char *next = NULL;
2517 char *temp_proclist;
2518 kmp_setting_t **rivals = (kmp_setting_t **)data;
2521 rc = __kmp_stg_check_rivals(name, value, rivals);
2526 if (TCR_4(__kmp_init_middle)) {
2527 KMP_WARNING(EnvMiddleWarn, name);
2528 __kmp_env_toPrint(name, 0);
2532 __kmp_env_toPrint(name, 1);
2534 if (__kmp_parse_affinity_proc_id_list(name, value, &next, &temp_proclist)) {
2536 if (*next ==
'\0') {
2538 __kmp_affinity_proclist = temp_proclist;
2539 __kmp_affinity_type = affinity_explicit;
2540 __kmp_affinity_gran = affinity_gran_fine;
2541 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2543 KMP_WARNING(AffSyntaxError, name);
2544 if (temp_proclist != NULL) {
2545 KMP_INTERNAL_FREE((
void *)temp_proclist);
2550 __kmp_affinity_type = affinity_none;
2551 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
2577 static int __kmp_parse_subplace_list(
const char *var,
const char **scan) {
2581 int start, count, stride;
2587 if ((**scan <
'0') || (**scan >
'9')) {
2588 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2593 start = __kmp_str_to_int(*scan, *next);
2594 KMP_ASSERT(start >= 0);
2599 if (**scan ==
'}') {
2602 if (**scan ==
',') {
2606 if (**scan !=
':') {
2607 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2614 if ((**scan <
'0') || (**scan >
'9')) {
2615 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2620 count = __kmp_str_to_int(*scan, *next);
2621 KMP_ASSERT(count >= 0);
2626 if (**scan ==
'}') {
2629 if (**scan ==
',') {
2633 if (**scan !=
':') {
2634 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2643 if (**scan ==
'+') {
2647 if (**scan ==
'-') {
2655 if ((**scan <
'0') || (**scan >
'9')) {
2656 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2661 stride = __kmp_str_to_int(*scan, *next);
2662 KMP_ASSERT(stride >= 0);
2668 if (**scan ==
'}') {
2671 if (**scan ==
',') {
2676 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2682 static int __kmp_parse_place(
const char *var,
const char **scan) {
2687 if (**scan ==
'{') {
2689 if (!__kmp_parse_subplace_list(var, scan)) {
2692 if (**scan !=
'}') {
2693 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2697 }
else if (**scan ==
'!') {
2699 return __kmp_parse_place(var, scan);
2700 }
else if ((**scan >=
'0') && (**scan <=
'9')) {
2703 int proc = __kmp_str_to_int(*scan, *next);
2704 KMP_ASSERT(proc >= 0);
2707 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2713 static int __kmp_parse_place_list(
const char *var,
const char *env,
2714 char **place_list) {
2715 const char *scan = env;
2716 const char *next = scan;
2721 if (!__kmp_parse_place(var, &scan)) {
2727 if (*scan ==
'\0') {
2735 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2742 if ((*scan <
'0') || (*scan >
'9')) {
2743 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2748 count = __kmp_str_to_int(scan, *next);
2749 KMP_ASSERT(count >= 0);
2754 if (*scan ==
'\0') {
2762 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2783 if ((*scan <
'0') || (*scan >
'9')) {
2784 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2789 stride = __kmp_str_to_int(scan, *next);
2790 KMP_ASSERT(stride >= 0);
2796 if (*scan ==
'\0') {
2804 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2809 ptrdiff_t len = scan - env;
2810 char *retlist = (
char *)__kmp_allocate((len + 1) *
sizeof(char));
2811 KMP_MEMCPY_S(retlist, (len + 1) *
sizeof(
char), env, len *
sizeof(
char));
2812 retlist[len] =
'\0';
2813 *place_list = retlist;
2818 static void __kmp_stg_parse_places(
char const *name,
char const *value,
2821 const char *scan = value;
2822 const char *next = scan;
2823 const char *kind =
"\"threads\"";
2824 kmp_setting_t **rivals = (kmp_setting_t **)data;
2827 rc = __kmp_stg_check_rivals(name, value, rivals);
2834 if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_default) {
2835 __kmp_nested_proc_bind.bind_types[0] = proc_bind_true;
2840 if (__kmp_match_str(
"threads", scan, &next)) {
2842 __kmp_affinity_type = affinity_compact;
2843 __kmp_affinity_gran = affinity_gran_thread;
2844 __kmp_affinity_dups = FALSE;
2845 kind =
"\"threads\"";
2846 }
else if (__kmp_match_str(
"cores", scan, &next)) {
2848 __kmp_affinity_type = affinity_compact;
2849 __kmp_affinity_gran = affinity_gran_core;
2850 __kmp_affinity_dups = FALSE;
2853 }
else if (__kmp_match_str(
"tiles", scan, &next)) {
2855 __kmp_affinity_type = affinity_compact;
2856 __kmp_affinity_gran = affinity_gran_tile;
2857 __kmp_affinity_dups = FALSE;
2860 }
else if (__kmp_match_str(
"sockets", scan, &next)) {
2862 __kmp_affinity_type = affinity_compact;
2863 __kmp_affinity_gran = affinity_gran_package;
2864 __kmp_affinity_dups = FALSE;
2865 kind =
"\"sockets\"";
2867 if (__kmp_affinity_proclist != NULL) {
2868 KMP_INTERNAL_FREE((
void *)__kmp_affinity_proclist);
2869 __kmp_affinity_proclist = NULL;
2871 if (__kmp_parse_place_list(name, value, &__kmp_affinity_proclist)) {
2872 __kmp_affinity_type = affinity_explicit;
2873 __kmp_affinity_gran = affinity_gran_fine;
2874 __kmp_affinity_dups = FALSE;
2875 if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_default) {
2876 __kmp_nested_proc_bind.bind_types[0] = proc_bind_true;
2882 if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_default) {
2883 __kmp_nested_proc_bind.bind_types[0] = proc_bind_true;
2887 if (*scan ==
'\0') {
2893 KMP_WARNING(SyntaxErrorUsing, name, kind);
2901 count = __kmp_str_to_int(scan, *next);
2902 KMP_ASSERT(count >= 0);
2907 KMP_WARNING(SyntaxErrorUsing, name, kind);
2913 if (*scan !=
'\0') {
2914 KMP_WARNING(ParseExtraCharsWarn, name, scan);
2916 __kmp_affinity_num_places = count;
2919 static void __kmp_stg_print_places(kmp_str_buf_t *buffer,
char const *name,
2921 if (__kmp_env_format) {
2922 KMP_STR_BUF_PRINT_NAME;
2924 __kmp_str_buf_print(buffer,
" %s", name);
2926 if ((__kmp_nested_proc_bind.used == 0) ||
2927 (__kmp_nested_proc_bind.bind_types == NULL) ||
2928 (__kmp_nested_proc_bind.bind_types[0] == proc_bind_false)) {
2929 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
2930 }
else if (__kmp_affinity_type == affinity_explicit) {
2931 if (__kmp_affinity_proclist != NULL) {
2932 __kmp_str_buf_print(buffer,
"='%s'\n", __kmp_affinity_proclist);
2934 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
2936 }
else if (__kmp_affinity_type == affinity_compact) {
2938 if (__kmp_affinity_num_masks > 0) {
2939 num = __kmp_affinity_num_masks;
2940 }
else if (__kmp_affinity_num_places > 0) {
2941 num = __kmp_affinity_num_places;
2945 if (__kmp_affinity_gran == affinity_gran_thread) {
2947 __kmp_str_buf_print(buffer,
"='threads(%d)'\n", num);
2949 __kmp_str_buf_print(buffer,
"='threads'\n");
2951 }
else if (__kmp_affinity_gran == affinity_gran_core) {
2953 __kmp_str_buf_print(buffer,
"='cores(%d)' \n", num);
2955 __kmp_str_buf_print(buffer,
"='cores'\n");
2958 }
else if (__kmp_affinity_gran == affinity_gran_tile) {
2960 __kmp_str_buf_print(buffer,
"='tiles(%d)' \n", num);
2962 __kmp_str_buf_print(buffer,
"='tiles'\n");
2965 }
else if (__kmp_affinity_gran == affinity_gran_package) {
2967 __kmp_str_buf_print(buffer,
"='sockets(%d)'\n", num);
2969 __kmp_str_buf_print(buffer,
"='sockets'\n");
2972 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
2975 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
2979 static void __kmp_stg_parse_topology_method(
char const *name,
char const *value,
2981 if (__kmp_str_match(
"all", 1, value)) {
2982 __kmp_affinity_top_method = affinity_top_method_all;
2985 else if (__kmp_str_match(
"hwloc", 1, value)) {
2986 __kmp_affinity_top_method = affinity_top_method_hwloc;
2989 #if KMP_ARCH_X86 || KMP_ARCH_X86_64
2990 else if (__kmp_str_match(
"x2apic id", 9, value) ||
2991 __kmp_str_match(
"x2apic_id", 9, value) ||
2992 __kmp_str_match(
"x2apic-id", 9, value) ||
2993 __kmp_str_match(
"x2apicid", 8, value) ||
2994 __kmp_str_match(
"cpuid leaf 11", 13, value) ||
2995 __kmp_str_match(
"cpuid_leaf_11", 13, value) ||
2996 __kmp_str_match(
"cpuid-leaf-11", 13, value) ||
2997 __kmp_str_match(
"cpuid leaf11", 12, value) ||
2998 __kmp_str_match(
"cpuid_leaf11", 12, value) ||
2999 __kmp_str_match(
"cpuid-leaf11", 12, value) ||
3000 __kmp_str_match(
"cpuidleaf 11", 12, value) ||
3001 __kmp_str_match(
"cpuidleaf_11", 12, value) ||
3002 __kmp_str_match(
"cpuidleaf-11", 12, value) ||
3003 __kmp_str_match(
"cpuidleaf11", 11, value) ||
3004 __kmp_str_match(
"cpuid 11", 8, value) ||
3005 __kmp_str_match(
"cpuid_11", 8, value) ||
3006 __kmp_str_match(
"cpuid-11", 8, value) ||
3007 __kmp_str_match(
"cpuid11", 7, value) ||
3008 __kmp_str_match(
"leaf 11", 7, value) ||
3009 __kmp_str_match(
"leaf_11", 7, value) ||
3010 __kmp_str_match(
"leaf-11", 7, value) ||
3011 __kmp_str_match(
"leaf11", 6, value)) {
3012 __kmp_affinity_top_method = affinity_top_method_x2apicid;
3013 }
else if (__kmp_str_match(
"apic id", 7, value) ||
3014 __kmp_str_match(
"apic_id", 7, value) ||
3015 __kmp_str_match(
"apic-id", 7, value) ||
3016 __kmp_str_match(
"apicid", 6, value) ||
3017 __kmp_str_match(
"cpuid leaf 4", 12, value) ||
3018 __kmp_str_match(
"cpuid_leaf_4", 12, value) ||
3019 __kmp_str_match(
"cpuid-leaf-4", 12, value) ||
3020 __kmp_str_match(
"cpuid leaf4", 11, value) ||
3021 __kmp_str_match(
"cpuid_leaf4", 11, value) ||
3022 __kmp_str_match(
"cpuid-leaf4", 11, value) ||
3023 __kmp_str_match(
"cpuidleaf 4", 11, value) ||
3024 __kmp_str_match(
"cpuidleaf_4", 11, value) ||
3025 __kmp_str_match(
"cpuidleaf-4", 11, value) ||
3026 __kmp_str_match(
"cpuidleaf4", 10, value) ||
3027 __kmp_str_match(
"cpuid 4", 7, value) ||
3028 __kmp_str_match(
"cpuid_4", 7, value) ||
3029 __kmp_str_match(
"cpuid-4", 7, value) ||
3030 __kmp_str_match(
"cpuid4", 6, value) ||
3031 __kmp_str_match(
"leaf 4", 6, value) ||
3032 __kmp_str_match(
"leaf_4", 6, value) ||
3033 __kmp_str_match(
"leaf-4", 6, value) ||
3034 __kmp_str_match(
"leaf4", 5, value)) {
3035 __kmp_affinity_top_method = affinity_top_method_apicid;
3038 else if (__kmp_str_match(
"/proc/cpuinfo", 2, value) ||
3039 __kmp_str_match(
"cpuinfo", 5, value)) {
3040 __kmp_affinity_top_method = affinity_top_method_cpuinfo;
3042 #if KMP_GROUP_AFFINITY
3043 else if (__kmp_str_match(
"group", 1, value)) {
3044 __kmp_affinity_top_method = affinity_top_method_group;
3047 else if (__kmp_str_match(
"flat", 1, value)) {
3048 __kmp_affinity_top_method = affinity_top_method_flat;
3050 KMP_WARNING(StgInvalidValue, name, value);
3054 static void __kmp_stg_print_topology_method(kmp_str_buf_t *buffer,
3055 char const *name,
void *data) {
3056 char const *value = NULL;
3058 switch (__kmp_affinity_top_method) {
3059 case affinity_top_method_default:
3063 case affinity_top_method_all:
3067 #if KMP_ARCH_X86 || KMP_ARCH_X86_64
3068 case affinity_top_method_x2apicid:
3069 value =
"x2APIC id";
3072 case affinity_top_method_apicid:
3078 case affinity_top_method_hwloc:
3083 case affinity_top_method_cpuinfo:
3087 #if KMP_GROUP_AFFINITY
3088 case affinity_top_method_group:
3093 case affinity_top_method_flat:
3098 if (value != NULL) {
3099 __kmp_stg_print_str(buffer, name, value);
3107 static void __kmp_stg_parse_proc_bind(
char const *name,
char const *value,
3109 kmp_setting_t **rivals = (kmp_setting_t **)data;
3112 rc = __kmp_stg_check_rivals(name, value, rivals);
3118 KMP_DEBUG_ASSERT((__kmp_nested_proc_bind.bind_types != NULL) &&
3119 (__kmp_nested_proc_bind.used > 0));
3121 const char *buf = value;
3125 if ((*buf >=
'0') && (*buf <=
'9')) {
3128 num = __kmp_str_to_int(buf, *next);
3129 KMP_ASSERT(num >= 0);
3137 if (__kmp_match_str(
"disabled", buf, &next)) {
3140 #if KMP_AFFINITY_SUPPORTED
3141 __kmp_affinity_type = affinity_disabled;
3143 __kmp_nested_proc_bind.used = 1;
3144 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
3145 }
else if ((num == (
int)proc_bind_false) ||
3146 __kmp_match_str(
"false", buf, &next)) {
3149 #if KMP_AFFINITY_SUPPORTED
3150 __kmp_affinity_type = affinity_none;
3152 __kmp_nested_proc_bind.used = 1;
3153 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
3154 }
else if ((num == (
int)proc_bind_true) ||
3155 __kmp_match_str(
"true", buf, &next)) {
3158 __kmp_nested_proc_bind.used = 1;
3159 __kmp_nested_proc_bind.bind_types[0] = proc_bind_true;
3164 for (scan = buf; *scan !=
'\0'; scan++) {
3171 if (__kmp_nested_proc_bind.size < nelem) {
3172 __kmp_nested_proc_bind.bind_types =
3173 (kmp_proc_bind_t *)KMP_INTERNAL_REALLOC(
3174 __kmp_nested_proc_bind.bind_types,
3175 sizeof(kmp_proc_bind_t) * nelem);
3176 if (__kmp_nested_proc_bind.bind_types == NULL) {
3177 KMP_FATAL(MemoryAllocFailed);
3179 __kmp_nested_proc_bind.size = nelem;
3181 __kmp_nested_proc_bind.used = nelem;
3183 if (nelem > 1 && !__kmp_dflt_max_active_levels_set)
3184 __kmp_dflt_max_active_levels = KMP_MAX_ACTIVE_LEVELS_LIMIT;
3189 enum kmp_proc_bind_t bind;
3191 if ((num == (
int)proc_bind_master) ||
3192 __kmp_match_str(
"master", buf, &next)) {
3195 bind = proc_bind_master;
3196 }
else if ((num == (
int)proc_bind_close) ||
3197 __kmp_match_str(
"close", buf, &next)) {
3200 bind = proc_bind_close;
3201 }
else if ((num == (
int)proc_bind_spread) ||
3202 __kmp_match_str(
"spread", buf, &next)) {
3205 bind = proc_bind_spread;
3207 KMP_WARNING(StgInvalidValue, name, value);
3208 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
3209 __kmp_nested_proc_bind.used = 1;
3213 __kmp_nested_proc_bind.bind_types[i++] = bind;
3217 KMP_DEBUG_ASSERT(*buf ==
',');
3222 if ((*buf >=
'0') && (*buf <=
'9')) {
3225 num = __kmp_str_to_int(buf, *next);
3226 KMP_ASSERT(num >= 0);
3236 KMP_WARNING(ParseExtraCharsWarn, name, buf);
3240 static void __kmp_stg_print_proc_bind(kmp_str_buf_t *buffer,
char const *name,
3242 int nelem = __kmp_nested_proc_bind.used;
3243 if (__kmp_env_format) {
3244 KMP_STR_BUF_PRINT_NAME;
3246 __kmp_str_buf_print(buffer,
" %s", name);
3249 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
3252 __kmp_str_buf_print(buffer,
"='", name);
3253 for (i = 0; i < nelem; i++) {
3254 switch (__kmp_nested_proc_bind.bind_types[i]) {
3255 case proc_bind_false:
3256 __kmp_str_buf_print(buffer,
"false");
3259 case proc_bind_true:
3260 __kmp_str_buf_print(buffer,
"true");
3263 case proc_bind_master:
3264 __kmp_str_buf_print(buffer,
"master");
3267 case proc_bind_close:
3268 __kmp_str_buf_print(buffer,
"close");
3271 case proc_bind_spread:
3272 __kmp_str_buf_print(buffer,
"spread");
3275 case proc_bind_intel:
3276 __kmp_str_buf_print(buffer,
"intel");
3279 case proc_bind_default:
3280 __kmp_str_buf_print(buffer,
"default");
3283 if (i < nelem - 1) {
3284 __kmp_str_buf_print(buffer,
",");
3287 __kmp_str_buf_print(buffer,
"'\n");
3291 static void __kmp_stg_parse_display_affinity(
char const *name,
3292 char const *value,
void *data) {
3293 __kmp_stg_parse_bool(name, value, &__kmp_display_affinity);
3295 static void __kmp_stg_print_display_affinity(kmp_str_buf_t *buffer,
3296 char const *name,
void *data) {
3297 __kmp_stg_print_bool(buffer, name, __kmp_display_affinity);
3299 static void __kmp_stg_parse_affinity_format(
char const *name,
char const *value,
3301 size_t length = KMP_STRLEN(value);
3302 __kmp_strncpy_truncate(__kmp_affinity_format, KMP_AFFINITY_FORMAT_SIZE, value,
3305 static void __kmp_stg_print_affinity_format(kmp_str_buf_t *buffer,
3306 char const *name,
void *data) {
3307 if (__kmp_env_format) {
3308 KMP_STR_BUF_PRINT_NAME_EX(name);
3310 __kmp_str_buf_print(buffer,
" %s='", name);
3312 __kmp_str_buf_print(buffer,
"%s'\n", __kmp_affinity_format);
3334 static void __kmp_stg_parse_allocator(
char const *name,
char const *value,
3336 const char *buf = value;
3337 const char *next, *scan, *start;
3339 omp_allocator_handle_t al;
3340 omp_memspace_handle_t ms = omp_default_mem_space;
3341 bool is_memspace =
false;
3342 int ntraits = 0, count = 0;
3346 const char *delim = strchr(buf,
':');
3347 const char *predef_mem_space = strstr(buf,
"mem_space");
3349 bool is_memalloc = (!predef_mem_space && !delim) ?
true :
false;
3354 for (scan = buf; *scan !=
'\0'; scan++) {
3359 omp_alloctrait_t *traits =
3360 (omp_alloctrait_t *)KMP_ALLOCA(ntraits *
sizeof(omp_alloctrait_t));
3363 #define IS_POWER_OF_TWO(n) (((n) & ((n)-1)) == 0)
3365 #define GET_NEXT(sentinel) \
3368 if (*next == sentinel) \
3374 #define SKIP_PAIR(key) \
3376 char const str_delimiter[] = {',', 0}; \
3377 char *value = __kmp_str_token(CCAST(char *, scan), str_delimiter, \
3378 CCAST(char **, &next)); \
3379 KMP_WARNING(StgInvalidValue, key, value); \
3387 char const str_delimiter[] = {'=', 0}; \
3388 key = __kmp_str_token(CCAST(char *, start), str_delimiter, \
3389 CCAST(char **, &next)); \
3394 while (*next !=
'\0') {
3396 __kmp_match_str(
"fb_data", scan, &next)) {
3400 if (__kmp_match_str(
"omp_high_bw_mem_alloc", scan, &next)) {
3403 if (__kmp_memkind_available) {
3404 __kmp_def_allocator = omp_high_bw_mem_alloc;
3407 KMP_WARNING(OmpNoAllocator,
"omp_high_bw_mem_alloc");
3410 traits[count].key = omp_atk_fb_data;
3411 traits[count].value = RCAST(omp_uintptr_t, omp_high_bw_mem_alloc);
3413 }
else if (__kmp_match_str(
"omp_large_cap_mem_alloc", scan, &next)) {
3416 if (__kmp_memkind_available) {
3417 __kmp_def_allocator = omp_large_cap_mem_alloc;
3420 KMP_WARNING(OmpNoAllocator,
"omp_large_cap_mem_alloc");
3423 traits[count].key = omp_atk_fb_data;
3424 traits[count].value = RCAST(omp_uintptr_t, omp_large_cap_mem_alloc);
3426 }
else if (__kmp_match_str(
"omp_default_mem_alloc", scan, &next)) {
3430 traits[count].key = omp_atk_fb_data;
3431 traits[count].value = RCAST(omp_uintptr_t, omp_default_mem_alloc);
3433 }
else if (__kmp_match_str(
"omp_const_mem_alloc", scan, &next)) {
3436 KMP_WARNING(OmpNoAllocator,
"omp_const_mem_alloc");
3438 traits[count].key = omp_atk_fb_data;
3439 traits[count].value = RCAST(omp_uintptr_t, omp_const_mem_alloc);
3441 }
else if (__kmp_match_str(
"omp_low_lat_mem_alloc", scan, &next)) {
3444 KMP_WARNING(OmpNoAllocator,
"omp_low_lat_mem_alloc");
3446 traits[count].key = omp_atk_fb_data;
3447 traits[count].value = RCAST(omp_uintptr_t, omp_low_lat_mem_alloc);
3449 }
else if (__kmp_match_str(
"omp_cgroup_mem_alloc", scan, &next)) {
3452 KMP_WARNING(OmpNoAllocator,
"omp_cgroup_mem_alloc");
3454 traits[count].key = omp_atk_fb_data;
3455 traits[count].value = RCAST(omp_uintptr_t, omp_cgroup_mem_alloc);
3457 }
else if (__kmp_match_str(
"omp_pteam_mem_alloc", scan, &next)) {
3460 KMP_WARNING(OmpNoAllocator,
"omp_pteam_mem_alloc");
3462 traits[count].key = omp_atk_fb_data;
3463 traits[count].value = RCAST(omp_uintptr_t, omp_pteam_mem_alloc);
3465 }
else if (__kmp_match_str(
"omp_thread_mem_alloc", scan, &next)) {
3468 KMP_WARNING(OmpNoAllocator,
"omp_thread_mem_alloc");
3470 traits[count].key = omp_atk_fb_data;
3471 traits[count].value = RCAST(omp_uintptr_t, omp_thread_mem_alloc);
3481 __kmp_def_allocator = omp_default_mem_alloc;
3482 if (next == buf || *next !=
'\0') {
3484 KMP_WARNING(StgInvalidValue, name, value);
3489 if (count == ntraits)
3495 if (__kmp_match_str(
"omp_default_mem_space", scan, &next)) {
3497 ms = omp_default_mem_space;
3498 }
else if (__kmp_match_str(
"omp_large_cap_mem_space", scan, &next)) {
3500 ms = omp_large_cap_mem_space;
3501 }
else if (__kmp_match_str(
"omp_const_mem_space", scan, &next)) {
3503 ms = omp_const_mem_space;
3504 }
else if (__kmp_match_str(
"omp_high_bw_mem_space", scan, &next)) {
3506 ms = omp_high_bw_mem_space;
3507 }
else if (__kmp_match_str(
"omp_low_lat_mem_space", scan, &next)) {
3509 ms = omp_low_lat_mem_space;
3511 __kmp_def_allocator = omp_default_mem_alloc;
3512 if (next == buf || *next !=
'\0') {
3514 KMP_WARNING(StgInvalidValue, name, value);
3523 if (__kmp_match_str(
"sync_hint", scan, &next)) {
3525 traits[count].key = omp_atk_sync_hint;
3526 if (__kmp_match_str(
"contended", scan, &next)) {
3527 traits[count].value = omp_atv_contended;
3528 }
else if (__kmp_match_str(
"uncontended", scan, &next)) {
3529 traits[count].value = omp_atv_uncontended;
3530 }
else if (__kmp_match_str(
"serialized", scan, &next)) {
3531 traits[count].value = omp_atv_serialized;
3532 }
else if (__kmp_match_str(
"private", scan, &next)) {
3533 traits[count].value = omp_atv_private;
3539 }
else if (__kmp_match_str(
"alignment", scan, &next)) {
3541 if (!isdigit(*next)) {
3547 int n = __kmp_str_to_int(scan,
',');
3548 if (n < 0 || !IS_POWER_OF_TWO(n)) {
3553 traits[count].key = omp_atk_alignment;
3554 traits[count].value = n;
3555 }
else if (__kmp_match_str(
"access", scan, &next)) {
3557 traits[count].key = omp_atk_access;
3558 if (__kmp_match_str(
"all", scan, &next)) {
3559 traits[count].value = omp_atv_all;
3560 }
else if (__kmp_match_str(
"cgroup", scan, &next)) {
3561 traits[count].value = omp_atv_cgroup;
3562 }
else if (__kmp_match_str(
"pteam", scan, &next)) {
3563 traits[count].value = omp_atv_pteam;
3564 }
else if (__kmp_match_str(
"thread", scan, &next)) {
3565 traits[count].value = omp_atv_thread;
3571 }
else if (__kmp_match_str(
"pool_size", scan, &next)) {
3573 if (!isdigit(*next)) {
3579 int n = __kmp_str_to_int(scan,
',');
3585 traits[count].key = omp_atk_pool_size;
3586 traits[count].value = n;
3587 }
else if (__kmp_match_str(
"fallback", scan, &next)) {
3589 traits[count].key = omp_atk_fallback;
3590 if (__kmp_match_str(
"default_mem_fb", scan, &next)) {
3591 traits[count].value = omp_atv_default_mem_fb;
3592 }
else if (__kmp_match_str(
"null_fb", scan, &next)) {
3593 traits[count].value = omp_atv_null_fb;
3594 }
else if (__kmp_match_str(
"abort_fb", scan, &next)) {
3595 traits[count].value = omp_atv_abort_fb;
3596 }
else if (__kmp_match_str(
"allocator_fb", scan, &next)) {
3597 traits[count].value = omp_atv_allocator_fb;
3603 }
else if (__kmp_match_str(
"pinned", scan, &next)) {
3605 traits[count].key = omp_atk_pinned;
3606 if (__kmp_str_match_true(next)) {
3607 traits[count].value = omp_atv_true;
3608 }
else if (__kmp_str_match_false(next)) {
3609 traits[count].value = omp_atv_false;
3615 }
else if (__kmp_match_str(
"partition", scan, &next)) {
3617 traits[count].key = omp_atk_partition;
3618 if (__kmp_match_str(
"environment", scan, &next)) {
3619 traits[count].value = omp_atv_environment;
3620 }
else if (__kmp_match_str(
"nearest", scan, &next)) {
3621 traits[count].value = omp_atv_nearest;
3622 }
else if (__kmp_match_str(
"blocked", scan, &next)) {
3623 traits[count].value = omp_atv_blocked;
3624 }
else if (__kmp_match_str(
"interleaved", scan, &next)) {
3625 traits[count].value = omp_atv_interleaved;
3638 if (count == ntraits)
3644 al = __kmpc_init_allocator(__kmp_get_gtid(), ms, ntraits, traits);
3645 __kmp_def_allocator = (al == omp_null_allocator) ? omp_default_mem_alloc : al;
3648 static void __kmp_stg_print_allocator(kmp_str_buf_t *buffer,
char const *name,
3650 if (__kmp_def_allocator == omp_default_mem_alloc) {
3651 __kmp_stg_print_str(buffer, name,
"omp_default_mem_alloc");
3652 }
else if (__kmp_def_allocator == omp_high_bw_mem_alloc) {
3653 __kmp_stg_print_str(buffer, name,
"omp_high_bw_mem_alloc");
3654 }
else if (__kmp_def_allocator == omp_large_cap_mem_alloc) {
3655 __kmp_stg_print_str(buffer, name,
"omp_large_cap_mem_alloc");
3656 }
else if (__kmp_def_allocator == omp_const_mem_alloc) {
3657 __kmp_stg_print_str(buffer, name,
"omp_const_mem_alloc");
3658 }
else if (__kmp_def_allocator == omp_low_lat_mem_alloc) {
3659 __kmp_stg_print_str(buffer, name,
"omp_low_lat_mem_alloc");
3660 }
else if (__kmp_def_allocator == omp_cgroup_mem_alloc) {
3661 __kmp_stg_print_str(buffer, name,
"omp_cgroup_mem_alloc");
3662 }
else if (__kmp_def_allocator == omp_pteam_mem_alloc) {
3663 __kmp_stg_print_str(buffer, name,
"omp_pteam_mem_alloc");
3664 }
else if (__kmp_def_allocator == omp_thread_mem_alloc) {
3665 __kmp_stg_print_str(buffer, name,
"omp_thread_mem_alloc");
3672 static void __kmp_stg_parse_omp_dynamic(
char const *name,
char const *value,
3674 __kmp_stg_parse_bool(name, value, &(__kmp_global.g.g_dynamic));
3677 static void __kmp_stg_print_omp_dynamic(kmp_str_buf_t *buffer,
char const *name,
3679 __kmp_stg_print_bool(buffer, name, __kmp_global.g.g_dynamic);
3682 static void __kmp_stg_parse_kmp_dynamic_mode(
char const *name,
3683 char const *value,
void *data) {
3684 if (TCR_4(__kmp_init_parallel)) {
3685 KMP_WARNING(EnvParallelWarn, name);
3686 __kmp_env_toPrint(name, 0);
3689 #ifdef USE_LOAD_BALANCE
3690 else if (__kmp_str_match(
"load balance", 2, value) ||
3691 __kmp_str_match(
"load_balance", 2, value) ||
3692 __kmp_str_match(
"load-balance", 2, value) ||
3693 __kmp_str_match(
"loadbalance", 2, value) ||
3694 __kmp_str_match(
"balance", 1, value)) {
3695 __kmp_global.g.g_dynamic_mode = dynamic_load_balance;
3698 else if (__kmp_str_match(
"thread limit", 1, value) ||
3699 __kmp_str_match(
"thread_limit", 1, value) ||
3700 __kmp_str_match(
"thread-limit", 1, value) ||
3701 __kmp_str_match(
"threadlimit", 1, value) ||
3702 __kmp_str_match(
"limit", 2, value)) {
3703 __kmp_global.g.g_dynamic_mode = dynamic_thread_limit;
3704 }
else if (__kmp_str_match(
"random", 1, value)) {
3705 __kmp_global.g.g_dynamic_mode = dynamic_random;
3707 KMP_WARNING(StgInvalidValue, name, value);
3711 static void __kmp_stg_print_kmp_dynamic_mode(kmp_str_buf_t *buffer,
3712 char const *name,
void *data) {
3714 if (__kmp_global.g.g_dynamic_mode == dynamic_default) {
3715 __kmp_str_buf_print(buffer,
" %s: %s \n", name, KMP_I18N_STR(NotDefined));
3717 #ifdef USE_LOAD_BALANCE
3718 else if (__kmp_global.g.g_dynamic_mode == dynamic_load_balance) {
3719 __kmp_stg_print_str(buffer, name,
"load balance");
3722 else if (__kmp_global.g.g_dynamic_mode == dynamic_thread_limit) {
3723 __kmp_stg_print_str(buffer, name,
"thread limit");
3724 }
else if (__kmp_global.g.g_dynamic_mode == dynamic_random) {
3725 __kmp_stg_print_str(buffer, name,
"random");
3732 #ifdef USE_LOAD_BALANCE
3737 static void __kmp_stg_parse_ld_balance_interval(
char const *name,
3738 char const *value,
void *data) {
3739 double interval = __kmp_convert_to_double(value);
3740 if (interval >= 0) {
3741 __kmp_load_balance_interval = interval;
3743 KMP_WARNING(StgInvalidValue, name, value);
3747 static void __kmp_stg_print_ld_balance_interval(kmp_str_buf_t *buffer,
3748 char const *name,
void *data) {
3750 __kmp_str_buf_print(buffer,
" %s=%8.6f\n", name,
3751 __kmp_load_balance_interval);
3760 static void __kmp_stg_parse_init_at_fork(
char const *name,
char const *value,
3762 __kmp_stg_parse_bool(name, value, &__kmp_need_register_atfork);
3763 if (__kmp_need_register_atfork) {
3764 __kmp_need_register_atfork_specified = TRUE;
3768 static void __kmp_stg_print_init_at_fork(kmp_str_buf_t *buffer,
3769 char const *name,
void *data) {
3770 __kmp_stg_print_bool(buffer, name, __kmp_need_register_atfork_specified);
3776 static void __kmp_stg_parse_schedule(
char const *name,
char const *value,
3779 if (value != NULL) {
3780 size_t length = KMP_STRLEN(value);
3781 if (length > INT_MAX) {
3782 KMP_WARNING(LongValue, name);
3784 const char *semicolon;
3785 if (value[length - 1] ==
'"' || value[length - 1] ==
'\'')
3786 KMP_WARNING(UnbalancedQuotes, name);
3790 semicolon = strchr(value,
';');
3791 if (*value && semicolon != value) {
3792 const char *comma = strchr(value,
',');
3799 if (!__kmp_strcasecmp_with_sentinel(
"static", value, sentinel)) {
3800 if (!__kmp_strcasecmp_with_sentinel(
"greedy", comma,
';')) {
3801 __kmp_static = kmp_sch_static_greedy;
3803 }
else if (!__kmp_strcasecmp_with_sentinel(
"balanced", comma,
3805 __kmp_static = kmp_sch_static_balanced;
3808 }
else if (!__kmp_strcasecmp_with_sentinel(
"guided", value,
3810 if (!__kmp_strcasecmp_with_sentinel(
"iterative", comma,
';')) {
3811 __kmp_guided = kmp_sch_guided_iterative_chunked;
3813 }
else if (!__kmp_strcasecmp_with_sentinel(
"analytical", comma,
3816 __kmp_guided = kmp_sch_guided_analytical_chunked;
3820 KMP_WARNING(InvalidClause, name, value);
3822 KMP_WARNING(EmptyClause, name);
3823 }
while ((value = semicolon ? semicolon + 1 : NULL));
3829 static void __kmp_stg_print_schedule(kmp_str_buf_t *buffer,
char const *name,
3831 if (__kmp_env_format) {
3832 KMP_STR_BUF_PRINT_NAME_EX(name);
3834 __kmp_str_buf_print(buffer,
" %s='", name);
3836 if (__kmp_static == kmp_sch_static_greedy) {
3837 __kmp_str_buf_print(buffer,
"%s",
"static,greedy");
3838 }
else if (__kmp_static == kmp_sch_static_balanced) {
3839 __kmp_str_buf_print(buffer,
"%s",
"static,balanced");
3841 if (__kmp_guided == kmp_sch_guided_iterative_chunked) {
3842 __kmp_str_buf_print(buffer,
";%s'\n",
"guided,iterative");
3843 }
else if (__kmp_guided == kmp_sch_guided_analytical_chunked) {
3844 __kmp_str_buf_print(buffer,
";%s'\n",
"guided,analytical");
3851 static inline void __kmp_omp_schedule_restore() {
3852 #if KMP_USE_HIER_SCHED
3853 __kmp_hier_scheds.deallocate();
3863 static const char *__kmp_parse_single_omp_schedule(
const char *name,
3865 bool parse_hier =
false) {
3867 const char *ptr = value;
3874 while (*delim !=
',' && *delim !=
':' && *delim !=
'\0')
3876 #if KMP_USE_HIER_SCHED
3877 kmp_hier_layer_e layer = kmp_hier_layer_e::LAYER_THREAD;
3879 if (*delim ==
',') {
3880 if (!__kmp_strcasecmp_with_sentinel(
"L1", ptr,
',')) {
3881 layer = kmp_hier_layer_e::LAYER_L1;
3882 }
else if (!__kmp_strcasecmp_with_sentinel(
"L2", ptr,
',')) {
3883 layer = kmp_hier_layer_e::LAYER_L2;
3884 }
else if (!__kmp_strcasecmp_with_sentinel(
"L3", ptr,
',')) {
3885 layer = kmp_hier_layer_e::LAYER_L3;
3886 }
else if (!__kmp_strcasecmp_with_sentinel(
"NUMA", ptr,
',')) {
3887 layer = kmp_hier_layer_e::LAYER_NUMA;
3890 if (layer != kmp_hier_layer_e::LAYER_THREAD && *delim !=
',') {
3892 KMP_WARNING(StgInvalidValue, name, value);
3893 __kmp_omp_schedule_restore();
3895 }
else if (layer != kmp_hier_layer_e::LAYER_THREAD) {
3897 while (*delim !=
',' && *delim !=
':' && *delim !=
'\0')
3904 if (*delim ==
':') {
3905 if (!__kmp_strcasecmp_with_sentinel(
"monotonic", ptr, *delim)) {
3908 while (*delim !=
',' && *delim !=
':' && *delim !=
'\0')
3910 }
else if (!__kmp_strcasecmp_with_sentinel(
"nonmonotonic", ptr, *delim)) {
3913 while (*delim !=
',' && *delim !=
':' && *delim !=
'\0')
3915 }
else if (!parse_hier) {
3917 KMP_WARNING(StgInvalidValue, name, value);
3918 __kmp_omp_schedule_restore();
3923 if (!__kmp_strcasecmp_with_sentinel(
"dynamic", ptr, *delim))
3924 sched = kmp_sch_dynamic_chunked;
3925 else if (!__kmp_strcasecmp_with_sentinel(
"guided", ptr, *delim))
3928 else if (!__kmp_strcasecmp_with_sentinel(
"auto", ptr, *delim))
3930 else if (!__kmp_strcasecmp_with_sentinel(
"trapezoidal", ptr, *delim))
3931 sched = kmp_sch_trapezoidal;
3932 else if (!__kmp_strcasecmp_with_sentinel(
"static", ptr, *delim))
3934 #if KMP_STATIC_STEAL_ENABLED
3935 else if (!__kmp_strcasecmp_with_sentinel(
"static_steal", ptr, *delim))
3936 sched = kmp_sch_static_steal;
3940 KMP_WARNING(StgInvalidValue, name, value);
3941 __kmp_omp_schedule_restore();
3946 if (*delim ==
',') {
3949 if (!isdigit(*ptr)) {
3951 KMP_WARNING(StgInvalidValue, name, value);
3952 __kmp_omp_schedule_restore();
3958 __kmp_msg(kmp_ms_warning, KMP_MSG(IgnoreChunk, name, delim),
3962 sched = kmp_sch_static_chunked;
3963 chunk = __kmp_str_to_int(delim + 1, *ptr);
3965 chunk = KMP_DEFAULT_CHUNK;
3966 __kmp_msg(kmp_ms_warning, KMP_MSG(InvalidChunk, name, delim),
3968 KMP_INFORM(Using_int_Value, name, __kmp_chunk);
3977 }
else if (chunk > KMP_MAX_CHUNK) {
3978 chunk = KMP_MAX_CHUNK;
3979 __kmp_msg(kmp_ms_warning, KMP_MSG(LargeChunk, name, delim),
3981 KMP_INFORM(Using_int_Value, name, chunk);
3988 SCHEDULE_SET_MODIFIERS(sched, sched_modifier);
3990 #if KMP_USE_HIER_SCHED
3991 if (layer != kmp_hier_layer_e::LAYER_THREAD) {
3992 __kmp_hier_scheds.append(sched, chunk, layer);
3996 __kmp_chunk = chunk;
3997 __kmp_sched = sched;
4002 static void __kmp_stg_parse_omp_schedule(
char const *name,
char const *value,
4005 const char *ptr = value;
4008 length = KMP_STRLEN(value);
4010 if (value[length - 1] ==
'"' || value[length - 1] ==
'\'')
4011 KMP_WARNING(UnbalancedQuotes, name);
4013 #if KMP_USE_HIER_SCHED
4014 if (!__kmp_strcasecmp_with_sentinel(
"EXPERIMENTAL", ptr,
' ')) {
4017 while ((ptr = __kmp_parse_single_omp_schedule(name, ptr,
true))) {
4018 while (*ptr ==
' ' || *ptr ==
'\t' || *ptr ==
':')
4025 __kmp_parse_single_omp_schedule(name, ptr);
4027 KMP_WARNING(EmptyString, name);
4029 #if KMP_USE_HIER_SCHED
4030 __kmp_hier_scheds.sort();
4032 K_DIAG(1, (
"__kmp_static == %d\n", __kmp_static))
4033 K_DIAG(1, (
"__kmp_guided == %d\n", __kmp_guided))
4034 K_DIAG(1, (
"__kmp_sched == %d\n", __kmp_sched))
4035 K_DIAG(1, (
"__kmp_chunk == %d\n", __kmp_chunk))
4038 static void __kmp_stg_print_omp_schedule(kmp_str_buf_t *buffer,
4039 char const *name,
void *data) {
4040 if (__kmp_env_format) {
4041 KMP_STR_BUF_PRINT_NAME_EX(name);
4043 __kmp_str_buf_print(buffer,
" %s='", name);
4045 enum sched_type sched = SCHEDULE_WITHOUT_MODIFIERS(__kmp_sched);
4046 if (SCHEDULE_HAS_MONOTONIC(__kmp_sched)) {
4047 __kmp_str_buf_print(buffer,
"monotonic:");
4048 }
else if (SCHEDULE_HAS_NONMONOTONIC(__kmp_sched)) {
4049 __kmp_str_buf_print(buffer,
"nonmonotonic:");
4053 case kmp_sch_dynamic_chunked:
4054 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"dynamic", __kmp_chunk);
4056 case kmp_sch_guided_iterative_chunked:
4057 case kmp_sch_guided_analytical_chunked:
4058 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"guided", __kmp_chunk);
4060 case kmp_sch_trapezoidal:
4061 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"trapezoidal", __kmp_chunk);
4064 case kmp_sch_static_chunked:
4065 case kmp_sch_static_balanced:
4066 case kmp_sch_static_greedy:
4067 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"static", __kmp_chunk);
4069 case kmp_sch_static_steal:
4070 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"static_steal", __kmp_chunk);
4073 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"auto", __kmp_chunk);
4078 case kmp_sch_dynamic_chunked:
4079 __kmp_str_buf_print(buffer,
"%s'\n",
"dynamic");
4081 case kmp_sch_guided_iterative_chunked:
4082 case kmp_sch_guided_analytical_chunked:
4083 __kmp_str_buf_print(buffer,
"%s'\n",
"guided");
4085 case kmp_sch_trapezoidal:
4086 __kmp_str_buf_print(buffer,
"%s'\n",
"trapezoidal");
4089 case kmp_sch_static_chunked:
4090 case kmp_sch_static_balanced:
4091 case kmp_sch_static_greedy:
4092 __kmp_str_buf_print(buffer,
"%s'\n",
"static");
4094 case kmp_sch_static_steal:
4095 __kmp_str_buf_print(buffer,
"%s'\n",
"static_steal");
4098 __kmp_str_buf_print(buffer,
"%s'\n",
"auto");
4104 #if KMP_USE_HIER_SCHED
4107 static void __kmp_stg_parse_kmp_hand_thread(
char const *name,
char const *value,
4109 __kmp_stg_parse_bool(name, value, &(__kmp_dispatch_hand_threading));
4112 static void __kmp_stg_print_kmp_hand_thread(kmp_str_buf_t *buffer,
4113 char const *name,
void *data) {
4114 __kmp_stg_print_bool(buffer, name, __kmp_dispatch_hand_threading);
4121 static void __kmp_stg_parse_atomic_mode(
char const *name,
char const *value,
4127 #ifdef KMP_GOMP_COMPAT
4130 __kmp_stg_parse_int(name, value, 0, max, &mode);
4135 __kmp_atomic_mode = mode;
4139 static void __kmp_stg_print_atomic_mode(kmp_str_buf_t *buffer,
char const *name,
4141 __kmp_stg_print_int(buffer, name, __kmp_atomic_mode);
4147 static void __kmp_stg_parse_consistency_check(
char const *name,
4148 char const *value,
void *data) {
4149 if (!__kmp_strcasecmp_with_sentinel(
"all", value, 0)) {
4155 __kmp_env_consistency_check = TRUE;
4156 }
else if (!__kmp_strcasecmp_with_sentinel(
"none", value, 0)) {
4157 __kmp_env_consistency_check = FALSE;
4159 KMP_WARNING(StgInvalidValue, name, value);
4163 static void __kmp_stg_print_consistency_check(kmp_str_buf_t *buffer,
4164 char const *name,
void *data) {
4166 const char *value = NULL;
4168 if (__kmp_env_consistency_check) {
4174 if (value != NULL) {
4175 __kmp_stg_print_str(buffer, name, value);
4186 static void __kmp_stg_parse_itt_prepare_delay(
char const *name,
4187 char const *value,
void *data) {
4191 __kmp_stg_parse_int(name, value, 0, INT_MAX, &delay);
4192 __kmp_itt_prepare_delay = delay;
4195 static void __kmp_stg_print_itt_prepare_delay(kmp_str_buf_t *buffer,
4196 char const *name,
void *data) {
4197 __kmp_stg_print_uint64(buffer, name, __kmp_itt_prepare_delay);
4207 static void __kmp_stg_parse_malloc_pool_incr(
char const *name,
4208 char const *value,
void *data) {
4209 __kmp_stg_parse_size(name, value, KMP_MIN_MALLOC_POOL_INCR,
4210 KMP_MAX_MALLOC_POOL_INCR, NULL, &__kmp_malloc_pool_incr,
4214 static void __kmp_stg_print_malloc_pool_incr(kmp_str_buf_t *buffer,
4215 char const *name,
void *data) {
4216 __kmp_stg_print_size(buffer, name, __kmp_malloc_pool_incr);
4225 static void __kmp_stg_parse_par_range_env(
char const *name,
char const *value,
4227 __kmp_stg_parse_par_range(name, value, &__kmp_par_range,
4228 __kmp_par_range_routine, __kmp_par_range_filename,
4229 &__kmp_par_range_lb, &__kmp_par_range_ub);
4232 static void __kmp_stg_print_par_range_env(kmp_str_buf_t *buffer,
4233 char const *name,
void *data) {
4234 if (__kmp_par_range != 0) {
4235 __kmp_stg_print_str(buffer, name, par_range_to_print);
4244 static void __kmp_stg_parse_gtid_mode(
char const *name,
char const *value,
4254 #ifdef KMP_TDATA_GTID
4257 __kmp_stg_parse_int(name, value, 0, max, &mode);
4261 __kmp_adjust_gtid_mode = TRUE;
4263 __kmp_gtid_mode = mode;
4264 __kmp_adjust_gtid_mode = FALSE;
4268 static void __kmp_stg_print_gtid_mode(kmp_str_buf_t *buffer,
char const *name,
4270 if (__kmp_adjust_gtid_mode) {
4271 __kmp_stg_print_int(buffer, name, 0);
4273 __kmp_stg_print_int(buffer, name, __kmp_gtid_mode);
4280 static void __kmp_stg_parse_lock_block(
char const *name,
char const *value,
4282 __kmp_stg_parse_int(name, value, 0, KMP_INT_MAX, &__kmp_num_locks_in_block);
4285 static void __kmp_stg_print_lock_block(kmp_str_buf_t *buffer,
char const *name,
4287 __kmp_stg_print_int(buffer, name, __kmp_num_locks_in_block);
4293 #if KMP_USE_DYNAMIC_LOCK
4294 #define KMP_STORE_LOCK_SEQ(a) (__kmp_user_lock_seq = lockseq_##a)
4296 #define KMP_STORE_LOCK_SEQ(a)
4299 static void __kmp_stg_parse_lock_kind(
char const *name,
char const *value,
4301 if (__kmp_init_user_locks) {
4302 KMP_WARNING(EnvLockWarn, name);
4306 if (__kmp_str_match(
"tas", 2, value) ||
4307 __kmp_str_match(
"test and set", 2, value) ||
4308 __kmp_str_match(
"test_and_set", 2, value) ||
4309 __kmp_str_match(
"test-and-set", 2, value) ||
4310 __kmp_str_match(
"test andset", 2, value) ||
4311 __kmp_str_match(
"test_andset", 2, value) ||
4312 __kmp_str_match(
"test-andset", 2, value) ||
4313 __kmp_str_match(
"testand set", 2, value) ||
4314 __kmp_str_match(
"testand_set", 2, value) ||
4315 __kmp_str_match(
"testand-set", 2, value) ||
4316 __kmp_str_match(
"testandset", 2, value)) {
4317 __kmp_user_lock_kind = lk_tas;
4318 KMP_STORE_LOCK_SEQ(tas);
4321 else if (__kmp_str_match(
"futex", 1, value)) {
4322 if (__kmp_futex_determine_capable()) {
4323 __kmp_user_lock_kind = lk_futex;
4324 KMP_STORE_LOCK_SEQ(futex);
4326 KMP_WARNING(FutexNotSupported, name, value);
4330 else if (__kmp_str_match(
"ticket", 2, value)) {
4331 __kmp_user_lock_kind = lk_ticket;
4332 KMP_STORE_LOCK_SEQ(ticket);
4333 }
else if (__kmp_str_match(
"queuing", 1, value) ||
4334 __kmp_str_match(
"queue", 1, value)) {
4335 __kmp_user_lock_kind = lk_queuing;
4336 KMP_STORE_LOCK_SEQ(queuing);
4337 }
else if (__kmp_str_match(
"drdpa ticket", 1, value) ||
4338 __kmp_str_match(
"drdpa_ticket", 1, value) ||
4339 __kmp_str_match(
"drdpa-ticket", 1, value) ||
4340 __kmp_str_match(
"drdpaticket", 1, value) ||
4341 __kmp_str_match(
"drdpa", 1, value)) {
4342 __kmp_user_lock_kind = lk_drdpa;
4343 KMP_STORE_LOCK_SEQ(drdpa);
4345 #if KMP_USE_ADAPTIVE_LOCKS
4346 else if (__kmp_str_match(
"adaptive", 1, value)) {
4347 if (__kmp_cpuinfo.rtm) {
4348 __kmp_user_lock_kind = lk_adaptive;
4349 KMP_STORE_LOCK_SEQ(adaptive);
4351 KMP_WARNING(AdaptiveNotSupported, name, value);
4352 __kmp_user_lock_kind = lk_queuing;
4353 KMP_STORE_LOCK_SEQ(queuing);
4357 #if KMP_USE_DYNAMIC_LOCK && KMP_USE_TSX
4358 else if (__kmp_str_match(
"rtm_queuing", 1, value)) {
4359 if (__kmp_cpuinfo.rtm) {
4360 __kmp_user_lock_kind = lk_rtm_queuing;
4361 KMP_STORE_LOCK_SEQ(rtm_queuing);
4363 KMP_WARNING(AdaptiveNotSupported, name, value);
4364 __kmp_user_lock_kind = lk_queuing;
4365 KMP_STORE_LOCK_SEQ(queuing);
4367 }
else if (__kmp_str_match(
"rtm_spin", 1, value)) {
4368 if (__kmp_cpuinfo.rtm) {
4369 __kmp_user_lock_kind = lk_rtm_spin;
4370 KMP_STORE_LOCK_SEQ(rtm_spin);
4372 KMP_WARNING(AdaptiveNotSupported, name, value);
4373 __kmp_user_lock_kind = lk_tas;
4374 KMP_STORE_LOCK_SEQ(queuing);
4376 }
else if (__kmp_str_match(
"hle", 1, value)) {
4377 __kmp_user_lock_kind = lk_hle;
4378 KMP_STORE_LOCK_SEQ(hle);
4382 KMP_WARNING(StgInvalidValue, name, value);
4386 static void __kmp_stg_print_lock_kind(kmp_str_buf_t *buffer,
char const *name,
4388 const char *value = NULL;
4390 switch (__kmp_user_lock_kind) {
4405 #if KMP_USE_DYNAMIC_LOCK && KMP_USE_TSX
4406 case lk_rtm_queuing:
4407 value =
"rtm_queuing";
4430 #if KMP_USE_ADAPTIVE_LOCKS
4437 if (value != NULL) {
4438 __kmp_stg_print_str(buffer, name, value);
4447 static void __kmp_stg_parse_spin_backoff_params(
const char *name,
4448 const char *value,
void *data) {
4449 const char *next = value;
4452 int prev_comma = FALSE;
4455 kmp_uint32 max_backoff = __kmp_spin_backoff_params.max_backoff;
4456 kmp_uint32 min_tick = __kmp_spin_backoff_params.min_tick;
4460 for (i = 0; i < 3; i++) {
4463 if (*next ==
'\0') {
4468 if (((*next < '0' || *next >
'9') && *next !=
',') || total > 2) {
4469 KMP_WARNING(EnvSyntaxError, name, value);
4475 if (total == 0 || prev_comma) {
4483 if (*next >=
'0' && *next <=
'9') {
4485 const char *buf = next;
4486 char const *msg = NULL;
4491 const char *tmp = next;
4493 if ((*next ==
' ' || *next ==
'\t') && (*tmp >=
'0' && *tmp <=
'9')) {
4494 KMP_WARNING(EnvSpacesNotAllowed, name, value);
4498 num = __kmp_str_to_int(buf, *next);
4500 msg = KMP_I18N_STR(ValueTooSmall);
4502 }
else if (num > KMP_INT_MAX) {
4503 msg = KMP_I18N_STR(ValueTooLarge);
4508 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
4509 KMP_INFORM(Using_int_Value, name, num);
4513 }
else if (total == 2) {
4518 KMP_DEBUG_ASSERT(total > 0);
4520 KMP_WARNING(EnvSyntaxError, name, value);
4523 __kmp_spin_backoff_params.max_backoff = max_backoff;
4524 __kmp_spin_backoff_params.min_tick = min_tick;
4527 static void __kmp_stg_print_spin_backoff_params(kmp_str_buf_t *buffer,
4528 char const *name,
void *data) {
4529 if (__kmp_env_format) {
4530 KMP_STR_BUF_PRINT_NAME_EX(name);
4532 __kmp_str_buf_print(buffer,
" %s='", name);
4534 __kmp_str_buf_print(buffer,
"%d,%d'\n", __kmp_spin_backoff_params.max_backoff,
4535 __kmp_spin_backoff_params.min_tick);
4538 #if KMP_USE_ADAPTIVE_LOCKS
4545 static void __kmp_stg_parse_adaptive_lock_props(
const char *name,
4546 const char *value,
void *data) {
4547 int max_retries = 0;
4548 int max_badness = 0;
4550 const char *next = value;
4553 int prev_comma = FALSE;
4559 for (i = 0; i < 3; i++) {
4562 if (*next ==
'\0') {
4567 if (((*next < '0' || *next >
'9') && *next !=
',') || total > 2) {
4568 KMP_WARNING(EnvSyntaxError, name, value);
4574 if (total == 0 || prev_comma) {
4582 if (*next >=
'0' && *next <=
'9') {
4584 const char *buf = next;
4585 char const *msg = NULL;
4590 const char *tmp = next;
4592 if ((*next ==
' ' || *next ==
'\t') && (*tmp >=
'0' && *tmp <=
'9')) {
4593 KMP_WARNING(EnvSpacesNotAllowed, name, value);
4597 num = __kmp_str_to_int(buf, *next);
4599 msg = KMP_I18N_STR(ValueTooSmall);
4601 }
else if (num > KMP_INT_MAX) {
4602 msg = KMP_I18N_STR(ValueTooLarge);
4607 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
4608 KMP_INFORM(Using_int_Value, name, num);
4612 }
else if (total == 2) {
4617 KMP_DEBUG_ASSERT(total > 0);
4619 KMP_WARNING(EnvSyntaxError, name, value);
4622 __kmp_adaptive_backoff_params.max_soft_retries = max_retries;
4623 __kmp_adaptive_backoff_params.max_badness = max_badness;
4626 static void __kmp_stg_print_adaptive_lock_props(kmp_str_buf_t *buffer,
4627 char const *name,
void *data) {
4628 if (__kmp_env_format) {
4629 KMP_STR_BUF_PRINT_NAME_EX(name);
4631 __kmp_str_buf_print(buffer,
" %s='", name);
4633 __kmp_str_buf_print(buffer,
"%d,%d'\n",
4634 __kmp_adaptive_backoff_params.max_soft_retries,
4635 __kmp_adaptive_backoff_params.max_badness);
4638 #if KMP_DEBUG_ADAPTIVE_LOCKS
4640 static void __kmp_stg_parse_speculative_statsfile(
char const *name,
4643 __kmp_stg_parse_file(name, value,
"", CCAST(
char**, &__kmp_speculative_statsfile));
4646 static void __kmp_stg_print_speculative_statsfile(kmp_str_buf_t *buffer,
4649 if (__kmp_str_match(
"-", 0, __kmp_speculative_statsfile)) {
4650 __kmp_stg_print_str(buffer, name,
"stdout");
4652 __kmp_stg_print_str(buffer, name, __kmp_speculative_statsfile);
4668 #define MAX_T_LEVEL 5
4669 #define MAX_STR_LEN 512
4670 static void __kmp_stg_parse_hw_subset(
char const *name,
char const *value,
4674 kmp_setting_t **rivals = (kmp_setting_t **)data;
4675 if (strcmp(name,
"KMP_PLACE_THREADS") == 0) {
4676 KMP_INFORM(EnvVarDeprecated, name,
"KMP_HW_SUBSET");
4678 if (__kmp_stg_check_rivals(name, value, rivals)) {
4682 char *components[MAX_T_LEVEL];
4683 char const *digits =
"0123456789";
4684 char input[MAX_STR_LEN];
4685 size_t len = 0, mlen = MAX_STR_LEN;
4688 char *pos = CCAST(
char *, value);
4689 while (*pos && mlen) {
4691 if (len == 0 && *pos ==
':') {
4692 __kmp_hws_abs_flag = 1;
4694 input[len] = (char)(toupper(*pos));
4695 if (input[len] ==
'X')
4697 if (input[len] ==
'O' && strchr(digits, *(pos + 1)))
4705 if (len == 0 || mlen == 0)
4708 __kmp_hws_requested = 1;
4711 components[level++] = pos;
4712 while ((pos = strchr(pos,
','))) {
4713 if (level >= MAX_T_LEVEL)
4716 components[level++] = ++pos;
4719 for (
int i = 0; i < level; ++i) {
4721 int num = atoi(components[i]);
4722 if ((pos = strchr(components[i],
'@'))) {
4723 offset = atoi(pos + 1);
4726 pos = components[i] + strspn(components[i], digits);
4727 if (pos == components[i])
4732 if (__kmp_hws_socket.num > 0)
4734 __kmp_hws_socket.num = num;
4735 __kmp_hws_socket.offset = offset;
4738 if (__kmp_hws_node.num > 0)
4740 __kmp_hws_node.num = num;
4741 __kmp_hws_node.offset = offset;
4744 if (*(pos + 1) ==
'2') {
4745 if (__kmp_hws_tile.num > 0)
4747 __kmp_hws_tile.num = num;
4748 __kmp_hws_tile.offset = offset;
4749 }
else if (*(pos + 1) ==
'3') {
4750 if (__kmp_hws_socket.num > 0)
4752 __kmp_hws_socket.num = num;
4753 __kmp_hws_socket.offset = offset;
4754 }
else if (*(pos + 1) ==
'1') {
4755 if (__kmp_hws_core.num > 0)
4757 __kmp_hws_core.num = num;
4758 __kmp_hws_core.offset = offset;
4762 if (*(pos + 1) !=
'A') {
4763 if (__kmp_hws_core.num > 0)
4765 __kmp_hws_core.num = num;
4766 __kmp_hws_core.offset = offset;
4768 char *d = pos + strcspn(pos, digits);
4770 if (__kmp_hws_tile.num > 0)
4772 __kmp_hws_tile.num = num;
4773 __kmp_hws_tile.offset = offset;
4774 }
else if (*d ==
'3') {
4775 if (__kmp_hws_socket.num > 0)
4777 __kmp_hws_socket.num = num;
4778 __kmp_hws_socket.offset = offset;
4779 }
else if (*d ==
'1') {
4780 if (__kmp_hws_core.num > 0)
4782 __kmp_hws_core.num = num;
4783 __kmp_hws_core.offset = offset;
4790 if (__kmp_hws_proc.num > 0)
4792 __kmp_hws_proc.num = num;
4793 __kmp_hws_proc.offset = offset;
4801 KMP_WARNING(AffHWSubsetInvalid, name, value);
4802 __kmp_hws_requested = 0;
4806 static void __kmp_stg_print_hw_subset(kmp_str_buf_t *buffer,
char const *name,
4808 if (__kmp_hws_requested) {
4811 __kmp_str_buf_init(&buf);
4812 if (__kmp_env_format)
4813 KMP_STR_BUF_PRINT_NAME_EX(name);
4815 __kmp_str_buf_print(buffer,
" %s='", name);
4816 if (__kmp_hws_socket.num) {
4817 __kmp_str_buf_print(&buf,
"%ds", __kmp_hws_socket.num);
4818 if (__kmp_hws_socket.offset)
4819 __kmp_str_buf_print(&buf,
"@%d", __kmp_hws_socket.offset);
4822 if (__kmp_hws_node.num) {
4823 __kmp_str_buf_print(&buf,
"%s%dn", comma ?
"," :
"", __kmp_hws_node.num);
4824 if (__kmp_hws_node.offset)
4825 __kmp_str_buf_print(&buf,
"@%d", __kmp_hws_node.offset);
4828 if (__kmp_hws_tile.num) {
4829 __kmp_str_buf_print(&buf,
"%s%dL2", comma ?
"," :
"", __kmp_hws_tile.num);
4830 if (__kmp_hws_tile.offset)
4831 __kmp_str_buf_print(&buf,
"@%d", __kmp_hws_tile.offset);
4834 if (__kmp_hws_core.num) {
4835 __kmp_str_buf_print(&buf,
"%s%dc", comma ?
"," :
"", __kmp_hws_core.num);
4836 if (__kmp_hws_core.offset)
4837 __kmp_str_buf_print(&buf,
"@%d", __kmp_hws_core.offset);
4840 if (__kmp_hws_proc.num)
4841 __kmp_str_buf_print(&buf,
"%s%dt", comma ?
"," :
"", __kmp_hws_proc.num);
4842 __kmp_str_buf_print(buffer,
"%s'\n", buf.str);
4843 __kmp_str_buf_free(&buf);
4851 static void __kmp_stg_parse_forkjoin_frames(
char const *name,
char const *value,
4853 __kmp_stg_parse_bool(name, value, &__kmp_forkjoin_frames);
4856 static void __kmp_stg_print_forkjoin_frames(kmp_str_buf_t *buffer,
4857 char const *name,
void *data) {
4858 __kmp_stg_print_bool(buffer, name, __kmp_forkjoin_frames);
4864 static void __kmp_stg_parse_forkjoin_frames_mode(
char const *name,
4867 __kmp_stg_parse_int(name, value, 0, 3, &__kmp_forkjoin_frames_mode);
4870 static void __kmp_stg_print_forkjoin_frames_mode(kmp_str_buf_t *buffer,
4871 char const *name,
void *data) {
4872 __kmp_stg_print_int(buffer, name, __kmp_forkjoin_frames_mode);
4879 static void __kmp_stg_parse_task_throttling(
char const *name,
4880 char const *value,
void *data) {
4881 __kmp_stg_parse_bool(name, value, &__kmp_enable_task_throttling);
4885 static void __kmp_stg_print_task_throttling(kmp_str_buf_t *buffer,
4886 char const *name,
void *data) {
4887 __kmp_stg_print_bool(buffer, name, __kmp_enable_task_throttling);
4890 #if KMP_HAVE_MWAIT || KMP_HAVE_UMWAIT
4894 static void __kmp_stg_parse_user_level_mwait(
char const *name,
4895 char const *value,
void *data) {
4896 __kmp_stg_parse_bool(name, value, &__kmp_user_level_mwait);
4899 static void __kmp_stg_print_user_level_mwait(kmp_str_buf_t *buffer,
4900 char const *name,
void *data) {
4901 __kmp_stg_print_bool(buffer, name, __kmp_user_level_mwait);
4907 static void __kmp_stg_parse_mwait_hints(
char const *name,
char const *value,
4909 __kmp_stg_parse_int(name, value, 0, INT_MAX, &__kmp_mwait_hints);
4912 static void __kmp_stg_print_mwait_hints(kmp_str_buf_t *buffer,
char const *name,
4914 __kmp_stg_print_int(buffer, name, __kmp_mwait_hints);
4922 static void __kmp_stg_parse_omp_display_env(
char const *name,
char const *value,
4924 if (__kmp_str_match(
"VERBOSE", 1, value)) {
4925 __kmp_display_env_verbose = TRUE;
4927 __kmp_stg_parse_bool(name, value, &__kmp_display_env);
4931 static void __kmp_stg_print_omp_display_env(kmp_str_buf_t *buffer,
4932 char const *name,
void *data) {
4933 if (__kmp_display_env_verbose) {
4934 __kmp_stg_print_str(buffer, name,
"VERBOSE");
4936 __kmp_stg_print_bool(buffer, name, __kmp_display_env);
4940 static void __kmp_stg_parse_omp_cancellation(
char const *name,
4941 char const *value,
void *data) {
4942 if (TCR_4(__kmp_init_parallel)) {
4943 KMP_WARNING(EnvParallelWarn, name);
4946 __kmp_stg_parse_bool(name, value, &__kmp_omp_cancellation);
4949 static void __kmp_stg_print_omp_cancellation(kmp_str_buf_t *buffer,
4950 char const *name,
void *data) {
4951 __kmp_stg_print_bool(buffer, name, __kmp_omp_cancellation);
4955 static int __kmp_tool = 1;
4957 static void __kmp_stg_parse_omp_tool(
char const *name,
char const *value,
4959 __kmp_stg_parse_bool(name, value, &__kmp_tool);
4962 static void __kmp_stg_print_omp_tool(kmp_str_buf_t *buffer,
char const *name,
4964 if (__kmp_env_format) {
4965 KMP_STR_BUF_PRINT_BOOL_EX(name, __kmp_tool,
"enabled",
"disabled");
4967 __kmp_str_buf_print(buffer,
" %s=%s\n", name,
4968 __kmp_tool ?
"enabled" :
"disabled");
4972 static char *__kmp_tool_libraries = NULL;
4974 static void __kmp_stg_parse_omp_tool_libraries(
char const *name,
4975 char const *value,
void *data) {
4976 __kmp_stg_parse_str(name, value, &__kmp_tool_libraries);
4979 static void __kmp_stg_print_omp_tool_libraries(kmp_str_buf_t *buffer,
4980 char const *name,
void *data) {
4981 if (__kmp_tool_libraries)
4982 __kmp_stg_print_str(buffer, name, __kmp_tool_libraries);
4984 if (__kmp_env_format) {
4985 KMP_STR_BUF_PRINT_NAME;
4987 __kmp_str_buf_print(buffer,
" %s", name);
4989 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
4993 static char *__kmp_tool_verbose_init = NULL;
4995 static void __kmp_stg_parse_omp_tool_verbose_init(
char const *name,
4996 char const *value,
void *data) {
4997 __kmp_stg_parse_str(name, value, &__kmp_tool_verbose_init);
5000 static void __kmp_stg_print_omp_tool_verbose_init(kmp_str_buf_t *buffer,
5001 char const *name,
void *data) {
5002 if (__kmp_tool_verbose_init)
5003 __kmp_stg_print_str(buffer, name, __kmp_tool_libraries);
5005 if (__kmp_env_format) {
5006 KMP_STR_BUF_PRINT_NAME;
5008 __kmp_str_buf_print(buffer,
" %s", name);
5010 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
5018 static kmp_setting_t __kmp_stg_table[] = {
5020 {
"KMP_ALL_THREADS", __kmp_stg_parse_device_thread_limit, NULL, NULL, 0, 0},
5021 {
"KMP_BLOCKTIME", __kmp_stg_parse_blocktime, __kmp_stg_print_blocktime,
5023 {
"KMP_USE_YIELD", __kmp_stg_parse_use_yield, __kmp_stg_print_use_yield,
5025 {
"KMP_DUPLICATE_LIB_OK", __kmp_stg_parse_duplicate_lib_ok,
5026 __kmp_stg_print_duplicate_lib_ok, NULL, 0, 0},
5027 {
"KMP_LIBRARY", __kmp_stg_parse_wait_policy, __kmp_stg_print_wait_policy,
5029 {
"KMP_DEVICE_THREAD_LIMIT", __kmp_stg_parse_device_thread_limit,
5030 __kmp_stg_print_device_thread_limit, NULL, 0, 0},
5032 {
"KMP_MONITOR_STACKSIZE", __kmp_stg_parse_monitor_stacksize,
5033 __kmp_stg_print_monitor_stacksize, NULL, 0, 0},
5035 {
"KMP_SETTINGS", __kmp_stg_parse_settings, __kmp_stg_print_settings, NULL,
5037 {
"KMP_STACKOFFSET", __kmp_stg_parse_stackoffset,
5038 __kmp_stg_print_stackoffset, NULL, 0, 0},
5039 {
"KMP_STACKSIZE", __kmp_stg_parse_stacksize, __kmp_stg_print_stacksize,
5041 {
"KMP_STACKPAD", __kmp_stg_parse_stackpad, __kmp_stg_print_stackpad, NULL,
5043 {
"KMP_VERSION", __kmp_stg_parse_version, __kmp_stg_print_version, NULL, 0,
5045 {
"KMP_WARNINGS", __kmp_stg_parse_warnings, __kmp_stg_print_warnings, NULL,
5048 {
"OMP_NESTED", __kmp_stg_parse_nested, __kmp_stg_print_nested, NULL, 0, 0},
5049 {
"OMP_NUM_THREADS", __kmp_stg_parse_num_threads,
5050 __kmp_stg_print_num_threads, NULL, 0, 0},
5051 {
"OMP_STACKSIZE", __kmp_stg_parse_stacksize, __kmp_stg_print_stacksize,
5054 {
"KMP_TASKING", __kmp_stg_parse_tasking, __kmp_stg_print_tasking, NULL, 0,
5056 {
"KMP_TASK_STEALING_CONSTRAINT", __kmp_stg_parse_task_stealing,
5057 __kmp_stg_print_task_stealing, NULL, 0, 0},
5058 {
"OMP_MAX_ACTIVE_LEVELS", __kmp_stg_parse_max_active_levels,
5059 __kmp_stg_print_max_active_levels, NULL, 0, 0},
5060 {
"OMP_DEFAULT_DEVICE", __kmp_stg_parse_default_device,
5061 __kmp_stg_print_default_device, NULL, 0, 0},
5062 {
"OMP_TARGET_OFFLOAD", __kmp_stg_parse_target_offload,
5063 __kmp_stg_print_target_offload, NULL, 0, 0},
5064 {
"OMP_MAX_TASK_PRIORITY", __kmp_stg_parse_max_task_priority,
5065 __kmp_stg_print_max_task_priority, NULL, 0, 0},
5066 {
"KMP_TASKLOOP_MIN_TASKS", __kmp_stg_parse_taskloop_min_tasks,
5067 __kmp_stg_print_taskloop_min_tasks, NULL, 0, 0},
5068 {
"OMP_THREAD_LIMIT", __kmp_stg_parse_thread_limit,
5069 __kmp_stg_print_thread_limit, NULL, 0, 0},
5070 {
"KMP_TEAMS_THREAD_LIMIT", __kmp_stg_parse_teams_thread_limit,
5071 __kmp_stg_print_teams_thread_limit, NULL, 0, 0},
5072 {
"OMP_WAIT_POLICY", __kmp_stg_parse_wait_policy,
5073 __kmp_stg_print_wait_policy, NULL, 0, 0},
5074 {
"KMP_DISP_NUM_BUFFERS", __kmp_stg_parse_disp_buffers,
5075 __kmp_stg_print_disp_buffers, NULL, 0, 0},
5076 #if KMP_NESTED_HOT_TEAMS
5077 {
"KMP_HOT_TEAMS_MAX_LEVEL", __kmp_stg_parse_hot_teams_level,
5078 __kmp_stg_print_hot_teams_level, NULL, 0, 0},
5079 {
"KMP_HOT_TEAMS_MODE", __kmp_stg_parse_hot_teams_mode,
5080 __kmp_stg_print_hot_teams_mode, NULL, 0, 0},
5083 #if KMP_HANDLE_SIGNALS
5084 {
"KMP_HANDLE_SIGNALS", __kmp_stg_parse_handle_signals,
5085 __kmp_stg_print_handle_signals, NULL, 0, 0},
5088 #if KMP_ARCH_X86 || KMP_ARCH_X86_64
5089 {
"KMP_INHERIT_FP_CONTROL", __kmp_stg_parse_inherit_fp_control,
5090 __kmp_stg_print_inherit_fp_control, NULL, 0, 0},
5093 #ifdef KMP_GOMP_COMPAT
5094 {
"GOMP_STACKSIZE", __kmp_stg_parse_stacksize, NULL, NULL, 0, 0},
5098 {
"KMP_A_DEBUG", __kmp_stg_parse_a_debug, __kmp_stg_print_a_debug, NULL, 0,
5100 {
"KMP_B_DEBUG", __kmp_stg_parse_b_debug, __kmp_stg_print_b_debug, NULL, 0,
5102 {
"KMP_C_DEBUG", __kmp_stg_parse_c_debug, __kmp_stg_print_c_debug, NULL, 0,
5104 {
"KMP_D_DEBUG", __kmp_stg_parse_d_debug, __kmp_stg_print_d_debug, NULL, 0,
5106 {
"KMP_E_DEBUG", __kmp_stg_parse_e_debug, __kmp_stg_print_e_debug, NULL, 0,
5108 {
"KMP_F_DEBUG", __kmp_stg_parse_f_debug, __kmp_stg_print_f_debug, NULL, 0,
5110 {
"KMP_DEBUG", __kmp_stg_parse_debug, NULL, NULL, 0, 0},
5111 {
"KMP_DEBUG_BUF", __kmp_stg_parse_debug_buf, __kmp_stg_print_debug_buf,
5113 {
"KMP_DEBUG_BUF_ATOMIC", __kmp_stg_parse_debug_buf_atomic,
5114 __kmp_stg_print_debug_buf_atomic, NULL, 0, 0},
5115 {
"KMP_DEBUG_BUF_CHARS", __kmp_stg_parse_debug_buf_chars,
5116 __kmp_stg_print_debug_buf_chars, NULL, 0, 0},
5117 {
"KMP_DEBUG_BUF_LINES", __kmp_stg_parse_debug_buf_lines,
5118 __kmp_stg_print_debug_buf_lines, NULL, 0, 0},
5119 {
"KMP_DIAG", __kmp_stg_parse_diag, __kmp_stg_print_diag, NULL, 0, 0},
5121 {
"KMP_PAR_RANGE", __kmp_stg_parse_par_range_env,
5122 __kmp_stg_print_par_range_env, NULL, 0, 0},
5125 {
"KMP_ALIGN_ALLOC", __kmp_stg_parse_align_alloc,
5126 __kmp_stg_print_align_alloc, NULL, 0, 0},
5128 {
"KMP_PLAIN_BARRIER", __kmp_stg_parse_barrier_branch_bit,
5129 __kmp_stg_print_barrier_branch_bit, NULL, 0, 0},
5130 {
"KMP_PLAIN_BARRIER_PATTERN", __kmp_stg_parse_barrier_pattern,
5131 __kmp_stg_print_barrier_pattern, NULL, 0, 0},
5132 {
"KMP_FORKJOIN_BARRIER", __kmp_stg_parse_barrier_branch_bit,
5133 __kmp_stg_print_barrier_branch_bit, NULL, 0, 0},
5134 {
"KMP_FORKJOIN_BARRIER_PATTERN", __kmp_stg_parse_barrier_pattern,
5135 __kmp_stg_print_barrier_pattern, NULL, 0, 0},
5136 #if KMP_FAST_REDUCTION_BARRIER
5137 {
"KMP_REDUCTION_BARRIER", __kmp_stg_parse_barrier_branch_bit,
5138 __kmp_stg_print_barrier_branch_bit, NULL, 0, 0},
5139 {
"KMP_REDUCTION_BARRIER_PATTERN", __kmp_stg_parse_barrier_pattern,
5140 __kmp_stg_print_barrier_pattern, NULL, 0, 0},
5143 {
"KMP_ABORT_DELAY", __kmp_stg_parse_abort_delay,
5144 __kmp_stg_print_abort_delay, NULL, 0, 0},
5145 {
"KMP_CPUINFO_FILE", __kmp_stg_parse_cpuinfo_file,
5146 __kmp_stg_print_cpuinfo_file, NULL, 0, 0},
5147 {
"KMP_FORCE_REDUCTION", __kmp_stg_parse_force_reduction,
5148 __kmp_stg_print_force_reduction, NULL, 0, 0},
5149 {
"KMP_DETERMINISTIC_REDUCTION", __kmp_stg_parse_force_reduction,
5150 __kmp_stg_print_force_reduction, NULL, 0, 0},
5151 {
"KMP_STORAGE_MAP", __kmp_stg_parse_storage_map,
5152 __kmp_stg_print_storage_map, NULL, 0, 0},
5153 {
"KMP_ALL_THREADPRIVATE", __kmp_stg_parse_all_threadprivate,
5154 __kmp_stg_print_all_threadprivate, NULL, 0, 0},
5155 {
"KMP_FOREIGN_THREADS_THREADPRIVATE",
5156 __kmp_stg_parse_foreign_threads_threadprivate,
5157 __kmp_stg_print_foreign_threads_threadprivate, NULL, 0, 0},
5159 #if KMP_AFFINITY_SUPPORTED
5160 {
"KMP_AFFINITY", __kmp_stg_parse_affinity, __kmp_stg_print_affinity, NULL,
5162 #ifdef KMP_GOMP_COMPAT
5163 {
"GOMP_CPU_AFFINITY", __kmp_stg_parse_gomp_cpu_affinity, NULL,
5166 {
"OMP_PROC_BIND", __kmp_stg_parse_proc_bind, __kmp_stg_print_proc_bind,
5168 {
"OMP_PLACES", __kmp_stg_parse_places, __kmp_stg_print_places, NULL, 0, 0},
5169 {
"KMP_TOPOLOGY_METHOD", __kmp_stg_parse_topology_method,
5170 __kmp_stg_print_topology_method, NULL, 0, 0},
5176 {
"OMP_PROC_BIND", __kmp_stg_parse_proc_bind, __kmp_stg_print_proc_bind,
5180 {
"OMP_DISPLAY_AFFINITY", __kmp_stg_parse_display_affinity,
5181 __kmp_stg_print_display_affinity, NULL, 0, 0},
5182 {
"OMP_AFFINITY_FORMAT", __kmp_stg_parse_affinity_format,
5183 __kmp_stg_print_affinity_format, NULL, 0, 0},
5184 {
"KMP_INIT_AT_FORK", __kmp_stg_parse_init_at_fork,
5185 __kmp_stg_print_init_at_fork, NULL, 0, 0},
5186 {
"KMP_SCHEDULE", __kmp_stg_parse_schedule, __kmp_stg_print_schedule, NULL,
5188 {
"OMP_SCHEDULE", __kmp_stg_parse_omp_schedule, __kmp_stg_print_omp_schedule,
5190 #if KMP_USE_HIER_SCHED
5191 {
"KMP_DISP_HAND_THREAD", __kmp_stg_parse_kmp_hand_thread,
5192 __kmp_stg_print_kmp_hand_thread, NULL, 0, 0},
5194 {
"KMP_ATOMIC_MODE", __kmp_stg_parse_atomic_mode,
5195 __kmp_stg_print_atomic_mode, NULL, 0, 0},
5196 {
"KMP_CONSISTENCY_CHECK", __kmp_stg_parse_consistency_check,
5197 __kmp_stg_print_consistency_check, NULL, 0, 0},
5199 #if USE_ITT_BUILD && USE_ITT_NOTIFY
5200 {
"KMP_ITT_PREPARE_DELAY", __kmp_stg_parse_itt_prepare_delay,
5201 __kmp_stg_print_itt_prepare_delay, NULL, 0, 0},
5203 {
"KMP_MALLOC_POOL_INCR", __kmp_stg_parse_malloc_pool_incr,
5204 __kmp_stg_print_malloc_pool_incr, NULL, 0, 0},
5205 {
"KMP_GTID_MODE", __kmp_stg_parse_gtid_mode, __kmp_stg_print_gtid_mode,
5207 {
"OMP_DYNAMIC", __kmp_stg_parse_omp_dynamic, __kmp_stg_print_omp_dynamic,
5209 {
"KMP_DYNAMIC_MODE", __kmp_stg_parse_kmp_dynamic_mode,
5210 __kmp_stg_print_kmp_dynamic_mode, NULL, 0, 0},
5212 #ifdef USE_LOAD_BALANCE
5213 {
"KMP_LOAD_BALANCE_INTERVAL", __kmp_stg_parse_ld_balance_interval,
5214 __kmp_stg_print_ld_balance_interval, NULL, 0, 0},
5217 {
"KMP_NUM_LOCKS_IN_BLOCK", __kmp_stg_parse_lock_block,
5218 __kmp_stg_print_lock_block, NULL, 0, 0},
5219 {
"KMP_LOCK_KIND", __kmp_stg_parse_lock_kind, __kmp_stg_print_lock_kind,
5221 {
"KMP_SPIN_BACKOFF_PARAMS", __kmp_stg_parse_spin_backoff_params,
5222 __kmp_stg_print_spin_backoff_params, NULL, 0, 0},
5223 #if KMP_USE_ADAPTIVE_LOCKS
5224 {
"KMP_ADAPTIVE_LOCK_PROPS", __kmp_stg_parse_adaptive_lock_props,
5225 __kmp_stg_print_adaptive_lock_props, NULL, 0, 0},
5226 #if KMP_DEBUG_ADAPTIVE_LOCKS
5227 {
"KMP_SPECULATIVE_STATSFILE", __kmp_stg_parse_speculative_statsfile,
5228 __kmp_stg_print_speculative_statsfile, NULL, 0, 0},
5231 {
"KMP_PLACE_THREADS", __kmp_stg_parse_hw_subset, __kmp_stg_print_hw_subset,
5233 {
"KMP_HW_SUBSET", __kmp_stg_parse_hw_subset, __kmp_stg_print_hw_subset,
5236 {
"KMP_FORKJOIN_FRAMES", __kmp_stg_parse_forkjoin_frames,
5237 __kmp_stg_print_forkjoin_frames, NULL, 0, 0},
5238 {
"KMP_FORKJOIN_FRAMES_MODE", __kmp_stg_parse_forkjoin_frames_mode,
5239 __kmp_stg_print_forkjoin_frames_mode, NULL, 0, 0},
5241 {
"KMP_ENABLE_TASK_THROTTLING", __kmp_stg_parse_task_throttling,
5242 __kmp_stg_print_task_throttling, NULL, 0, 0},
5244 {
"OMP_DISPLAY_ENV", __kmp_stg_parse_omp_display_env,
5245 __kmp_stg_print_omp_display_env, NULL, 0, 0},
5246 {
"OMP_CANCELLATION", __kmp_stg_parse_omp_cancellation,
5247 __kmp_stg_print_omp_cancellation, NULL, 0, 0},
5248 {
"OMP_ALLOCATOR", __kmp_stg_parse_allocator, __kmp_stg_print_allocator,
5250 {
"LIBOMP_USE_HIDDEN_HELPER_TASK", __kmp_stg_parse_use_hidden_helper,
5251 __kmp_stg_print_use_hidden_helper, NULL, 0, 0},
5252 {
"LIBOMP_NUM_HIDDEN_HELPER_THREADS",
5253 __kmp_stg_parse_num_hidden_helper_threads,
5254 __kmp_stg_print_num_hidden_helper_threads, NULL, 0, 0},
5257 {
"OMP_TOOL", __kmp_stg_parse_omp_tool, __kmp_stg_print_omp_tool, NULL, 0,
5259 {
"OMP_TOOL_LIBRARIES", __kmp_stg_parse_omp_tool_libraries,
5260 __kmp_stg_print_omp_tool_libraries, NULL, 0, 0},
5261 {
"OMP_TOOL_VERBOSE_INIT", __kmp_stg_parse_omp_tool_verbose_init,
5262 __kmp_stg_print_omp_tool_verbose_init, NULL, 0, 0},
5265 #if KMP_HAVE_MWAIT || KMP_HAVE_UMWAIT
5266 {
"KMP_USER_LEVEL_MWAIT", __kmp_stg_parse_user_level_mwait,
5267 __kmp_stg_print_user_level_mwait, NULL, 0, 0},
5268 {
"KMP_MWAIT_HINTS", __kmp_stg_parse_mwait_hints,
5269 __kmp_stg_print_mwait_hints, NULL, 0, 0},
5271 {
"", NULL, NULL, NULL, 0, 0}};
5273 static int const __kmp_stg_count =
5274 sizeof(__kmp_stg_table) /
sizeof(kmp_setting_t);
5276 static inline kmp_setting_t *__kmp_stg_find(
char const *name) {
5280 for (i = 0; i < __kmp_stg_count; ++i) {
5281 if (strcmp(__kmp_stg_table[i].name, name) == 0) {
5282 return &__kmp_stg_table[i];
5290 static int __kmp_stg_cmp(
void const *_a,
void const *_b) {
5291 const kmp_setting_t *a = RCAST(
const kmp_setting_t *, _a);
5292 const kmp_setting_t *b = RCAST(
const kmp_setting_t *, _b);
5296 if (strcmp(a->name,
"KMP_AFFINITY") == 0) {
5297 if (strcmp(b->name,
"KMP_AFFINITY") == 0) {
5301 }
else if (strcmp(b->name,
"KMP_AFFINITY") == 0) {
5304 return strcmp(a->name, b->name);
5307 static void __kmp_stg_init(
void) {
5309 static int initialized = 0;
5314 qsort(__kmp_stg_table, __kmp_stg_count - 1,
sizeof(kmp_setting_t),
5318 kmp_setting_t *kmp_stacksize =
5319 __kmp_stg_find(
"KMP_STACKSIZE");
5320 #ifdef KMP_GOMP_COMPAT
5321 kmp_setting_t *gomp_stacksize =
5322 __kmp_stg_find(
"GOMP_STACKSIZE");
5324 kmp_setting_t *omp_stacksize =
5325 __kmp_stg_find(
"OMP_STACKSIZE");
5331 static kmp_setting_t *
volatile rivals[4];
5332 static kmp_stg_ss_data_t kmp_data = {1, CCAST(kmp_setting_t **, rivals)};
5333 #ifdef KMP_GOMP_COMPAT
5334 static kmp_stg_ss_data_t gomp_data = {1024,
5335 CCAST(kmp_setting_t **, rivals)};
5337 static kmp_stg_ss_data_t omp_data = {1024,
5338 CCAST(kmp_setting_t **, rivals)};
5341 rivals[i++] = kmp_stacksize;
5342 #ifdef KMP_GOMP_COMPAT
5343 if (gomp_stacksize != NULL) {
5344 rivals[i++] = gomp_stacksize;
5347 rivals[i++] = omp_stacksize;
5350 kmp_stacksize->data = &kmp_data;
5351 #ifdef KMP_GOMP_COMPAT
5352 if (gomp_stacksize != NULL) {
5353 gomp_stacksize->data = &gomp_data;
5356 omp_stacksize->data = &omp_data;
5360 kmp_setting_t *kmp_library =
5361 __kmp_stg_find(
"KMP_LIBRARY");
5362 kmp_setting_t *omp_wait_policy =
5363 __kmp_stg_find(
"OMP_WAIT_POLICY");
5366 static kmp_setting_t *
volatile rivals[3];
5367 static kmp_stg_wp_data_t kmp_data = {0, CCAST(kmp_setting_t **, rivals)};
5368 static kmp_stg_wp_data_t omp_data = {1, CCAST(kmp_setting_t **, rivals)};
5371 rivals[i++] = kmp_library;
5372 if (omp_wait_policy != NULL) {
5373 rivals[i++] = omp_wait_policy;
5377 kmp_library->data = &kmp_data;
5378 if (omp_wait_policy != NULL) {
5379 omp_wait_policy->data = &omp_data;
5384 kmp_setting_t *kmp_device_thread_limit =
5385 __kmp_stg_find(
"KMP_DEVICE_THREAD_LIMIT");
5386 kmp_setting_t *kmp_all_threads =
5387 __kmp_stg_find(
"KMP_ALL_THREADS");
5390 static kmp_setting_t *
volatile rivals[3];
5393 rivals[i++] = kmp_device_thread_limit;
5394 rivals[i++] = kmp_all_threads;
5397 kmp_device_thread_limit->data = CCAST(kmp_setting_t **, rivals);
5398 kmp_all_threads->data = CCAST(kmp_setting_t **, rivals);
5403 kmp_setting_t *kmp_hw_subset = __kmp_stg_find(
"KMP_HW_SUBSET");
5405 kmp_setting_t *kmp_place_threads = __kmp_stg_find(
"KMP_PLACE_THREADS");
5408 static kmp_setting_t *
volatile rivals[3];
5411 rivals[i++] = kmp_hw_subset;
5412 rivals[i++] = kmp_place_threads;
5415 kmp_hw_subset->data = CCAST(kmp_setting_t **, rivals);
5416 kmp_place_threads->data = CCAST(kmp_setting_t **, rivals);
5419 #if KMP_AFFINITY_SUPPORTED
5421 kmp_setting_t *kmp_affinity =
5422 __kmp_stg_find(
"KMP_AFFINITY");
5423 KMP_DEBUG_ASSERT(kmp_affinity != NULL);
5425 #ifdef KMP_GOMP_COMPAT
5426 kmp_setting_t *gomp_cpu_affinity =
5427 __kmp_stg_find(
"GOMP_CPU_AFFINITY");
5428 KMP_DEBUG_ASSERT(gomp_cpu_affinity != NULL);
5431 kmp_setting_t *omp_proc_bind =
5432 __kmp_stg_find(
"OMP_PROC_BIND");
5433 KMP_DEBUG_ASSERT(omp_proc_bind != NULL);
5436 static kmp_setting_t *
volatile rivals[4];
5439 rivals[i++] = kmp_affinity;
5441 #ifdef KMP_GOMP_COMPAT
5442 rivals[i++] = gomp_cpu_affinity;
5443 gomp_cpu_affinity->data = CCAST(kmp_setting_t **, rivals);
5446 rivals[i++] = omp_proc_bind;
5447 omp_proc_bind->data = CCAST(kmp_setting_t **, rivals);
5450 static kmp_setting_t *
volatile places_rivals[4];
5453 kmp_setting_t *omp_places = __kmp_stg_find(
"OMP_PLACES");
5454 KMP_DEBUG_ASSERT(omp_places != NULL);
5456 places_rivals[i++] = kmp_affinity;
5457 #ifdef KMP_GOMP_COMPAT
5458 places_rivals[i++] = gomp_cpu_affinity;
5460 places_rivals[i++] = omp_places;
5461 omp_places->data = CCAST(kmp_setting_t **, places_rivals);
5462 places_rivals[i++] = NULL;
5470 kmp_setting_t *kmp_force_red =
5471 __kmp_stg_find(
"KMP_FORCE_REDUCTION");
5472 kmp_setting_t *kmp_determ_red =
5473 __kmp_stg_find(
"KMP_DETERMINISTIC_REDUCTION");
5476 static kmp_setting_t *
volatile rivals[3];
5477 static kmp_stg_fr_data_t force_data = {1,
5478 CCAST(kmp_setting_t **, rivals)};
5479 static kmp_stg_fr_data_t determ_data = {0,
5480 CCAST(kmp_setting_t **, rivals)};
5483 rivals[i++] = kmp_force_red;
5484 if (kmp_determ_red != NULL) {
5485 rivals[i++] = kmp_determ_red;
5489 kmp_force_red->data = &force_data;
5490 if (kmp_determ_red != NULL) {
5491 kmp_determ_red->data = &determ_data;
5500 for (i = 0; i < __kmp_stg_count; ++i) {
5501 __kmp_stg_table[i].set = 0;
5506 static void __kmp_stg_parse(
char const *name,
char const *value) {
5514 if (value != NULL) {
5515 kmp_setting_t *setting = __kmp_stg_find(name);
5516 if (setting != NULL) {
5517 setting->parse(name, value, setting->data);
5518 setting->defined = 1;
5524 static int __kmp_stg_check_rivals(
5527 kmp_setting_t **rivals
5530 if (rivals == NULL) {
5536 for (; strcmp(rivals[i]->name, name) != 0; i++) {
5537 KMP_DEBUG_ASSERT(rivals[i] != NULL);
5539 #if KMP_AFFINITY_SUPPORTED
5540 if (rivals[i] == __kmp_affinity_notype) {
5547 if (rivals[i]->set) {
5548 KMP_WARNING(StgIgnored, name, rivals[i]->name);
5558 static int __kmp_env_toPrint(
char const *name,
int flag) {
5560 kmp_setting_t *setting = __kmp_stg_find(name);
5561 if (setting != NULL) {
5562 rc = setting->defined;
5564 setting->defined = flag;
5570 static void __kmp_aux_env_initialize(kmp_env_blk_t *block) {
5575 value = __kmp_env_blk_var(block,
"OMP_NUM_THREADS");
5577 ompc_set_num_threads(__kmp_dflt_team_nth);
5581 value = __kmp_env_blk_var(block,
"KMP_BLOCKTIME");
5583 kmpc_set_blocktime(__kmp_dflt_blocktime);
5587 value = __kmp_env_blk_var(block,
"OMP_NESTED");
5589 ompc_set_nested(__kmp_dflt_max_active_levels > 1);
5593 value = __kmp_env_blk_var(block,
"OMP_DYNAMIC");
5595 ompc_set_dynamic(__kmp_global.g.g_dynamic);
5599 void __kmp_env_initialize(
char const *
string) {
5601 kmp_env_blk_t block;
5607 if (
string == NULL) {
5609 __kmp_threads_capacity =
5610 __kmp_initial_threads_capacity(__kmp_dflt_team_nth_ub);
5612 __kmp_env_blk_init(&block,
string);
5615 for (i = 0; i < block.count; ++i) {
5616 if ((block.vars[i].name == NULL) || (*block.vars[i].name ==
'\0')) {
5619 if (block.vars[i].value == NULL) {
5622 kmp_setting_t *setting = __kmp_stg_find(block.vars[i].name);
5623 if (setting != NULL) {
5629 blocktime_str = __kmp_env_blk_var(&block,
"KMP_BLOCKTIME");
5633 if (
string == NULL) {
5634 char const *name =
"KMP_WARNINGS";
5635 char const *value = __kmp_env_blk_var(&block, name);
5636 __kmp_stg_parse(name, value);
5639 #if KMP_AFFINITY_SUPPORTED
5645 __kmp_affinity_notype = NULL;
5646 char const *aff_str = __kmp_env_blk_var(&block,
"KMP_AFFINITY");
5647 if (aff_str != NULL) {
5661 #define FIND strcasestr
5664 if ((FIND(aff_str,
"none") == NULL) &&
5665 (FIND(aff_str,
"physical") == NULL) &&
5666 (FIND(aff_str,
"logical") == NULL) &&
5667 (FIND(aff_str,
"compact") == NULL) &&
5668 (FIND(aff_str,
"scatter") == NULL) &&
5669 (FIND(aff_str,
"explicit") == NULL) &&
5670 (FIND(aff_str,
"balanced") == NULL) &&
5671 (FIND(aff_str,
"disabled") == NULL)) {
5672 __kmp_affinity_notype = __kmp_stg_find(
"KMP_AFFINITY");
5677 __kmp_affinity_type = affinity_default;
5678 __kmp_affinity_gran = affinity_gran_default;
5679 __kmp_affinity_top_method = affinity_top_method_default;
5680 __kmp_affinity_respect_mask = affinity_respect_mask_default;
5685 aff_str = __kmp_env_blk_var(&block,
"OMP_PROC_BIND");
5686 if (aff_str != NULL) {
5687 __kmp_affinity_type = affinity_default;
5688 __kmp_affinity_gran = affinity_gran_default;
5689 __kmp_affinity_top_method = affinity_top_method_default;
5690 __kmp_affinity_respect_mask = affinity_respect_mask_default;
5697 if (__kmp_nested_proc_bind.bind_types == NULL) {
5698 __kmp_nested_proc_bind.bind_types =
5699 (kmp_proc_bind_t *)KMP_INTERNAL_MALLOC(
sizeof(kmp_proc_bind_t));
5700 if (__kmp_nested_proc_bind.bind_types == NULL) {
5701 KMP_FATAL(MemoryAllocFailed);
5703 __kmp_nested_proc_bind.size = 1;
5704 __kmp_nested_proc_bind.used = 1;
5705 #if KMP_AFFINITY_SUPPORTED
5706 __kmp_nested_proc_bind.bind_types[0] = proc_bind_default;
5709 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
5716 __kmp_msg_format(kmp_i18n_msg_AffFormatDefault,
"%P",
"%i",
"%n",
"%A");
5717 KMP_DEBUG_ASSERT(KMP_STRLEN(m.str) < KMP_AFFINITY_FORMAT_SIZE);
5719 if (__kmp_affinity_format == NULL) {
5720 __kmp_affinity_format =
5721 (
char *)KMP_INTERNAL_MALLOC(
sizeof(
char) * KMP_AFFINITY_FORMAT_SIZE);
5723 KMP_STRCPY_S(__kmp_affinity_format, KMP_AFFINITY_FORMAT_SIZE, m.str);
5724 __kmp_str_free(&m.str);
5727 for (i = 0; i < block.count; ++i) {
5728 __kmp_stg_parse(block.vars[i].name, block.vars[i].value);
5732 if (!__kmp_init_user_locks) {
5733 if (__kmp_user_lock_kind == lk_default) {
5734 __kmp_user_lock_kind = lk_queuing;
5736 #if KMP_USE_DYNAMIC_LOCK
5737 __kmp_init_dynamic_user_locks();
5739 __kmp_set_user_lock_vptrs(__kmp_user_lock_kind);
5742 KMP_DEBUG_ASSERT(
string != NULL);
5743 KMP_DEBUG_ASSERT(__kmp_user_lock_kind != lk_default);
5748 #if KMP_USE_DYNAMIC_LOCK
5749 __kmp_init_dynamic_user_locks();
5751 __kmp_set_user_lock_vptrs(__kmp_user_lock_kind);
5755 #if KMP_AFFINITY_SUPPORTED
5757 if (!TCR_4(__kmp_init_middle)) {
5761 if ((__kmp_hws_node.num > 0 || __kmp_hws_tile.num > 0 ||
5762 __kmp_affinity_gran == affinity_gran_tile) &&
5763 (__kmp_affinity_top_method == affinity_top_method_default)) {
5764 __kmp_affinity_top_method = affinity_top_method_hwloc;
5769 const char *var =
"KMP_AFFINITY";
5770 KMPAffinity::pick_api();
5775 if (__kmp_affinity_top_method == affinity_top_method_hwloc &&
5776 __kmp_affinity_dispatch->get_api_type() != KMPAffinity::HWLOC) {
5777 KMP_WARNING(AffIgnoringHwloc, var);
5778 __kmp_affinity_top_method = affinity_top_method_all;
5781 if (__kmp_affinity_type == affinity_disabled) {
5782 KMP_AFFINITY_DISABLE();
5783 }
else if (!KMP_AFFINITY_CAPABLE()) {
5784 __kmp_affinity_dispatch->determine_capable(var);
5785 if (!KMP_AFFINITY_CAPABLE()) {
5786 if (__kmp_affinity_verbose ||
5787 (__kmp_affinity_warnings &&
5788 (__kmp_affinity_type != affinity_default) &&
5789 (__kmp_affinity_type != affinity_none) &&
5790 (__kmp_affinity_type != affinity_disabled))) {
5791 KMP_WARNING(AffNotSupported, var);
5793 __kmp_affinity_type = affinity_disabled;
5794 __kmp_affinity_respect_mask = 0;
5795 __kmp_affinity_gran = affinity_gran_fine;
5799 if (__kmp_affinity_type == affinity_disabled) {
5800 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
5801 }
else if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_true) {
5803 __kmp_nested_proc_bind.bind_types[0] = proc_bind_spread;
5806 if (KMP_AFFINITY_CAPABLE()) {
5808 #if KMP_GROUP_AFFINITY
5813 bool exactly_one_group =
false;
5814 if (__kmp_num_proc_groups > 1) {
5816 bool within_one_group;
5819 kmp_affin_mask_t *init_mask;
5820 KMP_CPU_ALLOC(init_mask);
5821 __kmp_get_system_affinity(init_mask, TRUE);
5822 group = __kmp_get_proc_group(init_mask);
5823 within_one_group = (group >= 0);
5826 if (within_one_group) {
5827 DWORD num_bits_in_group = __kmp_GetActiveProcessorCount(group);
5828 DWORD num_bits_in_mask = 0;
5829 for (
int bit = init_mask->begin(); bit != init_mask->end();
5830 bit = init_mask->next(bit))
5832 exactly_one_group = (num_bits_in_group == num_bits_in_mask);
5834 KMP_CPU_FREE(init_mask);
5840 if (((__kmp_num_proc_groups > 1) &&
5841 (__kmp_affinity_type == affinity_default) &&
5842 (__kmp_nested_proc_bind.bind_types[0] == proc_bind_default)) ||
5843 (__kmp_affinity_top_method == affinity_top_method_group)) {
5844 if (__kmp_affinity_respect_mask == affinity_respect_mask_default &&
5845 exactly_one_group) {
5846 __kmp_affinity_respect_mask = FALSE;
5848 if (__kmp_affinity_type == affinity_default) {
5849 __kmp_affinity_type = affinity_compact;
5850 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
5852 if (__kmp_affinity_top_method == affinity_top_method_default) {
5853 if (__kmp_affinity_gran == affinity_gran_default) {
5854 __kmp_affinity_top_method = affinity_top_method_group;
5855 __kmp_affinity_gran = affinity_gran_group;
5856 }
else if (__kmp_affinity_gran == affinity_gran_group) {
5857 __kmp_affinity_top_method = affinity_top_method_group;
5859 __kmp_affinity_top_method = affinity_top_method_all;
5861 }
else if (__kmp_affinity_top_method == affinity_top_method_group) {
5862 if (__kmp_affinity_gran == affinity_gran_default) {
5863 __kmp_affinity_gran = affinity_gran_group;
5864 }
else if ((__kmp_affinity_gran != affinity_gran_group) &&
5865 (__kmp_affinity_gran != affinity_gran_fine) &&
5866 (__kmp_affinity_gran != affinity_gran_thread)) {
5867 const char *str = NULL;
5868 switch (__kmp_affinity_gran) {
5869 case affinity_gran_core:
5872 case affinity_gran_package:
5875 case affinity_gran_node:
5878 case affinity_gran_tile:
5882 KMP_DEBUG_ASSERT(0);
5884 KMP_WARNING(AffGranTopGroup, var, str);
5885 __kmp_affinity_gran = affinity_gran_fine;
5888 if (__kmp_affinity_gran == affinity_gran_default) {
5889 __kmp_affinity_gran = affinity_gran_core;
5890 }
else if (__kmp_affinity_gran == affinity_gran_group) {
5891 const char *str = NULL;
5892 switch (__kmp_affinity_type) {
5893 case affinity_physical:
5896 case affinity_logical:
5899 case affinity_compact:
5902 case affinity_scatter:
5905 case affinity_explicit:
5910 KMP_DEBUG_ASSERT(0);
5912 KMP_WARNING(AffGranGroupType, var, str);
5913 __kmp_affinity_gran = affinity_gran_core;
5921 if (__kmp_affinity_respect_mask == affinity_respect_mask_default) {
5922 #if KMP_GROUP_AFFINITY
5923 if (__kmp_num_proc_groups > 1 && exactly_one_group) {
5924 __kmp_affinity_respect_mask = FALSE;
5928 __kmp_affinity_respect_mask = TRUE;
5931 if ((__kmp_nested_proc_bind.bind_types[0] != proc_bind_intel) &&
5932 (__kmp_nested_proc_bind.bind_types[0] != proc_bind_default)) {
5933 if (__kmp_affinity_type == affinity_default) {
5934 __kmp_affinity_type = affinity_compact;
5935 __kmp_affinity_dups = FALSE;
5937 }
else if (__kmp_affinity_type == affinity_default) {
5938 #if KMP_MIC_SUPPORTED
5939 if (__kmp_mic_type != non_mic) {
5940 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
5944 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
5946 #if KMP_MIC_SUPPORTED
5947 if (__kmp_mic_type != non_mic) {
5948 __kmp_affinity_type = affinity_scatter;
5952 __kmp_affinity_type = affinity_none;
5955 if ((__kmp_affinity_gran == affinity_gran_default) &&
5956 (__kmp_affinity_gran_levels < 0)) {
5957 #if KMP_MIC_SUPPORTED
5958 if (__kmp_mic_type != non_mic) {
5959 __kmp_affinity_gran = affinity_gran_fine;
5963 __kmp_affinity_gran = affinity_gran_core;
5966 if (__kmp_affinity_top_method == affinity_top_method_default) {
5967 __kmp_affinity_top_method = affinity_top_method_all;
5972 K_DIAG(1, (
"__kmp_affinity_type == %d\n", __kmp_affinity_type));
5973 K_DIAG(1, (
"__kmp_affinity_compact == %d\n", __kmp_affinity_compact));
5974 K_DIAG(1, (
"__kmp_affinity_offset == %d\n", __kmp_affinity_offset));
5975 K_DIAG(1, (
"__kmp_affinity_verbose == %d\n", __kmp_affinity_verbose));
5976 K_DIAG(1, (
"__kmp_affinity_warnings == %d\n", __kmp_affinity_warnings));
5977 K_DIAG(1, (
"__kmp_affinity_respect_mask == %d\n",
5978 __kmp_affinity_respect_mask));
5979 K_DIAG(1, (
"__kmp_affinity_gran == %d\n", __kmp_affinity_gran));
5981 KMP_DEBUG_ASSERT(__kmp_affinity_type != affinity_default);
5982 KMP_DEBUG_ASSERT(__kmp_nested_proc_bind.bind_types[0] != proc_bind_default);
5983 K_DIAG(1, (
"__kmp_nested_proc_bind.bind_types[0] == %d\n",
5984 __kmp_nested_proc_bind.bind_types[0]));
5989 if (__kmp_version) {
5990 __kmp_print_version_1();
5995 if (
string != NULL) {
5996 __kmp_aux_env_initialize(&block);
5999 __kmp_env_blk_free(&block);
6005 void __kmp_env_print() {
6007 kmp_env_blk_t block;
6009 kmp_str_buf_t buffer;
6012 __kmp_str_buf_init(&buffer);
6014 __kmp_env_blk_init(&block, NULL);
6015 __kmp_env_blk_sort(&block);
6018 __kmp_str_buf_print(&buffer,
"\n%s\n\n", KMP_I18N_STR(UserSettings));
6019 for (i = 0; i < block.count; ++i) {
6020 char const *name = block.vars[i].name;
6021 char const *value = block.vars[i].value;
6022 if ((KMP_STRLEN(name) > 4 && strncmp(name,
"KMP_", 4) == 0) ||
6023 strncmp(name,
"OMP_", 4) == 0
6024 #ifdef KMP_GOMP_COMPAT
6025 || strncmp(name,
"GOMP_", 5) == 0
6028 __kmp_str_buf_print(&buffer,
" %s=%s\n", name, value);
6031 __kmp_str_buf_print(&buffer,
"\n");
6034 __kmp_str_buf_print(&buffer,
"%s\n\n", KMP_I18N_STR(EffectiveSettings));
6035 for (
int i = 0; i < __kmp_stg_count; ++i) {
6036 if (__kmp_stg_table[i].print != NULL) {
6037 __kmp_stg_table[i].print(&buffer, __kmp_stg_table[i].name,
6038 __kmp_stg_table[i].data);
6042 __kmp_printf(
"%s", buffer.str);
6044 __kmp_env_blk_free(&block);
6045 __kmp_str_buf_free(&buffer);
6051 void __kmp_env_print_2() {
6052 __kmp_display_env_impl(__kmp_display_env, __kmp_display_env_verbose);
6056 void __kmp_display_env_impl(
int display_env,
int display_env_verbose) {
6057 kmp_env_blk_t block;
6058 kmp_str_buf_t buffer;
6060 __kmp_env_format = 1;
6063 __kmp_str_buf_init(&buffer);
6065 __kmp_env_blk_init(&block, NULL);
6066 __kmp_env_blk_sort(&block);
6068 __kmp_str_buf_print(&buffer,
"\n%s\n", KMP_I18N_STR(DisplayEnvBegin));
6069 __kmp_str_buf_print(&buffer,
" _OPENMP='%d'\n", __kmp_openmp_version);
6071 for (
int i = 0; i < __kmp_stg_count; ++i) {
6072 if (__kmp_stg_table[i].print != NULL &&
6074 strncmp(__kmp_stg_table[i].name,
"OMP_", 4) == 0) ||
6075 display_env_verbose)) {
6076 __kmp_stg_table[i].print(&buffer, __kmp_stg_table[i].name,
6077 __kmp_stg_table[i].data);
6081 __kmp_str_buf_print(&buffer,
"%s\n", KMP_I18N_STR(DisplayEnvEnd));
6082 __kmp_str_buf_print(&buffer,
"\n");
6084 __kmp_printf(
"%s", buffer.str);
6086 __kmp_env_blk_free(&block);
6087 __kmp_str_buf_free(&buffer);
@ kmp_sch_modifier_monotonic
@ kmp_sch_modifier_nonmonotonic