Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
77c43d1
repr(C) StepRecord
Velaciela Mar 4, 2026
ac2bf54
fix
Velaciela Mar 4, 2026
f550783
witgen: add
Velaciela Mar 3, 2026
5a10916
witgen: lw
Velaciela Mar 3, 2026
07360f8
witgen: integration
Velaciela Mar 3, 2026
9b673ca
minor
Velaciela Mar 3, 2026
35154b1
fmt
Velaciela Mar 3, 2026
2d82306
minor
Velaciela Mar 3, 2026
65985ff
dev-local
Velaciela Mar 3, 2026
0f96033
GPU: AOS StepRecord
Velaciela Mar 4, 2026
4fc7368
SHARD_STEPS_DEVICE
Velaciela Mar 4, 2026
72dd155
batch-1234
Velaciela Mar 5, 2026
273cf7c
batch-5,12
Velaciela Mar 5, 2026
31697bf
batch-6-shift
Velaciela Mar 5, 2026
707ea1d
batch-8,9-slt
Velaciela Mar 5, 2026
3fcc70e
test: orrectness
Velaciela Mar 5, 2026
7191624
batch-10,11-branch
Velaciela Mar 5, 2026
1b6f346
batch-13-JALR
Velaciela Mar 6, 2026
107f72f
batch-14-SW
Velaciela Mar 6, 2026
4ac98ab
batch-15-SH,SB
Velaciela Mar 6, 2026
3b9e4b5
batch-16-LH,LB
Velaciela Mar 6, 2026
32c0acb
batch-17-MUL
Velaciela Mar 6, 2026
cb48e7a
batch-18-DIV
Velaciela Mar 6, 2026
6c43c6a
dev: non-witgen-overlap
Velaciela Mar 6, 2026
4ba08c0
test coverage: compare all column
Velaciela Mar 6, 2026
e943735
test coverage: edge cases
Velaciela Mar 6, 2026
bcdc2a3
gpu witgen: col-major
Velaciela Mar 6, 2026
1e21d37
phase5
Velaciela Mar 8, 2026
8307ba1
shard-1
Velaciela Mar 12, 2026
a24c51c
phase6-2: dispatch all 22 GPU kinds with shard metadata + enable all …
Velaciela Mar 12, 2026
45a359e
fa_sort
Velaciela Mar 12, 2026
e539505
perf-preflight
Velaciela Mar 13, 2026
12cd5ee
shardram: ec
Velaciela Mar 13, 2026
4cd7281
api
Velaciela Mar 13, 2026
2974a8a
debug
Velaciela Mar 13, 2026
018ad73
perf
Velaciela Mar 13, 2026
39078ce
profile
Velaciela Mar 13, 2026
a8cc5a3
batch_continuation_ec
Velaciela Mar 17, 2026
1fe145b
try-perf
Velaciela Mar 17, 2026
2d7f3e9
perf-minor
Velaciela Mar 17, 2026
6a21816
shardram-1
Velaciela Mar 17, 2026
1d27ae1
profile
Velaciela Mar 18, 2026
c4ab9ff
shard-1
Velaciela Mar 18, 2026
be58c5e
shard-2
Velaciela Mar 18, 2026
8fe9d32
minor: LB LH
Velaciela Mar 23, 2026
23f04f0
keccak
Velaciela Mar 23, 2026
5868490
fix-1
Velaciela Mar 23, 2026
1deb849
fix-2
Velaciela Mar 23, 2026
7c8d16a
fix-3
Velaciela Mar 23, 2026
ed9eb6e
minor
Velaciela Mar 23, 2026
cc0d7ee
part-a
Velaciela Mar 23, 2026
aa34af5
part-b
Velaciela Mar 23, 2026
e298511
part-b: fix
Velaciela Mar 23, 2026
033d729
part-c
Velaciela Mar 23, 2026
b54af50
part-c: fix
Velaciela Mar 23, 2026
7ee32ed
simplify: macro-1,2
Velaciela Mar 23, 2026
6daebf4
simplify: macro-3
Velaciela Mar 23, 2026
78a51d2
simplify: naming
Velaciela Mar 23, 2026
b690229
gpu: hal.witgen
Velaciela Mar 24, 2026
130cc4a
path: ceno_zkvm/src/instructions/gpu
Velaciela Mar 24, 2026
211c875
naming: side_effects to lk_shardram
Velaciela Mar 24, 2026
6595860
path: gpu/host_ops to gpu/utils
Velaciela Mar 24, 2026
bcf8e0c
naming: ceno_zkvm/src/instructions/gpu
Velaciela Mar 24, 2026
bc6f3eb
lints, fmt
Velaciela Mar 24, 2026
f7dc9b4
macro: test
Velaciela Mar 24, 2026
6ca050b
config, dispatch
Velaciela Mar 24, 2026
aadf86b
fmt, lints
Velaciela Mar 24, 2026
3c719dc
shard_ram: funcs
Velaciela Mar 25, 2026
bd18f1d
default: disable gpu witgen
Velaciela Mar 25, 2026
4ac6a6f
e2e: pipeline
Velaciela Mar 25, 2026
4dba098
README.md
Velaciela Mar 25, 2026
e7bb55b
invasive_changes.md
Velaciela Mar 25, 2026
e2b8ae7
revert: local path
Velaciela Mar 25, 2026
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
1 change: 1 addition & 0 deletions Cargo.lock

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

