Skip to content
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

[FEA]: Improve thrust::complex compile time throughput #486

Closed
1 task done
miscco opened this issue Sep 26, 2023 · 0 comments · Fixed by #567
Closed
1 task done

[FEA]: Improve thrust::complex compile time throughput #486

miscco opened this issue Sep 26, 2023 · 0 comments · Fixed by #567
Labels
feature request New feature or request. good first issue Good for newcomers. help wanted Request for input or help from the community thrust For all items related to Thrust.

Comments

@miscco
Copy link
Collaborator

miscco commented Sep 26, 2023

Is this a duplicate?

Area

Thrust

Is your feature request related to a problem? Please describe.

thrust::complex has an extended API surface compared to cuda::std::complex

The implementation of those additional operators / features has aged a bit and can be improved:

template <typename T0, typename T1>
__host__ __device__ typename detail::disable_if<
  detail::or_<detail::is_same<T0, T1>, detail::not_<detail::is_arithmetic<T1>>>::value,
  complex<typename detail::promoted_numerical_type<T0, T1>::type>>::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(), T(y.imag()));
}

This requires us to instantiate is_same and is_arithmetic and promoted_numerical_type even if the first constraint is not true

Describe the solution you'd like

We can avoid extensive instantiations by moving the constraints into the template arguments:

  template <typename T0, typename T1, 
            typename = typename detail::enable_if<detail::not_<detail::is_same<T0, T1>>::value>::type,
            typename = typename detail::enable_if<detail::is_arithmetic<T1>>::value>::type,
            typename = typename detail::enable_if<detail::has_promoted_numerical_type<T0, T1>::value>::type,
>
  __host__ __device__
  complex<typename detail::promoted_numerical_type<T0, T1>::type> &operator=(const U &rhs)
  {
    typedef typename detail::promoted_numerical_type<T0, T1>::type T;
    return complex<T>(x + y.real(), T(y.imag()));
  }

This would short circuit relatively early

Describe alternatives you've considered

No response

Additional context

No response

@miscco miscco added feature request New feature or request. good first issue Good for newcomers. thrust For all items related to Thrust. help wanted Request for input or help from the community labels Sep 26, 2023
elstehle pushed a commit to elstehle/cccl that referenced this issue Nov 16, 2023
Previous link points at empty page as cppreference documentation was merged with the page for std::counting_semaphore.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request. good first issue Good for newcomers. help wanted Request for input or help from the community thrust For all items related to Thrust.
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant