From afd5f766c29ccbcf3d7c8754e8ed31473b0001f0 Mon Sep 17 00:00:00 2001 From: Bartosz Dunajski Date: Mon, 28 Jun 2021 13:44:09 +0000 Subject: [PATCH] HwHelper: update getSubDevicesCount and getEnginesCount implementation Signed-off-by: Bartosz Dunajski --- opencl/test/unit_test/device/device_tests.cpp | 32 +++++++++++++++++++ .../unit_test/helpers/hw_helper_tests.cpp | 16 ++++++++++ shared/source/helpers/hw_helper.cpp | 24 ++++++++++++++ shared/source/helpers/hw_helper_extended.cpp | 11 +------ 4 files changed, 73 insertions(+), 10 deletions(-) diff --git a/opencl/test/unit_test/device/device_tests.cpp b/opencl/test/unit_test/device/device_tests.cpp index 5ef6a0476a..3fe6fd1063 100644 --- a/opencl/test/unit_test/device/device_tests.cpp +++ b/opencl/test/unit_test/device/device_tests.cpp @@ -715,3 +715,35 @@ HWCMDTEST_F(IGFX_GEN8_CORE, DeviceQueueFamiliesTests, givenCopyQueueWhenGettingQ auto device = std::make_unique(MockDevice::createWithNewExecutionEnvironment(defaultHwInfo.get())); EXPECT_EQ(expectedBlitterCapabilities, device->getQueueFamilyCapabilities(NEO::EngineGroupType::Copy)); } + +TEST(ClDeviceHelperTest, givenNonZeroNumberOfTilesWhenPrepareDeviceEnvironmentsCountCalledThenReturnCorrectValue) { + DebugManagerStateRestore stateRestore; + FeatureTable skuTable; + WorkaroundTable waTable = {}; + RuntimeCapabilityTable capTable = {}; + GT_SYSTEM_INFO sysInfo = {}; + sysInfo.MultiTileArchInfo.IsValid = true; + sysInfo.MultiTileArchInfo.TileCount = 3; + PLATFORM platform = {}; + HardwareInfo hwInfo{&platform, &skuTable, &waTable, &sysInfo, capTable}; + DebugManager.flags.CreateMultipleSubDevices.set(0); + + uint32_t devicesCount = HwHelper::getSubDevicesCount(&hwInfo); + EXPECT_EQ(devicesCount, 3u); +} + +TEST(ClDeviceHelperTest, givenZeroNumberOfTilesWhenPrepareDeviceEnvironmentsCountCalledThenReturnCorrectValue) { + DebugManagerStateRestore stateRestore; + FeatureTable skuTable; + WorkaroundTable waTable = {}; + RuntimeCapabilityTable capTable = {}; + GT_SYSTEM_INFO sysInfo = {}; + sysInfo.MultiTileArchInfo.IsValid = true; + sysInfo.MultiTileArchInfo.TileCount = 0; + PLATFORM platform = {}; + HardwareInfo hwInfo{&platform, &skuTable, &waTable, &sysInfo, capTable}; + DebugManager.flags.CreateMultipleSubDevices.set(0); + + uint32_t devicesCount = HwHelper::getSubDevicesCount(&hwInfo); + EXPECT_EQ(devicesCount, 1u); +} \ No newline at end of file diff --git a/opencl/test/unit_test/helpers/hw_helper_tests.cpp b/opencl/test/unit_test/helpers/hw_helper_tests.cpp index 9e253478c8..483118a288 100644 --- a/opencl/test/unit_test/helpers/hw_helper_tests.cpp +++ b/opencl/test/unit_test/helpers/hw_helper_tests.cpp @@ -1334,3 +1334,19 @@ HWTEST_F(HwHelperTest, whenSetRenderCompressedFlagThenProperFlagSet) { hwHelper.applyRenderCompressionFlag(*gmm, 0); EXPECT_EQ(0u, gmm->resourceParams.Flags.Info.RenderCompressed); } + +HWTEST_F(HwHelperTest, givenRcsOrCcsEnabledWhenQueryingEngineCountThenReturnCorrectValue) { + HardwareInfo hwInfo = *defaultHwInfo; + + hwInfo.gtSystemInfo.CCSInfo.NumberOfCCSEnabled = 3; + hwInfo.featureTable.ftrRcsNode = false; + hwInfo.featureTable.ftrCCSNode = false; + + EXPECT_EQ(0u, HwHelper::getEnginesCount(hwInfo)); + + hwInfo.featureTable.ftrCCSNode = true; + EXPECT_EQ(3u, HwHelper::getEnginesCount(hwInfo)); + + hwInfo.featureTable.ftrRcsNode = true; + EXPECT_EQ(4u, HwHelper::getEnginesCount(hwInfo)); +} diff --git a/shared/source/helpers/hw_helper.cpp b/shared/source/helpers/hw_helper.cpp index 11daef08c8..7ed75feab5 100644 --- a/shared/source/helpers/hw_helper.cpp +++ b/shared/source/helpers/hw_helper.cpp @@ -59,4 +59,28 @@ uint32_t HwHelper::getMaxThreadsForWorkgroup(const HardwareInfo &hwInfo, uint32_ uint32_t numThreadsPerEU = hwInfo.gtSystemInfo.ThreadCount / hwInfo.gtSystemInfo.EUCount; return maxNumEUsPerSubSlice * numThreadsPerEU; } + +uint32_t HwHelper::getSubDevicesCount(const HardwareInfo *pHwInfo) { + if (DebugManager.flags.CreateMultipleSubDevices.get() > 0) { + return DebugManager.flags.CreateMultipleSubDevices.get(); + } else if (pHwInfo->gtSystemInfo.MultiTileArchInfo.IsValid && pHwInfo->gtSystemInfo.MultiTileArchInfo.TileCount > 0u) { + return pHwInfo->gtSystemInfo.MultiTileArchInfo.TileCount; + } else { + return 1u; + } +} + +uint32_t HwHelper::getEnginesCount(const HardwareInfo &hwInfo) { + uint32_t enginesCount = 0; + + if (hwInfo.featureTable.ftrCCSNode) { + enginesCount += hwInfo.gtSystemInfo.CCSInfo.NumberOfCCSEnabled; + } + + if (hwInfo.featureTable.ftrRcsNode) { + enginesCount += 1; + } + + return enginesCount; +} } // namespace NEO diff --git a/shared/source/helpers/hw_helper_extended.cpp b/shared/source/helpers/hw_helper_extended.cpp index aaec04f97c..ac9a44fcb5 100644 --- a/shared/source/helpers/hw_helper_extended.cpp +++ b/shared/source/helpers/hw_helper_extended.cpp @@ -1,23 +1,14 @@ /* - * Copyright (C) 2020 Intel Corporation + * Copyright (C) 2020-2021 Intel Corporation * * SPDX-License-Identifier: MIT * */ -#include "shared/source/debug_settings/debug_settings_manager.h" #include "shared/source/helpers/hw_helper.h" namespace NEO { -uint32_t HwHelper::getSubDevicesCount(const HardwareInfo *pHwInfo) { - return DebugManager.flags.CreateMultipleSubDevices.get() > 0 ? DebugManager.flags.CreateMultipleSubDevices.get() : 1u; -} - -uint32_t HwHelper::getEnginesCount(const HardwareInfo &hwInfo) { - return 1u; -} - uint32_t HwHelper::getCopyEnginesCount(const HardwareInfo &hwInfo) { return hwInfo.capabilityTable.blitterOperationsSupported ? 1 : 0; }