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

Single airgroup #149

Merged
merged 4 commits into from
Nov 5, 2024
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
28 changes: 14 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions emulator/src/emu_full_trace.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
use zisk_pil::Main0Row;
use zisk_pil::MainRow;

pub type EmuFullTraceStep<F> = Main0Row<F>;
pub type EmuFullTraceStep<F> = MainRow<F>;
50 changes: 10 additions & 40 deletions pil/src/pil_helpers/pilout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,72 +2,42 @@
// Manual modifications are not recommended and may be overwritten.
use proofman_common::WitnessPilout;

pub const PILOUT_HASH: &[u8] = b"ZiskContinuations1-hash";
pub const PILOUT_HASH: &[u8] = b"Zisk-hash";

//AIRGROUP CONSTANTS

pub const MAIN_AIRGROUP_ID: usize = 0;

pub const ROM_AIRGROUP_ID: usize = 1;

pub const BINARY_AIRGROUP_ID: usize = 2;

pub const BINARY_TABLE_AIRGROUP_ID: usize = 3;

pub const BINARY_EXTENSION_AIRGROUP_ID: usize = 4;

pub const BINARY_EXTENSION_TABLE_AIRGROUP_ID: usize = 5;

pub const SPECIFIED_RANGES_AIRGROUP_ID: usize = 6;
pub const ZISK_AIRGROUP_ID: usize = 0;

//AIR CONSTANTS

pub const MAIN_AIR_IDS: &[usize] = &[0];

pub const ROM_AIR_IDS: &[usize] = &[0];
pub const ROM_AIR_IDS: &[usize] = &[1];

pub const BINARY_AIR_IDS: &[usize] = &[0];
pub const BINARY_AIR_IDS: &[usize] = &[2];

pub const BINARY_TABLE_AIR_IDS: &[usize] = &[0];
pub const BINARY_TABLE_AIR_IDS: &[usize] = &[3];

pub const BINARY_EXTENSION_AIR_IDS: &[usize] = &[0];
pub const BINARY_EXTENSION_AIR_IDS: &[usize] = &[4];

pub const BINARY_EXTENSION_TABLE_AIR_IDS: &[usize] = &[0];
pub const BINARY_EXTENSION_TABLE_AIR_IDS: &[usize] = &[5];

pub const SPECIFIED_RANGES_AIR_IDS: &[usize] = &[0];
pub const SPECIFIED_RANGES_AIR_IDS: &[usize] = &[6];

pub struct Pilout;

