Skip to content

Commit b450d3c

Browse files
Baj, TomaszCompute-Runtime-Automation
authored andcommitted
Add cl_khr_device_uuid to extension list
Related-To: NEO-5681 Signed-off-by: Baj, Tomasz <tomasz.baj@intel.com>
1 parent d5b2f03 commit b450d3c

File tree

23 files changed

+362
-51
lines changed

23 files changed

+362
-51
lines changed

opencl/source/cl_device/cl_device_info.cpp

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ cl_int ClDevice::getDeviceInfo(cl_device_info paramName,
6868
size_t value = 0u;
6969
ClDeviceInfoParam param{};
7070
const void *src = nullptr;
71-
std::array<uint8_t, HwInfoConfig::uuidSize> deviceUuid;
71+
std::array<uint8_t, CL_UUID_SIZE_KHR> uuid;
72+
std::array<uint8_t, CL_LUID_SIZE_KHR> luid;
7273

7374
// clang-format off
7475
// please keep alphabetical order
@@ -294,12 +295,36 @@ cl_int ClDevice::getDeviceInfo(cl_device_info paramName,
294295
retSize = srcSize = sizeof(deviceInfo.pciBusInfo);
295296
}
296297
break;
297-
case CL_DEVICE_UUID_KHR: {
298-
device.generateUuid(deviceUuid);
299-
src = &deviceUuid;
300-
retSize = srcSize = sizeof(deviceUuid);
298+
case CL_DEVICE_UUID_KHR:
299+
device.generateUuid(uuid);
300+
src = uuid.data();
301+
retSize = srcSize = CL_UUID_SIZE_KHR;
302+
break;
303+
case CL_DRIVER_UUID_KHR:
304+
const void *tmpUuid;
305+
getStr<CL_DRIVER_UUID_KHR>(tmpUuid, srcSize, retSize);
306+
uuid.fill(0);
307+
memcpy_s(uuid.data(), srcSize, tmpUuid, srcSize);
308+
src = uuid.data();
309+
retSize = srcSize = CL_UUID_SIZE_KHR;
310+
break;
311+
case CL_DEVICE_LUID_VALID_KHR:
312+
param.boolean = device.verifyAdapterLuid();
313+
src = &param.boolean;
314+
retSize = srcSize = sizeof(cl_bool);
315+
break;
316+
case CL_DEVICE_LUID_KHR:
317+
memcpy_s(luid.data(), CL_LUID_SIZE_KHR, paramValue, CL_LUID_SIZE_KHR);
318+
device.getAdapterLuid(luid);
319+
src = luid.data();
320+
retSize = srcSize = CL_LUID_SIZE_KHR;
321+
break;
322+
case CL_DEVICE_NODE_MASK_KHR:
323+
memcpy_s(&param.uint, sizeof(cl_uint), paramValue, paramValueSize);
324+
device.getAdapterMask(param.uint);
325+
src = &param.uint;
326+
retSize = srcSize = sizeof(cl_uint);
301327
break;
302-
}
303328
default:
304329
if (getDeviceInfoForImage(paramName, src, srcSize, retSize) && !getSharedDeviceInfo().imageSupport) {
305330
src = &value;

opencl/source/cl_device/cl_device_info_map.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ template<> struct Map<CL_DEVICE_TYPE > :
171171
template<> struct Map<CL_DEVICE_VENDOR > : public ClMapBase<CL_DEVICE_VENDOR, const char *, &ClDeviceInfo::vendor> {};
172172
template<> struct Map<CL_DEVICE_VERSION > : public ClMapBase<CL_DEVICE_VERSION, const char *, &ClDeviceInfo::clVersion> {};
173173
template<> struct Map<CL_DRIVER_VERSION > : public ClMapBase<CL_DRIVER_VERSION, const char *, &ClDeviceInfo::driverVersion> {};
174+
template<> struct Map<CL_DRIVER_UUID_KHR > : public ClMapBase<CL_DRIVER_UUID_KHR, const char *, &ClDeviceInfo::driverVersion> {};
174175
template<> struct Map<CL_DEVICE_WORK_GROUP_COLLECTIVE_FUNCTIONS_SUPPORT > : public ClMapBase<CL_DEVICE_WORK_GROUP_COLLECTIVE_FUNCTIONS_SUPPORT, uint32_t, &ClDeviceInfo::workGroupCollectiveFunctionsSupport> {};
175176
// clang-format on
176177

opencl/test/unit_test/api/cl_get_device_info_tests.inl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ TEST_F(clGetDeviceInfoTests, GivenClDeviceExtensionsParamWhenGettingDeviceInfoTh
255255
std::string extensionString(paramValue.get());
256256
static const char *const supportedExtensions[] = {
257257
"cl_khr_byte_addressable_store ",
258+
"cl_khr_device_uuid ",
258259
"cl_khr_fp16 ",
259260
"cl_khr_global_int32_base_atomics ",
260261
"cl_khr_global_int32_extended_atomics ",

opencl/test/unit_test/device/CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (C) 2018-2021 Intel Corporation
2+
# Copyright (C) 2018-2022 Intel Corporation
33
#
44
# SPDX-License-Identifier: MIT
55
#
@@ -17,7 +17,11 @@ set(IGDRCL_SRCS_tests_device
1717

1818
if(WIN32)
1919
list(APPEND IGDRCL_SRCS_tests_device
20-
${CMAKE_CURRENT_SOURCE_DIR}/device_win_timers_tests.cpp
20+
${CMAKE_CURRENT_SOURCE_DIR}/windows/device_windows_tests.cpp
21+
)
22+
else()
23+
list(APPEND IGDRCL_SRCS_tests_device
24+
${CMAKE_CURRENT_SOURCE_DIR}/linux/device_linux_tests.cpp
2125
)
2226
endif()
2327
target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_device})

opencl/test/unit_test/device/device_win_timers_tests.cpp

Lines changed: 0 additions & 42 deletions
This file was deleted.

opencl/test/unit_test/device/get_device_info_tests.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -970,6 +970,7 @@ cl_device_info deviceInfoParams[] = {
970970
CL_DEVICE_VENDOR_ID,
971971
CL_DEVICE_VERSION,
972972
CL_DRIVER_VERSION,
973+
CL_DRIVER_UUID_KHR,
973974
};
974975

975976
INSTANTIATE_TEST_CASE_P(
@@ -1043,7 +1044,7 @@ TEST(GetDeviceInfoTest, givenPciBusInfoIsNotAvailableWhenGettingPciBusInfoForDev
10431044
}
10441045

10451046
TEST(GetDeviceInfo, givenDeviceUuidWhenGettingDeviceInfoThenGenerateDeviceUuid) {
1046-
std::array<uint8_t, HwInfoConfig::uuidSize> generateDeviceUuid, deviceUuidKHR;
1047+
std::array<uint8_t, CL_UUID_SIZE_KHR> generateDeviceUuid, deviceUuidKHR;
10471048
size_t retSize = 0;
10481049

10491050
auto device = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright (C) 2022 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#include "opencl/test/unit_test/fixtures/cl_device_fixture.h"
9+
10+
using namespace NEO;
11+
12+
namespace ULT {
13+
14+
TEST(GetDeviceInfo, givenClDeviceWhenGettingDeviceInfoThenBadAdapterLuidIsReturned) {
15+
std::array<uint8_t, CL_LUID_SIZE_KHR> deviceLuidKHR, expectLuid = {0, 1, 2, 3, 4, 5, 6, 7};
16+
deviceLuidKHR = expectLuid;
17+
auto clDevice = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
18+
auto retVal = clDevice->getDeviceInfo(CL_DEVICE_LUID_KHR, CL_LUID_SIZE_KHR, deviceLuidKHR.data(), 0);
19+
20+
ASSERT_EQ(retVal, CL_SUCCESS);
21+
EXPECT_EQ(deviceLuidKHR, expectLuid);
22+
}
23+
24+
TEST(GetDeviceInfo, givenClDeviceWhenGettingDeviceInfoThenLuidIsInvalid) {
25+
cl_bool isValid = true;
26+
auto clDevice = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
27+
auto retVal = clDevice->getDeviceInfo(CL_DEVICE_LUID_VALID_KHR, sizeof(cl_bool), &isValid, 0);
28+
29+
ASSERT_EQ(retVal, CL_SUCCESS);
30+
EXPECT_FALSE(isValid);
31+
}
32+
33+
TEST(GetDeviceInfo, givenClDeviceWhenGettingDeviceInfoThenNodeMaskIsUnchanged) {
34+
cl_uint nodeMask = 0x1234u;
35+
auto clDevice = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
36+
auto retVal = clDevice->getDeviceInfo(CL_DEVICE_NODE_MASK_KHR, sizeof(cl_uint), &nodeMask, 0);
37+
38+
ASSERT_EQ(retVal, CL_SUCCESS);
39+
EXPECT_EQ(nodeMask, 0x1234u);
40+
}
41+
} // namespace ULT
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/*
2+
* Copyright (C) 2018-2022 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#include "shared/source/execution_environment/root_device_environment.h"
9+
#include "shared/test/common/mocks/mock_execution_environment.h"
10+
#include "shared/test/common/mocks/mock_ostime.h"
11+
#include "shared/test/common/mocks/mock_ostime_win.h"
12+
#include "shared/test/common/mocks/mock_wddm.h"
13+
#include "shared/test/common/test_macros/test.h"
14+
15+
#include "opencl/test/unit_test/fixtures/cl_device_fixture.h"
16+
17+
using namespace NEO;
18+
19+
namespace ULT {
20+
21+
typedef ::testing::Test MockOSTimeWinTest;
22+
23+
TEST_F(MockOSTimeWinTest, whenCreatingTimerThenResolutionIsSetCorrectly) {
24+
MockExecutionEnvironment executionEnvironment;
25+
RootDeviceEnvironment rootDeviceEnvironment(executionEnvironment);
26+
auto wddmMock = new WddmMock(rootDeviceEnvironment);
27+
auto device = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
28+
29+
wddmMock->init();
30+
31+
wddmMock->timestampFrequency = 1000;
32+
33+
std::unique_ptr<MockOSTimeWin> timeWin(new MockOSTimeWin(wddmMock));
34+
35+
double res = 0.0;
36+
res = timeWin->getDynamicDeviceTimerResolution(device->getHardwareInfo());
37+
EXPECT_EQ(res, 1e+06);
38+
}
39+
40+
TEST(GetDeviceInfo, givenClDeviceWhenGettingDeviceInfoThenCorrectAdapterLuidIsReturned) {
41+
auto clDevice = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
42+
clDevice->executionEnvironment->rootDeviceEnvironments[0]->osInterface.reset(new NEO::OSInterface);
43+
auto mockWddm = new WddmMock(*clDevice->executionEnvironment->rootDeviceEnvironments[0]);
44+
clDevice->executionEnvironment->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mockWddm));
45+
46+
std::array<uint8_t, CL_LUID_SIZE_KHR> deviceLuidKHR;
47+
auto luid = clDevice->executionEnvironment->rootDeviceEnvironments[0]->osInterface->getDriverModel()->as<Wddm>()->getAdapterLuid();
48+
auto retVal = clDevice->getDeviceInfo(CL_DEVICE_LUID_KHR, CL_LUID_SIZE_KHR, deviceLuidKHR.data(), 0);
49+
50+
ASSERT_EQ(retVal, CL_SUCCESS);
51+
EXPECT_EQ(std::memcmp(deviceLuidKHR.data(), &luid, CL_LUID_SIZE_KHR), 0);
52+
}
53+
54+
TEST(GetDeviceInfo, givenClDeviceWhenVerifyAdapterLuidThenGetTrue) {
55+
auto clDevice = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
56+
clDevice->executionEnvironment->rootDeviceEnvironments[0]->osInterface.reset(new NEO::OSInterface);
57+
auto mockWddm = new WddmMock(*clDevice->executionEnvironment->rootDeviceEnvironments[0]);
58+
clDevice->executionEnvironment->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mockWddm));
59+
60+
cl_bool isValid = false;
61+
auto retVal = clDevice->getDeviceInfo(CL_DEVICE_LUID_VALID_KHR, sizeof(cl_bool), &isValid, 0);
62+
63+
ASSERT_EQ(retVal, CL_SUCCESS);
64+
EXPECT_TRUE(isValid);
65+
}
66+
67+
TEST(GetDeviceInfo, givenClDeviceWhenGettingDeviceInfoThenGetNodeMask) {
68+
auto clDevice = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
69+
clDevice->executionEnvironment->rootDeviceEnvironments[0]->osInterface.reset(new NEO::OSInterface);
70+
auto mockWddm = new WddmMock(*clDevice->executionEnvironment->rootDeviceEnvironments[0]);
71+
clDevice->executionEnvironment->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mockWddm));
72+
73+
cl_uint nodeMask = 0b0;
74+
auto retVal = clDevice->getDeviceInfo(CL_DEVICE_NODE_MASK_KHR, sizeof(cl_uint), &nodeMask, 0);
75+
76+
ASSERT_EQ(retVal, CL_SUCCESS);
77+
EXPECT_EQ(nodeMask, 0b1);
78+
}
79+
} // namespace ULT

shared/source/compiler_interface/oclc_extensions.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
namespace NEO {
1818
const char *deviceExtensionsList = "cl_khr_byte_addressable_store "
19+
"cl_khr_device_uuid "
1920
"cl_khr_fp16 "
2021
"cl_khr_global_int32_base_atomics "
2122
"cl_khr_global_int32_extended_atomics "

shared/source/device/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@ set(NEO_CORE_DEVICE
1616
${CMAKE_CURRENT_SOURCE_DIR}/sub_device.h
1717
${CMAKE_CURRENT_SOURCE_DIR}/device_get_device_name.cpp
1818
)
19+
if(WIN32)
20+
list(APPEND NEO_CORE_DEVICE
21+
${CMAKE_CURRENT_SOURCE_DIR}/windows/device_windows.cpp
22+
)
23+
else()
24+
list(APPEND NEO_CORE_DEVICE
25+
${CMAKE_CURRENT_SOURCE_DIR}/linux/device_linux.cpp
26+
)
27+
endif()
1928

2029
set_property(GLOBAL PROPERTY NEO_CORE_DEVICE ${NEO_CORE_DEVICE})
2130
add_subdirectories()

0 commit comments

Comments
 (0)