Skip to content

Commit

Permalink
inline ntt
Browse files Browse the repository at this point in the history
  • Loading branch information
franziskuskiefer committed Nov 8, 2024
1 parent 8f41090 commit a31e411
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
3 changes: 1 addition & 2 deletions libcrux-ml-dsa/src/simd/avx2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,8 @@ impl Operations for AVX2SIMDUnit {
}

#[inline(always)]
#[allow(unsafe_code)]
fn ntt(simd_units: [Self; SIMD_UNITS_IN_RING_ELEMENT]) -> [Self; SIMD_UNITS_IN_RING_ELEMENT] {
let result = unsafe { ntt::ntt(simd_units.map(|x| x.coefficients)) };
let result = ntt::ntt(simd_units.map(|x| x.coefficients));

result.map(|x| x.into())
}
Expand Down
16 changes: 9 additions & 7 deletions libcrux-ml-dsa/src/simd/avx2/ntt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -488,16 +488,18 @@ unsafe fn ntt_at_layer_5_to_3(re: &mut [Vec256; SIMD_UNITS_IN_RING_ELEMENT]) {
()
}

#[cfg_attr(not(hax), target_feature(enable = "avx2"))]
#[allow(unsafe_code)]
pub(crate) unsafe fn ntt(
#[inline(always)]
pub(crate) fn ntt(
mut re: [Vec256; SIMD_UNITS_IN_RING_ELEMENT],
) -> [Vec256; SIMD_UNITS_IN_RING_ELEMENT] {
ntt_at_layer_7_and_6(&mut re);
ntt_at_layer_5_to_3(&mut re);
ntt_at_layer_2(&mut re);
ntt_at_layer_1(&mut re);
ntt_at_layer_0(&mut re);
unsafe {
ntt_at_layer_7_and_6(&mut re);
ntt_at_layer_5_to_3(&mut re);
ntt_at_layer_2(&mut re);
ntt_at_layer_1(&mut re);
ntt_at_layer_0(&mut re);
}

re
}

0 comments on commit a31e411

Please sign in to comment.