From e96f1afa6f5edd241972730717f4600d396f3646 Mon Sep 17 00:00:00 2001 From: Rafal Maziejuk Date: Mon, 30 Aug 2021 14:34:53 +0000 Subject: [PATCH] Move HwInfoConfig tests to common file Signed-off-by: Rafal Maziejuk --- .../linux/hw_info_config_linux_tests.cpp | 131 --------------- .../windows/hw_info_config_win_tests.cpp | 131 --------------- .../unit_test/os_interface/CMakeLists.txt | 2 + .../os_agnostic_hw_info_config_tests.cpp | 152 ++++++++++++++++++ .../os_agnostic_hw_info_config_tests.h | 26 +++ 5 files changed, 180 insertions(+), 262 deletions(-) create mode 100644 shared/test/unit_test/os_interface/os_agnostic_hw_info_config_tests.cpp create mode 100644 shared/test/unit_test/os_interface/os_agnostic_hw_info_config_tests.h diff --git a/opencl/test/unit_test/os_interface/linux/hw_info_config_linux_tests.cpp b/opencl/test/unit_test/os_interface/linux/hw_info_config_linux_tests.cpp index 066489477b..9a2d9128d5 100644 --- a/opencl/test/unit_test/os_interface/linux/hw_info_config_linux_tests.cpp +++ b/opencl/test/unit_test/os_interface/linux/hw_info_config_linux_tests.cpp @@ -44,112 +44,6 @@ int HwInfoConfigHw::configureHardwareCustom(HardwareInfo *hwInfo, } return (hwInfo->platform.usDeviceID == 10) ? -1 : 0; } - -template <> -cl_unified_shared_memory_capabilities_intel HwInfoConfigHw::getHostMemCapabilities(const HardwareInfo * /*hwInfo*/) { - return 0; -} - -template <> -void HwInfoConfigHw::adjustPlatformForProductFamily(HardwareInfo *hwInfo) { -} - -template <> -cl_unified_shared_memory_capabilities_intel HwInfoConfigHw::getDeviceMemCapabilities() { - return 0; -} - -template <> -cl_unified_shared_memory_capabilities_intel HwInfoConfigHw::getSingleDeviceSharedMemCapabilities() { - return 0; -} - -template <> -cl_unified_shared_memory_capabilities_intel HwInfoConfigHw::getCrossDeviceSharedMemCapabilities() { - return 0; -} - -template <> -void HwInfoConfigHw::getKernelExtendedProperties(uint32_t *fp16, uint32_t *fp32, uint32_t *fp64) { -} - -template <> -uint32_t HwInfoConfigHw::getDeviceMemoryMaxClkRate(const HardwareInfo *hwInfo) { - return 0; -} - -template <> -cl_unified_shared_memory_capabilities_intel HwInfoConfigHw::getSharedSystemMemCapabilities() { - return 0; -} - -template <> -void HwInfoConfigHw::adjustSamplerState(void *sampler, const HardwareInfo &hwInfo){}; - -template <> -void HwInfoConfigHw::convertTimestampsFromOaToCsDomain(uint64_t ×tampData){}; - -template <> -bool HwInfoConfigHw::isAdditionalStateBaseAddressWARequired(const HardwareInfo &hwInfo) const { - return false; -} - -template <> -bool HwInfoConfigHw::isMaxThreadsForWorkgroupWARequired(const HardwareInfo &hwInfo) const { - return false; -} - -template <> -uint32_t HwInfoConfigHw::getMaxThreadsForWorkgroupInDSSOrSS(const HardwareInfo &hwInfo, uint32_t maxNumEUsPerSubSlice, uint32_t maxNumEUsPerDualSubSlice) const { - return 0; -} - -template <> -uint32_t HwInfoConfigHw::getMaxThreadsForWorkgroup(const HardwareInfo &hwInfo, uint32_t maxNumEUsPerSubSlice) const { - return 0; -} - -template <> -void HwInfoConfigHw::setForceNonCoherent(void *const commandPtr, const StateComputeModeProperties &properties) {} - -template <> -bool HwInfoConfigHw::obtainBlitterPreference(const HardwareInfo &hwInfo) const { - return false; -} - -template <> -bool HwInfoConfigHw::isPageTableManagerSupported(const HardwareInfo &hwInfo) const { - return false; -} - -template <> -uint32_t HwInfoConfigHw::getHwRevIdFromStepping(uint32_t stepping, const HardwareInfo &hwInfo) const { - return CommonConstants::invalidStepping; -} - -template <> -uint32_t HwInfoConfigHw::getSteppingFromHwRevId(const HardwareInfo &hwInfo) const { - return CommonConstants::invalidStepping; -} - -template <> -uint32_t HwInfoConfigHw::getAubStreamSteppingFromHwRevId(const HardwareInfo &hwInfo) const { - switch (getSteppingFromHwRevId(hwInfo)) { - default: - case REVISION_A0: - case REVISION_A1: - case REVISION_A3: - return AubMemDump::SteppingValues::A; - case REVISION_B: - return AubMemDump::SteppingValues::B; - case REVISION_C: - return AubMemDump::SteppingValues::C; - case REVISION_D: - return AubMemDump::SteppingValues::D; - case REVISION_K: - return AubMemDump::SteppingValues::K; - } -} } // namespace NEO struct DummyHwConfig : HwInfoConfigHw { @@ -601,16 +495,6 @@ TEST_F(HwInfoConfigTestLinuxDummy, givenFailingGttSizeIoctlWhenInitializingHwInf EXPECT_EQ(pInHwInfo.capabilityTable.gpuAddressSpace, outHwInfo.capabilityTable.gpuAddressSpace); } -HWTEST_F(HwInfoConfigTestLinuxDummy, givenHardwareInfoWhenCallingIsAdditionalStateBaseAddressWARequiredThenFalseIsReturned) { - bool ret = hwConfig.isAdditionalStateBaseAddressWARequired(outHwInfo); - EXPECT_FALSE(ret); -} - -HWTEST_F(HwInfoConfigTestLinuxDummy, givenHardwareInfoWhenCallingIsMaxThreadsForWorkgroupWARequiredThenFalseIsReturned) { - bool ret = hwConfig.isMaxThreadsForWorkgroupWARequired(outHwInfo); - EXPECT_FALSE(ret); -} - using HwConfigLinux = ::testing::Test; HWTEST2_F(HwConfigLinux, GivenDifferentValuesFromTopologyQueryWhenConfiguringHwInfoThenMaxSlicesSupportedSetToAvailableCountInGtSystemInfo, MatchAny) { @@ -665,18 +549,3 @@ HWTEST2_F(HwConfigLinux, GivenDifferentValuesFromTopologyQueryWhenConfiguringHwI EXPECT_EQ(0, ret); EXPECT_EQ(8u, outHwInfo.gtSystemInfo.MaxEuPerSubSlice); } - -HWTEST_F(HwInfoConfigTestLinuxDummy, givenHardwareInfoWhenCallingObtainBlitterPreferenceThenFalseIsReturned) { - bool ret = hwConfig.obtainBlitterPreference(outHwInfo); - EXPECT_FALSE(ret); -} - -HWTEST_F(HwInfoConfigTestLinuxDummy, givenHardwareInfoWhenCallingIsPageTableManagerSupportedThenFalseIsReturned) { - bool ret = hwConfig.isPageTableManagerSupported(outHwInfo); - EXPECT_FALSE(ret); -} - -HWTEST_F(HwInfoConfigTestLinuxDummy, givenHardwareInfoWhenCallingGetSteppingFromHwRevIdThenInvalidSteppingIsReturned) { - uint32_t ret = hwConfig.getSteppingFromHwRevId(outHwInfo); - EXPECT_EQ(CommonConstants::invalidStepping, ret); -} diff --git a/opencl/test/unit_test/os_interface/windows/hw_info_config_win_tests.cpp b/opencl/test/unit_test/os_interface/windows/hw_info_config_win_tests.cpp index a3eda7c492..4d26778676 100644 --- a/opencl/test/unit_test/os_interface/windows/hw_info_config_win_tests.cpp +++ b/opencl/test/unit_test/os_interface/windows/hw_info_config_win_tests.cpp @@ -19,117 +19,11 @@ namespace NEO { -template <> -uint64_t HwInfoConfigHw::getHostMemCapabilities(const HardwareInfo * /*hwInfo*/) { - return 0; -} - -template <> -uint64_t HwInfoConfigHw::getDeviceMemCapabilities() { - return 0; -} - -template <> -uint64_t HwInfoConfigHw::getSingleDeviceSharedMemCapabilities() { - return 0; -} - -template <> -uint64_t HwInfoConfigHw::getCrossDeviceSharedMemCapabilities() { - return 0; -} - -template <> -void HwInfoConfigHw::getKernelExtendedProperties(uint32_t *fp16, uint32_t *fp32, uint32_t *fp64) { -} - -template <> -uint32_t HwInfoConfigHw::getDeviceMemoryMaxClkRate(const HardwareInfo *hwInfo) { - return 0; -} - -template <> -uint64_t HwInfoConfigHw::getSharedSystemMemCapabilities() { - return 0; -} - template <> int HwInfoConfigHw::configureHardwareCustom(HardwareInfo *hwInfo, OSInterface *osIface) { return 0; } -template <> -void HwInfoConfigHw::adjustPlatformForProductFamily(HardwareInfo *hwInfo) { -} - -template <> -void HwInfoConfigHw::convertTimestampsFromOaToCsDomain(uint64_t ×tampData){}; - -template <> -void HwInfoConfigHw::adjustSamplerState(void *sampler, const HardwareInfo &hwInfo){}; - -template <> -bool HwInfoConfigHw::isAdditionalStateBaseAddressWARequired(const HardwareInfo &hwInfo) const { - return false; -} - -template <> -bool HwInfoConfigHw::isMaxThreadsForWorkgroupWARequired(const HardwareInfo &hwInfo) const { - return false; -} - -template <> -uint32_t HwInfoConfigHw::getMaxThreadsForWorkgroupInDSSOrSS(const HardwareInfo &hwInfo, uint32_t maxNumEUsPerSubSlice, uint32_t maxNumEUsPerDualSubSlice) const { - return 0; -} - -template <> -uint32_t HwInfoConfigHw::getMaxThreadsForWorkgroup(const HardwareInfo &hwInfo, uint32_t maxNumEUsPerSubSlice) const { - return 0; -} - -template <> -void HwInfoConfigHw::setForceNonCoherent(void *const commandPtr, const StateComputeModeProperties &properties) {} - -template <> -bool HwInfoConfigHw::obtainBlitterPreference(const HardwareInfo &hwInfo) const { - return false; -} - -template <> -bool HwInfoConfigHw::isPageTableManagerSupported(const HardwareInfo &hwInfo) const { - return false; -} - -template <> -uint32_t HwInfoConfigHw::getHwRevIdFromStepping(uint32_t stepping, const HardwareInfo &hwInfo) const { - return CommonConstants::invalidStepping; -} - -template <> -uint32_t HwInfoConfigHw::getSteppingFromHwRevId(const HardwareInfo &hwInfo) const { - return CommonConstants::invalidStepping; -} - -template <> -uint32_t HwInfoConfigHw::getAubStreamSteppingFromHwRevId(const HardwareInfo &hwInfo) const { - switch (getSteppingFromHwRevId(hwInfo)) { - default: - case REVISION_A0: - case REVISION_A1: - case REVISION_A3: - return AubMemDump::SteppingValues::A; - case REVISION_B: - return AubMemDump::SteppingValues::B; - case REVISION_C: - return AubMemDump::SteppingValues::C; - case REVISION_D: - return AubMemDump::SteppingValues::D; - case REVISION_K: - return AubMemDump::SteppingValues::K; - } -} - HwInfoConfigTestWindows::HwInfoConfigTestWindows() { this->executionEnvironment = std::make_unique(); this->rootDeviceEnvironment = std::make_unique(*executionEnvironment); @@ -180,16 +74,6 @@ TEST_F(HwInfoConfigTestWindows, givenInstrumentationForHardwareIsEnabledOrDisabl EXPECT_TRUE(outHwInfo.capabilityTable.instrumentationEnabled); } -HWTEST_F(HwInfoConfigTestWindows, givenHardwareInfoWhenCallingIsAdditionalStateBaseAddressWARequiredThenFalseIsReturned) { - bool ret = hwConfig.isAdditionalStateBaseAddressWARequired(outHwInfo); - EXPECT_FALSE(ret); -} - -HWTEST_F(HwInfoConfigTestWindows, givenHardwareInfoWhenCallingIsMaxThreadsForWorkgroupWARequiredThenFalseIsReturned) { - bool ret = hwConfig.isMaxThreadsForWorkgroupWARequired(outHwInfo); - EXPECT_FALSE(ret); -} - HWTEST_F(HwInfoConfigTestWindows, givenFtrIaCoherencyFlagWhenConfiguringHwInfoThenSetCoherencySupportCorrectly) { HardwareInfo initialHwInfo = *defaultHwInfo; auto &hwHelper = HwHelper::get(initialHwInfo.platform.eRenderCoreFamily); @@ -207,19 +91,4 @@ HWTEST_F(HwInfoConfigTestWindows, givenFtrIaCoherencyFlagWhenConfiguringHwInfoTh EXPECT_EQ(initialCoherencyStatus, outHwInfo.capabilityTable.ftrSupportsCoherency); } -HWTEST_F(HwInfoConfigTestWindows, givenHardwareInfoWhenCallingObtainBlitterPreferenceThenFalseIsReturned) { - bool ret = hwConfig.obtainBlitterPreference(outHwInfo); - EXPECT_FALSE(ret); -} - -HWTEST_F(HwInfoConfigTestWindows, givenHardwareInfoWhenCallingIsPageTableManagerSupportedThenFalseIsReturned) { - bool ret = hwConfig.isPageTableManagerSupported(outHwInfo); - EXPECT_FALSE(ret); -} - -HWTEST_F(HwInfoConfigTestWindows, givenHardwareInfoWhenCallingGetSteppingFromHwRevIdThenInvalidSteppingIsReturned) { - uint32_t ret = hwConfig.getSteppingFromHwRevId(outHwInfo); - EXPECT_EQ(CommonConstants::invalidStepping, ret); -} - } // namespace NEO diff --git a/shared/test/unit_test/os_interface/CMakeLists.txt b/shared/test/unit_test/os_interface/CMakeLists.txt index bc62622582..5c46e009d9 100644 --- a/shared/test/unit_test/os_interface/CMakeLists.txt +++ b/shared/test/unit_test/os_interface/CMakeLists.txt @@ -8,6 +8,8 @@ set(NEO_CORE_OS_INTERFACE_AUB_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt ${CMAKE_CURRENT_SOURCE_DIR}/aub_memory_operations_handler_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/aub_memory_operations_handler_tests.h + ${CMAKE_CURRENT_SOURCE_DIR}/os_agnostic_hw_info_config_tests.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/os_agnostic_hw_info_config_tests.h ) set_property(GLOBAL PROPERTY NEO_CORE_OS_INTERFACE_AUB_TESTS ${NEO_CORE_OS_INTERFACE_AUB_TESTS}) diff --git a/shared/test/unit_test/os_interface/os_agnostic_hw_info_config_tests.cpp b/shared/test/unit_test/os_interface/os_agnostic_hw_info_config_tests.cpp new file mode 100644 index 0000000000..10fc719cbb --- /dev/null +++ b/shared/test/unit_test/os_interface/os_agnostic_hw_info_config_tests.cpp @@ -0,0 +1,152 @@ +/* + * Copyright (C) 2021 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/test/unit_test/os_interface/os_agnostic_hw_info_config_tests.h" + +#include "shared/source/helpers/hw_helper.h" + +template <> +void HwInfoConfigHw::adjustSamplerState(void *sampler, const HardwareInfo &hwInfo) { +} + +template <> +void HwInfoConfigHw::convertTimestampsFromOaToCsDomain(uint64_t ×tampData) { +} + +template <> +uint32_t HwInfoConfigHw::getMaxThreadsForWorkgroupInDSSOrSS(const HardwareInfo &hwInfo, uint32_t maxNumEUsPerSubSlice, uint32_t maxNumEUsPerDualSubSlice) const { + return 0; +} + +template <> +uint32_t HwInfoConfigHw::getMaxThreadsForWorkgroup(const HardwareInfo &hwInfo, uint32_t maxNumEUsPerSubSlice) const { + return 0; +} + +template <> +void HwInfoConfigHw::setForceNonCoherent(void *const commandPtr, const StateComputeModeProperties &properties) { +} + +template <> +void HwInfoConfigHw::adjustPlatformForProductFamily(HardwareInfo *hwInfo) { +} + +template <> +uint64_t HwInfoConfigHw::getSharedSystemMemCapabilities() { + return 0; +} + +template <> +uint64_t HwInfoConfigHw::getHostMemCapabilities(const HardwareInfo * /*hwInfo*/) { + return 0; +} + +template <> +uint64_t HwInfoConfigHw::getDeviceMemCapabilities() { + return 0; +} + +template <> +uint64_t HwInfoConfigHw::getSingleDeviceSharedMemCapabilities() { + return 0; +} + +template <> +uint64_t HwInfoConfigHw::getCrossDeviceSharedMemCapabilities() { + return 0; +} + +template <> +void HwInfoConfigHw::getKernelExtendedProperties(uint32_t *fp16, uint32_t *fp32, uint32_t *fp64) { +} + +template <> +uint32_t HwInfoConfigHw::getDeviceMemoryMaxClkRate(const HardwareInfo *hwInfo) { + return 0; +} + +template <> +bool HwInfoConfigHw::isAdditionalStateBaseAddressWARequired(const HardwareInfo &hwInfo) const { + return false; +} + +template <> +bool HwInfoConfigHw::isMaxThreadsForWorkgroupWARequired(const HardwareInfo &hwInfo) const { + return false; +} + +template <> +bool HwInfoConfigHw::obtainBlitterPreference(const HardwareInfo &hwInfo) const { + return false; +} + +template <> +bool HwInfoConfigHw::isPageTableManagerSupported(const HardwareInfo &hwInfo) const { + return false; +} + +template <> +uint32_t HwInfoConfigHw::getHwRevIdFromStepping(uint32_t stepping, const HardwareInfo &hwInfo) const { + return CommonConstants::invalidStepping; +} + +template <> +uint32_t HwInfoConfigHw::getSteppingFromHwRevId(const HardwareInfo &hwInfo) const { + return CommonConstants::invalidStepping; +} + +template <> +uint32_t HwInfoConfigHw::getAubStreamSteppingFromHwRevId(const HardwareInfo &hwInfo) const { + switch (getSteppingFromHwRevId(hwInfo)) { + default: + case REVISION_A0: + case REVISION_A1: + case REVISION_A3: + return AubMemDump::SteppingValues::A; + case REVISION_B: + return AubMemDump::SteppingValues::B; + case REVISION_C: + return AubMemDump::SteppingValues::C; + case REVISION_D: + return AubMemDump::SteppingValues::D; + case REVISION_K: + return AubMemDump::SteppingValues::K; + } +} + +void OsAgnosticHwInfoConfigTest::SetUp() { + DeviceFixture::SetUp(); +} + +void OsAgnosticHwInfoConfigTest::TearDown() { + DeviceFixture::TearDown(); +} + +HWTEST_F(OsAgnosticHwInfoConfigTest, givenHardwareInfoWhenCallingObtainBlitterPreferenceThenFalseIsReturned) { + bool ret = hwConfig.obtainBlitterPreference(hardwareInfo); + EXPECT_FALSE(ret); +} + +HWTEST_F(OsAgnosticHwInfoConfigTest, givenHardwareInfoWhenCallingIsPageTableManagerSupportedThenFalseIsReturned) { + bool ret = hwConfig.isPageTableManagerSupported(hardwareInfo); + EXPECT_FALSE(ret); +} + +HWTEST_F(OsAgnosticHwInfoConfigTest, givenHardwareInfoWhenCallingGetSteppingFromHwRevIdThenInvalidSteppingIsReturned) { + uint32_t ret = hwConfig.getSteppingFromHwRevId(hardwareInfo); + EXPECT_EQ(CommonConstants::invalidStepping, ret); +} + +HWTEST_F(OsAgnosticHwInfoConfigTest, givenHardwareInfoWhenCallingIsAdditionalStateBaseAddressWARequiredThenFalseIsReturned) { + bool ret = hwConfig.isAdditionalStateBaseAddressWARequired(hardwareInfo); + EXPECT_FALSE(ret); +} + +HWTEST_F(OsAgnosticHwInfoConfigTest, givenHardwareInfoWhenCallingIsMaxThreadsForWorkgroupWARequiredThenFalseIsReturned) { + bool ret = hwConfig.isMaxThreadsForWorkgroupWARequired(hardwareInfo); + EXPECT_FALSE(ret); +} diff --git a/shared/test/unit_test/os_interface/os_agnostic_hw_info_config_tests.h b/shared/test/unit_test/os_interface/os_agnostic_hw_info_config_tests.h new file mode 100644 index 0000000000..b8c2a595bc --- /dev/null +++ b/shared/test/unit_test/os_interface/os_agnostic_hw_info_config_tests.h @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2021 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#pragma once + +#include "shared/source/os_interface/hw_info_config.h" +#include "shared/test/common/fixtures/device_fixture.h" + +#include "test.h" + +using namespace NEO; + +struct DummyHwConfig : HwInfoConfigHw { +}; + +struct OsAgnosticHwInfoConfigTest : public ::testing::Test, + public DeviceFixture { + void SetUp() override; + void TearDown() override; + + DummyHwConfig hwConfig; +};