Skip to content

Enable __float128 in cuda::std::copysign and cuda::std::signbit#9991

Open
temujinkz wants to merge 1 commit into
NVIDIA:mainfrom
temujinkz:enable-float128-copysign-signbit
Open

Enable __float128 in cuda::std::copysign and cuda::std::signbit#9991
temujinkz wants to merge 1 commit into
NVIDIA:mainfrom
temujinkz:enable-float128-copysign-signbit

Conversation

@temujinkz

Copy link
Copy Markdown
Contributor

Adds __float128 support to cuda::std::copysign and test coverage for both copysign and signbit. Doing these two together since the signbit test generates its negative values through copysign.

copysign follows the same pattern as fabs in #9895: route to __builtin_copysignf128 when available, to __nv_fp128_copysign in device code otherwise, and keep the existing storage mask path as the constexpr fallback. signbit needed no implementation change, the generic sign mask path already handles binary128.

No __float128 capable host here (macOS arm64), so locally I could only compile and run both tests with float128 disabled to check for regressions. CI is the gate for the new paths.

Fixes #9961, fixes #9967

Signed-off-by: temujinkz <ttalkenov@gmail.com>
@temujinkz
temujinkz requested a review from a team as a code owner July 17, 2026 08:53
@temujinkz
temujinkz requested a review from gevtushenko July 17, 2026 08:53
@github-project-automation github-project-automation Bot moved this to Todo in CCCL Jul 17, 2026
@copy-pr-bot

copy-pr-bot Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@cccl-authenticator-app cccl-authenticator-app Bot moved this from Todo to In Review in CCCL Jul 17, 2026
@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes

    • Improved copysign handling for __float128 values across supported host and device environments.
    • Enhanced sign-bit processing for extended-precision floating-point values.
  • Tests

    • Added coverage for copysign and signbit operations using __float128 when available.

Walkthrough

Changes

Float128 math support

Layer / File(s) Summary
__float128 copysign dispatch
libcudacxx/include/cuda/std/__cmath/copysign.h
Adds guarded copysignf128 builtin and NV device-intrinsic paths for __float128, while retaining generic floating-point handling for other types.
Float128 validation
libcudacxx/test/libcudacxx/std/numerics/c.math/fp_manip/copysign.pass.cpp, libcudacxx/test/libcudacxx/std/numerics/c.math/fp_traits/signbit.pass.cpp
Adds guarded __float128 coverage to the copysign and signbit tests.

Assessment against linked issues

Objective Addressed Explanation
Enable __float128 in cuda::std::copysign [#9961]
Enable __float128 in cuda::std::signbit [#9967] Only test coverage changes are shown; no signbit implementation change is provided, so existing implementation support cannot be confirmed.

Suggested reviewers: gevtushenko


Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

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.

🧹 Nitpick comments (1)
libcudacxx/include/cuda/std/__cmath/copysign.h (1)

77-95: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

suggestion: Keep the preprocessor annotations identical to their controlling condition.

Line 80 uses #if defined(_CCCL_BUILTIN_COPYSIGNF128), but Lines 88 and 93 annotate a negated form. Repeat defined(_CCCL_BUILTIN_COPYSIGNF128) verbatim in both comments.

Based on learnings, annotated #else and #endif branches must repeat the exact condition text from the corresponding #if.

Source: Learnings


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 317e6c30-970e-4f59-b80c-0f98030a808d

📥 Commits

Reviewing files that changed from the base of the PR and between a129c6d and b7dbc5e.

📒 Files selected for processing (3)
  • libcudacxx/include/cuda/std/__cmath/copysign.h
  • libcudacxx/test/libcudacxx/std/numerics/c.math/fp_manip/copysign.pass.cpp
  • libcudacxx/test/libcudacxx/std/numerics/c.math/fp_traits/signbit.pass.cpp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Review

Development

Successfully merging this pull request may close these issues.

[FEA]: Enable __float128 in cuda::std::signbit [FEA]: Enable __float128 in cuda::std::copysign

1 participant