SWDEV-413997 - Fixing MGPU cases on PAL side by passing Global Context to virtual alloc.
Change-Id: I6614058d1456d199d710b12acd95160a79aa48c8
[ROCm/clr commit: ec010e4d2d]
Este commit está contenido en:
cometido por
Karthik Jayaprakash
padre
7883f1e6f7
commit
9a53a2bec3
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
|
||||
Referencia en una nueva incidencia
Block a user