Skip to content

workaround llvm mips bug; enable msa on ci #41

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

Closed
wants to merge 2 commits into from
Closed
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
2 changes: 1 addition & 1 deletion ci/docker/mips64-unknown-linux-gnuabi64/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
gcc-mips64-linux-gnuabi64 libc6-dev-mips64-cross \
qemu-system-mips64 qemu-user

ENV CARGO_TARGET_MIPS64_UNKNOWN_LINUX_GNUABI64_LINKER=mips64-linux-gnuabi64-gcc \
ENV CARGO_TARGET_MIPS64_UNKNOWN_LINUX_GNUABI64_LINKER="mips64-linux-gnuabi64-gcc --with-mips-arch-variant=r6" \
CARGO_TARGET_MIPS64_UNKNOWN_LINUX_GNUABI64_RUNNER="qemu-mips64 -L /usr/mips64-linux-gnuabi64" \
OBJDUMP=mips64-linux-gnuabi64-objdump
2 changes: 1 addition & 1 deletion ci/docker/mips64el-unknown-linux-gnuabi64/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
gcc-mips64el-linux-gnuabi64 libc6-dev-mips64el-cross \
qemu-system-mips64el

ENV CARGO_TARGET_MIPS64EL_UNKNOWN_LINUX_GNUABI64_LINKER=mips64el-linux-gnuabi64-gcc \
ENV CARGO_TARGET_MIPS64EL_UNKNOWN_LINUX_GNUABI64_LINKER="mips64el-linux-gnuabi64-gcc --with-mips-arch-variant=r6" \
CARGO_TARGET_MIPS64EL_UNKNOWN_LINUX_GNUABI64_RUNNER="qemu-mips64el -L /usr/mips64el-linux-gnuabi64" \
OBJDUMP=mips64el-linux-gnuabi64-objdump
7 changes: 2 additions & 5 deletions ci/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,8 @@ case ${TARGET} in
cargo_test
cargo_test "--release" "--features=into_bits"

# FIXME: this doesn't compile succesfully
# https://github.com/rust-lang-nursery/packed_simd/issues/18
#
# export RUSTFLAGS="${RUSTFLAGS} -C target-feature=+msa -C target-cpu=mips64r6"
# cargo_test "--release" "--features=into_bits"
export RUSTFLAGS="${RUSTFLAGS} -C target-feature=+msa -C target-cpu=mips64r6"
cargo_test "--release" "--features=into_bits"
;;
powerpc-*)
cargo_test
Expand Down
125 changes: 73 additions & 52 deletions src/api/reductions/min_max.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,66 +2,79 @@

macro_rules! impl_reduction_min_max {
([$elem_ty:ident; $elem_count:expr]: $id:ident) => {
impl $id {
/// Largest vector element value.
#[inline]
pub fn max_element(self) -> $elem_ty {
#[cfg(not(any(target_arch = "aarch64", target_arch = "arm")))]
{
use llvm::simd_reduce_max;
unsafe { simd_reduce_max(self.0) }
cfg_if! {
if #[cfg(any(
target_arch = "aarch64",
target_arch = "arm",
all(any(target_arch = "mips",
target_arch = "mips64"),
target_feature = "msa")
))] {
impl $id {
/// Largest vector element value.
#[inline]
pub fn max_element(self) -> $elem_ty {
// FIXME: broken on AArch64
// https://github.com/rust-lang-nursery/packed_simd/issues/15
// FIXME: broken on MIPS
// https://github.com/rust-lang-nursery/packed_simd/issues/18
let mut x = self.extract(0);
for i in 1..$id::lanes() {
x = x.max(self.extract(i));
}
x
}
}
#[cfg(any(target_arch = "aarch64", target_arch = "arm"))]
{
// FIXME: broken on AArch64
// https://github.com/rust-lang-nursery/packed_simd/issues/15
let mut x = self.extract(0);
for i in 1..$id::lanes() {
x = x.max(self.extract(i));
} else {
impl $id {
/// Largest vector element value.
#[inline]
pub fn max_element(self) -> $elem_ty {
use llvm::simd_reduce_max;
unsafe { simd_reduce_max(self.0) }
}
x
}
}
}

/// Smallest vector element value.
#[inline]
pub fn min_element(self) -> $elem_ty {
#[cfg(
not(
any(
target_arch = "aarch64",
target_arch = "arm",
all(
target_arch = "x86",
not(target_feature = "sse2")
)
)
)
)]
{
use llvm::simd_reduce_min;
unsafe { simd_reduce_min(self.0) }
cfg_if! {
if #[cfg(any(
target_arch = "aarch64",
target_arch = "arm",
all(any(target_arch = "mips", target_arch = "mips64"),
target_feature = "msa"),
all(target_arch = "x86", not(target_feature = "sse2"))
))]
{
impl $id {
/// Smallest vector element value.
#[inline]
pub fn min_element(self) -> $elem_ty {
// FIXME: broken on AArch64
// https://github.com/rust-lang-nursery/packed_simd/issues/15
// FIXME: broken on i586-unknown-linux-gnu
// https://github.com/rust-lang-nursery/packed_simd/issues/22
// FIXME: broken on MIPS
// https://github.com/rust-lang-nursery/packed_simd/issues/18
let mut x = self.extract(0);
for i in 1..$id::lanes() {
x = x.min(self.extract(i));
}
x
}
}
#[cfg(
any(
target_arch = "aarch64",
target_arch = "arm",
all(target_arch = "x86", not(target_feature = "sse2"))
)
)]
{
// FIXME: broken on AArch64
// https://github.com/rust-lang-nursery/packed_simd/issues/15
// FIXME: broken on i586-unknown-linux-gnu
// https://github.com/rust-lang-nursery/packed_simd/issues/22
let mut x = self.extract(0);
for i in 1..$id::lanes() {
x = x.min(self.extract(i));
} else {
impl $id {
/// Smallest vector element value.
#[inline]
pub fn min_element(self) -> $elem_ty {
use llvm::simd_reduce_min;
unsafe { simd_reduce_min(self.0) }
}
x
}
}
}

#[cfg(test)]
interpolate_idents! {
mod [$id _reduction_min_max] {
Expand All @@ -75,7 +88,7 @@ macro_rules! impl_reduction_min_max {
assert_eq!(v.max_element(), 1 as $elem_ty);
}
let v = v.replace(0, 2 as $elem_ty);
assert_eq!(v.max_element(), 2 as $elem_ty);
assert_eq!(v.max_element(), 2 as $elem_ty);
}

#[test]
Expand Down Expand Up @@ -121,6 +134,10 @@ macro_rules! test_reduction_float_min_max {

let target_with_broken_last_lane_nan = !cfg!(any(
target_arch = "arm", target_arch = "aarch64",
all(
any(target_arch = "mips",target_arch = "mips64"),
target_feature = "msa"
),
all(target_arch = "x86", not(target_feature = "sse2"))
));

Expand Down Expand Up @@ -223,7 +240,11 @@ macro_rules! test_reduction_float_min_max {
let v0 = $id::splat(-3.);

let target_with_broken_last_lane_nan = !cfg!(any(
target_arch = "arm", target_arch = "aarch64"
target_arch = "arm", target_arch = "aarch64",
all(
any(target_arch = "mips",target_arch = "mips64"),
target_feature = "msa"
)
));

// The vector is initialized to `-3.`s: [-3, -3, -3, -3]
Expand Down