-
Notifications
You must be signed in to change notification settings - Fork 25
Remove unsafe expression on safe AVX2 instructions #1109
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
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.
CI is failing
I miss some understanding on how to use compilation targets and configuration flags here. For example the _mm256_sign_epi32 function is safe and is for the #[inline(always)]
#[hax_lib::fstar::before(r#"[@@ "opaque_to_smt"]"#)]
pub fn mm256_sign_epi32(a: Vec256, b: Vec256) -> Vec256 {
_mm256_sign_epi32(a, b)
} Function _mm256_setzero_si256 is for the same target but feature Is the correct way to use these SIMD functions for different features to put the correct The motivation for this being that safe functions are not wrapped in an unsafe block. Maybe its also a good idea to separate them into different modules? A function for SSE2 being in |
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.
You have to make sure to enable the target feature etc. But you also have to check if these are actually safe intrinsics for the stable Rust compiler.
CPU intrinsics require an unsafe block because they are hardware-dependent. Running them on an unsupported CPU will crash the program. Only when using the HAX target we get a warning. |
c8bb680
to
2af622a
Compare
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.
CI is failing
The changed AVX2 simd instructions in this PR are no longer unsafe. The Compiler gives a warning when using them in an unsafe block.