38 #include "kmp_wrapper_getpid.h"
39 #include "kmp_environment.h"
40 #include "kmp_atomic.h"
43 #include "kmp_settings.h"
48 #define KMP_MAX( x, y ) ( (x) > (y) ? (x) : (y) )
49 #define KMP_MIN( x, y ) ( (x) < (y) ? (x) : (y) )
51 static int __kmp_env_isDefined(
char const * name );
52 static int __kmp_env_toPrint(
char const * name,
int flag );
59 __kmp_convert_to_double(
char const * s )
63 if ( sscanf( s,
"%lf", &result ) < 1 ) {
71 __kmp_readstr_with_sentinel(
char *dest,
char const * src,
size_t len,
char sentinel) {
73 for (i = 0; i < len; i++) {
74 if ((*src ==
'\0') || (*src == sentinel)) {
84 __kmp_match_with_sentinel(
char const * a,
char const * b,
size_t len,
char sentinel ) {
91 while(*a && *b && *b != sentinel) {
92 char ca = *a, cb = *b;
94 if(ca >=
'a' && ca <=
'z')
96 if(cb >=
'a' && cb <=
'z')
134 __kmp_match_str(
char const *token,
char const *buf,
const char **end) {
136 KMP_ASSERT(token != NULL);
137 KMP_ASSERT(buf != NULL);
138 KMP_ASSERT(end != NULL);
140 while (*token && *buf) {
141 char ct = *token, cb = *buf;
143 if(ct >=
'a' && ct <=
'z')
145 if(cb >=
'a' && cb <=
'z')
160 __kmp_strip_quotes(
char *target,
int len) {
161 char *end = target + len - 1;
163 while(*target ==
'"' || *target ==
'\'') {
164 if(end <= target || (*end !=
'"' && *end !=
'\''))
176 __kmp_round4k(
size_t size ) {
177 size_t _4k = 4 * 1024;
178 if ( size & ( _4k - 1 ) ) {
179 size &= ~ ( _4k - 1 );
180 if ( size <= KMP_SIZE_T_MAX - _4k ) {
189 __kmp_convert_to_seconds(
char const * data )
191 int nvalues, value, factor;
194 if (data == NULL)
return (0);
197 nvalues = sscanf (data,
"%d%c%c", &value, &mult, &extra);
198 if (nvalues < 1)
return (0);
199 if (nvalues == 1) mult =
'\0';
200 if (nvalues == 3)
return (-1);
216 factor = 24 * 60 * 60;
222 if (value > (INT_MAX / factor))
237 __kmp_convert_to_milliseconds(
char const * data )
239 int ret, nvalues, factor;
243 if (data == NULL)
return (-1);
244 if ( __kmp_str_match(
"infinit", -1, data))
return (INT_MAX);
245 value = (double) 0.0;
247 nvalues = sscanf (data,
"%lf%c%c", &value, &mult, &extra);
248 if (nvalues < 1)
return (-1);
249 if (nvalues == 1) mult =
'\0';
250 if (nvalues == 3)
return (-1);
252 if (value < 0)
return (-1);
266 factor = 1000 * 60 * 60;
269 factor = 1000 * 24 * 60 * 60;
275 if ( value >= ( (INT_MAX-1) / factor) )
278 ret = (int) (value * (
double) factor);
284 __kmp_convert_to_nanoseconds(
295 if ( str == NULL || str[ 0 ] == 0 ) {
298 rc = sscanf( str,
"%lf%c%c", &value, &unit, &extra );
330 result = (kmp_uint64)( value * factor );
337 __kmp_strcasecmp_with_sentinel(
char const * a,
char const * b,
char sentinel ) {
342 while(*a && *b && *b != sentinel) {
343 char ca = *a, cb = *b;
345 if(ca >=
'a' && ca <=
'z')
347 if(cb >=
'a' && cb <=
'z')
350 return (
int)(
unsigned char)*a - (
int)(
unsigned char)*b;
355 (*b && *b != sentinel) ? (
int)(
unsigned char)*a - (
int)(
unsigned char)*b : 1 :
356 (*b && *b != sentinel) ? -1 : 0;
364 typedef struct __kmp_setting kmp_setting_t;
365 typedef struct __kmp_stg_ss_data kmp_stg_ss_data_t;
366 typedef struct __kmp_stg_wp_data kmp_stg_wp_data_t;
367 typedef struct __kmp_stg_fr_data kmp_stg_fr_data_t;
369 typedef void ( * kmp_stg_parse_func_t )(
char const * name,
char const * value,
void * data );
370 typedef void ( * kmp_stg_print_func_t )( kmp_str_buf_t * buffer,
char const * name,
void * data );
372 struct __kmp_setting {
374 kmp_stg_parse_func_t parse;
375 kmp_stg_print_func_t print;
382 struct __kmp_stg_ss_data {
384 kmp_setting_t * * rivals;
387 struct __kmp_stg_wp_data {
389 kmp_setting_t * * rivals;
392 struct __kmp_stg_fr_data {
394 kmp_setting_t * * rivals;
398 __kmp_stg_check_rivals(
401 kmp_setting_t * * rivals
410 __kmp_stg_parse_bool(
415 if ( __kmp_str_match_true( value ) ) {
417 }
else if (__kmp_str_match_false( value ) ) {
422 KMP_MSG( BadBoolValue, name, value ),
423 KMP_HNT( ValidBoolValues ),
430 __kmp_stg_parse_size(
439 char const * msg = NULL;
441 size_min = __kmp_round4k( size_min );
442 size_max = __kmp_round4k( size_max );
443 #endif // KMP_OS_DARWIN
445 if ( is_specified != NULL ) {
448 __kmp_str_to_size( value, out, factor, & msg );
450 if ( * out > size_max ) {
452 msg = KMP_I18N_STR( ValueTooLarge );
453 }
else if ( * out < size_min ) {
455 msg = KMP_I18N_STR( ValueTooSmall );
458 size_t round4k = __kmp_round4k( * out );
459 if ( * out != round4k ) {
461 msg = KMP_I18N_STR( NotMultiple4K );
467 if ( * out < size_min ) {
470 else if ( * out > size_max ) {
477 __kmp_str_buf_init( & buf );
478 __kmp_str_buf_print_size( & buf, * out );
479 KMP_WARNING( ParseSizeIntWarn, name, value, msg );
480 KMP_INFORM( Using_str_Value, name, buf.str );
481 __kmp_str_buf_free( & buf );
492 KMP_INTERNAL_FREE( (
void *) * out );
493 * out = __kmp_str_format(
"%s", value );
505 char const * msg = NULL;
506 kmp_uint64 uint = * out;
507 __kmp_str_to_uint( value, & uint, & msg );
510 msg = KMP_I18N_STR( ValueTooSmall );
512 }
else if ( uint > max ) {
513 msg = KMP_I18N_STR( ValueTooLarge );
522 else if ( uint > max ) {
529 KMP_WARNING( ParseSizeIntWarn, name, value, msg );
530 __kmp_str_buf_init( & buf );
531 __kmp_str_buf_print( &buf,
"%" KMP_UINT64_SPEC
"", uint );
532 KMP_INFORM( Using_uint64_Value, name, buf.str );
533 __kmp_str_buf_free( &buf );
540 __kmp_stg_parse_file(
549 KMP_INTERNAL_FREE( (
void *) * out );
550 t = (
char *) strrchr(value,
'.');
551 hasSuffix = t && __kmp_str_eqf( t, suffix );
552 t = __kmp_str_format(
"%s%s", value, hasSuffix ?
"" : suffix );
553 __kmp_expand_file_name( buffer,
sizeof(buffer), t);
554 KMP_INTERNAL_FREE(t);
555 * out = __kmp_str_format(
"%s", buffer );
558 static char * par_range_to_print = NULL;
561 __kmp_stg_parse_par_range(
570 size_t len = strlen( value + 1 );
571 par_range_to_print = (
char *) KMP_INTERNAL_MALLOC( len +1 );
572 strncpy( par_range_to_print, value, len + 1);
573 __kmp_par_range = +1;
574 __kmp_par_range_lb = 0;
575 __kmp_par_range_ub = INT_MAX;
578 if (( value == NULL ) || ( *value ==
'\0' )) {
581 if ( ! __kmp_strcasecmp_with_sentinel(
"routine", value,
'=' )) {
582 value = strchr( value,
'=' ) + 1;
583 len = __kmp_readstr_with_sentinel( out_routine,
584 value, KMP_PAR_RANGE_ROUTINE_LEN - 1,
',' );
586 goto par_range_error;
588 value = strchr( value,
',' );
589 if ( value != NULL ) {
594 if ( ! __kmp_strcasecmp_with_sentinel(
"filename", value,
'=' )) {
595 value = strchr( value,
'=' ) + 1;
596 len = __kmp_readstr_with_sentinel( out_file,
597 value, KMP_PAR_RANGE_FILENAME_LEN - 1,
',' );
599 goto par_range_error;
601 value = strchr( value,
',' );
602 if ( value != NULL ) {
607 if (( ! __kmp_strcasecmp_with_sentinel(
"range", value,
'=' ))
608 || ( ! __kmp_strcasecmp_with_sentinel(
"incl_range", value,
'=' ))) {
609 value = strchr( value,
'=' ) + 1;
610 if ( sscanf( value,
"%d:%d", out_lb, out_ub ) != 2 ) {
611 goto par_range_error;
614 value = strchr( value,
',' );
615 if ( value != NULL ) {
620 if ( ! __kmp_strcasecmp_with_sentinel(
"excl_range", value,
'=' )) {
621 value = strchr( value,
'=' ) + 1;
622 if ( sscanf( value,
"%d:%d", out_lb, out_ub) != 2 ) {
623 goto par_range_error;
626 value = strchr( value,
',' );
627 if ( value != NULL ) {
633 KMP_WARNING( ParRangeSyntax, name );
641 __kmp_initial_threads_capacity(
int req_nproc )
646 if (nth < (4 * req_nproc))
647 nth = (4 * req_nproc);
648 if (nth < (4 * __kmp_xproc))
649 nth = (4 * __kmp_xproc);
651 if (nth > __kmp_max_nth)
659 __kmp_default_tp_capacity(
int req_nproc,
int max_nth,
int all_threads_specified) {
662 if(all_threads_specified)
665 if (nth < (4 * req_nproc))
666 nth = (4 * req_nproc);
667 if (nth < (4 * __kmp_xproc))
668 nth = (4 * __kmp_xproc);
670 if (nth > __kmp_max_nth)
682 __kmp_stg_print_bool( kmp_str_buf_t * buffer,
char const * name,
int value ) {
683 __kmp_str_buf_print( buffer,
" %s=%s\n", name, value ?
"true" :
"false" );
687 __kmp_stg_print_int( kmp_str_buf_t * buffer,
char const * name,
int value ) {
688 __kmp_str_buf_print( buffer,
" %s=%d\n", name, value );
692 __kmp_stg_print_uint64( kmp_str_buf_t * buffer,
char const * name, kmp_uint64 value ) {
693 __kmp_str_buf_print( buffer,
" %s=%" KMP_UINT64_SPEC
"\n", name, value );
697 __kmp_stg_print_str( kmp_str_buf_t * buffer,
char const * name,
char const * value ) {
698 __kmp_str_buf_print( buffer,
" %s=%s\n", name, value );
702 __kmp_stg_print_size( kmp_str_buf_t * buffer,
char const * name,
size_t value ) {
703 __kmp_str_buf_print( buffer,
" %s=", name );
704 __kmp_str_buf_print_size( buffer, value );
705 __kmp_str_buf_print( buffer,
"\n" );
718 __kmp_stg_parse_all_threads(
char const * name,
char const * value,
void * data ) {
720 kmp_setting_t * * rivals = (kmp_setting_t * *) data;
722 rc = __kmp_stg_check_rivals( name, value, rivals );
726 if ( ! __kmp_strcasecmp_with_sentinel(
"all", value, 0 ) ) {
727 __kmp_max_nth = __kmp_xproc;
728 __kmp_allThreadsSpecified = 1;
730 __kmp_stg_parse_int( name, value, 1, __kmp_sys_max_nth, & __kmp_max_nth );
731 __kmp_allThreadsSpecified = 0;
733 K_DIAG( 1, (
"__kmp_max_nth == %d\n", __kmp_max_nth ) );
738 __kmp_stg_print_all_threads( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
739 __kmp_stg_print_int( buffer, name, __kmp_max_nth );
747 __kmp_stg_parse_blocktime(
char const * name,
char const * value,
void * data ) {
748 __kmp_dflt_blocktime = __kmp_convert_to_milliseconds( value );
749 if ( __kmp_dflt_blocktime < 0 ) {
750 __kmp_dflt_blocktime = KMP_DEFAULT_BLOCKTIME;
751 __kmp_msg( kmp_ms_warning, KMP_MSG( InvalidValue, name, value ), __kmp_msg_null );
752 KMP_INFORM( Using_int_Value, name, __kmp_dflt_blocktime );
753 __kmp_env_blocktime = FALSE;
755 if ( __kmp_dflt_blocktime < KMP_MIN_BLOCKTIME ) {
756 __kmp_dflt_blocktime = KMP_MIN_BLOCKTIME;
757 __kmp_msg( kmp_ms_warning, KMP_MSG( SmallValue, name, value ), __kmp_msg_null );
758 KMP_INFORM( MinValueUsing, name, __kmp_dflt_blocktime );
759 }
else if ( __kmp_dflt_blocktime > KMP_MAX_BLOCKTIME ) {
760 __kmp_dflt_blocktime = KMP_MAX_BLOCKTIME;
761 __kmp_msg( kmp_ms_warning, KMP_MSG( LargeValue, name, value ), __kmp_msg_null );
762 KMP_INFORM( MaxValueUsing, name, __kmp_dflt_blocktime );
764 __kmp_env_blocktime = TRUE;
767 __kmp_monitor_wakeups = KMP_WAKEUPS_FROM_BLOCKTIME( __kmp_dflt_blocktime, __kmp_monitor_wakeups );
768 __kmp_bt_intervals = KMP_INTERVALS_FROM_BLOCKTIME( __kmp_dflt_blocktime, __kmp_monitor_wakeups );
769 K_DIAG( 1, (
"__kmp_env_blocktime == %d\n", __kmp_env_blocktime ) );
770 if ( __kmp_env_blocktime ) {
771 K_DIAG( 1, (
"__kmp_dflt_blocktime == %d\n", __kmp_dflt_blocktime ) );
776 __kmp_stg_print_blocktime( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
777 __kmp_stg_print_int( buffer, name, __kmp_dflt_blocktime );
785 __kmp_stg_parse_duplicate_lib_ok(
char const * name,
char const * value,
void * data ) {
788 __kmp_stg_parse_bool( name, value, & __kmp_duplicate_library_ok );
792 __kmp_stg_print_duplicate_lib_ok( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
793 __kmp_stg_print_bool( buffer, name, __kmp_duplicate_library_ok );
800 #if KMP_ARCH_X86 || KMP_ARCH_X86_64
803 __kmp_stg_parse_inherit_fp_control(
char const * name,
char const * value,
void * data ) {
804 __kmp_stg_parse_bool( name, value, & __kmp_inherit_fp_control );
808 __kmp_stg_print_inherit_fp_control( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
810 __kmp_stg_print_bool( buffer, name, __kmp_inherit_fp_control );
821 __kmp_stg_parse_wait_policy(
char const * name,
char const * value,
void * data ) {
823 kmp_stg_wp_data_t * wait = (kmp_stg_wp_data_t *) data;
826 rc = __kmp_stg_check_rivals( name, value, wait->rivals );
832 if ( __kmp_str_match(
"ACTIVE", 1, value ) ) {
833 __kmp_library = library_turnaround;
834 }
else if ( __kmp_str_match(
"PASSIVE", 1, value ) ) {
835 __kmp_library = library_throughput;
837 KMP_WARNING( StgInvalidValue, name, value );
840 if ( __kmp_str_match(
"serial", 1, value ) ) {
841 __kmp_library = library_serial;
842 }
else if ( __kmp_str_match(
"throughput", 2, value ) ) {
843 __kmp_library = library_throughput;
844 }
else if ( __kmp_str_match(
"turnaround", 2, value ) ) {
845 __kmp_library = library_turnaround;
846 }
else if ( __kmp_str_match(
"dedicated", 1, value ) ) {
847 __kmp_library = library_turnaround;
848 }
else if ( __kmp_str_match(
"multiuser", 1, value ) ) {
849 __kmp_library = library_throughput;
851 KMP_WARNING( StgInvalidValue, name, value );
854 __kmp_aux_set_library( __kmp_library );
859 __kmp_stg_print_wait_policy( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
861 kmp_stg_wp_data_t * wait = (kmp_stg_wp_data_t *) data;
862 char const * value = NULL;
865 switch ( __kmp_library ) {
866 case library_turnaround : {
869 case library_throughput : {
874 switch ( __kmp_library ) {
875 case library_serial : {
878 case library_turnaround : {
879 value =
"turnaround";
881 case library_throughput : {
882 value =
"throughput";
886 if ( value != NULL ) {
887 __kmp_stg_print_str( buffer, name, value );
897 __kmp_stg_parse_monitor_stacksize(
char const * name,
char const * value,
void * data ) {
898 __kmp_stg_parse_size(
901 __kmp_sys_min_stksize,
904 & __kmp_monitor_stksize,
910 __kmp_stg_print_monitor_stacksize( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
911 if ( __kmp_monitor_stksize > 0 ) {
912 __kmp_stg_print_size( buffer, name, __kmp_monitor_stksize );
914 __kmp_str_buf_print( buffer,
" %s: %s \n", name, KMP_I18N_STR( NotDefined ) );
923 __kmp_stg_parse_settings(
char const * name,
char const * value,
void * data ) {
924 __kmp_stg_parse_bool( name, value, & __kmp_settings );
928 __kmp_stg_print_settings( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
929 __kmp_stg_print_bool( buffer, name, __kmp_settings );
937 __kmp_stg_parse_stackoffset(
char const * name,
char const * value,
void * data ) {
938 __kmp_stg_parse_size(
950 __kmp_stg_print_stackoffset( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
951 __kmp_stg_print_size( buffer, name, __kmp_stkoffset );
959 __kmp_stg_parse_stacksize(
char const * name,
char const * value,
void * data ) {
961 kmp_stg_ss_data_t * stacksize = (kmp_stg_ss_data_t *) data;
964 rc = __kmp_stg_check_rivals( name, value, stacksize->rivals );
968 __kmp_stg_parse_size(
971 __kmp_sys_min_stksize,
981 __kmp_stg_print_stacksize( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
983 kmp_stg_ss_data_t * stacksize = (kmp_stg_ss_data_t *) data;
984 KMP_DEBUG_ASSERT( stacksize->factor == 1 );
985 __kmp_str_buf_print( buffer,
" %s=", name );
986 __kmp_str_buf_print_size( buffer, __kmp_stksize );
987 __kmp_str_buf_print( buffer,
"\n" );
995 __kmp_stg_parse_version(
char const * name,
char const * value,
void * data ) {
996 __kmp_stg_parse_bool( name, value, & __kmp_version );
1000 __kmp_stg_print_version( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1001 __kmp_stg_print_bool( buffer, name, __kmp_version );
1009 __kmp_stg_parse_warnings(
char const * name,
char const * value,
void * data ) {
1010 __kmp_stg_parse_bool( name, value, & __kmp_generate_warnings );
1011 if (__kmp_generate_warnings != kmp_warnings_off) {
1012 __kmp_generate_warnings = kmp_warnings_explicit;
1017 __kmp_stg_print_warnings( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1018 __kmp_stg_print_bool( buffer, name, __kmp_generate_warnings );
1026 __kmp_stg_parse_nested(
char const * name,
char const * value,
void * data ) {
1027 __kmp_stg_parse_bool( name, value, & __kmp_dflt_nested );
1031 __kmp_stg_print_nested( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1032 __kmp_stg_print_bool( buffer, name, __kmp_dflt_nested );
1036 __kmp_parse_nested_num_threads(
const char *var,
const char *env, kmp_nested_nthreads_t *nth_array )
1038 const char *next = env;
1039 const char *scan = next;
1042 int prev_comma = FALSE;
1048 if ( *next ==
'\0' ) {
1052 if ( ( ( *next <
'0' ) || ( *next >
'9' ) ) && ( *next !=
',') ) {
1053 KMP_WARNING( NthSyntaxError, var, env );
1057 if ( *next ==
',' ) {
1059 if ( total == 0 || prev_comma ) {
1067 if ( *next >=
'0' && *next <=
'9' ) {
1069 SKIP_DIGITS( next );
1071 const char *tmp = next;
1073 if ( ( *next ==
' ' || *next ==
'\t' ) && ( *tmp >=
'0' && *tmp <=
'9' ) ) {
1074 KMP_WARNING( NthSpacesNotAllowed, var, env );
1079 KMP_DEBUG_ASSERT( total > 0 );
1081 KMP_WARNING( NthSyntaxError, var, env );
1086 if ( ! nth_array->nth ) {
1088 nth_array->nth = (
int * )KMP_INTERNAL_MALLOC(
sizeof(
int ) * total * 2 );
1089 if ( nth_array->nth == NULL ) {
1090 KMP_FATAL( MemoryAllocFailed );
1092 nth_array->size = total * 2;
1094 if ( nth_array->size < total ) {
1097 nth_array->size *= 2;
1098 }
while ( nth_array->size < total );
1100 nth_array->nth = (
int *) KMP_INTERNAL_REALLOC(
1101 nth_array->nth,
sizeof(
int ) * nth_array->size );
1102 if ( nth_array->nth == NULL ) {
1103 KMP_FATAL( MemoryAllocFailed );
1107 nth_array->used = total;
1115 if ( *scan ==
'\0' ) {
1119 if ( *scan ==
',' ) {
1124 nth_array->nth[i++] = 0;
1126 }
else if ( prev_comma ) {
1128 nth_array->nth[i] = nth_array->nth[i - 1];
1137 if ( *scan >=
'0' && *scan <=
'9' ) {
1139 const char *buf = scan;
1140 char const * msg = NULL;
1142 SKIP_DIGITS( scan );
1145 num = __kmp_str_to_int( buf, *scan );
1146 if ( num < KMP_MIN_NTH ) {
1147 msg = KMP_I18N_STR( ValueTooSmall );
1149 }
else if ( num > __kmp_sys_max_nth ) {
1150 msg = KMP_I18N_STR( ValueTooLarge );
1151 num = __kmp_sys_max_nth;
1153 if ( msg != NULL ) {
1155 KMP_WARNING( ParseSizeIntWarn, var, env, msg );
1156 KMP_INFORM( Using_int_Value, var, num );
1158 nth_array->nth[i++] = num;
1164 __kmp_stg_parse_num_threads(
char const * name,
char const * value,
void * data ) {
1166 if ( ! __kmp_strcasecmp_with_sentinel(
"all", value, 0 ) ) {
1168 __kmp_nested_nth.nth = (
int* )KMP_INTERNAL_MALLOC(
sizeof(
int ) );
1169 __kmp_nested_nth.size = __kmp_nested_nth.used = 1;
1170 __kmp_nested_nth.nth[0] = __kmp_dflt_team_nth = __kmp_dflt_team_nth_ub = __kmp_xproc;
1172 __kmp_parse_nested_num_threads( name, value, & __kmp_nested_nth );
1173 if ( __kmp_nested_nth.nth ) {
1174 __kmp_dflt_team_nth = __kmp_nested_nth.nth[0];
1175 if ( __kmp_dflt_team_nth_ub < __kmp_dflt_team_nth ) {
1176 __kmp_dflt_team_nth_ub = __kmp_dflt_team_nth;
1180 K_DIAG( 1, (
"__kmp_dflt_team_nth == %d\n", __kmp_dflt_team_nth ) );
1184 __kmp_stg_print_num_threads( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1185 if ( __kmp_nested_nth.used ) {
1187 __kmp_str_buf_init( &buf );
1188 for (
int i = 0; i < __kmp_nested_nth.used; i++) {
1189 __kmp_str_buf_print( &buf,
"%d", __kmp_nested_nth.nth[i] );
1190 if ( i < __kmp_nested_nth.used - 1 ) {
1191 __kmp_str_buf_print( &buf,
"," );
1194 __kmp_stg_print_str(buffer, name, buf.str );
1195 __kmp_str_buf_free(&buf);
1197 __kmp_str_buf_print( buffer,
" %s: %s \n", name, KMP_I18N_STR( NotDefined ) );
1207 __kmp_stg_parse_tasking(
char const * name,
char const * value,
void * data ) {
1208 __kmp_stg_parse_int( name, value, 0, (
int)tskm_max, (
int *)&__kmp_tasking_mode );
1212 __kmp_stg_print_tasking( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1213 __kmp_stg_print_int( buffer, name, __kmp_tasking_mode );
1217 __kmp_stg_parse_task_stealing(
char const * name,
char const * value,
void * data ) {
1218 __kmp_stg_parse_int( name, value, 0, 1, (
int *)&__kmp_task_stealing_constraint );
1222 __kmp_stg_print_task_stealing( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1223 __kmp_stg_print_int( buffer, name, __kmp_task_stealing_constraint );
1227 __kmp_stg_parse_max_active_levels(
char const * name,
char const * value,
void * data ) {
1228 __kmp_stg_parse_int( name, value, 0, KMP_MAX_ACTIVE_LEVELS_LIMIT, & __kmp_dflt_max_active_levels );
1232 __kmp_stg_print_max_active_levels( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1233 __kmp_stg_print_int( buffer, name, __kmp_dflt_max_active_levels );
1235 #endif // OMP_30_ENABLED
1241 #if KMP_HANDLE_SIGNALS
1244 __kmp_stg_parse_handle_signals(
char const * name,
char const * value,
void * data ) {
1245 __kmp_stg_parse_bool( name, value, & __kmp_handle_signals );
1249 __kmp_stg_print_handle_signals( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1250 __kmp_stg_print_bool( buffer, name, __kmp_handle_signals );
1253 #endif // KMP_HANDLE_SIGNALS
1261 #define KMP_STG_X_DEBUG( x ) \
1262 static void __kmp_stg_parse_##x##_debug( char const * name, char const * value, void * data ) { \
1263 __kmp_stg_parse_int( name, value, 0, INT_MAX, & kmp_##x##_debug ); \
1265 static void __kmp_stg_print_##x##_debug( kmp_str_buf_t * buffer, char const * name, void * data ) { \
1266 __kmp_stg_print_int( buffer, name, kmp_##x##_debug ); \
1269 KMP_STG_X_DEBUG( a )
1270 KMP_STG_X_DEBUG( b )
1271 KMP_STG_X_DEBUG( c )
1272 KMP_STG_X_DEBUG( d )
1273 KMP_STG_X_DEBUG( e )
1274 KMP_STG_X_DEBUG( f )
1276 #undef KMP_STG_X_DEBUG
1279 __kmp_stg_parse_debug(
char const * name,
char const * value,
void * data ) {
1281 __kmp_stg_parse_int( name, value, 0, INT_MAX, & debug );
1282 if ( kmp_a_debug < debug ) {
1283 kmp_a_debug = debug;
1285 if ( kmp_b_debug < debug ) {
1286 kmp_b_debug = debug;
1288 if ( kmp_c_debug < debug ) {
1289 kmp_c_debug = debug;
1291 if ( kmp_d_debug < debug ) {
1292 kmp_d_debug = debug;
1294 if ( kmp_e_debug < debug ) {
1295 kmp_e_debug = debug;
1297 if ( kmp_f_debug < debug ) {
1298 kmp_f_debug = debug;
1303 __kmp_stg_parse_debug_buf(
char const * name,
char const * value,
void * data ) {
1304 __kmp_stg_parse_bool( name, value, & __kmp_debug_buf );
1307 if ( __kmp_debug_buf ) {
1309 int elements = __kmp_debug_buf_lines * __kmp_debug_buf_chars;
1312 __kmp_debug_buffer = (
char *) __kmp_page_allocate( elements *
sizeof(
char ) );
1313 for ( i = 0; i < elements; i += __kmp_debug_buf_chars )
1314 __kmp_debug_buffer[i] =
'\0';
1316 __kmp_debug_count = 0;
1318 K_DIAG( 1, (
"__kmp_debug_buf = %d\n", __kmp_debug_buf ) );
1322 __kmp_stg_print_debug_buf( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1323 __kmp_stg_print_bool( buffer, name, __kmp_debug_buf );
1327 __kmp_stg_parse_debug_buf_atomic(
char const * name,
char const * value,
void * data ) {
1328 __kmp_stg_parse_bool( name, value, & __kmp_debug_buf_atomic );
1332 __kmp_stg_print_debug_buf_atomic( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1333 __kmp_stg_print_bool( buffer, name, __kmp_debug_buf_atomic );
1337 __kmp_stg_parse_debug_buf_chars(
char const * name,
char const * value,
void * data ) {
1338 __kmp_stg_parse_int(
1341 KMP_DEBUG_BUF_CHARS_MIN,
1343 & __kmp_debug_buf_chars
1348 __kmp_stg_print_debug_buf_chars( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1349 __kmp_stg_print_int( buffer, name, __kmp_debug_buf_chars );
1353 __kmp_stg_parse_debug_buf_lines(
char const * name,
char const * value,
void * data ) {
1354 __kmp_stg_parse_int(
1357 KMP_DEBUG_BUF_LINES_MIN,
1359 & __kmp_debug_buf_lines
1364 __kmp_stg_print_debug_buf_lines( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1365 __kmp_stg_print_int( buffer, name, __kmp_debug_buf_lines );
1369 __kmp_stg_parse_diag(
char const * name,
char const * value,
void * data ) {
1370 __kmp_stg_parse_int( name, value, 0, INT_MAX, & kmp_diag );
1374 __kmp_stg_print_diag( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1375 __kmp_stg_print_int( buffer, name, kmp_diag );
1385 __kmp_stg_parse_align_alloc(
char const * name,
char const * value,
void * data ) {
1386 __kmp_stg_parse_size(
1392 & __kmp_align_alloc,
1398 __kmp_stg_print_align_alloc( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1399 __kmp_stg_print_size( buffer, name, __kmp_align_alloc );
1410 __kmp_stg_parse_barrier_branch_bit(
char const * name,
char const * value,
void * data ) {
1415 for (
int i=bs_plain_barrier; i<bs_last_barrier; i++ ) {
1416 var = __kmp_barrier_branch_bit_env_name[ i ];
1418 if ( ( strcmp( var, name) == 0 ) && ( value != 0 ) ) {
1421 comma = (
char *) strchr( value,
',' );
1422 __kmp_barrier_gather_branch_bits[ i ] = ( kmp_uint32 ) __kmp_str_to_int( value,
',' );
1424 if ( comma == NULL ) {
1425 __kmp_barrier_release_branch_bits[ i ] = __kmp_barrier_release_bb_dflt;
1427 __kmp_barrier_release_branch_bits[ i ] = (kmp_uint32) __kmp_str_to_int( comma + 1, 0 );
1429 if ( __kmp_barrier_release_branch_bits[ i ] > KMP_MAX_BRANCH_BITS ) {
1430 __kmp_msg( kmp_ms_warning, KMP_MSG( BarrReleaseValueInvalid, name, comma + 1 ), __kmp_msg_null );
1432 __kmp_barrier_release_branch_bits[ i ] = __kmp_barrier_release_bb_dflt;
1435 if ( __kmp_barrier_gather_branch_bits[ i ] > KMP_MAX_BRANCH_BITS ) {
1436 KMP_WARNING( BarrGatherValueInvalid, name, value );
1437 KMP_INFORM( Using_uint_Value, name, __kmp_barrier_gather_bb_dflt );
1438 __kmp_barrier_gather_branch_bits[ i ] = __kmp_barrier_gather_bb_dflt;
1441 K_DIAG(1, (
"%s == %d,%d\n", __kmp_barrier_branch_bit_env_name[ i ], \
1442 __kmp_barrier_gather_branch_bits [ i ], \
1443 __kmp_barrier_release_branch_bits [ i ]))
1448 __kmp_stg_print_barrier_branch_bit( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1450 for (
int i=bs_plain_barrier; i<bs_last_barrier; i++ ) {
1451 var = __kmp_barrier_branch_bit_env_name[ i ];
1452 if ( strcmp( var, name) == 0 ) {
1453 __kmp_str_buf_print( buffer,
" %s=\"%d,%d\"\n", __kmp_barrier_branch_bit_env_name[ i ], \
1454 __kmp_barrier_gather_branch_bits [ i ], \
1455 __kmp_barrier_release_branch_bits [ i ]);
1469 __kmp_stg_parse_barrier_pattern(
char const * name,
char const * value,
void * data ) {
1473 for (
int i=bs_plain_barrier; i<bs_last_barrier; i++ ) {
1474 var = __kmp_barrier_pattern_env_name[ i ];
1476 if ( ( strcmp ( var, name ) == 0 ) && ( value != 0 ) ) {
1478 char *comma = (
char *) strchr( value,
',' );
1481 for ( j = bp_linear_bar; j<bp_last_bar; j++ ) {
1482 if (__kmp_match_with_sentinel( __kmp_barrier_pattern_name[j], value, 1,
',' )) {
1483 __kmp_barrier_gather_pattern[ i ] = (kmp_bar_pat_e) j;
1487 if ( j == bp_last_bar ) {
1488 KMP_WARNING( BarrGatherValueInvalid, name, value );
1489 KMP_INFORM( Using_str_Value, name, __kmp_barrier_pattern_name[ bp_linear_bar ] );
1493 if ( comma != NULL ) {
1494 for ( j = bp_linear_bar; j < bp_last_bar; j++ ) {
1495 if ( __kmp_str_match( __kmp_barrier_pattern_name[j], 1, comma + 1 ) ) {
1496 __kmp_barrier_release_pattern[ i ] = (kmp_bar_pat_e) j;
1500 if (j == bp_last_bar) {
1501 __kmp_msg( kmp_ms_warning, KMP_MSG( BarrReleaseValueInvalid, name, comma + 1 ), __kmp_msg_null );
1502 KMP_INFORM( Using_str_Value, name, __kmp_barrier_pattern_name[ bp_linear_bar ] );
1510 __kmp_stg_print_barrier_pattern( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1512 for (
int i=bs_plain_barrier; i<bs_last_barrier; i++ ) {
1513 var = __kmp_barrier_pattern_env_name[ i ];
1514 if ( strcmp ( var, name ) == 0 ) {
1515 int j = __kmp_barrier_gather_pattern [ i ];
1516 int k = __kmp_barrier_release_pattern [ i ];
1517 __kmp_str_buf_print( buffer,
" %s=\"%s,%s\"\n", __kmp_barrier_pattern_env_name[ i ], \
1518 __kmp_barrier_pattern_name [ j ], \
1519 __kmp_barrier_pattern_name [ k ]);
1529 __kmp_stg_parse_abort_delay(
char const * name,
char const * value,
void * data ) {
1531 int delay = __kmp_abort_delay / 1000;
1532 __kmp_stg_parse_int( name, value, 0, INT_MAX / 1000, & delay );
1533 __kmp_abort_delay = delay * 1000;
1537 __kmp_stg_print_abort_delay( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1538 __kmp_stg_print_int( buffer, name, __kmp_abort_delay );
1546 __kmp_stg_parse_cpuinfo_file(
char const * name,
char const * value,
void * data ) {
1547 #if KMP_OS_LINUX || KMP_OS_WINDOWS
1548 __kmp_stg_parse_str( name, value, & __kmp_cpuinfo_file );
1549 K_DIAG( 1, (
"__kmp_cpuinfo_file == %s\n", __kmp_cpuinfo_file ) );
1553 #error "Unknown or unsupported OS"
1558 __kmp_stg_print_cpuinfo_file( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1559 #if KMP_OS_LINUX || KMP_OS_WINDOWS
1560 if ( __kmp_cpuinfo_file ) {
1561 __kmp_stg_print_str( buffer, name, __kmp_cpuinfo_file);
1563 __kmp_str_buf_print( buffer,
" %s: %s \n", name, KMP_I18N_STR( NotDefined ) );
1573 __kmp_stg_parse_force_reduction(
char const * name,
char const * value,
void * data )
1575 kmp_stg_fr_data_t * reduction = (kmp_stg_fr_data_t *) data;
1578 rc = __kmp_stg_check_rivals( name, value, reduction->rivals );
1582 if ( reduction->force ) {
1584 if( __kmp_str_match(
"critical", 0, value ) )
1585 __kmp_force_reduction_method = critical_reduce_block;
1586 else if( __kmp_str_match(
"atomic", 0, value ) )
1587 __kmp_force_reduction_method = atomic_reduce_block;
1588 else if( __kmp_str_match(
"tree", 0, value ) )
1589 __kmp_force_reduction_method = tree_reduce_block;
1591 KMP_FATAL( UnknownForceReduction, name, value );
1595 __kmp_stg_parse_bool( name, value, & __kmp_determ_red );
1596 if( __kmp_determ_red ) {
1597 __kmp_force_reduction_method = tree_reduce_block;
1599 __kmp_force_reduction_method = reduction_method_not_defined;
1602 K_DIAG( 1, (
"__kmp_force_reduction_method == %d\n", __kmp_force_reduction_method ) );
1606 __kmp_stg_print_force_reduction( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1608 kmp_stg_fr_data_t * reduction = (kmp_stg_fr_data_t *) data;
1609 char const * value = NULL;
1610 if ( reduction->force ) {
1611 if( __kmp_force_reduction_method == critical_reduce_block) {
1612 __kmp_stg_print_str( buffer, name,
"critical");
1613 }
else if ( __kmp_force_reduction_method == atomic_reduce_block ) {
1614 __kmp_stg_print_str( buffer, name,
"atomic");
1615 }
else if ( __kmp_force_reduction_method == tree_reduce_block ) {
1616 __kmp_stg_print_str( buffer, name,
"tree");
1618 __kmp_str_buf_print( buffer,
" %s: %s \n", name, KMP_I18N_STR( NotDefined ) );
1621 __kmp_stg_print_bool( buffer, name, __kmp_determ_red );
1632 __kmp_stg_parse_storage_map(
char const * name,
char const * value,
void * data ) {
1633 if ( __kmp_str_match(
"verbose", 1, value ) ) {
1634 __kmp_storage_map = TRUE;
1635 __kmp_storage_map_verbose = TRUE;
1636 __kmp_storage_map_verbose_specified = TRUE;
1639 __kmp_storage_map_verbose = FALSE;
1640 __kmp_stg_parse_bool( name, value, & __kmp_storage_map );
1645 __kmp_stg_print_storage_map( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1646 if ( __kmp_storage_map_verbose || __kmp_storage_map_verbose_specified ) {
1647 __kmp_stg_print_str( buffer, name,
"verbose" );
1649 __kmp_stg_print_bool( buffer, name, __kmp_storage_map );
1658 __kmp_stg_parse_all_threadprivate(
char const * name,
char const * value,
void * data ) {
1659 __kmp_stg_parse_int( name, value, __kmp_allThreadsSpecified ? __kmp_max_nth : 1, __kmp_max_nth,
1660 & __kmp_tp_capacity );
1664 __kmp_stg_print_all_threadprivate( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1665 __kmp_stg_print_int( buffer, name, __kmp_tp_capacity );
1674 __kmp_stg_parse_foreign_threads_threadprivate(
char const * name,
char const * value,
void * data ) {
1675 __kmp_stg_parse_bool( name, value, & __kmp_foreign_tp );
1679 __kmp_stg_print_foreign_threads_threadprivate( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1680 __kmp_stg_print_bool( buffer, name, __kmp_foreign_tp );
1688 #if KMP_OS_LINUX || KMP_OS_WINDOWS
1693 __kmp_parse_affinity_proc_id_list(
const char *var,
const char *env,
1694 const char **nextEnv,
char **proclist )
1696 const char *scan = env;
1697 const char *next = scan;
1703 int start, end, stride;
1707 if (*next ==
'\0') {
1720 if ((*next <
'0') || (*next >
'9')) {
1721 KMP_WARNING( AffSyntaxError, var );
1725 num = __kmp_str_to_int(scan, *next);
1726 KMP_ASSERT(num >= 0);
1750 if ((*next <
'0') || (*next >
'9')) {
1751 KMP_WARNING( AffSyntaxError, var );
1756 num = __kmp_str_to_int(scan, *next);
1757 KMP_ASSERT(num >= 0);
1772 if ((*next <
'0') || (*next >
'9')) {
1774 KMP_WARNING( AffSyntaxError, var );
1784 start = __kmp_str_to_int(scan, *next);
1785 KMP_ASSERT(start >= 0);
1810 if ((*next <
'0') || (*next >
'9')) {
1811 KMP_WARNING( AffSyntaxError, var );
1815 end = __kmp_str_to_int(scan, *next);
1816 KMP_ASSERT(end >= 0);
1837 if ((*next <
'0') || (*next >
'9')) {
1838 KMP_WARNING( AffSyntaxError, var );
1842 stride = __kmp_str_to_int(scan, *next);
1843 KMP_ASSERT(stride >= 0);
1851 KMP_WARNING( AffZeroStride, var );
1856 KMP_WARNING( AffStartGreaterEnd, var, start, end );
1862 KMP_WARNING( AffStrideLessZero, var, start, end );
1866 if ((end - start) / stride > 65536 ) {
1867 KMP_WARNING( AffRangeTooBig, var, end, start, stride );
1886 int len = next - env;
1887 char *retlist = (
char *)__kmp_allocate((len + 1) *
sizeof(char));
1888 memcpy(retlist, env, len *
sizeof(
char));
1889 retlist[len] =
'\0';
1890 *proclist = retlist;
1900 static kmp_setting_t *__kmp_affinity_notype = NULL;
1903 __kmp_parse_affinity_env(
char const * name,
char const * value,
1904 enum affinity_type * out_type,
1905 char ** out_proclist,
1909 enum affinity_gran * out_gran,
1910 int * out_gran_levels,
1916 char * buffer = NULL;
1926 int max_proclist = 0;
1933 KMP_ASSERT( value != NULL );
1935 if ( TCR_4(__kmp_init_middle) ) {
1936 KMP_WARNING( EnvMiddleWarn, name );
1937 __kmp_env_toPrint( name, 0 );
1940 __kmp_env_toPrint( name, 1 );
1942 buffer = __kmp_str_format(
"%s", value );
1954 #define EMIT_WARN(skip,errlist) \
1958 SKIP_TO(next, ','); \
1962 KMP_WARNING errlist; \
1965 if (ch == ',') next++; \
1970 #define _set_param(_guard,_var,_val) \
1972 if ( _guard == 0 ) { \
1975 EMIT_WARN( FALSE, ( AffParamDefined, name, start ) ); \
1980 #define set_type(val) _set_param( type, *out_type, val )
1981 #define set_verbose(val) _set_param( verbose, *out_verbose, val )
1982 #define set_warnings(val) _set_param( warnings, *out_warn, val )
1983 #define set_respect(val) _set_param( respect, *out_respect, val )
1984 #define set_dups(val) _set_param( dups, *out_dups, val )
1985 #define set_proclist(val) _set_param( proclist, *out_proclist, val )
1987 #define set_gran(val,levels) \
1989 if ( gran == 0 ) { \
1991 *out_gran_levels = levels; \
1993 EMIT_WARN( FALSE, ( AffParamDefined, name, start ) ); \
1999 KMP_DEBUG_ASSERT( ( __kmp_nested_proc_bind.bind_types != NULL )
2000 && ( __kmp_nested_proc_bind.used > 0 ) );
2001 if ( ( __kmp_affinity_notype != NULL )
2002 && ( ( __kmp_nested_proc_bind.bind_types[0] == proc_bind_default )
2003 || ( __kmp_nested_proc_bind.bind_types[0] == proc_bind_intel ) ) ) {
2008 while ( *buf !=
'\0' ) {
2011 if (__kmp_match_str(
"none", buf, (
const char **)&next)) {
2012 set_type( affinity_none );
2014 }
else if (__kmp_match_str(
"scatter", buf, (
const char **)&next)) {
2015 set_type( affinity_scatter );
2017 }
else if (__kmp_match_str(
"compact", buf, (
const char **)&next)) {
2018 set_type( affinity_compact );
2020 }
else if (__kmp_match_str(
"logical", buf, (
const char **)&next)) {
2021 set_type( affinity_logical );
2023 }
else if (__kmp_match_str(
"physical", buf, (
const char **)&next)) {
2024 set_type( affinity_physical );
2026 }
else if (__kmp_match_str(
"explicit", buf, (
const char **)&next)) {
2027 set_type( affinity_explicit );
2030 }
else if (__kmp_match_str(
"balanced", buf, (
const char **)&next)) {
2031 set_type( affinity_balanced );
2034 }
else if (__kmp_match_str(
"disabled", buf, (
const char **)&next)) {
2035 set_type( affinity_disabled );
2037 }
else if (__kmp_match_str(
"verbose", buf, (
const char **)&next)) {
2038 set_verbose( TRUE );
2040 }
else if (__kmp_match_str(
"noverbose", buf, (
const char **)&next)) {
2041 set_verbose( FALSE );
2043 }
else if (__kmp_match_str(
"warnings", buf, (
const char **)&next)) {
2044 set_warnings( TRUE );
2046 }
else if (__kmp_match_str(
"nowarnings", buf, (
const char **)&next)) {
2047 set_warnings( FALSE );
2049 }
else if (__kmp_match_str(
"respect", buf, (
const char **)&next)) {
2050 set_respect( TRUE );
2052 }
else if (__kmp_match_str(
"norespect", buf, (
const char **)&next)) {
2053 set_respect( FALSE );
2055 }
else if (__kmp_match_str(
"duplicates", buf, (
const char **)&next)
2056 || __kmp_match_str(
"dups", buf, (
const char **)&next)) {
2059 }
else if (__kmp_match_str(
"noduplicates", buf, (
const char **)&next)
2060 || __kmp_match_str(
"nodups", buf, (
const char **)&next)) {
2063 }
else if (__kmp_match_str(
"granularity", buf, (
const char **)&next)
2064 || __kmp_match_str(
"gran", buf, (
const char **)&next)) {
2067 EMIT_WARN( TRUE, ( AffInvalidParam, name, start ) );
2074 if (__kmp_match_str(
"fine", buf, (
const char **)&next)) {
2075 set_gran( affinity_gran_fine, -1 );
2077 }
else if (__kmp_match_str(
"thread", buf, (
const char **)&next)) {
2078 set_gran( affinity_gran_thread, -1 );
2080 }
else if (__kmp_match_str(
"core", buf, (
const char **)&next)) {
2081 set_gran( affinity_gran_core, -1 );
2083 }
else if (__kmp_match_str(
"package", buf, (
const char **)&next)) {
2084 set_gran( affinity_gran_package, -1 );
2086 }
else if (__kmp_match_str(
"node", buf, (
const char **)&next)) {
2087 set_gran( affinity_gran_node, -1 );
2089 # if KMP_OS_WINDOWS && KMP_ARCH_X86_64
2090 }
else if (__kmp_match_str(
"group", buf, (
const char **)&next)) {
2091 set_gran( affinity_gran_group, -1 );
2094 }
else if ((*buf >=
'0') && (*buf <=
'9')) {
2098 n = __kmp_str_to_int( buf, *next );
2101 set_gran( affinity_gran_default, n );
2103 EMIT_WARN( TRUE, ( AffInvalidParam, name, start ) );
2106 }
else if (__kmp_match_str(
"proclist", buf, (
const char **)&next)) {
2107 char *temp_proclist;
2111 EMIT_WARN( TRUE, ( AffInvalidParam, name, start ) );
2117 EMIT_WARN( TRUE, ( AffInvalidParam, name, start ) );
2122 if (! __kmp_parse_affinity_proc_id_list(name, buf,
2123 (
const char **)&next, &temp_proclist)) {
2128 if (*next ==
']') next++;
2130 if (*next ==
',') next++;
2135 EMIT_WARN( TRUE, ( AffInvalidParam, name, start ) );
2139 set_proclist( temp_proclist );
2140 }
else if ((*buf >=
'0') && (*buf <=
'9')) {
2145 n = __kmp_str_to_int( buf, *next );
2149 number[ count ] = n;
2151 KMP_WARNING( AffManyParams, name, start );
2155 EMIT_WARN( TRUE, ( AffInvalidParam, name, start ) );
2164 else if (*next !=
'\0') {
2165 const char *temp = next;
2166 EMIT_WARN( TRUE, ( ParseExtraCharsWarn, name, temp ) );
2178 #undef set_granularity
2180 KMP_INTERNAL_FREE( buffer );
2184 KMP_WARNING( AffProcListNoType, name );
2185 __kmp_affinity_type = affinity_explicit;
2187 else if ( __kmp_affinity_type != affinity_explicit ) {
2188 KMP_WARNING( AffProcListNotExplicit, name );
2189 KMP_ASSERT( *out_proclist != NULL );
2190 KMP_INTERNAL_FREE( *out_proclist );
2191 *out_proclist = NULL;
2194 switch ( *out_type ) {
2195 case affinity_logical:
2196 case affinity_physical: {
2198 *out_offset = number[ 0 ];
2201 KMP_WARNING( AffManyParamsForLogic, name, number[ 1 ] );
2205 case affinity_balanced: {
2207 *out_compact = number[ 0 ];
2210 *out_offset = number[ 1 ];
2214 if( __kmp_affinity_gran != affinity_gran_default && __kmp_affinity_gran != affinity_gran_fine
2215 && __kmp_affinity_gran != affinity_gran_thread && __kmp_affinity_gran != affinity_gran_core ) {
2216 if( __kmp_affinity_verbose || __kmp_affinity_warnings ) {
2217 KMP_WARNING( AffGranUsing,
"KMP_AFFINITY",
"core" );
2219 __kmp_affinity_gran = affinity_gran_fine;
2223 case affinity_scatter:
2224 case affinity_compact: {
2226 *out_compact = number[ 0 ];
2229 *out_offset = number[ 1 ];
2232 case affinity_explicit: {
2233 if ( *out_proclist == NULL ) {
2234 KMP_WARNING( AffNoProcList, name );
2235 __kmp_affinity_type = affinity_none;
2238 KMP_WARNING( AffNoParam, name,
"explicit" );
2241 case affinity_none: {
2243 KMP_WARNING( AffNoParam, name,
"none" );
2246 case affinity_disabled: {
2248 KMP_WARNING( AffNoParam, name,
"disabled" );
2251 case affinity_default: {
2253 KMP_WARNING( AffNoParam, name,
"default" );
2263 __kmp_stg_parse_affinity(
char const * name,
char const * value,
void * data )
2265 kmp_setting_t **rivals = (kmp_setting_t **) data;
2268 rc = __kmp_stg_check_rivals( name, value, rivals );
2273 __kmp_parse_affinity_env( name, value, & __kmp_affinity_type,
2274 & __kmp_affinity_proclist, & __kmp_affinity_verbose,
2275 & __kmp_affinity_warnings, & __kmp_affinity_respect_mask,
2276 & __kmp_affinity_gran, & __kmp_affinity_gran_levels,
2277 & __kmp_affinity_dups, & __kmp_affinity_compact,
2278 & __kmp_affinity_offset );
2283 __kmp_stg_print_affinity( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
2284 if ( __kmp_affinity_verbose ) {
2285 __kmp_str_buf_print( buffer,
" %s=\"%s,", name,
"verbose");
2287 __kmp_str_buf_print( buffer,
" %s=\"%s,", name,
"noverbose");
2289 if ( __kmp_affinity_warnings ) {
2290 __kmp_str_buf_print( buffer,
"%s,",
"warnings");
2292 __kmp_str_buf_print( buffer,
"%s,",
"nowarnings");
2294 if ( KMP_AFFINITY_CAPABLE() ) {
2295 if ( __kmp_affinity_respect_mask ) {
2296 __kmp_str_buf_print( buffer,
"%s,",
"respect");
2298 __kmp_str_buf_print( buffer,
"%s,",
"norespect");
2300 switch ( __kmp_affinity_gran ) {
2301 case affinity_gran_default:
2302 __kmp_str_buf_print( buffer,
"%s",
"granularity=default,");
2304 case affinity_gran_fine:
2305 __kmp_str_buf_print( buffer,
"%s",
"granularity=fine,");
2307 case affinity_gran_thread:
2308 __kmp_str_buf_print( buffer,
"%s",
"granularity=thread,");
2310 case affinity_gran_core:
2311 __kmp_str_buf_print( buffer,
"%s",
"granularity=core,");
2313 case affinity_gran_package:
2314 __kmp_str_buf_print( buffer,
"%s",
"granularity=package,");
2316 case affinity_gran_node:
2317 __kmp_str_buf_print( buffer,
"%s",
"granularity=node,");
2319 # if KMP_OS_WINDOWS && KMP_ARCH_X86_64
2320 case affinity_gran_group:
2321 __kmp_str_buf_print( buffer,
"%s",
"granularity=group,");
2325 if ( __kmp_affinity_dups ) {
2326 __kmp_str_buf_print( buffer,
"%s,",
"duplicates");
2328 __kmp_str_buf_print( buffer,
"%s,",
"noduplicates");
2331 if ( ! KMP_AFFINITY_CAPABLE() ) {
2332 __kmp_str_buf_print( buffer,
"%s\"\n",
"disabled" );
2334 else switch ( __kmp_affinity_type ){
2336 __kmp_str_buf_print( buffer,
"%s\"\n",
"none");
2338 case affinity_physical:
2339 __kmp_str_buf_print( buffer,
"%s,%d\"\n",
"physical",
2340 __kmp_affinity_offset );
2342 case affinity_logical:
2343 __kmp_str_buf_print( buffer,
"%s,%d\"\n",
"logical",
2344 __kmp_affinity_offset );
2346 case affinity_compact:
2347 __kmp_str_buf_print( buffer,
"%s,%d,%d\"\n",
"compact",
2348 __kmp_affinity_compact, __kmp_affinity_offset );
2350 case affinity_scatter:
2351 __kmp_str_buf_print( buffer,
"%s,%d,%d\"\n",
"scatter",
2352 __kmp_affinity_compact, __kmp_affinity_offset );
2354 case affinity_explicit:
2355 __kmp_str_buf_print( buffer,
"%s=[%s],%s\"\n",
"proclist",
2356 __kmp_affinity_proclist,
"explicit" );
2359 case affinity_balanced:
2360 __kmp_str_buf_print( buffer,
"%s,%d,%d\"\n",
"balanced",
2361 __kmp_affinity_compact, __kmp_affinity_offset );
2364 case affinity_disabled:
2365 __kmp_str_buf_print( buffer,
"%s\"\n",
"disabled");
2367 case affinity_default:
2368 __kmp_str_buf_print( buffer,
"%s\"\n",
"default");
2371 __kmp_str_buf_print( buffer,
"%s",
"<unknown>\n");
2376 # ifdef KMP_GOMP_COMPAT
2379 __kmp_stg_parse_gomp_cpu_affinity(
char const * name,
char const * value,
void * data )
2381 const char * next = NULL;
2382 char * temp_proclist;
2383 kmp_setting_t **rivals = (kmp_setting_t **) data;
2386 rc = __kmp_stg_check_rivals( name, value, rivals );
2391 if ( TCR_4(__kmp_init_middle) ) {
2392 KMP_WARNING( EnvMiddleWarn, name );
2393 __kmp_env_toPrint( name, 0 );
2397 __kmp_env_toPrint( name, 1 );
2399 if ( __kmp_parse_affinity_proc_id_list( name, value, &next,
2402 if (*next ==
'\0') {
2406 __kmp_affinity_proclist = temp_proclist;
2407 __kmp_affinity_type = affinity_explicit;
2408 __kmp_affinity_gran = affinity_gran_fine;
2411 KMP_WARNING( AffSyntaxError, name );
2412 if (temp_proclist != NULL) {
2413 KMP_INTERNAL_FREE((
void *)temp_proclist);
2421 __kmp_affinity_type = affinity_none;
2453 __kmp_parse_subplace_list(
const char *var,
const char **scan )
2458 int start, count, stride;
2464 if ((**scan <
'0') || (**scan >
'9')) {
2465 KMP_WARNING( SyntaxErrorUsing, var,
"\"threads\"" );
2470 start = __kmp_str_to_int(*scan, *next);
2471 KMP_ASSERT(start >= 0);
2478 if (**scan ==
'}') {
2481 if (**scan ==
',') {
2485 if (**scan !=
':') {
2486 KMP_WARNING( SyntaxErrorUsing, var,
"\"threads\"" );
2495 if ((**scan <
'0') || (**scan >
'9')) {
2496 KMP_WARNING( SyntaxErrorUsing, var,
"\"threads\"" );
2501 count = __kmp_str_to_int(*scan, *next);
2502 KMP_ASSERT(count >= 0);
2509 if (**scan ==
'}') {
2512 if (**scan ==
',') {
2516 if (**scan !=
':') {
2517 KMP_WARNING( SyntaxErrorUsing, var,
"\"threads\"" );
2528 if (**scan ==
'+') {
2532 if (**scan ==
'-') {
2540 if ((**scan <
'0') || (**scan >
'9')) {
2541 KMP_WARNING( SyntaxErrorUsing, var,
"\"threads\"" );
2546 stride = __kmp_str_to_int(*scan, *next);
2547 KMP_ASSERT(stride >= 0);
2555 if (**scan ==
'}') {
2558 if (**scan ==
',') {
2563 KMP_WARNING( SyntaxErrorUsing, var,
"\"threads\"" );
2570 __kmp_parse_place(
const char *var,
const char ** scan )
2578 if (**scan ==
'{') {
2580 if (! __kmp_parse_subplace_list(var, scan)) {
2583 if (**scan !=
'}') {
2584 KMP_WARNING( SyntaxErrorUsing, var,
"\"threads\"" );
2589 else if (**scan ==
'!') {
2591 return __kmp_parse_place(var, scan);
2593 else if ((**scan >=
'0') && (**scan <=
'9')) {
2596 int proc = __kmp_str_to_int(*scan, *next);
2597 KMP_ASSERT(proc >= 0);
2601 KMP_WARNING( SyntaxErrorUsing, var,
"\"threads\"" );
2608 __kmp_parse_place_list(
const char *var,
const char *env,
char **place_list )
2610 const char *scan = env;
2611 const char *next = scan;
2614 int start, count, stride;
2616 if (! __kmp_parse_place(var, &scan)) {
2624 if (*scan ==
'\0') {
2632 KMP_WARNING( SyntaxErrorUsing, var,
"\"threads\"" );
2641 if ((*scan <
'0') || (*scan >
'9')) {
2642 KMP_WARNING( SyntaxErrorUsing, var,
"\"threads\"" );
2647 count = __kmp_str_to_int(scan, *next);
2648 KMP_ASSERT(count >= 0);
2655 if (*scan ==
'\0') {
2663 KMP_WARNING( SyntaxErrorUsing, var,
"\"threads\"" );
2686 if ((*scan <
'0') || (*scan >
'9')) {
2687 KMP_WARNING( SyntaxErrorUsing, var,
"\"threads\"" );
2692 stride = __kmp_str_to_int(scan, *next);
2693 KMP_ASSERT(stride >= 0);
2701 if (*scan ==
'\0') {
2709 KMP_WARNING( SyntaxErrorUsing, var,
"\"threads\"" );
2714 int len = scan - env;
2715 char *retlist = (
char *)__kmp_allocate((len + 1) *
sizeof(char));
2716 memcpy(retlist, env, len *
sizeof(
char));
2717 retlist[len] =
'\0';
2718 *place_list = retlist;
2724 __kmp_stg_parse_places(
char const * name,
char const * value,
void * data )
2727 const char *scan = value;
2728 const char *next = scan;
2729 const char *kind =
"\"threads\"";
2733 if ( __kmp_match_str(
"threads", scan, &next ) ) {
2735 __kmp_affinity_type = affinity_compact;
2736 __kmp_affinity_gran = affinity_gran_thread;
2737 __kmp_affinity_dups = FALSE;
2738 kind =
"\"threads\"";
2740 else if ( __kmp_match_str(
"cores", scan, &next ) ) {
2742 __kmp_affinity_type = affinity_compact;
2743 __kmp_affinity_gran = affinity_gran_core;
2744 __kmp_affinity_dups = FALSE;
2747 else if ( __kmp_match_str(
"sockets", scan, &next ) ) {
2749 __kmp_affinity_type = affinity_compact;
2750 __kmp_affinity_gran = affinity_gran_package;
2751 __kmp_affinity_dups = FALSE;
2752 kind =
"\"sockets\"";
2755 if ( __kmp_affinity_proclist != NULL ) {
2756 KMP_INTERNAL_FREE( (
void *)__kmp_affinity_proclist );
2757 __kmp_affinity_proclist = NULL;
2759 if ( __kmp_parse_place_list( name, value, &__kmp_affinity_proclist ) ) {
2760 __kmp_affinity_type = affinity_explicit;
2761 __kmp_affinity_gran = affinity_gran_fine;
2762 __kmp_affinity_dups = FALSE;
2768 if ( *scan ==
'\0' ) {
2775 if ( *scan !=
'(' ) {
2776 KMP_WARNING( SyntaxErrorUsing, name, kind );
2784 count = __kmp_str_to_int(scan, *next);
2785 KMP_ASSERT(count >= 0);
2789 if ( *scan !=
')' ) {
2790 KMP_WARNING( SyntaxErrorUsing, name, kind );
2796 if ( *scan !=
'\0' ) {
2797 KMP_WARNING( ParseExtraCharsWarn, name, scan );
2799 __kmp_affinity_num_places = count;
2803 __kmp_stg_print_places( kmp_str_buf_t * buffer,
char const * name,
2806 if ( ( __kmp_nested_proc_bind.used == 0 )
2807 || ( __kmp_nested_proc_bind.bind_types == NULL )
2808 || ( __kmp_nested_proc_bind.bind_types[0] == proc_bind_false )
2809 || ( __kmp_nested_proc_bind.bind_types[0] == proc_bind_intel ) ) {
2810 __kmp_str_buf_print( buffer,
" %s: %s \n", name,
2811 KMP_I18N_STR( NotDefined ) );
2813 else if ( __kmp_affinity_type == affinity_explicit ) {
2814 if ( __kmp_affinity_proclist != NULL ) {
2815 __kmp_str_buf_print( buffer,
" %s=\"%s\" \n", name,
2816 __kmp_affinity_proclist );
2819 __kmp_str_buf_print( buffer,
" %s: %s \n", name,
2820 KMP_I18N_STR( NotDefined ) );
2823 else if ( __kmp_affinity_type == affinity_compact ) {
2825 if ( __kmp_affinity_num_masks > 0 ) {
2826 num = __kmp_affinity_num_masks;
2828 else if ( __kmp_affinity_num_places > 0 ) {
2829 num = __kmp_affinity_num_places;
2834 if ( __kmp_affinity_gran == affinity_gran_thread ) {
2836 __kmp_str_buf_print( buffer,
" %s=\"threads(%d)\" \n", name,
2840 __kmp_str_buf_print( buffer,
" %s=\"threads\" \n", name );
2843 else if ( __kmp_affinity_gran == affinity_gran_core ) {
2845 __kmp_str_buf_print( buffer,
" %s=\"cores(%d)\" \n", name,
2849 __kmp_str_buf_print( buffer,
" %s=\"cores\" \n", name );
2852 else if ( __kmp_affinity_gran == affinity_gran_package ) {
2854 __kmp_str_buf_print( buffer,
" %s=\"sockets(%d)\" \n", name,
2858 __kmp_str_buf_print( buffer,
" %s=\"sockets\" \n", name );
2862 __kmp_str_buf_print( buffer,
" %s: %s \n", name, KMP_I18N_STR( NotDefined ) );
2866 __kmp_str_buf_print( buffer,
" %s: %s \n", name, KMP_I18N_STR( NotDefined ) );
2872 # if OMP_30_ENABLED && (! OMP_40_ENABLED)
2875 __kmp_stg_parse_proc_bind(
char const * name,
char const * value,
void * data )
2878 kmp_setting_t **rivals = (kmp_setting_t **) data;
2881 rc = __kmp_stg_check_rivals( name, value, rivals );
2889 __kmp_stg_parse_bool( name, value, & enabled );
2894 __kmp_affinity_type = affinity_scatter;
2895 __kmp_affinity_gran = affinity_gran_core;
2898 __kmp_affinity_type = affinity_none;
2906 __kmp_stg_parse_topology_method(
char const * name,
char const * value,
2908 if ( __kmp_str_match(
"all", 1, value ) ) {
2909 __kmp_affinity_top_method = affinity_top_method_all;
2911 # if KMP_ARCH_X86 || KMP_ARCH_X86_64
2912 else if ( __kmp_str_match(
"x2apic id", 9, value )
2913 || __kmp_str_match(
"x2apic_id", 9, value )
2914 || __kmp_str_match(
"x2apic-id", 9, value )
2915 || __kmp_str_match(
"x2apicid", 8, value )
2916 || __kmp_str_match(
"cpuid leaf 11", 13, value )
2917 || __kmp_str_match(
"cpuid_leaf_11", 13, value )
2918 || __kmp_str_match(
"cpuid-leaf-11", 13, value )
2919 || __kmp_str_match(
"cpuid leaf11", 12, value )
2920 || __kmp_str_match(
"cpuid_leaf11", 12, value )
2921 || __kmp_str_match(
"cpuid-leaf11", 12, value )
2922 || __kmp_str_match(
"cpuidleaf 11", 12, value )
2923 || __kmp_str_match(
"cpuidleaf_11", 12, value )
2924 || __kmp_str_match(
"cpuidleaf-11", 12, value )
2925 || __kmp_str_match(
"cpuidleaf11", 11, value )
2926 || __kmp_str_match(
"cpuid 11", 8, value )
2927 || __kmp_str_match(
"cpuid_11", 8, value )
2928 || __kmp_str_match(
"cpuid-11", 8, value )
2929 || __kmp_str_match(
"cpuid11", 7, value )
2930 || __kmp_str_match(
"leaf 11", 7, value )
2931 || __kmp_str_match(
"leaf_11", 7, value )
2932 || __kmp_str_match(
"leaf-11", 7, value )
2933 || __kmp_str_match(
"leaf11", 6, value ) ) {
2934 __kmp_affinity_top_method = affinity_top_method_x2apicid;
2936 else if ( __kmp_str_match(
"apic id", 7, value )
2937 || __kmp_str_match(
"apic_id", 7, value )
2938 || __kmp_str_match(
"apic-id", 7, value )
2939 || __kmp_str_match(
"apicid", 6, value )
2940 || __kmp_str_match(
"cpuid leaf 4", 12, value )
2941 || __kmp_str_match(
"cpuid_leaf_4", 12, value )
2942 || __kmp_str_match(
"cpuid-leaf-4", 12, value )
2943 || __kmp_str_match(
"cpuid leaf4", 11, value )
2944 || __kmp_str_match(
"cpuid_leaf4", 11, value )
2945 || __kmp_str_match(
"cpuid-leaf4", 11, value )
2946 || __kmp_str_match(
"cpuidleaf 4", 11, value )
2947 || __kmp_str_match(
"cpuidleaf_4", 11, value )
2948 || __kmp_str_match(
"cpuidleaf-4", 11, value )
2949 || __kmp_str_match(
"cpuidleaf4", 10, value )
2950 || __kmp_str_match(
"cpuid 4", 7, value )
2951 || __kmp_str_match(
"cpuid_4", 7, value )
2952 || __kmp_str_match(
"cpuid-4", 7, value )
2953 || __kmp_str_match(
"cpuid4", 6, value )
2954 || __kmp_str_match(
"leaf 4", 6, value )
2955 || __kmp_str_match(
"leaf_4", 6, value )
2956 || __kmp_str_match(
"leaf-4", 6, value )
2957 || __kmp_str_match(
"leaf4", 5, value ) ) {
2958 __kmp_affinity_top_method = affinity_top_method_apicid;
2961 else if ( __kmp_str_match(
"/proc/cpuinfo", 2, value )
2962 || __kmp_str_match(
"cpuinfo", 5, value )) {
2963 __kmp_affinity_top_method = affinity_top_method_cpuinfo;
2965 # if KMP_OS_WINDOWS && KMP_ARCH_X86_64
2966 else if ( __kmp_str_match(
"group", 1, value ) ) {
2967 __kmp_affinity_top_method = affinity_top_method_group;
2970 else if ( __kmp_str_match(
"flat", 1, value ) ) {
2971 __kmp_affinity_top_method = affinity_top_method_flat;
2974 KMP_WARNING( StgInvalidValue, name, value );
2979 __kmp_stg_print_topology_method( kmp_str_buf_t * buffer,
char const * name,
2982 char const * value = NULL;
2984 switch ( __kmp_affinity_top_method ) {
2985 case affinity_top_method_default:
2989 case affinity_top_method_all:
2993 # if KMP_ARCH_X86 || KMP_ARCH_X86_64
2994 case affinity_top_method_x2apicid:
2995 value =
"x2APIC id";
2998 case affinity_top_method_apicid:
3003 case affinity_top_method_cpuinfo:
3007 # if KMP_OS_WINDOWS && KMP_ARCH_X86_64
3008 case affinity_top_method_group:
3013 case affinity_top_method_flat:
3018 if ( value != NULL ) {
3019 __kmp_stg_print_str( buffer, name, value );
3027 #error "Unknown or unsupported OS"
3038 __kmp_stg_parse_proc_bind(
char const * name,
char const * value,
void * data )
3040 kmp_setting_t **rivals = (kmp_setting_t **) data;
3043 rc = __kmp_stg_check_rivals( name, value, rivals );
3051 KMP_DEBUG_ASSERT( (__kmp_nested_proc_bind.bind_types != NULL)
3052 && ( __kmp_nested_proc_bind.used > 0 ) );
3054 const char *buf = value;
3058 if ( (*buf >=
'0') && (*buf <=
'9') ) {
3060 SKIP_DIGITS( next );
3061 num = __kmp_str_to_int( buf, *next );
3062 KMP_ASSERT( num >= 0 );
3071 if ( __kmp_match_str(
"disabled", buf, &next ) ) {
3074 # if KMP_OS_LINUX || KMP_OS_WINDOWS
3075 __kmp_affinity_type = affinity_disabled;
3077 __kmp_nested_proc_bind.used = 1;
3078 __kmp_nested_proc_bind.bind_types[0] = proc_bind_disabled;
3080 else if ( ( num == (
int)proc_bind_false )
3081 || __kmp_match_str(
"false", buf, &next ) ) {
3084 # if KMP_OS_LINUX || KMP_OS_WINDOWS
3085 __kmp_affinity_type = affinity_none;
3087 __kmp_nested_proc_bind.used = 1;
3088 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
3090 else if ( ( num == (
int)proc_bind_true )
3091 || __kmp_match_str(
"true", buf, &next ) ) {
3094 __kmp_nested_proc_bind.used = 1;
3099 __kmp_nested_proc_bind.bind_types[0] = proc_bind_spread;
3107 for ( scan = buf; *scan !=
'\0'; scan++ ) {
3108 if ( *scan ==
',' ) {
3116 if ( __kmp_nested_proc_bind.size < nelem ) {
3117 __kmp_nested_proc_bind.bind_types = (kmp_proc_bind_t *)
3118 KMP_INTERNAL_REALLOC( __kmp_nested_proc_bind.bind_types,
3119 sizeof(kmp_proc_bind_t) * nelem );
3120 if ( __kmp_nested_proc_bind.bind_types == NULL ) {
3121 KMP_FATAL( MemoryAllocFailed );
3123 __kmp_nested_proc_bind.size = nelem;
3125 __kmp_nested_proc_bind.used = nelem;
3132 enum kmp_proc_bind_t bind;
3134 if ( ( num == (
int)proc_bind_master )
3135 || __kmp_match_str(
"master", buf, &next ) ) {
3138 bind = proc_bind_master;
3140 else if ( ( num == (
int)proc_bind_close )
3141 || __kmp_match_str(
"close", buf, &next ) ) {
3144 bind = proc_bind_close;
3146 else if ( ( num == (
int)proc_bind_spread )
3147 || __kmp_match_str(
"spread", buf, &next ) ) {
3150 bind = proc_bind_spread;
3153 KMP_WARNING( StgInvalidValue, name, value );
3154 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
3155 __kmp_nested_proc_bind.used = 1;
3159 __kmp_nested_proc_bind.bind_types[i++] = bind;
3163 KMP_DEBUG_ASSERT( *buf ==
',' );
3170 if ( (*buf >=
'0') && (*buf <=
'9') ) {
3172 SKIP_DIGITS( next );
3173 num = __kmp_str_to_int( buf, *next );
3174 KMP_ASSERT( num >= 0 );
3184 if ( *buf !=
'\0' ) {
3185 KMP_WARNING( ParseExtraCharsWarn, name, buf );
3191 __kmp_stg_print_proc_bind( kmp_str_buf_t * buffer,
char const * name,
3194 int nelem = __kmp_nested_proc_bind.used;
3196 __kmp_str_buf_print( buffer,
" %s: %s \n", name, KMP_I18N_STR( NotDefined ) );
3200 __kmp_str_buf_print( buffer,
" %s=\"", name );
3201 for ( i = 0; i < nelem; i++ ) {
3202 switch ( __kmp_nested_proc_bind.bind_types[i] ) {
3203 case proc_bind_false:
3204 __kmp_str_buf_print( buffer,
"false" );
3207 case proc_bind_true:
3208 __kmp_str_buf_print( buffer,
"true" );
3211 case proc_bind_master:
3212 __kmp_str_buf_print( buffer,
"master" );
3215 case proc_bind_close:
3216 __kmp_str_buf_print( buffer,
"close" );
3219 case proc_bind_spread:
3220 __kmp_str_buf_print( buffer,
"spread" );
3223 case proc_bind_disabled:
3224 __kmp_str_buf_print( buffer,
"disabled" );
3227 case proc_bind_intel:
3228 __kmp_str_buf_print( buffer,
"intel" );
3231 case proc_bind_default:
3232 __kmp_str_buf_print( buffer,
"default" );
3235 if ( i < nelem - 1 ) {
3236 __kmp_str_buf_print( buffer,
"," );
3239 __kmp_str_buf_print( buffer,
"\"\n" );
3251 __kmp_stg_parse_omp_dynamic(
char const * name,
char const * value,
void * data )
3253 __kmp_stg_parse_bool( name, value, & (__kmp_global.g.g_dynamic) );
3257 __kmp_stg_print_omp_dynamic( kmp_str_buf_t * buffer,
char const * name,
void * data )
3259 __kmp_stg_print_bool( buffer, name, __kmp_global.g.g_dynamic );
3263 __kmp_stg_parse_kmp_dynamic_mode(
char const * name,
char const * value,
void * data )
3265 if ( TCR_4(__kmp_init_parallel) ) {
3266 KMP_WARNING( EnvParallelWarn, name );
3267 __kmp_env_toPrint( name, 0 );
3270 #ifdef USE_LOAD_BALANCE
3271 else if ( __kmp_str_match(
"load balance", 2, value )
3272 || __kmp_str_match(
"load_balance", 2, value )
3273 || __kmp_str_match(
"load-balance", 2, value )
3274 || __kmp_str_match(
"loadbalance", 2, value )
3275 || __kmp_str_match(
"balance", 1, value ) ) {
3276 __kmp_global.g.g_dynamic_mode = dynamic_load_balance;
3279 else if ( __kmp_str_match(
"thread limit", 1, value )
3280 || __kmp_str_match(
"thread_limit", 1, value )
3281 || __kmp_str_match(
"thread-limit", 1, value )
3282 || __kmp_str_match(
"threadlimit", 1, value )
3283 || __kmp_str_match(
"limit", 2, value ) ) {
3284 __kmp_global.g.g_dynamic_mode = dynamic_thread_limit;
3286 else if ( __kmp_str_match(
"random", 1, value ) ) {
3287 __kmp_global.g.g_dynamic_mode = dynamic_random;
3290 KMP_WARNING( StgInvalidValue, name, value );
3295 __kmp_stg_print_kmp_dynamic_mode( kmp_str_buf_t * buffer,
char const * name,
void * data )
3298 if ( __kmp_global.g.g_dynamic_mode == dynamic_default ) {
3299 __kmp_str_buf_print( buffer,
" %s: %s \n", name, KMP_I18N_STR( NotDefined ) );
3301 # ifdef USE_LOAD_BALANCE
3302 else if ( __kmp_global.g.g_dynamic_mode == dynamic_load_balance ) {
3303 __kmp_stg_print_str( buffer, name,
"load balance" );
3306 else if ( __kmp_global.g.g_dynamic_mode == dynamic_thread_limit ) {
3307 __kmp_stg_print_str( buffer, name,
"thread limit" );
3309 else if ( __kmp_global.g.g_dynamic_mode == dynamic_random ) {
3310 __kmp_stg_print_str( buffer, name,
"random" );
3319 #ifdef USE_LOAD_BALANCE
3326 __kmp_stg_parse_ld_balance_interval(
char const * name,
char const * value,
void * data )
3328 double interval = __kmp_convert_to_double( value );
3329 if ( interval >= 0 ) {
3330 __kmp_load_balance_interval = interval;
3332 KMP_WARNING( StgInvalidValue, name, value );
3337 __kmp_stg_print_ld_balance_interval( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3339 __kmp_str_buf_print( buffer,
" %s=%8.6f\n", name, __kmp_load_balance_interval );
3352 __kmp_stg_parse_init_at_fork(
char const * name,
char const * value,
void * data ) {
3353 __kmp_stg_parse_bool( name, value, & __kmp_need_register_atfork );
3354 if ( __kmp_need_register_atfork ) {
3355 __kmp_need_register_atfork_specified = TRUE;
3360 __kmp_stg_print_init_at_fork( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3361 __kmp_stg_print_bool( buffer, name, __kmp_need_register_atfork_specified );
3369 __kmp_stg_parse_schedule(
char const * name,
char const * value,
void * data ) {
3371 if ( value != NULL ) {
3372 size_t length = strlen( value );
3373 if ( length > INT_MAX ) {
3374 KMP_WARNING( LongValue, name );
3377 if( value[ length - 1 ] ==
'"' || value[ length -1 ] ==
'\'' )
3378 KMP_WARNING( UnbalancedQuotes, name );
3382 semicolon = (
char *) strchr( value,
';' );
3383 if( *value && semicolon != value ) {
3384 char *comma = (
char *) strchr( value,
',' );
3391 if ( !__kmp_strcasecmp_with_sentinel(
"static", value, sentinel ) ) {
3392 if( !__kmp_strcasecmp_with_sentinel(
"greedy", comma,
';' ) ) {
3393 __kmp_static = kmp_sch_static_greedy;
3395 }
else if( !__kmp_strcasecmp_with_sentinel(
"balanced", comma,
';' ) ) {
3396 __kmp_static = kmp_sch_static_balanced;
3399 }
else if ( !__kmp_strcasecmp_with_sentinel(
"guided", value, sentinel ) ) {
3400 if ( !__kmp_strcasecmp_with_sentinel(
"iterative", comma,
';' ) ) {
3401 __kmp_guided = kmp_sch_guided_iterative_chunked;
3403 }
else if ( !__kmp_strcasecmp_with_sentinel(
"analytical", comma,
';' ) ) {
3405 __kmp_guided = kmp_sch_guided_analytical_chunked;
3409 KMP_WARNING( InvalidClause, name, value );
3411 KMP_WARNING( EmptyClause, name );
3412 }
while ( value = semicolon ? semicolon + 1 : NULL );
3419 __kmp_stg_print_schedule( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3420 if ( __kmp_static == kmp_sch_static_greedy ) {
3421 __kmp_str_buf_print( buffer,
" %s=\"%s", name,
"static,greedy");
3422 }
else if ( __kmp_static == kmp_sch_static_balanced ) {
3423 __kmp_str_buf_print ( buffer,
" %s=\"%s", name,
"static,balanced");
3425 if ( __kmp_guided == kmp_sch_guided_iterative_chunked ) {
3426 __kmp_str_buf_print( buffer,
";%s\"\n",
"guided,iterative");
3427 }
else if ( __kmp_guided == kmp_sch_guided_analytical_chunked ) {
3428 __kmp_str_buf_print( buffer,
";%s\"\n",
"guided,analytical");
3437 __kmp_stg_parse_omp_schedule(
char const * name,
char const * value,
void * data )
3441 length = strlen( value );
3443 char *comma = (
char *) strchr( value,
',' );
3444 if( value[ length - 1 ] ==
'"' || value[ length -1 ] ==
'\'')
3445 KMP_WARNING( UnbalancedQuotes, name );
3447 if (!__kmp_strcasecmp_with_sentinel(
"dynamic", value,
','))
3448 __kmp_sched = kmp_sch_dynamic_chunked;
3449 else if (!__kmp_strcasecmp_with_sentinel(
"guided", value,
','))
3453 else if (!__kmp_strcasecmp_with_sentinel(
"auto", value,
',')) {
3456 __kmp_msg( kmp_ms_warning, KMP_MSG( IgnoreChunk, name, comma ), __kmp_msg_null );
3460 #endif // OMP_30_ENABLED
3461 else if (!__kmp_strcasecmp_with_sentinel(
"trapezoidal", value,
','))
3462 __kmp_sched = kmp_sch_trapezoidal;
3463 else if (!__kmp_strcasecmp_with_sentinel(
"static", value,
','))
3465 #ifdef KMP_STATIC_STEAL_ENABLED
3466 else if (KMP_ARCH_X86_64 &&
3467 !__kmp_strcasecmp_with_sentinel(
"static_steal", value,
','))
3471 KMP_WARNING( StgInvalidValue, name, value );
3474 if( value && comma ) {
3475 __kmp_env_chunk = TRUE;
3478 __kmp_sched = kmp_sch_static_chunked;
3480 __kmp_chunk = __kmp_str_to_int( comma, 0 );
3481 if ( __kmp_chunk < 1 ) {
3482 __kmp_chunk = KMP_DEFAULT_CHUNK;
3483 __kmp_msg( kmp_ms_warning, KMP_MSG( InvalidChunk, name, comma ), __kmp_msg_null );
3484 KMP_INFORM( Using_int_Value, name, __kmp_chunk );
3490 }
else if ( __kmp_chunk > KMP_MAX_CHUNK ) {
3491 __kmp_chunk = KMP_MAX_CHUNK;
3492 __kmp_msg( kmp_ms_warning, KMP_MSG( LargeChunk, name, comma ), __kmp_msg_null );
3493 KMP_INFORM( Using_int_Value, name, __kmp_chunk );
3496 __kmp_env_chunk = FALSE;
3498 KMP_WARNING( EmptyString, name );
3500 K_DIAG(1, (
"__kmp_static == %d\n", __kmp_static))
3501 K_DIAG(1, ("__kmp_guided == %d\n", __kmp_guided))
3502 K_DIAG(1, ("__kmp_sched == %d\n", __kmp_sched))
3503 K_DIAG(1, ("__kmp_chunk == %d\n", __kmp_chunk))
3507 __kmp_stg_print_omp_schedule( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3508 if ( __kmp_chunk ) {
3509 switch ( __kmp_sched ) {
3510 case kmp_sch_dynamic_chunked:
3511 __kmp_str_buf_print( buffer,
" %s=\"%s, %d\"\n", name,
"dynamic", __kmp_chunk);
3513 case kmp_sch_guided_iterative_chunked:
3514 case kmp_sch_guided_analytical_chunked:
3515 __kmp_str_buf_print( buffer,
" %s=\"%s, %d\"\n", name,
"guided", __kmp_chunk);
3517 case kmp_sch_trapezoidal:
3518 __kmp_str_buf_print( buffer,
" %s=\"%s, %d\"\n", name,
"trapezoidal", __kmp_chunk);
3520 case kmp_sch_static_chunked:
3521 case kmp_sch_static_balanced:
3522 case kmp_sch_static_greedy:
3523 __kmp_str_buf_print( buffer,
" %s=\"%s, %d\"\n", name,
"static", __kmp_chunk);
3526 __kmp_str_buf_print( buffer,
" %s=\"%s, %d\"\n", name,
"static_steal", __kmp_chunk);
3530 switch ( __kmp_sched ) {
3531 case kmp_sch_dynamic_chunked:
3532 __kmp_stg_print_str( buffer, name,
"dynamic");
3534 case kmp_sch_guided_iterative_chunked:
3535 case kmp_sch_guided_analytical_chunked:
3536 __kmp_stg_print_str( buffer, name,
"guided");
3538 case kmp_sch_trapezoidal:
3539 __kmp_stg_print_str( buffer, name,
"trapezoidal");
3541 case kmp_sch_static_chunked:
3542 case kmp_sch_static_balanced:
3543 case kmp_sch_static_greedy:
3544 __kmp_stg_print_str( buffer, name,
"static");
3547 __kmp_stg_print_str( buffer, name,
"static_steal");
3558 __kmp_stg_parse_atomic_mode(
char const * name,
char const * value,
void * data ) {
3562 #ifdef KMP_GOMP_COMPAT
3565 __kmp_stg_parse_int( name, value, 0, max, & mode );
3569 __kmp_atomic_mode = mode;
3574 __kmp_stg_print_atomic_mode( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3575 __kmp_stg_print_int( buffer, name, __kmp_atomic_mode );
3584 __kmp_stg_parse_consistency_check(
char const * name,
char const * value,
void * data ) {
3585 if ( ! __kmp_strcasecmp_with_sentinel(
"all", value, 0 ) ) {
3589 __kmp_env_consistency_check = TRUE;
3590 }
else if ( ! __kmp_strcasecmp_with_sentinel(
"none", value, 0 ) ) {
3591 __kmp_env_consistency_check = FALSE;
3593 KMP_WARNING( StgInvalidValue, name, value );
3598 __kmp_stg_print_consistency_check( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3600 const char *value = NULL;
3602 if ( __kmp_env_consistency_check ) {
3608 if ( value != NULL ) {
3609 __kmp_stg_print_str( buffer, name, value );
3623 __kmp_stg_parse_itt_prepare_delay(
char const * name,
char const * value,
void * data )
3627 __kmp_stg_parse_int( name, value, 0, INT_MAX, & delay );
3628 __kmp_itt_prepare_delay = delay;
3632 __kmp_stg_print_itt_prepare_delay( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3633 __kmp_stg_print_uint64( buffer, name, __kmp_itt_prepare_delay );
3637 #endif // USE_ITT_NOTIFY
3645 __kmp_stg_parse_malloc_pool_incr(
char const * name,
char const * value,
void * data ) {
3646 __kmp_stg_parse_size(
3649 KMP_MIN_MALLOC_POOL_INCR,
3650 KMP_MAX_MALLOC_POOL_INCR,
3652 & __kmp_malloc_pool_incr,
3658 __kmp_stg_print_malloc_pool_incr( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3659 __kmp_stg_print_size( buffer, name, __kmp_malloc_pool_incr );
3671 __kmp_stg_parse_par_range_env(
char const * name,
char const * value,
void * data ) {
3672 __kmp_stg_parse_par_range(
3676 __kmp_par_range_routine,
3677 __kmp_par_range_filename,
3678 & __kmp_par_range_lb,
3679 & __kmp_par_range_ub
3684 __kmp_stg_print_par_range_env( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3685 if (__kmp_par_range != 0) {
3686 __kmp_stg_print_str( buffer, name, par_range_to_print );
3695 __kmp_stg_parse_yield_cycle(
char const * name,
char const * value,
void * data ) {
3696 int flag = __kmp_yield_cycle;
3697 __kmp_stg_parse_bool( name, value, & flag );
3698 __kmp_yield_cycle = flag;
3702 __kmp_stg_print_yield_cycle( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3703 __kmp_stg_print_bool( buffer, name, __kmp_yield_cycle );
3707 __kmp_stg_parse_yield_on(
char const * name,
char const * value,
void * data ) {
3708 __kmp_stg_parse_int( name, value, 2, INT_MAX, & __kmp_yield_on_count );
3712 __kmp_stg_print_yield_on( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3713 __kmp_stg_print_int( buffer, name, __kmp_yield_on_count );
3717 __kmp_stg_parse_yield_off(
char const * name,
char const * value,
void * data ) {
3718 __kmp_stg_parse_int( name, value, 2, INT_MAX, & __kmp_yield_off_count );
3722 __kmp_stg_print_yield_off( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3723 __kmp_stg_print_int( buffer, name, __kmp_yield_off_count );
3733 __kmp_stg_parse_init_wait(
char const * name,
char const * value,
void * data ) {
3735 KMP_ASSERT( ( __kmp_init_wait & 1 ) == 0 );
3736 wait = __kmp_init_wait / 2;
3737 __kmp_stg_parse_int( name, value, KMP_MIN_INIT_WAIT, KMP_MAX_INIT_WAIT, & wait );
3738 __kmp_init_wait = wait * 2;
3739 KMP_ASSERT( ( __kmp_init_wait & 1 ) == 0 );
3740 __kmp_yield_init = __kmp_init_wait;
3744 __kmp_stg_print_init_wait( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3745 __kmp_stg_print_int( buffer, name, __kmp_init_wait );
3749 __kmp_stg_parse_next_wait(
char const * name,
char const * value,
void * data ) {
3751 KMP_ASSERT( ( __kmp_next_wait & 1 ) == 0 );
3752 wait = __kmp_next_wait / 2;
3753 __kmp_stg_parse_int( name, value, KMP_MIN_NEXT_WAIT, KMP_MAX_NEXT_WAIT, & wait );
3754 __kmp_next_wait = wait * 2;
3755 KMP_ASSERT( ( __kmp_next_wait & 1 ) == 0 );
3756 __kmp_yield_next = __kmp_next_wait;
3760 __kmp_stg_print_next_wait( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3761 __kmp_stg_print_int( buffer, name, __kmp_next_wait );
3770 __kmp_stg_parse_gtid_mode(
char const * name,
char const * value,
void * data ) {
3781 #ifdef KMP_TDATA_GTID
3784 __kmp_stg_parse_int( name, value, 0, max, & mode );
3788 __kmp_adjust_gtid_mode = TRUE;
3791 __kmp_gtid_mode = mode;
3792 __kmp_adjust_gtid_mode = FALSE;
3797 __kmp_stg_print_gtid_mode( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3798 if ( __kmp_adjust_gtid_mode ) {
3799 __kmp_stg_print_int( buffer, name, 0 );
3802 __kmp_stg_print_int( buffer, name, __kmp_gtid_mode );
3812 __kmp_stg_parse_lock_block(
char const * name,
char const * value,
void * data ) {
3813 __kmp_stg_parse_int( name, value, 0, KMP_INT_MAX, & __kmp_num_locks_in_block );
3817 __kmp_stg_print_lock_block( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3818 __kmp_stg_print_int( buffer, name, __kmp_num_locks_in_block );
3826 __kmp_stg_parse_lock_kind(
char const * name,
char const * value,
void * data ) {
3827 if ( __kmp_init_user_locks ) {
3828 KMP_WARNING( EnvLockWarn, name );
3832 if ( __kmp_str_match(
"tas", 2, value )
3833 || __kmp_str_match(
"test and set", 2, value )
3834 || __kmp_str_match(
"test_and_set", 2, value )
3835 || __kmp_str_match(
"test-and-set", 2, value )
3836 || __kmp_str_match(
"test andset", 2, value )
3837 || __kmp_str_match(
"test_andset", 2, value )
3838 || __kmp_str_match(
"test-andset", 2, value )
3839 || __kmp_str_match(
"testand set", 2, value )
3840 || __kmp_str_match(
"testand_set", 2, value )
3841 || __kmp_str_match(
"testand-set", 2, value )
3842 || __kmp_str_match(
"testandset", 2, value ) ) {
3843 __kmp_user_lock_kind = lk_tas;
3845 #if KMP_OS_LINUX && (KMP_ARCH_X86 || KMP_ARCH_X86_64)
3846 else if ( __kmp_str_match(
"futex", 1, value ) ) {
3847 if ( __kmp_futex_determine_capable() ) {
3848 __kmp_user_lock_kind = lk_futex;
3851 KMP_WARNING( FutexNotSupported, name, value );
3855 else if ( __kmp_str_match(
"ticket", 2, value ) ) {
3856 __kmp_user_lock_kind = lk_ticket;
3858 else if ( __kmp_str_match(
"queuing", 1, value )
3859 || __kmp_str_match(
"queue", 1, value ) ) {
3860 __kmp_user_lock_kind = lk_queuing;
3862 else if ( __kmp_str_match(
"drdpa ticket", 1, value )
3863 || __kmp_str_match(
"drdpa_ticket", 1, value )
3864 || __kmp_str_match(
"drdpa-ticket", 1, value )
3865 || __kmp_str_match(
"drdpaticket", 1, value )
3866 || __kmp_str_match(
"drdpa", 1, value ) ) {
3867 __kmp_user_lock_kind = lk_drdpa;
3869 #if KMP_USE_ADAPTIVE_LOCKS
3870 else if ( __kmp_str_match(
"adaptive", 1, value ) ) {
3871 if( __kmp_cpuinfo.rtm ) {
3872 __kmp_user_lock_kind = lk_adaptive;
3874 KMP_WARNING( AdaptiveNotSupported, name, value );
3875 __kmp_user_lock_kind = lk_queuing;
3878 #endif // KMP_USE_ADAPTIVE_LOCKS
3880 KMP_WARNING( StgInvalidValue, name, value );
3885 __kmp_stg_print_lock_kind( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3886 const char *value = NULL;
3888 switch ( __kmp_user_lock_kind ) {
3897 #if KMP_OS_LINUX && (KMP_ARCH_X86 || KMP_ARCH_X86_64)
3914 #if KMP_USE_ADAPTIVE_LOCKS
3921 if ( value != NULL ) {
3922 __kmp_stg_print_str( buffer, name, value );
3926 #if KMP_USE_ADAPTIVE_LOCKS
3935 __kmp_stg_parse_adaptive_lock_props(
const char *name,
const char *value,
void *data )
3937 int max_retries = 0;
3938 int max_badness = 0;
3940 const char *next = value;
3941 const char *scan = next;
3944 int prev_comma = FALSE;
3949 for ( i = 0; i < 3 ; i++) {
3952 if ( *next ==
'\0' ) {
3956 if ( ( ( *next <
'0' ) || ( *next >
'9' ) ) && ( *next !=
',') || ( total > 2 ) ) {
3957 KMP_WARNING( EnvSyntaxError, name, value );
3961 if ( *next ==
',' ) {
3963 if ( total == 0 || prev_comma ) {
3971 if ( *next >=
'0' && *next <=
'9' ) {
3973 const char *buf = next;
3974 char const * msg = NULL;
3976 SKIP_DIGITS( next );
3979 const char *tmp = next;
3981 if ( ( *next ==
' ' || *next ==
'\t' ) && ( *tmp >=
'0' && *tmp <=
'9' ) ) {
3982 KMP_WARNING( EnvSpacesNotAllowed, name, value );
3986 num = __kmp_str_to_int( buf, *next );
3988 msg = KMP_I18N_STR( ValueTooSmall );
3990 }
else if ( num > KMP_INT_MAX ) {
3991 msg = KMP_I18N_STR( ValueTooLarge );
3994 if ( msg != NULL ) {
3996 KMP_WARNING( ParseSizeIntWarn, name, value, msg );
3997 KMP_INFORM( Using_int_Value, name, num );
4001 }
else if( total == 2 ) {
4006 KMP_DEBUG_ASSERT( total > 0 );
4008 KMP_WARNING( EnvSyntaxError, name, value );
4011 if( max_retries != 0 ) {
4012 __kmp_adaptive_backoff_params.max_soft_retries = max_retries;
4014 if( max_badness != 0 ) {
4015 __kmp_adaptive_backoff_params.max_badness = max_badness;
4021 __kmp_stg_print_adaptive_lock_props(kmp_str_buf_t * buffer,
char const * name,
void * data )
4023 __kmp_str_buf_print( buffer,
" %s=%d,%d\n", name, __kmp_adaptive_backoff_params.max_soft_retries,
4024 __kmp_adaptive_backoff_params.max_badness );
4027 #if KMP_DEBUG_ADAPTIVE_LOCKS
4030 __kmp_stg_parse_speculative_statsfile(
char const * name,
char const * value,
void * data ) {
4031 __kmp_stg_parse_file( name, value,
"", & __kmp_speculative_statsfile );
4035 __kmp_stg_print_speculative_statsfile( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
4036 if ( __kmp_str_match(
"-", 0, __kmp_speculative_statsfile ) ) {
4037 __kmp_stg_print_str( buffer, name,
"stdout" );
4039 __kmp_stg_print_str( buffer, name, __kmp_speculative_statsfile );
4044 #endif // KMP_DEBUG_ADAPTIVE_LOCKS
4046 #endif // KMP_USE_ADAPTIVE_LOCKS
4054 __kmp_stg_parse_place_threads(
char const * name,
char const * value,
void * data ) {
4060 const char *next = value;
4064 if ( *next ==
'\0' ) {
4069 if ( *next >=
'0' && *next <=
'9' ) {
4071 SKIP_DIGITS( next );
4072 num = __kmp_str_to_int( prev, *next );
4074 if ( *next ==
'C' || *next ==
'c' ) {
4075 __kmp_place_num_cores = num;
4077 }
else if ( *next ==
',' || *next ==
'x' ) {
4078 __kmp_place_num_cores = num;
4081 }
else if ( *next ==
'T' || *next ==
't' ) {
4082 __kmp_place_num_threads_per_core = num;
4084 }
else if ( *next ==
'\0' ) {
4085 __kmp_place_num_cores = num;
4088 KMP_WARNING( AffThrPlaceInvalid, name, value );
4091 }
else if ( *next ==
',' || *next ==
'x' ) {
4096 KMP_WARNING( AffThrPlaceInvalid, name, value );
4100 if ( *next ==
'\0' ) {
4103 if ( ( *next ==
',' || *next ==
'x' ) && !prev_delim ) {
4110 if ( *next >=
'0' && *next <=
'9' ) {
4113 SKIP_DIGITS( next );
4114 num = __kmp_str_to_int( prev, *next );
4116 if ( *next ==
'T' || *next ==
't' ) {
4117 __kmp_place_num_threads_per_core = num;
4119 }
else if ( *next ==
',' || *next ==
'x' ) {
4120 __kmp_place_num_threads_per_core = num;
4123 }
else if ( *next ==
'O' || *next ==
'o' ) {
4124 __kmp_place_core_offset = num;
4126 }
else if ( *next ==
'\0' ) {
4127 __kmp_place_num_threads_per_core = num;
4130 KMP_WARNING( AffThrPlaceInvalid, name, value );
4133 }
else if ( *next ==
',' || *next ==
'x' ) {
4134 if ( prev_delim == 2 ) {
4137 KMP_DEBUG_ASSERT( prev_delim == 1 );
4140 KMP_WARNING( AffThrPlaceInvalid, name, value );
4144 if ( *next ==
'\0' ) {
4147 if ( ( *next ==
',' || *next ==
'x' ) && !prev_delim ) {
4155 if ( *next >=
'0' && *next <=
'9' ) {
4157 SKIP_DIGITS( next );
4158 num = __kmp_str_to_int( prev, *next );
4159 __kmp_place_core_offset = num;
4164 __kmp_stg_print_place_threads( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
4165 if ( __kmp_place_num_cores + __kmp_place_num_threads_per_core ) {
4167 __kmp_str_buf_init( &buf );
4168 __kmp_str_buf_print( &buf,
"%dC", __kmp_place_num_cores );
4169 __kmp_str_buf_print( &buf,
"x%dT", __kmp_place_num_threads_per_core );
4170 if ( __kmp_place_core_offset ) {
4171 __kmp_str_buf_print( &buf,
",%dO", __kmp_place_core_offset );
4173 __kmp_stg_print_str(buffer, name, buf.str );
4174 __kmp_str_buf_free(&buf);
4188 __kmp_stg_parse_forkjoin_frames(
char const * name,
char const * value,
void * data ) {
4189 __kmp_stg_parse_bool( name, value, & __kmp_forkjoin_frames );
4193 __kmp_stg_print_forkjoin_frames( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
4194 __kmp_stg_print_bool( buffer, name, __kmp_forkjoin_frames );
4202 static kmp_setting_t __kmp_stg_table[] = {
4204 {
"KMP_ALL_THREADS", __kmp_stg_parse_all_threads, __kmp_stg_print_all_threads, NULL, 0, 0 },
4205 {
"KMP_BLOCKTIME", __kmp_stg_parse_blocktime, __kmp_stg_print_blocktime, NULL, 0, 0 },
4206 {
"KMP_DUPLICATE_LIB_OK", __kmp_stg_parse_duplicate_lib_ok, __kmp_stg_print_duplicate_lib_ok, NULL, 0, 0 },
4207 {
"KMP_LIBRARY", __kmp_stg_parse_wait_policy, __kmp_stg_print_wait_policy, NULL, 0, 0 },
4208 {
"KMP_MAX_THREADS", __kmp_stg_parse_all_threads, NULL, NULL, 0, 0 },
4209 {
"KMP_MONITOR_STACKSIZE", __kmp_stg_parse_monitor_stacksize, __kmp_stg_print_monitor_stacksize, NULL, 0, 0 },
4210 {
"KMP_SETTINGS", __kmp_stg_parse_settings, __kmp_stg_print_settings, NULL, 0, 0 },
4211 {
"KMP_STACKOFFSET", __kmp_stg_parse_stackoffset, __kmp_stg_print_stackoffset, NULL, 0, 0 },
4212 {
"KMP_STACKSIZE", __kmp_stg_parse_stacksize, __kmp_stg_print_stacksize, NULL, 0, 0 },
4213 {
"KMP_VERSION", __kmp_stg_parse_version, __kmp_stg_print_version, NULL, 0, 0 },
4214 {
"KMP_WARNINGS", __kmp_stg_parse_warnings, __kmp_stg_print_warnings, NULL, 0, 0 },
4216 {
"OMP_NESTED", __kmp_stg_parse_nested, __kmp_stg_print_nested, NULL, 0, 0 },
4217 {
"OMP_NUM_THREADS", __kmp_stg_parse_num_threads, __kmp_stg_print_num_threads, NULL, 0, 0 },
4218 {
"OMP_STACKSIZE", __kmp_stg_parse_stacksize, NULL, NULL, 0, 0 },
4221 {
"KMP_TASKING", __kmp_stg_parse_tasking, __kmp_stg_print_tasking, NULL, 0, 0 },
4222 {
"KMP_TASK_STEALING_CONSTRAINT", __kmp_stg_parse_task_stealing, __kmp_stg_print_task_stealing, NULL, 0, 0 },
4223 {
"OMP_MAX_ACTIVE_LEVELS", __kmp_stg_parse_max_active_levels, __kmp_stg_print_max_active_levels, NULL, 0, 0 },
4224 {
"OMP_THREAD_LIMIT", __kmp_stg_parse_all_threads, NULL, NULL, 0, 0 },
4225 {
"OMP_WAIT_POLICY", __kmp_stg_parse_wait_policy, __kmp_stg_print_wait_policy, NULL, 0, 0 },
4226 #endif // OMP_30_ENABLED
4228 #if KMP_HANDLE_SIGNALS
4229 {
"KMP_HANDLE_SIGNALS", __kmp_stg_parse_handle_signals, __kmp_stg_print_handle_signals, NULL, 0, 0 },
4232 #if KMP_ARCH_X86 || KMP_ARCH_X86_64
4233 {
"KMP_INHERIT_FP_CONTROL", __kmp_stg_parse_inherit_fp_control, __kmp_stg_print_inherit_fp_control, NULL, 0, 0 },
4236 #ifdef KMP_GOMP_COMPAT
4237 {
"GOMP_STACKSIZE", __kmp_stg_parse_stacksize, NULL, NULL, 0, 0 },
4241 {
"KMP_A_DEBUG", __kmp_stg_parse_a_debug, __kmp_stg_print_a_debug, NULL, 0, 0 },
4242 {
"KMP_B_DEBUG", __kmp_stg_parse_b_debug, __kmp_stg_print_b_debug, NULL, 0, 0 },
4243 {
"KMP_C_DEBUG", __kmp_stg_parse_c_debug, __kmp_stg_print_c_debug, NULL, 0, 0 },
4244 {
"KMP_D_DEBUG", __kmp_stg_parse_d_debug, __kmp_stg_print_d_debug, NULL, 0, 0 },
4245 {
"KMP_E_DEBUG", __kmp_stg_parse_e_debug, __kmp_stg_print_e_debug, NULL, 0, 0 },
4246 {
"KMP_F_DEBUG", __kmp_stg_parse_f_debug, __kmp_stg_print_f_debug, NULL, 0, 0 },
4247 {
"KMP_DEBUG", __kmp_stg_parse_debug, NULL, NULL, 0, 0 },
4248 {
"KMP_DEBUG_BUF", __kmp_stg_parse_debug_buf, __kmp_stg_print_debug_buf, NULL, 0, 0 },
4249 {
"KMP_DEBUG_BUF_ATOMIC", __kmp_stg_parse_debug_buf_atomic, __kmp_stg_print_debug_buf_atomic, NULL, 0, 0 },
4250 {
"KMP_DEBUG_BUF_CHARS", __kmp_stg_parse_debug_buf_chars, __kmp_stg_print_debug_buf_chars, NULL, 0, 0 },
4251 {
"KMP_DEBUG_BUF_LINES", __kmp_stg_parse_debug_buf_lines, __kmp_stg_print_debug_buf_lines, NULL, 0, 0 },
4252 {
"KMP_DIAG", __kmp_stg_parse_diag, __kmp_stg_print_diag, NULL, 0, 0 },
4254 {
"KMP_PAR_RANGE", __kmp_stg_parse_par_range_env, __kmp_stg_print_par_range_env, NULL, 0, 0 },
4255 {
"KMP_YIELD_CYCLE", __kmp_stg_parse_yield_cycle, __kmp_stg_print_yield_cycle, NULL, 0, 0 },
4256 {
"KMP_YIELD_ON", __kmp_stg_parse_yield_on, __kmp_stg_print_yield_on, NULL, 0, 0 },
4257 {
"KMP_YIELD_OFF", __kmp_stg_parse_yield_off, __kmp_stg_print_yield_off, NULL, 0, 0 },
4260 {
"KMP_ALIGN_ALLOC", __kmp_stg_parse_align_alloc, __kmp_stg_print_align_alloc, NULL, 0, 0 },
4262 {
"KMP_PLAIN_BARRIER", __kmp_stg_parse_barrier_branch_bit, __kmp_stg_print_barrier_branch_bit, NULL, 0, 0 },
4263 {
"KMP_PLAIN_BARRIER_PATTERN", __kmp_stg_parse_barrier_pattern, __kmp_stg_print_barrier_pattern, NULL, 0, 0 },
4264 {
"KMP_FORKJOIN_BARRIER", __kmp_stg_parse_barrier_branch_bit, __kmp_stg_print_barrier_branch_bit, NULL, 0, 0 },
4265 {
"KMP_FORKJOIN_BARRIER_PATTERN", __kmp_stg_parse_barrier_pattern, __kmp_stg_print_barrier_pattern, NULL, 0, 0 },
4266 #if KMP_FAST_REDUCTION_BARRIER
4267 {
"KMP_REDUCTION_BARRIER", __kmp_stg_parse_barrier_branch_bit, __kmp_stg_print_barrier_branch_bit, NULL, 0, 0 },
4268 {
"KMP_REDUCTION_BARRIER_PATTERN", __kmp_stg_parse_barrier_pattern, __kmp_stg_print_barrier_pattern, NULL, 0, 0 },
4271 {
"KMP_ABORT_DELAY", __kmp_stg_parse_abort_delay, __kmp_stg_print_abort_delay, NULL, 0, 0 },
4272 {
"KMP_CPUINFO_FILE", __kmp_stg_parse_cpuinfo_file, __kmp_stg_print_cpuinfo_file, NULL, 0, 0 },
4273 {
"KMP_FORCE_REDUCTION", __kmp_stg_parse_force_reduction, __kmp_stg_print_force_reduction, NULL, 0, 0 },
4274 {
"KMP_DETERMINISTIC_REDUCTION", __kmp_stg_parse_force_reduction, __kmp_stg_print_force_reduction, NULL, 0, 0 },
4275 {
"KMP_STORAGE_MAP", __kmp_stg_parse_storage_map, __kmp_stg_print_storage_map, NULL, 0, 0 },
4276 {
"KMP_ALL_THREADPRIVATE", __kmp_stg_parse_all_threadprivate, __kmp_stg_print_all_threadprivate, NULL, 0, 0 },
4277 {
"KMP_FOREIGN_THREADS_THREADPRIVATE", __kmp_stg_parse_foreign_threads_threadprivate, __kmp_stg_print_foreign_threads_threadprivate, NULL, 0, 0 },
4279 #if KMP_OS_LINUX || KMP_OS_WINDOWS
4280 {
"KMP_AFFINITY", __kmp_stg_parse_affinity, __kmp_stg_print_affinity, NULL, 0, 0 },
4281 # ifdef KMP_GOMP_COMPAT
4282 {
"GOMP_CPU_AFFINITY", __kmp_stg_parse_gomp_cpu_affinity, NULL, NULL, 0, 0 },
4286 {
"OMP_PROC_BIND", __kmp_stg_parse_proc_bind, __kmp_stg_print_proc_bind, NULL, 0, 0 },
4287 {
"OMP_PLACES", __kmp_stg_parse_places, __kmp_stg_print_places, NULL, 0, 0 },
4289 {
"OMP_PROC_BIND", __kmp_stg_parse_proc_bind, NULL, NULL, 0, 0 },
4293 {
"KMP_TOPOLOGY_METHOD", __kmp_stg_parse_topology_method, __kmp_stg_print_topology_method, NULL, 0, 0 },
4302 {
"OMP_PROC_BIND", __kmp_stg_parse_proc_bind, __kmp_stg_print_proc_bind, NULL, 0, 0 },
4306 #error "Unknown or unsupported OS"
4307 #endif // KMP_OS_LINUX || KMP_OS_WINDOWS
4309 {
"KMP_INIT_AT_FORK", __kmp_stg_parse_init_at_fork, __kmp_stg_print_init_at_fork, NULL, 0, 0 },
4310 {
"KMP_SCHEDULE", __kmp_stg_parse_schedule, __kmp_stg_print_schedule, NULL, 0, 0 },
4311 {
"OMP_SCHEDULE", __kmp_stg_parse_omp_schedule, __kmp_stg_print_omp_schedule, NULL, 0, 0 },
4312 {
"KMP_ATOMIC_MODE", __kmp_stg_parse_atomic_mode, __kmp_stg_print_atomic_mode, NULL, 0, 0 },
4313 {
"KMP_CONSISTENCY_CHECK", __kmp_stg_parse_consistency_check, __kmp_stg_print_consistency_check, NULL, 0, 0 },
4315 #if USE_ITT_BUILD && USE_ITT_NOTIFY
4316 {
"KMP_ITT_PREPARE_DELAY", __kmp_stg_parse_itt_prepare_delay, __kmp_stg_print_itt_prepare_delay, NULL, 0, 0 },
4318 {
"KMP_MALLOC_POOL_INCR", __kmp_stg_parse_malloc_pool_incr, __kmp_stg_print_malloc_pool_incr, NULL, 0, 0 },
4319 {
"KMP_INIT_WAIT", __kmp_stg_parse_init_wait, __kmp_stg_print_init_wait, NULL, 0, 0 },
4320 {
"KMP_NEXT_WAIT", __kmp_stg_parse_next_wait, __kmp_stg_print_next_wait, NULL, 0, 0 },
4321 {
"KMP_GTID_MODE", __kmp_stg_parse_gtid_mode, __kmp_stg_print_gtid_mode, NULL, 0, 0 },
4322 {
"OMP_DYNAMIC", __kmp_stg_parse_omp_dynamic, __kmp_stg_print_omp_dynamic, NULL, 0, 0 },
4323 {
"KMP_DYNAMIC_MODE", __kmp_stg_parse_kmp_dynamic_mode, __kmp_stg_print_kmp_dynamic_mode, NULL, 0, 0 },
4325 #ifdef USE_LOAD_BALANCE
4326 {
"KMP_LOAD_BALANCE_INTERVAL", __kmp_stg_parse_ld_balance_interval,__kmp_stg_print_ld_balance_interval,NULL, 0, 0 },
4331 {
"KMP_NUM_LOCKS_IN_BLOCK", __kmp_stg_parse_lock_block, __kmp_stg_print_lock_block, NULL, 0, 0 },
4332 {
"KMP_LOCK_KIND", __kmp_stg_parse_lock_kind, __kmp_stg_print_lock_kind, NULL, 0, 0 },
4333 #if KMP_USE_ADAPTIVE_LOCKS
4334 {
"KMP_ADAPTIVE_LOCK_PROPS", __kmp_stg_parse_adaptive_lock_props,__kmp_stg_print_adaptive_lock_props, NULL, 0, 0 },
4335 #if KMP_DEBUG_ADAPTIVE_LOCKS
4336 {
"KMP_SPECULATIVE_STATSFILE", __kmp_stg_parse_speculative_statsfile,__kmp_stg_print_speculative_statsfile, NULL, 0, 0 },
4338 #endif // KMP_USE_ADAPTIVE_LOCKS
4340 {
"KMP_PLACE_THREADS", __kmp_stg_parse_place_threads, __kmp_stg_print_place_threads, NULL, 0, 0 },
4342 {
"KMP_FORKJOIN_FRAMES", __kmp_stg_parse_forkjoin_frames, __kmp_stg_print_forkjoin_frames, NULL, 0, 0 },
4344 {
"", NULL, NULL, NULL, 0, 0 }
4347 static int const __kmp_stg_count =
sizeof( __kmp_stg_table ) /
sizeof( kmp_setting_t );
4351 __kmp_stg_find(
char const * name ) {
4354 if ( name != NULL ) {
4355 for ( i = 0; i < __kmp_stg_count; ++ i ) {
4356 if ( strcmp( __kmp_stg_table[ i ].name, name ) == 0 ) {
4357 return & __kmp_stg_table[ i ];
4367 __kmp_stg_cmp(
void const * _a,
void const * _b ) {
4368 kmp_setting_t * a = (kmp_setting_t *) _a;
4369 kmp_setting_t * b = (kmp_setting_t *) _b;
4375 if ( strcmp( a->name,
"KMP_AFFINITY" ) == 0 ) {
4376 if ( strcmp( b->name,
"KMP_AFFINITY" ) == 0 ) {
4381 else if ( strcmp( b->name,
"KMP_AFFINITY" ) == 0 ) {
4384 return strcmp( a->name, b->name );
4389 __kmp_stg_init(
void
4392 static int initialized = 0;
4394 if ( ! initialized ) {
4397 qsort( __kmp_stg_table, __kmp_stg_count - 1,
sizeof( kmp_setting_t ), __kmp_stg_cmp );
4401 kmp_setting_t * kmp_stacksize = __kmp_stg_find(
"KMP_STACKSIZE" );
4402 #ifdef KMP_GOMP_COMPAT
4403 kmp_setting_t * gomp_stacksize = __kmp_stg_find(
"GOMP_STACKSIZE" );
4405 kmp_setting_t * omp_stacksize = __kmp_stg_find(
"OMP_STACKSIZE" );
4410 static kmp_setting_t *
volatile rivals[ 4 ];
4411 static kmp_stg_ss_data_t kmp_data = { 1, (kmp_setting_t **)rivals };
4412 #ifdef KMP_GOMP_COMPAT
4413 static kmp_stg_ss_data_t gomp_data = { 1024, (kmp_setting_t **)rivals };
4415 static kmp_stg_ss_data_t omp_data = { 1024, (kmp_setting_t **)rivals };
4418 rivals[ i ++ ] = kmp_stacksize;
4419 #ifdef KMP_GOMP_COMPAT
4420 if ( gomp_stacksize != NULL ) {
4421 rivals[ i ++ ] = gomp_stacksize;
4424 rivals[ i ++ ] = omp_stacksize;
4425 rivals[ i ++ ] = NULL;
4427 kmp_stacksize->data = & kmp_data;
4428 #ifdef KMP_GOMP_COMPAT
4429 if ( gomp_stacksize != NULL ) {
4430 gomp_stacksize->data = & gomp_data;
4433 omp_stacksize->data = & omp_data;
4440 kmp_setting_t * kmp_library = __kmp_stg_find(
"KMP_LIBRARY" );
4441 kmp_setting_t * omp_wait_policy = __kmp_stg_find(
"OMP_WAIT_POLICY" );
4444 static kmp_setting_t *
volatile rivals[ 3 ];
4445 static kmp_stg_wp_data_t kmp_data = { 0, (kmp_setting_t **)rivals };
4446 static kmp_stg_wp_data_t omp_data = { 1, (kmp_setting_t **)rivals };
4449 rivals[ i ++ ] = kmp_library;
4450 if ( omp_wait_policy != NULL ) {
4451 rivals[ i ++ ] = omp_wait_policy;
4453 rivals[ i ++ ] = NULL;
4455 kmp_library->data = & kmp_data;
4456 if ( omp_wait_policy != NULL ) {
4457 omp_wait_policy->data = & omp_data;
4465 kmp_setting_t * kmp_all_threads = __kmp_stg_find(
"KMP_ALL_THREADS" );
4466 kmp_setting_t * kmp_max_threads = __kmp_stg_find(
"KMP_MAX_THREADS" );
4468 kmp_setting_t * omp_thread_limit = __kmp_stg_find(
"OMP_THREAD_LIMIT" );
4472 static kmp_setting_t *
volatile rivals[ 4 ];
4475 rivals[ i ++ ] = kmp_all_threads;
4476 rivals[ i ++ ] = kmp_max_threads;
4478 if ( omp_thread_limit != NULL ) {
4479 rivals[ i ++ ] = omp_thread_limit;
4482 rivals[ i ++ ] = NULL;
4484 kmp_all_threads->data = (
void*)& rivals;
4485 kmp_max_threads->data = (
void*)& rivals;
4487 if ( omp_thread_limit != NULL ) {
4488 omp_thread_limit->data = (
void*)& rivals;
4494 #if KMP_OS_LINUX || KMP_OS_WINDOWS
4497 kmp_setting_t * kmp_affinity = __kmp_stg_find(
"KMP_AFFINITY" );
4498 KMP_DEBUG_ASSERT( kmp_affinity != NULL );
4500 # ifdef KMP_GOMP_COMPAT
4501 kmp_setting_t * gomp_cpu_affinity = __kmp_stg_find(
"GOMP_CPU_AFFINITY" );
4502 KMP_DEBUG_ASSERT( gomp_cpu_affinity != NULL );
4506 kmp_setting_t * omp_proc_bind = __kmp_stg_find(
"OMP_PROC_BIND" );
4507 KMP_DEBUG_ASSERT( omp_proc_bind != NULL );
4511 kmp_setting_t * omp_places = __kmp_stg_find(
"OMP_PLACES" );
4512 KMP_DEBUG_ASSERT( omp_places != NULL );
4516 static kmp_setting_t *
volatile rivals[ 5 ];
4519 rivals[ i ++ ] = kmp_affinity;
4521 # ifdef KMP_GOMP_COMPAT
4522 rivals[ i ++ ] = gomp_cpu_affinity;
4523 gomp_cpu_affinity->data = (
void*)& rivals;
4527 rivals[ i ++ ] = omp_proc_bind;
4528 omp_proc_bind->data = (
void*)& rivals;
4532 rivals[ i ++ ] = omp_places;
4533 omp_places->data = (
void*)& rivals;
4536 rivals[ i ++ ] = NULL;
4543 #error "Unknown or unsupported OS"
4548 kmp_setting_t * kmp_force_red = __kmp_stg_find(
"KMP_FORCE_REDUCTION" );
4549 kmp_setting_t * kmp_determ_red = __kmp_stg_find(
"KMP_DETERMINISTIC_REDUCTION" );
4552 static kmp_setting_t *
volatile rivals[ 3 ];
4553 static kmp_stg_fr_data_t force_data = { 1, (kmp_setting_t **)rivals };
4554 static kmp_stg_fr_data_t determ_data = { 0, (kmp_setting_t **)rivals };
4557 rivals[ i ++ ] = kmp_force_red;
4558 if ( kmp_determ_red != NULL ) {
4559 rivals[ i ++ ] = kmp_determ_red;
4561 rivals[ i ++ ] = NULL;
4563 kmp_force_red->data = & force_data;
4564 if ( kmp_determ_red != NULL ) {
4565 kmp_determ_red->data = & determ_data;
4575 for ( i = 0; i < __kmp_stg_count; ++ i ) {
4576 __kmp_stg_table[ i ].set = 0;
4590 if ( name[ 0 ] == 0 ) {
4594 if ( value != NULL ) {
4595 kmp_setting_t * setting = __kmp_stg_find( name );
4596 if ( setting != NULL ) {
4597 setting->parse( name, value, setting->data );
4598 setting->defined = 1;
4606 __kmp_stg_check_rivals(
4609 kmp_setting_t * * rivals
4612 if ( rivals == NULL ) {
4618 for ( ; strcmp( rivals[ i ]->name, name ) != 0; i++ ) {
4619 KMP_DEBUG_ASSERT( rivals[ i ] != NULL );
4621 #if KMP_OS_LINUX || KMP_OS_WINDOWS
4622 if ( rivals[ i ] == __kmp_affinity_notype ) {
4631 if ( rivals[ i ]->set ) {
4632 KMP_WARNING( StgIgnored, name, value, rivals[ i ]->name );
4645 __kmp_env_isDefined(
char const * name ) {
4647 kmp_setting_t * setting = __kmp_stg_find( name );
4648 if ( setting != NULL ) {
4655 __kmp_env_toPrint(
char const * name,
int flag ) {
4657 kmp_setting_t * setting = __kmp_stg_find( name );
4658 if ( setting != NULL ) {
4659 rc = setting->defined;
4661 setting->defined = flag;
4669 __kmp_aux_env_initialize( kmp_env_blk_t* block ) {
4674 value = __kmp_env_blk_var( block,
"OMP_NUM_THREADS" );
4676 ompc_set_num_threads( __kmp_dflt_team_nth );
4680 value = __kmp_env_blk_var( block,
"KMP_BLOCKTIME" );
4682 kmpc_set_blocktime( __kmp_dflt_blocktime );
4686 value = __kmp_env_blk_var( block,
"OMP_NESTED" );
4688 ompc_set_nested( __kmp_dflt_nested );
4692 value = __kmp_env_blk_var( block,
"OMP_DYNAMIC" );
4694 ompc_set_dynamic( __kmp_global.g.g_dynamic );
4700 __kmp_env_initialize(
char const *
string ) {
4702 kmp_env_blk_t block;
4708 if (
string == NULL ) {
4710 __kmp_threads_capacity = __kmp_initial_threads_capacity( __kmp_dflt_team_nth_ub );
4712 __kmp_env_blk_init( & block,
string );
4717 for ( i = 0; i < block.count; ++ i ) {
4718 if (( block.vars[ i ].name == NULL )
4719 || ( *block.vars[ i ].name ==
'\0')) {
4722 if ( block.vars[ i ].value == NULL ) {
4725 kmp_setting_t * setting = __kmp_stg_find( block.vars[ i ].name );
4726 if ( setting != NULL ) {
4732 if (
string == NULL ) {
4733 char const * name =
"KMP_WARNINGS";
4734 char const * value = __kmp_env_blk_var( & block, name );
4735 __kmp_stg_parse( name, value );
4738 #if KMP_OS_LINUX || KMP_OS_WINDOWS
4746 __kmp_affinity_notype = NULL;
4747 char const *aff_str = __kmp_env_blk_var( & block,
"KMP_AFFINITY" );
4748 if ( aff_str != NULL ) {
4762 # define FIND strstr
4764 # define FIND strcasestr
4767 if ( ( FIND( aff_str,
"none" ) == NULL )
4768 && ( FIND( aff_str,
"physical" ) == NULL )
4769 && ( FIND( aff_str,
"logical" ) == NULL )
4770 && ( FIND( aff_str,
"compact" ) == NULL )
4771 && ( FIND( aff_str,
"scatter" ) == NULL )
4772 && ( FIND( aff_str,
"explicit" ) == NULL )
4774 && ( FIND( aff_str,
"balanced" ) == NULL )
4776 && ( FIND( aff_str,
"disabled" ) == NULL ) ) {
4777 __kmp_affinity_notype = __kmp_stg_find(
"KMP_AFFINITY" );
4787 if ( __kmp_nested_proc_bind.bind_types == NULL ) {
4788 __kmp_nested_proc_bind.bind_types = (kmp_proc_bind_t *)
4789 KMP_INTERNAL_MALLOC(
sizeof(kmp_proc_bind_t) );
4790 if ( __kmp_nested_proc_bind.bind_types == NULL ) {
4791 KMP_FATAL( MemoryAllocFailed );
4793 __kmp_nested_proc_bind.size = 1;
4794 __kmp_nested_proc_bind.used = 1;
4795 __kmp_nested_proc_bind.bind_types[0] = proc_bind_default;
4802 for ( i = 0; i < block.count; ++ i ) {
4803 __kmp_stg_parse( block.vars[ i ].name, block.vars[ i ].value );
4809 if ( ! __kmp_init_user_locks ) {
4810 if ( __kmp_user_lock_kind == lk_default ) {
4811 __kmp_user_lock_kind = lk_queuing;
4813 __kmp_set_user_lock_vptrs( __kmp_user_lock_kind );
4816 KMP_DEBUG_ASSERT(
string != NULL);
4817 KMP_DEBUG_ASSERT( __kmp_user_lock_kind != lk_default );
4820 #if KMP_OS_LINUX || KMP_OS_WINDOWS
4821 if ( ! TCR_4(__kmp_init_middle) ) {
4826 const char *var =
"KMP_AFFINITY";
4827 if ( __kmp_affinity_type == affinity_disabled ) {
4828 __kmp_affin_mask_size = 0;
4830 else if ( ! KMP_AFFINITY_CAPABLE() ) {
4831 __kmp_affinity_determine_capable( var );
4832 if ( ! KMP_AFFINITY_CAPABLE() ) {
4833 if ( __kmp_affinity_verbose || ( __kmp_affinity_warnings
4834 && ( __kmp_affinity_type != affinity_default )
4835 && ( __kmp_affinity_type != affinity_none )
4836 && ( __kmp_affinity_type != affinity_disabled ) ) ) {
4837 KMP_WARNING( AffNotSupported, var );
4839 __kmp_affinity_type = affinity_disabled;
4840 __kmp_affinity_respect_mask = 0;
4841 __kmp_affinity_gran = affinity_gran_fine;
4847 if ( __kmp_affinity_type == affinity_disabled ) {
4848 __kmp_nested_proc_bind.bind_types[0] = proc_bind_disabled;
4850 else if ( __kmp_nested_proc_bind.bind_types[0] == proc_bind_default ) {
4855 # if KMP_OS_WINDOWS || KMP_OS_LINUX
4856 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
4858 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
4867 if ( __kmp_nested_proc_bind.bind_types[0] == proc_bind_intel ) {
4868 if ( ( __kmp_affinity_type == affinity_none )
4870 || ( __kmp_affinity_type == affinity_default )
4873 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
4876 else if ( ( __kmp_nested_proc_bind.bind_types[0] != proc_bind_false )
4877 && ( __kmp_nested_proc_bind.bind_types[0] != proc_bind_disabled ) ) {
4878 if ( __kmp_affinity_type == affinity_default ) {
4879 __kmp_affinity_type = affinity_compact;
4880 __kmp_affinity_dups = FALSE;
4882 if ( __kmp_affinity_gran == affinity_gran_default ) {
4883 __kmp_affinity_gran = affinity_gran_fine;
4886 # endif // OMP_40_ENABLED
4888 if ( KMP_AFFINITY_CAPABLE() ) {
4890 # if KMP_OS_WINDOWS && KMP_ARCH_X86_64
4892 if ( __kmp_num_proc_groups > 1 ) {
4893 if ( __kmp_affinity_respect_mask == affinity_respect_mask_default ) {
4894 __kmp_affinity_respect_mask = FALSE;
4897 if ( ( __kmp_affinity_type == affinity_default )
4898 || ( __kmp_affinity_type == affinity_none ) ) {
4899 if ( __kmp_affinity_type == affinity_none ) {
4900 if ( __kmp_affinity_verbose || ( __kmp_affinity_warnings
4901 && ( __kmp_affinity_type != affinity_none ) ) ) {
4902 KMP_WARNING( AffTypeCantUseMultGroups,
"none",
"compact" );
4905 __kmp_affinity_type = affinity_compact;
4906 if ( __kmp_affinity_top_method == affinity_top_method_default ) {
4907 __kmp_affinity_top_method = affinity_top_method_group;
4910 else if ( __kmp_affinity_top_method == affinity_top_method_default ) {
4911 __kmp_affinity_top_method = affinity_top_method_all;
4914 if ( __kmp_affinity_gran_levels < 0 ) {
4915 if ( __kmp_affinity_top_method == affinity_top_method_group ) {
4916 if ( __kmp_affinity_gran == affinity_gran_default ) {
4917 __kmp_affinity_gran = affinity_gran_group;
4919 else if ( __kmp_affinity_gran == affinity_gran_core ) {
4920 if ( __kmp_affinity_verbose || ( __kmp_affinity_warnings
4921 && ( __kmp_affinity_type != affinity_none ) ) ) {
4922 KMP_WARNING( AffGranCantUseMultGroups,
"core",
"thread" );
4924 __kmp_affinity_gran = affinity_gran_thread;
4926 else if ( __kmp_affinity_gran == affinity_gran_package ) {
4927 if ( __kmp_affinity_verbose || ( __kmp_affinity_warnings
4928 && ( __kmp_affinity_type != affinity_none ) ) ) {
4929 KMP_WARNING( AffGranCantUseMultGroups,
"package",
"group" );
4931 __kmp_affinity_gran = affinity_gran_group;
4933 else if ( __kmp_affinity_gran == affinity_gran_node ) {
4934 if ( __kmp_affinity_verbose || ( __kmp_affinity_warnings
4935 && ( __kmp_affinity_type != affinity_none ) ) ) {
4936 KMP_WARNING( AffGranCantUseMultGroups,
"node",
"group" );
4938 __kmp_affinity_gran = affinity_gran_group;
4941 else if ( __kmp_affinity_gran == affinity_gran_default ) {
4942 __kmp_affinity_gran = affinity_gran_core;
4950 if ( __kmp_affinity_respect_mask == affinity_respect_mask_default ) {
4951 __kmp_affinity_respect_mask = TRUE;
4953 if ( __kmp_affinity_type == affinity_default ) {
4955 __kmp_affinity_type = affinity_scatter;
4957 __kmp_affinity_type = affinity_none;
4960 if ( ( __kmp_affinity_gran == affinity_gran_default )
4961 && ( __kmp_affinity_gran_levels < 0 ) ) {
4963 __kmp_affinity_gran = affinity_gran_fine;
4965 __kmp_affinity_gran = affinity_gran_core;
4968 if ( __kmp_affinity_top_method == affinity_top_method_default ) {
4969 __kmp_affinity_top_method = affinity_top_method_all;
4974 K_DIAG( 1, (
"__kmp_affinity_type == %d\n", __kmp_affinity_type ) );
4975 K_DIAG( 1, (
"__kmp_affinity_compact == %d\n", __kmp_affinity_compact ) );
4976 K_DIAG( 1, (
"__kmp_affinity_offset == %d\n", __kmp_affinity_offset ) );
4977 K_DIAG( 1, (
"__kmp_affinity_verbose == %d\n", __kmp_affinity_verbose ) );
4978 K_DIAG( 1, (
"__kmp_affinity_warnings == %d\n", __kmp_affinity_warnings ) );
4979 K_DIAG( 1, (
"__kmp_affinity_respect_mask == %d\n", __kmp_affinity_respect_mask ) );
4980 K_DIAG( 1, (
"__kmp_affinity_gran == %d\n", __kmp_affinity_gran ) );
4982 KMP_DEBUG_ASSERT( __kmp_affinity_type != affinity_default);
4984 KMP_DEBUG_ASSERT( __kmp_nested_proc_bind.bind_types[0]
4985 != proc_bind_default );
4992 #error "Unknown or unsupported OS"
4995 if ( __kmp_version ) {
4996 __kmp_print_version_1();
5000 if (
string != NULL) {
5001 __kmp_aux_env_initialize( &block );
5004 __kmp_env_blk_free( & block );
5014 kmp_env_blk_t block;
5016 kmp_str_buf_t buffer;
5019 __kmp_str_buf_init( & buffer );
5021 __kmp_env_blk_init( & block, NULL );
5022 __kmp_env_blk_sort( & block );
5025 __kmp_str_buf_print( & buffer,
"\n%s\n\n", KMP_I18N_STR( UserSettings ) );
5026 for ( i = 0; i < block.count; ++ i ) {
5027 char const * name = block.vars[ i ].name;
5028 char const * value = block.vars[ i ].value;
5032 ( strncmp( name,
"KMP_", 4 ) == 0 ) || strncmp( name,
"OMP_", 4 ) == 0
5033 #ifdef KMP_GOMP_COMPAT
5034 || strncmp( name,
"GOMP_", 5 ) == 0
5037 __kmp_str_buf_print( & buffer,
" %s=%s\n", name, value );
5040 __kmp_str_buf_print( & buffer,
"\n" );
5043 __kmp_str_buf_print( & buffer,
"%s\n\n", KMP_I18N_STR( EffectiveSettings ) );
5044 for (
int i = 0; i < __kmp_stg_count; ++ i ) {
5045 if ( __kmp_stg_table[ i ].print != NULL ) {
5046 __kmp_stg_table[ i ].print( & buffer, __kmp_stg_table[ i ].name, __kmp_stg_table[ i ].data );
5050 __kmp_printf(
"%s", buffer.str );
5052 __kmp_env_blk_free( & block );
5053 __kmp_str_buf_free( & buffer );