diff --git a/runtime/compiler_interface/compiler_interface.cpp b/runtime/compiler_interface/compiler_interface.cpp index cfc14b9baa..6d73ef5f22 100644 --- a/runtime/compiler_interface/compiler_interface.cpp +++ b/runtime/compiler_interface/compiler_interface.cpp @@ -460,7 +460,7 @@ CIF::RAII::UPtr_t CompilerInterface::createIgcT const HardwareInfo *hwInfo = &device.getHardwareInfo(); auto productFamily = DebugManager.flags.ForceCompilerUsePlatform.get(); if (productFamily != "unk") { - getHwInfoForPlatformString(productFamily.c_str(), hwInfo); + getHwInfoForPlatformString(productFamily, hwInfo); } IGC::PlatformHelper::PopulateInterfaceWith(*igcPlatform, hwInfo->platform); IGC::GtSysInfoHelper::PopulateInterfaceWith(*igcGtSystemInfo, hwInfo->gtSystemInfo); diff --git a/runtime/helpers/hw_info.cpp b/runtime/helpers/hw_info.cpp index bc135b442c..97a0192163 100644 --- a/runtime/helpers/hw_info.cpp +++ b/runtime/helpers/hw_info.cpp @@ -11,6 +11,8 @@ #include "hw_cmds.h" +#include + namespace NEO { HardwareInfo::HardwareInfo(const PLATFORM *platform, const FeatureTable *featureTable, const WorkaroundTable *workaroundTable, const GT_SYSTEM_INFO *gtSystemInfo, const RuntimeCapabilityTable &capabilityTable) @@ -29,12 +31,14 @@ const char *getPlatformType(const HardwareInfo &hwInfo) { return "lp"; } -bool getHwInfoForPlatformString(const char *str, const HardwareInfo *&hwInfoIn) { +bool getHwInfoForPlatformString(std::string &platform, const HardwareInfo *&hwInfoIn) { + std::transform(platform.begin(), platform.end(), platform.begin(), ::tolower); + bool ret = false; for (int j = 0; j < IGFX_MAX_PRODUCT; j++) { if (hardwarePrefix[j] == nullptr) continue; - if (strcmp(hardwarePrefix[j], str) == 0) { + if (hardwarePrefix[j] == platform) { hwInfoIn = hardwareInfoTable[j]; ret = true; break; diff --git a/runtime/helpers/hw_info.h b/runtime/helpers/hw_info.h index 9220cd17cd..f296b7d085 100644 --- a/runtime/helpers/hw_info.h +++ b/runtime/helpers/hw_info.h @@ -100,6 +100,6 @@ struct EnableGfxFamilyHw { }; const char *getPlatformType(const HardwareInfo &hwInfo); -bool getHwInfoForPlatformString(const char *str, const HardwareInfo *&hwInfoIn); +bool getHwInfoForPlatformString(std::string &platform, const HardwareInfo *&hwInfoIn); aub_stream::EngineType getChosenEngineType(const HardwareInfo &hwInfo); } // namespace NEO diff --git a/runtime/os_interface/device_factory.cpp b/runtime/os_interface/device_factory.cpp index 4924b5f933..33839529ba 100644 --- a/runtime/os_interface/device_factory.cpp +++ b/runtime/os_interface/device_factory.cpp @@ -19,7 +19,7 @@ bool DeviceFactory::getDevicesForProductFamilyOverride(size_t &numDevices, Execu } auto productFamily = DebugManager.flags.ProductFamilyOverride.get(); auto hwInfoConst = *platformDevices; - getHwInfoForPlatformString(productFamily.c_str(), hwInfoConst); + getHwInfoForPlatformString(productFamily, hwInfoConst); numDevices = 0; std::string hwInfoConfig; DebugManager.getHardwareInfoOverride(hwInfoConfig); diff --git a/unit_tests/command_stream/get_devices_tests.cpp b/unit_tests/command_stream/get_devices_tests.cpp index 1cc3d50773..982d28ea76 100644 --- a/unit_tests/command_stream/get_devices_tests.cpp +++ b/unit_tests/command_stream/get_devices_tests.cpp @@ -109,6 +109,36 @@ HWTEST_F(GetDevicesTest, givenGetDevicesWhenCsrIsSetToVariousTypesThenTheFunctio } } +HWTEST_F(GetDevicesTest, givenUpperCaseProductFamilyOverrideFlagSetWhenCreatingDevicesThenFindExpectedPlatform) { + std::string hwPrefix; + std::string hwPrefixUpperCase; + PRODUCT_FAMILY productFamily; + + for (int productFamilyIndex = 0; productFamilyIndex < IGFX_MAX_PRODUCT; productFamilyIndex++) { + if (hardwarePrefix[productFamilyIndex]) { + hwPrefix = hardwarePrefix[productFamilyIndex]; + productFamily = static_cast(productFamilyIndex); + break; + } + } + + EXPECT_NE(0u, hwPrefix.length()); + hwPrefixUpperCase.resize(hwPrefix.length()); + std::transform(hwPrefix.begin(), hwPrefix.end(), hwPrefixUpperCase.begin(), ::toupper); + EXPECT_NE(hwPrefix, hwPrefixUpperCase); + + DebugManager.flags.ProductFamilyOverride.set(hwPrefixUpperCase); + DebugManager.flags.SetCommandStreamReceiver.set(CommandStreamReceiverType::CSR_AUB); + + ExecutionEnvironment *exeEnv = platformImpl->peekExecutionEnvironment(); + bool ret = getDevices(numDevices, *exeEnv); + + EXPECT_TRUE(ret); + EXPECT_EQ(productFamily, exeEnv->getHardwareInfo()->platform.eProductFamily); + + DeviceFactory::releaseDevices(); +} + HWTEST_F(GetDevicesTest, givenGetDevicesAndUnknownProductFamilyWhenCsrIsSetToValidTypeThenTheFunctionReturnsTheExpectedValueOfHardwareInfo) { uint32_t expectedDevices = 1; DebugManager.flags.CreateMultipleDevices.set(expectedDevices);