From 1f524e9d1c2881f9669ab43f312060b3ac50e764 Mon Sep 17 00:00:00 2001 From: Katarzyna Cencelewska Date: Thu, 16 Oct 2025 19:41:56 +0000 Subject: [PATCH] feature: add check for product and hw info override in non hw mode Related-To: HSD-18043580274 Signed-off-by: Katarzyna Cencelewska --- shared/source/dll/get_devices.cpp | 4 ++ shared/source/os_interface/device_factory.cpp | 30 ++++++++- shared/source/os_interface/device_factory.h | 3 + shared/source/os_interface/product_helper.h | 1 + shared/source/os_interface/product_helper.inl | 5 ++ .../source/os_interface/product_helper_hw.h | 1 + .../command_stream/get_devices_tests.cpp | 1 - .../os_interface/device_factory_tests.cpp | 61 +++++++++++++++++++ .../os_interface/product_helper_tests.cpp | 6 +- 9 files changed, 109 insertions(+), 3 deletions(-) diff --git a/shared/source/dll/get_devices.cpp b/shared/source/dll/get_devices.cpp index 2fcb2990b5..8e3e08a1b1 100644 --- a/shared/source/dll/get_devices.cpp +++ b/shared/source/dll/get_devices.cpp @@ -9,6 +9,7 @@ #include "shared/source/debug_settings/debug_settings_manager.h" #include "shared/source/execution_environment/execution_environment.h" #include "shared/source/execution_environment/root_device_environment.h" +#include "shared/source/os_interface/device_factory.h" #include "shared/source/os_interface/product_helper.h" #include "hw_cmds_default.h" @@ -28,6 +29,9 @@ bool prepareDeviceEnvironments(ExecutionEnvironment &executionEnvironment, std:: } if (returnValue) { + if (!DeviceFactory::validateDeviceFlags(executionEnvironment.rootDeviceEnvironments[0]->getProductHelper())) { + return false; + } auto i = 0u; while (i < executionEnvironment.rootDeviceEnvironments.size()) { executionEnvironment.rootDeviceEnvironments[i]->initGmm(); diff --git a/shared/source/os_interface/device_factory.cpp b/shared/source/os_interface/device_factory.cpp index 01dff035ea..cc5fee1b03 100644 --- a/shared/source/os_interface/device_factory.cpp +++ b/shared/source/os_interface/device_factory.cpp @@ -125,7 +125,7 @@ bool DeviceFactory::prepareDeviceEnvironmentsForProductFamilyOverride(ExecutionE auto aubCenter = rootDeviceEnvironment.aubCenter.get(); rootDeviceEnvironment.memoryOperationsInterface = std::make_unique(aubCenter->getAubManager()); - if (csrType == CommandStreamReceiverType::tbx || csrType == CommandStreamReceiverType::tbxWithAub) { + if (DeviceFactory::isTbxModeSelected()) { auto capsReader = productHelper.getDeviceCapsReader(*aubCenter->getAubManager()); if (capsReader) { if (!productHelper.setupHardwareInfo(*hardwareInfo, *capsReader)) { @@ -183,6 +183,34 @@ bool DeviceFactory::isHwModeSelected() { } } +bool DeviceFactory::isTbxModeSelected() { + CommandStreamReceiverType csrType = obtainCsrTypeFromIntegerValue(debugManager.flags.SetCommandStreamReceiver.get(), CommandStreamReceiverType::hardware); + switch (csrType) { + case CommandStreamReceiverType::tbx: + case CommandStreamReceiverType::tbxWithAub: + return true; + default: + return false; + } +} + +bool DeviceFactory::validateDeviceFlags(const ProductHelper &productHelper) { + bool ret = true; + if (!DeviceFactory::isHwModeSelected()) { + + if (debugManager.flags.ProductFamilyOverride.get() == "unk") { + PRINT_DEBUG_STRING(true, stderr, "Missing override for product family, required to set flag ProductFamilyOverride in non hw mode\n"); + ret = false; + } + + if (!(productHelper.isDeviceCapsReaderSupported()) && debugManager.flags.HardwareInfoOverride.get() == "default") { + PRINT_DEBUG_STRING(true, stderr, "Missing override for hardware info, required to set flag HardwareInfoOverride in non hw mode\n"); + ret = false; + } + } + return ret; +} + static bool initHwDeviceIdResources(ExecutionEnvironment &executionEnvironment, std::unique_ptr &&hwDeviceId, uint32_t rootDeviceIndex) { if (!executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->initOsInterface(std::move(hwDeviceId), rootDeviceIndex)) { diff --git a/shared/source/os_interface/device_factory.h b/shared/source/os_interface/device_factory.h index 02bac68e8f..8b900ef2c6 100644 --- a/shared/source/os_interface/device_factory.h +++ b/shared/source/os_interface/device_factory.h @@ -15,6 +15,7 @@ namespace NEO { class ExecutionEnvironment; class Device; +class ProductHelper; struct HardwareInfo; const HardwareInfo *getDefaultHwInfo(); bool prepareDeviceEnvironments(ExecutionEnvironment &executionEnvironment); @@ -24,9 +25,11 @@ class DeviceFactory { static bool prepareDeviceEnvironments(ExecutionEnvironment &executionEnvironment); static bool prepareDeviceEnvironment(ExecutionEnvironment &executionEnvironment, std::string &osPciPath, const uint32_t rootDeviceIndex); static bool prepareDeviceEnvironmentsForProductFamilyOverride(ExecutionEnvironment &executionEnvironment); + static bool validateDeviceFlags(const ProductHelper &productHelper); static std::vector> createDevices(ExecutionEnvironment &executionEnvironment); static std::unique_ptr createDevice(ExecutionEnvironment &executionEnvironment, std::string &osPciPath, const uint32_t rootDeviceIndex); static bool isHwModeSelected(); + static bool isTbxModeSelected(); static std::unique_ptr (*createRootDeviceFunc)(ExecutionEnvironment &executionEnvironment, uint32_t rootDeviceIndex); static bool (*createMemoryManagerFunc)(ExecutionEnvironment &executionEnvironment); diff --git a/shared/source/os_interface/product_helper.h b/shared/source/os_interface/product_helper.h index 4d3e9c490a..6b0672cbb7 100644 --- a/shared/source/os_interface/product_helper.h +++ b/shared/source/os_interface/product_helper.h @@ -279,6 +279,7 @@ class ProductHelper { virtual bool shouldRegisterEnqueuedWalkerWithProfiling() const = 0; virtual bool isInterruptSupported() const = 0; virtual bool isCompressionFormatFromGmmRequired() const = 0; + virtual bool isDeviceCapsReaderSupported() const = 0; virtual bool isMediaContextSupported() const = 0; virtual uint32_t getActualHwSlmSize(const RootDeviceEnvironment &rootDeviceEnvironment) const = 0; diff --git a/shared/source/os_interface/product_helper.inl b/shared/source/os_interface/product_helper.inl index 4a6e22e34b..59f8c5029d 100644 --- a/shared/source/os_interface/product_helper.inl +++ b/shared/source/os_interface/product_helper.inl @@ -1106,6 +1106,11 @@ bool ProductHelperHw::isCompressionFormatFromGmmRequired() const { return false; } +template +bool ProductHelperHw::isDeviceCapsReaderSupported() const { + return false; +} + template bool ProductHelperHw::isMediaContextSupported() const { return false; diff --git a/shared/source/os_interface/product_helper_hw.h b/shared/source/os_interface/product_helper_hw.h index 5822f6a8c6..015be95a4a 100644 --- a/shared/source/os_interface/product_helper_hw.h +++ b/shared/source/os_interface/product_helper_hw.h @@ -217,6 +217,7 @@ class ProductHelperHw : public ProductHelper { uint32_t getActualHwSlmSize(const RootDeviceEnvironment &rootDeviceEnvironment) const override; bool isInterruptSupported() const override; bool isCompressionFormatFromGmmRequired() const override; + bool isDeviceCapsReaderSupported() const override; bool isMediaContextSupported() const override; ~ProductHelperHw() override = default; diff --git a/shared/test/unit_test/command_stream/get_devices_tests.cpp b/shared/test/unit_test/command_stream/get_devices_tests.cpp index b333443bca..b36f1aaa5a 100644 --- a/shared/test/unit_test/command_stream/get_devices_tests.cpp +++ b/shared/test/unit_test/command_stream/get_devices_tests.cpp @@ -406,5 +406,4 @@ HWTEST_F(PrepareDeviceEnvironmentsTest, givenPrepareDeviceEnvironmentsAndUnknown } } } - } // namespace NEO diff --git a/shared/test/unit_test/os_interface/device_factory_tests.cpp b/shared/test/unit_test/os_interface/device_factory_tests.cpp index 813b15ce28..292a0afcdd 100644 --- a/shared/test/unit_test/os_interface/device_factory_tests.cpp +++ b/shared/test/unit_test/os_interface/device_factory_tests.cpp @@ -12,6 +12,8 @@ #include "shared/test/common/helpers/debug_manager_state_restore.h" #include "shared/test/common/helpers/default_hw_info.h" #include "shared/test/common/helpers/device_caps_reader_test_helper.h" +#include "shared/test/common/helpers/gtest_helpers.h" +#include "shared/test/common/helpers/stream_capture.h" #include "shared/test/common/mocks/mock_execution_environment.h" #include "shared/test/common/mocks/mock_product_helper.h" #include "shared/test/common/test_macros/hw_test.h" @@ -325,4 +327,63 @@ TEST_F(DeviceFactoryOverrideTest, givenDefaultHwInfoWhenPrepareDeviceEnvironment EXPECT_TRUE(success); auto hwInfo = executionEnvironment.rootDeviceEnvironments[0]->getHardwareInfo(); EXPECT_EQ(hwInfo->capabilityTable.maxProgrammableSlmSize, hwInfo->gtSystemInfo.SLMSizeInKb); +} + +HWTEST_F(DeviceFactoryOverrideTest, GivenAubModeWhenValidateDeviceFlagsThenIsProperMessagePrintedAndValueReturned) { + DebugManagerStateRestore restorer; + debugManager.flags.SetCommandStreamReceiver.set(static_cast(CommandStreamReceiverType::aub)); + std::string expectedMissingProductFamilyStderrSubstr("Missing override for product family, required to set flag ProductFamilyOverride in non hw mode\n"); + std::string expectedMissingHardwareInfoStderrSubstr("Missing override for hardware info, required to set flag HardwareInfoOverride in non hw mode\n"); + auto defaultProductFamily = hardwarePrefix[defaultHwInfo.get()->platform.eProductFamily]; + auto &productHelper = executionEnvironment.rootDeviceEnvironments[0]->getProductHelper(); + StreamCapture capture; + + { + debugManager.flags.ProductFamilyOverride.set("unk"); + debugManager.flags.HardwareInfoOverride.set("default"); + capture.captureStderr(); + EXPECT_FALSE(DeviceFactory::validateDeviceFlags(productHelper)); + auto capturedStderr = capture.getCapturedStderr(); + + EXPECT_TRUE(hasSubstr(capturedStderr, expectedMissingProductFamilyStderrSubstr)); + EXPECT_TRUE(hasSubstr(capturedStderr, expectedMissingHardwareInfoStderrSubstr)); + } + { + debugManager.flags.ProductFamilyOverride.set(defaultProductFamily); + debugManager.flags.HardwareInfoOverride.set("default"); + capture.captureStderr(); + EXPECT_FALSE(DeviceFactory::validateDeviceFlags(productHelper)); + auto capturedStderr = capture.getCapturedStderr(); + EXPECT_FALSE(hasSubstr(capturedStderr, expectedMissingProductFamilyStderrSubstr)); + EXPECT_TRUE(hasSubstr(capturedStderr, expectedMissingHardwareInfoStderrSubstr)); + } + + { + debugManager.flags.ProductFamilyOverride.set("unk"); + debugManager.flags.HardwareInfoOverride.set("1x1x1"); + capture.captureStderr(); + EXPECT_FALSE(DeviceFactory::validateDeviceFlags(productHelper)); + auto capturedStderr = capture.getCapturedStderr(); + EXPECT_TRUE(hasSubstr(capturedStderr, expectedMissingProductFamilyStderrSubstr)); + EXPECT_FALSE(hasSubstr(capturedStderr, expectedMissingHardwareInfoStderrSubstr)); + } + + { + + debugManager.flags.ProductFamilyOverride.set(defaultProductFamily); + debugManager.flags.HardwareInfoOverride.set("1x1x1"); + capture.captureStderr(); + EXPECT_TRUE(DeviceFactory::validateDeviceFlags(productHelper)); + auto capturedStderr = capture.getCapturedStderr(); + EXPECT_FALSE(hasSubstr(capturedStderr, expectedMissingProductFamilyStderrSubstr)); + EXPECT_FALSE(hasSubstr(capturedStderr, expectedMissingHardwareInfoStderrSubstr)); + } + { + debugManager.flags.SetCommandStreamReceiver.set(static_cast(CommandStreamReceiverType::hardware)); + capture.captureStderr(); + EXPECT_TRUE(DeviceFactory::validateDeviceFlags(productHelper)); + auto capturedStderr = capture.getCapturedStderr(); + EXPECT_FALSE(hasSubstr(capturedStderr, expectedMissingProductFamilyStderrSubstr)); + EXPECT_FALSE(hasSubstr(capturedStderr, expectedMissingHardwareInfoStderrSubstr)); + } } \ No newline at end of file diff --git a/shared/test/unit_test/os_interface/product_helper_tests.cpp b/shared/test/unit_test/os_interface/product_helper_tests.cpp index ce353b7239..1f908645bb 100644 --- a/shared/test/unit_test/os_interface/product_helper_tests.cpp +++ b/shared/test/unit_test/os_interface/product_helper_tests.cpp @@ -1305,6 +1305,10 @@ HWTEST2_F(ProductHelperTest, givenNonDG1ProductHelperWhenCanShareMemoryWithoutNT EXPECT_EQ(productHelper->canShareMemoryWithoutNTHandle(), 1u); } +HWTEST_F(ProductHelperTest, givenProductHelperWhenAskedIsDeviceCapsReaderSupportedThenReturnFalse) { + EXPECT_FALSE(productHelper->isDeviceCapsReaderSupported()); +} + HWTEST_F(ProductHelperTest, givenProductHelperWhenAskingIsMediaContextSupportedThenFalseReturned) { EXPECT_FALSE(productHelper->isMediaContextSupported()); -} \ No newline at end of file +}