You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create clspv own convert.cl
This is needed as Vulkan SPIR-V does not respect the assumptions
needed to have the generic convert.cl compliant on many platforms.
It is needed because of the conversion of TYPE_MAX and
TYPE_MIN. Depending on the platform the behaviour can vary, but most
of them just do not convert correctly those 2 values.
Because of that, we also need to avoid having explicit function for
simple conversions because it allows llvm to optimise the code, thus
removing some of the added checks that are in fact needed.
Here are the differences between this new gen_convert.cl and the one in generic:
```
4a5
> # Copyright (c) 2023 Romaric Jodin <[email protected]>
144a146
> Copyright (c) 2023 Romaric Jodin <[email protected]>
254,257d255
< for src in types:
< for dst in types:
< generate_default_conversion(src, dst, "")
<
260a259,260
> if mode == "_rte":
> continue
310,311c310,311
< y = select(y, ({DST}{N}){DST_MIN}, {BP}(x < ({SRC}{N}){DST_MIN}){BS});
< y = select(y, ({DST}{N}){DST_MAX}, {BP}(x > ({SRC}{N}){DST_MAX}){BS});
---
> y = select(y, ({DST}{N}){DST_MIN}, {BP}(x <= ({SRC}{N}){DST_MIN}){BS});
> y = select(y, ({DST}{N}){DST_MAX}, {BP}(x >= ({SRC}{N}){DST_MAX}){BS});
435c435
< print(" {SRC}{N} y = convert_{SRC}{N}(r);".format(SRC=src, N=size))
---
> print(" {SRC}{N} y = convert_{SRC}{N}_sat(r);".format(SRC=src, N=size))
450a451,457
> print(" {BOOL}{N} c = convert_{BOOL}{N}(abs_y > abs_x);".format(BOOL=bool_type[dst], N=size))
> if sizeof_type[src] >= 4 and src in int_types:
> print(
> " c = c || convert_{BOOL}{N}(({SRC}{N}){SRC_MAX} == x);".format(
> BOOL=bool_type[dst], N=size, SRC=src, SRC_MAX=limit_max[src]
> )
> )
452,453c459,460
< " return select(r, nextafter(r, sign(r) * ({DST}{N})-INFINITY), convert_{BOOL}{N}(abs_y > abs_x));".format(
< DST=dst, N=size, BOOL=bool_type[dst]
---
> " return select(r, nextafter(r, sign(r) * ({DST}{N})-INFINITY), c);".format(
> DST=dst, N=size, BOOL=bool_type[dst], SRC=src
462a470,476
> print(" {BOOL}{N} c = convert_{BOOL}{N}(y > x);".format(BOOL=bool_type[dst], N=size))
> if sizeof_type[src] >= 4 and src in int_types:
> print(
> " c = c || convert_{BOOL}{N}(({SRC}{N}){SRC_MAX} == x);".format(
> BOOL=bool_type[dst], N=size, SRC=src, SRC_MAX=limit_max[src]
> )
> )
464,465c478,479
< " return select(r, nextafter(r, ({DST}{N})-INFINITY), convert_{BOOL}{N}(y > x));".format(
< DST=dst, N=size, BOOL=bool_type[dst]
---
> " return select(r, nextafter(r, ({DST}{N})-INFINITY), c);".format(
> DST=dst, N=size, BOOL=bool_type[dst], SRC=src
486a501,502
> if mode == "_rte":
> continue
```
0 commit comments