Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optimize compute_cell_and_kzg_proofs #286

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 60 additions & 16 deletions kzg/src/das.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@
return Err("Both cells & proofs cannot be none".to_string());
}

let settings = self.kzg_settings();

Check failure on line 229 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / kzg_ci

no method named `iter_mut` found for mutable reference `&mut <B as das::EcBackend>::Fr` in the current scope

Check failure on line 229 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / backend_ci (ubuntu-latest, zkcrypto)

no method named `iter_mut` found for mutable reference `&mut <B as das::EcBackend>::Fr` in the current scope

Check failure on line 229 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / backend_ci (ubuntu-latest, arkworks4)

no method named `iter_mut` found for mutable reference `&mut <B as das::EcBackend>::Fr` in the current scope

Check failure on line 229 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / backend_ci (ubuntu-latest, blst)

no method named `iter_mut` found for mutable reference `&mut <B as das::EcBackend>::Fr` in the current scope

Check failure on line 229 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / backend_ci (ubuntu-latest, arkworks5)

no method named `iter_mut` found for mutable reference `&mut <B as das::EcBackend>::Fr` in the current scope

Check failure on line 229 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / backend_ci (ubuntu-latest, arkworks3)

no method named `iter_mut` found for mutable reference `&mut <B as das::EcBackend>::Fr` in the current scope

Check failure on line 229 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / backend_ci (ubuntu-latest, constantine)

no method named `iter_mut` found for mutable reference `&mut <B as das::EcBackend>::Fr` in the current scope
let ts_size = settings.get_g1_monomial().len();
let cell_size = settings.get_cell_size();

Expand All @@ -238,24 +238,68 @@
let fft_settings = self.kzg_settings().get_fft_settings();
poly_lagrange_to_monomial::<B>(&mut poly_monomial[..ts_size], fft_settings)?;

