Repository navigation
feat: Add cbrt intrinsic support for f32 and f64 - #148
Merged
Merged
Conversation
Signed-off-by: sunteng <[email protected]>
…odule] Main made bare cuda_launch! a caller-unsafe API (NVIDIA#171) after this example was written, so its host side no longer compiles (E0133). The typed #[cuda_module] launch path is the safe replacement the other math examples already use; the 16-value x 2-width host comparison and the SUCCESS marker are unchanged.
The committed lock pinned the cuda-* path deps at 0.1.0; the workspace has been at 0.2.1 since the version bump, so any build rewrites the lock and dirties the tree. Commit the regenerated lock.
CI runs a workspace-wide cargo fmt check; the new test table in float_math.rs was not rustfmt-clean.
On the pinned toolchain f{32,64}::cbrt inlines down to the
core::num::imp::libm extern declarations, not the std::sys::cmath
shims (those carry atan but only cbrtf128 for cbrt). Reword so the
actually-taken path leads and the cmath spelling is the historical
note.
…him guard is_intrinsic_lowered_cmath_shim is only consulted inside the forbidden-std branch of should_collect_from_crate, where every def path starts with std::, so the core::num::imp::libm arms could never match. They are also unneeded: core is an allowed crate and those libm shims are extern "C" declarations with no MIR, so the collector's existing no-MIR skip already excludes them (verbose build of cbrt_smoke confirms the 'Skipping extern/intrinsic (no MIR)' path fires for both). Document the std-only constraint on the guard.
# Conflicts: # crates/mir-importer/src/translator/terminator/intrinsics/float_math.rs
Collaborator
|
Thanks for the nice addition, mirrors the atan lowering #109 . Main moved underneath the PR, so I layered fixups on top:
|
Completes the coordination between the libm interception table (NVIDIA#142) and the cbrt lowering (NVIDIA#148): the libm-crate spellings now reach the same libdevice __nv_cbrt{,f} path as the core ones.
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.
Summary
cbrtf32/cbrtf64placeholder symbols indialect-mir/src/rust_intrinsics.rs, following the same pattern as existing float math intrinsics__nv_cbrtf/__nv_cbrtin the MIR-lower call translatorcbrt_smokeexample: 16 test values × 2 type variants (f32/f64), verifying GPU results are within 2 ULP of hostlibmTest plan
cargo test -p dialect-mir -p mir-lower --lib— unit tests covering intrinsic name → enum dispatch and arg countcargo oxide run cbrt_smoke— end-to-end GPU smoke test; expected output:SUCCESS: 16 cases × 2 variants within 2 ULP of host libm