Skip to content

Commit 0632492

Browse files
committed
split the portable vector tests into separate crates
1 parent 3a5ab60 commit 0632492

37 files changed

+814
-426
lines changed

ci/run.sh

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,14 @@
22

33
set -ex
44

5+
: ${TARGET?"The TARGET environment variable must be set."}
6+
57
# Tests are all super fast anyway, and they fault often enough on travis that
68
# having only one thread increases debuggability to be worth it.
79
export RUST_TEST_THREADS=1
810
#export RUST_BACKTRACE=1
911
#export RUST_TEST_NOCAPTURE=1
1012

11-
# FIXME(rust-lang-nursery/stdsimd#120) run-time feature detection for ARM Neon
12-
case ${TARGET} in
13-
aarch*)
14-
export RUSTFLAGS="${RUSTFLAGS} -C target-feature=+neon"
15-
;;
16-
*)
17-
;;
18-
esac
19-
2013
FEATURES="strict,$FEATURES"
2114

2215
echo "RUSTFLAGS=${RUSTFLAGS}"
@@ -25,7 +18,8 @@ echo "OBJDUMP=${OBJDUMP}"
2518

2619
cargo_test() {
2720
cmd="cargo test --target=$TARGET --features $FEATURES $1"
28-
cmd="$cmd -p coresimd -p stdsimd --manifest-path crates/stdsimd/Cargo.toml"
21+
cmd="$cmd -p coresimd -p stdsimd"
22+
cmd="$cmd --manifest-path crates/stdsimd/Cargo.toml"
2923
cmd="$cmd -- $2"
3024
$cmd
3125
}

coresimd/ppsv/api/arithmetic_ops.rs

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,82 @@
11
//! Lane-wise arithmetic operations.
2+
#![allow(unused)]
23

