diff options
Diffstat (limited to 'dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm12-0006-OpenCL-Add-cl_khr_integer_dot_product.patch')
-rw-r--r-- | dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm12-0006-OpenCL-Add-cl_khr_integer_dot_product.patch | 146 |
1 files changed, 146 insertions, 0 deletions
diff --git a/dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm12-0006-OpenCL-Add-cl_khr_integer_dot_product.patch b/dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm12-0006-OpenCL-Add-cl_khr_integer_dot_product.patch new file mode 100644 index 00000000..25174047 --- /dev/null +++ b/dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm12-0006-OpenCL-Add-cl_khr_integer_dot_product.patch | |||
@@ -0,0 +1,146 @@ | |||
1 | From 54802abece1e4742050795162e3a773f0e143aa3 Mon Sep 17 00:00:00 2001 | ||
2 | From: haonanya <haonan.yang@intel.com> | ||
3 | Date: Fri, 24 Dec 2021 15:27:46 +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 <haonan.yang@intel.com> | ||
13 | |||
14 | Upstream-Status: Backport [https://github.com/llvm/llvm-project/commit/989bedec7a6ae95a0db865f23677047f78dc9257] | ||
15 | Signed-off-by: Anuj Mittal <anuj.mittal@intel.com> | ||
16 | --- | ||
17 | clang/lib/Headers/opencl-c-base.h | 3 +++ | ||
18 | clang/lib/Headers/opencl-c.h | 24 ++++++++++++++++++++++++ | ||
19 | clang/lib/Sema/OpenCLBuiltins.td | 25 +++++++++++++++++++++++++ | ||
20 | clang/test/Headers/opencl-c-header.cl | 18 ++++++++++++++++++ | ||
21 | 4 files changed, 70 insertions(+) | ||
22 | |||
23 | diff --git a/clang/lib/Headers/opencl-c-base.h b/clang/lib/Headers/opencl-c-base.h | ||
24 | index d94d64372dbb..b55d9601a452 100644 | ||
25 | --- a/clang/lib/Headers/opencl-c-base.h | ||
26 | +++ b/clang/lib/Headers/opencl-c-base.h | ||
27 | @@ -40,6 +40,9 @@ | ||
28 | #define __opencl_c_ext_fp32_local_atomic_add 1 | ||
29 | #define __opencl_c_ext_fp32_global_atomic_min_max 1 | ||
30 | #define __opencl_c_ext_fp32_local_atomic_min_max 1 | ||
31 | +#define cl_khr_integer_dot_product 1 | ||
32 | +#define __opencl_c_integer_dot_product_input_4x8bit 1 | ||
33 | +#define __opencl_c_integer_dot_product_input_4x8bit_packed 1 | ||
34 | #endif // defined(__SPIR__) | ||
35 | #endif // (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200) | ||
36 | |||
37 | diff --git a/clang/lib/Headers/opencl-c.h b/clang/lib/Headers/opencl-c.h | ||
38 | index 501a04f6e82b..50dcc03955cb 100644 | ||
39 | --- a/clang/lib/Headers/opencl-c.h | ||
40 | +++ b/clang/lib/Headers/opencl-c.h | ||
41 | @@ -16362,6 +16362,30 @@ double __ovld sub_group_clustered_reduce_max( double value, uint clustersize ); | ||
42 | |||
43 | #endif // cl_khr_subgroup_clustered_reduce | ||
44 | |||
45 | +#if defined(__opencl_c_integer_dot_product_input_4x8bit) | ||
46 | +uint __ovld __cnfn dot(uchar4, uchar4); | ||
47 | +int __ovld __cnfn dot(char4, char4); | ||
48 | +int __ovld __cnfn dot(uchar4, char4); | ||
49 | +int __ovld __cnfn dot(char4, uchar4); | ||
50 | + | ||
51 | +uint __ovld __cnfn dot_acc_sat(uchar4, uchar4, uint); | ||
52 | +int __ovld __cnfn dot_acc_sat(char4, char4, int); | ||
53 | +int __ovld __cnfn dot_acc_sat(uchar4, char4, int); | ||
54 | +int __ovld __cnfn dot_acc_sat(char4, uchar4, int); | ||
55 | +#endif // __opencl_c_integer_dot_product_input_4x8bit | ||
56 | + | ||
57 | +#if defined(__opencl_c_integer_dot_product_input_4x8bit_packed) | ||
58 | +uint __ovld __cnfn dot_4x8packed_uu_uint(uint, uint); | ||
59 | +int __ovld __cnfn dot_4x8packed_ss_int(uint, uint); | ||
60 | +int __ovld __cnfn dot_4x8packed_us_int(uint, uint); | ||
61 | +int __ovld __cnfn dot_4x8packed_su_int(uint, uint); | ||
62 | + | ||
63 | +uint __ovld __cnfn dot_acc_sat_4x8packed_uu_uint(uint, uint, uint); | ||
64 | +int __ovld __cnfn dot_acc_sat_4x8packed_ss_int(uint, uint, int); | ||
65 | +int __ovld __cnfn dot_acc_sat_4x8packed_us_int(uint, uint, int); | ||
66 | +int __ovld __cnfn dot_acc_sat_4x8packed_su_int(uint, uint, int); | ||
67 | +#endif // __opencl_c_integer_dot_product_input_4x8bit_packed | ||
68 | + | ||
69 | #if defined(cl_intel_subgroups) | ||
70 | // Intel-Specific Sub Group Functions | ||
71 | float __ovld __conv intel_sub_group_shuffle( float x, uint c ); | ||
72 | diff --git a/clang/lib/Sema/OpenCLBuiltins.td b/clang/lib/Sema/OpenCLBuiltins.td | ||
73 | index 745363a6b43f..3c5f8821063d 100644 | ||
74 | --- a/clang/lib/Sema/OpenCLBuiltins.td | ||
75 | +++ b/clang/lib/Sema/OpenCLBuiltins.td | ||
76 | @@ -1482,6 +1482,31 @@ let Extension = FuncExtKhrSubgroups in { | ||
77 | } | ||
78 | } | ||
79 | |||
80 | +// Section 42.3 - cl_khr_integer_dot_product | ||
81 | +let Extension = FunctionExtension<"__opencl_c_integer_dot_product_input_4x8bit"> in { | ||
82 | + def : Builtin<"dot", [UInt, VectorType<UChar, 4>, VectorType<UChar, 4>], Attr.Const>; | ||
83 | + def : Builtin<"dot", [Int, VectorType<Char, 4>, VectorType<Char, 4>], Attr.Const>; | ||
84 | + def : Builtin<"dot", [Int, VectorType<UChar, 4>, VectorType<Char, 4>], Attr.Const>; | ||
85 | + def : Builtin<"dot", [Int, VectorType<Char, 4>, VectorType<UChar, 4>], Attr.Const>; | ||
86 | + | ||
87 | + def : Builtin<"dot_acc_sat", [UInt, VectorType<UChar, 4>, VectorType<UChar, 4>, UInt], Attr.Const>; | ||
88 | + def : Builtin<"dot_acc_sat", [Int, VectorType<Char, 4>, VectorType<Char, 4>, Int], Attr.Const>; | ||
89 | + def : Builtin<"dot_acc_sat", [Int, VectorType<UChar, 4>, VectorType<Char, 4>, Int], Attr.Const>; | ||
90 | + def : Builtin<"dot_acc_sat", [Int, VectorType<Char, 4>, VectorType<UChar, 4>, Int], Attr.Const>; | ||
91 | +} | ||
92 | + | ||
93 | +let Extension = FunctionExtension<"__opencl_c_integer_dot_product_input_4x8bit_packed"> in { | ||
94 | + def : Builtin<"dot_4x8packed_uu_uint", [UInt, UInt, UInt], Attr.Const>; | ||
95 | + def : Builtin<"dot_4x8packed_ss_int", [Int, UInt, UInt], Attr.Const>; | ||
96 | + def : Builtin<"dot_4x8packed_us_int", [Int, UInt, UInt], Attr.Const>; | ||
97 | + def : Builtin<"dot_4x8packed_su_int", [Int, UInt, UInt], Attr.Const>; | ||
98 | + | ||
99 | + def : Builtin<"dot_acc_sat_4x8packed_uu_uint", [UInt, UInt, UInt, UInt], Attr.Const>; | ||
100 | + def : Builtin<"dot_acc_sat_4x8packed_ss_int", [Int, UInt, UInt, Int], Attr.Const>; | ||
101 | + def : Builtin<"dot_acc_sat_4x8packed_us_int", [Int, UInt, UInt, Int], Attr.Const>; | ||
102 | + def : Builtin<"dot_acc_sat_4x8packed_su_int", [Int, UInt, UInt, Int], Attr.Const>; | ||
103 | +} | ||
104 | + | ||
105 | //-------------------------------------------------------------------- | ||
106 | // Arm extensions. | ||
107 | let Extension = ArmIntegerDotProductInt8 in { | ||
108 | diff --git a/clang/test/Headers/opencl-c-header.cl b/clang/test/Headers/opencl-c-header.cl | ||
109 | index 443f682c711a..184eefd9f9c3 100644 | ||
110 | --- a/clang/test/Headers/opencl-c-header.cl | ||
111 | +++ b/clang/test/Headers/opencl-c-header.cl | ||
112 | @@ -166,6 +166,15 @@ global atomic_int z = ATOMIC_VAR_INIT(99); | ||
113 | #if __opencl_c_ext_fp64_local_atomic_min_max != 1 | ||
114 | #error "Incorrectly defined __opencl_c_ext_fp64_local_atomic_min_max" | ||
115 | #endif | ||
116 | +#if cl_khr_integer_dot_product != 1 | ||
117 | +#error "Incorrectly defined cl_khr_integer_dot_product" | ||
118 | +#endif | ||
119 | +#if __opencl_c_integer_dot_product_input_4x8bit != 1 | ||
120 | +#error "Incorrectly defined __opencl_c_integer_dot_product_input_4x8bit" | ||
121 | +#endif | ||
122 | +#if __opencl_c_integer_dot_product_input_4x8bit_packed != 1 | ||
123 | +#error "Incorrectly defined __opencl_c_integer_dot_product_input_4x8bit_packed" | ||
124 | +#endif | ||
125 | |||
126 | #else | ||
127 | |||
128 | @@ -232,6 +241,15 @@ global atomic_int z = ATOMIC_VAR_INIT(99); | ||
129 | #ifdef __opencl_c_ext_fp64_local_atomic_min_max | ||
130 | #error "Incorrectly __opencl_c_ext_fp64_local_atomic_min_max defined" | ||
131 | #endif | ||
132 | +#ifdef cl_khr_integer_dot_product | ||
133 | +#error "Incorrect cl_khr_integer_dot_product define" | ||
134 | +#endif | ||
135 | +#ifdef __opencl_c_integer_dot_product_input_4x8bit | ||
136 | +#error "Incorrect __opencl_c_integer_dot_product_input_4x8bit define" | ||
137 | +#endif | ||
138 | +#ifdef __opencl_c_integer_dot_product_input_4x8bit_packed | ||
139 | +#error "Incorrect __opencl_c_integer_dot_product_input_4x8bit_packed define" | ||
140 | +#endif | ||
141 | |||
142 | #endif //(defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200) | ||
143 | |||
144 | -- | ||
145 | 2.17.1 | ||
146 | |||