Repository navigation
Conversation
Kernels can now write `y.atan2(x)` / `x.atan()` directly. Signed-off-by: Paul Zhang <[email protected]>
This was referenced Jun 4, 2026
Collaborator
|
Thanks for this, @paulzhng, LGTM. Once #62 merged it overlapped the same Closing in favor of #109. Appreciate it. |
nihalpasham
added a commit
that referenced
this pull request
Jun 4, 2026
mir: lower f32::atan{,2} / f64::atan{,2} via libdevice (rebased #78)
ianrgraham
added a commit
to ianrgraham/cuda-oxide
that referenced
this pull request
Jun 4, 2026
…cbrt/hypot/…) to libdevice
f64/f32 methods like sqrt/sin/exp are core::intrinsics and already lower to __nv_*, but
the inverse-trig / hyperbolic / cbrt / hypot family are libm calls, not intrinsics:
- atan2/atan/asin/acos/sinh/cosh/tanh/asinh/acosh/atanh/expm1/log1p/hypot route through
`std::sys::cmath` (extern "C") — which tripped the std-forbidden collector panic;
- cbrt (and other core_float_math) route through the bundled pure-Rust
`core::num::imp::libm` — which was never collected ("symbol not found").
Fix, mirroring the existing core::intrinsics → __nv_ path:
1. collector: whitelist `std::sys::cmath::*` (SkipIntentional instead of the std-forbidden
panic) — the wrapper isn't compiled; the call is redirected during lowering.
2. mir-lower call.rs: RustFloatMathIntrinsic::from_libm_symbol matches the legalized
`std__sys__cmath__<fn>` and `core__num__imp__libm__<fn>` callees (prefix-stripped) and
maps them to the corresponding `__nv_*` libdevice function, with f32/f64 + arg-count
handling. Closes the atan2 gap (issues NVIDIA#77/NVIDIA#78).
Validated by gale's probe-libm (atan2/atan/asin/acos/sinh/cosh/tanh/hypot/cbrt vs host
std, worst rel 6.9e-15 on sm_70 Titan V).
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
meefs
pushed a commit
to meefs/cuda-oxide
that referenced
this pull request
Sep 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #77
After this change, kernels can now write
y.atan2(x)/x.atan()directly.Before that, using these functions lead to a kernel compilation failure.