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 #include "ompd-specific.h" 32 static int __kmp_env_toPrint(
char const *name,
int flag);
34 bool __kmp_env_format = 0;
39 #ifdef USE_LOAD_BALANCE 40 static double __kmp_convert_to_double(
char const *s) {
43 if (KMP_SSCANF(s,
"%lf", &result) < 1) {
52 static unsigned int __kmp_readstr_with_sentinel(
char *dest,
char const *src,
53 size_t len,
char sentinel) {
55 for (i = 0; i < len; i++) {
56 if ((*src ==
'\0') || (*src == sentinel)) {
66 static int __kmp_match_with_sentinel(
char const *a,
char const *b,
size_t len,
74 while (*a && *b && *b != sentinel) {
75 char ca = *a, cb = *b;
77 if (ca >=
'a' && ca <=
'z')
79 if (cb >=
'a' && cb <=
'z')
113 static int __kmp_match_str(
char const *token,
char const *buf,
116 KMP_ASSERT(token != NULL);
117 KMP_ASSERT(buf != NULL);
118 KMP_ASSERT(end != NULL);
120 while (*token && *buf) {
121 char ct = *token, cb = *buf;
123 if (ct >=
'a' && ct <=
'z')
125 if (cb >=
'a' && cb <=
'z')
140 static size_t __kmp_round4k(
size_t size) {
141 size_t _4k = 4 * 1024;
142 if (size & (_4k - 1)) {
144 if (size <= KMP_SIZE_T_MAX - _4k) {
156 int __kmp_convert_to_milliseconds(
char const *data) {
157 int ret, nvalues, factor;
163 if (__kmp_str_match(
"infinit", -1, data))
167 nvalues = KMP_SSCANF(data,
"%lf%c%c", &value, &mult, &extra);
193 factor = 1000 * 60 * 60;
197 factor = 1000 * 24 * 60 * 60;
203 if (value >= ((INT_MAX - 1) / factor))
206 ret = (int)(value * (
double)factor);
211 static int __kmp_strcasecmp_with_sentinel(
char const *a,
char const *b,
217 while (*a && *b && *b != sentinel) {
218 char ca = *a, cb = *b;
220 if (ca >=
'a' && ca <=
'z')
222 if (cb >=
'a' && cb <=
'z')
225 return (
int)(
unsigned char)*a - (
int)(
unsigned char)*b;
229 return *a ? (*b && *b != sentinel)
230 ? (
int)(
unsigned char)*a - (
int)(
unsigned char)*b
232 : (*b && *b != sentinel) ? -1
239 typedef struct __kmp_setting kmp_setting_t;
240 typedef struct __kmp_stg_ss_data kmp_stg_ss_data_t;
241 typedef struct __kmp_stg_wp_data kmp_stg_wp_data_t;
242 typedef struct __kmp_stg_fr_data kmp_stg_fr_data_t;
244 typedef void (*kmp_stg_parse_func_t)(
char const *name,
char const *value,
246 typedef void (*kmp_stg_print_func_t)(kmp_str_buf_t *buffer,
char const *name,
249 struct __kmp_setting {
251 kmp_stg_parse_func_t parse;
252 kmp_stg_print_func_t print;
259 struct __kmp_stg_ss_data {
261 kmp_setting_t **rivals;
264 struct __kmp_stg_wp_data {
266 kmp_setting_t **rivals;
269 struct __kmp_stg_fr_data {
271 kmp_setting_t **rivals;
274 static int __kmp_stg_check_rivals(
277 kmp_setting_t **rivals
283 static void __kmp_stg_parse_bool(
char const *name,
char const *value,
285 if (__kmp_str_match_true(value)) {
287 }
else if (__kmp_str_match_false(value)) {
290 __kmp_msg(kmp_ms_warning, KMP_MSG(BadBoolValue, name, value),
291 KMP_HNT(ValidBoolValues), __kmp_msg_null);
296 void __kmp_check_stksize(
size_t *val) {
298 if (*val > KMP_DEFAULT_STKSIZE * 16)
299 *val = KMP_DEFAULT_STKSIZE * 16;
300 if (*val < KMP_MIN_STKSIZE)
301 *val = KMP_MIN_STKSIZE;
302 if (*val > KMP_MAX_STKSIZE)
303 *val = KMP_MAX_STKSIZE;
305 *val = __kmp_round4k(*val);
306 #endif // KMP_OS_DARWIN 309 static void __kmp_stg_parse_size(
char const *name,
char const *value,
310 size_t size_min,
size_t size_max,
311 int *is_specified,
size_t *out,
313 char const *msg = NULL;
315 size_min = __kmp_round4k(size_min);
316 size_max = __kmp_round4k(size_max);
317 #endif // KMP_OS_DARWIN 319 if (is_specified != NULL) {
322 __kmp_str_to_size(value, out, factor, &msg);
324 if (*out > size_max) {
326 msg = KMP_I18N_STR(ValueTooLarge);
327 }
else if (*out < size_min) {
329 msg = KMP_I18N_STR(ValueTooSmall);
332 size_t round4k = __kmp_round4k(*out);
333 if (*out != round4k) {
335 msg = KMP_I18N_STR(NotMultiple4K);
342 if (*out < size_min) {
344 }
else if (*out > size_max) {
351 __kmp_str_buf_init(&buf);
352 __kmp_str_buf_print_size(&buf, *out);
353 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
354 KMP_INFORM(Using_str_Value, name, buf.str);
355 __kmp_str_buf_free(&buf);
360 static void __kmp_stg_parse_str(
char const *name,
char const *value,
363 *out = __kmp_str_format(
"%s", value);
366 static void __kmp_stg_parse_int(
374 char const *msg = NULL;
375 kmp_uint64 uint = *out;
376 __kmp_str_to_uint(value, &uint, &msg);
378 if (uint < (
unsigned int)min) {
379 msg = KMP_I18N_STR(ValueTooSmall);
381 }
else if (uint > (
unsigned int)max) {
382 msg = KMP_I18N_STR(ValueTooLarge);
388 if (uint < (
unsigned int)min) {
390 }
else if (uint > (
unsigned int)max) {
397 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
398 __kmp_str_buf_init(&buf);
399 __kmp_str_buf_print(&buf,
"%" KMP_UINT64_SPEC
"", uint);
400 KMP_INFORM(Using_uint64_Value, name, buf.str);
401 __kmp_str_buf_free(&buf);
403 __kmp_type_convert(uint, out);
406 #if KMP_DEBUG_ADAPTIVE_LOCKS 407 static void __kmp_stg_parse_file(
char const *name,
char const *value,
408 const char *suffix,
char **out) {
413 t = (
char *)strrchr(value,
'.');
414 hasSuffix = t && __kmp_str_eqf(t, suffix);
415 t = __kmp_str_format(
"%s%s", value, hasSuffix ?
"" : suffix);
416 __kmp_expand_file_name(buffer,
sizeof(buffer), t);
418 *out = __kmp_str_format(
"%s", buffer);
423 static char *par_range_to_print = NULL;
425 static void __kmp_stg_parse_par_range(
char const *name,
char const *value,
426 int *out_range,
char *out_routine,
427 char *out_file,
int *out_lb,
429 size_t len = KMP_STRLEN(value) + 1;
430 par_range_to_print = (
char *)KMP_INTERNAL_MALLOC(len + 1);
431 KMP_STRNCPY_S(par_range_to_print, len + 1, value, len + 1);
432 __kmp_par_range = +1;
433 __kmp_par_range_lb = 0;
434 __kmp_par_range_ub = INT_MAX;
437 if (*value ==
'\0') {
440 if (!__kmp_strcasecmp_with_sentinel(
"routine", value,
'=')) {
441 value = strchr(value,
'=') + 1;
442 len = __kmp_readstr_with_sentinel(out_routine, value,
443 KMP_PAR_RANGE_ROUTINE_LEN - 1,
',');
445 goto par_range_error;
447 value = strchr(value,
',');
453 if (!__kmp_strcasecmp_with_sentinel(
"filename", value,
'=')) {
454 value = strchr(value,
'=') + 1;
455 len = __kmp_readstr_with_sentinel(out_file, value,
456 KMP_PAR_RANGE_FILENAME_LEN - 1,
',');
458 goto par_range_error;
460 value = strchr(value,
',');
466 if ((!__kmp_strcasecmp_with_sentinel(
"range", value,
'=')) ||
467 (!__kmp_strcasecmp_with_sentinel(
"incl_range", value,
'='))) {
468 value = strchr(value,
'=') + 1;
469 if (KMP_SSCANF(value,
"%d:%d", out_lb, out_ub) != 2) {
470 goto par_range_error;
473 value = strchr(value,
',');
479 if (!__kmp_strcasecmp_with_sentinel(
"excl_range", value,
'=')) {
480 value = strchr(value,
'=') + 1;
481 if (KMP_SSCANF(value,
"%d:%d", out_lb, out_ub) != 2) {
482 goto par_range_error;
485 value = strchr(value,
',');
492 KMP_WARNING(ParRangeSyntax, name);
499 int __kmp_initial_threads_capacity(
int req_nproc) {
504 if (nth < (4 * req_nproc))
505 nth = (4 * req_nproc);
506 if (nth < (4 * __kmp_xproc))
507 nth = (4 * __kmp_xproc);
511 if (__kmp_enable_hidden_helper) {
512 nth += __kmp_hidden_helper_threads_num;
515 if (nth > __kmp_max_nth)
521 int __kmp_default_tp_capacity(
int req_nproc,
int max_nth,
522 int all_threads_specified) {
525 if (all_threads_specified)
529 if (nth < (4 * req_nproc))
530 nth = (4 * req_nproc);
531 if (nth < (4 * __kmp_xproc))
532 nth = (4 * __kmp_xproc);
534 if (nth > __kmp_max_nth)
543 static void __kmp_stg_print_bool(kmp_str_buf_t *buffer,
char const *name,
545 if (__kmp_env_format) {
546 KMP_STR_BUF_PRINT_BOOL;
548 __kmp_str_buf_print(buffer,
" %s=%s\n", name, value ?
"true" :
"false");
552 static void __kmp_stg_print_int(kmp_str_buf_t *buffer,
char const *name,
554 if (__kmp_env_format) {
555 KMP_STR_BUF_PRINT_INT;
557 __kmp_str_buf_print(buffer,
" %s=%d\n", name, value);
561 static void __kmp_stg_print_uint64(kmp_str_buf_t *buffer,
char const *name,
563 if (__kmp_env_format) {
564 KMP_STR_BUF_PRINT_UINT64;
566 __kmp_str_buf_print(buffer,
" %s=%" KMP_UINT64_SPEC
"\n", name, value);
570 static void __kmp_stg_print_str(kmp_str_buf_t *buffer,
char const *name,
572 if (__kmp_env_format) {
573 KMP_STR_BUF_PRINT_STR;
575 __kmp_str_buf_print(buffer,
" %s=%s\n", name, value);
579 static void __kmp_stg_print_size(kmp_str_buf_t *buffer,
char const *name,
581 if (__kmp_env_format) {
582 KMP_STR_BUF_PRINT_NAME_EX(name);
583 __kmp_str_buf_print_size(buffer, value);
584 __kmp_str_buf_print(buffer,
"'\n");
586 __kmp_str_buf_print(buffer,
" %s=", name);
587 __kmp_str_buf_print_size(buffer, value);
588 __kmp_str_buf_print(buffer,
"\n");
599 static void __kmp_stg_parse_device_thread_limit(
char const *name,
600 char const *value,
void *data) {
601 kmp_setting_t **rivals = (kmp_setting_t **)data;
603 if (strcmp(name,
"KMP_ALL_THREADS") == 0) {
604 KMP_INFORM(EnvVarDeprecated, name,
"KMP_DEVICE_THREAD_LIMIT");
606 rc = __kmp_stg_check_rivals(name, value, rivals);
610 if (!__kmp_strcasecmp_with_sentinel(
"all", value, 0)) {
611 __kmp_max_nth = __kmp_xproc;
612 __kmp_allThreadsSpecified = 1;
614 __kmp_stg_parse_int(name, value, 1, __kmp_sys_max_nth, &__kmp_max_nth);
615 __kmp_allThreadsSpecified = 0;
617 K_DIAG(1, (
"__kmp_max_nth == %d\n", __kmp_max_nth));
621 static void __kmp_stg_print_device_thread_limit(kmp_str_buf_t *buffer,
622 char const *name,
void *data) {
623 __kmp_stg_print_int(buffer, name, __kmp_max_nth);
628 static void __kmp_stg_parse_thread_limit(
char const *name,
char const *value,
630 __kmp_stg_parse_int(name, value, 1, __kmp_sys_max_nth, &__kmp_cg_max_nth);
631 K_DIAG(1, (
"__kmp_cg_max_nth == %d\n", __kmp_cg_max_nth));
635 static void __kmp_stg_print_thread_limit(kmp_str_buf_t *buffer,
636 char const *name,
void *data) {
637 __kmp_stg_print_int(buffer, name, __kmp_cg_max_nth);
642 static void __kmp_stg_parse_nteams(
char const *name,
char const *value,
644 __kmp_stg_parse_int(name, value, 1, __kmp_sys_max_nth, &__kmp_nteams);
645 K_DIAG(1, (
"__kmp_nteams == %d\n", __kmp_nteams));
648 static void __kmp_stg_print_nteams(kmp_str_buf_t *buffer,
char const *name,
650 __kmp_stg_print_int(buffer, name, __kmp_nteams);
655 static void __kmp_stg_parse_teams_th_limit(
char const *name,
char const *value,
657 __kmp_stg_parse_int(name, value, 1, __kmp_sys_max_nth,
658 &__kmp_teams_thread_limit);
659 K_DIAG(1, (
"__kmp_teams_thread_limit == %d\n", __kmp_teams_thread_limit));
662 static void __kmp_stg_print_teams_th_limit(kmp_str_buf_t *buffer,
663 char const *name,
void *data) {
664 __kmp_stg_print_int(buffer, name, __kmp_teams_thread_limit);
669 static void __kmp_stg_parse_teams_thread_limit(
char const *name,
670 char const *value,
void *data) {
671 __kmp_stg_parse_int(name, value, 1, __kmp_sys_max_nth, &__kmp_teams_max_nth);
674 static void __kmp_stg_print_teams_thread_limit(kmp_str_buf_t *buffer,
675 char const *name,
void *data) {
676 __kmp_stg_print_int(buffer, name, __kmp_teams_max_nth);
681 static void __kmp_stg_parse_use_yield(
char const *name,
char const *value,
683 __kmp_stg_parse_int(name, value, 0, 2, &__kmp_use_yield);
684 __kmp_use_yield_exp_set = 1;
687 static void __kmp_stg_print_use_yield(kmp_str_buf_t *buffer,
char const *name,
689 __kmp_stg_print_int(buffer, name, __kmp_use_yield);
695 static void __kmp_stg_parse_blocktime(
char const *name,
char const *value,
697 __kmp_dflt_blocktime = __kmp_convert_to_milliseconds(value);
698 if (__kmp_dflt_blocktime < 0) {
699 __kmp_dflt_blocktime = KMP_DEFAULT_BLOCKTIME;
700 __kmp_msg(kmp_ms_warning, KMP_MSG(InvalidValue, name, value),
702 KMP_INFORM(Using_int_Value, name, __kmp_dflt_blocktime);
703 __kmp_env_blocktime = FALSE;
705 if (__kmp_dflt_blocktime < KMP_MIN_BLOCKTIME) {
706 __kmp_dflt_blocktime = KMP_MIN_BLOCKTIME;
707 __kmp_msg(kmp_ms_warning, KMP_MSG(SmallValue, name, value),
709 KMP_INFORM(MinValueUsing, name, __kmp_dflt_blocktime);
710 }
else if (__kmp_dflt_blocktime > KMP_MAX_BLOCKTIME) {
711 __kmp_dflt_blocktime = KMP_MAX_BLOCKTIME;
712 __kmp_msg(kmp_ms_warning, KMP_MSG(LargeValue, name, value),
714 KMP_INFORM(MaxValueUsing, name, __kmp_dflt_blocktime);
716 __kmp_env_blocktime = TRUE;
721 __kmp_monitor_wakeups =
722 KMP_WAKEUPS_FROM_BLOCKTIME(__kmp_dflt_blocktime, __kmp_monitor_wakeups);
724 KMP_INTERVALS_FROM_BLOCKTIME(__kmp_dflt_blocktime, __kmp_monitor_wakeups);
726 K_DIAG(1, (
"__kmp_env_blocktime == %d\n", __kmp_env_blocktime));
727 if (__kmp_env_blocktime) {
728 K_DIAG(1, (
"__kmp_dflt_blocktime == %d\n", __kmp_dflt_blocktime));
732 static void __kmp_stg_print_blocktime(kmp_str_buf_t *buffer,
char const *name,
734 __kmp_stg_print_int(buffer, name, __kmp_dflt_blocktime);
740 static void __kmp_stg_parse_duplicate_lib_ok(
char const *name,
741 char const *value,
void *data) {
744 __kmp_stg_parse_bool(name, value, &__kmp_duplicate_library_ok);
747 static void __kmp_stg_print_duplicate_lib_ok(kmp_str_buf_t *buffer,
748 char const *name,
void *data) {
749 __kmp_stg_print_bool(buffer, name, __kmp_duplicate_library_ok);
755 #if KMP_ARCH_X86 || KMP_ARCH_X86_64 757 static void __kmp_stg_parse_inherit_fp_control(
char const *name,
758 char const *value,
void *data) {
759 __kmp_stg_parse_bool(name, value, &__kmp_inherit_fp_control);
762 static void __kmp_stg_print_inherit_fp_control(kmp_str_buf_t *buffer,
763 char const *name,
void *data) {
765 __kmp_stg_print_bool(buffer, name, __kmp_inherit_fp_control);
772 static char const *blocktime_str = NULL;
777 static void __kmp_stg_parse_wait_policy(
char const *name,
char const *value,
780 kmp_stg_wp_data_t *wait = (kmp_stg_wp_data_t *)data;
783 rc = __kmp_stg_check_rivals(name, value, wait->rivals);
789 if (__kmp_str_match(
"ACTIVE", 1, value)) {
790 __kmp_library = library_turnaround;
791 if (blocktime_str == NULL) {
793 __kmp_dflt_blocktime = KMP_MAX_BLOCKTIME;
795 }
else if (__kmp_str_match(
"PASSIVE", 1, value)) {
796 __kmp_library = library_throughput;
797 if (blocktime_str == NULL) {
799 __kmp_dflt_blocktime = 0;
802 KMP_WARNING(StgInvalidValue, name, value);
805 if (__kmp_str_match(
"serial", 1, value)) {
806 __kmp_library = library_serial;
807 }
else if (__kmp_str_match(
"throughput", 2, value)) {
808 __kmp_library = library_throughput;
809 if (blocktime_str == NULL) {
811 __kmp_dflt_blocktime = 0;
813 }
else if (__kmp_str_match(
"turnaround", 2, value)) {
814 __kmp_library = library_turnaround;
815 }
else if (__kmp_str_match(
"dedicated", 1, value)) {
816 __kmp_library = library_turnaround;
817 }
else if (__kmp_str_match(
"multiuser", 1, value)) {
818 __kmp_library = library_throughput;
819 if (blocktime_str == NULL) {
821 __kmp_dflt_blocktime = 0;
824 KMP_WARNING(StgInvalidValue, name, value);
829 static void __kmp_stg_print_wait_policy(kmp_str_buf_t *buffer,
char const *name,
832 kmp_stg_wp_data_t *wait = (kmp_stg_wp_data_t *)data;
833 char const *value = NULL;
836 switch (__kmp_library) {
837 case library_turnaround: {
840 case library_throughput: {
845 switch (__kmp_library) {
846 case library_serial: {
849 case library_turnaround: {
850 value =
"turnaround";
852 case library_throughput: {
853 value =
"throughput";
858 __kmp_stg_print_str(buffer, name, value);
867 static void __kmp_stg_parse_monitor_stacksize(
char const *name,
868 char const *value,
void *data) {
869 __kmp_stg_parse_size(name, value, __kmp_sys_min_stksize, KMP_MAX_STKSIZE,
870 NULL, &__kmp_monitor_stksize, 1);
873 static void __kmp_stg_print_monitor_stacksize(kmp_str_buf_t *buffer,
874 char const *name,
void *data) {
875 if (__kmp_env_format) {
876 if (__kmp_monitor_stksize > 0)
877 KMP_STR_BUF_PRINT_NAME_EX(name);
879 KMP_STR_BUF_PRINT_NAME;
881 __kmp_str_buf_print(buffer,
" %s", name);
883 if (__kmp_monitor_stksize > 0) {
884 __kmp_str_buf_print_size(buffer, __kmp_monitor_stksize);
886 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
888 if (__kmp_env_format && __kmp_monitor_stksize) {
889 __kmp_str_buf_print(buffer,
"'\n");
892 #endif // KMP_USE_MONITOR 897 static void __kmp_stg_parse_settings(
char const *name,
char const *value,
899 __kmp_stg_parse_bool(name, value, &__kmp_settings);
902 static void __kmp_stg_print_settings(kmp_str_buf_t *buffer,
char const *name,
904 __kmp_stg_print_bool(buffer, name, __kmp_settings);
910 static void __kmp_stg_parse_stackpad(
char const *name,
char const *value,
912 __kmp_stg_parse_int(name,
920 static void __kmp_stg_print_stackpad(kmp_str_buf_t *buffer,
char const *name,
922 __kmp_stg_print_int(buffer, name, __kmp_stkpadding);
928 static void __kmp_stg_parse_stackoffset(
char const *name,
char const *value,
930 __kmp_stg_parse_size(name,
939 static void __kmp_stg_print_stackoffset(kmp_str_buf_t *buffer,
char const *name,
941 __kmp_stg_print_size(buffer, name, __kmp_stkoffset);
947 static void __kmp_stg_parse_stacksize(
char const *name,
char const *value,
950 kmp_stg_ss_data_t *stacksize = (kmp_stg_ss_data_t *)data;
953 rc = __kmp_stg_check_rivals(name, value, stacksize->rivals);
957 __kmp_stg_parse_size(name,
959 __kmp_sys_min_stksize,
971 static void __kmp_stg_print_stacksize(kmp_str_buf_t *buffer,
char const *name,
973 kmp_stg_ss_data_t *stacksize = (kmp_stg_ss_data_t *)data;
974 if (__kmp_env_format) {
975 KMP_STR_BUF_PRINT_NAME_EX(name);
976 __kmp_str_buf_print_size(buffer, (__kmp_stksize % 1024)
977 ? __kmp_stksize / stacksize->factor
979 __kmp_str_buf_print(buffer,
"'\n");
981 __kmp_str_buf_print(buffer,
" %s=", name);
982 __kmp_str_buf_print_size(buffer, (__kmp_stksize % 1024)
983 ? __kmp_stksize / stacksize->factor
985 __kmp_str_buf_print(buffer,
"\n");
992 static void __kmp_stg_parse_version(
char const *name,
char const *value,
994 __kmp_stg_parse_bool(name, value, &__kmp_version);
997 static void __kmp_stg_print_version(kmp_str_buf_t *buffer,
char const *name,
999 __kmp_stg_print_bool(buffer, name, __kmp_version);
1005 static void __kmp_stg_parse_warnings(
char const *name,
char const *value,
1007 __kmp_stg_parse_bool(name, value, &__kmp_generate_warnings);
1008 if (__kmp_generate_warnings != kmp_warnings_off) {
1011 __kmp_generate_warnings = kmp_warnings_explicit;
1015 static void __kmp_stg_print_warnings(kmp_str_buf_t *buffer,
char const *name,
1018 __kmp_stg_print_bool(buffer, name, __kmp_generate_warnings);
1024 static void __kmp_stg_parse_nesting_mode(
char const *name,
char const *value,
1026 __kmp_stg_parse_int(name, value, 0, INT_MAX, &__kmp_nesting_mode);
1027 #if KMP_AFFINITY_SUPPORTED && KMP_USE_HWLOC 1028 if (__kmp_nesting_mode > 0)
1029 __kmp_affinity_top_method = affinity_top_method_hwloc;
1033 static void __kmp_stg_print_nesting_mode(kmp_str_buf_t *buffer,
1034 char const *name,
void *data) {
1035 if (__kmp_env_format) {
1036 KMP_STR_BUF_PRINT_NAME;
1038 __kmp_str_buf_print(buffer,
" %s", name);
1040 __kmp_str_buf_print(buffer,
"=%d\n", __kmp_nesting_mode);
1046 static void __kmp_stg_parse_nested(
char const *name,
char const *value,
1049 KMP_INFORM(EnvVarDeprecated, name,
"OMP_MAX_ACTIVE_LEVELS");
1050 __kmp_stg_parse_bool(name, value, &nested);
1052 if (!__kmp_dflt_max_active_levels_set)
1053 __kmp_dflt_max_active_levels = KMP_MAX_ACTIVE_LEVELS_LIMIT;
1055 __kmp_dflt_max_active_levels = 1;
1056 __kmp_dflt_max_active_levels_set =
true;
1060 static void __kmp_stg_print_nested(kmp_str_buf_t *buffer,
char const *name,
1062 if (__kmp_env_format) {
1063 KMP_STR_BUF_PRINT_NAME;
1065 __kmp_str_buf_print(buffer,
" %s", name);
1067 __kmp_str_buf_print(buffer,
": deprecated; max-active-levels-var=%d\n",
1068 __kmp_dflt_max_active_levels);
1071 static void __kmp_parse_nested_num_threads(
const char *var,
const char *env,
1072 kmp_nested_nthreads_t *nth_array) {
1073 const char *next = env;
1074 const char *scan = next;
1077 int prev_comma = FALSE;
1083 if (*next ==
'\0') {
1087 if (((*next <
'0') || (*next >
'9')) && (*next !=
',')) {
1088 KMP_WARNING(NthSyntaxError, var, env);
1094 if (total == 0 || prev_comma) {
1102 if (*next >=
'0' && *next <=
'9') {
1106 const char *tmp = next;
1108 if ((*next ==
' ' || *next ==
'\t') && (*tmp >=
'0' && *tmp <=
'9')) {
1109 KMP_WARNING(NthSpacesNotAllowed, var, env);
1114 if (!__kmp_dflt_max_active_levels_set && total > 1)
1115 __kmp_dflt_max_active_levels = KMP_MAX_ACTIVE_LEVELS_LIMIT;
1116 KMP_DEBUG_ASSERT(total > 0);
1118 KMP_WARNING(NthSyntaxError, var, env);
1123 if (!nth_array->nth) {
1125 nth_array->nth = (
int *)KMP_INTERNAL_MALLOC(
sizeof(
int) * total * 2);
1126 if (nth_array->nth == NULL) {
1127 KMP_FATAL(MemoryAllocFailed);
1129 nth_array->size = total * 2;
1131 if (nth_array->size < total) {
1134 nth_array->size *= 2;
1135 }
while (nth_array->size < total);
1137 nth_array->nth = (
int *)KMP_INTERNAL_REALLOC(
1138 nth_array->nth,
sizeof(
int) * nth_array->size);
1139 if (nth_array->nth == NULL) {
1140 KMP_FATAL(MemoryAllocFailed);
1144 nth_array->used = total;
1152 if (*scan ==
'\0') {
1162 nth_array->nth[i++] = 0;
1164 }
else if (prev_comma) {
1166 nth_array->nth[i] = nth_array->nth[i - 1];
1175 if (*scan >=
'0' && *scan <=
'9') {
1177 const char *buf = scan;
1178 char const *msg = NULL;
1183 num = __kmp_str_to_int(buf, *scan);
1184 if (num < KMP_MIN_NTH) {
1185 msg = KMP_I18N_STR(ValueTooSmall);
1187 }
else if (num > __kmp_sys_max_nth) {
1188 msg = KMP_I18N_STR(ValueTooLarge);
1189 num = __kmp_sys_max_nth;
1193 KMP_WARNING(ParseSizeIntWarn, var, env, msg);
1194 KMP_INFORM(Using_int_Value, var, num);
1196 nth_array->nth[i++] = num;
1201 static void __kmp_stg_parse_num_threads(
char const *name,
char const *value,
1204 if (!__kmp_strcasecmp_with_sentinel(
"all", value, 0)) {
1206 __kmp_nested_nth.nth = (
int *)KMP_INTERNAL_MALLOC(
sizeof(
int));
1207 __kmp_nested_nth.size = __kmp_nested_nth.used = 1;
1208 __kmp_nested_nth.nth[0] = __kmp_dflt_team_nth = __kmp_dflt_team_nth_ub =
1211 __kmp_parse_nested_num_threads(name, value, &__kmp_nested_nth);
1212 if (__kmp_nested_nth.nth) {
1213 __kmp_dflt_team_nth = __kmp_nested_nth.nth[0];
1214 if (__kmp_dflt_team_nth_ub < __kmp_dflt_team_nth) {
1215 __kmp_dflt_team_nth_ub = __kmp_dflt_team_nth;
1219 K_DIAG(1, (
"__kmp_dflt_team_nth == %d\n", __kmp_dflt_team_nth));
1222 static void __kmp_stg_parse_num_hidden_helper_threads(
char const *name,
1225 __kmp_stg_parse_int(name, value, 0, 16, &__kmp_hidden_helper_threads_num);
1228 if (__kmp_hidden_helper_threads_num == 0) {
1229 __kmp_enable_hidden_helper = FALSE;
1233 static void __kmp_stg_print_num_hidden_helper_threads(kmp_str_buf_t *buffer,
1236 __kmp_stg_print_int(buffer, name, __kmp_hidden_helper_threads_num);
1239 static void __kmp_stg_parse_use_hidden_helper(
char const *name,
1240 char const *value,
void *data) {
1241 __kmp_stg_parse_bool(name, value, &__kmp_enable_hidden_helper);
1243 __kmp_enable_hidden_helper = FALSE;
1245 (
"__kmp_stg_parse_use_hidden_helper: Disable hidden helper task on " 1246 "non-Linux platform although it is enabled by user explicitly.\n"));
1250 static void __kmp_stg_print_use_hidden_helper(kmp_str_buf_t *buffer,
1251 char const *name,
void *data) {
1252 __kmp_stg_print_bool(buffer, name, __kmp_enable_hidden_helper);
1255 static void __kmp_stg_print_num_threads(kmp_str_buf_t *buffer,
char const *name,
1257 if (__kmp_env_format) {
1258 KMP_STR_BUF_PRINT_NAME;
1260 __kmp_str_buf_print(buffer,
" %s", name);
1262 if (__kmp_nested_nth.used) {
1264 __kmp_str_buf_init(&buf);
1265 for (
int i = 0; i < __kmp_nested_nth.used; i++) {
1266 __kmp_str_buf_print(&buf,
"%d", __kmp_nested_nth.nth[i]);
1267 if (i < __kmp_nested_nth.used - 1) {
1268 __kmp_str_buf_print(&buf,
",");
1271 __kmp_str_buf_print(buffer,
"='%s'\n", buf.str);
1272 __kmp_str_buf_free(&buf);
1274 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
1281 static void __kmp_stg_parse_tasking(
char const *name,
char const *value,
1283 __kmp_stg_parse_int(name, value, 0, (
int)tskm_max,
1284 (
int *)&__kmp_tasking_mode);
1287 static void __kmp_stg_print_tasking(kmp_str_buf_t *buffer,
char const *name,
1289 __kmp_stg_print_int(buffer, name, __kmp_tasking_mode);
1292 static void __kmp_stg_parse_task_stealing(
char const *name,
char const *value,
1294 __kmp_stg_parse_int(name, value, 0, 1,
1295 (
int *)&__kmp_task_stealing_constraint);
1298 static void __kmp_stg_print_task_stealing(kmp_str_buf_t *buffer,
1299 char const *name,
void *data) {
1300 __kmp_stg_print_int(buffer, name, __kmp_task_stealing_constraint);
1303 static void __kmp_stg_parse_max_active_levels(
char const *name,
1304 char const *value,
void *data) {
1305 kmp_uint64 tmp_dflt = 0;
1306 char const *msg = NULL;
1307 if (!__kmp_dflt_max_active_levels_set) {
1309 __kmp_str_to_uint(value, &tmp_dflt, &msg);
1311 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
1312 }
else if (tmp_dflt > KMP_MAX_ACTIVE_LEVELS_LIMIT) {
1314 msg = KMP_I18N_STR(ValueTooLarge);
1315 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
1317 __kmp_type_convert(tmp_dflt, &(__kmp_dflt_max_active_levels));
1318 __kmp_dflt_max_active_levels_set =
true;
1323 static void __kmp_stg_print_max_active_levels(kmp_str_buf_t *buffer,
1324 char const *name,
void *data) {
1325 __kmp_stg_print_int(buffer, name, __kmp_dflt_max_active_levels);
1330 static void __kmp_stg_parse_default_device(
char const *name,
char const *value,
1332 __kmp_stg_parse_int(name, value, 0, KMP_MAX_DEFAULT_DEVICE_LIMIT,
1333 &__kmp_default_device);
1336 static void __kmp_stg_print_default_device(kmp_str_buf_t *buffer,
1337 char const *name,
void *data) {
1338 __kmp_stg_print_int(buffer, name, __kmp_default_device);
1343 static void __kmp_stg_parse_target_offload(
char const *name,
char const *value,
1345 const char *next = value;
1346 const char *scan = next;
1348 __kmp_target_offload = tgt_default;
1353 if (!__kmp_strcasecmp_with_sentinel(
"mandatory", scan, 0)) {
1354 __kmp_target_offload = tgt_mandatory;
1355 }
else if (!__kmp_strcasecmp_with_sentinel(
"disabled", scan, 0)) {
1356 __kmp_target_offload = tgt_disabled;
1357 }
else if (!__kmp_strcasecmp_with_sentinel(
"default", scan, 0)) {
1358 __kmp_target_offload = tgt_default;
1360 KMP_WARNING(SyntaxErrorUsing, name,
"DEFAULT");
1365 static void __kmp_stg_print_target_offload(kmp_str_buf_t *buffer,
1366 char const *name,
void *data) {
1367 const char *value = NULL;
1368 if (__kmp_target_offload == tgt_default)
1370 else if (__kmp_target_offload == tgt_mandatory)
1371 value =
"MANDATORY";
1372 else if (__kmp_target_offload == tgt_disabled)
1374 KMP_DEBUG_ASSERT(value);
1375 if (__kmp_env_format) {
1376 KMP_STR_BUF_PRINT_NAME;
1378 __kmp_str_buf_print(buffer,
" %s", name);
1380 __kmp_str_buf_print(buffer,
"=%s\n", value);
1385 static void __kmp_stg_parse_max_task_priority(
char const *name,
1386 char const *value,
void *data) {
1387 __kmp_stg_parse_int(name, value, 0, KMP_MAX_TASK_PRIORITY_LIMIT,
1388 &__kmp_max_task_priority);
1391 static void __kmp_stg_print_max_task_priority(kmp_str_buf_t *buffer,
1392 char const *name,
void *data) {
1393 __kmp_stg_print_int(buffer, name, __kmp_max_task_priority);
1398 static void __kmp_stg_parse_taskloop_min_tasks(
char const *name,
1399 char const *value,
void *data) {
1401 __kmp_stg_parse_int(name, value, 0, INT_MAX, &tmp);
1402 __kmp_taskloop_min_tasks = tmp;
1405 static void __kmp_stg_print_taskloop_min_tasks(kmp_str_buf_t *buffer,
1406 char const *name,
void *data) {
1407 __kmp_stg_print_uint64(buffer, name, __kmp_taskloop_min_tasks);
1412 static void __kmp_stg_parse_disp_buffers(
char const *name,
char const *value,
1414 if (TCR_4(__kmp_init_serial)) {
1415 KMP_WARNING(EnvSerialWarn, name);
1418 __kmp_stg_parse_int(name, value, KMP_MIN_DISP_NUM_BUFF, KMP_MAX_DISP_NUM_BUFF,
1419 &__kmp_dispatch_num_buffers);
1422 static void __kmp_stg_print_disp_buffers(kmp_str_buf_t *buffer,
1423 char const *name,
void *data) {
1424 __kmp_stg_print_int(buffer, name, __kmp_dispatch_num_buffers);
1427 #if KMP_NESTED_HOT_TEAMS 1431 static void __kmp_stg_parse_hot_teams_level(
char const *name,
char const *value,
1433 if (TCR_4(__kmp_init_parallel)) {
1434 KMP_WARNING(EnvParallelWarn, name);
1437 __kmp_stg_parse_int(name, value, 0, KMP_MAX_ACTIVE_LEVELS_LIMIT,
1438 &__kmp_hot_teams_max_level);
1441 static void __kmp_stg_print_hot_teams_level(kmp_str_buf_t *buffer,
1442 char const *name,
void *data) {
1443 __kmp_stg_print_int(buffer, name, __kmp_hot_teams_max_level);
1446 static void __kmp_stg_parse_hot_teams_mode(
char const *name,
char const *value,
1448 if (TCR_4(__kmp_init_parallel)) {
1449 KMP_WARNING(EnvParallelWarn, name);
1452 __kmp_stg_parse_int(name, value, 0, KMP_MAX_ACTIVE_LEVELS_LIMIT,
1453 &__kmp_hot_teams_mode);
1456 static void __kmp_stg_print_hot_teams_mode(kmp_str_buf_t *buffer,
1457 char const *name,
void *data) {
1458 __kmp_stg_print_int(buffer, name, __kmp_hot_teams_mode);
1461 #endif // KMP_NESTED_HOT_TEAMS 1466 #if KMP_HANDLE_SIGNALS 1468 static void __kmp_stg_parse_handle_signals(
char const *name,
char const *value,
1470 __kmp_stg_parse_bool(name, value, &__kmp_handle_signals);
1473 static void __kmp_stg_print_handle_signals(kmp_str_buf_t *buffer,
1474 char const *name,
void *data) {
1475 __kmp_stg_print_bool(buffer, name, __kmp_handle_signals);
1478 #endif // KMP_HANDLE_SIGNALS 1485 #define KMP_STG_X_DEBUG(x) \ 1486 static void __kmp_stg_parse_##x##_debug(char const *name, char const *value, \ 1488 __kmp_stg_parse_int(name, value, 0, INT_MAX, &kmp_##x##_debug); \ 1490 static void __kmp_stg_print_##x##_debug(kmp_str_buf_t *buffer, \ 1491 char const *name, void *data) { \ 1492 __kmp_stg_print_int(buffer, name, kmp_##x##_debug); \ 1502 #undef KMP_STG_X_DEBUG 1504 static void __kmp_stg_parse_debug(
char const *name,
char const *value,
1507 __kmp_stg_parse_int(name, value, 0, INT_MAX, &debug);
1508 if (kmp_a_debug < debug) {
1509 kmp_a_debug = debug;
1511 if (kmp_b_debug < debug) {
1512 kmp_b_debug = debug;
1514 if (kmp_c_debug < debug) {
1515 kmp_c_debug = debug;
1517 if (kmp_d_debug < debug) {
1518 kmp_d_debug = debug;
1520 if (kmp_e_debug < debug) {
1521 kmp_e_debug = debug;
1523 if (kmp_f_debug < debug) {
1524 kmp_f_debug = debug;
1528 static void __kmp_stg_parse_debug_buf(
char const *name,
char const *value,
1530 __kmp_stg_parse_bool(name, value, &__kmp_debug_buf);
1534 if (__kmp_debug_buf) {
1536 int elements = __kmp_debug_buf_lines * __kmp_debug_buf_chars;
1539 __kmp_debug_buffer = (
char *)__kmp_page_allocate(elements *
sizeof(
char));
1540 for (i = 0; i < elements; i += __kmp_debug_buf_chars)
1541 __kmp_debug_buffer[i] =
'\0';
1543 __kmp_debug_count = 0;
1545 K_DIAG(1, (
"__kmp_debug_buf = %d\n", __kmp_debug_buf));
1548 static void __kmp_stg_print_debug_buf(kmp_str_buf_t *buffer,
char const *name,
1550 __kmp_stg_print_bool(buffer, name, __kmp_debug_buf);
1553 static void __kmp_stg_parse_debug_buf_atomic(
char const *name,
1554 char const *value,
void *data) {
1555 __kmp_stg_parse_bool(name, value, &__kmp_debug_buf_atomic);
1558 static void __kmp_stg_print_debug_buf_atomic(kmp_str_buf_t *buffer,
1559 char const *name,
void *data) {
1560 __kmp_stg_print_bool(buffer, name, __kmp_debug_buf_atomic);
1563 static void __kmp_stg_parse_debug_buf_chars(
char const *name,
char const *value,
1565 __kmp_stg_parse_int(name, value, KMP_DEBUG_BUF_CHARS_MIN, INT_MAX,
1566 &__kmp_debug_buf_chars);
1569 static void __kmp_stg_print_debug_buf_chars(kmp_str_buf_t *buffer,
1570 char const *name,
void *data) {
1571 __kmp_stg_print_int(buffer, name, __kmp_debug_buf_chars);
1574 static void __kmp_stg_parse_debug_buf_lines(
char const *name,
char const *value,
1576 __kmp_stg_parse_int(name, value, KMP_DEBUG_BUF_LINES_MIN, INT_MAX,
1577 &__kmp_debug_buf_lines);
1580 static void __kmp_stg_print_debug_buf_lines(kmp_str_buf_t *buffer,
1581 char const *name,
void *data) {
1582 __kmp_stg_print_int(buffer, name, __kmp_debug_buf_lines);
1585 static void __kmp_stg_parse_diag(
char const *name,
char const *value,
1587 __kmp_stg_parse_int(name, value, 0, INT_MAX, &kmp_diag);
1590 static void __kmp_stg_print_diag(kmp_str_buf_t *buffer,
char const *name,
1592 __kmp_stg_print_int(buffer, name, kmp_diag);
1600 static void __kmp_stg_parse_align_alloc(
char const *name,
char const *value,
1602 __kmp_stg_parse_size(name, value, CACHE_LINE, INT_MAX, NULL,
1603 &__kmp_align_alloc, 1);
1606 static void __kmp_stg_print_align_alloc(kmp_str_buf_t *buffer,
char const *name,
1608 __kmp_stg_print_size(buffer, name, __kmp_align_alloc);
1617 static void __kmp_stg_parse_barrier_branch_bit(
char const *name,
1618 char const *value,
void *data) {
1622 for (
int i = bs_plain_barrier; i < bs_last_barrier; i++) {
1623 var = __kmp_barrier_branch_bit_env_name[i];
1624 if ((strcmp(var, name) == 0) && (value != 0)) {
1627 comma = CCAST(
char *, strchr(value,
','));
1628 __kmp_barrier_gather_branch_bits[i] =
1629 (kmp_uint32)__kmp_str_to_int(value,
',');
1631 if (comma == NULL) {
1632 __kmp_barrier_release_branch_bits[i] = __kmp_barrier_release_bb_dflt;
1634 __kmp_barrier_release_branch_bits[i] =
1635 (kmp_uint32)__kmp_str_to_int(comma + 1, 0);
1637 if (__kmp_barrier_release_branch_bits[i] > KMP_MAX_BRANCH_BITS) {
1638 __kmp_msg(kmp_ms_warning,
1639 KMP_MSG(BarrReleaseValueInvalid, name, comma + 1),
1641 __kmp_barrier_release_branch_bits[i] = __kmp_barrier_release_bb_dflt;
1644 if (__kmp_barrier_gather_branch_bits[i] > KMP_MAX_BRANCH_BITS) {
1645 KMP_WARNING(BarrGatherValueInvalid, name, value);
1646 KMP_INFORM(Using_uint_Value, name, __kmp_barrier_gather_bb_dflt);
1647 __kmp_barrier_gather_branch_bits[i] = __kmp_barrier_gather_bb_dflt;
1650 K_DIAG(1, (
"%s == %d,%d\n", __kmp_barrier_branch_bit_env_name[i],
1651 __kmp_barrier_gather_branch_bits[i],
1652 __kmp_barrier_release_branch_bits[i]))
1656 static void __kmp_stg_print_barrier_branch_bit(kmp_str_buf_t *buffer,
1657 char const *name,
void *data) {
1659 for (
int i = bs_plain_barrier; i < bs_last_barrier; i++) {
1660 var = __kmp_barrier_branch_bit_env_name[i];
1661 if (strcmp(var, name) == 0) {
1662 if (__kmp_env_format) {
1663 KMP_STR_BUF_PRINT_NAME_EX(__kmp_barrier_branch_bit_env_name[i]);
1665 __kmp_str_buf_print(buffer,
" %s='",
1666 __kmp_barrier_branch_bit_env_name[i]);
1668 __kmp_str_buf_print(buffer,
"%d,%d'\n",
1669 __kmp_barrier_gather_branch_bits[i],
1670 __kmp_barrier_release_branch_bits[i]);
1682 static void __kmp_stg_parse_barrier_pattern(
char const *name,
char const *value,
1687 for (
int i = bs_plain_barrier; i < bs_last_barrier; i++) {
1688 var = __kmp_barrier_pattern_env_name[i];
1690 if ((strcmp(var, name) == 0) && (value != 0)) {
1692 char *comma = CCAST(
char *, strchr(value,
','));
1695 for (j = bp_linear_bar; j < bp_last_bar; j++) {
1696 if (__kmp_match_with_sentinel(__kmp_barrier_pattern_name[j], value, 1,
1698 __kmp_barrier_gather_pattern[i] = (kmp_bar_pat_e)j;
1702 if (j == bp_last_bar) {
1703 KMP_WARNING(BarrGatherValueInvalid, name, value);
1704 KMP_INFORM(Using_str_Value, name,
1705 __kmp_barrier_pattern_name[bp_linear_bar]);
1709 if (comma != NULL) {
1710 for (j = bp_linear_bar; j < bp_last_bar; j++) {
1711 if (__kmp_str_match(__kmp_barrier_pattern_name[j], 1, comma + 1)) {
1712 __kmp_barrier_release_pattern[i] = (kmp_bar_pat_e)j;
1716 if (j == bp_last_bar) {
1717 __kmp_msg(kmp_ms_warning,
1718 KMP_MSG(BarrReleaseValueInvalid, name, comma + 1),
1720 KMP_INFORM(Using_str_Value, name,
1721 __kmp_barrier_pattern_name[bp_linear_bar]);
1728 static void __kmp_stg_print_barrier_pattern(kmp_str_buf_t *buffer,
1729 char const *name,
void *data) {
1731 for (
int i = bs_plain_barrier; i < bs_last_barrier; i++) {
1732 var = __kmp_barrier_pattern_env_name[i];
1733 if (strcmp(var, name) == 0) {
1734 int j = __kmp_barrier_gather_pattern[i];
1735 int k = __kmp_barrier_release_pattern[i];
1736 if (__kmp_env_format) {
1737 KMP_STR_BUF_PRINT_NAME_EX(__kmp_barrier_pattern_env_name[i]);
1739 __kmp_str_buf_print(buffer,
" %s='",
1740 __kmp_barrier_pattern_env_name[i]);
1742 KMP_DEBUG_ASSERT(j < bs_last_barrier && k < bs_last_barrier);
1743 __kmp_str_buf_print(buffer,
"%s,%s'\n", __kmp_barrier_pattern_name[j],
1744 __kmp_barrier_pattern_name[k]);
1752 static void __kmp_stg_parse_abort_delay(
char const *name,
char const *value,
1756 int delay = __kmp_abort_delay / 1000;
1757 __kmp_stg_parse_int(name, value, 0, INT_MAX / 1000, &delay);
1758 __kmp_abort_delay = delay * 1000;
1761 static void __kmp_stg_print_abort_delay(kmp_str_buf_t *buffer,
char const *name,
1763 __kmp_stg_print_int(buffer, name, __kmp_abort_delay);
1769 static void __kmp_stg_parse_cpuinfo_file(
char const *name,
char const *value,
1771 #if KMP_AFFINITY_SUPPORTED 1772 __kmp_stg_parse_str(name, value, &__kmp_cpuinfo_file);
1773 K_DIAG(1, (
"__kmp_cpuinfo_file == %s\n", __kmp_cpuinfo_file));
1777 static void __kmp_stg_print_cpuinfo_file(kmp_str_buf_t *buffer,
1778 char const *name,
void *data) {
1779 #if KMP_AFFINITY_SUPPORTED 1780 if (__kmp_env_format) {
1781 KMP_STR_BUF_PRINT_NAME;
1783 __kmp_str_buf_print(buffer,
" %s", name);
1785 if (__kmp_cpuinfo_file) {
1786 __kmp_str_buf_print(buffer,
"='%s'\n", __kmp_cpuinfo_file);
1788 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
1796 static void __kmp_stg_parse_force_reduction(
char const *name,
char const *value,
1798 kmp_stg_fr_data_t *reduction = (kmp_stg_fr_data_t *)data;
1801 rc = __kmp_stg_check_rivals(name, value, reduction->rivals);
1805 if (reduction->force) {
1807 if (__kmp_str_match(
"critical", 0, value))
1808 __kmp_force_reduction_method = critical_reduce_block;
1809 else if (__kmp_str_match(
"atomic", 0, value))
1810 __kmp_force_reduction_method = atomic_reduce_block;
1811 else if (__kmp_str_match(
"tree", 0, value))
1812 __kmp_force_reduction_method = tree_reduce_block;
1814 KMP_FATAL(UnknownForceReduction, name, value);
1818 __kmp_stg_parse_bool(name, value, &__kmp_determ_red);
1819 if (__kmp_determ_red) {
1820 __kmp_force_reduction_method = tree_reduce_block;
1822 __kmp_force_reduction_method = reduction_method_not_defined;
1825 K_DIAG(1, (
"__kmp_force_reduction_method == %d\n",
1826 __kmp_force_reduction_method));
1829 static void __kmp_stg_print_force_reduction(kmp_str_buf_t *buffer,
1830 char const *name,
void *data) {
1832 kmp_stg_fr_data_t *reduction = (kmp_stg_fr_data_t *)data;
1833 if (reduction->force) {
1834 if (__kmp_force_reduction_method == critical_reduce_block) {
1835 __kmp_stg_print_str(buffer, name,
"critical");
1836 }
else if (__kmp_force_reduction_method == atomic_reduce_block) {
1837 __kmp_stg_print_str(buffer, name,
"atomic");
1838 }
else if (__kmp_force_reduction_method == tree_reduce_block) {
1839 __kmp_stg_print_str(buffer, name,
"tree");
1841 if (__kmp_env_format) {
1842 KMP_STR_BUF_PRINT_NAME;
1844 __kmp_str_buf_print(buffer,
" %s", name);
1846 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
1849 __kmp_stg_print_bool(buffer, name, __kmp_determ_red);
1857 static void __kmp_stg_parse_storage_map(
char const *name,
char const *value,
1859 if (__kmp_str_match(
"verbose", 1, value)) {
1860 __kmp_storage_map = TRUE;
1861 __kmp_storage_map_verbose = TRUE;
1862 __kmp_storage_map_verbose_specified = TRUE;
1865 __kmp_storage_map_verbose = FALSE;
1866 __kmp_stg_parse_bool(name, value, &__kmp_storage_map);
1870 static void __kmp_stg_print_storage_map(kmp_str_buf_t *buffer,
char const *name,
1872 if (__kmp_storage_map_verbose || __kmp_storage_map_verbose_specified) {
1873 __kmp_stg_print_str(buffer, name,
"verbose");
1875 __kmp_stg_print_bool(buffer, name, __kmp_storage_map);
1882 static void __kmp_stg_parse_all_threadprivate(
char const *name,
1883 char const *value,
void *data) {
1884 __kmp_stg_parse_int(name, value,
1885 __kmp_allThreadsSpecified ? __kmp_max_nth : 1,
1886 __kmp_max_nth, &__kmp_tp_capacity);
1889 static void __kmp_stg_print_all_threadprivate(kmp_str_buf_t *buffer,
1890 char const *name,
void *data) {
1891 __kmp_stg_print_int(buffer, name, __kmp_tp_capacity);
1897 static void __kmp_stg_parse_foreign_threads_threadprivate(
char const *name,
1900 __kmp_stg_parse_bool(name, value, &__kmp_foreign_tp);
1903 static void __kmp_stg_print_foreign_threads_threadprivate(kmp_str_buf_t *buffer,
1906 __kmp_stg_print_bool(buffer, name, __kmp_foreign_tp);
1912 #if KMP_AFFINITY_SUPPORTED 1914 static int __kmp_parse_affinity_proc_id_list(
const char *var,
const char *env,
1915 const char **nextEnv,
1917 const char *scan = env;
1918 const char *next = scan;
1924 int start, end, stride;
1928 if (*next ==
'\0') {
1939 if ((*next <
'0') || (*next >
'9')) {
1940 KMP_WARNING(AffSyntaxError, var);
1944 num = __kmp_str_to_int(scan, *next);
1945 KMP_ASSERT(num >= 0);
1963 if ((*next <
'0') || (*next >
'9')) {
1964 KMP_WARNING(AffSyntaxError, var);
1969 num = __kmp_str_to_int(scan, *next);
1970 KMP_ASSERT(num >= 0);
1983 if ((*next <
'0') || (*next >
'9')) {
1985 KMP_WARNING(AffSyntaxError, var);
1993 start = __kmp_str_to_int(scan, *next);
1994 KMP_ASSERT(start >= 0);
2013 if ((*next <
'0') || (*next >
'9')) {
2014 KMP_WARNING(AffSyntaxError, var);
2018 end = __kmp_str_to_int(scan, *next);
2019 KMP_ASSERT(end >= 0);
2036 if ((*next <
'0') || (*next >
'9')) {
2037 KMP_WARNING(AffSyntaxError, var);
2041 stride = __kmp_str_to_int(scan, *next);
2042 KMP_ASSERT(stride >= 0);
2048 KMP_WARNING(AffZeroStride, var);
2053 KMP_WARNING(AffStartGreaterEnd, var, start, end);
2058 KMP_WARNING(AffStrideLessZero, var, start, end);
2062 if ((end - start) / stride > 65536) {
2063 KMP_WARNING(AffRangeTooBig, var, end, start, stride);
2080 ptrdiff_t len = next - env;
2081 char *retlist = (
char *)__kmp_allocate((len + 1) *
sizeof(char));
2082 KMP_MEMCPY_S(retlist, (len + 1) *
sizeof(
char), env, len *
sizeof(
char));
2083 retlist[len] =
'\0';
2084 *proclist = retlist;
2091 static kmp_setting_t *__kmp_affinity_notype = NULL;
2093 static void __kmp_parse_affinity_env(
char const *name,
char const *value,
2094 enum affinity_type *out_type,
2095 char **out_proclist,
int *out_verbose,
2096 int *out_warn,
int *out_respect,
2097 kmp_hw_t *out_gran,
int *out_gran_levels,
2098 int *out_dups,
int *out_compact,
2100 char *buffer = NULL;
2117 KMP_ASSERT(value != NULL);
2119 if (TCR_4(__kmp_init_middle)) {
2120 KMP_WARNING(EnvMiddleWarn, name);
2121 __kmp_env_toPrint(name, 0);
2124 __kmp_env_toPrint(name, 1);
2127 __kmp_str_format(
"%s", value);
2137 #define EMIT_WARN(skip, errlist) \ 2141 SKIP_TO(next, ','); \ 2145 KMP_WARNING errlist; \ 2154 #define _set_param(_guard, _var, _val) \ 2156 if (_guard == 0) { \ 2159 EMIT_WARN(FALSE, (AffParamDefined, name, start)); \ 2164 #define set_type(val) _set_param(type, *out_type, val) 2165 #define set_verbose(val) _set_param(verbose, *out_verbose, val) 2166 #define set_warnings(val) _set_param(warnings, *out_warn, val) 2167 #define set_respect(val) _set_param(respect, *out_respect, val) 2168 #define set_dups(val) _set_param(dups, *out_dups, val) 2169 #define set_proclist(val) _set_param(proclist, *out_proclist, val) 2171 #define set_gran(val, levels) \ 2175 *out_gran_levels = levels; \ 2177 EMIT_WARN(FALSE, (AffParamDefined, name, start)); \ 2182 KMP_DEBUG_ASSERT((__kmp_nested_proc_bind.bind_types != NULL) &&
2183 (__kmp_nested_proc_bind.used > 0));
2185 while (*buf !=
'\0') {
2188 if (__kmp_match_str(
"none", buf, CCAST(
const char **, &next))) {
2189 set_type(affinity_none);
2190 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
2192 }
else if (__kmp_match_str(
"scatter", buf, CCAST(
const char **, &next))) {
2193 set_type(affinity_scatter);
2194 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2196 }
else if (__kmp_match_str(
"compact", buf, CCAST(
const char **, &next))) {
2197 set_type(affinity_compact);
2198 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2200 }
else if (__kmp_match_str(
"logical", buf, CCAST(
const char **, &next))) {
2201 set_type(affinity_logical);
2202 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2204 }
else if (__kmp_match_str(
"physical", buf, CCAST(
const char **, &next))) {
2205 set_type(affinity_physical);
2206 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2208 }
else if (__kmp_match_str(
"explicit", buf, CCAST(
const char **, &next))) {
2209 set_type(affinity_explicit);
2210 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2212 }
else if (__kmp_match_str(
"balanced", buf, CCAST(
const char **, &next))) {
2213 set_type(affinity_balanced);
2214 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2216 }
else if (__kmp_match_str(
"disabled", buf, CCAST(
const char **, &next))) {
2217 set_type(affinity_disabled);
2218 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
2220 }
else if (__kmp_match_str(
"verbose", buf, CCAST(
const char **, &next))) {
2223 }
else if (__kmp_match_str(
"noverbose", buf, CCAST(
const char **, &next))) {
2226 }
else if (__kmp_match_str(
"warnings", buf, CCAST(
const char **, &next))) {
2229 }
else if (__kmp_match_str(
"nowarnings", buf,
2230 CCAST(
const char **, &next))) {
2231 set_warnings(FALSE);
2233 }
else if (__kmp_match_str(
"respect", buf, CCAST(
const char **, &next))) {
2236 }
else if (__kmp_match_str(
"norespect", buf, CCAST(
const char **, &next))) {
2239 }
else if (__kmp_match_str(
"duplicates", buf,
2240 CCAST(
const char **, &next)) ||
2241 __kmp_match_str(
"dups", buf, CCAST(
const char **, &next))) {
2244 }
else if (__kmp_match_str(
"noduplicates", buf,
2245 CCAST(
const char **, &next)) ||
2246 __kmp_match_str(
"nodups", buf, CCAST(
const char **, &next))) {
2249 }
else if (__kmp_match_str(
"granularity", buf,
2250 CCAST(
const char **, &next)) ||
2251 __kmp_match_str(
"gran", buf, CCAST(
const char **, &next))) {
2254 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2263 KMP_FOREACH_HW_TYPE(type) {
2264 const char *name = __kmp_hw_get_keyword(type);
2265 if (__kmp_match_str(name, buf, CCAST(
const char **, &next))) {
2274 if (__kmp_match_str(
"fine", buf, CCAST(
const char **, &next))) {
2275 set_gran(KMP_HW_THREAD, -1);
2278 }
else if (__kmp_match_str(
"package", buf,
2279 CCAST(
const char **, &next))) {
2280 set_gran(KMP_HW_SOCKET, -1);
2283 }
else if (__kmp_match_str(
"node", buf, CCAST(
const char **, &next))) {
2284 set_gran(KMP_HW_NUMA, -1);
2287 #if KMP_GROUP_AFFINITY 2288 }
else if (__kmp_match_str(
"group", buf, CCAST(
const char **, &next))) {
2289 set_gran(KMP_HW_PROC_GROUP, -1);
2293 }
else if ((*buf >=
'0') && (*buf <=
'9')) {
2297 n = __kmp_str_to_int(buf, *next);
2300 set_gran(KMP_HW_UNKNOWN, n);
2303 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2307 }
else if (__kmp_match_str(
"proclist", buf, CCAST(
const char **, &next))) {
2308 char *temp_proclist;
2312 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2318 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2323 if (!__kmp_parse_affinity_proc_id_list(
2324 name, buf, CCAST(
const char **, &next), &temp_proclist)) {
2336 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2340 set_proclist(temp_proclist);
2341 }
else if ((*buf >=
'0') && (*buf <=
'9')) {
2346 n = __kmp_str_to_int(buf, *next);
2352 KMP_WARNING(AffManyParams, name, start);
2356 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2364 }
else if (*next !=
'\0') {
2365 const char *temp = next;
2366 EMIT_WARN(TRUE, (ParseExtraCharsWarn, name, temp));
2378 #undef set_granularity 2380 __kmp_str_free(&buffer);
2384 KMP_WARNING(AffProcListNoType, name);
2385 *out_type = affinity_explicit;
2386 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2387 }
else if (*out_type != affinity_explicit) {
2388 KMP_WARNING(AffProcListNotExplicit, name);
2389 KMP_ASSERT(*out_proclist != NULL);
2390 KMP_INTERNAL_FREE(*out_proclist);
2391 *out_proclist = NULL;
2394 switch (*out_type) {
2395 case affinity_logical:
2396 case affinity_physical: {
2398 *out_offset = number[0];
2401 KMP_WARNING(AffManyParamsForLogic, name, number[1]);
2404 case affinity_balanced: {
2406 *out_compact = number[0];
2409 *out_offset = number[1];
2412 if (__kmp_affinity_gran == KMP_HW_UNKNOWN) {
2413 #if KMP_MIC_SUPPORTED 2414 if (__kmp_mic_type != non_mic) {
2415 if (__kmp_affinity_verbose || __kmp_affinity_warnings) {
2416 KMP_WARNING(AffGranUsing,
"KMP_AFFINITY",
"fine");
2418 __kmp_affinity_gran = KMP_HW_THREAD;
2422 if (__kmp_affinity_verbose || __kmp_affinity_warnings) {
2423 KMP_WARNING(AffGranUsing,
"KMP_AFFINITY",
"core");
2425 __kmp_affinity_gran = KMP_HW_CORE;
2429 case affinity_scatter:
2430 case affinity_compact: {
2432 *out_compact = number[0];
2435 *out_offset = number[1];
2438 case affinity_explicit: {
2439 if (*out_proclist == NULL) {
2440 KMP_WARNING(AffNoProcList, name);
2441 __kmp_affinity_type = affinity_none;
2444 KMP_WARNING(AffNoParam, name,
"explicit");
2447 case affinity_none: {
2449 KMP_WARNING(AffNoParam, name,
"none");
2452 case affinity_disabled: {
2454 KMP_WARNING(AffNoParam, name,
"disabled");
2457 case affinity_default: {
2459 KMP_WARNING(AffNoParam, name,
"default");
2468 static void __kmp_stg_parse_affinity(
char const *name,
char const *value,
2470 kmp_setting_t **rivals = (kmp_setting_t **)data;
2473 rc = __kmp_stg_check_rivals(name, value, rivals);
2478 __kmp_parse_affinity_env(name, value, &__kmp_affinity_type,
2479 &__kmp_affinity_proclist, &__kmp_affinity_verbose,
2480 &__kmp_affinity_warnings,
2481 &__kmp_affinity_respect_mask, &__kmp_affinity_gran,
2482 &__kmp_affinity_gran_levels, &__kmp_affinity_dups,
2483 &__kmp_affinity_compact, &__kmp_affinity_offset);
2487 static void __kmp_stg_print_affinity(kmp_str_buf_t *buffer,
char const *name,
2489 if (__kmp_env_format) {
2490 KMP_STR_BUF_PRINT_NAME_EX(name);
2492 __kmp_str_buf_print(buffer,
" %s='", name);
2494 if (__kmp_affinity_verbose) {
2495 __kmp_str_buf_print(buffer,
"%s,",
"verbose");
2497 __kmp_str_buf_print(buffer,
"%s,",
"noverbose");
2499 if (__kmp_affinity_warnings) {
2500 __kmp_str_buf_print(buffer,
"%s,",
"warnings");
2502 __kmp_str_buf_print(buffer,
"%s,",
"nowarnings");
2504 if (KMP_AFFINITY_CAPABLE()) {
2505 if (__kmp_affinity_respect_mask) {
2506 __kmp_str_buf_print(buffer,
"%s,",
"respect");
2508 __kmp_str_buf_print(buffer,
"%s,",
"norespect");
2510 __kmp_str_buf_print(buffer,
"granularity=%s,",
2511 __kmp_hw_get_keyword(__kmp_affinity_gran,
false));
2513 if (!KMP_AFFINITY_CAPABLE()) {
2514 __kmp_str_buf_print(buffer,
"%s",
"disabled");
2516 switch (__kmp_affinity_type) {
2518 __kmp_str_buf_print(buffer,
"%s",
"none");
2520 case affinity_physical:
2521 __kmp_str_buf_print(buffer,
"%s,%d",
"physical", __kmp_affinity_offset);
2523 case affinity_logical:
2524 __kmp_str_buf_print(buffer,
"%s,%d",
"logical", __kmp_affinity_offset);
2526 case affinity_compact:
2527 __kmp_str_buf_print(buffer,
"%s,%d,%d",
"compact", __kmp_affinity_compact,
2528 __kmp_affinity_offset);
2530 case affinity_scatter:
2531 __kmp_str_buf_print(buffer,
"%s,%d,%d",
"scatter", __kmp_affinity_compact,
2532 __kmp_affinity_offset);
2534 case affinity_explicit:
2535 __kmp_str_buf_print(buffer,
"%s=[%s],%s",
"proclist",
2536 __kmp_affinity_proclist,
"explicit");
2538 case affinity_balanced:
2539 __kmp_str_buf_print(buffer,
"%s,%d,%d",
"balanced",
2540 __kmp_affinity_compact, __kmp_affinity_offset);
2542 case affinity_disabled:
2543 __kmp_str_buf_print(buffer,
"%s",
"disabled");
2545 case affinity_default:
2546 __kmp_str_buf_print(buffer,
"%s",
"default");
2549 __kmp_str_buf_print(buffer,
"%s",
"<unknown>");
2552 __kmp_str_buf_print(buffer,
"'\n");
2555 #ifdef KMP_GOMP_COMPAT 2557 static void __kmp_stg_parse_gomp_cpu_affinity(
char const *name,
2558 char const *value,
void *data) {
2559 const char *next = NULL;
2560 char *temp_proclist;
2561 kmp_setting_t **rivals = (kmp_setting_t **)data;
2564 rc = __kmp_stg_check_rivals(name, value, rivals);
2569 if (TCR_4(__kmp_init_middle)) {
2570 KMP_WARNING(EnvMiddleWarn, name);
2571 __kmp_env_toPrint(name, 0);
2575 __kmp_env_toPrint(name, 1);
2577 if (__kmp_parse_affinity_proc_id_list(name, value, &next, &temp_proclist)) {
2579 if (*next ==
'\0') {
2581 __kmp_affinity_proclist = temp_proclist;
2582 __kmp_affinity_type = affinity_explicit;
2583 __kmp_affinity_gran = KMP_HW_THREAD;
2584 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2586 KMP_WARNING(AffSyntaxError, name);
2587 if (temp_proclist != NULL) {
2588 KMP_INTERNAL_FREE((
void *)temp_proclist);
2593 __kmp_affinity_type = affinity_none;
2594 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
2621 static inline void __kmp_omp_places_syntax_warn(
const char *var) {
2622 KMP_WARNING(SyntaxErrorUsing, var,
"\"cores\"");
2625 static int __kmp_parse_subplace_list(
const char *var,
const char **scan) {
2629 int start, count, stride;
2635 if ((**scan <
'0') || (**scan >
'9')) {
2636 __kmp_omp_places_syntax_warn(var);
2641 start = __kmp_str_to_int(*scan, *next);
2642 KMP_ASSERT(start >= 0);
2647 if (**scan ==
'}') {
2650 if (**scan ==
',') {
2654 if (**scan !=
':') {
2655 __kmp_omp_places_syntax_warn(var);
2662 if ((**scan <
'0') || (**scan >
'9')) {
2663 __kmp_omp_places_syntax_warn(var);
2668 count = __kmp_str_to_int(*scan, *next);
2669 KMP_ASSERT(count >= 0);
2674 if (**scan ==
'}') {
2677 if (**scan ==
',') {
2681 if (**scan !=
':') {
2682 __kmp_omp_places_syntax_warn(var);
2691 if (**scan ==
'+') {
2695 if (**scan ==
'-') {
2703 if ((**scan <
'0') || (**scan >
'9')) {
2704 __kmp_omp_places_syntax_warn(var);
2709 stride = __kmp_str_to_int(*scan, *next);
2710 KMP_ASSERT(stride >= 0);
2716 if (**scan ==
'}') {
2719 if (**scan ==
',') {
2724 __kmp_omp_places_syntax_warn(var);
2730 static int __kmp_parse_place(
const char *var,
const char **scan) {
2735 if (**scan ==
'{') {
2737 if (!__kmp_parse_subplace_list(var, scan)) {
2740 if (**scan !=
'}') {
2741 __kmp_omp_places_syntax_warn(var);
2745 }
else if (**scan ==
'!') {
2747 return __kmp_parse_place(var, scan);
2748 }
else if ((**scan >=
'0') && (**scan <=
'9')) {
2751 int proc = __kmp_str_to_int(*scan, *next);
2752 KMP_ASSERT(proc >= 0);
2755 __kmp_omp_places_syntax_warn(var);
2761 static int __kmp_parse_place_list(
const char *var,
const char *env,
2762 char **place_list) {
2763 const char *scan = env;
2764 const char *next = scan;
2769 if (!__kmp_parse_place(var, &scan)) {
2775 if (*scan ==
'\0') {
2783 __kmp_omp_places_syntax_warn(var);
2790 if ((*scan <
'0') || (*scan >
'9')) {
2791 __kmp_omp_places_syntax_warn(var);
2796 count = __kmp_str_to_int(scan, *next);
2797 KMP_ASSERT(count >= 0);
2802 if (*scan ==
'\0') {
2810 __kmp_omp_places_syntax_warn(var);
2831 if ((*scan <
'0') || (*scan >
'9')) {
2832 __kmp_omp_places_syntax_warn(var);
2837 stride = __kmp_str_to_int(scan, *next);
2838 KMP_ASSERT(stride >= 0);
2844 if (*scan ==
'\0') {
2852 __kmp_omp_places_syntax_warn(var);
2857 ptrdiff_t len = scan - env;
2858 char *retlist = (
char *)__kmp_allocate((len + 1) *
sizeof(char));
2859 KMP_MEMCPY_S(retlist, (len + 1) *
sizeof(
char), env, len *
sizeof(
char));
2860 retlist[len] =
'\0';
2861 *place_list = retlist;
2866 static void __kmp_stg_parse_places(
char const *name,
char const *value,
2868 struct kmp_place_t {
2874 const char *scan = value;
2875 const char *next = scan;
2876 const char *kind =
"\"threads\"";
2877 kmp_place_t std_places[] = {{
"threads", KMP_HW_THREAD},
2878 {
"cores", KMP_HW_CORE},
2879 {
"numa_domains", KMP_HW_NUMA},
2880 {
"ll_caches", KMP_HW_LLC},
2881 {
"sockets", KMP_HW_SOCKET}};
2882 kmp_setting_t **rivals = (kmp_setting_t **)data;
2885 rc = __kmp_stg_check_rivals(name, value, rivals);
2891 for (
size_t i = 0; i <
sizeof(std_places) /
sizeof(std_places[0]); ++i) {
2892 const kmp_place_t &place = std_places[i];
2893 if (__kmp_match_str(place.name, scan, &next)) {
2895 __kmp_affinity_type = affinity_compact;
2896 __kmp_affinity_gran = place.type;
2897 __kmp_affinity_dups = FALSE;
2904 KMP_FOREACH_HW_TYPE(type) {
2905 const char *name = __kmp_hw_get_keyword(type,
true);
2906 if (__kmp_match_str(
"unknowns", scan, &next))
2908 if (__kmp_match_str(name, scan, &next)) {
2910 __kmp_affinity_type = affinity_compact;
2911 __kmp_affinity_gran = type;
2912 __kmp_affinity_dups = FALSE;
2919 if (__kmp_affinity_proclist != NULL) {
2920 KMP_INTERNAL_FREE((
void *)__kmp_affinity_proclist);
2921 __kmp_affinity_proclist = NULL;
2923 if (__kmp_parse_place_list(name, value, &__kmp_affinity_proclist)) {
2924 __kmp_affinity_type = affinity_explicit;
2925 __kmp_affinity_gran = KMP_HW_THREAD;
2926 __kmp_affinity_dups = FALSE;
2929 __kmp_affinity_type = affinity_compact;
2930 __kmp_affinity_gran = KMP_HW_CORE;
2931 __kmp_affinity_dups = FALSE;
2933 if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_default) {
2934 __kmp_nested_proc_bind.bind_types[0] = proc_bind_true;
2938 if (__kmp_affinity_gran != KMP_HW_UNKNOWN) {
2939 kind = __kmp_hw_get_keyword(__kmp_affinity_gran);
2942 if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_default) {
2943 __kmp_nested_proc_bind.bind_types[0] = proc_bind_true;
2947 if (*scan ==
'\0') {
2953 KMP_WARNING(SyntaxErrorUsing, name, kind);
2961 count = __kmp_str_to_int(scan, *next);
2962 KMP_ASSERT(count >= 0);
2967 KMP_WARNING(SyntaxErrorUsing, name, kind);
2973 if (*scan !=
'\0') {
2974 KMP_WARNING(ParseExtraCharsWarn, name, scan);
2976 __kmp_affinity_num_places = count;
2979 static void __kmp_stg_print_places(kmp_str_buf_t *buffer,
char const *name,
2981 if (__kmp_env_format) {
2982 KMP_STR_BUF_PRINT_NAME;
2984 __kmp_str_buf_print(buffer,
" %s", name);
2986 if ((__kmp_nested_proc_bind.used == 0) ||
2987 (__kmp_nested_proc_bind.bind_types == NULL) ||
2988 (__kmp_nested_proc_bind.bind_types[0] == proc_bind_false)) {
2989 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
2990 }
else if (__kmp_affinity_type == affinity_explicit) {
2991 if (__kmp_affinity_proclist != NULL) {
2992 __kmp_str_buf_print(buffer,
"='%s'\n", __kmp_affinity_proclist);
2994 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
2996 }
else if (__kmp_affinity_type == affinity_compact) {
2998 if (__kmp_affinity_num_masks > 0) {
2999 num = __kmp_affinity_num_masks;
3000 }
else if (__kmp_affinity_num_places > 0) {
3001 num = __kmp_affinity_num_places;
3005 if (__kmp_affinity_gran != KMP_HW_UNKNOWN) {
3006 const char *name = __kmp_hw_get_keyword(__kmp_affinity_gran,
true);
3008 __kmp_str_buf_print(buffer,
"='%s(%d)'\n", name, num);
3010 __kmp_str_buf_print(buffer,
"='%s'\n", name);
3013 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
3016 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
3020 static void __kmp_stg_parse_topology_method(
char const *name,
char const *value,
3022 if (__kmp_str_match(
"all", 1, value)) {
3023 __kmp_affinity_top_method = affinity_top_method_all;
3026 else if (__kmp_str_match(
"hwloc", 1, value)) {
3027 __kmp_affinity_top_method = affinity_top_method_hwloc;
3030 #if KMP_ARCH_X86 || KMP_ARCH_X86_64 3031 else if (__kmp_str_match(
"cpuid_leaf31", 12, value) ||
3032 __kmp_str_match(
"cpuid 1f", 8, value) ||
3033 __kmp_str_match(
"cpuid 31", 8, value) ||
3034 __kmp_str_match(
"cpuid1f", 7, value) ||
3035 __kmp_str_match(
"cpuid31", 7, value) ||
3036 __kmp_str_match(
"leaf 1f", 7, value) ||
3037 __kmp_str_match(
"leaf 31", 7, value) ||
3038 __kmp_str_match(
"leaf1f", 6, value) ||
3039 __kmp_str_match(
"leaf31", 6, value)) {
3040 __kmp_affinity_top_method = affinity_top_method_x2apicid_1f;
3041 }
else if (__kmp_str_match(
"x2apic id", 9, value) ||
3042 __kmp_str_match(
"x2apic_id", 9, value) ||
3043 __kmp_str_match(
"x2apic-id", 9, value) ||
3044 __kmp_str_match(
"x2apicid", 8, value) ||
3045 __kmp_str_match(
"cpuid leaf 11", 13, value) ||
3046 __kmp_str_match(
"cpuid_leaf_11", 13, value) ||
3047 __kmp_str_match(
"cpuid-leaf-11", 13, value) ||
3048 __kmp_str_match(
"cpuid leaf11", 12, value) ||
3049 __kmp_str_match(
"cpuid_leaf11", 12, value) ||
3050 __kmp_str_match(
"cpuid-leaf11", 12, value) ||
3051 __kmp_str_match(
"cpuidleaf 11", 12, value) ||
3052 __kmp_str_match(
"cpuidleaf_11", 12, value) ||
3053 __kmp_str_match(
"cpuidleaf-11", 12, value) ||
3054 __kmp_str_match(
"cpuidleaf11", 11, value) ||
3055 __kmp_str_match(
"cpuid 11", 8, value) ||
3056 __kmp_str_match(
"cpuid_11", 8, value) ||
3057 __kmp_str_match(
"cpuid-11", 8, value) ||
3058 __kmp_str_match(
"cpuid11", 7, value) ||
3059 __kmp_str_match(
"leaf 11", 7, value) ||
3060 __kmp_str_match(
"leaf_11", 7, value) ||
3061 __kmp_str_match(
"leaf-11", 7, value) ||
3062 __kmp_str_match(
"leaf11", 6, value)) {
3063 __kmp_affinity_top_method = affinity_top_method_x2apicid;
3064 }
else if (__kmp_str_match(
"apic id", 7, value) ||
3065 __kmp_str_match(
"apic_id", 7, value) ||
3066 __kmp_str_match(
"apic-id", 7, value) ||
3067 __kmp_str_match(
"apicid", 6, value) ||
3068 __kmp_str_match(
"cpuid leaf 4", 12, value) ||
3069 __kmp_str_match(
"cpuid_leaf_4", 12, value) ||
3070 __kmp_str_match(
"cpuid-leaf-4", 12, value) ||
3071 __kmp_str_match(
"cpuid leaf4", 11, value) ||
3072 __kmp_str_match(
"cpuid_leaf4", 11, value) ||
3073 __kmp_str_match(
"cpuid-leaf4", 11, value) ||
3074 __kmp_str_match(
"cpuidleaf 4", 11, value) ||
3075 __kmp_str_match(
"cpuidleaf_4", 11, value) ||
3076 __kmp_str_match(
"cpuidleaf-4", 11, value) ||
3077 __kmp_str_match(
"cpuidleaf4", 10, value) ||
3078 __kmp_str_match(
"cpuid 4", 7, value) ||
3079 __kmp_str_match(
"cpuid_4", 7, value) ||
3080 __kmp_str_match(
"cpuid-4", 7, value) ||
3081 __kmp_str_match(
"cpuid4", 6, value) ||
3082 __kmp_str_match(
"leaf 4", 6, value) ||
3083 __kmp_str_match(
"leaf_4", 6, value) ||
3084 __kmp_str_match(
"leaf-4", 6, value) ||
3085 __kmp_str_match(
"leaf4", 5, value)) {
3086 __kmp_affinity_top_method = affinity_top_method_apicid;
3089 else if (__kmp_str_match(
"/proc/cpuinfo", 2, value) ||
3090 __kmp_str_match(
"cpuinfo", 5, value)) {
3091 __kmp_affinity_top_method = affinity_top_method_cpuinfo;
3093 #if KMP_GROUP_AFFINITY 3094 else if (__kmp_str_match(
"group", 1, value)) {
3095 __kmp_affinity_top_method = affinity_top_method_group;
3098 else if (__kmp_str_match(
"flat", 1, value)) {
3099 __kmp_affinity_top_method = affinity_top_method_flat;
3101 KMP_WARNING(StgInvalidValue, name, value);
3105 static void __kmp_stg_print_topology_method(kmp_str_buf_t *buffer,
3106 char const *name,
void *data) {
3107 char const *value = NULL;
3109 switch (__kmp_affinity_top_method) {
3110 case affinity_top_method_default:
3114 case affinity_top_method_all:
3118 #if KMP_ARCH_X86 || KMP_ARCH_X86_64 3119 case affinity_top_method_x2apicid_1f:
3120 value =
"x2APIC id leaf 0x1f";
3123 case affinity_top_method_x2apicid:
3124 value =
"x2APIC id leaf 0xb";
3127 case affinity_top_method_apicid:
3133 case affinity_top_method_hwloc:
3138 case affinity_top_method_cpuinfo:
3142 #if KMP_GROUP_AFFINITY 3143 case affinity_top_method_group:
3148 case affinity_top_method_flat:
3153 if (value != NULL) {
3154 __kmp_stg_print_str(buffer, name, value);
3162 static void __kmp_stg_parse_proc_bind(
char const *name,
char const *value,
3164 kmp_setting_t **rivals = (kmp_setting_t **)data;
3167 rc = __kmp_stg_check_rivals(name, value, rivals);
3173 KMP_DEBUG_ASSERT((__kmp_nested_proc_bind.bind_types != NULL) &&
3174 (__kmp_nested_proc_bind.used > 0));
3176 const char *buf = value;
3180 if ((*buf >=
'0') && (*buf <=
'9')) {
3183 num = __kmp_str_to_int(buf, *next);
3184 KMP_ASSERT(num >= 0);
3192 if (__kmp_match_str(
"disabled", buf, &next)) {
3195 #if KMP_AFFINITY_SUPPORTED 3196 __kmp_affinity_type = affinity_disabled;
3198 __kmp_nested_proc_bind.used = 1;
3199 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
3200 }
else if ((num == (
int)proc_bind_false) ||
3201 __kmp_match_str(
"false", buf, &next)) {
3204 #if KMP_AFFINITY_SUPPORTED 3205 __kmp_affinity_type = affinity_none;
3207 __kmp_nested_proc_bind.used = 1;
3208 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
3209 }
else if ((num == (
int)proc_bind_true) ||
3210 __kmp_match_str(
"true", buf, &next)) {
3213 __kmp_nested_proc_bind.used = 1;
3214 __kmp_nested_proc_bind.bind_types[0] = proc_bind_true;
3219 for (scan = buf; *scan !=
'\0'; scan++) {
3226 if (__kmp_nested_proc_bind.size < nelem) {
3227 __kmp_nested_proc_bind.bind_types =
3228 (kmp_proc_bind_t *)KMP_INTERNAL_REALLOC(
3229 __kmp_nested_proc_bind.bind_types,
3230 sizeof(kmp_proc_bind_t) * nelem);
3231 if (__kmp_nested_proc_bind.bind_types == NULL) {
3232 KMP_FATAL(MemoryAllocFailed);
3234 __kmp_nested_proc_bind.size = nelem;
3236 __kmp_nested_proc_bind.used = nelem;
3238 if (nelem > 1 && !__kmp_dflt_max_active_levels_set)
3239 __kmp_dflt_max_active_levels = KMP_MAX_ACTIVE_LEVELS_LIMIT;
3244 enum kmp_proc_bind_t bind;
3246 if ((num == (
int)proc_bind_primary) ||
3247 __kmp_match_str(
"master", buf, &next) ||
3248 __kmp_match_str(
"primary", buf, &next)) {
3251 bind = proc_bind_primary;
3252 }
else if ((num == (
int)proc_bind_close) ||
3253 __kmp_match_str(
"close", buf, &next)) {
3256 bind = proc_bind_close;
3257 }
else if ((num == (
int)proc_bind_spread) ||
3258 __kmp_match_str(
"spread", buf, &next)) {
3261 bind = proc_bind_spread;
3263 KMP_WARNING(StgInvalidValue, name, value);
3264 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
3265 __kmp_nested_proc_bind.used = 1;
3269 __kmp_nested_proc_bind.bind_types[i++] = bind;
3273 KMP_DEBUG_ASSERT(*buf ==
',');
3278 if ((*buf >=
'0') && (*buf <=
'9')) {
3281 num = __kmp_str_to_int(buf, *next);
3282 KMP_ASSERT(num >= 0);
3292 KMP_WARNING(ParseExtraCharsWarn, name, buf);
3296 static void __kmp_stg_print_proc_bind(kmp_str_buf_t *buffer,
char const *name,
3298 int nelem = __kmp_nested_proc_bind.used;
3299 if (__kmp_env_format) {
3300 KMP_STR_BUF_PRINT_NAME;
3302 __kmp_str_buf_print(buffer,
" %s", name);
3305 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
3308 __kmp_str_buf_print(buffer,
"='", name);
3309 for (i = 0; i < nelem; i++) {
3310 switch (__kmp_nested_proc_bind.bind_types[i]) {
3311 case proc_bind_false:
3312 __kmp_str_buf_print(buffer,
"false");
3315 case proc_bind_true:
3316 __kmp_str_buf_print(buffer,
"true");
3319 case proc_bind_primary:
3320 __kmp_str_buf_print(buffer,
"primary");
3323 case proc_bind_close:
3324 __kmp_str_buf_print(buffer,
"close");
3327 case proc_bind_spread:
3328 __kmp_str_buf_print(buffer,
"spread");
3331 case proc_bind_intel:
3332 __kmp_str_buf_print(buffer,
"intel");
3335 case proc_bind_default:
3336 __kmp_str_buf_print(buffer,
"default");
3339 if (i < nelem - 1) {
3340 __kmp_str_buf_print(buffer,
",");
3343 __kmp_str_buf_print(buffer,
"'\n");
3347 static void __kmp_stg_parse_display_affinity(
char const *name,
3348 char const *value,
void *data) {
3349 __kmp_stg_parse_bool(name, value, &__kmp_display_affinity);
3351 static void __kmp_stg_print_display_affinity(kmp_str_buf_t *buffer,
3352 char const *name,
void *data) {
3353 __kmp_stg_print_bool(buffer, name, __kmp_display_affinity);
3355 static void __kmp_stg_parse_affinity_format(
char const *name,
char const *value,
3357 size_t length = KMP_STRLEN(value);
3358 __kmp_strncpy_truncate(__kmp_affinity_format, KMP_AFFINITY_FORMAT_SIZE, value,
3361 static void __kmp_stg_print_affinity_format(kmp_str_buf_t *buffer,
3362 char const *name,
void *data) {
3363 if (__kmp_env_format) {
3364 KMP_STR_BUF_PRINT_NAME_EX(name);
3366 __kmp_str_buf_print(buffer,
" %s='", name);
3368 __kmp_str_buf_print(buffer,
"%s'\n", __kmp_affinity_format);
3390 static void __kmp_stg_parse_allocator(
char const *name,
char const *value,
3392 const char *buf = value;
3393 const char *next, *scan, *start;
3395 omp_allocator_handle_t al;
3396 omp_memspace_handle_t ms = omp_default_mem_space;
3397 bool is_memspace =
false;
3398 int ntraits = 0, count = 0;
3402 const char *delim = strchr(buf,
':');
3403 const char *predef_mem_space = strstr(buf,
"mem_space");
3405 bool is_memalloc = (!predef_mem_space && !delim) ?
true :
false;
3410 for (scan = buf; *scan !=
'\0'; scan++) {
3415 omp_alloctrait_t *traits =
3416 (omp_alloctrait_t *)KMP_ALLOCA(ntraits *
sizeof(omp_alloctrait_t));
3419 #define IS_POWER_OF_TWO(n) (((n) & ((n)-1)) == 0) 3421 #define GET_NEXT(sentinel) \ 3424 if (*next == sentinel) \ 3430 #define SKIP_PAIR(key) \ 3432 char const str_delimiter[] = {',', 0}; \ 3433 char *value = __kmp_str_token(CCAST(char *, scan), str_delimiter, \ 3434 CCAST(char **, &next)); \ 3435 KMP_WARNING(StgInvalidValue, key, value); \ 3443 char const str_delimiter[] = {'=', 0}; \ 3444 key = __kmp_str_token(CCAST(char *, start), str_delimiter, \ 3445 CCAST(char **, &next)); \ 3450 while (*next !=
'\0') {
3452 __kmp_match_str(
"fb_data", scan, &next)) {
3456 if (__kmp_match_str(
"omp_high_bw_mem_alloc", scan, &next)) {
3459 if (__kmp_memkind_available) {
3460 __kmp_def_allocator = omp_high_bw_mem_alloc;
3463 KMP_WARNING(OmpNoAllocator,
"omp_high_bw_mem_alloc");
3466 traits[count].key = omp_atk_fb_data;
3467 traits[count].value = RCAST(omp_uintptr_t, omp_high_bw_mem_alloc);
3469 }
else if (__kmp_match_str(
"omp_large_cap_mem_alloc", scan, &next)) {
3472 if (__kmp_memkind_available) {
3473 __kmp_def_allocator = omp_large_cap_mem_alloc;
3476 KMP_WARNING(OmpNoAllocator,
"omp_large_cap_mem_alloc");
3479 traits[count].key = omp_atk_fb_data;
3480 traits[count].value = RCAST(omp_uintptr_t, omp_large_cap_mem_alloc);
3482 }
else if (__kmp_match_str(
"omp_default_mem_alloc", scan, &next)) {
3486 traits[count].key = omp_atk_fb_data;
3487 traits[count].value = RCAST(omp_uintptr_t, omp_default_mem_alloc);
3489 }
else if (__kmp_match_str(
"omp_const_mem_alloc", scan, &next)) {
3492 KMP_WARNING(OmpNoAllocator,
"omp_const_mem_alloc");
3494 traits[count].key = omp_atk_fb_data;
3495 traits[count].value = RCAST(omp_uintptr_t, omp_const_mem_alloc);
3497 }
else if (__kmp_match_str(
"omp_low_lat_mem_alloc", scan, &next)) {
3500 KMP_WARNING(OmpNoAllocator,
"omp_low_lat_mem_alloc");
3502 traits[count].key = omp_atk_fb_data;
3503 traits[count].value = RCAST(omp_uintptr_t, omp_low_lat_mem_alloc);
3505 }
else if (__kmp_match_str(
"omp_cgroup_mem_alloc", scan, &next)) {
3508 KMP_WARNING(OmpNoAllocator,
"omp_cgroup_mem_alloc");
3510 traits[count].key = omp_atk_fb_data;
3511 traits[count].value = RCAST(omp_uintptr_t, omp_cgroup_mem_alloc);
3513 }
else if (__kmp_match_str(
"omp_pteam_mem_alloc", scan, &next)) {
3516 KMP_WARNING(OmpNoAllocator,
"omp_pteam_mem_alloc");
3518 traits[count].key = omp_atk_fb_data;
3519 traits[count].value = RCAST(omp_uintptr_t, omp_pteam_mem_alloc);
3521 }
else if (__kmp_match_str(
"omp_thread_mem_alloc", scan, &next)) {
3524 KMP_WARNING(OmpNoAllocator,
"omp_thread_mem_alloc");
3526 traits[count].key = omp_atk_fb_data;
3527 traits[count].value = RCAST(omp_uintptr_t, omp_thread_mem_alloc);
3537 __kmp_def_allocator = omp_default_mem_alloc;
3538 if (next == buf || *next !=
'\0') {
3540 KMP_WARNING(StgInvalidValue, name, value);
3545 if (count == ntraits)
3551 if (__kmp_match_str(
"omp_default_mem_space", scan, &next)) {
3553 ms = omp_default_mem_space;
3554 }
else if (__kmp_match_str(
"omp_large_cap_mem_space", scan, &next)) {
3556 ms = omp_large_cap_mem_space;
3557 }
else if (__kmp_match_str(
"omp_const_mem_space", scan, &next)) {
3559 ms = omp_const_mem_space;
3560 }
else if (__kmp_match_str(
"omp_high_bw_mem_space", scan, &next)) {
3562 ms = omp_high_bw_mem_space;
3563 }
else if (__kmp_match_str(
"omp_low_lat_mem_space", scan, &next)) {
3565 ms = omp_low_lat_mem_space;
3567 __kmp_def_allocator = omp_default_mem_alloc;
3568 if (next == buf || *next !=
'\0') {
3570 KMP_WARNING(StgInvalidValue, name, value);
3579 if (__kmp_match_str(
"sync_hint", scan, &next)) {
3581 traits[count].key = omp_atk_sync_hint;
3582 if (__kmp_match_str(
"contended", scan, &next)) {
3583 traits[count].value = omp_atv_contended;
3584 }
else if (__kmp_match_str(
"uncontended", scan, &next)) {
3585 traits[count].value = omp_atv_uncontended;
3586 }
else if (__kmp_match_str(
"serialized", scan, &next)) {
3587 traits[count].value = omp_atv_serialized;
3588 }
else if (__kmp_match_str(
"private", scan, &next)) {
3589 traits[count].value = omp_atv_private;
3595 }
else if (__kmp_match_str(
"alignment", scan, &next)) {
3597 if (!isdigit(*next)) {
3603 int n = __kmp_str_to_int(scan,
',');
3604 if (n < 0 || !IS_POWER_OF_TWO(n)) {
3609 traits[count].key = omp_atk_alignment;
3610 traits[count].value = n;
3611 }
else if (__kmp_match_str(
"access", scan, &next)) {
3613 traits[count].key = omp_atk_access;
3614 if (__kmp_match_str(
"all", scan, &next)) {
3615 traits[count].value = omp_atv_all;
3616 }
else if (__kmp_match_str(
"cgroup", scan, &next)) {
3617 traits[count].value = omp_atv_cgroup;
3618 }
else if (__kmp_match_str(
"pteam", scan, &next)) {
3619 traits[count].value = omp_atv_pteam;
3620 }
else if (__kmp_match_str(
"thread", scan, &next)) {
3621 traits[count].value = omp_atv_thread;
3627 }
else if (__kmp_match_str(
"pool_size", scan, &next)) {
3629 if (!isdigit(*next)) {
3635 int n = __kmp_str_to_int(scan,
',');
3641 traits[count].key = omp_atk_pool_size;
3642 traits[count].value = n;
3643 }
else if (__kmp_match_str(
"fallback", scan, &next)) {
3645 traits[count].key = omp_atk_fallback;
3646 if (__kmp_match_str(
"default_mem_fb", scan, &next)) {
3647 traits[count].value = omp_atv_default_mem_fb;
3648 }
else if (__kmp_match_str(
"null_fb", scan, &next)) {
3649 traits[count].value = omp_atv_null_fb;
3650 }
else if (__kmp_match_str(
"abort_fb", scan, &next)) {
3651 traits[count].value = omp_atv_abort_fb;
3652 }
else if (__kmp_match_str(
"allocator_fb", scan, &next)) {
3653 traits[count].value = omp_atv_allocator_fb;
3659 }
else if (__kmp_match_str(
"pinned", scan, &next)) {
3661 traits[count].key = omp_atk_pinned;
3662 if (__kmp_str_match_true(next)) {
3663 traits[count].value = omp_atv_true;
3664 }
else if (__kmp_str_match_false(next)) {
3665 traits[count].value = omp_atv_false;
3671 }
else if (__kmp_match_str(
"partition", scan, &next)) {
3673 traits[count].key = omp_atk_partition;
3674 if (__kmp_match_str(
"environment", scan, &next)) {
3675 traits[count].value = omp_atv_environment;
3676 }
else if (__kmp_match_str(
"nearest", scan, &next)) {
3677 traits[count].value = omp_atv_nearest;
3678 }
else if (__kmp_match_str(
"blocked", scan, &next)) {
3679 traits[count].value = omp_atv_blocked;
3680 }
else if (__kmp_match_str(
"interleaved", scan, &next)) {
3681 traits[count].value = omp_atv_interleaved;
3694 if (count == ntraits)
3700 al = __kmpc_init_allocator(__kmp_get_gtid(), ms, ntraits, traits);
3701 __kmp_def_allocator = (al == omp_null_allocator) ? omp_default_mem_alloc : al;
3704 static void __kmp_stg_print_allocator(kmp_str_buf_t *buffer,
char const *name,
3706 if (__kmp_def_allocator == omp_default_mem_alloc) {
3707 __kmp_stg_print_str(buffer, name,
"omp_default_mem_alloc");
3708 }
else if (__kmp_def_allocator == omp_high_bw_mem_alloc) {
3709 __kmp_stg_print_str(buffer, name,
"omp_high_bw_mem_alloc");
3710 }
else if (__kmp_def_allocator == omp_large_cap_mem_alloc) {
3711 __kmp_stg_print_str(buffer, name,
"omp_large_cap_mem_alloc");
3712 }
else if (__kmp_def_allocator == omp_const_mem_alloc) {
3713 __kmp_stg_print_str(buffer, name,
"omp_const_mem_alloc");
3714 }
else if (__kmp_def_allocator == omp_low_lat_mem_alloc) {
3715 __kmp_stg_print_str(buffer, name,
"omp_low_lat_mem_alloc");
3716 }
else if (__kmp_def_allocator == omp_cgroup_mem_alloc) {
3717 __kmp_stg_print_str(buffer, name,
"omp_cgroup_mem_alloc");
3718 }
else if (__kmp_def_allocator == omp_pteam_mem_alloc) {
3719 __kmp_stg_print_str(buffer, name,
"omp_pteam_mem_alloc");
3720 }
else if (__kmp_def_allocator == omp_thread_mem_alloc) {
3721 __kmp_stg_print_str(buffer, name,
"omp_thread_mem_alloc");
3728 static void __kmp_stg_parse_omp_dynamic(
char const *name,
char const *value,
3730 __kmp_stg_parse_bool(name, value, &(__kmp_global.g.g_dynamic));
3733 static void __kmp_stg_print_omp_dynamic(kmp_str_buf_t *buffer,
char const *name,
3735 __kmp_stg_print_bool(buffer, name, __kmp_global.g.g_dynamic);
3738 static void __kmp_stg_parse_kmp_dynamic_mode(
char const *name,
3739 char const *value,
void *data) {
3740 if (TCR_4(__kmp_init_parallel)) {
3741 KMP_WARNING(EnvParallelWarn, name);
3742 __kmp_env_toPrint(name, 0);
3745 #ifdef USE_LOAD_BALANCE 3746 else if (__kmp_str_match(
"load balance", 2, value) ||
3747 __kmp_str_match(
"load_balance", 2, value) ||
3748 __kmp_str_match(
"load-balance", 2, value) ||
3749 __kmp_str_match(
"loadbalance", 2, value) ||
3750 __kmp_str_match(
"balance", 1, value)) {
3751 __kmp_global.g.g_dynamic_mode = dynamic_load_balance;
3754 else if (__kmp_str_match(
"thread limit", 1, value) ||
3755 __kmp_str_match(
"thread_limit", 1, value) ||
3756 __kmp_str_match(
"thread-limit", 1, value) ||
3757 __kmp_str_match(
"threadlimit", 1, value) ||
3758 __kmp_str_match(
"limit", 2, value)) {
3759 __kmp_global.g.g_dynamic_mode = dynamic_thread_limit;
3760 }
else if (__kmp_str_match(
"random", 1, value)) {
3761 __kmp_global.g.g_dynamic_mode = dynamic_random;
3763 KMP_WARNING(StgInvalidValue, name, value);
3767 static void __kmp_stg_print_kmp_dynamic_mode(kmp_str_buf_t *buffer,
3768 char const *name,
void *data) {
3770 if (__kmp_global.g.g_dynamic_mode == dynamic_default) {
3771 __kmp_str_buf_print(buffer,
" %s: %s \n", name, KMP_I18N_STR(NotDefined));
3773 #ifdef USE_LOAD_BALANCE 3774 else if (__kmp_global.g.g_dynamic_mode == dynamic_load_balance) {
3775 __kmp_stg_print_str(buffer, name,
"load balance");
3778 else if (__kmp_global.g.g_dynamic_mode == dynamic_thread_limit) {
3779 __kmp_stg_print_str(buffer, name,
"thread limit");
3780 }
else if (__kmp_global.g.g_dynamic_mode == dynamic_random) {
3781 __kmp_stg_print_str(buffer, name,
"random");
3788 #ifdef USE_LOAD_BALANCE 3793 static void __kmp_stg_parse_ld_balance_interval(
char const *name,
3794 char const *value,
void *data) {
3795 double interval = __kmp_convert_to_double(value);
3796 if (interval >= 0) {
3797 __kmp_load_balance_interval = interval;
3799 KMP_WARNING(StgInvalidValue, name, value);
3803 static void __kmp_stg_print_ld_balance_interval(kmp_str_buf_t *buffer,
3804 char const *name,
void *data) {
3806 __kmp_str_buf_print(buffer,
" %s=%8.6f\n", name,
3807 __kmp_load_balance_interval);
3816 static void __kmp_stg_parse_init_at_fork(
char const *name,
char const *value,
3818 __kmp_stg_parse_bool(name, value, &__kmp_need_register_atfork);
3819 if (__kmp_need_register_atfork) {
3820 __kmp_need_register_atfork_specified = TRUE;
3824 static void __kmp_stg_print_init_at_fork(kmp_str_buf_t *buffer,
3825 char const *name,
void *data) {
3826 __kmp_stg_print_bool(buffer, name, __kmp_need_register_atfork_specified);
3832 static void __kmp_stg_parse_schedule(
char const *name,
char const *value,
3835 if (value != NULL) {
3836 size_t length = KMP_STRLEN(value);
3837 if (length > INT_MAX) {
3838 KMP_WARNING(LongValue, name);
3840 const char *semicolon;
3841 if (value[length - 1] ==
'"' || value[length - 1] ==
'\'')
3842 KMP_WARNING(UnbalancedQuotes, name);
3846 semicolon = strchr(value,
';');
3847 if (*value && semicolon != value) {
3848 const char *comma = strchr(value,
',');
3855 if (!__kmp_strcasecmp_with_sentinel(
"static", value, sentinel)) {
3856 if (!__kmp_strcasecmp_with_sentinel(
"greedy", comma,
';')) {
3857 __kmp_static = kmp_sch_static_greedy;
3859 }
else if (!__kmp_strcasecmp_with_sentinel(
"balanced", comma,
3861 __kmp_static = kmp_sch_static_balanced;
3864 }
else if (!__kmp_strcasecmp_with_sentinel(
"guided", value,
3866 if (!__kmp_strcasecmp_with_sentinel(
"iterative", comma,
';')) {
3867 __kmp_guided = kmp_sch_guided_iterative_chunked;
3869 }
else if (!__kmp_strcasecmp_with_sentinel(
"analytical", comma,
3872 __kmp_guided = kmp_sch_guided_analytical_chunked;
3876 KMP_WARNING(InvalidClause, name, value);
3878 KMP_WARNING(EmptyClause, name);
3879 }
while ((value = semicolon ? semicolon + 1 : NULL));
3885 static void __kmp_stg_print_schedule(kmp_str_buf_t *buffer,
char const *name,
3887 if (__kmp_env_format) {
3888 KMP_STR_BUF_PRINT_NAME_EX(name);
3890 __kmp_str_buf_print(buffer,
" %s='", name);
3892 if (__kmp_static == kmp_sch_static_greedy) {
3893 __kmp_str_buf_print(buffer,
"%s",
"static,greedy");
3894 }
else if (__kmp_static == kmp_sch_static_balanced) {
3895 __kmp_str_buf_print(buffer,
"%s",
"static,balanced");
3897 if (__kmp_guided == kmp_sch_guided_iterative_chunked) {
3898 __kmp_str_buf_print(buffer,
";%s'\n",
"guided,iterative");
3899 }
else if (__kmp_guided == kmp_sch_guided_analytical_chunked) {
3900 __kmp_str_buf_print(buffer,
";%s'\n",
"guided,analytical");
3907 static inline void __kmp_omp_schedule_restore() {
3908 #if KMP_USE_HIER_SCHED 3909 __kmp_hier_scheds.deallocate();
3919 static const char *__kmp_parse_single_omp_schedule(
const char *name,
3921 bool parse_hier =
false) {
3923 const char *ptr = value;
3930 while (*delim !=
',' && *delim !=
':' && *delim !=
'\0')
3932 #if KMP_USE_HIER_SCHED 3933 kmp_hier_layer_e layer = kmp_hier_layer_e::LAYER_THREAD;
3935 if (*delim ==
',') {
3936 if (!__kmp_strcasecmp_with_sentinel(
"L1", ptr,
',')) {
3937 layer = kmp_hier_layer_e::LAYER_L1;
3938 }
else if (!__kmp_strcasecmp_with_sentinel(
"L2", ptr,
',')) {
3939 layer = kmp_hier_layer_e::LAYER_L2;
3940 }
else if (!__kmp_strcasecmp_with_sentinel(
"L3", ptr,
',')) {
3941 layer = kmp_hier_layer_e::LAYER_L3;
3942 }
else if (!__kmp_strcasecmp_with_sentinel(
"NUMA", ptr,
',')) {
3943 layer = kmp_hier_layer_e::LAYER_NUMA;
3946 if (layer != kmp_hier_layer_e::LAYER_THREAD && *delim !=
',') {
3948 KMP_WARNING(StgInvalidValue, name, value);
3949 __kmp_omp_schedule_restore();
3951 }
else if (layer != kmp_hier_layer_e::LAYER_THREAD) {
3953 while (*delim !=
',' && *delim !=
':' && *delim !=
'\0')
3957 #endif // KMP_USE_HIER_SCHED 3960 if (*delim ==
':') {
3961 if (!__kmp_strcasecmp_with_sentinel(
"monotonic", ptr, *delim)) {
3964 while (*delim !=
',' && *delim !=
':' && *delim !=
'\0')
3966 }
else if (!__kmp_strcasecmp_with_sentinel(
"nonmonotonic", ptr, *delim)) {
3969 while (*delim !=
',' && *delim !=
':' && *delim !=
'\0')
3971 }
else if (!parse_hier) {
3973 KMP_WARNING(StgInvalidValue, name, value);
3974 __kmp_omp_schedule_restore();
3979 if (!__kmp_strcasecmp_with_sentinel(
"dynamic", ptr, *delim))
3980 sched = kmp_sch_dynamic_chunked;
3981 else if (!__kmp_strcasecmp_with_sentinel(
"guided", ptr, *delim))
3984 else if (!__kmp_strcasecmp_with_sentinel(
"auto", ptr, *delim))
3986 else if (!__kmp_strcasecmp_with_sentinel(
"trapezoidal", ptr, *delim))
3987 sched = kmp_sch_trapezoidal;
3988 else if (!__kmp_strcasecmp_with_sentinel(
"static", ptr, *delim))
3990 #if KMP_STATIC_STEAL_ENABLED 3991 else if (!__kmp_strcasecmp_with_sentinel(
"static_steal", ptr, *delim)) {
3993 sched = kmp_sch_dynamic_chunked;
3999 KMP_WARNING(StgInvalidValue, name, value);
4000 __kmp_omp_schedule_restore();
4005 if (*delim ==
',') {
4008 if (!isdigit(*ptr)) {
4010 KMP_WARNING(StgInvalidValue, name, value);
4011 __kmp_omp_schedule_restore();
4017 __kmp_msg(kmp_ms_warning, KMP_MSG(IgnoreChunk, name, delim),
4021 sched = kmp_sch_static_chunked;
4022 chunk = __kmp_str_to_int(delim + 1, *ptr);
4024 chunk = KMP_DEFAULT_CHUNK;
4025 __kmp_msg(kmp_ms_warning, KMP_MSG(InvalidChunk, name, delim),
4027 KMP_INFORM(Using_int_Value, name, __kmp_chunk);
4036 }
else if (chunk > KMP_MAX_CHUNK) {
4037 chunk = KMP_MAX_CHUNK;
4038 __kmp_msg(kmp_ms_warning, KMP_MSG(LargeChunk, name, delim),
4040 KMP_INFORM(Using_int_Value, name, chunk);
4047 SCHEDULE_SET_MODIFIERS(sched, sched_modifier);
4049 #if KMP_USE_HIER_SCHED 4050 if (layer != kmp_hier_layer_e::LAYER_THREAD) {
4051 __kmp_hier_scheds.append(sched, chunk, layer);
4055 __kmp_chunk = chunk;
4056 __kmp_sched = sched;
4061 static void __kmp_stg_parse_omp_schedule(
char const *name,
char const *value,
4064 const char *ptr = value;
4067 length = KMP_STRLEN(value);
4069 if (value[length - 1] ==
'"' || value[length - 1] ==
'\'')
4070 KMP_WARNING(UnbalancedQuotes, name);
4072 #if KMP_USE_HIER_SCHED 4073 if (!__kmp_strcasecmp_with_sentinel(
"EXPERIMENTAL", ptr,
' ')) {
4076 while ((ptr = __kmp_parse_single_omp_schedule(name, ptr,
true))) {
4077 while (*ptr ==
' ' || *ptr ==
'\t' || *ptr ==
':')
4084 __kmp_parse_single_omp_schedule(name, ptr);
4086 KMP_WARNING(EmptyString, name);
4088 #if KMP_USE_HIER_SCHED 4089 __kmp_hier_scheds.sort();
4091 K_DIAG(1, (
"__kmp_static == %d\n", __kmp_static))
4092 K_DIAG(1, (
"__kmp_guided == %d\n", __kmp_guided))
4093 K_DIAG(1, (
"__kmp_sched == %d\n", __kmp_sched))
4094 K_DIAG(1, (
"__kmp_chunk == %d\n", __kmp_chunk))
4097 static void __kmp_stg_print_omp_schedule(kmp_str_buf_t *buffer,
4098 char const *name,
void *data) {
4099 if (__kmp_env_format) {
4100 KMP_STR_BUF_PRINT_NAME_EX(name);
4102 __kmp_str_buf_print(buffer,
" %s='", name);
4104 enum sched_type sched = SCHEDULE_WITHOUT_MODIFIERS(__kmp_sched);
4105 if (SCHEDULE_HAS_MONOTONIC(__kmp_sched)) {
4106 __kmp_str_buf_print(buffer,
"monotonic:");
4107 }
else if (SCHEDULE_HAS_NONMONOTONIC(__kmp_sched)) {
4108 __kmp_str_buf_print(buffer,
"nonmonotonic:");
4112 case kmp_sch_dynamic_chunked:
4113 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"dynamic", __kmp_chunk);
4115 case kmp_sch_guided_iterative_chunked:
4116 case kmp_sch_guided_analytical_chunked:
4117 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"guided", __kmp_chunk);
4119 case kmp_sch_trapezoidal:
4120 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"trapezoidal", __kmp_chunk);
4123 case kmp_sch_static_chunked:
4124 case kmp_sch_static_balanced:
4125 case kmp_sch_static_greedy:
4126 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"static", __kmp_chunk);
4128 case kmp_sch_static_steal:
4129 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"static_steal", __kmp_chunk);
4132 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"auto", __kmp_chunk);
4137 case kmp_sch_dynamic_chunked:
4138 __kmp_str_buf_print(buffer,
"%s'\n",
"dynamic");
4140 case kmp_sch_guided_iterative_chunked:
4141 case kmp_sch_guided_analytical_chunked:
4142 __kmp_str_buf_print(buffer,
"%s'\n",
"guided");
4144 case kmp_sch_trapezoidal:
4145 __kmp_str_buf_print(buffer,
"%s'\n",
"trapezoidal");
4148 case kmp_sch_static_chunked:
4149 case kmp_sch_static_balanced:
4150 case kmp_sch_static_greedy:
4151 __kmp_str_buf_print(buffer,
"%s'\n",
"static");
4153 case kmp_sch_static_steal:
4154 __kmp_str_buf_print(buffer,
"%s'\n",
"static_steal");
4157 __kmp_str_buf_print(buffer,
"%s'\n",
"auto");
4163 #if KMP_USE_HIER_SCHED 4166 static void __kmp_stg_parse_kmp_hand_thread(
char const *name,
char const *value,
4168 __kmp_stg_parse_bool(name, value, &(__kmp_dispatch_hand_threading));
4171 static void __kmp_stg_print_kmp_hand_thread(kmp_str_buf_t *buffer,
4172 char const *name,
void *data) {
4173 __kmp_stg_print_bool(buffer, name, __kmp_dispatch_hand_threading);
4179 static void __kmp_stg_parse_kmp_force_monotonic(
char const *name,
4180 char const *value,
void *data) {
4181 __kmp_stg_parse_bool(name, value, &(__kmp_force_monotonic));
4184 static void __kmp_stg_print_kmp_force_monotonic(kmp_str_buf_t *buffer,
4185 char const *name,
void *data) {
4186 __kmp_stg_print_bool(buffer, name, __kmp_force_monotonic);
4192 static void __kmp_stg_parse_atomic_mode(
char const *name,
char const *value,
4198 #ifdef KMP_GOMP_COMPAT 4201 __kmp_stg_parse_int(name, value, 0, max, &mode);
4206 __kmp_atomic_mode = mode;
4210 static void __kmp_stg_print_atomic_mode(kmp_str_buf_t *buffer,
char const *name,
4212 __kmp_stg_print_int(buffer, name, __kmp_atomic_mode);
4218 static void __kmp_stg_parse_consistency_check(
char const *name,
4219 char const *value,
void *data) {
4220 if (!__kmp_strcasecmp_with_sentinel(
"all", value, 0)) {
4226 __kmp_env_consistency_check = TRUE;
4227 }
else if (!__kmp_strcasecmp_with_sentinel(
"none", value, 0)) {
4228 __kmp_env_consistency_check = FALSE;
4230 KMP_WARNING(StgInvalidValue, name, value);
4234 static void __kmp_stg_print_consistency_check(kmp_str_buf_t *buffer,
4235 char const *name,
void *data) {
4237 const char *value = NULL;
4239 if (__kmp_env_consistency_check) {
4245 if (value != NULL) {
4246 __kmp_stg_print_str(buffer, name, value);
4257 static void __kmp_stg_parse_itt_prepare_delay(
char const *name,
4258 char const *value,
void *data) {
4262 __kmp_stg_parse_int(name, value, 0, INT_MAX, &delay);
4263 __kmp_itt_prepare_delay = delay;
4266 static void __kmp_stg_print_itt_prepare_delay(kmp_str_buf_t *buffer,
4267 char const *name,
void *data) {
4268 __kmp_stg_print_uint64(buffer, name, __kmp_itt_prepare_delay);
4272 #endif // USE_ITT_NOTIFY 4278 static void __kmp_stg_parse_malloc_pool_incr(
char const *name,
4279 char const *value,
void *data) {
4280 __kmp_stg_parse_size(name, value, KMP_MIN_MALLOC_POOL_INCR,
4281 KMP_MAX_MALLOC_POOL_INCR, NULL, &__kmp_malloc_pool_incr,
4285 static void __kmp_stg_print_malloc_pool_incr(kmp_str_buf_t *buffer,
4286 char const *name,
void *data) {
4287 __kmp_stg_print_size(buffer, name, __kmp_malloc_pool_incr);
4296 static void __kmp_stg_parse_par_range_env(
char const *name,
char const *value,
4298 __kmp_stg_parse_par_range(name, value, &__kmp_par_range,
4299 __kmp_par_range_routine, __kmp_par_range_filename,
4300 &__kmp_par_range_lb, &__kmp_par_range_ub);
4303 static void __kmp_stg_print_par_range_env(kmp_str_buf_t *buffer,
4304 char const *name,
void *data) {
4305 if (__kmp_par_range != 0) {
4306 __kmp_stg_print_str(buffer, name, par_range_to_print);
4315 static void __kmp_stg_parse_gtid_mode(
char const *name,
char const *value,
4325 #ifdef KMP_TDATA_GTID 4328 __kmp_stg_parse_int(name, value, 0, max, &mode);
4332 __kmp_adjust_gtid_mode = TRUE;
4334 __kmp_gtid_mode = mode;
4335 __kmp_adjust_gtid_mode = FALSE;
4339 static void __kmp_stg_print_gtid_mode(kmp_str_buf_t *buffer,
char const *name,
4341 if (__kmp_adjust_gtid_mode) {
4342 __kmp_stg_print_int(buffer, name, 0);
4344 __kmp_stg_print_int(buffer, name, __kmp_gtid_mode);
4351 static void __kmp_stg_parse_lock_block(
char const *name,
char const *value,
4353 __kmp_stg_parse_int(name, value, 0, KMP_INT_MAX, &__kmp_num_locks_in_block);
4356 static void __kmp_stg_print_lock_block(kmp_str_buf_t *buffer,
char const *name,
4358 __kmp_stg_print_int(buffer, name, __kmp_num_locks_in_block);
4364 #if KMP_USE_DYNAMIC_LOCK 4365 #define KMP_STORE_LOCK_SEQ(a) (__kmp_user_lock_seq = lockseq_##a) 4367 #define KMP_STORE_LOCK_SEQ(a) 4370 static void __kmp_stg_parse_lock_kind(
char const *name,
char const *value,
4372 if (__kmp_init_user_locks) {
4373 KMP_WARNING(EnvLockWarn, name);
4377 if (__kmp_str_match(
"tas", 2, value) ||
4378 __kmp_str_match(
"test and set", 2, value) ||
4379 __kmp_str_match(
"test_and_set", 2, value) ||
4380 __kmp_str_match(
"test-and-set", 2, value) ||
4381 __kmp_str_match(
"test andset", 2, value) ||
4382 __kmp_str_match(
"test_andset", 2, value) ||
4383 __kmp_str_match(
"test-andset", 2, value) ||
4384 __kmp_str_match(
"testand set", 2, value) ||
4385 __kmp_str_match(
"testand_set", 2, value) ||
4386 __kmp_str_match(
"testand-set", 2, value) ||
4387 __kmp_str_match(
"testandset", 2, value)) {
4388 __kmp_user_lock_kind = lk_tas;
4389 KMP_STORE_LOCK_SEQ(tas);
4392 else if (__kmp_str_match(
"futex", 1, value)) {
4393 if (__kmp_futex_determine_capable()) {
4394 __kmp_user_lock_kind = lk_futex;
4395 KMP_STORE_LOCK_SEQ(futex);
4397 KMP_WARNING(FutexNotSupported, name, value);
4401 else if (__kmp_str_match(
"ticket", 2, value)) {
4402 __kmp_user_lock_kind = lk_ticket;
4403 KMP_STORE_LOCK_SEQ(ticket);
4404 }
else if (__kmp_str_match(
"queuing", 1, value) ||
4405 __kmp_str_match(
"queue", 1, value)) {
4406 __kmp_user_lock_kind = lk_queuing;
4407 KMP_STORE_LOCK_SEQ(queuing);
4408 }
else if (__kmp_str_match(
"drdpa ticket", 1, value) ||
4409 __kmp_str_match(
"drdpa_ticket", 1, value) ||
4410 __kmp_str_match(
"drdpa-ticket", 1, value) ||
4411 __kmp_str_match(
"drdpaticket", 1, value) ||
4412 __kmp_str_match(
"drdpa", 1, value)) {
4413 __kmp_user_lock_kind = lk_drdpa;
4414 KMP_STORE_LOCK_SEQ(drdpa);
4416 #if KMP_USE_ADAPTIVE_LOCKS 4417 else if (__kmp_str_match(
"adaptive", 1, value)) {
4418 if (__kmp_cpuinfo.rtm) {
4419 __kmp_user_lock_kind = lk_adaptive;
4420 KMP_STORE_LOCK_SEQ(adaptive);
4422 KMP_WARNING(AdaptiveNotSupported, name, value);
4423 __kmp_user_lock_kind = lk_queuing;
4424 KMP_STORE_LOCK_SEQ(queuing);
4427 #endif // KMP_USE_ADAPTIVE_LOCKS 4428 #if KMP_USE_DYNAMIC_LOCK && KMP_USE_TSX 4429 else if (__kmp_str_match(
"rtm_queuing", 1, value)) {
4430 if (__kmp_cpuinfo.rtm) {
4431 __kmp_user_lock_kind = lk_rtm_queuing;
4432 KMP_STORE_LOCK_SEQ(rtm_queuing);
4434 KMP_WARNING(AdaptiveNotSupported, name, value);
4435 __kmp_user_lock_kind = lk_queuing;
4436 KMP_STORE_LOCK_SEQ(queuing);
4438 }
else if (__kmp_str_match(
"rtm_spin", 1, value)) {
4439 if (__kmp_cpuinfo.rtm) {
4440 __kmp_user_lock_kind = lk_rtm_spin;
4441 KMP_STORE_LOCK_SEQ(rtm_spin);
4443 KMP_WARNING(AdaptiveNotSupported, name, value);
4444 __kmp_user_lock_kind = lk_tas;
4445 KMP_STORE_LOCK_SEQ(queuing);
4447 }
else if (__kmp_str_match(
"hle", 1, value)) {
4448 __kmp_user_lock_kind = lk_hle;
4449 KMP_STORE_LOCK_SEQ(hle);
4453 KMP_WARNING(StgInvalidValue, name, value);
4457 static void __kmp_stg_print_lock_kind(kmp_str_buf_t *buffer,
char const *name,
4459 const char *value = NULL;
4461 switch (__kmp_user_lock_kind) {
4476 #if KMP_USE_DYNAMIC_LOCK && KMP_USE_TSX 4477 case lk_rtm_queuing:
4478 value =
"rtm_queuing";
4501 #if KMP_USE_ADAPTIVE_LOCKS 4508 if (value != NULL) {
4509 __kmp_stg_print_str(buffer, name, value);
4518 static void __kmp_stg_parse_spin_backoff_params(
const char *name,
4519 const char *value,
void *data) {
4520 const char *next = value;
4523 int prev_comma = FALSE;
4526 kmp_uint32 max_backoff = __kmp_spin_backoff_params.max_backoff;
4527 kmp_uint32 min_tick = __kmp_spin_backoff_params.min_tick;
4531 for (i = 0; i < 3; i++) {
4534 if (*next ==
'\0') {
4539 if (((*next < '0' || *next >
'9') && *next !=
',') || total > 2) {
4540 KMP_WARNING(EnvSyntaxError, name, value);
4546 if (total == 0 || prev_comma) {
4554 if (*next >=
'0' && *next <=
'9') {
4556 const char *buf = next;
4557 char const *msg = NULL;
4562 const char *tmp = next;
4564 if ((*next ==
' ' || *next ==
'\t') && (*tmp >=
'0' && *tmp <=
'9')) {
4565 KMP_WARNING(EnvSpacesNotAllowed, name, value);
4569 num = __kmp_str_to_int(buf, *next);
4571 msg = KMP_I18N_STR(ValueTooSmall);
4573 }
else if (num > KMP_INT_MAX) {
4574 msg = KMP_I18N_STR(ValueTooLarge);
4579 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
4580 KMP_INFORM(Using_int_Value, name, num);
4584 }
else if (total == 2) {
4589 KMP_DEBUG_ASSERT(total > 0);
4591 KMP_WARNING(EnvSyntaxError, name, value);
4594 __kmp_spin_backoff_params.max_backoff = max_backoff;
4595 __kmp_spin_backoff_params.min_tick = min_tick;
4598 static void __kmp_stg_print_spin_backoff_params(kmp_str_buf_t *buffer,
4599 char const *name,
void *data) {
4600 if (__kmp_env_format) {
4601 KMP_STR_BUF_PRINT_NAME_EX(name);
4603 __kmp_str_buf_print(buffer,
" %s='", name);
4605 __kmp_str_buf_print(buffer,
"%d,%d'\n", __kmp_spin_backoff_params.max_backoff,
4606 __kmp_spin_backoff_params.min_tick);
4609 #if KMP_USE_ADAPTIVE_LOCKS 4616 static void __kmp_stg_parse_adaptive_lock_props(
const char *name,
4617 const char *value,
void *data) {
4618 int max_retries = 0;
4619 int max_badness = 0;
4621 const char *next = value;
4624 int prev_comma = FALSE;
4630 for (i = 0; i < 3; i++) {
4633 if (*next ==
'\0') {
4638 if (((*next < '0' || *next >
'9') && *next !=
',') || total > 2) {
4639 KMP_WARNING(EnvSyntaxError, name, value);
4645 if (total == 0 || prev_comma) {
4653 if (*next >=
'0' && *next <=
'9') {
4655 const char *buf = next;
4656 char const *msg = NULL;
4661 const char *tmp = next;
4663 if ((*next ==
' ' || *next ==
'\t') && (*tmp >=
'0' && *tmp <=
'9')) {
4664 KMP_WARNING(EnvSpacesNotAllowed, name, value);
4668 num = __kmp_str_to_int(buf, *next);
4670 msg = KMP_I18N_STR(ValueTooSmall);
4672 }
else if (num > KMP_INT_MAX) {
4673 msg = KMP_I18N_STR(ValueTooLarge);
4678 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
4679 KMP_INFORM(Using_int_Value, name, num);
4683 }
else if (total == 2) {
4688 KMP_DEBUG_ASSERT(total > 0);
4690 KMP_WARNING(EnvSyntaxError, name, value);
4693 __kmp_adaptive_backoff_params.max_soft_retries = max_retries;
4694 __kmp_adaptive_backoff_params.max_badness = max_badness;
4697 static void __kmp_stg_print_adaptive_lock_props(kmp_str_buf_t *buffer,
4698 char const *name,
void *data) {
4699 if (__kmp_env_format) {
4700 KMP_STR_BUF_PRINT_NAME_EX(name);
4702 __kmp_str_buf_print(buffer,
" %s='", name);
4704 __kmp_str_buf_print(buffer,
"%d,%d'\n",
4705 __kmp_adaptive_backoff_params.max_soft_retries,
4706 __kmp_adaptive_backoff_params.max_badness);
4709 #if KMP_DEBUG_ADAPTIVE_LOCKS 4711 static void __kmp_stg_parse_speculative_statsfile(
char const *name,
4714 __kmp_stg_parse_file(name, value,
"",
4715 CCAST(
char **, &__kmp_speculative_statsfile));
4718 static void __kmp_stg_print_speculative_statsfile(kmp_str_buf_t *buffer,
4721 if (__kmp_str_match(
"-", 0, __kmp_speculative_statsfile)) {
4722 __kmp_stg_print_str(buffer, name,
"stdout");
4724 __kmp_stg_print_str(buffer, name, __kmp_speculative_statsfile);
4729 #endif // KMP_DEBUG_ADAPTIVE_LOCKS 4731 #endif // KMP_USE_ADAPTIVE_LOCKS 4740 static kmp_hw_t __kmp_hw_subset_break_tie(
const kmp_hw_t *possible,
4741 size_t num_possible) {
4742 for (
size_t i = 0; i < num_possible; ++i) {
4743 if (possible[i] == KMP_HW_THREAD)
4744 return KMP_HW_THREAD;
4745 else if (possible[i] == KMP_HW_CORE)
4747 else if (possible[i] == KMP_HW_SOCKET)
4748 return KMP_HW_SOCKET;
4750 return KMP_HW_UNKNOWN;
4757 static kmp_hw_t __kmp_stg_parse_hw_subset_name(
char const *token) {
4758 size_t index, num_possible, token_length;
4759 kmp_hw_t possible[KMP_HW_LAST];
4765 while (isalnum(*end) || *end ==
'_') {
4772 KMP_FOREACH_HW_TYPE(type) { possible[num_possible++] = type; }
4779 while (num_possible > 1 && index < token_length) {
4780 size_t n = num_possible;
4781 char token_char = (char)toupper(token[index]);
4782 for (
size_t i = 0; i < n; ++i) {
4784 kmp_hw_t type = possible[i];
4785 s = __kmp_hw_get_keyword(type,
false);
4786 if (index < KMP_STRLEN(s)) {
4787 char c = (char)toupper(s[index]);
4789 if (c != token_char) {
4790 possible[i] = KMP_HW_UNKNOWN;
4797 for (
size_t i = 0; i < n; ++i) {
4798 if (possible[i] != KMP_HW_UNKNOWN) {
4799 kmp_hw_t temp = possible[i];
4800 possible[i] = possible[start];
4801 possible[start] = temp;
4805 KMP_ASSERT(start == num_possible);
4811 if (num_possible > 1)
4812 return __kmp_hw_subset_break_tie(possible, num_possible);
4813 if (num_possible == 1)
4815 return KMP_HW_UNKNOWN;
4820 #define MAX_T_LEVEL KMP_HW_LAST 4821 #define MAX_STR_LEN 512 4822 static void __kmp_stg_parse_hw_subset(
char const *name,
char const *value,
4826 kmp_setting_t **rivals = (kmp_setting_t **)data;
4827 if (strcmp(name,
"KMP_PLACE_THREADS") == 0) {
4828 KMP_INFORM(EnvVarDeprecated, name,
"KMP_HW_SUBSET");
4830 if (__kmp_stg_check_rivals(name, value, rivals)) {
4834 char *components[MAX_T_LEVEL];
4835 char const *digits =
"0123456789";
4836 char input[MAX_STR_LEN];
4837 size_t len = 0, mlen = MAX_STR_LEN;
4839 bool absolute =
false;
4841 char *pos = CCAST(
char *, value);
4842 while (*pos && mlen) {
4844 if (len == 0 && *pos ==
':') {
4847 input[len] = (char)(toupper(*pos));
4848 if (input[len] ==
'X')
4850 if (input[len] ==
'O' && strchr(digits, *(pos + 1)))
4858 if (len == 0 || mlen == 0) {
4864 components[level++] = pos;
4865 while ((pos = strchr(pos,
','))) {
4866 if (level >= MAX_T_LEVEL)
4869 components[level++] = ++pos;
4872 __kmp_hw_subset = kmp_hw_subset_t::allocate();
4874 __kmp_hw_subset->set_absolute();
4877 for (
int i = 0; i < level; ++i) {
4879 int num = atoi(components[i]);
4883 if ((pos = strchr(components[i],
'@'))) {
4884 offset = atoi(pos + 1);
4887 pos = components[i] + strspn(components[i], digits);
4888 if (pos == components[i]) {
4892 kmp_hw_t type = __kmp_stg_parse_hw_subset_name(pos);
4893 if (type == KMP_HW_UNKNOWN) {
4896 if (__kmp_hw_subset->specified(type)) {
4899 __kmp_hw_subset->push_back(num, type, offset);
4903 KMP_WARNING(AffHWSubsetInvalid, name, value);
4904 if (__kmp_hw_subset) {
4905 kmp_hw_subset_t::deallocate(__kmp_hw_subset);
4906 __kmp_hw_subset =
nullptr;
4911 static void __kmp_stg_print_hw_subset(kmp_str_buf_t *buffer,
char const *name,
4915 if (!__kmp_hw_subset)
4917 __kmp_str_buf_init(&buf);
4918 if (__kmp_env_format)
4919 KMP_STR_BUF_PRINT_NAME_EX(name);
4921 __kmp_str_buf_print(buffer,
" %s='", name);
4923 depth = __kmp_hw_subset->get_depth();
4924 for (
int i = 0; i < depth; ++i) {
4925 const auto &item = __kmp_hw_subset->at(i);
4926 __kmp_str_buf_print(&buf,
"%s%d%s", (i > 0 ?
"," :
""), item.num,
4927 __kmp_hw_get_keyword(item.type));
4929 __kmp_str_buf_print(&buf,
"@%d", item.offset);
4931 __kmp_str_buf_print(buffer,
"%s'\n", buf.str);
4932 __kmp_str_buf_free(&buf);
4939 static void __kmp_stg_parse_forkjoin_frames(
char const *name,
char const *value,
4941 __kmp_stg_parse_bool(name, value, &__kmp_forkjoin_frames);
4944 static void __kmp_stg_print_forkjoin_frames(kmp_str_buf_t *buffer,
4945 char const *name,
void *data) {
4946 __kmp_stg_print_bool(buffer, name, __kmp_forkjoin_frames);
4952 static void __kmp_stg_parse_forkjoin_frames_mode(
char const *name,
4955 __kmp_stg_parse_int(name, value, 0, 3, &__kmp_forkjoin_frames_mode);
4958 static void __kmp_stg_print_forkjoin_frames_mode(kmp_str_buf_t *buffer,
4959 char const *name,
void *data) {
4960 __kmp_stg_print_int(buffer, name, __kmp_forkjoin_frames_mode);
4967 static void __kmp_stg_parse_task_throttling(
char const *name,
char const *value,
4969 __kmp_stg_parse_bool(name, value, &__kmp_enable_task_throttling);
4972 static void __kmp_stg_print_task_throttling(kmp_str_buf_t *buffer,
4973 char const *name,
void *data) {
4974 __kmp_stg_print_bool(buffer, name, __kmp_enable_task_throttling);
4977 #if KMP_HAVE_MWAIT || KMP_HAVE_UMWAIT 4981 static void __kmp_stg_parse_user_level_mwait(
char const *name,
4982 char const *value,
void *data) {
4983 __kmp_stg_parse_bool(name, value, &__kmp_user_level_mwait);
4986 static void __kmp_stg_print_user_level_mwait(kmp_str_buf_t *buffer,
4987 char const *name,
void *data) {
4988 __kmp_stg_print_bool(buffer, name, __kmp_user_level_mwait);
4994 static void __kmp_stg_parse_mwait_hints(
char const *name,
char const *value,
4996 __kmp_stg_parse_int(name, value, 0, INT_MAX, &__kmp_mwait_hints);
4999 static void __kmp_stg_print_mwait_hints(kmp_str_buf_t *buffer,
char const *name,
5001 __kmp_stg_print_int(buffer, name, __kmp_mwait_hints);
5004 #endif // KMP_HAVE_MWAIT || KMP_HAVE_UMWAIT 5009 static void __kmp_stg_parse_omp_display_env(
char const *name,
char const *value,
5011 if (__kmp_str_match(
"VERBOSE", 1, value)) {
5012 __kmp_display_env_verbose = TRUE;
5014 __kmp_stg_parse_bool(name, value, &__kmp_display_env);
5018 static void __kmp_stg_print_omp_display_env(kmp_str_buf_t *buffer,
5019 char const *name,
void *data) {
5020 if (__kmp_display_env_verbose) {
5021 __kmp_stg_print_str(buffer, name,
"VERBOSE");
5023 __kmp_stg_print_bool(buffer, name, __kmp_display_env);
5027 static void __kmp_stg_parse_omp_cancellation(
char const *name,
5028 char const *value,
void *data) {
5029 if (TCR_4(__kmp_init_parallel)) {
5030 KMP_WARNING(EnvParallelWarn, name);
5033 __kmp_stg_parse_bool(name, value, &__kmp_omp_cancellation);
5036 static void __kmp_stg_print_omp_cancellation(kmp_str_buf_t *buffer,
5037 char const *name,
void *data) {
5038 __kmp_stg_print_bool(buffer, name, __kmp_omp_cancellation);
5044 static void __kmp_stg_parse_omp_tool(
char const *name,
char const *value,
5046 __kmp_stg_parse_bool(name, value, &__kmp_tool);
5049 static void __kmp_stg_print_omp_tool(kmp_str_buf_t *buffer,
char const *name,
5051 if (__kmp_env_format) {
5052 KMP_STR_BUF_PRINT_BOOL_EX(name, __kmp_tool,
"enabled",
"disabled");
5054 __kmp_str_buf_print(buffer,
" %s=%s\n", name,
5055 __kmp_tool ?
"enabled" :
"disabled");
5059 char *__kmp_tool_libraries = NULL;
5061 static void __kmp_stg_parse_omp_tool_libraries(
char const *name,
5062 char const *value,
void *data) {
5063 __kmp_stg_parse_str(name, value, &__kmp_tool_libraries);
5066 static void __kmp_stg_print_omp_tool_libraries(kmp_str_buf_t *buffer,
5067 char const *name,
void *data) {
5068 if (__kmp_tool_libraries)
5069 __kmp_stg_print_str(buffer, name, __kmp_tool_libraries);
5071 if (__kmp_env_format) {
5072 KMP_STR_BUF_PRINT_NAME;
5074 __kmp_str_buf_print(buffer,
" %s", name);
5076 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
5080 char *__kmp_tool_verbose_init = NULL;
5082 static void __kmp_stg_parse_omp_tool_verbose_init(
char const *name,
5085 __kmp_stg_parse_str(name, value, &__kmp_tool_verbose_init);
5088 static void __kmp_stg_print_omp_tool_verbose_init(kmp_str_buf_t *buffer,
5091 if (__kmp_tool_verbose_init)
5092 __kmp_stg_print_str(buffer, name, __kmp_tool_verbose_init);
5094 if (__kmp_env_format) {
5095 KMP_STR_BUF_PRINT_NAME;
5097 __kmp_str_buf_print(buffer,
" %s", name);
5099 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
5107 static kmp_setting_t __kmp_stg_table[] = {
5109 {
"KMP_ALL_THREADS", __kmp_stg_parse_device_thread_limit, NULL, NULL, 0, 0},
5110 {
"KMP_BLOCKTIME", __kmp_stg_parse_blocktime, __kmp_stg_print_blocktime,
5112 {
"KMP_USE_YIELD", __kmp_stg_parse_use_yield, __kmp_stg_print_use_yield,
5114 {
"KMP_DUPLICATE_LIB_OK", __kmp_stg_parse_duplicate_lib_ok,
5115 __kmp_stg_print_duplicate_lib_ok, NULL, 0, 0},
5116 {
"KMP_LIBRARY", __kmp_stg_parse_wait_policy, __kmp_stg_print_wait_policy,
5118 {
"KMP_DEVICE_THREAD_LIMIT", __kmp_stg_parse_device_thread_limit,
5119 __kmp_stg_print_device_thread_limit, NULL, 0, 0},
5121 {
"KMP_MONITOR_STACKSIZE", __kmp_stg_parse_monitor_stacksize,
5122 __kmp_stg_print_monitor_stacksize, NULL, 0, 0},
5124 {
"KMP_SETTINGS", __kmp_stg_parse_settings, __kmp_stg_print_settings, NULL,
5126 {
"KMP_STACKOFFSET", __kmp_stg_parse_stackoffset,
5127 __kmp_stg_print_stackoffset, NULL, 0, 0},
5128 {
"KMP_STACKSIZE", __kmp_stg_parse_stacksize, __kmp_stg_print_stacksize,
5130 {
"KMP_STACKPAD", __kmp_stg_parse_stackpad, __kmp_stg_print_stackpad, NULL,
5132 {
"KMP_VERSION", __kmp_stg_parse_version, __kmp_stg_print_version, NULL, 0,
5134 {
"KMP_WARNINGS", __kmp_stg_parse_warnings, __kmp_stg_print_warnings, NULL,
5137 {
"KMP_NESTING_MODE", __kmp_stg_parse_nesting_mode,
5138 __kmp_stg_print_nesting_mode, NULL, 0, 0},
5139 {
"OMP_NESTED", __kmp_stg_parse_nested, __kmp_stg_print_nested, NULL, 0, 0},
5140 {
"OMP_NUM_THREADS", __kmp_stg_parse_num_threads,
5141 __kmp_stg_print_num_threads, NULL, 0, 0},
5142 {
"OMP_STACKSIZE", __kmp_stg_parse_stacksize, __kmp_stg_print_stacksize,
5145 {
"KMP_TASKING", __kmp_stg_parse_tasking, __kmp_stg_print_tasking, NULL, 0,
5147 {
"KMP_TASK_STEALING_CONSTRAINT", __kmp_stg_parse_task_stealing,
5148 __kmp_stg_print_task_stealing, NULL, 0, 0},
5149 {
"OMP_MAX_ACTIVE_LEVELS", __kmp_stg_parse_max_active_levels,
5150 __kmp_stg_print_max_active_levels, NULL, 0, 0},
5151 {
"OMP_DEFAULT_DEVICE", __kmp_stg_parse_default_device,
5152 __kmp_stg_print_default_device, NULL, 0, 0},
5153 {
"OMP_TARGET_OFFLOAD", __kmp_stg_parse_target_offload,
5154 __kmp_stg_print_target_offload, NULL, 0, 0},
5155 {
"OMP_MAX_TASK_PRIORITY", __kmp_stg_parse_max_task_priority,
5156 __kmp_stg_print_max_task_priority, NULL, 0, 0},
5157 {
"KMP_TASKLOOP_MIN_TASKS", __kmp_stg_parse_taskloop_min_tasks,
5158 __kmp_stg_print_taskloop_min_tasks, NULL, 0, 0},
5159 {
"OMP_THREAD_LIMIT", __kmp_stg_parse_thread_limit,
5160 __kmp_stg_print_thread_limit, NULL, 0, 0},
5161 {
"KMP_TEAMS_THREAD_LIMIT", __kmp_stg_parse_teams_thread_limit,
5162 __kmp_stg_print_teams_thread_limit, NULL, 0, 0},
5163 {
"OMP_NUM_TEAMS", __kmp_stg_parse_nteams, __kmp_stg_print_nteams, NULL, 0,
5165 {
"OMP_TEAMS_THREAD_LIMIT", __kmp_stg_parse_teams_th_limit,
5166 __kmp_stg_print_teams_th_limit, NULL, 0, 0},
5167 {
"OMP_WAIT_POLICY", __kmp_stg_parse_wait_policy,
5168 __kmp_stg_print_wait_policy, NULL, 0, 0},
5169 {
"KMP_DISP_NUM_BUFFERS", __kmp_stg_parse_disp_buffers,
5170 __kmp_stg_print_disp_buffers, NULL, 0, 0},
5171 #if KMP_NESTED_HOT_TEAMS 5172 {
"KMP_HOT_TEAMS_MAX_LEVEL", __kmp_stg_parse_hot_teams_level,
5173 __kmp_stg_print_hot_teams_level, NULL, 0, 0},
5174 {
"KMP_HOT_TEAMS_MODE", __kmp_stg_parse_hot_teams_mode,
5175 __kmp_stg_print_hot_teams_mode, NULL, 0, 0},
5176 #endif // KMP_NESTED_HOT_TEAMS 5178 #if KMP_HANDLE_SIGNALS 5179 {
"KMP_HANDLE_SIGNALS", __kmp_stg_parse_handle_signals,
5180 __kmp_stg_print_handle_signals, NULL, 0, 0},
5183 #if KMP_ARCH_X86 || KMP_ARCH_X86_64 5184 {
"KMP_INHERIT_FP_CONTROL", __kmp_stg_parse_inherit_fp_control,
5185 __kmp_stg_print_inherit_fp_control, NULL, 0, 0},
5188 #ifdef KMP_GOMP_COMPAT 5189 {
"GOMP_STACKSIZE", __kmp_stg_parse_stacksize, NULL, NULL, 0, 0},
5193 {
"KMP_A_DEBUG", __kmp_stg_parse_a_debug, __kmp_stg_print_a_debug, NULL, 0,
5195 {
"KMP_B_DEBUG", __kmp_stg_parse_b_debug, __kmp_stg_print_b_debug, NULL, 0,
5197 {
"KMP_C_DEBUG", __kmp_stg_parse_c_debug, __kmp_stg_print_c_debug, NULL, 0,
5199 {
"KMP_D_DEBUG", __kmp_stg_parse_d_debug, __kmp_stg_print_d_debug, NULL, 0,
5201 {
"KMP_E_DEBUG", __kmp_stg_parse_e_debug, __kmp_stg_print_e_debug, NULL, 0,
5203 {
"KMP_F_DEBUG", __kmp_stg_parse_f_debug, __kmp_stg_print_f_debug, NULL, 0,
5205 {
"KMP_DEBUG", __kmp_stg_parse_debug, NULL, NULL, 0, 0},
5206 {
"KMP_DEBUG_BUF", __kmp_stg_parse_debug_buf, __kmp_stg_print_debug_buf,
5208 {
"KMP_DEBUG_BUF_ATOMIC", __kmp_stg_parse_debug_buf_atomic,
5209 __kmp_stg_print_debug_buf_atomic, NULL, 0, 0},
5210 {
"KMP_DEBUG_BUF_CHARS", __kmp_stg_parse_debug_buf_chars,
5211 __kmp_stg_print_debug_buf_chars, NULL, 0, 0},
5212 {
"KMP_DEBUG_BUF_LINES", __kmp_stg_parse_debug_buf_lines,
5213 __kmp_stg_print_debug_buf_lines, NULL, 0, 0},
5214 {
"KMP_DIAG", __kmp_stg_parse_diag, __kmp_stg_print_diag, NULL, 0, 0},
5216 {
"KMP_PAR_RANGE", __kmp_stg_parse_par_range_env,
5217 __kmp_stg_print_par_range_env, NULL, 0, 0},
5220 {
"KMP_ALIGN_ALLOC", __kmp_stg_parse_align_alloc,
5221 __kmp_stg_print_align_alloc, NULL, 0, 0},
5223 {
"KMP_PLAIN_BARRIER", __kmp_stg_parse_barrier_branch_bit,
5224 __kmp_stg_print_barrier_branch_bit, NULL, 0, 0},
5225 {
"KMP_PLAIN_BARRIER_PATTERN", __kmp_stg_parse_barrier_pattern,
5226 __kmp_stg_print_barrier_pattern, NULL, 0, 0},
5227 {
"KMP_FORKJOIN_BARRIER", __kmp_stg_parse_barrier_branch_bit,
5228 __kmp_stg_print_barrier_branch_bit, NULL, 0, 0},
5229 {
"KMP_FORKJOIN_BARRIER_PATTERN", __kmp_stg_parse_barrier_pattern,
5230 __kmp_stg_print_barrier_pattern, NULL, 0, 0},
5231 #if KMP_FAST_REDUCTION_BARRIER 5232 {
"KMP_REDUCTION_BARRIER", __kmp_stg_parse_barrier_branch_bit,
5233 __kmp_stg_print_barrier_branch_bit, NULL, 0, 0},
5234 {
"KMP_REDUCTION_BARRIER_PATTERN", __kmp_stg_parse_barrier_pattern,
5235 __kmp_stg_print_barrier_pattern, NULL, 0, 0},
5238 {
"KMP_ABORT_DELAY", __kmp_stg_parse_abort_delay,
5239 __kmp_stg_print_abort_delay, NULL, 0, 0},
5240 {
"KMP_CPUINFO_FILE", __kmp_stg_parse_cpuinfo_file,
5241 __kmp_stg_print_cpuinfo_file, NULL, 0, 0},
5242 {
"KMP_FORCE_REDUCTION", __kmp_stg_parse_force_reduction,
5243 __kmp_stg_print_force_reduction, NULL, 0, 0},
5244 {
"KMP_DETERMINISTIC_REDUCTION", __kmp_stg_parse_force_reduction,
5245 __kmp_stg_print_force_reduction, NULL, 0, 0},
5246 {
"KMP_STORAGE_MAP", __kmp_stg_parse_storage_map,
5247 __kmp_stg_print_storage_map, NULL, 0, 0},
5248 {
"KMP_ALL_THREADPRIVATE", __kmp_stg_parse_all_threadprivate,
5249 __kmp_stg_print_all_threadprivate, NULL, 0, 0},
5250 {
"KMP_FOREIGN_THREADS_THREADPRIVATE",
5251 __kmp_stg_parse_foreign_threads_threadprivate,
5252 __kmp_stg_print_foreign_threads_threadprivate, NULL, 0, 0},
5254 #if KMP_AFFINITY_SUPPORTED 5255 {
"KMP_AFFINITY", __kmp_stg_parse_affinity, __kmp_stg_print_affinity, NULL,
5257 #ifdef KMP_GOMP_COMPAT 5258 {
"GOMP_CPU_AFFINITY", __kmp_stg_parse_gomp_cpu_affinity, NULL,
5261 {
"OMP_PROC_BIND", __kmp_stg_parse_proc_bind, __kmp_stg_print_proc_bind,
5263 {
"OMP_PLACES", __kmp_stg_parse_places, __kmp_stg_print_places, NULL, 0, 0},
5264 {
"KMP_TOPOLOGY_METHOD", __kmp_stg_parse_topology_method,
5265 __kmp_stg_print_topology_method, NULL, 0, 0},
5271 {
"OMP_PROC_BIND", __kmp_stg_parse_proc_bind, __kmp_stg_print_proc_bind,
5274 #endif // KMP_AFFINITY_SUPPORTED 5275 {
"OMP_DISPLAY_AFFINITY", __kmp_stg_parse_display_affinity,
5276 __kmp_stg_print_display_affinity, NULL, 0, 0},
5277 {
"OMP_AFFINITY_FORMAT", __kmp_stg_parse_affinity_format,
5278 __kmp_stg_print_affinity_format, NULL, 0, 0},
5279 {
"KMP_INIT_AT_FORK", __kmp_stg_parse_init_at_fork,
5280 __kmp_stg_print_init_at_fork, NULL, 0, 0},
5281 {
"KMP_SCHEDULE", __kmp_stg_parse_schedule, __kmp_stg_print_schedule, NULL,
5283 {
"OMP_SCHEDULE", __kmp_stg_parse_omp_schedule, __kmp_stg_print_omp_schedule,
5285 #if KMP_USE_HIER_SCHED 5286 {
"KMP_DISP_HAND_THREAD", __kmp_stg_parse_kmp_hand_thread,
5287 __kmp_stg_print_kmp_hand_thread, NULL, 0, 0},
5289 {
"KMP_FORCE_MONOTONIC_DYNAMIC_SCHEDULE",
5290 __kmp_stg_parse_kmp_force_monotonic, __kmp_stg_print_kmp_force_monotonic,
5292 {
"KMP_ATOMIC_MODE", __kmp_stg_parse_atomic_mode,
5293 __kmp_stg_print_atomic_mode, NULL, 0, 0},
5294 {
"KMP_CONSISTENCY_CHECK", __kmp_stg_parse_consistency_check,
5295 __kmp_stg_print_consistency_check, NULL, 0, 0},
5297 #if USE_ITT_BUILD && USE_ITT_NOTIFY 5298 {
"KMP_ITT_PREPARE_DELAY", __kmp_stg_parse_itt_prepare_delay,
5299 __kmp_stg_print_itt_prepare_delay, NULL, 0, 0},
5301 {
"KMP_MALLOC_POOL_INCR", __kmp_stg_parse_malloc_pool_incr,
5302 __kmp_stg_print_malloc_pool_incr, NULL, 0, 0},
5303 {
"KMP_GTID_MODE", __kmp_stg_parse_gtid_mode, __kmp_stg_print_gtid_mode,
5305 {
"OMP_DYNAMIC", __kmp_stg_parse_omp_dynamic, __kmp_stg_print_omp_dynamic,
5307 {
"KMP_DYNAMIC_MODE", __kmp_stg_parse_kmp_dynamic_mode,
5308 __kmp_stg_print_kmp_dynamic_mode, NULL, 0, 0},
5310 #ifdef USE_LOAD_BALANCE 5311 {
"KMP_LOAD_BALANCE_INTERVAL", __kmp_stg_parse_ld_balance_interval,
5312 __kmp_stg_print_ld_balance_interval, NULL, 0, 0},
5315 {
"KMP_NUM_LOCKS_IN_BLOCK", __kmp_stg_parse_lock_block,
5316 __kmp_stg_print_lock_block, NULL, 0, 0},
5317 {
"KMP_LOCK_KIND", __kmp_stg_parse_lock_kind, __kmp_stg_print_lock_kind,
5319 {
"KMP_SPIN_BACKOFF_PARAMS", __kmp_stg_parse_spin_backoff_params,
5320 __kmp_stg_print_spin_backoff_params, NULL, 0, 0},
5321 #if KMP_USE_ADAPTIVE_LOCKS 5322 {
"KMP_ADAPTIVE_LOCK_PROPS", __kmp_stg_parse_adaptive_lock_props,
5323 __kmp_stg_print_adaptive_lock_props, NULL, 0, 0},
5324 #if KMP_DEBUG_ADAPTIVE_LOCKS 5325 {
"KMP_SPECULATIVE_STATSFILE", __kmp_stg_parse_speculative_statsfile,
5326 __kmp_stg_print_speculative_statsfile, NULL, 0, 0},
5328 #endif // KMP_USE_ADAPTIVE_LOCKS 5329 {
"KMP_PLACE_THREADS", __kmp_stg_parse_hw_subset, __kmp_stg_print_hw_subset,
5331 {
"KMP_HW_SUBSET", __kmp_stg_parse_hw_subset, __kmp_stg_print_hw_subset,
5334 {
"KMP_FORKJOIN_FRAMES", __kmp_stg_parse_forkjoin_frames,
5335 __kmp_stg_print_forkjoin_frames, NULL, 0, 0},
5336 {
"KMP_FORKJOIN_FRAMES_MODE", __kmp_stg_parse_forkjoin_frames_mode,
5337 __kmp_stg_print_forkjoin_frames_mode, NULL, 0, 0},
5339 {
"KMP_ENABLE_TASK_THROTTLING", __kmp_stg_parse_task_throttling,
5340 __kmp_stg_print_task_throttling, NULL, 0, 0},
5342 {
"OMP_DISPLAY_ENV", __kmp_stg_parse_omp_display_env,
5343 __kmp_stg_print_omp_display_env, NULL, 0, 0},
5344 {
"OMP_CANCELLATION", __kmp_stg_parse_omp_cancellation,
5345 __kmp_stg_print_omp_cancellation, NULL, 0, 0},
5346 {
"OMP_ALLOCATOR", __kmp_stg_parse_allocator, __kmp_stg_print_allocator,
5348 {
"LIBOMP_USE_HIDDEN_HELPER_TASK", __kmp_stg_parse_use_hidden_helper,
5349 __kmp_stg_print_use_hidden_helper, NULL, 0, 0},
5350 {
"LIBOMP_NUM_HIDDEN_HELPER_THREADS",
5351 __kmp_stg_parse_num_hidden_helper_threads,
5352 __kmp_stg_print_num_hidden_helper_threads, NULL, 0, 0},
5355 {
"OMP_TOOL", __kmp_stg_parse_omp_tool, __kmp_stg_print_omp_tool, NULL, 0,
5357 {
"OMP_TOOL_LIBRARIES", __kmp_stg_parse_omp_tool_libraries,
5358 __kmp_stg_print_omp_tool_libraries, NULL, 0, 0},
5359 {
"OMP_TOOL_VERBOSE_INIT", __kmp_stg_parse_omp_tool_verbose_init,
5360 __kmp_stg_print_omp_tool_verbose_init, NULL, 0, 0},
5363 #if KMP_HAVE_MWAIT || KMP_HAVE_UMWAIT 5364 {
"KMP_USER_LEVEL_MWAIT", __kmp_stg_parse_user_level_mwait,
5365 __kmp_stg_print_user_level_mwait, NULL, 0, 0},
5366 {
"KMP_MWAIT_HINTS", __kmp_stg_parse_mwait_hints,
5367 __kmp_stg_print_mwait_hints, NULL, 0, 0},
5369 {
"", NULL, NULL, NULL, 0, 0}};
5371 static int const __kmp_stg_count =
5372 sizeof(__kmp_stg_table) /
sizeof(kmp_setting_t);
5374 static inline kmp_setting_t *__kmp_stg_find(
char const *name) {
5378 for (i = 0; i < __kmp_stg_count; ++i) {
5379 if (strcmp(__kmp_stg_table[i].name, name) == 0) {
5380 return &__kmp_stg_table[i];
5388 static int __kmp_stg_cmp(
void const *_a,
void const *_b) {
5389 const kmp_setting_t *a = RCAST(
const kmp_setting_t *, _a);
5390 const kmp_setting_t *b = RCAST(
const kmp_setting_t *, _b);
5394 if (strcmp(a->name,
"KMP_AFFINITY") == 0) {
5395 if (strcmp(b->name,
"KMP_AFFINITY") == 0) {
5399 }
else if (strcmp(b->name,
"KMP_AFFINITY") == 0) {
5402 return strcmp(a->name, b->name);
5405 static void __kmp_stg_init(
void) {
5407 static int initialized = 0;
5412 qsort(__kmp_stg_table, __kmp_stg_count - 1,
sizeof(kmp_setting_t),
5416 kmp_setting_t *kmp_stacksize =
5417 __kmp_stg_find(
"KMP_STACKSIZE");
5418 #ifdef KMP_GOMP_COMPAT 5419 kmp_setting_t *gomp_stacksize =
5420 __kmp_stg_find(
"GOMP_STACKSIZE");
5422 kmp_setting_t *omp_stacksize =
5423 __kmp_stg_find(
"OMP_STACKSIZE");
5429 static kmp_setting_t *
volatile rivals[4];
5430 static kmp_stg_ss_data_t kmp_data = {1, CCAST(kmp_setting_t **, rivals)};
5431 #ifdef KMP_GOMP_COMPAT 5432 static kmp_stg_ss_data_t gomp_data = {1024,
5433 CCAST(kmp_setting_t **, rivals)};
5435 static kmp_stg_ss_data_t omp_data = {1024,
5436 CCAST(kmp_setting_t **, rivals)};
5439 rivals[i++] = kmp_stacksize;
5440 #ifdef KMP_GOMP_COMPAT 5441 if (gomp_stacksize != NULL) {
5442 rivals[i++] = gomp_stacksize;
5445 rivals[i++] = omp_stacksize;
5448 kmp_stacksize->data = &kmp_data;
5449 #ifdef KMP_GOMP_COMPAT 5450 if (gomp_stacksize != NULL) {
5451 gomp_stacksize->data = &gomp_data;
5454 omp_stacksize->data = &omp_data;
5458 kmp_setting_t *kmp_library =
5459 __kmp_stg_find(
"KMP_LIBRARY");
5460 kmp_setting_t *omp_wait_policy =
5461 __kmp_stg_find(
"OMP_WAIT_POLICY");
5464 static kmp_setting_t *
volatile rivals[3];
5465 static kmp_stg_wp_data_t kmp_data = {0, CCAST(kmp_setting_t **, rivals)};
5466 static kmp_stg_wp_data_t omp_data = {1, CCAST(kmp_setting_t **, rivals)};
5469 rivals[i++] = kmp_library;
5470 if (omp_wait_policy != NULL) {
5471 rivals[i++] = omp_wait_policy;
5475 kmp_library->data = &kmp_data;
5476 if (omp_wait_policy != NULL) {
5477 omp_wait_policy->data = &omp_data;
5482 kmp_setting_t *kmp_device_thread_limit =
5483 __kmp_stg_find(
"KMP_DEVICE_THREAD_LIMIT");
5484 kmp_setting_t *kmp_all_threads =
5485 __kmp_stg_find(
"KMP_ALL_THREADS");
5488 static kmp_setting_t *
volatile rivals[3];
5491 rivals[i++] = kmp_device_thread_limit;
5492 rivals[i++] = kmp_all_threads;
5495 kmp_device_thread_limit->data = CCAST(kmp_setting_t **, rivals);
5496 kmp_all_threads->data = CCAST(kmp_setting_t **, rivals);
5501 kmp_setting_t *kmp_hw_subset = __kmp_stg_find(
"KMP_HW_SUBSET");
5503 kmp_setting_t *kmp_place_threads = __kmp_stg_find(
"KMP_PLACE_THREADS");
5506 static kmp_setting_t *
volatile rivals[3];
5509 rivals[i++] = kmp_hw_subset;
5510 rivals[i++] = kmp_place_threads;
5513 kmp_hw_subset->data = CCAST(kmp_setting_t **, rivals);
5514 kmp_place_threads->data = CCAST(kmp_setting_t **, rivals);
5517 #if KMP_AFFINITY_SUPPORTED 5519 kmp_setting_t *kmp_affinity =
5520 __kmp_stg_find(
"KMP_AFFINITY");
5521 KMP_DEBUG_ASSERT(kmp_affinity != NULL);
5523 #ifdef KMP_GOMP_COMPAT 5524 kmp_setting_t *gomp_cpu_affinity =
5525 __kmp_stg_find(
"GOMP_CPU_AFFINITY");
5526 KMP_DEBUG_ASSERT(gomp_cpu_affinity != NULL);
5529 kmp_setting_t *omp_proc_bind =
5530 __kmp_stg_find(
"OMP_PROC_BIND");
5531 KMP_DEBUG_ASSERT(omp_proc_bind != NULL);
5534 static kmp_setting_t *
volatile rivals[4];
5537 rivals[i++] = kmp_affinity;
5539 #ifdef KMP_GOMP_COMPAT 5540 rivals[i++] = gomp_cpu_affinity;
5541 gomp_cpu_affinity->data = CCAST(kmp_setting_t **, rivals);
5544 rivals[i++] = omp_proc_bind;
5545 omp_proc_bind->data = CCAST(kmp_setting_t **, rivals);
5548 static kmp_setting_t *
volatile places_rivals[4];
5551 kmp_setting_t *omp_places = __kmp_stg_find(
"OMP_PLACES");
5552 KMP_DEBUG_ASSERT(omp_places != NULL);
5554 places_rivals[i++] = kmp_affinity;
5555 #ifdef KMP_GOMP_COMPAT 5556 places_rivals[i++] = gomp_cpu_affinity;
5558 places_rivals[i++] = omp_places;
5559 omp_places->data = CCAST(kmp_setting_t **, places_rivals);
5560 places_rivals[i++] = NULL;
5565 #endif // KMP_AFFINITY_SUPPORTED 5568 kmp_setting_t *kmp_force_red =
5569 __kmp_stg_find(
"KMP_FORCE_REDUCTION");
5570 kmp_setting_t *kmp_determ_red =
5571 __kmp_stg_find(
"KMP_DETERMINISTIC_REDUCTION");
5574 static kmp_setting_t *
volatile rivals[3];
5575 static kmp_stg_fr_data_t force_data = {1,
5576 CCAST(kmp_setting_t **, rivals)};
5577 static kmp_stg_fr_data_t determ_data = {0,
5578 CCAST(kmp_setting_t **, rivals)};
5581 rivals[i++] = kmp_force_red;
5582 if (kmp_determ_red != NULL) {
5583 rivals[i++] = kmp_determ_red;
5587 kmp_force_red->data = &force_data;
5588 if (kmp_determ_red != NULL) {
5589 kmp_determ_red->data = &determ_data;
5598 for (i = 0; i < __kmp_stg_count; ++i) {
5599 __kmp_stg_table[i].set = 0;
5604 static void __kmp_stg_parse(
char const *name,
char const *value) {
5612 if (value != NULL) {
5613 kmp_setting_t *setting = __kmp_stg_find(name);
5614 if (setting != NULL) {
5615 setting->parse(name, value, setting->data);
5616 setting->defined = 1;
5622 static int __kmp_stg_check_rivals(
5625 kmp_setting_t **rivals
5628 if (rivals == NULL) {
5634 for (; strcmp(rivals[i]->name, name) != 0; i++) {
5635 KMP_DEBUG_ASSERT(rivals[i] != NULL);
5637 #if KMP_AFFINITY_SUPPORTED 5638 if (rivals[i] == __kmp_affinity_notype) {
5645 if (rivals[i]->
set) {
5646 KMP_WARNING(StgIgnored, name, rivals[i]->name);
5656 static int __kmp_env_toPrint(
char const *name,
int flag) {
5658 kmp_setting_t *setting = __kmp_stg_find(name);
5659 if (setting != NULL) {
5660 rc = setting->defined;
5662 setting->defined = flag;
5668 static void __kmp_aux_env_initialize(kmp_env_blk_t *block) {
5673 value = __kmp_env_blk_var(block,
"OMP_NUM_THREADS");
5675 ompc_set_num_threads(__kmp_dflt_team_nth);
5679 value = __kmp_env_blk_var(block,
"KMP_BLOCKTIME");
5681 kmpc_set_blocktime(__kmp_dflt_blocktime);
5685 value = __kmp_env_blk_var(block,
"OMP_NESTED");
5687 ompc_set_nested(__kmp_dflt_max_active_levels > 1);
5691 value = __kmp_env_blk_var(block,
"OMP_DYNAMIC");
5693 ompc_set_dynamic(__kmp_global.g.g_dynamic);
5697 void __kmp_env_initialize(
char const *
string) {
5699 kmp_env_blk_t block;
5705 if (
string == NULL) {
5707 __kmp_threads_capacity =
5708 __kmp_initial_threads_capacity(__kmp_dflt_team_nth_ub);
5710 __kmp_env_blk_init(&block,
string);
5713 for (i = 0; i < block.count; ++i) {
5714 if ((block.vars[i].name == NULL) || (*block.vars[i].name ==
'\0')) {
5717 if (block.vars[i].value == NULL) {
5720 kmp_setting_t *setting = __kmp_stg_find(block.vars[i].name);
5721 if (setting != NULL) {
5727 blocktime_str = __kmp_env_blk_var(&block,
"KMP_BLOCKTIME");
5731 if (
string == NULL) {
5732 char const *name =
"KMP_WARNINGS";
5733 char const *value = __kmp_env_blk_var(&block, name);
5734 __kmp_stg_parse(name, value);
5737 #if KMP_AFFINITY_SUPPORTED 5743 __kmp_affinity_notype = NULL;
5744 char const *aff_str = __kmp_env_blk_var(&block,
"KMP_AFFINITY");
5745 if (aff_str != NULL) {
5759 #define FIND strcasestr 5762 if ((FIND(aff_str,
"none") == NULL) &&
5763 (FIND(aff_str,
"physical") == NULL) &&
5764 (FIND(aff_str,
"logical") == NULL) &&
5765 (FIND(aff_str,
"compact") == NULL) &&
5766 (FIND(aff_str,
"scatter") == NULL) &&
5767 (FIND(aff_str,
"explicit") == NULL) &&
5768 (FIND(aff_str,
"balanced") == NULL) &&
5769 (FIND(aff_str,
"disabled") == NULL)) {
5770 __kmp_affinity_notype = __kmp_stg_find(
"KMP_AFFINITY");
5775 __kmp_affinity_type = affinity_default;
5776 __kmp_affinity_gran = KMP_HW_UNKNOWN;
5777 __kmp_affinity_top_method = affinity_top_method_default;
5778 __kmp_affinity_respect_mask = affinity_respect_mask_default;
5783 aff_str = __kmp_env_blk_var(&block,
"OMP_PROC_BIND");
5784 if (aff_str != NULL) {
5785 __kmp_affinity_type = affinity_default;
5786 __kmp_affinity_gran = KMP_HW_UNKNOWN;
5787 __kmp_affinity_top_method = affinity_top_method_default;
5788 __kmp_affinity_respect_mask = affinity_respect_mask_default;
5795 if (__kmp_nested_proc_bind.bind_types == NULL) {
5796 __kmp_nested_proc_bind.bind_types =
5797 (kmp_proc_bind_t *)KMP_INTERNAL_MALLOC(
sizeof(kmp_proc_bind_t));
5798 if (__kmp_nested_proc_bind.bind_types == NULL) {
5799 KMP_FATAL(MemoryAllocFailed);
5801 __kmp_nested_proc_bind.size = 1;
5802 __kmp_nested_proc_bind.used = 1;
5803 #if KMP_AFFINITY_SUPPORTED 5804 __kmp_nested_proc_bind.bind_types[0] = proc_bind_default;
5807 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
5814 __kmp_msg_format(kmp_i18n_msg_AffFormatDefault,
"%P",
"%i",
"%n",
"%A");
5815 KMP_DEBUG_ASSERT(KMP_STRLEN(m.str) < KMP_AFFINITY_FORMAT_SIZE);
5817 if (__kmp_affinity_format == NULL) {
5818 __kmp_affinity_format =
5819 (
char *)KMP_INTERNAL_MALLOC(
sizeof(
char) * KMP_AFFINITY_FORMAT_SIZE);
5821 KMP_STRCPY_S(__kmp_affinity_format, KMP_AFFINITY_FORMAT_SIZE, m.str);
5822 __kmp_str_free(&m.str);
5825 for (i = 0; i < block.count; ++i) {
5826 __kmp_stg_parse(block.vars[i].name, block.vars[i].value);
5830 if (!__kmp_init_user_locks) {
5831 if (__kmp_user_lock_kind == lk_default) {
5832 __kmp_user_lock_kind = lk_queuing;
5834 #if KMP_USE_DYNAMIC_LOCK 5835 __kmp_init_dynamic_user_locks();
5837 __kmp_set_user_lock_vptrs(__kmp_user_lock_kind);
5840 KMP_DEBUG_ASSERT(
string != NULL);
5841 KMP_DEBUG_ASSERT(__kmp_user_lock_kind != lk_default);
5846 #if KMP_USE_DYNAMIC_LOCK 5847 __kmp_init_dynamic_user_locks();
5849 __kmp_set_user_lock_vptrs(__kmp_user_lock_kind);
5853 #if KMP_AFFINITY_SUPPORTED 5855 if (!TCR_4(__kmp_init_middle)) {
5860 if (__kmp_hw_subset &&
5861 __kmp_affinity_top_method == affinity_top_method_default)
5862 if (__kmp_hw_subset->specified(KMP_HW_NUMA) ||
5863 __kmp_hw_subset->specified(KMP_HW_TILE) ||
5864 __kmp_affinity_gran == KMP_HW_TILE ||
5865 __kmp_affinity_gran == KMP_HW_NUMA)
5866 __kmp_affinity_top_method = affinity_top_method_hwloc;
5868 if (__kmp_affinity_gran == KMP_HW_NUMA ||
5869 __kmp_affinity_gran == KMP_HW_TILE)
5870 __kmp_affinity_top_method = affinity_top_method_hwloc;
5874 const char *var =
"KMP_AFFINITY";
5875 KMPAffinity::pick_api();
5880 if (__kmp_affinity_top_method == affinity_top_method_hwloc &&
5881 __kmp_affinity_dispatch->get_api_type() != KMPAffinity::HWLOC) {
5882 KMP_WARNING(AffIgnoringHwloc, var);
5883 __kmp_affinity_top_method = affinity_top_method_all;
5886 if (__kmp_affinity_type == affinity_disabled) {
5887 KMP_AFFINITY_DISABLE();
5888 }
else if (!KMP_AFFINITY_CAPABLE()) {
5889 __kmp_affinity_dispatch->determine_capable(var);
5890 if (!KMP_AFFINITY_CAPABLE()) {
5891 if (__kmp_affinity_verbose ||
5892 (__kmp_affinity_warnings &&
5893 (__kmp_affinity_type != affinity_default) &&
5894 (__kmp_affinity_type != affinity_none) &&
5895 (__kmp_affinity_type != affinity_disabled))) {
5896 KMP_WARNING(AffNotSupported, var);
5898 __kmp_affinity_type = affinity_disabled;
5899 __kmp_affinity_respect_mask = 0;
5900 __kmp_affinity_gran = KMP_HW_THREAD;
5904 if (__kmp_affinity_type == affinity_disabled) {
5905 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
5906 }
else if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_true) {
5908 __kmp_nested_proc_bind.bind_types[0] = proc_bind_spread;
5911 if (KMP_AFFINITY_CAPABLE()) {
5913 #if KMP_GROUP_AFFINITY 5918 bool exactly_one_group =
false;
5919 if (__kmp_num_proc_groups > 1) {
5921 bool within_one_group;
5924 kmp_affin_mask_t *init_mask;
5925 KMP_CPU_ALLOC(init_mask);
5926 __kmp_get_system_affinity(init_mask, TRUE);
5927 group = __kmp_get_proc_group(init_mask);
5928 within_one_group = (group >= 0);
5931 if (within_one_group) {
5932 DWORD num_bits_in_group = __kmp_GetActiveProcessorCount(group);
5933 DWORD num_bits_in_mask = 0;
5934 for (
int bit = init_mask->begin(); bit != init_mask->end();
5935 bit = init_mask->next(bit))
5937 exactly_one_group = (num_bits_in_group == num_bits_in_mask);
5939 KMP_CPU_FREE(init_mask);
5945 if (((__kmp_num_proc_groups > 1) &&
5946 (__kmp_affinity_type == affinity_default) &&
5947 (__kmp_nested_proc_bind.bind_types[0] == proc_bind_default)) ||
5948 (__kmp_affinity_top_method == affinity_top_method_group)) {
5949 if (__kmp_affinity_respect_mask == affinity_respect_mask_default &&
5950 exactly_one_group) {
5951 __kmp_affinity_respect_mask = FALSE;
5953 if (__kmp_affinity_type == affinity_default) {
5954 __kmp_affinity_type = affinity_compact;
5955 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
5957 if (__kmp_affinity_top_method == affinity_top_method_default) {
5958 if (__kmp_affinity_gran == KMP_HW_UNKNOWN) {
5959 __kmp_affinity_top_method = affinity_top_method_group;
5960 __kmp_affinity_gran = KMP_HW_PROC_GROUP;
5961 }
else if (__kmp_affinity_gran == KMP_HW_PROC_GROUP) {
5962 __kmp_affinity_top_method = affinity_top_method_group;
5964 __kmp_affinity_top_method = affinity_top_method_all;
5966 }
else if (__kmp_affinity_top_method == affinity_top_method_group) {
5967 if (__kmp_affinity_gran == KMP_HW_UNKNOWN) {
5968 __kmp_affinity_gran = KMP_HW_PROC_GROUP;
5969 }
else if ((__kmp_affinity_gran != KMP_HW_PROC_GROUP) &&
5970 (__kmp_affinity_gran != KMP_HW_THREAD)) {
5971 const char *str = __kmp_hw_get_keyword(__kmp_affinity_gran);
5972 KMP_WARNING(AffGranTopGroup, var, str);
5973 __kmp_affinity_gran = KMP_HW_THREAD;
5976 if (__kmp_affinity_gran == KMP_HW_UNKNOWN) {
5977 __kmp_affinity_gran = KMP_HW_CORE;
5978 }
else if (__kmp_affinity_gran == KMP_HW_PROC_GROUP) {
5979 const char *str = NULL;
5980 switch (__kmp_affinity_type) {
5981 case affinity_physical:
5984 case affinity_logical:
5987 case affinity_compact:
5990 case affinity_scatter:
5993 case affinity_explicit:
5998 KMP_DEBUG_ASSERT(0);
6000 KMP_WARNING(AffGranGroupType, var, str);
6001 __kmp_affinity_gran = KMP_HW_CORE;
6009 if (__kmp_affinity_respect_mask == affinity_respect_mask_default) {
6010 #if KMP_GROUP_AFFINITY 6011 if (__kmp_num_proc_groups > 1 && exactly_one_group) {
6012 __kmp_affinity_respect_mask = FALSE;
6016 __kmp_affinity_respect_mask = TRUE;
6019 if ((__kmp_nested_proc_bind.bind_types[0] != proc_bind_intel) &&
6020 (__kmp_nested_proc_bind.bind_types[0] != proc_bind_default)) {
6021 if (__kmp_affinity_type == affinity_default) {
6022 __kmp_affinity_type = affinity_compact;
6023 __kmp_affinity_dups = FALSE;
6025 }
else if (__kmp_affinity_type == affinity_default) {
6026 #if KMP_MIC_SUPPORTED 6027 if (__kmp_mic_type != non_mic) {
6028 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
6032 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
6034 #if KMP_MIC_SUPPORTED 6035 if (__kmp_mic_type != non_mic) {
6036 __kmp_affinity_type = affinity_scatter;
6040 __kmp_affinity_type = affinity_none;
6043 if ((__kmp_affinity_gran == KMP_HW_UNKNOWN) &&
6044 (__kmp_affinity_gran_levels < 0)) {
6045 #if KMP_MIC_SUPPORTED 6046 if (__kmp_mic_type != non_mic) {
6047 __kmp_affinity_gran = KMP_HW_THREAD;
6051 __kmp_affinity_gran = KMP_HW_CORE;
6054 if (__kmp_affinity_top_method == affinity_top_method_default) {
6055 __kmp_affinity_top_method = affinity_top_method_all;
6060 K_DIAG(1, (
"__kmp_affinity_type == %d\n", __kmp_affinity_type));
6061 K_DIAG(1, (
"__kmp_affinity_compact == %d\n", __kmp_affinity_compact));
6062 K_DIAG(1, (
"__kmp_affinity_offset == %d\n", __kmp_affinity_offset));
6063 K_DIAG(1, (
"__kmp_affinity_verbose == %d\n", __kmp_affinity_verbose));
6064 K_DIAG(1, (
"__kmp_affinity_warnings == %d\n", __kmp_affinity_warnings));
6065 K_DIAG(1, (
"__kmp_affinity_respect_mask == %d\n",
6066 __kmp_affinity_respect_mask));
6067 K_DIAG(1, (
"__kmp_affinity_gran == %d\n", __kmp_affinity_gran));
6069 KMP_DEBUG_ASSERT(__kmp_affinity_type != affinity_default);
6070 KMP_DEBUG_ASSERT(__kmp_nested_proc_bind.bind_types[0] != proc_bind_default);
6071 K_DIAG(1, (
"__kmp_nested_proc_bind.bind_types[0] == %d\n",
6072 __kmp_nested_proc_bind.bind_types[0]));
6077 if (__kmp_version) {
6078 __kmp_print_version_1();
6083 if (
string != NULL) {
6084 __kmp_aux_env_initialize(&block);
6087 __kmp_env_blk_free(&block);
6093 void __kmp_env_print() {
6095 kmp_env_blk_t block;
6097 kmp_str_buf_t buffer;
6100 __kmp_str_buf_init(&buffer);
6102 __kmp_env_blk_init(&block, NULL);
6103 __kmp_env_blk_sort(&block);
6106 __kmp_str_buf_print(&buffer,
"\n%s\n\n", KMP_I18N_STR(UserSettings));
6107 for (i = 0; i < block.count; ++i) {
6108 char const *name = block.vars[i].name;
6109 char const *value = block.vars[i].value;
6110 if ((KMP_STRLEN(name) > 4 && strncmp(name,
"KMP_", 4) == 0) ||
6111 strncmp(name,
"OMP_", 4) == 0
6112 #ifdef KMP_GOMP_COMPAT
6113 || strncmp(name,
"GOMP_", 5) == 0
6116 __kmp_str_buf_print(&buffer,
" %s=%s\n", name, value);
6119 __kmp_str_buf_print(&buffer,
"\n");
6122 __kmp_str_buf_print(&buffer,
"%s\n\n", KMP_I18N_STR(EffectiveSettings));
6123 for (
int i = 0; i < __kmp_stg_count; ++i) {
6124 if (__kmp_stg_table[i].print != NULL) {
6125 __kmp_stg_table[i].print(&buffer, __kmp_stg_table[i].name,
6126 __kmp_stg_table[i].data);
6130 __kmp_printf(
"%s", buffer.str);
6132 __kmp_env_blk_free(&block);
6133 __kmp_str_buf_free(&buffer);
6139 void __kmp_env_print_2() {
6140 __kmp_display_env_impl(__kmp_display_env, __kmp_display_env_verbose);
6143 void __kmp_display_env_impl(
int display_env,
int display_env_verbose) {
6144 kmp_env_blk_t block;
6145 kmp_str_buf_t buffer;
6147 __kmp_env_format = 1;
6150 __kmp_str_buf_init(&buffer);
6152 __kmp_env_blk_init(&block, NULL);
6153 __kmp_env_blk_sort(&block);
6155 __kmp_str_buf_print(&buffer,
"\n%s\n", KMP_I18N_STR(DisplayEnvBegin));
6156 __kmp_str_buf_print(&buffer,
" _OPENMP='%d'\n", __kmp_openmp_version);
6158 for (
int i = 0; i < __kmp_stg_count; ++i) {
6159 if (__kmp_stg_table[i].print != NULL &&
6160 ((display_env && strncmp(__kmp_stg_table[i].name,
"OMP_", 4) == 0) ||
6161 display_env_verbose)) {
6162 __kmp_stg_table[i].print(&buffer, __kmp_stg_table[i].name,
6163 __kmp_stg_table[i].data);
6167 __kmp_str_buf_print(&buffer,
"%s\n", KMP_I18N_STR(DisplayEnvEnd));
6168 __kmp_str_buf_print(&buffer,
"\n");
6170 __kmp_printf(
"%s", buffer.str);
6172 __kmp_env_blk_free(&block);
6173 __kmp_str_buf_free(&buffer);
6180 void __kmp_env_dump() {
6182 kmp_env_blk_t block;
6183 kmp_str_buf_t buffer, env, notdefined;
6186 __kmp_str_buf_init(&buffer);
6187 __kmp_str_buf_init(&env);
6188 __kmp_str_buf_init(¬defined);
6190 __kmp_env_blk_init(&block, NULL);
6191 __kmp_env_blk_sort(&block);
6193 __kmp_str_buf_print(¬defined,
": %s", KMP_I18N_STR(NotDefined));
6195 for (
int i = 0; i < __kmp_stg_count; ++i) {
6196 if (__kmp_stg_table[i].print == NULL)
6198 __kmp_str_buf_clear(&env);
6199 __kmp_stg_table[i].print(&env, __kmp_stg_table[i].name,
6200 __kmp_stg_table[i].data);
6203 if (strstr(env.str, notdefined.str))
6205 __kmp_str_buf_print(&buffer,
"%s=undefined\n", __kmp_stg_table[i].name);
6207 __kmp_str_buf_cat(&buffer, env.str + 3, env.used - 3);
6210 ompd_env_block = (
char *)__kmp_allocate(buffer.used + 1);
6211 KMP_MEMCPY(ompd_env_block, buffer.str, buffer.used + 1);
6212 ompd_env_block_size = (ompd_size_t)KMP_STRLEN(ompd_env_block);
6214 __kmp_env_blk_free(&block);
6215 __kmp_str_buf_free(&buffer);
6216 __kmp_str_buf_free(&env);
6217 __kmp_str_buf_free(¬defined);
6219 #endif // OMPD_SUPPORT