15 #include "kmp_affinity.h" 16 #include "kmp_atomic.h" 17 #include "kmp_environment.h" 22 #include "kmp_settings.h" 24 #include "kmp_wrapper_getpid.h" 27 static int __kmp_env_toPrint(
char const *name,
int flag);
29 bool __kmp_env_format = 0;
34 static double __kmp_convert_to_double(
char const *s) {
37 if (KMP_SSCANF(s,
"%lf", &result) < 1) {
45 static unsigned int __kmp_readstr_with_sentinel(
char *dest,
char const *src,
46 size_t len,
char sentinel) {
48 for (i = 0; i < len; i++) {
49 if ((*src ==
'\0') || (*src == sentinel)) {
59 static int __kmp_match_with_sentinel(
char const *a,
char const *b,
size_t len,
67 while (*a && *b && *b != sentinel) {
68 char ca = *a, cb = *b;
70 if (ca >=
'a' && ca <=
'z')
72 if (cb >=
'a' && cb <=
'z')
106 static int __kmp_match_str(
char const *token,
char const *buf,
109 KMP_ASSERT(token != NULL);
110 KMP_ASSERT(buf != NULL);
111 KMP_ASSERT(end != NULL);
113 while (*token && *buf) {
114 char ct = *token, cb = *buf;
116 if (ct >=
'a' && ct <=
'z')
118 if (cb >=
'a' && cb <=
'z')
132 static size_t __kmp_round4k(
size_t size) {
133 size_t _4k = 4 * 1024;
134 if (size & (_4k - 1)) {
136 if (size <= KMP_SIZE_T_MAX - _4k) {
147 int __kmp_convert_to_milliseconds(
char const *data) {
148 int ret, nvalues, factor;
154 if (__kmp_str_match(
"infinit", -1, data))
158 nvalues = KMP_SSCANF(data,
"%lf%c%c", &value, &mult, &extra);
184 factor = 1000 * 60 * 60;
188 factor = 1000 * 24 * 60 * 60;
194 if (value >= ((INT_MAX - 1) / factor))
197 ret = (int)(value * (
double)factor);
202 static int __kmp_strcasecmp_with_sentinel(
char const *a,
char const *b,
208 while (*a && *b && *b != sentinel) {
209 char ca = *a, cb = *b;
211 if (ca >=
'a' && ca <=
'z')
213 if (cb >=
'a' && cb <=
'z')
216 return (
int)(
unsigned char)*a - (
int)(
unsigned char)*b;
221 ? (*b && *b != sentinel)
222 ? (
int)(
unsigned char)*a - (
int)(
unsigned char)*b
224 : (*b && *b != sentinel) ? -1 : 0;
230 typedef struct __kmp_setting kmp_setting_t;
231 typedef struct __kmp_stg_ss_data kmp_stg_ss_data_t;
232 typedef struct __kmp_stg_wp_data kmp_stg_wp_data_t;
233 typedef struct __kmp_stg_fr_data kmp_stg_fr_data_t;
235 typedef void (*kmp_stg_parse_func_t)(
char const *name,
char const *value,
237 typedef void (*kmp_stg_print_func_t)(kmp_str_buf_t *buffer,
char const *name,
240 struct __kmp_setting {
242 kmp_stg_parse_func_t parse;
243 kmp_stg_print_func_t print;
250 struct __kmp_stg_ss_data {
252 kmp_setting_t **rivals;
255 struct __kmp_stg_wp_data {
257 kmp_setting_t **rivals;
260 struct __kmp_stg_fr_data {
262 kmp_setting_t **rivals;
265 static int __kmp_stg_check_rivals(
268 kmp_setting_t **rivals
274 static void __kmp_stg_parse_bool(
char const *name,
char const *value,
276 if (__kmp_str_match_true(value)) {
278 }
else if (__kmp_str_match_false(value)) {
281 __kmp_msg(kmp_ms_warning, KMP_MSG(BadBoolValue, name, value),
282 KMP_HNT(ValidBoolValues), __kmp_msg_null);
286 static void __kmp_stg_parse_size(
char const *name,
char const *value,
287 size_t size_min,
size_t size_max,
288 int *is_specified,
size_t *out,
290 char const *msg = NULL;
292 size_min = __kmp_round4k(size_min);
293 size_max = __kmp_round4k(size_max);
294 #endif // KMP_OS_DARWIN 296 if (is_specified != NULL) {
299 __kmp_str_to_size(value, out, factor, &msg);
301 if (*out > size_max) {
303 msg = KMP_I18N_STR(ValueTooLarge);
304 }
else if (*out < size_min) {
306 msg = KMP_I18N_STR(ValueTooSmall);
309 size_t round4k = __kmp_round4k(*out);
310 if (*out != round4k) {
312 msg = KMP_I18N_STR(NotMultiple4K);
319 if (*out < size_min) {
321 }
else if (*out > size_max) {
328 __kmp_str_buf_init(&buf);
329 __kmp_str_buf_print_size(&buf, *out);
330 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
331 KMP_INFORM(Using_str_Value, name, buf.str);
332 __kmp_str_buf_free(&buf);
337 static void __kmp_stg_parse_str(
char const *name,
char const *value,
340 *out = __kmp_str_format(
"%s", value);
343 static void __kmp_stg_parse_int(
351 char const *msg = NULL;
352 kmp_uint64 uint = *out;
353 __kmp_str_to_uint(value, &uint, &msg);
355 if (uint < (
unsigned int)min) {
356 msg = KMP_I18N_STR(ValueTooSmall);
358 }
else if (uint > (
unsigned int)max) {
359 msg = KMP_I18N_STR(ValueTooLarge);
365 if (uint < (
unsigned int)min) {
367 }
else if (uint > (
unsigned int)max) {
374 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
375 __kmp_str_buf_init(&buf);
376 __kmp_str_buf_print(&buf,
"%" KMP_UINT64_SPEC
"", uint);
377 KMP_INFORM(Using_uint64_Value, name, buf.str);
378 __kmp_str_buf_free(&buf);
383 #if KMP_DEBUG_ADAPTIVE_LOCKS 384 static void __kmp_stg_parse_file(
char const *name,
char const *value,
385 char *suffix,
char **out) {
390 t = (
char *)strrchr(value,
'.');
391 hasSuffix = t && __kmp_str_eqf(t, suffix);
392 t = __kmp_str_format(
"%s%s", value, hasSuffix ?
"" : suffix);
393 __kmp_expand_file_name(buffer,
sizeof(buffer), t);
395 *out = __kmp_str_format(
"%s", buffer);
400 static char *par_range_to_print = NULL;
402 static void __kmp_stg_parse_par_range(
char const *name,
char const *value,
403 int *out_range,
char *out_routine,
404 char *out_file,
int *out_lb,
406 size_t len = KMP_STRLEN(value + 1);
407 par_range_to_print = (
char *)KMP_INTERNAL_MALLOC(len + 1);
408 KMP_STRNCPY_S(par_range_to_print, len + 1, value, len + 1);
409 __kmp_par_range = +1;
410 __kmp_par_range_lb = 0;
411 __kmp_par_range_ub = INT_MAX;
414 if ((value == NULL) || (*value ==
'\0')) {
417 if (!__kmp_strcasecmp_with_sentinel(
"routine", value,
'=')) {
418 value = strchr(value,
'=') + 1;
419 len = __kmp_readstr_with_sentinel(out_routine, value,
420 KMP_PAR_RANGE_ROUTINE_LEN - 1,
',');
422 goto par_range_error;
424 value = strchr(value,
',');
430 if (!__kmp_strcasecmp_with_sentinel(
"filename", value,
'=')) {
431 value = strchr(value,
'=') + 1;
432 len = __kmp_readstr_with_sentinel(out_file, value,
433 KMP_PAR_RANGE_FILENAME_LEN - 1,
',');
435 goto par_range_error;
437 value = strchr(value,
',');
443 if ((!__kmp_strcasecmp_with_sentinel(
"range", value,
'=')) ||
444 (!__kmp_strcasecmp_with_sentinel(
"incl_range", value,
'='))) {
445 value = strchr(value,
'=') + 1;
446 if (KMP_SSCANF(value,
"%d:%d", out_lb, out_ub) != 2) {
447 goto par_range_error;
450 value = strchr(value,
',');
456 if (!__kmp_strcasecmp_with_sentinel(
"excl_range", value,
'=')) {
457 value = strchr(value,
'=') + 1;
458 if (KMP_SSCANF(value,
"%d:%d", out_lb, out_ub) != 2) {
459 goto par_range_error;
462 value = strchr(value,
',');
469 KMP_WARNING(ParRangeSyntax, name);
476 int __kmp_initial_threads_capacity(
int req_nproc) {
481 if (nth < (4 * req_nproc))
482 nth = (4 * req_nproc);
483 if (nth < (4 * __kmp_xproc))
484 nth = (4 * __kmp_xproc);
486 if (nth > __kmp_max_nth)
492 int __kmp_default_tp_capacity(
int req_nproc,
int max_nth,
493 int all_threads_specified) {
496 if (all_threads_specified)
500 if (nth < (4 * req_nproc))
501 nth = (4 * req_nproc);
502 if (nth < (4 * __kmp_xproc))
503 nth = (4 * __kmp_xproc);
505 if (nth > __kmp_max_nth)
514 static void __kmp_stg_print_bool(kmp_str_buf_t *buffer,
char const *name,
516 if (__kmp_env_format) {
517 KMP_STR_BUF_PRINT_BOOL;
519 __kmp_str_buf_print(buffer,
" %s=%s\n", name, value ?
"true" :
"false");
523 static void __kmp_stg_print_int(kmp_str_buf_t *buffer,
char const *name,
525 if (__kmp_env_format) {
526 KMP_STR_BUF_PRINT_INT;
528 __kmp_str_buf_print(buffer,
" %s=%d\n", name, value);
532 static void __kmp_stg_print_uint64(kmp_str_buf_t *buffer,
char const *name,
534 if (__kmp_env_format) {
535 KMP_STR_BUF_PRINT_UINT64;
537 __kmp_str_buf_print(buffer,
" %s=%" KMP_UINT64_SPEC
"\n", name, value);
541 static void __kmp_stg_print_str(kmp_str_buf_t *buffer,
char const *name,
543 if (__kmp_env_format) {
544 KMP_STR_BUF_PRINT_STR;
546 __kmp_str_buf_print(buffer,
" %s=%s\n", name, value);
550 static void __kmp_stg_print_size(kmp_str_buf_t *buffer,
char const *name,
552 if (__kmp_env_format) {
553 KMP_STR_BUF_PRINT_NAME_EX(name);
554 __kmp_str_buf_print_size(buffer, value);
555 __kmp_str_buf_print(buffer,
"'\n");
557 __kmp_str_buf_print(buffer,
" %s=", name);
558 __kmp_str_buf_print_size(buffer, value);
559 __kmp_str_buf_print(buffer,
"\n");
570 static void __kmp_stg_parse_device_thread_limit(
char const *name,
571 char const *value,
void *data) {
572 kmp_setting_t **rivals = (kmp_setting_t **)data;
574 if (strcmp(name,
"KMP_ALL_THREADS") == 0) {
575 KMP_INFORM(EnvVarDeprecated, name,
"KMP_DEVICE_THREAD_LIMIT");
577 rc = __kmp_stg_check_rivals(name, value, rivals);
581 if (!__kmp_strcasecmp_with_sentinel(
"all", value, 0)) {
582 __kmp_max_nth = __kmp_xproc;
583 __kmp_allThreadsSpecified = 1;
585 __kmp_stg_parse_int(name, value, 1, __kmp_sys_max_nth, &__kmp_max_nth);
586 __kmp_allThreadsSpecified = 0;
588 K_DIAG(1, (
"__kmp_max_nth == %d\n", __kmp_max_nth));
592 static void __kmp_stg_print_device_thread_limit(kmp_str_buf_t *buffer,
593 char const *name,
void *data) {
594 __kmp_stg_print_int(buffer, name, __kmp_max_nth);
599 static void __kmp_stg_parse_thread_limit(
char const *name,
char const *value,
601 __kmp_stg_parse_int(name, value, 1, __kmp_sys_max_nth, &__kmp_cg_max_nth);
602 K_DIAG(1, (
"__kmp_cg_max_nth == %d\n", __kmp_cg_max_nth));
606 static void __kmp_stg_print_thread_limit(kmp_str_buf_t *buffer,
607 char const *name,
void *data) {
608 __kmp_stg_print_int(buffer, name, __kmp_cg_max_nth);
613 static void __kmp_stg_parse_teams_thread_limit(
char const *name,
614 char const *value,
void *data) {
615 __kmp_stg_parse_int(name, value, 1, __kmp_sys_max_nth, &__kmp_teams_max_nth);
618 static void __kmp_stg_print_teams_thread_limit(kmp_str_buf_t *buffer,
619 char const *name,
void *data) {
620 __kmp_stg_print_int(buffer, name, __kmp_teams_max_nth);
626 static void __kmp_stg_parse_blocktime(
char const *name,
char const *value,
628 __kmp_dflt_blocktime = __kmp_convert_to_milliseconds(value);
629 if (__kmp_dflt_blocktime < 0) {
630 __kmp_dflt_blocktime = KMP_DEFAULT_BLOCKTIME;
631 __kmp_msg(kmp_ms_warning, KMP_MSG(InvalidValue, name, value),
633 KMP_INFORM(Using_int_Value, name, __kmp_dflt_blocktime);
634 __kmp_env_blocktime = FALSE;
636 if (__kmp_dflt_blocktime < KMP_MIN_BLOCKTIME) {
637 __kmp_dflt_blocktime = KMP_MIN_BLOCKTIME;
638 __kmp_msg(kmp_ms_warning, KMP_MSG(SmallValue, name, value),
640 KMP_INFORM(MinValueUsing, name, __kmp_dflt_blocktime);
641 }
else if (__kmp_dflt_blocktime > KMP_MAX_BLOCKTIME) {
642 __kmp_dflt_blocktime = KMP_MAX_BLOCKTIME;
643 __kmp_msg(kmp_ms_warning, KMP_MSG(LargeValue, name, value),
645 KMP_INFORM(MaxValueUsing, name, __kmp_dflt_blocktime);
647 __kmp_env_blocktime = TRUE;
652 __kmp_monitor_wakeups =
653 KMP_WAKEUPS_FROM_BLOCKTIME(__kmp_dflt_blocktime, __kmp_monitor_wakeups);
655 KMP_INTERVALS_FROM_BLOCKTIME(__kmp_dflt_blocktime, __kmp_monitor_wakeups);
657 K_DIAG(1, (
"__kmp_env_blocktime == %d\n", __kmp_env_blocktime));
658 if (__kmp_env_blocktime) {
659 K_DIAG(1, (
"__kmp_dflt_blocktime == %d\n", __kmp_dflt_blocktime));
663 static void __kmp_stg_print_blocktime(kmp_str_buf_t *buffer,
char const *name,
665 __kmp_stg_print_int(buffer, name, __kmp_dflt_blocktime);
671 static void __kmp_stg_parse_duplicate_lib_ok(
char const *name,
672 char const *value,
void *data) {
675 __kmp_stg_parse_bool(name, value, &__kmp_duplicate_library_ok);
678 static void __kmp_stg_print_duplicate_lib_ok(kmp_str_buf_t *buffer,
679 char const *name,
void *data) {
680 __kmp_stg_print_bool(buffer, name, __kmp_duplicate_library_ok);
686 #if KMP_ARCH_X86 || KMP_ARCH_X86_64 688 static void __kmp_stg_parse_inherit_fp_control(
char const *name,
689 char const *value,
void *data) {
690 __kmp_stg_parse_bool(name, value, &__kmp_inherit_fp_control);
693 static void __kmp_stg_print_inherit_fp_control(kmp_str_buf_t *buffer,
694 char const *name,
void *data) {
696 __kmp_stg_print_bool(buffer, name, __kmp_inherit_fp_control);
703 static char const *blocktime_str = NULL;
708 static void __kmp_stg_parse_wait_policy(
char const *name,
char const *value,
711 kmp_stg_wp_data_t *wait = (kmp_stg_wp_data_t *)data;
714 rc = __kmp_stg_check_rivals(name, value, wait->rivals);
720 if (__kmp_str_match(
"ACTIVE", 1, value)) {
721 __kmp_library = library_turnaround;
722 if (blocktime_str == NULL) {
724 __kmp_dflt_blocktime = KMP_MAX_BLOCKTIME;
726 }
else if (__kmp_str_match(
"PASSIVE", 1, value)) {
727 __kmp_library = library_throughput;
728 if (blocktime_str == NULL) {
730 __kmp_dflt_blocktime = 0;
733 KMP_WARNING(StgInvalidValue, name, value);
736 if (__kmp_str_match(
"serial", 1, value)) {
737 __kmp_library = library_serial;
738 }
else if (__kmp_str_match(
"throughput", 2, value)) {
739 __kmp_library = library_throughput;
740 }
else if (__kmp_str_match(
"turnaround", 2, value)) {
741 __kmp_library = library_turnaround;
742 }
else if (__kmp_str_match(
"dedicated", 1, value)) {
743 __kmp_library = library_turnaround;
744 }
else if (__kmp_str_match(
"multiuser", 1, value)) {
745 __kmp_library = library_throughput;
747 KMP_WARNING(StgInvalidValue, name, value);
750 __kmp_aux_set_library(__kmp_library);
754 static void __kmp_stg_print_wait_policy(kmp_str_buf_t *buffer,
char const *name,
757 kmp_stg_wp_data_t *wait = (kmp_stg_wp_data_t *)data;
758 char const *value = NULL;
761 switch (__kmp_library) {
762 case library_turnaround: {
765 case library_throughput: {
770 switch (__kmp_library) {
771 case library_serial: {
774 case library_turnaround: {
775 value =
"turnaround";
777 case library_throughput: {
778 value =
"throughput";
783 __kmp_stg_print_str(buffer, name, value);
792 static void __kmp_stg_parse_monitor_stacksize(
char const *name,
793 char const *value,
void *data) {
794 __kmp_stg_parse_size(name, value, __kmp_sys_min_stksize, KMP_MAX_STKSIZE,
795 NULL, &__kmp_monitor_stksize, 1);
798 static void __kmp_stg_print_monitor_stacksize(kmp_str_buf_t *buffer,
799 char const *name,
void *data) {
800 if (__kmp_env_format) {
801 if (__kmp_monitor_stksize > 0)
802 KMP_STR_BUF_PRINT_NAME_EX(name);
804 KMP_STR_BUF_PRINT_NAME;
806 __kmp_str_buf_print(buffer,
" %s", name);
808 if (__kmp_monitor_stksize > 0) {
809 __kmp_str_buf_print_size(buffer, __kmp_monitor_stksize);
811 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
813 if (__kmp_env_format && __kmp_monitor_stksize) {
814 __kmp_str_buf_print(buffer,
"'\n");
817 #endif // KMP_USE_MONITOR 822 static void __kmp_stg_parse_settings(
char const *name,
char const *value,
824 __kmp_stg_parse_bool(name, value, &__kmp_settings);
827 static void __kmp_stg_print_settings(kmp_str_buf_t *buffer,
char const *name,
829 __kmp_stg_print_bool(buffer, name, __kmp_settings);
835 static void __kmp_stg_parse_stackpad(
char const *name,
char const *value,
837 __kmp_stg_parse_int(name,
845 static void __kmp_stg_print_stackpad(kmp_str_buf_t *buffer,
char const *name,
847 __kmp_stg_print_int(buffer, name, __kmp_stkpadding);
853 static void __kmp_stg_parse_stackoffset(
char const *name,
char const *value,
855 __kmp_stg_parse_size(name,
864 static void __kmp_stg_print_stackoffset(kmp_str_buf_t *buffer,
char const *name,
866 __kmp_stg_print_size(buffer, name, __kmp_stkoffset);
872 static void __kmp_stg_parse_stacksize(
char const *name,
char const *value,
875 kmp_stg_ss_data_t *stacksize = (kmp_stg_ss_data_t *)data;
878 rc = __kmp_stg_check_rivals(name, value, stacksize->rivals);
882 __kmp_stg_parse_size(name,
884 __kmp_sys_min_stksize,
896 static void __kmp_stg_print_stacksize(kmp_str_buf_t *buffer,
char const *name,
898 kmp_stg_ss_data_t *stacksize = (kmp_stg_ss_data_t *)data;
899 if (__kmp_env_format) {
900 KMP_STR_BUF_PRINT_NAME_EX(name);
901 __kmp_str_buf_print_size(buffer, (__kmp_stksize % 1024)
902 ? __kmp_stksize / stacksize->factor
904 __kmp_str_buf_print(buffer,
"'\n");
906 __kmp_str_buf_print(buffer,
" %s=", name);
907 __kmp_str_buf_print_size(buffer, (__kmp_stksize % 1024)
908 ? __kmp_stksize / stacksize->factor
910 __kmp_str_buf_print(buffer,
"\n");
917 static void __kmp_stg_parse_version(
char const *name,
char const *value,
919 __kmp_stg_parse_bool(name, value, &__kmp_version);
922 static void __kmp_stg_print_version(kmp_str_buf_t *buffer,
char const *name,
924 __kmp_stg_print_bool(buffer, name, __kmp_version);
930 static void __kmp_stg_parse_warnings(
char const *name,
char const *value,
932 __kmp_stg_parse_bool(name, value, &__kmp_generate_warnings);
933 if (__kmp_generate_warnings != kmp_warnings_off) {
936 __kmp_generate_warnings = kmp_warnings_explicit;
940 static void __kmp_stg_print_warnings(kmp_str_buf_t *buffer,
char const *name,
943 __kmp_stg_print_bool(buffer, name, __kmp_generate_warnings);
949 static void __kmp_stg_parse_nested(
char const *name,
char const *value,
951 __kmp_stg_parse_bool(name, value, &__kmp_dflt_nested);
954 static void __kmp_stg_print_nested(kmp_str_buf_t *buffer,
char const *name,
956 __kmp_stg_print_bool(buffer, name, __kmp_dflt_nested);
959 static void __kmp_parse_nested_num_threads(
const char *var,
const char *env,
960 kmp_nested_nthreads_t *nth_array) {
961 const char *next = env;
962 const char *scan = next;
965 int prev_comma = FALSE;
975 if (((*next <
'0') || (*next >
'9')) && (*next !=
',')) {
976 KMP_WARNING(NthSyntaxError, var, env);
982 if (total == 0 || prev_comma) {
990 if (*next >=
'0' && *next <=
'9') {
994 const char *tmp = next;
996 if ((*next ==
' ' || *next ==
'\t') && (*tmp >=
'0' && *tmp <=
'9')) {
997 KMP_WARNING(NthSpacesNotAllowed, var, env);
1002 KMP_DEBUG_ASSERT(total > 0);
1004 KMP_WARNING(NthSyntaxError, var, env);
1009 if (!nth_array->nth) {
1011 nth_array->nth = (
int *)KMP_INTERNAL_MALLOC(
sizeof(
int) * total * 2);
1012 if (nth_array->nth == NULL) {
1013 KMP_FATAL(MemoryAllocFailed);
1015 nth_array->size = total * 2;
1017 if (nth_array->size < total) {
1020 nth_array->size *= 2;
1021 }
while (nth_array->size < total);
1023 nth_array->nth = (
int *)KMP_INTERNAL_REALLOC(
1024 nth_array->nth,
sizeof(
int) * nth_array->size);
1025 if (nth_array->nth == NULL) {
1026 KMP_FATAL(MemoryAllocFailed);
1030 nth_array->used = total;
1038 if (*scan ==
'\0') {
1048 nth_array->nth[i++] = 0;
1050 }
else if (prev_comma) {
1052 nth_array->nth[i] = nth_array->nth[i - 1];
1061 if (*scan >=
'0' && *scan <=
'9') {
1063 const char *buf = scan;
1064 char const *msg = NULL;
1069 num = __kmp_str_to_int(buf, *scan);
1070 if (num < KMP_MIN_NTH) {
1071 msg = KMP_I18N_STR(ValueTooSmall);
1073 }
else if (num > __kmp_sys_max_nth) {
1074 msg = KMP_I18N_STR(ValueTooLarge);
1075 num = __kmp_sys_max_nth;
1079 KMP_WARNING(ParseSizeIntWarn, var, env, msg);
1080 KMP_INFORM(Using_int_Value, var, num);
1082 nth_array->nth[i++] = num;
1087 static void __kmp_stg_parse_num_threads(
char const *name,
char const *value,
1090 if (!__kmp_strcasecmp_with_sentinel(
"all", value, 0)) {
1092 __kmp_nested_nth.nth = (
int *)KMP_INTERNAL_MALLOC(
sizeof(
int));
1093 __kmp_nested_nth.size = __kmp_nested_nth.used = 1;
1094 __kmp_nested_nth.nth[0] = __kmp_dflt_team_nth = __kmp_dflt_team_nth_ub =
1097 __kmp_parse_nested_num_threads(name, value, &__kmp_nested_nth);
1098 if (__kmp_nested_nth.nth) {
1099 __kmp_dflt_team_nth = __kmp_nested_nth.nth[0];
1100 if (__kmp_dflt_team_nth_ub < __kmp_dflt_team_nth) {
1101 __kmp_dflt_team_nth_ub = __kmp_dflt_team_nth;
1105 K_DIAG(1, (
"__kmp_dflt_team_nth == %d\n", __kmp_dflt_team_nth));
1108 static void __kmp_stg_print_num_threads(kmp_str_buf_t *buffer,
char const *name,
1110 if (__kmp_env_format) {
1111 KMP_STR_BUF_PRINT_NAME;
1113 __kmp_str_buf_print(buffer,
" %s", name);
1115 if (__kmp_nested_nth.used) {
1117 __kmp_str_buf_init(&buf);
1118 for (
int i = 0; i < __kmp_nested_nth.used; i++) {
1119 __kmp_str_buf_print(&buf,
"%d", __kmp_nested_nth.nth[i]);
1120 if (i < __kmp_nested_nth.used - 1) {
1121 __kmp_str_buf_print(&buf,
",");
1124 __kmp_str_buf_print(buffer,
"='%s'\n", buf.str);
1125 __kmp_str_buf_free(&buf);
1127 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
1134 static void __kmp_stg_parse_tasking(
char const *name,
char const *value,
1136 __kmp_stg_parse_int(name, value, 0, (
int)tskm_max,
1137 (
int *)&__kmp_tasking_mode);
1140 static void __kmp_stg_print_tasking(kmp_str_buf_t *buffer,
char const *name,
1142 __kmp_stg_print_int(buffer, name, __kmp_tasking_mode);
1145 static void __kmp_stg_parse_task_stealing(
char const *name,
char const *value,
1147 __kmp_stg_parse_int(name, value, 0, 1,
1148 (
int *)&__kmp_task_stealing_constraint);
1151 static void __kmp_stg_print_task_stealing(kmp_str_buf_t *buffer,
1152 char const *name,
void *data) {
1153 __kmp_stg_print_int(buffer, name, __kmp_task_stealing_constraint);
1156 static void __kmp_stg_parse_max_active_levels(
char const *name,
1157 char const *value,
void *data) {
1158 __kmp_stg_parse_int(name, value, 0, KMP_MAX_ACTIVE_LEVELS_LIMIT,
1159 &__kmp_dflt_max_active_levels);
1162 static void __kmp_stg_print_max_active_levels(kmp_str_buf_t *buffer,
1163 char const *name,
void *data) {
1164 __kmp_stg_print_int(buffer, name, __kmp_dflt_max_active_levels);
1170 static void __kmp_stg_parse_default_device(
char const *name,
char const *value,
1172 __kmp_stg_parse_int(name, value, 0, KMP_MAX_DEFAULT_DEVICE_LIMIT,
1173 &__kmp_default_device);
1176 static void __kmp_stg_print_default_device(kmp_str_buf_t *buffer,
1177 char const *name,
void *data) {
1178 __kmp_stg_print_int(buffer, name, __kmp_default_device);
1185 static void __kmp_stg_parse_target_offload(
char const *name,
char const *value,
1187 const char *next = value;
1188 const char *scan = next;
1190 __kmp_target_offload = tgt_default;
1195 if (__kmp_match_str(
"MANDATORY", scan, &next)) {
1196 __kmp_target_offload = tgt_mandatory;
1197 }
else if (__kmp_match_str(
"DISABLED", scan, &next)) {
1198 __kmp_target_offload = tgt_disabled;
1199 }
else if (__kmp_match_str(
"DEFAULT", scan, &next)) {
1200 __kmp_target_offload = tgt_default;
1202 KMP_WARNING(SyntaxErrorUsing, name,
"DEFAULT");
1207 static void __kmp_stg_print_target_offload(kmp_str_buf_t *buffer,
1208 char const *name,
void *data) {
1209 const char *value = NULL;
1210 if (__kmp_target_offload == tgt_default)
1212 else if (__kmp_target_offload == tgt_mandatory)
1213 value =
"MANDATORY";
1214 else if (__kmp_target_offload == tgt_disabled)
1217 __kmp_str_buf_print(buffer,
" %s=%s\n", name, value);
1225 static void __kmp_stg_parse_max_task_priority(
char const *name,
1226 char const *value,
void *data) {
1227 __kmp_stg_parse_int(name, value, 0, KMP_MAX_TASK_PRIORITY_LIMIT,
1228 &__kmp_max_task_priority);
1231 static void __kmp_stg_print_max_task_priority(kmp_str_buf_t *buffer,
1232 char const *name,
void *data) {
1233 __kmp_stg_print_int(buffer, name, __kmp_max_task_priority);
1238 static void __kmp_stg_parse_taskloop_min_tasks(
char const *name,
1239 char const *value,
void *data) {
1241 __kmp_stg_parse_int(name, value, 0, INT_MAX, &tmp);
1242 __kmp_taskloop_min_tasks = tmp;
1245 static void __kmp_stg_print_taskloop_min_tasks(kmp_str_buf_t *buffer,
1246 char const *name,
void *data) {
1247 __kmp_stg_print_int(buffer, name, __kmp_taskloop_min_tasks);
1249 #endif // OMP_45_ENABLED 1253 static void __kmp_stg_parse_disp_buffers(
char const *name,
char const *value,
1255 if (TCR_4(__kmp_init_serial)) {
1256 KMP_WARNING(EnvSerialWarn, name);
1259 __kmp_stg_parse_int(name, value, 1, KMP_MAX_NTH, &__kmp_dispatch_num_buffers);
1262 static void __kmp_stg_print_disp_buffers(kmp_str_buf_t *buffer,
1263 char const *name,
void *data) {
1264 __kmp_stg_print_int(buffer, name, __kmp_dispatch_num_buffers);
1267 #if KMP_NESTED_HOT_TEAMS 1271 static void __kmp_stg_parse_hot_teams_level(
char const *name,
char const *value,
1273 if (TCR_4(__kmp_init_parallel)) {
1274 KMP_WARNING(EnvParallelWarn, name);
1277 __kmp_stg_parse_int(name, value, 0, KMP_MAX_ACTIVE_LEVELS_LIMIT,
1278 &__kmp_hot_teams_max_level);
1281 static void __kmp_stg_print_hot_teams_level(kmp_str_buf_t *buffer,
1282 char const *name,
void *data) {
1283 __kmp_stg_print_int(buffer, name, __kmp_hot_teams_max_level);
1286 static void __kmp_stg_parse_hot_teams_mode(
char const *name,
char const *value,
1288 if (TCR_4(__kmp_init_parallel)) {
1289 KMP_WARNING(EnvParallelWarn, name);
1292 __kmp_stg_parse_int(name, value, 0, KMP_MAX_ACTIVE_LEVELS_LIMIT,
1293 &__kmp_hot_teams_mode);
1296 static void __kmp_stg_print_hot_teams_mode(kmp_str_buf_t *buffer,
1297 char const *name,
void *data) {
1298 __kmp_stg_print_int(buffer, name, __kmp_hot_teams_mode);
1301 #endif // KMP_NESTED_HOT_TEAMS 1306 #if KMP_HANDLE_SIGNALS 1308 static void __kmp_stg_parse_handle_signals(
char const *name,
char const *value,
1310 __kmp_stg_parse_bool(name, value, &__kmp_handle_signals);
1313 static void __kmp_stg_print_handle_signals(kmp_str_buf_t *buffer,
1314 char const *name,
void *data) {
1315 __kmp_stg_print_bool(buffer, name, __kmp_handle_signals);
1318 #endif // KMP_HANDLE_SIGNALS 1325 #define KMP_STG_X_DEBUG(x) \ 1326 static void __kmp_stg_parse_##x##_debug(char const *name, char const *value, \ 1328 __kmp_stg_parse_int(name, value, 0, INT_MAX, &kmp_##x##_debug); \ 1330 static void __kmp_stg_print_##x##_debug(kmp_str_buf_t *buffer, \ 1331 char const *name, void *data) { \ 1332 __kmp_stg_print_int(buffer, name, kmp_##x##_debug); \ 1342 #undef KMP_STG_X_DEBUG 1344 static void __kmp_stg_parse_debug(
char const *name,
char const *value,
1347 __kmp_stg_parse_int(name, value, 0, INT_MAX, &debug);
1348 if (kmp_a_debug < debug) {
1349 kmp_a_debug = debug;
1351 if (kmp_b_debug < debug) {
1352 kmp_b_debug = debug;
1354 if (kmp_c_debug < debug) {
1355 kmp_c_debug = debug;
1357 if (kmp_d_debug < debug) {
1358 kmp_d_debug = debug;
1360 if (kmp_e_debug < debug) {
1361 kmp_e_debug = debug;
1363 if (kmp_f_debug < debug) {
1364 kmp_f_debug = debug;
1368 static void __kmp_stg_parse_debug_buf(
char const *name,
char const *value,
1370 __kmp_stg_parse_bool(name, value, &__kmp_debug_buf);
1374 if (__kmp_debug_buf) {
1376 int elements = __kmp_debug_buf_lines * __kmp_debug_buf_chars;
1379 __kmp_debug_buffer = (
char *)__kmp_page_allocate(elements *
sizeof(
char));
1380 for (i = 0; i < elements; i += __kmp_debug_buf_chars)
1381 __kmp_debug_buffer[i] =
'\0';
1383 __kmp_debug_count = 0;
1385 K_DIAG(1, (
"__kmp_debug_buf = %d\n", __kmp_debug_buf));
1388 static void __kmp_stg_print_debug_buf(kmp_str_buf_t *buffer,
char const *name,
1390 __kmp_stg_print_bool(buffer, name, __kmp_debug_buf);
1393 static void __kmp_stg_parse_debug_buf_atomic(
char const *name,
1394 char const *value,
void *data) {
1395 __kmp_stg_parse_bool(name, value, &__kmp_debug_buf_atomic);
1398 static void __kmp_stg_print_debug_buf_atomic(kmp_str_buf_t *buffer,
1399 char const *name,
void *data) {
1400 __kmp_stg_print_bool(buffer, name, __kmp_debug_buf_atomic);
1403 static void __kmp_stg_parse_debug_buf_chars(
char const *name,
char const *value,
1405 __kmp_stg_parse_int(name, value, KMP_DEBUG_BUF_CHARS_MIN, INT_MAX,
1406 &__kmp_debug_buf_chars);
1409 static void __kmp_stg_print_debug_buf_chars(kmp_str_buf_t *buffer,
1410 char const *name,
void *data) {
1411 __kmp_stg_print_int(buffer, name, __kmp_debug_buf_chars);
1414 static void __kmp_stg_parse_debug_buf_lines(
char const *name,
char const *value,
1416 __kmp_stg_parse_int(name, value, KMP_DEBUG_BUF_LINES_MIN, INT_MAX,
1417 &__kmp_debug_buf_lines);
1420 static void __kmp_stg_print_debug_buf_lines(kmp_str_buf_t *buffer,
1421 char const *name,
void *data) {
1422 __kmp_stg_print_int(buffer, name, __kmp_debug_buf_lines);
1425 static void __kmp_stg_parse_diag(
char const *name,
char const *value,
1427 __kmp_stg_parse_int(name, value, 0, INT_MAX, &kmp_diag);
1430 static void __kmp_stg_print_diag(kmp_str_buf_t *buffer,
char const *name,
1432 __kmp_stg_print_int(buffer, name, kmp_diag);
1440 static void __kmp_stg_parse_align_alloc(
char const *name,
char const *value,
1442 __kmp_stg_parse_size(name, value, CACHE_LINE, INT_MAX, NULL,
1443 &__kmp_align_alloc, 1);
1446 static void __kmp_stg_print_align_alloc(kmp_str_buf_t *buffer,
char const *name,
1448 __kmp_stg_print_size(buffer, name, __kmp_align_alloc);
1457 static void __kmp_stg_parse_barrier_branch_bit(
char const *name,
1458 char const *value,
void *data) {
1462 for (
int i = bs_plain_barrier; i < bs_last_barrier; i++) {
1463 var = __kmp_barrier_branch_bit_env_name[i];
1464 if ((strcmp(var, name) == 0) && (value != 0)) {
1467 comma = CCAST(
char *, strchr(value,
','));
1468 __kmp_barrier_gather_branch_bits[i] =
1469 (kmp_uint32)__kmp_str_to_int(value,
',');
1471 if (comma == NULL) {
1472 __kmp_barrier_release_branch_bits[i] = __kmp_barrier_release_bb_dflt;
1474 __kmp_barrier_release_branch_bits[i] =
1475 (kmp_uint32)__kmp_str_to_int(comma + 1, 0);
1477 if (__kmp_barrier_release_branch_bits[i] > KMP_MAX_BRANCH_BITS) {
1478 __kmp_msg(kmp_ms_warning,
1479 KMP_MSG(BarrReleaseValueInvalid, name, comma + 1),
1481 __kmp_barrier_release_branch_bits[i] = __kmp_barrier_release_bb_dflt;
1484 if (__kmp_barrier_gather_branch_bits[i] > KMP_MAX_BRANCH_BITS) {
1485 KMP_WARNING(BarrGatherValueInvalid, name, value);
1486 KMP_INFORM(Using_uint_Value, name, __kmp_barrier_gather_bb_dflt);
1487 __kmp_barrier_gather_branch_bits[i] = __kmp_barrier_gather_bb_dflt;
1490 K_DIAG(1, (
"%s == %d,%d\n", __kmp_barrier_branch_bit_env_name[i],
1491 __kmp_barrier_gather_branch_bits[i],
1492 __kmp_barrier_release_branch_bits[i]))
1496 static void __kmp_stg_print_barrier_branch_bit(kmp_str_buf_t *buffer,
1497 char const *name,
void *data) {
1499 for (
int i = bs_plain_barrier; i < bs_last_barrier; i++) {
1500 var = __kmp_barrier_branch_bit_env_name[i];
1501 if (strcmp(var, name) == 0) {
1502 if (__kmp_env_format) {
1503 KMP_STR_BUF_PRINT_NAME_EX(__kmp_barrier_branch_bit_env_name[i]);
1505 __kmp_str_buf_print(buffer,
" %s='",
1506 __kmp_barrier_branch_bit_env_name[i]);
1508 __kmp_str_buf_print(buffer,
"%d,%d'\n",
1509 __kmp_barrier_gather_branch_bits[i],
1510 __kmp_barrier_release_branch_bits[i]);
1522 static void __kmp_stg_parse_barrier_pattern(
char const *name,
char const *value,
1527 for (
int i = bs_plain_barrier; i < bs_last_barrier; i++) {
1528 var = __kmp_barrier_pattern_env_name[i];
1530 if ((strcmp(var, name) == 0) && (value != 0)) {
1532 char *comma = CCAST(
char *, strchr(value,
','));
1535 for (j = bp_linear_bar; j < bp_last_bar; j++) {
1536 if (__kmp_match_with_sentinel(__kmp_barrier_pattern_name[j], value, 1,
1538 __kmp_barrier_gather_pattern[i] = (kmp_bar_pat_e)j;
1542 if (j == bp_last_bar) {
1543 KMP_WARNING(BarrGatherValueInvalid, name, value);
1544 KMP_INFORM(Using_str_Value, name,
1545 __kmp_barrier_pattern_name[bp_linear_bar]);
1549 if (comma != NULL) {
1550 for (j = bp_linear_bar; j < bp_last_bar; j++) {
1551 if (__kmp_str_match(__kmp_barrier_pattern_name[j], 1, comma + 1)) {
1552 __kmp_barrier_release_pattern[i] = (kmp_bar_pat_e)j;
1556 if (j == bp_last_bar) {
1557 __kmp_msg(kmp_ms_warning,
1558 KMP_MSG(BarrReleaseValueInvalid, name, comma + 1),
1560 KMP_INFORM(Using_str_Value, name,
1561 __kmp_barrier_pattern_name[bp_linear_bar]);
1568 static void __kmp_stg_print_barrier_pattern(kmp_str_buf_t *buffer,
1569 char const *name,
void *data) {
1571 for (
int i = bs_plain_barrier; i < bs_last_barrier; i++) {
1572 var = __kmp_barrier_pattern_env_name[i];
1573 if (strcmp(var, name) == 0) {
1574 int j = __kmp_barrier_gather_pattern[i];
1575 int k = __kmp_barrier_release_pattern[i];
1576 if (__kmp_env_format) {
1577 KMP_STR_BUF_PRINT_NAME_EX(__kmp_barrier_pattern_env_name[i]);
1579 __kmp_str_buf_print(buffer,
" %s='",
1580 __kmp_barrier_pattern_env_name[i]);
1582 __kmp_str_buf_print(buffer,
"%s,%s'\n", __kmp_barrier_pattern_name[j],
1583 __kmp_barrier_pattern_name[k]);
1591 static void __kmp_stg_parse_abort_delay(
char const *name,
char const *value,
1595 int delay = __kmp_abort_delay / 1000;
1596 __kmp_stg_parse_int(name, value, 0, INT_MAX / 1000, &delay);
1597 __kmp_abort_delay = delay * 1000;
1600 static void __kmp_stg_print_abort_delay(kmp_str_buf_t *buffer,
char const *name,
1602 __kmp_stg_print_int(buffer, name, __kmp_abort_delay);
1608 static void __kmp_stg_parse_cpuinfo_file(
char const *name,
char const *value,
1610 #if KMP_AFFINITY_SUPPORTED 1611 __kmp_stg_parse_str(name, value, &__kmp_cpuinfo_file);
1612 K_DIAG(1, (
"__kmp_cpuinfo_file == %s\n", __kmp_cpuinfo_file));
1616 static void __kmp_stg_print_cpuinfo_file(kmp_str_buf_t *buffer,
1617 char const *name,
void *data) {
1618 #if KMP_AFFINITY_SUPPORTED 1619 if (__kmp_env_format) {
1620 KMP_STR_BUF_PRINT_NAME;
1622 __kmp_str_buf_print(buffer,
" %s", name);
1624 if (__kmp_cpuinfo_file) {
1625 __kmp_str_buf_print(buffer,
"='%s'\n", __kmp_cpuinfo_file);
1627 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
1635 static void __kmp_stg_parse_force_reduction(
char const *name,
char const *value,
1637 kmp_stg_fr_data_t *reduction = (kmp_stg_fr_data_t *)data;
1640 rc = __kmp_stg_check_rivals(name, value, reduction->rivals);
1644 if (reduction->force) {
1646 if (__kmp_str_match(
"critical", 0, value))
1647 __kmp_force_reduction_method = critical_reduce_block;
1648 else if (__kmp_str_match(
"atomic", 0, value))
1649 __kmp_force_reduction_method = atomic_reduce_block;
1650 else if (__kmp_str_match(
"tree", 0, value))
1651 __kmp_force_reduction_method = tree_reduce_block;
1653 KMP_FATAL(UnknownForceReduction, name, value);
1657 __kmp_stg_parse_bool(name, value, &__kmp_determ_red);
1658 if (__kmp_determ_red) {
1659 __kmp_force_reduction_method = tree_reduce_block;
1661 __kmp_force_reduction_method = reduction_method_not_defined;
1664 K_DIAG(1, (
"__kmp_force_reduction_method == %d\n",
1665 __kmp_force_reduction_method));
1668 static void __kmp_stg_print_force_reduction(kmp_str_buf_t *buffer,
1669 char const *name,
void *data) {
1671 kmp_stg_fr_data_t *reduction = (kmp_stg_fr_data_t *)data;
1672 if (reduction->force) {
1673 if (__kmp_force_reduction_method == critical_reduce_block) {
1674 __kmp_stg_print_str(buffer, name,
"critical");
1675 }
else if (__kmp_force_reduction_method == atomic_reduce_block) {
1676 __kmp_stg_print_str(buffer, name,
"atomic");
1677 }
else if (__kmp_force_reduction_method == tree_reduce_block) {
1678 __kmp_stg_print_str(buffer, name,
"tree");
1680 if (__kmp_env_format) {
1681 KMP_STR_BUF_PRINT_NAME;
1683 __kmp_str_buf_print(buffer,
" %s", name);
1685 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
1688 __kmp_stg_print_bool(buffer, name, __kmp_determ_red);
1696 static void __kmp_stg_parse_storage_map(
char const *name,
char const *value,
1698 if (__kmp_str_match(
"verbose", 1, value)) {
1699 __kmp_storage_map = TRUE;
1700 __kmp_storage_map_verbose = TRUE;
1701 __kmp_storage_map_verbose_specified = TRUE;
1704 __kmp_storage_map_verbose = FALSE;
1705 __kmp_stg_parse_bool(name, value, &__kmp_storage_map);
1709 static void __kmp_stg_print_storage_map(kmp_str_buf_t *buffer,
char const *name,
1711 if (__kmp_storage_map_verbose || __kmp_storage_map_verbose_specified) {
1712 __kmp_stg_print_str(buffer, name,
"verbose");
1714 __kmp_stg_print_bool(buffer, name, __kmp_storage_map);
1721 static void __kmp_stg_parse_all_threadprivate(
char const *name,
1722 char const *value,
void *data) {
1723 __kmp_stg_parse_int(name, value,
1724 __kmp_allThreadsSpecified ? __kmp_max_nth : 1,
1725 __kmp_max_nth, &__kmp_tp_capacity);
1728 static void __kmp_stg_print_all_threadprivate(kmp_str_buf_t *buffer,
1729 char const *name,
void *data) {
1730 __kmp_stg_print_int(buffer, name, __kmp_tp_capacity);
1736 static void __kmp_stg_parse_foreign_threads_threadprivate(
char const *name,
1739 __kmp_stg_parse_bool(name, value, &__kmp_foreign_tp);
1742 static void __kmp_stg_print_foreign_threads_threadprivate(kmp_str_buf_t *buffer,
1745 __kmp_stg_print_bool(buffer, name, __kmp_foreign_tp);
1751 #if KMP_AFFINITY_SUPPORTED 1753 static int __kmp_parse_affinity_proc_id_list(
const char *var,
const char *env,
1754 const char **nextEnv,
1756 const char *scan = env;
1757 const char *next = scan;
1763 int start, end, stride;
1767 if (*next ==
'\0') {
1778 if ((*next <
'0') || (*next >
'9')) {
1779 KMP_WARNING(AffSyntaxError, var);
1783 num = __kmp_str_to_int(scan, *next);
1784 KMP_ASSERT(num >= 0);
1802 if ((*next <
'0') || (*next >
'9')) {
1803 KMP_WARNING(AffSyntaxError, var);
1808 num = __kmp_str_to_int(scan, *next);
1809 KMP_ASSERT(num >= 0);
1822 if ((*next <
'0') || (*next >
'9')) {
1824 KMP_WARNING(AffSyntaxError, var);
1832 start = __kmp_str_to_int(scan, *next);
1833 KMP_ASSERT(start >= 0);
1852 if ((*next <
'0') || (*next >
'9')) {
1853 KMP_WARNING(AffSyntaxError, var);
1857 end = __kmp_str_to_int(scan, *next);
1858 KMP_ASSERT(end >= 0);
1875 if ((*next <
'0') || (*next >
'9')) {
1876 KMP_WARNING(AffSyntaxError, var);
1880 stride = __kmp_str_to_int(scan, *next);
1881 KMP_ASSERT(stride >= 0);
1887 KMP_WARNING(AffZeroStride, var);
1892 KMP_WARNING(AffStartGreaterEnd, var, start, end);
1897 KMP_WARNING(AffStrideLessZero, var, start, end);
1901 if ((end - start) / stride > 65536) {
1902 KMP_WARNING(AffRangeTooBig, var, end, start, stride);
1919 int len = next - env;
1920 char *retlist = (
char *)__kmp_allocate((len + 1) *
sizeof(char));
1921 KMP_MEMCPY_S(retlist, (len + 1) *
sizeof(
char), env, len *
sizeof(
char));
1922 retlist[len] =
'\0';
1923 *proclist = retlist;
1930 static kmp_setting_t *__kmp_affinity_notype = NULL;
1932 static void __kmp_parse_affinity_env(
char const *name,
char const *value,
1933 enum affinity_type *out_type,
1934 char **out_proclist,
int *out_verbose,
1935 int *out_warn,
int *out_respect,
1936 enum affinity_gran *out_gran,
1937 int *out_gran_levels,
int *out_dups,
1938 int *out_compact,
int *out_offset) {
1939 char *buffer = NULL;
1949 int max_proclist = 0;
1956 KMP_ASSERT(value != NULL);
1958 if (TCR_4(__kmp_init_middle)) {
1959 KMP_WARNING(EnvMiddleWarn, name);
1960 __kmp_env_toPrint(name, 0);
1963 __kmp_env_toPrint(name, 1);
1966 __kmp_str_format(
"%s", value);
1976 #define EMIT_WARN(skip, errlist) \ 1980 SKIP_TO(next, ','); \ 1984 KMP_WARNING errlist; \ 1993 #define _set_param(_guard, _var, _val) \ 1995 if (_guard == 0) { \ 1998 EMIT_WARN(FALSE, (AffParamDefined, name, start)); \ 2003 #define set_type(val) _set_param(type, *out_type, val) 2004 #define set_verbose(val) _set_param(verbose, *out_verbose, val) 2005 #define set_warnings(val) _set_param(warnings, *out_warn, val) 2006 #define set_respect(val) _set_param(respect, *out_respect, val) 2007 #define set_dups(val) _set_param(dups, *out_dups, val) 2008 #define set_proclist(val) _set_param(proclist, *out_proclist, val) 2010 #define set_gran(val, levels) \ 2014 *out_gran_levels = levels; \ 2016 EMIT_WARN(FALSE, (AffParamDefined, name, start)); \ 2022 KMP_DEBUG_ASSERT((__kmp_nested_proc_bind.bind_types != NULL) &&
2023 (__kmp_nested_proc_bind.used > 0));
2026 while (*buf !=
'\0') {
2029 if (__kmp_match_str(
"none", buf, CCAST(
const char **, &next))) {
2030 set_type(affinity_none);
2032 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
2035 }
else if (__kmp_match_str(
"scatter", buf, CCAST(
const char **, &next))) {
2036 set_type(affinity_scatter);
2038 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2041 }
else if (__kmp_match_str(
"compact", buf, CCAST(
const char **, &next))) {
2042 set_type(affinity_compact);
2044 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2047 }
else if (__kmp_match_str(
"logical", buf, CCAST(
const char **, &next))) {
2048 set_type(affinity_logical);
2050 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2053 }
else if (__kmp_match_str(
"physical", buf, CCAST(
const char **, &next))) {
2054 set_type(affinity_physical);
2056 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2059 }
else if (__kmp_match_str(
"explicit", buf, CCAST(
const char **, &next))) {
2060 set_type(affinity_explicit);
2062 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2065 }
else if (__kmp_match_str(
"balanced", buf, CCAST(
const char **, &next))) {
2066 set_type(affinity_balanced);
2068 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2071 }
else if (__kmp_match_str(
"disabled", buf, CCAST(
const char **, &next))) {
2072 set_type(affinity_disabled);
2074 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
2077 }
else if (__kmp_match_str(
"verbose", buf, CCAST(
const char **, &next))) {
2080 }
else if (__kmp_match_str(
"noverbose", buf, CCAST(
const char **, &next))) {
2083 }
else if (__kmp_match_str(
"warnings", buf, CCAST(
const char **, &next))) {
2086 }
else if (__kmp_match_str(
"nowarnings", buf,
2087 CCAST(
const char **, &next))) {
2088 set_warnings(FALSE);
2090 }
else if (__kmp_match_str(
"respect", buf, CCAST(
const char **, &next))) {
2093 }
else if (__kmp_match_str(
"norespect", buf, CCAST(
const char **, &next))) {
2096 }
else if (__kmp_match_str(
"duplicates", buf,
2097 CCAST(
const char **, &next)) ||
2098 __kmp_match_str(
"dups", buf, CCAST(
const char **, &next))) {
2101 }
else if (__kmp_match_str(
"noduplicates", buf,
2102 CCAST(
const char **, &next)) ||
2103 __kmp_match_str(
"nodups", buf, CCAST(
const char **, &next))) {
2106 }
else if (__kmp_match_str(
"granularity", buf,
2107 CCAST(
const char **, &next)) ||
2108 __kmp_match_str(
"gran", buf, CCAST(
const char **, &next))) {
2111 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2118 if (__kmp_match_str(
"fine", buf, CCAST(
const char **, &next))) {
2119 set_gran(affinity_gran_fine, -1);
2121 }
else if (__kmp_match_str(
"thread", buf, CCAST(
const char **, &next))) {
2122 set_gran(affinity_gran_thread, -1);
2124 }
else if (__kmp_match_str(
"core", buf, CCAST(
const char **, &next))) {
2125 set_gran(affinity_gran_core, -1);
2128 }
else if (__kmp_match_str(
"tile", buf, CCAST(
const char **, &next))) {
2129 set_gran(affinity_gran_tile, -1);
2132 }
else if (__kmp_match_str(
"package", buf, CCAST(
const char **, &next))) {
2133 set_gran(affinity_gran_package, -1);
2135 }
else if (__kmp_match_str(
"node", buf, CCAST(
const char **, &next))) {
2136 set_gran(affinity_gran_node, -1);
2138 #if KMP_GROUP_AFFINITY 2139 }
else if (__kmp_match_str(
"group", buf, CCAST(
const char **, &next))) {
2140 set_gran(affinity_gran_group, -1);
2143 }
else if ((*buf >=
'0') && (*buf <=
'9')) {
2147 n = __kmp_str_to_int(buf, *next);
2150 set_gran(affinity_gran_default, n);
2152 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2155 }
else if (__kmp_match_str(
"proclist", buf, CCAST(
const char **, &next))) {
2156 char *temp_proclist;
2160 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2166 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2171 if (!__kmp_parse_affinity_proc_id_list(
2172 name, buf, CCAST(
const char **, &next), &temp_proclist)) {
2184 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2188 set_proclist(temp_proclist);
2189 }
else if ((*buf >=
'0') && (*buf <=
'9')) {
2194 n = __kmp_str_to_int(buf, *next);
2200 KMP_WARNING(AffManyParams, name, start);
2204 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2212 }
else if (*next !=
'\0') {
2213 const char *temp = next;
2214 EMIT_WARN(TRUE, (ParseExtraCharsWarn, name, temp));
2226 #undef set_granularity 2228 __kmp_str_free(&buffer);
2232 KMP_WARNING(AffProcListNoType, name);
2233 *out_type = affinity_explicit;
2235 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2237 }
else if (*out_type != affinity_explicit) {
2238 KMP_WARNING(AffProcListNotExplicit, name);
2239 KMP_ASSERT(*out_proclist != NULL);
2240 KMP_INTERNAL_FREE(*out_proclist);
2241 *out_proclist = NULL;
2244 switch (*out_type) {
2245 case affinity_logical:
2246 case affinity_physical: {
2248 *out_offset = number[0];
2251 KMP_WARNING(AffManyParamsForLogic, name, number[1]);
2254 case affinity_balanced: {
2256 *out_compact = number[0];
2259 *out_offset = number[1];
2262 if (__kmp_affinity_gran == affinity_gran_default) {
2263 #if KMP_MIC_SUPPORTED 2264 if (__kmp_mic_type != non_mic) {
2265 if (__kmp_affinity_verbose || __kmp_affinity_warnings) {
2266 KMP_WARNING(AffGranUsing,
"KMP_AFFINITY",
"fine");
2268 __kmp_affinity_gran = affinity_gran_fine;
2272 if (__kmp_affinity_verbose || __kmp_affinity_warnings) {
2273 KMP_WARNING(AffGranUsing,
"KMP_AFFINITY",
"core");
2275 __kmp_affinity_gran = affinity_gran_core;
2279 case affinity_scatter:
2280 case affinity_compact: {
2282 *out_compact = number[0];
2285 *out_offset = number[1];
2288 case affinity_explicit: {
2289 if (*out_proclist == NULL) {
2290 KMP_WARNING(AffNoProcList, name);
2291 __kmp_affinity_type = affinity_none;
2294 KMP_WARNING(AffNoParam, name,
"explicit");
2297 case affinity_none: {
2299 KMP_WARNING(AffNoParam, name,
"none");
2302 case affinity_disabled: {
2304 KMP_WARNING(AffNoParam, name,
"disabled");
2307 case affinity_default: {
2309 KMP_WARNING(AffNoParam, name,
"default");
2312 default: { KMP_ASSERT(0); }
2316 static void __kmp_stg_parse_affinity(
char const *name,
char const *value,
2318 kmp_setting_t **rivals = (kmp_setting_t **)data;
2321 rc = __kmp_stg_check_rivals(name, value, rivals);
2326 __kmp_parse_affinity_env(name, value, &__kmp_affinity_type,
2327 &__kmp_affinity_proclist, &__kmp_affinity_verbose,
2328 &__kmp_affinity_warnings,
2329 &__kmp_affinity_respect_mask, &__kmp_affinity_gran,
2330 &__kmp_affinity_gran_levels, &__kmp_affinity_dups,
2331 &__kmp_affinity_compact, &__kmp_affinity_offset);
2335 static void __kmp_stg_print_affinity(kmp_str_buf_t *buffer,
char const *name,
2337 if (__kmp_env_format) {
2338 KMP_STR_BUF_PRINT_NAME_EX(name);
2340 __kmp_str_buf_print(buffer,
" %s='", name);
2342 if (__kmp_affinity_verbose) {
2343 __kmp_str_buf_print(buffer,
"%s,",
"verbose");
2345 __kmp_str_buf_print(buffer,
"%s,",
"noverbose");
2347 if (__kmp_affinity_warnings) {
2348 __kmp_str_buf_print(buffer,
"%s,",
"warnings");
2350 __kmp_str_buf_print(buffer,
"%s,",
"nowarnings");
2352 if (KMP_AFFINITY_CAPABLE()) {
2353 if (__kmp_affinity_respect_mask) {
2354 __kmp_str_buf_print(buffer,
"%s,",
"respect");
2356 __kmp_str_buf_print(buffer,
"%s,",
"norespect");
2358 switch (__kmp_affinity_gran) {
2359 case affinity_gran_default:
2360 __kmp_str_buf_print(buffer,
"%s",
"granularity=default,");
2362 case affinity_gran_fine:
2363 __kmp_str_buf_print(buffer,
"%s",
"granularity=fine,");
2365 case affinity_gran_thread:
2366 __kmp_str_buf_print(buffer,
"%s",
"granularity=thread,");
2368 case affinity_gran_core:
2369 __kmp_str_buf_print(buffer,
"%s",
"granularity=core,");
2371 case affinity_gran_package:
2372 __kmp_str_buf_print(buffer,
"%s",
"granularity=package,");
2374 case affinity_gran_node:
2375 __kmp_str_buf_print(buffer,
"%s",
"granularity=node,");
2377 #if KMP_GROUP_AFFINITY 2378 case affinity_gran_group:
2379 __kmp_str_buf_print(buffer,
"%s",
"granularity=group,");
2384 if (!KMP_AFFINITY_CAPABLE()) {
2385 __kmp_str_buf_print(buffer,
"%s",
"disabled");
2387 switch (__kmp_affinity_type) {
2389 __kmp_str_buf_print(buffer,
"%s",
"none");
2391 case affinity_physical:
2392 __kmp_str_buf_print(buffer,
"%s,%d",
"physical", __kmp_affinity_offset);
2394 case affinity_logical:
2395 __kmp_str_buf_print(buffer,
"%s,%d",
"logical", __kmp_affinity_offset);
2397 case affinity_compact:
2398 __kmp_str_buf_print(buffer,
"%s,%d,%d",
"compact", __kmp_affinity_compact,
2399 __kmp_affinity_offset);
2401 case affinity_scatter:
2402 __kmp_str_buf_print(buffer,
"%s,%d,%d",
"scatter", __kmp_affinity_compact,
2403 __kmp_affinity_offset);
2405 case affinity_explicit:
2406 __kmp_str_buf_print(buffer,
"%s=[%s],%s",
"proclist",
2407 __kmp_affinity_proclist,
"explicit");
2409 case affinity_balanced:
2410 __kmp_str_buf_print(buffer,
"%s,%d,%d",
"balanced",
2411 __kmp_affinity_compact, __kmp_affinity_offset);
2413 case affinity_disabled:
2414 __kmp_str_buf_print(buffer,
"%s",
"disabled");
2416 case affinity_default:
2417 __kmp_str_buf_print(buffer,
"%s",
"default");
2420 __kmp_str_buf_print(buffer,
"%s",
"<unknown>");
2423 __kmp_str_buf_print(buffer,
"'\n");
2426 #ifdef KMP_GOMP_COMPAT 2428 static void __kmp_stg_parse_gomp_cpu_affinity(
char const *name,
2429 char const *value,
void *data) {
2430 const char *next = NULL;
2431 char *temp_proclist;
2432 kmp_setting_t **rivals = (kmp_setting_t **)data;
2435 rc = __kmp_stg_check_rivals(name, value, rivals);
2440 if (TCR_4(__kmp_init_middle)) {
2441 KMP_WARNING(EnvMiddleWarn, name);
2442 __kmp_env_toPrint(name, 0);
2446 __kmp_env_toPrint(name, 1);
2448 if (__kmp_parse_affinity_proc_id_list(name, value, &next, &temp_proclist)) {
2450 if (*next ==
'\0') {
2452 __kmp_affinity_proclist = temp_proclist;
2453 __kmp_affinity_type = affinity_explicit;
2454 __kmp_affinity_gran = affinity_gran_fine;
2456 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2459 KMP_WARNING(AffSyntaxError, name);
2460 if (temp_proclist != NULL) {
2461 KMP_INTERNAL_FREE((
void *)temp_proclist);
2466 __kmp_affinity_type = affinity_none;
2468 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
2497 static int __kmp_parse_subplace_list(
const char *var,
const char **scan) {
2501 int start, count, stride;
2507 if ((**scan <
'0') || (**scan >
'9')) {
2508 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2513 start = __kmp_str_to_int(*scan, *next);
2514 KMP_ASSERT(start >= 0);
2519 if (**scan ==
'}') {
2522 if (**scan ==
',') {
2526 if (**scan !=
':') {
2527 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2534 if ((**scan <
'0') || (**scan >
'9')) {
2535 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2540 count = __kmp_str_to_int(*scan, *next);
2541 KMP_ASSERT(count >= 0);
2546 if (**scan ==
'}') {
2549 if (**scan ==
',') {
2553 if (**scan !=
':') {
2554 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2563 if (**scan ==
'+') {
2567 if (**scan ==
'-') {
2575 if ((**scan <
'0') || (**scan >
'9')) {
2576 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2581 stride = __kmp_str_to_int(*scan, *next);
2582 KMP_ASSERT(stride >= 0);
2588 if (**scan ==
'}') {
2591 if (**scan ==
',') {
2596 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2602 static int __kmp_parse_place(
const char *var,
const char **scan) {
2607 if (**scan ==
'{') {
2609 if (!__kmp_parse_subplace_list(var, scan)) {
2612 if (**scan !=
'}') {
2613 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2617 }
else if (**scan ==
'!') {
2619 return __kmp_parse_place(var, scan);
2620 }
else if ((**scan >=
'0') && (**scan <=
'9')) {
2623 int proc = __kmp_str_to_int(*scan, *next);
2624 KMP_ASSERT(proc >= 0);
2627 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2633 static int __kmp_parse_place_list(
const char *var,
const char *env,
2634 char **place_list) {
2635 const char *scan = env;
2636 const char *next = scan;
2639 int start, count, stride;
2641 if (!__kmp_parse_place(var, &scan)) {
2647 if (*scan ==
'\0') {
2655 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2662 if ((*scan <
'0') || (*scan >
'9')) {
2663 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2668 count = __kmp_str_to_int(scan, *next);
2669 KMP_ASSERT(count >= 0);
2674 if (*scan ==
'\0') {
2682 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2703 if ((*scan <
'0') || (*scan >
'9')) {
2704 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2709 stride = __kmp_str_to_int(scan, *next);
2710 KMP_ASSERT(stride >= 0);
2716 if (*scan ==
'\0') {
2724 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2729 int len = scan - env;
2730 char *retlist = (
char *)__kmp_allocate((len + 1) *
sizeof(char));
2731 KMP_MEMCPY_S(retlist, (len + 1) *
sizeof(
char), env, len *
sizeof(
char));
2732 retlist[len] =
'\0';
2733 *place_list = retlist;
2738 static void __kmp_stg_parse_places(
char const *name,
char const *value,
2741 const char *scan = value;
2742 const char *next = scan;
2743 const char *kind =
"\"threads\"";
2744 kmp_setting_t **rivals = (kmp_setting_t **)data;
2747 rc = __kmp_stg_check_rivals(name, value, rivals);
2754 if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_default) {
2755 __kmp_nested_proc_bind.bind_types[0] = proc_bind_true;
2760 if (__kmp_match_str(
"threads", scan, &next)) {
2762 __kmp_affinity_type = affinity_compact;
2763 __kmp_affinity_gran = affinity_gran_thread;
2764 __kmp_affinity_dups = FALSE;
2765 kind =
"\"threads\"";
2766 }
else if (__kmp_match_str(
"cores", scan, &next)) {
2768 __kmp_affinity_type = affinity_compact;
2769 __kmp_affinity_gran = affinity_gran_core;
2770 __kmp_affinity_dups = FALSE;
2773 }
else if (__kmp_match_str(
"tiles", scan, &next)) {
2775 __kmp_affinity_type = affinity_compact;
2776 __kmp_affinity_gran = affinity_gran_tile;
2777 __kmp_affinity_dups = FALSE;
2780 }
else if (__kmp_match_str(
"sockets", scan, &next)) {
2782 __kmp_affinity_type = affinity_compact;
2783 __kmp_affinity_gran = affinity_gran_package;
2784 __kmp_affinity_dups = FALSE;
2785 kind =
"\"sockets\"";
2787 if (__kmp_affinity_proclist != NULL) {
2788 KMP_INTERNAL_FREE((
void *)__kmp_affinity_proclist);
2789 __kmp_affinity_proclist = NULL;
2791 if (__kmp_parse_place_list(name, value, &__kmp_affinity_proclist)) {
2792 __kmp_affinity_type = affinity_explicit;
2793 __kmp_affinity_gran = affinity_gran_fine;
2794 __kmp_affinity_dups = FALSE;
2795 if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_default) {
2796 __kmp_nested_proc_bind.bind_types[0] = proc_bind_true;
2802 if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_default) {
2803 __kmp_nested_proc_bind.bind_types[0] = proc_bind_true;
2807 if (*scan ==
'\0') {
2813 KMP_WARNING(SyntaxErrorUsing, name, kind);
2821 count = __kmp_str_to_int(scan, *next);
2822 KMP_ASSERT(count >= 0);
2827 KMP_WARNING(SyntaxErrorUsing, name, kind);
2833 if (*scan !=
'\0') {
2834 KMP_WARNING(ParseExtraCharsWarn, name, scan);
2836 __kmp_affinity_num_places = count;
2839 static void __kmp_stg_print_places(kmp_str_buf_t *buffer,
char const *name,
2841 if (__kmp_env_format) {
2842 KMP_STR_BUF_PRINT_NAME;
2844 __kmp_str_buf_print(buffer,
" %s", name);
2846 if ((__kmp_nested_proc_bind.used == 0) ||
2847 (__kmp_nested_proc_bind.bind_types == NULL) ||
2848 (__kmp_nested_proc_bind.bind_types[0] == proc_bind_false)) {
2849 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
2850 }
else if (__kmp_affinity_type == affinity_explicit) {
2851 if (__kmp_affinity_proclist != NULL) {
2852 __kmp_str_buf_print(buffer,
"='%s'\n", __kmp_affinity_proclist);
2854 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
2856 }
else if (__kmp_affinity_type == affinity_compact) {
2858 if (__kmp_affinity_num_masks > 0) {
2859 num = __kmp_affinity_num_masks;
2860 }
else if (__kmp_affinity_num_places > 0) {
2861 num = __kmp_affinity_num_places;
2865 if (__kmp_affinity_gran == affinity_gran_thread) {
2867 __kmp_str_buf_print(buffer,
"='threads(%d)'\n", num);
2869 __kmp_str_buf_print(buffer,
"='threads'\n");
2871 }
else if (__kmp_affinity_gran == affinity_gran_core) {
2873 __kmp_str_buf_print(buffer,
"='cores(%d)' \n", num);
2875 __kmp_str_buf_print(buffer,
"='cores'\n");
2878 }
else if (__kmp_affinity_gran == affinity_gran_tile) {
2880 __kmp_str_buf_print(buffer,
"='tiles(%d)' \n", num);
2882 __kmp_str_buf_print(buffer,
"='tiles'\n");
2885 }
else if (__kmp_affinity_gran == affinity_gran_package) {
2887 __kmp_str_buf_print(buffer,
"='sockets(%d)'\n", num);
2889 __kmp_str_buf_print(buffer,
"='sockets'\n");
2892 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
2895 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
2901 #if (!OMP_40_ENABLED) 2903 static void __kmp_stg_parse_proc_bind(
char const *name,
char const *value,
2906 kmp_setting_t **rivals = (kmp_setting_t **)data;
2909 rc = __kmp_stg_check_rivals(name, value, rivals);
2915 __kmp_stg_parse_bool(name, value, &enabled);
2919 __kmp_affinity_type = affinity_scatter;
2920 #if KMP_MIC_SUPPORTED 2921 if (__kmp_mic_type != non_mic)
2922 __kmp_affinity_gran = affinity_gran_fine;
2925 __kmp_affinity_gran = affinity_gran_core;
2927 __kmp_affinity_type = affinity_none;
2933 static void __kmp_stg_parse_topology_method(
char const *name,
char const *value,
2935 if (__kmp_str_match(
"all", 1, value)) {
2936 __kmp_affinity_top_method = affinity_top_method_all;
2939 else if (__kmp_str_match(
"hwloc", 1, value)) {
2940 __kmp_affinity_top_method = affinity_top_method_hwloc;
2943 #if KMP_ARCH_X86 || KMP_ARCH_X86_64 2944 else if (__kmp_str_match(
"x2apic id", 9, value) ||
2945 __kmp_str_match(
"x2apic_id", 9, value) ||
2946 __kmp_str_match(
"x2apic-id", 9, value) ||
2947 __kmp_str_match(
"x2apicid", 8, value) ||
2948 __kmp_str_match(
"cpuid leaf 11", 13, value) ||
2949 __kmp_str_match(
"cpuid_leaf_11", 13, value) ||
2950 __kmp_str_match(
"cpuid-leaf-11", 13, value) ||
2951 __kmp_str_match(
"cpuid leaf11", 12, value) ||
2952 __kmp_str_match(
"cpuid_leaf11", 12, value) ||
2953 __kmp_str_match(
"cpuid-leaf11", 12, value) ||
2954 __kmp_str_match(
"cpuidleaf 11", 12, value) ||
2955 __kmp_str_match(
"cpuidleaf_11", 12, value) ||
2956 __kmp_str_match(
"cpuidleaf-11", 12, value) ||
2957 __kmp_str_match(
"cpuidleaf11", 11, value) ||
2958 __kmp_str_match(
"cpuid 11", 8, value) ||
2959 __kmp_str_match(
"cpuid_11", 8, value) ||
2960 __kmp_str_match(
"cpuid-11", 8, value) ||
2961 __kmp_str_match(
"cpuid11", 7, value) ||
2962 __kmp_str_match(
"leaf 11", 7, value) ||
2963 __kmp_str_match(
"leaf_11", 7, value) ||
2964 __kmp_str_match(
"leaf-11", 7, value) ||
2965 __kmp_str_match(
"leaf11", 6, value)) {
2966 __kmp_affinity_top_method = affinity_top_method_x2apicid;
2967 }
else if (__kmp_str_match(
"apic id", 7, value) ||
2968 __kmp_str_match(
"apic_id", 7, value) ||
2969 __kmp_str_match(
"apic-id", 7, value) ||
2970 __kmp_str_match(
"apicid", 6, value) ||
2971 __kmp_str_match(
"cpuid leaf 4", 12, value) ||
2972 __kmp_str_match(
"cpuid_leaf_4", 12, value) ||
2973 __kmp_str_match(
"cpuid-leaf-4", 12, value) ||
2974 __kmp_str_match(
"cpuid leaf4", 11, value) ||
2975 __kmp_str_match(
"cpuid_leaf4", 11, value) ||
2976 __kmp_str_match(
"cpuid-leaf4", 11, value) ||
2977 __kmp_str_match(
"cpuidleaf 4", 11, value) ||
2978 __kmp_str_match(
"cpuidleaf_4", 11, value) ||
2979 __kmp_str_match(
"cpuidleaf-4", 11, value) ||
2980 __kmp_str_match(
"cpuidleaf4", 10, value) ||
2981 __kmp_str_match(
"cpuid 4", 7, value) ||
2982 __kmp_str_match(
"cpuid_4", 7, value) ||
2983 __kmp_str_match(
"cpuid-4", 7, value) ||
2984 __kmp_str_match(
"cpuid4", 6, value) ||
2985 __kmp_str_match(
"leaf 4", 6, value) ||
2986 __kmp_str_match(
"leaf_4", 6, value) ||
2987 __kmp_str_match(
"leaf-4", 6, value) ||
2988 __kmp_str_match(
"leaf4", 5, value)) {
2989 __kmp_affinity_top_method = affinity_top_method_apicid;
2992 else if (__kmp_str_match(
"/proc/cpuinfo", 2, value) ||
2993 __kmp_str_match(
"cpuinfo", 5, value)) {
2994 __kmp_affinity_top_method = affinity_top_method_cpuinfo;
2996 #if KMP_GROUP_AFFINITY 2997 else if (__kmp_str_match(
"group", 1, value)) {
2998 __kmp_affinity_top_method = affinity_top_method_group;
3001 else if (__kmp_str_match(
"flat", 1, value)) {
3002 __kmp_affinity_top_method = affinity_top_method_flat;
3004 KMP_WARNING(StgInvalidValue, name, value);
3008 static void __kmp_stg_print_topology_method(kmp_str_buf_t *buffer,
3009 char const *name,
void *data) {
3010 char const *value = NULL;
3012 switch (__kmp_affinity_top_method) {
3013 case affinity_top_method_default:
3017 case affinity_top_method_all:
3021 #if KMP_ARCH_X86 || KMP_ARCH_X86_64 3022 case affinity_top_method_x2apicid:
3023 value =
"x2APIC id";
3026 case affinity_top_method_apicid:
3032 case affinity_top_method_hwloc:
3037 case affinity_top_method_cpuinfo:
3041 #if KMP_GROUP_AFFINITY 3042 case affinity_top_method_group:
3047 case affinity_top_method_flat:
3052 if (value != NULL) {
3053 __kmp_stg_print_str(buffer, name, value);
3063 static void __kmp_stg_parse_proc_bind(
char const *name,
char const *value,
3065 kmp_setting_t **rivals = (kmp_setting_t **)data;
3068 rc = __kmp_stg_check_rivals(name, value, rivals);
3074 KMP_DEBUG_ASSERT((__kmp_nested_proc_bind.bind_types != NULL) &&
3075 (__kmp_nested_proc_bind.used > 0));
3077 const char *buf = value;
3081 if ((*buf >=
'0') && (*buf <=
'9')) {
3084 num = __kmp_str_to_int(buf, *next);
3085 KMP_ASSERT(num >= 0);
3093 if (__kmp_match_str(
"disabled", buf, &next)) {
3096 #if KMP_AFFINITY_SUPPORTED 3097 __kmp_affinity_type = affinity_disabled;
3099 __kmp_nested_proc_bind.used = 1;
3100 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
3101 }
else if ((num == (
int)proc_bind_false) ||
3102 __kmp_match_str(
"false", buf, &next)) {
3105 #if KMP_AFFINITY_SUPPORTED 3106 __kmp_affinity_type = affinity_none;
3108 __kmp_nested_proc_bind.used = 1;
3109 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
3110 }
else if ((num == (
int)proc_bind_true) ||
3111 __kmp_match_str(
"true", buf, &next)) {
3114 __kmp_nested_proc_bind.used = 1;
3115 __kmp_nested_proc_bind.bind_types[0] = proc_bind_true;
3120 for (scan = buf; *scan !=
'\0'; scan++) {
3127 if (__kmp_nested_proc_bind.size < nelem) {
3128 __kmp_nested_proc_bind.bind_types =
3129 (kmp_proc_bind_t *)KMP_INTERNAL_REALLOC(
3130 __kmp_nested_proc_bind.bind_types,
3131 sizeof(kmp_proc_bind_t) * nelem);
3132 if (__kmp_nested_proc_bind.bind_types == NULL) {
3133 KMP_FATAL(MemoryAllocFailed);
3135 __kmp_nested_proc_bind.size = nelem;
3137 __kmp_nested_proc_bind.used = nelem;
3142 enum kmp_proc_bind_t bind;
3144 if ((num == (
int)proc_bind_master) ||
3145 __kmp_match_str(
"master", buf, &next)) {
3148 bind = proc_bind_master;
3149 }
else if ((num == (
int)proc_bind_close) ||
3150 __kmp_match_str(
"close", buf, &next)) {
3153 bind = proc_bind_close;
3154 }
else if ((num == (
int)proc_bind_spread) ||
3155 __kmp_match_str(
"spread", buf, &next)) {
3158 bind = proc_bind_spread;
3160 KMP_WARNING(StgInvalidValue, name, value);
3161 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
3162 __kmp_nested_proc_bind.used = 1;
3166 __kmp_nested_proc_bind.bind_types[i++] = bind;
3170 KMP_DEBUG_ASSERT(*buf ==
',');
3175 if ((*buf >=
'0') && (*buf <=
'9')) {
3178 num = __kmp_str_to_int(buf, *next);
3179 KMP_ASSERT(num >= 0);
3189 KMP_WARNING(ParseExtraCharsWarn, name, buf);
3193 static void __kmp_stg_print_proc_bind(kmp_str_buf_t *buffer,
char const *name,
3195 int nelem = __kmp_nested_proc_bind.used;
3196 if (__kmp_env_format) {
3197 KMP_STR_BUF_PRINT_NAME;
3199 __kmp_str_buf_print(buffer,
" %s", name);
3202 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
3205 __kmp_str_buf_print(buffer,
"='", name);
3206 for (i = 0; i < nelem; i++) {
3207 switch (__kmp_nested_proc_bind.bind_types[i]) {
3208 case proc_bind_false:
3209 __kmp_str_buf_print(buffer,
"false");
3212 case proc_bind_true:
3213 __kmp_str_buf_print(buffer,
"true");
3216 case proc_bind_master:
3217 __kmp_str_buf_print(buffer,
"master");
3220 case proc_bind_close:
3221 __kmp_str_buf_print(buffer,
"close");
3224 case proc_bind_spread:
3225 __kmp_str_buf_print(buffer,
"spread");
3228 case proc_bind_intel:
3229 __kmp_str_buf_print(buffer,
"intel");
3232 case proc_bind_default:
3233 __kmp_str_buf_print(buffer,
"default");
3236 if (i < nelem - 1) {
3237 __kmp_str_buf_print(buffer,
",");
3240 __kmp_str_buf_print(buffer,
"'\n");
3249 static void __kmp_stg_parse_omp_dynamic(
char const *name,
char const *value,
3251 __kmp_stg_parse_bool(name, value, &(__kmp_global.g.g_dynamic));
3254 static void __kmp_stg_print_omp_dynamic(kmp_str_buf_t *buffer,
char const *name,
3256 __kmp_stg_print_bool(buffer, name, __kmp_global.g.g_dynamic);
3259 static void __kmp_stg_parse_kmp_dynamic_mode(
char const *name,
3260 char const *value,
void *data) {
3261 if (TCR_4(__kmp_init_parallel)) {
3262 KMP_WARNING(EnvParallelWarn, name);
3263 __kmp_env_toPrint(name, 0);
3266 #ifdef USE_LOAD_BALANCE 3267 else if (__kmp_str_match(
"load balance", 2, value) ||
3268 __kmp_str_match(
"load_balance", 2, value) ||
3269 __kmp_str_match(
"load-balance", 2, value) ||
3270 __kmp_str_match(
"loadbalance", 2, value) ||
3271 __kmp_str_match(
"balance", 1, value)) {
3272 __kmp_global.g.g_dynamic_mode = dynamic_load_balance;
3275 else if (__kmp_str_match(
"thread limit", 1, value) ||
3276 __kmp_str_match(
"thread_limit", 1, value) ||
3277 __kmp_str_match(
"thread-limit", 1, value) ||
3278 __kmp_str_match(
"threadlimit", 1, value) ||
3279 __kmp_str_match(
"limit", 2, value)) {
3280 __kmp_global.g.g_dynamic_mode = dynamic_thread_limit;
3281 }
else if (__kmp_str_match(
"random", 1, value)) {
3282 __kmp_global.g.g_dynamic_mode = dynamic_random;
3284 KMP_WARNING(StgInvalidValue, name, value);
3288 static void __kmp_stg_print_kmp_dynamic_mode(kmp_str_buf_t *buffer,
3289 char const *name,
void *data) {
3291 if (__kmp_global.g.g_dynamic_mode == dynamic_default) {
3292 __kmp_str_buf_print(buffer,
" %s: %s \n", name, KMP_I18N_STR(NotDefined));
3294 #ifdef USE_LOAD_BALANCE 3295 else if (__kmp_global.g.g_dynamic_mode == dynamic_load_balance) {
3296 __kmp_stg_print_str(buffer, name,
"load balance");
3299 else if (__kmp_global.g.g_dynamic_mode == dynamic_thread_limit) {
3300 __kmp_stg_print_str(buffer, name,
"thread limit");
3301 }
else if (__kmp_global.g.g_dynamic_mode == dynamic_random) {
3302 __kmp_stg_print_str(buffer, name,
"random");
3309 #ifdef USE_LOAD_BALANCE 3314 static void __kmp_stg_parse_ld_balance_interval(
char const *name,
3315 char const *value,
void *data) {
3316 double interval = __kmp_convert_to_double(value);
3317 if (interval >= 0) {
3318 __kmp_load_balance_interval = interval;
3320 KMP_WARNING(StgInvalidValue, name, value);
3324 static void __kmp_stg_print_ld_balance_interval(kmp_str_buf_t *buffer,
3325 char const *name,
void *data) {
3327 __kmp_str_buf_print(buffer,
" %s=%8.6f\n", name,
3328 __kmp_load_balance_interval);
3337 static void __kmp_stg_parse_init_at_fork(
char const *name,
char const *value,
3339 __kmp_stg_parse_bool(name, value, &__kmp_need_register_atfork);
3340 if (__kmp_need_register_atfork) {
3341 __kmp_need_register_atfork_specified = TRUE;
3345 static void __kmp_stg_print_init_at_fork(kmp_str_buf_t *buffer,
3346 char const *name,
void *data) {
3347 __kmp_stg_print_bool(buffer, name, __kmp_need_register_atfork_specified);
3353 static void __kmp_stg_parse_schedule(
char const *name,
char const *value,
3356 if (value != NULL) {
3357 size_t length = KMP_STRLEN(value);
3358 if (length > INT_MAX) {
3359 KMP_WARNING(LongValue, name);
3361 const char *semicolon;
3362 if (value[length - 1] ==
'"' || value[length - 1] ==
'\'')
3363 KMP_WARNING(UnbalancedQuotes, name);
3367 semicolon = strchr(value,
';');
3368 if (*value && semicolon != value) {
3369 const char *comma = strchr(value,
',');
3376 if (!__kmp_strcasecmp_with_sentinel(
"static", value, sentinel)) {
3377 if (!__kmp_strcasecmp_with_sentinel(
"greedy", comma,
';')) {
3378 __kmp_static = kmp_sch_static_greedy;
3380 }
else if (!__kmp_strcasecmp_with_sentinel(
"balanced", comma,
3382 __kmp_static = kmp_sch_static_balanced;
3385 }
else if (!__kmp_strcasecmp_with_sentinel(
"guided", value,
3387 if (!__kmp_strcasecmp_with_sentinel(
"iterative", comma,
';')) {
3388 __kmp_guided = kmp_sch_guided_iterative_chunked;
3390 }
else if (!__kmp_strcasecmp_with_sentinel(
"analytical", comma,
3393 __kmp_guided = kmp_sch_guided_analytical_chunked;
3397 KMP_WARNING(InvalidClause, name, value);
3399 KMP_WARNING(EmptyClause, name);
3400 }
while ((value = semicolon ? semicolon + 1 : NULL));
3406 static void __kmp_stg_print_schedule(kmp_str_buf_t *buffer,
char const *name,
3408 if (__kmp_env_format) {
3409 KMP_STR_BUF_PRINT_NAME_EX(name);
3411 __kmp_str_buf_print(buffer,
" %s='", name);
3413 if (__kmp_static == kmp_sch_static_greedy) {
3414 __kmp_str_buf_print(buffer,
"%s",
"static,greedy");
3415 }
else if (__kmp_static == kmp_sch_static_balanced) {
3416 __kmp_str_buf_print(buffer,
"%s",
"static,balanced");
3418 if (__kmp_guided == kmp_sch_guided_iterative_chunked) {
3419 __kmp_str_buf_print(buffer,
";%s'\n",
"guided,iterative");
3420 }
else if (__kmp_guided == kmp_sch_guided_analytical_chunked) {
3421 __kmp_str_buf_print(buffer,
";%s'\n",
"guided,analytical");
3428 static void __kmp_stg_parse_omp_schedule(
char const *name,
char const *value,
3432 length = KMP_STRLEN(value);
3434 const char *comma = strchr(value,
',');
3435 if (value[length - 1] ==
'"' || value[length - 1] ==
'\'')
3436 KMP_WARNING(UnbalancedQuotes, name);
3438 if (!__kmp_strcasecmp_with_sentinel(
"dynamic", value,
','))
3439 __kmp_sched = kmp_sch_dynamic_chunked;
3440 else if (!__kmp_strcasecmp_with_sentinel(
"guided", value,
3445 else if (!__kmp_strcasecmp_with_sentinel(
"auto", value,
',')) {
3448 __kmp_msg(kmp_ms_warning, KMP_MSG(IgnoreChunk, name, comma),
3452 }
else if (!__kmp_strcasecmp_with_sentinel(
"trapezoidal", value,
3454 __kmp_sched = kmp_sch_trapezoidal;
3455 else if (!__kmp_strcasecmp_with_sentinel(
"static", value,
3458 #if KMP_STATIC_STEAL_ENABLED 3459 else if (!__kmp_strcasecmp_with_sentinel(
"static_steal", value,
','))
3460 __kmp_sched = kmp_sch_static_steal;
3463 KMP_WARNING(StgInvalidValue, name, value);
3466 if (value && comma) {
3468 __kmp_sched = kmp_sch_static_chunked;
3470 __kmp_chunk = __kmp_str_to_int(comma, 0);
3471 if (__kmp_chunk < 1) {
3472 __kmp_chunk = KMP_DEFAULT_CHUNK;
3473 __kmp_msg(kmp_ms_warning, KMP_MSG(InvalidChunk, name, comma),
3475 KMP_INFORM(Using_int_Value, name, __kmp_chunk);
3484 }
else if (__kmp_chunk > KMP_MAX_CHUNK) {
3485 __kmp_chunk = KMP_MAX_CHUNK;
3486 __kmp_msg(kmp_ms_warning, KMP_MSG(LargeChunk, name, comma),
3488 KMP_INFORM(Using_int_Value, name, __kmp_chunk);
3492 KMP_WARNING(EmptyString, name);
3494 K_DIAG(1, (
"__kmp_static == %d\n", __kmp_static))
3495 K_DIAG(1, (
"__kmp_guided == %d\n", __kmp_guided))
3496 K_DIAG(1, (
"__kmp_sched == %d\n", __kmp_sched))
3497 K_DIAG(1, (
"__kmp_chunk == %d\n", __kmp_chunk))
3500 static void __kmp_stg_print_omp_schedule(kmp_str_buf_t *buffer,
3501 char const *name,
void *data) {
3502 if (__kmp_env_format) {
3503 KMP_STR_BUF_PRINT_NAME_EX(name);
3505 __kmp_str_buf_print(buffer,
" %s='", name);
3508 switch (__kmp_sched) {
3509 case kmp_sch_dynamic_chunked:
3510 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"dynamic", __kmp_chunk);
3512 case kmp_sch_guided_iterative_chunked:
3513 case kmp_sch_guided_analytical_chunked:
3514 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"guided", __kmp_chunk);
3516 case kmp_sch_trapezoidal:
3517 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"trapezoidal", __kmp_chunk);
3520 case kmp_sch_static_chunked:
3521 case kmp_sch_static_balanced:
3522 case kmp_sch_static_greedy:
3523 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"static", __kmp_chunk);
3525 case kmp_sch_static_steal:
3526 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"static_steal", __kmp_chunk);
3529 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"auto", __kmp_chunk);
3533 switch (__kmp_sched) {
3534 case kmp_sch_dynamic_chunked:
3535 __kmp_str_buf_print(buffer,
"%s'\n",
"dynamic");
3537 case kmp_sch_guided_iterative_chunked:
3538 case kmp_sch_guided_analytical_chunked:
3539 __kmp_str_buf_print(buffer,
"%s'\n",
"guided");
3541 case kmp_sch_trapezoidal:
3542 __kmp_str_buf_print(buffer,
"%s'\n",
"trapezoidal");
3545 case kmp_sch_static_chunked:
3546 case kmp_sch_static_balanced:
3547 case kmp_sch_static_greedy:
3548 __kmp_str_buf_print(buffer,
"%s'\n",
"static");
3550 case kmp_sch_static_steal:
3551 __kmp_str_buf_print(buffer,
"%s'\n",
"static_steal");
3554 __kmp_str_buf_print(buffer,
"%s'\n",
"auto");
3563 static void __kmp_stg_parse_atomic_mode(
char const *name,
char const *value,
3569 #ifdef KMP_GOMP_COMPAT 3572 __kmp_stg_parse_int(name, value, 0, max, &mode);
3577 __kmp_atomic_mode = mode;
3581 static void __kmp_stg_print_atomic_mode(kmp_str_buf_t *buffer,
char const *name,
3583 __kmp_stg_print_int(buffer, name, __kmp_atomic_mode);
3589 static void __kmp_stg_parse_consistency_check(
char const *name,
3590 char const *value,
void *data) {
3591 if (!__kmp_strcasecmp_with_sentinel(
"all", value, 0)) {
3597 __kmp_env_consistency_check = TRUE;
3598 }
else if (!__kmp_strcasecmp_with_sentinel(
"none", value, 0)) {
3599 __kmp_env_consistency_check = FALSE;
3601 KMP_WARNING(StgInvalidValue, name, value);
3605 static void __kmp_stg_print_consistency_check(kmp_str_buf_t *buffer,
3606 char const *name,
void *data) {
3608 const char *value = NULL;
3610 if (__kmp_env_consistency_check) {
3616 if (value != NULL) {
3617 __kmp_stg_print_str(buffer, name, value);
3628 static void __kmp_stg_parse_itt_prepare_delay(
char const *name,
3629 char const *value,
void *data) {
3633 __kmp_stg_parse_int(name, value, 0, INT_MAX, &delay);
3634 __kmp_itt_prepare_delay = delay;
3637 static void __kmp_stg_print_itt_prepare_delay(kmp_str_buf_t *buffer,
3638 char const *name,
void *data) {
3639 __kmp_stg_print_uint64(buffer, name, __kmp_itt_prepare_delay);
3643 #endif // USE_ITT_NOTIFY 3649 static void __kmp_stg_parse_malloc_pool_incr(
char const *name,
3650 char const *value,
void *data) {
3651 __kmp_stg_parse_size(name, value, KMP_MIN_MALLOC_POOL_INCR,
3652 KMP_MAX_MALLOC_POOL_INCR, NULL, &__kmp_malloc_pool_incr,
3656 static void __kmp_stg_print_malloc_pool_incr(kmp_str_buf_t *buffer,
3657 char const *name,
void *data) {
3658 __kmp_stg_print_size(buffer, name, __kmp_malloc_pool_incr);
3667 static void __kmp_stg_parse_par_range_env(
char const *name,
char const *value,
3669 __kmp_stg_parse_par_range(name, value, &__kmp_par_range,
3670 __kmp_par_range_routine, __kmp_par_range_filename,
3671 &__kmp_par_range_lb, &__kmp_par_range_ub);
3674 static void __kmp_stg_print_par_range_env(kmp_str_buf_t *buffer,
3675 char const *name,
void *data) {
3676 if (__kmp_par_range != 0) {
3677 __kmp_stg_print_str(buffer, name, par_range_to_print);
3684 static void __kmp_stg_parse_yield_cycle(
char const *name,
char const *value,
3686 int flag = __kmp_yield_cycle;
3687 __kmp_stg_parse_bool(name, value, &flag);
3688 __kmp_yield_cycle = flag;
3691 static void __kmp_stg_print_yield_cycle(kmp_str_buf_t *buffer,
char const *name,
3693 __kmp_stg_print_bool(buffer, name, __kmp_yield_cycle);
3696 static void __kmp_stg_parse_yield_on(
char const *name,
char const *value,
3698 __kmp_stg_parse_int(name, value, 2, INT_MAX, &__kmp_yield_on_count);
3701 static void __kmp_stg_print_yield_on(kmp_str_buf_t *buffer,
char const *name,
3703 __kmp_stg_print_int(buffer, name, __kmp_yield_on_count);
3706 static void __kmp_stg_parse_yield_off(
char const *name,
char const *value,
3708 __kmp_stg_parse_int(name, value, 2, INT_MAX, &__kmp_yield_off_count);
3711 static void __kmp_stg_print_yield_off(kmp_str_buf_t *buffer,
char const *name,
3713 __kmp_stg_print_int(buffer, name, __kmp_yield_off_count);
3721 static void __kmp_stg_parse_init_wait(
char const *name,
char const *value,
3724 KMP_ASSERT((__kmp_init_wait & 1) == 0);
3725 wait = __kmp_init_wait / 2;
3726 __kmp_stg_parse_int(name, value, KMP_MIN_INIT_WAIT, KMP_MAX_INIT_WAIT, &wait);
3727 __kmp_init_wait = wait * 2;
3728 KMP_ASSERT((__kmp_init_wait & 1) == 0);
3729 __kmp_yield_init = __kmp_init_wait;
3732 static void __kmp_stg_print_init_wait(kmp_str_buf_t *buffer,
char const *name,
3734 __kmp_stg_print_int(buffer, name, __kmp_init_wait);
3737 static void __kmp_stg_parse_next_wait(
char const *name,
char const *value,
3740 KMP_ASSERT((__kmp_next_wait & 1) == 0);
3741 wait = __kmp_next_wait / 2;
3742 __kmp_stg_parse_int(name, value, KMP_MIN_NEXT_WAIT, KMP_MAX_NEXT_WAIT, &wait);
3743 __kmp_next_wait = wait * 2;
3744 KMP_ASSERT((__kmp_next_wait & 1) == 0);
3745 __kmp_yield_next = __kmp_next_wait;
3748 static void __kmp_stg_print_next_wait(kmp_str_buf_t *buffer,
char const *name,
3750 __kmp_stg_print_int(buffer, name, __kmp_next_wait);
3756 static void __kmp_stg_parse_gtid_mode(
char const *name,
char const *value,
3766 #ifdef KMP_TDATA_GTID 3769 __kmp_stg_parse_int(name, value, 0, max, &mode);
3773 __kmp_adjust_gtid_mode = TRUE;
3775 __kmp_gtid_mode = mode;
3776 __kmp_adjust_gtid_mode = FALSE;
3780 static void __kmp_stg_print_gtid_mode(kmp_str_buf_t *buffer,
char const *name,
3782 if (__kmp_adjust_gtid_mode) {
3783 __kmp_stg_print_int(buffer, name, 0);
3785 __kmp_stg_print_int(buffer, name, __kmp_gtid_mode);
3792 static void __kmp_stg_parse_lock_block(
char const *name,
char const *value,
3794 __kmp_stg_parse_int(name, value, 0, KMP_INT_MAX, &__kmp_num_locks_in_block);
3797 static void __kmp_stg_print_lock_block(kmp_str_buf_t *buffer,
char const *name,
3799 __kmp_stg_print_int(buffer, name, __kmp_num_locks_in_block);
3805 #if KMP_USE_DYNAMIC_LOCK 3806 #define KMP_STORE_LOCK_SEQ(a) (__kmp_user_lock_seq = lockseq_##a) 3808 #define KMP_STORE_LOCK_SEQ(a) 3811 static void __kmp_stg_parse_lock_kind(
char const *name,
char const *value,
3813 if (__kmp_init_user_locks) {
3814 KMP_WARNING(EnvLockWarn, name);
3818 if (__kmp_str_match(
"tas", 2, value) ||
3819 __kmp_str_match(
"test and set", 2, value) ||
3820 __kmp_str_match(
"test_and_set", 2, value) ||
3821 __kmp_str_match(
"test-and-set", 2, value) ||
3822 __kmp_str_match(
"test andset", 2, value) ||
3823 __kmp_str_match(
"test_andset", 2, value) ||
3824 __kmp_str_match(
"test-andset", 2, value) ||
3825 __kmp_str_match(
"testand set", 2, value) ||
3826 __kmp_str_match(
"testand_set", 2, value) ||
3827 __kmp_str_match(
"testand-set", 2, value) ||
3828 __kmp_str_match(
"testandset", 2, value)) {
3829 __kmp_user_lock_kind = lk_tas;
3830 KMP_STORE_LOCK_SEQ(tas);
3833 else if (__kmp_str_match(
"futex", 1, value)) {
3834 if (__kmp_futex_determine_capable()) {
3835 __kmp_user_lock_kind = lk_futex;
3836 KMP_STORE_LOCK_SEQ(futex);
3838 KMP_WARNING(FutexNotSupported, name, value);
3842 else if (__kmp_str_match(
"ticket", 2, value)) {
3843 __kmp_user_lock_kind = lk_ticket;
3844 KMP_STORE_LOCK_SEQ(ticket);
3845 }
else if (__kmp_str_match(
"queuing", 1, value) ||
3846 __kmp_str_match(
"queue", 1, value)) {
3847 __kmp_user_lock_kind = lk_queuing;
3848 KMP_STORE_LOCK_SEQ(queuing);
3849 }
else if (__kmp_str_match(
"drdpa ticket", 1, value) ||
3850 __kmp_str_match(
"drdpa_ticket", 1, value) ||
3851 __kmp_str_match(
"drdpa-ticket", 1, value) ||
3852 __kmp_str_match(
"drdpaticket", 1, value) ||
3853 __kmp_str_match(
"drdpa", 1, value)) {
3854 __kmp_user_lock_kind = lk_drdpa;
3855 KMP_STORE_LOCK_SEQ(drdpa);
3857 #if KMP_USE_ADAPTIVE_LOCKS 3858 else if (__kmp_str_match(
"adaptive", 1, value)) {
3859 if (__kmp_cpuinfo.rtm) {
3860 __kmp_user_lock_kind = lk_adaptive;
3861 KMP_STORE_LOCK_SEQ(adaptive);
3863 KMP_WARNING(AdaptiveNotSupported, name, value);
3864 __kmp_user_lock_kind = lk_queuing;
3865 KMP_STORE_LOCK_SEQ(queuing);
3868 #endif // KMP_USE_ADAPTIVE_LOCKS 3869 #if KMP_USE_DYNAMIC_LOCK && KMP_USE_TSX 3870 else if (__kmp_str_match(
"rtm", 1, value)) {
3871 if (__kmp_cpuinfo.rtm) {
3872 __kmp_user_lock_kind = lk_rtm;
3873 KMP_STORE_LOCK_SEQ(rtm);
3875 KMP_WARNING(AdaptiveNotSupported, name, value);
3876 __kmp_user_lock_kind = lk_queuing;
3877 KMP_STORE_LOCK_SEQ(queuing);
3879 }
else if (__kmp_str_match(
"hle", 1, value)) {
3880 __kmp_user_lock_kind = lk_hle;
3881 KMP_STORE_LOCK_SEQ(hle);
3885 KMP_WARNING(StgInvalidValue, name, value);
3889 static void __kmp_stg_print_lock_kind(kmp_str_buf_t *buffer,
char const *name,
3891 const char *value = NULL;
3893 switch (__kmp_user_lock_kind) {
3908 #if KMP_USE_DYNAMIC_LOCK && KMP_USE_TSX 3929 #if KMP_USE_ADAPTIVE_LOCKS 3936 if (value != NULL) {
3937 __kmp_stg_print_str(buffer, name, value);
3946 static void __kmp_stg_parse_spin_backoff_params(
const char *name,
3947 const char *value,
void *data) {
3948 const char *next = value;
3951 int prev_comma = FALSE;
3954 kmp_uint32 max_backoff = __kmp_spin_backoff_params.max_backoff;
3955 kmp_uint32 min_tick = __kmp_spin_backoff_params.min_tick;
3959 for (i = 0; i < 3; i++) {
3962 if (*next ==
'\0') {
3967 if (((*next < '0' || *next >
'9') && *next !=
',') || total > 2) {
3968 KMP_WARNING(EnvSyntaxError, name, value);
3974 if (total == 0 || prev_comma) {
3982 if (*next >=
'0' && *next <=
'9') {
3984 const char *buf = next;
3985 char const *msg = NULL;
3990 const char *tmp = next;
3992 if ((*next ==
' ' || *next ==
'\t') && (*tmp >=
'0' && *tmp <=
'9')) {
3993 KMP_WARNING(EnvSpacesNotAllowed, name, value);
3997 num = __kmp_str_to_int(buf, *next);
3999 msg = KMP_I18N_STR(ValueTooSmall);
4001 }
else if (num > KMP_INT_MAX) {
4002 msg = KMP_I18N_STR(ValueTooLarge);
4007 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
4008 KMP_INFORM(Using_int_Value, name, num);
4012 }
else if (total == 2) {
4017 KMP_DEBUG_ASSERT(total > 0);
4019 KMP_WARNING(EnvSyntaxError, name, value);
4022 __kmp_spin_backoff_params.max_backoff = max_backoff;
4023 __kmp_spin_backoff_params.min_tick = min_tick;
4026 static void __kmp_stg_print_spin_backoff_params(kmp_str_buf_t *buffer,
4027 char const *name,
void *data) {
4028 if (__kmp_env_format) {
4029 KMP_STR_BUF_PRINT_NAME_EX(name);
4031 __kmp_str_buf_print(buffer,
" %s='", name);
4033 __kmp_str_buf_print(buffer,
"%d,%d'\n", __kmp_spin_backoff_params.max_backoff,
4034 __kmp_spin_backoff_params.min_tick);
4037 #if KMP_USE_ADAPTIVE_LOCKS 4044 static void __kmp_stg_parse_adaptive_lock_props(
const char *name,
4045 const char *value,
void *data) {
4046 int max_retries = 0;
4047 int max_badness = 0;
4049 const char *next = value;
4052 int prev_comma = FALSE;
4058 for (i = 0; i < 3; i++) {
4061 if (*next ==
'\0') {
4066 if (((*next < '0' || *next >
'9') && *next !=
',') || total > 2) {
4067 KMP_WARNING(EnvSyntaxError, name, value);
4073 if (total == 0 || prev_comma) {
4081 if (*next >=
'0' && *next <=
'9') {
4083 const char *buf = next;
4084 char const *msg = NULL;
4089 const char *tmp = next;
4091 if ((*next ==
' ' || *next ==
'\t') && (*tmp >=
'0' && *tmp <=
'9')) {
4092 KMP_WARNING(EnvSpacesNotAllowed, name, value);
4096 num = __kmp_str_to_int(buf, *next);
4098 msg = KMP_I18N_STR(ValueTooSmall);
4100 }
else if (num > KMP_INT_MAX) {
4101 msg = KMP_I18N_STR(ValueTooLarge);
4106 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
4107 KMP_INFORM(Using_int_Value, name, num);
4111 }
else if (total == 2) {
4116 KMP_DEBUG_ASSERT(total > 0);
4118 KMP_WARNING(EnvSyntaxError, name, value);
4121 __kmp_adaptive_backoff_params.max_soft_retries = max_retries;
4122 __kmp_adaptive_backoff_params.max_badness = max_badness;
4125 static void __kmp_stg_print_adaptive_lock_props(kmp_str_buf_t *buffer,
4126 char const *name,
void *data) {
4127 if (__kmp_env_format) {
4128 KMP_STR_BUF_PRINT_NAME_EX(name);
4130 __kmp_str_buf_print(buffer,
" %s='", name);
4132 __kmp_str_buf_print(buffer,
"%d,%d'\n",
4133 __kmp_adaptive_backoff_params.max_soft_retries,
4134 __kmp_adaptive_backoff_params.max_badness);
4137 #if KMP_DEBUG_ADAPTIVE_LOCKS 4139 static void __kmp_stg_parse_speculative_statsfile(
char const *name,
4142 __kmp_stg_parse_file(name, value,
"", &__kmp_speculative_statsfile);
4145 static void __kmp_stg_print_speculative_statsfile(kmp_str_buf_t *buffer,
4148 if (__kmp_str_match(
"-", 0, __kmp_speculative_statsfile)) {
4149 __kmp_stg_print_str(buffer, name,
"stdout");
4151 __kmp_stg_print_str(buffer, name, __kmp_speculative_statsfile);
4156 #endif // KMP_DEBUG_ADAPTIVE_LOCKS 4158 #endif // KMP_USE_ADAPTIVE_LOCKS 4167 #define MAX_T_LEVEL 5 4168 #define MAX_STR_LEN 512 4169 static void __kmp_stg_parse_hw_subset(
char const *name,
char const *value,
4173 kmp_setting_t **rivals = (kmp_setting_t **)data;
4174 if (strcmp(name,
"KMP_PLACE_THREADS") == 0) {
4175 KMP_INFORM(EnvVarDeprecated, name,
"KMP_HW_SUBSET");
4177 if (__kmp_stg_check_rivals(name, value, rivals)) {
4181 char *components[MAX_T_LEVEL];
4182 char const *digits =
"0123456789";
4183 char input[MAX_STR_LEN];
4184 size_t len = 0, mlen = MAX_STR_LEN;
4187 char *pos = CCAST(
char *, value);
4188 while (*pos && mlen) {
4190 if (len == 0 && *pos ==
':') {
4191 __kmp_hws_abs_flag = 1;
4193 input[len] = toupper(*pos);
4194 if (input[len] ==
'X')
4196 if (input[len] ==
'O' && strchr(digits, *(pos + 1)))
4204 if (len == 0 || mlen == 0)
4207 __kmp_hws_requested = 1;
4210 components[level++] = pos;
4211 while ((pos = strchr(pos,
','))) {
4213 components[level++] = ++pos;
4214 if (level > MAX_T_LEVEL)
4218 for (
int i = 0; i < level; ++i) {
4220 int num = atoi(components[i]);
4221 if ((pos = strchr(components[i],
'@'))) {
4222 offset = atoi(pos + 1);
4225 pos = components[i] + strspn(components[i], digits);
4226 if (pos == components[i])
4231 if (__kmp_hws_socket.num > 0)
4233 __kmp_hws_socket.num = num;
4234 __kmp_hws_socket.offset = offset;
4237 if (__kmp_hws_node.num > 0)
4239 __kmp_hws_node.num = num;
4240 __kmp_hws_node.offset = offset;
4243 if (*(pos + 1) ==
'2') {
4244 if (__kmp_hws_tile.num > 0)
4246 __kmp_hws_tile.num = num;
4247 __kmp_hws_tile.offset = offset;
4248 }
else if (*(pos + 1) ==
'3') {
4249 if (__kmp_hws_socket.num > 0)
4251 __kmp_hws_socket.num = num;
4252 __kmp_hws_socket.offset = offset;
4253 }
else if (*(pos + 1) ==
'1') {
4254 if (__kmp_hws_core.num > 0)
4256 __kmp_hws_core.num = num;
4257 __kmp_hws_core.offset = offset;
4261 if (*(pos + 1) !=
'A') {
4262 if (__kmp_hws_core.num > 0)
4264 __kmp_hws_core.num = num;
4265 __kmp_hws_core.offset = offset;
4267 char *d = pos + strcspn(pos, digits);
4269 if (__kmp_hws_tile.num > 0)
4271 __kmp_hws_tile.num = num;
4272 __kmp_hws_tile.offset = offset;
4273 }
else if (*d ==
'3') {
4274 if (__kmp_hws_socket.num > 0)
4276 __kmp_hws_socket.num = num;
4277 __kmp_hws_socket.offset = offset;
4278 }
else if (*d ==
'1') {
4279 if (__kmp_hws_core.num > 0)
4281 __kmp_hws_core.num = num;
4282 __kmp_hws_core.offset = offset;
4289 if (__kmp_hws_proc.num > 0)
4291 __kmp_hws_proc.num = num;
4292 __kmp_hws_proc.offset = offset;
4300 KMP_WARNING(AffHWSubsetInvalid, name, value);
4301 __kmp_hws_requested = 0;
4305 static void __kmp_stg_print_hw_subset(kmp_str_buf_t *buffer,
char const *name,
4307 if (__kmp_hws_requested) {
4310 __kmp_str_buf_init(&buf);
4311 if (__kmp_env_format)
4312 KMP_STR_BUF_PRINT_NAME_EX(name);
4314 __kmp_str_buf_print(buffer,
" %s='", name);
4315 if (__kmp_hws_socket.num) {
4316 __kmp_str_buf_print(&buf,
"%ds", __kmp_hws_socket.num);
4317 if (__kmp_hws_socket.offset)
4318 __kmp_str_buf_print(&buf,
"@%d", __kmp_hws_socket.offset);
4321 if (__kmp_hws_node.num) {
4322 __kmp_str_buf_print(&buf,
"%s%dn", comma ?
"," :
"", __kmp_hws_node.num);
4323 if (__kmp_hws_node.offset)
4324 __kmp_str_buf_print(&buf,
"@%d", __kmp_hws_node.offset);
4327 if (__kmp_hws_tile.num) {
4328 __kmp_str_buf_print(&buf,
"%s%dL2", comma ?
"," :
"", __kmp_hws_tile.num);
4329 if (__kmp_hws_tile.offset)
4330 __kmp_str_buf_print(&buf,
"@%d", __kmp_hws_tile.offset);
4333 if (__kmp_hws_core.num) {
4334 __kmp_str_buf_print(&buf,
"%s%dc", comma ?
"," :
"", __kmp_hws_core.num);
4335 if (__kmp_hws_core.offset)
4336 __kmp_str_buf_print(&buf,
"@%d", __kmp_hws_core.offset);
4339 if (__kmp_hws_proc.num)
4340 __kmp_str_buf_print(&buf,
"%s%dt", comma ?
"," :
"", __kmp_hws_proc.num);
4341 __kmp_str_buf_print(buffer,
"%s'\n", buf.str);
4342 __kmp_str_buf_free(&buf);
4350 static void __kmp_stg_parse_forkjoin_frames(
char const *name,
char const *value,
4352 __kmp_stg_parse_bool(name, value, &__kmp_forkjoin_frames);
4355 static void __kmp_stg_print_forkjoin_frames(kmp_str_buf_t *buffer,
4356 char const *name,
void *data) {
4357 __kmp_stg_print_bool(buffer, name, __kmp_forkjoin_frames);
4363 static void __kmp_stg_parse_forkjoin_frames_mode(
char const *name,
4366 __kmp_stg_parse_int(name, value, 0, 3, &__kmp_forkjoin_frames_mode);
4369 static void __kmp_stg_print_forkjoin_frames_mode(kmp_str_buf_t *buffer,
4370 char const *name,
void *data) {
4371 __kmp_stg_print_int(buffer, name, __kmp_forkjoin_frames_mode);
4380 static void __kmp_stg_parse_omp_display_env(
char const *name,
char const *value,
4382 if (__kmp_str_match(
"VERBOSE", 1, value)) {
4383 __kmp_display_env_verbose = TRUE;
4385 __kmp_stg_parse_bool(name, value, &__kmp_display_env);
4390 static void __kmp_stg_print_omp_display_env(kmp_str_buf_t *buffer,
4391 char const *name,
void *data) {
4392 if (__kmp_display_env_verbose) {
4393 __kmp_stg_print_str(buffer, name,
"VERBOSE");
4395 __kmp_stg_print_bool(buffer, name, __kmp_display_env);
4399 static void __kmp_stg_parse_omp_cancellation(
char const *name,
4400 char const *value,
void *data) {
4401 if (TCR_4(__kmp_init_parallel)) {
4402 KMP_WARNING(EnvParallelWarn, name);
4405 __kmp_stg_parse_bool(name, value, &__kmp_omp_cancellation);
4408 static void __kmp_stg_print_omp_cancellation(kmp_str_buf_t *buffer,
4409 char const *name,
void *data) {
4410 __kmp_stg_print_bool(buffer, name, __kmp_omp_cancellation);
4415 #if OMP_50_ENABLED && OMPT_SUPPORT 4417 static char *__kmp_tool_libraries = NULL;
4419 static void __kmp_stg_parse_omp_tool_libraries(
char const *name,
4420 char const *value,
void *data) {
4421 __kmp_stg_parse_str(name, value, &__kmp_tool_libraries);
4424 static void __kmp_stg_print_omp_tool_libraries(kmp_str_buf_t *buffer,
4425 char const *name,
void *data) {
4426 if (__kmp_tool_libraries)
4427 __kmp_stg_print_str(buffer, name, __kmp_tool_libraries);
4429 if (__kmp_env_format) {
4430 KMP_STR_BUF_PRINT_NAME;
4432 __kmp_str_buf_print(buffer,
" %s", name);
4434 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
4442 static kmp_setting_t __kmp_stg_table[] = {
4444 {
"KMP_ALL_THREADS", __kmp_stg_parse_device_thread_limit, NULL, NULL, 0, 0},
4445 {
"KMP_BLOCKTIME", __kmp_stg_parse_blocktime, __kmp_stg_print_blocktime,
4447 {
"KMP_DUPLICATE_LIB_OK", __kmp_stg_parse_duplicate_lib_ok,
4448 __kmp_stg_print_duplicate_lib_ok, NULL, 0, 0},
4449 {
"KMP_LIBRARY", __kmp_stg_parse_wait_policy, __kmp_stg_print_wait_policy,
4451 {
"KMP_DEVICE_THREAD_LIMIT", __kmp_stg_parse_device_thread_limit,
4452 __kmp_stg_print_device_thread_limit, NULL, 0, 0},
4454 {
"KMP_MONITOR_STACKSIZE", __kmp_stg_parse_monitor_stacksize,
4455 __kmp_stg_print_monitor_stacksize, NULL, 0, 0},
4457 {
"KMP_SETTINGS", __kmp_stg_parse_settings, __kmp_stg_print_settings, NULL,
4459 {
"KMP_STACKOFFSET", __kmp_stg_parse_stackoffset,
4460 __kmp_stg_print_stackoffset, NULL, 0, 0},
4461 {
"KMP_STACKSIZE", __kmp_stg_parse_stacksize, __kmp_stg_print_stacksize,
4463 {
"KMP_STACKPAD", __kmp_stg_parse_stackpad, __kmp_stg_print_stackpad, NULL,
4465 {
"KMP_VERSION", __kmp_stg_parse_version, __kmp_stg_print_version, NULL, 0,
4467 {
"KMP_WARNINGS", __kmp_stg_parse_warnings, __kmp_stg_print_warnings, NULL,
4470 {
"OMP_NESTED", __kmp_stg_parse_nested, __kmp_stg_print_nested, NULL, 0, 0},
4471 {
"OMP_NUM_THREADS", __kmp_stg_parse_num_threads,
4472 __kmp_stg_print_num_threads, NULL, 0, 0},
4473 {
"OMP_STACKSIZE", __kmp_stg_parse_stacksize, __kmp_stg_print_stacksize,
4476 {
"KMP_TASKING", __kmp_stg_parse_tasking, __kmp_stg_print_tasking, NULL, 0,
4478 {
"KMP_TASK_STEALING_CONSTRAINT", __kmp_stg_parse_task_stealing,
4479 __kmp_stg_print_task_stealing, NULL, 0, 0},
4480 {
"OMP_MAX_ACTIVE_LEVELS", __kmp_stg_parse_max_active_levels,
4481 __kmp_stg_print_max_active_levels, NULL, 0, 0},
4483 {
"OMP_DEFAULT_DEVICE", __kmp_stg_parse_default_device,
4484 __kmp_stg_print_default_device, NULL, 0, 0},
4487 {
"OMP_TARGET_OFFLOAD", __kmp_stg_parse_target_offload,
4488 __kmp_stg_print_target_offload, NULL, 0, 0},
4491 {
"OMP_MAX_TASK_PRIORITY", __kmp_stg_parse_max_task_priority,
4492 __kmp_stg_print_max_task_priority, NULL, 0, 0},
4493 {
"KMP_TASKLOOP_MIN_TASKS", __kmp_stg_parse_taskloop_min_tasks,
4494 __kmp_stg_print_taskloop_min_tasks, NULL, 0, 0},
4496 {
"OMP_THREAD_LIMIT", __kmp_stg_parse_thread_limit,
4497 __kmp_stg_print_thread_limit, NULL, 0, 0},
4498 {
"KMP_TEAMS_THREAD_LIMIT", __kmp_stg_parse_teams_thread_limit,
4499 __kmp_stg_print_teams_thread_limit, NULL, 0, 0},
4500 {
"OMP_WAIT_POLICY", __kmp_stg_parse_wait_policy,
4501 __kmp_stg_print_wait_policy, NULL, 0, 0},
4502 {
"KMP_DISP_NUM_BUFFERS", __kmp_stg_parse_disp_buffers,
4503 __kmp_stg_print_disp_buffers, NULL, 0, 0},
4504 #if KMP_NESTED_HOT_TEAMS 4505 {
"KMP_HOT_TEAMS_MAX_LEVEL", __kmp_stg_parse_hot_teams_level,
4506 __kmp_stg_print_hot_teams_level, NULL, 0, 0},
4507 {
"KMP_HOT_TEAMS_MODE", __kmp_stg_parse_hot_teams_mode,
4508 __kmp_stg_print_hot_teams_mode, NULL, 0, 0},
4509 #endif // KMP_NESTED_HOT_TEAMS 4511 #if KMP_HANDLE_SIGNALS 4512 {
"KMP_HANDLE_SIGNALS", __kmp_stg_parse_handle_signals,
4513 __kmp_stg_print_handle_signals, NULL, 0, 0},
4516 #if KMP_ARCH_X86 || KMP_ARCH_X86_64 4517 {
"KMP_INHERIT_FP_CONTROL", __kmp_stg_parse_inherit_fp_control,
4518 __kmp_stg_print_inherit_fp_control, NULL, 0, 0},
4521 #ifdef KMP_GOMP_COMPAT 4522 {
"GOMP_STACKSIZE", __kmp_stg_parse_stacksize, NULL, NULL, 0, 0},
4526 {
"KMP_A_DEBUG", __kmp_stg_parse_a_debug, __kmp_stg_print_a_debug, NULL, 0,
4528 {
"KMP_B_DEBUG", __kmp_stg_parse_b_debug, __kmp_stg_print_b_debug, NULL, 0,
4530 {
"KMP_C_DEBUG", __kmp_stg_parse_c_debug, __kmp_stg_print_c_debug, NULL, 0,
4532 {
"KMP_D_DEBUG", __kmp_stg_parse_d_debug, __kmp_stg_print_d_debug, NULL, 0,
4534 {
"KMP_E_DEBUG", __kmp_stg_parse_e_debug, __kmp_stg_print_e_debug, NULL, 0,
4536 {
"KMP_F_DEBUG", __kmp_stg_parse_f_debug, __kmp_stg_print_f_debug, NULL, 0,
4538 {
"KMP_DEBUG", __kmp_stg_parse_debug, NULL, NULL, 0, 0},
4539 {
"KMP_DEBUG_BUF", __kmp_stg_parse_debug_buf, __kmp_stg_print_debug_buf,
4541 {
"KMP_DEBUG_BUF_ATOMIC", __kmp_stg_parse_debug_buf_atomic,
4542 __kmp_stg_print_debug_buf_atomic, NULL, 0, 0},
4543 {
"KMP_DEBUG_BUF_CHARS", __kmp_stg_parse_debug_buf_chars,
4544 __kmp_stg_print_debug_buf_chars, NULL, 0, 0},
4545 {
"KMP_DEBUG_BUF_LINES", __kmp_stg_parse_debug_buf_lines,
4546 __kmp_stg_print_debug_buf_lines, NULL, 0, 0},
4547 {
"KMP_DIAG", __kmp_stg_parse_diag, __kmp_stg_print_diag, NULL, 0, 0},
4549 {
"KMP_PAR_RANGE", __kmp_stg_parse_par_range_env,
4550 __kmp_stg_print_par_range_env, NULL, 0, 0},
4551 {
"KMP_YIELD_CYCLE", __kmp_stg_parse_yield_cycle,
4552 __kmp_stg_print_yield_cycle, NULL, 0, 0},
4553 {
"KMP_YIELD_ON", __kmp_stg_parse_yield_on, __kmp_stg_print_yield_on, NULL,
4555 {
"KMP_YIELD_OFF", __kmp_stg_parse_yield_off, __kmp_stg_print_yield_off,
4559 {
"KMP_ALIGN_ALLOC", __kmp_stg_parse_align_alloc,
4560 __kmp_stg_print_align_alloc, NULL, 0, 0},
4562 {
"KMP_PLAIN_BARRIER", __kmp_stg_parse_barrier_branch_bit,
4563 __kmp_stg_print_barrier_branch_bit, NULL, 0, 0},
4564 {
"KMP_PLAIN_BARRIER_PATTERN", __kmp_stg_parse_barrier_pattern,
4565 __kmp_stg_print_barrier_pattern, NULL, 0, 0},
4566 {
"KMP_FORKJOIN_BARRIER", __kmp_stg_parse_barrier_branch_bit,
4567 __kmp_stg_print_barrier_branch_bit, NULL, 0, 0},
4568 {
"KMP_FORKJOIN_BARRIER_PATTERN", __kmp_stg_parse_barrier_pattern,
4569 __kmp_stg_print_barrier_pattern, NULL, 0, 0},
4570 #if KMP_FAST_REDUCTION_BARRIER 4571 {
"KMP_REDUCTION_BARRIER", __kmp_stg_parse_barrier_branch_bit,
4572 __kmp_stg_print_barrier_branch_bit, NULL, 0, 0},
4573 {
"KMP_REDUCTION_BARRIER_PATTERN", __kmp_stg_parse_barrier_pattern,
4574 __kmp_stg_print_barrier_pattern, NULL, 0, 0},
4577 {
"KMP_ABORT_DELAY", __kmp_stg_parse_abort_delay,
4578 __kmp_stg_print_abort_delay, NULL, 0, 0},
4579 {
"KMP_CPUINFO_FILE", __kmp_stg_parse_cpuinfo_file,
4580 __kmp_stg_print_cpuinfo_file, NULL, 0, 0},
4581 {
"KMP_FORCE_REDUCTION", __kmp_stg_parse_force_reduction,
4582 __kmp_stg_print_force_reduction, NULL, 0, 0},
4583 {
"KMP_DETERMINISTIC_REDUCTION", __kmp_stg_parse_force_reduction,
4584 __kmp_stg_print_force_reduction, NULL, 0, 0},
4585 {
"KMP_STORAGE_MAP", __kmp_stg_parse_storage_map,
4586 __kmp_stg_print_storage_map, NULL, 0, 0},
4587 {
"KMP_ALL_THREADPRIVATE", __kmp_stg_parse_all_threadprivate,
4588 __kmp_stg_print_all_threadprivate, NULL, 0, 0},
4589 {
"KMP_FOREIGN_THREADS_THREADPRIVATE",
4590 __kmp_stg_parse_foreign_threads_threadprivate,
4591 __kmp_stg_print_foreign_threads_threadprivate, NULL, 0, 0},
4593 #if KMP_AFFINITY_SUPPORTED 4594 {
"KMP_AFFINITY", __kmp_stg_parse_affinity, __kmp_stg_print_affinity, NULL,
4596 #ifdef KMP_GOMP_COMPAT 4597 {
"GOMP_CPU_AFFINITY", __kmp_stg_parse_gomp_cpu_affinity, NULL,
4601 {
"OMP_PROC_BIND", __kmp_stg_parse_proc_bind, __kmp_stg_print_proc_bind,
4603 {
"OMP_PLACES", __kmp_stg_parse_places, __kmp_stg_print_places, NULL, 0, 0},
4605 {
"OMP_PROC_BIND", __kmp_stg_parse_proc_bind, NULL, NULL, 0,
4609 {
"KMP_TOPOLOGY_METHOD", __kmp_stg_parse_topology_method,
4610 __kmp_stg_print_topology_method, NULL, 0, 0},
4617 {
"OMP_PROC_BIND", __kmp_stg_parse_proc_bind, __kmp_stg_print_proc_bind,
4621 #endif // KMP_AFFINITY_SUPPORTED 4623 {
"KMP_INIT_AT_FORK", __kmp_stg_parse_init_at_fork,
4624 __kmp_stg_print_init_at_fork, NULL, 0, 0},
4625 {
"KMP_SCHEDULE", __kmp_stg_parse_schedule, __kmp_stg_print_schedule, NULL,
4627 {
"OMP_SCHEDULE", __kmp_stg_parse_omp_schedule, __kmp_stg_print_omp_schedule,
4629 {
"KMP_ATOMIC_MODE", __kmp_stg_parse_atomic_mode,
4630 __kmp_stg_print_atomic_mode, NULL, 0, 0},
4631 {
"KMP_CONSISTENCY_CHECK", __kmp_stg_parse_consistency_check,
4632 __kmp_stg_print_consistency_check, NULL, 0, 0},
4634 #if USE_ITT_BUILD && USE_ITT_NOTIFY 4635 {
"KMP_ITT_PREPARE_DELAY", __kmp_stg_parse_itt_prepare_delay,
4636 __kmp_stg_print_itt_prepare_delay, NULL, 0, 0},
4638 {
"KMP_MALLOC_POOL_INCR", __kmp_stg_parse_malloc_pool_incr,
4639 __kmp_stg_print_malloc_pool_incr, NULL, 0, 0},
4640 {
"KMP_INIT_WAIT", __kmp_stg_parse_init_wait, __kmp_stg_print_init_wait,
4642 {
"KMP_NEXT_WAIT", __kmp_stg_parse_next_wait, __kmp_stg_print_next_wait,
4644 {
"KMP_GTID_MODE", __kmp_stg_parse_gtid_mode, __kmp_stg_print_gtid_mode,
4646 {
"OMP_DYNAMIC", __kmp_stg_parse_omp_dynamic, __kmp_stg_print_omp_dynamic,
4648 {
"KMP_DYNAMIC_MODE", __kmp_stg_parse_kmp_dynamic_mode,
4649 __kmp_stg_print_kmp_dynamic_mode, NULL, 0, 0},
4651 #ifdef USE_LOAD_BALANCE 4652 {
"KMP_LOAD_BALANCE_INTERVAL", __kmp_stg_parse_ld_balance_interval,
4653 __kmp_stg_print_ld_balance_interval, NULL, 0, 0},
4656 {
"KMP_NUM_LOCKS_IN_BLOCK", __kmp_stg_parse_lock_block,
4657 __kmp_stg_print_lock_block, NULL, 0, 0},
4658 {
"KMP_LOCK_KIND", __kmp_stg_parse_lock_kind, __kmp_stg_print_lock_kind,
4660 {
"KMP_SPIN_BACKOFF_PARAMS", __kmp_stg_parse_spin_backoff_params,
4661 __kmp_stg_print_spin_backoff_params, NULL, 0, 0},
4662 #if KMP_USE_ADAPTIVE_LOCKS 4663 {
"KMP_ADAPTIVE_LOCK_PROPS", __kmp_stg_parse_adaptive_lock_props,
4664 __kmp_stg_print_adaptive_lock_props, NULL, 0, 0},
4665 #if KMP_DEBUG_ADAPTIVE_LOCKS 4666 {
"KMP_SPECULATIVE_STATSFILE", __kmp_stg_parse_speculative_statsfile,
4667 __kmp_stg_print_speculative_statsfile, NULL, 0, 0},
4669 #endif // KMP_USE_ADAPTIVE_LOCKS 4670 {
"KMP_PLACE_THREADS", __kmp_stg_parse_hw_subset, __kmp_stg_print_hw_subset,
4672 {
"KMP_HW_SUBSET", __kmp_stg_parse_hw_subset, __kmp_stg_print_hw_subset,
4675 {
"KMP_FORKJOIN_FRAMES", __kmp_stg_parse_forkjoin_frames,
4676 __kmp_stg_print_forkjoin_frames, NULL, 0, 0},
4677 {
"KMP_FORKJOIN_FRAMES_MODE", __kmp_stg_parse_forkjoin_frames_mode,
4678 __kmp_stg_print_forkjoin_frames_mode, NULL, 0, 0},
4682 {
"OMP_DISPLAY_ENV", __kmp_stg_parse_omp_display_env,
4683 __kmp_stg_print_omp_display_env, NULL, 0, 0},
4684 {
"OMP_CANCELLATION", __kmp_stg_parse_omp_cancellation,
4685 __kmp_stg_print_omp_cancellation, NULL, 0, 0},
4688 #if OMP_50_ENABLED && OMPT_SUPPORT 4689 {
"OMP_TOOL_LIBRARIES", __kmp_stg_parse_omp_tool_libraries,
4690 __kmp_stg_print_omp_tool_libraries, NULL, 0, 0},
4693 {
"", NULL, NULL, NULL, 0, 0}};
4695 static int const __kmp_stg_count =
4696 sizeof(__kmp_stg_table) /
sizeof(kmp_setting_t);
4698 static inline kmp_setting_t *__kmp_stg_find(
char const *name) {
4702 for (i = 0; i < __kmp_stg_count; ++i) {
4703 if (strcmp(__kmp_stg_table[i].name, name) == 0) {
4704 return &__kmp_stg_table[i];
4712 static int __kmp_stg_cmp(
void const *_a,
void const *_b) {
4713 const kmp_setting_t *a = RCAST(
const kmp_setting_t *, _a);
4714 const kmp_setting_t *b = RCAST(
const kmp_setting_t *, _b);
4718 if (strcmp(a->name,
"KMP_AFFINITY") == 0) {
4719 if (strcmp(b->name,
"KMP_AFFINITY") == 0) {
4723 }
else if (strcmp(b->name,
"KMP_AFFINITY") == 0) {
4726 return strcmp(a->name, b->name);
4729 static void __kmp_stg_init(
void) {
4731 static int initialized = 0;
4736 qsort(__kmp_stg_table, __kmp_stg_count - 1,
sizeof(kmp_setting_t),
4740 kmp_setting_t *kmp_stacksize =
4741 __kmp_stg_find(
"KMP_STACKSIZE");
4742 #ifdef KMP_GOMP_COMPAT 4743 kmp_setting_t *gomp_stacksize =
4744 __kmp_stg_find(
"GOMP_STACKSIZE");
4746 kmp_setting_t *omp_stacksize =
4747 __kmp_stg_find(
"OMP_STACKSIZE");
4753 static kmp_setting_t *
volatile rivals[4];
4754 static kmp_stg_ss_data_t kmp_data = {1, CCAST(kmp_setting_t **, rivals)};
4755 #ifdef KMP_GOMP_COMPAT 4756 static kmp_stg_ss_data_t gomp_data = {1024,
4757 CCAST(kmp_setting_t **, rivals)};
4759 static kmp_stg_ss_data_t omp_data = {1024,
4760 CCAST(kmp_setting_t **, rivals)};
4763 rivals[i++] = kmp_stacksize;
4764 #ifdef KMP_GOMP_COMPAT 4765 if (gomp_stacksize != NULL) {
4766 rivals[i++] = gomp_stacksize;
4769 rivals[i++] = omp_stacksize;
4772 kmp_stacksize->data = &kmp_data;
4773 #ifdef KMP_GOMP_COMPAT 4774 if (gomp_stacksize != NULL) {
4775 gomp_stacksize->data = &gomp_data;
4778 omp_stacksize->data = &omp_data;
4782 kmp_setting_t *kmp_library =
4783 __kmp_stg_find(
"KMP_LIBRARY");
4784 kmp_setting_t *omp_wait_policy =
4785 __kmp_stg_find(
"OMP_WAIT_POLICY");
4788 static kmp_setting_t *
volatile rivals[3];
4789 static kmp_stg_wp_data_t kmp_data = {0, CCAST(kmp_setting_t **, rivals)};
4790 static kmp_stg_wp_data_t omp_data = {1, CCAST(kmp_setting_t **, rivals)};
4793 rivals[i++] = kmp_library;
4794 if (omp_wait_policy != NULL) {
4795 rivals[i++] = omp_wait_policy;
4799 kmp_library->data = &kmp_data;
4800 if (omp_wait_policy != NULL) {
4801 omp_wait_policy->data = &omp_data;
4806 kmp_setting_t *kmp_device_thread_limit =
4807 __kmp_stg_find(
"KMP_DEVICE_THREAD_LIMIT");
4808 kmp_setting_t *kmp_all_threads =
4809 __kmp_stg_find(
"KMP_ALL_THREADS");
4812 static kmp_setting_t *
volatile rivals[3];
4815 rivals[i++] = kmp_device_thread_limit;
4816 rivals[i++] = kmp_all_threads;
4819 kmp_device_thread_limit->data = CCAST(kmp_setting_t **, rivals);
4820 kmp_all_threads->data = CCAST(kmp_setting_t **, rivals);
4825 kmp_setting_t *kmp_hw_subset = __kmp_stg_find(
"KMP_HW_SUBSET");
4827 kmp_setting_t *kmp_place_threads = __kmp_stg_find(
"KMP_PLACE_THREADS");
4830 static kmp_setting_t *
volatile rivals[3];
4833 rivals[i++] = kmp_hw_subset;
4834 rivals[i++] = kmp_place_threads;
4837 kmp_hw_subset->data = CCAST(kmp_setting_t **, rivals);
4838 kmp_place_threads->data = CCAST(kmp_setting_t **, rivals);
4841 #if KMP_AFFINITY_SUPPORTED 4843 kmp_setting_t *kmp_affinity =
4844 __kmp_stg_find(
"KMP_AFFINITY");
4845 KMP_DEBUG_ASSERT(kmp_affinity != NULL);
4847 #ifdef KMP_GOMP_COMPAT 4848 kmp_setting_t *gomp_cpu_affinity =
4849 __kmp_stg_find(
"GOMP_CPU_AFFINITY");
4850 KMP_DEBUG_ASSERT(gomp_cpu_affinity != NULL);
4853 kmp_setting_t *omp_proc_bind =
4854 __kmp_stg_find(
"OMP_PROC_BIND");
4855 KMP_DEBUG_ASSERT(omp_proc_bind != NULL);
4858 static kmp_setting_t *
volatile rivals[4];
4861 rivals[i++] = kmp_affinity;
4863 #ifdef KMP_GOMP_COMPAT 4864 rivals[i++] = gomp_cpu_affinity;
4865 gomp_cpu_affinity->data = CCAST(kmp_setting_t **, rivals);
4868 rivals[i++] = omp_proc_bind;
4869 omp_proc_bind->data = CCAST(kmp_setting_t **, rivals);
4873 static kmp_setting_t *
volatile places_rivals[4];
4876 kmp_setting_t *omp_places = __kmp_stg_find(
"OMP_PLACES");
4877 KMP_DEBUG_ASSERT(omp_places != NULL);
4879 places_rivals[i++] = kmp_affinity;
4880 #ifdef KMP_GOMP_COMPAT 4881 places_rivals[i++] = gomp_cpu_affinity;
4883 places_rivals[i++] = omp_places;
4884 omp_places->data = CCAST(kmp_setting_t **, places_rivals);
4885 places_rivals[i++] = NULL;
4891 #endif // KMP_AFFINITY_SUPPORTED 4894 kmp_setting_t *kmp_force_red =
4895 __kmp_stg_find(
"KMP_FORCE_REDUCTION");
4896 kmp_setting_t *kmp_determ_red =
4897 __kmp_stg_find(
"KMP_DETERMINISTIC_REDUCTION");
4900 static kmp_setting_t *
volatile rivals[3];
4901 static kmp_stg_fr_data_t force_data = {1,
4902 CCAST(kmp_setting_t **, rivals)};
4903 static kmp_stg_fr_data_t determ_data = {0,
4904 CCAST(kmp_setting_t **, rivals)};
4907 rivals[i++] = kmp_force_red;
4908 if (kmp_determ_red != NULL) {
4909 rivals[i++] = kmp_determ_red;
4913 kmp_force_red->data = &force_data;
4914 if (kmp_determ_red != NULL) {
4915 kmp_determ_red->data = &determ_data;
4924 for (i = 0; i < __kmp_stg_count; ++i) {
4925 __kmp_stg_table[i].set = 0;
4930 static void __kmp_stg_parse(
char const *name,
char const *value) {
4938 if (value != NULL) {
4939 kmp_setting_t *setting = __kmp_stg_find(name);
4940 if (setting != NULL) {
4941 setting->parse(name, value, setting->data);
4942 setting->defined = 1;
4948 static int __kmp_stg_check_rivals(
4951 kmp_setting_t **rivals
4954 if (rivals == NULL) {
4960 for (; strcmp(rivals[i]->name, name) != 0; i++) {
4961 KMP_DEBUG_ASSERT(rivals[i] != NULL);
4963 #if KMP_AFFINITY_SUPPORTED 4964 if (rivals[i] == __kmp_affinity_notype) {
4971 if (rivals[i]->
set) {
4972 KMP_WARNING(StgIgnored, name, rivals[i]->name);
4982 static int __kmp_env_toPrint(
char const *name,
int flag) {
4984 kmp_setting_t *setting = __kmp_stg_find(name);
4985 if (setting != NULL) {
4986 rc = setting->defined;
4988 setting->defined = flag;
4994 static void __kmp_aux_env_initialize(kmp_env_blk_t *block) {
4999 value = __kmp_env_blk_var(block,
"OMP_NUM_THREADS");
5001 ompc_set_num_threads(__kmp_dflt_team_nth);
5005 value = __kmp_env_blk_var(block,
"KMP_BLOCKTIME");
5007 kmpc_set_blocktime(__kmp_dflt_blocktime);
5011 value = __kmp_env_blk_var(block,
"OMP_NESTED");
5013 ompc_set_nested(__kmp_dflt_nested);
5017 value = __kmp_env_blk_var(block,
"OMP_DYNAMIC");
5019 ompc_set_dynamic(__kmp_global.g.g_dynamic);
5023 void __kmp_env_initialize(
char const *
string) {
5025 kmp_env_blk_t block;
5031 if (
string == NULL) {
5033 __kmp_threads_capacity =
5034 __kmp_initial_threads_capacity(__kmp_dflt_team_nth_ub);
5036 __kmp_env_blk_init(&block,
string);
5039 for (i = 0; i < block.count; ++i) {
5040 if ((block.vars[i].name == NULL) || (*block.vars[i].name ==
'\0')) {
5043 if (block.vars[i].value == NULL) {
5046 kmp_setting_t *setting = __kmp_stg_find(block.vars[i].name);
5047 if (setting != NULL) {
5053 blocktime_str = __kmp_env_blk_var(&block,
"KMP_BLOCKTIME");
5057 if (
string == NULL) {
5058 char const *name =
"KMP_WARNINGS";
5059 char const *value = __kmp_env_blk_var(&block, name);
5060 __kmp_stg_parse(name, value);
5063 #if KMP_AFFINITY_SUPPORTED 5069 __kmp_affinity_notype = NULL;
5070 char const *aff_str = __kmp_env_blk_var(&block,
"KMP_AFFINITY");
5071 if (aff_str != NULL) {
5085 #define FIND strcasestr 5088 if ((FIND(aff_str,
"none") == NULL) &&
5089 (FIND(aff_str,
"physical") == NULL) &&
5090 (FIND(aff_str,
"logical") == NULL) &&
5091 (FIND(aff_str,
"compact") == NULL) &&
5092 (FIND(aff_str,
"scatter") == NULL) &&
5093 (FIND(aff_str,
"explicit") == NULL) &&
5094 (FIND(aff_str,
"balanced") == NULL) &&
5095 (FIND(aff_str,
"disabled") == NULL)) {
5096 __kmp_affinity_notype = __kmp_stg_find(
"KMP_AFFINITY");
5101 __kmp_affinity_type = affinity_default;
5102 __kmp_affinity_gran = affinity_gran_default;
5103 __kmp_affinity_top_method = affinity_top_method_default;
5104 __kmp_affinity_respect_mask = affinity_respect_mask_default;
5110 aff_str = __kmp_env_blk_var(&block,
"OMP_PROC_BIND");
5111 if (aff_str != NULL) {
5112 __kmp_affinity_type = affinity_default;
5113 __kmp_affinity_gran = affinity_gran_default;
5114 __kmp_affinity_top_method = affinity_top_method_default;
5115 __kmp_affinity_respect_mask = affinity_respect_mask_default;
5124 if (__kmp_nested_proc_bind.bind_types == NULL) {
5125 __kmp_nested_proc_bind.bind_types =
5126 (kmp_proc_bind_t *)KMP_INTERNAL_MALLOC(
sizeof(kmp_proc_bind_t));
5127 if (__kmp_nested_proc_bind.bind_types == NULL) {
5128 KMP_FATAL(MemoryAllocFailed);
5130 __kmp_nested_proc_bind.size = 1;
5131 __kmp_nested_proc_bind.used = 1;
5132 #if KMP_AFFINITY_SUPPORTED 5133 __kmp_nested_proc_bind.bind_types[0] = proc_bind_default;
5136 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
5142 for (i = 0; i < block.count; ++i) {
5143 __kmp_stg_parse(block.vars[i].name, block.vars[i].value);
5147 if (!__kmp_init_user_locks) {
5148 if (__kmp_user_lock_kind == lk_default) {
5149 __kmp_user_lock_kind = lk_queuing;
5151 #if KMP_USE_DYNAMIC_LOCK 5152 __kmp_init_dynamic_user_locks();
5154 __kmp_set_user_lock_vptrs(__kmp_user_lock_kind);
5157 KMP_DEBUG_ASSERT(
string != NULL);
5158 KMP_DEBUG_ASSERT(__kmp_user_lock_kind != lk_default);
5163 #if KMP_USE_DYNAMIC_LOCK 5164 __kmp_init_dynamic_user_locks();
5166 __kmp_set_user_lock_vptrs(__kmp_user_lock_kind);
5170 #if KMP_AFFINITY_SUPPORTED 5172 if (!TCR_4(__kmp_init_middle)) {
5176 if ((__kmp_hws_node.num > 0 || __kmp_hws_tile.num > 0 ||
5177 __kmp_affinity_gran == affinity_gran_tile) &&
5178 (__kmp_affinity_top_method == affinity_top_method_default)) {
5179 __kmp_affinity_top_method = affinity_top_method_hwloc;
5184 const char *var =
"KMP_AFFINITY";
5185 KMPAffinity::pick_api();
5190 if (__kmp_affinity_top_method == affinity_top_method_hwloc &&
5191 __kmp_affinity_dispatch->get_api_type() != KMPAffinity::HWLOC) {
5192 KMP_WARNING(AffIgnoringHwloc, var);
5193 __kmp_affinity_top_method = affinity_top_method_all;
5196 if (__kmp_affinity_type == affinity_disabled) {
5197 KMP_AFFINITY_DISABLE();
5198 }
else if (!KMP_AFFINITY_CAPABLE()) {
5199 __kmp_affinity_dispatch->determine_capable(var);
5200 if (!KMP_AFFINITY_CAPABLE()) {
5201 if (__kmp_affinity_verbose ||
5202 (__kmp_affinity_warnings &&
5203 (__kmp_affinity_type != affinity_default) &&
5204 (__kmp_affinity_type != affinity_none) &&
5205 (__kmp_affinity_type != affinity_disabled))) {
5206 KMP_WARNING(AffNotSupported, var);
5208 __kmp_affinity_type = affinity_disabled;
5209 __kmp_affinity_respect_mask = 0;
5210 __kmp_affinity_gran = affinity_gran_fine;
5215 if (__kmp_affinity_type == affinity_disabled) {
5216 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
5217 }
else if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_true) {
5219 __kmp_nested_proc_bind.bind_types[0] = proc_bind_spread;
5223 if (KMP_AFFINITY_CAPABLE()) {
5225 #if KMP_GROUP_AFFINITY 5230 bool exactly_one_group =
false;
5231 if (__kmp_num_proc_groups > 1) {
5233 bool within_one_group;
5236 kmp_affin_mask_t *init_mask;
5237 KMP_CPU_ALLOC(init_mask);
5238 __kmp_get_system_affinity(init_mask, TRUE);
5239 group = __kmp_get_proc_group(init_mask);
5240 within_one_group = (group >= 0);
5243 if (within_one_group) {
5244 DWORD num_bits_in_group = __kmp_GetActiveProcessorCount(group);
5245 int num_bits_in_mask = 0;
5246 for (
int bit = init_mask->begin(); bit != init_mask->end();
5247 bit = init_mask->next(bit))
5249 exactly_one_group = (num_bits_in_group == num_bits_in_mask);
5251 KMP_CPU_FREE(init_mask);
5257 if (((__kmp_num_proc_groups > 1) &&
5258 (__kmp_affinity_type == affinity_default)
5260 && (__kmp_nested_proc_bind.bind_types[0] == proc_bind_default))
5262 || (__kmp_affinity_top_method == affinity_top_method_group)) {
5263 if (__kmp_affinity_respect_mask == affinity_respect_mask_default &&
5264 exactly_one_group) {
5265 __kmp_affinity_respect_mask = FALSE;
5267 if (__kmp_affinity_type == affinity_default) {
5268 __kmp_affinity_type = affinity_compact;
5270 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
5273 if (__kmp_affinity_top_method == affinity_top_method_default) {
5274 if (__kmp_affinity_gran == affinity_gran_default) {
5275 __kmp_affinity_top_method = affinity_top_method_group;
5276 __kmp_affinity_gran = affinity_gran_group;
5277 }
else if (__kmp_affinity_gran == affinity_gran_group) {
5278 __kmp_affinity_top_method = affinity_top_method_group;
5280 __kmp_affinity_top_method = affinity_top_method_all;
5282 }
else if (__kmp_affinity_top_method == affinity_top_method_group) {
5283 if (__kmp_affinity_gran == affinity_gran_default) {
5284 __kmp_affinity_gran = affinity_gran_group;
5285 }
else if ((__kmp_affinity_gran != affinity_gran_group) &&
5286 (__kmp_affinity_gran != affinity_gran_fine) &&
5287 (__kmp_affinity_gran != affinity_gran_thread)) {
5288 const char *str = NULL;
5289 switch (__kmp_affinity_gran) {
5290 case affinity_gran_core:
5293 case affinity_gran_package:
5296 case affinity_gran_node:
5299 case affinity_gran_tile:
5303 KMP_DEBUG_ASSERT(0);
5305 KMP_WARNING(AffGranTopGroup, var, str);
5306 __kmp_affinity_gran = affinity_gran_fine;
5309 if (__kmp_affinity_gran == affinity_gran_default) {
5310 __kmp_affinity_gran = affinity_gran_core;
5311 }
else if (__kmp_affinity_gran == affinity_gran_group) {
5312 const char *str = NULL;
5313 switch (__kmp_affinity_type) {
5314 case affinity_physical:
5317 case affinity_logical:
5320 case affinity_compact:
5323 case affinity_scatter:
5326 case affinity_explicit:
5331 KMP_DEBUG_ASSERT(0);
5333 KMP_WARNING(AffGranGroupType, var, str);
5334 __kmp_affinity_gran = affinity_gran_core;
5342 if (__kmp_affinity_respect_mask == affinity_respect_mask_default) {
5343 #if KMP_GROUP_AFFINITY 5344 if (__kmp_num_proc_groups > 1 && exactly_one_group) {
5345 __kmp_affinity_respect_mask = FALSE;
5349 __kmp_affinity_respect_mask = TRUE;
5353 if ((__kmp_nested_proc_bind.bind_types[0] != proc_bind_intel) &&
5354 (__kmp_nested_proc_bind.bind_types[0] != proc_bind_default)) {
5355 if (__kmp_affinity_type == affinity_default) {
5356 __kmp_affinity_type = affinity_compact;
5357 __kmp_affinity_dups = FALSE;
5361 if (__kmp_affinity_type == affinity_default) {
5363 #if KMP_MIC_SUPPORTED 5364 if (__kmp_mic_type != non_mic) {
5365 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
5369 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
5372 #if KMP_MIC_SUPPORTED 5373 if (__kmp_mic_type != non_mic) {
5374 __kmp_affinity_type = affinity_scatter;
5378 __kmp_affinity_type = affinity_none;
5381 if ((__kmp_affinity_gran == affinity_gran_default) &&
5382 (__kmp_affinity_gran_levels < 0)) {
5383 #if KMP_MIC_SUPPORTED 5384 if (__kmp_mic_type != non_mic) {
5385 __kmp_affinity_gran = affinity_gran_fine;
5389 __kmp_affinity_gran = affinity_gran_core;
5392 if (__kmp_affinity_top_method == affinity_top_method_default) {
5393 __kmp_affinity_top_method = affinity_top_method_all;
5398 K_DIAG(1, (
"__kmp_affinity_type == %d\n", __kmp_affinity_type));
5399 K_DIAG(1, (
"__kmp_affinity_compact == %d\n", __kmp_affinity_compact));
5400 K_DIAG(1, (
"__kmp_affinity_offset == %d\n", __kmp_affinity_offset));
5401 K_DIAG(1, (
"__kmp_affinity_verbose == %d\n", __kmp_affinity_verbose));
5402 K_DIAG(1, (
"__kmp_affinity_warnings == %d\n", __kmp_affinity_warnings));
5403 K_DIAG(1, (
"__kmp_affinity_respect_mask == %d\n",
5404 __kmp_affinity_respect_mask));
5405 K_DIAG(1, (
"__kmp_affinity_gran == %d\n", __kmp_affinity_gran));
5407 KMP_DEBUG_ASSERT(__kmp_affinity_type != affinity_default);
5409 KMP_DEBUG_ASSERT(__kmp_nested_proc_bind.bind_types[0] != proc_bind_default);
5410 K_DIAG(1, (
"__kmp_nested_proc_bind.bind_types[0] == %d\n",
5411 __kmp_nested_proc_bind.bind_types[0]));
5417 if (__kmp_version) {
5418 __kmp_print_version_1();
5423 if (
string != NULL) {
5424 __kmp_aux_env_initialize(&block);
5427 __kmp_env_blk_free(&block);
5433 void __kmp_env_print() {
5435 kmp_env_blk_t block;
5437 kmp_str_buf_t buffer;
5440 __kmp_str_buf_init(&buffer);
5442 __kmp_env_blk_init(&block, NULL);
5443 __kmp_env_blk_sort(&block);
5446 __kmp_str_buf_print(&buffer,
"\n%s\n\n", KMP_I18N_STR(UserSettings));
5447 for (i = 0; i < block.count; ++i) {
5448 char const *name = block.vars[i].name;
5449 char const *value = block.vars[i].value;
5450 if ((KMP_STRLEN(name) > 4 && strncmp(name,
"KMP_", 4) == 0) ||
5451 strncmp(name,
"OMP_", 4) == 0
5452 #ifdef KMP_GOMP_COMPAT
5453 || strncmp(name,
"GOMP_", 5) == 0
5456 __kmp_str_buf_print(&buffer,
" %s=%s\n", name, value);
5459 __kmp_str_buf_print(&buffer,
"\n");
5462 __kmp_str_buf_print(&buffer,
"%s\n\n", KMP_I18N_STR(EffectiveSettings));
5463 for (
int i = 0; i < __kmp_stg_count; ++i) {
5464 if (__kmp_stg_table[i].print != NULL) {
5465 __kmp_stg_table[i].print(&buffer, __kmp_stg_table[i].name,
5466 __kmp_stg_table[i].data);
5470 __kmp_printf(
"%s", buffer.str);
5472 __kmp_env_blk_free(&block);
5473 __kmp_str_buf_free(&buffer);
5480 void __kmp_env_print_2() {
5482 kmp_env_blk_t block;
5483 kmp_str_buf_t buffer;
5485 __kmp_env_format = 1;
5488 __kmp_str_buf_init(&buffer);
5490 __kmp_env_blk_init(&block, NULL);
5491 __kmp_env_blk_sort(&block);
5493 __kmp_str_buf_print(&buffer,
"\n%s\n", KMP_I18N_STR(DisplayEnvBegin));
5494 __kmp_str_buf_print(&buffer,
" _OPENMP='%d'\n", __kmp_openmp_version);
5496 for (
int i = 0; i < __kmp_stg_count; ++i) {
5497 if (__kmp_stg_table[i].print != NULL &&
5498 ((__kmp_display_env &&
5499 strncmp(__kmp_stg_table[i].name,
"OMP_", 4) == 0) ||
5500 __kmp_display_env_verbose)) {
5501 __kmp_stg_table[i].print(&buffer, __kmp_stg_table[i].name,
5502 __kmp_stg_table[i].data);
5506 __kmp_str_buf_print(&buffer,
"%s\n", KMP_I18N_STR(DisplayEnvEnd));
5507 __kmp_str_buf_print(&buffer,
"\n");
5509 __kmp_printf(
"%s", buffer.str);
5511 __kmp_env_blk_free(&block);
5512 __kmp_str_buf_free(&buffer);
5517 #endif // OMP_40_ENABLED