File: select.cl

package info (click to toggle)
intel-graphics-compiler 1.0.12504.6-1%2Bdeb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 83,912 kB
  • sloc: cpp: 910,147; lisp: 202,655; ansic: 15,197; python: 4,025; yacc: 2,241; lex: 1,570; pascal: 244; sh: 104; makefile: 25
file content (271 lines) | stat: -rw-r--r-- 8,106 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
/*========================== begin_copyright_notice ============================

Copyright (C) 2017-2021 Intel Corporation

SPDX-License-Identifier: MIT

============================= end_copyright_notice ===========================*/

#include "../include/BiF_Definitions.cl"
#include "spirv.h"

INLINE char OVERLOADABLE select( char a, char b, char c )
{
    return SPIRV_OCL_BUILTIN(select, _i8_i8_i8, )( a, b, c );
}

static INLINE char OVERLOADABLE __intel_vector_select_helper( char a, char b, char c )
{
    return c < 0 ? b : a;
}

INLINE char OVERLOADABLE select( char a, char b, uchar c )
{
    return SPIRV_OCL_BUILTIN(select, _i8_i8_i8, )( a, b, as_char(c) );
}

static INLINE char OVERLOADABLE __intel_vector_select_helper( char a, char b, uchar c )
{
    return as_char(c) < 0 ? b : a;
}

INLINE uchar OVERLOADABLE select( uchar a, uchar b, char c )
{
    return SPIRV_OCL_BUILTIN(select, _i8_i8_i8, )( as_char(a), as_char(b), c );
}

static INLINE uchar OVERLOADABLE __intel_vector_select_helper( uchar a, uchar b, char c )
{
    return c < 0 ? b : a;
}

INLINE uchar OVERLOADABLE select( uchar a, uchar b, uchar c )
{
    return SPIRV_OCL_BUILTIN(select, _i8_i8_i8, )( as_char(a), as_char(b), as_char(c) );
}

static INLINE uchar OVERLOADABLE __intel_vector_select_helper( uchar a, uchar b, uchar c )
{
    return as_char(c) < 0 ? b : a;
}

GENERATE_VECTOR_FUNCTIONS_3ARGS_SELECT( __intel_vector_select_helper, char, char )
GENERATE_VECTOR_FUNCTIONS_3ARGS_SELECT( __intel_vector_select_helper, char, uchar )
GENERATE_VECTOR_FUNCTIONS_3ARGS_SELECT( __intel_vector_select_helper, uchar, char )
GENERATE_VECTOR_FUNCTIONS_3ARGS_SELECT( __intel_vector_select_helper, uchar, uchar )


INLINE short OVERLOADABLE select( short a, short b, short c )
{
    return SPIRV_OCL_BUILTIN(select, _i16_i16_i16, )( a, b, c );
}

static INLINE short OVERLOADABLE __intel_vector_select_helper( short a, short b, short c )
{
    return c < 0 ? b : a;
}

INLINE short OVERLOADABLE select( short a, short b, ushort c )
{
    return SPIRV_OCL_BUILTIN(select, _i16_i16_i16, )( a, b, as_short(c) );
}

static INLINE short OVERLOADABLE __intel_vector_select_helper( short a, short b, ushort c )
{
    return as_short(c) < 0 ? b : a;
}

INLINE ushort OVERLOADABLE select( ushort a, ushort b, short c )
{
    return SPIRV_OCL_BUILTIN(select, _i16_i16_i16, )( as_short(a), as_short(b), c );
}

static INLINE ushort OVERLOADABLE __intel_vector_select_helper( ushort a, ushort b, short c )
{
    return c < 0 ? b : a;
}

INLINE ushort OVERLOADABLE select( ushort a, ushort b, ushort c )
{
    return SPIRV_OCL_BUILTIN(select, _i16_i16_i16, )( as_short(a), as_short(b), as_short(c) );
}

static INLINE ushort OVERLOADABLE __intel_vector_select_helper( ushort a, ushort b, ushort c )
{
    return as_short(c) < 0 ? b : a;
}

GENERATE_VECTOR_FUNCTIONS_3ARGS_SELECT( __intel_vector_select_helper, short, short )
GENERATE_VECTOR_FUNCTIONS_3ARGS_SELECT( __intel_vector_select_helper, short, ushort )
GENERATE_VECTOR_FUNCTIONS_3ARGS_SELECT( __intel_vector_select_helper, ushort, short )
GENERATE_VECTOR_FUNCTIONS_3ARGS_SELECT( __intel_vector_select_helper, ushort, ushort )


INLINE int OVERLOADABLE select( int a, int b, int c )
{
    return SPIRV_OCL_BUILTIN(select, _i32_i32_i32, )( a, b, c );
}

static INLINE int OVERLOADABLE __intel_vector_select_helper( int a, int b, int c )
{
    return c < 0 ? b : a;
}

INLINE int OVERLOADABLE select( int a, int b, uint c )
{
    return SPIRV_OCL_BUILTIN(select, _i32_i32_i32, )( a, b, as_int(c) );
}

static INLINE int OVERLOADABLE __intel_vector_select_helper( int a, int b, uint c )
{
    return as_int(c) < 0 ? b : a;
}

INLINE uint OVERLOADABLE select( uint a, uint b, int c )
{
    return SPIRV_OCL_BUILTIN(select, _i32_i32_i32, )( as_int(a), as_int(b), c );
}

static INLINE uint OVERLOADABLE __intel_vector_select_helper( uint a, uint b, int c )
{
    return c < 0 ? b : a;
}

