Skip to content

Commit

Permalink
Verify code generation of the AVX-512 rotates
Browse files Browse the repository at this point in the history
  • Loading branch information
gnzlbg committed Aug 12, 2018
1 parent dfb5494 commit 8c3da85
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 4 deletions.
13 changes: 9 additions & 4 deletions ci/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ if [[ ${TARGET} == "x86_64-apple-ios" ]] || [[ ${TARGET} == "i386-apple-ios" ]];
export CARGO_TARGET_I386_APPLE_IOS_RUNNER=$HOME/runtest
fi

# The source directory is read-only. Need to copy internal crates to the target
# directory for their Cargo.lock to be properly written.
mkdir target || true

rustc --version
cargo --version
echo "TARGET=${TARGET}"
Expand Down Expand Up @@ -62,10 +66,11 @@ cargo_test_impl
cargo_test_impl --release --features=into_bits
cargo_test_impl --release --features=into_bits,coresimd

# Examples - the source directory is read-only.
# Need to copy them to the target directory for the Cargo.lock to be
# properly written.
mkdir target || true
# Verify code generation
if [[ "${NOVERIFY}" != "1" ]]; then
cp -r verify target/verify
cargo_test "--release --manifest-path=target/verify/Cargo.toml"
fi

# FIXME: https://github.com/rust-lang-nursery/packed_simd/issues/55
# All examples fail to build for `armv7-apple-ios`.
Expand Down
8 changes: 8 additions & 0 deletions verify/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "verify"
version = "0.1.0"
authors = ["gnzlbg <gonzalobg88@gmail.com>"]

[dev-dependencies]
stdsimd-test = { git = "https://github.com/rust-lang-nursery/stdsimd.git" }
packed_simd = { path = ".." }
1 change: 1 addition & 0 deletions verify/src/api.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mod ops;
1 change: 1 addition & 0 deletions verify/src/api/ops.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mod vector_rotates;
70 changes: 70 additions & 0 deletions verify/src/api/ops/vector_rotates.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
mod u64x8 {
use packed_simd::*;
use stdsimd_test::assert_instr;

#[inline]
#[cfg_attr(
any(target_arch = "x86", target_arch = "x86_64"),
target_feature(enable = "avx512f,avx512vl")
)]
#[cfg_attr(
any(target_arch = "x86", target_arch = "x86_64"),
assert_instr(vpro)
)]
unsafe fn rotate_right_variable(x: u64x8, v: u64x8) -> u64x8 {
x.rotate_right(v)
}

#[inline]
#[cfg_attr(
any(target_arch = "x86", target_arch = "x86_64"),
target_feature(enable = "avx512f,avx512vl")
)]
#[cfg_attr(
any(target_arch = "x86", target_arch = "x86_64"),
assert_instr(vpro)
)]
unsafe fn rotate_left_variable(x: u64x8, v: u64x8) -> u64x8 {
x.rotate_left(v)
}

#[inline]
#[cfg_attr(
any(target_arch = "x86", target_arch = "x86_64"),
target_feature(enable = "avx512f")
)]
#[cfg_attr(
any(target_arch = "x86", target_arch = "x86_64"),
assert_instr(vpro)
)]
unsafe fn rotate_right(x: u64x8) -> u64x8 {
x.rotate_right(u64x8::splat(12))
}

#[inline]
#[cfg_attr(
any(target_arch = "x86", target_arch = "x86_64"),
target_feature(enable = "avx512f")
)]
#[cfg_attr(
any(target_arch = "x86", target_arch = "x86_64"),
assert_instr(vpro)
)]
unsafe fn rotate_left(x: u64x8) -> u64x8 {
x.rotate_left(u64x8::splat(12))
}

#[inline]
#[cfg_attr(
any(target_arch = "x86", target_arch = "x86_64"),
target_feature(enable = "avx512f")
)]
#[cfg_attr(
any(target_arch = "x86", target_arch = "x86_64"),
assert_instr(vpro)
)]
unsafe fn rotate_left_x2(x: u64x2) -> u64x2 {
x.rotate_left(u64x2::splat(12))
}

}
10 changes: 10 additions & 0 deletions verify/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#![feature(rust_2018_preview, use_extern_macros, avx512_target_feature)]

#[cfg(test)]
extern crate packed_simd;

#[cfg(test)]
extern crate stdsimd_test;

#[cfg(test)]
mod api;

0 comments on commit 8c3da85

Please sign in to comment.