2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2024-06-20 19:56:15 +08:00
|
|
|
* Copyright (C) 2020-2024 Intel Corporation
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
2018-09-18 15:11:08 +08:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2021-01-21 20:10:13 +08:00
|
|
|
#include "shared/test/common/fixtures/device_fixture.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2021-04-16 20:52:30 +08:00
|
|
|
#include "shared/source/built_ins/sip.h"
|
2024-06-20 19:56:15 +08:00
|
|
|
#include "shared/source/debug_settings/debug_settings_manager.h"
|
2022-11-09 00:16:37 +08:00
|
|
|
#include "shared/source/execution_environment/root_device_environment.h"
|
2023-01-16 23:30:27 +08:00
|
|
|
#include "shared/test/common/mocks/mock_device.h"
|
2021-04-16 20:52:30 +08:00
|
|
|
|
2019-02-27 18:39:32 +08:00
|
|
|
#include "gtest/gtest.h"
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2022-08-11 22:01:11 +08:00
|
|
|
void DeviceFixture::setUp() {
|
2020-03-24 18:42:54 +08:00
|
|
|
hardwareInfo = *defaultHwInfo;
|
2022-06-29 00:27:56 +08:00
|
|
|
setUpImpl(&hardwareInfo);
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
2022-06-29 00:27:56 +08:00
|
|
|
void DeviceFixture::setUpImpl(const NEO::HardwareInfo *hardwareInfo) {
|
2021-12-21 02:16:04 +08:00
|
|
|
pDevice = MockDevice::createWithNewExecutionEnvironment<MockDevice>(hardwareInfo, rootDeviceIndex);
|
2017-12-21 07:45:38 +08:00
|
|
|
ASSERT_NE(nullptr, pDevice);
|
|
|
|
|
2019-07-15 20:28:09 +08:00
|
|
|
auto &commandStreamReceiver = pDevice->getGpgpuCommandStreamReceiver();
|
2017-12-21 07:45:38 +08:00
|
|
|
pTagMemory = commandStreamReceiver.getTagAddress();
|
2022-11-22 21:53:59 +08:00
|
|
|
ASSERT_NE(nullptr, const_cast<TagAddressType *>(pTagMemory));
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
2022-08-11 22:01:11 +08:00
|
|
|
void DeviceFixture::tearDown() {
|
2020-05-28 20:05:12 +08:00
|
|
|
delete pDevice;
|
2019-02-04 20:08:47 +08:00
|
|
|
pDevice = nullptr;
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
2022-05-28 00:47:43 +08:00
|
|
|
MockDevice *DeviceFixture::createWithUsDeviceIdRevId(unsigned short usDeviceId, unsigned short usRevId) {
|
2020-03-24 18:42:54 +08:00
|
|
|
hardwareInfo = *defaultHwInfo;
|
2019-05-08 22:00:24 +08:00
|
|
|
hardwareInfo.platform.usDeviceID = usDeviceId;
|
2022-05-28 00:47:43 +08:00
|
|
|
hardwareInfo.platform.usRevId = usRevId;
|
2019-05-08 23:16:25 +08:00
|
|
|
return MockDevice::createWithNewExecutionEnvironment<MockDevice>(&hardwareInfo);
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
2022-11-07 22:47:17 +08:00
|
|
|
|
2022-11-09 00:16:37 +08:00
|
|
|
template <typename HelperType>
|
|
|
|
HelperType &DeviceFixture::getHelper() const {
|
|
|
|
auto &helper = this->pDevice->getRootDeviceEnvironment().getHelper<HelperType>();
|
|
|
|
return helper;
|
2022-11-07 22:47:17 +08:00
|
|
|
}
|
|
|
|
|
2023-04-13 22:16:49 +08:00
|
|
|
const ReleaseHelper *DeviceFixture::getReleaseHelper() {
|
|
|
|
const auto *releaseHelper = this->pDevice->getRootDeviceEnvironment().getReleaseHelper();
|
|
|
|
return releaseHelper;
|
|
|
|
}
|
|
|
|
|
2022-11-09 00:16:37 +08:00
|
|
|
template ProductHelper &DeviceFixture::getHelper<ProductHelper>() const;
|
2022-12-08 20:22:35 +08:00
|
|
|
template GfxCoreHelper &DeviceFixture::getHelper<GfxCoreHelper>() const;
|
2023-01-24 00:24:42 +08:00
|
|
|
template CompilerProductHelper &DeviceFixture::getHelper<CompilerProductHelper>() const;
|
2022-11-09 00:16:37 +08:00
|
|
|
|
2024-06-20 19:56:15 +08:00
|
|
|
void DeviceWithoutSipFixture::setUp() {
|
|
|
|
debugManager.flags.ForcePreemptionMode.set(static_cast<int32_t>(NEO::PreemptionMode::Disabled));
|
|
|
|
DeviceFixture::setUp();
|
|
|
|
|
|
|
|
for (auto &rootDeviceEnvironment : pDevice->executionEnvironment->rootDeviceEnvironments) {
|
|
|
|
for (auto &sipKernel : rootDeviceEnvironment->sipKernels) {
|
|
|
|
EXPECT_EQ(nullptr, sipKernel);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
debugManager.flags.ForcePreemptionMode.set(dbgRestorer.debugVarSnapshot.ForcePreemptionMode.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
void DeviceWithoutSipFixture::tearDown() {
|
|
|
|
DeviceFixture::tearDown();
|
|
|
|
}
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|