impl Pilout {
pub fn pilout() -> WitnessPilout {
let mut pilout = WitnessPilout::new("ZiskContinuations1", 2, PILOUT_HASH.to_vec());
let mut pilout = WitnessPilout::new("Zisk", 2, PILOUT_HASH.to_vec());

let air_group = pilout.add_air_group(Some("Main"));
let air_group = pilout.add_air_group(Some("Zisk"));

air_group.add_air(Some("Main"), 2097152);

let air_group = pilout.add_air_group(Some("Rom"));

air_group.add_air(Some("Rom"), 1048576);

let air_group = pilout.add_air_group(Some("Binary"));

air_group.add_air(Some("Binary"), 2097152);

let air_group = pilout.add_air_group(Some("BinaryTable"));

air_group.add_air(Some("BinaryTable"), 4194304);

let air_group = pilout.add_air_group(Some("BinaryExtension"));

air_group.add_air(Some("BinaryExtension"), 2097152);

let air_group = pilout.add_air_group(Some("BinaryExtensionTable"));

air_group.add_air(Some("BinaryExtensionTable"), 4194304);

let air_group = pilout.add_air_group(Some("SpecifiedRanges"));

air_group.add_air(Some("SpecifiedRanges"), 16777216);

pilout
Expand Down
14 changes: 7 additions & 7 deletions pil/src/pil_helpers/traces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,30 @@
use proofman_common as common;
pub use proofman_macros::trace;

trace!(Main0Row, Main0Trace<F> {
trace!(MainRow, MainTrace<F> {
a: [F; 2], b: [F; 2], c: [F; 2], flag: F, pc: F, a_src_imm: F, a_src_mem: F, a_offset_imm0: F, a_imm1: F, a_src_step: F, b_src_imm: F, b_src_mem: F, b_offset_imm0: F, b_imm1: F, b_src_ind: F, ind_width: F, is_external_op: F, op: F, store_ra: F, store_mem: F, store_ind: F, store_offset: F, set_pc: F, jmp_offset1: F, jmp_offset2: F, m32: F, addr1: F, __debug_operation_bus_enabled: F,
});

trace!(Rom0Row, Rom0Trace<F> {
trace!(RomRow, RomTrace<F> {
line: F, a_offset_imm0: F, a_imm1: F, b_offset_imm0: F, b_imm1: F, ind_width: F, op: F, store_offset: F, jmp_offset1: F, jmp_offset2: F, flags: F, multiplicity: F,
});

trace!(Binary0Row, Binary0Trace<F> {
trace!(BinaryRow, BinaryTrace<F> {
m_op: F, mode32: F, free_in_a: [F; 8], free_in_b: [F; 8], free_in_c: [F; 8], carry: [F; 8], use_last_carry: F, op_is_min_max: F, multiplicity: F, main_step: F,
});

trace!(BinaryTable0Row, BinaryTable0Trace<F> {
trace!(BinaryTableRow, BinaryTableTrace<F> {
multiplicity: F,
});

trace!(BinaryExtension0Row, BinaryExtension0Trace<F> {
trace!(BinaryExtensionRow, BinaryExtensionTrace<F> {
op: F, in1: [F; 8], in2_low: F, out: [[F; 2]; 8], op_is_shift: F, in2: [F; 2], main_step: F, multiplicity: F,
});

trace!(BinaryExtensionTable0Row, BinaryExtensionTable0Trace<F> {
trace!(BinaryExtensionTableRow, BinaryExtensionTableTrace<F> {
multiplicity: F,
});

trace!(SpecifiedRanges0Row, SpecifiedRanges0Trace<F> {
trace!(SpecifiedRangesRow, SpecifiedRangesTrace<F> {
mul: [F; 1],
});
22 changes: 2 additions & 20 deletions pil/zisk.pil
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,12 @@ require "binary/pil/binary_extension_table.pil"
// require "mem/pil/mem.pil"

const int OPERATION_BUS_ID = 5000;
airgroup Main {
airgroup Zisk {
Main(N: 2**21, RC: 2, operation_bus_id: OPERATION_BUS_ID);
}

airgroup Rom {
Rom(N: 2**20);
}

// airgroup Mem {
// Mem(N: 2**21, RC: 2);
// }

airgroup Binary {
// Mem(N: 2**21, RC: 2);
Binary(N: 2**21, operation_bus_id: OPERATION_BUS_ID);
}

airgroup BinaryTable {
BinaryTable(disable_fixed: 0);
}

airgroup BinaryExtension {
BinaryExtension(N: 2**21, operation_bus_id: OPERATION_BUS_ID);
}

airgroup BinaryExtensionTable {
BinaryExtensionTable(disable_fixed: 0);
}
6 changes: 3 additions & 3 deletions state-machines/arith/src/arith_traces.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use proofman_common as common;
pub use proofman_macros::trace;

trace!(Arith320Row, Arith320Trace<F> { fake: F });
trace!(Arith640Row, Arith640Trace<F> { fake: F });
trace!(Arith32640Row, Arith32640Trace<F> { fake: F });
trace!(Arith32Row, Arith32Trace<F> { fake: F });
trace!(Arith64Row, Arith64Trace<F> { fake: F });
trace!(Arith3264Row, Arith3264Trace<F> { fake: F });
13 changes: 6 additions & 7 deletions state-machines/binary/src/binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ use rayon::Scope;
use sm_common::{OpResult, Provable};
use zisk_core::ZiskRequiredOperation;
use zisk_pil::{
BINARY_AIRGROUP_ID, BINARY_AIR_IDS, BINARY_EXTENSION_AIRGROUP_ID, BINARY_EXTENSION_AIR_IDS,
BINARY_EXTENSION_TABLE_AIRGROUP_ID, BINARY_EXTENSION_TABLE_AIR_IDS, BINARY_TABLE_AIRGROUP_ID,
BINARY_TABLE_AIR_IDS,
BINARY_AIR_IDS, BINARY_EXTENSION_AIR_IDS, BINARY_EXTENSION_TABLE_AIR_IDS, BINARY_TABLE_AIR_IDS,
ZISK_AIRGROUP_ID,
};

const PROVE_CHUNK_SIZE: usize = 1 << 16;
Expand All @@ -35,24 +34,24 @@ pub struct BinarySM<F: PrimeField> {
impl<F: PrimeField> BinarySM<F> {
pub fn new(wcm: Arc<WitnessManager<F>>, std: Arc<Std<F>>) -> Arc<Self> {
let binary_basic_table_sm =
BinaryBasicTableSM::new(wcm.clone(), BINARY_TABLE_AIRGROUP_ID, BINARY_TABLE_AIR_IDS);
BinaryBasicTableSM::new(wcm.clone(), ZISK_AIRGROUP_ID, BINARY_TABLE_AIR_IDS);
let binary_basic_sm = BinaryBasicSM::new(
wcm.clone(),
binary_basic_table_sm,
BINARY_AIRGROUP_ID,
ZISK_AIRGROUP_ID,
BINARY_AIR_IDS,
);

let binary_extension_table_sm = BinaryExtensionTableSM::new(
wcm.clone(),
BINARY_EXTENSION_TABLE_AIRGROUP_ID,
ZISK_AIRGROUP_ID,
BINARY_EXTENSION_TABLE_AIR_IDS,
);
let binary_extension_sm = BinaryExtensionSM::new(
wcm.clone(),
std,
binary_extension_table_sm,
BINARY_EXTENSION_AIRGROUP_ID,
ZISK_AIRGROUP_ID,
BINARY_EXTENSION_AIR_IDS,
);

Expand Down
19 changes: 9 additions & 10 deletions state-machines/binary/src/binary_basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ impl<F: Field> BinaryBasicSM<F> {
pub fn process_slice(
operation: &ZiskRequiredOperation,
multiplicity: &mut [u64],
) -> Binary0Row<F> {
) -> BinaryRow<F> {
// Create an empty trace
let mut row: Binary0Row<F> = Default::default();
let mut row: BinaryRow<F> = Default::default();

// Execute the opcode
let c: u64;
Expand Down Expand Up @@ -657,9 +657,8 @@ impl<F: Field> BinaryBasicSM<F> {
) {
timer_start_trace!(BINARY_TRACE);
let pctx = wcm.get_pctx();
let air = pctx.pilout.get_air(BINARY_AIRGROUP_ID, BINARY_AIR_IDS[0]);
let air_binary_table =
pctx.pilout.get_air(BINARY_TABLE_AIRGROUP_ID, BINARY_TABLE_AIR_IDS[0]);
let air = pctx.pilout.get_air(ZISK_AIRGROUP_ID, BINARY_AIR_IDS[0]);
let air_binary_table = pctx.pilout.get_air(ZISK_AIRGROUP_ID, BINARY_TABLE_AIR_IDS[0]);
assert!(operations.len() <= air.num_rows());

info!(
Expand All @@ -672,7 +671,7 @@ impl<F: Field> BinaryBasicSM<F> {

let mut multiplicity_table = vec![0u64; air_binary_table.num_rows()];
let mut trace_buffer =
Binary0Trace::<F>::map_buffer(prover_buffer, air.num_rows(), offset as usize).unwrap();
BinaryTrace::<F>::map_buffer(prover_buffer, air.num_rows(), offset as usize).unwrap();

for (i, operation) in operations.iter().enumerate() {
let row = Self::process_slice(operation, &mut multiplicity_table);
Expand All @@ -681,7 +680,7 @@ impl<F: Field> BinaryBasicSM<F> {
timer_stop_and_log_trace!(BINARY_TRACE);

timer_start_trace!(BINARY_PADDING);
let padding_row = Binary0Row::<F> {
let padding_row = BinaryRow::<F> {
m_op: F::from_canonical_u8(0x20),
multiplicity: F::zero(),
main_step: F::zero(), /* TODO: remove, since main_step is just for
Expand Down Expand Up @@ -729,7 +728,7 @@ impl<F: Field> Provable<ZiskRequiredOperation, OpResult> for BinaryBasicSM<F> {
inputs.extend_from_slice(operations);

let pctx = self.wcm.get_pctx();
let air = pctx.pilout.get_air(BINARY_AIRGROUP_ID, BINARY_AIR_IDS[0]);
let air = pctx.pilout.get_air(ZISK_AIRGROUP_ID, BINARY_AIR_IDS[0]);

while inputs.len() >= air.num_rows() || (drain && !inputs.is_empty()) {
let num_drained = std::cmp::min(air.num_rows(), inputs.len());
Expand All @@ -743,7 +742,7 @@ impl<F: Field> Provable<ZiskRequiredOperation, OpResult> for BinaryBasicSM<F> {
let (mut prover_buffer, offset) = create_prover_buffer(
&wcm.get_ectx(),
&wcm.get_sctx(),
BINARY_AIRGROUP_ID,
ZISK_AIRGROUP_ID,
BINARY_AIR_IDS[0],
);

Expand All @@ -757,7 +756,7 @@ impl<F: Field> Provable<ZiskRequiredOperation, OpResult> for BinaryBasicSM<F> {

let air_instance = AirInstance::new(
sctx,
BINARY_AIRGROUP_ID,
ZISK_AIRGROUP_ID,
BINARY_AIR_IDS[0],
None,
prover_buffer,
Expand Down
Loading
Loading