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

Remove timing functions to support WASM #8

Merged
merged 2 commits into from
Jul 28, 2023
Merged
Show file tree
Hide file tree
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
12 changes: 6 additions & 6 deletions halo2_proofs/src/arithmetic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ pub fn best_multiexp<C: CurveAffine>(coeffs: &[C::Scalar], bases: &[C]) -> C::Cu

//println!("msm: {}", coeffs.len());

let start = get_time();
// let start = get_time();
let num_threads = multicore::current_num_threads();
let res = if coeffs.len() > num_threads {
let chunk = coeffs.len() / num_threads;
Expand All @@ -163,11 +163,11 @@ pub fn best_multiexp<C: CurveAffine>(coeffs: &[C::Scalar], bases: &[C]) -> C::Cu
acc
};

let duration = get_duration(start);
// let duration = get_duration(start);
#[allow(unsafe_code)]
unsafe {
MULTIEXP_TOTAL_TIME += duration;
}
// unsafe {
// MULTIEXP_TOTAL_TIME += duration;
// }

res
}
Expand Down Expand Up @@ -525,7 +525,7 @@ use rand_core::OsRng;

#[cfg(test)]
use crate::halo2curves::pasta::Fp;
use crate::plonk::{get_duration, get_time, start_measure, stop_measure};
// use crate::plonk::{get_duration, get_time, start_measure, stop_measure};

#[test]
fn test_lagrange_interpolate() {
Expand Down
2 changes: 1 addition & 1 deletion halo2_proofs/src/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::fmt;
use std::iter;
use std::ops::{Add, Mul, Neg, Range};
use std::sync::Arc;
use std::time::{Duration, Instant};
// use std::time::{Duration, Instant};

use blake2b_simd::blake2b;
use ff::Field;
Expand Down
64 changes: 32 additions & 32 deletions halo2_proofs/src/plonk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,38 +45,38 @@ pub use verifier::*;
use evaluation::Evaluator;
use std::env::var;
use std::io;
use std::time::Instant;

/// Temp
#[allow(missing_debug_implementations)]
pub struct MeasurementInfo {
/// Temp
pub measure: bool,
/// Temp
pub time: Instant,
/// Message
pub message: String,
/// Indent
pub indent: usize,
}

/// TEMP
#[cfg(feature = "profile")]
pub static NUM_INDENT: AtomicUsize = AtomicUsize::new(0);

/// Temp
pub fn get_time() -> Instant {
Instant::now()
}

/// Temp
pub fn get_duration(start: Instant) -> usize {
let final_time = Instant::now() - start;
let secs = final_time.as_secs() as usize;
let millis = final_time.subsec_millis() as usize;
let micros = (final_time.subsec_micros() % 1000) as usize;
secs * 1000000 + millis * 1000 + micros
}
// use std::time::Instant;

// /// Temp
// #[allow(missing_debug_implementations)]
// pub struct MeasurementInfo {
// /// Temp
// pub measure: bool,
// /// Temp
// pub time: Instant,
// /// Message
// pub message: String,
// /// Indent
// pub indent: usize,
// }

// /// TEMP
// #[cfg(feature = "profile")]
// pub static NUM_INDENT: AtomicUsize = AtomicUsize::new(0);

// /// Temp
// pub fn get_time() -> Instant {
// Instant::now()
// }

// /// Temp
// pub fn get_duration(start: Instant) -> usize {
// let final_time = Instant::now() - start;
// let secs = final_time.as_secs() as usize;
// let millis = final_time.subsec_millis() as usize;
// let micros = (final_time.subsec_micros() % 1000) as usize;
// secs * 1000000 + millis * 1000 + micros
// }

/// Temp
pub fn log_measurement(indent: Option<usize>, msg: String, duration: usize) {
Expand Down
34 changes: 15 additions & 19 deletions halo2_proofs/src/poly/domain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use crate::{
arithmetic::{best_fft, parallelize, parallelize_count, FieldExt, Group},
multicore,
plonk::{get_duration, get_time, start_measure, stop_measure, Assigned},
plonk::{Assigned},
};

use super::{Coeff, ExtendedLagrangeCoeff, LagrangeCoeff, Polynomial, Rotation};
Expand Down Expand Up @@ -787,7 +787,7 @@ impl<G: Group> EvaluationDomain<G> {
}

fn fft_inner(&self, a: &mut Vec<G::Scalar>, omega: G::Scalar, log_n: u32, inverse: bool) {
let start = get_time();
// let start = get_time();
if get_fft_mode() == 1 {
let fft_data = if a.len() == self.fft_data.n {
&self.fft_data
Expand All @@ -798,12 +798,12 @@ impl<G: Group> EvaluationDomain<G> {
} else {
best_fft(a, omega, log_n);
}
let duration = get_duration(start);
// let duration = get_duration(start);

#[allow(unsafe_code)]
unsafe {
FFT_TOTAL_TIME += duration;
}
// #[allow(unsafe_code)]
// unsafe {
// FFT_TOTAL_TIME += duration;
// }
}

/// Get the size of the domain
Expand Down Expand Up @@ -1029,21 +1029,17 @@ fn test_fft() {
let num_threads = multicore::current_num_threads();

let mut a = input.clone();
#[cfg(feature = "profile")]
let start = start_measure(format!("best fft {} ({})", a.len(), num_threads), false);
// let start = start_measure(format!("best fft {} ({})", a.len(), num_threads), false);
best_fft(&mut a, domain.omega, k);
#[cfg(feature = "profile")]
stop_measure(start);
// stop_measure(start);

let mut b = input;
#[cfg(feature = "profile")]
let start = start_measure(
format!("recursive fft {} ({})", a.len(), num_threads),
false,
);
let mut b = input.clone();
// let start = start_measure(
// format!("recursive fft {} ({})", a.len(), num_threads),
// false,
// );
recursive_fft(&domain.fft_data, &mut b, false);
#[cfg(feature = "profile")]
stop_measure(start);
// stop_measure(start);

for i in 0..n {
//println!("{}: {} {}", i, a[i], b[i]);
Expand Down
Loading