@@ -88,6 +88,14 @@ macro_rules! multiversion {
8888 AVX2x4 => unsafe { $name:: avx2x4:: $name( $( $arg_name) ,* ) } ,
8989 #[ cfg( all( feature = "unsafe" , feature = "all-simd" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ]
9090 AVX2x8 => unsafe { $name:: avx2x8:: $name( $( $arg_name) ,* ) } ,
91+ #[ cfg( all( feature = "unsafe" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ]
92+ AVX512 => unsafe { $name:: avx512:: $name( $( $arg_name) ,* ) } ,
93+ #[ cfg( all( feature = "unsafe" , feature = "all-simd" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ]
94+ AVX512x2 => unsafe { $name:: avx512x2:: $name( $( $arg_name) ,* ) } ,
95+ #[ cfg( all( feature = "unsafe" , feature = "all-simd" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ]
96+ AVX512x4 => unsafe { $name:: avx512x4:: $name( $( $arg_name) ,* ) } ,
97+ #[ cfg( all( feature = "unsafe" , feature = "all-simd" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ]
98+ AVX512x8 => unsafe { $name:: avx512x8:: $name( $( $arg_name) ,* ) } ,
9199 #[ cfg( all( feature = "unsafe" , target_arch = "aarch64" ) ) ]
92100 Neon => unsafe { $name:: neon:: $name( $( $arg_name) ,* ) } ,
93101 #[ cfg( all( feature = "unsafe" , feature = "all-simd" , target_arch = "aarch64" ) ) ]
@@ -184,6 +192,42 @@ macro_rules! multiversion {
184192 $crate:: multiversion!{ @enable target_feature( enable = "avx2" ) $( $tail) * }
185193 }
186194
195+ /// [`multiversion!`] avx512 implementation.
196+ #[ cfg( all( feature = "unsafe" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ]
197+ pub mod avx512 {
198+ #[ allow( clippy:: allow_attributes, unused_imports, clippy:: wildcard_imports) ]
199+ use { super :: * , $( $( $path:: ) +avx512:: * ) ,* } ;
200+
201+ $crate:: multiversion!{ @enable target_feature( enable = "avx512f" ) $( $tail) * }
202+ }
203+
204+ /// [`multiversion!`] avx512x2 implementation.
205+ #[ cfg( all( feature = "unsafe" , feature = "all-simd" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ]
206+ pub mod avx512x2 {
207+ #[ allow( clippy:: allow_attributes, unused_imports, clippy:: wildcard_imports) ]
208+ use { super :: * , $( $( $path:: ) +avx512x2:: * ) ,* } ;
209+
210+ $crate:: multiversion!{ @enable target_feature( enable = "avx512f" ) $( $tail) * }
211+ }
212+
213+ /// [`multiversion!`] avx512x4 implementation.
214+ #[ cfg( all( feature = "unsafe" , feature = "all-simd" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ]
215+ pub mod avx512x4 {
216+ #[ allow( clippy:: allow_attributes, unused_imports, clippy:: wildcard_imports) ]
217+ use { super :: * , $( $( $path:: ) +avx512x4:: * ) ,* } ;
218+
219+ $crate:: multiversion!{ @enable target_feature( enable = "avx512f" ) $( $tail) * }
220+ }
221+
222+ /// [`multiversion!`] avx512x8 implementation.
223+ #[ cfg( all( feature = "unsafe" , feature = "all-simd" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ]
224+ pub mod avx512x8 {
225+ #[ allow( clippy:: allow_attributes, unused_imports, clippy:: wildcard_imports) ]
226+ use { super :: * , $( $( $path:: ) +avx512x8:: * ) ,* } ;
227+
228+ $crate:: multiversion!{ @enable target_feature( enable = "avx512f" ) $( $tail) * }
229+ }
230+
187231 /// [`multiversion!`] neon implementation.
188232 #[ cfg( all( feature = "unsafe" , target_arch = "aarch64" ) ) ]
189233 pub mod neon {
@@ -254,6 +298,14 @@ macro_rules! multiversion {
254298 AVX2x4 => unsafe { avx2x4:: $name( ) } ,
255299 #[ cfg( all( feature = "unsafe" , feature = "all-simd" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ]
256300 AVX2x8 => unsafe { avx2x8:: $name( ) } ,
301+ #[ cfg( all( feature = "unsafe" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ]
302+ AVX512 => unsafe { avx512:: $name( ) } ,
303+ #[ cfg( all( feature = "unsafe" , feature = "all-simd" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ]
304+ AVX512x2 => unsafe { avx512x2:: $name( ) } ,
305+ #[ cfg( all( feature = "unsafe" , feature = "all-simd" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ]
306+ AVX512x4 => unsafe { avx512x4:: $name( ) } ,
307+ #[ cfg( all( feature = "unsafe" , feature = "all-simd" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ]
308+ AVX512x8 => unsafe { avx512x8:: $name( ) } ,
257309 #[ cfg( all( feature = "unsafe" , target_arch = "aarch64" ) ) ]
258310 Neon => unsafe { neon:: $name( ) } ,
259311 #[ cfg( all( feature = "unsafe" , feature = "all-simd" , target_arch = "aarch64" ) ) ]
@@ -433,6 +485,70 @@ macro_rules! multiversion_test {
433485 unsafe { $body }
434486 }
435487
488+ #[ test]
489+ #[ cfg( all( feature = "unsafe" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ]
490+ $( #[ $m] ) *
491+ fn avx512( ) {
492+ #[ allow( clippy:: allow_attributes, unused_imports, clippy:: wildcard_imports) ]
493+ use { $( $( $path:: ) +avx512:: * ) ,* } ;
494+
495+ if !$crate:: multiversion:: Version :: AVX512 . supported( ) {
496+ use std:: io:: { stdout, Write } ;
497+ let _ = writeln!( & mut stdout( ) , "warning: skipping test in {}::avx512 due to missing avx512 support" , module_path!( ) ) ;
498+ return ;
499+ }
500+
501+ unsafe { $body }
502+ }
503+
504+ #[ test]
505+ #[ cfg( all( feature = "unsafe" , feature = "all-simd" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ]
506+ $( #[ $m] ) *
507+ fn avx512x2( ) {
508+ #[ allow( clippy:: allow_attributes, unused_imports, clippy:: wildcard_imports) ]
509+ use { $( $( $path:: ) +avx512x2:: * ) ,* } ;
510+
511+ if !$crate:: multiversion:: Version :: AVX512x2 . supported( ) {
512+ use std:: io:: { stdout, Write } ;
513+ let _ = writeln!( & mut stdout( ) , "warning: skipping test in {}::avx512x2 due to missing avx512 support" , module_path!( ) ) ;
514+ return ;
515+ }
516+
517+ unsafe { $body }
518+ }
519+
520+ #[ test]
521+ #[ cfg( all( feature = "unsafe" , feature = "all-simd" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ]
522+ $( #[ $m] ) *
523+ fn avx512x4( ) {
524+ #[ allow( clippy:: allow_attributes, unused_imports, clippy:: wildcard_imports) ]
525+ use { $( $( $path:: ) +avx512x4:: * ) ,* } ;
526+
527+ if !$crate:: multiversion:: Version :: AVX512x4 . supported( ) {
528+ use std:: io:: { stdout, Write } ;
529+ let _ = writeln!( & mut stdout( ) , "warning: skipping test in {}::avx512x4 due to missing avx512 support" , module_path!( ) ) ;
530+ return ;
531+ }
532+
533+ unsafe { $body }
534+ }
535+
536+ #[ test]
537+ #[ cfg( all( feature = "unsafe" , feature = "all-simd" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ]
538+ $( #[ $m] ) *
539+ fn avx512x8( ) {
540+ #[ allow( clippy:: allow_attributes, unused_imports, clippy:: wildcard_imports) ]
541+ use { $( $( $path:: ) +avx512x8:: * ) ,* } ;
542+
543+ if !$crate:: multiversion:: Version :: AVX512x8 . supported( ) {
544+ use std:: io:: { stdout, Write } ;
545+ let _ = writeln!( & mut stdout( ) , "warning: skipping test in {}::avx512x8 due to missing avx512 support" , module_path!( ) ) ;
546+ return ;
547+ }
548+
549+ unsafe { $body }
550+ }
551+
436552 #[ test]
437553 #[ cfg( all( feature = "unsafe" , target_arch = "aarch64" ) ) ]
438554 $( #[ $m] ) *
@@ -549,6 +665,40 @@ macro_rules! multiversion_test {
549665 }
550666 }
551667
668+ #[ cfg( all( feature = "unsafe" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ]
669+ if $crate:: multiversion:: Version :: AVX512 . supported( ) {
670+ unsafe {
671+ #[ allow( clippy:: allow_attributes, unused_imports, clippy:: wildcard_imports) ]
672+ use { $( $( $path:: ) +avx512:: * ) ,* } ;
673+
674+ $crate:: multiversion_test!( @expr { $( $tail) + } ) ;
675+ }
676+
677+ #[ cfg( feature = "all-simd" ) ]
678+ unsafe {
679+ #[ allow( clippy:: allow_attributes, unused_imports, clippy:: wildcard_imports) ]
680+ use { $( $( $path:: ) +avx512x2:: * ) ,* } ;
681+
682+ $crate:: multiversion_test!( @expr { $( $tail) + } ) ;
683+ }
684+
685+ #[ cfg( feature = "all-simd" ) ]
686+ unsafe {
687+ #[ allow( clippy:: allow_attributes, unused_imports, clippy:: wildcard_imports) ]
688+ use { $( $( $path:: ) +avx512x4:: * ) ,* } ;
689+
690+ $crate:: multiversion_test!( @expr { $( $tail) + } ) ;
691+ }
692+
693+ #[ cfg( feature = "all-simd" ) ]
694+ unsafe {
695+ #[ allow( clippy:: allow_attributes, unused_imports, clippy:: wildcard_imports) ]
696+ use { $( $( $path:: ) +avx512x8:: * ) ,* } ;
697+
698+ $crate:: multiversion_test!( @expr { $( $tail) + } ) ;
699+ }
700+ }
701+
552702 #[ cfg( all( feature = "unsafe" , target_arch = "aarch64" ) ) ]
553703 {
554704 unsafe {
@@ -647,6 +797,14 @@ versions_impl! {
647797 AVX2x4 if std:: arch:: is_x86_feature_detected!( "avx2" ) ,
648798 #[ cfg( all( feature = "unsafe" , feature = "all-simd" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ]
649799 AVX2x8 if std:: arch:: is_x86_feature_detected!( "avx2" ) ,
800+ #[ cfg( all( feature = "unsafe" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ]
801+ AVX512 if std:: arch:: is_x86_feature_detected!( "avx512f" ) ,
802+ #[ cfg( all( feature = "unsafe" , feature = "all-simd" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ]
803+ AVX512x2 if std:: arch:: is_x86_feature_detected!( "avx512f" ) ,
804+ #[ cfg( all( feature = "unsafe" , feature = "all-simd" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ]
805+ AVX512x4 if std:: arch:: is_x86_feature_detected!( "avx512f" ) ,
806+ #[ cfg( all( feature = "unsafe" , feature = "all-simd" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ]
807+ AVX512x8 if std:: arch:: is_x86_feature_detected!( "avx512f" ) ,
650808 #[ cfg( all( feature = "unsafe" , target_arch = "aarch64" ) ) ]
651809 Neon ,
652810 #[ cfg( all( feature = "unsafe" , feature = "all-simd" , target_arch = "aarch64" ) ) ]
0 commit comments