Skip to content

Ensure cuda::std::complex is trivially copyable when possible#8356

Merged
miscco merged 1 commit intoNVIDIA:mainfrom
miscco:trivially_copyable_complex
Apr 10, 2026
Merged

Ensure cuda::std::complex is trivially copyable when possible#8356
miscco merged 1 commit intoNVIDIA:mainfrom
miscco:trivially_copyable_complex

Conversation

@miscco
Copy link
Copy Markdown
Contributor

@miscco miscco commented Apr 10, 2026

With C++23 std::complex has been changed to be trivially copyable

Adopt those changes for our implementations.

Unfortunately, we cannot make __half of __nv_bfloat16 work because we do not controll those

@miscco miscco requested a review from a team as a code owner April 10, 2026 09:22
@miscco miscco requested a review from ericniebler April 10, 2026 09:22
@github-project-automation github-project-automation bot moved this to Todo in CCCL Apr 10, 2026
@cccl-authenticator-app cccl-authenticator-app bot moved this from Todo to In Review in CCCL Apr 10, 2026
Comment on lines +84 to 88
_CCCL_API constexpr complex(const value_type& __re = value_type(),
const value_type& __im = value_type()) noexcept(is_nothrow_default_constructible_v<_Tp>)
: __re_(__re)
, __im_(__im)
{}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think the condition in noexcept is needed, see requirements on numeric types

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I want to be safe because users are users and may specialize accordingly

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

But that's UB:
The behavior is unspecified (and may fail to compile) if T is not a cv-unqualified standard(until C++23) floating-point type and undefined if T is not NumericType.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't have a strong opinion on that, but noexcept is what we expect by this type even if it is not strictly required

@github-actions

This comment has been minimized.

With C++23  `std::complex` has been changed to be trivially copyable

Adopt those changes for our implementations.

Unfortunately, we cannot make `__half` of `__nv_bfloat16` work because we do not controll those
@miscco miscco force-pushed the trivially_copyable_complex branch from 9edf945 to e9afc92 Compare April 10, 2026 11:07
@github-actions
Copy link
Copy Markdown
Contributor

🥳 CI Workflow Results

🟩 Finished in 1h 10m: Pass: 100%/108 | Total: 1d 11h | Max: 1h 01m | Hits: 93%/282032

See results here.

Comment on lines +84 to 88
_CCCL_API constexpr complex(const value_type& __re = value_type(),
const value_type& __im = value_type()) noexcept(is_nothrow_default_constructible_v<_Tp>)
: __re_(__re)
, __im_(__im)
{}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't have a strong opinion on that, but noexcept is what we expect by this type even if it is not strictly required

@miscco miscco merged commit 8ee46b0 into NVIDIA:main Apr 10, 2026
127 of 131 checks passed
@miscco miscco deleted the trivially_copyable_complex branch April 10, 2026 17:02
@github-project-automation github-project-automation bot moved this from In Review to Done in CCCL Apr 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