Skip to content

Conversation

steffenlarsen
Copy link
Contributor

This commit replaces the uses of NAN and INFINITY in the SYCL complex headers with std::numeric_limits::quiet_NaN() and std::numeric_limits::infinity() respectively. This avoids issues where the definition of the macros could cause issues with differing constexpr'ness between platforms.

Fixes #19114.

This commit replaces the uses of NAN and INFINITY in the SYCL complex
headers with std::numeric_limits<float>::quiet_NaN() and
std::numeric_limits<float>::infinity() respectively. This avoids issues
where the definition of the macros could cause issues with differing
constexpr'ness between platforms.

Fixes intel#19114.

Signed-off-by: Larsen, Steffen <[email protected]>
Signed-off-by: Larsen, Steffen <[email protected]>
z = __SYCL_CMPLX((INFINITY * (__a * __c - __b * __d)),
(INFINITY * (__a * __d + __b * __c)));
z = __SYCL_CMPLX(
(std::numeric_limits<float>::infinity() * (__a * __c - __b * __d)),
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't this be std::numeric_limits<double> (instead of float)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The only cases I changed the type were the ones with an immediate cast after them. Though I could change it here, I am worried that there could be some unexpected changes in rounding as a result of that.

z_real = INFINITY * (__a * __c + __b * __d);
z_imag = INFINITY * (__b * __c - __a * __d);
z_real = std::numeric_limits<float>::infinity() * (__a * __c + __b * __d);
z_imag = std::numeric_limits<float>::infinity() * (__b * __c - __a * __d);
Copy link
Contributor

Choose a reason for hiding this comment

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

ibid. double instead float ?

return r;
}
__SYCL_DEVICE_C
double __complex__ cproj(double __complex__ z) {
double __complex__ r = z;
if (__spirv_IsInf(creal(z)) || __spirv_IsInf(cimag(z)))
r = __SYCL_CMPLX(INFINITY, __spirv_ocl_copysign(0.0, cimag(z)));
r = __SYCL_CMPLX(std::numeric_limits<float>::infinity(),
Copy link
Contributor

Choose a reason for hiding this comment

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

double again?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NAN is not constexpr anymore after <sycl/detail/core.hpp> is included
2 participants