-
Notifications
You must be signed in to change notification settings - Fork 798
[SYCL] Use numeric_limits instead of NAN And INFINITY macros #19852
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: sycl
Are you sure you want to change the base?
Conversation
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)), |
There was a problem hiding this comment.
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
)?
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
double
again?
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.