Skip to content

Commit

Permalink
Creating meaningfull logs
Browse files Browse the repository at this point in the history
  • Loading branch information
hecmas committed Dec 18, 2024
1 parent 254f1e1 commit 46bbbc1
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 34 deletions.
1 change: 0 additions & 1 deletion state-machines/arith/src/arith_full.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,6 @@ impl<F: PrimeField> ArithFullSM<F> {

if !binary_inputs.is_empty() {
timer_start_trace!(ARITH_BINARY);
info!("{}: ··· calling binary_sm", Self::MY_NAME);
self.binary_sm.prove(binary_inputs.as_slice(), false);
timer_stop_and_log_trace!(ARITH_BINARY);
}
Expand Down
2 changes: 1 addition & 1 deletion state-machines/binary/src/binary_basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,7 @@ impl<F: Field> BinaryBasicSM<F> {
assert!(operations.len() <= air.num_rows());

info!(
"{}: ··· Creating Binary basic instance [{} / {} rows filled {:.2}%]",
"{}: ··· Creating Binary instance [{} / {} rows filled {:.2}%]",
Self::MY_NAME,
operations.len(),
air.num_rows(),
Expand Down
28 changes: 20 additions & 8 deletions state-machines/binary/src/binary_basic_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use std::sync::{
Arc, Mutex,
};

use log::info;
use p3_field::Field;
use proofman::{WitnessComponent, WitnessManager};
use proofman_common::AirInstance;
Expand Down Expand Up @@ -261,19 +260,32 @@ impl<F: Field> BinaryBasicTableSM<F> {

if is_myne {
// Create the prover buffer
let trace: BinaryTableTrace<'_, _> = BinaryTableTrace::new(self.num_rows);
let num_rows = self.num_rows;
let trace: BinaryTableTrace<'_, _> = BinaryTableTrace::new(num_rows);
let mut prover_buffer = trace.buffer.unwrap();

prover_buffer[0..self.num_rows]
let non_zero_multiplicities = prover_buffer[0..num_rows]
.par_iter_mut()
.enumerate()
.for_each(|(i, input)| *input = F::from_canonical_u64(multiplicity_[i]));

info!(
"{}: ··· Creating Binary basic table instance [{} rows filled 100%]",
.map(|(i, input)| {
*input = F::from_canonical_u64(multiplicity_[i]);
if multiplicity_[i] != 0 {
Some(1)
} else {
None
}
})
.filter_map(|x| x)
.sum::<usize>();

log::info!(
"{}: ··· Creating Binary Table instance [{} / {} rows used {:.2}%]",
Self::MY_NAME,
self.num_rows,
non_zero_multiplicities,
num_rows,
non_zero_multiplicities as f64 / num_rows as f64 * 100.0
);

let air_instance = AirInstance::new(
self.wcm.get_sctx(),
ZISK_AIRGROUP_ID,
Expand Down
2 changes: 1 addition & 1 deletion state-machines/binary/src/binary_extension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ impl<F: PrimeField> BinaryExtensionSM<F> {
assert!(operations.len() <= air.num_rows());

info!(
"{}: ··· Creating Binary extension instance [{} / {} rows filled {:.2}%]",
"{}: ··· Creating Binary Extension instance [{} / {} rows filled {:.2}%]",
Self::MY_NAME,
operations.len(),
air.num_rows(),
Expand Down
28 changes: 19 additions & 9 deletions state-machines/binary/src/binary_extension_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use std::sync::{
Arc, Mutex,
};

use log::info;
use p3_field::Field;
use proofman::{WitnessComponent, WitnessManager};
use proofman_common::AirInstance;
Expand Down Expand Up @@ -136,19 +135,30 @@ impl<F: Field> BinaryExtensionTableSM<F> {
dctx.distribute_multiplicity(&mut multiplicity_, owner);

if is_myne {
let trace: BinaryExtensionTableTrace<'_, _> =
BinaryExtensionTableTrace::new(self.num_rows);
let num_rows = self.num_rows;
let trace: BinaryExtensionTableTrace<'_, _> = BinaryExtensionTableTrace::new(num_rows);
let mut prover_buffer = trace.buffer.unwrap();

prover_buffer[0..self.num_rows]
let non_zero_multiplicities = prover_buffer[0..num_rows]
.par_iter_mut()
.enumerate()
.for_each(|(i, input)| *input = F::from_canonical_u64(multiplicity_[i]));

info!(
"{}: ··· Creating Binary extension table instance [{} rows filled 100%]",
.map(|(i, input)| {
*input = F::from_canonical_u64(multiplicity_[i]);
if multiplicity_[i] != 0 {
Some(1)
} else {
None
}
})
.filter_map(|x| x)
.sum::<usize>();

log::info!(
"{}: ··· Creating Binary Extension Table instance [{} / {} rows used {:.2}%]",
Self::MY_NAME,
self.num_rows,
non_zero_multiplicities,
num_rows,
non_zero_multiplicities as f64 / num_rows as f64 * 100.0
);

let air_instance = AirInstance::new(
Expand Down
13 changes: 9 additions & 4 deletions state-machines/mem/src/mem_align_rom_sm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use std::{
},
};

use log::info;
use p3_field::PrimeField;
use proofman::{WitnessComponent, WitnessManager};
use proofman_common::AirInstance;
Expand Down Expand Up @@ -43,7 +42,7 @@ pub enum ExtensionTableSMErr {
}

impl<F: PrimeField> MemAlignRomSM<F> {
const MY_NAME: &'static str = "MemAlignRom";
const MY_NAME: &'static str = "MemAlROM";

pub fn new(wcm: Arc<WitnessManager<F>>) -> Arc<Self> {
let pctx = wcm.get_pctx();
Expand Down Expand Up @@ -196,9 +195,15 @@ impl<F: PrimeField> MemAlignRomSM<F> {
trace_buffer[*row_idx as usize] =
MemAlignRomRow { multiplicity: F::from_canonical_u64(*multiplicity) };
}
}

info!("{}: ··· Creating Mem Align Rom instance", Self::MY_NAME,);
log::info!(
"{}: ··· Creating Mem Align ROM instance [{} / {} rows executed {:.2}%]",
Self::MY_NAME,
multiplicity.len(),
air_mem_align_rom_rows,
multiplicity.len() as f64 / air_mem_align_rom_rows as f64 * 100.0
);
}

let air_instance = AirInstance::new(
sctx,
Expand Down
16 changes: 9 additions & 7 deletions state-machines/mem/src/mem_align_sm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -926,13 +926,15 @@ impl<F: PrimeField> MemAlignSM<F> {

while rows.len() >= air_mem_align.num_rows() {
// Find the correct cutting point
let cutting_point = if previous_num_rows + computed_rows.len() == air_mem_align.num_rows() {
air_mem_align.num_rows()
} else {
// This is the case where previous_num_rows + computed_rows.len() > air_mem_align.num_rows()
// In this case, we prove computed_rows in the next air instance
previous_num_rows
};
let cutting_point =
if previous_num_rows + computed_rows.len() == air_mem_align.num_rows() {
air_mem_align.num_rows()
} else {
// This is the case where previous_num_rows + computed_rows.len() >
// air_mem_align.num_rows() In this case, we prove
// computed_rows in the next air instance
previous_num_rows
};
let drained_rows = rows.drain(..cutting_point).collect::<Vec<_>>();

self.fill_new_air_instance(&drained_rows);
Expand Down
6 changes: 3 additions & 3 deletions state-machines/mem/src/mem_proxy_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ use crate::{
MAX_MAIN_STEP, MAX_MEM_ADDR, MAX_MEM_OPS_BY_MAIN_STEP, MAX_MEM_STEP, MAX_MEM_STEP_OFFSET,
MEMORY_MAX_DIFF, MEM_ADDR_MASK, MEM_BYTES, MEM_BYTES_BITS,
};
use log::info;

use p3_field::PrimeField;
use proofman_util::{timer_start_debug, timer_stop_and_log_debug};
Expand Down Expand Up @@ -545,9 +544,10 @@ impl<F: PrimeField> MemProxyEngine<F> {
);
module.send_inputs(&self.modules_data[module_id].inputs);
}
info!(
debug_info!(
"MemProxy: ··· Intermediate reads [cases:{} steps:{}]",
self.intermediate_cases, self.intermediate_steps
self.intermediate_cases,
self.intermediate_steps
);
}
/// Fetches the address map, defining and calculating all necessary structures to manage the
Expand Down

0 comments on commit 46bbbc1

Please sign in to comment.