Skip to content

Commit d96ec48

Browse files
authored
[libclc] Route select through __clc_select (#123647)
This was missed during the introduction of select. This also unifies the various .inc files used for each, as they were essentially identical. The __clc_select function is now also built for SPIR-V targets.
1 parent 7acad68 commit d96ec48

File tree

11 files changed

+38
-87
lines changed

11 files changed

+38
-87
lines changed
Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,19 @@
11
#ifndef __CLC_RELATIONAL_CLC_SELECT_H__
22
#define __CLC_RELATIONAL_CLC_SELECT_H__
33

4-
#if defined(CLC_CLSPV) || defined(CLC_SPIRV)
5-
// clspv and spir-v targets provide their own OpenCL-compatible select
6-
#define __clc_select select
7-
#else
8-
94
/* Duplciate these so we don't have to distribute utils.h */
105
#define __CLC_CONCAT(x, y) x##y
116
#define __CLC_XCONCAT(x, y) __CLC_CONCAT(x, y)
127

13-
#define __CLC_BODY <clc/relational/clc_select.inc>
8+
#define __CLC_SELECT_FN __clc_select
9+
10+
#define __CLC_BODY <clc/relational/clc_select_decl.inc>
1411
#include <clc/math/gentype.inc>
15-
#define __CLC_BODY <clc/relational/clc_select.inc>
12+
#define __CLC_BODY <clc/relational/clc_select_decl.inc>
1613
#include <clc/integer/gentype.inc>
1714

15+
#undef __CLC_SELECT_FN
1816
#undef __CLC_CONCAT
1917
#undef __CLC_XCONCAT
2018

21-
#endif
22-
2319
#endif // __CLC_RELATIONAL_CLC_SELECT_H__

libclc/clc/include/clc/relational/clc_select.inc renamed to libclc/clc/include/clc/relational/clc_select_decl.inc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
#define __CLC_U_GENTYPE __CLC_XCONCAT(ushort, __CLC_VECSIZE)
1414
#endif
1515

16-
_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE __clc_select(__CLC_GENTYPE x,
17-
__CLC_GENTYPE y,
18-
__CLC_S_GENTYPE z);
19-
_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE __clc_select(__CLC_GENTYPE x,
20-
__CLC_GENTYPE y,
21-
__CLC_U_GENTYPE z);
16+
_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE __CLC_SELECT_FN(__CLC_GENTYPE x,
17+
__CLC_GENTYPE y,
18+
__CLC_S_GENTYPE z);
19+
_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE __CLC_SELECT_FN(__CLC_GENTYPE x,
20+
__CLC_GENTYPE y,
21+
__CLC_U_GENTYPE z);
2222

2323
#ifdef __CLC_FPSIZE
2424
#undef __CLC_S_GENTYPE

libclc/clc/lib/generic/relational/clc_select.inc renamed to libclc/clc/include/clc/relational/clc_select_impl.inc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@
1313
#define __CLC_U_GENTYPE __CLC_XCONCAT(ushort, __CLC_VECSIZE)
1414
#endif
1515

16-
_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_select(__CLC_GENTYPE x,
17-
__CLC_GENTYPE y,
18-
__CLC_S_GENTYPE z) {
19-
return z ? y : x;
16+
_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __CLC_SELECT_FN(__CLC_GENTYPE x,
17+
__CLC_GENTYPE y,
18+
__CLC_S_GENTYPE z) {
19+
__CLC_SELECT_DEF(x, y, z);
2020
}
2121

22-
_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_select(__CLC_GENTYPE x,
23-
__CLC_GENTYPE y,
24-
__CLC_U_GENTYPE z) {
25-
return z ? y : x;
22+
_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __CLC_SELECT_FN(__CLC_GENTYPE x,
23+
__CLC_GENTYPE y,
24+
__CLC_U_GENTYPE z) {
25+
__CLC_SELECT_DEF(x, y, z);
2626
}
2727

2828
#ifdef __CLC_FPSIZE

libclc/clc/lib/clspv/SOURCES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44
../generic/math/clc_mad.cl
55
../generic/math/clc_rint.cl
66
../generic/math/clc_trunc.cl
7+
../generic/relational/clc_select.cl
78
../generic/shared/clc_clamp.cl
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
#include <clc/internal/clc.h>
22
#include <clc/utils.h>
33

4-
#define __CLC_BODY <clc_select.inc>
4+
#define __CLC_SELECT_FN __clc_select
5+
#define __CLC_SELECT_DEF(x, y, z) return z ? y : x
6+
7+
#define __CLC_BODY <clc/relational/clc_select_impl.inc>
58
#include <clc/math/gentype.inc>
6-
#define __CLC_BODY <clc_select.inc>
9+
#define __CLC_BODY <clc/relational/clc_select_impl.inc>
710
#include <clc/integer/gentype.inc>

libclc/clc/lib/spirv/SOURCES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@
88
../generic/math/clc_mad.cl
99
../generic/math/clc_rint.cl
1010
../generic/math/clc_trunc.cl
11+
../generic/relational/clc_select.cl
1112
../generic/shared/clc_clamp.cl

libclc/clc/lib/spirv64/SOURCES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@
88
../generic/math/clc_mad.cl
99
../generic/math/clc_rint.cl
1010
../generic/math/clc_trunc.cl
11+
../generic/relational/clc_select.cl
1112
../generic/shared/clc_clamp.cl

libclc/generic/include/clc/relational/select.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22
#define __CLC_CONCAT(x, y) x ## y
33
#define __CLC_XCONCAT(x, y) __CLC_CONCAT(x, y)
44

5-
#define __CLC_BODY <clc/relational/select.inc>
5+
#define __CLC_SELECT_FN select
6+
7+
#define __CLC_BODY <clc/relational/clc_select_decl.inc>
68
#include <clc/math/gentype.inc>
7-
#define __CLC_BODY <clc/relational/select.inc>
9+
#define __CLC_BODY <clc/relational/clc_select_decl.inc>
810
#include <clc/integer/gentype.inc>
911

12+
#undef __CLC_SELECT_FN
1013
#undef __CLC_CONCAT
1114
#undef __CLC_XCONCAT

libclc/generic/include/clc/relational/select.inc

Lines changed: 0 additions & 25 deletions
This file was deleted.
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
#include <clc/clc.h>
2+
#include <clc/relational/clc_select.h>
23
#include <clc/utils.h>
34

4-
#define __CLC_BODY <select.inc>
5+
#define __CLC_SELECT_FN select
6+
#define __CLC_SELECT_DEF(x, y, z) return __clc_select(x, y, z)
7+
8+
#define __CLC_BODY <clc/relational/clc_select_impl.inc>
59
#include <clc/math/gentype.inc>
6-
#define __CLC_BODY <select.inc>
10+
#define __CLC_BODY <clc/relational/clc_select_impl.inc>
711
#include <clc/integer/gentype.inc>

libclc/generic/lib/relational/select.inc

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)