Account for offset pointer in P2P memory copies

Signed-off-by: Raiyan Latif <raiyan.latif@intel.com>
This commit is contained in:
Raiyan Latif 2021-10-20 17:21:14 +00:00 committed by Compute-Runtime-Automation
parent 033b16fa43
commit f5210ed89f
2 changed files with 8 additions and 0 deletions

View File

@ -1752,8 +1752,12 @@ inline AlignedAllocationData CommandListCoreFamily<gfxCoreFamily>::getAlignedAll
DeviceImp *deviceImp = static_cast<DeviceImp *>(device);
DriverHandleImp *driverHandle = static_cast<DriverHandleImp *>(deviceImp->getDriverHandle());
if (driverHandle->isRemoteResourceNeeded(const_cast<void *>(buffer), alloc, allocData, device)) {
uint64_t pbase = allocData->gpuAllocations.getDefaultGraphicsAllocation()->getGpuAddress();
uint64_t offset = sourcePtr - pbase;
alloc = driverHandle->getPeerAllocation(device, allocData, const_cast<void *>(buffer), &alignedPtr);
UNRECOVERABLE_IF(alloc == nullptr);
alignedPtr += offset;
} else {
alignedPtr = sourcePtr;
}

View File

@ -620,10 +620,14 @@ ze_result_t KernelImp::setArgBuffer(uint32_t argIndex, size_t argSize, const voi
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
}
uint64_t pbase = allocData->gpuAllocations.getDefaultGraphicsAllocation()->getGpuAddress();
uint64_t offset = (uint64_t)requestedAddress - pbase;
alloc = driverHandle->getPeerAllocation(device, allocData, requestedAddress, &gpuAddress);
if (alloc == nullptr) {
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
}
gpuAddress += offset;
}
return setArgBufferWithAlloc(argIndex, gpuAddress, alloc);