Skip to content

Commit

Permalink
[SYCL] Fix unintended use of fp64 math in complex maths (#6897)
Browse files Browse the repository at this point in the history
Select complex math operations unintentionally uses double-precision
floating point math in all variants of that builtin. This can cause
tests to fail on devices that do not support doubles. This commit fixes
these math operations.

Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
  • Loading branch information
steffenlarsen committed Oct 6, 2022
1 parent 4e5d276 commit 6b24fdc
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions sycl/include/sycl/ext/oneapi/experimental/sycl_complex.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1029,7 +1029,7 @@ _SYCL_EXT_CPLX_INLINE_VISIBILITY complex<_Tp> __sqr(const complex<_Tp> &__x) {

template <class _Tp, class = std::enable_if<is_gencomplex<_Tp>::value>>
SYCL_EXTERNAL complex<_Tp> asinh(const complex<_Tp> &__x) {
const _Tp __pi(sycl::atan2(+0., -0.));
const _Tp __pi(sycl::atan2(_Tp(+0.), _Tp(-0.)));
if (sycl::isinf(__x.real())) {
if (sycl::isnan(__x.imag()))
return __x;
Expand Down Expand Up @@ -1057,7 +1057,7 @@ SYCL_EXTERNAL complex<_Tp> asinh(const complex<_Tp> &__x) {

template <class _Tp, class = std::enable_if<is_gencomplex<_Tp>::value>>
SYCL_EXTERNAL complex<_Tp> acosh(const complex<_Tp> &__x) {
const _Tp __pi(sycl::atan2(+0., -0.));
const _Tp __pi(sycl::atan2(_Tp(+0.), _Tp(-0.)));
if (sycl::isinf(__x.real())) {
if (sycl::isnan(__x.imag()))
return complex<_Tp>(sycl::fabs(__x.real()), __x.imag());
Expand Down Expand Up @@ -1090,7 +1090,7 @@ SYCL_EXTERNAL complex<_Tp> acosh(const complex<_Tp> &__x) {

template <class _Tp, class = std::enable_if<is_gencomplex<_Tp>::value>>
SYCL_EXTERNAL complex<_Tp> atanh(const complex<_Tp> &__x) {
const _Tp __pi(sycl::atan2(+0., -0.));
const _Tp __pi(sycl::atan2(_Tp(+0.), _Tp(-0.)));
if (sycl::isinf(__x.imag())) {
return complex<_Tp>(sycl::copysign(_Tp(0), __x.real()),
sycl::copysign(__pi / _Tp(2), __x.imag()));
Expand Down Expand Up @@ -1180,7 +1180,7 @@ SYCL_EXTERNAL complex<_Tp> asin(const complex<_Tp> &__x) {

template <class _Tp, class = std::enable_if<is_gencomplex<_Tp>::value>>
SYCL_EXTERNAL complex<_Tp> acos(const complex<_Tp> &__x) {
const _Tp __pi(sycl::atan2(+0., -0.));
const _Tp __pi(sycl::atan2(_Tp(+0.), _Tp(-0.)));
if (sycl::isinf(__x.real())) {
if (sycl::isnan(__x.imag()))
return complex<_Tp>(__x.imag(), __x.real());
Expand Down

0 comments on commit 6b24fdc

Please sign in to comment.