Skip to content

[OpenCL] Add cl_khr_kernel_clock builtins #91950

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions clang/lib/Headers/opencl-c-base.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@
#define __opencl_c_ext_fp32_global_atomic_min_max 1
#define __opencl_c_ext_fp32_local_atomic_min_max 1
#define __opencl_c_ext_image_raw10_raw12 1
#define cl_khr_kernel_clock 1
#define __opencl_c_kernel_clock_scope_device 1
#define __opencl_c_kernel_clock_scope_work_group 1
#define __opencl_c_kernel_clock_scope_sub_group 1

#endif // defined(__SPIR__) || defined(__SPIRV__)
#endif // (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
Expand Down
15 changes: 15 additions & 0 deletions clang/lib/Headers/opencl-c.h
Original file line number Diff line number Diff line change
Expand Up @@ -17314,6 +17314,21 @@ half __ovld __conv sub_group_clustered_rotate(half, int, uint);
#endif // cl_khr_fp16
#endif // cl_khr_subgroup_rotate

#if defined(cl_khr_kernel_clock)
#if defined(__opencl_c_kernel_clock_scope_device)
ulong __ovld clock_read_device();
uint2 __ovld clock_read_hilo_device();
#endif // __opencl_c_kernel_clock_scope_device
#if defined(__opencl_c_kernel_clock_scope_work_group)
ulong __ovld clock_read_work_group();
uint2 __ovld clock_read_hilo_work_group();
#endif // __opencl_c_kernel_clock_scope_work_group
#if defined(__opencl_c_kernel_clock_scope_sub_group)
ulong __ovld clock_read_sub_group();
uint2 __ovld clock_read_hilo_sub_group();
#endif // __opencl_c_kernel_clock_scope_sub_group
#endif // cl_khr_kernel_clock

#if defined(cl_intel_subgroups)
// Intel-Specific Sub Group Functions
float __ovld __conv intel_sub_group_shuffle( float , uint );
Expand Down
14 changes: 14 additions & 0 deletions clang/lib/Sema/OpenCLBuiltins.td
Original file line number Diff line number Diff line change
Expand Up @@ -1852,6 +1852,20 @@ let Extension = FunctionExtension<"cl_khr_subgroup_rotate"> in {
def : Builtin<"sub_group_clustered_rotate", [AGenType1, AGenType1, Int, UInt], Attr.Convergent>;
}

// cl_khr_kernel_clock
let Extension = FunctionExtension<"cl_khr_kernel_clock __opencl_c_kernel_clock_scope_device"> in {
def : Builtin<"clock_read_device", [ULong]>;
def : Builtin<"clock_read_hilo_device", [VectorType<UInt, 2>]>;
}
let Extension = FunctionExtension<"cl_khr_kernel_clock __opencl_c_kernel_clock_scope_work_group"> in {
def : Builtin<"clock_read_work_group", [ULong]>;
def : Builtin<"clock_read_hilo_work_group", [VectorType<UInt, 2>]>;
}
let Extension = FunctionExtension<"cl_khr_kernel_clock __opencl_c_kernel_clock_scope_sub_group"> in {
def : Builtin<"clock_read_sub_group", [ULong]>;
def : Builtin<"clock_read_hilo_sub_group", [VectorType<UInt, 2>]>;
}

//--------------------------------------------------------------------
// Arm extensions.
let Extension = ArmIntegerDotProductInt8 in {
Expand Down