Files
compute-runtime/opencl/test/unit_test/fixtures/cl_device_fixture.cpp
Kamil Kopryk 171e97e71a feature: introduce release helper
Related-To: NEO-7786
Signed-off-by: Kamil Kopryk <kamil.kopryk@intel.com>
2023-04-27 21:38:08 +02:00

68 lines
2.2 KiB
C++

/*
* Copyright (C) 2020-2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "opencl/test/unit_test/fixtures/cl_device_fixture.h"
#include "shared/source/built_ins/sip.h"
#include "opencl/source/helpers/cl_gfx_core_helper.h"
#include "opencl/test/unit_test/mocks/mock_cl_device.h"
#include "opencl/test/unit_test/mocks/mock_cl_execution_environment.h"
#include "gtest/gtest.h"
namespace NEO {
void ClDeviceFixture::setUp() {
hardwareInfo = *defaultHwInfo;
setUpImpl(&hardwareInfo);
}
void ClDeviceFixture::setUpImpl(const NEO::HardwareInfo *hardwareInfo) {
pDevice = MockClDevice::createWithNewExecutionEnvironment<MockDevice>(hardwareInfo, rootDeviceIndex);
ASSERT_NE(nullptr, pDevice);
pClExecutionEnvironment = static_cast<MockClExecutionEnvironment *>(pDevice->getExecutionEnvironment());
pClDevice = new MockClDevice{pDevice};
ASSERT_NE(nullptr, pClDevice);
auto &commandStreamReceiver = pDevice->getGpgpuCommandStreamReceiver();
pTagMemory = commandStreamReceiver.getTagAddress();
ASSERT_NE(nullptr, const_cast<TagAddressType *>(pTagMemory));
this->osContext = pDevice->getDefaultEngine().osContext;
}
void ClDeviceFixture::tearDown() {
delete pClDevice;
pClDevice = nullptr;
pDevice = nullptr;
}
MockDevice *ClDeviceFixture::createWithUsDeviceId(unsigned short usDeviceId) {
hardwareInfo = *defaultHwInfo;
hardwareInfo.platform.usDeviceID = usDeviceId;
return MockDevice::createWithNewExecutionEnvironment<MockDevice>(&hardwareInfo, rootDeviceIndex);
}
const RootDeviceEnvironment &ClDeviceFixture::getRootDeviceEnvironment() const {
return pClDevice->getRootDeviceEnvironment();
}
RootDeviceEnvironment &ClDeviceFixture::getMutableRootDeviceEnvironment() {
return pClDevice->getDevice().getRootDeviceEnvironmentRef();
}
template <typename HelperType>
HelperType &ClDeviceFixture::getHelper() const {
auto &helper = pClDevice->getRootDeviceEnvironment().getHelper<HelperType>();
return helper;
}
template ProductHelper &ClDeviceFixture::getHelper() const;
template CompilerProductHelper &ClDeviceFixture::getHelper() const;
template GfxCoreHelper &ClDeviceFixture::getHelper() const;
template ClGfxCoreHelper &ClDeviceFixture::getHelper() const;
} // namespace NEO