From 67c93c3bad747aec42581454921ed6274831b918 Mon Sep 17 00:00:00 2001 From: Ioannis Assiouras Date: Mon, 23 Dec 2024 11:47:23 +0000 Subject: [PATCH] SWDEV-505503 - Use internal device synchronize function in __hipUnregisterFatBinary This is to avoid calling the HIP_INIT macro during the shutdown process. Change-Id: I2e65f6e10491918a17445ee1e8ddd08286070358 [ROCm/clr commit: 5e3a29078d78a78b06f3e9ca3795faa5bc1442e6] --- projects/clr/hipamd/src/hip_platform.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/projects/clr/hipamd/src/hip_platform.cpp b/projects/clr/hipamd/src/hip_platform.cpp index 40de044b10..fcb3540e5e 100644 --- a/projects/clr/hipamd/src/hip_platform.cpp +++ b/projects/clr/hipamd/src/hip_platform.cpp @@ -185,10 +185,14 @@ void __hipRegisterTexture( } void __hipUnregisterFatBinary(hip::FatBinaryInfo** modules) { - // By calling hipDeviceSynchronize ensure that all HSA signal handlers - // complete before removeFatBinary static std::once_flag unregister_device_sync; - std::call_once(unregister_device_sync, hipDeviceSynchronize); + std::call_once(unregister_device_sync, [](){ + for (auto& hipDevice : g_devices) { + // By synchronizing devices ensure that all HSA signal handlers + // complete before removeFatBinary + hipDevice->SyncAllStreams(true); + } + }); hipError_t err = PlatformState::instance().removeFatBinary(modules); guarantee((err == hipSuccess), "Cannot Unregister Fat Binary, error:%d", err); }