From 6cc5dc03265d50e4ae511c66e25854bab51fe40e Mon Sep 17 00:00:00 2001 From: Ben Sander Date: Tue, 30 May 2017 21:54:33 -0500 Subject: [PATCH] Set event->_stream on hipHccModuleLaunchKernel path if start/stop used Ensure _stream is always non-null in recorded events. Fixes isDefaultStream fault. --- hipamd/src/hip_event.cpp | 4 +++- hipamd/src/hip_hcc_internal.h | 3 ++- hipamd/src/hip_module.cpp | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/hipamd/src/hip_event.cpp b/hipamd/src/hip_event.cpp index 2c31769718..8ef652489a 100644 --- a/hipamd/src/hip_event.cpp +++ b/hipamd/src/hip_event.cpp @@ -42,11 +42,13 @@ ihipEvent_t::ihipEvent_t(unsigned flags) // Attach to an existing completion future: -void ihipEvent_t::attachToCompletionFuture(const hc::completion_future *cf, ihipEventType_t eventType) +void ihipEvent_t::attachToCompletionFuture(const hc::completion_future *cf, + hipStream_t stream, ihipEventType_t eventType) { _state = hipEventStatusRecording; _marker = *cf; _type = eventType; + _stream = stream; } diff --git a/hipamd/src/hip_hcc_internal.h b/hipamd/src/hip_hcc_internal.h index 94ad4f9340..b15d5a73e4 100644 --- a/hipamd/src/hip_hcc_internal.h +++ b/hipamd/src/hip_hcc_internal.h @@ -538,6 +538,7 @@ public: const ihipDevice_t * getDevice() const; ihipCtx_t * getCtx() const; + // Before calling this function, stream must be resolved from "0" to the actual stream: bool isDefaultStream() const { return _id == 0; }; public: @@ -602,7 +603,7 @@ enum ihipEventType_t { class ihipEvent_t { public: ihipEvent_t(unsigned flags); - void attachToCompletionFuture(const hc::completion_future *cf, ihipEventType_t eventType); + void attachToCompletionFuture(const hc::completion_future *cf, hipStream_t stream, ihipEventType_t eventType); void setTimestamp(); uint64_t timestamp() const { return _timestamp; } ; ihipEventType_t type() const { return _type; }; diff --git a/hipamd/src/hip_module.cpp b/hipamd/src/hip_module.cpp index d364a6b519..2a3bfabc28 100644 --- a/hipamd/src/hip_module.cpp +++ b/hipamd/src/hip_module.cpp @@ -455,10 +455,10 @@ hipError_t ihipModuleLaunchKernel(hipFunction_t f, if (startEvent) { - startEvent->attachToCompletionFuture(&cf, hipEventTypeStartCommand); + startEvent->attachToCompletionFuture(&cf, hStream, hipEventTypeStartCommand); } if (stopEvent) { - stopEvent->attachToCompletionFuture (&cf, hipEventTypeStopCommand); + stopEvent->attachToCompletionFuture (&cf, hStream, hipEventTypeStopCommand); }