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

need to run proof.synthesize in parallel #1620

Open
fishjar opened this issue Jul 8, 2022 · 0 comments
Open

need to run proof.synthesize in parallel #1620

fishjar opened this issue Jul 8, 2022 · 0 comments

Comments

@fishjar
Copy link

fishjar commented Jul 8, 2022

Is it possible for the for loops here to run in parallel?

for (i, proof) in proofs.into_iter().enumerate() {
proof.synthesize(
&mut cs.namespace(|| format!("challenge_{}", i)),
public_params.layer_challenges.layers(),
&comm_d_num,
&comm_c_num,
&comm_r_last_num,
&replica_id_bits,
)?;
}

like this:

use rayon::prelude::*;
// ...
        for (i, proof) in proofs.into_par_iter().enumerate() {
            proof.synthesize(
                &mut cs.namespace(|| format!("challenge_{}", i)),
                public_params.layer_challenges.layers(),
                &comm_d_num,
                &comm_c_num,
                &comm_r_last_num,
                &replica_id_bits,
            )?;
        }

or:

use rayon::prelude::*;
// ...
        if CS::is_extensible() {
            let css = proofs
                .into_par_iter()
                .enumerate()
                .map(|(i, proof)| {
                    let mut cs = CS::new();
                    cs.alloc_input(|| "temp synthesize ONE", || Ok(Fr::one())).unwrap();
                    proof.synthesize(
                        &mut cs.namespace(|| format!("challenge_{}", i)),
                        public_params.layer_challenges.layers(),
                        &comm_d_num,
                        &comm_c_num,
                        &comm_r_last_num,
                        &replica_id_bits,
                    ).unwrap();
                    Ok(cs)
                }).collect::<Result<Vec<_>, SynthesisError>>()?;
            for (i, c) in css.into_iter().enumerate() {
                cs.extend(c);
            }
            return Ok(());
        }

        for (i, proof) in proofs.into_iter().enumerate() {
            proof.synthesize(
                &mut cs.namespace(|| format!("challenge_{}", i)),
                public_params.layer_challenges.layers(),
                &comm_d_num,
                &comm_c_num,
                &comm_r_last_num,
                &replica_id_bits,
            )?;
        }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant