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);
669 static char const *blocktime_str = NULL;
674 static void __kmp_stg_parse_duplicate_lib_ok(
char const *name,
675 char const *value,
void *data) {
678 __kmp_stg_parse_bool(name, value, &__kmp_duplicate_library_ok);
681 static void __kmp_stg_print_duplicate_lib_ok(kmp_str_buf_t *buffer,
682 char const *name,
void *data) {
683 __kmp_stg_print_bool(buffer, name, __kmp_duplicate_library_ok);
689 #if KMP_ARCH_X86 || KMP_ARCH_X86_64 691 static void __kmp_stg_parse_inherit_fp_control(
char const *name,
692 char const *value,
void *data) {
693 __kmp_stg_parse_bool(name, value, &__kmp_inherit_fp_control);
696 static void __kmp_stg_print_inherit_fp_control(kmp_str_buf_t *buffer,
697 char const *name,
void *data) {
699 __kmp_stg_print_bool(buffer, name, __kmp_inherit_fp_control);
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_max_task_priority(
char const *name,
1186 char const *value,
void *data) {
1187 __kmp_stg_parse_int(name, value, 0, KMP_MAX_TASK_PRIORITY_LIMIT,
1188 &__kmp_max_task_priority);
1191 static void __kmp_stg_print_max_task_priority(kmp_str_buf_t *buffer,
1192 char const *name,
void *data) {
1193 __kmp_stg_print_int(buffer, name, __kmp_max_task_priority);
1198 static void __kmp_stg_parse_taskloop_min_tasks(
char const *name,
1199 char const *value,
void *data) {
1201 __kmp_stg_parse_int(name, value, 0, INT_MAX, &tmp);
1202 __kmp_taskloop_min_tasks = tmp;
1205 static void __kmp_stg_print_taskloop_min_tasks(kmp_str_buf_t *buffer,
1206 char const *name,
void *data) {
1207 __kmp_stg_print_int(buffer, name, __kmp_taskloop_min_tasks);
1209 #endif // OMP_45_ENABLED 1213 static void __kmp_stg_parse_disp_buffers(
char const *name,
char const *value,
1215 if (TCR_4(__kmp_init_serial)) {
1216 KMP_WARNING(EnvSerialWarn, name);
1219 __kmp_stg_parse_int(name, value, 1, KMP_MAX_NTH, &__kmp_dispatch_num_buffers);
1222 static void __kmp_stg_print_disp_buffers(kmp_str_buf_t *buffer,
1223 char const *name,
void *data) {
1224 __kmp_stg_print_int(buffer, name, __kmp_dispatch_num_buffers);
1227 #if KMP_NESTED_HOT_TEAMS 1231 static void __kmp_stg_parse_hot_teams_level(
char const *name,
char const *value,
1233 if (TCR_4(__kmp_init_parallel)) {
1234 KMP_WARNING(EnvParallelWarn, name);
1237 __kmp_stg_parse_int(name, value, 0, KMP_MAX_ACTIVE_LEVELS_LIMIT,
1238 &__kmp_hot_teams_max_level);
1241 static void __kmp_stg_print_hot_teams_level(kmp_str_buf_t *buffer,
1242 char const *name,
void *data) {
1243 __kmp_stg_print_int(buffer, name, __kmp_hot_teams_max_level);
1246 static void __kmp_stg_parse_hot_teams_mode(
char const *name,
char const *value,
1248 if (TCR_4(__kmp_init_parallel)) {
1249 KMP_WARNING(EnvParallelWarn, name);
1252 __kmp_stg_parse_int(name, value, 0, KMP_MAX_ACTIVE_LEVELS_LIMIT,
1253 &__kmp_hot_teams_mode);
1256 static void __kmp_stg_print_hot_teams_mode(kmp_str_buf_t *buffer,
1257 char const *name,
void *data) {
1258 __kmp_stg_print_int(buffer, name, __kmp_hot_teams_mode);
1261 #endif // KMP_NESTED_HOT_TEAMS 1266 #if KMP_HANDLE_SIGNALS 1268 static void __kmp_stg_parse_handle_signals(
char const *name,
char const *value,
1270 __kmp_stg_parse_bool(name, value, &__kmp_handle_signals);
1273 static void __kmp_stg_print_handle_signals(kmp_str_buf_t *buffer,
1274 char const *name,
void *data) {
1275 __kmp_stg_print_bool(buffer, name, __kmp_handle_signals);
1278 #endif // KMP_HANDLE_SIGNALS 1285 #define KMP_STG_X_DEBUG(x) \ 1286 static void __kmp_stg_parse_##x##_debug(char const *name, char const *value, \ 1288 __kmp_stg_parse_int(name, value, 0, INT_MAX, &kmp_##x##_debug); \ 1290 static void __kmp_stg_print_##x##_debug(kmp_str_buf_t *buffer, \ 1291 char const *name, void *data) { \ 1292 __kmp_stg_print_int(buffer, name, kmp_##x##_debug); \ 1302 #undef KMP_STG_X_DEBUG 1304 static void __kmp_stg_parse_debug(
char const *name,
char const *value,
1307 __kmp_stg_parse_int(name, value, 0, INT_MAX, &debug);
1308 if (kmp_a_debug < debug) {
1309 kmp_a_debug = debug;
1311 if (kmp_b_debug < debug) {
1312 kmp_b_debug = debug;
1314 if (kmp_c_debug < debug) {
1315 kmp_c_debug = debug;
1317 if (kmp_d_debug < debug) {
1318 kmp_d_debug = debug;
1320 if (kmp_e_debug < debug) {
1321 kmp_e_debug = debug;
1323 if (kmp_f_debug < debug) {
1324 kmp_f_debug = debug;
1328 static void __kmp_stg_parse_debug_buf(
char const *name,
char const *value,
1330 __kmp_stg_parse_bool(name, value, &__kmp_debug_buf);
1334 if (__kmp_debug_buf) {
1336 int elements = __kmp_debug_buf_lines * __kmp_debug_buf_chars;
1339 __kmp_debug_buffer = (
char *)__kmp_page_allocate(elements *
sizeof(
char));
1340 for (i = 0; i < elements; i += __kmp_debug_buf_chars)
1341 __kmp_debug_buffer[i] =
'\0';
1343 __kmp_debug_count = 0;
1345 K_DIAG(1, (
"__kmp_debug_buf = %d\n", __kmp_debug_buf));
1348 static void __kmp_stg_print_debug_buf(kmp_str_buf_t *buffer,
char const *name,
1350 __kmp_stg_print_bool(buffer, name, __kmp_debug_buf);
1353 static void __kmp_stg_parse_debug_buf_atomic(
char const *name,
1354 char const *value,
void *data) {
1355 __kmp_stg_parse_bool(name, value, &__kmp_debug_buf_atomic);
1358 static void __kmp_stg_print_debug_buf_atomic(kmp_str_buf_t *buffer,
1359 char const *name,
void *data) {
1360 __kmp_stg_print_bool(buffer, name, __kmp_debug_buf_atomic);
1363 static void __kmp_stg_parse_debug_buf_chars(
char const *name,
char const *value,
1365 __kmp_stg_parse_int(name, value, KMP_DEBUG_BUF_CHARS_MIN, INT_MAX,
1366 &__kmp_debug_buf_chars);
1369 static void __kmp_stg_print_debug_buf_chars(kmp_str_buf_t *buffer,
1370 char const *name,
void *data) {
1371 __kmp_stg_print_int(buffer, name, __kmp_debug_buf_chars);
1374 static void __kmp_stg_parse_debug_buf_lines(
char const *name,
char const *value,
1376 __kmp_stg_parse_int(name, value, KMP_DEBUG_BUF_LINES_MIN, INT_MAX,
1377 &__kmp_debug_buf_lines);
1380 static void __kmp_stg_print_debug_buf_lines(kmp_str_buf_t *buffer,
1381 char const *name,
void *data) {
1382 __kmp_stg_print_int(buffer, name, __kmp_debug_buf_lines);
1385 static void __kmp_stg_parse_diag(
char const *name,
char const *value,
1387 __kmp_stg_parse_int(name, value, 0, INT_MAX, &kmp_diag);
1390 static void __kmp_stg_print_diag(kmp_str_buf_t *buffer,
char const *name,
1392 __kmp_stg_print_int(buffer, name, kmp_diag);
1400 static void __kmp_stg_parse_align_alloc(
char const *name,
char const *value,
1402 __kmp_stg_parse_size(name, value, CACHE_LINE, INT_MAX, NULL,
1403 &__kmp_align_alloc, 1);
1406 static void __kmp_stg_print_align_alloc(kmp_str_buf_t *buffer,
char const *name,
1408 __kmp_stg_print_size(buffer, name, __kmp_align_alloc);
1417 static void __kmp_stg_parse_barrier_branch_bit(
char const *name,
1418 char const *value,
void *data) {
1422 for (
int i = bs_plain_barrier; i < bs_last_barrier; i++) {
1423 var = __kmp_barrier_branch_bit_env_name[i];
1424 if ((strcmp(var, name) == 0) && (value != 0)) {
1427 comma = CCAST(
char *, strchr(value,
','));
1428 __kmp_barrier_gather_branch_bits[i] =
1429 (kmp_uint32)__kmp_str_to_int(value,
',');
1431 if (comma == NULL) {
1432 __kmp_barrier_release_branch_bits[i] = __kmp_barrier_release_bb_dflt;
1434 __kmp_barrier_release_branch_bits[i] =
1435 (kmp_uint32)__kmp_str_to_int(comma + 1, 0);
1437 if (__kmp_barrier_release_branch_bits[i] > KMP_MAX_BRANCH_BITS) {
1438 __kmp_msg(kmp_ms_warning,
1439 KMP_MSG(BarrReleaseValueInvalid, name, comma + 1),
1441 __kmp_barrier_release_branch_bits[i] = __kmp_barrier_release_bb_dflt;
1444 if (__kmp_barrier_gather_branch_bits[i] > KMP_MAX_BRANCH_BITS) {
1445 KMP_WARNING(BarrGatherValueInvalid, name, value);
1446 KMP_INFORM(Using_uint_Value, name, __kmp_barrier_gather_bb_dflt);
1447 __kmp_barrier_gather_branch_bits[i] = __kmp_barrier_gather_bb_dflt;
1450 K_DIAG(1, (
"%s == %d,%d\n", __kmp_barrier_branch_bit_env_name[i],
1451 __kmp_barrier_gather_branch_bits[i],
1452 __kmp_barrier_release_branch_bits[i]))
1456 static void __kmp_stg_print_barrier_branch_bit(kmp_str_buf_t *buffer,
1457 char const *name,
void *data) {
1459 for (
int i = bs_plain_barrier; i < bs_last_barrier; i++) {
1460 var = __kmp_barrier_branch_bit_env_name[i];
1461 if (strcmp(var, name) == 0) {
1462 if (__kmp_env_format) {
1463 KMP_STR_BUF_PRINT_NAME_EX(__kmp_barrier_branch_bit_env_name[i]);
1465 __kmp_str_buf_print(buffer,
" %s='",
1466 __kmp_barrier_branch_bit_env_name[i]);
1468 __kmp_str_buf_print(buffer,
"%d,%d'\n",
1469 __kmp_barrier_gather_branch_bits[i],
1470 __kmp_barrier_release_branch_bits[i]);
1482 static void __kmp_stg_parse_barrier_pattern(
char const *name,
char const *value,
1487 for (
int i = bs_plain_barrier; i < bs_last_barrier; i++) {
1488 var = __kmp_barrier_pattern_env_name[i];
1490 if ((strcmp(var, name) == 0) && (value != 0)) {
1492 char *comma = CCAST(
char *, strchr(value,
','));
1495 for (j = bp_linear_bar; j < bp_last_bar; j++) {
1496 if (__kmp_match_with_sentinel(__kmp_barrier_pattern_name[j], value, 1,
1498 __kmp_barrier_gather_pattern[i] = (kmp_bar_pat_e)j;
1502 if (j == bp_last_bar) {
1503 KMP_WARNING(BarrGatherValueInvalid, name, value);
1504 KMP_INFORM(Using_str_Value, name,
1505 __kmp_barrier_pattern_name[bp_linear_bar]);
1509 if (comma != NULL) {
1510 for (j = bp_linear_bar; j < bp_last_bar; j++) {
1511 if (__kmp_str_match(__kmp_barrier_pattern_name[j], 1, comma + 1)) {
1512 __kmp_barrier_release_pattern[i] = (kmp_bar_pat_e)j;
1516 if (j == bp_last_bar) {
1517 __kmp_msg(kmp_ms_warning,
1518 KMP_MSG(BarrReleaseValueInvalid, name, comma + 1),
1520 KMP_INFORM(Using_str_Value, name,
1521 __kmp_barrier_pattern_name[bp_linear_bar]);
1528 static void __kmp_stg_print_barrier_pattern(kmp_str_buf_t *buffer,
1529 char const *name,
void *data) {
1531 for (
int i = bs_plain_barrier; i < bs_last_barrier; i++) {
1532 var = __kmp_barrier_pattern_env_name[i];
1533 if (strcmp(var, name) == 0) {
1534 int j = __kmp_barrier_gather_pattern[i];
1535 int k = __kmp_barrier_release_pattern[i];
1536 if (__kmp_env_format) {
1537 KMP_STR_BUF_PRINT_NAME_EX(__kmp_barrier_pattern_env_name[i]);
1539 __kmp_str_buf_print(buffer,
" %s='",
1540 __kmp_barrier_pattern_env_name[i]);
1542 __kmp_str_buf_print(buffer,
"%s,%s'\n", __kmp_barrier_pattern_name[j],
1543 __kmp_barrier_pattern_name[k]);
1551 static void __kmp_stg_parse_abort_delay(
char const *name,
char const *value,
1555 int delay = __kmp_abort_delay / 1000;
1556 __kmp_stg_parse_int(name, value, 0, INT_MAX / 1000, &delay);
1557 __kmp_abort_delay = delay * 1000;
1560 static void __kmp_stg_print_abort_delay(kmp_str_buf_t *buffer,
char const *name,
1562 __kmp_stg_print_int(buffer, name, __kmp_abort_delay);
1568 static void __kmp_stg_parse_cpuinfo_file(
char const *name,
char const *value,
1570 #if KMP_AFFINITY_SUPPORTED 1571 __kmp_stg_parse_str(name, value, &__kmp_cpuinfo_file);
1572 K_DIAG(1, (
"__kmp_cpuinfo_file == %s\n", __kmp_cpuinfo_file));
1576 static void __kmp_stg_print_cpuinfo_file(kmp_str_buf_t *buffer,
1577 char const *name,
void *data) {
1578 #if KMP_AFFINITY_SUPPORTED 1579 if (__kmp_env_format) {
1580 KMP_STR_BUF_PRINT_NAME;
1582 __kmp_str_buf_print(buffer,
" %s", name);
1584 if (__kmp_cpuinfo_file) {
1585 __kmp_str_buf_print(buffer,
"='%s'\n", __kmp_cpuinfo_file);
1587 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
1595 static void __kmp_stg_parse_force_reduction(
char const *name,
char const *value,
1597 kmp_stg_fr_data_t *reduction = (kmp_stg_fr_data_t *)data;
1600 rc = __kmp_stg_check_rivals(name, value, reduction->rivals);
1604 if (reduction->force) {
1606 if (__kmp_str_match(
"critical", 0, value))
1607 __kmp_force_reduction_method = critical_reduce_block;
1608 else if (__kmp_str_match(
"atomic", 0, value))
1609 __kmp_force_reduction_method = atomic_reduce_block;
1610 else if (__kmp_str_match(
"tree", 0, value))
1611 __kmp_force_reduction_method = tree_reduce_block;
1613 KMP_FATAL(UnknownForceReduction, name, value);
1617 __kmp_stg_parse_bool(name, value, &__kmp_determ_red);
1618 if (__kmp_determ_red) {
1619 __kmp_force_reduction_method = tree_reduce_block;
1621 __kmp_force_reduction_method = reduction_method_not_defined;
1624 K_DIAG(1, (
"__kmp_force_reduction_method == %d\n",
1625 __kmp_force_reduction_method));
1628 static void __kmp_stg_print_force_reduction(kmp_str_buf_t *buffer,
1629 char const *name,
void *data) {
1631 kmp_stg_fr_data_t *reduction = (kmp_stg_fr_data_t *)data;
1632 if (reduction->force) {
1633 if (__kmp_force_reduction_method == critical_reduce_block) {
1634 __kmp_stg_print_str(buffer, name,
"critical");
1635 }
else if (__kmp_force_reduction_method == atomic_reduce_block) {
1636 __kmp_stg_print_str(buffer, name,
"atomic");
1637 }
else if (__kmp_force_reduction_method == tree_reduce_block) {
1638 __kmp_stg_print_str(buffer, name,
"tree");
1640 if (__kmp_env_format) {
1641 KMP_STR_BUF_PRINT_NAME;
1643 __kmp_str_buf_print(buffer,
" %s", name);
1645 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
1648 __kmp_stg_print_bool(buffer, name, __kmp_determ_red);
1656 static void __kmp_stg_parse_storage_map(
char const *name,
char const *value,
1658 if (__kmp_str_match(
"verbose", 1, value)) {
1659 __kmp_storage_map = TRUE;
1660 __kmp_storage_map_verbose = TRUE;
1661 __kmp_storage_map_verbose_specified = TRUE;
1664 __kmp_storage_map_verbose = FALSE;
1665 __kmp_stg_parse_bool(name, value, &__kmp_storage_map);
1669 static void __kmp_stg_print_storage_map(kmp_str_buf_t *buffer,
char const *name,
1671 if (__kmp_storage_map_verbose || __kmp_storage_map_verbose_specified) {
1672 __kmp_stg_print_str(buffer, name,
"verbose");
1674 __kmp_stg_print_bool(buffer, name, __kmp_storage_map);
1681 static void __kmp_stg_parse_all_threadprivate(
char const *name,
1682 char const *value,
void *data) {
1683 __kmp_stg_parse_int(name, value,
1684 __kmp_allThreadsSpecified ? __kmp_max_nth : 1,
1685 __kmp_max_nth, &__kmp_tp_capacity);
1688 static void __kmp_stg_print_all_threadprivate(kmp_str_buf_t *buffer,
1689 char const *name,
void *data) {
1690 __kmp_stg_print_int(buffer, name, __kmp_tp_capacity);
1696 static void __kmp_stg_parse_foreign_threads_threadprivate(
char const *name,
1699 __kmp_stg_parse_bool(name, value, &__kmp_foreign_tp);
1702 static void __kmp_stg_print_foreign_threads_threadprivate(kmp_str_buf_t *buffer,
1705 __kmp_stg_print_bool(buffer, name, __kmp_foreign_tp);
1711 #if KMP_AFFINITY_SUPPORTED 1713 static int __kmp_parse_affinity_proc_id_list(
const char *var,
const char *env,
1714 const char **nextEnv,
1716 const char *scan = env;
1717 const char *next = scan;
1723 int start, end, stride;
1727 if (*next ==
'\0') {
1738 if ((*next <
'0') || (*next >
'9')) {
1739 KMP_WARNING(AffSyntaxError, var);
1743 num = __kmp_str_to_int(scan, *next);
1744 KMP_ASSERT(num >= 0);
1762 if ((*next <
'0') || (*next >
'9')) {
1763 KMP_WARNING(AffSyntaxError, var);
1768 num = __kmp_str_to_int(scan, *next);
1769 KMP_ASSERT(num >= 0);
1782 if ((*next <
'0') || (*next >
'9')) {
1784 KMP_WARNING(AffSyntaxError, var);
1792 start = __kmp_str_to_int(scan, *next);
1793 KMP_ASSERT(start >= 0);
1812 if ((*next <
'0') || (*next >
'9')) {
1813 KMP_WARNING(AffSyntaxError, var);
1817 end = __kmp_str_to_int(scan, *next);
1818 KMP_ASSERT(end >= 0);
1835 if ((*next <
'0') || (*next >
'9')) {
1836 KMP_WARNING(AffSyntaxError, var);
1840 stride = __kmp_str_to_int(scan, *next);
1841 KMP_ASSERT(stride >= 0);
1847 KMP_WARNING(AffZeroStride, var);
1852 KMP_WARNING(AffStartGreaterEnd, var, start, end);
1857 KMP_WARNING(AffStrideLessZero, var, start, end);
1861 if ((end - start) / stride > 65536) {
1862 KMP_WARNING(AffRangeTooBig, var, end, start, stride);
1879 int len = next - env;
1880 char *retlist = (
char *)__kmp_allocate((len + 1) *
sizeof(char));
1881 KMP_MEMCPY_S(retlist, (len + 1) *
sizeof(
char), env, len *
sizeof(
char));
1882 retlist[len] =
'\0';
1883 *proclist = retlist;
1890 static kmp_setting_t *__kmp_affinity_notype = NULL;
1892 static void __kmp_parse_affinity_env(
char const *name,
char const *value,
1893 enum affinity_type *out_type,
1894 char **out_proclist,
int *out_verbose,
1895 int *out_warn,
int *out_respect,
1896 enum affinity_gran *out_gran,
1897 int *out_gran_levels,
int *out_dups,
1898 int *out_compact,
int *out_offset) {
1899 char *buffer = NULL;
1909 int max_proclist = 0;
1916 KMP_ASSERT(value != NULL);
1918 if (TCR_4(__kmp_init_middle)) {
1919 KMP_WARNING(EnvMiddleWarn, name);
1920 __kmp_env_toPrint(name, 0);
1923 __kmp_env_toPrint(name, 1);
1926 __kmp_str_format(
"%s", value);
1936 #define EMIT_WARN(skip, errlist) \ 1940 SKIP_TO(next, ','); \ 1944 KMP_WARNING errlist; \ 1953 #define _set_param(_guard, _var, _val) \ 1955 if (_guard == 0) { \ 1958 EMIT_WARN(FALSE, (AffParamDefined, name, start)); \ 1963 #define set_type(val) _set_param(type, *out_type, val) 1964 #define set_verbose(val) _set_param(verbose, *out_verbose, val) 1965 #define set_warnings(val) _set_param(warnings, *out_warn, val) 1966 #define set_respect(val) _set_param(respect, *out_respect, val) 1967 #define set_dups(val) _set_param(dups, *out_dups, val) 1968 #define set_proclist(val) _set_param(proclist, *out_proclist, val) 1970 #define set_gran(val, levels) \ 1974 *out_gran_levels = levels; \ 1976 EMIT_WARN(FALSE, (AffParamDefined, name, start)); \ 1982 KMP_DEBUG_ASSERT((__kmp_nested_proc_bind.bind_types != NULL) &&
1983 (__kmp_nested_proc_bind.used > 0));
1986 while (*buf !=
'\0') {
1989 if (__kmp_match_str(
"none", buf, CCAST(
const char **, &next))) {
1990 set_type(affinity_none);
1992 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
1995 }
else if (__kmp_match_str(
"scatter", buf, CCAST(
const char **, &next))) {
1996 set_type(affinity_scatter);
1998 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2001 }
else if (__kmp_match_str(
"compact", buf, CCAST(
const char **, &next))) {
2002 set_type(affinity_compact);
2004 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2007 }
else if (__kmp_match_str(
"logical", buf, CCAST(
const char **, &next))) {
2008 set_type(affinity_logical);
2010 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2013 }
else if (__kmp_match_str(
"physical", buf, CCAST(
const char **, &next))) {
2014 set_type(affinity_physical);
2016 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2019 }
else if (__kmp_match_str(
"explicit", buf, CCAST(
const char **, &next))) {
2020 set_type(affinity_explicit);
2022 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2025 }
else if (__kmp_match_str(
"balanced", buf, CCAST(
const char **, &next))) {
2026 set_type(affinity_balanced);
2028 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2031 }
else if (__kmp_match_str(
"disabled", buf, CCAST(
const char **, &next))) {
2032 set_type(affinity_disabled);
2034 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
2037 }
else if (__kmp_match_str(
"verbose", buf, CCAST(
const char **, &next))) {
2040 }
else if (__kmp_match_str(
"noverbose", buf, CCAST(
const char **, &next))) {
2043 }
else if (__kmp_match_str(
"warnings", buf, CCAST(
const char **, &next))) {
2046 }
else if (__kmp_match_str(
"nowarnings", buf,
2047 CCAST(
const char **, &next))) {
2048 set_warnings(FALSE);
2050 }
else if (__kmp_match_str(
"respect", buf, CCAST(
const char **, &next))) {
2053 }
else if (__kmp_match_str(
"norespect", buf, CCAST(
const char **, &next))) {
2056 }
else if (__kmp_match_str(
"duplicates", buf,
2057 CCAST(
const char **, &next)) ||
2058 __kmp_match_str(
"dups", buf, CCAST(
const char **, &next))) {
2061 }
else if (__kmp_match_str(
"noduplicates", buf,
2062 CCAST(
const char **, &next)) ||
2063 __kmp_match_str(
"nodups", buf, CCAST(
const char **, &next))) {
2066 }
else if (__kmp_match_str(
"granularity", buf,
2067 CCAST(
const char **, &next)) ||
2068 __kmp_match_str(
"gran", buf, CCAST(
const char **, &next))) {
2071 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2078 if (__kmp_match_str(
"fine", buf, CCAST(
const char **, &next))) {
2079 set_gran(affinity_gran_fine, -1);
2081 }
else if (__kmp_match_str(
"thread", buf, CCAST(
const char **, &next))) {
2082 set_gran(affinity_gran_thread, -1);
2084 }
else if (__kmp_match_str(
"core", buf, CCAST(
const char **, &next))) {
2085 set_gran(affinity_gran_core, -1);
2088 }
else if (__kmp_match_str(
"tile", buf, CCAST(
const char **, &next))) {
2089 set_gran(affinity_gran_tile, -1);
2092 }
else if (__kmp_match_str(
"package", buf, CCAST(
const char **, &next))) {
2093 set_gran(affinity_gran_package, -1);
2095 }
else if (__kmp_match_str(
"node", buf, CCAST(
const char **, &next))) {
2096 set_gran(affinity_gran_node, -1);
2098 #if KMP_GROUP_AFFINITY 2099 }
else if (__kmp_match_str(
"group", buf, CCAST(
const char **, &next))) {
2100 set_gran(affinity_gran_group, -1);
2103 }
else if ((*buf >=
'0') && (*buf <=
'9')) {
2107 n = __kmp_str_to_int(buf, *next);
2110 set_gran(affinity_gran_default, n);
2112 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2115 }
else if (__kmp_match_str(
"proclist", buf, CCAST(
const char **, &next))) {
2116 char *temp_proclist;
2120 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2126 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2131 if (!__kmp_parse_affinity_proc_id_list(
2132 name, buf, CCAST(
const char **, &next), &temp_proclist)) {
2144 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2148 set_proclist(temp_proclist);
2149 }
else if ((*buf >=
'0') && (*buf <=
'9')) {
2154 n = __kmp_str_to_int(buf, *next);
2160 KMP_WARNING(AffManyParams, name, start);
2164 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2172 }
else if (*next !=
'\0') {
2173 const char *temp = next;
2174 EMIT_WARN(TRUE, (ParseExtraCharsWarn, name, temp));
2186 #undef set_granularity 2188 __kmp_str_free(&buffer);
2192 KMP_WARNING(AffProcListNoType, name);
2193 *out_type = affinity_explicit;
2195 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2197 }
else if (*out_type != affinity_explicit) {
2198 KMP_WARNING(AffProcListNotExplicit, name);
2199 KMP_ASSERT(*out_proclist != NULL);
2200 KMP_INTERNAL_FREE(*out_proclist);
2201 *out_proclist = NULL;
2204 switch (*out_type) {
2205 case affinity_logical:
2206 case affinity_physical: {
2208 *out_offset = number[0];
2211 KMP_WARNING(AffManyParamsForLogic, name, number[1]);
2214 case affinity_balanced: {
2216 *out_compact = number[0];
2219 *out_offset = number[1];
2222 if (__kmp_affinity_gran == affinity_gran_default) {
2223 #if KMP_MIC_SUPPORTED 2224 if (__kmp_mic_type != non_mic) {
2225 if (__kmp_affinity_verbose || __kmp_affinity_warnings) {
2226 KMP_WARNING(AffGranUsing,
"KMP_AFFINITY",
"fine");
2228 __kmp_affinity_gran = affinity_gran_fine;
2232 if (__kmp_affinity_verbose || __kmp_affinity_warnings) {
2233 KMP_WARNING(AffGranUsing,
"KMP_AFFINITY",
"core");
2235 __kmp_affinity_gran = affinity_gran_core;
2239 case affinity_scatter:
2240 case affinity_compact: {
2242 *out_compact = number[0];
2245 *out_offset = number[1];
2248 case affinity_explicit: {
2249 if (*out_proclist == NULL) {
2250 KMP_WARNING(AffNoProcList, name);
2251 __kmp_affinity_type = affinity_none;
2254 KMP_WARNING(AffNoParam, name,
"explicit");
2257 case affinity_none: {
2259 KMP_WARNING(AffNoParam, name,
"none");
2262 case affinity_disabled: {
2264 KMP_WARNING(AffNoParam, name,
"disabled");
2267 case affinity_default: {
2269 KMP_WARNING(AffNoParam, name,
"default");
2272 default: { KMP_ASSERT(0); }
2276 static void __kmp_stg_parse_affinity(
char const *name,
char const *value,
2278 kmp_setting_t **rivals = (kmp_setting_t **)data;
2281 rc = __kmp_stg_check_rivals(name, value, rivals);
2286 __kmp_parse_affinity_env(name, value, &__kmp_affinity_type,
2287 &__kmp_affinity_proclist, &__kmp_affinity_verbose,
2288 &__kmp_affinity_warnings,
2289 &__kmp_affinity_respect_mask, &__kmp_affinity_gran,
2290 &__kmp_affinity_gran_levels, &__kmp_affinity_dups,
2291 &__kmp_affinity_compact, &__kmp_affinity_offset);
2295 static void __kmp_stg_print_affinity(kmp_str_buf_t *buffer,
char const *name,
2297 if (__kmp_env_format) {
2298 KMP_STR_BUF_PRINT_NAME_EX(name);
2300 __kmp_str_buf_print(buffer,
" %s='", name);
2302 if (__kmp_affinity_verbose) {
2303 __kmp_str_buf_print(buffer,
"%s,",
"verbose");
2305 __kmp_str_buf_print(buffer,
"%s,",
"noverbose");
2307 if (__kmp_affinity_warnings) {
2308 __kmp_str_buf_print(buffer,
"%s,",
"warnings");
2310 __kmp_str_buf_print(buffer,
"%s,",
"nowarnings");
2312 if (KMP_AFFINITY_CAPABLE()) {
2313 if (__kmp_affinity_respect_mask) {
2314 __kmp_str_buf_print(buffer,
"%s,",
"respect");
2316 __kmp_str_buf_print(buffer,
"%s,",
"norespect");
2318 switch (__kmp_affinity_gran) {
2319 case affinity_gran_default:
2320 __kmp_str_buf_print(buffer,
"%s",
"granularity=default,");
2322 case affinity_gran_fine:
2323 __kmp_str_buf_print(buffer,
"%s",
"granularity=fine,");
2325 case affinity_gran_thread:
2326 __kmp_str_buf_print(buffer,
"%s",
"granularity=thread,");
2328 case affinity_gran_core:
2329 __kmp_str_buf_print(buffer,
"%s",
"granularity=core,");
2331 case affinity_gran_package:
2332 __kmp_str_buf_print(buffer,
"%s",
"granularity=package,");
2334 case affinity_gran_node:
2335 __kmp_str_buf_print(buffer,
"%s",
"granularity=node,");
2337 #if KMP_GROUP_AFFINITY 2338 case affinity_gran_group:
2339 __kmp_str_buf_print(buffer,
"%s",
"granularity=group,");
2344 if (!KMP_AFFINITY_CAPABLE()) {
2345 __kmp_str_buf_print(buffer,
"%s",
"disabled");
2347 switch (__kmp_affinity_type) {
2349 __kmp_str_buf_print(buffer,
"%s",
"none");
2351 case affinity_physical:
2352 __kmp_str_buf_print(buffer,
"%s,%d",
"physical", __kmp_affinity_offset);
2354 case affinity_logical:
2355 __kmp_str_buf_print(buffer,
"%s,%d",
"logical", __kmp_affinity_offset);
2357 case affinity_compact:
2358 __kmp_str_buf_print(buffer,
"%s,%d,%d",
"compact", __kmp_affinity_compact,
2359 __kmp_affinity_offset);
2361 case affinity_scatter:
2362 __kmp_str_buf_print(buffer,
"%s,%d,%d",
"scatter", __kmp_affinity_compact,
2363 __kmp_affinity_offset);
2365 case affinity_explicit:
2366 __kmp_str_buf_print(buffer,
"%s=[%s],%s",
"proclist",
2367 __kmp_affinity_proclist,
"explicit");
2369 case affinity_balanced:
2370 __kmp_str_buf_print(buffer,
"%s,%d,%d",
"balanced",
2371 __kmp_affinity_compact, __kmp_affinity_offset);
2373 case affinity_disabled:
2374 __kmp_str_buf_print(buffer,
"%s",
"disabled");
2376 case affinity_default:
2377 __kmp_str_buf_print(buffer,
"%s",
"default");
2380 __kmp_str_buf_print(buffer,
"%s",
"<unknown>");
2383 __kmp_str_buf_print(buffer,
"'\n");
2386 #ifdef KMP_GOMP_COMPAT 2388 static void __kmp_stg_parse_gomp_cpu_affinity(
char const *name,
2389 char const *value,
void *data) {
2390 const char *next = NULL;
2391 char *temp_proclist;
2392 kmp_setting_t **rivals = (kmp_setting_t **)data;
2395 rc = __kmp_stg_check_rivals(name, value, rivals);
2400 if (TCR_4(__kmp_init_middle)) {
2401 KMP_WARNING(EnvMiddleWarn, name);
2402 __kmp_env_toPrint(name, 0);
2406 __kmp_env_toPrint(name, 1);
2408 if (__kmp_parse_affinity_proc_id_list(name, value, &next, &temp_proclist)) {
2410 if (*next ==
'\0') {
2412 __kmp_affinity_proclist = temp_proclist;
2413 __kmp_affinity_type = affinity_explicit;
2414 __kmp_affinity_gran = affinity_gran_fine;
2416 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2419 KMP_WARNING(AffSyntaxError, name);
2420 if (temp_proclist != NULL) {
2421 KMP_INTERNAL_FREE((
void *)temp_proclist);
2426 __kmp_affinity_type = affinity_none;
2428 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
2457 static int __kmp_parse_subplace_list(
const char *var,
const char **scan) {
2461 int start, count, stride;
2467 if ((**scan <
'0') || (**scan >
'9')) {
2468 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2473 start = __kmp_str_to_int(*scan, *next);
2474 KMP_ASSERT(start >= 0);
2479 if (**scan ==
'}') {
2482 if (**scan ==
',') {
2486 if (**scan !=
':') {
2487 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2494 if ((**scan <
'0') || (**scan >
'9')) {
2495 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2500 count = __kmp_str_to_int(*scan, *next);
2501 KMP_ASSERT(count >= 0);
2506 if (**scan ==
'}') {
2509 if (**scan ==
',') {
2513 if (**scan !=
':') {
2514 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2523 if (**scan ==
'+') {
2527 if (**scan ==
'-') {
2535 if ((**scan <
'0') || (**scan >
'9')) {
2536 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2541 stride = __kmp_str_to_int(*scan, *next);
2542 KMP_ASSERT(stride >= 0);
2548 if (**scan ==
'}') {
2551 if (**scan ==
',') {
2556 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2562 static int __kmp_parse_place(
const char *var,
const char **scan) {
2567 if (**scan ==
'{') {
2569 if (!__kmp_parse_subplace_list(var, scan)) {
2572 if (**scan !=
'}') {
2573 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2577 }
else if (**scan ==
'!') {
2579 return __kmp_parse_place(var, scan);
2580 }
else if ((**scan >=
'0') && (**scan <=
'9')) {
2583 int proc = __kmp_str_to_int(*scan, *next);
2584 KMP_ASSERT(proc >= 0);
2587 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2593 static int __kmp_parse_place_list(
const char *var,
const char *env,
2594 char **place_list) {
2595 const char *scan = env;
2596 const char *next = scan;
2599 int start, count, stride;
2601 if (!__kmp_parse_place(var, &scan)) {
2607 if (*scan ==
'\0') {
2615 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2622 if ((*scan <
'0') || (*scan >
'9')) {
2623 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2628 count = __kmp_str_to_int(scan, *next);
2629 KMP_ASSERT(count >= 0);
2634 if (*scan ==
'\0') {
2642 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2663 if ((*scan <
'0') || (*scan >
'9')) {
2664 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2669 stride = __kmp_str_to_int(scan, *next);
2670 KMP_ASSERT(stride >= 0);
2676 if (*scan ==
'\0') {
2684 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2689 int len = scan - env;
2690 char *retlist = (
char *)__kmp_allocate((len + 1) *
sizeof(char));
2691 KMP_MEMCPY_S(retlist, (len + 1) *
sizeof(
char), env, len *
sizeof(
char));
2692 retlist[len] =
'\0';
2693 *place_list = retlist;
2698 static void __kmp_stg_parse_places(
char const *name,
char const *value,
2701 const char *scan = value;
2702 const char *next = scan;
2703 const char *kind =
"\"threads\"";
2704 kmp_setting_t **rivals = (kmp_setting_t **)data;
2707 rc = __kmp_stg_check_rivals(name, value, rivals);
2714 if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_default) {
2715 __kmp_nested_proc_bind.bind_types[0] = proc_bind_true;
2720 if (__kmp_match_str(
"threads", scan, &next)) {
2722 __kmp_affinity_type = affinity_compact;
2723 __kmp_affinity_gran = affinity_gran_thread;
2724 __kmp_affinity_dups = FALSE;
2725 kind =
"\"threads\"";
2726 }
else if (__kmp_match_str(
"cores", scan, &next)) {
2728 __kmp_affinity_type = affinity_compact;
2729 __kmp_affinity_gran = affinity_gran_core;
2730 __kmp_affinity_dups = FALSE;
2733 }
else if (__kmp_match_str(
"tiles", scan, &next)) {
2735 __kmp_affinity_type = affinity_compact;
2736 __kmp_affinity_gran = affinity_gran_tile;
2737 __kmp_affinity_dups = FALSE;
2740 }
else if (__kmp_match_str(
"sockets", scan, &next)) {
2742 __kmp_affinity_type = affinity_compact;
2743 __kmp_affinity_gran = affinity_gran_package;
2744 __kmp_affinity_dups = FALSE;
2745 kind =
"\"sockets\"";
2747 if (__kmp_affinity_proclist != NULL) {
2748 KMP_INTERNAL_FREE((
void *)__kmp_affinity_proclist);
2749 __kmp_affinity_proclist = NULL;
2751 if (__kmp_parse_place_list(name, value, &__kmp_affinity_proclist)) {
2752 __kmp_affinity_type = affinity_explicit;
2753 __kmp_affinity_gran = affinity_gran_fine;
2754 __kmp_affinity_dups = FALSE;
2755 if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_default) {
2756 __kmp_nested_proc_bind.bind_types[0] = proc_bind_true;
2762 if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_default) {
2763 __kmp_nested_proc_bind.bind_types[0] = proc_bind_true;
2767 if (*scan ==
'\0') {
2773 KMP_WARNING(SyntaxErrorUsing, name, kind);
2781 count = __kmp_str_to_int(scan, *next);
2782 KMP_ASSERT(count >= 0);
2787 KMP_WARNING(SyntaxErrorUsing, name, kind);
2793 if (*scan !=
'\0') {
2794 KMP_WARNING(ParseExtraCharsWarn, name, scan);
2796 __kmp_affinity_num_places = count;
2799 static void __kmp_stg_print_places(kmp_str_buf_t *buffer,
char const *name,
2801 if (__kmp_env_format) {
2802 KMP_STR_BUF_PRINT_NAME;
2804 __kmp_str_buf_print(buffer,
" %s", name);
2806 if ((__kmp_nested_proc_bind.used == 0) ||
2807 (__kmp_nested_proc_bind.bind_types == NULL) ||
2808 (__kmp_nested_proc_bind.bind_types[0] == proc_bind_false)) {
2809 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
2810 }
else if (__kmp_affinity_type == affinity_explicit) {
2811 if (__kmp_affinity_proclist != NULL) {
2812 __kmp_str_buf_print(buffer,
"='%s'\n", __kmp_affinity_proclist);
2814 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
2816 }
else if (__kmp_affinity_type == affinity_compact) {
2818 if (__kmp_affinity_num_masks > 0) {
2819 num = __kmp_affinity_num_masks;
2820 }
else if (__kmp_affinity_num_places > 0) {
2821 num = __kmp_affinity_num_places;
2825 if (__kmp_affinity_gran == affinity_gran_thread) {
2827 __kmp_str_buf_print(buffer,
"='threads(%d)'\n", num);
2829 __kmp_str_buf_print(buffer,
"='threads'\n");
2831 }
else if (__kmp_affinity_gran == affinity_gran_core) {
2833 __kmp_str_buf_print(buffer,
"='cores(%d)' \n", num);
2835 __kmp_str_buf_print(buffer,
"='cores'\n");
2838 }
else if (__kmp_affinity_gran == affinity_gran_tile) {
2840 __kmp_str_buf_print(buffer,
"='tiles(%d)' \n", num);
2842 __kmp_str_buf_print(buffer,
"='tiles'\n");
2845 }
else if (__kmp_affinity_gran == affinity_gran_package) {
2847 __kmp_str_buf_print(buffer,
"='sockets(%d)'\n", num);
2849 __kmp_str_buf_print(buffer,
"='sockets'\n");
2852 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
2855 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
2861 #if (!OMP_40_ENABLED) 2863 static void __kmp_stg_parse_proc_bind(
char const *name,
char const *value,
2866 kmp_setting_t **rivals = (kmp_setting_t **)data;
2869 rc = __kmp_stg_check_rivals(name, value, rivals);
2875 __kmp_stg_parse_bool(name, value, &enabled);
2879 __kmp_affinity_type = affinity_scatter;
2880 #if KMP_MIC_SUPPORTED 2881 if (__kmp_mic_type != non_mic)
2882 __kmp_affinity_gran = affinity_gran_fine;
2885 __kmp_affinity_gran = affinity_gran_core;
2887 __kmp_affinity_type = affinity_none;
2893 static void __kmp_stg_parse_topology_method(
char const *name,
char const *value,
2895 if (__kmp_str_match(
"all", 1, value)) {
2896 __kmp_affinity_top_method = affinity_top_method_all;
2899 else if (__kmp_str_match(
"hwloc", 1, value)) {
2900 __kmp_affinity_top_method = affinity_top_method_hwloc;
2903 #if KMP_ARCH_X86 || KMP_ARCH_X86_64 2904 else if (__kmp_str_match(
"x2apic id", 9, value) ||
2905 __kmp_str_match(
"x2apic_id", 9, value) ||
2906 __kmp_str_match(
"x2apic-id", 9, value) ||
2907 __kmp_str_match(
"x2apicid", 8, value) ||
2908 __kmp_str_match(
"cpuid leaf 11", 13, value) ||
2909 __kmp_str_match(
"cpuid_leaf_11", 13, value) ||
2910 __kmp_str_match(
"cpuid-leaf-11", 13, value) ||
2911 __kmp_str_match(
"cpuid leaf11", 12, value) ||
2912 __kmp_str_match(
"cpuid_leaf11", 12, value) ||
2913 __kmp_str_match(
"cpuid-leaf11", 12, value) ||
2914 __kmp_str_match(
"cpuidleaf 11", 12, value) ||
2915 __kmp_str_match(
"cpuidleaf_11", 12, value) ||
2916 __kmp_str_match(
"cpuidleaf-11", 12, value) ||
2917 __kmp_str_match(
"cpuidleaf11", 11, value) ||
2918 __kmp_str_match(
"cpuid 11", 8, value) ||
2919 __kmp_str_match(
"cpuid_11", 8, value) ||
2920 __kmp_str_match(
"cpuid-11", 8, value) ||
2921 __kmp_str_match(
"cpuid11", 7, value) ||
2922 __kmp_str_match(
"leaf 11", 7, value) ||
2923 __kmp_str_match(
"leaf_11", 7, value) ||
2924 __kmp_str_match(
"leaf-11", 7, value) ||
2925 __kmp_str_match(
"leaf11", 6, value)) {
2926 __kmp_affinity_top_method = affinity_top_method_x2apicid;
2927 }
else if (__kmp_str_match(
"apic id", 7, value) ||
2928 __kmp_str_match(
"apic_id", 7, value) ||
2929 __kmp_str_match(
"apic-id", 7, value) ||
2930 __kmp_str_match(
"apicid", 6, value) ||
2931 __kmp_str_match(
"cpuid leaf 4", 12, value) ||
2932 __kmp_str_match(
"cpuid_leaf_4", 12, value) ||
2933 __kmp_str_match(
"cpuid-leaf-4", 12, value) ||
2934 __kmp_str_match(
"cpuid leaf4", 11, value) ||
2935 __kmp_str_match(
"cpuid_leaf4", 11, value) ||
2936 __kmp_str_match(
"cpuid-leaf4", 11, value) ||
2937 __kmp_str_match(
"cpuidleaf 4", 11, value) ||
2938 __kmp_str_match(
"cpuidleaf_4", 11, value) ||
2939 __kmp_str_match(
"cpuidleaf-4", 11, value) ||
2940 __kmp_str_match(
"cpuidleaf4", 10, value) ||
2941 __kmp_str_match(
"cpuid 4", 7, value) ||
2942 __kmp_str_match(
"cpuid_4", 7, value) ||
2943 __kmp_str_match(
"cpuid-4", 7, value) ||
2944 __kmp_str_match(
"cpuid4", 6, value) ||
2945 __kmp_str_match(
"leaf 4", 6, value) ||
2946 __kmp_str_match(
"leaf_4", 6, value) ||
2947 __kmp_str_match(
"leaf-4", 6, value) ||
2948 __kmp_str_match(
"leaf4", 5, value)) {
2949 __kmp_affinity_top_method = affinity_top_method_apicid;
2952 else if (__kmp_str_match(
"/proc/cpuinfo", 2, value) ||
2953 __kmp_str_match(
"cpuinfo", 5, value)) {
2954 __kmp_affinity_top_method = affinity_top_method_cpuinfo;
2956 #if KMP_GROUP_AFFINITY 2957 else if (__kmp_str_match(
"group", 1, value)) {
2958 __kmp_affinity_top_method = affinity_top_method_group;
2961 else if (__kmp_str_match(
"flat", 1, value)) {
2962 __kmp_affinity_top_method = affinity_top_method_flat;
2964 KMP_WARNING(StgInvalidValue, name, value);
2968 static void __kmp_stg_print_topology_method(kmp_str_buf_t *buffer,
2969 char const *name,
void *data) {
2970 char const *value = NULL;
2972 switch (__kmp_affinity_top_method) {
2973 case affinity_top_method_default:
2977 case affinity_top_method_all:
2981 #if KMP_ARCH_X86 || KMP_ARCH_X86_64 2982 case affinity_top_method_x2apicid:
2983 value =
"x2APIC id";
2986 case affinity_top_method_apicid:
2992 case affinity_top_method_hwloc:
2997 case affinity_top_method_cpuinfo:
3001 #if KMP_GROUP_AFFINITY 3002 case affinity_top_method_group:
3007 case affinity_top_method_flat:
3012 if (value != NULL) {
3013 __kmp_stg_print_str(buffer, name, value);
3023 static void __kmp_stg_parse_proc_bind(
char const *name,
char const *value,
3025 kmp_setting_t **rivals = (kmp_setting_t **)data;
3028 rc = __kmp_stg_check_rivals(name, value, rivals);
3034 KMP_DEBUG_ASSERT((__kmp_nested_proc_bind.bind_types != NULL) &&
3035 (__kmp_nested_proc_bind.used > 0));
3037 const char *buf = value;
3041 if ((*buf >=
'0') && (*buf <=
'9')) {
3044 num = __kmp_str_to_int(buf, *next);
3045 KMP_ASSERT(num >= 0);
3053 if (__kmp_match_str(
"disabled", buf, &next)) {
3056 #if KMP_AFFINITY_SUPPORTED 3057 __kmp_affinity_type = affinity_disabled;
3059 __kmp_nested_proc_bind.used = 1;
3060 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
3061 }
else if ((num == (
int)proc_bind_false) ||
3062 __kmp_match_str(
"false", buf, &next)) {
3065 #if KMP_AFFINITY_SUPPORTED 3066 __kmp_affinity_type = affinity_none;
3068 __kmp_nested_proc_bind.used = 1;
3069 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
3070 }
else if ((num == (
int)proc_bind_true) ||
3071 __kmp_match_str(
"true", buf, &next)) {
3074 __kmp_nested_proc_bind.used = 1;
3075 __kmp_nested_proc_bind.bind_types[0] = proc_bind_true;
3080 for (scan = buf; *scan !=
'\0'; scan++) {
3087 if (__kmp_nested_proc_bind.size < nelem) {
3088 __kmp_nested_proc_bind.bind_types =
3089 (kmp_proc_bind_t *)KMP_INTERNAL_REALLOC(
3090 __kmp_nested_proc_bind.bind_types,
3091 sizeof(kmp_proc_bind_t) * nelem);
3092 if (__kmp_nested_proc_bind.bind_types == NULL) {
3093 KMP_FATAL(MemoryAllocFailed);
3095 __kmp_nested_proc_bind.size = nelem;
3097 __kmp_nested_proc_bind.used = nelem;
3102 enum kmp_proc_bind_t bind;
3104 if ((num == (
int)proc_bind_master) ||
3105 __kmp_match_str(
"master", buf, &next)) {
3108 bind = proc_bind_master;
3109 }
else if ((num == (
int)proc_bind_close) ||
3110 __kmp_match_str(
"close", buf, &next)) {
3113 bind = proc_bind_close;
3114 }
else if ((num == (
int)proc_bind_spread) ||
3115 __kmp_match_str(
"spread", buf, &next)) {
3118 bind = proc_bind_spread;
3120 KMP_WARNING(StgInvalidValue, name, value);
3121 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
3122 __kmp_nested_proc_bind.used = 1;
3126 __kmp_nested_proc_bind.bind_types[i++] = bind;
3130 KMP_DEBUG_ASSERT(*buf ==
',');
3135 if ((*buf >=
'0') && (*buf <=
'9')) {
3138 num = __kmp_str_to_int(buf, *next);
3139 KMP_ASSERT(num >= 0);
3149 KMP_WARNING(ParseExtraCharsWarn, name, buf);
3153 static void __kmp_stg_print_proc_bind(kmp_str_buf_t *buffer,
char const *name,
3155 int nelem = __kmp_nested_proc_bind.used;
3156 if (__kmp_env_format) {
3157 KMP_STR_BUF_PRINT_NAME;
3159 __kmp_str_buf_print(buffer,
" %s", name);
3162 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
3165 __kmp_str_buf_print(buffer,
"='", name);
3166 for (i = 0; i < nelem; i++) {
3167 switch (__kmp_nested_proc_bind.bind_types[i]) {
3168 case proc_bind_false:
3169 __kmp_str_buf_print(buffer,
"false");
3172 case proc_bind_true:
3173 __kmp_str_buf_print(buffer,
"true");
3176 case proc_bind_master:
3177 __kmp_str_buf_print(buffer,
"master");
3180 case proc_bind_close:
3181 __kmp_str_buf_print(buffer,
"close");
3184 case proc_bind_spread:
3185 __kmp_str_buf_print(buffer,
"spread");
3188 case proc_bind_intel:
3189 __kmp_str_buf_print(buffer,
"intel");
3192 case proc_bind_default:
3193 __kmp_str_buf_print(buffer,
"default");
3196 if (i < nelem - 1) {
3197 __kmp_str_buf_print(buffer,
",");
3200 __kmp_str_buf_print(buffer,
"'\n");
3209 static void __kmp_stg_parse_omp_dynamic(
char const *name,
char const *value,
3211 __kmp_stg_parse_bool(name, value, &(__kmp_global.g.g_dynamic));
3214 static void __kmp_stg_print_omp_dynamic(kmp_str_buf_t *buffer,
char const *name,
3216 __kmp_stg_print_bool(buffer, name, __kmp_global.g.g_dynamic);
3219 static void __kmp_stg_parse_kmp_dynamic_mode(
char const *name,
3220 char const *value,
void *data) {
3221 if (TCR_4(__kmp_init_parallel)) {
3222 KMP_WARNING(EnvParallelWarn, name);
3223 __kmp_env_toPrint(name, 0);
3226 #ifdef USE_LOAD_BALANCE 3227 else if (__kmp_str_match(
"load balance", 2, value) ||
3228 __kmp_str_match(
"load_balance", 2, value) ||
3229 __kmp_str_match(
"load-balance", 2, value) ||
3230 __kmp_str_match(
"loadbalance", 2, value) ||
3231 __kmp_str_match(
"balance", 1, value)) {
3232 __kmp_global.g.g_dynamic_mode = dynamic_load_balance;
3235 else if (__kmp_str_match(
"thread limit", 1, value) ||
3236 __kmp_str_match(
"thread_limit", 1, value) ||
3237 __kmp_str_match(
"thread-limit", 1, value) ||
3238 __kmp_str_match(
"threadlimit", 1, value) ||
3239 __kmp_str_match(
"limit", 2, value)) {
3240 __kmp_global.g.g_dynamic_mode = dynamic_thread_limit;
3241 }
else if (__kmp_str_match(
"random", 1, value)) {
3242 __kmp_global.g.g_dynamic_mode = dynamic_random;
3244 KMP_WARNING(StgInvalidValue, name, value);
3248 static void __kmp_stg_print_kmp_dynamic_mode(kmp_str_buf_t *buffer,
3249 char const *name,
void *data) {
3251 if (__kmp_global.g.g_dynamic_mode == dynamic_default) {
3252 __kmp_str_buf_print(buffer,
" %s: %s \n", name, KMP_I18N_STR(NotDefined));
3254 #ifdef USE_LOAD_BALANCE 3255 else if (__kmp_global.g.g_dynamic_mode == dynamic_load_balance) {
3256 __kmp_stg_print_str(buffer, name,
"load balance");
3259 else if (__kmp_global.g.g_dynamic_mode == dynamic_thread_limit) {
3260 __kmp_stg_print_str(buffer, name,
"thread limit");
3261 }
else if (__kmp_global.g.g_dynamic_mode == dynamic_random) {
3262 __kmp_stg_print_str(buffer, name,
"random");
3269 #ifdef USE_LOAD_BALANCE 3274 static void __kmp_stg_parse_ld_balance_interval(
char const *name,
3275 char const *value,
void *data) {
3276 double interval = __kmp_convert_to_double(value);
3277 if (interval >= 0) {
3278 __kmp_load_balance_interval = interval;
3280 KMP_WARNING(StgInvalidValue, name, value);
3284 static void __kmp_stg_print_ld_balance_interval(kmp_str_buf_t *buffer,
3285 char const *name,
void *data) {
3287 __kmp_str_buf_print(buffer,
" %s=%8.6f\n", name,
3288 __kmp_load_balance_interval);
3297 static void __kmp_stg_parse_init_at_fork(
char const *name,
char const *value,
3299 __kmp_stg_parse_bool(name, value, &__kmp_need_register_atfork);
3300 if (__kmp_need_register_atfork) {
3301 __kmp_need_register_atfork_specified = TRUE;
3305 static void __kmp_stg_print_init_at_fork(kmp_str_buf_t *buffer,
3306 char const *name,
void *data) {
3307 __kmp_stg_print_bool(buffer, name, __kmp_need_register_atfork_specified);
3313 static void __kmp_stg_parse_schedule(
char const *name,
char const *value,
3316 if (value != NULL) {
3317 size_t length = KMP_STRLEN(value);
3318 if (length > INT_MAX) {
3319 KMP_WARNING(LongValue, name);
3321 const char *semicolon;
3322 if (value[length - 1] ==
'"' || value[length - 1] ==
'\'')
3323 KMP_WARNING(UnbalancedQuotes, name);
3327 semicolon = strchr(value,
';');
3328 if (*value && semicolon != value) {
3329 const char *comma = strchr(value,
',');
3336 if (!__kmp_strcasecmp_with_sentinel(
"static", value, sentinel)) {
3337 if (!__kmp_strcasecmp_with_sentinel(
"greedy", comma,
';')) {
3338 __kmp_static = kmp_sch_static_greedy;
3340 }
else if (!__kmp_strcasecmp_with_sentinel(
"balanced", comma,
3342 __kmp_static = kmp_sch_static_balanced;
3345 }
else if (!__kmp_strcasecmp_with_sentinel(
"guided", value,
3347 if (!__kmp_strcasecmp_with_sentinel(
"iterative", comma,
';')) {
3348 __kmp_guided = kmp_sch_guided_iterative_chunked;
3350 }
else if (!__kmp_strcasecmp_with_sentinel(
"analytical", comma,
3353 __kmp_guided = kmp_sch_guided_analytical_chunked;
3357 KMP_WARNING(InvalidClause, name, value);
3359 KMP_WARNING(EmptyClause, name);
3360 }
while ((value = semicolon ? semicolon + 1 : NULL));
3366 static void __kmp_stg_print_schedule(kmp_str_buf_t *buffer,
char const *name,
3368 if (__kmp_env_format) {
3369 KMP_STR_BUF_PRINT_NAME_EX(name);
3371 __kmp_str_buf_print(buffer,
" %s='", name);
3373 if (__kmp_static == kmp_sch_static_greedy) {
3374 __kmp_str_buf_print(buffer,
"%s",
"static,greedy");
3375 }
else if (__kmp_static == kmp_sch_static_balanced) {
3376 __kmp_str_buf_print(buffer,
"%s",
"static,balanced");
3378 if (__kmp_guided == kmp_sch_guided_iterative_chunked) {
3379 __kmp_str_buf_print(buffer,
";%s'\n",
"guided,iterative");
3380 }
else if (__kmp_guided == kmp_sch_guided_analytical_chunked) {
3381 __kmp_str_buf_print(buffer,
";%s'\n",
"guided,analytical");
3388 static void __kmp_stg_parse_omp_schedule(
char const *name,
char const *value,
3392 length = KMP_STRLEN(value);
3394 const char *comma = strchr(value,
',');
3395 if (value[length - 1] ==
'"' || value[length - 1] ==
'\'')
3396 KMP_WARNING(UnbalancedQuotes, name);
3398 if (!__kmp_strcasecmp_with_sentinel(
"dynamic", value,
','))
3399 __kmp_sched = kmp_sch_dynamic_chunked;
3400 else if (!__kmp_strcasecmp_with_sentinel(
"guided", value,
3405 else if (!__kmp_strcasecmp_with_sentinel(
"auto", value,
',')) {
3408 __kmp_msg(kmp_ms_warning, KMP_MSG(IgnoreChunk, name, comma),
3412 }
else if (!__kmp_strcasecmp_with_sentinel(
"trapezoidal", value,
3414 __kmp_sched = kmp_sch_trapezoidal;
3415 else if (!__kmp_strcasecmp_with_sentinel(
"static", value,
3418 #if KMP_STATIC_STEAL_ENABLED 3419 else if (!__kmp_strcasecmp_with_sentinel(
"static_steal", value,
','))
3420 __kmp_sched = kmp_sch_static_steal;
3423 KMP_WARNING(StgInvalidValue, name, value);
3426 if (value && comma) {
3428 __kmp_sched = kmp_sch_static_chunked;
3430 __kmp_chunk = __kmp_str_to_int(comma, 0);
3431 if (__kmp_chunk < 1) {
3432 __kmp_chunk = KMP_DEFAULT_CHUNK;
3433 __kmp_msg(kmp_ms_warning, KMP_MSG(InvalidChunk, name, comma),
3435 KMP_INFORM(Using_int_Value, name, __kmp_chunk);
3444 }
else if (__kmp_chunk > KMP_MAX_CHUNK) {
3445 __kmp_chunk = KMP_MAX_CHUNK;
3446 __kmp_msg(kmp_ms_warning, KMP_MSG(LargeChunk, name, comma),
3448 KMP_INFORM(Using_int_Value, name, __kmp_chunk);
3452 KMP_WARNING(EmptyString, name);
3454 K_DIAG(1, (
"__kmp_static == %d\n", __kmp_static))
3455 K_DIAG(1, (
"__kmp_guided == %d\n", __kmp_guided))
3456 K_DIAG(1, (
"__kmp_sched == %d\n", __kmp_sched))
3457 K_DIAG(1, (
"__kmp_chunk == %d\n", __kmp_chunk))
3460 static void __kmp_stg_print_omp_schedule(kmp_str_buf_t *buffer,
3461 char const *name,
void *data) {
3462 if (__kmp_env_format) {
3463 KMP_STR_BUF_PRINT_NAME_EX(name);
3465 __kmp_str_buf_print(buffer,
" %s='", name);
3468 switch (__kmp_sched) {
3469 case kmp_sch_dynamic_chunked:
3470 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"dynamic", __kmp_chunk);
3472 case kmp_sch_guided_iterative_chunked:
3473 case kmp_sch_guided_analytical_chunked:
3474 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"guided", __kmp_chunk);
3476 case kmp_sch_trapezoidal:
3477 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"trapezoidal", __kmp_chunk);
3480 case kmp_sch_static_chunked:
3481 case kmp_sch_static_balanced:
3482 case kmp_sch_static_greedy:
3483 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"static", __kmp_chunk);
3485 case kmp_sch_static_steal:
3486 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"static_steal", __kmp_chunk);
3489 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"auto", __kmp_chunk);
3493 switch (__kmp_sched) {
3494 case kmp_sch_dynamic_chunked:
3495 __kmp_str_buf_print(buffer,
"%s'\n",
"dynamic");
3497 case kmp_sch_guided_iterative_chunked:
3498 case kmp_sch_guided_analytical_chunked:
3499 __kmp_str_buf_print(buffer,
"%s'\n",
"guided");
3501 case kmp_sch_trapezoidal:
3502 __kmp_str_buf_print(buffer,
"%s'\n",
"trapezoidal");
3505 case kmp_sch_static_chunked:
3506 case kmp_sch_static_balanced:
3507 case kmp_sch_static_greedy:
3508 __kmp_str_buf_print(buffer,
"%s'\n",
"static");
3510 case kmp_sch_static_steal:
3511 __kmp_str_buf_print(buffer,
"%s'\n",
"static_steal");
3514 __kmp_str_buf_print(buffer,
"%s'\n",
"auto");
3523 static void __kmp_stg_parse_atomic_mode(
char const *name,
char const *value,
3529 #ifdef KMP_GOMP_COMPAT 3532 __kmp_stg_parse_int(name, value, 0, max, &mode);
3537 __kmp_atomic_mode = mode;
3541 static void __kmp_stg_print_atomic_mode(kmp_str_buf_t *buffer,
char const *name,
3543 __kmp_stg_print_int(buffer, name, __kmp_atomic_mode);
3549 static void __kmp_stg_parse_consistency_check(
char const *name,
3550 char const *value,
void *data) {
3551 if (!__kmp_strcasecmp_with_sentinel(
"all", value, 0)) {
3557 __kmp_env_consistency_check = TRUE;
3558 }
else if (!__kmp_strcasecmp_with_sentinel(
"none", value, 0)) {
3559 __kmp_env_consistency_check = FALSE;
3561 KMP_WARNING(StgInvalidValue, name, value);
3565 static void __kmp_stg_print_consistency_check(kmp_str_buf_t *buffer,
3566 char const *name,
void *data) {
3568 const char *value = NULL;
3570 if (__kmp_env_consistency_check) {
3576 if (value != NULL) {
3577 __kmp_stg_print_str(buffer, name, value);
3588 static void __kmp_stg_parse_itt_prepare_delay(
char const *name,
3589 char const *value,
void *data) {
3593 __kmp_stg_parse_int(name, value, 0, INT_MAX, &delay);
3594 __kmp_itt_prepare_delay = delay;
3597 static void __kmp_stg_print_itt_prepare_delay(kmp_str_buf_t *buffer,
3598 char const *name,
void *data) {
3599 __kmp_stg_print_uint64(buffer, name, __kmp_itt_prepare_delay);
3603 #endif // USE_ITT_NOTIFY 3609 static void __kmp_stg_parse_malloc_pool_incr(
char const *name,
3610 char const *value,
void *data) {
3611 __kmp_stg_parse_size(name, value, KMP_MIN_MALLOC_POOL_INCR,
3612 KMP_MAX_MALLOC_POOL_INCR, NULL, &__kmp_malloc_pool_incr,
3616 static void __kmp_stg_print_malloc_pool_incr(kmp_str_buf_t *buffer,
3617 char const *name,
void *data) {
3618 __kmp_stg_print_size(buffer, name, __kmp_malloc_pool_incr);
3627 static void __kmp_stg_parse_par_range_env(
char const *name,
char const *value,
3629 __kmp_stg_parse_par_range(name, value, &__kmp_par_range,
3630 __kmp_par_range_routine, __kmp_par_range_filename,
3631 &__kmp_par_range_lb, &__kmp_par_range_ub);
3634 static void __kmp_stg_print_par_range_env(kmp_str_buf_t *buffer,
3635 char const *name,
void *data) {
3636 if (__kmp_par_range != 0) {
3637 __kmp_stg_print_str(buffer, name, par_range_to_print);
3644 static void __kmp_stg_parse_yield_cycle(
char const *name,
char const *value,
3646 int flag = __kmp_yield_cycle;
3647 __kmp_stg_parse_bool(name, value, &flag);
3648 __kmp_yield_cycle = flag;
3651 static void __kmp_stg_print_yield_cycle(kmp_str_buf_t *buffer,
char const *name,
3653 __kmp_stg_print_bool(buffer, name, __kmp_yield_cycle);
3656 static void __kmp_stg_parse_yield_on(
char const *name,
char const *value,
3658 __kmp_stg_parse_int(name, value, 2, INT_MAX, &__kmp_yield_on_count);
3661 static void __kmp_stg_print_yield_on(kmp_str_buf_t *buffer,
char const *name,
3663 __kmp_stg_print_int(buffer, name, __kmp_yield_on_count);
3666 static void __kmp_stg_parse_yield_off(
char const *name,
char const *value,
3668 __kmp_stg_parse_int(name, value, 2, INT_MAX, &__kmp_yield_off_count);
3671 static void __kmp_stg_print_yield_off(kmp_str_buf_t *buffer,
char const *name,
3673 __kmp_stg_print_int(buffer, name, __kmp_yield_off_count);
3681 static void __kmp_stg_parse_init_wait(
char const *name,
char const *value,
3684 KMP_ASSERT((__kmp_init_wait & 1) == 0);
3685 wait = __kmp_init_wait / 2;
3686 __kmp_stg_parse_int(name, value, KMP_MIN_INIT_WAIT, KMP_MAX_INIT_WAIT, &wait);
3687 __kmp_init_wait = wait * 2;
3688 KMP_ASSERT((__kmp_init_wait & 1) == 0);
3689 __kmp_yield_init = __kmp_init_wait;
3692 static void __kmp_stg_print_init_wait(kmp_str_buf_t *buffer,
char const *name,
3694 __kmp_stg_print_int(buffer, name, __kmp_init_wait);
3697 static void __kmp_stg_parse_next_wait(
char const *name,
char const *value,
3700 KMP_ASSERT((__kmp_next_wait & 1) == 0);
3701 wait = __kmp_next_wait / 2;
3702 __kmp_stg_parse_int(name, value, KMP_MIN_NEXT_WAIT, KMP_MAX_NEXT_WAIT, &wait);
3703 __kmp_next_wait = wait * 2;
3704 KMP_ASSERT((__kmp_next_wait & 1) == 0);
3705 __kmp_yield_next = __kmp_next_wait;
3708 static void __kmp_stg_print_next_wait(kmp_str_buf_t *buffer,
char const *name,
3710 __kmp_stg_print_int(buffer, name, __kmp_next_wait);
3716 static void __kmp_stg_parse_gtid_mode(
char const *name,
char const *value,
3726 #ifdef KMP_TDATA_GTID 3729 __kmp_stg_parse_int(name, value, 0, max, &mode);
3733 __kmp_adjust_gtid_mode = TRUE;
3735 __kmp_gtid_mode = mode;
3736 __kmp_adjust_gtid_mode = FALSE;
3740 static void __kmp_stg_print_gtid_mode(kmp_str_buf_t *buffer,
char const *name,
3742 if (__kmp_adjust_gtid_mode) {
3743 __kmp_stg_print_int(buffer, name, 0);
3745 __kmp_stg_print_int(buffer, name, __kmp_gtid_mode);
3752 static void __kmp_stg_parse_lock_block(
char const *name,
char const *value,
3754 __kmp_stg_parse_int(name, value, 0, KMP_INT_MAX, &__kmp_num_locks_in_block);
3757 static void __kmp_stg_print_lock_block(kmp_str_buf_t *buffer,
char const *name,
3759 __kmp_stg_print_int(buffer, name, __kmp_num_locks_in_block);
3765 #if KMP_USE_DYNAMIC_LOCK 3766 #define KMP_STORE_LOCK_SEQ(a) (__kmp_user_lock_seq = lockseq_##a) 3768 #define KMP_STORE_LOCK_SEQ(a) 3771 static void __kmp_stg_parse_lock_kind(
char const *name,
char const *value,
3773 if (__kmp_init_user_locks) {
3774 KMP_WARNING(EnvLockWarn, name);
3778 if (__kmp_str_match(
"tas", 2, value) ||
3779 __kmp_str_match(
"test and set", 2, value) ||
3780 __kmp_str_match(
"test_and_set", 2, value) ||
3781 __kmp_str_match(
"test-and-set", 2, value) ||
3782 __kmp_str_match(
"test andset", 2, value) ||
3783 __kmp_str_match(
"test_andset", 2, value) ||
3784 __kmp_str_match(
"test-andset", 2, value) ||
3785 __kmp_str_match(
"testand set", 2, value) ||
3786 __kmp_str_match(
"testand_set", 2, value) ||
3787 __kmp_str_match(
"testand-set", 2, value) ||
3788 __kmp_str_match(
"testandset", 2, value)) {
3789 __kmp_user_lock_kind = lk_tas;
3790 KMP_STORE_LOCK_SEQ(tas);
3793 else if (__kmp_str_match(
"futex", 1, value)) {
3794 if (__kmp_futex_determine_capable()) {
3795 __kmp_user_lock_kind = lk_futex;
3796 KMP_STORE_LOCK_SEQ(futex);
3798 KMP_WARNING(FutexNotSupported, name, value);
3802 else if (__kmp_str_match(
"ticket", 2, value)) {
3803 __kmp_user_lock_kind = lk_ticket;
3804 KMP_STORE_LOCK_SEQ(ticket);
3805 }
else if (__kmp_str_match(
"queuing", 1, value) ||
3806 __kmp_str_match(
"queue", 1, value)) {
3807 __kmp_user_lock_kind = lk_queuing;
3808 KMP_STORE_LOCK_SEQ(queuing);
3809 }
else if (__kmp_str_match(
"drdpa ticket", 1, value) ||
3810 __kmp_str_match(
"drdpa_ticket", 1, value) ||
3811 __kmp_str_match(
"drdpa-ticket", 1, value) ||
3812 __kmp_str_match(
"drdpaticket", 1, value) ||
3813 __kmp_str_match(
"drdpa", 1, value)) {
3814 __kmp_user_lock_kind = lk_drdpa;
3815 KMP_STORE_LOCK_SEQ(drdpa);
3817 #if KMP_USE_ADAPTIVE_LOCKS 3818 else if (__kmp_str_match(
"adaptive", 1, value)) {
3819 if (__kmp_cpuinfo.rtm) {
3820 __kmp_user_lock_kind = lk_adaptive;
3821 KMP_STORE_LOCK_SEQ(adaptive);
3823 KMP_WARNING(AdaptiveNotSupported, name, value);
3824 __kmp_user_lock_kind = lk_queuing;
3825 KMP_STORE_LOCK_SEQ(queuing);
3828 #endif // KMP_USE_ADAPTIVE_LOCKS 3829 #if KMP_USE_DYNAMIC_LOCK && KMP_USE_TSX 3830 else if (__kmp_str_match(
"rtm", 1, value)) {
3831 if (__kmp_cpuinfo.rtm) {
3832 __kmp_user_lock_kind = lk_rtm;
3833 KMP_STORE_LOCK_SEQ(rtm);
3835 KMP_WARNING(AdaptiveNotSupported, name, value);
3836 __kmp_user_lock_kind = lk_queuing;
3837 KMP_STORE_LOCK_SEQ(queuing);
3839 }
else if (__kmp_str_match(
"hle", 1, value)) {
3840 __kmp_user_lock_kind = lk_hle;
3841 KMP_STORE_LOCK_SEQ(hle);
3845 KMP_WARNING(StgInvalidValue, name, value);
3849 static void __kmp_stg_print_lock_kind(kmp_str_buf_t *buffer,
char const *name,
3851 const char *value = NULL;
3853 switch (__kmp_user_lock_kind) {
3868 #if KMP_USE_DYNAMIC_LOCK && KMP_USE_TSX 3889 #if KMP_USE_ADAPTIVE_LOCKS 3896 if (value != NULL) {
3897 __kmp_stg_print_str(buffer, name, value);
3906 static void __kmp_stg_parse_spin_backoff_params(
const char *name,
3907 const char *value,
void *data) {
3908 const char *next = value;
3911 int prev_comma = FALSE;
3914 kmp_uint32 max_backoff = __kmp_spin_backoff_params.max_backoff;
3915 kmp_uint32 min_tick = __kmp_spin_backoff_params.min_tick;
3919 for (i = 0; i < 3; i++) {
3922 if (*next ==
'\0') {
3927 if (((*next < '0' || *next >
'9') && *next !=
',') || total > 2) {
3928 KMP_WARNING(EnvSyntaxError, name, value);
3934 if (total == 0 || prev_comma) {
3942 if (*next >=
'0' && *next <=
'9') {
3944 const char *buf = next;
3945 char const *msg = NULL;
3950 const char *tmp = next;
3952 if ((*next ==
' ' || *next ==
'\t') && (*tmp >=
'0' && *tmp <=
'9')) {
3953 KMP_WARNING(EnvSpacesNotAllowed, name, value);
3957 num = __kmp_str_to_int(buf, *next);
3959 msg = KMP_I18N_STR(ValueTooSmall);
3961 }
else if (num > KMP_INT_MAX) {
3962 msg = KMP_I18N_STR(ValueTooLarge);
3967 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
3968 KMP_INFORM(Using_int_Value, name, num);
3972 }
else if (total == 2) {
3977 KMP_DEBUG_ASSERT(total > 0);
3979 KMP_WARNING(EnvSyntaxError, name, value);
3982 __kmp_spin_backoff_params.max_backoff = max_backoff;
3983 __kmp_spin_backoff_params.min_tick = min_tick;
3986 static void __kmp_stg_print_spin_backoff_params(kmp_str_buf_t *buffer,
3987 char const *name,
void *data) {
3988 if (__kmp_env_format) {
3989 KMP_STR_BUF_PRINT_NAME_EX(name);
3991 __kmp_str_buf_print(buffer,
" %s='", name);
3993 __kmp_str_buf_print(buffer,
"%d,%d'\n", __kmp_spin_backoff_params.max_backoff,
3994 __kmp_spin_backoff_params.min_tick);
3997 #if KMP_USE_ADAPTIVE_LOCKS 4004 static void __kmp_stg_parse_adaptive_lock_props(
const char *name,
4005 const char *value,
void *data) {
4006 int max_retries = 0;
4007 int max_badness = 0;
4009 const char *next = value;
4012 int prev_comma = FALSE;
4018 for (i = 0; i < 3; i++) {
4021 if (*next ==
'\0') {
4026 if (((*next < '0' || *next >
'9') && *next !=
',') || total > 2) {
4027 KMP_WARNING(EnvSyntaxError, name, value);
4033 if (total == 0 || prev_comma) {
4041 if (*next >=
'0' && *next <=
'9') {
4043 const char *buf = next;
4044 char const *msg = NULL;
4049 const char *tmp = next;
4051 if ((*next ==
' ' || *next ==
'\t') && (*tmp >=
'0' && *tmp <=
'9')) {
4052 KMP_WARNING(EnvSpacesNotAllowed, name, value);
4056 num = __kmp_str_to_int(buf, *next);
4058 msg = KMP_I18N_STR(ValueTooSmall);
4060 }
else if (num > KMP_INT_MAX) {
4061 msg = KMP_I18N_STR(ValueTooLarge);
4066 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
4067 KMP_INFORM(Using_int_Value, name, num);
4071 }
else if (total == 2) {
4076 KMP_DEBUG_ASSERT(total > 0);
4078 KMP_WARNING(EnvSyntaxError, name, value);
4081 __kmp_adaptive_backoff_params.max_soft_retries = max_retries;
4082 __kmp_adaptive_backoff_params.max_badness = max_badness;
4085 static void __kmp_stg_print_adaptive_lock_props(kmp_str_buf_t *buffer,
4086 char const *name,
void *data) {
4087 if (__kmp_env_format) {
4088 KMP_STR_BUF_PRINT_NAME_EX(name);
4090 __kmp_str_buf_print(buffer,
" %s='", name);
4092 __kmp_str_buf_print(buffer,
"%d,%d'\n",
4093 __kmp_adaptive_backoff_params.max_soft_retries,
4094 __kmp_adaptive_backoff_params.max_badness);
4097 #if KMP_DEBUG_ADAPTIVE_LOCKS 4099 static void __kmp_stg_parse_speculative_statsfile(
char const *name,
4102 __kmp_stg_parse_file(name, value,
"", &__kmp_speculative_statsfile);
4105 static void __kmp_stg_print_speculative_statsfile(kmp_str_buf_t *buffer,
4108 if (__kmp_str_match(
"-", 0, __kmp_speculative_statsfile)) {
4109 __kmp_stg_print_str(buffer, name,
"stdout");
4111 __kmp_stg_print_str(buffer, name, __kmp_speculative_statsfile);
4116 #endif // KMP_DEBUG_ADAPTIVE_LOCKS 4118 #endif // KMP_USE_ADAPTIVE_LOCKS 4127 #define MAX_T_LEVEL 5 4128 #define MAX_STR_LEN 512 4129 static void __kmp_stg_parse_hw_subset(
char const *name,
char const *value,
4133 kmp_setting_t **rivals = (kmp_setting_t **)data;
4134 if (strcmp(name,
"KMP_PLACE_THREADS") == 0) {
4135 KMP_INFORM(EnvVarDeprecated, name,
"KMP_HW_SUBSET");
4137 if (__kmp_stg_check_rivals(name, value, rivals)) {
4141 char *components[MAX_T_LEVEL];
4142 char const *digits =
"0123456789";
4143 char input[MAX_STR_LEN];
4144 size_t len = 0, mlen = MAX_STR_LEN;
4147 char *pos = CCAST(
char *, value);
4148 while (*pos && mlen) {
4150 if (len == 0 && *pos ==
':') {
4151 __kmp_hws_abs_flag = 1;
4153 input[len] = toupper(*pos);
4154 if (input[len] ==
'X')
4156 if (input[len] ==
'O' && strchr(digits, *(pos + 1)))
4164 if (len == 0 || mlen == 0)
4167 __kmp_hws_requested = 1;
4170 components[level++] = pos;
4171 while ((pos = strchr(pos,
','))) {
4173 components[level++] = ++pos;
4174 if (level > MAX_T_LEVEL)
4178 for (
int i = 0; i < level; ++i) {
4180 int num = atoi(components[i]);
4181 if ((pos = strchr(components[i],
'@'))) {
4182 offset = atoi(pos + 1);
4185 pos = components[i] + strspn(components[i], digits);
4186 if (pos == components[i])
4191 if (__kmp_hws_socket.num > 0)
4193 __kmp_hws_socket.num = num;
4194 __kmp_hws_socket.offset = offset;
4197 if (__kmp_hws_node.num > 0)
4199 __kmp_hws_node.num = num;
4200 __kmp_hws_node.offset = offset;
4203 if (*(pos + 1) ==
'2') {
4204 if (__kmp_hws_tile.num > 0)
4206 __kmp_hws_tile.num = num;
4207 __kmp_hws_tile.offset = offset;
4208 }
else if (*(pos + 1) ==
'3') {
4209 if (__kmp_hws_socket.num > 0)
4211 __kmp_hws_socket.num = num;
4212 __kmp_hws_socket.offset = offset;
4213 }
else if (*(pos + 1) ==
'1') {
4214 if (__kmp_hws_core.num > 0)
4216 __kmp_hws_core.num = num;
4217 __kmp_hws_core.offset = offset;
4221 if (*(pos + 1) !=
'A') {
4222 if (__kmp_hws_core.num > 0)
4224 __kmp_hws_core.num = num;
4225 __kmp_hws_core.offset = offset;
4227 char *d = pos + strcspn(pos, digits);
4229 if (__kmp_hws_tile.num > 0)
4231 __kmp_hws_tile.num = num;
4232 __kmp_hws_tile.offset = offset;
4233 }
else if (*d ==
'3') {
4234 if (__kmp_hws_socket.num > 0)
4236 __kmp_hws_socket.num = num;
4237 __kmp_hws_socket.offset = offset;
4238 }
else if (*d ==
'1') {
4239 if (__kmp_hws_core.num > 0)
4241 __kmp_hws_core.num = num;
4242 __kmp_hws_core.offset = offset;
4249 if (__kmp_hws_proc.num > 0)
4251 __kmp_hws_proc.num = num;
4252 __kmp_hws_proc.offset = offset;
4260 KMP_WARNING(AffHWSubsetInvalid, name, value);
4261 __kmp_hws_requested = 0;
4265 static void __kmp_stg_print_hw_subset(kmp_str_buf_t *buffer,
char const *name,
4267 if (__kmp_hws_requested) {
4270 __kmp_str_buf_init(&buf);
4271 if (__kmp_env_format)
4272 KMP_STR_BUF_PRINT_NAME_EX(name);
4274 __kmp_str_buf_print(buffer,
" %s='", name);
4275 if (__kmp_hws_socket.num) {
4276 __kmp_str_buf_print(&buf,
"%ds", __kmp_hws_socket.num);
4277 if (__kmp_hws_socket.offset)
4278 __kmp_str_buf_print(&buf,
"@%d", __kmp_hws_socket.offset);
4281 if (__kmp_hws_node.num) {
4282 __kmp_str_buf_print(&buf,
"%s%dn", comma ?
"," :
"", __kmp_hws_node.num);
4283 if (__kmp_hws_node.offset)
4284 __kmp_str_buf_print(&buf,
"@%d", __kmp_hws_node.offset);
4287 if (__kmp_hws_tile.num) {
4288 __kmp_str_buf_print(&buf,
"%s%dL2", comma ?
"," :
"", __kmp_hws_tile.num);
4289 if (__kmp_hws_tile.offset)
4290 __kmp_str_buf_print(&buf,
"@%d", __kmp_hws_tile.offset);
4293 if (__kmp_hws_core.num) {
4294 __kmp_str_buf_print(&buf,
"%s%dc", comma ?
"," :
"", __kmp_hws_core.num);
4295 if (__kmp_hws_core.offset)
4296 __kmp_str_buf_print(&buf,
"@%d", __kmp_hws_core.offset);
4299 if (__kmp_hws_proc.num)
4300 __kmp_str_buf_print(&buf,
"%s%dt", comma ?
"," :
"", __kmp_hws_proc.num);
4301 __kmp_str_buf_print(buffer,
"%s'\n", buf.str);
4302 __kmp_str_buf_free(&buf);
4310 static void __kmp_stg_parse_forkjoin_frames(
char const *name,
char const *value,
4312 __kmp_stg_parse_bool(name, value, &__kmp_forkjoin_frames);
4315 static void __kmp_stg_print_forkjoin_frames(kmp_str_buf_t *buffer,
4316 char const *name,
void *data) {
4317 __kmp_stg_print_bool(buffer, name, __kmp_forkjoin_frames);
4323 static void __kmp_stg_parse_forkjoin_frames_mode(
char const *name,
4326 __kmp_stg_parse_int(name, value, 0, 3, &__kmp_forkjoin_frames_mode);
4329 static void __kmp_stg_print_forkjoin_frames_mode(kmp_str_buf_t *buffer,
4330 char const *name,
void *data) {
4331 __kmp_stg_print_int(buffer, name, __kmp_forkjoin_frames_mode);
4340 static void __kmp_stg_parse_omp_display_env(
char const *name,
char const *value,
4342 if (__kmp_str_match(
"VERBOSE", 1, value)) {
4343 __kmp_display_env_verbose = TRUE;
4345 __kmp_stg_parse_bool(name, value, &__kmp_display_env);
4350 static void __kmp_stg_print_omp_display_env(kmp_str_buf_t *buffer,
4351 char const *name,
void *data) {
4352 if (__kmp_display_env_verbose) {
4353 __kmp_stg_print_str(buffer, name,
"VERBOSE");
4355 __kmp_stg_print_bool(buffer, name, __kmp_display_env);
4359 static void __kmp_stg_parse_omp_cancellation(
char const *name,
4360 char const *value,
void *data) {
4361 if (TCR_4(__kmp_init_parallel)) {
4362 KMP_WARNING(EnvParallelWarn, name);
4365 __kmp_stg_parse_bool(name, value, &__kmp_omp_cancellation);
4368 static void __kmp_stg_print_omp_cancellation(kmp_str_buf_t *buffer,
4369 char const *name,
void *data) {
4370 __kmp_stg_print_bool(buffer, name, __kmp_omp_cancellation);
4375 #if OMP_50_ENABLED && OMPT_SUPPORT 4377 static char *__kmp_tool_libraries = NULL;
4379 static void __kmp_stg_parse_omp_tool_libraries(
char const *name,
4380 char const *value,
void *data) {
4381 __kmp_stg_parse_str(name, value, &__kmp_tool_libraries);
4384 static void __kmp_stg_print_omp_tool_libraries(kmp_str_buf_t *buffer,
4385 char const *name,
void *data) {
4386 if (__kmp_tool_libraries)
4387 __kmp_stg_print_str(buffer, name, __kmp_tool_libraries);
4389 if (__kmp_env_format) {
4390 KMP_STR_BUF_PRINT_NAME;
4392 __kmp_str_buf_print(buffer,
" %s", name);
4394 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
4402 static kmp_setting_t __kmp_stg_table[] = {
4404 {
"KMP_ALL_THREADS", __kmp_stg_parse_device_thread_limit, NULL, NULL, 0, 0},
4405 {
"KMP_BLOCKTIME", __kmp_stg_parse_blocktime, __kmp_stg_print_blocktime,
4407 {
"KMP_DUPLICATE_LIB_OK", __kmp_stg_parse_duplicate_lib_ok,
4408 __kmp_stg_print_duplicate_lib_ok, NULL, 0, 0},
4409 {
"KMP_LIBRARY", __kmp_stg_parse_wait_policy, __kmp_stg_print_wait_policy,
4411 {
"KMP_DEVICE_THREAD_LIMIT", __kmp_stg_parse_device_thread_limit,
4412 __kmp_stg_print_device_thread_limit, NULL, 0, 0},
4414 {
"KMP_MONITOR_STACKSIZE", __kmp_stg_parse_monitor_stacksize,
4415 __kmp_stg_print_monitor_stacksize, NULL, 0, 0},
4417 {
"KMP_SETTINGS", __kmp_stg_parse_settings, __kmp_stg_print_settings, NULL,
4419 {
"KMP_STACKOFFSET", __kmp_stg_parse_stackoffset,
4420 __kmp_stg_print_stackoffset, NULL, 0, 0},
4421 {
"KMP_STACKSIZE", __kmp_stg_parse_stacksize, __kmp_stg_print_stacksize,
4423 {
"KMP_STACKPAD", __kmp_stg_parse_stackpad, __kmp_stg_print_stackpad, NULL,
4425 {
"KMP_VERSION", __kmp_stg_parse_version, __kmp_stg_print_version, NULL, 0,
4427 {
"KMP_WARNINGS", __kmp_stg_parse_warnings, __kmp_stg_print_warnings, NULL,
4430 {
"OMP_NESTED", __kmp_stg_parse_nested, __kmp_stg_print_nested, NULL, 0, 0},
4431 {
"OMP_NUM_THREADS", __kmp_stg_parse_num_threads,
4432 __kmp_stg_print_num_threads, NULL, 0, 0},
4433 {
"OMP_STACKSIZE", __kmp_stg_parse_stacksize, __kmp_stg_print_stacksize,
4436 {
"KMP_TASKING", __kmp_stg_parse_tasking, __kmp_stg_print_tasking, NULL, 0,
4438 {
"KMP_TASK_STEALING_CONSTRAINT", __kmp_stg_parse_task_stealing,
4439 __kmp_stg_print_task_stealing, NULL, 0, 0},
4440 {
"OMP_MAX_ACTIVE_LEVELS", __kmp_stg_parse_max_active_levels,
4441 __kmp_stg_print_max_active_levels, NULL, 0, 0},
4443 {
"OMP_DEFAULT_DEVICE", __kmp_stg_parse_default_device,
4444 __kmp_stg_print_default_device, NULL, 0, 0},
4447 {
"OMP_MAX_TASK_PRIORITY", __kmp_stg_parse_max_task_priority,
4448 __kmp_stg_print_max_task_priority, NULL, 0, 0},
4449 {
"KMP_TASKLOOP_MIN_TASKS", __kmp_stg_parse_taskloop_min_tasks,
4450 __kmp_stg_print_taskloop_min_tasks, NULL, 0, 0},
4452 {
"OMP_THREAD_LIMIT", __kmp_stg_parse_thread_limit,
4453 __kmp_stg_print_thread_limit, NULL, 0, 0},
4454 {
"KMP_TEAMS_THREAD_LIMIT", __kmp_stg_parse_teams_thread_limit,
4455 __kmp_stg_print_teams_thread_limit, NULL, 0, 0},
4456 {
"OMP_WAIT_POLICY", __kmp_stg_parse_wait_policy,
4457 __kmp_stg_print_wait_policy, NULL, 0, 0},
4458 {
"KMP_DISP_NUM_BUFFERS", __kmp_stg_parse_disp_buffers,
4459 __kmp_stg_print_disp_buffers, NULL, 0, 0},
4460 #if KMP_NESTED_HOT_TEAMS 4461 {
"KMP_HOT_TEAMS_MAX_LEVEL", __kmp_stg_parse_hot_teams_level,
4462 __kmp_stg_print_hot_teams_level, NULL, 0, 0},
4463 {
"KMP_HOT_TEAMS_MODE", __kmp_stg_parse_hot_teams_mode,
4464 __kmp_stg_print_hot_teams_mode, NULL, 0, 0},
4465 #endif // KMP_NESTED_HOT_TEAMS 4467 #if KMP_HANDLE_SIGNALS 4468 {
"KMP_HANDLE_SIGNALS", __kmp_stg_parse_handle_signals,
4469 __kmp_stg_print_handle_signals, NULL, 0, 0},
4472 #if KMP_ARCH_X86 || KMP_ARCH_X86_64 4473 {
"KMP_INHERIT_FP_CONTROL", __kmp_stg_parse_inherit_fp_control,
4474 __kmp_stg_print_inherit_fp_control, NULL, 0, 0},
4477 #ifdef KMP_GOMP_COMPAT 4478 {
"GOMP_STACKSIZE", __kmp_stg_parse_stacksize, NULL, NULL, 0, 0},
4482 {
"KMP_A_DEBUG", __kmp_stg_parse_a_debug, __kmp_stg_print_a_debug, NULL, 0,
4484 {
"KMP_B_DEBUG", __kmp_stg_parse_b_debug, __kmp_stg_print_b_debug, NULL, 0,
4486 {
"KMP_C_DEBUG", __kmp_stg_parse_c_debug, __kmp_stg_print_c_debug, NULL, 0,
4488 {
"KMP_D_DEBUG", __kmp_stg_parse_d_debug, __kmp_stg_print_d_debug, NULL, 0,
4490 {
"KMP_E_DEBUG", __kmp_stg_parse_e_debug, __kmp_stg_print_e_debug, NULL, 0,
4492 {
"KMP_F_DEBUG", __kmp_stg_parse_f_debug, __kmp_stg_print_f_debug, NULL, 0,
4494 {
"KMP_DEBUG", __kmp_stg_parse_debug, NULL, NULL, 0, 0},
4495 {
"KMP_DEBUG_BUF", __kmp_stg_parse_debug_buf, __kmp_stg_print_debug_buf,
4497 {
"KMP_DEBUG_BUF_ATOMIC", __kmp_stg_parse_debug_buf_atomic,
4498 __kmp_stg_print_debug_buf_atomic, NULL, 0, 0},
4499 {
"KMP_DEBUG_BUF_CHARS", __kmp_stg_parse_debug_buf_chars,
4500 __kmp_stg_print_debug_buf_chars, NULL, 0, 0},
4501 {
"KMP_DEBUG_BUF_LINES", __kmp_stg_parse_debug_buf_lines,
4502 __kmp_stg_print_debug_buf_lines, NULL, 0, 0},
4503 {
"KMP_DIAG", __kmp_stg_parse_diag, __kmp_stg_print_diag, NULL, 0, 0},
4505 {
"KMP_PAR_RANGE", __kmp_stg_parse_par_range_env,
4506 __kmp_stg_print_par_range_env, NULL, 0, 0},
4507 {
"KMP_YIELD_CYCLE", __kmp_stg_parse_yield_cycle,
4508 __kmp_stg_print_yield_cycle, NULL, 0, 0},
4509 {
"KMP_YIELD_ON", __kmp_stg_parse_yield_on, __kmp_stg_print_yield_on, NULL,
4511 {
"KMP_YIELD_OFF", __kmp_stg_parse_yield_off, __kmp_stg_print_yield_off,
4515 {
"KMP_ALIGN_ALLOC", __kmp_stg_parse_align_alloc,
4516 __kmp_stg_print_align_alloc, NULL, 0, 0},
4518 {
"KMP_PLAIN_BARRIER", __kmp_stg_parse_barrier_branch_bit,
4519 __kmp_stg_print_barrier_branch_bit, NULL, 0, 0},
4520 {
"KMP_PLAIN_BARRIER_PATTERN", __kmp_stg_parse_barrier_pattern,
4521 __kmp_stg_print_barrier_pattern, NULL, 0, 0},
4522 {
"KMP_FORKJOIN_BARRIER", __kmp_stg_parse_barrier_branch_bit,
4523 __kmp_stg_print_barrier_branch_bit, NULL, 0, 0},
4524 {
"KMP_FORKJOIN_BARRIER_PATTERN", __kmp_stg_parse_barrier_pattern,
4525 __kmp_stg_print_barrier_pattern, NULL, 0, 0},
4526 #if KMP_FAST_REDUCTION_BARRIER 4527 {
"KMP_REDUCTION_BARRIER", __kmp_stg_parse_barrier_branch_bit,
4528 __kmp_stg_print_barrier_branch_bit, NULL, 0, 0},
4529 {
"KMP_REDUCTION_BARRIER_PATTERN", __kmp_stg_parse_barrier_pattern,
4530 __kmp_stg_print_barrier_pattern, NULL, 0, 0},
4533 {
"KMP_ABORT_DELAY", __kmp_stg_parse_abort_delay,
4534 __kmp_stg_print_abort_delay, NULL, 0, 0},
4535 {
"KMP_CPUINFO_FILE", __kmp_stg_parse_cpuinfo_file,
4536 __kmp_stg_print_cpuinfo_file, NULL, 0, 0},
4537 {
"KMP_FORCE_REDUCTION", __kmp_stg_parse_force_reduction,
4538 __kmp_stg_print_force_reduction, NULL, 0, 0},
4539 {
"KMP_DETERMINISTIC_REDUCTION", __kmp_stg_parse_force_reduction,
4540 __kmp_stg_print_force_reduction, NULL, 0, 0},
4541 {
"KMP_STORAGE_MAP", __kmp_stg_parse_storage_map,
4542 __kmp_stg_print_storage_map, NULL, 0, 0},
4543 {
"KMP_ALL_THREADPRIVATE", __kmp_stg_parse_all_threadprivate,
4544 __kmp_stg_print_all_threadprivate, NULL, 0, 0},
4545 {
"KMP_FOREIGN_THREADS_THREADPRIVATE",
4546 __kmp_stg_parse_foreign_threads_threadprivate,
4547 __kmp_stg_print_foreign_threads_threadprivate, NULL, 0, 0},
4549 #if KMP_AFFINITY_SUPPORTED 4550 {
"KMP_AFFINITY", __kmp_stg_parse_affinity, __kmp_stg_print_affinity, NULL,
4552 #ifdef KMP_GOMP_COMPAT 4553 {
"GOMP_CPU_AFFINITY", __kmp_stg_parse_gomp_cpu_affinity, NULL,
4557 {
"OMP_PROC_BIND", __kmp_stg_parse_proc_bind, __kmp_stg_print_proc_bind,
4559 {
"OMP_PLACES", __kmp_stg_parse_places, __kmp_stg_print_places, NULL, 0, 0},
4561 {
"OMP_PROC_BIND", __kmp_stg_parse_proc_bind, NULL, NULL, 0,
4565 {
"KMP_TOPOLOGY_METHOD", __kmp_stg_parse_topology_method,
4566 __kmp_stg_print_topology_method, NULL, 0, 0},
4573 {
"OMP_PROC_BIND", __kmp_stg_parse_proc_bind, __kmp_stg_print_proc_bind,
4577 #endif // KMP_AFFINITY_SUPPORTED 4579 {
"KMP_INIT_AT_FORK", __kmp_stg_parse_init_at_fork,
4580 __kmp_stg_print_init_at_fork, NULL, 0, 0},
4581 {
"KMP_SCHEDULE", __kmp_stg_parse_schedule, __kmp_stg_print_schedule, NULL,
4583 {
"OMP_SCHEDULE", __kmp_stg_parse_omp_schedule, __kmp_stg_print_omp_schedule,
4585 {
"KMP_ATOMIC_MODE", __kmp_stg_parse_atomic_mode,
4586 __kmp_stg_print_atomic_mode, NULL, 0, 0},
4587 {
"KMP_CONSISTENCY_CHECK", __kmp_stg_parse_consistency_check,
4588 __kmp_stg_print_consistency_check, NULL, 0, 0},
4590 #if USE_ITT_BUILD && USE_ITT_NOTIFY 4591 {
"KMP_ITT_PREPARE_DELAY", __kmp_stg_parse_itt_prepare_delay,
4592 __kmp_stg_print_itt_prepare_delay, NULL, 0, 0},
4594 {
"KMP_MALLOC_POOL_INCR", __kmp_stg_parse_malloc_pool_incr,
4595 __kmp_stg_print_malloc_pool_incr, NULL, 0, 0},
4596 {
"KMP_INIT_WAIT", __kmp_stg_parse_init_wait, __kmp_stg_print_init_wait,
4598 {
"KMP_NEXT_WAIT", __kmp_stg_parse_next_wait, __kmp_stg_print_next_wait,
4600 {
"KMP_GTID_MODE", __kmp_stg_parse_gtid_mode, __kmp_stg_print_gtid_mode,
4602 {
"OMP_DYNAMIC", __kmp_stg_parse_omp_dynamic, __kmp_stg_print_omp_dynamic,
4604 {
"KMP_DYNAMIC_MODE", __kmp_stg_parse_kmp_dynamic_mode,
4605 __kmp_stg_print_kmp_dynamic_mode, NULL, 0, 0},
4607 #ifdef USE_LOAD_BALANCE 4608 {
"KMP_LOAD_BALANCE_INTERVAL", __kmp_stg_parse_ld_balance_interval,
4609 __kmp_stg_print_ld_balance_interval, NULL, 0, 0},
4612 {
"KMP_NUM_LOCKS_IN_BLOCK", __kmp_stg_parse_lock_block,
4613 __kmp_stg_print_lock_block, NULL, 0, 0},
4614 {
"KMP_LOCK_KIND", __kmp_stg_parse_lock_kind, __kmp_stg_print_lock_kind,
4616 {
"KMP_SPIN_BACKOFF_PARAMS", __kmp_stg_parse_spin_backoff_params,
4617 __kmp_stg_print_spin_backoff_params, NULL, 0, 0},
4618 #if KMP_USE_ADAPTIVE_LOCKS 4619 {
"KMP_ADAPTIVE_LOCK_PROPS", __kmp_stg_parse_adaptive_lock_props,
4620 __kmp_stg_print_adaptive_lock_props, NULL, 0, 0},
4621 #if KMP_DEBUG_ADAPTIVE_LOCKS 4622 {
"KMP_SPECULATIVE_STATSFILE", __kmp_stg_parse_speculative_statsfile,
4623 __kmp_stg_print_speculative_statsfile, NULL, 0, 0},
4625 #endif // KMP_USE_ADAPTIVE_LOCKS 4626 {
"KMP_PLACE_THREADS", __kmp_stg_parse_hw_subset, __kmp_stg_print_hw_subset,
4628 {
"KMP_HW_SUBSET", __kmp_stg_parse_hw_subset, __kmp_stg_print_hw_subset,
4631 {
"KMP_FORKJOIN_FRAMES", __kmp_stg_parse_forkjoin_frames,
4632 __kmp_stg_print_forkjoin_frames, NULL, 0, 0},
4633 {
"KMP_FORKJOIN_FRAMES_MODE", __kmp_stg_parse_forkjoin_frames_mode,
4634 __kmp_stg_print_forkjoin_frames_mode, NULL, 0, 0},
4638 {
"OMP_DISPLAY_ENV", __kmp_stg_parse_omp_display_env,
4639 __kmp_stg_print_omp_display_env, NULL, 0, 0},
4640 {
"OMP_CANCELLATION", __kmp_stg_parse_omp_cancellation,
4641 __kmp_stg_print_omp_cancellation, NULL, 0, 0},
4644 #if OMP_50_ENABLED && OMPT_SUPPORT 4645 {
"OMP_TOOL_LIBRARIES", __kmp_stg_parse_omp_tool_libraries,
4646 __kmp_stg_print_omp_tool_libraries, NULL, 0, 0},
4649 {
"", NULL, NULL, NULL, 0, 0}};
4651 static int const __kmp_stg_count =
4652 sizeof(__kmp_stg_table) /
sizeof(kmp_setting_t);
4654 static inline kmp_setting_t *__kmp_stg_find(
char const *name) {
4658 for (i = 0; i < __kmp_stg_count; ++i) {
4659 if (strcmp(__kmp_stg_table[i].name, name) == 0) {
4660 return &__kmp_stg_table[i];
4668 static int __kmp_stg_cmp(
void const *_a,
void const *_b) {
4669 const kmp_setting_t *a = RCAST(
const kmp_setting_t *, _a);
4670 const kmp_setting_t *b = RCAST(
const kmp_setting_t *, _b);
4674 if (strcmp(a->name,
"KMP_AFFINITY") == 0) {
4675 if (strcmp(b->name,
"KMP_AFFINITY") == 0) {
4679 }
else if (strcmp(b->name,
"KMP_AFFINITY") == 0) {
4682 return strcmp(a->name, b->name);
4685 static void __kmp_stg_init(
void) {
4687 static int initialized = 0;
4692 qsort(__kmp_stg_table, __kmp_stg_count - 1,
sizeof(kmp_setting_t),
4696 kmp_setting_t *kmp_stacksize =
4697 __kmp_stg_find(
"KMP_STACKSIZE");
4698 #ifdef KMP_GOMP_COMPAT 4699 kmp_setting_t *gomp_stacksize =
4700 __kmp_stg_find(
"GOMP_STACKSIZE");
4702 kmp_setting_t *omp_stacksize =
4703 __kmp_stg_find(
"OMP_STACKSIZE");
4709 static kmp_setting_t *
volatile rivals[4];
4710 static kmp_stg_ss_data_t kmp_data = {1, CCAST(kmp_setting_t **, rivals)};
4711 #ifdef KMP_GOMP_COMPAT 4712 static kmp_stg_ss_data_t gomp_data = {1024,
4713 CCAST(kmp_setting_t **, rivals)};
4715 static kmp_stg_ss_data_t omp_data = {1024,
4716 CCAST(kmp_setting_t **, rivals)};
4719 rivals[i++] = kmp_stacksize;
4720 #ifdef KMP_GOMP_COMPAT 4721 if (gomp_stacksize != NULL) {
4722 rivals[i++] = gomp_stacksize;
4725 rivals[i++] = omp_stacksize;
4728 kmp_stacksize->data = &kmp_data;
4729 #ifdef KMP_GOMP_COMPAT 4730 if (gomp_stacksize != NULL) {
4731 gomp_stacksize->data = &gomp_data;
4734 omp_stacksize->data = &omp_data;
4738 kmp_setting_t *kmp_library =
4739 __kmp_stg_find(
"KMP_LIBRARY");
4740 kmp_setting_t *omp_wait_policy =
4741 __kmp_stg_find(
"OMP_WAIT_POLICY");
4744 static kmp_setting_t *
volatile rivals[3];
4745 static kmp_stg_wp_data_t kmp_data = {0, CCAST(kmp_setting_t **, rivals)};
4746 static kmp_stg_wp_data_t omp_data = {1, CCAST(kmp_setting_t **, rivals)};
4749 rivals[i++] = kmp_library;
4750 if (omp_wait_policy != NULL) {
4751 rivals[i++] = omp_wait_policy;
4755 kmp_library->data = &kmp_data;
4756 if (omp_wait_policy != NULL) {
4757 omp_wait_policy->data = &omp_data;
4762 kmp_setting_t *kmp_device_thread_limit =
4763 __kmp_stg_find(
"KMP_DEVICE_THREAD_LIMIT");
4764 kmp_setting_t *kmp_all_threads =
4765 __kmp_stg_find(
"KMP_ALL_THREADS");
4768 static kmp_setting_t *
volatile rivals[3];
4771 rivals[i++] = kmp_device_thread_limit;
4772 rivals[i++] = kmp_all_threads;
4775 kmp_device_thread_limit->data = CCAST(kmp_setting_t **, rivals);
4776 kmp_all_threads->data = CCAST(kmp_setting_t **, rivals);
4781 kmp_setting_t *kmp_hw_subset = __kmp_stg_find(
"KMP_HW_SUBSET");
4783 kmp_setting_t *kmp_place_threads = __kmp_stg_find(
"KMP_PLACE_THREADS");
4786 static kmp_setting_t *
volatile rivals[3];
4789 rivals[i++] = kmp_hw_subset;
4790 rivals[i++] = kmp_place_threads;
4793 kmp_hw_subset->data = CCAST(kmp_setting_t **, rivals);
4794 kmp_place_threads->data = CCAST(kmp_setting_t **, rivals);
4797 #if KMP_AFFINITY_SUPPORTED 4799 kmp_setting_t *kmp_affinity =
4800 __kmp_stg_find(
"KMP_AFFINITY");
4801 KMP_DEBUG_ASSERT(kmp_affinity != NULL);
4803 #ifdef KMP_GOMP_COMPAT 4804 kmp_setting_t *gomp_cpu_affinity =
4805 __kmp_stg_find(
"GOMP_CPU_AFFINITY");
4806 KMP_DEBUG_ASSERT(gomp_cpu_affinity != NULL);
4809 kmp_setting_t *omp_proc_bind =
4810 __kmp_stg_find(
"OMP_PROC_BIND");
4811 KMP_DEBUG_ASSERT(omp_proc_bind != NULL);
4814 static kmp_setting_t *
volatile rivals[4];
4817 rivals[i++] = kmp_affinity;
4819 #ifdef KMP_GOMP_COMPAT 4820 rivals[i++] = gomp_cpu_affinity;
4821 gomp_cpu_affinity->data = CCAST(kmp_setting_t **, rivals);
4824 rivals[i++] = omp_proc_bind;
4825 omp_proc_bind->data = CCAST(kmp_setting_t **, rivals);
4829 static kmp_setting_t *
volatile places_rivals[4];
4832 kmp_setting_t *omp_places = __kmp_stg_find(
"OMP_PLACES");
4833 KMP_DEBUG_ASSERT(omp_places != NULL);
4835 places_rivals[i++] = kmp_affinity;
4836 #ifdef KMP_GOMP_COMPAT 4837 places_rivals[i++] = gomp_cpu_affinity;
4839 places_rivals[i++] = omp_places;
4840 omp_places->data = CCAST(kmp_setting_t **, places_rivals);
4841 places_rivals[i++] = NULL;
4847 #endif // KMP_AFFINITY_SUPPORTED 4850 kmp_setting_t *kmp_force_red =
4851 __kmp_stg_find(
"KMP_FORCE_REDUCTION");
4852 kmp_setting_t *kmp_determ_red =
4853 __kmp_stg_find(
"KMP_DETERMINISTIC_REDUCTION");
4856 static kmp_setting_t *
volatile rivals[3];
4857 static kmp_stg_fr_data_t force_data = {1,
4858 CCAST(kmp_setting_t **, rivals)};
4859 static kmp_stg_fr_data_t determ_data = {0,
4860 CCAST(kmp_setting_t **, rivals)};
4863 rivals[i++] = kmp_force_red;
4864 if (kmp_determ_red != NULL) {
4865 rivals[i++] = kmp_determ_red;
4869 kmp_force_red->data = &force_data;
4870 if (kmp_determ_red != NULL) {
4871 kmp_determ_red->data = &determ_data;
4880 for (i = 0; i < __kmp_stg_count; ++i) {
4881 __kmp_stg_table[i].set = 0;
4886 static void __kmp_stg_parse(
char const *name,
char const *value) {
4894 if (value != NULL) {
4895 kmp_setting_t *setting = __kmp_stg_find(name);
4896 if (setting != NULL) {
4897 setting->parse(name, value, setting->data);
4898 setting->defined = 1;
4904 static int __kmp_stg_check_rivals(
4907 kmp_setting_t **rivals
4910 if (rivals == NULL) {
4916 for (; strcmp(rivals[i]->name, name) != 0; i++) {
4917 KMP_DEBUG_ASSERT(rivals[i] != NULL);
4919 #if KMP_AFFINITY_SUPPORTED 4920 if (rivals[i] == __kmp_affinity_notype) {
4927 if (rivals[i]->
set) {
4928 KMP_WARNING(StgIgnored, name, rivals[i]->name);
4938 static int __kmp_env_toPrint(
char const *name,
int flag) {
4940 kmp_setting_t *setting = __kmp_stg_find(name);
4941 if (setting != NULL) {
4942 rc = setting->defined;
4944 setting->defined = flag;
4950 static void __kmp_aux_env_initialize(kmp_env_blk_t *block) {
4955 value = __kmp_env_blk_var(block,
"OMP_NUM_THREADS");
4957 ompc_set_num_threads(__kmp_dflt_team_nth);
4961 value = __kmp_env_blk_var(block,
"KMP_BLOCKTIME");
4963 kmpc_set_blocktime(__kmp_dflt_blocktime);
4967 value = __kmp_env_blk_var(block,
"OMP_NESTED");
4969 ompc_set_nested(__kmp_dflt_nested);
4973 value = __kmp_env_blk_var(block,
"OMP_DYNAMIC");
4975 ompc_set_dynamic(__kmp_global.g.g_dynamic);
4979 void __kmp_env_initialize(
char const *
string) {
4981 kmp_env_blk_t block;
4987 if (
string == NULL) {
4989 __kmp_threads_capacity =
4990 __kmp_initial_threads_capacity(__kmp_dflt_team_nth_ub);
4992 __kmp_env_blk_init(&block,
string);
4995 for (i = 0; i < block.count; ++i) {
4996 if ((block.vars[i].name == NULL) || (*block.vars[i].name ==
'\0')) {
4999 if (block.vars[i].value == NULL) {
5002 kmp_setting_t *setting = __kmp_stg_find(block.vars[i].name);
5003 if (setting != NULL) {
5009 blocktime_str = __kmp_env_blk_var(&block,
"KMP_BLOCKTIME");
5013 if (
string == NULL) {
5014 char const *name =
"KMP_WARNINGS";
5015 char const *value = __kmp_env_blk_var(&block, name);
5016 __kmp_stg_parse(name, value);
5019 #if KMP_AFFINITY_SUPPORTED 5025 __kmp_affinity_notype = NULL;
5026 char const *aff_str = __kmp_env_blk_var(&block,
"KMP_AFFINITY");
5027 if (aff_str != NULL) {
5041 #define FIND strcasestr 5044 if ((FIND(aff_str,
"none") == NULL) &&
5045 (FIND(aff_str,
"physical") == NULL) &&
5046 (FIND(aff_str,
"logical") == NULL) &&
5047 (FIND(aff_str,
"compact") == NULL) &&
5048 (FIND(aff_str,
"scatter") == NULL) &&
5049 (FIND(aff_str,
"explicit") == NULL) &&
5050 (FIND(aff_str,
"balanced") == NULL) &&
5051 (FIND(aff_str,
"disabled") == NULL)) {
5052 __kmp_affinity_notype = __kmp_stg_find(
"KMP_AFFINITY");
5057 __kmp_affinity_type = affinity_default;
5058 __kmp_affinity_gran = affinity_gran_default;
5059 __kmp_affinity_top_method = affinity_top_method_default;
5060 __kmp_affinity_respect_mask = affinity_respect_mask_default;
5066 aff_str = __kmp_env_blk_var(&block,
"OMP_PROC_BIND");
5067 if (aff_str != NULL) {
5068 __kmp_affinity_type = affinity_default;
5069 __kmp_affinity_gran = affinity_gran_default;
5070 __kmp_affinity_top_method = affinity_top_method_default;
5071 __kmp_affinity_respect_mask = affinity_respect_mask_default;
5080 if (__kmp_nested_proc_bind.bind_types == NULL) {
5081 __kmp_nested_proc_bind.bind_types =
5082 (kmp_proc_bind_t *)KMP_INTERNAL_MALLOC(
sizeof(kmp_proc_bind_t));
5083 if (__kmp_nested_proc_bind.bind_types == NULL) {
5084 KMP_FATAL(MemoryAllocFailed);
5086 __kmp_nested_proc_bind.size = 1;
5087 __kmp_nested_proc_bind.used = 1;
5088 #if KMP_AFFINITY_SUPPORTED 5089 __kmp_nested_proc_bind.bind_types[0] = proc_bind_default;
5092 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
5098 for (i = 0; i < block.count; ++i) {
5099 __kmp_stg_parse(block.vars[i].name, block.vars[i].value);
5103 if (!__kmp_init_user_locks) {
5104 if (__kmp_user_lock_kind == lk_default) {
5105 __kmp_user_lock_kind = lk_queuing;
5107 #if KMP_USE_DYNAMIC_LOCK 5108 __kmp_init_dynamic_user_locks();
5110 __kmp_set_user_lock_vptrs(__kmp_user_lock_kind);
5113 KMP_DEBUG_ASSERT(
string != NULL);
5114 KMP_DEBUG_ASSERT(__kmp_user_lock_kind != lk_default);
5119 #if KMP_USE_DYNAMIC_LOCK 5120 __kmp_init_dynamic_user_locks();
5122 __kmp_set_user_lock_vptrs(__kmp_user_lock_kind);
5126 #if KMP_AFFINITY_SUPPORTED 5128 if (!TCR_4(__kmp_init_middle)) {
5131 const char *var =
"KMP_AFFINITY";
5132 KMPAffinity::pick_api();
5137 if (__kmp_affinity_top_method == affinity_top_method_hwloc &&
5138 __kmp_affinity_dispatch->get_api_type() != KMPAffinity::HWLOC) {
5139 KMP_WARNING(AffIgnoringHwloc, var);
5140 __kmp_affinity_top_method = affinity_top_method_all;
5143 if (__kmp_affinity_type == affinity_disabled) {
5144 KMP_AFFINITY_DISABLE();
5145 }
else if (!KMP_AFFINITY_CAPABLE()) {
5146 __kmp_affinity_dispatch->determine_capable(var);
5147 if (!KMP_AFFINITY_CAPABLE()) {
5148 if (__kmp_affinity_verbose ||
5149 (__kmp_affinity_warnings &&
5150 (__kmp_affinity_type != affinity_default) &&
5151 (__kmp_affinity_type != affinity_none) &&
5152 (__kmp_affinity_type != affinity_disabled))) {
5153 KMP_WARNING(AffNotSupported, var);
5155 __kmp_affinity_type = affinity_disabled;
5156 __kmp_affinity_respect_mask = 0;
5157 __kmp_affinity_gran = affinity_gran_fine;
5162 if (__kmp_affinity_type == affinity_disabled) {
5163 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
5164 }
else if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_true) {
5166 __kmp_nested_proc_bind.bind_types[0] = proc_bind_spread;
5170 if (KMP_AFFINITY_CAPABLE()) {
5172 #if KMP_GROUP_AFFINITY 5177 bool exactly_one_group =
false;
5178 if (__kmp_num_proc_groups > 1) {
5180 bool within_one_group;
5183 kmp_affin_mask_t *init_mask;
5184 KMP_CPU_ALLOC(init_mask);
5185 __kmp_get_system_affinity(init_mask, TRUE);
5186 group = __kmp_get_proc_group(init_mask);
5187 within_one_group = (group >= 0);
5190 if (within_one_group) {
5191 DWORD num_bits_in_group = __kmp_GetActiveProcessorCount(group);
5192 int num_bits_in_mask = 0;
5193 for (
int bit = init_mask->begin(); bit != init_mask->end();
5194 bit = init_mask->next(bit))
5196 exactly_one_group = (num_bits_in_group == num_bits_in_mask);
5198 KMP_CPU_FREE(init_mask);
5204 if (((__kmp_num_proc_groups > 1) &&
5205 (__kmp_affinity_type == affinity_default)
5207 && (__kmp_nested_proc_bind.bind_types[0] == proc_bind_default))
5209 || (__kmp_affinity_top_method == affinity_top_method_group)) {
5210 if (__kmp_affinity_respect_mask == affinity_respect_mask_default &&
5211 exactly_one_group) {
5212 __kmp_affinity_respect_mask = FALSE;
5214 if (__kmp_affinity_type == affinity_default) {
5215 __kmp_affinity_type = affinity_compact;
5217 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
5220 if (__kmp_affinity_top_method == affinity_top_method_default) {
5221 if (__kmp_affinity_gran == affinity_gran_default) {
5222 __kmp_affinity_top_method = affinity_top_method_group;
5223 __kmp_affinity_gran = affinity_gran_group;
5224 }
else if (__kmp_affinity_gran == affinity_gran_group) {
5225 __kmp_affinity_top_method = affinity_top_method_group;
5227 __kmp_affinity_top_method = affinity_top_method_all;
5229 }
else if (__kmp_affinity_top_method == affinity_top_method_group) {
5230 if (__kmp_affinity_gran == affinity_gran_default) {
5231 __kmp_affinity_gran = affinity_gran_group;
5232 }
else if ((__kmp_affinity_gran != affinity_gran_group) &&
5233 (__kmp_affinity_gran != affinity_gran_fine) &&
5234 (__kmp_affinity_gran != affinity_gran_thread)) {
5235 const char *str = NULL;
5236 switch (__kmp_affinity_gran) {
5237 case affinity_gran_core:
5240 case affinity_gran_package:
5243 case affinity_gran_node:
5246 case affinity_gran_tile:
5250 KMP_DEBUG_ASSERT(0);
5252 KMP_WARNING(AffGranTopGroup, var, str);
5253 __kmp_affinity_gran = affinity_gran_fine;
5256 if (__kmp_affinity_gran == affinity_gran_default) {
5257 __kmp_affinity_gran = affinity_gran_core;
5258 }
else if (__kmp_affinity_gran == affinity_gran_group) {
5259 const char *str = NULL;
5260 switch (__kmp_affinity_type) {
5261 case affinity_physical:
5264 case affinity_logical:
5267 case affinity_compact:
5270 case affinity_scatter:
5273 case affinity_explicit:
5278 KMP_DEBUG_ASSERT(0);
5280 KMP_WARNING(AffGranGroupType, var, str);
5281 __kmp_affinity_gran = affinity_gran_core;
5289 if (__kmp_affinity_respect_mask == affinity_respect_mask_default) {
5290 #if KMP_GROUP_AFFINITY 5291 if (__kmp_num_proc_groups > 1 && exactly_one_group) {
5292 __kmp_affinity_respect_mask = FALSE;
5296 __kmp_affinity_respect_mask = TRUE;
5300 if ((__kmp_nested_proc_bind.bind_types[0] != proc_bind_intel) &&
5301 (__kmp_nested_proc_bind.bind_types[0] != proc_bind_default)) {
5302 if (__kmp_affinity_type == affinity_default) {
5303 __kmp_affinity_type = affinity_compact;
5304 __kmp_affinity_dups = FALSE;
5308 if (__kmp_affinity_type == affinity_default) {
5310 #if KMP_MIC_SUPPORTED 5311 if (__kmp_mic_type != non_mic) {
5312 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
5316 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
5319 #if KMP_MIC_SUPPORTED 5320 if (__kmp_mic_type != non_mic) {
5321 __kmp_affinity_type = affinity_scatter;
5325 __kmp_affinity_type = affinity_none;
5328 if ((__kmp_affinity_gran == affinity_gran_default) &&
5329 (__kmp_affinity_gran_levels < 0)) {
5330 #if KMP_MIC_SUPPORTED 5331 if (__kmp_mic_type != non_mic) {
5332 __kmp_affinity_gran = affinity_gran_fine;
5336 __kmp_affinity_gran = affinity_gran_core;
5339 if (__kmp_affinity_top_method == affinity_top_method_default) {
5340 __kmp_affinity_top_method = affinity_top_method_all;
5345 K_DIAG(1, (
"__kmp_affinity_type == %d\n", __kmp_affinity_type));
5346 K_DIAG(1, (
"__kmp_affinity_compact == %d\n", __kmp_affinity_compact));
5347 K_DIAG(1, (
"__kmp_affinity_offset == %d\n", __kmp_affinity_offset));
5348 K_DIAG(1, (
"__kmp_affinity_verbose == %d\n", __kmp_affinity_verbose));
5349 K_DIAG(1, (
"__kmp_affinity_warnings == %d\n", __kmp_affinity_warnings));
5350 K_DIAG(1, (
"__kmp_affinity_respect_mask == %d\n",
5351 __kmp_affinity_respect_mask));
5352 K_DIAG(1, (
"__kmp_affinity_gran == %d\n", __kmp_affinity_gran));
5354 KMP_DEBUG_ASSERT(__kmp_affinity_type != affinity_default);
5356 KMP_DEBUG_ASSERT(__kmp_nested_proc_bind.bind_types[0] != proc_bind_default);
5362 if (__kmp_version) {
5363 __kmp_print_version_1();
5368 if (
string != NULL) {
5369 __kmp_aux_env_initialize(&block);
5372 __kmp_env_blk_free(&block);
5378 void __kmp_env_print() {
5380 kmp_env_blk_t block;
5382 kmp_str_buf_t buffer;
5385 __kmp_str_buf_init(&buffer);
5387 __kmp_env_blk_init(&block, NULL);
5388 __kmp_env_blk_sort(&block);
5391 __kmp_str_buf_print(&buffer,
"\n%s\n\n", KMP_I18N_STR(UserSettings));
5392 for (i = 0; i < block.count; ++i) {
5393 char const *name = block.vars[i].name;
5394 char const *value = block.vars[i].value;
5395 if ((KMP_STRLEN(name) > 4 && strncmp(name,
"KMP_", 4) == 0) ||
5396 strncmp(name,
"OMP_", 4) == 0
5397 #ifdef KMP_GOMP_COMPAT
5398 || strncmp(name,
"GOMP_", 5) == 0
5401 __kmp_str_buf_print(&buffer,
" %s=%s\n", name, value);
5404 __kmp_str_buf_print(&buffer,
"\n");
5407 __kmp_str_buf_print(&buffer,
"%s\n\n", KMP_I18N_STR(EffectiveSettings));
5408 for (
int i = 0; i < __kmp_stg_count; ++i) {
5409 if (__kmp_stg_table[i].print != NULL) {
5410 __kmp_stg_table[i].print(&buffer, __kmp_stg_table[i].name,
5411 __kmp_stg_table[i].data);
5415 __kmp_printf(
"%s", buffer.str);
5417 __kmp_env_blk_free(&block);
5418 __kmp_str_buf_free(&buffer);
5425 void __kmp_env_print_2() {
5427 kmp_env_blk_t block;
5428 kmp_str_buf_t buffer;
5430 __kmp_env_format = 1;
5433 __kmp_str_buf_init(&buffer);
5435 __kmp_env_blk_init(&block, NULL);
5436 __kmp_env_blk_sort(&block);
5438 __kmp_str_buf_print(&buffer,
"\n%s\n", KMP_I18N_STR(DisplayEnvBegin));
5439 __kmp_str_buf_print(&buffer,
" _OPENMP='%d'\n", __kmp_openmp_version);
5441 for (
int i = 0; i < __kmp_stg_count; ++i) {
5442 if (__kmp_stg_table[i].print != NULL &&
5443 ((__kmp_display_env &&
5444 strncmp(__kmp_stg_table[i].name,
"OMP_", 4) == 0) ||
5445 __kmp_display_env_verbose)) {
5446 __kmp_stg_table[i].print(&buffer, __kmp_stg_table[i].name,
5447 __kmp_stg_table[i].data);
5451 __kmp_str_buf_print(&buffer,
"%s\n", KMP_I18N_STR(DisplayEnvEnd));
5452 __kmp_str_buf_print(&buffer,
"\n");
5454 __kmp_printf(
"%s", buffer.str);
5456 __kmp_env_blk_free(&block);
5457 __kmp_str_buf_free(&buffer);
5462 #endif // OMP_40_ENABLED