P4 to Git Change 1792745 by vsytchen@vsytchen-remote-ocl-win10 on 2019/06/06 11:18:13

SWDEV-145570 - Simplify pinned memory allocation logic

	ReviewBoardURL = http://ocltc.amd.com/reviews/r/17467/diff/

Affected files ...

... //depot/stg/opencl/drivers/opencl/api/hip/hip_memory.cpp#58 edit


[ROCm/clr commit: 5683d9d218]
This commit is contained in:
foreman
2019-06-06 11:51:22 -04:00
orang tua c10cebcf6f
melakukan 3bc1711330
+8 -13
Melihat File
@@ -556,26 +556,21 @@ hipError_t hipHostRegister(void* hostPtr, size_t sizeBytes, unsigned int flags)
if(hostPtr != nullptr) {
amd::Memory* mem = new (*hip::host_context) amd::Buffer(*hip::host_context, CL_MEM_USE_HOST_PTR, sizeBytes);
if (!mem->create(hostPtr)) {
constexpr bool sysMemAlloc = false;
constexpr bool skipAlloc = false;
constexpr bool forceAlloc = true;
if (!mem->create(hostPtr, sysMemAlloc, skipAlloc, forceAlloc)) {
mem->release();
HIP_RETURN(hipErrorMemoryAllocation);
}
std::vector<void*> devPtrs;
for (const auto& device: hip::getCurrentContext()->devices()) {
// Since the amd::Memory object is shared between all devices
// it's fine to have multiple addresses mapped to it
const device::Memory* devMem = mem->getDeviceMemory(*device);
if (devMem != nullptr) {
devPtrs.emplace_back(reinterpret_cast<void*>(devMem->virtualAddress()));
} else {
mem->release();
HIP_RETURN(hipErrorMemoryAllocation);
}
}
// Since the amd::Memory object is shared between all devices
// it's fine to have multiple addresses mapped to it
for (const auto& devPtr: devPtrs) {
amd::MemObjMap::AddMemObj(devPtr, mem);
amd::MemObjMap::AddMemObj(reinterpret_cast<void*>(devMem->virtualAddress()), mem);
}
amd::MemObjMap::AddMemObj(hostPtr, mem);
HIP_RETURN(hipSuccess);
} else {