SWDEV-322620 - Virtual Memory Management

Implemented hipMemMap and hipMemUnmap

Change-Id: Idc75e3964d88e375e445733557cfa8e421688f1f


[ROCm/clr commit: 6d73282f25]
Αυτή η υποβολή περιλαμβάνεται σε:
Christophe Paquot authored and Christophe Paquot committed 2022-04-28 02:14:14 -04:00
1 γονέας 558467643d
υποβολή c2b3dd7dc5
2 files changed
+22

No files matched your search

@@ -193,6 +193,18 @@ hipError_t hipMemMap(void* ptr, size_t size, size_t offset, hipMemGenericAllocat
HIP_RETURN(hipErrorInvalidValue);
}
hip::GenericAllocation* ga = reinterpret_cast<hip::GenericAllocation*>(handle);
auto& queue = *g_devices[ga->GetProperties().location.id]->NullStream();
amd::Command* cmd = new amd::VirtualMapCommand(queue, amd::Command::EventWaitList{}, ptr, size, &ga->asAmdMemory());
cmd->enqueue();
cmd->awaitCompletion();
cmd->release();
amd::Memory* va = amd::MemObjMap::FindMemObj(ptr);
va->getUserData().deviceId = ga->GetProperties().location.id;
HIP_RETURN(hipSuccess);
}
@@ -244,6 +256,15 @@ hipError_t hipMemUnmap(void* ptr, size_t size) {
if (ptr == nullptr) HIP_RETURN(hipErrorInvalidValue);
amd::Memory* va = amd::MemObjMap::FindMemObj(ptr);
auto& queue = *g_devices[va->getUserData().deviceId]->NullStream();
amd::Command* cmd = new amd::VirtualMapCommand(queue, amd::Command::EventWaitList{}, ptr, size, nullptr);
cmd->enqueue();
cmd->awaitCompletion();
cmd->release();
HIP_RETURN(hipSuccess);
}