SWDEV-466747 - call device sync once while unregistering

Basically embed hipDeviceSync in std::call_once.

Change-Id: I29ca926d61ed80e21acba5c388a8256d913487e4
This commit is contained in:
Jatin Chaudhary
2024-07-25 15:10:23 +01:00
کامیت شده توسط Rakesh Roy
والد 29cc678d8d
کامیت f8beeede22
+5 -5
مشاهده پرونده
@@ -26,6 +26,8 @@
#include "platform/runtime.hpp" #include "platform/runtime.hpp"
#include <unordered_map> #include <unordered_map>
#include <mutex>
namespace hip { namespace hip {
constexpr unsigned __hipFatMAGIC2 = 0x48495046; // "HIPF" constexpr unsigned __hipFatMAGIC2 = 0x48495046; // "HIPF"
@@ -177,11 +179,9 @@ void __hipRegisterTexture(
void __hipUnregisterFatBinary(hip::FatBinaryInfo** modules) { void __hipUnregisterFatBinary(hip::FatBinaryInfo** modules) {
// By calling hipDeviceSynchronize ensure that all HSA signal handlers // By calling hipDeviceSynchronize ensure that all HSA signal handlers
// complete before removeFatBinary // complete before removeFatBinary
hipError_t err = hipDeviceSynchronize(); static std::once_flag unregister_device_sync;
if (err != hipSuccess) { std::call_once(unregister_device_sync, hipDeviceSynchronize);
LogPrintfError("Error during hipDeviceSynchronize, error: %d", err); hipError_t err = PlatformState::instance().removeFatBinary(modules);
}
err = PlatformState::instance().removeFatBinary(modules);
guarantee((err == hipSuccess), "Cannot Unregister Fat Binary, error:%d", err); guarantee((err == hipSuccess), "Cannot Unregister Fat Binary, error:%d", err);
} }