11// This test checks edge cases handling for std::exp(std::complex<T>) used
22// in SYCL kernels.
3- //
4- // REQUIRES: aspect-fp64
5- // UNSUPPORTED: hip || cuda
6- //
7- // RUN: %{build} -o %t.out
8- // RUN: %{run} %t.out
93
104#include < sycl/detail/core.hpp>
115
126#include < cmath>
137#include < complex>
14- #include < set>
158
169bool check (bool cond, const std::string &cond_str, int line,
1710 unsigned testcase) {
@@ -203,12 +196,14 @@ template <typename T> bool test() {
203196
204197 constexpr unsigned N = sizeof (testcases) / sizeof (testcases[0 ]);
205198
199+ sycl::buffer<std::complex <T>> data (testcases, sycl::range{N});
206200 sycl::buffer<std::complex <T>> results (sycl::range{N});
207201
208202 q.submit ([&](sycl::handler &cgh) {
203+ sycl::accessor acc_data (data, cgh, sycl::read_only);
209204 sycl::accessor acc (results, cgh, sycl::write_only);
210205 cgh.parallel_for (sycl::range{N}, [=](sycl::item<1 > it) {
211- acc[it] = std::exp (testcases [it]);
206+ acc[it] = std::exp (acc_data [it]);
212207 });
213208 }).wait_and_throw ();
214209
@@ -227,7 +222,8 @@ template <typename T> bool test() {
227222 for (unsigned i = 0 ; i < N; ++i) {
228223 std::complex <T> r = acc[i];
229224 // If z is (+/-0, +0), the result is (1, +0)
230- if (testcases[i].real () == 0 && testcases[i].imag () == 0 ) {
225+ if (testcases[i].real () == 0 && testcases[i].imag () == 0 &&
226+ !std::signbit (testcases[i].imag ())) {
231227 CHECK (r.real () == 1.0 , passed, i);
232228 CHECK (r.imag () == 0 , passed, i);
233229 CHECK (std::signbit (testcases[i].imag ()) == std::signbit (r.imag ()),
@@ -294,8 +290,13 @@ template <typename T> bool test() {
294290 } else if (std::isfinite (testcases[i].imag ()) &&
295291 std::abs (testcases[i].imag ()) <= 1 ) {
296292 CHECK (!std::signbit (r.real ()), passed, i);
293+ // TODO: This case fails on win. Need to investigate and remove this macro
294+ // check.
295+ // CMPLRLLVM-62905
296+ #ifndef _WIN32
297297 CHECK (std::signbit (r.imag ()) == std::signbit (testcases[i].imag ()),
298298 passed, i);
299+ #endif
299300 // Those tests were taken from oneDPL, not sure what is the corner case
300301 // they are covering here
301302 } else if (std::isinf (r.real ()) && testcases[i].imag () == 0 ) {
0 commit comments