Skip to content

Commit

Permalink
fixed config flags for unpacked to pre-verification
Browse files Browse the repository at this point in the history
  • Loading branch information
karthikbhargavan committed Jul 1, 2024
1 parent f6b0243 commit f592ce3
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 57 deletions.
15 changes: 9 additions & 6 deletions libcrux-ml-kem/benches/ml-kem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub fn comparisons_key_generation(c: &mut Criterion) {
})
});

#[cfg(feature = "simd256")]
#[cfg(all(feature = "mlkem768", feature = "pre-verification", feature = "simd256"))]
group.bench_function("libcrux avx2 unpacked (external random)", |b| {
let mut seed = [0; 64];
rng.fill_bytes(&mut seed);
Expand All @@ -29,7 +29,7 @@ pub fn comparisons_key_generation(c: &mut Criterion) {
})
});

#[cfg(feature = "simd128")]
#[cfg(all(feature = "mlkem768", feature = "pre-verification", feature = "simd128"))]
group.bench_function("libcrux neon unpacked (external random)", |b| {
let mut seed = [0; 64];
rng.fill_bytes(&mut seed);
Expand All @@ -38,6 +38,7 @@ pub fn comparisons_key_generation(c: &mut Criterion) {
})
});

#[cfg(all(feature = "mlkem768", feature = "pre-verification"))]
group.bench_function("libcrux portable unpacked (external random)", |b| {
let mut seed = [0; 64];
rng.fill_bytes(&mut seed);
Expand Down Expand Up @@ -87,6 +88,7 @@ pub fn comparisons_encapsulation(c: &mut Criterion) {
)
});

#[cfg(all(feature = "mlkem768", feature = "pre-verification"))]
group.bench_function("libcrux unpacked portable (external random)", |b| {
let mut seed1 = [0; 64];
OsRng.fill_bytes(&mut seed1);
Expand All @@ -105,7 +107,7 @@ pub fn comparisons_encapsulation(c: &mut Criterion) {
)
});

#[cfg(feature = "simd128")]
#[cfg(all(feature = "mlkem768", feature = "pre-verification", feature = "simd128"))]
group.bench_function("libcrux unpacked neon (external random)", |b| {
let mut seed1 = [0; 64];
OsRng.fill_bytes(&mut seed1);
Expand All @@ -124,7 +126,7 @@ pub fn comparisons_encapsulation(c: &mut Criterion) {
)
});

#[cfg(feature = "simd256")]
#[cfg(all(feature = "mlkem768", feature = "pre-verification", feature = "simd256"))]
group.bench_function("libcrux unpacked avx2 (external random)", |b| {
let mut seed1 = [0; 64];
OsRng.fill_bytes(&mut seed1);
Expand Down Expand Up @@ -167,6 +169,7 @@ pub fn comparisons_decapsulation(c: &mut Criterion) {
)
});

#[cfg(all(feature = "mlkem768", feature = "pre-verification"))]
group.bench_function("libcrux unpacked portable", |b| {
let mut seed1 = [0; 64];
OsRng.fill_bytes(&mut seed1);
Expand All @@ -190,7 +193,7 @@ pub fn comparisons_decapsulation(c: &mut Criterion) {
)
});

#[cfg(feature = "simd128")]
#[cfg(all(feature = "mlkem768", feature = "pre-verification", feature = "simd128"))]
group.bench_function("libcrux unpacked neon", |b| {
let mut seed1 = [0; 64];
OsRng.fill_bytes(&mut seed1);
Expand All @@ -213,7 +216,7 @@ pub fn comparisons_decapsulation(c: &mut Criterion) {
)
});

