|
| 1 | +From 4dd7d0ddc63fd510b72c62e981e6f6aaad2fdb48 Mon Sep 17 00:00:00 2001 |
| 2 | +From: haonanya < [email protected]> |
| 3 | +Date: Thu, 30 Dec 2021 15:12:26 +0800 |
| 4 | +Subject: [PATCH] [OpenCL] Add cl_khr_integer_dot_product |
| 5 | + |
| 6 | +This is backporting of https://reviews.llvm.org/D106434 |
| 7 | +Add the builtins defined by Section 42 "Integer dot product" in the OpenCL |
| 8 | +Extension Specification. |
| 9 | + |
| 10 | +See https://www.khronos.org/registry/OpenCL/specs/3.0-unified/html/OpenCL_Ext.html#cl_khr_integer_dot_product |
| 11 | + |
| 12 | +Signed-off-by: haonanya < [email protected]> |
| 13 | +--- |
| 14 | + clang/lib/Headers/opencl-c-base.h | 3 +++ |
| 15 | + clang/lib/Headers/opencl-c.h | 24 ++++++++++++++++++++++++ |
| 16 | + clang/test/Headers/opencl-c-header.cl | 18 ++++++++++++++++++ |
| 17 | + 3 files changed, 45 insertions(+) |
| 18 | + |
| 19 | +diff --git a/clang/lib/Headers/opencl-c-base.h b/clang/lib/Headers/opencl-c-base.h |
| 20 | +index 5ed94e1b486b..b26e9ededc17 100644 |
| 21 | +--- a/clang/lib/Headers/opencl-c-base.h |
| 22 | ++++ b/clang/lib/Headers/opencl-c-base.h |
| 23 | +@@ -35,6 +35,9 @@ |
| 24 | + #define __opencl_c_ext_fp32_local_atomic_add 1 |
| 25 | + #define __opencl_c_ext_fp32_global_atomic_min_max 1 |
| 26 | + #define __opencl_c_ext_fp32_local_atomic_min_max 1 |
| 27 | ++#define cl_khr_integer_dot_product 1 |
| 28 | ++#define __opencl_c_integer_dot_product_input_4x8bit 1 |
| 29 | ++#define __opencl_c_integer_dot_product_input_4x8bit_packed 1 |
| 30 | + #endif // (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200) |
| 31 | + |
| 32 | + // Define features for 2.0 for header backward compatibility |
| 33 | +diff --git a/clang/lib/Headers/opencl-c.h b/clang/lib/Headers/opencl-c.h |
| 34 | +index 786691b3a29d..ca70ff9e31d1 100644 |
| 35 | +--- a/clang/lib/Headers/opencl-c.h |
| 36 | ++++ b/clang/lib/Headers/opencl-c.h |
| 37 | +@@ -18430,6 +18430,30 @@ double __ovld sub_group_clustered_reduce_max( double value, uint clustersize ); |
| 38 | + |
| 39 | + #endif // cl_khr_subgroup_clustered_reduce |
| 40 | + |
| 41 | ++#if defined(__opencl_c_integer_dot_product_input_4x8bit) |
| 42 | ++uint __ovld __cnfn dot(uchar4, uchar4); |
| 43 | ++int __ovld __cnfn dot(char4, char4); |
| 44 | ++int __ovld __cnfn dot(uchar4, char4); |
| 45 | ++int __ovld __cnfn dot(char4, uchar4); |
| 46 | ++ |
| 47 | ++uint __ovld __cnfn dot_acc_sat(uchar4, uchar4, uint); |
| 48 | ++int __ovld __cnfn dot_acc_sat(char4, char4, int); |
| 49 | ++int __ovld __cnfn dot_acc_sat(uchar4, char4, int); |
| 50 | ++int __ovld __cnfn dot_acc_sat(char4, uchar4, int); |
| 51 | ++#endif // __opencl_c_integer_dot_product_input_4x8bit |
| 52 | ++ |
| 53 | ++#if defined(__opencl_c_integer_dot_product_input_4x8bit_packed) |
| 54 | ++uint __ovld __cnfn dot_4x8packed_uu_uint(uint, uint); |
| 55 | ++int __ovld __cnfn dot_4x8packed_ss_int(uint, uint); |
| 56 | ++int __ovld __cnfn dot_4x8packed_us_int(uint, uint); |
| 57 | ++int __ovld __cnfn dot_4x8packed_su_int(uint, uint); |
| 58 | ++ |
| 59 | ++uint __ovld __cnfn dot_acc_sat_4x8packed_uu_uint(uint, uint, uint); |
| 60 | ++int __ovld __cnfn dot_acc_sat_4x8packed_ss_int(uint, uint, int); |
| 61 | ++int __ovld __cnfn dot_acc_sat_4x8packed_us_int(uint, uint, int); |
| 62 | ++int __ovld __cnfn dot_acc_sat_4x8packed_su_int(uint, uint, int); |
| 63 | ++#endif // __opencl_c_integer_dot_product_input_4x8bit_packed |
| 64 | ++ |
| 65 | + #if defined(cl_intel_subgroups) |
| 66 | + // Intel-Specific Sub Group Functions |
| 67 | + float __ovld __conv intel_sub_group_shuffle( float x, uint c ); |
| 68 | +diff --git a/clang/test/Headers/opencl-c-header.cl b/clang/test/Headers/opencl-c-header.cl |
| 69 | +index ab25574eec8e..fe8b00c00b28 100644 |
| 70 | +--- a/clang/test/Headers/opencl-c-header.cl |
| 71 | ++++ b/clang/test/Headers/opencl-c-header.cl |
| 72 | +@@ -146,6 +146,15 @@ global atomic_int z = ATOMIC_VAR_INIT(99); |
| 73 | + #if __opencl_c_ext_fp64_local_atomic_min_max != 1 |
| 74 | + #error "Incorrectly defined __opencl_c_ext_fp64_local_atomic_min_max" |
| 75 | + #endif |
| 76 | ++#if cl_khr_integer_dot_product != 1 |
| 77 | ++#error "Incorrectly defined cl_khr_integer_dot_product" |
| 78 | ++#endif |
| 79 | ++#if __opencl_c_integer_dot_product_input_4x8bit != 1 |
| 80 | ++#error "Incorrectly defined __opencl_c_integer_dot_product_input_4x8bit" |
| 81 | ++#endif |
| 82 | ++#if __opencl_c_integer_dot_product_input_4x8bit_packed != 1 |
| 83 | ++#error "Incorrectly defined __opencl_c_integer_dot_product_input_4x8bit_packed" |
| 84 | ++#endif |
| 85 | + #else |
| 86 | + |
| 87 | + #ifdef __opencl_c_ext_fp16_global_atomic_load_store |
| 88 | +@@ -190,6 +199,15 @@ global atomic_int z = ATOMIC_VAR_INIT(99); |
| 89 | + #ifdef __opencl_c_ext_fp64_local_atomic_min_max |
| 90 | + #error "Incorrectly __opencl_c_ext_fp64_local_atomic_min_max defined" |
| 91 | + #endif |
| 92 | ++#ifdef cl_khr_integer_dot_product |
| 93 | ++#error "Incorrect cl_khr_integer_dot_product define" |
| 94 | ++#endif |
| 95 | ++#ifdef __opencl_c_integer_dot_product_input_4x8bit |
| 96 | ++#error "Incorrect __opencl_c_integer_dot_product_input_4x8bit define" |
| 97 | ++#endif |
| 98 | ++#ifdef __opencl_c_integer_dot_product_input_4x8bit_packed |
| 99 | ++#error "Incorrect __opencl_c_integer_dot_product_input_4x8bit_packed define" |
| 100 | ++#endif |
| 101 | + |
| 102 | + #endif //(defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200) |
| 103 | + |
| 104 | +-- |
| 105 | +2.17.1 |
| 106 | + |
0 commit comments