Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixups #207

Merged
merged 5 commits into from
Jan 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,10 @@ matrix:
# BENCHMARKS:
- name: "Benchmarks - x86_64-unknown-linux-gnu"
install: TARGET=x86_64-unknown-linux-gnu ./ci/setup_benchmarks.sh
script: PATH=$(pwd):$PATH NORUN=1 VERIFY=1 FEATURES=coresimd,ispc,sleef-sys ci/benchmark.sh
script: PATH=$(pwd):$PATH NORUN=1 VERIFY=1 FEATURES=core_arch,ispc,sleef-sys ci/benchmark.sh
- name: "Benchmarks - x86_64-apple-darwin"
install: TARGET=x86_64-apple-darwin ./ci/setup_benchmarks.sh
script: PATH=$(pwd):$PATH NORUN=1 VERIFY=1 FEATURES=coresimd,ispc,sleef-sys ci/benchmark.sh
script: PATH=$(pwd):$PATH NORUN=1 VERIFY=1 FEATURES=core_arch,ispc,sleef-sys ci/benchmark.sh
os: osx
osx_image: xcode9.4
# TOOLS:
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ maintenance = { status = "experimental" }

[dependencies]
cfg-if = "^0.1"
coresimd = { version = "^0.1.0", optional = true }
core_arch = { version = "^0.1.3", optional = true }

[features]
default = []
Expand All @@ -32,7 +32,7 @@ paste = "^0.1.3"
arrayvec = { version = "^0.4", default-features = false }

[target.'cfg(target_arch = "x86_64")'.dependencies.sleef-sys]
version = "^0.1"
version = "^0.1.2"
optional = true

[target.wasm32-unknown-unknown.dev-dependencies]
Expand Down
30 changes: 15 additions & 15 deletions ci/android-install-ndk.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env sh
# Copyright 2016 The Rust Project Developers. See the COPYRIGHT
# file at the top-level directory of this distribution and at
# http://rust-lang.org/COPYRIGHT.
Expand All @@ -11,27 +11,27 @@

set -ex

curl -O https://dl.google.com/android/repository/android-ndk-r15b-linux-x86_64.zip
curl --retry 5 -O https://dl.google.com/android/repository/android-ndk-r15b-linux-x86_64.zip
unzip -q android-ndk-r15b-linux-x86_64.zip

case "$1" in
aarch64)
arch=arm64
;;
aarch64)
arch=arm64
;;

i686)
arch=x86
;;
i686)
arch=x86
;;

*)
arch=$1
;;
*)
arch=$1
;;
esac;

android-ndk-r15b/build/tools/make_standalone_toolchain.py \
--unified-headers \
--install-dir /android/ndk-$1 \
--arch $arch \
--api 24
--unified-headers \
--install-dir "/android/ndk-${1}" \
--arch "${arch}" \
--api 24

rm -rf ./android-ndk-r15b-linux-x86_64.zip ./android-ndk-r15b
12 changes: 6 additions & 6 deletions ci/android-install-sdk.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env sh
# Copyright 2016 The Rust Project Developers. See the COPYRIGHT
# file at the top-level directory of this distribution and at
# http://rust-lang.org/COPYRIGHT.
Expand All @@ -19,7 +19,7 @@ set -ex
# which apparently magically accepts the licenses.

mkdir sdk
curl https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip -O
curl --retry 5 https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip -O
unzip -d sdk sdk-tools-linux-3859397.zip

case "$1" in
Expand All @@ -46,15 +46,15 @@ case "$1" in
esac;

# --no_https avoids
# javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: No trusted certificate found
echo "yes" | \
./sdk/tools/bin/sdkmanager --no_https \
# javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: No trusted certificate found
yes | ./sdk/tools/bin/sdkmanager --licenses --no_https
yes | ./sdk/tools/bin/sdkmanager --no_https \
"emulator" \
"platform-tools" \
"platforms;android-24" \
"system-images;android-24;default;$abi"

echo "no" |
./sdk/tools/bin/avdmanager create avd \
--name $1 \
--name "${1}" \
--package "system-images;android-24;default;$abi"
40 changes: 22 additions & 18 deletions ci/android-sysimage.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env bash

# Copyright 2017 The Rust Project Developers. See the COPYRIGHT
# file at the top-level directory of this distribution and at
# http://rust-lang.org/COPYRIGHT.
Expand All @@ -13,40 +15,42 @@ set -ex
URL=https://dl.google.com/android/repository/sys-img/android

