Allow device allocations for transfer calls.

- make sure that transfer is not handled via cpu.

Change-Id: Ieffb1d8920b72d44cbe108410c00f76f4b110d83
Signed-off-by: Michal Mrozek <michal.mrozek@intel.com>
This commit is contained in:
Michal Mrozek
2020-01-24 11:47:19 +01:00
committed by sys_ocldev
parent d5cedc4fd5
commit 94ebf4ac23
4 changed files with 133 additions and 35 deletions

View File

@@ -41,6 +41,23 @@ cl_int CommandQueueHw<GfxFamily>::enqueueReadBuffer(
bool isCpuCopyAllowed = bufferCpuCopyAllowed(buffer, cmdType, blockingRead, size, ptr,
numEventsInWaitList, eventWaitList);
//check if we are dealing with SVM pointer here for which we already have an allocation
if (!mapAllocation && this->getContext().getSVMAllocsManager()) {
auto svmEntry = this->getContext().getSVMAllocsManager()->getSVMAlloc(ptr);
if (svmEntry) {
if ((svmEntry->gpuAllocation->getGpuAddress() + svmEntry->size) < (castToUint64(ptr) + size)) {
return CL_INVALID_OPERATION;
}
mapAllocation = svmEntry->cpuAllocation ? svmEntry->cpuAllocation : svmEntry->gpuAllocation;
if (isCpuCopyAllowed) {
if (svmEntry->memoryType == DEVICE_UNIFIED_MEMORY) {
isCpuCopyAllowed = false;
}
}
}
}
if (isCpuCopyAllowed) {
if (isMemTransferNeeded) {
return enqueueReadWriteBufferOnCpuWithMemoryTransfer(cmdType, buffer, offset, size, ptr,
@@ -70,21 +87,6 @@ cl_int CommandQueueHw<GfxFamily>::enqueueReadBuffer(
GeneralSurface mapSurface;
Surface *surfaces[] = {&bufferSurf, nullptr};
//check if we are dealing with SVM pointer here for which we already have an allocation
if (!mapAllocation && this->getContext().getSVMAllocsManager()) {
auto svmEntry = this->getContext().getSVMAllocsManager()->getSVMAlloc(ptr);
if (svmEntry) {
if (svmEntry->memoryType == DEVICE_UNIFIED_MEMORY) {
return CL_INVALID_OPERATION;
}
if ((svmEntry->gpuAllocation->getGpuAddress() + svmEntry->size) < (castToUint64(ptr) + size)) {
return CL_INVALID_OPERATION;
}
mapAllocation = svmEntry->cpuAllocation ? svmEntry->cpuAllocation : svmEntry->gpuAllocation;
}
}
if (mapAllocation) {
surfaces[1] = &mapSurface;
mapSurface.setGraphicsAllocation(mapAllocation);