Skip to content

Commit

Permalink
feat: cache for bit_reverse
Browse files Browse the repository at this point in the history
  • Loading branch information
SuccinctPaul committed Oct 24, 2023
1 parent d3920d3 commit d2aab57
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions starky/src/fft_p.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,8 @@ pub fn bit_reverse<F: FieldExtension>(
let n = 1 << nbits;
let ris = BRs(0, n, nbits); // move it outside the loop. obtain it from cache.

// todo parallel. Does the buffdst
let len = n * n_pols;
assert_eq!(len, buffdst.len()); // is ok?
assert_eq!(len, buffdst.len());
for j in 0..len {
let i = j / n_pols;
let k = j % n_pols;
Expand All @@ -113,9 +112,10 @@ pub fn interpolate_bit_reverse<F: FieldExtension>(
nbits: usize,
) {
let n = 1 << nbits;
let ris = BRs(0, n, nbits); // move it outside the loop. obtain it from cache.

for i in 0..n {
let ri = BR(i, nbits);
let rii = (n - ri) % n;
let rii = (n - ris[i]) % n;
for k in 0..n_pols {
buffdst[i * n_pols + k] = buffsrc[rii * n_pols + k];
}
Expand All @@ -130,12 +130,15 @@ pub fn inv_bit_reverse<F: FieldExtension>(
) {
let n = 1 << nbits;
let n_inv = F::inv(&F::from(n));
for i in 0..n {
let ri = BR(i, nbits);
let rii = (n - ri) % n;
for p in 0..n_pols {
buffdst[i * n_pols + p] = buffsrc[rii * n_pols + p] * n_inv;
}
let ris = BRs(0, n, nbits); // move it outside the loop. obtain it from cache.

let len = n * n_pols;
assert_eq!(len, buffdst.len());
for j in 0..len {
let i = j / n_pols;
let k = j % n_pols;
let rii = (n - ris[i]) % n;
buffdst[j] = buffsrc[rii * n_pols + k] * n_inv;
}
}

Expand Down

0 comments on commit d2aab57

Please sign in to comment.