From f8beeede22f2600ca42ccedeea255a4f3ffbc2d0 Mon Sep 17 00:00:00 2001 From: Jatin Chaudhary Date: Thu, 25 Jul 2024 15:10:23 +0100 Subject: [PATCH] SWDEV-466747 - call device sync once while unregistering Basically embed hipDeviceSync in std::call_once. Change-Id: I29ca926d61ed80e21acba5c388a8256d913487e4 --- hipamd/src/hip_platform.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hipamd/src/hip_platform.cpp b/hipamd/src/hip_platform.cpp index 5f88d53654..535d6e96f6 100644 --- a/hipamd/src/hip_platform.cpp +++ b/hipamd/src/hip_platform.cpp @@ -26,6 +26,8 @@ #include "platform/runtime.hpp" #include +#include + namespace hip { constexpr unsigned __hipFatMAGIC2 = 0x48495046; // "HIPF" @@ -177,11 +179,9 @@ void __hipRegisterTexture( void __hipUnregisterFatBinary(hip::FatBinaryInfo** modules) { // By calling hipDeviceSynchronize ensure that all HSA signal handlers // complete before removeFatBinary - hipError_t err = hipDeviceSynchronize(); - if (err != hipSuccess) { - LogPrintfError("Error during hipDeviceSynchronize, error: %d", err); - } - err = PlatformState::instance().removeFatBinary(modules); + static std::once_flag unregister_device_sync; + std::call_once(unregister_device_sync, hipDeviceSynchronize); + hipError_t err = PlatformState::instance().removeFatBinary(modules); guarantee((err == hipSuccess), "Cannot Unregister Fat Binary, error:%d", err); }