#[cfg(feature = "simd256")]
#[cfg(all(feature = "mlkem768", feature = "pre-verification", feature = "simd256"))]
group.bench_function("libcrux unpacked avx2", |b| {
let mut seed1 = [0; 64];
OsRng.fill_bytes(&mut seed1);
Expand Down
106 changes: 55 additions & 51 deletions libcrux-ml-kem/tests/self.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ macro_rules! impl_modified_ciphertext_and_implicit_rejection_value {
};
}


#[cfg(feature = "mlkem512")]
impl_consistency!(
consistency_512,
Expand All @@ -231,91 +232,94 @@ impl_consistency!(
libcrux_ml_kem::mlkem1024::decapsulate
);

#[cfg(all(feature = "mlkem512", feature = "pre-verification"))]
impl_consistency_unpacked!(
consistency_unpacked_512_portable,
mlkem512::portable::generate_key_pair,
mlkem512::portable::encapsulate,
mlkem512::portable::generate_key_pair_unpacked,
mlkem512::portable::encapsulate_unpacked,
mlkem512::portable::decapsulate_unpacked
libcrux_ml_kem::mlkem512::portable::generate_key_pair,
libcrux_ml_kem::mlkem512::portable::encapsulate,
libcrux_ml_kem::mlkem512::portable::generate_key_pair_unpacked,
libcrux_ml_kem::mlkem512::portable::encapsulate_unpacked,
libcrux_ml_kem::mlkem512::portable::decapsulate_unpacked
);

#[cfg(all(feature = "mlkem512", feature = "simd128"))]
#[cfg(all(feature = "mlkem512", feature = "pre-verification", feature = "simd128"))]
impl_consistency_unpacked!(
consistency_unpacked_512_neon,
mlkem512::neon::generate_key_pair,
mlkem512::neon::encapsulate,
mlkem512::neon::generate_key_pair_unpacked,
mlkem512::neon::encapsulate_unpacked,
mlkem512::neon::decapsulate_unpacked
libcrux_ml_kem::mlkem512::neon::generate_key_pair,
libcrux_ml_kem::mlkem512::neon::encapsulate,
libcrux_ml_kem::mlkem512::neon::generate_key_pair_unpacked,
libcrux_ml_kem::mlkem512::neon::encapsulate_unpacked,
libcrux_ml_kem::mlkem512::neon::decapsulate_unpacked
);

#[cfg(all(feature = "mlkem512", feature = "simd256"))]
#[cfg(all(feature = "mlkem512", feature = "pre-verification", feature = "simd256"))]
impl_consistency_unpacked!(
consistency_unpacked_512_avx2,
mlkem512::avx2::generate_key_pair,
mlkem512::avx2::encapsulate,
mlkem512::avx2::generate_key_pair_unpacked,
mlkem512::avx2::encapsulate_unpacked,
mlkem512::avx2::decapsulate_unpacked
libcrux_ml_kem::mlkem512::avx2::generate_key_pair,
libcrux_ml_kem::mlkem512::avx2::encapsulate,
libcrux_ml_kem::mlkem512::avx2::generate_key_pair_unpacked,
libcrux_ml_kem::mlkem512::avx2::encapsulate_unpacked,
libcrux_ml_kem::mlkem512::avx2::decapsulate_unpacked
);

#[cfg(all(feature = "mlkem1024", feature = "pre-verification"))]
impl_consistency_unpacked!(
consistency_unpacked_1024_portable,
mlkem1024::portable::generate_key_pair,
mlkem1024::portable::encapsulate,
mlkem1024::portable::generate_key_pair_unpacked,
mlkem1024::portable::encapsulate_unpacked,
mlkem1024::portable::decapsulate_unpacked
libcrux_ml_kem::mlkem1024::portable::generate_key_pair,
libcrux_ml_kem::mlkem1024::portable::encapsulate,
libcrux_ml_kem::mlkem1024::portable::generate_key_pair_unpacked,
libcrux_ml_kem::mlkem1024::portable::encapsulate_unpacked,
libcrux_ml_kem::mlkem1024::portable::decapsulate_unpacked
);

#[cfg(all(feature = "mlkem1024", feature = "simd128"))]
#[cfg(all(feature = "mlkem1024", feature = "pre-verification", feature = "simd128"))]
impl_consistency_unpacked!(
consistency_unpacked_1024_neon,
mlkem1024::neon::generate_key_pair,
mlkem1024::neon::encapsulate,
mlkem1024::neon::generate_key_pair_unpacked,
mlkem1024::neon::encapsulate_unpacked,
mlkem1024::neon::decapsulate_unpacked
libcrux_ml_kem::mlkem1024::neon::generate_key_pair,
libcrux_ml_kem::mlkem1024::neon::encapsulate,
libcrux_ml_kem::mlkem1024::neon::generate_key_pair_unpacked,
libcrux_ml_kem::mlkem1024::neon::encapsulate_unpacked,
libcrux_ml_kem::mlkem1024::neon::decapsulate_unpacked
);

#[cfg(all(feature = "mlkem1024", feature = "simd256"))]
#[cfg(all(feature = "mlkem1024", feature = "pre-verification", feature = "simd256"))]
impl_consistency_unpacked!(
consistency_unpacked_1024_avx2,
mlkem1024::avx2::generate_key_pair,
mlkem1024::avx2::encapsulate,
mlkem1024::avx2::generate_key_pair_unpacked,
mlkem1024::avx2::encapsulate_unpacked,
mlkem1024::avx2::decapsulate_unpacked
libcrux_ml_kem::mlkem1024::avx2::generate_key_pair,
libcrux_ml_kem::mlkem1024::avx2::encapsulate,
libcrux_ml_kem::mlkem1024::avx2::generate_key_pair_unpacked,
libcrux_ml_kem::mlkem1024::avx2::encapsulate_unpacked,
libcrux_ml_kem::mlkem1024::avx2::decapsulate_unpacked
);

#[cfg(all(feature = "mlkem768", feature = "pre-verification"))]
impl_consistency_unpacked!(
consistency_unpacked_768_portable,
mlkem768::portable::generate_key_pair,
mlkem768::portable::encapsulate,
mlkem768::portable::generate_key_pair_unpacked,
mlkem768::portable::encapsulate_unpacked,
mlkem768::portable::decapsulate_unpacked
libcrux_ml_kem::mlkem768::portable::generate_key_pair,
libcrux_ml_kem::mlkem768::portable::encapsulate,
libcrux_ml_kem::mlkem768::portable::generate_key_pair_unpacked,
libcrux_ml_kem::mlkem768::portable::encapsulate_unpacked,
libcrux_ml_kem::mlkem768::portable::decapsulate_unpacked
);

#[cfg(all(feature = "mlkem768", feature = "simd128"))]
#[cfg(all(feature = "mlkem768", feature = "pre-verification", feature = "simd128"))]
impl_consistency_unpacked!(
consistency_unpacked_768_neon,
mlkem768::neon::generate_key_pair,
mlkem768::neon::encapsulate,
mlkem768::neon::generate_key_pair_unpacked,
mlkem768::neon::encapsulate_unpacked,
mlkem768::neon::decapsulate_unpacked
libcrux_ml_kem::mlkem768::neon::generate_key_pair,
libcrux_ml_kem::mlkem768::neon::encapsulate,
libcrux_ml_kem::mlkem768::neon::generate_key_pair_unpacked,
libcrux_ml_kem::mlkem768::neon::encapsulate_unpacked,
libcrux_ml_kem::mlkem768::neon::decapsulate_unpacked
);

#[cfg(all(feature = "mlkem768", feature = "simd256"))]
#[cfg(all(feature = "mlkem768", feature = "pre-verification", feature = "simd256"))]
impl_consistency_unpacked!(
consistency_unpacked_768_avx2,
mlkem768::avx2::generate_key_pair,
mlkem768::avx2::encapsulate,
mlkem768::avx2::generate_key_pair_unpacked,
mlkem768::avx2::encapsulate_unpacked,
mlkem768::avx2::decapsulate_unpacked
libcrux_ml_kem::mlkem768::avx2::generate_key_pair,
libcrux_ml_kem::mlkem768::avx2::encapsulate,
libcrux_ml_kem::mlkem768::avx2::generate_key_pair_unpacked,
libcrux_ml_kem::mlkem768::avx2::encapsulate_unpacked,
libcrux_ml_kem::mlkem768::avx2::decapsulate_unpacked
);

#[cfg(feature = "mlkem512")]
Expand Down

0 comments on commit f592ce3

Please sign in to comment.