15 #include "kmp_affinity.h" 16 #include "kmp_atomic.h" 17 #if KMP_USE_HIER_SCHED 18 #include "kmp_dispatch_hier.h" 20 #include "kmp_environment.h" 25 #include "kmp_settings.h" 27 #include "kmp_wrapper_getpid.h" 30 static int __kmp_env_toPrint(
char const *name,
int flag);
32 bool __kmp_env_format = 0;
37 static double __kmp_convert_to_double(
char const *s) {
40 if (KMP_SSCANF(s,
"%lf", &result) < 1) {
48 static unsigned int __kmp_readstr_with_sentinel(
char *dest,
char const *src,
49 size_t len,
char sentinel) {
51 for (i = 0; i < len; i++) {
52 if ((*src ==
'\0') || (*src == sentinel)) {
62 static int __kmp_match_with_sentinel(
char const *a,
char const *b,
size_t len,
70 while (*a && *b && *b != sentinel) {
71 char ca = *a, cb = *b;
73 if (ca >=
'a' && ca <=
'z')
75 if (cb >=
'a' && cb <=
'z')
109 static int __kmp_match_str(
char const *token,
char const *buf,
112 KMP_ASSERT(token != NULL);
113 KMP_ASSERT(buf != NULL);
114 KMP_ASSERT(end != NULL);
116 while (*token && *buf) {
117 char ct = *token, cb = *buf;
119 if (ct >=
'a' && ct <=
'z')
121 if (cb >=
'a' && cb <=
'z')
135 static size_t __kmp_round4k(
size_t size) {
136 size_t _4k = 4 * 1024;
137 if (size & (_4k - 1)) {
139 if (size <= KMP_SIZE_T_MAX - _4k) {
150 int __kmp_convert_to_milliseconds(
char const *data) {
151 int ret, nvalues, factor;
157 if (__kmp_str_match(
"infinit", -1, data))
161 nvalues = KMP_SSCANF(data,
"%lf%c%c", &value, &mult, &extra);
187 factor = 1000 * 60 * 60;
191 factor = 1000 * 24 * 60 * 60;
197 if (value >= ((INT_MAX - 1) / factor))
200 ret = (int)(value * (
double)factor);
205 static int __kmp_strcasecmp_with_sentinel(
char const *a,
char const *b,
211 while (*a && *b && *b != sentinel) {
212 char ca = *a, cb = *b;
214 if (ca >=
'a' && ca <=
'z')
216 if (cb >=
'a' && cb <=
'z')
219 return (
int)(
unsigned char)*a - (
int)(
unsigned char)*b;
224 ? (*b && *b != sentinel)
225 ? (
int)(
unsigned char)*a - (
int)(
unsigned char)*b
227 : (*b && *b != sentinel) ? -1 : 0;
233 typedef struct __kmp_setting kmp_setting_t;
234 typedef struct __kmp_stg_ss_data kmp_stg_ss_data_t;
235 typedef struct __kmp_stg_wp_data kmp_stg_wp_data_t;
236 typedef struct __kmp_stg_fr_data kmp_stg_fr_data_t;
238 typedef void (*kmp_stg_parse_func_t)(
char const *name,
char const *value,
240 typedef void (*kmp_stg_print_func_t)(kmp_str_buf_t *buffer,
char const *name,
243 struct __kmp_setting {
245 kmp_stg_parse_func_t parse;
246 kmp_stg_print_func_t print;
253 struct __kmp_stg_ss_data {
255 kmp_setting_t **rivals;
258 struct __kmp_stg_wp_data {
260 kmp_setting_t **rivals;
263 struct __kmp_stg_fr_data {
265 kmp_setting_t **rivals;
268 static int __kmp_stg_check_rivals(
271 kmp_setting_t **rivals
277 static void __kmp_stg_parse_bool(
char const *name,
char const *value,
279 if (__kmp_str_match_true(value)) {
281 }
else if (__kmp_str_match_false(value)) {
284 __kmp_msg(kmp_ms_warning, KMP_MSG(BadBoolValue, name, value),
285 KMP_HNT(ValidBoolValues), __kmp_msg_null);
289 static void __kmp_stg_parse_size(
char const *name,
char const *value,
290 size_t size_min,
size_t size_max,
291 int *is_specified,
size_t *out,
293 char const *msg = NULL;
295 size_min = __kmp_round4k(size_min);
296 size_max = __kmp_round4k(size_max);
297 #endif // KMP_OS_DARWIN 299 if (is_specified != NULL) {
302 __kmp_str_to_size(value, out, factor, &msg);
304 if (*out > size_max) {
306 msg = KMP_I18N_STR(ValueTooLarge);
307 }
else if (*out < size_min) {
309 msg = KMP_I18N_STR(ValueTooSmall);
312 size_t round4k = __kmp_round4k(*out);
313 if (*out != round4k) {
315 msg = KMP_I18N_STR(NotMultiple4K);
322 if (*out < size_min) {
324 }
else if (*out > size_max) {
331 __kmp_str_buf_init(&buf);
332 __kmp_str_buf_print_size(&buf, *out);
333 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
334 KMP_INFORM(Using_str_Value, name, buf.str);
335 __kmp_str_buf_free(&buf);
340 static void __kmp_stg_parse_str(
char const *name,
char const *value,
343 *out = __kmp_str_format(
"%s", value);
346 static void __kmp_stg_parse_int(
354 char const *msg = NULL;
355 kmp_uint64 uint = *out;
356 __kmp_str_to_uint(value, &uint, &msg);
358 if (uint < (
unsigned int)min) {
359 msg = KMP_I18N_STR(ValueTooSmall);
361 }
else if (uint > (
unsigned int)max) {
362 msg = KMP_I18N_STR(ValueTooLarge);
368 if (uint < (
unsigned int)min) {
370 }
else if (uint > (
unsigned int)max) {
377 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
378 __kmp_str_buf_init(&buf);
379 __kmp_str_buf_print(&buf,
"%" KMP_UINT64_SPEC
"", uint);
380 KMP_INFORM(Using_uint64_Value, name, buf.str);
381 __kmp_str_buf_free(&buf);
386 #if KMP_DEBUG_ADAPTIVE_LOCKS 387 static void __kmp_stg_parse_file(
char const *name,
char const *value,
388 const char *suffix,
char **out) {
393 t = (
char *)strrchr(value,
'.');
394 hasSuffix = t && __kmp_str_eqf(t, suffix);
395 t = __kmp_str_format(
"%s%s", value, hasSuffix ?
"" : suffix);
396 __kmp_expand_file_name(buffer,
sizeof(buffer), t);
398 *out = __kmp_str_format(
"%s", buffer);
403 static char *par_range_to_print = NULL;
405 static void __kmp_stg_parse_par_range(
char const *name,
char const *value,
406 int *out_range,
char *out_routine,
407 char *out_file,
int *out_lb,
409 size_t len = KMP_STRLEN(value + 1);
410 par_range_to_print = (
char *)KMP_INTERNAL_MALLOC(len + 1);
411 KMP_STRNCPY_S(par_range_to_print, len + 1, value, len + 1);
412 __kmp_par_range = +1;
413 __kmp_par_range_lb = 0;
414 __kmp_par_range_ub = INT_MAX;
417 if ((value == NULL) || (*value ==
'\0')) {
420 if (!__kmp_strcasecmp_with_sentinel(
"routine", value,
'=')) {
421 value = strchr(value,
'=') + 1;
422 len = __kmp_readstr_with_sentinel(out_routine, value,
423 KMP_PAR_RANGE_ROUTINE_LEN - 1,
',');
425 goto par_range_error;
427 value = strchr(value,
',');
433 if (!__kmp_strcasecmp_with_sentinel(
"filename", value,
'=')) {
434 value = strchr(value,
'=') + 1;
435 len = __kmp_readstr_with_sentinel(out_file, value,
436 KMP_PAR_RANGE_FILENAME_LEN - 1,
',');
438 goto par_range_error;
440 value = strchr(value,
',');
446 if ((!__kmp_strcasecmp_with_sentinel(
"range", value,
'=')) ||
447 (!__kmp_strcasecmp_with_sentinel(
"incl_range", value,
'='))) {
448 value = strchr(value,
'=') + 1;
449 if (KMP_SSCANF(value,
"%d:%d", out_lb, out_ub) != 2) {
450 goto par_range_error;
453 value = strchr(value,
',');
459 if (!__kmp_strcasecmp_with_sentinel(
"excl_range", value,
'=')) {
460 value = strchr(value,
'=') + 1;
461 if (KMP_SSCANF(value,
"%d:%d", out_lb, out_ub) != 2) {
462 goto par_range_error;
465 value = strchr(value,
',');
472 KMP_WARNING(ParRangeSyntax, name);
479 int __kmp_initial_threads_capacity(
int req_nproc) {
484 if (nth < (4 * req_nproc))
485 nth = (4 * req_nproc);
486 if (nth < (4 * __kmp_xproc))
487 nth = (4 * __kmp_xproc);
489 if (nth > __kmp_max_nth)
495 int __kmp_default_tp_capacity(
int req_nproc,
int max_nth,
496 int all_threads_specified) {
499 if (all_threads_specified)
503 if (nth < (4 * req_nproc))
504 nth = (4 * req_nproc);
505 if (nth < (4 * __kmp_xproc))
506 nth = (4 * __kmp_xproc);
508 if (nth > __kmp_max_nth)
517 static void __kmp_stg_print_bool(kmp_str_buf_t *buffer,
char const *name,
519 if (__kmp_env_format) {
520 KMP_STR_BUF_PRINT_BOOL;
522 __kmp_str_buf_print(buffer,
" %s=%s\n", name, value ?
"true" :
"false");
526 static void __kmp_stg_print_int(kmp_str_buf_t *buffer,
char const *name,
528 if (__kmp_env_format) {
529 KMP_STR_BUF_PRINT_INT;
531 __kmp_str_buf_print(buffer,
" %s=%d\n", name, value);
535 static void __kmp_stg_print_uint64(kmp_str_buf_t *buffer,
char const *name,
537 if (__kmp_env_format) {
538 KMP_STR_BUF_PRINT_UINT64;
540 __kmp_str_buf_print(buffer,
" %s=%" KMP_UINT64_SPEC
"\n", name, value);
544 static void __kmp_stg_print_str(kmp_str_buf_t *buffer,
char const *name,
546 if (__kmp_env_format) {
547 KMP_STR_BUF_PRINT_STR;
549 __kmp_str_buf_print(buffer,
" %s=%s\n", name, value);
553 static void __kmp_stg_print_size(kmp_str_buf_t *buffer,
char const *name,
555 if (__kmp_env_format) {
556 KMP_STR_BUF_PRINT_NAME_EX(name);
557 __kmp_str_buf_print_size(buffer, value);
558 __kmp_str_buf_print(buffer,
"'\n");
560 __kmp_str_buf_print(buffer,
" %s=", name);
561 __kmp_str_buf_print_size(buffer, value);
562 __kmp_str_buf_print(buffer,
"\n");
573 static void __kmp_stg_parse_device_thread_limit(
char const *name,
574 char const *value,
void *data) {
575 kmp_setting_t **rivals = (kmp_setting_t **)data;
577 if (strcmp(name,
"KMP_ALL_THREADS") == 0) {
578 KMP_INFORM(EnvVarDeprecated, name,
"KMP_DEVICE_THREAD_LIMIT");
580 rc = __kmp_stg_check_rivals(name, value, rivals);
584 if (!__kmp_strcasecmp_with_sentinel(
"all", value, 0)) {
585 __kmp_max_nth = __kmp_xproc;
586 __kmp_allThreadsSpecified = 1;
588 __kmp_stg_parse_int(name, value, 1, __kmp_sys_max_nth, &__kmp_max_nth);
589 __kmp_allThreadsSpecified = 0;
591 K_DIAG(1, (
"__kmp_max_nth == %d\n", __kmp_max_nth));
595 static void __kmp_stg_print_device_thread_limit(kmp_str_buf_t *buffer,
596 char const *name,
void *data) {
597 __kmp_stg_print_int(buffer, name, __kmp_max_nth);
602 static void __kmp_stg_parse_thread_limit(
char const *name,
char const *value,
604 __kmp_stg_parse_int(name, value, 1, __kmp_sys_max_nth, &__kmp_cg_max_nth);
605 K_DIAG(1, (
"__kmp_cg_max_nth == %d\n", __kmp_cg_max_nth));
609 static void __kmp_stg_print_thread_limit(kmp_str_buf_t *buffer,
610 char const *name,
void *data) {
611 __kmp_stg_print_int(buffer, name, __kmp_cg_max_nth);
616 static void __kmp_stg_parse_teams_thread_limit(
char const *name,
617 char const *value,
void *data) {
618 __kmp_stg_parse_int(name, value, 1, __kmp_sys_max_nth, &__kmp_teams_max_nth);
621 static void __kmp_stg_print_teams_thread_limit(kmp_str_buf_t *buffer,
622 char const *name,
void *data) {
623 __kmp_stg_print_int(buffer, name, __kmp_teams_max_nth);
629 static void __kmp_stg_parse_blocktime(
char const *name,
char const *value,
631 __kmp_dflt_blocktime = __kmp_convert_to_milliseconds(value);
632 if (__kmp_dflt_blocktime < 0) {
633 __kmp_dflt_blocktime = KMP_DEFAULT_BLOCKTIME;
634 __kmp_msg(kmp_ms_warning, KMP_MSG(InvalidValue, name, value),
636 KMP_INFORM(Using_int_Value, name, __kmp_dflt_blocktime);
637 __kmp_env_blocktime = FALSE;
639 if (__kmp_dflt_blocktime < KMP_MIN_BLOCKTIME) {
640 __kmp_dflt_blocktime = KMP_MIN_BLOCKTIME;
641 __kmp_msg(kmp_ms_warning, KMP_MSG(SmallValue, name, value),
643 KMP_INFORM(MinValueUsing, name, __kmp_dflt_blocktime);
644 }
else if (__kmp_dflt_blocktime > KMP_MAX_BLOCKTIME) {
645 __kmp_dflt_blocktime = KMP_MAX_BLOCKTIME;
646 __kmp_msg(kmp_ms_warning, KMP_MSG(LargeValue, name, value),
648 KMP_INFORM(MaxValueUsing, name, __kmp_dflt_blocktime);
650 __kmp_env_blocktime = TRUE;
655 __kmp_monitor_wakeups =
656 KMP_WAKEUPS_FROM_BLOCKTIME(__kmp_dflt_blocktime, __kmp_monitor_wakeups);
658 KMP_INTERVALS_FROM_BLOCKTIME(__kmp_dflt_blocktime, __kmp_monitor_wakeups);
660 K_DIAG(1, (
"__kmp_env_blocktime == %d\n", __kmp_env_blocktime));
661 if (__kmp_env_blocktime) {
662 K_DIAG(1, (
"__kmp_dflt_blocktime == %d\n", __kmp_dflt_blocktime));
666 static void __kmp_stg_print_blocktime(kmp_str_buf_t *buffer,
char const *name,
668 __kmp_stg_print_int(buffer, name, __kmp_dflt_blocktime);
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);
706 static char const *blocktime_str = NULL;
711 static void __kmp_stg_parse_wait_policy(
char const *name,
char const *value,
714 kmp_stg_wp_data_t *wait = (kmp_stg_wp_data_t *)data;
717 rc = __kmp_stg_check_rivals(name, value, wait->rivals);
723 if (__kmp_str_match(
"ACTIVE", 1, value)) {
724 __kmp_library = library_turnaround;
725 if (blocktime_str == NULL) {
727 __kmp_dflt_blocktime = KMP_MAX_BLOCKTIME;
729 }
else if (__kmp_str_match(
"PASSIVE", 1, value)) {
730 __kmp_library = library_throughput;
731 if (blocktime_str == NULL) {
733 __kmp_dflt_blocktime = 0;
736 KMP_WARNING(StgInvalidValue, name, value);
739 if (__kmp_str_match(
"serial", 1, value)) {
740 __kmp_library = library_serial;
741 }
else if (__kmp_str_match(
"throughput", 2, value)) {
742 __kmp_library = library_throughput;
743 }
else if (__kmp_str_match(
"turnaround", 2, value)) {
744 __kmp_library = library_turnaround;
745 }
else if (__kmp_str_match(
"dedicated", 1, value)) {
746 __kmp_library = library_turnaround;
747 }
else if (__kmp_str_match(
"multiuser", 1, value)) {
748 __kmp_library = library_throughput;
750 KMP_WARNING(StgInvalidValue, name, value);
753 __kmp_aux_set_library(__kmp_library);
757 static void __kmp_stg_print_wait_policy(kmp_str_buf_t *buffer,
char const *name,
760 kmp_stg_wp_data_t *wait = (kmp_stg_wp_data_t *)data;
761 char const *value = NULL;
764 switch (__kmp_library) {
765 case library_turnaround: {
768 case library_throughput: {
773 switch (__kmp_library) {
774 case library_serial: {
777 case library_turnaround: {
778 value =
"turnaround";
780 case library_throughput: {
781 value =
"throughput";
786 __kmp_stg_print_str(buffer, name, value);
795 static void __kmp_stg_parse_monitor_stacksize(
char const *name,
796 char const *value,
void *data) {
797 __kmp_stg_parse_size(name, value, __kmp_sys_min_stksize, KMP_MAX_STKSIZE,
798 NULL, &__kmp_monitor_stksize, 1);
801 static void __kmp_stg_print_monitor_stacksize(kmp_str_buf_t *buffer,
802 char const *name,
void *data) {
803 if (__kmp_env_format) {
804 if (__kmp_monitor_stksize > 0)
805 KMP_STR_BUF_PRINT_NAME_EX(name);
807 KMP_STR_BUF_PRINT_NAME;
809 __kmp_str_buf_print(buffer,
" %s", name);
811 if (__kmp_monitor_stksize > 0) {
812 __kmp_str_buf_print_size(buffer, __kmp_monitor_stksize);
814 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
816 if (__kmp_env_format && __kmp_monitor_stksize) {
817 __kmp_str_buf_print(buffer,
"'\n");
820 #endif // KMP_USE_MONITOR 825 static void __kmp_stg_parse_settings(
char const *name,
char const *value,
827 __kmp_stg_parse_bool(name, value, &__kmp_settings);
830 static void __kmp_stg_print_settings(kmp_str_buf_t *buffer,
char const *name,
832 __kmp_stg_print_bool(buffer, name, __kmp_settings);
838 static void __kmp_stg_parse_stackpad(
char const *name,
char const *value,
840 __kmp_stg_parse_int(name,
848 static void __kmp_stg_print_stackpad(kmp_str_buf_t *buffer,
char const *name,
850 __kmp_stg_print_int(buffer, name, __kmp_stkpadding);
856 static void __kmp_stg_parse_stackoffset(
char const *name,
char const *value,
858 __kmp_stg_parse_size(name,
867 static void __kmp_stg_print_stackoffset(kmp_str_buf_t *buffer,
char const *name,
869 __kmp_stg_print_size(buffer, name, __kmp_stkoffset);
875 static void __kmp_stg_parse_stacksize(
char const *name,
char const *value,
878 kmp_stg_ss_data_t *stacksize = (kmp_stg_ss_data_t *)data;
881 rc = __kmp_stg_check_rivals(name, value, stacksize->rivals);
885 __kmp_stg_parse_size(name,
887 __kmp_sys_min_stksize,
899 static void __kmp_stg_print_stacksize(kmp_str_buf_t *buffer,
char const *name,
901 kmp_stg_ss_data_t *stacksize = (kmp_stg_ss_data_t *)data;
902 if (__kmp_env_format) {
903 KMP_STR_BUF_PRINT_NAME_EX(name);
904 __kmp_str_buf_print_size(buffer, (__kmp_stksize % 1024)
905 ? __kmp_stksize / stacksize->factor
907 __kmp_str_buf_print(buffer,
"'\n");
909 __kmp_str_buf_print(buffer,
" %s=", name);
910 __kmp_str_buf_print_size(buffer, (__kmp_stksize % 1024)
911 ? __kmp_stksize / stacksize->factor
913 __kmp_str_buf_print(buffer,
"\n");
920 static void __kmp_stg_parse_version(
char const *name,
char const *value,
922 __kmp_stg_parse_bool(name, value, &__kmp_version);
925 static void __kmp_stg_print_version(kmp_str_buf_t *buffer,
char const *name,
927 __kmp_stg_print_bool(buffer, name, __kmp_version);
933 static void __kmp_stg_parse_warnings(
char const *name,
char const *value,
935 __kmp_stg_parse_bool(name, value, &__kmp_generate_warnings);
936 if (__kmp_generate_warnings != kmp_warnings_off) {
939 __kmp_generate_warnings = kmp_warnings_explicit;
943 static void __kmp_stg_print_warnings(kmp_str_buf_t *buffer,
char const *name,
946 __kmp_stg_print_bool(buffer, name, __kmp_generate_warnings);
952 static void __kmp_stg_parse_nested(
char const *name,
char const *value,
954 __kmp_stg_parse_bool(name, value, &__kmp_dflt_nested);
957 static void __kmp_stg_print_nested(kmp_str_buf_t *buffer,
char const *name,
959 __kmp_stg_print_bool(buffer, name, __kmp_dflt_nested);
962 static void __kmp_parse_nested_num_threads(
const char *var,
const char *env,
963 kmp_nested_nthreads_t *nth_array) {
964 const char *next = env;
965 const char *scan = next;
968 int prev_comma = FALSE;
978 if (((*next <
'0') || (*next >
'9')) && (*next !=
',')) {
979 KMP_WARNING(NthSyntaxError, var, env);
985 if (total == 0 || prev_comma) {
993 if (*next >=
'0' && *next <=
'9') {
997 const char *tmp = next;
999 if ((*next ==
' ' || *next ==
'\t') && (*tmp >=
'0' && *tmp <=
'9')) {
1000 KMP_WARNING(NthSpacesNotAllowed, var, env);
1005 KMP_DEBUG_ASSERT(total > 0);
1007 KMP_WARNING(NthSyntaxError, var, env);
1012 if (!nth_array->nth) {
1014 nth_array->nth = (
int *)KMP_INTERNAL_MALLOC(
sizeof(
int) * total * 2);
1015 if (nth_array->nth == NULL) {
1016 KMP_FATAL(MemoryAllocFailed);
1018 nth_array->size = total * 2;
1020 if (nth_array->size < total) {
1023 nth_array->size *= 2;
1024 }
while (nth_array->size < total);
1026 nth_array->nth = (
int *)KMP_INTERNAL_REALLOC(
1027 nth_array->nth,
sizeof(
int) * nth_array->size);
1028 if (nth_array->nth == NULL) {
1029 KMP_FATAL(MemoryAllocFailed);
1033 nth_array->used = total;
1041 if (*scan ==
'\0') {
1051 nth_array->nth[i++] = 0;
1053 }
else if (prev_comma) {
1055 nth_array->nth[i] = nth_array->nth[i - 1];
1064 if (*scan >=
'0' && *scan <=
'9') {
1066 const char *buf = scan;
1067 char const *msg = NULL;
1072 num = __kmp_str_to_int(buf, *scan);
1073 if (num < KMP_MIN_NTH) {
1074 msg = KMP_I18N_STR(ValueTooSmall);
1076 }
else if (num > __kmp_sys_max_nth) {
1077 msg = KMP_I18N_STR(ValueTooLarge);
1078 num = __kmp_sys_max_nth;
1082 KMP_WARNING(ParseSizeIntWarn, var, env, msg);
1083 KMP_INFORM(Using_int_Value, var, num);
1085 nth_array->nth[i++] = num;
1090 static void __kmp_stg_parse_num_threads(
char const *name,
char const *value,
1093 if (!__kmp_strcasecmp_with_sentinel(
"all", value, 0)) {
1095 __kmp_nested_nth.nth = (
int *)KMP_INTERNAL_MALLOC(
sizeof(
int));
1096 __kmp_nested_nth.size = __kmp_nested_nth.used = 1;
1097 __kmp_nested_nth.nth[0] = __kmp_dflt_team_nth = __kmp_dflt_team_nth_ub =
1100 __kmp_parse_nested_num_threads(name, value, &__kmp_nested_nth);
1101 if (__kmp_nested_nth.nth) {
1102 __kmp_dflt_team_nth = __kmp_nested_nth.nth[0];
1103 if (__kmp_dflt_team_nth_ub < __kmp_dflt_team_nth) {
1104 __kmp_dflt_team_nth_ub = __kmp_dflt_team_nth;
1108 K_DIAG(1, (
"__kmp_dflt_team_nth == %d\n", __kmp_dflt_team_nth));
1111 static void __kmp_stg_print_num_threads(kmp_str_buf_t *buffer,
char const *name,
1113 if (__kmp_env_format) {
1114 KMP_STR_BUF_PRINT_NAME;
1116 __kmp_str_buf_print(buffer,
" %s", name);
1118 if (__kmp_nested_nth.used) {
1120 __kmp_str_buf_init(&buf);
1121 for (
int i = 0; i < __kmp_nested_nth.used; i++) {
1122 __kmp_str_buf_print(&buf,
"%d", __kmp_nested_nth.nth[i]);
1123 if (i < __kmp_nested_nth.used - 1) {
1124 __kmp_str_buf_print(&buf,
",");
1127 __kmp_str_buf_print(buffer,
"='%s'\n", buf.str);
1128 __kmp_str_buf_free(&buf);
1130 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
1137 static void __kmp_stg_parse_tasking(
char const *name,
char const *value,
1139 __kmp_stg_parse_int(name, value, 0, (
int)tskm_max,
1140 (
int *)&__kmp_tasking_mode);
1143 static void __kmp_stg_print_tasking(kmp_str_buf_t *buffer,
char const *name,
1145 __kmp_stg_print_int(buffer, name, __kmp_tasking_mode);
1148 static void __kmp_stg_parse_task_stealing(
char const *name,
char const *value,
1150 __kmp_stg_parse_int(name, value, 0, 1,
1151 (
int *)&__kmp_task_stealing_constraint);
1154 static void __kmp_stg_print_task_stealing(kmp_str_buf_t *buffer,
1155 char const *name,
void *data) {
1156 __kmp_stg_print_int(buffer, name, __kmp_task_stealing_constraint);
1159 static void __kmp_stg_parse_max_active_levels(
char const *name,
1160 char const *value,
void *data) {
1161 __kmp_stg_parse_int(name, value, 0, KMP_MAX_ACTIVE_LEVELS_LIMIT,
1162 &__kmp_dflt_max_active_levels);
1165 static void __kmp_stg_print_max_active_levels(kmp_str_buf_t *buffer,
1166 char const *name,
void *data) {
1167 __kmp_stg_print_int(buffer, name, __kmp_dflt_max_active_levels);
1173 static void __kmp_stg_parse_default_device(
char const *name,
char const *value,
1175 __kmp_stg_parse_int(name, value, 0, KMP_MAX_DEFAULT_DEVICE_LIMIT,
1176 &__kmp_default_device);
1179 static void __kmp_stg_print_default_device(kmp_str_buf_t *buffer,
1180 char const *name,
void *data) {
1181 __kmp_stg_print_int(buffer, name, __kmp_default_device);
1188 static void __kmp_stg_parse_target_offload(
char const *name,
char const *value,
1190 const char *next = value;
1191 const char *scan = next;
1193 __kmp_target_offload = tgt_default;
1198 if (__kmp_match_str(
"MANDATORY", scan, &next)) {
1199 __kmp_target_offload = tgt_mandatory;
1200 }
else if (__kmp_match_str(
"DISABLED", scan, &next)) {
1201 __kmp_target_offload = tgt_disabled;
1202 }
else if (__kmp_match_str(
"DEFAULT", scan, &next)) {
1203 __kmp_target_offload = tgt_default;
1205 KMP_WARNING(SyntaxErrorUsing, name,
"DEFAULT");
1210 static void __kmp_stg_print_target_offload(kmp_str_buf_t *buffer,
1211 char const *name,
void *data) {
1212 const char *value = NULL;
1213 if (__kmp_target_offload == tgt_default)
1215 else if (__kmp_target_offload == tgt_mandatory)
1216 value =
"MANDATORY";
1217 else if (__kmp_target_offload == tgt_disabled)
1220 __kmp_str_buf_print(buffer,
" %s=%s\n", name, value);
1228 static void __kmp_stg_parse_max_task_priority(
char const *name,
1229 char const *value,
void *data) {
1230 __kmp_stg_parse_int(name, value, 0, KMP_MAX_TASK_PRIORITY_LIMIT,
1231 &__kmp_max_task_priority);
1234 static void __kmp_stg_print_max_task_priority(kmp_str_buf_t *buffer,
1235 char const *name,
void *data) {
1236 __kmp_stg_print_int(buffer, name, __kmp_max_task_priority);
1241 static void __kmp_stg_parse_taskloop_min_tasks(
char const *name,
1242 char const *value,
void *data) {
1244 __kmp_stg_parse_int(name, value, 0, INT_MAX, &tmp);
1245 __kmp_taskloop_min_tasks = tmp;
1248 static void __kmp_stg_print_taskloop_min_tasks(kmp_str_buf_t *buffer,
1249 char const *name,
void *data) {
1250 __kmp_stg_print_int(buffer, name, __kmp_taskloop_min_tasks);
1252 #endif // OMP_45_ENABLED 1256 static void __kmp_stg_parse_disp_buffers(
char const *name,
char const *value,
1258 if (TCR_4(__kmp_init_serial)) {
1259 KMP_WARNING(EnvSerialWarn, name);
1262 __kmp_stg_parse_int(name, value, 1, KMP_MAX_NTH, &__kmp_dispatch_num_buffers);
1265 static void __kmp_stg_print_disp_buffers(kmp_str_buf_t *buffer,
1266 char const *name,
void *data) {
1267 __kmp_stg_print_int(buffer, name, __kmp_dispatch_num_buffers);
1270 #if KMP_NESTED_HOT_TEAMS 1274 static void __kmp_stg_parse_hot_teams_level(
char const *name,
char const *value,
1276 if (TCR_4(__kmp_init_parallel)) {
1277 KMP_WARNING(EnvParallelWarn, name);
1280 __kmp_stg_parse_int(name, value, 0, KMP_MAX_ACTIVE_LEVELS_LIMIT,
1281 &__kmp_hot_teams_max_level);
1284 static void __kmp_stg_print_hot_teams_level(kmp_str_buf_t *buffer,
1285 char const *name,
void *data) {
1286 __kmp_stg_print_int(buffer, name, __kmp_hot_teams_max_level);
1289 static void __kmp_stg_parse_hot_teams_mode(
char const *name,
char const *value,
1291 if (TCR_4(__kmp_init_parallel)) {
1292 KMP_WARNING(EnvParallelWarn, name);
1295 __kmp_stg_parse_int(name, value, 0, KMP_MAX_ACTIVE_LEVELS_LIMIT,
1296 &__kmp_hot_teams_mode);
1299 static void __kmp_stg_print_hot_teams_mode(kmp_str_buf_t *buffer,
1300 char const *name,
void *data) {
1301 __kmp_stg_print_int(buffer, name, __kmp_hot_teams_mode);
1304 #endif // KMP_NESTED_HOT_TEAMS 1309 #if KMP_HANDLE_SIGNALS 1311 static void __kmp_stg_parse_handle_signals(
char const *name,
char const *value,
1313 __kmp_stg_parse_bool(name, value, &__kmp_handle_signals);
1316 static void __kmp_stg_print_handle_signals(kmp_str_buf_t *buffer,
1317 char const *name,
void *data) {
1318 __kmp_stg_print_bool(buffer, name, __kmp_handle_signals);
1321 #endif // KMP_HANDLE_SIGNALS 1328 #define KMP_STG_X_DEBUG(x) \ 1329 static void __kmp_stg_parse_##x##_debug(char const *name, char const *value, \ 1331 __kmp_stg_parse_int(name, value, 0, INT_MAX, &kmp_##x##_debug); \ 1333 static void __kmp_stg_print_##x##_debug(kmp_str_buf_t *buffer, \ 1334 char const *name, void *data) { \ 1335 __kmp_stg_print_int(buffer, name, kmp_##x##_debug); \ 1345 #undef KMP_STG_X_DEBUG 1347 static void __kmp_stg_parse_debug(
char const *name,
char const *value,
1350 __kmp_stg_parse_int(name, value, 0, INT_MAX, &debug);
1351 if (kmp_a_debug < debug) {
1352 kmp_a_debug = debug;
1354 if (kmp_b_debug < debug) {
1355 kmp_b_debug = debug;
1357 if (kmp_c_debug < debug) {
1358 kmp_c_debug = debug;
1360 if (kmp_d_debug < debug) {
1361 kmp_d_debug = debug;
1363 if (kmp_e_debug < debug) {
1364 kmp_e_debug = debug;
1366 if (kmp_f_debug < debug) {
1367 kmp_f_debug = debug;
1371 static void __kmp_stg_parse_debug_buf(
char const *name,
char const *value,
1373 __kmp_stg_parse_bool(name, value, &__kmp_debug_buf);
1377 if (__kmp_debug_buf) {
1379 int elements = __kmp_debug_buf_lines * __kmp_debug_buf_chars;
1382 __kmp_debug_buffer = (
char *)__kmp_page_allocate(elements *
sizeof(
char));
1383 for (i = 0; i < elements; i += __kmp_debug_buf_chars)
1384 __kmp_debug_buffer[i] =
'\0';
1386 __kmp_debug_count = 0;
1388 K_DIAG(1, (
"__kmp_debug_buf = %d\n", __kmp_debug_buf));
1391 static void __kmp_stg_print_debug_buf(kmp_str_buf_t *buffer,
char const *name,
1393 __kmp_stg_print_bool(buffer, name, __kmp_debug_buf);
1396 static void __kmp_stg_parse_debug_buf_atomic(
char const *name,
1397 char const *value,
void *data) {
1398 __kmp_stg_parse_bool(name, value, &__kmp_debug_buf_atomic);
1401 static void __kmp_stg_print_debug_buf_atomic(kmp_str_buf_t *buffer,
1402 char const *name,
void *data) {
1403 __kmp_stg_print_bool(buffer, name, __kmp_debug_buf_atomic);
1406 static void __kmp_stg_parse_debug_buf_chars(
char const *name,
char const *value,
1408 __kmp_stg_parse_int(name, value, KMP_DEBUG_BUF_CHARS_MIN, INT_MAX,
1409 &__kmp_debug_buf_chars);
1412 static void __kmp_stg_print_debug_buf_chars(kmp_str_buf_t *buffer,
1413 char const *name,
void *data) {
1414 __kmp_stg_print_int(buffer, name, __kmp_debug_buf_chars);
1417 static void __kmp_stg_parse_debug_buf_lines(
char const *name,
char const *value,
1419 __kmp_stg_parse_int(name, value, KMP_DEBUG_BUF_LINES_MIN, INT_MAX,
1420 &__kmp_debug_buf_lines);
1423 static void __kmp_stg_print_debug_buf_lines(kmp_str_buf_t *buffer,
1424 char const *name,
void *data) {
1425 __kmp_stg_print_int(buffer, name, __kmp_debug_buf_lines);
1428 static void __kmp_stg_parse_diag(
char const *name,
char const *value,
1430 __kmp_stg_parse_int(name, value, 0, INT_MAX, &kmp_diag);
1433 static void __kmp_stg_print_diag(kmp_str_buf_t *buffer,
char const *name,
1435 __kmp_stg_print_int(buffer, name, kmp_diag);
1443 static void __kmp_stg_parse_align_alloc(
char const *name,
char const *value,
1445 __kmp_stg_parse_size(name, value, CACHE_LINE, INT_MAX, NULL,
1446 &__kmp_align_alloc, 1);
1449 static void __kmp_stg_print_align_alloc(kmp_str_buf_t *buffer,
char const *name,
1451 __kmp_stg_print_size(buffer, name, __kmp_align_alloc);
1460 static void __kmp_stg_parse_barrier_branch_bit(
char const *name,
1461 char const *value,
void *data) {
1465 for (
int i = bs_plain_barrier; i < bs_last_barrier; i++) {
1466 var = __kmp_barrier_branch_bit_env_name[i];
1467 if ((strcmp(var, name) == 0) && (value != 0)) {
1470 comma = CCAST(
char *, strchr(value,
','));
1471 __kmp_barrier_gather_branch_bits[i] =
1472 (kmp_uint32)__kmp_str_to_int(value,
',');
1474 if (comma == NULL) {
1475 __kmp_barrier_release_branch_bits[i] = __kmp_barrier_release_bb_dflt;
1477 __kmp_barrier_release_branch_bits[i] =
1478 (kmp_uint32)__kmp_str_to_int(comma + 1, 0);
1480 if (__kmp_barrier_release_branch_bits[i] > KMP_MAX_BRANCH_BITS) {
1481 __kmp_msg(kmp_ms_warning,
1482 KMP_MSG(BarrReleaseValueInvalid, name, comma + 1),
1484 __kmp_barrier_release_branch_bits[i] = __kmp_barrier_release_bb_dflt;
1487 if (__kmp_barrier_gather_branch_bits[i] > KMP_MAX_BRANCH_BITS) {
1488 KMP_WARNING(BarrGatherValueInvalid, name, value);
1489 KMP_INFORM(Using_uint_Value, name, __kmp_barrier_gather_bb_dflt);
1490 __kmp_barrier_gather_branch_bits[i] = __kmp_barrier_gather_bb_dflt;
1493 K_DIAG(1, (
"%s == %d,%d\n", __kmp_barrier_branch_bit_env_name[i],
1494 __kmp_barrier_gather_branch_bits[i],
1495 __kmp_barrier_release_branch_bits[i]))
1499 static void __kmp_stg_print_barrier_branch_bit(kmp_str_buf_t *buffer,
1500 char const *name,
void *data) {
1502 for (
int i = bs_plain_barrier; i < bs_last_barrier; i++) {
1503 var = __kmp_barrier_branch_bit_env_name[i];
1504 if (strcmp(var, name) == 0) {
1505 if (__kmp_env_format) {
1506 KMP_STR_BUF_PRINT_NAME_EX(__kmp_barrier_branch_bit_env_name[i]);
1508 __kmp_str_buf_print(buffer,
" %s='",
1509 __kmp_barrier_branch_bit_env_name[i]);
1511 __kmp_str_buf_print(buffer,
"%d,%d'\n",
1512 __kmp_barrier_gather_branch_bits[i],
1513 __kmp_barrier_release_branch_bits[i]);
1525 static void __kmp_stg_parse_barrier_pattern(
char const *name,
char const *value,
1530 for (
int i = bs_plain_barrier; i < bs_last_barrier; i++) {
1531 var = __kmp_barrier_pattern_env_name[i];
1533 if ((strcmp(var, name) == 0) && (value != 0)) {
1535 char *comma = CCAST(
char *, strchr(value,
','));
1538 for (j = bp_linear_bar; j < bp_last_bar; j++) {
1539 if (__kmp_match_with_sentinel(__kmp_barrier_pattern_name[j], value, 1,
1541 __kmp_barrier_gather_pattern[i] = (kmp_bar_pat_e)j;
1545 if (j == bp_last_bar) {
1546 KMP_WARNING(BarrGatherValueInvalid, name, value);
1547 KMP_INFORM(Using_str_Value, name,
1548 __kmp_barrier_pattern_name[bp_linear_bar]);
1552 if (comma != NULL) {
1553 for (j = bp_linear_bar; j < bp_last_bar; j++) {
1554 if (__kmp_str_match(__kmp_barrier_pattern_name[j], 1, comma + 1)) {
1555 __kmp_barrier_release_pattern[i] = (kmp_bar_pat_e)j;
1559 if (j == bp_last_bar) {
1560 __kmp_msg(kmp_ms_warning,
1561 KMP_MSG(BarrReleaseValueInvalid, name, comma + 1),
1563 KMP_INFORM(Using_str_Value, name,
1564 __kmp_barrier_pattern_name[bp_linear_bar]);
1571 static void __kmp_stg_print_barrier_pattern(kmp_str_buf_t *buffer,
1572 char const *name,
void *data) {
1574 for (
int i = bs_plain_barrier; i < bs_last_barrier; i++) {
1575 var = __kmp_barrier_pattern_env_name[i];
1576 if (strcmp(var, name) == 0) {
1577 int j = __kmp_barrier_gather_pattern[i];
1578 int k = __kmp_barrier_release_pattern[i];
1579 if (__kmp_env_format) {
1580 KMP_STR_BUF_PRINT_NAME_EX(__kmp_barrier_pattern_env_name[i]);
1582 __kmp_str_buf_print(buffer,
" %s='",
1583 __kmp_barrier_pattern_env_name[i]);
1585 __kmp_str_buf_print(buffer,
"%s,%s'\n", __kmp_barrier_pattern_name[j],
1586 __kmp_barrier_pattern_name[k]);
1594 static void __kmp_stg_parse_abort_delay(
char const *name,
char const *value,
1598 int delay = __kmp_abort_delay / 1000;
1599 __kmp_stg_parse_int(name, value, 0, INT_MAX / 1000, &delay);
1600 __kmp_abort_delay = delay * 1000;
1603 static void __kmp_stg_print_abort_delay(kmp_str_buf_t *buffer,
char const *name,
1605 __kmp_stg_print_int(buffer, name, __kmp_abort_delay);
1611 static void __kmp_stg_parse_cpuinfo_file(
char const *name,
char const *value,
1613 #if KMP_AFFINITY_SUPPORTED 1614 __kmp_stg_parse_str(name, value, &__kmp_cpuinfo_file);
1615 K_DIAG(1, (
"__kmp_cpuinfo_file == %s\n", __kmp_cpuinfo_file));
1619 static void __kmp_stg_print_cpuinfo_file(kmp_str_buf_t *buffer,
1620 char const *name,
void *data) {
1621 #if KMP_AFFINITY_SUPPORTED 1622 if (__kmp_env_format) {
1623 KMP_STR_BUF_PRINT_NAME;
1625 __kmp_str_buf_print(buffer,
" %s", name);
1627 if (__kmp_cpuinfo_file) {
1628 __kmp_str_buf_print(buffer,
"='%s'\n", __kmp_cpuinfo_file);
1630 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
1638 static void __kmp_stg_parse_force_reduction(
char const *name,
char const *value,
1640 kmp_stg_fr_data_t *reduction = (kmp_stg_fr_data_t *)data;
1643 rc = __kmp_stg_check_rivals(name, value, reduction->rivals);
1647 if (reduction->force) {
1649 if (__kmp_str_match(
"critical", 0, value))
1650 __kmp_force_reduction_method = critical_reduce_block;
1651 else if (__kmp_str_match(
"atomic", 0, value))
1652 __kmp_force_reduction_method = atomic_reduce_block;
1653 else if (__kmp_str_match(
"tree", 0, value))
1654 __kmp_force_reduction_method = tree_reduce_block;
1656 KMP_FATAL(UnknownForceReduction, name, value);
1660 __kmp_stg_parse_bool(name, value, &__kmp_determ_red);
1661 if (__kmp_determ_red) {
1662 __kmp_force_reduction_method = tree_reduce_block;
1664 __kmp_force_reduction_method = reduction_method_not_defined;
1667 K_DIAG(1, (
"__kmp_force_reduction_method == %d\n",
1668 __kmp_force_reduction_method));
1671 static void __kmp_stg_print_force_reduction(kmp_str_buf_t *buffer,
1672 char const *name,
void *data) {
1674 kmp_stg_fr_data_t *reduction = (kmp_stg_fr_data_t *)data;
1675 if (reduction->force) {
1676 if (__kmp_force_reduction_method == critical_reduce_block) {
1677 __kmp_stg_print_str(buffer, name,
"critical");
1678 }
else if (__kmp_force_reduction_method == atomic_reduce_block) {
1679 __kmp_stg_print_str(buffer, name,
"atomic");
1680 }
else if (__kmp_force_reduction_method == tree_reduce_block) {
1681 __kmp_stg_print_str(buffer, name,
"tree");
1683 if (__kmp_env_format) {
1684 KMP_STR_BUF_PRINT_NAME;
1686 __kmp_str_buf_print(buffer,
" %s", name);
1688 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
1691 __kmp_stg_print_bool(buffer, name, __kmp_determ_red);
1699 static void __kmp_stg_parse_storage_map(
char const *name,
char const *value,
1701 if (__kmp_str_match(
"verbose", 1, value)) {
1702 __kmp_storage_map = TRUE;
1703 __kmp_storage_map_verbose = TRUE;
1704 __kmp_storage_map_verbose_specified = TRUE;
1707 __kmp_storage_map_verbose = FALSE;
1708 __kmp_stg_parse_bool(name, value, &__kmp_storage_map);
1712 static void __kmp_stg_print_storage_map(kmp_str_buf_t *buffer,
char const *name,
1714 if (__kmp_storage_map_verbose || __kmp_storage_map_verbose_specified) {
1715 __kmp_stg_print_str(buffer, name,
"verbose");
1717 __kmp_stg_print_bool(buffer, name, __kmp_storage_map);
1724 static void __kmp_stg_parse_all_threadprivate(
char const *name,
1725 char const *value,
void *data) {
1726 __kmp_stg_parse_int(name, value,
1727 __kmp_allThreadsSpecified ? __kmp_max_nth : 1,
1728 __kmp_max_nth, &__kmp_tp_capacity);
1731 static void __kmp_stg_print_all_threadprivate(kmp_str_buf_t *buffer,
1732 char const *name,
void *data) {
1733 __kmp_stg_print_int(buffer, name, __kmp_tp_capacity);
1739 static void __kmp_stg_parse_foreign_threads_threadprivate(
char const *name,
1742 __kmp_stg_parse_bool(name, value, &__kmp_foreign_tp);
1745 static void __kmp_stg_print_foreign_threads_threadprivate(kmp_str_buf_t *buffer,
1748 __kmp_stg_print_bool(buffer, name, __kmp_foreign_tp);
1754 #if KMP_AFFINITY_SUPPORTED 1756 static int __kmp_parse_affinity_proc_id_list(
const char *var,
const char *env,
1757 const char **nextEnv,
1759 const char *scan = env;
1760 const char *next = scan;
1766 int start, end, stride;
1770 if (*next ==
'\0') {
1781 if ((*next <
'0') || (*next >
'9')) {
1782 KMP_WARNING(AffSyntaxError, var);
1786 num = __kmp_str_to_int(scan, *next);
1787 KMP_ASSERT(num >= 0);
1805 if ((*next <
'0') || (*next >
'9')) {
1806 KMP_WARNING(AffSyntaxError, var);
1811 num = __kmp_str_to_int(scan, *next);
1812 KMP_ASSERT(num >= 0);
1825 if ((*next <
'0') || (*next >
'9')) {
1827 KMP_WARNING(AffSyntaxError, var);
1835 start = __kmp_str_to_int(scan, *next);
1836 KMP_ASSERT(start >= 0);
1855 if ((*next <
'0') || (*next >
'9')) {
1856 KMP_WARNING(AffSyntaxError, var);
1860 end = __kmp_str_to_int(scan, *next);
1861 KMP_ASSERT(end >= 0);
1878 if ((*next <
'0') || (*next >
'9')) {
1879 KMP_WARNING(AffSyntaxError, var);
1883 stride = __kmp_str_to_int(scan, *next);
1884 KMP_ASSERT(stride >= 0);
1890 KMP_WARNING(AffZeroStride, var);
1895 KMP_WARNING(AffStartGreaterEnd, var, start, end);
1900 KMP_WARNING(AffStrideLessZero, var, start, end);
1904 if ((end - start) / stride > 65536) {
1905 KMP_WARNING(AffRangeTooBig, var, end, start, stride);
1922 int len = next - env;
1923 char *retlist = (
char *)__kmp_allocate((len + 1) *
sizeof(char));
1924 KMP_MEMCPY_S(retlist, (len + 1) *
sizeof(
char), env, len *
sizeof(
char));
1925 retlist[len] =
'\0';
1926 *proclist = retlist;
1933 static kmp_setting_t *__kmp_affinity_notype = NULL;
1935 static void __kmp_parse_affinity_env(
char const *name,
char const *value,
1936 enum affinity_type *out_type,
1937 char **out_proclist,
int *out_verbose,
1938 int *out_warn,
int *out_respect,
1939 enum affinity_gran *out_gran,
1940 int *out_gran_levels,
int *out_dups,
1941 int *out_compact,
int *out_offset) {
1942 char *buffer = NULL;
1952 int max_proclist = 0;
1959 KMP_ASSERT(value != NULL);
1961 if (TCR_4(__kmp_init_middle)) {
1962 KMP_WARNING(EnvMiddleWarn, name);
1963 __kmp_env_toPrint(name, 0);
1966 __kmp_env_toPrint(name, 1);
1969 __kmp_str_format(
"%s", value);
1979 #define EMIT_WARN(skip, errlist) \ 1983 SKIP_TO(next, ','); \ 1987 KMP_WARNING errlist; \ 1996 #define _set_param(_guard, _var, _val) \ 1998 if (_guard == 0) { \ 2001 EMIT_WARN(FALSE, (AffParamDefined, name, start)); \ 2006 #define set_type(val) _set_param(type, *out_type, val) 2007 #define set_verbose(val) _set_param(verbose, *out_verbose, val) 2008 #define set_warnings(val) _set_param(warnings, *out_warn, val) 2009 #define set_respect(val) _set_param(respect, *out_respect, val) 2010 #define set_dups(val) _set_param(dups, *out_dups, val) 2011 #define set_proclist(val) _set_param(proclist, *out_proclist, val) 2013 #define set_gran(val, levels) \ 2017 *out_gran_levels = levels; \ 2019 EMIT_WARN(FALSE, (AffParamDefined, name, start)); \ 2025 KMP_DEBUG_ASSERT((__kmp_nested_proc_bind.bind_types != NULL) &&
2026 (__kmp_nested_proc_bind.used > 0));
2029 while (*buf !=
'\0') {
2032 if (__kmp_match_str(
"none", buf, CCAST(
const char **, &next))) {
2033 set_type(affinity_none);
2035 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
2038 }
else if (__kmp_match_str(
"scatter", buf, CCAST(
const char **, &next))) {
2039 set_type(affinity_scatter);
2041 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2044 }
else if (__kmp_match_str(
"compact", buf, CCAST(
const char **, &next))) {
2045 set_type(affinity_compact);
2047 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2050 }
else if (__kmp_match_str(
"logical", buf, CCAST(
const char **, &next))) {
2051 set_type(affinity_logical);
2053 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2056 }
else if (__kmp_match_str(
"physical", buf, CCAST(
const char **, &next))) {
2057 set_type(affinity_physical);
2059 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2062 }
else if (__kmp_match_str(
"explicit", buf, CCAST(
const char **, &next))) {
2063 set_type(affinity_explicit);
2065 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2068 }
else if (__kmp_match_str(
"balanced", buf, CCAST(
const char **, &next))) {
2069 set_type(affinity_balanced);
2071 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2074 }
else if (__kmp_match_str(
"disabled", buf, CCAST(
const char **, &next))) {
2075 set_type(affinity_disabled);
2077 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
2080 }
else if (__kmp_match_str(
"verbose", buf, CCAST(
const char **, &next))) {
2083 }
else if (__kmp_match_str(
"noverbose", buf, CCAST(
const char **, &next))) {
2086 }
else if (__kmp_match_str(
"warnings", buf, CCAST(
const char **, &next))) {
2089 }
else if (__kmp_match_str(
"nowarnings", buf,
2090 CCAST(
const char **, &next))) {
2091 set_warnings(FALSE);
2093 }
else if (__kmp_match_str(
"respect", buf, CCAST(
const char **, &next))) {
2096 }
else if (__kmp_match_str(
"norespect", buf, CCAST(
const char **, &next))) {
2099 }
else if (__kmp_match_str(
"duplicates", buf,
2100 CCAST(
const char **, &next)) ||
2101 __kmp_match_str(
"dups", buf, CCAST(
const char **, &next))) {
2104 }
else if (__kmp_match_str(
"noduplicates", buf,
2105 CCAST(
const char **, &next)) ||
2106 __kmp_match_str(
"nodups", buf, CCAST(
const char **, &next))) {
2109 }
else if (__kmp_match_str(
"granularity", buf,
2110 CCAST(
const char **, &next)) ||
2111 __kmp_match_str(
"gran", buf, CCAST(
const char **, &next))) {
2114 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2121 if (__kmp_match_str(
"fine", buf, CCAST(
const char **, &next))) {
2122 set_gran(affinity_gran_fine, -1);
2124 }
else if (__kmp_match_str(
"thread", buf, CCAST(
const char **, &next))) {
2125 set_gran(affinity_gran_thread, -1);
2127 }
else if (__kmp_match_str(
"core", buf, CCAST(
const char **, &next))) {
2128 set_gran(affinity_gran_core, -1);
2131 }
else if (__kmp_match_str(
"tile", buf, CCAST(
const char **, &next))) {
2132 set_gran(affinity_gran_tile, -1);
2135 }
else if (__kmp_match_str(
"package", buf, CCAST(
const char **, &next))) {
2136 set_gran(affinity_gran_package, -1);
2138 }
else if (__kmp_match_str(
"node", buf, CCAST(
const char **, &next))) {
2139 set_gran(affinity_gran_node, -1);
2141 #if KMP_GROUP_AFFINITY 2142 }
else if (__kmp_match_str(
"group", buf, CCAST(
const char **, &next))) {
2143 set_gran(affinity_gran_group, -1);
2146 }
else if ((*buf >=
'0') && (*buf <=
'9')) {
2150 n = __kmp_str_to_int(buf, *next);
2153 set_gran(affinity_gran_default, n);
2155 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2158 }
else if (__kmp_match_str(
"proclist", buf, CCAST(
const char **, &next))) {
2159 char *temp_proclist;
2163 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2169 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2174 if (!__kmp_parse_affinity_proc_id_list(
2175 name, buf, CCAST(
const char **, &next), &temp_proclist)) {
2187 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2191 set_proclist(temp_proclist);
2192 }
else if ((*buf >=
'0') && (*buf <=
'9')) {
2197 n = __kmp_str_to_int(buf, *next);
2203 KMP_WARNING(AffManyParams, name, start);
2207 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2215 }
else if (*next !=
'\0') {
2216 const char *temp = next;
2217 EMIT_WARN(TRUE, (ParseExtraCharsWarn, name, temp));
2229 #undef set_granularity 2231 __kmp_str_free(&buffer);
2235 KMP_WARNING(AffProcListNoType, name);
2236 *out_type = affinity_explicit;
2238 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2240 }
else if (*out_type != affinity_explicit) {
2241 KMP_WARNING(AffProcListNotExplicit, name);
2242 KMP_ASSERT(*out_proclist != NULL);
2243 KMP_INTERNAL_FREE(*out_proclist);
2244 *out_proclist = NULL;
2247 switch (*out_type) {
2248 case affinity_logical:
2249 case affinity_physical: {
2251 *out_offset = number[0];
2254 KMP_WARNING(AffManyParamsForLogic, name, number[1]);
2257 case affinity_balanced: {
2259 *out_compact = number[0];
2262 *out_offset = number[1];
2265 if (__kmp_affinity_gran == affinity_gran_default) {
2266 #if KMP_MIC_SUPPORTED 2267 if (__kmp_mic_type != non_mic) {
2268 if (__kmp_affinity_verbose || __kmp_affinity_warnings) {
2269 KMP_WARNING(AffGranUsing,
"KMP_AFFINITY",
"fine");
2271 __kmp_affinity_gran = affinity_gran_fine;
2275 if (__kmp_affinity_verbose || __kmp_affinity_warnings) {
2276 KMP_WARNING(AffGranUsing,
"KMP_AFFINITY",
"core");
2278 __kmp_affinity_gran = affinity_gran_core;
2282 case affinity_scatter:
2283 case affinity_compact: {
2285 *out_compact = number[0];
2288 *out_offset = number[1];
2291 case affinity_explicit: {
2292 if (*out_proclist == NULL) {
2293 KMP_WARNING(AffNoProcList, name);
2294 __kmp_affinity_type = affinity_none;
2297 KMP_WARNING(AffNoParam, name,
"explicit");
2300 case affinity_none: {
2302 KMP_WARNING(AffNoParam, name,
"none");
2305 case affinity_disabled: {
2307 KMP_WARNING(AffNoParam, name,
"disabled");
2310 case affinity_default: {
2312 KMP_WARNING(AffNoParam, name,
"default");
2315 default: { KMP_ASSERT(0); }
2319 static void __kmp_stg_parse_affinity(
char const *name,
char const *value,
2321 kmp_setting_t **rivals = (kmp_setting_t **)data;
2324 rc = __kmp_stg_check_rivals(name, value, rivals);
2329 __kmp_parse_affinity_env(name, value, &__kmp_affinity_type,
2330 &__kmp_affinity_proclist, &__kmp_affinity_verbose,
2331 &__kmp_affinity_warnings,
2332 &__kmp_affinity_respect_mask, &__kmp_affinity_gran,
2333 &__kmp_affinity_gran_levels, &__kmp_affinity_dups,
2334 &__kmp_affinity_compact, &__kmp_affinity_offset);
2338 static void __kmp_stg_print_affinity(kmp_str_buf_t *buffer,
char const *name,
2340 if (__kmp_env_format) {
2341 KMP_STR_BUF_PRINT_NAME_EX(name);
2343 __kmp_str_buf_print(buffer,
" %s='", name);
2345 if (__kmp_affinity_verbose) {
2346 __kmp_str_buf_print(buffer,
"%s,",
"verbose");
2348 __kmp_str_buf_print(buffer,
"%s,",
"noverbose");
2350 if (__kmp_affinity_warnings) {
2351 __kmp_str_buf_print(buffer,
"%s,",
"warnings");
2353 __kmp_str_buf_print(buffer,
"%s,",
"nowarnings");
2355 if (KMP_AFFINITY_CAPABLE()) {
2356 if (__kmp_affinity_respect_mask) {
2357 __kmp_str_buf_print(buffer,
"%s,",
"respect");
2359 __kmp_str_buf_print(buffer,
"%s,",
"norespect");
2361 switch (__kmp_affinity_gran) {
2362 case affinity_gran_default:
2363 __kmp_str_buf_print(buffer,
"%s",
"granularity=default,");
2365 case affinity_gran_fine:
2366 __kmp_str_buf_print(buffer,
"%s",
"granularity=fine,");
2368 case affinity_gran_thread:
2369 __kmp_str_buf_print(buffer,
"%s",
"granularity=thread,");
2371 case affinity_gran_core:
2372 __kmp_str_buf_print(buffer,
"%s",
"granularity=core,");
2374 case affinity_gran_package:
2375 __kmp_str_buf_print(buffer,
"%s",
"granularity=package,");
2377 case affinity_gran_node:
2378 __kmp_str_buf_print(buffer,
"%s",
"granularity=node,");
2380 #if KMP_GROUP_AFFINITY 2381 case affinity_gran_group:
2382 __kmp_str_buf_print(buffer,
"%s",
"granularity=group,");
2387 if (!KMP_AFFINITY_CAPABLE()) {
2388 __kmp_str_buf_print(buffer,
"%s",
"disabled");
2390 switch (__kmp_affinity_type) {
2392 __kmp_str_buf_print(buffer,
"%s",
"none");
2394 case affinity_physical:
2395 __kmp_str_buf_print(buffer,
"%s,%d",
"physical", __kmp_affinity_offset);
2397 case affinity_logical:
2398 __kmp_str_buf_print(buffer,
"%s,%d",
"logical", __kmp_affinity_offset);
2400 case affinity_compact:
2401 __kmp_str_buf_print(buffer,
"%s,%d,%d",
"compact", __kmp_affinity_compact,
2402 __kmp_affinity_offset);
2404 case affinity_scatter:
2405 __kmp_str_buf_print(buffer,
"%s,%d,%d",
"scatter", __kmp_affinity_compact,
2406 __kmp_affinity_offset);
2408 case affinity_explicit:
2409 __kmp_str_buf_print(buffer,
"%s=[%s],%s",
"proclist",
2410 __kmp_affinity_proclist,
"explicit");
2412 case affinity_balanced:
2413 __kmp_str_buf_print(buffer,
"%s,%d,%d",
"balanced",
2414 __kmp_affinity_compact, __kmp_affinity_offset);
2416 case affinity_disabled:
2417 __kmp_str_buf_print(buffer,
"%s",
"disabled");
2419 case affinity_default:
2420 __kmp_str_buf_print(buffer,
"%s",
"default");
2423 __kmp_str_buf_print(buffer,
"%s",
"<unknown>");
2426 __kmp_str_buf_print(buffer,
"'\n");
2429 #ifdef KMP_GOMP_COMPAT 2431 static void __kmp_stg_parse_gomp_cpu_affinity(
char const *name,
2432 char const *value,
void *data) {
2433 const char *next = NULL;
2434 char *temp_proclist;
2435 kmp_setting_t **rivals = (kmp_setting_t **)data;
2438 rc = __kmp_stg_check_rivals(name, value, rivals);
2443 if (TCR_4(__kmp_init_middle)) {
2444 KMP_WARNING(EnvMiddleWarn, name);
2445 __kmp_env_toPrint(name, 0);
2449 __kmp_env_toPrint(name, 1);
2451 if (__kmp_parse_affinity_proc_id_list(name, value, &next, &temp_proclist)) {
2453 if (*next ==
'\0') {
2455 __kmp_affinity_proclist = temp_proclist;
2456 __kmp_affinity_type = affinity_explicit;
2457 __kmp_affinity_gran = affinity_gran_fine;
2459 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2462 KMP_WARNING(AffSyntaxError, name);
2463 if (temp_proclist != NULL) {
2464 KMP_INTERNAL_FREE((
void *)temp_proclist);
2469 __kmp_affinity_type = affinity_none;
2471 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
2500 static int __kmp_parse_subplace_list(
const char *var,
const char **scan) {
2504 int start, count, stride;
2510 if ((**scan <
'0') || (**scan >
'9')) {
2511 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2516 start = __kmp_str_to_int(*scan, *next);
2517 KMP_ASSERT(start >= 0);
2522 if (**scan ==
'}') {
2525 if (**scan ==
',') {
2529 if (**scan !=
':') {
2530 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2537 if ((**scan <
'0') || (**scan >
'9')) {
2538 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2543 count = __kmp_str_to_int(*scan, *next);
2544 KMP_ASSERT(count >= 0);
2549 if (**scan ==
'}') {
2552 if (**scan ==
',') {
2556 if (**scan !=
':') {
2557 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2566 if (**scan ==
'+') {
2570 if (**scan ==
'-') {
2578 if ((**scan <
'0') || (**scan >
'9')) {
2579 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2584 stride = __kmp_str_to_int(*scan, *next);
2585 KMP_ASSERT(stride >= 0);
2591 if (**scan ==
'}') {
2594 if (**scan ==
',') {
2599 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2605 static int __kmp_parse_place(
const char *var,
const char **scan) {
2610 if (**scan ==
'{') {
2612 if (!__kmp_parse_subplace_list(var, scan)) {
2615 if (**scan !=
'}') {
2616 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2620 }
else if (**scan ==
'!') {
2622 return __kmp_parse_place(var, scan);
2623 }
else if ((**scan >=
'0') && (**scan <=
'9')) {
2626 int proc = __kmp_str_to_int(*scan, *next);
2627 KMP_ASSERT(proc >= 0);
2630 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2636 static int __kmp_parse_place_list(
const char *var,
const char *env,
2637 char **place_list) {
2638 const char *scan = env;
2639 const char *next = scan;
2642 int start, count, stride;
2644 if (!__kmp_parse_place(var, &scan)) {
2650 if (*scan ==
'\0') {
2658 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2665 if ((*scan <
'0') || (*scan >
'9')) {
2666 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2671 count = __kmp_str_to_int(scan, *next);
2672 KMP_ASSERT(count >= 0);
2677 if (*scan ==
'\0') {
2685 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2706 if ((*scan <
'0') || (*scan >
'9')) {
2707 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2712 stride = __kmp_str_to_int(scan, *next);
2713 KMP_ASSERT(stride >= 0);
2719 if (*scan ==
'\0') {
2727 KMP_WARNING(SyntaxErrorUsing, var,
"\"threads\"");
2732 int len = scan - env;
2733 char *retlist = (
char *)__kmp_allocate((len + 1) *
sizeof(char));
2734 KMP_MEMCPY_S(retlist, (len + 1) *
sizeof(
char), env, len *
sizeof(
char));
2735 retlist[len] =
'\0';
2736 *place_list = retlist;
2741 static void __kmp_stg_parse_places(
char const *name,
char const *value,
2744 const char *scan = value;
2745 const char *next = scan;
2746 const char *kind =
"\"threads\"";
2747 kmp_setting_t **rivals = (kmp_setting_t **)data;
2750 rc = __kmp_stg_check_rivals(name, value, rivals);
2757 if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_default) {
2758 __kmp_nested_proc_bind.bind_types[0] = proc_bind_true;
2763 if (__kmp_match_str(
"threads", scan, &next)) {
2765 __kmp_affinity_type = affinity_compact;
2766 __kmp_affinity_gran = affinity_gran_thread;
2767 __kmp_affinity_dups = FALSE;
2768 kind =
"\"threads\"";
2769 }
else if (__kmp_match_str(
"cores", scan, &next)) {
2771 __kmp_affinity_type = affinity_compact;
2772 __kmp_affinity_gran = affinity_gran_core;
2773 __kmp_affinity_dups = FALSE;
2776 }
else if (__kmp_match_str(
"tiles", scan, &next)) {
2778 __kmp_affinity_type = affinity_compact;
2779 __kmp_affinity_gran = affinity_gran_tile;
2780 __kmp_affinity_dups = FALSE;
2783 }
else if (__kmp_match_str(
"sockets", scan, &next)) {
2785 __kmp_affinity_type = affinity_compact;
2786 __kmp_affinity_gran = affinity_gran_package;
2787 __kmp_affinity_dups = FALSE;
2788 kind =
"\"sockets\"";
2790 if (__kmp_affinity_proclist != NULL) {
2791 KMP_INTERNAL_FREE((
void *)__kmp_affinity_proclist);
2792 __kmp_affinity_proclist = NULL;
2794 if (__kmp_parse_place_list(name, value, &__kmp_affinity_proclist)) {
2795 __kmp_affinity_type = affinity_explicit;
2796 __kmp_affinity_gran = affinity_gran_fine;
2797 __kmp_affinity_dups = FALSE;
2798 if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_default) {
2799 __kmp_nested_proc_bind.bind_types[0] = proc_bind_true;
2805 if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_default) {
2806 __kmp_nested_proc_bind.bind_types[0] = proc_bind_true;
2810 if (*scan ==
'\0') {
2816 KMP_WARNING(SyntaxErrorUsing, name, kind);
2824 count = __kmp_str_to_int(scan, *next);
2825 KMP_ASSERT(count >= 0);
2830 KMP_WARNING(SyntaxErrorUsing, name, kind);
2836 if (*scan !=
'\0') {
2837 KMP_WARNING(ParseExtraCharsWarn, name, scan);
2839 __kmp_affinity_num_places = count;
2842 static void __kmp_stg_print_places(kmp_str_buf_t *buffer,
char const *name,
2844 if (__kmp_env_format) {
2845 KMP_STR_BUF_PRINT_NAME;
2847 __kmp_str_buf_print(buffer,
" %s", name);
2849 if ((__kmp_nested_proc_bind.used == 0) ||
2850 (__kmp_nested_proc_bind.bind_types == NULL) ||
2851 (__kmp_nested_proc_bind.bind_types[0] == proc_bind_false)) {
2852 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
2853 }
else if (__kmp_affinity_type == affinity_explicit) {
2854 if (__kmp_affinity_proclist != NULL) {
2855 __kmp_str_buf_print(buffer,
"='%s'\n", __kmp_affinity_proclist);
2857 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
2859 }
else if (__kmp_affinity_type == affinity_compact) {
2861 if (__kmp_affinity_num_masks > 0) {
2862 num = __kmp_affinity_num_masks;
2863 }
else if (__kmp_affinity_num_places > 0) {
2864 num = __kmp_affinity_num_places;
2868 if (__kmp_affinity_gran == affinity_gran_thread) {
2870 __kmp_str_buf_print(buffer,
"='threads(%d)'\n", num);
2872 __kmp_str_buf_print(buffer,
"='threads'\n");
2874 }
else if (__kmp_affinity_gran == affinity_gran_core) {
2876 __kmp_str_buf_print(buffer,
"='cores(%d)' \n", num);
2878 __kmp_str_buf_print(buffer,
"='cores'\n");
2881 }
else if (__kmp_affinity_gran == affinity_gran_tile) {
2883 __kmp_str_buf_print(buffer,
"='tiles(%d)' \n", num);
2885 __kmp_str_buf_print(buffer,
"='tiles'\n");
2888 }
else if (__kmp_affinity_gran == affinity_gran_package) {
2890 __kmp_str_buf_print(buffer,
"='sockets(%d)'\n", num);
2892 __kmp_str_buf_print(buffer,
"='sockets'\n");
2895 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
2898 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
2904 #if (!OMP_40_ENABLED) 2906 static void __kmp_stg_parse_proc_bind(
char const *name,
char const *value,
2909 kmp_setting_t **rivals = (kmp_setting_t **)data;
2912 rc = __kmp_stg_check_rivals(name, value, rivals);
2918 __kmp_stg_parse_bool(name, value, &enabled);
2922 __kmp_affinity_type = affinity_scatter;
2923 #if KMP_MIC_SUPPORTED 2924 if (__kmp_mic_type != non_mic)
2925 __kmp_affinity_gran = affinity_gran_fine;
2928 __kmp_affinity_gran = affinity_gran_core;
2930 __kmp_affinity_type = affinity_none;
2936 static void __kmp_stg_parse_topology_method(
char const *name,
char const *value,
2938 if (__kmp_str_match(
"all", 1, value)) {
2939 __kmp_affinity_top_method = affinity_top_method_all;
2942 else if (__kmp_str_match(
"hwloc", 1, value)) {
2943 __kmp_affinity_top_method = affinity_top_method_hwloc;
2946 #if KMP_ARCH_X86 || KMP_ARCH_X86_64 2947 else if (__kmp_str_match(
"x2apic id", 9, value) ||
2948 __kmp_str_match(
"x2apic_id", 9, value) ||
2949 __kmp_str_match(
"x2apic-id", 9, value) ||
2950 __kmp_str_match(
"x2apicid", 8, value) ||
2951 __kmp_str_match(
"cpuid leaf 11", 13, value) ||
2952 __kmp_str_match(
"cpuid_leaf_11", 13, value) ||
2953 __kmp_str_match(
"cpuid-leaf-11", 13, value) ||
2954 __kmp_str_match(
"cpuid leaf11", 12, value) ||
2955 __kmp_str_match(
"cpuid_leaf11", 12, value) ||
2956 __kmp_str_match(
"cpuid-leaf11", 12, value) ||
2957 __kmp_str_match(
"cpuidleaf 11", 12, value) ||
2958 __kmp_str_match(
"cpuidleaf_11", 12, value) ||
2959 __kmp_str_match(
"cpuidleaf-11", 12, value) ||
2960 __kmp_str_match(
"cpuidleaf11", 11, value) ||
2961 __kmp_str_match(
"cpuid 11", 8, value) ||
2962 __kmp_str_match(
"cpuid_11", 8, value) ||
2963 __kmp_str_match(
"cpuid-11", 8, value) ||
2964 __kmp_str_match(
"cpuid11", 7, value) ||
2965 __kmp_str_match(
"leaf 11", 7, value) ||
2966 __kmp_str_match(
"leaf_11", 7, value) ||
2967 __kmp_str_match(
"leaf-11", 7, value) ||
2968 __kmp_str_match(
"leaf11", 6, value)) {
2969 __kmp_affinity_top_method = affinity_top_method_x2apicid;
2970 }
else if (__kmp_str_match(
"apic id", 7, value) ||
2971 __kmp_str_match(
"apic_id", 7, value) ||
2972 __kmp_str_match(
"apic-id", 7, value) ||
2973 __kmp_str_match(
"apicid", 6, value) ||
2974 __kmp_str_match(
"cpuid leaf 4", 12, value) ||
2975 __kmp_str_match(
"cpuid_leaf_4", 12, value) ||
2976 __kmp_str_match(
"cpuid-leaf-4", 12, value) ||
2977 __kmp_str_match(
"cpuid leaf4", 11, value) ||
2978 __kmp_str_match(
"cpuid_leaf4", 11, value) ||
2979 __kmp_str_match(
"cpuid-leaf4", 11, value) ||
2980 __kmp_str_match(
"cpuidleaf 4", 11, value) ||
2981 __kmp_str_match(
"cpuidleaf_4", 11, value) ||
2982 __kmp_str_match(
"cpuidleaf-4", 11, value) ||
2983 __kmp_str_match(
"cpuidleaf4", 10, value) ||
2984 __kmp_str_match(
"cpuid 4", 7, value) ||
2985 __kmp_str_match(
"cpuid_4", 7, value) ||
2986 __kmp_str_match(
"cpuid-4", 7, value) ||
2987 __kmp_str_match(
"cpuid4", 6, value) ||
2988 __kmp_str_match(
"leaf 4", 6, value) ||
2989 __kmp_str_match(
"leaf_4", 6, value) ||
2990 __kmp_str_match(
"leaf-4", 6, value) ||
2991 __kmp_str_match(
"leaf4", 5, value)) {
2992 __kmp_affinity_top_method = affinity_top_method_apicid;
2995 else if (__kmp_str_match(
"/proc/cpuinfo", 2, value) ||
2996 __kmp_str_match(
"cpuinfo", 5, value)) {
2997 __kmp_affinity_top_method = affinity_top_method_cpuinfo;
2999 #if KMP_GROUP_AFFINITY 3000 else if (__kmp_str_match(
"group", 1, value)) {
3001 __kmp_affinity_top_method = affinity_top_method_group;
3004 else if (__kmp_str_match(
"flat", 1, value)) {
3005 __kmp_affinity_top_method = affinity_top_method_flat;
3007 KMP_WARNING(StgInvalidValue, name, value);
3011 static void __kmp_stg_print_topology_method(kmp_str_buf_t *buffer,
3012 char const *name,
void *data) {
3013 char const *value = NULL;
3015 switch (__kmp_affinity_top_method) {
3016 case affinity_top_method_default:
3020 case affinity_top_method_all:
3024 #if KMP_ARCH_X86 || KMP_ARCH_X86_64 3025 case affinity_top_method_x2apicid:
3026 value =
"x2APIC id";
3029 case affinity_top_method_apicid:
3035 case affinity_top_method_hwloc:
3040 case affinity_top_method_cpuinfo:
3044 #if KMP_GROUP_AFFINITY 3045 case affinity_top_method_group:
3050 case affinity_top_method_flat:
3055 if (value != NULL) {
3056 __kmp_stg_print_str(buffer, name, value);
3066 static void __kmp_stg_parse_proc_bind(
char const *name,
char const *value,
3068 kmp_setting_t **rivals = (kmp_setting_t **)data;
3071 rc = __kmp_stg_check_rivals(name, value, rivals);
3077 KMP_DEBUG_ASSERT((__kmp_nested_proc_bind.bind_types != NULL) &&
3078 (__kmp_nested_proc_bind.used > 0));
3080 const char *buf = value;
3084 if ((*buf >=
'0') && (*buf <=
'9')) {
3087 num = __kmp_str_to_int(buf, *next);
3088 KMP_ASSERT(num >= 0);
3096 if (__kmp_match_str(
"disabled", buf, &next)) {
3099 #if KMP_AFFINITY_SUPPORTED 3100 __kmp_affinity_type = affinity_disabled;
3102 __kmp_nested_proc_bind.used = 1;
3103 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
3104 }
else if ((num == (
int)proc_bind_false) ||
3105 __kmp_match_str(
"false", buf, &next)) {
3108 #if KMP_AFFINITY_SUPPORTED 3109 __kmp_affinity_type = affinity_none;
3111 __kmp_nested_proc_bind.used = 1;
3112 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
3113 }
else if ((num == (
int)proc_bind_true) ||
3114 __kmp_match_str(
"true", buf, &next)) {
3117 __kmp_nested_proc_bind.used = 1;
3118 __kmp_nested_proc_bind.bind_types[0] = proc_bind_true;
3123 for (scan = buf; *scan !=
'\0'; scan++) {
3130 if (__kmp_nested_proc_bind.size < nelem) {
3131 __kmp_nested_proc_bind.bind_types =
3132 (kmp_proc_bind_t *)KMP_INTERNAL_REALLOC(
3133 __kmp_nested_proc_bind.bind_types,
3134 sizeof(kmp_proc_bind_t) * nelem);
3135 if (__kmp_nested_proc_bind.bind_types == NULL) {
3136 KMP_FATAL(MemoryAllocFailed);
3138 __kmp_nested_proc_bind.size = nelem;
3140 __kmp_nested_proc_bind.used = nelem;
3145 enum kmp_proc_bind_t bind;
3147 if ((num == (
int)proc_bind_master) ||
3148 __kmp_match_str(
"master", buf, &next)) {
3151 bind = proc_bind_master;
3152 }
else if ((num == (
int)proc_bind_close) ||
3153 __kmp_match_str(
"close", buf, &next)) {
3156 bind = proc_bind_close;
3157 }
else if ((num == (
int)proc_bind_spread) ||
3158 __kmp_match_str(
"spread", buf, &next)) {
3161 bind = proc_bind_spread;
3163 KMP_WARNING(StgInvalidValue, name, value);
3164 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
3165 __kmp_nested_proc_bind.used = 1;
3169 __kmp_nested_proc_bind.bind_types[i++] = bind;
3173 KMP_DEBUG_ASSERT(*buf ==
',');
3178 if ((*buf >=
'0') && (*buf <=
'9')) {
3181 num = __kmp_str_to_int(buf, *next);
3182 KMP_ASSERT(num >= 0);
3192 KMP_WARNING(ParseExtraCharsWarn, name, buf);
3196 static void __kmp_stg_print_proc_bind(kmp_str_buf_t *buffer,
char const *name,
3198 int nelem = __kmp_nested_proc_bind.used;
3199 if (__kmp_env_format) {
3200 KMP_STR_BUF_PRINT_NAME;
3202 __kmp_str_buf_print(buffer,
" %s", name);
3205 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
3208 __kmp_str_buf_print(buffer,
"='", name);
3209 for (i = 0; i < nelem; i++) {
3210 switch (__kmp_nested_proc_bind.bind_types[i]) {
3211 case proc_bind_false:
3212 __kmp_str_buf_print(buffer,
"false");
3215 case proc_bind_true:
3216 __kmp_str_buf_print(buffer,
"true");
3219 case proc_bind_master:
3220 __kmp_str_buf_print(buffer,
"master");
3223 case proc_bind_close:
3224 __kmp_str_buf_print(buffer,
"close");
3227 case proc_bind_spread:
3228 __kmp_str_buf_print(buffer,
"spread");
3231 case proc_bind_intel:
3232 __kmp_str_buf_print(buffer,
"intel");
3235 case proc_bind_default:
3236 __kmp_str_buf_print(buffer,
"default");
3239 if (i < nelem - 1) {
3240 __kmp_str_buf_print(buffer,
",");
3243 __kmp_str_buf_print(buffer,
"'\n");
3252 static void __kmp_stg_parse_omp_dynamic(
char const *name,
char const *value,
3254 __kmp_stg_parse_bool(name, value, &(__kmp_global.g.g_dynamic));
3257 static void __kmp_stg_print_omp_dynamic(kmp_str_buf_t *buffer,
char const *name,
3259 __kmp_stg_print_bool(buffer, name, __kmp_global.g.g_dynamic);
3262 static void __kmp_stg_parse_kmp_dynamic_mode(
char const *name,
3263 char const *value,
void *data) {
3264 if (TCR_4(__kmp_init_parallel)) {
3265 KMP_WARNING(EnvParallelWarn, name);
3266 __kmp_env_toPrint(name, 0);
3269 #ifdef USE_LOAD_BALANCE 3270 else if (__kmp_str_match(
"load balance", 2, value) ||
3271 __kmp_str_match(
"load_balance", 2, value) ||
3272 __kmp_str_match(
"load-balance", 2, value) ||
3273 __kmp_str_match(
"loadbalance", 2, value) ||
3274 __kmp_str_match(
"balance", 1, value)) {
3275 __kmp_global.g.g_dynamic_mode = dynamic_load_balance;
3278 else if (__kmp_str_match(
"thread limit", 1, value) ||
3279 __kmp_str_match(
"thread_limit", 1, value) ||
3280 __kmp_str_match(
"thread-limit", 1, value) ||
3281 __kmp_str_match(
"threadlimit", 1, value) ||
3282 __kmp_str_match(
"limit", 2, value)) {
3283 __kmp_global.g.g_dynamic_mode = dynamic_thread_limit;
3284 }
else if (__kmp_str_match(
"random", 1, value)) {
3285 __kmp_global.g.g_dynamic_mode = dynamic_random;
3287 KMP_WARNING(StgInvalidValue, name, value);
3291 static void __kmp_stg_print_kmp_dynamic_mode(kmp_str_buf_t *buffer,
3292 char const *name,
void *data) {
3294 if (__kmp_global.g.g_dynamic_mode == dynamic_default) {
3295 __kmp_str_buf_print(buffer,
" %s: %s \n", name, KMP_I18N_STR(NotDefined));
3297 #ifdef USE_LOAD_BALANCE 3298 else if (__kmp_global.g.g_dynamic_mode == dynamic_load_balance) {
3299 __kmp_stg_print_str(buffer, name,
"load balance");
3302 else if (__kmp_global.g.g_dynamic_mode == dynamic_thread_limit) {
3303 __kmp_stg_print_str(buffer, name,
"thread limit");
3304 }
else if (__kmp_global.g.g_dynamic_mode == dynamic_random) {
3305 __kmp_stg_print_str(buffer, name,
"random");
3312 #ifdef USE_LOAD_BALANCE 3317 static void __kmp_stg_parse_ld_balance_interval(
char const *name,
3318 char const *value,
void *data) {
3319 double interval = __kmp_convert_to_double(value);
3320 if (interval >= 0) {
3321 __kmp_load_balance_interval = interval;
3323 KMP_WARNING(StgInvalidValue, name, value);
3327 static void __kmp_stg_print_ld_balance_interval(kmp_str_buf_t *buffer,
3328 char const *name,
void *data) {
3330 __kmp_str_buf_print(buffer,
" %s=%8.6f\n", name,
3331 __kmp_load_balance_interval);
3340 static void __kmp_stg_parse_init_at_fork(
char const *name,
char const *value,
3342 __kmp_stg_parse_bool(name, value, &__kmp_need_register_atfork);
3343 if (__kmp_need_register_atfork) {
3344 __kmp_need_register_atfork_specified = TRUE;
3348 static void __kmp_stg_print_init_at_fork(kmp_str_buf_t *buffer,
3349 char const *name,
void *data) {
3350 __kmp_stg_print_bool(buffer, name, __kmp_need_register_atfork_specified);
3356 static void __kmp_stg_parse_schedule(
char const *name,
char const *value,
3359 if (value != NULL) {
3360 size_t length = KMP_STRLEN(value);
3361 if (length > INT_MAX) {
3362 KMP_WARNING(LongValue, name);
3364 const char *semicolon;
3365 if (value[length - 1] ==
'"' || value[length - 1] ==
'\'')
3366 KMP_WARNING(UnbalancedQuotes, name);
3370 semicolon = strchr(value,
';');
3371 if (*value && semicolon != value) {
3372 const char *comma = strchr(value,
',');
3379 if (!__kmp_strcasecmp_with_sentinel(
"static", value, sentinel)) {
3380 if (!__kmp_strcasecmp_with_sentinel(
"greedy", comma,
';')) {
3381 __kmp_static = kmp_sch_static_greedy;
3383 }
else if (!__kmp_strcasecmp_with_sentinel(
"balanced", comma,
3385 __kmp_static = kmp_sch_static_balanced;
3388 }
else if (!__kmp_strcasecmp_with_sentinel(
"guided", value,
3390 if (!__kmp_strcasecmp_with_sentinel(
"iterative", comma,
';')) {
3391 __kmp_guided = kmp_sch_guided_iterative_chunked;
3393 }
else if (!__kmp_strcasecmp_with_sentinel(
"analytical", comma,
3396 __kmp_guided = kmp_sch_guided_analytical_chunked;
3400 KMP_WARNING(InvalidClause, name, value);
3402 KMP_WARNING(EmptyClause, name);
3403 }
while ((value = semicolon ? semicolon + 1 : NULL));
3409 static void __kmp_stg_print_schedule(kmp_str_buf_t *buffer,
char const *name,
3411 if (__kmp_env_format) {
3412 KMP_STR_BUF_PRINT_NAME_EX(name);
3414 __kmp_str_buf_print(buffer,
" %s='", name);
3416 if (__kmp_static == kmp_sch_static_greedy) {
3417 __kmp_str_buf_print(buffer,
"%s",
"static,greedy");
3418 }
else if (__kmp_static == kmp_sch_static_balanced) {
3419 __kmp_str_buf_print(buffer,
"%s",
"static,balanced");
3421 if (__kmp_guided == kmp_sch_guided_iterative_chunked) {
3422 __kmp_str_buf_print(buffer,
";%s'\n",
"guided,iterative");
3423 }
else if (__kmp_guided == kmp_sch_guided_analytical_chunked) {
3424 __kmp_str_buf_print(buffer,
";%s'\n",
"guided,analytical");
3431 static inline void __kmp_omp_schedule_restore() {
3432 #if KMP_USE_HIER_SCHED 3433 __kmp_hier_scheds.deallocate();
3439 static const char *__kmp_parse_single_omp_schedule(
const char *name,
3441 bool parse_hier =
false) {
3443 const char *ptr = value;
3444 const char *comma = strchr(ptr,
',');
3450 #if KMP_USE_HIER_SCHED 3451 kmp_hier_layer_e layer = kmp_hier_layer_e::LAYER_THREAD;
3453 if (!__kmp_strcasecmp_with_sentinel(
"L1", ptr,
',')) {
3454 layer = kmp_hier_layer_e::LAYER_L1;
3455 }
else if (!__kmp_strcasecmp_with_sentinel(
"L2", ptr,
',')) {
3456 layer = kmp_hier_layer_e::LAYER_L2;
3457 }
else if (!__kmp_strcasecmp_with_sentinel(
"L3", ptr,
',')) {
3458 layer = kmp_hier_layer_e::LAYER_L3;
3459 }
else if (!__kmp_strcasecmp_with_sentinel(
"NUMA", ptr,
',')) {
3460 layer = kmp_hier_layer_e::LAYER_NUMA;
3462 if (layer != kmp_hier_layer_e::LAYER_THREAD && !comma) {
3464 KMP_WARNING(StgInvalidValue, name, value);
3465 __kmp_omp_schedule_restore();
3467 }
else if (layer != kmp_hier_layer_e::LAYER_THREAD) {
3469 comma = strchr(ptr,
',');
3473 while (*delim !=
',' && *delim !=
':' && *delim !=
'\0')
3475 #else // KMP_USE_HIER_SCHED 3477 while (*delim !=
',' && *delim !=
'\0')
3479 #endif // KMP_USE_HIER_SCHED 3480 if (!__kmp_strcasecmp_with_sentinel(
"dynamic", ptr, *delim))
3481 sched = kmp_sch_dynamic_chunked;
3482 else if (!__kmp_strcasecmp_with_sentinel(
"guided", ptr, *delim))
3486 else if (!__kmp_strcasecmp_with_sentinel(
"auto", ptr, *delim)) {
3489 __kmp_msg(kmp_ms_warning, KMP_MSG(IgnoreChunk, name, comma),
3493 }
else if (!__kmp_strcasecmp_with_sentinel(
"trapezoidal", ptr,
3495 sched = kmp_sch_trapezoidal;
3496 else if (!__kmp_strcasecmp_with_sentinel(
"static", ptr, *delim))
3498 #if KMP_STATIC_STEAL_ENABLED 3499 else if (!__kmp_strcasecmp_with_sentinel(
"static_steal", ptr, *delim))
3500 sched = kmp_sch_static_steal;
3503 KMP_WARNING(StgInvalidValue, name, value);
3504 __kmp_omp_schedule_restore();
3507 if (ptr && comma && *comma == *delim) {
3512 sched = kmp_sch_static_chunked;
3514 chunk = __kmp_str_to_int(comma, *ptr);
3516 chunk = KMP_DEFAULT_CHUNK;
3517 __kmp_msg(kmp_ms_warning, KMP_MSG(InvalidChunk, name, comma),
3519 KMP_INFORM(Using_int_Value, name, __kmp_chunk);
3528 }
else if (chunk > KMP_MAX_CHUNK) {
3529 chunk = KMP_MAX_CHUNK;
3530 __kmp_msg(kmp_ms_warning, KMP_MSG(LargeChunk, name, comma),
3532 KMP_INFORM(Using_int_Value, name, chunk);
3537 #if KMP_USE_HIER_SCHED 3538 if (layer != kmp_hier_layer_e::LAYER_THREAD) {
3539 __kmp_hier_scheds.append(sched, chunk, layer);
3543 __kmp_chunk = chunk;
3544 __kmp_sched = sched;
3549 static void __kmp_stg_parse_omp_schedule(
char const *name,
char const *value,
3552 const char *ptr = value;
3555 length = KMP_STRLEN(value);
3557 if (value[length - 1] ==
'"' || value[length - 1] ==
'\'')
3558 KMP_WARNING(UnbalancedQuotes, name);
3560 #if KMP_USE_HIER_SCHED 3561 if (!__kmp_strcasecmp_with_sentinel(
"EXPERIMENTAL", ptr,
' ')) {
3564 while ((ptr = __kmp_parse_single_omp_schedule(name, ptr,
true))) {
3565 while (*ptr ==
' ' || *ptr ==
'\t' || *ptr ==
':')
3570 __kmp_parse_single_omp_schedule(name, ptr);
3572 KMP_WARNING(EmptyString, name);
3574 #if KMP_USE_HIER_SCHED 3575 __kmp_hier_scheds.sort();
3577 K_DIAG(1, (
"__kmp_static == %d\n", __kmp_static))
3578 K_DIAG(1, (
"__kmp_guided == %d\n", __kmp_guided))
3579 K_DIAG(1, (
"__kmp_sched == %d\n", __kmp_sched))
3580 K_DIAG(1, (
"__kmp_chunk == %d\n", __kmp_chunk))
3583 static void __kmp_stg_print_omp_schedule(kmp_str_buf_t *buffer,
3584 char const *name,
void *data) {
3585 if (__kmp_env_format) {
3586 KMP_STR_BUF_PRINT_NAME_EX(name);
3588 __kmp_str_buf_print(buffer,
" %s='", name);
3591 switch (__kmp_sched) {
3592 case kmp_sch_dynamic_chunked:
3593 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"dynamic", __kmp_chunk);
3595 case kmp_sch_guided_iterative_chunked:
3596 case kmp_sch_guided_analytical_chunked:
3597 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"guided", __kmp_chunk);
3599 case kmp_sch_trapezoidal:
3600 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"trapezoidal", __kmp_chunk);
3603 case kmp_sch_static_chunked:
3604 case kmp_sch_static_balanced:
3605 case kmp_sch_static_greedy:
3606 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"static", __kmp_chunk);
3608 case kmp_sch_static_steal:
3609 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"static_steal", __kmp_chunk);
3612 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"auto", __kmp_chunk);
3616 switch (__kmp_sched) {
3617 case kmp_sch_dynamic_chunked:
3618 __kmp_str_buf_print(buffer,
"%s'\n",
"dynamic");
3620 case kmp_sch_guided_iterative_chunked:
3621 case kmp_sch_guided_analytical_chunked:
3622 __kmp_str_buf_print(buffer,
"%s'\n",
"guided");
3624 case kmp_sch_trapezoidal:
3625 __kmp_str_buf_print(buffer,
"%s'\n",
"trapezoidal");
3628 case kmp_sch_static_chunked:
3629 case kmp_sch_static_balanced:
3630 case kmp_sch_static_greedy:
3631 __kmp_str_buf_print(buffer,
"%s'\n",
"static");
3633 case kmp_sch_static_steal:
3634 __kmp_str_buf_print(buffer,
"%s'\n",
"static_steal");
3637 __kmp_str_buf_print(buffer,
"%s'\n",
"auto");
3643 #if KMP_USE_HIER_SCHED 3646 static void __kmp_stg_parse_kmp_hand_thread(
char const *name,
char const *value,
3648 __kmp_stg_parse_bool(name, value, &(__kmp_dispatch_hand_threading));
3651 static void __kmp_stg_print_kmp_hand_thread(kmp_str_buf_t *buffer,
3652 char const *name,
void *data) {
3653 __kmp_stg_print_bool(buffer, name, __kmp_dispatch_hand_threading);
3660 static void __kmp_stg_parse_atomic_mode(
char const *name,
char const *value,
3666 #ifdef KMP_GOMP_COMPAT 3669 __kmp_stg_parse_int(name, value, 0, max, &mode);
3674 __kmp_atomic_mode = mode;
3678 static void __kmp_stg_print_atomic_mode(kmp_str_buf_t *buffer,
char const *name,
3680 __kmp_stg_print_int(buffer, name, __kmp_atomic_mode);
3686 static void __kmp_stg_parse_consistency_check(
char const *name,
3687 char const *value,
void *data) {
3688 if (!__kmp_strcasecmp_with_sentinel(
"all", value, 0)) {
3694 __kmp_env_consistency_check = TRUE;
3695 }
else if (!__kmp_strcasecmp_with_sentinel(
"none", value, 0)) {
3696 __kmp_env_consistency_check = FALSE;
3698 KMP_WARNING(StgInvalidValue, name, value);
3702 static void __kmp_stg_print_consistency_check(kmp_str_buf_t *buffer,
3703 char const *name,
void *data) {
3705 const char *value = NULL;
3707 if (__kmp_env_consistency_check) {
3713 if (value != NULL) {
3714 __kmp_stg_print_str(buffer, name, value);
3725 static void __kmp_stg_parse_itt_prepare_delay(
char const *name,
3726 char const *value,
void *data) {
3730 __kmp_stg_parse_int(name, value, 0, INT_MAX, &delay);
3731 __kmp_itt_prepare_delay = delay;
3734 static void __kmp_stg_print_itt_prepare_delay(kmp_str_buf_t *buffer,
3735 char const *name,
void *data) {
3736 __kmp_stg_print_uint64(buffer, name, __kmp_itt_prepare_delay);
3740 #endif // USE_ITT_NOTIFY 3746 static void __kmp_stg_parse_malloc_pool_incr(
char const *name,
3747 char const *value,
void *data) {
3748 __kmp_stg_parse_size(name, value, KMP_MIN_MALLOC_POOL_INCR,
3749 KMP_MAX_MALLOC_POOL_INCR, NULL, &__kmp_malloc_pool_incr,
3753 static void __kmp_stg_print_malloc_pool_incr(kmp_str_buf_t *buffer,
3754 char const *name,
void *data) {
3755 __kmp_stg_print_size(buffer, name, __kmp_malloc_pool_incr);
3764 static void __kmp_stg_parse_par_range_env(
char const *name,
char const *value,
3766 __kmp_stg_parse_par_range(name, value, &__kmp_par_range,
3767 __kmp_par_range_routine, __kmp_par_range_filename,
3768 &__kmp_par_range_lb, &__kmp_par_range_ub);
3771 static void __kmp_stg_print_par_range_env(kmp_str_buf_t *buffer,
3772 char const *name,
void *data) {
3773 if (__kmp_par_range != 0) {
3774 __kmp_stg_print_str(buffer, name, par_range_to_print);
3781 static void __kmp_stg_parse_yield_cycle(
char const *name,
char const *value,
3783 int flag = __kmp_yield_cycle;
3784 __kmp_stg_parse_bool(name, value, &flag);
3785 __kmp_yield_cycle = flag;
3788 static void __kmp_stg_print_yield_cycle(kmp_str_buf_t *buffer,
char const *name,
3790 __kmp_stg_print_bool(buffer, name, __kmp_yield_cycle);
3793 static void __kmp_stg_parse_yield_on(
char const *name,
char const *value,
3795 __kmp_stg_parse_int(name, value, 2, INT_MAX, &__kmp_yield_on_count);
3798 static void __kmp_stg_print_yield_on(kmp_str_buf_t *buffer,
char const *name,
3800 __kmp_stg_print_int(buffer, name, __kmp_yield_on_count);
3803 static void __kmp_stg_parse_yield_off(
char const *name,
char const *value,
3805 __kmp_stg_parse_int(name, value, 2, INT_MAX, &__kmp_yield_off_count);
3808 static void __kmp_stg_print_yield_off(kmp_str_buf_t *buffer,
char const *name,
3810 __kmp_stg_print_int(buffer, name, __kmp_yield_off_count);
3818 static void __kmp_stg_parse_init_wait(
char const *name,
char const *value,
3821 KMP_ASSERT((__kmp_init_wait & 1) == 0);
3822 wait = __kmp_init_wait / 2;
3823 __kmp_stg_parse_int(name, value, KMP_MIN_INIT_WAIT, KMP_MAX_INIT_WAIT, &wait);
3824 __kmp_init_wait = wait * 2;
3825 KMP_ASSERT((__kmp_init_wait & 1) == 0);
3826 __kmp_yield_init = __kmp_init_wait;
3829 static void __kmp_stg_print_init_wait(kmp_str_buf_t *buffer,
char const *name,
3831 __kmp_stg_print_int(buffer, name, __kmp_init_wait);
3834 static void __kmp_stg_parse_next_wait(
char const *name,
char const *value,
3837 KMP_ASSERT((__kmp_next_wait & 1) == 0);
3838 wait = __kmp_next_wait / 2;
3839 __kmp_stg_parse_int(name, value, KMP_MIN_NEXT_WAIT, KMP_MAX_NEXT_WAIT, &wait);
3840 __kmp_next_wait = wait * 2;
3841 KMP_ASSERT((__kmp_next_wait & 1) == 0);
3842 __kmp_yield_next = __kmp_next_wait;
3845 static void __kmp_stg_print_next_wait(kmp_str_buf_t *buffer,
char const *name,
3847 __kmp_stg_print_int(buffer, name, __kmp_next_wait);
3853 static void __kmp_stg_parse_gtid_mode(
char const *name,
char const *value,
3863 #ifdef KMP_TDATA_GTID 3866 __kmp_stg_parse_int(name, value, 0, max, &mode);
3870 __kmp_adjust_gtid_mode = TRUE;
3872 __kmp_gtid_mode = mode;
3873 __kmp_adjust_gtid_mode = FALSE;
3877 static void __kmp_stg_print_gtid_mode(kmp_str_buf_t *buffer,
char const *name,
3879 if (__kmp_adjust_gtid_mode) {
3880 __kmp_stg_print_int(buffer, name, 0);
3882 __kmp_stg_print_int(buffer, name, __kmp_gtid_mode);
3889 static void __kmp_stg_parse_lock_block(
char const *name,
char const *value,
3891 __kmp_stg_parse_int(name, value, 0, KMP_INT_MAX, &__kmp_num_locks_in_block);
3894 static void __kmp_stg_print_lock_block(kmp_str_buf_t *buffer,
char const *name,
3896 __kmp_stg_print_int(buffer, name, __kmp_num_locks_in_block);
3902 #if KMP_USE_DYNAMIC_LOCK 3903 #define KMP_STORE_LOCK_SEQ(a) (__kmp_user_lock_seq = lockseq_##a) 3905 #define KMP_STORE_LOCK_SEQ(a) 3908 static void __kmp_stg_parse_lock_kind(
char const *name,
char const *value,
3910 if (__kmp_init_user_locks) {
3911 KMP_WARNING(EnvLockWarn, name);
3915 if (__kmp_str_match(
"tas", 2, value) ||
3916 __kmp_str_match(
"test and set", 2, value) ||
3917 __kmp_str_match(
"test_and_set", 2, value) ||
3918 __kmp_str_match(
"test-and-set", 2, value) ||
3919 __kmp_str_match(
"test andset", 2, value) ||
3920 __kmp_str_match(
"test_andset", 2, value) ||
3921 __kmp_str_match(
"test-andset", 2, value) ||
3922 __kmp_str_match(
"testand set", 2, value) ||
3923 __kmp_str_match(
"testand_set", 2, value) ||
3924 __kmp_str_match(
"testand-set", 2, value) ||
3925 __kmp_str_match(
"testandset", 2, value)) {
3926 __kmp_user_lock_kind = lk_tas;
3927 KMP_STORE_LOCK_SEQ(tas);
3930 else if (__kmp_str_match(
"futex", 1, value)) {
3931 if (__kmp_futex_determine_capable()) {
3932 __kmp_user_lock_kind = lk_futex;
3933 KMP_STORE_LOCK_SEQ(futex);
3935 KMP_WARNING(FutexNotSupported, name, value);
3939 else if (__kmp_str_match(
"ticket", 2, value)) {
3940 __kmp_user_lock_kind = lk_ticket;
3941 KMP_STORE_LOCK_SEQ(ticket);
3942 }
else if (__kmp_str_match(
"queuing", 1, value) ||
3943 __kmp_str_match(
"queue", 1, value)) {
3944 __kmp_user_lock_kind = lk_queuing;
3945 KMP_STORE_LOCK_SEQ(queuing);
3946 }
else if (__kmp_str_match(
"drdpa ticket", 1, value) ||
3947 __kmp_str_match(
"drdpa_ticket", 1, value) ||
3948 __kmp_str_match(
"drdpa-ticket", 1, value) ||
3949 __kmp_str_match(
"drdpaticket", 1, value) ||
3950 __kmp_str_match(
"drdpa", 1, value)) {
3951 __kmp_user_lock_kind = lk_drdpa;
3952 KMP_STORE_LOCK_SEQ(drdpa);
3954 #if KMP_USE_ADAPTIVE_LOCKS 3955 else if (__kmp_str_match(
"adaptive", 1, value)) {
3956 if (__kmp_cpuinfo.rtm) {
3957 __kmp_user_lock_kind = lk_adaptive;
3958 KMP_STORE_LOCK_SEQ(adaptive);
3960 KMP_WARNING(AdaptiveNotSupported, name, value);
3961 __kmp_user_lock_kind = lk_queuing;
3962 KMP_STORE_LOCK_SEQ(queuing);
3965 #endif // KMP_USE_ADAPTIVE_LOCKS 3966 #if KMP_USE_DYNAMIC_LOCK && KMP_USE_TSX 3967 else if (__kmp_str_match(
"rtm", 1, value)) {
3968 if (__kmp_cpuinfo.rtm) {
3969 __kmp_user_lock_kind = lk_rtm;
3970 KMP_STORE_LOCK_SEQ(rtm);
3972 KMP_WARNING(AdaptiveNotSupported, name, value);
3973 __kmp_user_lock_kind = lk_queuing;
3974 KMP_STORE_LOCK_SEQ(queuing);
3976 }
else if (__kmp_str_match(
"hle", 1, value)) {
3977 __kmp_user_lock_kind = lk_hle;
3978 KMP_STORE_LOCK_SEQ(hle);
3982 KMP_WARNING(StgInvalidValue, name, value);
3986 static void __kmp_stg_print_lock_kind(kmp_str_buf_t *buffer,
char const *name,
3988 const char *value = NULL;
3990 switch (__kmp_user_lock_kind) {
4005 #if KMP_USE_DYNAMIC_LOCK && KMP_USE_TSX 4026 #if KMP_USE_ADAPTIVE_LOCKS 4033 if (value != NULL) {
4034 __kmp_stg_print_str(buffer, name, value);
4043 static void __kmp_stg_parse_spin_backoff_params(
const char *name,
4044 const char *value,
void *data) {
4045 const char *next = value;
4048 int prev_comma = FALSE;
4051 kmp_uint32 max_backoff = __kmp_spin_backoff_params.max_backoff;
4052 kmp_uint32 min_tick = __kmp_spin_backoff_params.min_tick;
4056 for (i = 0; i < 3; i++) {
4059 if (*next ==
'\0') {
4064 if (((*next < '0' || *next >
'9') && *next !=
',') || total > 2) {
4065 KMP_WARNING(EnvSyntaxError, name, value);
4071 if (total == 0 || prev_comma) {
4079 if (*next >=
'0' && *next <=
'9') {
4081 const char *buf = next;
4082 char const *msg = NULL;
4087 const char *tmp = next;
4089 if ((*next ==
' ' || *next ==
'\t') && (*tmp >=
'0' && *tmp <=
'9')) {
4090 KMP_WARNING(EnvSpacesNotAllowed, name, value);
4094 num = __kmp_str_to_int(buf, *next);
4096 msg = KMP_I18N_STR(ValueTooSmall);
4098 }
else if (num > KMP_INT_MAX) {
4099 msg = KMP_I18N_STR(ValueTooLarge);
4104 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
4105 KMP_INFORM(Using_int_Value, name, num);
4109 }
else if (total == 2) {
4114 KMP_DEBUG_ASSERT(total > 0);
4116 KMP_WARNING(EnvSyntaxError, name, value);
4119 __kmp_spin_backoff_params.max_backoff = max_backoff;
4120 __kmp_spin_backoff_params.min_tick = min_tick;
4123 static void __kmp_stg_print_spin_backoff_params(kmp_str_buf_t *buffer,
4124 char const *name,
void *data) {
4125 if (__kmp_env_format) {
4126 KMP_STR_BUF_PRINT_NAME_EX(name);
4128 __kmp_str_buf_print(buffer,
" %s='", name);
4130 __kmp_str_buf_print(buffer,
"%d,%d'\n", __kmp_spin_backoff_params.max_backoff,
4131 __kmp_spin_backoff_params.min_tick);
4134 #if KMP_USE_ADAPTIVE_LOCKS 4141 static void __kmp_stg_parse_adaptive_lock_props(
const char *name,
4142 const char *value,
void *data) {
4143 int max_retries = 0;
4144 int max_badness = 0;
4146 const char *next = value;
4149 int prev_comma = FALSE;
4155 for (i = 0; i < 3; i++) {
4158 if (*next ==
'\0') {
4163 if (((*next < '0' || *next >
'9') && *next !=
',') || total > 2) {
4164 KMP_WARNING(EnvSyntaxError, name, value);
4170 if (total == 0 || prev_comma) {
4178 if (*next >=
'0' && *next <=
'9') {
4180 const char *buf = next;
4181 char const *msg = NULL;
4186 const char *tmp = next;
4188 if ((*next ==
' ' || *next ==
'\t') && (*tmp >=
'0' && *tmp <=
'9')) {
4189 KMP_WARNING(EnvSpacesNotAllowed, name, value);
4193 num = __kmp_str_to_int(buf, *next);
4195 msg = KMP_I18N_STR(ValueTooSmall);
4197 }
else if (num > KMP_INT_MAX) {
4198 msg = KMP_I18N_STR(ValueTooLarge);
4203 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
4204 KMP_INFORM(Using_int_Value, name, num);
4208 }
else if (total == 2) {
4213 KMP_DEBUG_ASSERT(total > 0);
4215 KMP_WARNING(EnvSyntaxError, name, value);
4218 __kmp_adaptive_backoff_params.max_soft_retries = max_retries;
4219 __kmp_adaptive_backoff_params.max_badness = max_badness;
4222 static void __kmp_stg_print_adaptive_lock_props(kmp_str_buf_t *buffer,
4223 char const *name,
void *data) {
4224 if (__kmp_env_format) {
4225 KMP_STR_BUF_PRINT_NAME_EX(name);
4227 __kmp_str_buf_print(buffer,
" %s='", name);
4229 __kmp_str_buf_print(buffer,
"%d,%d'\n",
4230 __kmp_adaptive_backoff_params.max_soft_retries,
4231 __kmp_adaptive_backoff_params.max_badness);
4234 #if KMP_DEBUG_ADAPTIVE_LOCKS 4236 static void __kmp_stg_parse_speculative_statsfile(
char const *name,
4239 __kmp_stg_parse_file(name, value,
"", CCAST(
char**, &__kmp_speculative_statsfile));
4242 static void __kmp_stg_print_speculative_statsfile(kmp_str_buf_t *buffer,
4245 if (__kmp_str_match(
"-", 0, __kmp_speculative_statsfile)) {
4246 __kmp_stg_print_str(buffer, name,
"stdout");
4248 __kmp_stg_print_str(buffer, name, __kmp_speculative_statsfile);
4253 #endif // KMP_DEBUG_ADAPTIVE_LOCKS 4255 #endif // KMP_USE_ADAPTIVE_LOCKS 4264 #define MAX_T_LEVEL 5 4265 #define MAX_STR_LEN 512 4266 static void __kmp_stg_parse_hw_subset(
char const *name,
char const *value,
4270 kmp_setting_t **rivals = (kmp_setting_t **)data;
4271 if (strcmp(name,
"KMP_PLACE_THREADS") == 0) {
4272 KMP_INFORM(EnvVarDeprecated, name,
"KMP_HW_SUBSET");
4274 if (__kmp_stg_check_rivals(name, value, rivals)) {
4278 char *components[MAX_T_LEVEL];
4279 char const *digits =
"0123456789";
4280 char input[MAX_STR_LEN];
4281 size_t len = 0, mlen = MAX_STR_LEN;
4284 char *pos = CCAST(
char *, value);
4285 while (*pos && mlen) {
4287 if (len == 0 && *pos ==
':') {
4288 __kmp_hws_abs_flag = 1;
4290 input[len] = toupper(*pos);
4291 if (input[len] ==
'X')
4293 if (input[len] ==
'O' && strchr(digits, *(pos + 1)))
4301 if (len == 0 || mlen == 0)
4304 __kmp_hws_requested = 1;
4307 components[level++] = pos;
4308 while ((pos = strchr(pos,
','))) {
4310 components[level++] = ++pos;
4311 if (level > MAX_T_LEVEL)
4315 for (
int i = 0; i < level; ++i) {
4317 int num = atoi(components[i]);
4318 if ((pos = strchr(components[i],
'@'))) {
4319 offset = atoi(pos + 1);
4322 pos = components[i] + strspn(components[i], digits);
4323 if (pos == components[i])
4328 if (__kmp_hws_socket.num > 0)
4330 __kmp_hws_socket.num = num;
4331 __kmp_hws_socket.offset = offset;
4334 if (__kmp_hws_node.num > 0)
4336 __kmp_hws_node.num = num;
4337 __kmp_hws_node.offset = offset;
4340 if (*(pos + 1) ==
'2') {
4341 if (__kmp_hws_tile.num > 0)
4343 __kmp_hws_tile.num = num;
4344 __kmp_hws_tile.offset = offset;
4345 }
else if (*(pos + 1) ==
'3') {
4346 if (__kmp_hws_socket.num > 0)
4348 __kmp_hws_socket.num = num;
4349 __kmp_hws_socket.offset = offset;
4350 }
else if (*(pos + 1) ==
'1') {
4351 if (__kmp_hws_core.num > 0)
4353 __kmp_hws_core.num = num;
4354 __kmp_hws_core.offset = offset;
4358 if (*(pos + 1) !=
'A') {
4359 if (__kmp_hws_core.num > 0)
4361 __kmp_hws_core.num = num;
4362 __kmp_hws_core.offset = offset;
4364 char *d = pos + strcspn(pos, digits);
4366 if (__kmp_hws_tile.num > 0)
4368 __kmp_hws_tile.num = num;
4369 __kmp_hws_tile.offset = offset;
4370 }
else if (*d ==
'3') {
4371 if (__kmp_hws_socket.num > 0)
4373 __kmp_hws_socket.num = num;
4374 __kmp_hws_socket.offset = offset;
4375 }
else if (*d ==
'1') {
4376 if (__kmp_hws_core.num > 0)
4378 __kmp_hws_core.num = num;
4379 __kmp_hws_core.offset = offset;
4386 if (__kmp_hws_proc.num > 0)
4388 __kmp_hws_proc.num = num;
4389 __kmp_hws_proc.offset = offset;
4397 KMP_WARNING(AffHWSubsetInvalid, name, value);
4398 __kmp_hws_requested = 0;
4402 static void __kmp_stg_print_hw_subset(kmp_str_buf_t *buffer,
char const *name,
4404 if (__kmp_hws_requested) {
4407 __kmp_str_buf_init(&buf);
4408 if (__kmp_env_format)
4409 KMP_STR_BUF_PRINT_NAME_EX(name);
4411 __kmp_str_buf_print(buffer,
" %s='", name);
4412 if (__kmp_hws_socket.num) {
4413 __kmp_str_buf_print(&buf,
"%ds", __kmp_hws_socket.num);
4414 if (__kmp_hws_socket.offset)
4415 __kmp_str_buf_print(&buf,
"@%d", __kmp_hws_socket.offset);
4418 if (__kmp_hws_node.num) {
4419 __kmp_str_buf_print(&buf,
"%s%dn", comma ?
"," :
"", __kmp_hws_node.num);
4420 if (__kmp_hws_node.offset)
4421 __kmp_str_buf_print(&buf,
"@%d", __kmp_hws_node.offset);
4424 if (__kmp_hws_tile.num) {
4425 __kmp_str_buf_print(&buf,
"%s%dL2", comma ?
"," :
"", __kmp_hws_tile.num);
4426 if (__kmp_hws_tile.offset)
4427 __kmp_str_buf_print(&buf,
"@%d", __kmp_hws_tile.offset);
4430 if (__kmp_hws_core.num) {
4431 __kmp_str_buf_print(&buf,
"%s%dc", comma ?
"," :
"", __kmp_hws_core.num);
4432 if (__kmp_hws_core.offset)
4433 __kmp_str_buf_print(&buf,
"@%d", __kmp_hws_core.offset);
4436 if (__kmp_hws_proc.num)
4437 __kmp_str_buf_print(&buf,
"%s%dt", comma ?
"," :
"", __kmp_hws_proc.num);
4438 __kmp_str_buf_print(buffer,
"%s'\n", buf.str);
4439 __kmp_str_buf_free(&buf);
4447 static void __kmp_stg_parse_forkjoin_frames(
char const *name,
char const *value,
4449 __kmp_stg_parse_bool(name, value, &__kmp_forkjoin_frames);
4452 static void __kmp_stg_print_forkjoin_frames(kmp_str_buf_t *buffer,
4453 char const *name,
void *data) {
4454 __kmp_stg_print_bool(buffer, name, __kmp_forkjoin_frames);
4460 static void __kmp_stg_parse_forkjoin_frames_mode(
char const *name,
4463 __kmp_stg_parse_int(name, value, 0, 3, &__kmp_forkjoin_frames_mode);
4466 static void __kmp_stg_print_forkjoin_frames_mode(kmp_str_buf_t *buffer,
4467 char const *name,
void *data) {
4468 __kmp_stg_print_int(buffer, name, __kmp_forkjoin_frames_mode);
4477 static void __kmp_stg_parse_omp_display_env(
char const *name,
char const *value,
4479 if (__kmp_str_match(
"VERBOSE", 1, value)) {
4480 __kmp_display_env_verbose = TRUE;
4482 __kmp_stg_parse_bool(name, value, &__kmp_display_env);
4487 static void __kmp_stg_print_omp_display_env(kmp_str_buf_t *buffer,
4488 char const *name,
void *data) {
4489 if (__kmp_display_env_verbose) {
4490 __kmp_stg_print_str(buffer, name,
"VERBOSE");
4492 __kmp_stg_print_bool(buffer, name, __kmp_display_env);
4496 static void __kmp_stg_parse_omp_cancellation(
char const *name,
4497 char const *value,
void *data) {
4498 if (TCR_4(__kmp_init_parallel)) {
4499 KMP_WARNING(EnvParallelWarn, name);
4502 __kmp_stg_parse_bool(name, value, &__kmp_omp_cancellation);
4505 static void __kmp_stg_print_omp_cancellation(kmp_str_buf_t *buffer,
4506 char const *name,
void *data) {
4507 __kmp_stg_print_bool(buffer, name, __kmp_omp_cancellation);
4512 #if OMP_50_ENABLED && OMPT_SUPPORT 4514 static char *__kmp_tool_libraries = NULL;
4516 static void __kmp_stg_parse_omp_tool_libraries(
char const *name,
4517 char const *value,
void *data) {
4518 __kmp_stg_parse_str(name, value, &__kmp_tool_libraries);
4521 static void __kmp_stg_print_omp_tool_libraries(kmp_str_buf_t *buffer,
4522 char const *name,
void *data) {
4523 if (__kmp_tool_libraries)
4524 __kmp_stg_print_str(buffer, name, __kmp_tool_libraries);
4526 if (__kmp_env_format) {
4527 KMP_STR_BUF_PRINT_NAME;
4529 __kmp_str_buf_print(buffer,
" %s", name);
4531 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
4539 static kmp_setting_t __kmp_stg_table[] = {
4541 {
"KMP_ALL_THREADS", __kmp_stg_parse_device_thread_limit, NULL, NULL, 0, 0},
4542 {
"KMP_BLOCKTIME", __kmp_stg_parse_blocktime, __kmp_stg_print_blocktime,
4544 {
"KMP_DUPLICATE_LIB_OK", __kmp_stg_parse_duplicate_lib_ok,
4545 __kmp_stg_print_duplicate_lib_ok, NULL, 0, 0},
4546 {
"KMP_LIBRARY", __kmp_stg_parse_wait_policy, __kmp_stg_print_wait_policy,
4548 {
"KMP_DEVICE_THREAD_LIMIT", __kmp_stg_parse_device_thread_limit,
4549 __kmp_stg_print_device_thread_limit, NULL, 0, 0},
4551 {
"KMP_MONITOR_STACKSIZE", __kmp_stg_parse_monitor_stacksize,
4552 __kmp_stg_print_monitor_stacksize, NULL, 0, 0},
4554 {
"KMP_SETTINGS", __kmp_stg_parse_settings, __kmp_stg_print_settings, NULL,
4556 {
"KMP_STACKOFFSET", __kmp_stg_parse_stackoffset,
4557 __kmp_stg_print_stackoffset, NULL, 0, 0},
4558 {
"KMP_STACKSIZE", __kmp_stg_parse_stacksize, __kmp_stg_print_stacksize,
4560 {
"KMP_STACKPAD", __kmp_stg_parse_stackpad, __kmp_stg_print_stackpad, NULL,
4562 {
"KMP_VERSION", __kmp_stg_parse_version, __kmp_stg_print_version, NULL, 0,
4564 {
"KMP_WARNINGS", __kmp_stg_parse_warnings, __kmp_stg_print_warnings, NULL,
4567 {
"OMP_NESTED", __kmp_stg_parse_nested, __kmp_stg_print_nested, NULL, 0, 0},
4568 {
"OMP_NUM_THREADS", __kmp_stg_parse_num_threads,
4569 __kmp_stg_print_num_threads, NULL, 0, 0},
4570 {
"OMP_STACKSIZE", __kmp_stg_parse_stacksize, __kmp_stg_print_stacksize,
4573 {
"KMP_TASKING", __kmp_stg_parse_tasking, __kmp_stg_print_tasking, NULL, 0,
4575 {
"KMP_TASK_STEALING_CONSTRAINT", __kmp_stg_parse_task_stealing,
4576 __kmp_stg_print_task_stealing, NULL, 0, 0},
4577 {
"OMP_MAX_ACTIVE_LEVELS", __kmp_stg_parse_max_active_levels,
4578 __kmp_stg_print_max_active_levels, NULL, 0, 0},
4580 {
"OMP_DEFAULT_DEVICE", __kmp_stg_parse_default_device,
4581 __kmp_stg_print_default_device, NULL, 0, 0},
4584 {
"OMP_TARGET_OFFLOAD", __kmp_stg_parse_target_offload,
4585 __kmp_stg_print_target_offload, NULL, 0, 0},
4588 {
"OMP_MAX_TASK_PRIORITY", __kmp_stg_parse_max_task_priority,
4589 __kmp_stg_print_max_task_priority, NULL, 0, 0},
4590 {
"KMP_TASKLOOP_MIN_TASKS", __kmp_stg_parse_taskloop_min_tasks,
4591 __kmp_stg_print_taskloop_min_tasks, NULL, 0, 0},
4593 {
"OMP_THREAD_LIMIT", __kmp_stg_parse_thread_limit,
4594 __kmp_stg_print_thread_limit, NULL, 0, 0},
4595 {
"KMP_TEAMS_THREAD_LIMIT", __kmp_stg_parse_teams_thread_limit,
4596 __kmp_stg_print_teams_thread_limit, NULL, 0, 0},
4597 {
"OMP_WAIT_POLICY", __kmp_stg_parse_wait_policy,
4598 __kmp_stg_print_wait_policy, NULL, 0, 0},
4599 {
"KMP_DISP_NUM_BUFFERS", __kmp_stg_parse_disp_buffers,
4600 __kmp_stg_print_disp_buffers, NULL, 0, 0},
4601 #if KMP_NESTED_HOT_TEAMS 4602 {
"KMP_HOT_TEAMS_MAX_LEVEL", __kmp_stg_parse_hot_teams_level,
4603 __kmp_stg_print_hot_teams_level, NULL, 0, 0},
4604 {
"KMP_HOT_TEAMS_MODE", __kmp_stg_parse_hot_teams_mode,
4605 __kmp_stg_print_hot_teams_mode, NULL, 0, 0},
4606 #endif // KMP_NESTED_HOT_TEAMS 4608 #if KMP_HANDLE_SIGNALS 4609 {
"KMP_HANDLE_SIGNALS", __kmp_stg_parse_handle_signals,
4610 __kmp_stg_print_handle_signals, NULL, 0, 0},
4613 #if KMP_ARCH_X86 || KMP_ARCH_X86_64 4614 {
"KMP_INHERIT_FP_CONTROL", __kmp_stg_parse_inherit_fp_control,
4615 __kmp_stg_print_inherit_fp_control, NULL, 0, 0},
4618 #ifdef KMP_GOMP_COMPAT 4619 {
"GOMP_STACKSIZE", __kmp_stg_parse_stacksize, NULL, NULL, 0, 0},
4623 {
"KMP_A_DEBUG", __kmp_stg_parse_a_debug, __kmp_stg_print_a_debug, NULL, 0,
4625 {
"KMP_B_DEBUG", __kmp_stg_parse_b_debug, __kmp_stg_print_b_debug, NULL, 0,
4627 {
"KMP_C_DEBUG", __kmp_stg_parse_c_debug, __kmp_stg_print_c_debug, NULL, 0,
4629 {
"KMP_D_DEBUG", __kmp_stg_parse_d_debug, __kmp_stg_print_d_debug, NULL, 0,
4631 {
"KMP_E_DEBUG", __kmp_stg_parse_e_debug, __kmp_stg_print_e_debug, NULL, 0,
4633 {
"KMP_F_DEBUG", __kmp_stg_parse_f_debug, __kmp_stg_print_f_debug, NULL, 0,
4635 {
"KMP_DEBUG", __kmp_stg_parse_debug, NULL, NULL, 0, 0},
4636 {
"KMP_DEBUG_BUF", __kmp_stg_parse_debug_buf, __kmp_stg_print_debug_buf,
4638 {
"KMP_DEBUG_BUF_ATOMIC", __kmp_stg_parse_debug_buf_atomic,
4639 __kmp_stg_print_debug_buf_atomic, NULL, 0, 0},
4640 {
"KMP_DEBUG_BUF_CHARS", __kmp_stg_parse_debug_buf_chars,
4641 __kmp_stg_print_debug_buf_chars, NULL, 0, 0},
4642 {
"KMP_DEBUG_BUF_LINES", __kmp_stg_parse_debug_buf_lines,
4643 __kmp_stg_print_debug_buf_lines, NULL, 0, 0},
4644 {
"KMP_DIAG", __kmp_stg_parse_diag, __kmp_stg_print_diag, NULL, 0, 0},
4646 {
"KMP_PAR_RANGE", __kmp_stg_parse_par_range_env,
4647 __kmp_stg_print_par_range_env, NULL, 0, 0},
4648 {
"KMP_YIELD_CYCLE", __kmp_stg_parse_yield_cycle,
4649 __kmp_stg_print_yield_cycle, NULL, 0, 0},
4650 {
"KMP_YIELD_ON", __kmp_stg_parse_yield_on, __kmp_stg_print_yield_on, NULL,
4652 {
"KMP_YIELD_OFF", __kmp_stg_parse_yield_off, __kmp_stg_print_yield_off,
4656 {
"KMP_ALIGN_ALLOC", __kmp_stg_parse_align_alloc,
4657 __kmp_stg_print_align_alloc, NULL, 0, 0},
4659 {
"KMP_PLAIN_BARRIER", __kmp_stg_parse_barrier_branch_bit,
4660 __kmp_stg_print_barrier_branch_bit, NULL, 0, 0},
4661 {
"KMP_PLAIN_BARRIER_PATTERN", __kmp_stg_parse_barrier_pattern,
4662 __kmp_stg_print_barrier_pattern, NULL, 0, 0},
4663 {
"KMP_FORKJOIN_BARRIER", __kmp_stg_parse_barrier_branch_bit,
4664 __kmp_stg_print_barrier_branch_bit, NULL, 0, 0},
4665 {
"KMP_FORKJOIN_BARRIER_PATTERN", __kmp_stg_parse_barrier_pattern,
4666 __kmp_stg_print_barrier_pattern, NULL, 0, 0},
4667 #if KMP_FAST_REDUCTION_BARRIER 4668 {
"KMP_REDUCTION_BARRIER", __kmp_stg_parse_barrier_branch_bit,
4669 __kmp_stg_print_barrier_branch_bit, NULL, 0, 0},
4670 {
"KMP_REDUCTION_BARRIER_PATTERN", __kmp_stg_parse_barrier_pattern,
4671 __kmp_stg_print_barrier_pattern, NULL, 0, 0},
4674 {
"KMP_ABORT_DELAY", __kmp_stg_parse_abort_delay,
4675 __kmp_stg_print_abort_delay, NULL, 0, 0},
4676 {
"KMP_CPUINFO_FILE", __kmp_stg_parse_cpuinfo_file,
4677 __kmp_stg_print_cpuinfo_file, NULL, 0, 0},
4678 {
"KMP_FORCE_REDUCTION", __kmp_stg_parse_force_reduction,
4679 __kmp_stg_print_force_reduction, NULL, 0, 0},
4680 {
"KMP_DETERMINISTIC_REDUCTION", __kmp_stg_parse_force_reduction,
4681 __kmp_stg_print_force_reduction, NULL, 0, 0},
4682 {
"KMP_STORAGE_MAP", __kmp_stg_parse_storage_map,
4683 __kmp_stg_print_storage_map, NULL, 0, 0},
4684 {
"KMP_ALL_THREADPRIVATE", __kmp_stg_parse_all_threadprivate,
4685 __kmp_stg_print_all_threadprivate, NULL, 0, 0},
4686 {
"KMP_FOREIGN_THREADS_THREADPRIVATE",
4687 __kmp_stg_parse_foreign_threads_threadprivate,
4688 __kmp_stg_print_foreign_threads_threadprivate, NULL, 0, 0},
4690 #if KMP_AFFINITY_SUPPORTED 4691 {
"KMP_AFFINITY", __kmp_stg_parse_affinity, __kmp_stg_print_affinity, NULL,
4693 #ifdef KMP_GOMP_COMPAT 4694 {
"GOMP_CPU_AFFINITY", __kmp_stg_parse_gomp_cpu_affinity, NULL,
4698 {
"OMP_PROC_BIND", __kmp_stg_parse_proc_bind, __kmp_stg_print_proc_bind,
4700 {
"OMP_PLACES", __kmp_stg_parse_places, __kmp_stg_print_places, NULL, 0, 0},
4702 {
"OMP_PROC_BIND", __kmp_stg_parse_proc_bind, NULL, NULL, 0,
4706 {
"KMP_TOPOLOGY_METHOD", __kmp_stg_parse_topology_method,
4707 __kmp_stg_print_topology_method, NULL, 0, 0},
4714 {
"OMP_PROC_BIND", __kmp_stg_parse_proc_bind, __kmp_stg_print_proc_bind,
4718 #endif // KMP_AFFINITY_SUPPORTED 4720 {
"KMP_INIT_AT_FORK", __kmp_stg_parse_init_at_fork,
4721 __kmp_stg_print_init_at_fork, NULL, 0, 0},
4722 {
"KMP_SCHEDULE", __kmp_stg_parse_schedule, __kmp_stg_print_schedule, NULL,
4724 {
"OMP_SCHEDULE", __kmp_stg_parse_omp_schedule, __kmp_stg_print_omp_schedule,
4726 #if KMP_USE_HIER_SCHED 4727 {
"KMP_DISP_HAND_THREAD", __kmp_stg_parse_kmp_hand_thread,
4728 __kmp_stg_print_kmp_hand_thread, NULL, 0, 0},
4730 {
"KMP_ATOMIC_MODE", __kmp_stg_parse_atomic_mode,
4731 __kmp_stg_print_atomic_mode, NULL, 0, 0},
4732 {
"KMP_CONSISTENCY_CHECK", __kmp_stg_parse_consistency_check,
4733 __kmp_stg_print_consistency_check, NULL, 0, 0},
4735 #if USE_ITT_BUILD && USE_ITT_NOTIFY 4736 {
"KMP_ITT_PREPARE_DELAY", __kmp_stg_parse_itt_prepare_delay,
4737 __kmp_stg_print_itt_prepare_delay, NULL, 0, 0},
4739 {
"KMP_MALLOC_POOL_INCR", __kmp_stg_parse_malloc_pool_incr,
4740 __kmp_stg_print_malloc_pool_incr, NULL, 0, 0},
4741 {
"KMP_INIT_WAIT", __kmp_stg_parse_init_wait, __kmp_stg_print_init_wait,
4743 {
"KMP_NEXT_WAIT", __kmp_stg_parse_next_wait, __kmp_stg_print_next_wait,
4745 {
"KMP_GTID_MODE", __kmp_stg_parse_gtid_mode, __kmp_stg_print_gtid_mode,
4747 {
"OMP_DYNAMIC", __kmp_stg_parse_omp_dynamic, __kmp_stg_print_omp_dynamic,
4749 {
"KMP_DYNAMIC_MODE", __kmp_stg_parse_kmp_dynamic_mode,
4750 __kmp_stg_print_kmp_dynamic_mode, NULL, 0, 0},
4752 #ifdef USE_LOAD_BALANCE 4753 {
"KMP_LOAD_BALANCE_INTERVAL", __kmp_stg_parse_ld_balance_interval,
4754 __kmp_stg_print_ld_balance_interval, NULL, 0, 0},
4757 {
"KMP_NUM_LOCKS_IN_BLOCK", __kmp_stg_parse_lock_block,
4758 __kmp_stg_print_lock_block, NULL, 0, 0},
4759 {
"KMP_LOCK_KIND", __kmp_stg_parse_lock_kind, __kmp_stg_print_lock_kind,
4761 {
"KMP_SPIN_BACKOFF_PARAMS", __kmp_stg_parse_spin_backoff_params,
4762 __kmp_stg_print_spin_backoff_params, NULL, 0, 0},
4763 #if KMP_USE_ADAPTIVE_LOCKS 4764 {
"KMP_ADAPTIVE_LOCK_PROPS", __kmp_stg_parse_adaptive_lock_props,
4765 __kmp_stg_print_adaptive_lock_props, NULL, 0, 0},
4766 #if KMP_DEBUG_ADAPTIVE_LOCKS 4767 {
"KMP_SPECULATIVE_STATSFILE", __kmp_stg_parse_speculative_statsfile,
4768 __kmp_stg_print_speculative_statsfile, NULL, 0, 0},
4770 #endif // KMP_USE_ADAPTIVE_LOCKS 4771 {
"KMP_PLACE_THREADS", __kmp_stg_parse_hw_subset, __kmp_stg_print_hw_subset,
4773 {
"KMP_HW_SUBSET", __kmp_stg_parse_hw_subset, __kmp_stg_print_hw_subset,
4776 {
"KMP_FORKJOIN_FRAMES", __kmp_stg_parse_forkjoin_frames,
4777 __kmp_stg_print_forkjoin_frames, NULL, 0, 0},
4778 {
"KMP_FORKJOIN_FRAMES_MODE", __kmp_stg_parse_forkjoin_frames_mode,
4779 __kmp_stg_print_forkjoin_frames_mode, NULL, 0, 0},
4783 {
"OMP_DISPLAY_ENV", __kmp_stg_parse_omp_display_env,
4784 __kmp_stg_print_omp_display_env, NULL, 0, 0},
4785 {
"OMP_CANCELLATION", __kmp_stg_parse_omp_cancellation,
4786 __kmp_stg_print_omp_cancellation, NULL, 0, 0},
4789 #if OMP_50_ENABLED && OMPT_SUPPORT 4790 {
"OMP_TOOL_LIBRARIES", __kmp_stg_parse_omp_tool_libraries,
4791 __kmp_stg_print_omp_tool_libraries, NULL, 0, 0},
4794 {
"", NULL, NULL, NULL, 0, 0}};
4796 static int const __kmp_stg_count =
4797 sizeof(__kmp_stg_table) /
sizeof(kmp_setting_t);
4799 static inline kmp_setting_t *__kmp_stg_find(
char const *name) {
4803 for (i = 0; i < __kmp_stg_count; ++i) {
4804 if (strcmp(__kmp_stg_table[i].name, name) == 0) {
4805 return &__kmp_stg_table[i];
4813 static int __kmp_stg_cmp(
void const *_a,
void const *_b) {
4814 const kmp_setting_t *a = RCAST(
const kmp_setting_t *, _a);
4815 const kmp_setting_t *b = RCAST(
const kmp_setting_t *, _b);
4819 if (strcmp(a->name,
"KMP_AFFINITY") == 0) {
4820 if (strcmp(b->name,
"KMP_AFFINITY") == 0) {
4824 }
else if (strcmp(b->name,
"KMP_AFFINITY") == 0) {
4827 return strcmp(a->name, b->name);
4830 static void __kmp_stg_init(
void) {
4832 static int initialized = 0;
4837 qsort(__kmp_stg_table, __kmp_stg_count - 1,
sizeof(kmp_setting_t),
4841 kmp_setting_t *kmp_stacksize =
4842 __kmp_stg_find(
"KMP_STACKSIZE");
4843 #ifdef KMP_GOMP_COMPAT 4844 kmp_setting_t *gomp_stacksize =
4845 __kmp_stg_find(
"GOMP_STACKSIZE");
4847 kmp_setting_t *omp_stacksize =
4848 __kmp_stg_find(
"OMP_STACKSIZE");
4854 static kmp_setting_t *
volatile rivals[4];
4855 static kmp_stg_ss_data_t kmp_data = {1, CCAST(kmp_setting_t **, rivals)};
4856 #ifdef KMP_GOMP_COMPAT 4857 static kmp_stg_ss_data_t gomp_data = {1024,
4858 CCAST(kmp_setting_t **, rivals)};
4860 static kmp_stg_ss_data_t omp_data = {1024,
4861 CCAST(kmp_setting_t **, rivals)};
4864 rivals[i++] = kmp_stacksize;
4865 #ifdef KMP_GOMP_COMPAT 4866 if (gomp_stacksize != NULL) {
4867 rivals[i++] = gomp_stacksize;
4870 rivals[i++] = omp_stacksize;
4873 kmp_stacksize->data = &kmp_data;
4874 #ifdef KMP_GOMP_COMPAT 4875 if (gomp_stacksize != NULL) {
4876 gomp_stacksize->data = &gomp_data;
4879 omp_stacksize->data = &omp_data;
4883 kmp_setting_t *kmp_library =
4884 __kmp_stg_find(
"KMP_LIBRARY");
4885 kmp_setting_t *omp_wait_policy =
4886 __kmp_stg_find(
"OMP_WAIT_POLICY");
4889 static kmp_setting_t *
volatile rivals[3];
4890 static kmp_stg_wp_data_t kmp_data = {0, CCAST(kmp_setting_t **, rivals)};
4891 static kmp_stg_wp_data_t omp_data = {1, CCAST(kmp_setting_t **, rivals)};
4894 rivals[i++] = kmp_library;
4895 if (omp_wait_policy != NULL) {
4896 rivals[i++] = omp_wait_policy;
4900 kmp_library->data = &kmp_data;
4901 if (omp_wait_policy != NULL) {
4902 omp_wait_policy->data = &omp_data;
4907 kmp_setting_t *kmp_device_thread_limit =
4908 __kmp_stg_find(
"KMP_DEVICE_THREAD_LIMIT");
4909 kmp_setting_t *kmp_all_threads =
4910 __kmp_stg_find(
"KMP_ALL_THREADS");
4913 static kmp_setting_t *
volatile rivals[3];
4916 rivals[i++] = kmp_device_thread_limit;
4917 rivals[i++] = kmp_all_threads;
4920 kmp_device_thread_limit->data = CCAST(kmp_setting_t **, rivals);
4921 kmp_all_threads->data = CCAST(kmp_setting_t **, rivals);
4926 kmp_setting_t *kmp_hw_subset = __kmp_stg_find(
"KMP_HW_SUBSET");
4928 kmp_setting_t *kmp_place_threads = __kmp_stg_find(
"KMP_PLACE_THREADS");
4931 static kmp_setting_t *
volatile rivals[3];
4934 rivals[i++] = kmp_hw_subset;
4935 rivals[i++] = kmp_place_threads;
4938 kmp_hw_subset->data = CCAST(kmp_setting_t **, rivals);
4939 kmp_place_threads->data = CCAST(kmp_setting_t **, rivals);
4942 #if KMP_AFFINITY_SUPPORTED 4944 kmp_setting_t *kmp_affinity =
4945 __kmp_stg_find(
"KMP_AFFINITY");
4946 KMP_DEBUG_ASSERT(kmp_affinity != NULL);
4948 #ifdef KMP_GOMP_COMPAT 4949 kmp_setting_t *gomp_cpu_affinity =
4950 __kmp_stg_find(
"GOMP_CPU_AFFINITY");
4951 KMP_DEBUG_ASSERT(gomp_cpu_affinity != NULL);
4954 kmp_setting_t *omp_proc_bind =
4955 __kmp_stg_find(
"OMP_PROC_BIND");
4956 KMP_DEBUG_ASSERT(omp_proc_bind != NULL);
4959 static kmp_setting_t *
volatile rivals[4];
4962 rivals[i++] = kmp_affinity;
4964 #ifdef KMP_GOMP_COMPAT 4965 rivals[i++] = gomp_cpu_affinity;
4966 gomp_cpu_affinity->data = CCAST(kmp_setting_t **, rivals);
4969 rivals[i++] = omp_proc_bind;
4970 omp_proc_bind->data = CCAST(kmp_setting_t **, rivals);
4974 static kmp_setting_t *
volatile places_rivals[4];
4977 kmp_setting_t *omp_places = __kmp_stg_find(
"OMP_PLACES");
4978 KMP_DEBUG_ASSERT(omp_places != NULL);
4980 places_rivals[i++] = kmp_affinity;
4981 #ifdef KMP_GOMP_COMPAT 4982 places_rivals[i++] = gomp_cpu_affinity;
4984 places_rivals[i++] = omp_places;
4985 omp_places->data = CCAST(kmp_setting_t **, places_rivals);
4986 places_rivals[i++] = NULL;
4992 #endif // KMP_AFFINITY_SUPPORTED 4995 kmp_setting_t *kmp_force_red =
4996 __kmp_stg_find(
"KMP_FORCE_REDUCTION");
4997 kmp_setting_t *kmp_determ_red =
4998 __kmp_stg_find(
"KMP_DETERMINISTIC_REDUCTION");
5001 static kmp_setting_t *
volatile rivals[3];
5002 static kmp_stg_fr_data_t force_data = {1,
5003 CCAST(kmp_setting_t **, rivals)};
5004 static kmp_stg_fr_data_t determ_data = {0,
5005 CCAST(kmp_setting_t **, rivals)};
5008 rivals[i++] = kmp_force_red;
5009 if (kmp_determ_red != NULL) {
5010 rivals[i++] = kmp_determ_red;
5014 kmp_force_red->data = &force_data;
5015 if (kmp_determ_red != NULL) {
5016 kmp_determ_red->data = &determ_data;
5025 for (i = 0; i < __kmp_stg_count; ++i) {
5026 __kmp_stg_table[i].set = 0;
5031 static void __kmp_stg_parse(
char const *name,
char const *value) {
5039 if (value != NULL) {
5040 kmp_setting_t *setting = __kmp_stg_find(name);
5041 if (setting != NULL) {
5042 setting->parse(name, value, setting->data);
5043 setting->defined = 1;
5049 static int __kmp_stg_check_rivals(
5052 kmp_setting_t **rivals
5055 if (rivals == NULL) {
5061 for (; strcmp(rivals[i]->name, name) != 0; i++) {
5062 KMP_DEBUG_ASSERT(rivals[i] != NULL);
5064 #if KMP_AFFINITY_SUPPORTED 5065 if (rivals[i] == __kmp_affinity_notype) {
5072 if (rivals[i]->
set) {
5073 KMP_WARNING(StgIgnored, name, rivals[i]->name);
5083 static int __kmp_env_toPrint(
char const *name,
int flag) {
5085 kmp_setting_t *setting = __kmp_stg_find(name);
5086 if (setting != NULL) {
5087 rc = setting->defined;
5089 setting->defined = flag;
5095 static void __kmp_aux_env_initialize(kmp_env_blk_t *block) {
5100 value = __kmp_env_blk_var(block,
"OMP_NUM_THREADS");
5102 ompc_set_num_threads(__kmp_dflt_team_nth);
5106 value = __kmp_env_blk_var(block,
"KMP_BLOCKTIME");
5108 kmpc_set_blocktime(__kmp_dflt_blocktime);
5112 value = __kmp_env_blk_var(block,
"OMP_NESTED");
5114 ompc_set_nested(__kmp_dflt_nested);
5118 value = __kmp_env_blk_var(block,
"OMP_DYNAMIC");
5120 ompc_set_dynamic(__kmp_global.g.g_dynamic);
5124 void __kmp_env_initialize(
char const *
string) {
5126 kmp_env_blk_t block;
5132 if (
string == NULL) {
5134 __kmp_threads_capacity =
5135 __kmp_initial_threads_capacity(__kmp_dflt_team_nth_ub);
5137 __kmp_env_blk_init(&block,
string);
5140 for (i = 0; i < block.count; ++i) {
5141 if ((block.vars[i].name == NULL) || (*block.vars[i].name ==
'\0')) {
5144 if (block.vars[i].value == NULL) {
5147 kmp_setting_t *setting = __kmp_stg_find(block.vars[i].name);
5148 if (setting != NULL) {
5154 blocktime_str = __kmp_env_blk_var(&block,
"KMP_BLOCKTIME");
5158 if (
string == NULL) {
5159 char const *name =
"KMP_WARNINGS";
5160 char const *value = __kmp_env_blk_var(&block, name);
5161 __kmp_stg_parse(name, value);
5164 #if KMP_AFFINITY_SUPPORTED 5170 __kmp_affinity_notype = NULL;
5171 char const *aff_str = __kmp_env_blk_var(&block,
"KMP_AFFINITY");
5172 if (aff_str != NULL) {
5186 #define FIND strcasestr 5189 if ((FIND(aff_str,
"none") == NULL) &&
5190 (FIND(aff_str,
"physical") == NULL) &&
5191 (FIND(aff_str,
"logical") == NULL) &&
5192 (FIND(aff_str,
"compact") == NULL) &&
5193 (FIND(aff_str,
"scatter") == NULL) &&
5194 (FIND(aff_str,
"explicit") == NULL) &&
5195 (FIND(aff_str,
"balanced") == NULL) &&
5196 (FIND(aff_str,
"disabled") == NULL)) {
5197 __kmp_affinity_notype = __kmp_stg_find(
"KMP_AFFINITY");
5202 __kmp_affinity_type = affinity_default;
5203 __kmp_affinity_gran = affinity_gran_default;
5204 __kmp_affinity_top_method = affinity_top_method_default;
5205 __kmp_affinity_respect_mask = affinity_respect_mask_default;
5211 aff_str = __kmp_env_blk_var(&block,
"OMP_PROC_BIND");
5212 if (aff_str != NULL) {
5213 __kmp_affinity_type = affinity_default;
5214 __kmp_affinity_gran = affinity_gran_default;
5215 __kmp_affinity_top_method = affinity_top_method_default;
5216 __kmp_affinity_respect_mask = affinity_respect_mask_default;
5225 if (__kmp_nested_proc_bind.bind_types == NULL) {
5226 __kmp_nested_proc_bind.bind_types =
5227 (kmp_proc_bind_t *)KMP_INTERNAL_MALLOC(
sizeof(kmp_proc_bind_t));
5228 if (__kmp_nested_proc_bind.bind_types == NULL) {
5229 KMP_FATAL(MemoryAllocFailed);
5231 __kmp_nested_proc_bind.size = 1;
5232 __kmp_nested_proc_bind.used = 1;
5233 #if KMP_AFFINITY_SUPPORTED 5234 __kmp_nested_proc_bind.bind_types[0] = proc_bind_default;
5237 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
5243 for (i = 0; i < block.count; ++i) {
5244 __kmp_stg_parse(block.vars[i].name, block.vars[i].value);
5248 if (!__kmp_init_user_locks) {
5249 if (__kmp_user_lock_kind == lk_default) {
5250 __kmp_user_lock_kind = lk_queuing;
5252 #if KMP_USE_DYNAMIC_LOCK 5253 __kmp_init_dynamic_user_locks();
5255 __kmp_set_user_lock_vptrs(__kmp_user_lock_kind);
5258 KMP_DEBUG_ASSERT(
string != NULL);
5259 KMP_DEBUG_ASSERT(__kmp_user_lock_kind != lk_default);
5264 #if KMP_USE_DYNAMIC_LOCK 5265 __kmp_init_dynamic_user_locks();
5267 __kmp_set_user_lock_vptrs(__kmp_user_lock_kind);
5271 #if KMP_AFFINITY_SUPPORTED 5273 if (!TCR_4(__kmp_init_middle)) {
5277 if ((__kmp_hws_node.num > 0 || __kmp_hws_tile.num > 0 ||
5278 __kmp_affinity_gran == affinity_gran_tile) &&
5279 (__kmp_affinity_top_method == affinity_top_method_default)) {
5280 __kmp_affinity_top_method = affinity_top_method_hwloc;
5285 const char *var =
"KMP_AFFINITY";
5286 KMPAffinity::pick_api();
5291 if (__kmp_affinity_top_method == affinity_top_method_hwloc &&
5292 __kmp_affinity_dispatch->get_api_type() != KMPAffinity::HWLOC) {
5293 KMP_WARNING(AffIgnoringHwloc, var);
5294 __kmp_affinity_top_method = affinity_top_method_all;
5297 if (__kmp_affinity_type == affinity_disabled) {
5298 KMP_AFFINITY_DISABLE();
5299 }
else if (!KMP_AFFINITY_CAPABLE()) {
5300 __kmp_affinity_dispatch->determine_capable(var);
5301 if (!KMP_AFFINITY_CAPABLE()) {
5302 if (__kmp_affinity_verbose ||
5303 (__kmp_affinity_warnings &&
5304 (__kmp_affinity_type != affinity_default) &&
5305 (__kmp_affinity_type != affinity_none) &&
5306 (__kmp_affinity_type != affinity_disabled))) {
5307 KMP_WARNING(AffNotSupported, var);
5309 __kmp_affinity_type = affinity_disabled;
5310 __kmp_affinity_respect_mask = 0;
5311 __kmp_affinity_gran = affinity_gran_fine;
5316 if (__kmp_affinity_type == affinity_disabled) {
5317 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
5318 }
else if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_true) {
5320 __kmp_nested_proc_bind.bind_types[0] = proc_bind_spread;
5324 if (KMP_AFFINITY_CAPABLE()) {
5326 #if KMP_GROUP_AFFINITY 5331 bool exactly_one_group =
false;
5332 if (__kmp_num_proc_groups > 1) {
5334 bool within_one_group;
5337 kmp_affin_mask_t *init_mask;
5338 KMP_CPU_ALLOC(init_mask);
5339 __kmp_get_system_affinity(init_mask, TRUE);
5340 group = __kmp_get_proc_group(init_mask);
5341 within_one_group = (group >= 0);
5344 if (within_one_group) {
5345 DWORD num_bits_in_group = __kmp_GetActiveProcessorCount(group);
5346 int num_bits_in_mask = 0;
5347 for (
int bit = init_mask->begin(); bit != init_mask->end();
5348 bit = init_mask->next(bit))
5350 exactly_one_group = (num_bits_in_group == num_bits_in_mask);
5352 KMP_CPU_FREE(init_mask);
5358 if (((__kmp_num_proc_groups > 1) &&
5359 (__kmp_affinity_type == affinity_default)
5361 && (__kmp_nested_proc_bind.bind_types[0] == proc_bind_default))
5363 || (__kmp_affinity_top_method == affinity_top_method_group)) {
5364 if (__kmp_affinity_respect_mask == affinity_respect_mask_default &&
5365 exactly_one_group) {
5366 __kmp_affinity_respect_mask = FALSE;
5368 if (__kmp_affinity_type == affinity_default) {
5369 __kmp_affinity_type = affinity_compact;
5371 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
5374 if (__kmp_affinity_top_method == affinity_top_method_default) {
5375 if (__kmp_affinity_gran == affinity_gran_default) {
5376 __kmp_affinity_top_method = affinity_top_method_group;
5377 __kmp_affinity_gran = affinity_gran_group;
5378 }
else if (__kmp_affinity_gran == affinity_gran_group) {
5379 __kmp_affinity_top_method = affinity_top_method_group;
5381 __kmp_affinity_top_method = affinity_top_method_all;
5383 }
else if (__kmp_affinity_top_method == affinity_top_method_group) {
5384 if (__kmp_affinity_gran == affinity_gran_default) {
5385 __kmp_affinity_gran = affinity_gran_group;
5386 }
else if ((__kmp_affinity_gran != affinity_gran_group) &&
5387 (__kmp_affinity_gran != affinity_gran_fine) &&
5388 (__kmp_affinity_gran != affinity_gran_thread)) {
5389 const char *str = NULL;
5390 switch (__kmp_affinity_gran) {
5391 case affinity_gran_core:
5394 case affinity_gran_package:
5397 case affinity_gran_node:
5400 case affinity_gran_tile:
5404 KMP_DEBUG_ASSERT(0);
5406 KMP_WARNING(AffGranTopGroup, var, str);
5407 __kmp_affinity_gran = affinity_gran_fine;
5410 if (__kmp_affinity_gran == affinity_gran_default) {
5411 __kmp_affinity_gran = affinity_gran_core;
5412 }
else if (__kmp_affinity_gran == affinity_gran_group) {
5413 const char *str = NULL;
5414 switch (__kmp_affinity_type) {
5415 case affinity_physical:
5418 case affinity_logical:
5421 case affinity_compact:
5424 case affinity_scatter:
5427 case affinity_explicit:
5432 KMP_DEBUG_ASSERT(0);
5434 KMP_WARNING(AffGranGroupType, var, str);
5435 __kmp_affinity_gran = affinity_gran_core;
5443 if (__kmp_affinity_respect_mask == affinity_respect_mask_default) {
5444 #if KMP_GROUP_AFFINITY 5445 if (__kmp_num_proc_groups > 1 && exactly_one_group) {
5446 __kmp_affinity_respect_mask = FALSE;
5450 __kmp_affinity_respect_mask = TRUE;
5454 if ((__kmp_nested_proc_bind.bind_types[0] != proc_bind_intel) &&
5455 (__kmp_nested_proc_bind.bind_types[0] != proc_bind_default)) {
5456 if (__kmp_affinity_type == affinity_default) {
5457 __kmp_affinity_type = affinity_compact;
5458 __kmp_affinity_dups = FALSE;
5462 if (__kmp_affinity_type == affinity_default) {
5464 #if KMP_MIC_SUPPORTED 5465 if (__kmp_mic_type != non_mic) {
5466 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
5470 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
5473 #if KMP_MIC_SUPPORTED 5474 if (__kmp_mic_type != non_mic) {
5475 __kmp_affinity_type = affinity_scatter;
5479 __kmp_affinity_type = affinity_none;
5482 if ((__kmp_affinity_gran == affinity_gran_default) &&
5483 (__kmp_affinity_gran_levels < 0)) {
5484 #if KMP_MIC_SUPPORTED 5485 if (__kmp_mic_type != non_mic) {
5486 __kmp_affinity_gran = affinity_gran_fine;
5490 __kmp_affinity_gran = affinity_gran_core;
5493 if (__kmp_affinity_top_method == affinity_top_method_default) {
5494 __kmp_affinity_top_method = affinity_top_method_all;
5499 K_DIAG(1, (
"__kmp_affinity_type == %d\n", __kmp_affinity_type));
5500 K_DIAG(1, (
"__kmp_affinity_compact == %d\n", __kmp_affinity_compact));
5501 K_DIAG(1, (
"__kmp_affinity_offset == %d\n", __kmp_affinity_offset));
5502 K_DIAG(1, (
"__kmp_affinity_verbose == %d\n", __kmp_affinity_verbose));
5503 K_DIAG(1, (
"__kmp_affinity_warnings == %d\n", __kmp_affinity_warnings));
5504 K_DIAG(1, (
"__kmp_affinity_respect_mask == %d\n",
5505 __kmp_affinity_respect_mask));
5506 K_DIAG(1, (
"__kmp_affinity_gran == %d\n", __kmp_affinity_gran));
5508 KMP_DEBUG_ASSERT(__kmp_affinity_type != affinity_default);
5510 KMP_DEBUG_ASSERT(__kmp_nested_proc_bind.bind_types[0] != proc_bind_default);
5511 K_DIAG(1, (
"__kmp_nested_proc_bind.bind_types[0] == %d\n",
5512 __kmp_nested_proc_bind.bind_types[0]));
5518 if (__kmp_version) {
5519 __kmp_print_version_1();
5524 if (
string != NULL) {
5525 __kmp_aux_env_initialize(&block);
5528 __kmp_env_blk_free(&block);
5534 void __kmp_env_print() {
5536 kmp_env_blk_t block;
5538 kmp_str_buf_t buffer;
5541 __kmp_str_buf_init(&buffer);
5543 __kmp_env_blk_init(&block, NULL);
5544 __kmp_env_blk_sort(&block);
5547 __kmp_str_buf_print(&buffer,
"\n%s\n\n", KMP_I18N_STR(UserSettings));
5548 for (i = 0; i < block.count; ++i) {
5549 char const *name = block.vars[i].name;
5550 char const *value = block.vars[i].value;
5551 if ((KMP_STRLEN(name) > 4 && strncmp(name,
"KMP_", 4) == 0) ||
5552 strncmp(name,
"OMP_", 4) == 0
5553 #ifdef KMP_GOMP_COMPAT
5554 || strncmp(name,
"GOMP_", 5) == 0
5557 __kmp_str_buf_print(&buffer,
" %s=%s\n", name, value);
5560 __kmp_str_buf_print(&buffer,
"\n");
5563 __kmp_str_buf_print(&buffer,
"%s\n\n", KMP_I18N_STR(EffectiveSettings));
5564 for (
int i = 0; i < __kmp_stg_count; ++i) {
5565 if (__kmp_stg_table[i].print != NULL) {
5566 __kmp_stg_table[i].print(&buffer, __kmp_stg_table[i].name,
5567 __kmp_stg_table[i].data);
5571 __kmp_printf(
"%s", buffer.str);
5573 __kmp_env_blk_free(&block);
5574 __kmp_str_buf_free(&buffer);
5581 void __kmp_env_print_2() {
5583 kmp_env_blk_t block;
5584 kmp_str_buf_t buffer;
5586 __kmp_env_format = 1;
5589 __kmp_str_buf_init(&buffer);
5591 __kmp_env_blk_init(&block, NULL);
5592 __kmp_env_blk_sort(&block);
5594 __kmp_str_buf_print(&buffer,
"\n%s\n", KMP_I18N_STR(DisplayEnvBegin));
5595 __kmp_str_buf_print(&buffer,
" _OPENMP='%d'\n", __kmp_openmp_version);
5597 for (
int i = 0; i < __kmp_stg_count; ++i) {
5598 if (__kmp_stg_table[i].print != NULL &&
5599 ((__kmp_display_env &&
5600 strncmp(__kmp_stg_table[i].name,
"OMP_", 4) == 0) ||
5601 __kmp_display_env_verbose)) {
5602 __kmp_stg_table[i].print(&buffer, __kmp_stg_table[i].name,
5603 __kmp_stg_table[i].data);
5607 __kmp_str_buf_print(&buffer,
"%s\n", KMP_I18N_STR(DisplayEnvEnd));
5608 __kmp_str_buf_print(&buffer,
"\n");
5610 __kmp_printf(
"%s", buffer.str);
5612 __kmp_env_blk_free(&block);
5613 __kmp_str_buf_free(&buffer);
5618 #endif // OMP_40_ENABLED