mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-24 12:23:05 +08:00
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:
committed by
sys_ocldev
parent
d5cedc4fd5
commit
94ebf4ac23
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user