Skip to content

Commit 3274ca1

Browse files
authored
[SYCL][UR] Support sycl_ext_oneapi_clock (#20070)
Spec: https://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/proposed/sycl_ext_oneapi_clock.asciidoc The test for this exists, but isn't being tested due to issues down the stack, see #20100.
1 parent ec607fb commit 3274ca1

File tree

8 files changed

+196
-6
lines changed

8 files changed

+196
-6
lines changed

sycl/source/detail/device_impl.hpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1580,16 +1580,17 @@ class device_impl : public std::enable_shared_from_this<device_impl> {
15801580
.value_or(0);
15811581
}
15821582
CASE(ext_oneapi_clock_sub_group) {
1583-
// Will be updated in a follow-up UR patch.
1584-
return false;
1583+
return get_info_impl_nocheck<UR_DEVICE_INFO_CLOCK_SUB_GROUP_SUPPORT_EXP>()
1584+
.value_or(0);
15851585
}
15861586
CASE(ext_oneapi_clock_work_group) {
1587-
// Will be updated in a follow-up UR patch.
1588-
return false;
1587+
return get_info_impl_nocheck<
1588+
UR_DEVICE_INFO_CLOCK_WORK_GROUP_SUPPORT_EXP>()
1589+
.value_or(0);
15891590
}
15901591
CASE(ext_oneapi_clock_device) {
1591-
// Will be updated in a follow-up UR patch.
1592-
return false;
1592+
return get_info_impl_nocheck<UR_DEVICE_INFO_CLOCK_DEVICE_SUPPORT_EXP>()
1593+
.value_or(0);
15931594
}
15941595
else {
15951596
return false; // This device aspect has not been implemented yet.

sycl/source/detail/ur_device_info_ret_types.inc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,4 +193,7 @@ MAP(UR_DEVICE_INFO_MIPMAP_SUPPORT_EXP, ur_bool_t)
193193
MAP(UR_DEVICE_INFO_TIMESTAMP_RECORDING_SUPPORT_EXP, ur_bool_t)
194194
MAP(UR_DEVICE_INFO_KERNEL_LAUNCH_CAPABILITIES, ur_kernel_launch_properties_flags_t)
195195
MAP(UR_DEVICE_INFO_MEMORY_EXPORT_EXPORTABLE_DEVICE_MEM_EXP, ur_bool_t)
196+
MAP(UR_DEVICE_INFO_CLOCK_SUB_GROUP_SUPPORT_EXP, ur_bool_t)
197+
MAP(UR_DEVICE_INFO_CLOCK_WORK_GROUP_SUPPORT_EXP, ur_bool_t)
198+
MAP(UR_DEVICE_INFO_CLOCK_DEVICE_SUPPORT_EXP, ur_bool_t)
196199
// clang-format on

unified-runtime/include/ur_api.h

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

unified-runtime/include/ur_print.hpp

Lines changed: 48 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<%
2+
OneApi=tags['$OneApi']
3+
x=tags['$x']
4+
X=x.upper()
5+
%>
6+
7+
.. _experimental-clock:
8+
9+
================================================================================
10+
Clock
11+
================================================================================
12+
13+
.. warning::
14+
15+
Experimental features:
16+
17+
* May be replaced, updated, or removed at any time.
18+
* Do not require maintaining API/ABI stability of their own additions over
19+
time.
20+
* Do not require conformance testing of their own additions.
21+
22+
23+
Motivation
24+
--------------------------------------------------------------------------------
25+
This experimental extension enables the sycl_ext_oneapi_clock feature:
26+
https://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/proposed/sycl_ext_oneapi_clock.asciidoc
27+
It introduces descriptors to query sub-group/work-group/device clock support.
28+
29+
API
30+
--------------------------------------------------------------------------------
31+
32+
Enums
33+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
34+
* ${x}_device_info_t
35+
* ${X}_DEVICE_INFO_CLOCK_SUB_GROUP_SUPPORT_EXP
36+
* ${X}_DEVICE_INFO_CLOCK_WORK_GROUP_SUPPORT_EXP
37+
* ${X}_DEVICE_INFO_CLOCK_DEVICE_SUPPORT_EXP
38+
39+
Changelog
40+
--------------------------------------------------------------------------------
41+
42+
+-----------+------------------------+
43+
| Revision | Changes |
44+
+===========+========================+
45+
| 1.0 | Initial Draft |
46+
+-----------+------------------------+
47+
48+
49+
Support
50+
--------------------------------------------------------------------------------
51+
52+
Adapters which support this experimental feature *must* return ${X}_RESULT_SUCCESS from
53+
the ${x}DeviceGetInfo call with new ${X}_DEVICE_INFO_CLOCK_SUB_GROUP_SUPPORT_EXP,
54+
${X}_DEVICE_INFO_CLOCK_WORK_GROUP_SUPPORT_EXP or ${X}_DEVICE_INFO_CLOCK_DEVICE_SUPPORT_EXP
55+
device descriptors.
56+
57+
Contributors
58+
--------------------------------------------------------------------------------
59+
60+
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#
2+
# Copyright (C) 2025 Intel Corporation
3+
#
4+
# Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM
5+
# Exceptions.
6+
# See LICENSE.TXT
7+
#
8+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
9+
#
10+
# See YaML.md for syntax definition
11+
#
12+
--- #--------------------------------------------------------------------------
13+
type: header
14+
desc: "Intel $OneApi Unified Runtime Experimental APIs for Clock"
15+
ordinal: "99"
16+
--- #--------------------------------------------------------------------------
17+
type: enum
18+
extend: true
19+
typed_etors: true
20+
desc: "Extension enums for $x_device_info_t to support multi device compile."
21+
name: $x_device_info_t
22+
etors:
23+
- name: CLOCK_SUB_GROUP_SUPPORT_EXP
24+
value: "0x2060"
25+
desc: "[$x_bool_t] returns true if the device supports sampling values from the sub-group clock."
26+
- name: CLOCK_WORK_GROUP_SUPPORT_EXP
27+
value: "0x2061"
28+
desc: "[$x_bool_t] returns true if the device supports sampling values from the work-group clock."
29+
- name: CLOCK_DEVICE_SUPPORT_EXP
30+
value: "0x2062"
31+
desc: "[$x_bool_t] returns true if the device supports sampling values from the device clock."

unified-runtime/source/adapters/opencl/device.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1480,6 +1480,36 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
14801480

14811481
return ReturnValue(nodeMask);
14821482
}
1483+
case UR_DEVICE_INFO_CLOCK_SUB_GROUP_SUPPORT_EXP:
1484+
case UR_DEVICE_INFO_CLOCK_WORK_GROUP_SUPPORT_EXP:
1485+
case UR_DEVICE_INFO_CLOCK_DEVICE_SUPPORT_EXP: {
1486+
bool Supported = false;
1487+
size_t ExtSize = 0;
1488+
1489+
CL_RETURN_ON_FAILURE(clGetDeviceInfo(
1490+
hDevice->CLDevice, CL_DEVICE_EXTENSIONS, 0, nullptr, &ExtSize));
1491+
std::string ExtStr(ExtSize, '\0');
1492+
CL_RETURN_ON_FAILURE(clGetDeviceInfo(hDevice->CLDevice,
1493+
CL_DEVICE_EXTENSIONS, ExtSize,
1494+
ExtStr.data(), nullptr));
1495+
1496+
if (ExtStr.find("cl_khr_kernel_clock") != std::string::npos) {
1497+
cl_device_kernel_clock_capabilities_khr caps = 0;
1498+
1499+
CL_RETURN_ON_FAILURE(clGetDeviceInfo(
1500+
hDevice->CLDevice, CL_DEVICE_KERNEL_CLOCK_CAPABILITIES_KHR,
1501+
sizeof(cl_device_kernel_clock_capabilities_khr), &caps, nullptr));
1502+
1503+
if ((propName == UR_DEVICE_INFO_CLOCK_SUB_GROUP_SUPPORT_EXP &&
1504+
(caps & CL_DEVICE_KERNEL_CLOCK_SCOPE_SUB_GROUP_KHR)) ||
1505+
(propName == UR_DEVICE_INFO_CLOCK_WORK_GROUP_SUPPORT_EXP &&
1506+
(caps & CL_DEVICE_KERNEL_CLOCK_SCOPE_WORK_GROUP_KHR)) ||
1507+
(propName == UR_DEVICE_INFO_CLOCK_DEVICE_SUPPORT_EXP &&
1508+
(caps & CL_DEVICE_KERNEL_CLOCK_SCOPE_DEVICE_KHR)))
1509+
Supported = true;
1510+
}
1511+
return ReturnValue(Supported);
1512+
}
14831513
// TODO: We can't query to check if these are supported, they will need to be
14841514
// manually updated if support is ever implemented.
14851515
case UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS:

unified-runtime/tools/urinfo/urinfo.hpp

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)