progress
This commit is contained in:
parent
52cb807e6e
commit
1203e97ac0
3 changed files with 33 additions and 11 deletions
|
|
@ -1,26 +1,47 @@
|
|||
#![feature(target_feature)]
|
||||
|
||||
extern crate stdsimd;
|
||||
|
||||
use std::env;
|
||||
use stdsimd as s;
|
||||
|
||||
#[inline(never)]
|
||||
fn foobar(a: s::f64x2, b: s::f64x2) -> bool {
|
||||
s::_mm_ucomieq_sd(a, b)
|
||||
#[target_feature = "+sse4.2"]
|
||||
fn index(needle: &str, haystack: &str) -> usize {
|
||||
assert!(needle.len() <= 16 && haystack.len() <= 16);
|
||||
|
||||
let (needle_len, hay_len) = (needle.len(), haystack.len());
|
||||
|
||||
let mut needle = needle.to_string().into_bytes();
|
||||
needle.resize(16, 0);
|
||||
let vneedle = s::__m128i::from(s::u8x16::load(&needle, 0));
|
||||
|
||||
let mut haystack = haystack.to_string().into_bytes();
|
||||
haystack.resize(16, 0);
|
||||
let vhaystack = s::__m128i::from(s::u8x16::load(&haystack, 0));
|
||||
|
||||
s::_mm_cmpestri(
|
||||
vneedle, needle_len as i32, vhaystack, hay_len as i32,
|
||||
s::_SIDD_CMP_EQUAL_ORDERED) as usize
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x0: f64 = env::args().nth(1).unwrap().parse().unwrap();
|
||||
let x1: f64 = env::args().nth(2).unwrap().parse().unwrap();
|
||||
let x2: f64 = env::args().nth(3).unwrap().parse().unwrap();
|
||||
let x3: f64 = env::args().nth(4).unwrap().parse().unwrap();
|
||||
// let x0: f64 = env::args().nth(1).unwrap().parse().unwrap();
|
||||
// let x1: f64 = env::args().nth(2).unwrap().parse().unwrap();
|
||||
// let x2: f64 = env::args().nth(3).unwrap().parse().unwrap();
|
||||
// let x3: f64 = env::args().nth(4).unwrap().parse().unwrap();
|
||||
// let y0: i32 = env::args().nth(5).unwrap().parse().unwrap();
|
||||
// let y1: i32 = env::args().nth(6).unwrap().parse().unwrap();
|
||||
// let y2: i32 = env::args().nth(7).unwrap().parse().unwrap();
|
||||
// let y3: i32 = env::args().nth(8).unwrap().parse().unwrap();
|
||||
|
||||
let a = s::f64x2::new(x0, x1);
|
||||
let b = s::f64x2::new(x2, x3);
|
||||
// let a = s::f64x2::new(x0, x1);
|
||||
// let b = s::f64x2::new(x2, x3);
|
||||
// let r = s::_mm_cmplt_sd(a, b);
|
||||
let r = foobar(a, b);
|
||||
println!("{:?}", r);
|
||||
// let r = foobar(a, b);
|
||||
|
||||
|
||||
let needle = env::args().nth(1).unwrap();
|
||||
let haystack = env::args().nth(2).unwrap();
|
||||
println!("{:?}", index(&needle, &haystack));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
// pub use self::sse::*;
|
||||
pub use self::sse2::*;
|
||||
pub use self::ssse3::*;
|
||||
pub use self::sse42::*;
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
pub type __m128i = ::v128::i8x16;
|
||||
|
|
|
|||
|
|
@ -319,7 +319,7 @@ mod tests {
|
|||
let vb = __m128i::from(u8x16::load(b, 0));
|
||||
let i = sse42::_mm_cmpestri(
|
||||
va, 3, vb, 6,
|
||||
sse42::_SIDD_CMP_EQUAL_ORDERED | sse42::_SIDD_MOST_SIGNIFICANT);
|
||||
sse42::_SIDD_CMP_EQUAL_ORDERED);
|
||||
assert_eq!(3, i);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue