Skip to content

Commit 0602053

Browse files
committed
OMPT backend: configurable source of ImplicitTaskEnd event.
Optionally use barrier-related execution model events. Merge branch 'feature/configurableImplicitTaskEnd' into develop
2 parents 6c93d51 + a89a279 commit 0602053

4 files changed

Lines changed: 42 additions & 7 deletions

File tree

.gitlab-ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,17 @@ clang-macro:
2727

2828
clang-ompt:
2929
image: fedora:41
30+
parallel:
31+
matrix:
32+
- FLAGS: ["-DOPDI_OMPT_BACKEND_IMPLICIT_TASK_END_SOURCE=1", "-DOPDI_OMPT_BACKEND_IMPLICIT_TASK_END_SOURCE=2"]
3033
script:
3134
- dnf install -y diffutils binutils clang git
3235
- git clone --depth 1 --branch develop https://github.com/SciCompKL/CoDiPack.git
3336
- export CODI_DIR=$(pwd)/CoDiPack/include
3437
- export OPDI_DIR=$(pwd)/include
3538
- cd tests
3639
- export CXX=clang++
40+
- export CXXFLAGS="$FLAGS"
3741
- export BACKEND=OMPT
3842
- make all
3943

include/opdi/backend/ompt/implicitTaskCallbacks.hpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <omp.h>
3030
#include <omp-tools.h>
3131

32+
#include "../../config.hpp"
3233
#include "../../helpers/exceptions.hpp"
3334
#include "../../helpers/macros.hpp"
3435
#include "../../logic/logicInterface.hpp"
@@ -60,7 +61,12 @@ namespace opdi {
6061
taskData->ptr = logic->onImplicitTaskBegin(false, actualParallelism, index, parallelData->ptr);
6162
}
6263
else {
63-
logic->onImplicitTaskEnd(taskData->ptr);
64+
#if OPDI_OMPT_BACKEND_IMPLICIT_TASK_END_SOURCE == OPDI_OMPT_IMPLICIT_TASK_END
65+
logic->onImplicitTaskEnd(taskData->ptr);
66+
#else
67+
if (index == 0) // master thread always produces ImplicitTaskEnd here
68+
logic->onImplicitTaskEnd(taskData->ptr);
69+
#endif
6470
}
6571
}
6672

include/opdi/backend/ompt/syncRegionCallbacks.hpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,12 @@ namespace opdi {
5050
void const* codeptr) {
5151

5252
OPDI_UNUSED(parallelData);
53-
OPDI_UNUSED(taskData);
5453
OPDI_UNUSED(codeptr);
5554

55+
#if OPDI_OMPT_BACKEND_IMPLICIT_TASK_END_SOURCE != OPDI_SYNC_REGION_END
56+
OPDI_UNUSED(taskData);
57+
#endif
58+
5659
LogicInterface::ScopeEndpoint endpoint;
5760
if (ompt_scope_begin == _endpoint) {
5861
endpoint = LogicInterface::ScopeEndpoint::Begin;
@@ -79,11 +82,18 @@ namespace opdi {
7982
case ompt_sync_region_barrier_implementation:
8083
logic->onSyncRegion(LogicInterface::SyncRegionKind::BarrierImplementation, endpoint);
8184
break;
82-
#if _OPENMP >= 202011
85+
#if _OPENMP >= 202011
8386
case ompt_sync_region_barrier_implicit_parallel:
84-
#else // fallback for compilers with _OPENMP < 202011 that already support fine-grained sync region types
87+
#else // fallback for compilers with _OPENMP < 202011 that already support fine-grained sync region types
8588
case 9: // ompt_sync_region_barrier_implicit_parallel
86-
#endif
89+
#endif
90+
// implicit barriers on parallel regions themselves do not require treatment
91+
// however, we optionally use this to generate ImplicitTaskEnd events of non-master threads
92+
#if OPDI_OMPT_BACKEND_IMPLICIT_TASK_END_SOURCE == OPDI_OMPT_SYNC_REGION_END
93+
if (LogicInterface::ScopeEndpoint::Begin == endpoint && omp_get_thread_num() != 0) {
94+
opdi::logic->onImplicitTaskEnd(taskData->ptr);
95+
}
96+
#endif
8797
break; // no treatment needed
8898
case ompt_sync_region_reduction: // does not occur in this callback
8999
OPDI_WARNING("Unexpected kind argument ompt_sync_region_reduction.");

include/opdi/config.hpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,24 @@
3939
#define OPDI_SCOPE_ENDPOINT_END 2
4040
#define OPDI_SCOPE_ENDPOINT_BOTH 3
4141

42+
#define OPDI_OMPT_IMPLICIT_TASK_END 1
43+
#define OPDI_OMPT_SYNC_REGION_END 2
44+
4245
/* ------------------ configuration ------------------ */
4346

44-
/* logic options */
47+
/* ----- backend configuration ----- */
48+
49+
#ifndef OPDI_OMPT_BACKEND_IMPLICIT_TASK_END_SOURCE
50+
#define OPDI_OMPT_BACKEND_IMPLICIT_TASK_END_SOURCE OPDI_OMPT_IMPLICIT_TASK_END
51+
#endif
52+
53+
static_assert(0 < OPDI_OMPT_BACKEND_IMPLICIT_TASK_END_SOURCE);
54+
static_assert(OPDI_OMPT_BACKEND_IMPLICIT_TASK_END_SOURCE <= 2);
55+
56+
57+
/* ----- logic configuration ----- */
58+
59+
/* general logic options */
4560

4661
#ifndef OPDI_OMP_LOGIC_INSTRUMENT
4762
#define OPDI_OMP_LOGIC_INSTRUMENT 0
@@ -95,7 +110,7 @@ static_assert(OPDI_SYNC_REGION_BARRIER_IMPLEMENTATION_BEHAVIOUR <= 3);
95110
static_assert(0 < OPDI_SYNC_REGION_BARRIER_REVERSE_BEHAVIOUR);
96111
static_assert(OPDI_SYNC_REGION_BARRIER_REVERSE_BEHAVIOUR <= 3);
97112

98-
/* error handling options */
113+
/* ----- error handling ----- */
99114

100115
#ifndef OPDI_ENABLE_WARNINGS
101116
#define OPDI_ENABLE_WARNINGS 1

0 commit comments

Comments
 (0)