diff options
Diffstat (limited to 'runtime/src/kmp_settings.cpp')
-rw-r--r-- | runtime/src/kmp_settings.cpp | 508 |
1 files changed, 218 insertions, 290 deletions
diff --git a/runtime/src/kmp_settings.cpp b/runtime/src/kmp_settings.cpp index 6d049e4b92320..692ca26d0e424 100644 --- a/runtime/src/kmp_settings.cpp +++ b/runtime/src/kmp_settings.cpp @@ -4,10 +4,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -290,6 +289,20 @@ static void __kmp_stg_parse_bool(char const *name, char const *value, } } // __kmp_stg_parse_bool +// placed here in order to use __kmp_round4k static function +void __kmp_check_stksize(size_t *val) { + // if system stack size is too big then limit the size for worker threads + if (*val > KMP_DEFAULT_STKSIZE * 16) // just a heuristics... + *val = KMP_DEFAULT_STKSIZE * 16; + if (*val < KMP_MIN_STKSIZE) + *val = KMP_MIN_STKSIZE; + if (*val > KMP_MAX_STKSIZE) + *val = KMP_MAX_STKSIZE; // dead code currently, but may work in future +#if KMP_OS_DARWIN + *val = __kmp_round4k(*val); +#endif // KMP_OS_DARWIN +} + static void __kmp_stg_parse_size(char const *name, char const *value, size_t size_min, size_t size_max, int *is_specified, size_t *out, @@ -630,6 +643,19 @@ static void __kmp_stg_print_teams_thread_limit(kmp_str_buf_t *buffer, } // __kmp_stg_print_teams_thread_limit // ----------------------------------------------------------------------------- +// KMP_USE_YIELD +static void __kmp_stg_parse_use_yield(char const *name, char const *value, + void *data) { + __kmp_stg_parse_int(name, value, 0, 2, &__kmp_use_yield); + __kmp_use_yield_exp_set = 1; +} // __kmp_stg_parse_use_yield + +static void __kmp_stg_print_use_yield(kmp_str_buf_t *buffer, char const *name, + void *data) { + __kmp_stg_print_int(buffer, name, __kmp_use_yield); +} // __kmp_stg_print_use_yield + +// ----------------------------------------------------------------------------- // KMP_BLOCKTIME static void __kmp_stg_parse_blocktime(char const *name, char const *value, @@ -746,18 +772,24 @@ static void __kmp_stg_parse_wait_policy(char const *name, char const *value, __kmp_library = library_serial; } else if (__kmp_str_match("throughput", 2, value)) { /* TH */ __kmp_library = library_throughput; + if (blocktime_str == NULL) { + // KMP_BLOCKTIME not specified, so set default to 0. + __kmp_dflt_blocktime = 0; + } } else if (__kmp_str_match("turnaround", 2, value)) { /* TU */ __kmp_library = library_turnaround; } else if (__kmp_str_match("dedicated", 1, value)) { /* D */ __kmp_library = library_turnaround; } else if (__kmp_str_match("multiuser", 1, value)) { /* M */ __kmp_library = library_throughput; + if (blocktime_str == NULL) { + // KMP_BLOCKTIME not specified, so set default to 0. + __kmp_dflt_blocktime = 0; + } } else { KMP_WARNING(StgInvalidValue, name, value); } } - __kmp_aux_set_library(__kmp_library); - } // __kmp_stg_parse_wait_policy static void __kmp_stg_print_wait_policy(kmp_str_buf_t *buffer, char const *name, @@ -957,12 +989,27 @@ static void __kmp_stg_print_warnings(kmp_str_buf_t *buffer, char const *name, static void __kmp_stg_parse_nested(char const *name, char const *value, void *data) { - __kmp_stg_parse_bool(name, value, &__kmp_dflt_nested); + int nested; + KMP_INFORM(EnvVarDeprecated, name, "OMP_MAX_ACTIVE_LEVELS"); + __kmp_stg_parse_bool(name, value, &nested); + if (nested) { + if (!__kmp_dflt_max_active_levels_set) + __kmp_dflt_max_active_levels = KMP_MAX_ACTIVE_LEVELS_LIMIT; + } else { // nesting explicitly turned off + __kmp_dflt_max_active_levels = 1; + __kmp_dflt_max_active_levels_set = true; + } } // __kmp_stg_parse_nested static void __kmp_stg_print_nested(kmp_str_buf_t *buffer, char const *name, void *data) { - __kmp_stg_print_bool(buffer, name, __kmp_dflt_nested); + if (__kmp_env_format) { + KMP_STR_BUF_PRINT_NAME; + } else { + __kmp_str_buf_print(buffer, " %s", name); + } + __kmp_str_buf_print(buffer, ": deprecated; max-active-levels-var=%d\n", + __kmp_dflt_max_active_levels); } // __kmp_stg_print_nested static void __kmp_parse_nested_num_threads(const char *var, const char *env, @@ -1008,6 +1055,8 @@ static void __kmp_parse_nested_num_threads(const char *var, const char *env, } } } + if (!__kmp_dflt_max_active_levels_set && total > 1) + __kmp_dflt_max_active_levels = KMP_MAX_ACTIVE_LEVELS_LIMIT; KMP_DEBUG_ASSERT(total > 0); if (total <= 0) { KMP_WARNING(NthSyntaxError, var, env); @@ -1164,8 +1213,22 @@ static void __kmp_stg_print_task_stealing(kmp_str_buf_t *buffer, static void __kmp_stg_parse_max_active_levels(char const *name, char const *value, void *data) { - __kmp_stg_parse_int(name, value, 0, KMP_MAX_ACTIVE_LEVELS_LIMIT, - &__kmp_dflt_max_active_levels); + kmp_uint64 tmp_dflt = 0; + char const *msg = NULL; + if (!__kmp_dflt_max_active_levels_set) { + // Don't overwrite __kmp_dflt_max_active_levels if we get an invalid setting + __kmp_str_to_uint(value, &tmp_dflt, &msg); + if (msg != NULL) { // invalid setting; print warning and ignore + KMP_WARNING(ParseSizeIntWarn, name, value, msg); + } else if (tmp_dflt > KMP_MAX_ACTIVE_LEVELS_LIMIT) { + // invalid setting; print warning and ignore + msg = KMP_I18N_STR(ValueTooLarge); + KMP_WARNING(ParseSizeIntWarn, name, value, msg); + } else { // valid setting + __kmp_dflt_max_active_levels = tmp_dflt; + __kmp_dflt_max_active_levels_set = true; + } + } } // __kmp_stg_parse_max_active_levels static void __kmp_stg_print_max_active_levels(kmp_str_buf_t *buffer, @@ -1173,7 +1236,6 @@ static void __kmp_stg_print_max_active_levels(kmp_str_buf_t *buffer, __kmp_stg_print_int(buffer, name, __kmp_dflt_max_active_levels); } // __kmp_stg_print_max_active_levels -#if OMP_40_ENABLED // ----------------------------------------------------------------------------- // OpenMP 4.0: OMP_DEFAULT_DEVICE static void __kmp_stg_parse_default_device(char const *name, char const *value, @@ -1186,9 +1248,7 @@ static void __kmp_stg_print_default_device(kmp_str_buf_t *buffer, char const *name, void *data) { __kmp_stg_print_int(buffer, name, __kmp_default_device); } // __kmp_stg_print_default_device -#endif -#if OMP_50_ENABLED // ----------------------------------------------------------------------------- // OpenMP 5.0: OMP_TARGET_OFFLOAD static void __kmp_stg_parse_target_offload(char const *name, char const *value, @@ -1201,11 +1261,11 @@ static void __kmp_stg_parse_target_offload(char const *name, char const *value, if (*next == '\0') return; scan = next; - if (__kmp_match_str("MANDATORY", scan, &next)) { + if (!__kmp_strcasecmp_with_sentinel("mandatory", scan, 0)) { __kmp_target_offload = tgt_mandatory; - } else if (__kmp_match_str("DISABLED", scan, &next)) { + } else if (!__kmp_strcasecmp_with_sentinel("disabled", scan, 0)) { __kmp_target_offload = tgt_disabled; - } else if (__kmp_match_str("DEFAULT", scan, &next)) { + } else if (!__kmp_strcasecmp_with_sentinel("default", scan, 0)) { __kmp_target_offload = tgt_default; } else { KMP_WARNING(SyntaxErrorUsing, name, "DEFAULT"); @@ -1222,13 +1282,15 @@ static void __kmp_stg_print_target_offload(kmp_str_buf_t *buffer, value = "MANDATORY"; else if (__kmp_target_offload == tgt_disabled) value = "DISABLED"; - if (value) { - __kmp_str_buf_print(buffer, " %s=%s\n", name, value); + KMP_DEBUG_ASSERT(value); + if (__kmp_env_format) { + KMP_STR_BUF_PRINT_NAME; + } else { + __kmp_str_buf_print(buffer, " %s", name); } + __kmp_str_buf_print(buffer, "=%s\n", value); } // __kmp_stg_print_target_offload -#endif -#if OMP_45_ENABLED // ----------------------------------------------------------------------------- // OpenMP 4.5: OMP_MAX_TASK_PRIORITY static void __kmp_stg_parse_max_task_priority(char const *name, @@ -1255,7 +1317,6 @@ static void __kmp_stg_print_taskloop_min_tasks(kmp_str_buf_t *buffer, char const *name, void *data) { __kmp_stg_print_int(buffer, name, __kmp_taskloop_min_tasks); } // __kmp_stg_print_taskloop_min_tasks -#endif // OMP_45_ENABLED // ----------------------------------------------------------------------------- // KMP_DISP_NUM_BUFFERS @@ -2026,61 +2087,43 @@ static void __kmp_parse_affinity_env(char const *name, char const *value, ++gran; \ } -#if OMP_40_ENABLED KMP_DEBUG_ASSERT((__kmp_nested_proc_bind.bind_types != NULL) && (__kmp_nested_proc_bind.used > 0)); -#endif while (*buf != '\0') { start = next = buf; if (__kmp_match_str("none", buf, CCAST(const char **, &next))) { set_type(affinity_none); -#if OMP_40_ENABLED __kmp_nested_proc_bind.bind_types[0] = proc_bind_false; -#endif buf = next; } else if (__kmp_match_str("scatter", buf, CCAST(const char **, &next))) { set_type(affinity_scatter); -#if OMP_40_ENABLED __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel; -#endif buf = next; } else if (__kmp_match_str("compact", buf, CCAST(const char **, &next))) { set_type(affinity_compact); -#if OMP_40_ENABLED __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel; -#endif buf = next; } else if (__kmp_match_str("logical", buf, CCAST(const char **, &next))) { set_type(affinity_logical); -#if OMP_40_ENABLED __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel; -#endif buf = next; } else if (__kmp_match_str("physical", buf, CCAST(const char **, &next))) { set_type(affinity_physical); -#if OMP_40_ENABLED __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel; -#endif buf = next; } else if (__kmp_match_str("explicit", buf, CCAST(const char **, &next))) { set_type(affinity_explicit); -#if OMP_40_ENABLED __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel; -#endif buf = next; } else if (__kmp_match_str("balanced", buf, CCAST(const char **, &next))) { set_type(affinity_balanced); -#if OMP_40_ENABLED __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel; -#endif buf = next; } else if (__kmp_match_str("disabled", buf, CCAST(const char **, &next))) { set_type(affinity_disabled); -#if OMP_40_ENABLED __kmp_nested_proc_bind.bind_types[0] = proc_bind_false; -#endif buf = next; } else if (__kmp_match_str("verbose", buf, CCAST(const char **, &next))) { set_verbose(TRUE); @@ -2239,9 +2282,7 @@ static void __kmp_parse_affinity_env(char const *name, char const *value, if (!type) { KMP_WARNING(AffProcListNoType, name); *out_type = affinity_explicit; -#if OMP_40_ENABLED __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel; -#endif } else if (*out_type != affinity_explicit) { KMP_WARNING(AffProcListNotExplicit, name); KMP_ASSERT(*out_proclist != NULL); @@ -2460,9 +2501,7 @@ static void __kmp_stg_parse_gomp_cpu_affinity(char const *name, __kmp_affinity_proclist = temp_proclist; __kmp_affinity_type = affinity_explicit; __kmp_affinity_gran = affinity_gran_fine; -#if OMP_40_ENABLED __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel; -#endif } else { KMP_WARNING(AffSyntaxError, name); if (temp_proclist != NULL) { @@ -2472,16 +2511,12 @@ static void __kmp_stg_parse_gomp_cpu_affinity(char const *name, } else { // Warning already emitted __kmp_affinity_type = affinity_none; -#if OMP_40_ENABLED __kmp_nested_proc_bind.bind_types[0] = proc_bind_false; -#endif } } // __kmp_stg_parse_gomp_cpu_affinity #endif /* KMP_GOMP_COMPAT */ -#if OMP_40_ENABLED - /*----------------------------------------------------------------------------- The OMP_PLACES proc id list parser. Here is the grammar: @@ -2904,40 +2939,6 @@ static void __kmp_stg_print_places(kmp_str_buf_t *buffer, char const *name, } } -#endif /* OMP_40_ENABLED */ - -#if (!OMP_40_ENABLED) - -static void __kmp_stg_parse_proc_bind(char const *name, char const *value, - void *data) { - int enabled; - kmp_setting_t **rivals = (kmp_setting_t **)data; - int rc; - - rc = __kmp_stg_check_rivals(name, value, rivals); - if (rc) { - return; - } - - // In OMP 3.1, OMP_PROC_BIND is strictly a boolean - __kmp_stg_parse_bool(name, value, &enabled); - if (enabled) { - // OMP_PROC_BIND => granularity=fine,scatter on MIC - // OMP_PROC_BIND => granularity=core,scatter elsewhere - __kmp_affinity_type = affinity_scatter; -#if KMP_MIC_SUPPORTED - if (__kmp_mic_type != non_mic) - __kmp_affinity_gran = affinity_gran_fine; - else -#endif - __kmp_affinity_gran = affinity_gran_core; - } else { - __kmp_affinity_type = affinity_none; - } -} // __kmp_parse_proc_bind - -#endif /* if (! OMP_40_ENABLED) */ - static void __kmp_stg_parse_topology_method(char const *name, char const *value, void *data) { if (__kmp_str_match("all", 1, value)) { @@ -3064,8 +3065,6 @@ static void __kmp_stg_print_topology_method(kmp_str_buf_t *buffer, #endif /* KMP_AFFINITY_SUPPORTED */ -#if OMP_40_ENABLED - // OMP_PROC_BIND / bind-var is functional on all 4.0 builds, including OS X* // OMP_PLACES / place-partition-var is not. static void __kmp_stg_parse_proc_bind(char const *name, char const *value, @@ -3144,6 +3143,9 @@ static void __kmp_stg_parse_proc_bind(char const *name, char const *value, } __kmp_nested_proc_bind.used = nelem; + if (nelem > 1 && !__kmp_dflt_max_active_levels_set) + __kmp_dflt_max_active_levels = KMP_MAX_ACTIVE_LEVELS_LIMIT; + // Save values in the nested proc_bind array int i = 0; for (;;) { @@ -3249,9 +3251,6 @@ static void __kmp_stg_print_proc_bind(kmp_str_buf_t *buffer, char const *name, } } -#endif /* OMP_40_ENABLED */ - -#if OMP_50_ENABLED static void __kmp_stg_parse_display_affinity(char const *name, char const *value, void *data) { __kmp_stg_parse_bool(name, value, &__kmp_display_affinity); @@ -3301,7 +3300,7 @@ static void __kmp_stg_parse_allocator(char const *name, char const *value, KMP_ASSERT(num > 0); switch (num) { case 4: - if (__kmp_hbw_mem_available) { + if (__kmp_memkind_available) { __kmp_def_allocator = omp_high_bw_mem_alloc; } else { __kmp_msg(kmp_ms_warning, @@ -3350,7 +3349,7 @@ static void __kmp_stg_parse_allocator(char const *name, char const *value, } next = buf; if (__kmp_match_str("omp_high_bw_mem_alloc", buf, &next)) { - if (__kmp_hbw_mem_available) { + if (__kmp_memkind_available) { __kmp_def_allocator = omp_high_bw_mem_alloc; } else { __kmp_msg(kmp_ms_warning, @@ -3414,8 +3413,6 @@ static void __kmp_stg_print_allocator(kmp_str_buf_t *buffer, char const *name, } } -#endif /* OMP_50_ENABLED */ - // ----------------------------------------------------------------------------- // OMP_DYNAMIC @@ -3606,104 +3603,137 @@ static inline void __kmp_omp_schedule_restore() { __kmp_sched = kmp_sch_default; } +// if parse_hier = true: +// Parse [HW,][modifier:]kind[,chunk] +// else: +// Parse [modifier:]kind[,chunk] static const char *__kmp_parse_single_omp_schedule(const char *name, const char *value, bool parse_hier = false) { /* get the specified scheduling style */ const char *ptr = value; - const char *comma = strchr(ptr, ','); const char *delim; int chunk = 0; enum sched_type sched = kmp_sch_default; if (*ptr == '\0') return NULL; + delim = ptr; + while (*delim != ',' && *delim != ':' && *delim != '\0') + delim++; #if KMP_USE_HIER_SCHED kmp_hier_layer_e layer = kmp_hier_layer_e::LAYER_THREAD; if (parse_hier) { - if (!__kmp_strcasecmp_with_sentinel("L1", ptr, ',')) { - layer = kmp_hier_layer_e::LAYER_L1; - } else if (!__kmp_strcasecmp_with_sentinel("L2", ptr, ',')) { - layer = kmp_hier_layer_e::LAYER_L2; - } else if (!__kmp_strcasecmp_with_sentinel("L3", ptr, ',')) { - layer = kmp_hier_layer_e::LAYER_L3; - } else if (!__kmp_strcasecmp_with_sentinel("NUMA", ptr, ',')) { - layer = kmp_hier_layer_e::LAYER_NUMA; - } - if (layer != kmp_hier_layer_e::LAYER_THREAD && !comma) { + if (*delim == ',') { + if (!__kmp_strcasecmp_with_sentinel("L1", ptr, ',')) { + layer = kmp_hier_layer_e::LAYER_L1; + } else if (!__kmp_strcasecmp_with_sentinel("L2", ptr, ',')) { + layer = kmp_hier_layer_e::LAYER_L2; + } else if (!__kmp_strcasecmp_with_sentinel("L3", ptr, ',')) { + layer = kmp_hier_layer_e::LAYER_L3; + } else if (!__kmp_strcasecmp_with_sentinel("NUMA", ptr, ',')) { + layer = kmp_hier_layer_e::LAYER_NUMA; + } + } + if (layer != kmp_hier_layer_e::LAYER_THREAD && *delim != ',') { // If there is no comma after the layer, then this schedule is invalid KMP_WARNING(StgInvalidValue, name, value); __kmp_omp_schedule_restore(); return NULL; } else if (layer != kmp_hier_layer_e::LAYER_THREAD) { - ptr = ++comma; - comma = strchr(ptr, ','); + ptr = ++delim; + while (*delim != ',' && *delim != ':' && *delim != '\0') + delim++; } } - delim = ptr; - while (*delim != ',' && *delim != ':' && *delim != '\0') - delim++; -#else // KMP_USE_HIER_SCHED - delim = ptr; - while (*delim != ',' && *delim != '\0') - delim++; #endif // KMP_USE_HIER_SCHED - if (!__kmp_strcasecmp_with_sentinel("dynamic", ptr, *delim)) /* DYNAMIC */ + // Read in schedule modifier if specified + enum sched_type sched_modifier = (enum sched_type)0; + if (*delim == ':') { + if (!__kmp_strcasecmp_with_sentinel("monotonic", ptr, *delim)) { + sched_modifier = sched_type::kmp_sch_modifier_monotonic; + ptr = ++delim; + while (*delim != ',' && *delim != ':' && *delim != '\0') + delim++; + } else if (!__kmp_strcasecmp_with_sentinel("nonmonotonic", ptr, *delim)) { + sched_modifier = sched_type::kmp_sch_modifier_nonmonotonic; + ptr = ++delim; + while (*delim != ',' && *delim != ':' && *delim != '\0') + delim++; + } else if (!parse_hier) { + // If there is no proper schedule modifier, then this schedule is invalid + KMP_WARNING(StgInvalidValue, name, value); + __kmp_omp_schedule_restore(); + return NULL; + } + } + // Read in schedule kind (required) + if (!__kmp_strcasecmp_with_sentinel("dynamic", ptr, *delim)) sched = kmp_sch_dynamic_chunked; - else if (!__kmp_strcasecmp_with_sentinel("guided", ptr, *delim)) /* GUIDED */ + else if (!__kmp_strcasecmp_with_sentinel("guided", ptr, *delim)) sched = kmp_sch_guided_chunked; - // AC: TODO: add AUTO schedule, and probably remove TRAPEZOIDAL (OMP 3.0 does - // not allow it) - else if (!__kmp_strcasecmp_with_sentinel("auto", ptr, *delim)) { /* AUTO */ + // AC: TODO: probably remove TRAPEZOIDAL (OMP 3.0 does not allow it) + else if (!__kmp_strcasecmp_with_sentinel("auto", ptr, *delim)) sched = kmp_sch_auto; - if (comma) { - __kmp_msg(kmp_ms_warning, KMP_MSG(IgnoreChunk, name, comma), - __kmp_msg_null); - comma = NULL; - } - } else if (!__kmp_strcasecmp_with_sentinel("trapezoidal", ptr, - *delim)) /* TRAPEZOIDAL */ + else if (!__kmp_strcasecmp_with_sentinel("trapezoidal", ptr, *delim)) sched = kmp_sch_trapezoidal; - else if (!__kmp_strcasecmp_with_sentinel("static", ptr, *delim)) /* STATIC */ + else if (!__kmp_strcasecmp_with_sentinel("static", ptr, *delim)) sched = kmp_sch_static; #if KMP_STATIC_STEAL_ENABLED else if (!__kmp_strcasecmp_with_sentinel("static_steal", ptr, *delim)) sched = kmp_sch_static_steal; #endif else { + // If there is no proper schedule kind, then this schedule is invalid KMP_WARNING(StgInvalidValue, name, value); __kmp_omp_schedule_restore(); return NULL; } - if (ptr && comma && *comma == *delim) { - ptr = comma + 1; - SKIP_DIGITS(ptr); - if (sched == kmp_sch_static) - sched = kmp_sch_static_chunked; - ++comma; - chunk = __kmp_str_to_int(comma, *ptr); - if (chunk < 1) { - chunk = KMP_DEFAULT_CHUNK; - __kmp_msg(kmp_ms_warning, KMP_MSG(InvalidChunk, name, comma), - __kmp_msg_null); - KMP_INFORM(Using_int_Value, name, __kmp_chunk); - // AC: next block commented out until KMP_DEFAULT_CHUNK != KMP_MIN_CHUNK - // (to improve code coverage :) - // The default chunk size is 1 according to standard, thus making - // KMP_MIN_CHUNK not 1 we would introduce mess: - // wrong chunk becomes 1, but it will be impossible to explicitely set - // 1, because it becomes KMP_MIN_CHUNK... - // } else if ( chunk < KMP_MIN_CHUNK ) { - // chunk = KMP_MIN_CHUNK; - } else if (chunk > KMP_MAX_CHUNK) { - chunk = KMP_MAX_CHUNK; - __kmp_msg(kmp_ms_warning, KMP_MSG(LargeChunk, name, comma), + // Read in schedule chunk size if specified + if (*delim == ',') { + ptr = delim + 1; + SKIP_WS(ptr); + if (!isdigit(*ptr)) { + // If there is no chunk after comma, then this schedule is invalid + KMP_WARNING(StgInvalidValue, name, value); + __kmp_omp_schedule_restore(); + return NULL; + } + SKIP_DIGITS(ptr); + // auto schedule should not specify chunk size + if (sched == kmp_sch_auto) { + __kmp_msg(kmp_ms_warning, KMP_MSG(IgnoreChunk, name, delim), __kmp_msg_null); - KMP_INFORM(Using_int_Value, name, chunk); + } else { + if (sched == kmp_sch_static) + sched = kmp_sch_static_chunked; + chunk = __kmp_str_to_int(delim + 1, *ptr); + if (chunk < 1) { + chunk = KMP_DEFAULT_CHUNK; + __kmp_msg(kmp_ms_warning, KMP_MSG(InvalidChunk, name, delim), + __kmp_msg_null); + KMP_INFORM(Using_int_Value, name, __kmp_chunk); + // AC: next block commented out until KMP_DEFAULT_CHUNK != KMP_MIN_CHUNK + // (to improve code coverage :) + // The default chunk size is 1 according to standard, thus making + // KMP_MIN_CHUNK not 1 we would introduce mess: + // wrong chunk becomes 1, but it will be impossible to explicitly set + // to 1 because it becomes KMP_MIN_CHUNK... + // } else if ( chunk < KMP_MIN_CHUNK ) { + // chunk = KMP_MIN_CHUNK; + } else if (chunk > KMP_MAX_CHUNK) { + chunk = KMP_MAX_CHUNK; + __kmp_msg(kmp_ms_warning, KMP_MSG(LargeChunk, name, delim), + __kmp_msg_null); + KMP_INFORM(Using_int_Value, name, chunk); + } } - } else if (ptr) { - SKIP_TOKEN(ptr); + } else { + ptr = delim; } + + SCHEDULE_SET_MODIFIERS(sched, sched_modifier); + #if KMP_USE_HIER_SCHED if (layer != kmp_hier_layer_e::LAYER_THREAD) { __kmp_hier_scheds.append(sched, chunk, layer); @@ -3734,6 +3764,8 @@ static void __kmp_stg_parse_omp_schedule(char const *name, char const *value, while ((ptr = __kmp_parse_single_omp_schedule(name, ptr, true))) { while (*ptr == ' ' || *ptr == '\t' || *ptr == ':') ptr++; + if (*ptr == '\0') + break; } } else #endif @@ -3757,8 +3789,14 @@ static void __kmp_stg_print_omp_schedule(kmp_str_buf_t *buffer, } else { __kmp_str_buf_print(buffer, " %s='", name); } + enum sched_type sched = SCHEDULE_WITHOUT_MODIFIERS(__kmp_sched); + if (SCHEDULE_HAS_MONOTONIC(__kmp_sched)) { + __kmp_str_buf_print(buffer, "monotonic:"); + } else if (SCHEDULE_HAS_NONMONOTONIC(__kmp_sched)) { + __kmp_str_buf_print(buffer, "nonmonotonic:"); + } if (__kmp_chunk) { - switch (__kmp_sched) { + switch (sched) { case kmp_sch_dynamic_chunked: __kmp_str_buf_print(buffer, "%s,%d'\n", "dynamic", __kmp_chunk); break; @@ -3783,7 +3821,7 @@ static void __kmp_stg_print_omp_schedule(kmp_str_buf_t *buffer, break; } } else { - switch (__kmp_sched) { + switch (sched) { case kmp_sch_dynamic_chunked: __kmp_str_buf_print(buffer, "%s'\n", "dynamic"); break; @@ -3945,79 +3983,9 @@ static void __kmp_stg_print_par_range_env(kmp_str_buf_t *buffer, } } // __kmp_stg_print_par_range_env -// ----------------------------------------------------------------------------- -// KMP_YIELD_CYCLE, KMP_YIELD_ON, KMP_YIELD_OFF - -static void __kmp_stg_parse_yield_cycle(char const *name, char const *value, - void *data) { - int flag = __kmp_yield_cycle; - __kmp_stg_parse_bool(name, value, &flag); - __kmp_yield_cycle = flag; -} // __kmp_stg_parse_yield_cycle - -static void __kmp_stg_print_yield_cycle(kmp_str_buf_t *buffer, char const *name, - void *data) { - __kmp_stg_print_bool(buffer, name, __kmp_yield_cycle); -} // __kmp_stg_print_yield_cycle - -static void __kmp_stg_parse_yield_on(char const *name, char const *value, - void *data) { - __kmp_stg_parse_int(name, value, 2, INT_MAX, &__kmp_yield_on_count); -} // __kmp_stg_parse_yield_on - -static void __kmp_stg_print_yield_on(kmp_str_buf_t *buffer, char const *name, - void *data) { - __kmp_stg_print_int(buffer, name, __kmp_yield_on_count); -} // __kmp_stg_print_yield_on - -static void __kmp_stg_parse_yield_off(char const *name, char const *value, - void *data) { - __kmp_stg_parse_int(name, value, 2, INT_MAX, &__kmp_yield_off_count); -} // __kmp_stg_parse_yield_off - -static void __kmp_stg_print_yield_off(kmp_str_buf_t *buffer, char const *name, - void *data) { - __kmp_stg_print_int(buffer, name, __kmp_yield_off_count); -} // __kmp_stg_print_yield_off - #endif // ----------------------------------------------------------------------------- -// KMP_INIT_WAIT, KMP_NEXT_WAIT - -static void __kmp_stg_parse_init_wait(char const *name, char const *value, - void *data) { - int wait; - KMP_ASSERT((__kmp_init_wait & 1) == 0); - wait = __kmp_init_wait / 2; - __kmp_stg_parse_int(name, value, KMP_MIN_INIT_WAIT, KMP_MAX_INIT_WAIT, &wait); - __kmp_init_wait = wait * 2; - KMP_ASSERT((__kmp_init_wait & 1) == 0); - __kmp_yield_init = __kmp_init_wait; -} // __kmp_stg_parse_init_wait - -static void __kmp_stg_print_init_wait(kmp_str_buf_t *buffer, char const *name, - void *data) { - __kmp_stg_print_int(buffer, name, __kmp_init_wait); -} // __kmp_stg_print_init_wait - -static void __kmp_stg_parse_next_wait(char const *name, char const *value, - void *data) { - int wait; - KMP_ASSERT((__kmp_next_wait & 1) == 0); - wait = __kmp_next_wait / 2; - __kmp_stg_parse_int(name, value, KMP_MIN_NEXT_WAIT, KMP_MAX_NEXT_WAIT, &wait); - __kmp_next_wait = wait * 2; - KMP_ASSERT((__kmp_next_wait & 1) == 0); - __kmp_yield_next = __kmp_next_wait; -} // __kmp_stg_parse_next_wait - -static void __kmp_stg_print_next_wait(kmp_str_buf_t *buffer, char const *name, - void *data) { - __kmp_stg_print_int(buffer, name, __kmp_next_wait); -} //__kmp_stg_print_next_wait - -// ----------------------------------------------------------------------------- // KMP_GTID_MODE static void __kmp_stg_parse_gtid_mode(char const *name, char const *value, @@ -4476,10 +4444,10 @@ static void __kmp_stg_parse_hw_subset(char const *name, char const *value, pos = input; components[level++] = pos; while ((pos = strchr(pos, ','))) { + if (level >= MAX_T_LEVEL) + goto err; // too many components provided *pos = '\0'; // modify input and avoid more copying components[level++] = ++pos; // expect something after "," - if (level > MAX_T_LEVEL) - goto err; // too many components provided } // Check each component for (int i = 0; i < level; ++i) { @@ -4640,9 +4608,21 @@ static void __kmp_stg_print_forkjoin_frames_mode(kmp_str_buf_t *buffer, #endif /* USE_ITT_BUILD */ // ----------------------------------------------------------------------------- -// OMP_DISPLAY_ENV +// KMP_ENABLE_TASK_THROTTLING -#if OMP_40_ENABLED +static void __kmp_stg_parse_task_throttling(char const *name, + char const *value, void *data) { + __kmp_stg_parse_bool(name, value, &__kmp_enable_task_throttling); +} // __kmp_stg_parse_task_throttling + + +static void __kmp_stg_print_task_throttling(kmp_str_buf_t *buffer, + char const *name, void *data) { + __kmp_stg_print_bool(buffer, name, __kmp_enable_task_throttling); +} // __kmp_stg_print_task_throttling + +// ----------------------------------------------------------------------------- +// OMP_DISPLAY_ENV static void __kmp_stg_parse_omp_display_env(char const *name, char const *value, void *data) { @@ -4651,7 +4631,6 @@ static void __kmp_stg_parse_omp_display_env(char const *name, char const *value, } else { __kmp_stg_parse_bool(name, value, &__kmp_display_env); } - } // __kmp_stg_parse_omp_display_env static void __kmp_stg_print_omp_display_env(kmp_str_buf_t *buffer, @@ -4677,9 +4656,7 @@ static void __kmp_stg_print_omp_cancellation(kmp_str_buf_t *buffer, __kmp_stg_print_bool(buffer, name, __kmp_omp_cancellation); } // __kmp_stg_print_omp_cancellation -#endif - -#if OMP_50_ENABLED && OMPT_SUPPORT +#if OMPT_SUPPORT static int __kmp_tool = 1; static void __kmp_stg_parse_omp_tool(char const *name, char const *value, @@ -4727,6 +4704,8 @@ static kmp_setting_t __kmp_stg_table[] = { {"KMP_ALL_THREADS", __kmp_stg_parse_device_thread_limit, NULL, NULL, 0, 0}, {"KMP_BLOCKTIME", __kmp_stg_parse_blocktime, __kmp_stg_print_blocktime, NULL, 0, 0}, + {"KMP_USE_YIELD", __kmp_stg_parse_use_yield, __kmp_stg_print_use_yield, + NULL, 0, 0}, {"KMP_DUPLICATE_LIB_OK", __kmp_stg_parse_duplicate_lib_ok, __kmp_stg_print_duplicate_lib_ok, NULL, 0, 0}, {"KMP_LIBRARY", __kmp_stg_parse_wait_policy, __kmp_stg_print_wait_policy, @@ -4762,20 +4741,14 @@ static kmp_setting_t __kmp_stg_table[] = { __kmp_stg_print_task_stealing, NULL, 0, 0}, {"OMP_MAX_ACTIVE_LEVELS", __kmp_stg_parse_max_active_levels, __kmp_stg_print_max_active_levels, NULL, 0, 0}, -#if OMP_40_ENABLED {"OMP_DEFAULT_DEVICE", __kmp_stg_parse_default_device, __kmp_stg_print_default_device, NULL, 0, 0}, -#endif -#if OMP_50_ENABLED {"OMP_TARGET_OFFLOAD", __kmp_stg_parse_target_offload, __kmp_stg_print_target_offload, NULL, 0, 0}, -#endif -#if OMP_45_ENABLED {"OMP_MAX_TASK_PRIORITY", __kmp_stg_parse_max_task_priority, __kmp_stg_print_max_task_priority, NULL, 0, 0}, {"KMP_TASKLOOP_MIN_TASKS", __kmp_stg_parse_taskloop_min_tasks, __kmp_stg_print_taskloop_min_tasks, NULL, 0, 0}, -#endif {"OMP_THREAD_LIMIT", __kmp_stg_parse_thread_limit, __kmp_stg_print_thread_limit, NULL, 0, 0}, {"KMP_TEAMS_THREAD_LIMIT", __kmp_stg_parse_teams_thread_limit, @@ -4831,12 +4804,6 @@ static kmp_setting_t __kmp_stg_table[] = { {"KMP_PAR_RANGE", __kmp_stg_parse_par_range_env, __kmp_stg_print_par_range_env, NULL, 0, 0}, - {"KMP_YIELD_CYCLE", __kmp_stg_parse_yield_cycle, - __kmp_stg_print_yield_cycle, NULL, 0, 0}, - {"KMP_YIELD_ON", __kmp_stg_parse_yield_on, __kmp_stg_print_yield_on, NULL, - 0, 0}, - {"KMP_YIELD_OFF", __kmp_stg_parse_yield_off, __kmp_stg_print_yield_off, - NULL, 0, 0}, #endif // KMP_DEBUG {"KMP_ALIGN_ALLOC", __kmp_stg_parse_align_alloc, @@ -4880,33 +4847,24 @@ static kmp_setting_t __kmp_stg_table[] = { {"GOMP_CPU_AFFINITY", __kmp_stg_parse_gomp_cpu_affinity, NULL, /* no print */ NULL, 0, 0}, #endif /* KMP_GOMP_COMPAT */ -#if OMP_40_ENABLED {"OMP_PROC_BIND", __kmp_stg_parse_proc_bind, __kmp_stg_print_proc_bind, NULL, 0, 0}, {"OMP_PLACES", __kmp_stg_parse_places, __kmp_stg_print_places, NULL, 0, 0}, -#else - {"OMP_PROC_BIND", __kmp_stg_parse_proc_bind, NULL, /* no print */ NULL, 0, - 0}, -#endif /* OMP_40_ENABLED */ {"KMP_TOPOLOGY_METHOD", __kmp_stg_parse_topology_method, __kmp_stg_print_topology_method, NULL, 0, 0}, #else -// KMP_AFFINITY is not supported on OS X*, nor is OMP_PLACES. -// OMP_PROC_BIND and proc-bind-var are supported, however. -#if OMP_40_ENABLED + // KMP_AFFINITY is not supported on OS X*, nor is OMP_PLACES. + // OMP_PROC_BIND and proc-bind-var are supported, however. {"OMP_PROC_BIND", __kmp_stg_parse_proc_bind, __kmp_stg_print_proc_bind, NULL, 0, 0}, -#endif #endif // KMP_AFFINITY_SUPPORTED -#if OMP_50_ENABLED {"OMP_DISPLAY_AFFINITY", __kmp_stg_parse_display_affinity, __kmp_stg_print_display_affinity, NULL, 0, 0}, {"OMP_AFFINITY_FORMAT", __kmp_stg_parse_affinity_format, __kmp_stg_print_affinity_format, NULL, 0, 0}, -#endif {"KMP_INIT_AT_FORK", __kmp_stg_parse_init_at_fork, __kmp_stg_print_init_at_fork, NULL, 0, 0}, {"KMP_SCHEDULE", __kmp_stg_parse_schedule, __kmp_stg_print_schedule, NULL, @@ -4928,10 +4886,6 @@ static kmp_setting_t __kmp_stg_table[] = { #endif /* USE_ITT_BUILD && USE_ITT_NOTIFY */ {"KMP_MALLOC_POOL_INCR", __kmp_stg_parse_malloc_pool_incr, __kmp_stg_print_malloc_pool_incr, NULL, 0, 0}, - {"KMP_INIT_WAIT", __kmp_stg_parse_init_wait, __kmp_stg_print_init_wait, - NULL, 0, 0}, - {"KMP_NEXT_WAIT", __kmp_stg_parse_next_wait, __kmp_stg_print_next_wait, - NULL, 0, 0}, {"KMP_GTID_MODE", __kmp_stg_parse_gtid_mode, __kmp_stg_print_gtid_mode, NULL, 0, 0}, {"OMP_DYNAMIC", __kmp_stg_parse_omp_dynamic, __kmp_stg_print_omp_dynamic, @@ -4968,20 +4922,17 @@ static kmp_setting_t __kmp_stg_table[] = { {"KMP_FORKJOIN_FRAMES_MODE", __kmp_stg_parse_forkjoin_frames_mode, __kmp_stg_print_forkjoin_frames_mode, NULL, 0, 0}, #endif + {"KMP_ENABLE_TASK_THROTTLING", __kmp_stg_parse_task_throttling, + __kmp_stg_print_task_throttling, NULL, 0, 0}, -#if OMP_40_ENABLED {"OMP_DISPLAY_ENV", __kmp_stg_parse_omp_display_env, __kmp_stg_print_omp_display_env, NULL, 0, 0}, {"OMP_CANCELLATION", __kmp_stg_parse_omp_cancellation, __kmp_stg_print_omp_cancellation, NULL, 0, 0}, -#endif - -#if OMP_50_ENABLED {"OMP_ALLOCATOR", __kmp_stg_parse_allocator, __kmp_stg_print_allocator, NULL, 0, 0}, -#endif -#if OMP_50_ENABLED && OMPT_SUPPORT +#if OMPT_SUPPORT {"OMP_TOOL", __kmp_stg_parse_omp_tool, __kmp_stg_print_omp_tool, NULL, 0, 0}, {"OMP_TOOL_LIBRARIES", __kmp_stg_parse_omp_tool_libraries, @@ -5167,7 +5118,6 @@ static void __kmp_stg_init(void) { omp_proc_bind->data = CCAST(kmp_setting_t **, rivals); rivals[i++] = NULL; -#if OMP_40_ENABLED static kmp_setting_t *volatile places_rivals[4]; i = 0; @@ -5181,7 +5131,6 @@ static void __kmp_stg_init(void) { places_rivals[i++] = omp_places; omp_places->data = CCAST(kmp_setting_t **, places_rivals); places_rivals[i++] = NULL; -#endif } #else // KMP_AFFINITY not supported, so OMP_PROC_BIND has no rivals. @@ -5308,7 +5257,7 @@ static void __kmp_aux_env_initialize(kmp_env_blk_t *block) { /* OMP_NESTED */ value = __kmp_env_blk_var(block, "OMP_NESTED"); if (value) { - ompc_set_nested(__kmp_dflt_nested); + ompc_set_nested(__kmp_dflt_max_active_levels > 1); } /* OMP_DYNAMIC */ @@ -5403,7 +5352,6 @@ void __kmp_env_initialize(char const *string) { } #undef FIND -#if OMP_40_ENABLED // Also reset the affinity flags if OMP_PROC_BIND is specified. aff_str = __kmp_env_blk_var(&block, "OMP_PROC_BIND"); if (aff_str != NULL) { @@ -5412,12 +5360,10 @@ void __kmp_env_initialize(char const *string) { __kmp_affinity_top_method = affinity_top_method_default; __kmp_affinity_respect_mask = affinity_respect_mask_default; } -#endif /* OMP_40_ENABLED */ } #endif /* KMP_AFFINITY_SUPPORTED */ -#if OMP_40_ENABLED // Set up the nested proc bind type vector. if (__kmp_nested_proc_bind.bind_types == NULL) { __kmp_nested_proc_bind.bind_types = @@ -5434,9 +5380,7 @@ void __kmp_env_initialize(char const *string) { __kmp_nested_proc_bind.bind_types[0] = proc_bind_false; #endif } -#endif /* OMP_40_ENABLED */ -#if OMP_50_ENABLED // Set up the affinity format ICV // Grab the default affinity format string from the message catalog kmp_msg_t m = @@ -5449,7 +5393,6 @@ void __kmp_env_initialize(char const *string) { } KMP_STRCPY_S(__kmp_affinity_format, KMP_AFFINITY_FORMAT_SIZE, m.str); __kmp_str_free(&m.str); -#endif // Now process all of the settings. for (i = 0; i < block.count; ++i) { @@ -5524,14 +5467,12 @@ void __kmp_env_initialize(char const *string) { } } -#if OMP_40_ENABLED if (__kmp_affinity_type == affinity_disabled) { __kmp_nested_proc_bind.bind_types[0] = proc_bind_false; } else if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_true) { // OMP_PROC_BIND=true maps to OMP_PROC_BIND=spread. __kmp_nested_proc_bind.bind_types[0] = proc_bind_spread; } -#endif /* OMP_40_ENABLED */ if (KMP_AFFINITY_CAPABLE()) { @@ -5568,20 +5509,16 @@ void __kmp_env_initialize(char const *string) { // processor groups, or if the user requested it, and OMP 4.0 // affinity is not in effect. if (((__kmp_num_proc_groups > 1) && - (__kmp_affinity_type == affinity_default) -#if OMP_40_ENABLED - && (__kmp_nested_proc_bind.bind_types[0] == proc_bind_default)) -#endif - || (__kmp_affinity_top_method == affinity_top_method_group)) { + (__kmp_affinity_type == affinity_default) && + (__kmp_nested_proc_bind.bind_types[0] == proc_bind_default)) || + (__kmp_affinity_top_method == affinity_top_method_group)) { if (__kmp_affinity_respect_mask == affinity_respect_mask_default && exactly_one_group) { __kmp_affinity_respect_mask = FALSE; } if (__kmp_affinity_type == affinity_default) { __kmp_affinity_type = affinity_compact; -#if OMP_40_ENABLED __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel; -#endif } if (__kmp_affinity_top_method == affinity_top_method_default) { if (__kmp_affinity_gran == affinity_gran_default) { @@ -5662,17 +5599,13 @@ void __kmp_env_initialize(char const *string) { __kmp_affinity_respect_mask = TRUE; } } -#if OMP_40_ENABLED if ((__kmp_nested_proc_bind.bind_types[0] != proc_bind_intel) && (__kmp_nested_proc_bind.bind_types[0] != proc_bind_default)) { if (__kmp_affinity_type == affinity_default) { __kmp_affinity_type = affinity_compact; __kmp_affinity_dups = FALSE; } - } else -#endif /* OMP_40_ENABLED */ - if (__kmp_affinity_type == affinity_default) { -#if OMP_40_ENABLED + } else if (__kmp_affinity_type == affinity_default) { #if KMP_MIC_SUPPORTED if (__kmp_mic_type != non_mic) { __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel; @@ -5681,7 +5614,6 @@ void __kmp_env_initialize(char const *string) { { __kmp_nested_proc_bind.bind_types[0] = proc_bind_false; } -#endif /* OMP_40_ENABLED */ #if KMP_MIC_SUPPORTED if (__kmp_mic_type != non_mic) { __kmp_affinity_type = affinity_scatter; @@ -5718,11 +5650,9 @@ void __kmp_env_initialize(char const *string) { K_DIAG(1, ("__kmp_affinity_gran == %d\n", __kmp_affinity_gran)); KMP_DEBUG_ASSERT(__kmp_affinity_type != affinity_default); -#if OMP_40_ENABLED KMP_DEBUG_ASSERT(__kmp_nested_proc_bind.bind_types[0] != proc_bind_default); K_DIAG(1, ("__kmp_nested_proc_bind.bind_types[0] == %d\n", __kmp_nested_proc_bind.bind_types[0])); -#endif } #endif /* KMP_AFFINITY_SUPPORTED */ @@ -5789,7 +5719,6 @@ void __kmp_env_print() { } // __kmp_env_print -#if OMP_40_ENABLED void __kmp_env_print_2() { kmp_env_blk_t block; @@ -5827,6 +5756,5 @@ void __kmp_env_print_2() { __kmp_printf("\n"); } // __kmp_env_print_2 -#endif // OMP_40_ENABLED // end of file |