Skip to content

Commit 0c68637

Browse files
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 <[email protected]>
1 parent 7a2c5e2 commit 0c68637

File tree

14 files changed

+271
-12
lines changed

14 files changed

+271
-12
lines changed

opencl/test/unit_test/offline_compiler/offline_compiler_tests.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,28 @@ TEST_F(OfflineCompilerTests, givenDeviceNumerationWhenPassedValuesAreOutOfRangeT
489489
EXPECT_EQ(CL_INVALID_DEVICE, retVal);
490490
}
491491

492+
TEST_F(OfflineCompilerTests, givenInitHardwareInfowhenDeviceConfigContainsDeviceIdsThenSetFirstDeviceId) {
493+
MockOfflineCompiler mockOfflineCompiler;
494+
auto &allEnabledDeviceConfigs = mockOfflineCompiler.argHelper->getAllSupportedDeviceConfigs();
495+
if (allEnabledDeviceConfigs.empty()) {
496+
GTEST_SKIP();
497+
}
498+
499+
std::vector<unsigned short> deviceIdsForTests = {0xfffd, 0xfffe, 0xffff};
500+
501+
for (auto &deviceMapConfig : allEnabledDeviceConfigs) {
502+
if (productFamily == deviceMapConfig.hwInfo->platform.eProductFamily) {
503+
mockOfflineCompiler.deviceName = mockOfflineCompiler.argHelper->parseProductConfigFromValue(deviceMapConfig.config);
504+
deviceMapConfig.deviceIds = &deviceIdsForTests;
505+
break;
506+
}
507+
}
508+
509+
mockOfflineCompiler.initHardwareInfo(mockOfflineCompiler.deviceName);
510+
EXPECT_EQ(mockOfflineCompiler.hwInfo.platform.eProductFamily, productFamily);
511+
EXPECT_EQ(mockOfflineCompiler.hwInfo.platform.usDeviceID, deviceIdsForTests.front());
512+
}
513+
492514
TEST_F(OfflineCompilerTests, givenIncorrectDeviceIdWithIncorrectHexPatternThenInvalidDeviceIsReturned) {
493515
std::vector<std::string> argv = {
494516
"ocloc",
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#
2+
# Copyright (C) 2022 Intel Corporation
3+
#
4+
# SPDX-License-Identifier: MIT
5+
#
6+
7+
if(TESTS_XE_HPC_CORE)
8+
set(IGDRCL_SRCS_offline_compiler_tests_xe_hpc_core
9+
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
10+
)
11+
target_sources(ocloc_tests PRIVATE ${IGDRCL_SRCS_offline_compiler_tests_xe_hpc_core})
12+
add_subdirectories()
13+
endif()
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#
2+
# Copyright (C) 2022 Intel Corporation
3+
#
4+
# SPDX-License-Identifier: MIT
5+
#
6+
7+
if(TESTS_PVC)
8+
set(IGDRCL_SRCS_offline_compiler_tests_pvc
9+
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
10+
${CMAKE_CURRENT_SOURCE_DIR}/offline_compiler_tests_pvc.cpp
11+
)
12+
target_sources(ocloc_tests PRIVATE ${IGDRCL_SRCS_offline_compiler_tests_pvc})
13+
14+
endif()
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* Copyright (C) 2022 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#include "shared/test/common/test_macros/test.h"
9+
10+
#include "opencl/test/unit_test/offline_compiler/mock/mock_offline_compiler.h"
11+
12+
namespace NEO {
13+
14+
using MockOfflineCompilerPvcTests = ::testing::Test;
15+
16+
PVCTEST_F(MockOfflineCompilerPvcTests, GivenPvcXlA0ConfigWhenInitHardwareInfoThenCorrectValuesAreSet) {
17+
MockOfflineCompiler mockOfflineCompiler;
18+
auto pvcConfig = PVC_XL_A0;
19+
auto pvcXlId = PVC_XL_IDS.front();
20+
mockOfflineCompiler.deviceName = mockOfflineCompiler.argHelper->parseProductConfigFromValue(pvcConfig);
21+
mockOfflineCompiler.initHardwareInfo(mockOfflineCompiler.deviceName);
22+
23+
EXPECT_EQ(mockOfflineCompiler.hwInfo.platform.eProductFamily, IGFX_PVC);
24+
EXPECT_EQ(mockOfflineCompiler.hwInfo.platform.usRevId, 0x0);
25+
EXPECT_EQ(mockOfflineCompiler.hwInfo.platform.usDeviceID, pvcXlId);
26+
}
27+
28+
PVCTEST_F(MockOfflineCompilerPvcTests, GivenPvcXlB0ConfigWhenInitHardwareInfoThenCorrectValuesAreSet) {
29+
MockOfflineCompiler mockOfflineCompiler;
30+
auto pvcConfig = PVC_XL_B0;
31+
auto pvcXlId = PVC_XL_IDS.front();
32+
mockOfflineCompiler.deviceName = mockOfflineCompiler.argHelper->parseProductConfigFromValue(pvcConfig);
33+
mockOfflineCompiler.initHardwareInfo(mockOfflineCompiler.deviceName);
34+
35+
EXPECT_EQ(mockOfflineCompiler.hwInfo.platform.eProductFamily, IGFX_PVC);
36+
EXPECT_EQ(mockOfflineCompiler.hwInfo.platform.usRevId, 0x01);
37+
EXPECT_EQ(mockOfflineCompiler.hwInfo.platform.usDeviceID, pvcXlId);
38+
}
39+
40+
PVCTEST_F(MockOfflineCompilerPvcTests, GivenPvcXtA0ConfigWhenInitHardwareInfoThenCorrectValuesAreSet) {
41+
MockOfflineCompiler mockOfflineCompiler;
42+
auto pvcConfig = PVC_XT_A0;
43+
auto pvcXtId = PVC_XT_IDS.front();
44+
mockOfflineCompiler.deviceName = mockOfflineCompiler.argHelper->parseProductConfigFromValue(pvcConfig);
45+
mockOfflineCompiler.initHardwareInfo(mockOfflineCompiler.deviceName);
46+
47+
EXPECT_EQ(mockOfflineCompiler.hwInfo.platform.eProductFamily, IGFX_PVC);
48+
EXPECT_EQ(mockOfflineCompiler.hwInfo.platform.usRevId, 0x03);
49+
EXPECT_EQ(mockOfflineCompiler.hwInfo.platform.usDeviceID, pvcXtId);
50+
}
51+
52+
PVCTEST_F(MockOfflineCompilerPvcTests, GivenPvcXtB0ConfigWhenInitHardwareInfoThenCorrectValuesAreSet) {
53+
MockOfflineCompiler mockOfflineCompiler;
54+
auto pvcConfig = PVC_XT_B0;
55+
auto pvcXtId = PVC_XT_IDS.front();
56+
mockOfflineCompiler.deviceName = mockOfflineCompiler.argHelper->parseProductConfigFromValue(pvcConfig);
57+
mockOfflineCompiler.initHardwareInfo(mockOfflineCompiler.deviceName);
58+
59+
EXPECT_EQ(mockOfflineCompiler.hwInfo.platform.eProductFamily, IGFX_PVC);
60+
EXPECT_EQ(mockOfflineCompiler.hwInfo.platform.usRevId, 0x1E);
61+
EXPECT_EQ(mockOfflineCompiler.hwInfo.platform.usDeviceID, pvcXtId);
62+
}
63+
64+
} // namespace NEO
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#
2+
# Copyright (C) 2022 Intel Corporation
3+
#
4+
# SPDX-License-Identifier: MIT
5+
#
6+
7+
if(TESTS_XE_HPG_CORE)
8+
set(IGDRCL_SRCS_offline_compiler_tests_xe_hpg_core
9+
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
10+
)
11+
target_sources(ocloc_tests PRIVATE ${IGDRCL_SRCS_offline_compiler_tests_xe_hpg_core})
12+
add_subdirectories()
13+
endif()
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#
2+
# Copyright (C) 2022 Intel Corporation
3+
#
4+
# SPDX-License-Identifier: MIT
5+
#
6+
7+
if(TESTS_DG2)
8+
set(IGDRCL_SRCS_offline_compiler_tests_dg2
9+
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
10+
${CMAKE_CURRENT_SOURCE_DIR}/offline_compiler_tests_dg2.cpp
11+
)
12+
target_sources(ocloc_tests PRIVATE ${IGDRCL_SRCS_offline_compiler_tests_dg2})
13+
14+
endif()
15+
16+
add_subdirectories()
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Copyright (C) 2022 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#include "shared/test/common/test_macros/test.h"
9+
10+
#include "opencl/test/unit_test/offline_compiler/mock/mock_offline_compiler.h"
11+
12+
namespace NEO {
13+
14+
using MockOfflineCompilerDg2Tests = ::testing::Test;
15+
16+
DG2TEST_F(MockOfflineCompilerDg2Tests, GivenDg2G10A0ConfigWhenInitHardwareInfoThenCorrectValuesAreSet) {
17+
MockOfflineCompiler mockOfflineCompiler;
18+
PRODUCT_CONFIG dg2Config = DG2_G10_A0;
19+
auto dg2G10Id = DG2_G10_IDS.front();
20+
mockOfflineCompiler.deviceName = mockOfflineCompiler.argHelper->parseProductConfigFromValue(dg2Config);
21+
22+
mockOfflineCompiler.initHardwareInfo(mockOfflineCompiler.deviceName);
23+
24+
EXPECT_EQ(mockOfflineCompiler.hwInfo.platform.eProductFamily, IGFX_DG2);
25+
EXPECT_EQ(mockOfflineCompiler.hwInfo.platform.usRevId, 0x0);
26+
EXPECT_EQ(mockOfflineCompiler.hwInfo.platform.usDeviceID, dg2G10Id);
27+
}
28+
29+
DG2TEST_F(MockOfflineCompilerDg2Tests, GivenDg2G10B0ConfigWhenInitHardwareInfoThenCorrectValuesAreSet) {
30+
MockOfflineCompiler mockOfflineCompiler;
31+
PRODUCT_CONFIG dg2Config = DG2_G10_B0;
32+
auto dg2G10Id = DG2_G10_IDS.front();
33+
mockOfflineCompiler.deviceName = mockOfflineCompiler.argHelper->parseProductConfigFromValue(dg2Config);
34+
35+
mockOfflineCompiler.initHardwareInfo(mockOfflineCompiler.deviceName);
36+
37+
EXPECT_EQ(mockOfflineCompiler.hwInfo.platform.eProductFamily, IGFX_DG2);
38+
EXPECT_EQ(mockOfflineCompiler.hwInfo.platform.usRevId, 0x4);
39+
EXPECT_EQ(mockOfflineCompiler.hwInfo.platform.usDeviceID, dg2G10Id);
40+
}
41+
42+
DG2TEST_F(MockOfflineCompilerDg2Tests, GivenDg2G11ConfigWhenInitHardwareInfoThenCorrectValuesAreSet) {
43+
MockOfflineCompiler mockOfflineCompiler;
44+
PRODUCT_CONFIG dg2Config = DG2_G11;
45+
auto dg2G11Id = DG2_G11_IDS.front();
46+
mockOfflineCompiler.deviceName = mockOfflineCompiler.argHelper->parseProductConfigFromValue(dg2Config);
47+
48+
mockOfflineCompiler.initHardwareInfo(mockOfflineCompiler.deviceName);
49+
50+
EXPECT_EQ(mockOfflineCompiler.hwInfo.platform.eProductFamily, IGFX_DG2);
51+
EXPECT_EQ(mockOfflineCompiler.hwInfo.platform.usRevId, 0x0);
52+
EXPECT_EQ(mockOfflineCompiler.hwInfo.platform.usDeviceID, dg2G11Id);
53+
}
54+
55+
} // namespace NEO

shared/offline_compiler/source/ocloc_arg_helper.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,13 @@ OclocArgHelper::OclocArgHelper(const uint32_t numSources, const uint8_t **dataSo
5757
#undef NAMEDDEVICE
5858
{0u, std::string("")}}),
5959
deviceMap({
60-
#define DEVICE_CONFIG_REVISION(product, productConfig, revision_id) {product, &NEO::productConfig::hwInfo, NEO::productConfig::setupHardwareInfo, revision_id},
61-
#define DEVICE_CONFIG(product, productConfig) {product, &NEO::productConfig::hwInfo, NEO::productConfig::setupHardwareInfo, NEO::productConfig::hwInfo.platform.usRevId},
60+
#define DEVICE_CONFIG_IDS_AND_REVISION(product, productConfig, deviceIds, revision_id) {product, &NEO::productConfig::hwInfo, &NEO::deviceIds, NEO::productConfig::setupHardwareInfo, revision_id},
61+
#define DEVICE_CONFIG_IDS(product, productConfig, deviceIds) {product, &NEO::productConfig::hwInfo, &NEO::deviceIds, NEO::productConfig::setupHardwareInfo, NEO::productConfig::hwInfo.platform.usRevId},
62+
#define DEVICE_CONFIG(product, productConfig) {product, &NEO::productConfig::hwInfo, nullptr, NEO::productConfig::setupHardwareInfo, NEO::productConfig::hwInfo.platform.usRevId},
6263
#include "product_config.inl"
6364
#undef DEVICE_CONFIG
64-
#undef DEVICE_CONFIG_REVISION
65+
#undef DEVICE_CONFIG_IDS
66+
#undef DEVICE_CONFIG_IDS_AND_REVISION
6567
}) {
6668
for (uint32_t i = 0; i < numSources; ++i) {
6769
inputs.push_back(Source(dataSources[i], static_cast<size_t>(lenSources[i]), nameSources[i]));
@@ -165,12 +167,16 @@ void OclocArgHelper::setDeviceInfoForFatbinaryTarget(const DeviceMapping &device
165167
deviceForFatbinary.hwInfo = device.hwInfo;
166168
deviceForFatbinary.setupHardwareInfo = device.setupHardwareInfo;
167169
deviceForFatbinary.revId = device.revId;
170+
deviceForFatbinary.deviceIds = device.deviceIds;
168171
}
169172

170173
void OclocArgHelper::setHwInfoForFatbinaryTarget(NEO::HardwareInfo &hwInfo) {
171174
hwInfo = *deviceForFatbinary.hwInfo;
172175
deviceForFatbinary.setupHardwareInfo(&hwInfo, true);
173176
hwInfo.platform.usRevId = deviceForFatbinary.revId;
177+
if (deviceForFatbinary.deviceIds) {
178+
hwInfo.platform.usDeviceID = deviceForFatbinary.deviceIds->front();
179+
}
174180
}
175181

176182
bool OclocArgHelper::getHwInfoForProductConfig(uint32_t config, NEO::HardwareInfo &hwInfo) {
@@ -183,6 +189,9 @@ bool OclocArgHelper::getHwInfoForProductConfig(uint32_t config, NEO::HardwareInf
183189
hwInfo = *deviceConfig.hwInfo;
184190
deviceConfig.setupHardwareInfo(&hwInfo, true);
185191
hwInfo.platform.usRevId = deviceConfig.revId;
192+
if (deviceConfig.deviceIds) {
193+
hwInfo.platform.usDeviceID = deviceConfig.deviceIds->front();
194+
}
186195
retVal = true;
187196
return retVal;
188197
}
@@ -227,7 +236,7 @@ std::string OclocArgHelper::returnProductNameForDevice(unsigned short deviceId)
227236
return res;
228237
}
229238

230-
std::vector<DeviceMapping> OclocArgHelper::getAllSupportedDeviceConfigs() {
239+
std::vector<DeviceMapping> &OclocArgHelper::getAllSupportedDeviceConfigs() {
231240
return deviceMap;
232241
}
233242

shared/offline_compiler/source/ocloc_arg_helper.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "shared/offline_compiler/source/decoder/helper.h"
99
#include "shared/source/helpers/hw_info.h"
1010

11+
#include "device_ids_configs.h"
1112
#include "hw_cmds.h"
1213
#include "platforms.h"
1314

@@ -49,6 +50,7 @@ struct DeviceProduct {
4950
struct DeviceMapping {
5051
PRODUCT_CONFIG config;
5152
const NEO::HardwareInfo *hwInfo;
53+
const std::vector<unsigned short> *deviceIds;
5254
void (*setupHardwareInfo)(NEO::HardwareInfo *hwInfo, bool setupFeatureTableAndWorkaroundTable);
5355
unsigned int revId;
5456

@@ -109,7 +111,7 @@ class OclocArgHelper {
109111
void setDeviceInfoForFatbinaryTarget(const DeviceMapping &device);
110112
void setHwInfoForFatbinaryTarget(NEO::HardwareInfo &hwInfo);
111113
std::vector<PRODUCT_CONFIG> getAllSupportedProductConfigs();
112-
std::vector<DeviceMapping> getAllSupportedDeviceConfigs();
114+
std::vector<DeviceMapping> &getAllSupportedDeviceConfigs();
113115
std::vector<uint32_t> getMajorMinorRevision(const std::string &device);
114116
uint32_t getProductConfig(std::vector<uint32_t> &numeration);
115117
uint32_t getMaskForConfig(std::vector<uint32_t> &numeration);
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2021 Intel Corporation
2+
* Copyright (C) 2021-2022 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -9,16 +9,16 @@
99

1010
#ifdef SUPPORT_XE_HPG_CORE
1111
#ifdef SUPPORT_DG2
12-
DEVICE_CONFIG_REVISION(DG2_G10_A0, DG2_CONFIG, 0x00)
13-
DEVICE_CONFIG_REVISION(DG2_G10_B0, DG2_CONFIG, 0x04)
12+
DEVICE_CONFIG_IDS_AND_REVISION(DG2_G10_A0, DG2_CONFIG, DG2_G10_IDS, 0x00)
13+
DEVICE_CONFIG_IDS_AND_REVISION(DG2_G10_B0, DG2_CONFIG, DG2_G10_IDS, 0x04)
1414
#endif
1515
#endif
1616

1717
#if SUPPORT_XE_HPC_CORE
1818
#ifdef SUPPORT_PVC
19-
DEVICE_CONFIG_REVISION(PVC_XT_A0, PVC_CONFIG, 0x03)
20-
DEVICE_CONFIG_REVISION(PVC_XT_B0, PVC_CONFIG, 0x1E)
21-
DEVICE_CONFIG_REVISION(PVC_XL_A0, PVC_CONFIG, 0x00)
22-
DEVICE_CONFIG_REVISION(PVC_XL_B0, PVC_CONFIG, 0x01)
19+
DEVICE_CONFIG_IDS_AND_REVISION(PVC_XT_A0, PVC_CONFIG, PVC_XT_IDS, 0x03)
20+
DEVICE_CONFIG_IDS_AND_REVISION(PVC_XT_B0, PVC_CONFIG, PVC_XT_IDS, 0x1E)
21+
DEVICE_CONFIG_IDS_AND_REVISION(PVC_XL_A0, PVC_CONFIG, PVC_XL_IDS, 0x00)
22+
DEVICE_CONFIG_IDS_AND_REVISION(PVC_XL_B0, PVC_CONFIG, PVC_XL_IDS, 0x01)
2323
#endif
2424
#endif

shared/source/helpers/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ set(NEO_CORE_HELPERS
129129
${CMAKE_CURRENT_SOURCE_DIR}/validators.h
130130
${CMAKE_CURRENT_SOURCE_DIR}/vec.h
131131
${CMAKE_CURRENT_SOURCE_DIR}/definitions${BRANCH_DIR_SUFFIX}hw_cmds.h
132+
${CMAKE_CURRENT_SOURCE_DIR}/definitions${BRANCH_DIR_SUFFIX}device_ids_configs.h
132133
${CMAKE_CURRENT_SOURCE_DIR}/definitions/engine_group_types.h
133134
${CMAKE_CURRENT_SOURCE_DIR}/definitions/mi_flush_args.h
134135
)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright (C) 2022 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#pragma once
9+
10+
#ifdef SUPPORT_XE_HPG_CORE
11+
#ifdef SUPPORT_DG2
12+
#include "shared/source/xe_hpg_core/definitions/device_ids_configs_dg2.h"
13+
#endif
14+
#endif
15+
16+
#if SUPPORT_XE_HPC_CORE
17+
#ifdef SUPPORT_PVC
18+
#include "shared/source/xe_hpc_core/definitions/device_ids_configs_pvc.h"
19+
#endif
20+
#endif
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
* Copyright (C) 2022 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#pragma once
9+
10+
#include <vector>
11+
12+
namespace NEO {
13+
static const std::vector<unsigned short> PVC_XT_IDS{0x0BD5};
14+
static const std::vector<unsigned short> PVC_XL_IDS{0x0BD0};
15+
} // namespace NEO
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
* Copyright (C) 2022 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#pragma once
9+
10+
#include <vector>
11+
12+
namespace NEO {
13+
static const std::vector<unsigned short> DG2_G10_IDS{0x4F80, 0x4F81, 0x4F82, 0x4F83, 0x4F84, 0x5690, 0x5691, 0x5692, 0x56A0, 0x56A1, 0x56A2, 0x56C0};
14+
static const std::vector<unsigned short> DG2_G11_IDS{0x4F87, 0x4F88, 0x5693, 0x5694, 0x5695, 0x56A5, 0x56A6, 0x56B0, 0x56B1, 0x56C1};
15+
} // namespace NEO

0 commit comments

Comments
 (0)