diff --git a/projects/clr/hipamd/src/hip_graph_internal.hpp b/projects/clr/hipamd/src/hip_graph_internal.hpp index a78779aa3f..fbd581c3ec 100644 --- a/projects/clr/hipamd/src/hip_graph_internal.hpp +++ b/projects/clr/hipamd/src/hip_graph_internal.hpp @@ -494,32 +494,21 @@ struct Graph { void* ReserveAddress(size_t size) const { void* startAddress = nullptr; void* ptr; - for (auto& dev : g_devices) { - const auto& dev_info = dev->devices()[0]->info(); - ptr = dev->devices()[0]->virtualAlloc(startAddress, size, - dev_info.virtualMemAllocGranularity_); + const auto& dev_info = g_devices[0]->devices()[0]->info(); - // if addr==0 then runtime will use the first VA on other devices - if (startAddress == nullptr) { - startAddress = ptr; - } else if (ptr != startAddress) { - // if runtime cannot reserve the same VA on other devices, just fail - for (auto& d : g_devices) { - if (d == dev) { - d->devices()[0]->virtualFree(ptr); - return nullptr; - } - d->devices()[0]->virtualFree(startAddress); - } - } + // Single virtual alloc would reserve for all devices. + ptr = g_devices[0]->devices()[0]->virtualAlloc(startAddress, size, + dev_info.virtualMemAllocGranularity_); + if (ptr == nullptr) { + LogError("Failed to reserve Virtual Address"); } + return ptr; } void FreeAddress(void* ptr) const { - for (auto& dev : g_devices) { - dev->devices()[0]->virtualFree(ptr); - } + // Single Free would free for all devices. + g_devices[0]->devices()[0]->virtualFree(ptr); } void FreeMemory(void* dev_ptr, hip::Stream* stream) const { diff --git a/projects/clr/rocclr/device/pal/paldevice.cpp b/projects/clr/rocclr/device/pal/paldevice.cpp index 225d949895..950e29f50b 100644 --- a/projects/clr/rocclr/device/pal/paldevice.cpp +++ b/projects/clr/rocclr/device/pal/paldevice.cpp @@ -2395,7 +2395,7 @@ void Device::svmFree(void* ptr) const { // ================================================================================================ void* Device::virtualAlloc(void* addr, size_t size, size_t alignment) { // create a hidden buffer, which will allocated on the device later - auto mem = new (context()) amd::Buffer(context(), CL_MEM_VA_RANGE_AMD, size, addr); + auto mem = new (GlbCtx()) amd::Buffer(GlbCtx(), CL_MEM_VA_RANGE_AMD, size, addr); if (mem == nullptr) { LogError("failed to new a va range mem object!"); return nullptr;