14#include "kmp_affinity.h"
15#include "kmp_atomic.h"
17#include "kmp_dispatch_hier.h"
19#include "kmp_environment.h"
24#include "kmp_settings.h"
26#include "kmp_wrapper_getpid.h"
29#include "ompd-specific.h"
32static int __kmp_env_toPrint(
char const *name,
int flag);
34bool __kmp_env_format = 0;
39#ifdef USE_LOAD_BALANCE
40static double __kmp_convert_to_double(
char const *s) {
43 if (KMP_SSCANF(s,
"%lf", &result) < 1) {
52static unsigned int __kmp_readstr_with_sentinel(
char *dest,
char const *src,
53 size_t len,
char sentinel) {
55 for (i = 0; i < len; i++) {
56 if ((*src ==
'\0') || (*src == sentinel)) {
66static int __kmp_match_with_sentinel(
char const *a,
char const *b,
size_t len,
74 while (*a && *b && *b != sentinel) {
75 char ca = *a, cb = *b;
77 if (ca >=
'a' && ca <=
'z')
79 if (cb >=
'a' && cb <=
'z')
113static int __kmp_match_str(
char const *token,
char const *buf,
116 KMP_ASSERT(token != NULL);
117 KMP_ASSERT(buf != NULL);
118 KMP_ASSERT(end != NULL);
120 while (*token && *buf) {
121 char ct = *token, cb = *buf;
123 if (ct >=
'a' && ct <=
'z')
125 if (cb >=
'a' && cb <=
'z')
140static size_t __kmp_round4k(
size_t size) {
141 size_t _4k = 4 * 1024;
142 if (size & (_4k - 1)) {
144 if (size <= KMP_SIZE_T_MAX - _4k) {
156int __kmp_convert_to_milliseconds(
char const *data) {
157 int ret, nvalues, factor;
163 if (__kmp_str_match(
"infinit", -1, data))
167#if KMP_OS_WINDOWS && KMP_MSVC_COMPAT
169 nvalues = KMP_SSCANF(data,
"%lf%c%c", &value, &mult, 1, &extra, 1);
171 nvalues = KMP_SSCANF(data,
"%lf%c%c", &value, &mult, &extra);
198 factor = 1000 * 60 * 60;
202 factor = 1000 * 24 * 60 * 60;
208 if (value >= ((INT_MAX - 1) / factor))
211 ret = (int)(value * (
double)factor);
216static int __kmp_strcasecmp_with_sentinel(
char const *a,
char const *b,
222 while (*a && *b && *b != sentinel) {
223 char ca = *a, cb = *b;
225 if (ca >=
'a' && ca <=
'z')
227 if (cb >=
'a' && cb <=
'z')
230 return (
int)(
unsigned char)*a - (
int)(
unsigned char)*b;
234 return *a ? (*b && *b != sentinel)
235 ? (
int)(
unsigned char)*a - (
int)(
unsigned char)*b
237 : (*b && *b != sentinel) ? -1
244typedef struct __kmp_setting kmp_setting_t;
245typedef struct __kmp_stg_ss_data kmp_stg_ss_data_t;
246typedef struct __kmp_stg_wp_data kmp_stg_wp_data_t;
247typedef struct __kmp_stg_fr_data kmp_stg_fr_data_t;
249typedef void (*kmp_stg_parse_func_t)(
char const *name,
char const *value,
251typedef void (*kmp_stg_print_func_t)(kmp_str_buf_t *buffer,
char const *name,
254struct __kmp_setting {
256 kmp_stg_parse_func_t parse;
257 kmp_stg_print_func_t print;
264struct __kmp_stg_ss_data {
266 kmp_setting_t **rivals;
269struct __kmp_stg_wp_data {
271 kmp_setting_t **rivals;
274struct __kmp_stg_fr_data {
276 kmp_setting_t **rivals;
279static int __kmp_stg_check_rivals(
282 kmp_setting_t **rivals
286struct kmp_trimmed_str_t {
288 kmp_trimmed_str_t(
const char *str) {
289 __kmp_str_buf_init(&buf);
290 size_t len = KMP_STRLEN(str);
293 const char *begin = str;
294 const char *end = str + KMP_STRLEN(str) - 1;
296 while (begin < end && *end ==
' ')
298 __kmp_str_buf_cat(&buf, begin, end - begin + 1);
300 ~kmp_trimmed_str_t() { __kmp_str_buf_free(&buf); }
301 const char *get() {
return buf.str; }
307static void __kmp_stg_parse_bool(
char const *name,
char const *value,
309 if (__kmp_str_match_true(value)) {
311 }
else if (__kmp_str_match_false(value)) {
314 __kmp_msg(kmp_ms_warning, KMP_MSG(BadBoolValue, name, value),
315 KMP_HNT(ValidBoolValues), __kmp_msg_null);
320void __kmp_check_stksize(
size_t *val) {
322 if (*val > KMP_DEFAULT_STKSIZE * 16)
323 *val = KMP_DEFAULT_STKSIZE * 16;
324 if (*val < __kmp_sys_min_stksize)
325 *val = __kmp_sys_min_stksize;
326 if (*val > KMP_MAX_STKSIZE)
327 *val = KMP_MAX_STKSIZE;
329 *val = __kmp_round4k(*val);
333static void __kmp_stg_parse_size(
char const *name,
char const *value,
334 size_t size_min,
size_t size_max,
335 int *is_specified,
size_t *out,
337 char const *msg = NULL;
339 size_min = __kmp_round4k(size_min);
340 size_max = __kmp_round4k(size_max);
343 if (is_specified != NULL) {
346 __kmp_str_to_size(value, out, factor, &msg);
348 if (*out > size_max) {
350 msg = KMP_I18N_STR(ValueTooLarge);
351 }
else if (*out < size_min) {
353 msg = KMP_I18N_STR(ValueTooSmall);
356 size_t round4k = __kmp_round4k(*out);
357 if (*out != round4k) {
359 msg = KMP_I18N_STR(NotMultiple4K);
366 if (*out < size_min) {
368 }
else if (*out > size_max) {
375 __kmp_str_buf_init(&buf);
376 __kmp_str_buf_print_size(&buf, *out);
377 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
378 KMP_INFORM(Using_str_Value, name, buf.str);
379 __kmp_str_buf_free(&buf);
384static void __kmp_stg_parse_str(
char const *name,
char const *value,
387 *out = __kmp_str_format(
"%s", value);
390static void __kmp_stg_parse_int(
398 char const *msg = NULL;
399 kmp_uint64 uint = *out;
400 __kmp_str_to_uint(value, &uint, &msg);
402 if (uint < (
unsigned int)min) {
403 msg = KMP_I18N_STR(ValueTooSmall);
405 }
else if (uint > (
unsigned int)max) {
406 msg = KMP_I18N_STR(ValueTooLarge);
412 if (uint < (
unsigned int)min) {
414 }
else if (uint > (
unsigned int)max) {
421 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
422 __kmp_str_buf_init(&buf);
423 __kmp_str_buf_print(&buf,
"%" KMP_UINT64_SPEC
"", uint);
424 KMP_INFORM(Using_uint64_Value, name, buf.str);
425 __kmp_str_buf_free(&buf);
427 __kmp_type_convert(uint, out);
430#if KMP_DEBUG_ADAPTIVE_LOCKS
431static void __kmp_stg_parse_file(
char const *name,
char const *value,
432 const char *suffix,
char **out) {
437 t = (
char *)strrchr(value,
'.');
438 hasSuffix = t && __kmp_str_eqf(t, suffix);
439 t = __kmp_str_format(
"%s%s", value, hasSuffix ?
"" : suffix);
440 __kmp_expand_file_name(buffer,
sizeof(buffer), t);
442 *out = __kmp_str_format(
"%s", buffer);
447static char *par_range_to_print = NULL;
449static void __kmp_stg_parse_par_range(
char const *name,
char const *value,
450 int *out_range,
char *out_routine,
451 char *out_file,
int *out_lb,
453 const char *par_range_value;
454 size_t len = KMP_STRLEN(value) + 1;
455 par_range_to_print = (
char *)KMP_INTERNAL_MALLOC(len + 1);
456 KMP_STRNCPY_S(par_range_to_print, len + 1, value, len + 1);
457 __kmp_par_range = +1;
458 __kmp_par_range_lb = 0;
459 __kmp_par_range_ub = INT_MAX;
462 if (!value || *value ==
'\0') {
465 if (!__kmp_strcasecmp_with_sentinel(
"routine", value,
'=')) {
466 par_range_value = strchr(value,
'=') + 1;
467 if (!par_range_value)
468 goto par_range_error;
469 value = par_range_value;
470 len = __kmp_readstr_with_sentinel(out_routine, value,
471 KMP_PAR_RANGE_ROUTINE_LEN - 1,
',');
473 goto par_range_error;
475 value = strchr(value,
',');
481 if (!__kmp_strcasecmp_with_sentinel(
"filename", value,
'=')) {
482 par_range_value = strchr(value,
'=') + 1;
483 if (!par_range_value)
484 goto par_range_error;
485 value = par_range_value;
486 len = __kmp_readstr_with_sentinel(out_file, value,
487 KMP_PAR_RANGE_FILENAME_LEN - 1,
',');
489 goto par_range_error;
491 value = strchr(value,
',');
497 if ((!__kmp_strcasecmp_with_sentinel(
"range", value,
'=')) ||
498 (!__kmp_strcasecmp_with_sentinel(
"incl_range", value,
'='))) {
499 par_range_value = strchr(value,
'=') + 1;
500 if (!par_range_value)
501 goto par_range_error;
502 value = par_range_value;
503 if (KMP_SSCANF(value,
"%d:%d", out_lb, out_ub) != 2) {
504 goto par_range_error;
507 value = strchr(value,
',');
513 if (!__kmp_strcasecmp_with_sentinel(
"excl_range", value,
'=')) {
514 par_range_value = strchr(value,
'=') + 1;
515 if (!par_range_value)
516 goto par_range_error;
517 value = par_range_value;
518 if (KMP_SSCANF(value,
"%d:%d", out_lb, out_ub) != 2) {
519 goto par_range_error;
522 value = strchr(value,
',');
529 KMP_WARNING(ParRangeSyntax, name);
536int __kmp_initial_threads_capacity(
int req_nproc) {
541 if (nth < (4 * req_nproc))
542 nth = (4 * req_nproc);
543 if (nth < (4 * __kmp_xproc))
544 nth = (4 * __kmp_xproc);
548 if (__kmp_enable_hidden_helper) {
549 nth += __kmp_hidden_helper_threads_num;
552 if (nth > __kmp_max_nth)
558int __kmp_default_tp_capacity(
int req_nproc,
int max_nth,
559 int all_threads_specified) {
562 if (all_threads_specified)
566 if (nth < (4 * req_nproc))
567 nth = (4 * req_nproc);
568 if (nth < (4 * __kmp_xproc))
569 nth = (4 * __kmp_xproc);
571 if (nth > __kmp_max_nth)
580static void __kmp_stg_print_bool(kmp_str_buf_t *buffer,
char const *name,
582 if (__kmp_env_format) {
583 KMP_STR_BUF_PRINT_BOOL;
585 __kmp_str_buf_print(buffer,
" %s=%s\n", name, value ?
"true" :
"false");
589static void __kmp_stg_print_int(kmp_str_buf_t *buffer,
char const *name,
591 if (__kmp_env_format) {
592 KMP_STR_BUF_PRINT_INT;
594 __kmp_str_buf_print(buffer,
" %s=%d\n", name, value);
598static void __kmp_stg_print_uint64(kmp_str_buf_t *buffer,
char const *name,
600 if (__kmp_env_format) {
601 KMP_STR_BUF_PRINT_UINT64;
603 __kmp_str_buf_print(buffer,
" %s=%" KMP_UINT64_SPEC
"\n", name, value);
607static void __kmp_stg_print_str(kmp_str_buf_t *buffer,
char const *name,
609 if (__kmp_env_format) {
610 KMP_STR_BUF_PRINT_STR;
612 __kmp_str_buf_print(buffer,
" %s=%s\n", name, value);
616static void __kmp_stg_print_size(kmp_str_buf_t *buffer,
char const *name,
618 if (__kmp_env_format) {
619 KMP_STR_BUF_PRINT_NAME_EX(name);
620 __kmp_str_buf_print_size(buffer, value);
621 __kmp_str_buf_print(buffer,
"'\n");
623 __kmp_str_buf_print(buffer,
" %s=", name);
624 __kmp_str_buf_print_size(buffer, value);
625 __kmp_str_buf_print(buffer,
"\n");
636static void __kmp_stg_parse_device_thread_limit(
char const *name,
637 char const *value,
void *data) {
638 kmp_setting_t **rivals = (kmp_setting_t **)data;
640 if (strcmp(name,
"KMP_ALL_THREADS") == 0) {
641 KMP_INFORM(EnvVarDeprecated, name,
"KMP_DEVICE_THREAD_LIMIT");
643 rc = __kmp_stg_check_rivals(name, value, rivals);
647 if (!__kmp_strcasecmp_with_sentinel(
"all", value, 0)) {
648 __kmp_max_nth = __kmp_xproc;
649 __kmp_allThreadsSpecified = 1;
651 __kmp_stg_parse_int(name, value, 1, __kmp_sys_max_nth, &__kmp_max_nth);
652 __kmp_allThreadsSpecified = 0;
654 K_DIAG(1, (
"__kmp_max_nth == %d\n", __kmp_max_nth));
658static void __kmp_stg_print_device_thread_limit(kmp_str_buf_t *buffer,
659 char const *name,
void *data) {
660 __kmp_stg_print_int(buffer, name, __kmp_max_nth);
665static void __kmp_stg_parse_thread_limit(
char const *name,
char const *value,
667 __kmp_stg_parse_int(name, value, 1, __kmp_sys_max_nth, &__kmp_cg_max_nth);
668 K_DIAG(1, (
"__kmp_cg_max_nth == %d\n", __kmp_cg_max_nth));
672static void __kmp_stg_print_thread_limit(kmp_str_buf_t *buffer,
673 char const *name,
void *data) {
674 __kmp_stg_print_int(buffer, name, __kmp_cg_max_nth);
679static void __kmp_stg_parse_nteams(
char const *name,
char const *value,
681 __kmp_stg_parse_int(name, value, 1, __kmp_sys_max_nth, &__kmp_nteams);
682 K_DIAG(1, (
"__kmp_nteams == %d\n", __kmp_nteams));
685static void __kmp_stg_print_nteams(kmp_str_buf_t *buffer,
char const *name,
687 __kmp_stg_print_int(buffer, name, __kmp_nteams);
692static void __kmp_stg_parse_teams_th_limit(
char const *name,
char const *value,
694 __kmp_stg_parse_int(name, value, 1, __kmp_sys_max_nth,
695 &__kmp_teams_thread_limit);
696 K_DIAG(1, (
"__kmp_teams_thread_limit == %d\n", __kmp_teams_thread_limit));
699static void __kmp_stg_print_teams_th_limit(kmp_str_buf_t *buffer,
700 char const *name,
void *data) {
701 __kmp_stg_print_int(buffer, name, __kmp_teams_thread_limit);
706static void __kmp_stg_parse_teams_thread_limit(
char const *name,
707 char const *value,
void *data) {
708 __kmp_stg_parse_int(name, value, 1, __kmp_sys_max_nth, &__kmp_teams_max_nth);
711static void __kmp_stg_print_teams_thread_limit(kmp_str_buf_t *buffer,
712 char const *name,
void *data) {
713 __kmp_stg_print_int(buffer, name, __kmp_teams_max_nth);
718static void __kmp_stg_parse_use_yield(
char const *name,
char const *value,
720 __kmp_stg_parse_int(name, value, 0, 2, &__kmp_use_yield);
721 __kmp_use_yield_exp_set = 1;
724static void __kmp_stg_print_use_yield(kmp_str_buf_t *buffer,
char const *name,
726 __kmp_stg_print_int(buffer, name, __kmp_use_yield);
732static void __kmp_stg_parse_blocktime(
char const *name,
char const *value,
734 __kmp_dflt_blocktime = __kmp_convert_to_milliseconds(value);
735 if (__kmp_dflt_blocktime < 0) {
736 __kmp_dflt_blocktime = KMP_DEFAULT_BLOCKTIME;
737 __kmp_msg(kmp_ms_warning, KMP_MSG(InvalidValue, name, value),
739 KMP_INFORM(Using_int_Value, name, __kmp_dflt_blocktime);
740 __kmp_env_blocktime = FALSE;
742 if (__kmp_dflt_blocktime < KMP_MIN_BLOCKTIME) {
743 __kmp_dflt_blocktime = KMP_MIN_BLOCKTIME;
744 __kmp_msg(kmp_ms_warning, KMP_MSG(SmallValue, name, value),
746 KMP_INFORM(MinValueUsing, name, __kmp_dflt_blocktime);
747 }
else if (__kmp_dflt_blocktime > KMP_MAX_BLOCKTIME) {
748 __kmp_dflt_blocktime = KMP_MAX_BLOCKTIME;
749 __kmp_msg(kmp_ms_warning, KMP_MSG(LargeValue, name, value),
751 KMP_INFORM(MaxValueUsing, name, __kmp_dflt_blocktime);
753 __kmp_env_blocktime = TRUE;
758 __kmp_monitor_wakeups =
759 KMP_WAKEUPS_FROM_BLOCKTIME(__kmp_dflt_blocktime, __kmp_monitor_wakeups);
761 KMP_INTERVALS_FROM_BLOCKTIME(__kmp_dflt_blocktime, __kmp_monitor_wakeups);
763 K_DIAG(1, (
"__kmp_env_blocktime == %d\n", __kmp_env_blocktime));
764 if (__kmp_env_blocktime) {
765 K_DIAG(1, (
"__kmp_dflt_blocktime == %d\n", __kmp_dflt_blocktime));
769static void __kmp_stg_print_blocktime(kmp_str_buf_t *buffer,
char const *name,
771 __kmp_stg_print_int(buffer, name, __kmp_dflt_blocktime);
777static void __kmp_stg_parse_duplicate_lib_ok(
char const *name,
778 char const *value,
void *data) {
781 __kmp_stg_parse_bool(name, value, &__kmp_duplicate_library_ok);
784static void __kmp_stg_print_duplicate_lib_ok(kmp_str_buf_t *buffer,
785 char const *name,
void *data) {
786 __kmp_stg_print_bool(buffer, name, __kmp_duplicate_library_ok);
792#if KMP_ARCH_X86 || KMP_ARCH_X86_64
794static void __kmp_stg_parse_inherit_fp_control(
char const *name,
795 char const *value,
void *data) {
796 __kmp_stg_parse_bool(name, value, &__kmp_inherit_fp_control);
799static void __kmp_stg_print_inherit_fp_control(kmp_str_buf_t *buffer,
800 char const *name,
void *data) {
802 __kmp_stg_print_bool(buffer, name, __kmp_inherit_fp_control);
809static char const *blocktime_str = NULL;
814static void __kmp_stg_parse_wait_policy(
char const *name,
char const *value,
817 kmp_stg_wp_data_t *wait = (kmp_stg_wp_data_t *)data;
820 rc = __kmp_stg_check_rivals(name, value, wait->rivals);
826 if (__kmp_str_match(
"ACTIVE", 1, value)) {
827 __kmp_library = library_turnaround;
828 if (blocktime_str == NULL) {
830 __kmp_dflt_blocktime = KMP_MAX_BLOCKTIME;
832 }
else if (__kmp_str_match(
"PASSIVE", 1, value)) {
833 __kmp_library = library_throughput;
834 __kmp_wpolicy_passive =
true;
835 if (blocktime_str == NULL) {
837 __kmp_dflt_blocktime = 0;
840 KMP_WARNING(StgInvalidValue, name, value);
843 if (__kmp_str_match(
"serial", 1, value)) {
844 __kmp_library = library_serial;
845 }
else if (__kmp_str_match(
"throughput", 2, value)) {
846 __kmp_library = library_throughput;
847 if (blocktime_str == NULL) {
849 __kmp_dflt_blocktime = 0;
851 }
else if (__kmp_str_match(
"turnaround", 2, value)) {
852 __kmp_library = library_turnaround;
853 }
else if (__kmp_str_match(
"dedicated", 1, value)) {
854 __kmp_library = library_turnaround;
855 }
else if (__kmp_str_match(
"multiuser", 1, value)) {
856 __kmp_library = library_throughput;
857 if (blocktime_str == NULL) {
859 __kmp_dflt_blocktime = 0;
862 KMP_WARNING(StgInvalidValue, name, value);
867static void __kmp_stg_print_wait_policy(kmp_str_buf_t *buffer,
char const *name,
870 kmp_stg_wp_data_t *wait = (kmp_stg_wp_data_t *)data;
871 char const *value = NULL;
874 switch (__kmp_library) {
875 case library_turnaround: {
878 case library_throughput: {
883 switch (__kmp_library) {
884 case library_serial: {
887 case library_turnaround: {
888 value =
"turnaround";
890 case library_throughput: {
891 value =
"throughput";
896 __kmp_stg_print_str(buffer, name, value);
905static void __kmp_stg_parse_monitor_stacksize(
char const *name,
906 char const *value,
void *data) {
907 __kmp_stg_parse_size(name, value, __kmp_sys_min_stksize, KMP_MAX_STKSIZE,
908 NULL, &__kmp_monitor_stksize, 1);
911static void __kmp_stg_print_monitor_stacksize(kmp_str_buf_t *buffer,
912 char const *name,
void *data) {
913 if (__kmp_env_format) {
914 if (__kmp_monitor_stksize > 0)
915 KMP_STR_BUF_PRINT_NAME_EX(name);
917 KMP_STR_BUF_PRINT_NAME;
919 __kmp_str_buf_print(buffer,
" %s", name);
921 if (__kmp_monitor_stksize > 0) {
922 __kmp_str_buf_print_size(buffer, __kmp_monitor_stksize);
924 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
926 if (__kmp_env_format && __kmp_monitor_stksize) {
927 __kmp_str_buf_print(buffer,
"'\n");
935static void __kmp_stg_parse_settings(
char const *name,
char const *value,
937 __kmp_stg_parse_bool(name, value, &__kmp_settings);
940static void __kmp_stg_print_settings(kmp_str_buf_t *buffer,
char const *name,
942 __kmp_stg_print_bool(buffer, name, __kmp_settings);
948static void __kmp_stg_parse_stackpad(
char const *name,
char const *value,
950 __kmp_stg_parse_int(name,
958static void __kmp_stg_print_stackpad(kmp_str_buf_t *buffer,
char const *name,
960 __kmp_stg_print_int(buffer, name, __kmp_stkpadding);
966static void __kmp_stg_parse_stackoffset(
char const *name,
char const *value,
968 __kmp_stg_parse_size(name,
977static void __kmp_stg_print_stackoffset(kmp_str_buf_t *buffer,
char const *name,
979 __kmp_stg_print_size(buffer, name, __kmp_stkoffset);
985static void __kmp_stg_parse_stacksize(
char const *name,
char const *value,
988 kmp_stg_ss_data_t *stacksize = (kmp_stg_ss_data_t *)data;
991 rc = __kmp_stg_check_rivals(name, value, stacksize->rivals);
995 __kmp_stg_parse_size(name,
997 __kmp_sys_min_stksize,
1009static void __kmp_stg_print_stacksize(kmp_str_buf_t *buffer,
char const *name,
1011 kmp_stg_ss_data_t *stacksize = (kmp_stg_ss_data_t *)data;
1012 if (__kmp_env_format) {
1013 KMP_STR_BUF_PRINT_NAME_EX(name);
1014 __kmp_str_buf_print_size(buffer, (__kmp_stksize % 1024)
1015 ? __kmp_stksize / stacksize->factor
1017 __kmp_str_buf_print(buffer,
"'\n");
1019 __kmp_str_buf_print(buffer,
" %s=", name);
1020 __kmp_str_buf_print_size(buffer, (__kmp_stksize % 1024)
1021 ? __kmp_stksize / stacksize->factor
1023 __kmp_str_buf_print(buffer,
"\n");
1030static void __kmp_stg_parse_version(
char const *name,
char const *value,
1032 __kmp_stg_parse_bool(name, value, &__kmp_version);
1035static void __kmp_stg_print_version(kmp_str_buf_t *buffer,
char const *name,
1037 __kmp_stg_print_bool(buffer, name, __kmp_version);
1043static void __kmp_stg_parse_warnings(
char const *name,
char const *value,
1045 __kmp_stg_parse_bool(name, value, &__kmp_generate_warnings);
1046 if (__kmp_generate_warnings != kmp_warnings_off) {
1049 __kmp_generate_warnings = kmp_warnings_explicit;
1053static void __kmp_stg_print_warnings(kmp_str_buf_t *buffer,
char const *name,
1056 __kmp_stg_print_bool(buffer, name, __kmp_generate_warnings);
1062static void __kmp_stg_parse_nesting_mode(
char const *name,
char const *value,
1064 __kmp_stg_parse_int(name, value, 0, INT_MAX, &__kmp_nesting_mode);
1065#if KMP_AFFINITY_SUPPORTED && KMP_USE_HWLOC
1066 if (__kmp_nesting_mode > 0)
1067 __kmp_affinity_top_method = affinity_top_method_hwloc;
1071static void __kmp_stg_print_nesting_mode(kmp_str_buf_t *buffer,
1072 char const *name,
void *data) {
1073 if (__kmp_env_format) {
1074 KMP_STR_BUF_PRINT_NAME;
1076 __kmp_str_buf_print(buffer,
" %s", name);
1078 __kmp_str_buf_print(buffer,
"=%d\n", __kmp_nesting_mode);
1084static void __kmp_stg_parse_nested(
char const *name,
char const *value,
1087 KMP_INFORM(EnvVarDeprecated, name,
"OMP_MAX_ACTIVE_LEVELS");
1088 __kmp_stg_parse_bool(name, value, &nested);
1090 if (!__kmp_dflt_max_active_levels_set)
1091 __kmp_dflt_max_active_levels = KMP_MAX_ACTIVE_LEVELS_LIMIT;
1093 __kmp_dflt_max_active_levels = 1;
1094 __kmp_dflt_max_active_levels_set =
true;
1098static void __kmp_stg_print_nested(kmp_str_buf_t *buffer,
char const *name,
1100 if (__kmp_env_format) {
1101 KMP_STR_BUF_PRINT_NAME;
1103 __kmp_str_buf_print(buffer,
" %s", name);
1105 __kmp_str_buf_print(buffer,
": deprecated; max-active-levels-var=%d\n",
1106 __kmp_dflt_max_active_levels);
1109static void __kmp_parse_nested_num_threads(
const char *var,
const char *env,
1110 kmp_nested_nthreads_t *nth_array) {
1111 const char *next = env;
1112 const char *scan = next;
1115 int prev_comma = FALSE;
1121 if (*next ==
'\0') {
1125 if (((*next <
'0') || (*next >
'9')) && (*next !=
',')) {
1126 KMP_WARNING(NthSyntaxError, var, env);
1132 if (total == 0 || prev_comma) {
1140 if (*next >=
'0' && *next <=
'9') {
1144 const char *tmp = next;
1146 if ((*next ==
' ' || *next ==
'\t') && (*tmp >=
'0' && *tmp <=
'9')) {
1147 KMP_WARNING(NthSpacesNotAllowed, var, env);
1152 if (!__kmp_dflt_max_active_levels_set && total > 1)
1153 __kmp_dflt_max_active_levels = KMP_MAX_ACTIVE_LEVELS_LIMIT;
1154 KMP_DEBUG_ASSERT(total > 0);
1156 KMP_WARNING(NthSyntaxError, var, env);
1161 if (!nth_array->nth) {
1163 nth_array->nth = (
int *)KMP_INTERNAL_MALLOC(
sizeof(
int) * total * 2);
1164 if (nth_array->nth == NULL) {
1165 KMP_FATAL(MemoryAllocFailed);
1167 nth_array->size = total * 2;
1169 if (nth_array->size < total) {
1172 nth_array->size *= 2;
1173 }
while (nth_array->size < total);
1175 nth_array->nth = (
int *)KMP_INTERNAL_REALLOC(
1176 nth_array->nth,
sizeof(
int) * nth_array->size);
1177 if (nth_array->nth == NULL) {
1178 KMP_FATAL(MemoryAllocFailed);
1182 nth_array->used = total;
1190 if (*scan ==
'\0') {
1200 nth_array->nth[i++] = 0;
1202 }
else if (prev_comma) {
1204 nth_array->nth[i] = nth_array->nth[i - 1];
1213 if (*scan >=
'0' && *scan <=
'9') {
1215 const char *buf = scan;
1216 char const *msg = NULL;
1221 num = __kmp_str_to_int(buf, *scan);
1222 if (num < KMP_MIN_NTH) {
1223 msg = KMP_I18N_STR(ValueTooSmall);
1225 }
else if (num > __kmp_sys_max_nth) {
1226 msg = KMP_I18N_STR(ValueTooLarge);
1227 num = __kmp_sys_max_nth;
1231 KMP_WARNING(ParseSizeIntWarn, var, env, msg);
1232 KMP_INFORM(Using_int_Value, var, num);
1234 nth_array->nth[i++] = num;
1239static void __kmp_stg_parse_num_threads(
char const *name,
char const *value,
1242 if (!__kmp_strcasecmp_with_sentinel(
"all", value, 0)) {
1244 __kmp_nested_nth.nth = (
int *)KMP_INTERNAL_MALLOC(
sizeof(
int));
1245 __kmp_nested_nth.size = __kmp_nested_nth.used = 1;
1246 __kmp_nested_nth.nth[0] = __kmp_dflt_team_nth = __kmp_dflt_team_nth_ub =
1249 __kmp_parse_nested_num_threads(name, value, &__kmp_nested_nth);
1250 if (__kmp_nested_nth.nth) {
1251 __kmp_dflt_team_nth = __kmp_nested_nth.nth[0];
1252 if (__kmp_dflt_team_nth_ub < __kmp_dflt_team_nth) {
1253 __kmp_dflt_team_nth_ub = __kmp_dflt_team_nth;
1257 K_DIAG(1, (
"__kmp_dflt_team_nth == %d\n", __kmp_dflt_team_nth));
1261static void __kmp_stg_parse_max_tdgs(
char const *name,
char const *value,
1263 __kmp_stg_parse_int(name, value, 0, INT_MAX, &__kmp_max_tdgs);
1266static void __kmp_std_print_max_tdgs(kmp_str_buf_t *buffer,
char const *name,
1268 __kmp_stg_print_int(buffer, name, __kmp_max_tdgs);
1271static void __kmp_stg_parse_tdg_dot(
char const *name,
char const *value,
1273 __kmp_stg_parse_bool(name, value, &__kmp_tdg_dot);
1276static void __kmp_stg_print_tdg_dot(kmp_str_buf_t *buffer,
char const *name,
1278 __kmp_stg_print_bool(buffer, name, __kmp_tdg_dot);
1282static void __kmp_stg_parse_num_hidden_helper_threads(
char const *name,
1285 __kmp_stg_parse_int(name, value, 0, 16, &__kmp_hidden_helper_threads_num);
1288 if (__kmp_hidden_helper_threads_num == 0) {
1289 __kmp_enable_hidden_helper = FALSE;
1294 __kmp_hidden_helper_threads_num++;
1298static void __kmp_stg_print_num_hidden_helper_threads(kmp_str_buf_t *buffer,
1301 if (__kmp_hidden_helper_threads_num == 0) {
1302 __kmp_stg_print_int(buffer, name, __kmp_hidden_helper_threads_num);
1304 KMP_DEBUG_ASSERT(__kmp_hidden_helper_threads_num > 1);
1307 __kmp_stg_print_int(buffer, name, __kmp_hidden_helper_threads_num - 1);
1311static void __kmp_stg_parse_use_hidden_helper(
char const *name,
1312 char const *value,
void *data) {
1313 __kmp_stg_parse_bool(name, value, &__kmp_enable_hidden_helper);
1315 __kmp_enable_hidden_helper = FALSE;
1317 (
"__kmp_stg_parse_use_hidden_helper: Disable hidden helper task on "
1318 "non-Linux platform although it is enabled by user explicitly.\n"));
1322static void __kmp_stg_print_use_hidden_helper(kmp_str_buf_t *buffer,
1323 char const *name,
void *data) {
1324 __kmp_stg_print_bool(buffer, name, __kmp_enable_hidden_helper);
1327static void __kmp_stg_print_num_threads(kmp_str_buf_t *buffer,
char const *name,
1329 if (__kmp_env_format) {
1330 KMP_STR_BUF_PRINT_NAME;
1332 __kmp_str_buf_print(buffer,
" %s", name);
1334 if (__kmp_nested_nth.used) {
1336 __kmp_str_buf_init(&buf);
1337 for (
int i = 0; i < __kmp_nested_nth.used; i++) {
1338 __kmp_str_buf_print(&buf,
"%d", __kmp_nested_nth.nth[i]);
1339 if (i < __kmp_nested_nth.used - 1) {
1340 __kmp_str_buf_print(&buf,
",");
1343 __kmp_str_buf_print(buffer,
"='%s'\n", buf.str);
1344 __kmp_str_buf_free(&buf);
1346 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
1353static void __kmp_stg_parse_tasking(
char const *name,
char const *value,
1355 __kmp_stg_parse_int(name, value, 0, (
int)tskm_max,
1356 (
int *)&__kmp_tasking_mode);
1359static void __kmp_stg_print_tasking(kmp_str_buf_t *buffer,
char const *name,
1361 __kmp_stg_print_int(buffer, name, __kmp_tasking_mode);
1364static void __kmp_stg_parse_task_stealing(
char const *name,
char const *value,
1366 __kmp_stg_parse_int(name, value, 0, 1,
1367 (
int *)&__kmp_task_stealing_constraint);
1370static void __kmp_stg_print_task_stealing(kmp_str_buf_t *buffer,
1371 char const *name,
void *data) {
1372 __kmp_stg_print_int(buffer, name, __kmp_task_stealing_constraint);
1375static void __kmp_stg_parse_max_active_levels(
char const *name,
1376 char const *value,
void *data) {
1377 kmp_uint64 tmp_dflt = 0;
1378 char const *msg = NULL;
1379 if (!__kmp_dflt_max_active_levels_set) {
1381 __kmp_str_to_uint(value, &tmp_dflt, &msg);
1383 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
1384 }
else if (tmp_dflt > KMP_MAX_ACTIVE_LEVELS_LIMIT) {
1386 msg = KMP_I18N_STR(ValueTooLarge);
1387 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
1389 __kmp_type_convert(tmp_dflt, &(__kmp_dflt_max_active_levels));
1390 __kmp_dflt_max_active_levels_set =
true;
1395static void __kmp_stg_print_max_active_levels(kmp_str_buf_t *buffer,
1396 char const *name,
void *data) {
1397 __kmp_stg_print_int(buffer, name, __kmp_dflt_max_active_levels);
1402static void __kmp_stg_parse_default_device(
char const *name,
char const *value,
1404 __kmp_stg_parse_int(name, value, 0, KMP_MAX_DEFAULT_DEVICE_LIMIT,
1405 &__kmp_default_device);
1408static void __kmp_stg_print_default_device(kmp_str_buf_t *buffer,
1409 char const *name,
void *data) {
1410 __kmp_stg_print_int(buffer, name, __kmp_default_device);
1415static void __kmp_stg_parse_target_offload(
char const *name,
char const *value,
1417 kmp_trimmed_str_t value_str(value);
1418 const char *scan = value_str.get();
1419 __kmp_target_offload = tgt_default;
1424 if (!__kmp_strcasecmp_with_sentinel(
"mandatory", scan, 0)) {
1425 __kmp_target_offload = tgt_mandatory;
1426 }
else if (!__kmp_strcasecmp_with_sentinel(
"disabled", scan, 0)) {
1427 __kmp_target_offload = tgt_disabled;
1428 }
else if (!__kmp_strcasecmp_with_sentinel(
"default", scan, 0)) {
1429 __kmp_target_offload = tgt_default;
1431 KMP_WARNING(SyntaxErrorUsing, name,
"DEFAULT");
1435static void __kmp_stg_print_target_offload(kmp_str_buf_t *buffer,
1436 char const *name,
void *data) {
1437 const char *value = NULL;
1438 if (__kmp_target_offload == tgt_default)
1440 else if (__kmp_target_offload == tgt_mandatory)
1441 value =
"MANDATORY";
1442 else if (__kmp_target_offload == tgt_disabled)
1444 KMP_DEBUG_ASSERT(value);
1445 if (__kmp_env_format) {
1446 KMP_STR_BUF_PRINT_NAME;
1448 __kmp_str_buf_print(buffer,
" %s", name);
1450 __kmp_str_buf_print(buffer,
"=%s\n", value);
1455static void __kmp_stg_parse_max_task_priority(
char const *name,
1456 char const *value,
void *data) {
1457 __kmp_stg_parse_int(name, value, 0, KMP_MAX_TASK_PRIORITY_LIMIT,
1458 &__kmp_max_task_priority);
1461static void __kmp_stg_print_max_task_priority(kmp_str_buf_t *buffer,
1462 char const *name,
void *data) {
1463 __kmp_stg_print_int(buffer, name, __kmp_max_task_priority);
1468static void __kmp_stg_parse_taskloop_min_tasks(
char const *name,
1469 char const *value,
void *data) {
1471 __kmp_stg_parse_int(name, value, 0, INT_MAX, &tmp);
1472 __kmp_taskloop_min_tasks = tmp;
1475static void __kmp_stg_print_taskloop_min_tasks(kmp_str_buf_t *buffer,
1476 char const *name,
void *data) {
1477 __kmp_stg_print_uint64(buffer, name, __kmp_taskloop_min_tasks);
1482static void __kmp_stg_parse_disp_buffers(
char const *name,
char const *value,
1484 if (TCR_4(__kmp_init_serial)) {
1485 KMP_WARNING(EnvSerialWarn, name);
1488 __kmp_stg_parse_int(name, value, KMP_MIN_DISP_NUM_BUFF, KMP_MAX_DISP_NUM_BUFF,
1489 &__kmp_dispatch_num_buffers);
1492static void __kmp_stg_print_disp_buffers(kmp_str_buf_t *buffer,
1493 char const *name,
void *data) {
1494 __kmp_stg_print_int(buffer, name, __kmp_dispatch_num_buffers);
1497#if KMP_NESTED_HOT_TEAMS
1501static void __kmp_stg_parse_hot_teams_level(
char const *name,
char const *value,
1503 if (TCR_4(__kmp_init_parallel)) {
1504 KMP_WARNING(EnvParallelWarn, name);
1507 __kmp_stg_parse_int(name, value, 0, KMP_MAX_ACTIVE_LEVELS_LIMIT,
1508 &__kmp_hot_teams_max_level);
1511static void __kmp_stg_print_hot_teams_level(kmp_str_buf_t *buffer,
1512 char const *name,
void *data) {
1513 __kmp_stg_print_int(buffer, name, __kmp_hot_teams_max_level);
1516static void __kmp_stg_parse_hot_teams_mode(
char const *name,
char const *value,
1518 if (TCR_4(__kmp_init_parallel)) {
1519 KMP_WARNING(EnvParallelWarn, name);
1522 __kmp_stg_parse_int(name, value, 0, KMP_MAX_ACTIVE_LEVELS_LIMIT,
1523 &__kmp_hot_teams_mode);
1526static void __kmp_stg_print_hot_teams_mode(kmp_str_buf_t *buffer,
1527 char const *name,
void *data) {
1528 __kmp_stg_print_int(buffer, name, __kmp_hot_teams_mode);
1536#if KMP_HANDLE_SIGNALS
1538static void __kmp_stg_parse_handle_signals(
char const *name,
char const *value,
1540 __kmp_stg_parse_bool(name, value, &__kmp_handle_signals);
1543static void __kmp_stg_print_handle_signals(kmp_str_buf_t *buffer,
1544 char const *name,
void *data) {
1545 __kmp_stg_print_bool(buffer, name, __kmp_handle_signals);
1555#define KMP_STG_X_DEBUG(x) \
1556 static void __kmp_stg_parse_##x##_debug(char const *name, char const *value, \
1558 __kmp_stg_parse_int(name, value, 0, INT_MAX, &kmp_##x##_debug); \
1560 static void __kmp_stg_print_##x##_debug(kmp_str_buf_t *buffer, \
1561 char const *name, void *data) { \
1562 __kmp_stg_print_int(buffer, name, kmp_##x##_debug); \
1572#undef KMP_STG_X_DEBUG
1574static void __kmp_stg_parse_debug(
char const *name,
char const *value,
1577 __kmp_stg_parse_int(name, value, 0, INT_MAX, &debug);
1578 if (kmp_a_debug < debug) {
1579 kmp_a_debug = debug;
1581 if (kmp_b_debug < debug) {
1582 kmp_b_debug = debug;
1584 if (kmp_c_debug < debug) {
1585 kmp_c_debug = debug;
1587 if (kmp_d_debug < debug) {
1588 kmp_d_debug = debug;
1590 if (kmp_e_debug < debug) {
1591 kmp_e_debug = debug;
1593 if (kmp_f_debug < debug) {
1594 kmp_f_debug = debug;
1598static void __kmp_stg_parse_debug_buf(
char const *name,
char const *value,
1600 __kmp_stg_parse_bool(name, value, &__kmp_debug_buf);
1604 if (__kmp_debug_buf) {
1606 int elements = __kmp_debug_buf_lines * __kmp_debug_buf_chars;
1609 __kmp_debug_buffer = (
char *)__kmp_page_allocate(elements *
sizeof(
char));
1610 for (i = 0; i < elements; i += __kmp_debug_buf_chars)
1611 __kmp_debug_buffer[i] =
'\0';
1613 __kmp_debug_count = 0;
1615 K_DIAG(1, (
"__kmp_debug_buf = %d\n", __kmp_debug_buf));
1618static void __kmp_stg_print_debug_buf(kmp_str_buf_t *buffer,
char const *name,
1620 __kmp_stg_print_bool(buffer, name, __kmp_debug_buf);
1623static void __kmp_stg_parse_debug_buf_atomic(
char const *name,
1624 char const *value,
void *data) {
1625 __kmp_stg_parse_bool(name, value, &__kmp_debug_buf_atomic);
1628static void __kmp_stg_print_debug_buf_atomic(kmp_str_buf_t *buffer,
1629 char const *name,
void *data) {
1630 __kmp_stg_print_bool(buffer, name, __kmp_debug_buf_atomic);
1633static void __kmp_stg_parse_debug_buf_chars(
char const *name,
char const *value,
1635 __kmp_stg_parse_int(name, value, KMP_DEBUG_BUF_CHARS_MIN, INT_MAX,
1636 &__kmp_debug_buf_chars);
1639static void __kmp_stg_print_debug_buf_chars(kmp_str_buf_t *buffer,
1640 char const *name,
void *data) {
1641 __kmp_stg_print_int(buffer, name, __kmp_debug_buf_chars);
1644static void __kmp_stg_parse_debug_buf_lines(
char const *name,
char const *value,
1646 __kmp_stg_parse_int(name, value, KMP_DEBUG_BUF_LINES_MIN, INT_MAX,
1647 &__kmp_debug_buf_lines);
1650static void __kmp_stg_print_debug_buf_lines(kmp_str_buf_t *buffer,
1651 char const *name,
void *data) {
1652 __kmp_stg_print_int(buffer, name, __kmp_debug_buf_lines);
1655static void __kmp_stg_parse_diag(
char const *name,
char const *value,
1657 __kmp_stg_parse_int(name, value, 0, INT_MAX, &kmp_diag);
1660static void __kmp_stg_print_diag(kmp_str_buf_t *buffer,
char const *name,
1662 __kmp_stg_print_int(buffer, name, kmp_diag);
1670static void __kmp_stg_parse_align_alloc(
char const *name,
char const *value,
1672 __kmp_stg_parse_size(name, value, CACHE_LINE, INT_MAX, NULL,
1673 &__kmp_align_alloc, 1);
1676static void __kmp_stg_print_align_alloc(kmp_str_buf_t *buffer,
char const *name,
1678 __kmp_stg_print_size(buffer, name, __kmp_align_alloc);
1687static void __kmp_stg_parse_barrier_branch_bit(
char const *name,
1688 char const *value,
void *data) {
1692 for (
int i = bs_plain_barrier; i < bs_last_barrier; i++) {
1693 var = __kmp_barrier_branch_bit_env_name[i];
1694 if ((strcmp(var, name) == 0) && (value != 0)) {
1697 comma = CCAST(
char *, strchr(value,
','));
1698 __kmp_barrier_gather_branch_bits[i] =
1699 (kmp_uint32)__kmp_str_to_int(value,
',');
1701 if (comma == NULL) {
1702 __kmp_barrier_release_branch_bits[i] = __kmp_barrier_release_bb_dflt;
1704 __kmp_barrier_release_branch_bits[i] =
1705 (kmp_uint32)__kmp_str_to_int(comma + 1, 0);
1707 if (__kmp_barrier_release_branch_bits[i] > KMP_MAX_BRANCH_BITS) {
1708 __kmp_msg(kmp_ms_warning,
1709 KMP_MSG(BarrReleaseValueInvalid, name, comma + 1),
1711 __kmp_barrier_release_branch_bits[i] = __kmp_barrier_release_bb_dflt;
1714 if (__kmp_barrier_gather_branch_bits[i] > KMP_MAX_BRANCH_BITS) {
1715 KMP_WARNING(BarrGatherValueInvalid, name, value);
1716 KMP_INFORM(Using_uint_Value, name, __kmp_barrier_gather_bb_dflt);
1717 __kmp_barrier_gather_branch_bits[i] = __kmp_barrier_gather_bb_dflt;
1720 K_DIAG(1, (
"%s == %d,%d\n", __kmp_barrier_branch_bit_env_name[i],
1721 __kmp_barrier_gather_branch_bits[i],
1722 __kmp_barrier_release_branch_bits[i]))
1726static void __kmp_stg_print_barrier_branch_bit(kmp_str_buf_t *buffer,
1727 char const *name,
void *data) {
1729 for (
int i = bs_plain_barrier; i < bs_last_barrier; i++) {
1730 var = __kmp_barrier_branch_bit_env_name[i];
1731 if (strcmp(var, name) == 0) {
1732 if (__kmp_env_format) {
1733 KMP_STR_BUF_PRINT_NAME_EX(__kmp_barrier_branch_bit_env_name[i]);
1735 __kmp_str_buf_print(buffer,
" %s='",
1736 __kmp_barrier_branch_bit_env_name[i]);
1738 __kmp_str_buf_print(buffer,
"%d,%d'\n",
1739 __kmp_barrier_gather_branch_bits[i],
1740 __kmp_barrier_release_branch_bits[i]);
1752static void __kmp_stg_parse_barrier_pattern(
char const *name,
char const *value,
1757 static int dist_req = 0, non_dist_req = 0;
1758 static bool warn = 1;
1759 for (
int i = bs_plain_barrier; i < bs_last_barrier; i++) {
1760 var = __kmp_barrier_pattern_env_name[i];
1762 if ((strcmp(var, name) == 0) && (value != 0)) {
1764 char *comma = CCAST(
char *, strchr(value,
','));
1767 for (j = bp_linear_bar; j < bp_last_bar; j++) {
1768 if (__kmp_match_with_sentinel(__kmp_barrier_pattern_name[j], value, 1,
1770 if (j == bp_dist_bar) {
1775 __kmp_barrier_gather_pattern[i] = (kmp_bar_pat_e)j;
1779 if (j == bp_last_bar) {
1780 KMP_WARNING(BarrGatherValueInvalid, name, value);
1781 KMP_INFORM(Using_str_Value, name,
1782 __kmp_barrier_pattern_name[bp_linear_bar]);
1786 if (comma != NULL) {
1787 for (j = bp_linear_bar; j < bp_last_bar; j++) {
1788 if (__kmp_str_match(__kmp_barrier_pattern_name[j], 1, comma + 1)) {
1789 if (j == bp_dist_bar) {
1794 __kmp_barrier_release_pattern[i] = (kmp_bar_pat_e)j;
1798 if (j == bp_last_bar) {
1799 __kmp_msg(kmp_ms_warning,
1800 KMP_MSG(BarrReleaseValueInvalid, name, comma + 1),
1802 KMP_INFORM(Using_str_Value, name,
1803 __kmp_barrier_pattern_name[bp_linear_bar]);
1808 if (dist_req != 0) {
1810 if ((non_dist_req != 0) && warn) {
1811 KMP_INFORM(BarrierPatternOverride, name,
1812 __kmp_barrier_pattern_name[bp_dist_bar]);
1815 for (
int i = bs_plain_barrier; i < bs_last_barrier; i++) {
1816 if (__kmp_barrier_release_pattern[i] != bp_dist_bar)
1817 __kmp_barrier_release_pattern[i] = bp_dist_bar;
1818 if (__kmp_barrier_gather_pattern[i] != bp_dist_bar)
1819 __kmp_barrier_gather_pattern[i] = bp_dist_bar;
1824static void __kmp_stg_print_barrier_pattern(kmp_str_buf_t *buffer,
1825 char const *name,
void *data) {
1827 for (
int i = bs_plain_barrier; i < bs_last_barrier; i++) {
1828 var = __kmp_barrier_pattern_env_name[i];
1829 if (strcmp(var, name) == 0) {
1830 int j = __kmp_barrier_gather_pattern[i];
1831 int k = __kmp_barrier_release_pattern[i];
1832 if (__kmp_env_format) {
1833 KMP_STR_BUF_PRINT_NAME_EX(__kmp_barrier_pattern_env_name[i]);
1835 __kmp_str_buf_print(buffer,
" %s='",
1836 __kmp_barrier_pattern_env_name[i]);
1838 KMP_DEBUG_ASSERT(j < bp_last_bar && k < bp_last_bar);
1839 __kmp_str_buf_print(buffer,
"%s,%s'\n", __kmp_barrier_pattern_name[j],
1840 __kmp_barrier_pattern_name[k]);
1848static void __kmp_stg_parse_abort_delay(
char const *name,
char const *value,
1852 int delay = __kmp_abort_delay / 1000;
1853 __kmp_stg_parse_int(name, value, 0, INT_MAX / 1000, &delay);
1854 __kmp_abort_delay = delay * 1000;
1857static void __kmp_stg_print_abort_delay(kmp_str_buf_t *buffer,
char const *name,
1859 __kmp_stg_print_int(buffer, name, __kmp_abort_delay);
1865static void __kmp_stg_parse_cpuinfo_file(
char const *name,
char const *value,
1867#if KMP_AFFINITY_SUPPORTED
1868 __kmp_stg_parse_str(name, value, &__kmp_cpuinfo_file);
1869 K_DIAG(1, (
"__kmp_cpuinfo_file == %s\n", __kmp_cpuinfo_file));
1873static void __kmp_stg_print_cpuinfo_file(kmp_str_buf_t *buffer,
1874 char const *name,
void *data) {
1875#if KMP_AFFINITY_SUPPORTED
1876 if (__kmp_env_format) {
1877 KMP_STR_BUF_PRINT_NAME;
1879 __kmp_str_buf_print(buffer,
" %s", name);
1881 if (__kmp_cpuinfo_file) {
1882 __kmp_str_buf_print(buffer,
"='%s'\n", __kmp_cpuinfo_file);
1884 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
1892static void __kmp_stg_parse_force_reduction(
char const *name,
char const *value,
1894 kmp_stg_fr_data_t *reduction = (kmp_stg_fr_data_t *)data;
1897 rc = __kmp_stg_check_rivals(name, value, reduction->rivals);
1901 if (reduction->force) {
1903 if (__kmp_str_match(
"critical", 0, value))
1904 __kmp_force_reduction_method = critical_reduce_block;
1905 else if (__kmp_str_match(
"atomic", 0, value))
1906 __kmp_force_reduction_method = atomic_reduce_block;
1907 else if (__kmp_str_match(
"tree", 0, value))
1908 __kmp_force_reduction_method = tree_reduce_block;
1910 KMP_FATAL(UnknownForceReduction, name, value);
1914 __kmp_stg_parse_bool(name, value, &__kmp_determ_red);
1915 if (__kmp_determ_red) {
1916 __kmp_force_reduction_method = tree_reduce_block;
1918 __kmp_force_reduction_method = reduction_method_not_defined;
1921 K_DIAG(1, (
"__kmp_force_reduction_method == %d\n",
1922 __kmp_force_reduction_method));
1925static void __kmp_stg_print_force_reduction(kmp_str_buf_t *buffer,
1926 char const *name,
void *data) {
1928 kmp_stg_fr_data_t *reduction = (kmp_stg_fr_data_t *)data;
1929 if (reduction->force) {
1930 if (__kmp_force_reduction_method == critical_reduce_block) {
1931 __kmp_stg_print_str(buffer, name,
"critical");
1932 }
else if (__kmp_force_reduction_method == atomic_reduce_block) {
1933 __kmp_stg_print_str(buffer, name,
"atomic");
1934 }
else if (__kmp_force_reduction_method == tree_reduce_block) {
1935 __kmp_stg_print_str(buffer, name,
"tree");
1937 if (__kmp_env_format) {
1938 KMP_STR_BUF_PRINT_NAME;
1940 __kmp_str_buf_print(buffer,
" %s", name);
1942 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
1945 __kmp_stg_print_bool(buffer, name, __kmp_determ_red);
1953static void __kmp_stg_parse_storage_map(
char const *name,
char const *value,
1955 if (__kmp_str_match(
"verbose", 1, value)) {
1956 __kmp_storage_map = TRUE;
1957 __kmp_storage_map_verbose = TRUE;
1958 __kmp_storage_map_verbose_specified = TRUE;
1961 __kmp_storage_map_verbose = FALSE;
1962 __kmp_stg_parse_bool(name, value, &__kmp_storage_map);
1966static void __kmp_stg_print_storage_map(kmp_str_buf_t *buffer,
char const *name,
1968 if (__kmp_storage_map_verbose || __kmp_storage_map_verbose_specified) {
1969 __kmp_stg_print_str(buffer, name,
"verbose");
1971 __kmp_stg_print_bool(buffer, name, __kmp_storage_map);
1978static void __kmp_stg_parse_all_threadprivate(
char const *name,
1979 char const *value,
void *data) {
1980 __kmp_stg_parse_int(name, value,
1981 __kmp_allThreadsSpecified ? __kmp_max_nth : 1,
1982 __kmp_max_nth, &__kmp_tp_capacity);
1985static void __kmp_stg_print_all_threadprivate(kmp_str_buf_t *buffer,
1986 char const *name,
void *data) {
1987 __kmp_stg_print_int(buffer, name, __kmp_tp_capacity);
1993static void __kmp_stg_parse_foreign_threads_threadprivate(
char const *name,
1996 __kmp_stg_parse_bool(name, value, &__kmp_foreign_tp);
1999static void __kmp_stg_print_foreign_threads_threadprivate(kmp_str_buf_t *buffer,
2002 __kmp_stg_print_bool(buffer, name, __kmp_foreign_tp);
2008static inline const char *
2009__kmp_hw_get_core_type_keyword(kmp_hw_core_type_t type) {
2011 case KMP_HW_CORE_TYPE_UNKNOWN:
2013#if KMP_ARCH_X86 || KMP_ARCH_X86_64
2014 case KMP_HW_CORE_TYPE_ATOM:
2015 return "intel_atom";
2016 case KMP_HW_CORE_TYPE_CORE:
2017 return "intel_core";
2023#if KMP_AFFINITY_SUPPORTED
2025static int __kmp_parse_affinity_proc_id_list(
const char *var,
const char *env,
2026 const char **nextEnv,
2028 const char *scan = env;
2029 const char *next = scan;
2035 int start, end, stride;
2039 if (*next ==
'\0') {
2050 if ((*next <
'0') || (*next >
'9')) {
2051 KMP_WARNING(AffSyntaxError, var);
2055 num = __kmp_str_to_int(scan, *next);
2056 KMP_ASSERT(num >= 0);
2074 if ((*next <
'0') || (*next >
'9')) {
2075 KMP_WARNING(AffSyntaxError, var);
2080 num = __kmp_str_to_int(scan, *next);
2081 KMP_ASSERT(num >= 0);
2094 if ((*next <
'0') || (*next >
'9')) {
2096 KMP_WARNING(AffSyntaxError, var);
2104 start = __kmp_str_to_int(scan, *next);
2105 KMP_ASSERT(start >= 0);
2124 if ((*next <
'0') || (*next >
'9')) {
2125 KMP_WARNING(AffSyntaxError, var);
2129 end = __kmp_str_to_int(scan, *next);
2130 KMP_ASSERT(end >= 0);
2147 if ((*next <
'0') || (*next >
'9')) {
2148 KMP_WARNING(AffSyntaxError, var);
2152 stride = __kmp_str_to_int(scan, *next);
2153 KMP_ASSERT(stride >= 0);
2159 KMP_WARNING(AffZeroStride, var);
2164 KMP_WARNING(AffStartGreaterEnd, var, start, end);
2169 KMP_WARNING(AffStrideLessZero, var, start, end);
2173 if ((end - start) / stride > 65536) {
2174 KMP_WARNING(AffRangeTooBig, var, end, start, stride);
2191 ptrdiff_t len = next - env;
2192 char *retlist = (
char *)__kmp_allocate((len + 1) *
sizeof(char));
2193 KMP_MEMCPY_S(retlist, (len + 1) *
sizeof(
char), env, len *
sizeof(
char));
2194 retlist[len] =
'\0';
2195 *proclist = retlist;
2202static kmp_setting_t *__kmp_affinity_notype = NULL;
2204static void __kmp_parse_affinity_env(
char const *name,
char const *value,
2205 kmp_affinity_t *out_affinity) {
2206 char *buffer = NULL;
2224 KMP_ASSERT(value != NULL);
2226 if (TCR_4(__kmp_init_middle)) {
2227 KMP_WARNING(EnvMiddleWarn, name);
2228 __kmp_env_toPrint(name, 0);
2231 __kmp_env_toPrint(name, 1);
2234 __kmp_str_format(
"%s", value);
2244#define EMIT_WARN(skip, errlist) \
2248 SKIP_TO(next, ','); \
2252 KMP_WARNING errlist; \
2261#define _set_param(_guard, _var, _val) \
2263 if (_guard == 0) { \
2266 EMIT_WARN(FALSE, (AffParamDefined, name, start)); \
2271#define set_type(val) _set_param(type, out_affinity->type, val)
2272#define set_verbose(val) _set_param(verbose, out_affinity->flags.verbose, val)
2273#define set_warnings(val) \
2274 _set_param(warnings, out_affinity->flags.warnings, val)
2275#define set_respect(val) _set_param(respect, out_affinity->flags.respect, val)
2276#define set_dups(val) _set_param(dups, out_affinity->flags.dups, val)
2277#define set_proclist(val) _set_param(proclist, out_affinity->proclist, val)
2278#define set_reset(val) _set_param(reset, out_affinity->flags.reset, val)
2280#define set_gran(val, levels) \
2283 out_affinity->gran = val; \
2284 out_affinity->gran_levels = levels; \
2286 EMIT_WARN(FALSE, (AffParamDefined, name, start)); \
2291 KMP_DEBUG_ASSERT((__kmp_nested_proc_bind.bind_types != NULL) &&
2292 (__kmp_nested_proc_bind.used > 0));
2294 while (*buf !=
'\0') {
2297 if (__kmp_match_str(
"none", buf, CCAST(
const char **, &next))) {
2298 set_type(affinity_none);
2299 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
2301 }
else if (__kmp_match_str(
"scatter", buf, CCAST(
const char **, &next))) {
2302 set_type(affinity_scatter);
2303 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2305 }
else if (__kmp_match_str(
"compact", buf, CCAST(
const char **, &next))) {
2306 set_type(affinity_compact);
2307 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2309 }
else if (__kmp_match_str(
"logical", buf, CCAST(
const char **, &next))) {
2310 set_type(affinity_logical);
2311 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2313 }
else if (__kmp_match_str(
"physical", buf, CCAST(
const char **, &next))) {
2314 set_type(affinity_physical);
2315 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2317 }
else if (__kmp_match_str(
"explicit", buf, CCAST(
const char **, &next))) {
2318 set_type(affinity_explicit);
2319 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2321 }
else if (__kmp_match_str(
"balanced", buf, CCAST(
const char **, &next))) {
2322 set_type(affinity_balanced);
2323 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2325 }
else if (__kmp_match_str(
"disabled", buf, CCAST(
const char **, &next))) {
2326 set_type(affinity_disabled);
2327 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
2329 }
else if (__kmp_match_str(
"verbose", buf, CCAST(
const char **, &next))) {
2332 }
else if (__kmp_match_str(
"noverbose", buf, CCAST(
const char **, &next))) {
2335 }
else if (__kmp_match_str(
"warnings", buf, CCAST(
const char **, &next))) {
2338 }
else if (__kmp_match_str(
"nowarnings", buf,
2339 CCAST(
const char **, &next))) {
2340 set_warnings(FALSE);
2342 }
else if (__kmp_match_str(
"respect", buf, CCAST(
const char **, &next))) {
2345 }
else if (__kmp_match_str(
"norespect", buf, CCAST(
const char **, &next))) {
2348 }
else if (__kmp_match_str(
"reset", buf, CCAST(
const char **, &next))) {
2351 }
else if (__kmp_match_str(
"noreset", buf, CCAST(
const char **, &next))) {
2354 }
else if (__kmp_match_str(
"duplicates", buf,
2355 CCAST(
const char **, &next)) ||
2356 __kmp_match_str(
"dups", buf, CCAST(
const char **, &next))) {
2359 }
else if (__kmp_match_str(
"noduplicates", buf,
2360 CCAST(
const char **, &next)) ||
2361 __kmp_match_str(
"nodups", buf, CCAST(
const char **, &next))) {
2364 }
else if (__kmp_match_str(
"granularity", buf,
2365 CCAST(
const char **, &next)) ||
2366 __kmp_match_str(
"gran", buf, CCAST(
const char **, &next))) {
2369 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2379 if (__kmp_match_str(
"core_type", buf, CCAST(
const char **, &next))) {
2380 set_gran(KMP_HW_CORE, -1);
2381 out_affinity->flags.core_types_gran = 1;
2384 }
else if (__kmp_match_str(
"core_efficiency", buf,
2385 CCAST(
const char **, &next)) ||
2386 __kmp_match_str(
"core_eff", buf,
2387 CCAST(
const char **, &next))) {
2388 set_gran(KMP_HW_CORE, -1);
2389 out_affinity->flags.core_effs_gran = 1;
2395 KMP_FOREACH_HW_TYPE(type) {
2396 const char *name = __kmp_hw_get_keyword(type);
2397 if (__kmp_match_str(name, buf, CCAST(
const char **, &next))) {
2407 if (__kmp_match_str(
"fine", buf, CCAST(
const char **, &next))) {
2408 set_gran(KMP_HW_THREAD, -1);
2411 }
else if (__kmp_match_str(
"package", buf,
2412 CCAST(
const char **, &next))) {
2413 set_gran(KMP_HW_SOCKET, -1);
2416 }
else if (__kmp_match_str(
"node", buf, CCAST(
const char **, &next))) {
2417 set_gran(KMP_HW_NUMA, -1);
2420#if KMP_GROUP_AFFINITY
2421 }
else if (__kmp_match_str(
"group", buf, CCAST(
const char **, &next))) {
2422 set_gran(KMP_HW_PROC_GROUP, -1);
2426 }
else if ((*buf >=
'0') && (*buf <=
'9')) {
2430 n = __kmp_str_to_int(buf, *next);
2433 set_gran(KMP_HW_UNKNOWN, n);
2436 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2440 }
else if (__kmp_match_str(
"proclist", buf, CCAST(
const char **, &next))) {
2441 char *temp_proclist;
2445 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2451 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2456 if (!__kmp_parse_affinity_proc_id_list(
2457 name, buf, CCAST(
const char **, &next), &temp_proclist)) {
2469 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2473 set_proclist(temp_proclist);
2474 }
else if ((*buf >=
'0') && (*buf <=
'9')) {
2479 n = __kmp_str_to_int(buf, *next);
2485 KMP_WARNING(AffManyParams, name, start);
2489 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2497 }
else if (*next !=
'\0') {
2498 const char *temp = next;
2499 EMIT_WARN(TRUE, (ParseExtraCharsWarn, name, temp));
2511#undef set_granularity
2514 __kmp_str_free(&buffer);
2518 KMP_WARNING(AffProcListNoType, name);
2519 out_affinity->type = affinity_explicit;
2520 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2521 }
else if (out_affinity->type != affinity_explicit) {
2522 KMP_WARNING(AffProcListNotExplicit, name);
2523 KMP_ASSERT(out_affinity->proclist != NULL);
2524 KMP_INTERNAL_FREE(out_affinity->proclist);
2525 out_affinity->proclist = NULL;
2528 switch (out_affinity->type) {
2529 case affinity_logical:
2530 case affinity_physical: {
2532 out_affinity->offset = number[0];
2535 KMP_WARNING(AffManyParamsForLogic, name, number[1]);
2538 case affinity_balanced: {
2540 out_affinity->compact = number[0];
2543 out_affinity->offset = number[1];
2546 if (__kmp_affinity.gran == KMP_HW_UNKNOWN) {
2547 int verbose = out_affinity->flags.verbose;
2548 int warnings = out_affinity->flags.warnings;
2549#if KMP_MIC_SUPPORTED
2550 if (__kmp_mic_type != non_mic) {
2551 if (verbose || warnings) {
2552 KMP_WARNING(AffGranUsing, out_affinity->env_var,
"fine");
2554 out_affinity->gran = KMP_HW_THREAD;
2558 if (verbose || warnings) {
2559 KMP_WARNING(AffGranUsing, out_affinity->env_var,
"core");
2561 out_affinity->gran = KMP_HW_CORE;
2565 case affinity_scatter:
2566 case affinity_compact: {
2568 out_affinity->compact = number[0];
2571 out_affinity->offset = number[1];
2574 case affinity_explicit: {
2575 if (out_affinity->proclist == NULL) {
2576 KMP_WARNING(AffNoProcList, name);
2577 out_affinity->type = affinity_none;
2580 KMP_WARNING(AffNoParam, name,
"explicit");
2583 case affinity_none: {
2585 KMP_WARNING(AffNoParam, name,
"none");
2588 case affinity_disabled: {
2590 KMP_WARNING(AffNoParam, name,
"disabled");
2593 case affinity_default: {
2595 KMP_WARNING(AffNoParam, name,
"default");
2604static void __kmp_stg_parse_affinity(
char const *name,
char const *value,
2606 kmp_setting_t **rivals = (kmp_setting_t **)data;
2609 rc = __kmp_stg_check_rivals(name, value, rivals);
2614 __kmp_parse_affinity_env(name, value, &__kmp_affinity);
2617static void __kmp_stg_parse_hh_affinity(
char const *name,
char const *value,
2619 __kmp_parse_affinity_env(name, value, &__kmp_hh_affinity);
2621 if (__kmp_hh_affinity.flags.reset) {
2622 KMP_WARNING(AffInvalidParam, name,
"reset");
2624 if (__kmp_hh_affinity.flags.respect != affinity_respect_mask_default) {
2625 KMP_WARNING(AffInvalidParam, name,
"respect");
2629static void __kmp_print_affinity_env(kmp_str_buf_t *buffer,
char const *name,
2630 const kmp_affinity_t &affinity) {
2631 bool is_hh_affinity = (&affinity == &__kmp_hh_affinity);
2632 if (__kmp_env_format) {
2633 KMP_STR_BUF_PRINT_NAME_EX(name);
2635 __kmp_str_buf_print(buffer,
" %s='", name);
2637 if (affinity.flags.verbose) {
2638 __kmp_str_buf_print(buffer,
"%s,",
"verbose");
2640 __kmp_str_buf_print(buffer,
"%s,",
"noverbose");
2642 if (affinity.flags.warnings) {
2643 __kmp_str_buf_print(buffer,
"%s,",
"warnings");
2645 __kmp_str_buf_print(buffer,
"%s,",
"nowarnings");
2647 if (KMP_AFFINITY_CAPABLE()) {
2650 if (!is_hh_affinity) {
2651 if (affinity.flags.respect) {
2652 __kmp_str_buf_print(buffer,
"%s,",
"respect");
2654 __kmp_str_buf_print(buffer,
"%s,",
"norespect");
2656 if (affinity.flags.reset) {
2657 __kmp_str_buf_print(buffer,
"%s,",
"reset");
2659 __kmp_str_buf_print(buffer,
"%s,",
"noreset");
2662 __kmp_str_buf_print(buffer,
"granularity=");
2663 if (affinity.flags.core_types_gran)
2664 __kmp_str_buf_print(buffer,
"core_type,");
2665 else if (affinity.flags.core_effs_gran) {
2666 __kmp_str_buf_print(buffer,
"core_eff,");
2668 __kmp_str_buf_print(
2669 buffer,
"%s,", __kmp_hw_get_keyword(affinity.gran,
false));
2672 if (!KMP_AFFINITY_CAPABLE()) {
2673 __kmp_str_buf_print(buffer,
"%s",
"disabled");
2675 int compact = affinity.compact;
2676 int offset = affinity.offset;
2677 switch (affinity.type) {
2679 __kmp_str_buf_print(buffer,
"%s",
"none");
2681 case affinity_physical:
2682 __kmp_str_buf_print(buffer,
"%s,%d",
"physical", offset);
2684 case affinity_logical:
2685 __kmp_str_buf_print(buffer,
"%s,%d",
"logical", offset);
2687 case affinity_compact:
2688 __kmp_str_buf_print(buffer,
"%s,%d,%d",
"compact", compact, offset);
2690 case affinity_scatter:
2691 __kmp_str_buf_print(buffer,
"%s,%d,%d",
"scatter", compact, offset);
2693 case affinity_explicit:
2694 __kmp_str_buf_print(buffer,
"%s=[%s],%s",
"proclist", affinity.proclist,
2697 case affinity_balanced:
2698 __kmp_str_buf_print(buffer,
"%s,%d,%d",
"balanced", compact, offset);
2700 case affinity_disabled:
2701 __kmp_str_buf_print(buffer,
"%s",
"disabled");
2703 case affinity_default:
2704 __kmp_str_buf_print(buffer,
"%s",
"default");
2707 __kmp_str_buf_print(buffer,
"%s",
"<unknown>");
2711 __kmp_str_buf_print(buffer,
"'\n");
2714static void __kmp_stg_print_affinity(kmp_str_buf_t *buffer,
char const *name,
2716 __kmp_print_affinity_env(buffer, name, __kmp_affinity);
2718static void __kmp_stg_print_hh_affinity(kmp_str_buf_t *buffer,
char const *name,
2720 __kmp_print_affinity_env(buffer, name, __kmp_hh_affinity);
2723#ifdef KMP_GOMP_COMPAT
2725static void __kmp_stg_parse_gomp_cpu_affinity(
char const *name,
2726 char const *value,
void *data) {
2727 const char *next = NULL;
2728 char *temp_proclist;
2729 kmp_setting_t **rivals = (kmp_setting_t **)data;
2732 rc = __kmp_stg_check_rivals(name, value, rivals);
2737 if (TCR_4(__kmp_init_middle)) {
2738 KMP_WARNING(EnvMiddleWarn, name);
2739 __kmp_env_toPrint(name, 0);
2743 __kmp_env_toPrint(name, 1);
2745 if (__kmp_parse_affinity_proc_id_list(name, value, &next, &temp_proclist)) {
2747 if (*next ==
'\0') {
2749 __kmp_affinity.proclist = temp_proclist;
2750 __kmp_affinity.type = affinity_explicit;
2751 __kmp_affinity.gran = KMP_HW_THREAD;
2752 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2754 KMP_WARNING(AffSyntaxError, name);
2755 if (temp_proclist != NULL) {
2756 KMP_INTERNAL_FREE((
void *)temp_proclist);
2761 __kmp_affinity.type = affinity_none;
2762 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
2789static int __kmp_parse_subplace_list(
const char *var,
const char **scan) {
2793 int start, count, stride;
2799 if ((**scan <
'0') || (**scan >
'9')) {
2804 start = __kmp_str_to_int(*scan, *next);
2805 KMP_ASSERT(start >= 0);
2810 if (**scan ==
'}') {
2813 if (**scan ==
',') {
2817 if (**scan !=
':') {
2824 if ((**scan <
'0') || (**scan >
'9')) {
2829 count = __kmp_str_to_int(*scan, *next);
2830 KMP_ASSERT(count >= 0);
2835 if (**scan ==
'}') {
2838 if (**scan ==
',') {
2842 if (**scan !=
':') {
2851 if (**scan ==
'+') {
2855 if (**scan ==
'-') {
2863 if ((**scan <
'0') || (**scan >
'9')) {
2868 stride = __kmp_str_to_int(*scan, *next);
2869 KMP_ASSERT(stride >= 0);
2875 if (**scan ==
'}') {
2878 if (**scan ==
',') {
2888static int __kmp_parse_place(
const char *var,
const char **scan) {
2893 if (**scan ==
'{') {
2895 if (!__kmp_parse_subplace_list(var, scan)) {
2898 if (**scan !=
'}') {
2902 }
else if (**scan ==
'!') {
2904 return __kmp_parse_place(var, scan);
2905 }
else if ((**scan >=
'0') && (**scan <=
'9')) {
2908 int proc = __kmp_str_to_int(*scan, *next);
2909 KMP_ASSERT(proc >= 0);
2918static int __kmp_parse_place_list(
const char *var,
const char *env,
2919 char **place_list) {
2920 const char *scan = env;
2921 const char *next = scan;
2926 if (!__kmp_parse_place(var, &scan)) {
2932 if (*scan ==
'\0') {
2946 if ((*scan <
'0') || (*scan >
'9')) {
2951 count = __kmp_str_to_int(scan, *next);
2952 KMP_ASSERT(count >= 0);
2957 if (*scan ==
'\0') {
2985 if ((*scan <
'0') || (*scan >
'9')) {
2990 stride = __kmp_str_to_int(scan, *next);
2991 KMP_ASSERT(stride >= 0);
2997 if (*scan ==
'\0') {
3009 ptrdiff_t len = scan - env;
3010 char *retlist = (
char *)__kmp_allocate((len + 1) *
sizeof(char));
3011 KMP_MEMCPY_S(retlist, (len + 1) *
sizeof(
char), env, len *
sizeof(
char));
3012 retlist[len] =
'\0';
3013 *place_list = retlist;
3018static inline void __kmp_places_set(
enum affinity_type type, kmp_hw_t kind) {
3019 __kmp_affinity.type = type;
3020 __kmp_affinity.gran = kind;
3021 __kmp_affinity.flags.dups = FALSE;
3022 __kmp_affinity.flags.omp_places = TRUE;
3025static void __kmp_places_syntax_error_fallback(
char const *name,
3027 const char *str = __kmp_hw_get_catalog_string(kind,
true);
3028 KMP_WARNING(SyntaxErrorUsing, name, str);
3029 __kmp_places_set(affinity_compact, kind);
3030 if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_default)
3031 __kmp_nested_proc_bind.bind_types[0] = proc_bind_true;
3034static void __kmp_stg_parse_places(
char const *name,
char const *value,
3036 struct kmp_place_t {
3042 const char *scan = value;
3043 const char *next = scan;
3044 kmp_place_t std_places[] = {{
"threads", KMP_HW_THREAD},
3045 {
"cores", KMP_HW_CORE},
3046 {
"numa_domains", KMP_HW_NUMA},
3047 {
"ll_caches", KMP_HW_LLC},
3048 {
"sockets", KMP_HW_SOCKET}};
3049 kmp_setting_t **rivals = (kmp_setting_t **)data;
3052 rc = __kmp_stg_check_rivals(name, value, rivals);
3058 for (
size_t i = 0; i <
sizeof(std_places) /
sizeof(std_places[0]); ++i) {
3059 const kmp_place_t &place = std_places[i];
3060 if (__kmp_match_str(place.name, scan, &next)) {
3062 __kmp_places_set(affinity_compact, place.type);
3065 if (KMP_HW_MAX_NUM_CORE_TYPES > 1) {
3068 if (place.type != KMP_HW_CORE) {
3069 __kmp_places_syntax_error_fallback(name, place.type);
3074#if KMP_ARCH_X86 || KMP_ARCH_X86_64
3075 if (__kmp_match_str(
"intel_core", scan, &next)) {
3076 __kmp_affinity.core_attr_gran.core_type = KMP_HW_CORE_TYPE_CORE;
3077 __kmp_affinity.core_attr_gran.valid = 1;
3079 }
else if (__kmp_match_str(
"intel_atom", scan, &next)) {
3080 __kmp_affinity.core_attr_gran.core_type = KMP_HW_CORE_TYPE_ATOM;
3081 __kmp_affinity.core_attr_gran.valid = 1;
3085 if (__kmp_match_str(
"eff", scan, &next)) {
3087 if (!isdigit(*next)) {
3088 __kmp_places_syntax_error_fallback(name, place.type);
3093 eff = __kmp_str_to_int(scan, *next);
3095 __kmp_places_syntax_error_fallback(name, place.type);
3098 if (eff >= KMP_HW_MAX_NUM_CORE_EFFS)
3099 eff = KMP_HW_MAX_NUM_CORE_EFFS - 1;
3100 __kmp_affinity.core_attr_gran.core_eff = eff;
3101 __kmp_affinity.core_attr_gran.valid = 1;
3104 if (!__kmp_affinity.core_attr_gran.valid) {
3105 __kmp_places_syntax_error_fallback(name, place.type);
3115 KMP_FOREACH_HW_TYPE(type) {
3116 const char *name = __kmp_hw_get_keyword(type,
true);
3117 if (__kmp_match_str(
"unknowns", scan, &next))
3119 if (__kmp_match_str(name, scan, &next)) {
3121 __kmp_places_set(affinity_compact, type);
3129 if (__kmp_match_str(
"core_types", scan, &next)) {
3131 if (*scan !=
'\0') {
3132 KMP_WARNING(ParseExtraCharsWarn, name, scan);
3134 __kmp_places_set(affinity_compact, KMP_HW_CORE);
3135 __kmp_affinity.flags.core_types_gran = 1;
3137 }
else if (__kmp_match_str(
"core_effs", scan, &next) ||
3138 __kmp_match_str(
"core_efficiencies", scan, &next)) {
3140 if (*scan !=
'\0') {
3141 KMP_WARNING(ParseExtraCharsWarn, name, scan);
3143 __kmp_places_set(affinity_compact, KMP_HW_CORE);
3144 __kmp_affinity.flags.core_effs_gran = 1;
3150 if (__kmp_affinity.proclist != NULL) {
3151 KMP_INTERNAL_FREE((
void *)__kmp_affinity.proclist);
3152 __kmp_affinity.proclist = NULL;
3154 if (__kmp_parse_place_list(name, value, &__kmp_affinity.proclist)) {
3155 __kmp_places_set(affinity_explicit, KMP_HW_THREAD);
3158 __kmp_places_syntax_error_fallback(name, KMP_HW_CORE);
3160 if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_default) {
3161 __kmp_nested_proc_bind.bind_types[0] = proc_bind_true;
3166 kmp_hw_t gran = __kmp_affinity.gran;
3167 if (__kmp_affinity.gran != KMP_HW_UNKNOWN) {
3168 gran = __kmp_affinity.gran;
3173 if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_default) {
3174 __kmp_nested_proc_bind.bind_types[0] = proc_bind_true;
3178 if (*scan ==
'\0') {
3184 __kmp_places_syntax_error_fallback(name, gran);
3192 count = __kmp_str_to_int(scan, *next);
3193 KMP_ASSERT(count >= 0);
3198 __kmp_places_syntax_error_fallback(name, gran);
3204 if (*scan !=
'\0') {
3205 KMP_WARNING(ParseExtraCharsWarn, name, scan);
3207 __kmp_affinity_num_places = count;
3210static void __kmp_stg_print_places(kmp_str_buf_t *buffer,
char const *name,
3212 enum affinity_type type = __kmp_affinity.type;
3213 const char *proclist = __kmp_affinity.proclist;
3214 kmp_hw_t gran = __kmp_affinity.gran;
3216 if (__kmp_env_format) {
3217 KMP_STR_BUF_PRINT_NAME;
3219 __kmp_str_buf_print(buffer,
" %s", name);
3221 if ((__kmp_nested_proc_bind.used == 0) ||
3222 (__kmp_nested_proc_bind.bind_types == NULL) ||
3223 (__kmp_nested_proc_bind.bind_types[0] == proc_bind_false)) {
3224 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
3225 }
else if (type == affinity_explicit) {
3226 if (proclist != NULL) {
3227 __kmp_str_buf_print(buffer,
"='%s'\n", proclist);
3229 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
3231 }
else if (type == affinity_compact) {
3233 if (__kmp_affinity.num_masks > 0) {
3234 num = __kmp_affinity.num_masks;
3235 }
else if (__kmp_affinity_num_places > 0) {
3236 num = __kmp_affinity_num_places;
3240 if (gran != KMP_HW_UNKNOWN) {
3242 if (__kmp_affinity.flags.core_types_gran) {
3243 __kmp_str_buf_print(buffer,
"='%s'\n",
"core_types");
3246 if (__kmp_affinity.flags.core_effs_gran) {
3247 __kmp_str_buf_print(buffer,
"='%s'\n",
"core_effs");
3252 const char *name = __kmp_hw_get_keyword(gran,
true);
3253 __kmp_str_buf_print(buffer,
"='%s", name);
3256 if (__kmp_affinity.core_attr_gran.valid) {
3257 kmp_hw_core_type_t ct =
3258 (kmp_hw_core_type_t)__kmp_affinity.core_attr_gran.core_type;
3259 int eff = __kmp_affinity.core_attr_gran.core_eff;
3260 if (ct != KMP_HW_CORE_TYPE_UNKNOWN) {
3261 const char *ct_name = __kmp_hw_get_core_type_keyword(ct);
3262 __kmp_str_buf_print(buffer,
":%s", name, ct_name);
3263 }
else if (eff >= 0 && eff < KMP_HW_MAX_NUM_CORE_EFFS) {
3264 __kmp_str_buf_print(buffer,
":eff%d", name, eff);
3270 __kmp_str_buf_print(buffer,
"(%d)", num);
3271 __kmp_str_buf_print(buffer,
"'\n");
3273 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
3276 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
3280static void __kmp_stg_parse_topology_method(
char const *name,
char const *value,
3282 if (__kmp_str_match(
"all", 1, value)) {
3283 __kmp_affinity_top_method = affinity_top_method_all;
3286 else if (__kmp_str_match(
"hwloc", 1, value)) {
3287 __kmp_affinity_top_method = affinity_top_method_hwloc;
3290#if KMP_ARCH_X86 || KMP_ARCH_X86_64
3291 else if (__kmp_str_match(
"cpuid_leaf31", 12, value) ||
3292 __kmp_str_match(
"cpuid 1f", 8, value) ||
3293 __kmp_str_match(
"cpuid 31", 8, value) ||
3294 __kmp_str_match(
"cpuid1f", 7, value) ||
3295 __kmp_str_match(
"cpuid31", 7, value) ||
3296 __kmp_str_match(
"leaf 1f", 7, value) ||
3297 __kmp_str_match(
"leaf 31", 7, value) ||
3298 __kmp_str_match(
"leaf1f", 6, value) ||
3299 __kmp_str_match(
"leaf31", 6, value)) {
3300 __kmp_affinity_top_method = affinity_top_method_x2apicid_1f;
3301 }
else if (__kmp_str_match(
"x2apic id", 9, value) ||
3302 __kmp_str_match(
"x2apic_id", 9, value) ||
3303 __kmp_str_match(
"x2apic-id", 9, value) ||
3304 __kmp_str_match(
"x2apicid", 8, value) ||
3305 __kmp_str_match(
"cpuid leaf 11", 13, value) ||
3306 __kmp_str_match(
"cpuid_leaf_11", 13, value) ||
3307 __kmp_str_match(
"cpuid-leaf-11", 13, value) ||
3308 __kmp_str_match(
"cpuid leaf11", 12, value) ||
3309 __kmp_str_match(
"cpuid_leaf11", 12, value) ||
3310 __kmp_str_match(
"cpuid-leaf11", 12, value) ||
3311 __kmp_str_match(
"cpuidleaf 11", 12, value) ||
3312 __kmp_str_match(
"cpuidleaf_11", 12, value) ||
3313 __kmp_str_match(
"cpuidleaf-11", 12, value) ||
3314 __kmp_str_match(
"cpuidleaf11", 11, value) ||
3315 __kmp_str_match(
"cpuid 11", 8, value) ||
3316 __kmp_str_match(
"cpuid_11", 8, value) ||
3317 __kmp_str_match(
"cpuid-11", 8, value) ||
3318 __kmp_str_match(
"cpuid11", 7, value) ||
3319 __kmp_str_match(
"leaf 11", 7, value) ||
3320 __kmp_str_match(
"leaf_11", 7, value) ||
3321 __kmp_str_match(
"leaf-11", 7, value) ||
3322 __kmp_str_match(
"leaf11", 6, value)) {
3323 __kmp_affinity_top_method = affinity_top_method_x2apicid;
3324 }
else if (__kmp_str_match(
"apic id", 7, value) ||
3325 __kmp_str_match(
"apic_id", 7, value) ||
3326 __kmp_str_match(
"apic-id", 7, value) ||
3327 __kmp_str_match(
"apicid", 6, value) ||
3328 __kmp_str_match(
"cpuid leaf 4", 12, value) ||
3329 __kmp_str_match(
"cpuid_leaf_4", 12, value) ||
3330 __kmp_str_match(
"cpuid-leaf-4", 12, value) ||
3331 __kmp_str_match(
"cpuid leaf4", 11, value) ||
3332 __kmp_str_match(
"cpuid_leaf4", 11, value) ||
3333 __kmp_str_match(
"cpuid-leaf4", 11, value) ||
3334 __kmp_str_match(
"cpuidleaf 4", 11, value) ||
3335 __kmp_str_match(
"cpuidleaf_4", 11, value) ||
3336 __kmp_str_match(
"cpuidleaf-4", 11, value) ||
3337 __kmp_str_match(
"cpuidleaf4", 10, value) ||
3338 __kmp_str_match(
"cpuid 4", 7, value) ||
3339 __kmp_str_match(
"cpuid_4", 7, value) ||
3340 __kmp_str_match(
"cpuid-4", 7, value) ||
3341 __kmp_str_match(
"cpuid4", 6, value) ||
3342 __kmp_str_match(
"leaf 4", 6, value) ||
3343 __kmp_str_match(
"leaf_4", 6, value) ||
3344 __kmp_str_match(
"leaf-4", 6, value) ||
3345 __kmp_str_match(
"leaf4", 5, value)) {
3346 __kmp_affinity_top_method = affinity_top_method_apicid;
3349 else if (__kmp_str_match(
"/proc/cpuinfo", 2, value) ||
3350 __kmp_str_match(
"cpuinfo", 5, value)) {
3351 __kmp_affinity_top_method = affinity_top_method_cpuinfo;
3353#if KMP_GROUP_AFFINITY
3354 else if (__kmp_str_match(
"group", 1, value)) {
3355 KMP_WARNING(StgDeprecatedValue, name, value,
"all");
3356 __kmp_affinity_top_method = affinity_top_method_group;
3359 else if (__kmp_str_match(
"flat", 1, value)) {
3360 __kmp_affinity_top_method = affinity_top_method_flat;
3362 KMP_WARNING(StgInvalidValue, name, value);
3366static void __kmp_stg_print_topology_method(kmp_str_buf_t *buffer,
3367 char const *name,
void *data) {
3368 char const *value = NULL;
3370 switch (__kmp_affinity_top_method) {
3371 case affinity_top_method_default:
3375 case affinity_top_method_all:
3379#if KMP_ARCH_X86 || KMP_ARCH_X86_64
3380 case affinity_top_method_x2apicid_1f:
3381 value =
"x2APIC id leaf 0x1f";
3384 case affinity_top_method_x2apicid:
3385 value =
"x2APIC id leaf 0xb";
3388 case affinity_top_method_apicid:
3394 case affinity_top_method_hwloc:
3399 case affinity_top_method_cpuinfo:
3403#if KMP_GROUP_AFFINITY
3404 case affinity_top_method_group:
3409 case affinity_top_method_flat:
3414 if (value != NULL) {
3415 __kmp_stg_print_str(buffer, name, value);
3420struct kmp_proc_bind_info_t {
3422 kmp_proc_bind_t proc_bind;
3424static kmp_proc_bind_info_t proc_bind_table[] = {
3425 {
"spread", proc_bind_spread},
3426 {
"true", proc_bind_spread},
3427 {
"close", proc_bind_close},
3429 {
"false", proc_bind_primary},
3430 {
"primary", proc_bind_primary}};
3431static void __kmp_stg_parse_teams_proc_bind(
char const *name,
char const *value,
3436 for (
size_t i = 0; i <
sizeof(proc_bind_table) /
sizeof(proc_bind_table[0]);
3438 if (__kmp_match_str(proc_bind_table[i].name, value, &end)) {
3439 __kmp_teams_proc_bind = proc_bind_table[i].proc_bind;
3445 KMP_WARNING(StgInvalidValue, name, value);
3448static void __kmp_stg_print_teams_proc_bind(kmp_str_buf_t *buffer,
3449 char const *name,
void *data) {
3450 const char *value = KMP_I18N_STR(NotDefined);
3451 for (
size_t i = 0; i <
sizeof(proc_bind_table) /
sizeof(proc_bind_table[0]);
3453 if (__kmp_teams_proc_bind == proc_bind_table[i].proc_bind) {
3454 value = proc_bind_table[i].name;
3458 __kmp_stg_print_str(buffer, name, value);
3464static void __kmp_stg_parse_proc_bind(
char const *name,
char const *value,
3466 kmp_setting_t **rivals = (kmp_setting_t **)data;
3469 rc = __kmp_stg_check_rivals(name, value, rivals);
3475 KMP_DEBUG_ASSERT((__kmp_nested_proc_bind.bind_types != NULL) &&
3476 (__kmp_nested_proc_bind.used > 0));
3478 const char *buf = value;
3482 if ((*buf >=
'0') && (*buf <=
'9')) {
3485 num = __kmp_str_to_int(buf, *next);
3486 KMP_ASSERT(num >= 0);
3494 if (__kmp_match_str(
"disabled", buf, &next)) {
3497#if KMP_AFFINITY_SUPPORTED
3498 __kmp_affinity.type = affinity_disabled;
3500 __kmp_nested_proc_bind.used = 1;
3501 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
3502 }
else if ((num == (
int)proc_bind_false) ||
3503 __kmp_match_str(
"false", buf, &next)) {
3506#if KMP_AFFINITY_SUPPORTED
3507 __kmp_affinity.type = affinity_none;
3509 __kmp_nested_proc_bind.used = 1;
3510 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
3511 }
else if ((num == (
int)proc_bind_true) ||
3512 __kmp_match_str(
"true", buf, &next)) {
3515 __kmp_nested_proc_bind.used = 1;
3516 __kmp_nested_proc_bind.bind_types[0] = proc_bind_true;
3521 for (scan = buf; *scan !=
'\0'; scan++) {
3528 if (__kmp_nested_proc_bind.size < nelem) {
3529 __kmp_nested_proc_bind.bind_types =
3530 (kmp_proc_bind_t *)KMP_INTERNAL_REALLOC(
3531 __kmp_nested_proc_bind.bind_types,
3532 sizeof(kmp_proc_bind_t) * nelem);
3533 if (__kmp_nested_proc_bind.bind_types == NULL) {
3534 KMP_FATAL(MemoryAllocFailed);
3536 __kmp_nested_proc_bind.size = nelem;
3538 __kmp_nested_proc_bind.used = nelem;
3540 if (nelem > 1 && !__kmp_dflt_max_active_levels_set)
3541 __kmp_dflt_max_active_levels = KMP_MAX_ACTIVE_LEVELS_LIMIT;
3546 enum kmp_proc_bind_t bind;
3548 if ((num == (
int)proc_bind_primary) ||
3549 __kmp_match_str(
"master", buf, &next) ||
3550 __kmp_match_str(
"primary", buf, &next)) {
3553 bind = proc_bind_primary;
3554 }
else if ((num == (
int)proc_bind_close) ||
3555 __kmp_match_str(
"close", buf, &next)) {
3558 bind = proc_bind_close;
3559 }
else if ((num == (
int)proc_bind_spread) ||
3560 __kmp_match_str(
"spread", buf, &next)) {
3563 bind = proc_bind_spread;
3565 KMP_WARNING(StgInvalidValue, name, value);
3566 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
3567 __kmp_nested_proc_bind.used = 1;
3571 __kmp_nested_proc_bind.bind_types[i++] = bind;
3575 KMP_DEBUG_ASSERT(*buf ==
',');
3580 if ((*buf >=
'0') && (*buf <=
'9')) {
3583 num = __kmp_str_to_int(buf, *next);
3584 KMP_ASSERT(num >= 0);
3594 KMP_WARNING(ParseExtraCharsWarn, name, buf);
3598static void __kmp_stg_print_proc_bind(kmp_str_buf_t *buffer,
char const *name,
3600 int nelem = __kmp_nested_proc_bind.used;
3601 if (__kmp_env_format) {
3602 KMP_STR_BUF_PRINT_NAME;
3604 __kmp_str_buf_print(buffer,
" %s", name);
3607 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
3610 __kmp_str_buf_print(buffer,
"='", name);
3611 for (i = 0; i < nelem; i++) {
3612 switch (__kmp_nested_proc_bind.bind_types[i]) {
3613 case proc_bind_false:
3614 __kmp_str_buf_print(buffer,
"false");
3617 case proc_bind_true:
3618 __kmp_str_buf_print(buffer,
"true");
3621 case proc_bind_primary:
3622 __kmp_str_buf_print(buffer,
"primary");
3625 case proc_bind_close:
3626 __kmp_str_buf_print(buffer,
"close");
3629 case proc_bind_spread:
3630 __kmp_str_buf_print(buffer,
"spread");
3633 case proc_bind_intel:
3634 __kmp_str_buf_print(buffer,
"intel");
3637 case proc_bind_default:
3638 __kmp_str_buf_print(buffer,
"default");
3641 if (i < nelem - 1) {
3642 __kmp_str_buf_print(buffer,
",");
3645 __kmp_str_buf_print(buffer,
"'\n");
3649static void __kmp_stg_parse_display_affinity(
char const *name,
3650 char const *value,
void *data) {
3651 __kmp_stg_parse_bool(name, value, &__kmp_display_affinity);
3653static void __kmp_stg_print_display_affinity(kmp_str_buf_t *buffer,
3654 char const *name,
void *data) {
3655 __kmp_stg_print_bool(buffer, name, __kmp_display_affinity);
3657static void __kmp_stg_parse_affinity_format(
char const *name,
char const *value,
3659 size_t length = KMP_STRLEN(value);
3660 __kmp_strncpy_truncate(__kmp_affinity_format, KMP_AFFINITY_FORMAT_SIZE, value,
3663static void __kmp_stg_print_affinity_format(kmp_str_buf_t *buffer,
3664 char const *name,
void *data) {
3665 if (__kmp_env_format) {
3666 KMP_STR_BUF_PRINT_NAME_EX(name);
3668 __kmp_str_buf_print(buffer,
" %s='", name);
3670 __kmp_str_buf_print(buffer,
"%s'\n", __kmp_affinity_format);
3692static void __kmp_stg_parse_allocator(
char const *name,
char const *value,
3694 const char *buf = value;
3695 const char *next, *scan, *start;
3697 omp_allocator_handle_t al;
3698 omp_memspace_handle_t ms = omp_default_mem_space;
3699 bool is_memspace =
false;
3700 int ntraits = 0, count = 0;
3704 const char *delim = strchr(buf,
':');
3705 const char *predef_mem_space = strstr(buf,
"mem_space");
3707 bool is_memalloc = (!predef_mem_space && !delim) ?
true :
false;
3712 for (scan = buf; *scan !=
'\0'; scan++) {
3717 omp_alloctrait_t *traits =
3718 (omp_alloctrait_t *)KMP_ALLOCA(ntraits *
sizeof(omp_alloctrait_t));
3721#define IS_POWER_OF_TWO(n) (((n) & ((n)-1)) == 0)
3723#define GET_NEXT(sentinel) \
3726 if (*next == sentinel) \
3732#define SKIP_PAIR(key) \
3734 char const str_delimiter[] = {',', 0}; \
3735 char *value = __kmp_str_token(CCAST(char *, scan), str_delimiter, \
3736 CCAST(char **, &next)); \
3737 KMP_WARNING(StgInvalidValue, key, value); \
3745 char const str_delimiter[] = {'=', 0}; \
3746 key = __kmp_str_token(CCAST(char *, start), str_delimiter, \
3747 CCAST(char **, &next)); \
3752 while (*next !=
'\0') {
3754 __kmp_match_str(
"fb_data", scan, &next)) {
3758 if (__kmp_match_str(
"omp_high_bw_mem_alloc", scan, &next)) {
3761 if (__kmp_memkind_available) {
3762 __kmp_def_allocator = omp_high_bw_mem_alloc;
3765 KMP_WARNING(OmpNoAllocator,
"omp_high_bw_mem_alloc");
3768 traits[count].key = omp_atk_fb_data;
3769 traits[count].value = RCAST(omp_uintptr_t, omp_high_bw_mem_alloc);
3771 }
else if (__kmp_match_str(
"omp_large_cap_mem_alloc", scan, &next)) {
3774 if (__kmp_memkind_available) {
3775 __kmp_def_allocator = omp_large_cap_mem_alloc;
3778 KMP_WARNING(OmpNoAllocator,
"omp_large_cap_mem_alloc");
3781 traits[count].key = omp_atk_fb_data;
3782 traits[count].value = RCAST(omp_uintptr_t, omp_large_cap_mem_alloc);
3784 }
else if (__kmp_match_str(
"omp_default_mem_alloc", scan, &next)) {
3788 traits[count].key = omp_atk_fb_data;
3789 traits[count].value = RCAST(omp_uintptr_t, omp_default_mem_alloc);
3791 }
else if (__kmp_match_str(
"omp_const_mem_alloc", scan, &next)) {
3794 KMP_WARNING(OmpNoAllocator,
"omp_const_mem_alloc");
3796 traits[count].key = omp_atk_fb_data;
3797 traits[count].value = RCAST(omp_uintptr_t, omp_const_mem_alloc);
3799 }
else if (__kmp_match_str(
"omp_low_lat_mem_alloc", scan, &next)) {
3802 KMP_WARNING(OmpNoAllocator,
"omp_low_lat_mem_alloc");
3804 traits[count].key = omp_atk_fb_data;
3805 traits[count].value = RCAST(omp_uintptr_t, omp_low_lat_mem_alloc);
3807 }
else if (__kmp_match_str(
"omp_cgroup_mem_alloc", scan, &next)) {
3810 KMP_WARNING(OmpNoAllocator,
"omp_cgroup_mem_alloc");
3812 traits[count].key = omp_atk_fb_data;
3813 traits[count].value = RCAST(omp_uintptr_t, omp_cgroup_mem_alloc);
3815 }
else if (__kmp_match_str(
"omp_pteam_mem_alloc", scan, &next)) {
3818 KMP_WARNING(OmpNoAllocator,
"omp_pteam_mem_alloc");
3820 traits[count].key = omp_atk_fb_data;
3821 traits[count].value = RCAST(omp_uintptr_t, omp_pteam_mem_alloc);
3823 }
else if (__kmp_match_str(
"omp_thread_mem_alloc", scan, &next)) {
3826 KMP_WARNING(OmpNoAllocator,
"omp_thread_mem_alloc");
3828 traits[count].key = omp_atk_fb_data;
3829 traits[count].value = RCAST(omp_uintptr_t, omp_thread_mem_alloc);
3839 __kmp_def_allocator = omp_default_mem_alloc;
3840 if (next == buf || *next !=
'\0') {
3842 KMP_WARNING(StgInvalidValue, name, value);
3847 if (count == ntraits)
3853 if (__kmp_match_str(
"omp_default_mem_space", scan, &next)) {
3855 ms = omp_default_mem_space;
3856 }
else if (__kmp_match_str(
"omp_large_cap_mem_space", scan, &next)) {
3858 ms = omp_large_cap_mem_space;
3859 }
else if (__kmp_match_str(
"omp_const_mem_space", scan, &next)) {
3861 ms = omp_const_mem_space;
3862 }
else if (__kmp_match_str(
"omp_high_bw_mem_space", scan, &next)) {
3864 ms = omp_high_bw_mem_space;
3865 }
else if (__kmp_match_str(
"omp_low_lat_mem_space", scan, &next)) {
3867 ms = omp_low_lat_mem_space;
3869 __kmp_def_allocator = omp_default_mem_alloc;
3870 if (next == buf || *next !=
'\0') {
3872 KMP_WARNING(StgInvalidValue, name, value);
3881 if (__kmp_match_str(
"sync_hint", scan, &next)) {
3883 traits[count].key = omp_atk_sync_hint;
3884 if (__kmp_match_str(
"contended", scan, &next)) {
3885 traits[count].value = omp_atv_contended;
3886 }
else if (__kmp_match_str(
"uncontended", scan, &next)) {
3887 traits[count].value = omp_atv_uncontended;
3888 }
else if (__kmp_match_str(
"serialized", scan, &next)) {
3889 traits[count].value = omp_atv_serialized;
3890 }
else if (__kmp_match_str(
"private", scan, &next)) {
3891 traits[count].value = omp_atv_private;
3897 }
else if (__kmp_match_str(
"alignment", scan, &next)) {
3899 if (!isdigit(*next)) {
3905 int n = __kmp_str_to_int(scan,
',');
3906 if (n < 0 || !IS_POWER_OF_TWO(n)) {
3911 traits[count].key = omp_atk_alignment;
3912 traits[count].value = n;
3913 }
else if (__kmp_match_str(
"access", scan, &next)) {
3915 traits[count].key = omp_atk_access;
3916 if (__kmp_match_str(
"all", scan, &next)) {
3917 traits[count].value = omp_atv_all;
3918 }
else if (__kmp_match_str(
"cgroup", scan, &next)) {
3919 traits[count].value = omp_atv_cgroup;
3920 }
else if (__kmp_match_str(
"pteam", scan, &next)) {
3921 traits[count].value = omp_atv_pteam;
3922 }
else if (__kmp_match_str(
"thread", scan, &next)) {
3923 traits[count].value = omp_atv_thread;
3929 }
else if (__kmp_match_str(
"pool_size", scan, &next)) {
3931 if (!isdigit(*next)) {
3937 int n = __kmp_str_to_int(scan,
',');
3943 traits[count].key = omp_atk_pool_size;
3944 traits[count].value = n;
3945 }
else if (__kmp_match_str(
"fallback", scan, &next)) {
3947 traits[count].key = omp_atk_fallback;
3948 if (__kmp_match_str(
"default_mem_fb", scan, &next)) {
3949 traits[count].value = omp_atv_default_mem_fb;
3950 }
else if (__kmp_match_str(
"null_fb", scan, &next)) {
3951 traits[count].value = omp_atv_null_fb;
3952 }
else if (__kmp_match_str(
"abort_fb", scan, &next)) {
3953 traits[count].value = omp_atv_abort_fb;
3954 }
else if (__kmp_match_str(
"allocator_fb", scan, &next)) {
3955 traits[count].value = omp_atv_allocator_fb;
3961 }
else if (__kmp_match_str(
"pinned", scan, &next)) {
3963 traits[count].key = omp_atk_pinned;
3964 if (__kmp_str_match_true(next)) {
3965 traits[count].value = omp_atv_true;
3966 }
else if (__kmp_str_match_false(next)) {
3967 traits[count].value = omp_atv_false;
3973 }
else if (__kmp_match_str(
"partition", scan, &next)) {
3975 traits[count].key = omp_atk_partition;
3976 if (__kmp_match_str(
"environment", scan, &next)) {
3977 traits[count].value = omp_atv_environment;
3978 }
else if (__kmp_match_str(
"nearest", scan, &next)) {
3979 traits[count].value = omp_atv_nearest;
3980 }
else if (__kmp_match_str(
"blocked", scan, &next)) {
3981 traits[count].value = omp_atv_blocked;
3982 }
else if (__kmp_match_str(
"interleaved", scan, &next)) {
3983 traits[count].value = omp_atv_interleaved;
3996 if (count == ntraits)
4002 al = __kmpc_init_allocator(__kmp_get_gtid(), ms, ntraits, traits);
4003 __kmp_def_allocator = (al == omp_null_allocator) ? omp_default_mem_alloc : al;
4006static void __kmp_stg_print_allocator(kmp_str_buf_t *buffer,
char const *name,
4008 if (__kmp_def_allocator == omp_default_mem_alloc) {
4009 __kmp_stg_print_str(buffer, name,
"omp_default_mem_alloc");
4010 }
else if (__kmp_def_allocator == omp_high_bw_mem_alloc) {
4011 __kmp_stg_print_str(buffer, name,
"omp_high_bw_mem_alloc");
4012 }
else if (__kmp_def_allocator == omp_large_cap_mem_alloc) {
4013 __kmp_stg_print_str(buffer, name,
"omp_large_cap_mem_alloc");
4014 }
else if (__kmp_def_allocator == omp_const_mem_alloc) {
4015 __kmp_stg_print_str(buffer, name,
"omp_const_mem_alloc");
4016 }
else if (__kmp_def_allocator == omp_low_lat_mem_alloc) {
4017 __kmp_stg_print_str(buffer, name,
"omp_low_lat_mem_alloc");
4018 }
else if (__kmp_def_allocator == omp_cgroup_mem_alloc) {
4019 __kmp_stg_print_str(buffer, name,
"omp_cgroup_mem_alloc");
4020 }
else if (__kmp_def_allocator == omp_pteam_mem_alloc) {
4021 __kmp_stg_print_str(buffer, name,
"omp_pteam_mem_alloc");
4022 }
else if (__kmp_def_allocator == omp_thread_mem_alloc) {
4023 __kmp_stg_print_str(buffer, name,
"omp_thread_mem_alloc");
4030static void __kmp_stg_parse_omp_dynamic(
char const *name,
char const *value,
4032 __kmp_stg_parse_bool(name, value, &(__kmp_global.g.g_dynamic));
4035static void __kmp_stg_print_omp_dynamic(kmp_str_buf_t *buffer,
char const *name,
4037 __kmp_stg_print_bool(buffer, name, __kmp_global.g.g_dynamic);
4040static void __kmp_stg_parse_kmp_dynamic_mode(
char const *name,
4041 char const *value,
void *data) {
4042 if (TCR_4(__kmp_init_parallel)) {
4043 KMP_WARNING(EnvParallelWarn, name);
4044 __kmp_env_toPrint(name, 0);
4047#ifdef USE_LOAD_BALANCE
4048 else if (__kmp_str_match(
"load balance", 2, value) ||
4049 __kmp_str_match(
"load_balance", 2, value) ||
4050 __kmp_str_match(
"load-balance", 2, value) ||
4051 __kmp_str_match(
"loadbalance", 2, value) ||
4052 __kmp_str_match(
"balance", 1, value)) {
4053 __kmp_global.g.g_dynamic_mode = dynamic_load_balance;
4056 else if (__kmp_str_match(
"thread limit", 1, value) ||
4057 __kmp_str_match(
"thread_limit", 1, value) ||
4058 __kmp_str_match(
"thread-limit", 1, value) ||
4059 __kmp_str_match(
"threadlimit", 1, value) ||
4060 __kmp_str_match(
"limit", 2, value)) {
4061 __kmp_global.g.g_dynamic_mode = dynamic_thread_limit;
4062 }
else if (__kmp_str_match(
"random", 1, value)) {
4063 __kmp_global.g.g_dynamic_mode = dynamic_random;
4065 KMP_WARNING(StgInvalidValue, name, value);
4069static void __kmp_stg_print_kmp_dynamic_mode(kmp_str_buf_t *buffer,
4070 char const *name,
void *data) {
4072 if (__kmp_global.g.g_dynamic_mode == dynamic_default) {
4073 __kmp_str_buf_print(buffer,
" %s: %s \n", name, KMP_I18N_STR(NotDefined));
4075#ifdef USE_LOAD_BALANCE
4076 else if (__kmp_global.g.g_dynamic_mode == dynamic_load_balance) {
4077 __kmp_stg_print_str(buffer, name,
"load balance");
4080 else if (__kmp_global.g.g_dynamic_mode == dynamic_thread_limit) {
4081 __kmp_stg_print_str(buffer, name,
"thread limit");
4082 }
else if (__kmp_global.g.g_dynamic_mode == dynamic_random) {
4083 __kmp_stg_print_str(buffer, name,
"random");
4090#ifdef USE_LOAD_BALANCE
4095static void __kmp_stg_parse_ld_balance_interval(
char const *name,
4096 char const *value,
void *data) {
4097 double interval = __kmp_convert_to_double(value);
4098 if (interval >= 0) {
4099 __kmp_load_balance_interval = interval;
4101 KMP_WARNING(StgInvalidValue, name, value);
4105static void __kmp_stg_print_ld_balance_interval(kmp_str_buf_t *buffer,
4106 char const *name,
void *data) {
4108 __kmp_str_buf_print(buffer,
" %s=%8.6f\n", name,
4109 __kmp_load_balance_interval);
4118static void __kmp_stg_parse_init_at_fork(
char const *name,
char const *value,
4120 __kmp_stg_parse_bool(name, value, &__kmp_need_register_atfork);
4121 if (__kmp_need_register_atfork) {
4122 __kmp_need_register_atfork_specified = TRUE;
4126static void __kmp_stg_print_init_at_fork(kmp_str_buf_t *buffer,
4127 char const *name,
void *data) {
4128 __kmp_stg_print_bool(buffer, name, __kmp_need_register_atfork_specified);
4134static void __kmp_stg_parse_schedule(
char const *name,
char const *value,
4137 if (value != NULL) {
4138 size_t length = KMP_STRLEN(value);
4139 if (length > INT_MAX) {
4140 KMP_WARNING(LongValue, name);
4142 const char *semicolon;
4143 if (value[length - 1] ==
'"' || value[length - 1] ==
'\'')
4144 KMP_WARNING(UnbalancedQuotes, name);
4148 semicolon = strchr(value,
';');
4149 if (*value && semicolon != value) {
4150 const char *comma = strchr(value,
',');
4157 if (!__kmp_strcasecmp_with_sentinel(
"static", value, sentinel)) {
4158 if (!__kmp_strcasecmp_with_sentinel(
"greedy", comma,
';')) {
4159 __kmp_static = kmp_sch_static_greedy;
4161 }
else if (!__kmp_strcasecmp_with_sentinel(
"balanced", comma,
4163 __kmp_static = kmp_sch_static_balanced;
4166 }
else if (!__kmp_strcasecmp_with_sentinel(
"guided", value,
4168 if (!__kmp_strcasecmp_with_sentinel(
"iterative", comma,
';')) {
4169 __kmp_guided = kmp_sch_guided_iterative_chunked;
4171 }
else if (!__kmp_strcasecmp_with_sentinel(
"analytical", comma,
4174 __kmp_guided = kmp_sch_guided_analytical_chunked;
4178 KMP_WARNING(InvalidClause, name, value);
4180 KMP_WARNING(EmptyClause, name);
4181 }
while ((value = semicolon ? semicolon + 1 : NULL));
4187static void __kmp_stg_print_schedule(kmp_str_buf_t *buffer,
char const *name,
4189 if (__kmp_env_format) {
4190 KMP_STR_BUF_PRINT_NAME_EX(name);
4192 __kmp_str_buf_print(buffer,
" %s='", name);
4194 if (__kmp_static == kmp_sch_static_greedy) {
4195 __kmp_str_buf_print(buffer,
"%s",
"static,greedy");
4196 }
else if (__kmp_static == kmp_sch_static_balanced) {
4197 __kmp_str_buf_print(buffer,
"%s",
"static,balanced");
4199 if (__kmp_guided == kmp_sch_guided_iterative_chunked) {
4200 __kmp_str_buf_print(buffer,
";%s'\n",
"guided,iterative");
4201 }
else if (__kmp_guided == kmp_sch_guided_analytical_chunked) {
4202 __kmp_str_buf_print(buffer,
";%s'\n",
"guided,analytical");
4209static inline void __kmp_omp_schedule_restore() {
4210#if KMP_USE_HIER_SCHED
4211 __kmp_hier_scheds.deallocate();
4221static const char *__kmp_parse_single_omp_schedule(
const char *name,
4223 bool parse_hier =
false) {
4225 const char *ptr = value;
4232 while (*delim !=
',' && *delim !=
':' && *delim !=
'\0')
4234#if KMP_USE_HIER_SCHED
4235 kmp_hier_layer_e layer = kmp_hier_layer_e::LAYER_THREAD;
4237 if (*delim ==
',') {
4238 if (!__kmp_strcasecmp_with_sentinel(
"L1", ptr,
',')) {
4239 layer = kmp_hier_layer_e::LAYER_L1;
4240 }
else if (!__kmp_strcasecmp_with_sentinel(
"L2", ptr,
',')) {
4241 layer = kmp_hier_layer_e::LAYER_L2;
4242 }
else if (!__kmp_strcasecmp_with_sentinel(
"L3", ptr,
',')) {
4243 layer = kmp_hier_layer_e::LAYER_L3;
4244 }
else if (!__kmp_strcasecmp_with_sentinel(
"NUMA", ptr,
',')) {
4245 layer = kmp_hier_layer_e::LAYER_NUMA;
4248 if (layer != kmp_hier_layer_e::LAYER_THREAD && *delim !=
',') {
4250 KMP_WARNING(StgInvalidValue, name, value);
4251 __kmp_omp_schedule_restore();
4253 }
else if (layer != kmp_hier_layer_e::LAYER_THREAD) {
4255 while (*delim !=
',' && *delim !=
':' && *delim !=
'\0')
4262 if (*delim ==
':') {
4263 if (!__kmp_strcasecmp_with_sentinel(
"monotonic", ptr, *delim)) {
4266 while (*delim !=
',' && *delim !=
':' && *delim !=
'\0')
4268 }
else if (!__kmp_strcasecmp_with_sentinel(
"nonmonotonic", ptr, *delim)) {
4271 while (*delim !=
',' && *delim !=
':' && *delim !=
'\0')
4273 }
else if (!parse_hier) {
4275 KMP_WARNING(StgInvalidValue, name, value);
4276 __kmp_omp_schedule_restore();
4281 if (!__kmp_strcasecmp_with_sentinel(
"dynamic", ptr, *delim))
4282 sched = kmp_sch_dynamic_chunked;
4283 else if (!__kmp_strcasecmp_with_sentinel(
"guided", ptr, *delim))
4286 else if (!__kmp_strcasecmp_with_sentinel(
"auto", ptr, *delim))
4288 else if (!__kmp_strcasecmp_with_sentinel(
"trapezoidal", ptr, *delim))
4289 sched = kmp_sch_trapezoidal;
4290 else if (!__kmp_strcasecmp_with_sentinel(
"static", ptr, *delim))
4292#if KMP_STATIC_STEAL_ENABLED
4293 else if (!__kmp_strcasecmp_with_sentinel(
"static_steal", ptr, *delim)) {
4295 sched = kmp_sch_dynamic_chunked;
4301 KMP_WARNING(StgInvalidValue, name, value);
4302 __kmp_omp_schedule_restore();
4307 if (*delim ==
',') {
4310 if (!isdigit(*ptr)) {
4312 KMP_WARNING(StgInvalidValue, name, value);
4313 __kmp_omp_schedule_restore();
4319 __kmp_msg(kmp_ms_warning, KMP_MSG(IgnoreChunk, name, delim),
4323 sched = kmp_sch_static_chunked;
4324 chunk = __kmp_str_to_int(delim + 1, *ptr);
4326 chunk = KMP_DEFAULT_CHUNK;
4327 __kmp_msg(kmp_ms_warning, KMP_MSG(InvalidChunk, name, delim),
4329 KMP_INFORM(Using_int_Value, name, __kmp_chunk);
4338 }
else if (chunk > KMP_MAX_CHUNK) {
4339 chunk = KMP_MAX_CHUNK;
4340 __kmp_msg(kmp_ms_warning, KMP_MSG(LargeChunk, name, delim),
4342 KMP_INFORM(Using_int_Value, name, chunk);
4349 SCHEDULE_SET_MODIFIERS(sched, sched_modifier);
4351#if KMP_USE_HIER_SCHED
4352 if (layer != kmp_hier_layer_e::LAYER_THREAD) {
4353 __kmp_hier_scheds.append(sched, chunk, layer);
4357 __kmp_chunk = chunk;
4358 __kmp_sched = sched;
4363static void __kmp_stg_parse_omp_schedule(
char const *name,
char const *value,
4366 const char *ptr = value;
4369 length = KMP_STRLEN(value);
4371 if (value[length - 1] ==
'"' || value[length - 1] ==
'\'')
4372 KMP_WARNING(UnbalancedQuotes, name);
4374#if KMP_USE_HIER_SCHED
4375 if (!__kmp_strcasecmp_with_sentinel(
"EXPERIMENTAL", ptr,
' ')) {
4378 while ((ptr = __kmp_parse_single_omp_schedule(name, ptr,
true))) {
4379 while (*ptr ==
' ' || *ptr ==
'\t' || *ptr ==
':')
4386 __kmp_parse_single_omp_schedule(name, ptr);
4388 KMP_WARNING(EmptyString, name);
4390#if KMP_USE_HIER_SCHED
4391 __kmp_hier_scheds.sort();
4393 K_DIAG(1, (
"__kmp_static == %d\n", __kmp_static))
4394 K_DIAG(1, (
"__kmp_guided == %d\n", __kmp_guided))
4395 K_DIAG(1, (
"__kmp_sched == %d\n", __kmp_sched))
4396 K_DIAG(1, (
"__kmp_chunk == %d\n", __kmp_chunk))
4399static void __kmp_stg_print_omp_schedule(kmp_str_buf_t *buffer,
4400 char const *name,
void *data) {
4401 if (__kmp_env_format) {
4402 KMP_STR_BUF_PRINT_NAME_EX(name);
4404 __kmp_str_buf_print(buffer,
" %s='", name);
4406 enum sched_type sched = SCHEDULE_WITHOUT_MODIFIERS(__kmp_sched);
4407 if (SCHEDULE_HAS_MONOTONIC(__kmp_sched)) {
4408 __kmp_str_buf_print(buffer,
"monotonic:");
4409 }
else if (SCHEDULE_HAS_NONMONOTONIC(__kmp_sched)) {
4410 __kmp_str_buf_print(buffer,
"nonmonotonic:");
4414 case kmp_sch_dynamic_chunked:
4415 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"dynamic", __kmp_chunk);
4417 case kmp_sch_guided_iterative_chunked:
4418 case kmp_sch_guided_analytical_chunked:
4419 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"guided", __kmp_chunk);
4421 case kmp_sch_trapezoidal:
4422 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"trapezoidal", __kmp_chunk);
4425 case kmp_sch_static_chunked:
4426 case kmp_sch_static_balanced:
4427 case kmp_sch_static_greedy:
4428 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"static", __kmp_chunk);
4430 case kmp_sch_static_steal:
4431 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"static_steal", __kmp_chunk);
4434 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"auto", __kmp_chunk);
4439 case kmp_sch_dynamic_chunked:
4440 __kmp_str_buf_print(buffer,
"%s'\n",
"dynamic");
4442 case kmp_sch_guided_iterative_chunked:
4443 case kmp_sch_guided_analytical_chunked:
4444 __kmp_str_buf_print(buffer,
"%s'\n",
"guided");
4446 case kmp_sch_trapezoidal:
4447 __kmp_str_buf_print(buffer,
"%s'\n",
"trapezoidal");
4450 case kmp_sch_static_chunked:
4451 case kmp_sch_static_balanced:
4452 case kmp_sch_static_greedy:
4453 __kmp_str_buf_print(buffer,
"%s'\n",
"static");
4455 case kmp_sch_static_steal:
4456 __kmp_str_buf_print(buffer,
"%s'\n",
"static_steal");
4459 __kmp_str_buf_print(buffer,
"%s'\n",
"auto");
4465#if KMP_USE_HIER_SCHED
4468static void __kmp_stg_parse_kmp_hand_thread(
char const *name,
char const *value,
4470 __kmp_stg_parse_bool(name, value, &(__kmp_dispatch_hand_threading));
4473static void __kmp_stg_print_kmp_hand_thread(kmp_str_buf_t *buffer,
4474 char const *name,
void *data) {
4475 __kmp_stg_print_bool(buffer, name, __kmp_dispatch_hand_threading);
4481static void __kmp_stg_parse_kmp_force_monotonic(
char const *name,
4482 char const *value,
void *data) {
4483 __kmp_stg_parse_bool(name, value, &(__kmp_force_monotonic));
4486static void __kmp_stg_print_kmp_force_monotonic(kmp_str_buf_t *buffer,
4487 char const *name,
void *data) {
4488 __kmp_stg_print_bool(buffer, name, __kmp_force_monotonic);
4494static void __kmp_stg_parse_atomic_mode(
char const *name,
char const *value,
4500#ifdef KMP_GOMP_COMPAT
4503 __kmp_stg_parse_int(name, value, 0, max, &mode);
4508 __kmp_atomic_mode = mode;
4512static void __kmp_stg_print_atomic_mode(kmp_str_buf_t *buffer,
char const *name,
4514 __kmp_stg_print_int(buffer, name, __kmp_atomic_mode);
4520static void __kmp_stg_parse_consistency_check(
char const *name,
4521 char const *value,
void *data) {
4522 if (!__kmp_strcasecmp_with_sentinel(
"all", value, 0)) {
4528 __kmp_env_consistency_check = TRUE;
4529 }
else if (!__kmp_strcasecmp_with_sentinel(
"none", value, 0)) {
4530 __kmp_env_consistency_check = FALSE;
4532 KMP_WARNING(StgInvalidValue, name, value);
4536static void __kmp_stg_print_consistency_check(kmp_str_buf_t *buffer,
4537 char const *name,
void *data) {
4539 const char *value = NULL;
4541 if (__kmp_env_consistency_check) {
4547 if (value != NULL) {
4548 __kmp_stg_print_str(buffer, name, value);
4559static void __kmp_stg_parse_itt_prepare_delay(
char const *name,
4560 char const *value,
void *data) {
4564 __kmp_stg_parse_int(name, value, 0, INT_MAX, &delay);
4565 __kmp_itt_prepare_delay = delay;
4568static void __kmp_stg_print_itt_prepare_delay(kmp_str_buf_t *buffer,
4569 char const *name,
void *data) {
4570 __kmp_stg_print_uint64(buffer, name, __kmp_itt_prepare_delay);
4580static void __kmp_stg_parse_malloc_pool_incr(
char const *name,
4581 char const *value,
void *data) {
4582 __kmp_stg_parse_size(name, value, KMP_MIN_MALLOC_POOL_INCR,
4583 KMP_MAX_MALLOC_POOL_INCR, NULL, &__kmp_malloc_pool_incr,
4587static void __kmp_stg_print_malloc_pool_incr(kmp_str_buf_t *buffer,
4588 char const *name,
void *data) {
4589 __kmp_stg_print_size(buffer, name, __kmp_malloc_pool_incr);
4598static void __kmp_stg_parse_par_range_env(
char const *name,
char const *value,
4600 __kmp_stg_parse_par_range(name, value, &__kmp_par_range,
4601 __kmp_par_range_routine, __kmp_par_range_filename,
4602 &__kmp_par_range_lb, &__kmp_par_range_ub);
4605static void __kmp_stg_print_par_range_env(kmp_str_buf_t *buffer,
4606 char const *name,
void *data) {
4607 if (__kmp_par_range != 0) {
4608 __kmp_stg_print_str(buffer, name, par_range_to_print);
4617static void __kmp_stg_parse_gtid_mode(
char const *name,
char const *value,
4627#ifdef KMP_TDATA_GTID
4630 __kmp_stg_parse_int(name, value, 0, max, &mode);
4634 __kmp_adjust_gtid_mode = TRUE;
4636 __kmp_gtid_mode = mode;
4637 __kmp_adjust_gtid_mode = FALSE;
4641static void __kmp_stg_print_gtid_mode(kmp_str_buf_t *buffer,
char const *name,
4643 if (__kmp_adjust_gtid_mode) {
4644 __kmp_stg_print_int(buffer, name, 0);
4646 __kmp_stg_print_int(buffer, name, __kmp_gtid_mode);
4653static void __kmp_stg_parse_lock_block(
char const *name,
char const *value,
4655 __kmp_stg_parse_int(name, value, 0, KMP_INT_MAX, &__kmp_num_locks_in_block);
4658static void __kmp_stg_print_lock_block(kmp_str_buf_t *buffer,
char const *name,
4660 __kmp_stg_print_int(buffer, name, __kmp_num_locks_in_block);
4666#if KMP_USE_DYNAMIC_LOCK
4667#define KMP_STORE_LOCK_SEQ(a) (__kmp_user_lock_seq = lockseq_##a)
4669#define KMP_STORE_LOCK_SEQ(a)
4672static void __kmp_stg_parse_lock_kind(
char const *name,
char const *value,
4674 if (__kmp_init_user_locks) {
4675 KMP_WARNING(EnvLockWarn, name);
4679 if (__kmp_str_match(
"tas", 2, value) ||
4680 __kmp_str_match(
"test and set", 2, value) ||
4681 __kmp_str_match(
"test_and_set", 2, value) ||
4682 __kmp_str_match(
"test-and-set", 2, value) ||
4683 __kmp_str_match(
"test andset", 2, value) ||
4684 __kmp_str_match(
"test_andset", 2, value) ||
4685 __kmp_str_match(
"test-andset", 2, value) ||
4686 __kmp_str_match(
"testand set", 2, value) ||
4687 __kmp_str_match(
"testand_set", 2, value) ||
4688 __kmp_str_match(
"testand-set", 2, value) ||
4689 __kmp_str_match(
"testandset", 2, value)) {
4690 __kmp_user_lock_kind = lk_tas;
4691 KMP_STORE_LOCK_SEQ(tas);
4694 else if (__kmp_str_match(
"futex", 1, value)) {
4695 if (__kmp_futex_determine_capable()) {
4696 __kmp_user_lock_kind = lk_futex;
4697 KMP_STORE_LOCK_SEQ(futex);
4699 KMP_WARNING(FutexNotSupported, name, value);
4703 else if (__kmp_str_match(
"ticket", 2, value)) {
4704 __kmp_user_lock_kind = lk_ticket;
4705 KMP_STORE_LOCK_SEQ(ticket);
4706 }
else if (__kmp_str_match(
"queuing", 1, value) ||
4707 __kmp_str_match(
"queue", 1, value)) {
4708 __kmp_user_lock_kind = lk_queuing;
4709 KMP_STORE_LOCK_SEQ(queuing);
4710 }
else if (__kmp_str_match(
"drdpa ticket", 1, value) ||
4711 __kmp_str_match(
"drdpa_ticket", 1, value) ||
4712 __kmp_str_match(
"drdpa-ticket", 1, value) ||
4713 __kmp_str_match(
"drdpaticket", 1, value) ||
4714 __kmp_str_match(
"drdpa", 1, value)) {
4715 __kmp_user_lock_kind = lk_drdpa;
4716 KMP_STORE_LOCK_SEQ(drdpa);
4718#if KMP_USE_ADAPTIVE_LOCKS
4719 else if (__kmp_str_match(
"adaptive", 1, value)) {
4720 if (__kmp_cpuinfo.flags.rtm) {
4721 __kmp_user_lock_kind = lk_adaptive;
4722 KMP_STORE_LOCK_SEQ(adaptive);
4724 KMP_WARNING(AdaptiveNotSupported, name, value);
4725 __kmp_user_lock_kind = lk_queuing;
4726 KMP_STORE_LOCK_SEQ(queuing);
4730#if KMP_USE_DYNAMIC_LOCK && KMP_USE_TSX
4731 else if (__kmp_str_match(
"rtm_queuing", 1, value)) {
4732 if (__kmp_cpuinfo.flags.rtm) {
4733 __kmp_user_lock_kind = lk_rtm_queuing;
4734 KMP_STORE_LOCK_SEQ(rtm_queuing);
4736 KMP_WARNING(AdaptiveNotSupported, name, value);
4737 __kmp_user_lock_kind = lk_queuing;
4738 KMP_STORE_LOCK_SEQ(queuing);
4740 }
else if (__kmp_str_match(
"rtm_spin", 1, value)) {
4741 if (__kmp_cpuinfo.flags.rtm) {
4742 __kmp_user_lock_kind = lk_rtm_spin;
4743 KMP_STORE_LOCK_SEQ(rtm_spin);
4745 KMP_WARNING(AdaptiveNotSupported, name, value);
4746 __kmp_user_lock_kind = lk_tas;
4747 KMP_STORE_LOCK_SEQ(queuing);
4749 }
else if (__kmp_str_match(
"hle", 1, value)) {
4750 __kmp_user_lock_kind = lk_hle;
4751 KMP_STORE_LOCK_SEQ(hle);
4755 KMP_WARNING(StgInvalidValue, name, value);
4759static void __kmp_stg_print_lock_kind(kmp_str_buf_t *buffer,
char const *name,
4761 const char *value = NULL;
4763 switch (__kmp_user_lock_kind) {
4778#if KMP_USE_DYNAMIC_LOCK && KMP_USE_TSX
4779 case lk_rtm_queuing:
4780 value =
"rtm_queuing";
4803#if KMP_USE_ADAPTIVE_LOCKS
4810 if (value != NULL) {
4811 __kmp_stg_print_str(buffer, name, value);
4820static void __kmp_stg_parse_spin_backoff_params(
const char *name,
4821 const char *value,
void *data) {
4822 const char *next = value;
4825 int prev_comma = FALSE;
4828 kmp_uint32 max_backoff = __kmp_spin_backoff_params.max_backoff;
4829 kmp_uint32 min_tick = __kmp_spin_backoff_params.min_tick;
4833 for (i = 0; i < 3; i++) {
4836 if (*next ==
'\0') {
4841 if (((*next < '0' || *next >
'9') && *next !=
',') || total > 2) {
4842 KMP_WARNING(EnvSyntaxError, name, value);
4848 if (total == 0 || prev_comma) {
4856 if (*next >=
'0' && *next <=
'9') {
4858 const char *buf = next;
4859 char const *msg = NULL;
4864 const char *tmp = next;
4866 if ((*next ==
' ' || *next ==
'\t') && (*tmp >=
'0' && *tmp <=
'9')) {
4867 KMP_WARNING(EnvSpacesNotAllowed, name, value);
4871 num = __kmp_str_to_int(buf, *next);
4873 msg = KMP_I18N_STR(ValueTooSmall);
4875 }
else if (num > KMP_INT_MAX) {
4876 msg = KMP_I18N_STR(ValueTooLarge);
4881 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
4882 KMP_INFORM(Using_int_Value, name, num);
4886 }
else if (total == 2) {
4891 KMP_DEBUG_ASSERT(total > 0);
4893 KMP_WARNING(EnvSyntaxError, name, value);
4896 __kmp_spin_backoff_params.max_backoff = max_backoff;
4897 __kmp_spin_backoff_params.min_tick = min_tick;
4900static void __kmp_stg_print_spin_backoff_params(kmp_str_buf_t *buffer,
4901 char const *name,
void *data) {
4902 if (__kmp_env_format) {
4903 KMP_STR_BUF_PRINT_NAME_EX(name);
4905 __kmp_str_buf_print(buffer,
" %s='", name);
4907 __kmp_str_buf_print(buffer,
"%d,%d'\n", __kmp_spin_backoff_params.max_backoff,
4908 __kmp_spin_backoff_params.min_tick);
4911#if KMP_USE_ADAPTIVE_LOCKS
4918static void __kmp_stg_parse_adaptive_lock_props(
const char *name,
4919 const char *value,
void *data) {
4920 int max_retries = 0;
4921 int max_badness = 0;
4923 const char *next = value;
4926 int prev_comma = FALSE;
4932 for (i = 0; i < 3; i++) {
4935 if (*next ==
'\0') {
4940 if (((*next < '0' || *next >
'9') && *next !=
',') || total > 2) {
4941 KMP_WARNING(EnvSyntaxError, name, value);
4947 if (total == 0 || prev_comma) {
4955 if (*next >=
'0' && *next <=
'9') {
4957 const char *buf = next;
4958 char const *msg = NULL;
4963 const char *tmp = next;
4965 if ((*next ==
' ' || *next ==
'\t') && (*tmp >=
'0' && *tmp <=
'9')) {
4966 KMP_WARNING(EnvSpacesNotAllowed, name, value);
4970 num = __kmp_str_to_int(buf, *next);
4972 msg = KMP_I18N_STR(ValueTooSmall);
4974 }
else if (num > KMP_INT_MAX) {
4975 msg = KMP_I18N_STR(ValueTooLarge);
4980 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
4981 KMP_INFORM(Using_int_Value, name, num);
4985 }
else if (total == 2) {
4990 KMP_DEBUG_ASSERT(total > 0);
4992 KMP_WARNING(EnvSyntaxError, name, value);
4995 __kmp_adaptive_backoff_params.max_soft_retries = max_retries;
4996 __kmp_adaptive_backoff_params.max_badness = max_badness;
4999static void __kmp_stg_print_adaptive_lock_props(kmp_str_buf_t *buffer,
5000 char const *name,
void *data) {
5001 if (__kmp_env_format) {
5002 KMP_STR_BUF_PRINT_NAME_EX(name);
5004 __kmp_str_buf_print(buffer,
" %s='", name);
5006 __kmp_str_buf_print(buffer,
"%d,%d'\n",
5007 __kmp_adaptive_backoff_params.max_soft_retries,
5008 __kmp_adaptive_backoff_params.max_badness);
5011#if KMP_DEBUG_ADAPTIVE_LOCKS
5013static void __kmp_stg_parse_speculative_statsfile(
char const *name,
5016 __kmp_stg_parse_file(name, value,
"",
5017 CCAST(
char **, &__kmp_speculative_statsfile));
5020static void __kmp_stg_print_speculative_statsfile(kmp_str_buf_t *buffer,
5023 if (__kmp_str_match(
"-", 0, __kmp_speculative_statsfile)) {
5024 __kmp_stg_print_str(buffer, name,
"stdout");
5026 __kmp_stg_print_str(buffer, name, __kmp_speculative_statsfile);
5042static kmp_hw_t __kmp_hw_subset_break_tie(
const kmp_hw_t *possible,
5043 size_t num_possible) {
5044 for (
size_t i = 0; i < num_possible; ++i) {
5045 if (possible[i] == KMP_HW_THREAD)
5046 return KMP_HW_THREAD;
5047 else if (possible[i] == KMP_HW_CORE)
5049 else if (possible[i] == KMP_HW_SOCKET)
5050 return KMP_HW_SOCKET;
5052 return KMP_HW_UNKNOWN;
5059static kmp_hw_t __kmp_stg_parse_hw_subset_name(
char const *token) {
5060 size_t index, num_possible, token_length;
5061 kmp_hw_t possible[KMP_HW_LAST];
5067 while (isalnum(*end) || *end ==
'_') {
5074 KMP_FOREACH_HW_TYPE(type) { possible[num_possible++] = type; }
5081 while (num_possible > 1 && index < token_length) {
5082 size_t n = num_possible;
5083 char token_char = (char)toupper(token[index]);
5084 for (
size_t i = 0; i < n; ++i) {
5086 kmp_hw_t type = possible[i];
5087 s = __kmp_hw_get_keyword(type,
false);
5088 if (index < KMP_STRLEN(s)) {
5089 char c = (char)toupper(s[index]);
5091 if (c != token_char) {
5092 possible[i] = KMP_HW_UNKNOWN;
5099 for (
size_t i = 0; i < n; ++i) {
5100 if (possible[i] != KMP_HW_UNKNOWN) {
5101 kmp_hw_t temp = possible[i];
5102 possible[i] = possible[start];
5103 possible[start] = temp;
5107 KMP_ASSERT(start == num_possible);
5113 if (num_possible > 1)
5114 return __kmp_hw_subset_break_tie(possible, num_possible);
5115 if (num_possible == 1)
5117 return KMP_HW_UNKNOWN;
5122#define MAX_T_LEVEL KMP_HW_LAST
5123#define MAX_STR_LEN 512
5124static void __kmp_stg_parse_hw_subset(
char const *name,
char const *value,
5128 kmp_setting_t **rivals = (kmp_setting_t **)data;
5129 if (strcmp(name,
"KMP_PLACE_THREADS") == 0) {
5130 KMP_INFORM(EnvVarDeprecated, name,
"KMP_HW_SUBSET");
5132 if (__kmp_stg_check_rivals(name, value, rivals)) {
5136 char *components[MAX_T_LEVEL];
5137 char const *digits =
"0123456789";
5138 char input[MAX_STR_LEN];
5139 size_t len = 0, mlen = MAX_STR_LEN;
5141 bool absolute =
false;
5143 char *pos = CCAST(
char *, value);
5144 while (*pos && mlen) {
5146 if (len == 0 && *pos ==
':') {
5149 input[len] = (char)(toupper(*pos));
5150 if (input[len] ==
'X')
5152 if (input[len] ==
'O' && strchr(digits, *(pos + 1)))
5160 if (len == 0 || mlen == 0) {
5166 components[level++] = pos;
5167 while ((pos = strchr(pos,
','))) {
5168 if (level >= MAX_T_LEVEL)
5171 components[level++] = ++pos;
5174 __kmp_hw_subset = kmp_hw_subset_t::allocate();
5176 __kmp_hw_subset->set_absolute();
5179 for (
int i = 0; i < level; ++i) {
5181 char *core_components[MAX_T_LEVEL];
5183 pos = components[i];
5184 core_components[core_level++] = pos;
5185 while ((pos = strchr(pos,
'&'))) {
5186 if (core_level >= MAX_T_LEVEL)
5189 core_components[core_level++] = ++pos;
5192 for (
int j = 0; j < core_level; ++j) {
5199 if (isdigit(*core_components[j])) {
5200 num = atoi(core_components[j]);
5204 pos = core_components[j] + strspn(core_components[j], digits);
5205 }
else if (*core_components[j] ==
'*') {
5206 num = kmp_hw_subset_t::USE_ALL;
5207 pos = core_components[j] + 1;
5209 num = kmp_hw_subset_t::USE_ALL;
5210 pos = core_components[j];
5213 offset_ptr = strchr(core_components[j],
'@');
5214 attr_ptr = strchr(core_components[j],
':');
5217 offset = atoi(offset_ptr + 1);
5223#if KMP_ARCH_X86 || KMP_ARCH_X86_64
5224 if (__kmp_str_match(
"intel_core", -1, attr_ptr + 1)) {
5225 attr.set_core_type(KMP_HW_CORE_TYPE_CORE);
5226 }
else if (__kmp_str_match(
"intel_atom", -1, attr_ptr + 1)) {
5227 attr.set_core_type(KMP_HW_CORE_TYPE_ATOM);
5230 if (__kmp_str_match(
"eff", 3, attr_ptr + 1)) {
5231 const char *number = attr_ptr + 1;
5233 while (isalpha(*number))
5235 if (!isdigit(*number)) {
5238 int efficiency = atoi(number);
5239 attr.set_core_eff(efficiency);
5246 kmp_hw_t type = __kmp_stg_parse_hw_subset_name(pos);
5247 if (type == KMP_HW_UNKNOWN) {
5251 if (attr && type != KMP_HW_CORE)
5254 if (type != KMP_HW_CORE && __kmp_hw_subset->specified(type)) {
5257 __kmp_hw_subset->push_back(num, type, offset, attr);
5262 KMP_WARNING(AffHWSubsetInvalid, name, value);
5263 if (__kmp_hw_subset) {
5264 kmp_hw_subset_t::deallocate(__kmp_hw_subset);
5265 __kmp_hw_subset =
nullptr;
5270static void __kmp_stg_print_hw_subset(kmp_str_buf_t *buffer,
char const *name,
5274 if (!__kmp_hw_subset)
5276 __kmp_str_buf_init(&buf);
5277 if (__kmp_env_format)
5278 KMP_STR_BUF_PRINT_NAME_EX(name);
5280 __kmp_str_buf_print(buffer,
" %s='", name);
5282 depth = __kmp_hw_subset->get_depth();
5283 for (
int i = 0; i < depth; ++i) {
5284 const auto &item = __kmp_hw_subset->at(i);
5286 __kmp_str_buf_print(&buf,
"%c",
',');
5287 for (
int j = 0; j < item.num_attrs; ++j) {
5288 __kmp_str_buf_print(&buf,
"%s%d%s", (j > 0 ?
"&" :
""), item.num[j],
5289 __kmp_hw_get_keyword(item.type));
5290 if (item.attr[j].is_core_type_valid())
5291 __kmp_str_buf_print(
5293 __kmp_hw_get_core_type_keyword(item.attr[j].get_core_type()));
5294 if (item.attr[j].is_core_eff_valid())
5295 __kmp_str_buf_print(&buf,
":eff%d", item.attr[j].get_core_eff());
5297 __kmp_str_buf_print(&buf,
"@%d", item.offset[j]);
5300 __kmp_str_buf_print(buffer,
"%s'\n", buf.str);
5301 __kmp_str_buf_free(&buf);
5308static void __kmp_stg_parse_forkjoin_frames(
char const *name,
char const *value,
5310 __kmp_stg_parse_bool(name, value, &__kmp_forkjoin_frames);
5313static void __kmp_stg_print_forkjoin_frames(kmp_str_buf_t *buffer,
5314 char const *name,
void *data) {
5315 __kmp_stg_print_bool(buffer, name, __kmp_forkjoin_frames);
5321static void __kmp_stg_parse_forkjoin_frames_mode(
char const *name,
5324 __kmp_stg_parse_int(name, value, 0, 3, &__kmp_forkjoin_frames_mode);
5327static void __kmp_stg_print_forkjoin_frames_mode(kmp_str_buf_t *buffer,
5328 char const *name,
void *data) {
5329 __kmp_stg_print_int(buffer, name, __kmp_forkjoin_frames_mode);
5336static void __kmp_stg_parse_task_throttling(
char const *name,
char const *value,
5338 __kmp_stg_parse_bool(name, value, &__kmp_enable_task_throttling);
5341static void __kmp_stg_print_task_throttling(kmp_str_buf_t *buffer,
5342 char const *name,
void *data) {
5343 __kmp_stg_print_bool(buffer, name, __kmp_enable_task_throttling);
5346#if KMP_HAVE_MWAIT || KMP_HAVE_UMWAIT
5350static void __kmp_stg_parse_user_level_mwait(
char const *name,
5351 char const *value,
void *data) {
5352 __kmp_stg_parse_bool(name, value, &__kmp_user_level_mwait);
5355static void __kmp_stg_print_user_level_mwait(kmp_str_buf_t *buffer,
5356 char const *name,
void *data) {
5357 __kmp_stg_print_bool(buffer, name, __kmp_user_level_mwait);
5363static void __kmp_stg_parse_mwait_hints(
char const *name,
char const *value,
5365 __kmp_stg_parse_int(name, value, 0, INT_MAX, &__kmp_mwait_hints);
5368static void __kmp_stg_print_mwait_hints(kmp_str_buf_t *buffer,
char const *name,
5370 __kmp_stg_print_int(buffer, name, __kmp_mwait_hints);
5380static void __kmp_stg_parse_tpause(
char const *name,
char const *value,
5382 __kmp_stg_parse_int(name, value, 0, INT_MAX, &__kmp_tpause_state);
5383 if (__kmp_tpause_state != 0) {
5385 if (__kmp_tpause_state == 2)
5386 __kmp_tpause_hint = 0;
5390static void __kmp_stg_print_tpause(kmp_str_buf_t *buffer,
char const *name,
5392 __kmp_stg_print_int(buffer, name, __kmp_tpause_state);
5399static void __kmp_stg_parse_omp_display_env(
char const *name,
char const *value,
5401 if (__kmp_str_match(
"VERBOSE", 1, value)) {
5402 __kmp_display_env_verbose = TRUE;
5404 __kmp_stg_parse_bool(name, value, &__kmp_display_env);
5408static void __kmp_stg_print_omp_display_env(kmp_str_buf_t *buffer,
5409 char const *name,
void *data) {
5410 if (__kmp_display_env_verbose) {
5411 __kmp_stg_print_str(buffer, name,
"VERBOSE");
5413 __kmp_stg_print_bool(buffer, name, __kmp_display_env);
5417static void __kmp_stg_parse_omp_cancellation(
char const *name,
5418 char const *value,
void *data) {
5419 if (TCR_4(__kmp_init_parallel)) {
5420 KMP_WARNING(EnvParallelWarn, name);
5423 __kmp_stg_parse_bool(name, value, &__kmp_omp_cancellation);
5426static void __kmp_stg_print_omp_cancellation(kmp_str_buf_t *buffer,
5427 char const *name,
void *data) {
5428 __kmp_stg_print_bool(buffer, name, __kmp_omp_cancellation);
5434static void __kmp_stg_parse_omp_tool(
char const *name,
char const *value,
5436 __kmp_stg_parse_bool(name, value, &__kmp_tool);
5439static void __kmp_stg_print_omp_tool(kmp_str_buf_t *buffer,
char const *name,
5441 if (__kmp_env_format) {
5442 KMP_STR_BUF_PRINT_BOOL_EX(name, __kmp_tool,
"enabled",
"disabled");
5444 __kmp_str_buf_print(buffer,
" %s=%s\n", name,
5445 __kmp_tool ?
"enabled" :
"disabled");
5449char *__kmp_tool_libraries = NULL;
5451static void __kmp_stg_parse_omp_tool_libraries(
char const *name,
5452 char const *value,
void *data) {
5453 __kmp_stg_parse_str(name, value, &__kmp_tool_libraries);
5456static void __kmp_stg_print_omp_tool_libraries(kmp_str_buf_t *buffer,
5457 char const *name,
void *data) {
5458 if (__kmp_tool_libraries)
5459 __kmp_stg_print_str(buffer, name, __kmp_tool_libraries);
5461 if (__kmp_env_format) {
5462 KMP_STR_BUF_PRINT_NAME;
5464 __kmp_str_buf_print(buffer,
" %s", name);
5466 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
5470char *__kmp_tool_verbose_init = NULL;
5472static void __kmp_stg_parse_omp_tool_verbose_init(
char const *name,
5475 __kmp_stg_parse_str(name, value, &__kmp_tool_verbose_init);
5478static void __kmp_stg_print_omp_tool_verbose_init(kmp_str_buf_t *buffer,
5481 if (__kmp_tool_verbose_init)
5482 __kmp_stg_print_str(buffer, name, __kmp_tool_verbose_init);
5484 if (__kmp_env_format) {
5485 KMP_STR_BUF_PRINT_NAME;
5487 __kmp_str_buf_print(buffer,
" %s", name);
5489 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
5497static kmp_setting_t __kmp_stg_table[] = {
5499 {
"KMP_ALL_THREADS", __kmp_stg_parse_device_thread_limit, NULL, NULL, 0, 0},
5500 {
"KMP_BLOCKTIME", __kmp_stg_parse_blocktime, __kmp_stg_print_blocktime,
5502 {
"KMP_USE_YIELD", __kmp_stg_parse_use_yield, __kmp_stg_print_use_yield,
5504 {
"KMP_DUPLICATE_LIB_OK", __kmp_stg_parse_duplicate_lib_ok,
5505 __kmp_stg_print_duplicate_lib_ok, NULL, 0, 0},
5506 {
"KMP_LIBRARY", __kmp_stg_parse_wait_policy, __kmp_stg_print_wait_policy,
5508 {
"KMP_DEVICE_THREAD_LIMIT", __kmp_stg_parse_device_thread_limit,
5509 __kmp_stg_print_device_thread_limit, NULL, 0, 0},
5511 {
"KMP_MONITOR_STACKSIZE", __kmp_stg_parse_monitor_stacksize,
5512 __kmp_stg_print_monitor_stacksize, NULL, 0, 0},
5514 {
"KMP_SETTINGS", __kmp_stg_parse_settings, __kmp_stg_print_settings, NULL,
5516 {
"KMP_STACKOFFSET", __kmp_stg_parse_stackoffset,
5517 __kmp_stg_print_stackoffset, NULL, 0, 0},
5518 {
"KMP_STACKSIZE", __kmp_stg_parse_stacksize, __kmp_stg_print_stacksize,
5520 {
"KMP_STACKPAD", __kmp_stg_parse_stackpad, __kmp_stg_print_stackpad, NULL,
5522 {
"KMP_VERSION", __kmp_stg_parse_version, __kmp_stg_print_version, NULL, 0,
5524 {
"KMP_WARNINGS", __kmp_stg_parse_warnings, __kmp_stg_print_warnings, NULL,
5527 {
"KMP_NESTING_MODE", __kmp_stg_parse_nesting_mode,
5528 __kmp_stg_print_nesting_mode, NULL, 0, 0},
5529 {
"OMP_NESTED", __kmp_stg_parse_nested, __kmp_stg_print_nested, NULL, 0, 0},
5530 {
"OMP_NUM_THREADS", __kmp_stg_parse_num_threads,
5531 __kmp_stg_print_num_threads, NULL, 0, 0},
5532 {
"OMP_STACKSIZE", __kmp_stg_parse_stacksize, __kmp_stg_print_stacksize,
5535 {
"KMP_TASKING", __kmp_stg_parse_tasking, __kmp_stg_print_tasking, NULL, 0,
5537 {
"KMP_TASK_STEALING_CONSTRAINT", __kmp_stg_parse_task_stealing,
5538 __kmp_stg_print_task_stealing, NULL, 0, 0},
5539 {
"OMP_MAX_ACTIVE_LEVELS", __kmp_stg_parse_max_active_levels,
5540 __kmp_stg_print_max_active_levels, NULL, 0, 0},
5541 {
"OMP_DEFAULT_DEVICE", __kmp_stg_parse_default_device,
5542 __kmp_stg_print_default_device, NULL, 0, 0},
5543 {
"OMP_TARGET_OFFLOAD", __kmp_stg_parse_target_offload,
5544 __kmp_stg_print_target_offload, NULL, 0, 0},
5545 {
"OMP_MAX_TASK_PRIORITY", __kmp_stg_parse_max_task_priority,
5546 __kmp_stg_print_max_task_priority, NULL, 0, 0},
5547 {
"KMP_TASKLOOP_MIN_TASKS", __kmp_stg_parse_taskloop_min_tasks,
5548 __kmp_stg_print_taskloop_min_tasks, NULL, 0, 0},
5549 {
"OMP_THREAD_LIMIT", __kmp_stg_parse_thread_limit,
5550 __kmp_stg_print_thread_limit, NULL, 0, 0},
5551 {
"KMP_TEAMS_THREAD_LIMIT", __kmp_stg_parse_teams_thread_limit,
5552 __kmp_stg_print_teams_thread_limit, NULL, 0, 0},
5553 {
"OMP_NUM_TEAMS", __kmp_stg_parse_nteams, __kmp_stg_print_nteams, NULL, 0,
5555 {
"OMP_TEAMS_THREAD_LIMIT", __kmp_stg_parse_teams_th_limit,
5556 __kmp_stg_print_teams_th_limit, NULL, 0, 0},
5557 {
"OMP_WAIT_POLICY", __kmp_stg_parse_wait_policy,
5558 __kmp_stg_print_wait_policy, NULL, 0, 0},
5559 {
"KMP_DISP_NUM_BUFFERS", __kmp_stg_parse_disp_buffers,
5560 __kmp_stg_print_disp_buffers, NULL, 0, 0},
5561#if KMP_NESTED_HOT_TEAMS
5562 {
"KMP_HOT_TEAMS_MAX_LEVEL", __kmp_stg_parse_hot_teams_level,
5563 __kmp_stg_print_hot_teams_level, NULL, 0, 0},
5564 {
"KMP_HOT_TEAMS_MODE", __kmp_stg_parse_hot_teams_mode,
5565 __kmp_stg_print_hot_teams_mode, NULL, 0, 0},
5568#if KMP_HANDLE_SIGNALS
5569 {
"KMP_HANDLE_SIGNALS", __kmp_stg_parse_handle_signals,
5570 __kmp_stg_print_handle_signals, NULL, 0, 0},
5573#if KMP_ARCH_X86 || KMP_ARCH_X86_64
5574 {
"KMP_INHERIT_FP_CONTROL", __kmp_stg_parse_inherit_fp_control,
5575 __kmp_stg_print_inherit_fp_control, NULL, 0, 0},
5578#ifdef KMP_GOMP_COMPAT
5579 {
"GOMP_STACKSIZE", __kmp_stg_parse_stacksize, NULL, NULL, 0, 0},
5583 {
"KMP_A_DEBUG", __kmp_stg_parse_a_debug, __kmp_stg_print_a_debug, NULL, 0,
5585 {
"KMP_B_DEBUG", __kmp_stg_parse_b_debug, __kmp_stg_print_b_debug, NULL, 0,
5587 {
"KMP_C_DEBUG", __kmp_stg_parse_c_debug, __kmp_stg_print_c_debug, NULL, 0,
5589 {
"KMP_D_DEBUG", __kmp_stg_parse_d_debug, __kmp_stg_print_d_debug, NULL, 0,
5591 {
"KMP_E_DEBUG", __kmp_stg_parse_e_debug, __kmp_stg_print_e_debug, NULL, 0,
5593 {
"KMP_F_DEBUG", __kmp_stg_parse_f_debug, __kmp_stg_print_f_debug, NULL, 0,
5595 {
"KMP_DEBUG", __kmp_stg_parse_debug, NULL, NULL, 0, 0},
5596 {
"KMP_DEBUG_BUF", __kmp_stg_parse_debug_buf, __kmp_stg_print_debug_buf,
5598 {
"KMP_DEBUG_BUF_ATOMIC", __kmp_stg_parse_debug_buf_atomic,
5599 __kmp_stg_print_debug_buf_atomic, NULL, 0, 0},
5600 {
"KMP_DEBUG_BUF_CHARS", __kmp_stg_parse_debug_buf_chars,
5601 __kmp_stg_print_debug_buf_chars, NULL, 0, 0},
5602 {
"KMP_DEBUG_BUF_LINES", __kmp_stg_parse_debug_buf_lines,
5603 __kmp_stg_print_debug_buf_lines, NULL, 0, 0},
5604 {
"KMP_DIAG", __kmp_stg_parse_diag, __kmp_stg_print_diag, NULL, 0, 0},
5606 {
"KMP_PAR_RANGE", __kmp_stg_parse_par_range_env,
5607 __kmp_stg_print_par_range_env, NULL, 0, 0},
5610 {
"KMP_ALIGN_ALLOC", __kmp_stg_parse_align_alloc,
5611 __kmp_stg_print_align_alloc, NULL, 0, 0},
5613 {
"KMP_PLAIN_BARRIER", __kmp_stg_parse_barrier_branch_bit,
5614 __kmp_stg_print_barrier_branch_bit, NULL, 0, 0},
5615 {
"KMP_PLAIN_BARRIER_PATTERN", __kmp_stg_parse_barrier_pattern,
5616 __kmp_stg_print_barrier_pattern, NULL, 0, 0},
5617 {
"KMP_FORKJOIN_BARRIER", __kmp_stg_parse_barrier_branch_bit,
5618 __kmp_stg_print_barrier_branch_bit, NULL, 0, 0},
5619 {
"KMP_FORKJOIN_BARRIER_PATTERN", __kmp_stg_parse_barrier_pattern,
5620 __kmp_stg_print_barrier_pattern, NULL, 0, 0},
5621#if KMP_FAST_REDUCTION_BARRIER
5622 {
"KMP_REDUCTION_BARRIER", __kmp_stg_parse_barrier_branch_bit,
5623 __kmp_stg_print_barrier_branch_bit, NULL, 0, 0},
5624 {
"KMP_REDUCTION_BARRIER_PATTERN", __kmp_stg_parse_barrier_pattern,
5625 __kmp_stg_print_barrier_pattern, NULL, 0, 0},
5628 {
"KMP_ABORT_DELAY", __kmp_stg_parse_abort_delay,
5629 __kmp_stg_print_abort_delay, NULL, 0, 0},
5630 {
"KMP_CPUINFO_FILE", __kmp_stg_parse_cpuinfo_file,
5631 __kmp_stg_print_cpuinfo_file, NULL, 0, 0},
5632 {
"KMP_FORCE_REDUCTION", __kmp_stg_parse_force_reduction,
5633 __kmp_stg_print_force_reduction, NULL, 0, 0},
5634 {
"KMP_DETERMINISTIC_REDUCTION", __kmp_stg_parse_force_reduction,
5635 __kmp_stg_print_force_reduction, NULL, 0, 0},
5636 {
"KMP_STORAGE_MAP", __kmp_stg_parse_storage_map,
5637 __kmp_stg_print_storage_map, NULL, 0, 0},
5638 {
"KMP_ALL_THREADPRIVATE", __kmp_stg_parse_all_threadprivate,
5639 __kmp_stg_print_all_threadprivate, NULL, 0, 0},
5640 {
"KMP_FOREIGN_THREADS_THREADPRIVATE",
5641 __kmp_stg_parse_foreign_threads_threadprivate,
5642 __kmp_stg_print_foreign_threads_threadprivate, NULL, 0, 0},
5644#if KMP_AFFINITY_SUPPORTED
5645 {
"KMP_AFFINITY", __kmp_stg_parse_affinity, __kmp_stg_print_affinity, NULL,
5647 {
"KMP_HIDDEN_HELPER_AFFINITY", __kmp_stg_parse_hh_affinity,
5648 __kmp_stg_print_hh_affinity, NULL, 0, 0},
5649#ifdef KMP_GOMP_COMPAT
5650 {
"GOMP_CPU_AFFINITY", __kmp_stg_parse_gomp_cpu_affinity, NULL,
5653 {
"OMP_PROC_BIND", __kmp_stg_parse_proc_bind, __kmp_stg_print_proc_bind,
5655 {
"KMP_TEAMS_PROC_BIND", __kmp_stg_parse_teams_proc_bind,
5656 __kmp_stg_print_teams_proc_bind, NULL, 0, 0},
5657 {
"OMP_PLACES", __kmp_stg_parse_places, __kmp_stg_print_places, NULL, 0, 0},
5658 {
"KMP_TOPOLOGY_METHOD", __kmp_stg_parse_topology_method,
5659 __kmp_stg_print_topology_method, NULL, 0, 0},
5665 {
"OMP_PROC_BIND", __kmp_stg_parse_proc_bind, __kmp_stg_print_proc_bind,
5669 {
"OMP_DISPLAY_AFFINITY", __kmp_stg_parse_display_affinity,
5670 __kmp_stg_print_display_affinity, NULL, 0, 0},
5671 {
"OMP_AFFINITY_FORMAT", __kmp_stg_parse_affinity_format,
5672 __kmp_stg_print_affinity_format, NULL, 0, 0},
5673 {
"KMP_INIT_AT_FORK", __kmp_stg_parse_init_at_fork,
5674 __kmp_stg_print_init_at_fork, NULL, 0, 0},
5675 {
"KMP_SCHEDULE", __kmp_stg_parse_schedule, __kmp_stg_print_schedule, NULL,
5677 {
"OMP_SCHEDULE", __kmp_stg_parse_omp_schedule, __kmp_stg_print_omp_schedule,
5679#if KMP_USE_HIER_SCHED
5680 {
"KMP_DISP_HAND_THREAD", __kmp_stg_parse_kmp_hand_thread,
5681 __kmp_stg_print_kmp_hand_thread, NULL, 0, 0},
5683 {
"KMP_FORCE_MONOTONIC_DYNAMIC_SCHEDULE",
5684 __kmp_stg_parse_kmp_force_monotonic, __kmp_stg_print_kmp_force_monotonic,
5686 {
"KMP_ATOMIC_MODE", __kmp_stg_parse_atomic_mode,
5687 __kmp_stg_print_atomic_mode, NULL, 0, 0},
5688 {
"KMP_CONSISTENCY_CHECK", __kmp_stg_parse_consistency_check,
5689 __kmp_stg_print_consistency_check, NULL, 0, 0},
5691#if USE_ITT_BUILD && USE_ITT_NOTIFY
5692 {
"KMP_ITT_PREPARE_DELAY", __kmp_stg_parse_itt_prepare_delay,
5693 __kmp_stg_print_itt_prepare_delay, NULL, 0, 0},
5695 {
"KMP_MALLOC_POOL_INCR", __kmp_stg_parse_malloc_pool_incr,
5696 __kmp_stg_print_malloc_pool_incr, NULL, 0, 0},
5697 {
"KMP_GTID_MODE", __kmp_stg_parse_gtid_mode, __kmp_stg_print_gtid_mode,
5699 {
"OMP_DYNAMIC", __kmp_stg_parse_omp_dynamic, __kmp_stg_print_omp_dynamic,
5701 {
"KMP_DYNAMIC_MODE", __kmp_stg_parse_kmp_dynamic_mode,
5702 __kmp_stg_print_kmp_dynamic_mode, NULL, 0, 0},
5704#ifdef USE_LOAD_BALANCE
5705 {
"KMP_LOAD_BALANCE_INTERVAL", __kmp_stg_parse_ld_balance_interval,
5706 __kmp_stg_print_ld_balance_interval, NULL, 0, 0},
5709 {
"KMP_NUM_LOCKS_IN_BLOCK", __kmp_stg_parse_lock_block,
5710 __kmp_stg_print_lock_block, NULL, 0, 0},
5711 {
"KMP_LOCK_KIND", __kmp_stg_parse_lock_kind, __kmp_stg_print_lock_kind,
5713 {
"KMP_SPIN_BACKOFF_PARAMS", __kmp_stg_parse_spin_backoff_params,
5714 __kmp_stg_print_spin_backoff_params, NULL, 0, 0},
5715#if KMP_USE_ADAPTIVE_LOCKS
5716 {
"KMP_ADAPTIVE_LOCK_PROPS", __kmp_stg_parse_adaptive_lock_props,
5717 __kmp_stg_print_adaptive_lock_props, NULL, 0, 0},
5718#if KMP_DEBUG_ADAPTIVE_LOCKS
5719 {
"KMP_SPECULATIVE_STATSFILE", __kmp_stg_parse_speculative_statsfile,
5720 __kmp_stg_print_speculative_statsfile, NULL, 0, 0},
5723 {
"KMP_PLACE_THREADS", __kmp_stg_parse_hw_subset, __kmp_stg_print_hw_subset,
5725 {
"KMP_HW_SUBSET", __kmp_stg_parse_hw_subset, __kmp_stg_print_hw_subset,
5728 {
"KMP_FORKJOIN_FRAMES", __kmp_stg_parse_forkjoin_frames,
5729 __kmp_stg_print_forkjoin_frames, NULL, 0, 0},
5730 {
"KMP_FORKJOIN_FRAMES_MODE", __kmp_stg_parse_forkjoin_frames_mode,
5731 __kmp_stg_print_forkjoin_frames_mode, NULL, 0, 0},
5733 {
"KMP_ENABLE_TASK_THROTTLING", __kmp_stg_parse_task_throttling,
5734 __kmp_stg_print_task_throttling, NULL, 0, 0},
5736 {
"OMP_DISPLAY_ENV", __kmp_stg_parse_omp_display_env,
5737 __kmp_stg_print_omp_display_env, NULL, 0, 0},
5738 {
"OMP_CANCELLATION", __kmp_stg_parse_omp_cancellation,
5739 __kmp_stg_print_omp_cancellation, NULL, 0, 0},
5740 {
"OMP_ALLOCATOR", __kmp_stg_parse_allocator, __kmp_stg_print_allocator,
5742 {
"LIBOMP_USE_HIDDEN_HELPER_TASK", __kmp_stg_parse_use_hidden_helper,
5743 __kmp_stg_print_use_hidden_helper, NULL, 0, 0},
5744 {
"LIBOMP_NUM_HIDDEN_HELPER_THREADS",
5745 __kmp_stg_parse_num_hidden_helper_threads,
5746 __kmp_stg_print_num_hidden_helper_threads, NULL, 0, 0},
5748 {
"KMP_MAX_TDGS", __kmp_stg_parse_max_tdgs, __kmp_std_print_max_tdgs, NULL,
5750 {
"KMP_TDG_DOT", __kmp_stg_parse_tdg_dot, __kmp_stg_print_tdg_dot, NULL, 0, 0},
5754 {
"OMP_TOOL", __kmp_stg_parse_omp_tool, __kmp_stg_print_omp_tool, NULL, 0,
5756 {
"OMP_TOOL_LIBRARIES", __kmp_stg_parse_omp_tool_libraries,
5757 __kmp_stg_print_omp_tool_libraries, NULL, 0, 0},
5758 {
"OMP_TOOL_VERBOSE_INIT", __kmp_stg_parse_omp_tool_verbose_init,
5759 __kmp_stg_print_omp_tool_verbose_init, NULL, 0, 0},
5762#if KMP_HAVE_MWAIT || KMP_HAVE_UMWAIT
5763 {
"KMP_USER_LEVEL_MWAIT", __kmp_stg_parse_user_level_mwait,
5764 __kmp_stg_print_user_level_mwait, NULL, 0, 0},
5765 {
"KMP_MWAIT_HINTS", __kmp_stg_parse_mwait_hints,
5766 __kmp_stg_print_mwait_hints, NULL, 0, 0},
5770 {
"KMP_TPAUSE", __kmp_stg_parse_tpause, __kmp_stg_print_tpause, NULL, 0, 0},
5772 {
"", NULL, NULL, NULL, 0, 0}};
5774static int const __kmp_stg_count =
5775 sizeof(__kmp_stg_table) /
sizeof(kmp_setting_t);
5777static inline kmp_setting_t *__kmp_stg_find(
char const *name) {
5781 for (i = 0; i < __kmp_stg_count; ++i) {
5782 if (strcmp(__kmp_stg_table[i].name, name) == 0) {
5783 return &__kmp_stg_table[i];
5791static int __kmp_stg_cmp(
void const *_a,
void const *_b) {
5792 const kmp_setting_t *a = RCAST(
const kmp_setting_t *, _a);
5793 const kmp_setting_t *b = RCAST(
const kmp_setting_t *, _b);
5797 if (strcmp(a->name,
"KMP_AFFINITY") == 0) {
5798 if (strcmp(b->name,
"KMP_AFFINITY") == 0) {
5802 }
else if (strcmp(b->name,
"KMP_AFFINITY") == 0) {
5805 return strcmp(a->name, b->name);
5808static void __kmp_stg_init(
void) {
5810 static int initialized = 0;
5815 qsort(__kmp_stg_table, __kmp_stg_count - 1,
sizeof(kmp_setting_t),
5819 kmp_setting_t *kmp_stacksize =
5820 __kmp_stg_find(
"KMP_STACKSIZE");
5821#ifdef KMP_GOMP_COMPAT
5822 kmp_setting_t *gomp_stacksize =
5823 __kmp_stg_find(
"GOMP_STACKSIZE");
5825 kmp_setting_t *omp_stacksize =
5826 __kmp_stg_find(
"OMP_STACKSIZE");
5832 static kmp_setting_t *
volatile rivals[4];
5833 static kmp_stg_ss_data_t kmp_data = {1, CCAST(kmp_setting_t **, rivals)};
5834#ifdef KMP_GOMP_COMPAT
5835 static kmp_stg_ss_data_t gomp_data = {1024,
5836 CCAST(kmp_setting_t **, rivals)};
5838 static kmp_stg_ss_data_t omp_data = {1024,
5839 CCAST(kmp_setting_t **, rivals)};
5842 rivals[i++] = kmp_stacksize;
5843#ifdef KMP_GOMP_COMPAT
5844 if (gomp_stacksize != NULL) {
5845 rivals[i++] = gomp_stacksize;
5848 rivals[i++] = omp_stacksize;
5851 kmp_stacksize->data = &kmp_data;
5852#ifdef KMP_GOMP_COMPAT
5853 if (gomp_stacksize != NULL) {
5854 gomp_stacksize->data = &gomp_data;
5857 omp_stacksize->data = &omp_data;
5861 kmp_setting_t *kmp_library =
5862 __kmp_stg_find(
"KMP_LIBRARY");
5863 kmp_setting_t *omp_wait_policy =
5864 __kmp_stg_find(
"OMP_WAIT_POLICY");
5867 static kmp_setting_t *
volatile rivals[3];
5868 static kmp_stg_wp_data_t kmp_data = {0, CCAST(kmp_setting_t **, rivals)};
5869 static kmp_stg_wp_data_t omp_data = {1, CCAST(kmp_setting_t **, rivals)};
5872 rivals[i++] = kmp_library;
5873 if (omp_wait_policy != NULL) {
5874 rivals[i++] = omp_wait_policy;
5878 kmp_library->data = &kmp_data;
5879 if (omp_wait_policy != NULL) {
5880 omp_wait_policy->data = &omp_data;
5885 kmp_setting_t *kmp_device_thread_limit =
5886 __kmp_stg_find(
"KMP_DEVICE_THREAD_LIMIT");
5887 kmp_setting_t *kmp_all_threads =
5888 __kmp_stg_find(
"KMP_ALL_THREADS");
5891 static kmp_setting_t *
volatile rivals[3];
5894 rivals[i++] = kmp_device_thread_limit;
5895 rivals[i++] = kmp_all_threads;
5898 kmp_device_thread_limit->data = CCAST(kmp_setting_t **, rivals);
5899 kmp_all_threads->data = CCAST(kmp_setting_t **, rivals);
5904 kmp_setting_t *kmp_hw_subset = __kmp_stg_find(
"KMP_HW_SUBSET");
5906 kmp_setting_t *kmp_place_threads = __kmp_stg_find(
"KMP_PLACE_THREADS");
5909 static kmp_setting_t *
volatile rivals[3];
5912 rivals[i++] = kmp_hw_subset;
5913 rivals[i++] = kmp_place_threads;
5916 kmp_hw_subset->data = CCAST(kmp_setting_t **, rivals);
5917 kmp_place_threads->data = CCAST(kmp_setting_t **, rivals);
5920#if KMP_AFFINITY_SUPPORTED
5922 kmp_setting_t *kmp_affinity =
5923 __kmp_stg_find(
"KMP_AFFINITY");
5924 KMP_DEBUG_ASSERT(kmp_affinity != NULL);
5926#ifdef KMP_GOMP_COMPAT
5927 kmp_setting_t *gomp_cpu_affinity =
5928 __kmp_stg_find(
"GOMP_CPU_AFFINITY");
5929 KMP_DEBUG_ASSERT(gomp_cpu_affinity != NULL);
5932 kmp_setting_t *omp_proc_bind =
5933 __kmp_stg_find(
"OMP_PROC_BIND");
5934 KMP_DEBUG_ASSERT(omp_proc_bind != NULL);
5937 static kmp_setting_t *
volatile rivals[4];
5940 rivals[i++] = kmp_affinity;
5942#ifdef KMP_GOMP_COMPAT
5943 rivals[i++] = gomp_cpu_affinity;
5944 gomp_cpu_affinity->data = CCAST(kmp_setting_t **, rivals);
5947 rivals[i++] = omp_proc_bind;
5948 omp_proc_bind->data = CCAST(kmp_setting_t **, rivals);
5951 static kmp_setting_t *
volatile places_rivals[4];
5954 kmp_setting_t *omp_places = __kmp_stg_find(
"OMP_PLACES");
5955 KMP_DEBUG_ASSERT(omp_places != NULL);
5957 places_rivals[i++] = kmp_affinity;
5958#ifdef KMP_GOMP_COMPAT
5959 places_rivals[i++] = gomp_cpu_affinity;
5961 places_rivals[i++] = omp_places;
5962 omp_places->data = CCAST(kmp_setting_t **, places_rivals);
5963 places_rivals[i++] = NULL;
5971 kmp_setting_t *kmp_force_red =
5972 __kmp_stg_find(
"KMP_FORCE_REDUCTION");
5973 kmp_setting_t *kmp_determ_red =
5974 __kmp_stg_find(
"KMP_DETERMINISTIC_REDUCTION");
5977 static kmp_setting_t *
volatile rivals[3];
5978 static kmp_stg_fr_data_t force_data = {1,
5979 CCAST(kmp_setting_t **, rivals)};
5980 static kmp_stg_fr_data_t determ_data = {0,
5981 CCAST(kmp_setting_t **, rivals)};
5984 rivals[i++] = kmp_force_red;
5985 if (kmp_determ_red != NULL) {
5986 rivals[i++] = kmp_determ_red;
5990 kmp_force_red->data = &force_data;
5991 if (kmp_determ_red != NULL) {
5992 kmp_determ_red->data = &determ_data;
6001 for (i = 0; i < __kmp_stg_count; ++i) {
6002 __kmp_stg_table[i].set = 0;
6007static void __kmp_stg_parse(
char const *name,
char const *value) {
6015 if (value != NULL) {
6016 kmp_setting_t *setting = __kmp_stg_find(name);
6017 if (setting != NULL) {
6018 setting->parse(name, value, setting->data);
6019 setting->defined = 1;
6025static int __kmp_stg_check_rivals(
6028 kmp_setting_t **rivals
6031 if (rivals == NULL) {
6037 for (; strcmp(rivals[i]->name, name) != 0; i++) {
6038 KMP_DEBUG_ASSERT(rivals[i] != NULL);
6040#if KMP_AFFINITY_SUPPORTED
6041 if (rivals[i] == __kmp_affinity_notype) {
6048 if (rivals[i]->set) {
6049 KMP_WARNING(StgIgnored, name, rivals[i]->name);
6059static int __kmp_env_toPrint(
char const *name,
int flag) {
6061 kmp_setting_t *setting = __kmp_stg_find(name);
6062 if (setting != NULL) {
6063 rc = setting->defined;
6065 setting->defined = flag;
6071#if defined(KMP_DEBUG) && KMP_AFFINITY_SUPPORTED
6072static void __kmp_print_affinity_settings(
const kmp_affinity_t *affinity) {
6073 K_DIAG(1, (
"%s:\n", affinity->env_var));
6074 K_DIAG(1, (
" type : %d\n", affinity->type));
6075 K_DIAG(1, (
" compact : %d\n", affinity->compact));
6076 K_DIAG(1, (
" offset : %d\n", affinity->offset));
6077 K_DIAG(1, (
" verbose : %u\n", affinity->flags.verbose));
6078 K_DIAG(1, (
" warnings : %u\n", affinity->flags.warnings));
6079 K_DIAG(1, (
" respect : %u\n", affinity->flags.respect));
6080 K_DIAG(1, (
" reset : %u\n", affinity->flags.reset));
6081 K_DIAG(1, (
" dups : %u\n", affinity->flags.dups));
6082 K_DIAG(1, (
" gran : %d\n", (
int)affinity->gran));
6083 KMP_DEBUG_ASSERT(affinity->type != affinity_default);
6087static void __kmp_aux_env_initialize(kmp_env_blk_t *block) {
6092 value = __kmp_env_blk_var(block,
"OMP_NUM_THREADS");
6094 ompc_set_num_threads(__kmp_dflt_team_nth);
6098 value = __kmp_env_blk_var(block,
"KMP_BLOCKTIME");
6100 kmpc_set_blocktime(__kmp_dflt_blocktime);
6104 value = __kmp_env_blk_var(block,
"OMP_NESTED");
6106 ompc_set_nested(__kmp_dflt_max_active_levels > 1);
6110 value = __kmp_env_blk_var(block,
"OMP_DYNAMIC");
6112 ompc_set_dynamic(__kmp_global.g.g_dynamic);
6116void __kmp_env_initialize(
char const *
string) {
6118 kmp_env_blk_t block;
6124 if (
string == NULL) {
6126 __kmp_threads_capacity =
6127 __kmp_initial_threads_capacity(__kmp_dflt_team_nth_ub);
6129 __kmp_env_blk_init(&block,
string);
6132 for (i = 0; i < block.count; ++i) {
6133 if ((block.vars[i].name == NULL) || (*block.vars[i].name ==
'\0')) {
6136 if (block.vars[i].value == NULL) {
6139 kmp_setting_t *setting = __kmp_stg_find(block.vars[i].name);
6140 if (setting != NULL) {
6146 blocktime_str = __kmp_env_blk_var(&block,
"KMP_BLOCKTIME");
6150 if (
string == NULL) {
6151 char const *name =
"KMP_WARNINGS";
6152 char const *value = __kmp_env_blk_var(&block, name);
6153 __kmp_stg_parse(name, value);
6156#if KMP_AFFINITY_SUPPORTED
6162 __kmp_affinity_notype = NULL;
6163 char const *aff_str = __kmp_env_blk_var(&block,
"KMP_AFFINITY");
6164 if (aff_str != NULL) {
6178#define FIND strcasestr
6181 if ((FIND(aff_str,
"none") == NULL) &&
6182 (FIND(aff_str,
"physical") == NULL) &&
6183 (FIND(aff_str,
"logical") == NULL) &&
6184 (FIND(aff_str,
"compact") == NULL) &&
6185 (FIND(aff_str,
"scatter") == NULL) &&
6186 (FIND(aff_str,
"explicit") == NULL) &&
6187 (FIND(aff_str,
"balanced") == NULL) &&
6188 (FIND(aff_str,
"disabled") == NULL)) {
6189 __kmp_affinity_notype = __kmp_stg_find(
"KMP_AFFINITY");
6194 __kmp_affinity.type = affinity_default;
6195 __kmp_affinity.gran = KMP_HW_UNKNOWN;
6196 __kmp_affinity_top_method = affinity_top_method_default;
6197 __kmp_affinity.flags.respect = affinity_respect_mask_default;
6202 aff_str = __kmp_env_blk_var(&block,
"OMP_PROC_BIND");
6203 if (aff_str != NULL) {
6204 __kmp_affinity.type = affinity_default;
6205 __kmp_affinity.gran = KMP_HW_UNKNOWN;
6206 __kmp_affinity_top_method = affinity_top_method_default;
6207 __kmp_affinity.flags.respect = affinity_respect_mask_default;
6214 if (__kmp_nested_proc_bind.bind_types == NULL) {
6215 __kmp_nested_proc_bind.bind_types =
6216 (kmp_proc_bind_t *)KMP_INTERNAL_MALLOC(
sizeof(kmp_proc_bind_t));
6217 if (__kmp_nested_proc_bind.bind_types == NULL) {
6218 KMP_FATAL(MemoryAllocFailed);
6220 __kmp_nested_proc_bind.size = 1;
6221 __kmp_nested_proc_bind.used = 1;
6222#if KMP_AFFINITY_SUPPORTED
6223 __kmp_nested_proc_bind.bind_types[0] = proc_bind_default;
6226 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
6233 __kmp_msg_format(kmp_i18n_msg_AffFormatDefault,
"%P",
"%i",
"%n",
"%A");
6234 KMP_DEBUG_ASSERT(KMP_STRLEN(m.str) < KMP_AFFINITY_FORMAT_SIZE);
6236 if (__kmp_affinity_format == NULL) {
6237 __kmp_affinity_format =
6238 (
char *)KMP_INTERNAL_MALLOC(
sizeof(
char) * KMP_AFFINITY_FORMAT_SIZE);
6240 KMP_STRCPY_S(__kmp_affinity_format, KMP_AFFINITY_FORMAT_SIZE, m.str);
6241 __kmp_str_free(&m.str);
6244 for (i = 0; i < block.count; ++i) {
6245 __kmp_stg_parse(block.vars[i].name, block.vars[i].value);
6249 if (!__kmp_init_user_locks) {
6250 if (__kmp_user_lock_kind == lk_default) {
6251 __kmp_user_lock_kind = lk_queuing;
6253#if KMP_USE_DYNAMIC_LOCK
6254 __kmp_init_dynamic_user_locks();
6256 __kmp_set_user_lock_vptrs(__kmp_user_lock_kind);
6259 KMP_DEBUG_ASSERT(
string != NULL);
6260 KMP_DEBUG_ASSERT(__kmp_user_lock_kind != lk_default);
6265#if KMP_USE_DYNAMIC_LOCK
6266 __kmp_init_dynamic_user_locks();
6268 __kmp_set_user_lock_vptrs(__kmp_user_lock_kind);
6272#if KMP_AFFINITY_SUPPORTED
6274 if (!TCR_4(__kmp_init_middle)) {
6279 if (__kmp_hw_subset &&
6280 __kmp_affinity_top_method == affinity_top_method_default)
6281 if (__kmp_hw_subset->specified(KMP_HW_NUMA) ||
6282 __kmp_hw_subset->specified(KMP_HW_TILE) ||
6283 __kmp_affinity.gran == KMP_HW_TILE ||
6284 __kmp_affinity.gran == KMP_HW_NUMA)
6285 __kmp_affinity_top_method = affinity_top_method_hwloc;
6287 if (__kmp_affinity.gran == KMP_HW_NUMA ||
6288 __kmp_affinity.gran == KMP_HW_TILE)
6289 __kmp_affinity_top_method = affinity_top_method_hwloc;
6293 const char *var =
"KMP_AFFINITY";
6294 KMPAffinity::pick_api();
6299 if (__kmp_affinity_top_method == affinity_top_method_hwloc &&
6300 __kmp_affinity_dispatch->get_api_type() != KMPAffinity::HWLOC) {
6301 KMP_WARNING(AffIgnoringHwloc, var);
6302 __kmp_affinity_top_method = affinity_top_method_all;
6305 if (__kmp_affinity.type == affinity_disabled) {
6306 KMP_AFFINITY_DISABLE();
6307 }
else if (!KMP_AFFINITY_CAPABLE()) {
6308 __kmp_affinity_dispatch->determine_capable(var);
6309 if (!KMP_AFFINITY_CAPABLE()) {
6310 if (__kmp_affinity.flags.verbose ||
6311 (__kmp_affinity.flags.warnings &&
6312 (__kmp_affinity.type != affinity_default) &&
6313 (__kmp_affinity.type != affinity_none) &&
6314 (__kmp_affinity.type != affinity_disabled))) {
6315 KMP_WARNING(AffNotSupported, var);
6317 __kmp_affinity.type = affinity_disabled;
6318 __kmp_affinity.flags.respect = FALSE;
6319 __kmp_affinity.gran = KMP_HW_THREAD;
6323 if (__kmp_affinity.type == affinity_disabled) {
6324 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
6325 }
else if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_true) {
6327 __kmp_nested_proc_bind.bind_types[0] = proc_bind_spread;
6330 if (KMP_AFFINITY_CAPABLE()) {
6332#if KMP_GROUP_AFFINITY
6337 bool exactly_one_group =
false;
6338 if (__kmp_num_proc_groups > 1) {
6340 bool within_one_group;
6343 kmp_affin_mask_t *init_mask;
6344 KMP_CPU_ALLOC(init_mask);
6345 __kmp_get_system_affinity(init_mask, TRUE);
6346 group = __kmp_get_proc_group(init_mask);
6347 within_one_group = (group >= 0);
6350 if (within_one_group) {
6351 DWORD num_bits_in_group = __kmp_GetActiveProcessorCount(group);
6352 DWORD num_bits_in_mask = 0;
6353 for (
int bit = init_mask->begin(); bit != init_mask->end();
6354 bit = init_mask->next(bit))
6356 exactly_one_group = (num_bits_in_group == num_bits_in_mask);
6358 KMP_CPU_FREE(init_mask);
6364 if (__kmp_num_proc_groups > 1 &&
6365 __kmp_affinity.type == affinity_default &&
6366 __kmp_nested_proc_bind.bind_types[0] == proc_bind_default) {
6371 if (__kmp_affinity.flags.respect == affinity_respect_mask_default &&
6372 exactly_one_group) {
6373 __kmp_affinity.flags.respect = FALSE;
6377 if (__kmp_affinity.type == affinity_default) {
6378 __kmp_affinity.type = affinity_compact;
6379 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
6381 if (__kmp_hh_affinity.type == affinity_default)
6382 __kmp_hh_affinity.type = affinity_compact;
6383 if (__kmp_affinity_top_method == affinity_top_method_default)
6384 __kmp_affinity_top_method = affinity_top_method_all;
6385 if (__kmp_affinity.gran == KMP_HW_UNKNOWN)
6386 __kmp_affinity.gran = KMP_HW_PROC_GROUP;
6387 if (__kmp_hh_affinity.gran == KMP_HW_UNKNOWN)
6388 __kmp_hh_affinity.gran = KMP_HW_PROC_GROUP;
6394 if (__kmp_affinity.flags.respect == affinity_respect_mask_default) {
6395#if KMP_GROUP_AFFINITY
6396 if (__kmp_num_proc_groups > 1 && exactly_one_group) {
6397 __kmp_affinity.flags.respect = FALSE;
6401 __kmp_affinity.flags.respect = TRUE;
6404 if ((__kmp_nested_proc_bind.bind_types[0] != proc_bind_intel) &&
6405 (__kmp_nested_proc_bind.bind_types[0] != proc_bind_default)) {
6406 if (__kmp_affinity.type == affinity_default) {
6407 __kmp_affinity.type = affinity_compact;
6408 __kmp_affinity.flags.dups = FALSE;
6410 }
else if (__kmp_affinity.type == affinity_default) {
6411#if KMP_MIC_SUPPORTED
6412 if (__kmp_mic_type != non_mic) {
6413 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
6417 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
6419#if KMP_MIC_SUPPORTED
6420 if (__kmp_mic_type != non_mic) {
6421 __kmp_affinity.type = affinity_scatter;
6425 __kmp_affinity.type = affinity_none;
6428 if (__kmp_hh_affinity.type == affinity_default)
6429 __kmp_hh_affinity.type = affinity_none;
6430 if ((__kmp_affinity.gran == KMP_HW_UNKNOWN) &&
6431 (__kmp_affinity.gran_levels < 0)) {
6432#if KMP_MIC_SUPPORTED
6433 if (__kmp_mic_type != non_mic) {
6434 __kmp_affinity.gran = KMP_HW_THREAD;
6438 __kmp_affinity.gran = KMP_HW_CORE;
6441 if ((__kmp_hh_affinity.gran == KMP_HW_UNKNOWN) &&
6442 (__kmp_hh_affinity.gran_levels < 0)) {
6443#if KMP_MIC_SUPPORTED
6444 if (__kmp_mic_type != non_mic) {
6445 __kmp_hh_affinity.gran = KMP_HW_THREAD;
6449 __kmp_hh_affinity.gran = KMP_HW_CORE;
6452 if (__kmp_affinity_top_method == affinity_top_method_default) {
6453 __kmp_affinity_top_method = affinity_top_method_all;
6459 if (__kmp_affinity_top_method == affinity_top_method_default)
6460 __kmp_affinity_top_method = affinity_top_method_all;
6461 if (__kmp_affinity.type == affinity_default)
6462 __kmp_affinity.type = affinity_disabled;
6463 if (__kmp_hh_affinity.type == affinity_default)
6464 __kmp_hh_affinity.type = affinity_disabled;
6468 for (
const kmp_affinity_t *affinity : __kmp_affinities)
6469 __kmp_print_affinity_settings(affinity);
6470 KMP_DEBUG_ASSERT(__kmp_nested_proc_bind.bind_types[0] != proc_bind_default);
6471 K_DIAG(1, (
"__kmp_nested_proc_bind.bind_types[0] == %d\n",
6472 __kmp_nested_proc_bind.bind_types[0]));
6480 if (
string != NULL) {
6481 __kmp_aux_env_initialize(&block);
6484 __kmp_env_blk_free(&block);
6490void __kmp_env_print() {
6492 kmp_env_blk_t block;
6494 kmp_str_buf_t buffer;
6497 __kmp_str_buf_init(&buffer);
6499 __kmp_env_blk_init(&block, NULL);
6500 __kmp_env_blk_sort(&block);
6503 __kmp_str_buf_print(&buffer,
"\n%s\n\n", KMP_I18N_STR(UserSettings));
6504 for (i = 0; i < block.count; ++i) {
6505 char const *name = block.vars[i].name;
6506 char const *value = block.vars[i].value;
6507 if ((KMP_STRLEN(name) > 4 && strncmp(name,
"KMP_", 4) == 0) ||
6508 strncmp(name,
"OMP_", 4) == 0
6509#ifdef KMP_GOMP_COMPAT
6510 || strncmp(name,
"GOMP_", 5) == 0
6513 __kmp_str_buf_print(&buffer,
" %s=%s\n", name, value);
6516 __kmp_str_buf_print(&buffer,
"\n");
6519 __kmp_str_buf_print(&buffer,
"%s\n\n", KMP_I18N_STR(EffectiveSettings));
6520 for (
int i = 0; i < __kmp_stg_count; ++i) {
6521 if (__kmp_stg_table[i].print != NULL) {
6522 __kmp_stg_table[i].print(&buffer, __kmp_stg_table[i].name,
6523 __kmp_stg_table[i].data);
6527 __kmp_printf(
"%s", buffer.str);
6529 __kmp_env_blk_free(&block);
6530 __kmp_str_buf_free(&buffer);
6536void __kmp_env_print_2() {
6537 __kmp_display_env_impl(__kmp_display_env, __kmp_display_env_verbose);
6540void __kmp_display_env_impl(
int display_env,
int display_env_verbose) {
6541 kmp_env_blk_t block;
6542 kmp_str_buf_t buffer;
6544 __kmp_env_format = 1;
6547 __kmp_str_buf_init(&buffer);
6549 __kmp_env_blk_init(&block, NULL);
6550 __kmp_env_blk_sort(&block);
6552 __kmp_str_buf_print(&buffer,
"\n%s\n", KMP_I18N_STR(DisplayEnvBegin));
6553 __kmp_str_buf_print(&buffer,
" _OPENMP='%d'\n", __kmp_openmp_version);
6555 for (
int i = 0; i < __kmp_stg_count; ++i) {
6556 if (__kmp_stg_table[i].print != NULL &&
6557 ((display_env && strncmp(__kmp_stg_table[i].name,
"OMP_", 4) == 0) ||
6558 display_env_verbose)) {
6559 __kmp_stg_table[i].print(&buffer, __kmp_stg_table[i].name,
6560 __kmp_stg_table[i].data);
6564 __kmp_str_buf_print(&buffer,
"%s\n", KMP_I18N_STR(DisplayEnvEnd));
6565 __kmp_str_buf_print(&buffer,
"\n");
6567 __kmp_printf(
"%s", buffer.str);
6569 __kmp_env_blk_free(&block);
6570 __kmp_str_buf_free(&buffer);
6577void __kmp_env_dump() {
6579 kmp_env_blk_t block;
6580 kmp_str_buf_t buffer, env, notdefined;
6583 __kmp_str_buf_init(&buffer);
6584 __kmp_str_buf_init(&env);
6585 __kmp_str_buf_init(¬defined);
6587 __kmp_env_blk_init(&block, NULL);
6588 __kmp_env_blk_sort(&block);
6590 __kmp_str_buf_print(¬defined,
": %s", KMP_I18N_STR(NotDefined));
6592 for (
int i = 0; i < __kmp_stg_count; ++i) {
6593 if (__kmp_stg_table[i].print == NULL)
6595 __kmp_str_buf_clear(&env);
6596 __kmp_stg_table[i].print(&env, __kmp_stg_table[i].name,
6597 __kmp_stg_table[i].data);
6600 if (strstr(env.str, notdefined.str))
6602 __kmp_str_buf_print(&buffer,
"%s=undefined\n", __kmp_stg_table[i].name);
6604 __kmp_str_buf_cat(&buffer, env.str + 3, env.used - 3);
6607 ompd_env_block = (
char *)__kmp_allocate(buffer.used + 1);
6608 KMP_MEMCPY(ompd_env_block, buffer.str, buffer.used + 1);
6609 ompd_env_block_size = (ompd_size_t)KMP_STRLEN(ompd_env_block);
6611 __kmp_env_blk_free(&block);
6612 __kmp_str_buf_free(&buffer);
6613 __kmp_str_buf_free(&env);
6614 __kmp_str_buf_free(¬defined);
@ kmp_sch_modifier_monotonic
@ kmp_sch_modifier_nonmonotonic