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 #if KMP_OS_WINDOWS && KMP_MSVC_COMPAT
169 nvalues = KMP_SSCANF(data,
"%lf%c%c", &value, &mult, 1, &extra, 1);
171 nvalues = KMP_SSCANF(data,
"%lf%c%c", &value, &mult, &extra);
198 factor = 1000 * 60 * 60;
202 factor = 1000 * 24 * 60 * 60;
208 if (value >= ((INT_MAX - 1) / factor))
211 ret = (int)(value * (
double)factor);
216 static int __kmp_strcasecmp_with_sentinel(
char const *a,
char const *b,
222 while (*a && *b && *b != sentinel) {
223 char ca = *a, cb = *b;
225 if (ca >=
'a' && ca <=
'z')
227 if (cb >=
'a' && cb <=
'z')
230 return (
int)(
unsigned char)*a - (
int)(
unsigned char)*b;
234 return *a ? (*b && *b != sentinel)
235 ? (
int)(
unsigned char)*a - (
int)(
unsigned char)*b
237 : (*b && *b != sentinel) ? -1
244 typedef struct __kmp_setting kmp_setting_t;
245 typedef struct __kmp_stg_ss_data kmp_stg_ss_data_t;
246 typedef struct __kmp_stg_wp_data kmp_stg_wp_data_t;
247 typedef struct __kmp_stg_fr_data kmp_stg_fr_data_t;
249 typedef void (*kmp_stg_parse_func_t)(
char const *name,
char const *value,
251 typedef void (*kmp_stg_print_func_t)(kmp_str_buf_t *buffer,
char const *name,
254 struct __kmp_setting {
256 kmp_stg_parse_func_t parse;
257 kmp_stg_print_func_t print;
264 struct __kmp_stg_ss_data {
266 kmp_setting_t **rivals;
269 struct __kmp_stg_wp_data {
271 kmp_setting_t **rivals;
274 struct __kmp_stg_fr_data {
276 kmp_setting_t **rivals;
279 static int __kmp_stg_check_rivals(
282 kmp_setting_t **rivals
288 static void __kmp_stg_parse_bool(
char const *name,
char const *value,
290 if (__kmp_str_match_true(value)) {
292 }
else if (__kmp_str_match_false(value)) {
295 __kmp_msg(kmp_ms_warning, KMP_MSG(BadBoolValue, name, value),
296 KMP_HNT(ValidBoolValues), __kmp_msg_null);
301 void __kmp_check_stksize(
size_t *val) {
303 if (*val > KMP_DEFAULT_STKSIZE * 16)
304 *val = KMP_DEFAULT_STKSIZE * 16;
305 if (*val < __kmp_sys_min_stksize)
306 *val = __kmp_sys_min_stksize;
307 if (*val > KMP_MAX_STKSIZE)
308 *val = KMP_MAX_STKSIZE;
310 *val = __kmp_round4k(*val);
314 static void __kmp_stg_parse_size(
char const *name,
char const *value,
315 size_t size_min,
size_t size_max,
316 int *is_specified,
size_t *out,
318 char const *msg = NULL;
320 size_min = __kmp_round4k(size_min);
321 size_max = __kmp_round4k(size_max);
324 if (is_specified != NULL) {
327 __kmp_str_to_size(value, out, factor, &msg);
329 if (*out > size_max) {
331 msg = KMP_I18N_STR(ValueTooLarge);
332 }
else if (*out < size_min) {
334 msg = KMP_I18N_STR(ValueTooSmall);
337 size_t round4k = __kmp_round4k(*out);
338 if (*out != round4k) {
340 msg = KMP_I18N_STR(NotMultiple4K);
347 if (*out < size_min) {
349 }
else if (*out > size_max) {
356 __kmp_str_buf_init(&buf);
357 __kmp_str_buf_print_size(&buf, *out);
358 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
359 KMP_INFORM(Using_str_Value, name, buf.str);
360 __kmp_str_buf_free(&buf);
365 static void __kmp_stg_parse_str(
char const *name,
char const *value,
368 *out = __kmp_str_format(
"%s", value);
371 static void __kmp_stg_parse_int(
379 char const *msg = NULL;
380 kmp_uint64 uint = *out;
381 __kmp_str_to_uint(value, &uint, &msg);
383 if (uint < (
unsigned int)min) {
384 msg = KMP_I18N_STR(ValueTooSmall);
386 }
else if (uint > (
unsigned int)max) {
387 msg = KMP_I18N_STR(ValueTooLarge);
393 if (uint < (
unsigned int)min) {
395 }
else if (uint > (
unsigned int)max) {
402 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
403 __kmp_str_buf_init(&buf);
404 __kmp_str_buf_print(&buf,
"%" KMP_UINT64_SPEC
"", uint);
405 KMP_INFORM(Using_uint64_Value, name, buf.str);
406 __kmp_str_buf_free(&buf);
408 __kmp_type_convert(uint, out);
411 #if KMP_DEBUG_ADAPTIVE_LOCKS
412 static void __kmp_stg_parse_file(
char const *name,
char const *value,
413 const char *suffix,
char **out) {
418 t = (
char *)strrchr(value,
'.');
419 hasSuffix = t && __kmp_str_eqf(t, suffix);
420 t = __kmp_str_format(
"%s%s", value, hasSuffix ?
"" : suffix);
421 __kmp_expand_file_name(buffer,
sizeof(buffer), t);
423 *out = __kmp_str_format(
"%s", buffer);
428 static char *par_range_to_print = NULL;
430 static void __kmp_stg_parse_par_range(
char const *name,
char const *value,
431 int *out_range,
char *out_routine,
432 char *out_file,
int *out_lb,
434 const char *par_range_value;
435 size_t len = KMP_STRLEN(value) + 1;
436 par_range_to_print = (
char *)KMP_INTERNAL_MALLOC(len + 1);
437 KMP_STRNCPY_S(par_range_to_print, len + 1, value, len + 1);
438 __kmp_par_range = +1;
439 __kmp_par_range_lb = 0;
440 __kmp_par_range_ub = INT_MAX;
443 if (!value || *value ==
'\0') {
446 if (!__kmp_strcasecmp_with_sentinel(
"routine", value,
'=')) {
447 par_range_value = strchr(value,
'=') + 1;
448 if (!par_range_value)
449 goto par_range_error;
450 value = par_range_value;
451 len = __kmp_readstr_with_sentinel(out_routine, value,
452 KMP_PAR_RANGE_ROUTINE_LEN - 1,
',');
454 goto par_range_error;
456 value = strchr(value,
',');
462 if (!__kmp_strcasecmp_with_sentinel(
"filename", value,
'=')) {
463 par_range_value = strchr(value,
'=') + 1;
464 if (!par_range_value)
465 goto par_range_error;
466 value = par_range_value;
467 len = __kmp_readstr_with_sentinel(out_file, value,
468 KMP_PAR_RANGE_FILENAME_LEN - 1,
',');
470 goto par_range_error;
472 value = strchr(value,
',');
478 if ((!__kmp_strcasecmp_with_sentinel(
"range", value,
'=')) ||
479 (!__kmp_strcasecmp_with_sentinel(
"incl_range", value,
'='))) {
480 par_range_value = strchr(value,
'=') + 1;
481 if (!par_range_value)
482 goto par_range_error;
483 value = par_range_value;
484 if (KMP_SSCANF(value,
"%d:%d", out_lb, out_ub) != 2) {
485 goto par_range_error;
488 value = strchr(value,
',');
494 if (!__kmp_strcasecmp_with_sentinel(
"excl_range", value,
'=')) {
495 par_range_value = strchr(value,
'=') + 1;
496 if (!par_range_value)
497 goto par_range_error;
498 value = par_range_value;
499 if (KMP_SSCANF(value,
"%d:%d", out_lb, out_ub) != 2) {
500 goto par_range_error;
503 value = strchr(value,
',');
510 KMP_WARNING(ParRangeSyntax, name);
517 int __kmp_initial_threads_capacity(
int req_nproc) {
522 if (nth < (4 * req_nproc))
523 nth = (4 * req_nproc);
524 if (nth < (4 * __kmp_xproc))
525 nth = (4 * __kmp_xproc);
529 if (__kmp_enable_hidden_helper) {
530 nth += __kmp_hidden_helper_threads_num;
533 if (nth > __kmp_max_nth)
539 int __kmp_default_tp_capacity(
int req_nproc,
int max_nth,
540 int all_threads_specified) {
543 if (all_threads_specified)
547 if (nth < (4 * req_nproc))
548 nth = (4 * req_nproc);
549 if (nth < (4 * __kmp_xproc))
550 nth = (4 * __kmp_xproc);
552 if (nth > __kmp_max_nth)
561 static void __kmp_stg_print_bool(kmp_str_buf_t *buffer,
char const *name,
563 if (__kmp_env_format) {
564 KMP_STR_BUF_PRINT_BOOL;
566 __kmp_str_buf_print(buffer,
" %s=%s\n", name, value ?
"true" :
"false");
570 static void __kmp_stg_print_int(kmp_str_buf_t *buffer,
char const *name,
572 if (__kmp_env_format) {
573 KMP_STR_BUF_PRINT_INT;
575 __kmp_str_buf_print(buffer,
" %s=%d\n", name, value);
579 static void __kmp_stg_print_uint64(kmp_str_buf_t *buffer,
char const *name,
581 if (__kmp_env_format) {
582 KMP_STR_BUF_PRINT_UINT64;
584 __kmp_str_buf_print(buffer,
" %s=%" KMP_UINT64_SPEC
"\n", name, value);
588 static void __kmp_stg_print_str(kmp_str_buf_t *buffer,
char const *name,
590 if (__kmp_env_format) {
591 KMP_STR_BUF_PRINT_STR;
593 __kmp_str_buf_print(buffer,
" %s=%s\n", name, value);
597 static void __kmp_stg_print_size(kmp_str_buf_t *buffer,
char const *name,
599 if (__kmp_env_format) {
600 KMP_STR_BUF_PRINT_NAME_EX(name);
601 __kmp_str_buf_print_size(buffer, value);
602 __kmp_str_buf_print(buffer,
"'\n");
604 __kmp_str_buf_print(buffer,
" %s=", name);
605 __kmp_str_buf_print_size(buffer, value);
606 __kmp_str_buf_print(buffer,
"\n");
617 static void __kmp_stg_parse_device_thread_limit(
char const *name,
618 char const *value,
void *data) {
619 kmp_setting_t **rivals = (kmp_setting_t **)data;
621 if (strcmp(name,
"KMP_ALL_THREADS") == 0) {
622 KMP_INFORM(EnvVarDeprecated, name,
"KMP_DEVICE_THREAD_LIMIT");
624 rc = __kmp_stg_check_rivals(name, value, rivals);
628 if (!__kmp_strcasecmp_with_sentinel(
"all", value, 0)) {
629 __kmp_max_nth = __kmp_xproc;
630 __kmp_allThreadsSpecified = 1;
632 __kmp_stg_parse_int(name, value, 1, __kmp_sys_max_nth, &__kmp_max_nth);
633 __kmp_allThreadsSpecified = 0;
635 K_DIAG(1, (
"__kmp_max_nth == %d\n", __kmp_max_nth));
639 static void __kmp_stg_print_device_thread_limit(kmp_str_buf_t *buffer,
640 char const *name,
void *data) {
641 __kmp_stg_print_int(buffer, name, __kmp_max_nth);
646 static void __kmp_stg_parse_thread_limit(
char const *name,
char const *value,
648 __kmp_stg_parse_int(name, value, 1, __kmp_sys_max_nth, &__kmp_cg_max_nth);
649 K_DIAG(1, (
"__kmp_cg_max_nth == %d\n", __kmp_cg_max_nth));
653 static void __kmp_stg_print_thread_limit(kmp_str_buf_t *buffer,
654 char const *name,
void *data) {
655 __kmp_stg_print_int(buffer, name, __kmp_cg_max_nth);
660 static void __kmp_stg_parse_nteams(
char const *name,
char const *value,
662 __kmp_stg_parse_int(name, value, 1, __kmp_sys_max_nth, &__kmp_nteams);
663 K_DIAG(1, (
"__kmp_nteams == %d\n", __kmp_nteams));
666 static void __kmp_stg_print_nteams(kmp_str_buf_t *buffer,
char const *name,
668 __kmp_stg_print_int(buffer, name, __kmp_nteams);
673 static void __kmp_stg_parse_teams_th_limit(
char const *name,
char const *value,
675 __kmp_stg_parse_int(name, value, 1, __kmp_sys_max_nth,
676 &__kmp_teams_thread_limit);
677 K_DIAG(1, (
"__kmp_teams_thread_limit == %d\n", __kmp_teams_thread_limit));
680 static void __kmp_stg_print_teams_th_limit(kmp_str_buf_t *buffer,
681 char const *name,
void *data) {
682 __kmp_stg_print_int(buffer, name, __kmp_teams_thread_limit);
687 static void __kmp_stg_parse_teams_thread_limit(
char const *name,
688 char const *value,
void *data) {
689 __kmp_stg_parse_int(name, value, 1, __kmp_sys_max_nth, &__kmp_teams_max_nth);
692 static void __kmp_stg_print_teams_thread_limit(kmp_str_buf_t *buffer,
693 char const *name,
void *data) {
694 __kmp_stg_print_int(buffer, name, __kmp_teams_max_nth);
699 static void __kmp_stg_parse_use_yield(
char const *name,
char const *value,
701 __kmp_stg_parse_int(name, value, 0, 2, &__kmp_use_yield);
702 __kmp_use_yield_exp_set = 1;
705 static void __kmp_stg_print_use_yield(kmp_str_buf_t *buffer,
char const *name,
707 __kmp_stg_print_int(buffer, name, __kmp_use_yield);
713 static void __kmp_stg_parse_blocktime(
char const *name,
char const *value,
715 __kmp_dflt_blocktime = __kmp_convert_to_milliseconds(value);
716 if (__kmp_dflt_blocktime < 0) {
717 __kmp_dflt_blocktime = KMP_DEFAULT_BLOCKTIME;
718 __kmp_msg(kmp_ms_warning, KMP_MSG(InvalidValue, name, value),
720 KMP_INFORM(Using_int_Value, name, __kmp_dflt_blocktime);
721 __kmp_env_blocktime = FALSE;
723 if (__kmp_dflt_blocktime < KMP_MIN_BLOCKTIME) {
724 __kmp_dflt_blocktime = KMP_MIN_BLOCKTIME;
725 __kmp_msg(kmp_ms_warning, KMP_MSG(SmallValue, name, value),
727 KMP_INFORM(MinValueUsing, name, __kmp_dflt_blocktime);
728 }
else if (__kmp_dflt_blocktime > KMP_MAX_BLOCKTIME) {
729 __kmp_dflt_blocktime = KMP_MAX_BLOCKTIME;
730 __kmp_msg(kmp_ms_warning, KMP_MSG(LargeValue, name, value),
732 KMP_INFORM(MaxValueUsing, name, __kmp_dflt_blocktime);
734 __kmp_env_blocktime = TRUE;
739 __kmp_monitor_wakeups =
740 KMP_WAKEUPS_FROM_BLOCKTIME(__kmp_dflt_blocktime, __kmp_monitor_wakeups);
742 KMP_INTERVALS_FROM_BLOCKTIME(__kmp_dflt_blocktime, __kmp_monitor_wakeups);
744 K_DIAG(1, (
"__kmp_env_blocktime == %d\n", __kmp_env_blocktime));
745 if (__kmp_env_blocktime) {
746 K_DIAG(1, (
"__kmp_dflt_blocktime == %d\n", __kmp_dflt_blocktime));
750 static void __kmp_stg_print_blocktime(kmp_str_buf_t *buffer,
char const *name,
752 __kmp_stg_print_int(buffer, name, __kmp_dflt_blocktime);
758 static void __kmp_stg_parse_duplicate_lib_ok(
char const *name,
759 char const *value,
void *data) {
762 __kmp_stg_parse_bool(name, value, &__kmp_duplicate_library_ok);
765 static void __kmp_stg_print_duplicate_lib_ok(kmp_str_buf_t *buffer,
766 char const *name,
void *data) {
767 __kmp_stg_print_bool(buffer, name, __kmp_duplicate_library_ok);
773 #if KMP_ARCH_X86 || KMP_ARCH_X86_64
775 static void __kmp_stg_parse_inherit_fp_control(
char const *name,
776 char const *value,
void *data) {
777 __kmp_stg_parse_bool(name, value, &__kmp_inherit_fp_control);
780 static void __kmp_stg_print_inherit_fp_control(kmp_str_buf_t *buffer,
781 char const *name,
void *data) {
783 __kmp_stg_print_bool(buffer, name, __kmp_inherit_fp_control);
790 static char const *blocktime_str = NULL;
795 static void __kmp_stg_parse_wait_policy(
char const *name,
char const *value,
798 kmp_stg_wp_data_t *wait = (kmp_stg_wp_data_t *)data;
801 rc = __kmp_stg_check_rivals(name, value, wait->rivals);
807 if (__kmp_str_match(
"ACTIVE", 1, value)) {
808 __kmp_library = library_turnaround;
809 if (blocktime_str == NULL) {
811 __kmp_dflt_blocktime = KMP_MAX_BLOCKTIME;
813 }
else if (__kmp_str_match(
"PASSIVE", 1, value)) {
814 __kmp_library = library_throughput;
815 if (blocktime_str == NULL) {
817 __kmp_dflt_blocktime = 0;
820 KMP_WARNING(StgInvalidValue, name, value);
823 if (__kmp_str_match(
"serial", 1, value)) {
824 __kmp_library = library_serial;
825 }
else if (__kmp_str_match(
"throughput", 2, value)) {
826 __kmp_library = library_throughput;
827 if (blocktime_str == NULL) {
829 __kmp_dflt_blocktime = 0;
831 }
else if (__kmp_str_match(
"turnaround", 2, value)) {
832 __kmp_library = library_turnaround;
833 }
else if (__kmp_str_match(
"dedicated", 1, value)) {
834 __kmp_library = library_turnaround;
835 }
else if (__kmp_str_match(
"multiuser", 1, value)) {
836 __kmp_library = library_throughput;
837 if (blocktime_str == NULL) {
839 __kmp_dflt_blocktime = 0;
842 KMP_WARNING(StgInvalidValue, name, value);
847 static void __kmp_stg_print_wait_policy(kmp_str_buf_t *buffer,
char const *name,
850 kmp_stg_wp_data_t *wait = (kmp_stg_wp_data_t *)data;
851 char const *value = NULL;
854 switch (__kmp_library) {
855 case library_turnaround: {
858 case library_throughput: {
863 switch (__kmp_library) {
864 case library_serial: {
867 case library_turnaround: {
868 value =
"turnaround";
870 case library_throughput: {
871 value =
"throughput";
876 __kmp_stg_print_str(buffer, name, value);
885 static void __kmp_stg_parse_monitor_stacksize(
char const *name,
886 char const *value,
void *data) {
887 __kmp_stg_parse_size(name, value, __kmp_sys_min_stksize, KMP_MAX_STKSIZE,
888 NULL, &__kmp_monitor_stksize, 1);
891 static void __kmp_stg_print_monitor_stacksize(kmp_str_buf_t *buffer,
892 char const *name,
void *data) {
893 if (__kmp_env_format) {
894 if (__kmp_monitor_stksize > 0)
895 KMP_STR_BUF_PRINT_NAME_EX(name);
897 KMP_STR_BUF_PRINT_NAME;
899 __kmp_str_buf_print(buffer,
" %s", name);
901 if (__kmp_monitor_stksize > 0) {
902 __kmp_str_buf_print_size(buffer, __kmp_monitor_stksize);
904 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
906 if (__kmp_env_format && __kmp_monitor_stksize) {
907 __kmp_str_buf_print(buffer,
"'\n");
915 static void __kmp_stg_parse_settings(
char const *name,
char const *value,
917 __kmp_stg_parse_bool(name, value, &__kmp_settings);
920 static void __kmp_stg_print_settings(kmp_str_buf_t *buffer,
char const *name,
922 __kmp_stg_print_bool(buffer, name, __kmp_settings);
928 static void __kmp_stg_parse_stackpad(
char const *name,
char const *value,
930 __kmp_stg_parse_int(name,
938 static void __kmp_stg_print_stackpad(kmp_str_buf_t *buffer,
char const *name,
940 __kmp_stg_print_int(buffer, name, __kmp_stkpadding);
946 static void __kmp_stg_parse_stackoffset(
char const *name,
char const *value,
948 __kmp_stg_parse_size(name,
957 static void __kmp_stg_print_stackoffset(kmp_str_buf_t *buffer,
char const *name,
959 __kmp_stg_print_size(buffer, name, __kmp_stkoffset);
965 static void __kmp_stg_parse_stacksize(
char const *name,
char const *value,
968 kmp_stg_ss_data_t *stacksize = (kmp_stg_ss_data_t *)data;
971 rc = __kmp_stg_check_rivals(name, value, stacksize->rivals);
975 __kmp_stg_parse_size(name,
977 __kmp_sys_min_stksize,
989 static void __kmp_stg_print_stacksize(kmp_str_buf_t *buffer,
char const *name,
991 kmp_stg_ss_data_t *stacksize = (kmp_stg_ss_data_t *)data;
992 if (__kmp_env_format) {
993 KMP_STR_BUF_PRINT_NAME_EX(name);
994 __kmp_str_buf_print_size(buffer, (__kmp_stksize % 1024)
995 ? __kmp_stksize / stacksize->factor
997 __kmp_str_buf_print(buffer,
"'\n");
999 __kmp_str_buf_print(buffer,
" %s=", name);
1000 __kmp_str_buf_print_size(buffer, (__kmp_stksize % 1024)
1001 ? __kmp_stksize / stacksize->factor
1003 __kmp_str_buf_print(buffer,
"\n");
1010 static void __kmp_stg_parse_version(
char const *name,
char const *value,
1012 __kmp_stg_parse_bool(name, value, &__kmp_version);
1015 static void __kmp_stg_print_version(kmp_str_buf_t *buffer,
char const *name,
1017 __kmp_stg_print_bool(buffer, name, __kmp_version);
1023 static void __kmp_stg_parse_warnings(
char const *name,
char const *value,
1025 __kmp_stg_parse_bool(name, value, &__kmp_generate_warnings);
1026 if (__kmp_generate_warnings != kmp_warnings_off) {
1029 __kmp_generate_warnings = kmp_warnings_explicit;
1033 static void __kmp_stg_print_warnings(kmp_str_buf_t *buffer,
char const *name,
1036 __kmp_stg_print_bool(buffer, name, __kmp_generate_warnings);
1042 static void __kmp_stg_parse_nesting_mode(
char const *name,
char const *value,
1044 __kmp_stg_parse_int(name, value, 0, INT_MAX, &__kmp_nesting_mode);
1045 #if KMP_AFFINITY_SUPPORTED && KMP_USE_HWLOC
1046 if (__kmp_nesting_mode > 0)
1047 __kmp_affinity_top_method = affinity_top_method_hwloc;
1051 static void __kmp_stg_print_nesting_mode(kmp_str_buf_t *buffer,
1052 char const *name,
void *data) {
1053 if (__kmp_env_format) {
1054 KMP_STR_BUF_PRINT_NAME;
1056 __kmp_str_buf_print(buffer,
" %s", name);
1058 __kmp_str_buf_print(buffer,
"=%d\n", __kmp_nesting_mode);
1064 static void __kmp_stg_parse_nested(
char const *name,
char const *value,
1067 KMP_INFORM(EnvVarDeprecated, name,
"OMP_MAX_ACTIVE_LEVELS");
1068 __kmp_stg_parse_bool(name, value, &nested);
1070 if (!__kmp_dflt_max_active_levels_set)
1071 __kmp_dflt_max_active_levels = KMP_MAX_ACTIVE_LEVELS_LIMIT;
1073 __kmp_dflt_max_active_levels = 1;
1074 __kmp_dflt_max_active_levels_set =
true;
1078 static void __kmp_stg_print_nested(kmp_str_buf_t *buffer,
char const *name,
1080 if (__kmp_env_format) {
1081 KMP_STR_BUF_PRINT_NAME;
1083 __kmp_str_buf_print(buffer,
" %s", name);
1085 __kmp_str_buf_print(buffer,
": deprecated; max-active-levels-var=%d\n",
1086 __kmp_dflt_max_active_levels);
1089 static void __kmp_parse_nested_num_threads(
const char *var,
const char *env,
1090 kmp_nested_nthreads_t *nth_array) {
1091 const char *next = env;
1092 const char *scan = next;
1095 int prev_comma = FALSE;
1101 if (*next ==
'\0') {
1105 if (((*next <
'0') || (*next >
'9')) && (*next !=
',')) {
1106 KMP_WARNING(NthSyntaxError, var, env);
1112 if (total == 0 || prev_comma) {
1120 if (*next >=
'0' && *next <=
'9') {
1124 const char *tmp = next;
1126 if ((*next ==
' ' || *next ==
'\t') && (*tmp >=
'0' && *tmp <=
'9')) {
1127 KMP_WARNING(NthSpacesNotAllowed, var, env);
1132 if (!__kmp_dflt_max_active_levels_set && total > 1)
1133 __kmp_dflt_max_active_levels = KMP_MAX_ACTIVE_LEVELS_LIMIT;
1134 KMP_DEBUG_ASSERT(total > 0);
1136 KMP_WARNING(NthSyntaxError, var, env);
1141 if (!nth_array->nth) {
1143 nth_array->nth = (
int *)KMP_INTERNAL_MALLOC(
sizeof(
int) * total * 2);
1144 if (nth_array->nth == NULL) {
1145 KMP_FATAL(MemoryAllocFailed);
1147 nth_array->size = total * 2;
1149 if (nth_array->size < total) {
1152 nth_array->size *= 2;
1153 }
while (nth_array->size < total);
1155 nth_array->nth = (
int *)KMP_INTERNAL_REALLOC(
1156 nth_array->nth,
sizeof(
int) * nth_array->size);
1157 if (nth_array->nth == NULL) {
1158 KMP_FATAL(MemoryAllocFailed);
1162 nth_array->used = total;
1170 if (*scan ==
'\0') {
1180 nth_array->nth[i++] = 0;
1182 }
else if (prev_comma) {
1184 nth_array->nth[i] = nth_array->nth[i - 1];
1193 if (*scan >=
'0' && *scan <=
'9') {
1195 const char *buf = scan;
1196 char const *msg = NULL;
1201 num = __kmp_str_to_int(buf, *scan);
1202 if (num < KMP_MIN_NTH) {
1203 msg = KMP_I18N_STR(ValueTooSmall);
1205 }
else if (num > __kmp_sys_max_nth) {
1206 msg = KMP_I18N_STR(ValueTooLarge);
1207 num = __kmp_sys_max_nth;
1211 KMP_WARNING(ParseSizeIntWarn, var, env, msg);
1212 KMP_INFORM(Using_int_Value, var, num);
1214 nth_array->nth[i++] = num;
1219 static void __kmp_stg_parse_num_threads(
char const *name,
char const *value,
1222 if (!__kmp_strcasecmp_with_sentinel(
"all", value, 0)) {
1224 __kmp_nested_nth.nth = (
int *)KMP_INTERNAL_MALLOC(
sizeof(
int));
1225 __kmp_nested_nth.size = __kmp_nested_nth.used = 1;
1226 __kmp_nested_nth.nth[0] = __kmp_dflt_team_nth = __kmp_dflt_team_nth_ub =
1229 __kmp_parse_nested_num_threads(name, value, &__kmp_nested_nth);
1230 if (__kmp_nested_nth.nth) {
1231 __kmp_dflt_team_nth = __kmp_nested_nth.nth[0];
1232 if (__kmp_dflt_team_nth_ub < __kmp_dflt_team_nth) {
1233 __kmp_dflt_team_nth_ub = __kmp_dflt_team_nth;
1237 K_DIAG(1, (
"__kmp_dflt_team_nth == %d\n", __kmp_dflt_team_nth));
1240 static void __kmp_stg_parse_num_hidden_helper_threads(
char const *name,
1243 __kmp_stg_parse_int(name, value, 0, 16, &__kmp_hidden_helper_threads_num);
1246 if (__kmp_hidden_helper_threads_num == 0) {
1247 __kmp_enable_hidden_helper = FALSE;
1252 __kmp_hidden_helper_threads_num++;
1256 static void __kmp_stg_print_num_hidden_helper_threads(kmp_str_buf_t *buffer,
1259 if (__kmp_hidden_helper_threads_num == 0) {
1260 __kmp_stg_print_int(buffer, name, __kmp_hidden_helper_threads_num);
1262 KMP_DEBUG_ASSERT(__kmp_hidden_helper_threads_num > 1);
1265 __kmp_stg_print_int(buffer, name, __kmp_hidden_helper_threads_num - 1);
1269 static void __kmp_stg_parse_use_hidden_helper(
char const *name,
1270 char const *value,
void *data) {
1271 __kmp_stg_parse_bool(name, value, &__kmp_enable_hidden_helper);
1273 __kmp_enable_hidden_helper = FALSE;
1275 (
"__kmp_stg_parse_use_hidden_helper: Disable hidden helper task on "
1276 "non-Linux platform although it is enabled by user explicitly.\n"));
1280 static void __kmp_stg_print_use_hidden_helper(kmp_str_buf_t *buffer,
1281 char const *name,
void *data) {
1282 __kmp_stg_print_bool(buffer, name, __kmp_enable_hidden_helper);
1285 static void __kmp_stg_print_num_threads(kmp_str_buf_t *buffer,
char const *name,
1287 if (__kmp_env_format) {
1288 KMP_STR_BUF_PRINT_NAME;
1290 __kmp_str_buf_print(buffer,
" %s", name);
1292 if (__kmp_nested_nth.used) {
1294 __kmp_str_buf_init(&buf);
1295 for (
int i = 0; i < __kmp_nested_nth.used; i++) {
1296 __kmp_str_buf_print(&buf,
"%d", __kmp_nested_nth.nth[i]);
1297 if (i < __kmp_nested_nth.used - 1) {
1298 __kmp_str_buf_print(&buf,
",");
1301 __kmp_str_buf_print(buffer,
"='%s'\n", buf.str);
1302 __kmp_str_buf_free(&buf);
1304 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
1311 static void __kmp_stg_parse_tasking(
char const *name,
char const *value,
1313 __kmp_stg_parse_int(name, value, 0, (
int)tskm_max,
1314 (
int *)&__kmp_tasking_mode);
1317 static void __kmp_stg_print_tasking(kmp_str_buf_t *buffer,
char const *name,
1319 __kmp_stg_print_int(buffer, name, __kmp_tasking_mode);
1322 static void __kmp_stg_parse_task_stealing(
char const *name,
char const *value,
1324 __kmp_stg_parse_int(name, value, 0, 1,
1325 (
int *)&__kmp_task_stealing_constraint);
1328 static void __kmp_stg_print_task_stealing(kmp_str_buf_t *buffer,
1329 char const *name,
void *data) {
1330 __kmp_stg_print_int(buffer, name, __kmp_task_stealing_constraint);
1333 static void __kmp_stg_parse_max_active_levels(
char const *name,
1334 char const *value,
void *data) {
1335 kmp_uint64 tmp_dflt = 0;
1336 char const *msg = NULL;
1337 if (!__kmp_dflt_max_active_levels_set) {
1339 __kmp_str_to_uint(value, &tmp_dflt, &msg);
1341 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
1342 }
else if (tmp_dflt > KMP_MAX_ACTIVE_LEVELS_LIMIT) {
1344 msg = KMP_I18N_STR(ValueTooLarge);
1345 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
1347 __kmp_type_convert(tmp_dflt, &(__kmp_dflt_max_active_levels));
1348 __kmp_dflt_max_active_levels_set =
true;
1353 static void __kmp_stg_print_max_active_levels(kmp_str_buf_t *buffer,
1354 char const *name,
void *data) {
1355 __kmp_stg_print_int(buffer, name, __kmp_dflt_max_active_levels);
1360 static void __kmp_stg_parse_default_device(
char const *name,
char const *value,
1362 __kmp_stg_parse_int(name, value, 0, KMP_MAX_DEFAULT_DEVICE_LIMIT,
1363 &__kmp_default_device);
1366 static void __kmp_stg_print_default_device(kmp_str_buf_t *buffer,
1367 char const *name,
void *data) {
1368 __kmp_stg_print_int(buffer, name, __kmp_default_device);
1373 static void __kmp_stg_parse_target_offload(
char const *name,
char const *value,
1375 const char *next = value;
1376 const char *scan = next;
1378 __kmp_target_offload = tgt_default;
1383 if (!__kmp_strcasecmp_with_sentinel(
"mandatory", scan, 0)) {
1384 __kmp_target_offload = tgt_mandatory;
1385 }
else if (!__kmp_strcasecmp_with_sentinel(
"disabled", scan, 0)) {
1386 __kmp_target_offload = tgt_disabled;
1387 }
else if (!__kmp_strcasecmp_with_sentinel(
"default", scan, 0)) {
1388 __kmp_target_offload = tgt_default;
1390 KMP_WARNING(SyntaxErrorUsing, name,
"DEFAULT");
1395 static void __kmp_stg_print_target_offload(kmp_str_buf_t *buffer,
1396 char const *name,
void *data) {
1397 const char *value = NULL;
1398 if (__kmp_target_offload == tgt_default)
1400 else if (__kmp_target_offload == tgt_mandatory)
1401 value =
"MANDATORY";
1402 else if (__kmp_target_offload == tgt_disabled)
1404 KMP_DEBUG_ASSERT(value);
1405 if (__kmp_env_format) {
1406 KMP_STR_BUF_PRINT_NAME;
1408 __kmp_str_buf_print(buffer,
" %s", name);
1410 __kmp_str_buf_print(buffer,
"=%s\n", value);
1415 static void __kmp_stg_parse_max_task_priority(
char const *name,
1416 char const *value,
void *data) {
1417 __kmp_stg_parse_int(name, value, 0, KMP_MAX_TASK_PRIORITY_LIMIT,
1418 &__kmp_max_task_priority);
1421 static void __kmp_stg_print_max_task_priority(kmp_str_buf_t *buffer,
1422 char const *name,
void *data) {
1423 __kmp_stg_print_int(buffer, name, __kmp_max_task_priority);
1428 static void __kmp_stg_parse_taskloop_min_tasks(
char const *name,
1429 char const *value,
void *data) {
1431 __kmp_stg_parse_int(name, value, 0, INT_MAX, &tmp);
1432 __kmp_taskloop_min_tasks = tmp;
1435 static void __kmp_stg_print_taskloop_min_tasks(kmp_str_buf_t *buffer,
1436 char const *name,
void *data) {
1437 __kmp_stg_print_uint64(buffer, name, __kmp_taskloop_min_tasks);
1442 static void __kmp_stg_parse_disp_buffers(
char const *name,
char const *value,
1444 if (TCR_4(__kmp_init_serial)) {
1445 KMP_WARNING(EnvSerialWarn, name);
1448 __kmp_stg_parse_int(name, value, KMP_MIN_DISP_NUM_BUFF, KMP_MAX_DISP_NUM_BUFF,
1449 &__kmp_dispatch_num_buffers);
1452 static void __kmp_stg_print_disp_buffers(kmp_str_buf_t *buffer,
1453 char const *name,
void *data) {
1454 __kmp_stg_print_int(buffer, name, __kmp_dispatch_num_buffers);
1457 #if KMP_NESTED_HOT_TEAMS
1461 static void __kmp_stg_parse_hot_teams_level(
char const *name,
char const *value,
1463 if (TCR_4(__kmp_init_parallel)) {
1464 KMP_WARNING(EnvParallelWarn, name);
1467 __kmp_stg_parse_int(name, value, 0, KMP_MAX_ACTIVE_LEVELS_LIMIT,
1468 &__kmp_hot_teams_max_level);
1471 static void __kmp_stg_print_hot_teams_level(kmp_str_buf_t *buffer,
1472 char const *name,
void *data) {
1473 __kmp_stg_print_int(buffer, name, __kmp_hot_teams_max_level);
1476 static void __kmp_stg_parse_hot_teams_mode(
char const *name,
char const *value,
1478 if (TCR_4(__kmp_init_parallel)) {
1479 KMP_WARNING(EnvParallelWarn, name);
1482 __kmp_stg_parse_int(name, value, 0, KMP_MAX_ACTIVE_LEVELS_LIMIT,
1483 &__kmp_hot_teams_mode);
1486 static void __kmp_stg_print_hot_teams_mode(kmp_str_buf_t *buffer,
1487 char const *name,
void *data) {
1488 __kmp_stg_print_int(buffer, name, __kmp_hot_teams_mode);
1496 #if KMP_HANDLE_SIGNALS
1498 static void __kmp_stg_parse_handle_signals(
char const *name,
char const *value,
1500 __kmp_stg_parse_bool(name, value, &__kmp_handle_signals);
1503 static void __kmp_stg_print_handle_signals(kmp_str_buf_t *buffer,
1504 char const *name,
void *data) {
1505 __kmp_stg_print_bool(buffer, name, __kmp_handle_signals);
1515 #define KMP_STG_X_DEBUG(x) \
1516 static void __kmp_stg_parse_##x##_debug(char const *name, char const *value, \
1518 __kmp_stg_parse_int(name, value, 0, INT_MAX, &kmp_##x##_debug); \
1520 static void __kmp_stg_print_##x##_debug(kmp_str_buf_t *buffer, \
1521 char const *name, void *data) { \
1522 __kmp_stg_print_int(buffer, name, kmp_##x##_debug); \
1532 #undef KMP_STG_X_DEBUG
1534 static void __kmp_stg_parse_debug(
char const *name,
char const *value,
1537 __kmp_stg_parse_int(name, value, 0, INT_MAX, &debug);
1538 if (kmp_a_debug < debug) {
1539 kmp_a_debug = debug;
1541 if (kmp_b_debug < debug) {
1542 kmp_b_debug = debug;
1544 if (kmp_c_debug < debug) {
1545 kmp_c_debug = debug;
1547 if (kmp_d_debug < debug) {
1548 kmp_d_debug = debug;
1550 if (kmp_e_debug < debug) {
1551 kmp_e_debug = debug;
1553 if (kmp_f_debug < debug) {
1554 kmp_f_debug = debug;
1558 static void __kmp_stg_parse_debug_buf(
char const *name,
char const *value,
1560 __kmp_stg_parse_bool(name, value, &__kmp_debug_buf);
1564 if (__kmp_debug_buf) {
1566 int elements = __kmp_debug_buf_lines * __kmp_debug_buf_chars;
1569 __kmp_debug_buffer = (
char *)__kmp_page_allocate(elements *
sizeof(
char));
1570 for (i = 0; i < elements; i += __kmp_debug_buf_chars)
1571 __kmp_debug_buffer[i] =
'\0';
1573 __kmp_debug_count = 0;
1575 K_DIAG(1, (
"__kmp_debug_buf = %d\n", __kmp_debug_buf));
1578 static void __kmp_stg_print_debug_buf(kmp_str_buf_t *buffer,
char const *name,
1580 __kmp_stg_print_bool(buffer, name, __kmp_debug_buf);
1583 static void __kmp_stg_parse_debug_buf_atomic(
char const *name,
1584 char const *value,
void *data) {
1585 __kmp_stg_parse_bool(name, value, &__kmp_debug_buf_atomic);
1588 static void __kmp_stg_print_debug_buf_atomic(kmp_str_buf_t *buffer,
1589 char const *name,
void *data) {
1590 __kmp_stg_print_bool(buffer, name, __kmp_debug_buf_atomic);
1593 static void __kmp_stg_parse_debug_buf_chars(
char const *name,
char const *value,
1595 __kmp_stg_parse_int(name, value, KMP_DEBUG_BUF_CHARS_MIN, INT_MAX,
1596 &__kmp_debug_buf_chars);
1599 static void __kmp_stg_print_debug_buf_chars(kmp_str_buf_t *buffer,
1600 char const *name,
void *data) {
1601 __kmp_stg_print_int(buffer, name, __kmp_debug_buf_chars);
1604 static void __kmp_stg_parse_debug_buf_lines(
char const *name,
char const *value,
1606 __kmp_stg_parse_int(name, value, KMP_DEBUG_BUF_LINES_MIN, INT_MAX,
1607 &__kmp_debug_buf_lines);
1610 static void __kmp_stg_print_debug_buf_lines(kmp_str_buf_t *buffer,
1611 char const *name,
void *data) {
1612 __kmp_stg_print_int(buffer, name, __kmp_debug_buf_lines);
1615 static void __kmp_stg_parse_diag(
char const *name,
char const *value,
1617 __kmp_stg_parse_int(name, value, 0, INT_MAX, &kmp_diag);
1620 static void __kmp_stg_print_diag(kmp_str_buf_t *buffer,
char const *name,
1622 __kmp_stg_print_int(buffer, name, kmp_diag);
1630 static void __kmp_stg_parse_align_alloc(
char const *name,
char const *value,
1632 __kmp_stg_parse_size(name, value, CACHE_LINE, INT_MAX, NULL,
1633 &__kmp_align_alloc, 1);
1636 static void __kmp_stg_print_align_alloc(kmp_str_buf_t *buffer,
char const *name,
1638 __kmp_stg_print_size(buffer, name, __kmp_align_alloc);
1647 static void __kmp_stg_parse_barrier_branch_bit(
char const *name,
1648 char const *value,
void *data) {
1652 for (
int i = bs_plain_barrier; i < bs_last_barrier; i++) {
1653 var = __kmp_barrier_branch_bit_env_name[i];
1654 if ((strcmp(var, name) == 0) && (value != 0)) {
1657 comma = CCAST(
char *, strchr(value,
','));
1658 __kmp_barrier_gather_branch_bits[i] =
1659 (kmp_uint32)__kmp_str_to_int(value,
',');
1661 if (comma == NULL) {
1662 __kmp_barrier_release_branch_bits[i] = __kmp_barrier_release_bb_dflt;
1664 __kmp_barrier_release_branch_bits[i] =
1665 (kmp_uint32)__kmp_str_to_int(comma + 1, 0);
1667 if (__kmp_barrier_release_branch_bits[i] > KMP_MAX_BRANCH_BITS) {
1668 __kmp_msg(kmp_ms_warning,
1669 KMP_MSG(BarrReleaseValueInvalid, name, comma + 1),
1671 __kmp_barrier_release_branch_bits[i] = __kmp_barrier_release_bb_dflt;
1674 if (__kmp_barrier_gather_branch_bits[i] > KMP_MAX_BRANCH_BITS) {
1675 KMP_WARNING(BarrGatherValueInvalid, name, value);
1676 KMP_INFORM(Using_uint_Value, name, __kmp_barrier_gather_bb_dflt);
1677 __kmp_barrier_gather_branch_bits[i] = __kmp_barrier_gather_bb_dflt;
1680 K_DIAG(1, (
"%s == %d,%d\n", __kmp_barrier_branch_bit_env_name[i],
1681 __kmp_barrier_gather_branch_bits[i],
1682 __kmp_barrier_release_branch_bits[i]))
1686 static void __kmp_stg_print_barrier_branch_bit(kmp_str_buf_t *buffer,
1687 char const *name,
void *data) {
1689 for (
int i = bs_plain_barrier; i < bs_last_barrier; i++) {
1690 var = __kmp_barrier_branch_bit_env_name[i];
1691 if (strcmp(var, name) == 0) {
1692 if (__kmp_env_format) {
1693 KMP_STR_BUF_PRINT_NAME_EX(__kmp_barrier_branch_bit_env_name[i]);
1695 __kmp_str_buf_print(buffer,
" %s='",
1696 __kmp_barrier_branch_bit_env_name[i]);
1698 __kmp_str_buf_print(buffer,
"%d,%d'\n",
1699 __kmp_barrier_gather_branch_bits[i],
1700 __kmp_barrier_release_branch_bits[i]);
1712 static void __kmp_stg_parse_barrier_pattern(
char const *name,
char const *value,
1717 static int dist_req = 0, non_dist_req = 0;
1718 static bool warn = 1;
1719 for (
int i = bs_plain_barrier; i < bs_last_barrier; i++) {
1720 var = __kmp_barrier_pattern_env_name[i];
1722 if ((strcmp(var, name) == 0) && (value != 0)) {
1724 char *comma = CCAST(
char *, strchr(value,
','));
1727 for (j = bp_linear_bar; j < bp_last_bar; j++) {
1728 if (__kmp_match_with_sentinel(__kmp_barrier_pattern_name[j], value, 1,
1730 if (j == bp_dist_bar) {
1735 __kmp_barrier_gather_pattern[i] = (kmp_bar_pat_e)j;
1739 if (j == bp_last_bar) {
1740 KMP_WARNING(BarrGatherValueInvalid, name, value);
1741 KMP_INFORM(Using_str_Value, name,
1742 __kmp_barrier_pattern_name[bp_linear_bar]);
1746 if (comma != NULL) {
1747 for (j = bp_linear_bar; j < bp_last_bar; j++) {
1748 if (__kmp_str_match(__kmp_barrier_pattern_name[j], 1, comma + 1)) {
1749 if (j == bp_dist_bar) {
1754 __kmp_barrier_release_pattern[i] = (kmp_bar_pat_e)j;
1758 if (j == bp_last_bar) {
1759 __kmp_msg(kmp_ms_warning,
1760 KMP_MSG(BarrReleaseValueInvalid, name, comma + 1),
1762 KMP_INFORM(Using_str_Value, name,
1763 __kmp_barrier_pattern_name[bp_linear_bar]);
1768 if (dist_req != 0) {
1770 if ((non_dist_req != 0) && warn) {
1771 KMP_INFORM(BarrierPatternOverride, name,
1772 __kmp_barrier_pattern_name[bp_dist_bar]);
1775 for (
int i = bs_plain_barrier; i < bs_last_barrier; i++) {
1776 if (__kmp_barrier_release_pattern[i] != bp_dist_bar)
1777 __kmp_barrier_release_pattern[i] = bp_dist_bar;
1778 if (__kmp_barrier_gather_pattern[i] != bp_dist_bar)
1779 __kmp_barrier_gather_pattern[i] = bp_dist_bar;
1784 static void __kmp_stg_print_barrier_pattern(kmp_str_buf_t *buffer,
1785 char const *name,
void *data) {
1787 for (
int i = bs_plain_barrier; i < bs_last_barrier; i++) {
1788 var = __kmp_barrier_pattern_env_name[i];
1789 if (strcmp(var, name) == 0) {
1790 int j = __kmp_barrier_gather_pattern[i];
1791 int k = __kmp_barrier_release_pattern[i];
1792 if (__kmp_env_format) {
1793 KMP_STR_BUF_PRINT_NAME_EX(__kmp_barrier_pattern_env_name[i]);
1795 __kmp_str_buf_print(buffer,
" %s='",
1796 __kmp_barrier_pattern_env_name[i]);
1798 KMP_DEBUG_ASSERT(j < bp_last_bar && k < bp_last_bar);
1799 __kmp_str_buf_print(buffer,
"%s,%s'\n", __kmp_barrier_pattern_name[j],
1800 __kmp_barrier_pattern_name[k]);
1808 static void __kmp_stg_parse_abort_delay(
char const *name,
char const *value,
1812 int delay = __kmp_abort_delay / 1000;
1813 __kmp_stg_parse_int(name, value, 0, INT_MAX / 1000, &delay);
1814 __kmp_abort_delay = delay * 1000;
1817 static void __kmp_stg_print_abort_delay(kmp_str_buf_t *buffer,
char const *name,
1819 __kmp_stg_print_int(buffer, name, __kmp_abort_delay);
1825 static void __kmp_stg_parse_cpuinfo_file(
char const *name,
char const *value,
1827 #if KMP_AFFINITY_SUPPORTED
1828 __kmp_stg_parse_str(name, value, &__kmp_cpuinfo_file);
1829 K_DIAG(1, (
"__kmp_cpuinfo_file == %s\n", __kmp_cpuinfo_file));
1833 static void __kmp_stg_print_cpuinfo_file(kmp_str_buf_t *buffer,
1834 char const *name,
void *data) {
1835 #if KMP_AFFINITY_SUPPORTED
1836 if (__kmp_env_format) {
1837 KMP_STR_BUF_PRINT_NAME;
1839 __kmp_str_buf_print(buffer,
" %s", name);
1841 if (__kmp_cpuinfo_file) {
1842 __kmp_str_buf_print(buffer,
"='%s'\n", __kmp_cpuinfo_file);
1844 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
1852 static void __kmp_stg_parse_force_reduction(
char const *name,
char const *value,
1854 kmp_stg_fr_data_t *reduction = (kmp_stg_fr_data_t *)data;
1857 rc = __kmp_stg_check_rivals(name, value, reduction->rivals);
1861 if (reduction->force) {
1863 if (__kmp_str_match(
"critical", 0, value))
1864 __kmp_force_reduction_method = critical_reduce_block;
1865 else if (__kmp_str_match(
"atomic", 0, value))
1866 __kmp_force_reduction_method = atomic_reduce_block;
1867 else if (__kmp_str_match(
"tree", 0, value))
1868 __kmp_force_reduction_method = tree_reduce_block;
1870 KMP_FATAL(UnknownForceReduction, name, value);
1874 __kmp_stg_parse_bool(name, value, &__kmp_determ_red);
1875 if (__kmp_determ_red) {
1876 __kmp_force_reduction_method = tree_reduce_block;
1878 __kmp_force_reduction_method = reduction_method_not_defined;
1881 K_DIAG(1, (
"__kmp_force_reduction_method == %d\n",
1882 __kmp_force_reduction_method));
1885 static void __kmp_stg_print_force_reduction(kmp_str_buf_t *buffer,
1886 char const *name,
void *data) {
1888 kmp_stg_fr_data_t *reduction = (kmp_stg_fr_data_t *)data;
1889 if (reduction->force) {
1890 if (__kmp_force_reduction_method == critical_reduce_block) {
1891 __kmp_stg_print_str(buffer, name,
"critical");
1892 }
else if (__kmp_force_reduction_method == atomic_reduce_block) {
1893 __kmp_stg_print_str(buffer, name,
"atomic");
1894 }
else if (__kmp_force_reduction_method == tree_reduce_block) {
1895 __kmp_stg_print_str(buffer, name,
"tree");
1897 if (__kmp_env_format) {
1898 KMP_STR_BUF_PRINT_NAME;
1900 __kmp_str_buf_print(buffer,
" %s", name);
1902 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
1905 __kmp_stg_print_bool(buffer, name, __kmp_determ_red);
1913 static void __kmp_stg_parse_storage_map(
char const *name,
char const *value,
1915 if (__kmp_str_match(
"verbose", 1, value)) {
1916 __kmp_storage_map = TRUE;
1917 __kmp_storage_map_verbose = TRUE;
1918 __kmp_storage_map_verbose_specified = TRUE;
1921 __kmp_storage_map_verbose = FALSE;
1922 __kmp_stg_parse_bool(name, value, &__kmp_storage_map);
1926 static void __kmp_stg_print_storage_map(kmp_str_buf_t *buffer,
char const *name,
1928 if (__kmp_storage_map_verbose || __kmp_storage_map_verbose_specified) {
1929 __kmp_stg_print_str(buffer, name,
"verbose");
1931 __kmp_stg_print_bool(buffer, name, __kmp_storage_map);
1938 static void __kmp_stg_parse_all_threadprivate(
char const *name,
1939 char const *value,
void *data) {
1940 __kmp_stg_parse_int(name, value,
1941 __kmp_allThreadsSpecified ? __kmp_max_nth : 1,
1942 __kmp_max_nth, &__kmp_tp_capacity);
1945 static void __kmp_stg_print_all_threadprivate(kmp_str_buf_t *buffer,
1946 char const *name,
void *data) {
1947 __kmp_stg_print_int(buffer, name, __kmp_tp_capacity);
1953 static void __kmp_stg_parse_foreign_threads_threadprivate(
char const *name,
1956 __kmp_stg_parse_bool(name, value, &__kmp_foreign_tp);
1959 static void __kmp_stg_print_foreign_threads_threadprivate(kmp_str_buf_t *buffer,
1962 __kmp_stg_print_bool(buffer, name, __kmp_foreign_tp);
1968 #if KMP_AFFINITY_SUPPORTED
1970 static int __kmp_parse_affinity_proc_id_list(
const char *var,
const char *env,
1971 const char **nextEnv,
1973 const char *scan = env;
1974 const char *next = scan;
1980 int start, end, stride;
1984 if (*next ==
'\0') {
1995 if ((*next <
'0') || (*next >
'9')) {
1996 KMP_WARNING(AffSyntaxError, var);
2000 num = __kmp_str_to_int(scan, *next);
2001 KMP_ASSERT(num >= 0);
2019 if ((*next <
'0') || (*next >
'9')) {
2020 KMP_WARNING(AffSyntaxError, var);
2025 num = __kmp_str_to_int(scan, *next);
2026 KMP_ASSERT(num >= 0);
2039 if ((*next <
'0') || (*next >
'9')) {
2041 KMP_WARNING(AffSyntaxError, var);
2049 start = __kmp_str_to_int(scan, *next);
2050 KMP_ASSERT(start >= 0);
2069 if ((*next <
'0') || (*next >
'9')) {
2070 KMP_WARNING(AffSyntaxError, var);
2074 end = __kmp_str_to_int(scan, *next);
2075 KMP_ASSERT(end >= 0);
2092 if ((*next <
'0') || (*next >
'9')) {
2093 KMP_WARNING(AffSyntaxError, var);
2097 stride = __kmp_str_to_int(scan, *next);
2098 KMP_ASSERT(stride >= 0);
2104 KMP_WARNING(AffZeroStride, var);
2109 KMP_WARNING(AffStartGreaterEnd, var, start, end);
2114 KMP_WARNING(AffStrideLessZero, var, start, end);
2118 if ((end - start) / stride > 65536) {
2119 KMP_WARNING(AffRangeTooBig, var, end, start, stride);
2136 ptrdiff_t len = next - env;
2137 char *retlist = (
char *)__kmp_allocate((len + 1) *
sizeof(char));
2138 KMP_MEMCPY_S(retlist, (len + 1) *
sizeof(
char), env, len *
sizeof(
char));
2139 retlist[len] =
'\0';
2140 *proclist = retlist;
2147 static kmp_setting_t *__kmp_affinity_notype = NULL;
2149 static void __kmp_parse_affinity_env(
char const *name,
char const *value,
2150 enum affinity_type *out_type,
2151 char **out_proclist,
int *out_verbose,
2152 int *out_warn,
int *out_respect,
2153 kmp_hw_t *out_gran,
int *out_gran_levels,
2154 int *out_dups,
int *out_compact,
2156 char *buffer = NULL;
2173 KMP_ASSERT(value != NULL);
2175 if (TCR_4(__kmp_init_middle)) {
2176 KMP_WARNING(EnvMiddleWarn, name);
2177 __kmp_env_toPrint(name, 0);
2180 __kmp_env_toPrint(name, 1);
2183 __kmp_str_format(
"%s", value);
2193 #define EMIT_WARN(skip, errlist) \
2197 SKIP_TO(next, ','); \
2201 KMP_WARNING errlist; \
2210 #define _set_param(_guard, _var, _val) \
2212 if (_guard == 0) { \
2215 EMIT_WARN(FALSE, (AffParamDefined, name, start)); \
2220 #define set_type(val) _set_param(type, *out_type, val)
2221 #define set_verbose(val) _set_param(verbose, *out_verbose, val)
2222 #define set_warnings(val) _set_param(warnings, *out_warn, val)
2223 #define set_respect(val) _set_param(respect, *out_respect, val)
2224 #define set_dups(val) _set_param(dups, *out_dups, val)
2225 #define set_proclist(val) _set_param(proclist, *out_proclist, val)
2227 #define set_gran(val, levels) \
2231 *out_gran_levels = levels; \
2233 EMIT_WARN(FALSE, (AffParamDefined, name, start)); \
2238 KMP_DEBUG_ASSERT((__kmp_nested_proc_bind.bind_types != NULL) &&
2239 (__kmp_nested_proc_bind.used > 0));
2241 while (*buf !=
'\0') {
2244 if (__kmp_match_str(
"none", buf, CCAST(
const char **, &next))) {
2245 set_type(affinity_none);
2246 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
2248 }
else if (__kmp_match_str(
"scatter", buf, CCAST(
const char **, &next))) {
2249 set_type(affinity_scatter);
2250 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2252 }
else if (__kmp_match_str(
"compact", buf, CCAST(
const char **, &next))) {
2253 set_type(affinity_compact);
2254 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2256 }
else if (__kmp_match_str(
"logical", buf, CCAST(
const char **, &next))) {
2257 set_type(affinity_logical);
2258 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2260 }
else if (__kmp_match_str(
"physical", buf, CCAST(
const char **, &next))) {
2261 set_type(affinity_physical);
2262 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2264 }
else if (__kmp_match_str(
"explicit", buf, CCAST(
const char **, &next))) {
2265 set_type(affinity_explicit);
2266 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2268 }
else if (__kmp_match_str(
"balanced", buf, CCAST(
const char **, &next))) {
2269 set_type(affinity_balanced);
2270 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2272 }
else if (__kmp_match_str(
"disabled", buf, CCAST(
const char **, &next))) {
2273 set_type(affinity_disabled);
2274 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
2276 }
else if (__kmp_match_str(
"verbose", buf, CCAST(
const char **, &next))) {
2279 }
else if (__kmp_match_str(
"noverbose", buf, CCAST(
const char **, &next))) {
2282 }
else if (__kmp_match_str(
"warnings", buf, CCAST(
const char **, &next))) {
2285 }
else if (__kmp_match_str(
"nowarnings", buf,
2286 CCAST(
const char **, &next))) {
2287 set_warnings(FALSE);
2289 }
else if (__kmp_match_str(
"respect", buf, CCAST(
const char **, &next))) {
2292 }
else if (__kmp_match_str(
"norespect", buf, CCAST(
const char **, &next))) {
2295 }
else if (__kmp_match_str(
"duplicates", buf,
2296 CCAST(
const char **, &next)) ||
2297 __kmp_match_str(
"dups", buf, CCAST(
const char **, &next))) {
2300 }
else if (__kmp_match_str(
"noduplicates", buf,
2301 CCAST(
const char **, &next)) ||
2302 __kmp_match_str(
"nodups", buf, CCAST(
const char **, &next))) {
2305 }
else if (__kmp_match_str(
"granularity", buf,
2306 CCAST(
const char **, &next)) ||
2307 __kmp_match_str(
"gran", buf, CCAST(
const char **, &next))) {
2310 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2319 KMP_FOREACH_HW_TYPE(type) {
2320 const char *name = __kmp_hw_get_keyword(type);
2321 if (__kmp_match_str(name, buf, CCAST(
const char **, &next))) {
2330 if (__kmp_match_str(
"fine", buf, CCAST(
const char **, &next))) {
2331 set_gran(KMP_HW_THREAD, -1);
2334 }
else if (__kmp_match_str(
"package", buf,
2335 CCAST(
const char **, &next))) {
2336 set_gran(KMP_HW_SOCKET, -1);
2339 }
else if (__kmp_match_str(
"node", buf, CCAST(
const char **, &next))) {
2340 set_gran(KMP_HW_NUMA, -1);
2343 #if KMP_GROUP_AFFINITY
2344 }
else if (__kmp_match_str(
"group", buf, CCAST(
const char **, &next))) {
2345 set_gran(KMP_HW_PROC_GROUP, -1);
2349 }
else if ((*buf >=
'0') && (*buf <=
'9')) {
2353 n = __kmp_str_to_int(buf, *next);
2356 set_gran(KMP_HW_UNKNOWN, n);
2359 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2363 }
else if (__kmp_match_str(
"proclist", buf, CCAST(
const char **, &next))) {
2364 char *temp_proclist;
2368 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2374 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2379 if (!__kmp_parse_affinity_proc_id_list(
2380 name, buf, CCAST(
const char **, &next), &temp_proclist)) {
2392 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2396 set_proclist(temp_proclist);
2397 }
else if ((*buf >=
'0') && (*buf <=
'9')) {
2402 n = __kmp_str_to_int(buf, *next);
2408 KMP_WARNING(AffManyParams, name, start);
2412 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2420 }
else if (*next !=
'\0') {
2421 const char *temp = next;
2422 EMIT_WARN(TRUE, (ParseExtraCharsWarn, name, temp));
2434 #undef set_granularity
2436 __kmp_str_free(&buffer);
2440 KMP_WARNING(AffProcListNoType, name);
2441 *out_type = affinity_explicit;
2442 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2443 }
else if (*out_type != affinity_explicit) {
2444 KMP_WARNING(AffProcListNotExplicit, name);
2445 KMP_ASSERT(*out_proclist != NULL);
2446 KMP_INTERNAL_FREE(*out_proclist);
2447 *out_proclist = NULL;
2450 switch (*out_type) {
2451 case affinity_logical:
2452 case affinity_physical: {
2454 *out_offset = number[0];
2457 KMP_WARNING(AffManyParamsForLogic, name, number[1]);
2460 case affinity_balanced: {
2462 *out_compact = number[0];
2465 *out_offset = number[1];
2468 if (__kmp_affinity_gran == KMP_HW_UNKNOWN) {
2469 #if KMP_MIC_SUPPORTED
2470 if (__kmp_mic_type != non_mic) {
2471 if (__kmp_affinity_verbose || __kmp_affinity_warnings) {
2472 KMP_WARNING(AffGranUsing,
"KMP_AFFINITY",
"fine");
2474 __kmp_affinity_gran = KMP_HW_THREAD;
2478 if (__kmp_affinity_verbose || __kmp_affinity_warnings) {
2479 KMP_WARNING(AffGranUsing,
"KMP_AFFINITY",
"core");
2481 __kmp_affinity_gran = KMP_HW_CORE;
2485 case affinity_scatter:
2486 case affinity_compact: {
2488 *out_compact = number[0];
2491 *out_offset = number[1];
2494 case affinity_explicit: {
2495 if (*out_proclist == NULL) {
2496 KMP_WARNING(AffNoProcList, name);
2497 __kmp_affinity_type = affinity_none;
2500 KMP_WARNING(AffNoParam, name,
"explicit");
2503 case affinity_none: {
2505 KMP_WARNING(AffNoParam, name,
"none");
2508 case affinity_disabled: {
2510 KMP_WARNING(AffNoParam, name,
"disabled");
2513 case affinity_default: {
2515 KMP_WARNING(AffNoParam, name,
"default");
2524 static void __kmp_stg_parse_affinity(
char const *name,
char const *value,
2526 kmp_setting_t **rivals = (kmp_setting_t **)data;
2529 rc = __kmp_stg_check_rivals(name, value, rivals);
2534 __kmp_parse_affinity_env(name, value, &__kmp_affinity_type,
2535 &__kmp_affinity_proclist, &__kmp_affinity_verbose,
2536 &__kmp_affinity_warnings,
2537 &__kmp_affinity_respect_mask, &__kmp_affinity_gran,
2538 &__kmp_affinity_gran_levels, &__kmp_affinity_dups,
2539 &__kmp_affinity_compact, &__kmp_affinity_offset);
2543 static void __kmp_stg_print_affinity(kmp_str_buf_t *buffer,
char const *name,
2545 if (__kmp_env_format) {
2546 KMP_STR_BUF_PRINT_NAME_EX(name);
2548 __kmp_str_buf_print(buffer,
" %s='", name);
2550 if (__kmp_affinity_verbose) {
2551 __kmp_str_buf_print(buffer,
"%s,",
"verbose");
2553 __kmp_str_buf_print(buffer,
"%s,",
"noverbose");
2555 if (__kmp_affinity_warnings) {
2556 __kmp_str_buf_print(buffer,
"%s,",
"warnings");
2558 __kmp_str_buf_print(buffer,
"%s,",
"nowarnings");
2560 if (KMP_AFFINITY_CAPABLE()) {
2561 if (__kmp_affinity_respect_mask) {
2562 __kmp_str_buf_print(buffer,
"%s,",
"respect");
2564 __kmp_str_buf_print(buffer,
"%s,",
"norespect");
2566 __kmp_str_buf_print(buffer,
"granularity=%s,",
2567 __kmp_hw_get_keyword(__kmp_affinity_gran,
false));
2569 if (!KMP_AFFINITY_CAPABLE()) {
2570 __kmp_str_buf_print(buffer,
"%s",
"disabled");
2572 switch (__kmp_affinity_type) {
2574 __kmp_str_buf_print(buffer,
"%s",
"none");
2576 case affinity_physical:
2577 __kmp_str_buf_print(buffer,
"%s,%d",
"physical", __kmp_affinity_offset);
2579 case affinity_logical:
2580 __kmp_str_buf_print(buffer,
"%s,%d",
"logical", __kmp_affinity_offset);
2582 case affinity_compact:
2583 __kmp_str_buf_print(buffer,
"%s,%d,%d",
"compact", __kmp_affinity_compact,
2584 __kmp_affinity_offset);
2586 case affinity_scatter:
2587 __kmp_str_buf_print(buffer,
"%s,%d,%d",
"scatter", __kmp_affinity_compact,
2588 __kmp_affinity_offset);
2590 case affinity_explicit:
2591 __kmp_str_buf_print(buffer,
"%s=[%s],%s",
"proclist",
2592 __kmp_affinity_proclist,
"explicit");
2594 case affinity_balanced:
2595 __kmp_str_buf_print(buffer,
"%s,%d,%d",
"balanced",
2596 __kmp_affinity_compact, __kmp_affinity_offset);
2598 case affinity_disabled:
2599 __kmp_str_buf_print(buffer,
"%s",
"disabled");
2601 case affinity_default:
2602 __kmp_str_buf_print(buffer,
"%s",
"default");
2605 __kmp_str_buf_print(buffer,
"%s",
"<unknown>");
2608 __kmp_str_buf_print(buffer,
"'\n");
2611 #ifdef KMP_GOMP_COMPAT
2613 static void __kmp_stg_parse_gomp_cpu_affinity(
char const *name,
2614 char const *value,
void *data) {
2615 const char *next = NULL;
2616 char *temp_proclist;
2617 kmp_setting_t **rivals = (kmp_setting_t **)data;
2620 rc = __kmp_stg_check_rivals(name, value, rivals);
2625 if (TCR_4(__kmp_init_middle)) {
2626 KMP_WARNING(EnvMiddleWarn, name);
2627 __kmp_env_toPrint(name, 0);
2631 __kmp_env_toPrint(name, 1);
2633 if (__kmp_parse_affinity_proc_id_list(name, value, &next, &temp_proclist)) {
2635 if (*next ==
'\0') {
2637 __kmp_affinity_proclist = temp_proclist;
2638 __kmp_affinity_type = affinity_explicit;
2639 __kmp_affinity_gran = KMP_HW_THREAD;
2640 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2642 KMP_WARNING(AffSyntaxError, name);
2643 if (temp_proclist != NULL) {
2644 KMP_INTERNAL_FREE((
void *)temp_proclist);
2649 __kmp_affinity_type = affinity_none;
2650 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
2677 static inline void __kmp_omp_places_syntax_warn(
const char *var) {
2678 KMP_WARNING(SyntaxErrorUsing, var,
"\"cores\"");
2681 static int __kmp_parse_subplace_list(
const char *var,
const char **scan) {
2685 int start, count, stride;
2691 if ((**scan <
'0') || (**scan >
'9')) {
2692 __kmp_omp_places_syntax_warn(var);
2697 start = __kmp_str_to_int(*scan, *next);
2698 KMP_ASSERT(start >= 0);
2703 if (**scan ==
'}') {
2706 if (**scan ==
',') {
2710 if (**scan !=
':') {
2711 __kmp_omp_places_syntax_warn(var);
2718 if ((**scan <
'0') || (**scan >
'9')) {
2719 __kmp_omp_places_syntax_warn(var);
2724 count = __kmp_str_to_int(*scan, *next);
2725 KMP_ASSERT(count >= 0);
2730 if (**scan ==
'}') {
2733 if (**scan ==
',') {
2737 if (**scan !=
':') {
2738 __kmp_omp_places_syntax_warn(var);
2747 if (**scan ==
'+') {
2751 if (**scan ==
'-') {
2759 if ((**scan <
'0') || (**scan >
'9')) {
2760 __kmp_omp_places_syntax_warn(var);
2765 stride = __kmp_str_to_int(*scan, *next);
2766 KMP_ASSERT(stride >= 0);
2772 if (**scan ==
'}') {
2775 if (**scan ==
',') {
2780 __kmp_omp_places_syntax_warn(var);
2786 static int __kmp_parse_place(
const char *var,
const char **scan) {
2791 if (**scan ==
'{') {
2793 if (!__kmp_parse_subplace_list(var, scan)) {
2796 if (**scan !=
'}') {
2797 __kmp_omp_places_syntax_warn(var);
2801 }
else if (**scan ==
'!') {
2803 return __kmp_parse_place(var, scan);
2804 }
else if ((**scan >=
'0') && (**scan <=
'9')) {
2807 int proc = __kmp_str_to_int(*scan, *next);
2808 KMP_ASSERT(proc >= 0);
2811 __kmp_omp_places_syntax_warn(var);
2817 static int __kmp_parse_place_list(
const char *var,
const char *env,
2818 char **place_list) {
2819 const char *scan = env;
2820 const char *next = scan;
2825 if (!__kmp_parse_place(var, &scan)) {
2831 if (*scan ==
'\0') {
2839 __kmp_omp_places_syntax_warn(var);
2846 if ((*scan <
'0') || (*scan >
'9')) {
2847 __kmp_omp_places_syntax_warn(var);
2852 count = __kmp_str_to_int(scan, *next);
2853 KMP_ASSERT(count >= 0);
2858 if (*scan ==
'\0') {
2866 __kmp_omp_places_syntax_warn(var);
2887 if ((*scan <
'0') || (*scan >
'9')) {
2888 __kmp_omp_places_syntax_warn(var);
2893 stride = __kmp_str_to_int(scan, *next);
2894 KMP_ASSERT(stride >= 0);
2900 if (*scan ==
'\0') {
2908 __kmp_omp_places_syntax_warn(var);
2913 ptrdiff_t len = scan - env;
2914 char *retlist = (
char *)__kmp_allocate((len + 1) *
sizeof(char));
2915 KMP_MEMCPY_S(retlist, (len + 1) *
sizeof(
char), env, len *
sizeof(
char));
2916 retlist[len] =
'\0';
2917 *place_list = retlist;
2922 static void __kmp_stg_parse_places(
char const *name,
char const *value,
2924 struct kmp_place_t {
2930 const char *scan = value;
2931 const char *next = scan;
2932 const char *kind =
"\"threads\"";
2933 kmp_place_t std_places[] = {{
"threads", KMP_HW_THREAD},
2934 {
"cores", KMP_HW_CORE},
2935 {
"numa_domains", KMP_HW_NUMA},
2936 {
"ll_caches", KMP_HW_LLC},
2937 {
"sockets", KMP_HW_SOCKET}};
2938 kmp_setting_t **rivals = (kmp_setting_t **)data;
2941 rc = __kmp_stg_check_rivals(name, value, rivals);
2947 for (
size_t i = 0; i <
sizeof(std_places) /
sizeof(std_places[0]); ++i) {
2948 const kmp_place_t &place = std_places[i];
2949 if (__kmp_match_str(place.name, scan, &next)) {
2951 __kmp_affinity_type = affinity_compact;
2952 __kmp_affinity_gran = place.type;
2953 __kmp_affinity_dups = FALSE;
2960 KMP_FOREACH_HW_TYPE(type) {
2961 const char *name = __kmp_hw_get_keyword(type,
true);
2962 if (__kmp_match_str(
"unknowns", scan, &next))
2964 if (__kmp_match_str(name, scan, &next)) {
2966 __kmp_affinity_type = affinity_compact;
2967 __kmp_affinity_gran = type;
2968 __kmp_affinity_dups = FALSE;
2975 if (__kmp_affinity_proclist != NULL) {
2976 KMP_INTERNAL_FREE((
void *)__kmp_affinity_proclist);
2977 __kmp_affinity_proclist = NULL;
2979 if (__kmp_parse_place_list(name, value, &__kmp_affinity_proclist)) {
2980 __kmp_affinity_type = affinity_explicit;
2981 __kmp_affinity_gran = KMP_HW_THREAD;
2982 __kmp_affinity_dups = FALSE;
2985 __kmp_affinity_type = affinity_compact;
2986 __kmp_affinity_gran = KMP_HW_CORE;
2987 __kmp_affinity_dups = FALSE;
2989 if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_default) {
2990 __kmp_nested_proc_bind.bind_types[0] = proc_bind_true;
2994 if (__kmp_affinity_gran != KMP_HW_UNKNOWN) {
2995 kind = __kmp_hw_get_keyword(__kmp_affinity_gran);
2998 if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_default) {
2999 __kmp_nested_proc_bind.bind_types[0] = proc_bind_true;
3003 if (*scan ==
'\0') {
3009 KMP_WARNING(SyntaxErrorUsing, name, kind);
3017 count = __kmp_str_to_int(scan, *next);
3018 KMP_ASSERT(count >= 0);
3023 KMP_WARNING(SyntaxErrorUsing, name, kind);
3029 if (*scan !=
'\0') {
3030 KMP_WARNING(ParseExtraCharsWarn, name, scan);
3032 __kmp_affinity_num_places = count;
3035 static void __kmp_stg_print_places(kmp_str_buf_t *buffer,
char const *name,
3037 if (__kmp_env_format) {
3038 KMP_STR_BUF_PRINT_NAME;
3040 __kmp_str_buf_print(buffer,
" %s", name);
3042 if ((__kmp_nested_proc_bind.used == 0) ||
3043 (__kmp_nested_proc_bind.bind_types == NULL) ||
3044 (__kmp_nested_proc_bind.bind_types[0] == proc_bind_false)) {
3045 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
3046 }
else if (__kmp_affinity_type == affinity_explicit) {
3047 if (__kmp_affinity_proclist != NULL) {
3048 __kmp_str_buf_print(buffer,
"='%s'\n", __kmp_affinity_proclist);
3050 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
3052 }
else if (__kmp_affinity_type == affinity_compact) {
3054 if (__kmp_affinity_num_masks > 0) {
3055 num = __kmp_affinity_num_masks;
3056 }
else if (__kmp_affinity_num_places > 0) {
3057 num = __kmp_affinity_num_places;
3061 if (__kmp_affinity_gran != KMP_HW_UNKNOWN) {
3062 const char *name = __kmp_hw_get_keyword(__kmp_affinity_gran,
true);
3064 __kmp_str_buf_print(buffer,
"='%s(%d)'\n", name, num);
3066 __kmp_str_buf_print(buffer,
"='%s'\n", name);
3069 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
3072 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
3076 static void __kmp_stg_parse_topology_method(
char const *name,
char const *value,
3078 if (__kmp_str_match(
"all", 1, value)) {
3079 __kmp_affinity_top_method = affinity_top_method_all;
3082 else if (__kmp_str_match(
"hwloc", 1, value)) {
3083 __kmp_affinity_top_method = affinity_top_method_hwloc;
3086 #if KMP_ARCH_X86 || KMP_ARCH_X86_64
3087 else if (__kmp_str_match(
"cpuid_leaf31", 12, value) ||
3088 __kmp_str_match(
"cpuid 1f", 8, value) ||
3089 __kmp_str_match(
"cpuid 31", 8, value) ||
3090 __kmp_str_match(
"cpuid1f", 7, value) ||
3091 __kmp_str_match(
"cpuid31", 7, value) ||
3092 __kmp_str_match(
"leaf 1f", 7, value) ||
3093 __kmp_str_match(
"leaf 31", 7, value) ||
3094 __kmp_str_match(
"leaf1f", 6, value) ||
3095 __kmp_str_match(
"leaf31", 6, value)) {
3096 __kmp_affinity_top_method = affinity_top_method_x2apicid_1f;
3097 }
else if (__kmp_str_match(
"x2apic id", 9, value) ||
3098 __kmp_str_match(
"x2apic_id", 9, value) ||
3099 __kmp_str_match(
"x2apic-id", 9, value) ||
3100 __kmp_str_match(
"x2apicid", 8, value) ||
3101 __kmp_str_match(
"cpuid leaf 11", 13, value) ||
3102 __kmp_str_match(
"cpuid_leaf_11", 13, value) ||
3103 __kmp_str_match(
"cpuid-leaf-11", 13, value) ||
3104 __kmp_str_match(
"cpuid leaf11", 12, value) ||
3105 __kmp_str_match(
"cpuid_leaf11", 12, value) ||
3106 __kmp_str_match(
"cpuid-leaf11", 12, value) ||
3107 __kmp_str_match(
"cpuidleaf 11", 12, value) ||
3108 __kmp_str_match(
"cpuidleaf_11", 12, value) ||
3109 __kmp_str_match(
"cpuidleaf-11", 12, value) ||
3110 __kmp_str_match(
"cpuidleaf11", 11, value) ||
3111 __kmp_str_match(
"cpuid 11", 8, value) ||
3112 __kmp_str_match(
"cpuid_11", 8, value) ||
3113 __kmp_str_match(
"cpuid-11", 8, value) ||
3114 __kmp_str_match(
"cpuid11", 7, value) ||
3115 __kmp_str_match(
"leaf 11", 7, value) ||
3116 __kmp_str_match(
"leaf_11", 7, value) ||
3117 __kmp_str_match(
"leaf-11", 7, value) ||
3118 __kmp_str_match(
"leaf11", 6, value)) {
3119 __kmp_affinity_top_method = affinity_top_method_x2apicid;
3120 }
else if (__kmp_str_match(
"apic id", 7, value) ||
3121 __kmp_str_match(
"apic_id", 7, value) ||
3122 __kmp_str_match(
"apic-id", 7, value) ||
3123 __kmp_str_match(
"apicid", 6, value) ||
3124 __kmp_str_match(
"cpuid leaf 4", 12, value) ||
3125 __kmp_str_match(
"cpuid_leaf_4", 12, value) ||
3126 __kmp_str_match(
"cpuid-leaf-4", 12, value) ||
3127 __kmp_str_match(
"cpuid leaf4", 11, value) ||
3128 __kmp_str_match(
"cpuid_leaf4", 11, value) ||
3129 __kmp_str_match(
"cpuid-leaf4", 11, value) ||
3130 __kmp_str_match(
"cpuidleaf 4", 11, value) ||
3131 __kmp_str_match(
"cpuidleaf_4", 11, value) ||
3132 __kmp_str_match(
"cpuidleaf-4", 11, value) ||
3133 __kmp_str_match(
"cpuidleaf4", 10, value) ||
3134 __kmp_str_match(
"cpuid 4", 7, value) ||
3135 __kmp_str_match(
"cpuid_4", 7, value) ||
3136 __kmp_str_match(
"cpuid-4", 7, value) ||
3137 __kmp_str_match(
"cpuid4", 6, value) ||
3138 __kmp_str_match(
"leaf 4", 6, value) ||
3139 __kmp_str_match(
"leaf_4", 6, value) ||
3140 __kmp_str_match(
"leaf-4", 6, value) ||
3141 __kmp_str_match(
"leaf4", 5, value)) {
3142 __kmp_affinity_top_method = affinity_top_method_apicid;
3145 else if (__kmp_str_match(
"/proc/cpuinfo", 2, value) ||
3146 __kmp_str_match(
"cpuinfo", 5, value)) {
3147 __kmp_affinity_top_method = affinity_top_method_cpuinfo;
3149 #if KMP_GROUP_AFFINITY
3150 else if (__kmp_str_match(
"group", 1, value)) {
3151 KMP_WARNING(StgDeprecatedValue, name, value,
"all");
3152 __kmp_affinity_top_method = affinity_top_method_group;
3155 else if (__kmp_str_match(
"flat", 1, value)) {
3156 __kmp_affinity_top_method = affinity_top_method_flat;
3158 KMP_WARNING(StgInvalidValue, name, value);
3162 static void __kmp_stg_print_topology_method(kmp_str_buf_t *buffer,
3163 char const *name,
void *data) {
3164 char const *value = NULL;
3166 switch (__kmp_affinity_top_method) {
3167 case affinity_top_method_default:
3171 case affinity_top_method_all:
3175 #if KMP_ARCH_X86 || KMP_ARCH_X86_64
3176 case affinity_top_method_x2apicid_1f:
3177 value =
"x2APIC id leaf 0x1f";
3180 case affinity_top_method_x2apicid:
3181 value =
"x2APIC id leaf 0xb";
3184 case affinity_top_method_apicid:
3190 case affinity_top_method_hwloc:
3195 case affinity_top_method_cpuinfo:
3199 #if KMP_GROUP_AFFINITY
3200 case affinity_top_method_group:
3205 case affinity_top_method_flat:
3210 if (value != NULL) {
3211 __kmp_stg_print_str(buffer, name, value);
3216 struct kmp_proc_bind_info_t {
3218 kmp_proc_bind_t proc_bind;
3220 static kmp_proc_bind_info_t proc_bind_table[] = {
3221 {
"spread", proc_bind_spread},
3222 {
"true", proc_bind_spread},
3223 {
"close", proc_bind_close},
3225 {
"false", proc_bind_primary},
3226 {
"primary", proc_bind_primary}};
3227 static void __kmp_stg_parse_teams_proc_bind(
char const *name,
char const *value,
3232 for (
size_t i = 0; i <
sizeof(proc_bind_table) /
sizeof(proc_bind_table[0]);
3234 if (__kmp_match_str(proc_bind_table[i].name, value, &end)) {
3235 __kmp_teams_proc_bind = proc_bind_table[i].proc_bind;
3241 KMP_WARNING(StgInvalidValue, name, value);
3244 static void __kmp_stg_print_teams_proc_bind(kmp_str_buf_t *buffer,
3245 char const *name,
void *data) {
3246 const char *value = KMP_I18N_STR(NotDefined);
3247 for (
size_t i = 0; i <
sizeof(proc_bind_table) /
sizeof(proc_bind_table[0]);
3249 if (__kmp_teams_proc_bind == proc_bind_table[i].proc_bind) {
3250 value = proc_bind_table[i].name;
3254 __kmp_stg_print_str(buffer, name, value);
3260 static void __kmp_stg_parse_proc_bind(
char const *name,
char const *value,
3262 kmp_setting_t **rivals = (kmp_setting_t **)data;
3265 rc = __kmp_stg_check_rivals(name, value, rivals);
3271 KMP_DEBUG_ASSERT((__kmp_nested_proc_bind.bind_types != NULL) &&
3272 (__kmp_nested_proc_bind.used > 0));
3274 const char *buf = value;
3278 if ((*buf >=
'0') && (*buf <=
'9')) {
3281 num = __kmp_str_to_int(buf, *next);
3282 KMP_ASSERT(num >= 0);
3290 if (__kmp_match_str(
"disabled", buf, &next)) {
3293 #if KMP_AFFINITY_SUPPORTED
3294 __kmp_affinity_type = affinity_disabled;
3296 __kmp_nested_proc_bind.used = 1;
3297 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
3298 }
else if ((num == (
int)proc_bind_false) ||
3299 __kmp_match_str(
"false", buf, &next)) {
3302 #if KMP_AFFINITY_SUPPORTED
3303 __kmp_affinity_type = affinity_none;
3305 __kmp_nested_proc_bind.used = 1;
3306 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
3307 }
else if ((num == (
int)proc_bind_true) ||
3308 __kmp_match_str(
"true", buf, &next)) {
3311 __kmp_nested_proc_bind.used = 1;
3312 __kmp_nested_proc_bind.bind_types[0] = proc_bind_true;
3317 for (scan = buf; *scan !=
'\0'; scan++) {
3324 if (__kmp_nested_proc_bind.size < nelem) {
3325 __kmp_nested_proc_bind.bind_types =
3326 (kmp_proc_bind_t *)KMP_INTERNAL_REALLOC(
3327 __kmp_nested_proc_bind.bind_types,
3328 sizeof(kmp_proc_bind_t) * nelem);
3329 if (__kmp_nested_proc_bind.bind_types == NULL) {
3330 KMP_FATAL(MemoryAllocFailed);
3332 __kmp_nested_proc_bind.size = nelem;
3334 __kmp_nested_proc_bind.used = nelem;
3336 if (nelem > 1 && !__kmp_dflt_max_active_levels_set)
3337 __kmp_dflt_max_active_levels = KMP_MAX_ACTIVE_LEVELS_LIMIT;
3342 enum kmp_proc_bind_t bind;
3344 if ((num == (
int)proc_bind_primary) ||
3345 __kmp_match_str(
"master", buf, &next) ||
3346 __kmp_match_str(
"primary", buf, &next)) {
3349 bind = proc_bind_primary;
3350 }
else if ((num == (
int)proc_bind_close) ||
3351 __kmp_match_str(
"close", buf, &next)) {
3354 bind = proc_bind_close;
3355 }
else if ((num == (
int)proc_bind_spread) ||
3356 __kmp_match_str(
"spread", buf, &next)) {
3359 bind = proc_bind_spread;
3361 KMP_WARNING(StgInvalidValue, name, value);
3362 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
3363 __kmp_nested_proc_bind.used = 1;
3367 __kmp_nested_proc_bind.bind_types[i++] = bind;
3371 KMP_DEBUG_ASSERT(*buf ==
',');
3376 if ((*buf >=
'0') && (*buf <=
'9')) {
3379 num = __kmp_str_to_int(buf, *next);
3380 KMP_ASSERT(num >= 0);
3390 KMP_WARNING(ParseExtraCharsWarn, name, buf);
3394 static void __kmp_stg_print_proc_bind(kmp_str_buf_t *buffer,
char const *name,
3396 int nelem = __kmp_nested_proc_bind.used;
3397 if (__kmp_env_format) {
3398 KMP_STR_BUF_PRINT_NAME;
3400 __kmp_str_buf_print(buffer,
" %s", name);
3403 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
3406 __kmp_str_buf_print(buffer,
"='", name);
3407 for (i = 0; i < nelem; i++) {
3408 switch (__kmp_nested_proc_bind.bind_types[i]) {
3409 case proc_bind_false:
3410 __kmp_str_buf_print(buffer,
"false");
3413 case proc_bind_true:
3414 __kmp_str_buf_print(buffer,
"true");
3417 case proc_bind_primary:
3418 __kmp_str_buf_print(buffer,
"primary");
3421 case proc_bind_close:
3422 __kmp_str_buf_print(buffer,
"close");
3425 case proc_bind_spread:
3426 __kmp_str_buf_print(buffer,
"spread");
3429 case proc_bind_intel:
3430 __kmp_str_buf_print(buffer,
"intel");
3433 case proc_bind_default:
3434 __kmp_str_buf_print(buffer,
"default");
3437 if (i < nelem - 1) {
3438 __kmp_str_buf_print(buffer,
",");
3441 __kmp_str_buf_print(buffer,
"'\n");
3445 static void __kmp_stg_parse_display_affinity(
char const *name,
3446 char const *value,
void *data) {
3447 __kmp_stg_parse_bool(name, value, &__kmp_display_affinity);
3449 static void __kmp_stg_print_display_affinity(kmp_str_buf_t *buffer,
3450 char const *name,
void *data) {
3451 __kmp_stg_print_bool(buffer, name, __kmp_display_affinity);
3453 static void __kmp_stg_parse_affinity_format(
char const *name,
char const *value,
3455 size_t length = KMP_STRLEN(value);
3456 __kmp_strncpy_truncate(__kmp_affinity_format, KMP_AFFINITY_FORMAT_SIZE, value,
3459 static void __kmp_stg_print_affinity_format(kmp_str_buf_t *buffer,
3460 char const *name,
void *data) {
3461 if (__kmp_env_format) {
3462 KMP_STR_BUF_PRINT_NAME_EX(name);
3464 __kmp_str_buf_print(buffer,
" %s='", name);
3466 __kmp_str_buf_print(buffer,
"%s'\n", __kmp_affinity_format);
3488 static void __kmp_stg_parse_allocator(
char const *name,
char const *value,
3490 const char *buf = value;
3491 const char *next, *scan, *start;
3493 omp_allocator_handle_t al;
3494 omp_memspace_handle_t ms = omp_default_mem_space;
3495 bool is_memspace =
false;
3496 int ntraits = 0, count = 0;
3500 const char *delim = strchr(buf,
':');
3501 const char *predef_mem_space = strstr(buf,
"mem_space");
3503 bool is_memalloc = (!predef_mem_space && !delim) ?
true :
false;
3508 for (scan = buf; *scan !=
'\0'; scan++) {
3513 omp_alloctrait_t *traits =
3514 (omp_alloctrait_t *)KMP_ALLOCA(ntraits *
sizeof(omp_alloctrait_t));
3517 #define IS_POWER_OF_TWO(n) (((n) & ((n)-1)) == 0)
3519 #define GET_NEXT(sentinel) \
3522 if (*next == sentinel) \
3528 #define SKIP_PAIR(key) \
3530 char const str_delimiter[] = {',', 0}; \
3531 char *value = __kmp_str_token(CCAST(char *, scan), str_delimiter, \
3532 CCAST(char **, &next)); \
3533 KMP_WARNING(StgInvalidValue, key, value); \
3541 char const str_delimiter[] = {'=', 0}; \
3542 key = __kmp_str_token(CCAST(char *, start), str_delimiter, \
3543 CCAST(char **, &next)); \
3548 while (*next !=
'\0') {
3550 __kmp_match_str(
"fb_data", scan, &next)) {
3554 if (__kmp_match_str(
"omp_high_bw_mem_alloc", scan, &next)) {
3557 if (__kmp_memkind_available) {
3558 __kmp_def_allocator = omp_high_bw_mem_alloc;
3561 KMP_WARNING(OmpNoAllocator,
"omp_high_bw_mem_alloc");
3564 traits[count].key = omp_atk_fb_data;
3565 traits[count].value = RCAST(omp_uintptr_t, omp_high_bw_mem_alloc);
3567 }
else if (__kmp_match_str(
"omp_large_cap_mem_alloc", scan, &next)) {
3570 if (__kmp_memkind_available) {
3571 __kmp_def_allocator = omp_large_cap_mem_alloc;
3574 KMP_WARNING(OmpNoAllocator,
"omp_large_cap_mem_alloc");
3577 traits[count].key = omp_atk_fb_data;
3578 traits[count].value = RCAST(omp_uintptr_t, omp_large_cap_mem_alloc);
3580 }
else if (__kmp_match_str(
"omp_default_mem_alloc", scan, &next)) {
3584 traits[count].key = omp_atk_fb_data;
3585 traits[count].value = RCAST(omp_uintptr_t, omp_default_mem_alloc);
3587 }
else if (__kmp_match_str(
"omp_const_mem_alloc", scan, &next)) {
3590 KMP_WARNING(OmpNoAllocator,
"omp_const_mem_alloc");
3592 traits[count].key = omp_atk_fb_data;
3593 traits[count].value = RCAST(omp_uintptr_t, omp_const_mem_alloc);
3595 }
else if (__kmp_match_str(
"omp_low_lat_mem_alloc", scan, &next)) {
3598 KMP_WARNING(OmpNoAllocator,
"omp_low_lat_mem_alloc");
3600 traits[count].key = omp_atk_fb_data;
3601 traits[count].value = RCAST(omp_uintptr_t, omp_low_lat_mem_alloc);
3603 }
else if (__kmp_match_str(
"omp_cgroup_mem_alloc", scan, &next)) {
3606 KMP_WARNING(OmpNoAllocator,
"omp_cgroup_mem_alloc");
3608 traits[count].key = omp_atk_fb_data;
3609 traits[count].value = RCAST(omp_uintptr_t, omp_cgroup_mem_alloc);
3611 }
else if (__kmp_match_str(
"omp_pteam_mem_alloc", scan, &next)) {
3614 KMP_WARNING(OmpNoAllocator,
"omp_pteam_mem_alloc");
3616 traits[count].key = omp_atk_fb_data;
3617 traits[count].value = RCAST(omp_uintptr_t, omp_pteam_mem_alloc);
3619 }
else if (__kmp_match_str(
"omp_thread_mem_alloc", scan, &next)) {
3622 KMP_WARNING(OmpNoAllocator,
"omp_thread_mem_alloc");
3624 traits[count].key = omp_atk_fb_data;
3625 traits[count].value = RCAST(omp_uintptr_t, omp_thread_mem_alloc);
3635 __kmp_def_allocator = omp_default_mem_alloc;
3636 if (next == buf || *next !=
'\0') {
3638 KMP_WARNING(StgInvalidValue, name, value);
3643 if (count == ntraits)
3649 if (__kmp_match_str(
"omp_default_mem_space", scan, &next)) {
3651 ms = omp_default_mem_space;
3652 }
else if (__kmp_match_str(
"omp_large_cap_mem_space", scan, &next)) {
3654 ms = omp_large_cap_mem_space;
3655 }
else if (__kmp_match_str(
"omp_const_mem_space", scan, &next)) {
3657 ms = omp_const_mem_space;
3658 }
else if (__kmp_match_str(
"omp_high_bw_mem_space", scan, &next)) {
3660 ms = omp_high_bw_mem_space;
3661 }
else if (__kmp_match_str(
"omp_low_lat_mem_space", scan, &next)) {
3663 ms = omp_low_lat_mem_space;
3665 __kmp_def_allocator = omp_default_mem_alloc;
3666 if (next == buf || *next !=
'\0') {
3668 KMP_WARNING(StgInvalidValue, name, value);
3677 if (__kmp_match_str(
"sync_hint", scan, &next)) {
3679 traits[count].key = omp_atk_sync_hint;
3680 if (__kmp_match_str(
"contended", scan, &next)) {
3681 traits[count].value = omp_atv_contended;
3682 }
else if (__kmp_match_str(
"uncontended", scan, &next)) {
3683 traits[count].value = omp_atv_uncontended;
3684 }
else if (__kmp_match_str(
"serialized", scan, &next)) {
3685 traits[count].value = omp_atv_serialized;
3686 }
else if (__kmp_match_str(
"private", scan, &next)) {
3687 traits[count].value = omp_atv_private;
3693 }
else if (__kmp_match_str(
"alignment", scan, &next)) {
3695 if (!isdigit(*next)) {
3701 int n = __kmp_str_to_int(scan,
',');
3702 if (n < 0 || !IS_POWER_OF_TWO(n)) {
3707 traits[count].key = omp_atk_alignment;
3708 traits[count].value = n;
3709 }
else if (__kmp_match_str(
"access", scan, &next)) {
3711 traits[count].key = omp_atk_access;
3712 if (__kmp_match_str(
"all", scan, &next)) {
3713 traits[count].value = omp_atv_all;
3714 }
else if (__kmp_match_str(
"cgroup", scan, &next)) {
3715 traits[count].value = omp_atv_cgroup;
3716 }
else if (__kmp_match_str(
"pteam", scan, &next)) {
3717 traits[count].value = omp_atv_pteam;
3718 }
else if (__kmp_match_str(
"thread", scan, &next)) {
3719 traits[count].value = omp_atv_thread;
3725 }
else if (__kmp_match_str(
"pool_size", scan, &next)) {
3727 if (!isdigit(*next)) {
3733 int n = __kmp_str_to_int(scan,
',');
3739 traits[count].key = omp_atk_pool_size;
3740 traits[count].value = n;
3741 }
else if (__kmp_match_str(
"fallback", scan, &next)) {
3743 traits[count].key = omp_atk_fallback;
3744 if (__kmp_match_str(
"default_mem_fb", scan, &next)) {
3745 traits[count].value = omp_atv_default_mem_fb;
3746 }
else if (__kmp_match_str(
"null_fb", scan, &next)) {
3747 traits[count].value = omp_atv_null_fb;
3748 }
else if (__kmp_match_str(
"abort_fb", scan, &next)) {
3749 traits[count].value = omp_atv_abort_fb;
3750 }
else if (__kmp_match_str(
"allocator_fb", scan, &next)) {
3751 traits[count].value = omp_atv_allocator_fb;
3757 }
else if (__kmp_match_str(
"pinned", scan, &next)) {
3759 traits[count].key = omp_atk_pinned;
3760 if (__kmp_str_match_true(next)) {
3761 traits[count].value = omp_atv_true;
3762 }
else if (__kmp_str_match_false(next)) {
3763 traits[count].value = omp_atv_false;
3769 }
else if (__kmp_match_str(
"partition", scan, &next)) {
3771 traits[count].key = omp_atk_partition;
3772 if (__kmp_match_str(
"environment", scan, &next)) {
3773 traits[count].value = omp_atv_environment;
3774 }
else if (__kmp_match_str(
"nearest", scan, &next)) {
3775 traits[count].value = omp_atv_nearest;
3776 }
else if (__kmp_match_str(
"blocked", scan, &next)) {
3777 traits[count].value = omp_atv_blocked;
3778 }
else if (__kmp_match_str(
"interleaved", scan, &next)) {
3779 traits[count].value = omp_atv_interleaved;
3792 if (count == ntraits)
3798 al = __kmpc_init_allocator(__kmp_get_gtid(), ms, ntraits, traits);
3799 __kmp_def_allocator = (al == omp_null_allocator) ? omp_default_mem_alloc : al;
3802 static void __kmp_stg_print_allocator(kmp_str_buf_t *buffer,
char const *name,
3804 if (__kmp_def_allocator == omp_default_mem_alloc) {
3805 __kmp_stg_print_str(buffer, name,
"omp_default_mem_alloc");
3806 }
else if (__kmp_def_allocator == omp_high_bw_mem_alloc) {
3807 __kmp_stg_print_str(buffer, name,
"omp_high_bw_mem_alloc");
3808 }
else if (__kmp_def_allocator == omp_large_cap_mem_alloc) {
3809 __kmp_stg_print_str(buffer, name,
"omp_large_cap_mem_alloc");
3810 }
else if (__kmp_def_allocator == omp_const_mem_alloc) {
3811 __kmp_stg_print_str(buffer, name,
"omp_const_mem_alloc");
3812 }
else if (__kmp_def_allocator == omp_low_lat_mem_alloc) {
3813 __kmp_stg_print_str(buffer, name,
"omp_low_lat_mem_alloc");
3814 }
else if (__kmp_def_allocator == omp_cgroup_mem_alloc) {
3815 __kmp_stg_print_str(buffer, name,
"omp_cgroup_mem_alloc");
3816 }
else if (__kmp_def_allocator == omp_pteam_mem_alloc) {
3817 __kmp_stg_print_str(buffer, name,
"omp_pteam_mem_alloc");
3818 }
else if (__kmp_def_allocator == omp_thread_mem_alloc) {
3819 __kmp_stg_print_str(buffer, name,
"omp_thread_mem_alloc");
3826 static void __kmp_stg_parse_omp_dynamic(
char const *name,
char const *value,
3828 __kmp_stg_parse_bool(name, value, &(__kmp_global.g.g_dynamic));
3831 static void __kmp_stg_print_omp_dynamic(kmp_str_buf_t *buffer,
char const *name,
3833 __kmp_stg_print_bool(buffer, name, __kmp_global.g.g_dynamic);
3836 static void __kmp_stg_parse_kmp_dynamic_mode(
char const *name,
3837 char const *value,
void *data) {
3838 if (TCR_4(__kmp_init_parallel)) {
3839 KMP_WARNING(EnvParallelWarn, name);
3840 __kmp_env_toPrint(name, 0);
3843 #ifdef USE_LOAD_BALANCE
3844 else if (__kmp_str_match(
"load balance", 2, value) ||
3845 __kmp_str_match(
"load_balance", 2, value) ||
3846 __kmp_str_match(
"load-balance", 2, value) ||
3847 __kmp_str_match(
"loadbalance", 2, value) ||
3848 __kmp_str_match(
"balance", 1, value)) {
3849 __kmp_global.g.g_dynamic_mode = dynamic_load_balance;
3852 else if (__kmp_str_match(
"thread limit", 1, value) ||
3853 __kmp_str_match(
"thread_limit", 1, value) ||
3854 __kmp_str_match(
"thread-limit", 1, value) ||
3855 __kmp_str_match(
"threadlimit", 1, value) ||
3856 __kmp_str_match(
"limit", 2, value)) {
3857 __kmp_global.g.g_dynamic_mode = dynamic_thread_limit;
3858 }
else if (__kmp_str_match(
"random", 1, value)) {
3859 __kmp_global.g.g_dynamic_mode = dynamic_random;
3861 KMP_WARNING(StgInvalidValue, name, value);
3865 static void __kmp_stg_print_kmp_dynamic_mode(kmp_str_buf_t *buffer,
3866 char const *name,
void *data) {
3868 if (__kmp_global.g.g_dynamic_mode == dynamic_default) {
3869 __kmp_str_buf_print(buffer,
" %s: %s \n", name, KMP_I18N_STR(NotDefined));
3871 #ifdef USE_LOAD_BALANCE
3872 else if (__kmp_global.g.g_dynamic_mode == dynamic_load_balance) {
3873 __kmp_stg_print_str(buffer, name,
"load balance");
3876 else if (__kmp_global.g.g_dynamic_mode == dynamic_thread_limit) {
3877 __kmp_stg_print_str(buffer, name,
"thread limit");
3878 }
else if (__kmp_global.g.g_dynamic_mode == dynamic_random) {
3879 __kmp_stg_print_str(buffer, name,
"random");
3886 #ifdef USE_LOAD_BALANCE
3891 static void __kmp_stg_parse_ld_balance_interval(
char const *name,
3892 char const *value,
void *data) {
3893 double interval = __kmp_convert_to_double(value);
3894 if (interval >= 0) {
3895 __kmp_load_balance_interval = interval;
3897 KMP_WARNING(StgInvalidValue, name, value);
3901 static void __kmp_stg_print_ld_balance_interval(kmp_str_buf_t *buffer,
3902 char const *name,
void *data) {
3904 __kmp_str_buf_print(buffer,
" %s=%8.6f\n", name,
3905 __kmp_load_balance_interval);
3914 static void __kmp_stg_parse_init_at_fork(
char const *name,
char const *value,
3916 __kmp_stg_parse_bool(name, value, &__kmp_need_register_atfork);
3917 if (__kmp_need_register_atfork) {
3918 __kmp_need_register_atfork_specified = TRUE;
3922 static void __kmp_stg_print_init_at_fork(kmp_str_buf_t *buffer,
3923 char const *name,
void *data) {
3924 __kmp_stg_print_bool(buffer, name, __kmp_need_register_atfork_specified);
3930 static void __kmp_stg_parse_schedule(
char const *name,
char const *value,
3933 if (value != NULL) {
3934 size_t length = KMP_STRLEN(value);
3935 if (length > INT_MAX) {
3936 KMP_WARNING(LongValue, name);
3938 const char *semicolon;
3939 if (value[length - 1] ==
'"' || value[length - 1] ==
'\'')
3940 KMP_WARNING(UnbalancedQuotes, name);
3944 semicolon = strchr(value,
';');
3945 if (*value && semicolon != value) {
3946 const char *comma = strchr(value,
',');
3953 if (!__kmp_strcasecmp_with_sentinel(
"static", value, sentinel)) {
3954 if (!__kmp_strcasecmp_with_sentinel(
"greedy", comma,
';')) {
3955 __kmp_static = kmp_sch_static_greedy;
3957 }
else if (!__kmp_strcasecmp_with_sentinel(
"balanced", comma,
3959 __kmp_static = kmp_sch_static_balanced;
3962 }
else if (!__kmp_strcasecmp_with_sentinel(
"guided", value,
3964 if (!__kmp_strcasecmp_with_sentinel(
"iterative", comma,
';')) {
3965 __kmp_guided = kmp_sch_guided_iterative_chunked;
3967 }
else if (!__kmp_strcasecmp_with_sentinel(
"analytical", comma,
3970 __kmp_guided = kmp_sch_guided_analytical_chunked;
3974 KMP_WARNING(InvalidClause, name, value);
3976 KMP_WARNING(EmptyClause, name);
3977 }
while ((value = semicolon ? semicolon + 1 : NULL));
3983 static void __kmp_stg_print_schedule(kmp_str_buf_t *buffer,
char const *name,
3985 if (__kmp_env_format) {
3986 KMP_STR_BUF_PRINT_NAME_EX(name);
3988 __kmp_str_buf_print(buffer,
" %s='", name);
3990 if (__kmp_static == kmp_sch_static_greedy) {
3991 __kmp_str_buf_print(buffer,
"%s",
"static,greedy");
3992 }
else if (__kmp_static == kmp_sch_static_balanced) {
3993 __kmp_str_buf_print(buffer,
"%s",
"static,balanced");
3995 if (__kmp_guided == kmp_sch_guided_iterative_chunked) {
3996 __kmp_str_buf_print(buffer,
";%s'\n",
"guided,iterative");
3997 }
else if (__kmp_guided == kmp_sch_guided_analytical_chunked) {
3998 __kmp_str_buf_print(buffer,
";%s'\n",
"guided,analytical");
4005 static inline void __kmp_omp_schedule_restore() {
4006 #if KMP_USE_HIER_SCHED
4007 __kmp_hier_scheds.deallocate();
4017 static const char *__kmp_parse_single_omp_schedule(
const char *name,
4019 bool parse_hier =
false) {
4021 const char *ptr = value;
4028 while (*delim !=
',' && *delim !=
':' && *delim !=
'\0')
4030 #if KMP_USE_HIER_SCHED
4031 kmp_hier_layer_e layer = kmp_hier_layer_e::LAYER_THREAD;
4033 if (*delim ==
',') {
4034 if (!__kmp_strcasecmp_with_sentinel(
"L1", ptr,
',')) {
4035 layer = kmp_hier_layer_e::LAYER_L1;
4036 }
else if (!__kmp_strcasecmp_with_sentinel(
"L2", ptr,
',')) {
4037 layer = kmp_hier_layer_e::LAYER_L2;
4038 }
else if (!__kmp_strcasecmp_with_sentinel(
"L3", ptr,
',')) {
4039 layer = kmp_hier_layer_e::LAYER_L3;
4040 }
else if (!__kmp_strcasecmp_with_sentinel(
"NUMA", ptr,
',')) {
4041 layer = kmp_hier_layer_e::LAYER_NUMA;
4044 if (layer != kmp_hier_layer_e::LAYER_THREAD && *delim !=
',') {
4046 KMP_WARNING(StgInvalidValue, name, value);
4047 __kmp_omp_schedule_restore();
4049 }
else if (layer != kmp_hier_layer_e::LAYER_THREAD) {
4051 while (*delim !=
',' && *delim !=
':' && *delim !=
'\0')
4058 if (*delim ==
':') {
4059 if (!__kmp_strcasecmp_with_sentinel(
"monotonic", ptr, *delim)) {
4062 while (*delim !=
',' && *delim !=
':' && *delim !=
'\0')
4064 }
else if (!__kmp_strcasecmp_with_sentinel(
"nonmonotonic", ptr, *delim)) {
4067 while (*delim !=
',' && *delim !=
':' && *delim !=
'\0')
4069 }
else if (!parse_hier) {
4071 KMP_WARNING(StgInvalidValue, name, value);
4072 __kmp_omp_schedule_restore();
4077 if (!__kmp_strcasecmp_with_sentinel(
"dynamic", ptr, *delim))
4078 sched = kmp_sch_dynamic_chunked;
4079 else if (!__kmp_strcasecmp_with_sentinel(
"guided", ptr, *delim))
4082 else if (!__kmp_strcasecmp_with_sentinel(
"auto", ptr, *delim))
4084 else if (!__kmp_strcasecmp_with_sentinel(
"trapezoidal", ptr, *delim))
4085 sched = kmp_sch_trapezoidal;
4086 else if (!__kmp_strcasecmp_with_sentinel(
"static", ptr, *delim))
4088 #if KMP_STATIC_STEAL_ENABLED
4089 else if (!__kmp_strcasecmp_with_sentinel(
"static_steal", ptr, *delim)) {
4091 sched = kmp_sch_dynamic_chunked;
4097 KMP_WARNING(StgInvalidValue, name, value);
4098 __kmp_omp_schedule_restore();
4103 if (*delim ==
',') {
4106 if (!isdigit(*ptr)) {
4108 KMP_WARNING(StgInvalidValue, name, value);
4109 __kmp_omp_schedule_restore();
4115 __kmp_msg(kmp_ms_warning, KMP_MSG(IgnoreChunk, name, delim),
4119 sched = kmp_sch_static_chunked;
4120 chunk = __kmp_str_to_int(delim + 1, *ptr);
4122 chunk = KMP_DEFAULT_CHUNK;
4123 __kmp_msg(kmp_ms_warning, KMP_MSG(InvalidChunk, name, delim),
4125 KMP_INFORM(Using_int_Value, name, __kmp_chunk);
4134 }
else if (chunk > KMP_MAX_CHUNK) {
4135 chunk = KMP_MAX_CHUNK;
4136 __kmp_msg(kmp_ms_warning, KMP_MSG(LargeChunk, name, delim),
4138 KMP_INFORM(Using_int_Value, name, chunk);
4145 SCHEDULE_SET_MODIFIERS(sched, sched_modifier);
4147 #if KMP_USE_HIER_SCHED
4148 if (layer != kmp_hier_layer_e::LAYER_THREAD) {
4149 __kmp_hier_scheds.append(sched, chunk, layer);
4153 __kmp_chunk = chunk;
4154 __kmp_sched = sched;
4159 static void __kmp_stg_parse_omp_schedule(
char const *name,
char const *value,
4162 const char *ptr = value;
4165 length = KMP_STRLEN(value);
4167 if (value[length - 1] ==
'"' || value[length - 1] ==
'\'')
4168 KMP_WARNING(UnbalancedQuotes, name);
4170 #if KMP_USE_HIER_SCHED
4171 if (!__kmp_strcasecmp_with_sentinel(
"EXPERIMENTAL", ptr,
' ')) {
4174 while ((ptr = __kmp_parse_single_omp_schedule(name, ptr,
true))) {
4175 while (*ptr ==
' ' || *ptr ==
'\t' || *ptr ==
':')
4182 __kmp_parse_single_omp_schedule(name, ptr);
4184 KMP_WARNING(EmptyString, name);
4186 #if KMP_USE_HIER_SCHED
4187 __kmp_hier_scheds.sort();
4189 K_DIAG(1, (
"__kmp_static == %d\n", __kmp_static))
4190 K_DIAG(1, (
"__kmp_guided == %d\n", __kmp_guided))
4191 K_DIAG(1, (
"__kmp_sched == %d\n", __kmp_sched))
4192 K_DIAG(1, (
"__kmp_chunk == %d\n", __kmp_chunk))
4195 static void __kmp_stg_print_omp_schedule(kmp_str_buf_t *buffer,
4196 char const *name,
void *data) {
4197 if (__kmp_env_format) {
4198 KMP_STR_BUF_PRINT_NAME_EX(name);
4200 __kmp_str_buf_print(buffer,
" %s='", name);
4202 enum sched_type sched = SCHEDULE_WITHOUT_MODIFIERS(__kmp_sched);
4203 if (SCHEDULE_HAS_MONOTONIC(__kmp_sched)) {
4204 __kmp_str_buf_print(buffer,
"monotonic:");
4205 }
else if (SCHEDULE_HAS_NONMONOTONIC(__kmp_sched)) {
4206 __kmp_str_buf_print(buffer,
"nonmonotonic:");
4210 case kmp_sch_dynamic_chunked:
4211 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"dynamic", __kmp_chunk);
4213 case kmp_sch_guided_iterative_chunked:
4214 case kmp_sch_guided_analytical_chunked:
4215 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"guided", __kmp_chunk);
4217 case kmp_sch_trapezoidal:
4218 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"trapezoidal", __kmp_chunk);
4221 case kmp_sch_static_chunked:
4222 case kmp_sch_static_balanced:
4223 case kmp_sch_static_greedy:
4224 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"static", __kmp_chunk);
4226 case kmp_sch_static_steal:
4227 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"static_steal", __kmp_chunk);
4230 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"auto", __kmp_chunk);
4235 case kmp_sch_dynamic_chunked:
4236 __kmp_str_buf_print(buffer,
"%s'\n",
"dynamic");
4238 case kmp_sch_guided_iterative_chunked:
4239 case kmp_sch_guided_analytical_chunked:
4240 __kmp_str_buf_print(buffer,
"%s'\n",
"guided");
4242 case kmp_sch_trapezoidal:
4243 __kmp_str_buf_print(buffer,
"%s'\n",
"trapezoidal");
4246 case kmp_sch_static_chunked:
4247 case kmp_sch_static_balanced:
4248 case kmp_sch_static_greedy:
4249 __kmp_str_buf_print(buffer,
"%s'\n",
"static");
4251 case kmp_sch_static_steal:
4252 __kmp_str_buf_print(buffer,
"%s'\n",
"static_steal");
4255 __kmp_str_buf_print(buffer,
"%s'\n",
"auto");
4261 #if KMP_USE_HIER_SCHED
4264 static void __kmp_stg_parse_kmp_hand_thread(
char const *name,
char const *value,
4266 __kmp_stg_parse_bool(name, value, &(__kmp_dispatch_hand_threading));
4269 static void __kmp_stg_print_kmp_hand_thread(kmp_str_buf_t *buffer,
4270 char const *name,
void *data) {
4271 __kmp_stg_print_bool(buffer, name, __kmp_dispatch_hand_threading);
4277 static void __kmp_stg_parse_kmp_force_monotonic(
char const *name,
4278 char const *value,
void *data) {
4279 __kmp_stg_parse_bool(name, value, &(__kmp_force_monotonic));
4282 static void __kmp_stg_print_kmp_force_monotonic(kmp_str_buf_t *buffer,
4283 char const *name,
void *data) {
4284 __kmp_stg_print_bool(buffer, name, __kmp_force_monotonic);
4290 static void __kmp_stg_parse_atomic_mode(
char const *name,
char const *value,
4296 #ifdef KMP_GOMP_COMPAT
4299 __kmp_stg_parse_int(name, value, 0, max, &mode);
4304 __kmp_atomic_mode = mode;
4308 static void __kmp_stg_print_atomic_mode(kmp_str_buf_t *buffer,
char const *name,
4310 __kmp_stg_print_int(buffer, name, __kmp_atomic_mode);
4316 static void __kmp_stg_parse_consistency_check(
char const *name,
4317 char const *value,
void *data) {
4318 if (!__kmp_strcasecmp_with_sentinel(
"all", value, 0)) {
4324 __kmp_env_consistency_check = TRUE;
4325 }
else if (!__kmp_strcasecmp_with_sentinel(
"none", value, 0)) {
4326 __kmp_env_consistency_check = FALSE;
4328 KMP_WARNING(StgInvalidValue, name, value);
4332 static void __kmp_stg_print_consistency_check(kmp_str_buf_t *buffer,
4333 char const *name,
void *data) {
4335 const char *value = NULL;
4337 if (__kmp_env_consistency_check) {
4343 if (value != NULL) {
4344 __kmp_stg_print_str(buffer, name, value);
4355 static void __kmp_stg_parse_itt_prepare_delay(
char const *name,
4356 char const *value,
void *data) {
4360 __kmp_stg_parse_int(name, value, 0, INT_MAX, &delay);
4361 __kmp_itt_prepare_delay = delay;
4364 static void __kmp_stg_print_itt_prepare_delay(kmp_str_buf_t *buffer,
4365 char const *name,
void *data) {
4366 __kmp_stg_print_uint64(buffer, name, __kmp_itt_prepare_delay);
4376 static void __kmp_stg_parse_malloc_pool_incr(
char const *name,
4377 char const *value,
void *data) {
4378 __kmp_stg_parse_size(name, value, KMP_MIN_MALLOC_POOL_INCR,
4379 KMP_MAX_MALLOC_POOL_INCR, NULL, &__kmp_malloc_pool_incr,
4383 static void __kmp_stg_print_malloc_pool_incr(kmp_str_buf_t *buffer,
4384 char const *name,
void *data) {
4385 __kmp_stg_print_size(buffer, name, __kmp_malloc_pool_incr);
4394 static void __kmp_stg_parse_par_range_env(
char const *name,
char const *value,
4396 __kmp_stg_parse_par_range(name, value, &__kmp_par_range,
4397 __kmp_par_range_routine, __kmp_par_range_filename,
4398 &__kmp_par_range_lb, &__kmp_par_range_ub);
4401 static void __kmp_stg_print_par_range_env(kmp_str_buf_t *buffer,
4402 char const *name,
void *data) {
4403 if (__kmp_par_range != 0) {
4404 __kmp_stg_print_str(buffer, name, par_range_to_print);
4413 static void __kmp_stg_parse_gtid_mode(
char const *name,
char const *value,
4423 #ifdef KMP_TDATA_GTID
4426 __kmp_stg_parse_int(name, value, 0, max, &mode);
4430 __kmp_adjust_gtid_mode = TRUE;
4432 __kmp_gtid_mode = mode;
4433 __kmp_adjust_gtid_mode = FALSE;
4437 static void __kmp_stg_print_gtid_mode(kmp_str_buf_t *buffer,
char const *name,
4439 if (__kmp_adjust_gtid_mode) {
4440 __kmp_stg_print_int(buffer, name, 0);
4442 __kmp_stg_print_int(buffer, name, __kmp_gtid_mode);
4449 static void __kmp_stg_parse_lock_block(
char const *name,
char const *value,
4451 __kmp_stg_parse_int(name, value, 0, KMP_INT_MAX, &__kmp_num_locks_in_block);
4454 static void __kmp_stg_print_lock_block(kmp_str_buf_t *buffer,
char const *name,
4456 __kmp_stg_print_int(buffer, name, __kmp_num_locks_in_block);
4462 #if KMP_USE_DYNAMIC_LOCK
4463 #define KMP_STORE_LOCK_SEQ(a) (__kmp_user_lock_seq = lockseq_##a)
4465 #define KMP_STORE_LOCK_SEQ(a)
4468 static void __kmp_stg_parse_lock_kind(
char const *name,
char const *value,
4470 if (__kmp_init_user_locks) {
4471 KMP_WARNING(EnvLockWarn, name);
4475 if (__kmp_str_match(
"tas", 2, value) ||
4476 __kmp_str_match(
"test and set", 2, value) ||
4477 __kmp_str_match(
"test_and_set", 2, value) ||
4478 __kmp_str_match(
"test-and-set", 2, value) ||
4479 __kmp_str_match(
"test andset", 2, value) ||
4480 __kmp_str_match(
"test_andset", 2, value) ||
4481 __kmp_str_match(
"test-andset", 2, value) ||
4482 __kmp_str_match(
"testand set", 2, value) ||
4483 __kmp_str_match(
"testand_set", 2, value) ||
4484 __kmp_str_match(
"testand-set", 2, value) ||
4485 __kmp_str_match(
"testandset", 2, value)) {
4486 __kmp_user_lock_kind = lk_tas;
4487 KMP_STORE_LOCK_SEQ(tas);
4490 else if (__kmp_str_match(
"futex", 1, value)) {
4491 if (__kmp_futex_determine_capable()) {
4492 __kmp_user_lock_kind = lk_futex;
4493 KMP_STORE_LOCK_SEQ(futex);
4495 KMP_WARNING(FutexNotSupported, name, value);
4499 else if (__kmp_str_match(
"ticket", 2, value)) {
4500 __kmp_user_lock_kind = lk_ticket;
4501 KMP_STORE_LOCK_SEQ(ticket);
4502 }
else if (__kmp_str_match(
"queuing", 1, value) ||
4503 __kmp_str_match(
"queue", 1, value)) {
4504 __kmp_user_lock_kind = lk_queuing;
4505 KMP_STORE_LOCK_SEQ(queuing);
4506 }
else if (__kmp_str_match(
"drdpa ticket", 1, value) ||
4507 __kmp_str_match(
"drdpa_ticket", 1, value) ||
4508 __kmp_str_match(
"drdpa-ticket", 1, value) ||
4509 __kmp_str_match(
"drdpaticket", 1, value) ||
4510 __kmp_str_match(
"drdpa", 1, value)) {
4511 __kmp_user_lock_kind = lk_drdpa;
4512 KMP_STORE_LOCK_SEQ(drdpa);
4514 #if KMP_USE_ADAPTIVE_LOCKS
4515 else if (__kmp_str_match(
"adaptive", 1, value)) {
4516 if (__kmp_cpuinfo.flags.rtm) {
4517 __kmp_user_lock_kind = lk_adaptive;
4518 KMP_STORE_LOCK_SEQ(adaptive);
4520 KMP_WARNING(AdaptiveNotSupported, name, value);
4521 __kmp_user_lock_kind = lk_queuing;
4522 KMP_STORE_LOCK_SEQ(queuing);
4526 #if KMP_USE_DYNAMIC_LOCK && KMP_USE_TSX
4527 else if (__kmp_str_match(
"rtm_queuing", 1, value)) {
4528 if (__kmp_cpuinfo.flags.rtm) {
4529 __kmp_user_lock_kind = lk_rtm_queuing;
4530 KMP_STORE_LOCK_SEQ(rtm_queuing);
4532 KMP_WARNING(AdaptiveNotSupported, name, value);
4533 __kmp_user_lock_kind = lk_queuing;
4534 KMP_STORE_LOCK_SEQ(queuing);
4536 }
else if (__kmp_str_match(
"rtm_spin", 1, value)) {
4537 if (__kmp_cpuinfo.flags.rtm) {
4538 __kmp_user_lock_kind = lk_rtm_spin;
4539 KMP_STORE_LOCK_SEQ(rtm_spin);
4541 KMP_WARNING(AdaptiveNotSupported, name, value);
4542 __kmp_user_lock_kind = lk_tas;
4543 KMP_STORE_LOCK_SEQ(queuing);
4545 }
else if (__kmp_str_match(
"hle", 1, value)) {
4546 __kmp_user_lock_kind = lk_hle;
4547 KMP_STORE_LOCK_SEQ(hle);
4551 KMP_WARNING(StgInvalidValue, name, value);
4555 static void __kmp_stg_print_lock_kind(kmp_str_buf_t *buffer,
char const *name,
4557 const char *value = NULL;
4559 switch (__kmp_user_lock_kind) {
4574 #if KMP_USE_DYNAMIC_LOCK && KMP_USE_TSX
4575 case lk_rtm_queuing:
4576 value =
"rtm_queuing";
4599 #if KMP_USE_ADAPTIVE_LOCKS
4606 if (value != NULL) {
4607 __kmp_stg_print_str(buffer, name, value);
4616 static void __kmp_stg_parse_spin_backoff_params(
const char *name,
4617 const char *value,
void *data) {
4618 const char *next = value;
4621 int prev_comma = FALSE;
4624 kmp_uint32 max_backoff = __kmp_spin_backoff_params.max_backoff;
4625 kmp_uint32 min_tick = __kmp_spin_backoff_params.min_tick;
4629 for (i = 0; i < 3; i++) {
4632 if (*next ==
'\0') {
4637 if (((*next < '0' || *next >
'9') && *next !=
',') || total > 2) {
4638 KMP_WARNING(EnvSyntaxError, name, value);
4644 if (total == 0 || prev_comma) {
4652 if (*next >=
'0' && *next <=
'9') {
4654 const char *buf = next;
4655 char const *msg = NULL;
4660 const char *tmp = next;
4662 if ((*next ==
' ' || *next ==
'\t') && (*tmp >=
'0' && *tmp <=
'9')) {
4663 KMP_WARNING(EnvSpacesNotAllowed, name, value);
4667 num = __kmp_str_to_int(buf, *next);
4669 msg = KMP_I18N_STR(ValueTooSmall);
4671 }
else if (num > KMP_INT_MAX) {
4672 msg = KMP_I18N_STR(ValueTooLarge);
4677 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
4678 KMP_INFORM(Using_int_Value, name, num);
4682 }
else if (total == 2) {
4687 KMP_DEBUG_ASSERT(total > 0);
4689 KMP_WARNING(EnvSyntaxError, name, value);
4692 __kmp_spin_backoff_params.max_backoff = max_backoff;
4693 __kmp_spin_backoff_params.min_tick = min_tick;
4696 static void __kmp_stg_print_spin_backoff_params(kmp_str_buf_t *buffer,
4697 char const *name,
void *data) {
4698 if (__kmp_env_format) {
4699 KMP_STR_BUF_PRINT_NAME_EX(name);
4701 __kmp_str_buf_print(buffer,
" %s='", name);
4703 __kmp_str_buf_print(buffer,
"%d,%d'\n", __kmp_spin_backoff_params.max_backoff,
4704 __kmp_spin_backoff_params.min_tick);
4707 #if KMP_USE_ADAPTIVE_LOCKS
4714 static void __kmp_stg_parse_adaptive_lock_props(
const char *name,
4715 const char *value,
void *data) {
4716 int max_retries = 0;
4717 int max_badness = 0;
4719 const char *next = value;
4722 int prev_comma = FALSE;
4728 for (i = 0; i < 3; i++) {
4731 if (*next ==
'\0') {
4736 if (((*next < '0' || *next >
'9') && *next !=
',') || total > 2) {
4737 KMP_WARNING(EnvSyntaxError, name, value);
4743 if (total == 0 || prev_comma) {
4751 if (*next >=
'0' && *next <=
'9') {
4753 const char *buf = next;
4754 char const *msg = NULL;
4759 const char *tmp = next;
4761 if ((*next ==
' ' || *next ==
'\t') && (*tmp >=
'0' && *tmp <=
'9')) {
4762 KMP_WARNING(EnvSpacesNotAllowed, name, value);
4766 num = __kmp_str_to_int(buf, *next);
4768 msg = KMP_I18N_STR(ValueTooSmall);
4770 }
else if (num > KMP_INT_MAX) {
4771 msg = KMP_I18N_STR(ValueTooLarge);
4776 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
4777 KMP_INFORM(Using_int_Value, name, num);
4781 }
else if (total == 2) {
4786 KMP_DEBUG_ASSERT(total > 0);
4788 KMP_WARNING(EnvSyntaxError, name, value);
4791 __kmp_adaptive_backoff_params.max_soft_retries = max_retries;
4792 __kmp_adaptive_backoff_params.max_badness = max_badness;
4795 static void __kmp_stg_print_adaptive_lock_props(kmp_str_buf_t *buffer,
4796 char const *name,
void *data) {
4797 if (__kmp_env_format) {
4798 KMP_STR_BUF_PRINT_NAME_EX(name);
4800 __kmp_str_buf_print(buffer,
" %s='", name);
4802 __kmp_str_buf_print(buffer,
"%d,%d'\n",
4803 __kmp_adaptive_backoff_params.max_soft_retries,
4804 __kmp_adaptive_backoff_params.max_badness);
4807 #if KMP_DEBUG_ADAPTIVE_LOCKS
4809 static void __kmp_stg_parse_speculative_statsfile(
char const *name,
4812 __kmp_stg_parse_file(name, value,
"",
4813 CCAST(
char **, &__kmp_speculative_statsfile));
4816 static void __kmp_stg_print_speculative_statsfile(kmp_str_buf_t *buffer,
4819 if (__kmp_str_match(
"-", 0, __kmp_speculative_statsfile)) {
4820 __kmp_stg_print_str(buffer, name,
"stdout");
4822 __kmp_stg_print_str(buffer, name, __kmp_speculative_statsfile);
4838 static kmp_hw_t __kmp_hw_subset_break_tie(
const kmp_hw_t *possible,
4839 size_t num_possible) {
4840 for (
size_t i = 0; i < num_possible; ++i) {
4841 if (possible[i] == KMP_HW_THREAD)
4842 return KMP_HW_THREAD;
4843 else if (possible[i] == KMP_HW_CORE)
4845 else if (possible[i] == KMP_HW_SOCKET)
4846 return KMP_HW_SOCKET;
4848 return KMP_HW_UNKNOWN;
4855 static kmp_hw_t __kmp_stg_parse_hw_subset_name(
char const *token) {
4856 size_t index, num_possible, token_length;
4857 kmp_hw_t possible[KMP_HW_LAST];
4863 while (isalnum(*end) || *end ==
'_') {
4870 KMP_FOREACH_HW_TYPE(type) { possible[num_possible++] = type; }
4877 while (num_possible > 1 && index < token_length) {
4878 size_t n = num_possible;
4879 char token_char = (char)toupper(token[index]);
4880 for (
size_t i = 0; i < n; ++i) {
4882 kmp_hw_t type = possible[i];
4883 s = __kmp_hw_get_keyword(type,
false);
4884 if (index < KMP_STRLEN(s)) {
4885 char c = (char)toupper(s[index]);
4887 if (c != token_char) {
4888 possible[i] = KMP_HW_UNKNOWN;
4895 for (
size_t i = 0; i < n; ++i) {
4896 if (possible[i] != KMP_HW_UNKNOWN) {
4897 kmp_hw_t temp = possible[i];
4898 possible[i] = possible[start];
4899 possible[start] = temp;
4903 KMP_ASSERT(start == num_possible);
4909 if (num_possible > 1)
4910 return __kmp_hw_subset_break_tie(possible, num_possible);
4911 if (num_possible == 1)
4913 return KMP_HW_UNKNOWN;
4918 #define MAX_T_LEVEL KMP_HW_LAST
4919 #define MAX_STR_LEN 512
4920 static void __kmp_stg_parse_hw_subset(
char const *name,
char const *value,
4924 kmp_setting_t **rivals = (kmp_setting_t **)data;
4925 if (strcmp(name,
"KMP_PLACE_THREADS") == 0) {
4926 KMP_INFORM(EnvVarDeprecated, name,
"KMP_HW_SUBSET");
4928 if (__kmp_stg_check_rivals(name, value, rivals)) {
4932 char *components[MAX_T_LEVEL];
4933 char const *digits =
"0123456789";
4934 char input[MAX_STR_LEN];
4935 size_t len = 0, mlen = MAX_STR_LEN;
4937 bool absolute =
false;
4939 char *pos = CCAST(
char *, value);
4940 while (*pos && mlen) {
4942 if (len == 0 && *pos ==
':') {
4945 input[len] = (char)(toupper(*pos));
4946 if (input[len] ==
'X')
4948 if (input[len] ==
'O' && strchr(digits, *(pos + 1)))
4956 if (len == 0 || mlen == 0) {
4962 components[level++] = pos;
4963 while ((pos = strchr(pos,
','))) {
4964 if (level >= MAX_T_LEVEL)
4967 components[level++] = ++pos;
4970 __kmp_hw_subset = kmp_hw_subset_t::allocate();
4972 __kmp_hw_subset->set_absolute();
4975 for (
int i = 0; i < level; ++i) {
4977 char *core_components[MAX_T_LEVEL];
4979 pos = components[i];
4980 core_components[core_level++] = pos;
4981 while ((pos = strchr(pos,
'&'))) {
4982 if (core_level >= MAX_T_LEVEL)
4985 core_components[core_level++] = ++pos;
4988 for (
int j = 0; j < core_level; ++j) {
4995 if (isdigit(*core_components[j])) {
4996 num = atoi(core_components[j]);
5000 pos = core_components[j] + strspn(core_components[j], digits);
5001 }
else if (*core_components[j] ==
'*') {
5002 num = kmp_hw_subset_t::USE_ALL;
5003 pos = core_components[j] + 1;
5005 num = kmp_hw_subset_t::USE_ALL;
5006 pos = core_components[j];
5009 offset_ptr = strchr(core_components[j],
'@');
5010 attr_ptr = strchr(core_components[j],
':');
5013 offset = atoi(offset_ptr + 1);
5019 #if KMP_ARCH_X86 || KMP_ARCH_X86_64
5020 if (__kmp_str_match(
"intel_core", -1, attr_ptr + 1)) {
5021 attr.set_core_type(KMP_HW_CORE_TYPE_CORE);
5022 }
else if (__kmp_str_match(
"intel_atom", -1, attr_ptr + 1)) {
5023 attr.set_core_type(KMP_HW_CORE_TYPE_ATOM);
5026 if (__kmp_str_match(
"eff", 3, attr_ptr + 1)) {
5027 const char *number = attr_ptr + 1;
5029 while (isalpha(*number))
5031 if (!isdigit(*number)) {
5034 int efficiency = atoi(number);
5035 attr.set_core_eff(efficiency);
5042 kmp_hw_t type = __kmp_stg_parse_hw_subset_name(pos);
5043 if (type == KMP_HW_UNKNOWN) {
5047 if (attr && type != KMP_HW_CORE)
5050 if (type != KMP_HW_CORE && __kmp_hw_subset->specified(type)) {
5053 __kmp_hw_subset->push_back(num, type, offset, attr);
5058 KMP_WARNING(AffHWSubsetInvalid, name, value);
5059 if (__kmp_hw_subset) {
5060 kmp_hw_subset_t::deallocate(__kmp_hw_subset);
5061 __kmp_hw_subset =
nullptr;
5066 static inline const char *
5067 __kmp_hw_get_core_type_keyword(kmp_hw_core_type_t type) {
5069 case KMP_HW_CORE_TYPE_UNKNOWN:
5071 #if KMP_ARCH_X86 || KMP_ARCH_X86_64
5072 case KMP_HW_CORE_TYPE_ATOM:
5073 return "intel_atom";
5074 case KMP_HW_CORE_TYPE_CORE:
5075 return "intel_core";
5081 static void __kmp_stg_print_hw_subset(kmp_str_buf_t *buffer,
char const *name,
5085 if (!__kmp_hw_subset)
5087 __kmp_str_buf_init(&buf);
5088 if (__kmp_env_format)
5089 KMP_STR_BUF_PRINT_NAME_EX(name);
5091 __kmp_str_buf_print(buffer,
" %s='", name);
5093 depth = __kmp_hw_subset->get_depth();
5094 for (
int i = 0; i < depth; ++i) {
5095 const auto &item = __kmp_hw_subset->at(i);
5097 __kmp_str_buf_print(&buf,
"%c",
',');
5098 for (
int j = 0; j < item.num_attrs; ++j) {
5099 __kmp_str_buf_print(&buf,
"%s%d%s", (j > 0 ?
"&" :
""), item.num[j],
5100 __kmp_hw_get_keyword(item.type));
5101 if (item.attr[j].is_core_type_valid())
5102 __kmp_str_buf_print(
5104 __kmp_hw_get_core_type_keyword(item.attr[j].get_core_type()));
5105 if (item.attr[j].is_core_eff_valid())
5106 __kmp_str_buf_print(&buf,
":eff%d", item.attr[j].get_core_eff());
5108 __kmp_str_buf_print(&buf,
"@%d", item.offset[j]);
5111 __kmp_str_buf_print(buffer,
"%s'\n", buf.str);
5112 __kmp_str_buf_free(&buf);
5119 static void __kmp_stg_parse_forkjoin_frames(
char const *name,
char const *value,
5121 __kmp_stg_parse_bool(name, value, &__kmp_forkjoin_frames);
5124 static void __kmp_stg_print_forkjoin_frames(kmp_str_buf_t *buffer,
5125 char const *name,
void *data) {
5126 __kmp_stg_print_bool(buffer, name, __kmp_forkjoin_frames);
5132 static void __kmp_stg_parse_forkjoin_frames_mode(
char const *name,
5135 __kmp_stg_parse_int(name, value, 0, 3, &__kmp_forkjoin_frames_mode);
5138 static void __kmp_stg_print_forkjoin_frames_mode(kmp_str_buf_t *buffer,
5139 char const *name,
void *data) {
5140 __kmp_stg_print_int(buffer, name, __kmp_forkjoin_frames_mode);
5147 static void __kmp_stg_parse_task_throttling(
char const *name,
char const *value,
5149 __kmp_stg_parse_bool(name, value, &__kmp_enable_task_throttling);
5152 static void __kmp_stg_print_task_throttling(kmp_str_buf_t *buffer,
5153 char const *name,
void *data) {
5154 __kmp_stg_print_bool(buffer, name, __kmp_enable_task_throttling);
5157 #if KMP_HAVE_MWAIT || KMP_HAVE_UMWAIT
5161 static void __kmp_stg_parse_user_level_mwait(
char const *name,
5162 char const *value,
void *data) {
5163 __kmp_stg_parse_bool(name, value, &__kmp_user_level_mwait);
5166 static void __kmp_stg_print_user_level_mwait(kmp_str_buf_t *buffer,
5167 char const *name,
void *data) {
5168 __kmp_stg_print_bool(buffer, name, __kmp_user_level_mwait);
5174 static void __kmp_stg_parse_mwait_hints(
char const *name,
char const *value,
5176 __kmp_stg_parse_int(name, value, 0, INT_MAX, &__kmp_mwait_hints);
5179 static void __kmp_stg_print_mwait_hints(kmp_str_buf_t *buffer,
char const *name,
5181 __kmp_stg_print_int(buffer, name, __kmp_mwait_hints);
5191 static void __kmp_stg_parse_tpause(
char const *name,
char const *value,
5193 __kmp_stg_parse_int(name, value, 0, INT_MAX, &__kmp_tpause_state);
5194 if (__kmp_tpause_state != 0) {
5196 if (__kmp_tpause_state == 2)
5197 __kmp_tpause_hint = 0;
5201 static void __kmp_stg_print_tpause(kmp_str_buf_t *buffer,
char const *name,
5203 __kmp_stg_print_int(buffer, name, __kmp_tpause_state);
5210 static void __kmp_stg_parse_omp_display_env(
char const *name,
char const *value,
5212 if (__kmp_str_match(
"VERBOSE", 1, value)) {
5213 __kmp_display_env_verbose = TRUE;
5215 __kmp_stg_parse_bool(name, value, &__kmp_display_env);
5219 static void __kmp_stg_print_omp_display_env(kmp_str_buf_t *buffer,
5220 char const *name,
void *data) {
5221 if (__kmp_display_env_verbose) {
5222 __kmp_stg_print_str(buffer, name,
"VERBOSE");
5224 __kmp_stg_print_bool(buffer, name, __kmp_display_env);
5228 static void __kmp_stg_parse_omp_cancellation(
char const *name,
5229 char const *value,
void *data) {
5230 if (TCR_4(__kmp_init_parallel)) {
5231 KMP_WARNING(EnvParallelWarn, name);
5234 __kmp_stg_parse_bool(name, value, &__kmp_omp_cancellation);
5237 static void __kmp_stg_print_omp_cancellation(kmp_str_buf_t *buffer,
5238 char const *name,
void *data) {
5239 __kmp_stg_print_bool(buffer, name, __kmp_omp_cancellation);
5245 static void __kmp_stg_parse_omp_tool(
char const *name,
char const *value,
5247 __kmp_stg_parse_bool(name, value, &__kmp_tool);
5250 static void __kmp_stg_print_omp_tool(kmp_str_buf_t *buffer,
char const *name,
5252 if (__kmp_env_format) {
5253 KMP_STR_BUF_PRINT_BOOL_EX(name, __kmp_tool,
"enabled",
"disabled");
5255 __kmp_str_buf_print(buffer,
" %s=%s\n", name,
5256 __kmp_tool ?
"enabled" :
"disabled");
5260 char *__kmp_tool_libraries = NULL;
5262 static void __kmp_stg_parse_omp_tool_libraries(
char const *name,
5263 char const *value,
void *data) {
5264 __kmp_stg_parse_str(name, value, &__kmp_tool_libraries);
5267 static void __kmp_stg_print_omp_tool_libraries(kmp_str_buf_t *buffer,
5268 char const *name,
void *data) {
5269 if (__kmp_tool_libraries)
5270 __kmp_stg_print_str(buffer, name, __kmp_tool_libraries);
5272 if (__kmp_env_format) {
5273 KMP_STR_BUF_PRINT_NAME;
5275 __kmp_str_buf_print(buffer,
" %s", name);
5277 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
5281 char *__kmp_tool_verbose_init = NULL;
5283 static void __kmp_stg_parse_omp_tool_verbose_init(
char const *name,
5286 __kmp_stg_parse_str(name, value, &__kmp_tool_verbose_init);
5289 static void __kmp_stg_print_omp_tool_verbose_init(kmp_str_buf_t *buffer,
5292 if (__kmp_tool_verbose_init)
5293 __kmp_stg_print_str(buffer, name, __kmp_tool_verbose_init);
5295 if (__kmp_env_format) {
5296 KMP_STR_BUF_PRINT_NAME;
5298 __kmp_str_buf_print(buffer,
" %s", name);
5300 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
5308 static kmp_setting_t __kmp_stg_table[] = {
5310 {
"KMP_ALL_THREADS", __kmp_stg_parse_device_thread_limit, NULL, NULL, 0, 0},
5311 {
"KMP_BLOCKTIME", __kmp_stg_parse_blocktime, __kmp_stg_print_blocktime,
5313 {
"KMP_USE_YIELD", __kmp_stg_parse_use_yield, __kmp_stg_print_use_yield,
5315 {
"KMP_DUPLICATE_LIB_OK", __kmp_stg_parse_duplicate_lib_ok,
5316 __kmp_stg_print_duplicate_lib_ok, NULL, 0, 0},
5317 {
"KMP_LIBRARY", __kmp_stg_parse_wait_policy, __kmp_stg_print_wait_policy,
5319 {
"KMP_DEVICE_THREAD_LIMIT", __kmp_stg_parse_device_thread_limit,
5320 __kmp_stg_print_device_thread_limit, NULL, 0, 0},
5322 {
"KMP_MONITOR_STACKSIZE", __kmp_stg_parse_monitor_stacksize,
5323 __kmp_stg_print_monitor_stacksize, NULL, 0, 0},
5325 {
"KMP_SETTINGS", __kmp_stg_parse_settings, __kmp_stg_print_settings, NULL,
5327 {
"KMP_STACKOFFSET", __kmp_stg_parse_stackoffset,
5328 __kmp_stg_print_stackoffset, NULL, 0, 0},
5329 {
"KMP_STACKSIZE", __kmp_stg_parse_stacksize, __kmp_stg_print_stacksize,
5331 {
"KMP_STACKPAD", __kmp_stg_parse_stackpad, __kmp_stg_print_stackpad, NULL,
5333 {
"KMP_VERSION", __kmp_stg_parse_version, __kmp_stg_print_version, NULL, 0,
5335 {
"KMP_WARNINGS", __kmp_stg_parse_warnings, __kmp_stg_print_warnings, NULL,
5338 {
"KMP_NESTING_MODE", __kmp_stg_parse_nesting_mode,
5339 __kmp_stg_print_nesting_mode, NULL, 0, 0},
5340 {
"OMP_NESTED", __kmp_stg_parse_nested, __kmp_stg_print_nested, NULL, 0, 0},
5341 {
"OMP_NUM_THREADS", __kmp_stg_parse_num_threads,
5342 __kmp_stg_print_num_threads, NULL, 0, 0},
5343 {
"OMP_STACKSIZE", __kmp_stg_parse_stacksize, __kmp_stg_print_stacksize,
5346 {
"KMP_TASKING", __kmp_stg_parse_tasking, __kmp_stg_print_tasking, NULL, 0,
5348 {
"KMP_TASK_STEALING_CONSTRAINT", __kmp_stg_parse_task_stealing,
5349 __kmp_stg_print_task_stealing, NULL, 0, 0},
5350 {
"OMP_MAX_ACTIVE_LEVELS", __kmp_stg_parse_max_active_levels,
5351 __kmp_stg_print_max_active_levels, NULL, 0, 0},
5352 {
"OMP_DEFAULT_DEVICE", __kmp_stg_parse_default_device,
5353 __kmp_stg_print_default_device, NULL, 0, 0},
5354 {
"OMP_TARGET_OFFLOAD", __kmp_stg_parse_target_offload,
5355 __kmp_stg_print_target_offload, NULL, 0, 0},
5356 {
"OMP_MAX_TASK_PRIORITY", __kmp_stg_parse_max_task_priority,
5357 __kmp_stg_print_max_task_priority, NULL, 0, 0},
5358 {
"KMP_TASKLOOP_MIN_TASKS", __kmp_stg_parse_taskloop_min_tasks,
5359 __kmp_stg_print_taskloop_min_tasks, NULL, 0, 0},
5360 {
"OMP_THREAD_LIMIT", __kmp_stg_parse_thread_limit,
5361 __kmp_stg_print_thread_limit, NULL, 0, 0},
5362 {
"KMP_TEAMS_THREAD_LIMIT", __kmp_stg_parse_teams_thread_limit,
5363 __kmp_stg_print_teams_thread_limit, NULL, 0, 0},
5364 {
"OMP_NUM_TEAMS", __kmp_stg_parse_nteams, __kmp_stg_print_nteams, NULL, 0,
5366 {
"OMP_TEAMS_THREAD_LIMIT", __kmp_stg_parse_teams_th_limit,
5367 __kmp_stg_print_teams_th_limit, NULL, 0, 0},
5368 {
"OMP_WAIT_POLICY", __kmp_stg_parse_wait_policy,
5369 __kmp_stg_print_wait_policy, NULL, 0, 0},
5370 {
"KMP_DISP_NUM_BUFFERS", __kmp_stg_parse_disp_buffers,
5371 __kmp_stg_print_disp_buffers, NULL, 0, 0},
5372 #if KMP_NESTED_HOT_TEAMS
5373 {
"KMP_HOT_TEAMS_MAX_LEVEL", __kmp_stg_parse_hot_teams_level,
5374 __kmp_stg_print_hot_teams_level, NULL, 0, 0},
5375 {
"KMP_HOT_TEAMS_MODE", __kmp_stg_parse_hot_teams_mode,
5376 __kmp_stg_print_hot_teams_mode, NULL, 0, 0},
5379 #if KMP_HANDLE_SIGNALS
5380 {
"KMP_HANDLE_SIGNALS", __kmp_stg_parse_handle_signals,
5381 __kmp_stg_print_handle_signals, NULL, 0, 0},
5384 #if KMP_ARCH_X86 || KMP_ARCH_X86_64
5385 {
"KMP_INHERIT_FP_CONTROL", __kmp_stg_parse_inherit_fp_control,
5386 __kmp_stg_print_inherit_fp_control, NULL, 0, 0},
5389 #ifdef KMP_GOMP_COMPAT
5390 {
"GOMP_STACKSIZE", __kmp_stg_parse_stacksize, NULL, NULL, 0, 0},
5394 {
"KMP_A_DEBUG", __kmp_stg_parse_a_debug, __kmp_stg_print_a_debug, NULL, 0,
5396 {
"KMP_B_DEBUG", __kmp_stg_parse_b_debug, __kmp_stg_print_b_debug, NULL, 0,
5398 {
"KMP_C_DEBUG", __kmp_stg_parse_c_debug, __kmp_stg_print_c_debug, NULL, 0,
5400 {
"KMP_D_DEBUG", __kmp_stg_parse_d_debug, __kmp_stg_print_d_debug, NULL, 0,
5402 {
"KMP_E_DEBUG", __kmp_stg_parse_e_debug, __kmp_stg_print_e_debug, NULL, 0,
5404 {
"KMP_F_DEBUG", __kmp_stg_parse_f_debug, __kmp_stg_print_f_debug, NULL, 0,
5406 {
"KMP_DEBUG", __kmp_stg_parse_debug, NULL, NULL, 0, 0},
5407 {
"KMP_DEBUG_BUF", __kmp_stg_parse_debug_buf, __kmp_stg_print_debug_buf,
5409 {
"KMP_DEBUG_BUF_ATOMIC", __kmp_stg_parse_debug_buf_atomic,
5410 __kmp_stg_print_debug_buf_atomic, NULL, 0, 0},
5411 {
"KMP_DEBUG_BUF_CHARS", __kmp_stg_parse_debug_buf_chars,
5412 __kmp_stg_print_debug_buf_chars, NULL, 0, 0},
5413 {
"KMP_DEBUG_BUF_LINES", __kmp_stg_parse_debug_buf_lines,
5414 __kmp_stg_print_debug_buf_lines, NULL, 0, 0},
5415 {
"KMP_DIAG", __kmp_stg_parse_diag, __kmp_stg_print_diag, NULL, 0, 0},
5417 {
"KMP_PAR_RANGE", __kmp_stg_parse_par_range_env,
5418 __kmp_stg_print_par_range_env, NULL, 0, 0},
5421 {
"KMP_ALIGN_ALLOC", __kmp_stg_parse_align_alloc,
5422 __kmp_stg_print_align_alloc, NULL, 0, 0},
5424 {
"KMP_PLAIN_BARRIER", __kmp_stg_parse_barrier_branch_bit,
5425 __kmp_stg_print_barrier_branch_bit, NULL, 0, 0},
5426 {
"KMP_PLAIN_BARRIER_PATTERN", __kmp_stg_parse_barrier_pattern,
5427 __kmp_stg_print_barrier_pattern, NULL, 0, 0},
5428 {
"KMP_FORKJOIN_BARRIER", __kmp_stg_parse_barrier_branch_bit,
5429 __kmp_stg_print_barrier_branch_bit, NULL, 0, 0},
5430 {
"KMP_FORKJOIN_BARRIER_PATTERN", __kmp_stg_parse_barrier_pattern,
5431 __kmp_stg_print_barrier_pattern, NULL, 0, 0},
5432 #if KMP_FAST_REDUCTION_BARRIER
5433 {
"KMP_REDUCTION_BARRIER", __kmp_stg_parse_barrier_branch_bit,
5434 __kmp_stg_print_barrier_branch_bit, NULL, 0, 0},
5435 {
"KMP_REDUCTION_BARRIER_PATTERN", __kmp_stg_parse_barrier_pattern,
5436 __kmp_stg_print_barrier_pattern, NULL, 0, 0},
5439 {
"KMP_ABORT_DELAY", __kmp_stg_parse_abort_delay,
5440 __kmp_stg_print_abort_delay, NULL, 0, 0},
5441 {
"KMP_CPUINFO_FILE", __kmp_stg_parse_cpuinfo_file,
5442 __kmp_stg_print_cpuinfo_file, NULL, 0, 0},
5443 {
"KMP_FORCE_REDUCTION", __kmp_stg_parse_force_reduction,
5444 __kmp_stg_print_force_reduction, NULL, 0, 0},
5445 {
"KMP_DETERMINISTIC_REDUCTION", __kmp_stg_parse_force_reduction,
5446 __kmp_stg_print_force_reduction, NULL, 0, 0},
5447 {
"KMP_STORAGE_MAP", __kmp_stg_parse_storage_map,
5448 __kmp_stg_print_storage_map, NULL, 0, 0},
5449 {
"KMP_ALL_THREADPRIVATE", __kmp_stg_parse_all_threadprivate,
5450 __kmp_stg_print_all_threadprivate, NULL, 0, 0},
5451 {
"KMP_FOREIGN_THREADS_THREADPRIVATE",
5452 __kmp_stg_parse_foreign_threads_threadprivate,
5453 __kmp_stg_print_foreign_threads_threadprivate, NULL, 0, 0},
5455 #if KMP_AFFINITY_SUPPORTED
5456 {
"KMP_AFFINITY", __kmp_stg_parse_affinity, __kmp_stg_print_affinity, NULL,
5458 #ifdef KMP_GOMP_COMPAT
5459 {
"GOMP_CPU_AFFINITY", __kmp_stg_parse_gomp_cpu_affinity, NULL,
5462 {
"OMP_PROC_BIND", __kmp_stg_parse_proc_bind, __kmp_stg_print_proc_bind,
5464 {
"KMP_TEAMS_PROC_BIND", __kmp_stg_parse_teams_proc_bind,
5465 __kmp_stg_print_teams_proc_bind, NULL, 0, 0},
5466 {
"OMP_PLACES", __kmp_stg_parse_places, __kmp_stg_print_places, NULL, 0, 0},
5467 {
"KMP_TOPOLOGY_METHOD", __kmp_stg_parse_topology_method,
5468 __kmp_stg_print_topology_method, NULL, 0, 0},
5474 {
"OMP_PROC_BIND", __kmp_stg_parse_proc_bind, __kmp_stg_print_proc_bind,
5478 {
"OMP_DISPLAY_AFFINITY", __kmp_stg_parse_display_affinity,
5479 __kmp_stg_print_display_affinity, NULL, 0, 0},
5480 {
"OMP_AFFINITY_FORMAT", __kmp_stg_parse_affinity_format,
5481 __kmp_stg_print_affinity_format, NULL, 0, 0},
5482 {
"KMP_INIT_AT_FORK", __kmp_stg_parse_init_at_fork,
5483 __kmp_stg_print_init_at_fork, NULL, 0, 0},
5484 {
"KMP_SCHEDULE", __kmp_stg_parse_schedule, __kmp_stg_print_schedule, NULL,
5486 {
"OMP_SCHEDULE", __kmp_stg_parse_omp_schedule, __kmp_stg_print_omp_schedule,
5488 #if KMP_USE_HIER_SCHED
5489 {
"KMP_DISP_HAND_THREAD", __kmp_stg_parse_kmp_hand_thread,
5490 __kmp_stg_print_kmp_hand_thread, NULL, 0, 0},
5492 {
"KMP_FORCE_MONOTONIC_DYNAMIC_SCHEDULE",
5493 __kmp_stg_parse_kmp_force_monotonic, __kmp_stg_print_kmp_force_monotonic,
5495 {
"KMP_ATOMIC_MODE", __kmp_stg_parse_atomic_mode,
5496 __kmp_stg_print_atomic_mode, NULL, 0, 0},
5497 {
"KMP_CONSISTENCY_CHECK", __kmp_stg_parse_consistency_check,
5498 __kmp_stg_print_consistency_check, NULL, 0, 0},
5500 #if USE_ITT_BUILD && USE_ITT_NOTIFY
5501 {
"KMP_ITT_PREPARE_DELAY", __kmp_stg_parse_itt_prepare_delay,
5502 __kmp_stg_print_itt_prepare_delay, NULL, 0, 0},
5504 {
"KMP_MALLOC_POOL_INCR", __kmp_stg_parse_malloc_pool_incr,
5505 __kmp_stg_print_malloc_pool_incr, NULL, 0, 0},
5506 {
"KMP_GTID_MODE", __kmp_stg_parse_gtid_mode, __kmp_stg_print_gtid_mode,
5508 {
"OMP_DYNAMIC", __kmp_stg_parse_omp_dynamic, __kmp_stg_print_omp_dynamic,
5510 {
"KMP_DYNAMIC_MODE", __kmp_stg_parse_kmp_dynamic_mode,
5511 __kmp_stg_print_kmp_dynamic_mode, NULL, 0, 0},
5513 #ifdef USE_LOAD_BALANCE
5514 {
"KMP_LOAD_BALANCE_INTERVAL", __kmp_stg_parse_ld_balance_interval,
5515 __kmp_stg_print_ld_balance_interval, NULL, 0, 0},
5518 {
"KMP_NUM_LOCKS_IN_BLOCK", __kmp_stg_parse_lock_block,
5519 __kmp_stg_print_lock_block, NULL, 0, 0},
5520 {
"KMP_LOCK_KIND", __kmp_stg_parse_lock_kind, __kmp_stg_print_lock_kind,
5522 {
"KMP_SPIN_BACKOFF_PARAMS", __kmp_stg_parse_spin_backoff_params,
5523 __kmp_stg_print_spin_backoff_params, NULL, 0, 0},
5524 #if KMP_USE_ADAPTIVE_LOCKS
5525 {
"KMP_ADAPTIVE_LOCK_PROPS", __kmp_stg_parse_adaptive_lock_props,
5526 __kmp_stg_print_adaptive_lock_props, NULL, 0, 0},
5527 #if KMP_DEBUG_ADAPTIVE_LOCKS
5528 {
"KMP_SPECULATIVE_STATSFILE", __kmp_stg_parse_speculative_statsfile,
5529 __kmp_stg_print_speculative_statsfile, NULL, 0, 0},
5532 {
"KMP_PLACE_THREADS", __kmp_stg_parse_hw_subset, __kmp_stg_print_hw_subset,
5534 {
"KMP_HW_SUBSET", __kmp_stg_parse_hw_subset, __kmp_stg_print_hw_subset,
5537 {
"KMP_FORKJOIN_FRAMES", __kmp_stg_parse_forkjoin_frames,
5538 __kmp_stg_print_forkjoin_frames, NULL, 0, 0},
5539 {
"KMP_FORKJOIN_FRAMES_MODE", __kmp_stg_parse_forkjoin_frames_mode,
5540 __kmp_stg_print_forkjoin_frames_mode, NULL, 0, 0},
5542 {
"KMP_ENABLE_TASK_THROTTLING", __kmp_stg_parse_task_throttling,
5543 __kmp_stg_print_task_throttling, NULL, 0, 0},
5545 {
"OMP_DISPLAY_ENV", __kmp_stg_parse_omp_display_env,
5546 __kmp_stg_print_omp_display_env, NULL, 0, 0},
5547 {
"OMP_CANCELLATION", __kmp_stg_parse_omp_cancellation,
5548 __kmp_stg_print_omp_cancellation, NULL, 0, 0},
5549 {
"OMP_ALLOCATOR", __kmp_stg_parse_allocator, __kmp_stg_print_allocator,
5551 {
"LIBOMP_USE_HIDDEN_HELPER_TASK", __kmp_stg_parse_use_hidden_helper,
5552 __kmp_stg_print_use_hidden_helper, NULL, 0, 0},
5553 {
"LIBOMP_NUM_HIDDEN_HELPER_THREADS",
5554 __kmp_stg_parse_num_hidden_helper_threads,
5555 __kmp_stg_print_num_hidden_helper_threads, NULL, 0, 0},
5558 {
"OMP_TOOL", __kmp_stg_parse_omp_tool, __kmp_stg_print_omp_tool, NULL, 0,
5560 {
"OMP_TOOL_LIBRARIES", __kmp_stg_parse_omp_tool_libraries,
5561 __kmp_stg_print_omp_tool_libraries, NULL, 0, 0},
5562 {
"OMP_TOOL_VERBOSE_INIT", __kmp_stg_parse_omp_tool_verbose_init,
5563 __kmp_stg_print_omp_tool_verbose_init, NULL, 0, 0},
5566 #if KMP_HAVE_MWAIT || KMP_HAVE_UMWAIT
5567 {
"KMP_USER_LEVEL_MWAIT", __kmp_stg_parse_user_level_mwait,
5568 __kmp_stg_print_user_level_mwait, NULL, 0, 0},
5569 {
"KMP_MWAIT_HINTS", __kmp_stg_parse_mwait_hints,
5570 __kmp_stg_print_mwait_hints, NULL, 0, 0},
5574 {
"KMP_TPAUSE", __kmp_stg_parse_tpause, __kmp_stg_print_tpause, NULL, 0, 0},
5576 {
"", NULL, NULL, NULL, 0, 0}};
5578 static int const __kmp_stg_count =
5579 sizeof(__kmp_stg_table) /
sizeof(kmp_setting_t);
5581 static inline kmp_setting_t *__kmp_stg_find(
char const *name) {
5585 for (i = 0; i < __kmp_stg_count; ++i) {
5586 if (strcmp(__kmp_stg_table[i].name, name) == 0) {
5587 return &__kmp_stg_table[i];
5595 static int __kmp_stg_cmp(
void const *_a,
void const *_b) {
5596 const kmp_setting_t *a = RCAST(
const kmp_setting_t *, _a);
5597 const kmp_setting_t *b = RCAST(
const kmp_setting_t *, _b);
5601 if (strcmp(a->name,
"KMP_AFFINITY") == 0) {
5602 if (strcmp(b->name,
"KMP_AFFINITY") == 0) {
5606 }
else if (strcmp(b->name,
"KMP_AFFINITY") == 0) {
5609 return strcmp(a->name, b->name);
5612 static void __kmp_stg_init(
void) {
5614 static int initialized = 0;
5619 qsort(__kmp_stg_table, __kmp_stg_count - 1,
sizeof(kmp_setting_t),
5623 kmp_setting_t *kmp_stacksize =
5624 __kmp_stg_find(
"KMP_STACKSIZE");
5625 #ifdef KMP_GOMP_COMPAT
5626 kmp_setting_t *gomp_stacksize =
5627 __kmp_stg_find(
"GOMP_STACKSIZE");
5629 kmp_setting_t *omp_stacksize =
5630 __kmp_stg_find(
"OMP_STACKSIZE");
5636 static kmp_setting_t *
volatile rivals[4];
5637 static kmp_stg_ss_data_t kmp_data = {1, CCAST(kmp_setting_t **, rivals)};
5638 #ifdef KMP_GOMP_COMPAT
5639 static kmp_stg_ss_data_t gomp_data = {1024,
5640 CCAST(kmp_setting_t **, rivals)};
5642 static kmp_stg_ss_data_t omp_data = {1024,
5643 CCAST(kmp_setting_t **, rivals)};
5646 rivals[i++] = kmp_stacksize;
5647 #ifdef KMP_GOMP_COMPAT
5648 if (gomp_stacksize != NULL) {
5649 rivals[i++] = gomp_stacksize;
5652 rivals[i++] = omp_stacksize;
5655 kmp_stacksize->data = &kmp_data;
5656 #ifdef KMP_GOMP_COMPAT
5657 if (gomp_stacksize != NULL) {
5658 gomp_stacksize->data = &gomp_data;
5661 omp_stacksize->data = &omp_data;
5665 kmp_setting_t *kmp_library =
5666 __kmp_stg_find(
"KMP_LIBRARY");
5667 kmp_setting_t *omp_wait_policy =
5668 __kmp_stg_find(
"OMP_WAIT_POLICY");
5671 static kmp_setting_t *
volatile rivals[3];
5672 static kmp_stg_wp_data_t kmp_data = {0, CCAST(kmp_setting_t **, rivals)};
5673 static kmp_stg_wp_data_t omp_data = {1, CCAST(kmp_setting_t **, rivals)};
5676 rivals[i++] = kmp_library;
5677 if (omp_wait_policy != NULL) {
5678 rivals[i++] = omp_wait_policy;
5682 kmp_library->data = &kmp_data;
5683 if (omp_wait_policy != NULL) {
5684 omp_wait_policy->data = &omp_data;
5689 kmp_setting_t *kmp_device_thread_limit =
5690 __kmp_stg_find(
"KMP_DEVICE_THREAD_LIMIT");
5691 kmp_setting_t *kmp_all_threads =
5692 __kmp_stg_find(
"KMP_ALL_THREADS");
5695 static kmp_setting_t *
volatile rivals[3];
5698 rivals[i++] = kmp_device_thread_limit;
5699 rivals[i++] = kmp_all_threads;
5702 kmp_device_thread_limit->data = CCAST(kmp_setting_t **, rivals);
5703 kmp_all_threads->data = CCAST(kmp_setting_t **, rivals);
5708 kmp_setting_t *kmp_hw_subset = __kmp_stg_find(
"KMP_HW_SUBSET");
5710 kmp_setting_t *kmp_place_threads = __kmp_stg_find(
"KMP_PLACE_THREADS");
5713 static kmp_setting_t *
volatile rivals[3];
5716 rivals[i++] = kmp_hw_subset;
5717 rivals[i++] = kmp_place_threads;
5720 kmp_hw_subset->data = CCAST(kmp_setting_t **, rivals);
5721 kmp_place_threads->data = CCAST(kmp_setting_t **, rivals);
5724 #if KMP_AFFINITY_SUPPORTED
5726 kmp_setting_t *kmp_affinity =
5727 __kmp_stg_find(
"KMP_AFFINITY");
5728 KMP_DEBUG_ASSERT(kmp_affinity != NULL);
5730 #ifdef KMP_GOMP_COMPAT
5731 kmp_setting_t *gomp_cpu_affinity =
5732 __kmp_stg_find(
"GOMP_CPU_AFFINITY");
5733 KMP_DEBUG_ASSERT(gomp_cpu_affinity != NULL);
5736 kmp_setting_t *omp_proc_bind =
5737 __kmp_stg_find(
"OMP_PROC_BIND");
5738 KMP_DEBUG_ASSERT(omp_proc_bind != NULL);
5741 static kmp_setting_t *
volatile rivals[4];
5744 rivals[i++] = kmp_affinity;
5746 #ifdef KMP_GOMP_COMPAT
5747 rivals[i++] = gomp_cpu_affinity;
5748 gomp_cpu_affinity->data = CCAST(kmp_setting_t **, rivals);
5751 rivals[i++] = omp_proc_bind;
5752 omp_proc_bind->data = CCAST(kmp_setting_t **, rivals);
5755 static kmp_setting_t *
volatile places_rivals[4];
5758 kmp_setting_t *omp_places = __kmp_stg_find(
"OMP_PLACES");
5759 KMP_DEBUG_ASSERT(omp_places != NULL);
5761 places_rivals[i++] = kmp_affinity;
5762 #ifdef KMP_GOMP_COMPAT
5763 places_rivals[i++] = gomp_cpu_affinity;
5765 places_rivals[i++] = omp_places;
5766 omp_places->data = CCAST(kmp_setting_t **, places_rivals);
5767 places_rivals[i++] = NULL;
5775 kmp_setting_t *kmp_force_red =
5776 __kmp_stg_find(
"KMP_FORCE_REDUCTION");
5777 kmp_setting_t *kmp_determ_red =
5778 __kmp_stg_find(
"KMP_DETERMINISTIC_REDUCTION");
5781 static kmp_setting_t *
volatile rivals[3];
5782 static kmp_stg_fr_data_t force_data = {1,
5783 CCAST(kmp_setting_t **, rivals)};
5784 static kmp_stg_fr_data_t determ_data = {0,
5785 CCAST(kmp_setting_t **, rivals)};
5788 rivals[i++] = kmp_force_red;
5789 if (kmp_determ_red != NULL) {
5790 rivals[i++] = kmp_determ_red;
5794 kmp_force_red->data = &force_data;
5795 if (kmp_determ_red != NULL) {
5796 kmp_determ_red->data = &determ_data;
5805 for (i = 0; i < __kmp_stg_count; ++i) {
5806 __kmp_stg_table[i].set = 0;
5811 static void __kmp_stg_parse(
char const *name,
char const *value) {
5819 if (value != NULL) {
5820 kmp_setting_t *setting = __kmp_stg_find(name);
5821 if (setting != NULL) {
5822 setting->parse(name, value, setting->data);
5823 setting->defined = 1;
5829 static int __kmp_stg_check_rivals(
5832 kmp_setting_t **rivals
5835 if (rivals == NULL) {
5841 for (; strcmp(rivals[i]->name, name) != 0; i++) {
5842 KMP_DEBUG_ASSERT(rivals[i] != NULL);
5844 #if KMP_AFFINITY_SUPPORTED
5845 if (rivals[i] == __kmp_affinity_notype) {
5852 if (rivals[i]->set) {
5853 KMP_WARNING(StgIgnored, name, rivals[i]->name);
5863 static int __kmp_env_toPrint(
char const *name,
int flag) {
5865 kmp_setting_t *setting = __kmp_stg_find(name);
5866 if (setting != NULL) {
5867 rc = setting->defined;
5869 setting->defined = flag;
5875 static void __kmp_aux_env_initialize(kmp_env_blk_t *block) {
5880 value = __kmp_env_blk_var(block,
"OMP_NUM_THREADS");
5882 ompc_set_num_threads(__kmp_dflt_team_nth);
5886 value = __kmp_env_blk_var(block,
"KMP_BLOCKTIME");
5888 kmpc_set_blocktime(__kmp_dflt_blocktime);
5892 value = __kmp_env_blk_var(block,
"OMP_NESTED");
5894 ompc_set_nested(__kmp_dflt_max_active_levels > 1);
5898 value = __kmp_env_blk_var(block,
"OMP_DYNAMIC");
5900 ompc_set_dynamic(__kmp_global.g.g_dynamic);
5904 void __kmp_env_initialize(
char const *
string) {
5906 kmp_env_blk_t block;
5912 if (
string == NULL) {
5914 __kmp_threads_capacity =
5915 __kmp_initial_threads_capacity(__kmp_dflt_team_nth_ub);
5917 __kmp_env_blk_init(&block,
string);
5920 for (i = 0; i < block.count; ++i) {
5921 if ((block.vars[i].name == NULL) || (*block.vars[i].name ==
'\0')) {
5924 if (block.vars[i].value == NULL) {
5927 kmp_setting_t *setting = __kmp_stg_find(block.vars[i].name);
5928 if (setting != NULL) {
5934 blocktime_str = __kmp_env_blk_var(&block,
"KMP_BLOCKTIME");
5938 if (
string == NULL) {
5939 char const *name =
"KMP_WARNINGS";
5940 char const *value = __kmp_env_blk_var(&block, name);
5941 __kmp_stg_parse(name, value);
5944 #if KMP_AFFINITY_SUPPORTED
5950 __kmp_affinity_notype = NULL;
5951 char const *aff_str = __kmp_env_blk_var(&block,
"KMP_AFFINITY");
5952 if (aff_str != NULL) {
5966 #define FIND strcasestr
5969 if ((FIND(aff_str,
"none") == NULL) &&
5970 (FIND(aff_str,
"physical") == NULL) &&
5971 (FIND(aff_str,
"logical") == NULL) &&
5972 (FIND(aff_str,
"compact") == NULL) &&
5973 (FIND(aff_str,
"scatter") == NULL) &&
5974 (FIND(aff_str,
"explicit") == NULL) &&
5975 (FIND(aff_str,
"balanced") == NULL) &&
5976 (FIND(aff_str,
"disabled") == NULL)) {
5977 __kmp_affinity_notype = __kmp_stg_find(
"KMP_AFFINITY");
5982 __kmp_affinity_type = affinity_default;
5983 __kmp_affinity_gran = KMP_HW_UNKNOWN;
5984 __kmp_affinity_top_method = affinity_top_method_default;
5985 __kmp_affinity_respect_mask = affinity_respect_mask_default;
5990 aff_str = __kmp_env_blk_var(&block,
"OMP_PROC_BIND");
5991 if (aff_str != NULL) {
5992 __kmp_affinity_type = affinity_default;
5993 __kmp_affinity_gran = KMP_HW_UNKNOWN;
5994 __kmp_affinity_top_method = affinity_top_method_default;
5995 __kmp_affinity_respect_mask = affinity_respect_mask_default;
6002 if (__kmp_nested_proc_bind.bind_types == NULL) {
6003 __kmp_nested_proc_bind.bind_types =
6004 (kmp_proc_bind_t *)KMP_INTERNAL_MALLOC(
sizeof(kmp_proc_bind_t));
6005 if (__kmp_nested_proc_bind.bind_types == NULL) {
6006 KMP_FATAL(MemoryAllocFailed);
6008 __kmp_nested_proc_bind.size = 1;
6009 __kmp_nested_proc_bind.used = 1;
6010 #if KMP_AFFINITY_SUPPORTED
6011 __kmp_nested_proc_bind.bind_types[0] = proc_bind_default;
6014 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
6021 __kmp_msg_format(kmp_i18n_msg_AffFormatDefault,
"%P",
"%i",
"%n",
"%A");
6022 KMP_DEBUG_ASSERT(KMP_STRLEN(m.str) < KMP_AFFINITY_FORMAT_SIZE);
6024 if (__kmp_affinity_format == NULL) {
6025 __kmp_affinity_format =
6026 (
char *)KMP_INTERNAL_MALLOC(
sizeof(
char) * KMP_AFFINITY_FORMAT_SIZE);
6028 KMP_STRCPY_S(__kmp_affinity_format, KMP_AFFINITY_FORMAT_SIZE, m.str);
6029 __kmp_str_free(&m.str);
6032 for (i = 0; i < block.count; ++i) {
6033 __kmp_stg_parse(block.vars[i].name, block.vars[i].value);
6037 if (!__kmp_init_user_locks) {
6038 if (__kmp_user_lock_kind == lk_default) {
6039 __kmp_user_lock_kind = lk_queuing;
6041 #if KMP_USE_DYNAMIC_LOCK
6042 __kmp_init_dynamic_user_locks();
6044 __kmp_set_user_lock_vptrs(__kmp_user_lock_kind);
6047 KMP_DEBUG_ASSERT(
string != NULL);
6048 KMP_DEBUG_ASSERT(__kmp_user_lock_kind != lk_default);
6053 #if KMP_USE_DYNAMIC_LOCK
6054 __kmp_init_dynamic_user_locks();
6056 __kmp_set_user_lock_vptrs(__kmp_user_lock_kind);
6060 #if KMP_AFFINITY_SUPPORTED
6062 if (!TCR_4(__kmp_init_middle)) {
6067 if (__kmp_hw_subset &&
6068 __kmp_affinity_top_method == affinity_top_method_default)
6069 if (__kmp_hw_subset->specified(KMP_HW_NUMA) ||
6070 __kmp_hw_subset->specified(KMP_HW_TILE) ||
6071 __kmp_affinity_gran == KMP_HW_TILE ||
6072 __kmp_affinity_gran == KMP_HW_NUMA)
6073 __kmp_affinity_top_method = affinity_top_method_hwloc;
6075 if (__kmp_affinity_gran == KMP_HW_NUMA ||
6076 __kmp_affinity_gran == KMP_HW_TILE)
6077 __kmp_affinity_top_method = affinity_top_method_hwloc;
6081 const char *var =
"KMP_AFFINITY";
6082 KMPAffinity::pick_api();
6087 if (__kmp_affinity_top_method == affinity_top_method_hwloc &&
6088 __kmp_affinity_dispatch->get_api_type() != KMPAffinity::HWLOC) {
6089 KMP_WARNING(AffIgnoringHwloc, var);
6090 __kmp_affinity_top_method = affinity_top_method_all;
6093 if (__kmp_affinity_type == affinity_disabled) {
6094 KMP_AFFINITY_DISABLE();
6095 }
else if (!KMP_AFFINITY_CAPABLE()) {
6096 __kmp_affinity_dispatch->determine_capable(var);
6097 if (!KMP_AFFINITY_CAPABLE()) {
6098 if (__kmp_affinity_verbose ||
6099 (__kmp_affinity_warnings &&
6100 (__kmp_affinity_type != affinity_default) &&
6101 (__kmp_affinity_type != affinity_none) &&
6102 (__kmp_affinity_type != affinity_disabled))) {
6103 KMP_WARNING(AffNotSupported, var);
6105 __kmp_affinity_type = affinity_disabled;
6106 __kmp_affinity_respect_mask = 0;
6107 __kmp_affinity_gran = KMP_HW_THREAD;
6111 if (__kmp_affinity_type == affinity_disabled) {
6112 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
6113 }
else if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_true) {
6115 __kmp_nested_proc_bind.bind_types[0] = proc_bind_spread;
6118 if (KMP_AFFINITY_CAPABLE()) {
6120 #if KMP_GROUP_AFFINITY
6125 bool exactly_one_group =
false;
6126 if (__kmp_num_proc_groups > 1) {
6128 bool within_one_group;
6131 kmp_affin_mask_t *init_mask;
6132 KMP_CPU_ALLOC(init_mask);
6133 __kmp_get_system_affinity(init_mask, TRUE);
6134 group = __kmp_get_proc_group(init_mask);
6135 within_one_group = (group >= 0);
6138 if (within_one_group) {
6139 DWORD num_bits_in_group = __kmp_GetActiveProcessorCount(group);
6140 DWORD num_bits_in_mask = 0;
6141 for (
int bit = init_mask->begin(); bit != init_mask->end();
6142 bit = init_mask->next(bit))
6144 exactly_one_group = (num_bits_in_group == num_bits_in_mask);
6146 KMP_CPU_FREE(init_mask);
6152 if (__kmp_num_proc_groups > 1 &&
6153 __kmp_affinity_type == affinity_default &&
6154 __kmp_nested_proc_bind.bind_types[0] == proc_bind_default) {
6159 if (__kmp_affinity_respect_mask == affinity_respect_mask_default &&
6160 exactly_one_group) {
6161 __kmp_affinity_respect_mask = FALSE;
6165 if (__kmp_affinity_type == affinity_default) {
6166 __kmp_affinity_type = affinity_compact;
6167 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
6169 if (__kmp_affinity_top_method == affinity_top_method_default)
6170 __kmp_affinity_top_method = affinity_top_method_all;
6171 if (__kmp_affinity_gran == KMP_HW_UNKNOWN)
6172 __kmp_affinity_gran = KMP_HW_PROC_GROUP;
6178 if (__kmp_affinity_respect_mask == affinity_respect_mask_default) {
6179 #if KMP_GROUP_AFFINITY
6180 if (__kmp_num_proc_groups > 1 && exactly_one_group) {
6181 __kmp_affinity_respect_mask = FALSE;
6185 __kmp_affinity_respect_mask = TRUE;
6188 if ((__kmp_nested_proc_bind.bind_types[0] != proc_bind_intel) &&
6189 (__kmp_nested_proc_bind.bind_types[0] != proc_bind_default)) {
6190 if (__kmp_affinity_type == affinity_default) {
6191 __kmp_affinity_type = affinity_compact;
6192 __kmp_affinity_dups = FALSE;
6194 }
else if (__kmp_affinity_type == affinity_default) {
6195 #if KMP_MIC_SUPPORTED
6196 if (__kmp_mic_type != non_mic) {
6197 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
6201 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
6203 #if KMP_MIC_SUPPORTED
6204 if (__kmp_mic_type != non_mic) {
6205 __kmp_affinity_type = affinity_scatter;
6209 __kmp_affinity_type = affinity_none;
6212 if ((__kmp_affinity_gran == KMP_HW_UNKNOWN) &&
6213 (__kmp_affinity_gran_levels < 0)) {
6214 #if KMP_MIC_SUPPORTED
6215 if (__kmp_mic_type != non_mic) {
6216 __kmp_affinity_gran = KMP_HW_THREAD;
6220 __kmp_affinity_gran = KMP_HW_CORE;
6223 if (__kmp_affinity_top_method == affinity_top_method_default) {
6224 __kmp_affinity_top_method = affinity_top_method_all;
6229 K_DIAG(1, (
"__kmp_affinity_type == %d\n", __kmp_affinity_type));
6230 K_DIAG(1, (
"__kmp_affinity_compact == %d\n", __kmp_affinity_compact));
6231 K_DIAG(1, (
"__kmp_affinity_offset == %d\n", __kmp_affinity_offset));
6232 K_DIAG(1, (
"__kmp_affinity_verbose == %d\n", __kmp_affinity_verbose));
6233 K_DIAG(1, (
"__kmp_affinity_warnings == %d\n", __kmp_affinity_warnings));
6234 K_DIAG(1, (
"__kmp_affinity_respect_mask == %d\n",
6235 __kmp_affinity_respect_mask));
6236 K_DIAG(1, (
"__kmp_affinity_gran == %d\n", __kmp_affinity_gran));
6238 KMP_DEBUG_ASSERT(__kmp_affinity_type != affinity_default);
6239 KMP_DEBUG_ASSERT(__kmp_nested_proc_bind.bind_types[0] != proc_bind_default);
6240 K_DIAG(1, (
"__kmp_nested_proc_bind.bind_types[0] == %d\n",
6241 __kmp_nested_proc_bind.bind_types[0]));
6246 if (__kmp_version) {
6247 __kmp_print_version_1();
6252 if (
string != NULL) {
6253 __kmp_aux_env_initialize(&block);
6256 __kmp_env_blk_free(&block);
6262 void __kmp_env_print() {
6264 kmp_env_blk_t block;
6266 kmp_str_buf_t buffer;
6269 __kmp_str_buf_init(&buffer);
6271 __kmp_env_blk_init(&block, NULL);
6272 __kmp_env_blk_sort(&block);
6275 __kmp_str_buf_print(&buffer,
"\n%s\n\n", KMP_I18N_STR(UserSettings));
6276 for (i = 0; i < block.count; ++i) {
6277 char const *name = block.vars[i].name;
6278 char const *value = block.vars[i].value;
6279 if ((KMP_STRLEN(name) > 4 && strncmp(name,
"KMP_", 4) == 0) ||
6280 strncmp(name,
"OMP_", 4) == 0
6281 #ifdef KMP_GOMP_COMPAT
6282 || strncmp(name,
"GOMP_", 5) == 0
6285 __kmp_str_buf_print(&buffer,
" %s=%s\n", name, value);
6288 __kmp_str_buf_print(&buffer,
"\n");
6291 __kmp_str_buf_print(&buffer,
"%s\n\n", KMP_I18N_STR(EffectiveSettings));
6292 for (
int i = 0; i < __kmp_stg_count; ++i) {
6293 if (__kmp_stg_table[i].print != NULL) {
6294 __kmp_stg_table[i].print(&buffer, __kmp_stg_table[i].name,
6295 __kmp_stg_table[i].data);
6299 __kmp_printf(
"%s", buffer.str);
6301 __kmp_env_blk_free(&block);
6302 __kmp_str_buf_free(&buffer);
6308 void __kmp_env_print_2() {
6309 __kmp_display_env_impl(__kmp_display_env, __kmp_display_env_verbose);
6312 void __kmp_display_env_impl(
int display_env,
int display_env_verbose) {
6313 kmp_env_blk_t block;
6314 kmp_str_buf_t buffer;
6316 __kmp_env_format = 1;
6319 __kmp_str_buf_init(&buffer);
6321 __kmp_env_blk_init(&block, NULL);
6322 __kmp_env_blk_sort(&block);
6324 __kmp_str_buf_print(&buffer,
"\n%s\n", KMP_I18N_STR(DisplayEnvBegin));
6325 __kmp_str_buf_print(&buffer,
" _OPENMP='%d'\n", __kmp_openmp_version);
6327 for (
int i = 0; i < __kmp_stg_count; ++i) {
6328 if (__kmp_stg_table[i].print != NULL &&
6329 ((display_env && strncmp(__kmp_stg_table[i].name,
"OMP_", 4) == 0) ||
6330 display_env_verbose)) {
6331 __kmp_stg_table[i].print(&buffer, __kmp_stg_table[i].name,
6332 __kmp_stg_table[i].data);
6336 __kmp_str_buf_print(&buffer,
"%s\n", KMP_I18N_STR(DisplayEnvEnd));
6337 __kmp_str_buf_print(&buffer,
"\n");
6339 __kmp_printf(
"%s", buffer.str);
6341 __kmp_env_blk_free(&block);
6342 __kmp_str_buf_free(&buffer);
6349 void __kmp_env_dump() {
6351 kmp_env_blk_t block;
6352 kmp_str_buf_t buffer, env, notdefined;
6355 __kmp_str_buf_init(&buffer);
6356 __kmp_str_buf_init(&env);
6357 __kmp_str_buf_init(¬defined);
6359 __kmp_env_blk_init(&block, NULL);
6360 __kmp_env_blk_sort(&block);
6362 __kmp_str_buf_print(¬defined,
": %s", KMP_I18N_STR(NotDefined));
6364 for (
int i = 0; i < __kmp_stg_count; ++i) {
6365 if (__kmp_stg_table[i].print == NULL)
6367 __kmp_str_buf_clear(&env);
6368 __kmp_stg_table[i].print(&env, __kmp_stg_table[i].name,
6369 __kmp_stg_table[i].data);
6372 if (strstr(env.str, notdefined.str))
6374 __kmp_str_buf_print(&buffer,
"%s=undefined\n", __kmp_stg_table[i].name);
6376 __kmp_str_buf_cat(&buffer, env.str + 3, env.used - 3);
6379 ompd_env_block = (
char *)__kmp_allocate(buffer.used + 1);
6380 KMP_MEMCPY(ompd_env_block, buffer.str, buffer.used + 1);
6381 ompd_env_block_size = (ompd_size_t)KMP_STRLEN(ompd_env_block);
6383 __kmp_env_blk_free(&block);
6384 __kmp_str_buf_free(&buffer);
6385 __kmp_str_buf_free(&env);
6386 __kmp_str_buf_free(¬defined);
@ kmp_sch_modifier_monotonic
@ kmp_sch_modifier_nonmonotonic