Skip to content

Commit 1457e00

Browse files
committed
[SYCL] Use union to do bitcast after bif removal in 8be6b10
1 parent 2816519 commit 1457e00

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

sycl/include/sycl/ext/oneapi/experimental/cuda/masked_shuffles.hpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,15 @@ namespace detail {
3939
mask, static_cast<int>(tmp_b16), shfl_param, c); \
4040
asm("mov.b16 %0,%1;" : "=h"(res) : "h"(static_cast<short>(tmp_b32))); \
4141
} else if constexpr (std::is_same_v<T, float>) { \
42-
auto tmp_b32 = __nvvm_shfl_sync_##SHUFFLE_INSTR( \
43-
mask, __nvvm_bitcast_f2i(val), shfl_param, c); \
44-
res = __nvvm_bitcast_i2f(tmp_b32); \
42+
union { \
43+
int i; \
44+
float f; \
45+
} u; \
46+
u.f = val; \
47+
auto tmp_b32 = \
48+
__nvvm_shfl_sync_##SHUFFLE_INSTR(mask, u.i, shfl_param, c); \
49+
u.i = tmp_b32; \
50+
res = u.f; \
4551
} else { \
4652
res = __nvvm_shfl_sync_##SHUFFLE_INSTR(mask, val, shfl_param, c); \
4753
} \

sycl/include/sycl/ext/oneapi/matrix/matrix-unified.hpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,12 @@ inline __SYCL_ALWAYS_INLINE float round_to_tf32(const float &a) {
580580
#if defined(__SYCL_DEVICE_ONLY__)
581581
#if defined(__NVPTX__)
582582
int32_t tmp_int = __nvvm_f2tf32_rna(a);
583-
return __nvvm_bitcast_i2f(tmp_int);
583+
union {
584+
int32_t i;
585+
float f;
586+
} u;
587+
u.i = tmp_int;
588+
return u.f;
584589
#else
585590
return __spirv_RoundFToTF32INTEL(a);
586591
#endif // defined(__NVPTX__)

0 commit comments

Comments
 (0)