|
| 1 | +From da6a0b7af29a222b2e16a10155b49d4fafe967f3 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Sven van Haastregt < [email protected]> |
| 3 | +Date: Mon, 20 May 2024 09:37:53 +0200 |
| 4 | +Subject: [PATCH] [OpenCL] Add cl_khr_kernel_clock builtins (#91950) |
| 5 | + |
| 6 | +--- |
| 7 | + clang/lib/Headers/opencl-c-base.h | 4 ++++ |
| 8 | + clang/lib/Headers/opencl-c.h | 15 +++++++++++++++ |
| 9 | + clang/lib/Sema/OpenCLBuiltins.td | 14 ++++++++++++++ |
| 10 | + 3 files changed, 33 insertions(+) |
| 11 | + |
| 12 | +diff --git a/clang/lib/Headers/opencl-c-base.h b/clang/lib/Headers/opencl-c-base.h |
| 13 | +index 2494f6213fc5..786678b9d8a7 100644 |
| 14 | +--- a/clang/lib/Headers/opencl-c-base.h |
| 15 | ++++ b/clang/lib/Headers/opencl-c-base.h |
| 16 | +@@ -46,6 +46,10 @@ |
| 17 | + #define __opencl_c_ext_fp32_global_atomic_min_max 1 |
| 18 | + #define __opencl_c_ext_fp32_local_atomic_min_max 1 |
| 19 | + #define __opencl_c_ext_image_raw10_raw12 1 |
| 20 | ++#define cl_khr_kernel_clock 1 |
| 21 | ++#define __opencl_c_kernel_clock_scope_device 1 |
| 22 | ++#define __opencl_c_kernel_clock_scope_work_group 1 |
| 23 | ++#define __opencl_c_kernel_clock_scope_sub_group 1 |
| 24 | + |
| 25 | + #endif // defined(__SPIR__) || defined(__SPIRV__) |
| 26 | + #endif // (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200) |
| 27 | +diff --git a/clang/lib/Headers/opencl-c.h b/clang/lib/Headers/opencl-c.h |
| 28 | +index 288bb18bc654..20719b74b6b8 100644 |
| 29 | +--- a/clang/lib/Headers/opencl-c.h |
| 30 | ++++ b/clang/lib/Headers/opencl-c.h |
| 31 | +@@ -17314,6 +17314,21 @@ half __ovld __conv sub_group_clustered_rotate(half, int, uint); |
| 32 | + #endif // cl_khr_fp16 |
| 33 | + #endif // cl_khr_subgroup_rotate |
| 34 | + |
| 35 | ++#if defined(cl_khr_kernel_clock) |
| 36 | ++#if defined(__opencl_c_kernel_clock_scope_device) |
| 37 | ++ulong __ovld clock_read_device(); |
| 38 | ++uint2 __ovld clock_read_hilo_device(); |
| 39 | ++#endif // __opencl_c_kernel_clock_scope_device |
| 40 | ++#if defined(__opencl_c_kernel_clock_scope_work_group) |
| 41 | ++ulong __ovld clock_read_work_group(); |
| 42 | ++uint2 __ovld clock_read_hilo_work_group(); |
| 43 | ++#endif // __opencl_c_kernel_clock_scope_work_group |
| 44 | ++#if defined(__opencl_c_kernel_clock_scope_sub_group) |
| 45 | ++ulong __ovld clock_read_sub_group(); |
| 46 | ++uint2 __ovld clock_read_hilo_sub_group(); |
| 47 | ++#endif // __opencl_c_kernel_clock_scope_sub_group |
| 48 | ++#endif // cl_khr_kernel_clock |
| 49 | ++ |
| 50 | + #if defined(cl_intel_subgroups) |
| 51 | + // Intel-Specific Sub Group Functions |
| 52 | + float __ovld __conv intel_sub_group_shuffle( float , uint ); |
| 53 | +diff --git a/clang/lib/Sema/OpenCLBuiltins.td b/clang/lib/Sema/OpenCLBuiltins.td |
| 54 | +index a7bdfe20b982..4da61429fcce 100644 |
| 55 | +--- a/clang/lib/Sema/OpenCLBuiltins.td |
| 56 | ++++ b/clang/lib/Sema/OpenCLBuiltins.td |
| 57 | +@@ -1852,6 +1852,20 @@ let Extension = FunctionExtension<"cl_khr_subgroup_rotate"> in { |
| 58 | + def : Builtin<"sub_group_clustered_rotate", [AGenType1, AGenType1, Int, UInt], Attr.Convergent>; |
| 59 | + } |
| 60 | + |
| 61 | ++// cl_khr_kernel_clock |
| 62 | ++let Extension = FunctionExtension<"cl_khr_kernel_clock __opencl_c_kernel_clock_scope_device"> in { |
| 63 | ++ def : Builtin<"clock_read_device", [ULong]>; |
| 64 | ++ def : Builtin<"clock_read_hilo_device", [VectorType<UInt, 2>]>; |
| 65 | ++} |
| 66 | ++let Extension = FunctionExtension<"cl_khr_kernel_clock __opencl_c_kernel_clock_scope_work_group"> in { |
| 67 | ++ def : Builtin<"clock_read_work_group", [ULong]>; |
| 68 | ++ def : Builtin<"clock_read_hilo_work_group", [VectorType<UInt, 2>]>; |
| 69 | ++} |
| 70 | ++let Extension = FunctionExtension<"cl_khr_kernel_clock __opencl_c_kernel_clock_scope_sub_group"> in { |
| 71 | ++ def : Builtin<"clock_read_sub_group", [ULong]>; |
| 72 | ++ def : Builtin<"clock_read_hilo_sub_group", [VectorType<UInt, 2>]>; |
| 73 | ++} |
| 74 | ++ |
| 75 | + //-------------------------------------------------------------------- |
| 76 | + // Arm extensions. |
| 77 | + let Extension = ArmIntegerDotProductInt8 in { |
| 78 | +-- |
| 79 | +2.39.1 |
| 80 | + |
0 commit comments