34
macro_rules! impl_arithmetic_ops {
45
($id:ident) => {
5-
impl ops::Add for $id {
6+
impl ::ops::Add for $id {
67
type Output = Self;
78
#[inline]
89
fn add(self, other: Self) -> Self {
10+
use coresimd::simd_llvm::simd_add;
911
unsafe { simd_add(self, other) }
1012
}
1113
}
1214

13-
impl ops::Sub for $id {
15+
impl ::ops::Sub for $id {
1416
type Output = Self;
1517
#[inline]
1618
fn sub(self, other: Self) -> Self {
19+
use coresimd::simd_llvm::simd_sub;
1720
unsafe { simd_sub(self, other) }
1821
}
1922
}
2023

21-
impl ops::Mul for $id {
24+
impl ::ops::Mul for $id {
2225
type Output = Self;
2326
#[inline]
2427
fn mul(self, other: Self) -> Self {
28+
use coresimd::simd_llvm::simd_mul;
2529
unsafe { simd_mul(self, other) }
2630
}
2731
}
2832

29-
impl ops::Div for $id {
33+
impl ::ops::Div for $id {
3034
type Output = Self;
3135
#[inline]
3236
fn div(self, other: Self) -> Self {
37+
use coresimd::simd_llvm::simd_div;
3338
unsafe { simd_div(self, other) }
3439
}
3540
}
3641

37-
impl ops::Rem for $id {
42+
impl ::ops::Rem for $id {
3843
type Output = Self;
3944
#[inline]
4045
fn rem(self, other: Self) -> Self {
46+
use coresimd::simd_llvm::simd_rem;
4147
unsafe { simd_rem(self, other) }
4248
}
4349
}
4450

45-
impl ops::AddAssign for $id {
51+
impl ::ops::AddAssign for $id {
4652
#[inline]
4753
fn add_assign(&mut self, other: Self) {
4854
*self = *self + other;
4955
}
5056
}
5157

52-
impl ops::SubAssign for $id {
58+
impl ::ops::SubAssign for $id {
5359
#[inline]
5460
fn sub_assign(&mut self, other: Self) {
5561
*self = *self - other;
5662
}
5763
}
5864

59-
impl ops::MulAssign for $id {
65+
impl ::ops::MulAssign for $id {
6066
#[inline]
6167
fn mul_assign(&mut self, other: Self) {
6268
*self = *self * other;
6369
}
6470
}
6571

66-
impl ops::DivAssign for $id {
72+
impl ::ops::DivAssign for $id {
6773
#[inline]
6874
fn div_assign(&mut self, other: Self) {
6975
*self = *self / other;
7076
}
7177
}
7278

73-
impl ops::RemAssign for $id {
79+
impl ::ops::RemAssign for $id {
7480
#[inline]
7581
fn rem_assign(&mut self, other: Self) {
7682
*self = *self % other;
@@ -80,7 +86,6 @@ macro_rules! impl_arithmetic_ops {
8086
}
8187

8288
#[cfg(test)]
83-
#[macro_export]
8489
macro_rules! test_arithmetic_ops {
8590
($id:ident, $elem_ty:ident) => {
8691
#[test]

coresimd/ppsv/api/arithmetic_reductions.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
//! Implements portable arithmetic vector reductions.
2+
#![allow(unused)]
23

34
macro_rules! impl_arithmetic_reductions {
45
($id:ident, $elem_ty:ident) => {
56
impl $id {
67
/// Lane-wise addition of the vector elements.
78
#[inline]
89
pub fn sum(self) -> $elem_ty {
9-
ReduceAdd::reduce_add(self)
10+
super::codegen::sum::ReduceAdd::reduce_add(self)
1011
}
1112
/// Lane-wise multiplication of the vector elements.
1213
#[inline]
1314
pub fn product(self) -> $elem_ty {
14-
ReduceMul::reduce_mul(self)
15+
super::codegen::product::ReduceMul::reduce_mul(self)
1516
}
1617
}
1718
}

coresimd/ppsv/api/bitwise_ops.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,52 @@
11
//! Lane-wise bitwise operations for integer and boolean vectors.
2+
#![allow(unused)]
23

34
macro_rules! impl_bitwise_ops {
45
($ty:ident, $true_val:expr) => {
5-
impl ops::Not for $ty {
6+
impl ::ops::Not for $ty {
67
type Output = Self;
78
#[inline]
89
fn not(self) -> Self {
910
Self::splat($true_val) ^ self
1011
}
1112
}
12-
impl ops::BitXor for $ty {
13+
impl ::ops::BitXor for $ty {
1314
type Output = Self;
1415
#[inline]
1516
fn bitxor(self, other: Self) -> Self {
17+
use coresimd::simd_llvm::simd_xor;
1618
unsafe { simd_xor(self, other) }
1719
}
1820
}
19-
impl ops::BitAnd for $ty {
21+
impl ::ops::BitAnd for $ty {
2022
type Output = Self;
2123
#[inline]
2224
fn bitand(self, other: Self) -> Self {
25+
use coresimd::simd_llvm::simd_and;
2326
unsafe { simd_and(self, other) }
2427
}
2528
}
26-
impl ops::BitOr for $ty {
29+
impl ::ops::BitOr for $ty {
2730
type Output = Self;
2831
#[inline]
2932
fn bitor(self, other: Self) -> Self {
33+
use coresimd::simd_llvm::simd_or;
3034
unsafe { simd_or(self, other) }
3135
}
3236
}
33-
impl ops::BitAndAssign for $ty {
37+
impl ::ops::BitAndAssign for $ty {
3438
#[inline]
3539
fn bitand_assign(&mut self, other: Self) {
3640
*self = *self & other;
3741
}
3842
}
39-
impl ops::BitOrAssign for $ty {
43+
impl ::ops::BitOrAssign for $ty {
4044
#[inline]
4145
fn bitor_assign(&mut self, other: Self) {
4246
*self = *self | other;
4347
}
4448
}
45-
impl ops::BitXorAssign for $ty {
49+
impl ::ops::BitXorAssign for $ty {
4650
#[inline]
4751
fn bitxor_assign(&mut self, other: Self) {
4852
*self = *self ^ other;
@@ -52,7 +56,6 @@ macro_rules! impl_bitwise_ops {
5256
}
5357

5458
#[cfg(test)]
55-
#[macro_export]
5659
macro_rules! test_int_bitwise_ops {
5760
($id:ident, $elem_ty:ident) => {
5861
#[test]
@@ -117,7 +120,6 @@ macro_rules! test_int_bitwise_ops {
117120
}
118121

119122
#[cfg(test)]
120-
#[macro_export]
121123
macro_rules! test_bool_bitwise_ops {
122124
($id:ident) => {
123125
#[test]

coresimd/ppsv/api/bitwise_reductions.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
//! Implements portable bitwise vector reductions.
2+
#![allow(unused)]
23

34
macro_rules! impl_bitwise_reductions {
45
($id:ident, $elem_ty:ident) => {
56
impl $id {
67
/// Lane-wise bitwise `and` of the vector elements.
78
#[inline]
89
pub fn and(self) -> $elem_ty {
9-
ReduceAnd::reduce_and(self)
10+
super::codegen::and::ReduceAnd::reduce_and(self)
1011
}
1112
/// Lane-wise bitwise `or` of the vector elements.
1213
#[inline]
1314
pub fn or(self) -> $elem_ty {
14-
ReduceOr::reduce_or(self)
15+
super::codegen::or::ReduceOr::reduce_or(self)
1516
}
1617
/// Lane-wise bitwise `xor` of the vector elements.
1718
#[inline]
1819
pub fn xor(self) -> $elem_ty {
19-
ReduceXor::reduce_xor(self)
20+
super::codegen::xor::ReduceXor::reduce_xor(self)
2021
}
2122
}
2223
}
@@ -28,17 +29,17 @@ macro_rules! impl_bool_bitwise_reductions {
2829
/// Lane-wise bitwise `and` of the vector elements.
2930
#[inline]
3031
pub fn and(self) -> $elem_ty {
31-
ReduceAnd::reduce_and(self) !=0
32+
super::codegen::and::ReduceAnd::reduce_and(self) !=0
3233
}
3334
/// Lane-wise bitwise `or` of the vector elements.
3435
#[inline]
3536
pub fn or(self) -> $elem_ty {
36-
ReduceOr::reduce_or(self) != 0
37+
super::codegen::or::ReduceOr::reduce_or(self) != 0
3738
}
3839
/// Lane-wise bitwise `xor` of the vector elements.
3940
#[inline]
4041
pub fn xor(self) -> $elem_ty {
41-
ReduceXor::reduce_xor(self) != 0
42+
super::codegen::xor::ReduceXor::reduce_xor(self) != 0
4243
}
4344
}
4445
}

coresimd/ppsv/api/bool_vectors.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
//! Minimal boolean vector implementation
2+
#![allow(unused)]
23

34
/// Minimal interface: all packed SIMD boolean vector types implement this.
45
macro_rules! impl_bool_minimal {
56
($id:ident, $elem_ty:ident, $elem_count:expr, $($elem_name:ident),+) => {
67

78
#[cfg_attr(feature = "cargo-clippy", allow(expl_impl_clone_on_copy))]
8-
impl Clone for $id {
9+
impl ::clone::Clone for $id {
910
#[inline] // currently needed for correctness
1011
fn clone(&self) -> Self {
1112
*self
@@ -59,6 +60,7 @@ macro_rules! impl_bool_minimal {
5960
/// If `index >= Self::lanes()` the behavior is undefined.
6061
#[inline]
6162
pub unsafe fn extract_unchecked(self, index: usize) -> bool {
63+
use coresimd::simd_llvm::simd_extract;
6264
let x: $elem_ty = simd_extract(self, index as u32);
6365
x != 0
6466
}
@@ -87,6 +89,7 @@ macro_rules! impl_bool_minimal {
8789
index: usize,
8890
new_value: bool,
8991
) -> Self {
92+
use coresimd::simd_llvm::simd_insert;
9093
simd_insert(self, index as u32, Self::bool_to_internal(new_value))
9194
}
9295
}

coresimd/ppsv/api/boolean_reductions.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//! Lane-wise boolean vector reductions.
2+
#![allow(unused)]
23

34
macro_rules! impl_bool_reductions {
45
($id:ident) => {

0 commit comments

Comments
 (0)