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 __kmp_wpolicy_passive =
true;
816 if (blocktime_str == NULL) {
818 __kmp_dflt_blocktime = 0;
821 KMP_WARNING(StgInvalidValue, name, value);
824 if (__kmp_str_match(
"serial", 1, value)) {
825 __kmp_library = library_serial;
826 }
else if (__kmp_str_match(
"throughput", 2, value)) {
827 __kmp_library = library_throughput;
828 if (blocktime_str == NULL) {
830 __kmp_dflt_blocktime = 0;
832 }
else if (__kmp_str_match(
"turnaround", 2, value)) {
833 __kmp_library = library_turnaround;
834 }
else if (__kmp_str_match(
"dedicated", 1, value)) {
835 __kmp_library = library_turnaround;
836 }
else if (__kmp_str_match(
"multiuser", 1, value)) {
837 __kmp_library = library_throughput;
838 if (blocktime_str == NULL) {
840 __kmp_dflt_blocktime = 0;
843 KMP_WARNING(StgInvalidValue, name, value);
848 static void __kmp_stg_print_wait_policy(kmp_str_buf_t *buffer,
char const *name,
851 kmp_stg_wp_data_t *wait = (kmp_stg_wp_data_t *)data;
852 char const *value = NULL;
855 switch (__kmp_library) {
856 case library_turnaround: {
859 case library_throughput: {
864 switch (__kmp_library) {
865 case library_serial: {
868 case library_turnaround: {
869 value =
"turnaround";
871 case library_throughput: {
872 value =
"throughput";
877 __kmp_stg_print_str(buffer, name, value);
886 static void __kmp_stg_parse_monitor_stacksize(
char const *name,
887 char const *value,
void *data) {
888 __kmp_stg_parse_size(name, value, __kmp_sys_min_stksize, KMP_MAX_STKSIZE,
889 NULL, &__kmp_monitor_stksize, 1);
892 static void __kmp_stg_print_monitor_stacksize(kmp_str_buf_t *buffer,
893 char const *name,
void *data) {
894 if (__kmp_env_format) {
895 if (__kmp_monitor_stksize > 0)
896 KMP_STR_BUF_PRINT_NAME_EX(name);
898 KMP_STR_BUF_PRINT_NAME;
900 __kmp_str_buf_print(buffer,
" %s", name);
902 if (__kmp_monitor_stksize > 0) {
903 __kmp_str_buf_print_size(buffer, __kmp_monitor_stksize);
905 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
907 if (__kmp_env_format && __kmp_monitor_stksize) {
908 __kmp_str_buf_print(buffer,
"'\n");
916 static void __kmp_stg_parse_settings(
char const *name,
char const *value,
918 __kmp_stg_parse_bool(name, value, &__kmp_settings);
921 static void __kmp_stg_print_settings(kmp_str_buf_t *buffer,
char const *name,
923 __kmp_stg_print_bool(buffer, name, __kmp_settings);
929 static void __kmp_stg_parse_stackpad(
char const *name,
char const *value,
931 __kmp_stg_parse_int(name,
939 static void __kmp_stg_print_stackpad(kmp_str_buf_t *buffer,
char const *name,
941 __kmp_stg_print_int(buffer, name, __kmp_stkpadding);
947 static void __kmp_stg_parse_stackoffset(
char const *name,
char const *value,
949 __kmp_stg_parse_size(name,
958 static void __kmp_stg_print_stackoffset(kmp_str_buf_t *buffer,
char const *name,
960 __kmp_stg_print_size(buffer, name, __kmp_stkoffset);
966 static void __kmp_stg_parse_stacksize(
char const *name,
char const *value,
969 kmp_stg_ss_data_t *stacksize = (kmp_stg_ss_data_t *)data;
972 rc = __kmp_stg_check_rivals(name, value, stacksize->rivals);
976 __kmp_stg_parse_size(name,
978 __kmp_sys_min_stksize,
990 static void __kmp_stg_print_stacksize(kmp_str_buf_t *buffer,
char const *name,
992 kmp_stg_ss_data_t *stacksize = (kmp_stg_ss_data_t *)data;
993 if (__kmp_env_format) {
994 KMP_STR_BUF_PRINT_NAME_EX(name);
995 __kmp_str_buf_print_size(buffer, (__kmp_stksize % 1024)
996 ? __kmp_stksize / stacksize->factor
998 __kmp_str_buf_print(buffer,
"'\n");
1000 __kmp_str_buf_print(buffer,
" %s=", name);
1001 __kmp_str_buf_print_size(buffer, (__kmp_stksize % 1024)
1002 ? __kmp_stksize / stacksize->factor
1004 __kmp_str_buf_print(buffer,
"\n");
1011 static void __kmp_stg_parse_version(
char const *name,
char const *value,
1013 __kmp_stg_parse_bool(name, value, &__kmp_version);
1016 static void __kmp_stg_print_version(kmp_str_buf_t *buffer,
char const *name,
1018 __kmp_stg_print_bool(buffer, name, __kmp_version);
1024 static void __kmp_stg_parse_warnings(
char const *name,
char const *value,
1026 __kmp_stg_parse_bool(name, value, &__kmp_generate_warnings);
1027 if (__kmp_generate_warnings != kmp_warnings_off) {
1030 __kmp_generate_warnings = kmp_warnings_explicit;
1034 static void __kmp_stg_print_warnings(kmp_str_buf_t *buffer,
char const *name,
1037 __kmp_stg_print_bool(buffer, name, __kmp_generate_warnings);
1043 static void __kmp_stg_parse_nesting_mode(
char const *name,
char const *value,
1045 __kmp_stg_parse_int(name, value, 0, INT_MAX, &__kmp_nesting_mode);
1046 #if KMP_AFFINITY_SUPPORTED && KMP_USE_HWLOC
1047 if (__kmp_nesting_mode > 0)
1048 __kmp_affinity_top_method = affinity_top_method_hwloc;
1052 static void __kmp_stg_print_nesting_mode(kmp_str_buf_t *buffer,
1053 char const *name,
void *data) {
1054 if (__kmp_env_format) {
1055 KMP_STR_BUF_PRINT_NAME;
1057 __kmp_str_buf_print(buffer,
" %s", name);
1059 __kmp_str_buf_print(buffer,
"=%d\n", __kmp_nesting_mode);
1065 static void __kmp_stg_parse_nested(
char const *name,
char const *value,
1068 KMP_INFORM(EnvVarDeprecated, name,
"OMP_MAX_ACTIVE_LEVELS");
1069 __kmp_stg_parse_bool(name, value, &nested);
1071 if (!__kmp_dflt_max_active_levels_set)
1072 __kmp_dflt_max_active_levels = KMP_MAX_ACTIVE_LEVELS_LIMIT;
1074 __kmp_dflt_max_active_levels = 1;
1075 __kmp_dflt_max_active_levels_set =
true;
1079 static void __kmp_stg_print_nested(kmp_str_buf_t *buffer,
char const *name,
1081 if (__kmp_env_format) {
1082 KMP_STR_BUF_PRINT_NAME;
1084 __kmp_str_buf_print(buffer,
" %s", name);
1086 __kmp_str_buf_print(buffer,
": deprecated; max-active-levels-var=%d\n",
1087 __kmp_dflt_max_active_levels);
1090 static void __kmp_parse_nested_num_threads(
const char *var,
const char *env,
1091 kmp_nested_nthreads_t *nth_array) {
1092 const char *next = env;
1093 const char *scan = next;
1096 int prev_comma = FALSE;
1102 if (*next ==
'\0') {
1106 if (((*next <
'0') || (*next >
'9')) && (*next !=
',')) {
1107 KMP_WARNING(NthSyntaxError, var, env);
1113 if (total == 0 || prev_comma) {
1121 if (*next >=
'0' && *next <=
'9') {
1125 const char *tmp = next;
1127 if ((*next ==
' ' || *next ==
'\t') && (*tmp >=
'0' && *tmp <=
'9')) {
1128 KMP_WARNING(NthSpacesNotAllowed, var, env);
1133 if (!__kmp_dflt_max_active_levels_set && total > 1)
1134 __kmp_dflt_max_active_levels = KMP_MAX_ACTIVE_LEVELS_LIMIT;
1135 KMP_DEBUG_ASSERT(total > 0);
1137 KMP_WARNING(NthSyntaxError, var, env);
1142 if (!nth_array->nth) {
1144 nth_array->nth = (
int *)KMP_INTERNAL_MALLOC(
sizeof(
int) * total * 2);
1145 if (nth_array->nth == NULL) {
1146 KMP_FATAL(MemoryAllocFailed);
1148 nth_array->size = total * 2;
1150 if (nth_array->size < total) {
1153 nth_array->size *= 2;
1154 }
while (nth_array->size < total);
1156 nth_array->nth = (
int *)KMP_INTERNAL_REALLOC(
1157 nth_array->nth,
sizeof(
int) * nth_array->size);
1158 if (nth_array->nth == NULL) {
1159 KMP_FATAL(MemoryAllocFailed);
1163 nth_array->used = total;
1171 if (*scan ==
'\0') {
1181 nth_array->nth[i++] = 0;
1183 }
else if (prev_comma) {
1185 nth_array->nth[i] = nth_array->nth[i - 1];
1194 if (*scan >=
'0' && *scan <=
'9') {
1196 const char *buf = scan;
1197 char const *msg = NULL;
1202 num = __kmp_str_to_int(buf, *scan);
1203 if (num < KMP_MIN_NTH) {
1204 msg = KMP_I18N_STR(ValueTooSmall);
1206 }
else if (num > __kmp_sys_max_nth) {
1207 msg = KMP_I18N_STR(ValueTooLarge);
1208 num = __kmp_sys_max_nth;
1212 KMP_WARNING(ParseSizeIntWarn, var, env, msg);
1213 KMP_INFORM(Using_int_Value, var, num);
1215 nth_array->nth[i++] = num;
1220 static void __kmp_stg_parse_num_threads(
char const *name,
char const *value,
1223 if (!__kmp_strcasecmp_with_sentinel(
"all", value, 0)) {
1225 __kmp_nested_nth.nth = (
int *)KMP_INTERNAL_MALLOC(
sizeof(
int));
1226 __kmp_nested_nth.size = __kmp_nested_nth.used = 1;
1227 __kmp_nested_nth.nth[0] = __kmp_dflt_team_nth = __kmp_dflt_team_nth_ub =
1230 __kmp_parse_nested_num_threads(name, value, &__kmp_nested_nth);
1231 if (__kmp_nested_nth.nth) {
1232 __kmp_dflt_team_nth = __kmp_nested_nth.nth[0];
1233 if (__kmp_dflt_team_nth_ub < __kmp_dflt_team_nth) {
1234 __kmp_dflt_team_nth_ub = __kmp_dflt_team_nth;
1238 K_DIAG(1, (
"__kmp_dflt_team_nth == %d\n", __kmp_dflt_team_nth));
1241 static void __kmp_stg_parse_num_hidden_helper_threads(
char const *name,
1244 __kmp_stg_parse_int(name, value, 0, 16, &__kmp_hidden_helper_threads_num);
1247 if (__kmp_hidden_helper_threads_num == 0) {
1248 __kmp_enable_hidden_helper = FALSE;
1253 __kmp_hidden_helper_threads_num++;
1257 static void __kmp_stg_print_num_hidden_helper_threads(kmp_str_buf_t *buffer,
1260 if (__kmp_hidden_helper_threads_num == 0) {
1261 __kmp_stg_print_int(buffer, name, __kmp_hidden_helper_threads_num);
1263 KMP_DEBUG_ASSERT(__kmp_hidden_helper_threads_num > 1);
1266 __kmp_stg_print_int(buffer, name, __kmp_hidden_helper_threads_num - 1);
1270 static void __kmp_stg_parse_use_hidden_helper(
char const *name,
1271 char const *value,
void *data) {
1272 __kmp_stg_parse_bool(name, value, &__kmp_enable_hidden_helper);
1274 __kmp_enable_hidden_helper = FALSE;
1276 (
"__kmp_stg_parse_use_hidden_helper: Disable hidden helper task on "
1277 "non-Linux platform although it is enabled by user explicitly.\n"));
1281 static void __kmp_stg_print_use_hidden_helper(kmp_str_buf_t *buffer,
1282 char const *name,
void *data) {
1283 __kmp_stg_print_bool(buffer, name, __kmp_enable_hidden_helper);
1286 static void __kmp_stg_print_num_threads(kmp_str_buf_t *buffer,
char const *name,
1288 if (__kmp_env_format) {
1289 KMP_STR_BUF_PRINT_NAME;
1291 __kmp_str_buf_print(buffer,
" %s", name);
1293 if (__kmp_nested_nth.used) {
1295 __kmp_str_buf_init(&buf);
1296 for (
int i = 0; i < __kmp_nested_nth.used; i++) {
1297 __kmp_str_buf_print(&buf,
"%d", __kmp_nested_nth.nth[i]);
1298 if (i < __kmp_nested_nth.used - 1) {
1299 __kmp_str_buf_print(&buf,
",");
1302 __kmp_str_buf_print(buffer,
"='%s'\n", buf.str);
1303 __kmp_str_buf_free(&buf);
1305 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
1312 static void __kmp_stg_parse_tasking(
char const *name,
char const *value,
1314 __kmp_stg_parse_int(name, value, 0, (
int)tskm_max,
1315 (
int *)&__kmp_tasking_mode);
1318 static void __kmp_stg_print_tasking(kmp_str_buf_t *buffer,
char const *name,
1320 __kmp_stg_print_int(buffer, name, __kmp_tasking_mode);
1323 static void __kmp_stg_parse_task_stealing(
char const *name,
char const *value,
1325 __kmp_stg_parse_int(name, value, 0, 1,
1326 (
int *)&__kmp_task_stealing_constraint);
1329 static void __kmp_stg_print_task_stealing(kmp_str_buf_t *buffer,
1330 char const *name,
void *data) {
1331 __kmp_stg_print_int(buffer, name, __kmp_task_stealing_constraint);
1334 static void __kmp_stg_parse_max_active_levels(
char const *name,
1335 char const *value,
void *data) {
1336 kmp_uint64 tmp_dflt = 0;
1337 char const *msg = NULL;
1338 if (!__kmp_dflt_max_active_levels_set) {
1340 __kmp_str_to_uint(value, &tmp_dflt, &msg);
1342 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
1343 }
else if (tmp_dflt > KMP_MAX_ACTIVE_LEVELS_LIMIT) {
1345 msg = KMP_I18N_STR(ValueTooLarge);
1346 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
1348 __kmp_type_convert(tmp_dflt, &(__kmp_dflt_max_active_levels));
1349 __kmp_dflt_max_active_levels_set =
true;
1354 static void __kmp_stg_print_max_active_levels(kmp_str_buf_t *buffer,
1355 char const *name,
void *data) {
1356 __kmp_stg_print_int(buffer, name, __kmp_dflt_max_active_levels);
1361 static void __kmp_stg_parse_default_device(
char const *name,
char const *value,
1363 __kmp_stg_parse_int(name, value, 0, KMP_MAX_DEFAULT_DEVICE_LIMIT,
1364 &__kmp_default_device);
1367 static void __kmp_stg_print_default_device(kmp_str_buf_t *buffer,
1368 char const *name,
void *data) {
1369 __kmp_stg_print_int(buffer, name, __kmp_default_device);
1374 static void __kmp_stg_parse_target_offload(
char const *name,
char const *value,
1376 const char *next = value;
1377 const char *scan = next;
1379 __kmp_target_offload = tgt_default;
1384 if (!__kmp_strcasecmp_with_sentinel(
"mandatory", scan, 0)) {
1385 __kmp_target_offload = tgt_mandatory;
1386 }
else if (!__kmp_strcasecmp_with_sentinel(
"disabled", scan, 0)) {
1387 __kmp_target_offload = tgt_disabled;
1388 }
else if (!__kmp_strcasecmp_with_sentinel(
"default", scan, 0)) {
1389 __kmp_target_offload = tgt_default;
1391 KMP_WARNING(SyntaxErrorUsing, name,
"DEFAULT");
1396 static void __kmp_stg_print_target_offload(kmp_str_buf_t *buffer,
1397 char const *name,
void *data) {
1398 const char *value = NULL;
1399 if (__kmp_target_offload == tgt_default)
1401 else if (__kmp_target_offload == tgt_mandatory)
1402 value =
"MANDATORY";
1403 else if (__kmp_target_offload == tgt_disabled)
1405 KMP_DEBUG_ASSERT(value);
1406 if (__kmp_env_format) {
1407 KMP_STR_BUF_PRINT_NAME;
1409 __kmp_str_buf_print(buffer,
" %s", name);
1411 __kmp_str_buf_print(buffer,
"=%s\n", value);
1416 static void __kmp_stg_parse_max_task_priority(
char const *name,
1417 char const *value,
void *data) {
1418 __kmp_stg_parse_int(name, value, 0, KMP_MAX_TASK_PRIORITY_LIMIT,
1419 &__kmp_max_task_priority);
1422 static void __kmp_stg_print_max_task_priority(kmp_str_buf_t *buffer,
1423 char const *name,
void *data) {
1424 __kmp_stg_print_int(buffer, name, __kmp_max_task_priority);
1429 static void __kmp_stg_parse_taskloop_min_tasks(
char const *name,
1430 char const *value,
void *data) {
1432 __kmp_stg_parse_int(name, value, 0, INT_MAX, &tmp);
1433 __kmp_taskloop_min_tasks = tmp;
1436 static void __kmp_stg_print_taskloop_min_tasks(kmp_str_buf_t *buffer,
1437 char const *name,
void *data) {
1438 __kmp_stg_print_uint64(buffer, name, __kmp_taskloop_min_tasks);
1443 static void __kmp_stg_parse_disp_buffers(
char const *name,
char const *value,
1445 if (TCR_4(__kmp_init_serial)) {
1446 KMP_WARNING(EnvSerialWarn, name);
1449 __kmp_stg_parse_int(name, value, KMP_MIN_DISP_NUM_BUFF, KMP_MAX_DISP_NUM_BUFF,
1450 &__kmp_dispatch_num_buffers);
1453 static void __kmp_stg_print_disp_buffers(kmp_str_buf_t *buffer,
1454 char const *name,
void *data) {
1455 __kmp_stg_print_int(buffer, name, __kmp_dispatch_num_buffers);
1458 #if KMP_NESTED_HOT_TEAMS
1462 static void __kmp_stg_parse_hot_teams_level(
char const *name,
char const *value,
1464 if (TCR_4(__kmp_init_parallel)) {
1465 KMP_WARNING(EnvParallelWarn, name);
1468 __kmp_stg_parse_int(name, value, 0, KMP_MAX_ACTIVE_LEVELS_LIMIT,
1469 &__kmp_hot_teams_max_level);
1472 static void __kmp_stg_print_hot_teams_level(kmp_str_buf_t *buffer,
1473 char const *name,
void *data) {
1474 __kmp_stg_print_int(buffer, name, __kmp_hot_teams_max_level);
1477 static void __kmp_stg_parse_hot_teams_mode(
char const *name,
char const *value,
1479 if (TCR_4(__kmp_init_parallel)) {
1480 KMP_WARNING(EnvParallelWarn, name);
1483 __kmp_stg_parse_int(name, value, 0, KMP_MAX_ACTIVE_LEVELS_LIMIT,
1484 &__kmp_hot_teams_mode);
1487 static void __kmp_stg_print_hot_teams_mode(kmp_str_buf_t *buffer,
1488 char const *name,
void *data) {
1489 __kmp_stg_print_int(buffer, name, __kmp_hot_teams_mode);
1497 #if KMP_HANDLE_SIGNALS
1499 static void __kmp_stg_parse_handle_signals(
char const *name,
char const *value,
1501 __kmp_stg_parse_bool(name, value, &__kmp_handle_signals);
1504 static void __kmp_stg_print_handle_signals(kmp_str_buf_t *buffer,
1505 char const *name,
void *data) {
1506 __kmp_stg_print_bool(buffer, name, __kmp_handle_signals);
1516 #define KMP_STG_X_DEBUG(x) \
1517 static void __kmp_stg_parse_##x##_debug(char const *name, char const *value, \
1519 __kmp_stg_parse_int(name, value, 0, INT_MAX, &kmp_##x##_debug); \
1521 static void __kmp_stg_print_##x##_debug(kmp_str_buf_t *buffer, \
1522 char const *name, void *data) { \
1523 __kmp_stg_print_int(buffer, name, kmp_##x##_debug); \
1533 #undef KMP_STG_X_DEBUG
1535 static void __kmp_stg_parse_debug(
char const *name,
char const *value,
1538 __kmp_stg_parse_int(name, value, 0, INT_MAX, &debug);
1539 if (kmp_a_debug < debug) {
1540 kmp_a_debug = debug;
1542 if (kmp_b_debug < debug) {
1543 kmp_b_debug = debug;
1545 if (kmp_c_debug < debug) {
1546 kmp_c_debug = debug;
1548 if (kmp_d_debug < debug) {
1549 kmp_d_debug = debug;
1551 if (kmp_e_debug < debug) {
1552 kmp_e_debug = debug;
1554 if (kmp_f_debug < debug) {
1555 kmp_f_debug = debug;
1559 static void __kmp_stg_parse_debug_buf(
char const *name,
char const *value,
1561 __kmp_stg_parse_bool(name, value, &__kmp_debug_buf);
1565 if (__kmp_debug_buf) {
1567 int elements = __kmp_debug_buf_lines * __kmp_debug_buf_chars;
1570 __kmp_debug_buffer = (
char *)__kmp_page_allocate(elements *
sizeof(
char));
1571 for (i = 0; i < elements; i += __kmp_debug_buf_chars)
1572 __kmp_debug_buffer[i] =
'\0';
1574 __kmp_debug_count = 0;
1576 K_DIAG(1, (
"__kmp_debug_buf = %d\n", __kmp_debug_buf));
1579 static void __kmp_stg_print_debug_buf(kmp_str_buf_t *buffer,
char const *name,
1581 __kmp_stg_print_bool(buffer, name, __kmp_debug_buf);
1584 static void __kmp_stg_parse_debug_buf_atomic(
char const *name,
1585 char const *value,
void *data) {
1586 __kmp_stg_parse_bool(name, value, &__kmp_debug_buf_atomic);
1589 static void __kmp_stg_print_debug_buf_atomic(kmp_str_buf_t *buffer,
1590 char const *name,
void *data) {
1591 __kmp_stg_print_bool(buffer, name, __kmp_debug_buf_atomic);
1594 static void __kmp_stg_parse_debug_buf_chars(
char const *name,
char const *value,
1596 __kmp_stg_parse_int(name, value, KMP_DEBUG_BUF_CHARS_MIN, INT_MAX,
1597 &__kmp_debug_buf_chars);
1600 static void __kmp_stg_print_debug_buf_chars(kmp_str_buf_t *buffer,
1601 char const *name,
void *data) {
1602 __kmp_stg_print_int(buffer, name, __kmp_debug_buf_chars);
1605 static void __kmp_stg_parse_debug_buf_lines(
char const *name,
char const *value,
1607 __kmp_stg_parse_int(name, value, KMP_DEBUG_BUF_LINES_MIN, INT_MAX,
1608 &__kmp_debug_buf_lines);
1611 static void __kmp_stg_print_debug_buf_lines(kmp_str_buf_t *buffer,
1612 char const *name,
void *data) {
1613 __kmp_stg_print_int(buffer, name, __kmp_debug_buf_lines);
1616 static void __kmp_stg_parse_diag(
char const *name,
char const *value,
1618 __kmp_stg_parse_int(name, value, 0, INT_MAX, &kmp_diag);
1621 static void __kmp_stg_print_diag(kmp_str_buf_t *buffer,
char const *name,
1623 __kmp_stg_print_int(buffer, name, kmp_diag);
1631 static void __kmp_stg_parse_align_alloc(
char const *name,
char const *value,
1633 __kmp_stg_parse_size(name, value, CACHE_LINE, INT_MAX, NULL,
1634 &__kmp_align_alloc, 1);
1637 static void __kmp_stg_print_align_alloc(kmp_str_buf_t *buffer,
char const *name,
1639 __kmp_stg_print_size(buffer, name, __kmp_align_alloc);
1648 static void __kmp_stg_parse_barrier_branch_bit(
char const *name,
1649 char const *value,
void *data) {
1653 for (
int i = bs_plain_barrier; i < bs_last_barrier; i++) {
1654 var = __kmp_barrier_branch_bit_env_name[i];
1655 if ((strcmp(var, name) == 0) && (value != 0)) {
1658 comma = CCAST(
char *, strchr(value,
','));
1659 __kmp_barrier_gather_branch_bits[i] =
1660 (kmp_uint32)__kmp_str_to_int(value,
',');
1662 if (comma == NULL) {
1663 __kmp_barrier_release_branch_bits[i] = __kmp_barrier_release_bb_dflt;
1665 __kmp_barrier_release_branch_bits[i] =
1666 (kmp_uint32)__kmp_str_to_int(comma + 1, 0);
1668 if (__kmp_barrier_release_branch_bits[i] > KMP_MAX_BRANCH_BITS) {
1669 __kmp_msg(kmp_ms_warning,
1670 KMP_MSG(BarrReleaseValueInvalid, name, comma + 1),
1672 __kmp_barrier_release_branch_bits[i] = __kmp_barrier_release_bb_dflt;
1675 if (__kmp_barrier_gather_branch_bits[i] > KMP_MAX_BRANCH_BITS) {
1676 KMP_WARNING(BarrGatherValueInvalid, name, value);
1677 KMP_INFORM(Using_uint_Value, name, __kmp_barrier_gather_bb_dflt);
1678 __kmp_barrier_gather_branch_bits[i] = __kmp_barrier_gather_bb_dflt;
1681 K_DIAG(1, (
"%s == %d,%d\n", __kmp_barrier_branch_bit_env_name[i],
1682 __kmp_barrier_gather_branch_bits[i],
1683 __kmp_barrier_release_branch_bits[i]))
1687 static void __kmp_stg_print_barrier_branch_bit(kmp_str_buf_t *buffer,
1688 char const *name,
void *data) {
1690 for (
int i = bs_plain_barrier; i < bs_last_barrier; i++) {
1691 var = __kmp_barrier_branch_bit_env_name[i];
1692 if (strcmp(var, name) == 0) {
1693 if (__kmp_env_format) {
1694 KMP_STR_BUF_PRINT_NAME_EX(__kmp_barrier_branch_bit_env_name[i]);
1696 __kmp_str_buf_print(buffer,
" %s='",
1697 __kmp_barrier_branch_bit_env_name[i]);
1699 __kmp_str_buf_print(buffer,
"%d,%d'\n",
1700 __kmp_barrier_gather_branch_bits[i],
1701 __kmp_barrier_release_branch_bits[i]);
1713 static void __kmp_stg_parse_barrier_pattern(
char const *name,
char const *value,
1718 static int dist_req = 0, non_dist_req = 0;
1719 static bool warn = 1;
1720 for (
int i = bs_plain_barrier; i < bs_last_barrier; i++) {
1721 var = __kmp_barrier_pattern_env_name[i];
1723 if ((strcmp(var, name) == 0) && (value != 0)) {
1725 char *comma = CCAST(
char *, strchr(value,
','));
1728 for (j = bp_linear_bar; j < bp_last_bar; j++) {
1729 if (__kmp_match_with_sentinel(__kmp_barrier_pattern_name[j], value, 1,
1731 if (j == bp_dist_bar) {
1736 __kmp_barrier_gather_pattern[i] = (kmp_bar_pat_e)j;
1740 if (j == bp_last_bar) {
1741 KMP_WARNING(BarrGatherValueInvalid, name, value);
1742 KMP_INFORM(Using_str_Value, name,
1743 __kmp_barrier_pattern_name[bp_linear_bar]);
1747 if (comma != NULL) {
1748 for (j = bp_linear_bar; j < bp_last_bar; j++) {
1749 if (__kmp_str_match(__kmp_barrier_pattern_name[j], 1, comma + 1)) {
1750 if (j == bp_dist_bar) {
1755 __kmp_barrier_release_pattern[i] = (kmp_bar_pat_e)j;
1759 if (j == bp_last_bar) {
1760 __kmp_msg(kmp_ms_warning,
1761 KMP_MSG(BarrReleaseValueInvalid, name, comma + 1),
1763 KMP_INFORM(Using_str_Value, name,
1764 __kmp_barrier_pattern_name[bp_linear_bar]);
1769 if (dist_req != 0) {
1771 if ((non_dist_req != 0) && warn) {
1772 KMP_INFORM(BarrierPatternOverride, name,
1773 __kmp_barrier_pattern_name[bp_dist_bar]);
1776 for (
int i = bs_plain_barrier; i < bs_last_barrier; i++) {
1777 if (__kmp_barrier_release_pattern[i] != bp_dist_bar)
1778 __kmp_barrier_release_pattern[i] = bp_dist_bar;
1779 if (__kmp_barrier_gather_pattern[i] != bp_dist_bar)
1780 __kmp_barrier_gather_pattern[i] = bp_dist_bar;
1785 static void __kmp_stg_print_barrier_pattern(kmp_str_buf_t *buffer,
1786 char const *name,
void *data) {
1788 for (
int i = bs_plain_barrier; i < bs_last_barrier; i++) {
1789 var = __kmp_barrier_pattern_env_name[i];
1790 if (strcmp(var, name) == 0) {
1791 int j = __kmp_barrier_gather_pattern[i];
1792 int k = __kmp_barrier_release_pattern[i];
1793 if (__kmp_env_format) {
1794 KMP_STR_BUF_PRINT_NAME_EX(__kmp_barrier_pattern_env_name[i]);
1796 __kmp_str_buf_print(buffer,
" %s='",
1797 __kmp_barrier_pattern_env_name[i]);
1799 KMP_DEBUG_ASSERT(j < bp_last_bar && k < bp_last_bar);
1800 __kmp_str_buf_print(buffer,
"%s,%s'\n", __kmp_barrier_pattern_name[j],
1801 __kmp_barrier_pattern_name[k]);
1809 static void __kmp_stg_parse_abort_delay(
char const *name,
char const *value,
1813 int delay = __kmp_abort_delay / 1000;
1814 __kmp_stg_parse_int(name, value, 0, INT_MAX / 1000, &delay);
1815 __kmp_abort_delay = delay * 1000;
1818 static void __kmp_stg_print_abort_delay(kmp_str_buf_t *buffer,
char const *name,
1820 __kmp_stg_print_int(buffer, name, __kmp_abort_delay);
1826 static void __kmp_stg_parse_cpuinfo_file(
char const *name,
char const *value,
1828 #if KMP_AFFINITY_SUPPORTED
1829 __kmp_stg_parse_str(name, value, &__kmp_cpuinfo_file);
1830 K_DIAG(1, (
"__kmp_cpuinfo_file == %s\n", __kmp_cpuinfo_file));
1834 static void __kmp_stg_print_cpuinfo_file(kmp_str_buf_t *buffer,
1835 char const *name,
void *data) {
1836 #if KMP_AFFINITY_SUPPORTED
1837 if (__kmp_env_format) {
1838 KMP_STR_BUF_PRINT_NAME;
1840 __kmp_str_buf_print(buffer,
" %s", name);
1842 if (__kmp_cpuinfo_file) {
1843 __kmp_str_buf_print(buffer,
"='%s'\n", __kmp_cpuinfo_file);
1845 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
1853 static void __kmp_stg_parse_force_reduction(
char const *name,
char const *value,
1855 kmp_stg_fr_data_t *reduction = (kmp_stg_fr_data_t *)data;
1858 rc = __kmp_stg_check_rivals(name, value, reduction->rivals);
1862 if (reduction->force) {
1864 if (__kmp_str_match(
"critical", 0, value))
1865 __kmp_force_reduction_method = critical_reduce_block;
1866 else if (__kmp_str_match(
"atomic", 0, value))
1867 __kmp_force_reduction_method = atomic_reduce_block;
1868 else if (__kmp_str_match(
"tree", 0, value))
1869 __kmp_force_reduction_method = tree_reduce_block;
1871 KMP_FATAL(UnknownForceReduction, name, value);
1875 __kmp_stg_parse_bool(name, value, &__kmp_determ_red);
1876 if (__kmp_determ_red) {
1877 __kmp_force_reduction_method = tree_reduce_block;
1879 __kmp_force_reduction_method = reduction_method_not_defined;
1882 K_DIAG(1, (
"__kmp_force_reduction_method == %d\n",
1883 __kmp_force_reduction_method));
1886 static void __kmp_stg_print_force_reduction(kmp_str_buf_t *buffer,
1887 char const *name,
void *data) {
1889 kmp_stg_fr_data_t *reduction = (kmp_stg_fr_data_t *)data;
1890 if (reduction->force) {
1891 if (__kmp_force_reduction_method == critical_reduce_block) {
1892 __kmp_stg_print_str(buffer, name,
"critical");
1893 }
else if (__kmp_force_reduction_method == atomic_reduce_block) {
1894 __kmp_stg_print_str(buffer, name,
"atomic");
1895 }
else if (__kmp_force_reduction_method == tree_reduce_block) {
1896 __kmp_stg_print_str(buffer, name,
"tree");
1898 if (__kmp_env_format) {
1899 KMP_STR_BUF_PRINT_NAME;
1901 __kmp_str_buf_print(buffer,
" %s", name);
1903 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
1906 __kmp_stg_print_bool(buffer, name, __kmp_determ_red);
1914 static void __kmp_stg_parse_storage_map(
char const *name,
char const *value,
1916 if (__kmp_str_match(
"verbose", 1, value)) {
1917 __kmp_storage_map = TRUE;
1918 __kmp_storage_map_verbose = TRUE;
1919 __kmp_storage_map_verbose_specified = TRUE;
1922 __kmp_storage_map_verbose = FALSE;
1923 __kmp_stg_parse_bool(name, value, &__kmp_storage_map);
1927 static void __kmp_stg_print_storage_map(kmp_str_buf_t *buffer,
char const *name,
1929 if (__kmp_storage_map_verbose || __kmp_storage_map_verbose_specified) {
1930 __kmp_stg_print_str(buffer, name,
"verbose");
1932 __kmp_stg_print_bool(buffer, name, __kmp_storage_map);
1939 static void __kmp_stg_parse_all_threadprivate(
char const *name,
1940 char const *value,
void *data) {
1941 __kmp_stg_parse_int(name, value,
1942 __kmp_allThreadsSpecified ? __kmp_max_nth : 1,
1943 __kmp_max_nth, &__kmp_tp_capacity);
1946 static void __kmp_stg_print_all_threadprivate(kmp_str_buf_t *buffer,
1947 char const *name,
void *data) {
1948 __kmp_stg_print_int(buffer, name, __kmp_tp_capacity);
1954 static void __kmp_stg_parse_foreign_threads_threadprivate(
char const *name,
1957 __kmp_stg_parse_bool(name, value, &__kmp_foreign_tp);
1960 static void __kmp_stg_print_foreign_threads_threadprivate(kmp_str_buf_t *buffer,
1963 __kmp_stg_print_bool(buffer, name, __kmp_foreign_tp);
1969 #if KMP_AFFINITY_SUPPORTED
1971 static int __kmp_parse_affinity_proc_id_list(
const char *var,
const char *env,
1972 const char **nextEnv,
1974 const char *scan = env;
1975 const char *next = scan;
1981 int start, end, stride;
1985 if (*next ==
'\0') {
1996 if ((*next <
'0') || (*next >
'9')) {
1997 KMP_WARNING(AffSyntaxError, var);
2001 num = __kmp_str_to_int(scan, *next);
2002 KMP_ASSERT(num >= 0);
2020 if ((*next <
'0') || (*next >
'9')) {
2021 KMP_WARNING(AffSyntaxError, var);
2026 num = __kmp_str_to_int(scan, *next);
2027 KMP_ASSERT(num >= 0);
2040 if ((*next <
'0') || (*next >
'9')) {
2042 KMP_WARNING(AffSyntaxError, var);
2050 start = __kmp_str_to_int(scan, *next);
2051 KMP_ASSERT(start >= 0);
2070 if ((*next <
'0') || (*next >
'9')) {
2071 KMP_WARNING(AffSyntaxError, var);
2075 end = __kmp_str_to_int(scan, *next);
2076 KMP_ASSERT(end >= 0);
2093 if ((*next <
'0') || (*next >
'9')) {
2094 KMP_WARNING(AffSyntaxError, var);
2098 stride = __kmp_str_to_int(scan, *next);
2099 KMP_ASSERT(stride >= 0);
2105 KMP_WARNING(AffZeroStride, var);
2110 KMP_WARNING(AffStartGreaterEnd, var, start, end);
2115 KMP_WARNING(AffStrideLessZero, var, start, end);
2119 if ((end - start) / stride > 65536) {
2120 KMP_WARNING(AffRangeTooBig, var, end, start, stride);
2137 ptrdiff_t len = next - env;
2138 char *retlist = (
char *)__kmp_allocate((len + 1) *
sizeof(char));
2139 KMP_MEMCPY_S(retlist, (len + 1) *
sizeof(
char), env, len *
sizeof(
char));
2140 retlist[len] =
'\0';
2141 *proclist = retlist;
2148 static kmp_setting_t *__kmp_affinity_notype = NULL;
2150 static void __kmp_parse_affinity_env(
char const *name,
char const *value,
2151 enum affinity_type *out_type,
2152 char **out_proclist,
int *out_verbose,
2153 int *out_warn,
int *out_respect,
2154 kmp_hw_t *out_gran,
int *out_gran_levels,
2155 int *out_dups,
int *out_compact,
2157 char *buffer = NULL;
2174 KMP_ASSERT(value != NULL);
2176 if (TCR_4(__kmp_init_middle)) {
2177 KMP_WARNING(EnvMiddleWarn, name);
2178 __kmp_env_toPrint(name, 0);
2181 __kmp_env_toPrint(name, 1);
2184 __kmp_str_format(
"%s", value);
2194 #define EMIT_WARN(skip, errlist) \
2198 SKIP_TO(next, ','); \
2202 KMP_WARNING errlist; \
2211 #define _set_param(_guard, _var, _val) \
2213 if (_guard == 0) { \
2216 EMIT_WARN(FALSE, (AffParamDefined, name, start)); \
2221 #define set_type(val) _set_param(type, *out_type, val)
2222 #define set_verbose(val) _set_param(verbose, *out_verbose, val)
2223 #define set_warnings(val) _set_param(warnings, *out_warn, val)
2224 #define set_respect(val) _set_param(respect, *out_respect, val)
2225 #define set_dups(val) _set_param(dups, *out_dups, val)
2226 #define set_proclist(val) _set_param(proclist, *out_proclist, val)
2228 #define set_gran(val, levels) \
2232 *out_gran_levels = levels; \
2234 EMIT_WARN(FALSE, (AffParamDefined, name, start)); \
2239 KMP_DEBUG_ASSERT((__kmp_nested_proc_bind.bind_types != NULL) &&
2240 (__kmp_nested_proc_bind.used > 0));
2242 while (*buf !=
'\0') {
2245 if (__kmp_match_str(
"none", buf, CCAST(
const char **, &next))) {
2246 set_type(affinity_none);
2247 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
2249 }
else if (__kmp_match_str(
"scatter", buf, CCAST(
const char **, &next))) {
2250 set_type(affinity_scatter);
2251 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2253 }
else if (__kmp_match_str(
"compact", buf, CCAST(
const char **, &next))) {
2254 set_type(affinity_compact);
2255 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2257 }
else if (__kmp_match_str(
"logical", buf, CCAST(
const char **, &next))) {
2258 set_type(affinity_logical);
2259 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2261 }
else if (__kmp_match_str(
"physical", buf, CCAST(
const char **, &next))) {
2262 set_type(affinity_physical);
2263 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2265 }
else if (__kmp_match_str(
"explicit", buf, CCAST(
const char **, &next))) {
2266 set_type(affinity_explicit);
2267 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2269 }
else if (__kmp_match_str(
"balanced", buf, CCAST(
const char **, &next))) {
2270 set_type(affinity_balanced);
2271 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2273 }
else if (__kmp_match_str(
"disabled", buf, CCAST(
const char **, &next))) {
2274 set_type(affinity_disabled);
2275 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
2277 }
else if (__kmp_match_str(
"verbose", buf, CCAST(
const char **, &next))) {
2280 }
else if (__kmp_match_str(
"noverbose", buf, CCAST(
const char **, &next))) {
2283 }
else if (__kmp_match_str(
"warnings", buf, CCAST(
const char **, &next))) {
2286 }
else if (__kmp_match_str(
"nowarnings", buf,
2287 CCAST(
const char **, &next))) {
2288 set_warnings(FALSE);
2290 }
else if (__kmp_match_str(
"respect", buf, CCAST(
const char **, &next))) {
2293 }
else if (__kmp_match_str(
"norespect", buf, CCAST(
const char **, &next))) {
2296 }
else if (__kmp_match_str(
"duplicates", buf,
2297 CCAST(
const char **, &next)) ||
2298 __kmp_match_str(
"dups", buf, CCAST(
const char **, &next))) {
2301 }
else if (__kmp_match_str(
"noduplicates", buf,
2302 CCAST(
const char **, &next)) ||
2303 __kmp_match_str(
"nodups", buf, CCAST(
const char **, &next))) {
2306 }
else if (__kmp_match_str(
"granularity", buf,
2307 CCAST(
const char **, &next)) ||
2308 __kmp_match_str(
"gran", buf, CCAST(
const char **, &next))) {
2311 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2320 KMP_FOREACH_HW_TYPE(type) {
2321 const char *name = __kmp_hw_get_keyword(type);
2322 if (__kmp_match_str(name, buf, CCAST(
const char **, &next))) {
2331 if (__kmp_match_str(
"fine", buf, CCAST(
const char **, &next))) {
2332 set_gran(KMP_HW_THREAD, -1);
2335 }
else if (__kmp_match_str(
"package", buf,
2336 CCAST(
const char **, &next))) {
2337 set_gran(KMP_HW_SOCKET, -1);
2340 }
else if (__kmp_match_str(
"node", buf, CCAST(
const char **, &next))) {
2341 set_gran(KMP_HW_NUMA, -1);
2344 #if KMP_GROUP_AFFINITY
2345 }
else if (__kmp_match_str(
"group", buf, CCAST(
const char **, &next))) {
2346 set_gran(KMP_HW_PROC_GROUP, -1);
2350 }
else if ((*buf >=
'0') && (*buf <=
'9')) {
2354 n = __kmp_str_to_int(buf, *next);
2357 set_gran(KMP_HW_UNKNOWN, n);
2360 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2364 }
else if (__kmp_match_str(
"proclist", buf, CCAST(
const char **, &next))) {
2365 char *temp_proclist;
2369 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2375 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2380 if (!__kmp_parse_affinity_proc_id_list(
2381 name, buf, CCAST(
const char **, &next), &temp_proclist)) {
2393 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2397 set_proclist(temp_proclist);
2398 }
else if ((*buf >=
'0') && (*buf <=
'9')) {
2403 n = __kmp_str_to_int(buf, *next);
2409 KMP_WARNING(AffManyParams, name, start);
2413 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2421 }
else if (*next !=
'\0') {
2422 const char *temp = next;
2423 EMIT_WARN(TRUE, (ParseExtraCharsWarn, name, temp));
2435 #undef set_granularity
2437 __kmp_str_free(&buffer);
2441 KMP_WARNING(AffProcListNoType, name);
2442 *out_type = affinity_explicit;
2443 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2444 }
else if (*out_type != affinity_explicit) {
2445 KMP_WARNING(AffProcListNotExplicit, name);
2446 KMP_ASSERT(*out_proclist != NULL);
2447 KMP_INTERNAL_FREE(*out_proclist);
2448 *out_proclist = NULL;
2451 switch (*out_type) {
2452 case affinity_logical:
2453 case affinity_physical: {
2455 *out_offset = number[0];
2458 KMP_WARNING(AffManyParamsForLogic, name, number[1]);
2461 case affinity_balanced: {
2463 *out_compact = number[0];
2466 *out_offset = number[1];
2469 if (__kmp_affinity_gran == KMP_HW_UNKNOWN) {
2470 #if KMP_MIC_SUPPORTED
2471 if (__kmp_mic_type != non_mic) {
2472 if (__kmp_affinity_verbose || __kmp_affinity_warnings) {
2473 KMP_WARNING(AffGranUsing,
"KMP_AFFINITY",
"fine");
2475 __kmp_affinity_gran = KMP_HW_THREAD;
2479 if (__kmp_affinity_verbose || __kmp_affinity_warnings) {
2480 KMP_WARNING(AffGranUsing,
"KMP_AFFINITY",
"core");
2482 __kmp_affinity_gran = KMP_HW_CORE;
2486 case affinity_scatter:
2487 case affinity_compact: {
2489 *out_compact = number[0];
2492 *out_offset = number[1];
2495 case affinity_explicit: {
2496 if (*out_proclist == NULL) {
2497 KMP_WARNING(AffNoProcList, name);
2498 __kmp_affinity_type = affinity_none;
2501 KMP_WARNING(AffNoParam, name,
"explicit");
2504 case affinity_none: {
2506 KMP_WARNING(AffNoParam, name,
"none");
2509 case affinity_disabled: {
2511 KMP_WARNING(AffNoParam, name,
"disabled");
2514 case affinity_default: {
2516 KMP_WARNING(AffNoParam, name,
"default");
2525 static void __kmp_stg_parse_affinity(
char const *name,
char const *value,
2527 kmp_setting_t **rivals = (kmp_setting_t **)data;
2530 rc = __kmp_stg_check_rivals(name, value, rivals);
2535 __kmp_parse_affinity_env(name, value, &__kmp_affinity_type,
2536 &__kmp_affinity_proclist, &__kmp_affinity_verbose,
2537 &__kmp_affinity_warnings,
2538 &__kmp_affinity_respect_mask, &__kmp_affinity_gran,
2539 &__kmp_affinity_gran_levels, &__kmp_affinity_dups,
2540 &__kmp_affinity_compact, &__kmp_affinity_offset);
2544 static void __kmp_stg_print_affinity(kmp_str_buf_t *buffer,
char const *name,
2546 if (__kmp_env_format) {
2547 KMP_STR_BUF_PRINT_NAME_EX(name);
2549 __kmp_str_buf_print(buffer,
" %s='", name);
2551 if (__kmp_affinity_verbose) {
2552 __kmp_str_buf_print(buffer,
"%s,",
"verbose");
2554 __kmp_str_buf_print(buffer,
"%s,",
"noverbose");
2556 if (__kmp_affinity_warnings) {
2557 __kmp_str_buf_print(buffer,
"%s,",
"warnings");
2559 __kmp_str_buf_print(buffer,
"%s,",
"nowarnings");
2561 if (KMP_AFFINITY_CAPABLE()) {
2562 if (__kmp_affinity_respect_mask) {
2563 __kmp_str_buf_print(buffer,
"%s,",
"respect");
2565 __kmp_str_buf_print(buffer,
"%s,",
"norespect");
2567 __kmp_str_buf_print(buffer,
"granularity=%s,",
2568 __kmp_hw_get_keyword(__kmp_affinity_gran,
false));
2570 if (!KMP_AFFINITY_CAPABLE()) {
2571 __kmp_str_buf_print(buffer,
"%s",
"disabled");
2573 switch (__kmp_affinity_type) {
2575 __kmp_str_buf_print(buffer,
"%s",
"none");
2577 case affinity_physical:
2578 __kmp_str_buf_print(buffer,
"%s,%d",
"physical", __kmp_affinity_offset);
2580 case affinity_logical:
2581 __kmp_str_buf_print(buffer,
"%s,%d",
"logical", __kmp_affinity_offset);
2583 case affinity_compact:
2584 __kmp_str_buf_print(buffer,
"%s,%d,%d",
"compact", __kmp_affinity_compact,
2585 __kmp_affinity_offset);
2587 case affinity_scatter:
2588 __kmp_str_buf_print(buffer,
"%s,%d,%d",
"scatter", __kmp_affinity_compact,
2589 __kmp_affinity_offset);
2591 case affinity_explicit:
2592 __kmp_str_buf_print(buffer,
"%s=[%s],%s",
"proclist",
2593 __kmp_affinity_proclist,
"explicit");
2595 case affinity_balanced:
2596 __kmp_str_buf_print(buffer,
"%s,%d,%d",
"balanced",
2597 __kmp_affinity_compact, __kmp_affinity_offset);
2599 case affinity_disabled:
2600 __kmp_str_buf_print(buffer,
"%s",
"disabled");
2602 case affinity_default:
2603 __kmp_str_buf_print(buffer,
"%s",
"default");
2606 __kmp_str_buf_print(buffer,
"%s",
"<unknown>");
2609 __kmp_str_buf_print(buffer,
"'\n");
2612 #ifdef KMP_GOMP_COMPAT
2614 static void __kmp_stg_parse_gomp_cpu_affinity(
char const *name,
2615 char const *value,
void *data) {
2616 const char *next = NULL;
2617 char *temp_proclist;
2618 kmp_setting_t **rivals = (kmp_setting_t **)data;
2621 rc = __kmp_stg_check_rivals(name, value, rivals);
2626 if (TCR_4(__kmp_init_middle)) {
2627 KMP_WARNING(EnvMiddleWarn, name);
2628 __kmp_env_toPrint(name, 0);
2632 __kmp_env_toPrint(name, 1);
2634 if (__kmp_parse_affinity_proc_id_list(name, value, &next, &temp_proclist)) {
2636 if (*next ==
'\0') {
2638 __kmp_affinity_proclist = temp_proclist;
2639 __kmp_affinity_type = affinity_explicit;
2640 __kmp_affinity_gran = KMP_HW_THREAD;
2641 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2643 KMP_WARNING(AffSyntaxError, name);
2644 if (temp_proclist != NULL) {
2645 KMP_INTERNAL_FREE((
void *)temp_proclist);
2650 __kmp_affinity_type = affinity_none;
2651 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
2678 static inline void __kmp_omp_places_syntax_warn(
const char *var) {
2679 KMP_WARNING(SyntaxErrorUsing, var,
"\"cores\"");
2682 static int __kmp_parse_subplace_list(
const char *var,
const char **scan) {
2686 int start, count, stride;
2692 if ((**scan <
'0') || (**scan >
'9')) {
2693 __kmp_omp_places_syntax_warn(var);
2698 start = __kmp_str_to_int(*scan, *next);
2699 KMP_ASSERT(start >= 0);
2704 if (**scan ==
'}') {
2707 if (**scan ==
',') {
2711 if (**scan !=
':') {
2712 __kmp_omp_places_syntax_warn(var);
2719 if ((**scan <
'0') || (**scan >
'9')) {
2720 __kmp_omp_places_syntax_warn(var);
2725 count = __kmp_str_to_int(*scan, *next);
2726 KMP_ASSERT(count >= 0);
2731 if (**scan ==
'}') {
2734 if (**scan ==
',') {
2738 if (**scan !=
':') {
2739 __kmp_omp_places_syntax_warn(var);
2748 if (**scan ==
'+') {
2752 if (**scan ==
'-') {
2760 if ((**scan <
'0') || (**scan >
'9')) {
2761 __kmp_omp_places_syntax_warn(var);
2766 stride = __kmp_str_to_int(*scan, *next);
2767 KMP_ASSERT(stride >= 0);
2773 if (**scan ==
'}') {
2776 if (**scan ==
',') {
2781 __kmp_omp_places_syntax_warn(var);
2787 static int __kmp_parse_place(
const char *var,
const char **scan) {
2792 if (**scan ==
'{') {
2794 if (!__kmp_parse_subplace_list(var, scan)) {
2797 if (**scan !=
'}') {
2798 __kmp_omp_places_syntax_warn(var);
2802 }
else if (**scan ==
'!') {
2804 return __kmp_parse_place(var, scan);
2805 }
else if ((**scan >=
'0') && (**scan <=
'9')) {
2808 int proc = __kmp_str_to_int(*scan, *next);
2809 KMP_ASSERT(proc >= 0);
2812 __kmp_omp_places_syntax_warn(var);
2818 static int __kmp_parse_place_list(
const char *var,
const char *env,
2819 char **place_list) {
2820 const char *scan = env;
2821 const char *next = scan;
2826 if (!__kmp_parse_place(var, &scan)) {
2832 if (*scan ==
'\0') {
2840 __kmp_omp_places_syntax_warn(var);
2847 if ((*scan <
'0') || (*scan >
'9')) {
2848 __kmp_omp_places_syntax_warn(var);
2853 count = __kmp_str_to_int(scan, *next);
2854 KMP_ASSERT(count >= 0);
2859 if (*scan ==
'\0') {
2867 __kmp_omp_places_syntax_warn(var);
2888 if ((*scan <
'0') || (*scan >
'9')) {
2889 __kmp_omp_places_syntax_warn(var);
2894 stride = __kmp_str_to_int(scan, *next);
2895 KMP_ASSERT(stride >= 0);
2901 if (*scan ==
'\0') {
2909 __kmp_omp_places_syntax_warn(var);
2914 ptrdiff_t len = scan - env;
2915 char *retlist = (
char *)__kmp_allocate((len + 1) *
sizeof(char));
2916 KMP_MEMCPY_S(retlist, (len + 1) *
sizeof(
char), env, len *
sizeof(
char));
2917 retlist[len] =
'\0';
2918 *place_list = retlist;
2923 static void __kmp_stg_parse_places(
char const *name,
char const *value,
2925 struct kmp_place_t {
2931 const char *scan = value;
2932 const char *next = scan;
2933 const char *kind =
"\"threads\"";
2934 kmp_place_t std_places[] = {{
"threads", KMP_HW_THREAD},
2935 {
"cores", KMP_HW_CORE},
2936 {
"numa_domains", KMP_HW_NUMA},
2937 {
"ll_caches", KMP_HW_LLC},
2938 {
"sockets", KMP_HW_SOCKET}};
2939 kmp_setting_t **rivals = (kmp_setting_t **)data;
2942 rc = __kmp_stg_check_rivals(name, value, rivals);
2948 for (
size_t i = 0; i <
sizeof(std_places) /
sizeof(std_places[0]); ++i) {
2949 const kmp_place_t &place = std_places[i];
2950 if (__kmp_match_str(place.name, scan, &next)) {
2952 __kmp_affinity_type = affinity_compact;
2953 __kmp_affinity_gran = place.type;
2954 __kmp_affinity_dups = FALSE;
2961 KMP_FOREACH_HW_TYPE(type) {
2962 const char *name = __kmp_hw_get_keyword(type,
true);
2963 if (__kmp_match_str(
"unknowns", scan, &next))
2965 if (__kmp_match_str(name, scan, &next)) {
2967 __kmp_affinity_type = affinity_compact;
2968 __kmp_affinity_gran = type;
2969 __kmp_affinity_dups = FALSE;
2976 if (__kmp_affinity_proclist != NULL) {
2977 KMP_INTERNAL_FREE((
void *)__kmp_affinity_proclist);
2978 __kmp_affinity_proclist = NULL;
2980 if (__kmp_parse_place_list(name, value, &__kmp_affinity_proclist)) {
2981 __kmp_affinity_type = affinity_explicit;
2982 __kmp_affinity_gran = KMP_HW_THREAD;
2983 __kmp_affinity_dups = FALSE;
2986 __kmp_affinity_type = affinity_compact;
2987 __kmp_affinity_gran = KMP_HW_CORE;
2988 __kmp_affinity_dups = FALSE;
2990 if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_default) {
2991 __kmp_nested_proc_bind.bind_types[0] = proc_bind_true;
2995 if (__kmp_affinity_gran != KMP_HW_UNKNOWN) {
2996 kind = __kmp_hw_get_keyword(__kmp_affinity_gran);
2999 if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_default) {
3000 __kmp_nested_proc_bind.bind_types[0] = proc_bind_true;
3004 if (*scan ==
'\0') {
3010 KMP_WARNING(SyntaxErrorUsing, name, kind);
3018 count = __kmp_str_to_int(scan, *next);
3019 KMP_ASSERT(count >= 0);
3024 KMP_WARNING(SyntaxErrorUsing, name, kind);
3030 if (*scan !=
'\0') {
3031 KMP_WARNING(ParseExtraCharsWarn, name, scan);
3033 __kmp_affinity_num_places = count;
3036 static void __kmp_stg_print_places(kmp_str_buf_t *buffer,
char const *name,
3038 if (__kmp_env_format) {
3039 KMP_STR_BUF_PRINT_NAME;
3041 __kmp_str_buf_print(buffer,
" %s", name);
3043 if ((__kmp_nested_proc_bind.used == 0) ||
3044 (__kmp_nested_proc_bind.bind_types == NULL) ||
3045 (__kmp_nested_proc_bind.bind_types[0] == proc_bind_false)) {
3046 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
3047 }
else if (__kmp_affinity_type == affinity_explicit) {
3048 if (__kmp_affinity_proclist != NULL) {
3049 __kmp_str_buf_print(buffer,
"='%s'\n", __kmp_affinity_proclist);
3051 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
3053 }
else if (__kmp_affinity_type == affinity_compact) {
3055 if (__kmp_affinity_num_masks > 0) {
3056 num = __kmp_affinity_num_masks;
3057 }
else if (__kmp_affinity_num_places > 0) {
3058 num = __kmp_affinity_num_places;
3062 if (__kmp_affinity_gran != KMP_HW_UNKNOWN) {
3063 const char *name = __kmp_hw_get_keyword(__kmp_affinity_gran,
true);
3065 __kmp_str_buf_print(buffer,
"='%s(%d)'\n", name, num);
3067 __kmp_str_buf_print(buffer,
"='%s'\n", name);
3070 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
3073 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
3077 static void __kmp_stg_parse_topology_method(
char const *name,
char const *value,
3079 if (__kmp_str_match(
"all", 1, value)) {
3080 __kmp_affinity_top_method = affinity_top_method_all;
3083 else if (__kmp_str_match(
"hwloc", 1, value)) {
3084 __kmp_affinity_top_method = affinity_top_method_hwloc;
3087 #if KMP_ARCH_X86 || KMP_ARCH_X86_64
3088 else if (__kmp_str_match(
"cpuid_leaf31", 12, value) ||
3089 __kmp_str_match(
"cpuid 1f", 8, value) ||
3090 __kmp_str_match(
"cpuid 31", 8, value) ||
3091 __kmp_str_match(
"cpuid1f", 7, value) ||
3092 __kmp_str_match(
"cpuid31", 7, value) ||
3093 __kmp_str_match(
"leaf 1f", 7, value) ||
3094 __kmp_str_match(
"leaf 31", 7, value) ||
3095 __kmp_str_match(
"leaf1f", 6, value) ||
3096 __kmp_str_match(
"leaf31", 6, value)) {
3097 __kmp_affinity_top_method = affinity_top_method_x2apicid_1f;
3098 }
else if (__kmp_str_match(
"x2apic id", 9, value) ||
3099 __kmp_str_match(
"x2apic_id", 9, value) ||
3100 __kmp_str_match(
"x2apic-id", 9, value) ||
3101 __kmp_str_match(
"x2apicid", 8, value) ||
3102 __kmp_str_match(
"cpuid leaf 11", 13, value) ||
3103 __kmp_str_match(
"cpuid_leaf_11", 13, value) ||
3104 __kmp_str_match(
"cpuid-leaf-11", 13, value) ||
3105 __kmp_str_match(
"cpuid leaf11", 12, value) ||
3106 __kmp_str_match(
"cpuid_leaf11", 12, value) ||
3107 __kmp_str_match(
"cpuid-leaf11", 12, value) ||
3108 __kmp_str_match(
"cpuidleaf 11", 12, value) ||
3109 __kmp_str_match(
"cpuidleaf_11", 12, value) ||
3110 __kmp_str_match(
"cpuidleaf-11", 12, value) ||
3111 __kmp_str_match(
"cpuidleaf11", 11, value) ||
3112 __kmp_str_match(
"cpuid 11", 8, value) ||
3113 __kmp_str_match(
"cpuid_11", 8, value) ||
3114 __kmp_str_match(
"cpuid-11", 8, value) ||
3115 __kmp_str_match(
"cpuid11", 7, value) ||
3116 __kmp_str_match(
"leaf 11", 7, value) ||
3117 __kmp_str_match(
"leaf_11", 7, value) ||
3118 __kmp_str_match(
"leaf-11", 7, value) ||
3119 __kmp_str_match(
"leaf11", 6, value)) {
3120 __kmp_affinity_top_method = affinity_top_method_x2apicid;
3121 }
else if (__kmp_str_match(
"apic id", 7, value) ||
3122 __kmp_str_match(
"apic_id", 7, value) ||
3123 __kmp_str_match(
"apic-id", 7, value) ||
3124 __kmp_str_match(
"apicid", 6, value) ||
3125 __kmp_str_match(
"cpuid leaf 4", 12, value) ||
3126 __kmp_str_match(
"cpuid_leaf_4", 12, value) ||
3127 __kmp_str_match(
"cpuid-leaf-4", 12, value) ||
3128 __kmp_str_match(
"cpuid leaf4", 11, value) ||
3129 __kmp_str_match(
"cpuid_leaf4", 11, value) ||
3130 __kmp_str_match(
"cpuid-leaf4", 11, value) ||
3131 __kmp_str_match(
"cpuidleaf 4", 11, value) ||
3132 __kmp_str_match(
"cpuidleaf_4", 11, value) ||
3133 __kmp_str_match(
"cpuidleaf-4", 11, value) ||
3134 __kmp_str_match(
"cpuidleaf4", 10, value) ||
3135 __kmp_str_match(
"cpuid 4", 7, value) ||
3136 __kmp_str_match(
"cpuid_4", 7, value) ||
3137 __kmp_str_match(
"cpuid-4", 7, value) ||
3138 __kmp_str_match(
"cpuid4", 6, value) ||
3139 __kmp_str_match(
"leaf 4", 6, value) ||
3140 __kmp_str_match(
"leaf_4", 6, value) ||
3141 __kmp_str_match(
"leaf-4", 6, value) ||
3142 __kmp_str_match(
"leaf4", 5, value)) {
3143 __kmp_affinity_top_method = affinity_top_method_apicid;
3146 else if (__kmp_str_match(
"/proc/cpuinfo", 2, value) ||
3147 __kmp_str_match(
"cpuinfo", 5, value)) {
3148 __kmp_affinity_top_method = affinity_top_method_cpuinfo;
3150 #if KMP_GROUP_AFFINITY
3151 else if (__kmp_str_match(
"group", 1, value)) {
3152 KMP_WARNING(StgDeprecatedValue, name, value,
"all");
3153 __kmp_affinity_top_method = affinity_top_method_group;
3156 else if (__kmp_str_match(
"flat", 1, value)) {
3157 __kmp_affinity_top_method = affinity_top_method_flat;
3159 KMP_WARNING(StgInvalidValue, name, value);
3163 static void __kmp_stg_print_topology_method(kmp_str_buf_t *buffer,
3164 char const *name,
void *data) {
3165 char const *value = NULL;
3167 switch (__kmp_affinity_top_method) {
3168 case affinity_top_method_default:
3172 case affinity_top_method_all:
3176 #if KMP_ARCH_X86 || KMP_ARCH_X86_64
3177 case affinity_top_method_x2apicid_1f:
3178 value =
"x2APIC id leaf 0x1f";
3181 case affinity_top_method_x2apicid:
3182 value =
"x2APIC id leaf 0xb";
3185 case affinity_top_method_apicid:
3191 case affinity_top_method_hwloc:
3196 case affinity_top_method_cpuinfo:
3200 #if KMP_GROUP_AFFINITY
3201 case affinity_top_method_group:
3206 case affinity_top_method_flat:
3211 if (value != NULL) {
3212 __kmp_stg_print_str(buffer, name, value);
3217 struct kmp_proc_bind_info_t {
3219 kmp_proc_bind_t proc_bind;
3221 static kmp_proc_bind_info_t proc_bind_table[] = {
3222 {
"spread", proc_bind_spread},
3223 {
"true", proc_bind_spread},
3224 {
"close", proc_bind_close},
3226 {
"false", proc_bind_primary},
3227 {
"primary", proc_bind_primary}};
3228 static void __kmp_stg_parse_teams_proc_bind(
char const *name,
char const *value,
3233 for (
size_t i = 0; i <
sizeof(proc_bind_table) /
sizeof(proc_bind_table[0]);
3235 if (__kmp_match_str(proc_bind_table[i].name, value, &end)) {
3236 __kmp_teams_proc_bind = proc_bind_table[i].proc_bind;
3242 KMP_WARNING(StgInvalidValue, name, value);
3245 static void __kmp_stg_print_teams_proc_bind(kmp_str_buf_t *buffer,
3246 char const *name,
void *data) {
3247 const char *value = KMP_I18N_STR(NotDefined);
3248 for (
size_t i = 0; i <
sizeof(proc_bind_table) /
sizeof(proc_bind_table[0]);
3250 if (__kmp_teams_proc_bind == proc_bind_table[i].proc_bind) {
3251 value = proc_bind_table[i].name;
3255 __kmp_stg_print_str(buffer, name, value);
3261 static void __kmp_stg_parse_proc_bind(
char const *name,
char const *value,
3263 kmp_setting_t **rivals = (kmp_setting_t **)data;
3266 rc = __kmp_stg_check_rivals(name, value, rivals);
3272 KMP_DEBUG_ASSERT((__kmp_nested_proc_bind.bind_types != NULL) &&
3273 (__kmp_nested_proc_bind.used > 0));
3275 const char *buf = value;
3279 if ((*buf >=
'0') && (*buf <=
'9')) {
3282 num = __kmp_str_to_int(buf, *next);
3283 KMP_ASSERT(num >= 0);
3291 if (__kmp_match_str(
"disabled", buf, &next)) {
3294 #if KMP_AFFINITY_SUPPORTED
3295 __kmp_affinity_type = affinity_disabled;
3297 __kmp_nested_proc_bind.used = 1;
3298 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
3299 }
else if ((num == (
int)proc_bind_false) ||
3300 __kmp_match_str(
"false", buf, &next)) {
3303 #if KMP_AFFINITY_SUPPORTED
3304 __kmp_affinity_type = affinity_none;
3306 __kmp_nested_proc_bind.used = 1;
3307 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
3308 }
else if ((num == (
int)proc_bind_true) ||
3309 __kmp_match_str(
"true", buf, &next)) {
3312 __kmp_nested_proc_bind.used = 1;
3313 __kmp_nested_proc_bind.bind_types[0] = proc_bind_true;
3318 for (scan = buf; *scan !=
'\0'; scan++) {
3325 if (__kmp_nested_proc_bind.size < nelem) {
3326 __kmp_nested_proc_bind.bind_types =
3327 (kmp_proc_bind_t *)KMP_INTERNAL_REALLOC(
3328 __kmp_nested_proc_bind.bind_types,
3329 sizeof(kmp_proc_bind_t) * nelem);
3330 if (__kmp_nested_proc_bind.bind_types == NULL) {
3331 KMP_FATAL(MemoryAllocFailed);
3333 __kmp_nested_proc_bind.size = nelem;
3335 __kmp_nested_proc_bind.used = nelem;
3337 if (nelem > 1 && !__kmp_dflt_max_active_levels_set)
3338 __kmp_dflt_max_active_levels = KMP_MAX_ACTIVE_LEVELS_LIMIT;
3343 enum kmp_proc_bind_t bind;
3345 if ((num == (
int)proc_bind_primary) ||
3346 __kmp_match_str(
"master", buf, &next) ||
3347 __kmp_match_str(
"primary", buf, &next)) {
3350 bind = proc_bind_primary;
3351 }
else if ((num == (
int)proc_bind_close) ||
3352 __kmp_match_str(
"close", buf, &next)) {
3355 bind = proc_bind_close;
3356 }
else if ((num == (
int)proc_bind_spread) ||
3357 __kmp_match_str(
"spread", buf, &next)) {
3360 bind = proc_bind_spread;
3362 KMP_WARNING(StgInvalidValue, name, value);
3363 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
3364 __kmp_nested_proc_bind.used = 1;
3368 __kmp_nested_proc_bind.bind_types[i++] = bind;
3372 KMP_DEBUG_ASSERT(*buf ==
',');
3377 if ((*buf >=
'0') && (*buf <=
'9')) {
3380 num = __kmp_str_to_int(buf, *next);
3381 KMP_ASSERT(num >= 0);
3391 KMP_WARNING(ParseExtraCharsWarn, name, buf);
3395 static void __kmp_stg_print_proc_bind(kmp_str_buf_t *buffer,
char const *name,
3397 int nelem = __kmp_nested_proc_bind.used;
3398 if (__kmp_env_format) {
3399 KMP_STR_BUF_PRINT_NAME;
3401 __kmp_str_buf_print(buffer,
" %s", name);
3404 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
3407 __kmp_str_buf_print(buffer,
"='", name);
3408 for (i = 0; i < nelem; i++) {
3409 switch (__kmp_nested_proc_bind.bind_types[i]) {
3410 case proc_bind_false:
3411 __kmp_str_buf_print(buffer,
"false");
3414 case proc_bind_true:
3415 __kmp_str_buf_print(buffer,
"true");
3418 case proc_bind_primary:
3419 __kmp_str_buf_print(buffer,
"primary");
3422 case proc_bind_close:
3423 __kmp_str_buf_print(buffer,
"close");
3426 case proc_bind_spread:
3427 __kmp_str_buf_print(buffer,
"spread");
3430 case proc_bind_intel:
3431 __kmp_str_buf_print(buffer,
"intel");
3434 case proc_bind_default:
3435 __kmp_str_buf_print(buffer,
"default");
3438 if (i < nelem - 1) {
3439 __kmp_str_buf_print(buffer,
",");
3442 __kmp_str_buf_print(buffer,
"'\n");
3446 static void __kmp_stg_parse_display_affinity(
char const *name,
3447 char const *value,
void *data) {
3448 __kmp_stg_parse_bool(name, value, &__kmp_display_affinity);
3450 static void __kmp_stg_print_display_affinity(kmp_str_buf_t *buffer,
3451 char const *name,
void *data) {
3452 __kmp_stg_print_bool(buffer, name, __kmp_display_affinity);
3454 static void __kmp_stg_parse_affinity_format(
char const *name,
char const *value,
3456 size_t length = KMP_STRLEN(value);
3457 __kmp_strncpy_truncate(__kmp_affinity_format, KMP_AFFINITY_FORMAT_SIZE, value,
3460 static void __kmp_stg_print_affinity_format(kmp_str_buf_t *buffer,
3461 char const *name,
void *data) {
3462 if (__kmp_env_format) {
3463 KMP_STR_BUF_PRINT_NAME_EX(name);
3465 __kmp_str_buf_print(buffer,
" %s='", name);
3467 __kmp_str_buf_print(buffer,
"%s'\n", __kmp_affinity_format);
3489 static void __kmp_stg_parse_allocator(
char const *name,
char const *value,
3491 const char *buf = value;
3492 const char *next, *scan, *start;
3494 omp_allocator_handle_t al;
3495 omp_memspace_handle_t ms = omp_default_mem_space;
3496 bool is_memspace =
false;
3497 int ntraits = 0, count = 0;
3501 const char *delim = strchr(buf,
':');
3502 const char *predef_mem_space = strstr(buf,
"mem_space");
3504 bool is_memalloc = (!predef_mem_space && !delim) ?
true :
false;
3509 for (scan = buf; *scan !=
'\0'; scan++) {
3514 omp_alloctrait_t *traits =
3515 (omp_alloctrait_t *)KMP_ALLOCA(ntraits *
sizeof(omp_alloctrait_t));
3518 #define IS_POWER_OF_TWO(n) (((n) & ((n)-1)) == 0)
3520 #define GET_NEXT(sentinel) \
3523 if (*next == sentinel) \
3529 #define SKIP_PAIR(key) \
3531 char const str_delimiter[] = {',', 0}; \
3532 char *value = __kmp_str_token(CCAST(char *, scan), str_delimiter, \
3533 CCAST(char **, &next)); \
3534 KMP_WARNING(StgInvalidValue, key, value); \
3542 char const str_delimiter[] = {'=', 0}; \
3543 key = __kmp_str_token(CCAST(char *, start), str_delimiter, \
3544 CCAST(char **, &next)); \
3549 while (*next !=
'\0') {
3551 __kmp_match_str(
"fb_data", scan, &next)) {
3555 if (__kmp_match_str(
"omp_high_bw_mem_alloc", scan, &next)) {
3558 if (__kmp_memkind_available) {
3559 __kmp_def_allocator = omp_high_bw_mem_alloc;
3562 KMP_WARNING(OmpNoAllocator,
"omp_high_bw_mem_alloc");
3565 traits[count].key = omp_atk_fb_data;
3566 traits[count].value = RCAST(omp_uintptr_t, omp_high_bw_mem_alloc);
3568 }
else if (__kmp_match_str(
"omp_large_cap_mem_alloc", scan, &next)) {
3571 if (__kmp_memkind_available) {
3572 __kmp_def_allocator = omp_large_cap_mem_alloc;
3575 KMP_WARNING(OmpNoAllocator,
"omp_large_cap_mem_alloc");
3578 traits[count].key = omp_atk_fb_data;
3579 traits[count].value = RCAST(omp_uintptr_t, omp_large_cap_mem_alloc);
3581 }
else if (__kmp_match_str(
"omp_default_mem_alloc", scan, &next)) {
3585 traits[count].key = omp_atk_fb_data;
3586 traits[count].value = RCAST(omp_uintptr_t, omp_default_mem_alloc);
3588 }
else if (__kmp_match_str(
"omp_const_mem_alloc", scan, &next)) {
3591 KMP_WARNING(OmpNoAllocator,
"omp_const_mem_alloc");
3593 traits[count].key = omp_atk_fb_data;
3594 traits[count].value = RCAST(omp_uintptr_t, omp_const_mem_alloc);
3596 }
else if (__kmp_match_str(
"omp_low_lat_mem_alloc", scan, &next)) {
3599 KMP_WARNING(OmpNoAllocator,
"omp_low_lat_mem_alloc");
3601 traits[count].key = omp_atk_fb_data;
3602 traits[count].value = RCAST(omp_uintptr_t, omp_low_lat_mem_alloc);
3604 }
else if (__kmp_match_str(
"omp_cgroup_mem_alloc", scan, &next)) {
3607 KMP_WARNING(OmpNoAllocator,
"omp_cgroup_mem_alloc");
3609 traits[count].key = omp_atk_fb_data;
3610 traits[count].value = RCAST(omp_uintptr_t, omp_cgroup_mem_alloc);
3612 }
else if (__kmp_match_str(
"omp_pteam_mem_alloc", scan, &next)) {
3615 KMP_WARNING(OmpNoAllocator,
"omp_pteam_mem_alloc");
3617 traits[count].key = omp_atk_fb_data;
3618 traits[count].value = RCAST(omp_uintptr_t, omp_pteam_mem_alloc);
3620 }
else if (__kmp_match_str(
"omp_thread_mem_alloc", scan, &next)) {
3623 KMP_WARNING(OmpNoAllocator,
"omp_thread_mem_alloc");
3625 traits[count].key = omp_atk_fb_data;
3626 traits[count].value = RCAST(omp_uintptr_t, omp_thread_mem_alloc);
3636 __kmp_def_allocator = omp_default_mem_alloc;
3637 if (next == buf || *next !=
'\0') {
3639 KMP_WARNING(StgInvalidValue, name, value);
3644 if (count == ntraits)
3650 if (__kmp_match_str(
"omp_default_mem_space", scan, &next)) {
3652 ms = omp_default_mem_space;
3653 }
else if (__kmp_match_str(
"omp_large_cap_mem_space", scan, &next)) {
3655 ms = omp_large_cap_mem_space;
3656 }
else if (__kmp_match_str(
"omp_const_mem_space", scan, &next)) {
3658 ms = omp_const_mem_space;
3659 }
else if (__kmp_match_str(
"omp_high_bw_mem_space", scan, &next)) {
3661 ms = omp_high_bw_mem_space;
3662 }
else if (__kmp_match_str(
"omp_low_lat_mem_space", scan, &next)) {
3664 ms = omp_low_lat_mem_space;
3666 __kmp_def_allocator = omp_default_mem_alloc;
3667 if (next == buf || *next !=
'\0') {
3669 KMP_WARNING(StgInvalidValue, name, value);
3678 if (__kmp_match_str(
"sync_hint", scan, &next)) {
3680 traits[count].key = omp_atk_sync_hint;
3681 if (__kmp_match_str(
"contended", scan, &next)) {
3682 traits[count].value = omp_atv_contended;
3683 }
else if (__kmp_match_str(
"uncontended", scan, &next)) {
3684 traits[count].value = omp_atv_uncontended;
3685 }
else if (__kmp_match_str(
"serialized", scan, &next)) {
3686 traits[count].value = omp_atv_serialized;
3687 }
else if (__kmp_match_str(
"private", scan, &next)) {
3688 traits[count].value = omp_atv_private;
3694 }
else if (__kmp_match_str(
"alignment", scan, &next)) {
3696 if (!isdigit(*next)) {
3702 int n = __kmp_str_to_int(scan,
',');
3703 if (n < 0 || !IS_POWER_OF_TWO(n)) {
3708 traits[count].key = omp_atk_alignment;
3709 traits[count].value = n;
3710 }
else if (__kmp_match_str(
"access", scan, &next)) {
3712 traits[count].key = omp_atk_access;
3713 if (__kmp_match_str(
"all", scan, &next)) {
3714 traits[count].value = omp_atv_all;
3715 }
else if (__kmp_match_str(
"cgroup", scan, &next)) {
3716 traits[count].value = omp_atv_cgroup;
3717 }
else if (__kmp_match_str(
"pteam", scan, &next)) {
3718 traits[count].value = omp_atv_pteam;
3719 }
else if (__kmp_match_str(
"thread", scan, &next)) {
3720 traits[count].value = omp_atv_thread;
3726 }
else if (__kmp_match_str(
"pool_size", scan, &next)) {
3728 if (!isdigit(*next)) {
3734 int n = __kmp_str_to_int(scan,
',');
3740 traits[count].key = omp_atk_pool_size;
3741 traits[count].value = n;
3742 }
else if (__kmp_match_str(
"fallback", scan, &next)) {
3744 traits[count].key = omp_atk_fallback;
3745 if (__kmp_match_str(
"default_mem_fb", scan, &next)) {
3746 traits[count].value = omp_atv_default_mem_fb;
3747 }
else if (__kmp_match_str(
"null_fb", scan, &next)) {
3748 traits[count].value = omp_atv_null_fb;
3749 }
else if (__kmp_match_str(
"abort_fb", scan, &next)) {
3750 traits[count].value = omp_atv_abort_fb;
3751 }
else if (__kmp_match_str(
"allocator_fb", scan, &next)) {
3752 traits[count].value = omp_atv_allocator_fb;
3758 }
else if (__kmp_match_str(
"pinned", scan, &next)) {
3760 traits[count].key = omp_atk_pinned;
3761 if (__kmp_str_match_true(next)) {
3762 traits[count].value = omp_atv_true;
3763 }
else if (__kmp_str_match_false(next)) {
3764 traits[count].value = omp_atv_false;
3770 }
else if (__kmp_match_str(
"partition", scan, &next)) {
3772 traits[count].key = omp_atk_partition;
3773 if (__kmp_match_str(
"environment", scan, &next)) {
3774 traits[count].value = omp_atv_environment;
3775 }
else if (__kmp_match_str(
"nearest", scan, &next)) {
3776 traits[count].value = omp_atv_nearest;
3777 }
else if (__kmp_match_str(
"blocked", scan, &next)) {
3778 traits[count].value = omp_atv_blocked;
3779 }
else if (__kmp_match_str(
"interleaved", scan, &next)) {
3780 traits[count].value = omp_atv_interleaved;
3793 if (count == ntraits)
3799 al = __kmpc_init_allocator(__kmp_get_gtid(), ms, ntraits, traits);
3800 __kmp_def_allocator = (al == omp_null_allocator) ? omp_default_mem_alloc : al;
3803 static void __kmp_stg_print_allocator(kmp_str_buf_t *buffer,
char const *name,
3805 if (__kmp_def_allocator == omp_default_mem_alloc) {
3806 __kmp_stg_print_str(buffer, name,
"omp_default_mem_alloc");
3807 }
else if (__kmp_def_allocator == omp_high_bw_mem_alloc) {
3808 __kmp_stg_print_str(buffer, name,
"omp_high_bw_mem_alloc");
3809 }
else if (__kmp_def_allocator == omp_large_cap_mem_alloc) {
3810 __kmp_stg_print_str(buffer, name,
"omp_large_cap_mem_alloc");
3811 }
else if (__kmp_def_allocator == omp_const_mem_alloc) {
3812 __kmp_stg_print_str(buffer, name,
"omp_const_mem_alloc");
3813 }
else if (__kmp_def_allocator == omp_low_lat_mem_alloc) {
3814 __kmp_stg_print_str(buffer, name,
"omp_low_lat_mem_alloc");
3815 }
else if (__kmp_def_allocator == omp_cgroup_mem_alloc) {
3816 __kmp_stg_print_str(buffer, name,
"omp_cgroup_mem_alloc");
3817 }
else if (__kmp_def_allocator == omp_pteam_mem_alloc) {
3818 __kmp_stg_print_str(buffer, name,
"omp_pteam_mem_alloc");
3819 }
else if (__kmp_def_allocator == omp_thread_mem_alloc) {
3820 __kmp_stg_print_str(buffer, name,
"omp_thread_mem_alloc");
3827 static void __kmp_stg_parse_omp_dynamic(
char const *name,
char const *value,
3829 __kmp_stg_parse_bool(name, value, &(__kmp_global.g.g_dynamic));
3832 static void __kmp_stg_print_omp_dynamic(kmp_str_buf_t *buffer,
char const *name,
3834 __kmp_stg_print_bool(buffer, name, __kmp_global.g.g_dynamic);
3837 static void __kmp_stg_parse_kmp_dynamic_mode(
char const *name,
3838 char const *value,
void *data) {
3839 if (TCR_4(__kmp_init_parallel)) {
3840 KMP_WARNING(EnvParallelWarn, name);
3841 __kmp_env_toPrint(name, 0);
3844 #ifdef USE_LOAD_BALANCE
3845 else if (__kmp_str_match(
"load balance", 2, value) ||
3846 __kmp_str_match(
"load_balance", 2, value) ||
3847 __kmp_str_match(
"load-balance", 2, value) ||
3848 __kmp_str_match(
"loadbalance", 2, value) ||
3849 __kmp_str_match(
"balance", 1, value)) {
3850 __kmp_global.g.g_dynamic_mode = dynamic_load_balance;
3853 else if (__kmp_str_match(
"thread limit", 1, value) ||
3854 __kmp_str_match(
"thread_limit", 1, value) ||
3855 __kmp_str_match(
"thread-limit", 1, value) ||
3856 __kmp_str_match(
"threadlimit", 1, value) ||
3857 __kmp_str_match(
"limit", 2, value)) {
3858 __kmp_global.g.g_dynamic_mode = dynamic_thread_limit;
3859 }
else if (__kmp_str_match(
"random", 1, value)) {
3860 __kmp_global.g.g_dynamic_mode = dynamic_random;
3862 KMP_WARNING(StgInvalidValue, name, value);
3866 static void __kmp_stg_print_kmp_dynamic_mode(kmp_str_buf_t *buffer,
3867 char const *name,
void *data) {
3869 if (__kmp_global.g.g_dynamic_mode == dynamic_default) {
3870 __kmp_str_buf_print(buffer,
" %s: %s \n", name, KMP_I18N_STR(NotDefined));
3872 #ifdef USE_LOAD_BALANCE
3873 else if (__kmp_global.g.g_dynamic_mode == dynamic_load_balance) {
3874 __kmp_stg_print_str(buffer, name,
"load balance");
3877 else if (__kmp_global.g.g_dynamic_mode == dynamic_thread_limit) {
3878 __kmp_stg_print_str(buffer, name,
"thread limit");
3879 }
else if (__kmp_global.g.g_dynamic_mode == dynamic_random) {
3880 __kmp_stg_print_str(buffer, name,
"random");
3887 #ifdef USE_LOAD_BALANCE
3892 static void __kmp_stg_parse_ld_balance_interval(
char const *name,
3893 char const *value,
void *data) {
3894 double interval = __kmp_convert_to_double(value);
3895 if (interval >= 0) {
3896 __kmp_load_balance_interval = interval;
3898 KMP_WARNING(StgInvalidValue, name, value);
3902 static void __kmp_stg_print_ld_balance_interval(kmp_str_buf_t *buffer,
3903 char const *name,
void *data) {
3905 __kmp_str_buf_print(buffer,
" %s=%8.6f\n", name,
3906 __kmp_load_balance_interval);
3915 static void __kmp_stg_parse_init_at_fork(
char const *name,
char const *value,
3917 __kmp_stg_parse_bool(name, value, &__kmp_need_register_atfork);
3918 if (__kmp_need_register_atfork) {
3919 __kmp_need_register_atfork_specified = TRUE;
3923 static void __kmp_stg_print_init_at_fork(kmp_str_buf_t *buffer,
3924 char const *name,
void *data) {
3925 __kmp_stg_print_bool(buffer, name, __kmp_need_register_atfork_specified);
3931 static void __kmp_stg_parse_schedule(
char const *name,
char const *value,
3934 if (value != NULL) {
3935 size_t length = KMP_STRLEN(value);
3936 if (length > INT_MAX) {
3937 KMP_WARNING(LongValue, name);
3939 const char *semicolon;
3940 if (value[length - 1] ==
'"' || value[length - 1] ==
'\'')
3941 KMP_WARNING(UnbalancedQuotes, name);
3945 semicolon = strchr(value,
';');
3946 if (*value && semicolon != value) {
3947 const char *comma = strchr(value,
',');
3954 if (!__kmp_strcasecmp_with_sentinel(
"static", value, sentinel)) {
3955 if (!__kmp_strcasecmp_with_sentinel(
"greedy", comma,
';')) {
3956 __kmp_static = kmp_sch_static_greedy;
3958 }
else if (!__kmp_strcasecmp_with_sentinel(
"balanced", comma,
3960 __kmp_static = kmp_sch_static_balanced;
3963 }
else if (!__kmp_strcasecmp_with_sentinel(
"guided", value,
3965 if (!__kmp_strcasecmp_with_sentinel(
"iterative", comma,
';')) {
3966 __kmp_guided = kmp_sch_guided_iterative_chunked;
3968 }
else if (!__kmp_strcasecmp_with_sentinel(
"analytical", comma,
3971 __kmp_guided = kmp_sch_guided_analytical_chunked;
3975 KMP_WARNING(InvalidClause, name, value);
3977 KMP_WARNING(EmptyClause, name);
3978 }
while ((value = semicolon ? semicolon + 1 : NULL));
3984 static void __kmp_stg_print_schedule(kmp_str_buf_t *buffer,
char const *name,
3986 if (__kmp_env_format) {
3987 KMP_STR_BUF_PRINT_NAME_EX(name);
3989 __kmp_str_buf_print(buffer,
" %s='", name);
3991 if (__kmp_static == kmp_sch_static_greedy) {
3992 __kmp_str_buf_print(buffer,
"%s",
"static,greedy");
3993 }
else if (__kmp_static == kmp_sch_static_balanced) {
3994 __kmp_str_buf_print(buffer,
"%s",
"static,balanced");
3996 if (__kmp_guided == kmp_sch_guided_iterative_chunked) {
3997 __kmp_str_buf_print(buffer,
";%s'\n",
"guided,iterative");
3998 }
else if (__kmp_guided == kmp_sch_guided_analytical_chunked) {
3999 __kmp_str_buf_print(buffer,
";%s'\n",
"guided,analytical");
4006 static inline void __kmp_omp_schedule_restore() {
4007 #if KMP_USE_HIER_SCHED
4008 __kmp_hier_scheds.deallocate();
4018 static const char *__kmp_parse_single_omp_schedule(
const char *name,
4020 bool parse_hier =
false) {
4022 const char *ptr = value;
4029 while (*delim !=
',' && *delim !=
':' && *delim !=
'\0')
4031 #if KMP_USE_HIER_SCHED
4032 kmp_hier_layer_e layer = kmp_hier_layer_e::LAYER_THREAD;
4034 if (*delim ==
',') {
4035 if (!__kmp_strcasecmp_with_sentinel(
"L1", ptr,
',')) {
4036 layer = kmp_hier_layer_e::LAYER_L1;
4037 }
else if (!__kmp_strcasecmp_with_sentinel(
"L2", ptr,
',')) {
4038 layer = kmp_hier_layer_e::LAYER_L2;
4039 }
else if (!__kmp_strcasecmp_with_sentinel(
"L3", ptr,
',')) {
4040 layer = kmp_hier_layer_e::LAYER_L3;
4041 }
else if (!__kmp_strcasecmp_with_sentinel(
"NUMA", ptr,
',')) {
4042 layer = kmp_hier_layer_e::LAYER_NUMA;
4045 if (layer != kmp_hier_layer_e::LAYER_THREAD && *delim !=
',') {
4047 KMP_WARNING(StgInvalidValue, name, value);
4048 __kmp_omp_schedule_restore();
4050 }
else if (layer != kmp_hier_layer_e::LAYER_THREAD) {
4052 while (*delim !=
',' && *delim !=
':' && *delim !=
'\0')
4059 if (*delim ==
':') {
4060 if (!__kmp_strcasecmp_with_sentinel(
"monotonic", ptr, *delim)) {
4063 while (*delim !=
',' && *delim !=
':' && *delim !=
'\0')
4065 }
else if (!__kmp_strcasecmp_with_sentinel(
"nonmonotonic", ptr, *delim)) {
4068 while (*delim !=
',' && *delim !=
':' && *delim !=
'\0')
4070 }
else if (!parse_hier) {
4072 KMP_WARNING(StgInvalidValue, name, value);
4073 __kmp_omp_schedule_restore();
4078 if (!__kmp_strcasecmp_with_sentinel(
"dynamic", ptr, *delim))
4079 sched = kmp_sch_dynamic_chunked;
4080 else if (!__kmp_strcasecmp_with_sentinel(
"guided", ptr, *delim))
4083 else if (!__kmp_strcasecmp_with_sentinel(
"auto", ptr, *delim))
4085 else if (!__kmp_strcasecmp_with_sentinel(
"trapezoidal", ptr, *delim))
4086 sched = kmp_sch_trapezoidal;
4087 else if (!__kmp_strcasecmp_with_sentinel(
"static", ptr, *delim))
4089 #if KMP_STATIC_STEAL_ENABLED
4090 else if (!__kmp_strcasecmp_with_sentinel(
"static_steal", ptr, *delim)) {
4092 sched = kmp_sch_dynamic_chunked;
4098 KMP_WARNING(StgInvalidValue, name, value);
4099 __kmp_omp_schedule_restore();
4104 if (*delim ==
',') {
4107 if (!isdigit(*ptr)) {
4109 KMP_WARNING(StgInvalidValue, name, value);
4110 __kmp_omp_schedule_restore();
4116 __kmp_msg(kmp_ms_warning, KMP_MSG(IgnoreChunk, name, delim),
4120 sched = kmp_sch_static_chunked;
4121 chunk = __kmp_str_to_int(delim + 1, *ptr);
4123 chunk = KMP_DEFAULT_CHUNK;
4124 __kmp_msg(kmp_ms_warning, KMP_MSG(InvalidChunk, name, delim),
4126 KMP_INFORM(Using_int_Value, name, __kmp_chunk);
4135 }
else if (chunk > KMP_MAX_CHUNK) {
4136 chunk = KMP_MAX_CHUNK;
4137 __kmp_msg(kmp_ms_warning, KMP_MSG(LargeChunk, name, delim),
4139 KMP_INFORM(Using_int_Value, name, chunk);
4146 SCHEDULE_SET_MODIFIERS(sched, sched_modifier);
4148 #if KMP_USE_HIER_SCHED
4149 if (layer != kmp_hier_layer_e::LAYER_THREAD) {
4150 __kmp_hier_scheds.append(sched, chunk, layer);
4154 __kmp_chunk = chunk;
4155 __kmp_sched = sched;
4160 static void __kmp_stg_parse_omp_schedule(
char const *name,
char const *value,
4163 const char *ptr = value;
4166 length = KMP_STRLEN(value);
4168 if (value[length - 1] ==
'"' || value[length - 1] ==
'\'')
4169 KMP_WARNING(UnbalancedQuotes, name);
4171 #if KMP_USE_HIER_SCHED
4172 if (!__kmp_strcasecmp_with_sentinel(
"EXPERIMENTAL", ptr,
' ')) {
4175 while ((ptr = __kmp_parse_single_omp_schedule(name, ptr,
true))) {
4176 while (*ptr ==
' ' || *ptr ==
'\t' || *ptr ==
':')
4183 __kmp_parse_single_omp_schedule(name, ptr);
4185 KMP_WARNING(EmptyString, name);
4187 #if KMP_USE_HIER_SCHED
4188 __kmp_hier_scheds.sort();
4190 K_DIAG(1, (
"__kmp_static == %d\n", __kmp_static))
4191 K_DIAG(1, (
"__kmp_guided == %d\n", __kmp_guided))
4192 K_DIAG(1, (
"__kmp_sched == %d\n", __kmp_sched))
4193 K_DIAG(1, (
"__kmp_chunk == %d\n", __kmp_chunk))
4196 static void __kmp_stg_print_omp_schedule(kmp_str_buf_t *buffer,
4197 char const *name,
void *data) {
4198 if (__kmp_env_format) {
4199 KMP_STR_BUF_PRINT_NAME_EX(name);
4201 __kmp_str_buf_print(buffer,
" %s='", name);
4203 enum sched_type sched = SCHEDULE_WITHOUT_MODIFIERS(__kmp_sched);
4204 if (SCHEDULE_HAS_MONOTONIC(__kmp_sched)) {
4205 __kmp_str_buf_print(buffer,
"monotonic:");
4206 }
else if (SCHEDULE_HAS_NONMONOTONIC(__kmp_sched)) {
4207 __kmp_str_buf_print(buffer,
"nonmonotonic:");
4211 case kmp_sch_dynamic_chunked:
4212 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"dynamic", __kmp_chunk);
4214 case kmp_sch_guided_iterative_chunked:
4215 case kmp_sch_guided_analytical_chunked:
4216 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"guided", __kmp_chunk);
4218 case kmp_sch_trapezoidal:
4219 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"trapezoidal", __kmp_chunk);
4222 case kmp_sch_static_chunked:
4223 case kmp_sch_static_balanced:
4224 case kmp_sch_static_greedy:
4225 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"static", __kmp_chunk);
4227 case kmp_sch_static_steal:
4228 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"static_steal", __kmp_chunk);
4231 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"auto", __kmp_chunk);
4236 case kmp_sch_dynamic_chunked:
4237 __kmp_str_buf_print(buffer,
"%s'\n",
"dynamic");
4239 case kmp_sch_guided_iterative_chunked:
4240 case kmp_sch_guided_analytical_chunked:
4241 __kmp_str_buf_print(buffer,
"%s'\n",
"guided");
4243 case kmp_sch_trapezoidal:
4244 __kmp_str_buf_print(buffer,
"%s'\n",
"trapezoidal");
4247 case kmp_sch_static_chunked:
4248 case kmp_sch_static_balanced:
4249 case kmp_sch_static_greedy:
4250 __kmp_str_buf_print(buffer,
"%s'\n",
"static");
4252 case kmp_sch_static_steal:
4253 __kmp_str_buf_print(buffer,
"%s'\n",
"static_steal");
4256 __kmp_str_buf_print(buffer,
"%s'\n",
"auto");
4262 #if KMP_USE_HIER_SCHED
4265 static void __kmp_stg_parse_kmp_hand_thread(
char const *name,
char const *value,
4267 __kmp_stg_parse_bool(name, value, &(__kmp_dispatch_hand_threading));
4270 static void __kmp_stg_print_kmp_hand_thread(kmp_str_buf_t *buffer,
4271 char const *name,
void *data) {
4272 __kmp_stg_print_bool(buffer, name, __kmp_dispatch_hand_threading);
4278 static void __kmp_stg_parse_kmp_force_monotonic(
char const *name,
4279 char const *value,
void *data) {
4280 __kmp_stg_parse_bool(name, value, &(__kmp_force_monotonic));
4283 static void __kmp_stg_print_kmp_force_monotonic(kmp_str_buf_t *buffer,
4284 char const *name,
void *data) {
4285 __kmp_stg_print_bool(buffer, name, __kmp_force_monotonic);
4291 static void __kmp_stg_parse_atomic_mode(
char const *name,
char const *value,
4297 #ifdef KMP_GOMP_COMPAT
4300 __kmp_stg_parse_int(name, value, 0, max, &mode);
4305 __kmp_atomic_mode = mode;
4309 static void __kmp_stg_print_atomic_mode(kmp_str_buf_t *buffer,
char const *name,
4311 __kmp_stg_print_int(buffer, name, __kmp_atomic_mode);
4317 static void __kmp_stg_parse_consistency_check(
char const *name,
4318 char const *value,
void *data) {
4319 if (!__kmp_strcasecmp_with_sentinel(
"all", value, 0)) {
4325 __kmp_env_consistency_check = TRUE;
4326 }
else if (!__kmp_strcasecmp_with_sentinel(
"none", value, 0)) {
4327 __kmp_env_consistency_check = FALSE;
4329 KMP_WARNING(StgInvalidValue, name, value);
4333 static void __kmp_stg_print_consistency_check(kmp_str_buf_t *buffer,
4334 char const *name,
void *data) {
4336 const char *value = NULL;
4338 if (__kmp_env_consistency_check) {
4344 if (value != NULL) {
4345 __kmp_stg_print_str(buffer, name, value);
4356 static void __kmp_stg_parse_itt_prepare_delay(
char const *name,
4357 char const *value,
void *data) {
4361 __kmp_stg_parse_int(name, value, 0, INT_MAX, &delay);
4362 __kmp_itt_prepare_delay = delay;
4365 static void __kmp_stg_print_itt_prepare_delay(kmp_str_buf_t *buffer,
4366 char const *name,
void *data) {
4367 __kmp_stg_print_uint64(buffer, name, __kmp_itt_prepare_delay);
4377 static void __kmp_stg_parse_malloc_pool_incr(
char const *name,
4378 char const *value,
void *data) {
4379 __kmp_stg_parse_size(name, value, KMP_MIN_MALLOC_POOL_INCR,
4380 KMP_MAX_MALLOC_POOL_INCR, NULL, &__kmp_malloc_pool_incr,
4384 static void __kmp_stg_print_malloc_pool_incr(kmp_str_buf_t *buffer,
4385 char const *name,
void *data) {
4386 __kmp_stg_print_size(buffer, name, __kmp_malloc_pool_incr);
4395 static void __kmp_stg_parse_par_range_env(
char const *name,
char const *value,
4397 __kmp_stg_parse_par_range(name, value, &__kmp_par_range,
4398 __kmp_par_range_routine, __kmp_par_range_filename,
4399 &__kmp_par_range_lb, &__kmp_par_range_ub);
4402 static void __kmp_stg_print_par_range_env(kmp_str_buf_t *buffer,
4403 char const *name,
void *data) {
4404 if (__kmp_par_range != 0) {
4405 __kmp_stg_print_str(buffer, name, par_range_to_print);
4414 static void __kmp_stg_parse_gtid_mode(
char const *name,
char const *value,
4424 #ifdef KMP_TDATA_GTID
4427 __kmp_stg_parse_int(name, value, 0, max, &mode);
4431 __kmp_adjust_gtid_mode = TRUE;
4433 __kmp_gtid_mode = mode;
4434 __kmp_adjust_gtid_mode = FALSE;
4438 static void __kmp_stg_print_gtid_mode(kmp_str_buf_t *buffer,
char const *name,
4440 if (__kmp_adjust_gtid_mode) {
4441 __kmp_stg_print_int(buffer, name, 0);
4443 __kmp_stg_print_int(buffer, name, __kmp_gtid_mode);
4450 static void __kmp_stg_parse_lock_block(
char const *name,
char const *value,
4452 __kmp_stg_parse_int(name, value, 0, KMP_INT_MAX, &__kmp_num_locks_in_block);
4455 static void __kmp_stg_print_lock_block(kmp_str_buf_t *buffer,
char const *name,
4457 __kmp_stg_print_int(buffer, name, __kmp_num_locks_in_block);
4463 #if KMP_USE_DYNAMIC_LOCK
4464 #define KMP_STORE_LOCK_SEQ(a) (__kmp_user_lock_seq = lockseq_##a)
4466 #define KMP_STORE_LOCK_SEQ(a)
4469 static void __kmp_stg_parse_lock_kind(
char const *name,
char const *value,
4471 if (__kmp_init_user_locks) {
4472 KMP_WARNING(EnvLockWarn, name);
4476 if (__kmp_str_match(
"tas", 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-and-set", 2, value) ||
4480 __kmp_str_match(
"test andset", 2, value) ||
4481 __kmp_str_match(
"test_andset", 2, value) ||
4482 __kmp_str_match(
"test-andset", 2, value) ||
4483 __kmp_str_match(
"testand set", 2, value) ||
4484 __kmp_str_match(
"testand_set", 2, value) ||
4485 __kmp_str_match(
"testand-set", 2, value) ||
4486 __kmp_str_match(
"testandset", 2, value)) {
4487 __kmp_user_lock_kind = lk_tas;
4488 KMP_STORE_LOCK_SEQ(tas);
4491 else if (__kmp_str_match(
"futex", 1, value)) {
4492 if (__kmp_futex_determine_capable()) {
4493 __kmp_user_lock_kind = lk_futex;
4494 KMP_STORE_LOCK_SEQ(futex);
4496 KMP_WARNING(FutexNotSupported, name, value);
4500 else if (__kmp_str_match(
"ticket", 2, value)) {
4501 __kmp_user_lock_kind = lk_ticket;
4502 KMP_STORE_LOCK_SEQ(ticket);
4503 }
else if (__kmp_str_match(
"queuing", 1, value) ||
4504 __kmp_str_match(
"queue", 1, value)) {
4505 __kmp_user_lock_kind = lk_queuing;
4506 KMP_STORE_LOCK_SEQ(queuing);
4507 }
else if (__kmp_str_match(
"drdpa ticket", 1, value) ||
4508 __kmp_str_match(
"drdpa_ticket", 1, value) ||
4509 __kmp_str_match(
"drdpa-ticket", 1, value) ||
4510 __kmp_str_match(
"drdpaticket", 1, value) ||
4511 __kmp_str_match(
"drdpa", 1, value)) {
4512 __kmp_user_lock_kind = lk_drdpa;
4513 KMP_STORE_LOCK_SEQ(drdpa);
4515 #if KMP_USE_ADAPTIVE_LOCKS
4516 else if (__kmp_str_match(
"adaptive", 1, value)) {
4517 if (__kmp_cpuinfo.flags.rtm) {
4518 __kmp_user_lock_kind = lk_adaptive;
4519 KMP_STORE_LOCK_SEQ(adaptive);
4521 KMP_WARNING(AdaptiveNotSupported, name, value);
4522 __kmp_user_lock_kind = lk_queuing;
4523 KMP_STORE_LOCK_SEQ(queuing);
4527 #if KMP_USE_DYNAMIC_LOCK && KMP_USE_TSX
4528 else if (__kmp_str_match(
"rtm_queuing", 1, value)) {
4529 if (__kmp_cpuinfo.flags.rtm) {
4530 __kmp_user_lock_kind = lk_rtm_queuing;
4531 KMP_STORE_LOCK_SEQ(rtm_queuing);
4533 KMP_WARNING(AdaptiveNotSupported, name, value);
4534 __kmp_user_lock_kind = lk_queuing;
4535 KMP_STORE_LOCK_SEQ(queuing);
4537 }
else if (__kmp_str_match(
"rtm_spin", 1, value)) {
4538 if (__kmp_cpuinfo.flags.rtm) {
4539 __kmp_user_lock_kind = lk_rtm_spin;
4540 KMP_STORE_LOCK_SEQ(rtm_spin);
4542 KMP_WARNING(AdaptiveNotSupported, name, value);
4543 __kmp_user_lock_kind = lk_tas;
4544 KMP_STORE_LOCK_SEQ(queuing);
4546 }
else if (__kmp_str_match(
"hle", 1, value)) {
4547 __kmp_user_lock_kind = lk_hle;
4548 KMP_STORE_LOCK_SEQ(hle);
4552 KMP_WARNING(StgInvalidValue, name, value);
4556 static void __kmp_stg_print_lock_kind(kmp_str_buf_t *buffer,
char const *name,
4558 const char *value = NULL;
4560 switch (__kmp_user_lock_kind) {
4575 #if KMP_USE_DYNAMIC_LOCK && KMP_USE_TSX
4576 case lk_rtm_queuing:
4577 value =
"rtm_queuing";
4600 #if KMP_USE_ADAPTIVE_LOCKS
4607 if (value != NULL) {
4608 __kmp_stg_print_str(buffer, name, value);
4617 static void __kmp_stg_parse_spin_backoff_params(
const char *name,
4618 const char *value,
void *data) {
4619 const char *next = value;
4622 int prev_comma = FALSE;
4625 kmp_uint32 max_backoff = __kmp_spin_backoff_params.max_backoff;
4626 kmp_uint32 min_tick = __kmp_spin_backoff_params.min_tick;
4630 for (i = 0; i < 3; i++) {
4633 if (*next ==
'\0') {
4638 if (((*next < '0' || *next >
'9') && *next !=
',') || total > 2) {
4639 KMP_WARNING(EnvSyntaxError, name, value);
4645 if (total == 0 || prev_comma) {
4653 if (*next >=
'0' && *next <=
'9') {
4655 const char *buf = next;
4656 char const *msg = NULL;
4661 const char *tmp = next;
4663 if ((*next ==
' ' || *next ==
'\t') && (*tmp >=
'0' && *tmp <=
'9')) {
4664 KMP_WARNING(EnvSpacesNotAllowed, name, value);
4668 num = __kmp_str_to_int(buf, *next);
4670 msg = KMP_I18N_STR(ValueTooSmall);
4672 }
else if (num > KMP_INT_MAX) {
4673 msg = KMP_I18N_STR(ValueTooLarge);
4678 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
4679 KMP_INFORM(Using_int_Value, name, num);
4683 }
else if (total == 2) {
4688 KMP_DEBUG_ASSERT(total > 0);
4690 KMP_WARNING(EnvSyntaxError, name, value);
4693 __kmp_spin_backoff_params.max_backoff = max_backoff;
4694 __kmp_spin_backoff_params.min_tick = min_tick;
4697 static void __kmp_stg_print_spin_backoff_params(kmp_str_buf_t *buffer,
4698 char const *name,
void *data) {
4699 if (__kmp_env_format) {
4700 KMP_STR_BUF_PRINT_NAME_EX(name);
4702 __kmp_str_buf_print(buffer,
" %s='", name);
4704 __kmp_str_buf_print(buffer,
"%d,%d'\n", __kmp_spin_backoff_params.max_backoff,
4705 __kmp_spin_backoff_params.min_tick);
4708 #if KMP_USE_ADAPTIVE_LOCKS
4715 static void __kmp_stg_parse_adaptive_lock_props(
const char *name,
4716 const char *value,
void *data) {
4717 int max_retries = 0;
4718 int max_badness = 0;
4720 const char *next = value;
4723 int prev_comma = FALSE;
4729 for (i = 0; i < 3; i++) {
4732 if (*next ==
'\0') {
4737 if (((*next < '0' || *next >
'9') && *next !=
',') || total > 2) {
4738 KMP_WARNING(EnvSyntaxError, name, value);
4744 if (total == 0 || prev_comma) {
4752 if (*next >=
'0' && *next <=
'9') {
4754 const char *buf = next;
4755 char const *msg = NULL;
4760 const char *tmp = next;
4762 if ((*next ==
' ' || *next ==
'\t') && (*tmp >=
'0' && *tmp <=
'9')) {
4763 KMP_WARNING(EnvSpacesNotAllowed, name, value);
4767 num = __kmp_str_to_int(buf, *next);
4769 msg = KMP_I18N_STR(ValueTooSmall);
4771 }
else if (num > KMP_INT_MAX) {
4772 msg = KMP_I18N_STR(ValueTooLarge);
4777 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
4778 KMP_INFORM(Using_int_Value, name, num);
4782 }
else if (total == 2) {
4787 KMP_DEBUG_ASSERT(total > 0);
4789 KMP_WARNING(EnvSyntaxError, name, value);
4792 __kmp_adaptive_backoff_params.max_soft_retries = max_retries;
4793 __kmp_adaptive_backoff_params.max_badness = max_badness;
4796 static void __kmp_stg_print_adaptive_lock_props(kmp_str_buf_t *buffer,
4797 char const *name,
void *data) {
4798 if (__kmp_env_format) {
4799 KMP_STR_BUF_PRINT_NAME_EX(name);
4801 __kmp_str_buf_print(buffer,
" %s='", name);
4803 __kmp_str_buf_print(buffer,
"%d,%d'\n",
4804 __kmp_adaptive_backoff_params.max_soft_retries,
4805 __kmp_adaptive_backoff_params.max_badness);
4808 #if KMP_DEBUG_ADAPTIVE_LOCKS
4810 static void __kmp_stg_parse_speculative_statsfile(
char const *name,
4813 __kmp_stg_parse_file(name, value,
"",
4814 CCAST(
char **, &__kmp_speculative_statsfile));
4817 static void __kmp_stg_print_speculative_statsfile(kmp_str_buf_t *buffer,
4820 if (__kmp_str_match(
"-", 0, __kmp_speculative_statsfile)) {
4821 __kmp_stg_print_str(buffer, name,
"stdout");
4823 __kmp_stg_print_str(buffer, name, __kmp_speculative_statsfile);
4839 static kmp_hw_t __kmp_hw_subset_break_tie(
const kmp_hw_t *possible,
4840 size_t num_possible) {
4841 for (
size_t i = 0; i < num_possible; ++i) {
4842 if (possible[i] == KMP_HW_THREAD)
4843 return KMP_HW_THREAD;
4844 else if (possible[i] == KMP_HW_CORE)
4846 else if (possible[i] == KMP_HW_SOCKET)
4847 return KMP_HW_SOCKET;
4849 return KMP_HW_UNKNOWN;
4856 static kmp_hw_t __kmp_stg_parse_hw_subset_name(
char const *token) {
4857 size_t index, num_possible, token_length;
4858 kmp_hw_t possible[KMP_HW_LAST];
4864 while (isalnum(*end) || *end ==
'_') {
4871 KMP_FOREACH_HW_TYPE(type) { possible[num_possible++] = type; }
4878 while (num_possible > 1 && index < token_length) {
4879 size_t n = num_possible;
4880 char token_char = (char)toupper(token[index]);
4881 for (
size_t i = 0; i < n; ++i) {
4883 kmp_hw_t type = possible[i];
4884 s = __kmp_hw_get_keyword(type,
false);
4885 if (index < KMP_STRLEN(s)) {
4886 char c = (char)toupper(s[index]);
4888 if (c != token_char) {
4889 possible[i] = KMP_HW_UNKNOWN;
4896 for (
size_t i = 0; i < n; ++i) {
4897 if (possible[i] != KMP_HW_UNKNOWN) {
4898 kmp_hw_t temp = possible[i];
4899 possible[i] = possible[start];
4900 possible[start] = temp;
4904 KMP_ASSERT(start == num_possible);
4910 if (num_possible > 1)
4911 return __kmp_hw_subset_break_tie(possible, num_possible);
4912 if (num_possible == 1)
4914 return KMP_HW_UNKNOWN;
4919 #define MAX_T_LEVEL KMP_HW_LAST
4920 #define MAX_STR_LEN 512
4921 static void __kmp_stg_parse_hw_subset(
char const *name,
char const *value,
4925 kmp_setting_t **rivals = (kmp_setting_t **)data;
4926 if (strcmp(name,
"KMP_PLACE_THREADS") == 0) {
4927 KMP_INFORM(EnvVarDeprecated, name,
"KMP_HW_SUBSET");
4929 if (__kmp_stg_check_rivals(name, value, rivals)) {
4933 char *components[MAX_T_LEVEL];
4934 char const *digits =
"0123456789";
4935 char input[MAX_STR_LEN];
4936 size_t len = 0, mlen = MAX_STR_LEN;
4938 bool absolute =
false;
4940 char *pos = CCAST(
char *, value);
4941 while (*pos && mlen) {
4943 if (len == 0 && *pos ==
':') {
4946 input[len] = (char)(toupper(*pos));
4947 if (input[len] ==
'X')
4949 if (input[len] ==
'O' && strchr(digits, *(pos + 1)))
4957 if (len == 0 || mlen == 0) {
4963 components[level++] = pos;
4964 while ((pos = strchr(pos,
','))) {
4965 if (level >= MAX_T_LEVEL)
4968 components[level++] = ++pos;
4971 __kmp_hw_subset = kmp_hw_subset_t::allocate();
4973 __kmp_hw_subset->set_absolute();
4976 for (
int i = 0; i < level; ++i) {
4978 char *core_components[MAX_T_LEVEL];
4980 pos = components[i];
4981 core_components[core_level++] = pos;
4982 while ((pos = strchr(pos,
'&'))) {
4983 if (core_level >= MAX_T_LEVEL)
4986 core_components[core_level++] = ++pos;
4989 for (
int j = 0; j < core_level; ++j) {
4996 if (isdigit(*core_components[j])) {
4997 num = atoi(core_components[j]);
5001 pos = core_components[j] + strspn(core_components[j], digits);
5002 }
else if (*core_components[j] ==
'*') {
5003 num = kmp_hw_subset_t::USE_ALL;
5004 pos = core_components[j] + 1;
5006 num = kmp_hw_subset_t::USE_ALL;
5007 pos = core_components[j];
5010 offset_ptr = strchr(core_components[j],
'@');
5011 attr_ptr = strchr(core_components[j],
':');
5014 offset = atoi(offset_ptr + 1);
5020 #if KMP_ARCH_X86 || KMP_ARCH_X86_64
5021 if (__kmp_str_match(
"intel_core", -1, attr_ptr + 1)) {
5022 attr.set_core_type(KMP_HW_CORE_TYPE_CORE);
5023 }
else if (__kmp_str_match(
"intel_atom", -1, attr_ptr + 1)) {
5024 attr.set_core_type(KMP_HW_CORE_TYPE_ATOM);
5027 if (__kmp_str_match(
"eff", 3, attr_ptr + 1)) {
5028 const char *number = attr_ptr + 1;
5030 while (isalpha(*number))
5032 if (!isdigit(*number)) {
5035 int efficiency = atoi(number);
5036 attr.set_core_eff(efficiency);
5043 kmp_hw_t type = __kmp_stg_parse_hw_subset_name(pos);
5044 if (type == KMP_HW_UNKNOWN) {
5048 if (attr && type != KMP_HW_CORE)
5051 if (type != KMP_HW_CORE && __kmp_hw_subset->specified(type)) {
5054 __kmp_hw_subset->push_back(num, type, offset, attr);
5059 KMP_WARNING(AffHWSubsetInvalid, name, value);
5060 if (__kmp_hw_subset) {
5061 kmp_hw_subset_t::deallocate(__kmp_hw_subset);
5062 __kmp_hw_subset =
nullptr;
5067 static inline const char *
5068 __kmp_hw_get_core_type_keyword(kmp_hw_core_type_t type) {
5070 case KMP_HW_CORE_TYPE_UNKNOWN:
5072 #if KMP_ARCH_X86 || KMP_ARCH_X86_64
5073 case KMP_HW_CORE_TYPE_ATOM:
5074 return "intel_atom";
5075 case KMP_HW_CORE_TYPE_CORE:
5076 return "intel_core";
5082 static void __kmp_stg_print_hw_subset(kmp_str_buf_t *buffer,
char const *name,
5086 if (!__kmp_hw_subset)
5088 __kmp_str_buf_init(&buf);
5089 if (__kmp_env_format)
5090 KMP_STR_BUF_PRINT_NAME_EX(name);
5092 __kmp_str_buf_print(buffer,
" %s='", name);
5094 depth = __kmp_hw_subset->get_depth();
5095 for (
int i = 0; i < depth; ++i) {
5096 const auto &item = __kmp_hw_subset->at(i);
5098 __kmp_str_buf_print(&buf,
"%c",
',');
5099 for (
int j = 0; j < item.num_attrs; ++j) {
5100 __kmp_str_buf_print(&buf,
"%s%d%s", (j > 0 ?
"&" :
""), item.num[j],
5101 __kmp_hw_get_keyword(item.type));
5102 if (item.attr[j].is_core_type_valid())
5103 __kmp_str_buf_print(
5105 __kmp_hw_get_core_type_keyword(item.attr[j].get_core_type()));
5106 if (item.attr[j].is_core_eff_valid())
5107 __kmp_str_buf_print(&buf,
":eff%d", item.attr[j].get_core_eff());
5109 __kmp_str_buf_print(&buf,
"@%d", item.offset[j]);
5112 __kmp_str_buf_print(buffer,
"%s'\n", buf.str);
5113 __kmp_str_buf_free(&buf);
5120 static void __kmp_stg_parse_forkjoin_frames(
char const *name,
char const *value,
5122 __kmp_stg_parse_bool(name, value, &__kmp_forkjoin_frames);
5125 static void __kmp_stg_print_forkjoin_frames(kmp_str_buf_t *buffer,
5126 char const *name,
void *data) {
5127 __kmp_stg_print_bool(buffer, name, __kmp_forkjoin_frames);
5133 static void __kmp_stg_parse_forkjoin_frames_mode(
char const *name,
5136 __kmp_stg_parse_int(name, value, 0, 3, &__kmp_forkjoin_frames_mode);
5139 static void __kmp_stg_print_forkjoin_frames_mode(kmp_str_buf_t *buffer,
5140 char const *name,
void *data) {
5141 __kmp_stg_print_int(buffer, name, __kmp_forkjoin_frames_mode);
5148 static void __kmp_stg_parse_task_throttling(
char const *name,
char const *value,
5150 __kmp_stg_parse_bool(name, value, &__kmp_enable_task_throttling);
5153 static void __kmp_stg_print_task_throttling(kmp_str_buf_t *buffer,
5154 char const *name,
void *data) {
5155 __kmp_stg_print_bool(buffer, name, __kmp_enable_task_throttling);
5158 #if KMP_HAVE_MWAIT || KMP_HAVE_UMWAIT
5162 static void __kmp_stg_parse_user_level_mwait(
char const *name,
5163 char const *value,
void *data) {
5164 __kmp_stg_parse_bool(name, value, &__kmp_user_level_mwait);
5167 static void __kmp_stg_print_user_level_mwait(kmp_str_buf_t *buffer,
5168 char const *name,
void *data) {
5169 __kmp_stg_print_bool(buffer, name, __kmp_user_level_mwait);
5175 static void __kmp_stg_parse_mwait_hints(
char const *name,
char const *value,
5177 __kmp_stg_parse_int(name, value, 0, INT_MAX, &__kmp_mwait_hints);
5180 static void __kmp_stg_print_mwait_hints(kmp_str_buf_t *buffer,
char const *name,
5182 __kmp_stg_print_int(buffer, name, __kmp_mwait_hints);
5192 static void __kmp_stg_parse_tpause(
char const *name,
char const *value,
5194 __kmp_stg_parse_int(name, value, 0, INT_MAX, &__kmp_tpause_state);
5195 if (__kmp_tpause_state != 0) {
5197 if (__kmp_tpause_state == 2)
5198 __kmp_tpause_hint = 0;
5202 static void __kmp_stg_print_tpause(kmp_str_buf_t *buffer,
char const *name,
5204 __kmp_stg_print_int(buffer, name, __kmp_tpause_state);
5211 static void __kmp_stg_parse_omp_display_env(
char const *name,
char const *value,
5213 if (__kmp_str_match(
"VERBOSE", 1, value)) {
5214 __kmp_display_env_verbose = TRUE;
5216 __kmp_stg_parse_bool(name, value, &__kmp_display_env);
5220 static void __kmp_stg_print_omp_display_env(kmp_str_buf_t *buffer,
5221 char const *name,
void *data) {
5222 if (__kmp_display_env_verbose) {
5223 __kmp_stg_print_str(buffer, name,
"VERBOSE");
5225 __kmp_stg_print_bool(buffer, name, __kmp_display_env);
5229 static void __kmp_stg_parse_omp_cancellation(
char const *name,
5230 char const *value,
void *data) {
5231 if (TCR_4(__kmp_init_parallel)) {
5232 KMP_WARNING(EnvParallelWarn, name);
5235 __kmp_stg_parse_bool(name, value, &__kmp_omp_cancellation);
5238 static void __kmp_stg_print_omp_cancellation(kmp_str_buf_t *buffer,
5239 char const *name,
void *data) {
5240 __kmp_stg_print_bool(buffer, name, __kmp_omp_cancellation);
5246 static void __kmp_stg_parse_omp_tool(
char const *name,
char const *value,
5248 __kmp_stg_parse_bool(name, value, &__kmp_tool);
5251 static void __kmp_stg_print_omp_tool(kmp_str_buf_t *buffer,
char const *name,
5253 if (__kmp_env_format) {
5254 KMP_STR_BUF_PRINT_BOOL_EX(name, __kmp_tool,
"enabled",
"disabled");
5256 __kmp_str_buf_print(buffer,
" %s=%s\n", name,
5257 __kmp_tool ?
"enabled" :
"disabled");
5261 char *__kmp_tool_libraries = NULL;
5263 static void __kmp_stg_parse_omp_tool_libraries(
char const *name,
5264 char const *value,
void *data) {
5265 __kmp_stg_parse_str(name, value, &__kmp_tool_libraries);
5268 static void __kmp_stg_print_omp_tool_libraries(kmp_str_buf_t *buffer,
5269 char const *name,
void *data) {
5270 if (__kmp_tool_libraries)
5271 __kmp_stg_print_str(buffer, name, __kmp_tool_libraries);
5273 if (__kmp_env_format) {
5274 KMP_STR_BUF_PRINT_NAME;
5276 __kmp_str_buf_print(buffer,
" %s", name);
5278 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
5282 char *__kmp_tool_verbose_init = NULL;
5284 static void __kmp_stg_parse_omp_tool_verbose_init(
char const *name,
5287 __kmp_stg_parse_str(name, value, &__kmp_tool_verbose_init);
5290 static void __kmp_stg_print_omp_tool_verbose_init(kmp_str_buf_t *buffer,
5293 if (__kmp_tool_verbose_init)
5294 __kmp_stg_print_str(buffer, name, __kmp_tool_verbose_init);
5296 if (__kmp_env_format) {
5297 KMP_STR_BUF_PRINT_NAME;
5299 __kmp_str_buf_print(buffer,
" %s", name);
5301 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
5309 static kmp_setting_t __kmp_stg_table[] = {
5311 {
"KMP_ALL_THREADS", __kmp_stg_parse_device_thread_limit, NULL, NULL, 0, 0},
5312 {
"KMP_BLOCKTIME", __kmp_stg_parse_blocktime, __kmp_stg_print_blocktime,
5314 {
"KMP_USE_YIELD", __kmp_stg_parse_use_yield, __kmp_stg_print_use_yield,
5316 {
"KMP_DUPLICATE_LIB_OK", __kmp_stg_parse_duplicate_lib_ok,
5317 __kmp_stg_print_duplicate_lib_ok, NULL, 0, 0},
5318 {
"KMP_LIBRARY", __kmp_stg_parse_wait_policy, __kmp_stg_print_wait_policy,
5320 {
"KMP_DEVICE_THREAD_LIMIT", __kmp_stg_parse_device_thread_limit,
5321 __kmp_stg_print_device_thread_limit, NULL, 0, 0},
5323 {
"KMP_MONITOR_STACKSIZE", __kmp_stg_parse_monitor_stacksize,
5324 __kmp_stg_print_monitor_stacksize, NULL, 0, 0},
5326 {
"KMP_SETTINGS", __kmp_stg_parse_settings, __kmp_stg_print_settings, NULL,
5328 {
"KMP_STACKOFFSET", __kmp_stg_parse_stackoffset,
5329 __kmp_stg_print_stackoffset, NULL, 0, 0},
5330 {
"KMP_STACKSIZE", __kmp_stg_parse_stacksize, __kmp_stg_print_stacksize,
5332 {
"KMP_STACKPAD", __kmp_stg_parse_stackpad, __kmp_stg_print_stackpad, NULL,
5334 {
"KMP_VERSION", __kmp_stg_parse_version, __kmp_stg_print_version, NULL, 0,
5336 {
"KMP_WARNINGS", __kmp_stg_parse_warnings, __kmp_stg_print_warnings, NULL,
5339 {
"KMP_NESTING_MODE", __kmp_stg_parse_nesting_mode,
5340 __kmp_stg_print_nesting_mode, NULL, 0, 0},
5341 {
"OMP_NESTED", __kmp_stg_parse_nested, __kmp_stg_print_nested, NULL, 0, 0},
5342 {
"OMP_NUM_THREADS", __kmp_stg_parse_num_threads,
5343 __kmp_stg_print_num_threads, NULL, 0, 0},
5344 {
"OMP_STACKSIZE", __kmp_stg_parse_stacksize, __kmp_stg_print_stacksize,
5347 {
"KMP_TASKING", __kmp_stg_parse_tasking, __kmp_stg_print_tasking, NULL, 0,
5349 {
"KMP_TASK_STEALING_CONSTRAINT", __kmp_stg_parse_task_stealing,
5350 __kmp_stg_print_task_stealing, NULL, 0, 0},
5351 {
"OMP_MAX_ACTIVE_LEVELS", __kmp_stg_parse_max_active_levels,
5352 __kmp_stg_print_max_active_levels, NULL, 0, 0},
5353 {
"OMP_DEFAULT_DEVICE", __kmp_stg_parse_default_device,
5354 __kmp_stg_print_default_device, NULL, 0, 0},
5355 {
"OMP_TARGET_OFFLOAD", __kmp_stg_parse_target_offload,
5356 __kmp_stg_print_target_offload, NULL, 0, 0},
5357 {
"OMP_MAX_TASK_PRIORITY", __kmp_stg_parse_max_task_priority,
5358 __kmp_stg_print_max_task_priority, NULL, 0, 0},
5359 {
"KMP_TASKLOOP_MIN_TASKS", __kmp_stg_parse_taskloop_min_tasks,
5360 __kmp_stg_print_taskloop_min_tasks, NULL, 0, 0},
5361 {
"OMP_THREAD_LIMIT", __kmp_stg_parse_thread_limit,
5362 __kmp_stg_print_thread_limit, NULL, 0, 0},
5363 {
"KMP_TEAMS_THREAD_LIMIT", __kmp_stg_parse_teams_thread_limit,
5364 __kmp_stg_print_teams_thread_limit, NULL, 0, 0},
5365 {
"OMP_NUM_TEAMS", __kmp_stg_parse_nteams, __kmp_stg_print_nteams, NULL, 0,
5367 {
"OMP_TEAMS_THREAD_LIMIT", __kmp_stg_parse_teams_th_limit,
5368 __kmp_stg_print_teams_th_limit, NULL, 0, 0},
5369 {
"OMP_WAIT_POLICY", __kmp_stg_parse_wait_policy,
5370 __kmp_stg_print_wait_policy, NULL, 0, 0},
5371 {
"KMP_DISP_NUM_BUFFERS", __kmp_stg_parse_disp_buffers,
5372 __kmp_stg_print_disp_buffers, NULL, 0, 0},
5373 #if KMP_NESTED_HOT_TEAMS
5374 {
"KMP_HOT_TEAMS_MAX_LEVEL", __kmp_stg_parse_hot_teams_level,
5375 __kmp_stg_print_hot_teams_level, NULL, 0, 0},
5376 {
"KMP_HOT_TEAMS_MODE", __kmp_stg_parse_hot_teams_mode,
5377 __kmp_stg_print_hot_teams_mode, NULL, 0, 0},
5380 #if KMP_HANDLE_SIGNALS
5381 {
"KMP_HANDLE_SIGNALS", __kmp_stg_parse_handle_signals,
5382 __kmp_stg_print_handle_signals, NULL, 0, 0},
5385 #if KMP_ARCH_X86 || KMP_ARCH_X86_64
5386 {
"KMP_INHERIT_FP_CONTROL", __kmp_stg_parse_inherit_fp_control,
5387 __kmp_stg_print_inherit_fp_control, NULL, 0, 0},
5390 #ifdef KMP_GOMP_COMPAT
5391 {
"GOMP_STACKSIZE", __kmp_stg_parse_stacksize, NULL, NULL, 0, 0},
5395 {
"KMP_A_DEBUG", __kmp_stg_parse_a_debug, __kmp_stg_print_a_debug, NULL, 0,
5397 {
"KMP_B_DEBUG", __kmp_stg_parse_b_debug, __kmp_stg_print_b_debug, NULL, 0,
5399 {
"KMP_C_DEBUG", __kmp_stg_parse_c_debug, __kmp_stg_print_c_debug, NULL, 0,
5401 {
"KMP_D_DEBUG", __kmp_stg_parse_d_debug, __kmp_stg_print_d_debug, NULL, 0,
5403 {
"KMP_E_DEBUG", __kmp_stg_parse_e_debug, __kmp_stg_print_e_debug, NULL, 0,
5405 {
"KMP_F_DEBUG", __kmp_stg_parse_f_debug, __kmp_stg_print_f_debug, NULL, 0,
5407 {
"KMP_DEBUG", __kmp_stg_parse_debug, NULL, NULL, 0, 0},
5408 {
"KMP_DEBUG_BUF", __kmp_stg_parse_debug_buf, __kmp_stg_print_debug_buf,
5410 {
"KMP_DEBUG_BUF_ATOMIC", __kmp_stg_parse_debug_buf_atomic,
5411 __kmp_stg_print_debug_buf_atomic, NULL, 0, 0},
5412 {
"KMP_DEBUG_BUF_CHARS", __kmp_stg_parse_debug_buf_chars,
5413 __kmp_stg_print_debug_buf_chars, NULL, 0, 0},
5414 {
"KMP_DEBUG_BUF_LINES", __kmp_stg_parse_debug_buf_lines,
5415 __kmp_stg_print_debug_buf_lines, NULL, 0, 0},
5416 {
"KMP_DIAG", __kmp_stg_parse_diag, __kmp_stg_print_diag, NULL, 0, 0},
5418 {
"KMP_PAR_RANGE", __kmp_stg_parse_par_range_env,
5419 __kmp_stg_print_par_range_env, NULL, 0, 0},
5422 {
"KMP_ALIGN_ALLOC", __kmp_stg_parse_align_alloc,
5423 __kmp_stg_print_align_alloc, NULL, 0, 0},
5425 {
"KMP_PLAIN_BARRIER", __kmp_stg_parse_barrier_branch_bit,
5426 __kmp_stg_print_barrier_branch_bit, NULL, 0, 0},
5427 {
"KMP_PLAIN_BARRIER_PATTERN", __kmp_stg_parse_barrier_pattern,
5428 __kmp_stg_print_barrier_pattern, NULL, 0, 0},
5429 {
"KMP_FORKJOIN_BARRIER", __kmp_stg_parse_barrier_branch_bit,
5430 __kmp_stg_print_barrier_branch_bit, NULL, 0, 0},
5431 {
"KMP_FORKJOIN_BARRIER_PATTERN", __kmp_stg_parse_barrier_pattern,
5432 __kmp_stg_print_barrier_pattern, NULL, 0, 0},
5433 #if KMP_FAST_REDUCTION_BARRIER
5434 {
"KMP_REDUCTION_BARRIER", __kmp_stg_parse_barrier_branch_bit,
5435 __kmp_stg_print_barrier_branch_bit, NULL, 0, 0},
5436 {
"KMP_REDUCTION_BARRIER_PATTERN", __kmp_stg_parse_barrier_pattern,
5437 __kmp_stg_print_barrier_pattern, NULL, 0, 0},
5440 {
"KMP_ABORT_DELAY", __kmp_stg_parse_abort_delay,
5441 __kmp_stg_print_abort_delay, NULL, 0, 0},
5442 {
"KMP_CPUINFO_FILE", __kmp_stg_parse_cpuinfo_file,
5443 __kmp_stg_print_cpuinfo_file, NULL, 0, 0},
5444 {
"KMP_FORCE_REDUCTION", __kmp_stg_parse_force_reduction,
5445 __kmp_stg_print_force_reduction, NULL, 0, 0},
5446 {
"KMP_DETERMINISTIC_REDUCTION", __kmp_stg_parse_force_reduction,
5447 __kmp_stg_print_force_reduction, NULL, 0, 0},
5448 {
"KMP_STORAGE_MAP", __kmp_stg_parse_storage_map,
5449 __kmp_stg_print_storage_map, NULL, 0, 0},
5450 {
"KMP_ALL_THREADPRIVATE", __kmp_stg_parse_all_threadprivate,
5451 __kmp_stg_print_all_threadprivate, NULL, 0, 0},
5452 {
"KMP_FOREIGN_THREADS_THREADPRIVATE",
5453 __kmp_stg_parse_foreign_threads_threadprivate,
5454 __kmp_stg_print_foreign_threads_threadprivate, NULL, 0, 0},
5456 #if KMP_AFFINITY_SUPPORTED
5457 {
"KMP_AFFINITY", __kmp_stg_parse_affinity, __kmp_stg_print_affinity, NULL,
5459 #ifdef KMP_GOMP_COMPAT
5460 {
"GOMP_CPU_AFFINITY", __kmp_stg_parse_gomp_cpu_affinity, NULL,
5463 {
"OMP_PROC_BIND", __kmp_stg_parse_proc_bind, __kmp_stg_print_proc_bind,
5465 {
"KMP_TEAMS_PROC_BIND", __kmp_stg_parse_teams_proc_bind,
5466 __kmp_stg_print_teams_proc_bind, NULL, 0, 0},
5467 {
"OMP_PLACES", __kmp_stg_parse_places, __kmp_stg_print_places, NULL, 0, 0},
5468 {
"KMP_TOPOLOGY_METHOD", __kmp_stg_parse_topology_method,
5469 __kmp_stg_print_topology_method, NULL, 0, 0},
5475 {
"OMP_PROC_BIND", __kmp_stg_parse_proc_bind, __kmp_stg_print_proc_bind,
5479 {
"OMP_DISPLAY_AFFINITY", __kmp_stg_parse_display_affinity,
5480 __kmp_stg_print_display_affinity, NULL, 0, 0},
5481 {
"OMP_AFFINITY_FORMAT", __kmp_stg_parse_affinity_format,
5482 __kmp_stg_print_affinity_format, NULL, 0, 0},
5483 {
"KMP_INIT_AT_FORK", __kmp_stg_parse_init_at_fork,
5484 __kmp_stg_print_init_at_fork, NULL, 0, 0},
5485 {
"KMP_SCHEDULE", __kmp_stg_parse_schedule, __kmp_stg_print_schedule, NULL,
5487 {
"OMP_SCHEDULE", __kmp_stg_parse_omp_schedule, __kmp_stg_print_omp_schedule,
5489 #if KMP_USE_HIER_SCHED
5490 {
"KMP_DISP_HAND_THREAD", __kmp_stg_parse_kmp_hand_thread,
5491 __kmp_stg_print_kmp_hand_thread, NULL, 0, 0},
5493 {
"KMP_FORCE_MONOTONIC_DYNAMIC_SCHEDULE",
5494 __kmp_stg_parse_kmp_force_monotonic, __kmp_stg_print_kmp_force_monotonic,
5496 {
"KMP_ATOMIC_MODE", __kmp_stg_parse_atomic_mode,
5497 __kmp_stg_print_atomic_mode, NULL, 0, 0},
5498 {
"KMP_CONSISTENCY_CHECK", __kmp_stg_parse_consistency_check,
5499 __kmp_stg_print_consistency_check, NULL, 0, 0},
5501 #if USE_ITT_BUILD && USE_ITT_NOTIFY
5502 {
"KMP_ITT_PREPARE_DELAY", __kmp_stg_parse_itt_prepare_delay,
5503 __kmp_stg_print_itt_prepare_delay, NULL, 0, 0},
5505 {
"KMP_MALLOC_POOL_INCR", __kmp_stg_parse_malloc_pool_incr,
5506 __kmp_stg_print_malloc_pool_incr, NULL, 0, 0},
5507 {
"KMP_GTID_MODE", __kmp_stg_parse_gtid_mode, __kmp_stg_print_gtid_mode,
5509 {
"OMP_DYNAMIC", __kmp_stg_parse_omp_dynamic, __kmp_stg_print_omp_dynamic,
5511 {
"KMP_DYNAMIC_MODE", __kmp_stg_parse_kmp_dynamic_mode,
5512 __kmp_stg_print_kmp_dynamic_mode, NULL, 0, 0},
5514 #ifdef USE_LOAD_BALANCE
5515 {
"KMP_LOAD_BALANCE_INTERVAL", __kmp_stg_parse_ld_balance_interval,
5516 __kmp_stg_print_ld_balance_interval, NULL, 0, 0},
5519 {
"KMP_NUM_LOCKS_IN_BLOCK", __kmp_stg_parse_lock_block,
5520 __kmp_stg_print_lock_block, NULL, 0, 0},
5521 {
"KMP_LOCK_KIND", __kmp_stg_parse_lock_kind, __kmp_stg_print_lock_kind,
5523 {
"KMP_SPIN_BACKOFF_PARAMS", __kmp_stg_parse_spin_backoff_params,
5524 __kmp_stg_print_spin_backoff_params, NULL, 0, 0},
5525 #if KMP_USE_ADAPTIVE_LOCKS
5526 {
"KMP_ADAPTIVE_LOCK_PROPS", __kmp_stg_parse_adaptive_lock_props,
5527 __kmp_stg_print_adaptive_lock_props, NULL, 0, 0},
5528 #if KMP_DEBUG_ADAPTIVE_LOCKS
5529 {
"KMP_SPECULATIVE_STATSFILE", __kmp_stg_parse_speculative_statsfile,
5530 __kmp_stg_print_speculative_statsfile, NULL, 0, 0},
5533 {
"KMP_PLACE_THREADS", __kmp_stg_parse_hw_subset, __kmp_stg_print_hw_subset,
5535 {
"KMP_HW_SUBSET", __kmp_stg_parse_hw_subset, __kmp_stg_print_hw_subset,
5538 {
"KMP_FORKJOIN_FRAMES", __kmp_stg_parse_forkjoin_frames,
5539 __kmp_stg_print_forkjoin_frames, NULL, 0, 0},
5540 {
"KMP_FORKJOIN_FRAMES_MODE", __kmp_stg_parse_forkjoin_frames_mode,
5541 __kmp_stg_print_forkjoin_frames_mode, NULL, 0, 0},
5543 {
"KMP_ENABLE_TASK_THROTTLING", __kmp_stg_parse_task_throttling,
5544 __kmp_stg_print_task_throttling, NULL, 0, 0},
5546 {
"OMP_DISPLAY_ENV", __kmp_stg_parse_omp_display_env,
5547 __kmp_stg_print_omp_display_env, NULL, 0, 0},
5548 {
"OMP_CANCELLATION", __kmp_stg_parse_omp_cancellation,
5549 __kmp_stg_print_omp_cancellation, NULL, 0, 0},
5550 {
"OMP_ALLOCATOR", __kmp_stg_parse_allocator, __kmp_stg_print_allocator,
5552 {
"LIBOMP_USE_HIDDEN_HELPER_TASK", __kmp_stg_parse_use_hidden_helper,
5553 __kmp_stg_print_use_hidden_helper, NULL, 0, 0},
5554 {
"LIBOMP_NUM_HIDDEN_HELPER_THREADS",
5555 __kmp_stg_parse_num_hidden_helper_threads,
5556 __kmp_stg_print_num_hidden_helper_threads, NULL, 0, 0},
5559 {
"OMP_TOOL", __kmp_stg_parse_omp_tool, __kmp_stg_print_omp_tool, NULL, 0,
5561 {
"OMP_TOOL_LIBRARIES", __kmp_stg_parse_omp_tool_libraries,
5562 __kmp_stg_print_omp_tool_libraries, NULL, 0, 0},
5563 {
"OMP_TOOL_VERBOSE_INIT", __kmp_stg_parse_omp_tool_verbose_init,
5564 __kmp_stg_print_omp_tool_verbose_init, NULL, 0, 0},
5567 #if KMP_HAVE_MWAIT || KMP_HAVE_UMWAIT
5568 {
"KMP_USER_LEVEL_MWAIT", __kmp_stg_parse_user_level_mwait,
5569 __kmp_stg_print_user_level_mwait, NULL, 0, 0},
5570 {
"KMP_MWAIT_HINTS", __kmp_stg_parse_mwait_hints,
5571 __kmp_stg_print_mwait_hints, NULL, 0, 0},
5575 {
"KMP_TPAUSE", __kmp_stg_parse_tpause, __kmp_stg_print_tpause, NULL, 0, 0},
5577 {
"", NULL, NULL, NULL, 0, 0}};
5579 static int const __kmp_stg_count =
5580 sizeof(__kmp_stg_table) /
sizeof(kmp_setting_t);
5582 static inline kmp_setting_t *__kmp_stg_find(
char const *name) {
5586 for (i = 0; i < __kmp_stg_count; ++i) {
5587 if (strcmp(__kmp_stg_table[i].name, name) == 0) {
5588 return &__kmp_stg_table[i];
5596 static int __kmp_stg_cmp(
void const *_a,
void const *_b) {
5597 const kmp_setting_t *a = RCAST(
const kmp_setting_t *, _a);
5598 const kmp_setting_t *b = RCAST(
const kmp_setting_t *, _b);
5602 if (strcmp(a->name,
"KMP_AFFINITY") == 0) {
5603 if (strcmp(b->name,
"KMP_AFFINITY") == 0) {
5607 }
else if (strcmp(b->name,
"KMP_AFFINITY") == 0) {
5610 return strcmp(a->name, b->name);
5613 static void __kmp_stg_init(
void) {
5615 static int initialized = 0;
5620 qsort(__kmp_stg_table, __kmp_stg_count - 1,
sizeof(kmp_setting_t),
5624 kmp_setting_t *kmp_stacksize =
5625 __kmp_stg_find(
"KMP_STACKSIZE");
5626 #ifdef KMP_GOMP_COMPAT
5627 kmp_setting_t *gomp_stacksize =
5628 __kmp_stg_find(
"GOMP_STACKSIZE");
5630 kmp_setting_t *omp_stacksize =
5631 __kmp_stg_find(
"OMP_STACKSIZE");
5637 static kmp_setting_t *
volatile rivals[4];
5638 static kmp_stg_ss_data_t kmp_data = {1, CCAST(kmp_setting_t **, rivals)};
5639 #ifdef KMP_GOMP_COMPAT
5640 static kmp_stg_ss_data_t gomp_data = {1024,
5641 CCAST(kmp_setting_t **, rivals)};
5643 static kmp_stg_ss_data_t omp_data = {1024,
5644 CCAST(kmp_setting_t **, rivals)};
5647 rivals[i++] = kmp_stacksize;
5648 #ifdef KMP_GOMP_COMPAT
5649 if (gomp_stacksize != NULL) {
5650 rivals[i++] = gomp_stacksize;
5653 rivals[i++] = omp_stacksize;
5656 kmp_stacksize->data = &kmp_data;
5657 #ifdef KMP_GOMP_COMPAT
5658 if (gomp_stacksize != NULL) {
5659 gomp_stacksize->data = &gomp_data;
5662 omp_stacksize->data = &omp_data;
5666 kmp_setting_t *kmp_library =
5667 __kmp_stg_find(
"KMP_LIBRARY");
5668 kmp_setting_t *omp_wait_policy =
5669 __kmp_stg_find(
"OMP_WAIT_POLICY");
5672 static kmp_setting_t *
volatile rivals[3];
5673 static kmp_stg_wp_data_t kmp_data = {0, CCAST(kmp_setting_t **, rivals)};
5674 static kmp_stg_wp_data_t omp_data = {1, CCAST(kmp_setting_t **, rivals)};
5677 rivals[i++] = kmp_library;
5678 if (omp_wait_policy != NULL) {
5679 rivals[i++] = omp_wait_policy;
5683 kmp_library->data = &kmp_data;
5684 if (omp_wait_policy != NULL) {
5685 omp_wait_policy->data = &omp_data;
5690 kmp_setting_t *kmp_device_thread_limit =
5691 __kmp_stg_find(
"KMP_DEVICE_THREAD_LIMIT");
5692 kmp_setting_t *kmp_all_threads =
5693 __kmp_stg_find(
"KMP_ALL_THREADS");
5696 static kmp_setting_t *
volatile rivals[3];
5699 rivals[i++] = kmp_device_thread_limit;
5700 rivals[i++] = kmp_all_threads;
5703 kmp_device_thread_limit->data = CCAST(kmp_setting_t **, rivals);
5704 kmp_all_threads->data = CCAST(kmp_setting_t **, rivals);
5709 kmp_setting_t *kmp_hw_subset = __kmp_stg_find(
"KMP_HW_SUBSET");
5711 kmp_setting_t *kmp_place_threads = __kmp_stg_find(
"KMP_PLACE_THREADS");
5714 static kmp_setting_t *
volatile rivals[3];
5717 rivals[i++] = kmp_hw_subset;
5718 rivals[i++] = kmp_place_threads;
5721 kmp_hw_subset->data = CCAST(kmp_setting_t **, rivals);
5722 kmp_place_threads->data = CCAST(kmp_setting_t **, rivals);
5725 #if KMP_AFFINITY_SUPPORTED
5727 kmp_setting_t *kmp_affinity =
5728 __kmp_stg_find(
"KMP_AFFINITY");
5729 KMP_DEBUG_ASSERT(kmp_affinity != NULL);
5731 #ifdef KMP_GOMP_COMPAT
5732 kmp_setting_t *gomp_cpu_affinity =
5733 __kmp_stg_find(
"GOMP_CPU_AFFINITY");
5734 KMP_DEBUG_ASSERT(gomp_cpu_affinity != NULL);
5737 kmp_setting_t *omp_proc_bind =
5738 __kmp_stg_find(
"OMP_PROC_BIND");
5739 KMP_DEBUG_ASSERT(omp_proc_bind != NULL);
5742 static kmp_setting_t *
volatile rivals[4];
5745 rivals[i++] = kmp_affinity;
5747 #ifdef KMP_GOMP_COMPAT
5748 rivals[i++] = gomp_cpu_affinity;
5749 gomp_cpu_affinity->data = CCAST(kmp_setting_t **, rivals);
5752 rivals[i++] = omp_proc_bind;
5753 omp_proc_bind->data = CCAST(kmp_setting_t **, rivals);
5756 static kmp_setting_t *
volatile places_rivals[4];
5759 kmp_setting_t *omp_places = __kmp_stg_find(
"OMP_PLACES");
5760 KMP_DEBUG_ASSERT(omp_places != NULL);
5762 places_rivals[i++] = kmp_affinity;
5763 #ifdef KMP_GOMP_COMPAT
5764 places_rivals[i++] = gomp_cpu_affinity;
5766 places_rivals[i++] = omp_places;
5767 omp_places->data = CCAST(kmp_setting_t **, places_rivals);
5768 places_rivals[i++] = NULL;
5776 kmp_setting_t *kmp_force_red =
5777 __kmp_stg_find(
"KMP_FORCE_REDUCTION");
5778 kmp_setting_t *kmp_determ_red =
5779 __kmp_stg_find(
"KMP_DETERMINISTIC_REDUCTION");
5782 static kmp_setting_t *
volatile rivals[3];
5783 static kmp_stg_fr_data_t force_data = {1,
5784 CCAST(kmp_setting_t **, rivals)};
5785 static kmp_stg_fr_data_t determ_data = {0,
5786 CCAST(kmp_setting_t **, rivals)};
5789 rivals[i++] = kmp_force_red;
5790 if (kmp_determ_red != NULL) {
5791 rivals[i++] = kmp_determ_red;
5795 kmp_force_red->data = &force_data;
5796 if (kmp_determ_red != NULL) {
5797 kmp_determ_red->data = &determ_data;
5806 for (i = 0; i < __kmp_stg_count; ++i) {
5807 __kmp_stg_table[i].set = 0;
5812 static void __kmp_stg_parse(
char const *name,
char const *value) {
5820 if (value != NULL) {
5821 kmp_setting_t *setting = __kmp_stg_find(name);
5822 if (setting != NULL) {
5823 setting->parse(name, value, setting->data);
5824 setting->defined = 1;
5830 static int __kmp_stg_check_rivals(
5833 kmp_setting_t **rivals
5836 if (rivals == NULL) {
5842 for (; strcmp(rivals[i]->name, name) != 0; i++) {
5843 KMP_DEBUG_ASSERT(rivals[i] != NULL);
5845 #if KMP_AFFINITY_SUPPORTED
5846 if (rivals[i] == __kmp_affinity_notype) {
5853 if (rivals[i]->set) {
5854 KMP_WARNING(StgIgnored, name, rivals[i]->name);
5864 static int __kmp_env_toPrint(
char const *name,
int flag) {
5866 kmp_setting_t *setting = __kmp_stg_find(name);
5867 if (setting != NULL) {
5868 rc = setting->defined;
5870 setting->defined = flag;
5876 static void __kmp_aux_env_initialize(kmp_env_blk_t *block) {
5881 value = __kmp_env_blk_var(block,
"OMP_NUM_THREADS");
5883 ompc_set_num_threads(__kmp_dflt_team_nth);
5887 value = __kmp_env_blk_var(block,
"KMP_BLOCKTIME");
5889 kmpc_set_blocktime(__kmp_dflt_blocktime);
5893 value = __kmp_env_blk_var(block,
"OMP_NESTED");
5895 ompc_set_nested(__kmp_dflt_max_active_levels > 1);
5899 value = __kmp_env_blk_var(block,
"OMP_DYNAMIC");
5901 ompc_set_dynamic(__kmp_global.g.g_dynamic);
5905 void __kmp_env_initialize(
char const *
string) {
5907 kmp_env_blk_t block;
5913 if (
string == NULL) {
5915 __kmp_threads_capacity =
5916 __kmp_initial_threads_capacity(__kmp_dflt_team_nth_ub);
5918 __kmp_env_blk_init(&block,
string);
5921 for (i = 0; i < block.count; ++i) {
5922 if ((block.vars[i].name == NULL) || (*block.vars[i].name ==
'\0')) {
5925 if (block.vars[i].value == NULL) {
5928 kmp_setting_t *setting = __kmp_stg_find(block.vars[i].name);
5929 if (setting != NULL) {
5935 blocktime_str = __kmp_env_blk_var(&block,
"KMP_BLOCKTIME");
5939 if (
string == NULL) {
5940 char const *name =
"KMP_WARNINGS";
5941 char const *value = __kmp_env_blk_var(&block, name);
5942 __kmp_stg_parse(name, value);
5945 #if KMP_AFFINITY_SUPPORTED
5951 __kmp_affinity_notype = NULL;
5952 char const *aff_str = __kmp_env_blk_var(&block,
"KMP_AFFINITY");
5953 if (aff_str != NULL) {
5967 #define FIND strcasestr
5970 if ((FIND(aff_str,
"none") == NULL) &&
5971 (FIND(aff_str,
"physical") == NULL) &&
5972 (FIND(aff_str,
"logical") == NULL) &&
5973 (FIND(aff_str,
"compact") == NULL) &&
5974 (FIND(aff_str,
"scatter") == NULL) &&
5975 (FIND(aff_str,
"explicit") == NULL) &&
5976 (FIND(aff_str,
"balanced") == NULL) &&
5977 (FIND(aff_str,
"disabled") == NULL)) {
5978 __kmp_affinity_notype = __kmp_stg_find(
"KMP_AFFINITY");
5983 __kmp_affinity_type = affinity_default;
5984 __kmp_affinity_gran = KMP_HW_UNKNOWN;
5985 __kmp_affinity_top_method = affinity_top_method_default;
5986 __kmp_affinity_respect_mask = affinity_respect_mask_default;
5991 aff_str = __kmp_env_blk_var(&block,
"OMP_PROC_BIND");
5992 if (aff_str != NULL) {
5993 __kmp_affinity_type = affinity_default;
5994 __kmp_affinity_gran = KMP_HW_UNKNOWN;
5995 __kmp_affinity_top_method = affinity_top_method_default;
5996 __kmp_affinity_respect_mask = affinity_respect_mask_default;
6003 if (__kmp_nested_proc_bind.bind_types == NULL) {
6004 __kmp_nested_proc_bind.bind_types =
6005 (kmp_proc_bind_t *)KMP_INTERNAL_MALLOC(
sizeof(kmp_proc_bind_t));
6006 if (__kmp_nested_proc_bind.bind_types == NULL) {
6007 KMP_FATAL(MemoryAllocFailed);
6009 __kmp_nested_proc_bind.size = 1;
6010 __kmp_nested_proc_bind.used = 1;
6011 #if KMP_AFFINITY_SUPPORTED
6012 __kmp_nested_proc_bind.bind_types[0] = proc_bind_default;
6015 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
6022 __kmp_msg_format(kmp_i18n_msg_AffFormatDefault,
"%P",
"%i",
"%n",
"%A");
6023 KMP_DEBUG_ASSERT(KMP_STRLEN(m.str) < KMP_AFFINITY_FORMAT_SIZE);
6025 if (__kmp_affinity_format == NULL) {
6026 __kmp_affinity_format =
6027 (
char *)KMP_INTERNAL_MALLOC(
sizeof(
char) * KMP_AFFINITY_FORMAT_SIZE);
6029 KMP_STRCPY_S(__kmp_affinity_format, KMP_AFFINITY_FORMAT_SIZE, m.str);
6030 __kmp_str_free(&m.str);
6033 for (i = 0; i < block.count; ++i) {
6034 __kmp_stg_parse(block.vars[i].name, block.vars[i].value);
6038 if (!__kmp_init_user_locks) {
6039 if (__kmp_user_lock_kind == lk_default) {
6040 __kmp_user_lock_kind = lk_queuing;
6042 #if KMP_USE_DYNAMIC_LOCK
6043 __kmp_init_dynamic_user_locks();
6045 __kmp_set_user_lock_vptrs(__kmp_user_lock_kind);
6048 KMP_DEBUG_ASSERT(
string != NULL);
6049 KMP_DEBUG_ASSERT(__kmp_user_lock_kind != lk_default);
6054 #if KMP_USE_DYNAMIC_LOCK
6055 __kmp_init_dynamic_user_locks();
6057 __kmp_set_user_lock_vptrs(__kmp_user_lock_kind);
6061 #if KMP_AFFINITY_SUPPORTED
6063 if (!TCR_4(__kmp_init_middle)) {
6068 if (__kmp_hw_subset &&
6069 __kmp_affinity_top_method == affinity_top_method_default)
6070 if (__kmp_hw_subset->specified(KMP_HW_NUMA) ||
6071 __kmp_hw_subset->specified(KMP_HW_TILE) ||
6072 __kmp_affinity_gran == KMP_HW_TILE ||
6073 __kmp_affinity_gran == KMP_HW_NUMA)
6074 __kmp_affinity_top_method = affinity_top_method_hwloc;
6076 if (__kmp_affinity_gran == KMP_HW_NUMA ||
6077 __kmp_affinity_gran == KMP_HW_TILE)
6078 __kmp_affinity_top_method = affinity_top_method_hwloc;
6082 const char *var =
"KMP_AFFINITY";
6083 KMPAffinity::pick_api();
6088 if (__kmp_affinity_top_method == affinity_top_method_hwloc &&
6089 __kmp_affinity_dispatch->get_api_type() != KMPAffinity::HWLOC) {
6090 KMP_WARNING(AffIgnoringHwloc, var);
6091 __kmp_affinity_top_method = affinity_top_method_all;
6094 if (__kmp_affinity_type == affinity_disabled) {
6095 KMP_AFFINITY_DISABLE();
6096 }
else if (!KMP_AFFINITY_CAPABLE()) {
6097 __kmp_affinity_dispatch->determine_capable(var);
6098 if (!KMP_AFFINITY_CAPABLE()) {
6099 if (__kmp_affinity_verbose ||
6100 (__kmp_affinity_warnings &&
6101 (__kmp_affinity_type != affinity_default) &&
6102 (__kmp_affinity_type != affinity_none) &&
6103 (__kmp_affinity_type != affinity_disabled))) {
6104 KMP_WARNING(AffNotSupported, var);
6106 __kmp_affinity_type = affinity_disabled;
6107 __kmp_affinity_respect_mask = 0;
6108 __kmp_affinity_gran = KMP_HW_THREAD;
6112 if (__kmp_affinity_type == affinity_disabled) {
6113 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
6114 }
else if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_true) {
6116 __kmp_nested_proc_bind.bind_types[0] = proc_bind_spread;
6119 if (KMP_AFFINITY_CAPABLE()) {
6121 #if KMP_GROUP_AFFINITY
6126 bool exactly_one_group =
false;
6127 if (__kmp_num_proc_groups > 1) {
6129 bool within_one_group;
6132 kmp_affin_mask_t *init_mask;
6133 KMP_CPU_ALLOC(init_mask);
6134 __kmp_get_system_affinity(init_mask, TRUE);
6135 group = __kmp_get_proc_group(init_mask);
6136 within_one_group = (group >= 0);
6139 if (within_one_group) {
6140 DWORD num_bits_in_group = __kmp_GetActiveProcessorCount(group);
6141 DWORD num_bits_in_mask = 0;
6142 for (
int bit = init_mask->begin(); bit != init_mask->end();
6143 bit = init_mask->next(bit))
6145 exactly_one_group = (num_bits_in_group == num_bits_in_mask);
6147 KMP_CPU_FREE(init_mask);
6153 if (__kmp_num_proc_groups > 1 &&
6154 __kmp_affinity_type == affinity_default &&
6155 __kmp_nested_proc_bind.bind_types[0] == proc_bind_default) {
6160 if (__kmp_affinity_respect_mask == affinity_respect_mask_default &&
6161 exactly_one_group) {
6162 __kmp_affinity_respect_mask = FALSE;
6166 if (__kmp_affinity_type == affinity_default) {
6167 __kmp_affinity_type = affinity_compact;
6168 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
6170 if (__kmp_affinity_top_method == affinity_top_method_default)
6171 __kmp_affinity_top_method = affinity_top_method_all;
6172 if (__kmp_affinity_gran == KMP_HW_UNKNOWN)
6173 __kmp_affinity_gran = KMP_HW_PROC_GROUP;
6179 if (__kmp_affinity_respect_mask == affinity_respect_mask_default) {
6180 #if KMP_GROUP_AFFINITY
6181 if (__kmp_num_proc_groups > 1 && exactly_one_group) {
6182 __kmp_affinity_respect_mask = FALSE;
6186 __kmp_affinity_respect_mask = TRUE;
6189 if ((__kmp_nested_proc_bind.bind_types[0] != proc_bind_intel) &&
6190 (__kmp_nested_proc_bind.bind_types[0] != proc_bind_default)) {
6191 if (__kmp_affinity_type == affinity_default) {
6192 __kmp_affinity_type = affinity_compact;
6193 __kmp_affinity_dups = FALSE;
6195 }
else if (__kmp_affinity_type == affinity_default) {
6196 #if KMP_MIC_SUPPORTED
6197 if (__kmp_mic_type != non_mic) {
6198 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
6202 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
6204 #if KMP_MIC_SUPPORTED
6205 if (__kmp_mic_type != non_mic) {
6206 __kmp_affinity_type = affinity_scatter;
6210 __kmp_affinity_type = affinity_none;
6213 if ((__kmp_affinity_gran == KMP_HW_UNKNOWN) &&
6214 (__kmp_affinity_gran_levels < 0)) {
6215 #if KMP_MIC_SUPPORTED
6216 if (__kmp_mic_type != non_mic) {
6217 __kmp_affinity_gran = KMP_HW_THREAD;
6221 __kmp_affinity_gran = KMP_HW_CORE;
6224 if (__kmp_affinity_top_method == affinity_top_method_default) {
6225 __kmp_affinity_top_method = affinity_top_method_all;
6230 K_DIAG(1, (
"__kmp_affinity_type == %d\n", __kmp_affinity_type));
6231 K_DIAG(1, (
"__kmp_affinity_compact == %d\n", __kmp_affinity_compact));
6232 K_DIAG(1, (
"__kmp_affinity_offset == %d\n", __kmp_affinity_offset));
6233 K_DIAG(1, (
"__kmp_affinity_verbose == %d\n", __kmp_affinity_verbose));
6234 K_DIAG(1, (
"__kmp_affinity_warnings == %d\n", __kmp_affinity_warnings));
6235 K_DIAG(1, (
"__kmp_affinity_respect_mask == %d\n",
6236 __kmp_affinity_respect_mask));
6237 K_DIAG(1, (
"__kmp_affinity_gran == %d\n", __kmp_affinity_gran));
6239 KMP_DEBUG_ASSERT(__kmp_affinity_type != affinity_default);
6240 KMP_DEBUG_ASSERT(__kmp_nested_proc_bind.bind_types[0] != proc_bind_default);
6241 K_DIAG(1, (
"__kmp_nested_proc_bind.bind_types[0] == %d\n",
6242 __kmp_nested_proc_bind.bind_types[0]));
6247 if (__kmp_version) {
6248 __kmp_print_version_1();
6253 if (
string != NULL) {
6254 __kmp_aux_env_initialize(&block);
6257 __kmp_env_blk_free(&block);
6263 void __kmp_env_print() {
6265 kmp_env_blk_t block;
6267 kmp_str_buf_t buffer;
6270 __kmp_str_buf_init(&buffer);
6272 __kmp_env_blk_init(&block, NULL);
6273 __kmp_env_blk_sort(&block);
6276 __kmp_str_buf_print(&buffer,
"\n%s\n\n", KMP_I18N_STR(UserSettings));
6277 for (i = 0; i < block.count; ++i) {
6278 char const *name = block.vars[i].name;
6279 char const *value = block.vars[i].value;
6280 if ((KMP_STRLEN(name) > 4 && strncmp(name,
"KMP_", 4) == 0) ||
6281 strncmp(name,
"OMP_", 4) == 0
6282 #ifdef KMP_GOMP_COMPAT
6283 || strncmp(name,
"GOMP_", 5) == 0
6286 __kmp_str_buf_print(&buffer,
" %s=%s\n", name, value);
6289 __kmp_str_buf_print(&buffer,
"\n");
6292 __kmp_str_buf_print(&buffer,
"%s\n\n", KMP_I18N_STR(EffectiveSettings));
6293 for (
int i = 0; i < __kmp_stg_count; ++i) {
6294 if (__kmp_stg_table[i].print != NULL) {
6295 __kmp_stg_table[i].print(&buffer, __kmp_stg_table[i].name,
6296 __kmp_stg_table[i].data);
6300 __kmp_printf(
"%s", buffer.str);
6302 __kmp_env_blk_free(&block);
6303 __kmp_str_buf_free(&buffer);
6309 void __kmp_env_print_2() {
6310 __kmp_display_env_impl(__kmp_display_env, __kmp_display_env_verbose);
6313 void __kmp_display_env_impl(
int display_env,
int display_env_verbose) {
6314 kmp_env_blk_t block;
6315 kmp_str_buf_t buffer;
6317 __kmp_env_format = 1;
6320 __kmp_str_buf_init(&buffer);
6322 __kmp_env_blk_init(&block, NULL);
6323 __kmp_env_blk_sort(&block);
6325 __kmp_str_buf_print(&buffer,
"\n%s\n", KMP_I18N_STR(DisplayEnvBegin));
6326 __kmp_str_buf_print(&buffer,
" _OPENMP='%d'\n", __kmp_openmp_version);
6328 for (
int i = 0; i < __kmp_stg_count; ++i) {
6329 if (__kmp_stg_table[i].print != NULL &&
6330 ((display_env && strncmp(__kmp_stg_table[i].name,
"OMP_", 4) == 0) ||
6331 display_env_verbose)) {
6332 __kmp_stg_table[i].print(&buffer, __kmp_stg_table[i].name,
6333 __kmp_stg_table[i].data);
6337 __kmp_str_buf_print(&buffer,
"%s\n", KMP_I18N_STR(DisplayEnvEnd));
6338 __kmp_str_buf_print(&buffer,
"\n");
6340 __kmp_printf(
"%s", buffer.str);
6342 __kmp_env_blk_free(&block);
6343 __kmp_str_buf_free(&buffer);
6350 void __kmp_env_dump() {
6352 kmp_env_blk_t block;
6353 kmp_str_buf_t buffer, env, notdefined;
6356 __kmp_str_buf_init(&buffer);
6357 __kmp_str_buf_init(&env);
6358 __kmp_str_buf_init(¬defined);
6360 __kmp_env_blk_init(&block, NULL);
6361 __kmp_env_blk_sort(&block);
6363 __kmp_str_buf_print(¬defined,
": %s", KMP_I18N_STR(NotDefined));
6365 for (
int i = 0; i < __kmp_stg_count; ++i) {
6366 if (__kmp_stg_table[i].print == NULL)
6368 __kmp_str_buf_clear(&env);
6369 __kmp_stg_table[i].print(&env, __kmp_stg_table[i].name,
6370 __kmp_stg_table[i].data);
6373 if (strstr(env.str, notdefined.str))
6375 __kmp_str_buf_print(&buffer,
"%s=undefined\n", __kmp_stg_table[i].name);
6377 __kmp_str_buf_cat(&buffer, env.str + 3, env.used - 3);
6380 ompd_env_block = (
char *)__kmp_allocate(buffer.used + 1);
6381 KMP_MEMCPY(ompd_env_block, buffer.str, buffer.used + 1);
6382 ompd_env_block_size = (ompd_size_t)KMP_STRLEN(ompd_env_block);
6384 __kmp_env_blk_free(&block);
6385 __kmp_str_buf_free(&buffer);
6386 __kmp_str_buf_free(&env);
6387 __kmp_str_buf_free(¬defined);
@ kmp_sch_modifier_monotonic
@ kmp_sch_modifier_nonmonotonic