From ff48859fda6b7b18a2cf0bbcd988fe66ea1cd1df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduardo=20S=C3=A1nchez=20Mu=C3=B1oz?= Date: Thu, 28 Sep 2023 18:50:22 +0200 Subject: [PATCH] Test stdarch (only x86 SSE and SSE2 for now) --- .github/workflows/ci.yml | 9 ++++++ Cargo.toml | 1 + ci-test.sh | 9 ++++++ run-stdarch-test.sh | 62 ++++++++++++++++++++++++++++++++++++++++ rust-version | 2 +- 5 files changed, 82 insertions(+), 1 deletion(-) create mode 100755 run-stdarch-test.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 59f28a1..0d5c3a8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -47,6 +47,15 @@ jobs: - name: Test run: bash ./ci-test.sh simd + test-stdarch: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Setup environment + run: bash ./ci-setup.sh + - name: Test + run: bash ./ci-test.sh stdarch + # Send a Zulip notification when a cron job fails cron-fail-notify: name: cronjob failure notification diff --git a/Cargo.toml b/Cargo.toml index 9217752..acaab28 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,4 +8,5 @@ members = [ exclude = [ # stdarch has its own Cargo workspace "library/stdarch", + "rust-src-patched/library/stdarch", ] diff --git a/ci-test.sh b/ci-test.sh index 8256abd..4cc514a 100644 --- a/ci-test.sh +++ b/ci-test.sh @@ -104,6 +104,15 @@ simd) 2>&1 | ts -i '%.s ' echo "::endgroup::" ;; +stdarch) + for TARGET in x86_64-unknown-linux-gnu i686-unknown-linux-gnu; do + echo "::group::Testing stdarch ($TARGET)" + MIRIFLAGS="$DEFAULTFLAGS" \ + ./run-stdarch-test.sh $TARGET \ + 2>&1 | ts -i '%.s ' + echo "::endgroup::" + done + ;; *) echo "Unknown command" exit 1 diff --git a/run-stdarch-test.sh b/run-stdarch-test.sh new file mode 100755 index 0000000..2dab68e --- /dev/null +++ b/run-stdarch-test.sh @@ -0,0 +1,62 @@ +#!/bin/bash +set -euo pipefail + +## Run stdarch test suite with Miri. +## Assumes Miri to be installed. +## Usage: +## ./run-test.sh TARGET +## Environment variables: +## MIRI_LIB_SRC: The path to the Rust library directory (`library`). +## RUSTFLAGS: rustc flags (optional) +## MIRIFLAGS: Miri flags (optional) + +if [ $# -ne 1 ]; then + echo "Usage: $0 TARGET" + exit 1 +fi + +export TARGET="$1" + +case "$TARGET" in +i586-*|i686-*|x86_64-*) + RUSTFLAGS="-C target-feature=+sse2" + TEST_ARGS=( + core_arch::x86::{sse,sse2}:: + core_arch::x86_64::{sse,sse2}:: + # FIXME add `#[cfg_attr(miri, ignore)]` to those tests in stdarch + --skip test_mm_comieq_ss_vs_ucomieq_ss + --skip test_mm_getcsr_setcsr_1 + --skip test_mm_getcsr_setcsr_2 + --skip test_mm_getcsr_setcsr_underflow + --skip test_mm_sfence + --skip test_mm_stream_ps + --skip test_mm_clflush + --skip test_mm_lfence + --skip test_mm_madd_epi16 # FIXME not yet implemented + --skip test_mm_maskmoveu_si128 + --skip test_mm_mfence + --skip test_mm_stream_pd + --skip test_mm_stream_si128 + --skip test_mm_stream_si32 + --skip test_mm_stream_si64 + # FIXME fix those in stdarch + --skip test_mm_rcp_ss # __m128(0.24997461, 13.0, 16.0, 100.0) != __m128(0.24993896, 13.0, 16.0, 100.0) + --skip test_mm_store1_ps # attempt to subtract with overflow + --skip test_mm_store_ps # attempt to subtract with overflow + --skip test_mm_storer_ps # attempt to subtract with overflow + ) + ;; +*) + echo "Unknown target $TARGET" + exit 1 +esac + +export RUSTFLAGS="${RUSTFLAGS:-} -Ainternal_features" + +# Make sure all tested target features are enabled +export STDARCH_TEST_EVERYTHING=1 +# Needed to pass the STDARCH_TEST_EVERYTHING environment variable +export MIRIFLAGS="${MIRIFLAGS:-} -Zmiri-disable-isolation" + +cd $MIRI_LIB_SRC/stdarch +cargo miri test --manifest-path=crates/core_arch/Cargo.toml -- "${TEST_ARGS[@]}" diff --git a/rust-version b/rust-version index c383f0f..0bc9639 100644 --- a/rust-version +++ b/rust-version @@ -1 +1 @@ -nightly-2023-08-16 +nightly-2023-09-28