17 #include "kmp_affinity.h" 18 #include "kmp_atomic.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 static double __kmp_convert_to_double(
char const *s) {
39 if (KMP_SSCANF(s,
"%lf", &result) < 1) {
47 static unsigned int __kmp_readstr_with_sentinel(
char *dest,
char const *src,
48 size_t len,
char sentinel) {
50 for (i = 0; i < len; i++) {
51 if ((*src ==
'\0') || (*src == sentinel)) {
61 static int __kmp_match_with_sentinel(
char const *a,
char const *b,
size_t len,
69 while (*a && *b && *b != sentinel) {
70 char ca = *a, cb = *b;
72 if (ca >=
'a' && ca <=
'z')
74 if (cb >=
'a' && cb <=
'z')
108 static int __kmp_match_str(
char const *token,
char const *buf,
111 KMP_ASSERT(token != NULL);
112 KMP_ASSERT(buf != NULL);
113 KMP_ASSERT(end != NULL);
115 while (*token && *buf) {
116 char ct = *token, cb = *buf;
118 if (ct >=
'a' && ct <=
'z')
120 if (cb >=
'a' && cb <=
'z')
134 static size_t __kmp_round4k(
size_t size) {
135 size_t _4k = 4 * 1024;
136 if (size & (_4k - 1)) {
138 if (size <= KMP_SIZE_T_MAX - _4k) {
149 int __kmp_convert_to_milliseconds(
char const *data) {
150 int ret, nvalues, factor;
156 if (__kmp_str_match(
"infinit", -1, data))
160 nvalues = KMP_SSCANF(data,
"%lf%c%c", &value, &mult, &extra);
186 factor = 1000 * 60 * 60;
190 factor = 1000 * 24 * 60 * 60;
196 if (value >= ((INT_MAX - 1) / factor))
199 ret = (int)(value * (
double)factor);
204 static int __kmp_strcasecmp_with_sentinel(
char const *a,
char const *b,
210 while (*a && *b && *b != sentinel) {
211 char ca = *a, cb = *b;
213 if (ca >=
'a' && ca <=
'z')
215 if (cb >=
'a' && cb <=
'z')
218 return (
int)(
unsigned char)*a - (
int)(
unsigned char)*b;
223 ? (*b && *b != sentinel)
224 ? (
int)(
unsigned char)*a - (
int)(
unsigned char)*b
226 : (*b && *b != sentinel) ? -1 : 0;
232 typedef struct __kmp_setting kmp_setting_t;
233 typedef struct __kmp_stg_ss_data kmp_stg_ss_data_t;
234 typedef struct __kmp_stg_wp_data kmp_stg_wp_data_t;
235 typedef struct __kmp_stg_fr_data kmp_stg_fr_data_t;
237 typedef void (*kmp_stg_parse_func_t)(
char const *name,
char const *value,
239 typedef void (*kmp_stg_print_func_t)(kmp_str_buf_t *buffer,
char const *name,
242 struct __kmp_setting {
244 kmp_stg_parse_func_t parse;
245 kmp_stg_print_func_t print;
252 struct __kmp_stg_ss_data {
254 kmp_setting_t **rivals;
257 struct __kmp_stg_wp_data {
259 kmp_setting_t **rivals;
262 struct __kmp_stg_fr_data {
264 kmp_setting_t **rivals;
267 static int __kmp_stg_check_rivals(
270 kmp_setting_t **rivals
276 static void __kmp_stg_parse_bool(
char const *name,
char const *value,
278 if (__kmp_str_match_true(value)) {
280 }
else if (__kmp_str_match_false(value)) {
283 __kmp_msg(kmp_ms_warning, KMP_MSG(BadBoolValue, name, value),
284 KMP_HNT(ValidBoolValues), __kmp_msg_null);
288 static void __kmp_stg_parse_size(
char const *name,
char const *value,
289 size_t size_min,
size_t size_max,
290 int *is_specified,
size_t *out,
292 char const *msg = NULL;
294 size_min = __kmp_round4k(size_min);
295 size_max = __kmp_round4k(size_max);
296 #endif // KMP_OS_DARWIN 298 if (is_specified != NULL) {
301 __kmp_str_to_size(value, out, factor, &msg);
303 if (*out > size_max) {
305 msg = KMP_I18N_STR(ValueTooLarge);
306 }
else if (*out < size_min) {
308 msg = KMP_I18N_STR(ValueTooSmall);
311 size_t round4k = __kmp_round4k(*out);
312 if (*out != round4k) {
314 msg = KMP_I18N_STR(NotMultiple4K);
321 if (*out < size_min) {
323 }
else if (*out > size_max) {
330 __kmp_str_buf_init(&buf);
331 __kmp_str_buf_print_size(&buf, *out);
332 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
333 KMP_INFORM(Using_str_Value, name, buf.str);
334 __kmp_str_buf_free(&buf);
339 #if KMP_AFFINITY_SUPPORTED 340 static void __kmp_stg_parse_str(
char const *name,
char const *value,
343 *out = __kmp_str_format(
"%s", value);
347 static void __kmp_stg_parse_int(
355 char const *msg = NULL;
356 kmp_uint64 uint = *out;
357 __kmp_str_to_uint(value, &uint, &msg);
359 if (uint < (
unsigned int)min) {
360 msg = KMP_I18N_STR(ValueTooSmall);
362 }
else if (uint > (
unsigned int)max) {
363 msg = KMP_I18N_STR(ValueTooLarge);
369 if (uint < (
unsigned int)min) {
371 }
else if (uint > (
unsigned int)max) {
378 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
379 __kmp_str_buf_init(&buf);
380 __kmp_str_buf_print(&buf,
"%" KMP_UINT64_SPEC
"", uint);
381 KMP_INFORM(Using_uint64_Value, name, buf.str);
382 __kmp_str_buf_free(&buf);
387 #if KMP_DEBUG_ADAPTIVE_LOCKS 388 static void __kmp_stg_parse_file(
char const *name,
char const *value,
389 char *suffix,
char **out) {
394 t = (
char *)strrchr(value,
'.');
395 hasSuffix = t && __kmp_str_eqf(t, suffix);
396 t = __kmp_str_format(
"%s%s", value, hasSuffix ?
"" : suffix);
397 __kmp_expand_file_name(buffer,
sizeof(buffer), t);
399 *out = __kmp_str_format(
"%s", buffer);
404 static char *par_range_to_print = NULL;
406 static void __kmp_stg_parse_par_range(
char const *name,
char const *value,
407 int *out_range,
char *out_routine,
408 char *out_file,
int *out_lb,
410 size_t len = KMP_STRLEN(value + 1);
411 par_range_to_print = (
char *)KMP_INTERNAL_MALLOC(len + 1);
412 KMP_STRNCPY_S(par_range_to_print, len + 1, value, len + 1);
413 __kmp_par_range = +1;
414 __kmp_par_range_lb = 0;
415 __kmp_par_range_ub = INT_MAX;
418 if ((value == NULL) || (*value ==
'\0')) {
421 if (!__kmp_strcasecmp_with_sentinel(
"routine", value,
'=')) {
422 value = strchr(value,
'=') + 1;
423 len = __kmp_readstr_with_sentinel(out_routine, value,
424 KMP_PAR_RANGE_ROUTINE_LEN - 1,
',');
426 goto par_range_error;
428 value = strchr(value,
',');
434 if (!__kmp_strcasecmp_with_sentinel(
"filename", value,
'=')) {
435 value = strchr(value,
'=') + 1;
436 len = __kmp_readstr_with_sentinel(out_file, value,
437 KMP_PAR_RANGE_FILENAME_LEN - 1,
',');
439 goto par_range_error;
441 value = strchr(value,
',');
447 if ((!__kmp_strcasecmp_with_sentinel(
"range", value,
'=')) ||
448 (!__kmp_strcasecmp_with_sentinel(
"incl_range", value,
'='))) {
449 value = strchr(value,
'=') + 1;
450 if (KMP_SSCANF(value,
"%d:%d", out_lb, out_ub) != 2) {
451 goto par_range_error;
454 value = strchr(value,
',');
460 if (!__kmp_strcasecmp_with_sentinel(
"excl_range", value,
'=')) {
461 value = strchr(value,
'=') + 1;
462 if (KMP_SSCANF(value,
"%d:%d", out_lb, out_ub) != 2) {
463 goto par_range_error;
466 value = strchr(value,
',');
473 KMP_WARNING(ParRangeSyntax, name);
480 int __kmp_initial_threads_capacity(
int req_nproc) {
485 if (nth < (4 * req_nproc))
486 nth = (4 * req_nproc);
487 if (nth < (4 * __kmp_xproc))
488 nth = (4 * __kmp_xproc);
490 if (nth > __kmp_max_nth)
496 int __kmp_default_tp_capacity(
int req_nproc,
int max_nth,
497 int all_threads_specified) {
500 if (all_threads_specified)
504 if (nth < (4 * req_nproc))
505 nth = (4 * req_nproc);
506 if (nth < (4 * __kmp_xproc))
507 nth = (4 * __kmp_xproc);
509 if (nth > __kmp_max_nth)
518 static void __kmp_stg_print_bool(kmp_str_buf_t *buffer,
char const *name,
520 if (__kmp_env_format) {
521 KMP_STR_BUF_PRINT_BOOL;
523 __kmp_str_buf_print(buffer,
" %s=%s\n", name, value ?
"true" :
"false");
527 static void __kmp_stg_print_int(kmp_str_buf_t *buffer,
char const *name,
529 if (__kmp_env_format) {
530 KMP_STR_BUF_PRINT_INT;
532 __kmp_str_buf_print(buffer,
" %s=%d\n", name, value);
536 static void __kmp_stg_print_uint64(kmp_str_buf_t *buffer,
char const *name,
538 if (__kmp_env_format) {
539 KMP_STR_BUF_PRINT_UINT64;
541 __kmp_str_buf_print(buffer,
" %s=%" KMP_UINT64_SPEC
"\n", name, value);
545 static void __kmp_stg_print_str(kmp_str_buf_t *buffer,
char const *name,
547 if (__kmp_env_format) {
548 KMP_STR_BUF_PRINT_STR;
550 __kmp_str_buf_print(buffer,
" %s=%s\n", name, value);
554 static void __kmp_stg_print_size(kmp_str_buf_t *buffer,
char const *name,
556 if (__kmp_env_format) {
557 KMP_STR_BUF_PRINT_NAME_EX(name);
558 __kmp_str_buf_print_size(buffer, value);
559 __kmp_str_buf_print(buffer,
"'\n");
561 __kmp_str_buf_print(buffer,
" %s=", name);
562 __kmp_str_buf_print_size(buffer, value);
563 __kmp_str_buf_print(buffer,
"\n");
574 static void __kmp_stg_parse_all_threads(
char const *name,
char const *value,
577 kmp_setting_t **rivals = (kmp_setting_t **)data;
579 rc = __kmp_stg_check_rivals(name, value, rivals);
583 if (!__kmp_strcasecmp_with_sentinel(
"all", value, 0)) {
584 __kmp_max_nth = __kmp_xproc;
585 __kmp_allThreadsSpecified = 1;
587 __kmp_stg_parse_int(name, value, 1, __kmp_sys_max_nth, &__kmp_max_nth);
588 __kmp_allThreadsSpecified = 0;
590 K_DIAG(1, (
"__kmp_max_nth == %d\n", __kmp_max_nth));
594 static void __kmp_stg_print_all_threads(kmp_str_buf_t *buffer,
char const *name,
596 __kmp_stg_print_int(buffer, name, __kmp_max_nth);
602 static void __kmp_stg_parse_blocktime(
char const *name,
char const *value,
604 __kmp_dflt_blocktime = __kmp_convert_to_milliseconds(value);
605 if (__kmp_dflt_blocktime < 0) {
606 __kmp_dflt_blocktime = KMP_DEFAULT_BLOCKTIME;
607 __kmp_msg(kmp_ms_warning, KMP_MSG(InvalidValue, name, value),
609 KMP_INFORM(Using_int_Value, name, __kmp_dflt_blocktime);
610 __kmp_env_blocktime = FALSE;
612 if (__kmp_dflt_blocktime < KMP_MIN_BLOCKTIME) {
613 __kmp_dflt_blocktime = KMP_MIN_BLOCKTIME;
614 __kmp_msg(kmp_ms_warning, KMP_MSG(SmallValue, name, value),
616 KMP_INFORM(MinValueUsing, name, __kmp_dflt_blocktime);
617 }
else if (__kmp_dflt_blocktime > KMP_MAX_BLOCKTIME) {
618 __kmp_dflt_blocktime = KMP_MAX_BLOCKTIME;
619 __kmp_msg(kmp_ms_warning, KMP_MSG(LargeValue, name, value),
621 KMP_INFORM(MaxValueUsing, name, __kmp_dflt_blocktime);
623 __kmp_env_blocktime = TRUE;
628 __kmp_monitor_wakeups =
629 KMP_WAKEUPS_FROM_BLOCKTIME(__kmp_dflt_blocktime, __kmp_monitor_wakeups);
631 KMP_INTERVALS_FROM_BLOCKTIME(__kmp_dflt_blocktime, __kmp_monitor_wakeups);
633 K_DIAG(1, (
"__kmp_env_blocktime == %d\n", __kmp_env_blocktime));
634 if (__kmp_env_blocktime) {
635 K_DIAG(1, (
"__kmp_dflt_blocktime == %d\n", __kmp_dflt_blocktime));
639 static void __kmp_stg_print_blocktime(kmp_str_buf_t *buffer,
char const *name,
641 __kmp_stg_print_int(buffer, name, __kmp_dflt_blocktime);
647 static void __kmp_stg_parse_duplicate_lib_ok(
char const *name,
648 char const *value,
void *data) {
651 __kmp_stg_parse_bool(name, value, &__kmp_duplicate_library_ok);
654 static void __kmp_stg_print_duplicate_lib_ok(kmp_str_buf_t *buffer,
655 char const *name,
void *data) {
656 __kmp_stg_print_bool(buffer, name, __kmp_duplicate_library_ok);
662 #if KMP_ARCH_X86 || KMP_ARCH_X86_64 664 static void __kmp_stg_parse_inherit_fp_control(
char const *name,
665 char const *value,
void *data) {
666 __kmp_stg_parse_bool(name, value, &__kmp_inherit_fp_control);
669 static void __kmp_stg_print_inherit_fp_control(kmp_str_buf_t *buffer,
670 char const *name,
void *data) {
672 __kmp_stg_print_bool(buffer, name, __kmp_inherit_fp_control);
681 static char const *blocktime_str = NULL;
683 static void __kmp_stg_parse_wait_policy(
char const *name,
char const *value,
686 kmp_stg_wp_data_t *wait = (kmp_stg_wp_data_t *)data;
689 rc = __kmp_stg_check_rivals(name, value, wait->rivals);
695 if (__kmp_str_match(
"ACTIVE", 1, value)) {
696 __kmp_library = library_turnaround;
697 if (blocktime_str == NULL) {
699 __kmp_dflt_blocktime = KMP_MAX_BLOCKTIME;
701 }
else if (__kmp_str_match(
"PASSIVE", 1, value)) {
702 __kmp_library = library_throughput;
703 if (blocktime_str == NULL) {
705 __kmp_dflt_blocktime = 0;
708 KMP_WARNING(StgInvalidValue, name, value);
711 if (__kmp_str_match(
"serial", 1, value)) {
712 __kmp_library = library_serial;
713 }
else if (__kmp_str_match(
"throughput", 2, value)) {
714 __kmp_library = library_throughput;
715 }
else if (__kmp_str_match(
"turnaround", 2, value)) {
716 __kmp_library = library_turnaround;
717 }
else if (__kmp_str_match(
"dedicated", 1, value)) {
718 __kmp_library = library_turnaround;
719 }
else if (__kmp_str_match(
"multiuser", 1, value)) {
720 __kmp_library = library_throughput;
722 KMP_WARNING(StgInvalidValue, name, value);
725 __kmp_aux_set_library(__kmp_library);
729 static void __kmp_stg_print_wait_policy(kmp_str_buf_t *buffer,
char const *name,
732 kmp_stg_wp_data_t *wait = (kmp_stg_wp_data_t *)data;
733 char const *value = NULL;
736 switch (__kmp_library) {
737 case library_turnaround: {
740 case library_throughput: {
745 switch (__kmp_library) {
746 case library_serial: {
749 case library_turnaround: {
750 value =
"turnaround";
752 case library_throughput: {
753 value =
"throughput";
758 __kmp_stg_print_str(buffer, name, value);
767 static void __kmp_stg_parse_monitor_stacksize(
char const *name,
768 char const *value,
void *data) {
769 __kmp_stg_parse_size(name, value, __kmp_sys_min_stksize, KMP_MAX_STKSIZE,
770 NULL, &__kmp_monitor_stksize, 1);
773 static void __kmp_stg_print_monitor_stacksize(kmp_str_buf_t *buffer,
774 char const *name,
void *data) {
775 if (__kmp_env_format) {
776 if (__kmp_monitor_stksize > 0)
777 KMP_STR_BUF_PRINT_NAME_EX(name);
779 KMP_STR_BUF_PRINT_NAME;
781 __kmp_str_buf_print(buffer,
" %s", name);
783 if (__kmp_monitor_stksize > 0) {
784 __kmp_str_buf_print_size(buffer, __kmp_monitor_stksize);
786 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
788 if (__kmp_env_format && __kmp_monitor_stksize) {
789 __kmp_str_buf_print(buffer,
"'\n");
792 #endif // KMP_USE_MONITOR 797 static void __kmp_stg_parse_settings(
char const *name,
char const *value,
799 __kmp_stg_parse_bool(name, value, &__kmp_settings);
802 static void __kmp_stg_print_settings(kmp_str_buf_t *buffer,
char const *name,
804 __kmp_stg_print_bool(buffer, name, __kmp_settings);
810 static void __kmp_stg_parse_stackpad(
char const *name,
char const *value,
812 __kmp_stg_parse_int(name,
820 static void __kmp_stg_print_stackpad(kmp_str_buf_t *buffer,
char const *name,
822 __kmp_stg_print_int(buffer, name, __kmp_stkpadding);
828 static void __kmp_stg_parse_stackoffset(
char const *name,
char const *value,
830 __kmp_stg_parse_size(name,
839 static void __kmp_stg_print_stackoffset(kmp_str_buf_t *buffer,
char const *name,
841 __kmp_stg_print_size(buffer, name, __kmp_stkoffset);
847 static void __kmp_stg_parse_stacksize(
char const *name,
char const *value,
850 kmp_stg_ss_data_t *stacksize = (kmp_stg_ss_data_t *)data;
853 rc = __kmp_stg_check_rivals(name, value, stacksize->rivals);
857 __kmp_stg_parse_size(name,
859 __kmp_sys_min_stksize,
871 static void __kmp_stg_print_stacksize(kmp_str_buf_t *buffer,
char const *name,
873 kmp_stg_ss_data_t *stacksize = (kmp_stg_ss_data_t *)data;
874 if (__kmp_env_format) {
875 KMP_STR_BUF_PRINT_NAME_EX(name);
876 __kmp_str_buf_print_size(buffer, (__kmp_stksize % 1024)
877 ? __kmp_stksize / stacksize->factor
879 __kmp_str_buf_print(buffer,
"'\n");
881 __kmp_str_buf_print(buffer,
" %s=", name);
882 __kmp_str_buf_print_size(buffer, (__kmp_stksize % 1024)
883 ? __kmp_stksize / stacksize->factor
885 __kmp_str_buf_print(buffer,
"\n");
892 static void __kmp_stg_parse_version(
char const *name,
char const *value,
894 __kmp_stg_parse_bool(name, value, &__kmp_version);
897 static void __kmp_stg_print_version(kmp_str_buf_t *buffer,
char const *name,
899 __kmp_stg_print_bool(buffer, name, __kmp_version);
905 static void __kmp_stg_parse_warnings(
char const *name,
char const *value,
907 __kmp_stg_parse_bool(name, value, &__kmp_generate_warnings);
908 if (__kmp_generate_warnings != kmp_warnings_off) {
911 __kmp_generate_warnings = kmp_warnings_explicit;
915 static void __kmp_stg_print_warnings(kmp_str_buf_t *buffer,
char const *name,
918 __kmp_stg_print_bool(buffer, name, __kmp_generate_warnings);
924 static void __kmp_stg_parse_nested(
char const *name,
char const *value,
926 __kmp_stg_parse_bool(name, value, &__kmp_dflt_nested);
929 static void __kmp_stg_print_nested(kmp_str_buf_t *buffer,
char const *name,
931 __kmp_stg_print_bool(buffer, name, __kmp_dflt_nested);
934 static void __kmp_parse_nested_num_threads(
const char *var,
const char *env,
935 kmp_nested_nthreads_t *nth_array) {
936 const char *next = env;
937 const char *scan = next;
940 int prev_comma = FALSE;
950 if (((*next <
'0') || (*next >
'9')) && (*next !=
',')) {
951 KMP_WARNING(NthSyntaxError, var, env);
957 if (total == 0 || prev_comma) {
965 if (*next >=
'0' && *next <=
'9') {
969 const char *tmp = next;
971 if ((*next ==
' ' || *next ==
'\t') && (*tmp >=
'0' && *tmp <=
'9')) {
972 KMP_WARNING(NthSpacesNotAllowed, var, env);
977 KMP_DEBUG_ASSERT(total > 0);
979 KMP_WARNING(NthSyntaxError, var, env);
984 if (!nth_array->nth) {
986 nth_array->nth = (
int *)KMP_INTERNAL_MALLOC(
sizeof(
int) * total * 2);
987 if (nth_array->nth == NULL) {
988 KMP_FATAL(MemoryAllocFailed);
990 nth_array->size = total * 2;
992 if (nth_array->size < total) {
995 nth_array->size *= 2;
996 }
while (nth_array->size < total);
998 nth_array->nth = (
int *)KMP_INTERNAL_REALLOC(
999 nth_array->nth,
sizeof(
int) * nth_array->size);
1000 if (nth_array->nth == NULL) {
1001 KMP_FATAL(MemoryAllocFailed);
1005 nth_array->used = total;
1013 if (*scan ==
'\0') {
1023 nth_array->nth[i++] = 0;
1025 }
else if (prev_comma) {
1027 nth_array->nth[i] = nth_array->nth[i - 1];
1036 if (*scan >=
'0' && *scan <=
'9') {
1038 const char *buf = scan;
1039 char const *msg = NULL;
1044 num = __kmp_str_to_int(buf, *scan);
1045 if (num < KMP_MIN_NTH) {
1046 msg = KMP_I18N_STR(ValueTooSmall);
1048 }
else if (num > __kmp_sys_max_nth) {
1049 msg = KMP_I18N_STR(ValueTooLarge);
1050 num = __kmp_sys_max_nth;
1054 KMP_WARNING(ParseSizeIntWarn, var, env, msg);
1055 KMP_INFORM(Using_int_Value, var, num);
1057 nth_array->nth[i++] = num;
1062 static void __kmp_stg_parse_num_threads(
char const *name,
char const *value,
1065 if (!__kmp_strcasecmp_with_sentinel(
"all", value, 0)) {
1067 __kmp_nested_nth.nth = (
int *)KMP_INTERNAL_MALLOC(
sizeof(
int));
1068 __kmp_nested_nth.size = __kmp_nested_nth.used = 1;
1069 __kmp_nested_nth.nth[0] = __kmp_dflt_team_nth = __kmp_dflt_team_nth_ub =
1072 __kmp_parse_nested_num_threads(name, value, &__kmp_nested_nth);
1073 if (__kmp_nested_nth.nth) {
1074 __kmp_dflt_team_nth = __kmp_nested_nth.nth[0];
1075 if (__kmp_dflt_team_nth_ub < __kmp_dflt_team_nth) {
1076 __kmp_dflt_team_nth_ub = __kmp_dflt_team_nth;
1080 K_DIAG(1, (
"__kmp_dflt_team_nth == %d\n", __kmp_dflt_team_nth));
1083 static void __kmp_stg_print_num_threads(kmp_str_buf_t *buffer,
char const *name,
1085 if (__kmp_env_format) {
1086 KMP_STR_BUF_PRINT_NAME;
1088 __kmp_str_buf_print(buffer,
" %s", name);
1090 if (__kmp_nested_nth.used) {
1092 __kmp_str_buf_init(&buf);
1093 for (
int i = 0; i < __kmp_nested_nth.used; i++) {
1094 __kmp_str_buf_print(&buf,
"%d", __kmp_nested_nth.nth[i]);
1095 if (i < __kmp_nested_nth.used - 1) {
1096 __kmp_str_buf_print(&buf,
",");
1099 __kmp_str_buf_print(buffer,
"='%s'\n", buf.str);
1100 __kmp_str_buf_free(&buf);
1102 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
1109 static void __kmp_stg_parse_tasking(
char const *name,
char const *value,
1111 __kmp_stg_parse_int(name, value, 0, (
int)tskm_max,
1112 (
int *)&__kmp_tasking_mode);
1115 static void __kmp_stg_print_tasking(kmp_str_buf_t *buffer,
char const *name,
1117 __kmp_stg_print_int(buffer, name, __kmp_tasking_mode);
1120 static void __kmp_stg_parse_task_stealing(
char const *name,
char const *value,
1122 __kmp_stg_parse_int(name, value, 0, 1,
1123 (
int *)&__kmp_task_stealing_constraint);
1126 static void __kmp_stg_print_task_stealing(kmp_str_buf_t *buffer,
1127 char const *name,
void *data) {
1128 __kmp_stg_print_int(buffer, name, __kmp_task_stealing_constraint);
1131 static void __kmp_stg_parse_max_active_levels(
char const *name,
1132 char const *value,
void *data) {
1133 __kmp_stg_parse_int(name, value, 0, KMP_MAX_ACTIVE_LEVELS_LIMIT,
1134 &__kmp_dflt_max_active_levels);
1137 static void __kmp_stg_print_max_active_levels(kmp_str_buf_t *buffer,
1138 char const *name,
void *data) {
1139 __kmp_stg_print_int(buffer, name, __kmp_dflt_max_active_levels);
1145 static void __kmp_stg_parse_default_device(
char const *name,
char const *value,
1147 __kmp_stg_parse_int(name, value, 0, KMP_MAX_DEFAULT_DEVICE_LIMIT,
1148 &__kmp_default_device);
1151 static void __kmp_stg_print_default_device(kmp_str_buf_t *buffer,
1152 char const *name,
void *data) {
1153 __kmp_stg_print_int(buffer, name, __kmp_default_device);
1160 static void __kmp_stg_parse_max_task_priority(
char const *name,
1161 char const *value,
void *data) {
1162 __kmp_stg_parse_int(name, value, 0, KMP_MAX_TASK_PRIORITY_LIMIT,
1163 &__kmp_max_task_priority);
1166 static void __kmp_stg_print_max_task_priority(kmp_str_buf_t *buffer,
1167 char const *name,
void *data) {
1168 __kmp_stg_print_int(buffer, name, __kmp_max_task_priority);
1173 static void __kmp_stg_parse_taskloop_min_tasks(
char const *name,
1174 char const *value,
void *data) {
1176 __kmp_stg_parse_int(name, value, 0, INT_MAX, &tmp);
1177 __kmp_taskloop_min_tasks = tmp;
1180 static void __kmp_stg_print_taskloop_min_tasks(kmp_str_buf_t *buffer,
1181 char const *name,
void *data) {
1182 __kmp_stg_print_int(buffer, name, __kmp_taskloop_min_tasks);
1184 #endif // OMP_45_ENABLED 1188 static void __kmp_stg_parse_disp_buffers(
char const *name,
char const *value,
1190 if (TCR_4(__kmp_init_serial)) {
1191 KMP_WARNING(EnvSerialWarn, name);
1194 __kmp_stg_parse_int(name, value, 1, KMP_MAX_NTH, &__kmp_dispatch_num_buffers);
1197 static void __kmp_stg_print_disp_buffers(kmp_str_buf_t *buffer,
1198 char const *name,
void *data) {
1199 __kmp_stg_print_int(buffer, name, __kmp_dispatch_num_buffers);
1202 #if KMP_NESTED_HOT_TEAMS 1206 static void __kmp_stg_parse_hot_teams_level(
char const *name,
char const *value,
1208 if (TCR_4(__kmp_init_parallel)) {
1209 KMP_WARNING(EnvParallelWarn, name);
1212 __kmp_stg_parse_int(name, value, 0, KMP_MAX_ACTIVE_LEVELS_LIMIT,
1213 &__kmp_hot_teams_max_level);
1216 static void __kmp_stg_print_hot_teams_level(kmp_str_buf_t *buffer,
1217 char const *name,
void *data) {
1218 __kmp_stg_print_int(buffer, name, __kmp_hot_teams_max_level);
1221 static void __kmp_stg_parse_hot_teams_mode(
char const *name,
char const *value,
1223 if (TCR_4(__kmp_init_parallel)) {
1224 KMP_WARNING(EnvParallelWarn, name);
1227 __kmp_stg_parse_int(name, value, 0, KMP_MAX_ACTIVE_LEVELS_LIMIT,
1228 &__kmp_hot_teams_mode);
1231 static void __kmp_stg_print_hot_teams_mode(kmp_str_buf_t *buffer,
1232 char const *name,
void *data) {
1233 __kmp_stg_print_int(buffer, name, __kmp_hot_teams_mode);
1236 #endif // KMP_NESTED_HOT_TEAMS 1241 #if KMP_HANDLE_SIGNALS 1243 static void __kmp_stg_parse_handle_signals(
char const *name,
char const *value,
1245 __kmp_stg_parse_bool(name, value, &__kmp_handle_signals);
1248 static void __kmp_stg_print_handle_signals(kmp_str_buf_t *buffer,
1249 char const *name,
void *data) {
1250 __kmp_stg_print_bool(buffer, name, __kmp_handle_signals);
1253 #endif // KMP_HANDLE_SIGNALS 1260 #define KMP_STG_X_DEBUG(x) \ 1261 static void __kmp_stg_parse_##x##_debug(char const *name, char const *value, \ 1263 __kmp_stg_parse_int(name, value, 0, INT_MAX, &kmp_##x##_debug); \ 1265 static void __kmp_stg_print_##x##_debug(kmp_str_buf_t *buffer, \ 1266 char const *name, void *data) { \ 1267 __kmp_stg_print_int(buffer, name, kmp_##x##_debug); \ 1277 #undef KMP_STG_X_DEBUG 1279 static void __kmp_stg_parse_debug(
char const *name,
char const *value,
1282 __kmp_stg_parse_int(name, value, 0, INT_MAX, &debug);
1283 if (kmp_a_debug < debug) {
1284 kmp_a_debug = debug;
1286 if (kmp_b_debug < debug) {
1287 kmp_b_debug = debug;
1289 if (kmp_c_debug < debug) {
1290 kmp_c_debug = debug;
1292 if (kmp_d_debug < debug) {
1293 kmp_d_debug = debug;
1295 if (kmp_e_debug < debug) {
1296 kmp_e_debug = debug;
1298 if (kmp_f_debug < debug) {
1299 kmp_f_debug = debug;
1303 static void __kmp_stg_parse_debug_buf(
char const *name,
char const *value,
1305 __kmp_stg_parse_bool(name, value, &__kmp_debug_buf);
1309 if (__kmp_debug_buf) {
1311 int elements = __kmp_debug_buf_lines * __kmp_debug_buf_chars;
1314 __kmp_debug_buffer = (
char *)__kmp_page_allocate(elements *
sizeof(
char));
1315 for (i = 0; i < elements; i += __kmp_debug_buf_chars)
1316 __kmp_debug_buffer[i] =
'\0';
1318 __kmp_debug_count = 0;
1320 K_DIAG(1, (
"__kmp_debug_buf = %d\n", __kmp_debug_buf));
1323 static void __kmp_stg_print_debug_buf(kmp_str_buf_t *buffer,
char const *name,
1325 __kmp_stg_print_bool(buffer, name, __kmp_debug_buf);
1328 static void __kmp_stg_parse_debug_buf_atomic(
char const *name,
1329 char const *value,
void *data) {
1330 __kmp_stg_parse_bool(name, value, &__kmp_debug_buf_atomic);
1333 static void __kmp_stg_print_debug_buf_atomic(kmp_str_buf_t *buffer,
1334 char const *name,
void *data) {
1335 __kmp_stg_print_bool(buffer, name, __kmp_debug_buf_atomic);
1338 static void __kmp_stg_parse_debug_buf_chars(
char const *name,
char const *value,
1340 __kmp_stg_parse_int(name, value, KMP_DEBUG_BUF_CHARS_MIN, INT_MAX,
1341 &__kmp_debug_buf_chars);
1344 static void __kmp_stg_print_debug_buf_chars(kmp_str_buf_t *buffer,
1345 char const *name,
void *data) {
1346 __kmp_stg_print_int(buffer, name, __kmp_debug_buf_chars);
1349 static void __kmp_stg_parse_debug_buf_lines(
char const *name,
char const *value,
1351 __kmp_stg_parse_int(name, value, KMP_DEBUG_BUF_LINES_MIN, INT_MAX,
1352 &__kmp_debug_buf_lines);
1355 static void __kmp_stg_print_debug_buf_lines(kmp_str_buf_t *buffer,
1356 char const *name,
void *data) {
1357 __kmp_stg_print_int(buffer, name, __kmp_debug_buf_lines);
1360 static void __kmp_stg_parse_diag(
char const *name,
char const *value,
1362 __kmp_stg_parse_int(name, value, 0, INT_MAX, &kmp_diag);
1365 static void __kmp_stg_print_diag(kmp_str_buf_t *buffer,
char const *name,
1367 __kmp_stg_print_int(buffer, name, kmp_diag);
1375 static void __kmp_stg_parse_align_alloc(
char const *name,
char const *value,
1377 __kmp_stg_parse_size(name, value, CACHE_LINE, INT_MAX, NULL,
1378 &__kmp_align_alloc, 1);
1381 static void __kmp_stg_print_align_alloc(kmp_str_buf_t *buffer,
char const *name,
1383 __kmp_stg_print_size(buffer, name, __kmp_align_alloc);
1392 static void __kmp_stg_parse_barrier_branch_bit(
char const *name,
1393 char const *value,
void *data) {
1397 for (
int i = bs_plain_barrier; i < bs_last_barrier; i++) {
1398 var = __kmp_barrier_branch_bit_env_name[i];
1399 if ((strcmp(var, name) == 0) && (value != 0)) {
1402 comma = CCAST(
char *, strchr(value,
','));
1403 __kmp_barrier_gather_branch_bits[i] =
1404 (kmp_uint32)__kmp_str_to_int(value,
',');
1406 if (comma == NULL) {
1407 __kmp_barrier_release_branch_bits[i] = __kmp_barrier_release_bb_dflt;
1409 __kmp_barrier_release_branch_bits[i] =
1410 (kmp_uint32)__kmp_str_to_int(comma + 1, 0);
1412 if (__kmp_barrier_release_branch_bits[i] > KMP_MAX_BRANCH_BITS) {
1413 __kmp_msg(kmp_ms_warning,
1414 KMP_MSG(BarrReleaseValueInvalid, name, comma + 1),
1416 __kmp_barrier_release_branch_bits[i] = __kmp_barrier_release_bb_dflt;
1419 if (__kmp_barrier_gather_branch_bits[i] > KMP_MAX_BRANCH_BITS) {
1420 KMP_WARNING(BarrGatherValueInvalid, name, value);
1421 KMP_INFORM(Using_uint_Value, name, __kmp_barrier_gather_bb_dflt);
1422 __kmp_barrier_gather_branch_bits[i] = __kmp_barrier_gather_bb_dflt;
1425 K_DIAG(1, (
"%s == %d,%d\n", __kmp_barrier_branch_bit_env_name[i],
1426 __kmp_barrier_gather_branch_bits[i],
1427 __kmp_barrier_release_branch_bits[i]))
1431 static void __kmp_stg_print_barrier_branch_bit(kmp_str_buf_t *buffer,
1432 char const *name,
void *data) {
1434 for (
int i = bs_plain_barrier; i < bs_last_barrier; i++) {
1435 var = __kmp_barrier_branch_bit_env_name[i];
1436 if (strcmp(var, name) == 0) {
1437 if (__kmp_env_format) {
1438 KMP_STR_BUF_PRINT_NAME_EX(__kmp_barrier_branch_bit_env_name[i]);
1440 __kmp_str_buf_print(buffer,
" %s='",
1441 __kmp_barrier_branch_bit_env_name[i]);
1443 __kmp_str_buf_print(buffer,
"%d,%d'\n",
1444 __kmp_barrier_gather_branch_bits[i],
1445 __kmp_barrier_release_branch_bits[i]);
1457 static void __kmp_stg_parse_barrier_pattern(
char const *name,
char const *value,
1462 for (
int i = bs_plain_barrier; i < bs_last_barrier; i++) {
1463 var = __kmp_barrier_pattern_env_name[i];
1465 if ((strcmp(var, name) == 0) && (value != 0)) {
1467 char *comma = CCAST(
char *, strchr(value,
','));
1470 for (j = bp_linear_bar; j < bp_last_bar; j++) {
1471 if (__kmp_match_with_sentinel(__kmp_barrier_pattern_name[j], value, 1,
1473 __kmp_barrier_gather_pattern[i] = (kmp_bar_pat_e)j;
1477 if (j == bp_last_bar) {
1478 KMP_WARNING(BarrGatherValueInvalid, name, value);
1479 KMP_INFORM(Using_str_Value, name,
1480 __kmp_barrier_pattern_name[bp_linear_bar]);
1484 if (comma != NULL) {
1485 for (j = bp_linear_bar; j < bp_last_bar; j++) {
1486 if (__kmp_str_match(__kmp_barrier_pattern_name[j], 1, comma + 1)) {
1487 __kmp_barrier_release_pattern[i] = (kmp_bar_pat_e)j;
1491 if (j == bp_last_bar) {
1492 __kmp_msg(kmp_ms_warning,
1493 KMP_MSG(BarrReleaseValueInvalid, name, comma + 1),
1495 KMP_INFORM(Using_str_Value, name,
1496 __kmp_barrier_pattern_name[bp_linear_bar]);
1503 static void __kmp_stg_print_barrier_pattern(kmp_str_buf_t *buffer,
1504 char const *name,
void *data) {
1506 for (
int i = bs_plain_barrier; i < bs_last_barrier; i++) {
1507 var = __kmp_barrier_pattern_env_name[i];
1508 if (strcmp(var, name) == 0) {
1509 int j = __kmp_barrier_gather_pattern[i];
1510 int k = __kmp_barrier_release_pattern[i];
1511 if (__kmp_env_format) {
1512 KMP_STR_BUF_PRINT_NAME_EX(__kmp_barrier_pattern_env_name[i]);
1514 __kmp_str_buf_print(buffer,
" %s='",
1515 __kmp_barrier_pattern_env_name[i]);
1517 __kmp_str_buf_print(buffer,
"%s,%s'\n", __kmp_barrier_pattern_name[j],
1518 __kmp_barrier_pattern_name[k]);
1526 static void __kmp_stg_parse_abort_delay(
char const *name,
char const *value,
1530 int delay = __kmp_abort_delay / 1000;
1531 __kmp_stg_parse_int(name, value, 0, INT_MAX / 1000, &delay);
1532 __kmp_abort_delay = delay * 1000;
1535 static void __kmp_stg_print_abort_delay(kmp_str_buf_t *buffer,
char const *name,
1537 __kmp_stg_print_int(buffer, name, __kmp_abort_delay);
1543 static void __kmp_stg_parse_cpuinfo_file(
char const *name,
char const *value,
1545 #if KMP_AFFINITY_SUPPORTED 1546 __kmp_stg_parse_str(name, value, &__kmp_cpuinfo_file);
1547 K_DIAG(1, (
"__kmp_cpuinfo_file == %s\n", __kmp_cpuinfo_file));
1551 static void __kmp_stg_print_cpuinfo_file(kmp_str_buf_t *buffer,
1552 char const *name,
void *data) {
1553 #if KMP_AFFINITY_SUPPORTED 1554 if (__kmp_env_format) {
1555 KMP_STR_BUF_PRINT_NAME;
1557 __kmp_str_buf_print(buffer,
" %s", name);
1559 if (__kmp_cpuinfo_file) {
1560 __kmp_str_buf_print(buffer,
"='%s'\n", __kmp_cpuinfo_file);
1562 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
1570 static void __kmp_stg_parse_force_reduction(
char const *name,
char const *value,
1572 kmp_stg_fr_data_t *reduction = (kmp_stg_fr_data_t *)data;
1575 rc = __kmp_stg_check_rivals(name, value, reduction->rivals);
1579 if (reduction->force) {
1581 if (__kmp_str_match(
"critical", 0, value))
1582 __kmp_force_reduction_method = critical_reduce_block;
1583 else if (__kmp_str_match(
"atomic", 0, value))
1584 __kmp_force_reduction_method = atomic_reduce_block;
1585 else if (__kmp_str_match(
"tree", 0, value))
1586 __kmp_force_reduction_method = tree_reduce_block;
1588 KMP_FATAL(UnknownForceReduction, name, value);
1592 __kmp_stg_parse_bool(name, value, &__kmp_determ_red);
1593 if (__kmp_determ_red) {
1594 __kmp_force_reduction_method = tree_reduce_block;
1596 __kmp_force_reduction_method = reduction_method_not_defined;
1599 K_DIAG(1, (
"__kmp_force_reduction_method == %d\n",
1600 __kmp_force_reduction_method));
1603 static void __kmp_stg_print_force_reduction(kmp_str_buf_t *buffer,
1604 char const *name,
void *data) {
1606 kmp_stg_fr_data_t *reduction = (kmp_stg_fr_data_t *)data;
1607 if (reduction->force) {
1608 if (__kmp_force_reduction_method == critical_reduce_block) {
1609 __kmp_stg_print_str(buffer, name,
"critical");
1610 }
else if (__kmp_force_reduction_method == atomic_reduce_block) {
1611 __kmp_stg_print_str(buffer, name,
"atomic");
1612 }
else if (__kmp_force_reduction_method == tree_reduce_block) {
1613 __kmp_stg_print_str(buffer, name,
"tree");
1615 if (__kmp_env_format) {
1616 KMP_STR_BUF_PRINT_NAME;
1618 __kmp_str_buf_print(buffer,
" %s", name);
1620 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
1623 __kmp_stg_print_bool(buffer, name, __kmp_determ_red);
1631 static void __kmp_stg_parse_storage_map(
char const *name,
char const *value,
1633 if (__kmp_str_match(
"verbose", 1, value)) {
1634 __kmp_storage_map = TRUE;
1635 __kmp_storage_map_verbose = TRUE;
1636 __kmp_storage_map_verbose_specified = TRUE;
1639 __kmp_storage_map_verbose = FALSE;
1640 __kmp_stg_parse_bool(name, value, &__kmp_storage_map);
1644 static void __kmp_stg_print_storage_map(kmp_str_buf_t *buffer,
char const *name,
1646 if (__kmp_storage_map_verbose || __kmp_storage_map_verbose_specified) {
1647 __kmp_stg_print_str(buffer, name,
"verbose");
1649 __kmp_stg_print_bool(buffer, name, __kmp_storage_map);
1656 static void __kmp_stg_parse_all_threadprivate(
char const *name,
1657 char const *value,
void *data) {
1658 __kmp_stg_parse_int(name, value,
1659 __kmp_allThreadsSpecified ? __kmp_max_nth : 1,
1660 __kmp_max_nth, &__kmp_tp_capacity);
1663 static void __kmp_stg_print_all_threadprivate(kmp_str_buf_t *buffer,
1664 char const *name,
void *data) {
1665 __kmp_stg_print_int(buffer, name, __kmp_tp_capacity);
1671 static void __kmp_stg_parse_foreign_threads_threadprivate(
char const *name,
1674 __kmp_stg_parse_bool(name, value, &__kmp_foreign_tp);
1677 static void __kmp_stg_print_foreign_threads_threadprivate(kmp_str_buf_t *buffer,
1680 __kmp_stg_print_bool(buffer, name, __kmp_foreign_tp);
1686 #if KMP_AFFINITY_SUPPORTED 1688 static int __kmp_parse_affinity_proc_id_list(
const char *var,
const char *env,
1689 const char **nextEnv,
1691 const char *scan = env;
1692 const char *next = scan;
1698 int start, end, stride;
1702 if (*next ==
'\0') {
1713 if ((*next <
'0') || (*next >
'9')) {
1714 KMP_WARNING(AffSyntaxError, var);
1718 num = __kmp_str_to_int(scan, *next);
1719 KMP_ASSERT(num >= 0);
1737 if ((*next <
'0') || (*next >
'9')) {
1738 KMP_WARNING(AffSyntaxError, var);
1743 num = __kmp_str_to_int(scan, *next);
1744 KMP_ASSERT(num >= 0);
1757 if ((*next <
'0') || (*next >
'9')) {
1759 KMP_WARNING(AffSyntaxError, var);
1767 start = __kmp_str_to_int(scan, *next);
1768 KMP_ASSERT(start >= 0);
1787 if ((*next <
'0') || (*next >
'9')) {
1788 KMP_WARNING(AffSyntaxError, var);
1792 end = __kmp_str_to_int(scan, *next);
1793 KMP_ASSERT(end >= 0);
1810 if ((*next <
'0') || (*next >
'9')) {
1811 KMP_WARNING(AffSyntaxError, var);
1815 stride = __kmp_str_to_int(scan, *next);
1816 KMP_ASSERT(stride >= 0);
1822 KMP_WARNING(AffZeroStride, var);
1827 KMP_WARNING(AffStartGreaterEnd, var, start, end);
1832 KMP_WARNING(AffStrideLessZero, var, start, end);
1836 if ((end - start) / stride > 65536) {
1837 KMP_WARNING(AffRangeTooBig, var, end, start, stride);
1854 int len = next - env;
1855 char *retlist = (
char *)__kmp_allocate((len + 1) *
sizeof(char));
1856 KMP_MEMCPY_S(retlist, (len + 1) *
sizeof(
char), env, len *
sizeof(
char));
1857 retlist[len] =
'\0';
1858 *proclist = retlist;
1865 static kmp_setting_t *__kmp_affinity_notype = NULL;
1867 static void __kmp_parse_affinity_env(
char const *name,
char const *value,
1868 enum affinity_type *out_type,
1869 char **out_proclist,
int *out_verbose,
1870 int *out_warn,
int *out_respect,
1871 enum affinity_gran *out_gran,
1872 int *out_gran_levels,
int *out_dups,
1873 int *out_compact,
int *out_offset) {
1874 char *buffer = NULL;
1884 int max_proclist = 0;
1891 KMP_ASSERT(value != NULL);
1893 if (TCR_4(__kmp_init_middle)) {
1894 KMP_WARNING(EnvMiddleWarn, name);
1895 __kmp_env_toPrint(name, 0);
1898 __kmp_env_toPrint(name, 1);
1901 __kmp_str_format(
"%s", value);
1911 #define EMIT_WARN(skip, errlist) \ 1915 SKIP_TO(next, ','); \ 1919 KMP_WARNING errlist; \ 1928 #define _set_param(_guard, _var, _val) \ 1930 if (_guard == 0) { \ 1933 EMIT_WARN(FALSE, (AffParamDefined, name, start)); \ 1938 #define set_type(val) _set_param(type, *out_type, val) 1939 #define set_verbose(val) _set_param(verbose, *out_verbose, val) 1940 #define set_warnings(val) _set_param(warnings, *out_warn, val) 1941 #define set_respect(val) _set_param(respect, *out_respect, val) 1942 #define set_dups(val) _set_param(dups, *out_dups, val) 1943 #define set_proclist(val) _set_param(proclist, *out_proclist, val) 1945 #define set_gran(val, levels) \ 1949 *out_gran_levels = levels; \ 1951 EMIT_WARN(FALSE, (AffParamDefined, name, start)); \ 1957 KMP_DEBUG_ASSERT((__kmp_nested_proc_bind.bind_types != NULL) &&
1958 (__kmp_nested_proc_bind.used > 0));
1961 while (*buf !=
'\0') {
1964 if (__kmp_match_str(
"none", buf, CCAST(
const char **, &next))) {
1965 set_type(affinity_none);
1967 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
1970 }
else if (__kmp_match_str(
"scatter", buf, CCAST(
const char **, &next))) {
1971 set_type(affinity_scatter);
1973 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
1976 }
else if (__kmp_match_str(
"compact", buf, CCAST(
const char **, &next))) {
1977 set_type(affinity_compact);
1979 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
1982 }
else if (__kmp_match_str(
"logical", buf, CCAST(
const char **, &next))) {
1983 set_type(affinity_logical);
1985 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
1988 }
else if (__kmp_match_str(
"physical", buf, CCAST(
const char **, &next))) {
1989 set_type(affinity_physical);
1991 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
1994 }
else if (__kmp_match_str(
"explicit", buf, CCAST(
const char **, &next))) {
1995 set_type(affinity_explicit);
1997 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2000 }
else if (__kmp_match_str(
"balanced", buf, CCAST(
const char **, &next))) {
2001 set_type(affinity_balanced);
2003 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2006 }
else if (__kmp_match_str(
"disabled", buf, CCAST(
const char **, &next))) {
2007 set_type(affinity_disabled);
2009 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
2012 }
else if (__kmp_match_str(
"verbose", buf, CCAST(
const char **, &next))) {
2015 }
else if (__kmp_match_str(
"noverbose", buf, CCAST(
const char **, &next))) {
2018 }
else if (__kmp_match_str(
"warnings", buf, CCAST(
const char **, &next))) {
2021 }
else if (__kmp_match_str(
"nowarnings", buf,
2022 CCAST(
const char **, &next))) {
2023 set_warnings(FALSE);
2025 }
else if (__kmp_match_str(
"respect", buf, CCAST(
const char **, &next))) {
2028 }
else if (__kmp_match_str(
"norespect", buf, CCAST(
const char **, &next))) {
2031 }
else if (__kmp_match_str(
"duplicates", buf,
2032 CCAST(
const char **, &next)) ||
2033 __kmp_match_str(
"dups", buf, CCAST(
const char **, &next))) {
2036 }
else if (__kmp_match_str(
"noduplicates", buf,
2037 CCAST(
const char **, &next)) ||
2038 __kmp_match_str(
"nodups", buf, CCAST(
const char **, &next))) {
2041 }
else if (__kmp_match_str(
"granularity", buf,
2042 CCAST(
const char **, &next)) ||
2043 __kmp_match_str(
"gran", buf, CCAST(
const char **, &next))) {
2046 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2053 if (__kmp_match_str(
"fine", buf, CCAST(
const char **, &next))) {
2054 set_gran(affinity_gran_fine, -1);
2056 }
else if (__kmp_match_str(
"thread", buf, CCAST(
const char **, &next))) {
2057 set_gran(affinity_gran_thread, -1);
2059 }
else if (__kmp_match_str(
"core", buf, CCAST(
const char **, &next))) {
2060 set_gran(affinity_gran_core, -1);
2062 }
else if (__kmp_match_str(
"package", buf, CCAST(
const char **, &next))) {
2063 set_gran(affinity_gran_package, -1);
2065 }
else if (__kmp_match_str(
"node", buf, CCAST(
const char **, &next))) {
2066 set_gran(affinity_gran_node, -1);
2068 #if KMP_GROUP_AFFINITY 2069 }
else if (__kmp_match_str(
"group", buf, CCAST(
const char **, &next))) {
2070 set_gran(affinity_gran_group, -1);
2073 }
else if ((*buf >=
'0') && (*buf <=
'9')) {
2077 n = __kmp_str_to_int(buf, *next);
2080 set_gran(affinity_gran_default, n);
2082 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2085 }
else if (__kmp_match_str(
"proclist", buf, CCAST(
const char **, &next))) {
2086 char *temp_proclist;
2090 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2096 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2101 if (!__kmp_parse_affinity_proc_id_list(
2102 name, buf, CCAST(
const char **, &next), &temp_proclist)) {
2114 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2118 set_proclist(temp_proclist);
2119 }
else if ((*buf >=
'0') && (*buf <=
'9')) {
2124 n = __kmp_str_to_int(buf, *next);
2130 KMP_WARNING(AffManyParams, name, start);
2134 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2142 }
else if (*next !=
'\0') {
2143 const char *temp = next;
2144 EMIT_WARN(TRUE, (ParseExtraCharsWarn, name, temp));
2156 #undef set_granularity 2158 __kmp_str_free(CCAST(
const char **, &buffer));
2162 KMP_WARNING(AffProcListNoType, name);
2163 *out_type = affinity_explicit;
2165 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2167 }
else if (*out_type != affinity_explicit) {
2168 KMP_WARNING(AffProcListNotExplicit, name);
2169 KMP_ASSERT(*out_proclist != NULL);
2170 KMP_INTERNAL_FREE(*out_proclist);
2171 *out_proclist = NULL;
2174 switch (*out_type) {
2175 case affinity_logical:
2176 case affinity_physical: {
2178 *out_offset = number[0];
2181 KMP_WARNING(AffManyParamsForLogic, name, number[1]);
2184 case affinity_balanced: {
2186 *out_compact = number[0];
2189 *out_offset = number[1];
2192 if (__kmp_affinity_gran == affinity_gran_default) {
2193 #if KMP_MIC_SUPPORTED 2194 if (__kmp_mic_type != non_mic) {
2195 if (__kmp_affinity_verbose || __kmp_affinity_warnings) {
2196 KMP_WARNING(AffGranUsing,
"KMP_AFFINITY",
"fine");
2198 __kmp_affinity_gran = affinity_gran_fine;
2202 if (__kmp_affinity_verbose || __kmp_affinity_warnings) {
2203 KMP_WARNING(AffGranUsing,
"KMP_AFFINITY",
"core");
2205 __kmp_affinity_gran = affinity_gran_core;
2209 case affinity_scatter:
2210 case affinity_compact: {
2212 *out_compact = number[0];
2215 *out_offset = number[1];
2218 case affinity_explicit: {
2219 if (*out_proclist == NULL) {
2220 KMP_WARNING(AffNoProcList, name);
2221 __kmp_affinity_type = affinity_none;
2224 KMP_WARNING(AffNoParam, name,
"explicit");
2227 case affinity_none: {
2229 KMP_WARNING(AffNoParam, name,
"none");
2232 case affinity_disabled: {
2234 KMP_WARNING(AffNoParam, name,
"disabled");
2237 case affinity_default: {
2239 KMP_WARNING(AffNoParam, name,
"default");
2242 default: { KMP_ASSERT(0); };
2246 static void __kmp_stg_parse_affinity(
char const *name,
char const *value,
2248 kmp_setting_t **rivals = (kmp_setting_t **)data;
2251 rc = __kmp_stg_check_rivals(name, value, rivals);
2256 __kmp_parse_affinity_env(name, value, &__kmp_affinity_type,
2257 &__kmp_affinity_proclist, &__kmp_affinity_verbose,
2258 &__kmp_affinity_warnings,
2259 &__kmp_affinity_respect_mask, &__kmp_affinity_gran,
2260 &__kmp_affinity_gran_levels, &__kmp_affinity_dups,
2261 &__kmp_affinity_compact, &__kmp_affinity_offset);
2265 static void __kmp_stg_print_affinity(kmp_str_buf_t *buffer,
char const *name,
2267 if (__kmp_env_format) {
2268 KMP_STR_BUF_PRINT_NAME_EX(name);
2270 __kmp_str_buf_print(buffer,
" %s='", name);
2272 if (__kmp_affinity_verbose) {
2273 __kmp_str_buf_print(buffer,
"%s,",
"verbose");
2275 __kmp_str_buf_print(buffer,
"%s,",
"noverbose");
2277 if (__kmp_affinity_warnings) {
2278 __kmp_str_buf_print(buffer,
"%s,",
"warnings");
2280 __kmp_str_buf_print(buffer,
"%s,",
"nowarnings");
2282 if (KMP_AFFINITY_CAPABLE()) {
2283 if (__kmp_affinity_respect_mask) {
2284 __kmp_str_buf_print(buffer,
"%s,",
"respect");
2286 __kmp_str_buf_print(buffer,
"%s,",
"norespect");
2288 switch (__kmp_affinity_gran) {
2289 case affinity_gran_default:
2290 __kmp_str_buf_print(buffer,
"%s",
"granularity=default,");
2292 case affinity_gran_fine:
2293 __kmp_str_buf_print(buffer,
"%s",
"granularity=fine,");
2295 case affinity_gran_thread:
2296 __kmp_str_buf_print(buffer,
"%s",
"granularity=thread,");
2298 case affinity_gran_core:
2299 __kmp_str_buf_print(buffer,
"%s",
"granularity=core,");
2301 case affinity_gran_package:
2302 __kmp_str_buf_print(buffer,
"%s",
"granularity=package,");
2304 case affinity_gran_node:
2305 __kmp_str_buf_print(buffer,
"%s",
"granularity=node,");
2307 #if KMP_GROUP_AFFINITY 2308 case affinity_gran_group:
2309 __kmp_str_buf_print(buffer,
"%s",
"granularity=group,");
2314 if (!KMP_AFFINITY_CAPABLE()) {
2315 __kmp_str_buf_print(buffer,
"%s",
"disabled");
2317 switch (__kmp_affinity_type) {
2319 __kmp_str_buf_print(buffer,
"%s",
"none");
2321 case affinity_physical:
2322 __kmp_str_buf_print(buffer,
"%s,%d",
"physical", __kmp_affinity_offset);
2324 case affinity_logical:
2325 __kmp_str_buf_print(buffer,
"%s,%d",
"logical", __kmp_affinity_offset);
2327 case affinity_compact:
2328 __kmp_str_buf_print(buffer,
"%s,%d,%d",
"compact", __kmp_affinity_compact,
2329 __kmp_affinity_offset);
2331 case affinity_scatter:
2332 __kmp_str_buf_print(buffer,
"%s,%d,%d",
"scatter", __kmp_affinity_compact,
2333 __kmp_affinity_offset);
2335 case affinity_explicit:
2336 __kmp_str_buf_print(buffer,
"%s=[%s],%s",
"proclist",
2337 __kmp_affinity_proclist,
"explicit");
2339 case affinity_balanced:
2340 __kmp_str_buf_print(buffer,
"%s,%d,%d",
"balanced",
2341 __kmp_affinity_compact, __kmp_affinity_offset);
2343 case affinity_disabled:
2344 __kmp_str_buf_print(buffer,
"%s",
"disabled");
2346 case affinity_default:
2347 __kmp_str_buf_print(buffer,
"%s",
"default");
2350 __kmp_str_buf_print(buffer,
"%s",
"<unknown>");
2353 __kmp_str_buf_print(buffer,
"'\n");
2356 #ifdef KMP_GOMP_COMPAT 2358 static void __kmp_stg_parse_gomp_cpu_affinity(
char const *name,
2359 char const *value,
void *data) {
2360 const char *next = NULL;
2361 char *temp_proclist;
2362 kmp_setting_t **rivals = (kmp_setting_t **)data;
2365 rc = __kmp_stg_check_rivals(name, value, rivals);
2370 if (TCR_4(__kmp_init_middle)) {
2371 KMP_WARNING(EnvMiddleWarn, name);
2372 __kmp_env_toPrint(name, 0);
2376 __kmp_env_toPrint(name, 1);
2378 if (__kmp_parse_affinity_proc_id_list(name, value, &next, &temp_proclist)) {
2380 if (*next ==
'\0') {
2382 __kmp_affinity_proclist = temp_proclist;
2383 __kmp_affinity_type = affinity_explicit;
2384 __kmp_affinity_gran = affinity_gran_fine;
2386 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2389 KMP_WARNING(AffSyntaxError, name);
2390 if (temp_proclist != NULL) {
2391 KMP_INTERNAL_FREE((
void *)temp_proclist);
2396 __kmp_affinity_type = affinity_none;
2398 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
2427 static int __kmp_parse_subplace_list(
const char *var,
const char **scan) {
2431 int start, count, stride;
2437 if ((**scan <
'0') || (**scan >
'9')) {
2438 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2443 start = __kmp_str_to_int(*scan, *next);
2444 KMP_ASSERT(start >= 0);
2449 if (**scan ==
'}') {
2452 if (**scan ==
',') {
2456 if (**scan !=
':') {
2457 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2464 if ((**scan <
'0') || (**scan >
'9')) {
2465 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2470 count = __kmp_str_to_int(*scan, *next);
2471 KMP_ASSERT(count >= 0);
2476 if (**scan ==
'}') {
2479 if (**scan ==
',') {
2483 if (**scan !=
':') {
2484 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2493 if (**scan ==
'+') {
2497 if (**scan ==
'-') {
2505 if ((**scan <
'0') || (**scan >
'9')) {
2506 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2511 stride = __kmp_str_to_int(*scan, *next);
2512 KMP_ASSERT(stride >= 0);
2518 if (**scan ==
'}') {
2521 if (**scan ==
',') {
2526 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2532 static int __kmp_parse_place(
const char *var,
const char **scan) {
2537 if (**scan ==
'{') {
2539 if (!__kmp_parse_subplace_list(var, scan)) {
2542 if (**scan !=
'}') {
2543 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2547 }
else if (**scan ==
'!') {
2549 return __kmp_parse_place(var, scan);
2550 }
else if ((**scan >=
'0') && (**scan <=
'9')) {
2553 int proc = __kmp_str_to_int(*scan, *next);
2554 KMP_ASSERT(proc >= 0);
2557 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2563 static int __kmp_parse_place_list(
const char *var,
const char *env,
2564 char **place_list) {
2565 const char *scan = env;
2566 const char *next = scan;
2569 int start, count, stride;
2571 if (!__kmp_parse_place(var, &scan)) {
2577 if (*scan ==
'\0') {
2585 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2592 if ((*scan <
'0') || (*scan >
'9')) {
2593 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2598 count = __kmp_str_to_int(scan, *next);
2599 KMP_ASSERT(count >= 0);
2604 if (*scan ==
'\0') {
2612 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2633 if ((*scan <
'0') || (*scan >
'9')) {
2634 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2639 stride = __kmp_str_to_int(scan, *next);
2640 KMP_ASSERT(stride >= 0);
2646 if (*scan ==
'\0') {
2654 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2659 int len = scan - env;
2660 char *retlist = (
char *)__kmp_allocate((len + 1) *
sizeof(char));
2661 KMP_MEMCPY_S(retlist, (len + 1) *
sizeof(
char), env, len *
sizeof(
char));
2662 retlist[len] =
'\0';
2663 *place_list = retlist;
2668 static void __kmp_stg_parse_places(
char const *name,
char const *value,
2671 const char *scan = value;
2672 const char *next = scan;
2673 const char *kind =
"\"threads\"";
2674 kmp_setting_t **rivals = (kmp_setting_t **)data;
2677 rc = __kmp_stg_check_rivals(name, value, rivals);
2684 if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_default) {
2685 __kmp_nested_proc_bind.bind_types[0] = proc_bind_true;
2690 if (__kmp_match_str(
"threads", scan, &next)) {
2692 __kmp_affinity_type = affinity_compact;
2693 __kmp_affinity_gran = affinity_gran_thread;
2694 __kmp_affinity_dups = FALSE;
2695 kind =
"\"threads\"";
2696 }
else if (__kmp_match_str(
"cores", scan, &next)) {
2698 __kmp_affinity_type = affinity_compact;
2699 __kmp_affinity_gran = affinity_gran_core;
2700 __kmp_affinity_dups = FALSE;
2702 }
else if (__kmp_match_str(
"sockets", scan, &next)) {
2704 __kmp_affinity_type = affinity_compact;
2705 __kmp_affinity_gran = affinity_gran_package;
2706 __kmp_affinity_dups = FALSE;
2707 kind =
"\"sockets\"";
2709 if (__kmp_affinity_proclist != NULL) {
2710 KMP_INTERNAL_FREE((
void *)__kmp_affinity_proclist);
2711 __kmp_affinity_proclist = NULL;
2713 if (__kmp_parse_place_list(name, value, &__kmp_affinity_proclist)) {
2714 __kmp_affinity_type = affinity_explicit;
2715 __kmp_affinity_gran = affinity_gran_fine;
2716 __kmp_affinity_dups = FALSE;
2717 if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_default) {
2718 __kmp_nested_proc_bind.bind_types[0] = proc_bind_true;
2724 if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_default) {
2725 __kmp_nested_proc_bind.bind_types[0] = proc_bind_true;
2729 if (*scan ==
'\0') {
2735 KMP_WARNING(SyntaxErrorUsing, name, kind);
2743 count = __kmp_str_to_int(scan, *next);
2744 KMP_ASSERT(count >= 0);
2749 KMP_WARNING(SyntaxErrorUsing, name, kind);
2755 if (*scan !=
'\0') {
2756 KMP_WARNING(ParseExtraCharsWarn, name, scan);
2758 __kmp_affinity_num_places = count;
2761 static void __kmp_stg_print_places(kmp_str_buf_t *buffer,
char const *name,
2763 if (__kmp_env_format) {
2764 KMP_STR_BUF_PRINT_NAME;
2766 __kmp_str_buf_print(buffer,
" %s", name);
2768 if ((__kmp_nested_proc_bind.used == 0) ||
2769 (__kmp_nested_proc_bind.bind_types == NULL) ||
2770 (__kmp_nested_proc_bind.bind_types[0] == proc_bind_false)) {
2771 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
2772 }
else if (__kmp_affinity_type == affinity_explicit) {
2773 if (__kmp_affinity_proclist != NULL) {
2774 __kmp_str_buf_print(buffer,
"='%s'\n", __kmp_affinity_proclist);
2776 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
2778 }
else if (__kmp_affinity_type == affinity_compact) {
2780 if (__kmp_affinity_num_masks > 0) {
2781 num = __kmp_affinity_num_masks;
2782 }
else if (__kmp_affinity_num_places > 0) {
2783 num = __kmp_affinity_num_places;
2787 if (__kmp_affinity_gran == affinity_gran_thread) {
2789 __kmp_str_buf_print(buffer,
"='threads(%d)'\n", num);
2791 __kmp_str_buf_print(buffer,
"='threads'\n");
2793 }
else if (__kmp_affinity_gran == affinity_gran_core) {
2795 __kmp_str_buf_print(buffer,
"='cores(%d)' \n", num);
2797 __kmp_str_buf_print(buffer,
"='cores'\n");
2799 }
else if (__kmp_affinity_gran == affinity_gran_package) {
2801 __kmp_str_buf_print(buffer,
"='sockets(%d)'\n", num);
2803 __kmp_str_buf_print(buffer,
"='sockets'\n");
2806 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
2809 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
2815 #if (!OMP_40_ENABLED) 2817 static void __kmp_stg_parse_proc_bind(
char const *name,
char const *value,
2820 kmp_setting_t **rivals = (kmp_setting_t **)data;
2823 rc = __kmp_stg_check_rivals(name, value, rivals);
2829 __kmp_stg_parse_bool(name, value, &enabled);
2833 __kmp_affinity_type = affinity_scatter;
2834 #if KMP_MIC_SUPPORTED 2835 if (__kmp_mic_type != non_mic)
2836 __kmp_affinity_gran = affinity_gran_fine;
2839 __kmp_affinity_gran = affinity_gran_core;
2841 __kmp_affinity_type = affinity_none;
2847 static void __kmp_stg_parse_topology_method(
char const *name,
char const *value,
2849 if (__kmp_str_match(
"all", 1, value)) {
2850 __kmp_affinity_top_method = affinity_top_method_all;
2852 #if KMP_ARCH_X86 || KMP_ARCH_X86_64 2853 else if (__kmp_str_match(
"x2apic id", 9, value) ||
2854 __kmp_str_match(
"x2apic_id", 9, value) ||
2855 __kmp_str_match(
"x2apic-id", 9, value) ||
2856 __kmp_str_match(
"x2apicid", 8, value) ||
2857 __kmp_str_match(
"cpuid leaf 11", 13, value) ||
2858 __kmp_str_match(
"cpuid_leaf_11", 13, value) ||
2859 __kmp_str_match(
"cpuid-leaf-11", 13, value) ||
2860 __kmp_str_match(
"cpuid leaf11", 12, value) ||
2861 __kmp_str_match(
"cpuid_leaf11", 12, value) ||
2862 __kmp_str_match(
"cpuid-leaf11", 12, value) ||
2863 __kmp_str_match(
"cpuidleaf 11", 12, value) ||
2864 __kmp_str_match(
"cpuidleaf_11", 12, value) ||
2865 __kmp_str_match(
"cpuidleaf-11", 12, value) ||
2866 __kmp_str_match(
"cpuidleaf11", 11, value) ||
2867 __kmp_str_match(
"cpuid 11", 8, value) ||
2868 __kmp_str_match(
"cpuid_11", 8, value) ||
2869 __kmp_str_match(
"cpuid-11", 8, value) ||
2870 __kmp_str_match(
"cpuid11", 7, value) ||
2871 __kmp_str_match(
"leaf 11", 7, value) ||
2872 __kmp_str_match(
"leaf_11", 7, value) ||
2873 __kmp_str_match(
"leaf-11", 7, value) ||
2874 __kmp_str_match(
"leaf11", 6, value)) {
2875 __kmp_affinity_top_method = affinity_top_method_x2apicid;
2876 }
else if (__kmp_str_match(
"apic id", 7, value) ||
2877 __kmp_str_match(
"apic_id", 7, value) ||
2878 __kmp_str_match(
"apic-id", 7, value) ||
2879 __kmp_str_match(
"apicid", 6, value) ||
2880 __kmp_str_match(
"cpuid leaf 4", 12, value) ||
2881 __kmp_str_match(
"cpuid_leaf_4", 12, value) ||
2882 __kmp_str_match(
"cpuid-leaf-4", 12, value) ||
2883 __kmp_str_match(
"cpuid leaf4", 11, value) ||
2884 __kmp_str_match(
"cpuid_leaf4", 11, value) ||
2885 __kmp_str_match(
"cpuid-leaf4", 11, value) ||
2886 __kmp_str_match(
"cpuidleaf 4", 11, value) ||
2887 __kmp_str_match(
"cpuidleaf_4", 11, value) ||
2888 __kmp_str_match(
"cpuidleaf-4", 11, value) ||
2889 __kmp_str_match(
"cpuidleaf4", 10, value) ||
2890 __kmp_str_match(
"cpuid 4", 7, value) ||
2891 __kmp_str_match(
"cpuid_4", 7, value) ||
2892 __kmp_str_match(
"cpuid-4", 7, value) ||
2893 __kmp_str_match(
"cpuid4", 6, value) ||
2894 __kmp_str_match(
"leaf 4", 6, value) ||
2895 __kmp_str_match(
"leaf_4", 6, value) ||
2896 __kmp_str_match(
"leaf-4", 6, value) ||
2897 __kmp_str_match(
"leaf4", 5, value)) {
2898 __kmp_affinity_top_method = affinity_top_method_apicid;
2901 else if (__kmp_str_match(
"/proc/cpuinfo", 2, value) ||
2902 __kmp_str_match(
"cpuinfo", 5, value)) {
2903 __kmp_affinity_top_method = affinity_top_method_cpuinfo;
2905 #if KMP_GROUP_AFFINITY 2906 else if (__kmp_str_match(
"group", 1, value)) {
2907 __kmp_affinity_top_method = affinity_top_method_group;
2910 else if (__kmp_str_match(
"flat", 1, value)) {
2911 __kmp_affinity_top_method = affinity_top_method_flat;
2914 else if (__kmp_str_match(
"hwloc", 1, value)) {
2915 __kmp_affinity_top_method = affinity_top_method_hwloc;
2919 KMP_WARNING(StgInvalidValue, name, value);
2923 static void __kmp_stg_print_topology_method(kmp_str_buf_t *buffer,
2924 char const *name,
void *data) {
2926 char const *value = NULL;
2928 switch (__kmp_affinity_top_method) {
2929 case affinity_top_method_default:
2933 case affinity_top_method_all:
2937 #if KMP_ARCH_X86 || KMP_ARCH_X86_64 2938 case affinity_top_method_x2apicid:
2939 value =
"x2APIC id";
2942 case affinity_top_method_apicid:
2948 case affinity_top_method_hwloc:
2953 case affinity_top_method_cpuinfo:
2957 #if KMP_GROUP_AFFINITY 2958 case affinity_top_method_group:
2963 case affinity_top_method_flat:
2968 if (value != NULL) {
2969 __kmp_stg_print_str(buffer, name, value);
2980 static void __kmp_stg_parse_proc_bind(
char const *name,
char const *value,
2982 kmp_setting_t **rivals = (kmp_setting_t **)data;
2985 rc = __kmp_stg_check_rivals(name, value, rivals);
2991 KMP_DEBUG_ASSERT((__kmp_nested_proc_bind.bind_types != NULL) &&
2992 (__kmp_nested_proc_bind.used > 0));
2994 const char *buf = value;
2998 if ((*buf >=
'0') && (*buf <=
'9')) {
3001 num = __kmp_str_to_int(buf, *next);
3002 KMP_ASSERT(num >= 0);
3010 if (__kmp_match_str(
"disabled", buf, &next)) {
3013 #if KMP_AFFINITY_SUPPORTED 3014 __kmp_affinity_type = affinity_disabled;
3016 __kmp_nested_proc_bind.used = 1;
3017 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
3018 }
else if ((num == (
int)proc_bind_false) ||
3019 __kmp_match_str(
"false", buf, &next)) {
3022 #if KMP_AFFINITY_SUPPORTED 3023 __kmp_affinity_type = affinity_none;
3025 __kmp_nested_proc_bind.used = 1;
3026 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
3027 }
else if ((num == (
int)proc_bind_true) ||
3028 __kmp_match_str(
"true", buf, &next)) {
3031 __kmp_nested_proc_bind.used = 1;
3032 __kmp_nested_proc_bind.bind_types[0] = proc_bind_true;
3037 for (scan = buf; *scan !=
'\0'; scan++) {
3044 if (__kmp_nested_proc_bind.size < nelem) {
3045 __kmp_nested_proc_bind.bind_types =
3046 (kmp_proc_bind_t *)KMP_INTERNAL_REALLOC(
3047 __kmp_nested_proc_bind.bind_types,
3048 sizeof(kmp_proc_bind_t) * nelem);
3049 if (__kmp_nested_proc_bind.bind_types == NULL) {
3050 KMP_FATAL(MemoryAllocFailed);
3052 __kmp_nested_proc_bind.size = nelem;
3054 __kmp_nested_proc_bind.used = nelem;
3059 enum kmp_proc_bind_t bind;
3061 if ((num == (
int)proc_bind_master) ||
3062 __kmp_match_str(
"master", buf, &next)) {
3065 bind = proc_bind_master;
3066 }
else if ((num == (
int)proc_bind_close) ||
3067 __kmp_match_str(
"close", buf, &next)) {
3070 bind = proc_bind_close;
3071 }
else if ((num == (
int)proc_bind_spread) ||
3072 __kmp_match_str(
"spread", buf, &next)) {
3075 bind = proc_bind_spread;
3077 KMP_WARNING(StgInvalidValue, name, value);
3078 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
3079 __kmp_nested_proc_bind.used = 1;
3083 __kmp_nested_proc_bind.bind_types[i++] = bind;
3087 KMP_DEBUG_ASSERT(*buf ==
',');
3092 if ((*buf >=
'0') && (*buf <=
'9')) {
3095 num = __kmp_str_to_int(buf, *next);
3096 KMP_ASSERT(num >= 0);
3106 KMP_WARNING(ParseExtraCharsWarn, name, buf);
3110 static void __kmp_stg_print_proc_bind(kmp_str_buf_t *buffer,
char const *name,
3112 int nelem = __kmp_nested_proc_bind.used;
3113 if (__kmp_env_format) {
3114 KMP_STR_BUF_PRINT_NAME;
3116 __kmp_str_buf_print(buffer,
" %s", name);
3119 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
3122 __kmp_str_buf_print(buffer,
"='", name);
3123 for (i = 0; i < nelem; i++) {
3124 switch (__kmp_nested_proc_bind.bind_types[i]) {
3125 case proc_bind_false:
3126 __kmp_str_buf_print(buffer,
"false");
3129 case proc_bind_true:
3130 __kmp_str_buf_print(buffer,
"true");
3133 case proc_bind_master:
3134 __kmp_str_buf_print(buffer,
"master");
3137 case proc_bind_close:
3138 __kmp_str_buf_print(buffer,
"close");
3141 case proc_bind_spread:
3142 __kmp_str_buf_print(buffer,
"spread");
3145 case proc_bind_intel:
3146 __kmp_str_buf_print(buffer,
"intel");
3149 case proc_bind_default:
3150 __kmp_str_buf_print(buffer,
"default");
3153 if (i < nelem - 1) {
3154 __kmp_str_buf_print(buffer,
",");
3157 __kmp_str_buf_print(buffer,
"'\n");
3166 static void __kmp_stg_parse_omp_dynamic(
char const *name,
char const *value,
3168 __kmp_stg_parse_bool(name, value, &(__kmp_global.g.g_dynamic));
3171 static void __kmp_stg_print_omp_dynamic(kmp_str_buf_t *buffer,
char const *name,
3173 __kmp_stg_print_bool(buffer, name, __kmp_global.g.g_dynamic);
3176 static void __kmp_stg_parse_kmp_dynamic_mode(
char const *name,
3177 char const *value,
void *data) {
3178 if (TCR_4(__kmp_init_parallel)) {
3179 KMP_WARNING(EnvParallelWarn, name);
3180 __kmp_env_toPrint(name, 0);
3183 #ifdef USE_LOAD_BALANCE 3184 else if (__kmp_str_match(
"load balance", 2, value) ||
3185 __kmp_str_match(
"load_balance", 2, value) ||
3186 __kmp_str_match(
"load-balance", 2, value) ||
3187 __kmp_str_match(
"loadbalance", 2, value) ||
3188 __kmp_str_match(
"balance", 1, value)) {
3189 __kmp_global.g.g_dynamic_mode = dynamic_load_balance;
3192 else if (__kmp_str_match(
"thread limit", 1, value) ||
3193 __kmp_str_match(
"thread_limit", 1, value) ||
3194 __kmp_str_match(
"thread-limit", 1, value) ||
3195 __kmp_str_match(
"threadlimit", 1, value) ||
3196 __kmp_str_match(
"limit", 2, value)) {
3197 __kmp_global.g.g_dynamic_mode = dynamic_thread_limit;
3198 }
else if (__kmp_str_match(
"random", 1, value)) {
3199 __kmp_global.g.g_dynamic_mode = dynamic_random;
3201 KMP_WARNING(StgInvalidValue, name, value);
3205 static void __kmp_stg_print_kmp_dynamic_mode(kmp_str_buf_t *buffer,
3206 char const *name,
void *data) {
3208 if (__kmp_global.g.g_dynamic_mode == dynamic_default) {
3209 __kmp_str_buf_print(buffer,
" %s: %s \n", name, KMP_I18N_STR(NotDefined));
3211 #ifdef USE_LOAD_BALANCE 3212 else if (__kmp_global.g.g_dynamic_mode == dynamic_load_balance) {
3213 __kmp_stg_print_str(buffer, name,
"load balance");
3216 else if (__kmp_global.g.g_dynamic_mode == dynamic_thread_limit) {
3217 __kmp_stg_print_str(buffer, name,
"thread limit");
3218 }
else if (__kmp_global.g.g_dynamic_mode == dynamic_random) {
3219 __kmp_stg_print_str(buffer, name,
"random");
3226 #ifdef USE_LOAD_BALANCE 3231 static void __kmp_stg_parse_ld_balance_interval(
char const *name,
3232 char const *value,
void *data) {
3233 double interval = __kmp_convert_to_double(value);
3234 if (interval >= 0) {
3235 __kmp_load_balance_interval = interval;
3237 KMP_WARNING(StgInvalidValue, name, value);
3241 static void __kmp_stg_print_ld_balance_interval(kmp_str_buf_t *buffer,
3242 char const *name,
void *data) {
3244 __kmp_str_buf_print(buffer,
" %s=%8.6f\n", name,
3245 __kmp_load_balance_interval);
3254 static void __kmp_stg_parse_init_at_fork(
char const *name,
char const *value,
3256 __kmp_stg_parse_bool(name, value, &__kmp_need_register_atfork);
3257 if (__kmp_need_register_atfork) {
3258 __kmp_need_register_atfork_specified = TRUE;
3262 static void __kmp_stg_print_init_at_fork(kmp_str_buf_t *buffer,
3263 char const *name,
void *data) {
3264 __kmp_stg_print_bool(buffer, name, __kmp_need_register_atfork_specified);
3270 static void __kmp_stg_parse_schedule(
char const *name,
char const *value,
3273 if (value != NULL) {
3274 size_t length = KMP_STRLEN(value);
3275 if (length > INT_MAX) {
3276 KMP_WARNING(LongValue, name);
3279 if (value[length - 1] ==
'"' || value[length - 1] ==
'\'')
3280 KMP_WARNING(UnbalancedQuotes, name);
3284 semicolon = CCAST(
char *, strchr(value,
';'));
3285 if (*value && semicolon != value) {
3286 char *comma = CCAST(
char *, strchr(value,
','));
3293 if (!__kmp_strcasecmp_with_sentinel(
"static", value, sentinel)) {
3294 if (!__kmp_strcasecmp_with_sentinel(
"greedy", comma,
';')) {
3295 __kmp_static = kmp_sch_static_greedy;
3297 }
else if (!__kmp_strcasecmp_with_sentinel(
"balanced", comma,
3299 __kmp_static = kmp_sch_static_balanced;
3302 }
else if (!__kmp_strcasecmp_with_sentinel(
"guided", value,
3304 if (!__kmp_strcasecmp_with_sentinel(
"iterative", comma,
';')) {
3305 __kmp_guided = kmp_sch_guided_iterative_chunked;
3307 }
else if (!__kmp_strcasecmp_with_sentinel(
"analytical", comma,
3310 __kmp_guided = kmp_sch_guided_analytical_chunked;
3314 KMP_WARNING(InvalidClause, name, value);
3316 KMP_WARNING(EmptyClause, name);
3317 }
while ((value = semicolon ? semicolon + 1 : NULL));
3323 static void __kmp_stg_print_schedule(kmp_str_buf_t *buffer,
char const *name,
3325 if (__kmp_env_format) {
3326 KMP_STR_BUF_PRINT_NAME_EX(name);
3328 __kmp_str_buf_print(buffer,
" %s='", name);
3330 if (__kmp_static == kmp_sch_static_greedy) {
3331 __kmp_str_buf_print(buffer,
"%s",
"static,greedy");
3332 }
else if (__kmp_static == kmp_sch_static_balanced) {
3333 __kmp_str_buf_print(buffer,
"%s",
"static,balanced");
3335 if (__kmp_guided == kmp_sch_guided_iterative_chunked) {
3336 __kmp_str_buf_print(buffer,
";%s'\n",
"guided,iterative");
3337 }
else if (__kmp_guided == kmp_sch_guided_analytical_chunked) {
3338 __kmp_str_buf_print(buffer,
";%s'\n",
"guided,analytical");
3345 static void __kmp_stg_parse_omp_schedule(
char const *name,
char const *value,
3349 length = KMP_STRLEN(value);
3351 char *comma = CCAST(
char *, strchr(value,
','));
3352 if (value[length - 1] ==
'"' || value[length - 1] ==
'\'')
3353 KMP_WARNING(UnbalancedQuotes, name);
3355 if (!__kmp_strcasecmp_with_sentinel(
"dynamic", value,
','))
3356 __kmp_sched = kmp_sch_dynamic_chunked;
3357 else if (!__kmp_strcasecmp_with_sentinel(
"guided", value,
3362 else if (!__kmp_strcasecmp_with_sentinel(
"auto", value,
',')) {
3365 __kmp_msg(kmp_ms_warning, KMP_MSG(IgnoreChunk, name, comma),
3369 }
else if (!__kmp_strcasecmp_with_sentinel(
"trapezoidal", value,
3371 __kmp_sched = kmp_sch_trapezoidal;
3372 else if (!__kmp_strcasecmp_with_sentinel(
"static", value,
3375 #if KMP_STATIC_STEAL_ENABLED 3376 else if (!__kmp_strcasecmp_with_sentinel(
"static_steal", value,
','))
3377 __kmp_sched = kmp_sch_static_steal;
3380 KMP_WARNING(StgInvalidValue, name, value);
3383 if (value && comma) {
3384 __kmp_env_chunk = TRUE;
3387 __kmp_sched = kmp_sch_static_chunked;
3389 __kmp_chunk = __kmp_str_to_int(comma, 0);
3390 if (__kmp_chunk < 1) {
3391 __kmp_chunk = KMP_DEFAULT_CHUNK;
3392 __kmp_msg(kmp_ms_warning, KMP_MSG(InvalidChunk, name, comma),
3394 KMP_INFORM(Using_int_Value, name, __kmp_chunk);
3403 }
else if (__kmp_chunk > KMP_MAX_CHUNK) {
3404 __kmp_chunk = KMP_MAX_CHUNK;
3405 __kmp_msg(kmp_ms_warning, KMP_MSG(LargeChunk, name, comma),
3407 KMP_INFORM(Using_int_Value, name, __kmp_chunk);
3410 __kmp_env_chunk = FALSE;
3412 KMP_WARNING(EmptyString, name);
3414 K_DIAG(1, (
"__kmp_static == %d\n", __kmp_static))
3415 K_DIAG(1, (
"__kmp_guided == %d\n", __kmp_guided))
3416 K_DIAG(1, (
"__kmp_sched == %d\n", __kmp_sched))
3417 K_DIAG(1, (
"__kmp_chunk == %d\n", __kmp_chunk))
3420 static void __kmp_stg_print_omp_schedule(kmp_str_buf_t *buffer,
3421 char const *name,
void *data) {
3422 if (__kmp_env_format) {
3423 KMP_STR_BUF_PRINT_NAME_EX(name);
3425 __kmp_str_buf_print(buffer,
" %s='", name);
3428 switch (__kmp_sched) {
3429 case kmp_sch_dynamic_chunked:
3430 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"dynamic", __kmp_chunk);
3432 case kmp_sch_guided_iterative_chunked:
3433 case kmp_sch_guided_analytical_chunked:
3434 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"guided", __kmp_chunk);
3436 case kmp_sch_trapezoidal:
3437 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"trapezoidal", __kmp_chunk);
3440 case kmp_sch_static_chunked:
3441 case kmp_sch_static_balanced:
3442 case kmp_sch_static_greedy:
3443 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"static", __kmp_chunk);
3445 case kmp_sch_static_steal:
3446 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"static_steal", __kmp_chunk);
3449 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"auto", __kmp_chunk);
3453 switch (__kmp_sched) {
3454 case kmp_sch_dynamic_chunked:
3455 __kmp_str_buf_print(buffer,
"%s'\n",
"dynamic");
3457 case kmp_sch_guided_iterative_chunked:
3458 case kmp_sch_guided_analytical_chunked:
3459 __kmp_str_buf_print(buffer,
"%s'\n",
"guided");
3461 case kmp_sch_trapezoidal:
3462 __kmp_str_buf_print(buffer,
"%s'\n",
"trapezoidal");
3465 case kmp_sch_static_chunked:
3466 case kmp_sch_static_balanced:
3467 case kmp_sch_static_greedy:
3468 __kmp_str_buf_print(buffer,
"%s'\n",
"static");
3470 case kmp_sch_static_steal:
3471 __kmp_str_buf_print(buffer,
"%s'\n",
"static_steal");
3474 __kmp_str_buf_print(buffer,
"%s'\n",
"auto");
3483 static void __kmp_stg_parse_atomic_mode(
char const *name,
char const *value,
3489 #ifdef KMP_GOMP_COMPAT 3492 __kmp_stg_parse_int(name, value, 0, max, &mode);
3497 __kmp_atomic_mode = mode;
3501 static void __kmp_stg_print_atomic_mode(kmp_str_buf_t *buffer,
char const *name,
3503 __kmp_stg_print_int(buffer, name, __kmp_atomic_mode);
3509 static void __kmp_stg_parse_consistency_check(
char const *name,
3510 char const *value,
void *data) {
3511 if (!__kmp_strcasecmp_with_sentinel(
"all", value, 0)) {
3517 __kmp_env_consistency_check = TRUE;
3518 }
else if (!__kmp_strcasecmp_with_sentinel(
"none", value, 0)) {
3519 __kmp_env_consistency_check = FALSE;
3521 KMP_WARNING(StgInvalidValue, name, value);
3525 static void __kmp_stg_print_consistency_check(kmp_str_buf_t *buffer,
3526 char const *name,
void *data) {
3528 const char *value = NULL;
3530 if (__kmp_env_consistency_check) {
3536 if (value != NULL) {
3537 __kmp_stg_print_str(buffer, name, value);
3548 static void __kmp_stg_parse_itt_prepare_delay(
char const *name,
3549 char const *value,
void *data) {
3553 __kmp_stg_parse_int(name, value, 0, INT_MAX, &delay);
3554 __kmp_itt_prepare_delay = delay;
3557 static void __kmp_stg_print_itt_prepare_delay(kmp_str_buf_t *buffer,
3558 char const *name,
void *data) {
3559 __kmp_stg_print_uint64(buffer, name, __kmp_itt_prepare_delay);
3563 #endif // USE_ITT_NOTIFY 3569 static void __kmp_stg_parse_malloc_pool_incr(
char const *name,
3570 char const *value,
void *data) {
3571 __kmp_stg_parse_size(name, value, KMP_MIN_MALLOC_POOL_INCR,
3572 KMP_MAX_MALLOC_POOL_INCR, NULL, &__kmp_malloc_pool_incr,
3576 static void __kmp_stg_print_malloc_pool_incr(kmp_str_buf_t *buffer,
3577 char const *name,
void *data) {
3578 __kmp_stg_print_size(buffer, name, __kmp_malloc_pool_incr);
3587 static void __kmp_stg_parse_par_range_env(
char const *name,
char const *value,
3589 __kmp_stg_parse_par_range(name, value, &__kmp_par_range,
3590 __kmp_par_range_routine, __kmp_par_range_filename,
3591 &__kmp_par_range_lb, &__kmp_par_range_ub);
3594 static void __kmp_stg_print_par_range_env(kmp_str_buf_t *buffer,
3595 char const *name,
void *data) {
3596 if (__kmp_par_range != 0) {
3597 __kmp_stg_print_str(buffer, name, par_range_to_print);
3604 static void __kmp_stg_parse_yield_cycle(
char const *name,
char const *value,
3606 int flag = __kmp_yield_cycle;
3607 __kmp_stg_parse_bool(name, value, &flag);
3608 __kmp_yield_cycle = flag;
3611 static void __kmp_stg_print_yield_cycle(kmp_str_buf_t *buffer,
char const *name,
3613 __kmp_stg_print_bool(buffer, name, __kmp_yield_cycle);
3616 static void __kmp_stg_parse_yield_on(
char const *name,
char const *value,
3618 __kmp_stg_parse_int(name, value, 2, INT_MAX, &__kmp_yield_on_count);
3621 static void __kmp_stg_print_yield_on(kmp_str_buf_t *buffer,
char const *name,
3623 __kmp_stg_print_int(buffer, name, __kmp_yield_on_count);
3626 static void __kmp_stg_parse_yield_off(
char const *name,
char const *value,
3628 __kmp_stg_parse_int(name, value, 2, INT_MAX, &__kmp_yield_off_count);
3631 static void __kmp_stg_print_yield_off(kmp_str_buf_t *buffer,
char const *name,
3633 __kmp_stg_print_int(buffer, name, __kmp_yield_off_count);
3641 static void __kmp_stg_parse_init_wait(
char const *name,
char const *value,
3644 KMP_ASSERT((__kmp_init_wait & 1) == 0);
3645 wait = __kmp_init_wait / 2;
3646 __kmp_stg_parse_int(name, value, KMP_MIN_INIT_WAIT, KMP_MAX_INIT_WAIT, &wait);
3647 __kmp_init_wait = wait * 2;
3648 KMP_ASSERT((__kmp_init_wait & 1) == 0);
3649 __kmp_yield_init = __kmp_init_wait;
3652 static void __kmp_stg_print_init_wait(kmp_str_buf_t *buffer,
char const *name,
3654 __kmp_stg_print_int(buffer, name, __kmp_init_wait);
3657 static void __kmp_stg_parse_next_wait(
char const *name,
char const *value,
3660 KMP_ASSERT((__kmp_next_wait & 1) == 0);
3661 wait = __kmp_next_wait / 2;
3662 __kmp_stg_parse_int(name, value, KMP_MIN_NEXT_WAIT, KMP_MAX_NEXT_WAIT, &wait);
3663 __kmp_next_wait = wait * 2;
3664 KMP_ASSERT((__kmp_next_wait & 1) == 0);
3665 __kmp_yield_next = __kmp_next_wait;
3668 static void __kmp_stg_print_next_wait(kmp_str_buf_t *buffer,
char const *name,
3670 __kmp_stg_print_int(buffer, name, __kmp_next_wait);
3676 static void __kmp_stg_parse_gtid_mode(
char const *name,
char const *value,
3686 #ifdef KMP_TDATA_GTID 3689 __kmp_stg_parse_int(name, value, 0, max, &mode);
3693 __kmp_adjust_gtid_mode = TRUE;
3695 __kmp_gtid_mode = mode;
3696 __kmp_adjust_gtid_mode = FALSE;
3700 static void __kmp_stg_print_gtid_mode(kmp_str_buf_t *buffer,
char const *name,
3702 if (__kmp_adjust_gtid_mode) {
3703 __kmp_stg_print_int(buffer, name, 0);
3705 __kmp_stg_print_int(buffer, name, __kmp_gtid_mode);
3712 static void __kmp_stg_parse_lock_block(
char const *name,
char const *value,
3714 __kmp_stg_parse_int(name, value, 0, KMP_INT_MAX, &__kmp_num_locks_in_block);
3717 static void __kmp_stg_print_lock_block(kmp_str_buf_t *buffer,
char const *name,
3719 __kmp_stg_print_int(buffer, name, __kmp_num_locks_in_block);
3725 #if KMP_USE_DYNAMIC_LOCK 3726 #define KMP_STORE_LOCK_SEQ(a) (__kmp_user_lock_seq = lockseq_##a) 3728 #define KMP_STORE_LOCK_SEQ(a) 3731 static void __kmp_stg_parse_lock_kind(
char const *name,
char const *value,
3733 if (__kmp_init_user_locks) {
3734 KMP_WARNING(EnvLockWarn, name);
3738 if (__kmp_str_match(
"tas", 2, value) ||
3739 __kmp_str_match(
"test and set", 2, value) ||
3740 __kmp_str_match(
"test_and_set", 2, value) ||
3741 __kmp_str_match(
"test-and-set", 2, value) ||
3742 __kmp_str_match(
"test andset", 2, value) ||
3743 __kmp_str_match(
"test_andset", 2, value) ||
3744 __kmp_str_match(
"test-andset", 2, value) ||
3745 __kmp_str_match(
"testand set", 2, value) ||
3746 __kmp_str_match(
"testand_set", 2, value) ||
3747 __kmp_str_match(
"testand-set", 2, value) ||
3748 __kmp_str_match(
"testandset", 2, value)) {
3749 __kmp_user_lock_kind = lk_tas;
3750 KMP_STORE_LOCK_SEQ(tas);
3753 else if (__kmp_str_match(
"futex", 1, value)) {
3754 if (__kmp_futex_determine_capable()) {
3755 __kmp_user_lock_kind = lk_futex;
3756 KMP_STORE_LOCK_SEQ(futex);
3758 KMP_WARNING(FutexNotSupported, name, value);
3762 else if (__kmp_str_match(
"ticket", 2, value)) {
3763 __kmp_user_lock_kind = lk_ticket;
3764 KMP_STORE_LOCK_SEQ(ticket);
3765 }
else if (__kmp_str_match(
"queuing", 1, value) ||
3766 __kmp_str_match(
"queue", 1, value)) {
3767 __kmp_user_lock_kind = lk_queuing;
3768 KMP_STORE_LOCK_SEQ(queuing);
3769 }
else if (__kmp_str_match(
"drdpa ticket", 1, value) ||
3770 __kmp_str_match(
"drdpa_ticket", 1, value) ||
3771 __kmp_str_match(
"drdpa-ticket", 1, value) ||
3772 __kmp_str_match(
"drdpaticket", 1, value) ||
3773 __kmp_str_match(
"drdpa", 1, value)) {
3774 __kmp_user_lock_kind = lk_drdpa;
3775 KMP_STORE_LOCK_SEQ(drdpa);
3777 #if KMP_USE_ADAPTIVE_LOCKS 3778 else if (__kmp_str_match(
"adaptive", 1, value)) {
3779 if (__kmp_cpuinfo.rtm) {
3780 __kmp_user_lock_kind = lk_adaptive;
3781 KMP_STORE_LOCK_SEQ(adaptive);
3783 KMP_WARNING(AdaptiveNotSupported, name, value);
3784 __kmp_user_lock_kind = lk_queuing;
3785 KMP_STORE_LOCK_SEQ(queuing);
3788 #endif // KMP_USE_ADAPTIVE_LOCKS 3789 #if KMP_USE_DYNAMIC_LOCK && KMP_USE_TSX 3790 else if (__kmp_str_match(
"rtm", 1, value)) {
3791 if (__kmp_cpuinfo.rtm) {
3792 __kmp_user_lock_kind = lk_rtm;
3793 KMP_STORE_LOCK_SEQ(rtm);
3795 KMP_WARNING(AdaptiveNotSupported, name, value);
3796 __kmp_user_lock_kind = lk_queuing;
3797 KMP_STORE_LOCK_SEQ(queuing);
3799 }
else if (__kmp_str_match(
"hle", 1, value)) {
3800 __kmp_user_lock_kind = lk_hle;
3801 KMP_STORE_LOCK_SEQ(hle);
3805 KMP_WARNING(StgInvalidValue, name, value);
3809 static void __kmp_stg_print_lock_kind(kmp_str_buf_t *buffer,
char const *name,
3811 const char *value = NULL;
3813 switch (__kmp_user_lock_kind) {
3828 #if KMP_USE_DYNAMIC_LOCK && KMP_USE_TSX 3849 #if KMP_USE_ADAPTIVE_LOCKS 3856 if (value != NULL) {
3857 __kmp_stg_print_str(buffer, name, value);
3866 static void __kmp_stg_parse_spin_backoff_params(
const char *name,
3867 const char *value,
void *data) {
3868 const char *next = value;
3871 int prev_comma = FALSE;
3874 kmp_uint32 max_backoff = __kmp_spin_backoff_params.max_backoff;
3875 kmp_uint32 min_tick = __kmp_spin_backoff_params.min_tick;
3879 for (i = 0; i < 3; i++) {
3882 if (*next ==
'\0') {
3887 if (((*next < '0' || *next >
'9') && *next !=
',') || total > 2) {
3888 KMP_WARNING(EnvSyntaxError, name, value);
3894 if (total == 0 || prev_comma) {
3902 if (*next >=
'0' && *next <=
'9') {
3904 const char *buf = next;
3905 char const *msg = NULL;
3910 const char *tmp = next;
3912 if ((*next ==
' ' || *next ==
'\t') && (*tmp >=
'0' && *tmp <=
'9')) {
3913 KMP_WARNING(EnvSpacesNotAllowed, name, value);
3917 num = __kmp_str_to_int(buf, *next);
3919 msg = KMP_I18N_STR(ValueTooSmall);
3921 }
else if (num > KMP_INT_MAX) {
3922 msg = KMP_I18N_STR(ValueTooLarge);
3927 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
3928 KMP_INFORM(Using_int_Value, name, num);
3932 }
else if (total == 2) {
3937 KMP_DEBUG_ASSERT(total > 0);
3939 KMP_WARNING(EnvSyntaxError, name, value);
3942 __kmp_spin_backoff_params.max_backoff = max_backoff;
3943 __kmp_spin_backoff_params.min_tick = min_tick;
3946 static void __kmp_stg_print_spin_backoff_params(kmp_str_buf_t *buffer,
3947 char const *name,
void *data) {
3948 if (__kmp_env_format) {
3949 KMP_STR_BUF_PRINT_NAME_EX(name);
3951 __kmp_str_buf_print(buffer,
" %s='", name);
3953 __kmp_str_buf_print(buffer,
"%d,%d'\n", __kmp_spin_backoff_params.max_backoff,
3954 __kmp_spin_backoff_params.min_tick);
3957 #if KMP_USE_ADAPTIVE_LOCKS 3964 static void __kmp_stg_parse_adaptive_lock_props(
const char *name,
3965 const char *value,
void *data) {
3966 int max_retries = 0;
3967 int max_badness = 0;
3969 const char *next = value;
3972 int prev_comma = FALSE;
3978 for (i = 0; i < 3; i++) {
3981 if (*next ==
'\0') {
3986 if (((*next < '0' || *next >
'9') && *next !=
',') || total > 2) {
3987 KMP_WARNING(EnvSyntaxError, name, value);
3993 if (total == 0 || prev_comma) {
4001 if (*next >=
'0' && *next <=
'9') {
4003 const char *buf = next;
4004 char const *msg = NULL;
4009 const char *tmp = next;
4011 if ((*next ==
' ' || *next ==
'\t') && (*tmp >=
'0' && *tmp <=
'9')) {
4012 KMP_WARNING(EnvSpacesNotAllowed, name, value);
4016 num = __kmp_str_to_int(buf, *next);
4018 msg = KMP_I18N_STR(ValueTooSmall);
4020 }
else if (num > KMP_INT_MAX) {
4021 msg = KMP_I18N_STR(ValueTooLarge);
4026 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
4027 KMP_INFORM(Using_int_Value, name, num);
4031 }
else if (total == 2) {
4036 KMP_DEBUG_ASSERT(total > 0);
4038 KMP_WARNING(EnvSyntaxError, name, value);
4041 __kmp_adaptive_backoff_params.max_soft_retries = max_retries;
4042 __kmp_adaptive_backoff_params.max_badness = max_badness;
4045 static void __kmp_stg_print_adaptive_lock_props(kmp_str_buf_t *buffer,
4046 char const *name,
void *data) {
4047 if (__kmp_env_format) {
4048 KMP_STR_BUF_PRINT_NAME_EX(name);
4050 __kmp_str_buf_print(buffer,
" %s='", name);
4052 __kmp_str_buf_print(buffer,
"%d,%d'\n",
4053 __kmp_adaptive_backoff_params.max_soft_retries,
4054 __kmp_adaptive_backoff_params.max_badness);
4057 #if KMP_DEBUG_ADAPTIVE_LOCKS 4059 static void __kmp_stg_parse_speculative_statsfile(
char const *name,
4062 __kmp_stg_parse_file(name, value,
"", &__kmp_speculative_statsfile);
4065 static void __kmp_stg_print_speculative_statsfile(kmp_str_buf_t *buffer,
4068 if (__kmp_str_match(
"-", 0, __kmp_speculative_statsfile)) {
4069 __kmp_stg_print_str(buffer, name,
"stdout");
4071 __kmp_stg_print_str(buffer, name, __kmp_speculative_statsfile);
4076 #endif // KMP_DEBUG_ADAPTIVE_LOCKS 4078 #endif // KMP_USE_ADAPTIVE_LOCKS 4087 #define MAX_T_LEVEL 5 4088 #define MAX_STR_LEN 512 4089 static void __kmp_stg_parse_hw_subset(
char const *name,
char const *value,
4093 static int parsed = 0;
4094 if (strcmp(name,
"KMP_PLACE_THREADS") == 0) {
4095 KMP_INFORM(EnvVarDeprecated, name,
"KMP_HW_SUBSET");
4102 char *components[MAX_T_LEVEL];
4103 char const *digits =
"0123456789";
4104 char input[MAX_STR_LEN];
4105 size_t len = 0, mlen = MAX_STR_LEN;
4108 char *pos = CCAST(
char *, value);
4109 while (*pos && mlen) {
4111 if (len == 0 && *pos ==
':') {
4112 __kmp_hws_abs_flag = 1;
4114 input[len] = toupper(*pos);
4115 if (input[len] ==
'X')
4117 if (input[len] ==
'O' && strchr(digits, *(pos + 1)))
4125 if (len == 0 || mlen == 0)
4128 __kmp_hws_requested = 1;
4131 components[level++] = pos;
4132 while ((pos = strchr(pos,
','))) {
4134 components[level++] = ++pos;
4135 if (level > MAX_T_LEVEL)
4139 for (
int i = 0; i < level; ++i) {
4141 int num = atoi(components[i]);
4142 if ((pos = strchr(components[i],
'@'))) {
4143 offset = atoi(pos + 1);
4146 pos = components[i] + strspn(components[i], digits);
4147 if (pos == components[i])
4152 if (__kmp_hws_socket.num > 0)
4154 __kmp_hws_socket.num = num;
4155 __kmp_hws_socket.offset = offset;
4158 if (__kmp_hws_node.num > 0)
4160 __kmp_hws_node.num = num;
4161 __kmp_hws_node.offset = offset;
4164 if (*(pos + 1) ==
'2') {
4165 if (__kmp_hws_tile.num > 0)
4167 __kmp_hws_tile.num = num;
4168 __kmp_hws_tile.offset = offset;
4169 }
else if (*(pos + 1) ==
'3') {
4170 if (__kmp_hws_socket.num > 0)
4172 __kmp_hws_socket.num = num;
4173 __kmp_hws_socket.offset = offset;
4174 }
else if (*(pos + 1) ==
'1') {
4175 if (__kmp_hws_core.num > 0)
4177 __kmp_hws_core.num = num;
4178 __kmp_hws_core.offset = offset;
4182 if (*(pos + 1) !=
'A') {
4183 if (__kmp_hws_core.num > 0)
4185 __kmp_hws_core.num = num;
4186 __kmp_hws_core.offset = offset;
4188 char *d = pos + strcspn(pos, digits);
4190 if (__kmp_hws_tile.num > 0)
4192 __kmp_hws_tile.num = num;
4193 __kmp_hws_tile.offset = offset;
4194 }
else if (*d ==
'3') {
4195 if (__kmp_hws_socket.num > 0)
4197 __kmp_hws_socket.num = num;
4198 __kmp_hws_socket.offset = offset;
4199 }
else if (*d ==
'1') {
4200 if (__kmp_hws_core.num > 0)
4202 __kmp_hws_core.num = num;
4203 __kmp_hws_core.offset = offset;
4210 if (__kmp_hws_proc.num > 0)
4212 __kmp_hws_proc.num = num;
4213 __kmp_hws_proc.offset = offset;
4221 KMP_WARNING(AffHWSubsetInvalid, name, value);
4222 __kmp_hws_requested = 0;
4226 static void __kmp_stg_print_hw_subset(kmp_str_buf_t *buffer,
char const *name,
4228 if (__kmp_hws_requested) {
4231 __kmp_str_buf_init(&buf);
4232 if (__kmp_env_format)
4233 KMP_STR_BUF_PRINT_NAME_EX(name);
4235 __kmp_str_buf_print(buffer,
" %s='", name);
4236 if (__kmp_hws_socket.num) {
4237 __kmp_str_buf_print(&buf,
"%ds", __kmp_hws_socket.num);
4238 if (__kmp_hws_socket.offset)
4239 __kmp_str_buf_print(&buf,
"@%d", __kmp_hws_socket.offset);
4242 if (__kmp_hws_node.num) {
4243 __kmp_str_buf_print(&buf,
"%s%dn", comma ?
"," :
"", __kmp_hws_node.num);
4244 if (__kmp_hws_node.offset)
4245 __kmp_str_buf_print(&buf,
"@%d", __kmp_hws_node.offset);
4248 if (__kmp_hws_tile.num) {
4249 __kmp_str_buf_print(&buf,
"%s%dL2", comma ?
"," :
"", __kmp_hws_tile.num);
4250 if (__kmp_hws_tile.offset)
4251 __kmp_str_buf_print(&buf,
"@%d", __kmp_hws_tile.offset);
4254 if (__kmp_hws_core.num) {
4255 __kmp_str_buf_print(&buf,
"%s%dc", comma ?
"," :
"", __kmp_hws_core.num);
4256 if (__kmp_hws_core.offset)
4257 __kmp_str_buf_print(&buf,
"@%d", __kmp_hws_core.offset);
4260 if (__kmp_hws_proc.num)
4261 __kmp_str_buf_print(&buf,
"%s%dt", comma ?
"," :
"", __kmp_hws_proc.num);
4262 __kmp_str_buf_print(buffer,
"%s'\n", buf.str);
4263 __kmp_str_buf_free(&buf);
4271 static void __kmp_stg_parse_forkjoin_frames(
char const *name,
char const *value,
4273 __kmp_stg_parse_bool(name, value, &__kmp_forkjoin_frames);
4276 static void __kmp_stg_print_forkjoin_frames(kmp_str_buf_t *buffer,
4277 char const *name,
void *data) {
4278 __kmp_stg_print_bool(buffer, name, __kmp_forkjoin_frames);
4284 static void __kmp_stg_parse_forkjoin_frames_mode(
char const *name,
4287 __kmp_stg_parse_int(name, value, 0, 3, &__kmp_forkjoin_frames_mode);
4290 static void __kmp_stg_print_forkjoin_frames_mode(kmp_str_buf_t *buffer,
4291 char const *name,
void *data) {
4292 __kmp_stg_print_int(buffer, name, __kmp_forkjoin_frames_mode);
4301 static void __kmp_stg_parse_omp_display_env(
char const *name,
char const *value,
4303 if (__kmp_str_match(
"VERBOSE", 1, value)) {
4304 __kmp_display_env_verbose = TRUE;
4306 __kmp_stg_parse_bool(name, value, &__kmp_display_env);
4311 static void __kmp_stg_print_omp_display_env(kmp_str_buf_t *buffer,
4312 char const *name,
void *data) {
4313 if (__kmp_display_env_verbose) {
4314 __kmp_stg_print_str(buffer, name,
"VERBOSE");
4316 __kmp_stg_print_bool(buffer, name, __kmp_display_env);
4320 static void __kmp_stg_parse_omp_cancellation(
char const *name,
4321 char const *value,
void *data) {
4322 if (TCR_4(__kmp_init_parallel)) {
4323 KMP_WARNING(EnvParallelWarn, name);
4326 __kmp_stg_parse_bool(name, value, &__kmp_omp_cancellation);
4329 static void __kmp_stg_print_omp_cancellation(kmp_str_buf_t *buffer,
4330 char const *name,
void *data) {
4331 __kmp_stg_print_bool(buffer, name, __kmp_omp_cancellation);
4339 static kmp_setting_t __kmp_stg_table[] = {
4341 {
"KMP_ALL_THREADS", __kmp_stg_parse_all_threads,
4342 __kmp_stg_print_all_threads, NULL, 0, 0},
4343 {
"KMP_BLOCKTIME", __kmp_stg_parse_blocktime, __kmp_stg_print_blocktime,
4345 {
"KMP_DUPLICATE_LIB_OK", __kmp_stg_parse_duplicate_lib_ok,
4346 __kmp_stg_print_duplicate_lib_ok, NULL, 0, 0},
4347 {
"KMP_LIBRARY", __kmp_stg_parse_wait_policy, __kmp_stg_print_wait_policy,
4349 {
"KMP_MAX_THREADS", __kmp_stg_parse_all_threads, NULL, NULL, 0,
4352 {
"KMP_MONITOR_STACKSIZE", __kmp_stg_parse_monitor_stacksize,
4353 __kmp_stg_print_monitor_stacksize, NULL, 0, 0},
4355 {
"KMP_SETTINGS", __kmp_stg_parse_settings, __kmp_stg_print_settings, NULL,
4357 {
"KMP_STACKOFFSET", __kmp_stg_parse_stackoffset,
4358 __kmp_stg_print_stackoffset, NULL, 0, 0},
4359 {
"KMP_STACKSIZE", __kmp_stg_parse_stacksize, __kmp_stg_print_stacksize,
4361 {
"KMP_STACKPAD", __kmp_stg_parse_stackpad, __kmp_stg_print_stackpad, NULL,
4363 {
"KMP_VERSION", __kmp_stg_parse_version, __kmp_stg_print_version, NULL, 0,
4365 {
"KMP_WARNINGS", __kmp_stg_parse_warnings, __kmp_stg_print_warnings, NULL,
4368 {
"OMP_NESTED", __kmp_stg_parse_nested, __kmp_stg_print_nested, NULL, 0, 0},
4369 {
"OMP_NUM_THREADS", __kmp_stg_parse_num_threads,
4370 __kmp_stg_print_num_threads, NULL, 0, 0},
4371 {
"OMP_STACKSIZE", __kmp_stg_parse_stacksize, __kmp_stg_print_stacksize,
4374 {
"KMP_TASKING", __kmp_stg_parse_tasking, __kmp_stg_print_tasking, NULL, 0,
4376 {
"KMP_TASK_STEALING_CONSTRAINT", __kmp_stg_parse_task_stealing,
4377 __kmp_stg_print_task_stealing, NULL, 0, 0},
4378 {
"OMP_MAX_ACTIVE_LEVELS", __kmp_stg_parse_max_active_levels,
4379 __kmp_stg_print_max_active_levels, NULL, 0, 0},
4381 {
"OMP_DEFAULT_DEVICE", __kmp_stg_parse_default_device,
4382 __kmp_stg_print_default_device, NULL, 0, 0},
4385 {
"OMP_MAX_TASK_PRIORITY", __kmp_stg_parse_max_task_priority,
4386 __kmp_stg_print_max_task_priority, NULL, 0, 0},
4387 {
"KMP_TASKLOOP_MIN_TASKS", __kmp_stg_parse_taskloop_min_tasks,
4388 __kmp_stg_print_taskloop_min_tasks, NULL, 0, 0},
4390 {
"OMP_THREAD_LIMIT", __kmp_stg_parse_all_threads,
4391 __kmp_stg_print_all_threads, NULL, 0, 0},
4392 {
"OMP_WAIT_POLICY", __kmp_stg_parse_wait_policy,
4393 __kmp_stg_print_wait_policy, NULL, 0, 0},
4394 {
"KMP_DISP_NUM_BUFFERS", __kmp_stg_parse_disp_buffers,
4395 __kmp_stg_print_disp_buffers, NULL, 0, 0},
4396 #if KMP_NESTED_HOT_TEAMS 4397 {
"KMP_HOT_TEAMS_MAX_LEVEL", __kmp_stg_parse_hot_teams_level,
4398 __kmp_stg_print_hot_teams_level, NULL, 0, 0},
4399 {
"KMP_HOT_TEAMS_MODE", __kmp_stg_parse_hot_teams_mode,
4400 __kmp_stg_print_hot_teams_mode, NULL, 0, 0},
4401 #endif // KMP_NESTED_HOT_TEAMS 4403 #if KMP_HANDLE_SIGNALS 4404 {
"KMP_HANDLE_SIGNALS", __kmp_stg_parse_handle_signals,
4405 __kmp_stg_print_handle_signals, NULL, 0, 0},
4408 #if KMP_ARCH_X86 || KMP_ARCH_X86_64 4409 {
"KMP_INHERIT_FP_CONTROL", __kmp_stg_parse_inherit_fp_control,
4410 __kmp_stg_print_inherit_fp_control, NULL, 0, 0},
4413 #ifdef KMP_GOMP_COMPAT 4414 {
"GOMP_STACKSIZE", __kmp_stg_parse_stacksize, NULL, NULL, 0, 0},
4418 {
"KMP_A_DEBUG", __kmp_stg_parse_a_debug, __kmp_stg_print_a_debug, NULL, 0,
4420 {
"KMP_B_DEBUG", __kmp_stg_parse_b_debug, __kmp_stg_print_b_debug, NULL, 0,
4422 {
"KMP_C_DEBUG", __kmp_stg_parse_c_debug, __kmp_stg_print_c_debug, NULL, 0,
4424 {
"KMP_D_DEBUG", __kmp_stg_parse_d_debug, __kmp_stg_print_d_debug, NULL, 0,
4426 {
"KMP_E_DEBUG", __kmp_stg_parse_e_debug, __kmp_stg_print_e_debug, NULL, 0,
4428 {
"KMP_F_DEBUG", __kmp_stg_parse_f_debug, __kmp_stg_print_f_debug, NULL, 0,
4430 {
"KMP_DEBUG", __kmp_stg_parse_debug, NULL, NULL, 0, 0},
4431 {
"KMP_DEBUG_BUF", __kmp_stg_parse_debug_buf, __kmp_stg_print_debug_buf,
4433 {
"KMP_DEBUG_BUF_ATOMIC", __kmp_stg_parse_debug_buf_atomic,
4434 __kmp_stg_print_debug_buf_atomic, NULL, 0, 0},
4435 {
"KMP_DEBUG_BUF_CHARS", __kmp_stg_parse_debug_buf_chars,
4436 __kmp_stg_print_debug_buf_chars, NULL, 0, 0},
4437 {
"KMP_DEBUG_BUF_LINES", __kmp_stg_parse_debug_buf_lines,
4438 __kmp_stg_print_debug_buf_lines, NULL, 0, 0},
4439 {
"KMP_DIAG", __kmp_stg_parse_diag, __kmp_stg_print_diag, NULL, 0, 0},
4441 {
"KMP_PAR_RANGE", __kmp_stg_parse_par_range_env,
4442 __kmp_stg_print_par_range_env, NULL, 0, 0},
4443 {
"KMP_YIELD_CYCLE", __kmp_stg_parse_yield_cycle,
4444 __kmp_stg_print_yield_cycle, NULL, 0, 0},
4445 {
"KMP_YIELD_ON", __kmp_stg_parse_yield_on, __kmp_stg_print_yield_on, NULL,
4447 {
"KMP_YIELD_OFF", __kmp_stg_parse_yield_off, __kmp_stg_print_yield_off,
4451 {
"KMP_ALIGN_ALLOC", __kmp_stg_parse_align_alloc,
4452 __kmp_stg_print_align_alloc, NULL, 0, 0},
4454 {
"KMP_PLAIN_BARRIER", __kmp_stg_parse_barrier_branch_bit,
4455 __kmp_stg_print_barrier_branch_bit, NULL, 0, 0},
4456 {
"KMP_PLAIN_BARRIER_PATTERN", __kmp_stg_parse_barrier_pattern,
4457 __kmp_stg_print_barrier_pattern, NULL, 0, 0},
4458 {
"KMP_FORKJOIN_BARRIER", __kmp_stg_parse_barrier_branch_bit,
4459 __kmp_stg_print_barrier_branch_bit, NULL, 0, 0},
4460 {
"KMP_FORKJOIN_BARRIER_PATTERN", __kmp_stg_parse_barrier_pattern,
4461 __kmp_stg_print_barrier_pattern, NULL, 0, 0},
4462 #if KMP_FAST_REDUCTION_BARRIER 4463 {
"KMP_REDUCTION_BARRIER", __kmp_stg_parse_barrier_branch_bit,
4464 __kmp_stg_print_barrier_branch_bit, NULL, 0, 0},
4465 {
"KMP_REDUCTION_BARRIER_PATTERN", __kmp_stg_parse_barrier_pattern,
4466 __kmp_stg_print_barrier_pattern, NULL, 0, 0},
4469 {
"KMP_ABORT_DELAY", __kmp_stg_parse_abort_delay,
4470 __kmp_stg_print_abort_delay, NULL, 0, 0},
4471 {
"KMP_CPUINFO_FILE", __kmp_stg_parse_cpuinfo_file,
4472 __kmp_stg_print_cpuinfo_file, NULL, 0, 0},
4473 {
"KMP_FORCE_REDUCTION", __kmp_stg_parse_force_reduction,
4474 __kmp_stg_print_force_reduction, NULL, 0, 0},
4475 {
"KMP_DETERMINISTIC_REDUCTION", __kmp_stg_parse_force_reduction,
4476 __kmp_stg_print_force_reduction, NULL, 0, 0},
4477 {
"KMP_STORAGE_MAP", __kmp_stg_parse_storage_map,
4478 __kmp_stg_print_storage_map, NULL, 0, 0},
4479 {
"KMP_ALL_THREADPRIVATE", __kmp_stg_parse_all_threadprivate,
4480 __kmp_stg_print_all_threadprivate, NULL, 0, 0},
4481 {
"KMP_FOREIGN_THREADS_THREADPRIVATE",
4482 __kmp_stg_parse_foreign_threads_threadprivate,
4483 __kmp_stg_print_foreign_threads_threadprivate, NULL, 0, 0},
4485 #if KMP_AFFINITY_SUPPORTED 4486 {
"KMP_AFFINITY", __kmp_stg_parse_affinity, __kmp_stg_print_affinity, NULL,
4488 #ifdef KMP_GOMP_COMPAT 4489 {
"GOMP_CPU_AFFINITY", __kmp_stg_parse_gomp_cpu_affinity, NULL,
4493 {
"OMP_PROC_BIND", __kmp_stg_parse_proc_bind, __kmp_stg_print_proc_bind,
4495 {
"OMP_PLACES", __kmp_stg_parse_places, __kmp_stg_print_places, NULL, 0, 0},
4497 {
"OMP_PROC_BIND", __kmp_stg_parse_proc_bind, NULL, NULL, 0,
4501 {
"KMP_TOPOLOGY_METHOD", __kmp_stg_parse_topology_method,
4502 __kmp_stg_print_topology_method, NULL, 0, 0},
4509 {
"OMP_PROC_BIND", __kmp_stg_parse_proc_bind, __kmp_stg_print_proc_bind,
4513 #endif // KMP_AFFINITY_SUPPORTED 4515 {
"KMP_INIT_AT_FORK", __kmp_stg_parse_init_at_fork,
4516 __kmp_stg_print_init_at_fork, NULL, 0, 0},
4517 {
"KMP_SCHEDULE", __kmp_stg_parse_schedule, __kmp_stg_print_schedule, NULL,
4519 {
"OMP_SCHEDULE", __kmp_stg_parse_omp_schedule, __kmp_stg_print_omp_schedule,
4521 {
"KMP_ATOMIC_MODE", __kmp_stg_parse_atomic_mode,
4522 __kmp_stg_print_atomic_mode, NULL, 0, 0},
4523 {
"KMP_CONSISTENCY_CHECK", __kmp_stg_parse_consistency_check,
4524 __kmp_stg_print_consistency_check, NULL, 0, 0},
4526 #if USE_ITT_BUILD && USE_ITT_NOTIFY 4527 {
"KMP_ITT_PREPARE_DELAY", __kmp_stg_parse_itt_prepare_delay,
4528 __kmp_stg_print_itt_prepare_delay, NULL, 0, 0},
4530 {
"KMP_MALLOC_POOL_INCR", __kmp_stg_parse_malloc_pool_incr,
4531 __kmp_stg_print_malloc_pool_incr, NULL, 0, 0},
4532 {
"KMP_INIT_WAIT", __kmp_stg_parse_init_wait, __kmp_stg_print_init_wait,
4534 {
"KMP_NEXT_WAIT", __kmp_stg_parse_next_wait, __kmp_stg_print_next_wait,
4536 {
"KMP_GTID_MODE", __kmp_stg_parse_gtid_mode, __kmp_stg_print_gtid_mode,
4538 {
"OMP_DYNAMIC", __kmp_stg_parse_omp_dynamic, __kmp_stg_print_omp_dynamic,
4540 {
"KMP_DYNAMIC_MODE", __kmp_stg_parse_kmp_dynamic_mode,
4541 __kmp_stg_print_kmp_dynamic_mode, NULL, 0, 0},
4543 #ifdef USE_LOAD_BALANCE 4544 {
"KMP_LOAD_BALANCE_INTERVAL", __kmp_stg_parse_ld_balance_interval,
4545 __kmp_stg_print_ld_balance_interval, NULL, 0, 0},
4548 {
"KMP_NUM_LOCKS_IN_BLOCK", __kmp_stg_parse_lock_block,
4549 __kmp_stg_print_lock_block, NULL, 0, 0},
4550 {
"KMP_LOCK_KIND", __kmp_stg_parse_lock_kind, __kmp_stg_print_lock_kind,
4552 {
"KMP_SPIN_BACKOFF_PARAMS", __kmp_stg_parse_spin_backoff_params,
4553 __kmp_stg_print_spin_backoff_params, NULL, 0, 0},
4554 #if KMP_USE_ADAPTIVE_LOCKS 4555 {
"KMP_ADAPTIVE_LOCK_PROPS", __kmp_stg_parse_adaptive_lock_props,
4556 __kmp_stg_print_adaptive_lock_props, NULL, 0, 0},
4557 #if KMP_DEBUG_ADAPTIVE_LOCKS 4558 {
"KMP_SPECULATIVE_STATSFILE", __kmp_stg_parse_speculative_statsfile,
4559 __kmp_stg_print_speculative_statsfile, NULL, 0, 0},
4561 #endif // KMP_USE_ADAPTIVE_LOCKS 4562 {
"KMP_PLACE_THREADS", __kmp_stg_parse_hw_subset, __kmp_stg_print_hw_subset,
4564 {
"KMP_HW_SUBSET", __kmp_stg_parse_hw_subset, __kmp_stg_print_hw_subset,
4567 {
"KMP_FORKJOIN_FRAMES", __kmp_stg_parse_forkjoin_frames,
4568 __kmp_stg_print_forkjoin_frames, NULL, 0, 0},
4569 {
"KMP_FORKJOIN_FRAMES_MODE", __kmp_stg_parse_forkjoin_frames_mode,
4570 __kmp_stg_print_forkjoin_frames_mode, NULL, 0, 0},
4574 {
"OMP_DISPLAY_ENV", __kmp_stg_parse_omp_display_env,
4575 __kmp_stg_print_omp_display_env, NULL, 0, 0},
4576 {
"OMP_CANCELLATION", __kmp_stg_parse_omp_cancellation,
4577 __kmp_stg_print_omp_cancellation, NULL, 0, 0},
4579 {
"", NULL, NULL, NULL, 0, 0}};
4581 static int const __kmp_stg_count =
4582 sizeof(__kmp_stg_table) /
sizeof(kmp_setting_t);
4584 static inline kmp_setting_t *__kmp_stg_find(
char const *name) {
4588 for (i = 0; i < __kmp_stg_count; ++i) {
4589 if (strcmp(__kmp_stg_table[i].name, name) == 0) {
4590 return &__kmp_stg_table[i];
4598 static int __kmp_stg_cmp(
void const *_a,
void const *_b) {
4599 const kmp_setting_t *a = RCAST(
const kmp_setting_t *, _a);
4600 const kmp_setting_t *b = RCAST(
const kmp_setting_t *, _b);
4604 if (strcmp(a->name,
"KMP_AFFINITY") == 0) {
4605 if (strcmp(b->name,
"KMP_AFFINITY") == 0) {
4609 }
else if (strcmp(b->name,
"KMP_AFFINITY") == 0) {
4612 return strcmp(a->name, b->name);
4615 static void __kmp_stg_init(
void) {
4617 static int initialized = 0;
4622 qsort(__kmp_stg_table, __kmp_stg_count - 1,
sizeof(kmp_setting_t),
4626 kmp_setting_t *kmp_stacksize =
4627 __kmp_stg_find(
"KMP_STACKSIZE");
4628 #ifdef KMP_GOMP_COMPAT 4629 kmp_setting_t *gomp_stacksize =
4630 __kmp_stg_find(
"GOMP_STACKSIZE");
4632 kmp_setting_t *omp_stacksize =
4633 __kmp_stg_find(
"OMP_STACKSIZE");
4639 static kmp_setting_t *
volatile rivals[4];
4640 static kmp_stg_ss_data_t kmp_data = {1, CCAST(kmp_setting_t **, rivals)};
4641 #ifdef KMP_GOMP_COMPAT 4642 static kmp_stg_ss_data_t gomp_data = {1024,
4643 CCAST(kmp_setting_t **, rivals)};
4645 static kmp_stg_ss_data_t omp_data = {1024,
4646 CCAST(kmp_setting_t **, rivals)};
4649 rivals[i++] = kmp_stacksize;
4650 #ifdef KMP_GOMP_COMPAT 4651 if (gomp_stacksize != NULL) {
4652 rivals[i++] = gomp_stacksize;
4655 rivals[i++] = omp_stacksize;
4658 kmp_stacksize->data = &kmp_data;
4659 #ifdef KMP_GOMP_COMPAT 4660 if (gomp_stacksize != NULL) {
4661 gomp_stacksize->data = &gomp_data;
4664 omp_stacksize->data = &omp_data;
4668 kmp_setting_t *kmp_library =
4669 __kmp_stg_find(
"KMP_LIBRARY");
4670 kmp_setting_t *omp_wait_policy =
4671 __kmp_stg_find(
"OMP_WAIT_POLICY");
4674 static kmp_setting_t *
volatile rivals[3];
4675 static kmp_stg_wp_data_t kmp_data = {0, CCAST(kmp_setting_t **, rivals)};
4676 static kmp_stg_wp_data_t omp_data = {1, CCAST(kmp_setting_t **, rivals)};
4679 rivals[i++] = kmp_library;
4680 if (omp_wait_policy != NULL) {
4681 rivals[i++] = omp_wait_policy;
4685 kmp_library->data = &kmp_data;
4686 if (omp_wait_policy != NULL) {
4687 omp_wait_policy->data = &omp_data;
4692 kmp_setting_t *kmp_all_threads =
4693 __kmp_stg_find(
"KMP_ALL_THREADS");
4694 kmp_setting_t *kmp_max_threads =
4695 __kmp_stg_find(
"KMP_MAX_THREADS");
4696 kmp_setting_t *omp_thread_limit =
4697 __kmp_stg_find(
"OMP_THREAD_LIMIT");
4700 static kmp_setting_t *
volatile rivals[4];
4703 rivals[i++] = kmp_all_threads;
4704 rivals[i++] = kmp_max_threads;
4705 if (omp_thread_limit != NULL) {
4706 rivals[i++] = omp_thread_limit;
4709 kmp_all_threads->data = CCAST(kmp_setting_t **, rivals);
4710 kmp_max_threads->data = CCAST(kmp_setting_t **, rivals);
4711 if (omp_thread_limit != NULL) {
4712 omp_thread_limit->data = CCAST(kmp_setting_t **, rivals);
4716 #if KMP_AFFINITY_SUPPORTED 4718 kmp_setting_t *kmp_affinity =
4719 __kmp_stg_find(
"KMP_AFFINITY");
4720 KMP_DEBUG_ASSERT(kmp_affinity != NULL);
4722 #ifdef KMP_GOMP_COMPAT 4723 kmp_setting_t *gomp_cpu_affinity =
4724 __kmp_stg_find(
"GOMP_CPU_AFFINITY");
4725 KMP_DEBUG_ASSERT(gomp_cpu_affinity != NULL);
4728 kmp_setting_t *omp_proc_bind =
4729 __kmp_stg_find(
"OMP_PROC_BIND");
4730 KMP_DEBUG_ASSERT(omp_proc_bind != NULL);
4733 static kmp_setting_t *
volatile rivals[4];
4736 rivals[i++] = kmp_affinity;
4738 #ifdef KMP_GOMP_COMPAT 4739 rivals[i++] = gomp_cpu_affinity;
4740 gomp_cpu_affinity->data = CCAST(kmp_setting_t **, rivals);
4743 rivals[i++] = omp_proc_bind;
4744 omp_proc_bind->data = CCAST(kmp_setting_t **, rivals);
4748 static kmp_setting_t *
volatile places_rivals[4];
4751 kmp_setting_t *omp_places = __kmp_stg_find(
"OMP_PLACES");
4752 KMP_DEBUG_ASSERT(omp_places != NULL);
4754 places_rivals[i++] = kmp_affinity;
4755 #ifdef KMP_GOMP_COMPAT 4756 places_rivals[i++] = gomp_cpu_affinity;
4758 places_rivals[i++] = omp_places;
4759 omp_places->data = CCAST(kmp_setting_t **, places_rivals);
4760 places_rivals[i++] = NULL;
4766 #endif // KMP_AFFINITY_SUPPORTED 4769 kmp_setting_t *kmp_force_red =
4770 __kmp_stg_find(
"KMP_FORCE_REDUCTION");
4771 kmp_setting_t *kmp_determ_red =
4772 __kmp_stg_find(
"KMP_DETERMINISTIC_REDUCTION");
4775 static kmp_setting_t *
volatile rivals[3];
4776 static kmp_stg_fr_data_t force_data = {1,
4777 CCAST(kmp_setting_t **, rivals)};
4778 static kmp_stg_fr_data_t determ_data = {0,
4779 CCAST(kmp_setting_t **, rivals)};
4782 rivals[i++] = kmp_force_red;
4783 if (kmp_determ_red != NULL) {
4784 rivals[i++] = kmp_determ_red;
4788 kmp_force_red->data = &force_data;
4789 if (kmp_determ_red != NULL) {
4790 kmp_determ_red->data = &determ_data;
4799 for (i = 0; i < __kmp_stg_count; ++i) {
4800 __kmp_stg_table[i].set = 0;
4805 static void __kmp_stg_parse(
char const *name,
char const *value) {
4813 if (value != NULL) {
4814 kmp_setting_t *setting = __kmp_stg_find(name);
4815 if (setting != NULL) {
4816 setting->parse(name, value, setting->data);
4817 setting->defined = 1;
4823 static int __kmp_stg_check_rivals(
4826 kmp_setting_t **rivals
4829 if (rivals == NULL) {
4835 for (; strcmp(rivals[i]->name, name) != 0; i++) {
4836 KMP_DEBUG_ASSERT(rivals[i] != NULL);
4838 #if KMP_AFFINITY_SUPPORTED 4839 if (rivals[i] == __kmp_affinity_notype) {
4846 if (rivals[i]->
set) {
4847 KMP_WARNING(StgIgnored, name, rivals[i]->name);
4857 static int __kmp_env_toPrint(
char const *name,
int flag) {
4859 kmp_setting_t *setting = __kmp_stg_find(name);
4860 if (setting != NULL) {
4861 rc = setting->defined;
4863 setting->defined = flag;
4869 static void __kmp_aux_env_initialize(kmp_env_blk_t *block) {
4874 value = __kmp_env_blk_var(block,
"OMP_NUM_THREADS");
4876 ompc_set_num_threads(__kmp_dflt_team_nth);
4880 value = __kmp_env_blk_var(block,
"KMP_BLOCKTIME");
4882 kmpc_set_blocktime(__kmp_dflt_blocktime);
4886 value = __kmp_env_blk_var(block,
"OMP_NESTED");
4888 ompc_set_nested(__kmp_dflt_nested);
4892 value = __kmp_env_blk_var(block,
"OMP_DYNAMIC");
4894 ompc_set_dynamic(__kmp_global.g.g_dynamic);
4899 void __kmp_env_initialize(
char const *
string) {
4901 kmp_env_blk_t block;
4907 if (
string == NULL) {
4909 __kmp_threads_capacity =
4910 __kmp_initial_threads_capacity(__kmp_dflt_team_nth_ub);
4912 __kmp_env_blk_init(&block,
string);
4915 for (i = 0; i < block.count; ++i) {
4916 if ((block.vars[i].name == NULL) || (*block.vars[i].name ==
'\0')) {
4919 if (block.vars[i].value == NULL) {
4922 kmp_setting_t *setting = __kmp_stg_find(block.vars[i].name);
4923 if (setting != NULL) {
4929 blocktime_str = __kmp_env_blk_var(&block,
"KMP_BLOCKTIME");
4933 if (
string == NULL) {
4934 char const *name =
"KMP_WARNINGS";
4935 char const *value = __kmp_env_blk_var(&block, name);
4936 __kmp_stg_parse(name, value);
4939 #if KMP_AFFINITY_SUPPORTED 4945 __kmp_affinity_notype = NULL;
4946 char const *aff_str = __kmp_env_blk_var(&block,
"KMP_AFFINITY");
4947 if (aff_str != NULL) {
4961 #define FIND strcasestr 4964 if ((FIND(aff_str,
"none") == NULL) &&
4965 (FIND(aff_str,
"physical") == NULL) &&
4966 (FIND(aff_str,
"logical") == NULL) &&
4967 (FIND(aff_str,
"compact") == NULL) &&
4968 (FIND(aff_str,
"scatter") == NULL) &&
4969 (FIND(aff_str,
"explicit") == NULL) &&
4970 (FIND(aff_str,
"balanced") == NULL) &&
4971 (FIND(aff_str,
"disabled") == NULL)) {
4972 __kmp_affinity_notype = __kmp_stg_find(
"KMP_AFFINITY");
4977 __kmp_affinity_type = affinity_default;
4978 __kmp_affinity_gran = affinity_gran_default;
4979 __kmp_affinity_top_method = affinity_top_method_default;
4980 __kmp_affinity_respect_mask = affinity_respect_mask_default;
4986 aff_str = __kmp_env_blk_var(&block,
"OMP_PROC_BIND");
4987 if (aff_str != NULL) {
4988 __kmp_affinity_type = affinity_default;
4989 __kmp_affinity_gran = affinity_gran_default;
4990 __kmp_affinity_top_method = affinity_top_method_default;
4991 __kmp_affinity_respect_mask = affinity_respect_mask_default;
5000 if (__kmp_nested_proc_bind.bind_types == NULL) {
5001 __kmp_nested_proc_bind.bind_types =
5002 (kmp_proc_bind_t *)KMP_INTERNAL_MALLOC(
sizeof(kmp_proc_bind_t));
5003 if (__kmp_nested_proc_bind.bind_types == NULL) {
5004 KMP_FATAL(MemoryAllocFailed);
5006 __kmp_nested_proc_bind.size = 1;
5007 __kmp_nested_proc_bind.used = 1;
5008 #if KMP_AFFINITY_SUPPORTED 5009 __kmp_nested_proc_bind.bind_types[0] = proc_bind_default;
5012 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
5018 for (i = 0; i < block.count; ++i) {
5019 __kmp_stg_parse(block.vars[i].name, block.vars[i].value);
5023 if (!__kmp_init_user_locks) {
5024 if (__kmp_user_lock_kind == lk_default) {
5025 __kmp_user_lock_kind = lk_queuing;
5027 #if KMP_USE_DYNAMIC_LOCK 5028 __kmp_init_dynamic_user_locks();
5030 __kmp_set_user_lock_vptrs(__kmp_user_lock_kind);
5033 KMP_DEBUG_ASSERT(
string != NULL);
5034 KMP_DEBUG_ASSERT(__kmp_user_lock_kind != lk_default);
5039 #if KMP_USE_DYNAMIC_LOCK 5040 __kmp_init_dynamic_user_locks();
5042 __kmp_set_user_lock_vptrs(__kmp_user_lock_kind);
5046 #if KMP_AFFINITY_SUPPORTED 5048 if (!TCR_4(__kmp_init_middle)) {
5051 const char *var =
"KMP_AFFINITY";
5052 KMPAffinity::pick_api();
5057 if (__kmp_affinity_top_method == affinity_top_method_hwloc &&
5058 __kmp_affinity_dispatch->get_api_type() != KMPAffinity::HWLOC) {
5059 KMP_WARNING(AffIgnoringHwloc, var);
5060 __kmp_affinity_top_method = affinity_top_method_all;
5063 if (__kmp_affinity_type == affinity_disabled) {
5064 KMP_AFFINITY_DISABLE();
5065 }
else if (!KMP_AFFINITY_CAPABLE()) {
5066 __kmp_affinity_dispatch->determine_capable(var);
5067 if (!KMP_AFFINITY_CAPABLE()) {
5068 if (__kmp_affinity_verbose ||
5069 (__kmp_affinity_warnings &&
5070 (__kmp_affinity_type != affinity_default) &&
5071 (__kmp_affinity_type != affinity_none) &&
5072 (__kmp_affinity_type != affinity_disabled))) {
5073 KMP_WARNING(AffNotSupported, var);
5075 __kmp_affinity_type = affinity_disabled;
5076 __kmp_affinity_respect_mask = 0;
5077 __kmp_affinity_gran = affinity_gran_fine;
5082 if (__kmp_affinity_type == affinity_disabled) {
5083 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
5084 }
else if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_true) {
5086 __kmp_nested_proc_bind.bind_types[0] = proc_bind_spread;
5090 if (KMP_AFFINITY_CAPABLE()) {
5092 #if KMP_GROUP_AFFINITY 5097 bool exactly_one_group =
false;
5098 if (__kmp_num_proc_groups > 1) {
5100 bool within_one_group;
5103 kmp_affin_mask_t *init_mask;
5104 KMP_CPU_ALLOC(init_mask);
5105 __kmp_get_system_affinity(init_mask, TRUE);
5106 group = __kmp_get_proc_group(init_mask);
5107 within_one_group = (group >= 0);
5110 if (within_one_group) {
5111 DWORD num_bits_in_group = __kmp_GetActiveProcessorCount(group);
5112 int num_bits_in_mask = 0;
5113 for (
int bit = init_mask->begin(); bit != init_mask->end();
5114 bit = init_mask->next(bit))
5116 exactly_one_group = (num_bits_in_group == num_bits_in_mask);
5118 KMP_CPU_FREE(init_mask);
5124 if (((__kmp_num_proc_groups > 1) &&
5125 (__kmp_affinity_type == affinity_default)
5127 && (__kmp_nested_proc_bind.bind_types[0] == proc_bind_default))
5129 || (__kmp_affinity_top_method == affinity_top_method_group)) {
5130 if (__kmp_affinity_respect_mask == affinity_respect_mask_default &&
5131 exactly_one_group) {
5132 __kmp_affinity_respect_mask = FALSE;
5134 if (__kmp_affinity_type == affinity_default) {
5135 __kmp_affinity_type = affinity_compact;
5137 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
5140 if (__kmp_affinity_top_method == affinity_top_method_default) {
5141 if (__kmp_affinity_gran == affinity_gran_default) {
5142 __kmp_affinity_top_method = affinity_top_method_group;
5143 __kmp_affinity_gran = affinity_gran_group;
5144 }
else if (__kmp_affinity_gran == affinity_gran_group) {
5145 __kmp_affinity_top_method = affinity_top_method_group;
5147 __kmp_affinity_top_method = affinity_top_method_all;
5149 }
else if (__kmp_affinity_top_method == affinity_top_method_group) {
5150 if (__kmp_affinity_gran == affinity_gran_default) {
5151 __kmp_affinity_gran = affinity_gran_group;
5152 }
else if ((__kmp_affinity_gran != affinity_gran_group) &&
5153 (__kmp_affinity_gran != affinity_gran_fine) &&
5154 (__kmp_affinity_gran != affinity_gran_thread)) {
5155 const char *str = NULL;
5156 switch (__kmp_affinity_gran) {
5157 case affinity_gran_core:
5160 case affinity_gran_package:
5163 case affinity_gran_node:
5167 KMP_DEBUG_ASSERT(0);
5169 KMP_WARNING(AffGranTopGroup, var, str);
5170 __kmp_affinity_gran = affinity_gran_fine;
5173 if (__kmp_affinity_gran == affinity_gran_default) {
5174 __kmp_affinity_gran = affinity_gran_core;
5175 }
else if (__kmp_affinity_gran == affinity_gran_group) {
5176 const char *str = NULL;
5177 switch (__kmp_affinity_type) {
5178 case affinity_physical:
5181 case affinity_logical:
5184 case affinity_compact:
5187 case affinity_scatter:
5190 case affinity_explicit:
5195 KMP_DEBUG_ASSERT(0);
5197 KMP_WARNING(AffGranGroupType, var, str);
5198 __kmp_affinity_gran = affinity_gran_core;
5206 if (__kmp_affinity_respect_mask == affinity_respect_mask_default) {
5207 #if KMP_GROUP_AFFINITY 5208 if (__kmp_num_proc_groups > 1 && exactly_one_group) {
5209 __kmp_affinity_respect_mask = FALSE;
5213 __kmp_affinity_respect_mask = TRUE;
5217 if ((__kmp_nested_proc_bind.bind_types[0] != proc_bind_intel) &&
5218 (__kmp_nested_proc_bind.bind_types[0] != proc_bind_default)) {
5219 if (__kmp_affinity_type == affinity_default) {
5220 __kmp_affinity_type = affinity_compact;
5221 __kmp_affinity_dups = FALSE;
5225 if (__kmp_affinity_type == affinity_default) {
5227 #if KMP_MIC_SUPPORTED 5228 if (__kmp_mic_type != non_mic) {
5229 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
5233 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
5236 #if KMP_MIC_SUPPORTED 5237 if (__kmp_mic_type != non_mic) {
5238 __kmp_affinity_type = affinity_scatter;
5242 __kmp_affinity_type = affinity_none;
5245 if ((__kmp_affinity_gran == affinity_gran_default) &&
5246 (__kmp_affinity_gran_levels < 0)) {
5247 #if KMP_MIC_SUPPORTED 5248 if (__kmp_mic_type != non_mic) {
5249 __kmp_affinity_gran = affinity_gran_fine;
5253 __kmp_affinity_gran = affinity_gran_core;
5256 if (__kmp_affinity_top_method == affinity_top_method_default) {
5257 __kmp_affinity_top_method = affinity_top_method_all;
5262 K_DIAG(1, (
"__kmp_affinity_type == %d\n", __kmp_affinity_type));
5263 K_DIAG(1, (
"__kmp_affinity_compact == %d\n", __kmp_affinity_compact));
5264 K_DIAG(1, (
"__kmp_affinity_offset == %d\n", __kmp_affinity_offset));
5265 K_DIAG(1, (
"__kmp_affinity_verbose == %d\n", __kmp_affinity_verbose));
5266 K_DIAG(1, (
"__kmp_affinity_warnings == %d\n", __kmp_affinity_warnings));
5267 K_DIAG(1, (
"__kmp_affinity_respect_mask == %d\n",
5268 __kmp_affinity_respect_mask));
5269 K_DIAG(1, (
"__kmp_affinity_gran == %d\n", __kmp_affinity_gran));
5271 KMP_DEBUG_ASSERT(__kmp_affinity_type != affinity_default);
5273 KMP_DEBUG_ASSERT(__kmp_nested_proc_bind.bind_types[0] != proc_bind_default);
5279 if (__kmp_version) {
5280 __kmp_print_version_1();
5285 if (
string != NULL) {
5286 __kmp_aux_env_initialize(&block);
5289 __kmp_env_blk_free(&block);
5295 void __kmp_env_print() {
5297 kmp_env_blk_t block;
5299 kmp_str_buf_t buffer;
5302 __kmp_str_buf_init(&buffer);
5304 __kmp_env_blk_init(&block, NULL);
5305 __kmp_env_blk_sort(&block);
5308 __kmp_str_buf_print(&buffer,
"\n%s\n\n", KMP_I18N_STR(UserSettings));
5309 for (i = 0; i < block.count; ++i) {
5310 char const *name = block.vars[i].name;
5311 char const *value = block.vars[i].value;
5312 if ((KMP_STRLEN(name) > 4 && strncmp(name,
"KMP_", 4) == 0) ||
5313 strncmp(name,
"OMP_", 4) == 0
5314 #ifdef KMP_GOMP_COMPAT
5315 || strncmp(name,
"GOMP_", 5) == 0
5318 __kmp_str_buf_print(&buffer,
" %s=%s\n", name, value);
5321 __kmp_str_buf_print(&buffer,
"\n");
5324 __kmp_str_buf_print(&buffer,
"%s\n\n", KMP_I18N_STR(EffectiveSettings));
5325 for (
int i = 0; i < __kmp_stg_count; ++i) {
5326 if (__kmp_stg_table[i].print != NULL) {
5327 __kmp_stg_table[i].print(&buffer, __kmp_stg_table[i].name,
5328 __kmp_stg_table[i].data);
5332 __kmp_printf(
"%s", buffer.str);
5334 __kmp_env_blk_free(&block);
5335 __kmp_str_buf_free(&buffer);
5342 void __kmp_env_print_2() {
5344 kmp_env_blk_t block;
5345 kmp_str_buf_t buffer;
5347 __kmp_env_format = 1;
5350 __kmp_str_buf_init(&buffer);
5352 __kmp_env_blk_init(&block, NULL);
5353 __kmp_env_blk_sort(&block);
5355 __kmp_str_buf_print(&buffer,
"\n%s\n", KMP_I18N_STR(DisplayEnvBegin));
5356 __kmp_str_buf_print(&buffer,
" _OPENMP='%d'\n", __kmp_openmp_version);
5358 for (
int i = 0; i < __kmp_stg_count; ++i) {
5359 if (__kmp_stg_table[i].print != NULL &&
5360 ((__kmp_display_env &&
5361 strncmp(__kmp_stg_table[i].name,
"OMP_", 4) == 0) ||
5362 __kmp_display_env_verbose)) {
5363 __kmp_stg_table[i].print(&buffer, __kmp_stg_table[i].name,
5364 __kmp_stg_table[i].data);
5368 __kmp_str_buf_print(&buffer,
"%s\n", KMP_I18N_STR(DisplayEnvEnd));
5369 __kmp_str_buf_print(&buffer,
"\n");
5371 __kmp_printf(
"%s", buffer.str);
5373 __kmp_env_blk_free(&block);
5374 __kmp_str_buf_free(&buffer);
5379 #endif // OMP_40_ENABLED