-
Notifications
You must be signed in to change notification settings - Fork 17
A stable, safe implementation of "Struct Target Features" #108
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file (and trampoline.rs
) contains the main code needed to understand this PR.
/// See the module level docs [self]. | ||
/// | ||
/// We require static lifetimes as this is primarily internal to the macro. | ||
pub const fn is_feature_subset<const N: usize>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function needs the most careful review, because its correctness is being relied upon for safety.
The "glamour shot" of this PR is that given: fearless_simd/fearless_simd_core/src/lib.rs Lines 236 to 241 in ac8cb44
You can run: fearless_simd/fearless_simd_core/src/lib.rs Lines 246 to 255 in ac8cb44
To entirely safely and soundly use Rust's SIMD intrinsics. To help guide review, the core contribution of this PR is a way to talk about target features in the type system. This is implemented through this trait: fearless_simd/fearless_simd_core/src/lib.rs Lines 24 to 50 in ac8cb44
Implementing fearless_simd/fearless_simd_core/src/lib.rs Lines 249 to 255 in ac8cb44
In this example, the SSE x86 functionality for multiplying is proven to be safe, and then executed and ran. Separately, in this PR, we have the functionality for properly using this on the x86_64 (and also plain x86) architectures. This is the contents of the
Every file in that folder (except for mod.rs files) is automatically generated by the binary crate of the |
Also removes unused additional impl support
The core contributions of this PR are:
trampoline
macro, which validates a#[target_feature(enable = "xxx")]
string against values of one or more of these, ensuring at compile time that a call to a#[target_feature]
function will be safe; and then calling it.The state of this feature is:
The x86-64-v{1,2,3,4} level implementations do not exist/are extremely incomplete.Some docs are missing (these are however not the most critical docs, it's only docs on the groupings of x86 features).There is also an open licensing question, around the docs taken from the Rust reference. My preference would be to copy https://github.com/rust-lang/reference/blob/1d930e1d5a27e114b4d22a50b0b6cd3771b92e31/LICENSE-MIT#L1 into our LICENSE-MIT, which avoids having to make a decision about copyright-ability here.
My proposed next steps are:
For review:
fearless_simd_core/x86/xxx/xxx.rs
, as these are entirely automatically generated. The exception isfearless_simd_core/x86/xxx/mod.rs
, which are hand-written, but don't have any logic.Discussed on Zulip: #simd > Removing `safe-wrappers`