binius_field/arch/
arch_optimal.rs

1// Copyright 2024-2025 Irreducible Inc.
2
3use cfg_if::cfg_if;
4
5cfg_if! {
6	if #[cfg(all(target_arch = "x86_64", target_feature = "avx512f"))] {
7		pub const OPTIMAL_ALIGNMENT: usize = 512;
8
9		pub type OptimalPackedB1 = crate::PackedBinaryField512x1b;
10		pub type OptimalPackedB128 = crate::PackedBinaryGhash4x128b;
11		pub type OptimalB128 = crate::BinaryField128bGhash;
12
13	} else if #[cfg(all(target_arch = "x86_64", target_feature = "avx2"))] {
14		pub const OPTIMAL_ALIGNMENT: usize = 256;
15
16		pub type OptimalPackedB1 = crate::PackedBinaryField256x1b;
17		pub type OptimalPackedB128 = crate::PackedBinaryGhash2x128b;
18		pub type OptimalB128 = crate::BinaryField128bGhash;
19	} else if #[cfg(all(target_arch = "x86_64", target_feature = "sse2"))] {
20		pub const OPTIMAL_ALIGNMENT: usize = 128;
21
22		pub type OptimalPackedB1 = crate::PackedBinaryField128x1b;
23		pub type OptimalPackedB128 = crate::PackedBinaryGhash1x128b;
24		pub type OptimalB128 = crate::BinaryField128bGhash;
25	} else if #[cfg(all(target_arch = "aarch64", target_feature = "neon", target_feature = "aes"))] {
26		pub const OPTIMAL_ALIGNMENT: usize = 128;
27
28		pub type OptimalPackedB1 = crate::PackedBinaryField128x1b;
29		pub type OptimalPackedB128 = crate::PackedBinaryGhash1x128b;
30		pub type OptimalB128 = crate::BinaryField128bGhash;
31	} else {
32		pub const OPTIMAL_ALIGNMENT: usize = 128;
33
34		pub type OptimalPackedB1 = crate::PackedBinaryField128x1b;
35		pub type OptimalPackedB128 = crate::PackedBinaryGhash1x128b;
36		pub type OptimalB128 = crate::BinaryField128bGhash;
37	}
38}