28 changes: 14 additions & 14 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -127,20 +127,20 @@ lto = "thin"
#ceno_crypto_primitives = { path = "../ceno-patch/crypto-primitives", package = "ceno_crypto_primitives" }
#ceno_syscall = { path = "../ceno-patch/syscall", package = "ceno_syscall" }

#[patch."https://github.com/scroll-tech/ceno-gpu-mock.git"]
#ceno_gpu = { path = "../ceno-gpu/cuda_hal", package = "cuda_hal", default-features = false, features = ["bb31"] }

#[patch."https://github.com/scroll-tech/gkr-backend"]
#ff_ext = { path = "../gkr-backend/crates/ff_ext", package = "ff_ext" }
#mpcs = { path = "../gkr-backend/crates/mpcs", package = "mpcs" }
#multilinear_extensions = { path = "../gkr-backend/crates/multilinear_extensions", package = "multilinear_extensions" }
#p3 = { path = "../gkr-backend/crates/p3", package = "p3" }
#poseidon = { path = "../gkr-backend/crates/poseidon", package = "poseidon" }
#sp1-curves = { path = "../gkr-backend/crates/curves", package = "sp1-curves" }
#sumcheck = { path = "../gkr-backend/crates/sumcheck", package = "sumcheck" }
#transcript = { path = "../gkr-backend/crates/transcript", package = "transcript" }
#whir = { path = "../gkr-backend/crates/whir", package = "whir" }
#witness = { path = "../gkr-backend/crates/witness", package = "witness" }
# [patch."https://github.com/scroll-tech/ceno-gpu-mock.git"]
# ceno_gpu = { path = "../ceno-gpu/cuda_hal", package = "cuda_hal", default-features = false, features = ["bb31"] }

# [patch."https://github.com/scroll-tech/gkr-backend"]
# ff_ext = { path = "../gkr-backend/crates/ff_ext", package = "ff_ext" }
# mpcs = { path = "../gkr-backend/crates/mpcs", package = "mpcs" }
# multilinear_extensions = { path = "../gkr-backend/crates/multilinear_extensions", package = "multilinear_extensions" }
# p3 = { path = "../gkr-backend/crates/p3", package = "p3" }
# poseidon = { path = "../gkr-backend/crates/poseidon", package = "poseidon" }
# sp1-curves = { path = "../gkr-backend/crates/curves", package = "sp1-curves" }
# sumcheck = { path = "../gkr-backend/crates/sumcheck", package = "sumcheck" }
# transcript = { path = "../gkr-backend/crates/transcript", package = "transcript" }
# whir = { path = "../gkr-backend/crates/whir", package = "whir" }
# witness = { path = "../gkr-backend/crates/witness", package = "witness" }

# [patch."https://github.com/scroll-tech/openvm.git"]
# openvm = { path = "../openvm-scroll-tech/crates/toolchain/openvm", default-features = false }
Expand Down
4 changes: 3 additions & 1 deletion ceno_emul/src/addr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@ pub type Word = u32;
pub type SWord = i32;
pub type Addr = u32;
pub type Cycle = u64;
pub type RegIdx = usize;
pub type RegIdx = u8;

