Skip to content

Commit 06490c6

Browse files
authored
[libspirv] Restore overloads of generic address space (#17214)
This adds some missing generic address space overloads of CLC functions: frexp, and whichever functions make use of the unary_def_with_(int_)?ptr.inc files. Note that this commit doesn't map the equivalent SPIR-V functions to these CLC implementations. This is because the generic SPIR-V implementation of FP16 types currently use the clang builtins as opposed to the software implementations. As discussed in #17163, this is not the proper behaviour for generic implementations, as not all targets support the builtins. In future work we will need to either provide target-specific overrides for the builtin implementations, or provide an easy mechanism by which the CLC implementations can select between builtins or software implementations automatically.
1 parent f957393 commit 06490c6

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

libclc/clc/include/clc/math/unary_def_with_int_ptr.inc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,10 @@ _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE FUNCTION(__CLC_GENTYPE x,
1818
local __CLC_INTN *iptr) {
1919
return __CLC_FUNCTION(FUNCTION)(x, iptr);
2020
}
21+
22+
#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED
23+
_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE FUNCTION(__CLC_GENTYPE x,
24+
generic __CLC_INTN *iptr) {
25+
return __CLC_FUNCTION(FUNCTION)(x, iptr);
26+
}
27+
#endif

libclc/clc/include/clc/math/unary_def_with_ptr.inc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,10 @@ _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE FUNCTION(__CLC_GENTYPE x,
1818
local __CLC_GENTYPE *ptr) {
1919
return __CLC_FUNCTION(FUNCTION)(x, ptr);
2020
}
21+
22+
#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED
23+
_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE FUNCTION(__CLC_GENTYPE x,
24+
generic __CLC_GENTYPE *ptr) {
25+
return __CLC_FUNCTION(FUNCTION)(x, ptr);
26+
}
27+
#endif

libclc/clc/lib/generic/math/clc_frexp.cl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,10 @@
4040
#define __CLC_ADDRESS_SPACE local
4141
#include <clc/math/gentype.inc>
4242
#undef __CLC_ADDRESS_SPACE
43+
44+
#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED
45+
#define __CLC_BODY <clc_frexp.inc>
46+
#define __CLC_ADDRESS_SPACE generic
47+
#include <clc/math/gentype.inc>
48+
#undef __CLC_ADDRESS_SPACE
49+
#endif

0 commit comments

Comments
 (0)