[Openmp-commits] [openmp] 6777368 - [OpenMP] Add environment variable to force monotonic dynamic scheduling
via Openmp-commits
openmp-commits at lists.llvm.org
Fri Jan 29 10:26:45 PST 2021
Author: Jonathan Peyton
Date: 2021-01-29T12:23:27-06:00
New Revision: 67773681c0ef2a778a3c34d23b365899cd33e0c3
URL: https://github.com/llvm/llvm-project/commit/67773681c0ef2a778a3c34d23b365899cd33e0c3
DIFF: https://github.com/llvm/llvm-project/commit/67773681c0ef2a778a3c34d23b365899cd33e0c3.diff
LOG: [OpenMP] Add environment variable to force monotonic dynamic scheduling
This patch introduces a new environment variable to force monotonic
behavior for users that absolutely need it. This is in anticipation
of 5.0 change that uses non-monotonic behavior for dynamic scheduling
by default. Fixes for that and the actual switch are coming soon.
Differential Revision: https://reviews.llvm.org/D95263
Added:
Modified:
openmp/runtime/src/kmp.h
openmp/runtime/src/kmp_dispatch.cpp
openmp/runtime/src/kmp_global.cpp
openmp/runtime/src/kmp_settings.cpp
Removed:
################################################################################
diff --git a/openmp/runtime/src/kmp.h b/openmp/runtime/src/kmp.h
index ca57bf7d800c..163dc0e26ea1 100644
--- a/openmp/runtime/src/kmp.h
+++ b/openmp/runtime/src/kmp.h
@@ -3004,6 +3004,7 @@ extern enum sched_type __kmp_static; /* default static scheduling method */
extern enum sched_type __kmp_guided; /* default guided scheduling method */
extern enum sched_type __kmp_auto; /* default auto scheduling method */
extern int __kmp_chunk; /* default runtime chunk size */
+extern int __kmp_force_monotonic; /* whether monotonic scheduling forced */
extern size_t __kmp_stksize; /* stack size per thread */
#if KMP_USE_MONITOR
diff --git a/openmp/runtime/src/kmp_dispatch.cpp b/openmp/runtime/src/kmp_dispatch.cpp
index a805ee44d5db..3e9fc7c804bb 100644
--- a/openmp/runtime/src/kmp_dispatch.cpp
+++ b/openmp/runtime/src/kmp_dispatch.cpp
@@ -80,7 +80,7 @@ static inline int __kmp_get_monotonicity(ident_t *loc, enum sched_type schedule,
if (loc->get_openmp_version() < 50)
monotonicity = SCHEDULE_MONOTONIC;
- if (use_hier)
+ if (use_hier || __kmp_force_monotonic)
monotonicity = SCHEDULE_MONOTONIC;
else if (SCHEDULE_HAS_NONMONOTONIC(schedule))
monotonicity = SCHEDULE_NONMONOTONIC;
diff --git a/openmp/runtime/src/kmp_global.cpp b/openmp/runtime/src/kmp_global.cpp
index afe723251f0f..0f508e8e7d49 100644
--- a/openmp/runtime/src/kmp_global.cpp
+++ b/openmp/runtime/src/kmp_global.cpp
@@ -166,6 +166,7 @@ int __kmp_zero_bt = FALSE;
int __kmp_ncores = 0;
#endif
int __kmp_chunk = 0;
+int __kmp_force_monotonic = 0;
int __kmp_abort_delay = 0;
#if KMP_OS_LINUX && defined(KMP_TDATA_GTID)
int __kmp_gtid_mode = 3; /* use __declspec(thread) TLS to store gtid */
diff --git a/openmp/runtime/src/kmp_settings.cpp b/openmp/runtime/src/kmp_settings.cpp
index 3d9bdb384861..b7d5d3b0d689 100644
--- a/openmp/runtime/src/kmp_settings.cpp
+++ b/openmp/runtime/src/kmp_settings.cpp
@@ -4136,6 +4136,18 @@ static void __kmp_stg_print_kmp_hand_thread(kmp_str_buf_t *buffer,
} // __kmp_stg_print_kmp_hand_thread
#endif
+// -----------------------------------------------------------------------------
+// KMP_FORCE_MONOTONIC_DYNAMIC_SCHEDULE
+static void __kmp_stg_parse_kmp_force_monotonic(char const *name,
+ char const *value, void *data) {
+ __kmp_stg_parse_bool(name, value, &(__kmp_force_monotonic));
+} // __kmp_stg_parse_kmp_force_monotonic
+
+static void __kmp_stg_print_kmp_force_monotonic(kmp_str_buf_t *buffer,
+ char const *name, void *data) {
+ __kmp_stg_print_bool(buffer, name, __kmp_force_monotonic);
+} // __kmp_stg_print_kmp_force_monotonic
+
// -----------------------------------------------------------------------------
// KMP_ATOMIC_MODE
@@ -5224,6 +5236,9 @@ static kmp_setting_t __kmp_stg_table[] = {
{"KMP_DISP_HAND_THREAD", __kmp_stg_parse_kmp_hand_thread,
__kmp_stg_print_kmp_hand_thread, NULL, 0, 0},
#endif
+ {"KMP_FORCE_MONOTONIC_DYNAMIC_SCHEDULE",
+ __kmp_stg_parse_kmp_force_monotonic, __kmp_stg_print_kmp_force_monotonic,
+ NULL, 0, 0},
{"KMP_ATOMIC_MODE", __kmp_stg_parse_atomic_mode,
__kmp_stg_print_atomic_mode, NULL, 0, 0},
{"KMP_CONSISTENCY_CHECK", __kmp_stg_parse_consistency_check,
More information about the Openmp-commits
mailing list