Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions libdevice/fallback-complex-fp64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,8 @@ double __complex__ __devicelib_cacos(double __complex__ z) {
return CMPLX(z_real, -z_imag);
return CMPLX(z_real, z_real);
}
if (__spirv_IsInf(z_real))
return CMPLX(__pi / 2.0, -z_real);
if (__spirv_IsInf(z_imag))
return CMPLX(__pi / 2.0, -z_imag);
if (z_real == 0 && (z_imag == 0 || __spirv_IsNan(z_imag)))
return CMPLX(__pi / 2.0, -z_imag);
double __complex__ w =
Expand Down
39 changes: 39 additions & 0 deletions sycl/test-e2e/Regression/acos.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// REQUIRES: aspect-fp64
// UNSUPPORTED: cuda || hip

// RUN: %{build} -o %t.out
// RUN: %{run} %t.out
#include <complex>
#include <sycl/detail/core.hpp>
#include <sycl/usm.hpp>

using namespace sycl;
using T = std::complex<double>;

int main() {
queue q;
const double pi = std::atan2(+0., -0.);
T data[][2] = {{{-2, -INFINITY}, {pi / 2, INFINITY}},
{{-0., INFINITY}, {pi / 2, -INFINITY}}};
int N = std::size(data);
auto *p = malloc_shared<T>(N, q);

q.single_task([=] {
for (int i = 0; i < N; ++i) {
p[i] = std::acos(data[i][0]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: we do not guarantee that std::acos works in kernels. But we should be supporting ::cacos according to our docs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, it seems we are still testing the std::complex math functions in our testing though: https://github.com/intel/llvm/blob/sycl/sycl/test-e2e/DeviceLib/std_complex_math_fp64_test.cpp

}
}).wait();

int fails = 0;
for (int i = 0; i < N; ++i) {
auto actual = p[i];
auto expected = data[i][1];
if (expected != actual) {
std::cout << i << " fail:"
<< "expected = " << expected << ", actual = " << actual << "\n";
++fails;
}
}

return fails;
}