Merge commit '8830dccd1d
' into sync_cg_clif-2023-06-15
This commit is contained in:
commit
82b497286d
56 changed files with 2511 additions and 592 deletions
|
@ -197,6 +197,10 @@ unsafe fn test_simd() {
|
|||
|
||||
test_mm_extract_epi8();
|
||||
test_mm_insert_epi16();
|
||||
test_mm_shuffle_epi8();
|
||||
|
||||
test_mm256_shuffle_epi8();
|
||||
test_mm256_permute2x128_si256();
|
||||
|
||||
#[rustfmt::skip]
|
||||
let mask1 = _mm_movemask_epi8(dbg!(_mm_setr_epi8(255u8 as i8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)));
|
||||
|
@ -293,6 +297,12 @@ pub unsafe fn assert_eq_m128d(a: __m128d, b: __m128d) {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
#[target_feature(enable = "avx")]
|
||||
pub unsafe fn assert_eq_m256i(a: __m256i, b: __m256i) {
|
||||
assert_eq!(std::mem::transmute::<_, [u64; 4]>(a), std::mem::transmute::<_, [u64; 4]>(b))
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
#[target_feature(enable = "sse2")]
|
||||
unsafe fn test_mm_cvtsi128_si64() {
|
||||
|
@ -336,6 +346,64 @@ unsafe fn test_mm_insert_epi16() {
|
|||
assert_eq_m128i(r, e);
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
#[target_feature(enable = "ssse3")]
|
||||
unsafe fn test_mm_shuffle_epi8() {
|
||||
#[rustfmt::skip]
|
||||
let a = _mm_setr_epi8(
|
||||
1, 2, 3, 4, 5, 6, 7, 8,
|
||||
9, 10, 11, 12, 13, 14, 15, 16,
|
||||
);
|
||||
#[rustfmt::skip]
|
||||
let b = _mm_setr_epi8(
|
||||
4, 128_u8 as i8, 4, 3,
|
||||
24, 12, 6, 19,
|
||||
12, 5, 5, 10,
|
||||
4, 1, 8, 0,
|
||||
);
|
||||
let expected = _mm_setr_epi8(5, 0, 5, 4, 9, 13, 7, 4, 13, 6, 6, 11, 5, 2, 9, 1);
|
||||
let r = _mm_shuffle_epi8(a, b);
|
||||
assert_eq_m128i(r, expected);
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
#[target_feature(enable = "avx2")]
|
||||
unsafe fn test_mm256_shuffle_epi8() {
|
||||
#[rustfmt::skip]
|
||||
let a = _mm256_setr_epi8(
|
||||
1, 2, 3, 4, 5, 6, 7, 8,
|
||||
9, 10, 11, 12, 13, 14, 15, 16,
|
||||
17, 18, 19, 20, 21, 22, 23, 24,
|
||||
25, 26, 27, 28, 29, 30, 31, 32,
|
||||
);
|
||||
#[rustfmt::skip]
|
||||
let b = _mm256_setr_epi8(
|
||||
4, 128u8 as i8, 4, 3, 24, 12, 6, 19,
|
||||
12, 5, 5, 10, 4, 1, 8, 0,
|
||||
4, 128u8 as i8, 4, 3, 24, 12, 6, 19,
|
||||
12, 5, 5, 10, 4, 1, 8, 0,
|
||||
);
|
||||
#[rustfmt::skip]
|
||||
let expected = _mm256_setr_epi8(
|
||||
5, 0, 5, 4, 9, 13, 7, 4,
|
||||
13, 6, 6, 11, 5, 2, 9, 1,
|
||||
21, 0, 21, 20, 25, 29, 23, 20,
|
||||
29, 22, 22, 27, 21, 18, 25, 17,
|
||||
);
|
||||
let r = _mm256_shuffle_epi8(a, b);
|
||||
assert_eq_m256i(r, expected);
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
#[target_feature(enable = "avx2")]
|
||||
unsafe fn test_mm256_permute2x128_si256() {
|
||||
let a = _mm256_setr_epi64x(100, 200, 500, 600);
|
||||
let b = _mm256_setr_epi64x(300, 400, 700, 800);
|
||||
let r = _mm256_permute2x128_si256::<0b00_01_00_11>(a, b);
|
||||
let e = _mm256_setr_epi64x(700, 800, 500, 600);
|
||||
assert_eq_m256i(r, e);
|
||||
}
|
||||
|
||||
fn test_checked_mul() {
|
||||
let u: Option<u8> = u8::from_str_radix("1000", 10).ok();
|
||||
assert_eq!(u, None);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue