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);
2008#if KMP_AFFINITY_SUPPORTED
2010static int __kmp_parse_affinity_proc_id_list(
const char *var,
const char *env,
2011 const char **nextEnv,
2013 const char *scan = env;
2014 const char *next = scan;
2020 int start, end, stride;
2024 if (*next ==
'\0') {
2035 if ((*next <
'0') || (*next >
'9')) {
2036 KMP_WARNING(AffSyntaxError, var);
2040 num = __kmp_str_to_int(scan, *next);
2041 KMP_ASSERT(num >= 0);
2059 if ((*next <
'0') || (*next >
'9')) {
2060 KMP_WARNING(AffSyntaxError, var);
2065 num = __kmp_str_to_int(scan, *next);
2066 KMP_ASSERT(num >= 0);
2079 if ((*next <
'0') || (*next >
'9')) {
2081 KMP_WARNING(AffSyntaxError, var);
2089 start = __kmp_str_to_int(scan, *next);
2090 KMP_ASSERT(start >= 0);
2109 if ((*next <
'0') || (*next >
'9')) {
2110 KMP_WARNING(AffSyntaxError, var);
2114 end = __kmp_str_to_int(scan, *next);
2115 KMP_ASSERT(end >= 0);
2132 if ((*next <
'0') || (*next >
'9')) {
2133 KMP_WARNING(AffSyntaxError, var);
2137 stride = __kmp_str_to_int(scan, *next);
2138 KMP_ASSERT(stride >= 0);
2144 KMP_WARNING(AffZeroStride, var);
2149 KMP_WARNING(AffStartGreaterEnd, var, start, end);
2154 KMP_WARNING(AffStrideLessZero, var, start, end);
2158 if ((end - start) / stride > 65536) {
2159 KMP_WARNING(AffRangeTooBig, var, end, start, stride);
2176 ptrdiff_t len = next - env;
2177 char *retlist = (
char *)__kmp_allocate((len + 1) *
sizeof(char));
2178 KMP_MEMCPY_S(retlist, (len + 1) *
sizeof(
char), env, len *
sizeof(
char));
2179 retlist[len] =
'\0';
2180 *proclist = retlist;
2187static kmp_setting_t *__kmp_affinity_notype = NULL;
2189static void __kmp_parse_affinity_env(
char const *name,
char const *value,
2190 kmp_affinity_t *out_affinity) {
2191 char *buffer = NULL;
2209 KMP_ASSERT(value != NULL);
2211 if (TCR_4(__kmp_init_middle)) {
2212 KMP_WARNING(EnvMiddleWarn, name);
2213 __kmp_env_toPrint(name, 0);
2216 __kmp_env_toPrint(name, 1);
2219 __kmp_str_format(
"%s", value);
2229#define EMIT_WARN(skip, errlist) \
2233 SKIP_TO(next, ','); \
2237 KMP_WARNING errlist; \
2246#define _set_param(_guard, _var, _val) \
2248 if (_guard == 0) { \
2251 EMIT_WARN(FALSE, (AffParamDefined, name, start)); \
2256#define set_type(val) _set_param(type, out_affinity->type, val)
2257#define set_verbose(val) _set_param(verbose, out_affinity->flags.verbose, val)
2258#define set_warnings(val) \
2259 _set_param(warnings, out_affinity->flags.warnings, val)
2260#define set_respect(val) _set_param(respect, out_affinity->flags.respect, val)
2261#define set_dups(val) _set_param(dups, out_affinity->flags.dups, val)
2262#define set_proclist(val) _set_param(proclist, out_affinity->proclist, val)
2263#define set_reset(val) _set_param(reset, out_affinity->flags.reset, val)
2265#define set_gran(val, levels) \
2268 out_affinity->gran = val; \
2269 out_affinity->gran_levels = levels; \
2271 EMIT_WARN(FALSE, (AffParamDefined, name, start)); \
2276 KMP_DEBUG_ASSERT((__kmp_nested_proc_bind.bind_types != NULL) &&
2277 (__kmp_nested_proc_bind.used > 0));
2279 while (*buf !=
'\0') {
2282 if (__kmp_match_str(
"none", buf, CCAST(
const char **, &next))) {
2283 set_type(affinity_none);
2284 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
2286 }
else if (__kmp_match_str(
"scatter", buf, CCAST(
const char **, &next))) {
2287 set_type(affinity_scatter);
2288 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2290 }
else if (__kmp_match_str(
"compact", buf, CCAST(
const char **, &next))) {
2291 set_type(affinity_compact);
2292 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2294 }
else if (__kmp_match_str(
"logical", buf, CCAST(
const char **, &next))) {
2295 set_type(affinity_logical);
2296 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2298 }
else if (__kmp_match_str(
"physical", buf, CCAST(
const char **, &next))) {
2299 set_type(affinity_physical);
2300 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2302 }
else if (__kmp_match_str(
"explicit", buf, CCAST(
const char **, &next))) {
2303 set_type(affinity_explicit);
2304 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2306 }
else if (__kmp_match_str(
"balanced", buf, CCAST(
const char **, &next))) {
2307 set_type(affinity_balanced);
2308 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2310 }
else if (__kmp_match_str(
"disabled", buf, CCAST(
const char **, &next))) {
2311 set_type(affinity_disabled);
2312 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
2314 }
else if (__kmp_match_str(
"verbose", buf, CCAST(
const char **, &next))) {
2317 }
else if (__kmp_match_str(
"noverbose", buf, CCAST(
const char **, &next))) {
2320 }
else if (__kmp_match_str(
"warnings", buf, CCAST(
const char **, &next))) {
2323 }
else if (__kmp_match_str(
"nowarnings", buf,
2324 CCAST(
const char **, &next))) {
2325 set_warnings(FALSE);
2327 }
else if (__kmp_match_str(
"respect", buf, CCAST(
const char **, &next))) {
2330 }
else if (__kmp_match_str(
"norespect", buf, CCAST(
const char **, &next))) {
2333 }
else if (__kmp_match_str(
"reset", buf, CCAST(
const char **, &next))) {
2336 }
else if (__kmp_match_str(
"noreset", buf, CCAST(
const char **, &next))) {
2339 }
else if (__kmp_match_str(
"duplicates", buf,
2340 CCAST(
const char **, &next)) ||
2341 __kmp_match_str(
"dups", buf, CCAST(
const char **, &next))) {
2344 }
else if (__kmp_match_str(
"noduplicates", buf,
2345 CCAST(
const char **, &next)) ||
2346 __kmp_match_str(
"nodups", buf, CCAST(
const char **, &next))) {
2349 }
else if (__kmp_match_str(
"granularity", buf,
2350 CCAST(
const char **, &next)) ||
2351 __kmp_match_str(
"gran", buf, CCAST(
const char **, &next))) {
2354 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2363 KMP_FOREACH_HW_TYPE(type) {
2364 const char *name = __kmp_hw_get_keyword(type);
2365 if (__kmp_match_str(name, buf, CCAST(
const char **, &next))) {
2374 if (__kmp_match_str(
"fine", buf, CCAST(
const char **, &next))) {
2375 set_gran(KMP_HW_THREAD, -1);
2378 }
else if (__kmp_match_str(
"package", buf,
2379 CCAST(
const char **, &next))) {
2380 set_gran(KMP_HW_SOCKET, -1);
2383 }
else if (__kmp_match_str(
"node", buf, CCAST(
const char **, &next))) {
2384 set_gran(KMP_HW_NUMA, -1);
2387#if KMP_GROUP_AFFINITY
2388 }
else if (__kmp_match_str(
"group", buf, CCAST(
const char **, &next))) {
2389 set_gran(KMP_HW_PROC_GROUP, -1);
2393 }
else if ((*buf >=
'0') && (*buf <=
'9')) {
2397 n = __kmp_str_to_int(buf, *next);
2400 set_gran(KMP_HW_UNKNOWN, n);
2403 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2407 }
else if (__kmp_match_str(
"proclist", buf, CCAST(
const char **, &next))) {
2408 char *temp_proclist;
2412 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2418 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2423 if (!__kmp_parse_affinity_proc_id_list(
2424 name, buf, CCAST(
const char **, &next), &temp_proclist)) {
2436 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2440 set_proclist(temp_proclist);
2441 }
else if ((*buf >=
'0') && (*buf <=
'9')) {
2446 n = __kmp_str_to_int(buf, *next);
2452 KMP_WARNING(AffManyParams, name, start);
2456 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2464 }
else if (*next !=
'\0') {
2465 const char *temp = next;
2466 EMIT_WARN(TRUE, (ParseExtraCharsWarn, name, temp));
2478#undef set_granularity
2481 __kmp_str_free(&buffer);
2485 KMP_WARNING(AffProcListNoType, name);
2486 out_affinity->type = affinity_explicit;
2487 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2488 }
else if (out_affinity->type != affinity_explicit) {
2489 KMP_WARNING(AffProcListNotExplicit, name);
2490 KMP_ASSERT(out_affinity->proclist != NULL);
2491 KMP_INTERNAL_FREE(out_affinity->proclist);
2492 out_affinity->proclist = NULL;
2495 switch (out_affinity->type) {
2496 case affinity_logical:
2497 case affinity_physical: {
2499 out_affinity->offset = number[0];
2502 KMP_WARNING(AffManyParamsForLogic, name, number[1]);
2505 case affinity_balanced: {
2507 out_affinity->compact = number[0];
2510 out_affinity->offset = number[1];
2513 if (__kmp_affinity.gran == KMP_HW_UNKNOWN) {
2514 int verbose = out_affinity->flags.verbose;
2515 int warnings = out_affinity->flags.warnings;
2516#if KMP_MIC_SUPPORTED
2517 if (__kmp_mic_type != non_mic) {
2518 if (verbose || warnings) {
2519 KMP_WARNING(AffGranUsing, out_affinity->env_var,
"fine");
2521 out_affinity->gran = KMP_HW_THREAD;
2525 if (verbose || warnings) {
2526 KMP_WARNING(AffGranUsing, out_affinity->env_var,
"core");
2528 out_affinity->gran = KMP_HW_CORE;
2532 case affinity_scatter:
2533 case affinity_compact: {
2535 out_affinity->compact = number[0];
2538 out_affinity->offset = number[1];
2541 case affinity_explicit: {
2542 if (out_affinity->proclist == NULL) {
2543 KMP_WARNING(AffNoProcList, name);
2544 out_affinity->type = affinity_none;
2547 KMP_WARNING(AffNoParam, name,
"explicit");
2550 case affinity_none: {
2552 KMP_WARNING(AffNoParam, name,
"none");
2555 case affinity_disabled: {
2557 KMP_WARNING(AffNoParam, name,
"disabled");
2560 case affinity_default: {
2562 KMP_WARNING(AffNoParam, name,
"default");
2571static void __kmp_stg_parse_affinity(
char const *name,
char const *value,
2573 kmp_setting_t **rivals = (kmp_setting_t **)data;
2576 rc = __kmp_stg_check_rivals(name, value, rivals);
2581 __kmp_parse_affinity_env(name, value, &__kmp_affinity);
2584static void __kmp_stg_parse_hh_affinity(
char const *name,
char const *value,
2586 __kmp_parse_affinity_env(name, value, &__kmp_hh_affinity);
2588 if (__kmp_hh_affinity.flags.reset) {
2589 KMP_WARNING(AffInvalidParam, name,
"reset");
2591 if (__kmp_hh_affinity.flags.respect != affinity_respect_mask_default) {
2592 KMP_WARNING(AffInvalidParam, name,
"respect");
2596static void __kmp_print_affinity_env(kmp_str_buf_t *buffer,
char const *name,
2597 const kmp_affinity_t &affinity) {
2598 bool is_hh_affinity = (&affinity == &__kmp_hh_affinity);
2599 if (__kmp_env_format) {
2600 KMP_STR_BUF_PRINT_NAME_EX(name);
2602 __kmp_str_buf_print(buffer,
" %s='", name);
2604 if (affinity.flags.verbose) {
2605 __kmp_str_buf_print(buffer,
"%s,",
"verbose");
2607 __kmp_str_buf_print(buffer,
"%s,",
"noverbose");
2609 if (affinity.flags.warnings) {
2610 __kmp_str_buf_print(buffer,
"%s,",
"warnings");
2612 __kmp_str_buf_print(buffer,
"%s,",
"nowarnings");
2614 if (KMP_AFFINITY_CAPABLE()) {
2617 if (!is_hh_affinity) {
2618 if (affinity.flags.respect) {
2619 __kmp_str_buf_print(buffer,
"%s,",
"respect");
2621 __kmp_str_buf_print(buffer,
"%s,",
"norespect");
2623 if (affinity.flags.reset) {
2624 __kmp_str_buf_print(buffer,
"%s,",
"reset");
2626 __kmp_str_buf_print(buffer,
"%s,",
"noreset");
2629 __kmp_str_buf_print(buffer,
"granularity=%s,",
2630 __kmp_hw_get_keyword(affinity.gran,
false));
2632 if (!KMP_AFFINITY_CAPABLE()) {
2633 __kmp_str_buf_print(buffer,
"%s",
"disabled");
2635 int compact = affinity.compact;
2636 int offset = affinity.offset;
2637 switch (affinity.type) {
2639 __kmp_str_buf_print(buffer,
"%s",
"none");
2641 case affinity_physical:
2642 __kmp_str_buf_print(buffer,
"%s,%d",
"physical", offset);
2644 case affinity_logical:
2645 __kmp_str_buf_print(buffer,
"%s,%d",
"logical", offset);
2647 case affinity_compact:
2648 __kmp_str_buf_print(buffer,
"%s,%d,%d",
"compact", compact, offset);
2650 case affinity_scatter:
2651 __kmp_str_buf_print(buffer,
"%s,%d,%d",
"scatter", compact, offset);
2653 case affinity_explicit:
2654 __kmp_str_buf_print(buffer,
"%s=[%s],%s",
"proclist", affinity.proclist,
2657 case affinity_balanced:
2658 __kmp_str_buf_print(buffer,
"%s,%d,%d",
"balanced", compact, offset);
2660 case affinity_disabled:
2661 __kmp_str_buf_print(buffer,
"%s",
"disabled");
2663 case affinity_default:
2664 __kmp_str_buf_print(buffer,
"%s",
"default");
2667 __kmp_str_buf_print(buffer,
"%s",
"<unknown>");
2671 __kmp_str_buf_print(buffer,
"'\n");
2674static void __kmp_stg_print_affinity(kmp_str_buf_t *buffer,
char const *name,
2676 __kmp_print_affinity_env(buffer, name, __kmp_affinity);
2678static void __kmp_stg_print_hh_affinity(kmp_str_buf_t *buffer,
char const *name,
2680 __kmp_print_affinity_env(buffer, name, __kmp_hh_affinity);
2683#ifdef KMP_GOMP_COMPAT
2685static void __kmp_stg_parse_gomp_cpu_affinity(
char const *name,
2686 char const *value,
void *data) {
2687 const char *next = NULL;
2688 char *temp_proclist;
2689 kmp_setting_t **rivals = (kmp_setting_t **)data;
2692 rc = __kmp_stg_check_rivals(name, value, rivals);
2697 if (TCR_4(__kmp_init_middle)) {
2698 KMP_WARNING(EnvMiddleWarn, name);
2699 __kmp_env_toPrint(name, 0);
2703 __kmp_env_toPrint(name, 1);
2705 if (__kmp_parse_affinity_proc_id_list(name, value, &next, &temp_proclist)) {
2707 if (*next ==
'\0') {
2709 __kmp_affinity.proclist = temp_proclist;
2710 __kmp_affinity.type = affinity_explicit;
2711 __kmp_affinity.gran = KMP_HW_THREAD;
2712 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2714 KMP_WARNING(AffSyntaxError, name);
2715 if (temp_proclist != NULL) {
2716 KMP_INTERNAL_FREE((
void *)temp_proclist);
2721 __kmp_affinity.type = affinity_none;
2722 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
2749static inline void __kmp_omp_places_syntax_warn(
const char *var) {
2750 KMP_WARNING(SyntaxErrorUsing, var,
"\"cores\"");
2753static int __kmp_parse_subplace_list(
const char *var,
const char **scan) {
2757 int start, count, stride;
2763 if ((**scan <
'0') || (**scan >
'9')) {
2764 __kmp_omp_places_syntax_warn(var);
2769 start = __kmp_str_to_int(*scan, *next);
2770 KMP_ASSERT(start >= 0);
2775 if (**scan ==
'}') {
2778 if (**scan ==
',') {
2782 if (**scan !=
':') {
2783 __kmp_omp_places_syntax_warn(var);
2790 if ((**scan <
'0') || (**scan >
'9')) {
2791 __kmp_omp_places_syntax_warn(var);
2796 count = __kmp_str_to_int(*scan, *next);
2797 KMP_ASSERT(count >= 0);
2802 if (**scan ==
'}') {
2805 if (**scan ==
',') {
2809 if (**scan !=
':') {
2810 __kmp_omp_places_syntax_warn(var);
2819 if (**scan ==
'+') {
2823 if (**scan ==
'-') {
2831 if ((**scan <
'0') || (**scan >
'9')) {
2832 __kmp_omp_places_syntax_warn(var);
2837 stride = __kmp_str_to_int(*scan, *next);
2838 KMP_ASSERT(stride >= 0);
2844 if (**scan ==
'}') {
2847 if (**scan ==
',') {
2852 __kmp_omp_places_syntax_warn(var);
2858static int __kmp_parse_place(
const char *var,
const char **scan) {
2863 if (**scan ==
'{') {
2865 if (!__kmp_parse_subplace_list(var, scan)) {
2868 if (**scan !=
'}') {
2869 __kmp_omp_places_syntax_warn(var);
2873 }
else if (**scan ==
'!') {
2875 return __kmp_parse_place(var, scan);
2876 }
else if ((**scan >=
'0') && (**scan <=
'9')) {
2879 int proc = __kmp_str_to_int(*scan, *next);
2880 KMP_ASSERT(proc >= 0);
2883 __kmp_omp_places_syntax_warn(var);
2889static int __kmp_parse_place_list(
const char *var,
const char *env,
2890 char **place_list) {
2891 const char *scan = env;
2892 const char *next = scan;
2897 if (!__kmp_parse_place(var, &scan)) {
2903 if (*scan ==
'\0') {
2911 __kmp_omp_places_syntax_warn(var);
2918 if ((*scan <
'0') || (*scan >
'9')) {
2919 __kmp_omp_places_syntax_warn(var);
2924 count = __kmp_str_to_int(scan, *next);
2925 KMP_ASSERT(count >= 0);
2930 if (*scan ==
'\0') {
2938 __kmp_omp_places_syntax_warn(var);
2959 if ((*scan <
'0') || (*scan >
'9')) {
2960 __kmp_omp_places_syntax_warn(var);
2965 stride = __kmp_str_to_int(scan, *next);
2966 KMP_ASSERT(stride >= 0);
2972 if (*scan ==
'\0') {
2980 __kmp_omp_places_syntax_warn(var);
2985 ptrdiff_t len = scan - env;
2986 char *retlist = (
char *)__kmp_allocate((len + 1) *
sizeof(char));
2987 KMP_MEMCPY_S(retlist, (len + 1) *
sizeof(
char), env, len *
sizeof(
char));
2988 retlist[len] =
'\0';
2989 *place_list = retlist;
2994static void __kmp_stg_parse_places(
char const *name,
char const *value,
2996 struct kmp_place_t {
3002 const char *scan = value;
3003 const char *next = scan;
3004 const char *kind =
"\"threads\"";
3005 kmp_place_t std_places[] = {{
"threads", KMP_HW_THREAD},
3006 {
"cores", KMP_HW_CORE},
3007 {
"numa_domains", KMP_HW_NUMA},
3008 {
"ll_caches", KMP_HW_LLC},
3009 {
"sockets", KMP_HW_SOCKET}};
3010 kmp_setting_t **rivals = (kmp_setting_t **)data;
3013 rc = __kmp_stg_check_rivals(name, value, rivals);
3019 for (
size_t i = 0; i <
sizeof(std_places) /
sizeof(std_places[0]); ++i) {
3020 const kmp_place_t &place = std_places[i];
3021 if (__kmp_match_str(place.name, scan, &next)) {
3023 __kmp_affinity.type = affinity_compact;
3024 __kmp_affinity.gran = place.type;
3025 __kmp_affinity.flags.dups = FALSE;
3032 KMP_FOREACH_HW_TYPE(type) {
3033 const char *name = __kmp_hw_get_keyword(type,
true);
3034 if (__kmp_match_str(
"unknowns", scan, &next))
3036 if (__kmp_match_str(name, scan, &next)) {
3038 __kmp_affinity.type = affinity_compact;
3039 __kmp_affinity.gran = type;
3040 __kmp_affinity.flags.dups = FALSE;
3047 if (__kmp_affinity.proclist != NULL) {
3048 KMP_INTERNAL_FREE((
void *)__kmp_affinity.proclist);
3049 __kmp_affinity.proclist = NULL;
3051 if (__kmp_parse_place_list(name, value, &__kmp_affinity.proclist)) {
3052 __kmp_affinity.type = affinity_explicit;
3053 __kmp_affinity.gran = KMP_HW_THREAD;
3054 __kmp_affinity.flags.dups = FALSE;
3057 __kmp_affinity.type = affinity_compact;
3058 __kmp_affinity.gran = KMP_HW_CORE;
3059 __kmp_affinity.flags.dups = FALSE;
3061 if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_default) {
3062 __kmp_nested_proc_bind.bind_types[0] = proc_bind_true;
3066 if (__kmp_affinity.gran != KMP_HW_UNKNOWN) {
3067 kind = __kmp_hw_get_keyword(__kmp_affinity.gran);
3070 if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_default) {
3071 __kmp_nested_proc_bind.bind_types[0] = proc_bind_true;
3075 if (*scan ==
'\0') {
3081 KMP_WARNING(SyntaxErrorUsing, name, kind);
3089 count = __kmp_str_to_int(scan, *next);
3090 KMP_ASSERT(count >= 0);
3095 KMP_WARNING(SyntaxErrorUsing, name, kind);
3101 if (*scan !=
'\0') {
3102 KMP_WARNING(ParseExtraCharsWarn, name, scan);
3104 __kmp_affinity_num_places = count;
3107static void __kmp_stg_print_places(kmp_str_buf_t *buffer,
char const *name,
3109 enum affinity_type type = __kmp_affinity.type;
3110 const char *proclist = __kmp_affinity.proclist;
3111 kmp_hw_t gran = __kmp_affinity.gran;
3113 if (__kmp_env_format) {
3114 KMP_STR_BUF_PRINT_NAME;
3116 __kmp_str_buf_print(buffer,
" %s", name);
3118 if ((__kmp_nested_proc_bind.used == 0) ||
3119 (__kmp_nested_proc_bind.bind_types == NULL) ||
3120 (__kmp_nested_proc_bind.bind_types[0] == proc_bind_false)) {
3121 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
3122 }
else if (type == affinity_explicit) {
3123 if (proclist != NULL) {
3124 __kmp_str_buf_print(buffer,
"='%s'\n", proclist);
3126 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
3128 }
else if (type == affinity_compact) {
3130 if (__kmp_affinity.num_masks > 0) {
3131 num = __kmp_affinity.num_masks;
3132 }
else if (__kmp_affinity_num_places > 0) {
3133 num = __kmp_affinity_num_places;
3137 if (gran != KMP_HW_UNKNOWN) {
3138 const char *name = __kmp_hw_get_keyword(gran,
true);
3140 __kmp_str_buf_print(buffer,
"='%s(%d)'\n", name, num);
3142 __kmp_str_buf_print(buffer,
"='%s'\n", name);
3145 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
3148 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
3152static void __kmp_stg_parse_topology_method(
char const *name,
char const *value,
3154 if (__kmp_str_match(
"all", 1, value)) {
3155 __kmp_affinity_top_method = affinity_top_method_all;
3158 else if (__kmp_str_match(
"hwloc", 1, value)) {
3159 __kmp_affinity_top_method = affinity_top_method_hwloc;
3162#if KMP_ARCH_X86 || KMP_ARCH_X86_64
3163 else if (__kmp_str_match(
"cpuid_leaf31", 12, value) ||
3164 __kmp_str_match(
"cpuid 1f", 8, value) ||
3165 __kmp_str_match(
"cpuid 31", 8, value) ||
3166 __kmp_str_match(
"cpuid1f", 7, value) ||
3167 __kmp_str_match(
"cpuid31", 7, value) ||
3168 __kmp_str_match(
"leaf 1f", 7, value) ||
3169 __kmp_str_match(
"leaf 31", 7, value) ||
3170 __kmp_str_match(
"leaf1f", 6, value) ||
3171 __kmp_str_match(
"leaf31", 6, value)) {
3172 __kmp_affinity_top_method = affinity_top_method_x2apicid_1f;
3173 }
else if (__kmp_str_match(
"x2apic id", 9, value) ||
3174 __kmp_str_match(
"x2apic_id", 9, value) ||
3175 __kmp_str_match(
"x2apic-id", 9, value) ||
3176 __kmp_str_match(
"x2apicid", 8, value) ||
3177 __kmp_str_match(
"cpuid leaf 11", 13, value) ||
3178 __kmp_str_match(
"cpuid_leaf_11", 13, value) ||
3179 __kmp_str_match(
"cpuid-leaf-11", 13, value) ||
3180 __kmp_str_match(
"cpuid leaf11", 12, value) ||
3181 __kmp_str_match(
"cpuid_leaf11", 12, value) ||
3182 __kmp_str_match(
"cpuid-leaf11", 12, value) ||
3183 __kmp_str_match(
"cpuidleaf 11", 12, value) ||
3184 __kmp_str_match(
"cpuidleaf_11", 12, value) ||
3185 __kmp_str_match(
"cpuidleaf-11", 12, value) ||
3186 __kmp_str_match(
"cpuidleaf11", 11, value) ||
3187 __kmp_str_match(
"cpuid 11", 8, value) ||
3188 __kmp_str_match(
"cpuid_11", 8, value) ||
3189 __kmp_str_match(
"cpuid-11", 8, value) ||
3190 __kmp_str_match(
"cpuid11", 7, value) ||
3191 __kmp_str_match(
"leaf 11", 7, value) ||
3192 __kmp_str_match(
"leaf_11", 7, value) ||
3193 __kmp_str_match(
"leaf-11", 7, value) ||
3194 __kmp_str_match(
"leaf11", 6, value)) {
3195 __kmp_affinity_top_method = affinity_top_method_x2apicid;
3196 }
else if (__kmp_str_match(
"apic id", 7, value) ||
3197 __kmp_str_match(
"apic_id", 7, value) ||
3198 __kmp_str_match(
"apic-id", 7, value) ||
3199 __kmp_str_match(
"apicid", 6, value) ||
3200 __kmp_str_match(
"cpuid leaf 4", 12, value) ||
3201 __kmp_str_match(
"cpuid_leaf_4", 12, value) ||
3202 __kmp_str_match(
"cpuid-leaf-4", 12, value) ||
3203 __kmp_str_match(
"cpuid leaf4", 11, value) ||
3204 __kmp_str_match(
"cpuid_leaf4", 11, value) ||
3205 __kmp_str_match(
"cpuid-leaf4", 11, value) ||
3206 __kmp_str_match(
"cpuidleaf 4", 11, value) ||
3207 __kmp_str_match(
"cpuidleaf_4", 11, value) ||
3208 __kmp_str_match(
"cpuidleaf-4", 11, value) ||
3209 __kmp_str_match(
"cpuidleaf4", 10, value) ||
3210 __kmp_str_match(
"cpuid 4", 7, value) ||
3211 __kmp_str_match(
"cpuid_4", 7, value) ||
3212 __kmp_str_match(
"cpuid-4", 7, value) ||
3213 __kmp_str_match(
"cpuid4", 6, value) ||
3214 __kmp_str_match(
"leaf 4", 6, value) ||
3215 __kmp_str_match(
"leaf_4", 6, value) ||
3216 __kmp_str_match(
"leaf-4", 6, value) ||
3217 __kmp_str_match(
"leaf4", 5, value)) {
3218 __kmp_affinity_top_method = affinity_top_method_apicid;
3221 else if (__kmp_str_match(
"/proc/cpuinfo", 2, value) ||
3222 __kmp_str_match(
"cpuinfo", 5, value)) {
3223 __kmp_affinity_top_method = affinity_top_method_cpuinfo;
3225#if KMP_GROUP_AFFINITY
3226 else if (__kmp_str_match(
"group", 1, value)) {
3227 KMP_WARNING(StgDeprecatedValue, name, value,
"all");
3228 __kmp_affinity_top_method = affinity_top_method_group;
3231 else if (__kmp_str_match(
"flat", 1, value)) {
3232 __kmp_affinity_top_method = affinity_top_method_flat;
3234 KMP_WARNING(StgInvalidValue, name, value);
3238static void __kmp_stg_print_topology_method(kmp_str_buf_t *buffer,
3239 char const *name,
void *data) {
3240 char const *value = NULL;
3242 switch (__kmp_affinity_top_method) {
3243 case affinity_top_method_default:
3247 case affinity_top_method_all:
3251#if KMP_ARCH_X86 || KMP_ARCH_X86_64
3252 case affinity_top_method_x2apicid_1f:
3253 value =
"x2APIC id leaf 0x1f";
3256 case affinity_top_method_x2apicid:
3257 value =
"x2APIC id leaf 0xb";
3260 case affinity_top_method_apicid:
3266 case affinity_top_method_hwloc:
3271 case affinity_top_method_cpuinfo:
3275#if KMP_GROUP_AFFINITY
3276 case affinity_top_method_group:
3281 case affinity_top_method_flat:
3286 if (value != NULL) {
3287 __kmp_stg_print_str(buffer, name, value);
3292struct kmp_proc_bind_info_t {
3294 kmp_proc_bind_t proc_bind;
3296static kmp_proc_bind_info_t proc_bind_table[] = {
3297 {
"spread", proc_bind_spread},
3298 {
"true", proc_bind_spread},
3299 {
"close", proc_bind_close},
3301 {
"false", proc_bind_primary},
3302 {
"primary", proc_bind_primary}};
3303static void __kmp_stg_parse_teams_proc_bind(
char const *name,
char const *value,
3308 for (
size_t i = 0; i <
sizeof(proc_bind_table) /
sizeof(proc_bind_table[0]);
3310 if (__kmp_match_str(proc_bind_table[i].name, value, &end)) {
3311 __kmp_teams_proc_bind = proc_bind_table[i].proc_bind;
3317 KMP_WARNING(StgInvalidValue, name, value);
3320static void __kmp_stg_print_teams_proc_bind(kmp_str_buf_t *buffer,
3321 char const *name,
void *data) {
3322 const char *value = KMP_I18N_STR(NotDefined);
3323 for (
size_t i = 0; i <
sizeof(proc_bind_table) /
sizeof(proc_bind_table[0]);
3325 if (__kmp_teams_proc_bind == proc_bind_table[i].proc_bind) {
3326 value = proc_bind_table[i].name;
3330 __kmp_stg_print_str(buffer, name, value);
3336static void __kmp_stg_parse_proc_bind(
char const *name,
char const *value,
3338 kmp_setting_t **rivals = (kmp_setting_t **)data;
3341 rc = __kmp_stg_check_rivals(name, value, rivals);
3347 KMP_DEBUG_ASSERT((__kmp_nested_proc_bind.bind_types != NULL) &&
3348 (__kmp_nested_proc_bind.used > 0));
3350 const char *buf = value;
3354 if ((*buf >=
'0') && (*buf <=
'9')) {
3357 num = __kmp_str_to_int(buf, *next);
3358 KMP_ASSERT(num >= 0);
3366 if (__kmp_match_str(
"disabled", buf, &next)) {
3369#if KMP_AFFINITY_SUPPORTED
3370 __kmp_affinity.type = affinity_disabled;
3372 __kmp_nested_proc_bind.used = 1;
3373 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
3374 }
else if ((num == (
int)proc_bind_false) ||
3375 __kmp_match_str(
"false", buf, &next)) {
3378#if KMP_AFFINITY_SUPPORTED
3379 __kmp_affinity.type = affinity_none;
3381 __kmp_nested_proc_bind.used = 1;
3382 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
3383 }
else if ((num == (
int)proc_bind_true) ||
3384 __kmp_match_str(
"true", buf, &next)) {
3387 __kmp_nested_proc_bind.used = 1;
3388 __kmp_nested_proc_bind.bind_types[0] = proc_bind_true;
3393 for (scan = buf; *scan !=
'\0'; scan++) {
3400 if (__kmp_nested_proc_bind.size < nelem) {
3401 __kmp_nested_proc_bind.bind_types =
3402 (kmp_proc_bind_t *)KMP_INTERNAL_REALLOC(
3403 __kmp_nested_proc_bind.bind_types,
3404 sizeof(kmp_proc_bind_t) * nelem);
3405 if (__kmp_nested_proc_bind.bind_types == NULL) {
3406 KMP_FATAL(MemoryAllocFailed);
3408 __kmp_nested_proc_bind.size = nelem;
3410 __kmp_nested_proc_bind.used = nelem;
3412 if (nelem > 1 && !__kmp_dflt_max_active_levels_set)
3413 __kmp_dflt_max_active_levels = KMP_MAX_ACTIVE_LEVELS_LIMIT;
3418 enum kmp_proc_bind_t bind;
3420 if ((num == (
int)proc_bind_primary) ||
3421 __kmp_match_str(
"master", buf, &next) ||
3422 __kmp_match_str(
"primary", buf, &next)) {
3425 bind = proc_bind_primary;
3426 }
else if ((num == (
int)proc_bind_close) ||
3427 __kmp_match_str(
"close", buf, &next)) {
3430 bind = proc_bind_close;
3431 }
else if ((num == (
int)proc_bind_spread) ||
3432 __kmp_match_str(
"spread", buf, &next)) {
3435 bind = proc_bind_spread;
3437 KMP_WARNING(StgInvalidValue, name, value);
3438 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
3439 __kmp_nested_proc_bind.used = 1;
3443 __kmp_nested_proc_bind.bind_types[i++] = bind;
3447 KMP_DEBUG_ASSERT(*buf ==
',');
3452 if ((*buf >=
'0') && (*buf <=
'9')) {
3455 num = __kmp_str_to_int(buf, *next);
3456 KMP_ASSERT(num >= 0);
3466 KMP_WARNING(ParseExtraCharsWarn, name, buf);
3470static void __kmp_stg_print_proc_bind(kmp_str_buf_t *buffer,
char const *name,
3472 int nelem = __kmp_nested_proc_bind.used;
3473 if (__kmp_env_format) {
3474 KMP_STR_BUF_PRINT_NAME;
3476 __kmp_str_buf_print(buffer,
" %s", name);
3479 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
3482 __kmp_str_buf_print(buffer,
"='", name);
3483 for (i = 0; i < nelem; i++) {
3484 switch (__kmp_nested_proc_bind.bind_types[i]) {
3485 case proc_bind_false:
3486 __kmp_str_buf_print(buffer,
"false");
3489 case proc_bind_true:
3490 __kmp_str_buf_print(buffer,
"true");
3493 case proc_bind_primary:
3494 __kmp_str_buf_print(buffer,
"primary");
3497 case proc_bind_close:
3498 __kmp_str_buf_print(buffer,
"close");
3501 case proc_bind_spread:
3502 __kmp_str_buf_print(buffer,
"spread");
3505 case proc_bind_intel:
3506 __kmp_str_buf_print(buffer,
"intel");
3509 case proc_bind_default:
3510 __kmp_str_buf_print(buffer,
"default");
3513 if (i < nelem - 1) {
3514 __kmp_str_buf_print(buffer,
",");
3517 __kmp_str_buf_print(buffer,
"'\n");
3521static void __kmp_stg_parse_display_affinity(
char const *name,
3522 char const *value,
void *data) {
3523 __kmp_stg_parse_bool(name, value, &__kmp_display_affinity);
3525static void __kmp_stg_print_display_affinity(kmp_str_buf_t *buffer,
3526 char const *name,
void *data) {
3527 __kmp_stg_print_bool(buffer, name, __kmp_display_affinity);
3529static void __kmp_stg_parse_affinity_format(
char const *name,
char const *value,
3531 size_t length = KMP_STRLEN(value);
3532 __kmp_strncpy_truncate(__kmp_affinity_format, KMP_AFFINITY_FORMAT_SIZE, value,
3535static void __kmp_stg_print_affinity_format(kmp_str_buf_t *buffer,
3536 char const *name,
void *data) {
3537 if (__kmp_env_format) {
3538 KMP_STR_BUF_PRINT_NAME_EX(name);
3540 __kmp_str_buf_print(buffer,
" %s='", name);
3542 __kmp_str_buf_print(buffer,
"%s'\n", __kmp_affinity_format);
3564static void __kmp_stg_parse_allocator(
char const *name,
char const *value,
3566 const char *buf = value;
3567 const char *next, *scan, *start;
3569 omp_allocator_handle_t al;
3570 omp_memspace_handle_t ms = omp_default_mem_space;
3571 bool is_memspace =
false;
3572 int ntraits = 0, count = 0;
3576 const char *delim = strchr(buf,
':');
3577 const char *predef_mem_space = strstr(buf,
"mem_space");
3579 bool is_memalloc = (!predef_mem_space && !delim) ?
true :
false;
3584 for (scan = buf; *scan !=
'\0'; scan++) {
3589 omp_alloctrait_t *traits =
3590 (omp_alloctrait_t *)KMP_ALLOCA(ntraits *
sizeof(omp_alloctrait_t));
3593#define IS_POWER_OF_TWO(n) (((n) & ((n)-1)) == 0)
3595#define GET_NEXT(sentinel) \
3598 if (*next == sentinel) \
3604#define SKIP_PAIR(key) \
3606 char const str_delimiter[] = {',', 0}; \
3607 char *value = __kmp_str_token(CCAST(char *, scan), str_delimiter, \
3608 CCAST(char **, &next)); \
3609 KMP_WARNING(StgInvalidValue, key, value); \
3617 char const str_delimiter[] = {'=', 0}; \
3618 key = __kmp_str_token(CCAST(char *, start), str_delimiter, \
3619 CCAST(char **, &next)); \
3624 while (*next !=
'\0') {
3626 __kmp_match_str(
"fb_data", scan, &next)) {
3630 if (__kmp_match_str(
"omp_high_bw_mem_alloc", scan, &next)) {
3633 if (__kmp_memkind_available) {
3634 __kmp_def_allocator = omp_high_bw_mem_alloc;
3637 KMP_WARNING(OmpNoAllocator,
"omp_high_bw_mem_alloc");
3640 traits[count].key = omp_atk_fb_data;
3641 traits[count].value = RCAST(omp_uintptr_t, omp_high_bw_mem_alloc);
3643 }
else if (__kmp_match_str(
"omp_large_cap_mem_alloc", scan, &next)) {
3646 if (__kmp_memkind_available) {
3647 __kmp_def_allocator = omp_large_cap_mem_alloc;
3650 KMP_WARNING(OmpNoAllocator,
"omp_large_cap_mem_alloc");
3653 traits[count].key = omp_atk_fb_data;
3654 traits[count].value = RCAST(omp_uintptr_t, omp_large_cap_mem_alloc);
3656 }
else if (__kmp_match_str(
"omp_default_mem_alloc", scan, &next)) {
3660 traits[count].key = omp_atk_fb_data;
3661 traits[count].value = RCAST(omp_uintptr_t, omp_default_mem_alloc);
3663 }
else if (__kmp_match_str(
"omp_const_mem_alloc", scan, &next)) {
3666 KMP_WARNING(OmpNoAllocator,
"omp_const_mem_alloc");
3668 traits[count].key = omp_atk_fb_data;
3669 traits[count].value = RCAST(omp_uintptr_t, omp_const_mem_alloc);
3671 }
else if (__kmp_match_str(
"omp_low_lat_mem_alloc", scan, &next)) {
3674 KMP_WARNING(OmpNoAllocator,
"omp_low_lat_mem_alloc");
3676 traits[count].key = omp_atk_fb_data;
3677 traits[count].value = RCAST(omp_uintptr_t, omp_low_lat_mem_alloc);
3679 }
else if (__kmp_match_str(
"omp_cgroup_mem_alloc", scan, &next)) {
3682 KMP_WARNING(OmpNoAllocator,
"omp_cgroup_mem_alloc");
3684 traits[count].key = omp_atk_fb_data;
3685 traits[count].value = RCAST(omp_uintptr_t, omp_cgroup_mem_alloc);
3687 }
else if (__kmp_match_str(
"omp_pteam_mem_alloc", scan, &next)) {
3690 KMP_WARNING(OmpNoAllocator,
"omp_pteam_mem_alloc");
3692 traits[count].key = omp_atk_fb_data;
3693 traits[count].value = RCAST(omp_uintptr_t, omp_pteam_mem_alloc);
3695 }
else if (__kmp_match_str(
"omp_thread_mem_alloc", scan, &next)) {
3698 KMP_WARNING(OmpNoAllocator,
"omp_thread_mem_alloc");
3700 traits[count].key = omp_atk_fb_data;
3701 traits[count].value = RCAST(omp_uintptr_t, omp_thread_mem_alloc);
3711 __kmp_def_allocator = omp_default_mem_alloc;
3712 if (next == buf || *next !=
'\0') {
3714 KMP_WARNING(StgInvalidValue, name, value);
3719 if (count == ntraits)
3725 if (__kmp_match_str(
"omp_default_mem_space", scan, &next)) {
3727 ms = omp_default_mem_space;
3728 }
else if (__kmp_match_str(
"omp_large_cap_mem_space", scan, &next)) {
3730 ms = omp_large_cap_mem_space;
3731 }
else if (__kmp_match_str(
"omp_const_mem_space", scan, &next)) {
3733 ms = omp_const_mem_space;
3734 }
else if (__kmp_match_str(
"omp_high_bw_mem_space", scan, &next)) {
3736 ms = omp_high_bw_mem_space;
3737 }
else if (__kmp_match_str(
"omp_low_lat_mem_space", scan, &next)) {
3739 ms = omp_low_lat_mem_space;
3741 __kmp_def_allocator = omp_default_mem_alloc;
3742 if (next == buf || *next !=
'\0') {
3744 KMP_WARNING(StgInvalidValue, name, value);
3753 if (__kmp_match_str(
"sync_hint", scan, &next)) {
3755 traits[count].key = omp_atk_sync_hint;
3756 if (__kmp_match_str(
"contended", scan, &next)) {
3757 traits[count].value = omp_atv_contended;
3758 }
else if (__kmp_match_str(
"uncontended", scan, &next)) {
3759 traits[count].value = omp_atv_uncontended;
3760 }
else if (__kmp_match_str(
"serialized", scan, &next)) {
3761 traits[count].value = omp_atv_serialized;
3762 }
else if (__kmp_match_str(
"private", scan, &next)) {
3763 traits[count].value = omp_atv_private;
3769 }
else if (__kmp_match_str(
"alignment", scan, &next)) {
3771 if (!isdigit(*next)) {
3777 int n = __kmp_str_to_int(scan,
',');
3778 if (n < 0 || !IS_POWER_OF_TWO(n)) {
3783 traits[count].key = omp_atk_alignment;
3784 traits[count].value = n;
3785 }
else if (__kmp_match_str(
"access", scan, &next)) {
3787 traits[count].key = omp_atk_access;
3788 if (__kmp_match_str(
"all", scan, &next)) {
3789 traits[count].value = omp_atv_all;
3790 }
else if (__kmp_match_str(
"cgroup", scan, &next)) {
3791 traits[count].value = omp_atv_cgroup;
3792 }
else if (__kmp_match_str(
"pteam", scan, &next)) {
3793 traits[count].value = omp_atv_pteam;
3794 }
else if (__kmp_match_str(
"thread", scan, &next)) {
3795 traits[count].value = omp_atv_thread;
3801 }
else if (__kmp_match_str(
"pool_size", scan, &next)) {
3803 if (!isdigit(*next)) {
3809 int n = __kmp_str_to_int(scan,
',');
3815 traits[count].key = omp_atk_pool_size;
3816 traits[count].value = n;
3817 }
else if (__kmp_match_str(
"fallback", scan, &next)) {
3819 traits[count].key = omp_atk_fallback;
3820 if (__kmp_match_str(
"default_mem_fb", scan, &next)) {
3821 traits[count].value = omp_atv_default_mem_fb;
3822 }
else if (__kmp_match_str(
"null_fb", scan, &next)) {
3823 traits[count].value = omp_atv_null_fb;
3824 }
else if (__kmp_match_str(
"abort_fb", scan, &next)) {
3825 traits[count].value = omp_atv_abort_fb;
3826 }
else if (__kmp_match_str(
"allocator_fb", scan, &next)) {
3827 traits[count].value = omp_atv_allocator_fb;
3833 }
else if (__kmp_match_str(
"pinned", scan, &next)) {
3835 traits[count].key = omp_atk_pinned;
3836 if (__kmp_str_match_true(next)) {
3837 traits[count].value = omp_atv_true;
3838 }
else if (__kmp_str_match_false(next)) {
3839 traits[count].value = omp_atv_false;
3845 }
else if (__kmp_match_str(
"partition", scan, &next)) {
3847 traits[count].key = omp_atk_partition;
3848 if (__kmp_match_str(
"environment", scan, &next)) {
3849 traits[count].value = omp_atv_environment;
3850 }
else if (__kmp_match_str(
"nearest", scan, &next)) {
3851 traits[count].value = omp_atv_nearest;
3852 }
else if (__kmp_match_str(
"blocked", scan, &next)) {
3853 traits[count].value = omp_atv_blocked;
3854 }
else if (__kmp_match_str(
"interleaved", scan, &next)) {
3855 traits[count].value = omp_atv_interleaved;
3868 if (count == ntraits)
3874 al = __kmpc_init_allocator(__kmp_get_gtid(), ms, ntraits, traits);
3875 __kmp_def_allocator = (al == omp_null_allocator) ? omp_default_mem_alloc : al;
3878static void __kmp_stg_print_allocator(kmp_str_buf_t *buffer,
char const *name,
3880 if (__kmp_def_allocator == omp_default_mem_alloc) {
3881 __kmp_stg_print_str(buffer, name,
"omp_default_mem_alloc");
3882 }
else if (__kmp_def_allocator == omp_high_bw_mem_alloc) {
3883 __kmp_stg_print_str(buffer, name,
"omp_high_bw_mem_alloc");
3884 }
else if (__kmp_def_allocator == omp_large_cap_mem_alloc) {
3885 __kmp_stg_print_str(buffer, name,
"omp_large_cap_mem_alloc");
3886 }
else if (__kmp_def_allocator == omp_const_mem_alloc) {
3887 __kmp_stg_print_str(buffer, name,
"omp_const_mem_alloc");
3888 }
else if (__kmp_def_allocator == omp_low_lat_mem_alloc) {
3889 __kmp_stg_print_str(buffer, name,
"omp_low_lat_mem_alloc");
3890 }
else if (__kmp_def_allocator == omp_cgroup_mem_alloc) {
3891 __kmp_stg_print_str(buffer, name,
"omp_cgroup_mem_alloc");
3892 }
else if (__kmp_def_allocator == omp_pteam_mem_alloc) {
3893 __kmp_stg_print_str(buffer, name,
"omp_pteam_mem_alloc");
3894 }
else if (__kmp_def_allocator == omp_thread_mem_alloc) {
3895 __kmp_stg_print_str(buffer, name,
"omp_thread_mem_alloc");
3902static void __kmp_stg_parse_omp_dynamic(
char const *name,
char const *value,
3904 __kmp_stg_parse_bool(name, value, &(__kmp_global.g.g_dynamic));
3907static void __kmp_stg_print_omp_dynamic(kmp_str_buf_t *buffer,
char const *name,
3909 __kmp_stg_print_bool(buffer, name, __kmp_global.g.g_dynamic);
3912static void __kmp_stg_parse_kmp_dynamic_mode(
char const *name,
3913 char const *value,
void *data) {
3914 if (TCR_4(__kmp_init_parallel)) {
3915 KMP_WARNING(EnvParallelWarn, name);
3916 __kmp_env_toPrint(name, 0);
3919#ifdef USE_LOAD_BALANCE
3920 else if (__kmp_str_match(
"load balance", 2, value) ||
3921 __kmp_str_match(
"load_balance", 2, value) ||
3922 __kmp_str_match(
"load-balance", 2, value) ||
3923 __kmp_str_match(
"loadbalance", 2, value) ||
3924 __kmp_str_match(
"balance", 1, value)) {
3925 __kmp_global.g.g_dynamic_mode = dynamic_load_balance;
3928 else if (__kmp_str_match(
"thread limit", 1, value) ||
3929 __kmp_str_match(
"thread_limit", 1, value) ||
3930 __kmp_str_match(
"thread-limit", 1, value) ||
3931 __kmp_str_match(
"threadlimit", 1, value) ||
3932 __kmp_str_match(
"limit", 2, value)) {
3933 __kmp_global.g.g_dynamic_mode = dynamic_thread_limit;
3934 }
else if (__kmp_str_match(
"random", 1, value)) {
3935 __kmp_global.g.g_dynamic_mode = dynamic_random;
3937 KMP_WARNING(StgInvalidValue, name, value);
3941static void __kmp_stg_print_kmp_dynamic_mode(kmp_str_buf_t *buffer,
3942 char const *name,
void *data) {
3944 if (__kmp_global.g.g_dynamic_mode == dynamic_default) {
3945 __kmp_str_buf_print(buffer,
" %s: %s \n", name, KMP_I18N_STR(NotDefined));
3947#ifdef USE_LOAD_BALANCE
3948 else if (__kmp_global.g.g_dynamic_mode == dynamic_load_balance) {
3949 __kmp_stg_print_str(buffer, name,
"load balance");
3952 else if (__kmp_global.g.g_dynamic_mode == dynamic_thread_limit) {
3953 __kmp_stg_print_str(buffer, name,
"thread limit");
3954 }
else if (__kmp_global.g.g_dynamic_mode == dynamic_random) {
3955 __kmp_stg_print_str(buffer, name,
"random");
3962#ifdef USE_LOAD_BALANCE
3967static void __kmp_stg_parse_ld_balance_interval(
char const *name,
3968 char const *value,
void *data) {
3969 double interval = __kmp_convert_to_double(value);
3970 if (interval >= 0) {
3971 __kmp_load_balance_interval = interval;
3973 KMP_WARNING(StgInvalidValue, name, value);
3977static void __kmp_stg_print_ld_balance_interval(kmp_str_buf_t *buffer,
3978 char const *name,
void *data) {
3980 __kmp_str_buf_print(buffer,
" %s=%8.6f\n", name,
3981 __kmp_load_balance_interval);
3990static void __kmp_stg_parse_init_at_fork(
char const *name,
char const *value,
3992 __kmp_stg_parse_bool(name, value, &__kmp_need_register_atfork);
3993 if (__kmp_need_register_atfork) {
3994 __kmp_need_register_atfork_specified = TRUE;
3998static void __kmp_stg_print_init_at_fork(kmp_str_buf_t *buffer,
3999 char const *name,
void *data) {
4000 __kmp_stg_print_bool(buffer, name, __kmp_need_register_atfork_specified);
4006static void __kmp_stg_parse_schedule(
char const *name,
char const *value,
4009 if (value != NULL) {
4010 size_t length = KMP_STRLEN(value);
4011 if (length > INT_MAX) {
4012 KMP_WARNING(LongValue, name);
4014 const char *semicolon;
4015 if (value[length - 1] ==
'"' || value[length - 1] ==
'\'')
4016 KMP_WARNING(UnbalancedQuotes, name);
4020 semicolon = strchr(value,
';');
4021 if (*value && semicolon != value) {
4022 const char *comma = strchr(value,
',');
4029 if (!__kmp_strcasecmp_with_sentinel(
"static", value, sentinel)) {
4030 if (!__kmp_strcasecmp_with_sentinel(
"greedy", comma,
';')) {
4031 __kmp_static = kmp_sch_static_greedy;
4033 }
else if (!__kmp_strcasecmp_with_sentinel(
"balanced", comma,
4035 __kmp_static = kmp_sch_static_balanced;
4038 }
else if (!__kmp_strcasecmp_with_sentinel(
"guided", value,
4040 if (!__kmp_strcasecmp_with_sentinel(
"iterative", comma,
';')) {
4041 __kmp_guided = kmp_sch_guided_iterative_chunked;
4043 }
else if (!__kmp_strcasecmp_with_sentinel(
"analytical", comma,
4046 __kmp_guided = kmp_sch_guided_analytical_chunked;
4050 KMP_WARNING(InvalidClause, name, value);
4052 KMP_WARNING(EmptyClause, name);
4053 }
while ((value = semicolon ? semicolon + 1 : NULL));
4059static void __kmp_stg_print_schedule(kmp_str_buf_t *buffer,
char const *name,
4061 if (__kmp_env_format) {
4062 KMP_STR_BUF_PRINT_NAME_EX(name);
4064 __kmp_str_buf_print(buffer,
" %s='", name);
4066 if (__kmp_static == kmp_sch_static_greedy) {
4067 __kmp_str_buf_print(buffer,
"%s",
"static,greedy");
4068 }
else if (__kmp_static == kmp_sch_static_balanced) {
4069 __kmp_str_buf_print(buffer,
"%s",
"static,balanced");
4071 if (__kmp_guided == kmp_sch_guided_iterative_chunked) {
4072 __kmp_str_buf_print(buffer,
";%s'\n",
"guided,iterative");
4073 }
else if (__kmp_guided == kmp_sch_guided_analytical_chunked) {
4074 __kmp_str_buf_print(buffer,
";%s'\n",
"guided,analytical");
4081static inline void __kmp_omp_schedule_restore() {
4082#if KMP_USE_HIER_SCHED
4083 __kmp_hier_scheds.deallocate();
4093static const char *__kmp_parse_single_omp_schedule(
const char *name,
4095 bool parse_hier =
false) {
4097 const char *ptr = value;
4104 while (*delim !=
',' && *delim !=
':' && *delim !=
'\0')
4106#if KMP_USE_HIER_SCHED
4107 kmp_hier_layer_e layer = kmp_hier_layer_e::LAYER_THREAD;
4109 if (*delim ==
',') {
4110 if (!__kmp_strcasecmp_with_sentinel(
"L1", ptr,
',')) {
4111 layer = kmp_hier_layer_e::LAYER_L1;
4112 }
else if (!__kmp_strcasecmp_with_sentinel(
"L2", ptr,
',')) {
4113 layer = kmp_hier_layer_e::LAYER_L2;
4114 }
else if (!__kmp_strcasecmp_with_sentinel(
"L3", ptr,
',')) {
4115 layer = kmp_hier_layer_e::LAYER_L3;
4116 }
else if (!__kmp_strcasecmp_with_sentinel(
"NUMA", ptr,
',')) {
4117 layer = kmp_hier_layer_e::LAYER_NUMA;
4120 if (layer != kmp_hier_layer_e::LAYER_THREAD && *delim !=
',') {
4122 KMP_WARNING(StgInvalidValue, name, value);
4123 __kmp_omp_schedule_restore();
4125 }
else if (layer != kmp_hier_layer_e::LAYER_THREAD) {
4127 while (*delim !=
',' && *delim !=
':' && *delim !=
'\0')
4134 if (*delim ==
':') {
4135 if (!__kmp_strcasecmp_with_sentinel(
"monotonic", ptr, *delim)) {
4138 while (*delim !=
',' && *delim !=
':' && *delim !=
'\0')
4140 }
else if (!__kmp_strcasecmp_with_sentinel(
"nonmonotonic", ptr, *delim)) {
4143 while (*delim !=
',' && *delim !=
':' && *delim !=
'\0')
4145 }
else if (!parse_hier) {
4147 KMP_WARNING(StgInvalidValue, name, value);
4148 __kmp_omp_schedule_restore();
4153 if (!__kmp_strcasecmp_with_sentinel(
"dynamic", ptr, *delim))
4154 sched = kmp_sch_dynamic_chunked;
4155 else if (!__kmp_strcasecmp_with_sentinel(
"guided", ptr, *delim))
4158 else if (!__kmp_strcasecmp_with_sentinel(
"auto", ptr, *delim))
4160 else if (!__kmp_strcasecmp_with_sentinel(
"trapezoidal", ptr, *delim))
4161 sched = kmp_sch_trapezoidal;
4162 else if (!__kmp_strcasecmp_with_sentinel(
"static", ptr, *delim))
4164#if KMP_STATIC_STEAL_ENABLED
4165 else if (!__kmp_strcasecmp_with_sentinel(
"static_steal", ptr, *delim)) {
4167 sched = kmp_sch_dynamic_chunked;
4173 KMP_WARNING(StgInvalidValue, name, value);
4174 __kmp_omp_schedule_restore();
4179 if (*delim ==
',') {
4182 if (!isdigit(*ptr)) {
4184 KMP_WARNING(StgInvalidValue, name, value);
4185 __kmp_omp_schedule_restore();
4191 __kmp_msg(kmp_ms_warning, KMP_MSG(IgnoreChunk, name, delim),
4195 sched = kmp_sch_static_chunked;
4196 chunk = __kmp_str_to_int(delim + 1, *ptr);
4198 chunk = KMP_DEFAULT_CHUNK;
4199 __kmp_msg(kmp_ms_warning, KMP_MSG(InvalidChunk, name, delim),
4201 KMP_INFORM(Using_int_Value, name, __kmp_chunk);
4210 }
else if (chunk > KMP_MAX_CHUNK) {
4211 chunk = KMP_MAX_CHUNK;
4212 __kmp_msg(kmp_ms_warning, KMP_MSG(LargeChunk, name, delim),
4214 KMP_INFORM(Using_int_Value, name, chunk);
4221 SCHEDULE_SET_MODIFIERS(sched, sched_modifier);
4223#if KMP_USE_HIER_SCHED
4224 if (layer != kmp_hier_layer_e::LAYER_THREAD) {
4225 __kmp_hier_scheds.append(sched, chunk, layer);
4229 __kmp_chunk = chunk;
4230 __kmp_sched = sched;
4235static void __kmp_stg_parse_omp_schedule(
char const *name,
char const *value,
4238 const char *ptr = value;
4241 length = KMP_STRLEN(value);
4243 if (value[length - 1] ==
'"' || value[length - 1] ==
'\'')
4244 KMP_WARNING(UnbalancedQuotes, name);
4246#if KMP_USE_HIER_SCHED
4247 if (!__kmp_strcasecmp_with_sentinel(
"EXPERIMENTAL", ptr,
' ')) {
4250 while ((ptr = __kmp_parse_single_omp_schedule(name, ptr,
true))) {
4251 while (*ptr ==
' ' || *ptr ==
'\t' || *ptr ==
':')
4258 __kmp_parse_single_omp_schedule(name, ptr);
4260 KMP_WARNING(EmptyString, name);
4262#if KMP_USE_HIER_SCHED
4263 __kmp_hier_scheds.sort();
4265 K_DIAG(1, (
"__kmp_static == %d\n", __kmp_static))
4266 K_DIAG(1, (
"__kmp_guided == %d\n", __kmp_guided))
4267 K_DIAG(1, (
"__kmp_sched == %d\n", __kmp_sched))
4268 K_DIAG(1, (
"__kmp_chunk == %d\n", __kmp_chunk))
4271static void __kmp_stg_print_omp_schedule(kmp_str_buf_t *buffer,
4272 char const *name,
void *data) {
4273 if (__kmp_env_format) {
4274 KMP_STR_BUF_PRINT_NAME_EX(name);
4276 __kmp_str_buf_print(buffer,
" %s='", name);
4278 enum sched_type sched = SCHEDULE_WITHOUT_MODIFIERS(__kmp_sched);
4279 if (SCHEDULE_HAS_MONOTONIC(__kmp_sched)) {
4280 __kmp_str_buf_print(buffer,
"monotonic:");
4281 }
else if (SCHEDULE_HAS_NONMONOTONIC(__kmp_sched)) {
4282 __kmp_str_buf_print(buffer,
"nonmonotonic:");
4286 case kmp_sch_dynamic_chunked:
4287 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"dynamic", __kmp_chunk);
4289 case kmp_sch_guided_iterative_chunked:
4290 case kmp_sch_guided_analytical_chunked:
4291 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"guided", __kmp_chunk);
4293 case kmp_sch_trapezoidal:
4294 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"trapezoidal", __kmp_chunk);
4297 case kmp_sch_static_chunked:
4298 case kmp_sch_static_balanced:
4299 case kmp_sch_static_greedy:
4300 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"static", __kmp_chunk);
4302 case kmp_sch_static_steal:
4303 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"static_steal", __kmp_chunk);
4306 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"auto", __kmp_chunk);
4311 case kmp_sch_dynamic_chunked:
4312 __kmp_str_buf_print(buffer,
"%s'\n",
"dynamic");
4314 case kmp_sch_guided_iterative_chunked:
4315 case kmp_sch_guided_analytical_chunked:
4316 __kmp_str_buf_print(buffer,
"%s'\n",
"guided");
4318 case kmp_sch_trapezoidal:
4319 __kmp_str_buf_print(buffer,
"%s'\n",
"trapezoidal");
4322 case kmp_sch_static_chunked:
4323 case kmp_sch_static_balanced:
4324 case kmp_sch_static_greedy:
4325 __kmp_str_buf_print(buffer,
"%s'\n",
"static");
4327 case kmp_sch_static_steal:
4328 __kmp_str_buf_print(buffer,
"%s'\n",
"static_steal");
4331 __kmp_str_buf_print(buffer,
"%s'\n",
"auto");
4337#if KMP_USE_HIER_SCHED
4340static void __kmp_stg_parse_kmp_hand_thread(
char const *name,
char const *value,
4342 __kmp_stg_parse_bool(name, value, &(__kmp_dispatch_hand_threading));
4345static void __kmp_stg_print_kmp_hand_thread(kmp_str_buf_t *buffer,
4346 char const *name,
void *data) {
4347 __kmp_stg_print_bool(buffer, name, __kmp_dispatch_hand_threading);
4353static void __kmp_stg_parse_kmp_force_monotonic(
char const *name,
4354 char const *value,
void *data) {
4355 __kmp_stg_parse_bool(name, value, &(__kmp_force_monotonic));
4358static void __kmp_stg_print_kmp_force_monotonic(kmp_str_buf_t *buffer,
4359 char const *name,
void *data) {
4360 __kmp_stg_print_bool(buffer, name, __kmp_force_monotonic);
4366static void __kmp_stg_parse_atomic_mode(
char const *name,
char const *value,
4372#ifdef KMP_GOMP_COMPAT
4375 __kmp_stg_parse_int(name, value, 0, max, &mode);
4380 __kmp_atomic_mode = mode;
4384static void __kmp_stg_print_atomic_mode(kmp_str_buf_t *buffer,
char const *name,
4386 __kmp_stg_print_int(buffer, name, __kmp_atomic_mode);
4392static void __kmp_stg_parse_consistency_check(
char const *name,
4393 char const *value,
void *data) {
4394 if (!__kmp_strcasecmp_with_sentinel(
"all", value, 0)) {
4400 __kmp_env_consistency_check = TRUE;
4401 }
else if (!__kmp_strcasecmp_with_sentinel(
"none", value, 0)) {
4402 __kmp_env_consistency_check = FALSE;
4404 KMP_WARNING(StgInvalidValue, name, value);
4408static void __kmp_stg_print_consistency_check(kmp_str_buf_t *buffer,
4409 char const *name,
void *data) {
4411 const char *value = NULL;
4413 if (__kmp_env_consistency_check) {
4419 if (value != NULL) {
4420 __kmp_stg_print_str(buffer, name, value);
4431static void __kmp_stg_parse_itt_prepare_delay(
char const *name,
4432 char const *value,
void *data) {
4436 __kmp_stg_parse_int(name, value, 0, INT_MAX, &delay);
4437 __kmp_itt_prepare_delay = delay;
4440static void __kmp_stg_print_itt_prepare_delay(kmp_str_buf_t *buffer,
4441 char const *name,
void *data) {
4442 __kmp_stg_print_uint64(buffer, name, __kmp_itt_prepare_delay);
4452static void __kmp_stg_parse_malloc_pool_incr(
char const *name,
4453 char const *value,
void *data) {
4454 __kmp_stg_parse_size(name, value, KMP_MIN_MALLOC_POOL_INCR,
4455 KMP_MAX_MALLOC_POOL_INCR, NULL, &__kmp_malloc_pool_incr,
4459static void __kmp_stg_print_malloc_pool_incr(kmp_str_buf_t *buffer,
4460 char const *name,
void *data) {
4461 __kmp_stg_print_size(buffer, name, __kmp_malloc_pool_incr);
4470static void __kmp_stg_parse_par_range_env(
char const *name,
char const *value,
4472 __kmp_stg_parse_par_range(name, value, &__kmp_par_range,
4473 __kmp_par_range_routine, __kmp_par_range_filename,
4474 &__kmp_par_range_lb, &__kmp_par_range_ub);
4477static void __kmp_stg_print_par_range_env(kmp_str_buf_t *buffer,
4478 char const *name,
void *data) {
4479 if (__kmp_par_range != 0) {
4480 __kmp_stg_print_str(buffer, name, par_range_to_print);
4489static void __kmp_stg_parse_gtid_mode(
char const *name,
char const *value,
4499#ifdef KMP_TDATA_GTID
4502 __kmp_stg_parse_int(name, value, 0, max, &mode);
4506 __kmp_adjust_gtid_mode = TRUE;
4508 __kmp_gtid_mode = mode;
4509 __kmp_adjust_gtid_mode = FALSE;
4513static void __kmp_stg_print_gtid_mode(kmp_str_buf_t *buffer,
char const *name,
4515 if (__kmp_adjust_gtid_mode) {
4516 __kmp_stg_print_int(buffer, name, 0);
4518 __kmp_stg_print_int(buffer, name, __kmp_gtid_mode);
4525static void __kmp_stg_parse_lock_block(
char const *name,
char const *value,
4527 __kmp_stg_parse_int(name, value, 0, KMP_INT_MAX, &__kmp_num_locks_in_block);
4530static void __kmp_stg_print_lock_block(kmp_str_buf_t *buffer,
char const *name,
4532 __kmp_stg_print_int(buffer, name, __kmp_num_locks_in_block);
4538#if KMP_USE_DYNAMIC_LOCK
4539#define KMP_STORE_LOCK_SEQ(a) (__kmp_user_lock_seq = lockseq_##a)
4541#define KMP_STORE_LOCK_SEQ(a)
4544static void __kmp_stg_parse_lock_kind(
char const *name,
char const *value,
4546 if (__kmp_init_user_locks) {
4547 KMP_WARNING(EnvLockWarn, name);
4551 if (__kmp_str_match(
"tas", 2, value) ||
4552 __kmp_str_match(
"test and set", 2, value) ||
4553 __kmp_str_match(
"test_and_set", 2, value) ||
4554 __kmp_str_match(
"test-and-set", 2, value) ||
4555 __kmp_str_match(
"test andset", 2, value) ||
4556 __kmp_str_match(
"test_andset", 2, value) ||
4557 __kmp_str_match(
"test-andset", 2, value) ||
4558 __kmp_str_match(
"testand set", 2, value) ||
4559 __kmp_str_match(
"testand_set", 2, value) ||
4560 __kmp_str_match(
"testand-set", 2, value) ||
4561 __kmp_str_match(
"testandset", 2, value)) {
4562 __kmp_user_lock_kind = lk_tas;
4563 KMP_STORE_LOCK_SEQ(tas);
4566 else if (__kmp_str_match(
"futex", 1, value)) {
4567 if (__kmp_futex_determine_capable()) {
4568 __kmp_user_lock_kind = lk_futex;
4569 KMP_STORE_LOCK_SEQ(futex);
4571 KMP_WARNING(FutexNotSupported, name, value);
4575 else if (__kmp_str_match(
"ticket", 2, value)) {
4576 __kmp_user_lock_kind = lk_ticket;
4577 KMP_STORE_LOCK_SEQ(ticket);
4578 }
else if (__kmp_str_match(
"queuing", 1, value) ||
4579 __kmp_str_match(
"queue", 1, value)) {
4580 __kmp_user_lock_kind = lk_queuing;
4581 KMP_STORE_LOCK_SEQ(queuing);
4582 }
else if (__kmp_str_match(
"drdpa ticket", 1, value) ||
4583 __kmp_str_match(
"drdpa_ticket", 1, value) ||
4584 __kmp_str_match(
"drdpa-ticket", 1, value) ||
4585 __kmp_str_match(
"drdpaticket", 1, value) ||
4586 __kmp_str_match(
"drdpa", 1, value)) {
4587 __kmp_user_lock_kind = lk_drdpa;
4588 KMP_STORE_LOCK_SEQ(drdpa);
4590#if KMP_USE_ADAPTIVE_LOCKS
4591 else if (__kmp_str_match(
"adaptive", 1, value)) {
4592 if (__kmp_cpuinfo.flags.rtm) {
4593 __kmp_user_lock_kind = lk_adaptive;
4594 KMP_STORE_LOCK_SEQ(adaptive);
4596 KMP_WARNING(AdaptiveNotSupported, name, value);
4597 __kmp_user_lock_kind = lk_queuing;
4598 KMP_STORE_LOCK_SEQ(queuing);
4602#if KMP_USE_DYNAMIC_LOCK && KMP_USE_TSX
4603 else if (__kmp_str_match(
"rtm_queuing", 1, value)) {
4604 if (__kmp_cpuinfo.flags.rtm) {
4605 __kmp_user_lock_kind = lk_rtm_queuing;
4606 KMP_STORE_LOCK_SEQ(rtm_queuing);
4608 KMP_WARNING(AdaptiveNotSupported, name, value);
4609 __kmp_user_lock_kind = lk_queuing;
4610 KMP_STORE_LOCK_SEQ(queuing);
4612 }
else if (__kmp_str_match(
"rtm_spin", 1, value)) {
4613 if (__kmp_cpuinfo.flags.rtm) {
4614 __kmp_user_lock_kind = lk_rtm_spin;
4615 KMP_STORE_LOCK_SEQ(rtm_spin);
4617 KMP_WARNING(AdaptiveNotSupported, name, value);
4618 __kmp_user_lock_kind = lk_tas;
4619 KMP_STORE_LOCK_SEQ(queuing);
4621 }
else if (__kmp_str_match(
"hle", 1, value)) {
4622 __kmp_user_lock_kind = lk_hle;
4623 KMP_STORE_LOCK_SEQ(hle);
4627 KMP_WARNING(StgInvalidValue, name, value);
4631static void __kmp_stg_print_lock_kind(kmp_str_buf_t *buffer,
char const *name,
4633 const char *value = NULL;
4635 switch (__kmp_user_lock_kind) {
4650#if KMP_USE_DYNAMIC_LOCK && KMP_USE_TSX
4651 case lk_rtm_queuing:
4652 value =
"rtm_queuing";
4675#if KMP_USE_ADAPTIVE_LOCKS
4682 if (value != NULL) {
4683 __kmp_stg_print_str(buffer, name, value);
4692static void __kmp_stg_parse_spin_backoff_params(
const char *name,
4693 const char *value,
void *data) {
4694 const char *next = value;
4697 int prev_comma = FALSE;
4700 kmp_uint32 max_backoff = __kmp_spin_backoff_params.max_backoff;
4701 kmp_uint32 min_tick = __kmp_spin_backoff_params.min_tick;
4705 for (i = 0; i < 3; i++) {
4708 if (*next ==
'\0') {
4713 if (((*next < '0' || *next >
'9') && *next !=
',') || total > 2) {
4714 KMP_WARNING(EnvSyntaxError, name, value);
4720 if (total == 0 || prev_comma) {
4728 if (*next >=
'0' && *next <=
'9') {
4730 const char *buf = next;
4731 char const *msg = NULL;
4736 const char *tmp = next;
4738 if ((*next ==
' ' || *next ==
'\t') && (*tmp >=
'0' && *tmp <=
'9')) {
4739 KMP_WARNING(EnvSpacesNotAllowed, name, value);
4743 num = __kmp_str_to_int(buf, *next);
4745 msg = KMP_I18N_STR(ValueTooSmall);
4747 }
else if (num > KMP_INT_MAX) {
4748 msg = KMP_I18N_STR(ValueTooLarge);
4753 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
4754 KMP_INFORM(Using_int_Value, name, num);
4758 }
else if (total == 2) {
4763 KMP_DEBUG_ASSERT(total > 0);
4765 KMP_WARNING(EnvSyntaxError, name, value);
4768 __kmp_spin_backoff_params.max_backoff = max_backoff;
4769 __kmp_spin_backoff_params.min_tick = min_tick;
4772static void __kmp_stg_print_spin_backoff_params(kmp_str_buf_t *buffer,
4773 char const *name,
void *data) {
4774 if (__kmp_env_format) {
4775 KMP_STR_BUF_PRINT_NAME_EX(name);
4777 __kmp_str_buf_print(buffer,
" %s='", name);
4779 __kmp_str_buf_print(buffer,
"%d,%d'\n", __kmp_spin_backoff_params.max_backoff,
4780 __kmp_spin_backoff_params.min_tick);
4783#if KMP_USE_ADAPTIVE_LOCKS
4790static void __kmp_stg_parse_adaptive_lock_props(
const char *name,
4791 const char *value,
void *data) {
4792 int max_retries = 0;
4793 int max_badness = 0;
4795 const char *next = value;
4798 int prev_comma = FALSE;
4804 for (i = 0; i < 3; i++) {
4807 if (*next ==
'\0') {
4812 if (((*next < '0' || *next >
'9') && *next !=
',') || total > 2) {
4813 KMP_WARNING(EnvSyntaxError, name, value);
4819 if (total == 0 || prev_comma) {
4827 if (*next >=
'0' && *next <=
'9') {
4829 const char *buf = next;
4830 char const *msg = NULL;
4835 const char *tmp = next;
4837 if ((*next ==
' ' || *next ==
'\t') && (*tmp >=
'0' && *tmp <=
'9')) {
4838 KMP_WARNING(EnvSpacesNotAllowed, name, value);
4842 num = __kmp_str_to_int(buf, *next);
4844 msg = KMP_I18N_STR(ValueTooSmall);
4846 }
else if (num > KMP_INT_MAX) {
4847 msg = KMP_I18N_STR(ValueTooLarge);
4852 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
4853 KMP_INFORM(Using_int_Value, name, num);
4857 }
else if (total == 2) {
4862 KMP_DEBUG_ASSERT(total > 0);
4864 KMP_WARNING(EnvSyntaxError, name, value);
4867 __kmp_adaptive_backoff_params.max_soft_retries = max_retries;
4868 __kmp_adaptive_backoff_params.max_badness = max_badness;
4871static void __kmp_stg_print_adaptive_lock_props(kmp_str_buf_t *buffer,
4872 char const *name,
void *data) {
4873 if (__kmp_env_format) {
4874 KMP_STR_BUF_PRINT_NAME_EX(name);
4876 __kmp_str_buf_print(buffer,
" %s='", name);
4878 __kmp_str_buf_print(buffer,
"%d,%d'\n",
4879 __kmp_adaptive_backoff_params.max_soft_retries,
4880 __kmp_adaptive_backoff_params.max_badness);
4883#if KMP_DEBUG_ADAPTIVE_LOCKS
4885static void __kmp_stg_parse_speculative_statsfile(
char const *name,
4888 __kmp_stg_parse_file(name, value,
"",
4889 CCAST(
char **, &__kmp_speculative_statsfile));
4892static void __kmp_stg_print_speculative_statsfile(kmp_str_buf_t *buffer,
4895 if (__kmp_str_match(
"-", 0, __kmp_speculative_statsfile)) {
4896 __kmp_stg_print_str(buffer, name,
"stdout");
4898 __kmp_stg_print_str(buffer, name, __kmp_speculative_statsfile);
4914static kmp_hw_t __kmp_hw_subset_break_tie(
const kmp_hw_t *possible,
4915 size_t num_possible) {
4916 for (
size_t i = 0; i < num_possible; ++i) {
4917 if (possible[i] == KMP_HW_THREAD)
4918 return KMP_HW_THREAD;
4919 else if (possible[i] == KMP_HW_CORE)
4921 else if (possible[i] == KMP_HW_SOCKET)
4922 return KMP_HW_SOCKET;
4924 return KMP_HW_UNKNOWN;
4931static kmp_hw_t __kmp_stg_parse_hw_subset_name(
char const *token) {
4932 size_t index, num_possible, token_length;
4933 kmp_hw_t possible[KMP_HW_LAST];
4939 while (isalnum(*end) || *end ==
'_') {
4946 KMP_FOREACH_HW_TYPE(type) { possible[num_possible++] = type; }
4953 while (num_possible > 1 && index < token_length) {
4954 size_t n = num_possible;
4955 char token_char = (char)toupper(token[index]);
4956 for (
size_t i = 0; i < n; ++i) {
4958 kmp_hw_t type = possible[i];
4959 s = __kmp_hw_get_keyword(type,
false);
4960 if (index < KMP_STRLEN(s)) {
4961 char c = (char)toupper(s[index]);
4963 if (c != token_char) {
4964 possible[i] = KMP_HW_UNKNOWN;
4971 for (
size_t i = 0; i < n; ++i) {
4972 if (possible[i] != KMP_HW_UNKNOWN) {
4973 kmp_hw_t temp = possible[i];
4974 possible[i] = possible[start];
4975 possible[start] = temp;
4979 KMP_ASSERT(start == num_possible);
4985 if (num_possible > 1)
4986 return __kmp_hw_subset_break_tie(possible, num_possible);
4987 if (num_possible == 1)
4989 return KMP_HW_UNKNOWN;
4994#define MAX_T_LEVEL KMP_HW_LAST
4995#define MAX_STR_LEN 512
4996static void __kmp_stg_parse_hw_subset(
char const *name,
char const *value,
5000 kmp_setting_t **rivals = (kmp_setting_t **)data;
5001 if (strcmp(name,
"KMP_PLACE_THREADS") == 0) {
5002 KMP_INFORM(EnvVarDeprecated, name,
"KMP_HW_SUBSET");
5004 if (__kmp_stg_check_rivals(name, value, rivals)) {
5008 char *components[MAX_T_LEVEL];
5009 char const *digits =
"0123456789";
5010 char input[MAX_STR_LEN];
5011 size_t len = 0, mlen = MAX_STR_LEN;
5013 bool absolute =
false;
5015 char *pos = CCAST(
char *, value);
5016 while (*pos && mlen) {
5018 if (len == 0 && *pos ==
':') {
5021 input[len] = (char)(toupper(*pos));
5022 if (input[len] ==
'X')
5024 if (input[len] ==
'O' && strchr(digits, *(pos + 1)))
5032 if (len == 0 || mlen == 0) {
5038 components[level++] = pos;
5039 while ((pos = strchr(pos,
','))) {
5040 if (level >= MAX_T_LEVEL)
5043 components[level++] = ++pos;
5046 __kmp_hw_subset = kmp_hw_subset_t::allocate();
5048 __kmp_hw_subset->set_absolute();
5051 for (
int i = 0; i < level; ++i) {
5053 char *core_components[MAX_T_LEVEL];
5055 pos = components[i];
5056 core_components[core_level++] = pos;
5057 while ((pos = strchr(pos,
'&'))) {
5058 if (core_level >= MAX_T_LEVEL)
5061 core_components[core_level++] = ++pos;
5064 for (
int j = 0; j < core_level; ++j) {
5071 if (isdigit(*core_components[j])) {
5072 num = atoi(core_components[j]);
5076 pos = core_components[j] + strspn(core_components[j], digits);
5077 }
else if (*core_components[j] ==
'*') {
5078 num = kmp_hw_subset_t::USE_ALL;
5079 pos = core_components[j] + 1;
5081 num = kmp_hw_subset_t::USE_ALL;
5082 pos = core_components[j];
5085 offset_ptr = strchr(core_components[j],
'@');
5086 attr_ptr = strchr(core_components[j],
':');
5089 offset = atoi(offset_ptr + 1);
5095#if KMP_ARCH_X86 || KMP_ARCH_X86_64
5096 if (__kmp_str_match(
"intel_core", -1, attr_ptr + 1)) {
5097 attr.set_core_type(KMP_HW_CORE_TYPE_CORE);
5098 }
else if (__kmp_str_match(
"intel_atom", -1, attr_ptr + 1)) {
5099 attr.set_core_type(KMP_HW_CORE_TYPE_ATOM);
5102 if (__kmp_str_match(
"eff", 3, attr_ptr + 1)) {
5103 const char *number = attr_ptr + 1;
5105 while (isalpha(*number))
5107 if (!isdigit(*number)) {
5110 int efficiency = atoi(number);
5111 attr.set_core_eff(efficiency);
5118 kmp_hw_t type = __kmp_stg_parse_hw_subset_name(pos);
5119 if (type == KMP_HW_UNKNOWN) {
5123 if (attr && type != KMP_HW_CORE)
5126 if (type != KMP_HW_CORE && __kmp_hw_subset->specified(type)) {
5129 __kmp_hw_subset->push_back(num, type, offset, attr);
5134 KMP_WARNING(AffHWSubsetInvalid, name, value);
5135 if (__kmp_hw_subset) {
5136 kmp_hw_subset_t::deallocate(__kmp_hw_subset);
5137 __kmp_hw_subset =
nullptr;
5142static inline const char *
5143__kmp_hw_get_core_type_keyword(kmp_hw_core_type_t type) {
5145 case KMP_HW_CORE_TYPE_UNKNOWN:
5147#if KMP_ARCH_X86 || KMP_ARCH_X86_64
5148 case KMP_HW_CORE_TYPE_ATOM:
5149 return "intel_atom";
5150 case KMP_HW_CORE_TYPE_CORE:
5151 return "intel_core";
5157static void __kmp_stg_print_hw_subset(kmp_str_buf_t *buffer,
char const *name,
5161 if (!__kmp_hw_subset)
5163 __kmp_str_buf_init(&buf);
5164 if (__kmp_env_format)
5165 KMP_STR_BUF_PRINT_NAME_EX(name);
5167 __kmp_str_buf_print(buffer,
" %s='", name);
5169 depth = __kmp_hw_subset->get_depth();
5170 for (
int i = 0; i < depth; ++i) {
5171 const auto &item = __kmp_hw_subset->at(i);
5173 __kmp_str_buf_print(&buf,
"%c",
',');
5174 for (
int j = 0; j < item.num_attrs; ++j) {
5175 __kmp_str_buf_print(&buf,
"%s%d%s", (j > 0 ?
"&" :
""), item.num[j],
5176 __kmp_hw_get_keyword(item.type));
5177 if (item.attr[j].is_core_type_valid())
5178 __kmp_str_buf_print(
5180 __kmp_hw_get_core_type_keyword(item.attr[j].get_core_type()));
5181 if (item.attr[j].is_core_eff_valid())
5182 __kmp_str_buf_print(&buf,
":eff%d", item.attr[j].get_core_eff());
5184 __kmp_str_buf_print(&buf,
"@%d", item.offset[j]);
5187 __kmp_str_buf_print(buffer,
"%s'\n", buf.str);
5188 __kmp_str_buf_free(&buf);
5195static void __kmp_stg_parse_forkjoin_frames(
char const *name,
char const *value,
5197 __kmp_stg_parse_bool(name, value, &__kmp_forkjoin_frames);
5200static void __kmp_stg_print_forkjoin_frames(kmp_str_buf_t *buffer,
5201 char const *name,
void *data) {
5202 __kmp_stg_print_bool(buffer, name, __kmp_forkjoin_frames);
5208static void __kmp_stg_parse_forkjoin_frames_mode(
char const *name,
5211 __kmp_stg_parse_int(name, value, 0, 3, &__kmp_forkjoin_frames_mode);
5214static void __kmp_stg_print_forkjoin_frames_mode(kmp_str_buf_t *buffer,
5215 char const *name,
void *data) {
5216 __kmp_stg_print_int(buffer, name, __kmp_forkjoin_frames_mode);
5223static void __kmp_stg_parse_task_throttling(
char const *name,
char const *value,
5225 __kmp_stg_parse_bool(name, value, &__kmp_enable_task_throttling);
5228static void __kmp_stg_print_task_throttling(kmp_str_buf_t *buffer,
5229 char const *name,
void *data) {
5230 __kmp_stg_print_bool(buffer, name, __kmp_enable_task_throttling);
5233#if KMP_HAVE_MWAIT || KMP_HAVE_UMWAIT
5237static void __kmp_stg_parse_user_level_mwait(
char const *name,
5238 char const *value,
void *data) {
5239 __kmp_stg_parse_bool(name, value, &__kmp_user_level_mwait);
5242static void __kmp_stg_print_user_level_mwait(kmp_str_buf_t *buffer,
5243 char const *name,
void *data) {
5244 __kmp_stg_print_bool(buffer, name, __kmp_user_level_mwait);
5250static void __kmp_stg_parse_mwait_hints(
char const *name,
char const *value,
5252 __kmp_stg_parse_int(name, value, 0, INT_MAX, &__kmp_mwait_hints);
5255static void __kmp_stg_print_mwait_hints(kmp_str_buf_t *buffer,
char const *name,
5257 __kmp_stg_print_int(buffer, name, __kmp_mwait_hints);
5267static void __kmp_stg_parse_tpause(
char const *name,
char const *value,
5269 __kmp_stg_parse_int(name, value, 0, INT_MAX, &__kmp_tpause_state);
5270 if (__kmp_tpause_state != 0) {
5272 if (__kmp_tpause_state == 2)
5273 __kmp_tpause_hint = 0;
5277static void __kmp_stg_print_tpause(kmp_str_buf_t *buffer,
char const *name,
5279 __kmp_stg_print_int(buffer, name, __kmp_tpause_state);
5286static void __kmp_stg_parse_omp_display_env(
char const *name,
char const *value,
5288 if (__kmp_str_match(
"VERBOSE", 1, value)) {
5289 __kmp_display_env_verbose = TRUE;
5291 __kmp_stg_parse_bool(name, value, &__kmp_display_env);
5295static void __kmp_stg_print_omp_display_env(kmp_str_buf_t *buffer,
5296 char const *name,
void *data) {
5297 if (__kmp_display_env_verbose) {
5298 __kmp_stg_print_str(buffer, name,
"VERBOSE");
5300 __kmp_stg_print_bool(buffer, name, __kmp_display_env);
5304static void __kmp_stg_parse_omp_cancellation(
char const *name,
5305 char const *value,
void *data) {
5306 if (TCR_4(__kmp_init_parallel)) {
5307 KMP_WARNING(EnvParallelWarn, name);
5310 __kmp_stg_parse_bool(name, value, &__kmp_omp_cancellation);
5313static void __kmp_stg_print_omp_cancellation(kmp_str_buf_t *buffer,
5314 char const *name,
void *data) {
5315 __kmp_stg_print_bool(buffer, name, __kmp_omp_cancellation);
5321static void __kmp_stg_parse_omp_tool(
char const *name,
char const *value,
5323 __kmp_stg_parse_bool(name, value, &__kmp_tool);
5326static void __kmp_stg_print_omp_tool(kmp_str_buf_t *buffer,
char const *name,
5328 if (__kmp_env_format) {
5329 KMP_STR_BUF_PRINT_BOOL_EX(name, __kmp_tool,
"enabled",
"disabled");
5331 __kmp_str_buf_print(buffer,
" %s=%s\n", name,
5332 __kmp_tool ?
"enabled" :
"disabled");
5336char *__kmp_tool_libraries = NULL;
5338static void __kmp_stg_parse_omp_tool_libraries(
char const *name,
5339 char const *value,
void *data) {
5340 __kmp_stg_parse_str(name, value, &__kmp_tool_libraries);
5343static void __kmp_stg_print_omp_tool_libraries(kmp_str_buf_t *buffer,
5344 char const *name,
void *data) {
5345 if (__kmp_tool_libraries)
5346 __kmp_stg_print_str(buffer, name, __kmp_tool_libraries);
5348 if (__kmp_env_format) {
5349 KMP_STR_BUF_PRINT_NAME;
5351 __kmp_str_buf_print(buffer,
" %s", name);
5353 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
5357char *__kmp_tool_verbose_init = NULL;
5359static void __kmp_stg_parse_omp_tool_verbose_init(
char const *name,
5362 __kmp_stg_parse_str(name, value, &__kmp_tool_verbose_init);
5365static void __kmp_stg_print_omp_tool_verbose_init(kmp_str_buf_t *buffer,
5368 if (__kmp_tool_verbose_init)
5369 __kmp_stg_print_str(buffer, name, __kmp_tool_verbose_init);
5371 if (__kmp_env_format) {
5372 KMP_STR_BUF_PRINT_NAME;
5374 __kmp_str_buf_print(buffer,
" %s", name);
5376 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
5384static kmp_setting_t __kmp_stg_table[] = {
5386 {
"KMP_ALL_THREADS", __kmp_stg_parse_device_thread_limit, NULL, NULL, 0, 0},
5387 {
"KMP_BLOCKTIME", __kmp_stg_parse_blocktime, __kmp_stg_print_blocktime,
5389 {
"KMP_USE_YIELD", __kmp_stg_parse_use_yield, __kmp_stg_print_use_yield,
5391 {
"KMP_DUPLICATE_LIB_OK", __kmp_stg_parse_duplicate_lib_ok,
5392 __kmp_stg_print_duplicate_lib_ok, NULL, 0, 0},
5393 {
"KMP_LIBRARY", __kmp_stg_parse_wait_policy, __kmp_stg_print_wait_policy,
5395 {
"KMP_DEVICE_THREAD_LIMIT", __kmp_stg_parse_device_thread_limit,
5396 __kmp_stg_print_device_thread_limit, NULL, 0, 0},
5398 {
"KMP_MONITOR_STACKSIZE", __kmp_stg_parse_monitor_stacksize,
5399 __kmp_stg_print_monitor_stacksize, NULL, 0, 0},
5401 {
"KMP_SETTINGS", __kmp_stg_parse_settings, __kmp_stg_print_settings, NULL,
5403 {
"KMP_STACKOFFSET", __kmp_stg_parse_stackoffset,
5404 __kmp_stg_print_stackoffset, NULL, 0, 0},
5405 {
"KMP_STACKSIZE", __kmp_stg_parse_stacksize, __kmp_stg_print_stacksize,
5407 {
"KMP_STACKPAD", __kmp_stg_parse_stackpad, __kmp_stg_print_stackpad, NULL,
5409 {
"KMP_VERSION", __kmp_stg_parse_version, __kmp_stg_print_version, NULL, 0,
5411 {
"KMP_WARNINGS", __kmp_stg_parse_warnings, __kmp_stg_print_warnings, NULL,
5414 {
"KMP_NESTING_MODE", __kmp_stg_parse_nesting_mode,
5415 __kmp_stg_print_nesting_mode, NULL, 0, 0},
5416 {
"OMP_NESTED", __kmp_stg_parse_nested, __kmp_stg_print_nested, NULL, 0, 0},
5417 {
"OMP_NUM_THREADS", __kmp_stg_parse_num_threads,
5418 __kmp_stg_print_num_threads, NULL, 0, 0},
5419 {
"OMP_STACKSIZE", __kmp_stg_parse_stacksize, __kmp_stg_print_stacksize,
5422 {
"KMP_TASKING", __kmp_stg_parse_tasking, __kmp_stg_print_tasking, NULL, 0,
5424 {
"KMP_TASK_STEALING_CONSTRAINT", __kmp_stg_parse_task_stealing,
5425 __kmp_stg_print_task_stealing, NULL, 0, 0},
5426 {
"OMP_MAX_ACTIVE_LEVELS", __kmp_stg_parse_max_active_levels,
5427 __kmp_stg_print_max_active_levels, NULL, 0, 0},
5428 {
"OMP_DEFAULT_DEVICE", __kmp_stg_parse_default_device,
5429 __kmp_stg_print_default_device, NULL, 0, 0},
5430 {
"OMP_TARGET_OFFLOAD", __kmp_stg_parse_target_offload,
5431 __kmp_stg_print_target_offload, NULL, 0, 0},
5432 {
"OMP_MAX_TASK_PRIORITY", __kmp_stg_parse_max_task_priority,
5433 __kmp_stg_print_max_task_priority, NULL, 0, 0},
5434 {
"KMP_TASKLOOP_MIN_TASKS", __kmp_stg_parse_taskloop_min_tasks,
5435 __kmp_stg_print_taskloop_min_tasks, NULL, 0, 0},
5436 {
"OMP_THREAD_LIMIT", __kmp_stg_parse_thread_limit,
5437 __kmp_stg_print_thread_limit, NULL, 0, 0},
5438 {
"KMP_TEAMS_THREAD_LIMIT", __kmp_stg_parse_teams_thread_limit,
5439 __kmp_stg_print_teams_thread_limit, NULL, 0, 0},
5440 {
"OMP_NUM_TEAMS", __kmp_stg_parse_nteams, __kmp_stg_print_nteams, NULL, 0,
5442 {
"OMP_TEAMS_THREAD_LIMIT", __kmp_stg_parse_teams_th_limit,
5443 __kmp_stg_print_teams_th_limit, NULL, 0, 0},
5444 {
"OMP_WAIT_POLICY", __kmp_stg_parse_wait_policy,
5445 __kmp_stg_print_wait_policy, NULL, 0, 0},
5446 {
"KMP_DISP_NUM_BUFFERS", __kmp_stg_parse_disp_buffers,
5447 __kmp_stg_print_disp_buffers, NULL, 0, 0},
5448#if KMP_NESTED_HOT_TEAMS
5449 {
"KMP_HOT_TEAMS_MAX_LEVEL", __kmp_stg_parse_hot_teams_level,
5450 __kmp_stg_print_hot_teams_level, NULL, 0, 0},
5451 {
"KMP_HOT_TEAMS_MODE", __kmp_stg_parse_hot_teams_mode,
5452 __kmp_stg_print_hot_teams_mode, NULL, 0, 0},
5455#if KMP_HANDLE_SIGNALS
5456 {
"KMP_HANDLE_SIGNALS", __kmp_stg_parse_handle_signals,
5457 __kmp_stg_print_handle_signals, NULL, 0, 0},
5460#if KMP_ARCH_X86 || KMP_ARCH_X86_64
5461 {
"KMP_INHERIT_FP_CONTROL", __kmp_stg_parse_inherit_fp_control,
5462 __kmp_stg_print_inherit_fp_control, NULL, 0, 0},
5465#ifdef KMP_GOMP_COMPAT
5466 {
"GOMP_STACKSIZE", __kmp_stg_parse_stacksize, NULL, NULL, 0, 0},
5470 {
"KMP_A_DEBUG", __kmp_stg_parse_a_debug, __kmp_stg_print_a_debug, NULL, 0,
5472 {
"KMP_B_DEBUG", __kmp_stg_parse_b_debug, __kmp_stg_print_b_debug, NULL, 0,
5474 {
"KMP_C_DEBUG", __kmp_stg_parse_c_debug, __kmp_stg_print_c_debug, NULL, 0,
5476 {
"KMP_D_DEBUG", __kmp_stg_parse_d_debug, __kmp_stg_print_d_debug, NULL, 0,
5478 {
"KMP_E_DEBUG", __kmp_stg_parse_e_debug, __kmp_stg_print_e_debug, NULL, 0,
5480 {
"KMP_F_DEBUG", __kmp_stg_parse_f_debug, __kmp_stg_print_f_debug, NULL, 0,
5482 {
"KMP_DEBUG", __kmp_stg_parse_debug, NULL, NULL, 0, 0},
5483 {
"KMP_DEBUG_BUF", __kmp_stg_parse_debug_buf, __kmp_stg_print_debug_buf,
5485 {
"KMP_DEBUG_BUF_ATOMIC", __kmp_stg_parse_debug_buf_atomic,
5486 __kmp_stg_print_debug_buf_atomic, NULL, 0, 0},
5487 {
"KMP_DEBUG_BUF_CHARS", __kmp_stg_parse_debug_buf_chars,
5488 __kmp_stg_print_debug_buf_chars, NULL, 0, 0},
5489 {
"KMP_DEBUG_BUF_LINES", __kmp_stg_parse_debug_buf_lines,
5490 __kmp_stg_print_debug_buf_lines, NULL, 0, 0},
5491 {
"KMP_DIAG", __kmp_stg_parse_diag, __kmp_stg_print_diag, NULL, 0, 0},
5493 {
"KMP_PAR_RANGE", __kmp_stg_parse_par_range_env,
5494 __kmp_stg_print_par_range_env, NULL, 0, 0},
5497 {
"KMP_ALIGN_ALLOC", __kmp_stg_parse_align_alloc,
5498 __kmp_stg_print_align_alloc, NULL, 0, 0},
5500 {
"KMP_PLAIN_BARRIER", __kmp_stg_parse_barrier_branch_bit,
5501 __kmp_stg_print_barrier_branch_bit, NULL, 0, 0},
5502 {
"KMP_PLAIN_BARRIER_PATTERN", __kmp_stg_parse_barrier_pattern,
5503 __kmp_stg_print_barrier_pattern, NULL, 0, 0},
5504 {
"KMP_FORKJOIN_BARRIER", __kmp_stg_parse_barrier_branch_bit,
5505 __kmp_stg_print_barrier_branch_bit, NULL, 0, 0},
5506 {
"KMP_FORKJOIN_BARRIER_PATTERN", __kmp_stg_parse_barrier_pattern,
5507 __kmp_stg_print_barrier_pattern, NULL, 0, 0},
5508#if KMP_FAST_REDUCTION_BARRIER
5509 {
"KMP_REDUCTION_BARRIER", __kmp_stg_parse_barrier_branch_bit,
5510 __kmp_stg_print_barrier_branch_bit, NULL, 0, 0},
5511 {
"KMP_REDUCTION_BARRIER_PATTERN", __kmp_stg_parse_barrier_pattern,
5512 __kmp_stg_print_barrier_pattern, NULL, 0, 0},
5515 {
"KMP_ABORT_DELAY", __kmp_stg_parse_abort_delay,
5516 __kmp_stg_print_abort_delay, NULL, 0, 0},
5517 {
"KMP_CPUINFO_FILE", __kmp_stg_parse_cpuinfo_file,
5518 __kmp_stg_print_cpuinfo_file, NULL, 0, 0},
5519 {
"KMP_FORCE_REDUCTION", __kmp_stg_parse_force_reduction,
5520 __kmp_stg_print_force_reduction, NULL, 0, 0},
5521 {
"KMP_DETERMINISTIC_REDUCTION", __kmp_stg_parse_force_reduction,
5522 __kmp_stg_print_force_reduction, NULL, 0, 0},
5523 {
"KMP_STORAGE_MAP", __kmp_stg_parse_storage_map,
5524 __kmp_stg_print_storage_map, NULL, 0, 0},
5525 {
"KMP_ALL_THREADPRIVATE", __kmp_stg_parse_all_threadprivate,
5526 __kmp_stg_print_all_threadprivate, NULL, 0, 0},
5527 {
"KMP_FOREIGN_THREADS_THREADPRIVATE",
5528 __kmp_stg_parse_foreign_threads_threadprivate,
5529 __kmp_stg_print_foreign_threads_threadprivate, NULL, 0, 0},
5531#if KMP_AFFINITY_SUPPORTED
5532 {
"KMP_AFFINITY", __kmp_stg_parse_affinity, __kmp_stg_print_affinity, NULL,
5534 {
"KMP_HIDDEN_HELPER_AFFINITY", __kmp_stg_parse_hh_affinity,
5535 __kmp_stg_print_hh_affinity, NULL, 0, 0},
5536#ifdef KMP_GOMP_COMPAT
5537 {
"GOMP_CPU_AFFINITY", __kmp_stg_parse_gomp_cpu_affinity, NULL,
5540 {
"OMP_PROC_BIND", __kmp_stg_parse_proc_bind, __kmp_stg_print_proc_bind,
5542 {
"KMP_TEAMS_PROC_BIND", __kmp_stg_parse_teams_proc_bind,
5543 __kmp_stg_print_teams_proc_bind, NULL, 0, 0},
5544 {
"OMP_PLACES", __kmp_stg_parse_places, __kmp_stg_print_places, NULL, 0, 0},
5545 {
"KMP_TOPOLOGY_METHOD", __kmp_stg_parse_topology_method,
5546 __kmp_stg_print_topology_method, NULL, 0, 0},
5552 {
"OMP_PROC_BIND", __kmp_stg_parse_proc_bind, __kmp_stg_print_proc_bind,
5556 {
"OMP_DISPLAY_AFFINITY", __kmp_stg_parse_display_affinity,
5557 __kmp_stg_print_display_affinity, NULL, 0, 0},
5558 {
"OMP_AFFINITY_FORMAT", __kmp_stg_parse_affinity_format,
5559 __kmp_stg_print_affinity_format, NULL, 0, 0},
5560 {
"KMP_INIT_AT_FORK", __kmp_stg_parse_init_at_fork,
5561 __kmp_stg_print_init_at_fork, NULL, 0, 0},
5562 {
"KMP_SCHEDULE", __kmp_stg_parse_schedule, __kmp_stg_print_schedule, NULL,
5564 {
"OMP_SCHEDULE", __kmp_stg_parse_omp_schedule, __kmp_stg_print_omp_schedule,
5566#if KMP_USE_HIER_SCHED
5567 {
"KMP_DISP_HAND_THREAD", __kmp_stg_parse_kmp_hand_thread,
5568 __kmp_stg_print_kmp_hand_thread, NULL, 0, 0},
5570 {
"KMP_FORCE_MONOTONIC_DYNAMIC_SCHEDULE",
5571 __kmp_stg_parse_kmp_force_monotonic, __kmp_stg_print_kmp_force_monotonic,
5573 {
"KMP_ATOMIC_MODE", __kmp_stg_parse_atomic_mode,
5574 __kmp_stg_print_atomic_mode, NULL, 0, 0},
5575 {
"KMP_CONSISTENCY_CHECK", __kmp_stg_parse_consistency_check,
5576 __kmp_stg_print_consistency_check, NULL, 0, 0},
5578#if USE_ITT_BUILD && USE_ITT_NOTIFY
5579 {
"KMP_ITT_PREPARE_DELAY", __kmp_stg_parse_itt_prepare_delay,
5580 __kmp_stg_print_itt_prepare_delay, NULL, 0, 0},
5582 {
"KMP_MALLOC_POOL_INCR", __kmp_stg_parse_malloc_pool_incr,
5583 __kmp_stg_print_malloc_pool_incr, NULL, 0, 0},
5584 {
"KMP_GTID_MODE", __kmp_stg_parse_gtid_mode, __kmp_stg_print_gtid_mode,
5586 {
"OMP_DYNAMIC", __kmp_stg_parse_omp_dynamic, __kmp_stg_print_omp_dynamic,
5588 {
"KMP_DYNAMIC_MODE", __kmp_stg_parse_kmp_dynamic_mode,
5589 __kmp_stg_print_kmp_dynamic_mode, NULL, 0, 0},
5591#ifdef USE_LOAD_BALANCE
5592 {
"KMP_LOAD_BALANCE_INTERVAL", __kmp_stg_parse_ld_balance_interval,
5593 __kmp_stg_print_ld_balance_interval, NULL, 0, 0},
5596 {
"KMP_NUM_LOCKS_IN_BLOCK", __kmp_stg_parse_lock_block,
5597 __kmp_stg_print_lock_block, NULL, 0, 0},
5598 {
"KMP_LOCK_KIND", __kmp_stg_parse_lock_kind, __kmp_stg_print_lock_kind,
5600 {
"KMP_SPIN_BACKOFF_PARAMS", __kmp_stg_parse_spin_backoff_params,
5601 __kmp_stg_print_spin_backoff_params, NULL, 0, 0},
5602#if KMP_USE_ADAPTIVE_LOCKS
5603 {
"KMP_ADAPTIVE_LOCK_PROPS", __kmp_stg_parse_adaptive_lock_props,
5604 __kmp_stg_print_adaptive_lock_props, NULL, 0, 0},
5605#if KMP_DEBUG_ADAPTIVE_LOCKS
5606 {
"KMP_SPECULATIVE_STATSFILE", __kmp_stg_parse_speculative_statsfile,
5607 __kmp_stg_print_speculative_statsfile, NULL, 0, 0},
5610 {
"KMP_PLACE_THREADS", __kmp_stg_parse_hw_subset, __kmp_stg_print_hw_subset,
5612 {
"KMP_HW_SUBSET", __kmp_stg_parse_hw_subset, __kmp_stg_print_hw_subset,
5615 {
"KMP_FORKJOIN_FRAMES", __kmp_stg_parse_forkjoin_frames,
5616 __kmp_stg_print_forkjoin_frames, NULL, 0, 0},
5617 {
"KMP_FORKJOIN_FRAMES_MODE", __kmp_stg_parse_forkjoin_frames_mode,
5618 __kmp_stg_print_forkjoin_frames_mode, NULL, 0, 0},
5620 {
"KMP_ENABLE_TASK_THROTTLING", __kmp_stg_parse_task_throttling,
5621 __kmp_stg_print_task_throttling, NULL, 0, 0},
5623 {
"OMP_DISPLAY_ENV", __kmp_stg_parse_omp_display_env,
5624 __kmp_stg_print_omp_display_env, NULL, 0, 0},
5625 {
"OMP_CANCELLATION", __kmp_stg_parse_omp_cancellation,
5626 __kmp_stg_print_omp_cancellation, NULL, 0, 0},
5627 {
"OMP_ALLOCATOR", __kmp_stg_parse_allocator, __kmp_stg_print_allocator,
5629 {
"LIBOMP_USE_HIDDEN_HELPER_TASK", __kmp_stg_parse_use_hidden_helper,
5630 __kmp_stg_print_use_hidden_helper, NULL, 0, 0},
5631 {
"LIBOMP_NUM_HIDDEN_HELPER_THREADS",
5632 __kmp_stg_parse_num_hidden_helper_threads,
5633 __kmp_stg_print_num_hidden_helper_threads, NULL, 0, 0},
5635 {
"KMP_MAX_TDGS", __kmp_stg_parse_max_tdgs, __kmp_std_print_max_tdgs, NULL,
5637 {
"KMP_TDG_DOT", __kmp_stg_parse_tdg_dot, __kmp_stg_print_tdg_dot, NULL, 0, 0},
5641 {
"OMP_TOOL", __kmp_stg_parse_omp_tool, __kmp_stg_print_omp_tool, NULL, 0,
5643 {
"OMP_TOOL_LIBRARIES", __kmp_stg_parse_omp_tool_libraries,
5644 __kmp_stg_print_omp_tool_libraries, NULL, 0, 0},
5645 {
"OMP_TOOL_VERBOSE_INIT", __kmp_stg_parse_omp_tool_verbose_init,
5646 __kmp_stg_print_omp_tool_verbose_init, NULL, 0, 0},
5649#if KMP_HAVE_MWAIT || KMP_HAVE_UMWAIT
5650 {
"KMP_USER_LEVEL_MWAIT", __kmp_stg_parse_user_level_mwait,
5651 __kmp_stg_print_user_level_mwait, NULL, 0, 0},
5652 {
"KMP_MWAIT_HINTS", __kmp_stg_parse_mwait_hints,
5653 __kmp_stg_print_mwait_hints, NULL, 0, 0},
5657 {
"KMP_TPAUSE", __kmp_stg_parse_tpause, __kmp_stg_print_tpause, NULL, 0, 0},
5659 {
"", NULL, NULL, NULL, 0, 0}};
5661static int const __kmp_stg_count =
5662 sizeof(__kmp_stg_table) /
sizeof(kmp_setting_t);
5664static inline kmp_setting_t *__kmp_stg_find(
char const *name) {
5668 for (i = 0; i < __kmp_stg_count; ++i) {
5669 if (strcmp(__kmp_stg_table[i].name, name) == 0) {
5670 return &__kmp_stg_table[i];
5678static int __kmp_stg_cmp(
void const *_a,
void const *_b) {
5679 const kmp_setting_t *a = RCAST(
const kmp_setting_t *, _a);
5680 const kmp_setting_t *b = RCAST(
const kmp_setting_t *, _b);
5684 if (strcmp(a->name,
"KMP_AFFINITY") == 0) {
5685 if (strcmp(b->name,
"KMP_AFFINITY") == 0) {
5689 }
else if (strcmp(b->name,
"KMP_AFFINITY") == 0) {
5692 return strcmp(a->name, b->name);
5695static void __kmp_stg_init(
void) {
5697 static int initialized = 0;
5702 qsort(__kmp_stg_table, __kmp_stg_count - 1,
sizeof(kmp_setting_t),
5706 kmp_setting_t *kmp_stacksize =
5707 __kmp_stg_find(
"KMP_STACKSIZE");
5708#ifdef KMP_GOMP_COMPAT
5709 kmp_setting_t *gomp_stacksize =
5710 __kmp_stg_find(
"GOMP_STACKSIZE");
5712 kmp_setting_t *omp_stacksize =
5713 __kmp_stg_find(
"OMP_STACKSIZE");
5719 static kmp_setting_t *
volatile rivals[4];
5720 static kmp_stg_ss_data_t kmp_data = {1, CCAST(kmp_setting_t **, rivals)};
5721#ifdef KMP_GOMP_COMPAT
5722 static kmp_stg_ss_data_t gomp_data = {1024,
5723 CCAST(kmp_setting_t **, rivals)};
5725 static kmp_stg_ss_data_t omp_data = {1024,
5726 CCAST(kmp_setting_t **, rivals)};
5729 rivals[i++] = kmp_stacksize;
5730#ifdef KMP_GOMP_COMPAT
5731 if (gomp_stacksize != NULL) {
5732 rivals[i++] = gomp_stacksize;
5735 rivals[i++] = omp_stacksize;
5738 kmp_stacksize->data = &kmp_data;
5739#ifdef KMP_GOMP_COMPAT
5740 if (gomp_stacksize != NULL) {
5741 gomp_stacksize->data = &gomp_data;
5744 omp_stacksize->data = &omp_data;
5748 kmp_setting_t *kmp_library =
5749 __kmp_stg_find(
"KMP_LIBRARY");
5750 kmp_setting_t *omp_wait_policy =
5751 __kmp_stg_find(
"OMP_WAIT_POLICY");
5754 static kmp_setting_t *
volatile rivals[3];
5755 static kmp_stg_wp_data_t kmp_data = {0, CCAST(kmp_setting_t **, rivals)};
5756 static kmp_stg_wp_data_t omp_data = {1, CCAST(kmp_setting_t **, rivals)};
5759 rivals[i++] = kmp_library;
5760 if (omp_wait_policy != NULL) {
5761 rivals[i++] = omp_wait_policy;
5765 kmp_library->data = &kmp_data;
5766 if (omp_wait_policy != NULL) {
5767 omp_wait_policy->data = &omp_data;
5772 kmp_setting_t *kmp_device_thread_limit =
5773 __kmp_stg_find(
"KMP_DEVICE_THREAD_LIMIT");
5774 kmp_setting_t *kmp_all_threads =
5775 __kmp_stg_find(
"KMP_ALL_THREADS");
5778 static kmp_setting_t *
volatile rivals[3];
5781 rivals[i++] = kmp_device_thread_limit;
5782 rivals[i++] = kmp_all_threads;
5785 kmp_device_thread_limit->data = CCAST(kmp_setting_t **, rivals);
5786 kmp_all_threads->data = CCAST(kmp_setting_t **, rivals);
5791 kmp_setting_t *kmp_hw_subset = __kmp_stg_find(
"KMP_HW_SUBSET");
5793 kmp_setting_t *kmp_place_threads = __kmp_stg_find(
"KMP_PLACE_THREADS");
5796 static kmp_setting_t *
volatile rivals[3];
5799 rivals[i++] = kmp_hw_subset;
5800 rivals[i++] = kmp_place_threads;
5803 kmp_hw_subset->data = CCAST(kmp_setting_t **, rivals);
5804 kmp_place_threads->data = CCAST(kmp_setting_t **, rivals);
5807#if KMP_AFFINITY_SUPPORTED
5809 kmp_setting_t *kmp_affinity =
5810 __kmp_stg_find(
"KMP_AFFINITY");
5811 KMP_DEBUG_ASSERT(kmp_affinity != NULL);
5813#ifdef KMP_GOMP_COMPAT
5814 kmp_setting_t *gomp_cpu_affinity =
5815 __kmp_stg_find(
"GOMP_CPU_AFFINITY");
5816 KMP_DEBUG_ASSERT(gomp_cpu_affinity != NULL);
5819 kmp_setting_t *omp_proc_bind =
5820 __kmp_stg_find(
"OMP_PROC_BIND");
5821 KMP_DEBUG_ASSERT(omp_proc_bind != NULL);
5824 static kmp_setting_t *
volatile rivals[4];
5827 rivals[i++] = kmp_affinity;
5829#ifdef KMP_GOMP_COMPAT
5830 rivals[i++] = gomp_cpu_affinity;
5831 gomp_cpu_affinity->data = CCAST(kmp_setting_t **, rivals);
5834 rivals[i++] = omp_proc_bind;
5835 omp_proc_bind->data = CCAST(kmp_setting_t **, rivals);
5838 static kmp_setting_t *
volatile places_rivals[4];
5841 kmp_setting_t *omp_places = __kmp_stg_find(
"OMP_PLACES");
5842 KMP_DEBUG_ASSERT(omp_places != NULL);
5844 places_rivals[i++] = kmp_affinity;
5845#ifdef KMP_GOMP_COMPAT
5846 places_rivals[i++] = gomp_cpu_affinity;
5848 places_rivals[i++] = omp_places;
5849 omp_places->data = CCAST(kmp_setting_t **, places_rivals);
5850 places_rivals[i++] = NULL;
5858 kmp_setting_t *kmp_force_red =
5859 __kmp_stg_find(
"KMP_FORCE_REDUCTION");
5860 kmp_setting_t *kmp_determ_red =
5861 __kmp_stg_find(
"KMP_DETERMINISTIC_REDUCTION");
5864 static kmp_setting_t *
volatile rivals[3];
5865 static kmp_stg_fr_data_t force_data = {1,
5866 CCAST(kmp_setting_t **, rivals)};
5867 static kmp_stg_fr_data_t determ_data = {0,
5868 CCAST(kmp_setting_t **, rivals)};
5871 rivals[i++] = kmp_force_red;
5872 if (kmp_determ_red != NULL) {
5873 rivals[i++] = kmp_determ_red;
5877 kmp_force_red->data = &force_data;
5878 if (kmp_determ_red != NULL) {
5879 kmp_determ_red->data = &determ_data;
5888 for (i = 0; i < __kmp_stg_count; ++i) {
5889 __kmp_stg_table[i].set = 0;
5894static void __kmp_stg_parse(
char const *name,
char const *value) {
5902 if (value != NULL) {
5903 kmp_setting_t *setting = __kmp_stg_find(name);
5904 if (setting != NULL) {
5905 setting->parse(name, value, setting->data);
5906 setting->defined = 1;
5912static int __kmp_stg_check_rivals(
5915 kmp_setting_t **rivals
5918 if (rivals == NULL) {
5924 for (; strcmp(rivals[i]->name, name) != 0; i++) {
5925 KMP_DEBUG_ASSERT(rivals[i] != NULL);
5927#if KMP_AFFINITY_SUPPORTED
5928 if (rivals[i] == __kmp_affinity_notype) {
5935 if (rivals[i]->set) {
5936 KMP_WARNING(StgIgnored, name, rivals[i]->name);
5946static int __kmp_env_toPrint(
char const *name,
int flag) {
5948 kmp_setting_t *setting = __kmp_stg_find(name);
5949 if (setting != NULL) {
5950 rc = setting->defined;
5952 setting->defined = flag;
5958#if defined(KMP_DEBUG) && KMP_AFFINITY_SUPPORTED
5959static void __kmp_print_affinity_settings(
const kmp_affinity_t *affinity) {
5960 K_DIAG(1, (
"%s:\n", affinity->env_var));
5961 K_DIAG(1, (
" type : %d\n", affinity->type));
5962 K_DIAG(1, (
" compact : %d\n", affinity->compact));
5963 K_DIAG(1, (
" offset : %d\n", affinity->offset));
5964 K_DIAG(1, (
" verbose : %u\n", affinity->flags.verbose));
5965 K_DIAG(1, (
" warnings : %u\n", affinity->flags.warnings));
5966 K_DIAG(1, (
" respect : %u\n", affinity->flags.respect));
5967 K_DIAG(1, (
" reset : %u\n", affinity->flags.reset));
5968 K_DIAG(1, (
" dups : %u\n", affinity->flags.dups));
5969 K_DIAG(1, (
" gran : %d\n", (
int)affinity->gran));
5970 KMP_DEBUG_ASSERT(affinity->type != affinity_default);
5974static void __kmp_aux_env_initialize(kmp_env_blk_t *block) {
5979 value = __kmp_env_blk_var(block,
"OMP_NUM_THREADS");
5981 ompc_set_num_threads(__kmp_dflt_team_nth);
5985 value = __kmp_env_blk_var(block,
"KMP_BLOCKTIME");
5987 kmpc_set_blocktime(__kmp_dflt_blocktime);
5991 value = __kmp_env_blk_var(block,
"OMP_NESTED");
5993 ompc_set_nested(__kmp_dflt_max_active_levels > 1);
5997 value = __kmp_env_blk_var(block,
"OMP_DYNAMIC");
5999 ompc_set_dynamic(__kmp_global.g.g_dynamic);
6003void __kmp_env_initialize(
char const *
string) {
6005 kmp_env_blk_t block;
6011 if (
string == NULL) {
6013 __kmp_threads_capacity =
6014 __kmp_initial_threads_capacity(__kmp_dflt_team_nth_ub);
6016 __kmp_env_blk_init(&block,
string);
6019 for (i = 0; i < block.count; ++i) {
6020 if ((block.vars[i].name == NULL) || (*block.vars[i].name ==
'\0')) {
6023 if (block.vars[i].value == NULL) {
6026 kmp_setting_t *setting = __kmp_stg_find(block.vars[i].name);
6027 if (setting != NULL) {
6033 blocktime_str = __kmp_env_blk_var(&block,
"KMP_BLOCKTIME");
6037 if (
string == NULL) {
6038 char const *name =
"KMP_WARNINGS";
6039 char const *value = __kmp_env_blk_var(&block, name);
6040 __kmp_stg_parse(name, value);
6043#if KMP_AFFINITY_SUPPORTED
6049 __kmp_affinity_notype = NULL;
6050 char const *aff_str = __kmp_env_blk_var(&block,
"KMP_AFFINITY");
6051 if (aff_str != NULL) {
6065#define FIND strcasestr
6068 if ((FIND(aff_str,
"none") == NULL) &&
6069 (FIND(aff_str,
"physical") == NULL) &&
6070 (FIND(aff_str,
"logical") == NULL) &&
6071 (FIND(aff_str,
"compact") == NULL) &&
6072 (FIND(aff_str,
"scatter") == NULL) &&
6073 (FIND(aff_str,
"explicit") == NULL) &&
6074 (FIND(aff_str,
"balanced") == NULL) &&
6075 (FIND(aff_str,
"disabled") == NULL)) {
6076 __kmp_affinity_notype = __kmp_stg_find(
"KMP_AFFINITY");
6081 __kmp_affinity.type = affinity_default;
6082 __kmp_affinity.gran = KMP_HW_UNKNOWN;
6083 __kmp_affinity_top_method = affinity_top_method_default;
6084 __kmp_affinity.flags.respect = affinity_respect_mask_default;
6089 aff_str = __kmp_env_blk_var(&block,
"OMP_PROC_BIND");
6090 if (aff_str != NULL) {
6091 __kmp_affinity.type = affinity_default;
6092 __kmp_affinity.gran = KMP_HW_UNKNOWN;
6093 __kmp_affinity_top_method = affinity_top_method_default;
6094 __kmp_affinity.flags.respect = affinity_respect_mask_default;
6101 if (__kmp_nested_proc_bind.bind_types == NULL) {
6102 __kmp_nested_proc_bind.bind_types =
6103 (kmp_proc_bind_t *)KMP_INTERNAL_MALLOC(
sizeof(kmp_proc_bind_t));
6104 if (__kmp_nested_proc_bind.bind_types == NULL) {
6105 KMP_FATAL(MemoryAllocFailed);
6107 __kmp_nested_proc_bind.size = 1;
6108 __kmp_nested_proc_bind.used = 1;
6109#if KMP_AFFINITY_SUPPORTED
6110 __kmp_nested_proc_bind.bind_types[0] = proc_bind_default;
6113 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
6120 __kmp_msg_format(kmp_i18n_msg_AffFormatDefault,
"%P",
"%i",
"%n",
"%A");
6121 KMP_DEBUG_ASSERT(KMP_STRLEN(m.str) < KMP_AFFINITY_FORMAT_SIZE);
6123 if (__kmp_affinity_format == NULL) {
6124 __kmp_affinity_format =
6125 (
char *)KMP_INTERNAL_MALLOC(
sizeof(
char) * KMP_AFFINITY_FORMAT_SIZE);
6127 KMP_STRCPY_S(__kmp_affinity_format, KMP_AFFINITY_FORMAT_SIZE, m.str);
6128 __kmp_str_free(&m.str);
6131 for (i = 0; i < block.count; ++i) {
6132 __kmp_stg_parse(block.vars[i].name, block.vars[i].value);
6136 if (!__kmp_init_user_locks) {
6137 if (__kmp_user_lock_kind == lk_default) {
6138 __kmp_user_lock_kind = lk_queuing;
6140#if KMP_USE_DYNAMIC_LOCK
6141 __kmp_init_dynamic_user_locks();
6143 __kmp_set_user_lock_vptrs(__kmp_user_lock_kind);
6146 KMP_DEBUG_ASSERT(
string != NULL);
6147 KMP_DEBUG_ASSERT(__kmp_user_lock_kind != lk_default);
6152#if KMP_USE_DYNAMIC_LOCK
6153 __kmp_init_dynamic_user_locks();
6155 __kmp_set_user_lock_vptrs(__kmp_user_lock_kind);
6159#if KMP_AFFINITY_SUPPORTED
6161 if (!TCR_4(__kmp_init_middle)) {
6166 if (__kmp_hw_subset &&
6167 __kmp_affinity_top_method == affinity_top_method_default)
6168 if (__kmp_hw_subset->specified(KMP_HW_NUMA) ||
6169 __kmp_hw_subset->specified(KMP_HW_TILE) ||
6170 __kmp_affinity.gran == KMP_HW_TILE ||
6171 __kmp_affinity.gran == KMP_HW_NUMA)
6172 __kmp_affinity_top_method = affinity_top_method_hwloc;
6174 if (__kmp_affinity.gran == KMP_HW_NUMA ||
6175 __kmp_affinity.gran == KMP_HW_TILE)
6176 __kmp_affinity_top_method = affinity_top_method_hwloc;
6180 const char *var =
"KMP_AFFINITY";
6181 KMPAffinity::pick_api();
6186 if (__kmp_affinity_top_method == affinity_top_method_hwloc &&
6187 __kmp_affinity_dispatch->get_api_type() != KMPAffinity::HWLOC) {
6188 KMP_WARNING(AffIgnoringHwloc, var);
6189 __kmp_affinity_top_method = affinity_top_method_all;
6192 if (__kmp_affinity.type == affinity_disabled) {
6193 KMP_AFFINITY_DISABLE();
6194 }
else if (!KMP_AFFINITY_CAPABLE()) {
6195 __kmp_affinity_dispatch->determine_capable(var);
6196 if (!KMP_AFFINITY_CAPABLE()) {
6197 if (__kmp_affinity.flags.verbose ||
6198 (__kmp_affinity.flags.warnings &&
6199 (__kmp_affinity.type != affinity_default) &&
6200 (__kmp_affinity.type != affinity_none) &&
6201 (__kmp_affinity.type != affinity_disabled))) {
6202 KMP_WARNING(AffNotSupported, var);
6204 __kmp_affinity.type = affinity_disabled;
6205 __kmp_affinity.flags.respect = FALSE;
6206 __kmp_affinity.gran = KMP_HW_THREAD;
6210 if (__kmp_affinity.type == affinity_disabled) {
6211 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
6212 }
else if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_true) {
6214 __kmp_nested_proc_bind.bind_types[0] = proc_bind_spread;
6217 if (KMP_AFFINITY_CAPABLE()) {
6219#if KMP_GROUP_AFFINITY
6224 bool exactly_one_group =
false;
6225 if (__kmp_num_proc_groups > 1) {
6227 bool within_one_group;
6230 kmp_affin_mask_t *init_mask;
6231 KMP_CPU_ALLOC(init_mask);
6232 __kmp_get_system_affinity(init_mask, TRUE);
6233 group = __kmp_get_proc_group(init_mask);
6234 within_one_group = (group >= 0);
6237 if (within_one_group) {
6238 DWORD num_bits_in_group = __kmp_GetActiveProcessorCount(group);
6239 DWORD num_bits_in_mask = 0;
6240 for (
int bit = init_mask->begin(); bit != init_mask->end();
6241 bit = init_mask->next(bit))
6243 exactly_one_group = (num_bits_in_group == num_bits_in_mask);
6245 KMP_CPU_FREE(init_mask);
6251 if (__kmp_num_proc_groups > 1 &&
6252 __kmp_affinity.type == affinity_default &&
6253 __kmp_nested_proc_bind.bind_types[0] == proc_bind_default) {
6258 if (__kmp_affinity.flags.respect == affinity_respect_mask_default &&
6259 exactly_one_group) {
6260 __kmp_affinity.flags.respect = FALSE;
6264 if (__kmp_affinity.type == affinity_default) {
6265 __kmp_affinity.type = affinity_compact;
6266 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
6268 if (__kmp_hh_affinity.type == affinity_default)
6269 __kmp_hh_affinity.type = affinity_compact;
6270 if (__kmp_affinity_top_method == affinity_top_method_default)
6271 __kmp_affinity_top_method = affinity_top_method_all;
6272 if (__kmp_affinity.gran == KMP_HW_UNKNOWN)
6273 __kmp_affinity.gran = KMP_HW_PROC_GROUP;
6274 if (__kmp_hh_affinity.gran == KMP_HW_UNKNOWN)
6275 __kmp_hh_affinity.gran = KMP_HW_PROC_GROUP;
6281 if (__kmp_affinity.flags.respect == affinity_respect_mask_default) {
6282#if KMP_GROUP_AFFINITY
6283 if (__kmp_num_proc_groups > 1 && exactly_one_group) {
6284 __kmp_affinity.flags.respect = FALSE;
6288 __kmp_affinity.flags.respect = TRUE;
6291 if ((__kmp_nested_proc_bind.bind_types[0] != proc_bind_intel) &&
6292 (__kmp_nested_proc_bind.bind_types[0] != proc_bind_default)) {
6293 if (__kmp_affinity.type == affinity_default) {
6294 __kmp_affinity.type = affinity_compact;
6295 __kmp_affinity.flags.dups = FALSE;
6297 }
else if (__kmp_affinity.type == affinity_default) {
6298#if KMP_MIC_SUPPORTED
6299 if (__kmp_mic_type != non_mic) {
6300 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
6304 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
6306#if KMP_MIC_SUPPORTED
6307 if (__kmp_mic_type != non_mic) {
6308 __kmp_affinity.type = affinity_scatter;
6312 __kmp_affinity.type = affinity_none;
6315 if (__kmp_hh_affinity.type == affinity_default)
6316 __kmp_hh_affinity.type = affinity_none;
6317 if ((__kmp_affinity.gran == KMP_HW_UNKNOWN) &&
6318 (__kmp_affinity.gran_levels < 0)) {
6319#if KMP_MIC_SUPPORTED
6320 if (__kmp_mic_type != non_mic) {
6321 __kmp_affinity.gran = KMP_HW_THREAD;
6325 __kmp_affinity.gran = KMP_HW_CORE;
6328 if ((__kmp_hh_affinity.gran == KMP_HW_UNKNOWN) &&
6329 (__kmp_hh_affinity.gran_levels < 0)) {
6330#if KMP_MIC_SUPPORTED
6331 if (__kmp_mic_type != non_mic) {
6332 __kmp_hh_affinity.gran = KMP_HW_THREAD;
6336 __kmp_hh_affinity.gran = KMP_HW_CORE;
6339 if (__kmp_affinity_top_method == affinity_top_method_default) {
6340 __kmp_affinity_top_method = affinity_top_method_all;
6346 if (__kmp_affinity_top_method == affinity_top_method_default)
6347 __kmp_affinity_top_method = affinity_top_method_all;
6348 if (__kmp_affinity.type == affinity_default)
6349 __kmp_affinity.type = affinity_disabled;
6350 if (__kmp_hh_affinity.type == affinity_default)
6351 __kmp_hh_affinity.type = affinity_disabled;
6355 for (
const kmp_affinity_t *affinity : __kmp_affinities)
6356 __kmp_print_affinity_settings(affinity);
6357 KMP_DEBUG_ASSERT(__kmp_nested_proc_bind.bind_types[0] != proc_bind_default);
6358 K_DIAG(1, (
"__kmp_nested_proc_bind.bind_types[0] == %d\n",
6359 __kmp_nested_proc_bind.bind_types[0]));
6367 if (
string != NULL) {
6368 __kmp_aux_env_initialize(&block);
6371 __kmp_env_blk_free(&block);
6377void __kmp_env_print() {
6379 kmp_env_blk_t block;
6381 kmp_str_buf_t buffer;
6384 __kmp_str_buf_init(&buffer);
6386 __kmp_env_blk_init(&block, NULL);
6387 __kmp_env_blk_sort(&block);
6390 __kmp_str_buf_print(&buffer,
"\n%s\n\n", KMP_I18N_STR(UserSettings));
6391 for (i = 0; i < block.count; ++i) {
6392 char const *name = block.vars[i].name;
6393 char const *value = block.vars[i].value;
6394 if ((KMP_STRLEN(name) > 4 && strncmp(name,
"KMP_", 4) == 0) ||
6395 strncmp(name,
"OMP_", 4) == 0
6396#ifdef KMP_GOMP_COMPAT
6397 || strncmp(name,
"GOMP_", 5) == 0
6400 __kmp_str_buf_print(&buffer,
" %s=%s\n", name, value);
6403 __kmp_str_buf_print(&buffer,
"\n");
6406 __kmp_str_buf_print(&buffer,
"%s\n\n", KMP_I18N_STR(EffectiveSettings));
6407 for (
int i = 0; i < __kmp_stg_count; ++i) {
6408 if (__kmp_stg_table[i].print != NULL) {
6409 __kmp_stg_table[i].print(&buffer, __kmp_stg_table[i].name,
6410 __kmp_stg_table[i].data);
6414 __kmp_printf(
"%s", buffer.str);
6416 __kmp_env_blk_free(&block);
6417 __kmp_str_buf_free(&buffer);
6423void __kmp_env_print_2() {
6424 __kmp_display_env_impl(__kmp_display_env, __kmp_display_env_verbose);
6427void __kmp_display_env_impl(
int display_env,
int display_env_verbose) {
6428 kmp_env_blk_t block;
6429 kmp_str_buf_t buffer;
6431 __kmp_env_format = 1;
6434 __kmp_str_buf_init(&buffer);
6436 __kmp_env_blk_init(&block, NULL);
6437 __kmp_env_blk_sort(&block);
6439 __kmp_str_buf_print(&buffer,
"\n%s\n", KMP_I18N_STR(DisplayEnvBegin));
6440 __kmp_str_buf_print(&buffer,
" _OPENMP='%d'\n", __kmp_openmp_version);
6442 for (
int i = 0; i < __kmp_stg_count; ++i) {
6443 if (__kmp_stg_table[i].print != NULL &&
6444 ((display_env && strncmp(__kmp_stg_table[i].name,
"OMP_", 4) == 0) ||
6445 display_env_verbose)) {
6446 __kmp_stg_table[i].print(&buffer, __kmp_stg_table[i].name,
6447 __kmp_stg_table[i].data);
6451 __kmp_str_buf_print(&buffer,
"%s\n", KMP_I18N_STR(DisplayEnvEnd));
6452 __kmp_str_buf_print(&buffer,
"\n");
6454 __kmp_printf(
"%s", buffer.str);
6456 __kmp_env_blk_free(&block);
6457 __kmp_str_buf_free(&buffer);
6464void __kmp_env_dump() {
6466 kmp_env_blk_t block;
6467 kmp_str_buf_t buffer, env, notdefined;
6470 __kmp_str_buf_init(&buffer);
6471 __kmp_str_buf_init(&env);
6472 __kmp_str_buf_init(¬defined);
6474 __kmp_env_blk_init(&block, NULL);
6475 __kmp_env_blk_sort(&block);
6477 __kmp_str_buf_print(¬defined,
": %s", KMP_I18N_STR(NotDefined));
6479 for (
int i = 0; i < __kmp_stg_count; ++i) {
6480 if (__kmp_stg_table[i].print == NULL)
6482 __kmp_str_buf_clear(&env);
6483 __kmp_stg_table[i].print(&env, __kmp_stg_table[i].name,
6484 __kmp_stg_table[i].data);
6487 if (strstr(env.str, notdefined.str))
6489 __kmp_str_buf_print(&buffer,
"%s=undefined\n", __kmp_stg_table[i].name);
6491 __kmp_str_buf_cat(&buffer, env.str + 3, env.used - 3);
6494 ompd_env_block = (
char *)__kmp_allocate(buffer.used + 1);
6495 KMP_MEMCPY(ompd_env_block, buffer.str, buffer.used + 1);
6496 ompd_env_block_size = (ompd_size_t)KMP_STRLEN(ompd_env_block);
6498 __kmp_env_blk_free(&block);
6499 __kmp_str_buf_free(&buffer);
6500 __kmp_str_buf_free(&env);
6501 __kmp_str_buf_free(¬defined);
@ kmp_sch_modifier_monotonic
@ kmp_sch_modifier_nonmonotonic