main() {
local arch=$1
local name=$2
local arch="${1}"
local name="${2}"
local dest=/system
local td=$(mktemp -d)
local td
td="$(mktemp -d)"

apt-get install --no-install-recommends e2tools

pushd $td
curl -O $URL/$name
unzip -q $name
pushd "${td}"
curl --retry 5 -O "${URL}/${name}"
unzip -q "${name}"

local system=$(find . -name system.img)
mkdir -p $dest/{bin,lib,lib64}
local system
system="$(find . -name system.img)"
mkdir -p ${dest}/{bin,lib,lib64}

# Extract android linker and libraries to /system
# This allows android executables to be run directly (or with qemu)
if [ $arch = "x86_64" -o $arch = "arm64" ]; then
e2cp -p $system:/bin/linker64 $dest/bin/
e2cp -p $system:/lib64/libdl.so $dest/lib64/
e2cp -p $system:/lib64/libc.so $dest/lib64/
e2cp -p $system:/lib64/libm.so $dest/lib64/
if [ "${arch}" = "x86_64" ] || [ "${arch}" = "arm64" ]; then
e2cp -p "${system}:/bin/linker64" "${dest}/bin/"
e2cp -p "${system}:/lib64/libdl.so" "${dest}/lib64/"
e2cp -p "${system}:/lib64/libc.so" "${dest}/lib64/"
e2cp -p "${system}:/lib64/libm.so" "${dest}/lib64/"
else
e2cp -p $system:/bin/linker $dest/bin/
e2cp -p $system:/lib/libdl.so $dest/lib/
e2cp -p $system:/lib/libc.so $dest/lib/
e2cp -p $system:/lib/libm.so $dest/lib/
e2cp -p "${system}:/bin/linker" "${dest}/bin/"
e2cp -p "${system}:/lib/libdl.so" "${dest}/lib/"
e2cp -p "${system}:/lib/libc.so" "${dest}/lib/"
e2cp -p "${system}:/lib/libm.so" "${dest}/lib/"
fi

# clean up
apt-get purge --auto-remove -y e2tools

popd

rm -rf $td
rm -rf "${td}"
}

main "${@}"
2 changes: 1 addition & 1 deletion ci/benchmark.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# Runs all benchmarks. Controlled by the following environment variables:
#
# FEATURES={} - cargo features to pass to all benchmarks (e.g. coresimd,sleef-sys,ispc)
# FEATURES={} - cargo features to pass to all benchmarks (e.g. core_arch,sleef-sys,ispc)
# NORUN={1} - only builds the benchmarks

set -ex
Expand Down
13 changes: 10 additions & 3 deletions ci/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set -ex

# Tests are all super fast anyway, and they fault often enough on travis that
# having only one thread increases debuggability to be worth it.
export RUST_TEST_THREADS=1
#export RUST_TEST_THREADS=1
#export RUST_BACKTRACE=full
#export RUST_TEST_NOCAPTURE=1

Expand Down Expand Up @@ -47,6 +47,13 @@ echo "RUST_TEST_NOCAPTURE=${RUST_TEST_NOCAPTURE}"

