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 );
557 static char * par_range_to_print = NULL;
560 __kmp_stg_parse_par_range(
569 size_t len = strlen( value + 1 );
570 par_range_to_print = (
char *) KMP_INTERNAL_MALLOC( len +1 );
571 strncpy( par_range_to_print, value, len + 1);
572 __kmp_par_range = +1;
573 __kmp_par_range_lb = 0;
574 __kmp_par_range_ub = INT_MAX;
577 if (( value == NULL ) || ( *value ==
'\0' )) {
580 if ( ! __kmp_strcasecmp_with_sentinel(
"routine", value,
'=' )) {
581 value = strchr( value,
'=' ) + 1;
582 len = __kmp_readstr_with_sentinel( out_routine,
583 value, KMP_PAR_RANGE_ROUTINE_LEN - 1,
',' );
585 goto par_range_error;
587 value = strchr( value,
',' );
588 if ( value != NULL ) {
593 if ( ! __kmp_strcasecmp_with_sentinel(
"filename", value,
'=' )) {
594 value = strchr( value,
'=' ) + 1;
595 len = __kmp_readstr_with_sentinel( out_file,
596 value, KMP_PAR_RANGE_FILENAME_LEN - 1,
',' );
598 goto par_range_error;
600 value = strchr( value,
',' );
601 if ( value != NULL ) {
606 if (( ! __kmp_strcasecmp_with_sentinel(
"range", value,
'=' ))
607 || ( ! __kmp_strcasecmp_with_sentinel(
"incl_range", value,
'=' ))) {
608 value = strchr( value,
'=' ) + 1;
609 if ( sscanf( value,
"%d:%d", out_lb, out_ub ) != 2 ) {
610 goto par_range_error;
613 value = strchr( value,
',' );
614 if ( value != NULL ) {
619 if ( ! __kmp_strcasecmp_with_sentinel(
"excl_range", value,
'=' )) {
620 value = strchr( value,
'=' ) + 1;
621 if ( sscanf( value,
"%d:%d", out_lb, out_ub) != 2 ) {
622 goto par_range_error;
625 value = strchr( value,
',' );
626 if ( value != NULL ) {
632 KMP_WARNING( ParRangeSyntax, name );
640 __kmp_initial_threads_capacity(
int req_nproc )
645 if (nth < (4 * req_nproc))
646 nth = (4 * req_nproc);
647 if (nth < (4 * __kmp_xproc))
648 nth = (4 * __kmp_xproc);
650 if (nth > __kmp_max_nth)
658 __kmp_default_tp_capacity(
int req_nproc,
int max_nth,
int all_threads_specified) {
661 if(all_threads_specified)
664 if (nth < (4 * req_nproc))
665 nth = (4 * req_nproc);
666 if (nth < (4 * __kmp_xproc))
667 nth = (4 * __kmp_xproc);
669 if (nth > __kmp_max_nth)
681 __kmp_stg_print_bool( kmp_str_buf_t * buffer,
char const * name,
int value ) {
682 if( __kmp_env_format ) {
683 KMP_STR_BUF_PRINT_BOOL;
685 __kmp_str_buf_print( buffer,
" %s=%s\n", name, value ?
"true" :
"false" );
690 __kmp_stg_print_int( kmp_str_buf_t * buffer,
char const * name,
int value ) {
691 if( __kmp_env_format ) {
692 KMP_STR_BUF_PRINT_INT;
694 __kmp_str_buf_print( buffer,
" %s=%d\n", name, value );
699 __kmp_stg_print_uint64( kmp_str_buf_t * buffer,
char const * name, kmp_uint64 value ) {
700 if( __kmp_env_format ) {
701 KMP_STR_BUF_PRINT_UINT64;
703 __kmp_str_buf_print( buffer,
" %s=%" KMP_UINT64_SPEC
"\n", name, value );
708 __kmp_stg_print_str( kmp_str_buf_t * buffer,
char const * name,
char const * value ) {
709 if( __kmp_env_format ) {
710 KMP_STR_BUF_PRINT_STR;
712 __kmp_str_buf_print( buffer,
" %s=%s\n", name, value );
717 __kmp_stg_print_size( kmp_str_buf_t * buffer,
char const * name,
size_t value ) {
718 if( __kmp_env_format ) {
719 KMP_STR_BUF_PRINT_NAME_EX(name);
720 __kmp_str_buf_print_size( buffer, value );
721 __kmp_str_buf_print( buffer,
"'\n" );
723 __kmp_str_buf_print( buffer,
" %s=", name );
724 __kmp_str_buf_print_size( buffer, value );
725 __kmp_str_buf_print( buffer,
"\n" );
740 __kmp_stg_parse_all_threads(
char const * name,
char const * value,
void * data ) {
742 kmp_setting_t * * rivals = (kmp_setting_t * *) data;
744 rc = __kmp_stg_check_rivals( name, value, rivals );
748 if ( ! __kmp_strcasecmp_with_sentinel(
"all", value, 0 ) ) {
749 __kmp_max_nth = __kmp_xproc;
750 __kmp_allThreadsSpecified = 1;
752 __kmp_stg_parse_int( name, value, 1, __kmp_sys_max_nth, & __kmp_max_nth );
753 __kmp_allThreadsSpecified = 0;
755 K_DIAG( 1, (
"__kmp_max_nth == %d\n", __kmp_max_nth ) );
760 __kmp_stg_print_all_threads( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
761 __kmp_stg_print_int( buffer, name, __kmp_max_nth );
769 __kmp_stg_parse_blocktime(
char const * name,
char const * value,
void * data ) {
770 __kmp_dflt_blocktime = __kmp_convert_to_milliseconds( value );
771 if ( __kmp_dflt_blocktime < 0 ) {
772 __kmp_dflt_blocktime = KMP_DEFAULT_BLOCKTIME;
773 __kmp_msg( kmp_ms_warning, KMP_MSG( InvalidValue, name, value ), __kmp_msg_null );
774 KMP_INFORM( Using_int_Value, name, __kmp_dflt_blocktime );
775 __kmp_env_blocktime = FALSE;
777 if ( __kmp_dflt_blocktime < KMP_MIN_BLOCKTIME ) {
778 __kmp_dflt_blocktime = KMP_MIN_BLOCKTIME;
779 __kmp_msg( kmp_ms_warning, KMP_MSG( SmallValue, name, value ), __kmp_msg_null );
780 KMP_INFORM( MinValueUsing, name, __kmp_dflt_blocktime );
781 }
else if ( __kmp_dflt_blocktime > KMP_MAX_BLOCKTIME ) {
782 __kmp_dflt_blocktime = KMP_MAX_BLOCKTIME;
783 __kmp_msg( kmp_ms_warning, KMP_MSG( LargeValue, name, value ), __kmp_msg_null );
784 KMP_INFORM( MaxValueUsing, name, __kmp_dflt_blocktime );
786 __kmp_env_blocktime = TRUE;
789 __kmp_monitor_wakeups = KMP_WAKEUPS_FROM_BLOCKTIME( __kmp_dflt_blocktime, __kmp_monitor_wakeups );
790 __kmp_bt_intervals = KMP_INTERVALS_FROM_BLOCKTIME( __kmp_dflt_blocktime, __kmp_monitor_wakeups );
791 K_DIAG( 1, (
"__kmp_env_blocktime == %d\n", __kmp_env_blocktime ) );
792 if ( __kmp_env_blocktime ) {
793 K_DIAG( 1, (
"__kmp_dflt_blocktime == %d\n", __kmp_dflt_blocktime ) );
798 __kmp_stg_print_blocktime( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
799 __kmp_stg_print_int( buffer, name, __kmp_dflt_blocktime );
807 __kmp_stg_parse_duplicate_lib_ok(
char const * name,
char const * value,
void * data ) {
810 __kmp_stg_parse_bool( name, value, & __kmp_duplicate_library_ok );
814 __kmp_stg_print_duplicate_lib_ok( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
815 __kmp_stg_print_bool( buffer, name, __kmp_duplicate_library_ok );
822 #if KMP_ARCH_X86 || KMP_ARCH_X86_64
825 __kmp_stg_parse_inherit_fp_control(
char const * name,
char const * value,
void * data ) {
826 __kmp_stg_parse_bool( name, value, & __kmp_inherit_fp_control );
830 __kmp_stg_print_inherit_fp_control( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
832 __kmp_stg_print_bool( buffer, name, __kmp_inherit_fp_control );
843 __kmp_stg_parse_wait_policy(
char const * name,
char const * value,
void * data ) {
845 kmp_stg_wp_data_t * wait = (kmp_stg_wp_data_t *) data;
848 rc = __kmp_stg_check_rivals( name, value, wait->rivals );
854 if ( __kmp_str_match(
"ACTIVE", 1, value ) ) {
855 __kmp_library = library_turnaround;
856 }
else if ( __kmp_str_match(
"PASSIVE", 1, value ) ) {
857 __kmp_library = library_throughput;
859 KMP_WARNING( StgInvalidValue, name, value );
862 if ( __kmp_str_match(
"serial", 1, value ) ) {
863 __kmp_library = library_serial;
864 }
else if ( __kmp_str_match(
"throughput", 2, value ) ) {
865 __kmp_library = library_throughput;
866 }
else if ( __kmp_str_match(
"turnaround", 2, value ) ) {
867 __kmp_library = library_turnaround;
868 }
else if ( __kmp_str_match(
"dedicated", 1, value ) ) {
869 __kmp_library = library_turnaround;
870 }
else if ( __kmp_str_match(
"multiuser", 1, value ) ) {
871 __kmp_library = library_throughput;
873 KMP_WARNING( StgInvalidValue, name, value );
876 __kmp_aux_set_library( __kmp_library );
881 __kmp_stg_print_wait_policy( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
883 kmp_stg_wp_data_t * wait = (kmp_stg_wp_data_t *) data;
884 char const * value = NULL;
887 switch ( __kmp_library ) {
888 case library_turnaround : {
891 case library_throughput : {
896 switch ( __kmp_library ) {
897 case library_serial : {
900 case library_turnaround : {
901 value =
"turnaround";
903 case library_throughput : {
904 value =
"throughput";
908 if ( value != NULL ) {
909 __kmp_stg_print_str( buffer, name, value );
919 __kmp_stg_parse_monitor_stacksize(
char const * name,
char const * value,
void * data ) {
920 __kmp_stg_parse_size(
923 __kmp_sys_min_stksize,
926 & __kmp_monitor_stksize,
932 __kmp_stg_print_monitor_stacksize( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
933 if( __kmp_env_format ) {
934 if ( __kmp_monitor_stksize > 0 )
935 KMP_STR_BUF_PRINT_NAME_EX(name);
937 KMP_STR_BUF_PRINT_NAME;
939 __kmp_str_buf_print( buffer,
" %s", name );
941 if ( __kmp_monitor_stksize > 0 ) {
942 __kmp_str_buf_print_size( buffer, __kmp_monitor_stksize );
944 __kmp_str_buf_print( buffer,
": %s\n", KMP_I18N_STR( NotDefined ) );
946 if( __kmp_env_format && __kmp_monitor_stksize ) {
947 __kmp_str_buf_print( buffer,
"'\n");
957 __kmp_stg_parse_settings(
char const * name,
char const * value,
void * data ) {
958 __kmp_stg_parse_bool( name, value, & __kmp_settings );
962 __kmp_stg_print_settings( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
963 __kmp_stg_print_bool( buffer, name, __kmp_settings );
971 __kmp_stg_parse_stackpad(
char const * name,
char const * value,
void * data ) {
982 __kmp_stg_print_stackpad( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
983 __kmp_stg_print_int( buffer, name, __kmp_stkpadding );
991 __kmp_stg_parse_stackoffset(
char const * name,
char const * value,
void * data ) {
992 __kmp_stg_parse_size(
1004 __kmp_stg_print_stackoffset( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1005 __kmp_stg_print_size( buffer, name, __kmp_stkoffset );
1013 __kmp_stg_parse_stacksize(
char const * name,
char const * value,
void * data ) {
1015 kmp_stg_ss_data_t * stacksize = (kmp_stg_ss_data_t *) data;
1018 rc = __kmp_stg_check_rivals( name, value, stacksize->rivals );
1022 __kmp_stg_parse_size(
1025 __kmp_sys_min_stksize,
1027 & __kmp_env_stksize,
1038 __kmp_stg_print_stacksize( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1039 kmp_stg_ss_data_t * stacksize = (kmp_stg_ss_data_t *) data;
1040 if( __kmp_env_format ) {
1041 KMP_STR_BUF_PRINT_NAME_EX(name);
1042 __kmp_str_buf_print_size( buffer, (__kmp_stksize % 1024) ? __kmp_stksize / stacksize->factor : __kmp_stksize );
1043 __kmp_str_buf_print( buffer,
"'\n" );
1045 __kmp_str_buf_print( buffer,
" %s=", name );
1046 __kmp_str_buf_print_size( buffer, (__kmp_stksize % 1024) ? __kmp_stksize / stacksize->factor : __kmp_stksize );
1047 __kmp_str_buf_print( buffer,
"\n" );
1056 __kmp_stg_parse_version(
char const * name,
char const * value,
void * data ) {
1057 __kmp_stg_parse_bool( name, value, & __kmp_version );
1061 __kmp_stg_print_version( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1062 __kmp_stg_print_bool( buffer, name, __kmp_version );
1070 __kmp_stg_parse_warnings(
char const * name,
char const * value,
void * data ) {
1071 __kmp_stg_parse_bool( name, value, & __kmp_generate_warnings );
1072 if (__kmp_generate_warnings != kmp_warnings_off) {
1073 __kmp_generate_warnings = kmp_warnings_explicit;
1078 __kmp_stg_print_warnings( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1079 __kmp_stg_print_bool( buffer, name, __kmp_generate_warnings );
1087 __kmp_stg_parse_nested(
char const * name,
char const * value,
void * data ) {
1088 __kmp_stg_parse_bool( name, value, & __kmp_dflt_nested );
1092 __kmp_stg_print_nested( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1093 __kmp_stg_print_bool( buffer, name, __kmp_dflt_nested );
1097 __kmp_parse_nested_num_threads(
const char *var,
const char *env, kmp_nested_nthreads_t *nth_array )
1099 const char *next = env;
1100 const char *scan = next;
1103 int prev_comma = FALSE;
1109 if ( *next ==
'\0' ) {
1113 if ( ( ( *next <
'0' ) || ( *next >
'9' ) ) && ( *next !=
',') ) {
1114 KMP_WARNING( NthSyntaxError, var, env );
1118 if ( *next ==
',' ) {
1120 if ( total == 0 || prev_comma ) {
1128 if ( *next >=
'0' && *next <=
'9' ) {
1130 SKIP_DIGITS( next );
1132 const char *tmp = next;
1134 if ( ( *next ==
' ' || *next ==
'\t' ) && ( *tmp >=
'0' && *tmp <=
'9' ) ) {
1135 KMP_WARNING( NthSpacesNotAllowed, var, env );
1140 KMP_DEBUG_ASSERT( total > 0 );
1142 KMP_WARNING( NthSyntaxError, var, env );
1147 if ( ! nth_array->nth ) {
1149 nth_array->nth = (
int * )KMP_INTERNAL_MALLOC(
sizeof(
int ) * total * 2 );
1150 if ( nth_array->nth == NULL ) {
1151 KMP_FATAL( MemoryAllocFailed );
1153 nth_array->size = total * 2;
1155 if ( nth_array->size < total ) {
1158 nth_array->size *= 2;
1159 }
while ( nth_array->size < total );
1161 nth_array->nth = (
int *) KMP_INTERNAL_REALLOC(
1162 nth_array->nth,
sizeof(
int ) * nth_array->size );
1163 if ( nth_array->nth == NULL ) {
1164 KMP_FATAL( MemoryAllocFailed );
1168 nth_array->used = total;
1176 if ( *scan ==
'\0' ) {
1180 if ( *scan ==
',' ) {
1185 nth_array->nth[i++] = 0;
1187 }
else if ( prev_comma ) {
1189 nth_array->nth[i] = nth_array->nth[i - 1];
1198 if ( *scan >=
'0' && *scan <=
'9' ) {
1200 const char *buf = scan;
1201 char const * msg = NULL;
1203 SKIP_DIGITS( scan );
1206 num = __kmp_str_to_int( buf, *scan );
1207 if ( num < KMP_MIN_NTH ) {
1208 msg = KMP_I18N_STR( ValueTooSmall );
1210 }
else if ( num > __kmp_sys_max_nth ) {
1211 msg = KMP_I18N_STR( ValueTooLarge );
1212 num = __kmp_sys_max_nth;
1214 if ( msg != NULL ) {
1216 KMP_WARNING( ParseSizeIntWarn, var, env, msg );
1217 KMP_INFORM( Using_int_Value, var, num );
1219 nth_array->nth[i++] = num;
1225 __kmp_stg_parse_num_threads(
char const * name,
char const * value,
void * data ) {
1227 if ( ! __kmp_strcasecmp_with_sentinel(
"all", value, 0 ) ) {
1229 __kmp_nested_nth.nth = (
int* )KMP_INTERNAL_MALLOC(
sizeof(
int ) );
1230 __kmp_nested_nth.size = __kmp_nested_nth.used = 1;
1231 __kmp_nested_nth.nth[0] = __kmp_dflt_team_nth = __kmp_dflt_team_nth_ub = __kmp_xproc;
1233 __kmp_parse_nested_num_threads( name, value, & __kmp_nested_nth );
1234 if ( __kmp_nested_nth.nth ) {
1235 __kmp_dflt_team_nth = __kmp_nested_nth.nth[0];
1236 if ( __kmp_dflt_team_nth_ub < __kmp_dflt_team_nth ) {
1237 __kmp_dflt_team_nth_ub = __kmp_dflt_team_nth;
1241 K_DIAG( 1, (
"__kmp_dflt_team_nth == %d\n", __kmp_dflt_team_nth ) );
1245 __kmp_stg_print_num_threads( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1246 if( __kmp_env_format ) {
1247 KMP_STR_BUF_PRINT_NAME;
1249 __kmp_str_buf_print( buffer,
" %s", name );
1251 if ( __kmp_nested_nth.used ) {
1253 __kmp_str_buf_init( &buf );
1254 for (
int i = 0; i < __kmp_nested_nth.used; i++) {
1255 __kmp_str_buf_print( &buf,
"%d", __kmp_nested_nth.nth[i] );
1256 if ( i < __kmp_nested_nth.used - 1 ) {
1257 __kmp_str_buf_print( &buf,
"," );
1260 __kmp_str_buf_print( buffer,
"='%s'\n", buf.str );
1261 __kmp_str_buf_free(&buf);
1263 __kmp_str_buf_print( buffer,
": %s\n", KMP_I18N_STR( NotDefined ) );
1272 __kmp_stg_parse_tasking(
char const * name,
char const * value,
void * data ) {
1273 __kmp_stg_parse_int( name, value, 0, (
int)tskm_max, (
int *)&__kmp_tasking_mode );
1277 __kmp_stg_print_tasking( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1278 __kmp_stg_print_int( buffer, name, __kmp_tasking_mode );
1282 __kmp_stg_parse_task_stealing(
char const * name,
char const * value,
void * data ) {
1283 __kmp_stg_parse_int( name, value, 0, 1, (
int *)&__kmp_task_stealing_constraint );
1287 __kmp_stg_print_task_stealing( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1288 __kmp_stg_print_int( buffer, name, __kmp_task_stealing_constraint );
1292 __kmp_stg_parse_max_active_levels(
char const * name,
char const * value,
void * data ) {
1293 __kmp_stg_parse_int( name, value, 0, KMP_MAX_ACTIVE_LEVELS_LIMIT, & __kmp_dflt_max_active_levels );
1297 __kmp_stg_print_max_active_levels( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1298 __kmp_stg_print_int( buffer, name, __kmp_dflt_max_active_levels );
1301 #if KMP_NESTED_HOT_TEAMS
1307 __kmp_stg_parse_hot_teams_level(
char const * name,
char const * value,
void * data ) {
1308 if ( TCR_4(__kmp_init_parallel) ) {
1309 KMP_WARNING( EnvParallelWarn, name );
1312 __kmp_stg_parse_int( name, value, 0, KMP_MAX_ACTIVE_LEVELS_LIMIT, & __kmp_hot_teams_max_level );
1316 __kmp_stg_print_hot_teams_level( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1317 __kmp_stg_print_int( buffer, name, __kmp_hot_teams_max_level );
1321 __kmp_stg_parse_hot_teams_mode(
char const * name,
char const * value,
void * data ) {
1322 if ( TCR_4(__kmp_init_parallel) ) {
1323 KMP_WARNING( EnvParallelWarn, name );
1326 __kmp_stg_parse_int( name, value, 0, KMP_MAX_ACTIVE_LEVELS_LIMIT, & __kmp_hot_teams_mode );
1330 __kmp_stg_print_hot_teams_mode( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1331 __kmp_stg_print_int( buffer, name, __kmp_hot_teams_mode );
1334 #endif // KMP_NESTED_HOT_TEAMS
1340 #if KMP_HANDLE_SIGNALS
1343 __kmp_stg_parse_handle_signals(
char const * name,
char const * value,
void * data ) {
1344 __kmp_stg_parse_bool( name, value, & __kmp_handle_signals );
1348 __kmp_stg_print_handle_signals( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1349 __kmp_stg_print_bool( buffer, name, __kmp_handle_signals );
1352 #endif // KMP_HANDLE_SIGNALS
1360 #define KMP_STG_X_DEBUG( x ) \
1361 static void __kmp_stg_parse_##x##_debug( char const * name, char const * value, void * data ) { \
1362 __kmp_stg_parse_int( name, value, 0, INT_MAX, & kmp_##x##_debug ); \
1364 static void __kmp_stg_print_##x##_debug( kmp_str_buf_t * buffer, char const * name, void * data ) { \
1365 __kmp_stg_print_int( buffer, name, kmp_##x##_debug ); \
1368 KMP_STG_X_DEBUG( a )
1369 KMP_STG_X_DEBUG( b )
1370 KMP_STG_X_DEBUG( c )
1371 KMP_STG_X_DEBUG( d )
1372 KMP_STG_X_DEBUG( e )
1373 KMP_STG_X_DEBUG( f )
1375 #undef KMP_STG_X_DEBUG
1378 __kmp_stg_parse_debug(
char const * name,
char const * value,
void * data ) {
1380 __kmp_stg_parse_int( name, value, 0, INT_MAX, & debug );
1381 if ( kmp_a_debug < debug ) {
1382 kmp_a_debug = debug;
1384 if ( kmp_b_debug < debug ) {
1385 kmp_b_debug = debug;
1387 if ( kmp_c_debug < debug ) {
1388 kmp_c_debug = debug;
1390 if ( kmp_d_debug < debug ) {
1391 kmp_d_debug = debug;
1393 if ( kmp_e_debug < debug ) {
1394 kmp_e_debug = debug;
1396 if ( kmp_f_debug < debug ) {
1397 kmp_f_debug = debug;
1402 __kmp_stg_parse_debug_buf(
char const * name,
char const * value,
void * data ) {
1403 __kmp_stg_parse_bool( name, value, & __kmp_debug_buf );
1406 if ( __kmp_debug_buf ) {
1408 int elements = __kmp_debug_buf_lines * __kmp_debug_buf_chars;
1411 __kmp_debug_buffer = (
char *) __kmp_page_allocate( elements *
sizeof(
char ) );
1412 for ( i = 0; i < elements; i += __kmp_debug_buf_chars )
1413 __kmp_debug_buffer[i] =
'\0';
1415 __kmp_debug_count = 0;
1417 K_DIAG( 1, (
"__kmp_debug_buf = %d\n", __kmp_debug_buf ) );
1421 __kmp_stg_print_debug_buf( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1422 __kmp_stg_print_bool( buffer, name, __kmp_debug_buf );
1426 __kmp_stg_parse_debug_buf_atomic(
char const * name,
char const * value,
void * data ) {
1427 __kmp_stg_parse_bool( name, value, & __kmp_debug_buf_atomic );
1431 __kmp_stg_print_debug_buf_atomic( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1432 __kmp_stg_print_bool( buffer, name, __kmp_debug_buf_atomic );
1436 __kmp_stg_parse_debug_buf_chars(
char const * name,
char const * value,
void * data ) {
1437 __kmp_stg_parse_int(
1440 KMP_DEBUG_BUF_CHARS_MIN,
1442 & __kmp_debug_buf_chars
1447 __kmp_stg_print_debug_buf_chars( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1448 __kmp_stg_print_int( buffer, name, __kmp_debug_buf_chars );
1452 __kmp_stg_parse_debug_buf_lines(
char const * name,
char const * value,
void * data ) {
1453 __kmp_stg_parse_int(
1456 KMP_DEBUG_BUF_LINES_MIN,
1458 & __kmp_debug_buf_lines
1463 __kmp_stg_print_debug_buf_lines( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1464 __kmp_stg_print_int( buffer, name, __kmp_debug_buf_lines );
1468 __kmp_stg_parse_diag(
char const * name,
char const * value,
void * data ) {
1469 __kmp_stg_parse_int( name, value, 0, INT_MAX, & kmp_diag );
1473 __kmp_stg_print_diag( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1474 __kmp_stg_print_int( buffer, name, kmp_diag );
1484 __kmp_stg_parse_align_alloc(
char const * name,
char const * value,
void * data ) {
1485 __kmp_stg_parse_size(
1491 & __kmp_align_alloc,
1497 __kmp_stg_print_align_alloc( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1498 __kmp_stg_print_size( buffer, name, __kmp_align_alloc );
1509 __kmp_stg_parse_barrier_branch_bit(
char const * name,
char const * value,
void * data ) {
1513 for (
int i=bs_plain_barrier; i<bs_last_barrier; i++ ) {
1514 var = __kmp_barrier_branch_bit_env_name[ i ];
1515 if ( ( strcmp( var, name) == 0 ) && ( value != 0 ) ) {
1518 comma = (
char *) strchr( value,
',' );
1519 __kmp_barrier_gather_branch_bits[ i ] = ( kmp_uint32 ) __kmp_str_to_int( value,
',' );
1521 if ( comma == NULL ) {
1522 __kmp_barrier_release_branch_bits[ i ] = __kmp_barrier_release_bb_dflt;
1524 __kmp_barrier_release_branch_bits[ i ] = (kmp_uint32) __kmp_str_to_int( comma + 1, 0 );
1526 if ( __kmp_barrier_release_branch_bits[ i ] > KMP_MAX_BRANCH_BITS ) {
1527 __kmp_msg( kmp_ms_warning, KMP_MSG( BarrReleaseValueInvalid, name, comma + 1 ), __kmp_msg_null );
1528 __kmp_barrier_release_branch_bits[ i ] = __kmp_barrier_release_bb_dflt;
1531 if ( __kmp_barrier_gather_branch_bits[ i ] > KMP_MAX_BRANCH_BITS ) {
1532 KMP_WARNING( BarrGatherValueInvalid, name, value );
1533 KMP_INFORM( Using_uint_Value, name, __kmp_barrier_gather_bb_dflt );
1534 __kmp_barrier_gather_branch_bits[ i ] = __kmp_barrier_gather_bb_dflt;
1537 K_DIAG(1, (
"%s == %d,%d\n", __kmp_barrier_branch_bit_env_name[ i ], \
1538 __kmp_barrier_gather_branch_bits [ i ], \
1539 __kmp_barrier_release_branch_bits [ i ]))
1544 __kmp_stg_print_barrier_branch_bit( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1546 for (
int i=bs_plain_barrier; i<bs_last_barrier; i++ ) {
1547 var = __kmp_barrier_branch_bit_env_name[ i ];
1548 if ( strcmp( var, name) == 0 ) {
1549 if( __kmp_env_format ) {
1550 KMP_STR_BUF_PRINT_NAME_EX(__kmp_barrier_branch_bit_env_name[ i ]);
1552 __kmp_str_buf_print( buffer,
" %s='", __kmp_barrier_branch_bit_env_name[ i ] );
1554 __kmp_str_buf_print( buffer,
"%d,%d'\n", __kmp_barrier_gather_branch_bits [ i ], __kmp_barrier_release_branch_bits [ i ]);
1568 __kmp_stg_parse_barrier_pattern(
char const * name,
char const * value,
void * data ) {
1572 for (
int i=bs_plain_barrier; i<bs_last_barrier; i++ ) {
1573 var = __kmp_barrier_pattern_env_name[ i ];
1575 if ( ( strcmp ( var, name ) == 0 ) && ( value != 0 ) ) {
1577 char *comma = (
char *) strchr( value,
',' );
1580 for ( j = bp_linear_bar; j<bp_last_bar; j++ ) {
1581 if (__kmp_match_with_sentinel( __kmp_barrier_pattern_name[j], value, 1,
',' )) {
1582 __kmp_barrier_gather_pattern[ i ] = (kmp_bar_pat_e) j;
1586 if ( j == bp_last_bar ) {
1587 KMP_WARNING( BarrGatherValueInvalid, name, value );
1588 KMP_INFORM( Using_str_Value, name, __kmp_barrier_pattern_name[ bp_linear_bar ] );
1592 if ( comma != NULL ) {
1593 for ( j = bp_linear_bar; j < bp_last_bar; j++ ) {
1594 if ( __kmp_str_match( __kmp_barrier_pattern_name[j], 1, comma + 1 ) ) {
1595 __kmp_barrier_release_pattern[ i ] = (kmp_bar_pat_e) j;
1599 if (j == bp_last_bar) {
1600 __kmp_msg( kmp_ms_warning, KMP_MSG( BarrReleaseValueInvalid, name, comma + 1 ), __kmp_msg_null );
1601 KMP_INFORM( Using_str_Value, name, __kmp_barrier_pattern_name[ bp_linear_bar ] );
1609 __kmp_stg_print_barrier_pattern( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1611 for (
int i=bs_plain_barrier; i<bs_last_barrier; i++ ) {
1612 var = __kmp_barrier_pattern_env_name[ i ];
1613 if ( strcmp ( var, name ) == 0 ) {
1614 int j = __kmp_barrier_gather_pattern [ i ];
1615 int k = __kmp_barrier_release_pattern [ i ];
1616 if( __kmp_env_format ) {
1617 KMP_STR_BUF_PRINT_NAME_EX(__kmp_barrier_pattern_env_name[ i ]);
1619 __kmp_str_buf_print( buffer,
" %s='", __kmp_barrier_pattern_env_name[ i ] );
1621 __kmp_str_buf_print( buffer,
"%s,%s'\n", __kmp_barrier_pattern_name [ j ], __kmp_barrier_pattern_name [ k ]);
1631 __kmp_stg_parse_abort_delay(
char const * name,
char const * value,
void * data ) {
1633 int delay = __kmp_abort_delay / 1000;
1634 __kmp_stg_parse_int( name, value, 0, INT_MAX / 1000, & delay );
1635 __kmp_abort_delay = delay * 1000;
1639 __kmp_stg_print_abort_delay( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1640 __kmp_stg_print_int( buffer, name, __kmp_abort_delay );
1648 __kmp_stg_parse_cpuinfo_file(
char const * name,
char const * value,
void * data ) {
1649 #if KMP_AFFINITY_SUPPORTED
1650 __kmp_stg_parse_str( name, value, & __kmp_cpuinfo_file );
1651 K_DIAG( 1, (
"__kmp_cpuinfo_file == %s\n", __kmp_cpuinfo_file ) );
1656 __kmp_stg_print_cpuinfo_file( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1657 #if KMP_AFFINITY_SUPPORTED
1658 if( __kmp_env_format ) {
1659 KMP_STR_BUF_PRINT_NAME;
1661 __kmp_str_buf_print( buffer,
" %s", name );
1663 if ( __kmp_cpuinfo_file ) {
1664 __kmp_str_buf_print( buffer,
"='%s'\n", __kmp_cpuinfo_file );
1666 __kmp_str_buf_print( buffer,
": %s\n", KMP_I18N_STR( NotDefined ) );
1676 __kmp_stg_parse_force_reduction(
char const * name,
char const * value,
void * data )
1678 kmp_stg_fr_data_t * reduction = (kmp_stg_fr_data_t *) data;
1681 rc = __kmp_stg_check_rivals( name, value, reduction->rivals );
1685 if ( reduction->force ) {
1687 if( __kmp_str_match(
"critical", 0, value ) )
1688 __kmp_force_reduction_method = critical_reduce_block;
1689 else if( __kmp_str_match(
"atomic", 0, value ) )
1690 __kmp_force_reduction_method = atomic_reduce_block;
1691 else if( __kmp_str_match(
"tree", 0, value ) )
1692 __kmp_force_reduction_method = tree_reduce_block;
1694 KMP_FATAL( UnknownForceReduction, name, value );
1698 __kmp_stg_parse_bool( name, value, & __kmp_determ_red );
1699 if( __kmp_determ_red ) {
1700 __kmp_force_reduction_method = tree_reduce_block;
1702 __kmp_force_reduction_method = reduction_method_not_defined;
1705 K_DIAG( 1, (
"__kmp_force_reduction_method == %d\n", __kmp_force_reduction_method ) );
1709 __kmp_stg_print_force_reduction( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1711 kmp_stg_fr_data_t * reduction = (kmp_stg_fr_data_t *) data;
1712 char const * value = NULL;
1713 if ( reduction->force ) {
1714 if( __kmp_force_reduction_method == critical_reduce_block) {
1715 __kmp_stg_print_str( buffer, name,
"critical");
1716 }
else if ( __kmp_force_reduction_method == atomic_reduce_block ) {
1717 __kmp_stg_print_str( buffer, name,
"atomic");
1718 }
else if ( __kmp_force_reduction_method == tree_reduce_block ) {
1719 __kmp_stg_print_str( buffer, name,
"tree");
1721 if( __kmp_env_format ) {
1722 KMP_STR_BUF_PRINT_NAME;
1724 __kmp_str_buf_print( buffer,
" %s", name );
1726 __kmp_str_buf_print( buffer,
": %s\n", KMP_I18N_STR( NotDefined ) );
1729 __kmp_stg_print_bool( buffer, name, __kmp_determ_red );
1740 __kmp_stg_parse_storage_map(
char const * name,
char const * value,
void * data ) {
1741 if ( __kmp_str_match(
"verbose", 1, value ) ) {
1742 __kmp_storage_map = TRUE;
1743 __kmp_storage_map_verbose = TRUE;
1744 __kmp_storage_map_verbose_specified = TRUE;
1747 __kmp_storage_map_verbose = FALSE;
1748 __kmp_stg_parse_bool( name, value, & __kmp_storage_map );
1753 __kmp_stg_print_storage_map( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1754 if ( __kmp_storage_map_verbose || __kmp_storage_map_verbose_specified ) {
1755 __kmp_stg_print_str( buffer, name,
"verbose" );
1757 __kmp_stg_print_bool( buffer, name, __kmp_storage_map );
1766 __kmp_stg_parse_all_threadprivate(
char const * name,
char const * value,
void * data ) {
1767 __kmp_stg_parse_int( name, value, __kmp_allThreadsSpecified ? __kmp_max_nth : 1, __kmp_max_nth,
1768 & __kmp_tp_capacity );
1772 __kmp_stg_print_all_threadprivate( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1773 __kmp_stg_print_int( buffer, name, __kmp_tp_capacity );
1782 __kmp_stg_parse_foreign_threads_threadprivate(
char const * name,
char const * value,
void * data ) {
1783 __kmp_stg_parse_bool( name, value, & __kmp_foreign_tp );
1787 __kmp_stg_print_foreign_threads_threadprivate( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1788 __kmp_stg_print_bool( buffer, name, __kmp_foreign_tp );
1796 #if KMP_AFFINITY_SUPPORTED
1801 __kmp_parse_affinity_proc_id_list(
const char *var,
const char *env,
1802 const char **nextEnv,
char **proclist )
1804 const char *scan = env;
1805 const char *next = scan;
1811 int start, end, stride;
1815 if (*next ==
'\0') {
1828 if ((*next <
'0') || (*next >
'9')) {
1829 KMP_WARNING( AffSyntaxError, var );
1833 num = __kmp_str_to_int(scan, *next);
1834 KMP_ASSERT(num >= 0);
1858 if ((*next <
'0') || (*next >
'9')) {
1859 KMP_WARNING( AffSyntaxError, var );
1864 num = __kmp_str_to_int(scan, *next);
1865 KMP_ASSERT(num >= 0);
1880 if ((*next <
'0') || (*next >
'9')) {
1882 KMP_WARNING( AffSyntaxError, var );
1892 start = __kmp_str_to_int(scan, *next);
1893 KMP_ASSERT(start >= 0);
1918 if ((*next <
'0') || (*next >
'9')) {
1919 KMP_WARNING( AffSyntaxError, var );
1923 end = __kmp_str_to_int(scan, *next);
1924 KMP_ASSERT(end >= 0);
1945 if ((*next <
'0') || (*next >
'9')) {
1946 KMP_WARNING( AffSyntaxError, var );
1950 stride = __kmp_str_to_int(scan, *next);
1951 KMP_ASSERT(stride >= 0);
1959 KMP_WARNING( AffZeroStride, var );
1964 KMP_WARNING( AffStartGreaterEnd, var, start, end );
1970 KMP_WARNING( AffStrideLessZero, var, start, end );
1974 if ((end - start) / stride > 65536 ) {
1975 KMP_WARNING( AffRangeTooBig, var, end, start, stride );
1994 int len = next - env;
1995 char *retlist = (
char *)__kmp_allocate((len + 1) *
sizeof(char));
1996 memcpy(retlist, env, len *
sizeof(
char));
1997 retlist[len] =
'\0';
1998 *proclist = retlist;
2008 static kmp_setting_t *__kmp_affinity_notype = NULL;
2011 __kmp_parse_affinity_env(
char const * name,
char const * value,
2012 enum affinity_type * out_type,
2013 char ** out_proclist,
2017 enum affinity_gran * out_gran,
2018 int * out_gran_levels,
2024 char * buffer = NULL;
2034 int max_proclist = 0;
2041 KMP_ASSERT( value != NULL );
2043 if ( TCR_4(__kmp_init_middle) ) {
2044 KMP_WARNING( EnvMiddleWarn, name );
2045 __kmp_env_toPrint( name, 0 );
2048 __kmp_env_toPrint( name, 1 );
2050 buffer = __kmp_str_format(
"%s", value );
2062 #define EMIT_WARN(skip,errlist) \
2066 SKIP_TO(next, ','); \
2070 KMP_WARNING errlist; \
2073 if (ch == ',') next++; \
2078 #define _set_param(_guard,_var,_val) \
2080 if ( _guard == 0 ) { \
2083 EMIT_WARN( FALSE, ( AffParamDefined, name, start ) ); \
2088 #define set_type(val) _set_param( type, *out_type, val )
2089 #define set_verbose(val) _set_param( verbose, *out_verbose, val )
2090 #define set_warnings(val) _set_param( warnings, *out_warn, val )
2091 #define set_respect(val) _set_param( respect, *out_respect, val )
2092 #define set_dups(val) _set_param( dups, *out_dups, val )
2093 #define set_proclist(val) _set_param( proclist, *out_proclist, val )
2095 #define set_gran(val,levels) \
2097 if ( gran == 0 ) { \
2099 *out_gran_levels = levels; \
2101 EMIT_WARN( FALSE, ( AffParamDefined, name, start ) ); \
2107 KMP_DEBUG_ASSERT( ( __kmp_nested_proc_bind.bind_types != NULL )
2108 && ( __kmp_nested_proc_bind.used > 0 ) );
2111 while ( *buf !=
'\0' ) {
2114 if (__kmp_match_str(
"none", buf, (
const char **)&next)) {
2115 set_type( affinity_none );
2117 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
2120 }
else if (__kmp_match_str(
"scatter", buf, (
const char **)&next)) {
2121 set_type( affinity_scatter );
2123 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2126 }
else if (__kmp_match_str(
"compact", buf, (
const char **)&next)) {
2127 set_type( affinity_compact );
2129 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2132 }
else if (__kmp_match_str(
"logical", buf, (
const char **)&next)) {
2133 set_type( affinity_logical );
2135 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2138 }
else if (__kmp_match_str(
"physical", buf, (
const char **)&next)) {
2139 set_type( affinity_physical );
2141 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2144 }
else if (__kmp_match_str(
"explicit", buf, (
const char **)&next)) {
2145 set_type( affinity_explicit );
2147 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2151 }
else if (__kmp_match_str(
"balanced", buf, (
const char **)&next)) {
2152 set_type( affinity_balanced );
2154 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2158 }
else if (__kmp_match_str(
"disabled", buf, (
const char **)&next)) {
2159 set_type( affinity_disabled );
2161 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
2164 }
else if (__kmp_match_str(
"verbose", buf, (
const char **)&next)) {
2165 set_verbose( TRUE );
2167 }
else if (__kmp_match_str(
"noverbose", buf, (
const char **)&next)) {
2168 set_verbose( FALSE );
2170 }
else if (__kmp_match_str(
"warnings", buf, (
const char **)&next)) {
2171 set_warnings( TRUE );
2173 }
else if (__kmp_match_str(
"nowarnings", buf, (
const char **)&next)) {
2174 set_warnings( FALSE );
2176 }
else if (__kmp_match_str(
"respect", buf, (
const char **)&next)) {
2177 set_respect( TRUE );
2179 }
else if (__kmp_match_str(
"norespect", buf, (
const char **)&next)) {
2180 set_respect( FALSE );
2182 }
else if (__kmp_match_str(
"duplicates", buf, (
const char **)&next)
2183 || __kmp_match_str(
"dups", buf, (
const char **)&next)) {
2186 }
else if (__kmp_match_str(
"noduplicates", buf, (
const char **)&next)
2187 || __kmp_match_str(
"nodups", buf, (
const char **)&next)) {
2190 }
else if (__kmp_match_str(
"granularity", buf, (
const char **)&next)
2191 || __kmp_match_str(
"gran", buf, (
const char **)&next)) {
2194 EMIT_WARN( TRUE, ( AffInvalidParam, name, start ) );
2201 if (__kmp_match_str(
"fine", buf, (
const char **)&next)) {
2202 set_gran( affinity_gran_fine, -1 );
2204 }
else if (__kmp_match_str(
"thread", buf, (
const char **)&next)) {
2205 set_gran( affinity_gran_thread, -1 );
2207 }
else if (__kmp_match_str(
"core", buf, (
const char **)&next)) {
2208 set_gran( affinity_gran_core, -1 );
2210 }
else if (__kmp_match_str(
"package", buf, (
const char **)&next)) {
2211 set_gran( affinity_gran_package, -1 );
2213 }
else if (__kmp_match_str(
"node", buf, (
const char **)&next)) {
2214 set_gran( affinity_gran_node, -1 );
2216 # if KMP_OS_WINDOWS && KMP_ARCH_X86_64
2217 }
else if (__kmp_match_str(
"group", buf, (
const char **)&next)) {
2218 set_gran( affinity_gran_group, -1 );
2221 }
else if ((*buf >=
'0') && (*buf <=
'9')) {
2225 n = __kmp_str_to_int( buf, *next );
2228 set_gran( affinity_gran_default, n );
2230 EMIT_WARN( TRUE, ( AffInvalidParam, name, start ) );
2233 }
else if (__kmp_match_str(
"proclist", buf, (
const char **)&next)) {
2234 char *temp_proclist;
2238 EMIT_WARN( TRUE, ( AffInvalidParam, name, start ) );
2244 EMIT_WARN( TRUE, ( AffInvalidParam, name, start ) );
2249 if (! __kmp_parse_affinity_proc_id_list(name, buf,
2250 (
const char **)&next, &temp_proclist)) {
2255 if (*next ==
']') next++;
2257 if (*next ==
',') next++;
2262 EMIT_WARN( TRUE, ( AffInvalidParam, name, start ) );
2266 set_proclist( temp_proclist );
2267 }
else if ((*buf >=
'0') && (*buf <=
'9')) {
2272 n = __kmp_str_to_int( buf, *next );
2276 number[ count ] = n;
2278 KMP_WARNING( AffManyParams, name, start );
2282 EMIT_WARN( TRUE, ( AffInvalidParam, name, start ) );
2291 else if (*next !=
'\0') {
2292 const char *temp = next;
2293 EMIT_WARN( TRUE, ( ParseExtraCharsWarn, name, temp ) );
2305 #undef set_granularity
2307 KMP_INTERNAL_FREE( buffer );
2311 KMP_WARNING( AffProcListNoType, name );
2312 __kmp_affinity_type = affinity_explicit;
2314 else if ( __kmp_affinity_type != affinity_explicit ) {
2315 KMP_WARNING( AffProcListNotExplicit, name );
2316 KMP_ASSERT( *out_proclist != NULL );
2317 KMP_INTERNAL_FREE( *out_proclist );
2318 *out_proclist = NULL;
2321 switch ( *out_type ) {
2322 case affinity_logical:
2323 case affinity_physical: {
2325 *out_offset = number[ 0 ];
2328 KMP_WARNING( AffManyParamsForLogic, name, number[ 1 ] );
2332 case affinity_balanced: {
2334 *out_compact = number[ 0 ];
2337 *out_offset = number[ 1 ];
2341 if( __kmp_affinity_gran != affinity_gran_default && __kmp_affinity_gran != affinity_gran_fine
2342 && __kmp_affinity_gran != affinity_gran_thread && __kmp_affinity_gran != affinity_gran_core ) {
2343 if( __kmp_affinity_verbose || __kmp_affinity_warnings ) {
2344 KMP_WARNING( AffGranUsing,
"KMP_AFFINITY",
"core" );
2346 __kmp_affinity_gran = affinity_gran_fine;
2350 case affinity_scatter:
2351 case affinity_compact: {
2353 *out_compact = number[ 0 ];
2356 *out_offset = number[ 1 ];
2359 case affinity_explicit: {
2360 if ( *out_proclist == NULL ) {
2361 KMP_WARNING( AffNoProcList, name );
2362 __kmp_affinity_type = affinity_none;
2365 KMP_WARNING( AffNoParam, name,
"explicit" );
2368 case affinity_none: {
2370 KMP_WARNING( AffNoParam, name,
"none" );
2373 case affinity_disabled: {
2375 KMP_WARNING( AffNoParam, name,
"disabled" );
2378 case affinity_default: {
2380 KMP_WARNING( AffNoParam, name,
"default" );
2390 __kmp_stg_parse_affinity(
char const * name,
char const * value,
void * data )
2392 kmp_setting_t **rivals = (kmp_setting_t **) data;
2395 rc = __kmp_stg_check_rivals( name, value, rivals );
2400 __kmp_parse_affinity_env( name, value, & __kmp_affinity_type,
2401 & __kmp_affinity_proclist, & __kmp_affinity_verbose,
2402 & __kmp_affinity_warnings, & __kmp_affinity_respect_mask,
2403 & __kmp_affinity_gran, & __kmp_affinity_gran_levels,
2404 & __kmp_affinity_dups, & __kmp_affinity_compact,
2405 & __kmp_affinity_offset );
2410 __kmp_stg_print_affinity( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
2411 if( __kmp_env_format ) {
2412 KMP_STR_BUF_PRINT_NAME_EX(name);
2414 __kmp_str_buf_print( buffer,
" %s='", name );
2416 if ( __kmp_affinity_verbose ) {
2417 __kmp_str_buf_print( buffer,
"%s,",
"verbose");
2419 __kmp_str_buf_print( buffer,
"%s,",
"noverbose");
2421 if ( __kmp_affinity_warnings ) {
2422 __kmp_str_buf_print( buffer,
"%s,",
"warnings");
2424 __kmp_str_buf_print( buffer,
"%s,",
"nowarnings");
2426 if ( KMP_AFFINITY_CAPABLE() ) {
2427 if ( __kmp_affinity_respect_mask ) {
2428 __kmp_str_buf_print( buffer,
"%s,",
"respect");
2430 __kmp_str_buf_print( buffer,
"%s,",
"norespect");
2432 switch ( __kmp_affinity_gran ) {
2433 case affinity_gran_default:
2434 __kmp_str_buf_print( buffer,
"%s",
"granularity=default,");
2436 case affinity_gran_fine:
2437 __kmp_str_buf_print( buffer,
"%s",
"granularity=fine,");
2439 case affinity_gran_thread:
2440 __kmp_str_buf_print( buffer,
"%s",
"granularity=thread,");
2442 case affinity_gran_core:
2443 __kmp_str_buf_print( buffer,
"%s",
"granularity=core,");
2445 case affinity_gran_package:
2446 __kmp_str_buf_print( buffer,
"%s",
"granularity=package,");
2448 case affinity_gran_node:
2449 __kmp_str_buf_print( buffer,
"%s",
"granularity=node,");
2451 # if KMP_OS_WINDOWS && KMP_ARCH_X86_64
2452 case affinity_gran_group:
2453 __kmp_str_buf_print( buffer,
"%s",
"granularity=group,");
2457 if ( __kmp_affinity_dups ) {
2458 __kmp_str_buf_print( buffer,
"%s,",
"duplicates");
2460 __kmp_str_buf_print( buffer,
"%s,",
"noduplicates");
2463 if ( ! KMP_AFFINITY_CAPABLE() ) {
2464 __kmp_str_buf_print( buffer,
"%s",
"disabled" );
2466 else switch ( __kmp_affinity_type ){
2468 __kmp_str_buf_print( buffer,
"%s",
"none");
2470 case affinity_physical:
2471 __kmp_str_buf_print( buffer,
"%s,%d",
"physical",
2472 __kmp_affinity_offset );
2474 case affinity_logical:
2475 __kmp_str_buf_print( buffer,
"%s,%d",
"logical",
2476 __kmp_affinity_offset );
2478 case affinity_compact:
2479 __kmp_str_buf_print( buffer,
"%s,%d,%d",
"compact",
2480 __kmp_affinity_compact, __kmp_affinity_offset );
2482 case affinity_scatter:
2483 __kmp_str_buf_print( buffer,
"%s,%d,%d",
"scatter",
2484 __kmp_affinity_compact, __kmp_affinity_offset );
2486 case affinity_explicit:
2487 __kmp_str_buf_print( buffer,
"%s=[%s],%s",
"proclist",
2488 __kmp_affinity_proclist,
"explicit" );
2491 case affinity_balanced:
2492 __kmp_str_buf_print( buffer,
"%s,%d,%d",
"balanced",
2493 __kmp_affinity_compact, __kmp_affinity_offset );
2496 case affinity_disabled:
2497 __kmp_str_buf_print( buffer,
"%s",
"disabled");
2499 case affinity_default:
2500 __kmp_str_buf_print( buffer,
"%s",
"default");
2503 __kmp_str_buf_print( buffer,
"%s",
"<unknown>");
2506 __kmp_str_buf_print( buffer,
"'\n" );
2509 # ifdef KMP_GOMP_COMPAT
2512 __kmp_stg_parse_gomp_cpu_affinity(
char const * name,
char const * value,
void * data )
2514 const char * next = NULL;
2515 char * temp_proclist;
2516 kmp_setting_t **rivals = (kmp_setting_t **) data;
2519 rc = __kmp_stg_check_rivals( name, value, rivals );
2524 if ( TCR_4(__kmp_init_middle) ) {
2525 KMP_WARNING( EnvMiddleWarn, name );
2526 __kmp_env_toPrint( name, 0 );
2530 __kmp_env_toPrint( name, 1 );
2532 if ( __kmp_parse_affinity_proc_id_list( name, value, &next,
2535 if (*next ==
'\0') {
2539 __kmp_affinity_proclist = temp_proclist;
2540 __kmp_affinity_type = affinity_explicit;
2541 __kmp_affinity_gran = affinity_gran_fine;
2543 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2547 KMP_WARNING( AffSyntaxError, name );
2548 if (temp_proclist != NULL) {
2549 KMP_INTERNAL_FREE((
void *)temp_proclist);
2557 __kmp_affinity_type = affinity_none;
2589 __kmp_parse_subplace_list(
const char *var,
const char **scan )
2594 int start, count, stride;
2600 if ((**scan <
'0') || (**scan >
'9')) {
2601 KMP_WARNING( SyntaxErrorUsing, var,
"\"threads\"" );
2606 start = __kmp_str_to_int(*scan, *next);
2607 KMP_ASSERT(start >= 0);
2614 if (**scan ==
'}') {
2617 if (**scan ==
',') {
2621 if (**scan !=
':') {
2622 KMP_WARNING( SyntaxErrorUsing, var,
"\"threads\"" );
2631 if ((**scan <
'0') || (**scan >
'9')) {
2632 KMP_WARNING( SyntaxErrorUsing, var,
"\"threads\"" );
2637 count = __kmp_str_to_int(*scan, *next);
2638 KMP_ASSERT(count >= 0);
2645 if (**scan ==
'}') {
2648 if (**scan ==
',') {
2652 if (**scan !=
':') {
2653 KMP_WARNING( SyntaxErrorUsing, var,
"\"threads\"" );
2664 if (**scan ==
'+') {
2668 if (**scan ==
'-') {
2676 if ((**scan <
'0') || (**scan >
'9')) {
2677 KMP_WARNING( SyntaxErrorUsing, var,
"\"threads\"" );
2682 stride = __kmp_str_to_int(*scan, *next);
2683 KMP_ASSERT(stride >= 0);
2691 if (**scan ==
'}') {
2694 if (**scan ==
',') {
2699 KMP_WARNING( SyntaxErrorUsing, var,
"\"threads\"" );
2706 __kmp_parse_place(
const char *var,
const char ** scan )
2714 if (**scan ==
'{') {
2716 if (! __kmp_parse_subplace_list(var, scan)) {
2719 if (**scan !=
'}') {
2720 KMP_WARNING( SyntaxErrorUsing, var,
"\"threads\"" );
2725 else if (**scan ==
'!') {
2727 return __kmp_parse_place(var, scan);
2729 else if ((**scan >=
'0') && (**scan <=
'9')) {
2732 int proc = __kmp_str_to_int(*scan, *next);
2733 KMP_ASSERT(proc >= 0);
2737 KMP_WARNING( SyntaxErrorUsing, var,
"\"threads\"" );
2744 __kmp_parse_place_list(
const char *var,
const char *env,
char **place_list )
2746 const char *scan = env;
2747 const char *next = scan;
2750 int start, count, stride;
2752 if (! __kmp_parse_place(var, &scan)) {
2760 if (*scan ==
'\0') {
2768 KMP_WARNING( SyntaxErrorUsing, var,
"\"threads\"" );
2777 if ((*scan <
'0') || (*scan >
'9')) {
2778 KMP_WARNING( SyntaxErrorUsing, var,
"\"threads\"" );
2783 count = __kmp_str_to_int(scan, *next);
2784 KMP_ASSERT(count >= 0);
2791 if (*scan ==
'\0') {
2799 KMP_WARNING( SyntaxErrorUsing, var,
"\"threads\"" );
2822 if ((*scan <
'0') || (*scan >
'9')) {
2823 KMP_WARNING( SyntaxErrorUsing, var,
"\"threads\"" );
2828 stride = __kmp_str_to_int(scan, *next);
2829 KMP_ASSERT(stride >= 0);
2837 if (*scan ==
'\0') {
2845 KMP_WARNING( SyntaxErrorUsing, var,
"\"threads\"" );
2850 int len = scan - env;
2851 char *retlist = (
char *)__kmp_allocate((len + 1) *
sizeof(char));
2852 memcpy(retlist, env, len *
sizeof(
char));
2853 retlist[len] =
'\0';
2854 *place_list = retlist;
2860 __kmp_stg_parse_places(
char const * name,
char const * value,
void * data )
2863 const char *scan = value;
2864 const char *next = scan;
2865 const char *kind =
"\"threads\"";
2866 kmp_setting_t **rivals = (kmp_setting_t **) data;
2869 rc = __kmp_stg_check_rivals( name, value, rivals );
2878 if ( __kmp_nested_proc_bind.bind_types[0] == proc_bind_default ) {
2879 __kmp_nested_proc_bind.bind_types[0] = proc_bind_true;
2884 if ( __kmp_match_str(
"threads", scan, &next ) ) {
2886 __kmp_affinity_type = affinity_compact;
2887 __kmp_affinity_gran = affinity_gran_thread;
2888 __kmp_affinity_dups = FALSE;
2889 kind =
"\"threads\"";
2891 else if ( __kmp_match_str(
"cores", scan, &next ) ) {
2893 __kmp_affinity_type = affinity_compact;
2894 __kmp_affinity_gran = affinity_gran_core;
2895 __kmp_affinity_dups = FALSE;
2898 else if ( __kmp_match_str(
"sockets", scan, &next ) ) {
2900 __kmp_affinity_type = affinity_compact;
2901 __kmp_affinity_gran = affinity_gran_package;
2902 __kmp_affinity_dups = FALSE;
2903 kind =
"\"sockets\"";
2906 if ( __kmp_affinity_proclist != NULL ) {
2907 KMP_INTERNAL_FREE( (
void *)__kmp_affinity_proclist );
2908 __kmp_affinity_proclist = NULL;
2910 if ( __kmp_parse_place_list( name, value, &__kmp_affinity_proclist ) ) {
2911 __kmp_affinity_type = affinity_explicit;
2912 __kmp_affinity_gran = affinity_gran_fine;
2913 __kmp_affinity_dups = FALSE;
2914 if ( __kmp_nested_proc_bind.bind_types[0] == proc_bind_default ) {
2915 __kmp_nested_proc_bind.bind_types[0] = proc_bind_true;
2921 if ( __kmp_nested_proc_bind.bind_types[0] == proc_bind_default ) {
2922 __kmp_nested_proc_bind.bind_types[0] = proc_bind_true;
2926 if ( *scan ==
'\0' ) {
2933 if ( *scan !=
'(' ) {
2934 KMP_WARNING( SyntaxErrorUsing, name, kind );
2942 count = __kmp_str_to_int(scan, *next);
2943 KMP_ASSERT(count >= 0);
2947 if ( *scan !=
')' ) {
2948 KMP_WARNING( SyntaxErrorUsing, name, kind );
2954 if ( *scan !=
'\0' ) {
2955 KMP_WARNING( ParseExtraCharsWarn, name, scan );
2957 __kmp_affinity_num_places = count;
2961 __kmp_stg_print_places( kmp_str_buf_t * buffer,
char const * name,
2964 if( __kmp_env_format ) {
2965 KMP_STR_BUF_PRINT_NAME;
2967 __kmp_str_buf_print( buffer,
" %s", name );
2969 if ( ( __kmp_nested_proc_bind.used == 0 )
2970 || ( __kmp_nested_proc_bind.bind_types == NULL )
2971 || ( __kmp_nested_proc_bind.bind_types[0] == proc_bind_false ) ) {
2972 __kmp_str_buf_print( buffer,
": %s\n", KMP_I18N_STR( NotDefined ) );
2974 else if ( __kmp_affinity_type == affinity_explicit ) {
2975 if ( __kmp_affinity_proclist != NULL ) {
2976 __kmp_str_buf_print( buffer,
"='%s'\n", __kmp_affinity_proclist );
2979 __kmp_str_buf_print( buffer,
": %s\n", KMP_I18N_STR( NotDefined ) );
2982 else if ( __kmp_affinity_type == affinity_compact ) {
2984 if ( __kmp_affinity_num_masks > 0 ) {
2985 num = __kmp_affinity_num_masks;
2987 else if ( __kmp_affinity_num_places > 0 ) {
2988 num = __kmp_affinity_num_places;
2993 if ( __kmp_affinity_gran == affinity_gran_thread ) {
2995 __kmp_str_buf_print( buffer,
"='threads(%d)'\n", num );
2998 __kmp_str_buf_print( buffer,
"='threads'\n" );
3001 else if ( __kmp_affinity_gran == affinity_gran_core ) {
3003 __kmp_str_buf_print( buffer,
"='cores(%d)' \n", num );
3006 __kmp_str_buf_print( buffer,
"='cores'\n" );
3009 else if ( __kmp_affinity_gran == affinity_gran_package ) {
3011 __kmp_str_buf_print( buffer,
"='sockets(%d)'\n", num );
3014 __kmp_str_buf_print( buffer,
"='sockets'\n" );
3018 __kmp_str_buf_print( buffer,
": %s\n", KMP_I18N_STR( NotDefined ) );
3022 __kmp_str_buf_print( buffer,
": %s\n", KMP_I18N_STR( NotDefined ) );
3028 # if (! OMP_40_ENABLED)
3031 __kmp_stg_parse_proc_bind(
char const * name,
char const * value,
void * data )
3034 kmp_setting_t **rivals = (kmp_setting_t **) data;
3037 rc = __kmp_stg_check_rivals( name, value, rivals );
3045 __kmp_stg_parse_bool( name, value, & enabled );
3050 __kmp_affinity_type = affinity_scatter;
3051 __kmp_affinity_gran = affinity_gran_core;
3054 __kmp_affinity_type = affinity_none;
3062 __kmp_stg_parse_topology_method(
char const * name,
char const * value,
3064 if ( __kmp_str_match(
"all", 1, value ) ) {
3065 __kmp_affinity_top_method = affinity_top_method_all;
3067 # if KMP_ARCH_X86 || KMP_ARCH_X86_64
3068 else if ( __kmp_str_match(
"x2apic id", 9, value )
3069 || __kmp_str_match(
"x2apic_id", 9, value )
3070 || __kmp_str_match(
"x2apic-id", 9, value )
3071 || __kmp_str_match(
"x2apicid", 8, value )
3072 || __kmp_str_match(
"cpuid leaf 11", 13, value )
3073 || __kmp_str_match(
"cpuid_leaf_11", 13, value )
3074 || __kmp_str_match(
"cpuid-leaf-11", 13, value )
3075 || __kmp_str_match(
"cpuid leaf11", 12, value )
3076 || __kmp_str_match(
"cpuid_leaf11", 12, value )
3077 || __kmp_str_match(
"cpuid-leaf11", 12, value )
3078 || __kmp_str_match(
"cpuidleaf 11", 12, value )
3079 || __kmp_str_match(
"cpuidleaf_11", 12, value )
3080 || __kmp_str_match(
"cpuidleaf-11", 12, value )
3081 || __kmp_str_match(
"cpuidleaf11", 11, value )
3082 || __kmp_str_match(
"cpuid 11", 8, value )
3083 || __kmp_str_match(
"cpuid_11", 8, value )
3084 || __kmp_str_match(
"cpuid-11", 8, value )
3085 || __kmp_str_match(
"cpuid11", 7, value )
3086 || __kmp_str_match(
"leaf 11", 7, value )
3087 || __kmp_str_match(
"leaf_11", 7, value )
3088 || __kmp_str_match(
"leaf-11", 7, value )
3089 || __kmp_str_match(
"leaf11", 6, value ) ) {
3090 __kmp_affinity_top_method = affinity_top_method_x2apicid;
3092 else if ( __kmp_str_match(
"apic id", 7, value )
3093 || __kmp_str_match(
"apic_id", 7, value )
3094 || __kmp_str_match(
"apic-id", 7, value )
3095 || __kmp_str_match(
"apicid", 6, value )
3096 || __kmp_str_match(
"cpuid leaf 4", 12, value )
3097 || __kmp_str_match(
"cpuid_leaf_4", 12, value )
3098 || __kmp_str_match(
"cpuid-leaf-4", 12, value )
3099 || __kmp_str_match(
"cpuid leaf4", 11, value )
3100 || __kmp_str_match(
"cpuid_leaf4", 11, value )
3101 || __kmp_str_match(
"cpuid-leaf4", 11, value )
3102 || __kmp_str_match(
"cpuidleaf 4", 11, value )
3103 || __kmp_str_match(
"cpuidleaf_4", 11, value )
3104 || __kmp_str_match(
"cpuidleaf-4", 11, value )
3105 || __kmp_str_match(
"cpuidleaf4", 10, value )
3106 || __kmp_str_match(
"cpuid 4", 7, value )
3107 || __kmp_str_match(
"cpuid_4", 7, value )
3108 || __kmp_str_match(
"cpuid-4", 7, value )
3109 || __kmp_str_match(
"cpuid4", 6, value )
3110 || __kmp_str_match(
"leaf 4", 6, value )
3111 || __kmp_str_match(
"leaf_4", 6, value )
3112 || __kmp_str_match(
"leaf-4", 6, value )
3113 || __kmp_str_match(
"leaf4", 5, value ) ) {
3114 __kmp_affinity_top_method = affinity_top_method_apicid;
3117 else if ( __kmp_str_match(
"/proc/cpuinfo", 2, value )
3118 || __kmp_str_match(
"cpuinfo", 5, value )) {
3119 __kmp_affinity_top_method = affinity_top_method_cpuinfo;
3121 # if KMP_OS_WINDOWS && KMP_ARCH_X86_64
3122 else if ( __kmp_str_match(
"group", 1, value ) ) {
3123 __kmp_affinity_top_method = affinity_top_method_group;
3126 else if ( __kmp_str_match(
"flat", 1, value ) ) {
3127 __kmp_affinity_top_method = affinity_top_method_flat;
3130 KMP_WARNING( StgInvalidValue, name, value );
3135 __kmp_stg_print_topology_method( kmp_str_buf_t * buffer,
char const * name,
3138 char const * value = NULL;
3140 switch ( __kmp_affinity_top_method ) {
3141 case affinity_top_method_default:
3145 case affinity_top_method_all:
3149 # if KMP_ARCH_X86 || KMP_ARCH_X86_64
3150 case affinity_top_method_x2apicid:
3151 value =
"x2APIC id";
3154 case affinity_top_method_apicid:
3159 case affinity_top_method_cpuinfo:
3163 # if KMP_OS_WINDOWS && KMP_ARCH_X86_64
3164 case affinity_top_method_group:
3169 case affinity_top_method_flat:
3174 if ( value != NULL ) {
3175 __kmp_stg_print_str( buffer, name, value );
3190 __kmp_stg_parse_proc_bind(
char const * name,
char const * value,
void * data )
3192 kmp_setting_t **rivals = (kmp_setting_t **) data;
3195 rc = __kmp_stg_check_rivals( name, value, rivals );
3203 KMP_DEBUG_ASSERT( (__kmp_nested_proc_bind.bind_types != NULL)
3204 && ( __kmp_nested_proc_bind.used > 0 ) );
3206 const char *buf = value;
3210 if ( (*buf >=
'0') && (*buf <=
'9') ) {
3212 SKIP_DIGITS( next );
3213 num = __kmp_str_to_int( buf, *next );
3214 KMP_ASSERT( num >= 0 );
3223 if ( __kmp_match_str(
"disabled", buf, &next ) ) {
3226 # if KMP_AFFINITY_SUPPORTED
3227 __kmp_affinity_type = affinity_disabled;
3229 __kmp_nested_proc_bind.used = 1;
3230 __kmp_nested_proc_bind.bind_types[0] = proc_bind_disabled;
3232 else if ( ( num == (
int)proc_bind_false )
3233 || __kmp_match_str(
"false", buf, &next ) ) {
3236 # if KMP_AFFINITY_SUPPORTED
3237 __kmp_affinity_type = affinity_none;
3239 __kmp_nested_proc_bind.used = 1;
3240 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
3242 else if ( ( num == (
int)proc_bind_true )
3243 || __kmp_match_str(
"true", buf, &next ) ) {
3246 __kmp_nested_proc_bind.used = 1;
3247 __kmp_nested_proc_bind.bind_types[0] = proc_bind_true;
3255 for ( scan = buf; *scan !=
'\0'; scan++ ) {
3256 if ( *scan ==
',' ) {
3264 if ( __kmp_nested_proc_bind.size < nelem ) {
3265 __kmp_nested_proc_bind.bind_types = (kmp_proc_bind_t *)
3266 KMP_INTERNAL_REALLOC( __kmp_nested_proc_bind.bind_types,
3267 sizeof(kmp_proc_bind_t) * nelem );
3268 if ( __kmp_nested_proc_bind.bind_types == NULL ) {
3269 KMP_FATAL( MemoryAllocFailed );
3271 __kmp_nested_proc_bind.size = nelem;
3273 __kmp_nested_proc_bind.used = nelem;
3280 enum kmp_proc_bind_t bind;
3282 if ( ( num == (
int)proc_bind_master )
3283 || __kmp_match_str(
"master", buf, &next ) ) {
3286 bind = proc_bind_master;
3288 else if ( ( num == (
int)proc_bind_close )
3289 || __kmp_match_str(
"close", buf, &next ) ) {
3292 bind = proc_bind_close;
3294 else if ( ( num == (
int)proc_bind_spread )
3295 || __kmp_match_str(
"spread", buf, &next ) ) {
3298 bind = proc_bind_spread;
3301 KMP_WARNING( StgInvalidValue, name, value );
3302 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
3303 __kmp_nested_proc_bind.used = 1;
3307 __kmp_nested_proc_bind.bind_types[i++] = bind;
3311 KMP_DEBUG_ASSERT( *buf ==
',' );
3318 if ( (*buf >=
'0') && (*buf <=
'9') ) {
3320 SKIP_DIGITS( next );
3321 num = __kmp_str_to_int( buf, *next );
3322 KMP_ASSERT( num >= 0 );
3332 if ( *buf !=
'\0' ) {
3333 KMP_WARNING( ParseExtraCharsWarn, name, buf );
3339 __kmp_stg_print_proc_bind( kmp_str_buf_t * buffer,
char const * name,
3342 int nelem = __kmp_nested_proc_bind.used;
3343 if( __kmp_env_format ) {
3344 KMP_STR_BUF_PRINT_NAME;
3346 __kmp_str_buf_print( buffer,
" %s", name );
3349 __kmp_str_buf_print( buffer,
": %s\n", KMP_I18N_STR( NotDefined ) );
3353 __kmp_str_buf_print( buffer,
"='", name );
3354 for ( i = 0; i < nelem; i++ ) {
3355 switch ( __kmp_nested_proc_bind.bind_types[i] ) {
3356 case proc_bind_false:
3357 __kmp_str_buf_print( buffer,
"false" );
3360 case proc_bind_true:
3361 __kmp_str_buf_print( buffer,
"true" );
3364 case proc_bind_master:
3365 __kmp_str_buf_print( buffer,
"master" );
3368 case proc_bind_close:
3369 __kmp_str_buf_print( buffer,
"close" );
3372 case proc_bind_spread:
3373 __kmp_str_buf_print( buffer,
"spread" );
3376 case proc_bind_disabled:
3377 __kmp_str_buf_print( buffer,
"disabled" );
3380 case proc_bind_intel:
3381 __kmp_str_buf_print( buffer,
"intel" );
3384 case proc_bind_default:
3385 __kmp_str_buf_print( buffer,
"default" );
3388 if ( i < nelem - 1 ) {
3389 __kmp_str_buf_print( buffer,
"," );
3392 __kmp_str_buf_print( buffer,
"'\n" );
3404 __kmp_stg_parse_omp_dynamic(
char const * name,
char const * value,
void * data )
3406 __kmp_stg_parse_bool( name, value, & (__kmp_global.g.g_dynamic) );
3410 __kmp_stg_print_omp_dynamic( kmp_str_buf_t * buffer,
char const * name,
void * data )
3412 __kmp_stg_print_bool( buffer, name, __kmp_global.g.g_dynamic );
3416 __kmp_stg_parse_kmp_dynamic_mode(
char const * name,
char const * value,
void * data )
3418 if ( TCR_4(__kmp_init_parallel) ) {
3419 KMP_WARNING( EnvParallelWarn, name );
3420 __kmp_env_toPrint( name, 0 );
3423 #ifdef USE_LOAD_BALANCE
3424 else if ( __kmp_str_match(
"load balance", 2, value )
3425 || __kmp_str_match(
"load_balance", 2, value )
3426 || __kmp_str_match(
"load-balance", 2, value )
3427 || __kmp_str_match(
"loadbalance", 2, value )
3428 || __kmp_str_match(
"balance", 1, value ) ) {
3429 __kmp_global.g.g_dynamic_mode = dynamic_load_balance;
3432 else if ( __kmp_str_match(
"thread limit", 1, value )
3433 || __kmp_str_match(
"thread_limit", 1, value )
3434 || __kmp_str_match(
"thread-limit", 1, value )
3435 || __kmp_str_match(
"threadlimit", 1, value )
3436 || __kmp_str_match(
"limit", 2, value ) ) {
3437 __kmp_global.g.g_dynamic_mode = dynamic_thread_limit;
3439 else if ( __kmp_str_match(
"random", 1, value ) ) {
3440 __kmp_global.g.g_dynamic_mode = dynamic_random;
3443 KMP_WARNING( StgInvalidValue, name, value );
3448 __kmp_stg_print_kmp_dynamic_mode( kmp_str_buf_t * buffer,
char const * name,
void * data )
3451 if ( __kmp_global.g.g_dynamic_mode == dynamic_default ) {
3452 __kmp_str_buf_print( buffer,
" %s: %s \n", name, KMP_I18N_STR( NotDefined ) );
3454 # ifdef USE_LOAD_BALANCE
3455 else if ( __kmp_global.g.g_dynamic_mode == dynamic_load_balance ) {
3456 __kmp_stg_print_str( buffer, name,
"load balance" );
3459 else if ( __kmp_global.g.g_dynamic_mode == dynamic_thread_limit ) {
3460 __kmp_stg_print_str( buffer, name,
"thread limit" );
3462 else if ( __kmp_global.g.g_dynamic_mode == dynamic_random ) {
3463 __kmp_stg_print_str( buffer, name,
"random" );
3472 #ifdef USE_LOAD_BALANCE
3479 __kmp_stg_parse_ld_balance_interval(
char const * name,
char const * value,
void * data )
3481 double interval = __kmp_convert_to_double( value );
3482 if ( interval >= 0 ) {
3483 __kmp_load_balance_interval = interval;
3485 KMP_WARNING( StgInvalidValue, name, value );
3490 __kmp_stg_print_ld_balance_interval( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3492 __kmp_str_buf_print( buffer,
" %s=%8.6f\n", name, __kmp_load_balance_interval );
3505 __kmp_stg_parse_init_at_fork(
char const * name,
char const * value,
void * data ) {
3506 __kmp_stg_parse_bool( name, value, & __kmp_need_register_atfork );
3507 if ( __kmp_need_register_atfork ) {
3508 __kmp_need_register_atfork_specified = TRUE;
3513 __kmp_stg_print_init_at_fork( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3514 __kmp_stg_print_bool( buffer, name, __kmp_need_register_atfork_specified );
3522 __kmp_stg_parse_schedule(
char const * name,
char const * value,
void * data ) {
3524 if ( value != NULL ) {
3525 size_t length = strlen( value );
3526 if ( length > INT_MAX ) {
3527 KMP_WARNING( LongValue, name );
3530 if( value[ length - 1 ] ==
'"' || value[ length -1 ] ==
'\'' )
3531 KMP_WARNING( UnbalancedQuotes, name );
3535 semicolon = (
char *) strchr( value,
';' );
3536 if( *value && semicolon != value ) {
3537 char *comma = (
char *) strchr( value,
',' );
3544 if ( !__kmp_strcasecmp_with_sentinel(
"static", value, sentinel ) ) {
3545 if( !__kmp_strcasecmp_with_sentinel(
"greedy", comma,
';' ) ) {
3546 __kmp_static = kmp_sch_static_greedy;
3548 }
else if( !__kmp_strcasecmp_with_sentinel(
"balanced", comma,
';' ) ) {
3549 __kmp_static = kmp_sch_static_balanced;
3552 }
else if ( !__kmp_strcasecmp_with_sentinel(
"guided", value, sentinel ) ) {
3553 if ( !__kmp_strcasecmp_with_sentinel(
"iterative", comma,
';' ) ) {
3554 __kmp_guided = kmp_sch_guided_iterative_chunked;
3556 }
else if ( !__kmp_strcasecmp_with_sentinel(
"analytical", comma,
';' ) ) {
3558 __kmp_guided = kmp_sch_guided_analytical_chunked;
3562 KMP_WARNING( InvalidClause, name, value );
3564 KMP_WARNING( EmptyClause, name );
3565 }
while ( (value = semicolon ? semicolon + 1 : NULL) );
3572 __kmp_stg_print_schedule( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3573 if( __kmp_env_format ) {
3574 KMP_STR_BUF_PRINT_NAME_EX(name);
3576 __kmp_str_buf_print( buffer,
" %s='", name );
3578 if ( __kmp_static == kmp_sch_static_greedy ) {
3579 __kmp_str_buf_print( buffer,
"%s",
"static,greedy");
3580 }
else if ( __kmp_static == kmp_sch_static_balanced ) {
3581 __kmp_str_buf_print ( buffer,
"%s",
"static,balanced");
3583 if ( __kmp_guided == kmp_sch_guided_iterative_chunked ) {
3584 __kmp_str_buf_print( buffer,
";%s'\n",
"guided,iterative");
3585 }
else if ( __kmp_guided == kmp_sch_guided_analytical_chunked ) {
3586 __kmp_str_buf_print( buffer,
";%s'\n",
"guided,analytical");
3595 __kmp_stg_parse_omp_schedule(
char const * name,
char const * value,
void * data )
3599 length = strlen( value );
3601 char *comma = (
char *) strchr( value,
',' );
3602 if( value[ length - 1 ] ==
'"' || value[ length -1 ] ==
'\'')
3603 KMP_WARNING( UnbalancedQuotes, name );
3605 if (!__kmp_strcasecmp_with_sentinel(
"dynamic", value,
','))
3606 __kmp_sched = kmp_sch_dynamic_chunked;
3607 else if (!__kmp_strcasecmp_with_sentinel(
"guided", value,
','))
3610 else if (!__kmp_strcasecmp_with_sentinel(
"auto", value,
',')) {
3613 __kmp_msg( kmp_ms_warning, KMP_MSG( IgnoreChunk, name, comma ), __kmp_msg_null );
3617 else if (!__kmp_strcasecmp_with_sentinel(
"trapezoidal", value,
','))
3618 __kmp_sched = kmp_sch_trapezoidal;
3619 else if (!__kmp_strcasecmp_with_sentinel(
"static", value,
','))
3621 #ifdef KMP_STATIC_STEAL_ENABLED
3622 else if (KMP_ARCH_X86_64 &&
3623 !__kmp_strcasecmp_with_sentinel(
"static_steal", value,
','))
3627 KMP_WARNING( StgInvalidValue, name, value );
3630 if( value && comma ) {
3631 __kmp_env_chunk = TRUE;
3634 __kmp_sched = kmp_sch_static_chunked;
3636 __kmp_chunk = __kmp_str_to_int( comma, 0 );
3637 if ( __kmp_chunk < 1 ) {
3638 __kmp_chunk = KMP_DEFAULT_CHUNK;
3639 __kmp_msg( kmp_ms_warning, KMP_MSG( InvalidChunk, name, comma ), __kmp_msg_null );
3640 KMP_INFORM( Using_int_Value, name, __kmp_chunk );
3646 }
else if ( __kmp_chunk > KMP_MAX_CHUNK ) {
3647 __kmp_chunk = KMP_MAX_CHUNK;
3648 __kmp_msg( kmp_ms_warning, KMP_MSG( LargeChunk, name, comma ), __kmp_msg_null );
3649 KMP_INFORM( Using_int_Value, name, __kmp_chunk );
3652 __kmp_env_chunk = FALSE;
3654 KMP_WARNING( EmptyString, name );
3656 K_DIAG(1, (
"__kmp_static == %d\n", __kmp_static))
3657 K_DIAG(1, ("__kmp_guided == %d\n", __kmp_guided))
3658 K_DIAG(1, ("__kmp_sched == %d\n", __kmp_sched))
3659 K_DIAG(1, ("__kmp_chunk == %d\n", __kmp_chunk))
3663 __kmp_stg_print_omp_schedule( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3664 if( __kmp_env_format ) {
3665 KMP_STR_BUF_PRINT_NAME_EX(name);
3667 __kmp_str_buf_print( buffer,
" %s='", name );
3669 if ( __kmp_chunk ) {
3670 switch ( __kmp_sched ) {
3671 case kmp_sch_dynamic_chunked:
3672 __kmp_str_buf_print( buffer,
"%s,%d'\n",
"dynamic", __kmp_chunk);
3674 case kmp_sch_guided_iterative_chunked:
3675 case kmp_sch_guided_analytical_chunked:
3676 __kmp_str_buf_print( buffer,
"%s,%d'\n",
"guided", __kmp_chunk);
3678 case kmp_sch_trapezoidal:
3679 __kmp_str_buf_print( buffer,
"%s,%d'\n",
"trapezoidal", __kmp_chunk);
3682 case kmp_sch_static_chunked:
3683 case kmp_sch_static_balanced:
3684 case kmp_sch_static_greedy:
3685 __kmp_str_buf_print( buffer,
"%s,%d'\n",
"static", __kmp_chunk);
3688 __kmp_str_buf_print( buffer,
"%s,%d'\n",
"static_steal", __kmp_chunk);
3691 __kmp_str_buf_print( buffer,
"%s,%d'\n",
"auto", __kmp_chunk);
3695 switch ( __kmp_sched ) {
3696 case kmp_sch_dynamic_chunked:
3697 __kmp_str_buf_print( buffer,
"%s'\n",
"dynamic");
3699 case kmp_sch_guided_iterative_chunked:
3700 case kmp_sch_guided_analytical_chunked:
3701 __kmp_str_buf_print( buffer,
"%s'\n",
"guided");
3703 case kmp_sch_trapezoidal:
3704 __kmp_str_buf_print( buffer,
"%s'\n",
"trapezoidal");
3707 case kmp_sch_static_chunked:
3708 case kmp_sch_static_balanced:
3709 case kmp_sch_static_greedy:
3710 __kmp_str_buf_print( buffer,
"%s'\n",
"static");
3713 __kmp_str_buf_print( buffer,
"%s'\n",
"static_steal");
3716 __kmp_str_buf_print( buffer,
"%s'\n",
"auto");
3727 __kmp_stg_parse_atomic_mode(
char const * name,
char const * value,
void * data ) {
3731 #ifdef KMP_GOMP_COMPAT
3734 __kmp_stg_parse_int( name, value, 0, max, & mode );
3738 __kmp_atomic_mode = mode;
3743 __kmp_stg_print_atomic_mode( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3744 __kmp_stg_print_int( buffer, name, __kmp_atomic_mode );
3753 __kmp_stg_parse_consistency_check(
char const * name,
char const * value,
void * data ) {
3754 if ( ! __kmp_strcasecmp_with_sentinel(
"all", value, 0 ) ) {
3758 __kmp_env_consistency_check = TRUE;
3759 }
else if ( ! __kmp_strcasecmp_with_sentinel(
"none", value, 0 ) ) {
3760 __kmp_env_consistency_check = FALSE;
3762 KMP_WARNING( StgInvalidValue, name, value );
3767 __kmp_stg_print_consistency_check( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3769 const char *value = NULL;
3771 if ( __kmp_env_consistency_check ) {
3777 if ( value != NULL ) {
3778 __kmp_stg_print_str( buffer, name, value );
3792 __kmp_stg_parse_itt_prepare_delay(
char const * name,
char const * value,
void * data )
3796 __kmp_stg_parse_int( name, value, 0, INT_MAX, & delay );
3797 __kmp_itt_prepare_delay = delay;
3801 __kmp_stg_print_itt_prepare_delay( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3802 __kmp_stg_print_uint64( buffer, name, __kmp_itt_prepare_delay );
3806 #endif // USE_ITT_NOTIFY
3814 __kmp_stg_parse_malloc_pool_incr(
char const * name,
char const * value,
void * data ) {
3815 __kmp_stg_parse_size(
3818 KMP_MIN_MALLOC_POOL_INCR,
3819 KMP_MAX_MALLOC_POOL_INCR,
3821 & __kmp_malloc_pool_incr,
3827 __kmp_stg_print_malloc_pool_incr( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3828 __kmp_stg_print_size( buffer, name, __kmp_malloc_pool_incr );
3840 __kmp_stg_parse_par_range_env(
char const * name,
char const * value,
void * data ) {
3841 __kmp_stg_parse_par_range(
3845 __kmp_par_range_routine,
3846 __kmp_par_range_filename,
3847 & __kmp_par_range_lb,
3848 & __kmp_par_range_ub
3853 __kmp_stg_print_par_range_env( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3854 if (__kmp_par_range != 0) {
3855 __kmp_stg_print_str( buffer, name, par_range_to_print );
3864 __kmp_stg_parse_yield_cycle(
char const * name,
char const * value,
void * data ) {
3865 int flag = __kmp_yield_cycle;
3866 __kmp_stg_parse_bool( name, value, & flag );
3867 __kmp_yield_cycle = flag;
3871 __kmp_stg_print_yield_cycle( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3872 __kmp_stg_print_bool( buffer, name, __kmp_yield_cycle );
3876 __kmp_stg_parse_yield_on(
char const * name,
char const * value,
void * data ) {
3877 __kmp_stg_parse_int( name, value, 2, INT_MAX, & __kmp_yield_on_count );
3881 __kmp_stg_print_yield_on( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3882 __kmp_stg_print_int( buffer, name, __kmp_yield_on_count );
3886 __kmp_stg_parse_yield_off(
char const * name,
char const * value,
void * data ) {
3887 __kmp_stg_parse_int( name, value, 2, INT_MAX, & __kmp_yield_off_count );
3891 __kmp_stg_print_yield_off( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3892 __kmp_stg_print_int( buffer, name, __kmp_yield_off_count );
3902 __kmp_stg_parse_init_wait(
char const * name,
char const * value,
void * data ) {
3904 KMP_ASSERT( ( __kmp_init_wait & 1 ) == 0 );
3905 wait = __kmp_init_wait / 2;
3906 __kmp_stg_parse_int( name, value, KMP_MIN_INIT_WAIT, KMP_MAX_INIT_WAIT, & wait );
3907 __kmp_init_wait = wait * 2;
3908 KMP_ASSERT( ( __kmp_init_wait & 1 ) == 0 );
3909 __kmp_yield_init = __kmp_init_wait;
3913 __kmp_stg_print_init_wait( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3914 __kmp_stg_print_int( buffer, name, __kmp_init_wait );
3918 __kmp_stg_parse_next_wait(
char const * name,
char const * value,
void * data ) {
3920 KMP_ASSERT( ( __kmp_next_wait & 1 ) == 0 );
3921 wait = __kmp_next_wait / 2;
3922 __kmp_stg_parse_int( name, value, KMP_MIN_NEXT_WAIT, KMP_MAX_NEXT_WAIT, & wait );
3923 __kmp_next_wait = wait * 2;
3924 KMP_ASSERT( ( __kmp_next_wait & 1 ) == 0 );
3925 __kmp_yield_next = __kmp_next_wait;
3929 __kmp_stg_print_next_wait( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3930 __kmp_stg_print_int( buffer, name, __kmp_next_wait );
3939 __kmp_stg_parse_gtid_mode(
char const * name,
char const * value,
void * data ) {
3950 #ifdef KMP_TDATA_GTID
3953 __kmp_stg_parse_int( name, value, 0, max, & mode );
3957 __kmp_adjust_gtid_mode = TRUE;
3960 __kmp_gtid_mode = mode;
3961 __kmp_adjust_gtid_mode = FALSE;
3966 __kmp_stg_print_gtid_mode( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3967 if ( __kmp_adjust_gtid_mode ) {
3968 __kmp_stg_print_int( buffer, name, 0 );
3971 __kmp_stg_print_int( buffer, name, __kmp_gtid_mode );
3981 __kmp_stg_parse_lock_block(
char const * name,
char const * value,
void * data ) {
3982 __kmp_stg_parse_int( name, value, 0, KMP_INT_MAX, & __kmp_num_locks_in_block );
3986 __kmp_stg_print_lock_block( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3987 __kmp_stg_print_int( buffer, name, __kmp_num_locks_in_block );
3995 __kmp_stg_parse_lock_kind(
char const * name,
char const * value,
void * data ) {
3996 if ( __kmp_init_user_locks ) {
3997 KMP_WARNING( EnvLockWarn, name );
4001 if ( __kmp_str_match(
"tas", 2, value )
4002 || __kmp_str_match(
"test and set", 2, value )
4003 || __kmp_str_match(
"test_and_set", 2, value )
4004 || __kmp_str_match(
"test-and-set", 2, value )
4005 || __kmp_str_match(
"test andset", 2, value )
4006 || __kmp_str_match(
"test_andset", 2, value )
4007 || __kmp_str_match(
"test-andset", 2, value )
4008 || __kmp_str_match(
"testand set", 2, value )
4009 || __kmp_str_match(
"testand_set", 2, value )
4010 || __kmp_str_match(
"testand-set", 2, value )
4011 || __kmp_str_match(
"testandset", 2, value ) ) {
4012 __kmp_user_lock_kind = lk_tas;
4014 #if KMP_OS_LINUX && (KMP_ARCH_X86 || KMP_ARCH_X86_64 || KMP_ARCH_ARM)
4015 else if ( __kmp_str_match(
"futex", 1, value ) ) {
4016 if ( __kmp_futex_determine_capable() ) {
4017 __kmp_user_lock_kind = lk_futex;
4020 KMP_WARNING( FutexNotSupported, name, value );
4024 else if ( __kmp_str_match(
"ticket", 2, value ) ) {
4025 __kmp_user_lock_kind = lk_ticket;
4027 else if ( __kmp_str_match(
"queuing", 1, value )
4028 || __kmp_str_match(
"queue", 1, value ) ) {
4029 __kmp_user_lock_kind = lk_queuing;
4031 else if ( __kmp_str_match(
"drdpa ticket", 1, value )
4032 || __kmp_str_match(
"drdpa_ticket", 1, value )
4033 || __kmp_str_match(
"drdpa-ticket", 1, value )
4034 || __kmp_str_match(
"drdpaticket", 1, value )
4035 || __kmp_str_match(
"drdpa", 1, value ) ) {
4036 __kmp_user_lock_kind = lk_drdpa;
4038 #if KMP_USE_ADAPTIVE_LOCKS
4039 else if ( __kmp_str_match(
"adaptive", 1, value ) ) {
4040 if( __kmp_cpuinfo.rtm ) {
4041 __kmp_user_lock_kind = lk_adaptive;
4043 KMP_WARNING( AdaptiveNotSupported, name, value );
4044 __kmp_user_lock_kind = lk_queuing;
4047 #endif // KMP_USE_ADAPTIVE_LOCKS
4049 KMP_WARNING( StgInvalidValue, name, value );
4054 __kmp_stg_print_lock_kind( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
4055 const char *value = NULL;
4057 switch ( __kmp_user_lock_kind ) {
4066 #if KMP_OS_LINUX && (KMP_ARCH_X86 || KMP_ARCH_X86_64)
4083 #if KMP_USE_ADAPTIVE_LOCKS
4090 if ( value != NULL ) {
4091 __kmp_stg_print_str( buffer, name, value );
4095 #if KMP_USE_ADAPTIVE_LOCKS
4104 __kmp_stg_parse_adaptive_lock_props(
const char *name,
const char *value,
void *data )
4106 int max_retries = 0;
4107 int max_badness = 0;
4109 const char *next = value;
4110 const char *scan = next;
4113 int prev_comma = FALSE;
4118 for ( i = 0; i < 3 ; i++) {
4121 if ( *next ==
'\0' ) {
4125 if ( ( ( *next < '0' || *next >
'9' ) && *next !=
',' ) || total > 2 ) {
4126 KMP_WARNING( EnvSyntaxError, name, value );
4130 if ( *next ==
',' ) {
4132 if ( total == 0 || prev_comma ) {
4140 if ( *next >=
'0' && *next <=
'9' ) {
4142 const char *buf = next;
4143 char const * msg = NULL;
4145 SKIP_DIGITS( next );
4148 const char *tmp = next;
4150 if ( ( *next ==
' ' || *next ==
'\t' ) && ( *tmp >=
'0' && *tmp <=
'9' ) ) {
4151 KMP_WARNING( EnvSpacesNotAllowed, name, value );
4155 num = __kmp_str_to_int( buf, *next );
4157 msg = KMP_I18N_STR( ValueTooSmall );
4159 }
else if ( num > KMP_INT_MAX ) {
4160 msg = KMP_I18N_STR( ValueTooLarge );
4163 if ( msg != NULL ) {
4165 KMP_WARNING( ParseSizeIntWarn, name, value, msg );
4166 KMP_INFORM( Using_int_Value, name, num );
4170 }
else if( total == 2 ) {
4175 KMP_DEBUG_ASSERT( total > 0 );
4177 KMP_WARNING( EnvSyntaxError, name, value );
4180 if( max_retries != 0 ) {
4181 __kmp_adaptive_backoff_params.max_soft_retries = max_retries;
4183 if( max_badness != 0 ) {
4184 __kmp_adaptive_backoff_params.max_badness = max_badness;
4190 __kmp_stg_print_adaptive_lock_props(kmp_str_buf_t * buffer,
char const * name,
void * data )
4192 if( __kmp_env_format ) {
4193 KMP_STR_BUF_PRINT_NAME_EX(name);
4195 __kmp_str_buf_print( buffer,
" %s='", name );
4197 __kmp_str_buf_print( buffer,
"%d,%d'\n", __kmp_adaptive_backoff_params.max_soft_retries,
4198 __kmp_adaptive_backoff_params.max_badness );
4201 #if KMP_DEBUG_ADAPTIVE_LOCKS
4204 __kmp_stg_parse_speculative_statsfile(
char const * name,
char const * value,
void * data ) {
4205 __kmp_stg_parse_file( name, value,
"", & __kmp_speculative_statsfile );
4209 __kmp_stg_print_speculative_statsfile( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
4210 if ( __kmp_str_match(
"-", 0, __kmp_speculative_statsfile ) ) {
4211 __kmp_stg_print_str( buffer, name,
"stdout" );
4213 __kmp_stg_print_str( buffer, name, __kmp_speculative_statsfile );
4218 #endif // KMP_DEBUG_ADAPTIVE_LOCKS
4220 #endif // KMP_USE_ADAPTIVE_LOCKS
4228 __kmp_stg_parse_place_threads(
char const * name,
char const * value,
void * data ) {
4234 const char *next = value;
4238 if ( *next ==
'\0' ) {
4243 if ( *next >=
'0' && *next <=
'9' ) {
4245 SKIP_DIGITS( next );
4246 num = __kmp_str_to_int( prev, *next );
4248 if ( *next ==
'C' || *next ==
'c' ) {
4249 __kmp_place_num_cores = num;
4251 }
else if ( *next ==
',' || *next ==
'x' ) {
4252 __kmp_place_num_cores = num;
4255 }
else if ( *next ==
'T' || *next ==
't' ) {
4256 __kmp_place_num_threads_per_core = num;
4258 }
else if ( *next ==
'\0' ) {
4259 __kmp_place_num_cores = num;
4262 KMP_WARNING( AffThrPlaceInvalid, name, value );
4265 }
else if ( *next ==
',' || *next ==
'x' ) {
4270 KMP_WARNING( AffThrPlaceInvalid, name, value );
4274 if ( *next ==
'\0' ) {
4277 if ( ( *next ==
',' || *next ==
'x' ) && !prev_delim ) {
4284 if ( *next >=
'0' && *next <=
'9' ) {
4287 SKIP_DIGITS( next );
4288 num = __kmp_str_to_int( prev, *next );
4290 if ( *next ==
'T' || *next ==
't' ) {
4291 __kmp_place_num_threads_per_core = num;
4293 }
else if ( *next ==
',' || *next ==
'x' ) {
4294 __kmp_place_num_threads_per_core = num;
4297 }
else if ( *next ==
'O' || *next ==
'o' ) {
4298 __kmp_place_core_offset = num;
4300 }
else if ( *next ==
'\0' ) {
4301 __kmp_place_num_threads_per_core = num;
4304 KMP_WARNING( AffThrPlaceInvalid, name, value );
4307 }
else if ( *next ==
',' || *next ==
'x' ) {
4308 if ( prev_delim == 2 ) {
4311 KMP_DEBUG_ASSERT( prev_delim == 1 );
4314 KMP_WARNING( AffThrPlaceInvalid, name, value );
4318 if ( *next ==
'\0' ) {
4321 if ( ( *next ==
',' || *next ==
'x' ) && !prev_delim ) {
4329 if ( *next >=
'0' && *next <=
'9' ) {
4331 SKIP_DIGITS( next );
4332 num = __kmp_str_to_int( prev, *next );
4333 __kmp_place_core_offset = num;
4338 __kmp_stg_print_place_threads( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
4339 if ( __kmp_place_num_cores + __kmp_place_num_threads_per_core ) {
4341 __kmp_str_buf_init( &buf );
4342 if( __kmp_env_format ) {
4343 KMP_STR_BUF_PRINT_NAME_EX(name);
4345 __kmp_str_buf_print( buffer,
" %s='", name );
4347 __kmp_str_buf_print( &buf,
"%dC", __kmp_place_num_cores );
4348 __kmp_str_buf_print( &buf,
"x%dT", __kmp_place_num_threads_per_core );
4349 if ( __kmp_place_core_offset ) {
4350 __kmp_str_buf_print( &buf,
",%dO", __kmp_place_core_offset );
4352 __kmp_str_buf_print(buffer,
"%s'\n", buf.str );
4353 __kmp_str_buf_free(&buf);
4368 __kmp_stg_parse_forkjoin_frames(
char const * name,
char const * value,
void * data ) {
4369 __kmp_stg_parse_bool( name, value, & __kmp_forkjoin_frames );
4373 __kmp_stg_print_forkjoin_frames( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
4374 __kmp_stg_print_bool( buffer, name, __kmp_forkjoin_frames );
4382 __kmp_stg_parse_forkjoin_frames_mode(
char const * name,
char const * value,
void * data ) {
4383 __kmp_stg_parse_int( name, value, 0, 3, & __kmp_forkjoin_frames_mode );
4387 __kmp_stg_print_forkjoin_frames_mode( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
4388 __kmp_stg_print_int( buffer, name, __kmp_forkjoin_frames_mode );
4399 __kmp_stg_parse_omp_display_env(
char const * name,
char const * value,
void * data )
4401 if ( __kmp_str_match(
"VERBOSE", 1, value ) )
4403 __kmp_display_env_verbose = TRUE;
4405 __kmp_stg_parse_bool( name, value, & __kmp_display_env );
4411 __kmp_stg_print_omp_display_env( kmp_str_buf_t * buffer,
char const * name,
void * data )
4413 if ( __kmp_display_env_verbose )
4415 __kmp_stg_print_str( buffer, name,
"VERBOSE" );
4417 __kmp_stg_print_bool( buffer, name, __kmp_display_env );
4422 __kmp_stg_parse_omp_cancellation(
char const * name,
char const * value,
void * data ) {
4423 if ( TCR_4(__kmp_init_parallel) ) {
4424 KMP_WARNING( EnvParallelWarn, name );
4427 __kmp_stg_parse_bool( name, value, & __kmp_omp_cancellation );
4431 __kmp_stg_print_omp_cancellation( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
4432 __kmp_stg_print_bool( buffer, name, __kmp_omp_cancellation );
4442 static kmp_setting_t __kmp_stg_table[] = {
4444 {
"KMP_ALL_THREADS", __kmp_stg_parse_all_threads, __kmp_stg_print_all_threads, NULL, 0, 0 },
4445 {
"KMP_BLOCKTIME", __kmp_stg_parse_blocktime, __kmp_stg_print_blocktime, NULL, 0, 0 },
4446 {
"KMP_DUPLICATE_LIB_OK", __kmp_stg_parse_duplicate_lib_ok, __kmp_stg_print_duplicate_lib_ok, NULL, 0, 0 },
4447 {
"KMP_LIBRARY", __kmp_stg_parse_wait_policy, __kmp_stg_print_wait_policy, NULL, 0, 0 },
4448 {
"KMP_MAX_THREADS", __kmp_stg_parse_all_threads, NULL, NULL, 0, 0 },
4449 {
"KMP_MONITOR_STACKSIZE", __kmp_stg_parse_monitor_stacksize, __kmp_stg_print_monitor_stacksize, NULL, 0, 0 },
4450 {
"KMP_SETTINGS", __kmp_stg_parse_settings, __kmp_stg_print_settings, NULL, 0, 0 },
4451 {
"KMP_STACKOFFSET", __kmp_stg_parse_stackoffset, __kmp_stg_print_stackoffset, NULL, 0, 0 },
4452 {
"KMP_STACKSIZE", __kmp_stg_parse_stacksize, __kmp_stg_print_stacksize, NULL, 0, 0 },
4453 {
"KMP_STACKPAD", __kmp_stg_parse_stackpad, __kmp_stg_print_stackpad, NULL, 0, 0 },
4454 {
"KMP_VERSION", __kmp_stg_parse_version, __kmp_stg_print_version, NULL, 0, 0 },
4455 {
"KMP_WARNINGS", __kmp_stg_parse_warnings, __kmp_stg_print_warnings, NULL, 0, 0 },
4457 {
"OMP_NESTED", __kmp_stg_parse_nested, __kmp_stg_print_nested, NULL, 0, 0 },
4458 {
"OMP_NUM_THREADS", __kmp_stg_parse_num_threads, __kmp_stg_print_num_threads, NULL, 0, 0 },
4459 {
"OMP_STACKSIZE", __kmp_stg_parse_stacksize, __kmp_stg_print_stacksize, NULL, 0, 0 },
4461 {
"KMP_TASKING", __kmp_stg_parse_tasking, __kmp_stg_print_tasking, NULL, 0, 0 },
4462 {
"KMP_TASK_STEALING_CONSTRAINT", __kmp_stg_parse_task_stealing, __kmp_stg_print_task_stealing, NULL, 0, 0 },
4463 {
"OMP_MAX_ACTIVE_LEVELS", __kmp_stg_parse_max_active_levels, __kmp_stg_print_max_active_levels, NULL, 0, 0 },
4464 {
"OMP_THREAD_LIMIT", __kmp_stg_parse_all_threads, __kmp_stg_print_all_threads, NULL, 0, 0 },
4465 {
"OMP_WAIT_POLICY", __kmp_stg_parse_wait_policy, __kmp_stg_print_wait_policy, NULL, 0, 0 },
4466 #if KMP_NESTED_HOT_TEAMS
4467 {
"KMP_HOT_TEAMS_MAX_LEVEL", __kmp_stg_parse_hot_teams_level, __kmp_stg_print_hot_teams_level, NULL, 0, 0 },
4468 {
"KMP_HOT_TEAMS_MODE", __kmp_stg_parse_hot_teams_mode, __kmp_stg_print_hot_teams_mode, NULL, 0, 0 },
4469 #endif // KMP_NESTED_HOT_TEAMS
4471 #if KMP_HANDLE_SIGNALS
4472 {
"KMP_HANDLE_SIGNALS", __kmp_stg_parse_handle_signals, __kmp_stg_print_handle_signals, NULL, 0, 0 },
4475 #if KMP_ARCH_X86 || KMP_ARCH_X86_64
4476 {
"KMP_INHERIT_FP_CONTROL", __kmp_stg_parse_inherit_fp_control, __kmp_stg_print_inherit_fp_control, NULL, 0, 0 },
4479 #ifdef KMP_GOMP_COMPAT
4480 {
"GOMP_STACKSIZE", __kmp_stg_parse_stacksize, NULL, NULL, 0, 0 },
4484 {
"KMP_A_DEBUG", __kmp_stg_parse_a_debug, __kmp_stg_print_a_debug, NULL, 0, 0 },
4485 {
"KMP_B_DEBUG", __kmp_stg_parse_b_debug, __kmp_stg_print_b_debug, NULL, 0, 0 },
4486 {
"KMP_C_DEBUG", __kmp_stg_parse_c_debug, __kmp_stg_print_c_debug, NULL, 0, 0 },
4487 {
"KMP_D_DEBUG", __kmp_stg_parse_d_debug, __kmp_stg_print_d_debug, NULL, 0, 0 },
4488 {
"KMP_E_DEBUG", __kmp_stg_parse_e_debug, __kmp_stg_print_e_debug, NULL, 0, 0 },
4489 {
"KMP_F_DEBUG", __kmp_stg_parse_f_debug, __kmp_stg_print_f_debug, NULL, 0, 0 },
4490 {
"KMP_DEBUG", __kmp_stg_parse_debug, NULL, NULL, 0, 0 },
4491 {
"KMP_DEBUG_BUF", __kmp_stg_parse_debug_buf, __kmp_stg_print_debug_buf, NULL, 0, 0 },
4492 {
"KMP_DEBUG_BUF_ATOMIC", __kmp_stg_parse_debug_buf_atomic, __kmp_stg_print_debug_buf_atomic, NULL, 0, 0 },
4493 {
"KMP_DEBUG_BUF_CHARS", __kmp_stg_parse_debug_buf_chars, __kmp_stg_print_debug_buf_chars, NULL, 0, 0 },
4494 {
"KMP_DEBUG_BUF_LINES", __kmp_stg_parse_debug_buf_lines, __kmp_stg_print_debug_buf_lines, NULL, 0, 0 },
4495 {
"KMP_DIAG", __kmp_stg_parse_diag, __kmp_stg_print_diag, NULL, 0, 0 },
4497 {
"KMP_PAR_RANGE", __kmp_stg_parse_par_range_env, __kmp_stg_print_par_range_env, NULL, 0, 0 },
4498 {
"KMP_YIELD_CYCLE", __kmp_stg_parse_yield_cycle, __kmp_stg_print_yield_cycle, NULL, 0, 0 },
4499 {
"KMP_YIELD_ON", __kmp_stg_parse_yield_on, __kmp_stg_print_yield_on, NULL, 0, 0 },
4500 {
"KMP_YIELD_OFF", __kmp_stg_parse_yield_off, __kmp_stg_print_yield_off, NULL, 0, 0 },
4503 {
"KMP_ALIGN_ALLOC", __kmp_stg_parse_align_alloc, __kmp_stg_print_align_alloc, NULL, 0, 0 },
4505 {
"KMP_PLAIN_BARRIER", __kmp_stg_parse_barrier_branch_bit, __kmp_stg_print_barrier_branch_bit, NULL, 0, 0 },
4506 {
"KMP_PLAIN_BARRIER_PATTERN", __kmp_stg_parse_barrier_pattern, __kmp_stg_print_barrier_pattern, NULL, 0, 0 },
4507 {
"KMP_FORKJOIN_BARRIER", __kmp_stg_parse_barrier_branch_bit, __kmp_stg_print_barrier_branch_bit, NULL, 0, 0 },
4508 {
"KMP_FORKJOIN_BARRIER_PATTERN", __kmp_stg_parse_barrier_pattern, __kmp_stg_print_barrier_pattern, NULL, 0, 0 },
4509 #if KMP_FAST_REDUCTION_BARRIER
4510 {
"KMP_REDUCTION_BARRIER", __kmp_stg_parse_barrier_branch_bit, __kmp_stg_print_barrier_branch_bit, NULL, 0, 0 },
4511 {
"KMP_REDUCTION_BARRIER_PATTERN", __kmp_stg_parse_barrier_pattern, __kmp_stg_print_barrier_pattern, NULL, 0, 0 },
4514 {
"KMP_ABORT_DELAY", __kmp_stg_parse_abort_delay, __kmp_stg_print_abort_delay, NULL, 0, 0 },
4515 {
"KMP_CPUINFO_FILE", __kmp_stg_parse_cpuinfo_file, __kmp_stg_print_cpuinfo_file, NULL, 0, 0 },
4516 {
"KMP_FORCE_REDUCTION", __kmp_stg_parse_force_reduction, __kmp_stg_print_force_reduction, NULL, 0, 0 },
4517 {
"KMP_DETERMINISTIC_REDUCTION", __kmp_stg_parse_force_reduction, __kmp_stg_print_force_reduction, NULL, 0, 0 },
4518 {
"KMP_STORAGE_MAP", __kmp_stg_parse_storage_map, __kmp_stg_print_storage_map, NULL, 0, 0 },
4519 {
"KMP_ALL_THREADPRIVATE", __kmp_stg_parse_all_threadprivate, __kmp_stg_print_all_threadprivate, NULL, 0, 0 },
4520 {
"KMP_FOREIGN_THREADS_THREADPRIVATE", __kmp_stg_parse_foreign_threads_threadprivate, __kmp_stg_print_foreign_threads_threadprivate, NULL, 0, 0 },
4522 #if KMP_AFFINITY_SUPPORTED
4523 {
"KMP_AFFINITY", __kmp_stg_parse_affinity, __kmp_stg_print_affinity, NULL, 0, 0 },
4524 # ifdef KMP_GOMP_COMPAT
4525 {
"GOMP_CPU_AFFINITY", __kmp_stg_parse_gomp_cpu_affinity, NULL, NULL, 0, 0 },
4528 {
"OMP_PROC_BIND", __kmp_stg_parse_proc_bind, __kmp_stg_print_proc_bind, NULL, 0, 0 },
4529 {
"OMP_PLACES", __kmp_stg_parse_places, __kmp_stg_print_places, NULL, 0, 0 },
4531 {
"OMP_PROC_BIND", __kmp_stg_parse_proc_bind, NULL, NULL, 0, 0 },
4534 {
"KMP_TOPOLOGY_METHOD", __kmp_stg_parse_topology_method, __kmp_stg_print_topology_method, NULL, 0, 0 },
4543 {
"OMP_PROC_BIND", __kmp_stg_parse_proc_bind, __kmp_stg_print_proc_bind, NULL, 0, 0 },
4546 #endif // KMP_AFFINITY_SUPPORTED
4548 {
"KMP_INIT_AT_FORK", __kmp_stg_parse_init_at_fork, __kmp_stg_print_init_at_fork, NULL, 0, 0 },
4549 {
"KMP_SCHEDULE", __kmp_stg_parse_schedule, __kmp_stg_print_schedule, NULL, 0, 0 },
4550 {
"OMP_SCHEDULE", __kmp_stg_parse_omp_schedule, __kmp_stg_print_omp_schedule, NULL, 0, 0 },
4551 {
"KMP_ATOMIC_MODE", __kmp_stg_parse_atomic_mode, __kmp_stg_print_atomic_mode, NULL, 0, 0 },
4552 {
"KMP_CONSISTENCY_CHECK", __kmp_stg_parse_consistency_check, __kmp_stg_print_consistency_check, NULL, 0, 0 },
4554 #if USE_ITT_BUILD && USE_ITT_NOTIFY
4555 {
"KMP_ITT_PREPARE_DELAY", __kmp_stg_parse_itt_prepare_delay, __kmp_stg_print_itt_prepare_delay, NULL, 0, 0 },
4557 {
"KMP_MALLOC_POOL_INCR", __kmp_stg_parse_malloc_pool_incr, __kmp_stg_print_malloc_pool_incr, NULL, 0, 0 },
4558 {
"KMP_INIT_WAIT", __kmp_stg_parse_init_wait, __kmp_stg_print_init_wait, NULL, 0, 0 },
4559 {
"KMP_NEXT_WAIT", __kmp_stg_parse_next_wait, __kmp_stg_print_next_wait, NULL, 0, 0 },
4560 {
"KMP_GTID_MODE", __kmp_stg_parse_gtid_mode, __kmp_stg_print_gtid_mode, NULL, 0, 0 },
4561 {
"OMP_DYNAMIC", __kmp_stg_parse_omp_dynamic, __kmp_stg_print_omp_dynamic, NULL, 0, 0 },
4562 {
"KMP_DYNAMIC_MODE", __kmp_stg_parse_kmp_dynamic_mode, __kmp_stg_print_kmp_dynamic_mode, NULL, 0, 0 },
4564 #ifdef USE_LOAD_BALANCE
4565 {
"KMP_LOAD_BALANCE_INTERVAL", __kmp_stg_parse_ld_balance_interval,__kmp_stg_print_ld_balance_interval,NULL, 0, 0 },
4570 {
"KMP_NUM_LOCKS_IN_BLOCK", __kmp_stg_parse_lock_block, __kmp_stg_print_lock_block, NULL, 0, 0 },
4571 {
"KMP_LOCK_KIND", __kmp_stg_parse_lock_kind, __kmp_stg_print_lock_kind, NULL, 0, 0 },
4572 #if KMP_USE_ADAPTIVE_LOCKS
4573 {
"KMP_ADAPTIVE_LOCK_PROPS", __kmp_stg_parse_adaptive_lock_props,__kmp_stg_print_adaptive_lock_props, NULL, 0, 0 },
4574 #if KMP_DEBUG_ADAPTIVE_LOCKS
4575 {
"KMP_SPECULATIVE_STATSFILE", __kmp_stg_parse_speculative_statsfile,__kmp_stg_print_speculative_statsfile, NULL, 0, 0 },
4577 #endif // KMP_USE_ADAPTIVE_LOCKS
4579 {
"KMP_PLACE_THREADS", __kmp_stg_parse_place_threads, __kmp_stg_print_place_threads, NULL, 0, 0 },
4582 {
"KMP_FORKJOIN_FRAMES", __kmp_stg_parse_forkjoin_frames, __kmp_stg_print_forkjoin_frames, NULL, 0, 0 },
4583 {
"KMP_FORKJOIN_FRAMES_MODE", __kmp_stg_parse_forkjoin_frames_mode,__kmp_stg_print_forkjoin_frames_mode, NULL, 0, 0 },
4587 {
"OMP_DISPLAY_ENV", __kmp_stg_parse_omp_display_env, __kmp_stg_print_omp_display_env, NULL, 0, 0 },
4588 {
"OMP_CANCELLATION", __kmp_stg_parse_omp_cancellation, __kmp_stg_print_omp_cancellation, NULL, 0, 0 },
4590 {
"", NULL, NULL, NULL, 0, 0 }
4593 static int const __kmp_stg_count =
sizeof( __kmp_stg_table ) /
sizeof( kmp_setting_t );
4597 __kmp_stg_find(
char const * name ) {
4600 if ( name != NULL ) {
4601 for ( i = 0; i < __kmp_stg_count; ++ i ) {
4602 if ( strcmp( __kmp_stg_table[ i ].name, name ) == 0 ) {
4603 return & __kmp_stg_table[ i ];
4613 __kmp_stg_cmp(
void const * _a,
void const * _b ) {
4614 kmp_setting_t * a = (kmp_setting_t *) _a;
4615 kmp_setting_t * b = (kmp_setting_t *) _b;
4621 if ( strcmp( a->name,
"KMP_AFFINITY" ) == 0 ) {
4622 if ( strcmp( b->name,
"KMP_AFFINITY" ) == 0 ) {
4627 else if ( strcmp( b->name,
"KMP_AFFINITY" ) == 0 ) {
4630 return strcmp( a->name, b->name );
4635 __kmp_stg_init(
void
4638 static int initialized = 0;
4640 if ( ! initialized ) {
4643 qsort( __kmp_stg_table, __kmp_stg_count - 1,
sizeof( kmp_setting_t ), __kmp_stg_cmp );
4647 kmp_setting_t * kmp_stacksize = __kmp_stg_find(
"KMP_STACKSIZE" );
4648 #ifdef KMP_GOMP_COMPAT
4649 kmp_setting_t * gomp_stacksize = __kmp_stg_find(
"GOMP_STACKSIZE" );
4651 kmp_setting_t * omp_stacksize = __kmp_stg_find(
"OMP_STACKSIZE" );
4656 static kmp_setting_t *
volatile rivals[ 4 ];
4657 static kmp_stg_ss_data_t kmp_data = { 1, (kmp_setting_t **)rivals };
4658 #ifdef KMP_GOMP_COMPAT
4659 static kmp_stg_ss_data_t gomp_data = { 1024, (kmp_setting_t **)rivals };
4661 static kmp_stg_ss_data_t omp_data = { 1024, (kmp_setting_t **)rivals };
4664 rivals[ i ++ ] = kmp_stacksize;
4665 #ifdef KMP_GOMP_COMPAT
4666 if ( gomp_stacksize != NULL ) {
4667 rivals[ i ++ ] = gomp_stacksize;
4670 rivals[ i ++ ] = omp_stacksize;
4671 rivals[ i ++ ] = NULL;
4673 kmp_stacksize->data = & kmp_data;
4674 #ifdef KMP_GOMP_COMPAT
4675 if ( gomp_stacksize != NULL ) {
4676 gomp_stacksize->data = & gomp_data;
4679 omp_stacksize->data = & omp_data;
4685 kmp_setting_t * kmp_library = __kmp_stg_find(
"KMP_LIBRARY" );
4686 kmp_setting_t * omp_wait_policy = __kmp_stg_find(
"OMP_WAIT_POLICY" );
4689 static kmp_setting_t *
volatile rivals[ 3 ];
4690 static kmp_stg_wp_data_t kmp_data = { 0, (kmp_setting_t **)rivals };
4691 static kmp_stg_wp_data_t omp_data = { 1, (kmp_setting_t **)rivals };
4694 rivals[ i ++ ] = kmp_library;
4695 if ( omp_wait_policy != NULL ) {
4696 rivals[ i ++ ] = omp_wait_policy;
4698 rivals[ i ++ ] = NULL;
4700 kmp_library->data = & kmp_data;
4701 if ( omp_wait_policy != NULL ) {
4702 omp_wait_policy->data = & omp_data;
4709 kmp_setting_t * kmp_all_threads = __kmp_stg_find(
"KMP_ALL_THREADS" );
4710 kmp_setting_t * kmp_max_threads = __kmp_stg_find(
"KMP_MAX_THREADS" );
4711 kmp_setting_t * omp_thread_limit = __kmp_stg_find(
"OMP_THREAD_LIMIT" );
4714 static kmp_setting_t *
volatile rivals[ 4 ];
4717 rivals[ i ++ ] = kmp_all_threads;
4718 rivals[ i ++ ] = kmp_max_threads;
4719 if ( omp_thread_limit != NULL ) {
4720 rivals[ i ++ ] = omp_thread_limit;
4722 rivals[ i ++ ] = NULL;
4724 kmp_all_threads->data = (
void*)& rivals;
4725 kmp_max_threads->data = (
void*)& rivals;
4726 if ( omp_thread_limit != NULL ) {
4727 omp_thread_limit->data = (
void*)& rivals;
4732 #if KMP_AFFINITY_SUPPORTED
4735 kmp_setting_t * kmp_affinity = __kmp_stg_find(
"KMP_AFFINITY" );
4736 KMP_DEBUG_ASSERT( kmp_affinity != NULL );
4738 # ifdef KMP_GOMP_COMPAT
4739 kmp_setting_t * gomp_cpu_affinity = __kmp_stg_find(
"GOMP_CPU_AFFINITY" );
4740 KMP_DEBUG_ASSERT( gomp_cpu_affinity != NULL );
4743 kmp_setting_t * omp_proc_bind = __kmp_stg_find(
"OMP_PROC_BIND" );
4744 KMP_DEBUG_ASSERT( omp_proc_bind != NULL );
4747 static kmp_setting_t *
volatile rivals[ 4 ];
4750 rivals[ i ++ ] = kmp_affinity;
4752 # ifdef KMP_GOMP_COMPAT
4753 rivals[ i ++ ] = gomp_cpu_affinity;
4754 gomp_cpu_affinity->data = (
void*)& rivals;
4757 rivals[ i ++ ] = omp_proc_bind;
4758 omp_proc_bind->data = (
void*)& rivals;
4759 rivals[ i ++ ] = NULL;
4762 static kmp_setting_t *
volatile places_rivals[ 4 ];
4765 kmp_setting_t * omp_places = __kmp_stg_find(
"OMP_PLACES" );
4766 KMP_DEBUG_ASSERT( omp_places != NULL );
4768 places_rivals[ i ++ ] = kmp_affinity;
4769 # ifdef KMP_GOMP_COMPAT
4770 places_rivals[ i ++ ] = gomp_cpu_affinity;
4772 places_rivals[ i ++ ] = omp_places;
4773 omp_places->data = (
void*)& places_rivals;
4774 places_rivals[ i ++ ] = NULL;
4780 #endif // KMP_AFFINITY_SUPPORTED
4784 kmp_setting_t * kmp_force_red = __kmp_stg_find(
"KMP_FORCE_REDUCTION" );
4785 kmp_setting_t * kmp_determ_red = __kmp_stg_find(
"KMP_DETERMINISTIC_REDUCTION" );
4788 static kmp_setting_t *
volatile rivals[ 3 ];
4789 static kmp_stg_fr_data_t force_data = { 1, (kmp_setting_t **)rivals };
4790 static kmp_stg_fr_data_t determ_data = { 0, (kmp_setting_t **)rivals };
4793 rivals[ i ++ ] = kmp_force_red;
4794 if ( kmp_determ_red != NULL ) {
4795 rivals[ i ++ ] = kmp_determ_red;
4797 rivals[ i ++ ] = NULL;
4799 kmp_force_red->data = & force_data;
4800 if ( kmp_determ_red != NULL ) {
4801 kmp_determ_red->data = & determ_data;
4811 for ( i = 0; i < __kmp_stg_count; ++ i ) {
4812 __kmp_stg_table[ i ].set = 0;
4826 if ( name[ 0 ] == 0 ) {
4830 if ( value != NULL ) {
4831 kmp_setting_t * setting = __kmp_stg_find( name );
4832 if ( setting != NULL ) {
4833 setting->parse( name, value, setting->data );
4834 setting->defined = 1;
4842 __kmp_stg_check_rivals(
4845 kmp_setting_t * * rivals
4848 if ( rivals == NULL ) {
4854 for ( ; strcmp( rivals[ i ]->name, name ) != 0; i++ ) {
4855 KMP_DEBUG_ASSERT( rivals[ i ] != NULL );
4857 #if KMP_AFFINITY_SUPPORTED
4858 if ( rivals[ i ] == __kmp_affinity_notype ) {
4867 if ( rivals[ i ]->set ) {
4868 KMP_WARNING( StgIgnored, name, value, rivals[ i ]->name );
4881 __kmp_env_isDefined(
char const * name ) {
4883 kmp_setting_t * setting = __kmp_stg_find( name );
4884 if ( setting != NULL ) {
4891 __kmp_env_toPrint(
char const * name,
int flag ) {
4893 kmp_setting_t * setting = __kmp_stg_find( name );
4894 if ( setting != NULL ) {
4895 rc = setting->defined;
4897 setting->defined = flag;
4905 __kmp_aux_env_initialize( kmp_env_blk_t* block ) {
4910 value = __kmp_env_blk_var( block,
"OMP_NUM_THREADS" );
4912 ompc_set_num_threads( __kmp_dflt_team_nth );
4916 value = __kmp_env_blk_var( block,
"KMP_BLOCKTIME" );
4918 kmpc_set_blocktime( __kmp_dflt_blocktime );
4922 value = __kmp_env_blk_var( block,
"OMP_NESTED" );
4924 ompc_set_nested( __kmp_dflt_nested );
4928 value = __kmp_env_blk_var( block,
"OMP_DYNAMIC" );
4930 ompc_set_dynamic( __kmp_global.g.g_dynamic );
4936 __kmp_env_initialize(
char const *
string ) {
4938 kmp_env_blk_t block;
4944 if (
string == NULL ) {
4946 __kmp_threads_capacity = __kmp_initial_threads_capacity( __kmp_dflt_team_nth_ub );
4948 __kmp_env_blk_init( & block,
string );
4953 for ( i = 0; i < block.count; ++ i ) {
4954 if (( block.vars[ i ].name == NULL )
4955 || ( *block.vars[ i ].name ==
'\0')) {
4958 if ( block.vars[ i ].value == NULL ) {
4961 kmp_setting_t * setting = __kmp_stg_find( block.vars[ i ].name );
4962 if ( setting != NULL ) {
4968 if (
string == NULL ) {
4969 char const * name =
"KMP_WARNINGS";
4970 char const * value = __kmp_env_blk_var( & block, name );
4971 __kmp_stg_parse( name, value );
4974 #if KMP_AFFINITY_SUPPORTED
4982 __kmp_affinity_notype = NULL;
4983 char const *aff_str = __kmp_env_blk_var( & block,
"KMP_AFFINITY" );
4984 if ( aff_str != NULL ) {
4998 # define FIND strstr
5000 # define FIND strcasestr
5003 if ( ( FIND( aff_str,
"none" ) == NULL )
5004 && ( FIND( aff_str,
"physical" ) == NULL )
5005 && ( FIND( aff_str,
"logical" ) == NULL )
5006 && ( FIND( aff_str,
"compact" ) == NULL )
5007 && ( FIND( aff_str,
"scatter" ) == NULL )
5008 && ( FIND( aff_str,
"explicit" ) == NULL )
5010 && ( FIND( aff_str,
"balanced" ) == NULL )
5012 && ( FIND( aff_str,
"disabled" ) == NULL ) ) {
5013 __kmp_affinity_notype = __kmp_stg_find(
"KMP_AFFINITY" );
5021 __kmp_affinity_type = affinity_default;
5022 __kmp_affinity_gran = affinity_gran_default;
5023 __kmp_affinity_top_method = affinity_top_method_default;
5024 __kmp_affinity_respect_mask = affinity_respect_mask_default;
5032 aff_str = __kmp_env_blk_var( & block,
"OMP_PROC_BIND" );
5033 if ( aff_str != NULL ) {
5034 __kmp_affinity_type = affinity_default;
5035 __kmp_affinity_gran = affinity_gran_default;
5036 __kmp_affinity_top_method = affinity_top_method_default;
5037 __kmp_affinity_respect_mask = affinity_respect_mask_default;
5048 if ( __kmp_nested_proc_bind.bind_types == NULL ) {
5049 __kmp_nested_proc_bind.bind_types = (kmp_proc_bind_t *)
5050 KMP_INTERNAL_MALLOC(
sizeof(kmp_proc_bind_t) );
5051 if ( __kmp_nested_proc_bind.bind_types == NULL ) {
5052 KMP_FATAL( MemoryAllocFailed );
5054 __kmp_nested_proc_bind.size = 1;
5055 __kmp_nested_proc_bind.used = 1;
5056 __kmp_nested_proc_bind.bind_types[0] = proc_bind_default;
5063 for ( i = 0; i < block.count; ++ i ) {
5064 __kmp_stg_parse( block.vars[ i ].name, block.vars[ i ].value );
5070 if ( ! __kmp_init_user_locks ) {
5071 if ( __kmp_user_lock_kind == lk_default ) {
5072 __kmp_user_lock_kind = lk_queuing;
5074 __kmp_set_user_lock_vptrs( __kmp_user_lock_kind );
5077 KMP_DEBUG_ASSERT(
string != NULL);
5078 KMP_DEBUG_ASSERT( __kmp_user_lock_kind != lk_default );
5079 __kmp_set_user_lock_vptrs( __kmp_user_lock_kind );
5086 #if KMP_AFFINITY_SUPPORTED
5088 if ( ! TCR_4(__kmp_init_middle) ) {
5093 const char *var =
"KMP_AFFINITY";
5094 if ( __kmp_affinity_type == affinity_disabled ) {
5095 __kmp_affin_mask_size = 0;
5097 else if ( ! KMP_AFFINITY_CAPABLE() ) {
5098 __kmp_affinity_determine_capable( var );
5099 if ( ! KMP_AFFINITY_CAPABLE() ) {
5100 if ( __kmp_affinity_verbose || ( __kmp_affinity_warnings
5101 && ( __kmp_affinity_type != affinity_default )
5102 && ( __kmp_affinity_type != affinity_none )
5103 && ( __kmp_affinity_type != affinity_disabled ) ) ) {
5104 KMP_WARNING( AffNotSupported, var );
5106 __kmp_affinity_type = affinity_disabled;
5107 __kmp_affinity_respect_mask = 0;
5108 __kmp_affinity_gran = affinity_gran_fine;
5113 if ( __kmp_affinity_type == affinity_disabled ) {
5114 __kmp_nested_proc_bind.bind_types[0] = proc_bind_disabled;
5116 else if ( __kmp_nested_proc_bind.bind_types[0] == proc_bind_true ) {
5120 __kmp_nested_proc_bind.bind_types[0] = proc_bind_spread;
5124 if ( KMP_AFFINITY_CAPABLE() ) {
5126 # if KMP_OS_WINDOWS && KMP_ARCH_X86_64
5133 if ( ( ( __kmp_num_proc_groups > 1 )
5134 && ( __kmp_affinity_type == affinity_default )
5136 && ( __kmp_nested_proc_bind.bind_types[0] == proc_bind_default ) )
5138 || ( __kmp_affinity_top_method == affinity_top_method_group ) ) {
5139 if ( __kmp_affinity_respect_mask == affinity_respect_mask_default ) {
5140 __kmp_affinity_respect_mask = FALSE;
5142 if ( __kmp_affinity_type == affinity_default ) {
5143 __kmp_affinity_type = affinity_compact;
5145 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
5148 if ( __kmp_affinity_top_method == affinity_top_method_default ) {
5149 if ( __kmp_affinity_gran == affinity_gran_default ) {
5150 __kmp_affinity_top_method = affinity_top_method_group;
5151 __kmp_affinity_gran = affinity_gran_group;
5153 else if ( __kmp_affinity_gran == affinity_gran_group ) {
5154 __kmp_affinity_top_method = affinity_top_method_group;
5157 __kmp_affinity_top_method = affinity_top_method_all;
5160 else if ( __kmp_affinity_top_method == affinity_top_method_group ) {
5161 if ( __kmp_affinity_gran == affinity_gran_default ) {
5162 __kmp_affinity_gran = affinity_gran_group;
5164 else if ( ( __kmp_affinity_gran != affinity_gran_group )
5165 && ( __kmp_affinity_gran != affinity_gran_fine )
5166 && ( __kmp_affinity_gran != affinity_gran_thread ) ) {
5168 switch ( __kmp_affinity_gran ) {
5169 case affinity_gran_core: str =
"core";
break;
5170 case affinity_gran_package: str =
"package";
break;
5171 case affinity_gran_node: str =
"node";
break;
5172 default: KMP_DEBUG_ASSERT( 0 );
5174 KMP_WARNING( AffGranTopGroup, var, str );
5175 __kmp_affinity_gran = affinity_gran_fine;
5179 if ( __kmp_affinity_gran == affinity_gran_default ) {
5180 __kmp_affinity_gran = affinity_gran_core;
5182 else if ( __kmp_affinity_gran == affinity_gran_group ) {
5184 switch ( __kmp_affinity_type ) {
5185 case affinity_physical: str =
"physical";
break;
5186 case affinity_logical: str =
"logical";
break;
5187 case affinity_compact: str =
"compact";
break;
5188 case affinity_scatter: str =
"scatter";
break;
5189 case affinity_explicit: str =
"explicit";
break;
5191 default: KMP_DEBUG_ASSERT( 0 );
5193 KMP_WARNING( AffGranGroupType, var, str );
5194 __kmp_affinity_gran = affinity_gran_core;
5203 if ( __kmp_affinity_respect_mask == affinity_respect_mask_default ) {
5204 # if KMP_OS_WINDOWS && KMP_ARCH_X86_64
5205 if ( __kmp_num_proc_groups > 1 ) {
5206 __kmp_affinity_respect_mask = FALSE;
5211 __kmp_affinity_respect_mask = TRUE;
5215 if ( ( __kmp_nested_proc_bind.bind_types[0] != proc_bind_intel )
5216 && ( __kmp_nested_proc_bind.bind_types[0] != proc_bind_default ) ) {
5217 if ( __kmp_affinity_type == affinity_default ) {
5218 __kmp_affinity_type = affinity_compact;
5219 __kmp_affinity_dups = FALSE;
5224 if ( __kmp_affinity_type == affinity_default ) {
5226 __kmp_affinity_type = affinity_scatter;
5228 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
5231 __kmp_affinity_type = affinity_none;
5233 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
5237 if ( ( __kmp_affinity_gran == affinity_gran_default )
5238 && ( __kmp_affinity_gran_levels < 0 ) ) {
5240 __kmp_affinity_gran = affinity_gran_fine;
5242 __kmp_affinity_gran = affinity_gran_core;
5245 if ( __kmp_affinity_top_method == affinity_top_method_default ) {
5246 __kmp_affinity_top_method = affinity_top_method_all;
5251 K_DIAG( 1, (
"__kmp_affinity_type == %d\n", __kmp_affinity_type ) );
5252 K_DIAG( 1, (
"__kmp_affinity_compact == %d\n", __kmp_affinity_compact ) );
5253 K_DIAG( 1, (
"__kmp_affinity_offset == %d\n", __kmp_affinity_offset ) );
5254 K_DIAG( 1, (
"__kmp_affinity_verbose == %d\n", __kmp_affinity_verbose ) );
5255 K_DIAG( 1, (
"__kmp_affinity_warnings == %d\n", __kmp_affinity_warnings ) );
5256 K_DIAG( 1, (
"__kmp_affinity_respect_mask == %d\n", __kmp_affinity_respect_mask ) );
5257 K_DIAG( 1, (
"__kmp_affinity_gran == %d\n", __kmp_affinity_gran ) );
5259 KMP_DEBUG_ASSERT( __kmp_affinity_type != affinity_default);
5261 KMP_DEBUG_ASSERT( __kmp_nested_proc_bind.bind_types[0]
5262 != proc_bind_default );
5268 if ( __kmp_version ) {
5269 __kmp_print_version_1();
5273 if (
string != NULL) {
5274 __kmp_aux_env_initialize( &block );
5277 __kmp_env_blk_free( & block );
5287 kmp_env_blk_t block;
5289 kmp_str_buf_t buffer;
5292 __kmp_str_buf_init( & buffer );
5294 __kmp_env_blk_init( & block, NULL );
5295 __kmp_env_blk_sort( & block );
5298 __kmp_str_buf_print( & buffer,
"\n%s\n\n", KMP_I18N_STR( UserSettings ) );
5299 for ( i = 0; i < block.count; ++ i ) {
5300 char const * name = block.vars[ i ].name;
5301 char const * value = block.vars[ i ].value;
5303 ( strlen( name ) > 4 && strncmp( name,
"KMP_", 4 ) == 0 )
5304 || strncmp( name,
"OMP_", 4 ) == 0
5305 #ifdef KMP_GOMP_COMPAT
5306 || strncmp( name,
"GOMP_", 5 ) == 0
5309 __kmp_str_buf_print( & buffer,
" %s=%s\n", name, value );
5312 __kmp_str_buf_print( & buffer,
"\n" );
5315 __kmp_str_buf_print( & buffer,
"%s\n\n", KMP_I18N_STR( EffectiveSettings ) );
5316 for (
int i = 0; i < __kmp_stg_count; ++ i ) {
5317 if ( __kmp_stg_table[ i ].print != NULL ) {
5318 __kmp_stg_table[ i ].print( & buffer, __kmp_stg_table[ i ].name, __kmp_stg_table[ i ].data );
5322 __kmp_printf(
"%s", buffer.str );
5324 __kmp_env_blk_free( & block );
5325 __kmp_str_buf_free( & buffer );
5334 __kmp_env_print_2() {
5336 kmp_env_blk_t block;
5338 kmp_str_buf_t buffer;
5340 __kmp_env_format = 1;
5343 __kmp_str_buf_init( & buffer );
5345 __kmp_env_blk_init( & block, NULL );
5346 __kmp_env_blk_sort( & block );
5348 __kmp_str_buf_print( & buffer,
"\n%s\n", KMP_I18N_STR( DisplayEnvBegin ) );
5349 __kmp_str_buf_print( & buffer,
" _OPENMP='%d'\n", __kmp_openmp_version );
5351 for (
int i = 0; i < __kmp_stg_count; ++ i ) {
5352 if ( __kmp_stg_table[ i ].print != NULL &&
5353 ( ( __kmp_display_env && strncmp( __kmp_stg_table[ i ].name,
"OMP_", 4 ) == 0 ) || __kmp_display_env_verbose ) ) {
5354 __kmp_stg_table[ i ].print( & buffer, __kmp_stg_table[ i ].name, __kmp_stg_table[ i ].data );
5358 __kmp_str_buf_print( & buffer,
"%s\n", KMP_I18N_STR( DisplayEnvEnd ) );
5359 __kmp_str_buf_print( & buffer,
"\n" );
5361 __kmp_printf(
"%s", buffer.str );
5363 __kmp_env_blk_free( & block );
5364 __kmp_str_buf_free( & buffer );
5369 #endif // OMP_40_ENABLED