From efa57f734bc7c6aede68aad458c32a0eff7f34a4 Mon Sep 17 00:00:00 2001 From: Daria Hinz Date: Wed, 23 Mar 2022 15:37:39 +0000 Subject: [PATCH] Reset GT_SYSTEM_INFO values in ocloc For AOT compilation, we don't want to set random/default values. The uploaded structure to IGC will be reset. Signed-off-by: Daria Hinz --- .../offline_compiler_tests.cpp | 25 +++++++++++++++++++ .../source/ocloc_arg_helper.cpp | 12 ++++----- .../source/ocloc_arg_helper.h | 4 +-- shared/source/dll/devices/product_config.inl | 16 ------------ .../dll/devices/product_config_base.inl | 19 +++++++++++++- 5 files changed, 51 insertions(+), 25 deletions(-) diff --git a/opencl/test/unit_test/offline_compiler/offline_compiler_tests.cpp b/opencl/test/unit_test/offline_compiler/offline_compiler_tests.cpp index c0418930bd..0402b539a6 100644 --- a/opencl/test/unit_test/offline_compiler/offline_compiler_tests.cpp +++ b/opencl/test/unit_test/offline_compiler/offline_compiler_tests.cpp @@ -314,6 +314,31 @@ TEST_F(MultiCommandTests, GivenOutputFileListFlagWhenBuildingMultiCommandThenSuc delete pMultiCommand; } +TEST(MockOfflineCompilerTests, givenProductConfigValueWhenInitHwInfoThenResetGtSystemInfo) { + MockOfflineCompiler mockOfflineCompiler; + auto allEnabledDeviceConfigs = mockOfflineCompiler.argHelper->getAllSupportedDeviceConfigs(); + if (allEnabledDeviceConfigs.empty()) { + GTEST_SKIP(); + } + + auto expectedRevId = 0u; + for (auto &deviceMapConfig : allEnabledDeviceConfigs) { + if (productFamily == deviceMapConfig.hwInfo->platform.eProductFamily) { + mockOfflineCompiler.deviceName = mockOfflineCompiler.argHelper->parseProductConfigFromValue(deviceMapConfig.config); + expectedRevId = deviceMapConfig.revId; + } + } + + EXPECT_FALSE(mockOfflineCompiler.deviceName.empty()); + + mockOfflineCompiler.initHardwareInfo(mockOfflineCompiler.deviceName); + GT_SYSTEM_INFO expectedGtSystemInfo = {0}; + + EXPECT_EQ(mockOfflineCompiler.hwInfo.platform.usRevId, expectedRevId); + EXPECT_EQ(mockOfflineCompiler.hwInfo.platform.eProductFamily, productFamily); + EXPECT_EQ(memcmp(&mockOfflineCompiler.hwInfo.gtSystemInfo, &expectedGtSystemInfo, sizeof(GT_SYSTEM_INFO)), 0); +} + TEST_F(OfflineCompilerTests, GivenHelpOptionOnQueryThenSuccessIsReturned) { std::vector argv = { "ocloc", diff --git a/shared/offline_compiler/source/ocloc_arg_helper.cpp b/shared/offline_compiler/source/ocloc_arg_helper.cpp index be322ef473..e4585b4229 100644 --- a/shared/offline_compiler/source/ocloc_arg_helper.cpp +++ b/shared/offline_compiler/source/ocloc_arg_helper.cpp @@ -57,9 +57,9 @@ OclocArgHelper::OclocArgHelper(const uint32_t numSources, const uint8_t **dataSo #undef NAMEDDEVICE {0u, std::string("")}}), deviceMap({ -#define DEVICE_CONFIG_IDS_AND_REVISION(product, productConfig, deviceIds, revision_id) {product, &NEO::productConfig::hwInfo, &NEO::deviceIds, NEO::productConfig::setupHardwareInfo, revision_id}, -#define DEVICE_CONFIG_IDS(product, productConfig, deviceIds) {product, &NEO::productConfig::hwInfo, &NEO::deviceIds, NEO::productConfig::setupHardwareInfo, NEO::productConfig::hwInfo.platform.usRevId}, -#define DEVICE_CONFIG(product, productConfig) {product, &NEO::productConfig::hwInfo, nullptr, NEO::productConfig::setupHardwareInfo, NEO::productConfig::hwInfo.platform.usRevId}, +#define DEVICE_CONFIG_IDS_AND_REVISION(product, productConfig, deviceIds, revision_id) {product, &NEO::productConfig::hwInfo, &NEO::deviceIds, NEO::productConfig::setupFeatureAndWorkaroundTable, revision_id}, +#define DEVICE_CONFIG_IDS(product, productConfig, deviceIds) {product, &NEO::productConfig::hwInfo, &NEO::deviceIds, NEO::productConfig::setupFeatureAndWorkaroundTable, NEO::productConfig::hwInfo.platform.usRevId}, +#define DEVICE_CONFIG(product, productConfig) {product, &NEO::productConfig::hwInfo, nullptr, NEO::productConfig::setupFeatureAndWorkaroundTable, NEO::productConfig::hwInfo.platform.usRevId}, #include "product_config.inl" #undef DEVICE_CONFIG #undef DEVICE_CONFIG_IDS @@ -165,14 +165,14 @@ std::unique_ptr OclocArgHelper::loadDataFromFile(const std::string &file void OclocArgHelper::setDeviceInfoForFatbinaryTarget(const DeviceMapping &device) { deviceForFatbinary.hwInfo = device.hwInfo; - deviceForFatbinary.setupHardwareInfo = device.setupHardwareInfo; + deviceForFatbinary.setupFeatureAndWorkaroundTable = device.setupFeatureAndWorkaroundTable; deviceForFatbinary.revId = device.revId; deviceForFatbinary.deviceIds = device.deviceIds; } void OclocArgHelper::setHwInfoForFatbinaryTarget(NEO::HardwareInfo &hwInfo) { hwInfo = *deviceForFatbinary.hwInfo; - deviceForFatbinary.setupHardwareInfo(&hwInfo, true); + deviceForFatbinary.setupFeatureAndWorkaroundTable(&hwInfo); hwInfo.platform.usRevId = deviceForFatbinary.revId; if (deviceForFatbinary.deviceIds) { hwInfo.platform.usDeviceID = deviceForFatbinary.deviceIds->front(); @@ -187,7 +187,7 @@ bool OclocArgHelper::getHwInfoForProductConfig(uint32_t config, NEO::HardwareInf for (auto &deviceConfig : deviceMap) { if (deviceConfig.config == config) { hwInfo = *deviceConfig.hwInfo; - deviceConfig.setupHardwareInfo(&hwInfo, true); + deviceConfig.setupFeatureAndWorkaroundTable(&hwInfo); hwInfo.platform.usRevId = deviceConfig.revId; if (deviceConfig.deviceIds) { hwInfo.platform.usDeviceID = deviceConfig.deviceIds->front(); diff --git a/shared/offline_compiler/source/ocloc_arg_helper.h b/shared/offline_compiler/source/ocloc_arg_helper.h index 22eba9d2d7..1c85e0008c 100644 --- a/shared/offline_compiler/source/ocloc_arg_helper.h +++ b/shared/offline_compiler/source/ocloc_arg_helper.h @@ -51,11 +51,11 @@ struct DeviceMapping { PRODUCT_CONFIG config; const NEO::HardwareInfo *hwInfo; const std::vector *deviceIds; - void (*setupHardwareInfo)(NEO::HardwareInfo *hwInfo, bool setupFeatureTableAndWorkaroundTable); + void (*setupFeatureAndWorkaroundTable)(NEO::HardwareInfo *hwInfo); unsigned int revId; bool operator==(const DeviceMapping &rhs) { - return config == rhs.config && hwInfo == rhs.hwInfo && setupHardwareInfo == rhs.setupHardwareInfo && revId == rhs.revId; + return config == rhs.config && hwInfo == rhs.hwInfo && setupFeatureAndWorkaroundTable == rhs.setupFeatureAndWorkaroundTable && revId == rhs.revId; } }; diff --git a/shared/source/dll/devices/product_config.inl b/shared/source/dll/devices/product_config.inl index ddab15db80..0667b014bb 100644 --- a/shared/source/dll/devices/product_config.inl +++ b/shared/source/dll/devices/product_config.inl @@ -6,19 +6,3 @@ */ #include "shared/source/dll/devices/product_config_base.inl" - -#ifdef SUPPORT_XE_HPG_CORE -#ifdef SUPPORT_DG2 -DEVICE_CONFIG_IDS_AND_REVISION(DG2_G10_A0, DG2_CONFIG, DG2_G10_IDS, 0x00) -DEVICE_CONFIG_IDS_AND_REVISION(DG2_G10_B0, DG2_CONFIG, DG2_G10_IDS, 0x04) -#endif -#endif - -#if SUPPORT_XE_HPC_CORE -#ifdef SUPPORT_PVC -DEVICE_CONFIG_IDS_AND_REVISION(PVC_XT_A0, PVC_CONFIG, PVC_XT_IDS, 0x03) -DEVICE_CONFIG_IDS_AND_REVISION(PVC_XT_B0, PVC_CONFIG, PVC_XT_IDS, 0x1E) -DEVICE_CONFIG_IDS_AND_REVISION(PVC_XL_A0, PVC_CONFIG, PVC_XL_IDS, 0x00) -DEVICE_CONFIG_IDS_AND_REVISION(PVC_XL_B0, PVC_CONFIG, PVC_XL_IDS, 0x01) -#endif -#endif \ No newline at end of file diff --git a/shared/source/dll/devices/product_config_base.inl b/shared/source/dll/devices/product_config_base.inl index 49faff60ce..4407dff31a 100644 --- a/shared/source/dll/devices/product_config_base.inl +++ b/shared/source/dll/devices/product_config_base.inl @@ -1,10 +1,27 @@ /* - * Copyright (C) 2021 Intel Corporation + * Copyright (C) 2021-2022 Intel Corporation * * SPDX-License-Identifier: MIT * */ +#if SUPPORT_XE_HPC_CORE +#ifdef SUPPORT_PVC +DEVICE_CONFIG_IDS_AND_REVISION(PVC_XT_A0, PVC_CONFIG, PVC_XT_IDS, 0x03) +DEVICE_CONFIG_IDS_AND_REVISION(PVC_XT_B0, PVC_CONFIG, PVC_XT_IDS, 0x1E) +DEVICE_CONFIG_IDS_AND_REVISION(PVC_XL_A0, PVC_CONFIG, PVC_XL_IDS, 0x00) +DEVICE_CONFIG_IDS_AND_REVISION(PVC_XL_B0, PVC_CONFIG, PVC_XL_IDS, 0x01) +#endif +#endif + +#ifdef SUPPORT_XE_HPG_CORE +#ifdef SUPPORT_DG2 +DEVICE_CONFIG_IDS_AND_REVISION(DG2_G10_A0, DG2_CONFIG, DG2_G10_IDS, 0x00) +DEVICE_CONFIG_IDS_AND_REVISION(DG2_G10_B0, DG2_CONFIG, DG2_G10_IDS, 0x04) +DEVICE_CONFIG_IDS(DG2_G11, DG2_CONFIG, DG2_G11_IDS) +#endif +#endif + #ifdef SUPPORT_XE_HP_CORE #ifdef SUPPORT_XE_HP_SDV DEVICE_CONFIG(XEHP_SDV, XE_HP_SDV_CONFIG)