Skip to content

feat: lower tgamma, ilogb and ldexp through libdevice - #1638

Open
uurl wants to merge 1 commit into
NVIDIA:mainfrom
uurl:feat/libdevice-special-scalar-math
Open

uurl wants to merge 1 commit into
NVIDIA:mainfrom
uurl:feat/libdevice-special-scalar-math

Conversation

@uurl

@uurl uurl commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Add missing f32/f64 libdevice mappings for tgamma, ilogb and ldexp, including scalbn aliases and standard-library gamma() shims. This covers the scalar additions in the first stage of #1224 and verifies both integer-result and integer-argument signatures before the table-generation work.

Refs #1224.

Changes

  • Wire placeholders, Rust path recognition, lowering and libdevice linking classification across the compiler.
  • Map scalbn/scalbnf to the corresponding ldexp libdevice functions.
  • Allow the exact std::sys::cmath::tgamma{f} shims through the collector.
  • Validate signatures before declaring libdevice callees: ilogb returns i32, and ldexp takes an i32 exponent.
  • Add importer and lowering tests covering aliases, both intrinsic backends, malformed signatures and unrelated function names.
  • Add math_special, checking libm and standard-library gamma, integer logarithms, scaling and a user-function control across both precisions.

frexp and the generated math tables will follow in separate PRs.

Testing

Validated on sm_120a with the pinned Rust 1.99.1 toolchain.

  • just check passes from cuda-oxide/.
  • Clippy for math_special passes with --all-targets -- -D warnings.
  • cargo oxide run math_special passes.
  • GPU regressions libm_math and math_hyperbolic pass.
  • New example added.
SUCCESS: math_special passed 264 checks across f32 and f64
SUCCESS: all libm lanes match host math
SUCCESS: 16 cases × 9 functions × 2 widths within tolerance of host libm

Checklist

  • All commits signed off (git commit -s)
  • SPDX headers on new source files
  • just -f cuda-oxide/Justfile check passes (the local mirror of CI: fmt, clippy, tests, guards, docs)
  • cargo oxide run <example> passes, or cuda-oxide/scripts/smoketest.sh -o '^<example>$'
  • New example added

Signed-off-by: Raul Estrada <raulestradaa@gmail.com>
@copy-pr-bot

copy-pr-bot Bot commented Oct 25, 2026

Copy link
Copy Markdown

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.

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

None yet

Development

Successfully merging this pull request may close these issues.

1 participant