Support AVX512 on stable Rust (#913)

Fixes #758
This commit is contained in:
Nazar Mokrynskyi 2026-06-29 17:44:40 +03:00 committed by GitHub
parent d995caf38f
commit 4cf8db2369
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 133 additions and 98 deletions

View file

@ -65,7 +65,7 @@ jobs:
run: cargo build -p ${{ matrix.crate }} --target thumbv7em-none-eabi --release --no-default-features run: cargo build -p ${{ matrix.crate }} --target thumbv7em-none-eabi --release --no-default-features
- name: no_std fiat / cargo hack ${{ matrix.crate }} - name: no_std fiat / cargo hack ${{ matrix.crate }}
env: env:
RUSTFLAGS: '--cfg curve25519_dalek_backend="fiat"' RUSTFLAGS: '--cfg curve25519_dalek_backend="fiat"'
run: cargo hack build -p ${{ matrix.crate }} --target thumbv7em-none-eabi --release --each-feature --exclude-features default,std,getrandom run: cargo hack build -p ${{ matrix.crate }} --target thumbv7em-none-eabi --release --each-feature --exclude-features default,std,getrandom
test-serial: test-serial:
@ -129,6 +129,24 @@ jobs:
RUSTFLAGS: '-C target_feature=+avx2' RUSTFLAGS: '-C target_feature=+avx2'
run: cargo test --no-default-features --features alloc,precomputed-tables,zeroize,group --target x86_64-unknown-linux-gnu run: cargo test --no-default-features --features alloc,precomputed-tables,zeroize,group --target x86_64-unknown-linux-gnu
test-avx512-sde:
name: Test avx512 backend under Intel SDE
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- uses: RustCrypto/actions/intel-sde-install@master
- name: Route the target through sde64
run: |
mkdir -p .cargo
echo '[target.x86_64-unknown-linux-gnu]' > .cargo/config.toml
echo 'runner = "sde64 -future --"' >> .cargo/config.toml
- env:
# avx512ifma + avx512vl are the two extensions curve25519-dalek's avx512 backend needs
RUSTFLAGS: '-C target_feature=+avx512ifma,+avx512vl'
RUSTDOCFLAGS: '-C target_feature=+avx512ifma,+avx512vl'
run: cargo test --target x86_64-unknown-linux-gnu
msrv: msrv:
name: Current MSRV is 1.85.0 name: Current MSRV is 1.85.0
runs-on: ubuntu-latest runs-on: ubuntu-latest

6
Cargo.lock generated
View file

@ -305,7 +305,7 @@ dependencies = [
[[package]] [[package]]
name = "curve25519-dalek" name = "curve25519-dalek"
version = "5.0.0-rc.0" version = "5.0.0-rc.1"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"cpufeatures", "cpufeatures",
@ -372,7 +372,7 @@ dependencies = [
[[package]] [[package]]
name = "ed25519-dalek" name = "ed25519-dalek"
version = "3.0.0-rc.0" version = "3.0.0-rc.1"
dependencies = [ dependencies = [
"blake2", "blake2",
"chacha20", "chacha20",
@ -1489,7 +1489,7 @@ dependencies = [
[[package]] [[package]]
name = "x25519-dalek" name = "x25519-dalek"
version = "3.0.0-rc.0" version = "3.0.0-rc.1"
dependencies = [ dependencies = [
"criterion", "criterion",
"curve25519-dalek", "curve25519-dalek",

View file

@ -117,6 +117,15 @@ pub fn unsafe_target_feature_specialize(
let ident = syn::Ident::new(&name, item_mod.ident.span()); let ident = syn::Ident::new(&name, item_mod.ident.span());
let mut attrs = item_mod.attrs.clone(); let mut attrs = item_mod.attrs.clone();
if let Some(condition) = attributes.condition() { if let Some(condition) = attributes.condition() {
// Build target_feature conditions for each feature
let target_features = features.iter().map(|feature| {
let feature_str = syn::LitStr::new(feature, attributes.lit().span());
quote::quote! { target_feature = #feature_str }
});
// Combine all conditions with 'all'
let cfg_tokens = quote::quote! { all(#(#target_features),*, #condition) };
attrs.push(syn::Attribute { attrs.push(syn::Attribute {
pound_token: Default::default(), pound_token: Default::default(),
style: syn::AttrStyle::Outer, style: syn::AttrStyle::Outer,
@ -124,7 +133,7 @@ pub fn unsafe_target_feature_specialize(
meta: syn::Meta::List(syn::MetaList { meta: syn::Meta::List(syn::MetaList {
path: syn::Ident::new("cfg", attributes.lit().span()).into(), path: syn::Ident::new("cfg", attributes.lit().span()).into(),
delimiter: syn::MacroDelimiter::Paren(Default::default()), delimiter: syn::MacroDelimiter::Paren(Default::default()),
tokens: condition.clone(), tokens: cfg_tokens,
}), }),
}); });
} }
@ -289,9 +298,22 @@ fn process_function(
function: syn::ItemFn, function: syn::ItemFn,
outer: Option<(syn::Generics, Box<syn::Type>)>, outer: Option<(syn::Generics, Box<syn::Type>)>,
) -> TokenStream { ) -> TokenStream {
// Split comma-separated features and create enable tokens for each
let (enable_features, target_features) = attributes
.value()
.split(',')
.map(|f| {
let feature_lit = syn::LitStr::new(f, attributes.span());
(
quote::quote! { enable = #feature_lit },
quote::quote! { target_feature = #feature_lit },
)
})
.unzip::<_, _, Vec<_>, Vec<_>>();
if function.sig.unsafety.is_some() { if function.sig.unsafety.is_some() {
return quote::quote! { return quote::quote! {
#[target_feature(enable = #attributes)] #[target_feature(#(#enable_features),*)]
#function #function
} }
.into(); .into();
@ -386,7 +408,7 @@ fn process_function(
} }
syn::Meta::Path(path) if is_path_eq(path, "test") => { syn::Meta::Path(path) if is_path_eq(path, "test") => {
maybe_outer_attributes.push(attribute); maybe_outer_attributes.push(attribute);
maybe_cfg = quote::quote! { #[cfg(target_feature = #attributes)] }; maybe_cfg = quote::quote! { #[cfg(all(#(#target_features),*))] };
} }
syn::Meta::List(syn::MetaList { path, tokens, .. }) syn::Meta::List(syn::MetaList { path, tokens, .. })
if is_path_eq(path, "inline") && tokens.to_string() == "always" => if is_path_eq(path, "inline") && tokens.to_string() == "always" =>
@ -428,7 +450,7 @@ fn process_function(
let item_trait_impl = quote::quote! { let item_trait_impl = quote::quote! {
impl #outer_impl_generics #trait_ident #outer_ty_generics for #self_ty #outer_where_clause { impl #outer_impl_generics #trait_ident #outer_ty_generics for #self_ty #outer_where_clause {
#[target_feature(enable = #attributes)] #[target_feature(#(#enable_features),*)]
#maybe_inline #maybe_inline
unsafe fn #function_inner_name #fn_impl_generics (#(#function_args_inner),*) #function_return #fn_where_clause #function_body unsafe fn #function_inner_name #fn_impl_generics (#(#function_args_inner),*) #function_return #fn_where_clause #function_body
} }
@ -451,7 +473,7 @@ fn process_function(
#maybe_cfg #maybe_cfg
#(#maybe_outer_attributes)* #(#maybe_outer_attributes)*
#function_visibility fn #function_name #fn_impl_generics (#(#function_args_outer),*) #function_return #fn_where_clause { #function_visibility fn #function_name #fn_impl_generics (#(#function_args_outer),*) #function_return #fn_where_clause {
#[target_feature(enable = #attributes)] #[target_feature(#(#enable_features),*)]
#maybe_inline #maybe_inline
unsafe fn #function_inner_name #fn_impl_generics (#(#function_args_inner),*) #function_return #fn_where_clause #function_body unsafe fn #function_inner_name #fn_impl_generics (#(#function_args_inner),*) #function_return #fn_where_clause #function_body
unsafe { unsafe {

View file

@ -81,7 +81,7 @@ curve25519-dalek-derive = "0.1"
level = "warn" level = "warn"
check-cfg = [ check-cfg = [
'cfg(allow_unused_unsafe)', 'cfg(allow_unused_unsafe)',
'cfg(curve25519_dalek_backend, values("fiat", "serial", "simd", "unstable_avx512"))', 'cfg(curve25519_dalek_backend, values("fiat", "serial", "simd", "avx512"))',
'cfg(curve25519_dalek_diagnostics, values("build"))', 'cfg(curve25519_dalek_diagnostics, values("build"))',
'cfg(curve25519_dalek_bits, values("32", "64"))', 'cfg(curve25519_dalek_bits, values("32", "64"))',
'cfg(nightly)', 'cfg(nightly)',

View file

@ -84,7 +84,7 @@ Curve arithmetic is implemented and used by one of the following backends:
| `serial` | Automatic | An optimized, non-parllel implementation | `32` and `64` | | `serial` | Automatic | An optimized, non-parllel implementation | `32` and `64` |
| `fiat` | Manual | Formally verified field arithmetic from [fiat-crypto] | `32` and `64` | | `fiat` | Manual | Formally verified field arithmetic from [fiat-crypto] | `32` and `64` |
| `simd` | Automatic | Intel AVX2 accelerated backend | `64` only | | `simd` | Automatic | Intel AVX2 accelerated backend | `64` only |
| `unstable_avx512` | Manual | Intel AVX512 IFMA accelerated backend (requires nightly) | `64` only | | `avx512` | Automatic | Intel AVX512 IFMA accelerated backend | `64` only |
At runtime, `curve25519-dalek` selects an arithmetic backend from the set of backends it was compiled to support. For Intel x86-64 targets, unless otherwise specified, it will build itself with `simd` support, and default to `serial` at runtime if the appropriate CPU features aren't detected. See [SIMD backend] for more details. At runtime, `curve25519-dalek` selects an arithmetic backend from the set of backends it was compiled to support. For Intel x86-64 targets, unless otherwise specified, it will build itself with `simd` support, and default to `serial` at runtime if the appropriate CPU features aren't detected. See [SIMD backend] for more details.
@ -138,16 +138,14 @@ $ cargo build --target i686-unknown-linux-gnu
## SIMD backend ## SIMD backend
When the `simd` backend is selected, the AVX2 or `serial` implementation is selected automatically at runtime, depending on the currently available CPU features. Similarly, when the `unstable_avx512` backend is selected, the AVX512 implementation is selected automatically at runtime if available, or else selection falls through to the aforementioned `simd` backend logic. When the `simd` backend is selected, the AVX2 or `serial` implementation is selected automatically at runtime, depending on the currently available CPU features. Similarly, when the `avx512` backend is selected, the AVX512 implementation is selected automatically at runtime if available, or else selection falls through to the aforementioned `simd` backend logic.
For a given CPU feature, you can also specify an appropriate `-C target_feature` to build a binary which assumes the required SIMD instructions are always available. Don't do this if you don't have a good reason. For a given CPU feature, you can also specify an appropriate `-C target_feature` to build a binary which assumes the required SIMD instructions are always available. Don't do this if you don't have a good reason.
| Backend | `RUSTFLAGS` | Requires nightly? | | Backend | `RUSTFLAGS` | Requires nightly? |
| :--- | :--- | :--- | | :--- | :--- | :--- |
| AVX2 | `-C target_feature=+avx2` | no | | AVX2 | `-C target_feature=+avx2` | no |
| AVX512 | `-C target_feature=+avx512ifma,+avx512vl` | yes | | AVX512 | `-C target_feature=+avx512ifma,+avx512vl` | yes if `<= 1.89` |
To reiterate, the `simd` backend will NOT use AVX512 code under any circumstance. The only way to enable AVX512 currently is to select the `unstable_avx512` backend and use a nightly compiler.
# Documentation # Documentation

View file

@ -3,7 +3,7 @@
#![deny(clippy::unwrap_used, dead_code)] #![deny(clippy::unwrap_used, dead_code)]
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
#[derive(PartialEq, Debug)] #[derive(PartialEq, Debug, Clone, Copy)]
enum DalekBits { enum DalekBits {
Dalek32, Dalek32,
Dalek64, Dalek64,
@ -21,6 +21,12 @@ impl std::fmt::Display for DalekBits {
} }
} }
fn target_has_feature(feature: &str) -> bool {
std::env::var("CARGO_CFG_TARGET_FEATURE")
.map(|features| features.split(',').any(|f| f == feature))
.unwrap_or(false)
}
fn main() { fn main() {
let target_arch = match std::env::var("CARGO_CFG_TARGET_ARCH") { let target_arch = match std::env::var("CARGO_CFG_TARGET_ARCH") {
Ok(arch) => arch, Ok(arch) => arch,
@ -35,17 +41,6 @@ fn main() {
println!("cargo:rustc-cfg=curve25519_dalek_bits=\"{curve25519_dalek_bits}\""); println!("cargo:rustc-cfg=curve25519_dalek_bits=\"{curve25519_dalek_bits}\"");
let nightly = if rustc_version::version_meta()
.expect("failed to detect rustc version")
.channel
== rustc_version::Channel::Nightly
{
println!("cargo:rustc-cfg=nightly");
true
} else {
false
};
let rustc_version = rustc_version::version().expect("failed to detect rustc version"); let rustc_version = rustc_version::version().expect("failed to detect rustc version");
if rustc_version.major == 1 && rustc_version.minor <= 64 { if rustc_version.major == 1 && rustc_version.minor <= 64 {
// Old versions of Rust complain when you have an `unsafe fn` and you use `unsafe {}` inside, // Old versions of Rust complain when you have an `unsafe fn` and you use `unsafe {}` inside,
@ -54,46 +49,45 @@ fn main() {
} }
// Backend overrides / defaults // Backend overrides / defaults
let curve25519_dalek_backend = match std::env::var("CARGO_CFG_CURVE25519_DALEK_BACKEND") let curve25519_dalek_backend =
.as_deref() match std::env::var("CARGO_CFG_CURVE25519_DALEK_BACKEND").as_deref() {
{ Ok("fiat") => "fiat",
Ok("fiat") => "fiat", Ok("serial") => "serial",
Ok("serial") => "serial", Ok("simd") => {
Ok("simd") => { // simd can only be enabled on x86_64 & 64bit target_pointer_width
// simd can only be enabled on x86_64 & 64bit target_pointer_width match is_capable_simd(&target_arch, curve25519_dalek_bits) {
match is_capable_simd(&target_arch, curve25519_dalek_bits) { true => "simd",
true => "simd", // If override is not possible this must result to compile error
// If override is not possible this must result to compile error // See: issues/532
// See: issues/532 false => panic!("Could not override curve25519_dalek_backend to simd"),
false => panic!("Could not override curve25519_dalek_backend to simd"),
}
}
Ok("unstable_avx512") if nightly => {
// simd can only be enabled on x86_64 & 64bit target_pointer_width
match is_capable_simd(&target_arch, curve25519_dalek_bits) {
true => {
// In addition enable Avx2 fallback through simd stable backend
// NOTE: Compiler permits duplicate / multi value on the same key
println!("cargo:rustc-cfg=curve25519_dalek_backend=\"simd\"");
"unstable_avx512"
} }
// If override is not possible this must result to compile error
// See: issues/532
false => panic!("Could not override curve25519_dalek_backend to unstable_avx512"),
} }
} Ok("avx512") => {
Ok("unstable_avx512") if !nightly => { // AVX-512 can only be enabled on x86_64 & 64bit target_pointer_width
panic!( match is_capable_simd(&target_arch, curve25519_dalek_bits) {
"Could not override curve25519_dalek_backend to unstable_avx512, as this is nightly only" true => {
); // Enable SIMD as fallback through stable backend
} // NOTE: Compiler permits duplicate / multi value on the same key
// default between serial / simd (if potentially capable) println!("cargo:rustc-cfg=curve25519_dalek_backend=\"simd\"");
_ => match is_capable_simd(&target_arch, curve25519_dalek_bits) { "avx512"
true => "simd", }
false => "serial", // If override is not possible this must result to compile error
}, // See: issues/532
}; false => panic!("Could not override curve25519_dalek_backend to avx512"),
}
}
// default between serial / simd / avx512 (if potentially capable)
_ => match is_capable_avx512(&target_arch, curve25519_dalek_bits, rustc_version) {
true => {
println!("cargo:rustc-cfg=curve25519_dalek_backend=\"simd\"");
"avx512"
}
false => match is_capable_simd(&target_arch, curve25519_dalek_bits) {
true => "simd",
false => "serial",
},
},
};
println!("cargo:rustc-cfg=curve25519_dalek_backend=\"{curve25519_dalek_backend}\""); println!("cargo:rustc-cfg=curve25519_dalek_backend=\"{curve25519_dalek_backend}\"");
} }
@ -102,6 +96,24 @@ fn is_capable_simd(arch: &str, bits: DalekBits) -> bool {
arch == "x86_64" && bits == DalekBits::Dalek64 arch == "x86_64" && bits == DalekBits::Dalek64
} }
// Is the target arch & curve25519_dalek_bits potentially AVX-512 capable ?
fn is_capable_avx512(arch: &str, bits: DalekBits, rustc_version: rustc_version::Version) -> bool {
// AVX-512 requires rustc >=1.89 or nightly
if rustc_version.major == 1 && rustc_version.minor < 89 {
let channel = rustc_version::version_meta()
.expect("failed to detect rustc version")
.channel;
if channel != rustc_version::Channel::Nightly {
return false;
}
}
is_capable_simd(arch, bits)
&& target_has_feature("avx512ifma")
&& target_has_feature("avx512vl")
}
// Deterministic cfg(curve25519_dalek_bits) when this is not explicitly set. // Deterministic cfg(curve25519_dalek_bits) when this is not explicitly set.
mod deterministic { mod deterministic {

View file

@ -46,14 +46,14 @@ pub mod vector;
enum BackendKind { enum BackendKind {
#[cfg(curve25519_dalek_backend = "simd")] #[cfg(curve25519_dalek_backend = "simd")]
Avx2, Avx2,
#[cfg(all(curve25519_dalek_backend = "unstable_avx512", nightly))] #[cfg(curve25519_dalek_backend = "avx512")]
Avx512, Avx512,
Serial, Serial,
} }
#[inline] #[inline]
fn get_selected_backend() -> BackendKind { fn get_selected_backend() -> BackendKind {
#[cfg(all(curve25519_dalek_backend = "unstable_avx512", nightly))] #[cfg(curve25519_dalek_backend = "avx512")]
{ {
cpufeatures::new!(cpuid_avx512, "avx512ifma", "avx512vl"); cpufeatures::new!(cpuid_avx512, "avx512ifma", "avx512vl");
let token_avx512: cpuid_avx512::InitToken = cpuid_avx512::init(); let token_avx512: cpuid_avx512::InitToken = cpuid_avx512::init();
@ -88,7 +88,7 @@ where
#[cfg(curve25519_dalek_backend = "simd")] #[cfg(curve25519_dalek_backend = "simd")]
BackendKind::Avx2 => BackendKind::Avx2 =>
vector::scalar_mul::pippenger::spec_avx2::Pippenger::optional_multiscalar_mul::<I, J>(scalars, points), vector::scalar_mul::pippenger::spec_avx2::Pippenger::optional_multiscalar_mul::<I, J>(scalars, points),
#[cfg(all(curve25519_dalek_backend = "unstable_avx512", nightly))] #[cfg(curve25519_dalek_backend = "avx512")]
BackendKind::Avx512 => BackendKind::Avx512 =>
vector::scalar_mul::pippenger::spec_avx512ifma_avx512vl::Pippenger::optional_multiscalar_mul::<I, J>(scalars, points), vector::scalar_mul::pippenger::spec_avx512ifma_avx512vl::Pippenger::optional_multiscalar_mul::<I, J>(scalars, points),
BackendKind::Serial => BackendKind::Serial =>
@ -100,7 +100,7 @@ where
pub(crate) enum VartimePrecomputedStraus { pub(crate) enum VartimePrecomputedStraus {
#[cfg(curve25519_dalek_backend = "simd")] #[cfg(curve25519_dalek_backend = "simd")]
Avx2(vector::scalar_mul::precomputed_straus::spec_avx2::VartimePrecomputedStraus), Avx2(vector::scalar_mul::precomputed_straus::spec_avx2::VartimePrecomputedStraus),
#[cfg(all(curve25519_dalek_backend = "unstable_avx512", nightly))] #[cfg(curve25519_dalek_backend = "avx512")]
Avx512ifma( Avx512ifma(
vector::scalar_mul::precomputed_straus::spec_avx512ifma_avx512vl::VartimePrecomputedStraus, vector::scalar_mul::precomputed_straus::spec_avx512ifma_avx512vl::VartimePrecomputedStraus,
), ),
@ -120,7 +120,7 @@ impl VartimePrecomputedStraus {
#[cfg(curve25519_dalek_backend = "simd")] #[cfg(curve25519_dalek_backend = "simd")]
BackendKind::Avx2 => BackendKind::Avx2 =>
VartimePrecomputedStraus::Avx2(vector::scalar_mul::precomputed_straus::spec_avx2::VartimePrecomputedStraus::new(static_points)), VartimePrecomputedStraus::Avx2(vector::scalar_mul::precomputed_straus::spec_avx2::VartimePrecomputedStraus::new(static_points)),
#[cfg(all(curve25519_dalek_backend = "unstable_avx512", nightly))] #[cfg(curve25519_dalek_backend = "avx512")]
BackendKind::Avx512 => BackendKind::Avx512 =>
VartimePrecomputedStraus::Avx512ifma(vector::scalar_mul::precomputed_straus::spec_avx512ifma_avx512vl::VartimePrecomputedStraus::new(static_points)), VartimePrecomputedStraus::Avx512ifma(vector::scalar_mul::precomputed_straus::spec_avx512ifma_avx512vl::VartimePrecomputedStraus::new(static_points)),
BackendKind::Serial => BackendKind::Serial =>
@ -135,7 +135,7 @@ impl VartimePrecomputedStraus {
match self { match self {
#[cfg(curve25519_dalek_backend = "simd")] #[cfg(curve25519_dalek_backend = "simd")]
VartimePrecomputedStraus::Avx2(inner) => inner.len(), VartimePrecomputedStraus::Avx2(inner) => inner.len(),
#[cfg(all(curve25519_dalek_backend = "unstable_avx512", nightly))] #[cfg(curve25519_dalek_backend = "avx512")]
VartimePrecomputedStraus::Avx512ifma(inner) => inner.len(), VartimePrecomputedStraus::Avx512ifma(inner) => inner.len(),
VartimePrecomputedStraus::Scalar(inner) => inner.len(), VartimePrecomputedStraus::Scalar(inner) => inner.len(),
} }
@ -148,7 +148,7 @@ impl VartimePrecomputedStraus {
match self { match self {
#[cfg(curve25519_dalek_backend = "simd")] #[cfg(curve25519_dalek_backend = "simd")]
VartimePrecomputedStraus::Avx2(inner) => inner.is_empty(), VartimePrecomputedStraus::Avx2(inner) => inner.is_empty(),
#[cfg(all(curve25519_dalek_backend = "unstable_avx512", nightly))] #[cfg(curve25519_dalek_backend = "avx512")]
VartimePrecomputedStraus::Avx512ifma(inner) => inner.is_empty(), VartimePrecomputedStraus::Avx512ifma(inner) => inner.is_empty(),
VartimePrecomputedStraus::Scalar(inner) => inner.is_empty(), VartimePrecomputedStraus::Scalar(inner) => inner.is_empty(),
} }
@ -176,7 +176,7 @@ impl VartimePrecomputedStraus {
dynamic_scalars, dynamic_scalars,
dynamic_points, dynamic_points,
), ),
#[cfg(all(curve25519_dalek_backend = "unstable_avx512", nightly))] #[cfg(curve25519_dalek_backend = "avx512")]
VartimePrecomputedStraus::Avx512ifma(inner) => inner.optional_mixed_multiscalar_mul( VartimePrecomputedStraus::Avx512ifma(inner) => inner.optional_mixed_multiscalar_mul(
static_scalars, static_scalars,
dynamic_scalars, dynamic_scalars,
@ -207,7 +207,7 @@ where
BackendKind::Avx2 => { BackendKind::Avx2 => {
vector::scalar_mul::straus::spec_avx2::Straus::multiscalar_mul::<I, J>(scalars, points) vector::scalar_mul::straus::spec_avx2::Straus::multiscalar_mul::<I, J>(scalars, points)
} }
#[cfg(all(curve25519_dalek_backend = "unstable_avx512", nightly))] #[cfg(curve25519_dalek_backend = "avx512")]
BackendKind::Avx512 => { BackendKind::Avx512 => {
vector::scalar_mul::straus::spec_avx512ifma_avx512vl::Straus::multiscalar_mul::<I, J>( vector::scalar_mul::straus::spec_avx512ifma_avx512vl::Straus::multiscalar_mul::<I, J>(
scalars, points, scalars, points,
@ -236,7 +236,7 @@ where
scalars, points, scalars, points,
) )
} }
#[cfg(all(curve25519_dalek_backend = "unstable_avx512", nightly))] #[cfg(curve25519_dalek_backend = "avx512")]
BackendKind::Avx512 => { BackendKind::Avx512 => {
vector::scalar_mul::straus::spec_avx512ifma_avx512vl::Straus::optional_multiscalar_mul::< vector::scalar_mul::straus::spec_avx512ifma_avx512vl::Straus::optional_multiscalar_mul::<
I, I,
@ -254,7 +254,7 @@ pub fn variable_base_mul(point: &EdwardsPoint, scalar: &Scalar) -> EdwardsPoint
match get_selected_backend() { match get_selected_backend() {
#[cfg(curve25519_dalek_backend = "simd")] #[cfg(curve25519_dalek_backend = "simd")]
BackendKind::Avx2 => vector::scalar_mul::variable_base::spec_avx2::mul(point, scalar), BackendKind::Avx2 => vector::scalar_mul::variable_base::spec_avx2::mul(point, scalar),
#[cfg(all(curve25519_dalek_backend = "unstable_avx512", nightly))] #[cfg(curve25519_dalek_backend = "avx512")]
BackendKind::Avx512 => { BackendKind::Avx512 => {
vector::scalar_mul::variable_base::spec_avx512ifma_avx512vl::mul(point, scalar) vector::scalar_mul::variable_base::spec_avx512ifma_avx512vl::mul(point, scalar)
} }
@ -268,7 +268,7 @@ pub fn vartime_double_base_mul(a: &Scalar, A: &EdwardsPoint, b: &Scalar) -> Edwa
match get_selected_backend() { match get_selected_backend() {
#[cfg(curve25519_dalek_backend = "simd")] #[cfg(curve25519_dalek_backend = "simd")]
BackendKind::Avx2 => vector::scalar_mul::vartime_double_base::spec_avx2::mul(a, A, b), BackendKind::Avx2 => vector::scalar_mul::vartime_double_base::spec_avx2::mul(a, A, b),
#[cfg(all(curve25519_dalek_backend = "unstable_avx512", nightly))] #[cfg(curve25519_dalek_backend = "avx512")]
BackendKind::Avx512 => { BackendKind::Avx512 => {
vector::scalar_mul::vartime_double_base::spec_avx512ifma_avx512vl::mul(a, A, b) vector::scalar_mul::vartime_double_base::spec_avx512ifma_avx512vl::mul(a, A, b)
} }

View file

@ -16,7 +16,7 @@ pub mod packed_simd;
pub mod avx2; pub mod avx2;
#[cfg(all(curve25519_dalek_backend = "unstable_avx512", nightly))] #[cfg(curve25519_dalek_backend = "avx512")]
pub mod ifma; pub mod ifma;
pub mod scalar_mul; pub mod scalar_mul;

View file

@ -11,10 +11,7 @@
#[curve25519_dalek_derive::unsafe_target_feature_specialize( #[curve25519_dalek_derive::unsafe_target_feature_specialize(
"avx2", "avx2",
conditional( conditional("avx512ifma,avx512vl", curve25519_dalek_backend = "avx512")
"avx512ifma,avx512vl",
all(curve25519_dalek_backend = "unstable_avx512", nightly)
)
)] )]
pub mod spec { pub mod spec {

View file

@ -13,10 +13,7 @@
#[curve25519_dalek_derive::unsafe_target_feature_specialize( #[curve25519_dalek_derive::unsafe_target_feature_specialize(
"avx2", "avx2",
conditional( conditional("avx512ifma,avx512vl", curve25519_dalek_backend = "avx512")
"avx512ifma,avx512vl",
all(curve25519_dalek_backend = "unstable_avx512", nightly)
)
)] )]
pub mod spec { pub mod spec {

View file

@ -13,10 +13,7 @@
#[curve25519_dalek_derive::unsafe_target_feature_specialize( #[curve25519_dalek_derive::unsafe_target_feature_specialize(
"avx2", "avx2",
conditional( conditional("avx512ifma,avx512vl", curve25519_dalek_backend = "avx512")
"avx512ifma,avx512vl",
all(curve25519_dalek_backend = "unstable_avx512", nightly)
)
)] )]
pub mod spec { pub mod spec {

View file

@ -2,10 +2,7 @@
#[curve25519_dalek_derive::unsafe_target_feature_specialize( #[curve25519_dalek_derive::unsafe_target_feature_specialize(
"avx2", "avx2",
conditional( conditional("avx512ifma,avx512vl", curve25519_dalek_backend = "avx512")
"avx512ifma,avx512vl",
all(curve25519_dalek_backend = "unstable_avx512", nightly)
)
)] )]
pub mod spec { pub mod spec {

View file

@ -13,10 +13,7 @@
#[curve25519_dalek_derive::unsafe_target_feature_specialize( #[curve25519_dalek_derive::unsafe_target_feature_specialize(
"avx2", "avx2",
conditional( conditional("avx512ifma,avx512vl", curve25519_dalek_backend = "avx512")
"avx512ifma,avx512vl",
all(curve25519_dalek_backend = "unstable_avx512", nightly)
)
)] )]
pub mod spec { pub mod spec {