Skip to content

Commit e958de3

Browse files
committed
Support work events in the macro backend, make work events optional.
1 parent 1f303da commit e958de3

3 files changed

Lines changed: 23 additions & 2 deletions

File tree

include/opdi/backend/macro/macros.hpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,22 +47,33 @@
4747
opdi::logic->onParallelEnd(opdiInternalParallelData); \
4848
}
4949

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+
5056
#define OPDI_FOR(...) \
5157
opdi::ImplicitBarrierTools::beginRegionWithImplicitBarrier(); \
58+
OPDI_WORK(opdi::LogicInterface::WorksharingKind::Loop, opdi::LogicInterface::ScopeEndpoint::Begin); \
5259
OPDI_PRAGMA(omp for __VA_ARGS__ private(opdi::internalLoopProbe))
5360

5461
#define OPDI_END_FOR \
62+
OPDI_WORK(opdi::LogicInterface::WorksharingKind::Loop, opdi::LogicInterface::ScopeEndpoint::End); \
5563
opdi::ImplicitBarrierTools::endRegionWithImplicitBarrier();
5664

5765
#define OPDI_SECTIONS(...) \
5866
opdi::ImplicitBarrierTools::beginRegionWithImplicitBarrier(); \
67+
OPDI_WORK(opdi::LogicInterface::WorksharingKind::Sections, opdi::LogicInterface::ScopeEndpoint::Begin); \
5968
OPDI_PRAGMA(omp sections private(opdi::internalSectionsProbe) __VA_ARGS__)
6069

6170
#define OPDI_END_SECTIONS \
71+
OPDI_WORK(opdi::LogicInterface::WorksharingKind::Sections, opdi::LogicInterface::ScopeEndpoint::End); \
6272
opdi::ImplicitBarrierTools::endRegionWithImplicitBarrier();
6373

6474
#define OPDI_SINGLE(...) \
6575
{ \
76+
OPDI_WORK(opdi::LogicInterface::WorksharingKind::Single, opdi::LogicInterface::ScopeEndpoint::Begin); \
6677
bool constexpr opdiInternalBarrierIndicator = true; \
6778
void* opdiInternalTapePosition1 = opdi::tool->allocPosition(); \
6879
opdi::tool->getTapePosition(opdi::tool->getThreadLocalTape(), opdiInternalTapePosition1); \
@@ -79,6 +90,7 @@
7990

8091
#define OPDI_SINGLE_NOWAIT(...) \
8192
{ \
93+
OPDI_WORK(opdi::LogicInterface::WorksharingKind::Single, opdi::LogicInterface::ScopeEndpoint::Begin); \
8294
bool constexpr opdiInternalBarrierIndicator = false; \
8395
void* opdiInternalTapePosition1 = opdi::tool->allocPosition(); \
8496
void* opdiInternalTapePosition2 = opdi::tool->allocPosition(); /* for consistency with the end macro */ \
@@ -101,6 +113,7 @@
101113
} \
102114
opdi::tool->freePosition(opdiInternalTapePosition1); \
103115
opdi::tool->freePosition(opdiInternalTapePosition2); \
116+
OPDI_WORK(opdi::LogicInterface::WorksharingKind::Single, opdi::LogicInterface::ScopeEndpoint::End); \
104117
opdi::ImplicitBarrierTools::implicitBarrierStack.top() = opdiInternalBarrierIndicator; \
105118
opdi::ImplicitBarrierTools::endRegionWithImplicitBarrier(); \
106119
}

include/opdi/backend/ompt/omptBackend.hpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ namespace opdi {
101101
// initialize callback structures
102102
ParallelCallbacks::init();
103103
ImplicitTaskCallbacks::init();
104-
WorkCallbacks::init();
104+
#if OPDI_BACKEND_GENERATE_WORK_EVENTS
105+
WorkCallbacks::init();
106+
#endif
105107
SyncRegionCallbacks::init();
106108
MutexCallbacks::init();
107109
ReductionCallbacks::init();
@@ -123,7 +125,9 @@ namespace opdi {
123125
ReductionCallbacks::finalize();
124126
MutexCallbacks::finalize();
125127
SyncRegionCallbacks::finalize();
126-
WorkCallbacks::finalize();
128+
#if OPDI_BACKEND_GENERATE_WORK_EVENTS
129+
WorkCallbacks::finalize();
130+
#endif
127131
ImplicitTaskCallbacks::finalize();
128132
ParallelCallbacks::finalize();
129133
}

include/opdi/config.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@
5050
#define OPDI_BACKEND_GENERATE_MASTER_EVENTS 0
5151
#endif
5252

53+
#ifndef OPDI_BACKEND_GENERATE_WORK_EVENTS
54+
#define OPDI_BACKEND_GENERATE_WORK_EVENTS 0
55+
#endif
56+
5357
#ifndef OPDI_OMPT_BACKEND_IMPLICIT_TASK_END_SOURCE
5458
#define OPDI_OMPT_BACKEND_IMPLICIT_TASK_END_SOURCE OPDI_OMPT_IMPLICIT_TASK_END
5559
#endif

0 commit comments

Comments
 (0)