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 c8d9743e76..b58b752691 100644 --- a/opencl/test/unit_test/offline_compiler/offline_compiler_tests.cpp +++ b/opencl/test/unit_test/offline_compiler/offline_compiler_tests.cpp @@ -489,6 +489,28 @@ TEST_F(OfflineCompilerTests, givenDeviceNumerationWhenPassedValuesAreOutOfRangeT EXPECT_EQ(CL_INVALID_DEVICE, retVal); } +TEST_F(OfflineCompilerTests, givenInitHardwareInfowhenDeviceConfigContainsDeviceIdsThenSetFirstDeviceId) { + MockOfflineCompiler mockOfflineCompiler; + auto &allEnabledDeviceConfigs = mockOfflineCompiler.argHelper->getAllSupportedDeviceConfigs(); + if (allEnabledDeviceConfigs.empty()) { + GTEST_SKIP(); + } + + std::vector deviceIdsForTests = {0xfffd, 0xfffe, 0xffff}; + + for (auto &deviceMapConfig : allEnabledDeviceConfigs) { + if (productFamily == deviceMapConfig.hwInfo->platform.eProductFamily) { + mockOfflineCompiler.deviceName = mockOfflineCompiler.argHelper->parseProductConfigFromValue(deviceMapConfig.config); + deviceMapConfig.deviceIds = &deviceIdsForTests; + break; + } + } + + mockOfflineCompiler.initHardwareInfo(mockOfflineCompiler.deviceName); + EXPECT_EQ(mockOfflineCompiler.hwInfo.platform.eProductFamily, productFamily); + EXPECT_EQ(mockOfflineCompiler.hwInfo.platform.usDeviceID, deviceIdsForTests.front()); +} + TEST_F(OfflineCompilerTests, givenIncorrectDeviceIdWithIncorrectHexPatternThenInvalidDeviceIsReturned) { std::vector argv = { "ocloc", diff --git a/opencl/test/unit_test/offline_compiler/xe_hpc_core/CMakeLists.txt b/opencl/test/unit_test/offline_compiler/xe_hpc_core/CMakeLists.txt new file mode 100644 index 0000000000..8c2a6a09b2 --- /dev/null +++ b/opencl/test/unit_test/offline_compiler/xe_hpc_core/CMakeLists.txt @@ -0,0 +1,13 @@ +# +# Copyright (C) 2022 Intel Corporation +# +# SPDX-License-Identifier: MIT +# + +if(TESTS_XE_HPC_CORE) + set(IGDRCL_SRCS_offline_compiler_tests_xe_hpc_core + ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt + ) + target_sources(ocloc_tests PRIVATE ${IGDRCL_SRCS_offline_compiler_tests_xe_hpc_core}) + add_subdirectories() +endif() diff --git a/opencl/test/unit_test/offline_compiler/xe_hpc_core/pvc/CMakeLists.txt b/opencl/test/unit_test/offline_compiler/xe_hpc_core/pvc/CMakeLists.txt new file mode 100644 index 0000000000..9b62318d1d --- /dev/null +++ b/opencl/test/unit_test/offline_compiler/xe_hpc_core/pvc/CMakeLists.txt @@ -0,0 +1,14 @@ +# +# Copyright (C) 2022 Intel Corporation +# +# SPDX-License-Identifier: MIT +# + +if(TESTS_PVC) + set(IGDRCL_SRCS_offline_compiler_tests_pvc + ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt + ${CMAKE_CURRENT_SOURCE_DIR}/offline_compiler_tests_pvc.cpp + ) + target_sources(ocloc_tests PRIVATE ${IGDRCL_SRCS_offline_compiler_tests_pvc}) + +endif() diff --git a/opencl/test/unit_test/offline_compiler/xe_hpc_core/pvc/offline_compiler_tests_pvc.cpp b/opencl/test/unit_test/offline_compiler/xe_hpc_core/pvc/offline_compiler_tests_pvc.cpp new file mode 100644 index 0000000000..2885bff608 --- /dev/null +++ b/opencl/test/unit_test/offline_compiler/xe_hpc_core/pvc/offline_compiler_tests_pvc.cpp @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2022 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/test/common/test_macros/test.h" + +#include "opencl/test/unit_test/offline_compiler/mock/mock_offline_compiler.h" + +namespace NEO { + +using MockOfflineCompilerPvcTests = ::testing::Test; + +PVCTEST_F(MockOfflineCompilerPvcTests, GivenPvcXlA0ConfigWhenInitHardwareInfoThenCorrectValuesAreSet) { + MockOfflineCompiler mockOfflineCompiler; + auto pvcConfig = PVC_XL_A0; + auto pvcXlId = PVC_XL_IDS.front(); + mockOfflineCompiler.deviceName = mockOfflineCompiler.argHelper->parseProductConfigFromValue(pvcConfig); + mockOfflineCompiler.initHardwareInfo(mockOfflineCompiler.deviceName); + + EXPECT_EQ(mockOfflineCompiler.hwInfo.platform.eProductFamily, IGFX_PVC); + EXPECT_EQ(mockOfflineCompiler.hwInfo.platform.usRevId, 0x0); + EXPECT_EQ(mockOfflineCompiler.hwInfo.platform.usDeviceID, pvcXlId); +} + +PVCTEST_F(MockOfflineCompilerPvcTests, GivenPvcXlB0ConfigWhenInitHardwareInfoThenCorrectValuesAreSet) { + MockOfflineCompiler mockOfflineCompiler; + auto pvcConfig = PVC_XL_B0; + auto pvcXlId = PVC_XL_IDS.front(); + mockOfflineCompiler.deviceName = mockOfflineCompiler.argHelper->parseProductConfigFromValue(pvcConfig); + mockOfflineCompiler.initHardwareInfo(mockOfflineCompiler.deviceName); + + EXPECT_EQ(mockOfflineCompiler.hwInfo.platform.eProductFamily, IGFX_PVC); + EXPECT_EQ(mockOfflineCompiler.hwInfo.platform.usRevId, 0x01); + EXPECT_EQ(mockOfflineCompiler.hwInfo.platform.usDeviceID, pvcXlId); +} + +PVCTEST_F(MockOfflineCompilerPvcTests, GivenPvcXtA0ConfigWhenInitHardwareInfoThenCorrectValuesAreSet) { + MockOfflineCompiler mockOfflineCompiler; + auto pvcConfig = PVC_XT_A0; + auto pvcXtId = PVC_XT_IDS.front(); + mockOfflineCompiler.deviceName = mockOfflineCompiler.argHelper->parseProductConfigFromValue(pvcConfig); + mockOfflineCompiler.initHardwareInfo(mockOfflineCompiler.deviceName); + + EXPECT_EQ(mockOfflineCompiler.hwInfo.platform.eProductFamily, IGFX_PVC); + EXPECT_EQ(mockOfflineCompiler.hwInfo.platform.usRevId, 0x03); + EXPECT_EQ(mockOfflineCompiler.hwInfo.platform.usDeviceID, pvcXtId); +} + +PVCTEST_F(MockOfflineCompilerPvcTests, GivenPvcXtB0ConfigWhenInitHardwareInfoThenCorrectValuesAreSet) { + MockOfflineCompiler mockOfflineCompiler; + auto pvcConfig = PVC_XT_B0; + auto pvcXtId = PVC_XT_IDS.front(); + mockOfflineCompiler.deviceName = mockOfflineCompiler.argHelper->parseProductConfigFromValue(pvcConfig); + mockOfflineCompiler.initHardwareInfo(mockOfflineCompiler.deviceName); + + EXPECT_EQ(mockOfflineCompiler.hwInfo.platform.eProductFamily, IGFX_PVC); + EXPECT_EQ(mockOfflineCompiler.hwInfo.platform.usRevId, 0x1E); + EXPECT_EQ(mockOfflineCompiler.hwInfo.platform.usDeviceID, pvcXtId); +} + +} // namespace NEO \ No newline at end of file diff --git a/opencl/test/unit_test/offline_compiler/xe_hpg_core/CMakeLists.txt b/opencl/test/unit_test/offline_compiler/xe_hpg_core/CMakeLists.txt new file mode 100644 index 0000000000..c8ee5fdec2 --- /dev/null +++ b/opencl/test/unit_test/offline_compiler/xe_hpg_core/CMakeLists.txt @@ -0,0 +1,13 @@ +# +# Copyright (C) 2022 Intel Corporation +# +# SPDX-License-Identifier: MIT +# + +if(TESTS_XE_HPG_CORE) + set(IGDRCL_SRCS_offline_compiler_tests_xe_hpg_core + ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt + ) + target_sources(ocloc_tests PRIVATE ${IGDRCL_SRCS_offline_compiler_tests_xe_hpg_core}) + add_subdirectories() +endif() diff --git a/opencl/test/unit_test/offline_compiler/xe_hpg_core/dg2/CMakeLists.txt b/opencl/test/unit_test/offline_compiler/xe_hpg_core/dg2/CMakeLists.txt new file mode 100644 index 0000000000..9c0f13bce7 --- /dev/null +++ b/opencl/test/unit_test/offline_compiler/xe_hpg_core/dg2/CMakeLists.txt @@ -0,0 +1,16 @@ +# +# Copyright (C) 2022 Intel Corporation +# +# SPDX-License-Identifier: MIT +# + +if(TESTS_DG2) + set(IGDRCL_SRCS_offline_compiler_tests_dg2 + ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt + ${CMAKE_CURRENT_SOURCE_DIR}/offline_compiler_tests_dg2.cpp + ) + target_sources(ocloc_tests PRIVATE ${IGDRCL_SRCS_offline_compiler_tests_dg2}) + +endif() + +add_subdirectories() diff --git a/opencl/test/unit_test/offline_compiler/xe_hpg_core/dg2/offline_compiler_tests_dg2.cpp b/opencl/test/unit_test/offline_compiler/xe_hpg_core/dg2/offline_compiler_tests_dg2.cpp new file mode 100644 index 0000000000..7ded7234d6 --- /dev/null +++ b/opencl/test/unit_test/offline_compiler/xe_hpg_core/dg2/offline_compiler_tests_dg2.cpp @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2022 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/test/common/test_macros/test.h" + +#include "opencl/test/unit_test/offline_compiler/mock/mock_offline_compiler.h" + +namespace NEO { + +using MockOfflineCompilerDg2Tests = ::testing::Test; + +DG2TEST_F(MockOfflineCompilerDg2Tests, GivenDg2G10A0ConfigWhenInitHardwareInfoThenCorrectValuesAreSet) { + MockOfflineCompiler mockOfflineCompiler; + PRODUCT_CONFIG dg2Config = DG2_G10_A0; + auto dg2G10Id = DG2_G10_IDS.front(); + mockOfflineCompiler.deviceName = mockOfflineCompiler.argHelper->parseProductConfigFromValue(dg2Config); + + mockOfflineCompiler.initHardwareInfo(mockOfflineCompiler.deviceName); + + EXPECT_EQ(mockOfflineCompiler.hwInfo.platform.eProductFamily, IGFX_DG2); + EXPECT_EQ(mockOfflineCompiler.hwInfo.platform.usRevId, 0x0); + EXPECT_EQ(mockOfflineCompiler.hwInfo.platform.usDeviceID, dg2G10Id); +} + +DG2TEST_F(MockOfflineCompilerDg2Tests, GivenDg2G10B0ConfigWhenInitHardwareInfoThenCorrectValuesAreSet) { + MockOfflineCompiler mockOfflineCompiler; + PRODUCT_CONFIG dg2Config = DG2_G10_B0; + auto dg2G10Id = DG2_G10_IDS.front(); + mockOfflineCompiler.deviceName = mockOfflineCompiler.argHelper->parseProductConfigFromValue(dg2Config); + + mockOfflineCompiler.initHardwareInfo(mockOfflineCompiler.deviceName); + + EXPECT_EQ(mockOfflineCompiler.hwInfo.platform.eProductFamily, IGFX_DG2); + EXPECT_EQ(mockOfflineCompiler.hwInfo.platform.usRevId, 0x4); + EXPECT_EQ(mockOfflineCompiler.hwInfo.platform.usDeviceID, dg2G10Id); +} + +DG2TEST_F(MockOfflineCompilerDg2Tests, GivenDg2G11ConfigWhenInitHardwareInfoThenCorrectValuesAreSet) { + MockOfflineCompiler mockOfflineCompiler; + PRODUCT_CONFIG dg2Config = DG2_G11; + auto dg2G11Id = DG2_G11_IDS.front(); + mockOfflineCompiler.deviceName = mockOfflineCompiler.argHelper->parseProductConfigFromValue(dg2Config); + + mockOfflineCompiler.initHardwareInfo(mockOfflineCompiler.deviceName); + + EXPECT_EQ(mockOfflineCompiler.hwInfo.platform.eProductFamily, IGFX_DG2); + EXPECT_EQ(mockOfflineCompiler.hwInfo.platform.usRevId, 0x0); + EXPECT_EQ(mockOfflineCompiler.hwInfo.platform.usDeviceID, dg2G11Id); +} + +} // namespace NEO \ No newline at end of file diff --git a/shared/offline_compiler/source/ocloc_arg_helper.cpp b/shared/offline_compiler/source/ocloc_arg_helper.cpp index e06bdb3328..be322ef473 100644 --- a/shared/offline_compiler/source/ocloc_arg_helper.cpp +++ b/shared/offline_compiler/source/ocloc_arg_helper.cpp @@ -57,11 +57,13 @@ OclocArgHelper::OclocArgHelper(const uint32_t numSources, const uint8_t **dataSo #undef NAMEDDEVICE {0u, std::string("")}}), deviceMap({ -#define DEVICE_CONFIG_REVISION(product, productConfig, revision_id) {product, &NEO::productConfig::hwInfo, NEO::productConfig::setupHardwareInfo, revision_id}, -#define DEVICE_CONFIG(product, productConfig) {product, &NEO::productConfig::hwInfo, 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::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}, #include "product_config.inl" #undef DEVICE_CONFIG -#undef DEVICE_CONFIG_REVISION +#undef DEVICE_CONFIG_IDS +#undef DEVICE_CONFIG_IDS_AND_REVISION }) { for (uint32_t i = 0; i < numSources; ++i) { inputs.push_back(Source(dataSources[i], static_cast(lenSources[i]), nameSources[i])); @@ -165,12 +167,16 @@ void OclocArgHelper::setDeviceInfoForFatbinaryTarget(const DeviceMapping &device deviceForFatbinary.hwInfo = device.hwInfo; deviceForFatbinary.setupHardwareInfo = device.setupHardwareInfo; deviceForFatbinary.revId = device.revId; + deviceForFatbinary.deviceIds = device.deviceIds; } void OclocArgHelper::setHwInfoForFatbinaryTarget(NEO::HardwareInfo &hwInfo) { hwInfo = *deviceForFatbinary.hwInfo; deviceForFatbinary.setupHardwareInfo(&hwInfo, true); hwInfo.platform.usRevId = deviceForFatbinary.revId; + if (deviceForFatbinary.deviceIds) { + hwInfo.platform.usDeviceID = deviceForFatbinary.deviceIds->front(); + } } bool OclocArgHelper::getHwInfoForProductConfig(uint32_t config, NEO::HardwareInfo &hwInfo) { @@ -183,6 +189,9 @@ bool OclocArgHelper::getHwInfoForProductConfig(uint32_t config, NEO::HardwareInf hwInfo = *deviceConfig.hwInfo; deviceConfig.setupHardwareInfo(&hwInfo, true); hwInfo.platform.usRevId = deviceConfig.revId; + if (deviceConfig.deviceIds) { + hwInfo.platform.usDeviceID = deviceConfig.deviceIds->front(); + } retVal = true; return retVal; } @@ -227,7 +236,7 @@ std::string OclocArgHelper::returnProductNameForDevice(unsigned short deviceId) return res; } -std::vector OclocArgHelper::getAllSupportedDeviceConfigs() { +std::vector &OclocArgHelper::getAllSupportedDeviceConfigs() { return deviceMap; } diff --git a/shared/offline_compiler/source/ocloc_arg_helper.h b/shared/offline_compiler/source/ocloc_arg_helper.h index 65f2b30f60..22eba9d2d7 100644 --- a/shared/offline_compiler/source/ocloc_arg_helper.h +++ b/shared/offline_compiler/source/ocloc_arg_helper.h @@ -8,6 +8,7 @@ #include "shared/offline_compiler/source/decoder/helper.h" #include "shared/source/helpers/hw_info.h" +#include "device_ids_configs.h" #include "hw_cmds.h" #include "platforms.h" @@ -49,6 +50,7 @@ struct DeviceProduct { struct DeviceMapping { PRODUCT_CONFIG config; const NEO::HardwareInfo *hwInfo; + const std::vector *deviceIds; void (*setupHardwareInfo)(NEO::HardwareInfo *hwInfo, bool setupFeatureTableAndWorkaroundTable); unsigned int revId; @@ -109,7 +111,7 @@ class OclocArgHelper { void setDeviceInfoForFatbinaryTarget(const DeviceMapping &device); void setHwInfoForFatbinaryTarget(NEO::HardwareInfo &hwInfo); std::vector getAllSupportedProductConfigs(); - std::vector getAllSupportedDeviceConfigs(); + std::vector &getAllSupportedDeviceConfigs(); std::vector getMajorMinorRevision(const std::string &device); uint32_t getProductConfig(std::vector &numeration); uint32_t getMaskForConfig(std::vector &numeration); diff --git a/shared/source/dll/devices/product_config.inl b/shared/source/dll/devices/product_config.inl index d5c169501a..ddab15db80 100644 --- a/shared/source/dll/devices/product_config.inl +++ b/shared/source/dll/devices/product_config.inl @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Intel Corporation + * Copyright (C) 2021-2022 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -9,16 +9,16 @@ #ifdef SUPPORT_XE_HPG_CORE #ifdef SUPPORT_DG2 -DEVICE_CONFIG_REVISION(DG2_G10_A0, DG2_CONFIG, 0x00) -DEVICE_CONFIG_REVISION(DG2_G10_B0, DG2_CONFIG, 0x04) +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_REVISION(PVC_XT_A0, PVC_CONFIG, 0x03) -DEVICE_CONFIG_REVISION(PVC_XT_B0, PVC_CONFIG, 0x1E) -DEVICE_CONFIG_REVISION(PVC_XL_A0, PVC_CONFIG, 0x00) -DEVICE_CONFIG_REVISION(PVC_XL_B0, PVC_CONFIG, 0x01) +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/helpers/CMakeLists.txt b/shared/source/helpers/CMakeLists.txt index dd0a94da8e..6c18b12f96 100644 --- a/shared/source/helpers/CMakeLists.txt +++ b/shared/source/helpers/CMakeLists.txt @@ -129,6 +129,7 @@ set(NEO_CORE_HELPERS ${CMAKE_CURRENT_SOURCE_DIR}/validators.h ${CMAKE_CURRENT_SOURCE_DIR}/vec.h ${CMAKE_CURRENT_SOURCE_DIR}/definitions${BRANCH_DIR_SUFFIX}hw_cmds.h + ${CMAKE_CURRENT_SOURCE_DIR}/definitions${BRANCH_DIR_SUFFIX}device_ids_configs.h ${CMAKE_CURRENT_SOURCE_DIR}/definitions/engine_group_types.h ${CMAKE_CURRENT_SOURCE_DIR}/definitions/mi_flush_args.h ) diff --git a/shared/source/helpers/definitions/device_ids_configs.h b/shared/source/helpers/definitions/device_ids_configs.h new file mode 100644 index 0000000000..d8c3af5fe9 --- /dev/null +++ b/shared/source/helpers/definitions/device_ids_configs.h @@ -0,0 +1,20 @@ +/* + * Copyright (C) 2022 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#pragma once + +#ifdef SUPPORT_XE_HPG_CORE +#ifdef SUPPORT_DG2 +#include "shared/source/xe_hpg_core/definitions/device_ids_configs_dg2.h" +#endif +#endif + +#if SUPPORT_XE_HPC_CORE +#ifdef SUPPORT_PVC +#include "shared/source/xe_hpc_core/definitions/device_ids_configs_pvc.h" +#endif +#endif diff --git a/shared/source/xe_hpc_core/definitions/device_ids_configs_pvc.h b/shared/source/xe_hpc_core/definitions/device_ids_configs_pvc.h new file mode 100644 index 0000000000..8eb27e8288 --- /dev/null +++ b/shared/source/xe_hpc_core/definitions/device_ids_configs_pvc.h @@ -0,0 +1,15 @@ +/* + * Copyright (C) 2022 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#pragma once + +#include + +namespace NEO { +static const std::vector PVC_XT_IDS{0x0BD5}; +static const std::vector PVC_XL_IDS{0x0BD0}; +} // namespace NEO \ No newline at end of file diff --git a/shared/source/xe_hpg_core/definitions/device_ids_configs_dg2.h b/shared/source/xe_hpg_core/definitions/device_ids_configs_dg2.h new file mode 100644 index 0000000000..1aa4ed3bfd --- /dev/null +++ b/shared/source/xe_hpg_core/definitions/device_ids_configs_dg2.h @@ -0,0 +1,15 @@ +/* + * Copyright (C) 2022 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#pragma once + +#include + +namespace NEO { +static const std::vector DG2_G10_IDS{0x4F80, 0x4F81, 0x4F82, 0x4F83, 0x4F84, 0x5690, 0x5691, 0x5692, 0x56A0, 0x56A1, 0x56A2, 0x56C0}; +static const std::vector DG2_G11_IDS{0x4F87, 0x4F88, 0x5693, 0x5694, 0x5695, 0x56A5, 0x56A6, 0x56B0, 0x56B1, 0x56C1}; +} // namespace NEO \ No newline at end of file