1 | namespace dnnl { |
2 | namespace impl { |
3 | namespace gpu { |
4 | namespace ocl { |
5 | const char * = R"==(/******************************************************************************* )==" "\n" |
6 | R"==(* Copyright 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_BINARY_TYPES_H )==" "\n" |
21 | R"==(#define GPU_OCL_BINARY_TYPES_H )==" "\n" |
22 | R"==(#include "gpu/ocl/ocl_post_ops.h" )==" "\n" |
23 | R"==(#include "gpu/ocl/ocl_types.h" )==" "\n" |
24 | R"==(#undef DST_OFF )==" "\n" |
25 | R"==(#define DST_OFF(x0, x1, x2, x3, x4, x5) OFF_MD(DST, x0, x1, x2, x3, x4, x5) )==" "\n" |
26 | R"==(#define SRC0_OFF(x0, x1, x2, x3, x4, x5) OFF_MD(SRC0, x0, x1, x2, x3, x4, x5) )==" "\n" |
27 | R"==(#define SRC1_OFF(x0, x1, x2, x3, x4, x5) OFF_MD(SRC1, x0, x1, x2, x3, x4, x5) )==" "\n" |
28 | R"==(#if SRC0_DT_S8 )==" "\n" |
29 | R"==(#define SRC0_BLOCK_READ(src) \ )==" "\n" |
30 | R"==(as_char(intel_sub_group_block_read_uc((const __global uchar *)(src))) )==" "\n" |
31 | R"==(#define SRC0_BLOCK_READ2(src) \ )==" "\n" |
32 | R"==(as_char2(intel_sub_group_block_read_uc2((const __global uchar *)(src))) )==" "\n" |
33 | R"==(#define SRC0_BLOCK_READ4(src) \ )==" "\n" |
34 | R"==(as_char4(intel_sub_group_block_read_uc4((const __global uchar *)(src))) )==" "\n" |
35 | R"==(#define SRC0_BLOCK_READ8(src) \ )==" "\n" |
36 | R"==(as_char8(intel_sub_group_block_read_uc8((const __global uchar *)(src))) )==" "\n" |
37 | R"==(#endif )==" "\n" |
38 | R"==(#if SRC1_DT_S8 )==" "\n" |
39 | R"==(#define SRC1_BLOCK_READ(src) \ )==" "\n" |
40 | R"==(as_char(intel_sub_group_block_read_uc((const __global uchar *)(src))) )==" "\n" |
41 | R"==(#define SRC1_BLOCK_READ2(src) \ )==" "\n" |
42 | R"==(as_char2(intel_sub_group_block_read_uc2((const __global uchar *)(src))) )==" "\n" |
43 | R"==(#define SRC1_BLOCK_READ4(src) \ )==" "\n" |
44 | R"==(as_char4(intel_sub_group_block_read_uc4((const __global uchar *)(src))) )==" "\n" |
45 | R"==(#define SRC1_BLOCK_READ8(src) \ )==" "\n" |
46 | R"==(as_char8(intel_sub_group_block_read_uc8((const __global uchar *)(src))) )==" "\n" |
47 | R"==(#endif )==" "\n" |
48 | R"==(#if SRC0_DT_U8 )==" "\n" |
49 | R"==(#define SRC0_BLOCK_READ(src) \ )==" "\n" |
50 | R"==(as_uchar(intel_sub_group_block_read_uc((const __global uchar *)(src))) )==" "\n" |
51 | R"==(#define SRC0_BLOCK_READ2(src) \ )==" "\n" |
52 | R"==(as_uchar2(intel_sub_group_block_read_uc2((const __global uchar *)(src))) )==" "\n" |
53 | R"==(#define SRC0_BLOCK_READ4(src) \ )==" "\n" |
54 | R"==(as_uchar4(intel_sub_group_block_read_uc4((const __global uchar *)(src))) )==" "\n" |
55 | R"==(#define SRC0_BLOCK_READ8(src) \ )==" "\n" |
56 | R"==(as_uchar8(intel_sub_group_block_read_uc8((const __global uchar *)(src))) )==" "\n" |
57 | R"==(#endif )==" "\n" |
58 | R"==(#if SRC1_DT_U8 )==" "\n" |
59 | R"==(#define SRC1_BLOCK_READ(src) \ )==" "\n" |
60 | R"==(as_uchar(intel_sub_group_block_read_uc((const __global uchar *)(src))) )==" "\n" |
61 | R"==(#define SRC1_BLOCK_READ2(src) \ )==" "\n" |
62 | R"==(as_uchar2(intel_sub_group_block_read_uc2((const __global uchar *)(src))) )==" "\n" |
63 | R"==(#define SRC1_BLOCK_READ4(src) \ )==" "\n" |
64 | R"==(as_uchar4(intel_sub_group_block_read_uc4((const __global uchar *)(src))) )==" "\n" |
65 | R"==(#define SRC1_BLOCK_READ8(src) \ )==" "\n" |
66 | R"==(as_uchar8(intel_sub_group_block_read_uc8((const __global uchar *)(src))) )==" "\n" |
67 | R"==(#endif )==" "\n" |
68 | R"==(#if SRC0_DT_F16 )==" "\n" |
69 | R"==(#define SRC0_BLOCK_READ(src) \ )==" "\n" |
70 | R"==(as_half(intel_sub_group_block_read_us((const __global ushort *)(src))) )==" "\n" |
71 | R"==(#define SRC0_BLOCK_READ2(src) \ )==" "\n" |
72 | R"==(as_half2(intel_sub_group_block_read_us2((const __global ushort *)(src))) )==" "\n" |
73 | R"==(#define SRC0_BLOCK_READ4(src) \ )==" "\n" |
74 | R"==(as_half4(intel_sub_group_block_read_us4((const __global ushort *)(src))) )==" "\n" |
75 | R"==(#define SRC0_BLOCK_READ8(src) \ )==" "\n" |
76 | R"==(as_half8(intel_sub_group_block_read_us8((const __global ushort *)(src))) )==" "\n" |
77 | R"==(#endif )==" "\n" |
78 | R"==(#if SRC1_DT_F16 )==" "\n" |
79 | R"==(#define SRC1_BLOCK_READ(src) \ )==" "\n" |
80 | R"==(as_half(intel_sub_group_block_read_us((const __global ushort *)(src))) )==" "\n" |
81 | R"==(#define SRC1_BLOCK_READ2(src) \ )==" "\n" |
82 | R"==(as_half2(intel_sub_group_block_read_us2((const __global ushort *)(src))) )==" "\n" |
83 | R"==(#define SRC1_BLOCK_READ4(src) \ )==" "\n" |
84 | R"==(as_half4(intel_sub_group_block_read_us4((const __global ushort *)(src))) )==" "\n" |
85 | R"==(#define SRC1_BLOCK_READ8(src) \ )==" "\n" |
86 | R"==(as_half8(intel_sub_group_block_read_us8((const __global ushort *)(src))) )==" "\n" |
87 | R"==(#endif )==" "\n" |
88 | R"==(#if SRC0_DT_S32 )==" "\n" |
89 | R"==(#define SRC0_BLOCK_READ(src) \ )==" "\n" |
90 | R"==(as_int(intel_sub_group_block_read((const __global uint *)(src))) )==" "\n" |
91 | R"==(#define SRC0_BLOCK_READ2(src) \ )==" "\n" |
92 | R"==(as_int2(intel_sub_group_block_read2((const __global uint *)(src))) )==" "\n" |
93 | R"==(#define SRC0_BLOCK_READ4(src) \ )==" "\n" |
94 | R"==(as_int4(intel_sub_group_block_read4((const __global uint *)(src))) )==" "\n" |
95 | R"==(#define SRC0_BLOCK_READ8(src) \ )==" "\n" |
96 | R"==(as_int8(intel_sub_group_block_read8((const __global uint *)(src))) )==" "\n" |
97 | R"==(#endif )==" "\n" |
98 | R"==(#if SRC1_DT_S32 )==" "\n" |
99 | R"==(#define SRC1_BLOCK_READ(src) \ )==" "\n" |
100 | R"==(as_int(intel_sub_group_block_read((const __global uint *)(src))) )==" "\n" |
101 | R"==(#define SRC1_BLOCK_READ2(src) \ )==" "\n" |
102 | R"==(as_int2(intel_sub_group_block_read2((const __global uint *)(src))) )==" "\n" |
103 | R"==(#define SRC1_BLOCK_READ4(src) \ )==" "\n" |
104 | R"==(as_int4(intel_sub_group_block_read4((const __global uint *)(src))) )==" "\n" |
105 | R"==(#define SRC1_BLOCK_READ8(src) \ )==" "\n" |
106 | R"==(as_int8(intel_sub_group_block_read8((const __global uint *)(src))) )==" "\n" |
107 | R"==(#endif )==" "\n" |
108 | R"==(#if SRC0_DT_F32 )==" "\n" |
109 | R"==(#define SRC0_BLOCK_READ(src) \ )==" "\n" |
110 | R"==(as_float(intel_sub_group_block_read((const __global uint *)(src))) )==" "\n" |
111 | R"==(#define SRC0_BLOCK_READ2(src) \ )==" "\n" |
112 | R"==(as_float2(intel_sub_group_block_read2((const __global uint *)(src))) )==" "\n" |
113 | R"==(#define SRC0_BLOCK_READ4(src) \ )==" "\n" |
114 | R"==(as_float4(intel_sub_group_block_read4((const __global uint *)(src))) )==" "\n" |
115 | R"==(#define SRC0_BLOCK_READ8(src) \ )==" "\n" |
116 | R"==(as_float8(intel_sub_group_block_read8((const __global uint *)(src))) )==" "\n" |
117 | R"==(#endif )==" "\n" |
118 | R"==(#if SRC1_DT_F32 )==" "\n" |
119 | R"==(#define SRC1_BLOCK_READ(src) \ )==" "\n" |
120 | R"==(as_float(intel_sub_group_block_read((const __global uint *)(src))) )==" "\n" |
121 | R"==(#define SRC1_BLOCK_READ2(src) \ )==" "\n" |
122 | R"==(as_float2(intel_sub_group_block_read2((const __global uint *)(src))) )==" "\n" |
123 | R"==(#define SRC1_BLOCK_READ4(src) \ )==" "\n" |
124 | R"==(as_float4(intel_sub_group_block_read4((const __global uint *)(src))) )==" "\n" |
125 | R"==(#define SRC1_BLOCK_READ8(src) \ )==" "\n" |
126 | R"==(as_float8(intel_sub_group_block_read8((const __global uint *)(src))) )==" "\n" |
127 | R"==(#endif )==" "\n" |
128 | R"==(#if SRC0_DT_BF16 )==" "\n" |
129 | R"==(#define SRC0_BLOCK_READ(src) \ )==" "\n" |
130 | R"==(as_ushort(intel_sub_group_block_read_us((const __global ushort *)(src))) )==" "\n" |
131 | R"==(#define SRC0_BLOCK_READ2(src) \ )==" "\n" |
132 | R"==(as_ushort2(intel_sub_group_block_read_us2((const __global ushort *)(src))) )==" "\n" |
133 | R"==(#define SRC0_BLOCK_READ4(src) \ )==" "\n" |
134 | R"==(as_ushort4(intel_sub_group_block_read_us4((const __global ushort *)(src))) )==" "\n" |
135 | R"==(#define SRC0_BLOCK_READ8(src) \ )==" "\n" |
136 | R"==(as_ushort8(intel_sub_group_block_read_us8((const __global ushort *)(src))) )==" "\n" |
137 | R"==(#endif )==" "\n" |
138 | R"==(#if SRC1_DT_BF16 )==" "\n" |
139 | R"==(#define SRC1_BLOCK_READ(src) \ )==" "\n" |
140 | R"==(as_ushort(intel_sub_group_block_read_us((const __global ushort *)(src))) )==" "\n" |
141 | R"==(#define SRC1_BLOCK_READ2(src) \ )==" "\n" |
142 | R"==(as_ushort2(intel_sub_group_block_read_us2((const __global ushort *)(src))) )==" "\n" |
143 | R"==(#define SRC1_BLOCK_READ4(src) \ )==" "\n" |
144 | R"==(as_ushort4(intel_sub_group_block_read_us4((const __global ushort *)(src))) )==" "\n" |
145 | R"==(#define SRC1_BLOCK_READ8(src) \ )==" "\n" |
146 | R"==(as_ushort8(intel_sub_group_block_read_us8((const __global ushort *)(src))) )==" "\n" |
147 | R"==(#endif )==" "\n" |
148 | R"==(#if DST_DT_S8 )==" "\n" |
149 | R"==(#define DST_BLOCK_READ(src) \ )==" "\n" |
150 | R"==(as_char(intel_sub_group_block_read_uc((const __global uchar *)(src))) )==" "\n" |
151 | R"==(#define DST_BLOCK_READ2(src) \ )==" "\n" |
152 | R"==(as_char2(intel_sub_group_block_read_uc2((const __global uchar *)(src))) )==" "\n" |
153 | R"==(#define DST_BLOCK_READ4(src) \ )==" "\n" |
154 | R"==(as_char4(intel_sub_group_block_read_uc4((const __global uchar *)(src))) )==" "\n" |
155 | R"==(#define DST_BLOCK_READ8(src) \ )==" "\n" |
156 | R"==(as_char8(intel_sub_group_block_read_uc8((const __global uchar *)(src))) )==" "\n" |
157 | R"==(#define DST_BLOCK_WRITE(dst, val) \ )==" "\n" |
158 | R"==(intel_sub_group_block_write_uc((__global uchar *)(dst), as_uchar(val)) )==" "\n" |
159 | R"==(#define DST_BLOCK_WRITE2(dst, val) \ )==" "\n" |
160 | R"==(intel_sub_group_block_write_uc2((__global uchar *)(dst), as_uchar2(val)) )==" "\n" |
161 | R"==(#define DST_BLOCK_WRITE4(dst, val) \ )==" "\n" |
162 | R"==(intel_sub_group_block_write_uc4((__global uchar *)(dst), as_uchar4(val)) )==" "\n" |
163 | R"==(#define DST_BLOCK_WRITE8(dst, val) \ )==" "\n" |
164 | R"==(intel_sub_group_block_write_uc8((__global uchar *)(dst), as_uchar8(val)) )==" "\n" |
165 | R"==(#endif )==" "\n" |
166 | R"==(#if DST_DT_U8 )==" "\n" |
167 | R"==(#define DST_BLOCK_READ(src) \ )==" "\n" |
168 | R"==(as_uchar(intel_sub_group_block_read_uc((const __global uchar *)(src))) )==" "\n" |
169 | R"==(#define DST_BLOCK_READ2(src) \ )==" "\n" |
170 | R"==(as_uchar2(intel_sub_group_block_read_uc2((const __global uchar *)(src))) )==" "\n" |
171 | R"==(#define DST_BLOCK_READ4(src) \ )==" "\n" |
172 | R"==(as_uchar4(intel_sub_group_block_read_uc4((const __global uchar *)(src))) )==" "\n" |
173 | R"==(#define DST_BLOCK_READ8(src) \ )==" "\n" |
174 | R"==(as_uchar8(intel_sub_group_block_read_uc8((const __global uchar *)(src))) )==" "\n" |
175 | R"==(#define DST_BLOCK_WRITE(dst, val) \ )==" "\n" |
176 | R"==(intel_sub_group_block_write_uc((__global uchar *)(dst), as_uchar(val)) )==" "\n" |
177 | R"==(#define DST_BLOCK_WRITE2(dst, val) \ )==" "\n" |
178 | R"==(intel_sub_group_block_write_uc2((__global uchar *)(dst), as_uchar2(val)) )==" "\n" |
179 | R"==(#define DST_BLOCK_WRITE4(dst, val) \ )==" "\n" |
180 | R"==(intel_sub_group_block_write_uc4((__global uchar *)(dst), as_uchar4(val)) )==" "\n" |
181 | R"==(#define DST_BLOCK_WRITE8(dst, val) \ )==" "\n" |
182 | R"==(intel_sub_group_block_write_uc8((__global uchar *)(dst), as_uchar8(val)) )==" "\n" |
183 | R"==(#endif )==" "\n" |
184 | R"==(#if DST_DT_F16 )==" "\n" |
185 | R"==(#define DST_BLOCK_READ(src) \ )==" "\n" |
186 | R"==(as_half(intel_sub_group_block_read_us((const __global ushort *)(src))) )==" "\n" |
187 | R"==(#define DST_BLOCK_READ2(src) \ )==" "\n" |
188 | R"==(as_half2(intel_sub_group_block_read_us2((const __global ushort *)(src))) )==" "\n" |
189 | R"==(#define DST_BLOCK_READ4(src) \ )==" "\n" |
190 | R"==(as_half4(intel_sub_group_block_read_us4((const __global ushort *)(src))) )==" "\n" |
191 | R"==(#define DST_BLOCK_READ8(src) \ )==" "\n" |
192 | R"==(as_half8(intel_sub_group_block_read_us8((const __global ushort *)(src))) )==" "\n" |
193 | R"==(#define DST_BLOCK_WRITE(dst, val) \ )==" "\n" |
194 | R"==(intel_sub_group_block_write_us((__global ushort *)(dst), as_ushort(val)) )==" "\n" |
195 | R"==(#define DST_BLOCK_WRITE2(dst, val) \ )==" "\n" |
196 | R"==(intel_sub_group_block_write_us2((__global ushort *)(dst), as_ushort2(val)) )==" "\n" |
197 | R"==(#define DST_BLOCK_WRITE4(dst, val) \ )==" "\n" |
198 | R"==(intel_sub_group_block_write_us4((__global ushort *)(dst), as_ushort4(val)) )==" "\n" |
199 | R"==(#define DST_BLOCK_WRITE8(dst, val) \ )==" "\n" |
200 | R"==(intel_sub_group_block_write_us8((__global ushort *)(dst), as_ushort8(val)) )==" "\n" |
201 | R"==(#endif )==" "\n" |
202 | R"==(#if DST_DT_S32 )==" "\n" |
203 | R"==(#define DST_BLOCK_READ(src) \ )==" "\n" |
204 | R"==(as_int(intel_sub_group_block_read((const __global uint *)(src))) )==" "\n" |
205 | R"==(#define DST_BLOCK_READ2(src) \ )==" "\n" |
206 | R"==(as_int2(intel_sub_group_block_read2((const __global uint *)(src))) )==" "\n" |
207 | R"==(#define DST_BLOCK_READ4(src) \ )==" "\n" |
208 | R"==(as_int4(intel_sub_group_block_read4((const __global uint *)(src))) )==" "\n" |
209 | R"==(#define DST_BLOCK_READ8(src) \ )==" "\n" |
210 | R"==(as_int8(intel_sub_group_block_read8((const __global uint *)(src))) )==" "\n" |
211 | R"==(#define DST_BLOCK_WRITE(dst, val) \ )==" "\n" |
212 | R"==(intel_sub_group_block_write((__global uint *)(dst), as_uint(val)) )==" "\n" |
213 | R"==(#define DST_BLOCK_WRITE2(dst, val) \ )==" "\n" |
214 | R"==(intel_sub_group_block_write2((__global uint *)(dst), as_uint2(val)) )==" "\n" |
215 | R"==(#define DST_BLOCK_WRITE4(dst, val) \ )==" "\n" |
216 | R"==(intel_sub_group_block_write4((__global uint *)(dst), as_uint4(val)) )==" "\n" |
217 | R"==(#define DST_BLOCK_WRITE8(dst, val) \ )==" "\n" |
218 | R"==(intel_sub_group_block_write8((__global uint *)(dst), as_uint8(val)) )==" "\n" |
219 | R"==(#endif )==" "\n" |
220 | R"==(#if DST_DT_F32 )==" "\n" |
221 | R"==(#define DST_BLOCK_READ(src) \ )==" "\n" |
222 | R"==(as_float(intel_sub_group_block_read((const __global uint *)(src))) )==" "\n" |
223 | R"==(#define DST_BLOCK_READ2(src) \ )==" "\n" |
224 | R"==(as_float2(intel_sub_group_block_read2((const __global uint *)(src))) )==" "\n" |
225 | R"==(#define DST_BLOCK_READ4(src) \ )==" "\n" |
226 | R"==(as_float4(intel_sub_group_block_read4((const __global uint *)(src))) )==" "\n" |
227 | R"==(#define DST_BLOCK_READ8(src) \ )==" "\n" |
228 | R"==(as_float8(intel_sub_group_block_read8((const __global uint *)(src))) )==" "\n" |
229 | R"==(#define DST_BLOCK_WRITE(dst, val) \ )==" "\n" |
230 | R"==(intel_sub_group_block_write((__global uint *)(dst), as_uint(val)) )==" "\n" |
231 | R"==(#define DST_BLOCK_WRITE2(dst, val) \ )==" "\n" |
232 | R"==(intel_sub_group_block_write2((__global uint *)(dst), as_uint2(val)) )==" "\n" |
233 | R"==(#define DST_BLOCK_WRITE4(dst, val) \ )==" "\n" |
234 | R"==(intel_sub_group_block_write4((__global uint *)(dst), as_uint4(val)) )==" "\n" |
235 | R"==(#define DST_BLOCK_WRITE8(dst, val) \ )==" "\n" |
236 | R"==(intel_sub_group_block_write8((__global uint *)(dst), as_uint8(val)) )==" "\n" |
237 | R"==(#endif )==" "\n" |
238 | R"==(#if DST_DT_BF16 )==" "\n" |
239 | R"==(#define DST_BLOCK_READ(src) \ )==" "\n" |
240 | R"==(as_ushort(intel_sub_group_block_read_us((const __global ushort *)(src))) )==" "\n" |
241 | R"==(#define DST_BLOCK_READ2(src) \ )==" "\n" |
242 | R"==(as_ushort2(intel_sub_group_block_read_us2((const __global ushort *)(src))) )==" "\n" |
243 | R"==(#define DST_BLOCK_READ4(src) \ )==" "\n" |
244 | R"==(as_ushort4(intel_sub_group_block_read_us4((const __global ushort *)(src))) )==" "\n" |
245 | R"==(#define DST_BLOCK_READ8(src) \ )==" "\n" |
246 | R"==(as_ushort8(intel_sub_group_block_read_us8((const __global ushort *)(src))) )==" "\n" |
247 | R"==(#define DST_BLOCK_WRITE(dst, val) \ )==" "\n" |
248 | R"==(intel_sub_group_block_write_us((__global ushort *)(dst), as_ushort(val)) )==" "\n" |
249 | R"==(#define DST_BLOCK_WRITE2(dst, val) \ )==" "\n" |
250 | R"==(intel_sub_group_block_write_us2((__global ushort *)(dst), as_ushort2(val)) )==" "\n" |
251 | R"==(#define DST_BLOCK_WRITE4(dst, val) \ )==" "\n" |
252 | R"==(intel_sub_group_block_write_us4((__global ushort *)(dst), as_ushort4(val)) )==" "\n" |
253 | R"==(#define DST_BLOCK_WRITE8(dst, val) \ )==" "\n" |
254 | R"==(intel_sub_group_block_write_us8((__global ushort *)(dst), as_ushort8(val)) )==" "\n" |
255 | R"==(#endif )==" "\n" |
256 | R"==(#if NVECT == 1 || IS_PLAIN_LAYOUT )==" "\n" |
257 | R"==(#define ELEM_DATA_T float )==" "\n" |
258 | R"==(#elif NVECT == 2 )==" "\n" |
259 | R"==(#define ELEM_DATA_T float2 )==" "\n" |
260 | R"==(#elif NVECT == 4 )==" "\n" |
261 | R"==(#define ELEM_DATA_T float4 )==" "\n" |
262 | R"==(#elif NVECT == 8 )==" "\n" |
263 | R"==(#define ELEM_DATA_T float8 )==" "\n" |
264 | R"==(#endif )==" "\n" |
265 | R"==(ELEM_DATA_T get_eltwise_op(ELEM_DATA_T src0, ELEM_DATA_T src1) { )==" "\n" |
266 | R"==(ELEM_DATA_T d = 0; )==" "\n" |
267 | R"==(#if IS_ADD )==" "\n" |
268 | R"==(d = src0 + src1; )==" "\n" |
269 | R"==(#elif IS_MUL )==" "\n" |
270 | R"==(d = src0 * src1; )==" "\n" |
271 | R"==(#elif IS_MAX )==" "\n" |
272 | R"==(d = max(src0, src1); )==" "\n" |
273 | R"==(#elif IS_MIN )==" "\n" |
274 | R"==(d = min(src0, src1); )==" "\n" |
275 | R"==(#elif IS_DIV )==" "\n" |
276 | R"==(d = src0 / src1; )==" "\n" |
277 | R"==(#elif IS_SUB )==" "\n" |
278 | R"==(d = src0 - src1; )==" "\n" |
279 | R"==(#elif IS_GE )==" "\n" |
280 | R"==(d = (src0 >= src1) ? 1.0f : 0.0f; )==" "\n" |
281 | R"==(#elif IS_GT )==" "\n" |
282 | R"==(d = (src0 > src1) ? 1.0f : 0.0f; )==" "\n" |
283 | R"==(#elif IS_LE )==" "\n" |
284 | R"==(d = (src0 <= src1) ? 1.0f : 0.0f; )==" "\n" |
285 | R"==(#elif IS_LT )==" "\n" |
286 | R"==(d = (src0 < src1) ? 1.0f : 0.0f; )==" "\n" |
287 | R"==(#elif IS_EQ )==" "\n" |
288 | R"==(d = (src0 == src1) ? 1.0f : 0.0f; )==" "\n" |
289 | R"==(#elif IS_NE )==" "\n" |
290 | R"==(d = (src0 != src1) ? 1.0f : 0.0f; )==" "\n" |
291 | R"==(#endif )==" "\n" |
292 | R"==(return d; )==" "\n" |
293 | R"==(} )==" "\n" |
294 | R"==(#define READ_DATA(size, name, source_ptr, dest_ptr, scale) \ )==" "\n" |
295 | R"==({ \ )==" "\n" |
296 | R"==(unsigned offset = 0; \ )==" "\n" |
297 | R"==(unroll_for(unsigned j8 = 0; j8 < size / 8; ++j8) { \ )==" "\n" |
298 | R"==(*((float8 *)(dest_ptr + offset)) = scale \ )==" "\n" |
299 | R"==(* CONVERT_FLOAT8_T(CONCAT2(name, _BLOCK_READ8)( \ )==" "\n" |
300 | R"==((source_ptr + offset * SUB_GROUP_SIZE))); \ )==" "\n" |
301 | R"==(offset += 8; \ )==" "\n" |
302 | R"==(} \ )==" "\n" |
303 | R"==(if ((size % 8) / 4) { \ )==" "\n" |
304 | R"==(*((float4 *)(dest_ptr + offset)) = scale \ )==" "\n" |
305 | R"==(* CONVERT_FLOAT4_T(CONCAT2(name, _BLOCK_READ4)( \ )==" "\n" |
306 | R"==((source_ptr + offset * SUB_GROUP_SIZE))); \ )==" "\n" |
307 | R"==(offset += 4; \ )==" "\n" |
308 | R"==(} \ )==" "\n" |
309 | R"==(if ((size % 4) / 2) { \ )==" "\n" |
310 | R"==(*((float2 *)(dest_ptr + offset)) = scale \ )==" "\n" |
311 | R"==(* CONVERT_FLOAT2_T(CONCAT2(name, _BLOCK_READ2)( \ )==" "\n" |
312 | R"==((source_ptr + offset * SUB_GROUP_SIZE))); \ )==" "\n" |
313 | R"==(offset += 2; \ )==" "\n" |
314 | R"==(} \ )==" "\n" |
315 | R"==(if ((size % 2)) { \ )==" "\n" |
316 | R"==(*((float *)(dest_ptr + offset)) = scale \ )==" "\n" |
317 | R"==(* CONVERT_FLOAT_T(CONCAT2(name, _BLOCK_READ)( \ )==" "\n" |
318 | R"==((source_ptr + offset * SUB_GROUP_SIZE))); \ )==" "\n" |
319 | R"==(} \ )==" "\n" |
320 | R"==(} )==" "\n" |
321 | R"==(#define WRITE_DATA(size, name, source_ptr, dest_ptr) \ )==" "\n" |
322 | R"==({ \ )==" "\n" |
323 | R"==(unsigned offset = 0; \ )==" "\n" |
324 | R"==(unroll_for(unsigned j8 = 0; j8 < size / 8; ++j8) { \ )==" "\n" |
325 | R"==(CONCAT2(name, _BLOCK_WRITE8) \ )==" "\n" |
326 | R"==(((dest_ptr + offset * SUB_GROUP_SIZE), \ )==" "\n" |
327 | R"==(TO_DST8(*((float8 *)(source_ptr + offset)))); \ )==" "\n" |
328 | R"==(offset += 8; \ )==" "\n" |
329 | R"==(} \ )==" "\n" |
330 | R"==(if ((size % 8) / 4) { \ )==" "\n" |
331 | R"==(CONCAT2(name, _BLOCK_WRITE4) \ )==" "\n" |
332 | R"==(((dest_ptr + offset * SUB_GROUP_SIZE), \ )==" "\n" |
333 | R"==(TO_DST4(*((float4 *)(source_ptr + offset)))); \ )==" "\n" |
334 | R"==(offset += 4; \ )==" "\n" |
335 | R"==(} \ )==" "\n" |
336 | R"==(if ((size % 4) / 2) { \ )==" "\n" |
337 | R"==(CONCAT2(name, _BLOCK_WRITE2) \ )==" "\n" |
338 | R"==(((dest_ptr + offset * SUB_GROUP_SIZE), \ )==" "\n" |
339 | R"==(TO_DST2(*((float2 *)(source_ptr + offset)))); \ )==" "\n" |
340 | R"==(offset += 2; \ )==" "\n" |
341 | R"==(} \ )==" "\n" |
342 | R"==(if ((size % 2)) { \ )==" "\n" |
343 | R"==(CONCAT2(name, _BLOCK_WRITE) \ )==" "\n" |
344 | R"==(((dest_ptr + offset * SUB_GROUP_SIZE), \ )==" "\n" |
345 | R"==(TO_DST(*((float *)(source_ptr + offset)))); \ )==" "\n" |
346 | R"==(} \ )==" "\n" |
347 | R"==(} )==" "\n" |
348 | R"==(#endif )==" "\n" |
349 | R"==()==" ; |
350 | } |
351 | } |
352 | } |
353 | } |