Skip to content

Commit

Permalink
[SYCL][ESIMD][E2E] Fix LSC USM store test failure (#16122)
Browse files Browse the repository at this point in the history
`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 <[email protected]>
  • Loading branch information
sarnex authored Nov 20, 2024
1 parent 42e63c1 commit 9e3aabf
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion sycl/test-e2e/ESIMD/lsc/Inputs/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#pragma once

#include <limits>
#include <stdlib.h>
#include <sycl/bit_cast.hpp>

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

0 comments on commit 9e3aabf

Please sign in to comment.