Skip to content

Commit fb7c8bd

Browse files
[SYCL] introduce precision mark to compare floating point numbers (#20317)
This PR fixes free function kernel test where class with virtual methods was used. It introduces precision value to compare two floating point values.
1 parent ee397f9 commit fb7c8bd

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

sycl/test-e2e/FreeFunctionKernels/virtual_methods.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* kernel arguments.
77
*/
88

9+
#include <cmath>
910
#include <iostream>
1011
#include <sycl/detail/core.hpp>
1112
#include <sycl/ext/oneapi/free_function_queries.hpp>
@@ -52,9 +53,10 @@ void func_single(TestClass *acc, float *ptr) {
5253
}
5354

5455
int check_result(float *ptr) {
56+
constexpr float diff_cmp = 1e-4f;
5557
for (size_t i = 0; i < NUM; ++i) {
5658
const float expected = 3.14f + static_cast<float>(i) + offset;
57-
if (ptr[i] != expected)
59+
if (std::fabs(ptr[i] - expected) > diff_cmp)
5860
return 1;
5961
}
6062
return 0;

0 commit comments

Comments
 (0)