summaryrefslogtreecommitdiffstats
path: root/openmp
diff options
context:
space:
mode:
authorJonathan Peyton <jonathan.l.peyton@intel.com>2019-02-28 20:55:39 +0000
committerJonathan Peyton <jonathan.l.peyton@intel.com>2019-02-28 20:55:39 +0000
commitad1ad7ae8be3807202669619dc2d9aa3dc650215 (patch)
tree5cc4278e3057d941359e0a8b096c61248bf9a6f1 /openmp
parent12b75594ed86d67b909bf1e6b0429ecdde6a4547 (diff)
downloadbcm5719-llvm-ad1ad7ae8be3807202669619dc2d9aa3dc650215.tar.gz
bcm5719-llvm-ad1ad7ae8be3807202669619dc2d9aa3dc650215.zip
[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 llvm-svn: 355140
Diffstat (limited to 'openmp')
-rw-r--r--openmp/runtime/src/kmp_barrier.cpp28
-rw-r--r--openmp/runtime/src/kmp_runtime.cpp6
-rw-r--r--openmp/runtime/src/kmp_wait_release.h6
-rw-r--r--openmp/runtime/src/ompt-specific.cpp22
-rw-r--r--openmp/runtime/src/ompt-specific.h2
-rw-r--r--openmp/runtime/test/ompt/synchronization/barrier/implicit_task_data.c14
6 files changed, 57 insertions, 21 deletions
diff --git a/openmp/runtime/src/kmp_barrier.cpp b/openmp/runtime/src/kmp_barrier.cpp
index ecb115ad523..0fd96e7b9b8 100644
--- a/openmp/runtime/src/kmp_barrier.cpp
+++ b/openmp/runtime/src/kmp_barrier.cpp
@@ -1297,6 +1297,7 @@ static int __kmp_barrier_template(enum barrier_type bt, int gtid, int is_split,
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 barrier_type bt, int gtid, int is_split,
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 barrier_type bt, int gtid, int is_split,
#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 tid) {
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) {
diff --git a/openmp/runtime/src/kmp_runtime.cpp b/openmp/runtime/src/kmp_runtime.cpp
index e6b673b425d..2d337b46370 100644
--- a/openmp/runtime/src/kmp_runtime.cpp
+++ b/openmp/runtime/src/kmp_runtime.cpp
@@ -7370,11 +7370,13 @@ void __kmp_internal_join(ident_t *id, int gtid, kmp_team_t *team) {
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) {
diff --git a/openmp/runtime/src/kmp_wait_release.h b/openmp/runtime/src/kmp_wait_release.h
index d1120d45600..048e74e8680 100644
--- a/openmp/runtime/src/kmp_wait_release.h
+++ b/openmp/runtime/src/kmp_wait_release.h
@@ -129,11 +129,13 @@ static void __ompt_implicit_task_end(kmp_info_t *this_thr,
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)) {
diff --git a/openmp/runtime/src/ompt-specific.cpp b/openmp/runtime/src/ompt-specific.cpp
index acd23896f18..f65048f3b00 100644
--- a/openmp/runtime/src/ompt-specific.cpp
+++ b/openmp/runtime/src/ompt-specific.cpp
@@ -448,3 +448,25 @@ static uint64_t __ompt_get_unique_id_internal() {
}
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;
+}
diff --git a/openmp/runtime/src/ompt-specific.h b/openmp/runtime/src/ompt-specific.h
index 25901df01e5..86fd928d037 100644
--- a/openmp/runtime/src/ompt-specific.h
+++ b/openmp/runtime/src/ompt-specific.h
@@ -50,6 +50,8 @@ ompt_data_t *__ompt_get_thread_data_internal();
static uint64_t __ompt_get_get_unique_id_internal();
*/
+ompt_sync_region_t __ompt_get_barrier_kind(enum barrier_type, kmp_info_t *);
+
/*****************************************************************************
* macros
****************************************************************************/
diff --git a/openmp/runtime/test/ompt/synchronization/barrier/implicit_task_data.c b/openmp/runtime/test/ompt/synchronization/barrier/implicit_task_data.c
index c933e8925d5..71c2b154065 100644
--- a/openmp/runtime/test/ompt/synchronization/barrier/implicit_task_data.c
+++ b/openmp/runtime/test/ompt/synchronization/barrier/implicit_task_data.c
@@ -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;
}
OpenPOWER on IntegriCloud