Files
compute-runtime/opencl/test/unit_test/fixtures/cl_device_fixture.cpp
Kamil Kopryk 1d4240a0c8 Move ClCoreHelper ownership to RootDeviceEnvironment 1/n
Related-To: NEO-6853
Signed-off-by: Kamil Kopryk <kamil.kopryk@intel.com>

Use RootDeviceEnvironment getHelper<ClCoreHelper> for
- requiresNonAuxMode
- requiresAuxResolves
2022-11-15 10:35:22 +01:00

61 lines
1.9 KiB
C++

/*
* Copyright (C) 2020-2022 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_hw_helper.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<uint32_t *>(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();
}
template <typename HelperType>
HelperType &ClDeviceFixture::getHelper() const {
auto &helper = pClDevice->getRootDeviceEnvironment().getHelper<HelperType>();
return helper;
}
template ProductHelper &ClDeviceFixture::getHelper() const;
template CoreHelper &ClDeviceFixture::getHelper() const;
template ClCoreHelper &ClDeviceFixture::getHelper() const;
} // namespace NEO