Skip to content

Instantly share code, notes, and snippets.

@kali
Created July 11, 2019 09:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kali/c145339fd4d7e95b38183617b789e756 to your computer and use it in GitHub Desktop.
Save kali/c145339fd4d7e95b38183617b789e756 to your computer and use it in GitHub Desktop.
use std::arch::x86_64::*;
fn main() {
unsafe { run() }
}
#[target_feature(enable = "avx")]
unsafe fn run() {
let mut data:Vec<u8> = Vec::new();
for i in 0..32 {
data.push(i);
}
println!("data: {:?}", data);
let mut result:Vec<u8> = std::iter::repeat(0).take(32).collect::<Vec<_>>();
unsafe {
let a = _mm256_loadu_si256(data.as_ptr() as usize as *const _);
_mm256_storeu_si256(result.as_mut_ptr() as usize as *mut _, a);
}
println!("res: {:?}", result);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment