From 9e3aabf45db24ee207b71774e4b550b939229d34 Mon Sep 17 00:00:00 2001 From: Nick Sarnie Date: Thu, 21 Nov 2024 06:29:14 +0900 Subject: [PATCH] [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 --- sycl/test-e2e/ESIMD/lsc/Inputs/common.hpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sycl/test-e2e/ESIMD/lsc/Inputs/common.hpp b/sycl/test-e2e/ESIMD/lsc/Inputs/common.hpp index 45c0a99840d93..661594d296e14 100644 --- a/sycl/test-e2e/ESIMD/lsc/Inputs/common.hpp +++ b/sycl/test-e2e/ESIMD/lsc/Inputs/common.hpp @@ -8,6 +8,7 @@ #pragma once +#include #include #include @@ -23,5 +24,7 @@ template T get_rand() { Tuint v = rand(); if constexpr (sizeof(Tuint) > 4) v = (v << 32) | rand(); - return sycl::bit_cast(v); + T bitcast_v = sycl::bit_cast(v); + return bitcast_v <= std::numeric_limits::epsilon() ? static_cast(0) + : bitcast_v; }