-
Notifications
You must be signed in to change notification settings - Fork 455
[Tile] Fix complex interop with extended floating point types #10550
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -120,11 +120,15 @@ class _CCCL_TYPE_VISIBILITY_DEFAULT _CCCL_ALIGNAS(alignof(__nv_bfloat162)) compl | |
| {} | ||
|
|
||
| # if !_CCCL_COMPILER(GCC, <, 10) // Old GCC considers those as deleted | ||
| _CCCL_EXEC_CHECK_DISABLE | ||
| _CCCL_HIDE_FROM_ABI complex(const complex&) noexcept = default; | ||
| _CCCL_HIDE_FROM_ABI complex(complex&&) noexcept = default; | ||
| _CCCL_EXEC_CHECK_DISABLE | ||
| _CCCL_HIDE_FROM_ABI complex(complex&&) noexcept = default; | ||
|
|
||
| _CCCL_EXEC_CHECK_DISABLE | ||
| _CCCL_HIDE_FROM_ABI complex& operator=(const complex&) noexcept = default; | ||
| _CCCL_HIDE_FROM_ABI complex& operator=(complex&&) noexcept = default; | ||
| _CCCL_EXEC_CHECK_DISABLE | ||
| _CCCL_HIDE_FROM_ABI complex& operator=(complex&&) noexcept = default; | ||
| # endif // !_CCCL_COMPILER(GCC, <, 10) | ||
|
|
||
| template <class _Up, enable_if_t<__cccl_internal::__is_non_narrowing_convertible<value_type, _Up>::value, int> = 0> | ||
|
|
@@ -276,6 +280,31 @@ _CCCL_HOST_DEVICE_API inline complex<double>& complex<double>::operator=(const c | |
| return *this; | ||
| } | ||
|
|
||
| [[nodiscard]] _CCCL_HOST_DEVICE_API inline __nv_bfloat16 real(const complex<__nv_bfloat16>& __c) noexcept | ||
| { | ||
| return __c.real(); | ||
| } | ||
| [[nodiscard]] _CCCL_HOST_DEVICE_API inline __nv_bfloat16 imag(const complex<__nv_bfloat16>& __c) noexcept | ||
| { | ||
| return __c.imag(); | ||
| } | ||
|
|
||
| [[nodiscard]] _CCCL_HOST_DEVICE_API inline complex<__nv_bfloat16> conj(const complex<__nv_bfloat16>& __c) | ||
| { | ||
| return complex<__nv_bfloat16>(__c.real(), ::__hneg(__c.imag())); | ||
| } | ||
|
|
||
| [[nodiscard]] _CCCL_HOST_DEVICE_API inline complex<__nv_bfloat16> proj(const complex<__nv_bfloat16>& __c) | ||
| { | ||
| complex<__nv_bfloat16> __r = __c; | ||
| if (::cuda::std::isinf(__c.real()) || ::cuda::std::isinf(__c.imag())) | ||
| { | ||
| __r = complex<__nv_bfloat16>( | ||
| numeric_limits<__nv_bfloat16>::infinity(), ::cuda::std::copysign(::__float2bfloat16(0.0f), __c.imag())); | ||
| } | ||
| return __r; | ||
| } | ||
|
Comment on lines
+292
to
+306
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win important: Make these non-throwing overloads
As per coding guidelines, “Functions that do not throw exceptions must be marked 📍 Affects 2 files
Source: Coding guidelines |
||
|
|
||
| template <> | ||
| struct __get_complex_impl<__nv_bfloat16> | ||
| { | ||
|
|
||
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.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: NVIDIA/cccl
Length of output: 16671
🏁 Script executed:
Repository: NVIDIA/cccl
Length of output: 13902
🏁 Script executed:
Repository: NVIDIA/cccl
Length of output: 20892
🏁 Script executed:
Repository: NVIDIA/cccl
Length of output: 7610
important: Replace these overload constraints with
_CCCL_TEMPLATE/_CCCL_REQUIRESto match the rest oflibcudacxx/include/cuda/std/__complex/complex.h; keep the implicit/explicit split and apply the same change to the assignment overloads below.Source: Coding guidelines