1 | namespace dnnl { |
2 | namespace impl { |
3 | namespace gpu { |
4 | namespace ocl { |
5 | const char * = R"==(/******************************************************************************* )==" "\n" |
6 | R"==(* Copyright 2019-2022 Intel Corporation )==" "\n" |
7 | R"==(* )==" "\n" |
8 | R"==(* Licensed under the Apache License, Version 2.0 (the "License"); )==" "\n" |
9 | R"==(* you may not use this file except in compliance with the License. )==" "\n" |
10 | R"==(* You may obtain a copy of the License at )==" "\n" |
11 | R"==(* )==" "\n" |
12 | R"==(* http: )==" "\n" |
13 | R"==(* )==" "\n" |
14 | R"==(* Unless required by applicable law or agreed to in writing, software )==" "\n" |
15 | R"==(* distributed under the License is distributed on an "AS IS" BASIS, )==" "\n" |
16 | R"==(* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. )==" "\n" |
17 | R"==(* See the License for the specific language governing permissions and )==" "\n" |
18 | R"==(* limitations under the License. )==" "\n" |
19 | R"==(*******************************************************************************/ )==" "\n" |
20 | R"==(#ifndef GPU_OCL_OCL_MATH_UTILS_H )==" "\n" |
21 | R"==(#define GPU_OCL_OCL_MATH_UTILS_H )==" "\n" |
22 | R"==(#pragma OPENCL EXTENSION cl_khr_fp16 : enable )==" "\n" |
23 | R"==(#if DT_BF16 || SRC_DT_BF16 || WEI_DT_BF16 || DST_DT_BF16 || BIA_DT_BF16 \ )==" "\n" |
24 | R"==(|| A_DT_BF16 || B_DT_BF16 || C_DT_BF16 || SUM_DT_BF16 \ )==" "\n" |
25 | R"==(|| POST_OP_USING_BF16 )==" "\n" |
26 | R"==(#define MATH_UTILS_DECLARE_BF16 1 )==" "\n" |
27 | R"==(#endif )==" "\n" |
28 | R"==(ulong8 __builtin_IB_simd_block_read_8_global_l(const __global ulong *); )==" "\n" |
29 | R"==(ushort16 __builtin_IB_simd_block_read_16_global_h(const __global ushort *); )==" "\n" |
30 | R"==(void __builtin_IB_simd_block_write_8_global_l(__global ulong *, ulong8); )==" "\n" |
31 | R"==(void __builtin_IB_simd_block_write_16_global_h(__global ushort *, ushort16); )==" "\n" |
32 | R"==(#if MATH_UTILS_DECLARE_BF16 )==" "\n" |
33 | R"==(#ifdef cl_future_bf16_cvt )==" "\n" |
34 | R"==(short __builtin_IB_ftobf_1(float a) __attribute__((const)); )==" "\n" |
35 | R"==(short2 __builtin_IB_ftobf_2(float2 a) __attribute__((const)); )==" "\n" |
36 | R"==(short4 __builtin_IB_ftobf_4(float4 a) __attribute__((const)); )==" "\n" |
37 | R"==(short8 __builtin_IB_ftobf_8(float8 a) __attribute__((const)); )==" "\n" |
38 | R"==(short16 __builtin_IB_ftobf_16(float16 a) __attribute__((const)); )==" "\n" |
39 | R"==(float __builtin_IB_bftof_1(short a) __attribute__((const)); )==" "\n" |
40 | R"==(float2 __builtin_IB_bftof_2(short2 a) __attribute__((const)); )==" "\n" |
41 | R"==(float4 __builtin_IB_bftof_4(short4 a) __attribute__((const)); )==" "\n" |
42 | R"==(float8 __builtin_IB_bftof_8(short8 a) __attribute__((const)); )==" "\n" |
43 | R"==(float16 __builtin_IB_bftof_16(short16 a) __attribute__((const)); )==" "\n" |
44 | R"==(ushort __attribute__((overloadable)) cvt_f32_to_bf16(float a) { return as_ushort (__builtin_IB_ftobf_1 (a)); } )==" "\n" |
45 | R"==(ushort2 __attribute__((overloadable)) cvt_f32_to_bf16(float2 a) { return as_ushort2 (__builtin_IB_ftobf_2 (a)); } )==" "\n" |
46 | R"==(ushort4 __attribute__((overloadable)) cvt_f32_to_bf16(float4 a) { return as_ushort4 (__builtin_IB_ftobf_4 (a)); } )==" "\n" |
47 | R"==(ushort8 __attribute__((overloadable)) cvt_f32_to_bf16(float8 a) { return as_ushort8 (__builtin_IB_ftobf_8 (a)); } )==" "\n" |
48 | R"==(ushort16 __attribute__((overloadable)) cvt_f32_to_bf16(float16 a) { return as_ushort16(__builtin_IB_ftobf_16(a)); } )==" "\n" |
49 | R"==(float __attribute__((overloadable)) cvt_bf16_to_f32(ushort a) { return __builtin_IB_bftof_1 (as_short (a)); } )==" "\n" |
50 | R"==(float2 __attribute__((overloadable)) cvt_bf16_to_f32(ushort2 a) { return __builtin_IB_bftof_2 (as_short2 (a)); } )==" "\n" |
51 | R"==(float4 __attribute__((overloadable)) cvt_bf16_to_f32(ushort4 a) { return __builtin_IB_bftof_4 (as_short4 (a)); } )==" "\n" |
52 | R"==(float8 __attribute__((overloadable)) cvt_bf16_to_f32(ushort8 a) { return __builtin_IB_bftof_8 (as_short8 (a)); } )==" "\n" |
53 | R"==(float16 __attribute__((overloadable)) cvt_bf16_to_f32(ushort16 a) { return __builtin_IB_bftof_16(as_short16(a)); } )==" "\n" |
54 | R"==(#else )==" "\n" |
55 | R"==(ushort __attribute__((overloadable)) cvt_f32_to_bf16(float f) { )==" "\n" |
56 | R"==(uint i = as_uint(f); )==" "\n" |
57 | R"==(i += 0x00007FFF + ((i & 0x10000) >> 16); )==" "\n" |
58 | R"==(ushort2 r = as_ushort2(i); )==" "\n" |
59 | R"==(return r[1]; )==" "\n" |
60 | R"==(} )==" "\n" |
61 | R"==(ushort2 __attribute__((overloadable)) cvt_f32_to_bf16(float2 f) { )==" "\n" |
62 | R"==(ushort2 r; )==" "\n" |
63 | R"==(for (int i = 0; i < 2; i++) { )==" "\n" |
64 | R"==(r[i] = cvt_f32_to_bf16(f[i]); )==" "\n" |
65 | R"==(} )==" "\n" |
66 | R"==(return r; )==" "\n" |
67 | R"==(} )==" "\n" |
68 | R"==(ushort4 __attribute__((overloadable)) cvt_f32_to_bf16(float4 f) { )==" "\n" |
69 | R"==(ushort4 r; )==" "\n" |
70 | R"==(for (int i = 0; i < 4; i++) { )==" "\n" |
71 | R"==(r[i] = cvt_f32_to_bf16(f[i]); )==" "\n" |
72 | R"==(} )==" "\n" |
73 | R"==(return r; )==" "\n" |
74 | R"==(} )==" "\n" |
75 | R"==(ushort8 __attribute__((overloadable)) cvt_f32_to_bf16(float8 f) { )==" "\n" |
76 | R"==(ushort8 r; )==" "\n" |
77 | R"==(for (int i = 0; i < 8; i++) { )==" "\n" |
78 | R"==(r[i] = cvt_f32_to_bf16(f[i]); )==" "\n" |
79 | R"==(} )==" "\n" |
80 | R"==(return r; )==" "\n" |
81 | R"==(} )==" "\n" |
82 | R"==(ushort16 __attribute__((overloadable)) cvt_f32_to_bf16(float16 f) { )==" "\n" |
83 | R"==(ushort16 r; )==" "\n" |
84 | R"==(for (int i = 0; i < 16; i++) { )==" "\n" |
85 | R"==(r[i] = cvt_f32_to_bf16(f[i]); )==" "\n" |
86 | R"==(} )==" "\n" |
87 | R"==(return r; )==" "\n" |
88 | R"==(} )==" "\n" |
89 | R"==(float __attribute__((overloadable)) cvt_bf16_to_f32(ushort b) { )==" "\n" |
90 | R"==(ushort2 r = {0, b}; )==" "\n" |
91 | R"==(float f = as_float(r); )==" "\n" |
92 | R"==(return f; )==" "\n" |
93 | R"==(} )==" "\n" |
94 | R"==(float2 __attribute__((overloadable)) cvt_bf16_to_f32(ushort2 b) { )==" "\n" |
95 | R"==(float2 f; )==" "\n" |
96 | R"==(for (int i = 0; i < 2; i++) { )==" "\n" |
97 | R"==(f[i] = cvt_bf16_to_f32(b[i]); )==" "\n" |
98 | R"==(} )==" "\n" |
99 | R"==(return f; )==" "\n" |
100 | R"==(} )==" "\n" |
101 | R"==(float4 __attribute__((overloadable)) cvt_bf16_to_f32(ushort4 b) { )==" "\n" |
102 | R"==(float4 f; )==" "\n" |
103 | R"==(for (int i = 0; i < 4; i++) { )==" "\n" |
104 | R"==(f[i] = cvt_bf16_to_f32(b[i]); )==" "\n" |
105 | R"==(} )==" "\n" |
106 | R"==(return f; )==" "\n" |
107 | R"==(} )==" "\n" |
108 | R"==(float8 __attribute__((overloadable)) cvt_bf16_to_f32(ushort8 b) { )==" "\n" |
109 | R"==(float8 f; )==" "\n" |
110 | R"==(for (int i = 0; i < 8; i++) { )==" "\n" |
111 | R"==(f[i] = cvt_bf16_to_f32(b[i]); )==" "\n" |
112 | R"==(} )==" "\n" |
113 | R"==(return f; )==" "\n" |
114 | R"==(} )==" "\n" |
115 | R"==(float16 __attribute__((overloadable)) cvt_bf16_to_f32(ushort16 b) { )==" "\n" |
116 | R"==(float16 f; )==" "\n" |
117 | R"==(for (int i = 0; i < 16; i++) { )==" "\n" |
118 | R"==(f[i] = cvt_bf16_to_f32(b[i]); )==" "\n" |
119 | R"==(} )==" "\n" |
120 | R"==(return f; )==" "\n" |
121 | R"==(} )==" "\n" |
122 | R"==(#endif )==" "\n" |
123 | R"==(#endif )==" "\n" |
124 | R"==(int __attribute__((overloadable)) idot4(char4 a, char4 b, int c) { )==" "\n" |
125 | R"==(c += a[0] * b[0]; )==" "\n" |
126 | R"==(c += a[1] * b[1]; )==" "\n" |
127 | R"==(c += a[2] * b[2]; )==" "\n" |
128 | R"==(c += a[3] * b[3]; )==" "\n" |
129 | R"==(return c; )==" "\n" |
130 | R"==(} )==" "\n" |
131 | R"==(int __attribute__((overloadable)) idot4(uchar4 a, uchar4 b, int c) { )==" "\n" |
132 | R"==(c += a[0] * b[0]; )==" "\n" |
133 | R"==(c += a[1] * b[1]; )==" "\n" |
134 | R"==(c += a[2] * b[2]; )==" "\n" |
135 | R"==(c += a[3] * b[3]; )==" "\n" |
136 | R"==(return c; )==" "\n" |
137 | R"==(} )==" "\n" |
138 | R"==(int __attribute__((overloadable)) idot4(char4 a, uchar4 b, int c) { )==" "\n" |
139 | R"==(c += a[0] * b[0]; )==" "\n" |
140 | R"==(c += a[1] * b[1]; )==" "\n" |
141 | R"==(c += a[2] * b[2]; )==" "\n" |
142 | R"==(c += a[3] * b[3]; )==" "\n" |
143 | R"==(return c; )==" "\n" |
144 | R"==(} )==" "\n" |
145 | R"==(int __attribute__((overloadable)) idot4(uchar4 a, char4 b, int c) { )==" "\n" |
146 | R"==(c += a[0] * b[0]; )==" "\n" |
147 | R"==(c += a[1] * b[1]; )==" "\n" |
148 | R"==(c += a[2] * b[2]; )==" "\n" |
149 | R"==(c += a[3] * b[3]; )==" "\n" |
150 | R"==(return c; )==" "\n" |
151 | R"==(} )==" "\n" |
152 | R"==(int __attribute__((overloadable)) idot4(int a, int b, int c) { )==" "\n" |
153 | R"==(return idot4(as_char4(a), as_char4(b), c); )==" "\n" |
154 | R"==(} )==" "\n" |
155 | R"==(int __attribute__((overloadable)) idot4(uint a, int b, int c) { )==" "\n" |
156 | R"==(return idot4(as_uchar4(a), as_char4(b), c); )==" "\n" |
157 | R"==(} )==" "\n" |
158 | R"==(float __attribute__((overloadable)) f16_dot2(int a, int b, float c) { )==" "\n" |
159 | R"==(half2 _a = as_half2(a); )==" "\n" |
160 | R"==(half2 _b = as_half2(b); )==" "\n" |
161 | R"==(return c + _a[0] * _b[0] + _a[1] * _b[1]; )==" "\n" |
162 | R"==(} )==" "\n" |
163 | R"==(#if MATH_UTILS_DECLARE_BF16 )==" "\n" |
164 | R"==(float __attribute__((overloadable)) bf16_dot2(int a, int b, float c) { )==" "\n" |
165 | R"==(ushort2 _a = as_ushort2(a); )==" "\n" |
166 | R"==(ushort2 _b = as_ushort2(b); )==" "\n" |
167 | R"==(c += cvt_bf16_to_f32(_a[0]) * cvt_bf16_to_f32(_b[0]); )==" "\n" |
168 | R"==(c += cvt_bf16_to_f32(_a[1]) * cvt_bf16_to_f32(_b[1]); )==" "\n" |
169 | R"==(return c; )==" "\n" |
170 | R"==(} )==" "\n" |
171 | R"==(#endif )==" "\n" |
172 | R"==(#define DECLARE_BLOCK_READ(suffix, func, data_type, addr_space, p_type) \ )==" "\n" |
173 | R"==(data_type __attribute__((overloadable)) \ )==" "\n" |
174 | R"==(block_read##suffix(const addr_space p_type *p) { \ )==" "\n" |
175 | R"==(return func(p); \ )==" "\n" |
176 | R"==(} )==" "\n" |
177 | R"==(#define DECLARE_BLOCK_READ_EMU(suffix, data_type, addr_space, p_type) \ )==" "\n" |
178 | R"==(data_type __attribute__((overloadable)) \ )==" "\n" |
179 | R"==(block_read##suffix##_emu(const addr_space p_type *p) { \ )==" "\n" |
180 | R"==(data_type ret; \ )==" "\n" |
181 | R"==(uint idx = get_sub_group_local_id(); \ )==" "\n" |
182 | R"==(for (int i = 0; i < sizeof(data_type) / sizeof(p_type); i++) { \ )==" "\n" |
183 | R"==(((p_type *)&ret)[i] = p[idx]; \ )==" "\n" |
184 | R"==(idx += get_max_sub_group_size(); \ )==" "\n" |
185 | R"==(} \ )==" "\n" |
186 | R"==(return ret; \ )==" "\n" |
187 | R"==(} )==" "\n" |
188 | R"==(#define DECLARE_BLOCK_WRITE(suffix, func, data_type, addr_space, p_type) \ )==" "\n" |
189 | R"==(void __attribute__((overloadable)) \ )==" "\n" |
190 | R"==(block_write##suffix(addr_space p_type *p, data_type data) { \ )==" "\n" |
191 | R"==(func(p, data); \ )==" "\n" |
192 | R"==(} )==" "\n" |
193 | R"==(#define DECLARE_BLOCK_WRITE_EMU(suffix, data_type, addr_space, p_type) \ )==" "\n" |
194 | R"==(void __attribute__((overloadable)) \ )==" "\n" |
195 | R"==(block_write##suffix##_emu(addr_space p_type *p, data_type data) { \ )==" "\n" |
196 | R"==(uint idx = get_sub_group_local_id(); \ )==" "\n" |
197 | R"==(for (int i = 0; i < sizeof(data_type) / sizeof(p_type); i++) { \ )==" "\n" |
198 | R"==(p[idx] = ((p_type *)&data)[i]; \ )==" "\n" |
199 | R"==(p += get_max_sub_group_size(); \ )==" "\n" |
200 | R"==(} \ )==" "\n" |
201 | R"==(} )==" "\n" |
202 | R"==(DECLARE_BLOCK_READ(, intel_sub_group_block_read, uint, __global, uint) )==" "\n" |
203 | R"==(DECLARE_BLOCK_READ(2, intel_sub_group_block_read2, uint2, __global, uint) )==" "\n" |
204 | R"==(DECLARE_BLOCK_READ(4, intel_sub_group_block_read4, uint4, __global, uint) )==" "\n" |
205 | R"==(DECLARE_BLOCK_READ(8, intel_sub_group_block_read8, uint8, __global, uint) )==" "\n" |
206 | R"==(DECLARE_BLOCK_WRITE(, intel_sub_group_block_write, uint, __global, uint) )==" "\n" |
207 | R"==(DECLARE_BLOCK_WRITE(2, intel_sub_group_block_write2, uint2, __global, uint) )==" "\n" |
208 | R"==(DECLARE_BLOCK_WRITE(4, intel_sub_group_block_write4, uint4, __global, uint) )==" "\n" |
209 | R"==(DECLARE_BLOCK_WRITE(8, intel_sub_group_block_write8, uint8, __global, uint) )==" "\n" |
210 | R"==(#ifdef cl_intel_subgroups_char )==" "\n" |
211 | R"==(void __attribute__((overloadable)) )==" "\n" |
212 | R"==(intel_sub_group_block_write_uc16(__global uchar *p, uchar16 data); )==" "\n" |
213 | R"==(uchar16 __attribute__((overloadable)) )==" "\n" |
214 | R"==(intel_sub_group_block_read_uc16(const __global uchar *p); )==" "\n" |
215 | R"==(#endif )==" "\n" |
216 | R"==(DECLARE_BLOCK_READ_EMU(, uint, __local, uint) )==" "\n" |
217 | R"==(DECLARE_BLOCK_READ_EMU(2, uint2, __local, uint) )==" "\n" |
218 | R"==(DECLARE_BLOCK_READ_EMU(4, uint4, __local, uint) )==" "\n" |
219 | R"==(DECLARE_BLOCK_READ_EMU(8, uint8, __local, uint) )==" "\n" |
220 | R"==(DECLARE_BLOCK_WRITE_EMU(, uint, __local, uint) )==" "\n" |
221 | R"==(DECLARE_BLOCK_WRITE_EMU(2, uint2, __local, uint) )==" "\n" |
222 | R"==(DECLARE_BLOCK_WRITE_EMU(4, uint4, __local, uint) )==" "\n" |
223 | R"==(DECLARE_BLOCK_WRITE_EMU(8, uint8, __local, uint) )==" "\n" |
224 | R"==(DECLARE_BLOCK_WRITE_EMU(_us, ushort, __local, ushort) )==" "\n" |
225 | R"==(DECLARE_BLOCK_WRITE_EMU(_us2, ushort2, __local, ushort) )==" "\n" |
226 | R"==(DECLARE_BLOCK_WRITE_EMU(_us4, ushort4, __local, ushort) )==" "\n" |
227 | R"==(DECLARE_BLOCK_WRITE_EMU(_us8, ushort8, __local, ushort) )==" "\n" |
228 | R"==(#ifdef cl_intel_subgroup_local_block_io )==" "\n" |
229 | R"==(DECLARE_BLOCK_READ(, intel_sub_group_block_read, uint, __local, uint) )==" "\n" |
230 | R"==(DECLARE_BLOCK_READ(2, intel_sub_group_block_read2, uint2, __local, uint) )==" "\n" |
231 | R"==(DECLARE_BLOCK_READ(4, intel_sub_group_block_read4, uint4, __local, uint) )==" "\n" |
232 | R"==(DECLARE_BLOCK_READ(8, intel_sub_group_block_read8, uint8, __local, uint) )==" "\n" |
233 | R"==(DECLARE_BLOCK_WRITE(, intel_sub_group_block_write, uint, __local, uint) )==" "\n" |
234 | R"==(DECLARE_BLOCK_WRITE(2, intel_sub_group_block_write2, uint2, __local, uint) )==" "\n" |
235 | R"==(DECLARE_BLOCK_WRITE(4, intel_sub_group_block_write4, uint4, __local, uint) )==" "\n" |
236 | R"==(DECLARE_BLOCK_WRITE(8, intel_sub_group_block_write8, uint8, __local, uint) )==" "\n" |
237 | R"==(DECLARE_BLOCK_WRITE( )==" "\n" |
238 | R"==(_us, intel_sub_group_block_write_us, ushort, __local, ushort) )==" "\n" |
239 | R"==(#else )==" "\n" |
240 | R"==(DECLARE_BLOCK_READ(, block_read_emu, uint, __local, uint) )==" "\n" |
241 | R"==(DECLARE_BLOCK_READ(2, block_read2_emu, uint2, __local, uint) )==" "\n" |
242 | R"==(DECLARE_BLOCK_READ(4, block_read4_emu, uint4, __local, uint) )==" "\n" |
243 | R"==(DECLARE_BLOCK_READ(8, block_read8_emu, uint8, __local, uint) )==" "\n" |
244 | R"==(DECLARE_BLOCK_WRITE(, block_write_emu, uint, __local, uint) )==" "\n" |
245 | R"==(DECLARE_BLOCK_WRITE(2, block_write2_emu, uint2, __local, uint) )==" "\n" |
246 | R"==(DECLARE_BLOCK_WRITE(4, block_write4_emu, uint4, __local, uint) )==" "\n" |
247 | R"==(DECLARE_BLOCK_WRITE(8, block_write8_emu, uint8, __local, uint) )==" "\n" |
248 | R"==(DECLARE_BLOCK_WRITE(_us, block_write_us_emu, ushort, __local, ushort) )==" "\n" |
249 | R"==(#endif )==" "\n" |
250 | R"==(#define DECLARE_MMAD_EMU(name, dot, K, m, a_type, b_type, acc_type) \ )==" "\n" |
251 | R"==(acc_type __attribute__((overloadable)) \ )==" "\n" |
252 | R"==(name(a_type A_vectors, b_type B_vectors, acc_type acc) { \ )==" "\n" |
253 | R"==(for (uint i = 0; i < (m); ++i) { \ )==" "\n" |
254 | R"==(for (uint j = 0; j < (K); ++j) \ )==" "\n" |
255 | R"==(acc[i] = dot(sub_group_broadcast(A_vectors[i], j), \ )==" "\n" |
256 | R"==(B_vectors[j], acc[i]); \ )==" "\n" |
257 | R"==(} \ )==" "\n" |
258 | R"==(return acc; \ )==" "\n" |
259 | R"==(} )==" "\n" |
260 | R"==(DECLARE_MMAD_EMU(mmad8x4, idot4, 8, 4, uint4, int8, int4) )==" "\n" |
261 | R"==(DECLARE_MMAD_EMU(mmad8x4, idot4, 8, 4, int4, int8, int4) )==" "\n" |
262 | R"==(DECLARE_MMAD_EMU(mmad8x8, idot4, 8, 8, uint8, int8, int8) )==" "\n" |
263 | R"==(DECLARE_MMAD_EMU(mmad8x8, idot4, 8, 8, int8, int8, int8) )==" "\n" |
264 | R"==(DECLARE_MMAD_EMU(mmad8x8, idot4, 8, 8, ushort8, int8, int8) )==" "\n" |
265 | R"==(DECLARE_MMAD_EMU(mmad8x8, idot4, 8, 8, short8, int8, int8) )==" "\n" |
266 | R"==(DECLARE_MMAD_EMU(mmad8x4_f16, f16_dot2, 8, 4, uint4, int8, float4) )==" "\n" |
267 | R"==(DECLARE_MMAD_EMU(mmad8x4_f16, f16_dot2, 8, 4, short4, int8, float4) )==" "\n" |
268 | R"==(DECLARE_MMAD_EMU(mmad8x8_f16, f16_dot2, 8, 8, uint8, int8, float8) )==" "\n" |
269 | R"==(DECLARE_MMAD_EMU(mmad8x8_f16, f16_dot2, 8, 8, short8, int8, float8) )==" "\n" |
270 | R"==(#if MATH_UTILS_DECLARE_BF16 )==" "\n" |
271 | R"==(DECLARE_MMAD_EMU(mmad8x4_bf16, bf16_dot2, 8, 4, uint4, int8, float4) )==" "\n" |
272 | R"==(DECLARE_MMAD_EMU(mmad8x8_bf16, bf16_dot2, 8, 8, uint8, int8, float8) )==" "\n" |
273 | R"==(DECLARE_MMAD_EMU(mmad8x4_bf16, bf16_dot2, 8, 4, ushort4, int8, float4) )==" "\n" |
274 | R"==(DECLARE_MMAD_EMU(mmad8x8_bf16, bf16_dot2, 8, 8, ushort8, int8, float8) )==" "\n" |
275 | R"==(DECLARE_MMAD_EMU(mmad8x8_bf16, bf16_dot2, 8, 8, short8, int8, float8) )==" "\n" |
276 | R"==(#endif )==" "\n" |
277 | R"==(#if __OPENCL_C_VERSION__ >= 200 )==" "\n" |
278 | R"==(#ifdef cl_intel_global_float_atomics )==" "\n" |
279 | R"==(inline void atomic_add_global( )==" "\n" |
280 | R"==(volatile global atomic_float *source, float operand) { )==" "\n" |
281 | R"==(atomic_fetch_add_explicit(source, operand, memory_order_relaxed); )==" "\n" |
282 | R"==(} )==" "\n" |
283 | R"==(#else )==" "\n" |
284 | R"==(inline void atomic_add_global( )==" "\n" |
285 | R"==(volatile __global atomic_float *source, float operand) { )==" "\n" |
286 | R"==(float old_val = atomic_load_explicit( )==" "\n" |
287 | R"==(source, memory_order_relaxed, memory_scope_device); )==" "\n" |
288 | R"==(bool success = false; )==" "\n" |
289 | R"==(do { )==" "\n" |
290 | R"==(float new_val = old_val + operand; )==" "\n" |
291 | R"==(success = atomic_compare_exchange_strong_explicit(source, &old_val, )==" "\n" |
292 | R"==(new_val, memory_order_acq_rel, memory_order_relaxed, )==" "\n" |
293 | R"==(memory_scope_device); )==" "\n" |
294 | R"==(} while (!success); )==" "\n" |
295 | R"==(} )==" "\n" |
296 | R"==(#endif )==" "\n" |
297 | R"==(#endif )==" "\n" |
298 | R"==(#endif )==" "\n" |
299 | R"==()==" ; |
300 | } |
301 | } |
302 | } |
303 | } |