Skip to content

Commit 16d5836

Browse files
committed
Revisit OPDI_SINGLE* macros.
Add OPDI_SINGLE_COPYPRIVATE, OPDI_SINGLE_COPYPRIVATE_NOWAIT. Consistency changes for single macros. Add SingleCopyprivateNowait testcase. Merge branch 'revisit/single' into develop
2 parents d41c56c + 3d56395 commit 16d5836

14 files changed

Lines changed: 339 additions & 11 deletions

include/opdi/backend/macro/macros.hpp

Lines changed: 55 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,43 +64,88 @@
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); \
98+
/* broadcast-related barrier */ \
6999
opdi::logic->onSyncRegion(opdi::LogicInterface::SyncRegionKind::BarrierImplementation, \
70100
opdi::LogicInterface::ScopeEndpoint::Begin); \
101+
opdi::logic->onSyncRegion(opdi::LogicInterface::SyncRegionKind::BarrierImplementation, \
102+
opdi::LogicInterface::ScopeEndpoint::End); \
71103
void* opdiInternalTapePosition2 = opdi::tool->allocPosition(); \
72104
opdi::tool->getTapePosition(opdi::tool->getThreadLocalTape(), opdiInternalTapePosition2); \
73105
opdi::ImplicitBarrierTools::beginRegionWithImplicitBarrier(); \
74106
{ \
75-
opdi::SingleProbe localSingleProbe; \
107+
opdi::SingleProbe localSingleProbe; /* worksharing events */ \
76108
OPDI_PRAGMA(omp single __VA_ARGS__) \
77109
{ \
110+
/* delay broadcast-related barrier for executor */ \
78111
opdi::tool->erase(opdi::tool->getThreadLocalTape(), opdiInternalTapePosition1, opdiInternalTapePosition2);
79112

80-
#define OPDI_SINGLE_NOWAIT(...) \
113+
#define OPDI_SINGLE_COPYPRIVATE_NOWAIT(...) \
81114
{ \
82115
bool constexpr opdiInternalBarrierIndicator = false; \
116+
bool constexpr opdiInternalBroadcastIndicator = true; \
83117
void* opdiInternalTapePosition1 = opdi::tool->allocPosition(); \
84-
void* opdiInternalTapePosition2 = opdi::tool->allocPosition(); /* for consistency with the end macro */ \
85118
opdi::tool->getTapePosition(opdi::tool->getThreadLocalTape(), opdiInternalTapePosition1); \
119+
/* broadcast-related barrier */ \
86120
opdi::logic->onSyncRegion(opdi::LogicInterface::SyncRegionKind::BarrierImplementation, \
87121
opdi::LogicInterface::ScopeEndpoint::Begin); \
122+
opdi::logic->onSyncRegion(opdi::LogicInterface::SyncRegionKind::BarrierImplementation, \
123+
opdi::LogicInterface::ScopeEndpoint::End); \
124+
void* opdiInternalTapePosition2 = opdi::tool->allocPosition(); \
125+
opdi::tool->getTapePosition(opdi::tool->getThreadLocalTape(), opdiInternalTapePosition2); \
88126
opdi::ImplicitBarrierTools::beginRegionWithImplicitBarrier(); \
89127
{ \
90128
opdi::SingleProbe localSingleProbe; \
91129
OPDI_PRAGMA(omp single nowait __VA_ARGS__) \
92130
{ \
93-
opdi::tool->reset(opdi::tool->getThreadLocalTape(), opdiInternalTapePosition1);
131+
/* delay broadcast-related barrier for executor */ \
132+
opdi::tool->erase(opdi::tool->getThreadLocalTape(), opdiInternalTapePosition1, opdiInternalTapePosition2);
94133

95134
#define OPDI_END_SINGLE \
96-
opdi::logic->onSyncRegion(opdi::LogicInterface::SyncRegionKind::BarrierImplementation, \
97-
opdi::LogicInterface::ScopeEndpoint::Begin); \
135+
/* broadcast-related barrier */ \
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+
} \
98142
} \
99-
opdi::logic->onSyncRegion(opdi::LogicInterface::SyncRegionKind::BarrierImplementation, \
100-
opdi::LogicInterface::ScopeEndpoint::End); \
101143
} \
102-
opdi::tool->freePosition(opdiInternalTapePosition1); \
103-
opdi::tool->freePosition(opdiInternalTapePosition2); \
144+
if (opdiInternalBroadcastIndicator) { \
145+
opdi::tool->freePosition(opdiInternalTapePosition1); \
146+
opdi::tool->freePosition(opdiInternalTapePosition2); \
147+
} \
148+
/* implicit barrier */ \
104149
opdi::ImplicitBarrierTools::implicitBarrierStack.top() = opdiInternalBarrierIndicator; \
105150
opdi::ImplicitBarrierTools::endRegionWithImplicitBarrier(); \
106151
}

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",
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Point 0 :
2+
504.058
3+
-2995.59
4+
12478.8
5+
-7023.06
6+
2306.68
7+
Point 1 :
8+
525.989
9+
-5603.59
10+
-66981.3
11+
-80166.6
12+
-2712.39
13+
Point 2 :
14+
415.495
15+
2920.65
16+
43411
17+
31465.3
18+
34829.2
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Point 0 :
2+
504.058
3+
-2995.59
4+
12478.8
5+
-7023.06
6+
2306.68
7+
Point 1 :
8+
525.989
9+
-5603.59
10+
-66981.3
11+
-80166.6
12+
-2712.39
13+
Point 2 :
14+
415.495
15+
2920.65
16+
43411
17+
31465.3
18+
34829.2
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Point 0 :
2+
504.058
3+
-2995.59
4+
12478.8
5+
-7023.06
6+
2306.68
7+
Point 1 :
8+
525.989
9+
-5603.59
10+
-66981.3
11+
-80166.6
12+
-2712.39
13+
Point 2 :
14+
415.495
15+
2920.65
16+
43411
17+
31465.3
18+
34829.2
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Point 0 :
2+
504.058
3+
0
4+
0
5+
0
6+
0
7+
Point 1 :
8+
525.989
9+
0
10+
0
11+
0
12+
0
13+
Point 2 :
14+
415.495
15+
0
16+
0
17+
0
18+
0
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Point 0 :
2+
504.058
3+
-2995.59
4+
12478.8
5+
-7023.06
6+
2306.68
7+
Point 1 :
8+
525.989
9+
-5603.59
10+
-66981.3
11+
-80166.6
12+
-2712.39
13+
Point 2 :
14+
415.495
15+
2920.65
16+
43411
17+
31465.3
18+
34829.2

0 commit comments

Comments
 (0)