diff --git a/hipamd/src/hip_internal.hpp b/hipamd/src/hip_internal.hpp index f4f949894b..78ee55bc15 100644 --- a/hipamd/src/hip_internal.hpp +++ b/hipamd/src/hip_internal.hpp @@ -464,11 +464,16 @@ namespace hip { void setFlags(unsigned int flags) { flags_ = flags; } void Reset(); - hip::Stream* NullStream(); - Stream* GetNullStream(); + hip::Stream* NullStream(); + Stream* GetNullStream(); + + void SetActiveStatus() { + isActive_ = true; + } bool GetActiveStatus() { amd::ScopedLock lock(lock_); + /// Either stream is active or device is active if (isActive_) return true; if (Stream::existsActiveStreamForDevice(this)) { isActive_ = true; diff --git a/hipamd/src/hip_memory.cpp b/hipamd/src/hip_memory.cpp index 1a4269c222..2f7b677570 100644 --- a/hipamd/src/hip_memory.cpp +++ b/hipamd/src/hip_memory.cpp @@ -290,6 +290,7 @@ hipError_t ihipMalloc(void** ptr, size_t sizeBytes, unsigned int flags) } const auto& dev_info = amdContext->devices()[0]->info(); + hip::getCurrentDevice()->SetActiveStatus(); if ((!useHostDevice && (dev_info.maxMemAllocSize_ < sizeBytes)) || (useHostDevice && (dev_info.maxPhysicalMemAllocSize_ < sizeBytes))) {