cargo_test() {
cmd="cargo ${CARGO_SUBCMD} --verbose --target=${TARGET} ${@}"
if [ "${NORUN}" != "1" ]
then
if [ "$TARGET" != "wasm32-unknown-unknown" ]
then
cmd="$cmd -- --quiet"
fi
fi
mkdir target || true
${cmd} 2>&1 | tee > target/output
if [[ ${PIPESTATUS[0]} != 0 ]]; then
Expand All @@ -71,9 +78,9 @@ fi

if [[ "${TARGET}" == "x86_64-unknown-linux-gnu" ]] || [[ "${TARGET}" == "x86_64-pc-windows-msvc" ]]; then
# use sleef on linux and windows x86_64 builds
cargo_test_impl --release --features=into_bits,coresimd,sleef-sys
cargo_test_impl --release --features=into_bits,core_arch,sleef-sys
else
cargo_test_impl --release --features=into_bits,coresimd
cargo_test_impl --release --features=into_bits,core_arch
fi

# Verify code generation
Expand Down
8 changes: 6 additions & 2 deletions ci/runtest-android.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ use std::process::Command;
use std::path::{Path, PathBuf};

fn main() {
assert_eq!(env::args_os().len(), 2);
let test = PathBuf::from(env::args_os().nth(1).unwrap());
let args = env::args_os()
.skip(1)
.filter(|arg| arg != "--quiet")
.collect::<Vec<_>>();
assert_eq!(args.len(), 1);
let test = PathBuf::from(&args[0]);
let dst = Path::new("/data/local/tmp").join(test.file_name().unwrap());

let status = Command::new("adb")
Expand Down
2 changes: 1 addition & 1 deletion examples/aobench/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ criterion = { version = '^0.2', features=['real_blackbox'] }
default = [ "256bit" ]
256bit = []
sleef-sys = [ "packed_simd/sleef-sys" ]
coresimd = [ "packed_simd/coresimd" ]
core_arch = [ "packed_simd/core_arch" ]

[[bench]]
name = "isec_sphere"
Expand Down
2 changes: 1 addition & 1 deletion examples/mandelbrot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ path = "src/lib.rs"
[features]
default = []
sleef-sys = ["packed_simd/sleef-sys"]
coresimd = ["packed_simd/coresimd"]
core_arch = ["packed_simd/core_arch"]
5 changes: 5 additions & 0 deletions examples/nbody/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,8 @@ path = "src/main.rs"
[lib]
name = "nbody_lib"
path = "src/lib.rs"

[features]
default = [ ]
sleef-sys = [ "packed_simd/sleef-sys" ]
core_arch = [ "packed_simd/core_arch" ]
2 changes: 1 addition & 1 deletion examples/options_pricing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ path = "src/lib.rs"

[features]
default = []
coresimd = [ "packed_simd/coresimd" ]
core_arch = [ "packed_simd/core_arch" ]
sleef-sys = [ "packed_simd/sleef-sys" ]
ispc_libm = [ "ispc" ]
2 changes: 1 addition & 1 deletion examples/stencil/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ path = "src/lib.rs"

[features]
default = []
coresimd = ["packed_simd/coresimd"]
core_arch = ["packed_simd/core_arch"]
sleef-sys = ["packed_simd/sleef-sys"]
35 changes: 24 additions & 11 deletions src/api/bit_manip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ macro_rules! impl_bit_manip {
super::codegen::bit_manip::BitManip::ctpop(!self)
}

/// Returns the number of leading zeros in the binary representation
/// of the lanes of `self`.
/// Returns the number of leading zeros in the binary
/// representation of the lanes of `self`.
#[inline]
pub fn leading_zeros(self) -> Self {
super::codegen::bit_manip::BitManip::ctlz(self)
}

/// Returns the number of trailing zeros in the binary representation
/// of the lanes of `self`.
/// Returns the number of trailing zeros in the binary
/// representation of the lanes of `self`.
#[inline]
pub fn trailing_zeros(self) -> Self {
super::codegen::bit_manip::BitManip::cttz(self)
Expand All @@ -45,7 +45,10 @@ macro_rules! impl_bit_manip {
($x:expr, $func:ident) => {{
let mut actual = $x;
for i in 0..$id::lanes() {
actual = actual.replace(i, $x.extract(i).$func() as $elem_ty);
actual = actual.replace(
i,
$x.extract(i).$func() as $elem_ty
);
}
let expected = $x.$func();
assert_eq!(actual, expected);
Expand Down Expand Up @@ -73,39 +76,49 @@ macro_rules! impl_bit_manip {
$id::from_slice_unaligned(elems)
}

#[cfg_attr(not(target_arch = "wasm32"), test)] #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
#[cfg_attr(not(target_arch = "wasm32"), test)]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn count_ones() {
test_func!($id::splat(0), count_ones);
test_func!($id::splat(!0), count_ones);
test_func!(load_bytes(), count_ones);
}

#[cfg_attr(not(target_arch = "wasm32"), test)] #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
#[cfg_attr(not(target_arch = "wasm32"), test)]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn count_zeros() {
test_func!($id::splat(0), count_zeros);
test_func!($id::splat(!0), count_zeros);
test_func!(load_bytes(), count_zeros);
}

#[cfg_attr(not(target_arch = "wasm32"), test)] #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
#[cfg_attr(not(target_arch = "wasm32"), test)]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn leading_zeros() {
test_func!($id::splat(0), leading_zeros);
test_func!($id::splat(1), leading_zeros);
// some implementations use `pshufb` which has unique
// behavior when the 8th bit is set.
test_func!($id::splat(0b1000_0010), leading_zeros);
test_func!($id::splat(!0), leading_zeros);
test_func!($id::splat(1 << (LANE_WIDTH - 1)), leading_zeros);
test_func!(
$id::splat(1 << (LANE_WIDTH - 1)),
leading_zeros
);
test_func!(load_bytes(), leading_zeros);
}

#[cfg_attr(not(target_arch = "wasm32"), test)] #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
#[cfg_attr(not(target_arch = "wasm32"), test)]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn trailing_zeros() {
test_func!($id::splat(0), trailing_zeros);
test_func!($id::splat(1), trailing_zeros);
test_func!($id::splat(0b1000_0010), trailing_zeros);
test_func!($id::splat(!0), trailing_zeros);
test_func!($id::splat(1 << (LANE_WIDTH - 1)), trailing_zeros);
test_func!(
$id::splat(1 << (LANE_WIDTH - 1)),
trailing_zeros
);
test_func!(load_bytes(), trailing_zeros);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/api/from/from_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ macro_rules! impl_from_array {
}
*/

test_if!{
test_if! {
$test_tt:
paste::item! {
mod [<$id _from>] {
Expand Down
2 changes: 1 addition & 1 deletion src/api/from/from_vector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ macro_rules! impl_from_vector {
}
*/

test_if!{
test_if! {
$test_tt:
paste::item! {
pub mod [<$id _from_ $source>] {
Expand Down
Loading