Skip to content

Commit d41c56c

Browse files
committed
Support for the masked construct.
Refactor master -> masked througout OpDiLib. Backend support for the masked construct. Merge branch 'feature/masked' into develop
2 parents 204e992 + 70329e7 commit d41c56c

26 files changed

Lines changed: 129 additions & 54 deletions

.gitlab-ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ clang-macro:
1818
image: fedora:41
1919
parallel:
2020
matrix:
21-
- FLAGS: ["", "-DOPDI_BACKEND_GENERATE_MASTER_EVENTS=1 -DOPDI_BACKEND_GENERATE_WORK_EVENTS=1"]
21+
- FLAGS: ["", "-DOPDI_BACKEND_GENERATE_MASKED_EVENTS=1 -DOPDI_BACKEND_GENERATE_WORK_EVENTS=1"]
2222
script:
2323
- dnf install -y diffutils binutils clang git
2424
- git clone --depth 1 --branch develop https://github.com/SciCompKL/CoDiPack.git
@@ -32,7 +32,7 @@ clang-ompt:
3232
image: fedora:41
3333
parallel:
3434
matrix:
35-
- FLAGS: ["-DOPDI_OMPT_BACKEND_IMPLICIT_TASK_END_SOURCE=1", "-DOPDI_OMPT_BACKEND_IMPLICIT_TASK_END_SOURCE=2", "-DOPDI_BACKEND_GENERATE_MASTER_EVENTS=1 -DOPDI_BACKEND_GENERATE_WORK_EVENTS=1"]
35+
- FLAGS: ["-DOPDI_OMPT_BACKEND_IMPLICIT_TASK_END_SOURCE=1", "-DOPDI_OMPT_BACKEND_IMPLICIT_TASK_END_SOURCE=2", "-DOPDI_BACKEND_GENERATE_MASKED_EVENTS=1 -DOPDI_BACKEND_GENERATE_WORK_EVENTS=1"]
3636
script:
3737
- dnf install -y diffutils binutils clang git
3838
- git clone --depth 1 --branch develop https://github.com/SciCompKL/CoDiPack.git

include/opdi/backend/macro/macros.hpp

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,20 +145,34 @@
145145

146146
#define OPDI_END_SECTION
147147

148-
#if OPDI_BACKEND_GENERATE_MASTER_EVENTS
148+
#if OPDI_BACKEND_GENERATE_MASKED_EVENTS
149149
#define OPDI_MASTER(...) \
150150
OPDI_PRAGMA(omp master __VA_ARGS__) \
151151
{ \
152-
opdi::logic->onMaster(opdi::LogicInterface::ScopeEndpoint::Begin);
152+
opdi::logic->onMasked(opdi::LogicInterface::ScopeEndpoint::Begin);
153153

154154
#define OPDI_END_MASTER \
155-
opdi::logic->onMaster(opdi::LogicInterface::ScopeEndpoint::End); \
155+
opdi::logic->onMasked(opdi::LogicInterface::ScopeEndpoint::End); \
156+
}
157+
158+
#define OPDI_MASKED(...) \
159+
OPDI_PRAGMA(omp masked __VA_ARGS__) \
160+
{ \
161+
opdi::logic->onMasked(opdi::LogicInterface::ScopeEndpoint::Begin);
162+
163+
#define OPDI_END_MASKED \
164+
opdi::logic->onMasked(opdi::LogicInterface::ScopeEndpoint::End); \
156165
}
157166
#else
158167
#define OPDI_MASTER(...) \
159168
OPDI_PRAGMA(omp master __VA_ARGS__) \
160169

161-
#define OPDI_END_MASTER /* empty */
170+
#define OPDI_END_MASTER
171+
172+
#define OPDI_MASKED(...) \
173+
OPDI_PRAGMA(omp masked __VA_ARGS__) \
174+
175+
#define OPDI_END_MASKED
162176
#endif
163177

164178
// standalone macros

include/opdi/backend/ompt/macros.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@
7878

7979
#define OPDI_END_MASTER
8080

81+
#define OPDI_MASKED(...) \
82+
OPDI_PRAGMA(omp masked __VA_ARGS__)
83+
84+
#define OPDI_END_MASKED
85+
8186
#define OPDI_BARRIER(...) \
8287
OPDI_PRAGMA(omp barrier __VA_ARGS__)
8388

include/opdi/backend/ompt/masterCallbacks.hpp renamed to include/opdi/backend/ompt/maskedCallbacks.hpp

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@
3434

