Files
compute-runtime/opencl/source/kernel/svm_object_arg.cpp
Mateusz Jablonski 6f2a8e8a1c Correct nullptr SVM arg handling
Related-To: NEO-5001
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
2021-01-25 15:43:53 +01:00

40 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;
}
if (multiDeviceSvmAlloc) {
return multiDeviceSvmAlloc->getGraphicsAllocation(rootDeviceIndex);
}
return nullptr;
}
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