Reuse SVM storage on writeBuffer call.

- Instead of creating new allocation, look if it already exists if so
re-use it.

Change-Id: I23bc4ac8b8e59e96fce7d48546b76289bedc157f
Signed-off-by: Michal Mrozek <michal.mrozek@intel.com>
This commit is contained in:
Michal Mrozek
2020-01-22 14:50:16 +01:00
parent 0d7cc3a8c0
commit 35b59b7cbe
3 changed files with 126 additions and 2 deletions

View File

@@ -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/string.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_stream/command_stream_receiver.h"
@@ -65,6 +66,14 @@ cl_int CommandQueueHw<GfxFamily>::enqueueWriteBuffer(
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) {
mapAllocation = svmEntry->cpuAllocation ? svmEntry->cpuAllocation : svmEntry->gpuAllocation;
}
}
if (mapAllocation) {
surfaces[1] = &mapSurface;
mapSurface.setGraphicsAllocation(mapAllocation);