SWDEV-322620 - Virtual Memory Management
Implemented hipMemMap and hipMemUnmap
Change-Id: Idc75e3964d88e375e445733557cfa8e421688f1f
[ROCm/clr commit: 6d73282f25]
Этот коммит содержится в:
коммит произвёл
Christophe Paquot
родитель
558467643d
Коммит
c2b3dd7dc5
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ public:
|
||||
|
||||
const hipMemAllocationProp& GetProperties() const { return properties_; }
|
||||
hipMemGenericAllocationHandle_t asMemGenericAllocationHandle() { return reinterpret_cast<hipMemGenericAllocationHandle_t>(this); }
|
||||
amd::Memory& asAmdMemory() { return *amd::MemObjMap::FindMemObj(ptr_); }
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user