Skip to content

Commit 548abdc

Browse files
gnzlbgalexcrichton
authored andcommitted
Prepare portable packed vector types for RFCs (#338)
* Prepare portable packed SIMD vector types for RFCs This commit cleans up the implementation of the Portable Packed Vector Types (PPTV), adds some new features, and makes some breaking changes. The implementation is moved to `coresimd/src/ppvt` (they are still exposed via `coresimd::simd`). As before, the vector types of a certain width are implemented in the `v{width}` submodules. The `macros.rs` file has been rewritten as an `api` module that exposes the macros to implement each API. It should now hopefully be really clear where each API is implemented, and which types implement these APIs. It should also now be really clear which APIs are tested and how. - boolean vectors of the form `b{element_size}x{number_of_lanes}`. - reductions: arithmetic, bitwise, min/max, and boolean - only the facade, and a naive working implementation. These need to be implemented as `llvm.experimental.vector.reduction.{...}` but this needs rustc support first. - FromBits trait analogous to `{f32,f64}::from_bits` that perform "safe" transmutes. Instead of writing `From::from`/`x.into()` (see below for breaking changes) now you write `FromBits::from_bits`/`x.into_bits()`. - portable vector types implement `Default` and `Hash` - tests for all portable vector types and all portable operations (~2000 new tests). - (hopefully) comprehensive implementation of bitwise transmutes and lane-wise casts (before `From` and the `.as_...` methods where implemented "when they were needed". - documentation for PPTV (not great yet, but better than nothing) - conversions/transmutes from/to x86 architecture specific vector types - `store/load` API has been replaced with `{store,load}_{aligned,unaligned}` - `eq,ne,lt,le,gt,ge` APIs now return boolean vectors - The `.as_{...}` methods have been removed. Lane-wise casts are now performed by `From`. - `From` now perform casts (see above). It used to perform bitwise transmutes. - `simd` vectors' `replace` method's result is now `#[must_use]`. * enable backtrace and nocapture * unalign load/store fail test by 1 byte * update arm and aarch64 neon modules * fix arm example * fmt * clippy and read example that rustfmt swallowed * reductions should take self * rename add/mul -> sum/product; delete other arith reductions * clean up fmt::LowerHex impl * revert incorret doc change * make Hash equivalent to [T; lanes()] * use travis_wait to increase timeout limit to 20 minutes * remove travis_wait; did not help * implement reductions on top of the llvm.experimental.vector.reduction intrinsics * implement cmp for boolean vectors * add missing eq impl file * implement default * rename llvm intrinsics * fix aarch64 example error * replace #[inline(always)] with #[inline] * remove cargo clean from run.sh * workaround broken product in aarch64 * make boolean vector constructors const fn * fix more reductions on aarch64 * fix min/max reductions on aarch64 * remove whitespace * remove all boolean vector types except for b8xN * use a sum reduction fallback on aarch64 * disable llvm add reduction for aarch64 * rename the llvm intrinsics to use llvm names * remove old macros.rs file
1 parent 641509b commit 548abdc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+5239
-1304
lines changed

ci/run.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ set -ex
55
# Tests are all super fast anyway, and they fault often enough on travis that
66
# having only one thread increases debuggability to be worth it.
77
export RUST_TEST_THREADS=1
8+
export RUST_BACKTRACE=1
9+
export RUST_TEST_NOCAPTURE=1
810

911
# FIXME(rust-lang-nursery/stdsimd#120) run-time feature detection for ARM Neon
1012
case ${TARGET} in

coresimd/aarch64/neon.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#[cfg(test)]
66
use stdsimd_test::assert_instr;
77
use coresimd::simd_llvm::simd_add;
8-
use coresimd::v128::f64x2;
8+
use coresimd::simd::*;
99

1010
/// Vector add.
1111
#[inline]

coresimd/arm/neon.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
use stdsimd_test::assert_instr;
55

66
use coresimd::simd_llvm::simd_add;
7-
use coresimd::v64::*;
8-
use coresimd::v128::*;
7+
use coresimd::simd::*;
8+
use convert::From;
99

1010
/// Vector add.
1111
#[inline]
@@ -140,8 +140,8 @@ pub unsafe fn vaddq_f32(a: f32x4, b: f32x4) -> f32x4 {
140140
#[target_feature(enable = "neon")]
141141
#[cfg_attr(test, assert_instr(saddl))]
142142
pub unsafe fn vaddl_s8(a: i8x8, b: i8x8) -> i16x8 {
143-
let a = a.as_i16x8();
144-
let b = b.as_i16x8();
143+
let a = i16x8::from(a);
144+
let b = i16x8::from(b);
145145
simd_add(a, b)
146146
}
147147

@@ -150,8 +150,8 @@ pub unsafe fn vaddl_s8(a: i8x8, b: i8x8) -> i16x8 {
150150
#[target_feature(enable = "neon")]
151151
#[cfg_attr(test, assert_instr(saddl))]
152152
pub unsafe fn vaddl_s16(a: i16x4, b: i16x4) -> i32x4 {
153-
let a = a.as_i32x4();
154-
let b = b.as_i32x4();
153+
let a = i32x4::from(a);
154+
let b = i32x4::from(b);
155155
simd_add(a, b)
156156
}
157157

@@ -160,8 +160,8 @@ pub unsafe fn vaddl_s16(a: i16x4, b: i16x4) -> i32x4 {
160160
#[target_feature(enable = "neon")]
161161
#[cfg_attr(test, assert_instr(saddl))]
162162
pub unsafe fn vaddl_s32(a: i32x2, b: i32x2) -> i64x2 {
163-
let a = a.as_i64x2();
164-
let b = b.as_i64x2();
163+
let a = i64x2::from(a);
164+
let b = i64x2::from(b);
165165
simd_add(a, b)
166166
}
167167

@@ -170,8 +170,8 @@ pub unsafe fn vaddl_s32(a: i32x2, b: i32x2) -> i64x2 {
170170
#[target_feature(enable = "neon")]
171171
#[cfg_attr(test, assert_instr(uaddl))]
172172
pub unsafe fn vaddl_u8(a: u8x8, b: u8x8) -> u16x8 {
173-
let a = a.as_u16x8();
174-
let b = b.as_u16x8();
173+
let a = u16x8::from(a);
174+
let b = u16x8::from(b);
175175
simd_add(a, b)
176176
}
177177

@@ -180,8 +180,8 @@ pub unsafe fn vaddl_u8(a: u8x8, b: u8x8) -> u16x8 {
180180
#[target_feature(enable = "neon")]
181181
#[cfg_attr(test, assert_instr(uaddl))]
182182
pub unsafe fn vaddl_u16(a: u16x4, b: u16x4) -> u32x4 {
183-
let a = a.as_u32x4();
184-
let b = b.as_u32x4();
183+
let a = u32x4::from(a);
184+
let b = u32x4::from(b);
185185
simd_add(a, b)
186186
}
187187

@@ -190,8 +190,8 @@ pub unsafe fn vaddl_u16(a: u16x4, b: u16x4) -> u32x4 {
190190
#[target_feature(enable = "neon")]
191191
#[cfg_attr(test, assert_instr(uaddl))]
192192
pub unsafe fn vaddl_u32(a: u32x2, b: u32x2) -> u64x2 {
193-
let a = a.as_u64x2();
194-
let b = b.as_u64x2();
193+
let a = u64x2::from(a);
194+
let b = u64x2::from(b);
195195
simd_add(a, b)
196196
}
197197

0 commit comments

Comments
 (0)