Files
compute-runtime/opencl/source/kernel/svm_object_arg.cpp
Mateusz Jablonski 00b2a28818 Create a new class for handling multi device SVM arguments in kernel
set arg SVM for devices in Kernel

Related-To: NEO-5001


Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
2021-01-22 15:53:02 +01:00

38 lines
1.4 KiB
C++

/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "opencl/source/kernel/svm_object_arg.h"
#include "shared/source/memory_manager/multi_graphics_allocation.h"
namespace NEO {
SvmObjectArg::SvmObjectArg(GraphicsAllocation *graphicsAllocation) : type(SvmObjectArgType::SingleDeviceSvm), singleDeviceSvmAlloc(graphicsAllocation) {}
SvmObjectArg::SvmObjectArg(MultiGraphicsAllocation *multiGraphicsAllocation) : type(SvmObjectArgType::MultiDeviceSvm), multiDeviceSvmAlloc(multiGraphicsAllocation) {}
GraphicsAllocation *SvmObjectArg::getGraphicsAllocation(uint32_t rootDeviceIndex) const {
if (SvmObjectArgType::SingleDeviceSvm == type) {
DEBUG_BREAK_IF(singleDeviceSvmAlloc && rootDeviceIndex != singleDeviceSvmAlloc->getRootDeviceIndex());
return singleDeviceSvmAlloc;
}
UNRECOVERABLE_IF(!multiDeviceSvmAlloc);
return multiDeviceSvmAlloc->getGraphicsAllocation(rootDeviceIndex);
}
bool SvmObjectArg::isCoherent() const {
if (SvmObjectArgType::SingleDeviceSvm == type) {
return singleDeviceSvmAlloc->isCoherent();
}
return multiDeviceSvmAlloc->isCoherent();
}
GraphicsAllocation::AllocationType SvmObjectArg::getAllocationType() const {
if (SvmObjectArgType::SingleDeviceSvm == type) {
return singleDeviceSvmAlloc->getAllocationType();
}
return multiDeviceSvmAlloc->getAllocationType();
}
} // namespace NEO