Skip to content

Commit

Permalink
Fallback to CPU in small size. (#824)
Browse files Browse the repository at this point in the history
  • Loading branch information
alonh5 authored Sep 9, 2024
1 parent 1f9187e commit 2abcb2b
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion crates/prover/src/core/backend/simd/quotients.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use super::m31::{PackedBaseField, LOG_N_LANES, N_LANES};
use super::qm31::PackedSecureField;
use super::SimdBackend;
use crate::core::backend::cpu::quotients::{batch_random_coeffs, column_line_coeffs};
use crate::core::backend::Column;
use crate::core::backend::{Column, CpuBackend};
use crate::core::fields::m31::BaseField;
use crate::core::fields::qm31::SecureField;
use crate::core::fields::secure_column::{SecureColumnByCoords, SECURE_EXTENSION_DEGREE};
Expand All @@ -36,6 +36,30 @@ impl QuotientOps for SimdBackend {
// Split the domain into a subdomain and a shift coset.
// TODO(spapini): Move to the caller when Columns support slices.
let (subdomain, mut subdomain_shifts) = domain.split(log_blowup_factor);
if subdomain.log_size() < LOG_N_LANES + 2 {
// Fall back to the CPU backend for small domains.
let columns = columns
.iter()
.map(|circle_eval| {
CircleEvaluation::<CpuBackend, _, BitReversedOrder>::new(
circle_eval.domain,
circle_eval.values.to_cpu(),
)
})
.collect_vec();
let eval = CpuBackend::accumulate_quotients(
domain,
&columns.iter().collect_vec(),
random_coeff,
sample_batches,
log_blowup_factor,
);

return SecureEvaluation::new(
domain,
SecureColumnByCoords::from_iter(eval.values.to_vec()),
);
}

// Bit reverse the shifts.
// Since we traverse the domain in bit-reversed order, we need bit-reverse the shifts.
Expand Down

0 comments on commit 2abcb2b

Please sign in to comment.