Set device ids for PRODUCT_CONFIG

Ocloc must set the default device id if the user
selects <major>.<minor>.<revision> pattern.

Signed-off-by: Daria Hinz <daria.hinz@intel.com>
This commit is contained in:
Daria Hinz
2022-02-22 15:00:35 +00:00
committed by Compute-Runtime-Automation
parent 7a2c5e28c1
commit 0c6863766a
14 changed files with 271 additions and 12 deletions

View File

@@ -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<unsigned short> 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<std::string> argv = {
"ocloc",

View File

@@ -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()

View File

@@ -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()

View File

@@ -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

View File

@@ -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()

View File

@@ -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()

View File

@@ -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

View File

@@ -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<size_t>(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<DeviceMapping> OclocArgHelper::getAllSupportedDeviceConfigs() {
std::vector<DeviceMapping> &OclocArgHelper::getAllSupportedDeviceConfigs() {
return deviceMap;
}

View File

@@ -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<unsigned short> *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<PRODUCT_CONFIG> getAllSupportedProductConfigs();
std::vector<DeviceMapping> getAllSupportedDeviceConfigs();
std::vector<DeviceMapping> &getAllSupportedDeviceConfigs();
std::vector<uint32_t> getMajorMinorRevision(const std::string &device);
uint32_t getProductConfig(std::vector<uint32_t> &numeration);
uint32_t getMaskForConfig(std::vector<uint32_t> &numeration);

View File

@@ -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

View File

@@ -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
)

View File

@@ -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

View File

@@ -0,0 +1,15 @@
/*
* Copyright (C) 2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include <vector>
namespace NEO {
static const std::vector<unsigned short> PVC_XT_IDS{0x0BD5};
static const std::vector<unsigned short> PVC_XL_IDS{0x0BD0};
} // namespace NEO

View File

@@ -0,0 +1,15 @@
/*
* Copyright (C) 2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include <vector>
namespace NEO {
static const std::vector<unsigned short> DG2_G10_IDS{0x4F80, 0x4F81, 0x4F82, 0x4F83, 0x4F84, 0x5690, 0x5691, 0x5692, 0x56A0, 0x56A1, 0x56A2, 0x56C0};
static const std::vector<unsigned short> DG2_G11_IDS{0x4F87, 0x4F88, 0x5693, 0x5694, 0x5695, 0x56A5, 0x56A6, 0x56B0, 0x56B1, 0x56C1};
} // namespace NEO