|
27 | 27 |
|
28 | 28 | #include <omp.h> |
29 | 29 |
|
| 30 | +#include "../../config.hpp" |
30 | 31 | #include "../../helpers/macros.hpp" |
31 | 32 |
|
32 | 33 | #include "implicitBarrierTools.hpp" |
|
46 | 47 | opdi::logic->onParallelEnd(opdiInternalParallelData); \ |
47 | 48 | } |
48 | 49 |
|
| 50 | +#if OPDI_BACKEND_GENERATE_WORK_EVENTS |
| 51 | + #define OPDI_WORK(type, endpoint) opdi::logic->onWork(kind, endpoint) |
| 52 | +#else |
| 53 | + #define OPDI_WORK(type, endpoint) /* empty */ |
| 54 | +#endif |
| 55 | + |
49 | 56 | #define OPDI_FOR(...) \ |
50 | 57 | opdi::ImplicitBarrierTools::beginRegionWithImplicitBarrier(); \ |
| 58 | + OPDI_WORK(opdi::LogicInterface::WorksharingKind::Loop, opdi::LogicInterface::ScopeEndpoint::Begin); \ |
51 | 59 | OPDI_PRAGMA(omp for __VA_ARGS__ private(opdi::internalLoopProbe)) |
52 | 60 |
|
53 | 61 | #define OPDI_END_FOR \ |
| 62 | + OPDI_WORK(opdi::LogicInterface::WorksharingKind::Loop, opdi::LogicInterface::ScopeEndpoint::End); \ |
54 | 63 | opdi::ImplicitBarrierTools::endRegionWithImplicitBarrier(); |
55 | 64 |
|
56 | 65 | #define OPDI_SECTIONS(...) \ |
57 | 66 | opdi::ImplicitBarrierTools::beginRegionWithImplicitBarrier(); \ |
| 67 | + OPDI_WORK(opdi::LogicInterface::WorksharingKind::Sections, opdi::LogicInterface::ScopeEndpoint::Begin); \ |
58 | 68 | OPDI_PRAGMA(omp sections private(opdi::internalSectionsProbe) __VA_ARGS__) |
59 | 69 |
|
60 | 70 | #define OPDI_END_SECTIONS \ |
| 71 | + OPDI_WORK(opdi::LogicInterface::WorksharingKind::Sections, opdi::LogicInterface::ScopeEndpoint::End); \ |
61 | 72 | opdi::ImplicitBarrierTools::endRegionWithImplicitBarrier(); |
62 | 73 |
|
63 | 74 | #define OPDI_SINGLE(...) \ |
64 | 75 | { \ |
| 76 | + OPDI_WORK(opdi::LogicInterface::WorksharingKind::Single, opdi::LogicInterface::ScopeEndpoint::Begin); \ |
65 | 77 | bool constexpr opdiInternalBarrierIndicator = true; \ |
66 | 78 | void* opdiInternalTapePosition1 = opdi::tool->allocPosition(); \ |
67 | 79 | opdi::tool->getTapePosition(opdi::tool->getThreadLocalTape(), opdiInternalTapePosition1); \ |
|
78 | 90 |
|
79 | 91 | #define OPDI_SINGLE_NOWAIT(...) \ |
80 | 92 | { \ |
| 93 | + OPDI_WORK(opdi::LogicInterface::WorksharingKind::Single, opdi::LogicInterface::ScopeEndpoint::Begin); \ |
81 | 94 | bool constexpr opdiInternalBarrierIndicator = false; \ |
82 | 95 | void* opdiInternalTapePosition1 = opdi::tool->allocPosition(); \ |
83 | 96 | void* opdiInternalTapePosition2 = opdi::tool->allocPosition(); /* for consistency with the end macro */ \ |
|
100 | 113 | } \ |
101 | 114 | opdi::tool->freePosition(opdiInternalTapePosition1); \ |
102 | 115 | opdi::tool->freePosition(opdiInternalTapePosition2); \ |
| 116 | + OPDI_WORK(opdi::LogicInterface::WorksharingKind::Single, opdi::LogicInterface::ScopeEndpoint::End); \ |
103 | 117 | opdi::ImplicitBarrierTools::implicitBarrierStack.top() = opdiInternalBarrierIndicator; \ |
104 | 118 | opdi::ImplicitBarrierTools::endRegionWithImplicitBarrier(); \ |
105 | 119 | } |
|
144 | 158 |
|
145 | 159 | #define OPDI_END_SECTION |
146 | 160 |
|
147 | | -#define OPDI_MASTER(...) \ |
148 | | - OPDI_PRAGMA(omp master __VA_ARGS__) \ |
149 | | - { \ |
150 | | - opdi::logic->onMaster(opdi::LogicInterface::ScopeEndpoint::Begin); |
| 161 | +#if OPDI_BACKEND_GENERATE_MASTER_EVENTS |
| 162 | + #define OPDI_MASTER(...) \ |
| 163 | + OPDI_PRAGMA(omp master __VA_ARGS__) \ |
| 164 | + { \ |
| 165 | + opdi::logic->onMaster(opdi::LogicInterface::ScopeEndpoint::Begin); |
151 | 166 |
|
152 | | -#define OPDI_END_MASTER \ |
153 | | - opdi::logic->onMaster(opdi::LogicInterface::ScopeEndpoint::End); \ |
154 | | - } |
| 167 | + #define OPDI_END_MASTER \ |
| 168 | + opdi::logic->onMaster(opdi::LogicInterface::ScopeEndpoint::End); \ |
| 169 | + } |
| 170 | +#else |
| 171 | + #define OPDI_MASTER(...) \ |
| 172 | + OPDI_PRAGMA(omp master __VA_ARGS__) \ |
| 173 | + |
| 174 | + #define OPDI_END_MASTER /* empty */ |
| 175 | +#endif |
155 | 176 |
|
156 | 177 | // standalone macros |
157 | 178 |
|
|
0 commit comments