Skip to content

Commit a180e83

Browse files
committed
Introduce dedicated OPDI_SINGLE_COPYPRIVATE and OPDI_SINGLE_COPYPRIVATE_NOWAIT macros.
Additions to syntax file. Adapt tests.
1 parent 9506e76 commit a180e83

6 files changed

Lines changed: 55 additions & 8 deletions

File tree

include/opdi/backend/macro/macros.hpp

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,35 @@
6464
#define OPDI_SINGLE(...) \
6565
{ \
6666
bool constexpr opdiInternalBarrierIndicator = true; \
67+
bool constexpr opdiInternalBroadcastIndicator = false; \
68+
void* opdiInternalTapePosition1; /* for consistency with the end macro */ \
69+
void* opdiInternalTapePosition2; \
70+
OPDI_UNUSED(opdiInternalTapePosition1); \
71+
OPDI_UNUSED(opdiInternalTapePosition2); \
72+
opdi::ImplicitBarrierTools::beginRegionWithImplicitBarrier(); \
73+
{ \
74+
opdi::SingleProbe localSingleProbe; /* worksharing events */ \
75+
OPDI_PRAGMA(omp single __VA_ARGS__) \
76+
{
77+
78+
#define OPDI_SINGLE_NOWAIT(...) \
79+
{ \
80+
bool constexpr opdiInternalBarrierIndicator = false; \
81+
bool constexpr opdiInternalBroadcastIndicator = false; \
82+
void* opdiInternalTapePosition1; /* for consistency with the end macro */ \
83+
void* opdiInternalTapePosition2; \
84+
OPDI_UNUSED(opdiInternalTapePosition1); \
85+
OPDI_UNUSED(opdiInternalTapePosition2); \
86+
opdi::ImplicitBarrierTools::beginRegionWithImplicitBarrier(); \
87+
{ \
88+
opdi::SingleProbe localSingleProbe; /* worksharing events */ \
89+
OPDI_PRAGMA(omp single nowait __VA_ARGS__) \
90+
{
91+
92+
#define OPDI_SINGLE_COPYPRIVATE(...) \
93+
{ \
94+
bool constexpr opdiInternalBarrierIndicator = true; \
95+
bool constexpr opdiInternalBroadcastIndicator = true; \
6796
void* opdiInternalTapePosition1 = opdi::tool->allocPosition(); \
6897
opdi::tool->getTapePosition(opdi::tool->getThreadLocalTape(), opdiInternalTapePosition1); \
6998
/* broadcast-related barrier */ \
@@ -81,9 +110,10 @@
81110
/* delay broadcast-related barrier for executor */ \
82111
opdi::tool->erase(opdi::tool->getThreadLocalTape(), opdiInternalTapePosition1, opdiInternalTapePosition2);
83112

84-
#define OPDI_SINGLE_NOWAIT(...) \
113+
#define OPDI_SINGLE_COPYPRIVATE_NOWAIT(...) \
85114
{ \
86115
bool constexpr opdiInternalBarrierIndicator = false; \
116+
bool constexpr opdiInternalBroadcastIndicator = true; \
87117
void* opdiInternalTapePosition1 = opdi::tool->allocPosition(); \
88118
opdi::tool->getTapePosition(opdi::tool->getThreadLocalTape(), opdiInternalTapePosition1); \
89119
/* broadcast-related barrier */ \
@@ -103,14 +133,18 @@
103133

104134
#define OPDI_END_SINGLE \
105135
/* broadcast-related barrier */ \
106-
opdi::logic->onSyncRegion(opdi::LogicInterface::SyncRegionKind::BarrierImplementation, \
107-
opdi::LogicInterface::ScopeEndpoint::Begin); \
108-
opdi::logic->onSyncRegion(opdi::LogicInterface::SyncRegionKind::BarrierImplementation, \
109-
opdi::LogicInterface::ScopeEndpoint::End); \
136+
if (opdiInternalBroadcastIndicator) { \
137+
opdi::logic->onSyncRegion(opdi::LogicInterface::SyncRegionKind::BarrierImplementation, \
138+
opdi::LogicInterface::ScopeEndpoint::Begin); \
139+
opdi::logic->onSyncRegion(opdi::LogicInterface::SyncRegionKind::BarrierImplementation, \
140+
opdi::LogicInterface::ScopeEndpoint::End); \
141+
} \
110142
} \
111143
} \
112-
opdi::tool->freePosition(opdiInternalTapePosition1); \
113-
opdi::tool->freePosition(opdiInternalTapePosition2); \
144+
if (opdiInternalBroadcastIndicator) { \
145+
opdi::tool->freePosition(opdiInternalTapePosition1); \
146+
opdi::tool->freePosition(opdiInternalTapePosition2); \
147+
} \
114148
/* implicit barrier */ \
115149
opdi::ImplicitBarrierTools::implicitBarrierStack.top() = opdiInternalBarrierIndicator; \
116150
opdi::ImplicitBarrierTools::endRegionWithImplicitBarrier(); \

include/opdi/backend/ompt/macros.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@
4848
#define OPDI_SINGLE_NOWAIT(...) \
4949
OPDI_PRAGMA(omp single nowait __VA_ARGS__)
5050

51+
#define OPDI_SINGLE_COPYPRIVATE(...) \
52+
OPDI_PRAGMA(omp single __VA_ARGS__)
53+
54+
#define OPDI_SINGLE_COPYPRIVATE_NOWAIT(...) \
55+
OPDI_PRAGMA(omp single nowait __VA_ARGS__)
56+
5157
#define OPDI_END_SINGLE
5258

5359
#define OPDI_NOWAIT nowait

include/opdi/helpers/emptyMacros.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636

3737
#define OPDI_SINGLE(...)
3838
#define OPDI_SINGLE_NOWAIT(...)
39+
#define OPDI_SINGLE_COPYPRIVATE(...)
40+
#define OPDI_SINGLE_COPYPRIVATE_NOWAIT(...)
3941
#define OPDI_END_SINGLE
4042

4143
#define OPDI_NOWAIT

include/opdi/helpers/undefineMacros.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434

3535
#undef OPDI_SINGLE
3636
#undef OPDI_SINGLE_NOWAIT
37+
#undef OPDI_SINGLE_COPYPRIVATE
38+
#undef OPDI_SINGLE_COPYPRIVATE_NOWAIT
3739
#undef OPDI_END_SINGLE
3840

3941
#undef OPDI_NOWAIT

syntax/opdi.syntax.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@
66
"OPDI_SECTIONS": "OPDI_END_SECTIONS",
77
"OPDI_SINGLE": "OPDI_END_SINGLE",
88
"OPDI_SINGLE_NOWAIT": "OPDI_END_SINGLE",
9+
"OPDI_SINGLE_COPYPRIVATE": "OPDI_END_SINGLE",
10+
"OPDI_SINGLE_COPYPRIVATE_NOWAIT": "OPDI_END_SINGLE",
911
"OPDI_CRITICAL": "OPDI_END_CRITICAL",
1012
"OPDI_CRITICAL_NAME": "OPDI_END_CRITICAL",
13+
"OPDI_CRITICAL_NAME_ARGS": "OPDI_END_CRITICAL",
1114
"OPDI_ORDERED": "OPDI_END_ORDERED",
1215
"OPDI_SECTION": "OPDI_END_SECTION",
1316
"OPDI_MASTER": "OPDI_END_MASTER",

tests/tests/TestSingleCopyprivate.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ struct TestSingleCopyprivate : public TestBase<4, 1, 3, TestSingleCopyprivate<_C
5353

5454
OPDI_BARRIER()
5555

56-
OPDI_SINGLE(copyprivate(helper))
56+
OPDI_SINGLE_COPYPRIVATE(copyprivate(helper))
5757
{
5858
for (int i = 0; i < N; ++i) {
5959
helper = sin(jobResults[i]);

0 commit comments

Comments
 (0)