Skip to content

Commit eaf3e1b

Browse files
authored
[libclc] Route int bitselect through CLC; add half (#123653)
The half variants were missing. The integer bitselect builtins weren't going through __clc_bitselect due to an oversight when the CLC version was introduced.
1 parent d96ec48 commit eaf3e1b

File tree

3 files changed

+17
-28
lines changed

3 files changed

+17
-28
lines changed

libclc/clc/lib/generic/relational/clc_bitselect.cl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,15 @@ FLOAT_BITSELECT(double, ulong, 8)
5353
FLOAT_BITSELECT(double, ulong, 16)
5454

5555
#endif
56+
57+
#ifdef cl_khr_fp16
58+
#pragma OPENCL EXTENSION cl_khr_fp16 : enable
59+
60+
FLOAT_BITSELECT(half, ushort, )
61+
FLOAT_BITSELECT(half, ushort, 2)
62+
FLOAT_BITSELECT(half, ushort, 3)
63+
FLOAT_BITSELECT(half, ushort, 4)
64+
FLOAT_BITSELECT(half, ushort, 8)
65+
FLOAT_BITSELECT(half, ushort, 16)
66+
67+
#endif

libclc/generic/lib/relational/bitselect.cl

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -21,34 +21,10 @@
2121
*/
2222

2323
#include <clc/clc.h>
24-
#include <clc/clcmacro.h>
2524
#include <clc/relational/clc_bitselect.h>
2625

2726
#define __CLC_BODY <bitselect.inc>
2827
#include <clc/integer/gentype.inc>
29-
#undef __CLC_BODY
3028

31-
#define FLOAT_BITSELECT(f_type, i_type, width) \
32-
_CLC_OVERLOAD _CLC_DEF f_type##width bitselect( \
33-
f_type##width x, f_type##width y, f_type##width z) { \
34-
return __clc_bitselect(x, y, z); \
35-
}
36-
37-
FLOAT_BITSELECT(float, uint, )
38-
FLOAT_BITSELECT(float, uint, 2)
39-
FLOAT_BITSELECT(float, uint, 3)
40-
FLOAT_BITSELECT(float, uint, 4)
41-
FLOAT_BITSELECT(float, uint, 8)
42-
FLOAT_BITSELECT(float, uint, 16)
43-
44-
#ifdef cl_khr_fp64
45-
#pragma OPENCL EXTENSION cl_khr_fp64 : enable
46-
47-
FLOAT_BITSELECT(double, ulong, )
48-
FLOAT_BITSELECT(double, ulong, 2)
49-
FLOAT_BITSELECT(double, ulong, 3)
50-
FLOAT_BITSELECT(double, ulong, 4)
51-
FLOAT_BITSELECT(double, ulong, 8)
52-
FLOAT_BITSELECT(double, ulong, 16)
53-
54-
#endif
29+
#define __CLC_BODY <bitselect.inc>
30+
#include <clc/math/gentype.inc>

libclc/generic/lib/relational/bitselect.inc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
* THE SOFTWARE.
2121
*/
2222

23-
_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE bitselect(__CLC_GENTYPE x, __CLC_GENTYPE y, __CLC_GENTYPE z) {
24-
return ((x) ^ ((z) & ((y) ^ (x))));
23+
_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE bitselect(__CLC_GENTYPE x, __CLC_GENTYPE y,
24+
__CLC_GENTYPE z) {
25+
return __clc_bitselect(x, y, z);
2526
}

0 commit comments

Comments
 (0)