3535
namespace opdi {
3636

37-
struct MasterCallbacks : public virtual CallbacksBase {
37+
struct MaskedCallbacks : public virtual CallbacksBase {
3838

3939
private:
4040

41-
static void onMaster(ompt_scope_endpoint_t _endpoint,
41+
static void onMasked(ompt_scope_endpoint_t _endpoint,
4242
ompt_data_t* parallelData,
4343
ompt_data_t* taskData,
4444
void const* codeptr) {
@@ -54,18 +54,27 @@ namespace opdi {
5454
endpoint = LogicInterface::ScopeEndpoint::End;
5555
}
5656

57-
logic->onMaster(endpoint);
57+
logic->onMasked(endpoint);
5858
}
5959

6060
protected:
6161

6262
static void init() {
63-
OPDI_CHECK_ERROR(CallbacksBase::registerCallback(ompt_callback_master,
64-
(ompt_callback_t) MasterCallbacks::onMaster));
63+
#if _OPENMP >= 202011
64+
OPDI_CHECK_ERROR(CallbacksBase::registerCallback(ompt_callback_masked,
65+
(ompt_callback_t) MaskedCallbacks::onMasked));
66+
#else
67+
OPDI_CHECK_ERROR(CallbacksBase::registerCallback(ompt_callback_master,
68+
(ompt_callback_t) MaskedCallbacks::onMasked));
69+
#endif
6570
}
6671

6772
static void finalize() {
68-
OPDI_CHECK_ERROR(CallbacksBase::clearCallback(ompt_callback_master));
73+
#if _OPENMP >= 202011
74+
OPDI_CHECK_ERROR(CallbacksBase::clearCallback(ompt_callback_masked));
75+
#else
76+
OPDI_CHECK_ERROR(CallbacksBase::clearCallback(ompt_callback_master));
77+
#endif
6978
}
7079

7180
};

include/opdi/backend/ompt/omptBackend.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444

4545
#include "implicitTaskCallbacks.hpp"
4646
#include "macros.hpp"
47-
#include "masterCallbacks.hpp"
47+
#include "maskedCallbacks.hpp"
4848
#include "mutexCallbacks.hpp"
4949
#include "parallelCallbacks.hpp"
5050
#include "reductionCallbacks.hpp"
@@ -55,7 +55,7 @@
5555
namespace opdi {
5656

5757
struct OmptBackend : public ImplicitTaskCallbacks,
58-
public MasterCallbacks,
58+
public MaskedCallbacks,
5959
public MutexCallbacks,
6060
public ParallelCallbacks,
6161
public ReductionCallbacks,
@@ -107,8 +107,8 @@ namespace opdi {
107107
SyncRegionCallbacks::init();
108108
MutexCallbacks::init();
109109
ReductionCallbacks::init();
110-
#if OPDI_BACKEND_GENERATE_MASTER_EVENTS
111-
MasterCallbacks::init();
110+
#if OPDI_BACKEND_GENERATE_MASKED_EVENTS
111+
MaskedCallbacks::init();
112112
#endif
113113

114114
return 1; // success
@@ -119,8 +119,8 @@ namespace opdi {
119119
OPDI_UNUSED(toolData);
120120

121121
// finalize callback structures
122-
#if OPDI_BACKEND_GENERATE_MASTER_EVENTS
123-
MasterCallbacks::finalize();
122+
#if OPDI_BACKEND_GENERATE_MASKED_EVENTS
123+
MaskedCallbacks::finalize();
124124
#endif
125125
ReductionCallbacks::finalize();
126126
MutexCallbacks::finalize();

include/opdi/config.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@
4747

4848
/* ----- backend configuration ----- */
4949

50-
#ifndef OPDI_BACKEND_GENERATE_MASTER_EVENTS
51-
#define OPDI_BACKEND_GENERATE_MASTER_EVENTS 0
50+
#ifndef OPDI_BACKEND_GENERATE_MASKED_EVENTS
51+
#define OPDI_BACKEND_GENERATE_MASKED_EVENTS 0
5252
#endif
5353

5454
#ifndef OPDI_BACKEND_GENERATE_WORK_EVENTS

include/opdi/helpers/emptyMacros.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@
5454
#define OPDI_MASTER(...)
5555
#define OPDI_END_MASTER
5656

57+
#define OPDI_MASKED(...)
58+
#define OPDI_END_MASKED
59+
5760
#define OPDI_BARRIER(...)
5861

5962
#define OPDI_DECLARE_REDUCTION(...)

include/opdi/helpers/undefineMacros.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@
5252
#undef OPDI_MASTER
5353
#undef OPDI_END_MASTER
5454

55+
#undef OPDI_MASKED
56+
#undef OPDI_END_MASKED
57+
5558
#undef OPDI_BARRIER
5659

5760
#undef OPDI_DECLARE_REDUCTION

include/opdi/logic/logicInterface.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ namespace opdi {
7373

7474
virtual void onWork(WorksharingKind kind, ScopeEndpoint endpoint) = 0;
7575

76-
virtual void onMaster(ScopeEndpoint endpoint) = 0;
76+
virtual void onMasked(ScopeEndpoint endpoint) = 0;
7777

7878
virtual void onSyncRegion(SyncRegionKind kind, ScopeEndpoint endpoint) = 0;
7979

include/opdi/logic/omp/instrument/ompLogicInstrumentInterface.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
#include "../../logicInterface.hpp"
3232
#include "../implicitTaskOmpLogic.hpp"
33-
#include "../masterOmpLogic.hpp"
33+
#include "../maskedOmpLogic.hpp"
3434
#include "../mutexOmpLogic.hpp"
3535
#include "../parallelOmpLogic.hpp"
3636
#include "../syncRegionOmpLogic.hpp"
@@ -68,8 +68,8 @@ namespace opdi {
6868
virtual void reverseWork(WorkOmpLogic::Data* /*data*/) {}
6969
virtual void onWork(LogicInterface::WorksharingKind /*kind*/, LogicInterface::ScopeEndpoint /*endpoint*/) {}
7070

71-
virtual void reverseMaster(MasterOmpLogic::Data* /*data*/) {}
72-
virtual void onMaster(LogicInterface::ScopeEndpoint /*endpoint*/) {}
71+
virtual void reverseMasked(MaskedOmpLogic::Data* /*data*/) {}
72+
virtual void onMasked(LogicInterface::ScopeEndpoint /*endpoint*/) {}
7373

7474
virtual void onSetAdjointAccessMode(LogicInterface::AdjointAccessMode /*adjointAccess*/) {}
7575
};

0 commit comments

Comments
 (0)