Skip to content
Open
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
1 change: 1 addition & 0 deletions ci/intrinsic-test-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ run() {
--env NORUN \
--env RUSTFLAGS \
--env CARGO_UNSTABLE_BUILD_STD \
--env TEST_SAMPLE_INTRINSICS_PERCENTAGE \
--volume "${HOME}/.cargo":/cargo \
--volume "$(rustc --print sysroot)":/rust:ro \
--volume "$(pwd)":/checkout:ro \
Expand Down
15 changes: 10 additions & 5 deletions ci/intrinsic-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,28 +51,31 @@ case ${TARGET} in
TEST_SKIP_INTRINSICS=crates/intrinsic-test/missing_aarch64.txt
TEST_CXX_COMPILER="clang++"
TEST_RUNNER="${CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUNNER}"
: "${TEST_SAMPLE_INTRINSICS_PERCENTAGE:=100}"
;;

aarch64_be-unknown-linux-gnu*)
TEST_CPPFLAGS="-fuse-ld=lld"
TEST_SKIP_INTRINSICS=crates/intrinsic-test/missing_aarch64.txt
TEST_CXX_COMPILER="clang++"
TEST_RUNNER="${CARGO_TARGET_AARCH64_BE_UNKNOWN_LINUX_GNU_RUNNER}"
: "${TEST_SAMPLE_INTRINSICS_PERCENTAGE:=100}"
;;

armv7-unknown-linux-gnueabihf*)
TEST_CPPFLAGS="-fuse-ld=lld -I/usr/arm-linux-gnueabihf/include/ -I/usr/arm-linux-gnueabihf/include/c++/9/arm-linux-gnueabihf/"
TEST_SKIP_INTRINSICS=crates/intrinsic-test/missing_arm.txt
TEST_CXX_COMPILER="clang++"
TEST_RUNNER="${CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_RUNNER}"
: "${TEST_SAMPLE_INTRINSICS_PERCENTAGE:=100}"
;;

x86_64-unknown-linux-gnu*)
TEST_CPPFLAGS="-fuse-ld=lld -I/usr/include/x86_64-linux-gnu/"
TEST_CXX_COMPILER="clang++"
TEST_RUNNER="${CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER}"
TEST_SKIP_INTRINSICS=crates/intrinsic-test/missing_x86.txt
TEST_SAMPLE_INTRINSICS_PERCENTAGE=5
: "${TEST_SAMPLE_INTRINSICS_PERCENTAGE:=5}"
;;
*)
;;
Expand All @@ -82,23 +85,25 @@ esac
# Arm specific
case "${TARGET}" in
aarch64-unknown-linux-gnu*|armv7-unknown-linux-gnueabihf*)
CPPFLAGS="${TEST_CPPFLAGS}" RUSTFLAGS="${HOST_RUSTFLAGS}" RUST_LOG=warn \
CPPFLAGS="${TEST_CPPFLAGS}" RUSTFLAGS="${HOST_RUSTFLAGS}" RUST_LOG=info \
cargo run "${INTRINSIC_TEST}" "${PROFILE}" \
--bin intrinsic-test -- intrinsics_data/arm_intrinsics.json \
--runner "${TEST_RUNNER}" \
--cppcompiler "${TEST_CXX_COMPILER}" \
--skip "${TEST_SKIP_INTRINSICS}" \
--target "${TARGET}"
--target "${TARGET}" \
--sample-percentage "${TEST_SAMPLE_INTRINSICS_PERCENTAGE}"
;;

