diff options
| author | Andrew Gallant <jamslam@gmail.com> | 2016-11-27 01:06:39 -0500 |
|---|---|---|
| committer | Andrew Gallant <jamslam@gmail.com> | 2016-11-27 01:06:39 -0500 |
| commit | 12121fc2bb34a851ba9ebd4276b2d8574d9671e1 (patch) | |
| tree | fa76f1793d1eceb2ba20c60203ee764c97f6e789 /library/stdarch/examples | |
| parent | c709196f7adc79598a1bf00c8d76aeb4a893ceae (diff) | |
| download | rust-12121fc2bb34a851ba9ebd4276b2d8574d9671e1.tar.gz rust-12121fc2bb34a851ba9ebd4276b2d8574d9671e1.zip | |
progress
Diffstat (limited to 'library/stdarch/examples')
| -rw-r--r-- | library/stdarch/examples/play.rs | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/library/stdarch/examples/play.rs b/library/stdarch/examples/play.rs index 5a3bf6ec8f0..21e18aadcdd 100644 --- a/library/stdarch/examples/play.rs +++ b/library/stdarch/examples/play.rs @@ -1,28 +1,24 @@ extern crate stdsimd; use std::env; -use std::io::Write; use stdsimd as s; fn main() { - let arg1: f64 = env::args().nth(1).unwrap().parse().unwrap(); - let arg2: f64 = env::args().nth(2).unwrap().parse().unwrap(); - let arg3: f64 = env::args().nth(3).unwrap().parse().unwrap(); - let arg4: f64 = env::args().nth(4).unwrap().parse().unwrap(); + let arg1: u8 = env::args().nth(1).unwrap().parse().unwrap(); + let arg2: u8 = env::args().nth(2).unwrap().parse().unwrap(); + let arg3: u8 = env::args().nth(3).unwrap().parse().unwrap(); + let arg4: u8 = env::args().nth(4).unwrap().parse().unwrap(); unsafe { - let a1 = s::_mm_load_pd(&(arg1, arg2) as *const _ as *const f64); - let b1 = s::_mm_load_pd(&(arg3, arg4) as *const _ as *const f64); - // println!("{:?}, {:?}", a, b); - let r1 = s::_mm_add_sd(a1, b1); - // println!("{:?}", r1); - let mut r2: (f64, f64) = (0.0, 0.0); - s::_mm_store_pd(&mut r2 as *mut _ as *mut f64, r1); - if r2 == (4.0, 2.0) { - ::std::io::stdout().write_all(b"yes\n").unwrap(); - } else { - ::std::io::stdout().write_all(b"NO\n").unwrap(); - } - // println!("{:?}", r2); + s::_mm_lfence(); + s::_mm_pause(); + let a = s::u8x16::new( + arg1, arg1, arg1, arg1, arg1, arg1, arg1, arg1, + arg2, arg2, arg2, arg2, arg2, arg2, arg2, arg2); + let b = s::u8x16::new( + arg3, arg3, arg3, arg3, arg3, arg3, arg3, arg3, + arg4, arg4, arg4, arg4, arg4, arg4, arg4, arg4); + let r = s::_mm_sad_epu8(a.as_m128i(), b.as_m128i()); + println!("{:?}", s::u64x2::from(r)); } } |
