Skip to content

Commit

Permalink
feat: remove timing functions for wasm support
Browse files Browse the repository at this point in the history
  • Loading branch information
rpalakkal committed Jul 28, 2023
1 parent 98bc83b commit 6e9afc3
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 54 deletions.
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
2 changes: 1 addition & 1 deletion halo2_proofs/src/plonk/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::marker::PhantomData;
use std::ops::RangeTo;
use std::rc::Rc;
use std::sync::atomic::AtomicUsize;
use std::time::Instant;
// use std::time::Instant;
use std::{collections::HashMap, iter, mem, sync::atomic::Ordering};

use super::{
Expand Down
28 changes: 14 additions & 14 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 @@ -1028,17 +1028,17 @@ fn test_fft() {
let num_threads = multicore::current_num_threads();

let mut a = input.clone();
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);
stop_measure(start);
// stop_measure(start);

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

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

0 comments on commit 6e9afc3

Please sign in to comment.