Skip to content

Commit 9e3aabf

Browse files
authored
[SYCL][ESIMD][E2E] Fix LSC USM store test failure (#16122)
`lsc_usm_store_u32.cpp` currently fails in syclos but passes in the internal compiler. The reason is that `rand` returns 0 and when `sycl::bit_cast` to `float`, it ends up as a very very small floating point number, like `1.4e-41`. In the internal compiler, this gets optimized to zero, probably due to unsafe fp math optimizations. It is also zero on-device. In syclos the host remains as that small number and ends up screwing up the correctness check because we need 0. Just explicitly return zero when the bit-casted result is below epsilon for the type. Signed-off-by: Sarnie, Nick <nick.sarnie@intel.com>
1 parent 42e63c1 commit 9e3aabf

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

sycl/test-e2e/ESIMD/lsc/Inputs/common.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#pragma once
1010

11+
#include <limits>
1112
#include <stdlib.h>
1213
#include <sycl/bit_cast.hpp>
1314

@@ -23,5 +24,7 @@ template <typename T> T get_rand() {
2324
Tuint v = rand();
2425
if constexpr (sizeof(Tuint) > 4)
2526
v = (v << 32) | rand();
26-
return sycl::bit_cast<T>(v);
27+
T bitcast_v = sycl::bit_cast<T>(v);
28+
return bitcast_v <= std::numeric_limits<T>::epsilon() ? static_cast<T>(0)
29+
: bitcast_v;
2730
}

0 commit comments

Comments
 (0)