[Openmp-commits] [openmp] r355140 - [OpenMP][OMPT] Distinguish different barrier kinds
Jonathan Peyton via Openmp-commits
openmp-commits at lists.llvm.org
Thu Feb 28 12:55:39 PST 2019
Author: jlpeyton
Date: Thu Feb 28 12:55:39 2019
New Revision: 355140
URL: http://llvm.org/viewvc/llvm-project?rev=355140&view=rev
Log:
[OpenMP][OMPT] Distinguish different barrier kinds
This change makes the runtime decide the intended use of each barrier
invocation, for the OMPT synchronization tool callbacks. The OpenMP 5.0
specification defines four possible barrier kinds -- implicit, explicit,
implementation, and just normal barrier.
Patch by Hansang Bae
Differential Revision: https://reviews.llvm.org/D58247
Modified:
openmp/trunk/runtime/src/kmp_barrier.cpp
openmp/trunk/runtime/src/kmp_runtime.cpp
openmp/trunk/runtime/src/kmp_wait_release.h
openmp/trunk/runtime/src/ompt-specific.cpp
openmp/trunk/runtime/src/ompt-specific.h
openmp/trunk/runtime/test/ompt/synchronization/barrier/implicit_task_data.c
Modified: openmp/trunk/runtime/src/kmp_barrier.cpp
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_barrier.cpp?rev=355140&r1=355139&r2=355140&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_barrier.cpp (original)
+++ openmp/trunk/runtime/src/kmp_barrier.cpp Thu Feb 28 12:55:39 2019
@@ -1297,6 +1297,7 @@ static int __kmp_barrier_template(enum b
ompt_data_t *my_task_data;
ompt_data_t *my_parallel_data;
void *return_address;
+ ompt_sync_region_t barrier_kind;
#endif
KA_TRACE(15, ("__kmp_barrier: T#%d(%d:%d) has arrived\n", gtid,
@@ -1309,15 +1310,16 @@ static int __kmp_barrier_template(enum b
my_task_data = OMPT_CUR_TASK_DATA(this_thr);
my_parallel_data = OMPT_CUR_TEAM_DATA(this_thr);
return_address = OMPT_LOAD_RETURN_ADDRESS(gtid);
+ barrier_kind = __ompt_get_barrier_kind(bt, this_thr);
if (ompt_enabled.ompt_callback_sync_region) {
ompt_callbacks.ompt_callback(ompt_callback_sync_region)(
- ompt_sync_region_barrier, ompt_scope_begin, my_parallel_data,
- my_task_data, return_address);
+ barrier_kind, ompt_scope_begin, my_parallel_data, my_task_data,
+ return_address);
}
if (ompt_enabled.ompt_callback_sync_region_wait) {
ompt_callbacks.ompt_callback(ompt_callback_sync_region_wait)(
- ompt_sync_region_barrier, ompt_scope_begin, my_parallel_data,
- my_task_data, return_address);
+ barrier_kind, ompt_scope_begin, my_parallel_data, my_task_data,
+ return_address);
}
#endif
// It is OK to report the barrier state after the barrier begin callback.
@@ -1575,13 +1577,13 @@ static int __kmp_barrier_template(enum b
#if OMPT_OPTIONAL
if (ompt_enabled.ompt_callback_sync_region_wait) {
ompt_callbacks.ompt_callback(ompt_callback_sync_region_wait)(
- ompt_sync_region_barrier, ompt_scope_end, my_parallel_data,
- my_task_data, return_address);
+ barrier_kind, ompt_scope_end, my_parallel_data, my_task_data,
+ return_address);
}
if (ompt_enabled.ompt_callback_sync_region) {
ompt_callbacks.ompt_callback(ompt_callback_sync_region)(
- ompt_sync_region_barrier, ompt_scope_end, my_parallel_data,
- my_task_data, return_address);
+ barrier_kind, ompt_scope_end, my_parallel_data, my_task_data,
+ return_address);
}
#endif
this_thr->th.ompt_thread_info.state = ompt_state_work_parallel;
@@ -1729,12 +1731,12 @@ void __kmp_join_barrier(int gtid) {
my_parallel_data = OMPT_CUR_TEAM_DATA(this_thr);
if (ompt_enabled.ompt_callback_sync_region) {
ompt_callbacks.ompt_callback(ompt_callback_sync_region)(
- ompt_sync_region_barrier, ompt_scope_begin, my_parallel_data,
+ ompt_sync_region_barrier_implicit, ompt_scope_begin, my_parallel_data,
my_task_data, codeptr);
}
if (ompt_enabled.ompt_callback_sync_region_wait) {
ompt_callbacks.ompt_callback(ompt_callback_sync_region_wait)(
- ompt_sync_region_barrier, ompt_scope_begin, my_parallel_data,
+ ompt_sync_region_barrier_implicit, ompt_scope_begin, my_parallel_data,
my_task_data, codeptr);
}
if (!KMP_MASTER_TID(ds_tid))
@@ -2017,11 +2019,13 @@ void __kmp_fork_barrier(int gtid, int ti
codeptr = team->t.ompt_team_info.master_return_address;
if (ompt_enabled.ompt_callback_sync_region_wait) {
ompt_callbacks.ompt_callback(ompt_callback_sync_region_wait)(
- ompt_sync_region_barrier, ompt_scope_end, NULL, task_data, codeptr);
+ ompt_sync_region_barrier_implicit, ompt_scope_end, NULL, task_data,
+ codeptr);
}
if (ompt_enabled.ompt_callback_sync_region) {
ompt_callbacks.ompt_callback(ompt_callback_sync_region)(
- ompt_sync_region_barrier, ompt_scope_end, NULL, task_data, codeptr);
+ ompt_sync_region_barrier_implicit, ompt_scope_end, NULL, task_data,
+ codeptr);
}
#endif
if (!KMP_MASTER_TID(ds_tid) && ompt_enabled.ompt_callback_implicit_task) {
Modified: openmp/trunk/runtime/src/kmp_runtime.cpp
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_runtime.cpp?rev=355140&r1=355139&r2=355140&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_runtime.cpp (original)
+++ openmp/trunk/runtime/src/kmp_runtime.cpp Thu Feb 28 12:55:39 2019
@@ -7370,11 +7370,13 @@ void __kmp_internal_join(ident_t *id, in
if (ompt_enabled.ompt_callback_sync_region_wait) {
ompt_callbacks.ompt_callback(ompt_callback_sync_region_wait)(
- ompt_sync_region_barrier, ompt_scope_end, NULL, task_data, codeptr);
+ ompt_sync_region_barrier_implicit, ompt_scope_end, NULL, task_data,
+ codeptr);
}
if (ompt_enabled.ompt_callback_sync_region) {
ompt_callbacks.ompt_callback(ompt_callback_sync_region)(
- ompt_sync_region_barrier, ompt_scope_end, NULL, task_data, codeptr);
+ ompt_sync_region_barrier_implicit, ompt_scope_end, NULL, task_data,
+ codeptr);
}
#endif
if (!KMP_MASTER_TID(ds_tid) && ompt_enabled.ompt_callback_implicit_task) {
Modified: openmp/trunk/runtime/src/kmp_wait_release.h
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_wait_release.h?rev=355140&r1=355139&r2=355140&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_wait_release.h (original)
+++ openmp/trunk/runtime/src/kmp_wait_release.h Thu Feb 28 12:55:39 2019
@@ -129,11 +129,13 @@ static void __ompt_implicit_task_end(kmp
void *codeptr = NULL;
if (ompt_enabled.ompt_callback_sync_region_wait) {
ompt_callbacks.ompt_callback(ompt_callback_sync_region_wait)(
- ompt_sync_region_barrier, ompt_scope_end, NULL, tId, codeptr);
+ ompt_sync_region_barrier_implicit, ompt_scope_end, NULL, tId,
+ codeptr);
}
if (ompt_enabled.ompt_callback_sync_region) {
ompt_callbacks.ompt_callback(ompt_callback_sync_region)(
- ompt_sync_region_barrier, ompt_scope_end, NULL, tId, codeptr);
+ ompt_sync_region_barrier_implicit, ompt_scope_end, NULL, tId,
+ codeptr);
}
#endif
if (!KMP_MASTER_TID(ds_tid)) {
Modified: openmp/trunk/runtime/src/ompt-specific.cpp
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/ompt-specific.cpp?rev=355140&r1=355139&r2=355140&view=diff
==============================================================================
--- openmp/trunk/runtime/src/ompt-specific.cpp (original)
+++ openmp/trunk/runtime/src/ompt-specific.cpp Thu Feb 28 12:55:39 2019
@@ -448,3 +448,25 @@ static uint64_t __ompt_get_unique_id_int
}
return ++ID;
}
+
+ompt_sync_region_t __ompt_get_barrier_kind(enum barrier_type bt,
+ kmp_info_t *thr) {
+ if (bt == bs_forkjoin_barrier)
+ return ompt_sync_region_barrier_implicit;
+
+ if (bt != bs_plain_barrier)
+ return ompt_sync_region_barrier_implementation;
+
+ if (!thr->th.th_ident)
+ return ompt_sync_region_barrier;
+
+ kmp_int32 flags = thr->th.th_ident->flags;
+
+ if ((flags & KMP_IDENT_BARRIER_EXPL) != 0)
+ return ompt_sync_region_barrier_explicit;
+
+ if ((flags & KMP_IDENT_BARRIER_IMPL) != 0)
+ return ompt_sync_region_barrier_implicit;
+
+ return ompt_sync_region_barrier_implementation;
+}
Modified: openmp/trunk/runtime/src/ompt-specific.h
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/ompt-specific.h?rev=355140&r1=355139&r2=355140&view=diff
==============================================================================
--- openmp/trunk/runtime/src/ompt-specific.h (original)
+++ openmp/trunk/runtime/src/ompt-specific.h Thu Feb 28 12:55:39 2019
@@ -50,6 +50,8 @@ ompt_data_t *__ompt_get_thread_data_inte
static uint64_t __ompt_get_get_unique_id_internal();
*/
+ompt_sync_region_t __ompt_get_barrier_kind(enum barrier_type, kmp_info_t *);
+
/*****************************************************************************
* macros
****************************************************************************/
Modified: openmp/trunk/runtime/test/ompt/synchronization/barrier/implicit_task_data.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/test/ompt/synchronization/barrier/implicit_task_data.c?rev=355140&r1=355139&r2=355140&view=diff
==============================================================================
--- openmp/trunk/runtime/test/ompt/synchronization/barrier/implicit_task_data.c (original)
+++ openmp/trunk/runtime/test/ompt/synchronization/barrier/implicit_task_data.c Thu Feb 28 12:55:39 2019
@@ -80,11 +80,11 @@ on_ompt_callback_sync_region(
{
case ompt_scope_begin:
task_data->value = ompt_get_unique_id();
- if(kind == ompt_sync_region_barrier)
+ if (kind == ompt_sync_region_barrier_implicit)
printf("%" PRIu64 ": ompt_event_barrier_begin: parallel_id=%" PRIu64 ", task_id=%" PRIu64 ", codeptr_ra=%p\n", ompt_get_thread_data()->value, parallel_data->value, task_data->value, codeptr_ra);
break;
case ompt_scope_end:
- if(kind == ompt_sync_region_barrier)
+ if (kind == ompt_sync_region_barrier_implicit)
printf("%" PRIu64 ": ompt_event_barrier_end: parallel_id=%" PRIu64 ", task_id=%" PRIu64 ", codeptr_ra=%p\n", ompt_get_thread_data()->value, (parallel_data)?parallel_data->value:0, task_data->value, codeptr_ra);
break;
}
@@ -101,11 +101,15 @@ on_ompt_callback_sync_region_wait(
switch(endpoint)
{
case ompt_scope_begin:
- if(kind == ompt_sync_region_barrier)
- printf("%" PRIu64 ": ompt_event_wait_barrier_begin: parallel_id=%" PRIu64 ", task_id=%" PRIu64 ", codeptr_ra=%p\n", ompt_get_thread_data()->value, parallel_data->value, task_data->value, codeptr_ra);
+ if (kind == ompt_sync_region_barrier_implicit)
+ printf("%" PRIu64
+ ": ompt_event_wait_barrier_begin: parallel_id=%" PRIu64
+ ", task_id=%" PRIu64 ", codeptr_ra=%p\n",
+ ompt_get_thread_data()->value, parallel_data->value,
+ task_data->value, codeptr_ra);
break;
case ompt_scope_end:
- if(kind == ompt_sync_region_barrier)
+ if (kind == ompt_sync_region_barrier_implicit)
printf("%" PRIu64 ": ompt_event_wait_barrier_end: parallel_id=%" PRIu64 ", task_id=%" PRIu64 ", codeptr_ra=%p\n", ompt_get_thread_data()->value, (parallel_data)?parallel_data->value:0, task_data->value, codeptr_ra);
break;
}
More information about the Openmp-commits
mailing list