INLINE uint OVERLOADABLE select( uint a, uint b, uint c )
{
    return SPIRV_OCL_BUILTIN(select, _i32_i32_i32, )( as_int(a), as_int(b), as_int(c) );
}

static INLINE uint OVERLOADABLE __intel_vector_select_helper( uint a, uint b, uint c )
{
    return as_int(c) < 0 ? b : a;
}

GENERATE_VECTOR_FUNCTIONS_3ARGS_SELECT( __intel_vector_select_helper, int, int )
GENERATE_VECTOR_FUNCTIONS_3ARGS_SELECT( __intel_vector_select_helper, int, uint )
GENERATE_VECTOR_FUNCTIONS_3ARGS_SELECT( __intel_vector_select_helper, uint, int )
GENERATE_VECTOR_FUNCTIONS_3ARGS_SELECT( __intel_vector_select_helper, uint, uint )


INLINE long OVERLOADABLE select( long a, long b, long c )
{
    return SPIRV_OCL_BUILTIN(select, _i64_i64_i64, )( a, b, c );
}

static INLINE long OVERLOADABLE __intel_vector_select_helper( long a, long b, long c )
{
    return c < 0 ? b : a;
}

INLINE long OVERLOADABLE select( long a, long b, ulong c )
{
    return SPIRV_OCL_BUILTIN(select, _i64_i64_i64, )( a, b, as_long(c) );
}

static INLINE long OVERLOADABLE __intel_vector_select_helper( long a, long b, ulong c )
{
    return as_long(c) < 0 ? b : a;
}

INLINE ulong OVERLOADABLE select( ulong a, ulong b, long c )
{
    return SPIRV_OCL_BUILTIN(select, _i64_i64_i64, )( as_long(a), as_long(b), c );
}

static INLINE ulong OVERLOADABLE __intel_vector_select_helper( ulong a, ulong b, long c )
{
    return c < 0 ? b : a;
}

INLINE ulong OVERLOADABLE select( ulong a, ulong b, ulong c )
{
    return SPIRV_OCL_BUILTIN(select, _i64_i64_i64, )( as_long(a), as_long(b), as_long(c) );
}

static INLINE ulong OVERLOADABLE __intel_vector_select_helper( ulong a, ulong b, ulong c )
{
    return as_long(c) < 0 ? b : a;
}

GENERATE_VECTOR_FUNCTIONS_3ARGS_SELECT( __intel_vector_select_helper, long, long )
GENERATE_VECTOR_FUNCTIONS_3ARGS_SELECT( __intel_vector_select_helper, long, ulong )
GENERATE_VECTOR_FUNCTIONS_3ARGS_SELECT( __intel_vector_select_helper, ulong, long )
GENERATE_VECTOR_FUNCTIONS_3ARGS_SELECT( __intel_vector_select_helper, ulong, ulong )


INLINE float OVERLOADABLE select( float a, float b, int c )
{
    return SPIRV_OCL_BUILTIN(select, _f32_f32_i32, )( a, b, c );
}

static INLINE float OVERLOADABLE __intel_vector_select_helper( float a, float b, int c )
{
    return c < 0 ? b : a;
}

INLINE float OVERLOADABLE select( float a, float b, uint c )
{
    return SPIRV_OCL_BUILTIN(select, _f32_f32_i32, )( a, b, c );
}

static INLINE float OVERLOADABLE __intel_vector_select_helper( float a, float b, uint c )
{
    return as_int(c) < 0 ? b : a;
}

GENERATE_VECTOR_FUNCTIONS_3ARGS_SELECT( __intel_vector_select_helper, float, int )
GENERATE_VECTOR_FUNCTIONS_3ARGS_SELECT( __intel_vector_select_helper, float, uint )

#if defined(cl_khr_fp64)

INLINE double OVERLOADABLE select( double a, double b, long c )
{
    return SPIRV_OCL_BUILTIN(select, _f64_f64_i64, )( a, b, c );
}

static INLINE double OVERLOADABLE __intel_vector_select_helper( double a, double b, long c )
{
    return c < 0 ? b : a;
}

INLINE double OVERLOADABLE select( double a, double b, ulong c )
{
    return SPIRV_OCL_BUILTIN(select, _f64_f64_i64, )( a, b, c );
}

static INLINE double OVERLOADABLE __intel_vector_select_helper( double a, double b, ulong c )
{
    return as_long(c) < 0 ? b : a;
}

GENERATE_VECTOR_FUNCTIONS_3ARGS_SELECT( __intel_vector_select_helper, double, long )
GENERATE_VECTOR_FUNCTIONS_3ARGS_SELECT( __intel_vector_select_helper, double, ulong )

#endif // defined(cl_khr_fp64)

#if defined(cl_khr_fp16)

INLINE half OVERLOADABLE select( half a, half b, short c )
{
    return SPIRV_OCL_BUILTIN(select, _f16_f16_i16, )( a, b, c );
}

static INLINE half OVERLOADABLE __intel_vector_select_helper( half a, half b, short c )
{
    return c < 0 ? b : a;
}

INLINE half OVERLOADABLE select( half a, half b, ushort c )
{
    return SPIRV_OCL_BUILTIN(select, _f16_f16_i16, )( a, b, as_short(c) );
}

static INLINE half OVERLOADABLE __intel_vector_select_helper( half a, half b, ushort c )
{
    return as_short(c) < 0 ? b : a;
}

GENERATE_VECTOR_FUNCTIONS_3ARGS_SELECT( __intel_vector_select_helper, half, short )
GENERATE_VECTOR_FUNCTIONS_3ARGS_SELECT( __intel_vector_select_helper, half, ushort )

#endif // defined(cl_khr_fp16)