Skip to content

Commit ef4d36b

Browse files
committed
Finish avx-512 support by bundling safe_arch upgrade
1 parent 2723d76 commit ef4d36b

File tree

1 file changed

+61
-38
lines changed

1 file changed

+61
-38
lines changed

src/arch/x86_family.rs

Lines changed: 61 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ use target_arch::__m256i;
1515
use target_arch::{__m128d, __m128i};
1616
#[cfg(any(target_feature = "avx", doc))]
1717
use target_arch::{__m256, __m256d};
18+
#[cfg(any(target_feature = "avx512f", doc))]
19+
use target_arch::{__m512, __m512d, __m512i};
1820

1921
pessimize_asm_values!(allow(missing_docs) { reg_byte: (i8, u8), reg: (i16, u16, i32, u32, isize, usize) });
2022

@@ -93,8 +95,8 @@ pessimize_asm_values!(
9395
);
9496

9597
/// AVX-512 specific functionality
96-
#[doc(cfg(target_feature = "avx512f"))]
9798
#[cfg(any(target_feature = "avx512f", doc))]
99+
#[cfg_attr(feature = "nightly", doc(cfg(target_feature = "avx512f")))]
98100
pub mod avx512 {
99101
use super::*;
100102
use crate::Pessimize;
@@ -146,7 +148,7 @@ pub mod avx512 {
146148
$(
147149
// This is one of the primitive Pessimize impls on which
148150
// the PessimizeCast/BorrowPessimize stack is built
149-
#[$doc_cfg]
151+
#[cfg_attr(feature = "nightly", $doc_cfg)]
150152
unsafe impl Pessimize for Mask<$mask_impl> {
151153
#[inline]
152154
fn hide(mut self) -> Self {
@@ -200,6 +202,8 @@ mod safe_arch_types {
200202
use safe_arch::{m128d, m128i};
201203
#[cfg(any(target_feature = "avx", doc))]
202204
use safe_arch::{m256, m256d};
205+
#[cfg(any(target_feature = "avx512f", doc))]
206+
use safe_arch::{m512, m512d, m512i};
203207

204208
#[cfg(any(target_feature = "sse", doc))]
205209
pessimize_newtypes!(
@@ -230,6 +234,16 @@ mod safe_arch_types {
230234
doc(cfg(all(feature = "safe_arch", target_feature = "avx2")))
231235
{ m256i{ __m256i } }
232236
);
237+
238+
#[cfg(any(target_feature = "avx512f", doc))]
239+
pessimize_newtypes!(
240+
doc(cfg(all(feature = "safe_arch", target_feature = "avx512f")))
241+
{
242+
m512{ __m512 },
243+
m512d{ __m512d },
244+
m512i{ __m512i }
245+
}
246+
);
233247
}
234248

235249
// Support portable_simd if enabled
@@ -725,15 +739,18 @@ mod tests {
725739
}
726740
}
727741

728-
// This is nightly-only even though the rest of avx512 is not nightly only
729-
// anymore because we can't easily test without safe_arch or portable_simd
730-
// and portable_simd doesn't have support for AVX-512 yet.
731-
#[cfg(all(feature = "nightly", target_feature = "avx512f"))]
732-
mod avx512 {
733-
use super::*;
734-
735-
#[test]
736-
fn avx512f() {
742+
#[cfg(target_feature = "avx512f")]
743+
#[test]
744+
fn avx512f() {
745+
use safe_arch::{m512, m512d, m512i};
746+
test_simd::<i32, 16, m512i>(i32::MIN, i32::MAX);
747+
test_simd::<u32, 16, m512i>(u32::MIN, u32::MAX);
748+
test_simd::<f32, 16, m512>(f32::MIN, f32::MAX);
749+
test_simd::<i64, 8, m512i>(i64::MIN, i64::MAX);
750+
test_simd::<u64, 8, m512i>(u64::MIN, u64::MAX);
751+
test_simd::<f64, 8, m512d>(f64::MIN, f64::MAX);
752+
#[cfg(feature = "nightly")]
753+
{
737754
portable_simd_tests!(
738755
(i32, 16),
739756
(u32, 16),
@@ -743,21 +760,21 @@ mod tests {
743760
(f64, 8)
744761
);
745762
portable_mask_tests!((i32, 16), (i64, 8));
746-
#[cfg(target_arch = "x86")]
747-
{
748-
portable_simd_tests!((isize, 16), (usize, 16));
749-
portable_mask_tests!((isize, 16));
750-
}
751-
#[cfg(target_arch = "x86_64")]
752-
{
753-
portable_simd_tests!((isize, 8), (usize, 8));
754-
portable_mask_tests!((isize, 8));
755-
}
763+
portable_simd_tests!((isize, 8), (usize, 8));
764+
portable_mask_tests!((isize, 8));
756765
}
766+
}
757767

758-
#[test]
759-
#[ignore]
760-
fn avx512f_optim() {
768+
#[cfg(target_feature = "avx512f")]
769+
#[test]
770+
#[ignore]
771+
fn avx512f_optim() {
772+
use safe_arch::{m512, m512d, m512i};
773+
test_unoptimized_value_type::<m512>();
774+
test_unoptimized_value_type::<m512d>();
775+
test_unoptimized_value_type::<m512i>();
776+
#[cfg(feature = "nightly")]
777+
{
761778
portable_simd_tests_optim!(
762779
(i32, 16),
763780
(u32, 16),
@@ -767,26 +784,32 @@ mod tests {
767784
(f64, 8)
768785
);
769786
portable_mask_tests_optim!((i32, 16), (i64, 8));
770-
#[cfg(target_arch = "x86")]
771-
{
772-
portable_simd_tests_optim!((isize, 16), (usize, 16));
773-
portable_mask_tests_optim!((isize, 16));
774-
}
775-
#[cfg(target_arch = "x86_64")]
776-
{
777-
portable_simd_tests_optim!((isize, 8), (usize, 8));
778-
portable_mask_tests_optim!((isize, 8));
779-
}
787+
portable_simd_tests_optim!((isize, 8), (usize, 8));
788+
portable_mask_tests_optim!((isize, 8));
780789
}
790+
}
781791

782-
#[cfg(target_feature = "avx512bw")]
783-
#[test]
784-
fn avx512bw() {
792+
#[cfg(target_feature = "avx512bw")]
793+
#[test]
794+
fn avx512bw() {
795+
test_simd::<i8, 64, m512i>(i8::MIN, i8::MAX);
796+
test_simd::<u8, 64, m512i>(u8::MIN, u8::MAX);
797+
test_simd::<i16, 32, m512i>(i16::MIN, i16::MAX);
798+
test_simd::<u16, 32, m512i>(u16::MIN, u16::MAX);
799+
#[cfg(feature = "nightly")]
800+
{
785801
portable_simd_tests!((i8, 64), (u8, 64), (i16, 32), (u16, 32));
786802
portable_mask_tests!((i8, 64), (i16, 32));
787803
}
804+
}
805+
806+
// This is nightly-only even though the rest of avx512 is not nightly only
807+
// anymore because we can't easily test without safe_arch or portable_simd
808+
// and portable_simd doesn't have support for AVX-512 yet.
809+
#[cfg(all(feature = "nightly", target_feature = "avx512bw"))]
810+
mod avx512 {
811+
use super::*;
788812

789-
#[cfg(target_feature = "avx512bw")]
790813
#[test]
791814
#[ignore]
792815
fn avx512bw_optim() {

0 commit comments

Comments
 (0)