mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-30 09:58:55 +08:00
Add support for SVM pointer reuse to enqueueReadBuffer.
Change-Id: I7a6718b2ebe48912a19af3da5e233acd84bdd3ef Signed-off-by: Michal Mrozek <michal.mrozek@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
c50d8e3eb9
commit
98006aa2bf
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2019 Intel Corporation
|
||||
* Copyright (C) 2017-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#pragma once
|
||||
#include "core/helpers/cache_policy.h"
|
||||
#include "core/memory_manager/unified_memory_manager.h"
|
||||
#include "runtime/built_ins/built_ins.h"
|
||||
#include "runtime/command_queue/command_queue_hw.h"
|
||||
#include "runtime/command_queue/enqueue_common.h"
|
||||
@@ -69,6 +70,21 @@ 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