Skip to content

Commit 8a44553

Browse files
authored
[SYCL] Fix assertion failure in E2E marray test (#14234)
This PR fixes a GPU accuracy bug by upscaling the error-tolerance to a double type if the GPU supports 64-bit floating point arithmetic.
1 parent fd00434 commit 8a44553

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

sycl/test-e2e/Basic/built-ins/helpers.hpp

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,28 @@ void test(bool CheckDevice, double delta, FuncTy F, ExpectedTy Expected,
3333

3434
sycl::buffer<bool, 1> SuccessBuf{1};
3535

36+
sycl::queue q;
37+
sycl::device dev = q.get_device();
3638
// Make sure we don't use fp64 on devices that don't support it.
37-
sycl::detail::get_elem_type_t<ExpectedTy> d(delta);
38-
39-
sycl::queue{}.submit([&](sycl::handler &cgh) {
39+
const bool fp64 = dev.has(sycl::aspect::fp64);
40+
q.submit([&](sycl::handler &cgh) {
4041
sycl::accessor Success{SuccessBuf, cgh};
41-
cgh.single_task([=]() {
42-
auto R = F(Args...);
43-
static_assert(std::is_same_v<decltype(Expected), decltype(R)>);
44-
Success[0] = equal(R, Expected, d);
45-
});
42+
if (fp64) {
43+
cgh.single_task([=]() {
44+
auto R = F(Args...);
45+
static_assert(std::is_same_v<decltype(Expected), decltype(R)>);
46+
// use double precision error tolerance when fp64 supported
47+
Success[0] = equal(R, Expected, delta);
48+
});
49+
} else {
50+
// downscale the error tolerance when fp64 is not supported
51+
sycl::detail::get_elem_type_t<ExpectedTy> d(delta);
52+
cgh.single_task([=]() {
53+
auto R = F(Args...);
54+
static_assert(std::is_same_v<decltype(Expected), decltype(R)>);
55+
Success[0] = equal(R, Expected, d);
56+
});
57+
}
4658
});
4759
assert(sycl::host_accessor{SuccessBuf}[0]);
4860
}

0 commit comments

Comments
 (0)