Skip to content

Commit

Permalink
fix CostEstimator
Browse files Browse the repository at this point in the history
  • Loading branch information
lispc committed Sep 8, 2024
1 parent b90a7f8 commit 8db9e57
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion crates/core/machine/src/riscv/cost.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use p3_baby_bear::BabyBear;
use sp1_core_executor::{syscalls::SyscallCode, ExecutionReport, Opcode};

use crate::riscv::RiscvAirDiscriminants;
use crate::{riscv::RiscvAirDiscriminants, syscall::precompiles::bn254_scalar};

use super::RiscvAir;

Expand Down Expand Up @@ -136,6 +136,26 @@ impl CostEstimator for ExecutionReport {
total_area += (bn254_fp2_mul_events as u64) * costs[&RiscvAirDiscriminants::Bn254Fp2Mul];
total_chips += 1;

let bn254_scalar_mul_events =
*self.syscall_counts.get(&SyscallCode::BN254_SCALAR_MUL).unwrap_or(&0);
total_area +=
(bn254_scalar_mul_events as u64) * costs[&RiscvAirDiscriminants::Bn254ScalarMul];
total_chips += 1;

let bn254_scalar_mac_events =
*self.syscall_counts.get(&SyscallCode::BN254_SCALAR_MAC).unwrap_or(&0);
total_area +=
(bn254_scalar_mac_events as u64) * costs[&RiscvAirDiscriminants::Bn254ScalarMac];
total_chips += 1;

let mem_copy_32_events = *self.syscall_counts.get(&SyscallCode::MEMCPY_32).unwrap_or(&0);
total_area += (mem_copy_32_events as u64) * costs[&RiscvAirDiscriminants::MemCopy32];
total_chips += 1;

let mem_copy_64_events = *self.syscall_counts.get(&SyscallCode::MEMCPY_64).unwrap_or(&0);
total_area += (mem_copy_64_events as u64) * costs[&RiscvAirDiscriminants::MemCopy64];
total_chips += 1;

let bls12381_decompress_events =
*self.syscall_counts.get(&SyscallCode::BLS12381_DECOMPRESS).unwrap_or(&0);
total_area +=
Expand Down

0 comments on commit 8db9e57

Please sign in to comment.