Skip to content

[libclc] Route select through __clc_select #123647

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions libclc/clc/include/clc/relational/clc_select.h
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
#ifndef __CLC_RELATIONAL_CLC_SELECT_H__
#define __CLC_RELATIONAL_CLC_SELECT_H__

#if defined(CLC_CLSPV) || defined(CLC_SPIRV)
// clspv and spir-v targets provide their own OpenCL-compatible select
#define __clc_select select
#else

/* Duplciate these so we don't have to distribute utils.h */
#define __CLC_CONCAT(x, y) x##y
#define __CLC_XCONCAT(x, y) __CLC_CONCAT(x, y)

#define __CLC_BODY <clc/relational/clc_select.inc>
#define __CLC_SELECT_FN __clc_select

#define __CLC_BODY <clc/relational/clc_select_decl.inc>
#include <clc/math/gentype.inc>
#define __CLC_BODY <clc/relational/clc_select.inc>
#define __CLC_BODY <clc/relational/clc_select_decl.inc>
#include <clc/integer/gentype.inc>

#undef __CLC_SELECT_FN
#undef __CLC_CONCAT
#undef __CLC_XCONCAT

#endif

#endif // __CLC_RELATIONAL_CLC_SELECT_H__
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
#define __CLC_U_GENTYPE __CLC_XCONCAT(ushort, __CLC_VECSIZE)
#endif

_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE __clc_select(__CLC_GENTYPE x,
__CLC_GENTYPE y,
__CLC_S_GENTYPE z);
_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE __clc_select(__CLC_GENTYPE x,
__CLC_GENTYPE y,
__CLC_U_GENTYPE z);
_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE __CLC_SELECT_FN(__CLC_GENTYPE x,
__CLC_GENTYPE y,
__CLC_S_GENTYPE z);
_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE __CLC_SELECT_FN(__CLC_GENTYPE x,
__CLC_GENTYPE y,
__CLC_U_GENTYPE z);

#ifdef __CLC_FPSIZE
#undef __CLC_S_GENTYPE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
#define __CLC_U_GENTYPE __CLC_XCONCAT(ushort, __CLC_VECSIZE)
#endif

_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_select(__CLC_GENTYPE x,
__CLC_GENTYPE y,
__CLC_S_GENTYPE z) {
return z ? y : x;
_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __CLC_SELECT_FN(__CLC_GENTYPE x,
__CLC_GENTYPE y,
__CLC_S_GENTYPE z) {
__CLC_SELECT_DEF(x, y, z);
}

_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_select(__CLC_GENTYPE x,
__CLC_GENTYPE y,
__CLC_U_GENTYPE z) {
return z ? y : x;
_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __CLC_SELECT_FN(__CLC_GENTYPE x,
__CLC_GENTYPE y,
__CLC_U_GENTYPE z) {
__CLC_SELECT_DEF(x, y, z);
}

#ifdef __CLC_FPSIZE
Expand Down
1 change: 1 addition & 0 deletions libclc/clc/lib/clspv/SOURCES
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
../generic/math/clc_mad.cl
../generic/math/clc_rint.cl
../generic/math/clc_trunc.cl
../generic/relational/clc_select.cl
../generic/shared/clc_clamp.cl
7 changes: 5 additions & 2 deletions libclc/clc/lib/generic/relational/clc_select.cl
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#include <clc/internal/clc.h>
#include <clc/utils.h>

#define __CLC_BODY <clc_select.inc>
#define __CLC_SELECT_FN __clc_select
#define __CLC_SELECT_DEF(x, y, z) return z ? y : x

#define __CLC_BODY <clc/relational/clc_select_impl.inc>
#include <clc/math/gentype.inc>
#define __CLC_BODY <clc_select.inc>
#define __CLC_BODY <clc/relational/clc_select_impl.inc>
#include <clc/integer/gentype.inc>
1 change: 1 addition & 0 deletions libclc/clc/lib/spirv/SOURCES
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
../generic/math/clc_mad.cl
../generic/math/clc_rint.cl
../generic/math/clc_trunc.cl
../generic/relational/clc_select.cl
../generic/shared/clc_clamp.cl
1 change: 1 addition & 0 deletions libclc/clc/lib/spirv64/SOURCES
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
../generic/math/clc_mad.cl
../generic/math/clc_rint.cl
../generic/math/clc_trunc.cl
../generic/relational/clc_select.cl
../generic/shared/clc_clamp.cl
7 changes: 5 additions & 2 deletions libclc/generic/include/clc/relational/select.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
#define __CLC_CONCAT(x, y) x ## y
#define __CLC_XCONCAT(x, y) __CLC_CONCAT(x, y)

#define __CLC_BODY <clc/relational/select.inc>
#define __CLC_SELECT_FN select

#define __CLC_BODY <clc/relational/clc_select_decl.inc>
#include <clc/math/gentype.inc>
#define __CLC_BODY <clc/relational/select.inc>
#define __CLC_BODY <clc/relational/clc_select_decl.inc>
#include <clc/integer/gentype.inc>

#undef __CLC_SELECT_FN
#undef __CLC_CONCAT
#undef __CLC_XCONCAT
25 changes: 0 additions & 25 deletions libclc/generic/include/clc/relational/select.inc

This file was deleted.

8 changes: 6 additions & 2 deletions libclc/generic/lib/relational/select.cl
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
#include <clc/clc.h>
#include <clc/relational/clc_select.h>
#include <clc/utils.h>

#define __CLC_BODY <select.inc>
#define __CLC_SELECT_FN select
#define __CLC_SELECT_DEF(x, y, z) return __clc_select(x, y, z)

#define __CLC_BODY <clc/relational/clc_select_impl.inc>
#include <clc/math/gentype.inc>
#define __CLC_BODY <select.inc>
#define __CLC_BODY <clc/relational/clc_select_impl.inc>
#include <clc/integer/gentype.inc>
33 changes: 0 additions & 33 deletions libclc/generic/lib/relational/select.inc

This file was deleted.

Loading