SWDEV-413997 - Fixing MGPU cases on PAL side by passing Global Context to virtual alloc.

Change-Id: I6614058d1456d199d710b12acd95160a79aa48c8


[ROCm/clr commit: ec010e4d2d]
This commit is contained in:
kjayapra-amd
2023-10-23 11:31:33 -04:00
committed by Karthik Jayaprakash
parent 7883f1e6f7
commit 9a53a2bec3
2 changed files with 10 additions and 21 deletions
+9 -20
View File
@@ -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 {