From a6c5c6a95afef184980b2d8e604341a96cd236cb Mon Sep 17 00:00:00 2001 From: Jaydeep Patel Date: Sat, 5 Oct 2024 12:05:49 +0000 Subject: [PATCH] SWDEV-487988 - Reserve event flag in hip::Event. Don't create new hip:Function if it is already registered. Change-Id: I3ecd5d61146659be6ba434717b0f21d3fc04cfc9 --- hipamd/src/hip_event.cpp | 5 +++++ hipamd/src/hip_platform.cpp | 9 +++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/hipamd/src/hip_event.cpp b/hipamd/src/hip_event.cpp index e43e8b00e0..815aee9fd5 100644 --- a/hipamd/src/hip_event.cpp +++ b/hipamd/src/hip_event.cpp @@ -308,6 +308,11 @@ hipError_t ihipEventCreateWithFlags(hipEvent_t* event, unsigned flags) { e = new hip::Event(flags); } } + // App might have used combination of flags i.e. hipEventInterprocess|hipEventDisableTiming + // However based on hipEventInterprocess flag, IPCEvent creates even with + // JUST hipEventInterprocess and hence, Actual hipEventInterprocess|hipEventDisableTiming + // flag is getting supressed with hipEventInterprocess + e->flags_ = flags; if (e == nullptr) { return hipErrorOutOfMemory; } diff --git a/hipamd/src/hip_platform.cpp b/hipamd/src/hip_platform.cpp index 11b00ed735..5f0d355172 100644 --- a/hipamd/src/hip_platform.cpp +++ b/hipamd/src/hip_platform.cpp @@ -88,8 +88,13 @@ void __hipRegisterFunction(hip::FatBinaryInfo** modules, const void* hostFunctio return var ? atoi(var) : 1; }()}; hipError_t hip_error = hipSuccess; - hip::Function* func = new hip::Function(std::string(deviceName), modules); - hip_error = PlatformState::instance().registerStatFunction(hostFunction, func); + // Compiler might share same hostFunction and hence it's needless to have another + // hip::Function and hip::Function is stored in map with hostFunction as key. + // Creating hip::Function in such case, Leaks it. + if (PlatformState::instance().getStatFuncName(hostFunction) == nullptr) { + hip::Function* func = new hip::Function(std::string(deviceName), modules); + hip_error = PlatformState::instance().registerStatFunction(hostFunction, func); + } guarantee((hip_error == hipSuccess), "Cannot register Static function, error: %d", hip_error); if (!enable_deferred_loading) {