17 #include "kmp_wrapper_getpid.h" 18 #include "kmp_environment.h" 19 #include "kmp_atomic.h" 22 #include "kmp_settings.h" 27 static int __kmp_env_toPrint(
char const * name,
int flag );
29 bool __kmp_env_format = 0;
35 __kmp_convert_to_double(
char const * s )
39 if ( KMP_SSCANF( s,
"%lf", &result ) < 1 ) {
48 __kmp_readstr_with_sentinel(
char *dest,
char const * src,
size_t len,
char sentinel) {
50 for (i = 0; i < len; i++) {
51 if ((*src ==
'\0') || (*src == sentinel)) {
62 __kmp_match_with_sentinel(
char const * a,
char const * b,
size_t len,
char sentinel ) {
69 while(*a && *b && *b != sentinel) {
70 char ca = *a, cb = *b;
72 if(ca >=
'a' && ca <=
'z')
74 if(cb >=
'a' && cb <=
'z')
112 __kmp_match_str(
char const *token,
char const *buf,
const char **end) {
114 KMP_ASSERT(token != NULL);
115 KMP_ASSERT(buf != NULL);
116 KMP_ASSERT(end != NULL);
118 while (*token && *buf) {
119 char ct = *token, cb = *buf;
121 if(ct >=
'a' && ct <=
'z')
123 if(cb >=
'a' && cb <=
'z')
139 __kmp_round4k(
size_t size ) {
140 size_t _4k = 4 * 1024;
141 if ( size & ( _4k - 1 ) ) {
142 size &= ~ ( _4k - 1 );
143 if ( size <= KMP_SIZE_T_MAX - _4k ) {
158 __kmp_convert_to_milliseconds(
char const * data )
160 int ret, nvalues, factor;
164 if (data == NULL)
return (-1);
165 if ( __kmp_str_match(
"infinit", -1, data))
return (INT_MAX);
166 value = (double) 0.0;
168 nvalues = KMP_SSCANF (data,
"%lf%c%c", &value, &mult, &extra);
169 if (nvalues < 1)
return (-1);
170 if (nvalues == 1) mult =
'\0';
171 if (nvalues == 3)
return (-1);
173 if (value < 0)
return (-1);
187 factor = 1000 * 60 * 60;
190 factor = 1000 * 24 * 60 * 60;
196 if ( value >= ( (INT_MAX-1) / factor) )
199 ret = (int) (value * (
double) factor);
206 __kmp_strcasecmp_with_sentinel(
char const * a,
char const * b,
char sentinel ) {
211 while(*a && *b && *b != sentinel) {
212 char ca = *a, cb = *b;
214 if(ca >=
'a' && ca <=
'z')
216 if(cb >=
'a' && cb <=
'z')
219 return (
int)(
unsigned char)*a - (
int)(
unsigned char)*b;
224 (*b && *b != sentinel) ? (
int)(
unsigned char)*a - (
int)(
unsigned char)*b : 1 :
225 (*b && *b != sentinel) ? -1 : 0;
233 typedef struct __kmp_setting kmp_setting_t;
234 typedef struct __kmp_stg_ss_data kmp_stg_ss_data_t;
235 typedef struct __kmp_stg_wp_data kmp_stg_wp_data_t;
236 typedef struct __kmp_stg_fr_data kmp_stg_fr_data_t;
238 typedef void ( * kmp_stg_parse_func_t )(
char const * name,
char const * value,
void * data );
239 typedef void ( * kmp_stg_print_func_t )( kmp_str_buf_t * buffer,
char const * name,
void * data );
241 struct __kmp_setting {
243 kmp_stg_parse_func_t parse;
244 kmp_stg_print_func_t print;
251 struct __kmp_stg_ss_data {
253 kmp_setting_t * * rivals;
256 struct __kmp_stg_wp_data {
258 kmp_setting_t * * rivals;
261 struct __kmp_stg_fr_data {
263 kmp_setting_t * * rivals;
267 __kmp_stg_check_rivals(
270 kmp_setting_t * * rivals
279 __kmp_stg_parse_bool(
284 if ( __kmp_str_match_true( value ) ) {
286 }
else if (__kmp_str_match_false( value ) ) {
291 KMP_MSG( BadBoolValue, name, value ),
292 KMP_HNT( ValidBoolValues ),
299 __kmp_stg_parse_size(
308 char const * msg = NULL;
310 size_min = __kmp_round4k( size_min );
311 size_max = __kmp_round4k( size_max );
312 #endif // KMP_OS_DARWIN 314 if ( is_specified != NULL ) {
317 __kmp_str_to_size( value, out, factor, & msg );
319 if ( * out > size_max ) {
321 msg = KMP_I18N_STR( ValueTooLarge );
322 }
else if ( * out < size_min ) {
324 msg = KMP_I18N_STR( ValueTooSmall );
327 size_t round4k = __kmp_round4k( * out );
328 if ( * out != round4k ) {
330 msg = KMP_I18N_STR( NotMultiple4K );
336 if ( * out < size_min ) {
339 else if ( * out > size_max ) {
346 __kmp_str_buf_init( & buf );
347 __kmp_str_buf_print_size( & buf, * out );
348 KMP_WARNING( ParseSizeIntWarn, name, value, msg );
349 KMP_INFORM( Using_str_Value, name, buf.str );
350 __kmp_str_buf_free( & buf );
355 #if KMP_AFFINITY_SUPPORTED 362 KMP_INTERNAL_FREE( (
void *) * out );
363 * out = __kmp_str_format(
"%s", value );
375 char const * msg = NULL;
376 kmp_uint64 uint = * out;
377 __kmp_str_to_uint( value, & uint, & msg );
379 if ( uint < (
unsigned int)min ) {
380 msg = KMP_I18N_STR( ValueTooSmall );
382 }
else if ( uint > (
unsigned int)max ) {
383 msg = KMP_I18N_STR( ValueTooLarge );
389 if ( uint < (
unsigned int)min ) {
392 else if ( uint > (
unsigned int)max ) {
399 KMP_WARNING( ParseSizeIntWarn, name, value, msg );
400 __kmp_str_buf_init( & buf );
401 __kmp_str_buf_print( &buf,
"%" KMP_UINT64_SPEC
"", uint );
402 KMP_INFORM( Using_uint64_Value, name, buf.str );
403 __kmp_str_buf_free( &buf );
409 #if KMP_DEBUG_ADAPTIVE_LOCKS 411 __kmp_stg_parse_file(
420 KMP_INTERNAL_FREE( (
void *) * out );
421 t = (
char *) strrchr(value,
'.');
422 hasSuffix = t && __kmp_str_eqf( t, suffix );
423 t = __kmp_str_format(
"%s%s", value, hasSuffix ?
"" : suffix );
424 __kmp_expand_file_name( buffer,
sizeof(buffer), t);
425 KMP_INTERNAL_FREE(t);
426 * out = __kmp_str_format(
"%s", buffer );
431 static char * par_range_to_print = NULL;
434 __kmp_stg_parse_par_range(
443 size_t len = KMP_STRLEN( value + 1 );
444 par_range_to_print = (
char *) KMP_INTERNAL_MALLOC( len +1 );
445 KMP_STRNCPY_S( par_range_to_print, len + 1, value, len + 1);
446 __kmp_par_range = +1;
447 __kmp_par_range_lb = 0;
448 __kmp_par_range_ub = INT_MAX;
451 if (( value == NULL ) || ( *value ==
'\0' )) {
454 if ( ! __kmp_strcasecmp_with_sentinel(
"routine", value,
'=' )) {
455 value = strchr( value,
'=' ) + 1;
456 len = __kmp_readstr_with_sentinel( out_routine,
457 value, KMP_PAR_RANGE_ROUTINE_LEN - 1,
',' );
459 goto par_range_error;
461 value = strchr( value,
',' );
462 if ( value != NULL ) {
467 if ( ! __kmp_strcasecmp_with_sentinel(
"filename", value,
'=' )) {
468 value = strchr( value,
'=' ) + 1;
469 len = __kmp_readstr_with_sentinel( out_file,
470 value, KMP_PAR_RANGE_FILENAME_LEN - 1,
',' );
472 goto par_range_error;
474 value = strchr( value,
',' );
475 if ( value != NULL ) {
480 if (( ! __kmp_strcasecmp_with_sentinel(
"range", value,
'=' ))
481 || ( ! __kmp_strcasecmp_with_sentinel(
"incl_range", value,
'=' ))) {
482 value = strchr( value,
'=' ) + 1;
483 if ( KMP_SSCANF( value,
"%d:%d", out_lb, out_ub ) != 2 ) {
484 goto par_range_error;
487 value = strchr( value,
',' );
488 if ( value != NULL ) {
493 if ( ! __kmp_strcasecmp_with_sentinel(
"excl_range", value,
'=' )) {
494 value = strchr( value,
'=' ) + 1;
495 if ( KMP_SSCANF( value,
"%d:%d", out_lb, out_ub) != 2 ) {
496 goto par_range_error;
499 value = strchr( value,
',' );
500 if ( value != NULL ) {
506 KMP_WARNING( ParRangeSyntax, name );
514 __kmp_initial_threads_capacity(
int req_nproc )
519 if (nth < (4 * req_nproc))
520 nth = (4 * req_nproc);
521 if (nth < (4 * __kmp_xproc))
522 nth = (4 * __kmp_xproc);
524 if (nth > __kmp_max_nth)
532 __kmp_default_tp_capacity(
int req_nproc,
int max_nth,
int all_threads_specified) {
535 if(all_threads_specified)
538 if (nth < (4 * req_nproc))
539 nth = (4 * req_nproc);
540 if (nth < (4 * __kmp_xproc))
541 nth = (4 * __kmp_xproc);
543 if (nth > __kmp_max_nth)
555 __kmp_stg_print_bool( kmp_str_buf_t * buffer,
char const * name,
int value ) {
556 if( __kmp_env_format ) {
557 KMP_STR_BUF_PRINT_BOOL;
559 __kmp_str_buf_print( buffer,
" %s=%s\n", name, value ?
"true" :
"false" );
564 __kmp_stg_print_int( kmp_str_buf_t * buffer,
char const * name,
int value ) {
565 if( __kmp_env_format ) {
566 KMP_STR_BUF_PRINT_INT;
568 __kmp_str_buf_print( buffer,
" %s=%d\n", name, value );
573 __kmp_stg_print_uint64( kmp_str_buf_t * buffer,
char const * name, kmp_uint64 value ) {
574 if( __kmp_env_format ) {
575 KMP_STR_BUF_PRINT_UINT64;
577 __kmp_str_buf_print( buffer,
" %s=%" KMP_UINT64_SPEC
"\n", name, value );
582 __kmp_stg_print_str( kmp_str_buf_t * buffer,
char const * name,
char const * value ) {
583 if( __kmp_env_format ) {
584 KMP_STR_BUF_PRINT_STR;
586 __kmp_str_buf_print( buffer,
" %s=%s\n", name, value );
591 __kmp_stg_print_size( kmp_str_buf_t * buffer,
char const * name,
size_t value ) {
592 if( __kmp_env_format ) {
593 KMP_STR_BUF_PRINT_NAME_EX(name);
594 __kmp_str_buf_print_size( buffer, value );
595 __kmp_str_buf_print( buffer,
"'\n" );
597 __kmp_str_buf_print( buffer,
" %s=", name );
598 __kmp_str_buf_print_size( buffer, value );
599 __kmp_str_buf_print( buffer,
"\n" );
614 __kmp_stg_parse_all_threads(
char const * name,
char const * value,
void * data ) {
616 kmp_setting_t * * rivals = (kmp_setting_t * *) data;
618 rc = __kmp_stg_check_rivals( name, value, rivals );
622 if ( ! __kmp_strcasecmp_with_sentinel(
"all", value, 0 ) ) {
623 __kmp_max_nth = __kmp_xproc;
624 __kmp_allThreadsSpecified = 1;
626 __kmp_stg_parse_int( name, value, 1, __kmp_sys_max_nth, & __kmp_max_nth );
627 __kmp_allThreadsSpecified = 0;
629 K_DIAG( 1, (
"__kmp_max_nth == %d\n", __kmp_max_nth ) );
634 __kmp_stg_print_all_threads( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
635 __kmp_stg_print_int( buffer, name, __kmp_max_nth );
643 __kmp_stg_parse_blocktime(
char const * name,
char const * value,
void * data ) {
644 __kmp_dflt_blocktime = __kmp_convert_to_milliseconds( value );
645 if ( __kmp_dflt_blocktime < 0 ) {
646 __kmp_dflt_blocktime = KMP_DEFAULT_BLOCKTIME;
647 __kmp_msg( kmp_ms_warning, KMP_MSG( InvalidValue, name, value ), __kmp_msg_null );
648 KMP_INFORM( Using_int_Value, name, __kmp_dflt_blocktime );
649 __kmp_env_blocktime = FALSE;
651 if ( __kmp_dflt_blocktime < KMP_MIN_BLOCKTIME ) {
652 __kmp_dflt_blocktime = KMP_MIN_BLOCKTIME;
653 __kmp_msg( kmp_ms_warning, KMP_MSG( SmallValue, name, value ), __kmp_msg_null );
654 KMP_INFORM( MinValueUsing, name, __kmp_dflt_blocktime );
655 }
else if ( __kmp_dflt_blocktime > KMP_MAX_BLOCKTIME ) {
656 __kmp_dflt_blocktime = KMP_MAX_BLOCKTIME;
657 __kmp_msg( kmp_ms_warning, KMP_MSG( LargeValue, name, value ), __kmp_msg_null );
658 KMP_INFORM( MaxValueUsing, name, __kmp_dflt_blocktime );
660 __kmp_env_blocktime = TRUE;
663 __kmp_monitor_wakeups = KMP_WAKEUPS_FROM_BLOCKTIME( __kmp_dflt_blocktime, __kmp_monitor_wakeups );
664 __kmp_bt_intervals = KMP_INTERVALS_FROM_BLOCKTIME( __kmp_dflt_blocktime, __kmp_monitor_wakeups );
665 K_DIAG( 1, (
"__kmp_env_blocktime == %d\n", __kmp_env_blocktime ) );
666 if ( __kmp_env_blocktime ) {
667 K_DIAG( 1, (
"__kmp_dflt_blocktime == %d\n", __kmp_dflt_blocktime ) );
672 __kmp_stg_print_blocktime( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
673 __kmp_stg_print_int( buffer, name, __kmp_dflt_blocktime );
681 __kmp_stg_parse_duplicate_lib_ok(
char const * name,
char const * value,
void * data ) {
684 __kmp_stg_parse_bool( name, value, & __kmp_duplicate_library_ok );
688 __kmp_stg_print_duplicate_lib_ok( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
689 __kmp_stg_print_bool( buffer, name, __kmp_duplicate_library_ok );
696 #if KMP_ARCH_X86 || KMP_ARCH_X86_64 699 __kmp_stg_parse_inherit_fp_control(
char const * name,
char const * value,
void * data ) {
700 __kmp_stg_parse_bool( name, value, & __kmp_inherit_fp_control );
704 __kmp_stg_print_inherit_fp_control( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
706 __kmp_stg_print_bool( buffer, name, __kmp_inherit_fp_control );
716 static char const *blocktime_str = NULL;
719 __kmp_stg_parse_wait_policy(
char const * name,
char const * value,
void * data ) {
721 kmp_stg_wp_data_t * wait = (kmp_stg_wp_data_t *) data;
724 rc = __kmp_stg_check_rivals( name, value, wait->rivals );
730 if ( __kmp_str_match(
"ACTIVE", 1, value ) ) {
731 __kmp_library = library_turnaround;
732 if ( blocktime_str == NULL ) {
734 __kmp_dflt_blocktime = KMP_MAX_BLOCKTIME;
736 }
else if ( __kmp_str_match(
"PASSIVE", 1, value ) ) {
737 __kmp_library = library_throughput;
738 if ( blocktime_str == NULL ) {
740 __kmp_dflt_blocktime = 0;
743 KMP_WARNING( StgInvalidValue, name, value );
746 if ( __kmp_str_match(
"serial", 1, value ) ) {
747 __kmp_library = library_serial;
748 }
else if ( __kmp_str_match(
"throughput", 2, value ) ) {
749 __kmp_library = library_throughput;
750 }
else if ( __kmp_str_match(
"turnaround", 2, value ) ) {
751 __kmp_library = library_turnaround;
752 }
else if ( __kmp_str_match(
"dedicated", 1, value ) ) {
753 __kmp_library = library_turnaround;
754 }
else if ( __kmp_str_match(
"multiuser", 1, value ) ) {
755 __kmp_library = library_throughput;
757 KMP_WARNING( StgInvalidValue, name, value );
760 __kmp_aux_set_library( __kmp_library );
765 __kmp_stg_print_wait_policy( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
767 kmp_stg_wp_data_t * wait = (kmp_stg_wp_data_t *) data;
768 char const * value = NULL;
771 switch ( __kmp_library ) {
772 case library_turnaround : {
775 case library_throughput : {
780 switch ( __kmp_library ) {
781 case library_serial : {
784 case library_turnaround : {
785 value =
"turnaround";
787 case library_throughput : {
788 value =
"throughput";
792 if ( value != NULL ) {
793 __kmp_stg_print_str( buffer, name, value );
803 __kmp_stg_parse_monitor_stacksize(
char const * name,
char const * value,
void * data ) {
804 __kmp_stg_parse_size(
807 __kmp_sys_min_stksize,
810 & __kmp_monitor_stksize,
816 __kmp_stg_print_monitor_stacksize( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
817 if( __kmp_env_format ) {
818 if ( __kmp_monitor_stksize > 0 )
819 KMP_STR_BUF_PRINT_NAME_EX(name);
821 KMP_STR_BUF_PRINT_NAME;
823 __kmp_str_buf_print( buffer,
" %s", name );
825 if ( __kmp_monitor_stksize > 0 ) {
826 __kmp_str_buf_print_size( buffer, __kmp_monitor_stksize );
828 __kmp_str_buf_print( buffer,
": %s\n", KMP_I18N_STR( NotDefined ) );
830 if( __kmp_env_format && __kmp_monitor_stksize ) {
831 __kmp_str_buf_print( buffer,
"'\n");
841 __kmp_stg_parse_settings(
char const * name,
char const * value,
void * data ) {
842 __kmp_stg_parse_bool( name, value, & __kmp_settings );
846 __kmp_stg_print_settings( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
847 __kmp_stg_print_bool( buffer, name, __kmp_settings );
855 __kmp_stg_parse_stackpad(
char const * name,
char const * value,
void * data ) {
866 __kmp_stg_print_stackpad( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
867 __kmp_stg_print_int( buffer, name, __kmp_stkpadding );
875 __kmp_stg_parse_stackoffset(
char const * name,
char const * value,
void * data ) {
876 __kmp_stg_parse_size(
888 __kmp_stg_print_stackoffset( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
889 __kmp_stg_print_size( buffer, name, __kmp_stkoffset );
897 __kmp_stg_parse_stacksize(
char const * name,
char const * value,
void * data ) {
899 kmp_stg_ss_data_t * stacksize = (kmp_stg_ss_data_t *) data;
902 rc = __kmp_stg_check_rivals( name, value, stacksize->rivals );
906 __kmp_stg_parse_size(
909 __kmp_sys_min_stksize,
922 __kmp_stg_print_stacksize( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
923 kmp_stg_ss_data_t * stacksize = (kmp_stg_ss_data_t *) data;
924 if( __kmp_env_format ) {
925 KMP_STR_BUF_PRINT_NAME_EX(name);
926 __kmp_str_buf_print_size( buffer, (__kmp_stksize % 1024) ? __kmp_stksize / stacksize->factor : __kmp_stksize );
927 __kmp_str_buf_print( buffer,
"'\n" );
929 __kmp_str_buf_print( buffer,
" %s=", name );
930 __kmp_str_buf_print_size( buffer, (__kmp_stksize % 1024) ? __kmp_stksize / stacksize->factor : __kmp_stksize );
931 __kmp_str_buf_print( buffer,
"\n" );
940 __kmp_stg_parse_version(
char const * name,
char const * value,
void * data ) {
941 __kmp_stg_parse_bool( name, value, & __kmp_version );
945 __kmp_stg_print_version( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
946 __kmp_stg_print_bool( buffer, name, __kmp_version );
954 __kmp_stg_parse_warnings(
char const * name,
char const * value,
void * data ) {
955 __kmp_stg_parse_bool( name, value, & __kmp_generate_warnings );
956 if (__kmp_generate_warnings != kmp_warnings_off) {
957 __kmp_generate_warnings = kmp_warnings_explicit;
962 __kmp_stg_print_warnings( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
963 __kmp_stg_print_bool( buffer, name, __kmp_generate_warnings );
971 __kmp_stg_parse_nested(
char const * name,
char const * value,
void * data ) {
972 __kmp_stg_parse_bool( name, value, & __kmp_dflt_nested );
976 __kmp_stg_print_nested( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
977 __kmp_stg_print_bool( buffer, name, __kmp_dflt_nested );
981 __kmp_parse_nested_num_threads(
const char *var,
const char *env, kmp_nested_nthreads_t *nth_array )
983 const char *next = env;
984 const char *scan = next;
987 int prev_comma = FALSE;
993 if ( *next ==
'\0' ) {
997 if ( ( ( *next <
'0' ) || ( *next >
'9' ) ) && ( *next !=
',') ) {
998 KMP_WARNING( NthSyntaxError, var, env );
1002 if ( *next ==
',' ) {
1004 if ( total == 0 || prev_comma ) {
1012 if ( *next >=
'0' && *next <=
'9' ) {
1014 SKIP_DIGITS( next );
1016 const char *tmp = next;
1018 if ( ( *next ==
' ' || *next ==
'\t' ) && ( *tmp >=
'0' && *tmp <=
'9' ) ) {
1019 KMP_WARNING( NthSpacesNotAllowed, var, env );
1024 KMP_DEBUG_ASSERT( total > 0 );
1026 KMP_WARNING( NthSyntaxError, var, env );
1031 if ( ! nth_array->nth ) {
1033 nth_array->nth = (
int * )KMP_INTERNAL_MALLOC(
sizeof(
int ) * total * 2 );
1034 if ( nth_array->nth == NULL ) {
1035 KMP_FATAL( MemoryAllocFailed );
1037 nth_array->size = total * 2;
1039 if ( nth_array->size < total ) {
1042 nth_array->size *= 2;
1043 }
while ( nth_array->size < total );
1045 nth_array->nth = (
int *) KMP_INTERNAL_REALLOC(
1046 nth_array->nth,
sizeof(
int ) * nth_array->size );
1047 if ( nth_array->nth == NULL ) {
1048 KMP_FATAL( MemoryAllocFailed );
1052 nth_array->used = total;
1060 if ( *scan ==
'\0' ) {
1064 if ( *scan ==
',' ) {
1069 nth_array->nth[i++] = 0;
1071 }
else if ( prev_comma ) {
1073 nth_array->nth[i] = nth_array->nth[i - 1];
1082 if ( *scan >=
'0' && *scan <=
'9' ) {
1084 const char *buf = scan;
1085 char const * msg = NULL;
1087 SKIP_DIGITS( scan );
1090 num = __kmp_str_to_int( buf, *scan );
1091 if ( num < KMP_MIN_NTH ) {
1092 msg = KMP_I18N_STR( ValueTooSmall );
1094 }
else if ( num > __kmp_sys_max_nth ) {
1095 msg = KMP_I18N_STR( ValueTooLarge );
1096 num = __kmp_sys_max_nth;
1098 if ( msg != NULL ) {
1100 KMP_WARNING( ParseSizeIntWarn, var, env, msg );
1101 KMP_INFORM( Using_int_Value, var, num );
1103 nth_array->nth[i++] = num;
1109 __kmp_stg_parse_num_threads(
char const * name,
char const * value,
void * data ) {
1111 if ( ! __kmp_strcasecmp_with_sentinel(
"all", value, 0 ) ) {
1113 __kmp_nested_nth.nth = (
int* )KMP_INTERNAL_MALLOC(
sizeof(
int ) );
1114 __kmp_nested_nth.size = __kmp_nested_nth.used = 1;
1115 __kmp_nested_nth.nth[0] = __kmp_dflt_team_nth = __kmp_dflt_team_nth_ub = __kmp_xproc;
1117 __kmp_parse_nested_num_threads( name, value, & __kmp_nested_nth );
1118 if ( __kmp_nested_nth.nth ) {
1119 __kmp_dflt_team_nth = __kmp_nested_nth.nth[0];
1120 if ( __kmp_dflt_team_nth_ub < __kmp_dflt_team_nth ) {
1121 __kmp_dflt_team_nth_ub = __kmp_dflt_team_nth;
1125 K_DIAG( 1, (
"__kmp_dflt_team_nth == %d\n", __kmp_dflt_team_nth ) );
1129 __kmp_stg_print_num_threads( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1130 if( __kmp_env_format ) {
1131 KMP_STR_BUF_PRINT_NAME;
1133 __kmp_str_buf_print( buffer,
" %s", name );
1135 if ( __kmp_nested_nth.used ) {
1137 __kmp_str_buf_init( &buf );
1138 for (
int i = 0; i < __kmp_nested_nth.used; i++) {
1139 __kmp_str_buf_print( &buf,
"%d", __kmp_nested_nth.nth[i] );
1140 if ( i < __kmp_nested_nth.used - 1 ) {
1141 __kmp_str_buf_print( &buf,
"," );
1144 __kmp_str_buf_print( buffer,
"='%s'\n", buf.str );
1145 __kmp_str_buf_free(&buf);
1147 __kmp_str_buf_print( buffer,
": %s\n", KMP_I18N_STR( NotDefined ) );
1156 __kmp_stg_parse_tasking(
char const * name,
char const * value,
void * data ) {
1157 __kmp_stg_parse_int( name, value, 0, (
int)tskm_max, (
int *)&__kmp_tasking_mode );
1161 __kmp_stg_print_tasking( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1162 __kmp_stg_print_int( buffer, name, __kmp_tasking_mode );
1166 __kmp_stg_parse_task_stealing(
char const * name,
char const * value,
void * data ) {
1167 __kmp_stg_parse_int( name, value, 0, 1, (
int *)&__kmp_task_stealing_constraint );
1171 __kmp_stg_print_task_stealing( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1172 __kmp_stg_print_int( buffer, name, __kmp_task_stealing_constraint );
1176 __kmp_stg_parse_max_active_levels(
char const * name,
char const * value,
void * data ) {
1177 __kmp_stg_parse_int( name, value, 0, KMP_MAX_ACTIVE_LEVELS_LIMIT, & __kmp_dflt_max_active_levels );
1181 __kmp_stg_print_max_active_levels( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1182 __kmp_stg_print_int( buffer, name, __kmp_dflt_max_active_levels );
1190 __kmp_stg_parse_max_task_priority(
char const *name,
char const *value,
void *data) {
1191 __kmp_stg_parse_int(name, value, 0, KMP_MAX_TASK_PRIORITY_LIMIT, &__kmp_max_task_priority);
1195 __kmp_stg_print_max_task_priority(kmp_str_buf_t *buffer,
char const *name,
void *data) {
1196 __kmp_stg_print_int(buffer, name, __kmp_max_task_priority);
1198 #endif // OMP_45_ENABLED 1204 __kmp_stg_parse_disp_buffers(
char const * name,
char const * value,
void * data ) {
1205 if ( TCR_4(__kmp_init_serial) ) {
1206 KMP_WARNING( EnvSerialWarn, name );
1209 __kmp_stg_parse_int( name, value, 1, KMP_MAX_NTH, & __kmp_dispatch_num_buffers );
1213 __kmp_stg_print_disp_buffers( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1214 __kmp_stg_print_int( buffer, name, __kmp_dispatch_num_buffers );
1217 #if KMP_NESTED_HOT_TEAMS 1223 __kmp_stg_parse_hot_teams_level(
char const * name,
char const * value,
void * data ) {
1224 if ( TCR_4(__kmp_init_parallel) ) {
1225 KMP_WARNING( EnvParallelWarn, name );
1228 __kmp_stg_parse_int( name, value, 0, KMP_MAX_ACTIVE_LEVELS_LIMIT, & __kmp_hot_teams_max_level );
1232 __kmp_stg_print_hot_teams_level( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1233 __kmp_stg_print_int( buffer, name, __kmp_hot_teams_max_level );
1237 __kmp_stg_parse_hot_teams_mode(
char const * name,
char const * value,
void * data ) {
1238 if ( TCR_4(__kmp_init_parallel) ) {
1239 KMP_WARNING( EnvParallelWarn, name );
1242 __kmp_stg_parse_int( name, value, 0, KMP_MAX_ACTIVE_LEVELS_LIMIT, & __kmp_hot_teams_mode );
1246 __kmp_stg_print_hot_teams_mode( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1247 __kmp_stg_print_int( buffer, name, __kmp_hot_teams_mode );
1250 #endif // KMP_NESTED_HOT_TEAMS 1256 #if KMP_HANDLE_SIGNALS 1259 __kmp_stg_parse_handle_signals(
char const * name,
char const * value,
void * data ) {
1260 __kmp_stg_parse_bool( name, value, & __kmp_handle_signals );
1264 __kmp_stg_print_handle_signals( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1265 __kmp_stg_print_bool( buffer, name, __kmp_handle_signals );
1268 #endif // KMP_HANDLE_SIGNALS 1276 #define KMP_STG_X_DEBUG( x ) \ 1277 static void __kmp_stg_parse_##x##_debug( char const * name, char const * value, void * data ) { \ 1278 __kmp_stg_parse_int( name, value, 0, INT_MAX, & kmp_##x##_debug ); \ 1280 static void __kmp_stg_print_##x##_debug( kmp_str_buf_t * buffer, char const * name, void * data ) { \ 1281 __kmp_stg_print_int( buffer, name, kmp_##x##_debug ); \ 1284 KMP_STG_X_DEBUG( a )
1285 KMP_STG_X_DEBUG( b )
1286 KMP_STG_X_DEBUG( c )
1287 KMP_STG_X_DEBUG( d )
1288 KMP_STG_X_DEBUG( e )
1289 KMP_STG_X_DEBUG( f )
1291 #undef KMP_STG_X_DEBUG 1294 __kmp_stg_parse_debug(
char const * name,
char const * value,
void * data ) {
1296 __kmp_stg_parse_int( name, value, 0, INT_MAX, & debug );
1297 if ( kmp_a_debug < debug ) {
1298 kmp_a_debug = debug;
1300 if ( kmp_b_debug < debug ) {
1301 kmp_b_debug = debug;
1303 if ( kmp_c_debug < debug ) {
1304 kmp_c_debug = debug;
1306 if ( kmp_d_debug < debug ) {
1307 kmp_d_debug = debug;
1309 if ( kmp_e_debug < debug ) {
1310 kmp_e_debug = debug;
1312 if ( kmp_f_debug < debug ) {
1313 kmp_f_debug = debug;
1318 __kmp_stg_parse_debug_buf(
char const * name,
char const * value,
void * data ) {
1319 __kmp_stg_parse_bool( name, value, & __kmp_debug_buf );
1322 if ( __kmp_debug_buf ) {
1324 int elements = __kmp_debug_buf_lines * __kmp_debug_buf_chars;
1327 __kmp_debug_buffer = (
char *) __kmp_page_allocate( elements *
sizeof(
char ) );
1328 for ( i = 0; i < elements; i += __kmp_debug_buf_chars )
1329 __kmp_debug_buffer[i] =
'\0';
1331 __kmp_debug_count = 0;
1333 K_DIAG( 1, (
"__kmp_debug_buf = %d\n", __kmp_debug_buf ) );
1337 __kmp_stg_print_debug_buf( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1338 __kmp_stg_print_bool( buffer, name, __kmp_debug_buf );
1342 __kmp_stg_parse_debug_buf_atomic(
char const * name,
char const * value,
void * data ) {
1343 __kmp_stg_parse_bool( name, value, & __kmp_debug_buf_atomic );
1347 __kmp_stg_print_debug_buf_atomic( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1348 __kmp_stg_print_bool( buffer, name, __kmp_debug_buf_atomic );
1352 __kmp_stg_parse_debug_buf_chars(
char const * name,
char const * value,
void * data ) {
1353 __kmp_stg_parse_int(
1356 KMP_DEBUG_BUF_CHARS_MIN,
1358 & __kmp_debug_buf_chars
1363 __kmp_stg_print_debug_buf_chars( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1364 __kmp_stg_print_int( buffer, name, __kmp_debug_buf_chars );
1368 __kmp_stg_parse_debug_buf_lines(
char const * name,
char const * value,
void * data ) {
1369 __kmp_stg_parse_int(
1372 KMP_DEBUG_BUF_LINES_MIN,
1374 & __kmp_debug_buf_lines
1379 __kmp_stg_print_debug_buf_lines( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1380 __kmp_stg_print_int( buffer, name, __kmp_debug_buf_lines );
1384 __kmp_stg_parse_diag(
char const * name,
char const * value,
void * data ) {
1385 __kmp_stg_parse_int( name, value, 0, INT_MAX, & kmp_diag );
1389 __kmp_stg_print_diag( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1390 __kmp_stg_print_int( buffer, name, kmp_diag );
1400 __kmp_stg_parse_align_alloc(
char const * name,
char const * value,
void * data ) {
1401 __kmp_stg_parse_size(
1407 & __kmp_align_alloc,
1413 __kmp_stg_print_align_alloc( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1414 __kmp_stg_print_size( buffer, name, __kmp_align_alloc );
1425 __kmp_stg_parse_barrier_branch_bit(
char const * name,
char const * value,
void * data ) {
1429 for (
int i=bs_plain_barrier; i<bs_last_barrier; i++ ) {
1430 var = __kmp_barrier_branch_bit_env_name[ i ];
1431 if ( ( strcmp( var, name) == 0 ) && ( value != 0 ) ) {
1434 comma = (
char *) strchr( value,
',' );
1435 __kmp_barrier_gather_branch_bits[ i ] = ( kmp_uint32 ) __kmp_str_to_int( value,
',' );
1437 if ( comma == NULL ) {
1438 __kmp_barrier_release_branch_bits[ i ] = __kmp_barrier_release_bb_dflt;
1440 __kmp_barrier_release_branch_bits[ i ] = (kmp_uint32) __kmp_str_to_int( comma + 1, 0 );
1442 if ( __kmp_barrier_release_branch_bits[ i ] > KMP_MAX_BRANCH_BITS ) {
1443 __kmp_msg( kmp_ms_warning, KMP_MSG( BarrReleaseValueInvalid, name, comma + 1 ), __kmp_msg_null );
1444 __kmp_barrier_release_branch_bits[ i ] = __kmp_barrier_release_bb_dflt;
1447 if ( __kmp_barrier_gather_branch_bits[ i ] > KMP_MAX_BRANCH_BITS ) {
1448 KMP_WARNING( BarrGatherValueInvalid, name, value );
1449 KMP_INFORM( Using_uint_Value, name, __kmp_barrier_gather_bb_dflt );
1450 __kmp_barrier_gather_branch_bits[ i ] = __kmp_barrier_gather_bb_dflt;
1453 K_DIAG(1, (
"%s == %d,%d\n", __kmp_barrier_branch_bit_env_name[ i ], \
1454 __kmp_barrier_gather_branch_bits [ i ], \
1455 __kmp_barrier_release_branch_bits [ i ]))
1460 __kmp_stg_print_barrier_branch_bit( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1462 for (
int i=bs_plain_barrier; i<bs_last_barrier; i++ ) {
1463 var = __kmp_barrier_branch_bit_env_name[ i ];
1464 if ( strcmp( var, name) == 0 ) {
1465 if( __kmp_env_format ) {
1466 KMP_STR_BUF_PRINT_NAME_EX(__kmp_barrier_branch_bit_env_name[ i ]);
1468 __kmp_str_buf_print( buffer,
" %s='", __kmp_barrier_branch_bit_env_name[ i ] );
1470 __kmp_str_buf_print( buffer,
"%d,%d'\n", __kmp_barrier_gather_branch_bits [ i ], __kmp_barrier_release_branch_bits [ i ]);
1484 __kmp_stg_parse_barrier_pattern(
char const * name,
char const * value,
void * data ) {
1488 for (
int i=bs_plain_barrier; i<bs_last_barrier; i++ ) {
1489 var = __kmp_barrier_pattern_env_name[ i ];
1491 if ( ( strcmp ( var, name ) == 0 ) && ( value != 0 ) ) {
1493 char *comma = (
char *) strchr( value,
',' );
1496 for ( j = bp_linear_bar; j<bp_last_bar; j++ ) {
1497 if (__kmp_match_with_sentinel( __kmp_barrier_pattern_name[j], value, 1,
',' )) {
1498 __kmp_barrier_gather_pattern[ i ] = (kmp_bar_pat_e) j;
1502 if ( j == bp_last_bar ) {
1503 KMP_WARNING( BarrGatherValueInvalid, name, value );
1504 KMP_INFORM( Using_str_Value, name, __kmp_barrier_pattern_name[ bp_linear_bar ] );
1508 if ( comma != NULL ) {
1509 for ( j = bp_linear_bar; j < bp_last_bar; j++ ) {
1510 if ( __kmp_str_match( __kmp_barrier_pattern_name[j], 1, comma + 1 ) ) {
1511 __kmp_barrier_release_pattern[ i ] = (kmp_bar_pat_e) j;
1515 if (j == bp_last_bar) {
1516 __kmp_msg( kmp_ms_warning, KMP_MSG( BarrReleaseValueInvalid, name, comma + 1 ), __kmp_msg_null );
1517 KMP_INFORM( Using_str_Value, name, __kmp_barrier_pattern_name[ bp_linear_bar ] );
1525 __kmp_stg_print_barrier_pattern( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1527 for (
int i=bs_plain_barrier; i<bs_last_barrier; i++ ) {
1528 var = __kmp_barrier_pattern_env_name[ i ];
1529 if ( strcmp ( var, name ) == 0 ) {
1530 int j = __kmp_barrier_gather_pattern [ i ];
1531 int k = __kmp_barrier_release_pattern [ i ];
1532 if( __kmp_env_format ) {
1533 KMP_STR_BUF_PRINT_NAME_EX(__kmp_barrier_pattern_env_name[ i ]);
1535 __kmp_str_buf_print( buffer,
" %s='", __kmp_barrier_pattern_env_name[ i ] );
1537 __kmp_str_buf_print( buffer,
"%s,%s'\n", __kmp_barrier_pattern_name [ j ], __kmp_barrier_pattern_name [ k ]);
1547 __kmp_stg_parse_abort_delay(
char const * name,
char const * value,
void * data ) {
1549 int delay = __kmp_abort_delay / 1000;
1550 __kmp_stg_parse_int( name, value, 0, INT_MAX / 1000, & delay );
1551 __kmp_abort_delay = delay * 1000;
1555 __kmp_stg_print_abort_delay( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1556 __kmp_stg_print_int( buffer, name, __kmp_abort_delay );
1564 __kmp_stg_parse_cpuinfo_file(
char const * name,
char const * value,
void * data ) {
1565 #if KMP_AFFINITY_SUPPORTED 1566 __kmp_stg_parse_str( name, value, & __kmp_cpuinfo_file );
1567 K_DIAG( 1, (
"__kmp_cpuinfo_file == %s\n", __kmp_cpuinfo_file ) );
1572 __kmp_stg_print_cpuinfo_file( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1573 #if KMP_AFFINITY_SUPPORTED 1574 if( __kmp_env_format ) {
1575 KMP_STR_BUF_PRINT_NAME;
1577 __kmp_str_buf_print( buffer,
" %s", name );
1579 if ( __kmp_cpuinfo_file ) {
1580 __kmp_str_buf_print( buffer,
"='%s'\n", __kmp_cpuinfo_file );
1582 __kmp_str_buf_print( buffer,
": %s\n", KMP_I18N_STR( NotDefined ) );
1592 __kmp_stg_parse_force_reduction(
char const * name,
char const * value,
void * data )
1594 kmp_stg_fr_data_t * reduction = (kmp_stg_fr_data_t *) data;
1597 rc = __kmp_stg_check_rivals( name, value, reduction->rivals );
1601 if ( reduction->force ) {
1603 if( __kmp_str_match(
"critical", 0, value ) )
1604 __kmp_force_reduction_method = critical_reduce_block;
1605 else if( __kmp_str_match(
"atomic", 0, value ) )
1606 __kmp_force_reduction_method = atomic_reduce_block;
1607 else if( __kmp_str_match(
"tree", 0, value ) )
1608 __kmp_force_reduction_method = tree_reduce_block;
1610 KMP_FATAL( UnknownForceReduction, name, value );
1614 __kmp_stg_parse_bool( name, value, & __kmp_determ_red );
1615 if( __kmp_determ_red ) {
1616 __kmp_force_reduction_method = tree_reduce_block;
1618 __kmp_force_reduction_method = reduction_method_not_defined;
1621 K_DIAG( 1, (
"__kmp_force_reduction_method == %d\n", __kmp_force_reduction_method ) );
1625 __kmp_stg_print_force_reduction( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1627 kmp_stg_fr_data_t * reduction = (kmp_stg_fr_data_t *) data;
1628 if ( reduction->force ) {
1629 if( __kmp_force_reduction_method == critical_reduce_block) {
1630 __kmp_stg_print_str( buffer, name,
"critical");
1631 }
else if ( __kmp_force_reduction_method == atomic_reduce_block ) {
1632 __kmp_stg_print_str( buffer, name,
"atomic");
1633 }
else if ( __kmp_force_reduction_method == tree_reduce_block ) {
1634 __kmp_stg_print_str( buffer, name,
"tree");
1636 if( __kmp_env_format ) {
1637 KMP_STR_BUF_PRINT_NAME;
1639 __kmp_str_buf_print( buffer,
" %s", name );
1641 __kmp_str_buf_print( buffer,
": %s\n", KMP_I18N_STR( NotDefined ) );
1644 __kmp_stg_print_bool( buffer, name, __kmp_determ_red );
1655 __kmp_stg_parse_storage_map(
char const * name,
char const * value,
void * data ) {
1656 if ( __kmp_str_match(
"verbose", 1, value ) ) {
1657 __kmp_storage_map = TRUE;
1658 __kmp_storage_map_verbose = TRUE;
1659 __kmp_storage_map_verbose_specified = TRUE;
1662 __kmp_storage_map_verbose = FALSE;
1663 __kmp_stg_parse_bool( name, value, & __kmp_storage_map );
1668 __kmp_stg_print_storage_map( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1669 if ( __kmp_storage_map_verbose || __kmp_storage_map_verbose_specified ) {
1670 __kmp_stg_print_str( buffer, name,
"verbose" );
1672 __kmp_stg_print_bool( buffer, name, __kmp_storage_map );
1681 __kmp_stg_parse_all_threadprivate(
char const * name,
char const * value,
void * data ) {
1682 __kmp_stg_parse_int( name, value, __kmp_allThreadsSpecified ? __kmp_max_nth : 1, __kmp_max_nth,
1683 & __kmp_tp_capacity );
1687 __kmp_stg_print_all_threadprivate( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1688 __kmp_stg_print_int( buffer, name, __kmp_tp_capacity );
1697 __kmp_stg_parse_foreign_threads_threadprivate(
char const * name,
char const * value,
void * data ) {
1698 __kmp_stg_parse_bool( name, value, & __kmp_foreign_tp );
1702 __kmp_stg_print_foreign_threads_threadprivate( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
1703 __kmp_stg_print_bool( buffer, name, __kmp_foreign_tp );
1711 #if KMP_AFFINITY_SUPPORTED 1716 __kmp_parse_affinity_proc_id_list(
const char *var,
const char *env,
1717 const char **nextEnv,
char **proclist )
1719 const char *scan = env;
1720 const char *next = scan;
1726 int start, end, stride;
1730 if (*next ==
'\0') {
1743 if ((*next <
'0') || (*next >
'9')) {
1744 KMP_WARNING( AffSyntaxError, var );
1748 num = __kmp_str_to_int(scan, *next);
1749 KMP_ASSERT(num >= 0);
1773 if ((*next <
'0') || (*next >
'9')) {
1774 KMP_WARNING( AffSyntaxError, var );
1779 num = __kmp_str_to_int(scan, *next);
1780 KMP_ASSERT(num >= 0);
1795 if ((*next <
'0') || (*next >
'9')) {
1797 KMP_WARNING( AffSyntaxError, var );
1807 start = __kmp_str_to_int(scan, *next);
1808 KMP_ASSERT(start >= 0);
1833 if ((*next <
'0') || (*next >
'9')) {
1834 KMP_WARNING( AffSyntaxError, var );
1838 end = __kmp_str_to_int(scan, *next);
1839 KMP_ASSERT(end >= 0);
1860 if ((*next <
'0') || (*next >
'9')) {
1861 KMP_WARNING( AffSyntaxError, var );
1865 stride = __kmp_str_to_int(scan, *next);
1866 KMP_ASSERT(stride >= 0);
1874 KMP_WARNING( AffZeroStride, var );
1879 KMP_WARNING( AffStartGreaterEnd, var, start, end );
1885 KMP_WARNING( AffStrideLessZero, var, start, end );
1889 if ((end - start) / stride > 65536 ) {
1890 KMP_WARNING( AffRangeTooBig, var, end, start, stride );
1909 int len = next - env;
1910 char *retlist = (
char *)__kmp_allocate((len + 1) *
sizeof(char));
1911 KMP_MEMCPY_S(retlist, (len+1)*
sizeof(
char), env, len *
sizeof(
char));
1912 retlist[len] =
'\0';
1913 *proclist = retlist;
1923 static kmp_setting_t *__kmp_affinity_notype = NULL;
1926 __kmp_parse_affinity_env(
char const * name,
char const * value,
1927 enum affinity_type * out_type,
1928 char ** out_proclist,
1932 enum affinity_gran * out_gran,
1933 int * out_gran_levels,
1939 char * buffer = NULL;
1949 int max_proclist = 0;
1956 KMP_ASSERT( value != NULL );
1958 if ( TCR_4(__kmp_init_middle) ) {
1959 KMP_WARNING( EnvMiddleWarn, name );
1960 __kmp_env_toPrint( name, 0 );
1963 __kmp_env_toPrint( name, 1 );
1965 buffer = __kmp_str_format(
"%s", value );
1977 #define EMIT_WARN(skip,errlist) \ 1981 SKIP_TO(next, ','); \ 1985 KMP_WARNING errlist; \ 1988 if (ch == ',') next++; \ 1993 #define _set_param(_guard,_var,_val) \ 1995 if ( _guard == 0 ) { \ 1998 EMIT_WARN( FALSE, ( AffParamDefined, name, start ) ); \ 2003 #define set_type(val) _set_param( type, *out_type, val ) 2004 #define set_verbose(val) _set_param( verbose, *out_verbose, val ) 2005 #define set_warnings(val) _set_param( warnings, *out_warn, val ) 2006 #define set_respect(val) _set_param( respect, *out_respect, val ) 2007 #define set_dups(val) _set_param( dups, *out_dups, val ) 2008 #define set_proclist(val) _set_param( proclist, *out_proclist, val ) 2010 #define set_gran(val,levels) \ 2012 if ( gran == 0 ) { \ 2014 *out_gran_levels = levels; \ 2016 EMIT_WARN( FALSE, ( AffParamDefined, name, start ) ); \ 2022 KMP_DEBUG_ASSERT( ( __kmp_nested_proc_bind.bind_types != NULL )
2023 && ( __kmp_nested_proc_bind.used > 0 ) );
2026 while ( *buf !=
'\0' ) {
2029 if (__kmp_match_str(
"none", buf, (
const char **)&next)) {
2030 set_type( affinity_none );
2032 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
2035 }
else if (__kmp_match_str(
"scatter", buf, (
const char **)&next)) {
2036 set_type( affinity_scatter );
2038 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2041 }
else if (__kmp_match_str(
"compact", buf, (
const char **)&next)) {
2042 set_type( affinity_compact );
2044 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2047 }
else if (__kmp_match_str(
"logical", buf, (
const char **)&next)) {
2048 set_type( affinity_logical );
2050 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2053 }
else if (__kmp_match_str(
"physical", buf, (
const char **)&next)) {
2054 set_type( affinity_physical );
2056 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2059 }
else if (__kmp_match_str(
"explicit", buf, (
const char **)&next)) {
2060 set_type( affinity_explicit );
2062 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2065 }
else if (__kmp_match_str(
"balanced", buf, (
const char **)&next)) {
2066 set_type( affinity_balanced );
2068 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2071 }
else if (__kmp_match_str(
"disabled", buf, (
const char **)&next)) {
2072 set_type( affinity_disabled );
2074 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
2077 }
else if (__kmp_match_str(
"verbose", buf, (
const char **)&next)) {
2078 set_verbose( TRUE );
2080 }
else if (__kmp_match_str(
"noverbose", buf, (
const char **)&next)) {
2081 set_verbose( FALSE );
2083 }
else if (__kmp_match_str(
"warnings", buf, (
const char **)&next)) {
2084 set_warnings( TRUE );
2086 }
else if (__kmp_match_str(
"nowarnings", buf, (
const char **)&next)) {
2087 set_warnings( FALSE );
2089 }
else if (__kmp_match_str(
"respect", buf, (
const char **)&next)) {
2090 set_respect( TRUE );
2092 }
else if (__kmp_match_str(
"norespect", buf, (
const char **)&next)) {
2093 set_respect( FALSE );
2095 }
else if (__kmp_match_str(
"duplicates", buf, (
const char **)&next)
2096 || __kmp_match_str(
"dups", buf, (
const char **)&next)) {
2099 }
else if (__kmp_match_str(
"noduplicates", buf, (
const char **)&next)
2100 || __kmp_match_str(
"nodups", buf, (
const char **)&next)) {
2103 }
else if (__kmp_match_str(
"granularity", buf, (
const char **)&next)
2104 || __kmp_match_str(
"gran", buf, (
const char **)&next)) {
2107 EMIT_WARN( TRUE, ( AffInvalidParam, name, start ) );
2114 if (__kmp_match_str(
"fine", buf, (
const char **)&next)) {
2115 set_gran( affinity_gran_fine, -1 );
2117 }
else if (__kmp_match_str(
"thread", buf, (
const char **)&next)) {
2118 set_gran( affinity_gran_thread, -1 );
2120 }
else if (__kmp_match_str(
"core", buf, (
const char **)&next)) {
2121 set_gran( affinity_gran_core, -1 );
2123 }
else if (__kmp_match_str(
"package", buf, (
const char **)&next)) {
2124 set_gran( affinity_gran_package, -1 );
2126 }
else if (__kmp_match_str(
"node", buf, (
const char **)&next)) {
2127 set_gran( affinity_gran_node, -1 );
2129 # if KMP_GROUP_AFFINITY 2130 }
else if (__kmp_match_str(
"group", buf, (
const char **)&next)) {
2131 set_gran( affinity_gran_group, -1 );
2134 }
else if ((*buf >=
'0') && (*buf <=
'9')) {
2138 n = __kmp_str_to_int( buf, *next );
2141 set_gran( affinity_gran_default, n );
2143 EMIT_WARN( TRUE, ( AffInvalidParam, name, start ) );
2146 }
else if (__kmp_match_str(
"proclist", buf, (
const char **)&next)) {
2147 char *temp_proclist;
2151 EMIT_WARN( TRUE, ( AffInvalidParam, name, start ) );
2157 EMIT_WARN( TRUE, ( AffInvalidParam, name, start ) );
2162 if (! __kmp_parse_affinity_proc_id_list(name, buf,
2163 (
const char **)&next, &temp_proclist)) {
2168 if (*next ==
']') next++;
2170 if (*next ==
',') next++;
2175 EMIT_WARN( TRUE, ( AffInvalidParam, name, start ) );
2179 set_proclist( temp_proclist );
2180 }
else if ((*buf >=
'0') && (*buf <=
'9')) {
2185 n = __kmp_str_to_int( buf, *next );
2189 number[ count ] = n;
2191 KMP_WARNING( AffManyParams, name, start );
2195 EMIT_WARN( TRUE, ( AffInvalidParam, name, start ) );
2204 else if (*next !=
'\0') {
2205 const char *temp = next;
2206 EMIT_WARN( TRUE, ( ParseExtraCharsWarn, name, temp ) );
2218 #undef set_granularity 2220 KMP_INTERNAL_FREE( buffer );
2224 KMP_WARNING( AffProcListNoType, name );
2225 __kmp_affinity_type = affinity_explicit;
2227 else if ( __kmp_affinity_type != affinity_explicit ) {
2228 KMP_WARNING( AffProcListNotExplicit, name );
2229 KMP_ASSERT( *out_proclist != NULL );
2230 KMP_INTERNAL_FREE( *out_proclist );
2231 *out_proclist = NULL;
2234 switch ( *out_type ) {
2235 case affinity_logical:
2236 case affinity_physical: {
2238 *out_offset = number[ 0 ];
2241 KMP_WARNING( AffManyParamsForLogic, name, number[ 1 ] );
2244 case affinity_balanced: {
2246 *out_compact = number[ 0 ];
2249 *out_offset = number[ 1 ];
2252 if ( __kmp_affinity_gran == affinity_gran_default ) {
2253 #if KMP_ARCH_X86_64 && (KMP_OS_LINUX || KMP_OS_WINDOWS) 2254 if( __kmp_mic_type != non_mic ) {
2255 if( __kmp_affinity_verbose || __kmp_affinity_warnings ) {
2256 KMP_WARNING( AffGranUsing,
"KMP_AFFINITY",
"fine" );
2258 __kmp_affinity_gran = affinity_gran_fine;
2262 if( __kmp_affinity_verbose || __kmp_affinity_warnings ) {
2263 KMP_WARNING( AffGranUsing,
"KMP_AFFINITY",
"core" );
2265 __kmp_affinity_gran = affinity_gran_core;
2269 case affinity_scatter:
2270 case affinity_compact: {
2272 *out_compact = number[ 0 ];
2275 *out_offset = number[ 1 ];
2278 case affinity_explicit: {
2279 if ( *out_proclist == NULL ) {
2280 KMP_WARNING( AffNoProcList, name );
2281 __kmp_affinity_type = affinity_none;
2284 KMP_WARNING( AffNoParam, name,
"explicit" );
2287 case affinity_none: {
2289 KMP_WARNING( AffNoParam, name,
"none" );
2292 case affinity_disabled: {
2294 KMP_WARNING( AffNoParam, name,
"disabled" );
2297 case affinity_default: {
2299 KMP_WARNING( AffNoParam, name,
"default" );
2309 __kmp_stg_parse_affinity(
char const * name,
char const * value,
void * data )
2311 kmp_setting_t **rivals = (kmp_setting_t **) data;
2314 rc = __kmp_stg_check_rivals( name, value, rivals );
2319 __kmp_parse_affinity_env( name, value, & __kmp_affinity_type,
2320 & __kmp_affinity_proclist, & __kmp_affinity_verbose,
2321 & __kmp_affinity_warnings, & __kmp_affinity_respect_mask,
2322 & __kmp_affinity_gran, & __kmp_affinity_gran_levels,
2323 & __kmp_affinity_dups, & __kmp_affinity_compact,
2324 & __kmp_affinity_offset );
2329 __kmp_stg_print_affinity( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
2330 if( __kmp_env_format ) {
2331 KMP_STR_BUF_PRINT_NAME_EX(name);
2333 __kmp_str_buf_print( buffer,
" %s='", name );
2335 if ( __kmp_affinity_verbose ) {
2336 __kmp_str_buf_print( buffer,
"%s,",
"verbose");
2338 __kmp_str_buf_print( buffer,
"%s,",
"noverbose");
2340 if ( __kmp_affinity_warnings ) {
2341 __kmp_str_buf_print( buffer,
"%s,",
"warnings");
2343 __kmp_str_buf_print( buffer,
"%s,",
"nowarnings");
2345 if ( KMP_AFFINITY_CAPABLE() ) {
2346 if ( __kmp_affinity_respect_mask ) {
2347 __kmp_str_buf_print( buffer,
"%s,",
"respect");
2349 __kmp_str_buf_print( buffer,
"%s,",
"norespect");
2351 switch ( __kmp_affinity_gran ) {
2352 case affinity_gran_default:
2353 __kmp_str_buf_print( buffer,
"%s",
"granularity=default,");
2355 case affinity_gran_fine:
2356 __kmp_str_buf_print( buffer,
"%s",
"granularity=fine,");
2358 case affinity_gran_thread:
2359 __kmp_str_buf_print( buffer,
"%s",
"granularity=thread,");
2361 case affinity_gran_core:
2362 __kmp_str_buf_print( buffer,
"%s",
"granularity=core,");
2364 case affinity_gran_package:
2365 __kmp_str_buf_print( buffer,
"%s",
"granularity=package,");
2367 case affinity_gran_node:
2368 __kmp_str_buf_print( buffer,
"%s",
"granularity=node,");
2370 # if KMP_GROUP_AFFINITY 2371 case affinity_gran_group:
2372 __kmp_str_buf_print( buffer,
"%s",
"granularity=group,");
2376 if ( __kmp_affinity_dups ) {
2377 __kmp_str_buf_print( buffer,
"%s,",
"duplicates");
2379 __kmp_str_buf_print( buffer,
"%s,",
"noduplicates");
2382 if ( ! KMP_AFFINITY_CAPABLE() ) {
2383 __kmp_str_buf_print( buffer,
"%s",
"disabled" );
2385 else switch ( __kmp_affinity_type ){
2387 __kmp_str_buf_print( buffer,
"%s",
"none");
2389 case affinity_physical:
2390 __kmp_str_buf_print( buffer,
"%s,%d",
"physical",
2391 __kmp_affinity_offset );
2393 case affinity_logical:
2394 __kmp_str_buf_print( buffer,
"%s,%d",
"logical",
2395 __kmp_affinity_offset );
2397 case affinity_compact:
2398 __kmp_str_buf_print( buffer,
"%s,%d,%d",
"compact",
2399 __kmp_affinity_compact, __kmp_affinity_offset );
2401 case affinity_scatter:
2402 __kmp_str_buf_print( buffer,
"%s,%d,%d",
"scatter",
2403 __kmp_affinity_compact, __kmp_affinity_offset );
2405 case affinity_explicit:
2406 __kmp_str_buf_print( buffer,
"%s=[%s],%s",
"proclist",
2407 __kmp_affinity_proclist,
"explicit" );
2409 case affinity_balanced:
2410 __kmp_str_buf_print( buffer,
"%s,%d,%d",
"balanced",
2411 __kmp_affinity_compact, __kmp_affinity_offset );
2413 case affinity_disabled:
2414 __kmp_str_buf_print( buffer,
"%s",
"disabled");
2416 case affinity_default:
2417 __kmp_str_buf_print( buffer,
"%s",
"default");
2420 __kmp_str_buf_print( buffer,
"%s",
"<unknown>");
2423 __kmp_str_buf_print( buffer,
"'\n" );
2426 # ifdef KMP_GOMP_COMPAT 2429 __kmp_stg_parse_gomp_cpu_affinity(
char const * name,
char const * value,
void * data )
2431 const char * next = NULL;
2432 char * temp_proclist;
2433 kmp_setting_t **rivals = (kmp_setting_t **) data;
2436 rc = __kmp_stg_check_rivals( name, value, rivals );
2441 if ( TCR_4(__kmp_init_middle) ) {
2442 KMP_WARNING( EnvMiddleWarn, name );
2443 __kmp_env_toPrint( name, 0 );
2447 __kmp_env_toPrint( name, 1 );
2449 if ( __kmp_parse_affinity_proc_id_list( name, value, &next,
2452 if (*next ==
'\0') {
2456 __kmp_affinity_proclist = temp_proclist;
2457 __kmp_affinity_type = affinity_explicit;
2458 __kmp_affinity_gran = affinity_gran_fine;
2460 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
2464 KMP_WARNING( AffSyntaxError, name );
2465 if (temp_proclist != NULL) {
2466 KMP_INTERNAL_FREE((
void *)temp_proclist);
2474 __kmp_affinity_type = affinity_none;
2476 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
2509 __kmp_parse_subplace_list(
const char *var,
const char **scan )
2514 int start, count, stride;
2520 if ((**scan <
'0') || (**scan >
'9')) {
2521 KMP_WARNING( SyntaxErrorUsing, var,
"\"threads\"" );
2526 start = __kmp_str_to_int(*scan, *next);
2527 KMP_ASSERT(start >= 0);
2534 if (**scan ==
'}') {
2537 if (**scan ==
',') {
2541 if (**scan !=
':') {
2542 KMP_WARNING( SyntaxErrorUsing, var,
"\"threads\"" );
2551 if ((**scan <
'0') || (**scan >
'9')) {
2552 KMP_WARNING( SyntaxErrorUsing, var,
"\"threads\"" );
2557 count = __kmp_str_to_int(*scan, *next);
2558 KMP_ASSERT(count >= 0);
2565 if (**scan ==
'}') {
2568 if (**scan ==
',') {
2572 if (**scan !=
':') {
2573 KMP_WARNING( SyntaxErrorUsing, var,
"\"threads\"" );
2584 if (**scan ==
'+') {
2588 if (**scan ==
'-') {
2596 if ((**scan <
'0') || (**scan >
'9')) {
2597 KMP_WARNING( SyntaxErrorUsing, var,
"\"threads\"" );
2602 stride = __kmp_str_to_int(*scan, *next);
2603 KMP_ASSERT(stride >= 0);
2611 if (**scan ==
'}') {
2614 if (**scan ==
',') {
2619 KMP_WARNING( SyntaxErrorUsing, var,
"\"threads\"" );
2626 __kmp_parse_place(
const char *var,
const char ** scan )
2634 if (**scan ==
'{') {
2636 if (! __kmp_parse_subplace_list(var, scan)) {
2639 if (**scan !=
'}') {
2640 KMP_WARNING( SyntaxErrorUsing, var,
"\"threads\"" );
2645 else if (**scan ==
'!') {
2647 return __kmp_parse_place(var, scan);
2649 else if ((**scan >=
'0') && (**scan <=
'9')) {
2652 int proc = __kmp_str_to_int(*scan, *next);
2653 KMP_ASSERT(proc >= 0);
2657 KMP_WARNING( SyntaxErrorUsing, var,
"\"threads\"" );
2664 __kmp_parse_place_list(
const char *var,
const char *env,
char **place_list )
2666 const char *scan = env;
2667 const char *next = scan;
2670 int start, count, stride;
2672 if (! __kmp_parse_place(var, &scan)) {
2680 if (*scan ==
'\0') {
2688 KMP_WARNING( SyntaxErrorUsing, var,
"\"threads\"" );
2697 if ((*scan <
'0') || (*scan >
'9')) {
2698 KMP_WARNING( SyntaxErrorUsing, var,
"\"threads\"" );
2703 count = __kmp_str_to_int(scan, *next);
2704 KMP_ASSERT(count >= 0);
2711 if (*scan ==
'\0') {
2719 KMP_WARNING( SyntaxErrorUsing, var,
"\"threads\"" );
2742 if ((*scan <
'0') || (*scan >
'9')) {
2743 KMP_WARNING( SyntaxErrorUsing, var,
"\"threads\"" );
2748 stride = __kmp_str_to_int(scan, *next);
2749 KMP_ASSERT(stride >= 0);
2757 if (*scan ==
'\0') {
2765 KMP_WARNING( SyntaxErrorUsing, var,
"\"threads\"" );
2770 int len = scan - env;
2771 char *retlist = (
char *)__kmp_allocate((len + 1) *
sizeof(char));
2772 KMP_MEMCPY_S(retlist, (len+1)*
sizeof(
char), env, len *
sizeof(
char));
2773 retlist[len] =
'\0';
2774 *place_list = retlist;
2780 __kmp_stg_parse_places(
char const * name,
char const * value,
void * data )
2783 const char *scan = value;
2784 const char *next = scan;
2785 const char *kind =
"\"threads\"";
2786 kmp_setting_t **rivals = (kmp_setting_t **) data;
2789 rc = __kmp_stg_check_rivals( name, value, rivals );
2798 if ( __kmp_nested_proc_bind.bind_types[0] == proc_bind_default ) {
2799 __kmp_nested_proc_bind.bind_types[0] = proc_bind_true;
2804 if ( __kmp_match_str(
"threads", scan, &next ) ) {
2806 __kmp_affinity_type = affinity_compact;
2807 __kmp_affinity_gran = affinity_gran_thread;
2808 __kmp_affinity_dups = FALSE;
2809 kind =
"\"threads\"";
2811 else if ( __kmp_match_str(
"cores", scan, &next ) ) {
2813 __kmp_affinity_type = affinity_compact;
2814 __kmp_affinity_gran = affinity_gran_core;
2815 __kmp_affinity_dups = FALSE;
2818 else if ( __kmp_match_str(
"sockets", scan, &next ) ) {
2820 __kmp_affinity_type = affinity_compact;
2821 __kmp_affinity_gran = affinity_gran_package;
2822 __kmp_affinity_dups = FALSE;
2823 kind =
"\"sockets\"";
2826 if ( __kmp_affinity_proclist != NULL ) {
2827 KMP_INTERNAL_FREE( (
void *)__kmp_affinity_proclist );
2828 __kmp_affinity_proclist = NULL;
2830 if ( __kmp_parse_place_list( name, value, &__kmp_affinity_proclist ) ) {
2831 __kmp_affinity_type = affinity_explicit;
2832 __kmp_affinity_gran = affinity_gran_fine;
2833 __kmp_affinity_dups = FALSE;
2834 if ( __kmp_nested_proc_bind.bind_types[0] == proc_bind_default ) {
2835 __kmp_nested_proc_bind.bind_types[0] = proc_bind_true;
2841 if ( __kmp_nested_proc_bind.bind_types[0] == proc_bind_default ) {
2842 __kmp_nested_proc_bind.bind_types[0] = proc_bind_true;
2846 if ( *scan ==
'\0' ) {
2853 if ( *scan !=
'(' ) {
2854 KMP_WARNING( SyntaxErrorUsing, name, kind );
2862 count = __kmp_str_to_int(scan, *next);
2863 KMP_ASSERT(count >= 0);
2867 if ( *scan !=
')' ) {
2868 KMP_WARNING( SyntaxErrorUsing, name, kind );
2874 if ( *scan !=
'\0' ) {
2875 KMP_WARNING( ParseExtraCharsWarn, name, scan );
2877 __kmp_affinity_num_places = count;
2881 __kmp_stg_print_places( kmp_str_buf_t * buffer,
char const * name,
2884 if( __kmp_env_format ) {
2885 KMP_STR_BUF_PRINT_NAME;
2887 __kmp_str_buf_print( buffer,
" %s", name );
2889 if ( ( __kmp_nested_proc_bind.used == 0 )
2890 || ( __kmp_nested_proc_bind.bind_types == NULL )
2891 || ( __kmp_nested_proc_bind.bind_types[0] == proc_bind_false ) ) {
2892 __kmp_str_buf_print( buffer,
": %s\n", KMP_I18N_STR( NotDefined ) );
2894 else if ( __kmp_affinity_type == affinity_explicit ) {
2895 if ( __kmp_affinity_proclist != NULL ) {
2896 __kmp_str_buf_print( buffer,
"='%s'\n", __kmp_affinity_proclist );
2899 __kmp_str_buf_print( buffer,
": %s\n", KMP_I18N_STR( NotDefined ) );
2902 else if ( __kmp_affinity_type == affinity_compact ) {
2904 if ( __kmp_affinity_num_masks > 0 ) {
2905 num = __kmp_affinity_num_masks;
2907 else if ( __kmp_affinity_num_places > 0 ) {
2908 num = __kmp_affinity_num_places;
2913 if ( __kmp_affinity_gran == affinity_gran_thread ) {
2915 __kmp_str_buf_print( buffer,
"='threads(%d)'\n", num );
2918 __kmp_str_buf_print( buffer,
"='threads'\n" );
2921 else if ( __kmp_affinity_gran == affinity_gran_core ) {
2923 __kmp_str_buf_print( buffer,
"='cores(%d)' \n", num );
2926 __kmp_str_buf_print( buffer,
"='cores'\n" );
2929 else if ( __kmp_affinity_gran == affinity_gran_package ) {
2931 __kmp_str_buf_print( buffer,
"='sockets(%d)'\n", num );
2934 __kmp_str_buf_print( buffer,
"='sockets'\n" );
2938 __kmp_str_buf_print( buffer,
": %s\n", KMP_I18N_STR( NotDefined ) );
2942 __kmp_str_buf_print( buffer,
": %s\n", KMP_I18N_STR( NotDefined ) );
2948 # if (! OMP_40_ENABLED) 2951 __kmp_stg_parse_proc_bind(
char const * name,
char const * value,
void * data )
2954 kmp_setting_t **rivals = (kmp_setting_t **) data;
2957 rc = __kmp_stg_check_rivals( name, value, rivals );
2965 __kmp_stg_parse_bool( name, value, & enabled );
2971 __kmp_affinity_type = affinity_scatter;
2972 # if KMP_ARCH_X86_64 && (KMP_OS_LINUX || KMP_OS_WINDOWS) 2973 if( __kmp_mic_type != non_mic )
2974 __kmp_affinity_gran = affinity_gran_fine;
2977 __kmp_affinity_gran = affinity_gran_core;
2980 __kmp_affinity_type = affinity_none;
2988 __kmp_stg_parse_topology_method(
char const * name,
char const * value,
2990 if ( __kmp_str_match(
"all", 1, value ) ) {
2991 __kmp_affinity_top_method = affinity_top_method_all;
2993 # if KMP_ARCH_X86 || KMP_ARCH_X86_64 2994 else if ( __kmp_str_match(
"x2apic id", 9, value )
2995 || __kmp_str_match(
"x2apic_id", 9, value )
2996 || __kmp_str_match(
"x2apic-id", 9, value )
2997 || __kmp_str_match(
"x2apicid", 8, value )
2998 || __kmp_str_match(
"cpuid leaf 11", 13, value )
2999 || __kmp_str_match(
"cpuid_leaf_11", 13, value )
3000 || __kmp_str_match(
"cpuid-leaf-11", 13, value )
3001 || __kmp_str_match(
"cpuid leaf11", 12, value )
3002 || __kmp_str_match(
"cpuid_leaf11", 12, value )
3003 || __kmp_str_match(
"cpuid-leaf11", 12, value )
3004 || __kmp_str_match(
"cpuidleaf 11", 12, value )
3005 || __kmp_str_match(
"cpuidleaf_11", 12, value )
3006 || __kmp_str_match(
"cpuidleaf-11", 12, value )
3007 || __kmp_str_match(
"cpuidleaf11", 11, value )
3008 || __kmp_str_match(
"cpuid 11", 8, value )
3009 || __kmp_str_match(
"cpuid_11", 8, value )
3010 || __kmp_str_match(
"cpuid-11", 8, value )
3011 || __kmp_str_match(
"cpuid11", 7, value )
3012 || __kmp_str_match(
"leaf 11", 7, value )
3013 || __kmp_str_match(
"leaf_11", 7, value )
3014 || __kmp_str_match(
"leaf-11", 7, value )
3015 || __kmp_str_match(
"leaf11", 6, value ) ) {
3016 __kmp_affinity_top_method = affinity_top_method_x2apicid;
3018 else if ( __kmp_str_match(
"apic id", 7, value )
3019 || __kmp_str_match(
"apic_id", 7, value )
3020 || __kmp_str_match(
"apic-id", 7, value )
3021 || __kmp_str_match(
"apicid", 6, value )
3022 || __kmp_str_match(
"cpuid leaf 4", 12, value )
3023 || __kmp_str_match(
"cpuid_leaf_4", 12, value )
3024 || __kmp_str_match(
"cpuid-leaf-4", 12, value )
3025 || __kmp_str_match(
"cpuid leaf4", 11, value )
3026 || __kmp_str_match(
"cpuid_leaf4", 11, value )
3027 || __kmp_str_match(
"cpuid-leaf4", 11, value )
3028 || __kmp_str_match(
"cpuidleaf 4", 11, value )
3029 || __kmp_str_match(
"cpuidleaf_4", 11, value )
3030 || __kmp_str_match(
"cpuidleaf-4", 11, value )
3031 || __kmp_str_match(
"cpuidleaf4", 10, value )
3032 || __kmp_str_match(
"cpuid 4", 7, value )
3033 || __kmp_str_match(
"cpuid_4", 7, value )
3034 || __kmp_str_match(
"cpuid-4", 7, value )
3035 || __kmp_str_match(
"cpuid4", 6, value )
3036 || __kmp_str_match(
"leaf 4", 6, value )
3037 || __kmp_str_match(
"leaf_4", 6, value )
3038 || __kmp_str_match(
"leaf-4", 6, value )
3039 || __kmp_str_match(
"leaf4", 5, value ) ) {
3040 __kmp_affinity_top_method = affinity_top_method_apicid;
3043 else if ( __kmp_str_match(
"/proc/cpuinfo", 2, value )
3044 || __kmp_str_match(
"cpuinfo", 5, value )) {
3045 __kmp_affinity_top_method = affinity_top_method_cpuinfo;
3047 # if KMP_GROUP_AFFINITY 3048 else if ( __kmp_str_match(
"group", 1, value ) ) {
3049 __kmp_affinity_top_method = affinity_top_method_group;
3052 else if ( __kmp_str_match(
"flat", 1, value ) ) {
3053 __kmp_affinity_top_method = affinity_top_method_flat;
3056 else if ( __kmp_str_match(
"hwloc", 1, value) ) {
3057 __kmp_affinity_top_method = affinity_top_method_hwloc;
3061 KMP_WARNING( StgInvalidValue, name, value );
3066 __kmp_stg_print_topology_method( kmp_str_buf_t * buffer,
char const * name,
3069 char const * value = NULL;
3071 switch ( __kmp_affinity_top_method ) {
3072 case affinity_top_method_default:
3076 case affinity_top_method_all:
3080 # if KMP_ARCH_X86 || KMP_ARCH_X86_64 3081 case affinity_top_method_x2apicid:
3082 value =
"x2APIC id";
3085 case affinity_top_method_apicid:
3090 case affinity_top_method_cpuinfo:
3094 # if KMP_GROUP_AFFINITY 3095 case affinity_top_method_group:
3100 case affinity_top_method_flat:
3105 if ( value != NULL ) {
3106 __kmp_stg_print_str( buffer, name, value );
3121 __kmp_stg_parse_proc_bind(
char const * name,
char const * value,
void * data )
3123 kmp_setting_t **rivals = (kmp_setting_t **) data;
3126 rc = __kmp_stg_check_rivals( name, value, rivals );
3134 KMP_DEBUG_ASSERT( (__kmp_nested_proc_bind.bind_types != NULL)
3135 && ( __kmp_nested_proc_bind.used > 0 ) );
3137 const char *buf = value;
3141 if ( (*buf >=
'0') && (*buf <=
'9') ) {
3143 SKIP_DIGITS( next );
3144 num = __kmp_str_to_int( buf, *next );
3145 KMP_ASSERT( num >= 0 );
3154 if ( __kmp_match_str(
"disabled", buf, &next ) ) {
3157 # if KMP_AFFINITY_SUPPORTED 3158 __kmp_affinity_type = affinity_disabled;
3160 __kmp_nested_proc_bind.used = 1;
3161 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
3163 else if ( ( num == (
int)proc_bind_false )
3164 || __kmp_match_str(
"false", buf, &next ) ) {
3167 # if KMP_AFFINITY_SUPPORTED 3168 __kmp_affinity_type = affinity_none;
3170 __kmp_nested_proc_bind.used = 1;
3171 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
3173 else if ( ( num == (
int)proc_bind_true )
3174 || __kmp_match_str(
"true", buf, &next ) ) {
3177 __kmp_nested_proc_bind.used = 1;
3178 __kmp_nested_proc_bind.bind_types[0] = proc_bind_true;
3186 for ( scan = buf; *scan !=
'\0'; scan++ ) {
3187 if ( *scan ==
',' ) {
3195 if ( __kmp_nested_proc_bind.size < nelem ) {
3196 __kmp_nested_proc_bind.bind_types = (kmp_proc_bind_t *)
3197 KMP_INTERNAL_REALLOC( __kmp_nested_proc_bind.bind_types,
3198 sizeof(kmp_proc_bind_t) * nelem );
3199 if ( __kmp_nested_proc_bind.bind_types == NULL ) {
3200 KMP_FATAL( MemoryAllocFailed );
3202 __kmp_nested_proc_bind.size = nelem;
3204 __kmp_nested_proc_bind.used = nelem;
3211 enum kmp_proc_bind_t bind;
3213 if ( ( num == (
int)proc_bind_master )
3214 || __kmp_match_str(
"master", buf, &next ) ) {
3217 bind = proc_bind_master;
3219 else if ( ( num == (
int)proc_bind_close )
3220 || __kmp_match_str(
"close", buf, &next ) ) {
3223 bind = proc_bind_close;
3225 else if ( ( num == (
int)proc_bind_spread )
3226 || __kmp_match_str(
"spread", buf, &next ) ) {
3229 bind = proc_bind_spread;
3232 KMP_WARNING( StgInvalidValue, name, value );
3233 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
3234 __kmp_nested_proc_bind.used = 1;
3238 __kmp_nested_proc_bind.bind_types[i++] = bind;
3242 KMP_DEBUG_ASSERT( *buf ==
',' );
3249 if ( (*buf >=
'0') && (*buf <=
'9') ) {
3251 SKIP_DIGITS( next );
3252 num = __kmp_str_to_int( buf, *next );
3253 KMP_ASSERT( num >= 0 );
3263 if ( *buf !=
'\0' ) {
3264 KMP_WARNING( ParseExtraCharsWarn, name, buf );
3270 __kmp_stg_print_proc_bind( kmp_str_buf_t * buffer,
char const * name,
3273 int nelem = __kmp_nested_proc_bind.used;
3274 if( __kmp_env_format ) {
3275 KMP_STR_BUF_PRINT_NAME;
3277 __kmp_str_buf_print( buffer,
" %s", name );
3280 __kmp_str_buf_print( buffer,
": %s\n", KMP_I18N_STR( NotDefined ) );
3284 __kmp_str_buf_print( buffer,
"='", name );
3285 for ( i = 0; i < nelem; i++ ) {
3286 switch ( __kmp_nested_proc_bind.bind_types[i] ) {
3287 case proc_bind_false:
3288 __kmp_str_buf_print( buffer,
"false" );
3291 case proc_bind_true:
3292 __kmp_str_buf_print( buffer,
"true" );
3295 case proc_bind_master:
3296 __kmp_str_buf_print( buffer,
"master" );
3299 case proc_bind_close:
3300 __kmp_str_buf_print( buffer,
"close" );
3303 case proc_bind_spread:
3304 __kmp_str_buf_print( buffer,
"spread" );
3307 case proc_bind_intel:
3308 __kmp_str_buf_print( buffer,
"intel" );
3311 case proc_bind_default:
3312 __kmp_str_buf_print( buffer,
"default" );
3315 if ( i < nelem - 1 ) {
3316 __kmp_str_buf_print( buffer,
"," );
3319 __kmp_str_buf_print( buffer,
"'\n" );
3331 __kmp_stg_parse_omp_dynamic(
char const * name,
char const * value,
void * data )
3333 __kmp_stg_parse_bool( name, value, & (__kmp_global.g.g_dynamic) );
3337 __kmp_stg_print_omp_dynamic( kmp_str_buf_t * buffer,
char const * name,
void * data )
3339 __kmp_stg_print_bool( buffer, name, __kmp_global.g.g_dynamic );
3343 __kmp_stg_parse_kmp_dynamic_mode(
char const * name,
char const * value,
void * data )
3345 if ( TCR_4(__kmp_init_parallel) ) {
3346 KMP_WARNING( EnvParallelWarn, name );
3347 __kmp_env_toPrint( name, 0 );
3350 #ifdef USE_LOAD_BALANCE 3351 else if ( __kmp_str_match(
"load balance", 2, value )
3352 || __kmp_str_match(
"load_balance", 2, value )
3353 || __kmp_str_match(
"load-balance", 2, value )
3354 || __kmp_str_match(
"loadbalance", 2, value )
3355 || __kmp_str_match(
"balance", 1, value ) ) {
3356 __kmp_global.g.g_dynamic_mode = dynamic_load_balance;
3359 else if ( __kmp_str_match(
"thread limit", 1, value )
3360 || __kmp_str_match(
"thread_limit", 1, value )
3361 || __kmp_str_match(
"thread-limit", 1, value )
3362 || __kmp_str_match(
"threadlimit", 1, value )
3363 || __kmp_str_match(
"limit", 2, value ) ) {
3364 __kmp_global.g.g_dynamic_mode = dynamic_thread_limit;
3366 else if ( __kmp_str_match(
"random", 1, value ) ) {
3367 __kmp_global.g.g_dynamic_mode = dynamic_random;
3370 KMP_WARNING( StgInvalidValue, name, value );
3375 __kmp_stg_print_kmp_dynamic_mode( kmp_str_buf_t * buffer,
char const * name,
void * data )
3378 if ( __kmp_global.g.g_dynamic_mode == dynamic_default ) {
3379 __kmp_str_buf_print( buffer,
" %s: %s \n", name, KMP_I18N_STR( NotDefined ) );
3381 # ifdef USE_LOAD_BALANCE 3382 else if ( __kmp_global.g.g_dynamic_mode == dynamic_load_balance ) {
3383 __kmp_stg_print_str( buffer, name,
"load balance" );
3386 else if ( __kmp_global.g.g_dynamic_mode == dynamic_thread_limit ) {
3387 __kmp_stg_print_str( buffer, name,
"thread limit" );
3389 else if ( __kmp_global.g.g_dynamic_mode == dynamic_random ) {
3390 __kmp_stg_print_str( buffer, name,
"random" );
3399 #ifdef USE_LOAD_BALANCE 3406 __kmp_stg_parse_ld_balance_interval(
char const * name,
char const * value,
void * data )
3408 double interval = __kmp_convert_to_double( value );
3409 if ( interval >= 0 ) {
3410 __kmp_load_balance_interval = interval;
3412 KMP_WARNING( StgInvalidValue, name, value );
3417 __kmp_stg_print_ld_balance_interval( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3419 __kmp_str_buf_print( buffer,
" %s=%8.6f\n", name, __kmp_load_balance_interval );
3430 __kmp_stg_parse_init_at_fork(
char const * name,
char const * value,
void * data ) {
3431 __kmp_stg_parse_bool( name, value, & __kmp_need_register_atfork );
3432 if ( __kmp_need_register_atfork ) {
3433 __kmp_need_register_atfork_specified = TRUE;
3438 __kmp_stg_print_init_at_fork( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3439 __kmp_stg_print_bool( buffer, name, __kmp_need_register_atfork_specified );
3447 __kmp_stg_parse_schedule(
char const * name,
char const * value,
void * data ) {
3449 if ( value != NULL ) {
3450 size_t length = KMP_STRLEN( value );
3451 if ( length > INT_MAX ) {
3452 KMP_WARNING( LongValue, name );
3455 if( value[ length - 1 ] ==
'"' || value[ length -1 ] ==
'\'' )
3456 KMP_WARNING( UnbalancedQuotes, name );
3460 semicolon = (
char *) strchr( value,
';' );
3461 if( *value && semicolon != value ) {
3462 char *comma = (
char *) strchr( value,
',' );
3469 if ( !__kmp_strcasecmp_with_sentinel(
"static", value, sentinel ) ) {
3470 if( !__kmp_strcasecmp_with_sentinel(
"greedy", comma,
';' ) ) {
3471 __kmp_static = kmp_sch_static_greedy;
3473 }
else if( !__kmp_strcasecmp_with_sentinel(
"balanced", comma,
';' ) ) {
3474 __kmp_static = kmp_sch_static_balanced;
3477 }
else if ( !__kmp_strcasecmp_with_sentinel(
"guided", value, sentinel ) ) {
3478 if ( !__kmp_strcasecmp_with_sentinel(
"iterative", comma,
';' ) ) {
3479 __kmp_guided = kmp_sch_guided_iterative_chunked;
3481 }
else if ( !__kmp_strcasecmp_with_sentinel(
"analytical", comma,
';' ) ) {
3483 __kmp_guided = kmp_sch_guided_analytical_chunked;
3487 KMP_WARNING( InvalidClause, name, value );
3489 KMP_WARNING( EmptyClause, name );
3490 }
while ( (value = semicolon ? semicolon + 1 : NULL) );
3497 __kmp_stg_print_schedule( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3498 if( __kmp_env_format ) {
3499 KMP_STR_BUF_PRINT_NAME_EX(name);
3501 __kmp_str_buf_print( buffer,
" %s='", name );
3503 if ( __kmp_static == kmp_sch_static_greedy ) {
3504 __kmp_str_buf_print( buffer,
"%s",
"static,greedy");
3505 }
else if ( __kmp_static == kmp_sch_static_balanced ) {
3506 __kmp_str_buf_print ( buffer,
"%s",
"static,balanced");
3508 if ( __kmp_guided == kmp_sch_guided_iterative_chunked ) {
3509 __kmp_str_buf_print( buffer,
";%s'\n",
"guided,iterative");
3510 }
else if ( __kmp_guided == kmp_sch_guided_analytical_chunked ) {
3511 __kmp_str_buf_print( buffer,
";%s'\n",
"guided,analytical");
3520 __kmp_stg_parse_omp_schedule(
char const * name,
char const * value,
void * data )
3524 length = KMP_STRLEN( value );
3526 char *comma = (
char *) strchr( value,
',' );
3527 if( value[ length - 1 ] ==
'"' || value[ length -1 ] ==
'\'')
3528 KMP_WARNING( UnbalancedQuotes, name );
3530 if (!__kmp_strcasecmp_with_sentinel(
"dynamic", value,
','))
3531 __kmp_sched = kmp_sch_dynamic_chunked;
3532 else if (!__kmp_strcasecmp_with_sentinel(
"guided", value,
','))
3535 else if (!__kmp_strcasecmp_with_sentinel(
"auto", value,
',')) {
3538 __kmp_msg( kmp_ms_warning, KMP_MSG( IgnoreChunk, name, comma ), __kmp_msg_null );
3542 else if (!__kmp_strcasecmp_with_sentinel(
"trapezoidal", value,
','))
3543 __kmp_sched = kmp_sch_trapezoidal;
3544 else if (!__kmp_strcasecmp_with_sentinel(
"static", value,
','))
3546 #if KMP_STATIC_STEAL_ENABLED 3547 else if (!__kmp_strcasecmp_with_sentinel(
"static_steal", value,
','))
3551 KMP_WARNING( StgInvalidValue, name, value );
3554 if( value && comma ) {
3555 __kmp_env_chunk = TRUE;
3558 __kmp_sched = kmp_sch_static_chunked;
3560 __kmp_chunk = __kmp_str_to_int( comma, 0 );
3561 if ( __kmp_chunk < 1 ) {
3562 __kmp_chunk = KMP_DEFAULT_CHUNK;
3563 __kmp_msg( kmp_ms_warning, KMP_MSG( InvalidChunk, name, comma ), __kmp_msg_null );
3564 KMP_INFORM( Using_int_Value, name, __kmp_chunk );
3570 }
else if ( __kmp_chunk > KMP_MAX_CHUNK ) {
3571 __kmp_chunk = KMP_MAX_CHUNK;
3572 __kmp_msg( kmp_ms_warning, KMP_MSG( LargeChunk, name, comma ), __kmp_msg_null );
3573 KMP_INFORM( Using_int_Value, name, __kmp_chunk );
3576 __kmp_env_chunk = FALSE;
3578 KMP_WARNING( EmptyString, name );
3580 K_DIAG(1, (
"__kmp_static == %d\n", __kmp_static))
3581 K_DIAG(1, ("__kmp_guided == %d\n", __kmp_guided))
3582 K_DIAG(1, ("__kmp_sched == %d\n", __kmp_sched))
3583 K_DIAG(1, ("__kmp_chunk == %d\n", __kmp_chunk))
3587 __kmp_stg_print_omp_schedule( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3588 if( __kmp_env_format ) {
3589 KMP_STR_BUF_PRINT_NAME_EX(name);
3591 __kmp_str_buf_print( buffer,
" %s='", name );
3593 if ( __kmp_chunk ) {
3594 switch ( __kmp_sched ) {
3595 case kmp_sch_dynamic_chunked:
3596 __kmp_str_buf_print( buffer,
"%s,%d'\n",
"dynamic", __kmp_chunk);
3598 case kmp_sch_guided_iterative_chunked:
3599 case kmp_sch_guided_analytical_chunked:
3600 __kmp_str_buf_print( buffer,
"%s,%d'\n",
"guided", __kmp_chunk);
3602 case kmp_sch_trapezoidal:
3603 __kmp_str_buf_print( buffer,
"%s,%d'\n",
"trapezoidal", __kmp_chunk);
3606 case kmp_sch_static_chunked:
3607 case kmp_sch_static_balanced:
3608 case kmp_sch_static_greedy:
3609 __kmp_str_buf_print( buffer,
"%s,%d'\n",
"static", __kmp_chunk);
3612 __kmp_str_buf_print( buffer,
"%s,%d'\n",
"static_steal", __kmp_chunk);
3615 __kmp_str_buf_print( buffer,
"%s,%d'\n",
"auto", __kmp_chunk);
3619 switch ( __kmp_sched ) {
3620 case kmp_sch_dynamic_chunked:
3621 __kmp_str_buf_print( buffer,
"%s'\n",
"dynamic");
3623 case kmp_sch_guided_iterative_chunked:
3624 case kmp_sch_guided_analytical_chunked:
3625 __kmp_str_buf_print( buffer,
"%s'\n",
"guided");
3627 case kmp_sch_trapezoidal:
3628 __kmp_str_buf_print( buffer,
"%s'\n",
"trapezoidal");
3631 case kmp_sch_static_chunked:
3632 case kmp_sch_static_balanced:
3633 case kmp_sch_static_greedy:
3634 __kmp_str_buf_print( buffer,
"%s'\n",
"static");
3637 __kmp_str_buf_print( buffer,
"%s'\n",
"static_steal");
3640 __kmp_str_buf_print( buffer,
"%s'\n",
"auto");
3651 __kmp_stg_parse_atomic_mode(
char const * name,
char const * value,
void * data ) {
3655 #ifdef KMP_GOMP_COMPAT 3658 __kmp_stg_parse_int( name, value, 0, max, & mode );
3662 __kmp_atomic_mode = mode;
3667 __kmp_stg_print_atomic_mode( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3668 __kmp_stg_print_int( buffer, name, __kmp_atomic_mode );
3677 __kmp_stg_parse_consistency_check(
char const * name,
char const * value,
void * data ) {
3678 if ( ! __kmp_strcasecmp_with_sentinel(
"all", value, 0 ) ) {
3682 __kmp_env_consistency_check = TRUE;
3683 }
else if ( ! __kmp_strcasecmp_with_sentinel(
"none", value, 0 ) ) {
3684 __kmp_env_consistency_check = FALSE;
3686 KMP_WARNING( StgInvalidValue, name, value );
3691 __kmp_stg_print_consistency_check( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3693 const char *value = NULL;
3695 if ( __kmp_env_consistency_check ) {
3701 if ( value != NULL ) {
3702 __kmp_stg_print_str( buffer, name, value );
3716 __kmp_stg_parse_itt_prepare_delay(
char const * name,
char const * value,
void * data )
3720 __kmp_stg_parse_int( name, value, 0, INT_MAX, & delay );
3721 __kmp_itt_prepare_delay = delay;
3725 __kmp_stg_print_itt_prepare_delay( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3726 __kmp_stg_print_uint64( buffer, name, __kmp_itt_prepare_delay );
3730 #endif // USE_ITT_NOTIFY 3738 __kmp_stg_parse_malloc_pool_incr(
char const * name,
char const * value,
void * data ) {
3739 __kmp_stg_parse_size(
3742 KMP_MIN_MALLOC_POOL_INCR,
3743 KMP_MAX_MALLOC_POOL_INCR,
3745 & __kmp_malloc_pool_incr,
3751 __kmp_stg_print_malloc_pool_incr( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3752 __kmp_stg_print_size( buffer, name, __kmp_malloc_pool_incr );
3764 __kmp_stg_parse_par_range_env(
char const * name,
char const * value,
void * data ) {
3765 __kmp_stg_parse_par_range(
3769 __kmp_par_range_routine,
3770 __kmp_par_range_filename,
3771 & __kmp_par_range_lb,
3772 & __kmp_par_range_ub
3777 __kmp_stg_print_par_range_env( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3778 if (__kmp_par_range != 0) {
3779 __kmp_stg_print_str( buffer, name, par_range_to_print );
3788 __kmp_stg_parse_yield_cycle(
char const * name,
char const * value,
void * data ) {
3789 int flag = __kmp_yield_cycle;
3790 __kmp_stg_parse_bool( name, value, & flag );
3791 __kmp_yield_cycle = flag;
3795 __kmp_stg_print_yield_cycle( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3796 __kmp_stg_print_bool( buffer, name, __kmp_yield_cycle );
3800 __kmp_stg_parse_yield_on(
char const * name,
char const * value,
void * data ) {
3801 __kmp_stg_parse_int( name, value, 2, INT_MAX, & __kmp_yield_on_count );
3805 __kmp_stg_print_yield_on( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3806 __kmp_stg_print_int( buffer, name, __kmp_yield_on_count );
3810 __kmp_stg_parse_yield_off(
char const * name,
char const * value,
void * data ) {
3811 __kmp_stg_parse_int( name, value, 2, INT_MAX, & __kmp_yield_off_count );
3815 __kmp_stg_print_yield_off( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3816 __kmp_stg_print_int( buffer, name, __kmp_yield_off_count );
3826 __kmp_stg_parse_init_wait(
char const * name,
char const * value,
void * data ) {
3828 KMP_ASSERT( ( __kmp_init_wait & 1 ) == 0 );
3829 wait = __kmp_init_wait / 2;
3830 __kmp_stg_parse_int( name, value, KMP_MIN_INIT_WAIT, KMP_MAX_INIT_WAIT, & wait );
3831 __kmp_init_wait = wait * 2;
3832 KMP_ASSERT( ( __kmp_init_wait & 1 ) == 0 );
3833 __kmp_yield_init = __kmp_init_wait;
3837 __kmp_stg_print_init_wait( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3838 __kmp_stg_print_int( buffer, name, __kmp_init_wait );
3842 __kmp_stg_parse_next_wait(
char const * name,
char const * value,
void * data ) {
3844 KMP_ASSERT( ( __kmp_next_wait & 1 ) == 0 );
3845 wait = __kmp_next_wait / 2;
3846 __kmp_stg_parse_int( name, value, KMP_MIN_NEXT_WAIT, KMP_MAX_NEXT_WAIT, & wait );
3847 __kmp_next_wait = wait * 2;
3848 KMP_ASSERT( ( __kmp_next_wait & 1 ) == 0 );
3849 __kmp_yield_next = __kmp_next_wait;
3853 __kmp_stg_print_next_wait( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3854 __kmp_stg_print_int( buffer, name, __kmp_next_wait );
3863 __kmp_stg_parse_gtid_mode(
char const * name,
char const * value,
void * data ) {
3874 #ifdef KMP_TDATA_GTID 3877 __kmp_stg_parse_int( name, value, 0, max, & mode );
3881 __kmp_adjust_gtid_mode = TRUE;
3884 __kmp_gtid_mode = mode;
3885 __kmp_adjust_gtid_mode = FALSE;
3890 __kmp_stg_print_gtid_mode( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3891 if ( __kmp_adjust_gtid_mode ) {
3892 __kmp_stg_print_int( buffer, name, 0 );
3895 __kmp_stg_print_int( buffer, name, __kmp_gtid_mode );
3904 __kmp_stg_parse_lock_block(
char const * name,
char const * value,
void * data ) {
3905 __kmp_stg_parse_int( name, value, 0, KMP_INT_MAX, & __kmp_num_locks_in_block );
3909 __kmp_stg_print_lock_block( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
3910 __kmp_stg_print_int( buffer, name, __kmp_num_locks_in_block );
3917 #if KMP_USE_DYNAMIC_LOCK 3918 # define KMP_STORE_LOCK_SEQ(a) (__kmp_user_lock_seq = lockseq_##a) 3920 # define KMP_STORE_LOCK_SEQ(a) 3924 __kmp_stg_parse_lock_kind(
char const * name,
char const * value,
void * data ) {
3925 if ( __kmp_init_user_locks ) {
3926 KMP_WARNING( EnvLockWarn, name );
3930 if ( __kmp_str_match(
"tas", 2, value )
3931 || __kmp_str_match(
"test and set", 2, value )
3932 || __kmp_str_match(
"test_and_set", 2, value )
3933 || __kmp_str_match(
"test-and-set", 2, value )
3934 || __kmp_str_match(
"test andset", 2, value )
3935 || __kmp_str_match(
"test_andset", 2, value )
3936 || __kmp_str_match(
"test-andset", 2, value )
3937 || __kmp_str_match(
"testand set", 2, value )
3938 || __kmp_str_match(
"testand_set", 2, value )
3939 || __kmp_str_match(
"testand-set", 2, value )
3940 || __kmp_str_match(
"testandset", 2, value ) ) {
3941 __kmp_user_lock_kind = lk_tas;
3942 KMP_STORE_LOCK_SEQ(tas);
3945 else if ( __kmp_str_match(
"futex", 1, value ) ) {
3946 if ( __kmp_futex_determine_capable() ) {
3947 __kmp_user_lock_kind = lk_futex;
3948 KMP_STORE_LOCK_SEQ(futex);
3951 KMP_WARNING( FutexNotSupported, name, value );
3955 else if ( __kmp_str_match(
"ticket", 2, value ) ) {
3956 __kmp_user_lock_kind = lk_ticket;
3957 KMP_STORE_LOCK_SEQ(ticket);
3959 else if ( __kmp_str_match(
"queuing", 1, value )
3960 || __kmp_str_match(
"queue", 1, value ) ) {
3961 __kmp_user_lock_kind = lk_queuing;
3962 KMP_STORE_LOCK_SEQ(queuing);
3964 else if ( __kmp_str_match(
"drdpa ticket", 1, value )
3965 || __kmp_str_match(
"drdpa_ticket", 1, value )
3966 || __kmp_str_match(
"drdpa-ticket", 1, value )
3967 || __kmp_str_match(
"drdpaticket", 1, value )
3968 || __kmp_str_match(
"drdpa", 1, value ) ) {
3969 __kmp_user_lock_kind = lk_drdpa;
3970 KMP_STORE_LOCK_SEQ(drdpa);
3972 #if KMP_USE_ADAPTIVE_LOCKS 3973 else if ( __kmp_str_match(
"adaptive", 1, value ) ) {
3974 if( __kmp_cpuinfo.rtm ) {
3975 __kmp_user_lock_kind = lk_adaptive;
3976 KMP_STORE_LOCK_SEQ(adaptive);
3978 KMP_WARNING( AdaptiveNotSupported, name, value );
3979 __kmp_user_lock_kind = lk_queuing;
3980 KMP_STORE_LOCK_SEQ(queuing);
3983 #endif // KMP_USE_ADAPTIVE_LOCKS 3984 #if KMP_USE_DYNAMIC_LOCK && KMP_USE_TSX 3985 else if ( __kmp_str_match(
"rtm", 1, value) ) {
3986 if ( __kmp_cpuinfo.rtm ) {
3987 __kmp_user_lock_kind = lk_rtm;
3988 KMP_STORE_LOCK_SEQ(rtm);
3990 KMP_WARNING( AdaptiveNotSupported, name, value );
3991 __kmp_user_lock_kind = lk_queuing;
3992 KMP_STORE_LOCK_SEQ(queuing);
3995 else if ( __kmp_str_match(
"hle", 1, value) ) {
3996 __kmp_user_lock_kind = lk_hle;
3997 KMP_STORE_LOCK_SEQ(hle);
4001 KMP_WARNING( StgInvalidValue, name, value );
4006 __kmp_stg_print_lock_kind( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
4007 const char *value = NULL;
4009 switch ( __kmp_user_lock_kind ) {
4024 #if KMP_USE_DYNAMIC_LOCK && KMP_USE_TSX 4045 #if KMP_USE_ADAPTIVE_LOCKS 4052 if ( value != NULL ) {
4053 __kmp_stg_print_str( buffer, name, value );
4063 __kmp_stg_parse_spin_backoff_params(
const char* name,
const char* value,
void* data)
4065 const char *next = value;
4068 int prev_comma = FALSE;
4071 kmp_uint32 max_backoff = __kmp_spin_backoff_params.max_backoff;
4072 kmp_uint32 min_tick = __kmp_spin_backoff_params.min_tick;
4075 for ( i = 0; i < 3 ; i++) {
4078 if ( *next ==
'\0' ) {
4082 if ( ( ( *next < '0' || *next >
'9' ) && *next !=
',' ) || total > 2 ) {
4083 KMP_WARNING( EnvSyntaxError, name, value );
4087 if ( *next ==
',' ) {
4089 if ( total == 0 || prev_comma ) {
4097 if ( *next >=
'0' && *next <=
'9' ) {
4099 const char *buf = next;
4100 char const * msg = NULL;
4102 SKIP_DIGITS( next );
4105 const char *tmp = next;
4107 if ( ( *next ==
' ' || *next ==
'\t' ) && ( *tmp >=
'0' && *tmp <=
'9' ) ) {
4108 KMP_WARNING( EnvSpacesNotAllowed, name, value );
4112 num = __kmp_str_to_int( buf, *next );
4114 msg = KMP_I18N_STR( ValueTooSmall );
4116 }
else if ( num > KMP_INT_MAX ) {
4117 msg = KMP_I18N_STR( ValueTooLarge );
4120 if ( msg != NULL ) {
4122 KMP_WARNING( ParseSizeIntWarn, name, value, msg );
4123 KMP_INFORM( Using_int_Value, name, num );
4127 }
else if( total == 2 ) {
4132 KMP_DEBUG_ASSERT( total > 0 );
4134 KMP_WARNING( EnvSyntaxError, name, value );
4137 __kmp_spin_backoff_params.max_backoff = max_backoff;
4138 __kmp_spin_backoff_params.min_tick = min_tick;
4142 __kmp_stg_print_spin_backoff_params(kmp_str_buf_t *buffer,
char const* name,
void* data)
4144 if( __kmp_env_format ) {
4145 KMP_STR_BUF_PRINT_NAME_EX(name);
4147 __kmp_str_buf_print( buffer,
" %s='", name );
4149 __kmp_str_buf_print( buffer,
"%d,%d'\n", __kmp_spin_backoff_params.max_backoff,
4150 __kmp_spin_backoff_params.min_tick );
4153 #if KMP_USE_ADAPTIVE_LOCKS 4162 __kmp_stg_parse_adaptive_lock_props(
const char *name,
const char *value,
void *data )
4164 int max_retries = 0;
4165 int max_badness = 0;
4167 const char *next = value;
4170 int prev_comma = FALSE;
4175 for ( i = 0; i < 3 ; i++) {
4178 if ( *next ==
'\0' ) {
4182 if ( ( ( *next < '0' || *next >
'9' ) && *next !=
',' ) || total > 2 ) {
4183 KMP_WARNING( EnvSyntaxError, name, value );
4187 if ( *next ==
',' ) {
4189 if ( total == 0 || prev_comma ) {
4197 if ( *next >=
'0' && *next <=
'9' ) {
4199 const char *buf = next;
4200 char const * msg = NULL;
4202 SKIP_DIGITS( next );
4205 const char *tmp = next;
4207 if ( ( *next ==
' ' || *next ==
'\t' ) && ( *tmp >=
'0' && *tmp <=
'9' ) ) {
4208 KMP_WARNING( EnvSpacesNotAllowed, name, value );
4212 num = __kmp_str_to_int( buf, *next );
4214 msg = KMP_I18N_STR( ValueTooSmall );
4216 }
else if ( num > KMP_INT_MAX ) {
4217 msg = KMP_I18N_STR( ValueTooLarge );
4220 if ( msg != NULL ) {
4222 KMP_WARNING( ParseSizeIntWarn, name, value, msg );
4223 KMP_INFORM( Using_int_Value, name, num );
4227 }
else if( total == 2 ) {
4232 KMP_DEBUG_ASSERT( total > 0 );
4234 KMP_WARNING( EnvSyntaxError, name, value );
4237 __kmp_adaptive_backoff_params.max_soft_retries = max_retries;
4238 __kmp_adaptive_backoff_params.max_badness = max_badness;
4243 __kmp_stg_print_adaptive_lock_props(kmp_str_buf_t * buffer,
char const * name,
void * data )
4245 if( __kmp_env_format ) {
4246 KMP_STR_BUF_PRINT_NAME_EX(name);
4248 __kmp_str_buf_print( buffer,
" %s='", name );
4250 __kmp_str_buf_print( buffer,
"%d,%d'\n", __kmp_adaptive_backoff_params.max_soft_retries,
4251 __kmp_adaptive_backoff_params.max_badness );
4254 #if KMP_DEBUG_ADAPTIVE_LOCKS 4257 __kmp_stg_parse_speculative_statsfile(
char const * name,
char const * value,
void * data ) {
4258 __kmp_stg_parse_file( name, value,
"", & __kmp_speculative_statsfile );
4262 __kmp_stg_print_speculative_statsfile( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
4263 if ( __kmp_str_match(
"-", 0, __kmp_speculative_statsfile ) ) {
4264 __kmp_stg_print_str( buffer, name,
"stdout" );
4266 __kmp_stg_print_str( buffer, name, __kmp_speculative_statsfile );
4271 #endif // KMP_DEBUG_ADAPTIVE_LOCKS 4273 #endif // KMP_USE_ADAPTIVE_LOCKS 4280 __kmp_stg_parse_hw_subset(
char const * name,
char const * value,
void * data ) {
4289 #define CHECK_DELIM(_x) (*(_x) == ',' || *(_x) == 'x') 4290 static int parsed = 0;
4292 int single_warning = 0;
4293 int flagS = 0, flagC = 0, flagT = 0, flagSO = 0, flagCO = 0;
4294 const char *next = value;
4297 if( strcmp(name,
"KMP_PLACE_THREADS") == 0 ) {
4298 KMP_INFORM(EnvVarDeprecated,name,
"KMP_HW_SUBSET");
4308 if( strcmp(name,
"KMP_PLACE_THREADS") == 0 ) {
4309 KMP_INFORM(EnvVarDeprecated,name,
"KMP_HW_SUBSET");
4320 if (*next >=
'0' && *next <=
'9') {
4323 num = __kmp_str_to_int(prev, *next);
4325 if (*next ==
's' || *next ==
'S') {
4326 __kmp_place_num_sockets = num;
4332 if (!(*next >=
'0' && *next <=
'9')) {
4333 KMP_WARNING(AffHWSubsetInvalid, name, value);
4337 num = __kmp_str_to_int(prev, *next);
4338 __kmp_place_socket_offset = num;
4340 }
else if (*next ==
'c' || *next ==
'C') {
4341 __kmp_place_num_cores = num;
4347 if (!(*next >=
'0' && *next <=
'9')) {
4348 KMP_WARNING(AffHWSubsetInvalid, name, value);
4352 num = __kmp_str_to_int(prev, *next);
4353 __kmp_place_core_offset = num;
4355 }
else if (CHECK_DELIM(next)) {
4356 __kmp_place_num_cores = num;
4359 }
else if (*next ==
't' || *next ==
'T') {
4360 __kmp_place_num_threads_per_core = num;
4363 }
else if (*next ==
'\0') {
4364 __kmp_place_num_cores = num;
4367 KMP_WARNING(AffHWSubsetInvalid, name, value);
4371 KMP_WARNING(AffHWSubsetInvalid, name, value);
4374 KMP_DEBUG_ASSERT(flagS);
4378 if (CHECK_DELIM(next)) {
4384 if (*next >=
'0' && *next <=
'9') {
4387 num = __kmp_str_to_int(prev, *next);
4389 if (*next ==
'c' || *next ==
'C') {
4390 KMP_DEBUG_ASSERT(flagC == 0);
4391 __kmp_place_num_cores = num;
4397 if (!(*next >=
'0' && *next <=
'9')) {
4398 KMP_WARNING(AffHWSubsetInvalid, name, value);
4402 num = __kmp_str_to_int(prev, *next);
4403 __kmp_place_core_offset = num;
4405 }
else if (*next ==
'o' || *next ==
'O') {
4406 KMP_WARNING(AffHWSubsetDeprecated);
4409 KMP_DEBUG_ASSERT(!flagCO);
4410 __kmp_place_core_offset = num;
4412 KMP_DEBUG_ASSERT(!flagSO);
4413 __kmp_place_socket_offset = num;
4416 }
else if (*next ==
't' || *next ==
'T') {
4417 KMP_DEBUG_ASSERT(flagT == 0);
4418 __kmp_place_num_threads_per_core = num;
4422 }
else if (*next ==
'\0') {
4423 KMP_DEBUG_ASSERT(flagC);
4424 __kmp_place_num_threads_per_core = num;
4427 KMP_WARNING(AffHWSubsetInvalid, name, value);
4431 KMP_WARNING(AffHWSubsetInvalid, name, value);
4437 if (CHECK_DELIM(next)) {
4443 if (*next >=
'0' && *next <=
'9') {
4446 num = __kmp_str_to_int(prev, *next);
4448 if (*next ==
't' || *next ==
'T') {
4449 KMP_DEBUG_ASSERT(flagT == 0);
4450 __kmp_place_num_threads_per_core = num;
4455 }
else if (*next ==
'c' || *next ==
'C') {
4456 KMP_DEBUG_ASSERT(flagC == 0);
4457 __kmp_place_num_cores = num;
4461 }
else if (*next ==
'o' || *next ==
'O') {
4462 KMP_WARNING(AffHWSubsetDeprecated);
4464 KMP_DEBUG_ASSERT(flagC);
4466 __kmp_place_core_offset = num;
4469 KMP_WARNING(AffHWSubsetInvalid, name, value);
4473 KMP_WARNING(AffHWSubsetInvalid, name, value);
4476 KMP_DEBUG_ASSERT(flagC);
4478 if ( *next ==
'\0' )
4480 if (CHECK_DELIM(next)) {
4486 if (*next >=
'0' && *next <=
'9') {
4489 num = __kmp_str_to_int(prev, *next);
4491 if (*next ==
'o' || *next ==
'O') {
4492 if (!single_warning) {
4493 KMP_WARNING(AffHWSubsetDeprecated);
4495 KMP_DEBUG_ASSERT(!flagSO);
4496 __kmp_place_core_offset = num;
4498 }
else if (*next ==
't' || *next ==
'T') {
4499 KMP_DEBUG_ASSERT(flagT == 0);
4500 __kmp_place_num_threads_per_core = num;
4504 KMP_WARNING(AffHWSubsetInvalid, name, value);
4508 KMP_WARNING(AffHWSubsetInvalid, name, value);
4512 if ( *next ==
'\0' )
4514 if (CHECK_DELIM(next)) {
4520 if (*next >=
'0' && *next <=
'9') {
4523 num = __kmp_str_to_int(prev, *next);
4525 if (*next ==
'o' || *next ==
'O') {
4526 if (!single_warning) {
4527 KMP_WARNING(AffHWSubsetDeprecated);
4529 KMP_DEBUG_ASSERT(flagT);
4530 KMP_DEBUG_ASSERT(!flagSO);
4531 __kmp_place_core_offset = num;
4532 }
else if (*next ==
't' || *next ==
'T') {
4533 KMP_DEBUG_ASSERT(flagT == 0);
4534 __kmp_place_num_threads_per_core = num;
4536 KMP_WARNING(AffHWSubsetInvalid, name, value);
4539 KMP_WARNING(AffHWSubsetInvalid, name, value);
4546 __kmp_stg_print_hw_subset( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
4547 if (__kmp_place_num_sockets + __kmp_place_num_cores + __kmp_place_num_threads_per_core) {
4550 __kmp_str_buf_init(&buf);
4551 if(__kmp_env_format)
4552 KMP_STR_BUF_PRINT_NAME_EX(name);
4554 __kmp_str_buf_print(buffer,
" %s='", name);
4555 if (__kmp_place_num_sockets) {
4556 __kmp_str_buf_print(&buf,
"%ds", __kmp_place_num_sockets);
4557 if (__kmp_place_socket_offset)
4558 __kmp_str_buf_print(&buf,
"@%d", __kmp_place_socket_offset);
4561 if (__kmp_place_num_cores) {
4562 __kmp_str_buf_print(&buf,
"%s%dc", comma?
",":
"", __kmp_place_num_cores);
4563 if (__kmp_place_core_offset)
4564 __kmp_str_buf_print(&buf,
"@%d", __kmp_place_core_offset);
4567 if (__kmp_place_num_threads_per_core)
4568 __kmp_str_buf_print(&buf,
"%s%dt", comma?
",":
"", __kmp_place_num_threads_per_core);
4569 __kmp_str_buf_print(buffer,
"%s'\n", buf.str );
4570 __kmp_str_buf_free(&buf);
4584 __kmp_stg_parse_forkjoin_frames(
char const * name,
char const * value,
void * data ) {
4585 __kmp_stg_parse_bool( name, value, & __kmp_forkjoin_frames );
4589 __kmp_stg_print_forkjoin_frames( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
4590 __kmp_stg_print_bool( buffer, name, __kmp_forkjoin_frames );
4598 __kmp_stg_parse_forkjoin_frames_mode(
char const * name,
char const * value,
void * data ) {
4599 __kmp_stg_parse_int( name, value, 0, 3, & __kmp_forkjoin_frames_mode );
4603 __kmp_stg_print_forkjoin_frames_mode( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
4604 __kmp_stg_print_int( buffer, name, __kmp_forkjoin_frames_mode );
4615 __kmp_stg_parse_omp_display_env(
char const * name,
char const * value,
void * data )
4617 if ( __kmp_str_match(
"VERBOSE", 1, value ) )
4619 __kmp_display_env_verbose = TRUE;
4621 __kmp_stg_parse_bool( name, value, & __kmp_display_env );
4627 __kmp_stg_print_omp_display_env( kmp_str_buf_t * buffer,
char const * name,
void * data )
4629 if ( __kmp_display_env_verbose )
4631 __kmp_stg_print_str( buffer, name,
"VERBOSE" );
4633 __kmp_stg_print_bool( buffer, name, __kmp_display_env );
4638 __kmp_stg_parse_omp_cancellation(
char const * name,
char const * value,
void * data ) {
4639 if ( TCR_4(__kmp_init_parallel) ) {
4640 KMP_WARNING( EnvParallelWarn, name );
4643 __kmp_stg_parse_bool( name, value, & __kmp_omp_cancellation );
4647 __kmp_stg_print_omp_cancellation( kmp_str_buf_t * buffer,
char const * name,
void * data ) {
4648 __kmp_stg_print_bool( buffer, name, __kmp_omp_cancellation );
4658 static kmp_setting_t __kmp_stg_table[] = {
4660 {
"KMP_ALL_THREADS", __kmp_stg_parse_all_threads, __kmp_stg_print_all_threads, NULL, 0, 0 },
4661 {
"KMP_BLOCKTIME", __kmp_stg_parse_blocktime, __kmp_stg_print_blocktime, NULL, 0, 0 },
4662 {
"KMP_DUPLICATE_LIB_OK", __kmp_stg_parse_duplicate_lib_ok, __kmp_stg_print_duplicate_lib_ok, NULL, 0, 0 },
4663 {
"KMP_LIBRARY", __kmp_stg_parse_wait_policy, __kmp_stg_print_wait_policy, NULL, 0, 0 },
4664 {
"KMP_MAX_THREADS", __kmp_stg_parse_all_threads, NULL, NULL, 0, 0 },
4665 {
"KMP_MONITOR_STACKSIZE", __kmp_stg_parse_monitor_stacksize, __kmp_stg_print_monitor_stacksize, NULL, 0, 0 },
4666 {
"KMP_SETTINGS", __kmp_stg_parse_settings, __kmp_stg_print_settings, NULL, 0, 0 },
4667 {
"KMP_STACKOFFSET", __kmp_stg_parse_stackoffset, __kmp_stg_print_stackoffset, NULL, 0, 0 },
4668 {
"KMP_STACKSIZE", __kmp_stg_parse_stacksize, __kmp_stg_print_stacksize, NULL, 0, 0 },
4669 {
"KMP_STACKPAD", __kmp_stg_parse_stackpad, __kmp_stg_print_stackpad, NULL, 0, 0 },
4670 {
"KMP_VERSION", __kmp_stg_parse_version, __kmp_stg_print_version, NULL, 0, 0 },
4671 {
"KMP_WARNINGS", __kmp_stg_parse_warnings, __kmp_stg_print_warnings, NULL, 0, 0 },
4673 {
"OMP_NESTED", __kmp_stg_parse_nested, __kmp_stg_print_nested, NULL, 0, 0 },
4674 {
"OMP_NUM_THREADS", __kmp_stg_parse_num_threads, __kmp_stg_print_num_threads, NULL, 0, 0 },
4675 {
"OMP_STACKSIZE", __kmp_stg_parse_stacksize, __kmp_stg_print_stacksize, NULL, 0, 0 },
4677 {
"KMP_TASKING", __kmp_stg_parse_tasking, __kmp_stg_print_tasking, NULL, 0, 0 },
4678 {
"KMP_TASK_STEALING_CONSTRAINT", __kmp_stg_parse_task_stealing, __kmp_stg_print_task_stealing, NULL, 0, 0 },
4679 {
"OMP_MAX_ACTIVE_LEVELS", __kmp_stg_parse_max_active_levels, __kmp_stg_print_max_active_levels, NULL, 0, 0 },
4681 {
"OMP_MAX_TASK_PRIORITY", __kmp_stg_parse_max_task_priority, __kmp_stg_print_max_task_priority, NULL, 0, 0 },
4683 {
"OMP_THREAD_LIMIT", __kmp_stg_parse_all_threads, __kmp_stg_print_all_threads, NULL, 0, 0 },
4684 {
"OMP_WAIT_POLICY", __kmp_stg_parse_wait_policy, __kmp_stg_print_wait_policy, NULL, 0, 0 },
4685 {
"KMP_DISP_NUM_BUFFERS", __kmp_stg_parse_disp_buffers, __kmp_stg_print_disp_buffers, NULL, 0, 0 },
4686 #if KMP_NESTED_HOT_TEAMS 4687 {
"KMP_HOT_TEAMS_MAX_LEVEL", __kmp_stg_parse_hot_teams_level, __kmp_stg_print_hot_teams_level, NULL, 0, 0 },
4688 {
"KMP_HOT_TEAMS_MODE", __kmp_stg_parse_hot_teams_mode, __kmp_stg_print_hot_teams_mode, NULL, 0, 0 },
4689 #endif // KMP_NESTED_HOT_TEAMS 4691 #if KMP_HANDLE_SIGNALS 4692 {
"KMP_HANDLE_SIGNALS", __kmp_stg_parse_handle_signals, __kmp_stg_print_handle_signals, NULL, 0, 0 },
4695 #if KMP_ARCH_X86 || KMP_ARCH_X86_64 4696 {
"KMP_INHERIT_FP_CONTROL", __kmp_stg_parse_inherit_fp_control, __kmp_stg_print_inherit_fp_control, NULL, 0, 0 },
4699 #ifdef KMP_GOMP_COMPAT 4700 {
"GOMP_STACKSIZE", __kmp_stg_parse_stacksize, NULL, NULL, 0, 0 },
4704 {
"KMP_A_DEBUG", __kmp_stg_parse_a_debug, __kmp_stg_print_a_debug, NULL, 0, 0 },
4705 {
"KMP_B_DEBUG", __kmp_stg_parse_b_debug, __kmp_stg_print_b_debug, NULL, 0, 0 },
4706 {
"KMP_C_DEBUG", __kmp_stg_parse_c_debug, __kmp_stg_print_c_debug, NULL, 0, 0 },
4707 {
"KMP_D_DEBUG", __kmp_stg_parse_d_debug, __kmp_stg_print_d_debug, NULL, 0, 0 },
4708 {
"KMP_E_DEBUG", __kmp_stg_parse_e_debug, __kmp_stg_print_e_debug, NULL, 0, 0 },
4709 {
"KMP_F_DEBUG", __kmp_stg_parse_f_debug, __kmp_stg_print_f_debug, NULL, 0, 0 },
4710 {
"KMP_DEBUG", __kmp_stg_parse_debug, NULL, NULL, 0, 0 },
4711 {
"KMP_DEBUG_BUF", __kmp_stg_parse_debug_buf, __kmp_stg_print_debug_buf, NULL, 0, 0 },
4712 {
"KMP_DEBUG_BUF_ATOMIC", __kmp_stg_parse_debug_buf_atomic, __kmp_stg_print_debug_buf_atomic, NULL, 0, 0 },
4713 {
"KMP_DEBUG_BUF_CHARS", __kmp_stg_parse_debug_buf_chars, __kmp_stg_print_debug_buf_chars, NULL, 0, 0 },
4714 {
"KMP_DEBUG_BUF_LINES", __kmp_stg_parse_debug_buf_lines, __kmp_stg_print_debug_buf_lines, NULL, 0, 0 },
4715 {
"KMP_DIAG", __kmp_stg_parse_diag, __kmp_stg_print_diag, NULL, 0, 0 },
4717 {
"KMP_PAR_RANGE", __kmp_stg_parse_par_range_env, __kmp_stg_print_par_range_env, NULL, 0, 0 },
4718 {
"KMP_YIELD_CYCLE", __kmp_stg_parse_yield_cycle, __kmp_stg_print_yield_cycle, NULL, 0, 0 },
4719 {
"KMP_YIELD_ON", __kmp_stg_parse_yield_on, __kmp_stg_print_yield_on, NULL, 0, 0 },
4720 {
"KMP_YIELD_OFF", __kmp_stg_parse_yield_off, __kmp_stg_print_yield_off, NULL, 0, 0 },
4723 {
"KMP_ALIGN_ALLOC", __kmp_stg_parse_align_alloc, __kmp_stg_print_align_alloc, NULL, 0, 0 },
4725 {
"KMP_PLAIN_BARRIER", __kmp_stg_parse_barrier_branch_bit, __kmp_stg_print_barrier_branch_bit, NULL, 0, 0 },
4726 {
"KMP_PLAIN_BARRIER_PATTERN", __kmp_stg_parse_barrier_pattern, __kmp_stg_print_barrier_pattern, NULL, 0, 0 },
4727 {
"KMP_FORKJOIN_BARRIER", __kmp_stg_parse_barrier_branch_bit, __kmp_stg_print_barrier_branch_bit, NULL, 0, 0 },
4728 {
"KMP_FORKJOIN_BARRIER_PATTERN", __kmp_stg_parse_barrier_pattern, __kmp_stg_print_barrier_pattern, NULL, 0, 0 },
4729 #if KMP_FAST_REDUCTION_BARRIER 4730 {
"KMP_REDUCTION_BARRIER", __kmp_stg_parse_barrier_branch_bit, __kmp_stg_print_barrier_branch_bit, NULL, 0, 0 },
4731 {
"KMP_REDUCTION_BARRIER_PATTERN", __kmp_stg_parse_barrier_pattern, __kmp_stg_print_barrier_pattern, NULL, 0, 0 },
4734 {
"KMP_ABORT_DELAY", __kmp_stg_parse_abort_delay, __kmp_stg_print_abort_delay, NULL, 0, 0 },
4735 {
"KMP_CPUINFO_FILE", __kmp_stg_parse_cpuinfo_file, __kmp_stg_print_cpuinfo_file, NULL, 0, 0 },
4736 {
"KMP_FORCE_REDUCTION", __kmp_stg_parse_force_reduction, __kmp_stg_print_force_reduction, NULL, 0, 0 },
4737 {
"KMP_DETERMINISTIC_REDUCTION", __kmp_stg_parse_force_reduction, __kmp_stg_print_force_reduction, NULL, 0, 0 },
4738 {
"KMP_STORAGE_MAP", __kmp_stg_parse_storage_map, __kmp_stg_print_storage_map, NULL, 0, 0 },
4739 {
"KMP_ALL_THREADPRIVATE", __kmp_stg_parse_all_threadprivate, __kmp_stg_print_all_threadprivate, NULL, 0, 0 },
4740 {
"KMP_FOREIGN_THREADS_THREADPRIVATE", __kmp_stg_parse_foreign_threads_threadprivate, __kmp_stg_print_foreign_threads_threadprivate, NULL, 0, 0 },
4742 #if KMP_AFFINITY_SUPPORTED 4743 {
"KMP_AFFINITY", __kmp_stg_parse_affinity, __kmp_stg_print_affinity, NULL, 0, 0 },
4744 # ifdef KMP_GOMP_COMPAT 4745 {
"GOMP_CPU_AFFINITY", __kmp_stg_parse_gomp_cpu_affinity, NULL, NULL, 0, 0 },
4748 {
"OMP_PROC_BIND", __kmp_stg_parse_proc_bind, __kmp_stg_print_proc_bind, NULL, 0, 0 },
4749 {
"OMP_PLACES", __kmp_stg_parse_places, __kmp_stg_print_places, NULL, 0, 0 },
4751 {
"OMP_PROC_BIND", __kmp_stg_parse_proc_bind, NULL, NULL, 0, 0 },
4754 {
"KMP_TOPOLOGY_METHOD", __kmp_stg_parse_topology_method, __kmp_stg_print_topology_method, NULL, 0, 0 },
4763 {
"OMP_PROC_BIND", __kmp_stg_parse_proc_bind, __kmp_stg_print_proc_bind, NULL, 0, 0 },
4766 #endif // KMP_AFFINITY_SUPPORTED 4768 {
"KMP_INIT_AT_FORK", __kmp_stg_parse_init_at_fork, __kmp_stg_print_init_at_fork, NULL, 0, 0 },
4769 {
"KMP_SCHEDULE", __kmp_stg_parse_schedule, __kmp_stg_print_schedule, NULL, 0, 0 },
4770 {
"OMP_SCHEDULE", __kmp_stg_parse_omp_schedule, __kmp_stg_print_omp_schedule, NULL, 0, 0 },
4771 {
"KMP_ATOMIC_MODE", __kmp_stg_parse_atomic_mode, __kmp_stg_print_atomic_mode, NULL, 0, 0 },
4772 {
"KMP_CONSISTENCY_CHECK", __kmp_stg_parse_consistency_check, __kmp_stg_print_consistency_check, NULL, 0, 0 },
4774 #if USE_ITT_BUILD && USE_ITT_NOTIFY 4775 {
"KMP_ITT_PREPARE_DELAY", __kmp_stg_parse_itt_prepare_delay, __kmp_stg_print_itt_prepare_delay, NULL, 0, 0 },
4777 {
"KMP_MALLOC_POOL_INCR", __kmp_stg_parse_malloc_pool_incr, __kmp_stg_print_malloc_pool_incr, NULL, 0, 0 },
4778 {
"KMP_INIT_WAIT", __kmp_stg_parse_init_wait, __kmp_stg_print_init_wait, NULL, 0, 0 },
4779 {
"KMP_NEXT_WAIT", __kmp_stg_parse_next_wait, __kmp_stg_print_next_wait, NULL, 0, 0 },
4780 {
"KMP_GTID_MODE", __kmp_stg_parse_gtid_mode, __kmp_stg_print_gtid_mode, NULL, 0, 0 },
4781 {
"OMP_DYNAMIC", __kmp_stg_parse_omp_dynamic, __kmp_stg_print_omp_dynamic, NULL, 0, 0 },
4782 {
"KMP_DYNAMIC_MODE", __kmp_stg_parse_kmp_dynamic_mode, __kmp_stg_print_kmp_dynamic_mode, NULL, 0, 0 },
4784 #ifdef USE_LOAD_BALANCE 4785 {
"KMP_LOAD_BALANCE_INTERVAL", __kmp_stg_parse_ld_balance_interval,__kmp_stg_print_ld_balance_interval,NULL, 0, 0 },
4788 {
"KMP_NUM_LOCKS_IN_BLOCK", __kmp_stg_parse_lock_block, __kmp_stg_print_lock_block, NULL, 0, 0 },
4789 {
"KMP_LOCK_KIND", __kmp_stg_parse_lock_kind, __kmp_stg_print_lock_kind, NULL, 0, 0 },
4790 {
"KMP_SPIN_BACKOFF_PARAMS", __kmp_stg_parse_spin_backoff_params, __kmp_stg_print_spin_backoff_params, NULL, 0, 0 },
4791 #if KMP_USE_ADAPTIVE_LOCKS 4792 {
"KMP_ADAPTIVE_LOCK_PROPS", __kmp_stg_parse_adaptive_lock_props,__kmp_stg_print_adaptive_lock_props, NULL, 0, 0 },
4793 #if KMP_DEBUG_ADAPTIVE_LOCKS 4794 {
"KMP_SPECULATIVE_STATSFILE", __kmp_stg_parse_speculative_statsfile,__kmp_stg_print_speculative_statsfile, NULL, 0, 0 },
4796 #endif // KMP_USE_ADAPTIVE_LOCKS 4797 {
"KMP_PLACE_THREADS", __kmp_stg_parse_hw_subset, __kmp_stg_print_hw_subset, NULL, 0, 0 },
4798 {
"KMP_HW_SUBSET", __kmp_stg_parse_hw_subset, __kmp_stg_print_hw_subset, NULL, 0, 0 },
4800 {
"KMP_FORKJOIN_FRAMES", __kmp_stg_parse_forkjoin_frames, __kmp_stg_print_forkjoin_frames, NULL, 0, 0 },
4801 {
"KMP_FORKJOIN_FRAMES_MODE", __kmp_stg_parse_forkjoin_frames_mode,__kmp_stg_print_forkjoin_frames_mode, NULL, 0, 0 },
4805 {
"OMP_DISPLAY_ENV", __kmp_stg_parse_omp_display_env, __kmp_stg_print_omp_display_env, NULL, 0, 0 },
4806 {
"OMP_CANCELLATION", __kmp_stg_parse_omp_cancellation, __kmp_stg_print_omp_cancellation, NULL, 0, 0 },
4808 {
"", NULL, NULL, NULL, 0, 0 }
4811 static int const __kmp_stg_count =
sizeof( __kmp_stg_table ) /
sizeof( kmp_setting_t );
4815 __kmp_stg_find(
char const * name ) {
4818 if ( name != NULL ) {
4819 for ( i = 0; i < __kmp_stg_count; ++ i ) {
4820 if ( strcmp( __kmp_stg_table[ i ].name, name ) == 0 ) {
4821 return & __kmp_stg_table[ i ];
4831 __kmp_stg_cmp(
void const * _a,
void const * _b ) {
4832 kmp_setting_t * a = (kmp_setting_t *) _a;
4833 kmp_setting_t * b = (kmp_setting_t *) _b;
4839 if ( strcmp( a->name,
"KMP_AFFINITY" ) == 0 ) {
4840 if ( strcmp( b->name,
"KMP_AFFINITY" ) == 0 ) {
4845 else if ( strcmp( b->name,
"KMP_AFFINITY" ) == 0 ) {
4848 return strcmp( a->name, b->name );
4853 __kmp_stg_init(
void 4856 static int initialized = 0;
4858 if ( ! initialized ) {
4861 qsort( __kmp_stg_table, __kmp_stg_count - 1,
sizeof( kmp_setting_t ), __kmp_stg_cmp );
4865 kmp_setting_t * kmp_stacksize = __kmp_stg_find(
"KMP_STACKSIZE" );
4866 #ifdef KMP_GOMP_COMPAT 4867 kmp_setting_t * gomp_stacksize = __kmp_stg_find(
"GOMP_STACKSIZE" );
4869 kmp_setting_t * omp_stacksize = __kmp_stg_find(
"OMP_STACKSIZE" );
4874 static kmp_setting_t *
volatile rivals[ 4 ];
4875 static kmp_stg_ss_data_t kmp_data = { 1, (kmp_setting_t **)rivals };
4876 #ifdef KMP_GOMP_COMPAT 4877 static kmp_stg_ss_data_t gomp_data = { 1024, (kmp_setting_t **)rivals };
4879 static kmp_stg_ss_data_t omp_data = { 1024, (kmp_setting_t **)rivals };
4882 rivals[ i ++ ] = kmp_stacksize;
4883 #ifdef KMP_GOMP_COMPAT 4884 if ( gomp_stacksize != NULL ) {
4885 rivals[ i ++ ] = gomp_stacksize;
4888 rivals[ i ++ ] = omp_stacksize;
4889 rivals[ i ++ ] = NULL;
4891 kmp_stacksize->data = & kmp_data;
4892 #ifdef KMP_GOMP_COMPAT 4893 if ( gomp_stacksize != NULL ) {
4894 gomp_stacksize->data = & gomp_data;
4897 omp_stacksize->data = & omp_data;
4903 kmp_setting_t * kmp_library = __kmp_stg_find(
"KMP_LIBRARY" );
4904 kmp_setting_t * omp_wait_policy = __kmp_stg_find(
"OMP_WAIT_POLICY" );
4907 static kmp_setting_t *
volatile rivals[ 3 ];
4908 static kmp_stg_wp_data_t kmp_data = { 0, (kmp_setting_t **)rivals };
4909 static kmp_stg_wp_data_t omp_data = { 1, (kmp_setting_t **)rivals };
4912 rivals[ i ++ ] = kmp_library;
4913 if ( omp_wait_policy != NULL ) {
4914 rivals[ i ++ ] = omp_wait_policy;
4916 rivals[ i ++ ] = NULL;
4918 kmp_library->data = & kmp_data;
4919 if ( omp_wait_policy != NULL ) {
4920 omp_wait_policy->data = & omp_data;
4927 kmp_setting_t * kmp_all_threads = __kmp_stg_find(
"KMP_ALL_THREADS" );
4928 kmp_setting_t * kmp_max_threads = __kmp_stg_find(
"KMP_MAX_THREADS" );
4929 kmp_setting_t * omp_thread_limit = __kmp_stg_find(
"OMP_THREAD_LIMIT" );
4932 static kmp_setting_t *
volatile rivals[ 4 ];
4935 rivals[ i ++ ] = kmp_all_threads;
4936 rivals[ i ++ ] = kmp_max_threads;
4937 if ( omp_thread_limit != NULL ) {
4938 rivals[ i ++ ] = omp_thread_limit;
4940 rivals[ i ++ ] = NULL;
4942 kmp_all_threads->data = (
void*)& rivals;
4943 kmp_max_threads->data = (
void*)& rivals;
4944 if ( omp_thread_limit != NULL ) {
4945 omp_thread_limit->data = (
void*)& rivals;
4950 #if KMP_AFFINITY_SUPPORTED 4953 kmp_setting_t * kmp_affinity = __kmp_stg_find(
"KMP_AFFINITY" );
4954 KMP_DEBUG_ASSERT( kmp_affinity != NULL );
4956 # ifdef KMP_GOMP_COMPAT 4957 kmp_setting_t * gomp_cpu_affinity = __kmp_stg_find(
"GOMP_CPU_AFFINITY" );
4958 KMP_DEBUG_ASSERT( gomp_cpu_affinity != NULL );
4961 kmp_setting_t * omp_proc_bind = __kmp_stg_find(
"OMP_PROC_BIND" );
4962 KMP_DEBUG_ASSERT( omp_proc_bind != NULL );
4965 static kmp_setting_t *
volatile rivals[ 4 ];
4968 rivals[ i ++ ] = kmp_affinity;
4970 # ifdef KMP_GOMP_COMPAT 4971 rivals[ i ++ ] = gomp_cpu_affinity;
4972 gomp_cpu_affinity->data = (
void*)& rivals;
4975 rivals[ i ++ ] = omp_proc_bind;
4976 omp_proc_bind->data = (
void*)& rivals;
4977 rivals[ i ++ ] = NULL;
4980 static kmp_setting_t *
volatile places_rivals[ 4 ];
4983 kmp_setting_t * omp_places = __kmp_stg_find(
"OMP_PLACES" );
4984 KMP_DEBUG_ASSERT( omp_places != NULL );
4986 places_rivals[ i ++ ] = kmp_affinity;
4987 # ifdef KMP_GOMP_COMPAT 4988 places_rivals[ i ++ ] = gomp_cpu_affinity;
4990 places_rivals[ i ++ ] = omp_places;
4991 omp_places->data = (
void*)& places_rivals;
4992 places_rivals[ i ++ ] = NULL;
4998 #endif // KMP_AFFINITY_SUPPORTED 5002 kmp_setting_t * kmp_force_red = __kmp_stg_find(
"KMP_FORCE_REDUCTION" );
5003 kmp_setting_t * kmp_determ_red = __kmp_stg_find(
"KMP_DETERMINISTIC_REDUCTION" );
5006 static kmp_setting_t *
volatile rivals[ 3 ];
5007 static kmp_stg_fr_data_t force_data = { 1, (kmp_setting_t **)rivals };
5008 static kmp_stg_fr_data_t determ_data = { 0, (kmp_setting_t **)rivals };
5011 rivals[ i ++ ] = kmp_force_red;
5012 if ( kmp_determ_red != NULL ) {
5013 rivals[ i ++ ] = kmp_determ_red;
5015 rivals[ i ++ ] = NULL;
5017 kmp_force_red->data = & force_data;
5018 if ( kmp_determ_red != NULL ) {
5019 kmp_determ_red->data = & determ_data;
5029 for ( i = 0; i < __kmp_stg_count; ++ i ) {
5030 __kmp_stg_table[ i ].set = 0;
5044 if ( name[ 0 ] == 0 ) {
5048 if ( value != NULL ) {
5049 kmp_setting_t * setting = __kmp_stg_find( name );
5050 if ( setting != NULL ) {
5051 setting->parse( name, value, setting->data );
5052 setting->defined = 1;
5060 __kmp_stg_check_rivals(
5063 kmp_setting_t * * rivals
5066 if ( rivals == NULL ) {
5072 for ( ; strcmp( rivals[ i ]->name, name ) != 0; i++ ) {
5073 KMP_DEBUG_ASSERT( rivals[ i ] != NULL );
5075 #if KMP_AFFINITY_SUPPORTED 5076 if ( rivals[ i ] == __kmp_affinity_notype ) {
5085 if ( rivals[ i ]->
set ) {
5086 KMP_WARNING( StgIgnored, name, rivals[ i ]->name );
5098 __kmp_env_toPrint(
char const * name,
int flag ) {
5100 kmp_setting_t * setting = __kmp_stg_find( name );
5101 if ( setting != NULL ) {
5102 rc = setting->defined;
5104 setting->defined = flag;
5112 __kmp_aux_env_initialize( kmp_env_blk_t* block ) {
5117 value = __kmp_env_blk_var( block,
"OMP_NUM_THREADS" );
5119 ompc_set_num_threads( __kmp_dflt_team_nth );
5123 value = __kmp_env_blk_var( block,
"KMP_BLOCKTIME" );
5125 kmpc_set_blocktime( __kmp_dflt_blocktime );
5129 value = __kmp_env_blk_var( block,
"OMP_NESTED" );
5131 ompc_set_nested( __kmp_dflt_nested );
5135 value = __kmp_env_blk_var( block,
"OMP_DYNAMIC" );
5137 ompc_set_dynamic( __kmp_global.g.g_dynamic );
5143 __kmp_env_initialize(
char const *
string ) {
5145 kmp_env_blk_t block;
5151 if (
string == NULL ) {
5153 __kmp_threads_capacity = __kmp_initial_threads_capacity( __kmp_dflt_team_nth_ub );
5155 __kmp_env_blk_init( & block,
string );
5160 for ( i = 0; i < block.count; ++ i ) {
5161 if (( block.vars[ i ].name == NULL )
5162 || ( *block.vars[ i ].name ==
'\0')) {
5165 if ( block.vars[ i ].value == NULL ) {
5168 kmp_setting_t * setting = __kmp_stg_find( block.vars[ i ].name );
5169 if ( setting != NULL ) {
5175 blocktime_str = __kmp_env_blk_var( & block,
"KMP_BLOCKTIME" );
5178 if (
string == NULL ) {
5179 char const * name =
"KMP_WARNINGS";
5180 char const * value = __kmp_env_blk_var( & block, name );
5181 __kmp_stg_parse( name, value );
5184 #if KMP_AFFINITY_SUPPORTED 5192 __kmp_affinity_notype = NULL;
5193 char const *aff_str = __kmp_env_blk_var( & block,
"KMP_AFFINITY" );
5194 if ( aff_str != NULL ) {
5208 # define FIND strstr 5210 # define FIND strcasestr 5213 if ( ( FIND( aff_str,
"none" ) == NULL )
5214 && ( FIND( aff_str,
"physical" ) == NULL )
5215 && ( FIND( aff_str,
"logical" ) == NULL )
5216 && ( FIND( aff_str,
"compact" ) == NULL )
5217 && ( FIND( aff_str,
"scatter" ) == NULL )
5218 && ( FIND( aff_str,
"explicit" ) == NULL )
5219 && ( FIND( aff_str,
"balanced" ) == NULL )
5220 && ( FIND( aff_str,
"disabled" ) == NULL ) ) {
5221 __kmp_affinity_notype = __kmp_stg_find(
"KMP_AFFINITY" );
5229 __kmp_affinity_type = affinity_default;
5230 __kmp_affinity_gran = affinity_gran_default;
5231 __kmp_affinity_top_method = affinity_top_method_default;
5232 __kmp_affinity_respect_mask = affinity_respect_mask_default;
5240 aff_str = __kmp_env_blk_var( & block,
"OMP_PROC_BIND" );
5241 if ( aff_str != NULL ) {
5242 __kmp_affinity_type = affinity_default;
5243 __kmp_affinity_gran = affinity_gran_default;
5244 __kmp_affinity_top_method = affinity_top_method_default;
5245 __kmp_affinity_respect_mask = affinity_respect_mask_default;
5256 if ( __kmp_nested_proc_bind.bind_types == NULL ) {
5257 __kmp_nested_proc_bind.bind_types = (kmp_proc_bind_t *)
5258 KMP_INTERNAL_MALLOC(
sizeof(kmp_proc_bind_t) );
5259 if ( __kmp_nested_proc_bind.bind_types == NULL ) {
5260 KMP_FATAL( MemoryAllocFailed );
5262 __kmp_nested_proc_bind.size = 1;
5263 __kmp_nested_proc_bind.used = 1;
5264 # if KMP_AFFINITY_SUPPORTED 5265 __kmp_nested_proc_bind.bind_types[0] = proc_bind_default;
5268 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
5277 for ( i = 0; i < block.count; ++ i ) {
5278 __kmp_stg_parse( block.vars[ i ].name, block.vars[ i ].value );
5284 if ( ! __kmp_init_user_locks ) {
5285 if ( __kmp_user_lock_kind == lk_default ) {
5286 __kmp_user_lock_kind = lk_queuing;
5288 #if KMP_USE_DYNAMIC_LOCK 5289 __kmp_init_dynamic_user_locks();
5291 __kmp_set_user_lock_vptrs( __kmp_user_lock_kind );
5295 KMP_DEBUG_ASSERT(
string != NULL);
5296 KMP_DEBUG_ASSERT( __kmp_user_lock_kind != lk_default );
5301 #if KMP_USE_DYNAMIC_LOCK 5302 __kmp_init_dynamic_user_locks();
5304 __kmp_set_user_lock_vptrs( __kmp_user_lock_kind );
5308 #if KMP_AFFINITY_SUPPORTED 5310 if ( ! TCR_4(__kmp_init_middle) ) {
5315 const char *var =
"KMP_AFFINITY";
5317 if(__kmp_hwloc_topology == NULL) {
5318 if(hwloc_topology_init(&__kmp_hwloc_topology) < 0) {
5319 __kmp_hwloc_error = TRUE;
5320 if(__kmp_affinity_verbose)
5321 KMP_WARNING(AffHwlocErrorOccurred, var,
"hwloc_topology_init()");
5323 if(hwloc_topology_load(__kmp_hwloc_topology) < 0) {
5324 __kmp_hwloc_error = TRUE;
5325 if(__kmp_affinity_verbose)
5326 KMP_WARNING(AffHwlocErrorOccurred, var,
"hwloc_topology_load()");
5330 if ( __kmp_affinity_type == affinity_disabled ) {
5331 KMP_AFFINITY_DISABLE();
5333 else if ( ! KMP_AFFINITY_CAPABLE() ) {
5335 const hwloc_topology_support* topology_support = hwloc_topology_get_support(__kmp_hwloc_topology);
5339 if(topology_support && topology_support->cpubind->set_thisthread_cpubind &&
5340 topology_support->cpubind->get_thisthread_cpubind &&
5341 topology_support->discovery->pu &&
5345 KMP_AFFINITY_ENABLE(TRUE);
5348 __kmp_hwloc_error = TRUE;
5349 KMP_AFFINITY_DISABLE();
5352 __kmp_affinity_determine_capable( var );
5353 # endif // KMP_USE_HWLOC 5354 if ( ! KMP_AFFINITY_CAPABLE() ) {
5355 if ( __kmp_affinity_verbose || ( __kmp_affinity_warnings
5356 && ( __kmp_affinity_type != affinity_default )
5357 && ( __kmp_affinity_type != affinity_none )
5358 && ( __kmp_affinity_type != affinity_disabled ) ) ) {
5359 KMP_WARNING( AffNotSupported, var );
5361 __kmp_affinity_type = affinity_disabled;
5362 __kmp_affinity_respect_mask = 0;
5363 __kmp_affinity_gran = affinity_gran_fine;
5368 if ( __kmp_affinity_type == affinity_disabled ) {
5369 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
5371 else if ( __kmp_nested_proc_bind.bind_types[0] == proc_bind_true ) {
5375 __kmp_nested_proc_bind.bind_types[0] = proc_bind_spread;
5379 if ( KMP_AFFINITY_CAPABLE() ) {
5381 # if KMP_GROUP_AFFINITY 5388 if ( ( ( __kmp_num_proc_groups > 1 )
5389 && ( __kmp_affinity_type == affinity_default )
5391 && ( __kmp_nested_proc_bind.bind_types[0] == proc_bind_default ) )
5393 || ( __kmp_affinity_top_method == affinity_top_method_group ) ) {
5394 if ( __kmp_affinity_respect_mask == affinity_respect_mask_default ) {
5395 __kmp_affinity_respect_mask = FALSE;
5397 if ( __kmp_affinity_type == affinity_default ) {
5398 __kmp_affinity_type = affinity_compact;
5400 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
5403 if ( __kmp_affinity_top_method == affinity_top_method_default ) {
5404 if ( __kmp_affinity_gran == affinity_gran_default ) {
5405 __kmp_affinity_top_method = affinity_top_method_group;
5406 __kmp_affinity_gran = affinity_gran_group;
5408 else if ( __kmp_affinity_gran == affinity_gran_group ) {
5409 __kmp_affinity_top_method = affinity_top_method_group;
5412 __kmp_affinity_top_method = affinity_top_method_all;
5415 else if ( __kmp_affinity_top_method == affinity_top_method_group ) {
5416 if ( __kmp_affinity_gran == affinity_gran_default ) {
5417 __kmp_affinity_gran = affinity_gran_group;
5419 else if ( ( __kmp_affinity_gran != affinity_gran_group )
5420 && ( __kmp_affinity_gran != affinity_gran_fine )
5421 && ( __kmp_affinity_gran != affinity_gran_thread ) ) {
5422 const char *str = NULL;
5423 switch ( __kmp_affinity_gran ) {
5424 case affinity_gran_core: str =
"core";
break;
5425 case affinity_gran_package: str =
"package";
break;
5426 case affinity_gran_node: str =
"node";
break;
5427 default: KMP_DEBUG_ASSERT( 0 );
5429 KMP_WARNING( AffGranTopGroup, var, str );
5430 __kmp_affinity_gran = affinity_gran_fine;
5434 if ( __kmp_affinity_gran == affinity_gran_default ) {
5435 __kmp_affinity_gran = affinity_gran_core;
5437 else if ( __kmp_affinity_gran == affinity_gran_group ) {
5438 const char *str = NULL;
5439 switch ( __kmp_affinity_type ) {
5440 case affinity_physical: str =
"physical";
break;
5441 case affinity_logical: str =
"logical";
break;
5442 case affinity_compact: str =
"compact";
break;
5443 case affinity_scatter: str =
"scatter";
break;
5444 case affinity_explicit: str =
"explicit";
break;
5446 default: KMP_DEBUG_ASSERT( 0 );
5448 KMP_WARNING( AffGranGroupType, var, str );
5449 __kmp_affinity_gran = affinity_gran_core;
5458 if ( __kmp_affinity_respect_mask == affinity_respect_mask_default ) {
5459 # if KMP_GROUP_AFFINITY 5460 if ( __kmp_num_proc_groups > 1 ) {
5461 __kmp_affinity_respect_mask = FALSE;
5466 __kmp_affinity_respect_mask = TRUE;
5470 if ( ( __kmp_nested_proc_bind.bind_types[0] != proc_bind_intel )
5471 && ( __kmp_nested_proc_bind.bind_types[0] != proc_bind_default ) ) {
5472 if ( __kmp_affinity_type == affinity_default ) {
5473 __kmp_affinity_type = affinity_compact;
5474 __kmp_affinity_dups = FALSE;
5479 if ( __kmp_affinity_type == affinity_default ) {
5481 #if KMP_ARCH_X86_64 && (KMP_OS_LINUX || KMP_OS_WINDOWS) 5482 if( __kmp_mic_type != non_mic ) {
5483 __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
5487 __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
5490 #if KMP_ARCH_X86_64 && (KMP_OS_LINUX || KMP_OS_WINDOWS) 5491 if( __kmp_mic_type != non_mic ) {
5492 __kmp_affinity_type = affinity_scatter;
5496 __kmp_affinity_type = affinity_none;
5500 if ( ( __kmp_affinity_gran == affinity_gran_default )
5501 && ( __kmp_affinity_gran_levels < 0 ) ) {
5502 #if KMP_ARCH_X86_64 && (KMP_OS_LINUX || KMP_OS_WINDOWS) 5503 if( __kmp_mic_type != non_mic ) {
5504 __kmp_affinity_gran = affinity_gran_fine;
5508 __kmp_affinity_gran = affinity_gran_core;
5511 if ( __kmp_affinity_top_method == affinity_top_method_default ) {
5512 __kmp_affinity_top_method = affinity_top_method_all;
5517 K_DIAG( 1, (
"__kmp_affinity_type == %d\n", __kmp_affinity_type ) );
5518 K_DIAG( 1, (
"__kmp_affinity_compact == %d\n", __kmp_affinity_compact ) );
5519 K_DIAG( 1, (
"__kmp_affinity_offset == %d\n", __kmp_affinity_offset ) );
5520 K_DIAG( 1, (
"__kmp_affinity_verbose == %d\n", __kmp_affinity_verbose ) );
5521 K_DIAG( 1, (
"__kmp_affinity_warnings == %d\n", __kmp_affinity_warnings ) );
5522 K_DIAG( 1, (
"__kmp_affinity_respect_mask == %d\n", __kmp_affinity_respect_mask ) );
5523 K_DIAG( 1, (
"__kmp_affinity_gran == %d\n", __kmp_affinity_gran ) );
5525 KMP_DEBUG_ASSERT( __kmp_affinity_type != affinity_default);
5527 KMP_DEBUG_ASSERT( __kmp_nested_proc_bind.bind_types[0] != proc_bind_default );
5533 if ( __kmp_version ) {
5534 __kmp_print_version_1();
5538 if (
string != NULL) {
5539 __kmp_aux_env_initialize( &block );
5542 __kmp_env_blk_free( & block );
5552 kmp_env_blk_t block;
5554 kmp_str_buf_t buffer;
5557 __kmp_str_buf_init( & buffer );
5559 __kmp_env_blk_init( & block, NULL );
5560 __kmp_env_blk_sort( & block );
5563 __kmp_str_buf_print( & buffer,
"\n%s\n\n", KMP_I18N_STR( UserSettings ) );
5564 for ( i = 0; i < block.count; ++ i ) {
5565 char const * name = block.vars[ i ].name;
5566 char const * value = block.vars[ i ].value;
5568 ( KMP_STRLEN( name ) > 4 && strncmp( name,
"KMP_", 4 ) == 0 )
5569 || strncmp( name,
"OMP_", 4 ) == 0
5570 #ifdef KMP_GOMP_COMPAT
5571 || strncmp( name,
"GOMP_", 5 ) == 0
5574 __kmp_str_buf_print( & buffer,
" %s=%s\n", name, value );
5577 __kmp_str_buf_print( & buffer,
"\n" );
5580 __kmp_str_buf_print( & buffer,
"%s\n\n", KMP_I18N_STR( EffectiveSettings ) );
5581 for (
int i = 0; i < __kmp_stg_count; ++ i ) {
5582 if ( __kmp_stg_table[ i ].print != NULL ) {
5583 __kmp_stg_table[ i ].print( & buffer, __kmp_stg_table[ i ].name, __kmp_stg_table[ i ].data );
5587 __kmp_printf(
"%s", buffer.str );
5589 __kmp_env_blk_free( & block );
5590 __kmp_str_buf_free( & buffer );
5599 __kmp_env_print_2() {
5601 kmp_env_blk_t block;
5602 kmp_str_buf_t buffer;
5604 __kmp_env_format = 1;
5607 __kmp_str_buf_init( & buffer );
5609 __kmp_env_blk_init( & block, NULL );
5610 __kmp_env_blk_sort( & block );
5612 __kmp_str_buf_print( & buffer,
"\n%s\n", KMP_I18N_STR( DisplayEnvBegin ) );
5613 __kmp_str_buf_print( & buffer,
" _OPENMP='%d'\n", __kmp_openmp_version );
5615 for (
int i = 0; i < __kmp_stg_count; ++ i ) {
5616 if ( __kmp_stg_table[ i ].print != NULL &&
5617 ( ( __kmp_display_env && strncmp( __kmp_stg_table[ i ].name,
"OMP_", 4 ) == 0 ) || __kmp_display_env_verbose ) ) {
5618 __kmp_stg_table[ i ].print( & buffer, __kmp_stg_table[ i ].name, __kmp_stg_table[ i ].data );
5622 __kmp_str_buf_print( & buffer,
"%s\n", KMP_I18N_STR( DisplayEnvEnd ) );
5623 __kmp_str_buf_print( & buffer,
"\n" );
5625 __kmp_printf(
"%s", buffer.str );
5627 __kmp_env_blk_free( & block );
5628 __kmp_str_buf_free( & buffer );
5633 #endif // OMP_40_ENABLED