// compute cells
if let Some(cells) = cells {
cells.clone_from_slice(&fft_settings.fft_fr(&poly_monomial, false)?);
#[cfg(feature = "parallel")]
{
use rayon::prelude::*;

if let Some(cells) = cells {
let fft_result = fft_settings.fft_fr(&poly_monomial, false)?;

let flattened_cells = fft_result.as_slice().to_vec();
let num_cells = cells.len();
flattened_cells
.par_chunks(flattened_cells.len() / num_cells)
.zip(cells.par_iter_mut())
.for_each(|(chunk, cell)| {
for (dest, src) in cell.iter_mut().zip(chunk.iter()) {
*dest = *src;
}
});
}

reverse_bit_order(cells)?;
};
if let Some(proofs) = proofs {

Check failure on line 260 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / benchmarks (ubuntu-latest, blst)

no method named `as_flattened_mut` found for mutable reference `&mut [<B as EcBackend>::Fr]` in the current scope

Check failure on line 260 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / benchmarks (ubuntu-latest, zkcrypto)

no method named `as_flattened_mut` found for mutable reference `&mut [<B as EcBackend>::Fr]` in the current scope

Check failure on line 260 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / benchmarks (ubuntu-latest, arkworks3)

no method named `as_flattened_mut` found for mutable reference `&mut [<B as EcBackend>::Fr]` in the current scope

Check failure on line 260 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / benchmarks (macos-latest, arkworks5)

no method named `as_flattened_mut` found for mutable reference `&mut [<B as EcBackend>::Fr]` in the current scope

Check failure on line 260 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / benchmarks (macos-latest, arkworks3)

no method named `as_flattened_mut` found for mutable reference `&mut [<B as EcBackend>::Fr]` in the current scope

Check failure on line 260 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / benchmarks (ubuntu-latest, arkworks5)

no method named `as_flattened_mut` found for mutable reference `&mut [<B as EcBackend>::Fr]` in the current scope

Check failure on line 260 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / benchmarks (macos-latest, arkworks4)

no method named `as_flattened_mut` found for mutable reference `&mut [<B as EcBackend>::Fr]` in the current scope

Check failure on line 260 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / benchmarks (ubuntu-latest, arkworks4)

no method named `as_flattened_mut` found for mutable reference `&mut [<B as EcBackend>::Fr]` in the current scope

Check failure on line 260 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / benchmarks (ubuntu-latest, constantine)

no method named `as_flattened_mut` found for mutable reference `&mut [<B as EcBackend>::Fr]` in the current scope

Check failure on line 260 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / benchmarks (windows-latest, blst)

no method named `as_flattened_mut` found for mutable reference `&mut [<B as EcBackend>::Fr]` in the current scope

Check failure on line 260 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / benchmarks (macos-latest, blst)

no method named `as_flattened_mut` found for mutable reference `&mut [<B as EcBackend>::Fr]` in the current scope

Check failure on line 260 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / benchmarks (macos-latest, zkcrypto)

no method named `as_flattened_mut` found for mutable reference `&mut [<B as EcBackend>::Fr]` in the current scope

Check failure on line 260 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / benchmarks (windows-latest, arkworks5)

no method named `as_flattened_mut` found for mutable reference `&mut [<B as EcBackend>::Fr]` in the current scope

Check failure on line 260 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / backend_ci (windows-latest, blst)

no method named `as_flattened_mut` found for mutable reference `&mut [<B as EcBackend>::Fr]` in the current scope

Check failure on line 260 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / benchmarks (windows-latest, zkcrypto)

no method named `as_flattened_mut` found for mutable reference `&mut [<B as EcBackend>::Fr]` in the current scope

Check failure on line 260 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / benchmarks (windows-latest, arkworks3)

no method named `as_flattened_mut` found for mutable reference `&mut [<B as EcBackend>::Fr]` in the current scope

Check failure on line 260 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / backend_ci (windows-latest, zkcrypto)

no method named `as_flattened_mut` found for mutable reference `&mut [<B as EcBackend>::Fr]` in the current scope

Check failure on line 260 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / benchmarks (windows-latest, constantine)

no method named `as_flattened_mut` found for mutable reference `&mut [<B as EcBackend>::Fr]` in the current scope

Check failure on line 260 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / benchmarks (windows-latest, arkworks4)

no method named `as_flattened_mut` found for mutable reference `&mut [<B as EcBackend>::Fr]` in the current scope

Check failure on line 260 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / backend_ci (windows-latest, arkworks5)

no method named `as_flattened_mut` found for mutable reference `&mut [<B as EcBackend>::Fr]` in the current scope

Check failure on line 260 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / backend_ci (windows-latest, arkworks4)

no method named `as_flattened_mut` found for mutable reference `&mut [<B as EcBackend>::Fr]` in the current scope

Check failure on line 260 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / backend_ci (windows-latest, arkworks3)

no method named `as_flattened_mut` found for mutable reference `&mut [<B as EcBackend>::Fr]` in the current scope

Check failure on line 260 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / backend_ci (windows-latest, constantine)

no method named `as_flattened_mut` found for mutable reference `&mut [<B as EcBackend>::Fr]` in the current scope

Check failure on line 260 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / benchmarks (macos-latest, constantine)

no method named `as_flattened_mut` found for mutable reference `&mut [<B as EcBackend>::Fr]` in the current scope

Check failure on line 260 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / backend_ci (macos-latest, arkworks3)

no method named `as_flattened_mut` found for mutable reference `&mut [<B as EcBackend>::Fr]` in the current scope

Check failure on line 260 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / backend_ci (macos-latest, arkworks5)

no method named `as_flattened_mut` found for mutable reference `&mut [<B as EcBackend>::Fr]` in the current scope

Check failure on line 260 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / backend_ci (macos-latest, arkworks4)

no method named `as_flattened_mut` found for mutable reference `&mut [<B as EcBackend>::Fr]` in the current scope

Check failure on line 260 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / backend_ci (macos-latest, blst)

no method named `as_flattened_mut` found for mutable reference `&mut [<B as EcBackend>::Fr]` in the current scope

Check failure on line 260 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / backend_ci (macos-latest, zkcrypto)

no method named `as_flattened_mut` found for mutable reference `&mut [<B as EcBackend>::Fr]` in the current scope

Check failure on line 260 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / backend_ci (macos-latest, constantine)

no method named `as_flattened_mut` found for mutable reference `&mut [<B as EcBackend>::Fr]` in the current scope
let fk20_proofs = compute_fk20_proofs::<B>(
cell_size,
&poly_monomial,

Check failure on line 263 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / benchmarks (ubuntu-latest, blst)

no method named `as_flattened_mut` found for mutable reference `&mut [<B as EcBackend>::Fr]` in the current scope

Check failure on line 263 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / benchmarks (ubuntu-latest, zkcrypto)

no method named `as_flattened_mut` found for mutable reference `&mut [<B as EcBackend>::Fr]` in the current scope

Check failure on line 263 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / benchmarks (ubuntu-latest, arkworks3)

no method named `as_flattened_mut` found for mutable reference `&mut [<B as EcBackend>::Fr]` in the current scope

Check failure on line 263 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / benchmarks (macos-latest, arkworks5)

no method named `as_flattened_mut` found for mutable reference `&mut [<B as EcBackend>::Fr]` in the current scope

Check failure on line 263 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / benchmarks (macos-latest, arkworks3)

no method named `as_flattened_mut` found for mutable reference `&mut [<B as EcBackend>::Fr]` in the current scope

Check failure on line 263 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / benchmarks (ubuntu-latest, arkworks5)

no method named `as_flattened_mut` found for mutable reference `&mut [<B as EcBackend>::Fr]` in the current scope

Check failure on line 263 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / benchmarks (macos-latest, arkworks4)

no method named `as_flattened_mut` found for mutable reference `&mut [<B as EcBackend>::Fr]` in the current scope

Check failure on line 263 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / benchmarks (ubuntu-latest, arkworks4)

no method named `as_flattened_mut` found for mutable reference `&mut [<B as EcBackend>::Fr]` in the current scope

Check failure on line 263 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / benchmarks (ubuntu-latest, constantine)

no method named `as_flattened_mut` found for mutable reference `&mut [<B as EcBackend>::Fr]` in the current scope

Check failure on line 263 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / benchmarks (windows-latest, blst)

no method named `as_flattened_mut` found for mutable reference `&mut [<B as EcBackend>::Fr]` in the current scope

Check failure on line 263 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / benchmarks (macos-latest, blst)

no method named `as_flattened_mut` found for mutable reference `&mut [<B as EcBackend>::Fr]` in the current scope

Check failure on line 263 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / benchmarks (macos-latest, zkcrypto)

no method named `as_flattened_mut` found for mutable reference `&mut [<B as EcBackend>::Fr]` in the current scope

Check failure on line 263 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / benchmarks (windows-latest, arkworks5)

no method named `as_flattened_mut` found for mutable reference `&mut [<B as EcBackend>::Fr]` in the current scope

Check failure on line 263 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / backend_ci (windows-latest, blst)

no method named `as_flattened_mut` found for mutable reference `&mut [<B as EcBackend>::Fr]` in the current scope

Check failure on line 263 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / benchmarks (windows-latest, zkcrypto)

no method named `as_flattened_mut` found for mutable reference `&mut [<B as EcBackend>::Fr]` in the current scope

Check failure on line 263 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / benchmarks (windows-latest, arkworks3)

no method named `as_flattened_mut` found for mutable reference `&mut [<B as EcBackend>::Fr]` in the current scope

Check failure on line 263 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / backend_ci (windows-latest, zkcrypto)

no method named `as_flattened_mut` found for mutable reference `&mut [<B as EcBackend>::Fr]` in the current scope

Check failure on line 263 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / benchmarks (windows-latest, constantine)

no method named `as_flattened_mut` found for mutable reference `&mut [<B as EcBackend>::Fr]` in the current scope

Check failure on line 263 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / benchmarks (windows-latest, arkworks4)

no method named `as_flattened_mut` found for mutable reference `&mut [<B as EcBackend>::Fr]` in the current scope

Check failure on line 263 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / backend_ci (windows-latest, arkworks5)

no method named `as_flattened_mut` found for mutable reference `&mut [<B as EcBackend>::Fr]` in the current scope

Check failure on line 263 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / backend_ci (windows-latest, arkworks4)

no method named `as_flattened_mut` found for mutable reference `&mut [<B as EcBackend>::Fr]` in the current scope

Check failure on line 263 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / backend_ci (windows-latest, arkworks3)

no method named `as_flattened_mut` found for mutable reference `&mut [<B as EcBackend>::Fr]` in the current scope

Check failure on line 263 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / backend_ci (windows-latest, constantine)

no method named `as_flattened_mut` found for mutable reference `&mut [<B as EcBackend>::Fr]` in the current scope

Check failure on line 263 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / benchmarks (macos-latest, constantine)

no method named `as_flattened_mut` found for mutable reference `&mut [<B as EcBackend>::Fr]` in the current scope

Check failure on line 263 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / backend_ci (macos-latest, arkworks3)

no method named `as_flattened_mut` found for mutable reference `&mut [<B as EcBackend>::Fr]` in the current scope

Check failure on line 263 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / backend_ci (macos-latest, arkworks5)

no method named `as_flattened_mut` found for mutable reference `&mut [<B as EcBackend>::Fr]` in the current scope

Check failure on line 263 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / backend_ci (macos-latest, arkworks4)

no method named `as_flattened_mut` found for mutable reference `&mut [<B as EcBackend>::Fr]` in the current scope

Check failure on line 263 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / backend_ci (macos-latest, blst)

no method named `as_flattened_mut` found for mutable reference `&mut [<B as EcBackend>::Fr]` in the current scope

Check failure on line 263 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / backend_ci (macos-latest, zkcrypto)

no method named `as_flattened_mut` found for mutable reference `&mut [<B as EcBackend>::Fr]` in the current scope

Check failure on line 263 in kzg/src/das.rs

View workflow job for this annotation

GitHub Actions / backend_ci (macos-latest, constantine)

no method named `as_flattened_mut` found for mutable reference `&mut [<B as EcBackend>::Fr]` in the current scope
ts_size,
fft_settings,
settings,
)?;

proofs
.par_iter_mut()
.zip(fk20_proofs.into_par_iter())
.for_each(|(proof, result_proof)| {
*proof = result_proof;
});

reverse_bit_order(&mut proofs[..])?;
}
}

// compute proofs
if let Some(proofs) = proofs {
let result = compute_fk20_proofs::<B>(
cell_size,
&poly_monomial,
ts_size,
fft_settings,
settings,
)?;
proofs.clone_from_slice(&result);
reverse_bit_order(proofs)?;
#[cfg(not(feature = "parallel"))]
{
// Compute cells sequentially
if let Some(cells) = cells {
cells
.as_flattened_mut()
.clone_from_slice(&fft_settings.fft_fr(&poly_monomial, false)?);

reverse_bit_order(cells.as_flattened_mut())?;
}

// Compute proofs sequentially
if let Some(proofs) = proofs {
let result = compute_fk20_proofs::<B>(
cell_size,
&poly_monomial,
ts_size,
fft_settings,
settings,
)?;
proofs.clone_from_slice(&result);
reverse_bit_order(proofs)?;
}
}

Ok(())
Expand Down
Loading