Skip to content

Commit da6a0b7

Browse files
authored
[OpenCL] Add cl_khr_kernel_clock builtins (#91950)
1 parent 6582efc commit da6a0b7

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

clang/lib/Headers/opencl-c-base.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@
4646
#define __opencl_c_ext_fp32_global_atomic_min_max 1
4747
#define __opencl_c_ext_fp32_local_atomic_min_max 1
4848
#define __opencl_c_ext_image_raw10_raw12 1
49+
#define cl_khr_kernel_clock 1
50+
#define __opencl_c_kernel_clock_scope_device 1
51+
#define __opencl_c_kernel_clock_scope_work_group 1
52+
#define __opencl_c_kernel_clock_scope_sub_group 1
4953

5054
#endif // defined(__SPIR__) || defined(__SPIRV__)
5155
#endif // (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)

clang/lib/Headers/opencl-c.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17314,6 +17314,21 @@ half __ovld __conv sub_group_clustered_rotate(half, int, uint);
1731417314
#endif // cl_khr_fp16
1731517315
#endif // cl_khr_subgroup_rotate
1731617316

17317+
#if defined(cl_khr_kernel_clock)
17318+
#if defined(__opencl_c_kernel_clock_scope_device)
17319+
ulong __ovld clock_read_device();
17320+
uint2 __ovld clock_read_hilo_device();
17321+
#endif // __opencl_c_kernel_clock_scope_device
17322+
#if defined(__opencl_c_kernel_clock_scope_work_group)
17323+
ulong __ovld clock_read_work_group();
17324+
uint2 __ovld clock_read_hilo_work_group();
17325+
#endif // __opencl_c_kernel_clock_scope_work_group
17326+
#if defined(__opencl_c_kernel_clock_scope_sub_group)
17327+
ulong __ovld clock_read_sub_group();
17328+
uint2 __ovld clock_read_hilo_sub_group();
17329+
#endif // __opencl_c_kernel_clock_scope_sub_group
17330+
#endif // cl_khr_kernel_clock
17331+
1731717332
#if defined(cl_intel_subgroups)
1731817333
// Intel-Specific Sub Group Functions
1731917334
float __ovld __conv intel_sub_group_shuffle( float , uint );

clang/lib/Sema/OpenCLBuiltins.td

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1852,6 +1852,20 @@ let Extension = FunctionExtension<"cl_khr_subgroup_rotate"> in {
18521852
def : Builtin<"sub_group_clustered_rotate", [AGenType1, AGenType1, Int, UInt], Attr.Convergent>;
18531853
}
18541854

1855+
// cl_khr_kernel_clock
1856+
let Extension = FunctionExtension<"cl_khr_kernel_clock __opencl_c_kernel_clock_scope_device"> in {
1857+
def : Builtin<"clock_read_device", [ULong]>;
1858+
def : Builtin<"clock_read_hilo_device", [VectorType<UInt, 2>]>;
1859+
}
1860+
let Extension = FunctionExtension<"cl_khr_kernel_clock __opencl_c_kernel_clock_scope_work_group"> in {
1861+
def : Builtin<"clock_read_work_group", [ULong]>;
1862+
def : Builtin<"clock_read_hilo_work_group", [VectorType<UInt, 2>]>;
1863+
}
1864+
let Extension = FunctionExtension<"cl_khr_kernel_clock __opencl_c_kernel_clock_scope_sub_group"> in {
1865+
def : Builtin<"clock_read_sub_group", [ULong]>;
1866+
def : Builtin<"clock_read_hilo_sub_group", [VectorType<UInt, 2>]>;
1867+
}
1868+
18551869
//--------------------------------------------------------------------
18561870
// Arm extensions.
18571871
let Extension = ArmIntegerDotProductInt8 in {

0 commit comments

Comments
 (0)