aarch64_be-unknown-linux-gnu*)
CPPFLAGS="${TEST_CPPFLAGS}" RUSTFLAGS="${HOST_RUSTFLAGS}" RUST_LOG=warn \
CPPFLAGS="${TEST_CPPFLAGS}" RUSTFLAGS="${HOST_RUSTFLAGS}" RUST_LOG=info \
cargo run "${INTRINSIC_TEST}" "${PROFILE}" \
--bin intrinsic-test -- intrinsics_data/arm_intrinsics.json \
--runner "${TEST_RUNNER}" \
--cppcompiler "${TEST_CXX_COMPILER}" \
--skip "${TEST_SKIP_INTRINSICS}" \
--target "${TARGET}" \
--sample-percentage "${TEST_SAMPLE_INTRINSICS_PERCENTAGE}" \
--linker "${CARGO_TARGET_AARCH64_BE_UNKNOWN_LINUX_GNU_LINKER}" \
--cxx-toolchain-dir "${AARCH64_BE_TOOLCHAIN}"
;;
Expand All @@ -109,7 +114,7 @@ case "${TARGET}" in
# Hence the use of `env -u`.
env -u CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER \
CPPFLAGS="${TEST_CPPFLAGS}" RUSTFLAGS="${HOST_RUSTFLAGS}" \
RUST_LOG=warn RUST_BACKTRACE=1 \
RUST_LOG=info RUST_BACKTRACE=1 \
cargo run "${INTRINSIC_TEST}" "${PROFILE}" \
--bin intrinsic-test -- intrinsics_data/x86-intel.xml \
--runner "${TEST_RUNNER}" \
Expand Down
8 changes: 6 additions & 2 deletions crates/intrinsic-test/src/arm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,12 @@ impl SupportedArchitectureTest for ArmArchitectureTest {
.expect("Error parsing input file");

intrinsics.sort_by(|a, b| a.name.cmp(&b.name));
intrinsics.dedup();

let sample_percentage: usize = cli_options.sample_percentage as usize;
let sample_size = (intrinsics.len() * sample_percentage) / 100;

let mut intrinsics = intrinsics
let intrinsics = intrinsics
.into_iter()
// Not sure how we would compare intrinsic that returns void.
.filter(|i| i.results.kind() != TypeKind::Void)
Expand All @@ -61,8 +65,8 @@ impl SupportedArchitectureTest for ArmArchitectureTest {
.filter(|i| !i.arguments.iter().any(|a| a.ty.inner_size() == 128))
.filter(|i| !cli_options.skip.contains(&i.name))
.filter(|i| !(a32 && i.arch_tags == vec!["A64".to_string()]))
.take(sample_size)
.collect::<Vec<_>>();
intrinsics.dedup();

Self {
intrinsics,
Expand Down
6 changes: 5 additions & 1 deletion crates/intrinsic-test/src/common/compare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ pub fn compare_outputs(intrinsic_name_list: &Vec<String>, runner: &str, target:
println!("Failed to run rust program for intrinsic {intrinsic}")
}
});
println!("{} differences found", intrinsics.len());
println!(
"{} differences found (tested {} intrinsics)",
intrinsics.len(),
intrinsic_name_list.len()
);
intrinsics.is_empty()
}
12 changes: 8 additions & 4 deletions crates/intrinsic-test/src/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,16 @@ pub trait SupportedArchitectureTest {
trace!("compiling mod_{i}.cpp");
if let Some(cpp_compiler) = cpp_compiler_wrapped.as_ref() {
let compile_output = cpp_compiler
.compile_object_file(&format!("mod_{i}.cpp"), &format!("mod_{i}.o"));
.compile_object_file(&format!("mod_{i}.cpp"), &format!("mod_{i}.o"))
.map_err(|e| format!("Error compiling mod_{i}.cpp: {e:?}"))?;

assert!(
compile_output.status.success(),
"{}",
String::from_utf8_lossy(&compile_output.stderr)
);

trace!("finished compiling mod_{i}.cpp");
if let Err(compile_error) = compile_output {
return Err(format!("Error compiling mod_{i}.cpp: {compile_error:?}"));
}
}
Ok(())
})
Expand Down
2 changes: 1 addition & 1 deletion crates/intrinsic-test/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fn run(test_environment: impl SupportedArchitectureTest) {
if !test_environment.build_rust_file() {
std::process::exit(3);
}
info!("comaparing outputs");
info!("comparing outputs");
if !test_environment.compare_outputs() {
std::process::exit(1);
}
Expand Down
15 changes: 7 additions & 8 deletions crates/intrinsic-test/src/x86/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use crate::common::compile_c::CppCompilation;
use crate::common::intrinsic::Intrinsic;
use crate::common::intrinsic_helpers::TypeKind;
use intrinsic::X86IntrinsicType;
use itertools::Itertools;
use xml_parser::get_xml_intrinsics;

pub struct X86ArchitectureTest {
Expand Down Expand Up @@ -44,12 +43,16 @@ impl SupportedArchitectureTest for X86ArchitectureTest {
const PLATFORM_RUST_CFGS: &str = config::PLATFORM_RUST_CFGS;

fn create(cli_options: ProcessedCli) -> Self {
let intrinsics =
let mut intrinsics =
get_xml_intrinsics(&cli_options.filename).expect("Error parsing input file");

intrinsics.sort_by(|a, b| a.name.cmp(&b.name));
intrinsics.dedup_by(|a, b| a.name == b.name);

let sample_percentage: usize = cli_options.sample_percentage as usize;
let sample_size = (intrinsics.len() * sample_percentage) / 100;

let mut intrinsics = intrinsics
let intrinsics = intrinsics
.into_iter()
// Not sure how we would compare intrinsic that returns void.
.filter(|i| i.results.kind() != TypeKind::Void)
Expand All @@ -61,13 +64,9 @@ impl SupportedArchitectureTest for X86ArchitectureTest {
.filter(|i| !i.arguments.iter().any(|a| a.is_ptr()))
.filter(|i| !i.arguments.iter().any(|a| a.ty.inner_size() == 128))
.filter(|i| !cli_options.skip.contains(&i.name))
.unique_by(|i| i.name.clone())
.take(sample_size)
.collect::<Vec<_>>();

let sample_size = (intrinsics.len() * sample_percentage) / 100;
intrinsics.truncate(sample_size);

intrinsics.sort_by(|a, b| a.name.cmp(&b.name));
Self {
intrinsics: intrinsics,
cli_options: cli_options,
Expand Down