Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions paddle/fluid/platform/event.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ class MemEvent {

class CudaEvent {
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)

public:
CudaEvent() {
#ifdef PADDLE_WITH_HIP
Expand All @@ -129,15 +130,23 @@ class CudaEvent {
#endif
}

CudaEvent(unsigned int flags) : flags_(flags) {
explicit CudaEvent(unsigned int flags) : flags_(flags) {
#ifdef PADDLE_WITH_HIP
hipEventCreateWithFlags(&event_, flags_);
#else
cudaEventCreateWithFlags(&event_, flags_);
#endif
}

void Record(paddle::platform::stream::CUDAStream& stream) {
~CudaEvent() {
#ifdef PADDLE_WITH_HIP
hipEventDestroy(event_);
#else
cudaEventDestroy(event_);
#endif
}

void Record(const paddle::platform::stream::CUDAStream& stream) {
#ifdef PADDLE_WITH_HIP
PADDLE_ENFORCE_CUDA_SUCCESS(hipEventRecord(event_, stream.raw_stream()));
#else
Expand Down