[Openmp-commits] [openmp] r240970 - Fix OMPT state maintenance for barriers and missing init of implicit task id.
Jonathan Peyton
jonathan.l.peyton at intel.com
Mon Jun 29 10:28:58 PDT 2015
Author: jlpeyton
Date: Mon Jun 29 12:28:57 2015
New Revision: 240970
URL: http://llvm.org/viewvc/llvm-project?rev=240970&view=rev
Log:
Fix OMPT state maintenance for barriers and missing init of implicit task id.
Fix OMPT support for barriers so that state changes occur even if OMPT_TRACE turned off.
These state changes are needed by performance tools that use callbacks for either
ompt_event_wait_barrier_begin or ompt_event_wait_barrier_end. Change ifdef flag to OMPT_BLAME
for callbacks ompt_event_wait_barrier_begin or ompt_event_wait_barrier_end rather than
OMPT_TRACE -- they were misclassified. Without this patch, when the runtime is compiled with
LIBOMP_OMPT_SUPPORT=true, LIBOMP_OMPT_BLAME=true, and LIBOMP_OMPT_TRACE=false, and a callback
is registered for either ompt_event_wait_barrier_begin or ompt_event_wait_barrier_end, then an
assertion will trip. Fix the scoping of one OMPT_TRACE ifdef, which should not have surrounded
an update of an OMPT state. Add a missing initialization of an OMPT task id for an implicit task.
Patch by John Mellor-Crummey
Differential Revision: http://reviews.llvm.org/D10759
Modified:
openmp/trunk/runtime/src/kmp_barrier.cpp
openmp/trunk/runtime/src/kmp_runtime.c
Modified: openmp/trunk/runtime/src/kmp_barrier.cpp
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_barrier.cpp?rev=240970&r1=240969&r2=240970&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_barrier.cpp (original)
+++ openmp/trunk/runtime/src/kmp_barrier.cpp Mon Jun 29 12:28:57 2015
@@ -1049,26 +1049,31 @@ __kmp_barrier(enum barrier_type bt, int
KA_TRACE(15, ("__kmp_barrier: T#%d(%d:%d) has arrived\n",
gtid, __kmp_team_from_gtid(gtid)->t.t_id, __kmp_tid_from_gtid(gtid)));
-#if OMPT_SUPPORT && OMPT_TRACE
+#if OMPT_SUPPORT
if (ompt_status & ompt_status_track) {
+#if OMPT_BLAME
if (ompt_status == ompt_status_track_callback) {
my_task_id = team->t.t_implicit_task_taskdata[tid].ompt_task_info.task_id;
my_parallel_id = team->t.ompt_team_info.parallel_id;
+#if OMPT_TRACE
if (this_thr->th.ompt_thread_info.state == ompt_state_wait_single) {
if (ompt_callbacks.ompt_callback(ompt_event_single_others_end)) {
ompt_callbacks.ompt_callback(ompt_event_single_others_end)(
my_parallel_id, my_task_id);
}
}
- this_thr->th.ompt_thread_info.state = ompt_state_wait_barrier;
+#endif
if (ompt_callbacks.ompt_callback(ompt_event_barrier_begin)) {
ompt_callbacks.ompt_callback(ompt_event_barrier_begin)(
my_parallel_id, my_task_id);
}
- } else {
- this_thr->th.ompt_thread_info.state = ompt_state_wait_barrier;
- }
+ }
+#endif
+ // It is OK to report the barrier state after the barrier begin callback.
+ // According to the OMPT specification, a compliant implementation may
+ // even delay reporting this state until the barrier begins to wait.
+ this_thr->th.ompt_thread_info.state = ompt_state_wait_barrier;
}
#endif
@@ -1261,7 +1266,7 @@ __kmp_barrier(enum barrier_type bt, int
#if OMPT_SUPPORT
if (ompt_status & ompt_status_track) {
-#if OMPT_TRACE
+#if OMPT_BLAME
if ((ompt_status == ompt_status_track_callback) &&
ompt_callbacks.ompt_callback(ompt_event_barrier_end)) {
ompt_callbacks.ompt_callback(ompt_event_barrier_end)(
@@ -1363,13 +1368,15 @@ __kmp_join_barrier(int gtid)
KMP_DEBUG_ASSERT(this_thr == team->t.t_threads[tid]);
KA_TRACE(10, ("__kmp_join_barrier: T#%d(%d:%d) arrived at join barrier\n", gtid, team_id, tid));
-#if OMPT_SUPPORT && OMPT_TRACE
+#if OMPT_SUPPORT
+#if OMPT_TRACE
if ((ompt_status == ompt_status_track_callback) &&
ompt_callbacks.ompt_callback(ompt_event_barrier_begin)) {
ompt_callbacks.ompt_callback(ompt_event_barrier_begin)(
team->t.ompt_team_info.parallel_id,
team->t.t_implicit_task_taskdata[tid].ompt_task_info.task_id);
}
+#endif
this_thr->th.ompt_thread_info.state = ompt_state_wait_barrier;
#endif
Modified: openmp/trunk/runtime/src/kmp_runtime.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_runtime.c?rev=240970&r1=240969&r2=240970&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_runtime.c (original)
+++ openmp/trunk/runtime/src/kmp_runtime.c Mon Jun 29 12:28:57 2015
@@ -5521,6 +5521,10 @@ __kmp_launch_thread( kmp_info_t *this_th
#if OMPT_SUPPORT
if (ompt_status & ompt_status_track) {
this_thr->th.ompt_thread_info.state = ompt_state_work_parallel;
+ // Initialize OMPT task id for implicit task.
+ int tid = __kmp_tid_from_gtid(gtid);
+ (*pteam)->t.t_implicit_task_taskdata[tid].ompt_task_info.task_id =
+ __ompt_task_id_new(tid);
}
#endif
More information about the Openmp-commits
mailing list