38 #include "kmp_wrapper_getpid.h"
39 #include "kmp_environment.h"
40 #include "kmp_atomic.h"
43 #include "kmp_settings.h"
48 static int __kmp_env_isDefined(
char const * name );
49 static int __kmp_env_toPrint(
char const * name,
int flag );
51 bool __kmp_env_format = 0;
57 __kmp_convert_to_double(
char const * s )
61 if ( sscanf( s,
"%lf", &result ) < 1 ) {
69 __kmp_readstr_with_sentinel(
char *dest,
char const * src,
size_t len,
char sentinel) {
71 for (i = 0; i < len; i++) {
72 if ((*src ==
'\0') || (*src == sentinel)) {
82 __kmp_match_with_sentinel(
char const * a,
char const * b,
size_t len,
char sentinel ) {
89 while(*a && *b && *b != sentinel) {
90 char ca = *a, cb = *b;
92 if(ca >=
'a' && ca <=
'z')
94 if(cb >=
'a' && cb <=
'z')
132 __kmp_match_str(
char const *token,
char const *buf,
const char **end) {
134 KMP_ASSERT(token != NULL);
135 KMP_ASSERT(buf != NULL);
136 KMP_ASSERT(end != NULL);
138 while (*token && *buf) {
139 char ct = *token, cb = *buf;
141 if(ct >=
'a' && ct <=
'z')
143 if(cb >=
'a' && cb <=
'z')
158 __kmp_strip_quotes(
char *target,
int len) {
159 char *end = target + len - 1;
161 while(*target ==
'"' || *target ==
'\'') {
162 if(end <= target || (*end !=
'"' && *end !=
'\''))
174 __kmp_round4k(
size_t size ) {
175 size_t _4k = 4 * 1024;
176 if ( size & ( _4k - 1 ) ) {
177 size &= ~ ( _4k - 1 );
178 if ( size <= KMP_SIZE_T_MAX - _4k ) {
187 __kmp_convert_to_seconds(
char const * data )
189 int nvalues, value, factor;
192 if (data == NULL)
return (0);
195 nvalues = sscanf (data,
"%d%c%c", &value, &mult, &extra);
196 if (nvalues < 1)
return (0);
197 if (nvalues == 1) mult =
'\0';
198 if (nvalues == 3)
return (-1);
214 factor = 24 * 60 * 60;
220 if (value > (INT_MAX / factor))
235 __kmp_convert_to_milliseconds(
char const * data )
237 int ret, nvalues, factor;
241 if (data == NULL)
return (-1);
242 if ( __kmp_str_match(
"infinit", -1, data))
return (INT_MAX);
243 value = (double) 0.0;
245 nvalues = sscanf (data,
"%lf%c%c", &value, &mult, &extra);
246 if (nvalues < 1)
return (-1);
247 if (nvalues == 1) mult =
'\0';
248 if (nvalues == 3)
return (-1);
250 if (value < 0)
return (-1);
264 factor = 1000 * 60 * 60;
267 factor = 1000 * 24 * 60 * 60;
273 if ( value >= ( (INT_MAX-1) / factor) )
276 ret = (int) (value * (
double) factor);
282 __kmp_convert_to_nanoseconds(
293 if ( str == NULL || str[ 0 ] == 0 ) {
296 rc = sscanf( str,
"%lf%c%c", &value, &unit, &extra );
328 result = (kmp_uint64)( value * factor );
335 __kmp_strcasecmp_with_sentinel(
char const * a,
char const * b,
char sentinel ) {
340 while(*a && *b && *b != sentinel) {
341 char ca = *a, cb = *b;
343 if(ca >=
'a' && ca <=
'z')
345 if(cb >=
'a' && cb <=
'z')
348 return (
int)(
unsigned char)*a - (
int)(
unsigned char)*b;
353 (*b && *b != sentinel) ? (
int)(
unsigned char)*a - (
int)(
unsigned char)*b : 1 :
354 (*b && *b != sentinel) ? -1 : 0;
362 typedef struct __kmp_setting kmp_setting_t;
363 typedef struct __kmp_stg_ss_data kmp_stg_ss_data_t;
364 typedef struct __kmp_stg_wp_data kmp_stg_wp_data_t;
365 typedef struct __kmp_stg_fr_data kmp_stg_fr_data_t;
367 typedef void ( * kmp_stg_parse_func_t )(
char const * name,
char const * value,
void * data );
368 typedef void ( * kmp_stg_print_func_t )( kmp_str_buf_t * buffer,
char const * name,
void * data );
370 struct __kmp_setting {
372 kmp_stg_parse_func_t parse;
373 kmp_stg_print_func_t print;
380 struct __kmp_stg_ss_data {
382 kmp_setting_t * * rivals;
385 struct __kmp_stg_wp_data {
387 kmp_setting_t * * rivals;
390 struct __kmp_stg_fr_data {
392 kmp_setting_t * * rivals;
396 __kmp_stg_check_rivals(
399 kmp_setting_t * * rivals
408 __kmp_stg_parse_bool(
413 if ( __kmp_str_match_true( value ) ) {
415 }
else if (__kmp_str_match_false( value ) ) {
420 KMP_MSG( BadBoolValue, name, value ),
421 KMP_HNT( ValidBoolValues ),
428 __kmp_stg_parse_size(
437 char const * msg = NULL;
439 size_min = __kmp_round4k( size_min );
440 size_max = __kmp_round4k( size_max );
441 #endif // KMP_OS_DARWIN
443 if ( is_specified != NULL ) {
446 __kmp_str_to_size( value, out, factor, & msg );
448 if ( * out > size_max ) {
450 msg = KMP_I18N_STR( ValueTooLarge );
451 }
else if ( * out < size_min ) {
453 msg = KMP_I18N_STR( ValueTooSmall );
456 size_t round4k = __kmp_round4k( * out );
457 if ( * out != round4k ) {
459 msg = KMP_I18N_STR( NotMultiple4K );
465 if ( * out < size_min ) {
468 else if ( * out > size_max ) {
475 __kmp_str_buf_init( & buf );
476 __kmp_str_buf_print_size( & buf, * out );
477 KMP_WARNING( ParseSizeIntWarn, name, value, msg );
478 KMP_INFORM( Using_str_Value, name, buf.str );
479 __kmp_str_buf_free( & buf );
490 KMP_INTERNAL_FREE( (
void *) * out );
491 * out = __kmp_str_format(
"%s", value );
503 char const * msg = NULL;
504 kmp_uint64 uint = * out;
505 __kmp_str_to_uint( value, & uint, & msg );
507 if ( uint < (
unsigned int)min ) {
508 msg = KMP_I18N_STR( ValueTooSmall );
510 }
else if ( uint > (
unsigned int)max ) {
511 msg = KMP_I18N_STR( ValueTooLarge );
517 if ( uint < (
unsigned int)min ) {
520 else if ( uint > (
unsigned int)max ) {
527 KMP_WARNING( ParseSizeIntWarn, name, value, msg );
528 __kmp_str_buf_init( & buf );
529 __kmp_str_buf_print( &buf,
"%" KMP_UINT64_SPEC
"", uint );
530 KMP_INFORM( Using_uint64_Value, name, buf.str );
531 __kmp_str_buf_free( &buf );
538 __kmp_stg_parse_file(
547 KMP_INTERNAL_FREE( (
void *) * out );
548 t = (
char *) strrchr(value,
'.');
549 hasSuffix = t && __kmp_str_eqf( t, suffix );
550 t = __kmp_str_format(
"%s%s", value, hasSuffix ?
"" : suffix );
551 __kmp_expand_file_name( buffer,
sizeof(buffer), t);
552 KMP_INTERNAL_FREE(t);
553 * out = __kmp_str_format(
"%s", buffer );
556 static char * par_range_to_print = NULL;
559 __kmp_stg_parse_par_range(
568 size_t len = strlen( value + 1 );
569 par_range_to_print = (
char *) KMP_INTERNAL_MALLOC( len +1 );
570 strncpy( par_range_to_print, value, len + 1);
571 __kmp_par_range = +1;
572 __kmp_par_range_lb = 0;
573 __kmp_par_range_ub = INT_MAX;
576 if (( value == NULL ) || ( *value ==
'\0' )) {
579 if ( ! __kmp_strcasecmp_with_sentinel(
"routine", value,
'=' )) {
580 value = strchr( value,
'=' ) + 1;
581 len = __kmp_readstr_with_sentinel( out_routine,
582 value, KMP_PAR_RANGE_ROUTINE_LEN - 1,
',' );
584 goto par_range_error;
586 value = strchr( value,
',' );
587 if ( value != NULL ) {
592 if ( ! __kmp_strcasecmp_with_sentinel(
"filename", value,
'=' )) {
593 value = strchr( value,
'=' ) + 1;
594 len = __kmp_readstr_with_sentinel( out_file,
595 value, KMP_PAR_RANGE_FILENAME_LEN - 1,
',' );
597 goto par_range_error;
599 value = strchr( value,
',' );
600 if ( value != NULL ) {
605 if (( ! __kmp_strcasecmp_with_sentinel(
"range", value,
'=' ))
606 || ( ! __kmp_strcasecmp_with_sentinel(
"incl_range", value,
'=' ))) {
607 value = strchr( value,
'=' ) + 1;
608 if ( sscanf( value,
"%d:%d", out_lb, out_ub ) != 2 ) {
609 goto par_range_error;
612 value = strchr( value,
',' );
613 if ( value != NULL ) {
618 if ( ! __kmp_strcasecmp_with_sentinel(
"excl_range", value,
'=' )) {
619 value = strchr( value,
'=' ) + 1;
620 if ( sscanf( value,
"%d:%d", out_lb, out_ub) != 2 ) {
621 goto par_range_error;
624 value = strchr( value,
',' );
625 if ( value != NULL ) {
631 KMP_WARNING( ParRangeSyntax, name );
639 __kmp_initial_threads_capacity(
int req_nproc )
644 if (nth < (4 * req_nproc))
645 nth = (4 * req_nproc);
646 if (nth < (4 * __kmp_xproc))
647 nth = (4 * __kmp_xproc);
649 if (nth > __kmp_max_nth)
657 __kmp_default_tp_capacity(
int req_nproc,
int max_nth,
int all_threads_specified) {
660 if(all_threads_specified)
663 if (nth < (4 * req_nproc))
664 nth = (4 * req_nproc);
665 if (nth < (4 * __kmp_xproc))
666 nth = (4 * __kmp_xproc);
668 if (nth > __kmp_max_nth)
680 __kmp_stg_print_bool( kmp_str_buf_t * buffer,
char const * name,
int value ) {
681 if( __kmp_env_format ) {
682 KMP_STR_BUF_PRINT_BOOL;
684 __kmp_str_buf_print( buffer,
" %s=%s\n", name, value ?
"true" :
"false" );
689 __kmp_stg_print_int( kmp_str_buf_t * buffer,
char const * name,
int value ) {
690 if( __kmp_env_format ) {
691 KMP_STR_BUF_PRINT_INT;
693 __kmp_str_buf_print( buffer,
" %s=%d\n", name, value );
698 __kmp_stg_print_uint64( kmp_str_buf_t * buffer,
char const * name, kmp_uint64 value ) {
699 if( __kmp_env_format ) {
700 KMP_STR_BUF_PRINT_UINT64;
702 __kmp_str_buf_print( buffer,
" %s=%" KMP_UINT64_SPEC
"\n", name, value );
707 __kmp_stg_print_str( kmp_str_buf_t * buffer,
char const * name,
char const * value ) {
708 if( __kmp_env_format ) {
709 KMP_STR_BUF_PRINT_STR;
711 __kmp_str_buf_print( buffer,
" %s=%s\n", name, value );
716 __kmp_stg_print_size( kmp_str_buf_t * buffer,
char const * name,
size_t value ) {
717 if( __kmp_env_format ) {
718 KMP_STR_BUF_PRINT_NAME_EX(name);
719 __kmp_str_buf_print_size( buffer, value );
720 __kmp_str_buf_print( buffer,
"'\n" );
722 __kmp_str_buf_print( buffer,
" %s=", name );
723 __kmp_str_buf_print_size( buffer, value );
724 __kmp_str_buf_print( buffer,
"\n" );
739 __kmp_stg_parse_all_threads(
char const * name,
char const * value,
void * data ) {
741 kmp_setting_t * * rivals = (kmp_setting_t * *) data;
743 rc = __kmp_stg_check_rivals( name, value, rivals );
747 if ( ! __kmp_strcasecmp_with_sentinel(
"all", value, 0 ) ) {
748 __kmp_max_nth = __kmp_xproc;
749 __kmp_allThreadsSpecified = 1;
751 __kmp_stg_parse_int( name, value, 1, __kmp_sys_max_nth, & __kmp_max_nth );
752 __kmp_allThreadsSpecified = 0;
754 K_DIAG( 1, (
"__kmp_max_nth == %d\n", __kmp_max_nth ) );
759 __kmp_stg_print_all_threads( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
760 __kmp_stg_print_int( buffer, name, __kmp_max_nth );
768 __kmp_stg_parse_blocktime(
char const * name,
char const * value,
void * data ) {
769 __kmp_dflt_blocktime = __kmp_convert_to_milliseconds( value );
770 if ( __kmp_dflt_blocktime < 0 ) {
771 __kmp_dflt_blocktime = KMP_DEFAULT_BLOCKTIME;
772 __kmp_msg( kmp_ms_warning, KMP_MSG( InvalidValue, name, value ), __kmp_msg_null );
773 KMP_INFORM( Using_int_Value, name, __kmp_dflt_blocktime );
774 __kmp_env_blocktime = FALSE;
776 if ( __kmp_dflt_blocktime < KMP_MIN_BLOCKTIME ) {
777 __kmp_dflt_blocktime = KMP_MIN_BLOCKTIME;
778 __kmp_msg( kmp_ms_warning, KMP_MSG( SmallValue, name, value ), __kmp_msg_null );
779 KMP_INFORM( MinValueUsing, name, __kmp_dflt_blocktime );
780 }
else if ( __kmp_dflt_blocktime > KMP_MAX_BLOCKTIME ) {
781 __kmp_dflt_blocktime = KMP_MAX_BLOCKTIME;
782 __kmp_msg( kmp_ms_warning, KMP_MSG( LargeValue, name, value ), __kmp_msg_null );
783 KMP_INFORM( MaxValueUsing, name, __kmp_dflt_blocktime );
785 __kmp_env_blocktime = TRUE;
788 __kmp_monitor_wakeups = KMP_WAKEUPS_FROM_BLOCKTIME( __kmp_dflt_blocktime, __kmp_monitor_wakeups );
789 __kmp_bt_intervals = KMP_INTERVALS_FROM_BLOCKTIME( __kmp_dflt_blocktime, __kmp_monitor_wakeups );
790 K_DIAG( 1, (
"__kmp_env_blocktime == %d\n", __kmp_env_blocktime ) );
791 if ( __kmp_env_blocktime ) {
792 K_DIAG( 1, (
"__kmp_dflt_blocktime == %d\n", __kmp_dflt_blocktime ) );
797 __kmp_stg_print_blocktime( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
798 __kmp_stg_print_int( buffer, name, __kmp_dflt_blocktime );
806 __kmp_stg_parse_duplicate_lib_ok(
char const * name,
char const * value,
void * data ) {
809 __kmp_stg_parse_bool( name, value, & __kmp_duplicate_library_ok );
813 __kmp_stg_print_duplicate_lib_ok( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
814 __kmp_stg_print_bool( buffer, name, __kmp_duplicate_library_ok );
821 #if KMP_ARCH_X86 || KMP_ARCH_X86_64
824 __kmp_stg_parse_inherit_fp_control(
char const * name,
char const * value,
void * data ) {
825 __kmp_stg_parse_bool( name, value, & __kmp_inherit_fp_control );
829 __kmp_stg_print_inherit_fp_control( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
831 __kmp_stg_print_bool( buffer, name, __kmp_inherit_fp_control );
842 __kmp_stg_parse_wait_policy(
char const * name,
char const * value,
void * data ) {
844 kmp_stg_wp_data_t * wait = (kmp_stg_wp_data_t *) data;
847 rc = __kmp_stg_check_rivals( name, value, wait->rivals );
853 if ( __kmp_str_match(
"ACTIVE", 1, value ) ) {
854 __kmp_library = library_turnaround;
855 }
else if ( __kmp_str_match(
"PASSIVE", 1, value ) ) {
856 __kmp_library = library_throughput;
858 KMP_WARNING( StgInvalidValue, name, value );
861 if ( __kmp_str_match(
"serial", 1, value ) ) {
862 __kmp_library = library_serial;
863 }
else if ( __kmp_str_match(
"throughput", 2, value ) ) {
864 __kmp_library = library_throughput;
865 }
else if ( __kmp_str_match(
"turnaround", 2, value ) ) {
866 __kmp_library = library_turnaround;
867 }
else if ( __kmp_str_match(
"dedicated", 1, value ) ) {
868 __kmp_library = library_turnaround;
869 }
else if ( __kmp_str_match(
"multiuser", 1, value ) ) {
870 __kmp_library = library_throughput;
872 KMP_WARNING( StgInvalidValue, name, value );
875 __kmp_aux_set_library( __kmp_library );
880 __kmp_stg_print_wait_policy( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
882 kmp_stg_wp_data_t * wait = (kmp_stg_wp_data_t *) data;
883 char const * value = NULL;
886 switch ( __kmp_library ) {
887 case library_turnaround : {
890 case library_throughput : {
895 switch ( __kmp_library ) {
896 case library_serial : {
899 case library_turnaround : {
900 value =
"turnaround";
902 case library_throughput : {
903 value =
"throughput";
907 if ( value != NULL ) {
908 __kmp_stg_print_str( buffer, name, value );
918 __kmp_stg_parse_monitor_stacksize(
char const * name,
char const * value,
void * data ) {
919 __kmp_stg_parse_size(
922 __kmp_sys_min_stksize,
925 & __kmp_monitor_stksize,
931 __kmp_stg_print_monitor_stacksize( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
932 if( __kmp_env_format ) {
933 if ( __kmp_monitor_stksize > 0 )
934 KMP_STR_BUF_PRINT_NAME_EX(name);
936 KMP_STR_BUF_PRINT_NAME;
938 __kmp_str_buf_print( buffer,
" %s", name );
940 if ( __kmp_monitor_stksize > 0 ) {
941 __kmp_str_buf_print_size( buffer, __kmp_monitor_stksize );
943 __kmp_str_buf_print( buffer,
": %s\n", KMP_I18N_STR( NotDefined ) );
945 if( __kmp_env_format && __kmp_monitor_stksize ) {
946 __kmp_str_buf_print( buffer,
"'\n");
956 __kmp_stg_parse_settings(
char const * name,
char const * value,
void * data ) {
957 __kmp_stg_parse_bool( name, value, & __kmp_settings );
961 __kmp_stg_print_settings( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
962 __kmp_stg_print_bool( buffer, name, __kmp_settings );
970 __kmp_stg_parse_stackoffset(
char const * name,
char const * value,
void * data ) {
971 __kmp_stg_parse_size(
983 __kmp_stg_print_stackoffset( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
984 __kmp_stg_print_size( buffer, name, __kmp_stkoffset );
992 __kmp_stg_parse_stacksize(
char const * name,
char const * value,
void * data ) {
994 kmp_stg_ss_data_t * stacksize = (kmp_stg_ss_data_t *) data;
997 rc = __kmp_stg_check_rivals( name, value, stacksize->rivals );
1001 __kmp_stg_parse_size(
1004 __kmp_sys_min_stksize,
1006 & __kmp_env_stksize,
1017 __kmp_stg_print_stacksize( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1018 kmp_stg_ss_data_t * stacksize = (kmp_stg_ss_data_t *) data;
1019 if( __kmp_env_format ) {
1020 KMP_STR_BUF_PRINT_NAME_EX(name);
1021 __kmp_str_buf_print_size( buffer, (__kmp_stksize % 1024) ? __kmp_stksize / stacksize->factor : __kmp_stksize );
1022 __kmp_str_buf_print( buffer,
"'\n" );
1024 __kmp_str_buf_print( buffer,
" %s=", name );
1025 __kmp_str_buf_print_size( buffer, (__kmp_stksize % 1024) ? __kmp_stksize / stacksize->factor : __kmp_stksize );
1026 __kmp_str_buf_print( buffer,
"\n" );
1035 __kmp_stg_parse_version(
char const * name,
char const * value,
void * data ) {
1036 __kmp_stg_parse_bool( name, value, & __kmp_version );
1040 __kmp_stg_print_version( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1041 __kmp_stg_print_bool( buffer, name, __kmp_version );
1049 __kmp_stg_parse_warnings(
char const * name,
char const * value,
void * data ) {
1050 __kmp_stg_parse_bool( name, value, & __kmp_generate_warnings );
1051 if (__kmp_generate_warnings != kmp_warnings_off) {
1052 __kmp_generate_warnings = kmp_warnings_explicit;
1057 __kmp_stg_print_warnings( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1058 __kmp_stg_print_bool( buffer, name, __kmp_generate_warnings );
1066 __kmp_stg_parse_nested(
char const * name,
char const * value,
void * data ) {
1067 __kmp_stg_parse_bool( name, value, & __kmp_dflt_nested );
1071 __kmp_stg_print_nested( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1072 __kmp_stg_print_bool( buffer, name, __kmp_dflt_nested );
1076 __kmp_parse_nested_num_threads(
const char *var,
const char *env, kmp_nested_nthreads_t *nth_array )
1078 const char *next = env;
1079 const char *scan = next;
1082 int prev_comma = FALSE;
1088 if ( *next ==
'\0' ) {
1092 if ( ( ( *next <
'0' ) || ( *next >
'9' ) ) && ( *next !=
',') ) {
1093 KMP_WARNING( NthSyntaxError, var, env );
1097 if ( *next ==
',' ) {
1099 if ( total == 0 || prev_comma ) {
1107 if ( *next >=
'0' && *next <=
'9' ) {
1109 SKIP_DIGITS( next );
1111 const char *tmp = next;
1113 if ( ( *next ==
' ' || *next ==
'\t' ) && ( *tmp >=
'0' && *tmp <=
'9' ) ) {
1114 KMP_WARNING( NthSpacesNotAllowed, var, env );
1119 KMP_DEBUG_ASSERT( total > 0 );
1121 KMP_WARNING( NthSyntaxError, var, env );
1126 if ( ! nth_array->nth ) {
1128 nth_array->nth = (
int * )KMP_INTERNAL_MALLOC(
sizeof(
int ) * total * 2 );
1129 if ( nth_array->nth == NULL ) {
1130 KMP_FATAL( MemoryAllocFailed );
1132 nth_array->size = total * 2;
1134 if ( nth_array->size < total ) {
1137 nth_array->size *= 2;
1138 }
while ( nth_array->size < total );
1140 nth_array->nth = (
int *) KMP_INTERNAL_REALLOC(
1141 nth_array->nth,
sizeof(
int ) * nth_array->size );
1142 if ( nth_array->nth == NULL ) {
1143 KMP_FATAL( MemoryAllocFailed );
1147 nth_array->used = total;
1155 if ( *scan ==
'\0' ) {
1159 if ( *scan ==
',' ) {
1164 nth_array->nth[i++] = 0;
1166 }
else if ( prev_comma ) {
1168 nth_array->nth[i] = nth_array->nth[i - 1];
1177 if ( *scan >=
'0' && *scan <=
'9' ) {
1179 const char *buf = scan;
1180 char const * msg = NULL;
1182 SKIP_DIGITS( scan );
1185 num = __kmp_str_to_int( buf, *scan );
1186 if ( num < KMP_MIN_NTH ) {
1187 msg = KMP_I18N_STR( ValueTooSmall );
1189 }
else if ( num > __kmp_sys_max_nth ) {
1190 msg = KMP_I18N_STR( ValueTooLarge );
1191 num = __kmp_sys_max_nth;
1193 if ( msg != NULL ) {
1195 KMP_WARNING( ParseSizeIntWarn, var, env, msg );
1196 KMP_INFORM( Using_int_Value, var, num );
1198 nth_array->nth[i++] = num;
1204 __kmp_stg_parse_num_threads(
char const * name,
char const * value,
void * data ) {
1206 if ( ! __kmp_strcasecmp_with_sentinel(
"all", value, 0 ) ) {
1208 __kmp_nested_nth.nth = (
int* )KMP_INTERNAL_MALLOC(
sizeof(
int ) );
1209 __kmp_nested_nth.size = __kmp_nested_nth.used = 1;
1210 __kmp_nested_nth.nth[0] = __kmp_dflt_team_nth = __kmp_dflt_team_nth_ub = __kmp_xproc;
1212 __kmp_parse_nested_num_threads( name, value, & __kmp_nested_nth );
1213 if ( __kmp_nested_nth.nth ) {
1214 __kmp_dflt_team_nth = __kmp_nested_nth.nth[0];
1215 if ( __kmp_dflt_team_nth_ub < __kmp_dflt_team_nth ) {
1216 __kmp_dflt_team_nth_ub = __kmp_dflt_team_nth;
1220 K_DIAG( 1, (
"__kmp_dflt_team_nth == %d\n", __kmp_dflt_team_nth ) );
1224 __kmp_stg_print_num_threads( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1225 if( __kmp_env_format ) {
1226 KMP_STR_BUF_PRINT_NAME;
1228 __kmp_str_buf_print( buffer,
" %s", name );
1230 if ( __kmp_nested_nth.used ) {
1232 __kmp_str_buf_init( &buf );
1233 for (
int i = 0; i < __kmp_nested_nth.used; i++) {
1234 __kmp_str_buf_print( &buf,
"%d", __kmp_nested_nth.nth[i] );
1235 if ( i < __kmp_nested_nth.used - 1 ) {
1236 __kmp_str_buf_print( &buf,
"," );
1239 __kmp_str_buf_print( buffer,
"='%s'\n", buf.str );
1240 __kmp_str_buf_free(&buf);
1242 __kmp_str_buf_print( buffer,
": %s\n", KMP_I18N_STR( NotDefined ) );
1252 __kmp_stg_parse_tasking(
char const * name,
char const * value,
void * data ) {
1253 __kmp_stg_parse_int( name, value, 0, (
int)tskm_max, (
int *)&__kmp_tasking_mode );
1257 __kmp_stg_print_tasking( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1258 __kmp_stg_print_int( buffer, name, __kmp_tasking_mode );
1262 __kmp_stg_parse_task_stealing(
char const * name,
char const * value,
void * data ) {
1263 __kmp_stg_parse_int( name, value, 0, 1, (
int *)&__kmp_task_stealing_constraint );
1267 __kmp_stg_print_task_stealing( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1268 __kmp_stg_print_int( buffer, name, __kmp_task_stealing_constraint );
1272 __kmp_stg_parse_max_active_levels(
char const * name,
char const * value,
void * data ) {
1273 __kmp_stg_parse_int( name, value, 0, KMP_MAX_ACTIVE_LEVELS_LIMIT, & __kmp_dflt_max_active_levels );
1277 __kmp_stg_print_max_active_levels( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1278 __kmp_stg_print_int( buffer, name, __kmp_dflt_max_active_levels );
1280 #endif // OMP_30_ENABLED
1286 #if KMP_HANDLE_SIGNALS
1289 __kmp_stg_parse_handle_signals(
char const * name,
char const * value,
void * data ) {
1290 __kmp_stg_parse_bool( name, value, & __kmp_handle_signals );
1294 __kmp_stg_print_handle_signals( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1295 __kmp_stg_print_bool( buffer, name, __kmp_handle_signals );
1298 #endif // KMP_HANDLE_SIGNALS
1306 #define KMP_STG_X_DEBUG( x ) \
1307 static void __kmp_stg_parse_##x##_debug( char const * name, char const * value, void * data ) { \
1308 __kmp_stg_parse_int( name, value, 0, INT_MAX, & kmp_##x##_debug ); \
1310 static void __kmp_stg_print_##x##_debug( kmp_str_buf_t * buffer, char const * name, void * data ) { \
1311 __kmp_stg_print_int( buffer, name, kmp_##x##_debug ); \
1314 KMP_STG_X_DEBUG( a )
1315 KMP_STG_X_DEBUG( b )
1316 KMP_STG_X_DEBUG( c )
1317 KMP_STG_X_DEBUG( d )
1318 KMP_STG_X_DEBUG( e )
1319 KMP_STG_X_DEBUG( f )
1321 #undef KMP_STG_X_DEBUG
1324 __kmp_stg_parse_debug(
char const * name,
char const * value,
void * data ) {
1326 __kmp_stg_parse_int( name, value, 0, INT_MAX, & debug );
1327 if ( kmp_a_debug < debug ) {
1328 kmp_a_debug = debug;
1330 if ( kmp_b_debug < debug ) {
1331 kmp_b_debug = debug;
1333 if ( kmp_c_debug < debug ) {
1334 kmp_c_debug = debug;
1336 if ( kmp_d_debug < debug ) {
1337 kmp_d_debug = debug;
1339 if ( kmp_e_debug < debug ) {
1340 kmp_e_debug = debug;
1342 if ( kmp_f_debug < debug ) {
1343 kmp_f_debug = debug;
1348 __kmp_stg_parse_debug_buf(
char const * name,
char const * value,
void * data ) {
1349 __kmp_stg_parse_bool( name, value, & __kmp_debug_buf );
1352 if ( __kmp_debug_buf ) {
1354 int elements = __kmp_debug_buf_lines * __kmp_debug_buf_chars;
1357 __kmp_debug_buffer = (
char *) __kmp_page_allocate( elements *
sizeof(
char ) );
1358 for ( i = 0; i < elements; i += __kmp_debug_buf_chars )
1359 __kmp_debug_buffer[i] =
'\0';
1361 __kmp_debug_count = 0;
1363 K_DIAG( 1, (
"__kmp_debug_buf = %d\n", __kmp_debug_buf ) );
1367 __kmp_stg_print_debug_buf( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1368 __kmp_stg_print_bool( buffer, name, __kmp_debug_buf );
1372 __kmp_stg_parse_debug_buf_atomic(
char const * name,
char const * value,
void * data ) {
1373 __kmp_stg_parse_bool( name, value, & __kmp_debug_buf_atomic );
1377 __kmp_stg_print_debug_buf_atomic( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1378 __kmp_stg_print_bool( buffer, name, __kmp_debug_buf_atomic );
1382 __kmp_stg_parse_debug_buf_chars(
char const * name,
char const * value,
void * data ) {
1383 __kmp_stg_parse_int(
1386 KMP_DEBUG_BUF_CHARS_MIN,
1388 & __kmp_debug_buf_chars
1393 __kmp_stg_print_debug_buf_chars( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1394 __kmp_stg_print_int( buffer, name, __kmp_debug_buf_chars );
1398 __kmp_stg_parse_debug_buf_lines(
char const * name,
char const * value,
void * data ) {
1399 __kmp_stg_parse_int(
1402 KMP_DEBUG_BUF_LINES_MIN,
1404 & __kmp_debug_buf_lines
1409 __kmp_stg_print_debug_buf_lines( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1410 __kmp_stg_print_int( buffer, name, __kmp_debug_buf_lines );
1414 __kmp_stg_parse_diag(
char const * name,
char const * value,
void * data ) {
1415 __kmp_stg_parse_int( name, value, 0, INT_MAX, & kmp_diag );
1419 __kmp_stg_print_diag( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1420 __kmp_stg_print_int( buffer, name, kmp_diag );
1430 __kmp_stg_parse_align_alloc(
char const * name,
char const * value,
void * data ) {
1431 __kmp_stg_parse_size(
1437 & __kmp_align_alloc,
1443 __kmp_stg_print_align_alloc( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1444 __kmp_stg_print_size( buffer, name, __kmp_align_alloc );
1455 __kmp_stg_parse_barrier_branch_bit(
char const * name,
char const * value,
void * data ) {
1460 for (
int i=bs_plain_barrier; i<bs_last_barrier; i++ ) {
1461 var = __kmp_barrier_branch_bit_env_name[ i ];
1463 if ( ( strcmp( var, name) == 0 ) && ( value != 0 ) ) {
1466 comma = (
char *) strchr( value,
',' );
1467 __kmp_barrier_gather_branch_bits[ i ] = ( kmp_uint32 ) __kmp_str_to_int( value,
',' );
1469 if ( comma == NULL ) {
1470 __kmp_barrier_release_branch_bits[ i ] = __kmp_barrier_release_bb_dflt;
1472 __kmp_barrier_release_branch_bits[ i ] = (kmp_uint32) __kmp_str_to_int( comma + 1, 0 );
1474 if ( __kmp_barrier_release_branch_bits[ i ] > KMP_MAX_BRANCH_BITS ) {
1475 __kmp_msg( kmp_ms_warning, KMP_MSG( BarrReleaseValueInvalid, name, comma + 1 ), __kmp_msg_null );
1477 __kmp_barrier_release_branch_bits[ i ] = __kmp_barrier_release_bb_dflt;
1480 if ( __kmp_barrier_gather_branch_bits[ i ] > KMP_MAX_BRANCH_BITS ) {
1481 KMP_WARNING( BarrGatherValueInvalid, name, value );
1482 KMP_INFORM( Using_uint_Value, name, __kmp_barrier_gather_bb_dflt );
1483 __kmp_barrier_gather_branch_bits[ i ] = __kmp_barrier_gather_bb_dflt;
1486 K_DIAG(1, (
"%s == %d,%d\n", __kmp_barrier_branch_bit_env_name[ i ], \
1487 __kmp_barrier_gather_branch_bits [ i ], \
1488 __kmp_barrier_release_branch_bits [ i ]))
1493 __kmp_stg_print_barrier_branch_bit( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1495 for (
int i=bs_plain_barrier; i<bs_last_barrier; i++ ) {
1496 var = __kmp_barrier_branch_bit_env_name[ i ];
1497 if ( strcmp( var, name) == 0 ) {
1498 if( __kmp_env_format ) {
1499 KMP_STR_BUF_PRINT_NAME_EX(__kmp_barrier_branch_bit_env_name[ i ]);
1501 __kmp_str_buf_print( buffer,
" %s='", __kmp_barrier_branch_bit_env_name[ i ] );
1503 __kmp_str_buf_print( buffer,
"%d,%d'\n", __kmp_barrier_gather_branch_bits [ i ], __kmp_barrier_release_branch_bits [ i ]);
1517 __kmp_stg_parse_barrier_pattern(
char const * name,
char const * value,
void * data ) {
1521 for (
int i=bs_plain_barrier; i<bs_last_barrier; i++ ) {
1522 var = __kmp_barrier_pattern_env_name[ i ];
1524 if ( ( strcmp ( var, name ) == 0 ) && ( value != 0 ) ) {
1526 char *comma = (
char *) strchr( value,
',' );
1529 for ( j = bp_linear_bar; j<bp_last_bar; j++ ) {
1530 if (__kmp_match_with_sentinel( __kmp_barrier_pattern_name[j], value, 1,
',' )) {
1531 __kmp_barrier_gather_pattern[ i ] = (kmp_bar_pat_e) j;
1535 if ( j == bp_last_bar ) {
1536 KMP_WARNING( BarrGatherValueInvalid, name, value );
1537 KMP_INFORM( Using_str_Value, name, __kmp_barrier_pattern_name[ bp_linear_bar ] );
1541 if ( comma != NULL ) {
1542 for ( j = bp_linear_bar; j < bp_last_bar; j++ ) {
1543 if ( __kmp_str_match( __kmp_barrier_pattern_name[j], 1, comma + 1 ) ) {
1544 __kmp_barrier_release_pattern[ i ] = (kmp_bar_pat_e) j;
1548 if (j == bp_last_bar) {
1549 __kmp_msg( kmp_ms_warning, KMP_MSG( BarrReleaseValueInvalid, name, comma + 1 ), __kmp_msg_null );
1550 KMP_INFORM( Using_str_Value, name, __kmp_barrier_pattern_name[ bp_linear_bar ] );
1558 __kmp_stg_print_barrier_pattern( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1560 for (
int i=bs_plain_barrier; i<bs_last_barrier; i++ ) {
1561 var = __kmp_barrier_pattern_env_name[ i ];
1562 if ( strcmp ( var, name ) == 0 ) {
1563 int j = __kmp_barrier_gather_pattern [ i ];
1564 int k = __kmp_barrier_release_pattern [ i ];
1565 if( __kmp_env_format ) {
1566 KMP_STR_BUF_PRINT_NAME_EX(__kmp_barrier_pattern_env_name[ i ]);
1568 __kmp_str_buf_print( buffer,
" %s='", __kmp_barrier_pattern_env_name[ i ] );
1570 __kmp_str_buf_print( buffer,
"%s,%s'\n", __kmp_barrier_pattern_name [ j ], __kmp_barrier_pattern_name [ k ]);
1580 __kmp_stg_parse_abort_delay(
char const * name,
char const * value,
void * data ) {
1582 int delay = __kmp_abort_delay / 1000;
1583 __kmp_stg_parse_int( name, value, 0, INT_MAX / 1000, & delay );
1584 __kmp_abort_delay = delay * 1000;
1588 __kmp_stg_print_abort_delay( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1589 __kmp_stg_print_int( buffer, name, __kmp_abort_delay );
1597 __kmp_stg_parse_cpuinfo_file(
char const * name,
char const * value,
void * data ) {
1598 #if KMP_OS_LINUX || KMP_OS_WINDOWS
1599 __kmp_stg_parse_str( name, value, & __kmp_cpuinfo_file );
1600 K_DIAG( 1, (
"__kmp_cpuinfo_file == %s\n", __kmp_cpuinfo_file ) );
1604 #error "Unknown or unsupported OS"
1609 __kmp_stg_print_cpuinfo_file( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1610 #if KMP_OS_LINUX || KMP_OS_WINDOWS
1611 if( __kmp_env_format ) {
1612 KMP_STR_BUF_PRINT_NAME;
1614 __kmp_str_buf_print( buffer,
" %s", name );
1616 if ( __kmp_cpuinfo_file ) {
1617 __kmp_str_buf_print( buffer,
"='%s'\n", __kmp_cpuinfo_file );
1619 __kmp_str_buf_print( buffer,
": %s\n", KMP_I18N_STR( NotDefined ) );
1629 __kmp_stg_parse_force_reduction(
char const * name,
char const * value,
void * data )
1631 kmp_stg_fr_data_t * reduction = (kmp_stg_fr_data_t *) data;
1634 rc = __kmp_stg_check_rivals( name, value, reduction->rivals );
1638 if ( reduction->force ) {
1640 if( __kmp_str_match(
"critical", 0, value ) )
1641 __kmp_force_reduction_method = critical_reduce_block;
1642 else if( __kmp_str_match(
"atomic", 0, value ) )
1643 __kmp_force_reduction_method = atomic_reduce_block;
1644 else if( __kmp_str_match(
"tree", 0, value ) )
1645 __kmp_force_reduction_method = tree_reduce_block;
1647 KMP_FATAL( UnknownForceReduction, name, value );
1651 __kmp_stg_parse_bool( name, value, & __kmp_determ_red );
1652 if( __kmp_determ_red ) {
1653 __kmp_force_reduction_method = tree_reduce_block;
1655 __kmp_force_reduction_method = reduction_method_not_defined;
1658 K_DIAG( 1, (
"__kmp_force_reduction_method == %d\n", __kmp_force_reduction_method ) );
1662 __kmp_stg_print_force_reduction( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1664 kmp_stg_fr_data_t * reduction = (kmp_stg_fr_data_t *) data;
1665 char const * value = NULL;
1666 if ( reduction->force ) {
1667 if( __kmp_force_reduction_method == critical_reduce_block) {
1668 __kmp_stg_print_str( buffer, name,
"critical");
1669 }
else if ( __kmp_force_reduction_method == atomic_reduce_block ) {
1670 __kmp_stg_print_str( buffer, name,
"atomic");
1671 }
else if ( __kmp_force_reduction_method == tree_reduce_block ) {
1672 __kmp_stg_print_str( buffer, name,
"tree");
1674 if( __kmp_env_format ) {
1675 KMP_STR_BUF_PRINT_NAME;
1677 __kmp_str_buf_print( buffer,
" %s", name );
1679 __kmp_str_buf_print( buffer,
": %s\n", KMP_I18N_STR( NotDefined ) );
1682 __kmp_stg_print_bool( buffer, name, __kmp_determ_red );
1693 __kmp_stg_parse_storage_map(
char const * name,
char const * value,
void * data ) {
1694 if ( __kmp_str_match(
"verbose", 1, value ) ) {
1695 __kmp_storage_map = TRUE;
1696 __kmp_storage_map_verbose = TRUE;
1697 __kmp_storage_map_verbose_specified = TRUE;
1700 __kmp_storage_map_verbose = FALSE;
1701 __kmp_stg_parse_bool( name, value, & __kmp_storage_map );
1706 __kmp_stg_print_storage_map( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1707 if ( __kmp_storage_map_verbose || __kmp_storage_map_verbose_specified ) {
1708 __kmp_stg_print_str( buffer, name,
"verbose" );
1710 __kmp_stg_print_bool( buffer, name, __kmp_storage_map );
1719 __kmp_stg_parse_all_threadprivate(
char const * name,
char const * value,
void * data ) {
1720 __kmp_stg_parse_int( name, value, __kmp_allThreadsSpecified ? __kmp_max_nth : 1, __kmp_max_nth,
1721 & __kmp_tp_capacity );
1725 __kmp_stg_print_all_threadprivate( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1726 __kmp_stg_print_int( buffer, name, __kmp_tp_capacity );
1735 __kmp_stg_parse_foreign_threads_threadprivate(
char const * name,
char const * value,
void * data ) {
1736 __kmp_stg_parse_bool( name, value, & __kmp_foreign_tp );
1740 __kmp_stg_print_foreign_threads_threadprivate( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1741 __kmp_stg_print_bool( buffer, name, __kmp_foreign_tp );
1749 #if KMP_OS_LINUX || KMP_OS_WINDOWS
1754 __kmp_parse_affinity_proc_id_list(
const char *var,
const char *env,
1755 const char **nextEnv,
char **proclist )
1757 const char *scan = env;
1758 const char *next = scan;
1764 int start, end, stride;
1768 if (*next ==
'\0') {
1781 if ((*next <
'0') || (*next >
'9')) {
1782 KMP_WARNING( AffSyntaxError, var );
1786 num = __kmp_str_to_int(scan, *next);
1787 KMP_ASSERT(num >= 0);
1811 if ((*next <
'0') || (*next >
'9')) {
1812 KMP_WARNING( AffSyntaxError, var );
1817 num = __kmp_str_to_int(scan, *next);
1818 KMP_ASSERT(num >= 0);
1833 if ((*next <
'0') || (*next >
'9')) {
1835 KMP_WARNING( AffSyntaxError, var );
1845 start = __kmp_str_to_int(scan, *next);
1846 KMP_ASSERT(start >= 0);
1871 if ((*next <
'0') || (*next >
'9')) {
1872 KMP_WARNING( AffSyntaxError, var );
1876 end = __kmp_str_to_int(scan, *next);
1877 KMP_ASSERT(end >= 0);
1898 if ((*next <
'0') || (*next >
'9')) {
1899 KMP_WARNING( AffSyntaxError, var );
1903 stride = __kmp_str_to_int(scan, *next);
1904 KMP_ASSERT(stride >= 0);
1912 KMP_WARNING( AffZeroStride, var );
1917 KMP_WARNING( AffStartGreaterEnd, var, start, end );
1923 KMP_WARNING( AffStrideLessZero, var, start, end );
1927 if ((end - start) / stride > 65536 ) {
1928 KMP_WARNING( AffRangeTooBig, var, end, start, stride );
1947 int len = next - env;
1948 char *retlist = (
char *)__kmp_allocate((len + 1) *
sizeof(char));
1949 memcpy(retlist, env, len *
sizeof(
char));
1950 retlist[len] =
'\0';
1951 *proclist = retlist;
1961 static kmp_setting_t *__kmp_affinity_notype = NULL;
1964 __kmp_parse_affinity_env(
char const * name,
char const * value,
1965 enum affinity_type * out_type,
1966 char ** out_proclist,
1970 enum affinity_gran * out_gran,
1971 int * out_gran_levels,
1977 char * buffer = NULL;
1987 int max_proclist = 0;
1994 KMP_ASSERT( value != NULL );
1996 if ( TCR_4(__kmp_init_middle) ) {
1997 KMP_WARNING( EnvMiddleWarn, name );
1998 __kmp_env_toPrint( name, 0 );
2001 __kmp_env_toPrint( name, 1 );
2003 buffer = __kmp_str_format(
"%s", value );
2015 #define EMIT_WARN(skip,errlist) \
2019 SKIP_TO(next, ','); \
2023 KMP_WARNING errlist; \
2026 if (ch == ',') next++; \
2031 #define _set_param(_guard,_var,_val) \
2033 if ( _guard == 0 ) { \
2036 EMIT_WARN( FALSE, ( AffParamDefined, name, start ) ); \
2041 #define set_type(val) _set_param( type, *out_type, val )
2042 #define set_verbose(val) _set_param( verbose, *out_verbose, val )
2043 #define set_warnings(val) _set_param( warnings, *out_warn, val )
2044 #define set_respect(val) _set_param( respect, *out_respect, val )
2045 #define set_dups(val) _set_param( dups, *out_dups, val )
2046 #define set_proclist(val) _set_param( proclist, *out_proclist, val )
2048 #define set_gran(val,levels) \
2050 if ( gran == 0 ) { \
2052 *out_gran_levels = levels; \
2054 EMIT_WARN( FALSE, ( AffParamDefined, name, start ) ); \
2060 KMP_DEBUG_ASSERT( ( __kmp_nested_proc_bind.bind_types != NULL )
2061 && ( __kmp_nested_proc_bind.used > 0 ) );
2062 if ( ( __kmp_affinity_notype != NULL )
2063 && ( ( __kmp_nested_proc_bind.bind_types[0] == proc_bind_default )
2064 || ( __kmp_nested_proc_bind.bind_types[0] == proc_bind_intel ) ) ) {
2069 while ( *buf !=
'\0' ) {
2072 if (__kmp_match_str(
"none", buf, (
const char **)&next)) {
2073 set_type( affinity_none );
2075 }
else if (__kmp_match_str(
"scatter", buf, (
const char **)&next)) {
2076 set_type( affinity_scatter );
2078 }
else if (__kmp_match_str(
"compact", buf, (
const char **)&next)) {
2079 set_type( affinity_compact );
2081 }
else if (__kmp_match_str(
"logical", buf, (
const char **)&next)) {
2082 set_type( affinity_logical );
2084 }
else if (__kmp_match_str(
"physical", buf, (
const char **)&next)) {
2085 set_type( affinity_physical );
2087 }
else if (__kmp_match_str(
"explicit", buf, (
const char **)&next)) {
2088 set_type( affinity_explicit );
2091 }
else if (__kmp_match_str(
"balanced", buf, (
const char **)&next)) {
2092 set_type( affinity_balanced );
2095 }
else if (__kmp_match_str(
"disabled", buf, (
const char **)&next)) {
2096 set_type( affinity_disabled );
2098 }
else if (__kmp_match_str(
"verbose", buf, (
const char **)&next)) {
2099 set_verbose( TRUE );
2101 }
else if (__kmp_match_str(
"noverbose", buf, (
const char **)&next)) {
2102 set_verbose( FALSE );
2104 }
else if (__kmp_match_str(
"warnings", buf, (
const char **)&next)) {
2105 set_warnings( TRUE );
2107 }
else if (__kmp_match_str(
"nowarnings", buf, (
const char **)&next)) {
2108 set_warnings( FALSE );
2110 }
else if (__kmp_match_str(
"respect", buf, (
const char **)&next)) {
2111 set_respect( TRUE );
2113 }
else if (__kmp_match_str(
"norespect", buf, (
const char **)&next)) {
2114 set_respect( FALSE );
2116 }
else if (__kmp_match_str(
"duplicates", buf, (
const char **)&next)
2117 || __kmp_match_str(
"dups", buf, (
const char **)&next)) {
2120 }
else if (__kmp_match_str(
"noduplicates", buf, (
const char **)&next)
2121 || __kmp_match_str(
"nodups", buf, (
const char **)&next)) {
2124 }
else if (__kmp_match_str(
"granularity", buf, (
const char **)&next)
2125 || __kmp_match_str(
"gran", buf, (
const char **)&next)) {
2128 EMIT_WARN( TRUE, ( AffInvalidParam, name, start ) );
2135 if (__kmp_match_str(
"fine", buf, (
const char **)&next)) {
2136 set_gran( affinity_gran_fine, -1 );
2138 }
else if (__kmp_match_str(
"thread", buf, (
const char **)&next)) {
2139 set_gran( affinity_gran_thread, -1 );
2141 }
else if (__kmp_match_str(
"core", buf, (
const char **)&next)) {
2142 set_gran( affinity_gran_core, -1 );
2144 }
else if (__kmp_match_str(
"package", buf, (
const char **)&next)) {
2145 set_gran( affinity_gran_package, -1 );
2147 }
else if (__kmp_match_str(
"node", buf, (
const char **)&next)) {
2148 set_gran( affinity_gran_node, -1 );
2150 # if KMP_OS_WINDOWS && KMP_ARCH_X86_64
2151 }
else if (__kmp_match_str(
"group", buf, (
const char **)&next)) {
2152 set_gran( affinity_gran_group, -1 );
2155 }
else if ((*buf >=
'0') && (*buf <=
'9')) {
2159 n = __kmp_str_to_int( buf, *next );
2162 set_gran( affinity_gran_default, n );
2164 EMIT_WARN( TRUE, ( AffInvalidParam, name, start ) );
2167 }
else if (__kmp_match_str(
"proclist", buf, (
const char **)&next)) {
2168 char *temp_proclist;
2172 EMIT_WARN( TRUE, ( AffInvalidParam, name, start ) );
2178 EMIT_WARN( TRUE, ( AffInvalidParam, name, start ) );
2183 if (! __kmp_parse_affinity_proc_id_list(name, buf,
2184 (
const char **)&next, &temp_proclist)) {
2189 if (*next ==
']') next++;
2191 if (*next ==
',') next++;
2196 EMIT_WARN( TRUE, ( AffInvalidParam, name, start ) );
2200 set_proclist( temp_proclist );
2201 }
else if ((*buf >=
'0') && (*buf <=
'9')) {
2206 n = __kmp_str_to_int( buf, *next );
2210 number[ count ] = n;
2212 KMP_WARNING( AffManyParams, name, start );
2216 EMIT_WARN( TRUE, ( AffInvalidParam, name, start ) );
2225 else if (*next !=
'\0') {
2226 const char *temp = next;
2227 EMIT_WARN( TRUE, ( ParseExtraCharsWarn, name, temp ) );
2239 #undef set_granularity
2241 KMP_INTERNAL_FREE( buffer );
2245 KMP_WARNING( AffProcListNoType, name );
2246 __kmp_affinity_type = affinity_explicit;
2248 else if ( __kmp_affinity_type != affinity_explicit ) {
2249 KMP_WARNING( AffProcListNotExplicit, name );
2250 KMP_ASSERT( *out_proclist != NULL );
2251 KMP_INTERNAL_FREE( *out_proclist );
2252 *out_proclist = NULL;
2255 switch ( *out_type ) {
2256 case affinity_logical:
2257 case affinity_physical: {
2259 *out_offset = number[ 0 ];
2262 KMP_WARNING( AffManyParamsForLogic, name, number[ 1 ] );
2266 case affinity_balanced: {
2268 *out_compact = number[ 0 ];
2271 *out_offset = number[ 1 ];
2275 if( __kmp_affinity_gran != affinity_gran_default && __kmp_affinity_gran != affinity_gran_fine
2276 && __kmp_affinity_gran != affinity_gran_thread && __kmp_affinity_gran != affinity_gran_core ) {
2277 if( __kmp_affinity_verbose || __kmp_affinity_warnings ) {
2278 KMP_WARNING( AffGranUsing,
"KMP_AFFINITY",
"core" );
2280 __kmp_affinity_gran = affinity_gran_fine;
2284 case affinity_scatter:
2285 case affinity_compact: {
2287 *out_compact = number[ 0 ];
2290 *out_offset = number[ 1 ];
2293 case affinity_explicit: {
2294 if ( *out_proclist == NULL ) {
2295 KMP_WARNING( AffNoProcList, name );
2296 __kmp_affinity_type = affinity_none;
2299 KMP_WARNING( AffNoParam, name,
"explicit" );
2302 case affinity_none: {
2304 KMP_WARNING( AffNoParam, name,
"none" );
2307 case affinity_disabled: {
2309 KMP_WARNING( AffNoParam, name,
"disabled" );
2312 case affinity_default: {
2314 KMP_WARNING( AffNoParam, name,
"default" );
2324 __kmp_stg_parse_affinity(
char const * name,
char const * value,
void * data )
2326 kmp_setting_t **rivals = (kmp_setting_t **) data;
2329 rc = __kmp_stg_check_rivals( name, value, rivals );
2334 __kmp_parse_affinity_env( name, value, & __kmp_affinity_type,
2335 & __kmp_affinity_proclist, & __kmp_affinity_verbose,
2336 & __kmp_affinity_warnings, & __kmp_affinity_respect_mask,
2337 & __kmp_affinity_gran, & __kmp_affinity_gran_levels,
2338 & __kmp_affinity_dups, & __kmp_affinity_compact,
2339 & __kmp_affinity_offset );
2344 __kmp_stg_print_affinity( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
2345 if( __kmp_env_format ) {
2346 KMP_STR_BUF_PRINT_NAME_EX(name);
2348 __kmp_str_buf_print( buffer,
" %s='", name );
2350 if ( __kmp_affinity_verbose ) {
2351 __kmp_str_buf_print( buffer,
"%s,",
"verbose");
2353 __kmp_str_buf_print( buffer,
"%s,",
"noverbose");
2355 if ( __kmp_affinity_warnings ) {
2356 __kmp_str_buf_print( buffer,
"%s,",
"warnings");
2358 __kmp_str_buf_print( buffer,
"%s,",
"nowarnings");
2360 if ( KMP_AFFINITY_CAPABLE() ) {
2361 if ( __kmp_affinity_respect_mask ) {
2362 __kmp_str_buf_print( buffer,
"%s,",
"respect");
2364 __kmp_str_buf_print( buffer,
"%s,",
"norespect");
2366 switch ( __kmp_affinity_gran ) {
2367 case affinity_gran_default:
2368 __kmp_str_buf_print( buffer,
"%s",
"granularity=default,");
2370 case affinity_gran_fine:
2371 __kmp_str_buf_print( buffer,
"%s",
"granularity=fine,");
2373 case affinity_gran_thread:
2374 __kmp_str_buf_print( buffer,
"%s",
"granularity=thread,");
2376 case affinity_gran_core:
2377 __kmp_str_buf_print( buffer,
"%s",
"granularity=core,");
2379 case affinity_gran_package:
2380 __kmp_str_buf_print( buffer,
"%s",
"granularity=package,");
2382 case affinity_gran_node:
2383 __kmp_str_buf_print( buffer,
"%s",
"granularity=node,");
2385 # if KMP_OS_WINDOWS && KMP_ARCH_X86_64
2386 case affinity_gran_group:
2387 __kmp_str_buf_print( buffer,
"%s",
"granularity=group,");
2391 if ( __kmp_affinity_dups ) {
2392 __kmp_str_buf_print( buffer,
"%s,",
"duplicates");
2394 __kmp_str_buf_print( buffer,
"%s,",
"noduplicates");
2397 if ( ! KMP_AFFINITY_CAPABLE() ) {
2398 __kmp_str_buf_print( buffer,
"%s",
"disabled" );
2400 else switch ( __kmp_affinity_type ){
2402 __kmp_str_buf_print( buffer,
"%s",
"none");
2404 case affinity_physical:
2405 __kmp_str_buf_print( buffer,
"%s,%d",
"physical",
2406 __kmp_affinity_offset );
2408 case affinity_logical:
2409 __kmp_str_buf_print( buffer,
"%s,%d",
"logical",
2410 __kmp_affinity_offset );
2412 case affinity_compact:
2413 __kmp_str_buf_print( buffer,
"%s,%d,%d",
"compact",
2414 __kmp_affinity_compact, __kmp_affinity_offset );
2416 case affinity_scatter:
2417 __kmp_str_buf_print( buffer,
"%s,%d,%d",
"scatter",
2418 __kmp_affinity_compact, __kmp_affinity_offset );
2420 case affinity_explicit:
2421 __kmp_str_buf_print( buffer,
"%s=[%s],%s",
"proclist",
2422 __kmp_affinity_proclist,
"explicit" );
2425 case affinity_balanced:
2426 __kmp_str_buf_print( buffer,
"%s,%d,%d",
"balanced",
2427 __kmp_affinity_compact, __kmp_affinity_offset );
2430 case affinity_disabled:
2431 __kmp_str_buf_print( buffer,
"%s",
"disabled");
2433 case affinity_default:
2434 __kmp_str_buf_print( buffer,
"%s",
"default");
2437 __kmp_str_buf_print( buffer,
"%s",
"<unknown>");
2440 __kmp_str_buf_print( buffer,
"'\n" );
2443 # ifdef KMP_GOMP_COMPAT
2446 __kmp_stg_parse_gomp_cpu_affinity(
char const * name,
char const * value,
void * data )
2448 const char * next = NULL;
2449 char * temp_proclist;
2450 kmp_setting_t **rivals = (kmp_setting_t **) data;
2453 rc = __kmp_stg_check_rivals( name, value, rivals );
2458 if ( TCR_4(__kmp_init_middle) ) {
2459 KMP_WARNING( EnvMiddleWarn, name );
2460 __kmp_env_toPrint( name, 0 );
2464 __kmp_env_toPrint( name, 1 );
2466 if ( __kmp_parse_affinity_proc_id_list( name, value, &next,
2469 if (*next ==
'\0') {
2473 __kmp_affinity_proclist = temp_proclist;
2474 __kmp_affinity_type = affinity_explicit;
2475 __kmp_affinity_gran = affinity_gran_fine;
2478 KMP_WARNING( AffSyntaxError, name );
2479 if (temp_proclist != NULL) {
2480 KMP_INTERNAL_FREE((
void *)temp_proclist);
2488 __kmp_affinity_type = affinity_none;
2520 __kmp_parse_subplace_list(
const char *var,
const char **scan )
2525 int start, count, stride;
2531 if ((**scan <
'0') || (**scan >
'9')) {
2532 KMP_WARNING( SyntaxErrorUsing, var,
"\"threads\"" );
2537 start = __kmp_str_to_int(*scan, *next);
2538 KMP_ASSERT(start >= 0);
2545 if (**scan ==
'}') {
2548 if (**scan ==
',') {
2552 if (**scan !=
':') {
2553 KMP_WARNING( SyntaxErrorUsing, var,
"\"threads\"" );
2562 if ((**scan <
'0') || (**scan >
'9')) {
2563 KMP_WARNING( SyntaxErrorUsing, var,
"\"threads\"" );
2568 count = __kmp_str_to_int(*scan, *next);
2569 KMP_ASSERT(count >= 0);
2576 if (**scan ==
'}') {
2579 if (**scan ==
',') {
2583 if (**scan !=
':') {
2584 KMP_WARNING( SyntaxErrorUsing, var,
"\"threads\"" );
2595 if (**scan ==
'+') {
2599 if (**scan ==
'-') {
2607 if ((**scan <
'0') || (**scan >
'9')) {
2608 KMP_WARNING( SyntaxErrorUsing, var,
"\"threads\"" );
2613 stride = __kmp_str_to_int(*scan, *next);
2614 KMP_ASSERT(stride >= 0);
2622 if (**scan ==
'}') {
2625 if (**scan ==
',') {
2630 KMP_WARNING( SyntaxErrorUsing, var,
"\"threads\"" );
2637 __kmp_parse_place(
const char *var,
const char ** scan )
2645 if (**scan ==
'{') {
2647 if (! __kmp_parse_subplace_list(var, scan)) {
2650 if (**scan !=
'}') {
2651 KMP_WARNING( SyntaxErrorUsing, var,
"\"threads\"" );
2656 else if (**scan ==
'!') {
2658 return __kmp_parse_place(var, scan);
2660 else if ((**scan >=
'0') && (**scan <=
'9')) {
2663 int proc = __kmp_str_to_int(*scan, *next);
2664 KMP_ASSERT(proc >= 0);
2668 KMP_WARNING( SyntaxErrorUsing, var,
"\"threads\"" );
2675 __kmp_parse_place_list(
const char *var,
const char *env,
char **place_list )
2677 const char *scan = env;
2678 const char *next = scan;
2681 int start, count, stride;
2683 if (! __kmp_parse_place(var, &scan)) {
2691 if (*scan ==
'\0') {
2699 KMP_WARNING( SyntaxErrorUsing, var,
"\"threads\"" );
2708 if ((*scan <
'0') || (*scan >
'9')) {
2709 KMP_WARNING( SyntaxErrorUsing, var,
"\"threads\"" );
2714 count = __kmp_str_to_int(scan, *next);
2715 KMP_ASSERT(count >= 0);
2722 if (*scan ==
'\0') {
2730 KMP_WARNING( SyntaxErrorUsing, var,
"\"threads\"" );
2753 if ((*scan <
'0') || (*scan >
'9')) {
2754 KMP_WARNING( SyntaxErrorUsing, var,
"\"threads\"" );
2759 stride = __kmp_str_to_int(scan, *next);
2760 KMP_ASSERT(stride >= 0);
2768 if (*scan ==
'\0') {
2776 KMP_WARNING( SyntaxErrorUsing, var,
"\"threads\"" );
2781 int len = scan - env;
2782 char *retlist = (
char *)__kmp_allocate((len + 1) *
sizeof(char));
2783 memcpy(retlist, env, len *
sizeof(
char));
2784 retlist[len] =
'\0';
2785 *place_list = retlist;
2791 __kmp_stg_parse_places(
char const * name,
char const * value,
void * data )
2794 const char *scan = value;
2795 const char *next = scan;
2796 const char *kind =
"\"threads\"";
2800 if ( __kmp_match_str(
"threads", scan, &next ) ) {
2802 __kmp_affinity_type = affinity_compact;
2803 __kmp_affinity_gran = affinity_gran_thread;
2804 __kmp_affinity_dups = FALSE;
2805 kind =
"\"threads\"";
2807 else if ( __kmp_match_str(
"cores", scan, &next ) ) {
2809 __kmp_affinity_type = affinity_compact;
2810 __kmp_affinity_gran = affinity_gran_core;
2811 __kmp_affinity_dups = FALSE;
2814 else if ( __kmp_match_str(
"sockets", scan, &next ) ) {
2816 __kmp_affinity_type = affinity_compact;
2817 __kmp_affinity_gran = affinity_gran_package;
2818 __kmp_affinity_dups = FALSE;
2819 kind =
"\"sockets\"";
2822 if ( __kmp_affinity_proclist != NULL ) {
2823 KMP_INTERNAL_FREE( (
void *)__kmp_affinity_proclist );
2824 __kmp_affinity_proclist = NULL;
2826 if ( __kmp_parse_place_list( name, value, &__kmp_affinity_proclist ) ) {
2827 __kmp_affinity_type = affinity_explicit;
2828 __kmp_affinity_gran = affinity_gran_fine;
2829 __kmp_affinity_dups = FALSE;
2835 if ( *scan ==
'\0' ) {
2842 if ( *scan !=
'(' ) {
2843 KMP_WARNING( SyntaxErrorUsing, name, kind );
2851 count = __kmp_str_to_int(scan, *next);
2852 KMP_ASSERT(count >= 0);
2856 if ( *scan !=
')' ) {
2857 KMP_WARNING( SyntaxErrorUsing, name, kind );
2863 if ( *scan !=
'\0' ) {
2864 KMP_WARNING( ParseExtraCharsWarn, name, scan );
2866 __kmp_affinity_num_places = count;
2870 __kmp_stg_print_places( kmp_str_buf_t * buffer,
char const * name,
2873 if( __kmp_env_format ) {
2874 KMP_STR_BUF_PRINT_NAME;
2876 __kmp_str_buf_print( buffer,
" %s", name );
2878 if ( ( __kmp_nested_proc_bind.used == 0 )
2879 || ( __kmp_nested_proc_bind.bind_types == NULL )
2880 || ( __kmp_nested_proc_bind.bind_types[0] == proc_bind_false )
2881 || ( __kmp_nested_proc_bind.bind_types[0] == proc_bind_intel ) ) {
2882 __kmp_str_buf_print( buffer,
": %s\n", KMP_I18N_STR( NotDefined ) );
2884 else if ( __kmp_affinity_type == affinity_explicit ) {
2885 if ( __kmp_affinity_proclist != NULL ) {
2886 __kmp_str_buf_print( buffer,
"='%s'\n", __kmp_affinity_proclist );
2889 __kmp_str_buf_print( buffer,
": %s\n", KMP_I18N_STR( NotDefined ) );
2892 else if ( __kmp_affinity_type == affinity_compact ) {
2894 if ( __kmp_affinity_num_masks > 0 ) {
2895 num = __kmp_affinity_num_masks;
2897 else if ( __kmp_affinity_num_places > 0 ) {
2898 num = __kmp_affinity_num_places;
2903 if ( __kmp_affinity_gran == affinity_gran_thread ) {
2905 __kmp_str_buf_print( buffer,
"='threads(%d)'\n", num );
2908 __kmp_str_buf_print( buffer,
"='threads'\n" );
2911 else if ( __kmp_affinity_gran == affinity_gran_core ) {
2913 __kmp_str_buf_print( buffer,
"='cores(%d)' \n", num );
2916 __kmp_str_buf_print( buffer,
"='cores'\n" );
2919 else if ( __kmp_affinity_gran == affinity_gran_package ) {
2921 __kmp_str_buf_print( buffer,
"='sockets(%d)'\n", num );
2924 __kmp_str_buf_print( buffer,
"='sockets'\n" );
2928 __kmp_str_buf_print( buffer,
": %s\n", KMP_I18N_STR( NotDefined ) );
2932 __kmp_str_buf_print( buffer,
": %s\n", KMP_I18N_STR( NotDefined ) );
2938 # if OMP_30_ENABLED && (! OMP_40_ENABLED)
2941 __kmp_stg_parse_proc_bind(
char const * name,
char const * value,
void * data )
2944 kmp_setting_t **rivals = (kmp_setting_t **) data;
2947 rc = __kmp_stg_check_rivals( name, value, rivals );
2955 __kmp_stg_parse_bool( name, value, & enabled );
2960 __kmp_affinity_type = affinity_scatter;
2961 __kmp_affinity_gran = affinity_gran_core;
2964 __kmp_affinity_type = affinity_none;
2972 __kmp_stg_parse_topology_method(
char const * name,
char const * value,
2974 if ( __kmp_str_match(
"all", 1, value ) ) {
2975 __kmp_affinity_top_method = affinity_top_method_all;
2977 # if KMP_ARCH_X86 || KMP_ARCH_X86_64
2978 else if ( __kmp_str_match(
"x2apic id", 9, value )
2979 || __kmp_str_match(
"x2apic_id", 9, value )
2980 || __kmp_str_match(
"x2apic-id", 9, value )
2981 || __kmp_str_match(
"x2apicid", 8, value )
2982 || __kmp_str_match(
"cpuid leaf 11", 13, value )
2983 || __kmp_str_match(
"cpuid_leaf_11", 13, value )
2984 || __kmp_str_match(
"cpuid-leaf-11", 13, value )
2985 || __kmp_str_match(
"cpuid leaf11", 12, value )
2986 || __kmp_str_match(
"cpuid_leaf11", 12, value )
2987 || __kmp_str_match(
"cpuid-leaf11", 12, value )
2988 || __kmp_str_match(
"cpuidleaf 11", 12, value )
2989 || __kmp_str_match(
"cpuidleaf_11", 12, value )
2990 || __kmp_str_match(
"cpuidleaf-11", 12, value )
2991 || __kmp_str_match(
"cpuidleaf11", 11, value )
2992 || __kmp_str_match(
"cpuid 11", 8, value )
2993 || __kmp_str_match(
"cpuid_11", 8, value )
2994 || __kmp_str_match(
"cpuid-11", 8, value )
2995 || __kmp_str_match(
"cpuid11", 7, value )
2996 || __kmp_str_match(
"leaf 11", 7, value )
2997 || __kmp_str_match(
"leaf_11", 7, value )
2998 || __kmp_str_match(
"leaf-11", 7, value )
2999 || __kmp_str_match(
"leaf11", 6, value ) ) {
3000 __kmp_affinity_top_method = affinity_top_method_x2apicid;
3002 else if ( __kmp_str_match(
"apic id", 7, value )
3003 || __kmp_str_match(
"apic_id", 7, value )
3004 || __kmp_str_match(
"apic-id", 7, value )
3005 || __kmp_str_match(
"apicid", 6, value )
3006 || __kmp_str_match(
"cpuid leaf 4", 12, value )
3007 || __kmp_str_match(
"cpuid_leaf_4", 12, value )
3008 || __kmp_str_match(
"cpuid-leaf-4", 12, value )
3009 || __kmp_str_match(
"cpuid leaf4", 11, value )
3010 || __kmp_str_match(
"cpuid_leaf4", 11, value )
3011 || __kmp_str_match(
"cpuid-leaf4", 11, value )
3012 || __kmp_str_match(
"cpuidleaf 4", 11, value )
3013 || __kmp_str_match(
"cpuidleaf_4", 11, value )
3014 || __kmp_str_match(
"cpuidleaf-4", 11, value )
3015 || __kmp_str_match(
"cpuidleaf4", 10, value )
3016 || __kmp_str_match(
"cpuid 4", 7, value )
3017 || __kmp_str_match(
"cpuid_4", 7, value )
3018 || __kmp_str_match(
"cpuid-4", 7, value )
3019 || __kmp_str_match(
"cpuid4", 6, value )
3020 || __kmp_str_match(
"leaf 4", 6, value )
3021 || __kmp_str_match(
"leaf_4", 6, value )
3022 || __kmp_str_match(
"leaf-4", 6, value )
3023 || __kmp_str_match(
"leaf4", 5, value ) ) {
3024 __kmp_affinity_top_method = affinity_top_method_apicid;
3027 else if ( __kmp_str_match(
"/proc/cpuinfo", 2, value )
3028 || __kmp_str_match(
"cpuinfo", 5, value )) {
3029 __kmp_affinity_top_method = affinity_top_method_cpuinfo;
3031 # if KMP_OS_WINDOWS && KMP_ARCH_X86_64
3032 else if ( __kmp_str_match(
"group", 1, value ) ) {
3033 __kmp_affinity_top_method = affinity_top_method_group;
3036 else if ( __kmp_str_match(
"flat", 1, value ) ) {
3037 __kmp_affinity_top_method = affinity_top_method_flat;
3040 KMP_WARNING( StgInvalidValue, name, value );
3045 __kmp_stg_print_topology_method( kmp_str_buf_t * buffer,
char const * name,
3048 char const * value = NULL;
3050 switch ( __kmp_affinity_top_method ) {
3051 case affinity_top_method_default:
3055 case affinity_top_method_all:
3059 # if KMP_ARCH_X86 || KMP_ARCH_X86_64
3060 case affinity_top_method_x2apicid:
3061 value =
"x2APIC id";
3064 case affinity_top_method_apicid:
3069 case affinity_top_method_cpuinfo:
3073 # if KMP_OS_WINDOWS && KMP_ARCH_X86_64
3074 case affinity_top_method_group:
3079 case affinity_top_method_flat:
3084 if ( value != NULL ) {
3085 __kmp_stg_print_str( buffer, name, value );
3093 #error "Unknown or unsupported OS"
3104 __kmp_stg_parse_proc_bind(
char const * name,
char const * value,
void * data )
3106 kmp_setting_t **rivals = (kmp_setting_t **) data;
3109 rc = __kmp_stg_check_rivals( name, value, rivals );
3117 KMP_DEBUG_ASSERT( (__kmp_nested_proc_bind.bind_types != NULL)
3118 && ( __kmp_nested_proc_bind.used > 0 ) );
3120 const char *buf = value;
3124 if ( (*buf >=
'0') && (*buf <=
'9') ) {
3126 SKIP_DIGITS( next );
3127 num = __kmp_str_to_int( buf, *next );
3128 KMP_ASSERT( num >= 0 );
3137 if ( __kmp_match_str(
"disabled", buf, &next ) ) {
3140 # if KMP_OS_LINUX || KMP_OS_WINDOWS
3141 __kmp_affinity_type = affinity_disabled;
3143 __kmp_nested_proc_bind.used = 1;
3144 __kmp_nested_proc_bind.bind_types[0] = proc_bind_disabled;
3146 else if ( ( num == (
int)proc_bind_false )
3147 || __kmp_match_str(
"false", buf, &next ) ) {
3150 # if KMP_OS_LINUX || KMP_OS_WINDOWS
3151 __kmp_affinity_type = affinity_none;
3153 __kmp_nested_proc_bind.used = 1;
3154 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
3156 else if ( ( num == (
int)proc_bind_true )
3157 || __kmp_match_str(
"true", buf, &next ) ) {
3160 __kmp_nested_proc_bind.used = 1;
3165 __kmp_nested_proc_bind.bind_types[0] = proc_bind_spread;
3173 for ( scan = buf; *scan !=
'\0'; scan++ ) {
3174 if ( *scan ==
',' ) {
3182 if ( __kmp_nested_proc_bind.size < nelem ) {
3183 __kmp_nested_proc_bind.bind_types = (kmp_proc_bind_t *)
3184 KMP_INTERNAL_REALLOC( __kmp_nested_proc_bind.bind_types,
3185 sizeof(kmp_proc_bind_t) * nelem );
3186 if ( __kmp_nested_proc_bind.bind_types == NULL ) {
3187 KMP_FATAL( MemoryAllocFailed );
3189 __kmp_nested_proc_bind.size = nelem;
3191 __kmp_nested_proc_bind.used = nelem;
3198 enum kmp_proc_bind_t bind;
3200 if ( ( num == (
int)proc_bind_master )
3201 || __kmp_match_str(
"master", buf, &next ) ) {
3204 bind = proc_bind_master;
3206 else if ( ( num == (
int)proc_bind_close )
3207 || __kmp_match_str(
"close", buf, &next ) ) {
3210 bind = proc_bind_close;
3212 else if ( ( num == (
int)proc_bind_spread )
3213 || __kmp_match_str(
"spread", buf, &next ) ) {
3216 bind = proc_bind_spread;
3219 KMP_WARNING( StgInvalidValue, name, value );
3220 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
3221 __kmp_nested_proc_bind.used = 1;
3225 __kmp_nested_proc_bind.bind_types[i++] = bind;
3229 KMP_DEBUG_ASSERT( *buf ==
',' );
3236 if ( (*buf >=
'0') && (*buf <=
'9') ) {
3238 SKIP_DIGITS( next );
3239 num = __kmp_str_to_int( buf, *next );
3240 KMP_ASSERT( num >= 0 );
3250 if ( *buf !=
'\0' ) {
3251 KMP_WARNING( ParseExtraCharsWarn, name, buf );
3257 __kmp_stg_print_proc_bind( kmp_str_buf_t * buffer,
char const * name,
3260 int nelem = __kmp_nested_proc_bind.used;
3261 if( __kmp_env_format ) {
3262 KMP_STR_BUF_PRINT_NAME;
3264 __kmp_str_buf_print( buffer,
" %s", name );
3267 __kmp_str_buf_print( buffer,
": %s\n", KMP_I18N_STR( NotDefined ) );
3271 __kmp_str_buf_print( buffer,
"='", name );
3272 for ( i = 0; i < nelem; i++ ) {
3273 switch ( __kmp_nested_proc_bind.bind_types[i] ) {
3274 case proc_bind_false:
3275 __kmp_str_buf_print( buffer,
"false" );
3278 case proc_bind_true:
3279 __kmp_str_buf_print( buffer,
"true" );
3282 case proc_bind_master:
3283 __kmp_str_buf_print( buffer,
"master" );
3286 case proc_bind_close:
3287 __kmp_str_buf_print( buffer,
"close" );
3290 case proc_bind_spread:
3291 __kmp_str_buf_print( buffer,
"spread" );
3294 case proc_bind_disabled:
3295 __kmp_str_buf_print( buffer,
"disabled" );
3298 case proc_bind_intel:
3299 __kmp_str_buf_print( buffer,
"intel" );
3302 case proc_bind_default:
3303 __kmp_str_buf_print( buffer,
"default" );
3306 if ( i < nelem - 1 ) {
3307 __kmp_str_buf_print( buffer,
"," );
3310 __kmp_str_buf_print( buffer,
"'\n" );
3322 __kmp_stg_parse_omp_dynamic(
char const * name,
char const * value,
void * data )
3324 __kmp_stg_parse_bool( name, value, & (__kmp_global.g.g_dynamic) );
3328 __kmp_stg_print_omp_dynamic( kmp_str_buf_t * buffer,
char const * name,
void * data )
3330 __kmp_stg_print_bool( buffer, name, __kmp_global.g.g_dynamic );
3334 __kmp_stg_parse_kmp_dynamic_mode(
char const * name,
char const * value,
void * data )
3336 if ( TCR_4(__kmp_init_parallel) ) {
3337 KMP_WARNING( EnvParallelWarn, name );
3338 __kmp_env_toPrint( name, 0 );
3341 #ifdef USE_LOAD_BALANCE
3342 else if ( __kmp_str_match(
"load balance", 2, value )
3343 || __kmp_str_match(
"load_balance", 2, value )
3344 || __kmp_str_match(
"load-balance", 2, value )
3345 || __kmp_str_match(
"loadbalance", 2, value )
3346 || __kmp_str_match(
"balance", 1, value ) ) {
3347 __kmp_global.g.g_dynamic_mode = dynamic_load_balance;
3350 else if ( __kmp_str_match(
"thread limit", 1, value )
3351 || __kmp_str_match(
"thread_limit", 1, value )
3352 || __kmp_str_match(
"thread-limit", 1, value )
3353 || __kmp_str_match(
"threadlimit", 1, value )
3354 || __kmp_str_match(
"limit", 2, value ) ) {
3355 __kmp_global.g.g_dynamic_mode = dynamic_thread_limit;
3357 else if ( __kmp_str_match(
"random", 1, value ) ) {
3358 __kmp_global.g.g_dynamic_mode = dynamic_random;
3361 KMP_WARNING( StgInvalidValue, name, value );
3366 __kmp_stg_print_kmp_dynamic_mode( kmp_str_buf_t * buffer,
char const * name,
void * data )
3369 if ( __kmp_global.g.g_dynamic_mode == dynamic_default ) {
3370 __kmp_str_buf_print( buffer,
" %s: %s \n", name, KMP_I18N_STR( NotDefined ) );
3372 # ifdef USE_LOAD_BALANCE
3373 else if ( __kmp_global.g.g_dynamic_mode == dynamic_load_balance ) {
3374 __kmp_stg_print_str( buffer, name,
"load balance" );
3377 else if ( __kmp_global.g.g_dynamic_mode == dynamic_thread_limit ) {
3378 __kmp_stg_print_str( buffer, name,
"thread limit" );
3380 else if ( __kmp_global.g.g_dynamic_mode == dynamic_random ) {
3381 __kmp_stg_print_str( buffer, name,
"random" );
3390 #ifdef USE_LOAD_BALANCE
3397 __kmp_stg_parse_ld_balance_interval(
char const * name,
char const * value,
void * data )
3399 double interval = __kmp_convert_to_double( value );
3400 if ( interval >= 0 ) {
3401 __kmp_load_balance_interval = interval;
3403 KMP_WARNING( StgInvalidValue, name, value );
3408 __kmp_stg_print_ld_balance_interval( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3410 __kmp_str_buf_print( buffer,
" %s=%8.6f\n", name, __kmp_load_balance_interval );
3423 __kmp_stg_parse_init_at_fork(
char const * name,
char const * value,
void * data ) {
3424 __kmp_stg_parse_bool( name, value, & __kmp_need_register_atfork );
3425 if ( __kmp_need_register_atfork ) {
3426 __kmp_need_register_atfork_specified = TRUE;
3431 __kmp_stg_print_init_at_fork( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3432 __kmp_stg_print_bool( buffer, name, __kmp_need_register_atfork_specified );
3440 __kmp_stg_parse_schedule(
char const * name,
char const * value,
void * data ) {
3442 if ( value != NULL ) {
3443 size_t length = strlen( value );
3444 if ( length > INT_MAX ) {
3445 KMP_WARNING( LongValue, name );
3448 if( value[ length - 1 ] ==
'"' || value[ length -1 ] ==
'\'' )
3449 KMP_WARNING( UnbalancedQuotes, name );
3453 semicolon = (
char *) strchr( value,
';' );
3454 if( *value && semicolon != value ) {
3455 char *comma = (
char *) strchr( value,
',' );
3462 if ( !__kmp_strcasecmp_with_sentinel(
"static", value, sentinel ) ) {
3463 if( !__kmp_strcasecmp_with_sentinel(
"greedy", comma,
';' ) ) {
3464 __kmp_static = kmp_sch_static_greedy;
3466 }
else if( !__kmp_strcasecmp_with_sentinel(
"balanced", comma,
';' ) ) {
3467 __kmp_static = kmp_sch_static_balanced;
3470 }
else if ( !__kmp_strcasecmp_with_sentinel(
"guided", value, sentinel ) ) {
3471 if ( !__kmp_strcasecmp_with_sentinel(
"iterative", comma,
';' ) ) {
3472 __kmp_guided = kmp_sch_guided_iterative_chunked;
3474 }
else if ( !__kmp_strcasecmp_with_sentinel(
"analytical", comma,
';' ) ) {
3476 __kmp_guided = kmp_sch_guided_analytical_chunked;
3480 KMP_WARNING( InvalidClause, name, value );
3482 KMP_WARNING( EmptyClause, name );
3483 }
while ( value = semicolon ? semicolon + 1 : NULL );
3490 __kmp_stg_print_schedule( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3491 if( __kmp_env_format ) {
3492 KMP_STR_BUF_PRINT_NAME_EX(name);
3494 __kmp_str_buf_print( buffer,
" %s='", name );
3496 if ( __kmp_static == kmp_sch_static_greedy ) {
3497 __kmp_str_buf_print( buffer,
"%s",
"static,greedy");
3498 }
else if ( __kmp_static == kmp_sch_static_balanced ) {
3499 __kmp_str_buf_print ( buffer,
"%s",
"static,balanced");
3501 if ( __kmp_guided == kmp_sch_guided_iterative_chunked ) {
3502 __kmp_str_buf_print( buffer,
";%s'\n",
"guided,iterative");
3503 }
else if ( __kmp_guided == kmp_sch_guided_analytical_chunked ) {
3504 __kmp_str_buf_print( buffer,
";%s'\n",
"guided,analytical");
3513 __kmp_stg_parse_omp_schedule(
char const * name,
char const * value,
void * data )
3517 length = strlen( value );
3519 char *comma = (
char *) strchr( value,
',' );
3520 if( value[ length - 1 ] ==
'"' || value[ length -1 ] ==
'\'')
3521 KMP_WARNING( UnbalancedQuotes, name );
3523 if (!__kmp_strcasecmp_with_sentinel(
"dynamic", value,
','))
3524 __kmp_sched = kmp_sch_dynamic_chunked;
3525 else if (!__kmp_strcasecmp_with_sentinel(
"guided", value,
','))
3529 else if (!__kmp_strcasecmp_with_sentinel(
"auto", value,
',')) {
3532 __kmp_msg( kmp_ms_warning, KMP_MSG( IgnoreChunk, name, comma ), __kmp_msg_null );
3536 #endif // OMP_30_ENABLED
3537 else if (!__kmp_strcasecmp_with_sentinel(
"trapezoidal", value,
','))
3538 __kmp_sched = kmp_sch_trapezoidal;
3539 else if (!__kmp_strcasecmp_with_sentinel(
"static", value,
','))
3541 #ifdef KMP_STATIC_STEAL_ENABLED
3542 else if (KMP_ARCH_X86_64 &&
3543 !__kmp_strcasecmp_with_sentinel(
"static_steal", value,
','))
3547 KMP_WARNING( StgInvalidValue, name, value );
3550 if( value && comma ) {
3551 __kmp_env_chunk = TRUE;
3554 __kmp_sched = kmp_sch_static_chunked;
3556 __kmp_chunk = __kmp_str_to_int( comma, 0 );
3557 if ( __kmp_chunk < 1 ) {
3558 __kmp_chunk = KMP_DEFAULT_CHUNK;
3559 __kmp_msg( kmp_ms_warning, KMP_MSG( InvalidChunk, name, comma ), __kmp_msg_null );
3560 KMP_INFORM( Using_int_Value, name, __kmp_chunk );
3566 }
else if ( __kmp_chunk > KMP_MAX_CHUNK ) {
3567 __kmp_chunk = KMP_MAX_CHUNK;
3568 __kmp_msg( kmp_ms_warning, KMP_MSG( LargeChunk, name, comma ), __kmp_msg_null );
3569 KMP_INFORM( Using_int_Value, name, __kmp_chunk );
3572 __kmp_env_chunk = FALSE;
3574 KMP_WARNING( EmptyString, name );
3576 K_DIAG(1, (
"__kmp_static == %d\n", __kmp_static))
3577 K_DIAG(1, ("__kmp_guided == %d\n", __kmp_guided))
3578 K_DIAG(1, ("__kmp_sched == %d\n", __kmp_sched))
3579 K_DIAG(1, ("__kmp_chunk == %d\n", __kmp_chunk))
3583 __kmp_stg_print_omp_schedule( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3584 if( __kmp_env_format ) {
3585 KMP_STR_BUF_PRINT_NAME_EX(name);
3587 __kmp_str_buf_print( buffer,
" %s='", name );
3589 if ( __kmp_chunk ) {
3590 switch ( __kmp_sched ) {
3591 case kmp_sch_dynamic_chunked:
3592 __kmp_str_buf_print( buffer,
"%s,%d'\n",
"dynamic", __kmp_chunk);
3594 case kmp_sch_guided_iterative_chunked:
3595 case kmp_sch_guided_analytical_chunked:
3596 __kmp_str_buf_print( buffer,
"%s,%d'\n",
"guided", __kmp_chunk);
3598 case kmp_sch_trapezoidal:
3599 __kmp_str_buf_print( buffer,
"%s,%d'\n",
"trapezoidal", __kmp_chunk);
3602 case kmp_sch_static_chunked:
3603 case kmp_sch_static_balanced:
3604 case kmp_sch_static_greedy:
3605 __kmp_str_buf_print( buffer,
"%s,%d'\n",
"static", __kmp_chunk);
3608 __kmp_str_buf_print( buffer,
"%s,%d'\n",
"static_steal", __kmp_chunk);
3611 __kmp_str_buf_print( buffer,
"%s,%d'\n",
"auto", __kmp_chunk);
3615 switch ( __kmp_sched ) {
3616 case kmp_sch_dynamic_chunked:
3617 __kmp_str_buf_print( buffer,
"%s'\n",
"dynamic");
3619 case kmp_sch_guided_iterative_chunked:
3620 case kmp_sch_guided_analytical_chunked:
3621 __kmp_str_buf_print( buffer,
"%s'\n",
"guided");
3623 case kmp_sch_trapezoidal:
3624 __kmp_str_buf_print( buffer,
"%s'\n",
"trapezoidal");
3627 case kmp_sch_static_chunked:
3628 case kmp_sch_static_balanced:
3629 case kmp_sch_static_greedy:
3630 __kmp_str_buf_print( buffer,
"%s'\n",
"static");
3633 __kmp_str_buf_print( buffer,
"%s'\n",
"static_steal");
3636 __kmp_str_buf_print( buffer,
"%s'\n",
"auto");
3647 __kmp_stg_parse_atomic_mode(
char const * name,
char const * value,
void * data ) {
3651 #ifdef KMP_GOMP_COMPAT
3654 __kmp_stg_parse_int( name, value, 0, max, & mode );
3658 __kmp_atomic_mode = mode;
3663 __kmp_stg_print_atomic_mode( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3664 __kmp_stg_print_int( buffer, name, __kmp_atomic_mode );
3673 __kmp_stg_parse_consistency_check(
char const * name,
char const * value,
void * data ) {
3674 if ( ! __kmp_strcasecmp_with_sentinel(
"all", value, 0 ) ) {
3678 __kmp_env_consistency_check = TRUE;
3679 }
else if ( ! __kmp_strcasecmp_with_sentinel(
"none", value, 0 ) ) {
3680 __kmp_env_consistency_check = FALSE;
3682 KMP_WARNING( StgInvalidValue, name, value );
3687 __kmp_stg_print_consistency_check( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3689 const char *value = NULL;
3691 if ( __kmp_env_consistency_check ) {
3697 if ( value != NULL ) {
3698 __kmp_stg_print_str( buffer, name, value );
3712 __kmp_stg_parse_itt_prepare_delay(
char const * name,
char const * value,
void * data )
3716 __kmp_stg_parse_int( name, value, 0, INT_MAX, & delay );
3717 __kmp_itt_prepare_delay = delay;
3721 __kmp_stg_print_itt_prepare_delay( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3722 __kmp_stg_print_uint64( buffer, name, __kmp_itt_prepare_delay );
3726 #endif // USE_ITT_NOTIFY
3734 __kmp_stg_parse_malloc_pool_incr(
char const * name,
char const * value,
void * data ) {
3735 __kmp_stg_parse_size(
3738 KMP_MIN_MALLOC_POOL_INCR,
3739 KMP_MAX_MALLOC_POOL_INCR,
3741 & __kmp_malloc_pool_incr,
3747 __kmp_stg_print_malloc_pool_incr( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3748 __kmp_stg_print_size( buffer, name, __kmp_malloc_pool_incr );
3760 __kmp_stg_parse_par_range_env(
char const * name,
char const * value,
void * data ) {
3761 __kmp_stg_parse_par_range(
3765 __kmp_par_range_routine,
3766 __kmp_par_range_filename,
3767 & __kmp_par_range_lb,
3768 & __kmp_par_range_ub
3773 __kmp_stg_print_par_range_env( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3774 if (__kmp_par_range != 0) {
3775 __kmp_stg_print_str( buffer, name, par_range_to_print );
3784 __kmp_stg_parse_yield_cycle(
char const * name,
char const * value,
void * data ) {
3785 int flag = __kmp_yield_cycle;
3786 __kmp_stg_parse_bool( name, value, & flag );
3787 __kmp_yield_cycle = flag;
3791 __kmp_stg_print_yield_cycle( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3792 __kmp_stg_print_bool( buffer, name, __kmp_yield_cycle );
3796 __kmp_stg_parse_yield_on(
char const * name,
char const * value,
void * data ) {
3797 __kmp_stg_parse_int( name, value, 2, INT_MAX, & __kmp_yield_on_count );
3801 __kmp_stg_print_yield_on( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3802 __kmp_stg_print_int( buffer, name, __kmp_yield_on_count );
3806 __kmp_stg_parse_yield_off(
char const * name,
char const * value,
void * data ) {
3807 __kmp_stg_parse_int( name, value, 2, INT_MAX, & __kmp_yield_off_count );
3811 __kmp_stg_print_yield_off( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3812 __kmp_stg_print_int( buffer, name, __kmp_yield_off_count );
3822 __kmp_stg_parse_init_wait(
char const * name,
char const * value,
void * data ) {
3824 KMP_ASSERT( ( __kmp_init_wait & 1 ) == 0 );
3825 wait = __kmp_init_wait / 2;
3826 __kmp_stg_parse_int( name, value, KMP_MIN_INIT_WAIT, KMP_MAX_INIT_WAIT, & wait );
3827 __kmp_init_wait = wait * 2;
3828 KMP_ASSERT( ( __kmp_init_wait & 1 ) == 0 );
3829 __kmp_yield_init = __kmp_init_wait;
3833 __kmp_stg_print_init_wait( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3834 __kmp_stg_print_int( buffer, name, __kmp_init_wait );
3838 __kmp_stg_parse_next_wait(
char const * name,
char const * value,
void * data ) {
3840 KMP_ASSERT( ( __kmp_next_wait & 1 ) == 0 );
3841 wait = __kmp_next_wait / 2;
3842 __kmp_stg_parse_int( name, value, KMP_MIN_NEXT_WAIT, KMP_MAX_NEXT_WAIT, & wait );
3843 __kmp_next_wait = wait * 2;
3844 KMP_ASSERT( ( __kmp_next_wait & 1 ) == 0 );
3845 __kmp_yield_next = __kmp_next_wait;
3849 __kmp_stg_print_next_wait( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3850 __kmp_stg_print_int( buffer, name, __kmp_next_wait );
3859 __kmp_stg_parse_gtid_mode(
char const * name,
char const * value,
void * data ) {
3870 #ifdef KMP_TDATA_GTID
3873 __kmp_stg_parse_int( name, value, 0, max, & mode );
3877 __kmp_adjust_gtid_mode = TRUE;
3880 __kmp_gtid_mode = mode;
3881 __kmp_adjust_gtid_mode = FALSE;
3886 __kmp_stg_print_gtid_mode( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3887 if ( __kmp_adjust_gtid_mode ) {
3888 __kmp_stg_print_int( buffer, name, 0 );
3891 __kmp_stg_print_int( buffer, name, __kmp_gtid_mode );
3901 __kmp_stg_parse_lock_block(
char const * name,
char const * value,
void * data ) {
3902 __kmp_stg_parse_int( name, value, 0, KMP_INT_MAX, & __kmp_num_locks_in_block );
3906 __kmp_stg_print_lock_block( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3907 __kmp_stg_print_int( buffer, name, __kmp_num_locks_in_block );
3915 __kmp_stg_parse_lock_kind(
char const * name,
char const * value,
void * data ) {
3916 if ( __kmp_init_user_locks ) {
3917 KMP_WARNING( EnvLockWarn, name );
3921 if ( __kmp_str_match(
"tas", 2, value )
3922 || __kmp_str_match(
"test and set", 2, value )
3923 || __kmp_str_match(
"test_and_set", 2, value )
3924 || __kmp_str_match(
"test-and-set", 2, value )
3925 || __kmp_str_match(
"test andset", 2, value )
3926 || __kmp_str_match(
"test_andset", 2, value )
3927 || __kmp_str_match(
"test-andset", 2, value )
3928 || __kmp_str_match(
"testand set", 2, value )
3929 || __kmp_str_match(
"testand_set", 2, value )
3930 || __kmp_str_match(
"testand-set", 2, value )
3931 || __kmp_str_match(
"testandset", 2, value ) ) {
3932 __kmp_user_lock_kind = lk_tas;
3934 #if KMP_OS_LINUX && (KMP_ARCH_X86 || KMP_ARCH_X86_64 || KMP_ARCH_ARM)
3935 else if ( __kmp_str_match(
"futex", 1, value ) ) {
3936 if ( __kmp_futex_determine_capable() ) {
3937 __kmp_user_lock_kind = lk_futex;
3940 KMP_WARNING( FutexNotSupported, name, value );
3944 else if ( __kmp_str_match(
"ticket", 2, value ) ) {
3945 __kmp_user_lock_kind = lk_ticket;
3947 else if ( __kmp_str_match(
"queuing", 1, value )
3948 || __kmp_str_match(
"queue", 1, value ) ) {
3949 __kmp_user_lock_kind = lk_queuing;
3951 else if ( __kmp_str_match(
"drdpa ticket", 1, value )
3952 || __kmp_str_match(
"drdpa_ticket", 1, value )
3953 || __kmp_str_match(
"drdpa-ticket", 1, value )
3954 || __kmp_str_match(
"drdpaticket", 1, value )
3955 || __kmp_str_match(
"drdpa", 1, value ) ) {
3956 __kmp_user_lock_kind = lk_drdpa;
3958 #if KMP_USE_ADAPTIVE_LOCKS
3959 else if ( __kmp_str_match(
"adaptive", 1, value ) ) {
3960 if( __kmp_cpuinfo.rtm ) {
3961 __kmp_user_lock_kind = lk_adaptive;
3963 KMP_WARNING( AdaptiveNotSupported, name, value );
3964 __kmp_user_lock_kind = lk_queuing;
3967 #endif // KMP_USE_ADAPTIVE_LOCKS
3969 KMP_WARNING( StgInvalidValue, name, value );
3974 __kmp_stg_print_lock_kind( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3975 const char *value = NULL;
3977 switch ( __kmp_user_lock_kind ) {
3986 #if KMP_OS_LINUX && (KMP_ARCH_X86 || KMP_ARCH_X86_64)
4003 #if KMP_USE_ADAPTIVE_LOCKS
4010 if ( value != NULL ) {
4011 __kmp_stg_print_str( buffer, name, value );
4015 #if KMP_USE_ADAPTIVE_LOCKS
4024 __kmp_stg_parse_adaptive_lock_props(
const char *name,
const char *value,
void *data )
4026 int max_retries = 0;
4027 int max_badness = 0;
4029 const char *next = value;
4030 const char *scan = next;
4033 int prev_comma = FALSE;
4038 for ( i = 0; i < 3 ; i++) {
4041 if ( *next ==
'\0' ) {
4045 if ( ( ( *next <
'0' ) || ( *next >
'9' ) ) && ( *next !=
',') || ( total > 2 ) ) {
4046 KMP_WARNING( EnvSyntaxError, name, value );
4050 if ( *next ==
',' ) {
4052 if ( total == 0 || prev_comma ) {
4060 if ( *next >=
'0' && *next <=
'9' ) {
4062 const char *buf = next;
4063 char const * msg = NULL;
4065 SKIP_DIGITS( next );
4068 const char *tmp = next;
4070 if ( ( *next ==
' ' || *next ==
'\t' ) && ( *tmp >=
'0' && *tmp <=
'9' ) ) {
4071 KMP_WARNING( EnvSpacesNotAllowed, name, value );
4075 num = __kmp_str_to_int( buf, *next );
4077 msg = KMP_I18N_STR( ValueTooSmall );
4079 }
else if ( num > KMP_INT_MAX ) {
4080 msg = KMP_I18N_STR( ValueTooLarge );
4083 if ( msg != NULL ) {
4085 KMP_WARNING( ParseSizeIntWarn, name, value, msg );
4086 KMP_INFORM( Using_int_Value, name, num );
4090 }
else if( total == 2 ) {
4095 KMP_DEBUG_ASSERT( total > 0 );
4097 KMP_WARNING( EnvSyntaxError, name, value );
4100 if( max_retries != 0 ) {
4101 __kmp_adaptive_backoff_params.max_soft_retries = max_retries;
4103 if( max_badness != 0 ) {
4104 __kmp_adaptive_backoff_params.max_badness = max_badness;
4110 __kmp_stg_print_adaptive_lock_props(kmp_str_buf_t * buffer,
char const * name,
void * data )
4112 if( __kmp_env_format ) {
4113 KMP_STR_BUF_PRINT_NAME_EX(name);
4115 __kmp_str_buf_print( buffer,
" %s='", name );
4117 __kmp_str_buf_print( buffer,
"%d,%d'\n", __kmp_adaptive_backoff_params.max_soft_retries,
4118 __kmp_adaptive_backoff_params.max_badness );
4121 #if KMP_DEBUG_ADAPTIVE_LOCKS
4124 __kmp_stg_parse_speculative_statsfile(
char const * name,
char const * value,
void * data ) {
4125 __kmp_stg_parse_file( name, value,
"", & __kmp_speculative_statsfile );
4129 __kmp_stg_print_speculative_statsfile( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
4130 if ( __kmp_str_match(
"-", 0, __kmp_speculative_statsfile ) ) {
4131 __kmp_stg_print_str( buffer, name,
"stdout" );
4133 __kmp_stg_print_str( buffer, name, __kmp_speculative_statsfile );
4138 #endif // KMP_DEBUG_ADAPTIVE_LOCKS
4140 #endif // KMP_USE_ADAPTIVE_LOCKS
4148 __kmp_stg_parse_place_threads(
char const * name,
char const * value,
void * data ) {
4154 const char *next = value;
4158 if ( *next ==
'\0' ) {
4163 if ( *next >=
'0' && *next <=
'9' ) {
4165 SKIP_DIGITS( next );
4166 num = __kmp_str_to_int( prev, *next );
4168 if ( *next ==
'C' || *next ==
'c' ) {
4169 __kmp_place_num_cores = num;
4171 }
else if ( *next ==
',' || *next ==
'x' ) {
4172 __kmp_place_num_cores = num;
4175 }
else if ( *next ==
'T' || *next ==
't' ) {
4176 __kmp_place_num_threads_per_core = num;
4178 }
else if ( *next ==
'\0' ) {
4179 __kmp_place_num_cores = num;
4182 KMP_WARNING( AffThrPlaceInvalid, name, value );
4185 }
else if ( *next ==
',' || *next ==
'x' ) {
4190 KMP_WARNING( AffThrPlaceInvalid, name, value );
4194 if ( *next ==
'\0' ) {
4197 if ( ( *next ==
',' || *next ==
'x' ) && !prev_delim ) {
4204 if ( *next >=
'0' && *next <=
'9' ) {
4207 SKIP_DIGITS( next );
4208 num = __kmp_str_to_int( prev, *next );
4210 if ( *next ==
'T' || *next ==
't' ) {
4211 __kmp_place_num_threads_per_core = num;
4213 }
else if ( *next ==
',' || *next ==
'x' ) {
4214 __kmp_place_num_threads_per_core = num;
4217 }
else if ( *next ==
'O' || *next ==
'o' ) {
4218 __kmp_place_core_offset = num;
4220 }
else if ( *next ==
'\0' ) {
4221 __kmp_place_num_threads_per_core = num;
4224 KMP_WARNING( AffThrPlaceInvalid, name, value );
4227 }
else if ( *next ==
',' || *next ==
'x' ) {
4228 if ( prev_delim == 2 ) {
4231 KMP_DEBUG_ASSERT( prev_delim == 1 );
4234 KMP_WARNING( AffThrPlaceInvalid, name, value );
4238 if ( *next ==
'\0' ) {
4241 if ( ( *next ==
',' || *next ==
'x' ) && !prev_delim ) {
4249 if ( *next >=
'0' && *next <=
'9' ) {
4251 SKIP_DIGITS( next );
4252 num = __kmp_str_to_int( prev, *next );
4253 __kmp_place_core_offset = num;
4258 __kmp_stg_print_place_threads( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
4259 if ( __kmp_place_num_cores + __kmp_place_num_threads_per_core ) {
4261 __kmp_str_buf_init( &buf );
4262 if( __kmp_env_format ) {
4263 KMP_STR_BUF_PRINT_NAME_EX(name);
4265 __kmp_str_buf_print( buffer,
" %s='", name );
4267 __kmp_str_buf_print( &buf,
"%dC", __kmp_place_num_cores );
4268 __kmp_str_buf_print( &buf,
"x%dT", __kmp_place_num_threads_per_core );
4269 if ( __kmp_place_core_offset ) {
4270 __kmp_str_buf_print( &buf,
",%dO", __kmp_place_core_offset );
4272 __kmp_str_buf_print(buffer,
"%s'\n", buf.str );
4273 __kmp_str_buf_free(&buf);
4288 __kmp_stg_parse_forkjoin_frames(
char const * name,
char const * value,
void * data ) {
4289 __kmp_stg_parse_bool( name, value, & __kmp_forkjoin_frames );
4293 __kmp_stg_print_forkjoin_frames( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
4294 __kmp_stg_print_bool( buffer, name, __kmp_forkjoin_frames );
4302 __kmp_stg_parse_forkjoin_frames_mode(
char const * name,
char const * value,
void * data ) {
4303 __kmp_stg_parse_int( name, value, 0, 3, & __kmp_forkjoin_frames_mode );
4307 __kmp_stg_print_forkjoin_frames_mode( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
4308 __kmp_stg_print_int( buffer, name, __kmp_forkjoin_frames_mode );
4319 __kmp_stg_parse_omp_display_env(
char const * name,
char const * value,
void * data )
4321 if ( __kmp_str_match(
"VERBOSE", 1, value ) )
4323 __kmp_display_env_verbose = TRUE;
4325 __kmp_stg_parse_bool( name, value, & __kmp_display_env );
4331 __kmp_stg_print_omp_display_env( kmp_str_buf_t * buffer,
char const * name,
void * data )
4333 if ( __kmp_display_env_verbose )
4335 __kmp_stg_print_str( buffer, name,
"VERBOSE" );
4337 __kmp_stg_print_bool( buffer, name, __kmp_display_env );
4342 __kmp_stg_parse_omp_cancellation(
char const * name,
char const * value,
void * data ) {
4343 __kmp_stg_parse_bool( name, value, & __kmp_omp_cancellation );
4347 __kmp_stg_print_omp_cancellation( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
4348 __kmp_stg_print_bool( buffer, name, __kmp_omp_cancellation );
4358 static kmp_setting_t __kmp_stg_table[] = {
4360 {
"KMP_ALL_THREADS", __kmp_stg_parse_all_threads, __kmp_stg_print_all_threads, NULL, 0, 0 },
4361 {
"KMP_BLOCKTIME", __kmp_stg_parse_blocktime, __kmp_stg_print_blocktime, NULL, 0, 0 },
4362 {
"KMP_DUPLICATE_LIB_OK", __kmp_stg_parse_duplicate_lib_ok, __kmp_stg_print_duplicate_lib_ok, NULL, 0, 0 },
4363 {
"KMP_LIBRARY", __kmp_stg_parse_wait_policy, __kmp_stg_print_wait_policy, NULL, 0, 0 },
4364 {
"KMP_MAX_THREADS", __kmp_stg_parse_all_threads, NULL, NULL, 0, 0 },
4365 {
"KMP_MONITOR_STACKSIZE", __kmp_stg_parse_monitor_stacksize, __kmp_stg_print_monitor_stacksize, NULL, 0, 0 },
4366 {
"KMP_SETTINGS", __kmp_stg_parse_settings, __kmp_stg_print_settings, NULL, 0, 0 },
4367 {
"KMP_STACKOFFSET", __kmp_stg_parse_stackoffset, __kmp_stg_print_stackoffset, NULL, 0, 0 },
4368 {
"KMP_STACKSIZE", __kmp_stg_parse_stacksize, __kmp_stg_print_stacksize, NULL, 0, 0 },
4369 {
"KMP_VERSION", __kmp_stg_parse_version, __kmp_stg_print_version, NULL, 0, 0 },
4370 {
"KMP_WARNINGS", __kmp_stg_parse_warnings, __kmp_stg_print_warnings, NULL, 0, 0 },
4372 {
"OMP_NESTED", __kmp_stg_parse_nested, __kmp_stg_print_nested, NULL, 0, 0 },
4373 {
"OMP_NUM_THREADS", __kmp_stg_parse_num_threads, __kmp_stg_print_num_threads, NULL, 0, 0 },
4374 {
"OMP_STACKSIZE", __kmp_stg_parse_stacksize, __kmp_stg_print_stacksize, NULL, 0, 0 },
4377 {
"KMP_TASKING", __kmp_stg_parse_tasking, __kmp_stg_print_tasking, NULL, 0, 0 },
4378 {
"KMP_TASK_STEALING_CONSTRAINT", __kmp_stg_parse_task_stealing, __kmp_stg_print_task_stealing, NULL, 0, 0 },
4379 {
"OMP_MAX_ACTIVE_LEVELS", __kmp_stg_parse_max_active_levels, __kmp_stg_print_max_active_levels, NULL, 0, 0 },
4380 {
"OMP_THREAD_LIMIT", __kmp_stg_parse_all_threads, __kmp_stg_print_all_threads, NULL, 0, 0 },
4381 {
"OMP_WAIT_POLICY", __kmp_stg_parse_wait_policy, __kmp_stg_print_wait_policy, NULL, 0, 0 },
4382 #endif // OMP_30_ENABLED
4384 #if KMP_HANDLE_SIGNALS
4385 {
"KMP_HANDLE_SIGNALS", __kmp_stg_parse_handle_signals, __kmp_stg_print_handle_signals, NULL, 0, 0 },
4388 #if KMP_ARCH_X86 || KMP_ARCH_X86_64
4389 {
"KMP_INHERIT_FP_CONTROL", __kmp_stg_parse_inherit_fp_control, __kmp_stg_print_inherit_fp_control, NULL, 0, 0 },
4392 #ifdef KMP_GOMP_COMPAT
4393 {
"GOMP_STACKSIZE", __kmp_stg_parse_stacksize, NULL, NULL, 0, 0 },
4397 {
"KMP_A_DEBUG", __kmp_stg_parse_a_debug, __kmp_stg_print_a_debug, NULL, 0, 0 },
4398 {
"KMP_B_DEBUG", __kmp_stg_parse_b_debug, __kmp_stg_print_b_debug, NULL, 0, 0 },
4399 {
"KMP_C_DEBUG", __kmp_stg_parse_c_debug, __kmp_stg_print_c_debug, NULL, 0, 0 },
4400 {
"KMP_D_DEBUG", __kmp_stg_parse_d_debug, __kmp_stg_print_d_debug, NULL, 0, 0 },
4401 {
"KMP_E_DEBUG", __kmp_stg_parse_e_debug, __kmp_stg_print_e_debug, NULL, 0, 0 },
4402 {
"KMP_F_DEBUG", __kmp_stg_parse_f_debug, __kmp_stg_print_f_debug, NULL, 0, 0 },
4403 {
"KMP_DEBUG", __kmp_stg_parse_debug, NULL, NULL, 0, 0 },
4404 {
"KMP_DEBUG_BUF", __kmp_stg_parse_debug_buf, __kmp_stg_print_debug_buf, NULL, 0, 0 },
4405 {
"KMP_DEBUG_BUF_ATOMIC", __kmp_stg_parse_debug_buf_atomic, __kmp_stg_print_debug_buf_atomic, NULL, 0, 0 },
4406 {
"KMP_DEBUG_BUF_CHARS", __kmp_stg_parse_debug_buf_chars, __kmp_stg_print_debug_buf_chars, NULL, 0, 0 },
4407 {
"KMP_DEBUG_BUF_LINES", __kmp_stg_parse_debug_buf_lines, __kmp_stg_print_debug_buf_lines, NULL, 0, 0 },
4408 {
"KMP_DIAG", __kmp_stg_parse_diag, __kmp_stg_print_diag, NULL, 0, 0 },
4410 {
"KMP_PAR_RANGE", __kmp_stg_parse_par_range_env, __kmp_stg_print_par_range_env, NULL, 0, 0 },
4411 {
"KMP_YIELD_CYCLE", __kmp_stg_parse_yield_cycle, __kmp_stg_print_yield_cycle, NULL, 0, 0 },
4412 {
"KMP_YIELD_ON", __kmp_stg_parse_yield_on, __kmp_stg_print_yield_on, NULL, 0, 0 },
4413 {
"KMP_YIELD_OFF", __kmp_stg_parse_yield_off, __kmp_stg_print_yield_off, NULL, 0, 0 },
4416 {
"KMP_ALIGN_ALLOC", __kmp_stg_parse_align_alloc, __kmp_stg_print_align_alloc, NULL, 0, 0 },
4418 {
"KMP_PLAIN_BARRIER", __kmp_stg_parse_barrier_branch_bit, __kmp_stg_print_barrier_branch_bit, NULL, 0, 0 },
4419 {
"KMP_PLAIN_BARRIER_PATTERN", __kmp_stg_parse_barrier_pattern, __kmp_stg_print_barrier_pattern, NULL, 0, 0 },
4420 {
"KMP_FORKJOIN_BARRIER", __kmp_stg_parse_barrier_branch_bit, __kmp_stg_print_barrier_branch_bit, NULL, 0, 0 },
4421 {
"KMP_FORKJOIN_BARRIER_PATTERN", __kmp_stg_parse_barrier_pattern, __kmp_stg_print_barrier_pattern, NULL, 0, 0 },
4422 #if KMP_FAST_REDUCTION_BARRIER
4423 {
"KMP_REDUCTION_BARRIER", __kmp_stg_parse_barrier_branch_bit, __kmp_stg_print_barrier_branch_bit, NULL, 0, 0 },
4424 {
"KMP_REDUCTION_BARRIER_PATTERN", __kmp_stg_parse_barrier_pattern, __kmp_stg_print_barrier_pattern, NULL, 0, 0 },
4427 {
"KMP_ABORT_DELAY", __kmp_stg_parse_abort_delay, __kmp_stg_print_abort_delay, NULL, 0, 0 },
4428 {
"KMP_CPUINFO_FILE", __kmp_stg_parse_cpuinfo_file, __kmp_stg_print_cpuinfo_file, NULL, 0, 0 },
4429 {
"KMP_FORCE_REDUCTION", __kmp_stg_parse_force_reduction, __kmp_stg_print_force_reduction, NULL, 0, 0 },
4430 {
"KMP_DETERMINISTIC_REDUCTION", __kmp_stg_parse_force_reduction, __kmp_stg_print_force_reduction, NULL, 0, 0 },
4431 {
"KMP_STORAGE_MAP", __kmp_stg_parse_storage_map, __kmp_stg_print_storage_map, NULL, 0, 0 },
4432 {
"KMP_ALL_THREADPRIVATE", __kmp_stg_parse_all_threadprivate, __kmp_stg_print_all_threadprivate, NULL, 0, 0 },
4433 {
"KMP_FOREIGN_THREADS_THREADPRIVATE", __kmp_stg_parse_foreign_threads_threadprivate, __kmp_stg_print_foreign_threads_threadprivate, NULL, 0, 0 },
4435 #if KMP_OS_LINUX || KMP_OS_WINDOWS
4436 {
"KMP_AFFINITY", __kmp_stg_parse_affinity, __kmp_stg_print_affinity, NULL, 0, 0 },
4437 # ifdef KMP_GOMP_COMPAT
4438 {
"GOMP_CPU_AFFINITY", __kmp_stg_parse_gomp_cpu_affinity, NULL, NULL, 0, 0 },
4442 {
"OMP_PROC_BIND", __kmp_stg_parse_proc_bind, __kmp_stg_print_proc_bind, NULL, 0, 0 },
4443 {
"OMP_PLACES", __kmp_stg_parse_places, __kmp_stg_print_places, NULL, 0, 0 },
4445 {
"OMP_PROC_BIND", __kmp_stg_parse_proc_bind, NULL, NULL, 0, 0 },
4449 {
"KMP_TOPOLOGY_METHOD", __kmp_stg_parse_topology_method, __kmp_stg_print_topology_method, NULL, 0, 0 },
4458 {
"OMP_PROC_BIND", __kmp_stg_parse_proc_bind, __kmp_stg_print_proc_bind, NULL, 0, 0 },
4462 #error "Unknown or unsupported OS"
4463 #endif // KMP_OS_LINUX || KMP_OS_WINDOWS
4465 {
"KMP_INIT_AT_FORK", __kmp_stg_parse_init_at_fork, __kmp_stg_print_init_at_fork, NULL, 0, 0 },
4466 {
"KMP_SCHEDULE", __kmp_stg_parse_schedule, __kmp_stg_print_schedule, NULL, 0, 0 },
4467 {
"OMP_SCHEDULE", __kmp_stg_parse_omp_schedule, __kmp_stg_print_omp_schedule, NULL, 0, 0 },
4468 {
"KMP_ATOMIC_MODE", __kmp_stg_parse_atomic_mode, __kmp_stg_print_atomic_mode, NULL, 0, 0 },
4469 {
"KMP_CONSISTENCY_CHECK", __kmp_stg_parse_consistency_check, __kmp_stg_print_consistency_check, NULL, 0, 0 },
4471 #if USE_ITT_BUILD && USE_ITT_NOTIFY
4472 {
"KMP_ITT_PREPARE_DELAY", __kmp_stg_parse_itt_prepare_delay, __kmp_stg_print_itt_prepare_delay, NULL, 0, 0 },
4474 {
"KMP_MALLOC_POOL_INCR", __kmp_stg_parse_malloc_pool_incr, __kmp_stg_print_malloc_pool_incr, NULL, 0, 0 },
4475 {
"KMP_INIT_WAIT", __kmp_stg_parse_init_wait, __kmp_stg_print_init_wait, NULL, 0, 0 },
4476 {
"KMP_NEXT_WAIT", __kmp_stg_parse_next_wait, __kmp_stg_print_next_wait, NULL, 0, 0 },
4477 {
"KMP_GTID_MODE", __kmp_stg_parse_gtid_mode, __kmp_stg_print_gtid_mode, NULL, 0, 0 },
4478 {
"OMP_DYNAMIC", __kmp_stg_parse_omp_dynamic, __kmp_stg_print_omp_dynamic, NULL, 0, 0 },
4479 {
"KMP_DYNAMIC_MODE", __kmp_stg_parse_kmp_dynamic_mode, __kmp_stg_print_kmp_dynamic_mode, NULL, 0, 0 },
4481 #ifdef USE_LOAD_BALANCE
4482 {
"KMP_LOAD_BALANCE_INTERVAL", __kmp_stg_parse_ld_balance_interval,__kmp_stg_print_ld_balance_interval,NULL, 0, 0 },
4487 {
"KMP_NUM_LOCKS_IN_BLOCK", __kmp_stg_parse_lock_block, __kmp_stg_print_lock_block, NULL, 0, 0 },
4488 {
"KMP_LOCK_KIND", __kmp_stg_parse_lock_kind, __kmp_stg_print_lock_kind, NULL, 0, 0 },
4489 #if KMP_USE_ADAPTIVE_LOCKS
4490 {
"KMP_ADAPTIVE_LOCK_PROPS", __kmp_stg_parse_adaptive_lock_props,__kmp_stg_print_adaptive_lock_props, NULL, 0, 0 },
4491 #if KMP_DEBUG_ADAPTIVE_LOCKS
4492 {
"KMP_SPECULATIVE_STATSFILE", __kmp_stg_parse_speculative_statsfile,__kmp_stg_print_speculative_statsfile, NULL, 0, 0 },
4494 #endif // KMP_USE_ADAPTIVE_LOCKS
4496 {
"KMP_PLACE_THREADS", __kmp_stg_parse_place_threads, __kmp_stg_print_place_threads, NULL, 0, 0 },
4499 {
"KMP_FORKJOIN_FRAMES", __kmp_stg_parse_forkjoin_frames, __kmp_stg_print_forkjoin_frames, NULL, 0, 0 },
4500 {
"KMP_FORKJOIN_FRAMES_MODE", __kmp_stg_parse_forkjoin_frames_mode,__kmp_stg_print_forkjoin_frames_mode, NULL, 0, 0 },
4504 {
"OMP_DISPLAY_ENV", __kmp_stg_parse_omp_display_env, __kmp_stg_print_omp_display_env, NULL, 0, 0 },
4505 {
"OMP_CANCELLATION", __kmp_stg_parse_omp_cancellation, __kmp_stg_print_omp_cancellation, NULL, 0, 0 },
4507 {
"", NULL, NULL, NULL, 0, 0 }
4510 static int const __kmp_stg_count =
sizeof( __kmp_stg_table ) /
sizeof( kmp_setting_t );
4514 __kmp_stg_find(
char const * name ) {
4517 if ( name != NULL ) {
4518 for ( i = 0; i < __kmp_stg_count; ++ i ) {
4519 if ( strcmp( __kmp_stg_table[ i ].name, name ) == 0 ) {
4520 return & __kmp_stg_table[ i ];
4530 __kmp_stg_cmp(
void const * _a,
void const * _b ) {
4531 kmp_setting_t * a = (kmp_setting_t *) _a;
4532 kmp_setting_t * b = (kmp_setting_t *) _b;
4538 if ( strcmp( a->name,
"KMP_AFFINITY" ) == 0 ) {
4539 if ( strcmp( b->name,
"KMP_AFFINITY" ) == 0 ) {
4544 else if ( strcmp( b->name,
"KMP_AFFINITY" ) == 0 ) {
4547 return strcmp( a->name, b->name );
4552 __kmp_stg_init(
void
4555 static int initialized = 0;
4557 if ( ! initialized ) {
4560 qsort( __kmp_stg_table, __kmp_stg_count - 1,
sizeof( kmp_setting_t ), __kmp_stg_cmp );
4564 kmp_setting_t * kmp_stacksize = __kmp_stg_find(
"KMP_STACKSIZE" );
4565 #ifdef KMP_GOMP_COMPAT
4566 kmp_setting_t * gomp_stacksize = __kmp_stg_find(
"GOMP_STACKSIZE" );
4568 kmp_setting_t * omp_stacksize = __kmp_stg_find(
"OMP_STACKSIZE" );
4573 static kmp_setting_t *
volatile rivals[ 4 ];
4574 static kmp_stg_ss_data_t kmp_data = { 1, (kmp_setting_t **)rivals };
4575 #ifdef KMP_GOMP_COMPAT
4576 static kmp_stg_ss_data_t gomp_data = { 1024, (kmp_setting_t **)rivals };
4578 static kmp_stg_ss_data_t omp_data = { 1024, (kmp_setting_t **)rivals };
4581 rivals[ i ++ ] = kmp_stacksize;
4582 #ifdef KMP_GOMP_COMPAT
4583 if ( gomp_stacksize != NULL ) {
4584 rivals[ i ++ ] = gomp_stacksize;
4587 rivals[ i ++ ] = omp_stacksize;
4588 rivals[ i ++ ] = NULL;
4590 kmp_stacksize->data = & kmp_data;
4591 #ifdef KMP_GOMP_COMPAT
4592 if ( gomp_stacksize != NULL ) {
4593 gomp_stacksize->data = & gomp_data;
4596 omp_stacksize->data = & omp_data;
4603 kmp_setting_t * kmp_library = __kmp_stg_find(
"KMP_LIBRARY" );
4604 kmp_setting_t * omp_wait_policy = __kmp_stg_find(
"OMP_WAIT_POLICY" );
4607 static kmp_setting_t *
volatile rivals[ 3 ];
4608 static kmp_stg_wp_data_t kmp_data = { 0, (kmp_setting_t **)rivals };
4609 static kmp_stg_wp_data_t omp_data = { 1, (kmp_setting_t **)rivals };
4612 rivals[ i ++ ] = kmp_library;
4613 if ( omp_wait_policy != NULL ) {
4614 rivals[ i ++ ] = omp_wait_policy;
4616 rivals[ i ++ ] = NULL;
4618 kmp_library->data = & kmp_data;
4619 if ( omp_wait_policy != NULL ) {
4620 omp_wait_policy->data = & omp_data;
4626 kmp_setting_t * kmp_library = __kmp_stg_find(
"KMP_LIBRARY" );
4627 static kmp_stg_wp_data_t kmp_data = { 0, NULL };
4628 kmp_library->data = & kmp_data;
4634 kmp_setting_t * kmp_all_threads = __kmp_stg_find(
"KMP_ALL_THREADS" );
4635 kmp_setting_t * kmp_max_threads = __kmp_stg_find(
"KMP_MAX_THREADS" );
4637 kmp_setting_t * omp_thread_limit = __kmp_stg_find(
"OMP_THREAD_LIMIT" );
4641 static kmp_setting_t *
volatile rivals[ 4 ];
4644 rivals[ i ++ ] = kmp_all_threads;
4645 rivals[ i ++ ] = kmp_max_threads;
4647 if ( omp_thread_limit != NULL ) {
4648 rivals[ i ++ ] = omp_thread_limit;
4651 rivals[ i ++ ] = NULL;
4653 kmp_all_threads->data = (
void*)& rivals;
4654 kmp_max_threads->data = (
void*)& rivals;
4656 if ( omp_thread_limit != NULL ) {
4657 omp_thread_limit->data = (
void*)& rivals;
4663 #if KMP_OS_LINUX || KMP_OS_WINDOWS
4666 kmp_setting_t * kmp_affinity = __kmp_stg_find(
"KMP_AFFINITY" );
4667 KMP_DEBUG_ASSERT( kmp_affinity != NULL );
4669 # ifdef KMP_GOMP_COMPAT
4670 kmp_setting_t * gomp_cpu_affinity = __kmp_stg_find(
"GOMP_CPU_AFFINITY" );
4671 KMP_DEBUG_ASSERT( gomp_cpu_affinity != NULL );
4675 kmp_setting_t * omp_proc_bind = __kmp_stg_find(
"OMP_PROC_BIND" );
4676 KMP_DEBUG_ASSERT( omp_proc_bind != NULL );
4680 kmp_setting_t * omp_places = __kmp_stg_find(
"OMP_PLACES" );
4681 KMP_DEBUG_ASSERT( omp_places != NULL );
4685 static kmp_setting_t *
volatile rivals[ 5 ];
4688 rivals[ i ++ ] = kmp_affinity;
4690 # ifdef KMP_GOMP_COMPAT
4691 rivals[ i ++ ] = gomp_cpu_affinity;
4692 gomp_cpu_affinity->data = (
void*)& rivals;
4696 rivals[ i ++ ] = omp_proc_bind;
4697 omp_proc_bind->data = (
void*)& rivals;
4701 rivals[ i ++ ] = omp_places;
4702 omp_places->data = (
void*)& rivals;
4705 rivals[ i ++ ] = NULL;
4712 #error "Unknown or unsupported OS"
4717 kmp_setting_t * kmp_force_red = __kmp_stg_find(
"KMP_FORCE_REDUCTION" );
4718 kmp_setting_t * kmp_determ_red = __kmp_stg_find(
"KMP_DETERMINISTIC_REDUCTION" );
4721 static kmp_setting_t *
volatile rivals[ 3 ];
4722 static kmp_stg_fr_data_t force_data = { 1, (kmp_setting_t **)rivals };
4723 static kmp_stg_fr_data_t determ_data = { 0, (kmp_setting_t **)rivals };
4726 rivals[ i ++ ] = kmp_force_red;
4727 if ( kmp_determ_red != NULL ) {
4728 rivals[ i ++ ] = kmp_determ_red;
4730 rivals[ i ++ ] = NULL;
4732 kmp_force_red->data = & force_data;
4733 if ( kmp_determ_red != NULL ) {
4734 kmp_determ_red->data = & determ_data;
4744 for ( i = 0; i < __kmp_stg_count; ++ i ) {
4745 __kmp_stg_table[ i ].set = 0;
4759 if ( name[ 0 ] == 0 ) {
4763 if ( value != NULL ) {
4764 kmp_setting_t * setting = __kmp_stg_find( name );
4765 if ( setting != NULL ) {
4766 setting->parse( name, value, setting->data );
4767 setting->defined = 1;
4775 __kmp_stg_check_rivals(
4778 kmp_setting_t * * rivals
4781 if ( rivals == NULL ) {
4787 for ( ; strcmp( rivals[ i ]->name, name ) != 0; i++ ) {
4788 KMP_DEBUG_ASSERT( rivals[ i ] != NULL );
4790 #if KMP_OS_LINUX || KMP_OS_WINDOWS
4791 if ( rivals[ i ] == __kmp_affinity_notype ) {
4800 if ( rivals[ i ]->set ) {
4801 KMP_WARNING( StgIgnored, name, value, rivals[ i ]->name );
4814 __kmp_env_isDefined(
char const * name ) {
4816 kmp_setting_t * setting = __kmp_stg_find( name );
4817 if ( setting != NULL ) {
4824 __kmp_env_toPrint(
char const * name,
int flag ) {
4826 kmp_setting_t * setting = __kmp_stg_find( name );
4827 if ( setting != NULL ) {
4828 rc = setting->defined;
4830 setting->defined = flag;
4838 __kmp_aux_env_initialize( kmp_env_blk_t* block ) {
4843 value = __kmp_env_blk_var( block,
"OMP_NUM_THREADS" );
4845 ompc_set_num_threads( __kmp_dflt_team_nth );
4849 value = __kmp_env_blk_var( block,
"KMP_BLOCKTIME" );
4851 kmpc_set_blocktime( __kmp_dflt_blocktime );
4855 value = __kmp_env_blk_var( block,
"OMP_NESTED" );
4857 ompc_set_nested( __kmp_dflt_nested );
4861 value = __kmp_env_blk_var( block,
"OMP_DYNAMIC" );
4863 ompc_set_dynamic( __kmp_global.g.g_dynamic );
4869 __kmp_env_initialize(
char const *
string ) {
4871 kmp_env_blk_t block;
4877 if (
string == NULL ) {
4879 __kmp_threads_capacity = __kmp_initial_threads_capacity( __kmp_dflt_team_nth_ub );
4881 __kmp_env_blk_init( & block,
string );
4886 for ( i = 0; i < block.count; ++ i ) {
4887 if (( block.vars[ i ].name == NULL )
4888 || ( *block.vars[ i ].name ==
'\0')) {
4891 if ( block.vars[ i ].value == NULL ) {
4894 kmp_setting_t * setting = __kmp_stg_find( block.vars[ i ].name );
4895 if ( setting != NULL ) {
4901 if (
string == NULL ) {
4902 char const * name =
"KMP_WARNINGS";
4903 char const * value = __kmp_env_blk_var( & block, name );
4904 __kmp_stg_parse( name, value );
4907 #if KMP_OS_LINUX || KMP_OS_WINDOWS
4915 __kmp_affinity_notype = NULL;
4916 char const *aff_str = __kmp_env_blk_var( & block,
"KMP_AFFINITY" );
4917 if ( aff_str != NULL ) {
4931 # define FIND strstr
4933 # define FIND strcasestr
4936 if ( ( FIND( aff_str,
"none" ) == NULL )
4937 && ( FIND( aff_str,
"physical" ) == NULL )
4938 && ( FIND( aff_str,
"logical" ) == NULL )
4939 && ( FIND( aff_str,
"compact" ) == NULL )
4940 && ( FIND( aff_str,
"scatter" ) == NULL )
4941 && ( FIND( aff_str,
"explicit" ) == NULL )
4943 && ( FIND( aff_str,
"balanced" ) == NULL )
4945 && ( FIND( aff_str,
"disabled" ) == NULL ) ) {
4946 __kmp_affinity_notype = __kmp_stg_find(
"KMP_AFFINITY" );
4956 if ( __kmp_nested_proc_bind.bind_types == NULL ) {
4957 __kmp_nested_proc_bind.bind_types = (kmp_proc_bind_t *)
4958 KMP_INTERNAL_MALLOC(
sizeof(kmp_proc_bind_t) );
4959 if ( __kmp_nested_proc_bind.bind_types == NULL ) {
4960 KMP_FATAL( MemoryAllocFailed );
4962 __kmp_nested_proc_bind.size = 1;
4963 __kmp_nested_proc_bind.used = 1;
4964 __kmp_nested_proc_bind.bind_types[0] = proc_bind_default;
4971 for ( i = 0; i < block.count; ++ i ) {
4972 __kmp_stg_parse( block.vars[ i ].name, block.vars[ i ].value );
4978 if ( ! __kmp_init_user_locks ) {
4979 if ( __kmp_user_lock_kind == lk_default ) {
4980 __kmp_user_lock_kind = lk_queuing;
4982 __kmp_set_user_lock_vptrs( __kmp_user_lock_kind );
4985 KMP_DEBUG_ASSERT(
string != NULL);
4986 KMP_DEBUG_ASSERT( __kmp_user_lock_kind != lk_default );
4989 #if KMP_OS_LINUX || KMP_OS_WINDOWS
4990 if ( ! TCR_4(__kmp_init_middle) ) {
4995 const char *var =
"KMP_AFFINITY";
4996 if ( __kmp_affinity_type == affinity_disabled ) {
4997 __kmp_affin_mask_size = 0;
4999 else if ( ! KMP_AFFINITY_CAPABLE() ) {
5000 __kmp_affinity_determine_capable( var );
5001 if ( ! KMP_AFFINITY_CAPABLE() ) {
5002 if ( __kmp_affinity_verbose || ( __kmp_affinity_warnings
5003 && ( __kmp_affinity_type != affinity_default )
5004 && ( __kmp_affinity_type != affinity_none )
5005 && ( __kmp_affinity_type != affinity_disabled ) ) ) {
5006 KMP_WARNING( AffNotSupported, var );
5008 __kmp_affinity_type = affinity_disabled;
5009 __kmp_affinity_respect_mask = 0;
5010 __kmp_affinity_gran = affinity_gran_fine;
5016 if ( __kmp_affinity_type == affinity_disabled ) {
5017 __kmp_nested_proc_bind.bind_types[0] = proc_bind_disabled;
5019 else if ( __kmp_nested_proc_bind.bind_types[0] == proc_bind_default ) {
5024 # if KMP_OS_WINDOWS || KMP_OS_LINUX
5025 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
5027 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
5036 if ( __kmp_nested_proc_bind.bind_types[0] == proc_bind_intel ) {
5037 if ( ( __kmp_affinity_type == affinity_none )
5039 || ( __kmp_affinity_type == affinity_default )
5042 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
5045 else if ( ( __kmp_nested_proc_bind.bind_types[0] != proc_bind_false )
5046 && ( __kmp_nested_proc_bind.bind_types[0] != proc_bind_disabled ) ) {
5047 if ( __kmp_affinity_type == affinity_default ) {
5048 __kmp_affinity_type = affinity_compact;
5049 __kmp_affinity_dups = FALSE;
5051 if ( __kmp_affinity_gran == affinity_gran_default ) {
5052 __kmp_affinity_gran = affinity_gran_fine;
5055 # endif // OMP_40_ENABLED
5057 if ( KMP_AFFINITY_CAPABLE() ) {
5059 # if KMP_OS_WINDOWS && KMP_ARCH_X86_64
5061 if ( __kmp_num_proc_groups > 1 ) {
5062 if ( __kmp_affinity_respect_mask == affinity_respect_mask_default ) {
5063 __kmp_affinity_respect_mask = FALSE;
5066 if ( ( __kmp_affinity_type == affinity_default )
5067 || ( __kmp_affinity_type == affinity_none ) ) {
5068 if ( __kmp_affinity_type == affinity_none ) {
5069 if ( __kmp_affinity_verbose || ( __kmp_affinity_warnings
5070 && ( __kmp_affinity_type != affinity_none ) ) ) {
5071 KMP_WARNING( AffTypeCantUseMultGroups,
"none",
"compact" );
5074 __kmp_affinity_type = affinity_compact;
5075 if ( __kmp_affinity_top_method == affinity_top_method_default ) {
5076 __kmp_affinity_top_method = affinity_top_method_group;
5079 else if ( __kmp_affinity_top_method == affinity_top_method_default ) {
5080 __kmp_affinity_top_method = affinity_top_method_all;
5083 if ( __kmp_affinity_gran_levels < 0 ) {
5084 if ( __kmp_affinity_top_method == affinity_top_method_group ) {
5085 if ( __kmp_affinity_gran == affinity_gran_default ) {
5086 __kmp_affinity_gran = affinity_gran_group;
5088 else if ( __kmp_affinity_gran == affinity_gran_core ) {
5089 if ( __kmp_affinity_verbose || ( __kmp_affinity_warnings
5090 && ( __kmp_affinity_type != affinity_none ) ) ) {
5091 KMP_WARNING( AffGranCantUseMultGroups,
"core",
"thread" );
5093 __kmp_affinity_gran = affinity_gran_thread;
5095 else if ( __kmp_affinity_gran == affinity_gran_package ) {
5096 if ( __kmp_affinity_verbose || ( __kmp_affinity_warnings
5097 && ( __kmp_affinity_type != affinity_none ) ) ) {
5098 KMP_WARNING( AffGranCantUseMultGroups,
"package",
"group" );
5100 __kmp_affinity_gran = affinity_gran_group;
5102 else if ( __kmp_affinity_gran == affinity_gran_node ) {
5103 if ( __kmp_affinity_verbose || ( __kmp_affinity_warnings
5104 && ( __kmp_affinity_type != affinity_none ) ) ) {
5105 KMP_WARNING( AffGranCantUseMultGroups,
"node",
"group" );
5107 __kmp_affinity_gran = affinity_gran_group;
5110 else if ( __kmp_affinity_gran == affinity_gran_default ) {
5111 __kmp_affinity_gran = affinity_gran_core;
5119 if ( __kmp_affinity_respect_mask == affinity_respect_mask_default ) {
5120 __kmp_affinity_respect_mask = TRUE;
5122 if ( __kmp_affinity_type == affinity_default ) {
5124 __kmp_affinity_type = affinity_scatter;
5126 __kmp_affinity_type = affinity_none;
5129 if ( ( __kmp_affinity_gran == affinity_gran_default )
5130 && ( __kmp_affinity_gran_levels < 0 ) ) {
5132 __kmp_affinity_gran = affinity_gran_fine;
5134 __kmp_affinity_gran = affinity_gran_core;
5137 if ( __kmp_affinity_top_method == affinity_top_method_default ) {
5138 __kmp_affinity_top_method = affinity_top_method_all;
5143 K_DIAG( 1, (
"__kmp_affinity_type == %d\n", __kmp_affinity_type ) );
5144 K_DIAG( 1, (
"__kmp_affinity_compact == %d\n", __kmp_affinity_compact ) );
5145 K_DIAG( 1, (
"__kmp_affinity_offset == %d\n", __kmp_affinity_offset ) );
5146 K_DIAG( 1, (
"__kmp_affinity_verbose == %d\n", __kmp_affinity_verbose ) );
5147 K_DIAG( 1, (
"__kmp_affinity_warnings == %d\n", __kmp_affinity_warnings ) );
5148 K_DIAG( 1, (
"__kmp_affinity_respect_mask == %d\n", __kmp_affinity_respect_mask ) );
5149 K_DIAG( 1, (
"__kmp_affinity_gran == %d\n", __kmp_affinity_gran ) );
5151 KMP_DEBUG_ASSERT( __kmp_affinity_type != affinity_default);
5153 KMP_DEBUG_ASSERT( __kmp_nested_proc_bind.bind_types[0]
5154 != proc_bind_default );
5161 #error "Unknown or unsupported OS"
5164 if ( __kmp_version ) {
5165 __kmp_print_version_1();
5169 if (
string != NULL) {
5170 __kmp_aux_env_initialize( &block );
5173 __kmp_env_blk_free( & block );
5183 kmp_env_blk_t block;
5185 kmp_str_buf_t buffer;
5188 __kmp_str_buf_init( & buffer );
5190 __kmp_env_blk_init( & block, NULL );
5191 __kmp_env_blk_sort( & block );
5194 __kmp_str_buf_print( & buffer,
"\n%s\n\n", KMP_I18N_STR( UserSettings ) );
5195 for ( i = 0; i < block.count; ++ i ) {
5196 char const * name = block.vars[ i ].name;
5197 char const * value = block.vars[ i ].value;
5201 ( strncmp( name,
"KMP_", 4 ) == 0 ) || strncmp( name,
"OMP_", 4 ) == 0
5202 #ifdef KMP_GOMP_COMPAT
5203 || strncmp( name,
"GOMP_", 5 ) == 0
5206 __kmp_str_buf_print( & buffer,
" %s=%s\n", name, value );
5209 __kmp_str_buf_print( & buffer,
"\n" );
5212 __kmp_str_buf_print( & buffer,
"%s\n\n", KMP_I18N_STR( EffectiveSettings ) );
5213 for (
int i = 0; i < __kmp_stg_count; ++ i ) {
5214 if ( __kmp_stg_table[ i ].print != NULL ) {
5215 __kmp_stg_table[ i ].print( & buffer, __kmp_stg_table[ i ].name, __kmp_stg_table[ i ].data );
5219 __kmp_printf(
"%s", buffer.str );
5221 __kmp_env_blk_free( & block );
5222 __kmp_str_buf_free( & buffer );
5231 __kmp_env_print_2() {
5233 kmp_env_blk_t block;
5235 kmp_str_buf_t buffer;
5237 __kmp_env_format = 1;
5240 __kmp_str_buf_init( & buffer );
5242 __kmp_env_blk_init( & block, NULL );
5243 __kmp_env_blk_sort( & block );
5245 __kmp_str_buf_print( & buffer,
"\n%s\n", KMP_I18N_STR( DisplayEnvBegin ) );
5246 __kmp_str_buf_print( & buffer,
" _OPENMP='%d'\n", __kmp_openmp_version );
5248 for (
int i = 0; i < __kmp_stg_count; ++ i ) {
5249 if ( __kmp_stg_table[ i ].print != NULL &&
5250 ( ( __kmp_display_env && strncmp( __kmp_stg_table[ i ].name,
"OMP_", 4 ) == 0 ) || __kmp_display_env_verbose ) ) {
5251 __kmp_stg_table[ i ].print( & buffer, __kmp_stg_table[ i ].name, __kmp_stg_table[ i ].data );
5255 __kmp_str_buf_print( & buffer,
"%s\n", KMP_I18N_STR( DisplayEnvEnd ) );
5256 __kmp_str_buf_print( & buffer,
"\n" );
5258 __kmp_printf(
"%s", buffer.str );
5260 __kmp_env_blk_free( & block );
5261 __kmp_str_buf_free( & buffer );
5266 #endif // OMP_40_ENABLED