Skip to content

examples: add the FP component examples under examples/cudax/fp - #11273

Draft
akolesov-nvidia wants to merge 7 commits into
NVIDIA:mainfrom
akolesov-nvidia:dev/akolesov/fp_examples_draft
Draft

examples: add the FP component examples under examples/cudax/fp#11273
akolesov-nvidia wants to merge 7 commits into
NVIDIA:mainfrom
akolesov-nvidia:dev/akolesov/fp_examples_draft

Conversation

@akolesov-nvidia

Copy link
Copy Markdown
Contributor

Four examples covering the extended and reduced precision floating-point types, with the documentation that goes with them. They land in the consumer example tree, which acquires CCCL through CPM and so builds the way a user of the released library would, since these are meant as customer entry points.

Each one reports from the host and from the device in a single run: the functions doing the arithmetic are host device, so the build already carries both copies and main only has to call one and launch the other. That also names the GPU the device results came from. A missing GPU is not an error, the device section is skipped.

The fpmp and fpemu readme open with what the types buy, measured on the pi benchmark and quoted with the caveats that go with the numbers: the software quad comparison reverses on FP64-limited hardware, the tied digit count is the benchmark's own truncation floor rather than equivalent formats, and the pipe-splitting figure is an upper bound with no such kernel built yet.

The fp_custom example holds its two inputs as doubles so the constants are written once. Building each reduced format from a native fp_custom value would work, but only because that source's operator float() is explicit; from any other format the same spelling is ambiguous, there being no conversion between two fp_custom instantiations. The doc records that gap, the route through double, and the caveat that it carries the value the source was given rather than the one its format would produce.

Description

closes

Checklist

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

Four examples covering the extended and reduced precision floating-point
types, with the documentation that goes with them. They land in the consumer
example tree, which acquires CCCL through CPM and so builds the way a user of
the released library would, since these are meant as customer entry points.

Each one reports from the host and from the device in a single run: the
functions doing the arithmetic are __host__ __device__, so the build already
carries both copies and main only has to call one and launch the other. That
also names the GPU the device results came from. A missing GPU is not an
error, the device section is skipped.

The fpmp and fpemu readme open with what the types buy, measured on the pi
benchmark and quoted with the caveats that go with the numbers: the software
quad comparison reverses on FP64-limited hardware, the tied digit count is
the benchmark's own truncation floor rather than equivalent formats, and the
pipe-splitting figure is an upper bound with no such kernel built yet.

The fp_custom example holds its two inputs as doubles so the constants are
written once. Building each reduced format from a native fp_custom value
would work, but only because that source's operator float() is explicit;
from any other format the same spelling is ambiguous, there being no
conversion between two fp_custom instantiations. The doc records that gap,
the route through double, and the caveat that it carries the value the
source was given rather than the one its format would produce.
@copy-pr-bot

copy-pr-bot Bot commented Sep 8, 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 Progress in CCCL Sep 8, 2026
@akolesov-nvidia

Copy link
Copy Markdown
Contributor Author

/ok to test 165c2c3

@github-actions

This comment has been minimized.

@miscco miscco 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.

Looks good.

Some nits and one request for cmake improvements

Comment thread examples/cudax/fp/fpemu.cu Outdated
Comment thread examples/cudax/fp/fpemu.cu Outdated
Comment thread examples/cudax/fp/README.md
Comment thread examples/cudax/CMakeLists.txt Outdated
@github-project-automation github-project-automation Bot moved this from In Progress to In Review in CCCL Sep 9, 2026
Review feedback on NVIDIA#11273.

The fp samples are picked up with a CONFIGURE_DEPENDS glob rather than a
hand-kept list, so adding one needs no edit here. This follows what the cub
and thrust examples already do; examples/cudax listed names only because
vector_add was the sole entry and there was no list to maintain.

The two fpemu inputs become named constants at file scope, next to the
existing drift constants. Each literal appeared four times per kernel, and
naming them groups the accuracy-level declarations by value as asked. Output
is unchanged, byte for byte.
@akolesov-nvidia

Copy link
Copy Markdown
Contributor Author

/ok to test f937476

@github-actions

This comment has been minimized.

@akolesov-nvidia

Copy link
Copy Markdown
Contributor Author

Thank you for looking into that, colleagues! Could you please merge this PR if no other suggestions? Then I will be able to proceed with main documentation development with links to these examples. Thanks!

@davebayer davebayer 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.

These examples need to be rewritten using CCCL Runtime, we want the examples to highlight our best practices

Comment thread examples/cudax/fp/fpemu.cu Outdated
Comment thread examples/cudax/fp/fpemu.cu Outdated
Comment thread examples/cudax/fp/fpemu.cu Outdated
Comment thread examples/cudax/fp/fpemu.cu Outdated
Comment thread examples/cudax/fp/fpemu.cu Outdated
@github-project-automation github-project-automation Bot moved this from In Review to In Progress in CCCL Sep 11, 2026
Review feedback on NVIDIA#11273.

The device half of each example now goes through the runtime rather than the
CUDA runtime API: cuda::devices to find a GPU, a cuda::stream to submit on,
cuda::make_pinned_buffer for the results the kernels write back, and
cuda::launch for the launches themselves. Errors arrive as exceptions, so the
per-call status checks give way to a catch on main. Pinned memory is enough
here, each result being one struct that the host reads once the stream has
drained. The fpemu stack limit has no runtime equivalent, so it remains a CUDA
runtime call, now with its status checked.
@akolesov-nvidia

Copy link
Copy Markdown
Contributor Author

/ok to test c127fca

@github-actions

This comment has been minimized.

The pinned memory pool arrived in 12.9, so reaching for make_pinned_buffer
left these uncompilable on the 12.0 packaging job. Each example now picks its
results buffer by toolkit version: the pinned pool where it exists, since
writing memory the host reads directly is the point of the pattern, and a
device buffer brought back with cuda::copy_bytes below that. Both paths were
run against one GPU and print the same bytes.
@akolesov-nvidia

Copy link
Copy Markdown
Contributor Author

/ok to test 0e7cf3d

@github-actions

Copy link
Copy Markdown
Contributor

🥳 CI Workflow Results

🟩 Finished in 5m 35s: Pass: 100%/9 | Total: 30m 52s | Max: 5m 15s | Hits: 100%/856

See results here.

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

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

3 participants