From 173de0665881c1e67971ccd9e2aa072d406c0ce5 Mon Sep 17 00:00:00 2001 From: sdashmiz Date: Wed, 12 Jul 2023 13:20:02 -0400 Subject: [PATCH] SWDEV-408586 - set device active when malloc is called Signed-off-by: sdashmiz Change-Id: Ib930d997b7d544d8b6fb42d2fea01fa8a4418e98 --- hipamd/src/hip_internal.hpp | 9 +++++++-- hipamd/src/hip_memory.cpp | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) 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))) {