Skip to content

feat: add libdevice frexp tuple adapter - #1645

Draft
uurl wants to merge 2 commits into
NVIDIA:mainfrom
uurl:feat/libdevice-frexp-adapter
Draft

uurl wants to merge 2 commits into
NVIDIA:mainfrom
uurl:feat/libdevice-frexp-adapter

Conversation

@uurl

@uurl uurl commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Lower libm::frexpf(f32) and libm::frexp(f64) through __nv_frexpf and __nv_frexp, adapting libdevice's scalar return and exponent output pointer to Rust's (float, i32) result.

Refs # 1 2 2 4
Depends on #1638. This PR is stacked on that change and should land after it.

Changes

  • Recognize the supported public and internal libm paths.
  • Add a reusable out-parameter helper with storage in the function's entry block and initialization at each call site.
  • Reconstruct the Rust tuple through the existing layout map, including reordered fields and padding.
  • Preserve libm's (x, 0) behavior for infinities and NaNs, including NaN payload bits.
  • Add positive, negative, and control tests across both intrinsic backends and float widths.
  • Extend math_special with tuple returns across device-function boundaries, nested tuple assignment, loop calls, and unrelated functions with libm-like names.

Testing

Validated with the pinned Rust 1.99.1 toolchain and GPU target sm_120a.

  • cargo oxide fmt --check and git diff --check.
  • Tests and Clippy for dialect-mir, mir-importer, and mir-lower.
  • Clippy for the math_special example.
  • cargo oxide run math_special: 776 checks passed, including 512 new frexp checks.
  • cargo oxide run libm_math: all lanes matched host math.
  • cargo oxide run math_hyperbolic: 288 checks passed.
  • just check: completed successfully, including generated-output checks, ABI history, license checks, documentation, and doctests.

Checklist

  • Commits include Signed-off-by.
  • Source files carry the required SPDX headers.
  • Regression tests and example documentation updated.

uurl added 2 commits October 25, 2026 01:39
Signed-off-by: Raul Estrada <raulestradaa@gmail.com>
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.

@uurl uurl changed the title Feat/libdevice frexp adapter feat: add libdevice frexp tuple adapter Oct 25, 2026

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