Skip to content

[on hold] Replace thrust::complex by libcu++ - #3507

Closed
bernhardmgruber wants to merge 1 commit into
NVIDIA:mainfrom
bernhardmgruber:complex
Closed

bernhardmgruber wants to merge 1 commit into
NVIDIA:mainfrom
bernhardmgruber:complex

Conversation

@bernhardmgruber

Copy link
Copy Markdown
Contributor

No description provided.

@copy-pr-bot

copy-pr-bot Bot commented Jan 23, 2025

Copy link
Copy Markdown
Contributor

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@bernhardmgruber

Copy link
Copy Markdown
Contributor Author

Discussed with @miscco, apparently something similar was tried with #260 but abandoned. Later #454 tried to replace thrust complex partially, but it was reverted in #1497, because the numerical results did not work out. It seems cuda::std::complex still needs fixes.

@miscco

miscco commented Jan 23, 2025

Copy link
Copy Markdown
Contributor

The issue is more with the math functions than with anything else

@davebayer

Copy link
Copy Markdown
Contributor

I think the biggest problem is that thrust::complex is trivially default constructible, but cuda::std::complex is not.

The replacement could lead to some unexpected behaviour. An example:

thrust::complex<float> alloc(size_t n)
{
  return new thrust::complex<float>[n];
}

The old implementation does not zero initialize the allocated array, but when implemented by cuda::std::complex, it does.

This can have some serious performance consequences, e. g. for NUMA systems where the memory will be first touched by a single thread.

@miscco

miscco commented Feb 9, 2025

Copy link
Copy Markdown
Contributor

I think the biggest problem is that thrust::complex is trivially default constructible, but cuda::std::complex is not.

That is actually a quite important problem, as certain libraries require trivially_copyable types, for example rapids device_uvector

The long term solution that we want is a cuda::complex which effectively has all the functionality of cuda::std::complex but is just a plain aggregate. The issue there is that we would then need to duplicate all math functions because they need to take a cuda::std::complex and return a cuda::std::complex and cannot rely on e.g implicit conversion through inheritance

@bernhardmgruber bernhardmgruber changed the title Replace thrust::complex by libcu++ [on hold] Replace thrust::complex by libcu++ Mar 5, 2025
@github-project-automation github-project-automation Bot moved this from In Progress to Done in CCCL Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants