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
288static void __kmp_stg_parse_bool(
char const *name,
char const *value,
290 if (__kmp_str_match_true(value)) {
292 }
else if (__kmp_str_match_false(value)) {
295 __kmp_msg(kmp_ms_warning, KMP_MSG(BadBoolValue, name, value),
296 KMP_HNT(ValidBoolValues), __kmp_msg_null);
301void __kmp_check_stksize(
size_t *val) {
303 if (*val > KMP_DEFAULT_STKSIZE * 16)
304 *val = KMP_DEFAULT_STKSIZE * 16;
305 if (*val < __kmp_sys_min_stksize)
306 *val = __kmp_sys_min_stksize;
307 if (*val > KMP_MAX_STKSIZE)
308 *val = KMP_MAX_STKSIZE;
310 *val = __kmp_round4k(*val);
314static void __kmp_stg_parse_size(
char const *name,
char const *value,
315 size_t size_min,
size_t size_max,
316 int *is_specified,
size_t *out,
318 char const *msg = NULL;
320 size_min = __kmp_round4k(size_min);
321 size_max = __kmp_round4k(size_max);
324 if (is_specified != NULL) {
327 __kmp_str_to_size(value, out, factor, &msg);
329 if (*out > size_max) {
331 msg = KMP_I18N_STR(ValueTooLarge);
332 }
else if (*out < size_min) {
334 msg = KMP_I18N_STR(ValueTooSmall);
337 size_t round4k = __kmp_round4k(*out);
338 if (*out != round4k) {
340 msg = KMP_I18N_STR(NotMultiple4K);
347 if (*out < size_min) {
349 }
else if (*out > size_max) {
356 __kmp_str_buf_init(&buf);
357 __kmp_str_buf_print_size(&buf, *out);
358 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
359 KMP_INFORM(Using_str_Value, name, buf.str);
360 __kmp_str_buf_free(&buf);
365static void __kmp_stg_parse_str(
char const *name,
char const *value,
368 *out = __kmp_str_format(
"%s", value);
371static void __kmp_stg_parse_int(
379 char const *msg = NULL;
380 kmp_uint64 uint = *out;
381 __kmp_str_to_uint(value, &uint, &msg);
383 if (uint < (
unsigned int)min) {
384 msg = KMP_I18N_STR(ValueTooSmall);
386 }
else if (uint > (
unsigned int)max) {
387 msg = KMP_I18N_STR(ValueTooLarge);
393 if (uint < (
unsigned int)min) {
395 }
else if (uint > (
unsigned int)max) {
402 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
403 __kmp_str_buf_init(&buf);
404 __kmp_str_buf_print(&buf,
"%" KMP_UINT64_SPEC
"", uint);
405 KMP_INFORM(Using_uint64_Value, name, buf.str);
406 __kmp_str_buf_free(&buf);
408 __kmp_type_convert(uint, out);
411#if KMP_DEBUG_ADAPTIVE_LOCKS
412static void __kmp_stg_parse_file(
char const *name,
char const *value,
413 const char *suffix,
char **out) {
418 t = (
char *)strrchr(value,
'.');
419 hasSuffix = t && __kmp_str_eqf(t, suffix);
420 t = __kmp_str_format(
"%s%s", value, hasSuffix ?
"" : suffix);
421 __kmp_expand_file_name(buffer,
sizeof(buffer), t);
423 *out = __kmp_str_format(
"%s", buffer);
428static char *par_range_to_print = NULL;
430static void __kmp_stg_parse_par_range(
char const *name,
char const *value,
431 int *out_range,
char *out_routine,
432 char *out_file,
int *out_lb,
434 const char *par_range_value;
435 size_t len = KMP_STRLEN(value) + 1;
436 par_range_to_print = (
char *)KMP_INTERNAL_MALLOC(len + 1);
437 KMP_STRNCPY_S(par_range_to_print, len + 1, value, len + 1);
438 __kmp_par_range = +1;
439 __kmp_par_range_lb = 0;
440 __kmp_par_range_ub = INT_MAX;
443 if (!value || *value ==
'\0') {
446 if (!__kmp_strcasecmp_with_sentinel(
"routine", value,
'=')) {
447 par_range_value = strchr(value,
'=') + 1;
448 if (!par_range_value)
449 goto par_range_error;
450 value = par_range_value;
451 len = __kmp_readstr_with_sentinel(out_routine, value,
452 KMP_PAR_RANGE_ROUTINE_LEN - 1,
',');
454 goto par_range_error;
456 value = strchr(value,
',');
462 if (!__kmp_strcasecmp_with_sentinel(
"filename", value,
'=')) {
463 par_range_value = strchr(value,
'=') + 1;
464 if (!par_range_value)
465 goto par_range_error;
466 value = par_range_value;
467 len = __kmp_readstr_with_sentinel(out_file, value,
468 KMP_PAR_RANGE_FILENAME_LEN - 1,
',');
470 goto par_range_error;
472 value = strchr(value,
',');
478 if ((!__kmp_strcasecmp_with_sentinel(
"range", value,
'=')) ||
479 (!__kmp_strcasecmp_with_sentinel(
"incl_range", value,
'='))) {
480 par_range_value = strchr(value,
'=') + 1;
481 if (!par_range_value)
482 goto par_range_error;
483 value = par_range_value;
484 if (KMP_SSCANF(value,
"%d:%d", out_lb, out_ub) != 2) {
485 goto par_range_error;
488 value = strchr(value,
',');
494 if (!__kmp_strcasecmp_with_sentinel(
"excl_range", value,
'=')) {
495 par_range_value = strchr(value,
'=') + 1;
496 if (!par_range_value)
497 goto par_range_error;
498 value = par_range_value;
499 if (KMP_SSCANF(value,
"%d:%d", out_lb, out_ub) != 2) {
500 goto par_range_error;
503 value = strchr(value,
',');
510 KMP_WARNING(ParRangeSyntax, name);
517int __kmp_initial_threads_capacity(
int req_nproc) {
522 if (nth < (4 * req_nproc))
523 nth = (4 * req_nproc);
524 if (nth < (4 * __kmp_xproc))
525 nth = (4 * __kmp_xproc);
529 if (__kmp_enable_hidden_helper) {
530 nth += __kmp_hidden_helper_threads_num;
533 if (nth > __kmp_max_nth)
539int __kmp_default_tp_capacity(
int req_nproc,
int max_nth,
540 int all_threads_specified) {
543 if (all_threads_specified)
547 if (nth < (4 * req_nproc))
548 nth = (4 * req_nproc);
549 if (nth < (4 * __kmp_xproc))
550 nth = (4 * __kmp_xproc);
552 if (nth > __kmp_max_nth)
561static void __kmp_stg_print_bool(kmp_str_buf_t *buffer,
char const *name,
563 if (__kmp_env_format) {
564 KMP_STR_BUF_PRINT_BOOL;
566 __kmp_str_buf_print(buffer,
" %s=%s\n", name, value ?
"true" :
"false");
570static void __kmp_stg_print_int(kmp_str_buf_t *buffer,
char const *name,
572 if (__kmp_env_format) {
573 KMP_STR_BUF_PRINT_INT;
575 __kmp_str_buf_print(buffer,
" %s=%d\n", name, value);
579static void __kmp_stg_print_uint64(kmp_str_buf_t *buffer,
char const *name,
581 if (__kmp_env_format) {
582 KMP_STR_BUF_PRINT_UINT64;
584 __kmp_str_buf_print(buffer,
" %s=%" KMP_UINT64_SPEC
"\n", name, value);
588static void __kmp_stg_print_str(kmp_str_buf_t *buffer,
char const *name,
590 if (__kmp_env_format) {
591 KMP_STR_BUF_PRINT_STR;
593 __kmp_str_buf_print(buffer,
" %s=%s\n", name, value);
597static void __kmp_stg_print_size(kmp_str_buf_t *buffer,
char const *name,
599 if (__kmp_env_format) {
600 KMP_STR_BUF_PRINT_NAME_EX(name);
601 __kmp_str_buf_print_size(buffer, value);
602 __kmp_str_buf_print(buffer,
"'\n");
604 __kmp_str_buf_print(buffer,
" %s=", name);
605 __kmp_str_buf_print_size(buffer, value);
606 __kmp_str_buf_print(buffer,
"\n");
617static void __kmp_stg_parse_device_thread_limit(
char const *name,
618 char const *value,
void *data) {
619 kmp_setting_t **rivals = (kmp_setting_t **)data;
621 if (strcmp(name,
"KMP_ALL_THREADS") == 0) {
622 KMP_INFORM(EnvVarDeprecated, name,
"KMP_DEVICE_THREAD_LIMIT");
624 rc = __kmp_stg_check_rivals(name, value, rivals);
628 if (!__kmp_strcasecmp_with_sentinel(
"all", value, 0)) {
629 __kmp_max_nth = __kmp_xproc;
630 __kmp_allThreadsSpecified = 1;
632 __kmp_stg_parse_int(name, value, 1, __kmp_sys_max_nth, &__kmp_max_nth);
633 __kmp_allThreadsSpecified = 0;
635 K_DIAG(1, (
"__kmp_max_nth == %d\n", __kmp_max_nth));
639static void __kmp_stg_print_device_thread_limit(kmp_str_buf_t *buffer,
640 char const *name,
void *data) {
641 __kmp_stg_print_int(buffer, name, __kmp_max_nth);
646static void __kmp_stg_parse_thread_limit(
char const *name,
char const *value,
648 __kmp_stg_parse_int(name, value, 1, __kmp_sys_max_nth, &__kmp_cg_max_nth);
649 K_DIAG(1, (
"__kmp_cg_max_nth == %d\n", __kmp_cg_max_nth));
653static void __kmp_stg_print_thread_limit(kmp_str_buf_t *buffer,
654 char const *name,
void *data) {
655 __kmp_stg_print_int(buffer, name, __kmp_cg_max_nth);
660static void __kmp_stg_parse_nteams(
char const *name,
char const *value,
662 __kmp_stg_parse_int(name, value, 1, __kmp_sys_max_nth, &__kmp_nteams);
663 K_DIAG(1, (
"__kmp_nteams == %d\n", __kmp_nteams));
666static void __kmp_stg_print_nteams(kmp_str_buf_t *buffer,
char const *name,
668 __kmp_stg_print_int(buffer, name, __kmp_nteams);
673static void __kmp_stg_parse_teams_th_limit(
char const *name,
char const *value,
675 __kmp_stg_parse_int(name, value, 1, __kmp_sys_max_nth,
676 &__kmp_teams_thread_limit);
677 K_DIAG(1, (
"__kmp_teams_thread_limit == %d\n", __kmp_teams_thread_limit));
680static void __kmp_stg_print_teams_th_limit(kmp_str_buf_t *buffer,
681 char const *name,
void *data) {
682 __kmp_stg_print_int(buffer, name, __kmp_teams_thread_limit);
687static void __kmp_stg_parse_teams_thread_limit(
char const *name,
688 char const *value,
void *data) {
689 __kmp_stg_parse_int(name, value, 1, __kmp_sys_max_nth, &__kmp_teams_max_nth);
692static void __kmp_stg_print_teams_thread_limit(kmp_str_buf_t *buffer,
693 char const *name,
void *data) {
694 __kmp_stg_print_int(buffer, name, __kmp_teams_max_nth);
699static void __kmp_stg_parse_use_yield(
char const *name,
char const *value,
701 __kmp_stg_parse_int(name, value, 0, 2, &__kmp_use_yield);
702 __kmp_use_yield_exp_set = 1;
705static void __kmp_stg_print_use_yield(kmp_str_buf_t *buffer,
char const *name,
707 __kmp_stg_print_int(buffer, name, __kmp_use_yield);
713static void __kmp_stg_parse_blocktime(
char const *name,
char const *value,
715 __kmp_dflt_blocktime = __kmp_convert_to_milliseconds(value);
716 if (__kmp_dflt_blocktime < 0) {
717 __kmp_dflt_blocktime = KMP_DEFAULT_BLOCKTIME;
718 __kmp_msg(kmp_ms_warning, KMP_MSG(InvalidValue, name, value),
720 KMP_INFORM(Using_int_Value, name, __kmp_dflt_blocktime);
721 __kmp_env_blocktime = FALSE;
723 if (__kmp_dflt_blocktime < KMP_MIN_BLOCKTIME) {
724 __kmp_dflt_blocktime = KMP_MIN_BLOCKTIME;
725 __kmp_msg(kmp_ms_warning, KMP_MSG(SmallValue, name, value),
727 KMP_INFORM(MinValueUsing, name, __kmp_dflt_blocktime);
728 }
else if (__kmp_dflt_blocktime > KMP_MAX_BLOCKTIME) {
729 __kmp_dflt_blocktime = KMP_MAX_BLOCKTIME;
730 __kmp_msg(kmp_ms_warning, KMP_MSG(LargeValue, name, value),
732 KMP_INFORM(MaxValueUsing, name, __kmp_dflt_blocktime);
734 __kmp_env_blocktime = TRUE;
739 __kmp_monitor_wakeups =
740 KMP_WAKEUPS_FROM_BLOCKTIME(__kmp_dflt_blocktime, __kmp_monitor_wakeups);
742 KMP_INTERVALS_FROM_BLOCKTIME(__kmp_dflt_blocktime, __kmp_monitor_wakeups);
744 K_DIAG(1, (
"__kmp_env_blocktime == %d\n", __kmp_env_blocktime));
745 if (__kmp_env_blocktime) {
746 K_DIAG(1, (
"__kmp_dflt_blocktime == %d\n", __kmp_dflt_blocktime));
750static void __kmp_stg_print_blocktime(kmp_str_buf_t *buffer,
char const *name,
752 __kmp_stg_print_int(buffer, name, __kmp_dflt_blocktime);
758static void __kmp_stg_parse_duplicate_lib_ok(
char const *name,
759 char const *value,
void *data) {
762 __kmp_stg_parse_bool(name, value, &__kmp_duplicate_library_ok);
765static void __kmp_stg_print_duplicate_lib_ok(kmp_str_buf_t *buffer,
766 char const *name,
void *data) {
767 __kmp_stg_print_bool(buffer, name, __kmp_duplicate_library_ok);
773#if KMP_ARCH_X86 || KMP_ARCH_X86_64
775static void __kmp_stg_parse_inherit_fp_control(
char const *name,
776 char const *value,
void *data) {
777 __kmp_stg_parse_bool(name, value, &__kmp_inherit_fp_control);
780static void __kmp_stg_print_inherit_fp_control(kmp_str_buf_t *buffer,
781 char const *name,
void *data) {
783 __kmp_stg_print_bool(buffer, name, __kmp_inherit_fp_control);
790static char const *blocktime_str = NULL;
795static void __kmp_stg_parse_wait_policy(
char const *name,
char const *value,
798 kmp_stg_wp_data_t *wait = (kmp_stg_wp_data_t *)data;
801 rc = __kmp_stg_check_rivals(name, value, wait->rivals);
807 if (__kmp_str_match(
"ACTIVE", 1, value)) {
808 __kmp_library = library_turnaround;
809 if (blocktime_str == NULL) {
811 __kmp_dflt_blocktime = KMP_MAX_BLOCKTIME;
813 }
else if (__kmp_str_match(
"PASSIVE", 1, value)) {
814 __kmp_library = library_throughput;
815 __kmp_wpolicy_passive =
true;
816 if (blocktime_str == NULL) {
818 __kmp_dflt_blocktime = 0;
821 KMP_WARNING(StgInvalidValue, name, value);
824 if (__kmp_str_match(
"serial", 1, value)) {
825 __kmp_library = library_serial;
826 }
else if (__kmp_str_match(
"throughput", 2, value)) {
827 __kmp_library = library_throughput;
828 if (blocktime_str == NULL) {
830 __kmp_dflt_blocktime = 0;
832 }
else if (__kmp_str_match(
"turnaround", 2, value)) {
833 __kmp_library = library_turnaround;
834 }
else if (__kmp_str_match(
"dedicated", 1, value)) {
835 __kmp_library = library_turnaround;
836 }
else if (__kmp_str_match(
"multiuser", 1, value)) {
837 __kmp_library = library_throughput;
838 if (blocktime_str == NULL) {
840 __kmp_dflt_blocktime = 0;
843 KMP_WARNING(StgInvalidValue, name, value);
848static void __kmp_stg_print_wait_policy(kmp_str_buf_t *buffer,
char const *name,
851 kmp_stg_wp_data_t *wait = (kmp_stg_wp_data_t *)data;
852 char const *value = NULL;
855 switch (__kmp_library) {
856 case library_turnaround: {
859 case library_throughput: {
864 switch (__kmp_library) {
865 case library_serial: {
868 case library_turnaround: {
869 value =
"turnaround";
871 case library_throughput: {
872 value =
"throughput";
877 __kmp_stg_print_str(buffer, name, value);
886static void __kmp_stg_parse_monitor_stacksize(
char const *name,
887 char const *value,
void *data) {
888 __kmp_stg_parse_size(name, value, __kmp_sys_min_stksize, KMP_MAX_STKSIZE,
889 NULL, &__kmp_monitor_stksize, 1);
892static void __kmp_stg_print_monitor_stacksize(kmp_str_buf_t *buffer,
893 char const *name,
void *data) {
894 if (__kmp_env_format) {
895 if (__kmp_monitor_stksize > 0)
896 KMP_STR_BUF_PRINT_NAME_EX(name);
898 KMP_STR_BUF_PRINT_NAME;
900 __kmp_str_buf_print(buffer,
" %s", name);
902 if (__kmp_monitor_stksize > 0) {
903 __kmp_str_buf_print_size(buffer, __kmp_monitor_stksize);
905 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
907 if (__kmp_env_format && __kmp_monitor_stksize) {
908 __kmp_str_buf_print(buffer,
"'\n");
916static void __kmp_stg_parse_settings(
char const *name,
char const *value,
918 __kmp_stg_parse_bool(name, value, &__kmp_settings);
921static void __kmp_stg_print_settings(kmp_str_buf_t *buffer,
char const *name,
923 __kmp_stg_print_bool(buffer, name, __kmp_settings);
929static void __kmp_stg_parse_stackpad(
char const *name,
char const *value,
931 __kmp_stg_parse_int(name,
939static void __kmp_stg_print_stackpad(kmp_str_buf_t *buffer,
char const *name,
941 __kmp_stg_print_int(buffer, name, __kmp_stkpadding);
947static void __kmp_stg_parse_stackoffset(
char const *name,
char const *value,
949 __kmp_stg_parse_size(name,
958static void __kmp_stg_print_stackoffset(kmp_str_buf_t *buffer,
char const *name,
960 __kmp_stg_print_size(buffer, name, __kmp_stkoffset);
966static void __kmp_stg_parse_stacksize(
char const *name,
char const *value,
969 kmp_stg_ss_data_t *stacksize = (kmp_stg_ss_data_t *)data;
972 rc = __kmp_stg_check_rivals(name, value, stacksize->rivals);
976 __kmp_stg_parse_size(name,
978 __kmp_sys_min_stksize,
990static void __kmp_stg_print_stacksize(kmp_str_buf_t *buffer,
char const *name,
992 kmp_stg_ss_data_t *stacksize = (kmp_stg_ss_data_t *)data;
993 if (__kmp_env_format) {
994 KMP_STR_BUF_PRINT_NAME_EX(name);
995 __kmp_str_buf_print_size(buffer, (__kmp_stksize % 1024)
996 ? __kmp_stksize / stacksize->factor
998 __kmp_str_buf_print(buffer,
"'\n");
1000 __kmp_str_buf_print(buffer,
" %s=", name);
1001 __kmp_str_buf_print_size(buffer, (__kmp_stksize % 1024)
1002 ? __kmp_stksize / stacksize->factor
1004 __kmp_str_buf_print(buffer,
"\n");
1011static void __kmp_stg_parse_version(
char const *name,
char const *value,
1013 __kmp_stg_parse_bool(name, value, &__kmp_version);
1016static void __kmp_stg_print_version(kmp_str_buf_t *buffer,
char const *name,
1018 __kmp_stg_print_bool(buffer, name, __kmp_version);
1024static void __kmp_stg_parse_warnings(
char const *name,
char const *value,
1026 __kmp_stg_parse_bool(name, value, &__kmp_generate_warnings);
1027 if (__kmp_generate_warnings != kmp_warnings_off) {
1030 __kmp_generate_warnings = kmp_warnings_explicit;
1034static void __kmp_stg_print_warnings(kmp_str_buf_t *buffer,
char const *name,
1037 __kmp_stg_print_bool(buffer, name, __kmp_generate_warnings);
1043static void __kmp_stg_parse_nesting_mode(
char const *name,
char const *value,
1045 __kmp_stg_parse_int(name, value, 0, INT_MAX, &__kmp_nesting_mode);
1046#if KMP_AFFINITY_SUPPORTED && KMP_USE_HWLOC
1047 if (__kmp_nesting_mode > 0)
1048 __kmp_affinity_top_method = affinity_top_method_hwloc;
1052static void __kmp_stg_print_nesting_mode(kmp_str_buf_t *buffer,
1053 char const *name,
void *data) {
1054 if (__kmp_env_format) {
1055 KMP_STR_BUF_PRINT_NAME;
1057 __kmp_str_buf_print(buffer,
" %s", name);
1059 __kmp_str_buf_print(buffer,
"=%d\n", __kmp_nesting_mode);
1065static void __kmp_stg_parse_nested(
char const *name,
char const *value,
1068 KMP_INFORM(EnvVarDeprecated, name,
"OMP_MAX_ACTIVE_LEVELS");
1069 __kmp_stg_parse_bool(name, value, &nested);
1071 if (!__kmp_dflt_max_active_levels_set)
1072 __kmp_dflt_max_active_levels = KMP_MAX_ACTIVE_LEVELS_LIMIT;
1074 __kmp_dflt_max_active_levels = 1;
1075 __kmp_dflt_max_active_levels_set =
true;
1079static void __kmp_stg_print_nested(kmp_str_buf_t *buffer,
char const *name,
1081 if (__kmp_env_format) {
1082 KMP_STR_BUF_PRINT_NAME;
1084 __kmp_str_buf_print(buffer,
" %s", name);
1086 __kmp_str_buf_print(buffer,
": deprecated; max-active-levels-var=%d\n",
1087 __kmp_dflt_max_active_levels);
1090static void __kmp_parse_nested_num_threads(
const char *var,
const char *env,
1091 kmp_nested_nthreads_t *nth_array) {
1092 const char *next = env;
1093 const char *scan = next;
1096 int prev_comma = FALSE;
1102 if (*next ==
'\0') {
1106 if (((*next <
'0') || (*next >
'9')) && (*next !=
',')) {
1107 KMP_WARNING(NthSyntaxError, var, env);
1113 if (total == 0 || prev_comma) {
1121 if (*next >=
'0' && *next <=
'9') {
1125 const char *tmp = next;
1127 if ((*next ==
' ' || *next ==
'\t') && (*tmp >=
'0' && *tmp <=
'9')) {
1128 KMP_WARNING(NthSpacesNotAllowed, var, env);
1133 if (!__kmp_dflt_max_active_levels_set && total > 1)
1134 __kmp_dflt_max_active_levels = KMP_MAX_ACTIVE_LEVELS_LIMIT;
1135 KMP_DEBUG_ASSERT(total > 0);
1137 KMP_WARNING(NthSyntaxError, var, env);
1142 if (!nth_array->nth) {
1144 nth_array->nth = (
int *)KMP_INTERNAL_MALLOC(
sizeof(
int) * total * 2);
1145 if (nth_array->nth == NULL) {
1146 KMP_FATAL(MemoryAllocFailed);
1148 nth_array->size = total * 2;
1150 if (nth_array->size < total) {
1153 nth_array->size *= 2;
1154 }
while (nth_array->size < total);
1156 nth_array->nth = (
int *)KMP_INTERNAL_REALLOC(
1157 nth_array->nth,
sizeof(
int) * nth_array->size);
1158 if (nth_array->nth == NULL) {
1159 KMP_FATAL(MemoryAllocFailed);
1163 nth_array->used = total;
1171 if (*scan ==
'\0') {
1181 nth_array->nth[i++] = 0;
1183 }
else if (prev_comma) {
1185 nth_array->nth[i] = nth_array->nth[i - 1];
1194 if (*scan >=
'0' && *scan <=
'9') {
1196 const char *buf = scan;
1197 char const *msg = NULL;
1202 num = __kmp_str_to_int(buf, *scan);
1203 if (num < KMP_MIN_NTH) {
1204 msg = KMP_I18N_STR(ValueTooSmall);
1206 }
else if (num > __kmp_sys_max_nth) {
1207 msg = KMP_I18N_STR(ValueTooLarge);
1208 num = __kmp_sys_max_nth;
1212 KMP_WARNING(ParseSizeIntWarn, var, env, msg);
1213 KMP_INFORM(Using_int_Value, var, num);
1215 nth_array->nth[i++] = num;
1220static void __kmp_stg_parse_num_threads(
char const *name,
char const *value,
1223 if (!__kmp_strcasecmp_with_sentinel(
"all", value, 0)) {
1225 __kmp_nested_nth.nth = (
int *)KMP_INTERNAL_MALLOC(
sizeof(
int));
1226 __kmp_nested_nth.size = __kmp_nested_nth.used = 1;
1227 __kmp_nested_nth.nth[0] = __kmp_dflt_team_nth = __kmp_dflt_team_nth_ub =
1230 __kmp_parse_nested_num_threads(name, value, &__kmp_nested_nth);
1231 if (__kmp_nested_nth.nth) {
1232 __kmp_dflt_team_nth = __kmp_nested_nth.nth[0];
1233 if (__kmp_dflt_team_nth_ub < __kmp_dflt_team_nth) {
1234 __kmp_dflt_team_nth_ub = __kmp_dflt_team_nth;
1238 K_DIAG(1, (
"__kmp_dflt_team_nth == %d\n", __kmp_dflt_team_nth));
1241static void __kmp_stg_parse_num_hidden_helper_threads(
char const *name,
1244 __kmp_stg_parse_int(name, value, 0, 16, &__kmp_hidden_helper_threads_num);
1247 if (__kmp_hidden_helper_threads_num == 0) {
1248 __kmp_enable_hidden_helper = FALSE;
1253 __kmp_hidden_helper_threads_num++;
1257static void __kmp_stg_print_num_hidden_helper_threads(kmp_str_buf_t *buffer,
1260 if (__kmp_hidden_helper_threads_num == 0) {
1261 __kmp_stg_print_int(buffer, name, __kmp_hidden_helper_threads_num);
1263 KMP_DEBUG_ASSERT(__kmp_hidden_helper_threads_num > 1);
1266 __kmp_stg_print_int(buffer, name, __kmp_hidden_helper_threads_num - 1);
1270static void __kmp_stg_parse_use_hidden_helper(
char const *name,
1271 char const *value,
void *data) {
1272 __kmp_stg_parse_bool(name, value, &__kmp_enable_hidden_helper);
1274 __kmp_enable_hidden_helper = FALSE;
1276 (
"__kmp_stg_parse_use_hidden_helper: Disable hidden helper task on "
1277 "non-Linux platform although it is enabled by user explicitly.\n"));
1281static void __kmp_stg_print_use_hidden_helper(kmp_str_buf_t *buffer,
1282 char const *name,
void *data) {
1283 __kmp_stg_print_bool(buffer, name, __kmp_enable_hidden_helper);
1286static void __kmp_stg_print_num_threads(kmp_str_buf_t *buffer,
char const *name,
1288 if (__kmp_env_format) {
1289 KMP_STR_BUF_PRINT_NAME;
1291 __kmp_str_buf_print(buffer,
" %s", name);
1293 if (__kmp_nested_nth.used) {
1295 __kmp_str_buf_init(&buf);
1296 for (
int i = 0; i < __kmp_nested_nth.used; i++) {
1297 __kmp_str_buf_print(&buf,
"%d", __kmp_nested_nth.nth[i]);
1298 if (i < __kmp_nested_nth.used - 1) {
1299 __kmp_str_buf_print(&buf,
",");
1302 __kmp_str_buf_print(buffer,
"='%s'\n", buf.str);
1303 __kmp_str_buf_free(&buf);
1305 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
1312static void __kmp_stg_parse_tasking(
char const *name,
char const *value,
1314 __kmp_stg_parse_int(name, value, 0, (
int)tskm_max,
1315 (
int *)&__kmp_tasking_mode);
1318static void __kmp_stg_print_tasking(kmp_str_buf_t *buffer,
char const *name,
1320 __kmp_stg_print_int(buffer, name, __kmp_tasking_mode);
1323static void __kmp_stg_parse_task_stealing(
char const *name,
char const *value,
1325 __kmp_stg_parse_int(name, value, 0, 1,
1326 (
int *)&__kmp_task_stealing_constraint);
1329static void __kmp_stg_print_task_stealing(kmp_str_buf_t *buffer,
1330 char const *name,
void *data) {
1331 __kmp_stg_print_int(buffer, name, __kmp_task_stealing_constraint);
1334static void __kmp_stg_parse_max_active_levels(
char const *name,
1335 char const *value,
void *data) {
1336 kmp_uint64 tmp_dflt = 0;
1337 char const *msg = NULL;
1338 if (!__kmp_dflt_max_active_levels_set) {
1340 __kmp_str_to_uint(value, &tmp_dflt, &msg);
1342 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
1343 }
else if (tmp_dflt > KMP_MAX_ACTIVE_LEVELS_LIMIT) {
1345 msg = KMP_I18N_STR(ValueTooLarge);
1346 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
1348 __kmp_type_convert(tmp_dflt, &(__kmp_dflt_max_active_levels));
1349 __kmp_dflt_max_active_levels_set =
true;
1354static void __kmp_stg_print_max_active_levels(kmp_str_buf_t *buffer,
1355 char const *name,
void *data) {
1356 __kmp_stg_print_int(buffer, name, __kmp_dflt_max_active_levels);
1361static void __kmp_stg_parse_default_device(
char const *name,
char const *value,
1363 __kmp_stg_parse_int(name, value, 0, KMP_MAX_DEFAULT_DEVICE_LIMIT,
1364 &__kmp_default_device);
1367static void __kmp_stg_print_default_device(kmp_str_buf_t *buffer,
1368 char const *name,
void *data) {
1369 __kmp_stg_print_int(buffer, name, __kmp_default_device);
1374static void __kmp_stg_parse_target_offload(
char const *name,
char const *value,
1376 const char *next = value;
1377 const char *scan = next;
1379 __kmp_target_offload = tgt_default;
1384 if (!__kmp_strcasecmp_with_sentinel(
"mandatory", scan, 0)) {
1385 __kmp_target_offload = tgt_mandatory;
1386 }
else if (!__kmp_strcasecmp_with_sentinel(
"disabled", scan, 0)) {
1387 __kmp_target_offload = tgt_disabled;
1388 }
else if (!__kmp_strcasecmp_with_sentinel(
"default", scan, 0)) {
1389 __kmp_target_offload = tgt_default;
1391 KMP_WARNING(SyntaxErrorUsing, name,
"DEFAULT");
1396static void __kmp_stg_print_target_offload(kmp_str_buf_t *buffer,
1397 char const *name,
void *data) {
1398 const char *value = NULL;
1399 if (__kmp_target_offload == tgt_default)
1401 else if (__kmp_target_offload == tgt_mandatory)
1402 value =
"MANDATORY";
1403 else if (__kmp_target_offload == tgt_disabled)
1405 KMP_DEBUG_ASSERT(value);
1406 if (__kmp_env_format) {
1407 KMP_STR_BUF_PRINT_NAME;
1409 __kmp_str_buf_print(buffer,
" %s", name);
1411 __kmp_str_buf_print(buffer,
"=%s\n", value);
1416static void __kmp_stg_parse_max_task_priority(
char const *name,
1417 char const *value,
void *data) {
1418 __kmp_stg_parse_int(name, value, 0, KMP_MAX_TASK_PRIORITY_LIMIT,
1419 &__kmp_max_task_priority);
1422static void __kmp_stg_print_max_task_priority(kmp_str_buf_t *buffer,
1423 char const *name,
void *data) {
1424 __kmp_stg_print_int(buffer, name, __kmp_max_task_priority);
1429static void __kmp_stg_parse_taskloop_min_tasks(
char const *name,
1430 char const *value,
void *data) {
1432 __kmp_stg_parse_int(name, value, 0, INT_MAX, &tmp);
1433 __kmp_taskloop_min_tasks = tmp;
1436static void __kmp_stg_print_taskloop_min_tasks(kmp_str_buf_t *buffer,
1437 char const *name,
void *data) {
1438 __kmp_stg_print_uint64(buffer, name, __kmp_taskloop_min_tasks);
1443static void __kmp_stg_parse_disp_buffers(
char const *name,
char const *value,
1445 if (TCR_4(__kmp_init_serial)) {
1446 KMP_WARNING(EnvSerialWarn, name);
1449 __kmp_stg_parse_int(name, value, KMP_MIN_DISP_NUM_BUFF, KMP_MAX_DISP_NUM_BUFF,
1450 &__kmp_dispatch_num_buffers);
1453static void __kmp_stg_print_disp_buffers(kmp_str_buf_t *buffer,
1454 char const *name,
void *data) {
1455 __kmp_stg_print_int(buffer, name, __kmp_dispatch_num_buffers);
1458#if KMP_NESTED_HOT_TEAMS
1462static void __kmp_stg_parse_hot_teams_level(
char const *name,
char const *value,
1464 if (TCR_4(__kmp_init_parallel)) {
1465 KMP_WARNING(EnvParallelWarn, name);
1468 __kmp_stg_parse_int(name, value, 0, KMP_MAX_ACTIVE_LEVELS_LIMIT,
1469 &__kmp_hot_teams_max_level);
1472static void __kmp_stg_print_hot_teams_level(kmp_str_buf_t *buffer,
1473 char const *name,
void *data) {
1474 __kmp_stg_print_int(buffer, name, __kmp_hot_teams_max_level);
1477static void __kmp_stg_parse_hot_teams_mode(
char const *name,
char const *value,
1479 if (TCR_4(__kmp_init_parallel)) {
1480 KMP_WARNING(EnvParallelWarn, name);
1483 __kmp_stg_parse_int(name, value, 0, KMP_MAX_ACTIVE_LEVELS_LIMIT,
1484 &__kmp_hot_teams_mode);
1487static void __kmp_stg_print_hot_teams_mode(kmp_str_buf_t *buffer,
1488 char const *name,
void *data) {
1489 __kmp_stg_print_int(buffer, name, __kmp_hot_teams_mode);
1497#if KMP_HANDLE_SIGNALS
1499static void __kmp_stg_parse_handle_signals(
char const *name,
char const *value,
1501 __kmp_stg_parse_bool(name, value, &__kmp_handle_signals);
1504static void __kmp_stg_print_handle_signals(kmp_str_buf_t *buffer,
1505 char const *name,
void *data) {
1506 __kmp_stg_print_bool(buffer, name, __kmp_handle_signals);
1516#define KMP_STG_X_DEBUG(x) \
1517 static void __kmp_stg_parse_##x##_debug(char const *name, char const *value, \
1519 __kmp_stg_parse_int(name, value, 0, INT_MAX, &kmp_##x##_debug); \
1521 static void __kmp_stg_print_##x##_debug(kmp_str_buf_t *buffer, \
1522 char const *name, void *data) { \
1523 __kmp_stg_print_int(buffer, name, kmp_##x##_debug); \
1533#undef KMP_STG_X_DEBUG
1535static void __kmp_stg_parse_debug(
char const *name,
char const *value,
1538 __kmp_stg_parse_int(name, value, 0, INT_MAX, &debug);
1539 if (kmp_a_debug < debug) {
1540 kmp_a_debug = debug;
1542 if (kmp_b_debug < debug) {
1543 kmp_b_debug = debug;
1545 if (kmp_c_debug < debug) {
1546 kmp_c_debug = debug;
1548 if (kmp_d_debug < debug) {
1549 kmp_d_debug = debug;
1551 if (kmp_e_debug < debug) {
1552 kmp_e_debug = debug;
1554 if (kmp_f_debug < debug) {
1555 kmp_f_debug = debug;
1559static void __kmp_stg_parse_debug_buf(
char const *name,
char const *value,
1561 __kmp_stg_parse_bool(name, value, &__kmp_debug_buf);
1565 if (__kmp_debug_buf) {
1567 int elements = __kmp_debug_buf_lines * __kmp_debug_buf_chars;
1570 __kmp_debug_buffer = (
char *)__kmp_page_allocate(elements *
sizeof(
char));
1571 for (i = 0; i < elements; i += __kmp_debug_buf_chars)
1572 __kmp_debug_buffer[i] =
'\0';
1574 __kmp_debug_count = 0;
1576 K_DIAG(1, (
"__kmp_debug_buf = %d\n", __kmp_debug_buf));
1579static void __kmp_stg_print_debug_buf(kmp_str_buf_t *buffer,
char const *name,
1581 __kmp_stg_print_bool(buffer, name, __kmp_debug_buf);
1584static void __kmp_stg_parse_debug_buf_atomic(
char const *name,
1585 char const *value,
void *data) {
1586 __kmp_stg_parse_bool(name, value, &__kmp_debug_buf_atomic);
1589static void __kmp_stg_print_debug_buf_atomic(kmp_str_buf_t *buffer,
1590 char const *name,
void *data) {
1591 __kmp_stg_print_bool(buffer, name, __kmp_debug_buf_atomic);
1594static void __kmp_stg_parse_debug_buf_chars(
char const *name,
char const *value,
1596 __kmp_stg_parse_int(name, value, KMP_DEBUG_BUF_CHARS_MIN, INT_MAX,
1597 &__kmp_debug_buf_chars);
1600static void __kmp_stg_print_debug_buf_chars(kmp_str_buf_t *buffer,
1601 char const *name,
void *data) {
1602 __kmp_stg_print_int(buffer, name, __kmp_debug_buf_chars);
1605static void __kmp_stg_parse_debug_buf_lines(
char const *name,
char const *value,
1607 __kmp_stg_parse_int(name, value, KMP_DEBUG_BUF_LINES_MIN, INT_MAX,
1608 &__kmp_debug_buf_lines);
1611static void __kmp_stg_print_debug_buf_lines(kmp_str_buf_t *buffer,
1612 char const *name,
void *data) {
1613 __kmp_stg_print_int(buffer, name, __kmp_debug_buf_lines);
1616static void __kmp_stg_parse_diag(
char const *name,
char const *value,
1618 __kmp_stg_parse_int(name, value, 0, INT_MAX, &kmp_diag);
1621static void __kmp_stg_print_diag(kmp_str_buf_t *buffer,
char const *name,
1623 __kmp_stg_print_int(buffer, name, kmp_diag);
1631static void __kmp_stg_parse_align_alloc(
char const *name,
char const *value,
1633 __kmp_stg_parse_size(name, value, CACHE_LINE, INT_MAX, NULL,
1634 &__kmp_align_alloc, 1);
1637static void __kmp_stg_print_align_alloc(kmp_str_buf_t *buffer,
char const *name,
1639 __kmp_stg_print_size(buffer, name, __kmp_align_alloc);
1648static void __kmp_stg_parse_barrier_branch_bit(
char const *name,
1649 char const *value,
void *data) {
1653 for (
int i = bs_plain_barrier; i < bs_last_barrier; i++) {
1654 var = __kmp_barrier_branch_bit_env_name[i];
1655 if ((strcmp(var, name) == 0) && (value != 0)) {
1658 comma = CCAST(
char *, strchr(value,
','));
1659 __kmp_barrier_gather_branch_bits[i] =
1660 (kmp_uint32)__kmp_str_to_int(value,
',');
1662 if (comma == NULL) {
1663 __kmp_barrier_release_branch_bits[i] = __kmp_barrier_release_bb_dflt;
1665 __kmp_barrier_release_branch_bits[i] =
1666 (kmp_uint32)__kmp_str_to_int(comma + 1, 0);
1668 if (__kmp_barrier_release_branch_bits[i] > KMP_MAX_BRANCH_BITS) {
1669 __kmp_msg(kmp_ms_warning,
1670 KMP_MSG(BarrReleaseValueInvalid, name, comma + 1),
1672 __kmp_barrier_release_branch_bits[i] = __kmp_barrier_release_bb_dflt;
1675 if (__kmp_barrier_gather_branch_bits[i] > KMP_MAX_BRANCH_BITS) {
1676 KMP_WARNING(BarrGatherValueInvalid, name, value);
1677 KMP_INFORM(Using_uint_Value, name, __kmp_barrier_gather_bb_dflt);
1678 __kmp_barrier_gather_branch_bits[i] = __kmp_barrier_gather_bb_dflt;
1681 K_DIAG(1, (
"%s == %d,%d\n", __kmp_barrier_branch_bit_env_name[i],
1682 __kmp_barrier_gather_branch_bits[i],
1683 __kmp_barrier_release_branch_bits[i]))
1687static void __kmp_stg_print_barrier_branch_bit(kmp_str_buf_t *buffer,
1688 char const *name,
void *data) {
1690 for (
int i = bs_plain_barrier; i < bs_last_barrier; i++) {
1691 var = __kmp_barrier_branch_bit_env_name[i];
1692 if (strcmp(var, name) == 0) {
1693 if (__kmp_env_format) {
1694 KMP_STR_BUF_PRINT_NAME_EX(__kmp_barrier_branch_bit_env_name[i]);
1696 __kmp_str_buf_print(buffer,
" %s='",
1697 __kmp_barrier_branch_bit_env_name[i]);
1699 __kmp_str_buf_print(buffer,
"%d,%d'\n",
1700 __kmp_barrier_gather_branch_bits[i],
1701 __kmp_barrier_release_branch_bits[i]);
1713static void __kmp_stg_parse_barrier_pattern(
char const *name,
char const *value,
1718 static int dist_req = 0, non_dist_req = 0;
1719 static bool warn = 1;
1720 for (
int i = bs_plain_barrier; i < bs_last_barrier; i++) {
1721 var = __kmp_barrier_pattern_env_name[i];
1723 if ((strcmp(var, name) == 0) && (value != 0)) {
1725 char *comma = CCAST(
char *, strchr(value,
','));
1728 for (j = bp_linear_bar; j < bp_last_bar; j++) {
1729 if (__kmp_match_with_sentinel(__kmp_barrier_pattern_name[j], value, 1,
1731 if (j == bp_dist_bar) {
1736 __kmp_barrier_gather_pattern[i] = (kmp_bar_pat_e)j;
1740 if (j == bp_last_bar) {
1741 KMP_WARNING(BarrGatherValueInvalid, name, value);
1742 KMP_INFORM(Using_str_Value, name,
1743 __kmp_barrier_pattern_name[bp_linear_bar]);
1747 if (comma != NULL) {
1748 for (j = bp_linear_bar; j < bp_last_bar; j++) {
1749 if (__kmp_str_match(__kmp_barrier_pattern_name[j], 1, comma + 1)) {
1750 if (j == bp_dist_bar) {
1755 __kmp_barrier_release_pattern[i] = (kmp_bar_pat_e)j;
1759 if (j == bp_last_bar) {
1760 __kmp_msg(kmp_ms_warning,
1761 KMP_MSG(BarrReleaseValueInvalid, name, comma + 1),
1763 KMP_INFORM(Using_str_Value, name,
1764 __kmp_barrier_pattern_name[bp_linear_bar]);
1769 if (dist_req != 0) {
1771 if ((non_dist_req != 0) && warn) {
1772 KMP_INFORM(BarrierPatternOverride, name,
1773 __kmp_barrier_pattern_name[bp_dist_bar]);
1776 for (
int i = bs_plain_barrier; i < bs_last_barrier; i++) {
1777 if (__kmp_barrier_release_pattern[i] != bp_dist_bar)
1778 __kmp_barrier_release_pattern[i] = bp_dist_bar;
1779 if (__kmp_barrier_gather_pattern[i] != bp_dist_bar)
1780 __kmp_barrier_gather_pattern[i] = bp_dist_bar;
1785static void __kmp_stg_print_barrier_pattern(kmp_str_buf_t *buffer,
1786 char const *name,
void *data) {
1788 for (
int i = bs_plain_barrier; i < bs_last_barrier; i++) {
1789 var = __kmp_barrier_pattern_env_name[i];
1790 if (strcmp(var, name) == 0) {
1791 int j = __kmp_barrier_gather_pattern[i];
1792 int k = __kmp_barrier_release_pattern[i];
1793 if (__kmp_env_format) {
1794 KMP_STR_BUF_PRINT_NAME_EX(__kmp_barrier_pattern_env_name[i]);
1796 __kmp_str_buf_print(buffer,
" %s='",
1797 __kmp_barrier_pattern_env_name[i]);
1799 KMP_DEBUG_ASSERT(j < bp_last_bar && k < bp_last_bar);
1800 __kmp_str_buf_print(buffer,
"%s,%s'\n", __kmp_barrier_pattern_name[j],
1801 __kmp_barrier_pattern_name[k]);
1809static void __kmp_stg_parse_abort_delay(
char const *name,
char const *value,
1813 int delay = __kmp_abort_delay / 1000;
1814 __kmp_stg_parse_int(name, value, 0, INT_MAX / 1000, &delay);
1815 __kmp_abort_delay = delay * 1000;
1818static void __kmp_stg_print_abort_delay(kmp_str_buf_t *buffer,
char const *name,
1820 __kmp_stg_print_int(buffer, name, __kmp_abort_delay);
1826static void __kmp_stg_parse_cpuinfo_file(
char const *name,
char const *value,
1828#if KMP_AFFINITY_SUPPORTED
1829 __kmp_stg_parse_str(name, value, &__kmp_cpuinfo_file);
1830 K_DIAG(1, (
"__kmp_cpuinfo_file == %s\n", __kmp_cpuinfo_file));
1834static void __kmp_stg_print_cpuinfo_file(kmp_str_buf_t *buffer,
1835 char const *name,
void *data) {
1836#if KMP_AFFINITY_SUPPORTED
1837 if (__kmp_env_format) {
1838 KMP_STR_BUF_PRINT_NAME;
1840 __kmp_str_buf_print(buffer,
" %s", name);
1842 if (__kmp_cpuinfo_file) {
1843 __kmp_str_buf_print(buffer,
"='%s'\n", __kmp_cpuinfo_file);
1845 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
1853static void __kmp_stg_parse_force_reduction(
char const *name,
char const *value,
1855 kmp_stg_fr_data_t *reduction = (kmp_stg_fr_data_t *)data;
1858 rc = __kmp_stg_check_rivals(name, value, reduction->rivals);
1862 if (reduction->force) {
1864 if (__kmp_str_match(
"critical", 0, value))
1865 __kmp_force_reduction_method = critical_reduce_block;
1866 else if (__kmp_str_match(
"atomic", 0, value))
1867 __kmp_force_reduction_method = atomic_reduce_block;
1868 else if (__kmp_str_match(
"tree", 0, value))
1869 __kmp_force_reduction_method = tree_reduce_block;
1871 KMP_FATAL(UnknownForceReduction, name, value);
1875 __kmp_stg_parse_bool(name, value, &__kmp_determ_red);
1876 if (__kmp_determ_red) {
1877 __kmp_force_reduction_method = tree_reduce_block;
1879 __kmp_force_reduction_method = reduction_method_not_defined;
1882 K_DIAG(1, (
"__kmp_force_reduction_method == %d\n",
1883 __kmp_force_reduction_method));
1886static void __kmp_stg_print_force_reduction(kmp_str_buf_t *buffer,
1887 char const *name,
void *data) {
1889 kmp_stg_fr_data_t *reduction = (kmp_stg_fr_data_t *)data;
1890 if (reduction->force) {
1891 if (__kmp_force_reduction_method == critical_reduce_block) {
1892 __kmp_stg_print_str(buffer, name,
"critical");
1893 }
else if (__kmp_force_reduction_method == atomic_reduce_block) {
1894 __kmp_stg_print_str(buffer, name,
"atomic");
1895 }
else if (__kmp_force_reduction_method == tree_reduce_block) {
1896 __kmp_stg_print_str(buffer, name,
"tree");
1898 if (__kmp_env_format) {
1899 KMP_STR_BUF_PRINT_NAME;
1901 __kmp_str_buf_print(buffer,
" %s", name);
1903 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
1906 __kmp_stg_print_bool(buffer, name, __kmp_determ_red);
1914static void __kmp_stg_parse_storage_map(
char const *name,
char const *value,
1916 if (__kmp_str_match(
"verbose", 1, value)) {
1917 __kmp_storage_map = TRUE;
1918 __kmp_storage_map_verbose = TRUE;
1919 __kmp_storage_map_verbose_specified = TRUE;
1922 __kmp_storage_map_verbose = FALSE;
1923 __kmp_stg_parse_bool(name, value, &__kmp_storage_map);
1927static void __kmp_stg_print_storage_map(kmp_str_buf_t *buffer,
char const *name,
1929 if (__kmp_storage_map_verbose || __kmp_storage_map_verbose_specified) {
1930 __kmp_stg_print_str(buffer, name,
"verbose");
1932 __kmp_stg_print_bool(buffer, name, __kmp_storage_map);
1939static void __kmp_stg_parse_all_threadprivate(
char const *name,
1940 char const *value,
void *data) {
1941 __kmp_stg_parse_int(name, value,
1942 __kmp_allThreadsSpecified ? __kmp_max_nth : 1,
1943 __kmp_max_nth, &__kmp_tp_capacity);
1946static void __kmp_stg_print_all_threadprivate(kmp_str_buf_t *buffer,
1947 char const *name,
void *data) {
1948 __kmp_stg_print_int(buffer, name, __kmp_tp_capacity);
1954static void __kmp_stg_parse_foreign_threads_threadprivate(
char const *name,
1957 __kmp_stg_parse_bool(name, value, &__kmp_foreign_tp);
1960static void __kmp_stg_print_foreign_threads_threadprivate(kmp_str_buf_t *buffer,
1963 __kmp_stg_print_bool(buffer, name, __kmp_foreign_tp);
1969#if KMP_AFFINITY_SUPPORTED
1971static int __kmp_parse_affinity_proc_id_list(
const char *var,
const char *env,
1972 const char **nextEnv,
1974 const char *scan = env;
1975 const char *next = scan;
1981 int start, end, stride;
1985 if (*next ==
'\0') {
1996 if ((*next <
'0') || (*next >
'9')) {
1997 KMP_WARNING(AffSyntaxError, var);
2001 num = __kmp_str_to_int(scan, *next);
2002 KMP_ASSERT(num >= 0);
2020 if ((*next <
'0') || (*next >
'9')) {
2021 KMP_WARNING(AffSyntaxError, var);
2026 num = __kmp_str_to_int(scan, *next);
2027 KMP_ASSERT(num >= 0);
2040 if ((*next <
'0') || (*next >
'9')) {
2042 KMP_WARNING(AffSyntaxError, var);
2050 start = __kmp_str_to_int(scan, *next);
2051 KMP_ASSERT(start >= 0);
2070 if ((*next <
'0') || (*next >
'9')) {
2071 KMP_WARNING(AffSyntaxError, var);
2075 end = __kmp_str_to_int(scan, *next);
2076 KMP_ASSERT(end >= 0);
2093 if ((*next <
'0') || (*next >
'9')) {
2094 KMP_WARNING(AffSyntaxError, var);
2098 stride = __kmp_str_to_int(scan, *next);
2099 KMP_ASSERT(stride >= 0);
2105 KMP_WARNING(AffZeroStride, var);
2110 KMP_WARNING(AffStartGreaterEnd, var, start, end);
2115 KMP_WARNING(AffStrideLessZero, var, start, end);
2119 if ((end - start) / stride > 65536) {
2120 KMP_WARNING(AffRangeTooBig, var, end, start, stride);
2137 ptrdiff_t len = next - env;
2138 char *retlist = (
char *)__kmp_allocate((len + 1) *
sizeof(char));
2139 KMP_MEMCPY_S(retlist, (len + 1) *
sizeof(
char), env, len *
sizeof(
char));
2140 retlist[len] =
'\0';
2141 *proclist = retlist;
2148static kmp_setting_t *__kmp_affinity_notype = NULL;
2150static void __kmp_parse_affinity_env(
char const *name,
char const *value,
2151 enum affinity_type *out_type,
2152 char **out_proclist,
int *out_verbose,
2153 int *out_warn,
int *out_respect,
2154 kmp_hw_t *out_gran,
int *out_gran_levels,
2155 int *out_dups,
int *out_compact,
2157 char *buffer = NULL;
2175 KMP_ASSERT(value != NULL);
2177 if (TCR_4(__kmp_init_middle)) {
2178 KMP_WARNING(EnvMiddleWarn, name);
2179 __kmp_env_toPrint(name, 0);
2182 __kmp_env_toPrint(name, 1);
2185 __kmp_str_format(
"%s", value);
2195#define EMIT_WARN(skip, errlist) \
2199 SKIP_TO(next, ','); \
2203 KMP_WARNING errlist; \
2212#define _set_param(_guard, _var, _val) \
2214 if (_guard == 0) { \
2217 EMIT_WARN(FALSE, (AffParamDefined, name, start)); \
2222#define set_type(val) _set_param(type, *out_type, val)
2223#define set_verbose(val) _set_param(verbose, *out_verbose, val)
2224#define set_warnings(val) _set_param(warnings, *out_warn, val)
2225#define set_respect(val) _set_param(respect, *out_respect, val)
2226#define set_dups(val) _set_param(dups, *out_dups, val)
2227#define set_proclist(val) _set_param(proclist, *out_proclist, val)
2228#define set_reset(val) _set_param(reset, __kmp_affin_reset, val)
2230#define set_gran(val, levels) \
2234 *out_gran_levels = levels; \
2236 EMIT_WARN(FALSE, (AffParamDefined, name, start)); \
2241 KMP_DEBUG_ASSERT((__kmp_nested_proc_bind.bind_types != NULL) &&
2242 (__kmp_nested_proc_bind.used > 0));
2244 while (*buf !=
'\0') {
2247 if (__kmp_match_str(
"none", buf, CCAST(
const char **, &next))) {
2248 set_type(affinity_none);
2249 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
2251 }
else if (__kmp_match_str(
"scatter", buf, CCAST(
const char **, &next))) {
2252 set_type(affinity_scatter);
2253 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2255 }
else if (__kmp_match_str(
"compact", buf, CCAST(
const char **, &next))) {
2256 set_type(affinity_compact);
2257 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2259 }
else if (__kmp_match_str(
"logical", buf, CCAST(
const char **, &next))) {
2260 set_type(affinity_logical);
2261 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2263 }
else if (__kmp_match_str(
"physical", buf, CCAST(
const char **, &next))) {
2264 set_type(affinity_physical);
2265 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2267 }
else if (__kmp_match_str(
"explicit", buf, CCAST(
const char **, &next))) {
2268 set_type(affinity_explicit);
2269 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2271 }
else if (__kmp_match_str(
"balanced", buf, CCAST(
const char **, &next))) {
2272 set_type(affinity_balanced);
2273 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2275 }
else if (__kmp_match_str(
"disabled", buf, CCAST(
const char **, &next))) {
2276 set_type(affinity_disabled);
2277 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
2279 }
else if (__kmp_match_str(
"verbose", buf, CCAST(
const char **, &next))) {
2282 }
else if (__kmp_match_str(
"noverbose", buf, CCAST(
const char **, &next))) {
2285 }
else if (__kmp_match_str(
"warnings", buf, CCAST(
const char **, &next))) {
2288 }
else if (__kmp_match_str(
"nowarnings", buf,
2289 CCAST(
const char **, &next))) {
2290 set_warnings(FALSE);
2292 }
else if (__kmp_match_str(
"respect", buf, CCAST(
const char **, &next))) {
2295 }
else if (__kmp_match_str(
"norespect", buf, CCAST(
const char **, &next))) {
2298 }
else if (__kmp_match_str(
"reset", buf, CCAST(
const char **, &next))) {
2301 }
else if (__kmp_match_str(
"noreset", buf, CCAST(
const char **, &next))) {
2304 }
else if (__kmp_match_str(
"duplicates", buf,
2305 CCAST(
const char **, &next)) ||
2306 __kmp_match_str(
"dups", buf, CCAST(
const char **, &next))) {
2309 }
else if (__kmp_match_str(
"noduplicates", buf,
2310 CCAST(
const char **, &next)) ||
2311 __kmp_match_str(
"nodups", buf, CCAST(
const char **, &next))) {
2314 }
else if (__kmp_match_str(
"granularity", buf,
2315 CCAST(
const char **, &next)) ||
2316 __kmp_match_str(
"gran", buf, CCAST(
const char **, &next))) {
2319 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2328 KMP_FOREACH_HW_TYPE(type) {
2329 const char *name = __kmp_hw_get_keyword(type);
2330 if (__kmp_match_str(name, buf, CCAST(
const char **, &next))) {
2339 if (__kmp_match_str(
"fine", buf, CCAST(
const char **, &next))) {
2340 set_gran(KMP_HW_THREAD, -1);
2343 }
else if (__kmp_match_str(
"package", buf,
2344 CCAST(
const char **, &next))) {
2345 set_gran(KMP_HW_SOCKET, -1);
2348 }
else if (__kmp_match_str(
"node", buf, CCAST(
const char **, &next))) {
2349 set_gran(KMP_HW_NUMA, -1);
2352#if KMP_GROUP_AFFINITY
2353 }
else if (__kmp_match_str(
"group", buf, CCAST(
const char **, &next))) {
2354 set_gran(KMP_HW_PROC_GROUP, -1);
2358 }
else if ((*buf >=
'0') && (*buf <=
'9')) {
2362 n = __kmp_str_to_int(buf, *next);
2365 set_gran(KMP_HW_UNKNOWN, n);
2368 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2372 }
else if (__kmp_match_str(
"proclist", buf, CCAST(
const char **, &next))) {
2373 char *temp_proclist;
2377 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2383 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2388 if (!__kmp_parse_affinity_proc_id_list(
2389 name, buf, CCAST(
const char **, &next), &temp_proclist)) {
2401 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2405 set_proclist(temp_proclist);
2406 }
else if ((*buf >=
'0') && (*buf <=
'9')) {
2411 n = __kmp_str_to_int(buf, *next);
2417 KMP_WARNING(AffManyParams, name, start);
2421 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2429 }
else if (*next !=
'\0') {
2430 const char *temp = next;
2431 EMIT_WARN(TRUE, (ParseExtraCharsWarn, name, temp));
2443#undef set_granularity
2446 __kmp_str_free(&buffer);
2450 KMP_WARNING(AffProcListNoType, name);
2451 *out_type = affinity_explicit;
2452 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2453 }
else if (*out_type != affinity_explicit) {
2454 KMP_WARNING(AffProcListNotExplicit, name);
2455 KMP_ASSERT(*out_proclist != NULL);
2456 KMP_INTERNAL_FREE(*out_proclist);
2457 *out_proclist = NULL;
2460 switch (*out_type) {
2461 case affinity_logical:
2462 case affinity_physical: {
2464 *out_offset = number[0];
2467 KMP_WARNING(AffManyParamsForLogic, name, number[1]);
2470 case affinity_balanced: {
2472 *out_compact = number[0];
2475 *out_offset = number[1];
2478 if (__kmp_affinity_gran == KMP_HW_UNKNOWN) {
2479#if KMP_MIC_SUPPORTED
2480 if (__kmp_mic_type != non_mic) {
2481 if (__kmp_affinity_verbose || __kmp_affinity_warnings) {
2482 KMP_WARNING(AffGranUsing,
"KMP_AFFINITY",
"fine");
2484 __kmp_affinity_gran = KMP_HW_THREAD;
2488 if (__kmp_affinity_verbose || __kmp_affinity_warnings) {
2489 KMP_WARNING(AffGranUsing,
"KMP_AFFINITY",
"core");
2491 __kmp_affinity_gran = KMP_HW_CORE;
2495 case affinity_scatter:
2496 case affinity_compact: {
2498 *out_compact = number[0];
2501 *out_offset = number[1];
2504 case affinity_explicit: {
2505 if (*out_proclist == NULL) {
2506 KMP_WARNING(AffNoProcList, name);
2507 __kmp_affinity_type = affinity_none;
2510 KMP_WARNING(AffNoParam, name,
"explicit");
2513 case affinity_none: {
2515 KMP_WARNING(AffNoParam, name,
"none");
2518 case affinity_disabled: {
2520 KMP_WARNING(AffNoParam, name,
"disabled");
2523 case affinity_default: {
2525 KMP_WARNING(AffNoParam, name,
"default");
2534static void __kmp_stg_parse_affinity(
char const *name,
char const *value,
2536 kmp_setting_t **rivals = (kmp_setting_t **)data;
2539 rc = __kmp_stg_check_rivals(name, value, rivals);
2544 __kmp_parse_affinity_env(name, value, &__kmp_affinity_type,
2545 &__kmp_affinity_proclist, &__kmp_affinity_verbose,
2546 &__kmp_affinity_warnings,
2547 &__kmp_affinity_respect_mask, &__kmp_affinity_gran,
2548 &__kmp_affinity_gran_levels, &__kmp_affinity_dups,
2549 &__kmp_affinity_compact, &__kmp_affinity_offset);
2553static void __kmp_stg_print_affinity(kmp_str_buf_t *buffer,
char const *name,
2555 if (__kmp_env_format) {
2556 KMP_STR_BUF_PRINT_NAME_EX(name);
2558 __kmp_str_buf_print(buffer,
" %s='", name);
2560 if (__kmp_affinity_verbose) {
2561 __kmp_str_buf_print(buffer,
"%s,",
"verbose");
2563 __kmp_str_buf_print(buffer,
"%s,",
"noverbose");
2565 if (__kmp_affinity_warnings) {
2566 __kmp_str_buf_print(buffer,
"%s,",
"warnings");
2568 __kmp_str_buf_print(buffer,
"%s,",
"nowarnings");
2570 if (KMP_AFFINITY_CAPABLE()) {
2571 if (__kmp_affinity_respect_mask) {
2572 __kmp_str_buf_print(buffer,
"%s,",
"respect");
2574 __kmp_str_buf_print(buffer,
"%s,",
"norespect");
2576 if (__kmp_affin_reset) {
2577 __kmp_str_buf_print(buffer,
"%s,",
"reset");
2579 __kmp_str_buf_print(buffer,
"%s,",
"noreset");
2581 __kmp_str_buf_print(buffer,
"granularity=%s,",
2582 __kmp_hw_get_keyword(__kmp_affinity_gran,
false));
2584 if (!KMP_AFFINITY_CAPABLE()) {
2585 __kmp_str_buf_print(buffer,
"%s",
"disabled");
2587 switch (__kmp_affinity_type) {
2589 __kmp_str_buf_print(buffer,
"%s",
"none");
2591 case affinity_physical:
2592 __kmp_str_buf_print(buffer,
"%s,%d",
"physical", __kmp_affinity_offset);
2594 case affinity_logical:
2595 __kmp_str_buf_print(buffer,
"%s,%d",
"logical", __kmp_affinity_offset);
2597 case affinity_compact:
2598 __kmp_str_buf_print(buffer,
"%s,%d,%d",
"compact", __kmp_affinity_compact,
2599 __kmp_affinity_offset);
2601 case affinity_scatter:
2602 __kmp_str_buf_print(buffer,
"%s,%d,%d",
"scatter", __kmp_affinity_compact,
2603 __kmp_affinity_offset);
2605 case affinity_explicit:
2606 __kmp_str_buf_print(buffer,
"%s=[%s],%s",
"proclist",
2607 __kmp_affinity_proclist,
"explicit");
2609 case affinity_balanced:
2610 __kmp_str_buf_print(buffer,
"%s,%d,%d",
"balanced",
2611 __kmp_affinity_compact, __kmp_affinity_offset);
2613 case affinity_disabled:
2614 __kmp_str_buf_print(buffer,
"%s",
"disabled");
2616 case affinity_default:
2617 __kmp_str_buf_print(buffer,
"%s",
"default");
2620 __kmp_str_buf_print(buffer,
"%s",
"<unknown>");
2623 __kmp_str_buf_print(buffer,
"'\n");
2626#ifdef KMP_GOMP_COMPAT
2628static void __kmp_stg_parse_gomp_cpu_affinity(
char const *name,
2629 char const *value,
void *data) {
2630 const char *next = NULL;
2631 char *temp_proclist;
2632 kmp_setting_t **rivals = (kmp_setting_t **)data;
2635 rc = __kmp_stg_check_rivals(name, value, rivals);
2640 if (TCR_4(__kmp_init_middle)) {
2641 KMP_WARNING(EnvMiddleWarn, name);
2642 __kmp_env_toPrint(name, 0);
2646 __kmp_env_toPrint(name, 1);
2648 if (__kmp_parse_affinity_proc_id_list(name, value, &next, &temp_proclist)) {
2650 if (*next ==
'\0') {
2652 __kmp_affinity_proclist = temp_proclist;
2653 __kmp_affinity_type = affinity_explicit;
2654 __kmp_affinity_gran = KMP_HW_THREAD;
2655 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2657 KMP_WARNING(AffSyntaxError, name);
2658 if (temp_proclist != NULL) {
2659 KMP_INTERNAL_FREE((
void *)temp_proclist);
2664 __kmp_affinity_type = affinity_none;
2665 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
2692static inline void __kmp_omp_places_syntax_warn(
const char *var) {
2693 KMP_WARNING(SyntaxErrorUsing, var,
"\"cores\"");
2696static int __kmp_parse_subplace_list(
const char *var,
const char **scan) {
2700 int start, count, stride;
2706 if ((**scan <
'0') || (**scan >
'9')) {
2707 __kmp_omp_places_syntax_warn(var);
2712 start = __kmp_str_to_int(*scan, *next);
2713 KMP_ASSERT(start >= 0);
2718 if (**scan ==
'}') {
2721 if (**scan ==
',') {
2725 if (**scan !=
':') {
2726 __kmp_omp_places_syntax_warn(var);
2733 if ((**scan <
'0') || (**scan >
'9')) {
2734 __kmp_omp_places_syntax_warn(var);
2739 count = __kmp_str_to_int(*scan, *next);
2740 KMP_ASSERT(count >= 0);
2745 if (**scan ==
'}') {
2748 if (**scan ==
',') {
2752 if (**scan !=
':') {
2753 __kmp_omp_places_syntax_warn(var);
2762 if (**scan ==
'+') {
2766 if (**scan ==
'-') {
2774 if ((**scan <
'0') || (**scan >
'9')) {
2775 __kmp_omp_places_syntax_warn(var);
2780 stride = __kmp_str_to_int(*scan, *next);
2781 KMP_ASSERT(stride >= 0);
2787 if (**scan ==
'}') {
2790 if (**scan ==
',') {
2795 __kmp_omp_places_syntax_warn(var);
2801static int __kmp_parse_place(
const char *var,
const char **scan) {
2806 if (**scan ==
'{') {
2808 if (!__kmp_parse_subplace_list(var, scan)) {
2811 if (**scan !=
'}') {
2812 __kmp_omp_places_syntax_warn(var);
2816 }
else if (**scan ==
'!') {
2818 return __kmp_parse_place(var, scan);
2819 }
else if ((**scan >=
'0') && (**scan <=
'9')) {
2822 int proc = __kmp_str_to_int(*scan, *next);
2823 KMP_ASSERT(proc >= 0);
2826 __kmp_omp_places_syntax_warn(var);
2832static int __kmp_parse_place_list(
const char *var,
const char *env,
2833 char **place_list) {
2834 const char *scan = env;
2835 const char *next = scan;
2840 if (!__kmp_parse_place(var, &scan)) {
2846 if (*scan ==
'\0') {
2854 __kmp_omp_places_syntax_warn(var);
2861 if ((*scan <
'0') || (*scan >
'9')) {
2862 __kmp_omp_places_syntax_warn(var);
2867 count = __kmp_str_to_int(scan, *next);
2868 KMP_ASSERT(count >= 0);
2873 if (*scan ==
'\0') {
2881 __kmp_omp_places_syntax_warn(var);
2902 if ((*scan <
'0') || (*scan >
'9')) {
2903 __kmp_omp_places_syntax_warn(var);
2908 stride = __kmp_str_to_int(scan, *next);
2909 KMP_ASSERT(stride >= 0);
2915 if (*scan ==
'\0') {
2923 __kmp_omp_places_syntax_warn(var);
2928 ptrdiff_t len = scan - env;
2929 char *retlist = (
char *)__kmp_allocate((len + 1) *
sizeof(char));
2930 KMP_MEMCPY_S(retlist, (len + 1) *
sizeof(
char), env, len *
sizeof(
char));
2931 retlist[len] =
'\0';
2932 *place_list = retlist;
2937static void __kmp_stg_parse_places(
char const *name,
char const *value,
2939 struct kmp_place_t {
2945 const char *scan = value;
2946 const char *next = scan;
2947 const char *kind =
"\"threads\"";
2948 kmp_place_t std_places[] = {{
"threads", KMP_HW_THREAD},
2949 {
"cores", KMP_HW_CORE},
2950 {
"numa_domains", KMP_HW_NUMA},
2951 {
"ll_caches", KMP_HW_LLC},
2952 {
"sockets", KMP_HW_SOCKET}};
2953 kmp_setting_t **rivals = (kmp_setting_t **)data;
2956 rc = __kmp_stg_check_rivals(name, value, rivals);
2962 for (
size_t i = 0; i <
sizeof(std_places) /
sizeof(std_places[0]); ++i) {
2963 const kmp_place_t &place = std_places[i];
2964 if (__kmp_match_str(place.name, scan, &next)) {
2966 __kmp_affinity_type = affinity_compact;
2967 __kmp_affinity_gran = place.type;
2968 __kmp_affinity_dups = FALSE;
2975 KMP_FOREACH_HW_TYPE(type) {
2976 const char *name = __kmp_hw_get_keyword(type,
true);
2977 if (__kmp_match_str(
"unknowns", scan, &next))
2979 if (__kmp_match_str(name, scan, &next)) {
2981 __kmp_affinity_type = affinity_compact;
2982 __kmp_affinity_gran = type;
2983 __kmp_affinity_dups = FALSE;
2990 if (__kmp_affinity_proclist != NULL) {
2991 KMP_INTERNAL_FREE((
void *)__kmp_affinity_proclist);
2992 __kmp_affinity_proclist = NULL;
2994 if (__kmp_parse_place_list(name, value, &__kmp_affinity_proclist)) {
2995 __kmp_affinity_type = affinity_explicit;
2996 __kmp_affinity_gran = KMP_HW_THREAD;
2997 __kmp_affinity_dups = FALSE;
3000 __kmp_affinity_type = affinity_compact;
3001 __kmp_affinity_gran = KMP_HW_CORE;
3002 __kmp_affinity_dups = FALSE;
3004 if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_default) {
3005 __kmp_nested_proc_bind.bind_types[0] = proc_bind_true;
3009 if (__kmp_affinity_gran != KMP_HW_UNKNOWN) {
3010 kind = __kmp_hw_get_keyword(__kmp_affinity_gran);
3013 if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_default) {
3014 __kmp_nested_proc_bind.bind_types[0] = proc_bind_true;
3018 if (*scan ==
'\0') {
3024 KMP_WARNING(SyntaxErrorUsing, name, kind);
3032 count = __kmp_str_to_int(scan, *next);
3033 KMP_ASSERT(count >= 0);
3038 KMP_WARNING(SyntaxErrorUsing, name, kind);
3044 if (*scan !=
'\0') {
3045 KMP_WARNING(ParseExtraCharsWarn, name, scan);
3047 __kmp_affinity_num_places = count;
3050static void __kmp_stg_print_places(kmp_str_buf_t *buffer,
char const *name,
3052 if (__kmp_env_format) {
3053 KMP_STR_BUF_PRINT_NAME;
3055 __kmp_str_buf_print(buffer,
" %s", name);
3057 if ((__kmp_nested_proc_bind.used == 0) ||
3058 (__kmp_nested_proc_bind.bind_types == NULL) ||
3059 (__kmp_nested_proc_bind.bind_types[0] == proc_bind_false)) {
3060 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
3061 }
else if (__kmp_affinity_type == affinity_explicit) {
3062 if (__kmp_affinity_proclist != NULL) {
3063 __kmp_str_buf_print(buffer,
"='%s'\n", __kmp_affinity_proclist);
3065 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
3067 }
else if (__kmp_affinity_type == affinity_compact) {
3069 if (__kmp_affinity_num_masks > 0) {
3070 num = __kmp_affinity_num_masks;
3071 }
else if (__kmp_affinity_num_places > 0) {
3072 num = __kmp_affinity_num_places;
3076 if (__kmp_affinity_gran != KMP_HW_UNKNOWN) {
3077 const char *name = __kmp_hw_get_keyword(__kmp_affinity_gran,
true);
3079 __kmp_str_buf_print(buffer,
"='%s(%d)'\n", name, num);
3081 __kmp_str_buf_print(buffer,
"='%s'\n", name);
3084 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
3087 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
3091static void __kmp_stg_parse_topology_method(
char const *name,
char const *value,
3093 if (__kmp_str_match(
"all", 1, value)) {
3094 __kmp_affinity_top_method = affinity_top_method_all;
3097 else if (__kmp_str_match(
"hwloc", 1, value)) {
3098 __kmp_affinity_top_method = affinity_top_method_hwloc;
3101#if KMP_ARCH_X86 || KMP_ARCH_X86_64
3102 else if (__kmp_str_match(
"cpuid_leaf31", 12, value) ||
3103 __kmp_str_match(
"cpuid 1f", 8, value) ||
3104 __kmp_str_match(
"cpuid 31", 8, value) ||
3105 __kmp_str_match(
"cpuid1f", 7, value) ||
3106 __kmp_str_match(
"cpuid31", 7, value) ||
3107 __kmp_str_match(
"leaf 1f", 7, value) ||
3108 __kmp_str_match(
"leaf 31", 7, value) ||
3109 __kmp_str_match(
"leaf1f", 6, value) ||
3110 __kmp_str_match(
"leaf31", 6, value)) {
3111 __kmp_affinity_top_method = affinity_top_method_x2apicid_1f;
3112 }
else if (__kmp_str_match(
"x2apic id", 9, value) ||
3113 __kmp_str_match(
"x2apic_id", 9, value) ||
3114 __kmp_str_match(
"x2apic-id", 9, value) ||
3115 __kmp_str_match(
"x2apicid", 8, value) ||
3116 __kmp_str_match(
"cpuid leaf 11", 13, value) ||
3117 __kmp_str_match(
"cpuid_leaf_11", 13, value) ||
3118 __kmp_str_match(
"cpuid-leaf-11", 13, value) ||
3119 __kmp_str_match(
"cpuid leaf11", 12, value) ||
3120 __kmp_str_match(
"cpuid_leaf11", 12, value) ||
3121 __kmp_str_match(
"cpuid-leaf11", 12, value) ||
3122 __kmp_str_match(
"cpuidleaf 11", 12, value) ||
3123 __kmp_str_match(
"cpuidleaf_11", 12, value) ||
3124 __kmp_str_match(
"cpuidleaf-11", 12, value) ||
3125 __kmp_str_match(
"cpuidleaf11", 11, value) ||
3126 __kmp_str_match(
"cpuid 11", 8, value) ||
3127 __kmp_str_match(
"cpuid_11", 8, value) ||
3128 __kmp_str_match(
"cpuid-11", 8, value) ||
3129 __kmp_str_match(
"cpuid11", 7, value) ||
3130 __kmp_str_match(
"leaf 11", 7, value) ||
3131 __kmp_str_match(
"leaf_11", 7, value) ||
3132 __kmp_str_match(
"leaf-11", 7, value) ||
3133 __kmp_str_match(
"leaf11", 6, value)) {
3134 __kmp_affinity_top_method = affinity_top_method_x2apicid;
3135 }
else if (__kmp_str_match(
"apic id", 7, value) ||
3136 __kmp_str_match(
"apic_id", 7, value) ||
3137 __kmp_str_match(
"apic-id", 7, value) ||
3138 __kmp_str_match(
"apicid", 6, value) ||
3139 __kmp_str_match(
"cpuid leaf 4", 12, value) ||
3140 __kmp_str_match(
"cpuid_leaf_4", 12, value) ||
3141 __kmp_str_match(
"cpuid-leaf-4", 12, value) ||
3142 __kmp_str_match(
"cpuid leaf4", 11, value) ||
3143 __kmp_str_match(
"cpuid_leaf4", 11, value) ||
3144 __kmp_str_match(
"cpuid-leaf4", 11, value) ||
3145 __kmp_str_match(
"cpuidleaf 4", 11, value) ||
3146 __kmp_str_match(
"cpuidleaf_4", 11, value) ||
3147 __kmp_str_match(
"cpuidleaf-4", 11, value) ||
3148 __kmp_str_match(
"cpuidleaf4", 10, value) ||
3149 __kmp_str_match(
"cpuid 4", 7, value) ||
3150 __kmp_str_match(
"cpuid_4", 7, value) ||
3151 __kmp_str_match(
"cpuid-4", 7, value) ||
3152 __kmp_str_match(
"cpuid4", 6, value) ||
3153 __kmp_str_match(
"leaf 4", 6, value) ||
3154 __kmp_str_match(
"leaf_4", 6, value) ||
3155 __kmp_str_match(
"leaf-4", 6, value) ||
3156 __kmp_str_match(
"leaf4", 5, value)) {
3157 __kmp_affinity_top_method = affinity_top_method_apicid;
3160 else if (__kmp_str_match(
"/proc/cpuinfo", 2, value) ||
3161 __kmp_str_match(
"cpuinfo", 5, value)) {
3162 __kmp_affinity_top_method = affinity_top_method_cpuinfo;
3164#if KMP_GROUP_AFFINITY
3165 else if (__kmp_str_match(
"group", 1, value)) {
3166 KMP_WARNING(StgDeprecatedValue, name, value,
"all");
3167 __kmp_affinity_top_method = affinity_top_method_group;
3170 else if (__kmp_str_match(
"flat", 1, value)) {
3171 __kmp_affinity_top_method = affinity_top_method_flat;
3173 KMP_WARNING(StgInvalidValue, name, value);
3177static void __kmp_stg_print_topology_method(kmp_str_buf_t *buffer,
3178 char const *name,
void *data) {
3179 char const *value = NULL;
3181 switch (__kmp_affinity_top_method) {
3182 case affinity_top_method_default:
3186 case affinity_top_method_all:
3190#if KMP_ARCH_X86 || KMP_ARCH_X86_64
3191 case affinity_top_method_x2apicid_1f:
3192 value =
"x2APIC id leaf 0x1f";
3195 case affinity_top_method_x2apicid:
3196 value =
"x2APIC id leaf 0xb";
3199 case affinity_top_method_apicid:
3205 case affinity_top_method_hwloc:
3210 case affinity_top_method_cpuinfo:
3214#if KMP_GROUP_AFFINITY
3215 case affinity_top_method_group:
3220 case affinity_top_method_flat:
3225 if (value != NULL) {
3226 __kmp_stg_print_str(buffer, name, value);
3231struct kmp_proc_bind_info_t {
3233 kmp_proc_bind_t proc_bind;
3235static kmp_proc_bind_info_t proc_bind_table[] = {
3236 {
"spread", proc_bind_spread},
3237 {
"true", proc_bind_spread},
3238 {
"close", proc_bind_close},
3240 {
"false", proc_bind_primary},
3241 {
"primary", proc_bind_primary}};
3242static void __kmp_stg_parse_teams_proc_bind(
char const *name,
char const *value,
3247 for (
size_t i = 0; i <
sizeof(proc_bind_table) /
sizeof(proc_bind_table[0]);
3249 if (__kmp_match_str(proc_bind_table[i].name, value, &end)) {
3250 __kmp_teams_proc_bind = proc_bind_table[i].proc_bind;
3256 KMP_WARNING(StgInvalidValue, name, value);
3259static void __kmp_stg_print_teams_proc_bind(kmp_str_buf_t *buffer,
3260 char const *name,
void *data) {
3261 const char *value = KMP_I18N_STR(NotDefined);
3262 for (
size_t i = 0; i <
sizeof(proc_bind_table) /
sizeof(proc_bind_table[0]);
3264 if (__kmp_teams_proc_bind == proc_bind_table[i].proc_bind) {
3265 value = proc_bind_table[i].name;
3269 __kmp_stg_print_str(buffer, name, value);
3275static void __kmp_stg_parse_proc_bind(
char const *name,
char const *value,
3277 kmp_setting_t **rivals = (kmp_setting_t **)data;
3280 rc = __kmp_stg_check_rivals(name, value, rivals);
3286 KMP_DEBUG_ASSERT((__kmp_nested_proc_bind.bind_types != NULL) &&
3287 (__kmp_nested_proc_bind.used > 0));
3289 const char *buf = value;
3293 if ((*buf >=
'0') && (*buf <=
'9')) {
3296 num = __kmp_str_to_int(buf, *next);
3297 KMP_ASSERT(num >= 0);
3305 if (__kmp_match_str(
"disabled", buf, &next)) {
3308#if KMP_AFFINITY_SUPPORTED
3309 __kmp_affinity_type = affinity_disabled;
3311 __kmp_nested_proc_bind.used = 1;
3312 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
3313 }
else if ((num == (
int)proc_bind_false) ||
3314 __kmp_match_str(
"false", buf, &next)) {
3317#if KMP_AFFINITY_SUPPORTED
3318 __kmp_affinity_type = affinity_none;
3320 __kmp_nested_proc_bind.used = 1;
3321 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
3322 }
else if ((num == (
int)proc_bind_true) ||
3323 __kmp_match_str(
"true", buf, &next)) {
3326 __kmp_nested_proc_bind.used = 1;
3327 __kmp_nested_proc_bind.bind_types[0] = proc_bind_true;
3332 for (scan = buf; *scan !=
'\0'; scan++) {
3339 if (__kmp_nested_proc_bind.size < nelem) {
3340 __kmp_nested_proc_bind.bind_types =
3341 (kmp_proc_bind_t *)KMP_INTERNAL_REALLOC(
3342 __kmp_nested_proc_bind.bind_types,
3343 sizeof(kmp_proc_bind_t) * nelem);
3344 if (__kmp_nested_proc_bind.bind_types == NULL) {
3345 KMP_FATAL(MemoryAllocFailed);
3347 __kmp_nested_proc_bind.size = nelem;
3349 __kmp_nested_proc_bind.used = nelem;
3351 if (nelem > 1 && !__kmp_dflt_max_active_levels_set)
3352 __kmp_dflt_max_active_levels = KMP_MAX_ACTIVE_LEVELS_LIMIT;
3357 enum kmp_proc_bind_t bind;
3359 if ((num == (
int)proc_bind_primary) ||
3360 __kmp_match_str(
"master", buf, &next) ||
3361 __kmp_match_str(
"primary", buf, &next)) {
3364 bind = proc_bind_primary;
3365 }
else if ((num == (
int)proc_bind_close) ||
3366 __kmp_match_str(
"close", buf, &next)) {
3369 bind = proc_bind_close;
3370 }
else if ((num == (
int)proc_bind_spread) ||
3371 __kmp_match_str(
"spread", buf, &next)) {
3374 bind = proc_bind_spread;
3376 KMP_WARNING(StgInvalidValue, name, value);
3377 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
3378 __kmp_nested_proc_bind.used = 1;
3382 __kmp_nested_proc_bind.bind_types[i++] = bind;
3386 KMP_DEBUG_ASSERT(*buf ==
',');
3391 if ((*buf >=
'0') && (*buf <=
'9')) {
3394 num = __kmp_str_to_int(buf, *next);
3395 KMP_ASSERT(num >= 0);
3405 KMP_WARNING(ParseExtraCharsWarn, name, buf);
3409static void __kmp_stg_print_proc_bind(kmp_str_buf_t *buffer,
char const *name,
3411 int nelem = __kmp_nested_proc_bind.used;
3412 if (__kmp_env_format) {
3413 KMP_STR_BUF_PRINT_NAME;
3415 __kmp_str_buf_print(buffer,
" %s", name);
3418 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
3421 __kmp_str_buf_print(buffer,
"='", name);
3422 for (i = 0; i < nelem; i++) {
3423 switch (__kmp_nested_proc_bind.bind_types[i]) {
3424 case proc_bind_false:
3425 __kmp_str_buf_print(buffer,
"false");
3428 case proc_bind_true:
3429 __kmp_str_buf_print(buffer,
"true");
3432 case proc_bind_primary:
3433 __kmp_str_buf_print(buffer,
"primary");
3436 case proc_bind_close:
3437 __kmp_str_buf_print(buffer,
"close");
3440 case proc_bind_spread:
3441 __kmp_str_buf_print(buffer,
"spread");
3444 case proc_bind_intel:
3445 __kmp_str_buf_print(buffer,
"intel");
3448 case proc_bind_default:
3449 __kmp_str_buf_print(buffer,
"default");
3452 if (i < nelem - 1) {
3453 __kmp_str_buf_print(buffer,
",");
3456 __kmp_str_buf_print(buffer,
"'\n");
3460static void __kmp_stg_parse_display_affinity(
char const *name,
3461 char const *value,
void *data) {
3462 __kmp_stg_parse_bool(name, value, &__kmp_display_affinity);
3464static void __kmp_stg_print_display_affinity(kmp_str_buf_t *buffer,
3465 char const *name,
void *data) {
3466 __kmp_stg_print_bool(buffer, name, __kmp_display_affinity);
3468static void __kmp_stg_parse_affinity_format(
char const *name,
char const *value,
3470 size_t length = KMP_STRLEN(value);
3471 __kmp_strncpy_truncate(__kmp_affinity_format, KMP_AFFINITY_FORMAT_SIZE, value,
3474static void __kmp_stg_print_affinity_format(kmp_str_buf_t *buffer,
3475 char const *name,
void *data) {
3476 if (__kmp_env_format) {
3477 KMP_STR_BUF_PRINT_NAME_EX(name);
3479 __kmp_str_buf_print(buffer,
" %s='", name);
3481 __kmp_str_buf_print(buffer,
"%s'\n", __kmp_affinity_format);
3503static void __kmp_stg_parse_allocator(
char const *name,
char const *value,
3505 const char *buf = value;
3506 const char *next, *scan, *start;
3508 omp_allocator_handle_t al;
3509 omp_memspace_handle_t ms = omp_default_mem_space;
3510 bool is_memspace =
false;
3511 int ntraits = 0, count = 0;
3515 const char *delim = strchr(buf,
':');
3516 const char *predef_mem_space = strstr(buf,
"mem_space");
3518 bool is_memalloc = (!predef_mem_space && !delim) ?
true : false;
3523 for (scan = buf; *scan !=
'\0'; scan++) {
3528 omp_alloctrait_t *traits =
3529 (omp_alloctrait_t *)KMP_ALLOCA(ntraits *
sizeof(omp_alloctrait_t));
3532#define IS_POWER_OF_TWO(n) (((n) & ((n)-1)) == 0)
3534#define GET_NEXT(sentinel) \
3537 if (*next == sentinel) \
3543#define SKIP_PAIR(key) \
3545 char const str_delimiter[] = {',', 0}; \
3546 char *value = __kmp_str_token(CCAST(char *, scan), str_delimiter, \
3547 CCAST(char **, &next)); \
3548 KMP_WARNING(StgInvalidValue, key, value); \
3556 char const str_delimiter[] = {'=', 0}; \
3557 key = __kmp_str_token(CCAST(char *, start), str_delimiter, \
3558 CCAST(char **, &next)); \
3563 while (*next !=
'\0') {
3565 __kmp_match_str(
"fb_data", scan, &next)) {
3569 if (__kmp_match_str(
"omp_high_bw_mem_alloc", scan, &next)) {
3572 if (__kmp_memkind_available) {
3573 __kmp_def_allocator = omp_high_bw_mem_alloc;
3576 KMP_WARNING(OmpNoAllocator,
"omp_high_bw_mem_alloc");
3579 traits[count].key = omp_atk_fb_data;
3580 traits[count].value = RCAST(omp_uintptr_t, omp_high_bw_mem_alloc);
3582 }
else if (__kmp_match_str(
"omp_large_cap_mem_alloc", scan, &next)) {
3585 if (__kmp_memkind_available) {
3586 __kmp_def_allocator = omp_large_cap_mem_alloc;
3589 KMP_WARNING(OmpNoAllocator,
"omp_large_cap_mem_alloc");
3592 traits[count].key = omp_atk_fb_data;
3593 traits[count].value = RCAST(omp_uintptr_t, omp_large_cap_mem_alloc);
3595 }
else if (__kmp_match_str(
"omp_default_mem_alloc", scan, &next)) {
3599 traits[count].key = omp_atk_fb_data;
3600 traits[count].value = RCAST(omp_uintptr_t, omp_default_mem_alloc);
3602 }
else if (__kmp_match_str(
"omp_const_mem_alloc", scan, &next)) {
3605 KMP_WARNING(OmpNoAllocator,
"omp_const_mem_alloc");
3607 traits[count].key = omp_atk_fb_data;
3608 traits[count].value = RCAST(omp_uintptr_t, omp_const_mem_alloc);
3610 }
else if (__kmp_match_str(
"omp_low_lat_mem_alloc", scan, &next)) {
3613 KMP_WARNING(OmpNoAllocator,
"omp_low_lat_mem_alloc");
3615 traits[count].key = omp_atk_fb_data;
3616 traits[count].value = RCAST(omp_uintptr_t, omp_low_lat_mem_alloc);
3618 }
else if (__kmp_match_str(
"omp_cgroup_mem_alloc", scan, &next)) {
3621 KMP_WARNING(OmpNoAllocator,
"omp_cgroup_mem_alloc");
3623 traits[count].key = omp_atk_fb_data;
3624 traits[count].value = RCAST(omp_uintptr_t, omp_cgroup_mem_alloc);
3626 }
else if (__kmp_match_str(
"omp_pteam_mem_alloc", scan, &next)) {
3629 KMP_WARNING(OmpNoAllocator,
"omp_pteam_mem_alloc");
3631 traits[count].key = omp_atk_fb_data;
3632 traits[count].value = RCAST(omp_uintptr_t, omp_pteam_mem_alloc);
3634 }
else if (__kmp_match_str(
"omp_thread_mem_alloc", scan, &next)) {
3637 KMP_WARNING(OmpNoAllocator,
"omp_thread_mem_alloc");
3639 traits[count].key = omp_atk_fb_data;
3640 traits[count].value = RCAST(omp_uintptr_t, omp_thread_mem_alloc);
3650 __kmp_def_allocator = omp_default_mem_alloc;
3651 if (next == buf || *next !=
'\0') {
3653 KMP_WARNING(StgInvalidValue, name, value);
3658 if (count == ntraits)
3664 if (__kmp_match_str(
"omp_default_mem_space", scan, &next)) {
3666 ms = omp_default_mem_space;
3667 }
else if (__kmp_match_str(
"omp_large_cap_mem_space", scan, &next)) {
3669 ms = omp_large_cap_mem_space;
3670 }
else if (__kmp_match_str(
"omp_const_mem_space", scan, &next)) {
3672 ms = omp_const_mem_space;
3673 }
else if (__kmp_match_str(
"omp_high_bw_mem_space", scan, &next)) {
3675 ms = omp_high_bw_mem_space;
3676 }
else if (__kmp_match_str(
"omp_low_lat_mem_space", scan, &next)) {
3678 ms = omp_low_lat_mem_space;
3680 __kmp_def_allocator = omp_default_mem_alloc;
3681 if (next == buf || *next !=
'\0') {
3683 KMP_WARNING(StgInvalidValue, name, value);
3692 if (__kmp_match_str(
"sync_hint", scan, &next)) {
3694 traits[count].key = omp_atk_sync_hint;
3695 if (__kmp_match_str(
"contended", scan, &next)) {
3696 traits[count].value = omp_atv_contended;
3697 }
else if (__kmp_match_str(
"uncontended", scan, &next)) {
3698 traits[count].value = omp_atv_uncontended;
3699 }
else if (__kmp_match_str(
"serialized", scan, &next)) {
3700 traits[count].value = omp_atv_serialized;
3701 }
else if (__kmp_match_str(
"private", scan, &next)) {
3702 traits[count].value = omp_atv_private;
3708 }
else if (__kmp_match_str(
"alignment", scan, &next)) {
3710 if (!isdigit(*next)) {
3716 int n = __kmp_str_to_int(scan,
',');
3717 if (n < 0 || !IS_POWER_OF_TWO(n)) {
3722 traits[count].key = omp_atk_alignment;
3723 traits[count].value = n;
3724 }
else if (__kmp_match_str(
"access", scan, &next)) {
3726 traits[count].key = omp_atk_access;
3727 if (__kmp_match_str(
"all", scan, &next)) {
3728 traits[count].value = omp_atv_all;
3729 }
else if (__kmp_match_str(
"cgroup", scan, &next)) {
3730 traits[count].value = omp_atv_cgroup;
3731 }
else if (__kmp_match_str(
"pteam", scan, &next)) {
3732 traits[count].value = omp_atv_pteam;
3733 }
else if (__kmp_match_str(
"thread", scan, &next)) {
3734 traits[count].value = omp_atv_thread;
3740 }
else if (__kmp_match_str(
"pool_size", scan, &next)) {
3742 if (!isdigit(*next)) {
3748 int n = __kmp_str_to_int(scan,
',');
3754 traits[count].key = omp_atk_pool_size;
3755 traits[count].value = n;
3756 }
else if (__kmp_match_str(
"fallback", scan, &next)) {
3758 traits[count].key = omp_atk_fallback;
3759 if (__kmp_match_str(
"default_mem_fb", scan, &next)) {
3760 traits[count].value = omp_atv_default_mem_fb;
3761 }
else if (__kmp_match_str(
"null_fb", scan, &next)) {
3762 traits[count].value = omp_atv_null_fb;
3763 }
else if (__kmp_match_str(
"abort_fb", scan, &next)) {
3764 traits[count].value = omp_atv_abort_fb;
3765 }
else if (__kmp_match_str(
"allocator_fb", scan, &next)) {
3766 traits[count].value = omp_atv_allocator_fb;
3772 }
else if (__kmp_match_str(
"pinned", scan, &next)) {
3774 traits[count].key = omp_atk_pinned;
3775 if (__kmp_str_match_true(next)) {
3776 traits[count].value = omp_atv_true;
3777 }
else if (__kmp_str_match_false(next)) {
3778 traits[count].value = omp_atv_false;
3784 }
else if (__kmp_match_str(
"partition", scan, &next)) {
3786 traits[count].key = omp_atk_partition;
3787 if (__kmp_match_str(
"environment", scan, &next)) {
3788 traits[count].value = omp_atv_environment;
3789 }
else if (__kmp_match_str(
"nearest", scan, &next)) {
3790 traits[count].value = omp_atv_nearest;
3791 }
else if (__kmp_match_str(
"blocked", scan, &next)) {
3792 traits[count].value = omp_atv_blocked;
3793 }
else if (__kmp_match_str(
"interleaved", scan, &next)) {
3794 traits[count].value = omp_atv_interleaved;
3807 if (count == ntraits)
3813 al = __kmpc_init_allocator(__kmp_get_gtid(), ms, ntraits, traits);
3814 __kmp_def_allocator = (al == omp_null_allocator) ? omp_default_mem_alloc : al;
3817static void __kmp_stg_print_allocator(kmp_str_buf_t *buffer,
char const *name,
3819 if (__kmp_def_allocator == omp_default_mem_alloc) {
3820 __kmp_stg_print_str(buffer, name,
"omp_default_mem_alloc");
3821 }
else if (__kmp_def_allocator == omp_high_bw_mem_alloc) {
3822 __kmp_stg_print_str(buffer, name,
"omp_high_bw_mem_alloc");
3823 }
else if (__kmp_def_allocator == omp_large_cap_mem_alloc) {
3824 __kmp_stg_print_str(buffer, name,
"omp_large_cap_mem_alloc");
3825 }
else if (__kmp_def_allocator == omp_const_mem_alloc) {
3826 __kmp_stg_print_str(buffer, name,
"omp_const_mem_alloc");
3827 }
else if (__kmp_def_allocator == omp_low_lat_mem_alloc) {
3828 __kmp_stg_print_str(buffer, name,
"omp_low_lat_mem_alloc");
3829 }
else if (__kmp_def_allocator == omp_cgroup_mem_alloc) {
3830 __kmp_stg_print_str(buffer, name,
"omp_cgroup_mem_alloc");
3831 }
else if (__kmp_def_allocator == omp_pteam_mem_alloc) {
3832 __kmp_stg_print_str(buffer, name,
"omp_pteam_mem_alloc");
3833 }
else if (__kmp_def_allocator == omp_thread_mem_alloc) {
3834 __kmp_stg_print_str(buffer, name,
"omp_thread_mem_alloc");
3841static void __kmp_stg_parse_omp_dynamic(
char const *name,
char const *value,
3843 __kmp_stg_parse_bool(name, value, &(__kmp_global.g.g_dynamic));
3846static void __kmp_stg_print_omp_dynamic(kmp_str_buf_t *buffer,
char const *name,
3848 __kmp_stg_print_bool(buffer, name, __kmp_global.g.g_dynamic);
3851static void __kmp_stg_parse_kmp_dynamic_mode(
char const *name,
3852 char const *value,
void *data) {
3853 if (TCR_4(__kmp_init_parallel)) {
3854 KMP_WARNING(EnvParallelWarn, name);
3855 __kmp_env_toPrint(name, 0);
3858#ifdef USE_LOAD_BALANCE
3859 else if (__kmp_str_match(
"load balance", 2, value) ||
3860 __kmp_str_match(
"load_balance", 2, value) ||
3861 __kmp_str_match(
"load-balance", 2, value) ||
3862 __kmp_str_match(
"loadbalance", 2, value) ||
3863 __kmp_str_match(
"balance", 1, value)) {
3864 __kmp_global.g.g_dynamic_mode = dynamic_load_balance;
3867 else if (__kmp_str_match(
"thread limit", 1, value) ||
3868 __kmp_str_match(
"thread_limit", 1, value) ||
3869 __kmp_str_match(
"thread-limit", 1, value) ||
3870 __kmp_str_match(
"threadlimit", 1, value) ||
3871 __kmp_str_match(
"limit", 2, value)) {
3872 __kmp_global.g.g_dynamic_mode = dynamic_thread_limit;
3873 }
else if (__kmp_str_match(
"random", 1, value)) {
3874 __kmp_global.g.g_dynamic_mode = dynamic_random;
3876 KMP_WARNING(StgInvalidValue, name, value);
3880static void __kmp_stg_print_kmp_dynamic_mode(kmp_str_buf_t *buffer,
3881 char const *name,
void *data) {
3883 if (__kmp_global.g.g_dynamic_mode == dynamic_default) {
3884 __kmp_str_buf_print(buffer,
" %s: %s \n", name, KMP_I18N_STR(NotDefined));
3886#ifdef USE_LOAD_BALANCE
3887 else if (__kmp_global.g.g_dynamic_mode == dynamic_load_balance) {
3888 __kmp_stg_print_str(buffer, name,
"load balance");
3891 else if (__kmp_global.g.g_dynamic_mode == dynamic_thread_limit) {
3892 __kmp_stg_print_str(buffer, name,
"thread limit");
3893 }
else if (__kmp_global.g.g_dynamic_mode == dynamic_random) {
3894 __kmp_stg_print_str(buffer, name,
"random");
3901#ifdef USE_LOAD_BALANCE
3906static void __kmp_stg_parse_ld_balance_interval(
char const *name,
3907 char const *value,
void *data) {
3908 double interval = __kmp_convert_to_double(value);
3909 if (interval >= 0) {
3910 __kmp_load_balance_interval = interval;
3912 KMP_WARNING(StgInvalidValue, name, value);
3916static void __kmp_stg_print_ld_balance_interval(kmp_str_buf_t *buffer,
3917 char const *name,
void *data) {
3919 __kmp_str_buf_print(buffer,
" %s=%8.6f\n", name,
3920 __kmp_load_balance_interval);
3929static void __kmp_stg_parse_init_at_fork(
char const *name,
char const *value,
3931 __kmp_stg_parse_bool(name, value, &__kmp_need_register_atfork);
3932 if (__kmp_need_register_atfork) {
3933 __kmp_need_register_atfork_specified = TRUE;
3937static void __kmp_stg_print_init_at_fork(kmp_str_buf_t *buffer,
3938 char const *name,
void *data) {
3939 __kmp_stg_print_bool(buffer, name, __kmp_need_register_atfork_specified);
3945static void __kmp_stg_parse_schedule(
char const *name,
char const *value,
3948 if (value != NULL) {
3949 size_t length = KMP_STRLEN(value);
3950 if (length > INT_MAX) {
3951 KMP_WARNING(LongValue, name);
3953 const char *semicolon;
3954 if (value[length - 1] ==
'"' || value[length - 1] ==
'\'')
3955 KMP_WARNING(UnbalancedQuotes, name);
3959 semicolon = strchr(value,
';');
3960 if (*value && semicolon != value) {
3961 const char *comma = strchr(value,
',');
3968 if (!__kmp_strcasecmp_with_sentinel(
"static", value, sentinel)) {
3969 if (!__kmp_strcasecmp_with_sentinel(
"greedy", comma,
';')) {
3970 __kmp_static = kmp_sch_static_greedy;
3972 }
else if (!__kmp_strcasecmp_with_sentinel(
"balanced", comma,
3974 __kmp_static = kmp_sch_static_balanced;
3977 }
else if (!__kmp_strcasecmp_with_sentinel(
"guided", value,
3979 if (!__kmp_strcasecmp_with_sentinel(
"iterative", comma,
';')) {
3980 __kmp_guided = kmp_sch_guided_iterative_chunked;
3982 }
else if (!__kmp_strcasecmp_with_sentinel(
"analytical", comma,
3985 __kmp_guided = kmp_sch_guided_analytical_chunked;
3989 KMP_WARNING(InvalidClause, name, value);
3991 KMP_WARNING(EmptyClause, name);
3992 }
while ((value = semicolon ? semicolon + 1 : NULL));
3998static void __kmp_stg_print_schedule(kmp_str_buf_t *buffer,
char const *name,
4000 if (__kmp_env_format) {
4001 KMP_STR_BUF_PRINT_NAME_EX(name);
4003 __kmp_str_buf_print(buffer,
" %s='", name);
4005 if (__kmp_static == kmp_sch_static_greedy) {
4006 __kmp_str_buf_print(buffer,
"%s",
"static,greedy");
4007 }
else if (__kmp_static == kmp_sch_static_balanced) {
4008 __kmp_str_buf_print(buffer,
"%s",
"static,balanced");
4010 if (__kmp_guided == kmp_sch_guided_iterative_chunked) {
4011 __kmp_str_buf_print(buffer,
";%s'\n",
"guided,iterative");
4012 }
else if (__kmp_guided == kmp_sch_guided_analytical_chunked) {
4013 __kmp_str_buf_print(buffer,
";%s'\n",
"guided,analytical");
4020static inline void __kmp_omp_schedule_restore() {
4021#if KMP_USE_HIER_SCHED
4022 __kmp_hier_scheds.deallocate();
4032static const char *__kmp_parse_single_omp_schedule(
const char *name,
4034 bool parse_hier =
false) {
4036 const char *ptr = value;
4043 while (*delim !=
',' && *delim !=
':' && *delim !=
'\0')
4045#if KMP_USE_HIER_SCHED
4046 kmp_hier_layer_e layer = kmp_hier_layer_e::LAYER_THREAD;
4048 if (*delim ==
',') {
4049 if (!__kmp_strcasecmp_with_sentinel(
"L1", ptr,
',')) {
4050 layer = kmp_hier_layer_e::LAYER_L1;
4051 }
else if (!__kmp_strcasecmp_with_sentinel(
"L2", ptr,
',')) {
4052 layer = kmp_hier_layer_e::LAYER_L2;
4053 }
else if (!__kmp_strcasecmp_with_sentinel(
"L3", ptr,
',')) {
4054 layer = kmp_hier_layer_e::LAYER_L3;
4055 }
else if (!__kmp_strcasecmp_with_sentinel(
"NUMA", ptr,
',')) {
4056 layer = kmp_hier_layer_e::LAYER_NUMA;
4059 if (layer != kmp_hier_layer_e::LAYER_THREAD && *delim !=
',') {
4061 KMP_WARNING(StgInvalidValue, name, value);
4062 __kmp_omp_schedule_restore();
4064 }
else if (layer != kmp_hier_layer_e::LAYER_THREAD) {
4066 while (*delim !=
',' && *delim !=
':' && *delim !=
'\0')
4073 if (*delim ==
':') {
4074 if (!__kmp_strcasecmp_with_sentinel(
"monotonic", ptr, *delim)) {
4077 while (*delim !=
',' && *delim !=
':' && *delim !=
'\0')
4079 }
else if (!__kmp_strcasecmp_with_sentinel(
"nonmonotonic", ptr, *delim)) {
4082 while (*delim !=
',' && *delim !=
':' && *delim !=
'\0')
4084 }
else if (!parse_hier) {
4086 KMP_WARNING(StgInvalidValue, name, value);
4087 __kmp_omp_schedule_restore();
4092 if (!__kmp_strcasecmp_with_sentinel(
"dynamic", ptr, *delim))
4093 sched = kmp_sch_dynamic_chunked;
4094 else if (!__kmp_strcasecmp_with_sentinel(
"guided", ptr, *delim))
4097 else if (!__kmp_strcasecmp_with_sentinel(
"auto", ptr, *delim))
4099 else if (!__kmp_strcasecmp_with_sentinel(
"trapezoidal", ptr, *delim))
4100 sched = kmp_sch_trapezoidal;
4101 else if (!__kmp_strcasecmp_with_sentinel(
"static", ptr, *delim))
4103#if KMP_STATIC_STEAL_ENABLED
4104 else if (!__kmp_strcasecmp_with_sentinel(
"static_steal", ptr, *delim)) {
4106 sched = kmp_sch_dynamic_chunked;
4112 KMP_WARNING(StgInvalidValue, name, value);
4113 __kmp_omp_schedule_restore();
4118 if (*delim ==
',') {
4121 if (!isdigit(*ptr)) {
4123 KMP_WARNING(StgInvalidValue, name, value);
4124 __kmp_omp_schedule_restore();
4130 __kmp_msg(kmp_ms_warning, KMP_MSG(IgnoreChunk, name, delim),
4134 sched = kmp_sch_static_chunked;
4135 chunk = __kmp_str_to_int(delim + 1, *ptr);
4137 chunk = KMP_DEFAULT_CHUNK;
4138 __kmp_msg(kmp_ms_warning, KMP_MSG(InvalidChunk, name, delim),
4140 KMP_INFORM(Using_int_Value, name, __kmp_chunk);
4149 }
else if (chunk > KMP_MAX_CHUNK) {
4150 chunk = KMP_MAX_CHUNK;
4151 __kmp_msg(kmp_ms_warning, KMP_MSG(LargeChunk, name, delim),
4153 KMP_INFORM(Using_int_Value, name, chunk);
4160 SCHEDULE_SET_MODIFIERS(sched, sched_modifier);
4162#if KMP_USE_HIER_SCHED
4163 if (layer != kmp_hier_layer_e::LAYER_THREAD) {
4164 __kmp_hier_scheds.append(sched, chunk, layer);
4168 __kmp_chunk = chunk;
4169 __kmp_sched = sched;
4174static void __kmp_stg_parse_omp_schedule(
char const *name,
char const *value,
4177 const char *ptr = value;
4180 length = KMP_STRLEN(value);
4182 if (value[length - 1] ==
'"' || value[length - 1] ==
'\'')
4183 KMP_WARNING(UnbalancedQuotes, name);
4185#if KMP_USE_HIER_SCHED
4186 if (!__kmp_strcasecmp_with_sentinel(
"EXPERIMENTAL", ptr,
' ')) {
4189 while ((ptr = __kmp_parse_single_omp_schedule(name, ptr,
true))) {
4190 while (*ptr ==
' ' || *ptr ==
'\t' || *ptr ==
':')
4197 __kmp_parse_single_omp_schedule(name, ptr);
4199 KMP_WARNING(EmptyString, name);
4201#if KMP_USE_HIER_SCHED
4202 __kmp_hier_scheds.sort();
4204 K_DIAG(1, (
"__kmp_static == %d\n", __kmp_static))
4205 K_DIAG(1, (
"__kmp_guided == %d\n", __kmp_guided))
4206 K_DIAG(1, (
"__kmp_sched == %d\n", __kmp_sched))
4207 K_DIAG(1, (
"__kmp_chunk == %d\n", __kmp_chunk))
4210static void __kmp_stg_print_omp_schedule(kmp_str_buf_t *buffer,
4211 char const *name,
void *data) {
4212 if (__kmp_env_format) {
4213 KMP_STR_BUF_PRINT_NAME_EX(name);
4215 __kmp_str_buf_print(buffer,
" %s='", name);
4217 enum sched_type sched = SCHEDULE_WITHOUT_MODIFIERS(__kmp_sched);
4218 if (SCHEDULE_HAS_MONOTONIC(__kmp_sched)) {
4219 __kmp_str_buf_print(buffer,
"monotonic:");
4220 }
else if (SCHEDULE_HAS_NONMONOTONIC(__kmp_sched)) {
4221 __kmp_str_buf_print(buffer,
"nonmonotonic:");
4225 case kmp_sch_dynamic_chunked:
4226 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"dynamic", __kmp_chunk);
4228 case kmp_sch_guided_iterative_chunked:
4229 case kmp_sch_guided_analytical_chunked:
4230 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"guided", __kmp_chunk);
4232 case kmp_sch_trapezoidal:
4233 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"trapezoidal", __kmp_chunk);
4236 case kmp_sch_static_chunked:
4237 case kmp_sch_static_balanced:
4238 case kmp_sch_static_greedy:
4239 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"static", __kmp_chunk);
4241 case kmp_sch_static_steal:
4242 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"static_steal", __kmp_chunk);
4245 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"auto", __kmp_chunk);
4250 case kmp_sch_dynamic_chunked:
4251 __kmp_str_buf_print(buffer,
"%s'\n",
"dynamic");
4253 case kmp_sch_guided_iterative_chunked:
4254 case kmp_sch_guided_analytical_chunked:
4255 __kmp_str_buf_print(buffer,
"%s'\n",
"guided");
4257 case kmp_sch_trapezoidal:
4258 __kmp_str_buf_print(buffer,
"%s'\n",
"trapezoidal");
4261 case kmp_sch_static_chunked:
4262 case kmp_sch_static_balanced:
4263 case kmp_sch_static_greedy:
4264 __kmp_str_buf_print(buffer,
"%s'\n",
"static");
4266 case kmp_sch_static_steal:
4267 __kmp_str_buf_print(buffer,
"%s'\n",
"static_steal");
4270 __kmp_str_buf_print(buffer,
"%s'\n",
"auto");
4276#if KMP_USE_HIER_SCHED
4279static void __kmp_stg_parse_kmp_hand_thread(
char const *name,
char const *value,
4281 __kmp_stg_parse_bool(name, value, &(__kmp_dispatch_hand_threading));
4284static void __kmp_stg_print_kmp_hand_thread(kmp_str_buf_t *buffer,
4285 char const *name,
void *data) {
4286 __kmp_stg_print_bool(buffer, name, __kmp_dispatch_hand_threading);
4292static void __kmp_stg_parse_kmp_force_monotonic(
char const *name,
4293 char const *value,
void *data) {
4294 __kmp_stg_parse_bool(name, value, &(__kmp_force_monotonic));
4297static void __kmp_stg_print_kmp_force_monotonic(kmp_str_buf_t *buffer,
4298 char const *name,
void *data) {
4299 __kmp_stg_print_bool(buffer, name, __kmp_force_monotonic);
4305static void __kmp_stg_parse_atomic_mode(
char const *name,
char const *value,
4311#ifdef KMP_GOMP_COMPAT
4314 __kmp_stg_parse_int(name, value, 0, max, &mode);
4319 __kmp_atomic_mode = mode;
4323static void __kmp_stg_print_atomic_mode(kmp_str_buf_t *buffer,
char const *name,
4325 __kmp_stg_print_int(buffer, name, __kmp_atomic_mode);
4331static void __kmp_stg_parse_consistency_check(
char const *name,
4332 char const *value,
void *data) {
4333 if (!__kmp_strcasecmp_with_sentinel(
"all", value, 0)) {
4339 __kmp_env_consistency_check = TRUE;
4340 }
else if (!__kmp_strcasecmp_with_sentinel(
"none", value, 0)) {
4341 __kmp_env_consistency_check = FALSE;
4343 KMP_WARNING(StgInvalidValue, name, value);
4347static void __kmp_stg_print_consistency_check(kmp_str_buf_t *buffer,
4348 char const *name,
void *data) {
4350 const char *value = NULL;
4352 if (__kmp_env_consistency_check) {
4358 if (value != NULL) {
4359 __kmp_stg_print_str(buffer, name, value);
4370static void __kmp_stg_parse_itt_prepare_delay(
char const *name,
4371 char const *value,
void *data) {
4375 __kmp_stg_parse_int(name, value, 0, INT_MAX, &delay);
4376 __kmp_itt_prepare_delay = delay;
4379static void __kmp_stg_print_itt_prepare_delay(kmp_str_buf_t *buffer,
4380 char const *name,
void *data) {
4381 __kmp_stg_print_uint64(buffer, name, __kmp_itt_prepare_delay);
4391static void __kmp_stg_parse_malloc_pool_incr(
char const *name,
4392 char const *value,
void *data) {
4393 __kmp_stg_parse_size(name, value, KMP_MIN_MALLOC_POOL_INCR,
4394 KMP_MAX_MALLOC_POOL_INCR, NULL, &__kmp_malloc_pool_incr,
4398static void __kmp_stg_print_malloc_pool_incr(kmp_str_buf_t *buffer,
4399 char const *name,
void *data) {
4400 __kmp_stg_print_size(buffer, name, __kmp_malloc_pool_incr);
4409static void __kmp_stg_parse_par_range_env(
char const *name,
char const *value,
4411 __kmp_stg_parse_par_range(name, value, &__kmp_par_range,
4412 __kmp_par_range_routine, __kmp_par_range_filename,
4413 &__kmp_par_range_lb, &__kmp_par_range_ub);
4416static void __kmp_stg_print_par_range_env(kmp_str_buf_t *buffer,
4417 char const *name,
void *data) {
4418 if (__kmp_par_range != 0) {
4419 __kmp_stg_print_str(buffer, name, par_range_to_print);
4428static void __kmp_stg_parse_gtid_mode(
char const *name,
char const *value,
4438#ifdef KMP_TDATA_GTID
4441 __kmp_stg_parse_int(name, value, 0, max, &mode);
4445 __kmp_adjust_gtid_mode = TRUE;
4447 __kmp_gtid_mode = mode;
4448 __kmp_adjust_gtid_mode = FALSE;
4452static void __kmp_stg_print_gtid_mode(kmp_str_buf_t *buffer,
char const *name,
4454 if (__kmp_adjust_gtid_mode) {
4455 __kmp_stg_print_int(buffer, name, 0);
4457 __kmp_stg_print_int(buffer, name, __kmp_gtid_mode);
4464static void __kmp_stg_parse_lock_block(
char const *name,
char const *value,
4466 __kmp_stg_parse_int(name, value, 0, KMP_INT_MAX, &__kmp_num_locks_in_block);
4469static void __kmp_stg_print_lock_block(kmp_str_buf_t *buffer,
char const *name,
4471 __kmp_stg_print_int(buffer, name, __kmp_num_locks_in_block);
4477#if KMP_USE_DYNAMIC_LOCK
4478#define KMP_STORE_LOCK_SEQ(a) (__kmp_user_lock_seq = lockseq_##a)
4480#define KMP_STORE_LOCK_SEQ(a)
4483static void __kmp_stg_parse_lock_kind(
char const *name,
char const *value,
4485 if (__kmp_init_user_locks) {
4486 KMP_WARNING(EnvLockWarn, name);
4490 if (__kmp_str_match(
"tas", 2, value) ||
4491 __kmp_str_match(
"test and set", 2, value) ||
4492 __kmp_str_match(
"test_and_set", 2, value) ||
4493 __kmp_str_match(
"test-and-set", 2, value) ||
4494 __kmp_str_match(
"test andset", 2, value) ||
4495 __kmp_str_match(
"test_andset", 2, value) ||
4496 __kmp_str_match(
"test-andset", 2, value) ||
4497 __kmp_str_match(
"testand set", 2, value) ||
4498 __kmp_str_match(
"testand_set", 2, value) ||
4499 __kmp_str_match(
"testand-set", 2, value) ||
4500 __kmp_str_match(
"testandset", 2, value)) {
4501 __kmp_user_lock_kind = lk_tas;
4502 KMP_STORE_LOCK_SEQ(tas);
4505 else if (__kmp_str_match(
"futex", 1, value)) {
4506 if (__kmp_futex_determine_capable()) {
4507 __kmp_user_lock_kind = lk_futex;
4508 KMP_STORE_LOCK_SEQ(futex);
4510 KMP_WARNING(FutexNotSupported, name, value);
4514 else if (__kmp_str_match(
"ticket", 2, value)) {
4515 __kmp_user_lock_kind = lk_ticket;
4516 KMP_STORE_LOCK_SEQ(ticket);
4517 }
else if (__kmp_str_match(
"queuing", 1, value) ||
4518 __kmp_str_match(
"queue", 1, value)) {
4519 __kmp_user_lock_kind = lk_queuing;
4520 KMP_STORE_LOCK_SEQ(queuing);
4521 }
else if (__kmp_str_match(
"drdpa ticket", 1, value) ||
4522 __kmp_str_match(
"drdpa_ticket", 1, value) ||
4523 __kmp_str_match(
"drdpa-ticket", 1, value) ||
4524 __kmp_str_match(
"drdpaticket", 1, value) ||
4525 __kmp_str_match(
"drdpa", 1, value)) {
4526 __kmp_user_lock_kind = lk_drdpa;
4527 KMP_STORE_LOCK_SEQ(drdpa);
4529#if KMP_USE_ADAPTIVE_LOCKS
4530 else if (__kmp_str_match(
"adaptive", 1, value)) {
4531 if (__kmp_cpuinfo.flags.rtm) {
4532 __kmp_user_lock_kind = lk_adaptive;
4533 KMP_STORE_LOCK_SEQ(adaptive);
4535 KMP_WARNING(AdaptiveNotSupported, name, value);
4536 __kmp_user_lock_kind = lk_queuing;
4537 KMP_STORE_LOCK_SEQ(queuing);
4541#if KMP_USE_DYNAMIC_LOCK && KMP_USE_TSX
4542 else if (__kmp_str_match(
"rtm_queuing", 1, value)) {
4543 if (__kmp_cpuinfo.flags.rtm) {
4544 __kmp_user_lock_kind = lk_rtm_queuing;
4545 KMP_STORE_LOCK_SEQ(rtm_queuing);
4547 KMP_WARNING(AdaptiveNotSupported, name, value);
4548 __kmp_user_lock_kind = lk_queuing;
4549 KMP_STORE_LOCK_SEQ(queuing);
4551 }
else if (__kmp_str_match(
"rtm_spin", 1, value)) {
4552 if (__kmp_cpuinfo.flags.rtm) {
4553 __kmp_user_lock_kind = lk_rtm_spin;
4554 KMP_STORE_LOCK_SEQ(rtm_spin);
4556 KMP_WARNING(AdaptiveNotSupported, name, value);
4557 __kmp_user_lock_kind = lk_tas;
4558 KMP_STORE_LOCK_SEQ(queuing);
4560 }
else if (__kmp_str_match(
"hle", 1, value)) {
4561 __kmp_user_lock_kind = lk_hle;
4562 KMP_STORE_LOCK_SEQ(hle);
4566 KMP_WARNING(StgInvalidValue, name, value);
4570static void __kmp_stg_print_lock_kind(kmp_str_buf_t *buffer,
char const *name,
4572 const char *value = NULL;
4574 switch (__kmp_user_lock_kind) {
4589#if KMP_USE_DYNAMIC_LOCK && KMP_USE_TSX
4590 case lk_rtm_queuing:
4591 value =
"rtm_queuing";
4614#if KMP_USE_ADAPTIVE_LOCKS
4621 if (value != NULL) {
4622 __kmp_stg_print_str(buffer, name, value);
4631static void __kmp_stg_parse_spin_backoff_params(
const char *name,
4632 const char *value,
void *data) {
4633 const char *next = value;
4636 int prev_comma = FALSE;
4639 kmp_uint32 max_backoff = __kmp_spin_backoff_params.max_backoff;
4640 kmp_uint32 min_tick = __kmp_spin_backoff_params.min_tick;
4644 for (i = 0; i < 3; i++) {
4647 if (*next ==
'\0') {
4652 if (((*next <
'0' || *next >
'9') && *next !=
',') || total > 2) {
4653 KMP_WARNING(EnvSyntaxError, name, value);
4659 if (total == 0 || prev_comma) {
4667 if (*next >=
'0' && *next <=
'9') {
4669 const char *buf = next;
4670 char const *msg = NULL;
4675 const char *tmp = next;
4677 if ((*next ==
' ' || *next ==
'\t') && (*tmp >=
'0' && *tmp <=
'9')) {
4678 KMP_WARNING(EnvSpacesNotAllowed, name, value);
4682 num = __kmp_str_to_int(buf, *next);
4684 msg = KMP_I18N_STR(ValueTooSmall);
4686 }
else if (num > KMP_INT_MAX) {
4687 msg = KMP_I18N_STR(ValueTooLarge);
4692 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
4693 KMP_INFORM(Using_int_Value, name, num);
4697 }
else if (total == 2) {
4702 KMP_DEBUG_ASSERT(total > 0);
4704 KMP_WARNING(EnvSyntaxError, name, value);
4707 __kmp_spin_backoff_params.max_backoff = max_backoff;
4708 __kmp_spin_backoff_params.min_tick = min_tick;
4711static void __kmp_stg_print_spin_backoff_params(kmp_str_buf_t *buffer,
4712 char const *name,
void *data) {
4713 if (__kmp_env_format) {
4714 KMP_STR_BUF_PRINT_NAME_EX(name);
4716 __kmp_str_buf_print(buffer,
" %s='", name);
4718 __kmp_str_buf_print(buffer,
"%d,%d'\n", __kmp_spin_backoff_params.max_backoff,
4719 __kmp_spin_backoff_params.min_tick);
4722#if KMP_USE_ADAPTIVE_LOCKS
4729static void __kmp_stg_parse_adaptive_lock_props(
const char *name,
4730 const char *value,
void *data) {
4731 int max_retries = 0;
4732 int max_badness = 0;
4734 const char *next = value;
4737 int prev_comma = FALSE;
4743 for (i = 0; i < 3; i++) {
4746 if (*next ==
'\0') {
4751 if (((*next <
'0' || *next >
'9') && *next !=
',') || total > 2) {
4752 KMP_WARNING(EnvSyntaxError, name, value);
4758 if (total == 0 || prev_comma) {
4766 if (*next >=
'0' && *next <=
'9') {
4768 const char *buf = next;
4769 char const *msg = NULL;
4774 const char *tmp = next;
4776 if ((*next ==
' ' || *next ==
'\t') && (*tmp >=
'0' && *tmp <=
'9')) {
4777 KMP_WARNING(EnvSpacesNotAllowed, name, value);
4781 num = __kmp_str_to_int(buf, *next);
4783 msg = KMP_I18N_STR(ValueTooSmall);
4785 }
else if (num > KMP_INT_MAX) {
4786 msg = KMP_I18N_STR(ValueTooLarge);
4791 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
4792 KMP_INFORM(Using_int_Value, name, num);
4796 }
else if (total == 2) {
4801 KMP_DEBUG_ASSERT(total > 0);
4803 KMP_WARNING(EnvSyntaxError, name, value);
4806 __kmp_adaptive_backoff_params.max_soft_retries = max_retries;
4807 __kmp_adaptive_backoff_params.max_badness = max_badness;
4810static void __kmp_stg_print_adaptive_lock_props(kmp_str_buf_t *buffer,
4811 char const *name,
void *data) {
4812 if (__kmp_env_format) {
4813 KMP_STR_BUF_PRINT_NAME_EX(name);
4815 __kmp_str_buf_print(buffer,
" %s='", name);
4817 __kmp_str_buf_print(buffer,
"%d,%d'\n",
4818 __kmp_adaptive_backoff_params.max_soft_retries,
4819 __kmp_adaptive_backoff_params.max_badness);
4822#if KMP_DEBUG_ADAPTIVE_LOCKS
4824static void __kmp_stg_parse_speculative_statsfile(
char const *name,
4827 __kmp_stg_parse_file(name, value,
"",
4828 CCAST(
char **, &__kmp_speculative_statsfile));
4831static void __kmp_stg_print_speculative_statsfile(kmp_str_buf_t *buffer,
4834 if (__kmp_str_match(
"-", 0, __kmp_speculative_statsfile)) {
4835 __kmp_stg_print_str(buffer, name,
"stdout");
4837 __kmp_stg_print_str(buffer, name, __kmp_speculative_statsfile);
4853static kmp_hw_t __kmp_hw_subset_break_tie(
const kmp_hw_t *possible,
4854 size_t num_possible) {
4855 for (
size_t i = 0; i < num_possible; ++i) {
4856 if (possible[i] == KMP_HW_THREAD)
4857 return KMP_HW_THREAD;
4858 else if (possible[i] == KMP_HW_CORE)
4860 else if (possible[i] == KMP_HW_SOCKET)
4861 return KMP_HW_SOCKET;
4863 return KMP_HW_UNKNOWN;
4870static kmp_hw_t __kmp_stg_parse_hw_subset_name(
char const *token) {
4871 size_t index, num_possible, token_length;
4872 kmp_hw_t possible[KMP_HW_LAST];
4878 while (isalnum(*end) || *end ==
'_') {
4885 KMP_FOREACH_HW_TYPE(type) { possible[num_possible++] = type; }
4892 while (num_possible > 1 && index < token_length) {
4893 size_t n = num_possible;
4894 char token_char = (char)toupper(token[index]);
4895 for (
size_t i = 0; i < n; ++i) {
4897 kmp_hw_t type = possible[i];
4898 s = __kmp_hw_get_keyword(type,
false);
4899 if (index < KMP_STRLEN(s)) {
4900 char c = (char)toupper(s[index]);
4902 if (c != token_char) {
4903 possible[i] = KMP_HW_UNKNOWN;
4910 for (
size_t i = 0; i < n; ++i) {
4911 if (possible[i] != KMP_HW_UNKNOWN) {
4912 kmp_hw_t temp = possible[i];
4913 possible[i] = possible[start];
4914 possible[start] = temp;
4918 KMP_ASSERT(start == num_possible);
4924 if (num_possible > 1)
4925 return __kmp_hw_subset_break_tie(possible, num_possible);
4926 if (num_possible == 1)
4928 return KMP_HW_UNKNOWN;
4933#define MAX_T_LEVEL KMP_HW_LAST
4934#define MAX_STR_LEN 512
4935static void __kmp_stg_parse_hw_subset(
char const *name,
char const *value,
4939 kmp_setting_t **rivals = (kmp_setting_t **)data;
4940 if (strcmp(name,
"KMP_PLACE_THREADS") == 0) {
4941 KMP_INFORM(EnvVarDeprecated, name,
"KMP_HW_SUBSET");
4943 if (__kmp_stg_check_rivals(name, value, rivals)) {
4947 char *components[MAX_T_LEVEL];
4948 char const *digits =
"0123456789";
4949 char input[MAX_STR_LEN];
4950 size_t len = 0, mlen = MAX_STR_LEN;
4952 bool absolute =
false;
4954 char *pos = CCAST(
char *, value);
4955 while (*pos && mlen) {
4957 if (len == 0 && *pos ==
':') {
4960 input[len] = (char)(toupper(*pos));
4961 if (input[len] ==
'X')
4963 if (input[len] ==
'O' && strchr(digits, *(pos + 1)))
4971 if (len == 0 || mlen == 0) {
4977 components[level++] = pos;
4978 while ((pos = strchr(pos,
','))) {
4979 if (level >= MAX_T_LEVEL)
4982 components[level++] = ++pos;
4985 __kmp_hw_subset = kmp_hw_subset_t::allocate();
4987 __kmp_hw_subset->set_absolute();
4990 for (
int i = 0; i < level; ++i) {
4992 char *core_components[MAX_T_LEVEL];
4994 pos = components[i];
4995 core_components[core_level++] = pos;
4996 while ((pos = strchr(pos,
'&'))) {
4997 if (core_level >= MAX_T_LEVEL)
5000 core_components[core_level++] = ++pos;
5003 for (
int j = 0; j < core_level; ++j) {
5010 if (isdigit(*core_components[j])) {
5011 num = atoi(core_components[j]);
5015 pos = core_components[j] + strspn(core_components[j], digits);
5016 }
else if (*core_components[j] ==
'*') {
5017 num = kmp_hw_subset_t::USE_ALL;
5018 pos = core_components[j] + 1;
5020 num = kmp_hw_subset_t::USE_ALL;
5021 pos = core_components[j];
5024 offset_ptr = strchr(core_components[j],
'@');
5025 attr_ptr = strchr(core_components[j],
':');
5028 offset = atoi(offset_ptr + 1);
5034#if KMP_ARCH_X86 || KMP_ARCH_X86_64
5035 if (__kmp_str_match(
"intel_core", -1, attr_ptr + 1)) {
5036 attr.set_core_type(KMP_HW_CORE_TYPE_CORE);
5037 }
else if (__kmp_str_match(
"intel_atom", -1, attr_ptr + 1)) {
5038 attr.set_core_type(KMP_HW_CORE_TYPE_ATOM);
5041 if (__kmp_str_match(
"eff", 3, attr_ptr + 1)) {
5042 const char *number = attr_ptr + 1;
5044 while (isalpha(*number))
5046 if (!isdigit(*number)) {
5049 int efficiency = atoi(number);
5050 attr.set_core_eff(efficiency);
5057 kmp_hw_t type = __kmp_stg_parse_hw_subset_name(pos);
5058 if (type == KMP_HW_UNKNOWN) {
5062 if (attr && type != KMP_HW_CORE)
5065 if (type != KMP_HW_CORE && __kmp_hw_subset->specified(type)) {
5068 __kmp_hw_subset->push_back(num, type, offset, attr);
5073 KMP_WARNING(AffHWSubsetInvalid, name, value);
5074 if (__kmp_hw_subset) {
5075 kmp_hw_subset_t::deallocate(__kmp_hw_subset);
5076 __kmp_hw_subset =
nullptr;
5081static inline const char *
5082__kmp_hw_get_core_type_keyword(kmp_hw_core_type_t type) {
5084 case KMP_HW_CORE_TYPE_UNKNOWN:
5086#if KMP_ARCH_X86 || KMP_ARCH_X86_64
5087 case KMP_HW_CORE_TYPE_ATOM:
5088 return "intel_atom";
5089 case KMP_HW_CORE_TYPE_CORE:
5090 return "intel_core";
5096static void __kmp_stg_print_hw_subset(kmp_str_buf_t *buffer,
char const *name,
5100 if (!__kmp_hw_subset)
5102 __kmp_str_buf_init(&buf);
5103 if (__kmp_env_format)
5104 KMP_STR_BUF_PRINT_NAME_EX(name);
5106 __kmp_str_buf_print(buffer,
" %s='", name);
5108 depth = __kmp_hw_subset->get_depth();
5109 for (
int i = 0; i < depth; ++i) {
5110 const auto &item = __kmp_hw_subset->at(i);
5112 __kmp_str_buf_print(&buf,
"%c",
',');
5113 for (
int j = 0; j < item.num_attrs; ++j) {
5114 __kmp_str_buf_print(&buf,
"%s%d%s", (j > 0 ?
"&" :
""), item.num[j],
5115 __kmp_hw_get_keyword(item.type));
5116 if (item.attr[j].is_core_type_valid())
5117 __kmp_str_buf_print(
5119 __kmp_hw_get_core_type_keyword(item.attr[j].get_core_type()));
5120 if (item.attr[j].is_core_eff_valid())
5121 __kmp_str_buf_print(&buf,
":eff%d", item.attr[j].get_core_eff());
5123 __kmp_str_buf_print(&buf,
"@%d", item.offset[j]);
5126 __kmp_str_buf_print(buffer,
"%s'\n", buf.str);
5127 __kmp_str_buf_free(&buf);
5134static void __kmp_stg_parse_forkjoin_frames(
char const *name,
char const *value,
5136 __kmp_stg_parse_bool(name, value, &__kmp_forkjoin_frames);
5139static void __kmp_stg_print_forkjoin_frames(kmp_str_buf_t *buffer,
5140 char const *name,
void *data) {
5141 __kmp_stg_print_bool(buffer, name, __kmp_forkjoin_frames);
5147static void __kmp_stg_parse_forkjoin_frames_mode(
char const *name,
5150 __kmp_stg_parse_int(name, value, 0, 3, &__kmp_forkjoin_frames_mode);
5153static void __kmp_stg_print_forkjoin_frames_mode(kmp_str_buf_t *buffer,
5154 char const *name,
void *data) {
5155 __kmp_stg_print_int(buffer, name, __kmp_forkjoin_frames_mode);
5162static void __kmp_stg_parse_task_throttling(
char const *name,
char const *value,
5164 __kmp_stg_parse_bool(name, value, &__kmp_enable_task_throttling);
5167static void __kmp_stg_print_task_throttling(kmp_str_buf_t *buffer,
5168 char const *name,
void *data) {
5169 __kmp_stg_print_bool(buffer, name, __kmp_enable_task_throttling);
5172#if KMP_HAVE_MWAIT || KMP_HAVE_UMWAIT
5176static void __kmp_stg_parse_user_level_mwait(
char const *name,
5177 char const *value,
void *data) {
5178 __kmp_stg_parse_bool(name, value, &__kmp_user_level_mwait);
5181static void __kmp_stg_print_user_level_mwait(kmp_str_buf_t *buffer,
5182 char const *name,
void *data) {
5183 __kmp_stg_print_bool(buffer, name, __kmp_user_level_mwait);
5189static void __kmp_stg_parse_mwait_hints(
char const *name,
char const *value,
5191 __kmp_stg_parse_int(name, value, 0, INT_MAX, &__kmp_mwait_hints);
5194static void __kmp_stg_print_mwait_hints(kmp_str_buf_t *buffer,
char const *name,
5196 __kmp_stg_print_int(buffer, name, __kmp_mwait_hints);
5206static void __kmp_stg_parse_tpause(
char const *name,
char const *value,
5208 __kmp_stg_parse_int(name, value, 0, INT_MAX, &__kmp_tpause_state);
5209 if (__kmp_tpause_state != 0) {
5211 if (__kmp_tpause_state == 2)
5212 __kmp_tpause_hint = 0;
5216static void __kmp_stg_print_tpause(kmp_str_buf_t *buffer,
char const *name,
5218 __kmp_stg_print_int(buffer, name, __kmp_tpause_state);
5225static void __kmp_stg_parse_omp_display_env(
char const *name,
char const *value,
5227 if (__kmp_str_match(
"VERBOSE", 1, value)) {
5228 __kmp_display_env_verbose = TRUE;
5230 __kmp_stg_parse_bool(name, value, &__kmp_display_env);
5234static void __kmp_stg_print_omp_display_env(kmp_str_buf_t *buffer,
5235 char const *name,
void *data) {
5236 if (__kmp_display_env_verbose) {
5237 __kmp_stg_print_str(buffer, name,
"VERBOSE");
5239 __kmp_stg_print_bool(buffer, name, __kmp_display_env);
5243static void __kmp_stg_parse_omp_cancellation(
char const *name,
5244 char const *value,
void *data) {
5245 if (TCR_4(__kmp_init_parallel)) {
5246 KMP_WARNING(EnvParallelWarn, name);
5249 __kmp_stg_parse_bool(name, value, &__kmp_omp_cancellation);
5252static void __kmp_stg_print_omp_cancellation(kmp_str_buf_t *buffer,
5253 char const *name,
void *data) {
5254 __kmp_stg_print_bool(buffer, name, __kmp_omp_cancellation);
5260static void __kmp_stg_parse_omp_tool(
char const *name,
char const *value,
5262 __kmp_stg_parse_bool(name, value, &__kmp_tool);
5265static void __kmp_stg_print_omp_tool(kmp_str_buf_t *buffer,
char const *name,
5267 if (__kmp_env_format) {
5268 KMP_STR_BUF_PRINT_BOOL_EX(name, __kmp_tool,
"enabled",
"disabled");
5270 __kmp_str_buf_print(buffer,
" %s=%s\n", name,
5271 __kmp_tool ?
"enabled" :
"disabled");
5275char *__kmp_tool_libraries = NULL;
5277static void __kmp_stg_parse_omp_tool_libraries(
char const *name,
5278 char const *value,
void *data) {
5279 __kmp_stg_parse_str(name, value, &__kmp_tool_libraries);
5282static void __kmp_stg_print_omp_tool_libraries(kmp_str_buf_t *buffer,
5283 char const *name,
void *data) {
5284 if (__kmp_tool_libraries)
5285 __kmp_stg_print_str(buffer, name, __kmp_tool_libraries);
5287 if (__kmp_env_format) {
5288 KMP_STR_BUF_PRINT_NAME;
5290 __kmp_str_buf_print(buffer,
" %s", name);
5292 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
5296char *__kmp_tool_verbose_init = NULL;
5298static void __kmp_stg_parse_omp_tool_verbose_init(
char const *name,
5301 __kmp_stg_parse_str(name, value, &__kmp_tool_verbose_init);
5304static void __kmp_stg_print_omp_tool_verbose_init(kmp_str_buf_t *buffer,
5307 if (__kmp_tool_verbose_init)
5308 __kmp_stg_print_str(buffer, name, __kmp_tool_verbose_init);
5310 if (__kmp_env_format) {
5311 KMP_STR_BUF_PRINT_NAME;
5313 __kmp_str_buf_print(buffer,
" %s", name);
5315 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
5323static kmp_setting_t __kmp_stg_table[] = {
5325 {
"KMP_ALL_THREADS", __kmp_stg_parse_device_thread_limit, NULL, NULL, 0, 0},
5326 {
"KMP_BLOCKTIME", __kmp_stg_parse_blocktime, __kmp_stg_print_blocktime,
5328 {
"KMP_USE_YIELD", __kmp_stg_parse_use_yield, __kmp_stg_print_use_yield,
5330 {
"KMP_DUPLICATE_LIB_OK", __kmp_stg_parse_duplicate_lib_ok,
5331 __kmp_stg_print_duplicate_lib_ok, NULL, 0, 0},
5332 {
"KMP_LIBRARY", __kmp_stg_parse_wait_policy, __kmp_stg_print_wait_policy,
5334 {
"KMP_DEVICE_THREAD_LIMIT", __kmp_stg_parse_device_thread_limit,
5335 __kmp_stg_print_device_thread_limit, NULL, 0, 0},
5337 {
"KMP_MONITOR_STACKSIZE", __kmp_stg_parse_monitor_stacksize,
5338 __kmp_stg_print_monitor_stacksize, NULL, 0, 0},
5340 {
"KMP_SETTINGS", __kmp_stg_parse_settings, __kmp_stg_print_settings, NULL,
5342 {
"KMP_STACKOFFSET", __kmp_stg_parse_stackoffset,
5343 __kmp_stg_print_stackoffset, NULL, 0, 0},
5344 {
"KMP_STACKSIZE", __kmp_stg_parse_stacksize, __kmp_stg_print_stacksize,
5346 {
"KMP_STACKPAD", __kmp_stg_parse_stackpad, __kmp_stg_print_stackpad, NULL,
5348 {
"KMP_VERSION", __kmp_stg_parse_version, __kmp_stg_print_version, NULL, 0,
5350 {
"KMP_WARNINGS", __kmp_stg_parse_warnings, __kmp_stg_print_warnings, NULL,
5353 {
"KMP_NESTING_MODE", __kmp_stg_parse_nesting_mode,
5354 __kmp_stg_print_nesting_mode, NULL, 0, 0},
5355 {
"OMP_NESTED", __kmp_stg_parse_nested, __kmp_stg_print_nested, NULL, 0, 0},
5356 {
"OMP_NUM_THREADS", __kmp_stg_parse_num_threads,
5357 __kmp_stg_print_num_threads, NULL, 0, 0},
5358 {
"OMP_STACKSIZE", __kmp_stg_parse_stacksize, __kmp_stg_print_stacksize,
5361 {
"KMP_TASKING", __kmp_stg_parse_tasking, __kmp_stg_print_tasking, NULL, 0,
5363 {
"KMP_TASK_STEALING_CONSTRAINT", __kmp_stg_parse_task_stealing,
5364 __kmp_stg_print_task_stealing, NULL, 0, 0},
5365 {
"OMP_MAX_ACTIVE_LEVELS", __kmp_stg_parse_max_active_levels,
5366 __kmp_stg_print_max_active_levels, NULL, 0, 0},
5367 {
"OMP_DEFAULT_DEVICE", __kmp_stg_parse_default_device,
5368 __kmp_stg_print_default_device, NULL, 0, 0},
5369 {
"OMP_TARGET_OFFLOAD", __kmp_stg_parse_target_offload,
5370 __kmp_stg_print_target_offload, NULL, 0, 0},
5371 {
"OMP_MAX_TASK_PRIORITY", __kmp_stg_parse_max_task_priority,
5372 __kmp_stg_print_max_task_priority, NULL, 0, 0},
5373 {
"KMP_TASKLOOP_MIN_TASKS", __kmp_stg_parse_taskloop_min_tasks,
5374 __kmp_stg_print_taskloop_min_tasks, NULL, 0, 0},
5375 {
"OMP_THREAD_LIMIT", __kmp_stg_parse_thread_limit,
5376 __kmp_stg_print_thread_limit, NULL, 0, 0},
5377 {
"KMP_TEAMS_THREAD_LIMIT", __kmp_stg_parse_teams_thread_limit,
5378 __kmp_stg_print_teams_thread_limit, NULL, 0, 0},
5379 {
"OMP_NUM_TEAMS", __kmp_stg_parse_nteams, __kmp_stg_print_nteams, NULL, 0,
5381 {
"OMP_TEAMS_THREAD_LIMIT", __kmp_stg_parse_teams_th_limit,
5382 __kmp_stg_print_teams_th_limit, NULL, 0, 0},
5383 {
"OMP_WAIT_POLICY", __kmp_stg_parse_wait_policy,
5384 __kmp_stg_print_wait_policy, NULL, 0, 0},
5385 {
"KMP_DISP_NUM_BUFFERS", __kmp_stg_parse_disp_buffers,
5386 __kmp_stg_print_disp_buffers, NULL, 0, 0},
5387#if KMP_NESTED_HOT_TEAMS
5388 {
"KMP_HOT_TEAMS_MAX_LEVEL", __kmp_stg_parse_hot_teams_level,
5389 __kmp_stg_print_hot_teams_level, NULL, 0, 0},
5390 {
"KMP_HOT_TEAMS_MODE", __kmp_stg_parse_hot_teams_mode,
5391 __kmp_stg_print_hot_teams_mode, NULL, 0, 0},
5394#if KMP_HANDLE_SIGNALS
5395 {
"KMP_HANDLE_SIGNALS", __kmp_stg_parse_handle_signals,
5396 __kmp_stg_print_handle_signals, NULL, 0, 0},
5399#if KMP_ARCH_X86 || KMP_ARCH_X86_64
5400 {
"KMP_INHERIT_FP_CONTROL", __kmp_stg_parse_inherit_fp_control,
5401 __kmp_stg_print_inherit_fp_control, NULL, 0, 0},
5404#ifdef KMP_GOMP_COMPAT
5405 {
"GOMP_STACKSIZE", __kmp_stg_parse_stacksize, NULL, NULL, 0, 0},
5409 {
"KMP_A_DEBUG", __kmp_stg_parse_a_debug, __kmp_stg_print_a_debug, NULL, 0,
5411 {
"KMP_B_DEBUG", __kmp_stg_parse_b_debug, __kmp_stg_print_b_debug, NULL, 0,
5413 {
"KMP_C_DEBUG", __kmp_stg_parse_c_debug, __kmp_stg_print_c_debug, NULL, 0,
5415 {
"KMP_D_DEBUG", __kmp_stg_parse_d_debug, __kmp_stg_print_d_debug, NULL, 0,
5417 {
"KMP_E_DEBUG", __kmp_stg_parse_e_debug, __kmp_stg_print_e_debug, NULL, 0,
5419 {
"KMP_F_DEBUG", __kmp_stg_parse_f_debug, __kmp_stg_print_f_debug, NULL, 0,
5421 {
"KMP_DEBUG", __kmp_stg_parse_debug, NULL, NULL, 0, 0},
5422 {
"KMP_DEBUG_BUF", __kmp_stg_parse_debug_buf, __kmp_stg_print_debug_buf,
5424 {
"KMP_DEBUG_BUF_ATOMIC", __kmp_stg_parse_debug_buf_atomic,
5425 __kmp_stg_print_debug_buf_atomic, NULL, 0, 0},
5426 {
"KMP_DEBUG_BUF_CHARS", __kmp_stg_parse_debug_buf_chars,
5427 __kmp_stg_print_debug_buf_chars, NULL, 0, 0},
5428 {
"KMP_DEBUG_BUF_LINES", __kmp_stg_parse_debug_buf_lines,
5429 __kmp_stg_print_debug_buf_lines, NULL, 0, 0},
5430 {
"KMP_DIAG", __kmp_stg_parse_diag, __kmp_stg_print_diag, NULL, 0, 0},
5432 {
"KMP_PAR_RANGE", __kmp_stg_parse_par_range_env,
5433 __kmp_stg_print_par_range_env, NULL, 0, 0},
5436 {
"KMP_ALIGN_ALLOC", __kmp_stg_parse_align_alloc,
5437 __kmp_stg_print_align_alloc, NULL, 0, 0},
5439 {
"KMP_PLAIN_BARRIER", __kmp_stg_parse_barrier_branch_bit,
5440 __kmp_stg_print_barrier_branch_bit, NULL, 0, 0},
5441 {
"KMP_PLAIN_BARRIER_PATTERN", __kmp_stg_parse_barrier_pattern,
5442 __kmp_stg_print_barrier_pattern, NULL, 0, 0},
5443 {
"KMP_FORKJOIN_BARRIER", __kmp_stg_parse_barrier_branch_bit,
5444 __kmp_stg_print_barrier_branch_bit, NULL, 0, 0},
5445 {
"KMP_FORKJOIN_BARRIER_PATTERN", __kmp_stg_parse_barrier_pattern,
5446 __kmp_stg_print_barrier_pattern, NULL, 0, 0},
5447#if KMP_FAST_REDUCTION_BARRIER
5448 {
"KMP_REDUCTION_BARRIER", __kmp_stg_parse_barrier_branch_bit,
5449 __kmp_stg_print_barrier_branch_bit, NULL, 0, 0},
5450 {
"KMP_REDUCTION_BARRIER_PATTERN", __kmp_stg_parse_barrier_pattern,
5451 __kmp_stg_print_barrier_pattern, NULL, 0, 0},
5454 {
"KMP_ABORT_DELAY", __kmp_stg_parse_abort_delay,
5455 __kmp_stg_print_abort_delay, NULL, 0, 0},
5456 {
"KMP_CPUINFO_FILE", __kmp_stg_parse_cpuinfo_file,
5457 __kmp_stg_print_cpuinfo_file, NULL, 0, 0},
5458 {
"KMP_FORCE_REDUCTION", __kmp_stg_parse_force_reduction,
5459 __kmp_stg_print_force_reduction, NULL, 0, 0},
5460 {
"KMP_DETERMINISTIC_REDUCTION", __kmp_stg_parse_force_reduction,
5461 __kmp_stg_print_force_reduction, NULL, 0, 0},
5462 {
"KMP_STORAGE_MAP", __kmp_stg_parse_storage_map,
5463 __kmp_stg_print_storage_map, NULL, 0, 0},
5464 {
"KMP_ALL_THREADPRIVATE", __kmp_stg_parse_all_threadprivate,
5465 __kmp_stg_print_all_threadprivate, NULL, 0, 0},
5466 {
"KMP_FOREIGN_THREADS_THREADPRIVATE",
5467 __kmp_stg_parse_foreign_threads_threadprivate,
5468 __kmp_stg_print_foreign_threads_threadprivate, NULL, 0, 0},
5470#if KMP_AFFINITY_SUPPORTED
5471 {
"KMP_AFFINITY", __kmp_stg_parse_affinity, __kmp_stg_print_affinity, NULL,
5473#ifdef KMP_GOMP_COMPAT
5474 {
"GOMP_CPU_AFFINITY", __kmp_stg_parse_gomp_cpu_affinity, NULL,
5477 {
"OMP_PROC_BIND", __kmp_stg_parse_proc_bind, __kmp_stg_print_proc_bind,
5479 {
"KMP_TEAMS_PROC_BIND", __kmp_stg_parse_teams_proc_bind,
5480 __kmp_stg_print_teams_proc_bind, NULL, 0, 0},
5481 {
"OMP_PLACES", __kmp_stg_parse_places, __kmp_stg_print_places, NULL, 0, 0},
5482 {
"KMP_TOPOLOGY_METHOD", __kmp_stg_parse_topology_method,
5483 __kmp_stg_print_topology_method, NULL, 0, 0},
5489 {
"OMP_PROC_BIND", __kmp_stg_parse_proc_bind, __kmp_stg_print_proc_bind,
5493 {
"OMP_DISPLAY_AFFINITY", __kmp_stg_parse_display_affinity,
5494 __kmp_stg_print_display_affinity, NULL, 0, 0},
5495 {
"OMP_AFFINITY_FORMAT", __kmp_stg_parse_affinity_format,
5496 __kmp_stg_print_affinity_format, NULL, 0, 0},
5497 {
"KMP_INIT_AT_FORK", __kmp_stg_parse_init_at_fork,
5498 __kmp_stg_print_init_at_fork, NULL, 0, 0},
5499 {
"KMP_SCHEDULE", __kmp_stg_parse_schedule, __kmp_stg_print_schedule, NULL,
5501 {
"OMP_SCHEDULE", __kmp_stg_parse_omp_schedule, __kmp_stg_print_omp_schedule,
5503#if KMP_USE_HIER_SCHED
5504 {
"KMP_DISP_HAND_THREAD", __kmp_stg_parse_kmp_hand_thread,
5505 __kmp_stg_print_kmp_hand_thread, NULL, 0, 0},
5507 {
"KMP_FORCE_MONOTONIC_DYNAMIC_SCHEDULE",
5508 __kmp_stg_parse_kmp_force_monotonic, __kmp_stg_print_kmp_force_monotonic,
5510 {
"KMP_ATOMIC_MODE", __kmp_stg_parse_atomic_mode,
5511 __kmp_stg_print_atomic_mode, NULL, 0, 0},
5512 {
"KMP_CONSISTENCY_CHECK", __kmp_stg_parse_consistency_check,
5513 __kmp_stg_print_consistency_check, NULL, 0, 0},
5515#if USE_ITT_BUILD && USE_ITT_NOTIFY
5516 {
"KMP_ITT_PREPARE_DELAY", __kmp_stg_parse_itt_prepare_delay,
5517 __kmp_stg_print_itt_prepare_delay, NULL, 0, 0},
5519 {
"KMP_MALLOC_POOL_INCR", __kmp_stg_parse_malloc_pool_incr,
5520 __kmp_stg_print_malloc_pool_incr, NULL, 0, 0},
5521 {
"KMP_GTID_MODE", __kmp_stg_parse_gtid_mode, __kmp_stg_print_gtid_mode,
5523 {
"OMP_DYNAMIC", __kmp_stg_parse_omp_dynamic, __kmp_stg_print_omp_dynamic,
5525 {
"KMP_DYNAMIC_MODE", __kmp_stg_parse_kmp_dynamic_mode,
5526 __kmp_stg_print_kmp_dynamic_mode, NULL, 0, 0},
5528#ifdef USE_LOAD_BALANCE
5529 {
"KMP_LOAD_BALANCE_INTERVAL", __kmp_stg_parse_ld_balance_interval,
5530 __kmp_stg_print_ld_balance_interval, NULL, 0, 0},
5533 {
"KMP_NUM_LOCKS_IN_BLOCK", __kmp_stg_parse_lock_block,
5534 __kmp_stg_print_lock_block, NULL, 0, 0},
5535 {
"KMP_LOCK_KIND", __kmp_stg_parse_lock_kind, __kmp_stg_print_lock_kind,
5537 {
"KMP_SPIN_BACKOFF_PARAMS", __kmp_stg_parse_spin_backoff_params,
5538 __kmp_stg_print_spin_backoff_params, NULL, 0, 0},
5539#if KMP_USE_ADAPTIVE_LOCKS
5540 {
"KMP_ADAPTIVE_LOCK_PROPS", __kmp_stg_parse_adaptive_lock_props,
5541 __kmp_stg_print_adaptive_lock_props, NULL, 0, 0},
5542#if KMP_DEBUG_ADAPTIVE_LOCKS
5543 {
"KMP_SPECULATIVE_STATSFILE", __kmp_stg_parse_speculative_statsfile,
5544 __kmp_stg_print_speculative_statsfile, NULL, 0, 0},
5547 {
"KMP_PLACE_THREADS", __kmp_stg_parse_hw_subset, __kmp_stg_print_hw_subset,
5549 {
"KMP_HW_SUBSET", __kmp_stg_parse_hw_subset, __kmp_stg_print_hw_subset,
5552 {
"KMP_FORKJOIN_FRAMES", __kmp_stg_parse_forkjoin_frames,
5553 __kmp_stg_print_forkjoin_frames, NULL, 0, 0},
5554 {
"KMP_FORKJOIN_FRAMES_MODE", __kmp_stg_parse_forkjoin_frames_mode,
5555 __kmp_stg_print_forkjoin_frames_mode, NULL, 0, 0},
5557 {
"KMP_ENABLE_TASK_THROTTLING", __kmp_stg_parse_task_throttling,
5558 __kmp_stg_print_task_throttling, NULL, 0, 0},
5560 {
"OMP_DISPLAY_ENV", __kmp_stg_parse_omp_display_env,
5561 __kmp_stg_print_omp_display_env, NULL, 0, 0},
5562 {
"OMP_CANCELLATION", __kmp_stg_parse_omp_cancellation,
5563 __kmp_stg_print_omp_cancellation, NULL, 0, 0},
5564 {
"OMP_ALLOCATOR", __kmp_stg_parse_allocator, __kmp_stg_print_allocator,
5566 {
"LIBOMP_USE_HIDDEN_HELPER_TASK", __kmp_stg_parse_use_hidden_helper,
5567 __kmp_stg_print_use_hidden_helper, NULL, 0, 0},
5568 {
"LIBOMP_NUM_HIDDEN_HELPER_THREADS",
5569 __kmp_stg_parse_num_hidden_helper_threads,
5570 __kmp_stg_print_num_hidden_helper_threads, NULL, 0, 0},
5573 {
"OMP_TOOL", __kmp_stg_parse_omp_tool, __kmp_stg_print_omp_tool, NULL, 0,
5575 {
"OMP_TOOL_LIBRARIES", __kmp_stg_parse_omp_tool_libraries,
5576 __kmp_stg_print_omp_tool_libraries, NULL, 0, 0},
5577 {
"OMP_TOOL_VERBOSE_INIT", __kmp_stg_parse_omp_tool_verbose_init,
5578 __kmp_stg_print_omp_tool_verbose_init, NULL, 0, 0},
5581#if KMP_HAVE_MWAIT || KMP_HAVE_UMWAIT
5582 {
"KMP_USER_LEVEL_MWAIT", __kmp_stg_parse_user_level_mwait,
5583 __kmp_stg_print_user_level_mwait, NULL, 0, 0},
5584 {
"KMP_MWAIT_HINTS", __kmp_stg_parse_mwait_hints,
5585 __kmp_stg_print_mwait_hints, NULL, 0, 0},
5589 {
"KMP_TPAUSE", __kmp_stg_parse_tpause, __kmp_stg_print_tpause, NULL, 0, 0},
5591 {
"", NULL, NULL, NULL, 0, 0}};
5593static int const __kmp_stg_count =
5594 sizeof(__kmp_stg_table) /
sizeof(kmp_setting_t);
5596static inline kmp_setting_t *__kmp_stg_find(
char const *name) {
5600 for (i = 0; i < __kmp_stg_count; ++i) {
5601 if (strcmp(__kmp_stg_table[i].name, name) == 0) {
5602 return &__kmp_stg_table[i];
5610static int __kmp_stg_cmp(
void const *_a,
void const *_b) {
5611 const kmp_setting_t *a = RCAST(
const kmp_setting_t *, _a);
5612 const kmp_setting_t *b = RCAST(
const kmp_setting_t *, _b);
5616 if (strcmp(a->name,
"KMP_AFFINITY") == 0) {
5617 if (strcmp(b->name,
"KMP_AFFINITY") == 0) {
5621 }
else if (strcmp(b->name,
"KMP_AFFINITY") == 0) {
5624 return strcmp(a->name, b->name);
5627static void __kmp_stg_init(
void) {
5629 static int initialized = 0;
5634 qsort(__kmp_stg_table, __kmp_stg_count - 1,
sizeof(kmp_setting_t),
5638 kmp_setting_t *kmp_stacksize =
5639 __kmp_stg_find(
"KMP_STACKSIZE");
5640#ifdef KMP_GOMP_COMPAT
5641 kmp_setting_t *gomp_stacksize =
5642 __kmp_stg_find(
"GOMP_STACKSIZE");
5644 kmp_setting_t *omp_stacksize =
5645 __kmp_stg_find(
"OMP_STACKSIZE");
5651 static kmp_setting_t *
volatile rivals[4];
5652 static kmp_stg_ss_data_t kmp_data = {1, CCAST(kmp_setting_t **, rivals)};
5653#ifdef KMP_GOMP_COMPAT
5654 static kmp_stg_ss_data_t gomp_data = {1024,
5655 CCAST(kmp_setting_t **, rivals)};
5657 static kmp_stg_ss_data_t omp_data = {1024,
5658 CCAST(kmp_setting_t **, rivals)};
5661 rivals[i++] = kmp_stacksize;
5662#ifdef KMP_GOMP_COMPAT
5663 if (gomp_stacksize != NULL) {
5664 rivals[i++] = gomp_stacksize;
5667 rivals[i++] = omp_stacksize;
5670 kmp_stacksize->data = &kmp_data;
5671#ifdef KMP_GOMP_COMPAT
5672 if (gomp_stacksize != NULL) {
5673 gomp_stacksize->data = &gomp_data;
5676 omp_stacksize->data = &omp_data;
5680 kmp_setting_t *kmp_library =
5681 __kmp_stg_find(
"KMP_LIBRARY");
5682 kmp_setting_t *omp_wait_policy =
5683 __kmp_stg_find(
"OMP_WAIT_POLICY");
5686 static kmp_setting_t *
volatile rivals[3];
5687 static kmp_stg_wp_data_t kmp_data = {0, CCAST(kmp_setting_t **, rivals)};
5688 static kmp_stg_wp_data_t omp_data = {1, CCAST(kmp_setting_t **, rivals)};
5691 rivals[i++] = kmp_library;
5692 if (omp_wait_policy != NULL) {
5693 rivals[i++] = omp_wait_policy;
5697 kmp_library->data = &kmp_data;
5698 if (omp_wait_policy != NULL) {
5699 omp_wait_policy->data = &omp_data;
5704 kmp_setting_t *kmp_device_thread_limit =
5705 __kmp_stg_find(
"KMP_DEVICE_THREAD_LIMIT");
5706 kmp_setting_t *kmp_all_threads =
5707 __kmp_stg_find(
"KMP_ALL_THREADS");
5710 static kmp_setting_t *
volatile rivals[3];
5713 rivals[i++] = kmp_device_thread_limit;
5714 rivals[i++] = kmp_all_threads;
5717 kmp_device_thread_limit->data = CCAST(kmp_setting_t **, rivals);
5718 kmp_all_threads->data = CCAST(kmp_setting_t **, rivals);
5723 kmp_setting_t *kmp_hw_subset = __kmp_stg_find(
"KMP_HW_SUBSET");
5725 kmp_setting_t *kmp_place_threads = __kmp_stg_find(
"KMP_PLACE_THREADS");
5728 static kmp_setting_t *
volatile rivals[3];
5731 rivals[i++] = kmp_hw_subset;
5732 rivals[i++] = kmp_place_threads;
5735 kmp_hw_subset->data = CCAST(kmp_setting_t **, rivals);
5736 kmp_place_threads->data = CCAST(kmp_setting_t **, rivals);
5739#if KMP_AFFINITY_SUPPORTED
5741 kmp_setting_t *kmp_affinity =
5742 __kmp_stg_find(
"KMP_AFFINITY");
5743 KMP_DEBUG_ASSERT(kmp_affinity != NULL);
5745#ifdef KMP_GOMP_COMPAT
5746 kmp_setting_t *gomp_cpu_affinity =
5747 __kmp_stg_find(
"GOMP_CPU_AFFINITY");
5748 KMP_DEBUG_ASSERT(gomp_cpu_affinity != NULL);
5751 kmp_setting_t *omp_proc_bind =
5752 __kmp_stg_find(
"OMP_PROC_BIND");
5753 KMP_DEBUG_ASSERT(omp_proc_bind != NULL);
5756 static kmp_setting_t *
volatile rivals[4];
5759 rivals[i++] = kmp_affinity;
5761#ifdef KMP_GOMP_COMPAT
5762 rivals[i++] = gomp_cpu_affinity;
5763 gomp_cpu_affinity->data = CCAST(kmp_setting_t **, rivals);
5766 rivals[i++] = omp_proc_bind;
5767 omp_proc_bind->data = CCAST(kmp_setting_t **, rivals);
5770 static kmp_setting_t *
volatile places_rivals[4];
5773 kmp_setting_t *omp_places = __kmp_stg_find(
"OMP_PLACES");
5774 KMP_DEBUG_ASSERT(omp_places != NULL);
5776 places_rivals[i++] = kmp_affinity;
5777#ifdef KMP_GOMP_COMPAT
5778 places_rivals[i++] = gomp_cpu_affinity;
5780 places_rivals[i++] = omp_places;
5781 omp_places->data = CCAST(kmp_setting_t **, places_rivals);
5782 places_rivals[i++] = NULL;
5790 kmp_setting_t *kmp_force_red =
5791 __kmp_stg_find(
"KMP_FORCE_REDUCTION");
5792 kmp_setting_t *kmp_determ_red =
5793 __kmp_stg_find(
"KMP_DETERMINISTIC_REDUCTION");
5796 static kmp_setting_t *
volatile rivals[3];
5797 static kmp_stg_fr_data_t force_data = {1,
5798 CCAST(kmp_setting_t **, rivals)};
5799 static kmp_stg_fr_data_t determ_data = {0,
5800 CCAST(kmp_setting_t **, rivals)};
5803 rivals[i++] = kmp_force_red;
5804 if (kmp_determ_red != NULL) {
5805 rivals[i++] = kmp_determ_red;
5809 kmp_force_red->data = &force_data;
5810 if (kmp_determ_red != NULL) {
5811 kmp_determ_red->data = &determ_data;
5820 for (i = 0; i < __kmp_stg_count; ++i) {
5821 __kmp_stg_table[i].set = 0;
5826static void __kmp_stg_parse(
char const *name,
char const *value) {
5834 if (value != NULL) {
5835 kmp_setting_t *setting = __kmp_stg_find(name);
5836 if (setting != NULL) {
5837 setting->parse(name, value, setting->data);
5838 setting->defined = 1;
5844static int __kmp_stg_check_rivals(
5847 kmp_setting_t **rivals
5850 if (rivals == NULL) {
5856 for (; strcmp(rivals[i]->name, name) != 0; i++) {
5857 KMP_DEBUG_ASSERT(rivals[i] != NULL);
5859#if KMP_AFFINITY_SUPPORTED
5860 if (rivals[i] == __kmp_affinity_notype) {
5867 if (rivals[i]->set) {
5868 KMP_WARNING(StgIgnored, name, rivals[i]->name);
5878static int __kmp_env_toPrint(
char const *name,
int flag) {
5880 kmp_setting_t *setting = __kmp_stg_find(name);
5881 if (setting != NULL) {
5882 rc = setting->defined;
5884 setting->defined = flag;
5890static void __kmp_aux_env_initialize(kmp_env_blk_t *block) {
5895 value = __kmp_env_blk_var(block,
"OMP_NUM_THREADS");
5897 ompc_set_num_threads(__kmp_dflt_team_nth);
5901 value = __kmp_env_blk_var(block,
"KMP_BLOCKTIME");
5903 kmpc_set_blocktime(__kmp_dflt_blocktime);
5907 value = __kmp_env_blk_var(block,
"OMP_NESTED");
5909 ompc_set_nested(__kmp_dflt_max_active_levels > 1);
5913 value = __kmp_env_blk_var(block,
"OMP_DYNAMIC");
5915 ompc_set_dynamic(__kmp_global.g.g_dynamic);
5919void __kmp_env_initialize(
char const *
string) {
5921 kmp_env_blk_t block;
5927 if (
string == NULL) {
5929 __kmp_threads_capacity =
5930 __kmp_initial_threads_capacity(__kmp_dflt_team_nth_ub);
5932 __kmp_env_blk_init(&block,
string);
5935 for (i = 0; i < block.count; ++i) {
5936 if ((block.vars[i].name == NULL) || (*block.vars[i].name ==
'\0')) {
5939 if (block.vars[i].value == NULL) {
5942 kmp_setting_t *setting = __kmp_stg_find(block.vars[i].name);
5943 if (setting != NULL) {
5949 blocktime_str = __kmp_env_blk_var(&block,
"KMP_BLOCKTIME");
5953 if (
string == NULL) {
5954 char const *name =
"KMP_WARNINGS";
5955 char const *value = __kmp_env_blk_var(&block, name);
5956 __kmp_stg_parse(name, value);
5959#if KMP_AFFINITY_SUPPORTED
5965 __kmp_affinity_notype = NULL;
5966 char const *aff_str = __kmp_env_blk_var(&block,
"KMP_AFFINITY");
5967 if (aff_str != NULL) {
5981#define FIND strcasestr
5984 if ((FIND(aff_str,
"none") == NULL) &&
5985 (FIND(aff_str,
"physical") == NULL) &&
5986 (FIND(aff_str,
"logical") == NULL) &&
5987 (FIND(aff_str,
"compact") == NULL) &&
5988 (FIND(aff_str,
"scatter") == NULL) &&
5989 (FIND(aff_str,
"explicit") == NULL) &&
5990 (FIND(aff_str,
"balanced") == NULL) &&
5991 (FIND(aff_str,
"disabled") == NULL)) {
5992 __kmp_affinity_notype = __kmp_stg_find(
"KMP_AFFINITY");
5997 __kmp_affinity_type = affinity_default;
5998 __kmp_affinity_gran = KMP_HW_UNKNOWN;
5999 __kmp_affinity_top_method = affinity_top_method_default;
6000 __kmp_affinity_respect_mask = affinity_respect_mask_default;
6005 aff_str = __kmp_env_blk_var(&block,
"OMP_PROC_BIND");
6006 if (aff_str != NULL) {
6007 __kmp_affinity_type = affinity_default;
6008 __kmp_affinity_gran = KMP_HW_UNKNOWN;
6009 __kmp_affinity_top_method = affinity_top_method_default;
6010 __kmp_affinity_respect_mask = affinity_respect_mask_default;
6017 if (__kmp_nested_proc_bind.bind_types == NULL) {
6018 __kmp_nested_proc_bind.bind_types =
6019 (kmp_proc_bind_t *)KMP_INTERNAL_MALLOC(
sizeof(kmp_proc_bind_t));
6020 if (__kmp_nested_proc_bind.bind_types == NULL) {
6021 KMP_FATAL(MemoryAllocFailed);
6023 __kmp_nested_proc_bind.size = 1;
6024 __kmp_nested_proc_bind.used = 1;
6025#if KMP_AFFINITY_SUPPORTED
6026 __kmp_nested_proc_bind.bind_types[0] = proc_bind_default;
6029 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
6036 __kmp_msg_format(kmp_i18n_msg_AffFormatDefault,
"%P",
"%i",
"%n",
"%A");
6037 KMP_DEBUG_ASSERT(KMP_STRLEN(m.str) < KMP_AFFINITY_FORMAT_SIZE);
6039 if (__kmp_affinity_format == NULL) {
6040 __kmp_affinity_format =
6041 (
char *)KMP_INTERNAL_MALLOC(
sizeof(
char) * KMP_AFFINITY_FORMAT_SIZE);
6043 KMP_STRCPY_S(__kmp_affinity_format, KMP_AFFINITY_FORMAT_SIZE, m.str);
6044 __kmp_str_free(&m.str);
6047 for (i = 0; i < block.count; ++i) {
6048 __kmp_stg_parse(block.vars[i].name, block.vars[i].value);
6052 if (!__kmp_init_user_locks) {
6053 if (__kmp_user_lock_kind == lk_default) {
6054 __kmp_user_lock_kind = lk_queuing;
6056#if KMP_USE_DYNAMIC_LOCK
6057 __kmp_init_dynamic_user_locks();
6059 __kmp_set_user_lock_vptrs(__kmp_user_lock_kind);
6062 KMP_DEBUG_ASSERT(
string != NULL);
6063 KMP_DEBUG_ASSERT(__kmp_user_lock_kind != lk_default);
6068#if KMP_USE_DYNAMIC_LOCK
6069 __kmp_init_dynamic_user_locks();
6071 __kmp_set_user_lock_vptrs(__kmp_user_lock_kind);
6075#if KMP_AFFINITY_SUPPORTED
6077 if (!TCR_4(__kmp_init_middle)) {
6082 if (__kmp_hw_subset &&
6083 __kmp_affinity_top_method == affinity_top_method_default)
6084 if (__kmp_hw_subset->specified(KMP_HW_NUMA) ||
6085 __kmp_hw_subset->specified(KMP_HW_TILE) ||
6086 __kmp_affinity_gran == KMP_HW_TILE ||
6087 __kmp_affinity_gran == KMP_HW_NUMA)
6088 __kmp_affinity_top_method = affinity_top_method_hwloc;
6090 if (__kmp_affinity_gran == KMP_HW_NUMA ||
6091 __kmp_affinity_gran == KMP_HW_TILE)
6092 __kmp_affinity_top_method = affinity_top_method_hwloc;
6096 const char *var =
"KMP_AFFINITY";
6097 KMPAffinity::pick_api();
6102 if (__kmp_affinity_top_method == affinity_top_method_hwloc &&
6103 __kmp_affinity_dispatch->get_api_type() != KMPAffinity::HWLOC) {
6104 KMP_WARNING(AffIgnoringHwloc, var);
6105 __kmp_affinity_top_method = affinity_top_method_all;
6108 if (__kmp_affinity_type == affinity_disabled) {
6109 KMP_AFFINITY_DISABLE();
6110 }
else if (!KMP_AFFINITY_CAPABLE()) {
6111 __kmp_affinity_dispatch->determine_capable(var);
6112 if (!KMP_AFFINITY_CAPABLE()) {
6113 if (__kmp_affinity_verbose ||
6114 (__kmp_affinity_warnings &&
6115 (__kmp_affinity_type != affinity_default) &&
6116 (__kmp_affinity_type != affinity_none) &&
6117 (__kmp_affinity_type != affinity_disabled))) {
6118 KMP_WARNING(AffNotSupported, var);
6120 __kmp_affinity_type = affinity_disabled;
6121 __kmp_affinity_respect_mask = 0;
6122 __kmp_affinity_gran = KMP_HW_THREAD;
6126 if (__kmp_affinity_type == affinity_disabled) {
6127 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
6128 }
else if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_true) {
6130 __kmp_nested_proc_bind.bind_types[0] = proc_bind_spread;
6133 if (KMP_AFFINITY_CAPABLE()) {
6135#if KMP_GROUP_AFFINITY
6140 bool exactly_one_group =
false;
6141 if (__kmp_num_proc_groups > 1) {
6143 bool within_one_group;
6146 kmp_affin_mask_t *init_mask;
6147 KMP_CPU_ALLOC(init_mask);
6148 __kmp_get_system_affinity(init_mask, TRUE);
6149 group = __kmp_get_proc_group(init_mask);
6150 within_one_group = (group >= 0);
6153 if (within_one_group) {
6154 DWORD num_bits_in_group = __kmp_GetActiveProcessorCount(group);
6155 DWORD num_bits_in_mask = 0;
6156 for (
int bit = init_mask->begin(); bit != init_mask->end();
6157 bit = init_mask->next(bit))
6159 exactly_one_group = (num_bits_in_group == num_bits_in_mask);
6161 KMP_CPU_FREE(init_mask);
6167 if (__kmp_num_proc_groups > 1 &&
6168 __kmp_affinity_type == affinity_default &&
6169 __kmp_nested_proc_bind.bind_types[0] == proc_bind_default) {
6174 if (__kmp_affinity_respect_mask == affinity_respect_mask_default &&
6175 exactly_one_group) {
6176 __kmp_affinity_respect_mask = FALSE;
6180 if (__kmp_affinity_type == affinity_default) {
6181 __kmp_affinity_type = affinity_compact;
6182 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
6184 if (__kmp_affinity_top_method == affinity_top_method_default)
6185 __kmp_affinity_top_method = affinity_top_method_all;
6186 if (__kmp_affinity_gran == KMP_HW_UNKNOWN)
6187 __kmp_affinity_gran = KMP_HW_PROC_GROUP;
6193 if (__kmp_affinity_respect_mask == affinity_respect_mask_default) {
6194#if KMP_GROUP_AFFINITY
6195 if (__kmp_num_proc_groups > 1 && exactly_one_group) {
6196 __kmp_affinity_respect_mask = FALSE;
6200 __kmp_affinity_respect_mask = TRUE;
6203 if ((__kmp_nested_proc_bind.bind_types[0] != proc_bind_intel) &&
6204 (__kmp_nested_proc_bind.bind_types[0] != proc_bind_default)) {
6205 if (__kmp_affinity_type == affinity_default) {
6206 __kmp_affinity_type = affinity_compact;
6207 __kmp_affinity_dups = FALSE;
6209 }
else if (__kmp_affinity_type == affinity_default) {
6210#if KMP_MIC_SUPPORTED
6211 if (__kmp_mic_type != non_mic) {
6212 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
6216 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
6218#if KMP_MIC_SUPPORTED
6219 if (__kmp_mic_type != non_mic) {
6220 __kmp_affinity_type = affinity_scatter;
6224 __kmp_affinity_type = affinity_none;
6227 if ((__kmp_affinity_gran == KMP_HW_UNKNOWN) &&
6228 (__kmp_affinity_gran_levels < 0)) {
6229#if KMP_MIC_SUPPORTED
6230 if (__kmp_mic_type != non_mic) {
6231 __kmp_affinity_gran = KMP_HW_THREAD;
6235 __kmp_affinity_gran = KMP_HW_CORE;
6238 if (__kmp_affinity_top_method == affinity_top_method_default) {
6239 __kmp_affinity_top_method = affinity_top_method_all;
6244 K_DIAG(1, (
"__kmp_affinity_type == %d\n", __kmp_affinity_type));
6245 K_DIAG(1, (
"__kmp_affinity_compact == %d\n", __kmp_affinity_compact));
6246 K_DIAG(1, (
"__kmp_affinity_offset == %d\n", __kmp_affinity_offset));
6247 K_DIAG(1, (
"__kmp_affinity_verbose == %d\n", __kmp_affinity_verbose));
6248 K_DIAG(1, (
"__kmp_affinity_warnings == %d\n", __kmp_affinity_warnings));
6249 K_DIAG(1, (
"__kmp_affinity_respect_mask == %d\n",
6250 __kmp_affinity_respect_mask));
6251 K_DIAG(1, (
"__kmp_affinity_gran == %d\n", __kmp_affinity_gran));
6253 KMP_DEBUG_ASSERT(__kmp_affinity_type != affinity_default);
6254 KMP_DEBUG_ASSERT(__kmp_nested_proc_bind.bind_types[0] != proc_bind_default);
6255 K_DIAG(1, (
"__kmp_nested_proc_bind.bind_types[0] == %d\n",
6256 __kmp_nested_proc_bind.bind_types[0]));
6261 if (__kmp_version) {
6262 __kmp_print_version_1();
6267 if (
string != NULL) {
6268 __kmp_aux_env_initialize(&block);
6271 __kmp_env_blk_free(&block);
6277void __kmp_env_print() {
6279 kmp_env_blk_t block;
6281 kmp_str_buf_t buffer;
6284 __kmp_str_buf_init(&buffer);
6286 __kmp_env_blk_init(&block, NULL);
6287 __kmp_env_blk_sort(&block);
6290 __kmp_str_buf_print(&buffer,
"\n%s\n\n", KMP_I18N_STR(UserSettings));
6291 for (i = 0; i < block.count; ++i) {
6292 char const *name = block.vars[i].name;
6293 char const *value = block.vars[i].value;
6294 if ((KMP_STRLEN(name) > 4 && strncmp(name,
"KMP_", 4) == 0) ||
6295 strncmp(name,
"OMP_", 4) == 0
6296#ifdef KMP_GOMP_COMPAT
6297 || strncmp(name,
"GOMP_", 5) == 0
6300 __kmp_str_buf_print(&buffer,
" %s=%s\n", name, value);
6303 __kmp_str_buf_print(&buffer,
"\n");
6306 __kmp_str_buf_print(&buffer,
"%s\n\n", KMP_I18N_STR(EffectiveSettings));
6307 for (
int i = 0; i < __kmp_stg_count; ++i) {
6308 if (__kmp_stg_table[i].print != NULL) {
6309 __kmp_stg_table[i].print(&buffer, __kmp_stg_table[i].name,
6310 __kmp_stg_table[i].data);
6314 __kmp_printf(
"%s", buffer.str);
6316 __kmp_env_blk_free(&block);
6317 __kmp_str_buf_free(&buffer);
6323void __kmp_env_print_2() {
6324 __kmp_display_env_impl(__kmp_display_env, __kmp_display_env_verbose);
6327void __kmp_display_env_impl(
int display_env,
int display_env_verbose) {
6328 kmp_env_blk_t block;
6329 kmp_str_buf_t buffer;
6331 __kmp_env_format = 1;
6334 __kmp_str_buf_init(&buffer);
6336 __kmp_env_blk_init(&block, NULL);
6337 __kmp_env_blk_sort(&block);
6339 __kmp_str_buf_print(&buffer,
"\n%s\n", KMP_I18N_STR(DisplayEnvBegin));
6340 __kmp_str_buf_print(&buffer,
" _OPENMP='%d'\n", __kmp_openmp_version);
6342 for (
int i = 0; i < __kmp_stg_count; ++i) {
6343 if (__kmp_stg_table[i].print != NULL &&
6344 ((display_env && strncmp(__kmp_stg_table[i].name,
"OMP_", 4) == 0) ||
6345 display_env_verbose)) {
6346 __kmp_stg_table[i].print(&buffer, __kmp_stg_table[i].name,
6347 __kmp_stg_table[i].data);
6351 __kmp_str_buf_print(&buffer,
"%s\n", KMP_I18N_STR(DisplayEnvEnd));
6352 __kmp_str_buf_print(&buffer,
"\n");
6354 __kmp_printf(
"%s", buffer.str);
6356 __kmp_env_blk_free(&block);
6357 __kmp_str_buf_free(&buffer);
6364void __kmp_env_dump() {
6366 kmp_env_blk_t block;
6367 kmp_str_buf_t buffer, env, notdefined;
6370 __kmp_str_buf_init(&buffer);
6371 __kmp_str_buf_init(&env);
6372 __kmp_str_buf_init(¬defined);
6374 __kmp_env_blk_init(&block, NULL);
6375 __kmp_env_blk_sort(&block);
6377 __kmp_str_buf_print(¬defined,
": %s", KMP_I18N_STR(NotDefined));
6379 for (
int i = 0; i < __kmp_stg_count; ++i) {
6380 if (__kmp_stg_table[i].print == NULL)
6382 __kmp_str_buf_clear(&env);
6383 __kmp_stg_table[i].print(&env, __kmp_stg_table[i].name,
6384 __kmp_stg_table[i].data);
6387 if (strstr(env.str, notdefined.str))
6389 __kmp_str_buf_print(&buffer,
"%s=undefined\n", __kmp_stg_table[i].name);
6391 __kmp_str_buf_cat(&buffer, env.str + 3, env.used - 3);
6394 ompd_env_block = (
char *)__kmp_allocate(buffer.used + 1);
6395 KMP_MEMCPY(ompd_env_block, buffer.str, buffer.used + 1);
6396 ompd_env_block_size = (ompd_size_t)KMP_STRLEN(ompd_env_block);
6398 __kmp_env_blk_free(&block);
6399 __kmp_str_buf_free(&buffer);
6400 __kmp_str_buf_free(&env);
6401 __kmp_str_buf_free(¬defined);
@ kmp_sch_modifier_monotonic
@ kmp_sch_modifier_nonmonotonic