[Openmp-commits] [openmp] r261906 - dd new OpenMP 4.5 schedule clause modifiers (monotonic/non-monotonic) feature
Jonathan Peyton via Openmp-commits
openmp-commits at lists.llvm.org
Thu Feb 25 09:55:50 PST 2016
Author: jlpeyton
Date: Thu Feb 25 11:55:50 2016
New Revision: 261906
URL: http://llvm.org/viewvc/llvm-project?rev=261906&view=rev
Log:
dd new OpenMP 4.5 schedule clause modifiers (monotonic/non-monotonic) feature
The monotonic/non-monotonic flags are sent to the runtime via the sched_type by
setting the 30th (non-monotonic) or 29th (monotonic) bit in the sched_type.
Macros are added to probe if monotonic or non-monotonic is specified
(SCHEDULE_HAS_[NON]MONOTONIC & SCHEDULE_HAS_NO_MODIFIERS)
and also to to get the base sched_type (SCHEDULE_WITHOUT_MODIFIERS)
Currently, nothing is done with the modifiers.
Also, this patch adds some comments on the use of the enumerations in at least
one place where it is subtle.
Differential Revision: http://reviews.llvm.org/D17406
Modified:
openmp/trunk/runtime/src/kmp.h
openmp/trunk/runtime/src/kmp_dispatch.cpp
openmp/trunk/runtime/src/kmp_sched.cpp
Modified: openmp/trunk/runtime/src/kmp.h
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp.h?rev=261906&r1=261905&r2=261906&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp.h (original)
+++ openmp/trunk/runtime/src/kmp.h Thu Feb 25 11:55:50 2016
@@ -369,6 +369,39 @@ enum sched_type {
kmp_nm_ord_trapezoidal = 199,
kmp_nm_upper = 200, /**< upper bound for nomerge values */
+#if OMP_41_ENABLED
+ /* Support for OpenMP 4.5 monotonic and nonmonotonic schedule modifiers.
+ * Since we need to distinguish the three possible cases (no modifier, monotonic modifier,
+ * nonmonotonic modifier), we need separate bits for each modifier.
+ * The absence of monotonic does not imply nonmonotonic, especially since 4.5 says
+ * that the behaviour of the "no modifier" case is implementation defined in 4.5,
+ * but will become "nonmonotonic" in 5.0.
+ *
+ * Since we're passing a full 32 bit value, we can use a couple of high bits for these
+ * flags; out of paranoia we avoid the sign bit.
+ *
+ * These modifiers can be or-ed into non-static schedules by the compiler to pass
+ * the additional information.
+ * They will be stripped early in the processing in __kmp_dispatch_init when setting up schedules, so
+ * most of the code won't ever see schedules with these bits set.
+ */
+ kmp_sch_modifier_monotonic = (1<<29), /**< Set if the monotonic schedule modifier was present */
+ kmp_sch_modifier_nonmonotonic = (1<<30), /**< Set if the nonmonotonic schedule modifier was present */
+
+# define SCHEDULE_WITHOUT_MODIFIERS(s) (enum sched_type)((s) & ~ (kmp_sch_modifier_nonmonotonic | kmp_sch_modifier_monotonic))
+# define SCHEDULE_HAS_MONOTONIC(s) (((s) & kmp_sch_modifier_monotonic) != 0)
+# define SCHEDULE_HAS_NONMONOTONIC(s) (((s) & kmp_sch_modifier_nonmonotonic) != 0)
+# define SCHEDULE_HAS_NO_MODIFIERS(s) (((s) & (kmp_sch_modifier_nonmonotonic | kmp_sch_modifier_monotonic)) == 0)
+#else
+ /* By doing this we hope to avoid multiple tests on OMP_41_ENABLED. Compilers can now eliminate tests on compile time
+ * constants and dead code that results from them, so we can leave code guarded by such an if in place.
+ */
+# define SCHEDULE_WITHOUT_MODIFIERS(s) (s)
+# define SCHEDULE_HAS_MONOTONIC(s) false
+# define SCHEDULE_HAS_NONMONOTONIC(s) false
+# define SCHEDULE_HAS_NO_MODIFIERS(s) true
+#endif
+
kmp_sch_default = kmp_sch_static /**< default scheduling algorithm */
};
Modified: openmp/trunk/runtime/src/kmp_dispatch.cpp
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_dispatch.cpp?rev=261906&r1=261905&r2=261906&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_dispatch.cpp (original)
+++ openmp/trunk/runtime/src/kmp_dispatch.cpp Thu Feb 25 11:55:50 2016
@@ -656,6 +656,14 @@ __kmp_dispatch_init(
( &team -> t.t_disp_buffer[ my_buffer_index % KMP_MAX_DISP_BUF ] );
}
+ /* Currently just ignore the monotonic and non-monotonic modifiers (the compiler isn't producing them
+ * yet anyway).
+ * When it is we'll want to look at them somewhere here and use that information to add to our
+ * schedule choice. We shouldn't need to pass them on, they merely affect which schedule we can
+ * legally choose for various dynamic cases. (In paritcular, whether or not a stealing scheme is legal).
+ */
+ schedule = SCHEDULE_WITHOUT_MODIFIERS(schedule);
+
/* Pick up the nomerge/ordered bits from the scheduling type */
if ( (schedule >= kmp_nm_lower) && (schedule < kmp_nm_upper) ) {
pr->nomerge = TRUE;
Modified: openmp/trunk/runtime/src/kmp_sched.cpp
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_sched.cpp?rev=261906&r1=261905&r2=261906&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_sched.cpp (original)
+++ openmp/trunk/runtime/src/kmp_sched.cpp Thu Feb 25 11:55:50 2016
@@ -164,6 +164,9 @@ __kmp_for_static_init(
}
#if OMP_40_ENABLED
+ // Although there are schedule enumerations above kmp_ord_upper which are not schedules for "distribute",
+ // the only ones which are useful are dynamic, so cannot be seen here, since this codepath is only executed
+ // for static schedules.
if ( schedtype > kmp_ord_upper ) {
// we are in DISTRIBUTE construct
schedtype += kmp_sch_static - kmp_distribute_static; // AC: convert to usual schedule type
More information about the Openmp-commits
mailing list