-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reduce use of unsafe
in portable SIMD library
#549
Labels
safety
Issues related to use of `unsafe` code
Comments
Related to this, one issue with rten-simd and rten-vecmath right now is that you can't use Miri on it, which would help identify bugs in unsafe code, due to lack of support for various SIMD intrinsics. See also rust-lang/miri#1912. |
Related upstream issue: rust-lang/libs-team#494 |
robertknight
added a commit
that referenced
this issue
Feb 16, 2025
Vectorized operations can operate either in-place on a single mutable slice, or a pair of source and destination slices where the destination is uninitialized. To handle both cases with the same implementation, slice-like types without the aliasing guarantees were used. Replace this with a `SrcDest` type which models the possible cases better in the type system and is a step towards reducing unsafety in vectorized ops. Part of #549.
This was referenced Feb 25, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The current low-level SIMD operations in
rten-simd
are allunsafe
because they are thin wrappers around intrinsics incore::arch
and therefore the caller needs to have verified that the instructions are supported before using them. It would be nice to find ways to reduce the amount of unsafe code here.Constraints
Sources of inspiration
std::simd
avoids the issue by using SIMD types with a fixed-width which can be implemented for every architecture. A given SIMD type will just be mapped to different instructions when used depending on active target featurespulp
- Safe portable SIMD library for Rust with dynamic dispatch. This handles the issue by making theSimd
trait represent an instruction family with operations and associated vector types, not a SIMD vector. This trait is then impl-ed by types which can only be constructed if the feature set is available.Vectorized
types in PyTorchThe text was updated successfully, but these errors were encountered: