Skip to content

Commit 6b24fdc

Browse files
[SYCL] Fix unintended use of fp64 math in complex maths (#6897)
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>
1 parent 4e5d276 commit 6b24fdc

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

sycl/include/sycl/ext/oneapi/experimental/sycl_complex.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,7 +1029,7 @@ _SYCL_EXT_CPLX_INLINE_VISIBILITY complex<_Tp> __sqr(const complex<_Tp> &__x) {
10291029

10301030
template <class _Tp, class = std::enable_if<is_gencomplex<_Tp>::value>>
10311031
SYCL_EXTERNAL complex<_Tp> asinh(const complex<_Tp> &__x) {
1032-
const _Tp __pi(sycl::atan2(+0., -0.));
1032+
const _Tp __pi(sycl::atan2(_Tp(+0.), _Tp(-0.)));
10331033
if (sycl::isinf(__x.real())) {
10341034
if (sycl::isnan(__x.imag()))
10351035
return __x;
@@ -1057,7 +1057,7 @@ SYCL_EXTERNAL complex<_Tp> asinh(const complex<_Tp> &__x) {
10571057

10581058
template <class _Tp, class = std::enable_if<is_gencomplex<_Tp>::value>>
10591059
SYCL_EXTERNAL complex<_Tp> acosh(const complex<_Tp> &__x) {
1060-
const _Tp __pi(sycl::atan2(+0., -0.));
1060+
const _Tp __pi(sycl::atan2(_Tp(+0.), _Tp(-0.)));
10611061
if (sycl::isinf(__x.real())) {
10621062
if (sycl::isnan(__x.imag()))
10631063
return complex<_Tp>(sycl::fabs(__x.real()), __x.imag());
@@ -1090,7 +1090,7 @@ SYCL_EXTERNAL complex<_Tp> acosh(const complex<_Tp> &__x) {
10901090

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

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

0 commit comments

Comments
 (0)