-
Notifications
You must be signed in to change notification settings - Fork 204
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
Replace thrust::complex
with cuda::std::complex
#260
Conversation
There are some notable differences though. thrust::complex has been a bit more lenient when determining the type of arithmetic operations. That said, I believe being more strict is actually a feature not a bug
@@ -1781,6 +1783,57 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const complex<_Tp>& __x) | |||
return __os << __s.str(); | |||
} | |||
#endif // !_LIBCUDACXX_HAS_NO_LOCALIZATION | |||
#else // ^^^ !__cuda_std__ ^^^ / vvv __cuda_std__ |
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.
Those changes might be controversial as we are pulling in quite some machinery. Thoughts?
thrust::complex
with std::complex
thrust::complex
with cuda::std::complex
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.
I've left a few comments on places that break API. I haven't covered all the changes, but I think that the comments should be applicable to the rest of them.
template <typename T0, typename T1> | ||
__host__ __device__ | ||
complex<typename detail::promoted_numerical_type<T0, T1>::type> | ||
operator-(const complex<T0>& x, const complex<T1>& y) | ||
{ | ||
typedef typename detail::promoted_numerical_type<T0, T1>::type T; | ||
return complex<T>(x.real() - y.real(), x.imag() - y.imag()); | ||
} |
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 following code used to work, but now it doesn't:
thrust::complex<float> a;
thrust::complex<double> b;
auto c = a + b;
I think we need to keep this overload and maybe mark it as deprecated. Same with other operators.
template <typename T0, typename T1> | ||
__host__ __device__ | ||
complex<typename detail::promoted_numerical_type<T0, T1>::type> | ||
operator+(const T0& x, const complex<T1>& y) | ||
{ | ||
typedef typename detail::promoted_numerical_type<T0, T1>::type T; | ||
return complex<T>(x + y.real(), y.imag()); | ||
} |
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 following code used to work, but now it doesn't:
float a = 84;
thrust::complex<double> b(42, 42);
auto c = a + b;
I think we need to keep this overload and maybe mark it as deprecated. Same with other operators.
// As std::hypot is only C++11 we have to use the C interface | ||
template <typename T> | ||
__host__ __device__ | ||
T abs(const complex<T>& z) |
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 following code used to work, now it doesn't:
thrust::complex<double> a;
auto b = thrust::abs(a);
|
||
template <typename T> | ||
__host__ __device__ | ||
T arg(const complex<T>& z) |
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 following code used to work, now it doesn't:
thrust::complex<double> a;
auto b = thrust::arg(a);
Dropping in favor of #454 |
There are some notable differences though. thrust::complex has been a
bit more lenient when determining the type of arithmetic operations.
That said, I believe being more strict is actually a feature not a bug