14 #include "kmp_affinity.h"
15 #include "kmp_atomic.h"
16 #if KMP_USE_HIER_SCHED
17 #include "kmp_dispatch_hier.h"
19 #include "kmp_environment.h"
24 #include "kmp_settings.h"
26 #include "kmp_wrapper_getpid.h"
29 static int __kmp_env_toPrint(
char const *name,
int flag);
31 bool __kmp_env_format = 0;
36 #ifdef USE_LOAD_BALANCE
37 static double __kmp_convert_to_double(
char const *s) {
40 if (KMP_SSCANF(s,
"%lf", &result) < 1) {
49 static unsigned int __kmp_readstr_with_sentinel(
char *dest,
char const *src,
50 size_t len,
char sentinel) {
52 for (i = 0; i < len; i++) {
53 if ((*src ==
'\0') || (*src == sentinel)) {
63 static int __kmp_match_with_sentinel(
char const *a,
char const *b,
size_t len,
71 while (*a && *b && *b != sentinel) {
72 char ca = *a, cb = *b;
74 if (ca >=
'a' && ca <=
'z')
76 if (cb >=
'a' && cb <=
'z')
110 static int __kmp_match_str(
char const *token,
char const *buf,
113 KMP_ASSERT(token != NULL);
114 KMP_ASSERT(buf != NULL);
115 KMP_ASSERT(end != NULL);
117 while (*token && *buf) {
118 char ct = *token, cb = *buf;
120 if (ct >=
'a' && ct <=
'z')
122 if (cb >=
'a' && cb <=
'z')
137 static size_t __kmp_round4k(
size_t size) {
138 size_t _4k = 4 * 1024;
139 if (size & (_4k - 1)) {
141 if (size <= KMP_SIZE_T_MAX - _4k) {
153 int __kmp_convert_to_milliseconds(
char const *data) {
154 int ret, nvalues, factor;
160 if (__kmp_str_match(
"infinit", -1, data))
164 nvalues = KMP_SSCANF(data,
"%lf%c%c", &value, &mult, &extra);
190 factor = 1000 * 60 * 60;
194 factor = 1000 * 24 * 60 * 60;
200 if (value >= ((INT_MAX - 1) / factor))
203 ret = (int)(value * (
double)factor);
208 static int __kmp_strcasecmp_with_sentinel(
char const *a,
char const *b,
214 while (*a && *b && *b != sentinel) {
215 char ca = *a, cb = *b;
217 if (ca >=
'a' && ca <=
'z')
219 if (cb >=
'a' && cb <=
'z')
222 return (
int)(
unsigned char)*a - (
int)(
unsigned char)*b;
226 return *a ? (*b && *b != sentinel)
227 ? (
int)(
unsigned char)*a - (
int)(
unsigned char)*b
229 : (*b && *b != sentinel) ? -1
236 typedef struct __kmp_setting kmp_setting_t;
237 typedef struct __kmp_stg_ss_data kmp_stg_ss_data_t;
238 typedef struct __kmp_stg_wp_data kmp_stg_wp_data_t;
239 typedef struct __kmp_stg_fr_data kmp_stg_fr_data_t;
241 typedef void (*kmp_stg_parse_func_t)(
char const *name,
char const *value,
243 typedef void (*kmp_stg_print_func_t)(kmp_str_buf_t *buffer,
char const *name,
246 struct __kmp_setting {
248 kmp_stg_parse_func_t parse;
249 kmp_stg_print_func_t print;
256 struct __kmp_stg_ss_data {
258 kmp_setting_t **rivals;
261 struct __kmp_stg_wp_data {
263 kmp_setting_t **rivals;
266 struct __kmp_stg_fr_data {
268 kmp_setting_t **rivals;
271 static int __kmp_stg_check_rivals(
274 kmp_setting_t **rivals
280 static void __kmp_stg_parse_bool(
char const *name,
char const *value,
282 if (__kmp_str_match_true(value)) {
284 }
else if (__kmp_str_match_false(value)) {
287 __kmp_msg(kmp_ms_warning, KMP_MSG(BadBoolValue, name, value),
288 KMP_HNT(ValidBoolValues), __kmp_msg_null);
293 void __kmp_check_stksize(
size_t *val) {
295 if (*val > KMP_DEFAULT_STKSIZE * 16)
296 *val = KMP_DEFAULT_STKSIZE * 16;
297 if (*val < KMP_MIN_STKSIZE)
298 *val = KMP_MIN_STKSIZE;
299 if (*val > KMP_MAX_STKSIZE)
300 *val = KMP_MAX_STKSIZE;
302 *val = __kmp_round4k(*val);
306 static void __kmp_stg_parse_size(
char const *name,
char const *value,
307 size_t size_min,
size_t size_max,
308 int *is_specified,
size_t *out,
310 char const *msg = NULL;
312 size_min = __kmp_round4k(size_min);
313 size_max = __kmp_round4k(size_max);
316 if (is_specified != NULL) {
319 __kmp_str_to_size(value, out, factor, &msg);
321 if (*out > size_max) {
323 msg = KMP_I18N_STR(ValueTooLarge);
324 }
else if (*out < size_min) {
326 msg = KMP_I18N_STR(ValueTooSmall);
329 size_t round4k = __kmp_round4k(*out);
330 if (*out != round4k) {
332 msg = KMP_I18N_STR(NotMultiple4K);
339 if (*out < size_min) {
341 }
else if (*out > size_max) {
348 __kmp_str_buf_init(&buf);
349 __kmp_str_buf_print_size(&buf, *out);
350 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
351 KMP_INFORM(Using_str_Value, name, buf.str);
352 __kmp_str_buf_free(&buf);
357 static void __kmp_stg_parse_str(
char const *name,
char const *value,
360 *out = __kmp_str_format(
"%s", value);
363 static void __kmp_stg_parse_int(
371 char const *msg = NULL;
372 kmp_uint64 uint = *out;
373 __kmp_str_to_uint(value, &uint, &msg);
375 if (uint < (
unsigned int)min) {
376 msg = KMP_I18N_STR(ValueTooSmall);
378 }
else if (uint > (
unsigned int)max) {
379 msg = KMP_I18N_STR(ValueTooLarge);
385 if (uint < (
unsigned int)min) {
387 }
else if (uint > (
unsigned int)max) {
394 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
395 __kmp_str_buf_init(&buf);
396 __kmp_str_buf_print(&buf,
"%" KMP_UINT64_SPEC
"", uint);
397 KMP_INFORM(Using_uint64_Value, name, buf.str);
398 __kmp_str_buf_free(&buf);
400 __kmp_type_convert(uint, out);
403 #if KMP_DEBUG_ADAPTIVE_LOCKS
404 static void __kmp_stg_parse_file(
char const *name,
char const *value,
405 const char *suffix,
char **out) {
410 t = (
char *)strrchr(value,
'.');
411 hasSuffix = t && __kmp_str_eqf(t, suffix);
412 t = __kmp_str_format(
"%s%s", value, hasSuffix ?
"" : suffix);
413 __kmp_expand_file_name(buffer,
sizeof(buffer), t);
415 *out = __kmp_str_format(
"%s", buffer);
420 static char *par_range_to_print = NULL;
422 static void __kmp_stg_parse_par_range(
char const *name,
char const *value,
423 int *out_range,
char *out_routine,
424 char *out_file,
int *out_lb,
426 size_t len = KMP_STRLEN(value) + 1;
427 par_range_to_print = (
char *)KMP_INTERNAL_MALLOC(len + 1);
428 KMP_STRNCPY_S(par_range_to_print, len + 1, value, len + 1);
429 __kmp_par_range = +1;
430 __kmp_par_range_lb = 0;
431 __kmp_par_range_ub = INT_MAX;
434 if (*value ==
'\0') {
437 if (!__kmp_strcasecmp_with_sentinel(
"routine", value,
'=')) {
438 value = strchr(value,
'=') + 1;
439 len = __kmp_readstr_with_sentinel(out_routine, value,
440 KMP_PAR_RANGE_ROUTINE_LEN - 1,
',');
442 goto par_range_error;
444 value = strchr(value,
',');
450 if (!__kmp_strcasecmp_with_sentinel(
"filename", value,
'=')) {
451 value = strchr(value,
'=') + 1;
452 len = __kmp_readstr_with_sentinel(out_file, value,
453 KMP_PAR_RANGE_FILENAME_LEN - 1,
',');
455 goto par_range_error;
457 value = strchr(value,
',');
463 if ((!__kmp_strcasecmp_with_sentinel(
"range", value,
'=')) ||
464 (!__kmp_strcasecmp_with_sentinel(
"incl_range", value,
'='))) {
465 value = strchr(value,
'=') + 1;
466 if (KMP_SSCANF(value,
"%d:%d", out_lb, out_ub) != 2) {
467 goto par_range_error;
470 value = strchr(value,
',');
476 if (!__kmp_strcasecmp_with_sentinel(
"excl_range", value,
'=')) {
477 value = strchr(value,
'=') + 1;
478 if (KMP_SSCANF(value,
"%d:%d", out_lb, out_ub) != 2) {
479 goto par_range_error;
482 value = strchr(value,
',');
489 KMP_WARNING(ParRangeSyntax, name);
496 int __kmp_initial_threads_capacity(
int req_nproc) {
501 if (nth < (4 * req_nproc))
502 nth = (4 * req_nproc);
503 if (nth < (4 * __kmp_xproc))
504 nth = (4 * __kmp_xproc);
508 if (__kmp_enable_hidden_helper) {
509 nth += __kmp_hidden_helper_threads_num;
512 if (nth > __kmp_max_nth)
518 int __kmp_default_tp_capacity(
int req_nproc,
int max_nth,
519 int all_threads_specified) {
522 if (all_threads_specified)
526 if (nth < (4 * req_nproc))
527 nth = (4 * req_nproc);
528 if (nth < (4 * __kmp_xproc))
529 nth = (4 * __kmp_xproc);
531 if (nth > __kmp_max_nth)
540 static void __kmp_stg_print_bool(kmp_str_buf_t *buffer,
char const *name,
542 if (__kmp_env_format) {
543 KMP_STR_BUF_PRINT_BOOL;
545 __kmp_str_buf_print(buffer,
" %s=%s\n", name, value ?
"true" :
"false");
549 static void __kmp_stg_print_int(kmp_str_buf_t *buffer,
char const *name,
551 if (__kmp_env_format) {
552 KMP_STR_BUF_PRINT_INT;
554 __kmp_str_buf_print(buffer,
" %s=%d\n", name, value);
558 static void __kmp_stg_print_uint64(kmp_str_buf_t *buffer,
char const *name,
560 if (__kmp_env_format) {
561 KMP_STR_BUF_PRINT_UINT64;
563 __kmp_str_buf_print(buffer,
" %s=%" KMP_UINT64_SPEC
"\n", name, value);
567 static void __kmp_stg_print_str(kmp_str_buf_t *buffer,
char const *name,
569 if (__kmp_env_format) {
570 KMP_STR_BUF_PRINT_STR;
572 __kmp_str_buf_print(buffer,
" %s=%s\n", name, value);
576 static void __kmp_stg_print_size(kmp_str_buf_t *buffer,
char const *name,
578 if (__kmp_env_format) {
579 KMP_STR_BUF_PRINT_NAME_EX(name);
580 __kmp_str_buf_print_size(buffer, value);
581 __kmp_str_buf_print(buffer,
"'\n");
583 __kmp_str_buf_print(buffer,
" %s=", name);
584 __kmp_str_buf_print_size(buffer, value);
585 __kmp_str_buf_print(buffer,
"\n");
596 static void __kmp_stg_parse_device_thread_limit(
char const *name,
597 char const *value,
void *data) {
598 kmp_setting_t **rivals = (kmp_setting_t **)data;
600 if (strcmp(name,
"KMP_ALL_THREADS") == 0) {
601 KMP_INFORM(EnvVarDeprecated, name,
"KMP_DEVICE_THREAD_LIMIT");
603 rc = __kmp_stg_check_rivals(name, value, rivals);
607 if (!__kmp_strcasecmp_with_sentinel(
"all", value, 0)) {
608 __kmp_max_nth = __kmp_xproc;
609 __kmp_allThreadsSpecified = 1;
611 __kmp_stg_parse_int(name, value, 1, __kmp_sys_max_nth, &__kmp_max_nth);
612 __kmp_allThreadsSpecified = 0;
614 K_DIAG(1, (
"__kmp_max_nth == %d\n", __kmp_max_nth));
618 static void __kmp_stg_print_device_thread_limit(kmp_str_buf_t *buffer,
619 char const *name,
void *data) {
620 __kmp_stg_print_int(buffer, name, __kmp_max_nth);
625 static void __kmp_stg_parse_thread_limit(
char const *name,
char const *value,
627 __kmp_stg_parse_int(name, value, 1, __kmp_sys_max_nth, &__kmp_cg_max_nth);
628 K_DIAG(1, (
"__kmp_cg_max_nth == %d\n", __kmp_cg_max_nth));
632 static void __kmp_stg_print_thread_limit(kmp_str_buf_t *buffer,
633 char const *name,
void *data) {
634 __kmp_stg_print_int(buffer, name, __kmp_cg_max_nth);
639 static void __kmp_stg_parse_nteams(
char const *name,
char const *value,
641 __kmp_stg_parse_int(name, value, 1, __kmp_sys_max_nth, &__kmp_nteams);
642 K_DIAG(1, (
"__kmp_nteams == %d\n", __kmp_nteams));
645 static void __kmp_stg_print_nteams(kmp_str_buf_t *buffer,
char const *name,
647 __kmp_stg_print_int(buffer, name, __kmp_nteams);
652 static void __kmp_stg_parse_teams_th_limit(
char const *name,
char const *value,
654 __kmp_stg_parse_int(name, value, 1, __kmp_sys_max_nth,
655 &__kmp_teams_thread_limit);
656 K_DIAG(1, (
"__kmp_teams_thread_limit == %d\n", __kmp_teams_thread_limit));
659 static void __kmp_stg_print_teams_th_limit(kmp_str_buf_t *buffer,
660 char const *name,
void *data) {
661 __kmp_stg_print_int(buffer, name, __kmp_teams_thread_limit);
666 static void __kmp_stg_parse_teams_thread_limit(
char const *name,
667 char const *value,
void *data) {
668 __kmp_stg_parse_int(name, value, 1, __kmp_sys_max_nth, &__kmp_teams_max_nth);
671 static void __kmp_stg_print_teams_thread_limit(kmp_str_buf_t *buffer,
672 char const *name,
void *data) {
673 __kmp_stg_print_int(buffer, name, __kmp_teams_max_nth);
678 static void __kmp_stg_parse_use_yield(
char const *name,
char const *value,
680 __kmp_stg_parse_int(name, value, 0, 2, &__kmp_use_yield);
681 __kmp_use_yield_exp_set = 1;
684 static void __kmp_stg_print_use_yield(kmp_str_buf_t *buffer,
char const *name,
686 __kmp_stg_print_int(buffer, name, __kmp_use_yield);
692 static void __kmp_stg_parse_blocktime(
char const *name,
char const *value,
694 __kmp_dflt_blocktime = __kmp_convert_to_milliseconds(value);
695 if (__kmp_dflt_blocktime < 0) {
696 __kmp_dflt_blocktime = KMP_DEFAULT_BLOCKTIME;
697 __kmp_msg(kmp_ms_warning, KMP_MSG(InvalidValue, name, value),
699 KMP_INFORM(Using_int_Value, name, __kmp_dflt_blocktime);
700 __kmp_env_blocktime = FALSE;
702 if (__kmp_dflt_blocktime < KMP_MIN_BLOCKTIME) {
703 __kmp_dflt_blocktime = KMP_MIN_BLOCKTIME;
704 __kmp_msg(kmp_ms_warning, KMP_MSG(SmallValue, name, value),
706 KMP_INFORM(MinValueUsing, name, __kmp_dflt_blocktime);
707 }
else if (__kmp_dflt_blocktime > KMP_MAX_BLOCKTIME) {
708 __kmp_dflt_blocktime = KMP_MAX_BLOCKTIME;
709 __kmp_msg(kmp_ms_warning, KMP_MSG(LargeValue, name, value),
711 KMP_INFORM(MaxValueUsing, name, __kmp_dflt_blocktime);
713 __kmp_env_blocktime = TRUE;
718 __kmp_monitor_wakeups =
719 KMP_WAKEUPS_FROM_BLOCKTIME(__kmp_dflt_blocktime, __kmp_monitor_wakeups);
721 KMP_INTERVALS_FROM_BLOCKTIME(__kmp_dflt_blocktime, __kmp_monitor_wakeups);
723 K_DIAG(1, (
"__kmp_env_blocktime == %d\n", __kmp_env_blocktime));
724 if (__kmp_env_blocktime) {
725 K_DIAG(1, (
"__kmp_dflt_blocktime == %d\n", __kmp_dflt_blocktime));
729 static void __kmp_stg_print_blocktime(kmp_str_buf_t *buffer,
char const *name,
731 __kmp_stg_print_int(buffer, name, __kmp_dflt_blocktime);
737 static void __kmp_stg_parse_duplicate_lib_ok(
char const *name,
738 char const *value,
void *data) {
741 __kmp_stg_parse_bool(name, value, &__kmp_duplicate_library_ok);
744 static void __kmp_stg_print_duplicate_lib_ok(kmp_str_buf_t *buffer,
745 char const *name,
void *data) {
746 __kmp_stg_print_bool(buffer, name, __kmp_duplicate_library_ok);
752 #if KMP_ARCH_X86 || KMP_ARCH_X86_64
754 static void __kmp_stg_parse_inherit_fp_control(
char const *name,
755 char const *value,
void *data) {
756 __kmp_stg_parse_bool(name, value, &__kmp_inherit_fp_control);
759 static void __kmp_stg_print_inherit_fp_control(kmp_str_buf_t *buffer,
760 char const *name,
void *data) {
762 __kmp_stg_print_bool(buffer, name, __kmp_inherit_fp_control);
769 static char const *blocktime_str = NULL;
774 static void __kmp_stg_parse_wait_policy(
char const *name,
char const *value,
777 kmp_stg_wp_data_t *wait = (kmp_stg_wp_data_t *)data;
780 rc = __kmp_stg_check_rivals(name, value, wait->rivals);
786 if (__kmp_str_match(
"ACTIVE", 1, value)) {
787 __kmp_library = library_turnaround;
788 if (blocktime_str == NULL) {
790 __kmp_dflt_blocktime = KMP_MAX_BLOCKTIME;
792 }
else if (__kmp_str_match(
"PASSIVE", 1, value)) {
793 __kmp_library = library_throughput;
794 if (blocktime_str == NULL) {
796 __kmp_dflt_blocktime = 0;
799 KMP_WARNING(StgInvalidValue, name, value);
802 if (__kmp_str_match(
"serial", 1, value)) {
803 __kmp_library = library_serial;
804 }
else if (__kmp_str_match(
"throughput", 2, value)) {
805 __kmp_library = library_throughput;
806 if (blocktime_str == NULL) {
808 __kmp_dflt_blocktime = 0;
810 }
else if (__kmp_str_match(
"turnaround", 2, value)) {
811 __kmp_library = library_turnaround;
812 }
else if (__kmp_str_match(
"dedicated", 1, value)) {
813 __kmp_library = library_turnaround;
814 }
else if (__kmp_str_match(
"multiuser", 1, value)) {
815 __kmp_library = library_throughput;
816 if (blocktime_str == NULL) {
818 __kmp_dflt_blocktime = 0;
821 KMP_WARNING(StgInvalidValue, name, value);
826 static void __kmp_stg_print_wait_policy(kmp_str_buf_t *buffer,
char const *name,
829 kmp_stg_wp_data_t *wait = (kmp_stg_wp_data_t *)data;
830 char const *value = NULL;
833 switch (__kmp_library) {
834 case library_turnaround: {
837 case library_throughput: {
842 switch (__kmp_library) {
843 case library_serial: {
846 case library_turnaround: {
847 value =
"turnaround";
849 case library_throughput: {
850 value =
"throughput";
855 __kmp_stg_print_str(buffer, name, value);
864 static void __kmp_stg_parse_monitor_stacksize(
char const *name,
865 char const *value,
void *data) {
866 __kmp_stg_parse_size(name, value, __kmp_sys_min_stksize, KMP_MAX_STKSIZE,
867 NULL, &__kmp_monitor_stksize, 1);
870 static void __kmp_stg_print_monitor_stacksize(kmp_str_buf_t *buffer,
871 char const *name,
void *data) {
872 if (__kmp_env_format) {
873 if (__kmp_monitor_stksize > 0)
874 KMP_STR_BUF_PRINT_NAME_EX(name);
876 KMP_STR_BUF_PRINT_NAME;
878 __kmp_str_buf_print(buffer,
" %s", name);
880 if (__kmp_monitor_stksize > 0) {
881 __kmp_str_buf_print_size(buffer, __kmp_monitor_stksize);
883 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
885 if (__kmp_env_format && __kmp_monitor_stksize) {
886 __kmp_str_buf_print(buffer,
"'\n");
894 static void __kmp_stg_parse_settings(
char const *name,
char const *value,
896 __kmp_stg_parse_bool(name, value, &__kmp_settings);
899 static void __kmp_stg_print_settings(kmp_str_buf_t *buffer,
char const *name,
901 __kmp_stg_print_bool(buffer, name, __kmp_settings);
907 static void __kmp_stg_parse_stackpad(
char const *name,
char const *value,
909 __kmp_stg_parse_int(name,
917 static void __kmp_stg_print_stackpad(kmp_str_buf_t *buffer,
char const *name,
919 __kmp_stg_print_int(buffer, name, __kmp_stkpadding);
925 static void __kmp_stg_parse_stackoffset(
char const *name,
char const *value,
927 __kmp_stg_parse_size(name,
936 static void __kmp_stg_print_stackoffset(kmp_str_buf_t *buffer,
char const *name,
938 __kmp_stg_print_size(buffer, name, __kmp_stkoffset);
944 static void __kmp_stg_parse_stacksize(
char const *name,
char const *value,
947 kmp_stg_ss_data_t *stacksize = (kmp_stg_ss_data_t *)data;
950 rc = __kmp_stg_check_rivals(name, value, stacksize->rivals);
954 __kmp_stg_parse_size(name,
956 __kmp_sys_min_stksize,
968 static void __kmp_stg_print_stacksize(kmp_str_buf_t *buffer,
char const *name,
970 kmp_stg_ss_data_t *stacksize = (kmp_stg_ss_data_t *)data;
971 if (__kmp_env_format) {
972 KMP_STR_BUF_PRINT_NAME_EX(name);
973 __kmp_str_buf_print_size(buffer, (__kmp_stksize % 1024)
974 ? __kmp_stksize / stacksize->factor
976 __kmp_str_buf_print(buffer,
"'\n");
978 __kmp_str_buf_print(buffer,
" %s=", name);
979 __kmp_str_buf_print_size(buffer, (__kmp_stksize % 1024)
980 ? __kmp_stksize / stacksize->factor
982 __kmp_str_buf_print(buffer,
"\n");
989 static void __kmp_stg_parse_version(
char const *name,
char const *value,
991 __kmp_stg_parse_bool(name, value, &__kmp_version);
994 static void __kmp_stg_print_version(kmp_str_buf_t *buffer,
char const *name,
996 __kmp_stg_print_bool(buffer, name, __kmp_version);
1002 static void __kmp_stg_parse_warnings(
char const *name,
char const *value,
1004 __kmp_stg_parse_bool(name, value, &__kmp_generate_warnings);
1005 if (__kmp_generate_warnings != kmp_warnings_off) {
1008 __kmp_generate_warnings = kmp_warnings_explicit;
1012 static void __kmp_stg_print_warnings(kmp_str_buf_t *buffer,
char const *name,
1015 __kmp_stg_print_bool(buffer, name, __kmp_generate_warnings);
1021 static void __kmp_stg_parse_nested(
char const *name,
char const *value,
1024 KMP_INFORM(EnvVarDeprecated, name,
"OMP_MAX_ACTIVE_LEVELS");
1025 __kmp_stg_parse_bool(name, value, &nested);
1027 if (!__kmp_dflt_max_active_levels_set)
1028 __kmp_dflt_max_active_levels = KMP_MAX_ACTIVE_LEVELS_LIMIT;
1030 __kmp_dflt_max_active_levels = 1;
1031 __kmp_dflt_max_active_levels_set =
true;
1035 static void __kmp_stg_print_nested(kmp_str_buf_t *buffer,
char const *name,
1037 if (__kmp_env_format) {
1038 KMP_STR_BUF_PRINT_NAME;
1040 __kmp_str_buf_print(buffer,
" %s", name);
1042 __kmp_str_buf_print(buffer,
": deprecated; max-active-levels-var=%d\n",
1043 __kmp_dflt_max_active_levels);
1046 static void __kmp_parse_nested_num_threads(
const char *var,
const char *env,
1047 kmp_nested_nthreads_t *nth_array) {
1048 const char *next = env;
1049 const char *scan = next;
1052 int prev_comma = FALSE;
1058 if (*next ==
'\0') {
1062 if (((*next <
'0') || (*next >
'9')) && (*next !=
',')) {
1063 KMP_WARNING(NthSyntaxError, var, env);
1069 if (total == 0 || prev_comma) {
1077 if (*next >=
'0' && *next <=
'9') {
1081 const char *tmp = next;
1083 if ((*next ==
' ' || *next ==
'\t') && (*tmp >=
'0' && *tmp <=
'9')) {
1084 KMP_WARNING(NthSpacesNotAllowed, var, env);
1089 if (!__kmp_dflt_max_active_levels_set && total > 1)
1090 __kmp_dflt_max_active_levels = KMP_MAX_ACTIVE_LEVELS_LIMIT;
1091 KMP_DEBUG_ASSERT(total > 0);
1093 KMP_WARNING(NthSyntaxError, var, env);
1098 if (!nth_array->nth) {
1100 nth_array->nth = (
int *)KMP_INTERNAL_MALLOC(
sizeof(
int) * total * 2);
1101 if (nth_array->nth == NULL) {
1102 KMP_FATAL(MemoryAllocFailed);
1104 nth_array->size = total * 2;
1106 if (nth_array->size < total) {
1109 nth_array->size *= 2;
1110 }
while (nth_array->size < total);
1112 nth_array->nth = (
int *)KMP_INTERNAL_REALLOC(
1113 nth_array->nth,
sizeof(
int) * nth_array->size);
1114 if (nth_array->nth == NULL) {
1115 KMP_FATAL(MemoryAllocFailed);
1119 nth_array->used = total;
1127 if (*scan ==
'\0') {
1137 nth_array->nth[i++] = 0;
1139 }
else if (prev_comma) {
1141 nth_array->nth[i] = nth_array->nth[i - 1];
1150 if (*scan >=
'0' && *scan <=
'9') {
1152 const char *buf = scan;
1153 char const *msg = NULL;
1158 num = __kmp_str_to_int(buf, *scan);
1159 if (num < KMP_MIN_NTH) {
1160 msg = KMP_I18N_STR(ValueTooSmall);
1162 }
else if (num > __kmp_sys_max_nth) {
1163 msg = KMP_I18N_STR(ValueTooLarge);
1164 num = __kmp_sys_max_nth;
1168 KMP_WARNING(ParseSizeIntWarn, var, env, msg);
1169 KMP_INFORM(Using_int_Value, var, num);
1171 nth_array->nth[i++] = num;
1176 static void __kmp_stg_parse_num_threads(
char const *name,
char const *value,
1179 if (!__kmp_strcasecmp_with_sentinel(
"all", value, 0)) {
1181 __kmp_nested_nth.nth = (
int *)KMP_INTERNAL_MALLOC(
sizeof(
int));
1182 __kmp_nested_nth.size = __kmp_nested_nth.used = 1;
1183 __kmp_nested_nth.nth[0] = __kmp_dflt_team_nth = __kmp_dflt_team_nth_ub =
1186 __kmp_parse_nested_num_threads(name, value, &__kmp_nested_nth);
1187 if (__kmp_nested_nth.nth) {
1188 __kmp_dflt_team_nth = __kmp_nested_nth.nth[0];
1189 if (__kmp_dflt_team_nth_ub < __kmp_dflt_team_nth) {
1190 __kmp_dflt_team_nth_ub = __kmp_dflt_team_nth;
1194 K_DIAG(1, (
"__kmp_dflt_team_nth == %d\n", __kmp_dflt_team_nth));
1197 static void __kmp_stg_parse_num_hidden_helper_threads(
char const *name,
1200 __kmp_stg_parse_int(name, value, 0, 16, &__kmp_hidden_helper_threads_num);
1203 if (__kmp_hidden_helper_threads_num == 0) {
1204 __kmp_enable_hidden_helper = FALSE;
1208 static void __kmp_stg_print_num_hidden_helper_threads(kmp_str_buf_t *buffer,
1211 __kmp_stg_print_int(buffer, name, __kmp_hidden_helper_threads_num);
1214 static void __kmp_stg_parse_use_hidden_helper(
char const *name,
1215 char const *value,
void *data) {
1216 __kmp_stg_parse_bool(name, value, &__kmp_enable_hidden_helper);
1218 __kmp_enable_hidden_helper = FALSE;
1220 (
"__kmp_stg_parse_use_hidden_helper: Disable hidden helper task on "
1221 "non-Linux platform although it is enabled by user explicitly.\n"));
1225 static void __kmp_stg_print_use_hidden_helper(kmp_str_buf_t *buffer,
1226 char const *name,
void *data) {
1227 __kmp_stg_print_bool(buffer, name, __kmp_enable_hidden_helper);
1230 static void __kmp_stg_print_num_threads(kmp_str_buf_t *buffer,
char const *name,
1232 if (__kmp_env_format) {
1233 KMP_STR_BUF_PRINT_NAME;
1235 __kmp_str_buf_print(buffer,
" %s", name);
1237 if (__kmp_nested_nth.used) {
1239 __kmp_str_buf_init(&buf);
1240 for (
int i = 0; i < __kmp_nested_nth.used; i++) {
1241 __kmp_str_buf_print(&buf,
"%d", __kmp_nested_nth.nth[i]);
1242 if (i < __kmp_nested_nth.used - 1) {
1243 __kmp_str_buf_print(&buf,
",");
1246 __kmp_str_buf_print(buffer,
"='%s'\n", buf.str);
1247 __kmp_str_buf_free(&buf);
1249 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
1256 static void __kmp_stg_parse_tasking(
char const *name,
char const *value,
1258 __kmp_stg_parse_int(name, value, 0, (
int)tskm_max,
1259 (
int *)&__kmp_tasking_mode);
1262 static void __kmp_stg_print_tasking(kmp_str_buf_t *buffer,
char const *name,
1264 __kmp_stg_print_int(buffer, name, __kmp_tasking_mode);
1267 static void __kmp_stg_parse_task_stealing(
char const *name,
char const *value,
1269 __kmp_stg_parse_int(name, value, 0, 1,
1270 (
int *)&__kmp_task_stealing_constraint);
1273 static void __kmp_stg_print_task_stealing(kmp_str_buf_t *buffer,
1274 char const *name,
void *data) {
1275 __kmp_stg_print_int(buffer, name, __kmp_task_stealing_constraint);
1278 static void __kmp_stg_parse_max_active_levels(
char const *name,
1279 char const *value,
void *data) {
1280 kmp_uint64 tmp_dflt = 0;
1281 char const *msg = NULL;
1282 if (!__kmp_dflt_max_active_levels_set) {
1284 __kmp_str_to_uint(value, &tmp_dflt, &msg);
1286 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
1287 }
else if (tmp_dflt > KMP_MAX_ACTIVE_LEVELS_LIMIT) {
1289 msg = KMP_I18N_STR(ValueTooLarge);
1290 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
1292 __kmp_type_convert(tmp_dflt, &(__kmp_dflt_max_active_levels));
1293 __kmp_dflt_max_active_levels_set =
true;
1298 static void __kmp_stg_print_max_active_levels(kmp_str_buf_t *buffer,
1299 char const *name,
void *data) {
1300 __kmp_stg_print_int(buffer, name, __kmp_dflt_max_active_levels);
1305 static void __kmp_stg_parse_default_device(
char const *name,
char const *value,
1307 __kmp_stg_parse_int(name, value, 0, KMP_MAX_DEFAULT_DEVICE_LIMIT,
1308 &__kmp_default_device);
1311 static void __kmp_stg_print_default_device(kmp_str_buf_t *buffer,
1312 char const *name,
void *data) {
1313 __kmp_stg_print_int(buffer, name, __kmp_default_device);
1318 static void __kmp_stg_parse_target_offload(
char const *name,
char const *value,
1320 const char *next = value;
1321 const char *scan = next;
1323 __kmp_target_offload = tgt_default;
1328 if (!__kmp_strcasecmp_with_sentinel(
"mandatory", scan, 0)) {
1329 __kmp_target_offload = tgt_mandatory;
1330 }
else if (!__kmp_strcasecmp_with_sentinel(
"disabled", scan, 0)) {
1331 __kmp_target_offload = tgt_disabled;
1332 }
else if (!__kmp_strcasecmp_with_sentinel(
"default", scan, 0)) {
1333 __kmp_target_offload = tgt_default;
1335 KMP_WARNING(SyntaxErrorUsing, name,
"DEFAULT");
1340 static void __kmp_stg_print_target_offload(kmp_str_buf_t *buffer,
1341 char const *name,
void *data) {
1342 const char *value = NULL;
1343 if (__kmp_target_offload == tgt_default)
1345 else if (__kmp_target_offload == tgt_mandatory)
1346 value =
"MANDATORY";
1347 else if (__kmp_target_offload == tgt_disabled)
1349 KMP_DEBUG_ASSERT(value);
1350 if (__kmp_env_format) {
1351 KMP_STR_BUF_PRINT_NAME;
1353 __kmp_str_buf_print(buffer,
" %s", name);
1355 __kmp_str_buf_print(buffer,
"=%s\n", value);
1360 static void __kmp_stg_parse_max_task_priority(
char const *name,
1361 char const *value,
void *data) {
1362 __kmp_stg_parse_int(name, value, 0, KMP_MAX_TASK_PRIORITY_LIMIT,
1363 &__kmp_max_task_priority);
1366 static void __kmp_stg_print_max_task_priority(kmp_str_buf_t *buffer,
1367 char const *name,
void *data) {
1368 __kmp_stg_print_int(buffer, name, __kmp_max_task_priority);
1373 static void __kmp_stg_parse_taskloop_min_tasks(
char const *name,
1374 char const *value,
void *data) {
1376 __kmp_stg_parse_int(name, value, 0, INT_MAX, &tmp);
1377 __kmp_taskloop_min_tasks = tmp;
1380 static void __kmp_stg_print_taskloop_min_tasks(kmp_str_buf_t *buffer,
1381 char const *name,
void *data) {
1382 __kmp_stg_print_uint64(buffer, name, __kmp_taskloop_min_tasks);
1387 static void __kmp_stg_parse_disp_buffers(
char const *name,
char const *value,
1389 if (TCR_4(__kmp_init_serial)) {
1390 KMP_WARNING(EnvSerialWarn, name);
1393 __kmp_stg_parse_int(name, value, KMP_MIN_DISP_NUM_BUFF, KMP_MAX_DISP_NUM_BUFF,
1394 &__kmp_dispatch_num_buffers);
1397 static void __kmp_stg_print_disp_buffers(kmp_str_buf_t *buffer,
1398 char const *name,
void *data) {
1399 __kmp_stg_print_int(buffer, name, __kmp_dispatch_num_buffers);
1402 #if KMP_NESTED_HOT_TEAMS
1406 static void __kmp_stg_parse_hot_teams_level(
char const *name,
char const *value,
1408 if (TCR_4(__kmp_init_parallel)) {
1409 KMP_WARNING(EnvParallelWarn, name);
1412 __kmp_stg_parse_int(name, value, 0, KMP_MAX_ACTIVE_LEVELS_LIMIT,
1413 &__kmp_hot_teams_max_level);
1416 static void __kmp_stg_print_hot_teams_level(kmp_str_buf_t *buffer,
1417 char const *name,
void *data) {
1418 __kmp_stg_print_int(buffer, name, __kmp_hot_teams_max_level);
1421 static void __kmp_stg_parse_hot_teams_mode(
char const *name,
char const *value,
1423 if (TCR_4(__kmp_init_parallel)) {
1424 KMP_WARNING(EnvParallelWarn, name);
1427 __kmp_stg_parse_int(name, value, 0, KMP_MAX_ACTIVE_LEVELS_LIMIT,
1428 &__kmp_hot_teams_mode);
1431 static void __kmp_stg_print_hot_teams_mode(kmp_str_buf_t *buffer,
1432 char const *name,
void *data) {
1433 __kmp_stg_print_int(buffer, name, __kmp_hot_teams_mode);
1441 #if KMP_HANDLE_SIGNALS
1443 static void __kmp_stg_parse_handle_signals(
char const *name,
char const *value,
1445 __kmp_stg_parse_bool(name, value, &__kmp_handle_signals);
1448 static void __kmp_stg_print_handle_signals(kmp_str_buf_t *buffer,
1449 char const *name,
void *data) {
1450 __kmp_stg_print_bool(buffer, name, __kmp_handle_signals);
1460 #define KMP_STG_X_DEBUG(x) \
1461 static void __kmp_stg_parse_##x##_debug(char const *name, char const *value, \
1463 __kmp_stg_parse_int(name, value, 0, INT_MAX, &kmp_##x##_debug); \
1465 static void __kmp_stg_print_##x##_debug(kmp_str_buf_t *buffer, \
1466 char const *name, void *data) { \
1467 __kmp_stg_print_int(buffer, name, kmp_##x##_debug); \
1477 #undef KMP_STG_X_DEBUG
1479 static void __kmp_stg_parse_debug(
char const *name,
char const *value,
1482 __kmp_stg_parse_int(name, value, 0, INT_MAX, &debug);
1483 if (kmp_a_debug < debug) {
1484 kmp_a_debug = debug;
1486 if (kmp_b_debug < debug) {
1487 kmp_b_debug = debug;
1489 if (kmp_c_debug < debug) {
1490 kmp_c_debug = debug;
1492 if (kmp_d_debug < debug) {
1493 kmp_d_debug = debug;
1495 if (kmp_e_debug < debug) {
1496 kmp_e_debug = debug;
1498 if (kmp_f_debug < debug) {
1499 kmp_f_debug = debug;
1503 static void __kmp_stg_parse_debug_buf(
char const *name,
char const *value,
1505 __kmp_stg_parse_bool(name, value, &__kmp_debug_buf);
1509 if (__kmp_debug_buf) {
1511 int elements = __kmp_debug_buf_lines * __kmp_debug_buf_chars;
1514 __kmp_debug_buffer = (
char *)__kmp_page_allocate(elements *
sizeof(
char));
1515 for (i = 0; i < elements; i += __kmp_debug_buf_chars)
1516 __kmp_debug_buffer[i] =
'\0';
1518 __kmp_debug_count = 0;
1520 K_DIAG(1, (
"__kmp_debug_buf = %d\n", __kmp_debug_buf));
1523 static void __kmp_stg_print_debug_buf(kmp_str_buf_t *buffer,
char const *name,
1525 __kmp_stg_print_bool(buffer, name, __kmp_debug_buf);
1528 static void __kmp_stg_parse_debug_buf_atomic(
char const *name,
1529 char const *value,
void *data) {
1530 __kmp_stg_parse_bool(name, value, &__kmp_debug_buf_atomic);
1533 static void __kmp_stg_print_debug_buf_atomic(kmp_str_buf_t *buffer,
1534 char const *name,
void *data) {
1535 __kmp_stg_print_bool(buffer, name, __kmp_debug_buf_atomic);
1538 static void __kmp_stg_parse_debug_buf_chars(
char const *name,
char const *value,
1540 __kmp_stg_parse_int(name, value, KMP_DEBUG_BUF_CHARS_MIN, INT_MAX,
1541 &__kmp_debug_buf_chars);
1544 static void __kmp_stg_print_debug_buf_chars(kmp_str_buf_t *buffer,
1545 char const *name,
void *data) {
1546 __kmp_stg_print_int(buffer, name, __kmp_debug_buf_chars);
1549 static void __kmp_stg_parse_debug_buf_lines(
char const *name,
char const *value,
1551 __kmp_stg_parse_int(name, value, KMP_DEBUG_BUF_LINES_MIN, INT_MAX,
1552 &__kmp_debug_buf_lines);
1555 static void __kmp_stg_print_debug_buf_lines(kmp_str_buf_t *buffer,
1556 char const *name,
void *data) {
1557 __kmp_stg_print_int(buffer, name, __kmp_debug_buf_lines);
1560 static void __kmp_stg_parse_diag(
char const *name,
char const *value,
1562 __kmp_stg_parse_int(name, value, 0, INT_MAX, &kmp_diag);
1565 static void __kmp_stg_print_diag(kmp_str_buf_t *buffer,
char const *name,
1567 __kmp_stg_print_int(buffer, name, kmp_diag);
1575 static void __kmp_stg_parse_align_alloc(
char const *name,
char const *value,
1577 __kmp_stg_parse_size(name, value, CACHE_LINE, INT_MAX, NULL,
1578 &__kmp_align_alloc, 1);
1581 static void __kmp_stg_print_align_alloc(kmp_str_buf_t *buffer,
char const *name,
1583 __kmp_stg_print_size(buffer, name, __kmp_align_alloc);
1592 static void __kmp_stg_parse_barrier_branch_bit(
char const *name,
1593 char const *value,
void *data) {
1597 for (
int i = bs_plain_barrier; i < bs_last_barrier; i++) {
1598 var = __kmp_barrier_branch_bit_env_name[i];
1599 if ((strcmp(var, name) == 0) && (value != 0)) {
1602 comma = CCAST(
char *, strchr(value,
','));
1603 __kmp_barrier_gather_branch_bits[i] =
1604 (kmp_uint32)__kmp_str_to_int(value,
',');
1606 if (comma == NULL) {
1607 __kmp_barrier_release_branch_bits[i] = __kmp_barrier_release_bb_dflt;
1609 __kmp_barrier_release_branch_bits[i] =
1610 (kmp_uint32)__kmp_str_to_int(comma + 1, 0);
1612 if (__kmp_barrier_release_branch_bits[i] > KMP_MAX_BRANCH_BITS) {
1613 __kmp_msg(kmp_ms_warning,
1614 KMP_MSG(BarrReleaseValueInvalid, name, comma + 1),
1616 __kmp_barrier_release_branch_bits[i] = __kmp_barrier_release_bb_dflt;
1619 if (__kmp_barrier_gather_branch_bits[i] > KMP_MAX_BRANCH_BITS) {
1620 KMP_WARNING(BarrGatherValueInvalid, name, value);
1621 KMP_INFORM(Using_uint_Value, name, __kmp_barrier_gather_bb_dflt);
1622 __kmp_barrier_gather_branch_bits[i] = __kmp_barrier_gather_bb_dflt;
1625 K_DIAG(1, (
"%s == %d,%d\n", __kmp_barrier_branch_bit_env_name[i],
1626 __kmp_barrier_gather_branch_bits[i],
1627 __kmp_barrier_release_branch_bits[i]))
1631 static void __kmp_stg_print_barrier_branch_bit(kmp_str_buf_t *buffer,
1632 char const *name,
void *data) {
1634 for (
int i = bs_plain_barrier; i < bs_last_barrier; i++) {
1635 var = __kmp_barrier_branch_bit_env_name[i];
1636 if (strcmp(var, name) == 0) {
1637 if (__kmp_env_format) {
1638 KMP_STR_BUF_PRINT_NAME_EX(__kmp_barrier_branch_bit_env_name[i]);
1640 __kmp_str_buf_print(buffer,
" %s='",
1641 __kmp_barrier_branch_bit_env_name[i]);
1643 __kmp_str_buf_print(buffer,
"%d,%d'\n",
1644 __kmp_barrier_gather_branch_bits[i],
1645 __kmp_barrier_release_branch_bits[i]);
1657 static void __kmp_stg_parse_barrier_pattern(
char const *name,
char const *value,
1662 for (
int i = bs_plain_barrier; i < bs_last_barrier; i++) {
1663 var = __kmp_barrier_pattern_env_name[i];
1665 if ((strcmp(var, name) == 0) && (value != 0)) {
1667 char *comma = CCAST(
char *, strchr(value,
','));
1670 for (j = bp_linear_bar; j < bp_last_bar; j++) {
1671 if (__kmp_match_with_sentinel(__kmp_barrier_pattern_name[j], value, 1,
1673 __kmp_barrier_gather_pattern[i] = (kmp_bar_pat_e)j;
1677 if (j == bp_last_bar) {
1678 KMP_WARNING(BarrGatherValueInvalid, name, value);
1679 KMP_INFORM(Using_str_Value, name,
1680 __kmp_barrier_pattern_name[bp_linear_bar]);
1684 if (comma != NULL) {
1685 for (j = bp_linear_bar; j < bp_last_bar; j++) {
1686 if (__kmp_str_match(__kmp_barrier_pattern_name[j], 1, comma + 1)) {
1687 __kmp_barrier_release_pattern[i] = (kmp_bar_pat_e)j;
1691 if (j == bp_last_bar) {
1692 __kmp_msg(kmp_ms_warning,
1693 KMP_MSG(BarrReleaseValueInvalid, name, comma + 1),
1695 KMP_INFORM(Using_str_Value, name,
1696 __kmp_barrier_pattern_name[bp_linear_bar]);
1703 static void __kmp_stg_print_barrier_pattern(kmp_str_buf_t *buffer,
1704 char const *name,
void *data) {
1706 for (
int i = bs_plain_barrier; i < bs_last_barrier; i++) {
1707 var = __kmp_barrier_pattern_env_name[i];
1708 if (strcmp(var, name) == 0) {
1709 int j = __kmp_barrier_gather_pattern[i];
1710 int k = __kmp_barrier_release_pattern[i];
1711 if (__kmp_env_format) {
1712 KMP_STR_BUF_PRINT_NAME_EX(__kmp_barrier_pattern_env_name[i]);
1714 __kmp_str_buf_print(buffer,
" %s='",
1715 __kmp_barrier_pattern_env_name[i]);
1717 KMP_DEBUG_ASSERT(j < bs_last_barrier && k < bs_last_barrier);
1718 __kmp_str_buf_print(buffer,
"%s,%s'\n", __kmp_barrier_pattern_name[j],
1719 __kmp_barrier_pattern_name[k]);
1727 static void __kmp_stg_parse_abort_delay(
char const *name,
char const *value,
1731 int delay = __kmp_abort_delay / 1000;
1732 __kmp_stg_parse_int(name, value, 0, INT_MAX / 1000, &delay);
1733 __kmp_abort_delay = delay * 1000;
1736 static void __kmp_stg_print_abort_delay(kmp_str_buf_t *buffer,
char const *name,
1738 __kmp_stg_print_int(buffer, name, __kmp_abort_delay);
1744 static void __kmp_stg_parse_cpuinfo_file(
char const *name,
char const *value,
1746 #if KMP_AFFINITY_SUPPORTED
1747 __kmp_stg_parse_str(name, value, &__kmp_cpuinfo_file);
1748 K_DIAG(1, (
"__kmp_cpuinfo_file == %s\n", __kmp_cpuinfo_file));
1752 static void __kmp_stg_print_cpuinfo_file(kmp_str_buf_t *buffer,
1753 char const *name,
void *data) {
1754 #if KMP_AFFINITY_SUPPORTED
1755 if (__kmp_env_format) {
1756 KMP_STR_BUF_PRINT_NAME;
1758 __kmp_str_buf_print(buffer,
" %s", name);
1760 if (__kmp_cpuinfo_file) {
1761 __kmp_str_buf_print(buffer,
"='%s'\n", __kmp_cpuinfo_file);
1763 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
1771 static void __kmp_stg_parse_force_reduction(
char const *name,
char const *value,
1773 kmp_stg_fr_data_t *reduction = (kmp_stg_fr_data_t *)data;
1776 rc = __kmp_stg_check_rivals(name, value, reduction->rivals);
1780 if (reduction->force) {
1782 if (__kmp_str_match(
"critical", 0, value))
1783 __kmp_force_reduction_method = critical_reduce_block;
1784 else if (__kmp_str_match(
"atomic", 0, value))
1785 __kmp_force_reduction_method = atomic_reduce_block;
1786 else if (__kmp_str_match(
"tree", 0, value))
1787 __kmp_force_reduction_method = tree_reduce_block;
1789 KMP_FATAL(UnknownForceReduction, name, value);
1793 __kmp_stg_parse_bool(name, value, &__kmp_determ_red);
1794 if (__kmp_determ_red) {
1795 __kmp_force_reduction_method = tree_reduce_block;
1797 __kmp_force_reduction_method = reduction_method_not_defined;
1800 K_DIAG(1, (
"__kmp_force_reduction_method == %d\n",
1801 __kmp_force_reduction_method));
1804 static void __kmp_stg_print_force_reduction(kmp_str_buf_t *buffer,
1805 char const *name,
void *data) {
1807 kmp_stg_fr_data_t *reduction = (kmp_stg_fr_data_t *)data;
1808 if (reduction->force) {
1809 if (__kmp_force_reduction_method == critical_reduce_block) {
1810 __kmp_stg_print_str(buffer, name,
"critical");
1811 }
else if (__kmp_force_reduction_method == atomic_reduce_block) {
1812 __kmp_stg_print_str(buffer, name,
"atomic");
1813 }
else if (__kmp_force_reduction_method == tree_reduce_block) {
1814 __kmp_stg_print_str(buffer, name,
"tree");
1816 if (__kmp_env_format) {
1817 KMP_STR_BUF_PRINT_NAME;
1819 __kmp_str_buf_print(buffer,
" %s", name);
1821 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
1824 __kmp_stg_print_bool(buffer, name, __kmp_determ_red);
1832 static void __kmp_stg_parse_storage_map(
char const *name,
char const *value,
1834 if (__kmp_str_match(
"verbose", 1, value)) {
1835 __kmp_storage_map = TRUE;
1836 __kmp_storage_map_verbose = TRUE;
1837 __kmp_storage_map_verbose_specified = TRUE;
1840 __kmp_storage_map_verbose = FALSE;
1841 __kmp_stg_parse_bool(name, value, &__kmp_storage_map);
1845 static void __kmp_stg_print_storage_map(kmp_str_buf_t *buffer,
char const *name,
1847 if (__kmp_storage_map_verbose || __kmp_storage_map_verbose_specified) {
1848 __kmp_stg_print_str(buffer, name,
"verbose");
1850 __kmp_stg_print_bool(buffer, name, __kmp_storage_map);
1857 static void __kmp_stg_parse_all_threadprivate(
char const *name,
1858 char const *value,
void *data) {
1859 __kmp_stg_parse_int(name, value,
1860 __kmp_allThreadsSpecified ? __kmp_max_nth : 1,
1861 __kmp_max_nth, &__kmp_tp_capacity);
1864 static void __kmp_stg_print_all_threadprivate(kmp_str_buf_t *buffer,
1865 char const *name,
void *data) {
1866 __kmp_stg_print_int(buffer, name, __kmp_tp_capacity);
1872 static void __kmp_stg_parse_foreign_threads_threadprivate(
char const *name,
1875 __kmp_stg_parse_bool(name, value, &__kmp_foreign_tp);
1878 static void __kmp_stg_print_foreign_threads_threadprivate(kmp_str_buf_t *buffer,
1881 __kmp_stg_print_bool(buffer, name, __kmp_foreign_tp);
1887 #if KMP_AFFINITY_SUPPORTED
1889 static int __kmp_parse_affinity_proc_id_list(
const char *var,
const char *env,
1890 const char **nextEnv,
1892 const char *scan = env;
1893 const char *next = scan;
1899 int start, end, stride;
1903 if (*next ==
'\0') {
1914 if ((*next <
'0') || (*next >
'9')) {
1915 KMP_WARNING(AffSyntaxError, var);
1919 num = __kmp_str_to_int(scan, *next);
1920 KMP_ASSERT(num >= 0);
1938 if ((*next <
'0') || (*next >
'9')) {
1939 KMP_WARNING(AffSyntaxError, var);
1944 num = __kmp_str_to_int(scan, *next);
1945 KMP_ASSERT(num >= 0);
1958 if ((*next <
'0') || (*next >
'9')) {
1960 KMP_WARNING(AffSyntaxError, var);
1968 start = __kmp_str_to_int(scan, *next);
1969 KMP_ASSERT(start >= 0);
1988 if ((*next <
'0') || (*next >
'9')) {
1989 KMP_WARNING(AffSyntaxError, var);
1993 end = __kmp_str_to_int(scan, *next);
1994 KMP_ASSERT(end >= 0);
2011 if ((*next <
'0') || (*next >
'9')) {
2012 KMP_WARNING(AffSyntaxError, var);
2016 stride = __kmp_str_to_int(scan, *next);
2017 KMP_ASSERT(stride >= 0);
2023 KMP_WARNING(AffZeroStride, var);
2028 KMP_WARNING(AffStartGreaterEnd, var, start, end);
2033 KMP_WARNING(AffStrideLessZero, var, start, end);
2037 if ((end - start) / stride > 65536) {
2038 KMP_WARNING(AffRangeTooBig, var, end, start, stride);
2055 ptrdiff_t len = next - env;
2056 char *retlist = (
char *)__kmp_allocate((len + 1) *
sizeof(char));
2057 KMP_MEMCPY_S(retlist, (len + 1) *
sizeof(
char), env, len *
sizeof(
char));
2058 retlist[len] =
'\0';
2059 *proclist = retlist;
2066 static kmp_setting_t *__kmp_affinity_notype = NULL;
2068 static void __kmp_parse_affinity_env(
char const *name,
char const *value,
2069 enum affinity_type *out_type,
2070 char **out_proclist,
int *out_verbose,
2071 int *out_warn,
int *out_respect,
2072 enum affinity_gran *out_gran,
2073 int *out_gran_levels,
int *out_dups,
2074 int *out_compact,
int *out_offset) {
2075 char *buffer = NULL;
2091 KMP_ASSERT(value != NULL);
2093 if (TCR_4(__kmp_init_middle)) {
2094 KMP_WARNING(EnvMiddleWarn, name);
2095 __kmp_env_toPrint(name, 0);
2098 __kmp_env_toPrint(name, 1);
2101 __kmp_str_format(
"%s", value);
2111 #define EMIT_WARN(skip, errlist) \
2115 SKIP_TO(next, ','); \
2119 KMP_WARNING errlist; \
2128 #define _set_param(_guard, _var, _val) \
2130 if (_guard == 0) { \
2133 EMIT_WARN(FALSE, (AffParamDefined, name, start)); \
2138 #define set_type(val) _set_param(type, *out_type, val)
2139 #define set_verbose(val) _set_param(verbose, *out_verbose, val)
2140 #define set_warnings(val) _set_param(warnings, *out_warn, val)
2141 #define set_respect(val) _set_param(respect, *out_respect, val)
2142 #define set_dups(val) _set_param(dups, *out_dups, val)
2143 #define set_proclist(val) _set_param(proclist, *out_proclist, val)
2145 #define set_gran(val, levels) \
2149 *out_gran_levels = levels; \
2151 EMIT_WARN(FALSE, (AffParamDefined, name, start)); \
2156 KMP_DEBUG_ASSERT((__kmp_nested_proc_bind.bind_types != NULL) &&
2157 (__kmp_nested_proc_bind.used > 0));
2159 while (*buf !=
'\0') {
2162 if (__kmp_match_str(
"none", buf, CCAST(
const char **, &next))) {
2163 set_type(affinity_none);
2164 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
2166 }
else if (__kmp_match_str(
"scatter", buf, CCAST(
const char **, &next))) {
2167 set_type(affinity_scatter);
2168 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2170 }
else if (__kmp_match_str(
"compact", buf, CCAST(
const char **, &next))) {
2171 set_type(affinity_compact);
2172 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2174 }
else if (__kmp_match_str(
"logical", buf, CCAST(
const char **, &next))) {
2175 set_type(affinity_logical);
2176 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2178 }
else if (__kmp_match_str(
"physical", buf, CCAST(
const char **, &next))) {
2179 set_type(affinity_physical);
2180 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2182 }
else if (__kmp_match_str(
"explicit", buf, CCAST(
const char **, &next))) {
2183 set_type(affinity_explicit);
2184 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2186 }
else if (__kmp_match_str(
"balanced", buf, CCAST(
const char **, &next))) {
2187 set_type(affinity_balanced);
2188 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2190 }
else if (__kmp_match_str(
"disabled", buf, CCAST(
const char **, &next))) {
2191 set_type(affinity_disabled);
2192 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
2194 }
else if (__kmp_match_str(
"verbose", buf, CCAST(
const char **, &next))) {
2197 }
else if (__kmp_match_str(
"noverbose", buf, CCAST(
const char **, &next))) {
2200 }
else if (__kmp_match_str(
"warnings", buf, CCAST(
const char **, &next))) {
2203 }
else if (__kmp_match_str(
"nowarnings", buf,
2204 CCAST(
const char **, &next))) {
2205 set_warnings(FALSE);
2207 }
else if (__kmp_match_str(
"respect", buf, CCAST(
const char **, &next))) {
2210 }
else if (__kmp_match_str(
"norespect", buf, CCAST(
const char **, &next))) {
2213 }
else if (__kmp_match_str(
"duplicates", buf,
2214 CCAST(
const char **, &next)) ||
2215 __kmp_match_str(
"dups", buf, CCAST(
const char **, &next))) {
2218 }
else if (__kmp_match_str(
"noduplicates", buf,
2219 CCAST(
const char **, &next)) ||
2220 __kmp_match_str(
"nodups", buf, CCAST(
const char **, &next))) {
2223 }
else if (__kmp_match_str(
"granularity", buf,
2224 CCAST(
const char **, &next)) ||
2225 __kmp_match_str(
"gran", buf, CCAST(
const char **, &next))) {
2228 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2235 if (__kmp_match_str(
"fine", buf, CCAST(
const char **, &next))) {
2236 set_gran(affinity_gran_fine, -1);
2238 }
else if (__kmp_match_str(
"thread", buf, CCAST(
const char **, &next))) {
2239 set_gran(affinity_gran_thread, -1);
2241 }
else if (__kmp_match_str(
"core", buf, CCAST(
const char **, &next))) {
2242 set_gran(affinity_gran_core, -1);
2245 }
else if (__kmp_match_str(
"tile", buf, CCAST(
const char **, &next))) {
2246 set_gran(affinity_gran_tile, -1);
2249 }
else if (__kmp_match_str(
"die", buf, CCAST(
const char **, &next))) {
2250 set_gran(affinity_gran_die, -1);
2252 }
else if (__kmp_match_str(
"package", buf, CCAST(
const char **, &next))) {
2253 set_gran(affinity_gran_package, -1);
2255 }
else if (__kmp_match_str(
"node", buf, CCAST(
const char **, &next))) {
2256 set_gran(affinity_gran_node, -1);
2258 #if KMP_GROUP_AFFINITY
2259 }
else if (__kmp_match_str(
"group", buf, CCAST(
const char **, &next))) {
2260 set_gran(affinity_gran_group, -1);
2263 }
else if ((*buf >=
'0') && (*buf <=
'9')) {
2267 n = __kmp_str_to_int(buf, *next);
2270 set_gran(affinity_gran_default, n);
2272 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2275 }
else if (__kmp_match_str(
"proclist", buf, CCAST(
const char **, &next))) {
2276 char *temp_proclist;
2280 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2286 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2291 if (!__kmp_parse_affinity_proc_id_list(
2292 name, buf, CCAST(
const char **, &next), &temp_proclist)) {
2304 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2308 set_proclist(temp_proclist);
2309 }
else if ((*buf >=
'0') && (*buf <=
'9')) {
2314 n = __kmp_str_to_int(buf, *next);
2320 KMP_WARNING(AffManyParams, name, start);
2324 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2332 }
else if (*next !=
'\0') {
2333 const char *temp = next;
2334 EMIT_WARN(TRUE, (ParseExtraCharsWarn, name, temp));
2346 #undef set_granularity
2348 __kmp_str_free(&buffer);
2352 KMP_WARNING(AffProcListNoType, name);
2353 *out_type = affinity_explicit;
2354 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2355 }
else if (*out_type != affinity_explicit) {
2356 KMP_WARNING(AffProcListNotExplicit, name);
2357 KMP_ASSERT(*out_proclist != NULL);
2358 KMP_INTERNAL_FREE(*out_proclist);
2359 *out_proclist = NULL;
2362 switch (*out_type) {
2363 case affinity_logical:
2364 case affinity_physical: {
2366 *out_offset = number[0];
2369 KMP_WARNING(AffManyParamsForLogic, name, number[1]);
2372 case affinity_balanced: {
2374 *out_compact = number[0];
2377 *out_offset = number[1];
2380 if (__kmp_affinity_gran == affinity_gran_default) {
2381 #if KMP_MIC_SUPPORTED
2382 if (__kmp_mic_type != non_mic) {
2383 if (__kmp_affinity_verbose || __kmp_affinity_warnings) {
2384 KMP_WARNING(AffGranUsing,
"KMP_AFFINITY",
"fine");
2386 __kmp_affinity_gran = affinity_gran_fine;
2390 if (__kmp_affinity_verbose || __kmp_affinity_warnings) {
2391 KMP_WARNING(AffGranUsing,
"KMP_AFFINITY",
"core");
2393 __kmp_affinity_gran = affinity_gran_core;
2397 case affinity_scatter:
2398 case affinity_compact: {
2400 *out_compact = number[0];
2403 *out_offset = number[1];
2406 case affinity_explicit: {
2407 if (*out_proclist == NULL) {
2408 KMP_WARNING(AffNoProcList, name);
2409 __kmp_affinity_type = affinity_none;
2412 KMP_WARNING(AffNoParam, name,
"explicit");
2415 case affinity_none: {
2417 KMP_WARNING(AffNoParam, name,
"none");
2420 case affinity_disabled: {
2422 KMP_WARNING(AffNoParam, name,
"disabled");
2425 case affinity_default: {
2427 KMP_WARNING(AffNoParam, name,
"default");
2436 static void __kmp_stg_parse_affinity(
char const *name,
char const *value,
2438 kmp_setting_t **rivals = (kmp_setting_t **)data;
2441 rc = __kmp_stg_check_rivals(name, value, rivals);
2446 __kmp_parse_affinity_env(name, value, &__kmp_affinity_type,
2447 &__kmp_affinity_proclist, &__kmp_affinity_verbose,
2448 &__kmp_affinity_warnings,
2449 &__kmp_affinity_respect_mask, &__kmp_affinity_gran,
2450 &__kmp_affinity_gran_levels, &__kmp_affinity_dups,
2451 &__kmp_affinity_compact, &__kmp_affinity_offset);
2455 static void __kmp_stg_print_affinity(kmp_str_buf_t *buffer,
char const *name,
2457 if (__kmp_env_format) {
2458 KMP_STR_BUF_PRINT_NAME_EX(name);
2460 __kmp_str_buf_print(buffer,
" %s='", name);
2462 if (__kmp_affinity_verbose) {
2463 __kmp_str_buf_print(buffer,
"%s,",
"verbose");
2465 __kmp_str_buf_print(buffer,
"%s,",
"noverbose");
2467 if (__kmp_affinity_warnings) {
2468 __kmp_str_buf_print(buffer,
"%s,",
"warnings");
2470 __kmp_str_buf_print(buffer,
"%s,",
"nowarnings");
2472 if (KMP_AFFINITY_CAPABLE()) {
2473 if (__kmp_affinity_respect_mask) {
2474 __kmp_str_buf_print(buffer,
"%s,",
"respect");
2476 __kmp_str_buf_print(buffer,
"%s,",
"norespect");
2478 switch (__kmp_affinity_gran) {
2479 case affinity_gran_default:
2480 __kmp_str_buf_print(buffer,
"%s",
"granularity=default,");
2482 case affinity_gran_fine:
2483 __kmp_str_buf_print(buffer,
"%s",
"granularity=fine,");
2485 case affinity_gran_thread:
2486 __kmp_str_buf_print(buffer,
"%s",
"granularity=thread,");
2488 case affinity_gran_core:
2489 __kmp_str_buf_print(buffer,
"%s",
"granularity=core,");
2491 case affinity_gran_package:
2492 __kmp_str_buf_print(buffer,
"%s",
"granularity=package,");
2494 case affinity_gran_node:
2495 __kmp_str_buf_print(buffer,
"%s",
"granularity=node,");
2497 #if KMP_GROUP_AFFINITY
2498 case affinity_gran_group:
2499 __kmp_str_buf_print(buffer,
"%s",
"granularity=group,");
2504 if (!KMP_AFFINITY_CAPABLE()) {
2505 __kmp_str_buf_print(buffer,
"%s",
"disabled");
2507 switch (__kmp_affinity_type) {
2509 __kmp_str_buf_print(buffer,
"%s",
"none");
2511 case affinity_physical:
2512 __kmp_str_buf_print(buffer,
"%s,%d",
"physical", __kmp_affinity_offset);
2514 case affinity_logical:
2515 __kmp_str_buf_print(buffer,
"%s,%d",
"logical", __kmp_affinity_offset);
2517 case affinity_compact:
2518 __kmp_str_buf_print(buffer,
"%s,%d,%d",
"compact", __kmp_affinity_compact,
2519 __kmp_affinity_offset);
2521 case affinity_scatter:
2522 __kmp_str_buf_print(buffer,
"%s,%d,%d",
"scatter", __kmp_affinity_compact,
2523 __kmp_affinity_offset);
2525 case affinity_explicit:
2526 __kmp_str_buf_print(buffer,
"%s=[%s],%s",
"proclist",
2527 __kmp_affinity_proclist,
"explicit");
2529 case affinity_balanced:
2530 __kmp_str_buf_print(buffer,
"%s,%d,%d",
"balanced",
2531 __kmp_affinity_compact, __kmp_affinity_offset);
2533 case affinity_disabled:
2534 __kmp_str_buf_print(buffer,
"%s",
"disabled");
2536 case affinity_default:
2537 __kmp_str_buf_print(buffer,
"%s",
"default");
2540 __kmp_str_buf_print(buffer,
"%s",
"<unknown>");
2543 __kmp_str_buf_print(buffer,
"'\n");
2546 #ifdef KMP_GOMP_COMPAT
2548 static void __kmp_stg_parse_gomp_cpu_affinity(
char const *name,
2549 char const *value,
void *data) {
2550 const char *next = NULL;
2551 char *temp_proclist;
2552 kmp_setting_t **rivals = (kmp_setting_t **)data;
2555 rc = __kmp_stg_check_rivals(name, value, rivals);
2560 if (TCR_4(__kmp_init_middle)) {
2561 KMP_WARNING(EnvMiddleWarn, name);
2562 __kmp_env_toPrint(name, 0);
2566 __kmp_env_toPrint(name, 1);
2568 if (__kmp_parse_affinity_proc_id_list(name, value, &next, &temp_proclist)) {
2570 if (*next ==
'\0') {
2572 __kmp_affinity_proclist = temp_proclist;
2573 __kmp_affinity_type = affinity_explicit;
2574 __kmp_affinity_gran = affinity_gran_fine;
2575 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2577 KMP_WARNING(AffSyntaxError, name);
2578 if (temp_proclist != NULL) {
2579 KMP_INTERNAL_FREE((
void *)temp_proclist);
2584 __kmp_affinity_type = affinity_none;
2585 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
2612 static inline void __kmp_omp_places_syntax_warn(
const char *var) {
2613 KMP_WARNING(SyntaxErrorUsing, var,
"\"cores\"");
2616 static int __kmp_parse_subplace_list(
const char *var,
const char **scan) {
2620 int start, count, stride;
2626 if ((**scan <
'0') || (**scan >
'9')) {
2627 __kmp_omp_places_syntax_warn(var);
2632 start = __kmp_str_to_int(*scan, *next);
2633 KMP_ASSERT(start >= 0);
2638 if (**scan ==
'}') {
2641 if (**scan ==
',') {
2645 if (**scan !=
':') {
2646 __kmp_omp_places_syntax_warn(var);
2653 if ((**scan <
'0') || (**scan >
'9')) {
2654 __kmp_omp_places_syntax_warn(var);
2659 count = __kmp_str_to_int(*scan, *next);
2660 KMP_ASSERT(count >= 0);
2665 if (**scan ==
'}') {
2668 if (**scan ==
',') {
2672 if (**scan !=
':') {
2673 __kmp_omp_places_syntax_warn(var);
2682 if (**scan ==
'+') {
2686 if (**scan ==
'-') {
2694 if ((**scan <
'0') || (**scan >
'9')) {
2695 __kmp_omp_places_syntax_warn(var);
2700 stride = __kmp_str_to_int(*scan, *next);
2701 KMP_ASSERT(stride >= 0);
2707 if (**scan ==
'}') {
2710 if (**scan ==
',') {
2715 __kmp_omp_places_syntax_warn(var);
2721 static int __kmp_parse_place(
const char *var,
const char **scan) {
2726 if (**scan ==
'{') {
2728 if (!__kmp_parse_subplace_list(var, scan)) {
2731 if (**scan !=
'}') {
2732 __kmp_omp_places_syntax_warn(var);
2736 }
else if (**scan ==
'!') {
2738 return __kmp_parse_place(var, scan);
2739 }
else if ((**scan >=
'0') && (**scan <=
'9')) {
2742 int proc = __kmp_str_to_int(*scan, *next);
2743 KMP_ASSERT(proc >= 0);
2746 __kmp_omp_places_syntax_warn(var);
2752 static int __kmp_parse_place_list(
const char *var,
const char *env,
2753 char **place_list) {
2754 const char *scan = env;
2755 const char *next = scan;
2760 if (!__kmp_parse_place(var, &scan)) {
2766 if (*scan ==
'\0') {
2774 __kmp_omp_places_syntax_warn(var);
2781 if ((*scan <
'0') || (*scan >
'9')) {
2782 __kmp_omp_places_syntax_warn(var);
2787 count = __kmp_str_to_int(scan, *next);
2788 KMP_ASSERT(count >= 0);
2793 if (*scan ==
'\0') {
2801 __kmp_omp_places_syntax_warn(var);
2822 if ((*scan <
'0') || (*scan >
'9')) {
2823 __kmp_omp_places_syntax_warn(var);
2828 stride = __kmp_str_to_int(scan, *next);
2829 KMP_ASSERT(stride >= 0);
2835 if (*scan ==
'\0') {
2843 __kmp_omp_places_syntax_warn(var);
2848 ptrdiff_t len = scan - env;
2849 char *retlist = (
char *)__kmp_allocate((len + 1) *
sizeof(char));
2850 KMP_MEMCPY_S(retlist, (len + 1) *
sizeof(
char), env, len *
sizeof(
char));
2851 retlist[len] =
'\0';
2852 *place_list = retlist;
2857 static void __kmp_stg_parse_places(
char const *name,
char const *value,
2860 const char *scan = value;
2861 const char *next = scan;
2862 const char *kind =
"\"threads\"";
2863 kmp_setting_t **rivals = (kmp_setting_t **)data;
2866 rc = __kmp_stg_check_rivals(name, value, rivals);
2871 if (__kmp_match_str(
"threads", scan, &next)) {
2873 __kmp_affinity_type = affinity_compact;
2874 __kmp_affinity_gran = affinity_gran_thread;
2875 __kmp_affinity_dups = FALSE;
2876 kind =
"\"threads\"";
2877 }
else if (__kmp_match_str(
"cores", scan, &next)) {
2879 __kmp_affinity_type = affinity_compact;
2880 __kmp_affinity_gran = affinity_gran_core;
2881 __kmp_affinity_dups = FALSE;
2884 }
else if (__kmp_match_str(
"tiles", scan, &next)) {
2886 __kmp_affinity_type = affinity_compact;
2887 __kmp_affinity_gran = affinity_gran_tile;
2888 __kmp_affinity_dups = FALSE;
2891 }
else if (__kmp_match_str(
"dice", scan, &next) ||
2892 __kmp_match_str(
"dies", scan, &next)) {
2894 __kmp_affinity_type = affinity_compact;
2895 __kmp_affinity_gran = affinity_gran_die;
2896 __kmp_affinity_dups = FALSE;
2898 }
else if (__kmp_match_str(
"sockets", scan, &next)) {
2900 __kmp_affinity_type = affinity_compact;
2901 __kmp_affinity_gran = affinity_gran_package;
2902 __kmp_affinity_dups = FALSE;
2903 kind =
"\"sockets\"";
2905 if (__kmp_affinity_proclist != NULL) {
2906 KMP_INTERNAL_FREE((
void *)__kmp_affinity_proclist);
2907 __kmp_affinity_proclist = NULL;
2909 if (__kmp_parse_place_list(name, value, &__kmp_affinity_proclist)) {
2910 __kmp_affinity_type = affinity_explicit;
2911 __kmp_affinity_gran = affinity_gran_fine;
2912 __kmp_affinity_dups = FALSE;
2915 __kmp_affinity_type = affinity_compact;
2916 __kmp_affinity_gran = affinity_gran_core;
2917 __kmp_affinity_dups = FALSE;
2919 if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_default) {
2920 __kmp_nested_proc_bind.bind_types[0] = proc_bind_true;
2925 if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_default) {
2926 __kmp_nested_proc_bind.bind_types[0] = proc_bind_true;
2930 if (*scan ==
'\0') {
2936 KMP_WARNING(SyntaxErrorUsing, name, kind);
2944 count = __kmp_str_to_int(scan, *next);
2945 KMP_ASSERT(count >= 0);
2950 KMP_WARNING(SyntaxErrorUsing, name, kind);
2956 if (*scan !=
'\0') {
2957 KMP_WARNING(ParseExtraCharsWarn, name, scan);
2959 __kmp_affinity_num_places = count;
2962 static void __kmp_stg_print_places(kmp_str_buf_t *buffer,
char const *name,
2964 if (__kmp_env_format) {
2965 KMP_STR_BUF_PRINT_NAME;
2967 __kmp_str_buf_print(buffer,
" %s", name);
2969 if ((__kmp_nested_proc_bind.used == 0) ||
2970 (__kmp_nested_proc_bind.bind_types == NULL) ||
2971 (__kmp_nested_proc_bind.bind_types[0] == proc_bind_false)) {
2972 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
2973 }
else if (__kmp_affinity_type == affinity_explicit) {
2974 if (__kmp_affinity_proclist != NULL) {
2975 __kmp_str_buf_print(buffer,
"='%s'\n", __kmp_affinity_proclist);
2977 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
2979 }
else if (__kmp_affinity_type == affinity_compact) {
2981 if (__kmp_affinity_num_masks > 0) {
2982 num = __kmp_affinity_num_masks;
2983 }
else if (__kmp_affinity_num_places > 0) {
2984 num = __kmp_affinity_num_places;
2988 if (__kmp_affinity_gran == affinity_gran_thread) {
2990 __kmp_str_buf_print(buffer,
"='threads(%d)'\n", num);
2992 __kmp_str_buf_print(buffer,
"='threads'\n");
2994 }
else if (__kmp_affinity_gran == affinity_gran_core) {
2996 __kmp_str_buf_print(buffer,
"='cores(%d)' \n", num);
2998 __kmp_str_buf_print(buffer,
"='cores'\n");
3001 }
else if (__kmp_affinity_gran == affinity_gran_tile) {
3003 __kmp_str_buf_print(buffer,
"='tiles(%d)' \n", num);
3005 __kmp_str_buf_print(buffer,
"='tiles'\n");
3008 }
else if (__kmp_affinity_gran == affinity_gran_package) {
3010 __kmp_str_buf_print(buffer,
"='sockets(%d)'\n", num);
3012 __kmp_str_buf_print(buffer,
"='sockets'\n");
3015 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
3018 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
3022 static void __kmp_stg_parse_topology_method(
char const *name,
char const *value,
3024 if (__kmp_str_match(
"all", 1, value)) {
3025 __kmp_affinity_top_method = affinity_top_method_all;
3028 else if (__kmp_str_match(
"hwloc", 1, value)) {
3029 __kmp_affinity_top_method = affinity_top_method_hwloc;
3032 #if KMP_ARCH_X86 || KMP_ARCH_X86_64
3033 else if (__kmp_str_match(
"cpuid_leaf31", 12, value) ||
3034 __kmp_str_match(
"cpuid 1f", 8, value) ||
3035 __kmp_str_match(
"cpuid 31", 8, value) ||
3036 __kmp_str_match(
"cpuid1f", 7, value) ||
3037 __kmp_str_match(
"cpuid31", 7, value) ||
3038 __kmp_str_match(
"leaf 1f", 7, value) ||
3039 __kmp_str_match(
"leaf 31", 7, value) ||
3040 __kmp_str_match(
"leaf1f", 6, value) ||
3041 __kmp_str_match(
"leaf31", 6, value)) {
3042 __kmp_affinity_top_method = affinity_top_method_x2apicid_1f;
3043 }
else if (__kmp_str_match(
"x2apic id", 9, value) ||
3044 __kmp_str_match(
"x2apic_id", 9, value) ||
3045 __kmp_str_match(
"x2apic-id", 9, value) ||
3046 __kmp_str_match(
"x2apicid", 8, value) ||
3047 __kmp_str_match(
"cpuid leaf 11", 13, value) ||
3048 __kmp_str_match(
"cpuid_leaf_11", 13, value) ||
3049 __kmp_str_match(
"cpuid-leaf-11", 13, value) ||
3050 __kmp_str_match(
"cpuid leaf11", 12, value) ||
3051 __kmp_str_match(
"cpuid_leaf11", 12, value) ||
3052 __kmp_str_match(
"cpuid-leaf11", 12, value) ||
3053 __kmp_str_match(
"cpuidleaf 11", 12, value) ||
3054 __kmp_str_match(
"cpuidleaf_11", 12, value) ||
3055 __kmp_str_match(
"cpuidleaf-11", 12, value) ||
3056 __kmp_str_match(
"cpuidleaf11", 11, value) ||
3057 __kmp_str_match(
"cpuid 11", 8, value) ||
3058 __kmp_str_match(
"cpuid_11", 8, value) ||
3059 __kmp_str_match(
"cpuid-11", 8, value) ||
3060 __kmp_str_match(
"cpuid11", 7, value) ||
3061 __kmp_str_match(
"leaf 11", 7, value) ||
3062 __kmp_str_match(
"leaf_11", 7, value) ||
3063 __kmp_str_match(
"leaf-11", 7, value) ||
3064 __kmp_str_match(
"leaf11", 6, value)) {
3065 __kmp_affinity_top_method = affinity_top_method_x2apicid;
3066 }
else if (__kmp_str_match(
"apic id", 7, value) ||
3067 __kmp_str_match(
"apic_id", 7, value) ||
3068 __kmp_str_match(
"apic-id", 7, value) ||
3069 __kmp_str_match(
"apicid", 6, value) ||
3070 __kmp_str_match(
"cpuid leaf 4", 12, value) ||
3071 __kmp_str_match(
"cpuid_leaf_4", 12, value) ||
3072 __kmp_str_match(
"cpuid-leaf-4", 12, value) ||
3073 __kmp_str_match(
"cpuid leaf4", 11, value) ||
3074 __kmp_str_match(
"cpuid_leaf4", 11, value) ||
3075 __kmp_str_match(
"cpuid-leaf4", 11, value) ||
3076 __kmp_str_match(
"cpuidleaf 4", 11, value) ||
3077 __kmp_str_match(
"cpuidleaf_4", 11, value) ||
3078 __kmp_str_match(
"cpuidleaf-4", 11, value) ||
3079 __kmp_str_match(
"cpuidleaf4", 10, value) ||
3080 __kmp_str_match(
"cpuid 4", 7, value) ||
3081 __kmp_str_match(
"cpuid_4", 7, value) ||
3082 __kmp_str_match(
"cpuid-4", 7, value) ||
3083 __kmp_str_match(
"cpuid4", 6, value) ||
3084 __kmp_str_match(
"leaf 4", 6, value) ||
3085 __kmp_str_match(
"leaf_4", 6, value) ||
3086 __kmp_str_match(
"leaf-4", 6, value) ||
3087 __kmp_str_match(
"leaf4", 5, value)) {
3088 __kmp_affinity_top_method = affinity_top_method_apicid;
3091 else if (__kmp_str_match(
"/proc/cpuinfo", 2, value) ||
3092 __kmp_str_match(
"cpuinfo", 5, value)) {
3093 __kmp_affinity_top_method = affinity_top_method_cpuinfo;
3095 #if KMP_GROUP_AFFINITY
3096 else if (__kmp_str_match(
"group", 1, value)) {
3097 __kmp_affinity_top_method = affinity_top_method_group;
3100 else if (__kmp_str_match(
"flat", 1, value)) {
3101 __kmp_affinity_top_method = affinity_top_method_flat;
3103 KMP_WARNING(StgInvalidValue, name, value);
3107 static void __kmp_stg_print_topology_method(kmp_str_buf_t *buffer,
3108 char const *name,
void *data) {
3109 char const *value = NULL;
3111 switch (__kmp_affinity_top_method) {
3112 case affinity_top_method_default:
3116 case affinity_top_method_all:
3120 #if KMP_ARCH_X86 || KMP_ARCH_X86_64
3121 case affinity_top_method_x2apicid:
3122 value =
"x2APIC id";
3125 case affinity_top_method_apicid:
3131 case affinity_top_method_hwloc:
3136 case affinity_top_method_cpuinfo:
3140 #if KMP_GROUP_AFFINITY
3141 case affinity_top_method_group:
3146 case affinity_top_method_flat:
3151 if (value != NULL) {
3152 __kmp_stg_print_str(buffer, name, value);
3160 static void __kmp_stg_parse_proc_bind(
char const *name,
char const *value,
3162 kmp_setting_t **rivals = (kmp_setting_t **)data;
3165 rc = __kmp_stg_check_rivals(name, value, rivals);
3171 KMP_DEBUG_ASSERT((__kmp_nested_proc_bind.bind_types != NULL) &&
3172 (__kmp_nested_proc_bind.used > 0));
3174 const char *buf = value;
3178 if ((*buf >=
'0') && (*buf <=
'9')) {
3181 num = __kmp_str_to_int(buf, *next);
3182 KMP_ASSERT(num >= 0);
3190 if (__kmp_match_str(
"disabled", buf, &next)) {
3193 #if KMP_AFFINITY_SUPPORTED
3194 __kmp_affinity_type = affinity_disabled;
3196 __kmp_nested_proc_bind.used = 1;
3197 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
3198 }
else if ((num == (
int)proc_bind_false) ||
3199 __kmp_match_str(
"false", buf, &next)) {
3202 #if KMP_AFFINITY_SUPPORTED
3203 __kmp_affinity_type = affinity_none;
3205 __kmp_nested_proc_bind.used = 1;
3206 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
3207 }
else if ((num == (
int)proc_bind_true) ||
3208 __kmp_match_str(
"true", buf, &next)) {
3211 __kmp_nested_proc_bind.used = 1;
3212 __kmp_nested_proc_bind.bind_types[0] = proc_bind_true;
3217 for (scan = buf; *scan !=
'\0'; scan++) {
3224 if (__kmp_nested_proc_bind.size < nelem) {
3225 __kmp_nested_proc_bind.bind_types =
3226 (kmp_proc_bind_t *)KMP_INTERNAL_REALLOC(
3227 __kmp_nested_proc_bind.bind_types,
3228 sizeof(kmp_proc_bind_t) * nelem);
3229 if (__kmp_nested_proc_bind.bind_types == NULL) {
3230 KMP_FATAL(MemoryAllocFailed);
3232 __kmp_nested_proc_bind.size = nelem;
3234 __kmp_nested_proc_bind.used = nelem;
3236 if (nelem > 1 && !__kmp_dflt_max_active_levels_set)
3237 __kmp_dflt_max_active_levels = KMP_MAX_ACTIVE_LEVELS_LIMIT;
3242 enum kmp_proc_bind_t bind;
3244 if ((num == (
int)proc_bind_primary) ||
3245 __kmp_match_str(
"master", buf, &next) ||
3246 __kmp_match_str(
"primary", buf, &next)) {
3249 bind = proc_bind_primary;
3250 }
else if ((num == (
int)proc_bind_close) ||
3251 __kmp_match_str(
"close", buf, &next)) {
3254 bind = proc_bind_close;
3255 }
else if ((num == (
int)proc_bind_spread) ||
3256 __kmp_match_str(
"spread", buf, &next)) {
3259 bind = proc_bind_spread;
3261 KMP_WARNING(StgInvalidValue, name, value);
3262 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
3263 __kmp_nested_proc_bind.used = 1;
3267 __kmp_nested_proc_bind.bind_types[i++] = bind;
3271 KMP_DEBUG_ASSERT(*buf ==
',');
3276 if ((*buf >=
'0') && (*buf <=
'9')) {
3279 num = __kmp_str_to_int(buf, *next);
3280 KMP_ASSERT(num >= 0);
3290 KMP_WARNING(ParseExtraCharsWarn, name, buf);
3294 static void __kmp_stg_print_proc_bind(kmp_str_buf_t *buffer,
char const *name,
3296 int nelem = __kmp_nested_proc_bind.used;
3297 if (__kmp_env_format) {
3298 KMP_STR_BUF_PRINT_NAME;
3300 __kmp_str_buf_print(buffer,
" %s", name);
3303 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
3306 __kmp_str_buf_print(buffer,
"='", name);
3307 for (i = 0; i < nelem; i++) {
3308 switch (__kmp_nested_proc_bind.bind_types[i]) {
3309 case proc_bind_false:
3310 __kmp_str_buf_print(buffer,
"false");
3313 case proc_bind_true:
3314 __kmp_str_buf_print(buffer,
"true");
3317 case proc_bind_primary:
3318 __kmp_str_buf_print(buffer,
"primary");
3321 case proc_bind_close:
3322 __kmp_str_buf_print(buffer,
"close");
3325 case proc_bind_spread:
3326 __kmp_str_buf_print(buffer,
"spread");
3329 case proc_bind_intel:
3330 __kmp_str_buf_print(buffer,
"intel");
3333 case proc_bind_default:
3334 __kmp_str_buf_print(buffer,
"default");
3337 if (i < nelem - 1) {
3338 __kmp_str_buf_print(buffer,
",");
3341 __kmp_str_buf_print(buffer,
"'\n");
3345 static void __kmp_stg_parse_display_affinity(
char const *name,
3346 char const *value,
void *data) {
3347 __kmp_stg_parse_bool(name, value, &__kmp_display_affinity);
3349 static void __kmp_stg_print_display_affinity(kmp_str_buf_t *buffer,
3350 char const *name,
void *data) {
3351 __kmp_stg_print_bool(buffer, name, __kmp_display_affinity);
3353 static void __kmp_stg_parse_affinity_format(
char const *name,
char const *value,
3355 size_t length = KMP_STRLEN(value);
3356 __kmp_strncpy_truncate(__kmp_affinity_format, KMP_AFFINITY_FORMAT_SIZE, value,
3359 static void __kmp_stg_print_affinity_format(kmp_str_buf_t *buffer,
3360 char const *name,
void *data) {
3361 if (__kmp_env_format) {
3362 KMP_STR_BUF_PRINT_NAME_EX(name);
3364 __kmp_str_buf_print(buffer,
" %s='", name);
3366 __kmp_str_buf_print(buffer,
"%s'\n", __kmp_affinity_format);
3388 static void __kmp_stg_parse_allocator(
char const *name,
char const *value,
3390 const char *buf = value;
3391 const char *next, *scan, *start;
3393 omp_allocator_handle_t al;
3394 omp_memspace_handle_t ms = omp_default_mem_space;
3395 bool is_memspace =
false;
3396 int ntraits = 0, count = 0;
3400 const char *delim = strchr(buf,
':');
3401 const char *predef_mem_space = strstr(buf,
"mem_space");
3403 bool is_memalloc = (!predef_mem_space && !delim) ?
true :
false;
3408 for (scan = buf; *scan !=
'\0'; scan++) {
3413 omp_alloctrait_t *traits =
3414 (omp_alloctrait_t *)KMP_ALLOCA(ntraits *
sizeof(omp_alloctrait_t));
3417 #define IS_POWER_OF_TWO(n) (((n) & ((n)-1)) == 0)
3419 #define GET_NEXT(sentinel) \
3422 if (*next == sentinel) \
3428 #define SKIP_PAIR(key) \
3430 char const str_delimiter[] = {',', 0}; \
3431 char *value = __kmp_str_token(CCAST(char *, scan), str_delimiter, \
3432 CCAST(char **, &next)); \
3433 KMP_WARNING(StgInvalidValue, key, value); \
3441 char const str_delimiter[] = {'=', 0}; \
3442 key = __kmp_str_token(CCAST(char *, start), str_delimiter, \
3443 CCAST(char **, &next)); \
3448 while (*next !=
'\0') {
3450 __kmp_match_str(
"fb_data", scan, &next)) {
3454 if (__kmp_match_str(
"omp_high_bw_mem_alloc", scan, &next)) {
3457 if (__kmp_memkind_available) {
3458 __kmp_def_allocator = omp_high_bw_mem_alloc;
3461 KMP_WARNING(OmpNoAllocator,
"omp_high_bw_mem_alloc");
3464 traits[count].key = omp_atk_fb_data;
3465 traits[count].value = RCAST(omp_uintptr_t, omp_high_bw_mem_alloc);
3467 }
else if (__kmp_match_str(
"omp_large_cap_mem_alloc", scan, &next)) {
3470 if (__kmp_memkind_available) {
3471 __kmp_def_allocator = omp_large_cap_mem_alloc;
3474 KMP_WARNING(OmpNoAllocator,
"omp_large_cap_mem_alloc");
3477 traits[count].key = omp_atk_fb_data;
3478 traits[count].value = RCAST(omp_uintptr_t, omp_large_cap_mem_alloc);
3480 }
else if (__kmp_match_str(
"omp_default_mem_alloc", scan, &next)) {
3484 traits[count].key = omp_atk_fb_data;
3485 traits[count].value = RCAST(omp_uintptr_t, omp_default_mem_alloc);
3487 }
else if (__kmp_match_str(
"omp_const_mem_alloc", scan, &next)) {
3490 KMP_WARNING(OmpNoAllocator,
"omp_const_mem_alloc");
3492 traits[count].key = omp_atk_fb_data;
3493 traits[count].value = RCAST(omp_uintptr_t, omp_const_mem_alloc);
3495 }
else if (__kmp_match_str(
"omp_low_lat_mem_alloc", scan, &next)) {
3498 KMP_WARNING(OmpNoAllocator,
"omp_low_lat_mem_alloc");
3500 traits[count].key = omp_atk_fb_data;
3501 traits[count].value = RCAST(omp_uintptr_t, omp_low_lat_mem_alloc);
3503 }
else if (__kmp_match_str(
"omp_cgroup_mem_alloc", scan, &next)) {
3506 KMP_WARNING(OmpNoAllocator,
"omp_cgroup_mem_alloc");
3508 traits[count].key = omp_atk_fb_data;
3509 traits[count].value = RCAST(omp_uintptr_t, omp_cgroup_mem_alloc);
3511 }
else if (__kmp_match_str(
"omp_pteam_mem_alloc", scan, &next)) {
3514 KMP_WARNING(OmpNoAllocator,
"omp_pteam_mem_alloc");
3516 traits[count].key = omp_atk_fb_data;
3517 traits[count].value = RCAST(omp_uintptr_t, omp_pteam_mem_alloc);
3519 }
else if (__kmp_match_str(
"omp_thread_mem_alloc", scan, &next)) {
3522 KMP_WARNING(OmpNoAllocator,
"omp_thread_mem_alloc");
3524 traits[count].key = omp_atk_fb_data;
3525 traits[count].value = RCAST(omp_uintptr_t, omp_thread_mem_alloc);
3535 __kmp_def_allocator = omp_default_mem_alloc;
3536 if (next == buf || *next !=
'\0') {
3538 KMP_WARNING(StgInvalidValue, name, value);
3543 if (count == ntraits)
3549 if (__kmp_match_str(
"omp_default_mem_space", scan, &next)) {
3551 ms = omp_default_mem_space;
3552 }
else if (__kmp_match_str(
"omp_large_cap_mem_space", scan, &next)) {
3554 ms = omp_large_cap_mem_space;
3555 }
else if (__kmp_match_str(
"omp_const_mem_space", scan, &next)) {
3557 ms = omp_const_mem_space;
3558 }
else if (__kmp_match_str(
"omp_high_bw_mem_space", scan, &next)) {
3560 ms = omp_high_bw_mem_space;
3561 }
else if (__kmp_match_str(
"omp_low_lat_mem_space", scan, &next)) {
3563 ms = omp_low_lat_mem_space;
3565 __kmp_def_allocator = omp_default_mem_alloc;
3566 if (next == buf || *next !=
'\0') {
3568 KMP_WARNING(StgInvalidValue, name, value);
3577 if (__kmp_match_str(
"sync_hint", scan, &next)) {
3579 traits[count].key = omp_atk_sync_hint;
3580 if (__kmp_match_str(
"contended", scan, &next)) {
3581 traits[count].value = omp_atv_contended;
3582 }
else if (__kmp_match_str(
"uncontended", scan, &next)) {
3583 traits[count].value = omp_atv_uncontended;
3584 }
else if (__kmp_match_str(
"serialized", scan, &next)) {
3585 traits[count].value = omp_atv_serialized;
3586 }
else if (__kmp_match_str(
"private", scan, &next)) {
3587 traits[count].value = omp_atv_private;
3593 }
else if (__kmp_match_str(
"alignment", scan, &next)) {
3595 if (!isdigit(*next)) {
3601 int n = __kmp_str_to_int(scan,
',');
3602 if (n < 0 || !IS_POWER_OF_TWO(n)) {
3607 traits[count].key = omp_atk_alignment;
3608 traits[count].value = n;
3609 }
else if (__kmp_match_str(
"access", scan, &next)) {
3611 traits[count].key = omp_atk_access;
3612 if (__kmp_match_str(
"all", scan, &next)) {
3613 traits[count].value = omp_atv_all;
3614 }
else if (__kmp_match_str(
"cgroup", scan, &next)) {
3615 traits[count].value = omp_atv_cgroup;
3616 }
else if (__kmp_match_str(
"pteam", scan, &next)) {
3617 traits[count].value = omp_atv_pteam;
3618 }
else if (__kmp_match_str(
"thread", scan, &next)) {
3619 traits[count].value = omp_atv_thread;
3625 }
else if (__kmp_match_str(
"pool_size", scan, &next)) {
3627 if (!isdigit(*next)) {
3633 int n = __kmp_str_to_int(scan,
',');
3639 traits[count].key = omp_atk_pool_size;
3640 traits[count].value = n;
3641 }
else if (__kmp_match_str(
"fallback", scan, &next)) {
3643 traits[count].key = omp_atk_fallback;
3644 if (__kmp_match_str(
"default_mem_fb", scan, &next)) {
3645 traits[count].value = omp_atv_default_mem_fb;
3646 }
else if (__kmp_match_str(
"null_fb", scan, &next)) {
3647 traits[count].value = omp_atv_null_fb;
3648 }
else if (__kmp_match_str(
"abort_fb", scan, &next)) {
3649 traits[count].value = omp_atv_abort_fb;
3650 }
else if (__kmp_match_str(
"allocator_fb", scan, &next)) {
3651 traits[count].value = omp_atv_allocator_fb;
3657 }
else if (__kmp_match_str(
"pinned", scan, &next)) {
3659 traits[count].key = omp_atk_pinned;
3660 if (__kmp_str_match_true(next)) {
3661 traits[count].value = omp_atv_true;
3662 }
else if (__kmp_str_match_false(next)) {
3663 traits[count].value = omp_atv_false;
3669 }
else if (__kmp_match_str(
"partition", scan, &next)) {
3671 traits[count].key = omp_atk_partition;
3672 if (__kmp_match_str(
"environment", scan, &next)) {
3673 traits[count].value = omp_atv_environment;
3674 }
else if (__kmp_match_str(
"nearest", scan, &next)) {
3675 traits[count].value = omp_atv_nearest;
3676 }
else if (__kmp_match_str(
"blocked", scan, &next)) {
3677 traits[count].value = omp_atv_blocked;
3678 }
else if (__kmp_match_str(
"interleaved", scan, &next)) {
3679 traits[count].value = omp_atv_interleaved;
3692 if (count == ntraits)
3698 al = __kmpc_init_allocator(__kmp_get_gtid(), ms, ntraits, traits);
3699 __kmp_def_allocator = (al == omp_null_allocator) ? omp_default_mem_alloc : al;
3702 static void __kmp_stg_print_allocator(kmp_str_buf_t *buffer,
char const *name,
3704 if (__kmp_def_allocator == omp_default_mem_alloc) {
3705 __kmp_stg_print_str(buffer, name,
"omp_default_mem_alloc");
3706 }
else if (__kmp_def_allocator == omp_high_bw_mem_alloc) {
3707 __kmp_stg_print_str(buffer, name,
"omp_high_bw_mem_alloc");
3708 }
else if (__kmp_def_allocator == omp_large_cap_mem_alloc) {
3709 __kmp_stg_print_str(buffer, name,
"omp_large_cap_mem_alloc");
3710 }
else if (__kmp_def_allocator == omp_const_mem_alloc) {
3711 __kmp_stg_print_str(buffer, name,
"omp_const_mem_alloc");
3712 }
else if (__kmp_def_allocator == omp_low_lat_mem_alloc) {
3713 __kmp_stg_print_str(buffer, name,
"omp_low_lat_mem_alloc");
3714 }
else if (__kmp_def_allocator == omp_cgroup_mem_alloc) {
3715 __kmp_stg_print_str(buffer, name,
"omp_cgroup_mem_alloc");
3716 }
else if (__kmp_def_allocator == omp_pteam_mem_alloc) {
3717 __kmp_stg_print_str(buffer, name,
"omp_pteam_mem_alloc");
3718 }
else if (__kmp_def_allocator == omp_thread_mem_alloc) {
3719 __kmp_stg_print_str(buffer, name,
"omp_thread_mem_alloc");
3726 static void __kmp_stg_parse_omp_dynamic(
char const *name,
char const *value,
3728 __kmp_stg_parse_bool(name, value, &(__kmp_global.g.g_dynamic));
3731 static void __kmp_stg_print_omp_dynamic(kmp_str_buf_t *buffer,
char const *name,
3733 __kmp_stg_print_bool(buffer, name, __kmp_global.g.g_dynamic);
3736 static void __kmp_stg_parse_kmp_dynamic_mode(
char const *name,
3737 char const *value,
void *data) {
3738 if (TCR_4(__kmp_init_parallel)) {
3739 KMP_WARNING(EnvParallelWarn, name);
3740 __kmp_env_toPrint(name, 0);
3743 #ifdef USE_LOAD_BALANCE
3744 else if (__kmp_str_match(
"load balance", 2, value) ||
3745 __kmp_str_match(
"load_balance", 2, value) ||
3746 __kmp_str_match(
"load-balance", 2, value) ||
3747 __kmp_str_match(
"loadbalance", 2, value) ||
3748 __kmp_str_match(
"balance", 1, value)) {
3749 __kmp_global.g.g_dynamic_mode = dynamic_load_balance;
3752 else if (__kmp_str_match(
"thread limit", 1, value) ||
3753 __kmp_str_match(
"thread_limit", 1, value) ||
3754 __kmp_str_match(
"thread-limit", 1, value) ||
3755 __kmp_str_match(
"threadlimit", 1, value) ||
3756 __kmp_str_match(
"limit", 2, value)) {
3757 __kmp_global.g.g_dynamic_mode = dynamic_thread_limit;
3758 }
else if (__kmp_str_match(
"random", 1, value)) {
3759 __kmp_global.g.g_dynamic_mode = dynamic_random;
3761 KMP_WARNING(StgInvalidValue, name, value);
3765 static void __kmp_stg_print_kmp_dynamic_mode(kmp_str_buf_t *buffer,
3766 char const *name,
void *data) {
3768 if (__kmp_global.g.g_dynamic_mode == dynamic_default) {
3769 __kmp_str_buf_print(buffer,
" %s: %s \n", name, KMP_I18N_STR(NotDefined));
3771 #ifdef USE_LOAD_BALANCE
3772 else if (__kmp_global.g.g_dynamic_mode == dynamic_load_balance) {
3773 __kmp_stg_print_str(buffer, name,
"load balance");
3776 else if (__kmp_global.g.g_dynamic_mode == dynamic_thread_limit) {
3777 __kmp_stg_print_str(buffer, name,
"thread limit");
3778 }
else if (__kmp_global.g.g_dynamic_mode == dynamic_random) {
3779 __kmp_stg_print_str(buffer, name,
"random");
3786 #ifdef USE_LOAD_BALANCE
3791 static void __kmp_stg_parse_ld_balance_interval(
char const *name,
3792 char const *value,
void *data) {
3793 double interval = __kmp_convert_to_double(value);
3794 if (interval >= 0) {
3795 __kmp_load_balance_interval = interval;
3797 KMP_WARNING(StgInvalidValue, name, value);
3801 static void __kmp_stg_print_ld_balance_interval(kmp_str_buf_t *buffer,
3802 char const *name,
void *data) {
3804 __kmp_str_buf_print(buffer,
" %s=%8.6f\n", name,
3805 __kmp_load_balance_interval);
3814 static void __kmp_stg_parse_init_at_fork(
char const *name,
char const *value,
3816 __kmp_stg_parse_bool(name, value, &__kmp_need_register_atfork);
3817 if (__kmp_need_register_atfork) {
3818 __kmp_need_register_atfork_specified = TRUE;
3822 static void __kmp_stg_print_init_at_fork(kmp_str_buf_t *buffer,
3823 char const *name,
void *data) {
3824 __kmp_stg_print_bool(buffer, name, __kmp_need_register_atfork_specified);
3830 static void __kmp_stg_parse_schedule(
char const *name,
char const *value,
3833 if (value != NULL) {
3834 size_t length = KMP_STRLEN(value);
3835 if (length > INT_MAX) {
3836 KMP_WARNING(LongValue, name);
3838 const char *semicolon;
3839 if (value[length - 1] ==
'"' || value[length - 1] ==
'\'')
3840 KMP_WARNING(UnbalancedQuotes, name);
3844 semicolon = strchr(value,
';');
3845 if (*value && semicolon != value) {
3846 const char *comma = strchr(value,
',');
3853 if (!__kmp_strcasecmp_with_sentinel(
"static", value, sentinel)) {
3854 if (!__kmp_strcasecmp_with_sentinel(
"greedy", comma,
';')) {
3855 __kmp_static = kmp_sch_static_greedy;
3857 }
else if (!__kmp_strcasecmp_with_sentinel(
"balanced", comma,
3859 __kmp_static = kmp_sch_static_balanced;
3862 }
else if (!__kmp_strcasecmp_with_sentinel(
"guided", value,
3864 if (!__kmp_strcasecmp_with_sentinel(
"iterative", comma,
';')) {
3865 __kmp_guided = kmp_sch_guided_iterative_chunked;
3867 }
else if (!__kmp_strcasecmp_with_sentinel(
"analytical", comma,
3870 __kmp_guided = kmp_sch_guided_analytical_chunked;
3874 KMP_WARNING(InvalidClause, name, value);
3876 KMP_WARNING(EmptyClause, name);
3877 }
while ((value = semicolon ? semicolon + 1 : NULL));
3883 static void __kmp_stg_print_schedule(kmp_str_buf_t *buffer,
char const *name,
3885 if (__kmp_env_format) {
3886 KMP_STR_BUF_PRINT_NAME_EX(name);
3888 __kmp_str_buf_print(buffer,
" %s='", name);
3890 if (__kmp_static == kmp_sch_static_greedy) {
3891 __kmp_str_buf_print(buffer,
"%s",
"static,greedy");
3892 }
else if (__kmp_static == kmp_sch_static_balanced) {
3893 __kmp_str_buf_print(buffer,
"%s",
"static,balanced");
3895 if (__kmp_guided == kmp_sch_guided_iterative_chunked) {
3896 __kmp_str_buf_print(buffer,
";%s'\n",
"guided,iterative");
3897 }
else if (__kmp_guided == kmp_sch_guided_analytical_chunked) {
3898 __kmp_str_buf_print(buffer,
";%s'\n",
"guided,analytical");
3905 static inline void __kmp_omp_schedule_restore() {
3906 #if KMP_USE_HIER_SCHED
3907 __kmp_hier_scheds.deallocate();
3917 static const char *__kmp_parse_single_omp_schedule(
const char *name,
3919 bool parse_hier =
false) {
3921 const char *ptr = value;
3928 while (*delim !=
',' && *delim !=
':' && *delim !=
'\0')
3930 #if KMP_USE_HIER_SCHED
3931 kmp_hier_layer_e layer = kmp_hier_layer_e::LAYER_THREAD;
3933 if (*delim ==
',') {
3934 if (!__kmp_strcasecmp_with_sentinel(
"L1", ptr,
',')) {
3935 layer = kmp_hier_layer_e::LAYER_L1;
3936 }
else if (!__kmp_strcasecmp_with_sentinel(
"L2", ptr,
',')) {
3937 layer = kmp_hier_layer_e::LAYER_L2;
3938 }
else if (!__kmp_strcasecmp_with_sentinel(
"L3", ptr,
',')) {
3939 layer = kmp_hier_layer_e::LAYER_L3;
3940 }
else if (!__kmp_strcasecmp_with_sentinel(
"NUMA", ptr,
',')) {
3941 layer = kmp_hier_layer_e::LAYER_NUMA;
3944 if (layer != kmp_hier_layer_e::LAYER_THREAD && *delim !=
',') {
3946 KMP_WARNING(StgInvalidValue, name, value);
3947 __kmp_omp_schedule_restore();
3949 }
else if (layer != kmp_hier_layer_e::LAYER_THREAD) {
3951 while (*delim !=
',' && *delim !=
':' && *delim !=
'\0')
3958 if (*delim ==
':') {
3959 if (!__kmp_strcasecmp_with_sentinel(
"monotonic", ptr, *delim)) {
3962 while (*delim !=
',' && *delim !=
':' && *delim !=
'\0')
3964 }
else if (!__kmp_strcasecmp_with_sentinel(
"nonmonotonic", ptr, *delim)) {
3967 while (*delim !=
',' && *delim !=
':' && *delim !=
'\0')
3969 }
else if (!parse_hier) {
3971 KMP_WARNING(StgInvalidValue, name, value);
3972 __kmp_omp_schedule_restore();
3977 if (!__kmp_strcasecmp_with_sentinel(
"dynamic", ptr, *delim))
3978 sched = kmp_sch_dynamic_chunked;
3979 else if (!__kmp_strcasecmp_with_sentinel(
"guided", ptr, *delim))
3982 else if (!__kmp_strcasecmp_with_sentinel(
"auto", ptr, *delim))
3984 else if (!__kmp_strcasecmp_with_sentinel(
"trapezoidal", ptr, *delim))
3985 sched = kmp_sch_trapezoidal;
3986 else if (!__kmp_strcasecmp_with_sentinel(
"static", ptr, *delim))
3988 #if KMP_STATIC_STEAL_ENABLED
3989 else if (!__kmp_strcasecmp_with_sentinel(
"static_steal", ptr, *delim))
3990 sched = kmp_sch_static_steal;
3994 KMP_WARNING(StgInvalidValue, name, value);
3995 __kmp_omp_schedule_restore();
4000 if (*delim ==
',') {
4003 if (!isdigit(*ptr)) {
4005 KMP_WARNING(StgInvalidValue, name, value);
4006 __kmp_omp_schedule_restore();
4012 __kmp_msg(kmp_ms_warning, KMP_MSG(IgnoreChunk, name, delim),
4016 sched = kmp_sch_static_chunked;
4017 chunk = __kmp_str_to_int(delim + 1, *ptr);
4019 chunk = KMP_DEFAULT_CHUNK;
4020 __kmp_msg(kmp_ms_warning, KMP_MSG(InvalidChunk, name, delim),
4022 KMP_INFORM(Using_int_Value, name, __kmp_chunk);
4031 }
else if (chunk > KMP_MAX_CHUNK) {
4032 chunk = KMP_MAX_CHUNK;
4033 __kmp_msg(kmp_ms_warning, KMP_MSG(LargeChunk, name, delim),
4035 KMP_INFORM(Using_int_Value, name, chunk);
4042 SCHEDULE_SET_MODIFIERS(sched, sched_modifier);
4044 #if KMP_USE_HIER_SCHED
4045 if (layer != kmp_hier_layer_e::LAYER_THREAD) {
4046 __kmp_hier_scheds.append(sched, chunk, layer);
4050 __kmp_chunk = chunk;
4051 __kmp_sched = sched;
4056 static void __kmp_stg_parse_omp_schedule(
char const *name,
char const *value,
4059 const char *ptr = value;
4062 length = KMP_STRLEN(value);
4064 if (value[length - 1] ==
'"' || value[length - 1] ==
'\'')
4065 KMP_WARNING(UnbalancedQuotes, name);
4067 #if KMP_USE_HIER_SCHED
4068 if (!__kmp_strcasecmp_with_sentinel(
"EXPERIMENTAL", ptr,
' ')) {
4071 while ((ptr = __kmp_parse_single_omp_schedule(name, ptr,
true))) {
4072 while (*ptr ==
' ' || *ptr ==
'\t' || *ptr ==
':')
4079 __kmp_parse_single_omp_schedule(name, ptr);
4081 KMP_WARNING(EmptyString, name);
4083 #if KMP_USE_HIER_SCHED
4084 __kmp_hier_scheds.sort();
4086 K_DIAG(1, (
"__kmp_static == %d\n", __kmp_static))
4087 K_DIAG(1, (
"__kmp_guided == %d\n", __kmp_guided))
4088 K_DIAG(1, (
"__kmp_sched == %d\n", __kmp_sched))
4089 K_DIAG(1, (
"__kmp_chunk == %d\n", __kmp_chunk))
4092 static void __kmp_stg_print_omp_schedule(kmp_str_buf_t *buffer,
4093 char const *name,
void *data) {
4094 if (__kmp_env_format) {
4095 KMP_STR_BUF_PRINT_NAME_EX(name);
4097 __kmp_str_buf_print(buffer,
" %s='", name);
4099 enum sched_type sched = SCHEDULE_WITHOUT_MODIFIERS(__kmp_sched);
4100 if (SCHEDULE_HAS_MONOTONIC(__kmp_sched)) {
4101 __kmp_str_buf_print(buffer,
"monotonic:");
4102 }
else if (SCHEDULE_HAS_NONMONOTONIC(__kmp_sched)) {
4103 __kmp_str_buf_print(buffer,
"nonmonotonic:");
4107 case kmp_sch_dynamic_chunked:
4108 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"dynamic", __kmp_chunk);
4110 case kmp_sch_guided_iterative_chunked:
4111 case kmp_sch_guided_analytical_chunked:
4112 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"guided", __kmp_chunk);
4114 case kmp_sch_trapezoidal:
4115 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"trapezoidal", __kmp_chunk);
4118 case kmp_sch_static_chunked:
4119 case kmp_sch_static_balanced:
4120 case kmp_sch_static_greedy:
4121 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"static", __kmp_chunk);
4123 case kmp_sch_static_steal:
4124 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"static_steal", __kmp_chunk);
4127 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"auto", __kmp_chunk);
4132 case kmp_sch_dynamic_chunked:
4133 __kmp_str_buf_print(buffer,
"%s'\n",
"dynamic");
4135 case kmp_sch_guided_iterative_chunked:
4136 case kmp_sch_guided_analytical_chunked:
4137 __kmp_str_buf_print(buffer,
"%s'\n",
"guided");
4139 case kmp_sch_trapezoidal:
4140 __kmp_str_buf_print(buffer,
"%s'\n",
"trapezoidal");
4143 case kmp_sch_static_chunked:
4144 case kmp_sch_static_balanced:
4145 case kmp_sch_static_greedy:
4146 __kmp_str_buf_print(buffer,
"%s'\n",
"static");
4148 case kmp_sch_static_steal:
4149 __kmp_str_buf_print(buffer,
"%s'\n",
"static_steal");
4152 __kmp_str_buf_print(buffer,
"%s'\n",
"auto");
4158 #if KMP_USE_HIER_SCHED
4161 static void __kmp_stg_parse_kmp_hand_thread(
char const *name,
char const *value,
4163 __kmp_stg_parse_bool(name, value, &(__kmp_dispatch_hand_threading));
4166 static void __kmp_stg_print_kmp_hand_thread(kmp_str_buf_t *buffer,
4167 char const *name,
void *data) {
4168 __kmp_stg_print_bool(buffer, name, __kmp_dispatch_hand_threading);
4174 static void __kmp_stg_parse_kmp_force_monotonic(
char const *name,
4175 char const *value,
void *data) {
4176 __kmp_stg_parse_bool(name, value, &(__kmp_force_monotonic));
4179 static void __kmp_stg_print_kmp_force_monotonic(kmp_str_buf_t *buffer,
4180 char const *name,
void *data) {
4181 __kmp_stg_print_bool(buffer, name, __kmp_force_monotonic);
4187 static void __kmp_stg_parse_atomic_mode(
char const *name,
char const *value,
4193 #ifdef KMP_GOMP_COMPAT
4196 __kmp_stg_parse_int(name, value, 0, max, &mode);
4201 __kmp_atomic_mode = mode;
4205 static void __kmp_stg_print_atomic_mode(kmp_str_buf_t *buffer,
char const *name,
4207 __kmp_stg_print_int(buffer, name, __kmp_atomic_mode);
4213 static void __kmp_stg_parse_consistency_check(
char const *name,
4214 char const *value,
void *data) {
4215 if (!__kmp_strcasecmp_with_sentinel(
"all", value, 0)) {
4221 __kmp_env_consistency_check = TRUE;
4222 }
else if (!__kmp_strcasecmp_with_sentinel(
"none", value, 0)) {
4223 __kmp_env_consistency_check = FALSE;
4225 KMP_WARNING(StgInvalidValue, name, value);
4229 static void __kmp_stg_print_consistency_check(kmp_str_buf_t *buffer,
4230 char const *name,
void *data) {
4232 const char *value = NULL;
4234 if (__kmp_env_consistency_check) {
4240 if (value != NULL) {
4241 __kmp_stg_print_str(buffer, name, value);
4252 static void __kmp_stg_parse_itt_prepare_delay(
char const *name,
4253 char const *value,
void *data) {
4257 __kmp_stg_parse_int(name, value, 0, INT_MAX, &delay);
4258 __kmp_itt_prepare_delay = delay;
4261 static void __kmp_stg_print_itt_prepare_delay(kmp_str_buf_t *buffer,
4262 char const *name,
void *data) {
4263 __kmp_stg_print_uint64(buffer, name, __kmp_itt_prepare_delay);
4273 static void __kmp_stg_parse_malloc_pool_incr(
char const *name,
4274 char const *value,
void *data) {
4275 __kmp_stg_parse_size(name, value, KMP_MIN_MALLOC_POOL_INCR,
4276 KMP_MAX_MALLOC_POOL_INCR, NULL, &__kmp_malloc_pool_incr,
4280 static void __kmp_stg_print_malloc_pool_incr(kmp_str_buf_t *buffer,
4281 char const *name,
void *data) {
4282 __kmp_stg_print_size(buffer, name, __kmp_malloc_pool_incr);
4291 static void __kmp_stg_parse_par_range_env(
char const *name,
char const *value,
4293 __kmp_stg_parse_par_range(name, value, &__kmp_par_range,
4294 __kmp_par_range_routine, __kmp_par_range_filename,
4295 &__kmp_par_range_lb, &__kmp_par_range_ub);
4298 static void __kmp_stg_print_par_range_env(kmp_str_buf_t *buffer,
4299 char const *name,
void *data) {
4300 if (__kmp_par_range != 0) {
4301 __kmp_stg_print_str(buffer, name, par_range_to_print);
4310 static void __kmp_stg_parse_gtid_mode(
char const *name,
char const *value,
4320 #ifdef KMP_TDATA_GTID
4323 __kmp_stg_parse_int(name, value, 0, max, &mode);
4327 __kmp_adjust_gtid_mode = TRUE;
4329 __kmp_gtid_mode = mode;
4330 __kmp_adjust_gtid_mode = FALSE;
4334 static void __kmp_stg_print_gtid_mode(kmp_str_buf_t *buffer,
char const *name,
4336 if (__kmp_adjust_gtid_mode) {
4337 __kmp_stg_print_int(buffer, name, 0);
4339 __kmp_stg_print_int(buffer, name, __kmp_gtid_mode);
4346 static void __kmp_stg_parse_lock_block(
char const *name,
char const *value,
4348 __kmp_stg_parse_int(name, value, 0, KMP_INT_MAX, &__kmp_num_locks_in_block);
4351 static void __kmp_stg_print_lock_block(kmp_str_buf_t *buffer,
char const *name,
4353 __kmp_stg_print_int(buffer, name, __kmp_num_locks_in_block);
4359 #if KMP_USE_DYNAMIC_LOCK
4360 #define KMP_STORE_LOCK_SEQ(a) (__kmp_user_lock_seq = lockseq_##a)
4362 #define KMP_STORE_LOCK_SEQ(a)
4365 static void __kmp_stg_parse_lock_kind(
char const *name,
char const *value,
4367 if (__kmp_init_user_locks) {
4368 KMP_WARNING(EnvLockWarn, name);
4372 if (__kmp_str_match(
"tas", 2, value) ||
4373 __kmp_str_match(
"test and set", 2, value) ||
4374 __kmp_str_match(
"test_and_set", 2, value) ||
4375 __kmp_str_match(
"test-and-set", 2, value) ||
4376 __kmp_str_match(
"test andset", 2, value) ||
4377 __kmp_str_match(
"test_andset", 2, value) ||
4378 __kmp_str_match(
"test-andset", 2, value) ||
4379 __kmp_str_match(
"testand set", 2, value) ||
4380 __kmp_str_match(
"testand_set", 2, value) ||
4381 __kmp_str_match(
"testand-set", 2, value) ||
4382 __kmp_str_match(
"testandset", 2, value)) {
4383 __kmp_user_lock_kind = lk_tas;
4384 KMP_STORE_LOCK_SEQ(tas);
4387 else if (__kmp_str_match(
"futex", 1, value)) {
4388 if (__kmp_futex_determine_capable()) {
4389 __kmp_user_lock_kind = lk_futex;
4390 KMP_STORE_LOCK_SEQ(futex);
4392 KMP_WARNING(FutexNotSupported, name, value);
4396 else if (__kmp_str_match(
"ticket", 2, value)) {
4397 __kmp_user_lock_kind = lk_ticket;
4398 KMP_STORE_LOCK_SEQ(ticket);
4399 }
else if (__kmp_str_match(
"queuing", 1, value) ||
4400 __kmp_str_match(
"queue", 1, value)) {
4401 __kmp_user_lock_kind = lk_queuing;
4402 KMP_STORE_LOCK_SEQ(queuing);
4403 }
else if (__kmp_str_match(
"drdpa ticket", 1, value) ||
4404 __kmp_str_match(
"drdpa_ticket", 1, value) ||
4405 __kmp_str_match(
"drdpa-ticket", 1, value) ||
4406 __kmp_str_match(
"drdpaticket", 1, value) ||
4407 __kmp_str_match(
"drdpa", 1, value)) {
4408 __kmp_user_lock_kind = lk_drdpa;
4409 KMP_STORE_LOCK_SEQ(drdpa);
4411 #if KMP_USE_ADAPTIVE_LOCKS
4412 else if (__kmp_str_match(
"adaptive", 1, value)) {
4413 if (__kmp_cpuinfo.rtm) {
4414 __kmp_user_lock_kind = lk_adaptive;
4415 KMP_STORE_LOCK_SEQ(adaptive);
4417 KMP_WARNING(AdaptiveNotSupported, name, value);
4418 __kmp_user_lock_kind = lk_queuing;
4419 KMP_STORE_LOCK_SEQ(queuing);
4423 #if KMP_USE_DYNAMIC_LOCK && KMP_USE_TSX
4424 else if (__kmp_str_match(
"rtm_queuing", 1, value)) {
4425 if (__kmp_cpuinfo.rtm) {
4426 __kmp_user_lock_kind = lk_rtm_queuing;
4427 KMP_STORE_LOCK_SEQ(rtm_queuing);
4429 KMP_WARNING(AdaptiveNotSupported, name, value);
4430 __kmp_user_lock_kind = lk_queuing;
4431 KMP_STORE_LOCK_SEQ(queuing);
4433 }
else if (__kmp_str_match(
"rtm_spin", 1, value)) {
4434 if (__kmp_cpuinfo.rtm) {
4435 __kmp_user_lock_kind = lk_rtm_spin;
4436 KMP_STORE_LOCK_SEQ(rtm_spin);
4438 KMP_WARNING(AdaptiveNotSupported, name, value);
4439 __kmp_user_lock_kind = lk_tas;
4440 KMP_STORE_LOCK_SEQ(queuing);
4442 }
else if (__kmp_str_match(
"hle", 1, value)) {
4443 __kmp_user_lock_kind = lk_hle;
4444 KMP_STORE_LOCK_SEQ(hle);
4448 KMP_WARNING(StgInvalidValue, name, value);
4452 static void __kmp_stg_print_lock_kind(kmp_str_buf_t *buffer,
char const *name,
4454 const char *value = NULL;
4456 switch (__kmp_user_lock_kind) {
4471 #if KMP_USE_DYNAMIC_LOCK && KMP_USE_TSX
4472 case lk_rtm_queuing:
4473 value =
"rtm_queuing";
4496 #if KMP_USE_ADAPTIVE_LOCKS
4503 if (value != NULL) {
4504 __kmp_stg_print_str(buffer, name, value);
4513 static void __kmp_stg_parse_spin_backoff_params(
const char *name,
4514 const char *value,
void *data) {
4515 const char *next = value;
4518 int prev_comma = FALSE;
4521 kmp_uint32 max_backoff = __kmp_spin_backoff_params.max_backoff;
4522 kmp_uint32 min_tick = __kmp_spin_backoff_params.min_tick;
4526 for (i = 0; i < 3; i++) {
4529 if (*next ==
'\0') {
4534 if (((*next < '0' || *next >
'9') && *next !=
',') || total > 2) {
4535 KMP_WARNING(EnvSyntaxError, name, value);
4541 if (total == 0 || prev_comma) {
4549 if (*next >=
'0' && *next <=
'9') {
4551 const char *buf = next;
4552 char const *msg = NULL;
4557 const char *tmp = next;
4559 if ((*next ==
' ' || *next ==
'\t') && (*tmp >=
'0' && *tmp <=
'9')) {
4560 KMP_WARNING(EnvSpacesNotAllowed, name, value);
4564 num = __kmp_str_to_int(buf, *next);
4566 msg = KMP_I18N_STR(ValueTooSmall);
4568 }
else if (num > KMP_INT_MAX) {
4569 msg = KMP_I18N_STR(ValueTooLarge);
4574 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
4575 KMP_INFORM(Using_int_Value, name, num);
4579 }
else if (total == 2) {
4584 KMP_DEBUG_ASSERT(total > 0);
4586 KMP_WARNING(EnvSyntaxError, name, value);
4589 __kmp_spin_backoff_params.max_backoff = max_backoff;
4590 __kmp_spin_backoff_params.min_tick = min_tick;
4593 static void __kmp_stg_print_spin_backoff_params(kmp_str_buf_t *buffer,
4594 char const *name,
void *data) {
4595 if (__kmp_env_format) {
4596 KMP_STR_BUF_PRINT_NAME_EX(name);
4598 __kmp_str_buf_print(buffer,
" %s='", name);
4600 __kmp_str_buf_print(buffer,
"%d,%d'\n", __kmp_spin_backoff_params.max_backoff,
4601 __kmp_spin_backoff_params.min_tick);
4604 #if KMP_USE_ADAPTIVE_LOCKS
4611 static void __kmp_stg_parse_adaptive_lock_props(
const char *name,
4612 const char *value,
void *data) {
4613 int max_retries = 0;
4614 int max_badness = 0;
4616 const char *next = value;
4619 int prev_comma = FALSE;
4625 for (i = 0; i < 3; i++) {
4628 if (*next ==
'\0') {
4633 if (((*next < '0' || *next >
'9') && *next !=
',') || total > 2) {
4634 KMP_WARNING(EnvSyntaxError, name, value);
4640 if (total == 0 || prev_comma) {
4648 if (*next >=
'0' && *next <=
'9') {
4650 const char *buf = next;
4651 char const *msg = NULL;
4656 const char *tmp = next;
4658 if ((*next ==
' ' || *next ==
'\t') && (*tmp >=
'0' && *tmp <=
'9')) {
4659 KMP_WARNING(EnvSpacesNotAllowed, name, value);
4663 num = __kmp_str_to_int(buf, *next);
4665 msg = KMP_I18N_STR(ValueTooSmall);
4667 }
else if (num > KMP_INT_MAX) {
4668 msg = KMP_I18N_STR(ValueTooLarge);
4673 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
4674 KMP_INFORM(Using_int_Value, name, num);
4678 }
else if (total == 2) {
4683 KMP_DEBUG_ASSERT(total > 0);
4685 KMP_WARNING(EnvSyntaxError, name, value);
4688 __kmp_adaptive_backoff_params.max_soft_retries = max_retries;
4689 __kmp_adaptive_backoff_params.max_badness = max_badness;
4692 static void __kmp_stg_print_adaptive_lock_props(kmp_str_buf_t *buffer,
4693 char const *name,
void *data) {
4694 if (__kmp_env_format) {
4695 KMP_STR_BUF_PRINT_NAME_EX(name);
4697 __kmp_str_buf_print(buffer,
" %s='", name);
4699 __kmp_str_buf_print(buffer,
"%d,%d'\n",
4700 __kmp_adaptive_backoff_params.max_soft_retries,
4701 __kmp_adaptive_backoff_params.max_badness);
4704 #if KMP_DEBUG_ADAPTIVE_LOCKS
4706 static void __kmp_stg_parse_speculative_statsfile(
char const *name,
4709 __kmp_stg_parse_file(name, value,
"",
4710 CCAST(
char **, &__kmp_speculative_statsfile));
4713 static void __kmp_stg_print_speculative_statsfile(kmp_str_buf_t *buffer,
4716 if (__kmp_str_match(
"-", 0, __kmp_speculative_statsfile)) {
4717 __kmp_stg_print_str(buffer, name,
"stdout");
4719 __kmp_stg_print_str(buffer, name, __kmp_speculative_statsfile);
4735 #define MAX_T_LEVEL 5
4736 #define MAX_STR_LEN 512
4737 static void __kmp_stg_parse_hw_subset(
char const *name,
char const *value,
4741 kmp_setting_t **rivals = (kmp_setting_t **)data;
4742 if (strcmp(name,
"KMP_PLACE_THREADS") == 0) {
4743 KMP_INFORM(EnvVarDeprecated, name,
"KMP_HW_SUBSET");
4745 if (__kmp_stg_check_rivals(name, value, rivals)) {
4749 char *components[MAX_T_LEVEL];
4750 char const *digits =
"0123456789";
4751 char input[MAX_STR_LEN];
4752 size_t len = 0, mlen = MAX_STR_LEN;
4755 char *pos = CCAST(
char *, value);
4756 while (*pos && mlen) {
4758 if (len == 0 && *pos ==
':') {
4759 __kmp_hws_abs_flag = 1;
4761 input[len] = (char)(toupper(*pos));
4762 if (input[len] ==
'X')
4764 if (input[len] ==
'O' && strchr(digits, *(pos + 1)))
4772 if (len == 0 || mlen == 0)
4775 __kmp_hws_requested = 1;
4778 components[level++] = pos;
4779 while ((pos = strchr(pos,
','))) {
4780 if (level >= MAX_T_LEVEL)
4783 components[level++] = ++pos;
4786 for (
int i = 0; i < level; ++i) {
4788 int num = atoi(components[i]);
4789 if ((pos = strchr(components[i],
'@'))) {
4790 offset = atoi(pos + 1);
4793 pos = components[i] + strspn(components[i], digits);
4794 if (pos == components[i])
4799 if (__kmp_hws_socket.num > 0)
4801 __kmp_hws_socket.num = num;
4802 __kmp_hws_socket.offset = offset;
4805 if (__kmp_hws_node.num > 0)
4807 __kmp_hws_node.num = num;
4808 __kmp_hws_node.offset = offset;
4811 if (__kmp_hws_die.num > 0)
4813 __kmp_hws_die.num = num;
4814 __kmp_hws_die.offset = offset;
4817 if (*(pos + 1) ==
'2') {
4818 if (__kmp_hws_tile.num > 0)
4820 __kmp_hws_tile.num = num;
4821 __kmp_hws_tile.offset = offset;
4822 }
else if (*(pos + 1) ==
'3') {
4823 if (__kmp_hws_socket.num > 0 || __kmp_hws_die.num > 0)
4825 __kmp_hws_socket.num = num;
4826 __kmp_hws_socket.offset = offset;
4827 }
else if (*(pos + 1) ==
'1') {
4828 if (__kmp_hws_core.num > 0)
4830 __kmp_hws_core.num = num;
4831 __kmp_hws_core.offset = offset;
4835 if (*(pos + 1) !=
'A') {
4836 if (__kmp_hws_core.num > 0)
4838 __kmp_hws_core.num = num;
4839 __kmp_hws_core.offset = offset;
4841 char *d = pos + strcspn(pos, digits);
4843 if (__kmp_hws_tile.num > 0)
4845 __kmp_hws_tile.num = num;
4846 __kmp_hws_tile.offset = offset;
4847 }
else if (*d ==
'3') {
4848 if (__kmp_hws_socket.num > 0 || __kmp_hws_die.num > 0)
4850 __kmp_hws_socket.num = num;
4851 __kmp_hws_socket.offset = offset;
4852 }
else if (*d ==
'1') {
4853 if (__kmp_hws_core.num > 0)
4855 __kmp_hws_core.num = num;
4856 __kmp_hws_core.offset = offset;
4863 if (__kmp_hws_proc.num > 0)
4865 __kmp_hws_proc.num = num;
4866 __kmp_hws_proc.offset = offset;
4874 KMP_WARNING(AffHWSubsetInvalid, name, value);
4875 __kmp_hws_requested = 0;
4879 static void __kmp_stg_print_hw_subset(kmp_str_buf_t *buffer,
char const *name,
4881 if (__kmp_hws_requested) {
4884 __kmp_str_buf_init(&buf);
4885 if (__kmp_env_format)
4886 KMP_STR_BUF_PRINT_NAME_EX(name);
4888 __kmp_str_buf_print(buffer,
" %s='", name);
4889 if (__kmp_hws_socket.num) {
4890 __kmp_str_buf_print(&buf,
"%ds", __kmp_hws_socket.num);
4891 if (__kmp_hws_socket.offset)
4892 __kmp_str_buf_print(&buf,
"@%d", __kmp_hws_socket.offset);
4895 if (__kmp_hws_die.num) {
4896 __kmp_str_buf_print(&buf,
"%s%dd", comma ?
"," :
"", __kmp_hws_die.num);
4897 if (__kmp_hws_die.offset)
4898 __kmp_str_buf_print(&buf,
"@%d", __kmp_hws_die.offset);
4901 if (__kmp_hws_node.num) {
4902 __kmp_str_buf_print(&buf,
"%s%dn", comma ?
"," :
"", __kmp_hws_node.num);
4903 if (__kmp_hws_node.offset)
4904 __kmp_str_buf_print(&buf,
"@%d", __kmp_hws_node.offset);
4907 if (__kmp_hws_tile.num) {
4908 __kmp_str_buf_print(&buf,
"%s%dL2", comma ?
"," :
"", __kmp_hws_tile.num);
4909 if (__kmp_hws_tile.offset)
4910 __kmp_str_buf_print(&buf,
"@%d", __kmp_hws_tile.offset);
4913 if (__kmp_hws_core.num) {
4914 __kmp_str_buf_print(&buf,
"%s%dc", comma ?
"," :
"", __kmp_hws_core.num);
4915 if (__kmp_hws_core.offset)
4916 __kmp_str_buf_print(&buf,
"@%d", __kmp_hws_core.offset);
4919 if (__kmp_hws_proc.num)
4920 __kmp_str_buf_print(&buf,
"%s%dt", comma ?
"," :
"", __kmp_hws_proc.num);
4921 __kmp_str_buf_print(buffer,
"%s'\n", buf.str);
4922 __kmp_str_buf_free(&buf);
4930 static void __kmp_stg_parse_forkjoin_frames(
char const *name,
char const *value,
4932 __kmp_stg_parse_bool(name, value, &__kmp_forkjoin_frames);
4935 static void __kmp_stg_print_forkjoin_frames(kmp_str_buf_t *buffer,
4936 char const *name,
void *data) {
4937 __kmp_stg_print_bool(buffer, name, __kmp_forkjoin_frames);
4943 static void __kmp_stg_parse_forkjoin_frames_mode(
char const *name,
4946 __kmp_stg_parse_int(name, value, 0, 3, &__kmp_forkjoin_frames_mode);
4949 static void __kmp_stg_print_forkjoin_frames_mode(kmp_str_buf_t *buffer,
4950 char const *name,
void *data) {
4951 __kmp_stg_print_int(buffer, name, __kmp_forkjoin_frames_mode);
4958 static void __kmp_stg_parse_task_throttling(
char const *name,
char const *value,
4960 __kmp_stg_parse_bool(name, value, &__kmp_enable_task_throttling);
4963 static void __kmp_stg_print_task_throttling(kmp_str_buf_t *buffer,
4964 char const *name,
void *data) {
4965 __kmp_stg_print_bool(buffer, name, __kmp_enable_task_throttling);
4968 #if KMP_HAVE_MWAIT || KMP_HAVE_UMWAIT
4972 static void __kmp_stg_parse_user_level_mwait(
char const *name,
4973 char const *value,
void *data) {
4974 __kmp_stg_parse_bool(name, value, &__kmp_user_level_mwait);
4977 static void __kmp_stg_print_user_level_mwait(kmp_str_buf_t *buffer,
4978 char const *name,
void *data) {
4979 __kmp_stg_print_bool(buffer, name, __kmp_user_level_mwait);
4985 static void __kmp_stg_parse_mwait_hints(
char const *name,
char const *value,
4987 __kmp_stg_parse_int(name, value, 0, INT_MAX, &__kmp_mwait_hints);
4990 static void __kmp_stg_print_mwait_hints(kmp_str_buf_t *buffer,
char const *name,
4992 __kmp_stg_print_int(buffer, name, __kmp_mwait_hints);
5000 static void __kmp_stg_parse_omp_display_env(
char const *name,
char const *value,
5002 if (__kmp_str_match(
"VERBOSE", 1, value)) {
5003 __kmp_display_env_verbose = TRUE;
5005 __kmp_stg_parse_bool(name, value, &__kmp_display_env);
5009 static void __kmp_stg_print_omp_display_env(kmp_str_buf_t *buffer,
5010 char const *name,
void *data) {
5011 if (__kmp_display_env_verbose) {
5012 __kmp_stg_print_str(buffer, name,
"VERBOSE");
5014 __kmp_stg_print_bool(buffer, name, __kmp_display_env);
5018 static void __kmp_stg_parse_omp_cancellation(
char const *name,
5019 char const *value,
void *data) {
5020 if (TCR_4(__kmp_init_parallel)) {
5021 KMP_WARNING(EnvParallelWarn, name);
5024 __kmp_stg_parse_bool(name, value, &__kmp_omp_cancellation);
5027 static void __kmp_stg_print_omp_cancellation(kmp_str_buf_t *buffer,
5028 char const *name,
void *data) {
5029 __kmp_stg_print_bool(buffer, name, __kmp_omp_cancellation);
5033 static int __kmp_tool = 1;
5035 static void __kmp_stg_parse_omp_tool(
char const *name,
char const *value,
5037 __kmp_stg_parse_bool(name, value, &__kmp_tool);
5040 static void __kmp_stg_print_omp_tool(kmp_str_buf_t *buffer,
char const *name,
5042 if (__kmp_env_format) {
5043 KMP_STR_BUF_PRINT_BOOL_EX(name, __kmp_tool,
"enabled",
"disabled");
5045 __kmp_str_buf_print(buffer,
" %s=%s\n", name,
5046 __kmp_tool ?
"enabled" :
"disabled");
5050 static char *__kmp_tool_libraries = NULL;
5052 static void __kmp_stg_parse_omp_tool_libraries(
char const *name,
5053 char const *value,
void *data) {
5054 __kmp_stg_parse_str(name, value, &__kmp_tool_libraries);
5057 static void __kmp_stg_print_omp_tool_libraries(kmp_str_buf_t *buffer,
5058 char const *name,
void *data) {
5059 if (__kmp_tool_libraries)
5060 __kmp_stg_print_str(buffer, name, __kmp_tool_libraries);
5062 if (__kmp_env_format) {
5063 KMP_STR_BUF_PRINT_NAME;
5065 __kmp_str_buf_print(buffer,
" %s", name);
5067 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
5071 static char *__kmp_tool_verbose_init = NULL;
5073 static void __kmp_stg_parse_omp_tool_verbose_init(
char const *name,
5076 __kmp_stg_parse_str(name, value, &__kmp_tool_verbose_init);
5079 static void __kmp_stg_print_omp_tool_verbose_init(kmp_str_buf_t *buffer,
5082 if (__kmp_tool_verbose_init)
5083 __kmp_stg_print_str(buffer, name, __kmp_tool_verbose_init);
5085 if (__kmp_env_format) {
5086 KMP_STR_BUF_PRINT_NAME;
5088 __kmp_str_buf_print(buffer,
" %s", name);
5090 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
5098 static kmp_setting_t __kmp_stg_table[] = {
5100 {
"KMP_ALL_THREADS", __kmp_stg_parse_device_thread_limit, NULL, NULL, 0, 0},
5101 {
"KMP_BLOCKTIME", __kmp_stg_parse_blocktime, __kmp_stg_print_blocktime,
5103 {
"KMP_USE_YIELD", __kmp_stg_parse_use_yield, __kmp_stg_print_use_yield,
5105 {
"KMP_DUPLICATE_LIB_OK", __kmp_stg_parse_duplicate_lib_ok,
5106 __kmp_stg_print_duplicate_lib_ok, NULL, 0, 0},
5107 {
"KMP_LIBRARY", __kmp_stg_parse_wait_policy, __kmp_stg_print_wait_policy,
5109 {
"KMP_DEVICE_THREAD_LIMIT", __kmp_stg_parse_device_thread_limit,
5110 __kmp_stg_print_device_thread_limit, NULL, 0, 0},
5112 {
"KMP_MONITOR_STACKSIZE", __kmp_stg_parse_monitor_stacksize,
5113 __kmp_stg_print_monitor_stacksize, NULL, 0, 0},
5115 {
"KMP_SETTINGS", __kmp_stg_parse_settings, __kmp_stg_print_settings, NULL,
5117 {
"KMP_STACKOFFSET", __kmp_stg_parse_stackoffset,
5118 __kmp_stg_print_stackoffset, NULL, 0, 0},
5119 {
"KMP_STACKSIZE", __kmp_stg_parse_stacksize, __kmp_stg_print_stacksize,
5121 {
"KMP_STACKPAD", __kmp_stg_parse_stackpad, __kmp_stg_print_stackpad, NULL,
5123 {
"KMP_VERSION", __kmp_stg_parse_version, __kmp_stg_print_version, NULL, 0,
5125 {
"KMP_WARNINGS", __kmp_stg_parse_warnings, __kmp_stg_print_warnings, NULL,
5128 {
"OMP_NESTED", __kmp_stg_parse_nested, __kmp_stg_print_nested, NULL, 0, 0},
5129 {
"OMP_NUM_THREADS", __kmp_stg_parse_num_threads,
5130 __kmp_stg_print_num_threads, NULL, 0, 0},
5131 {
"OMP_STACKSIZE", __kmp_stg_parse_stacksize, __kmp_stg_print_stacksize,
5134 {
"KMP_TASKING", __kmp_stg_parse_tasking, __kmp_stg_print_tasking, NULL, 0,
5136 {
"KMP_TASK_STEALING_CONSTRAINT", __kmp_stg_parse_task_stealing,
5137 __kmp_stg_print_task_stealing, NULL, 0, 0},
5138 {
"OMP_MAX_ACTIVE_LEVELS", __kmp_stg_parse_max_active_levels,
5139 __kmp_stg_print_max_active_levels, NULL, 0, 0},
5140 {
"OMP_DEFAULT_DEVICE", __kmp_stg_parse_default_device,
5141 __kmp_stg_print_default_device, NULL, 0, 0},
5142 {
"OMP_TARGET_OFFLOAD", __kmp_stg_parse_target_offload,
5143 __kmp_stg_print_target_offload, NULL, 0, 0},
5144 {
"OMP_MAX_TASK_PRIORITY", __kmp_stg_parse_max_task_priority,
5145 __kmp_stg_print_max_task_priority, NULL, 0, 0},
5146 {
"KMP_TASKLOOP_MIN_TASKS", __kmp_stg_parse_taskloop_min_tasks,
5147 __kmp_stg_print_taskloop_min_tasks, NULL, 0, 0},
5148 {
"OMP_THREAD_LIMIT", __kmp_stg_parse_thread_limit,
5149 __kmp_stg_print_thread_limit, NULL, 0, 0},
5150 {
"KMP_TEAMS_THREAD_LIMIT", __kmp_stg_parse_teams_thread_limit,
5151 __kmp_stg_print_teams_thread_limit, NULL, 0, 0},
5152 {
"OMP_NUM_TEAMS", __kmp_stg_parse_nteams, __kmp_stg_print_nteams, NULL, 0,
5154 {
"OMP_TEAMS_THREAD_LIMIT", __kmp_stg_parse_teams_th_limit,
5155 __kmp_stg_print_teams_th_limit, NULL, 0, 0},
5156 {
"OMP_WAIT_POLICY", __kmp_stg_parse_wait_policy,
5157 __kmp_stg_print_wait_policy, NULL, 0, 0},
5158 {
"KMP_DISP_NUM_BUFFERS", __kmp_stg_parse_disp_buffers,
5159 __kmp_stg_print_disp_buffers, NULL, 0, 0},
5160 #if KMP_NESTED_HOT_TEAMS
5161 {
"KMP_HOT_TEAMS_MAX_LEVEL", __kmp_stg_parse_hot_teams_level,
5162 __kmp_stg_print_hot_teams_level, NULL, 0, 0},
5163 {
"KMP_HOT_TEAMS_MODE", __kmp_stg_parse_hot_teams_mode,
5164 __kmp_stg_print_hot_teams_mode, NULL, 0, 0},
5167 #if KMP_HANDLE_SIGNALS
5168 {
"KMP_HANDLE_SIGNALS", __kmp_stg_parse_handle_signals,
5169 __kmp_stg_print_handle_signals, NULL, 0, 0},
5172 #if KMP_ARCH_X86 || KMP_ARCH_X86_64
5173 {
"KMP_INHERIT_FP_CONTROL", __kmp_stg_parse_inherit_fp_control,
5174 __kmp_stg_print_inherit_fp_control, NULL, 0, 0},
5177 #ifdef KMP_GOMP_COMPAT
5178 {
"GOMP_STACKSIZE", __kmp_stg_parse_stacksize, NULL, NULL, 0, 0},
5182 {
"KMP_A_DEBUG", __kmp_stg_parse_a_debug, __kmp_stg_print_a_debug, NULL, 0,
5184 {
"KMP_B_DEBUG", __kmp_stg_parse_b_debug, __kmp_stg_print_b_debug, NULL, 0,
5186 {
"KMP_C_DEBUG", __kmp_stg_parse_c_debug, __kmp_stg_print_c_debug, NULL, 0,
5188 {
"KMP_D_DEBUG", __kmp_stg_parse_d_debug, __kmp_stg_print_d_debug, NULL, 0,
5190 {
"KMP_E_DEBUG", __kmp_stg_parse_e_debug, __kmp_stg_print_e_debug, NULL, 0,
5192 {
"KMP_F_DEBUG", __kmp_stg_parse_f_debug, __kmp_stg_print_f_debug, NULL, 0,
5194 {
"KMP_DEBUG", __kmp_stg_parse_debug, NULL, NULL, 0, 0},
5195 {
"KMP_DEBUG_BUF", __kmp_stg_parse_debug_buf, __kmp_stg_print_debug_buf,
5197 {
"KMP_DEBUG_BUF_ATOMIC", __kmp_stg_parse_debug_buf_atomic,
5198 __kmp_stg_print_debug_buf_atomic, NULL, 0, 0},
5199 {
"KMP_DEBUG_BUF_CHARS", __kmp_stg_parse_debug_buf_chars,
5200 __kmp_stg_print_debug_buf_chars, NULL, 0, 0},
5201 {
"KMP_DEBUG_BUF_LINES", __kmp_stg_parse_debug_buf_lines,
5202 __kmp_stg_print_debug_buf_lines, NULL, 0, 0},
5203 {
"KMP_DIAG", __kmp_stg_parse_diag, __kmp_stg_print_diag, NULL, 0, 0},
5205 {
"KMP_PAR_RANGE", __kmp_stg_parse_par_range_env,
5206 __kmp_stg_print_par_range_env, NULL, 0, 0},
5209 {
"KMP_ALIGN_ALLOC", __kmp_stg_parse_align_alloc,
5210 __kmp_stg_print_align_alloc, NULL, 0, 0},
5212 {
"KMP_PLAIN_BARRIER", __kmp_stg_parse_barrier_branch_bit,
5213 __kmp_stg_print_barrier_branch_bit, NULL, 0, 0},
5214 {
"KMP_PLAIN_BARRIER_PATTERN", __kmp_stg_parse_barrier_pattern,
5215 __kmp_stg_print_barrier_pattern, NULL, 0, 0},
5216 {
"KMP_FORKJOIN_BARRIER", __kmp_stg_parse_barrier_branch_bit,
5217 __kmp_stg_print_barrier_branch_bit, NULL, 0, 0},
5218 {
"KMP_FORKJOIN_BARRIER_PATTERN", __kmp_stg_parse_barrier_pattern,
5219 __kmp_stg_print_barrier_pattern, NULL, 0, 0},
5220 #if KMP_FAST_REDUCTION_BARRIER
5221 {
"KMP_REDUCTION_BARRIER", __kmp_stg_parse_barrier_branch_bit,
5222 __kmp_stg_print_barrier_branch_bit, NULL, 0, 0},
5223 {
"KMP_REDUCTION_BARRIER_PATTERN", __kmp_stg_parse_barrier_pattern,
5224 __kmp_stg_print_barrier_pattern, NULL, 0, 0},
5227 {
"KMP_ABORT_DELAY", __kmp_stg_parse_abort_delay,
5228 __kmp_stg_print_abort_delay, NULL, 0, 0},
5229 {
"KMP_CPUINFO_FILE", __kmp_stg_parse_cpuinfo_file,
5230 __kmp_stg_print_cpuinfo_file, NULL, 0, 0},
5231 {
"KMP_FORCE_REDUCTION", __kmp_stg_parse_force_reduction,
5232 __kmp_stg_print_force_reduction, NULL, 0, 0},
5233 {
"KMP_DETERMINISTIC_REDUCTION", __kmp_stg_parse_force_reduction,
5234 __kmp_stg_print_force_reduction, NULL, 0, 0},
5235 {
"KMP_STORAGE_MAP", __kmp_stg_parse_storage_map,
5236 __kmp_stg_print_storage_map, NULL, 0, 0},
5237 {
"KMP_ALL_THREADPRIVATE", __kmp_stg_parse_all_threadprivate,
5238 __kmp_stg_print_all_threadprivate, NULL, 0, 0},
5239 {
"KMP_FOREIGN_THREADS_THREADPRIVATE",
5240 __kmp_stg_parse_foreign_threads_threadprivate,
5241 __kmp_stg_print_foreign_threads_threadprivate, NULL, 0, 0},
5243 #if KMP_AFFINITY_SUPPORTED
5244 {
"KMP_AFFINITY", __kmp_stg_parse_affinity, __kmp_stg_print_affinity, NULL,
5246 #ifdef KMP_GOMP_COMPAT
5247 {
"GOMP_CPU_AFFINITY", __kmp_stg_parse_gomp_cpu_affinity, NULL,
5250 {
"OMP_PROC_BIND", __kmp_stg_parse_proc_bind, __kmp_stg_print_proc_bind,
5252 {
"OMP_PLACES", __kmp_stg_parse_places, __kmp_stg_print_places, NULL, 0, 0},
5253 {
"KMP_TOPOLOGY_METHOD", __kmp_stg_parse_topology_method,
5254 __kmp_stg_print_topology_method, NULL, 0, 0},
5260 {
"OMP_PROC_BIND", __kmp_stg_parse_proc_bind, __kmp_stg_print_proc_bind,
5264 {
"OMP_DISPLAY_AFFINITY", __kmp_stg_parse_display_affinity,
5265 __kmp_stg_print_display_affinity, NULL, 0, 0},
5266 {
"OMP_AFFINITY_FORMAT", __kmp_stg_parse_affinity_format,
5267 __kmp_stg_print_affinity_format, NULL, 0, 0},
5268 {
"KMP_INIT_AT_FORK", __kmp_stg_parse_init_at_fork,
5269 __kmp_stg_print_init_at_fork, NULL, 0, 0},
5270 {
"KMP_SCHEDULE", __kmp_stg_parse_schedule, __kmp_stg_print_schedule, NULL,
5272 {
"OMP_SCHEDULE", __kmp_stg_parse_omp_schedule, __kmp_stg_print_omp_schedule,
5274 #if KMP_USE_HIER_SCHED
5275 {
"KMP_DISP_HAND_THREAD", __kmp_stg_parse_kmp_hand_thread,
5276 __kmp_stg_print_kmp_hand_thread, NULL, 0, 0},
5278 {
"KMP_FORCE_MONOTONIC_DYNAMIC_SCHEDULE",
5279 __kmp_stg_parse_kmp_force_monotonic, __kmp_stg_print_kmp_force_monotonic,
5281 {
"KMP_ATOMIC_MODE", __kmp_stg_parse_atomic_mode,
5282 __kmp_stg_print_atomic_mode, NULL, 0, 0},
5283 {
"KMP_CONSISTENCY_CHECK", __kmp_stg_parse_consistency_check,
5284 __kmp_stg_print_consistency_check, NULL, 0, 0},
5286 #if USE_ITT_BUILD && USE_ITT_NOTIFY
5287 {
"KMP_ITT_PREPARE_DELAY", __kmp_stg_parse_itt_prepare_delay,
5288 __kmp_stg_print_itt_prepare_delay, NULL, 0, 0},
5290 {
"KMP_MALLOC_POOL_INCR", __kmp_stg_parse_malloc_pool_incr,
5291 __kmp_stg_print_malloc_pool_incr, NULL, 0, 0},
5292 {
"KMP_GTID_MODE", __kmp_stg_parse_gtid_mode, __kmp_stg_print_gtid_mode,
5294 {
"OMP_DYNAMIC", __kmp_stg_parse_omp_dynamic, __kmp_stg_print_omp_dynamic,
5296 {
"KMP_DYNAMIC_MODE", __kmp_stg_parse_kmp_dynamic_mode,
5297 __kmp_stg_print_kmp_dynamic_mode, NULL, 0, 0},
5299 #ifdef USE_LOAD_BALANCE
5300 {
"KMP_LOAD_BALANCE_INTERVAL", __kmp_stg_parse_ld_balance_interval,
5301 __kmp_stg_print_ld_balance_interval, NULL, 0, 0},
5304 {
"KMP_NUM_LOCKS_IN_BLOCK", __kmp_stg_parse_lock_block,
5305 __kmp_stg_print_lock_block, NULL, 0, 0},
5306 {
"KMP_LOCK_KIND", __kmp_stg_parse_lock_kind, __kmp_stg_print_lock_kind,
5308 {
"KMP_SPIN_BACKOFF_PARAMS", __kmp_stg_parse_spin_backoff_params,
5309 __kmp_stg_print_spin_backoff_params, NULL, 0, 0},
5310 #if KMP_USE_ADAPTIVE_LOCKS
5311 {
"KMP_ADAPTIVE_LOCK_PROPS", __kmp_stg_parse_adaptive_lock_props,
5312 __kmp_stg_print_adaptive_lock_props, NULL, 0, 0},
5313 #if KMP_DEBUG_ADAPTIVE_LOCKS
5314 {
"KMP_SPECULATIVE_STATSFILE", __kmp_stg_parse_speculative_statsfile,
5315 __kmp_stg_print_speculative_statsfile, NULL, 0, 0},
5318 {
"KMP_PLACE_THREADS", __kmp_stg_parse_hw_subset, __kmp_stg_print_hw_subset,
5320 {
"KMP_HW_SUBSET", __kmp_stg_parse_hw_subset, __kmp_stg_print_hw_subset,
5323 {
"KMP_FORKJOIN_FRAMES", __kmp_stg_parse_forkjoin_frames,
5324 __kmp_stg_print_forkjoin_frames, NULL, 0, 0},
5325 {
"KMP_FORKJOIN_FRAMES_MODE", __kmp_stg_parse_forkjoin_frames_mode,
5326 __kmp_stg_print_forkjoin_frames_mode, NULL, 0, 0},
5328 {
"KMP_ENABLE_TASK_THROTTLING", __kmp_stg_parse_task_throttling,
5329 __kmp_stg_print_task_throttling, NULL, 0, 0},
5331 {
"OMP_DISPLAY_ENV", __kmp_stg_parse_omp_display_env,
5332 __kmp_stg_print_omp_display_env, NULL, 0, 0},
5333 {
"OMP_CANCELLATION", __kmp_stg_parse_omp_cancellation,
5334 __kmp_stg_print_omp_cancellation, NULL, 0, 0},
5335 {
"OMP_ALLOCATOR", __kmp_stg_parse_allocator, __kmp_stg_print_allocator,
5337 {
"LIBOMP_USE_HIDDEN_HELPER_TASK", __kmp_stg_parse_use_hidden_helper,
5338 __kmp_stg_print_use_hidden_helper, NULL, 0, 0},
5339 {
"LIBOMP_NUM_HIDDEN_HELPER_THREADS",
5340 __kmp_stg_parse_num_hidden_helper_threads,
5341 __kmp_stg_print_num_hidden_helper_threads, NULL, 0, 0},
5344 {
"OMP_TOOL", __kmp_stg_parse_omp_tool, __kmp_stg_print_omp_tool, NULL, 0,
5346 {
"OMP_TOOL_LIBRARIES", __kmp_stg_parse_omp_tool_libraries,
5347 __kmp_stg_print_omp_tool_libraries, NULL, 0, 0},
5348 {
"OMP_TOOL_VERBOSE_INIT", __kmp_stg_parse_omp_tool_verbose_init,
5349 __kmp_stg_print_omp_tool_verbose_init, NULL, 0, 0},
5352 #if KMP_HAVE_MWAIT || KMP_HAVE_UMWAIT
5353 {
"KMP_USER_LEVEL_MWAIT", __kmp_stg_parse_user_level_mwait,
5354 __kmp_stg_print_user_level_mwait, NULL, 0, 0},
5355 {
"KMP_MWAIT_HINTS", __kmp_stg_parse_mwait_hints,
5356 __kmp_stg_print_mwait_hints, NULL, 0, 0},
5358 {
"", NULL, NULL, NULL, 0, 0}};
5360 static int const __kmp_stg_count =
5361 sizeof(__kmp_stg_table) /
sizeof(kmp_setting_t);
5363 static inline kmp_setting_t *__kmp_stg_find(
char const *name) {
5367 for (i = 0; i < __kmp_stg_count; ++i) {
5368 if (strcmp(__kmp_stg_table[i].name, name) == 0) {
5369 return &__kmp_stg_table[i];
5377 static int __kmp_stg_cmp(
void const *_a,
void const *_b) {
5378 const kmp_setting_t *a = RCAST(
const kmp_setting_t *, _a);
5379 const kmp_setting_t *b = RCAST(
const kmp_setting_t *, _b);
5383 if (strcmp(a->name,
"KMP_AFFINITY") == 0) {
5384 if (strcmp(b->name,
"KMP_AFFINITY") == 0) {
5388 }
else if (strcmp(b->name,
"KMP_AFFINITY") == 0) {
5391 return strcmp(a->name, b->name);
5394 static void __kmp_stg_init(
void) {
5396 static int initialized = 0;
5401 qsort(__kmp_stg_table, __kmp_stg_count - 1,
sizeof(kmp_setting_t),
5405 kmp_setting_t *kmp_stacksize =
5406 __kmp_stg_find(
"KMP_STACKSIZE");
5407 #ifdef KMP_GOMP_COMPAT
5408 kmp_setting_t *gomp_stacksize =
5409 __kmp_stg_find(
"GOMP_STACKSIZE");
5411 kmp_setting_t *omp_stacksize =
5412 __kmp_stg_find(
"OMP_STACKSIZE");
5418 static kmp_setting_t *
volatile rivals[4];
5419 static kmp_stg_ss_data_t kmp_data = {1, CCAST(kmp_setting_t **, rivals)};
5420 #ifdef KMP_GOMP_COMPAT
5421 static kmp_stg_ss_data_t gomp_data = {1024,
5422 CCAST(kmp_setting_t **, rivals)};
5424 static kmp_stg_ss_data_t omp_data = {1024,
5425 CCAST(kmp_setting_t **, rivals)};
5428 rivals[i++] = kmp_stacksize;
5429 #ifdef KMP_GOMP_COMPAT
5430 if (gomp_stacksize != NULL) {
5431 rivals[i++] = gomp_stacksize;
5434 rivals[i++] = omp_stacksize;
5437 kmp_stacksize->data = &kmp_data;
5438 #ifdef KMP_GOMP_COMPAT
5439 if (gomp_stacksize != NULL) {
5440 gomp_stacksize->data = &gomp_data;
5443 omp_stacksize->data = &omp_data;
5447 kmp_setting_t *kmp_library =
5448 __kmp_stg_find(
"KMP_LIBRARY");
5449 kmp_setting_t *omp_wait_policy =
5450 __kmp_stg_find(
"OMP_WAIT_POLICY");
5453 static kmp_setting_t *
volatile rivals[3];
5454 static kmp_stg_wp_data_t kmp_data = {0, CCAST(kmp_setting_t **, rivals)};
5455 static kmp_stg_wp_data_t omp_data = {1, CCAST(kmp_setting_t **, rivals)};
5458 rivals[i++] = kmp_library;
5459 if (omp_wait_policy != NULL) {
5460 rivals[i++] = omp_wait_policy;
5464 kmp_library->data = &kmp_data;
5465 if (omp_wait_policy != NULL) {
5466 omp_wait_policy->data = &omp_data;
5471 kmp_setting_t *kmp_device_thread_limit =
5472 __kmp_stg_find(
"KMP_DEVICE_THREAD_LIMIT");
5473 kmp_setting_t *kmp_all_threads =
5474 __kmp_stg_find(
"KMP_ALL_THREADS");
5477 static kmp_setting_t *
volatile rivals[3];
5480 rivals[i++] = kmp_device_thread_limit;
5481 rivals[i++] = kmp_all_threads;
5484 kmp_device_thread_limit->data = CCAST(kmp_setting_t **, rivals);
5485 kmp_all_threads->data = CCAST(kmp_setting_t **, rivals);
5490 kmp_setting_t *kmp_hw_subset = __kmp_stg_find(
"KMP_HW_SUBSET");
5492 kmp_setting_t *kmp_place_threads = __kmp_stg_find(
"KMP_PLACE_THREADS");
5495 static kmp_setting_t *
volatile rivals[3];
5498 rivals[i++] = kmp_hw_subset;
5499 rivals[i++] = kmp_place_threads;
5502 kmp_hw_subset->data = CCAST(kmp_setting_t **, rivals);
5503 kmp_place_threads->data = CCAST(kmp_setting_t **, rivals);
5506 #if KMP_AFFINITY_SUPPORTED
5508 kmp_setting_t *kmp_affinity =
5509 __kmp_stg_find(
"KMP_AFFINITY");
5510 KMP_DEBUG_ASSERT(kmp_affinity != NULL);
5512 #ifdef KMP_GOMP_COMPAT
5513 kmp_setting_t *gomp_cpu_affinity =
5514 __kmp_stg_find(
"GOMP_CPU_AFFINITY");
5515 KMP_DEBUG_ASSERT(gomp_cpu_affinity != NULL);
5518 kmp_setting_t *omp_proc_bind =
5519 __kmp_stg_find(
"OMP_PROC_BIND");
5520 KMP_DEBUG_ASSERT(omp_proc_bind != NULL);
5523 static kmp_setting_t *
volatile rivals[4];
5526 rivals[i++] = kmp_affinity;
5528 #ifdef KMP_GOMP_COMPAT
5529 rivals[i++] = gomp_cpu_affinity;
5530 gomp_cpu_affinity->data = CCAST(kmp_setting_t **, rivals);
5533 rivals[i++] = omp_proc_bind;
5534 omp_proc_bind->data = CCAST(kmp_setting_t **, rivals);
5537 static kmp_setting_t *
volatile places_rivals[4];
5540 kmp_setting_t *omp_places = __kmp_stg_find(
"OMP_PLACES");
5541 KMP_DEBUG_ASSERT(omp_places != NULL);
5543 places_rivals[i++] = kmp_affinity;
5544 #ifdef KMP_GOMP_COMPAT
5545 places_rivals[i++] = gomp_cpu_affinity;
5547 places_rivals[i++] = omp_places;
5548 omp_places->data = CCAST(kmp_setting_t **, places_rivals);
5549 places_rivals[i++] = NULL;
5557 kmp_setting_t *kmp_force_red =
5558 __kmp_stg_find(
"KMP_FORCE_REDUCTION");
5559 kmp_setting_t *kmp_determ_red =
5560 __kmp_stg_find(
"KMP_DETERMINISTIC_REDUCTION");
5563 static kmp_setting_t *
volatile rivals[3];
5564 static kmp_stg_fr_data_t force_data = {1,
5565 CCAST(kmp_setting_t **, rivals)};
5566 static kmp_stg_fr_data_t determ_data = {0,
5567 CCAST(kmp_setting_t **, rivals)};
5570 rivals[i++] = kmp_force_red;
5571 if (kmp_determ_red != NULL) {
5572 rivals[i++] = kmp_determ_red;
5576 kmp_force_red->data = &force_data;
5577 if (kmp_determ_red != NULL) {
5578 kmp_determ_red->data = &determ_data;
5587 for (i = 0; i < __kmp_stg_count; ++i) {
5588 __kmp_stg_table[i].set = 0;
5593 static void __kmp_stg_parse(
char const *name,
char const *value) {
5601 if (value != NULL) {
5602 kmp_setting_t *setting = __kmp_stg_find(name);
5603 if (setting != NULL) {
5604 setting->parse(name, value, setting->data);
5605 setting->defined = 1;
5611 static int __kmp_stg_check_rivals(
5614 kmp_setting_t **rivals
5617 if (rivals == NULL) {
5623 for (; strcmp(rivals[i]->name, name) != 0; i++) {
5624 KMP_DEBUG_ASSERT(rivals[i] != NULL);
5626 #if KMP_AFFINITY_SUPPORTED
5627 if (rivals[i] == __kmp_affinity_notype) {
5634 if (rivals[i]->set) {
5635 KMP_WARNING(StgIgnored, name, rivals[i]->name);
5645 static int __kmp_env_toPrint(
char const *name,
int flag) {
5647 kmp_setting_t *setting = __kmp_stg_find(name);
5648 if (setting != NULL) {
5649 rc = setting->defined;
5651 setting->defined = flag;
5657 static void __kmp_aux_env_initialize(kmp_env_blk_t *block) {
5662 value = __kmp_env_blk_var(block,
"OMP_NUM_THREADS");
5664 ompc_set_num_threads(__kmp_dflt_team_nth);
5668 value = __kmp_env_blk_var(block,
"KMP_BLOCKTIME");
5670 kmpc_set_blocktime(__kmp_dflt_blocktime);
5674 value = __kmp_env_blk_var(block,
"OMP_NESTED");
5676 ompc_set_nested(__kmp_dflt_max_active_levels > 1);
5680 value = __kmp_env_blk_var(block,
"OMP_DYNAMIC");
5682 ompc_set_dynamic(__kmp_global.g.g_dynamic);
5686 void __kmp_env_initialize(
char const *
string) {
5688 kmp_env_blk_t block;
5694 if (
string == NULL) {
5696 __kmp_threads_capacity =
5697 __kmp_initial_threads_capacity(__kmp_dflt_team_nth_ub);
5699 __kmp_env_blk_init(&block,
string);
5702 for (i = 0; i < block.count; ++i) {
5703 if ((block.vars[i].name == NULL) || (*block.vars[i].name ==
'\0')) {
5706 if (block.vars[i].value == NULL) {
5709 kmp_setting_t *setting = __kmp_stg_find(block.vars[i].name);
5710 if (setting != NULL) {
5716 blocktime_str = __kmp_env_blk_var(&block,
"KMP_BLOCKTIME");
5720 if (
string == NULL) {
5721 char const *name =
"KMP_WARNINGS";
5722 char const *value = __kmp_env_blk_var(&block, name);
5723 __kmp_stg_parse(name, value);
5726 #if KMP_AFFINITY_SUPPORTED
5732 __kmp_affinity_notype = NULL;
5733 char const *aff_str = __kmp_env_blk_var(&block,
"KMP_AFFINITY");
5734 if (aff_str != NULL) {
5748 #define FIND strcasestr
5751 if ((FIND(aff_str,
"none") == NULL) &&
5752 (FIND(aff_str,
"physical") == NULL) &&
5753 (FIND(aff_str,
"logical") == NULL) &&
5754 (FIND(aff_str,
"compact") == NULL) &&
5755 (FIND(aff_str,
"scatter") == NULL) &&
5756 (FIND(aff_str,
"explicit") == NULL) &&
5757 (FIND(aff_str,
"balanced") == NULL) &&
5758 (FIND(aff_str,
"disabled") == NULL)) {
5759 __kmp_affinity_notype = __kmp_stg_find(
"KMP_AFFINITY");
5764 __kmp_affinity_type = affinity_default;
5765 __kmp_affinity_gran = affinity_gran_default;
5766 __kmp_affinity_top_method = affinity_top_method_default;
5767 __kmp_affinity_respect_mask = affinity_respect_mask_default;
5772 aff_str = __kmp_env_blk_var(&block,
"OMP_PROC_BIND");
5773 if (aff_str != NULL) {
5774 __kmp_affinity_type = affinity_default;
5775 __kmp_affinity_gran = affinity_gran_default;
5776 __kmp_affinity_top_method = affinity_top_method_default;
5777 __kmp_affinity_respect_mask = affinity_respect_mask_default;
5784 if (__kmp_nested_proc_bind.bind_types == NULL) {
5785 __kmp_nested_proc_bind.bind_types =
5786 (kmp_proc_bind_t *)KMP_INTERNAL_MALLOC(
sizeof(kmp_proc_bind_t));
5787 if (__kmp_nested_proc_bind.bind_types == NULL) {
5788 KMP_FATAL(MemoryAllocFailed);
5790 __kmp_nested_proc_bind.size = 1;
5791 __kmp_nested_proc_bind.used = 1;
5792 #if KMP_AFFINITY_SUPPORTED
5793 __kmp_nested_proc_bind.bind_types[0] = proc_bind_default;
5796 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
5803 __kmp_msg_format(kmp_i18n_msg_AffFormatDefault,
"%P",
"%i",
"%n",
"%A");
5804 KMP_DEBUG_ASSERT(KMP_STRLEN(m.str) < KMP_AFFINITY_FORMAT_SIZE);
5806 if (__kmp_affinity_format == NULL) {
5807 __kmp_affinity_format =
5808 (
char *)KMP_INTERNAL_MALLOC(
sizeof(
char) * KMP_AFFINITY_FORMAT_SIZE);
5810 KMP_STRCPY_S(__kmp_affinity_format, KMP_AFFINITY_FORMAT_SIZE, m.str);
5811 __kmp_str_free(&m.str);
5814 for (i = 0; i < block.count; ++i) {
5815 __kmp_stg_parse(block.vars[i].name, block.vars[i].value);
5819 if (!__kmp_init_user_locks) {
5820 if (__kmp_user_lock_kind == lk_default) {
5821 __kmp_user_lock_kind = lk_queuing;
5823 #if KMP_USE_DYNAMIC_LOCK
5824 __kmp_init_dynamic_user_locks();
5826 __kmp_set_user_lock_vptrs(__kmp_user_lock_kind);
5829 KMP_DEBUG_ASSERT(
string != NULL);
5830 KMP_DEBUG_ASSERT(__kmp_user_lock_kind != lk_default);
5835 #if KMP_USE_DYNAMIC_LOCK
5836 __kmp_init_dynamic_user_locks();
5838 __kmp_set_user_lock_vptrs(__kmp_user_lock_kind);
5842 #if KMP_AFFINITY_SUPPORTED
5844 if (!TCR_4(__kmp_init_middle)) {
5848 if ((__kmp_hws_node.num > 0 || __kmp_hws_tile.num > 0 ||
5849 __kmp_affinity_gran == affinity_gran_tile) &&
5850 (__kmp_affinity_top_method == affinity_top_method_default)) {
5851 __kmp_affinity_top_method = affinity_top_method_hwloc;
5856 const char *var =
"KMP_AFFINITY";
5857 KMPAffinity::pick_api();
5862 if (__kmp_affinity_top_method == affinity_top_method_hwloc &&
5863 __kmp_affinity_dispatch->get_api_type() != KMPAffinity::HWLOC) {
5864 KMP_WARNING(AffIgnoringHwloc, var);
5865 __kmp_affinity_top_method = affinity_top_method_all;
5868 if (__kmp_affinity_type == affinity_disabled) {
5869 KMP_AFFINITY_DISABLE();
5870 }
else if (!KMP_AFFINITY_CAPABLE()) {
5871 __kmp_affinity_dispatch->determine_capable(var);
5872 if (!KMP_AFFINITY_CAPABLE()) {
5873 if (__kmp_affinity_verbose ||
5874 (__kmp_affinity_warnings &&
5875 (__kmp_affinity_type != affinity_default) &&
5876 (__kmp_affinity_type != affinity_none) &&
5877 (__kmp_affinity_type != affinity_disabled))) {
5878 KMP_WARNING(AffNotSupported, var);
5880 __kmp_affinity_type = affinity_disabled;
5881 __kmp_affinity_respect_mask = 0;
5882 __kmp_affinity_gran = affinity_gran_fine;
5886 if (__kmp_affinity_type == affinity_disabled) {
5887 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
5888 }
else if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_true) {
5890 __kmp_nested_proc_bind.bind_types[0] = proc_bind_spread;
5893 if (KMP_AFFINITY_CAPABLE()) {
5895 #if KMP_GROUP_AFFINITY
5900 bool exactly_one_group =
false;
5901 if (__kmp_num_proc_groups > 1) {
5903 bool within_one_group;
5906 kmp_affin_mask_t *init_mask;
5907 KMP_CPU_ALLOC(init_mask);
5908 __kmp_get_system_affinity(init_mask, TRUE);
5909 group = __kmp_get_proc_group(init_mask);
5910 within_one_group = (group >= 0);
5913 if (within_one_group) {
5914 DWORD num_bits_in_group = __kmp_GetActiveProcessorCount(group);
5915 DWORD num_bits_in_mask = 0;
5916 for (
int bit = init_mask->begin(); bit != init_mask->end();
5917 bit = init_mask->next(bit))
5919 exactly_one_group = (num_bits_in_group == num_bits_in_mask);
5921 KMP_CPU_FREE(init_mask);
5927 if (((__kmp_num_proc_groups > 1) &&
5928 (__kmp_affinity_type == affinity_default) &&
5929 (__kmp_nested_proc_bind.bind_types[0] == proc_bind_default)) ||
5930 (__kmp_affinity_top_method == affinity_top_method_group)) {
5931 if (__kmp_affinity_respect_mask == affinity_respect_mask_default &&
5932 exactly_one_group) {
5933 __kmp_affinity_respect_mask = FALSE;
5935 if (__kmp_affinity_type == affinity_default) {
5936 __kmp_affinity_type = affinity_compact;
5937 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
5939 if (__kmp_affinity_top_method == affinity_top_method_default) {
5940 if (__kmp_affinity_gran == affinity_gran_default) {
5941 __kmp_affinity_top_method = affinity_top_method_group;
5942 __kmp_affinity_gran = affinity_gran_group;
5943 }
else if (__kmp_affinity_gran == affinity_gran_group) {
5944 __kmp_affinity_top_method = affinity_top_method_group;
5946 __kmp_affinity_top_method = affinity_top_method_all;
5948 }
else if (__kmp_affinity_top_method == affinity_top_method_group) {
5949 if (__kmp_affinity_gran == affinity_gran_default) {
5950 __kmp_affinity_gran = affinity_gran_group;
5951 }
else if ((__kmp_affinity_gran != affinity_gran_group) &&
5952 (__kmp_affinity_gran != affinity_gran_fine) &&
5953 (__kmp_affinity_gran != affinity_gran_thread)) {
5954 const char *str = NULL;
5955 switch (__kmp_affinity_gran) {
5956 case affinity_gran_core:
5959 case affinity_gran_package:
5962 case affinity_gran_node:
5965 case affinity_gran_tile:
5969 KMP_DEBUG_ASSERT(0);
5971 KMP_WARNING(AffGranTopGroup, var, str);
5972 __kmp_affinity_gran = affinity_gran_fine;
5975 if (__kmp_affinity_gran == affinity_gran_default) {
5976 __kmp_affinity_gran = affinity_gran_core;
5977 }
else if (__kmp_affinity_gran == affinity_gran_group) {
5978 const char *str = NULL;
5979 switch (__kmp_affinity_type) {
5980 case affinity_physical:
5983 case affinity_logical:
5986 case affinity_compact:
5989 case affinity_scatter:
5992 case affinity_explicit:
5997 KMP_DEBUG_ASSERT(0);
5999 KMP_WARNING(AffGranGroupType, var, str);
6000 __kmp_affinity_gran = affinity_gran_core;
6008 if (__kmp_affinity_respect_mask == affinity_respect_mask_default) {
6009 #if KMP_GROUP_AFFINITY
6010 if (__kmp_num_proc_groups > 1 && exactly_one_group) {
6011 __kmp_affinity_respect_mask = FALSE;
6015 __kmp_affinity_respect_mask = TRUE;
6018 if ((__kmp_nested_proc_bind.bind_types[0] != proc_bind_intel) &&
6019 (__kmp_nested_proc_bind.bind_types[0] != proc_bind_default)) {
6020 if (__kmp_affinity_type == affinity_default) {
6021 __kmp_affinity_type = affinity_compact;
6022 __kmp_affinity_dups = FALSE;
6024 }
else if (__kmp_affinity_type == affinity_default) {
6025 #if KMP_MIC_SUPPORTED
6026 if (__kmp_mic_type != non_mic) {
6027 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
6031 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
6033 #if KMP_MIC_SUPPORTED
6034 if (__kmp_mic_type != non_mic) {
6035 __kmp_affinity_type = affinity_scatter;
6039 __kmp_affinity_type = affinity_none;
6042 if ((__kmp_affinity_gran == affinity_gran_default) &&
6043 (__kmp_affinity_gran_levels < 0)) {
6044 #if KMP_MIC_SUPPORTED
6045 if (__kmp_mic_type != non_mic) {
6046 __kmp_affinity_gran = affinity_gran_fine;
6050 __kmp_affinity_gran = affinity_gran_core;
6053 if (__kmp_affinity_top_method == affinity_top_method_default) {
6054 __kmp_affinity_top_method = affinity_top_method_all;
6059 K_DIAG(1, (
"__kmp_affinity_type == %d\n", __kmp_affinity_type));
6060 K_DIAG(1, (
"__kmp_affinity_compact == %d\n", __kmp_affinity_compact));
6061 K_DIAG(1, (
"__kmp_affinity_offset == %d\n", __kmp_affinity_offset));
6062 K_DIAG(1, (
"__kmp_affinity_verbose == %d\n", __kmp_affinity_verbose));
6063 K_DIAG(1, (
"__kmp_affinity_warnings == %d\n", __kmp_affinity_warnings));
6064 K_DIAG(1, (
"__kmp_affinity_respect_mask == %d\n",
6065 __kmp_affinity_respect_mask));
6066 K_DIAG(1, (
"__kmp_affinity_gran == %d\n", __kmp_affinity_gran));
6068 KMP_DEBUG_ASSERT(__kmp_affinity_type != affinity_default);
6069 KMP_DEBUG_ASSERT(__kmp_nested_proc_bind.bind_types[0] != proc_bind_default);
6070 K_DIAG(1, (
"__kmp_nested_proc_bind.bind_types[0] == %d\n",
6071 __kmp_nested_proc_bind.bind_types[0]));
6076 if (__kmp_version) {
6077 __kmp_print_version_1();
6082 if (
string != NULL) {
6083 __kmp_aux_env_initialize(&block);
6086 __kmp_env_blk_free(&block);
6092 void __kmp_env_print() {
6094 kmp_env_blk_t block;
6096 kmp_str_buf_t buffer;
6099 __kmp_str_buf_init(&buffer);
6101 __kmp_env_blk_init(&block, NULL);
6102 __kmp_env_blk_sort(&block);
6105 __kmp_str_buf_print(&buffer,
"\n%s\n\n", KMP_I18N_STR(UserSettings));
6106 for (i = 0; i < block.count; ++i) {
6107 char const *name = block.vars[i].name;
6108 char const *value = block.vars[i].value;
6109 if ((KMP_STRLEN(name) > 4 && strncmp(name,
"KMP_", 4) == 0) ||
6110 strncmp(name,
"OMP_", 4) == 0
6111 #ifdef KMP_GOMP_COMPAT
6112 || strncmp(name,
"GOMP_", 5) == 0
6115 __kmp_str_buf_print(&buffer,
" %s=%s\n", name, value);
6118 __kmp_str_buf_print(&buffer,
"\n");
6121 __kmp_str_buf_print(&buffer,
"%s\n\n", KMP_I18N_STR(EffectiveSettings));
6122 for (
int i = 0; i < __kmp_stg_count; ++i) {
6123 if (__kmp_stg_table[i].print != NULL) {
6124 __kmp_stg_table[i].print(&buffer, __kmp_stg_table[i].name,
6125 __kmp_stg_table[i].data);
6129 __kmp_printf(
"%s", buffer.str);
6131 __kmp_env_blk_free(&block);
6132 __kmp_str_buf_free(&buffer);
6138 void __kmp_env_print_2() {
6139 __kmp_display_env_impl(__kmp_display_env, __kmp_display_env_verbose);
6142 void __kmp_display_env_impl(
int display_env,
int display_env_verbose) {
6143 kmp_env_blk_t block;
6144 kmp_str_buf_t buffer;
6146 __kmp_env_format = 1;
6149 __kmp_str_buf_init(&buffer);
6151 __kmp_env_blk_init(&block, NULL);
6152 __kmp_env_blk_sort(&block);
6154 __kmp_str_buf_print(&buffer,
"\n%s\n", KMP_I18N_STR(DisplayEnvBegin));
6155 __kmp_str_buf_print(&buffer,
" _OPENMP='%d'\n", __kmp_openmp_version);
6157 for (
int i = 0; i < __kmp_stg_count; ++i) {
6158 if (__kmp_stg_table[i].print != NULL &&
6159 ((display_env && strncmp(__kmp_stg_table[i].name,
"OMP_", 4) == 0) ||
6160 display_env_verbose)) {
6161 __kmp_stg_table[i].print(&buffer, __kmp_stg_table[i].name,
6162 __kmp_stg_table[i].data);
6166 __kmp_str_buf_print(&buffer,
"%s\n", KMP_I18N_STR(DisplayEnvEnd));
6167 __kmp_str_buf_print(&buffer,
"\n");
6169 __kmp_printf(
"%s", buffer.str);
6171 __kmp_env_blk_free(&block);
6172 __kmp_str_buf_free(&buffer);
@ kmp_sch_modifier_monotonic
@ kmp_sch_modifier_nonmonotonic