diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c3b9e85..bf58f44 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,7 +22,7 @@ env: CARGO_INCREMENTAL: 0 RUSTFLAGS: -D warnings RUSTDOCFLAGS: -D warnings - MINIMAL_RUST: 1.79.0 # Minimal Supported Rust Version + MINIMAL_RUST: 1.89.0 # Minimal Supported Rust Version jobs: # Workaround for github CI dropping env var expansion in matrix strategy diff --git a/CHANGELOG.md b/CHANGELOG.md index f6e8325..70433bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 _There are no unreleased changes in the pipeline at the moment._ +## [3.0.0] - 2025-10-04 + +### Changed + +- AVX-512 types do not require the `nightly` feature anymore +- Bumped MSRV to 1.89.0. + + ## [2.0.1] - 2025-05-04 ### Fixed @@ -34,7 +42,7 @@ _There are no unreleased changes in the pipeline at the moment._ ### Fixed -- Adapt nightly feature to latest nightly changes. +- Adapt `nightly` feature to latest nightly changes. ## [1.0.0] - 2024-01-05 @@ -44,7 +52,8 @@ _There are no unreleased changes in the pipeline at the moment._ - First tagged release of pessimize. -[Unreleased]: https://github.com/HadrienG2/pessimize/compare/v2.0.1...HEAD +[Unreleased]: https://github.com/HadrienG2/pessimize/compare/v3.0.0...HEAD +[3.0.0]: https://github.com/HadrienG2/pessimize/compare/v2.0.1...v3.0.0 [2.0.1]: https://github.com/HadrienG2/pessimize/compare/v2.0.0...v2.0.1 [2.0.0]: https://github.com/HadrienG2/pessimize/compare/v1.0.1...v2.0.0 [1.0.1]: https://github.com/HadrienG2/pessimize/compare/v1.0.0...v1.0.1 diff --git a/Cargo.lock b/Cargo.lock index af93a12..b15be37 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -89,9 +89,9 @@ dependencies = [ [[package]] name = "safe_arch" -version = "0.7.4" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96b02de82ddbe1b636e6170c21be622223aea188ef2e139be0a5b219ec215323" +checksum = "3fb5032219cc30e5bb98749b19a18ceb2cf15e24ba8d517a7e64dff4f1f1eca5" [[package]] name = "tempfile" diff --git a/Cargo.toml b/Cargo.toml index 5060af6..31c0d9f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ name = "pessimize" version = "2.0.1" authors = ["Hadrien G. "] edition = "2021" -rust-version = "1.79.0" +rust-version = "1.89.0" description = "More efficient Rust compiler optimization barriers" repository = "https://github.com/HadrienG2/pessimize/" license = "MPL-2.0" @@ -36,10 +36,10 @@ nightly = [] default_impl = ["nightly"] [dependencies] -safe_arch = { version = "0.7", optional = true } +safe_arch = { version = "0.9", optional = true } [dev-dependencies] -safe_arch = "0.7" +safe_arch = "0.9" tempfile = "3.20" [package.metadata.docs.rs] diff --git a/README.md b/README.md index 8c98024..4fdd9ca 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![Continuous Integration](https://img.shields.io/github/actions/workflow/status/HadrienG2/pessimize/ci.yml?branch=master)](https://github.com/HadrienG2/pessimize/actions?query=workflow%3A%22Continuous+Integration%22) ![Requires rustc -1.79.0+](https://img.shields.io/badge/rustc-1.79.0+-lightgray.svg) +1.89.0+](https://img.shields.io/badge/rustc-1.89.0+-lightgray.svg) Microbenchmarking is a subtle exercise to begin with, and the lack of lightweight optimization barriers on stable Rust makes it even more difficult. diff --git a/src/arch/x86_family.rs b/src/arch/x86_family.rs index 5e8deb4..8ea880e 100644 --- a/src/arch/x86_family.rs +++ b/src/arch/x86_family.rs @@ -11,15 +11,12 @@ use target_arch::CpuidResult; use target_arch::__m128; #[cfg(any(target_feature = "avx2", doc))] use target_arch::__m256i; -#[cfg(all( - feature = "nightly", - any(all(target_feature = "avx512vl", target_feature = "avx512bf16"), doc) -))] -use target_arch::{__m128bh, __m256bh}; #[cfg(any(target_feature = "sse2", doc))] use target_arch::{__m128d, __m128i}; #[cfg(any(target_feature = "avx", doc))] use target_arch::{__m256, __m256d}; +#[cfg(any(target_feature = "avx512f", doc))] +use target_arch::{__m512, __m512d, __m512i}; pessimize_asm_values!(allow(missing_docs) { reg_byte: (i8, u8), reg: (i16, u16, i32, u32, isize, usize) }); @@ -98,18 +95,16 @@ pessimize_asm_values!( ); /// AVX-512 specific functionality -#[cfg_attr( - feature = "nightly", - doc(cfg(all(feature = "nightly", target_feature = "avx512f"))) -)] -#[cfg(all(feature = "nightly", any(target_feature = "avx512f", doc)))] +#[cfg(any(target_feature = "avx512f", doc))] +#[cfg_attr(feature = "nightly", doc(cfg(target_feature = "avx512f")))] pub mod avx512 { use super::*; use crate::Pessimize; use core::arch::asm; #[cfg(any(target_feature = "avx512bf16", doc))] use target_arch::__m512bh; - use target_arch::{__m512, __m512d, __m512i}; + #[cfg(any(all(target_feature = "avx512vl", target_feature = "avx512bf16"), doc))] + use target_arch::{__m128bh, __m256bh}; // Basic register type support pessimize_asm_values!( @@ -152,7 +147,7 @@ pub mod avx512 { $( // This is one of the primitive Pessimize impls on which // the PessimizeCast/BorrowPessimize stack is built - #[$doc_cfg] + #[cfg_attr(feature = "nightly", $doc_cfg)] unsafe impl Pessimize for Mask<$mask_impl> { #[inline] fn hide(mut self) -> Self { @@ -206,6 +201,8 @@ mod safe_arch_types { use safe_arch::{m128d, m128i}; #[cfg(any(target_feature = "avx", doc))] use safe_arch::{m256, m256d}; + #[cfg(any(target_feature = "avx512f", doc))] + use safe_arch::{m512, m512d, m512i}; #[cfg(any(target_feature = "sse", doc))] pessimize_newtypes!( @@ -236,6 +233,16 @@ mod safe_arch_types { doc(cfg(all(feature = "safe_arch", target_feature = "avx2"))) { m256i{ __m256i } } ); + + #[cfg(any(target_feature = "avx512f", doc))] + pessimize_newtypes!( + doc(cfg(all(feature = "safe_arch", target_feature = "avx512f"))) + { + m512{ __m512 }, + m512d{ __m512d }, + m512i{ __m512i } + } + ); } // Support portable_simd if enabled @@ -731,12 +738,18 @@ mod tests { } } - #[cfg(all(feature = "nightly", target_feature = "avx512f"))] - mod avx512 { - use super::*; - - #[test] - fn avx512f() { + #[cfg(target_feature = "avx512f")] + #[test] + fn avx512f() { + use safe_arch::{m512, m512d, m512i}; + test_simd::(i32::MIN, i32::MAX); + test_simd::(u32::MIN, u32::MAX); + test_simd::(f32::MIN, f32::MAX); + test_simd::(i64::MIN, i64::MAX); + test_simd::(u64::MIN, u64::MAX); + test_simd::(f64::MIN, f64::MAX); + #[cfg(feature = "nightly")] + { portable_simd_tests!( (i32, 16), (u32, 16), @@ -746,21 +759,21 @@ mod tests { (f64, 8) ); portable_mask_tests!((i32, 16), (i64, 8)); - #[cfg(target_arch = "x86")] - { - portable_simd_tests!((isize, 16), (usize, 16)); - portable_mask_tests!((isize, 16)); - } - #[cfg(target_arch = "x86_64")] - { - portable_simd_tests!((isize, 8), (usize, 8)); - portable_mask_tests!((isize, 8)); - } + portable_simd_tests!((isize, 8), (usize, 8)); + portable_mask_tests!((isize, 8)); } + } - #[test] - #[ignore] - fn avx512f_optim() { + #[cfg(target_feature = "avx512f")] + #[test] + #[ignore] + fn avx512f_optim() { + use safe_arch::{m512, m512d, m512i}; + test_unoptimized_value_type::(); + test_unoptimized_value_type::(); + test_unoptimized_value_type::(); + #[cfg(feature = "nightly")] + { portable_simd_tests_optim!( (i32, 16), (u32, 16), @@ -770,26 +783,33 @@ mod tests { (f64, 8) ); portable_mask_tests_optim!((i32, 16), (i64, 8)); - #[cfg(target_arch = "x86")] - { - portable_simd_tests_optim!((isize, 16), (usize, 16)); - portable_mask_tests_optim!((isize, 16)); - } - #[cfg(target_arch = "x86_64")] - { - portable_simd_tests_optim!((isize, 8), (usize, 8)); - portable_mask_tests_optim!((isize, 8)); - } + portable_simd_tests_optim!((isize, 8), (usize, 8)); + portable_mask_tests_optim!((isize, 8)); } + } - #[cfg(target_feature = "avx512bw")] - #[test] - fn avx512bw() { + #[cfg(target_feature = "avx512bw")] + #[test] + fn avx512bw() { + use safe_arch::m512i; + test_simd::(i8::MIN, i8::MAX); + test_simd::(u8::MIN, u8::MAX); + test_simd::(i16::MIN, i16::MAX); + test_simd::(u16::MIN, u16::MAX); + #[cfg(feature = "nightly")] + { portable_simd_tests!((i8, 64), (u8, 64), (i16, 32), (u16, 32)); portable_mask_tests!((i8, 64), (i16, 32)); } + } + + // This is nightly-only even though the rest of avx512 is not nightly only + // anymore because we can't easily test without safe_arch or portable_simd + // and portable_simd doesn't have support for AVX-512 yet. + #[cfg(all(feature = "nightly", target_feature = "avx512bw"))] + mod avx512 { + use super::*; - #[cfg(target_feature = "avx512bw")] #[test] #[ignore] fn avx512bw_optim() {