@@ -89,6 +89,14 @@ macro_rules! multiversion {
8989 AVX2x4 => unsafe { $name:: avx2x4:: $name( $( $arg_name) ,* ) } ,
9090 #[ cfg( all( feature = "unsafe" , feature = "all-simd" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ]
9191 AVX2x8 => unsafe { $name:: avx2x8:: $name( $( $arg_name) ,* ) } ,
92+ #[ cfg( all( feature = "unsafe" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ]
93+ AVX512 => unsafe { $name:: avx512:: $name( $( $arg_name) ,* ) } ,
94+ #[ cfg( all( feature = "unsafe" , feature = "all-simd" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ]
95+ AVX512x2 => unsafe { $name:: avx512x2:: $name( $( $arg_name) ,* ) } ,
96+ #[ cfg( all( feature = "unsafe" , feature = "all-simd" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ]
97+ AVX512x4 => unsafe { $name:: avx512x4:: $name( $( $arg_name) ,* ) } ,
98+ #[ cfg( all( feature = "unsafe" , feature = "all-simd" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ]
99+ AVX512x8 => unsafe { $name:: avx512x8:: $name( $( $arg_name) ,* ) } ,
92100 }
93101 }
94102 } ;
@@ -184,6 +192,50 @@ macro_rules! multiversion {
184192
185193 $crate:: multiversion!{ @helper target_feature( enable = "avx2" ) $( $tail) * }
186194 }
195+
196+ /// [`multiversion!`] avx512 implementation.
197+ #[ cfg( all( feature = "unsafe" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ]
198+ pub mod avx512 {
199+ #![ allow( clippy:: missing_safety_doc) ]
200+
201+ #[ allow( clippy:: allow_attributes, unused_imports, clippy:: wildcard_imports) ]
202+ use { super :: * , $( $( $path:: ) +avx512:: * ) ,* } ;
203+
204+ $crate:: multiversion!{ @helper target_feature( enable = "avx512f" ) $( $tail) * }
205+ }
206+
207+ /// [`multiversion!`] avx512x2 implementation.
208+ #[ cfg( all( feature = "unsafe" , feature = "all-simd" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ]
209+ pub mod avx512x2 {
210+ #![ allow( clippy:: missing_safety_doc) ]
211+
212+ #[ allow( clippy:: allow_attributes, unused_imports, clippy:: wildcard_imports) ]
213+ use { super :: * , $( $( $path:: ) +avx512x2:: * ) ,* } ;
214+
215+ $crate:: multiversion!{ @helper target_feature( enable = "avx512f" ) $( $tail) * }
216+ }
217+
218+ /// [`multiversion!`] avx512x4 implementation.
219+ #[ cfg( all( feature = "unsafe" , feature = "all-simd" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ]
220+ pub mod avx512x4 {
221+ #![ allow( clippy:: missing_safety_doc) ]
222+
223+ #[ allow( clippy:: allow_attributes, unused_imports, clippy:: wildcard_imports) ]
224+ use { super :: * , $( $( $path:: ) +avx512x4:: * ) ,* } ;
225+
226+ $crate:: multiversion!{ @helper target_feature( enable = "avx512f" ) $( $tail) * }
227+ }
228+
229+ /// [`multiversion!`] avx512x8 implementation.
230+ #[ cfg( all( feature = "unsafe" , feature = "all-simd" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ]
231+ pub mod avx512x8 {
232+ #![ allow( clippy:: missing_safety_doc) ]
233+
234+ #[ allow( clippy:: allow_attributes, unused_imports, clippy:: wildcard_imports) ]
235+ use { super :: * , $( $( $path:: ) +avx512x8:: * ) ,* } ;
236+
237+ $crate:: multiversion!{ @helper target_feature( enable = "avx512f" ) $( $tail) * }
238+ }
187239 } ;
188240
189241 // Microbenchmark for dynamic dispatch
@@ -219,6 +271,14 @@ macro_rules! multiversion {
219271 AVX2x4 => unsafe { avx2x4:: $name( ) } ,
220272 #[ cfg( all( feature = "unsafe" , feature = "all-simd" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ]
221273 AVX2x8 => unsafe { avx2x8:: $name( ) } ,
274+ #[ cfg( all( feature = "unsafe" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ]
275+ AVX512 => unsafe { avx512:: $name( ) } ,
276+ #[ cfg( all( feature = "unsafe" , feature = "all-simd" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ]
277+ AVX512x2 => unsafe { avx512x2:: $name( ) } ,
278+ #[ cfg( all( feature = "unsafe" , feature = "all-simd" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ]
279+ AVX512x4 => unsafe { avx512x4:: $name( ) } ,
280+ #[ cfg( all( feature = "unsafe" , feature = "all-simd" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ]
281+ AVX512x8 => unsafe { avx512x8:: $name( ) } ,
222282 } ) ;
223283 ( start. elapsed( ) , x)
224284 } )
@@ -395,6 +455,70 @@ macro_rules! multiversion_test {
395455
396456 unsafe { $body }
397457 }
458+
459+ #[ test]
460+ #[ cfg( all( feature = "unsafe" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ]
461+ $( #[ $m] ) *
462+ fn avx512( ) {
463+ #[ allow( clippy:: allow_attributes, unused_imports, clippy:: wildcard_imports) ]
464+ use { $( $( $path:: ) +avx512:: * ) ,* } ;
465+
466+ if !$crate:: multiversion:: Version :: AVX512 . supported( ) {
467+ use std:: io:: { stdout, Write } ;
468+ let _ = writeln!( & mut stdout( ) , "warning: skipping test in {}::avx512 due to missing avx512 support" , module_path!( ) ) ;
469+ return ;
470+ }
471+
472+ unsafe { $body }
473+ }
474+
475+ #[ test]
476+ #[ cfg( all( feature = "unsafe" , feature = "all-simd" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ]
477+ $( #[ $m] ) *
478+ fn avx512x2( ) {
479+ #[ allow( clippy:: allow_attributes, unused_imports, clippy:: wildcard_imports) ]
480+ use { $( $( $path:: ) +avx512x2:: * ) ,* } ;
481+
482+ if !$crate:: multiversion:: Version :: AVX512x2 . supported( ) {
483+ use std:: io:: { stdout, Write } ;
484+ let _ = writeln!( & mut stdout( ) , "warning: skipping test in {}::avx512x2 due to missing avx512 support" , module_path!( ) ) ;
485+ return ;
486+ }
487+
488+ unsafe { $body }
489+ }
490+
491+ #[ test]
492+ #[ cfg( all( feature = "unsafe" , feature = "all-simd" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ]
493+ $( #[ $m] ) *
494+ fn avx512x4( ) {
495+ #[ allow( clippy:: allow_attributes, unused_imports, clippy:: wildcard_imports) ]
496+ use { $( $( $path:: ) +avx512x4:: * ) ,* } ;
497+
498+ if !$crate:: multiversion:: Version :: AVX512x4 . supported( ) {
499+ use std:: io:: { stdout, Write } ;
500+ let _ = writeln!( & mut stdout( ) , "warning: skipping test in {}::avx512x4 due to missing avx512 support" , module_path!( ) ) ;
501+ return ;
502+ }
503+
504+ unsafe { $body }
505+ }
506+
507+ #[ test]
508+ #[ cfg( all( feature = "unsafe" , feature = "all-simd" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ]
509+ $( #[ $m] ) *
510+ fn avx512x8( ) {
511+ #[ allow( clippy:: allow_attributes, unused_imports, clippy:: wildcard_imports) ]
512+ use { $( $( $path:: ) +avx512x8:: * ) ,* } ;
513+
514+ if !$crate:: multiversion:: Version :: AVX512x8 . supported( ) {
515+ use std:: io:: { stdout, Write } ;
516+ let _ = writeln!( & mut stdout( ) , "warning: skipping test in {}::avx512x8 due to missing avx512 support" , module_path!( ) ) ;
517+ return ;
518+ }
519+
520+ unsafe { $body }
521+ }
398522 } ;
399523
400524 (
@@ -471,6 +595,40 @@ macro_rules! multiversion_test {
471595 $crate:: multiversion_test!( @expr { $( $tail) + } ) ;
472596 }
473597 }
598+
599+ #[ cfg( all( feature = "unsafe" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ]
600+ if $crate:: multiversion:: Version :: AVX512 . supported( ) {
601+ unsafe {
602+ #[ allow( clippy:: allow_attributes, unused_imports, clippy:: wildcard_imports) ]
603+ use { $( $( $path:: ) +avx512:: * ) ,* } ;
604+
605+ $crate:: multiversion_test!( @expr { $( $tail) + } ) ;
606+ }
607+
608+ #[ cfg( feature = "all-simd" ) ]
609+ unsafe {
610+ #[ allow( clippy:: allow_attributes, unused_imports, clippy:: wildcard_imports) ]
611+ use { $( $( $path:: ) +avx512x2:: * ) ,* } ;
612+
613+ $crate:: multiversion_test!( @expr { $( $tail) + } ) ;
614+ }
615+
616+ #[ cfg( feature = "all-simd" ) ]
617+ unsafe {
618+ #[ allow( clippy:: allow_attributes, unused_imports, clippy:: wildcard_imports) ]
619+ use { $( $( $path:: ) +avx512x4:: * ) ,* } ;
620+
621+ $crate:: multiversion_test!( @expr { $( $tail) + } ) ;
622+ }
623+
624+ #[ cfg( feature = "all-simd" ) ]
625+ unsafe {
626+ #[ allow( clippy:: allow_attributes, unused_imports, clippy:: wildcard_imports) ]
627+ use { $( $( $path:: ) +avx512x8:: * ) ,* } ;
628+
629+ $crate:: multiversion_test!( @expr { $( $tail) + } ) ;
630+ }
631+ }
474632 } ;
475633 ( @expr $e: expr) => { $e }
476634}
@@ -536,6 +694,14 @@ versions_impl! {
536694 AVX2x4 if std:: arch:: is_x86_feature_detected!( "avx2" ) ,
537695 #[ cfg( all( feature = "unsafe" , feature = "all-simd" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ]
538696 AVX2x8 if std:: arch:: is_x86_feature_detected!( "avx2" ) ,
697+ #[ cfg( all( feature = "unsafe" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ]
698+ AVX512 if std:: arch:: is_x86_feature_detected!( "avx512f" ) ,
699+ #[ cfg( all( feature = "unsafe" , feature = "all-simd" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ]
700+ AVX512x2 if std:: arch:: is_x86_feature_detected!( "avx512f" ) ,
701+ #[ cfg( all( feature = "unsafe" , feature = "all-simd" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ]
702+ AVX512x4 if std:: arch:: is_x86_feature_detected!( "avx512f" ) ,
703+ #[ cfg( all( feature = "unsafe" , feature = "all-simd" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ]
704+ AVX512x8 if std:: arch:: is_x86_feature_detected!( "avx512f" ) ,
539705}
540706
541707static OVERRIDE : OnceLock < Option < Version > > = OnceLock :: new ( ) ;
0 commit comments