Skip to content

Commit 79d2105

Browse files
committed
Allow disabling event timing
1 parent 2098f47 commit 79d2105

File tree

8 files changed

+21
-11
lines changed

8 files changed

+21
-11
lines changed

AbstractAPI.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ struct AbstractAPI {
9494

9595
virtual void streamWaitMemory(void* streamPtr, uint32_t* location, uint32_t value) = 0;
9696

97-
virtual void* createEvent() = 0;
97+
virtual void* createEvent(bool withTiming = false) = 0;
9898
virtual void destroyEvent(void* eventPtr) = 0;
9999
virtual void syncEventWithHost(void* eventPtr) = 0;
100100
virtual bool isEventCompleted(void* eventPtr) = 0;

interfaces/cuda/CudaWrappedAPI.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class ConcreteAPI : public AbstractAPI {
8585

8686
void streamWaitMemory(void* streamPtr, uint32_t* location, uint32_t value) override;
8787

88-
void* createEvent() override;
88+
void* createEvent(bool withTiming) override;
8989
void destroyEvent(void* eventPtr) override;
9090
void syncEventWithHost(void* eventPtr) override;
9191
bool isEventCompleted(void* eventPtr) override;

interfaces/cuda/Events.cu

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,14 @@
1313

1414
using namespace device;
1515

16-
void* ConcreteAPI::createEvent() {
17-
cudaEvent_t event;
18-
APIWRAP(cudaEventCreate(&event));
16+
void* ConcreteAPI::createEvent(bool withTiming) {
17+
cudaEvent_t event{};
18+
if (withTiming) {
19+
APIWRAP(cudaEventCreate(&event));
20+
}
21+
else {
22+
APIWRAP(cudaEventCreateWithFlags(&event, cudaEventDisableTiming));
23+
}
1924
CHECK_ERR;
2025
return static_cast<void*>(event);
2126
}

interfaces/hip/Events.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,14 @@
1414

1515
using namespace device;
1616

17-
void* ConcreteAPI::createEvent() {
17+
void* ConcreteAPI::createEvent(bool withTiming) {
1818
hipEvent_t event;
19-
APIWRAP(hipEventCreate(&event));
19+
if (withTiming) {
20+
APIWRAP(hipEventCreate(&event));
21+
}
22+
else {
23+
APIWRAP(hipEventCreateWithFlags(&event, hipEventDisableTiming));
24+
}
2025
return static_cast<void*>(event);
2126
}
2227

interfaces/hip/HipWrappedAPI.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class ConcreteAPI : public AbstractAPI {
8585

8686
void streamWaitMemory(void* streamPtr, uint32_t* location, uint32_t value) override;
8787

88-
void* createEvent() override;
88+
void* createEvent(bool withTiming) override;
8989
void destroyEvent(void* eventPtr) override;
9090
void syncEventWithHost(void* eventPtr) override;
9191
bool isEventCompleted(void* eventPtr) override;

interfaces/sycl/Events.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ struct Event {
2323
};
2424
} // namespace
2525

26-
void* ConcreteAPI::createEvent() {
26+
void* ConcreteAPI::createEvent(bool withTiming) {
2727
return new Event();
2828
}
2929

interfaces/sycl/SyclWrappedAPI.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ class ConcreteAPI : public AbstractAPI {
119119

120120
void streamWaitMemory(void* streamPtr, uint32_t* location, uint32_t value) override;
121121

122-
void* createEvent() override;
122+
void* createEvent(bool withTiming) override;
123123
void destroyEvent(void* eventPtr) override;
124124
void syncEventWithHost(void* eventPtr) override;
125125
bool isEventCompleted(void* eventPtr) override;

tests/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# SPDX-License-Identifier: BSD-3-Clause
44

5-
cmake_minimum_required(VERSION 3.5)
5+
cmake_minimum_required(VERSION 3.14)
66
project(examples)
77

88
#set(CMAKE_CXX_CLANG_TIDY clang-tidy)

0 commit comments

Comments
 (0)