14 #include "kmp_affinity.h"
15 #include "kmp_atomic.h"
16 #if KMP_USE_HIER_SCHED
17 #include "kmp_dispatch_hier.h"
19 #include "kmp_environment.h"
24 #include "kmp_settings.h"
26 #include "kmp_wrapper_getpid.h"
29 static int __kmp_env_toPrint(
char const *name,
int flag);
31 bool __kmp_env_format = 0;
36 #ifdef USE_LOAD_BALANCE
37 static double __kmp_convert_to_double(
char const *s) {
40 if (KMP_SSCANF(s,
"%lf", &result) < 1) {
49 static unsigned int __kmp_readstr_with_sentinel(
char *dest,
char const *src,
50 size_t len,
char sentinel) {
52 for (i = 0; i < len; i++) {
53 if ((*src ==
'\0') || (*src == sentinel)) {
63 static int __kmp_match_with_sentinel(
char const *a,
char const *b,
size_t len,
71 while (*a && *b && *b != sentinel) {
72 char ca = *a, cb = *b;
74 if (ca >=
'a' && ca <=
'z')
76 if (cb >=
'a' && cb <=
'z')
110 static int __kmp_match_str(
char const *token,
char const *buf,
113 KMP_ASSERT(token != NULL);
114 KMP_ASSERT(buf != NULL);
115 KMP_ASSERT(end != NULL);
117 while (*token && *buf) {
118 char ct = *token, cb = *buf;
120 if (ct >=
'a' && ct <=
'z')
122 if (cb >=
'a' && cb <=
'z')
137 static size_t __kmp_round4k(
size_t size) {
138 size_t _4k = 4 * 1024;
139 if (size & (_4k - 1)) {
141 if (size <= KMP_SIZE_T_MAX - _4k) {
153 int __kmp_convert_to_milliseconds(
char const *data) {
154 int ret, nvalues, factor;
160 if (__kmp_str_match(
"infinit", -1, data))
164 nvalues = KMP_SSCANF(data,
"%lf%c%c", &value, &mult, &extra);
190 factor = 1000 * 60 * 60;
194 factor = 1000 * 24 * 60 * 60;
200 if (value >= ((INT_MAX - 1) / factor))
203 ret = (int)(value * (
double)factor);
208 static int __kmp_strcasecmp_with_sentinel(
char const *a,
char const *b,
214 while (*a && *b && *b != sentinel) {
215 char ca = *a, cb = *b;
217 if (ca >=
'a' && ca <=
'z')
219 if (cb >=
'a' && cb <=
'z')
222 return (
int)(
unsigned char)*a - (
int)(
unsigned char)*b;
227 ? (*b && *b != sentinel)
228 ? (
int)(
unsigned char)*a - (
int)(
unsigned char)*b
230 : (*b && *b != sentinel) ? -1 : 0;
236 typedef struct __kmp_setting kmp_setting_t;
237 typedef struct __kmp_stg_ss_data kmp_stg_ss_data_t;
238 typedef struct __kmp_stg_wp_data kmp_stg_wp_data_t;
239 typedef struct __kmp_stg_fr_data kmp_stg_fr_data_t;
241 typedef void (*kmp_stg_parse_func_t)(
char const *name,
char const *value,
243 typedef void (*kmp_stg_print_func_t)(kmp_str_buf_t *buffer,
char const *name,
246 struct __kmp_setting {
248 kmp_stg_parse_func_t parse;
249 kmp_stg_print_func_t print;
256 struct __kmp_stg_ss_data {
258 kmp_setting_t **rivals;
261 struct __kmp_stg_wp_data {
263 kmp_setting_t **rivals;
266 struct __kmp_stg_fr_data {
268 kmp_setting_t **rivals;
271 static int __kmp_stg_check_rivals(
274 kmp_setting_t **rivals
280 static void __kmp_stg_parse_bool(
char const *name,
char const *value,
282 if (__kmp_str_match_true(value)) {
284 }
else if (__kmp_str_match_false(value)) {
287 __kmp_msg(kmp_ms_warning, KMP_MSG(BadBoolValue, name, value),
288 KMP_HNT(ValidBoolValues), __kmp_msg_null);
293 void __kmp_check_stksize(
size_t *val) {
295 if (*val > KMP_DEFAULT_STKSIZE * 16)
296 *val = KMP_DEFAULT_STKSIZE * 16;
297 if (*val < KMP_MIN_STKSIZE)
298 *val = KMP_MIN_STKSIZE;
299 if (*val > KMP_MAX_STKSIZE)
300 *val = KMP_MAX_STKSIZE;
302 *val = __kmp_round4k(*val);
306 static void __kmp_stg_parse_size(
char const *name,
char const *value,
307 size_t size_min,
size_t size_max,
308 int *is_specified,
size_t *out,
310 char const *msg = NULL;
312 size_min = __kmp_round4k(size_min);
313 size_max = __kmp_round4k(size_max);
316 if (is_specified != NULL) {
319 __kmp_str_to_size(value, out, factor, &msg);
321 if (*out > size_max) {
323 msg = KMP_I18N_STR(ValueTooLarge);
324 }
else if (*out < size_min) {
326 msg = KMP_I18N_STR(ValueTooSmall);
329 size_t round4k = __kmp_round4k(*out);
330 if (*out != round4k) {
332 msg = KMP_I18N_STR(NotMultiple4K);
339 if (*out < size_min) {
341 }
else if (*out > size_max) {
348 __kmp_str_buf_init(&buf);
349 __kmp_str_buf_print_size(&buf, *out);
350 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
351 KMP_INFORM(Using_str_Value, name, buf.str);
352 __kmp_str_buf_free(&buf);
357 static void __kmp_stg_parse_str(
char const *name,
char const *value,
360 *out = __kmp_str_format(
"%s", value);
363 static void __kmp_stg_parse_int(
371 char const *msg = NULL;
372 kmp_uint64 uint = *out;
373 __kmp_str_to_uint(value, &uint, &msg);
375 if (uint < (
unsigned int)min) {
376 msg = KMP_I18N_STR(ValueTooSmall);
378 }
else if (uint > (
unsigned int)max) {
379 msg = KMP_I18N_STR(ValueTooLarge);
385 if (uint < (
unsigned int)min) {
387 }
else if (uint > (
unsigned int)max) {
394 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
395 __kmp_str_buf_init(&buf);
396 __kmp_str_buf_print(&buf,
"%" KMP_UINT64_SPEC
"", uint);
397 KMP_INFORM(Using_uint64_Value, name, buf.str);
398 __kmp_str_buf_free(&buf);
400 __kmp_type_convert(uint, out);
403 #if KMP_DEBUG_ADAPTIVE_LOCKS
404 static void __kmp_stg_parse_file(
char const *name,
char const *value,
405 const char *suffix,
char **out) {
410 t = (
char *)strrchr(value,
'.');
411 hasSuffix = t && __kmp_str_eqf(t, suffix);
412 t = __kmp_str_format(
"%s%s", value, hasSuffix ?
"" : suffix);
413 __kmp_expand_file_name(buffer,
sizeof(buffer), t);
415 *out = __kmp_str_format(
"%s", buffer);
420 static char *par_range_to_print = NULL;
422 static void __kmp_stg_parse_par_range(
char const *name,
char const *value,
423 int *out_range,
char *out_routine,
424 char *out_file,
int *out_lb,
426 size_t len = KMP_STRLEN(value) + 1;
427 par_range_to_print = (
char *)KMP_INTERNAL_MALLOC(len + 1);
428 KMP_STRNCPY_S(par_range_to_print, len + 1, value, len + 1);
429 __kmp_par_range = +1;
430 __kmp_par_range_lb = 0;
431 __kmp_par_range_ub = INT_MAX;
434 if (*value ==
'\0') {
437 if (!__kmp_strcasecmp_with_sentinel(
"routine", value,
'=')) {
438 value = strchr(value,
'=') + 1;
439 len = __kmp_readstr_with_sentinel(out_routine, value,
440 KMP_PAR_RANGE_ROUTINE_LEN - 1,
',');
442 goto par_range_error;
444 value = strchr(value,
',');
450 if (!__kmp_strcasecmp_with_sentinel(
"filename", value,
'=')) {
451 value = strchr(value,
'=') + 1;
452 len = __kmp_readstr_with_sentinel(out_file, value,
453 KMP_PAR_RANGE_FILENAME_LEN - 1,
',');
455 goto par_range_error;
457 value = strchr(value,
',');
463 if ((!__kmp_strcasecmp_with_sentinel(
"range", value,
'=')) ||
464 (!__kmp_strcasecmp_with_sentinel(
"incl_range", value,
'='))) {
465 value = strchr(value,
'=') + 1;
466 if (KMP_SSCANF(value,
"%d:%d", out_lb, out_ub) != 2) {
467 goto par_range_error;
470 value = strchr(value,
',');
476 if (!__kmp_strcasecmp_with_sentinel(
"excl_range", value,
'=')) {
477 value = strchr(value,
'=') + 1;
478 if (KMP_SSCANF(value,
"%d:%d", out_lb, out_ub) != 2) {
479 goto par_range_error;
482 value = strchr(value,
',');
489 KMP_WARNING(ParRangeSyntax, name);
496 int __kmp_initial_threads_capacity(
int req_nproc) {
501 if (nth < (4 * req_nproc))
502 nth = (4 * req_nproc);
503 if (nth < (4 * __kmp_xproc))
504 nth = (4 * __kmp_xproc);
509 nth += __kmp_hidden_helper_threads_num;
511 if (nth > __kmp_max_nth)
517 int __kmp_default_tp_capacity(
int req_nproc,
int max_nth,
518 int all_threads_specified) {
521 if (all_threads_specified)
525 if (nth < (4 * req_nproc))
526 nth = (4 * req_nproc);
527 if (nth < (4 * __kmp_xproc))
528 nth = (4 * __kmp_xproc);
530 if (nth > __kmp_max_nth)
539 static void __kmp_stg_print_bool(kmp_str_buf_t *buffer,
char const *name,
541 if (__kmp_env_format) {
542 KMP_STR_BUF_PRINT_BOOL;
544 __kmp_str_buf_print(buffer,
" %s=%s\n", name, value ?
"true" :
"false");
548 static void __kmp_stg_print_int(kmp_str_buf_t *buffer,
char const *name,
550 if (__kmp_env_format) {
551 KMP_STR_BUF_PRINT_INT;
553 __kmp_str_buf_print(buffer,
" %s=%d\n", name, value);
557 static void __kmp_stg_print_uint64(kmp_str_buf_t *buffer,
char const *name,
559 if (__kmp_env_format) {
560 KMP_STR_BUF_PRINT_UINT64;
562 __kmp_str_buf_print(buffer,
" %s=%" KMP_UINT64_SPEC
"\n", name, value);
566 static void __kmp_stg_print_str(kmp_str_buf_t *buffer,
char const *name,
568 if (__kmp_env_format) {
569 KMP_STR_BUF_PRINT_STR;
571 __kmp_str_buf_print(buffer,
" %s=%s\n", name, value);
575 static void __kmp_stg_print_size(kmp_str_buf_t *buffer,
char const *name,
577 if (__kmp_env_format) {
578 KMP_STR_BUF_PRINT_NAME_EX(name);
579 __kmp_str_buf_print_size(buffer, value);
580 __kmp_str_buf_print(buffer,
"'\n");
582 __kmp_str_buf_print(buffer,
" %s=", name);
583 __kmp_str_buf_print_size(buffer, value);
584 __kmp_str_buf_print(buffer,
"\n");
595 static void __kmp_stg_parse_device_thread_limit(
char const *name,
596 char const *value,
void *data) {
597 kmp_setting_t **rivals = (kmp_setting_t **)data;
599 if (strcmp(name,
"KMP_ALL_THREADS") == 0) {
600 KMP_INFORM(EnvVarDeprecated, name,
"KMP_DEVICE_THREAD_LIMIT");
602 rc = __kmp_stg_check_rivals(name, value, rivals);
606 if (!__kmp_strcasecmp_with_sentinel(
"all", value, 0)) {
607 __kmp_max_nth = __kmp_xproc;
608 __kmp_allThreadsSpecified = 1;
610 __kmp_stg_parse_int(name, value, 1, __kmp_sys_max_nth, &__kmp_max_nth);
611 __kmp_allThreadsSpecified = 0;
613 K_DIAG(1, (
"__kmp_max_nth == %d\n", __kmp_max_nth));
617 static void __kmp_stg_print_device_thread_limit(kmp_str_buf_t *buffer,
618 char const *name,
void *data) {
619 __kmp_stg_print_int(buffer, name, __kmp_max_nth);
624 static void __kmp_stg_parse_thread_limit(
char const *name,
char const *value,
626 __kmp_stg_parse_int(name, value, 1, __kmp_sys_max_nth, &__kmp_cg_max_nth);
627 K_DIAG(1, (
"__kmp_cg_max_nth == %d\n", __kmp_cg_max_nth));
631 static void __kmp_stg_print_thread_limit(kmp_str_buf_t *buffer,
632 char const *name,
void *data) {
633 __kmp_stg_print_int(buffer, name, __kmp_cg_max_nth);
638 static void __kmp_stg_parse_teams_thread_limit(
char const *name,
639 char const *value,
void *data) {
640 __kmp_stg_parse_int(name, value, 1, __kmp_sys_max_nth, &__kmp_teams_max_nth);
643 static void __kmp_stg_print_teams_thread_limit(kmp_str_buf_t *buffer,
644 char const *name,
void *data) {
645 __kmp_stg_print_int(buffer, name, __kmp_teams_max_nth);
650 static void __kmp_stg_parse_use_yield(
char const *name,
char const *value,
652 __kmp_stg_parse_int(name, value, 0, 2, &__kmp_use_yield);
653 __kmp_use_yield_exp_set = 1;
656 static void __kmp_stg_print_use_yield(kmp_str_buf_t *buffer,
char const *name,
658 __kmp_stg_print_int(buffer, name, __kmp_use_yield);
664 static void __kmp_stg_parse_blocktime(
char const *name,
char const *value,
666 __kmp_dflt_blocktime = __kmp_convert_to_milliseconds(value);
667 if (__kmp_dflt_blocktime < 0) {
668 __kmp_dflt_blocktime = KMP_DEFAULT_BLOCKTIME;
669 __kmp_msg(kmp_ms_warning, KMP_MSG(InvalidValue, name, value),
671 KMP_INFORM(Using_int_Value, name, __kmp_dflt_blocktime);
672 __kmp_env_blocktime = FALSE;
674 if (__kmp_dflt_blocktime < KMP_MIN_BLOCKTIME) {
675 __kmp_dflt_blocktime = KMP_MIN_BLOCKTIME;
676 __kmp_msg(kmp_ms_warning, KMP_MSG(SmallValue, name, value),
678 KMP_INFORM(MinValueUsing, name, __kmp_dflt_blocktime);
679 }
else if (__kmp_dflt_blocktime > KMP_MAX_BLOCKTIME) {
680 __kmp_dflt_blocktime = KMP_MAX_BLOCKTIME;
681 __kmp_msg(kmp_ms_warning, KMP_MSG(LargeValue, name, value),
683 KMP_INFORM(MaxValueUsing, name, __kmp_dflt_blocktime);
685 __kmp_env_blocktime = TRUE;
690 __kmp_monitor_wakeups =
691 KMP_WAKEUPS_FROM_BLOCKTIME(__kmp_dflt_blocktime, __kmp_monitor_wakeups);
693 KMP_INTERVALS_FROM_BLOCKTIME(__kmp_dflt_blocktime, __kmp_monitor_wakeups);
695 K_DIAG(1, (
"__kmp_env_blocktime == %d\n", __kmp_env_blocktime));
696 if (__kmp_env_blocktime) {
697 K_DIAG(1, (
"__kmp_dflt_blocktime == %d\n", __kmp_dflt_blocktime));
701 static void __kmp_stg_print_blocktime(kmp_str_buf_t *buffer,
char const *name,
703 __kmp_stg_print_int(buffer, name, __kmp_dflt_blocktime);
709 static void __kmp_stg_parse_duplicate_lib_ok(
char const *name,
710 char const *value,
void *data) {
713 __kmp_stg_parse_bool(name, value, &__kmp_duplicate_library_ok);
716 static void __kmp_stg_print_duplicate_lib_ok(kmp_str_buf_t *buffer,
717 char const *name,
void *data) {
718 __kmp_stg_print_bool(buffer, name, __kmp_duplicate_library_ok);
724 #if KMP_ARCH_X86 || KMP_ARCH_X86_64
726 static void __kmp_stg_parse_inherit_fp_control(
char const *name,
727 char const *value,
void *data) {
728 __kmp_stg_parse_bool(name, value, &__kmp_inherit_fp_control);
731 static void __kmp_stg_print_inherit_fp_control(kmp_str_buf_t *buffer,
732 char const *name,
void *data) {
734 __kmp_stg_print_bool(buffer, name, __kmp_inherit_fp_control);
741 static char const *blocktime_str = NULL;
746 static void __kmp_stg_parse_wait_policy(
char const *name,
char const *value,
749 kmp_stg_wp_data_t *wait = (kmp_stg_wp_data_t *)data;
752 rc = __kmp_stg_check_rivals(name, value, wait->rivals);
758 if (__kmp_str_match(
"ACTIVE", 1, value)) {
759 __kmp_library = library_turnaround;
760 if (blocktime_str == NULL) {
762 __kmp_dflt_blocktime = KMP_MAX_BLOCKTIME;
764 }
else if (__kmp_str_match(
"PASSIVE", 1, value)) {
765 __kmp_library = library_throughput;
766 if (blocktime_str == NULL) {
768 __kmp_dflt_blocktime = 0;
771 KMP_WARNING(StgInvalidValue, name, value);
774 if (__kmp_str_match(
"serial", 1, value)) {
775 __kmp_library = library_serial;
776 }
else if (__kmp_str_match(
"throughput", 2, value)) {
777 __kmp_library = library_throughput;
778 if (blocktime_str == NULL) {
780 __kmp_dflt_blocktime = 0;
782 }
else if (__kmp_str_match(
"turnaround", 2, value)) {
783 __kmp_library = library_turnaround;
784 }
else if (__kmp_str_match(
"dedicated", 1, value)) {
785 __kmp_library = library_turnaround;
786 }
else if (__kmp_str_match(
"multiuser", 1, value)) {
787 __kmp_library = library_throughput;
788 if (blocktime_str == NULL) {
790 __kmp_dflt_blocktime = 0;
793 KMP_WARNING(StgInvalidValue, name, value);
798 static void __kmp_stg_print_wait_policy(kmp_str_buf_t *buffer,
char const *name,
801 kmp_stg_wp_data_t *wait = (kmp_stg_wp_data_t *)data;
802 char const *value = NULL;
805 switch (__kmp_library) {
806 case library_turnaround: {
809 case library_throughput: {
814 switch (__kmp_library) {
815 case library_serial: {
818 case library_turnaround: {
819 value =
"turnaround";
821 case library_throughput: {
822 value =
"throughput";
827 __kmp_stg_print_str(buffer, name, value);
836 static void __kmp_stg_parse_monitor_stacksize(
char const *name,
837 char const *value,
void *data) {
838 __kmp_stg_parse_size(name, value, __kmp_sys_min_stksize, KMP_MAX_STKSIZE,
839 NULL, &__kmp_monitor_stksize, 1);
842 static void __kmp_stg_print_monitor_stacksize(kmp_str_buf_t *buffer,
843 char const *name,
void *data) {
844 if (__kmp_env_format) {
845 if (__kmp_monitor_stksize > 0)
846 KMP_STR_BUF_PRINT_NAME_EX(name);
848 KMP_STR_BUF_PRINT_NAME;
850 __kmp_str_buf_print(buffer,
" %s", name);
852 if (__kmp_monitor_stksize > 0) {
853 __kmp_str_buf_print_size(buffer, __kmp_monitor_stksize);
855 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
857 if (__kmp_env_format && __kmp_monitor_stksize) {
858 __kmp_str_buf_print(buffer,
"'\n");
866 static void __kmp_stg_parse_settings(
char const *name,
char const *value,
868 __kmp_stg_parse_bool(name, value, &__kmp_settings);
871 static void __kmp_stg_print_settings(kmp_str_buf_t *buffer,
char const *name,
873 __kmp_stg_print_bool(buffer, name, __kmp_settings);
879 static void __kmp_stg_parse_stackpad(
char const *name,
char const *value,
881 __kmp_stg_parse_int(name,
889 static void __kmp_stg_print_stackpad(kmp_str_buf_t *buffer,
char const *name,
891 __kmp_stg_print_int(buffer, name, __kmp_stkpadding);
897 static void __kmp_stg_parse_stackoffset(
char const *name,
char const *value,
899 __kmp_stg_parse_size(name,
908 static void __kmp_stg_print_stackoffset(kmp_str_buf_t *buffer,
char const *name,
910 __kmp_stg_print_size(buffer, name, __kmp_stkoffset);
916 static void __kmp_stg_parse_stacksize(
char const *name,
char const *value,
919 kmp_stg_ss_data_t *stacksize = (kmp_stg_ss_data_t *)data;
922 rc = __kmp_stg_check_rivals(name, value, stacksize->rivals);
926 __kmp_stg_parse_size(name,
928 __kmp_sys_min_stksize,
940 static void __kmp_stg_print_stacksize(kmp_str_buf_t *buffer,
char const *name,
942 kmp_stg_ss_data_t *stacksize = (kmp_stg_ss_data_t *)data;
943 if (__kmp_env_format) {
944 KMP_STR_BUF_PRINT_NAME_EX(name);
945 __kmp_str_buf_print_size(buffer, (__kmp_stksize % 1024)
946 ? __kmp_stksize / stacksize->factor
948 __kmp_str_buf_print(buffer,
"'\n");
950 __kmp_str_buf_print(buffer,
" %s=", name);
951 __kmp_str_buf_print_size(buffer, (__kmp_stksize % 1024)
952 ? __kmp_stksize / stacksize->factor
954 __kmp_str_buf_print(buffer,
"\n");
961 static void __kmp_stg_parse_version(
char const *name,
char const *value,
963 __kmp_stg_parse_bool(name, value, &__kmp_version);
966 static void __kmp_stg_print_version(kmp_str_buf_t *buffer,
char const *name,
968 __kmp_stg_print_bool(buffer, name, __kmp_version);
974 static void __kmp_stg_parse_warnings(
char const *name,
char const *value,
976 __kmp_stg_parse_bool(name, value, &__kmp_generate_warnings);
977 if (__kmp_generate_warnings != kmp_warnings_off) {
980 __kmp_generate_warnings = kmp_warnings_explicit;
984 static void __kmp_stg_print_warnings(kmp_str_buf_t *buffer,
char const *name,
987 __kmp_stg_print_bool(buffer, name, __kmp_generate_warnings);
993 static void __kmp_stg_parse_nested(
char const *name,
char const *value,
996 KMP_INFORM(EnvVarDeprecated, name,
"OMP_MAX_ACTIVE_LEVELS");
997 __kmp_stg_parse_bool(name, value, &nested);
999 if (!__kmp_dflt_max_active_levels_set)
1000 __kmp_dflt_max_active_levels = KMP_MAX_ACTIVE_LEVELS_LIMIT;
1002 __kmp_dflt_max_active_levels = 1;
1003 __kmp_dflt_max_active_levels_set =
true;
1007 static void __kmp_stg_print_nested(kmp_str_buf_t *buffer,
char const *name,
1009 if (__kmp_env_format) {
1010 KMP_STR_BUF_PRINT_NAME;
1012 __kmp_str_buf_print(buffer,
" %s", name);
1014 __kmp_str_buf_print(buffer,
": deprecated; max-active-levels-var=%d\n",
1015 __kmp_dflt_max_active_levels);
1018 static void __kmp_parse_nested_num_threads(
const char *var,
const char *env,
1019 kmp_nested_nthreads_t *nth_array) {
1020 const char *next = env;
1021 const char *scan = next;
1024 int prev_comma = FALSE;
1030 if (*next ==
'\0') {
1034 if (((*next <
'0') || (*next >
'9')) && (*next !=
',')) {
1035 KMP_WARNING(NthSyntaxError, var, env);
1041 if (total == 0 || prev_comma) {
1049 if (*next >=
'0' && *next <=
'9') {
1053 const char *tmp = next;
1055 if ((*next ==
' ' || *next ==
'\t') && (*tmp >=
'0' && *tmp <=
'9')) {
1056 KMP_WARNING(NthSpacesNotAllowed, var, env);
1061 if (!__kmp_dflt_max_active_levels_set && total > 1)
1062 __kmp_dflt_max_active_levels = KMP_MAX_ACTIVE_LEVELS_LIMIT;
1063 KMP_DEBUG_ASSERT(total > 0);
1065 KMP_WARNING(NthSyntaxError, var, env);
1070 if (!nth_array->nth) {
1072 nth_array->nth = (
int *)KMP_INTERNAL_MALLOC(
sizeof(
int) * total * 2);
1073 if (nth_array->nth == NULL) {
1074 KMP_FATAL(MemoryAllocFailed);
1076 nth_array->size = total * 2;
1078 if (nth_array->size < total) {
1081 nth_array->size *= 2;
1082 }
while (nth_array->size < total);
1084 nth_array->nth = (
int *)KMP_INTERNAL_REALLOC(
1085 nth_array->nth,
sizeof(
int) * nth_array->size);
1086 if (nth_array->nth == NULL) {
1087 KMP_FATAL(MemoryAllocFailed);
1091 nth_array->used = total;
1099 if (*scan ==
'\0') {
1109 nth_array->nth[i++] = 0;
1111 }
else if (prev_comma) {
1113 nth_array->nth[i] = nth_array->nth[i - 1];
1122 if (*scan >=
'0' && *scan <=
'9') {
1124 const char *buf = scan;
1125 char const *msg = NULL;
1130 num = __kmp_str_to_int(buf, *scan);
1131 if (num < KMP_MIN_NTH) {
1132 msg = KMP_I18N_STR(ValueTooSmall);
1134 }
else if (num > __kmp_sys_max_nth) {
1135 msg = KMP_I18N_STR(ValueTooLarge);
1136 num = __kmp_sys_max_nth;
1140 KMP_WARNING(ParseSizeIntWarn, var, env, msg);
1141 KMP_INFORM(Using_int_Value, var, num);
1143 nth_array->nth[i++] = num;
1148 static void __kmp_stg_parse_num_threads(
char const *name,
char const *value,
1151 if (!__kmp_strcasecmp_with_sentinel(
"all", value, 0)) {
1153 __kmp_nested_nth.nth = (
int *)KMP_INTERNAL_MALLOC(
sizeof(
int));
1154 __kmp_nested_nth.size = __kmp_nested_nth.used = 1;
1155 __kmp_nested_nth.nth[0] = __kmp_dflt_team_nth = __kmp_dflt_team_nth_ub =
1158 __kmp_parse_nested_num_threads(name, value, &__kmp_nested_nth);
1159 if (__kmp_nested_nth.nth) {
1160 __kmp_dflt_team_nth = __kmp_nested_nth.nth[0];
1161 if (__kmp_dflt_team_nth_ub < __kmp_dflt_team_nth) {
1162 __kmp_dflt_team_nth_ub = __kmp_dflt_team_nth;
1166 K_DIAG(1, (
"__kmp_dflt_team_nth == %d\n", __kmp_dflt_team_nth));
1169 static void __kmp_stg_parse_num_hidden_helper_threads(
char const *name,
1172 __kmp_stg_parse_int(name, value, 0, 16, &__kmp_hidden_helper_threads_num);
1175 if (__kmp_hidden_helper_threads_num == 0) {
1176 __kmp_enable_hidden_helper = FALSE;
1180 static void __kmp_stg_print_num_hidden_helper_threads(kmp_str_buf_t *buffer,
1183 __kmp_stg_print_int(buffer, name, __kmp_hidden_helper_threads_num);
1186 static void __kmp_stg_parse_use_hidden_helper(
char const *name,
1187 char const *value,
void *data) {
1188 __kmp_stg_parse_bool(name, value, &__kmp_enable_hidden_helper);
1190 __kmp_enable_hidden_helper = FALSE;
1192 (
"__kmp_stg_parse_use_hidden_helper: Disable hidden helper task on "
1193 "non-Linux platform although it is enabled by user explicitly.\n"));
1197 static void __kmp_stg_print_use_hidden_helper(kmp_str_buf_t *buffer,
1198 char const *name,
void *data) {
1199 __kmp_stg_print_bool(buffer, name, __kmp_enable_hidden_helper);
1202 static void __kmp_stg_print_num_threads(kmp_str_buf_t *buffer,
char const *name,
1204 if (__kmp_env_format) {
1205 KMP_STR_BUF_PRINT_NAME;
1207 __kmp_str_buf_print(buffer,
" %s", name);
1209 if (__kmp_nested_nth.used) {
1211 __kmp_str_buf_init(&buf);
1212 for (
int i = 0; i < __kmp_nested_nth.used; i++) {
1213 __kmp_str_buf_print(&buf,
"%d", __kmp_nested_nth.nth[i]);
1214 if (i < __kmp_nested_nth.used - 1) {
1215 __kmp_str_buf_print(&buf,
",");
1218 __kmp_str_buf_print(buffer,
"='%s'\n", buf.str);
1219 __kmp_str_buf_free(&buf);
1221 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
1228 static void __kmp_stg_parse_tasking(
char const *name,
char const *value,
1230 __kmp_stg_parse_int(name, value, 0, (
int)tskm_max,
1231 (
int *)&__kmp_tasking_mode);
1234 static void __kmp_stg_print_tasking(kmp_str_buf_t *buffer,
char const *name,
1236 __kmp_stg_print_int(buffer, name, __kmp_tasking_mode);
1239 static void __kmp_stg_parse_task_stealing(
char const *name,
char const *value,
1241 __kmp_stg_parse_int(name, value, 0, 1,
1242 (
int *)&__kmp_task_stealing_constraint);
1245 static void __kmp_stg_print_task_stealing(kmp_str_buf_t *buffer,
1246 char const *name,
void *data) {
1247 __kmp_stg_print_int(buffer, name, __kmp_task_stealing_constraint);
1250 static void __kmp_stg_parse_max_active_levels(
char const *name,
1251 char const *value,
void *data) {
1252 kmp_uint64 tmp_dflt = 0;
1253 char const *msg = NULL;
1254 if (!__kmp_dflt_max_active_levels_set) {
1256 __kmp_str_to_uint(value, &tmp_dflt, &msg);
1258 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
1259 }
else if (tmp_dflt > KMP_MAX_ACTIVE_LEVELS_LIMIT) {
1261 msg = KMP_I18N_STR(ValueTooLarge);
1262 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
1264 __kmp_type_convert(tmp_dflt, &(__kmp_dflt_max_active_levels));
1265 __kmp_dflt_max_active_levels_set =
true;
1270 static void __kmp_stg_print_max_active_levels(kmp_str_buf_t *buffer,
1271 char const *name,
void *data) {
1272 __kmp_stg_print_int(buffer, name, __kmp_dflt_max_active_levels);
1277 static void __kmp_stg_parse_default_device(
char const *name,
char const *value,
1279 __kmp_stg_parse_int(name, value, 0, KMP_MAX_DEFAULT_DEVICE_LIMIT,
1280 &__kmp_default_device);
1283 static void __kmp_stg_print_default_device(kmp_str_buf_t *buffer,
1284 char const *name,
void *data) {
1285 __kmp_stg_print_int(buffer, name, __kmp_default_device);
1290 static void __kmp_stg_parse_target_offload(
char const *name,
char const *value,
1292 const char *next = value;
1293 const char *scan = next;
1295 __kmp_target_offload = tgt_default;
1300 if (!__kmp_strcasecmp_with_sentinel(
"mandatory", scan, 0)) {
1301 __kmp_target_offload = tgt_mandatory;
1302 }
else if (!__kmp_strcasecmp_with_sentinel(
"disabled", scan, 0)) {
1303 __kmp_target_offload = tgt_disabled;
1304 }
else if (!__kmp_strcasecmp_with_sentinel(
"default", scan, 0)) {
1305 __kmp_target_offload = tgt_default;
1307 KMP_WARNING(SyntaxErrorUsing, name,
"DEFAULT");
1312 static void __kmp_stg_print_target_offload(kmp_str_buf_t *buffer,
1313 char const *name,
void *data) {
1314 const char *value = NULL;
1315 if (__kmp_target_offload == tgt_default)
1317 else if (__kmp_target_offload == tgt_mandatory)
1318 value =
"MANDATORY";
1319 else if (__kmp_target_offload == tgt_disabled)
1321 KMP_DEBUG_ASSERT(value);
1322 if (__kmp_env_format) {
1323 KMP_STR_BUF_PRINT_NAME;
1325 __kmp_str_buf_print(buffer,
" %s", name);
1327 __kmp_str_buf_print(buffer,
"=%s\n", value);
1332 static void __kmp_stg_parse_max_task_priority(
char const *name,
1333 char const *value,
void *data) {
1334 __kmp_stg_parse_int(name, value, 0, KMP_MAX_TASK_PRIORITY_LIMIT,
1335 &__kmp_max_task_priority);
1338 static void __kmp_stg_print_max_task_priority(kmp_str_buf_t *buffer,
1339 char const *name,
void *data) {
1340 __kmp_stg_print_int(buffer, name, __kmp_max_task_priority);
1345 static void __kmp_stg_parse_taskloop_min_tasks(
char const *name,
1346 char const *value,
void *data) {
1348 __kmp_stg_parse_int(name, value, 0, INT_MAX, &tmp);
1349 __kmp_taskloop_min_tasks = tmp;
1352 static void __kmp_stg_print_taskloop_min_tasks(kmp_str_buf_t *buffer,
1353 char const *name,
void *data) {
1354 __kmp_stg_print_uint64(buffer, name, __kmp_taskloop_min_tasks);
1359 static void __kmp_stg_parse_disp_buffers(
char const *name,
char const *value,
1361 if (TCR_4(__kmp_init_serial)) {
1362 KMP_WARNING(EnvSerialWarn, name);
1365 __kmp_stg_parse_int(name, value, 1, KMP_MAX_NTH, &__kmp_dispatch_num_buffers);
1368 static void __kmp_stg_print_disp_buffers(kmp_str_buf_t *buffer,
1369 char const *name,
void *data) {
1370 __kmp_stg_print_int(buffer, name, __kmp_dispatch_num_buffers);
1373 #if KMP_NESTED_HOT_TEAMS
1377 static void __kmp_stg_parse_hot_teams_level(
char const *name,
char const *value,
1379 if (TCR_4(__kmp_init_parallel)) {
1380 KMP_WARNING(EnvParallelWarn, name);
1383 __kmp_stg_parse_int(name, value, 0, KMP_MAX_ACTIVE_LEVELS_LIMIT,
1384 &__kmp_hot_teams_max_level);
1387 static void __kmp_stg_print_hot_teams_level(kmp_str_buf_t *buffer,
1388 char const *name,
void *data) {
1389 __kmp_stg_print_int(buffer, name, __kmp_hot_teams_max_level);
1392 static void __kmp_stg_parse_hot_teams_mode(
char const *name,
char const *value,
1394 if (TCR_4(__kmp_init_parallel)) {
1395 KMP_WARNING(EnvParallelWarn, name);
1398 __kmp_stg_parse_int(name, value, 0, KMP_MAX_ACTIVE_LEVELS_LIMIT,
1399 &__kmp_hot_teams_mode);
1402 static void __kmp_stg_print_hot_teams_mode(kmp_str_buf_t *buffer,
1403 char const *name,
void *data) {
1404 __kmp_stg_print_int(buffer, name, __kmp_hot_teams_mode);
1412 #if KMP_HANDLE_SIGNALS
1414 static void __kmp_stg_parse_handle_signals(
char const *name,
char const *value,
1416 __kmp_stg_parse_bool(name, value, &__kmp_handle_signals);
1419 static void __kmp_stg_print_handle_signals(kmp_str_buf_t *buffer,
1420 char const *name,
void *data) {
1421 __kmp_stg_print_bool(buffer, name, __kmp_handle_signals);
1431 #define KMP_STG_X_DEBUG(x) \
1432 static void __kmp_stg_parse_##x##_debug(char const *name, char const *value, \
1434 __kmp_stg_parse_int(name, value, 0, INT_MAX, &kmp_##x##_debug); \
1436 static void __kmp_stg_print_##x##_debug(kmp_str_buf_t *buffer, \
1437 char const *name, void *data) { \
1438 __kmp_stg_print_int(buffer, name, kmp_##x##_debug); \
1448 #undef KMP_STG_X_DEBUG
1450 static void __kmp_stg_parse_debug(
char const *name,
char const *value,
1453 __kmp_stg_parse_int(name, value, 0, INT_MAX, &debug);
1454 if (kmp_a_debug < debug) {
1455 kmp_a_debug = debug;
1457 if (kmp_b_debug < debug) {
1458 kmp_b_debug = debug;
1460 if (kmp_c_debug < debug) {
1461 kmp_c_debug = debug;
1463 if (kmp_d_debug < debug) {
1464 kmp_d_debug = debug;
1466 if (kmp_e_debug < debug) {
1467 kmp_e_debug = debug;
1469 if (kmp_f_debug < debug) {
1470 kmp_f_debug = debug;
1474 static void __kmp_stg_parse_debug_buf(
char const *name,
char const *value,
1476 __kmp_stg_parse_bool(name, value, &__kmp_debug_buf);
1480 if (__kmp_debug_buf) {
1482 int elements = __kmp_debug_buf_lines * __kmp_debug_buf_chars;
1485 __kmp_debug_buffer = (
char *)__kmp_page_allocate(elements *
sizeof(
char));
1486 for (i = 0; i < elements; i += __kmp_debug_buf_chars)
1487 __kmp_debug_buffer[i] =
'\0';
1489 __kmp_debug_count = 0;
1491 K_DIAG(1, (
"__kmp_debug_buf = %d\n", __kmp_debug_buf));
1494 static void __kmp_stg_print_debug_buf(kmp_str_buf_t *buffer,
char const *name,
1496 __kmp_stg_print_bool(buffer, name, __kmp_debug_buf);
1499 static void __kmp_stg_parse_debug_buf_atomic(
char const *name,
1500 char const *value,
void *data) {
1501 __kmp_stg_parse_bool(name, value, &__kmp_debug_buf_atomic);
1504 static void __kmp_stg_print_debug_buf_atomic(kmp_str_buf_t *buffer,
1505 char const *name,
void *data) {
1506 __kmp_stg_print_bool(buffer, name, __kmp_debug_buf_atomic);
1509 static void __kmp_stg_parse_debug_buf_chars(
char const *name,
char const *value,
1511 __kmp_stg_parse_int(name, value, KMP_DEBUG_BUF_CHARS_MIN, INT_MAX,
1512 &__kmp_debug_buf_chars);
1515 static void __kmp_stg_print_debug_buf_chars(kmp_str_buf_t *buffer,
1516 char const *name,
void *data) {
1517 __kmp_stg_print_int(buffer, name, __kmp_debug_buf_chars);
1520 static void __kmp_stg_parse_debug_buf_lines(
char const *name,
char const *value,
1522 __kmp_stg_parse_int(name, value, KMP_DEBUG_BUF_LINES_MIN, INT_MAX,
1523 &__kmp_debug_buf_lines);
1526 static void __kmp_stg_print_debug_buf_lines(kmp_str_buf_t *buffer,
1527 char const *name,
void *data) {
1528 __kmp_stg_print_int(buffer, name, __kmp_debug_buf_lines);
1531 static void __kmp_stg_parse_diag(
char const *name,
char const *value,
1533 __kmp_stg_parse_int(name, value, 0, INT_MAX, &kmp_diag);
1536 static void __kmp_stg_print_diag(kmp_str_buf_t *buffer,
char const *name,
1538 __kmp_stg_print_int(buffer, name, kmp_diag);
1546 static void __kmp_stg_parse_align_alloc(
char const *name,
char const *value,
1548 __kmp_stg_parse_size(name, value, CACHE_LINE, INT_MAX, NULL,
1549 &__kmp_align_alloc, 1);
1552 static void __kmp_stg_print_align_alloc(kmp_str_buf_t *buffer,
char const *name,
1554 __kmp_stg_print_size(buffer, name, __kmp_align_alloc);
1563 static void __kmp_stg_parse_barrier_branch_bit(
char const *name,
1564 char const *value,
void *data) {
1568 for (
int i = bs_plain_barrier; i < bs_last_barrier; i++) {
1569 var = __kmp_barrier_branch_bit_env_name[i];
1570 if ((strcmp(var, name) == 0) && (value != 0)) {
1573 comma = CCAST(
char *, strchr(value,
','));
1574 __kmp_barrier_gather_branch_bits[i] =
1575 (kmp_uint32)__kmp_str_to_int(value,
',');
1577 if (comma == NULL) {
1578 __kmp_barrier_release_branch_bits[i] = __kmp_barrier_release_bb_dflt;
1580 __kmp_barrier_release_branch_bits[i] =
1581 (kmp_uint32)__kmp_str_to_int(comma + 1, 0);
1583 if (__kmp_barrier_release_branch_bits[i] > KMP_MAX_BRANCH_BITS) {
1584 __kmp_msg(kmp_ms_warning,
1585 KMP_MSG(BarrReleaseValueInvalid, name, comma + 1),
1587 __kmp_barrier_release_branch_bits[i] = __kmp_barrier_release_bb_dflt;
1590 if (__kmp_barrier_gather_branch_bits[i] > KMP_MAX_BRANCH_BITS) {
1591 KMP_WARNING(BarrGatherValueInvalid, name, value);
1592 KMP_INFORM(Using_uint_Value, name, __kmp_barrier_gather_bb_dflt);
1593 __kmp_barrier_gather_branch_bits[i] = __kmp_barrier_gather_bb_dflt;
1596 K_DIAG(1, (
"%s == %d,%d\n", __kmp_barrier_branch_bit_env_name[i],
1597 __kmp_barrier_gather_branch_bits[i],
1598 __kmp_barrier_release_branch_bits[i]))
1602 static void __kmp_stg_print_barrier_branch_bit(kmp_str_buf_t *buffer,
1603 char const *name,
void *data) {
1605 for (
int i = bs_plain_barrier; i < bs_last_barrier; i++) {
1606 var = __kmp_barrier_branch_bit_env_name[i];
1607 if (strcmp(var, name) == 0) {
1608 if (__kmp_env_format) {
1609 KMP_STR_BUF_PRINT_NAME_EX(__kmp_barrier_branch_bit_env_name[i]);
1611 __kmp_str_buf_print(buffer,
" %s='",
1612 __kmp_barrier_branch_bit_env_name[i]);
1614 __kmp_str_buf_print(buffer,
"%d,%d'\n",
1615 __kmp_barrier_gather_branch_bits[i],
1616 __kmp_barrier_release_branch_bits[i]);
1628 static void __kmp_stg_parse_barrier_pattern(
char const *name,
char const *value,
1633 for (
int i = bs_plain_barrier; i < bs_last_barrier; i++) {
1634 var = __kmp_barrier_pattern_env_name[i];
1636 if ((strcmp(var, name) == 0) && (value != 0)) {
1638 char *comma = CCAST(
char *, strchr(value,
','));
1641 for (j = bp_linear_bar; j < bp_last_bar; j++) {
1642 if (__kmp_match_with_sentinel(__kmp_barrier_pattern_name[j], value, 1,
1644 __kmp_barrier_gather_pattern[i] = (kmp_bar_pat_e)j;
1648 if (j == bp_last_bar) {
1649 KMP_WARNING(BarrGatherValueInvalid, name, value);
1650 KMP_INFORM(Using_str_Value, name,
1651 __kmp_barrier_pattern_name[bp_linear_bar]);
1655 if (comma != NULL) {
1656 for (j = bp_linear_bar; j < bp_last_bar; j++) {
1657 if (__kmp_str_match(__kmp_barrier_pattern_name[j], 1, comma + 1)) {
1658 __kmp_barrier_release_pattern[i] = (kmp_bar_pat_e)j;
1662 if (j == bp_last_bar) {
1663 __kmp_msg(kmp_ms_warning,
1664 KMP_MSG(BarrReleaseValueInvalid, name, comma + 1),
1666 KMP_INFORM(Using_str_Value, name,
1667 __kmp_barrier_pattern_name[bp_linear_bar]);
1674 static void __kmp_stg_print_barrier_pattern(kmp_str_buf_t *buffer,
1675 char const *name,
void *data) {
1677 for (
int i = bs_plain_barrier; i < bs_last_barrier; i++) {
1678 var = __kmp_barrier_pattern_env_name[i];
1679 if (strcmp(var, name) == 0) {
1680 int j = __kmp_barrier_gather_pattern[i];
1681 int k = __kmp_barrier_release_pattern[i];
1682 if (__kmp_env_format) {
1683 KMP_STR_BUF_PRINT_NAME_EX(__kmp_barrier_pattern_env_name[i]);
1685 __kmp_str_buf_print(buffer,
" %s='",
1686 __kmp_barrier_pattern_env_name[i]);
1688 __kmp_str_buf_print(buffer,
"%s,%s'\n", __kmp_barrier_pattern_name[j],
1689 __kmp_barrier_pattern_name[k]);
1697 static void __kmp_stg_parse_abort_delay(
char const *name,
char const *value,
1701 int delay = __kmp_abort_delay / 1000;
1702 __kmp_stg_parse_int(name, value, 0, INT_MAX / 1000, &delay);
1703 __kmp_abort_delay = delay * 1000;
1706 static void __kmp_stg_print_abort_delay(kmp_str_buf_t *buffer,
char const *name,
1708 __kmp_stg_print_int(buffer, name, __kmp_abort_delay);
1714 static void __kmp_stg_parse_cpuinfo_file(
char const *name,
char const *value,
1716 #if KMP_AFFINITY_SUPPORTED
1717 __kmp_stg_parse_str(name, value, &__kmp_cpuinfo_file);
1718 K_DIAG(1, (
"__kmp_cpuinfo_file == %s\n", __kmp_cpuinfo_file));
1722 static void __kmp_stg_print_cpuinfo_file(kmp_str_buf_t *buffer,
1723 char const *name,
void *data) {
1724 #if KMP_AFFINITY_SUPPORTED
1725 if (__kmp_env_format) {
1726 KMP_STR_BUF_PRINT_NAME;
1728 __kmp_str_buf_print(buffer,
" %s", name);
1730 if (__kmp_cpuinfo_file) {
1731 __kmp_str_buf_print(buffer,
"='%s'\n", __kmp_cpuinfo_file);
1733 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
1741 static void __kmp_stg_parse_force_reduction(
char const *name,
char const *value,
1743 kmp_stg_fr_data_t *reduction = (kmp_stg_fr_data_t *)data;
1746 rc = __kmp_stg_check_rivals(name, value, reduction->rivals);
1750 if (reduction->force) {
1752 if (__kmp_str_match(
"critical", 0, value))
1753 __kmp_force_reduction_method = critical_reduce_block;
1754 else if (__kmp_str_match(
"atomic", 0, value))
1755 __kmp_force_reduction_method = atomic_reduce_block;
1756 else if (__kmp_str_match(
"tree", 0, value))
1757 __kmp_force_reduction_method = tree_reduce_block;
1759 KMP_FATAL(UnknownForceReduction, name, value);
1763 __kmp_stg_parse_bool(name, value, &__kmp_determ_red);
1764 if (__kmp_determ_red) {
1765 __kmp_force_reduction_method = tree_reduce_block;
1767 __kmp_force_reduction_method = reduction_method_not_defined;
1770 K_DIAG(1, (
"__kmp_force_reduction_method == %d\n",
1771 __kmp_force_reduction_method));
1774 static void __kmp_stg_print_force_reduction(kmp_str_buf_t *buffer,
1775 char const *name,
void *data) {
1777 kmp_stg_fr_data_t *reduction = (kmp_stg_fr_data_t *)data;
1778 if (reduction->force) {
1779 if (__kmp_force_reduction_method == critical_reduce_block) {
1780 __kmp_stg_print_str(buffer, name,
"critical");
1781 }
else if (__kmp_force_reduction_method == atomic_reduce_block) {
1782 __kmp_stg_print_str(buffer, name,
"atomic");
1783 }
else if (__kmp_force_reduction_method == tree_reduce_block) {
1784 __kmp_stg_print_str(buffer, name,
"tree");
1786 if (__kmp_env_format) {
1787 KMP_STR_BUF_PRINT_NAME;
1789 __kmp_str_buf_print(buffer,
" %s", name);
1791 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
1794 __kmp_stg_print_bool(buffer, name, __kmp_determ_red);
1802 static void __kmp_stg_parse_storage_map(
char const *name,
char const *value,
1804 if (__kmp_str_match(
"verbose", 1, value)) {
1805 __kmp_storage_map = TRUE;
1806 __kmp_storage_map_verbose = TRUE;
1807 __kmp_storage_map_verbose_specified = TRUE;
1810 __kmp_storage_map_verbose = FALSE;
1811 __kmp_stg_parse_bool(name, value, &__kmp_storage_map);
1815 static void __kmp_stg_print_storage_map(kmp_str_buf_t *buffer,
char const *name,
1817 if (__kmp_storage_map_verbose || __kmp_storage_map_verbose_specified) {
1818 __kmp_stg_print_str(buffer, name,
"verbose");
1820 __kmp_stg_print_bool(buffer, name, __kmp_storage_map);
1827 static void __kmp_stg_parse_all_threadprivate(
char const *name,
1828 char const *value,
void *data) {
1829 __kmp_stg_parse_int(name, value,
1830 __kmp_allThreadsSpecified ? __kmp_max_nth : 1,
1831 __kmp_max_nth, &__kmp_tp_capacity);
1834 static void __kmp_stg_print_all_threadprivate(kmp_str_buf_t *buffer,
1835 char const *name,
void *data) {
1836 __kmp_stg_print_int(buffer, name, __kmp_tp_capacity);
1842 static void __kmp_stg_parse_foreign_threads_threadprivate(
char const *name,
1845 __kmp_stg_parse_bool(name, value, &__kmp_foreign_tp);
1848 static void __kmp_stg_print_foreign_threads_threadprivate(kmp_str_buf_t *buffer,
1851 __kmp_stg_print_bool(buffer, name, __kmp_foreign_tp);
1857 #if KMP_AFFINITY_SUPPORTED
1859 static int __kmp_parse_affinity_proc_id_list(
const char *var,
const char *env,
1860 const char **nextEnv,
1862 const char *scan = env;
1863 const char *next = scan;
1869 int start, end, stride;
1873 if (*next ==
'\0') {
1884 if ((*next <
'0') || (*next >
'9')) {
1885 KMP_WARNING(AffSyntaxError, var);
1889 num = __kmp_str_to_int(scan, *next);
1890 KMP_ASSERT(num >= 0);
1908 if ((*next <
'0') || (*next >
'9')) {
1909 KMP_WARNING(AffSyntaxError, var);
1914 num = __kmp_str_to_int(scan, *next);
1915 KMP_ASSERT(num >= 0);
1928 if ((*next <
'0') || (*next >
'9')) {
1930 KMP_WARNING(AffSyntaxError, var);
1938 start = __kmp_str_to_int(scan, *next);
1939 KMP_ASSERT(start >= 0);
1958 if ((*next <
'0') || (*next >
'9')) {
1959 KMP_WARNING(AffSyntaxError, var);
1963 end = __kmp_str_to_int(scan, *next);
1964 KMP_ASSERT(end >= 0);
1981 if ((*next <
'0') || (*next >
'9')) {
1982 KMP_WARNING(AffSyntaxError, var);
1986 stride = __kmp_str_to_int(scan, *next);
1987 KMP_ASSERT(stride >= 0);
1993 KMP_WARNING(AffZeroStride, var);
1998 KMP_WARNING(AffStartGreaterEnd, var, start, end);
2003 KMP_WARNING(AffStrideLessZero, var, start, end);
2007 if ((end - start) / stride > 65536) {
2008 KMP_WARNING(AffRangeTooBig, var, end, start, stride);
2025 ptrdiff_t len = next - env;
2026 char *retlist = (
char *)__kmp_allocate((len + 1) *
sizeof(char));
2027 KMP_MEMCPY_S(retlist, (len + 1) *
sizeof(
char), env, len *
sizeof(
char));
2028 retlist[len] =
'\0';
2029 *proclist = retlist;
2036 static kmp_setting_t *__kmp_affinity_notype = NULL;
2038 static void __kmp_parse_affinity_env(
char const *name,
char const *value,
2039 enum affinity_type *out_type,
2040 char **out_proclist,
int *out_verbose,
2041 int *out_warn,
int *out_respect,
2042 enum affinity_gran *out_gran,
2043 int *out_gran_levels,
int *out_dups,
2044 int *out_compact,
int *out_offset) {
2045 char *buffer = NULL;
2061 KMP_ASSERT(value != NULL);
2063 if (TCR_4(__kmp_init_middle)) {
2064 KMP_WARNING(EnvMiddleWarn, name);
2065 __kmp_env_toPrint(name, 0);
2068 __kmp_env_toPrint(name, 1);
2071 __kmp_str_format(
"%s", value);
2081 #define EMIT_WARN(skip, errlist) \
2085 SKIP_TO(next, ','); \
2089 KMP_WARNING errlist; \
2098 #define _set_param(_guard, _var, _val) \
2100 if (_guard == 0) { \
2103 EMIT_WARN(FALSE, (AffParamDefined, name, start)); \
2108 #define set_type(val) _set_param(type, *out_type, val)
2109 #define set_verbose(val) _set_param(verbose, *out_verbose, val)
2110 #define set_warnings(val) _set_param(warnings, *out_warn, val)
2111 #define set_respect(val) _set_param(respect, *out_respect, val)
2112 #define set_dups(val) _set_param(dups, *out_dups, val)
2113 #define set_proclist(val) _set_param(proclist, *out_proclist, val)
2115 #define set_gran(val, levels) \
2119 *out_gran_levels = levels; \
2121 EMIT_WARN(FALSE, (AffParamDefined, name, start)); \
2126 KMP_DEBUG_ASSERT((__kmp_nested_proc_bind.bind_types != NULL) &&
2127 (__kmp_nested_proc_bind.used > 0));
2129 while (*buf !=
'\0') {
2132 if (__kmp_match_str(
"none", buf, CCAST(
const char **, &next))) {
2133 set_type(affinity_none);
2134 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
2136 }
else if (__kmp_match_str(
"scatter", buf, CCAST(
const char **, &next))) {
2137 set_type(affinity_scatter);
2138 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2140 }
else if (__kmp_match_str(
"compact", buf, CCAST(
const char **, &next))) {
2141 set_type(affinity_compact);
2142 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2144 }
else if (__kmp_match_str(
"logical", buf, CCAST(
const char **, &next))) {
2145 set_type(affinity_logical);
2146 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2148 }
else if (__kmp_match_str(
"physical", buf, CCAST(
const char **, &next))) {
2149 set_type(affinity_physical);
2150 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2152 }
else if (__kmp_match_str(
"explicit", buf, CCAST(
const char **, &next))) {
2153 set_type(affinity_explicit);
2154 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2156 }
else if (__kmp_match_str(
"balanced", buf, CCAST(
const char **, &next))) {
2157 set_type(affinity_balanced);
2158 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2160 }
else if (__kmp_match_str(
"disabled", buf, CCAST(
const char **, &next))) {
2161 set_type(affinity_disabled);
2162 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
2164 }
else if (__kmp_match_str(
"verbose", buf, CCAST(
const char **, &next))) {
2167 }
else if (__kmp_match_str(
"noverbose", buf, CCAST(
const char **, &next))) {
2170 }
else if (__kmp_match_str(
"warnings", buf, CCAST(
const char **, &next))) {
2173 }
else if (__kmp_match_str(
"nowarnings", buf,
2174 CCAST(
const char **, &next))) {
2175 set_warnings(FALSE);
2177 }
else if (__kmp_match_str(
"respect", buf, CCAST(
const char **, &next))) {
2180 }
else if (__kmp_match_str(
"norespect", buf, CCAST(
const char **, &next))) {
2183 }
else if (__kmp_match_str(
"duplicates", buf,
2184 CCAST(
const char **, &next)) ||
2185 __kmp_match_str(
"dups", buf, CCAST(
const char **, &next))) {
2188 }
else if (__kmp_match_str(
"noduplicates", buf,
2189 CCAST(
const char **, &next)) ||
2190 __kmp_match_str(
"nodups", buf, CCAST(
const char **, &next))) {
2193 }
else if (__kmp_match_str(
"granularity", buf,
2194 CCAST(
const char **, &next)) ||
2195 __kmp_match_str(
"gran", buf, CCAST(
const char **, &next))) {
2198 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2205 if (__kmp_match_str(
"fine", buf, CCAST(
const char **, &next))) {
2206 set_gran(affinity_gran_fine, -1);
2208 }
else if (__kmp_match_str(
"thread", buf, CCAST(
const char **, &next))) {
2209 set_gran(affinity_gran_thread, -1);
2211 }
else if (__kmp_match_str(
"core", buf, CCAST(
const char **, &next))) {
2212 set_gran(affinity_gran_core, -1);
2215 }
else if (__kmp_match_str(
"tile", buf, CCAST(
const char **, &next))) {
2216 set_gran(affinity_gran_tile, -1);
2219 }
else if (__kmp_match_str(
"die", buf, CCAST(
const char **, &next))) {
2220 set_gran(affinity_gran_die, -1);
2222 }
else if (__kmp_match_str(
"package", buf, CCAST(
const char **, &next))) {
2223 set_gran(affinity_gran_package, -1);
2225 }
else if (__kmp_match_str(
"node", buf, CCAST(
const char **, &next))) {
2226 set_gran(affinity_gran_node, -1);
2228 #if KMP_GROUP_AFFINITY
2229 }
else if (__kmp_match_str(
"group", buf, CCAST(
const char **, &next))) {
2230 set_gran(affinity_gran_group, -1);
2233 }
else if ((*buf >=
'0') && (*buf <=
'9')) {
2237 n = __kmp_str_to_int(buf, *next);
2240 set_gran(affinity_gran_default, n);
2242 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2245 }
else if (__kmp_match_str(
"proclist", buf, CCAST(
const char **, &next))) {
2246 char *temp_proclist;
2250 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2256 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2261 if (!__kmp_parse_affinity_proc_id_list(
2262 name, buf, CCAST(
const char **, &next), &temp_proclist)) {
2274 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2278 set_proclist(temp_proclist);
2279 }
else if ((*buf >=
'0') && (*buf <=
'9')) {
2284 n = __kmp_str_to_int(buf, *next);
2290 KMP_WARNING(AffManyParams, name, start);
2294 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2302 }
else if (*next !=
'\0') {
2303 const char *temp = next;
2304 EMIT_WARN(TRUE, (ParseExtraCharsWarn, name, temp));
2316 #undef set_granularity
2318 __kmp_str_free(&buffer);
2322 KMP_WARNING(AffProcListNoType, name);
2323 *out_type = affinity_explicit;
2324 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2325 }
else if (*out_type != affinity_explicit) {
2326 KMP_WARNING(AffProcListNotExplicit, name);
2327 KMP_ASSERT(*out_proclist != NULL);
2328 KMP_INTERNAL_FREE(*out_proclist);
2329 *out_proclist = NULL;
2332 switch (*out_type) {
2333 case affinity_logical:
2334 case affinity_physical: {
2336 *out_offset = number[0];
2339 KMP_WARNING(AffManyParamsForLogic, name, number[1]);
2342 case affinity_balanced: {
2344 *out_compact = number[0];
2347 *out_offset = number[1];
2350 if (__kmp_affinity_gran == affinity_gran_default) {
2351 #if KMP_MIC_SUPPORTED
2352 if (__kmp_mic_type != non_mic) {
2353 if (__kmp_affinity_verbose || __kmp_affinity_warnings) {
2354 KMP_WARNING(AffGranUsing,
"KMP_AFFINITY",
"fine");
2356 __kmp_affinity_gran = affinity_gran_fine;
2360 if (__kmp_affinity_verbose || __kmp_affinity_warnings) {
2361 KMP_WARNING(AffGranUsing,
"KMP_AFFINITY",
"core");
2363 __kmp_affinity_gran = affinity_gran_core;
2367 case affinity_scatter:
2368 case affinity_compact: {
2370 *out_compact = number[0];
2373 *out_offset = number[1];
2376 case affinity_explicit: {
2377 if (*out_proclist == NULL) {
2378 KMP_WARNING(AffNoProcList, name);
2379 __kmp_affinity_type = affinity_none;
2382 KMP_WARNING(AffNoParam, name,
"explicit");
2385 case affinity_none: {
2387 KMP_WARNING(AffNoParam, name,
"none");
2390 case affinity_disabled: {
2392 KMP_WARNING(AffNoParam, name,
"disabled");
2395 case affinity_default: {
2397 KMP_WARNING(AffNoParam, name,
"default");
2400 default: { KMP_ASSERT(0); }
2404 static void __kmp_stg_parse_affinity(
char const *name,
char const *value,
2406 kmp_setting_t **rivals = (kmp_setting_t **)data;
2409 rc = __kmp_stg_check_rivals(name, value, rivals);
2414 __kmp_parse_affinity_env(name, value, &__kmp_affinity_type,
2415 &__kmp_affinity_proclist, &__kmp_affinity_verbose,
2416 &__kmp_affinity_warnings,
2417 &__kmp_affinity_respect_mask, &__kmp_affinity_gran,
2418 &__kmp_affinity_gran_levels, &__kmp_affinity_dups,
2419 &__kmp_affinity_compact, &__kmp_affinity_offset);
2423 static void __kmp_stg_print_affinity(kmp_str_buf_t *buffer,
char const *name,
2425 if (__kmp_env_format) {
2426 KMP_STR_BUF_PRINT_NAME_EX(name);
2428 __kmp_str_buf_print(buffer,
" %s='", name);
2430 if (__kmp_affinity_verbose) {
2431 __kmp_str_buf_print(buffer,
"%s,",
"verbose");
2433 __kmp_str_buf_print(buffer,
"%s,",
"noverbose");
2435 if (__kmp_affinity_warnings) {
2436 __kmp_str_buf_print(buffer,
"%s,",
"warnings");
2438 __kmp_str_buf_print(buffer,
"%s,",
"nowarnings");
2440 if (KMP_AFFINITY_CAPABLE()) {
2441 if (__kmp_affinity_respect_mask) {
2442 __kmp_str_buf_print(buffer,
"%s,",
"respect");
2444 __kmp_str_buf_print(buffer,
"%s,",
"norespect");
2446 switch (__kmp_affinity_gran) {
2447 case affinity_gran_default:
2448 __kmp_str_buf_print(buffer,
"%s",
"granularity=default,");
2450 case affinity_gran_fine:
2451 __kmp_str_buf_print(buffer,
"%s",
"granularity=fine,");
2453 case affinity_gran_thread:
2454 __kmp_str_buf_print(buffer,
"%s",
"granularity=thread,");
2456 case affinity_gran_core:
2457 __kmp_str_buf_print(buffer,
"%s",
"granularity=core,");
2459 case affinity_gran_package:
2460 __kmp_str_buf_print(buffer,
"%s",
"granularity=package,");
2462 case affinity_gran_node:
2463 __kmp_str_buf_print(buffer,
"%s",
"granularity=node,");
2465 #if KMP_GROUP_AFFINITY
2466 case affinity_gran_group:
2467 __kmp_str_buf_print(buffer,
"%s",
"granularity=group,");
2472 if (!KMP_AFFINITY_CAPABLE()) {
2473 __kmp_str_buf_print(buffer,
"%s",
"disabled");
2475 switch (__kmp_affinity_type) {
2477 __kmp_str_buf_print(buffer,
"%s",
"none");
2479 case affinity_physical:
2480 __kmp_str_buf_print(buffer,
"%s,%d",
"physical", __kmp_affinity_offset);
2482 case affinity_logical:
2483 __kmp_str_buf_print(buffer,
"%s,%d",
"logical", __kmp_affinity_offset);
2485 case affinity_compact:
2486 __kmp_str_buf_print(buffer,
"%s,%d,%d",
"compact", __kmp_affinity_compact,
2487 __kmp_affinity_offset);
2489 case affinity_scatter:
2490 __kmp_str_buf_print(buffer,
"%s,%d,%d",
"scatter", __kmp_affinity_compact,
2491 __kmp_affinity_offset);
2493 case affinity_explicit:
2494 __kmp_str_buf_print(buffer,
"%s=[%s],%s",
"proclist",
2495 __kmp_affinity_proclist,
"explicit");
2497 case affinity_balanced:
2498 __kmp_str_buf_print(buffer,
"%s,%d,%d",
"balanced",
2499 __kmp_affinity_compact, __kmp_affinity_offset);
2501 case affinity_disabled:
2502 __kmp_str_buf_print(buffer,
"%s",
"disabled");
2504 case affinity_default:
2505 __kmp_str_buf_print(buffer,
"%s",
"default");
2508 __kmp_str_buf_print(buffer,
"%s",
"<unknown>");
2511 __kmp_str_buf_print(buffer,
"'\n");
2514 #ifdef KMP_GOMP_COMPAT
2516 static void __kmp_stg_parse_gomp_cpu_affinity(
char const *name,
2517 char const *value,
void *data) {
2518 const char *next = NULL;
2519 char *temp_proclist;
2520 kmp_setting_t **rivals = (kmp_setting_t **)data;
2523 rc = __kmp_stg_check_rivals(name, value, rivals);
2528 if (TCR_4(__kmp_init_middle)) {
2529 KMP_WARNING(EnvMiddleWarn, name);
2530 __kmp_env_toPrint(name, 0);
2534 __kmp_env_toPrint(name, 1);
2536 if (__kmp_parse_affinity_proc_id_list(name, value, &next, &temp_proclist)) {
2538 if (*next ==
'\0') {
2540 __kmp_affinity_proclist = temp_proclist;
2541 __kmp_affinity_type = affinity_explicit;
2542 __kmp_affinity_gran = affinity_gran_fine;
2543 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2545 KMP_WARNING(AffSyntaxError, name);
2546 if (temp_proclist != NULL) {
2547 KMP_INTERNAL_FREE((
void *)temp_proclist);
2552 __kmp_affinity_type = affinity_none;
2553 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
2580 static inline void __kmp_omp_places_syntax_warn(
const char *var) {
2581 KMP_WARNING(SyntaxErrorUsing, var,
"\"cores\"");
2584 static int __kmp_parse_subplace_list(
const char *var,
const char **scan) {
2588 int start, count, stride;
2594 if ((**scan <
'0') || (**scan >
'9')) {
2595 __kmp_omp_places_syntax_warn(var);
2600 start = __kmp_str_to_int(*scan, *next);
2601 KMP_ASSERT(start >= 0);
2606 if (**scan ==
'}') {
2609 if (**scan ==
',') {
2613 if (**scan !=
':') {
2614 __kmp_omp_places_syntax_warn(var);
2621 if ((**scan <
'0') || (**scan >
'9')) {
2622 __kmp_omp_places_syntax_warn(var);
2627 count = __kmp_str_to_int(*scan, *next);
2628 KMP_ASSERT(count >= 0);
2633 if (**scan ==
'}') {
2636 if (**scan ==
',') {
2640 if (**scan !=
':') {
2641 __kmp_omp_places_syntax_warn(var);
2650 if (**scan ==
'+') {
2654 if (**scan ==
'-') {
2662 if ((**scan <
'0') || (**scan >
'9')) {
2663 __kmp_omp_places_syntax_warn(var);
2668 stride = __kmp_str_to_int(*scan, *next);
2669 KMP_ASSERT(stride >= 0);
2675 if (**scan ==
'}') {
2678 if (**scan ==
',') {
2683 __kmp_omp_places_syntax_warn(var);
2689 static int __kmp_parse_place(
const char *var,
const char **scan) {
2694 if (**scan ==
'{') {
2696 if (!__kmp_parse_subplace_list(var, scan)) {
2699 if (**scan !=
'}') {
2700 __kmp_omp_places_syntax_warn(var);
2704 }
else if (**scan ==
'!') {
2706 return __kmp_parse_place(var, scan);
2707 }
else if ((**scan >=
'0') && (**scan <=
'9')) {
2710 int proc = __kmp_str_to_int(*scan, *next);
2711 KMP_ASSERT(proc >= 0);
2714 __kmp_omp_places_syntax_warn(var);
2720 static int __kmp_parse_place_list(
const char *var,
const char *env,
2721 char **place_list) {
2722 const char *scan = env;
2723 const char *next = scan;
2728 if (!__kmp_parse_place(var, &scan)) {
2734 if (*scan ==
'\0') {
2742 __kmp_omp_places_syntax_warn(var);
2749 if ((*scan <
'0') || (*scan >
'9')) {
2750 __kmp_omp_places_syntax_warn(var);
2755 count = __kmp_str_to_int(scan, *next);
2756 KMP_ASSERT(count >= 0);
2761 if (*scan ==
'\0') {
2769 __kmp_omp_places_syntax_warn(var);
2790 if ((*scan <
'0') || (*scan >
'9')) {
2791 __kmp_omp_places_syntax_warn(var);
2796 stride = __kmp_str_to_int(scan, *next);
2797 KMP_ASSERT(stride >= 0);
2803 if (*scan ==
'\0') {
2811 __kmp_omp_places_syntax_warn(var);
2816 ptrdiff_t len = scan - env;
2817 char *retlist = (
char *)__kmp_allocate((len + 1) *
sizeof(char));
2818 KMP_MEMCPY_S(retlist, (len + 1) *
sizeof(
char), env, len *
sizeof(
char));
2819 retlist[len] =
'\0';
2820 *place_list = retlist;
2825 static void __kmp_stg_parse_places(
char const *name,
char const *value,
2828 const char *scan = value;
2829 const char *next = scan;
2830 const char *kind =
"\"threads\"";
2831 kmp_setting_t **rivals = (kmp_setting_t **)data;
2834 rc = __kmp_stg_check_rivals(name, value, rivals);
2839 if (__kmp_match_str(
"threads", scan, &next)) {
2841 __kmp_affinity_type = affinity_compact;
2842 __kmp_affinity_gran = affinity_gran_thread;
2843 __kmp_affinity_dups = FALSE;
2844 kind =
"\"threads\"";
2845 }
else if (__kmp_match_str(
"cores", scan, &next)) {
2847 __kmp_affinity_type = affinity_compact;
2848 __kmp_affinity_gran = affinity_gran_core;
2849 __kmp_affinity_dups = FALSE;
2852 }
else if (__kmp_match_str(
"tiles", scan, &next)) {
2854 __kmp_affinity_type = affinity_compact;
2855 __kmp_affinity_gran = affinity_gran_tile;
2856 __kmp_affinity_dups = FALSE;
2859 }
else if (__kmp_match_str(
"dice", scan, &next) ||
2860 __kmp_match_str(
"dies", scan, &next)) {
2862 __kmp_affinity_type = affinity_compact;
2863 __kmp_affinity_gran = affinity_gran_die;
2864 __kmp_affinity_dups = FALSE;
2866 }
else if (__kmp_match_str(
"sockets", scan, &next)) {
2868 __kmp_affinity_type = affinity_compact;
2869 __kmp_affinity_gran = affinity_gran_package;
2870 __kmp_affinity_dups = FALSE;
2871 kind =
"\"sockets\"";
2873 if (__kmp_affinity_proclist != NULL) {
2874 KMP_INTERNAL_FREE((
void *)__kmp_affinity_proclist);
2875 __kmp_affinity_proclist = NULL;
2877 if (__kmp_parse_place_list(name, value, &__kmp_affinity_proclist)) {
2878 __kmp_affinity_type = affinity_explicit;
2879 __kmp_affinity_gran = affinity_gran_fine;
2880 __kmp_affinity_dups = FALSE;
2883 __kmp_affinity_type = affinity_compact;
2884 __kmp_affinity_gran = affinity_gran_core;
2885 __kmp_affinity_dups = FALSE;
2887 if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_default) {
2888 __kmp_nested_proc_bind.bind_types[0] = proc_bind_true;
2893 if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_default) {
2894 __kmp_nested_proc_bind.bind_types[0] = proc_bind_true;
2898 if (*scan ==
'\0') {
2904 KMP_WARNING(SyntaxErrorUsing, name, kind);
2912 count = __kmp_str_to_int(scan, *next);
2913 KMP_ASSERT(count >= 0);
2918 KMP_WARNING(SyntaxErrorUsing, name, kind);
2924 if (*scan !=
'\0') {
2925 KMP_WARNING(ParseExtraCharsWarn, name, scan);
2927 __kmp_affinity_num_places = count;
2930 static void __kmp_stg_print_places(kmp_str_buf_t *buffer,
char const *name,
2932 if (__kmp_env_format) {
2933 KMP_STR_BUF_PRINT_NAME;
2935 __kmp_str_buf_print(buffer,
" %s", name);
2937 if ((__kmp_nested_proc_bind.used == 0) ||
2938 (__kmp_nested_proc_bind.bind_types == NULL) ||
2939 (__kmp_nested_proc_bind.bind_types[0] == proc_bind_false)) {
2940 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
2941 }
else if (__kmp_affinity_type == affinity_explicit) {
2942 if (__kmp_affinity_proclist != NULL) {
2943 __kmp_str_buf_print(buffer,
"='%s'\n", __kmp_affinity_proclist);
2945 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
2947 }
else if (__kmp_affinity_type == affinity_compact) {
2949 if (__kmp_affinity_num_masks > 0) {
2950 num = __kmp_affinity_num_masks;
2951 }
else if (__kmp_affinity_num_places > 0) {
2952 num = __kmp_affinity_num_places;
2956 if (__kmp_affinity_gran == affinity_gran_thread) {
2958 __kmp_str_buf_print(buffer,
"='threads(%d)'\n", num);
2960 __kmp_str_buf_print(buffer,
"='threads'\n");
2962 }
else if (__kmp_affinity_gran == affinity_gran_core) {
2964 __kmp_str_buf_print(buffer,
"='cores(%d)' \n", num);
2966 __kmp_str_buf_print(buffer,
"='cores'\n");
2969 }
else if (__kmp_affinity_gran == affinity_gran_tile) {
2971 __kmp_str_buf_print(buffer,
"='tiles(%d)' \n", num);
2973 __kmp_str_buf_print(buffer,
"='tiles'\n");
2976 }
else if (__kmp_affinity_gran == affinity_gran_package) {
2978 __kmp_str_buf_print(buffer,
"='sockets(%d)'\n", num);
2980 __kmp_str_buf_print(buffer,
"='sockets'\n");
2983 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
2986 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
2990 static void __kmp_stg_parse_topology_method(
char const *name,
char const *value,
2992 if (__kmp_str_match(
"all", 1, value)) {
2993 __kmp_affinity_top_method = affinity_top_method_all;
2996 else if (__kmp_str_match(
"hwloc", 1, value)) {
2997 __kmp_affinity_top_method = affinity_top_method_hwloc;
3000 #if KMP_ARCH_X86 || KMP_ARCH_X86_64
3001 else if (__kmp_str_match(
"cpuid_leaf31", 12, value) ||
3002 __kmp_str_match(
"cpuid 1f", 8, value) ||
3003 __kmp_str_match(
"cpuid 31", 8, value) ||
3004 __kmp_str_match(
"cpuid1f", 7, value) ||
3005 __kmp_str_match(
"cpuid31", 7, value) ||
3006 __kmp_str_match(
"leaf 1f", 7, value) ||
3007 __kmp_str_match(
"leaf 31", 7, value) ||
3008 __kmp_str_match(
"leaf1f", 6, value) ||
3009 __kmp_str_match(
"leaf31", 6, value)) {
3010 __kmp_affinity_top_method = affinity_top_method_x2apicid_1f;
3011 }
else if (__kmp_str_match(
"x2apic id", 9, value) ||
3012 __kmp_str_match(
"x2apic_id", 9, value) ||
3013 __kmp_str_match(
"x2apic-id", 9, value) ||
3014 __kmp_str_match(
"x2apicid", 8, value) ||
3015 __kmp_str_match(
"cpuid leaf 11", 13, value) ||
3016 __kmp_str_match(
"cpuid_leaf_11", 13, value) ||
3017 __kmp_str_match(
"cpuid-leaf-11", 13, value) ||
3018 __kmp_str_match(
"cpuid leaf11", 12, value) ||
3019 __kmp_str_match(
"cpuid_leaf11", 12, value) ||
3020 __kmp_str_match(
"cpuid-leaf11", 12, value) ||
3021 __kmp_str_match(
"cpuidleaf 11", 12, value) ||
3022 __kmp_str_match(
"cpuidleaf_11", 12, value) ||
3023 __kmp_str_match(
"cpuidleaf-11", 12, value) ||
3024 __kmp_str_match(
"cpuidleaf11", 11, value) ||
3025 __kmp_str_match(
"cpuid 11", 8, value) ||
3026 __kmp_str_match(
"cpuid_11", 8, value) ||
3027 __kmp_str_match(
"cpuid-11", 8, value) ||
3028 __kmp_str_match(
"cpuid11", 7, value) ||
3029 __kmp_str_match(
"leaf 11", 7, value) ||
3030 __kmp_str_match(
"leaf_11", 7, value) ||
3031 __kmp_str_match(
"leaf-11", 7, value) ||
3032 __kmp_str_match(
"leaf11", 6, value)) {
3033 __kmp_affinity_top_method = affinity_top_method_x2apicid;
3034 }
else if (__kmp_str_match(
"apic id", 7, value) ||
3035 __kmp_str_match(
"apic_id", 7, value) ||
3036 __kmp_str_match(
"apic-id", 7, value) ||
3037 __kmp_str_match(
"apicid", 6, value) ||
3038 __kmp_str_match(
"cpuid leaf 4", 12, value) ||
3039 __kmp_str_match(
"cpuid_leaf_4", 12, value) ||
3040 __kmp_str_match(
"cpuid-leaf-4", 12, value) ||
3041 __kmp_str_match(
"cpuid leaf4", 11, value) ||
3042 __kmp_str_match(
"cpuid_leaf4", 11, value) ||
3043 __kmp_str_match(
"cpuid-leaf4", 11, value) ||
3044 __kmp_str_match(
"cpuidleaf 4", 11, value) ||
3045 __kmp_str_match(
"cpuidleaf_4", 11, value) ||
3046 __kmp_str_match(
"cpuidleaf-4", 11, value) ||
3047 __kmp_str_match(
"cpuidleaf4", 10, value) ||
3048 __kmp_str_match(
"cpuid 4", 7, value) ||
3049 __kmp_str_match(
"cpuid_4", 7, value) ||
3050 __kmp_str_match(
"cpuid-4", 7, value) ||
3051 __kmp_str_match(
"cpuid4", 6, value) ||
3052 __kmp_str_match(
"leaf 4", 6, value) ||
3053 __kmp_str_match(
"leaf_4", 6, value) ||
3054 __kmp_str_match(
"leaf-4", 6, value) ||
3055 __kmp_str_match(
"leaf4", 5, value)) {
3056 __kmp_affinity_top_method = affinity_top_method_apicid;
3059 else if (__kmp_str_match(
"/proc/cpuinfo", 2, value) ||
3060 __kmp_str_match(
"cpuinfo", 5, value)) {
3061 __kmp_affinity_top_method = affinity_top_method_cpuinfo;
3063 #if KMP_GROUP_AFFINITY
3064 else if (__kmp_str_match(
"group", 1, value)) {
3065 __kmp_affinity_top_method = affinity_top_method_group;
3068 else if (__kmp_str_match(
"flat", 1, value)) {
3069 __kmp_affinity_top_method = affinity_top_method_flat;
3071 KMP_WARNING(StgInvalidValue, name, value);
3075 static void __kmp_stg_print_topology_method(kmp_str_buf_t *buffer,
3076 char const *name,
void *data) {
3077 char const *value = NULL;
3079 switch (__kmp_affinity_top_method) {
3080 case affinity_top_method_default:
3084 case affinity_top_method_all:
3088 #if KMP_ARCH_X86 || KMP_ARCH_X86_64
3089 case affinity_top_method_x2apicid:
3090 value =
"x2APIC id";
3093 case affinity_top_method_apicid:
3099 case affinity_top_method_hwloc:
3104 case affinity_top_method_cpuinfo:
3108 #if KMP_GROUP_AFFINITY
3109 case affinity_top_method_group:
3114 case affinity_top_method_flat:
3119 if (value != NULL) {
3120 __kmp_stg_print_str(buffer, name, value);
3128 static void __kmp_stg_parse_proc_bind(
char const *name,
char const *value,
3130 kmp_setting_t **rivals = (kmp_setting_t **)data;
3133 rc = __kmp_stg_check_rivals(name, value, rivals);
3139 KMP_DEBUG_ASSERT((__kmp_nested_proc_bind.bind_types != NULL) &&
3140 (__kmp_nested_proc_bind.used > 0));
3142 const char *buf = value;
3146 if ((*buf >=
'0') && (*buf <=
'9')) {
3149 num = __kmp_str_to_int(buf, *next);
3150 KMP_ASSERT(num >= 0);
3158 if (__kmp_match_str(
"disabled", buf, &next)) {
3161 #if KMP_AFFINITY_SUPPORTED
3162 __kmp_affinity_type = affinity_disabled;
3164 __kmp_nested_proc_bind.used = 1;
3165 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
3166 }
else if ((num == (
int)proc_bind_false) ||
3167 __kmp_match_str(
"false", buf, &next)) {
3170 #if KMP_AFFINITY_SUPPORTED
3171 __kmp_affinity_type = affinity_none;
3173 __kmp_nested_proc_bind.used = 1;
3174 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
3175 }
else if ((num == (
int)proc_bind_true) ||
3176 __kmp_match_str(
"true", buf, &next)) {
3179 __kmp_nested_proc_bind.used = 1;
3180 __kmp_nested_proc_bind.bind_types[0] = proc_bind_true;
3185 for (scan = buf; *scan !=
'\0'; scan++) {
3192 if (__kmp_nested_proc_bind.size < nelem) {
3193 __kmp_nested_proc_bind.bind_types =
3194 (kmp_proc_bind_t *)KMP_INTERNAL_REALLOC(
3195 __kmp_nested_proc_bind.bind_types,
3196 sizeof(kmp_proc_bind_t) * nelem);
3197 if (__kmp_nested_proc_bind.bind_types == NULL) {
3198 KMP_FATAL(MemoryAllocFailed);
3200 __kmp_nested_proc_bind.size = nelem;
3202 __kmp_nested_proc_bind.used = nelem;
3204 if (nelem > 1 && !__kmp_dflt_max_active_levels_set)
3205 __kmp_dflt_max_active_levels = KMP_MAX_ACTIVE_LEVELS_LIMIT;
3210 enum kmp_proc_bind_t bind;
3212 if ((num == (
int)proc_bind_master) ||
3213 __kmp_match_str(
"master", buf, &next)) {
3216 bind = proc_bind_master;
3217 }
else if ((num == (
int)proc_bind_close) ||
3218 __kmp_match_str(
"close", buf, &next)) {
3221 bind = proc_bind_close;
3222 }
else if ((num == (
int)proc_bind_spread) ||
3223 __kmp_match_str(
"spread", buf, &next)) {
3226 bind = proc_bind_spread;
3228 KMP_WARNING(StgInvalidValue, name, value);
3229 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
3230 __kmp_nested_proc_bind.used = 1;
3234 __kmp_nested_proc_bind.bind_types[i++] = bind;
3238 KMP_DEBUG_ASSERT(*buf ==
',');
3243 if ((*buf >=
'0') && (*buf <=
'9')) {
3246 num = __kmp_str_to_int(buf, *next);
3247 KMP_ASSERT(num >= 0);
3257 KMP_WARNING(ParseExtraCharsWarn, name, buf);
3261 static void __kmp_stg_print_proc_bind(kmp_str_buf_t *buffer,
char const *name,
3263 int nelem = __kmp_nested_proc_bind.used;
3264 if (__kmp_env_format) {
3265 KMP_STR_BUF_PRINT_NAME;
3267 __kmp_str_buf_print(buffer,
" %s", name);
3270 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
3273 __kmp_str_buf_print(buffer,
"='", name);
3274 for (i = 0; i < nelem; i++) {
3275 switch (__kmp_nested_proc_bind.bind_types[i]) {
3276 case proc_bind_false:
3277 __kmp_str_buf_print(buffer,
"false");
3280 case proc_bind_true:
3281 __kmp_str_buf_print(buffer,
"true");
3284 case proc_bind_master:
3285 __kmp_str_buf_print(buffer,
"master");
3288 case proc_bind_close:
3289 __kmp_str_buf_print(buffer,
"close");
3292 case proc_bind_spread:
3293 __kmp_str_buf_print(buffer,
"spread");
3296 case proc_bind_intel:
3297 __kmp_str_buf_print(buffer,
"intel");
3300 case proc_bind_default:
3301 __kmp_str_buf_print(buffer,
"default");
3304 if (i < nelem - 1) {
3305 __kmp_str_buf_print(buffer,
",");
3308 __kmp_str_buf_print(buffer,
"'\n");
3312 static void __kmp_stg_parse_display_affinity(
char const *name,
3313 char const *value,
void *data) {
3314 __kmp_stg_parse_bool(name, value, &__kmp_display_affinity);
3316 static void __kmp_stg_print_display_affinity(kmp_str_buf_t *buffer,
3317 char const *name,
void *data) {
3318 __kmp_stg_print_bool(buffer, name, __kmp_display_affinity);
3320 static void __kmp_stg_parse_affinity_format(
char const *name,
char const *value,
3322 size_t length = KMP_STRLEN(value);
3323 __kmp_strncpy_truncate(__kmp_affinity_format, KMP_AFFINITY_FORMAT_SIZE, value,
3326 static void __kmp_stg_print_affinity_format(kmp_str_buf_t *buffer,
3327 char const *name,
void *data) {
3328 if (__kmp_env_format) {
3329 KMP_STR_BUF_PRINT_NAME_EX(name);
3331 __kmp_str_buf_print(buffer,
" %s='", name);
3333 __kmp_str_buf_print(buffer,
"%s'\n", __kmp_affinity_format);
3355 static void __kmp_stg_parse_allocator(
char const *name,
char const *value,
3357 const char *buf = value;
3358 const char *next, *scan, *start;
3360 omp_allocator_handle_t al;
3361 omp_memspace_handle_t ms = omp_default_mem_space;
3362 bool is_memspace =
false;
3363 int ntraits = 0, count = 0;
3367 const char *delim = strchr(buf,
':');
3368 const char *predef_mem_space = strstr(buf,
"mem_space");
3370 bool is_memalloc = (!predef_mem_space && !delim) ?
true :
false;
3375 for (scan = buf; *scan !=
'\0'; scan++) {
3380 omp_alloctrait_t *traits =
3381 (omp_alloctrait_t *)KMP_ALLOCA(ntraits *
sizeof(omp_alloctrait_t));
3384 #define IS_POWER_OF_TWO(n) (((n) & ((n)-1)) == 0)
3386 #define GET_NEXT(sentinel) \
3389 if (*next == sentinel) \
3395 #define SKIP_PAIR(key) \
3397 char const str_delimiter[] = {',', 0}; \
3398 char *value = __kmp_str_token(CCAST(char *, scan), str_delimiter, \
3399 CCAST(char **, &next)); \
3400 KMP_WARNING(StgInvalidValue, key, value); \
3408 char const str_delimiter[] = {'=', 0}; \
3409 key = __kmp_str_token(CCAST(char *, start), str_delimiter, \
3410 CCAST(char **, &next)); \
3415 while (*next !=
'\0') {
3417 __kmp_match_str(
"fb_data", scan, &next)) {
3421 if (__kmp_match_str(
"omp_high_bw_mem_alloc", scan, &next)) {
3424 if (__kmp_memkind_available) {
3425 __kmp_def_allocator = omp_high_bw_mem_alloc;
3428 KMP_WARNING(OmpNoAllocator,
"omp_high_bw_mem_alloc");
3431 traits[count].key = omp_atk_fb_data;
3432 traits[count].value = RCAST(omp_uintptr_t, omp_high_bw_mem_alloc);
3434 }
else if (__kmp_match_str(
"omp_large_cap_mem_alloc", scan, &next)) {
3437 if (__kmp_memkind_available) {
3438 __kmp_def_allocator = omp_large_cap_mem_alloc;
3441 KMP_WARNING(OmpNoAllocator,
"omp_large_cap_mem_alloc");
3444 traits[count].key = omp_atk_fb_data;
3445 traits[count].value = RCAST(omp_uintptr_t, omp_large_cap_mem_alloc);
3447 }
else if (__kmp_match_str(
"omp_default_mem_alloc", scan, &next)) {
3451 traits[count].key = omp_atk_fb_data;
3452 traits[count].value = RCAST(omp_uintptr_t, omp_default_mem_alloc);
3454 }
else if (__kmp_match_str(
"omp_const_mem_alloc", scan, &next)) {
3457 KMP_WARNING(OmpNoAllocator,
"omp_const_mem_alloc");
3459 traits[count].key = omp_atk_fb_data;
3460 traits[count].value = RCAST(omp_uintptr_t, omp_const_mem_alloc);
3462 }
else if (__kmp_match_str(
"omp_low_lat_mem_alloc", scan, &next)) {
3465 KMP_WARNING(OmpNoAllocator,
"omp_low_lat_mem_alloc");
3467 traits[count].key = omp_atk_fb_data;
3468 traits[count].value = RCAST(omp_uintptr_t, omp_low_lat_mem_alloc);
3470 }
else if (__kmp_match_str(
"omp_cgroup_mem_alloc", scan, &next)) {
3473 KMP_WARNING(OmpNoAllocator,
"omp_cgroup_mem_alloc");
3475 traits[count].key = omp_atk_fb_data;
3476 traits[count].value = RCAST(omp_uintptr_t, omp_cgroup_mem_alloc);
3478 }
else if (__kmp_match_str(
"omp_pteam_mem_alloc", scan, &next)) {
3481 KMP_WARNING(OmpNoAllocator,
"omp_pteam_mem_alloc");
3483 traits[count].key = omp_atk_fb_data;
3484 traits[count].value = RCAST(omp_uintptr_t, omp_pteam_mem_alloc);
3486 }
else if (__kmp_match_str(
"omp_thread_mem_alloc", scan, &next)) {
3489 KMP_WARNING(OmpNoAllocator,
"omp_thread_mem_alloc");
3491 traits[count].key = omp_atk_fb_data;
3492 traits[count].value = RCAST(omp_uintptr_t, omp_thread_mem_alloc);
3502 __kmp_def_allocator = omp_default_mem_alloc;
3503 if (next == buf || *next !=
'\0') {
3505 KMP_WARNING(StgInvalidValue, name, value);
3510 if (count == ntraits)
3516 if (__kmp_match_str(
"omp_default_mem_space", scan, &next)) {
3518 ms = omp_default_mem_space;
3519 }
else if (__kmp_match_str(
"omp_large_cap_mem_space", scan, &next)) {
3521 ms = omp_large_cap_mem_space;
3522 }
else if (__kmp_match_str(
"omp_const_mem_space", scan, &next)) {
3524 ms = omp_const_mem_space;
3525 }
else if (__kmp_match_str(
"omp_high_bw_mem_space", scan, &next)) {
3527 ms = omp_high_bw_mem_space;
3528 }
else if (__kmp_match_str(
"omp_low_lat_mem_space", scan, &next)) {
3530 ms = omp_low_lat_mem_space;
3532 __kmp_def_allocator = omp_default_mem_alloc;
3533 if (next == buf || *next !=
'\0') {
3535 KMP_WARNING(StgInvalidValue, name, value);
3544 if (__kmp_match_str(
"sync_hint", scan, &next)) {
3546 traits[count].key = omp_atk_sync_hint;
3547 if (__kmp_match_str(
"contended", scan, &next)) {
3548 traits[count].value = omp_atv_contended;
3549 }
else if (__kmp_match_str(
"uncontended", scan, &next)) {
3550 traits[count].value = omp_atv_uncontended;
3551 }
else if (__kmp_match_str(
"serialized", scan, &next)) {
3552 traits[count].value = omp_atv_serialized;
3553 }
else if (__kmp_match_str(
"private", scan, &next)) {
3554 traits[count].value = omp_atv_private;
3560 }
else if (__kmp_match_str(
"alignment", scan, &next)) {
3562 if (!isdigit(*next)) {
3568 int n = __kmp_str_to_int(scan,
',');
3569 if (n < 0 || !IS_POWER_OF_TWO(n)) {
3574 traits[count].key = omp_atk_alignment;
3575 traits[count].value = n;
3576 }
else if (__kmp_match_str(
"access", scan, &next)) {
3578 traits[count].key = omp_atk_access;
3579 if (__kmp_match_str(
"all", scan, &next)) {
3580 traits[count].value = omp_atv_all;
3581 }
else if (__kmp_match_str(
"cgroup", scan, &next)) {
3582 traits[count].value = omp_atv_cgroup;
3583 }
else if (__kmp_match_str(
"pteam", scan, &next)) {
3584 traits[count].value = omp_atv_pteam;
3585 }
else if (__kmp_match_str(
"thread", scan, &next)) {
3586 traits[count].value = omp_atv_thread;
3592 }
else if (__kmp_match_str(
"pool_size", scan, &next)) {
3594 if (!isdigit(*next)) {
3600 int n = __kmp_str_to_int(scan,
',');
3606 traits[count].key = omp_atk_pool_size;
3607 traits[count].value = n;
3608 }
else if (__kmp_match_str(
"fallback", scan, &next)) {
3610 traits[count].key = omp_atk_fallback;
3611 if (__kmp_match_str(
"default_mem_fb", scan, &next)) {
3612 traits[count].value = omp_atv_default_mem_fb;
3613 }
else if (__kmp_match_str(
"null_fb", scan, &next)) {
3614 traits[count].value = omp_atv_null_fb;
3615 }
else if (__kmp_match_str(
"abort_fb", scan, &next)) {
3616 traits[count].value = omp_atv_abort_fb;
3617 }
else if (__kmp_match_str(
"allocator_fb", scan, &next)) {
3618 traits[count].value = omp_atv_allocator_fb;
3624 }
else if (__kmp_match_str(
"pinned", scan, &next)) {
3626 traits[count].key = omp_atk_pinned;
3627 if (__kmp_str_match_true(next)) {
3628 traits[count].value = omp_atv_true;
3629 }
else if (__kmp_str_match_false(next)) {
3630 traits[count].value = omp_atv_false;
3636 }
else if (__kmp_match_str(
"partition", scan, &next)) {
3638 traits[count].key = omp_atk_partition;
3639 if (__kmp_match_str(
"environment", scan, &next)) {
3640 traits[count].value = omp_atv_environment;
3641 }
else if (__kmp_match_str(
"nearest", scan, &next)) {
3642 traits[count].value = omp_atv_nearest;
3643 }
else if (__kmp_match_str(
"blocked", scan, &next)) {
3644 traits[count].value = omp_atv_blocked;
3645 }
else if (__kmp_match_str(
"interleaved", scan, &next)) {
3646 traits[count].value = omp_atv_interleaved;
3659 if (count == ntraits)
3665 al = __kmpc_init_allocator(__kmp_get_gtid(), ms, ntraits, traits);
3666 __kmp_def_allocator = (al == omp_null_allocator) ? omp_default_mem_alloc : al;
3669 static void __kmp_stg_print_allocator(kmp_str_buf_t *buffer,
char const *name,
3671 if (__kmp_def_allocator == omp_default_mem_alloc) {
3672 __kmp_stg_print_str(buffer, name,
"omp_default_mem_alloc");
3673 }
else if (__kmp_def_allocator == omp_high_bw_mem_alloc) {
3674 __kmp_stg_print_str(buffer, name,
"omp_high_bw_mem_alloc");
3675 }
else if (__kmp_def_allocator == omp_large_cap_mem_alloc) {
3676 __kmp_stg_print_str(buffer, name,
"omp_large_cap_mem_alloc");
3677 }
else if (__kmp_def_allocator == omp_const_mem_alloc) {
3678 __kmp_stg_print_str(buffer, name,
"omp_const_mem_alloc");
3679 }
else if (__kmp_def_allocator == omp_low_lat_mem_alloc) {
3680 __kmp_stg_print_str(buffer, name,
"omp_low_lat_mem_alloc");
3681 }
else if (__kmp_def_allocator == omp_cgroup_mem_alloc) {
3682 __kmp_stg_print_str(buffer, name,
"omp_cgroup_mem_alloc");
3683 }
else if (__kmp_def_allocator == omp_pteam_mem_alloc) {
3684 __kmp_stg_print_str(buffer, name,
"omp_pteam_mem_alloc");
3685 }
else if (__kmp_def_allocator == omp_thread_mem_alloc) {
3686 __kmp_stg_print_str(buffer, name,
"omp_thread_mem_alloc");
3693 static void __kmp_stg_parse_omp_dynamic(
char const *name,
char const *value,
3695 __kmp_stg_parse_bool(name, value, &(__kmp_global.g.g_dynamic));
3698 static void __kmp_stg_print_omp_dynamic(kmp_str_buf_t *buffer,
char const *name,
3700 __kmp_stg_print_bool(buffer, name, __kmp_global.g.g_dynamic);
3703 static void __kmp_stg_parse_kmp_dynamic_mode(
char const *name,
3704 char const *value,
void *data) {
3705 if (TCR_4(__kmp_init_parallel)) {
3706 KMP_WARNING(EnvParallelWarn, name);
3707 __kmp_env_toPrint(name, 0);
3710 #ifdef USE_LOAD_BALANCE
3711 else if (__kmp_str_match(
"load balance", 2, value) ||
3712 __kmp_str_match(
"load_balance", 2, value) ||
3713 __kmp_str_match(
"load-balance", 2, value) ||
3714 __kmp_str_match(
"loadbalance", 2, value) ||
3715 __kmp_str_match(
"balance", 1, value)) {
3716 __kmp_global.g.g_dynamic_mode = dynamic_load_balance;
3719 else if (__kmp_str_match(
"thread limit", 1, value) ||
3720 __kmp_str_match(
"thread_limit", 1, value) ||
3721 __kmp_str_match(
"thread-limit", 1, value) ||
3722 __kmp_str_match(
"threadlimit", 1, value) ||
3723 __kmp_str_match(
"limit", 2, value)) {
3724 __kmp_global.g.g_dynamic_mode = dynamic_thread_limit;
3725 }
else if (__kmp_str_match(
"random", 1, value)) {
3726 __kmp_global.g.g_dynamic_mode = dynamic_random;
3728 KMP_WARNING(StgInvalidValue, name, value);
3732 static void __kmp_stg_print_kmp_dynamic_mode(kmp_str_buf_t *buffer,
3733 char const *name,
void *data) {
3735 if (__kmp_global.g.g_dynamic_mode == dynamic_default) {
3736 __kmp_str_buf_print(buffer,
" %s: %s \n", name, KMP_I18N_STR(NotDefined));
3738 #ifdef USE_LOAD_BALANCE
3739 else if (__kmp_global.g.g_dynamic_mode == dynamic_load_balance) {
3740 __kmp_stg_print_str(buffer, name,
"load balance");
3743 else if (__kmp_global.g.g_dynamic_mode == dynamic_thread_limit) {
3744 __kmp_stg_print_str(buffer, name,
"thread limit");
3745 }
else if (__kmp_global.g.g_dynamic_mode == dynamic_random) {
3746 __kmp_stg_print_str(buffer, name,
"random");
3753 #ifdef USE_LOAD_BALANCE
3758 static void __kmp_stg_parse_ld_balance_interval(
char const *name,
3759 char const *value,
void *data) {
3760 double interval = __kmp_convert_to_double(value);
3761 if (interval >= 0) {
3762 __kmp_load_balance_interval = interval;
3764 KMP_WARNING(StgInvalidValue, name, value);
3768 static void __kmp_stg_print_ld_balance_interval(kmp_str_buf_t *buffer,
3769 char const *name,
void *data) {
3771 __kmp_str_buf_print(buffer,
" %s=%8.6f\n", name,
3772 __kmp_load_balance_interval);
3781 static void __kmp_stg_parse_init_at_fork(
char const *name,
char const *value,
3783 __kmp_stg_parse_bool(name, value, &__kmp_need_register_atfork);
3784 if (__kmp_need_register_atfork) {
3785 __kmp_need_register_atfork_specified = TRUE;
3789 static void __kmp_stg_print_init_at_fork(kmp_str_buf_t *buffer,
3790 char const *name,
void *data) {
3791 __kmp_stg_print_bool(buffer, name, __kmp_need_register_atfork_specified);
3797 static void __kmp_stg_parse_schedule(
char const *name,
char const *value,
3800 if (value != NULL) {
3801 size_t length = KMP_STRLEN(value);
3802 if (length > INT_MAX) {
3803 KMP_WARNING(LongValue, name);
3805 const char *semicolon;
3806 if (value[length - 1] ==
'"' || value[length - 1] ==
'\'')
3807 KMP_WARNING(UnbalancedQuotes, name);
3811 semicolon = strchr(value,
';');
3812 if (*value && semicolon != value) {
3813 const char *comma = strchr(value,
',');
3820 if (!__kmp_strcasecmp_with_sentinel(
"static", value, sentinel)) {
3821 if (!__kmp_strcasecmp_with_sentinel(
"greedy", comma,
';')) {
3822 __kmp_static = kmp_sch_static_greedy;
3824 }
else if (!__kmp_strcasecmp_with_sentinel(
"balanced", comma,
3826 __kmp_static = kmp_sch_static_balanced;
3829 }
else if (!__kmp_strcasecmp_with_sentinel(
"guided", value,
3831 if (!__kmp_strcasecmp_with_sentinel(
"iterative", comma,
';')) {
3832 __kmp_guided = kmp_sch_guided_iterative_chunked;
3834 }
else if (!__kmp_strcasecmp_with_sentinel(
"analytical", comma,
3837 __kmp_guided = kmp_sch_guided_analytical_chunked;
3841 KMP_WARNING(InvalidClause, name, value);
3843 KMP_WARNING(EmptyClause, name);
3844 }
while ((value = semicolon ? semicolon + 1 : NULL));
3850 static void __kmp_stg_print_schedule(kmp_str_buf_t *buffer,
char const *name,
3852 if (__kmp_env_format) {
3853 KMP_STR_BUF_PRINT_NAME_EX(name);
3855 __kmp_str_buf_print(buffer,
" %s='", name);
3857 if (__kmp_static == kmp_sch_static_greedy) {
3858 __kmp_str_buf_print(buffer,
"%s",
"static,greedy");
3859 }
else if (__kmp_static == kmp_sch_static_balanced) {
3860 __kmp_str_buf_print(buffer,
"%s",
"static,balanced");
3862 if (__kmp_guided == kmp_sch_guided_iterative_chunked) {
3863 __kmp_str_buf_print(buffer,
";%s'\n",
"guided,iterative");
3864 }
else if (__kmp_guided == kmp_sch_guided_analytical_chunked) {
3865 __kmp_str_buf_print(buffer,
";%s'\n",
"guided,analytical");
3872 static inline void __kmp_omp_schedule_restore() {
3873 #if KMP_USE_HIER_SCHED
3874 __kmp_hier_scheds.deallocate();
3884 static const char *__kmp_parse_single_omp_schedule(
const char *name,
3886 bool parse_hier =
false) {
3888 const char *ptr = value;
3895 while (*delim !=
',' && *delim !=
':' && *delim !=
'\0')
3897 #if KMP_USE_HIER_SCHED
3898 kmp_hier_layer_e layer = kmp_hier_layer_e::LAYER_THREAD;
3900 if (*delim ==
',') {
3901 if (!__kmp_strcasecmp_with_sentinel(
"L1", ptr,
',')) {
3902 layer = kmp_hier_layer_e::LAYER_L1;
3903 }
else if (!__kmp_strcasecmp_with_sentinel(
"L2", ptr,
',')) {
3904 layer = kmp_hier_layer_e::LAYER_L2;
3905 }
else if (!__kmp_strcasecmp_with_sentinel(
"L3", ptr,
',')) {
3906 layer = kmp_hier_layer_e::LAYER_L3;
3907 }
else if (!__kmp_strcasecmp_with_sentinel(
"NUMA", ptr,
',')) {
3908 layer = kmp_hier_layer_e::LAYER_NUMA;
3911 if (layer != kmp_hier_layer_e::LAYER_THREAD && *delim !=
',') {
3913 KMP_WARNING(StgInvalidValue, name, value);
3914 __kmp_omp_schedule_restore();
3916 }
else if (layer != kmp_hier_layer_e::LAYER_THREAD) {
3918 while (*delim !=
',' && *delim !=
':' && *delim !=
'\0')
3925 if (*delim ==
':') {
3926 if (!__kmp_strcasecmp_with_sentinel(
"monotonic", ptr, *delim)) {
3929 while (*delim !=
',' && *delim !=
':' && *delim !=
'\0')
3931 }
else if (!__kmp_strcasecmp_with_sentinel(
"nonmonotonic", ptr, *delim)) {
3934 while (*delim !=
',' && *delim !=
':' && *delim !=
'\0')
3936 }
else if (!parse_hier) {
3938 KMP_WARNING(StgInvalidValue, name, value);
3939 __kmp_omp_schedule_restore();
3944 if (!__kmp_strcasecmp_with_sentinel(
"dynamic", ptr, *delim))
3945 sched = kmp_sch_dynamic_chunked;
3946 else if (!__kmp_strcasecmp_with_sentinel(
"guided", ptr, *delim))
3949 else if (!__kmp_strcasecmp_with_sentinel(
"auto", ptr, *delim))
3951 else if (!__kmp_strcasecmp_with_sentinel(
"trapezoidal", ptr, *delim))
3952 sched = kmp_sch_trapezoidal;
3953 else if (!__kmp_strcasecmp_with_sentinel(
"static", ptr, *delim))
3955 #if KMP_STATIC_STEAL_ENABLED
3956 else if (!__kmp_strcasecmp_with_sentinel(
"static_steal", ptr, *delim))
3957 sched = kmp_sch_static_steal;
3961 KMP_WARNING(StgInvalidValue, name, value);
3962 __kmp_omp_schedule_restore();
3967 if (*delim ==
',') {
3970 if (!isdigit(*ptr)) {
3972 KMP_WARNING(StgInvalidValue, name, value);
3973 __kmp_omp_schedule_restore();
3979 __kmp_msg(kmp_ms_warning, KMP_MSG(IgnoreChunk, name, delim),
3983 sched = kmp_sch_static_chunked;
3984 chunk = __kmp_str_to_int(delim + 1, *ptr);
3986 chunk = KMP_DEFAULT_CHUNK;
3987 __kmp_msg(kmp_ms_warning, KMP_MSG(InvalidChunk, name, delim),
3989 KMP_INFORM(Using_int_Value, name, __kmp_chunk);
3998 }
else if (chunk > KMP_MAX_CHUNK) {
3999 chunk = KMP_MAX_CHUNK;
4000 __kmp_msg(kmp_ms_warning, KMP_MSG(LargeChunk, name, delim),
4002 KMP_INFORM(Using_int_Value, name, chunk);
4009 SCHEDULE_SET_MODIFIERS(sched, sched_modifier);
4011 #if KMP_USE_HIER_SCHED
4012 if (layer != kmp_hier_layer_e::LAYER_THREAD) {
4013 __kmp_hier_scheds.append(sched, chunk, layer);
4017 __kmp_chunk = chunk;
4018 __kmp_sched = sched;
4023 static void __kmp_stg_parse_omp_schedule(
char const *name,
char const *value,
4026 const char *ptr = value;
4029 length = KMP_STRLEN(value);
4031 if (value[length - 1] ==
'"' || value[length - 1] ==
'\'')
4032 KMP_WARNING(UnbalancedQuotes, name);
4034 #if KMP_USE_HIER_SCHED
4035 if (!__kmp_strcasecmp_with_sentinel(
"EXPERIMENTAL", ptr,
' ')) {
4038 while ((ptr = __kmp_parse_single_omp_schedule(name, ptr,
true))) {
4039 while (*ptr ==
' ' || *ptr ==
'\t' || *ptr ==
':')
4046 __kmp_parse_single_omp_schedule(name, ptr);
4048 KMP_WARNING(EmptyString, name);
4050 #if KMP_USE_HIER_SCHED
4051 __kmp_hier_scheds.sort();
4053 K_DIAG(1, (
"__kmp_static == %d\n", __kmp_static))
4054 K_DIAG(1, (
"__kmp_guided == %d\n", __kmp_guided))
4055 K_DIAG(1, (
"__kmp_sched == %d\n", __kmp_sched))
4056 K_DIAG(1, (
"__kmp_chunk == %d\n", __kmp_chunk))
4059 static void __kmp_stg_print_omp_schedule(kmp_str_buf_t *buffer,
4060 char const *name,
void *data) {
4061 if (__kmp_env_format) {
4062 KMP_STR_BUF_PRINT_NAME_EX(name);
4064 __kmp_str_buf_print(buffer,
" %s='", name);
4066 enum sched_type sched = SCHEDULE_WITHOUT_MODIFIERS(__kmp_sched);
4067 if (SCHEDULE_HAS_MONOTONIC(__kmp_sched)) {
4068 __kmp_str_buf_print(buffer,
"monotonic:");
4069 }
else if (SCHEDULE_HAS_NONMONOTONIC(__kmp_sched)) {
4070 __kmp_str_buf_print(buffer,
"nonmonotonic:");
4074 case kmp_sch_dynamic_chunked:
4075 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"dynamic", __kmp_chunk);
4077 case kmp_sch_guided_iterative_chunked:
4078 case kmp_sch_guided_analytical_chunked:
4079 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"guided", __kmp_chunk);
4081 case kmp_sch_trapezoidal:
4082 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"trapezoidal", __kmp_chunk);
4085 case kmp_sch_static_chunked:
4086 case kmp_sch_static_balanced:
4087 case kmp_sch_static_greedy:
4088 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"static", __kmp_chunk);
4090 case kmp_sch_static_steal:
4091 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"static_steal", __kmp_chunk);
4094 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"auto", __kmp_chunk);
4099 case kmp_sch_dynamic_chunked:
4100 __kmp_str_buf_print(buffer,
"%s'\n",
"dynamic");
4102 case kmp_sch_guided_iterative_chunked:
4103 case kmp_sch_guided_analytical_chunked:
4104 __kmp_str_buf_print(buffer,
"%s'\n",
"guided");
4106 case kmp_sch_trapezoidal:
4107 __kmp_str_buf_print(buffer,
"%s'\n",
"trapezoidal");
4110 case kmp_sch_static_chunked:
4111 case kmp_sch_static_balanced:
4112 case kmp_sch_static_greedy:
4113 __kmp_str_buf_print(buffer,
"%s'\n",
"static");
4115 case kmp_sch_static_steal:
4116 __kmp_str_buf_print(buffer,
"%s'\n",
"static_steal");
4119 __kmp_str_buf_print(buffer,
"%s'\n",
"auto");
4125 #if KMP_USE_HIER_SCHED
4128 static void __kmp_stg_parse_kmp_hand_thread(
char const *name,
char const *value,
4130 __kmp_stg_parse_bool(name, value, &(__kmp_dispatch_hand_threading));
4133 static void __kmp_stg_print_kmp_hand_thread(kmp_str_buf_t *buffer,
4134 char const *name,
void *data) {
4135 __kmp_stg_print_bool(buffer, name, __kmp_dispatch_hand_threading);
4142 static void __kmp_stg_parse_atomic_mode(
char const *name,
char const *value,
4148 #ifdef KMP_GOMP_COMPAT
4151 __kmp_stg_parse_int(name, value, 0, max, &mode);
4156 __kmp_atomic_mode = mode;
4160 static void __kmp_stg_print_atomic_mode(kmp_str_buf_t *buffer,
char const *name,
4162 __kmp_stg_print_int(buffer, name, __kmp_atomic_mode);
4168 static void __kmp_stg_parse_consistency_check(
char const *name,
4169 char const *value,
void *data) {
4170 if (!__kmp_strcasecmp_with_sentinel(
"all", value, 0)) {
4176 __kmp_env_consistency_check = TRUE;
4177 }
else if (!__kmp_strcasecmp_with_sentinel(
"none", value, 0)) {
4178 __kmp_env_consistency_check = FALSE;
4180 KMP_WARNING(StgInvalidValue, name, value);
4184 static void __kmp_stg_print_consistency_check(kmp_str_buf_t *buffer,
4185 char const *name,
void *data) {
4187 const char *value = NULL;
4189 if (__kmp_env_consistency_check) {
4195 if (value != NULL) {
4196 __kmp_stg_print_str(buffer, name, value);
4207 static void __kmp_stg_parse_itt_prepare_delay(
char const *name,
4208 char const *value,
void *data) {
4212 __kmp_stg_parse_int(name, value, 0, INT_MAX, &delay);
4213 __kmp_itt_prepare_delay = delay;
4216 static void __kmp_stg_print_itt_prepare_delay(kmp_str_buf_t *buffer,
4217 char const *name,
void *data) {
4218 __kmp_stg_print_uint64(buffer, name, __kmp_itt_prepare_delay);
4228 static void __kmp_stg_parse_malloc_pool_incr(
char const *name,
4229 char const *value,
void *data) {
4230 __kmp_stg_parse_size(name, value, KMP_MIN_MALLOC_POOL_INCR,
4231 KMP_MAX_MALLOC_POOL_INCR, NULL, &__kmp_malloc_pool_incr,
4235 static void __kmp_stg_print_malloc_pool_incr(kmp_str_buf_t *buffer,
4236 char const *name,
void *data) {
4237 __kmp_stg_print_size(buffer, name, __kmp_malloc_pool_incr);
4246 static void __kmp_stg_parse_par_range_env(
char const *name,
char const *value,
4248 __kmp_stg_parse_par_range(name, value, &__kmp_par_range,
4249 __kmp_par_range_routine, __kmp_par_range_filename,
4250 &__kmp_par_range_lb, &__kmp_par_range_ub);
4253 static void __kmp_stg_print_par_range_env(kmp_str_buf_t *buffer,
4254 char const *name,
void *data) {
4255 if (__kmp_par_range != 0) {
4256 __kmp_stg_print_str(buffer, name, par_range_to_print);
4265 static void __kmp_stg_parse_gtid_mode(
char const *name,
char const *value,
4275 #ifdef KMP_TDATA_GTID
4278 __kmp_stg_parse_int(name, value, 0, max, &mode);
4282 __kmp_adjust_gtid_mode = TRUE;
4284 __kmp_gtid_mode = mode;
4285 __kmp_adjust_gtid_mode = FALSE;
4289 static void __kmp_stg_print_gtid_mode(kmp_str_buf_t *buffer,
char const *name,
4291 if (__kmp_adjust_gtid_mode) {
4292 __kmp_stg_print_int(buffer, name, 0);
4294 __kmp_stg_print_int(buffer, name, __kmp_gtid_mode);
4301 static void __kmp_stg_parse_lock_block(
char const *name,
char const *value,
4303 __kmp_stg_parse_int(name, value, 0, KMP_INT_MAX, &__kmp_num_locks_in_block);
4306 static void __kmp_stg_print_lock_block(kmp_str_buf_t *buffer,
char const *name,
4308 __kmp_stg_print_int(buffer, name, __kmp_num_locks_in_block);
4314 #if KMP_USE_DYNAMIC_LOCK
4315 #define KMP_STORE_LOCK_SEQ(a) (__kmp_user_lock_seq = lockseq_##a)
4317 #define KMP_STORE_LOCK_SEQ(a)
4320 static void __kmp_stg_parse_lock_kind(
char const *name,
char const *value,
4322 if (__kmp_init_user_locks) {
4323 KMP_WARNING(EnvLockWarn, name);
4327 if (__kmp_str_match(
"tas", 2, value) ||
4328 __kmp_str_match(
"test and set", 2, value) ||
4329 __kmp_str_match(
"test_and_set", 2, value) ||
4330 __kmp_str_match(
"test-and-set", 2, value) ||
4331 __kmp_str_match(
"test andset", 2, value) ||
4332 __kmp_str_match(
"test_andset", 2, value) ||
4333 __kmp_str_match(
"test-andset", 2, value) ||
4334 __kmp_str_match(
"testand set", 2, value) ||
4335 __kmp_str_match(
"testand_set", 2, value) ||
4336 __kmp_str_match(
"testand-set", 2, value) ||
4337 __kmp_str_match(
"testandset", 2, value)) {
4338 __kmp_user_lock_kind = lk_tas;
4339 KMP_STORE_LOCK_SEQ(tas);
4342 else if (__kmp_str_match(
"futex", 1, value)) {
4343 if (__kmp_futex_determine_capable()) {
4344 __kmp_user_lock_kind = lk_futex;
4345 KMP_STORE_LOCK_SEQ(futex);
4347 KMP_WARNING(FutexNotSupported, name, value);
4351 else if (__kmp_str_match(
"ticket", 2, value)) {
4352 __kmp_user_lock_kind = lk_ticket;
4353 KMP_STORE_LOCK_SEQ(ticket);
4354 }
else if (__kmp_str_match(
"queuing", 1, value) ||
4355 __kmp_str_match(
"queue", 1, value)) {
4356 __kmp_user_lock_kind = lk_queuing;
4357 KMP_STORE_LOCK_SEQ(queuing);
4358 }
else if (__kmp_str_match(
"drdpa ticket", 1, value) ||
4359 __kmp_str_match(
"drdpa_ticket", 1, value) ||
4360 __kmp_str_match(
"drdpa-ticket", 1, value) ||
4361 __kmp_str_match(
"drdpaticket", 1, value) ||
4362 __kmp_str_match(
"drdpa", 1, value)) {
4363 __kmp_user_lock_kind = lk_drdpa;
4364 KMP_STORE_LOCK_SEQ(drdpa);
4366 #if KMP_USE_ADAPTIVE_LOCKS
4367 else if (__kmp_str_match(
"adaptive", 1, value)) {
4368 if (__kmp_cpuinfo.rtm) {
4369 __kmp_user_lock_kind = lk_adaptive;
4370 KMP_STORE_LOCK_SEQ(adaptive);
4372 KMP_WARNING(AdaptiveNotSupported, name, value);
4373 __kmp_user_lock_kind = lk_queuing;
4374 KMP_STORE_LOCK_SEQ(queuing);
4378 #if KMP_USE_DYNAMIC_LOCK && KMP_USE_TSX
4379 else if (__kmp_str_match(
"rtm_queuing", 1, value)) {
4380 if (__kmp_cpuinfo.rtm) {
4381 __kmp_user_lock_kind = lk_rtm_queuing;
4382 KMP_STORE_LOCK_SEQ(rtm_queuing);
4384 KMP_WARNING(AdaptiveNotSupported, name, value);
4385 __kmp_user_lock_kind = lk_queuing;
4386 KMP_STORE_LOCK_SEQ(queuing);
4388 }
else if (__kmp_str_match(
"rtm_spin", 1, value)) {
4389 if (__kmp_cpuinfo.rtm) {
4390 __kmp_user_lock_kind = lk_rtm_spin;
4391 KMP_STORE_LOCK_SEQ(rtm_spin);
4393 KMP_WARNING(AdaptiveNotSupported, name, value);
4394 __kmp_user_lock_kind = lk_tas;
4395 KMP_STORE_LOCK_SEQ(queuing);
4397 }
else if (__kmp_str_match(
"hle", 1, value)) {
4398 __kmp_user_lock_kind = lk_hle;
4399 KMP_STORE_LOCK_SEQ(hle);
4403 KMP_WARNING(StgInvalidValue, name, value);
4407 static void __kmp_stg_print_lock_kind(kmp_str_buf_t *buffer,
char const *name,
4409 const char *value = NULL;
4411 switch (__kmp_user_lock_kind) {
4426 #if KMP_USE_DYNAMIC_LOCK && KMP_USE_TSX
4427 case lk_rtm_queuing:
4428 value =
"rtm_queuing";
4451 #if KMP_USE_ADAPTIVE_LOCKS
4458 if (value != NULL) {
4459 __kmp_stg_print_str(buffer, name, value);
4468 static void __kmp_stg_parse_spin_backoff_params(
const char *name,
4469 const char *value,
void *data) {
4470 const char *next = value;
4473 int prev_comma = FALSE;
4476 kmp_uint32 max_backoff = __kmp_spin_backoff_params.max_backoff;
4477 kmp_uint32 min_tick = __kmp_spin_backoff_params.min_tick;
4481 for (i = 0; i < 3; i++) {
4484 if (*next ==
'\0') {
4489 if (((*next < '0' || *next >
'9') && *next !=
',') || total > 2) {
4490 KMP_WARNING(EnvSyntaxError, name, value);
4496 if (total == 0 || prev_comma) {
4504 if (*next >=
'0' && *next <=
'9') {
4506 const char *buf = next;
4507 char const *msg = NULL;
4512 const char *tmp = next;
4514 if ((*next ==
' ' || *next ==
'\t') && (*tmp >=
'0' && *tmp <=
'9')) {
4515 KMP_WARNING(EnvSpacesNotAllowed, name, value);
4519 num = __kmp_str_to_int(buf, *next);
4521 msg = KMP_I18N_STR(ValueTooSmall);
4523 }
else if (num > KMP_INT_MAX) {
4524 msg = KMP_I18N_STR(ValueTooLarge);
4529 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
4530 KMP_INFORM(Using_int_Value, name, num);
4534 }
else if (total == 2) {
4539 KMP_DEBUG_ASSERT(total > 0);
4541 KMP_WARNING(EnvSyntaxError, name, value);
4544 __kmp_spin_backoff_params.max_backoff = max_backoff;
4545 __kmp_spin_backoff_params.min_tick = min_tick;
4548 static void __kmp_stg_print_spin_backoff_params(kmp_str_buf_t *buffer,
4549 char const *name,
void *data) {
4550 if (__kmp_env_format) {
4551 KMP_STR_BUF_PRINT_NAME_EX(name);
4553 __kmp_str_buf_print(buffer,
" %s='", name);
4555 __kmp_str_buf_print(buffer,
"%d,%d'\n", __kmp_spin_backoff_params.max_backoff,
4556 __kmp_spin_backoff_params.min_tick);
4559 #if KMP_USE_ADAPTIVE_LOCKS
4566 static void __kmp_stg_parse_adaptive_lock_props(
const char *name,
4567 const char *value,
void *data) {
4568 int max_retries = 0;
4569 int max_badness = 0;
4571 const char *next = value;
4574 int prev_comma = FALSE;
4580 for (i = 0; i < 3; i++) {
4583 if (*next ==
'\0') {
4588 if (((*next < '0' || *next >
'9') && *next !=
',') || total > 2) {
4589 KMP_WARNING(EnvSyntaxError, name, value);
4595 if (total == 0 || prev_comma) {
4603 if (*next >=
'0' && *next <=
'9') {
4605 const char *buf = next;
4606 char const *msg = NULL;
4611 const char *tmp = next;
4613 if ((*next ==
' ' || *next ==
'\t') && (*tmp >=
'0' && *tmp <=
'9')) {
4614 KMP_WARNING(EnvSpacesNotAllowed, name, value);
4618 num = __kmp_str_to_int(buf, *next);
4620 msg = KMP_I18N_STR(ValueTooSmall);
4622 }
else if (num > KMP_INT_MAX) {
4623 msg = KMP_I18N_STR(ValueTooLarge);
4628 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
4629 KMP_INFORM(Using_int_Value, name, num);
4633 }
else if (total == 2) {
4638 KMP_DEBUG_ASSERT(total > 0);
4640 KMP_WARNING(EnvSyntaxError, name, value);
4643 __kmp_adaptive_backoff_params.max_soft_retries = max_retries;
4644 __kmp_adaptive_backoff_params.max_badness = max_badness;
4647 static void __kmp_stg_print_adaptive_lock_props(kmp_str_buf_t *buffer,
4648 char const *name,
void *data) {
4649 if (__kmp_env_format) {
4650 KMP_STR_BUF_PRINT_NAME_EX(name);
4652 __kmp_str_buf_print(buffer,
" %s='", name);
4654 __kmp_str_buf_print(buffer,
"%d,%d'\n",
4655 __kmp_adaptive_backoff_params.max_soft_retries,
4656 __kmp_adaptive_backoff_params.max_badness);
4659 #if KMP_DEBUG_ADAPTIVE_LOCKS
4661 static void __kmp_stg_parse_speculative_statsfile(
char const *name,
4664 __kmp_stg_parse_file(name, value,
"", CCAST(
char**, &__kmp_speculative_statsfile));
4667 static void __kmp_stg_print_speculative_statsfile(kmp_str_buf_t *buffer,
4670 if (__kmp_str_match(
"-", 0, __kmp_speculative_statsfile)) {
4671 __kmp_stg_print_str(buffer, name,
"stdout");
4673 __kmp_stg_print_str(buffer, name, __kmp_speculative_statsfile);
4689 #define MAX_T_LEVEL 5
4690 #define MAX_STR_LEN 512
4691 static void __kmp_stg_parse_hw_subset(
char const *name,
char const *value,
4695 kmp_setting_t **rivals = (kmp_setting_t **)data;
4696 if (strcmp(name,
"KMP_PLACE_THREADS") == 0) {
4697 KMP_INFORM(EnvVarDeprecated, name,
"KMP_HW_SUBSET");
4699 if (__kmp_stg_check_rivals(name, value, rivals)) {
4703 char *components[MAX_T_LEVEL];
4704 char const *digits =
"0123456789";
4705 char input[MAX_STR_LEN];
4706 size_t len = 0, mlen = MAX_STR_LEN;
4709 char *pos = CCAST(
char *, value);
4710 while (*pos && mlen) {
4712 if (len == 0 && *pos ==
':') {
4713 __kmp_hws_abs_flag = 1;
4715 input[len] = (char)(toupper(*pos));
4716 if (input[len] ==
'X')
4718 if (input[len] ==
'O' && strchr(digits, *(pos + 1)))
4726 if (len == 0 || mlen == 0)
4729 __kmp_hws_requested = 1;
4732 components[level++] = pos;
4733 while ((pos = strchr(pos,
','))) {
4734 if (level >= MAX_T_LEVEL)
4737 components[level++] = ++pos;
4740 for (
int i = 0; i < level; ++i) {
4742 int num = atoi(components[i]);
4743 if ((pos = strchr(components[i],
'@'))) {
4744 offset = atoi(pos + 1);
4747 pos = components[i] + strspn(components[i], digits);
4748 if (pos == components[i])
4753 if (__kmp_hws_socket.num > 0)
4755 __kmp_hws_socket.num = num;
4756 __kmp_hws_socket.offset = offset;
4759 if (__kmp_hws_node.num > 0)
4761 __kmp_hws_node.num = num;
4762 __kmp_hws_node.offset = offset;
4765 if (__kmp_hws_die.num > 0)
4767 __kmp_hws_die.num = num;
4768 __kmp_hws_die.offset = offset;
4771 if (*(pos + 1) ==
'2') {
4772 if (__kmp_hws_tile.num > 0)
4774 __kmp_hws_tile.num = num;
4775 __kmp_hws_tile.offset = offset;
4776 }
else if (*(pos + 1) ==
'3') {
4777 if (__kmp_hws_socket.num > 0 || __kmp_hws_die.num > 0)
4779 __kmp_hws_socket.num = num;
4780 __kmp_hws_socket.offset = offset;
4781 }
else if (*(pos + 1) ==
'1') {
4782 if (__kmp_hws_core.num > 0)
4784 __kmp_hws_core.num = num;
4785 __kmp_hws_core.offset = offset;
4789 if (*(pos + 1) !=
'A') {
4790 if (__kmp_hws_core.num > 0)
4792 __kmp_hws_core.num = num;
4793 __kmp_hws_core.offset = offset;
4795 char *d = pos + strcspn(pos, digits);
4797 if (__kmp_hws_tile.num > 0)
4799 __kmp_hws_tile.num = num;
4800 __kmp_hws_tile.offset = offset;
4801 }
else if (*d ==
'3') {
4802 if (__kmp_hws_socket.num > 0 || __kmp_hws_die.num > 0)
4804 __kmp_hws_socket.num = num;
4805 __kmp_hws_socket.offset = offset;
4806 }
else if (*d ==
'1') {
4807 if (__kmp_hws_core.num > 0)
4809 __kmp_hws_core.num = num;
4810 __kmp_hws_core.offset = offset;
4817 if (__kmp_hws_proc.num > 0)
4819 __kmp_hws_proc.num = num;
4820 __kmp_hws_proc.offset = offset;
4828 KMP_WARNING(AffHWSubsetInvalid, name, value);
4829 __kmp_hws_requested = 0;
4833 static void __kmp_stg_print_hw_subset(kmp_str_buf_t *buffer,
char const *name,
4835 if (__kmp_hws_requested) {
4838 __kmp_str_buf_init(&buf);
4839 if (__kmp_env_format)
4840 KMP_STR_BUF_PRINT_NAME_EX(name);
4842 __kmp_str_buf_print(buffer,
" %s='", name);
4843 if (__kmp_hws_socket.num) {
4844 __kmp_str_buf_print(&buf,
"%ds", __kmp_hws_socket.num);
4845 if (__kmp_hws_socket.offset)
4846 __kmp_str_buf_print(&buf,
"@%d", __kmp_hws_socket.offset);
4849 if (__kmp_hws_die.num) {
4850 __kmp_str_buf_print(&buf,
"%s%dd", comma ?
"," :
"", __kmp_hws_die.num);
4851 if (__kmp_hws_die.offset)
4852 __kmp_str_buf_print(&buf,
"@%d", __kmp_hws_die.offset);
4855 if (__kmp_hws_node.num) {
4856 __kmp_str_buf_print(&buf,
"%s%dn", comma ?
"," :
"", __kmp_hws_node.num);
4857 if (__kmp_hws_node.offset)
4858 __kmp_str_buf_print(&buf,
"@%d", __kmp_hws_node.offset);
4861 if (__kmp_hws_tile.num) {
4862 __kmp_str_buf_print(&buf,
"%s%dL2", comma ?
"," :
"", __kmp_hws_tile.num);
4863 if (__kmp_hws_tile.offset)
4864 __kmp_str_buf_print(&buf,
"@%d", __kmp_hws_tile.offset);
4867 if (__kmp_hws_core.num) {
4868 __kmp_str_buf_print(&buf,
"%s%dc", comma ?
"," :
"", __kmp_hws_core.num);
4869 if (__kmp_hws_core.offset)
4870 __kmp_str_buf_print(&buf,
"@%d", __kmp_hws_core.offset);
4873 if (__kmp_hws_proc.num)
4874 __kmp_str_buf_print(&buf,
"%s%dt", comma ?
"," :
"", __kmp_hws_proc.num);
4875 __kmp_str_buf_print(buffer,
"%s'\n", buf.str);
4876 __kmp_str_buf_free(&buf);
4884 static void __kmp_stg_parse_forkjoin_frames(
char const *name,
char const *value,
4886 __kmp_stg_parse_bool(name, value, &__kmp_forkjoin_frames);
4889 static void __kmp_stg_print_forkjoin_frames(kmp_str_buf_t *buffer,
4890 char const *name,
void *data) {
4891 __kmp_stg_print_bool(buffer, name, __kmp_forkjoin_frames);
4897 static void __kmp_stg_parse_forkjoin_frames_mode(
char const *name,
4900 __kmp_stg_parse_int(name, value, 0, 3, &__kmp_forkjoin_frames_mode);
4903 static void __kmp_stg_print_forkjoin_frames_mode(kmp_str_buf_t *buffer,
4904 char const *name,
void *data) {
4905 __kmp_stg_print_int(buffer, name, __kmp_forkjoin_frames_mode);
4912 static void __kmp_stg_parse_task_throttling(
char const *name,
4913 char const *value,
void *data) {
4914 __kmp_stg_parse_bool(name, value, &__kmp_enable_task_throttling);
4918 static void __kmp_stg_print_task_throttling(kmp_str_buf_t *buffer,
4919 char const *name,
void *data) {
4920 __kmp_stg_print_bool(buffer, name, __kmp_enable_task_throttling);
4923 #if KMP_HAVE_MWAIT || KMP_HAVE_UMWAIT
4927 static void __kmp_stg_parse_user_level_mwait(
char const *name,
4928 char const *value,
void *data) {
4929 __kmp_stg_parse_bool(name, value, &__kmp_user_level_mwait);
4932 static void __kmp_stg_print_user_level_mwait(kmp_str_buf_t *buffer,
4933 char const *name,
void *data) {
4934 __kmp_stg_print_bool(buffer, name, __kmp_user_level_mwait);
4940 static void __kmp_stg_parse_mwait_hints(
char const *name,
char const *value,
4942 __kmp_stg_parse_int(name, value, 0, INT_MAX, &__kmp_mwait_hints);
4945 static void __kmp_stg_print_mwait_hints(kmp_str_buf_t *buffer,
char const *name,
4947 __kmp_stg_print_int(buffer, name, __kmp_mwait_hints);
4955 static void __kmp_stg_parse_omp_display_env(
char const *name,
char const *value,
4957 if (__kmp_str_match(
"VERBOSE", 1, value)) {
4958 __kmp_display_env_verbose = TRUE;
4960 __kmp_stg_parse_bool(name, value, &__kmp_display_env);
4964 static void __kmp_stg_print_omp_display_env(kmp_str_buf_t *buffer,
4965 char const *name,
void *data) {
4966 if (__kmp_display_env_verbose) {
4967 __kmp_stg_print_str(buffer, name,
"VERBOSE");
4969 __kmp_stg_print_bool(buffer, name, __kmp_display_env);
4973 static void __kmp_stg_parse_omp_cancellation(
char const *name,
4974 char const *value,
void *data) {
4975 if (TCR_4(__kmp_init_parallel)) {
4976 KMP_WARNING(EnvParallelWarn, name);
4979 __kmp_stg_parse_bool(name, value, &__kmp_omp_cancellation);
4982 static void __kmp_stg_print_omp_cancellation(kmp_str_buf_t *buffer,
4983 char const *name,
void *data) {
4984 __kmp_stg_print_bool(buffer, name, __kmp_omp_cancellation);
4988 static int __kmp_tool = 1;
4990 static void __kmp_stg_parse_omp_tool(
char const *name,
char const *value,
4992 __kmp_stg_parse_bool(name, value, &__kmp_tool);
4995 static void __kmp_stg_print_omp_tool(kmp_str_buf_t *buffer,
char const *name,
4997 if (__kmp_env_format) {
4998 KMP_STR_BUF_PRINT_BOOL_EX(name, __kmp_tool,
"enabled",
"disabled");
5000 __kmp_str_buf_print(buffer,
" %s=%s\n", name,
5001 __kmp_tool ?
"enabled" :
"disabled");
5005 static char *__kmp_tool_libraries = NULL;
5007 static void __kmp_stg_parse_omp_tool_libraries(
char const *name,
5008 char const *value,
void *data) {
5009 __kmp_stg_parse_str(name, value, &__kmp_tool_libraries);
5012 static void __kmp_stg_print_omp_tool_libraries(kmp_str_buf_t *buffer,
5013 char const *name,
void *data) {
5014 if (__kmp_tool_libraries)
5015 __kmp_stg_print_str(buffer, name, __kmp_tool_libraries);
5017 if (__kmp_env_format) {
5018 KMP_STR_BUF_PRINT_NAME;
5020 __kmp_str_buf_print(buffer,
" %s", name);
5022 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
5026 static char *__kmp_tool_verbose_init = NULL;
5028 static void __kmp_stg_parse_omp_tool_verbose_init(
char const *name,
5029 char const *value,
void *data) {
5030 __kmp_stg_parse_str(name, value, &__kmp_tool_verbose_init);
5033 static void __kmp_stg_print_omp_tool_verbose_init(kmp_str_buf_t *buffer,
5034 char const *name,
void *data) {
5035 if (__kmp_tool_verbose_init)
5036 __kmp_stg_print_str(buffer, name, __kmp_tool_libraries);
5038 if (__kmp_env_format) {
5039 KMP_STR_BUF_PRINT_NAME;
5041 __kmp_str_buf_print(buffer,
" %s", name);
5043 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
5051 static kmp_setting_t __kmp_stg_table[] = {
5053 {
"KMP_ALL_THREADS", __kmp_stg_parse_device_thread_limit, NULL, NULL, 0, 0},
5054 {
"KMP_BLOCKTIME", __kmp_stg_parse_blocktime, __kmp_stg_print_blocktime,
5056 {
"KMP_USE_YIELD", __kmp_stg_parse_use_yield, __kmp_stg_print_use_yield,
5058 {
"KMP_DUPLICATE_LIB_OK", __kmp_stg_parse_duplicate_lib_ok,
5059 __kmp_stg_print_duplicate_lib_ok, NULL, 0, 0},
5060 {
"KMP_LIBRARY", __kmp_stg_parse_wait_policy, __kmp_stg_print_wait_policy,
5062 {
"KMP_DEVICE_THREAD_LIMIT", __kmp_stg_parse_device_thread_limit,
5063 __kmp_stg_print_device_thread_limit, NULL, 0, 0},
5065 {
"KMP_MONITOR_STACKSIZE", __kmp_stg_parse_monitor_stacksize,
5066 __kmp_stg_print_monitor_stacksize, NULL, 0, 0},
5068 {
"KMP_SETTINGS", __kmp_stg_parse_settings, __kmp_stg_print_settings, NULL,
5070 {
"KMP_STACKOFFSET", __kmp_stg_parse_stackoffset,
5071 __kmp_stg_print_stackoffset, NULL, 0, 0},
5072 {
"KMP_STACKSIZE", __kmp_stg_parse_stacksize, __kmp_stg_print_stacksize,
5074 {
"KMP_STACKPAD", __kmp_stg_parse_stackpad, __kmp_stg_print_stackpad, NULL,
5076 {
"KMP_VERSION", __kmp_stg_parse_version, __kmp_stg_print_version, NULL, 0,
5078 {
"KMP_WARNINGS", __kmp_stg_parse_warnings, __kmp_stg_print_warnings, NULL,
5081 {
"OMP_NESTED", __kmp_stg_parse_nested, __kmp_stg_print_nested, NULL, 0, 0},
5082 {
"OMP_NUM_THREADS", __kmp_stg_parse_num_threads,
5083 __kmp_stg_print_num_threads, NULL, 0, 0},
5084 {
"OMP_STACKSIZE", __kmp_stg_parse_stacksize, __kmp_stg_print_stacksize,
5087 {
"KMP_TASKING", __kmp_stg_parse_tasking, __kmp_stg_print_tasking, NULL, 0,
5089 {
"KMP_TASK_STEALING_CONSTRAINT", __kmp_stg_parse_task_stealing,
5090 __kmp_stg_print_task_stealing, NULL, 0, 0},
5091 {
"OMP_MAX_ACTIVE_LEVELS", __kmp_stg_parse_max_active_levels,
5092 __kmp_stg_print_max_active_levels, NULL, 0, 0},
5093 {
"OMP_DEFAULT_DEVICE", __kmp_stg_parse_default_device,
5094 __kmp_stg_print_default_device, NULL, 0, 0},
5095 {
"OMP_TARGET_OFFLOAD", __kmp_stg_parse_target_offload,
5096 __kmp_stg_print_target_offload, NULL, 0, 0},
5097 {
"OMP_MAX_TASK_PRIORITY", __kmp_stg_parse_max_task_priority,
5098 __kmp_stg_print_max_task_priority, NULL, 0, 0},
5099 {
"KMP_TASKLOOP_MIN_TASKS", __kmp_stg_parse_taskloop_min_tasks,
5100 __kmp_stg_print_taskloop_min_tasks, NULL, 0, 0},
5101 {
"OMP_THREAD_LIMIT", __kmp_stg_parse_thread_limit,
5102 __kmp_stg_print_thread_limit, NULL, 0, 0},
5103 {
"KMP_TEAMS_THREAD_LIMIT", __kmp_stg_parse_teams_thread_limit,
5104 __kmp_stg_print_teams_thread_limit, NULL, 0, 0},
5105 {
"OMP_WAIT_POLICY", __kmp_stg_parse_wait_policy,
5106 __kmp_stg_print_wait_policy, NULL, 0, 0},
5107 {
"KMP_DISP_NUM_BUFFERS", __kmp_stg_parse_disp_buffers,
5108 __kmp_stg_print_disp_buffers, NULL, 0, 0},
5109 #if KMP_NESTED_HOT_TEAMS
5110 {
"KMP_HOT_TEAMS_MAX_LEVEL", __kmp_stg_parse_hot_teams_level,
5111 __kmp_stg_print_hot_teams_level, NULL, 0, 0},
5112 {
"KMP_HOT_TEAMS_MODE", __kmp_stg_parse_hot_teams_mode,
5113 __kmp_stg_print_hot_teams_mode, NULL, 0, 0},
5116 #if KMP_HANDLE_SIGNALS
5117 {
"KMP_HANDLE_SIGNALS", __kmp_stg_parse_handle_signals,
5118 __kmp_stg_print_handle_signals, NULL, 0, 0},
5121 #if KMP_ARCH_X86 || KMP_ARCH_X86_64
5122 {
"KMP_INHERIT_FP_CONTROL", __kmp_stg_parse_inherit_fp_control,
5123 __kmp_stg_print_inherit_fp_control, NULL, 0, 0},
5126 #ifdef KMP_GOMP_COMPAT
5127 {
"GOMP_STACKSIZE", __kmp_stg_parse_stacksize, NULL, NULL, 0, 0},
5131 {
"KMP_A_DEBUG", __kmp_stg_parse_a_debug, __kmp_stg_print_a_debug, NULL, 0,
5133 {
"KMP_B_DEBUG", __kmp_stg_parse_b_debug, __kmp_stg_print_b_debug, NULL, 0,
5135 {
"KMP_C_DEBUG", __kmp_stg_parse_c_debug, __kmp_stg_print_c_debug, NULL, 0,
5137 {
"KMP_D_DEBUG", __kmp_stg_parse_d_debug, __kmp_stg_print_d_debug, NULL, 0,
5139 {
"KMP_E_DEBUG", __kmp_stg_parse_e_debug, __kmp_stg_print_e_debug, NULL, 0,
5141 {
"KMP_F_DEBUG", __kmp_stg_parse_f_debug, __kmp_stg_print_f_debug, NULL, 0,
5143 {
"KMP_DEBUG", __kmp_stg_parse_debug, NULL, NULL, 0, 0},
5144 {
"KMP_DEBUG_BUF", __kmp_stg_parse_debug_buf, __kmp_stg_print_debug_buf,
5146 {
"KMP_DEBUG_BUF_ATOMIC", __kmp_stg_parse_debug_buf_atomic,
5147 __kmp_stg_print_debug_buf_atomic, NULL, 0, 0},
5148 {
"KMP_DEBUG_BUF_CHARS", __kmp_stg_parse_debug_buf_chars,
5149 __kmp_stg_print_debug_buf_chars, NULL, 0, 0},
5150 {
"KMP_DEBUG_BUF_LINES", __kmp_stg_parse_debug_buf_lines,
5151 __kmp_stg_print_debug_buf_lines, NULL, 0, 0},
5152 {
"KMP_DIAG", __kmp_stg_parse_diag, __kmp_stg_print_diag, NULL, 0, 0},
5154 {
"KMP_PAR_RANGE", __kmp_stg_parse_par_range_env,
5155 __kmp_stg_print_par_range_env, NULL, 0, 0},
5158 {
"KMP_ALIGN_ALLOC", __kmp_stg_parse_align_alloc,
5159 __kmp_stg_print_align_alloc, NULL, 0, 0},
5161 {
"KMP_PLAIN_BARRIER", __kmp_stg_parse_barrier_branch_bit,
5162 __kmp_stg_print_barrier_branch_bit, NULL, 0, 0},
5163 {
"KMP_PLAIN_BARRIER_PATTERN", __kmp_stg_parse_barrier_pattern,
5164 __kmp_stg_print_barrier_pattern, NULL, 0, 0},
5165 {
"KMP_FORKJOIN_BARRIER", __kmp_stg_parse_barrier_branch_bit,
5166 __kmp_stg_print_barrier_branch_bit, NULL, 0, 0},
5167 {
"KMP_FORKJOIN_BARRIER_PATTERN", __kmp_stg_parse_barrier_pattern,
5168 __kmp_stg_print_barrier_pattern, NULL, 0, 0},
5169 #if KMP_FAST_REDUCTION_BARRIER
5170 {
"KMP_REDUCTION_BARRIER", __kmp_stg_parse_barrier_branch_bit,
5171 __kmp_stg_print_barrier_branch_bit, NULL, 0, 0},
5172 {
"KMP_REDUCTION_BARRIER_PATTERN", __kmp_stg_parse_barrier_pattern,
5173 __kmp_stg_print_barrier_pattern, NULL, 0, 0},
5176 {
"KMP_ABORT_DELAY", __kmp_stg_parse_abort_delay,
5177 __kmp_stg_print_abort_delay, NULL, 0, 0},
5178 {
"KMP_CPUINFO_FILE", __kmp_stg_parse_cpuinfo_file,
5179 __kmp_stg_print_cpuinfo_file, NULL, 0, 0},
5180 {
"KMP_FORCE_REDUCTION", __kmp_stg_parse_force_reduction,
5181 __kmp_stg_print_force_reduction, NULL, 0, 0},
5182 {
"KMP_DETERMINISTIC_REDUCTION", __kmp_stg_parse_force_reduction,
5183 __kmp_stg_print_force_reduction, NULL, 0, 0},
5184 {
"KMP_STORAGE_MAP", __kmp_stg_parse_storage_map,
5185 __kmp_stg_print_storage_map, NULL, 0, 0},
5186 {
"KMP_ALL_THREADPRIVATE", __kmp_stg_parse_all_threadprivate,
5187 __kmp_stg_print_all_threadprivate, NULL, 0, 0},
5188 {
"KMP_FOREIGN_THREADS_THREADPRIVATE",
5189 __kmp_stg_parse_foreign_threads_threadprivate,
5190 __kmp_stg_print_foreign_threads_threadprivate, NULL, 0, 0},
5192 #if KMP_AFFINITY_SUPPORTED
5193 {
"KMP_AFFINITY", __kmp_stg_parse_affinity, __kmp_stg_print_affinity, NULL,
5195 #ifdef KMP_GOMP_COMPAT
5196 {
"GOMP_CPU_AFFINITY", __kmp_stg_parse_gomp_cpu_affinity, NULL,
5199 {
"OMP_PROC_BIND", __kmp_stg_parse_proc_bind, __kmp_stg_print_proc_bind,
5201 {
"OMP_PLACES", __kmp_stg_parse_places, __kmp_stg_print_places, NULL, 0, 0},
5202 {
"KMP_TOPOLOGY_METHOD", __kmp_stg_parse_topology_method,
5203 __kmp_stg_print_topology_method, NULL, 0, 0},
5209 {
"OMP_PROC_BIND", __kmp_stg_parse_proc_bind, __kmp_stg_print_proc_bind,
5213 {
"OMP_DISPLAY_AFFINITY", __kmp_stg_parse_display_affinity,
5214 __kmp_stg_print_display_affinity, NULL, 0, 0},
5215 {
"OMP_AFFINITY_FORMAT", __kmp_stg_parse_affinity_format,
5216 __kmp_stg_print_affinity_format, NULL, 0, 0},
5217 {
"KMP_INIT_AT_FORK", __kmp_stg_parse_init_at_fork,
5218 __kmp_stg_print_init_at_fork, NULL, 0, 0},
5219 {
"KMP_SCHEDULE", __kmp_stg_parse_schedule, __kmp_stg_print_schedule, NULL,
5221 {
"OMP_SCHEDULE", __kmp_stg_parse_omp_schedule, __kmp_stg_print_omp_schedule,
5223 #if KMP_USE_HIER_SCHED
5224 {
"KMP_DISP_HAND_THREAD", __kmp_stg_parse_kmp_hand_thread,
5225 __kmp_stg_print_kmp_hand_thread, NULL, 0, 0},
5227 {
"KMP_ATOMIC_MODE", __kmp_stg_parse_atomic_mode,
5228 __kmp_stg_print_atomic_mode, NULL, 0, 0},
5229 {
"KMP_CONSISTENCY_CHECK", __kmp_stg_parse_consistency_check,
5230 __kmp_stg_print_consistency_check, NULL, 0, 0},
5232 #if USE_ITT_BUILD && USE_ITT_NOTIFY
5233 {
"KMP_ITT_PREPARE_DELAY", __kmp_stg_parse_itt_prepare_delay,
5234 __kmp_stg_print_itt_prepare_delay, NULL, 0, 0},
5236 {
"KMP_MALLOC_POOL_INCR", __kmp_stg_parse_malloc_pool_incr,
5237 __kmp_stg_print_malloc_pool_incr, NULL, 0, 0},
5238 {
"KMP_GTID_MODE", __kmp_stg_parse_gtid_mode, __kmp_stg_print_gtid_mode,
5240 {
"OMP_DYNAMIC", __kmp_stg_parse_omp_dynamic, __kmp_stg_print_omp_dynamic,
5242 {
"KMP_DYNAMIC_MODE", __kmp_stg_parse_kmp_dynamic_mode,
5243 __kmp_stg_print_kmp_dynamic_mode, NULL, 0, 0},
5245 #ifdef USE_LOAD_BALANCE
5246 {
"KMP_LOAD_BALANCE_INTERVAL", __kmp_stg_parse_ld_balance_interval,
5247 __kmp_stg_print_ld_balance_interval, NULL, 0, 0},
5250 {
"KMP_NUM_LOCKS_IN_BLOCK", __kmp_stg_parse_lock_block,
5251 __kmp_stg_print_lock_block, NULL, 0, 0},
5252 {
"KMP_LOCK_KIND", __kmp_stg_parse_lock_kind, __kmp_stg_print_lock_kind,
5254 {
"KMP_SPIN_BACKOFF_PARAMS", __kmp_stg_parse_spin_backoff_params,
5255 __kmp_stg_print_spin_backoff_params, NULL, 0, 0},
5256 #if KMP_USE_ADAPTIVE_LOCKS
5257 {
"KMP_ADAPTIVE_LOCK_PROPS", __kmp_stg_parse_adaptive_lock_props,
5258 __kmp_stg_print_adaptive_lock_props, NULL, 0, 0},
5259 #if KMP_DEBUG_ADAPTIVE_LOCKS
5260 {
"KMP_SPECULATIVE_STATSFILE", __kmp_stg_parse_speculative_statsfile,
5261 __kmp_stg_print_speculative_statsfile, NULL, 0, 0},
5264 {
"KMP_PLACE_THREADS", __kmp_stg_parse_hw_subset, __kmp_stg_print_hw_subset,
5266 {
"KMP_HW_SUBSET", __kmp_stg_parse_hw_subset, __kmp_stg_print_hw_subset,
5269 {
"KMP_FORKJOIN_FRAMES", __kmp_stg_parse_forkjoin_frames,
5270 __kmp_stg_print_forkjoin_frames, NULL, 0, 0},
5271 {
"KMP_FORKJOIN_FRAMES_MODE", __kmp_stg_parse_forkjoin_frames_mode,
5272 __kmp_stg_print_forkjoin_frames_mode, NULL, 0, 0},
5274 {
"KMP_ENABLE_TASK_THROTTLING", __kmp_stg_parse_task_throttling,
5275 __kmp_stg_print_task_throttling, NULL, 0, 0},
5277 {
"OMP_DISPLAY_ENV", __kmp_stg_parse_omp_display_env,
5278 __kmp_stg_print_omp_display_env, NULL, 0, 0},
5279 {
"OMP_CANCELLATION", __kmp_stg_parse_omp_cancellation,
5280 __kmp_stg_print_omp_cancellation, NULL, 0, 0},
5281 {
"OMP_ALLOCATOR", __kmp_stg_parse_allocator, __kmp_stg_print_allocator,
5283 {
"LIBOMP_USE_HIDDEN_HELPER_TASK", __kmp_stg_parse_use_hidden_helper,
5284 __kmp_stg_print_use_hidden_helper, NULL, 0, 0},
5285 {
"LIBOMP_NUM_HIDDEN_HELPER_THREADS",
5286 __kmp_stg_parse_num_hidden_helper_threads,
5287 __kmp_stg_print_num_hidden_helper_threads, NULL, 0, 0},
5290 {
"OMP_TOOL", __kmp_stg_parse_omp_tool, __kmp_stg_print_omp_tool, NULL, 0,
5292 {
"OMP_TOOL_LIBRARIES", __kmp_stg_parse_omp_tool_libraries,
5293 __kmp_stg_print_omp_tool_libraries, NULL, 0, 0},
5294 {
"OMP_TOOL_VERBOSE_INIT", __kmp_stg_parse_omp_tool_verbose_init,
5295 __kmp_stg_print_omp_tool_verbose_init, NULL, 0, 0},
5298 #if KMP_HAVE_MWAIT || KMP_HAVE_UMWAIT
5299 {
"KMP_USER_LEVEL_MWAIT", __kmp_stg_parse_user_level_mwait,
5300 __kmp_stg_print_user_level_mwait, NULL, 0, 0},
5301 {
"KMP_MWAIT_HINTS", __kmp_stg_parse_mwait_hints,
5302 __kmp_stg_print_mwait_hints, NULL, 0, 0},
5304 {
"", NULL, NULL, NULL, 0, 0}};
5306 static int const __kmp_stg_count =
5307 sizeof(__kmp_stg_table) /
sizeof(kmp_setting_t);
5309 static inline kmp_setting_t *__kmp_stg_find(
char const *name) {
5313 for (i = 0; i < __kmp_stg_count; ++i) {
5314 if (strcmp(__kmp_stg_table[i].name, name) == 0) {
5315 return &__kmp_stg_table[i];
5323 static int __kmp_stg_cmp(
void const *_a,
void const *_b) {
5324 const kmp_setting_t *a = RCAST(
const kmp_setting_t *, _a);
5325 const kmp_setting_t *b = RCAST(
const kmp_setting_t *, _b);
5329 if (strcmp(a->name,
"KMP_AFFINITY") == 0) {
5330 if (strcmp(b->name,
"KMP_AFFINITY") == 0) {
5334 }
else if (strcmp(b->name,
"KMP_AFFINITY") == 0) {
5337 return strcmp(a->name, b->name);
5340 static void __kmp_stg_init(
void) {
5342 static int initialized = 0;
5347 qsort(__kmp_stg_table, __kmp_stg_count - 1,
sizeof(kmp_setting_t),
5351 kmp_setting_t *kmp_stacksize =
5352 __kmp_stg_find(
"KMP_STACKSIZE");
5353 #ifdef KMP_GOMP_COMPAT
5354 kmp_setting_t *gomp_stacksize =
5355 __kmp_stg_find(
"GOMP_STACKSIZE");
5357 kmp_setting_t *omp_stacksize =
5358 __kmp_stg_find(
"OMP_STACKSIZE");
5364 static kmp_setting_t *
volatile rivals[4];
5365 static kmp_stg_ss_data_t kmp_data = {1, CCAST(kmp_setting_t **, rivals)};
5366 #ifdef KMP_GOMP_COMPAT
5367 static kmp_stg_ss_data_t gomp_data = {1024,
5368 CCAST(kmp_setting_t **, rivals)};
5370 static kmp_stg_ss_data_t omp_data = {1024,
5371 CCAST(kmp_setting_t **, rivals)};
5374 rivals[i++] = kmp_stacksize;
5375 #ifdef KMP_GOMP_COMPAT
5376 if (gomp_stacksize != NULL) {
5377 rivals[i++] = gomp_stacksize;
5380 rivals[i++] = omp_stacksize;
5383 kmp_stacksize->data = &kmp_data;
5384 #ifdef KMP_GOMP_COMPAT
5385 if (gomp_stacksize != NULL) {
5386 gomp_stacksize->data = &gomp_data;
5389 omp_stacksize->data = &omp_data;
5393 kmp_setting_t *kmp_library =
5394 __kmp_stg_find(
"KMP_LIBRARY");
5395 kmp_setting_t *omp_wait_policy =
5396 __kmp_stg_find(
"OMP_WAIT_POLICY");
5399 static kmp_setting_t *
volatile rivals[3];
5400 static kmp_stg_wp_data_t kmp_data = {0, CCAST(kmp_setting_t **, rivals)};
5401 static kmp_stg_wp_data_t omp_data = {1, CCAST(kmp_setting_t **, rivals)};
5404 rivals[i++] = kmp_library;
5405 if (omp_wait_policy != NULL) {
5406 rivals[i++] = omp_wait_policy;
5410 kmp_library->data = &kmp_data;
5411 if (omp_wait_policy != NULL) {
5412 omp_wait_policy->data = &omp_data;
5417 kmp_setting_t *kmp_device_thread_limit =
5418 __kmp_stg_find(
"KMP_DEVICE_THREAD_LIMIT");
5419 kmp_setting_t *kmp_all_threads =
5420 __kmp_stg_find(
"KMP_ALL_THREADS");
5423 static kmp_setting_t *
volatile rivals[3];
5426 rivals[i++] = kmp_device_thread_limit;
5427 rivals[i++] = kmp_all_threads;
5430 kmp_device_thread_limit->data = CCAST(kmp_setting_t **, rivals);
5431 kmp_all_threads->data = CCAST(kmp_setting_t **, rivals);
5436 kmp_setting_t *kmp_hw_subset = __kmp_stg_find(
"KMP_HW_SUBSET");
5438 kmp_setting_t *kmp_place_threads = __kmp_stg_find(
"KMP_PLACE_THREADS");
5441 static kmp_setting_t *
volatile rivals[3];
5444 rivals[i++] = kmp_hw_subset;
5445 rivals[i++] = kmp_place_threads;
5448 kmp_hw_subset->data = CCAST(kmp_setting_t **, rivals);
5449 kmp_place_threads->data = CCAST(kmp_setting_t **, rivals);
5452 #if KMP_AFFINITY_SUPPORTED
5454 kmp_setting_t *kmp_affinity =
5455 __kmp_stg_find(
"KMP_AFFINITY");
5456 KMP_DEBUG_ASSERT(kmp_affinity != NULL);
5458 #ifdef KMP_GOMP_COMPAT
5459 kmp_setting_t *gomp_cpu_affinity =
5460 __kmp_stg_find(
"GOMP_CPU_AFFINITY");
5461 KMP_DEBUG_ASSERT(gomp_cpu_affinity != NULL);
5464 kmp_setting_t *omp_proc_bind =
5465 __kmp_stg_find(
"OMP_PROC_BIND");
5466 KMP_DEBUG_ASSERT(omp_proc_bind != NULL);
5469 static kmp_setting_t *
volatile rivals[4];
5472 rivals[i++] = kmp_affinity;
5474 #ifdef KMP_GOMP_COMPAT
5475 rivals[i++] = gomp_cpu_affinity;
5476 gomp_cpu_affinity->data = CCAST(kmp_setting_t **, rivals);
5479 rivals[i++] = omp_proc_bind;
5480 omp_proc_bind->data = CCAST(kmp_setting_t **, rivals);
5483 static kmp_setting_t *
volatile places_rivals[4];
5486 kmp_setting_t *omp_places = __kmp_stg_find(
"OMP_PLACES");
5487 KMP_DEBUG_ASSERT(omp_places != NULL);
5489 places_rivals[i++] = kmp_affinity;
5490 #ifdef KMP_GOMP_COMPAT
5491 places_rivals[i++] = gomp_cpu_affinity;
5493 places_rivals[i++] = omp_places;
5494 omp_places->data = CCAST(kmp_setting_t **, places_rivals);
5495 places_rivals[i++] = NULL;
5503 kmp_setting_t *kmp_force_red =
5504 __kmp_stg_find(
"KMP_FORCE_REDUCTION");
5505 kmp_setting_t *kmp_determ_red =
5506 __kmp_stg_find(
"KMP_DETERMINISTIC_REDUCTION");
5509 static kmp_setting_t *
volatile rivals[3];
5510 static kmp_stg_fr_data_t force_data = {1,
5511 CCAST(kmp_setting_t **, rivals)};
5512 static kmp_stg_fr_data_t determ_data = {0,
5513 CCAST(kmp_setting_t **, rivals)};
5516 rivals[i++] = kmp_force_red;
5517 if (kmp_determ_red != NULL) {
5518 rivals[i++] = kmp_determ_red;
5522 kmp_force_red->data = &force_data;
5523 if (kmp_determ_red != NULL) {
5524 kmp_determ_red->data = &determ_data;
5533 for (i = 0; i < __kmp_stg_count; ++i) {
5534 __kmp_stg_table[i].set = 0;
5539 static void __kmp_stg_parse(
char const *name,
char const *value) {
5547 if (value != NULL) {
5548 kmp_setting_t *setting = __kmp_stg_find(name);
5549 if (setting != NULL) {
5550 setting->parse(name, value, setting->data);
5551 setting->defined = 1;
5557 static int __kmp_stg_check_rivals(
5560 kmp_setting_t **rivals
5563 if (rivals == NULL) {
5569 for (; strcmp(rivals[i]->name, name) != 0; i++) {
5570 KMP_DEBUG_ASSERT(rivals[i] != NULL);
5572 #if KMP_AFFINITY_SUPPORTED
5573 if (rivals[i] == __kmp_affinity_notype) {
5580 if (rivals[i]->set) {
5581 KMP_WARNING(StgIgnored, name, rivals[i]->name);
5591 static int __kmp_env_toPrint(
char const *name,
int flag) {
5593 kmp_setting_t *setting = __kmp_stg_find(name);
5594 if (setting != NULL) {
5595 rc = setting->defined;
5597 setting->defined = flag;
5603 static void __kmp_aux_env_initialize(kmp_env_blk_t *block) {
5608 value = __kmp_env_blk_var(block,
"OMP_NUM_THREADS");
5610 ompc_set_num_threads(__kmp_dflt_team_nth);
5614 value = __kmp_env_blk_var(block,
"KMP_BLOCKTIME");
5616 kmpc_set_blocktime(__kmp_dflt_blocktime);
5620 value = __kmp_env_blk_var(block,
"OMP_NESTED");
5622 ompc_set_nested(__kmp_dflt_max_active_levels > 1);
5626 value = __kmp_env_blk_var(block,
"OMP_DYNAMIC");
5628 ompc_set_dynamic(__kmp_global.g.g_dynamic);
5632 void __kmp_env_initialize(
char const *
string) {
5634 kmp_env_blk_t block;
5640 if (
string == NULL) {
5642 __kmp_threads_capacity =
5643 __kmp_initial_threads_capacity(__kmp_dflt_team_nth_ub);
5645 __kmp_env_blk_init(&block,
string);
5648 for (i = 0; i < block.count; ++i) {
5649 if ((block.vars[i].name == NULL) || (*block.vars[i].name ==
'\0')) {
5652 if (block.vars[i].value == NULL) {
5655 kmp_setting_t *setting = __kmp_stg_find(block.vars[i].name);
5656 if (setting != NULL) {
5662 blocktime_str = __kmp_env_blk_var(&block,
"KMP_BLOCKTIME");
5666 if (
string == NULL) {
5667 char const *name =
"KMP_WARNINGS";
5668 char const *value = __kmp_env_blk_var(&block, name);
5669 __kmp_stg_parse(name, value);
5672 #if KMP_AFFINITY_SUPPORTED
5678 __kmp_affinity_notype = NULL;
5679 char const *aff_str = __kmp_env_blk_var(&block,
"KMP_AFFINITY");
5680 if (aff_str != NULL) {
5694 #define FIND strcasestr
5697 if ((FIND(aff_str,
"none") == NULL) &&
5698 (FIND(aff_str,
"physical") == NULL) &&
5699 (FIND(aff_str,
"logical") == NULL) &&
5700 (FIND(aff_str,
"compact") == NULL) &&
5701 (FIND(aff_str,
"scatter") == NULL) &&
5702 (FIND(aff_str,
"explicit") == NULL) &&
5703 (FIND(aff_str,
"balanced") == NULL) &&
5704 (FIND(aff_str,
"disabled") == NULL)) {
5705 __kmp_affinity_notype = __kmp_stg_find(
"KMP_AFFINITY");
5710 __kmp_affinity_type = affinity_default;
5711 __kmp_affinity_gran = affinity_gran_default;
5712 __kmp_affinity_top_method = affinity_top_method_default;
5713 __kmp_affinity_respect_mask = affinity_respect_mask_default;
5718 aff_str = __kmp_env_blk_var(&block,
"OMP_PROC_BIND");
5719 if (aff_str != NULL) {
5720 __kmp_affinity_type = affinity_default;
5721 __kmp_affinity_gran = affinity_gran_default;
5722 __kmp_affinity_top_method = affinity_top_method_default;
5723 __kmp_affinity_respect_mask = affinity_respect_mask_default;
5730 if (__kmp_nested_proc_bind.bind_types == NULL) {
5731 __kmp_nested_proc_bind.bind_types =
5732 (kmp_proc_bind_t *)KMP_INTERNAL_MALLOC(
sizeof(kmp_proc_bind_t));
5733 if (__kmp_nested_proc_bind.bind_types == NULL) {
5734 KMP_FATAL(MemoryAllocFailed);
5736 __kmp_nested_proc_bind.size = 1;
5737 __kmp_nested_proc_bind.used = 1;
5738 #if KMP_AFFINITY_SUPPORTED
5739 __kmp_nested_proc_bind.bind_types[0] = proc_bind_default;
5742 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
5749 __kmp_msg_format(kmp_i18n_msg_AffFormatDefault,
"%P",
"%i",
"%n",
"%A");
5750 KMP_DEBUG_ASSERT(KMP_STRLEN(m.str) < KMP_AFFINITY_FORMAT_SIZE);
5752 if (__kmp_affinity_format == NULL) {
5753 __kmp_affinity_format =
5754 (
char *)KMP_INTERNAL_MALLOC(
sizeof(
char) * KMP_AFFINITY_FORMAT_SIZE);
5756 KMP_STRCPY_S(__kmp_affinity_format, KMP_AFFINITY_FORMAT_SIZE, m.str);
5757 __kmp_str_free(&m.str);
5760 for (i = 0; i < block.count; ++i) {
5761 __kmp_stg_parse(block.vars[i].name, block.vars[i].value);
5765 if (!__kmp_init_user_locks) {
5766 if (__kmp_user_lock_kind == lk_default) {
5767 __kmp_user_lock_kind = lk_queuing;
5769 #if KMP_USE_DYNAMIC_LOCK
5770 __kmp_init_dynamic_user_locks();
5772 __kmp_set_user_lock_vptrs(__kmp_user_lock_kind);
5775 KMP_DEBUG_ASSERT(
string != NULL);
5776 KMP_DEBUG_ASSERT(__kmp_user_lock_kind != lk_default);
5781 #if KMP_USE_DYNAMIC_LOCK
5782 __kmp_init_dynamic_user_locks();
5784 __kmp_set_user_lock_vptrs(__kmp_user_lock_kind);
5788 #if KMP_AFFINITY_SUPPORTED
5790 if (!TCR_4(__kmp_init_middle)) {
5794 if ((__kmp_hws_node.num > 0 || __kmp_hws_tile.num > 0 ||
5795 __kmp_affinity_gran == affinity_gran_tile) &&
5796 (__kmp_affinity_top_method == affinity_top_method_default)) {
5797 __kmp_affinity_top_method = affinity_top_method_hwloc;
5802 const char *var =
"KMP_AFFINITY";
5803 KMPAffinity::pick_api();
5808 if (__kmp_affinity_top_method == affinity_top_method_hwloc &&
5809 __kmp_affinity_dispatch->get_api_type() != KMPAffinity::HWLOC) {
5810 KMP_WARNING(AffIgnoringHwloc, var);
5811 __kmp_affinity_top_method = affinity_top_method_all;
5814 if (__kmp_affinity_type == affinity_disabled) {
5815 KMP_AFFINITY_DISABLE();
5816 }
else if (!KMP_AFFINITY_CAPABLE()) {
5817 __kmp_affinity_dispatch->determine_capable(var);
5818 if (!KMP_AFFINITY_CAPABLE()) {
5819 if (__kmp_affinity_verbose ||
5820 (__kmp_affinity_warnings &&
5821 (__kmp_affinity_type != affinity_default) &&
5822 (__kmp_affinity_type != affinity_none) &&
5823 (__kmp_affinity_type != affinity_disabled))) {
5824 KMP_WARNING(AffNotSupported, var);
5826 __kmp_affinity_type = affinity_disabled;
5827 __kmp_affinity_respect_mask = 0;
5828 __kmp_affinity_gran = affinity_gran_fine;
5832 if (__kmp_affinity_type == affinity_disabled) {
5833 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
5834 }
else if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_true) {
5836 __kmp_nested_proc_bind.bind_types[0] = proc_bind_spread;
5839 if (KMP_AFFINITY_CAPABLE()) {
5841 #if KMP_GROUP_AFFINITY
5846 bool exactly_one_group =
false;
5847 if (__kmp_num_proc_groups > 1) {
5849 bool within_one_group;
5852 kmp_affin_mask_t *init_mask;
5853 KMP_CPU_ALLOC(init_mask);
5854 __kmp_get_system_affinity(init_mask, TRUE);
5855 group = __kmp_get_proc_group(init_mask);
5856 within_one_group = (group >= 0);
5859 if (within_one_group) {
5860 DWORD num_bits_in_group = __kmp_GetActiveProcessorCount(group);
5861 DWORD num_bits_in_mask = 0;
5862 for (
int bit = init_mask->begin(); bit != init_mask->end();
5863 bit = init_mask->next(bit))
5865 exactly_one_group = (num_bits_in_group == num_bits_in_mask);
5867 KMP_CPU_FREE(init_mask);
5873 if (((__kmp_num_proc_groups > 1) &&
5874 (__kmp_affinity_type == affinity_default) &&
5875 (__kmp_nested_proc_bind.bind_types[0] == proc_bind_default)) ||
5876 (__kmp_affinity_top_method == affinity_top_method_group)) {
5877 if (__kmp_affinity_respect_mask == affinity_respect_mask_default &&
5878 exactly_one_group) {
5879 __kmp_affinity_respect_mask = FALSE;
5881 if (__kmp_affinity_type == affinity_default) {
5882 __kmp_affinity_type = affinity_compact;
5883 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
5885 if (__kmp_affinity_top_method == affinity_top_method_default) {
5886 if (__kmp_affinity_gran == affinity_gran_default) {
5887 __kmp_affinity_top_method = affinity_top_method_group;
5888 __kmp_affinity_gran = affinity_gran_group;
5889 }
else if (__kmp_affinity_gran == affinity_gran_group) {
5890 __kmp_affinity_top_method = affinity_top_method_group;
5892 __kmp_affinity_top_method = affinity_top_method_all;
5894 }
else if (__kmp_affinity_top_method == affinity_top_method_group) {
5895 if (__kmp_affinity_gran == affinity_gran_default) {
5896 __kmp_affinity_gran = affinity_gran_group;
5897 }
else if ((__kmp_affinity_gran != affinity_gran_group) &&
5898 (__kmp_affinity_gran != affinity_gran_fine) &&
5899 (__kmp_affinity_gran != affinity_gran_thread)) {
5900 const char *str = NULL;
5901 switch (__kmp_affinity_gran) {
5902 case affinity_gran_core:
5905 case affinity_gran_package:
5908 case affinity_gran_node:
5911 case affinity_gran_tile:
5915 KMP_DEBUG_ASSERT(0);
5917 KMP_WARNING(AffGranTopGroup, var, str);
5918 __kmp_affinity_gran = affinity_gran_fine;
5921 if (__kmp_affinity_gran == affinity_gran_default) {
5922 __kmp_affinity_gran = affinity_gran_core;
5923 }
else if (__kmp_affinity_gran == affinity_gran_group) {
5924 const char *str = NULL;
5925 switch (__kmp_affinity_type) {
5926 case affinity_physical:
5929 case affinity_logical:
5932 case affinity_compact:
5935 case affinity_scatter:
5938 case affinity_explicit:
5943 KMP_DEBUG_ASSERT(0);
5945 KMP_WARNING(AffGranGroupType, var, str);
5946 __kmp_affinity_gran = affinity_gran_core;
5954 if (__kmp_affinity_respect_mask == affinity_respect_mask_default) {
5955 #if KMP_GROUP_AFFINITY
5956 if (__kmp_num_proc_groups > 1 && exactly_one_group) {
5957 __kmp_affinity_respect_mask = FALSE;
5961 __kmp_affinity_respect_mask = TRUE;
5964 if ((__kmp_nested_proc_bind.bind_types[0] != proc_bind_intel) &&
5965 (__kmp_nested_proc_bind.bind_types[0] != proc_bind_default)) {
5966 if (__kmp_affinity_type == affinity_default) {
5967 __kmp_affinity_type = affinity_compact;
5968 __kmp_affinity_dups = FALSE;
5970 }
else if (__kmp_affinity_type == affinity_default) {
5971 #if KMP_MIC_SUPPORTED
5972 if (__kmp_mic_type != non_mic) {
5973 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
5977 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
5979 #if KMP_MIC_SUPPORTED
5980 if (__kmp_mic_type != non_mic) {
5981 __kmp_affinity_type = affinity_scatter;
5985 __kmp_affinity_type = affinity_none;
5988 if ((__kmp_affinity_gran == affinity_gran_default) &&
5989 (__kmp_affinity_gran_levels < 0)) {
5990 #if KMP_MIC_SUPPORTED
5991 if (__kmp_mic_type != non_mic) {
5992 __kmp_affinity_gran = affinity_gran_fine;
5996 __kmp_affinity_gran = affinity_gran_core;
5999 if (__kmp_affinity_top_method == affinity_top_method_default) {
6000 __kmp_affinity_top_method = affinity_top_method_all;
6005 K_DIAG(1, (
"__kmp_affinity_type == %d\n", __kmp_affinity_type));
6006 K_DIAG(1, (
"__kmp_affinity_compact == %d\n", __kmp_affinity_compact));
6007 K_DIAG(1, (
"__kmp_affinity_offset == %d\n", __kmp_affinity_offset));
6008 K_DIAG(1, (
"__kmp_affinity_verbose == %d\n", __kmp_affinity_verbose));
6009 K_DIAG(1, (
"__kmp_affinity_warnings == %d\n", __kmp_affinity_warnings));
6010 K_DIAG(1, (
"__kmp_affinity_respect_mask == %d\n",
6011 __kmp_affinity_respect_mask));
6012 K_DIAG(1, (
"__kmp_affinity_gran == %d\n", __kmp_affinity_gran));
6014 KMP_DEBUG_ASSERT(__kmp_affinity_type != affinity_default);
6015 KMP_DEBUG_ASSERT(__kmp_nested_proc_bind.bind_types[0] != proc_bind_default);
6016 K_DIAG(1, (
"__kmp_nested_proc_bind.bind_types[0] == %d\n",
6017 __kmp_nested_proc_bind.bind_types[0]));
6022 if (__kmp_version) {
6023 __kmp_print_version_1();
6028 if (
string != NULL) {
6029 __kmp_aux_env_initialize(&block);
6032 __kmp_env_blk_free(&block);
6038 void __kmp_env_print() {
6040 kmp_env_blk_t block;
6042 kmp_str_buf_t buffer;
6045 __kmp_str_buf_init(&buffer);
6047 __kmp_env_blk_init(&block, NULL);
6048 __kmp_env_blk_sort(&block);
6051 __kmp_str_buf_print(&buffer,
"\n%s\n\n", KMP_I18N_STR(UserSettings));
6052 for (i = 0; i < block.count; ++i) {
6053 char const *name = block.vars[i].name;
6054 char const *value = block.vars[i].value;
6055 if ((KMP_STRLEN(name) > 4 && strncmp(name,
"KMP_", 4) == 0) ||
6056 strncmp(name,
"OMP_", 4) == 0
6057 #ifdef KMP_GOMP_COMPAT
6058 || strncmp(name,
"GOMP_", 5) == 0
6061 __kmp_str_buf_print(&buffer,
" %s=%s\n", name, value);
6064 __kmp_str_buf_print(&buffer,
"\n");
6067 __kmp_str_buf_print(&buffer,
"%s\n\n", KMP_I18N_STR(EffectiveSettings));
6068 for (
int i = 0; i < __kmp_stg_count; ++i) {
6069 if (__kmp_stg_table[i].print != NULL) {
6070 __kmp_stg_table[i].print(&buffer, __kmp_stg_table[i].name,
6071 __kmp_stg_table[i].data);
6075 __kmp_printf(
"%s", buffer.str);
6077 __kmp_env_blk_free(&block);
6078 __kmp_str_buf_free(&buffer);
6084 void __kmp_env_print_2() {
6085 __kmp_display_env_impl(__kmp_display_env, __kmp_display_env_verbose);
6089 void __kmp_display_env_impl(
int display_env,
int display_env_verbose) {
6090 kmp_env_blk_t block;
6091 kmp_str_buf_t buffer;
6093 __kmp_env_format = 1;
6096 __kmp_str_buf_init(&buffer);
6098 __kmp_env_blk_init(&block, NULL);
6099 __kmp_env_blk_sort(&block);
6101 __kmp_str_buf_print(&buffer,
"\n%s\n", KMP_I18N_STR(DisplayEnvBegin));
6102 __kmp_str_buf_print(&buffer,
" _OPENMP='%d'\n", __kmp_openmp_version);
6104 for (
int i = 0; i < __kmp_stg_count; ++i) {
6105 if (__kmp_stg_table[i].print != NULL &&
6107 strncmp(__kmp_stg_table[i].name,
"OMP_", 4) == 0) ||
6108 display_env_verbose)) {
6109 __kmp_stg_table[i].print(&buffer, __kmp_stg_table[i].name,
6110 __kmp_stg_table[i].data);
6114 __kmp_str_buf_print(&buffer,
"%s\n", KMP_I18N_STR(DisplayEnvEnd));
6115 __kmp_str_buf_print(&buffer,
"\n");
6117 __kmp_printf(
"%s", buffer.str);
6119 __kmp_env_blk_free(&block);
6120 __kmp_str_buf_free(&buffer);
@ kmp_sch_modifier_monotonic
@ kmp_sch_modifier_nonmonotonic