Skip to content

[libcu++] fpemu: drop the qualifier from the emulated int128 constructor - #12606

Open
0z5a wants to merge 1 commit into
NVIDIA:mainfrom
0z5a:fix/fpemu-emulated-int128-ctor
Open

0z5a wants to merge 1 commit into
NVIDIA:mainfrom
0z5a:fix/fpemu-emulated-int128-ctor

Conversation

@0z5a

@0z5a 0z5a commented Nov 11, 2026

Copy link
Copy Markdown

closes #12605

struct __fpemu_uint128 in cuda/__fp/fpemu_impl.h declared its default constructor as ::cuda::__fpemu_uint128() = default;. A qualified name is not valid for a constructor declared inside its class, so the emulated-int128 branch does not compile. NVRTC takes that branch whenever -device-int128 is not passed, which breaks #include <cuda/fpemu> with default NVRTC options. The qualifier came in with the promotion from cuda::experimental in #11956.

This PR drops the qualifier. It also adds fpemu/emulated_int128.pass.cpp, which defines _CCCL_FPEMU_FORCE_EMULATED_INT128 and runs the core.pass.cpp operations (mul, add, div, sub, fma). That way the emulated branch is built in CI; the NVRTC lane always passes -device-int128, so it never takes this branch today.

Checked locally:

  • The issue's snippet compiles with NVRTC 13.0.88, 13.3.33 and 13.5.37 without -device-int128 (it failed on all three before).
  • With nvcc 13.3 + GCC and _CCCL_FPEMU_FORCE_EMULATED_INT128, all tests in test/libcudacxx/cuda/fp/units/fpemu/ build and pass on the host.
  • The new test fails to compile before the change and passes after. I built it by hand with nvcc rather than through lit, and did not run the emulated path on a device.

Checklist:

  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

…uctor

`struct __fpemu_uint128` declared its default constructor as
`::cuda::__fpemu_uint128() = default;`. A qualified name is not valid
for a constructor declared inside its class, so the emulated branch of
fpemu_impl.h does not compile. NVRTC takes that branch whenever
-device-int128 is not passed, which breaks `#include <cuda/fpemu>` with
default NVRTC options.

Add a test that forces the emulated path with
_CCCL_FPEMU_FORCE_EMULATED_INT128 so the branch is built in CI.

Signed-off-by: 0z5a <dezhen.lu@student.uni-tuebingen.de>
@0z5a
0z5a requested a review from a team as a code owner November 11, 2026 22:35
@0z5a
0z5a requested a review from griwes November 11, 2026 22:35
@copy-pr-bot

copy-pr-bot Bot commented Nov 11, 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.

@github-project-automation github-project-automation Bot moved this to Todo in CCCL Nov 11, 2026
@cccl-authenticator-app cccl-authenticator-app Bot moved this from Todo to In Review in CCCL Nov 11, 2026
@coderabbitai

coderabbitai Bot commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Tests
    • Added coverage for emulated floating-point arithmetic, checking multiplication, addition, division, subtraction, and fused multiply-add results against native results.
    • The tests also verify that calculated values stay within a small tolerance.

The emulated __fpemu_uint128 default constructor no longer uses a namespace-qualified name. A host/device test forces emulated 128-bit integer support and compares five fp64 arithmetic results with native double results.

Changes: fp64 emulation with emulated integers

Layer / File(s) Summary
Constructor fix and arithmetic test
libcudacxx/include/cuda/__fp/fpemu_impl.h, libcudacxx/test/libcudacxx/cuda/fp/units/fpemu/emulated_int128.pass.cpp
The default constructor declaration drops the ::cuda:: qualification. The test checks multiplication, addition, division, subtraction, and fused multiply-add against native double results when emulated 128-bit integers are forced.

Assessment against linked issues

Objective Addressed Explanation
Fix <cuda/fpemu> compilation with NVRTC default options when emulated 128-bit integers are selected [#12605] ✅

Suggested reviewers: akolesov-nvidia

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: Minimal · up to 52656

This fixes compilation of the cuda/fpemu header under NVRTC without -device-int128 and adds a test for the emulated path. No merge-blocking risk was found.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: NVIDIA/cccl
  • Branch: main
  • File: .coderabbit.yaml
  • Commit: 5d63af4
  • Layers: Repository YAML
  • Review profile: CHILL
  • Plan: Enterprise
  • Run ID: 5508f4ac-2784-4e41-b782-e5cde6209bac
Commits

Reviewing files that changed from the base of the PR and between 5d63af4 and 52656d2.

Files selected for processing: 2

  • libcudacxx/include/cuda/__fp/fpemu_impl.h
  • libcudacxx/test/libcudacxx/cuda/fp/units/fpemu/emulated_int128.pass.cpp

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.

This branch has not been deployed

No deployments
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.

[BUG]: <cuda/fpemu> fails to compile with NVRTC unless -device-int128 is passed

1 participant