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

Change-Id: I6614058d1456d199d710b12acd95160a79aa48c8
Этот коммит содержится в:
kjayapra-amd authored and Karthik Jayaprakash committed 2023-12-14 11:34:32 -05:00
1 родитель 68d442f29a
Коммит ec010e4d2d
2 files changed
+10 -21

No files matched your search

+9 -20
Просмотреть файл
@@ -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 {