#[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
#[repr(C)]
pub struct ByteAddr(pub u32);

#[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(C)]
pub struct WordAddr(pub u32);

impl From<ByteAddr> for WordAddr {
Expand Down
41 changes: 22 additions & 19 deletions ceno_emul/src/disassemble/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use crate::rv32im::{InsnKind, Instruction};
use crate::{
addr::RegIdx,
rv32im::{InsnKind, Instruction},
};
use itertools::izip;
use rrs_lib::{
InstructionProcessor,
Expand All @@ -19,9 +22,9 @@ impl Instruction {
pub const fn from_r_type(kind: InsnKind, dec_insn: &RType, raw: u32) -> Self {
Self {
kind,
rd: dec_insn.rd,
rs1: dec_insn.rs1,
rs2: dec_insn.rs2,
rd: dec_insn.rd as RegIdx,
rs1: dec_insn.rs1 as RegIdx,
rs2: dec_insn.rs2 as RegIdx,
imm: 0,
raw,
}
Expand All @@ -32,8 +35,8 @@ impl Instruction {
pub const fn from_i_type(kind: InsnKind, dec_insn: &IType, raw: u32) -> Self {
Self {
kind,
rd: dec_insn.rd,
rs1: dec_insn.rs1,
rd: dec_insn.rd as RegIdx,
rs1: dec_insn.rs1 as RegIdx,
imm: dec_insn.imm,
rs2: 0,
raw,
Expand All @@ -45,8 +48,8 @@ impl Instruction {
pub const fn from_i_type_shamt(kind: InsnKind, dec_insn: &ITypeShamt, raw: u32) -> Self {
Self {
kind,
rd: dec_insn.rd,
rs1: dec_insn.rs1,
rd: dec_insn.rd as RegIdx,
rs1: dec_insn.rs1 as RegIdx,
imm: dec_insn.shamt as i32,
rs2: 0,
raw,
Expand All @@ -59,8 +62,8 @@ impl Instruction {
Self {
kind,
rd: 0,
rs1: dec_insn.rs1,
rs2: dec_insn.rs2,
rs1: dec_insn.rs1 as RegIdx,
rs2: dec_insn.rs2 as RegIdx,
imm: dec_insn.imm,
raw,
}
Expand All @@ -72,8 +75,8 @@ impl Instruction {
Self {
kind,
rd: 0,
rs1: dec_insn.rs1,
rs2: dec_insn.rs2,
rs1: dec_insn.rs1 as RegIdx,
rs2: dec_insn.rs2 as RegIdx,
imm: dec_insn.imm,
raw,
}
Expand Down Expand Up @@ -231,7 +234,7 @@ impl InstructionProcessor for InstructionTranspiler {
fn process_jal(&mut self, dec_insn: JType) -> Self::InstructionResult {
Instruction {
kind: InsnKind::JAL,
rd: dec_insn.rd,
rd: dec_insn.rd as RegIdx,
rs1: 0,
rs2: 0,
imm: dec_insn.imm,
Expand All @@ -242,8 +245,8 @@ impl InstructionProcessor for InstructionTranspiler {
fn process_jalr(&mut self, dec_insn: IType) -> Self::InstructionResult {
Instruction {
kind: InsnKind::JALR,
rd: dec_insn.rd,
rs1: dec_insn.rs1,
rd: dec_insn.rd as RegIdx,
rs1: dec_insn.rs1 as RegIdx,
rs2: 0,
imm: dec_insn.imm,
raw: self.word,
Expand All @@ -265,7 +268,7 @@ impl InstructionProcessor for InstructionTranspiler {
// See [`InstructionTranspiler::process_auipc`] for more background on the conversion.
Instruction {
kind: InsnKind::ADDI,
rd: dec_insn.rd,
rd: dec_insn.rd as RegIdx,
rs1: 0,
rs2: 0,
imm: dec_insn.imm,
Expand All @@ -276,7 +279,7 @@ impl InstructionProcessor for InstructionTranspiler {
{
Instruction {
kind: InsnKind::LUI,
rd: dec_insn.rd,
rd: dec_insn.rd as RegIdx,
rs1: 0,
rs2: 0,
imm: dec_insn.imm,
Expand Down Expand Up @@ -311,7 +314,7 @@ impl InstructionProcessor for InstructionTranspiler {
// real world scenarios like a `reth` run.
Instruction {
kind: InsnKind::ADDI,
rd: dec_insn.rd,
rd: dec_insn.rd as RegIdx,
rs1: 0,
rs2: 0,
imm: dec_insn.imm.wrapping_add(pc as i32),
Expand All @@ -322,7 +325,7 @@ impl InstructionProcessor for InstructionTranspiler {
{
Instruction {
kind: InsnKind::AUIPC,
rd: dec_insn.rd,
rd: dec_insn.rd as RegIdx,
rs1: 0,
rs2: 0,
imm: dec_insn.imm,
Expand Down
6 changes: 3 additions & 3 deletions ceno_emul/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ pub use platform::{CENO_PLATFORM, Platform};
mod tracer;
pub use tracer::{
Change, FullTracer, FullTracerConfig, LatestAccesses, MemOp, NextAccessPair, NextCycleAccess,
PreflightTracer, PreflightTracerConfig, ReadOp, ShardPlanBuilder, StepCellExtractor, StepIndex,
StepRecord, Tracer, WriteOp,
PackedNextAccessEntry, PreflightTracer, PreflightTracerConfig, ReadOp, ShardPlanBuilder,
StepCellExtractor, StepIndex, StepRecord, Tracer, WriteOp,
};

mod vm_state;
Expand All @@ -34,7 +34,7 @@ pub use syscalls::{
BN254_FP_MUL, BN254_FP2_ADD, BN254_FP2_MUL, KECCAK_PERMUTE, SECP256K1_ADD,
SECP256K1_DECOMPRESS, SECP256K1_DOUBLE, SECP256K1_SCALAR_INVERT, SECP256R1_ADD,
SECP256R1_DECOMPRESS, SECP256R1_DOUBLE, SECP256R1_SCALAR_INVERT, SHA_EXTEND, SyscallSpec,
UINT256_MUL,
SyscallWitness, UINT256_MUL,
bn254::{
BN254_FP_WORDS, BN254_FP2_WORDS, BN254_POINT_WORDS, Bn254AddSpec, Bn254DoubleSpec,
Bn254Fp2AddSpec, Bn254Fp2MulSpec, Bn254FpAddSpec, Bn254FpMulSpec,
Expand Down
4 changes: 2 additions & 2 deletions ceno_emul/src/platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ impl Platform {
/// Virtual address of a register.
pub const fn register_vma(index: RegIdx) -> Addr {
// Register VMAs are aligned, cannot be confused with indices, and readable in hex.
(index << 8) as Addr
(index as Addr) << 8
}

/// Register index from a virtual address (unchecked).
Expand Down Expand Up @@ -220,7 +220,7 @@ mod tests {
// Registers do not overlap with ROM or RAM.
for reg in [
Platform::register_vma(0),
Platform::register_vma(VMState::<PreflightTracer>::REG_COUNT - 1),
Platform::register_vma((VMState::<PreflightTracer>::REG_COUNT - 1) as RegIdx),
] {
assert!(!p.is_rom(reg));
assert!(!p.is_ram(reg));
Expand Down
18 changes: 10 additions & 8 deletions ceno_emul/src/rv32im.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ use super::addr::{ByteAddr, RegIdx, WORD_SIZE, Word, WordAddr};
pub const fn encode_rv32(kind: InsnKind, rs1: u32, rs2: u32, rd: u32, imm: i32) -> Instruction {
Instruction {
kind,
rs1: rs1 as usize,
rs2: rs2 as usize,
rd: rd as usize,
rs1: rs1 as RegIdx,
rs2: rs2 as RegIdx,
rd: rd as RegIdx,
imm,
raw: 0,
}
Expand All @@ -43,9 +43,9 @@ pub const fn encode_rv32(kind: InsnKind, rs1: u32, rs2: u32, rd: u32, imm: i32)
pub const fn encode_rv32u(kind: InsnKind, rs1: u32, rs2: u32, rd: u32, imm: u32) -> Instruction {
Instruction {
kind,
rs1: rs1 as usize,
rs2: rs2 as usize,
rd: rd as usize,
rs1: rs1 as RegIdx,
rs2: rs2 as RegIdx,
rd: rd as RegIdx,
imm: imm as i32,
raw: 0,
}
Expand Down Expand Up @@ -113,6 +113,7 @@ pub enum TrapCause {
}

#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord)]
#[repr(C)]
pub struct Instruction {
pub kind: InsnKind,
pub rs1: RegIdx,
Expand Down Expand Up @@ -162,6 +163,7 @@ use InsnFormat::*;
ToPrimitive,
Default,
)]
#[repr(u8)]
#[allow(clippy::upper_case_acronyms)]
pub enum InsnKind {
#[default]
Expand Down Expand Up @@ -425,7 +427,7 @@ fn step_compute<M: EmuContext>(ctx: &mut M, kind: InsnKind, insn: &Instruction)
if !new_pc.is_aligned() {
return ctx.trap(TrapCause::InstructionAddressMisaligned);
}
ctx.store_register(insn.rd_internal() as usize, out)?;
ctx.store_register(insn.rd_internal() as RegIdx, out)?;
ctx.set_pc(new_pc);
Ok(true)
}
Expand Down Expand Up @@ -502,7 +504,7 @@ fn step_load<M: EmuContext>(ctx: &mut M, kind: InsnKind, decoded: &Instruction)
}
_ => unreachable!(),
};
ctx.store_register(decoded.rd_internal() as usize, out)?;
ctx.store_register(decoded.rd_internal() as RegIdx, out)?;
ctx.set_pc(ctx.get_pc() + WORD_SIZE);
Ok(true)
}
Expand Down
8 changes: 2 additions & 6 deletions ceno_emul/src/syscalls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,15 @@ pub fn handle_syscall<T: Tracer>(vm: &VMState<T>, function_code: u32) -> Result<
/// A syscall event, available to the circuit witness generators.
/// TODO: separate mem_ops into two stages: reads-and-writes
#[derive(Clone, Debug, Default, PartialEq, Eq)]
#[non_exhaustive]
pub struct SyscallWitness {
pub mem_ops: Vec<WriteOp>,
pub reg_ops: Vec<WriteOp>,
_marker: (),
}

impl SyscallWitness {
fn new(mem_ops: Vec<WriteOp>, reg_ops: Vec<WriteOp>) -> SyscallWitness {
SyscallWitness {
mem_ops,
reg_ops,
_marker: (),
}
SyscallWitness { mem_ops, reg_ops }
}
}

Expand Down
15 changes: 11 additions & 4 deletions ceno_emul/src/test_utils.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
use crate::{
CENO_PLATFORM, InsnKind, Instruction, Platform, Program, StepRecord, VMState, encode_rv32,
encode_rv32u, syscalls::KECCAK_PERMUTE,
encode_rv32u,
syscalls::{KECCAK_PERMUTE, SyscallWitness},
tracer::FullTracerConfig,
};
use anyhow::Result;

pub fn keccak_step() -> (StepRecord, Vec<Instruction>) {
pub fn keccak_step() -> (StepRecord, Vec<Instruction>, Vec<SyscallWitness>) {
let instructions = vec![
// Call Keccak-f.
load_immediate(Platform::reg_arg0() as u32, CENO_PLATFORM.heap.start),
Expand All @@ -23,11 +25,16 @@ pub fn keccak_step() -> (StepRecord, Vec<Instruction>) {
instructions.clone(),
Default::default(),
);
let mut vm = VMState::new(CENO_PLATFORM.clone(), program.into());
let mut vm: VMState = VMState::new_with_tracer_config(
CENO_PLATFORM.clone(),
program.into(),
FullTracerConfig { max_step_shard: 10 },
);
vm.iter_until_halt().collect::<Result<Vec<_>>>().unwrap();
let steps = vm.tracer().recorded_steps();
let syscall_witnesses = vm.tracer().syscall_witnesses().to_vec();

(steps[2].clone(), instructions)
(steps[2], instructions, syscall_witnesses)
}

const fn load_immediate(rd: u32, imm: u32) -> Instruction {
Expand Down
Loading
Loading