Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 3 additions & 3 deletions libdevice/fallback-complex-fp64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@ double __complex__ __devicelib_cexp(double __complex__ z) {
return z;
else /* z_imag != 0.0 */
return CMPLX(NAN, NAN);
} else if (__spirv_IsFinite(z_real)) {
if (__spirv_IsNan(z_imag) || __spirv_IsInf(z_imag))
return CMPLX(NAN, NAN);
} else if (__spirv_IsFinite(z_real) &&
(__spirv_IsNan(z_imag) || __spirv_IsInf(z_imag))) {
return CMPLX(NAN, NAN);
}
double __e = __spirv_ocl_exp(z_real);
double ret_real = __e * __spirv_ocl_cos(z_imag);
Expand Down
10 changes: 8 additions & 2 deletions libdevice/fallback-complex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,14 @@ float __complex__ __devicelib_cexpf(float __complex__ z) {
z_imag = NAN;
return CMPLXF(z_real, z_imag);
}
} else if (__spirv_IsNan(z_real) && (z_imag == 0.0f)) {
return z;
} else if (__spirv_IsNan(z_real)) {
if (z_imag == 0.0f)
return z;
else /* z_imag != 0.0f */
return CMPLX(NAN, NAN);
} else if (__spirv_IsFinite(z_real) &&
(__spirv_IsNan(z_imag) || __spirv_IsInf(z_imag))) {
return CMPLX(NAN, NAN);
}
float __e = __spirv_ocl_exp(z_real);
float ret_real = __e * __spirv_ocl_cos(z_imag);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// This test checks edge cases handling for std::exp(std::complex<float>) used
// in SYCL kernels.
//
// UNSUPPORTED: hip || cuda
//
// RUN: %{build} -o %t.out
// RUN: %{run} %t.out

#include "exp-std-complex-edge-cases.hpp"

int main() { return test<float>(); }
Loading