14#include "kmp_affinity.h"
15#include "kmp_atomic.h"
17#include "kmp_dispatch_hier.h"
19#include "kmp_device_env.h"
20#include "kmp_environment.h"
25#include "kmp_settings.h"
27#include "kmp_traits.h"
28#include "kmp_wrapper_getpid.h"
31#include "ompd-specific.h"
34static int __kmp_env_toPrint(
char const *name,
int flag);
36bool __kmp_env_format = 0;
41#ifdef USE_LOAD_BALANCE
42static double __kmp_convert_to_double(
char const *s) {
45 if (KMP_SSCANF(s,
"%lf", &result) < 1) {
54static unsigned int __kmp_readstr_with_sentinel(
char *dest,
char const *src,
55 size_t len,
char sentinel) {
57 for (i = 0; i < len; i++) {
58 if ((*src ==
'\0') || (*src == sentinel)) {
68static int __kmp_match_with_sentinel(
char const *a,
char const *b,
size_t len,
76 while (*a && *b && *b != sentinel) {
77 char ca = *a, cb = *b;
79 if (ca >=
'a' && ca <=
'z')
81 if (cb >=
'a' && cb <=
'z')
115static int __kmp_match_str(
char const *token,
char const *buf,
118 KMP_ASSERT(token != NULL);
119 KMP_ASSERT(buf != NULL);
120 KMP_ASSERT(end != NULL);
122 while (*token && *buf) {
123 char ct = *token, cb = *buf;
125 if (ct >=
'a' && ct <=
'z')
127 if (cb >=
'a' && cb <=
'z')
142static size_t __kmp_round4k(
size_t size) {
143 size_t _4k = 4 * 1024;
144 if (size & (_4k - 1)) {
146 if (size <= KMP_SIZE_T_MAX - _4k) {
154static int __kmp_strcasecmp_with_sentinel(
char const *a,
char const *b,
160 while (*a && *b && *b != sentinel) {
161 char ca = *a, cb = *b;
163 if (ca >=
'a' && ca <=
'z')
165 if (cb >=
'a' && cb <=
'z')
168 return (
int)(
unsigned char)*a - (
int)(
unsigned char)*b;
172 return *a ? (*b && *b != sentinel)
173 ? (
int)(
unsigned char)*a - (
int)(
unsigned char)*b
175 : (*b && *b != sentinel) ? -1
182typedef struct __kmp_setting kmp_setting_t;
183typedef struct __kmp_stg_ss_data kmp_stg_ss_data_t;
184typedef struct __kmp_stg_wp_data kmp_stg_wp_data_t;
185typedef struct __kmp_stg_fr_data kmp_stg_fr_data_t;
187typedef void (*kmp_stg_parse_func_t)(
char const *name,
char const *value,
189typedef void (*kmp_stg_print_func_t)(kmp_str_buf_t *buffer,
char const *name,
192struct __kmp_setting {
194 kmp_stg_parse_func_t parse;
195 kmp_stg_print_func_t print;
202struct __kmp_stg_ss_data {
204 kmp_setting_t **rivals;
207struct __kmp_stg_wp_data {
209 kmp_setting_t **rivals;
212struct __kmp_stg_fr_data {
214 kmp_setting_t **rivals;
217static int __kmp_stg_check_rivals(
220 kmp_setting_t **rivals
224struct kmp_trimmed_str_t {
226 kmp_trimmed_str_t(
const char *str) {
227 __kmp_str_buf_init(&buf);
228 size_t len = KMP_STRLEN(str);
231 const char *begin = str;
232 const char *end = str + KMP_STRLEN(str) - 1;
234 while (begin < end && *end ==
' ')
236 __kmp_str_buf_cat(&buf, begin, end - begin + 1);
238 ~kmp_trimmed_str_t() { __kmp_str_buf_free(&buf); }
239 const char *get() {
return buf.str; }
245static void __kmp_stg_parse_bool(
char const *name,
char const *value,
247 if (__kmp_str_match_true(value)) {
249 }
else if (__kmp_str_match_false(value)) {
252 __kmp_msg(kmp_ms_warning, KMP_MSG(BadBoolValue, name, value),
253 KMP_HNT(ValidBoolValues), __kmp_msg_null);
258void __kmp_check_stksize(
size_t *val) {
261 if (*val > KMP_DEFAULT_STKSIZE * 2)
262 *val = KMP_DEFAULT_STKSIZE * 2;
264 if (*val > KMP_DEFAULT_STKSIZE * 16)
265 *val = KMP_DEFAULT_STKSIZE * 16;
267 if (*val < __kmp_sys_min_stksize)
268 *val = __kmp_sys_min_stksize;
269 if (*val > KMP_MAX_STKSIZE)
270 *val = KMP_MAX_STKSIZE;
272 *val = __kmp_round4k(*val);
276static void __kmp_stg_parse_size(
char const *name,
char const *value,
277 size_t size_min,
size_t size_max,
278 int *is_specified,
size_t *out,
280 char const *msg = NULL;
282 size_min = __kmp_round4k(size_min);
283 size_max = __kmp_round4k(size_max);
286 if (is_specified != NULL) {
289 __kmp_str_to_size(value, out, factor, &msg);
291 if (*out > size_max) {
293 msg = KMP_I18N_STR(ValueTooLarge);
294 }
else if (*out < size_min) {
296 msg = KMP_I18N_STR(ValueTooSmall);
299 size_t round4k = __kmp_round4k(*out);
300 if (*out != round4k) {
302 msg = KMP_I18N_STR(NotMultiple4K);
309 if (*out < size_min) {
311 }
else if (*out > size_max) {
318 __kmp_str_buf_init(&buf);
319 __kmp_str_buf_print_size(&buf, *out);
320 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
321 KMP_INFORM(Using_str_Value, name, buf.str);
322 __kmp_str_buf_free(&buf);
327static void __kmp_stg_parse_str(
char const *name,
char const *value,
330 *out = __kmp_str_format(
"%s", value);
333static void __kmp_stg_parse_int(
341 char const *msg = NULL;
342 kmp_uint64 uint = *out;
343 __kmp_str_to_uint(value, &uint, &msg);
345 if (uint < (
unsigned int)min) {
346 msg = KMP_I18N_STR(ValueTooSmall);
348 }
else if (uint > (
unsigned int)max) {
349 msg = KMP_I18N_STR(ValueTooLarge);
355 if (uint < (
unsigned int)min) {
357 }
else if (uint > (
unsigned int)max) {
364 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
365 __kmp_str_buf_init(&buf);
366 __kmp_str_buf_print(&buf,
"%" KMP_UINT64_SPEC
"", uint);
367 KMP_INFORM(Using_uint64_Value, name, buf.str);
368 __kmp_str_buf_free(&buf);
370 __kmp_type_convert(uint, out);
373#if KMP_DEBUG_ADAPTIVE_LOCKS
374static void __kmp_stg_parse_file(
char const *name,
char const *value,
375 const char *suffix,
char **out) {
380 t = (
char *)strrchr(value,
'.');
381 hasSuffix = t && __kmp_str_eqf(t, suffix);
382 t = __kmp_str_format(
"%s%s", value, hasSuffix ?
"" : suffix);
383 __kmp_expand_file_name(buffer,
sizeof(buffer), t);
385 *out = __kmp_str_format(
"%s", buffer);
390static char *par_range_to_print = NULL;
392static void __kmp_stg_parse_par_range(
char const *name,
char const *value,
393 int *out_range,
char *out_routine,
394 char *out_file,
int *out_lb,
396 const char *par_range_value;
397 size_t len = KMP_STRLEN(value) + 1;
398 par_range_to_print = (
char *)KMP_INTERNAL_MALLOC(len + 1);
399 KMP_STRNCPY_S(par_range_to_print, len + 1, value, len + 1);
400 __kmp_par_range = +1;
401 __kmp_par_range_lb = 0;
402 __kmp_par_range_ub = INT_MAX;
405 if (!value || *value ==
'\0') {
408 if (!__kmp_strcasecmp_with_sentinel(
"routine", value,
'=')) {
409 par_range_value = strchr(value,
'=') + 1;
410 if (!par_range_value)
411 goto par_range_error;
412 value = par_range_value;
413 len = __kmp_readstr_with_sentinel(out_routine, value,
414 KMP_PAR_RANGE_ROUTINE_LEN - 1,
',');
416 goto par_range_error;
418 value = strchr(value,
',');
424 if (!__kmp_strcasecmp_with_sentinel(
"filename", value,
'=')) {
425 par_range_value = strchr(value,
'=') + 1;
426 if (!par_range_value)
427 goto par_range_error;
428 value = par_range_value;
429 len = __kmp_readstr_with_sentinel(out_file, value,
430 KMP_PAR_RANGE_FILENAME_LEN - 1,
',');
432 goto par_range_error;
434 value = strchr(value,
',');
440 if ((!__kmp_strcasecmp_with_sentinel(
"range", value,
'=')) ||
441 (!__kmp_strcasecmp_with_sentinel(
"incl_range", value,
'='))) {
442 par_range_value = strchr(value,
'=') + 1;
443 if (!par_range_value)
444 goto par_range_error;
445 value = par_range_value;
446 if (KMP_SSCANF(value,
"%d:%d", out_lb, out_ub) != 2) {
447 goto par_range_error;
450 value = strchr(value,
',');
456 if (!__kmp_strcasecmp_with_sentinel(
"excl_range", value,
'=')) {
457 par_range_value = strchr(value,
'=') + 1;
458 if (!par_range_value)
459 goto par_range_error;
460 value = par_range_value;
461 if (KMP_SSCANF(value,
"%d:%d", out_lb, out_ub) != 2) {
462 goto par_range_error;
465 value = strchr(value,
',');
472 KMP_WARNING(ParRangeSyntax, name);
479int __kmp_initial_threads_capacity(
int req_nproc) {
484 if (nth < (4 * req_nproc))
485 nth = (4 * req_nproc);
486 if (nth < (4 * __kmp_xproc))
487 nth = (4 * __kmp_xproc);
491 if (__kmp_enable_hidden_helper) {
492 nth += __kmp_hidden_helper_threads_num;
495 if (nth > __kmp_max_nth)
501int __kmp_default_tp_capacity(
int req_nproc,
int max_nth,
502 int all_threads_specified) {
505 if (all_threads_specified)
509 if (nth < (4 * req_nproc))
510 nth = (4 * req_nproc);
511 if (nth < (4 * __kmp_xproc))
512 nth = (4 * __kmp_xproc);
514 if (nth > __kmp_max_nth)
523static void __kmp_stg_print_bool(kmp_str_buf_t *buffer,
char const *name,
525 if (__kmp_env_format) {
526 KMP_STR_BUF_PRINT_BOOL;
528 __kmp_str_buf_print(buffer,
" %s=%s\n", name, value ?
"true" :
"false");
532static void __kmp_stg_print_int(kmp_str_buf_t *buffer,
char const *name,
534 if (__kmp_env_format) {
535 KMP_STR_BUF_PRINT_INT;
537 __kmp_str_buf_print(buffer,
" %s=%d\n", name, value);
541static void __kmp_stg_print_uint64(kmp_str_buf_t *buffer,
char const *name,
543 if (__kmp_env_format) {
544 KMP_STR_BUF_PRINT_UINT64;
546 __kmp_str_buf_print(buffer,
" %s=%" KMP_UINT64_SPEC
"\n", name, value);
550static void __kmp_stg_print_str(kmp_str_buf_t *buffer,
char const *name,
552 if (__kmp_env_format) {
553 KMP_STR_BUF_PRINT_STR;
555 __kmp_str_buf_print(buffer,
" %s=%s\n", name, value);
559static void __kmp_stg_print_size(kmp_str_buf_t *buffer,
char const *name,
561 if (__kmp_env_format) {
562 KMP_STR_BUF_PRINT_NAME_EX(name);
563 __kmp_str_buf_print_size(buffer, value);
564 __kmp_str_buf_print(buffer,
"'\n");
566 __kmp_str_buf_print(buffer,
" %s=", name);
567 __kmp_str_buf_print_size(buffer, value);
568 __kmp_str_buf_print(buffer,
"\n");
579static void __kmp_stg_parse_device_thread_limit(
char const *name,
580 char const *value,
void *data) {
581 kmp_setting_t **rivals = (kmp_setting_t **)data;
583 if (strcmp(name,
"KMP_ALL_THREADS") == 0) {
584 KMP_INFORM(EnvVarDeprecated, name,
"KMP_DEVICE_THREAD_LIMIT");
586 rc = __kmp_stg_check_rivals(name, value, rivals);
590 if (!__kmp_strcasecmp_with_sentinel(
"all", value, 0)) {
591 __kmp_max_nth = __kmp_xproc;
592 __kmp_allThreadsSpecified = 1;
594 __kmp_stg_parse_int(name, value, 1, __kmp_sys_max_nth, &__kmp_max_nth);
595 __kmp_allThreadsSpecified = 0;
597 K_DIAG(1, (
"__kmp_max_nth == %d\n", __kmp_max_nth));
601static void __kmp_stg_print_device_thread_limit(kmp_str_buf_t *buffer,
602 char const *name,
void *data) {
603 __kmp_stg_print_int(buffer, name, __kmp_max_nth);
608static void __kmp_stg_parse_thread_limit(
char const *name,
char const *value,
610 __kmp_stg_parse_int(name, value, 1, __kmp_sys_max_nth, &__kmp_cg_max_nth);
611 K_DIAG(1, (
"__kmp_cg_max_nth == %d\n", __kmp_cg_max_nth));
615static void __kmp_stg_print_thread_limit(kmp_str_buf_t *buffer,
616 char const *name,
void *data) {
617 __kmp_stg_print_int(buffer, name, __kmp_cg_max_nth);
622static void __kmp_stg_parse_nteams(
char const *name,
char const *value,
624 __kmp_stg_parse_int(name, value, 1, __kmp_sys_max_nth, &__kmp_nteams);
625 K_DIAG(1, (
"__kmp_nteams == %d\n", __kmp_nteams));
628static void __kmp_stg_print_nteams(kmp_str_buf_t *buffer,
char const *name,
630 __kmp_stg_print_int(buffer, name, __kmp_nteams);
635static void __kmp_stg_parse_teams_th_limit(
char const *name,
char const *value,
637 __kmp_stg_parse_int(name, value, 1, __kmp_sys_max_nth,
638 &__kmp_teams_thread_limit);
639 K_DIAG(1, (
"__kmp_teams_thread_limit == %d\n", __kmp_teams_thread_limit));
642static void __kmp_stg_print_teams_th_limit(kmp_str_buf_t *buffer,
643 char const *name,
void *data) {
644 __kmp_stg_print_int(buffer, name, __kmp_teams_thread_limit);
649static void __kmp_stg_parse_teams_thread_limit(
char const *name,
650 char const *value,
void *data) {
651 __kmp_stg_parse_int(name, value, 1, __kmp_sys_max_nth, &__kmp_teams_max_nth);
654static void __kmp_stg_print_teams_thread_limit(kmp_str_buf_t *buffer,
655 char const *name,
void *data) {
656 __kmp_stg_print_int(buffer, name, __kmp_teams_max_nth);
661static void __kmp_stg_parse_use_yield(
char const *name,
char const *value,
663 __kmp_stg_parse_int(name, value, 0, 2, &__kmp_use_yield);
664 __kmp_use_yield_exp_set = 1;
667static void __kmp_stg_print_use_yield(kmp_str_buf_t *buffer,
char const *name,
669 __kmp_stg_print_int(buffer, name, __kmp_use_yield);
675static void __kmp_stg_parse_blocktime(
char const *name,
char const *value,
677 const char *buf = value;
679 const int ms_mult = 1000;
685 if ((*buf >=
'0') && (*buf <=
'9')) {
688 num = __kmp_basic_str_to_int(buf);
689 KMP_ASSERT(num >= 0);
698 if (*buf ==
'\0' || __kmp_match_str(
"ms", buf, &next)) {
700 __kmp_dflt_blocktime = ms_mult * num;
701 __kmp_blocktime_units =
'm';
702 multiplier = ms_mult;
703 }
else if (__kmp_match_str(
"us", buf, &next)) {
705 __kmp_dflt_blocktime = num;
706 __kmp_blocktime_units =
'u';
707 }
else if (__kmp_match_str(
"infinite", buf, &next) ||
708 __kmp_match_str(
"infinity", buf, &next)) {
710 __kmp_dflt_blocktime = KMP_MAX_BLOCKTIME;
711 __kmp_blocktime_units =
'm';
712 multiplier = ms_mult;
714 KMP_WARNING(StgInvalidValue, name, value);
716 __kmp_dflt_blocktime = ms_mult * num;
717 __kmp_blocktime_units =
'm';
718 multiplier = ms_mult;
721 if (num < 0 && __kmp_dflt_blocktime < 0) {
722 __kmp_dflt_blocktime = KMP_DEFAULT_BLOCKTIME;
723 __kmp_msg(kmp_ms_warning, KMP_MSG(InvalidValue, name, value),
726 KMP_INFORM(Using_int_Value, name, __kmp_dflt_blocktime / multiplier);
727 __kmp_env_blocktime = FALSE;
728 }
else if (num > 0 && __kmp_dflt_blocktime < 0) {
729 __kmp_dflt_blocktime = KMP_MAX_BLOCKTIME;
730 __kmp_msg(kmp_ms_warning, KMP_MSG(LargeValue, name, value), __kmp_msg_null);
731 KMP_INFORM(MaxValueUsing, name, __kmp_dflt_blocktime / multiplier);
732 __kmp_env_blocktime = TRUE;
734 if (__kmp_dflt_blocktime < KMP_MIN_BLOCKTIME) {
735 __kmp_dflt_blocktime = KMP_MIN_BLOCKTIME;
736 __kmp_msg(kmp_ms_warning, KMP_MSG(SmallValue, name, value),
738 KMP_INFORM(MinValueUsing, name, __kmp_dflt_blocktime / multiplier);
739 }
else if (__kmp_dflt_blocktime > KMP_MAX_BLOCKTIME) {
740 __kmp_dflt_blocktime = KMP_MAX_BLOCKTIME;
741 __kmp_msg(kmp_ms_warning, KMP_MSG(LargeValue, name, value),
743 KMP_INFORM(MaxValueUsing, name, __kmp_dflt_blocktime / multiplier);
745 __kmp_env_blocktime = TRUE;
750 __kmp_monitor_wakeups =
751 KMP_WAKEUPS_FROM_BLOCKTIME(__kmp_dflt_blocktime, __kmp_monitor_wakeups);
753 KMP_INTERVALS_FROM_BLOCKTIME(__kmp_dflt_blocktime, __kmp_monitor_wakeups);
755 K_DIAG(1, (
"__kmp_env_blocktime == %d\n", __kmp_env_blocktime));
756 if (__kmp_env_blocktime) {
757 K_DIAG(1, (
"__kmp_dflt_blocktime == %d\n", __kmp_dflt_blocktime));
761static void __kmp_stg_print_blocktime(kmp_str_buf_t *buffer,
char const *name,
763 int num = __kmp_dflt_blocktime;
764 if (__kmp_blocktime_units ==
'm') {
767 if (__kmp_env_format) {
768 KMP_STR_BUF_PRINT_NAME_EX(name);
770 __kmp_str_buf_print(buffer,
" %s=", name);
772 __kmp_str_buf_print(buffer,
"%d", num);
773 __kmp_str_buf_print(buffer,
"%cs\n", __kmp_blocktime_units);
779static void __kmp_stg_parse_duplicate_lib_ok(
char const *name,
780 char const *value,
void *data) {
783 __kmp_stg_parse_bool(name, value, &__kmp_duplicate_library_ok);
786static void __kmp_stg_print_duplicate_lib_ok(kmp_str_buf_t *buffer,
787 char const *name,
void *data) {
788 __kmp_stg_print_bool(buffer, name, __kmp_duplicate_library_ok);
794#if KMP_ARCH_X86 || KMP_ARCH_X86_64
796static void __kmp_stg_parse_inherit_fp_control(
char const *name,
797 char const *value,
void *data) {
798 __kmp_stg_parse_bool(name, value, &__kmp_inherit_fp_control);
801static void __kmp_stg_print_inherit_fp_control(kmp_str_buf_t *buffer,
802 char const *name,
void *data) {
804 __kmp_stg_print_bool(buffer, name, __kmp_inherit_fp_control);
811static char const *blocktime_str = NULL;
812static char const *use_yield_str = NULL;
817static void __kmp_stg_parse_wait_policy(
char const *name,
char const *value,
820 kmp_stg_wp_data_t *wait = (kmp_stg_wp_data_t *)data;
823 rc = __kmp_stg_check_rivals(name, value, wait->rivals);
829 if (__kmp_str_match(
"ACTIVE", 1, value)) {
830 __kmp_library = library_turnaround;
831 if (blocktime_str == NULL) {
833 __kmp_dflt_blocktime = KMP_MAX_BLOCKTIME;
835 if (use_yield_str == NULL) {
839 }
else if (__kmp_str_match(
"PASSIVE", 1, value)) {
840 __kmp_library = library_throughput;
841 __kmp_wpolicy_passive =
true;
842 if (blocktime_str == NULL) {
844 __kmp_dflt_blocktime = 0;
847 KMP_WARNING(StgInvalidValue, name, value);
850 if (__kmp_str_match(
"serial", 1, value)) {
851 __kmp_library = library_serial;
852 }
else if (__kmp_str_match(
"throughput", 2, value)) {
853 __kmp_library = library_throughput;
854 if (blocktime_str == NULL) {
856 __kmp_dflt_blocktime = 0;
858 }
else if (__kmp_str_match(
"turnaround", 2, value)) {
859 __kmp_library = library_turnaround;
860 }
else if (__kmp_str_match(
"dedicated", 1, value)) {
861 __kmp_library = library_turnaround;
862 }
else if (__kmp_str_match(
"multiuser", 1, value)) {
863 __kmp_library = library_throughput;
864 if (blocktime_str == NULL) {
866 __kmp_dflt_blocktime = 0;
869 KMP_WARNING(StgInvalidValue, name, value);
874static void __kmp_stg_print_wait_policy(kmp_str_buf_t *buffer,
char const *name,
877 kmp_stg_wp_data_t *wait = (kmp_stg_wp_data_t *)data;
878 char const *value = NULL;
881 switch (__kmp_library) {
882 case library_turnaround: {
885 case library_throughput: {
889 case library_serial: {
894 switch (__kmp_library) {
895 case library_serial: {
898 case library_turnaround: {
899 value =
"turnaround";
901 case library_throughput: {
902 value =
"throughput";
910 __kmp_stg_print_str(buffer, name, value);
919static void __kmp_stg_parse_monitor_stacksize(
char const *name,
920 char const *value,
void *data) {
921 __kmp_stg_parse_size(name, value, __kmp_sys_min_stksize, KMP_MAX_STKSIZE,
922 NULL, &__kmp_monitor_stksize, 1);
925static void __kmp_stg_print_monitor_stacksize(kmp_str_buf_t *buffer,
926 char const *name,
void *data) {
927 if (__kmp_env_format) {
928 if (__kmp_monitor_stksize > 0)
929 KMP_STR_BUF_PRINT_NAME_EX(name);
931 KMP_STR_BUF_PRINT_NAME;
933 __kmp_str_buf_print(buffer,
" %s", name);
935 if (__kmp_monitor_stksize > 0) {
936 __kmp_str_buf_print_size(buffer, __kmp_monitor_stksize);
938 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
940 if (__kmp_env_format && __kmp_monitor_stksize) {
941 __kmp_str_buf_print(buffer,
"'\n");
949static void __kmp_stg_parse_settings(
char const *name,
char const *value,
951 __kmp_stg_parse_bool(name, value, &__kmp_settings);
954static void __kmp_stg_print_settings(kmp_str_buf_t *buffer,
char const *name,
956 __kmp_stg_print_bool(buffer, name, __kmp_settings);
962static void __kmp_stg_parse_stackpad(
char const *name,
char const *value,
964 __kmp_stg_parse_int(name,
972static void __kmp_stg_print_stackpad(kmp_str_buf_t *buffer,
char const *name,
974 __kmp_stg_print_int(buffer, name, __kmp_stkpadding);
980static void __kmp_stg_parse_stackoffset(
char const *name,
char const *value,
982 __kmp_stg_parse_size(name,
991static void __kmp_stg_print_stackoffset(kmp_str_buf_t *buffer,
char const *name,
993 __kmp_stg_print_size(buffer, name, __kmp_stkoffset);
999static void __kmp_stg_parse_stacksize(
char const *name,
char const *value,
1002 kmp_stg_ss_data_t *stacksize = (kmp_stg_ss_data_t *)data;
1005 rc = __kmp_stg_check_rivals(name, value, stacksize->rivals);
1009 __kmp_stg_parse_size(name,
1011 __kmp_sys_min_stksize,
1023static void __kmp_stg_print_stacksize(kmp_str_buf_t *buffer,
char const *name,
1025 kmp_stg_ss_data_t *stacksize = (kmp_stg_ss_data_t *)data;
1026 if (__kmp_env_format) {
1027 KMP_STR_BUF_PRINT_NAME_EX(name);
1028 __kmp_str_buf_print_size(buffer, (__kmp_stksize % 1024)
1029 ? __kmp_stksize / stacksize->factor
1031 __kmp_str_buf_print(buffer,
"'\n");
1033 __kmp_str_buf_print(buffer,
" %s=", name);
1034 __kmp_str_buf_print_size(buffer, (__kmp_stksize % 1024)
1035 ? __kmp_stksize / stacksize->factor
1037 __kmp_str_buf_print(buffer,
"\n");
1044static void __kmp_stg_parse_version(
char const *name,
char const *value,
1046 __kmp_stg_parse_bool(name, value, &__kmp_version);
1049static void __kmp_stg_print_version(kmp_str_buf_t *buffer,
char const *name,
1051 __kmp_stg_print_bool(buffer, name, __kmp_version);
1057static void __kmp_stg_parse_warnings(
char const *name,
char const *value,
1059 __kmp_stg_parse_bool(name, value, &__kmp_generate_warnings);
1060 if (__kmp_generate_warnings != kmp_warnings_off) {
1063 __kmp_generate_warnings = kmp_warnings_explicit;
1067static void __kmp_stg_print_warnings(kmp_str_buf_t *buffer,
char const *name,
1070 __kmp_stg_print_bool(buffer, name, __kmp_generate_warnings);
1076static void __kmp_stg_parse_nesting_mode(
char const *name,
char const *value,
1078 __kmp_stg_parse_int(name, value, 0, INT_MAX, &__kmp_nesting_mode);
1079#if KMP_HWLOC_ENABLED
1080 if (__kmp_nesting_mode > 0)
1081 __kmp_affinity_top_method = affinity_top_method_hwloc;
1085static void __kmp_stg_print_nesting_mode(kmp_str_buf_t *buffer,
1086 char const *name,
void *data) {
1087 if (__kmp_env_format) {
1088 KMP_STR_BUF_PRINT_NAME;
1090 __kmp_str_buf_print(buffer,
" %s", name);
1092 __kmp_str_buf_print(buffer,
"=%d\n", __kmp_nesting_mode);
1098static void __kmp_stg_parse_nested(
char const *name,
char const *value,
1101 KMP_INFORM(EnvVarDeprecated, name,
"OMP_MAX_ACTIVE_LEVELS");
1102 __kmp_stg_parse_bool(name, value, &nested);
1104 if (!__kmp_dflt_max_active_levels_set)
1105 __kmp_dflt_max_active_levels = KMP_MAX_ACTIVE_LEVELS_LIMIT;
1107 __kmp_dflt_max_active_levels = 1;
1108 __kmp_dflt_max_active_levels_set =
true;
1112static void __kmp_stg_print_nested(kmp_str_buf_t *buffer,
char const *name,
1114 if (__kmp_env_format) {
1115 KMP_STR_BUF_PRINT_NAME;
1117 __kmp_str_buf_print(buffer,
" %s", name);
1119 __kmp_str_buf_print(buffer,
": deprecated; max-active-levels-var=%d\n",
1120 __kmp_dflt_max_active_levels);
1123static void __kmp_parse_nested_num_threads(
const char *var,
const char *env,
1124 kmp_nested_nthreads_t *nth_array) {
1125 const char *next = env;
1126 const char *scan = next;
1129 int prev_comma = FALSE;
1135 if (*next ==
'\0') {
1139 if (((*next <
'0') || (*next >
'9')) && (*next !=
',')) {
1140 KMP_WARNING(NthSyntaxError, var, env);
1146 if (total == 0 || prev_comma) {
1154 if (*next >=
'0' && *next <=
'9') {
1158 const char *tmp = next;
1160 if ((*next ==
' ' || *next ==
'\t') && (*tmp >=
'0' && *tmp <=
'9')) {
1161 KMP_WARNING(NthSpacesNotAllowed, var, env);
1166 if (!__kmp_dflt_max_active_levels_set && total > 1)
1167 __kmp_dflt_max_active_levels = KMP_MAX_ACTIVE_LEVELS_LIMIT;
1169 KMP_WARNING(NthSyntaxError, var, env);
1174 if (!nth_array->nth) {
1176 nth_array->nth = (
int *)KMP_INTERNAL_MALLOC(
sizeof(
int) * total * 2);
1177 if (nth_array->nth == NULL) {
1178 KMP_FATAL(MemoryAllocFailed);
1180 nth_array->size = total * 2;
1182 if (nth_array->size < total) {
1185 nth_array->size *= 2;
1186 }
while (nth_array->size < total);
1188 nth_array->nth = (
int *)KMP_INTERNAL_REALLOC(
1189 nth_array->nth,
sizeof(
int) * nth_array->size);
1190 if (nth_array->nth == NULL) {
1191 KMP_FATAL(MemoryAllocFailed);
1195 nth_array->used = total;
1203 if (*scan ==
'\0') {
1213 nth_array->nth[i++] = 0;
1215 }
else if (prev_comma) {
1217 nth_array->nth[i] = nth_array->nth[i - 1];
1226 if (*scan >=
'0' && *scan <=
'9') {
1228 const char *buf = scan;
1229 char const *msg = NULL;
1234 num = __kmp_str_to_int(buf, *scan);
1235 if (num < KMP_MIN_NTH) {
1236 msg = KMP_I18N_STR(ValueTooSmall);
1238 }
else if (num > __kmp_sys_max_nth) {
1239 msg = KMP_I18N_STR(ValueTooLarge);
1240 num = __kmp_sys_max_nth;
1244 KMP_WARNING(ParseSizeIntWarn, var, env, msg);
1245 KMP_INFORM(Using_int_Value, var, num);
1247 nth_array->nth[i++] = num;
1252static void __kmp_stg_parse_num_threads(
char const *name,
char const *value,
1255 if (!__kmp_strcasecmp_with_sentinel(
"all", value, 0)) {
1257 if (!__kmp_nested_nth.nth) {
1258 __kmp_nested_nth.nth = (
int *)KMP_INTERNAL_MALLOC(
sizeof(
int));
1259 __kmp_nested_nth.size = 1;
1261 __kmp_nested_nth.used = 1;
1262 __kmp_nested_nth.nth[0] = __kmp_dflt_team_nth = __kmp_dflt_team_nth_ub =
1265 __kmp_parse_nested_num_threads(name, value, &__kmp_nested_nth);
1266 if (__kmp_nested_nth.nth) {
1267 __kmp_dflt_team_nth = __kmp_nested_nth.nth[0];
1268 if (__kmp_dflt_team_nth_ub < __kmp_dflt_team_nth) {
1269 __kmp_dflt_team_nth_ub = __kmp_dflt_team_nth;
1273 K_DIAG(1, (
"__kmp_dflt_team_nth == %d\n", __kmp_dflt_team_nth));
1276#if OMP_TASKGRAPH_EXPERIMENTAL
1277static void __kmp_stg_parse_max_tdgs(
char const *name,
char const *value,
1279 __kmp_stg_parse_int(name, value, 0, INT_MAX, &__kmp_max_tdgs);
1282static void __kmp_std_print_max_tdgs(kmp_str_buf_t *buffer,
char const *name,
1284 __kmp_stg_print_int(buffer, name, __kmp_max_tdgs);
1287static void __kmp_stg_parse_tdg_dot(
char const *name,
char const *value,
1289 __kmp_stg_parse_bool(name, value, &__kmp_tdg_dot);
1292static void __kmp_stg_print_tdg_dot(kmp_str_buf_t *buffer,
char const *name,
1294 __kmp_stg_print_bool(buffer, name, __kmp_tdg_dot);
1298static void __kmp_stg_parse_num_hidden_helper_threads(
char const *name,
1301 __kmp_stg_parse_int(name, value, 0, 16, &__kmp_hidden_helper_threads_num);
1304 if (__kmp_hidden_helper_threads_num == 0) {
1305 __kmp_enable_hidden_helper = FALSE;
1310 __kmp_hidden_helper_threads_num++;
1314static void __kmp_stg_print_num_hidden_helper_threads(kmp_str_buf_t *buffer,
1317 if (__kmp_hidden_helper_threads_num == 0) {
1318 __kmp_stg_print_int(buffer, name, __kmp_hidden_helper_threads_num);
1320 KMP_DEBUG_ASSERT(__kmp_hidden_helper_threads_num > 1);
1323 __kmp_stg_print_int(buffer, name, __kmp_hidden_helper_threads_num - 1);
1327static void __kmp_stg_parse_use_hidden_helper(
char const *name,
1328 char const *value,
void *data) {
1329 __kmp_stg_parse_bool(name, value, &__kmp_enable_hidden_helper);
1331 __kmp_enable_hidden_helper = FALSE;
1333 (
"__kmp_stg_parse_use_hidden_helper: Disable hidden helper task on "
1334 "non-Linux platform although it is enabled by user explicitly.\n"));
1338static void __kmp_stg_print_use_hidden_helper(kmp_str_buf_t *buffer,
1339 char const *name,
void *data) {
1340 __kmp_stg_print_bool(buffer, name, __kmp_enable_hidden_helper);
1343static void __kmp_stg_print_num_threads(kmp_str_buf_t *buffer,
char const *name,
1345 if (__kmp_env_format) {
1346 KMP_STR_BUF_PRINT_NAME;
1348 __kmp_str_buf_print(buffer,
" %s", name);
1350 if (__kmp_nested_nth.used) {
1352 __kmp_str_buf_init(&buf);
1353 for (
int i = 0; i < __kmp_nested_nth.used; i++) {
1354 __kmp_str_buf_print(&buf,
"%d", __kmp_nested_nth.nth[i]);
1355 if (i < __kmp_nested_nth.used - 1) {
1356 __kmp_str_buf_print(&buf,
",");
1359 __kmp_str_buf_print(buffer,
"='%s'\n", buf.str);
1360 __kmp_str_buf_free(&buf);
1362 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
1369static void __kmp_stg_parse_tasking(
char const *name,
char const *value,
1371 __kmp_stg_parse_int(name, value, 0, (
int)tskm_max,
1372 (
int *)&__kmp_tasking_mode);
1374 if (__kmp_tasking_mode == tskm_extra_barrier) {
1375 KMP_WARNING(StgInvalidValue, name, value);
1376 __kmp_tasking_mode = tskm_task_teams;
1380static void __kmp_stg_print_tasking(kmp_str_buf_t *buffer,
char const *name,
1382 __kmp_stg_print_int(buffer, name, __kmp_tasking_mode);
1385static void __kmp_stg_parse_task_stealing(
char const *name,
char const *value,
1387 __kmp_stg_parse_int(name, value, 0, 1,
1388 (
int *)&__kmp_task_stealing_constraint);
1391static void __kmp_stg_print_task_stealing(kmp_str_buf_t *buffer,
1392 char const *name,
void *data) {
1393 __kmp_stg_print_int(buffer, name, __kmp_task_stealing_constraint);
1396static void __kmp_stg_parse_max_active_levels(
char const *name,
1397 char const *value,
void *data) {
1398 kmp_uint64 tmp_dflt = 0;
1399 char const *msg = NULL;
1400 if (!__kmp_dflt_max_active_levels_set) {
1402 __kmp_str_to_uint(value, &tmp_dflt, &msg);
1404 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
1405 }
else if (tmp_dflt > KMP_MAX_ACTIVE_LEVELS_LIMIT) {
1407 msg = KMP_I18N_STR(ValueTooLarge);
1408 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
1410 __kmp_type_convert(tmp_dflt, &(__kmp_dflt_max_active_levels));
1411 __kmp_dflt_max_active_levels_set =
true;
1416static void __kmp_stg_print_max_active_levels(kmp_str_buf_t *buffer,
1417 char const *name,
void *data) {
1418 __kmp_stg_print_int(buffer, name, __kmp_dflt_max_active_levels);
1423static void __kmp_stg_parse_default_device(
char const *name,
char const *value,
1425 __kmp_default_device = kmp_trait_context::parse_single_device(
1426 value, 0, KMP_MAX_DEFAULT_DEVICE_LIMIT, name);
1429static void __kmp_stg_print_default_device(kmp_str_buf_t *buffer,
1430 char const *name,
void *data) {
1431 __kmp_stg_print_int(buffer, name, __kmp_default_device);
1436static void __kmp_stg_parse_target_offload(
char const *name,
char const *value,
1438 kmp_trimmed_str_t value_str(value);
1439 const char *scan = value_str.get();
1440 __kmp_target_offload = tgt_default;
1445 if (!__kmp_strcasecmp_with_sentinel(
"mandatory", scan, 0)) {
1446 __kmp_target_offload = tgt_mandatory;
1447 }
else if (!__kmp_strcasecmp_with_sentinel(
"disabled", scan, 0)) {
1448 __kmp_target_offload = tgt_disabled;
1449 }
else if (!__kmp_strcasecmp_with_sentinel(
"default", scan, 0)) {
1450 __kmp_target_offload = tgt_default;
1452 KMP_WARNING(SyntaxErrorUsing, name,
"DEFAULT");
1456static void __kmp_stg_print_target_offload(kmp_str_buf_t *buffer,
1457 char const *name,
void *data) {
1458 const char *value = NULL;
1459 if (__kmp_target_offload == tgt_default)
1461 else if (__kmp_target_offload == tgt_mandatory)
1462 value =
"MANDATORY";
1463 else if (__kmp_target_offload == tgt_disabled)
1465 KMP_DEBUG_ASSERT(value);
1466 if (__kmp_env_format) {
1467 KMP_STR_BUF_PRINT_NAME;
1469 __kmp_str_buf_print(buffer,
" %s", name);
1471 __kmp_str_buf_print(buffer,
"=%s\n", value);
1476static void __kmp_stg_parse_max_task_priority(
char const *name,
1477 char const *value,
void *data) {
1478 __kmp_stg_parse_int(name, value, 0, KMP_MAX_TASK_PRIORITY_LIMIT,
1479 &__kmp_max_task_priority);
1482static void __kmp_stg_print_max_task_priority(kmp_str_buf_t *buffer,
1483 char const *name,
void *data) {
1484 __kmp_stg_print_int(buffer, name, __kmp_max_task_priority);
1489static void __kmp_stg_parse_taskloop_min_tasks(
char const *name,
1490 char const *value,
void *data) {
1492 __kmp_stg_parse_int(name, value, 0, INT_MAX, &tmp);
1493 __kmp_taskloop_min_tasks = tmp;
1496static void __kmp_stg_print_taskloop_min_tasks(kmp_str_buf_t *buffer,
1497 char const *name,
void *data) {
1498 __kmp_stg_print_uint64(buffer, name, __kmp_taskloop_min_tasks);
1503static void __kmp_stg_parse_disp_buffers(
char const *name,
char const *value,
1505 if (TCR_4(__kmp_init_serial)) {
1506 KMP_WARNING(EnvSerialWarn, name);
1509 __kmp_stg_parse_int(name, value, KMP_MIN_DISP_NUM_BUFF, KMP_MAX_DISP_NUM_BUFF,
1510 &__kmp_dispatch_num_buffers);
1513static void __kmp_stg_print_disp_buffers(kmp_str_buf_t *buffer,
1514 char const *name,
void *data) {
1515 __kmp_stg_print_int(buffer, name, __kmp_dispatch_num_buffers);
1521static void __kmp_stg_parse_hot_teams_level(
char const *name,
char const *value,
1523 if (TCR_4(__kmp_init_parallel)) {
1524 KMP_WARNING(EnvParallelWarn, name);
1527 __kmp_stg_parse_int(name, value, 0, 1024, &__kmp_hot_teams_max_level);
1531static void __kmp_stg_print_hot_teams_level(kmp_str_buf_t *buffer,
1532 char const *name,
void *data) {
1533 __kmp_stg_print_int(buffer, name, __kmp_hot_teams_max_level);
1536static void __kmp_stg_parse_hot_teams_mode(
char const *name,
char const *value,
1538 if (TCR_4(__kmp_init_parallel)) {
1539 KMP_WARNING(EnvParallelWarn, name);
1542 __kmp_stg_parse_int(name, value, 0, KMP_MAX_ACTIVE_LEVELS_LIMIT,
1543 &__kmp_hot_teams_mode);
1546static void __kmp_stg_print_hot_teams_mode(kmp_str_buf_t *buffer,
1547 char const *name,
void *data) {
1548 __kmp_stg_print_int(buffer, name, __kmp_hot_teams_mode);
1554#if KMP_HANDLE_SIGNALS
1556static void __kmp_stg_parse_handle_signals(
char const *name,
char const *value,
1558 __kmp_stg_parse_bool(name, value, &__kmp_handle_signals);
1561static void __kmp_stg_print_handle_signals(kmp_str_buf_t *buffer,
1562 char const *name,
void *data) {
1563 __kmp_stg_print_bool(buffer, name, __kmp_handle_signals);
1573#define KMP_STG_X_DEBUG(x) \
1574 static void __kmp_stg_parse_##x##_debug(char const *name, char const *value, \
1576 __kmp_stg_parse_int(name, value, 0, INT_MAX, &kmp_##x##_debug); \
1578 static void __kmp_stg_print_##x##_debug(kmp_str_buf_t *buffer, \
1579 char const *name, void *data) { \
1580 __kmp_stg_print_int(buffer, name, kmp_##x##_debug); \
1590#undef KMP_STG_X_DEBUG
1592static void __kmp_stg_parse_debug(
char const *name,
char const *value,
1595 __kmp_stg_parse_int(name, value, 0, INT_MAX, &debug);
1596 if (kmp_a_debug < debug) {
1597 kmp_a_debug = debug;
1599 if (kmp_b_debug < debug) {
1600 kmp_b_debug = debug;
1602 if (kmp_c_debug < debug) {
1603 kmp_c_debug = debug;
1605 if (kmp_d_debug < debug) {
1606 kmp_d_debug = debug;
1608 if (kmp_e_debug < debug) {
1609 kmp_e_debug = debug;
1611 if (kmp_f_debug < debug) {
1612 kmp_f_debug = debug;
1616static void __kmp_stg_parse_debug_buf(
char const *name,
char const *value,
1618 __kmp_stg_parse_bool(name, value, &__kmp_debug_buf);
1622 if (__kmp_debug_buf) {
1624 int elements = __kmp_debug_buf_lines * __kmp_debug_buf_chars;
1627 __kmp_debug_buffer = (
char *)__kmp_page_allocate(elements *
sizeof(
char));
1628 for (i = 0; i < elements; i += __kmp_debug_buf_chars)
1629 __kmp_debug_buffer[i] =
'\0';
1631 __kmp_debug_count = 0;
1633 K_DIAG(1, (
"__kmp_debug_buf = %d\n", __kmp_debug_buf));
1636static void __kmp_stg_print_debug_buf(kmp_str_buf_t *buffer,
char const *name,
1638 __kmp_stg_print_bool(buffer, name, __kmp_debug_buf);
1641static void __kmp_stg_parse_debug_buf_atomic(
char const *name,
1642 char const *value,
void *data) {
1643 __kmp_stg_parse_bool(name, value, &__kmp_debug_buf_atomic);
1646static void __kmp_stg_print_debug_buf_atomic(kmp_str_buf_t *buffer,
1647 char const *name,
void *data) {
1648 __kmp_stg_print_bool(buffer, name, __kmp_debug_buf_atomic);
1651static void __kmp_stg_parse_debug_buf_chars(
char const *name,
char const *value,
1653 __kmp_stg_parse_int(name, value, KMP_DEBUG_BUF_CHARS_MIN, INT_MAX,
1654 &__kmp_debug_buf_chars);
1657static void __kmp_stg_print_debug_buf_chars(kmp_str_buf_t *buffer,
1658 char const *name,
void *data) {
1659 __kmp_stg_print_int(buffer, name, __kmp_debug_buf_chars);
1662static void __kmp_stg_parse_debug_buf_lines(
char const *name,
char const *value,
1664 __kmp_stg_parse_int(name, value, KMP_DEBUG_BUF_LINES_MIN, INT_MAX,
1665 &__kmp_debug_buf_lines);
1668static void __kmp_stg_print_debug_buf_lines(kmp_str_buf_t *buffer,
1669 char const *name,
void *data) {
1670 __kmp_stg_print_int(buffer, name, __kmp_debug_buf_lines);
1673static void __kmp_stg_parse_diag(
char const *name,
char const *value,
1675 __kmp_stg_parse_int(name, value, 0, INT_MAX, &kmp_diag);
1678static void __kmp_stg_print_diag(kmp_str_buf_t *buffer,
char const *name,
1680 __kmp_stg_print_int(buffer, name, kmp_diag);
1688static void __kmp_stg_parse_align_alloc(
char const *name,
char const *value,
1690 __kmp_stg_parse_size(name, value, CACHE_LINE, INT_MAX, NULL,
1691 &__kmp_align_alloc, 1);
1693 if (__kmp_align_alloc == 0 || ((__kmp_align_alloc - 1) & __kmp_align_alloc)) {
1694 KMP_WARNING(StgInvalidValue, name, value);
1695 __kmp_align_alloc = CACHE_LINE;
1699static void __kmp_stg_print_align_alloc(kmp_str_buf_t *buffer,
char const *name,
1701 __kmp_stg_print_size(buffer, name, __kmp_align_alloc);
1710static void __kmp_stg_parse_barrier_branch_bit(
char const *name,
1711 char const *value,
void *data) {
1715 for (
int i = bs_plain_barrier; i < bs_last_barrier; i++) {
1716 var = __kmp_barrier_branch_bit_env_name[i];
1717 if ((strcmp(var, name) == 0) && (value != 0)) {
1720 comma = CCAST(
char *, strchr(value,
','));
1721 __kmp_barrier_gather_branch_bits[i] =
1722 (kmp_uint32)__kmp_str_to_int(value,
',');
1724 if (comma == NULL) {
1725 __kmp_barrier_release_branch_bits[i] = __kmp_barrier_release_bb_dflt;
1727 __kmp_barrier_release_branch_bits[i] =
1728 (kmp_uint32)__kmp_str_to_int(comma + 1, 0);
1729 if (__kmp_barrier_release_branch_bits[i] == 0 ||
1730 __kmp_barrier_release_branch_bits[i] > KMP_MAX_BRANCH_BITS) {
1731 __kmp_msg(kmp_ms_warning,
1732 KMP_MSG(BarrReleaseValueInvalid, name, comma + 1),
1734 __kmp_barrier_release_branch_bits[i] = __kmp_barrier_release_bb_dflt;
1737 if (__kmp_barrier_gather_branch_bits[i] == 0 ||
1738 __kmp_barrier_gather_branch_bits[i] > KMP_MAX_BRANCH_BITS) {
1739 KMP_WARNING(BarrGatherValueInvalid, name, value);
1740 KMP_INFORM(Using_uint_Value, name, __kmp_barrier_gather_bb_dflt);
1741 __kmp_barrier_gather_branch_bits[i] = __kmp_barrier_gather_bb_dflt;
1744 K_DIAG(1, (
"%s == %d,%d\n", __kmp_barrier_branch_bit_env_name[i],
1745 __kmp_barrier_gather_branch_bits[i],
1746 __kmp_barrier_release_branch_bits[i]))
1750static void __kmp_stg_print_barrier_branch_bit(kmp_str_buf_t *buffer,
1751 char const *name,
void *data) {
1753 for (
int i = bs_plain_barrier; i < bs_last_barrier; i++) {
1754 var = __kmp_barrier_branch_bit_env_name[i];
1755 if (strcmp(var, name) == 0) {
1756 if (__kmp_env_format) {
1757 KMP_STR_BUF_PRINT_NAME_EX(__kmp_barrier_branch_bit_env_name[i]);
1759 __kmp_str_buf_print(buffer,
" %s='",
1760 __kmp_barrier_branch_bit_env_name[i]);
1762 __kmp_str_buf_print(buffer,
"%d,%d'\n",
1763 __kmp_barrier_gather_branch_bits[i],
1764 __kmp_barrier_release_branch_bits[i]);
1776static void __kmp_stg_parse_barrier_pattern(
char const *name,
char const *value,
1781 static int dist_req = 0, non_dist_req = 0;
1782 static bool warn = 1;
1783 for (
int i = bs_plain_barrier; i < bs_last_barrier; i++) {
1784 var = __kmp_barrier_pattern_env_name[i];
1786 if ((strcmp(var, name) == 0) && (value != 0)) {
1788 char *comma = CCAST(
char *, strchr(value,
','));
1791 for (j = bp_linear_bar; j < bp_last_bar; j++) {
1792 if (__kmp_match_with_sentinel(__kmp_barrier_pattern_name[j], value, 1,
1794 if (j == bp_dist_bar) {
1799 __kmp_barrier_gather_pattern[i] = (kmp_bar_pat_e)j;
1803 if (j == bp_last_bar) {
1804 KMP_WARNING(BarrGatherValueInvalid, name, value);
1805 KMP_INFORM(Using_str_Value, name,
1806 __kmp_barrier_pattern_name[bp_linear_bar]);
1810 if (comma != NULL) {
1811 for (j = bp_linear_bar; j < bp_last_bar; j++) {
1812 if (__kmp_str_match(__kmp_barrier_pattern_name[j], 1, comma + 1)) {
1813 if (j == bp_dist_bar) {
1818 __kmp_barrier_release_pattern[i] = (kmp_bar_pat_e)j;
1822 if (j == bp_last_bar) {
1823 __kmp_msg(kmp_ms_warning,
1824 KMP_MSG(BarrReleaseValueInvalid, name, comma + 1),
1826 KMP_INFORM(Using_str_Value, name,
1827 __kmp_barrier_pattern_name[bp_linear_bar]);
1832 if (dist_req != 0) {
1834 if ((non_dist_req != 0) && warn) {
1835 KMP_INFORM(BarrierPatternOverride, name,
1836 __kmp_barrier_pattern_name[bp_dist_bar]);
1839 for (
int i = bs_plain_barrier; i < bs_last_barrier; i++) {
1840 if (__kmp_barrier_release_pattern[i] != bp_dist_bar)
1841 __kmp_barrier_release_pattern[i] = bp_dist_bar;
1842 if (__kmp_barrier_gather_pattern[i] != bp_dist_bar)
1843 __kmp_barrier_gather_pattern[i] = bp_dist_bar;
1848static void __kmp_stg_print_barrier_pattern(kmp_str_buf_t *buffer,
1849 char const *name,
void *data) {
1851 for (
int i = bs_plain_barrier; i < bs_last_barrier; i++) {
1852 var = __kmp_barrier_pattern_env_name[i];
1853 if (strcmp(var, name) == 0) {
1854 int j = __kmp_barrier_gather_pattern[i];
1855 int k = __kmp_barrier_release_pattern[i];
1856 if (__kmp_env_format) {
1857 KMP_STR_BUF_PRINT_NAME_EX(__kmp_barrier_pattern_env_name[i]);
1859 __kmp_str_buf_print(buffer,
" %s='",
1860 __kmp_barrier_pattern_env_name[i]);
1862 KMP_DEBUG_ASSERT(j < bp_last_bar && k < bp_last_bar);
1863 __kmp_str_buf_print(buffer,
"%s,%s'\n", __kmp_barrier_pattern_name[j],
1864 __kmp_barrier_pattern_name[k]);
1872static void __kmp_stg_parse_abort_delay(
char const *name,
char const *value,
1876 int delay = __kmp_abort_delay / 1000;
1877 __kmp_stg_parse_int(name, value, 0, INT_MAX / 1000, &delay);
1878 __kmp_abort_delay = delay * 1000;
1881static void __kmp_stg_print_abort_delay(kmp_str_buf_t *buffer,
char const *name,
1883 __kmp_stg_print_int(buffer, name, __kmp_abort_delay);
1889static void __kmp_stg_parse_cpuinfo_file(
char const *name,
char const *value,
1891#if KMP_AFFINITY_SUPPORTED
1892 __kmp_stg_parse_str(name, value, &__kmp_cpuinfo_file);
1893 K_DIAG(1, (
"__kmp_cpuinfo_file == %s\n", __kmp_cpuinfo_file));
1897static void __kmp_stg_print_cpuinfo_file(kmp_str_buf_t *buffer,
1898 char const *name,
void *data) {
1899#if KMP_AFFINITY_SUPPORTED
1900 if (__kmp_env_format) {
1901 KMP_STR_BUF_PRINT_NAME;
1903 __kmp_str_buf_print(buffer,
" %s", name);
1905 if (__kmp_cpuinfo_file) {
1906 __kmp_str_buf_print(buffer,
"='%s'\n", __kmp_cpuinfo_file);
1908 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
1916static void __kmp_stg_parse_force_reduction(
char const *name,
char const *value,
1918 kmp_stg_fr_data_t *reduction = (kmp_stg_fr_data_t *)data;
1921 rc = __kmp_stg_check_rivals(name, value, reduction->rivals);
1925 if (reduction->force) {
1927 if (__kmp_str_match(
"critical", 0, value))
1928 __kmp_force_reduction_method = critical_reduce_block;
1929 else if (__kmp_str_match(
"atomic", 0, value))
1930 __kmp_force_reduction_method = atomic_reduce_block;
1931 else if (__kmp_str_match(
"tree", 0, value))
1932 __kmp_force_reduction_method = tree_reduce_block;
1934 KMP_FATAL(UnknownForceReduction, name, value);
1938 __kmp_stg_parse_bool(name, value, &__kmp_determ_red);
1939 if (__kmp_determ_red) {
1940 __kmp_force_reduction_method = tree_reduce_block;
1942 __kmp_force_reduction_method = reduction_method_not_defined;
1945 K_DIAG(1, (
"__kmp_force_reduction_method == %d\n",
1946 __kmp_force_reduction_method));
1949static void __kmp_stg_print_force_reduction(kmp_str_buf_t *buffer,
1950 char const *name,
void *data) {
1952 kmp_stg_fr_data_t *reduction = (kmp_stg_fr_data_t *)data;
1953 if (reduction->force) {
1954 if (__kmp_force_reduction_method == critical_reduce_block) {
1955 __kmp_stg_print_str(buffer, name,
"critical");
1956 }
else if (__kmp_force_reduction_method == atomic_reduce_block) {
1957 __kmp_stg_print_str(buffer, name,
"atomic");
1958 }
else if (__kmp_force_reduction_method == tree_reduce_block) {
1959 __kmp_stg_print_str(buffer, name,
"tree");
1961 if (__kmp_env_format) {
1962 KMP_STR_BUF_PRINT_NAME;
1964 __kmp_str_buf_print(buffer,
" %s", name);
1966 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
1969 __kmp_stg_print_bool(buffer, name, __kmp_determ_red);
1977static void __kmp_stg_parse_storage_map(
char const *name,
char const *value,
1979 if (__kmp_str_match(
"verbose", 1, value)) {
1980 __kmp_storage_map = TRUE;
1981 __kmp_storage_map_verbose = TRUE;
1982 __kmp_storage_map_verbose_specified = TRUE;
1985 __kmp_storage_map_verbose = FALSE;
1986 __kmp_stg_parse_bool(name, value, &__kmp_storage_map);
1990static void __kmp_stg_print_storage_map(kmp_str_buf_t *buffer,
char const *name,
1992 if (__kmp_storage_map_verbose || __kmp_storage_map_verbose_specified) {
1993 __kmp_stg_print_str(buffer, name,
"verbose");
1995 __kmp_stg_print_bool(buffer, name, __kmp_storage_map);
2002static void __kmp_stg_parse_all_threadprivate(
char const *name,
2003 char const *value,
void *data) {
2004 __kmp_stg_parse_int(name, value,
2005 __kmp_allThreadsSpecified ? __kmp_max_nth : 1,
2006 __kmp_max_nth, &__kmp_tp_capacity);
2009static void __kmp_stg_print_all_threadprivate(kmp_str_buf_t *buffer,
2010 char const *name,
void *data) {
2011 __kmp_stg_print_int(buffer, name, __kmp_tp_capacity);
2017static void __kmp_stg_parse_foreign_threads_threadprivate(
char const *name,
2020 __kmp_stg_parse_bool(name, value, &__kmp_foreign_tp);
2023static void __kmp_stg_print_foreign_threads_threadprivate(kmp_str_buf_t *buffer,
2026 __kmp_stg_print_bool(buffer, name, __kmp_foreign_tp);
2032static inline const char *
2033__kmp_hw_get_core_type_keyword(kmp_hw_core_type_t type) {
2035 case KMP_HW_CORE_TYPE_UNKNOWN:
2036 case KMP_HW_MAX_NUM_CORE_TYPES:
2038#if KMP_ARCH_X86 || KMP_ARCH_X86_64
2039 case KMP_HW_CORE_TYPE_ATOM:
2040 return "intel_atom";
2041 case KMP_HW_CORE_TYPE_CORE:
2042 return "intel_core";
2045 KMP_ASSERT2(
false,
"Unhandled kmp_hw_core_type_t enumeration");
2046 KMP_BUILTIN_UNREACHABLE;
2049#if KMP_AFFINITY_SUPPORTED
2051static int __kmp_parse_affinity_proc_id_list(
const char *var,
const char *env,
2052 const char **nextEnv,
2054 const char *scan = env;
2055 const char *next = scan;
2061 int start, end, stride;
2065 if (*next ==
'\0') {
2076 if ((*next <
'0') || (*next >
'9')) {
2077 KMP_WARNING(AffSyntaxError, var);
2081 num = __kmp_str_to_int(scan, *next);
2082 KMP_ASSERT(num >= 0);
2100 if ((*next <
'0') || (*next >
'9')) {
2101 KMP_WARNING(AffSyntaxError, var);
2106 num = __kmp_str_to_int(scan, *next);
2107 KMP_ASSERT(num >= 0);
2120 if ((*next <
'0') || (*next >
'9')) {
2122 KMP_WARNING(AffSyntaxError, var);
2130 start = __kmp_str_to_int(scan, *next);
2131 KMP_ASSERT(start >= 0);
2150 if ((*next <
'0') || (*next >
'9')) {
2151 KMP_WARNING(AffSyntaxError, var);
2155 end = __kmp_str_to_int(scan, *next);
2156 KMP_ASSERT(end >= 0);
2173 if ((*next <
'0') || (*next >
'9')) {
2174 KMP_WARNING(AffSyntaxError, var);
2178 stride = __kmp_str_to_int(scan, *next);
2179 KMP_ASSERT(stride >= 0);
2185 KMP_WARNING(AffZeroStride, var);
2190 KMP_WARNING(AffStartGreaterEnd, var, start, end);
2195 KMP_WARNING(AffStrideLessZero, var, start, end);
2199 if ((end - start) / stride > 65536) {
2200 KMP_WARNING(AffRangeTooBig, var, end, start, stride);
2217 ptrdiff_t len = next - env;
2218 char *retlist = (
char *)KMP_INTERNAL_MALLOC((len + 1) *
sizeof(
char));
2219 KMP_MEMCPY_S(retlist, (len + 1) *
sizeof(
char), env, len *
sizeof(
char));
2220 retlist[len] =
'\0';
2221 *proclist = retlist;
2228static kmp_setting_t *__kmp_affinity_notype = NULL;
2230static void __kmp_parse_affinity_env(
char const *name,
char const *value,
2231 kmp_affinity_t *out_affinity) {
2232 char *buffer = NULL;
2250 KMP_ASSERT(value != NULL);
2252 if (TCR_4(__kmp_init_middle)) {
2253 KMP_WARNING(EnvMiddleWarn, name);
2254 __kmp_env_toPrint(name, 0);
2257 __kmp_env_toPrint(name, 1);
2260 __kmp_str_format(
"%s", value);
2270#define EMIT_WARN(skip, errlist) \
2274 SKIP_TO(next, ','); \
2278 KMP_WARNING errlist; \
2287#define _set_param(_guard, _var, _val) \
2289 if (_guard == 0) { \
2292 EMIT_WARN(FALSE, (AffParamDefined, name, start)); \
2297#define set_type(val) _set_param(type, out_affinity->type, val)
2298#define set_verbose(val) _set_param(verbose, out_affinity->flags.verbose, val)
2299#define set_warnings(val) \
2300 _set_param(warnings, out_affinity->flags.warnings, val)
2301#define set_respect(val) _set_param(respect, out_affinity->flags.respect, val)
2302#define set_dups(val) _set_param(dups, out_affinity->flags.dups, val)
2303#define set_proclist(val) _set_param(proclist, out_affinity->proclist, val)
2304#define set_reset(val) _set_param(reset, out_affinity->flags.reset, val)
2306#define set_gran(val, levels) \
2309 out_affinity->gran = val; \
2310 out_affinity->gran_levels = levels; \
2312 EMIT_WARN(FALSE, (AffParamDefined, name, start)); \
2317 KMP_DEBUG_ASSERT((__kmp_nested_proc_bind.bind_types != NULL) &&
2318 (__kmp_nested_proc_bind.used > 0));
2320 while (*buf !=
'\0') {
2323 if (__kmp_match_str(
"none", buf, CCAST(
const char **, &next))) {
2324 set_type(affinity_none);
2325 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
2327 }
else if (__kmp_match_str(
"scatter", buf, CCAST(
const char **, &next))) {
2328 set_type(affinity_scatter);
2329 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2331 }
else if (__kmp_match_str(
"compact", buf, CCAST(
const char **, &next))) {
2332 set_type(affinity_compact);
2333 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2335 }
else if (__kmp_match_str(
"logical", buf, CCAST(
const char **, &next))) {
2336 set_type(affinity_logical);
2337 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2339 }
else if (__kmp_match_str(
"physical", buf, CCAST(
const char **, &next))) {
2340 set_type(affinity_physical);
2341 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2343 }
else if (__kmp_match_str(
"explicit", buf, CCAST(
const char **, &next))) {
2344 set_type(affinity_explicit);
2345 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2347 }
else if (__kmp_match_str(
"balanced", buf, CCAST(
const char **, &next))) {
2348 set_type(affinity_balanced);
2349 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2351 }
else if (__kmp_match_str(
"disabled", buf, CCAST(
const char **, &next))) {
2352 set_type(affinity_disabled);
2353 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
2355 }
else if (__kmp_match_str(
"verbose", buf, CCAST(
const char **, &next))) {
2358 }
else if (__kmp_match_str(
"noverbose", buf, CCAST(
const char **, &next))) {
2361 }
else if (__kmp_match_str(
"warnings", buf, CCAST(
const char **, &next))) {
2364 }
else if (__kmp_match_str(
"nowarnings", buf,
2365 CCAST(
const char **, &next))) {
2366 set_warnings(FALSE);
2368 }
else if (__kmp_match_str(
"respect", buf, CCAST(
const char **, &next))) {
2371 }
else if (__kmp_match_str(
"norespect", buf, CCAST(
const char **, &next))) {
2374 }
else if (__kmp_match_str(
"reset", buf, CCAST(
const char **, &next))) {
2377 }
else if (__kmp_match_str(
"noreset", buf, CCAST(
const char **, &next))) {
2380 }
else if (__kmp_match_str(
"duplicates", buf,
2381 CCAST(
const char **, &next)) ||
2382 __kmp_match_str(
"dups", buf, CCAST(
const char **, &next))) {
2385 }
else if (__kmp_match_str(
"noduplicates", buf,
2386 CCAST(
const char **, &next)) ||
2387 __kmp_match_str(
"nodups", buf, CCAST(
const char **, &next))) {
2390 }
else if (__kmp_match_str(
"granularity", buf,
2391 CCAST(
const char **, &next)) ||
2392 __kmp_match_str(
"gran", buf, CCAST(
const char **, &next))) {
2395 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2405 if (__kmp_match_str(
"core_type", buf, CCAST(
const char **, &next))) {
2406 set_gran(KMP_HW_CORE, -1);
2407 out_affinity->flags.core_types_gran = 1;
2410 }
else if (__kmp_match_str(
"core_efficiency", buf,
2411 CCAST(
const char **, &next)) ||
2412 __kmp_match_str(
"core_eff", buf,
2413 CCAST(
const char **, &next))) {
2414 set_gran(KMP_HW_CORE, -1);
2415 out_affinity->flags.core_effs_gran = 1;
2421 KMP_FOREACH_HW_TYPE(type) {
2422 const char *name = __kmp_hw_get_keyword(type);
2423 if (__kmp_match_str(name, buf, CCAST(
const char **, &next))) {
2433 if (__kmp_match_str(
"fine", buf, CCAST(
const char **, &next))) {
2434 set_gran(KMP_HW_THREAD, -1);
2437 }
else if (__kmp_match_str(
"package", buf,
2438 CCAST(
const char **, &next))) {
2439 set_gran(KMP_HW_SOCKET, -1);
2442 }
else if (__kmp_match_str(
"node", buf, CCAST(
const char **, &next))) {
2443 set_gran(KMP_HW_NUMA, -1);
2446#if KMP_GROUP_AFFINITY
2447 }
else if (__kmp_match_str(
"group", buf, CCAST(
const char **, &next))) {
2448 set_gran(KMP_HW_PROC_GROUP, -1);
2452 }
else if ((*buf >=
'0') && (*buf <=
'9')) {
2456 n = __kmp_str_to_int(buf, *next);
2459 set_gran(KMP_HW_UNKNOWN, n);
2462 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2466 }
else if (__kmp_match_str(
"proclist", buf, CCAST(
const char **, &next))) {
2467 char *temp_proclist;
2471 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2477 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2482 if (!__kmp_parse_affinity_proc_id_list(
2483 name, buf, CCAST(
const char **, &next), &temp_proclist)) {
2495 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2499 set_proclist(temp_proclist);
2500 }
else if ((*buf >=
'0') && (*buf <=
'9')) {
2505 n = __kmp_str_to_int(buf, *next);
2511 KMP_WARNING(AffManyParams, name, start);
2515 EMIT_WARN(TRUE, (AffInvalidParam, name, start));
2523 }
else if (*next !=
'\0') {
2524 const char *temp = next;
2525 EMIT_WARN(TRUE, (ParseExtraCharsWarn, name, temp));
2537#undef set_granularity
2540 __kmp_str_free(&buffer);
2544 KMP_WARNING(AffProcListNoType, name);
2545 out_affinity->type = affinity_explicit;
2546 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2547 }
else if (out_affinity->type != affinity_explicit) {
2548 KMP_WARNING(AffProcListNotExplicit, name);
2549 KMP_ASSERT(out_affinity->proclist != NULL);
2550 KMP_INTERNAL_FREE(out_affinity->proclist);
2551 out_affinity->proclist = NULL;
2554 switch (out_affinity->type) {
2555 case affinity_logical:
2556 case affinity_physical: {
2558 out_affinity->offset = number[0];
2561 KMP_WARNING(AffManyParamsForLogic, name, number[1]);
2564 case affinity_balanced: {
2566 out_affinity->compact = number[0];
2569 out_affinity->offset = number[1];
2572 if (__kmp_affinity.gran == KMP_HW_UNKNOWN) {
2573 int verbose = out_affinity->flags.verbose;
2574 int warnings = out_affinity->flags.warnings;
2575#if KMP_MIC_SUPPORTED
2576 if (__kmp_mic_type != non_mic) {
2577 if (verbose || warnings) {
2578 KMP_WARNING(AffGranUsing, out_affinity->env_var,
"fine");
2580 out_affinity->gran = KMP_HW_THREAD;
2584 if (verbose || warnings) {
2585 KMP_WARNING(AffGranUsing, out_affinity->env_var,
"core");
2587 out_affinity->gran = KMP_HW_CORE;
2591 case affinity_scatter:
2592 case affinity_compact: {
2594 out_affinity->compact = number[0];
2597 out_affinity->offset = number[1];
2600 case affinity_explicit: {
2601 if (out_affinity->proclist == NULL) {
2602 KMP_WARNING(AffNoProcList, name);
2603 out_affinity->type = affinity_none;
2606 KMP_WARNING(AffNoParam, name,
"explicit");
2609 case affinity_none: {
2611 KMP_WARNING(AffNoParam, name,
"none");
2614 case affinity_disabled: {
2616 KMP_WARNING(AffNoParam, name,
"disabled");
2619 case affinity_default: {
2621 KMP_WARNING(AffNoParam, name,
"default");
2630static void __kmp_stg_parse_affinity(
char const *name,
char const *value,
2632 kmp_setting_t **rivals = (kmp_setting_t **)data;
2635 rc = __kmp_stg_check_rivals(name, value, rivals);
2640 __kmp_parse_affinity_env(name, value, &__kmp_affinity);
2643static void __kmp_stg_parse_hh_affinity(
char const *name,
char const *value,
2645 __kmp_parse_affinity_env(name, value, &__kmp_hh_affinity);
2647 if (__kmp_hh_affinity.flags.reset) {
2648 KMP_WARNING(AffInvalidParam, name,
"reset");
2650 if (__kmp_hh_affinity.flags.respect != affinity_respect_mask_default) {
2651 KMP_WARNING(AffInvalidParam, name,
"respect");
2655static void __kmp_print_affinity_env(kmp_str_buf_t *buffer,
char const *name,
2656 const kmp_affinity_t &affinity) {
2657 bool is_hh_affinity = (&affinity == &__kmp_hh_affinity);
2658 if (__kmp_env_format) {
2659 KMP_STR_BUF_PRINT_NAME_EX(name);
2661 __kmp_str_buf_print(buffer,
" %s='", name);
2663 if (affinity.flags.verbose) {
2664 __kmp_str_buf_print(buffer,
"%s,",
"verbose");
2666 __kmp_str_buf_print(buffer,
"%s,",
"noverbose");
2668 if (affinity.flags.warnings) {
2669 __kmp_str_buf_print(buffer,
"%s,",
"warnings");
2671 __kmp_str_buf_print(buffer,
"%s,",
"nowarnings");
2673 if (KMP_AFFINITY_CAPABLE()) {
2676 if (!is_hh_affinity) {
2677 if (affinity.flags.respect) {
2678 __kmp_str_buf_print(buffer,
"%s,",
"respect");
2680 __kmp_str_buf_print(buffer,
"%s,",
"norespect");
2682 if (affinity.flags.reset) {
2683 __kmp_str_buf_print(buffer,
"%s,",
"reset");
2685 __kmp_str_buf_print(buffer,
"%s,",
"noreset");
2688 __kmp_str_buf_print(buffer,
"granularity=");
2689 if (affinity.flags.core_types_gran)
2690 __kmp_str_buf_print(buffer,
"core_type,");
2691 else if (affinity.flags.core_effs_gran) {
2692 __kmp_str_buf_print(buffer,
"core_eff,");
2694 __kmp_str_buf_print(
2695 buffer,
"%s,", __kmp_hw_get_keyword(affinity.gran,
false));
2698 if (!KMP_AFFINITY_CAPABLE()) {
2699 __kmp_str_buf_print(buffer,
"%s",
"disabled");
2701 int compact = affinity.compact;
2702 int offset = affinity.offset;
2703 switch (affinity.type) {
2705 __kmp_str_buf_print(buffer,
"%s",
"none");
2707 case affinity_physical:
2708 __kmp_str_buf_print(buffer,
"%s,%d",
"physical", offset);
2710 case affinity_logical:
2711 __kmp_str_buf_print(buffer,
"%s,%d",
"logical", offset);
2713 case affinity_compact:
2714 __kmp_str_buf_print(buffer,
"%s,%d,%d",
"compact", compact, offset);
2716 case affinity_scatter:
2717 __kmp_str_buf_print(buffer,
"%s,%d,%d",
"scatter", compact, offset);
2719 case affinity_explicit:
2720 __kmp_str_buf_print(buffer,
"%s=[%s],%s",
"proclist", affinity.proclist,
2723 case affinity_balanced:
2724 __kmp_str_buf_print(buffer,
"%s,%d,%d",
"balanced", compact, offset);
2726 case affinity_disabled:
2727 __kmp_str_buf_print(buffer,
"%s",
"disabled");
2729 case affinity_default:
2730 __kmp_str_buf_print(buffer,
"%s",
"default");
2733 __kmp_str_buf_print(buffer,
"%s",
"<unknown>");
2737 __kmp_str_buf_print(buffer,
"'\n");
2740static void __kmp_stg_print_affinity(kmp_str_buf_t *buffer,
char const *name,
2742 __kmp_print_affinity_env(buffer, name, __kmp_affinity);
2744static void __kmp_stg_print_hh_affinity(kmp_str_buf_t *buffer,
char const *name,
2746 __kmp_print_affinity_env(buffer, name, __kmp_hh_affinity);
2749#ifdef KMP_GOMP_COMPAT
2751static void __kmp_stg_parse_gomp_cpu_affinity(
char const *name,
2752 char const *value,
void *data) {
2753 const char *next = NULL;
2754 char *temp_proclist;
2755 kmp_setting_t **rivals = (kmp_setting_t **)data;
2758 rc = __kmp_stg_check_rivals(name, value, rivals);
2763 if (TCR_4(__kmp_init_middle)) {
2764 KMP_WARNING(EnvMiddleWarn, name);
2765 __kmp_env_toPrint(name, 0);
2769 __kmp_env_toPrint(name, 1);
2771 if (__kmp_parse_affinity_proc_id_list(name, value, &next, &temp_proclist)) {
2773 if (*next ==
'\0') {
2775 __kmp_affinity.proclist = temp_proclist;
2776 __kmp_affinity.type = affinity_explicit;
2777 __kmp_affinity.gran = KMP_HW_THREAD;
2778 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2780 KMP_WARNING(AffSyntaxError, name);
2781 if (temp_proclist != NULL) {
2782 KMP_INTERNAL_FREE((
void *)temp_proclist);
2787 __kmp_affinity.type = affinity_none;
2788 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
2815static int __kmp_parse_subplace_list(
const char *var,
const char **scan) {
2819 int start, count, stride;
2825 if ((**scan <
'0') || (**scan >
'9')) {
2830 start = __kmp_str_to_int(*scan, *next);
2831 KMP_ASSERT(start >= 0);
2836 if (**scan ==
'}') {
2839 if (**scan ==
',') {
2843 if (**scan !=
':') {
2850 if ((**scan <
'0') || (**scan >
'9')) {
2855 count = __kmp_str_to_int(*scan, *next);
2856 KMP_ASSERT(count >= 0);
2861 if (**scan ==
'}') {
2864 if (**scan ==
',') {
2868 if (**scan !=
':') {
2877 if (**scan ==
'+') {
2881 if (**scan ==
'-') {
2889 if ((**scan <
'0') || (**scan >
'9')) {
2894 stride = __kmp_str_to_int(*scan, *next);
2895 KMP_ASSERT(stride >= 0);
2901 if (**scan ==
'}') {
2904 if (**scan ==
',') {
2914static int __kmp_parse_place(
const char *var,
const char **scan) {
2919 if (**scan ==
'{') {
2921 if (!__kmp_parse_subplace_list(var, scan)) {
2924 if (**scan !=
'}') {
2928 }
else if (**scan ==
'!') {
2930 return __kmp_parse_place(var, scan);
2931 }
else if ((**scan >=
'0') && (**scan <=
'9')) {
2934 int proc = __kmp_str_to_int(*scan, *next);
2935 KMP_ASSERT(proc >= 0);
2944static int __kmp_parse_place_list(
const char *var,
const char *env,
2945 char **place_list) {
2946 const char *scan = env;
2947 const char *next = scan;
2952 if (!__kmp_parse_place(var, &scan)) {
2958 if (*scan ==
'\0') {
2972 if ((*scan <
'0') || (*scan >
'9')) {
2977 count = __kmp_str_to_int(scan, *next);
2978 KMP_ASSERT(count >= 0);
2983 if (*scan ==
'\0') {
3011 if ((*scan <
'0') || (*scan >
'9')) {
3016 stride = __kmp_str_to_int(scan, *next);
3017 KMP_ASSERT(stride >= 0);
3023 if (*scan ==
'\0') {
3035 ptrdiff_t len = scan - env;
3036 char *retlist = (
char *)KMP_INTERNAL_MALLOC((len + 1) *
sizeof(
char));
3037 KMP_MEMCPY_S(retlist, (len + 1) *
sizeof(
char), env, len *
sizeof(
char));
3038 retlist[len] =
'\0';
3039 *place_list = retlist;
3044static inline void __kmp_places_set(
enum affinity_type type, kmp_hw_t kind) {
3045 __kmp_affinity.type = type;
3046 __kmp_affinity.gran = kind;
3047 __kmp_affinity.flags.dups = FALSE;
3048 __kmp_affinity.flags.omp_places = TRUE;
3051static void __kmp_places_syntax_error_fallback(
char const *name,
3053 const char *str = __kmp_hw_get_catalog_string(kind,
true);
3054 KMP_WARNING(SyntaxErrorUsing, name, str);
3055 __kmp_places_set(affinity_compact, kind);
3056 if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_default)
3057 __kmp_nested_proc_bind.bind_types[0] = proc_bind_true;
3060static void __kmp_stg_parse_places(
char const *name,
char const *value,
3062 struct kmp_place_t {
3068 const char *scan = value;
3069 const char *next = scan;
3070 kmp_place_t std_places[] = {{
"threads", KMP_HW_THREAD},
3071 {
"cores", KMP_HW_CORE},
3072 {
"numa_domains", KMP_HW_NUMA},
3073 {
"ll_caches", KMP_HW_LLC},
3074 {
"sockets", KMP_HW_SOCKET}};
3075 kmp_setting_t **rivals = (kmp_setting_t **)data;
3078 rc = __kmp_stg_check_rivals(name, value, rivals);
3084 for (
size_t i = 0; i <
sizeof(std_places) /
sizeof(std_places[0]); ++i) {
3085 const kmp_place_t &place = std_places[i];
3086 if (__kmp_match_str(place.name, scan, &next)) {
3088 __kmp_places_set(affinity_compact, place.type);
3091 if (KMP_HW_MAX_NUM_CORE_TYPES > 1) {
3094 if (place.type != KMP_HW_CORE) {
3095 __kmp_places_syntax_error_fallback(name, place.type);
3100#if KMP_ARCH_X86 || KMP_ARCH_X86_64
3101 if (__kmp_match_str(
"intel_core", scan, &next)) {
3102 __kmp_affinity.core_attr_gran.core_type = KMP_HW_CORE_TYPE_CORE;
3103 __kmp_affinity.core_attr_gran.valid = 1;
3105 }
else if (__kmp_match_str(
"intel_atom", scan, &next)) {
3106 __kmp_affinity.core_attr_gran.core_type = KMP_HW_CORE_TYPE_ATOM;
3107 __kmp_affinity.core_attr_gran.valid = 1;
3111 if (__kmp_match_str(
"eff", scan, &next)) {
3113 if (!isdigit(*next)) {
3114 __kmp_places_syntax_error_fallback(name, place.type);
3119 eff = __kmp_str_to_int(scan, *next);
3121 __kmp_places_syntax_error_fallback(name, place.type);
3124 if (eff >= KMP_HW_MAX_NUM_CORE_EFFS)
3125 eff = KMP_HW_MAX_NUM_CORE_EFFS - 1;
3126 __kmp_affinity.core_attr_gran.core_eff = eff;
3127 __kmp_affinity.core_attr_gran.valid = 1;
3130 if (!__kmp_affinity.core_attr_gran.valid) {
3131 __kmp_places_syntax_error_fallback(name, place.type);
3141 KMP_FOREACH_HW_TYPE(type) {
3142 const char *name = __kmp_hw_get_keyword(type,
true);
3143 if (__kmp_match_str(
"unknowns", scan, &next))
3145 if (__kmp_match_str(name, scan, &next)) {
3147 __kmp_places_set(affinity_compact, type);
3155 if (__kmp_match_str(
"core_types", scan, &next)) {
3157 if (*scan !=
'\0') {
3158 KMP_WARNING(ParseExtraCharsWarn, name, scan);
3160 __kmp_places_set(affinity_compact, KMP_HW_CORE);
3161 __kmp_affinity.flags.core_types_gran = 1;
3163 }
else if (__kmp_match_str(
"core_effs", scan, &next) ||
3164 __kmp_match_str(
"core_efficiencies", scan, &next)) {
3166 if (*scan !=
'\0') {
3167 KMP_WARNING(ParseExtraCharsWarn, name, scan);
3169 __kmp_places_set(affinity_compact, KMP_HW_CORE);
3170 __kmp_affinity.flags.core_effs_gran = 1;
3176 if (__kmp_affinity.proclist != NULL) {
3177 KMP_INTERNAL_FREE((
void *)__kmp_affinity.proclist);
3178 __kmp_affinity.proclist = NULL;
3180 if (__kmp_parse_place_list(name, value, &__kmp_affinity.proclist)) {
3181 __kmp_places_set(affinity_explicit, KMP_HW_THREAD);
3184 __kmp_places_syntax_error_fallback(name, KMP_HW_CORE);
3186 if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_default) {
3187 __kmp_nested_proc_bind.bind_types[0] = proc_bind_true;
3192 kmp_hw_t gran = __kmp_affinity.gran;
3193 if (__kmp_affinity.gran != KMP_HW_UNKNOWN) {
3194 gran = __kmp_affinity.gran;
3199 if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_default) {
3200 __kmp_nested_proc_bind.bind_types[0] = proc_bind_true;
3204 if (*scan ==
'\0') {
3210 __kmp_places_syntax_error_fallback(name, gran);
3218 count = __kmp_str_to_int(scan, *next);
3219 KMP_ASSERT(count >= 0);
3224 __kmp_places_syntax_error_fallback(name, gran);
3230 if (*scan !=
'\0') {
3231 KMP_WARNING(ParseExtraCharsWarn, name, scan);
3233 __kmp_affinity_num_places = count;
3236static void __kmp_stg_print_places(kmp_str_buf_t *buffer,
char const *name,
3238 enum affinity_type type = __kmp_affinity.type;
3239 const char *proclist = __kmp_affinity.proclist;
3240 kmp_hw_t gran = __kmp_affinity.gran;
3242 if (__kmp_env_format) {
3243 KMP_STR_BUF_PRINT_NAME;
3245 __kmp_str_buf_print(buffer,
" %s", name);
3247 if ((__kmp_nested_proc_bind.used == 0) ||
3248 (__kmp_nested_proc_bind.bind_types == NULL) ||
3249 (__kmp_nested_proc_bind.bind_types[0] == proc_bind_false)) {
3250 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
3251 }
else if (type == affinity_explicit) {
3252 if (proclist != NULL) {
3253 __kmp_str_buf_print(buffer,
"='%s'\n", proclist);
3255 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
3257 }
else if (type == affinity_compact) {
3259 if (__kmp_affinity.num_masks > 0) {
3260 num = __kmp_affinity.num_masks;
3261 }
else if (__kmp_affinity_num_places > 0) {
3262 num = __kmp_affinity_num_places;
3266 if (gran != KMP_HW_UNKNOWN) {
3268 if (__kmp_affinity.flags.core_types_gran) {
3269 __kmp_str_buf_print(buffer,
"='%s'\n",
"core_types");
3272 if (__kmp_affinity.flags.core_effs_gran) {
3273 __kmp_str_buf_print(buffer,
"='%s'\n",
"core_effs");
3278 const char *name = __kmp_hw_get_keyword(gran,
true);
3279 __kmp_str_buf_print(buffer,
"='%s", name);
3282 if (__kmp_affinity.core_attr_gran.valid) {
3283 kmp_hw_core_type_t ct =
3284 (kmp_hw_core_type_t)__kmp_affinity.core_attr_gran.core_type;
3285 int eff = __kmp_affinity.core_attr_gran.core_eff;
3286 if (ct != KMP_HW_CORE_TYPE_UNKNOWN) {
3287 const char *ct_name = __kmp_hw_get_core_type_keyword(ct);
3288 __kmp_str_buf_print(buffer,
":%s", ct_name);
3289 }
else if (eff >= 0 && eff < KMP_HW_MAX_NUM_CORE_EFFS) {
3290 __kmp_str_buf_print(buffer,
":eff%d", eff);
3296 __kmp_str_buf_print(buffer,
"(%d)", num);
3297 __kmp_str_buf_print(buffer,
"'\n");
3299 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
3302 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
3306static void __kmp_stg_parse_topology_method(
char const *name,
char const *value,
3308 if (__kmp_str_match(
"all", 1, value)) {
3309 __kmp_affinity_top_method = affinity_top_method_all;
3311#if KMP_HWLOC_ENABLED
3312 else if (__kmp_str_match(
"hwloc", 1, value)) {
3313 __kmp_affinity_top_method = affinity_top_method_hwloc;
3316#if KMP_ARCH_X86 || KMP_ARCH_X86_64
3317 else if (__kmp_str_match(
"cpuid_leaf31", 12, value) ||
3318 __kmp_str_match(
"cpuid 1f", 8, value) ||
3319 __kmp_str_match(
"cpuid 31", 8, value) ||
3320 __kmp_str_match(
"cpuid1f", 7, value) ||
3321 __kmp_str_match(
"cpuid31", 7, value) ||
3322 __kmp_str_match(
"leaf 1f", 7, value) ||
3323 __kmp_str_match(
"leaf 31", 7, value) ||
3324 __kmp_str_match(
"leaf1f", 6, value) ||
3325 __kmp_str_match(
"leaf31", 6, value)) {
3326 __kmp_affinity_top_method = affinity_top_method_x2apicid_1f;
3327 }
else if (__kmp_str_match(
"x2apic id", 9, value) ||
3328 __kmp_str_match(
"x2apic_id", 9, value) ||
3329 __kmp_str_match(
"x2apic-id", 9, value) ||
3330 __kmp_str_match(
"x2apicid", 8, value) ||
3331 __kmp_str_match(
"cpuid leaf 11", 13, value) ||
3332 __kmp_str_match(
"cpuid_leaf_11", 13, value) ||
3333 __kmp_str_match(
"cpuid-leaf-11", 13, value) ||
3334 __kmp_str_match(
"cpuid leaf11", 12, value) ||
3335 __kmp_str_match(
"cpuid_leaf11", 12, value) ||
3336 __kmp_str_match(
"cpuid-leaf11", 12, value) ||
3337 __kmp_str_match(
"cpuidleaf 11", 12, value) ||
3338 __kmp_str_match(
"cpuidleaf_11", 12, value) ||
3339 __kmp_str_match(
"cpuidleaf-11", 12, value) ||
3340 __kmp_str_match(
"cpuidleaf11", 11, value) ||
3341 __kmp_str_match(
"cpuid 11", 8, value) ||
3342 __kmp_str_match(
"cpuid_11", 8, value) ||
3343 __kmp_str_match(
"cpuid-11", 8, value) ||
3344 __kmp_str_match(
"cpuid11", 7, value) ||
3345 __kmp_str_match(
"leaf 11", 7, value) ||
3346 __kmp_str_match(
"leaf_11", 7, value) ||
3347 __kmp_str_match(
"leaf-11", 7, value) ||
3348 __kmp_str_match(
"leaf11", 6, value)) {
3349 __kmp_affinity_top_method = affinity_top_method_x2apicid;
3350 }
else if (__kmp_str_match(
"apic id", 7, value) ||
3351 __kmp_str_match(
"apic_id", 7, value) ||
3352 __kmp_str_match(
"apic-id", 7, value) ||
3353 __kmp_str_match(
"apicid", 6, value) ||
3354 __kmp_str_match(
"cpuid leaf 4", 12, value) ||
3355 __kmp_str_match(
"cpuid_leaf_4", 12, value) ||
3356 __kmp_str_match(
"cpuid-leaf-4", 12, value) ||
3357 __kmp_str_match(
"cpuid leaf4", 11, value) ||
3358 __kmp_str_match(
"cpuid_leaf4", 11, value) ||
3359 __kmp_str_match(
"cpuid-leaf4", 11, value) ||
3360 __kmp_str_match(
"cpuidleaf 4", 11, value) ||
3361 __kmp_str_match(
"cpuidleaf_4", 11, value) ||
3362 __kmp_str_match(
"cpuidleaf-4", 11, value) ||
3363 __kmp_str_match(
"cpuidleaf4", 10, value) ||
3364 __kmp_str_match(
"cpuid 4", 7, value) ||
3365 __kmp_str_match(
"cpuid_4", 7, value) ||
3366 __kmp_str_match(
"cpuid-4", 7, value) ||
3367 __kmp_str_match(
"cpuid4", 6, value) ||
3368 __kmp_str_match(
"leaf 4", 6, value) ||
3369 __kmp_str_match(
"leaf_4", 6, value) ||
3370 __kmp_str_match(
"leaf-4", 6, value) ||
3371 __kmp_str_match(
"leaf4", 5, value)) {
3372 __kmp_affinity_top_method = affinity_top_method_apicid;
3375 else if (__kmp_str_match(
"/proc/cpuinfo", 2, value) ||
3376 __kmp_str_match(
"cpuinfo", 5, value)) {
3377 __kmp_affinity_top_method = affinity_top_method_cpuinfo;
3379#if KMP_GROUP_AFFINITY
3380 else if (__kmp_str_match(
"group", 1, value)) {
3381 KMP_WARNING(StgDeprecatedValue, name, value,
"all");
3382 __kmp_affinity_top_method = affinity_top_method_group;
3385 else if (__kmp_str_match(
"flat", 1, value)) {
3386 __kmp_affinity_top_method = affinity_top_method_flat;
3388 KMP_WARNING(StgInvalidValue, name, value);
3392static void __kmp_stg_print_topology_method(kmp_str_buf_t *buffer,
3393 char const *name,
void *data) {
3394 char const *value = NULL;
3396 switch (__kmp_affinity_top_method) {
3397 case affinity_top_method_default:
3401 case affinity_top_method_all:
3405#if KMP_ARCH_X86 || KMP_ARCH_X86_64
3406 case affinity_top_method_x2apicid_1f:
3407 value =
"x2APIC id leaf 0x1f";
3410 case affinity_top_method_x2apicid:
3411 value =
"x2APIC id leaf 0xb";
3414 case affinity_top_method_apicid:
3419#if KMP_HWLOC_ENABLED
3420 case affinity_top_method_hwloc:
3425 case affinity_top_method_cpuinfo:
3429#if KMP_GROUP_AFFINITY
3430 case affinity_top_method_group:
3435 case affinity_top_method_flat:
3440 if (value != NULL) {
3441 __kmp_stg_print_str(buffer, name, value);
3446struct kmp_proc_bind_info_t {
3448 kmp_proc_bind_t proc_bind;
3450static kmp_proc_bind_info_t proc_bind_table[] = {
3451 {
"spread", proc_bind_spread},
3452 {
"true", proc_bind_spread},
3453 {
"close", proc_bind_close},
3455 {
"false", proc_bind_primary},
3456 {
"primary", proc_bind_primary}};
3457static void __kmp_stg_parse_teams_proc_bind(
char const *name,
char const *value,
3462 for (
size_t i = 0; i <
sizeof(proc_bind_table) /
sizeof(proc_bind_table[0]);
3464 if (__kmp_match_str(proc_bind_table[i].name, value, &end)) {
3465 __kmp_teams_proc_bind = proc_bind_table[i].proc_bind;
3471 KMP_WARNING(StgInvalidValue, name, value);
3474static void __kmp_stg_print_teams_proc_bind(kmp_str_buf_t *buffer,
3475 char const *name,
void *data) {
3476 const char *value = KMP_I18N_STR(NotDefined);
3477 for (
size_t i = 0; i <
sizeof(proc_bind_table) /
sizeof(proc_bind_table[0]);
3479 if (__kmp_teams_proc_bind == proc_bind_table[i].proc_bind) {
3480 value = proc_bind_table[i].name;
3484 __kmp_stg_print_str(buffer, name, value);
3490static void __kmp_stg_parse_proc_bind(
char const *name,
char const *value,
3492 kmp_setting_t **rivals = (kmp_setting_t **)data;
3495 rc = __kmp_stg_check_rivals(name, value, rivals);
3501 KMP_DEBUG_ASSERT((__kmp_nested_proc_bind.bind_types != NULL) &&
3502 (__kmp_nested_proc_bind.used > 0));
3504 const char *buf = value;
3510 if (__kmp_match_str(
"disabled", buf, &next)) {
3513#if KMP_AFFINITY_SUPPORTED
3514 __kmp_affinity.type = affinity_disabled;
3516 __kmp_nested_proc_bind.used = 1;
3517 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
3518 }
else if (__kmp_match_str(
"false", buf, &next)) {
3521#if KMP_AFFINITY_SUPPORTED
3522 __kmp_affinity.type = affinity_none;
3524 __kmp_nested_proc_bind.used = 1;
3525 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
3526 }
else if (__kmp_match_str(
"true", buf, &next)) {
3529 __kmp_nested_proc_bind.used = 1;
3530 __kmp_nested_proc_bind.bind_types[0] = proc_bind_true;
3535 for (scan = buf; *scan !=
'\0'; scan++) {
3542 if (__kmp_nested_proc_bind.size < nelem) {
3543 __kmp_nested_proc_bind.bind_types =
3544 (kmp_proc_bind_t *)KMP_INTERNAL_REALLOC(
3545 __kmp_nested_proc_bind.bind_types,
3546 sizeof(kmp_proc_bind_t) * nelem);
3547 if (__kmp_nested_proc_bind.bind_types == NULL) {
3548 KMP_FATAL(MemoryAllocFailed);
3550 __kmp_nested_proc_bind.size = nelem;
3552 __kmp_nested_proc_bind.used = nelem;
3554 if (nelem > 1 && !__kmp_dflt_max_active_levels_set)
3555 __kmp_dflt_max_active_levels = KMP_MAX_ACTIVE_LEVELS_LIMIT;
3560 enum kmp_proc_bind_t bind;
3562 if (__kmp_match_str(
"master", buf, &next) ||
3563 __kmp_match_str(
"primary", buf, &next)) {
3566 bind = proc_bind_primary;
3567 }
else if (__kmp_match_str(
"close", buf, &next)) {
3570 bind = proc_bind_close;
3571 }
else if (__kmp_match_str(
"spread", buf, &next)) {
3574 bind = proc_bind_spread;
3576 KMP_WARNING(StgInvalidValue, name, value);
3577 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
3578 __kmp_nested_proc_bind.used = 1;
3582 __kmp_nested_proc_bind.bind_types[i++] = bind;
3587 KMP_WARNING(ParseExtraCharsWarn, name, buf);
3597 KMP_WARNING(ParseExtraCharsWarn, name, buf);
3601static void __kmp_stg_print_proc_bind(kmp_str_buf_t *buffer,
char const *name,
3603 int nelem = __kmp_nested_proc_bind.used;
3604 if (__kmp_env_format) {
3605 KMP_STR_BUF_PRINT_NAME;
3607 __kmp_str_buf_print(buffer,
" %s", name);
3610 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
3613 __kmp_str_buf_print(buffer,
"='", name);
3614 for (i = 0; i < nelem; i++) {
3615 switch (__kmp_nested_proc_bind.bind_types[i]) {
3616 case proc_bind_false:
3617 __kmp_str_buf_print(buffer,
"false");
3620 case proc_bind_true:
3621 __kmp_str_buf_print(buffer,
"true");
3624 case proc_bind_primary:
3625 __kmp_str_buf_print(buffer,
"primary");
3628 case proc_bind_close:
3629 __kmp_str_buf_print(buffer,
"close");
3632 case proc_bind_spread:
3633 __kmp_str_buf_print(buffer,
"spread");
3636 case proc_bind_intel:
3637 __kmp_str_buf_print(buffer,
"intel");
3640 case proc_bind_default:
3641 __kmp_str_buf_print(buffer,
"default");
3644 if (i < nelem - 1) {
3645 __kmp_str_buf_print(buffer,
",");
3648 __kmp_str_buf_print(buffer,
"'\n");
3652static void __kmp_stg_parse_display_affinity(
char const *name,
3653 char const *value,
void *data) {
3654 __kmp_stg_parse_bool(name, value, &__kmp_display_affinity);
3656static void __kmp_stg_print_display_affinity(kmp_str_buf_t *buffer,
3657 char const *name,
void *data) {
3658 __kmp_stg_print_bool(buffer, name, __kmp_display_affinity);
3660static void __kmp_stg_parse_affinity_format(
char const *name,
char const *value,
3662 size_t length = KMP_STRLEN(value);
3663 __kmp_strncpy_truncate(__kmp_affinity_format, KMP_AFFINITY_FORMAT_SIZE, value,
3666static void __kmp_stg_print_affinity_format(kmp_str_buf_t *buffer,
3667 char const *name,
void *data) {
3668 if (__kmp_env_format) {
3669 KMP_STR_BUF_PRINT_NAME_EX(name);
3671 __kmp_str_buf_print(buffer,
" %s='", name);
3673 __kmp_str_buf_print(buffer,
"%s'\n", __kmp_affinity_format);
3695static void __kmp_stg_parse_allocator(
char const *name,
char const *value,
3697 const char *buf = value;
3698 const char *next, *scan, *start;
3700 omp_allocator_handle_t al;
3701 omp_memspace_handle_t ms = omp_default_mem_space;
3702 bool is_memspace =
false;
3703 int ntraits = 0, count = 0;
3707 const char *delim = strchr(buf,
':');
3708 const char *predef_mem_space = strstr(buf,
"mem_space");
3710 bool is_memalloc = (!predef_mem_space && !delim) ?
true : false;
3715 for (scan = buf; *scan !=
'\0'; scan++) {
3720 omp_alloctrait_t *traits =
3721 (omp_alloctrait_t *)KMP_ALLOCA(ntraits *
sizeof(omp_alloctrait_t));
3724#define IS_POWER_OF_TWO(n) (((n) & ((n)-1)) == 0)
3726#define GET_NEXT(sentinel) \
3729 if (*next == sentinel) \
3735#define SKIP_PAIR(key) \
3737 char const str_delimiter[] = {',', 0}; \
3738 char *value = __kmp_str_token(CCAST(char *, scan), str_delimiter, \
3739 CCAST(char **, &next)); \
3740 KMP_WARNING(StgInvalidValue, key, value); \
3748 char const str_delimiter[] = {'=', 0}; \
3749 key = __kmp_str_token(CCAST(char *, start), str_delimiter, \
3750 CCAST(char **, &next)); \
3755 while (*next !=
'\0') {
3757 __kmp_match_str(
"fb_data", scan, &next)) {
3761 if (__kmp_match_str(
"omp_high_bw_mem_alloc", scan, &next)) {
3764 if (__kmp_hwloc_available || __kmp_memkind_available) {
3765 __kmp_def_allocator = omp_high_bw_mem_alloc;
3768 KMP_WARNING(OmpNoAllocator,
"omp_high_bw_mem_alloc");
3771 traits[count].key = omp_atk_fb_data;
3772 traits[count].value = RCAST(omp_uintptr_t, omp_high_bw_mem_alloc);
3774 }
else if (__kmp_match_str(
"omp_large_cap_mem_alloc", scan, &next)) {
3777 if (__kmp_hwloc_available || __kmp_memkind_available) {
3778 __kmp_def_allocator = omp_large_cap_mem_alloc;
3781 KMP_WARNING(OmpNoAllocator,
"omp_large_cap_mem_alloc");
3784 traits[count].key = omp_atk_fb_data;
3785 traits[count].value = RCAST(omp_uintptr_t, omp_large_cap_mem_alloc);
3787 }
else if (__kmp_match_str(
"omp_default_mem_alloc", scan, &next)) {
3791 traits[count].key = omp_atk_fb_data;
3792 traits[count].value = RCAST(omp_uintptr_t, omp_default_mem_alloc);
3794 }
else if (__kmp_match_str(
"omp_const_mem_alloc", scan, &next)) {
3797 KMP_WARNING(OmpNoAllocator,
"omp_const_mem_alloc");
3799 traits[count].key = omp_atk_fb_data;
3800 traits[count].value = RCAST(omp_uintptr_t, omp_const_mem_alloc);
3802 }
else if (__kmp_match_str(
"omp_low_lat_mem_alloc", scan, &next)) {
3805 KMP_WARNING(OmpNoAllocator,
"omp_low_lat_mem_alloc");
3807 traits[count].key = omp_atk_fb_data;
3808 traits[count].value = RCAST(omp_uintptr_t, omp_low_lat_mem_alloc);
3810 }
else if (__kmp_match_str(
"omp_cgroup_mem_alloc", scan, &next)) {
3813 KMP_WARNING(OmpNoAllocator,
"omp_cgroup_mem_alloc");
3815 traits[count].key = omp_atk_fb_data;
3816 traits[count].value = RCAST(omp_uintptr_t, omp_cgroup_mem_alloc);
3818 }
else if (__kmp_match_str(
"omp_pteam_mem_alloc", scan, &next)) {
3821 KMP_WARNING(OmpNoAllocator,
"omp_pteam_mem_alloc");
3823 traits[count].key = omp_atk_fb_data;
3824 traits[count].value = RCAST(omp_uintptr_t, omp_pteam_mem_alloc);
3826 }
else if (__kmp_match_str(
"omp_thread_mem_alloc", scan, &next)) {
3829 KMP_WARNING(OmpNoAllocator,
"omp_thread_mem_alloc");
3831 traits[count].key = omp_atk_fb_data;
3832 traits[count].value = RCAST(omp_uintptr_t, omp_thread_mem_alloc);
3842 __kmp_def_allocator = omp_default_mem_alloc;
3843 if (next == buf || *next !=
'\0') {
3845 KMP_WARNING(StgInvalidValue, name, value);
3850 if (count == ntraits)
3856 if (__kmp_match_str(
"omp_default_mem_space", scan, &next)) {
3858 ms = omp_default_mem_space;
3859 }
else if (__kmp_match_str(
"omp_large_cap_mem_space", scan, &next)) {
3861 ms = omp_large_cap_mem_space;
3862 }
else if (__kmp_match_str(
"omp_const_mem_space", scan, &next)) {
3864 ms = omp_const_mem_space;
3865 }
else if (__kmp_match_str(
"omp_high_bw_mem_space", scan, &next)) {
3867 ms = omp_high_bw_mem_space;
3868 }
else if (__kmp_match_str(
"omp_low_lat_mem_space", scan, &next)) {
3870 ms = omp_low_lat_mem_space;
3872 __kmp_def_allocator = omp_default_mem_alloc;
3873 if (next == buf || *next !=
'\0') {
3875 KMP_WARNING(StgInvalidValue, name, value);
3884 if (__kmp_match_str(
"sync_hint", scan, &next)) {
3886 traits[count].key = omp_atk_sync_hint;
3887 if (__kmp_match_str(
"contended", scan, &next)) {
3888 traits[count].value = omp_atv_contended;
3889 }
else if (__kmp_match_str(
"uncontended", scan, &next)) {
3890 traits[count].value = omp_atv_uncontended;
3891 }
else if (__kmp_match_str(
"serialized", scan, &next)) {
3892 traits[count].value = omp_atv_serialized;
3893 }
else if (__kmp_match_str(
"private", scan, &next)) {
3894 traits[count].value = omp_atv_private;
3900 }
else if (__kmp_match_str(
"alignment", scan, &next)) {
3902 if (!isdigit(*next)) {
3908 int n = __kmp_str_to_int(scan,
',');
3909 if (n < 0 || !IS_POWER_OF_TWO(n)) {
3914 traits[count].key = omp_atk_alignment;
3915 traits[count].value = n;
3916 }
else if (__kmp_match_str(
"access", scan, &next)) {
3918 traits[count].key = omp_atk_access;
3919 if (__kmp_match_str(
"all", scan, &next)) {
3920 traits[count].value = omp_atv_all;
3921 }
else if (__kmp_match_str(
"cgroup", scan, &next)) {
3922 traits[count].value = omp_atv_cgroup;
3923 }
else if (__kmp_match_str(
"pteam", scan, &next)) {
3924 traits[count].value = omp_atv_pteam;
3925 }
else if (__kmp_match_str(
"thread", scan, &next)) {
3926 traits[count].value = omp_atv_thread;
3932 }
else if (__kmp_match_str(
"pool_size", scan, &next)) {
3934 if (!isdigit(*next)) {
3940 int n = __kmp_str_to_int(scan,
',');
3946 traits[count].key = omp_atk_pool_size;
3947 traits[count].value = n;
3948 }
else if (__kmp_match_str(
"fallback", scan, &next)) {
3950 traits[count].key = omp_atk_fallback;
3951 if (__kmp_match_str(
"default_mem_fb", scan, &next)) {
3952 traits[count].value = omp_atv_default_mem_fb;
3953 }
else if (__kmp_match_str(
"null_fb", scan, &next)) {
3954 traits[count].value = omp_atv_null_fb;
3955 }
else if (__kmp_match_str(
"abort_fb", scan, &next)) {
3956 traits[count].value = omp_atv_abort_fb;
3957 }
else if (__kmp_match_str(
"allocator_fb", scan, &next)) {
3958 traits[count].value = omp_atv_allocator_fb;
3964 }
else if (__kmp_match_str(
"pinned", scan, &next)) {
3966 traits[count].key = omp_atk_pinned;
3967 if (__kmp_str_match_true(next)) {
3968 traits[count].value = omp_atv_true;
3969 }
else if (__kmp_str_match_false(next)) {
3970 traits[count].value = omp_atv_false;
3976 }
else if (__kmp_match_str(
"partition", scan, &next)) {
3978 traits[count].key = omp_atk_partition;
3979 if (__kmp_match_str(
"environment", scan, &next)) {
3980 traits[count].value = omp_atv_environment;
3981 }
else if (__kmp_match_str(
"nearest", scan, &next)) {
3982 traits[count].value = omp_atv_nearest;
3983 }
else if (__kmp_match_str(
"blocked", scan, &next)) {
3984 traits[count].value = omp_atv_blocked;
3985 }
else if (__kmp_match_str(
"interleaved", scan, &next)) {
3986 traits[count].value = omp_atv_interleaved;
3999 if (count == ntraits)
4005 al = __kmpc_init_allocator(__kmp_get_gtid(), ms, ntraits, traits);
4006 __kmp_def_allocator = (al == omp_null_allocator) ? omp_default_mem_alloc : al;
4009static void __kmp_stg_print_allocator(kmp_str_buf_t *buffer,
char const *name,
4011 if (__kmp_def_allocator == omp_default_mem_alloc) {
4012 __kmp_stg_print_str(buffer, name,
"omp_default_mem_alloc");
4013 }
else if (__kmp_def_allocator == omp_high_bw_mem_alloc) {
4014 __kmp_stg_print_str(buffer, name,
"omp_high_bw_mem_alloc");
4015 }
else if (__kmp_def_allocator == omp_large_cap_mem_alloc) {
4016 __kmp_stg_print_str(buffer, name,
"omp_large_cap_mem_alloc");
4017 }
else if (__kmp_def_allocator == omp_const_mem_alloc) {
4018 __kmp_stg_print_str(buffer, name,
"omp_const_mem_alloc");
4019 }
else if (__kmp_def_allocator == omp_low_lat_mem_alloc) {
4020 __kmp_stg_print_str(buffer, name,
"omp_low_lat_mem_alloc");
4021 }
else if (__kmp_def_allocator == omp_cgroup_mem_alloc) {
4022 __kmp_stg_print_str(buffer, name,
"omp_cgroup_mem_alloc");
4023 }
else if (__kmp_def_allocator == omp_pteam_mem_alloc) {
4024 __kmp_stg_print_str(buffer, name,
"omp_pteam_mem_alloc");
4025 }
else if (__kmp_def_allocator == omp_thread_mem_alloc) {
4026 __kmp_stg_print_str(buffer, name,
"omp_thread_mem_alloc");
4033static void __kmp_stg_parse_omp_dynamic(
char const *name,
char const *value,
4035 __kmp_stg_parse_bool(name, value, &(__kmp_global.g.g_dynamic));
4038static void __kmp_stg_print_omp_dynamic(kmp_str_buf_t *buffer,
char const *name,
4040 __kmp_stg_print_bool(buffer, name, __kmp_global.g.g_dynamic);
4043static void __kmp_stg_parse_kmp_dynamic_mode(
char const *name,
4044 char const *value,
void *data) {
4045 if (TCR_4(__kmp_init_parallel)) {
4046 KMP_WARNING(EnvParallelWarn, name);
4047 __kmp_env_toPrint(name, 0);
4050#ifdef USE_LOAD_BALANCE
4051 else if (__kmp_str_match(
"load balance", 2, value) ||
4052 __kmp_str_match(
"load_balance", 2, value) ||
4053 __kmp_str_match(
"load-balance", 2, value) ||
4054 __kmp_str_match(
"loadbalance", 2, value) ||
4055 __kmp_str_match(
"balance", 1, value)) {
4056 __kmp_global.g.g_dynamic_mode = dynamic_load_balance;
4059 else if (__kmp_str_match(
"thread limit", 1, value) ||
4060 __kmp_str_match(
"thread_limit", 1, value) ||
4061 __kmp_str_match(
"thread-limit", 1, value) ||
4062 __kmp_str_match(
"threadlimit", 1, value) ||
4063 __kmp_str_match(
"limit", 2, value)) {
4064 __kmp_global.g.g_dynamic_mode = dynamic_thread_limit;
4065 }
else if (__kmp_str_match(
"random", 1, value)) {
4066 __kmp_global.g.g_dynamic_mode = dynamic_random;
4068 KMP_WARNING(StgInvalidValue, name, value);
4072static void __kmp_stg_print_kmp_dynamic_mode(kmp_str_buf_t *buffer,
4073 char const *name,
void *data) {
4075 if (__kmp_global.g.g_dynamic_mode == dynamic_default) {
4076 __kmp_str_buf_print(buffer,
" %s: %s \n", name, KMP_I18N_STR(NotDefined));
4078#ifdef USE_LOAD_BALANCE
4079 else if (__kmp_global.g.g_dynamic_mode == dynamic_load_balance) {
4080 __kmp_stg_print_str(buffer, name,
"load balance");
4083 else if (__kmp_global.g.g_dynamic_mode == dynamic_thread_limit) {
4084 __kmp_stg_print_str(buffer, name,
"thread limit");
4085 }
else if (__kmp_global.g.g_dynamic_mode == dynamic_random) {
4086 __kmp_stg_print_str(buffer, name,
"random");
4093#ifdef USE_LOAD_BALANCE
4098static void __kmp_stg_parse_ld_balance_interval(
char const *name,
4099 char const *value,
void *data) {
4100 double interval = __kmp_convert_to_double(value);
4101 if (interval >= 0) {
4102 __kmp_load_balance_interval = interval;
4104 KMP_WARNING(StgInvalidValue, name, value);
4108static void __kmp_stg_print_ld_balance_interval(kmp_str_buf_t *buffer,
4109 char const *name,
void *data) {
4111 __kmp_str_buf_print(buffer,
" %s=%8.6f\n", name,
4112 __kmp_load_balance_interval);
4121static void __kmp_stg_parse_init_at_fork(
char const *name,
char const *value,
4123 __kmp_stg_parse_bool(name, value, &__kmp_need_register_atfork);
4124 if (__kmp_need_register_atfork) {
4125 __kmp_need_register_atfork_specified = TRUE;
4129static void __kmp_stg_print_init_at_fork(kmp_str_buf_t *buffer,
4130 char const *name,
void *data) {
4131 __kmp_stg_print_bool(buffer, name, __kmp_need_register_atfork_specified);
4137static void __kmp_stg_parse_schedule(
char const *name,
char const *value,
4140 if (value != NULL) {
4141 size_t length = KMP_STRLEN(value);
4142 if (length > INT_MAX) {
4143 KMP_WARNING(LongValue, name);
4145 const char *semicolon;
4146 if (value[length - 1] ==
'"' || value[length - 1] ==
'\'')
4147 KMP_WARNING(UnbalancedQuotes, name);
4151 semicolon = strchr(value,
';');
4152 if (*value && semicolon != value) {
4153 const char *comma = strchr(value,
',');
4160 if (!__kmp_strcasecmp_with_sentinel(
"static", value, sentinel)) {
4161 if (!__kmp_strcasecmp_with_sentinel(
"greedy", comma,
';')) {
4162 __kmp_static = kmp_sch_static_greedy;
4164 }
else if (!__kmp_strcasecmp_with_sentinel(
"balanced", comma,
4166 __kmp_static = kmp_sch_static_balanced;
4169 }
else if (!__kmp_strcasecmp_with_sentinel(
"guided", value,
4171 if (!__kmp_strcasecmp_with_sentinel(
"iterative", comma,
';')) {
4172 __kmp_guided = kmp_sch_guided_iterative_chunked;
4174 }
else if (!__kmp_strcasecmp_with_sentinel(
"analytical", comma,
4177 __kmp_guided = kmp_sch_guided_analytical_chunked;
4181 KMP_WARNING(InvalidClause, name, value);
4183 KMP_WARNING(EmptyClause, name);
4184 }
while ((value = semicolon ? semicolon + 1 : NULL));
4190static void __kmp_stg_print_schedule(kmp_str_buf_t *buffer,
char const *name,
4192 if (__kmp_env_format) {
4193 KMP_STR_BUF_PRINT_NAME_EX(name);
4195 __kmp_str_buf_print(buffer,
" %s='", name);
4197 if (__kmp_static == kmp_sch_static_greedy) {
4198 __kmp_str_buf_print(buffer,
"%s",
"static,greedy");
4199 }
else if (__kmp_static == kmp_sch_static_balanced) {
4200 __kmp_str_buf_print(buffer,
"%s",
"static,balanced");
4202 if (__kmp_guided == kmp_sch_guided_iterative_chunked) {
4203 __kmp_str_buf_print(buffer,
";%s'\n",
"guided,iterative");
4204 }
else if (__kmp_guided == kmp_sch_guided_analytical_chunked) {
4205 __kmp_str_buf_print(buffer,
";%s'\n",
"guided,analytical");
4212static inline void __kmp_omp_schedule_restore() {
4213#if KMP_USE_HIER_SCHED
4214 __kmp_hier_scheds.deallocate();
4224static const char *__kmp_parse_single_omp_schedule(
const char *name,
4226 bool parse_hier =
false) {
4228 const char *ptr = value;
4235 while (*delim !=
',' && *delim !=
':' && *delim !=
'\0')
4237#if KMP_USE_HIER_SCHED
4238 kmp_hier_layer_e layer = kmp_hier_layer_e::LAYER_THREAD;
4240 if (*delim ==
',') {
4241 if (!__kmp_strcasecmp_with_sentinel(
"L1", ptr,
',')) {
4242 layer = kmp_hier_layer_e::LAYER_L1;
4243 }
else if (!__kmp_strcasecmp_with_sentinel(
"L2", ptr,
',')) {
4244 layer = kmp_hier_layer_e::LAYER_L2;
4245 }
else if (!__kmp_strcasecmp_with_sentinel(
"L3", ptr,
',')) {
4246 layer = kmp_hier_layer_e::LAYER_L3;
4247 }
else if (!__kmp_strcasecmp_with_sentinel(
"NUMA", ptr,
',')) {
4248 layer = kmp_hier_layer_e::LAYER_NUMA;
4251 if (layer != kmp_hier_layer_e::LAYER_THREAD && *delim !=
',') {
4253 KMP_WARNING(StgInvalidValue, name, value);
4254 __kmp_omp_schedule_restore();
4256 }
else if (layer != kmp_hier_layer_e::LAYER_THREAD) {
4258 while (*delim !=
',' && *delim !=
':' && *delim !=
'\0')
4265 if (*delim ==
':') {
4266 if (!__kmp_strcasecmp_with_sentinel(
"monotonic", ptr, *delim)) {
4269 while (*delim !=
',' && *delim !=
':' && *delim !=
'\0')
4271 }
else if (!__kmp_strcasecmp_with_sentinel(
"nonmonotonic", ptr, *delim)) {
4274 while (*delim !=
',' && *delim !=
':' && *delim !=
'\0')
4276 }
else if (!parse_hier) {
4278 KMP_WARNING(StgInvalidValue, name, value);
4279 __kmp_omp_schedule_restore();
4284 if (!__kmp_strcasecmp_with_sentinel(
"dynamic", ptr, *delim))
4285 sched = kmp_sch_dynamic_chunked;
4286 else if (!__kmp_strcasecmp_with_sentinel(
"guided", ptr, *delim))
4289 else if (!__kmp_strcasecmp_with_sentinel(
"auto", ptr, *delim))
4291 else if (!__kmp_strcasecmp_with_sentinel(
"trapezoidal", ptr, *delim))
4292 sched = kmp_sch_trapezoidal;
4293 else if (!__kmp_strcasecmp_with_sentinel(
"static", ptr, *delim))
4295#if KMP_STATIC_STEAL_ENABLED
4296 else if (!__kmp_strcasecmp_with_sentinel(
"static_steal", ptr, *delim)) {
4298 sched = kmp_sch_dynamic_chunked;
4304 KMP_WARNING(StgInvalidValue, name, value);
4305 __kmp_omp_schedule_restore();
4310 if (*delim ==
',') {
4313 if (!isdigit(*ptr)) {
4315 KMP_WARNING(StgInvalidValue, name, value);
4316 __kmp_omp_schedule_restore();
4322 __kmp_msg(kmp_ms_warning, KMP_MSG(IgnoreChunk, name, delim),
4326 sched = kmp_sch_static_chunked;
4327 chunk = __kmp_str_to_int(delim + 1, *ptr);
4329 chunk = KMP_DEFAULT_CHUNK;
4330 __kmp_msg(kmp_ms_warning, KMP_MSG(InvalidChunk, name, delim),
4332 KMP_INFORM(Using_int_Value, name, __kmp_chunk);
4341 }
else if (chunk > KMP_MAX_CHUNK) {
4342 chunk = KMP_MAX_CHUNK;
4343 __kmp_msg(kmp_ms_warning, KMP_MSG(LargeChunk, name, delim),
4345 KMP_INFORM(Using_int_Value, name, chunk);
4352 SCHEDULE_SET_MODIFIERS(sched, sched_modifier);
4354#if KMP_USE_HIER_SCHED
4355 if (layer != kmp_hier_layer_e::LAYER_THREAD) {
4356 __kmp_hier_scheds.append(sched, chunk, layer);
4360 __kmp_chunk = chunk;
4361 __kmp_sched = sched;
4366static void __kmp_stg_parse_omp_schedule(
char const *name,
char const *value,
4369 const char *ptr = value;
4372 length = KMP_STRLEN(value);
4374 if (value[length - 1] ==
'"' || value[length - 1] ==
'\'')
4375 KMP_WARNING(UnbalancedQuotes, name);
4377#if KMP_USE_HIER_SCHED
4378 if (!__kmp_strcasecmp_with_sentinel(
"EXPERIMENTAL", ptr,
' ')) {
4381 while ((ptr = __kmp_parse_single_omp_schedule(name, ptr,
true))) {
4382 while (*ptr ==
' ' || *ptr ==
'\t' || *ptr ==
':')
4389 __kmp_parse_single_omp_schedule(name, ptr);
4391 KMP_WARNING(EmptyString, name);
4393#if KMP_USE_HIER_SCHED
4394 __kmp_hier_scheds.sort();
4396 K_DIAG(1, (
"__kmp_static == %d\n", __kmp_static))
4397 K_DIAG(1, (
"__kmp_guided == %d\n", __kmp_guided))
4398 K_DIAG(1, (
"__kmp_sched == %d\n", __kmp_sched))
4399 K_DIAG(1, (
"__kmp_chunk == %d\n", __kmp_chunk))
4402static void __kmp_stg_print_omp_schedule(kmp_str_buf_t *buffer,
4403 char const *name,
void *data) {
4404 if (__kmp_env_format) {
4405 KMP_STR_BUF_PRINT_NAME_EX(name);
4407 __kmp_str_buf_print(buffer,
" %s='", name);
4409 enum sched_type sched = SCHEDULE_WITHOUT_MODIFIERS(__kmp_sched);
4410 if (SCHEDULE_HAS_MONOTONIC(__kmp_sched)) {
4411 __kmp_str_buf_print(buffer,
"monotonic:");
4412 }
else if (SCHEDULE_HAS_NONMONOTONIC(__kmp_sched)) {
4413 __kmp_str_buf_print(buffer,
"nonmonotonic:");
4417 case kmp_sch_dynamic_chunked:
4418 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"dynamic", __kmp_chunk);
4420 case kmp_sch_guided_iterative_chunked:
4421 case kmp_sch_guided_analytical_chunked:
4422 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"guided", __kmp_chunk);
4424 case kmp_sch_trapezoidal:
4425 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"trapezoidal", __kmp_chunk);
4428 case kmp_sch_static_chunked:
4429 case kmp_sch_static_balanced:
4430 case kmp_sch_static_greedy:
4431 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"static", __kmp_chunk);
4433 case kmp_sch_static_steal:
4434 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"static_steal", __kmp_chunk);
4437 __kmp_str_buf_print(buffer,
"%s,%d'\n",
"auto", __kmp_chunk);
4440 KMP_ASSERT2(
false,
"Unhandled sched_type enumeration");
4441 KMP_BUILTIN_UNREACHABLE;
4446 case kmp_sch_dynamic_chunked:
4447 __kmp_str_buf_print(buffer,
"%s'\n",
"dynamic");
4449 case kmp_sch_guided_iterative_chunked:
4450 case kmp_sch_guided_analytical_chunked:
4451 __kmp_str_buf_print(buffer,
"%s'\n",
"guided");
4453 case kmp_sch_trapezoidal:
4454 __kmp_str_buf_print(buffer,
"%s'\n",
"trapezoidal");
4457 case kmp_sch_static_chunked:
4458 case kmp_sch_static_balanced:
4459 case kmp_sch_static_greedy:
4460 __kmp_str_buf_print(buffer,
"%s'\n",
"static");
4462 case kmp_sch_static_steal:
4463 __kmp_str_buf_print(buffer,
"%s'\n",
"static_steal");
4466 __kmp_str_buf_print(buffer,
"%s'\n",
"auto");
4469 KMP_ASSERT2(
false,
"Unhandled sched_type enumeration");
4470 KMP_BUILTIN_UNREACHABLE;
4476#if KMP_USE_HIER_SCHED
4479static void __kmp_stg_parse_kmp_hand_thread(
char const *name,
char const *value,
4481 __kmp_stg_parse_bool(name, value, &(__kmp_dispatch_hand_threading));
4484static void __kmp_stg_print_kmp_hand_thread(kmp_str_buf_t *buffer,
4485 char const *name,
void *data) {
4486 __kmp_stg_print_bool(buffer, name, __kmp_dispatch_hand_threading);
4492static void __kmp_stg_parse_kmp_force_monotonic(
char const *name,
4493 char const *value,
void *data) {
4494 __kmp_stg_parse_bool(name, value, &(__kmp_force_monotonic));
4497static void __kmp_stg_print_kmp_force_monotonic(kmp_str_buf_t *buffer,
4498 char const *name,
void *data) {
4499 __kmp_stg_print_bool(buffer, name, __kmp_force_monotonic);
4505static void __kmp_stg_parse_atomic_mode(
char const *name,
char const *value,
4511#ifdef KMP_GOMP_COMPAT
4514 __kmp_stg_parse_int(name, value, 0, max, &mode);
4519 __kmp_atomic_mode = mode;
4523static void __kmp_stg_print_atomic_mode(kmp_str_buf_t *buffer,
char const *name,
4525 __kmp_stg_print_int(buffer, name, __kmp_atomic_mode);
4531static void __kmp_stg_parse_consistency_check(
char const *name,
4532 char const *value,
void *data) {
4533 if (TCR_4(__kmp_init_serial)) {
4534 KMP_WARNING(EnvSerialWarn, name);
4537 if (!__kmp_strcasecmp_with_sentinel(
"all", value, 0)) {
4543 __kmp_env_consistency_check = TRUE;
4544 }
else if (!__kmp_strcasecmp_with_sentinel(
"none", value, 0)) {
4545 __kmp_env_consistency_check = FALSE;
4547 KMP_WARNING(StgInvalidValue, name, value);
4551static void __kmp_stg_print_consistency_check(kmp_str_buf_t *buffer,
4552 char const *name,
void *data) {
4554 const char *value = NULL;
4556 if (__kmp_env_consistency_check) {
4562 if (value != NULL) {
4563 __kmp_stg_print_str(buffer, name, value);
4574static void __kmp_stg_parse_itt_prepare_delay(
char const *name,
4575 char const *value,
void *data) {
4579 __kmp_stg_parse_int(name, value, 0, INT_MAX, &delay);
4580 __kmp_itt_prepare_delay = delay;
4583static void __kmp_stg_print_itt_prepare_delay(kmp_str_buf_t *buffer,
4584 char const *name,
void *data) {
4585 __kmp_stg_print_uint64(buffer, name, __kmp_itt_prepare_delay);
4595static void __kmp_stg_parse_malloc_pool_incr(
char const *name,
4596 char const *value,
void *data) {
4597 __kmp_stg_parse_size(name, value, KMP_MIN_MALLOC_POOL_INCR,
4598 KMP_MAX_MALLOC_POOL_INCR, NULL, &__kmp_malloc_pool_incr,
4602static void __kmp_stg_print_malloc_pool_incr(kmp_str_buf_t *buffer,
4603 char const *name,
void *data) {
4604 __kmp_stg_print_size(buffer, name, __kmp_malloc_pool_incr);
4613static void __kmp_stg_parse_par_range_env(
char const *name,
char const *value,
4615 __kmp_stg_parse_par_range(name, value, &__kmp_par_range,
4616 __kmp_par_range_routine, __kmp_par_range_filename,
4617 &__kmp_par_range_lb, &__kmp_par_range_ub);
4620static void __kmp_stg_print_par_range_env(kmp_str_buf_t *buffer,
4621 char const *name,
void *data) {
4622 if (__kmp_par_range != 0) {
4623 __kmp_stg_print_str(buffer, name, par_range_to_print);
4632static void __kmp_stg_parse_gtid_mode(
char const *name,
char const *value,
4642#ifdef KMP_TDATA_GTID
4645 __kmp_stg_parse_int(name, value, 0, max, &mode);
4649 __kmp_adjust_gtid_mode = TRUE;
4651 __kmp_gtid_mode = mode;
4652 __kmp_adjust_gtid_mode = FALSE;
4656static void __kmp_stg_print_gtid_mode(kmp_str_buf_t *buffer,
char const *name,
4658 if (__kmp_adjust_gtid_mode) {
4659 __kmp_stg_print_int(buffer, name, 0);
4661 __kmp_stg_print_int(buffer, name, __kmp_gtid_mode);
4668static void __kmp_stg_parse_lock_block(
char const *name,
char const *value,
4670 __kmp_stg_parse_int(name, value, 0, KMP_INT_MAX, &__kmp_num_locks_in_block);
4673static void __kmp_stg_print_lock_block(kmp_str_buf_t *buffer,
char const *name,
4675 __kmp_stg_print_int(buffer, name, __kmp_num_locks_in_block);
4681#if KMP_USE_DYNAMIC_LOCK
4682#define KMP_STORE_LOCK_SEQ(a) (__kmp_user_lock_seq = lockseq_##a)
4684#define KMP_STORE_LOCK_SEQ(a)
4687static void __kmp_stg_parse_lock_kind(
char const *name,
char const *value,
4689 if (__kmp_init_user_locks) {
4690 KMP_WARNING(EnvLockWarn, name);
4694 if (__kmp_str_match(
"tas", 2, value) ||
4695 __kmp_str_match(
"test and set", 2, value) ||
4696 __kmp_str_match(
"test_and_set", 2, value) ||
4697 __kmp_str_match(
"test-and-set", 2, value) ||
4698 __kmp_str_match(
"test andset", 2, value) ||
4699 __kmp_str_match(
"test_andset", 2, value) ||
4700 __kmp_str_match(
"test-andset", 2, value) ||
4701 __kmp_str_match(
"testand set", 2, value) ||
4702 __kmp_str_match(
"testand_set", 2, value) ||
4703 __kmp_str_match(
"testand-set", 2, value) ||
4704 __kmp_str_match(
"testandset", 2, value)) {
4705 __kmp_user_lock_kind = lk_tas;
4706 KMP_STORE_LOCK_SEQ(tas);
4709 else if (__kmp_str_match(
"futex", 1, value)) {
4710 if (__kmp_futex_determine_capable()) {
4711 __kmp_user_lock_kind = lk_futex;
4712 KMP_STORE_LOCK_SEQ(futex);
4714 KMP_WARNING(FutexNotSupported, name, value);
4718 else if (__kmp_str_match(
"ticket", 2, value)) {
4719 __kmp_user_lock_kind = lk_ticket;
4720 KMP_STORE_LOCK_SEQ(ticket);
4721 }
else if (__kmp_str_match(
"queuing", 1, value) ||
4722 __kmp_str_match(
"queue", 1, value)) {
4723 __kmp_user_lock_kind = lk_queuing;
4724 KMP_STORE_LOCK_SEQ(queuing);
4725 }
else if (__kmp_str_match(
"drdpa ticket", 1, value) ||
4726 __kmp_str_match(
"drdpa_ticket", 1, value) ||
4727 __kmp_str_match(
"drdpa-ticket", 1, value) ||
4728 __kmp_str_match(
"drdpaticket", 1, value) ||
4729 __kmp_str_match(
"drdpa", 1, value)) {
4730 __kmp_user_lock_kind = lk_drdpa;
4731 KMP_STORE_LOCK_SEQ(drdpa);
4733#if KMP_USE_ADAPTIVE_LOCKS
4734 else if (__kmp_str_match(
"adaptive", 1, value)) {
4735 if (__kmp_cpuinfo.flags.rtm) {
4736 __kmp_user_lock_kind = lk_adaptive;
4737 KMP_STORE_LOCK_SEQ(adaptive);
4739 KMP_WARNING(AdaptiveNotSupported, name, value);
4740 __kmp_user_lock_kind = lk_queuing;
4741 KMP_STORE_LOCK_SEQ(queuing);
4745#if KMP_USE_DYNAMIC_LOCK && KMP_USE_TSX
4746 else if (__kmp_str_match(
"rtm_queuing", 1, value)) {
4747 if (__kmp_cpuinfo.flags.rtm) {
4748 __kmp_user_lock_kind = lk_rtm_queuing;
4749 KMP_STORE_LOCK_SEQ(rtm_queuing);
4751 KMP_WARNING(AdaptiveNotSupported, name, value);
4752 __kmp_user_lock_kind = lk_queuing;
4753 KMP_STORE_LOCK_SEQ(queuing);
4755 }
else if (__kmp_str_match(
"rtm_spin", 1, value)) {
4756 if (__kmp_cpuinfo.flags.rtm) {
4757 __kmp_user_lock_kind = lk_rtm_spin;
4758 KMP_STORE_LOCK_SEQ(rtm_spin);
4760 KMP_WARNING(AdaptiveNotSupported, name, value);
4761 __kmp_user_lock_kind = lk_tas;
4762 KMP_STORE_LOCK_SEQ(queuing);
4764 }
else if (__kmp_str_match(
"hle", 1, value)) {
4765 __kmp_user_lock_kind = lk_hle;
4766 KMP_STORE_LOCK_SEQ(hle);
4770 KMP_WARNING(StgInvalidValue, name, value);
4774static void __kmp_stg_print_lock_kind(kmp_str_buf_t *buffer,
char const *name,
4776 const char *value = NULL;
4778 switch (__kmp_user_lock_kind) {
4793#if KMP_USE_DYNAMIC_LOCK && KMP_USE_TSX
4794 case lk_rtm_queuing:
4795 value =
"rtm_queuing";
4818#if KMP_USE_ADAPTIVE_LOCKS
4825 if (value != NULL) {
4826 __kmp_stg_print_str(buffer, name, value);
4835static void __kmp_stg_parse_spin_backoff_params(
const char *name,
4836 const char *value,
void *data) {
4837 const char *next = value;
4840 int prev_comma = FALSE;
4843 kmp_uint32 max_backoff = __kmp_spin_backoff_params.max_backoff;
4844 kmp_uint32 min_tick = __kmp_spin_backoff_params.min_tick;
4848 for (i = 0; i < 3; i++) {
4851 if (*next ==
'\0') {
4856 if (((*next <
'0' || *next >
'9') && *next !=
',') || total > 2) {
4857 KMP_WARNING(EnvSyntaxError, name, value);
4863 if (total == 0 || prev_comma) {
4871 if (*next >=
'0' && *next <=
'9') {
4873 const char *buf = next;
4874 char const *msg = NULL;
4879 const char *tmp = next;
4881 if ((*next ==
' ' || *next ==
'\t') && (*tmp >=
'0' && *tmp <=
'9')) {
4882 KMP_WARNING(EnvSpacesNotAllowed, name, value);
4886 num = __kmp_str_to_int(buf, *next);
4888 msg = KMP_I18N_STR(ValueTooSmall);
4893 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
4894 KMP_INFORM(Using_int_Value, name, num);
4898 }
else if (total == 2) {
4904 KMP_WARNING(EnvSyntaxError, name, value);
4907 __kmp_spin_backoff_params.max_backoff = max_backoff;
4908 __kmp_spin_backoff_params.min_tick = min_tick;
4911static void __kmp_stg_print_spin_backoff_params(kmp_str_buf_t *buffer,
4912 char const *name,
void *data) {
4913 if (__kmp_env_format) {
4914 KMP_STR_BUF_PRINT_NAME_EX(name);
4916 __kmp_str_buf_print(buffer,
" %s='", name);
4918 __kmp_str_buf_print(buffer,
"%d,%d'\n", __kmp_spin_backoff_params.max_backoff,
4919 __kmp_spin_backoff_params.min_tick);
4922#if KMP_USE_ADAPTIVE_LOCKS
4929static void __kmp_stg_parse_adaptive_lock_props(
const char *name,
4930 const char *value,
void *data) {
4931 int max_retries = 0;
4932 int max_badness = 0;
4934 const char *next = value;
4937 int prev_comma = FALSE;
4943 for (i = 0; i < 3; i++) {
4946 if (*next ==
'\0') {
4951 if (((*next <
'0' || *next >
'9') && *next !=
',') || total > 2) {
4952 KMP_WARNING(EnvSyntaxError, name, value);
4958 if (total == 0 || prev_comma) {
4966 if (*next >=
'0' && *next <=
'9') {
4968 const char *buf = next;
4969 char const *msg = NULL;
4974 const char *tmp = next;
4976 if ((*next ==
' ' || *next ==
'\t') && (*tmp >=
'0' && *tmp <=
'9')) {
4977 KMP_WARNING(EnvSpacesNotAllowed, name, value);
4981 num = __kmp_str_to_int(buf, *next);
4983 msg = KMP_I18N_STR(ValueTooSmall);
4988 KMP_WARNING(ParseSizeIntWarn, name, value, msg);
4989 KMP_INFORM(Using_int_Value, name, num);
4993 }
else if (total == 2) {
4999 KMP_WARNING(EnvSyntaxError, name, value);
5002 __kmp_adaptive_backoff_params.max_soft_retries = max_retries;
5003 __kmp_adaptive_backoff_params.max_badness = max_badness;
5006static void __kmp_stg_print_adaptive_lock_props(kmp_str_buf_t *buffer,
5007 char const *name,
void *data) {
5008 if (__kmp_env_format) {
5009 KMP_STR_BUF_PRINT_NAME_EX(name);
5011 __kmp_str_buf_print(buffer,
" %s='", name);
5013 __kmp_str_buf_print(buffer,
"%d,%d'\n",
5014 __kmp_adaptive_backoff_params.max_soft_retries,
5015 __kmp_adaptive_backoff_params.max_badness);
5018#if KMP_DEBUG_ADAPTIVE_LOCKS
5020static void __kmp_stg_parse_speculative_statsfile(
char const *name,
5023 __kmp_stg_parse_file(name, value,
"",
5024 CCAST(
char **, &__kmp_speculative_statsfile));
5027static void __kmp_stg_print_speculative_statsfile(kmp_str_buf_t *buffer,
5030 if (__kmp_str_match(
"-", 0, __kmp_speculative_statsfile)) {
5031 __kmp_stg_print_str(buffer, name,
"stdout");
5033 __kmp_stg_print_str(buffer, name, __kmp_speculative_statsfile);
5049static kmp_hw_t __kmp_hw_subset_break_tie(
const kmp_hw_t *possible,
5050 size_t num_possible) {
5051 for (
size_t i = 0; i < num_possible; ++i) {
5052 if (possible[i] == KMP_HW_THREAD)
5053 return KMP_HW_THREAD;
5054 else if (possible[i] == KMP_HW_CORE)
5056 else if (possible[i] == KMP_HW_SOCKET)
5057 return KMP_HW_SOCKET;
5059 return KMP_HW_UNKNOWN;
5066static kmp_hw_t __kmp_stg_parse_hw_subset_name(
char const *token) {
5067 size_t index, num_possible, token_length;
5068 kmp_hw_t possible[KMP_HW_LAST];
5074 while (isalnum(*end) || *end ==
'_') {
5081 KMP_FOREACH_HW_TYPE(type) { possible[num_possible++] = type; }
5088 while (num_possible > 1 && index < token_length) {
5089 size_t n = num_possible;
5090 char token_char = (char)toupper(token[index]);
5091 for (
size_t i = 0; i < n; ++i) {
5093 kmp_hw_t type = possible[i];
5094 s = __kmp_hw_get_keyword(type,
false);
5095 if (index < KMP_STRLEN(s)) {
5096 char c = (char)toupper(s[index]);
5098 if (c != token_char) {
5099 possible[i] = KMP_HW_UNKNOWN;
5106 for (
size_t i = 0; i < n; ++i) {
5107 if (possible[i] != KMP_HW_UNKNOWN) {
5108 kmp_hw_t temp = possible[i];
5109 possible[i] = possible[start];
5110 possible[start] = temp;
5114 KMP_ASSERT(start == num_possible);
5120 if (num_possible > 1)
5121 return __kmp_hw_subset_break_tie(possible, num_possible);
5122 if (num_possible == 1)
5124 return KMP_HW_UNKNOWN;
5129#define MAX_T_LEVEL KMP_HW_LAST
5130#define MAX_STR_LEN 512
5131static void __kmp_stg_parse_hw_subset(
char const *name,
char const *value,
5135 kmp_setting_t **rivals = (kmp_setting_t **)data;
5136 if (strcmp(name,
"KMP_PLACE_THREADS") == 0) {
5137 KMP_INFORM(EnvVarDeprecated, name,
"KMP_HW_SUBSET");
5139 if (__kmp_stg_check_rivals(name, value, rivals)) {
5143 char *components[MAX_T_LEVEL];
5144 char const *digits =
"0123456789";
5145 char input[MAX_STR_LEN];
5146 size_t len = 0, mlen = MAX_STR_LEN;
5148 bool absolute =
false;
5150 char *pos = CCAST(
char *, value);
5151 while (*pos && mlen) {
5153 if (len == 0 && *pos ==
':') {
5156 input[len] = (char)(toupper(*pos));
5157 if (input[len] ==
'X')
5159 if (input[len] ==
'O' && strchr(digits, *(pos + 1)))
5167 if (len == 0 || mlen == 0) {
5173 components[level++] = pos;
5174 while ((pos = strchr(pos,
','))) {
5175 if (level >= MAX_T_LEVEL)
5178 components[level++] = ++pos;
5181 __kmp_hw_subset = kmp_hw_subset_t::allocate();
5183 __kmp_hw_subset->set_absolute();
5186 for (
int i = 0; i < level; ++i) {
5188 char *core_components[MAX_T_LEVEL];
5190 pos = components[i];
5191 core_components[core_level++] = pos;
5192 while ((pos = strchr(pos,
'&'))) {
5193 if (core_level >= MAX_T_LEVEL)
5196 core_components[core_level++] = ++pos;
5199 for (
int j = 0; j < core_level; ++j) {
5206 if (isdigit(*core_components[j])) {
5207 num = atoi(core_components[j]);
5211 pos = core_components[j] + strspn(core_components[j], digits);
5212 }
else if (*core_components[j] ==
'*') {
5213 num = kmp_hw_subset_t::USE_ALL;
5214 pos = core_components[j] + 1;
5216 num = kmp_hw_subset_t::USE_ALL;
5217 pos = core_components[j];
5220 offset_ptr = strchr(core_components[j],
'@');
5221 attr_ptr = strchr(core_components[j],
':');
5224 offset = atoi(offset_ptr + 1);
5230#if KMP_ARCH_X86 || KMP_ARCH_X86_64
5231 if (__kmp_str_match(
"intel_core", -1, attr_ptr + 1)) {
5232 attr.set_core_type(KMP_HW_CORE_TYPE_CORE);
5233 }
else if (__kmp_str_match(
"intel_atom", -1, attr_ptr + 1)) {
5234 attr.set_core_type(KMP_HW_CORE_TYPE_ATOM);
5237 if (__kmp_str_match(
"eff", 3, attr_ptr + 1)) {
5238 const char *number = attr_ptr + 1;
5240 while (isalpha(*number))
5242 if (!isdigit(*number)) {
5245 int efficiency = atoi(number);
5246 attr.set_core_eff(efficiency);
5253 kmp_hw_t type = __kmp_stg_parse_hw_subset_name(pos);
5254 if (type == KMP_HW_UNKNOWN) {
5258 if (attr && type != KMP_HW_CORE)
5261 if (type != KMP_HW_CORE && __kmp_hw_subset->specified(type)) {
5264 __kmp_hw_subset->push_back(num, type, offset, attr);
5269 KMP_WARNING(AffHWSubsetInvalid, name, value);
5270 if (__kmp_hw_subset) {
5271 kmp_hw_subset_t::deallocate(__kmp_hw_subset);
5272 __kmp_hw_subset =
nullptr;
5277static void __kmp_stg_print_hw_subset(kmp_str_buf_t *buffer,
char const *name,
5281 if (!__kmp_hw_subset)
5283 __kmp_str_buf_init(&buf);
5284 if (__kmp_env_format)
5285 KMP_STR_BUF_PRINT_NAME_EX(name);
5287 __kmp_str_buf_print(buffer,
" %s='", name);
5289 depth = __kmp_hw_subset->get_depth();
5290 for (
int i = 0; i < depth; ++i) {
5291 const auto &item = __kmp_hw_subset->at(i);
5293 __kmp_str_buf_print(&buf,
"%c",
',');
5294 for (
int j = 0; j < item.num_attrs; ++j) {
5295 __kmp_str_buf_print(&buf,
"%s%d%s", (j > 0 ?
"&" :
""), item.num[j],
5296 __kmp_hw_get_keyword(item.type));
5297 if (item.attr[j].is_core_type_valid())
5298 __kmp_str_buf_print(
5300 __kmp_hw_get_core_type_keyword(item.attr[j].get_core_type()));
5301 if (item.attr[j].is_core_eff_valid())
5302 __kmp_str_buf_print(&buf,
":eff%d", item.attr[j].get_core_eff());
5304 __kmp_str_buf_print(&buf,
"@%d", item.offset[j]);
5307 __kmp_str_buf_print(buffer,
"%s'\n", buf.str);
5308 __kmp_str_buf_free(&buf);
5315static void __kmp_stg_parse_forkjoin_frames(
char const *name,
char const *value,
5317 __kmp_stg_parse_bool(name, value, &__kmp_forkjoin_frames);
5320static void __kmp_stg_print_forkjoin_frames(kmp_str_buf_t *buffer,
5321 char const *name,
void *data) {
5322 __kmp_stg_print_bool(buffer, name, __kmp_forkjoin_frames);
5328static void __kmp_stg_parse_forkjoin_frames_mode(
char const *name,
5331 __kmp_stg_parse_int(name, value, 0, 3, &__kmp_forkjoin_frames_mode);
5334static void __kmp_stg_print_forkjoin_frames_mode(kmp_str_buf_t *buffer,
5335 char const *name,
void *data) {
5336 __kmp_stg_print_int(buffer, name, __kmp_forkjoin_frames_mode);
5343static void __kmp_stg_parse_task_throttling(
char const *name,
char const *value,
5345 __kmp_stg_parse_bool(name, value, &__kmp_enable_task_throttling);
5348static void __kmp_stg_print_task_throttling(kmp_str_buf_t *buffer,
5349 char const *name,
void *data) {
5350 __kmp_stg_print_bool(buffer, name, __kmp_enable_task_throttling);
5353#if KMP_HAVE_MWAIT || KMP_HAVE_UMWAIT
5357static void __kmp_stg_parse_user_level_mwait(
char const *name,
5358 char const *value,
void *data) {
5359 __kmp_stg_parse_bool(name, value, &__kmp_user_level_mwait);
5362static void __kmp_stg_print_user_level_mwait(kmp_str_buf_t *buffer,
5363 char const *name,
void *data) {
5364 __kmp_stg_print_bool(buffer, name, __kmp_user_level_mwait);
5370static void __kmp_stg_parse_mwait_hints(
char const *name,
char const *value,
5372 __kmp_stg_parse_int(name, value, 0, INT_MAX, &__kmp_mwait_hints);
5375static void __kmp_stg_print_mwait_hints(kmp_str_buf_t *buffer,
char const *name,
5377 __kmp_stg_print_int(buffer, name, __kmp_mwait_hints);
5387static void __kmp_stg_parse_tpause(
char const *name,
char const *value,
5389 __kmp_stg_parse_int(name, value, 0, INT_MAX, &__kmp_tpause_state);
5390 if (__kmp_tpause_state != 0) {
5392 if (__kmp_tpause_state == 2)
5393 __kmp_tpause_hint = 0;
5397static void __kmp_stg_print_tpause(kmp_str_buf_t *buffer,
char const *name,
5399 __kmp_stg_print_int(buffer, name, __kmp_tpause_state);
5406static void __kmp_stg_parse_omp_display_env(
char const *name,
char const *value,
5408 if (__kmp_str_match(
"VERBOSE", 1, value)) {
5409 __kmp_display_env_verbose = TRUE;
5411 __kmp_stg_parse_bool(name, value, &__kmp_display_env);
5415static void __kmp_stg_print_omp_display_env(kmp_str_buf_t *buffer,
5416 char const *name,
void *data) {
5417 if (__kmp_display_env_verbose) {
5418 __kmp_stg_print_str(buffer, name,
"VERBOSE");
5420 __kmp_stg_print_bool(buffer, name, __kmp_display_env);
5424static void __kmp_stg_parse_omp_cancellation(
char const *name,
5425 char const *value,
void *data) {
5426 if (TCR_4(__kmp_init_parallel)) {
5427 KMP_WARNING(EnvParallelWarn, name);
5430 __kmp_stg_parse_bool(name, value, &__kmp_omp_cancellation);
5433static void __kmp_stg_print_omp_cancellation(kmp_str_buf_t *buffer,
5434 char const *name,
void *data) {
5435 __kmp_stg_print_bool(buffer, name, __kmp_omp_cancellation);
5441static void __kmp_stg_parse_omp_tool(
char const *name,
char const *value,
5443 __kmp_stg_parse_bool(name, value, &__kmp_tool);
5446static void __kmp_stg_print_omp_tool(kmp_str_buf_t *buffer,
char const *name,
5448 if (__kmp_env_format) {
5449 KMP_STR_BUF_PRINT_BOOL_EX(name, __kmp_tool,
"enabled",
"disabled");
5451 __kmp_str_buf_print(buffer,
" %s=%s\n", name,
5452 __kmp_tool ?
"enabled" :
"disabled");
5456char *__kmp_tool_libraries = NULL;
5458static void __kmp_stg_parse_omp_tool_libraries(
char const *name,
5459 char const *value,
void *data) {
5460 __kmp_stg_parse_str(name, value, &__kmp_tool_libraries);
5463static void __kmp_stg_print_omp_tool_libraries(kmp_str_buf_t *buffer,
5464 char const *name,
void *data) {
5465 if (__kmp_tool_libraries)
5466 __kmp_stg_print_str(buffer, name, __kmp_tool_libraries);
5468 if (__kmp_env_format) {
5469 KMP_STR_BUF_PRINT_NAME;
5471 __kmp_str_buf_print(buffer,
" %s", name);
5473 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
5477char *__kmp_tool_verbose_init = NULL;
5479static void __kmp_stg_parse_omp_tool_verbose_init(
char const *name,
5482 __kmp_stg_parse_str(name, value, &__kmp_tool_verbose_init);
5485static void __kmp_stg_print_omp_tool_verbose_init(kmp_str_buf_t *buffer,
5488 if (__kmp_tool_verbose_init)
5489 __kmp_stg_print_str(buffer, name, __kmp_tool_verbose_init);
5491 if (__kmp_env_format) {
5492 KMP_STR_BUF_PRINT_NAME;
5494 __kmp_str_buf_print(buffer,
" %s", name);
5496 __kmp_str_buf_print(buffer,
": %s\n", KMP_I18N_STR(NotDefined));
5504static kmp_setting_t __kmp_stg_table[] = {
5506 {
"KMP_ALL_THREADS", __kmp_stg_parse_device_thread_limit, NULL, NULL, 0, 0},
5507 {
"KMP_BLOCKTIME", __kmp_stg_parse_blocktime, __kmp_stg_print_blocktime,
5509 {
"KMP_USE_YIELD", __kmp_stg_parse_use_yield, __kmp_stg_print_use_yield,
5511 {
"KMP_DUPLICATE_LIB_OK", __kmp_stg_parse_duplicate_lib_ok,
5512 __kmp_stg_print_duplicate_lib_ok, NULL, 0, 0},
5513 {
"KMP_LIBRARY", __kmp_stg_parse_wait_policy, __kmp_stg_print_wait_policy,
5515 {
"KMP_DEVICE_THREAD_LIMIT", __kmp_stg_parse_device_thread_limit,
5516 __kmp_stg_print_device_thread_limit, NULL, 0, 0},
5518 {
"KMP_MONITOR_STACKSIZE", __kmp_stg_parse_monitor_stacksize,
5519 __kmp_stg_print_monitor_stacksize, NULL, 0, 0},
5521 {
"KMP_SETTINGS", __kmp_stg_parse_settings, __kmp_stg_print_settings, NULL,
5523 {
"KMP_STACKOFFSET", __kmp_stg_parse_stackoffset,
5524 __kmp_stg_print_stackoffset, NULL, 0, 0},
5525 {
"KMP_STACKSIZE", __kmp_stg_parse_stacksize, __kmp_stg_print_stacksize,
5527 {
"KMP_STACKPAD", __kmp_stg_parse_stackpad, __kmp_stg_print_stackpad, NULL,
5529 {
"KMP_VERSION", __kmp_stg_parse_version, __kmp_stg_print_version, NULL, 0,
5531 {
"KMP_WARNINGS", __kmp_stg_parse_warnings, __kmp_stg_print_warnings, NULL,
5534 {
"KMP_NESTING_MODE", __kmp_stg_parse_nesting_mode,
5535 __kmp_stg_print_nesting_mode, NULL, 0, 0},
5536 {
"OMP_NESTED", __kmp_stg_parse_nested, __kmp_stg_print_nested, NULL, 0, 0},
5537 {
"OMP_NUM_THREADS", __kmp_stg_parse_num_threads,
5538 __kmp_stg_print_num_threads, NULL, 0, 0},
5539 {
"OMP_STACKSIZE", __kmp_stg_parse_stacksize, __kmp_stg_print_stacksize,
5542 {
"KMP_TASKING", __kmp_stg_parse_tasking, __kmp_stg_print_tasking, NULL, 0,
5544 {
"KMP_TASK_STEALING_CONSTRAINT", __kmp_stg_parse_task_stealing,
5545 __kmp_stg_print_task_stealing, NULL, 0, 0},
5546 {
"OMP_MAX_ACTIVE_LEVELS", __kmp_stg_parse_max_active_levels,
5547 __kmp_stg_print_max_active_levels, NULL, 0, 0},
5548 {
"OMP_DEFAULT_DEVICE", __kmp_stg_parse_default_device,
5549 __kmp_stg_print_default_device, NULL, 0, 0},
5550 {
"OMP_TARGET_OFFLOAD", __kmp_stg_parse_target_offload,
5551 __kmp_stg_print_target_offload, NULL, 0, 0},
5552 {
"OMP_MAX_TASK_PRIORITY", __kmp_stg_parse_max_task_priority,
5553 __kmp_stg_print_max_task_priority, NULL, 0, 0},
5554 {
"KMP_TASKLOOP_MIN_TASKS", __kmp_stg_parse_taskloop_min_tasks,
5555 __kmp_stg_print_taskloop_min_tasks, NULL, 0, 0},
5556 {
"OMP_THREAD_LIMIT", __kmp_stg_parse_thread_limit,
5557 __kmp_stg_print_thread_limit, NULL, 0, 0},
5558 {
"KMP_TEAMS_THREAD_LIMIT", __kmp_stg_parse_teams_thread_limit,
5559 __kmp_stg_print_teams_thread_limit, NULL, 0, 0},
5560 {
"OMP_NUM_TEAMS", __kmp_stg_parse_nteams, __kmp_stg_print_nteams, NULL, 0,
5562 {
"OMP_TEAMS_THREAD_LIMIT", __kmp_stg_parse_teams_th_limit,
5563 __kmp_stg_print_teams_th_limit, NULL, 0, 0},
5564 {
"OMP_WAIT_POLICY", __kmp_stg_parse_wait_policy,
5565 __kmp_stg_print_wait_policy, NULL, 0, 0},
5566 {
"KMP_DISP_NUM_BUFFERS", __kmp_stg_parse_disp_buffers,
5567 __kmp_stg_print_disp_buffers, NULL, 0, 0},
5568 {
"KMP_HOT_TEAMS_MAX_LEVEL", __kmp_stg_parse_hot_teams_level,
5569 __kmp_stg_print_hot_teams_level, NULL, 0, 0},
5570 {
"KMP_HOT_TEAMS_MODE", __kmp_stg_parse_hot_teams_mode,
5571 __kmp_stg_print_hot_teams_mode, NULL, 0, 0},
5573#if KMP_HANDLE_SIGNALS
5574 {
"KMP_HANDLE_SIGNALS", __kmp_stg_parse_handle_signals,
5575 __kmp_stg_print_handle_signals, NULL, 0, 0},
5578#if KMP_ARCH_X86 || KMP_ARCH_X86_64
5579 {
"KMP_INHERIT_FP_CONTROL", __kmp_stg_parse_inherit_fp_control,
5580 __kmp_stg_print_inherit_fp_control, NULL, 0, 0},
5583#ifdef KMP_GOMP_COMPAT
5584 {
"GOMP_STACKSIZE", __kmp_stg_parse_stacksize, NULL, NULL, 0, 0},
5588 {
"KMP_A_DEBUG", __kmp_stg_parse_a_debug, __kmp_stg_print_a_debug, NULL, 0,
5590 {
"KMP_B_DEBUG", __kmp_stg_parse_b_debug, __kmp_stg_print_b_debug, NULL, 0,
5592 {
"KMP_C_DEBUG", __kmp_stg_parse_c_debug, __kmp_stg_print_c_debug, NULL, 0,
5594 {
"KMP_D_DEBUG", __kmp_stg_parse_d_debug, __kmp_stg_print_d_debug, NULL, 0,
5596 {
"KMP_E_DEBUG", __kmp_stg_parse_e_debug, __kmp_stg_print_e_debug, NULL, 0,
5598 {
"KMP_F_DEBUG", __kmp_stg_parse_f_debug, __kmp_stg_print_f_debug, NULL, 0,
5600 {
"KMP_DEBUG", __kmp_stg_parse_debug, NULL, NULL, 0, 0},
5601 {
"KMP_DEBUG_BUF", __kmp_stg_parse_debug_buf, __kmp_stg_print_debug_buf,
5603 {
"KMP_DEBUG_BUF_ATOMIC", __kmp_stg_parse_debug_buf_atomic,
5604 __kmp_stg_print_debug_buf_atomic, NULL, 0, 0},
5605 {
"KMP_DEBUG_BUF_CHARS", __kmp_stg_parse_debug_buf_chars,
5606 __kmp_stg_print_debug_buf_chars, NULL, 0, 0},
5607 {
"KMP_DEBUG_BUF_LINES", __kmp_stg_parse_debug_buf_lines,
5608 __kmp_stg_print_debug_buf_lines, NULL, 0, 0},
5609 {
"KMP_DIAG", __kmp_stg_parse_diag, __kmp_stg_print_diag, NULL, 0, 0},
5611 {
"KMP_PAR_RANGE", __kmp_stg_parse_par_range_env,
5612 __kmp_stg_print_par_range_env, NULL, 0, 0},
5615 {
"KMP_ALIGN_ALLOC", __kmp_stg_parse_align_alloc,
5616 __kmp_stg_print_align_alloc, NULL, 0, 0},
5618 {
"KMP_PLAIN_BARRIER", __kmp_stg_parse_barrier_branch_bit,
5619 __kmp_stg_print_barrier_branch_bit, NULL, 0, 0},
5620 {
"KMP_PLAIN_BARRIER_PATTERN", __kmp_stg_parse_barrier_pattern,
5621 __kmp_stg_print_barrier_pattern, NULL, 0, 0},
5622 {
"KMP_FORKJOIN_BARRIER", __kmp_stg_parse_barrier_branch_bit,
5623 __kmp_stg_print_barrier_branch_bit, NULL, 0, 0},
5624 {
"KMP_FORKJOIN_BARRIER_PATTERN", __kmp_stg_parse_barrier_pattern,
5625 __kmp_stg_print_barrier_pattern, NULL, 0, 0},
5626#if KMP_FAST_REDUCTION_BARRIER
5627 {
"KMP_REDUCTION_BARRIER", __kmp_stg_parse_barrier_branch_bit,
5628 __kmp_stg_print_barrier_branch_bit, NULL, 0, 0},
5629 {
"KMP_REDUCTION_BARRIER_PATTERN", __kmp_stg_parse_barrier_pattern,
5630 __kmp_stg_print_barrier_pattern, NULL, 0, 0},
5633 {
"KMP_ABORT_DELAY", __kmp_stg_parse_abort_delay,
5634 __kmp_stg_print_abort_delay, NULL, 0, 0},
5635 {
"KMP_CPUINFO_FILE", __kmp_stg_parse_cpuinfo_file,
5636 __kmp_stg_print_cpuinfo_file, NULL, 0, 0},
5637 {
"KMP_FORCE_REDUCTION", __kmp_stg_parse_force_reduction,
5638 __kmp_stg_print_force_reduction, NULL, 0, 0},
5639 {
"KMP_DETERMINISTIC_REDUCTION", __kmp_stg_parse_force_reduction,
5640 __kmp_stg_print_force_reduction, NULL, 0, 0},
5641 {
"KMP_STORAGE_MAP", __kmp_stg_parse_storage_map,
5642 __kmp_stg_print_storage_map, NULL, 0, 0},
5643 {
"KMP_ALL_THREADPRIVATE", __kmp_stg_parse_all_threadprivate,
5644 __kmp_stg_print_all_threadprivate, NULL, 0, 0},
5645 {
"KMP_FOREIGN_THREADS_THREADPRIVATE",
5646 __kmp_stg_parse_foreign_threads_threadprivate,
5647 __kmp_stg_print_foreign_threads_threadprivate, NULL, 0, 0},
5649#if KMP_AFFINITY_SUPPORTED
5650 {
"KMP_AFFINITY", __kmp_stg_parse_affinity, __kmp_stg_print_affinity, NULL,
5652 {
"KMP_HIDDEN_HELPER_AFFINITY", __kmp_stg_parse_hh_affinity,
5653 __kmp_stg_print_hh_affinity, NULL, 0, 0},
5654#ifdef KMP_GOMP_COMPAT
5655 {
"GOMP_CPU_AFFINITY", __kmp_stg_parse_gomp_cpu_affinity, NULL,
5658 {
"OMP_PROC_BIND", __kmp_stg_parse_proc_bind, __kmp_stg_print_proc_bind,
5660 {
"KMP_TEAMS_PROC_BIND", __kmp_stg_parse_teams_proc_bind,
5661 __kmp_stg_print_teams_proc_bind, NULL, 0, 0},
5662 {
"OMP_PLACES", __kmp_stg_parse_places, __kmp_stg_print_places, NULL, 0, 0},
5663 {
"KMP_TOPOLOGY_METHOD", __kmp_stg_parse_topology_method,
5664 __kmp_stg_print_topology_method, NULL, 0, 0},
5670 {
"OMP_PROC_BIND", __kmp_stg_parse_proc_bind, __kmp_stg_print_proc_bind,
5674 {
"OMP_DISPLAY_AFFINITY", __kmp_stg_parse_display_affinity,
5675 __kmp_stg_print_display_affinity, NULL, 0, 0},
5676 {
"OMP_AFFINITY_FORMAT", __kmp_stg_parse_affinity_format,
5677 __kmp_stg_print_affinity_format, NULL, 0, 0},
5678 {
"KMP_INIT_AT_FORK", __kmp_stg_parse_init_at_fork,
5679 __kmp_stg_print_init_at_fork, NULL, 0, 0},
5680 {
"KMP_SCHEDULE", __kmp_stg_parse_schedule, __kmp_stg_print_schedule, NULL,
5682 {
"OMP_SCHEDULE", __kmp_stg_parse_omp_schedule, __kmp_stg_print_omp_schedule,
5684#if KMP_USE_HIER_SCHED
5685 {
"KMP_DISP_HAND_THREAD", __kmp_stg_parse_kmp_hand_thread,
5686 __kmp_stg_print_kmp_hand_thread, NULL, 0, 0},
5688 {
"KMP_FORCE_MONOTONIC_DYNAMIC_SCHEDULE",
5689 __kmp_stg_parse_kmp_force_monotonic, __kmp_stg_print_kmp_force_monotonic,
5691 {
"KMP_ATOMIC_MODE", __kmp_stg_parse_atomic_mode,
5692 __kmp_stg_print_atomic_mode, NULL, 0, 0},
5693 {
"KMP_CONSISTENCY_CHECK", __kmp_stg_parse_consistency_check,
5694 __kmp_stg_print_consistency_check, NULL, 0, 0},
5696#if USE_ITT_BUILD && USE_ITT_NOTIFY
5697 {
"KMP_ITT_PREPARE_DELAY", __kmp_stg_parse_itt_prepare_delay,
5698 __kmp_stg_print_itt_prepare_delay, NULL, 0, 0},
5700 {
"KMP_MALLOC_POOL_INCR", __kmp_stg_parse_malloc_pool_incr,
5701 __kmp_stg_print_malloc_pool_incr, NULL, 0, 0},
5702 {
"KMP_GTID_MODE", __kmp_stg_parse_gtid_mode, __kmp_stg_print_gtid_mode,
5704 {
"OMP_DYNAMIC", __kmp_stg_parse_omp_dynamic, __kmp_stg_print_omp_dynamic,
5706 {
"KMP_DYNAMIC_MODE", __kmp_stg_parse_kmp_dynamic_mode,
5707 __kmp_stg_print_kmp_dynamic_mode, NULL, 0, 0},
5709#ifdef USE_LOAD_BALANCE
5710 {
"KMP_LOAD_BALANCE_INTERVAL", __kmp_stg_parse_ld_balance_interval,
5711 __kmp_stg_print_ld_balance_interval, NULL, 0, 0},
5714 {
"KMP_NUM_LOCKS_IN_BLOCK", __kmp_stg_parse_lock_block,
5715 __kmp_stg_print_lock_block, NULL, 0, 0},
5716 {
"KMP_LOCK_KIND", __kmp_stg_parse_lock_kind, __kmp_stg_print_lock_kind,
5718 {
"KMP_SPIN_BACKOFF_PARAMS", __kmp_stg_parse_spin_backoff_params,
5719 __kmp_stg_print_spin_backoff_params, NULL, 0, 0},
5720#if KMP_USE_ADAPTIVE_LOCKS
5721 {
"KMP_ADAPTIVE_LOCK_PROPS", __kmp_stg_parse_adaptive_lock_props,
5722 __kmp_stg_print_adaptive_lock_props, NULL, 0, 0},
5723#if KMP_DEBUG_ADAPTIVE_LOCKS
5724 {
"KMP_SPECULATIVE_STATSFILE", __kmp_stg_parse_speculative_statsfile,
5725 __kmp_stg_print_speculative_statsfile, NULL, 0, 0},
5728 {
"KMP_PLACE_THREADS", __kmp_stg_parse_hw_subset, __kmp_stg_print_hw_subset,
5730 {
"KMP_HW_SUBSET", __kmp_stg_parse_hw_subset, __kmp_stg_print_hw_subset,
5733 {
"KMP_FORKJOIN_FRAMES", __kmp_stg_parse_forkjoin_frames,
5734 __kmp_stg_print_forkjoin_frames, NULL, 0, 0},
5735 {
"KMP_FORKJOIN_FRAMES_MODE", __kmp_stg_parse_forkjoin_frames_mode,
5736 __kmp_stg_print_forkjoin_frames_mode, NULL, 0, 0},
5738 {
"KMP_ENABLE_TASK_THROTTLING", __kmp_stg_parse_task_throttling,
5739 __kmp_stg_print_task_throttling, NULL, 0, 0},
5741 {
"OMP_DISPLAY_ENV", __kmp_stg_parse_omp_display_env,
5742 __kmp_stg_print_omp_display_env, NULL, 0, 0},
5743 {
"OMP_CANCELLATION", __kmp_stg_parse_omp_cancellation,
5744 __kmp_stg_print_omp_cancellation, NULL, 0, 0},
5745 {
"OMP_ALLOCATOR", __kmp_stg_parse_allocator, __kmp_stg_print_allocator,
5747 {
"LIBOMP_USE_HIDDEN_HELPER_TASK", __kmp_stg_parse_use_hidden_helper,
5748 __kmp_stg_print_use_hidden_helper, NULL, 0, 0},
5749 {
"LIBOMP_NUM_HIDDEN_HELPER_THREADS",
5750 __kmp_stg_parse_num_hidden_helper_threads,
5751 __kmp_stg_print_num_hidden_helper_threads, NULL, 0, 0},
5752#if OMP_TASKGRAPH_EXPERIMENTAL
5753 {
"KMP_MAX_TDGS", __kmp_stg_parse_max_tdgs, __kmp_std_print_max_tdgs, NULL,
5755 {
"KMP_TDG_DOT", __kmp_stg_parse_tdg_dot, __kmp_stg_print_tdg_dot, NULL, 0,
5760 {
"OMP_TOOL", __kmp_stg_parse_omp_tool, __kmp_stg_print_omp_tool, NULL, 0,
5762 {
"OMP_TOOL_LIBRARIES", __kmp_stg_parse_omp_tool_libraries,
5763 __kmp_stg_print_omp_tool_libraries, NULL, 0, 0},
5764 {
"OMP_TOOL_VERBOSE_INIT", __kmp_stg_parse_omp_tool_verbose_init,
5765 __kmp_stg_print_omp_tool_verbose_init, NULL, 0, 0},
5768#if KMP_HAVE_MWAIT || KMP_HAVE_UMWAIT
5769 {
"KMP_USER_LEVEL_MWAIT", __kmp_stg_parse_user_level_mwait,
5770 __kmp_stg_print_user_level_mwait, NULL, 0, 0},
5771 {
"KMP_MWAIT_HINTS", __kmp_stg_parse_mwait_hints,
5772 __kmp_stg_print_mwait_hints, NULL, 0, 0},
5776 {
"KMP_TPAUSE", __kmp_stg_parse_tpause, __kmp_stg_print_tpause, NULL, 0, 0},
5778 {
"", NULL, NULL, NULL, 0, 0}};
5780static int const __kmp_stg_count =
5781 sizeof(__kmp_stg_table) /
sizeof(kmp_setting_t);
5783static inline kmp_setting_t *__kmp_stg_find(
char const *name) {
5787 for (i = 0; i < __kmp_stg_count; ++i) {
5788 if (strcmp(__kmp_stg_table[i].name, name) == 0) {
5789 return &__kmp_stg_table[i];
5797static int __kmp_stg_cmp(
void const *_a,
void const *_b) {
5798 const kmp_setting_t *a = RCAST(
const kmp_setting_t *, _a);
5799 const kmp_setting_t *b = RCAST(
const kmp_setting_t *, _b);
5803 if (strcmp(a->name,
"KMP_AFFINITY") == 0) {
5804 if (strcmp(b->name,
"KMP_AFFINITY") == 0) {
5808 }
else if (strcmp(b->name,
"KMP_AFFINITY") == 0) {
5811 return strcmp(a->name, b->name);
5814static void __kmp_stg_init(
void) {
5816 static int initialized = 0;
5821 qsort(__kmp_stg_table, __kmp_stg_count - 1,
sizeof(kmp_setting_t),
5825 kmp_setting_t *kmp_stacksize =
5826 __kmp_stg_find(
"KMP_STACKSIZE");
5827#ifdef KMP_GOMP_COMPAT
5828 kmp_setting_t *gomp_stacksize =
5829 __kmp_stg_find(
"GOMP_STACKSIZE");
5831 kmp_setting_t *omp_stacksize =
5832 __kmp_stg_find(
"OMP_STACKSIZE");
5838 static kmp_setting_t *
volatile rivals[4];
5839 static kmp_stg_ss_data_t kmp_data = {1, CCAST(kmp_setting_t **, rivals)};
5840#ifdef KMP_GOMP_COMPAT
5841 static kmp_stg_ss_data_t gomp_data = {1024,
5842 CCAST(kmp_setting_t **, rivals)};
5844 static kmp_stg_ss_data_t omp_data = {1024,
5845 CCAST(kmp_setting_t **, rivals)};
5848 rivals[i++] = kmp_stacksize;
5849#ifdef KMP_GOMP_COMPAT
5850 if (gomp_stacksize != NULL) {
5851 rivals[i++] = gomp_stacksize;
5854 rivals[i++] = omp_stacksize;
5857 kmp_stacksize->data = &kmp_data;
5858#ifdef KMP_GOMP_COMPAT
5859 if (gomp_stacksize != NULL) {
5860 gomp_stacksize->data = &gomp_data;
5863 omp_stacksize->data = &omp_data;
5867 kmp_setting_t *kmp_library =
5868 __kmp_stg_find(
"KMP_LIBRARY");
5869 kmp_setting_t *omp_wait_policy =
5870 __kmp_stg_find(
"OMP_WAIT_POLICY");
5873 static kmp_setting_t *
volatile rivals[3];
5874 static kmp_stg_wp_data_t kmp_data = {0, CCAST(kmp_setting_t **, rivals)};
5875 static kmp_stg_wp_data_t omp_data = {1, CCAST(kmp_setting_t **, rivals)};
5878 rivals[i++] = kmp_library;
5879 if (omp_wait_policy != NULL) {
5880 rivals[i++] = omp_wait_policy;
5884 kmp_library->data = &kmp_data;
5885 if (omp_wait_policy != NULL) {
5886 omp_wait_policy->data = &omp_data;
5891 kmp_setting_t *kmp_device_thread_limit =
5892 __kmp_stg_find(
"KMP_DEVICE_THREAD_LIMIT");
5893 kmp_setting_t *kmp_all_threads =
5894 __kmp_stg_find(
"KMP_ALL_THREADS");
5897 static kmp_setting_t *
volatile rivals[3];
5900 rivals[i++] = kmp_device_thread_limit;
5901 rivals[i++] = kmp_all_threads;
5904 kmp_device_thread_limit->data = CCAST(kmp_setting_t **, rivals);
5905 kmp_all_threads->data = CCAST(kmp_setting_t **, rivals);
5910 kmp_setting_t *kmp_hw_subset = __kmp_stg_find(
"KMP_HW_SUBSET");
5912 kmp_setting_t *kmp_place_threads = __kmp_stg_find(
"KMP_PLACE_THREADS");
5915 static kmp_setting_t *
volatile rivals[3];
5918 rivals[i++] = kmp_hw_subset;
5919 rivals[i++] = kmp_place_threads;
5922 kmp_hw_subset->data = CCAST(kmp_setting_t **, rivals);
5923 kmp_place_threads->data = CCAST(kmp_setting_t **, rivals);
5926#if KMP_AFFINITY_SUPPORTED
5928 kmp_setting_t *kmp_affinity =
5929 __kmp_stg_find(
"KMP_AFFINITY");
5930 KMP_DEBUG_ASSERT(kmp_affinity != NULL);
5932#ifdef KMP_GOMP_COMPAT
5933 kmp_setting_t *gomp_cpu_affinity =
5934 __kmp_stg_find(
"GOMP_CPU_AFFINITY");
5935 KMP_DEBUG_ASSERT(gomp_cpu_affinity != NULL);
5938 kmp_setting_t *omp_proc_bind =
5939 __kmp_stg_find(
"OMP_PROC_BIND");
5940 KMP_DEBUG_ASSERT(omp_proc_bind != NULL);
5943 static kmp_setting_t *
volatile rivals[4];
5946 rivals[i++] = kmp_affinity;
5948#ifdef KMP_GOMP_COMPAT
5949 rivals[i++] = gomp_cpu_affinity;
5950 gomp_cpu_affinity->data = CCAST(kmp_setting_t **, rivals);
5953 rivals[i++] = omp_proc_bind;
5954 omp_proc_bind->data = CCAST(kmp_setting_t **, rivals);
5957 static kmp_setting_t *
volatile places_rivals[4];
5960 kmp_setting_t *omp_places = __kmp_stg_find(
"OMP_PLACES");
5961 KMP_DEBUG_ASSERT(omp_places != NULL);
5963 places_rivals[i++] = kmp_affinity;
5964#ifdef KMP_GOMP_COMPAT
5965 places_rivals[i++] = gomp_cpu_affinity;
5967 places_rivals[i++] = omp_places;
5968 omp_places->data = CCAST(kmp_setting_t **, places_rivals);
5969 places_rivals[i++] = NULL;
5977 kmp_setting_t *kmp_force_red =
5978 __kmp_stg_find(
"KMP_FORCE_REDUCTION");
5979 kmp_setting_t *kmp_determ_red =
5980 __kmp_stg_find(
"KMP_DETERMINISTIC_REDUCTION");
5983 static kmp_setting_t *
volatile rivals[3];
5984 static kmp_stg_fr_data_t force_data = {1,
5985 CCAST(kmp_setting_t **, rivals)};
5986 static kmp_stg_fr_data_t determ_data = {0,
5987 CCAST(kmp_setting_t **, rivals)};
5990 rivals[i++] = kmp_force_red;
5991 if (kmp_determ_red != NULL) {
5992 rivals[i++] = kmp_determ_red;
5996 kmp_force_red->data = &force_data;
5997 if (kmp_determ_red != NULL) {
5998 kmp_determ_red->data = &determ_data;
6007 for (i = 0; i < __kmp_stg_count; ++i) {
6008 __kmp_stg_table[i].set = 0;
6013static void __kmp_stg_parse(
char const *name,
char const *value) {
6021 if (value != NULL) {
6022 kmp_setting_t *setting = __kmp_stg_find(name);
6023 if (setting != NULL) {
6024 setting->parse(name, value, setting->data);
6025 setting->defined = 1;
6031static int __kmp_stg_check_rivals(
6034 kmp_setting_t **rivals
6037 if (rivals == NULL) {
6043 for (; strcmp(rivals[i]->name, name) != 0; i++) {
6044 KMP_DEBUG_ASSERT(rivals[i] != NULL);
6046#if KMP_AFFINITY_SUPPORTED
6047 if (rivals[i] == __kmp_affinity_notype) {
6054 if (rivals[i]->set) {
6055 KMP_WARNING(StgIgnored, name, rivals[i]->name);
6065static int __kmp_env_toPrint(
char const *name,
int flag) {
6067 kmp_setting_t *setting = __kmp_stg_find(name);
6068 if (setting != NULL) {
6069 rc = setting->defined;
6071 setting->defined = flag;
6077#if defined(KMP_DEBUG) && KMP_AFFINITY_SUPPORTED
6078static void __kmp_print_affinity_settings(
const kmp_affinity_t *affinity) {
6079 K_DIAG(1, (
"%s:\n", affinity->env_var));
6080 K_DIAG(1, (
" type : %d\n", affinity->type));
6081 K_DIAG(1, (
" compact : %d\n", affinity->compact));
6082 K_DIAG(1, (
" offset : %d\n", affinity->offset));
6083 K_DIAG(1, (
" verbose : %u\n", affinity->flags.verbose));
6084 K_DIAG(1, (
" warnings : %u\n", affinity->flags.warnings));
6085 K_DIAG(1, (
" respect : %u\n", affinity->flags.respect));
6086 K_DIAG(1, (
" reset : %u\n", affinity->flags.reset));
6087 K_DIAG(1, (
" dups : %u\n", affinity->flags.dups));
6088 K_DIAG(1, (
" gran : %d\n", (
int)affinity->gran));
6089 KMP_DEBUG_ASSERT(affinity->type != affinity_default);
6096static char const *__kmp_aux_env_blk_all_fallback(kmp_env_blk_t *block,
6097 char const *base_name) {
6098 for (
int e = 0;; ++e) {
6099 char const *base = __kmp_device_env_eligible_name(e);
6102 if (strcmp(base, base_name) != 0)
6104 char *all_name = __kmp_str_format(
"%s_ALL", base_name);
6105 char const *value = __kmp_env_blk_var(block, all_name);
6106 __kmp_str_free(&all_name);
6111static void __kmp_aux_env_initialize(kmp_env_blk_t *block) {
6116 value = __kmp_env_blk_var(block,
"OMP_NUM_THREADS");
6118 value = __kmp_aux_env_blk_all_fallback(block,
"OMP_NUM_THREADS");
6120 ompc_set_num_threads(__kmp_dflt_team_nth);
6124 value = __kmp_env_blk_var(block,
"KMP_BLOCKTIME");
6129 gtid = __kmp_entry_gtid();
6130 tid = __kmp_tid_from_gtid(gtid);
6131 thread = __kmp_thread_from_gtid(gtid);
6132 __kmp_aux_set_blocktime(__kmp_dflt_blocktime, thread, tid);
6136 value = __kmp_env_blk_var(block,
"OMP_NESTED");
6138 ompc_set_nested(__kmp_dflt_max_active_levels > 1);
6142 value = __kmp_env_blk_var(block,
"OMP_DYNAMIC");
6144 ompc_set_dynamic(__kmp_global.g.g_dynamic);
6148void __kmp_env_initialize(
char const *
string) {
6150 kmp_env_blk_t block;
6156 if (
string == NULL) {
6158 __kmp_threads_capacity =
6159 __kmp_initial_threads_capacity(__kmp_dflt_team_nth_ub);
6161 __kmp_env_blk_init(&block,
string);
6165 blocktime_str = __kmp_env_blk_var(&block,
"KMP_BLOCKTIME");
6166 use_yield_str = __kmp_env_blk_var(&block,
"KMP_USE_YIELD");
6170 if (
string == NULL) {
6171 char const *name =
"KMP_WARNINGS";
6172 char const *value = __kmp_env_blk_var(&block, name);
6173 __kmp_stg_parse(name, value);
6176#if KMP_AFFINITY_SUPPORTED
6182 __kmp_affinity_notype = NULL;
6183 char const *aff_str = __kmp_env_blk_var(&block,
"KMP_AFFINITY");
6184 if (aff_str != NULL) {
6195#if KMP_OS_WINDOWS || KMP_OS_AIX
6198#define FIND strcasestr
6201 if ((FIND(aff_str,
"none") == NULL) &&
6202 (FIND(aff_str,
"physical") == NULL) &&
6203 (FIND(aff_str,
"logical") == NULL) &&
6204 (FIND(aff_str,
"compact") == NULL) &&
6205 (FIND(aff_str,
"scatter") == NULL) &&
6206 (FIND(aff_str,
"explicit") == NULL) &&
6207 (FIND(aff_str,
"balanced") == NULL) &&
6208 (FIND(aff_str,
"disabled") == NULL)) {
6209 __kmp_affinity_notype = __kmp_stg_find(
"KMP_AFFINITY");
6214 __kmp_affinity.type = affinity_default;
6215 __kmp_affinity.gran = KMP_HW_UNKNOWN;
6216 __kmp_affinity_top_method = affinity_top_method_default;
6217 __kmp_affinity.flags.respect = affinity_respect_mask_default;
6222 aff_str = __kmp_env_blk_var(&block,
"OMP_PROC_BIND");
6223 if (aff_str != NULL) {
6224 __kmp_affinity.type = affinity_default;
6225 __kmp_affinity.gran = KMP_HW_UNKNOWN;
6226 __kmp_affinity_top_method = affinity_top_method_default;
6227 __kmp_affinity.flags.respect = affinity_respect_mask_default;
6236 for (i = 0; i < block.count; ++i) {
6237 if ((block.vars[i].name == NULL) || (*block.vars[i].name ==
'\0')) {
6240 if (block.vars[i].value == NULL) {
6243 if (__kmp_device_env_record(block.vars[i].name, block.vars[i].value))
6246 kmp_setting_t *setting = __kmp_stg_find(block.vars[i].name);
6247 if (setting != NULL) {
6253 if (__kmp_nested_proc_bind.bind_types == NULL) {
6254 __kmp_nested_proc_bind.bind_types =
6255 (kmp_proc_bind_t *)KMP_INTERNAL_MALLOC(
sizeof(kmp_proc_bind_t));
6256 if (__kmp_nested_proc_bind.bind_types == NULL) {
6257 KMP_FATAL(MemoryAllocFailed);
6259 __kmp_nested_proc_bind.size = 1;
6260 __kmp_nested_proc_bind.used = 1;
6261#if KMP_AFFINITY_SUPPORTED
6262 __kmp_nested_proc_bind.bind_types[0] = proc_bind_default;
6265 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
6272 __kmp_msg_format(kmp_i18n_msg_AffFormatDefault,
"%P",
"%i",
"%n",
"%A");
6273 KMP_DEBUG_ASSERT(KMP_STRLEN(m.str) < KMP_AFFINITY_FORMAT_SIZE);
6275 if (__kmp_affinity_format == NULL) {
6276 __kmp_affinity_format =
6277 (
char *)KMP_INTERNAL_MALLOC(
sizeof(
char) * KMP_AFFINITY_FORMAT_SIZE);
6279 KMP_STRCPY_S(__kmp_affinity_format, KMP_AFFINITY_FORMAT_SIZE, m.str);
6280 __kmp_str_free(&m.str);
6283 for (i = 0; i < block.count; ++i) {
6284 __kmp_stg_parse(block.vars[i].name, block.vars[i].value);
6291 for (
int e = 0;; ++e) {
6292 char const *base = __kmp_device_env_eligible_name(e);
6295 if (__kmp_env_blk_var(&block, base) != NULL)
6297 char *all_name = __kmp_str_format(
"%s_ALL", base);
6298 char const *all_v = __kmp_env_blk_var(&block, all_name);
6299 __kmp_str_free(&all_name);
6301 __kmp_stg_parse(base, all_v);
6305 if (!__kmp_init_user_locks) {
6306 if (__kmp_user_lock_kind == lk_default) {
6307 __kmp_user_lock_kind = lk_queuing;
6309#if KMP_USE_DYNAMIC_LOCK
6310 __kmp_init_dynamic_user_locks();
6312 __kmp_set_user_lock_vptrs(__kmp_user_lock_kind);
6315 KMP_DEBUG_ASSERT(
string != NULL);
6316 KMP_DEBUG_ASSERT(__kmp_user_lock_kind != lk_default);
6321#if KMP_USE_DYNAMIC_LOCK
6322 __kmp_init_dynamic_user_locks();
6324 __kmp_set_user_lock_vptrs(__kmp_user_lock_kind);
6328#if KMP_AFFINITY_SUPPORTED
6330 if (!TCR_4(__kmp_init_middle)) {
6331#if KMP_HWLOC_ENABLED
6335 if (__kmp_hw_subset &&
6336 __kmp_affinity_top_method == affinity_top_method_default)
6337 if (__kmp_hw_subset->specified(KMP_HW_NUMA) ||
6338 __kmp_hw_subset->specified(KMP_HW_TILE) ||
6339 __kmp_affinity.gran == KMP_HW_TILE ||
6340 __kmp_affinity.gran == KMP_HW_NUMA)
6341 __kmp_affinity_top_method = affinity_top_method_hwloc;
6343 if (__kmp_affinity.gran == KMP_HW_NUMA ||
6344 __kmp_affinity.gran == KMP_HW_TILE)
6345 __kmp_affinity_top_method = affinity_top_method_hwloc;
6349 const char *var =
"KMP_AFFINITY";
6350 KMPAffinity::pick_api();
6351#if KMP_HWLOC_ENABLED
6355 if (__kmp_affinity_top_method == affinity_top_method_hwloc &&
6356 __kmp_affinity_dispatch->get_api_type() != KMPAffinity::HWLOC) {
6357 KMP_WARNING(AffIgnoringHwloc, var);
6358 __kmp_affinity_top_method = affinity_top_method_all;
6361 if (__kmp_affinity.type == affinity_disabled) {
6362 KMP_AFFINITY_DISABLE();
6363 }
else if (!KMP_AFFINITY_CAPABLE()) {
6364 __kmp_affinity_dispatch->determine_capable(var);
6365 if (!KMP_AFFINITY_CAPABLE()) {
6366 if (__kmp_affinity.flags.verbose ||
6367 (__kmp_affinity.flags.warnings &&
6368 (__kmp_affinity.type != affinity_default) &&
6369 (__kmp_affinity.type != affinity_none) &&
6370 (__kmp_affinity.type != affinity_disabled))) {
6371 KMP_WARNING(AffNotSupported, var);
6373 __kmp_affinity.type = affinity_disabled;
6374 __kmp_affinity.flags.respect = FALSE;
6375 __kmp_affinity.gran = KMP_HW_THREAD;
6379 if (__kmp_affinity.type == affinity_disabled) {
6380 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
6381 }
else if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_true) {
6383 __kmp_nested_proc_bind.bind_types[0] = proc_bind_spread;
6386 if (KMP_AFFINITY_CAPABLE()) {
6388#if KMP_GROUP_AFFINITY
6393 bool exactly_one_group =
false;
6394 if (__kmp_num_proc_groups > 1) {
6396 bool within_one_group;
6399 kmp_affin_mask_t *init_mask;
6400 KMP_CPU_ALLOC(init_mask);
6401 __kmp_get_system_affinity(init_mask, TRUE);
6402 group = __kmp_get_proc_group(init_mask);
6403 within_one_group = (group >= 0);
6406 if (within_one_group) {
6407 DWORD num_bits_in_group = __kmp_GetActiveProcessorCount(group);
6408 DWORD num_bits_in_mask = 0;
6409 for (
int bit = init_mask->begin(); bit != init_mask->end();
6410 bit = init_mask->next(bit))
6412 exactly_one_group = (num_bits_in_group == num_bits_in_mask);
6414 KMP_CPU_FREE(init_mask);
6420 if (__kmp_num_proc_groups > 1 &&
6421 __kmp_affinity.type == affinity_default &&
6422 __kmp_nested_proc_bind.bind_types[0] == proc_bind_default) {
6427 if (__kmp_affinity.flags.respect == affinity_respect_mask_default &&
6428 exactly_one_group) {
6429 __kmp_affinity.flags.respect = FALSE;
6433 if (__kmp_affinity.type == affinity_default) {
6434 __kmp_affinity.type = affinity_compact;
6435 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
6437 if (__kmp_hh_affinity.type == affinity_default)
6438 __kmp_hh_affinity.type = affinity_compact;
6439 if (__kmp_affinity_top_method == affinity_top_method_default)
6440 __kmp_affinity_top_method = affinity_top_method_all;
6441 if (__kmp_affinity.gran == KMP_HW_UNKNOWN)
6442 __kmp_affinity.gran = KMP_HW_PROC_GROUP;
6443 if (__kmp_hh_affinity.gran == KMP_HW_UNKNOWN)
6444 __kmp_hh_affinity.gran = KMP_HW_PROC_GROUP;
6450 if (__kmp_affinity.flags.respect == affinity_respect_mask_default) {
6451#if KMP_GROUP_AFFINITY
6452 if (__kmp_num_proc_groups > 1 && exactly_one_group) {
6453 __kmp_affinity.flags.respect = FALSE;
6457 __kmp_affinity.flags.respect = TRUE;
6460 if ((__kmp_nested_proc_bind.bind_types[0] != proc_bind_intel) &&
6461 (__kmp_nested_proc_bind.bind_types[0] != proc_bind_default)) {
6462 if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_false)
6463 __kmp_affinity.type = affinity_none;
6464 if (__kmp_affinity.type == affinity_default) {
6465 __kmp_affinity.type = affinity_compact;
6466 __kmp_affinity.flags.dups = FALSE;
6468 }
else if (__kmp_affinity.type == affinity_default) {
6469#if KMP_MIC_SUPPORTED
6470 if (__kmp_mic_type != non_mic) {
6471 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
6475 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
6477#if KMP_MIC_SUPPORTED
6478 if (__kmp_mic_type != non_mic) {
6479 __kmp_affinity.type = affinity_scatter;
6483 __kmp_affinity.type = affinity_none;
6486 if (__kmp_hh_affinity.type == affinity_default)
6487 __kmp_hh_affinity.type = affinity_none;
6488 if ((__kmp_affinity.gran == KMP_HW_UNKNOWN) &&
6489 (__kmp_affinity.gran_levels < 0)) {
6490#if KMP_MIC_SUPPORTED
6491 if (__kmp_mic_type != non_mic) {
6492 __kmp_affinity.gran = KMP_HW_THREAD;
6496 __kmp_affinity.gran = KMP_HW_CORE;
6499 if ((__kmp_hh_affinity.gran == KMP_HW_UNKNOWN) &&
6500 (__kmp_hh_affinity.gran_levels < 0)) {
6501#if KMP_MIC_SUPPORTED
6502 if (__kmp_mic_type != non_mic) {
6503 __kmp_hh_affinity.gran = KMP_HW_THREAD;
6507 __kmp_hh_affinity.gran = KMP_HW_CORE;
6510 if (__kmp_affinity_top_method == affinity_top_method_default) {
6511 __kmp_affinity_top_method = affinity_top_method_all;
6517 if (__kmp_affinity_top_method == affinity_top_method_default)
6518 __kmp_affinity_top_method = affinity_top_method_all;
6519 if (__kmp_affinity.type == affinity_default)
6520 __kmp_affinity.type = affinity_disabled;
6521 if (__kmp_hh_affinity.type == affinity_default)
6522 __kmp_hh_affinity.type = affinity_disabled;
6526 for (
const kmp_affinity_t *affinity : __kmp_affinities)
6527 __kmp_print_affinity_settings(affinity);
6528 KMP_DEBUG_ASSERT(__kmp_nested_proc_bind.bind_types[0] != proc_bind_default);
6529 K_DIAG(1, (
"__kmp_nested_proc_bind.bind_types[0] == %d\n",
6530 __kmp_nested_proc_bind.bind_types[0]));
6538 if (
string != NULL) {
6539 __kmp_aux_env_initialize(&block);
6542 __kmp_env_blk_free(&block);
6548void __kmp_env_print() {
6550 kmp_env_blk_t block;
6552 kmp_str_buf_t buffer;
6555 __kmp_str_buf_init(&buffer);
6557 __kmp_env_blk_init(&block, NULL);
6558 __kmp_env_blk_sort(&block);
6561 __kmp_str_buf_print(&buffer,
"\n%s\n\n", KMP_I18N_STR(UserSettings));
6562 for (i = 0; i < block.count; ++i) {
6563 char const *name = block.vars[i].name;
6564 char const *value = block.vars[i].value;
6565 if ((KMP_STRLEN(name) > 4 && strncmp(name,
"KMP_", 4) == 0) ||
6566 strncmp(name,
"OMP_", 4) == 0
6567#ifdef KMP_GOMP_COMPAT
6568 || strncmp(name,
"GOMP_", 5) == 0
6571 __kmp_str_buf_print(&buffer,
" %s=%s\n", name, value);
6574 __kmp_str_buf_print(&buffer,
"\n");
6577 __kmp_str_buf_print(&buffer,
"%s\n\n", KMP_I18N_STR(EffectiveSettings));
6578 for (
int i = 0; i < __kmp_stg_count; ++i) {
6579 if (__kmp_stg_table[i].print != NULL) {
6580 __kmp_stg_table[i].print(&buffer, __kmp_stg_table[i].name,
6581 __kmp_stg_table[i].data);
6585 __kmp_printf(
"%s", buffer.str);
6587 __kmp_env_blk_free(&block);
6588 __kmp_str_buf_free(&buffer);
6594void __kmp_env_print_2() {
6595 __kmp_display_env_impl(__kmp_display_env, __kmp_display_env_verbose);
6598void __kmp_display_env_impl(
int display_env,
int display_env_verbose) {
6599 kmp_env_blk_t block;
6600 kmp_str_buf_t buffer;
6602 __kmp_env_format = 1;
6605 __kmp_str_buf_init(&buffer);
6607 __kmp_env_blk_init(&block, NULL);
6608 __kmp_env_blk_sort(&block);
6610 __kmp_str_buf_print(&buffer,
"\n%s\n", KMP_I18N_STR(DisplayEnvBegin));
6611 __kmp_str_buf_print(&buffer,
" _OPENMP='%d'\n", __kmp_openmp_version);
6613 for (
int i = 0; i < __kmp_stg_count; ++i) {
6614 if (__kmp_stg_table[i].print != NULL &&
6615 ((display_env && strncmp(__kmp_stg_table[i].name,
"OMP_", 4) == 0) ||
6616 display_env_verbose)) {
6617 __kmp_stg_table[i].print(&buffer, __kmp_stg_table[i].name,
6618 __kmp_stg_table[i].data);
6622 __kmp_str_buf_print(&buffer,
"%s\n", KMP_I18N_STR(DisplayEnvEnd));
6623 __kmp_str_buf_print(&buffer,
"\n");
6625 __kmp_printf(
"%s", buffer.str);
6627 __kmp_env_blk_free(&block);
6628 __kmp_str_buf_free(&buffer);
6635void __kmp_env_dump() {
6637 kmp_env_blk_t block;
6638 kmp_str_buf_t buffer, env, notdefined;
6641 __kmp_str_buf_init(&buffer);
6642 __kmp_str_buf_init(&env);
6643 __kmp_str_buf_init(¬defined);
6645 __kmp_env_blk_init(&block, NULL);
6646 __kmp_env_blk_sort(&block);
6648 __kmp_str_buf_print(¬defined,
": %s", KMP_I18N_STR(NotDefined));
6650 for (
int i = 0; i < __kmp_stg_count; ++i) {
6651 if (__kmp_stg_table[i].print == NULL)
6653 __kmp_str_buf_clear(&env);
6654 __kmp_stg_table[i].print(&env, __kmp_stg_table[i].name,
6655 __kmp_stg_table[i].data);
6658 if (strstr(env.str, notdefined.str))
6660 __kmp_str_buf_print(&buffer,
"%s=undefined\n", __kmp_stg_table[i].name);
6662 __kmp_str_buf_cat(&buffer, env.str + 3, env.used - 3);
6665 ompd_env_block = (
char *)__kmp_allocate(buffer.used + 1);
6666 KMP_MEMCPY(ompd_env_block, buffer.str, buffer.used + 1);
6667 ompd_env_block_size = (ompd_size_t)KMP_STRLEN(ompd_env_block);
6669 __kmp_env_blk_free(&block);
6670 __kmp_str_buf_free(&buffer);
6671 __kmp_str_buf_free(&env);
6672 __kmp_str_buf_free(¬defined);
@ kmp_sch_modifier_monotonic
@ kmp_sch_modifier_nonmonotonic