Skip to content

Add cuda::ceil_ilog10#9613

Merged
davebayer merged 2 commits into
NVIDIA:mainfrom
fbusato:ceil_ilog10
Jun 27, 2026
Merged

Add cuda::ceil_ilog10#9613
davebayer merged 2 commits into
NVIDIA:mainfrom
fbusato:ceil_ilog10

Conversation

@fbusato

@fbusato fbusato commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Description

The ceil_ilog10 can be used to covert integers to chars (e.g. to_chars).
In addition, we already have ilog2, ceil_ilog2, and ilog10, so would make sense to add ceil_log10 for completeness.

It tried a couple of optimizations but the simplest version should be also the most efficient.

@fbusato fbusato requested a review from davebayer June 26, 2026 18:54
@fbusato fbusato self-assigned this Jun 26, 2026
@fbusato fbusato requested review from a team as code owners June 26, 2026 18:54
@fbusato fbusato requested a review from alliepiper June 26, 2026 18:54
@fbusato fbusato added this to CCCL Jun 26, 2026
@github-project-automation github-project-automation Bot moved this to Todo in CCCL Jun 26, 2026
@fbusato fbusato added the libcu++ For all items related to libcu++ label Jun 26, 2026
@cccl-authenticator-app cccl-authenticator-app Bot moved this from Todo to In Review in CCCL Jun 26, 2026
@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 0c72a2cc-fe32-4abf-b102-73575bf5c043

📥 Commits

Reviewing files that changed from the base of the PR and between 0838c9f and 3cb3009.

📒 Files selected for processing (3)
  • docs/libcudacxx/extended_api/math.rst
  • docs/libcudacxx/extended_api/math/ilog.rst
  • libcudacxx/include/cuda/__cmath/ilog.h
✅ Files skipped from review due to trivial changes (1)
  • docs/libcudacxx/extended_api/math.rst
🚧 Files skipped from review as they are similar to previous changes (2)
  • docs/libcudacxx/extended_api/math/ilog.rst
  • libcudacxx/include/cuda/__cmath/ilog.h

Note: CodeRabbit is enabled on this repository as a convenience for maintainers
and contributors. Use your best judgment when considering its review comments and
suggestions — a suggested change may be inadequate, unnecessary, or safe to ignore.
Contributors are not expected to address every comment. Human reviews are what
ultimately matter for merging.

Added cuda::ceil_ilog10 to libcu++ alongside the existing integer log helpers (ilog2, ceil_ilog2, ilog10).

What changed

  • Implemented new public API cuda::ceil_ilog10 in libcudacxx/include/cuda/__cmath/ilog.h.
  • Marked ilog2, ceil_ilog2, ilog10, and the new ceil_ilog10 as [[nodiscard]], and updated their parameter types to const _Tp.
  • Adjusted internal compile-time helpers for powers-of-10 (moved to _CCCL_CONSTEVAL and qualified ::cuda::std::* types).
  • Extended libcudacxx/test/libcudacxx/cuda/cmath/ilog.pass.cpp with new coverage for ceil_ilog10, including boundary/neighbor checks and max-value behavior.
  • Updated documentation:
    • Added ceil_ilog10 to docs/libcudacxx/extended_api/math/ilog.rst (declaration, return-value wording, performance considerations, and examples).
    • Updated the math API compatibility matrix (docs/libcudacxx/extended_api/math.rst) to include ceil_ilog10.

Notes

  • The function targets integer-to-string style use cases (e.g., to_chars) where rounding up the base-10 integer logarithm is useful.

Walkthrough

important: Adds cuda::ceil_ilog10 docs, header API, and tests, and updates related ilog2, ceil_ilog2, and ilog10 declarations and helper code.

Changes

ceil_ilog10 API updates

Layer / File(s) Summary
Docs and compatibility entries
docs/libcudacxx/extended_api/math.rst, docs/libcudacxx/extended_api/math/ilog.rst
ceil_ilog10 is added to the compatibility matrix, the ilog API listing, the return/performance text, and the example assertions.
Header updates
libcudacxx/include/cuda/__cmath/ilog.h
Related ilog signatures and power-of-10 helpers are updated, one include is removed, and ceil_ilog10 is added.
Test coverage
libcudacxx/test/libcudacxx/cuda/cmath/ilog.pass.cpp
ceil_ilog10 gets a new templated test helper and is wired into the existing dispatcher.

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.

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 284ef720-5bac-4fd3-8ad9-8b2137beaa96

📥 Commits

Reviewing files that changed from the base of the PR and between 0b675e0 and 0838c9f.

📒 Files selected for processing (4)
  • docs/libcudacxx/extended_api/math.rst
  • docs/libcudacxx/extended_api/math/ilog.rst
  • libcudacxx/include/cuda/__cmath/ilog.h
  • libcudacxx/test/libcudacxx/cuda/cmath/ilog.pass.cpp

Comment thread docs/libcudacxx/extended_api/math.rst
Comment thread libcudacxx/include/cuda/__cmath/ilog.h
@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

🥳 CI Workflow Results

🟩 Finished in 1h 21m: Pass: 100%/120 | Total: 2d 15h | Max: 1h 19m | Hits: 82%/439967

See results here.

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

Thank you!

@davebayer davebayer merged commit f74dd50 into NVIDIA:main Jun 27, 2026
138 of 141 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

libcu++ For all items related to libcu++

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants