diff --git a/benches/benches/block_target_gas.rs b/benches/benches/block_target_gas.rs index fddd14a24c9..36aa5e1ecf6 100644 --- a/benches/benches/block_target_gas.rs +++ b/benches/benches/block_target_gas.rs @@ -1,10 +1,10 @@ use block_target_gas_set::{ - alu::run_alu, - contract::run_contract, - crypto::run_crypto, - flow::run_flow, + // alu::run_alu, + // contract::run_contract, + // crypto::run_crypto, + // flow::run_flow, memory::run_memory, - other::run_other, + // other::run_other, }; use criterion::{ criterion_group, @@ -456,17 +456,17 @@ fn run_with_service_with_extra_inputs( fn block_target_gas(c: &mut Criterion) { let mut group = c.benchmark_group("block target estimation"); - run_alu(&mut group); + // run_alu(&mut group); - run_contract(&mut group); + // run_contract(&mut group); - run_crypto(&mut group); + // run_crypto(&mut group); - run_flow(&mut group); + // run_flow(&mut group); run_memory(&mut group); - run_other(&mut group); + // run_other(&mut group); group.finish(); } diff --git a/benches/benches/block_target_gas_set/memory.rs b/benches/benches/block_target_gas_set/memory.rs index 8c31790d4ea..ef01b07aa90 100644 --- a/benches/benches/block_target_gas_set/memory.rs +++ b/benches/benches/block_target_gas_set/memory.rs @@ -25,264 +25,265 @@ use crate::{ // SB: Store byte // SW: Store word pub fn run_memory(group: &mut BenchmarkGroup) { - run( - "memory/aloc opcode", - group, - [op::movi(0x10, 0), op::aloc(0x10), op::jmpb(RegId::ZERO, 0)].to_vec(), - vec![], - ); - - // Extend by 10 10 times and then shrink by 100 once. This is to hopefully allow the extend to be - // the dominant opcode - run( - "memory/cfe opcode", - group, - vec![ - op::movi(0x10, 10), - op::movi(0x11, 100), - op::cfe(0x10), - op::cfe(0x10), - op::cfe(0x10), - op::cfe(0x10), - op::cfe(0x10), - op::cfe(0x10), - op::cfe(0x10), - op::cfe(0x10), - op::cfe(0x10), - op::cfe(0x10), - op::cfs(0x11), - op::jmpb(RegId::ZERO, 10), - ], - vec![], - ); - - // Extend by 10 10 times and then shrink by 100 once. This is to hopefully allow the extend to be - // the dominant opcode - run( - "memory/cfei opcode", - group, - vec![ - op::cfei(10), - op::cfei(10), - op::cfei(10), - op::cfei(10), - op::cfei(10), - op::cfei(10), - op::cfei(10), - op::cfei(10), - op::cfei(10), - op::cfei(10), - op::cfei(10), - op::cfsi(100), - op::jmpb(RegId::ZERO, 10), - ], - vec![], - ); - - // Extend by 100 once and then shrink by 10 10 times. This is to hopefully allow the shrink to - // be the dominant opcode - run( - "memory/cfs opcode", - group, - vec![ - op::movi(0x10, 100), - op::movi(0x11, 10), - op::cfe(0x10), - op::cfs(0x11), - op::cfs(0x11), - op::cfs(0x11), - op::cfs(0x11), - op::cfs(0x11), - op::cfs(0x11), - op::cfs(0x11), - op::cfs(0x11), - op::cfs(0x11), - op::cfs(0x11), - op::jmpb(RegId::ZERO, 10), - ], - vec![], - ); - - // Extend by 100 once and then shrink by 10 10 times. This is to hopefully allow the shrink to - // be the dominant opcode - run( - "memory/cfsi opcode", - group, - vec![ - op::cfei(100), - op::cfsi(10), - op::cfsi(10), - op::cfsi(10), - op::cfsi(10), - op::cfsi(10), - op::cfsi(10), - op::cfsi(10), - op::cfsi(10), - op::cfsi(10), - op::cfsi(10), - op::jmpb(RegId::ZERO, 10), - ], - vec![], - ); - - run( - "memory/lb opcode", - group, - [op::lb(0x10, RegId::ONE, 10), op::jmpb(RegId::ZERO, 0)].to_vec(), - vec![], - ); - - run( - "memory/lw opcode", - group, - [op::lw(0x10, RegId::ONE, 10), op::jmpb(RegId::ZERO, 0)].to_vec(), - vec![], - ); - - for i in arb_dependent_cost_values() { - let id = format!("memory/mcl opcode {:?}", i); - run( - &id, - group, - vec![ - op::movi(0x11, i), - op::aloc(0x11), - op::move_(0x10, RegId::HP), - op::mcl(0x10, 0x11), - op::jmpb(RegId::ZERO, 0), - ], - vec![], - ); - } - - for i in arb_dependent_cost_values() { - let id = format!("memory/mcli opcode {:?}", i); - run( - &id, - group, - vec![ - op::movi(0x11, i), - op::aloc(0x11), - op::move_(0x10, RegId::HP), - op::mcli(0x10, i), - op::jmpb(RegId::ZERO, 0), - ], - vec![], - ); - } - - for i in arb_dependent_cost_values() { - let id = format!("memory/mcp opcode {:?}", i); - run( - &id, - group, - vec![ - op::movi(0x11, i), - op::aloc(0x11), - op::move_(0x10, RegId::HP), - op::mcp(0x10, RegId::ZERO, 0x11), - op::jmpb(RegId::ZERO, 0), - ], - vec![], - ); - } - - let valid_values: Vec<_> = arb_dependent_cost_values() - .iter() - .copied() - .take_while(|p| *p < (1 << 12)) // 12 bits - .collect(); - for val in valid_values { - let id = format!("memory/mcpi opcode {:?}", val); - let val_as_u16 = (val).try_into().unwrap(); - run( - &id, - group, - vec![ - op::movi(0x11, val), - op::aloc(0x11), - op::move_(0x10, RegId::HP), - op::mcpi(0x10, RegId::ZERO, val_as_u16), - op::jmpb(RegId::ZERO, 0), - ], - vec![], - ); - } + // run( + // "memory/aloc opcode", + // group, + // [op::movi(0x10, 0), op::aloc(0x10), op::jmpb(RegId::ZERO, 0)].to_vec(), + // vec![], + // ); + // + // // Extend by 10 10 times and then shrink by 100 once. This is to hopefully allow the extend to be + // // the dominant opcode + // run( + // "memory/cfe opcode", + // group, + // vec![ + // op::movi(0x10, 10), + // op::movi(0x11, 100), + // op::cfe(0x10), + // op::cfe(0x10), + // op::cfe(0x10), + // op::cfe(0x10), + // op::cfe(0x10), + // op::cfe(0x10), + // op::cfe(0x10), + // op::cfe(0x10), + // op::cfe(0x10), + // op::cfe(0x10), + // op::cfs(0x11), + // op::jmpb(RegId::ZERO, 10), + // ], + // vec![], + // ); + // + // // Extend by 10 10 times and then shrink by 100 once. This is to hopefully allow the extend to be + // // the dominant opcode + // run( + // "memory/cfei opcode", + // group, + // vec![ + // op::cfei(10), + // op::cfei(10), + // op::cfei(10), + // op::cfei(10), + // op::cfei(10), + // op::cfei(10), + // op::cfei(10), + // op::cfei(10), + // op::cfei(10), + // op::cfei(10), + // op::cfei(10), + // op::cfsi(100), + // op::jmpb(RegId::ZERO, 10), + // ], + // vec![], + // ); + // + // // Extend by 100 once and then shrink by 10 10 times. This is to hopefully allow the shrink to + // // be the dominant opcode + // run( + // "memory/cfs opcode", + // group, + // vec![ + // op::movi(0x10, 100), + // op::movi(0x11, 10), + // op::cfe(0x10), + // op::cfs(0x11), + // op::cfs(0x11), + // op::cfs(0x11), + // op::cfs(0x11), + // op::cfs(0x11), + // op::cfs(0x11), + // op::cfs(0x11), + // op::cfs(0x11), + // op::cfs(0x11), + // op::cfs(0x11), + // op::jmpb(RegId::ZERO, 10), + // ], + // vec![], + // ); + // + // // Extend by 100 once and then shrink by 10 10 times. This is to hopefully allow the shrink to + // // be the dominant opcode + // run( + // "memory/cfsi opcode", + // group, + // vec![ + // op::cfei(100), + // op::cfsi(10), + // op::cfsi(10), + // op::cfsi(10), + // op::cfsi(10), + // op::cfsi(10), + // op::cfsi(10), + // op::cfsi(10), + // op::cfsi(10), + // op::cfsi(10), + // op::cfsi(10), + // op::jmpb(RegId::ZERO, 10), + // ], + // vec![], + // ); + // + // run( + // "memory/lb opcode", + // group, + // [op::lb(0x10, RegId::ONE, 10), op::jmpb(RegId::ZERO, 0)].to_vec(), + // vec![], + // ); + // + // run( + // "memory/lw opcode", + // group, + // [op::lw(0x10, RegId::ONE, 10), op::jmpb(RegId::ZERO, 0)].to_vec(), + // vec![], + // ); + // + // for i in arb_dependent_cost_values() { + // let id = format!("memory/mcl opcode {:?}", i); + // run( + // &id, + // group, + // vec![ + // op::movi(0x11, i), + // op::aloc(0x11), + // op::move_(0x10, RegId::HP), + // op::mcl(0x10, 0x11), + // op::jmpb(RegId::ZERO, 0), + // ], + // vec![], + // ); + // } + // + // for i in arb_dependent_cost_values() { + // let id = format!("memory/mcli opcode {:?}", i); + // run( + // &id, + // group, + // vec![ + // op::movi(0x11, i), + // op::aloc(0x11), + // op::move_(0x10, RegId::HP), + // op::mcli(0x10, i), + // op::jmpb(RegId::ZERO, 0), + // ], + // vec![], + // ); + // } + // + // for i in arb_dependent_cost_values() { + // let id = format!("memory/mcp opcode {:?}", i); + // run( + // &id, + // group, + // vec![ + // op::movi(0x11, i), + // op::aloc(0x11), + // op::move_(0x10, RegId::HP), + // op::mcp(0x10, RegId::ZERO, 0x11), + // op::jmpb(RegId::ZERO, 0), + // ], + // vec![], + // ); + // } + // + // let valid_values: Vec<_> = arb_dependent_cost_values() + // .iter() + // .copied() + // .take_while(|p| *p < (1 << 12)) // 12 bits + // .collect(); + // for val in valid_values { + // let id = format!("memory/mcpi opcode {:?}", val); + // let val_as_u16 = (val).try_into().unwrap(); + // run( + // &id, + // group, + // vec![ + // op::movi(0x11, val), + // op::aloc(0x11), + // op::move_(0x10, RegId::HP), + // op::mcpi(0x10, RegId::ZERO, val_as_u16), + // op::jmpb(RegId::ZERO, 0), + // ], + // vec![], + // ); + // } for i in arb_dependent_cost_values() { let id = format!("memory/meq opcode {:?}", i); let mut script = set_full_word(0x13, i as u64); script.extend(vec![ + op::cfe(0x13), op::meq(0x10, RegId::ZERO, RegId::ZERO, 0x13), op::jmpb(RegId::ZERO, 0), ]); run(&id, group, script, vec![]); } - let full_mask = (1 << 24) - 1; - - // Assumes that `pshh` has a correct cost - run( - "memory/poph opcode", - group, - vec![ - op::pshh(full_mask), - op::poph(full_mask), - op::jmpb(RegId::ZERO, 1), - ], - vec![], - ); - - // Assumes that `pshl` has a correct cost - run( - "memory/popl opcode", - group, - vec![ - op::pshl(full_mask), - op::popl(full_mask), - op::jmpb(RegId::ZERO, 1), - ], - vec![], - ); - - run( - "memory/pshh opcode", - group, - vec![op::pshh(full_mask), op::jmpb(RegId::ZERO, 0)], - vec![], - ); - - run( - "memory/pshl opcode", - group, - vec![op::pshl(full_mask), op::jmpb(RegId::ZERO, 0)], - vec![], - ); - - run( - "memory/sb opcode", - group, - vec![ - op::aloc(RegId::ONE), - op::move_(0x10, RegId::HP), - op::movi(0x11, 50), - op::sb(0x10, 0x11, 0), - op::jmpb(RegId::ZERO, 0), - ], - vec![], - ); - - run( - "memory/sw opcode", - group, - vec![ - op::movi(0x10, 8), - op::aloc(0x10), - op::move_(0x10, RegId::HP), - op::movi(0x11, 50), - op::sw(0x10, 0x11, 0), - op::jmpb(RegId::ZERO, 0), - ], - vec![], - ); + // let full_mask = (1 << 24) - 1; + // + // // Assumes that `pshh` has a correct cost + // run( + // "memory/poph opcode", + // group, + // vec![ + // op::pshh(full_mask), + // op::poph(full_mask), + // op::jmpb(RegId::ZERO, 1), + // ], + // vec![], + // ); + // + // // Assumes that `pshl` has a correct cost + // run( + // "memory/popl opcode", + // group, + // vec![ + // op::pshl(full_mask), + // op::popl(full_mask), + // op::jmpb(RegId::ZERO, 1), + // ], + // vec![], + // ); + // + // run( + // "memory/pshh opcode", + // group, + // vec![op::pshh(full_mask), op::jmpb(RegId::ZERO, 0)], + // vec![], + // ); + // + // run( + // "memory/pshl opcode", + // group, + // vec![op::pshl(full_mask), op::jmpb(RegId::ZERO, 0)], + // vec![], + // ); + // + // run( + // "memory/sb opcode", + // group, + // vec![ + // op::aloc(RegId::ONE), + // op::move_(0x10, RegId::HP), + // op::movi(0x11, 50), + // op::sb(0x10, 0x11, 0), + // op::jmpb(RegId::ZERO, 0), + // ], + // vec![], + // ); + // + // run( + // "memory/sw opcode", + // group, + // vec![ + // op::movi(0x10, 8), + // op::aloc(0x10), + // op::move_(0x10, RegId::HP), + // op::movi(0x11, 50), + // op::sw(0x10, 0x11, 0), + // op::jmpb(RegId::ZERO, 0), + // ], + // vec![], + // ); } diff --git a/benches/benches/utils.rs b/benches/benches/utils.rs index 52b82cee529..9a682eb0eea 100644 --- a/benches/benches/utils.rs +++ b/benches/benches/utils.rs @@ -57,13 +57,19 @@ pub fn make_u256(reg: u8, v: U256) -> Vec { } pub fn arb_dependent_cost_values() -> Vec { - let mut linear = vec![1, 10, 100, 1000, 10_000]; + let mut linear = vec![ + 1, 10, 100, 1000, 10_000, 100_000, 200_000, 1_000_000, 4_500_000, 17_700_000, + 27_800_000, 31_400_000, 50_000_000, 62_914_560, + ]; let mut l = successors(Some(100_000.0f64), |n| Some(n / 1.5)) .take(5) .map(|f| f as u32) .collect::>(); - l.sort_unstable(); linear.extend(l); + + linear.sort_unstable(); + linear.dedup(); + linear } diff --git a/benches/benches/vm.rs b/benches/benches/vm.rs index f895290bff8..b86be29d649 100644 --- a/benches/benches/vm.rs +++ b/benches/benches/vm.rs @@ -80,12 +80,12 @@ where fn vm(c: &mut Criterion) { alu::run(c); - crypto::run(c); - flow::run(c); + // crypto::run(c); + // flow::run(c); mem::run(c); - blockchain::run(c); - contract_root(c); - state_root(c); + // blockchain::run(c); + // contract_root(c); + // state_root(c); vm_initialization(c); } diff --git a/benches/benches/vm_set/alu.rs b/benches/benches/vm_set/alu.rs index 64c563e6b04..392ba94d11b 100644 --- a/benches/benches/vm_set/alu.rs +++ b/benches/benches/vm_set/alu.rs @@ -27,179 +27,179 @@ use super::utils::{ }; pub fn run(c: &mut Criterion) { - let linear_short = linear_short(); - - run_group_ref( - &mut c.benchmark_group("add"), - "add", - VmBench::new(op::add(0x10, 0x11, 0x12)) - .with_prepare_script(vec![op::movi(0x11, 100000), op::movi(0x12, 27)]), - ); - - run_group_ref( - &mut c.benchmark_group("addi"), - "addi", - VmBench::new(op::addi(0x10, 0x11, 27)) - .with_prepare_script(vec![op::movi(0x11, 100000)]), - ); - - // aloc - { - let mut aloc = c.benchmark_group("aloc"); - - let mut aloc_linear = linear_short.clone(); - aloc_linear.push(1_000_000); - aloc_linear.push(10_000_000); - aloc_linear.push(30_000_000); - for i in aloc_linear { - let bench = - VmBench::new(op::aloc(0x10)).with_prepare_script(set_full_word(0x10, i)); - aloc.throughput(Throughput::Bytes(i)); - run_group_ref(&mut aloc, format!("{i}"), bench); - } - - aloc.finish(); - } - - run_group_ref( - &mut c.benchmark_group("and"), - "and", - VmBench::new(op::and(0x10, 0x11, 0x12)) - .with_prepare_script(vec![op::movi(0x11, 100000), op::movi(0x12, 27)]), - ); - - run_group_ref( - &mut c.benchmark_group("andi"), - "andi", - VmBench::new(op::andi(0x10, 0x11, 27)) - .with_prepare_script(vec![op::movi(0x11, 100000)]), - ); - - run_group_ref( - &mut c.benchmark_group("div"), - "div", - VmBench::new(op::div(0x10, 0x11, 0x12)) - .with_prepare_script(vec![op::movi(0x11, 100000), op::movi(0x12, 27)]), - ); - - run_group_ref( - &mut c.benchmark_group("divi"), - "divi", - VmBench::new(op::divi(0x10, 0x11, 27)) - .with_prepare_script(vec![op::movi(0x11, 100000)]), - ); - - run_group_ref( - &mut c.benchmark_group("eq"), - "eq", - VmBench::new(op::eq(0x10, 0x11, 0x12)) - .with_prepare_script(vec![op::movi(0x11, 100000), op::movi(0x12, 27)]), - ); - - run_group_ref( - &mut c.benchmark_group("exp"), - "exp", - VmBench::new(op::exp(0x10, 0x11, 0x12)) - .with_prepare_script(vec![op::movi(0x11, 23), op::movi(0x12, 11)]), - ); - - run_group_ref( - &mut c.benchmark_group("expi"), - "expi", - VmBench::new(op::exp(0x10, 0x11, 11)) - .with_prepare_script(vec![op::movi(0x11, 23)]), - ); - - run_group_ref( - &mut c.benchmark_group("gt"), - "gt", - VmBench::new(op::gt(0x10, 0x11, 0x12)) - .with_prepare_script(vec![op::movi(0x11, 100000), op::movi(0x12, 27)]), - ); - - { - let count = 254; - let correct_index = count - 1; // Have the last index be the correct one. The builder includes an extra input, so it's the 255th index (254). - run_group_ref( - &mut c.benchmark_group("gtf"), - "gtf", - VmBench::new(op::gtf_args(0x10, 0x11, GTFArgs::InputContractOutputIndex)) - .with_empty_contracts_count(count) - .with_prepare_script(vec![op::movi(0x11, correct_index as u32)]), - ); - } - - run_group_ref( - &mut c.benchmark_group("lt"), - "lt", - VmBench::new(op::lt(0x10, 0x11, 0x12)) - .with_prepare_script(vec![op::movi(0x11, 100000), op::movi(0x12, 27)]), - ); - - run_group_ref( - &mut c.benchmark_group("mldv"), - "mldv", - VmBench::new(op::mldv(0x10, 0x11, 0x12, 0x13)).with_prepare_script(vec![ - op::movi(0x11, 123456), - op::not(0x12, RegId::ZERO), - op::movi(0x13, 234567), - ]), - ); - - run_group_ref( - &mut c.benchmark_group("mlog"), - "mlog", - VmBench::new(op::mlog(0x10, 0x11, 0x12)) - .with_prepare_script(vec![op::movi(0x11, 100000), op::movi(0x12, 27)]), - ); - - run_group_ref( - &mut c.benchmark_group("mod"), - "mod", - VmBench::new(op::mod_(0x10, 0x11, 0x12)) - .with_prepare_script(vec![op::movi(0x11, 100000), op::movi(0x12, 27)]), - ); - - run_group_ref( - &mut c.benchmark_group("modi"), - "modi", - VmBench::new(op::modi(0x10, 0x11, 27)) - .with_prepare_script(vec![op::movi(0x11, 100000)]), - ); - - run_group_ref( - &mut c.benchmark_group("move"), - "move", - VmBench::new(op::move_(0x10, 0x11)) - .with_prepare_script(vec![op::movi(0x11, 100000)]), - ); - - run_group_ref( - &mut c.benchmark_group("movi"), - "movi", - VmBench::new(op::movi(0x10, 27)), - ); - - run_group_ref( - &mut c.benchmark_group("mroo"), - "mroo", - VmBench::new(op::mroo(0x10, 0x11, 0x12)) - .with_prepare_script(vec![op::movi(0x11, 100000), op::movi(0x12, 27)]), - ); - - run_group_ref( - &mut c.benchmark_group("mul"), - "mul", - VmBench::new(op::mul(0x10, 0x11, 0x12)) - .with_prepare_script(vec![op::movi(0x11, 100000), op::movi(0x12, 27)]), - ); - - run_group_ref( - &mut c.benchmark_group("muli"), - "muli", - VmBench::new(op::muli(0x10, 0x11, 27)) - .with_prepare_script(vec![op::movi(0x11, 100000)]), - ); + // let linear_short = linear_short(); + // + // run_group_ref( + // &mut c.benchmark_group("add"), + // "add", + // VmBench::new(op::add(0x10, 0x11, 0x12)) + // .with_prepare_script(vec![op::movi(0x11, 100000), op::movi(0x12, 27)]), + // ); + // + // run_group_ref( + // &mut c.benchmark_group("addi"), + // "addi", + // VmBench::new(op::addi(0x10, 0x11, 27)) + // .with_prepare_script(vec![op::movi(0x11, 100000)]), + // ); + // + // // aloc + // { + // let mut aloc = c.benchmark_group("aloc"); + // + // let mut aloc_linear = linear_short.clone(); + // aloc_linear.push(1_000_000); + // aloc_linear.push(10_000_000); + // aloc_linear.push(30_000_000); + // for i in aloc_linear { + // let bench = + // VmBench::new(op::aloc(0x10)).with_prepare_script(set_full_word(0x10, i)); + // aloc.throughput(Throughput::Bytes(i)); + // run_group_ref(&mut aloc, format!("{i}"), bench); + // } + // + // aloc.finish(); + // } + // + // run_group_ref( + // &mut c.benchmark_group("and"), + // "and", + // VmBench::new(op::and(0x10, 0x11, 0x12)) + // .with_prepare_script(vec![op::movi(0x11, 100000), op::movi(0x12, 27)]), + // ); + // + // run_group_ref( + // &mut c.benchmark_group("andi"), + // "andi", + // VmBench::new(op::andi(0x10, 0x11, 27)) + // .with_prepare_script(vec![op::movi(0x11, 100000)]), + // ); + // + // run_group_ref( + // &mut c.benchmark_group("div"), + // "div", + // VmBench::new(op::div(0x10, 0x11, 0x12)) + // .with_prepare_script(vec![op::movi(0x11, 100000), op::movi(0x12, 27)]), + // ); + // + // run_group_ref( + // &mut c.benchmark_group("divi"), + // "divi", + // VmBench::new(op::divi(0x10, 0x11, 27)) + // .with_prepare_script(vec![op::movi(0x11, 100000)]), + // ); + // + // run_group_ref( + // &mut c.benchmark_group("eq"), + // "eq", + // VmBench::new(op::eq(0x10, 0x11, 0x12)) + // .with_prepare_script(vec![op::movi(0x11, 100000), op::movi(0x12, 27)]), + // ); + // + // run_group_ref( + // &mut c.benchmark_group("exp"), + // "exp", + // VmBench::new(op::exp(0x10, 0x11, 0x12)) + // .with_prepare_script(vec![op::movi(0x11, 23), op::movi(0x12, 11)]), + // ); + // + // run_group_ref( + // &mut c.benchmark_group("expi"), + // "expi", + // VmBench::new(op::exp(0x10, 0x11, 11)) + // .with_prepare_script(vec![op::movi(0x11, 23)]), + // ); + // + // run_group_ref( + // &mut c.benchmark_group("gt"), + // "gt", + // VmBench::new(op::gt(0x10, 0x11, 0x12)) + // .with_prepare_script(vec![op::movi(0x11, 100000), op::movi(0x12, 27)]), + // ); + // + // { + // let count = 254; + // let correct_index = count - 1; // Have the last index be the correct one. The builder includes an extra input, so it's the 255th index (254). + // run_group_ref( + // &mut c.benchmark_group("gtf"), + // "gtf", + // VmBench::new(op::gtf_args(0x10, 0x11, GTFArgs::InputContractOutputIndex)) + // .with_empty_contracts_count(count) + // .with_prepare_script(vec![op::movi(0x11, correct_index as u32)]), + // ); + // } + // + // run_group_ref( + // &mut c.benchmark_group("lt"), + // "lt", + // VmBench::new(op::lt(0x10, 0x11, 0x12)) + // .with_prepare_script(vec![op::movi(0x11, 100000), op::movi(0x12, 27)]), + // ); + // + // run_group_ref( + // &mut c.benchmark_group("mldv"), + // "mldv", + // VmBench::new(op::mldv(0x10, 0x11, 0x12, 0x13)).with_prepare_script(vec![ + // op::movi(0x11, 123456), + // op::not(0x12, RegId::ZERO), + // op::movi(0x13, 234567), + // ]), + // ); + // + // run_group_ref( + // &mut c.benchmark_group("mlog"), + // "mlog", + // VmBench::new(op::mlog(0x10, 0x11, 0x12)) + // .with_prepare_script(vec![op::movi(0x11, 100000), op::movi(0x12, 27)]), + // ); + // + // run_group_ref( + // &mut c.benchmark_group("mod"), + // "mod", + // VmBench::new(op::mod_(0x10, 0x11, 0x12)) + // .with_prepare_script(vec![op::movi(0x11, 100000), op::movi(0x12, 27)]), + // ); + // + // run_group_ref( + // &mut c.benchmark_group("modi"), + // "modi", + // VmBench::new(op::modi(0x10, 0x11, 27)) + // .with_prepare_script(vec![op::movi(0x11, 100000)]), + // ); + // + // run_group_ref( + // &mut c.benchmark_group("move"), + // "move", + // VmBench::new(op::move_(0x10, 0x11)) + // .with_prepare_script(vec![op::movi(0x11, 100000)]), + // ); + // + // run_group_ref( + // &mut c.benchmark_group("movi"), + // "movi", + // VmBench::new(op::movi(0x10, 27)), + // ); + // + // run_group_ref( + // &mut c.benchmark_group("mroo"), + // "mroo", + // VmBench::new(op::mroo(0x10, 0x11, 0x12)) + // .with_prepare_script(vec![op::movi(0x11, 100000), op::movi(0x12, 27)]), + // ); + // + // run_group_ref( + // &mut c.benchmark_group("mul"), + // "mul", + // VmBench::new(op::mul(0x10, 0x11, 0x12)) + // .with_prepare_script(vec![op::movi(0x11, 100000), op::movi(0x12, 27)]), + // ); + // + // run_group_ref( + // &mut c.benchmark_group("muli"), + // "muli", + // VmBench::new(op::muli(0x10, 0x11, 27)) + // .with_prepare_script(vec![op::movi(0x11, 100000)]), + // ); run_group_ref( &mut c.benchmark_group("noop"), @@ -207,252 +207,252 @@ pub fn run(c: &mut Criterion) { VmBench::new(op::noop()), ); - run_group_ref( - &mut c.benchmark_group("not"), - "not", - VmBench::new(op::not(0x10, 0x11)) - .with_prepare_script(vec![op::movi(0x11, 100000)]), - ); - - run_group_ref( - &mut c.benchmark_group("or"), - "or", - VmBench::new(op::or(0x10, 0x11, 0x12)) - .with_prepare_script(vec![op::movi(0x11, 100000), op::movi(0x12, 27)]), - ); - - run_group_ref( - &mut c.benchmark_group("ori"), - "ori", - VmBench::new(op::ori(0x10, 0x11, 27)) - .with_prepare_script(vec![op::movi(0x11, 100000)]), - ); - - run_group_ref( - &mut c.benchmark_group("sll"), - "sll", - VmBench::new(op::sll(0x10, 0x11, 0x12)) - .with_prepare_script(vec![op::movi(0x11, 100000), op::movi(0x12, 27)]), - ); - - run_group_ref( - &mut c.benchmark_group("slli"), - "slli", - VmBench::new(op::slli(0x10, 0x11, 27)) - .with_prepare_script(vec![op::movi(0x11, 100000)]), - ); - - run_group_ref( - &mut c.benchmark_group("srl"), - "srl", - VmBench::new(op::srl(0x10, 0x11, 0x12)) - .with_prepare_script(vec![op::movi(0x11, 100000), op::movi(0x12, 27)]), - ); - - run_group_ref( - &mut c.benchmark_group("srli"), - "srli", - VmBench::new(op::srli(0x10, 0x11, 27)) - .with_prepare_script(vec![op::movi(0x11, 100000)]), - ); - - run_group_ref( - &mut c.benchmark_group("sub"), - "sub", - VmBench::new(op::sub(0x10, 0x11, 0x12)) - .with_prepare_script(vec![op::movi(0x11, 100000), op::movi(0x12, 27)]), - ); - - run_group_ref( - &mut c.benchmark_group("subi"), - "subi", - VmBench::new(op::subi(0x10, 0x11, 27)) - .with_prepare_script(vec![op::movi(0x11, 100000)]), - ); - - run_group_ref( - &mut c.benchmark_group("xor"), - "xor", - VmBench::new(op::xor(0x10, 0x11, 0x12)) - .with_prepare_script(vec![op::movi(0x11, 100000), op::movi(0x12, 27)]), - ); - - run_group_ref( - &mut c.benchmark_group("xori"), - "xori", - VmBench::new(op::xori(0x10, 0x11, 27)) - .with_prepare_script(vec![op::movi(0x11, 100000)]), - ); - - // Wideint operations: 128 bit - let mut wideint_prepare = Vec::new(); - wideint_prepare.extend(make_u128(0x10, 0)); - wideint_prepare.extend(make_u128(0x11, u128::MAX)); - wideint_prepare.extend(make_u128(0x12, u128::MAX / 2 + 1)); - wideint_prepare.extend(make_u128(0x13, u128::MAX - 158)); // prime - wideint_prepare.extend(make_u128(0x14, u64::MAX.into())); - - run_group_ref( - &mut c.benchmark_group("wdcm"), - "wdcm", - VmBench::new(op::wdcm_args( - 0x10, - 0x12, - 0x13, - CompareArgs { - mode: CompareMode::LTE, - indirect_rhs: true, - }, - )) - .with_prepare_script(wideint_prepare.clone()), - ); - - run_group_ref( - &mut c.benchmark_group("wdop"), - "wdop", - VmBench::new(op::wdop_args( - 0x10, - 0x13, - 0x12, - MathArgs { - op: MathOp::SUB, - indirect_rhs: true, - }, - )) - .with_prepare_script(wideint_prepare.clone()), - ); - - run_group_ref( - &mut c.benchmark_group("wdml"), - "wdml", - VmBench::new(op::wdml_args( - 0x10, - 0x14, - 0x14, - MulArgs { - indirect_lhs: true, - indirect_rhs: true, - }, - )) - .with_prepare_script(wideint_prepare.clone()), - ); - - run_group_ref( - &mut c.benchmark_group("wddv"), - "wddv", - VmBench::new(op::wddv_args( - 0x10, - 0x12, - 0x13, - DivArgs { indirect_rhs: true }, - )) - .with_prepare_script(wideint_prepare.clone()), - ); - - run_group_ref( - &mut c.benchmark_group("wdmd"), - "wdmd", - VmBench::new(op::wdmd(0x10, 0x12, 0x13, 0x13)) - .with_prepare_script(wideint_prepare.clone()), - ); - - run_group_ref( - &mut c.benchmark_group("wdam"), - "wdam", - VmBench::new(op::wdam(0x10, 0x12, 0x13, 0x13)) - .with_prepare_script(wideint_prepare.clone()), - ); - - run_group_ref( - &mut c.benchmark_group("wdmm"), - "wdmm", - VmBench::new(op::wdmm(0x10, 0x12, 0x13, 0x13)) - .with_prepare_script(wideint_prepare.clone()), - ); - - // Wideint operations: 256 bit - let mut wideint_prepare = Vec::new(); - wideint_prepare.extend(make_u256(0x10, U256::ZERO)); - wideint_prepare.extend(make_u256(0x11, U256::MAX)); - wideint_prepare.extend(make_u256(0x12, U256::MAX / 2 + 1)); - wideint_prepare.extend(make_u256(0x13, U256::MAX - 188)); // prime - wideint_prepare.extend(make_u256(0x14, u128::MAX.into())); - - run_group_ref( - &mut c.benchmark_group("wqcm"), - "wqcm", - VmBench::new(op::wqcm_args( - 0x10, - 0x12, - 0x13, - CompareArgs { - mode: CompareMode::LTE, - indirect_rhs: true, - }, - )) - .with_prepare_script(wideint_prepare.clone()), - ); - - run_group_ref( - &mut c.benchmark_group("wqop"), - "wqop", - VmBench::new(op::wqop_args( - 0x10, - 0x13, - 0x12, - MathArgs { - op: MathOp::SUB, - indirect_rhs: true, - }, - )) - .with_prepare_script(wideint_prepare.clone()), - ); - - run_group_ref( - &mut c.benchmark_group("wqml"), - "wqml", - VmBench::new(op::wqml_args( - 0x10, - 0x14, - 0x14, - MulArgs { - indirect_lhs: true, - indirect_rhs: true, - }, - )) - .with_prepare_script(wideint_prepare.clone()), - ); - - run_group_ref( - &mut c.benchmark_group("wqdv"), - "wqdv", - VmBench::new(op::wqdv_args( - 0x10, - 0x12, - 0x13, - DivArgs { indirect_rhs: true }, - )) - .with_prepare_script(wideint_prepare.clone()), - ); - - run_group_ref( - &mut c.benchmark_group("wqmd"), - "wqmd", - VmBench::new(op::wqmd(0x10, 0x12, 0x13, 0x13)) - .with_prepare_script(wideint_prepare.clone()), - ); - - run_group_ref( - &mut c.benchmark_group("wqam"), - "wqam", - VmBench::new(op::wqam(0x10, 0x12, 0x13, 0x13)) - .with_prepare_script(wideint_prepare.clone()), - ); - - run_group_ref( - &mut c.benchmark_group("wqmm"), - "wqmm", - VmBench::new(op::wdmm(0x10, 0x12, 0x13, 0x13)) - .with_prepare_script(wideint_prepare.clone()), - ); + // run_group_ref( + // &mut c.benchmark_group("not"), + // "not", + // VmBench::new(op::not(0x10, 0x11)) + // .with_prepare_script(vec![op::movi(0x11, 100000)]), + // ); + // + // run_group_ref( + // &mut c.benchmark_group("or"), + // "or", + // VmBench::new(op::or(0x10, 0x11, 0x12)) + // .with_prepare_script(vec![op::movi(0x11, 100000), op::movi(0x12, 27)]), + // ); + // + // run_group_ref( + // &mut c.benchmark_group("ori"), + // "ori", + // VmBench::new(op::ori(0x10, 0x11, 27)) + // .with_prepare_script(vec![op::movi(0x11, 100000)]), + // ); + // + // run_group_ref( + // &mut c.benchmark_group("sll"), + // "sll", + // VmBench::new(op::sll(0x10, 0x11, 0x12)) + // .with_prepare_script(vec![op::movi(0x11, 100000), op::movi(0x12, 27)]), + // ); + // + // run_group_ref( + // &mut c.benchmark_group("slli"), + // "slli", + // VmBench::new(op::slli(0x10, 0x11, 27)) + // .with_prepare_script(vec![op::movi(0x11, 100000)]), + // ); + // + // run_group_ref( + // &mut c.benchmark_group("srl"), + // "srl", + // VmBench::new(op::srl(0x10, 0x11, 0x12)) + // .with_prepare_script(vec![op::movi(0x11, 100000), op::movi(0x12, 27)]), + // ); + // + // run_group_ref( + // &mut c.benchmark_group("srli"), + // "srli", + // VmBench::new(op::srli(0x10, 0x11, 27)) + // .with_prepare_script(vec![op::movi(0x11, 100000)]), + // ); + // + // run_group_ref( + // &mut c.benchmark_group("sub"), + // "sub", + // VmBench::new(op::sub(0x10, 0x11, 0x12)) + // .with_prepare_script(vec![op::movi(0x11, 100000), op::movi(0x12, 27)]), + // ); + // + // run_group_ref( + // &mut c.benchmark_group("subi"), + // "subi", + // VmBench::new(op::subi(0x10, 0x11, 27)) + // .with_prepare_script(vec![op::movi(0x11, 100000)]), + // ); + // + // run_group_ref( + // &mut c.benchmark_group("xor"), + // "xor", + // VmBench::new(op::xor(0x10, 0x11, 0x12)) + // .with_prepare_script(vec![op::movi(0x11, 100000), op::movi(0x12, 27)]), + // ); + // + // run_group_ref( + // &mut c.benchmark_group("xori"), + // "xori", + // VmBench::new(op::xori(0x10, 0x11, 27)) + // .with_prepare_script(vec![op::movi(0x11, 100000)]), + // ); + // + // // Wideint operations: 128 bit + // let mut wideint_prepare = Vec::new(); + // wideint_prepare.extend(make_u128(0x10, 0)); + // wideint_prepare.extend(make_u128(0x11, u128::MAX)); + // wideint_prepare.extend(make_u128(0x12, u128::MAX / 2 + 1)); + // wideint_prepare.extend(make_u128(0x13, u128::MAX - 158)); // prime + // wideint_prepare.extend(make_u128(0x14, u64::MAX.into())); + // + // run_group_ref( + // &mut c.benchmark_group("wdcm"), + // "wdcm", + // VmBench::new(op::wdcm_args( + // 0x10, + // 0x12, + // 0x13, + // CompareArgs { + // mode: CompareMode::LTE, + // indirect_rhs: true, + // }, + // )) + // .with_prepare_script(wideint_prepare.clone()), + // ); + // + // run_group_ref( + // &mut c.benchmark_group("wdop"), + // "wdop", + // VmBench::new(op::wdop_args( + // 0x10, + // 0x13, + // 0x12, + // MathArgs { + // op: MathOp::SUB, + // indirect_rhs: true, + // }, + // )) + // .with_prepare_script(wideint_prepare.clone()), + // ); + // + // run_group_ref( + // &mut c.benchmark_group("wdml"), + // "wdml", + // VmBench::new(op::wdml_args( + // 0x10, + // 0x14, + // 0x14, + // MulArgs { + // indirect_lhs: true, + // indirect_rhs: true, + // }, + // )) + // .with_prepare_script(wideint_prepare.clone()), + // ); + // + // run_group_ref( + // &mut c.benchmark_group("wddv"), + // "wddv", + // VmBench::new(op::wddv_args( + // 0x10, + // 0x12, + // 0x13, + // DivArgs { indirect_rhs: true }, + // )) + // .with_prepare_script(wideint_prepare.clone()), + // ); + // + // run_group_ref( + // &mut c.benchmark_group("wdmd"), + // "wdmd", + // VmBench::new(op::wdmd(0x10, 0x12, 0x13, 0x13)) + // .with_prepare_script(wideint_prepare.clone()), + // ); + // + // run_group_ref( + // &mut c.benchmark_group("wdam"), + // "wdam", + // VmBench::new(op::wdam(0x10, 0x12, 0x13, 0x13)) + // .with_prepare_script(wideint_prepare.clone()), + // ); + // + // run_group_ref( + // &mut c.benchmark_group("wdmm"), + // "wdmm", + // VmBench::new(op::wdmm(0x10, 0x12, 0x13, 0x13)) + // .with_prepare_script(wideint_prepare.clone()), + // ); + // + // // Wideint operations: 256 bit + // let mut wideint_prepare = Vec::new(); + // wideint_prepare.extend(make_u256(0x10, U256::ZERO)); + // wideint_prepare.extend(make_u256(0x11, U256::MAX)); + // wideint_prepare.extend(make_u256(0x12, U256::MAX / 2 + 1)); + // wideint_prepare.extend(make_u256(0x13, U256::MAX - 188)); // prime + // wideint_prepare.extend(make_u256(0x14, u128::MAX.into())); + // + // run_group_ref( + // &mut c.benchmark_group("wqcm"), + // "wqcm", + // VmBench::new(op::wqcm_args( + // 0x10, + // 0x12, + // 0x13, + // CompareArgs { + // mode: CompareMode::LTE, + // indirect_rhs: true, + // }, + // )) + // .with_prepare_script(wideint_prepare.clone()), + // ); + // + // run_group_ref( + // &mut c.benchmark_group("wqop"), + // "wqop", + // VmBench::new(op::wqop_args( + // 0x10, + // 0x13, + // 0x12, + // MathArgs { + // op: MathOp::SUB, + // indirect_rhs: true, + // }, + // )) + // .with_prepare_script(wideint_prepare.clone()), + // ); + // + // run_group_ref( + // &mut c.benchmark_group("wqml"), + // "wqml", + // VmBench::new(op::wqml_args( + // 0x10, + // 0x14, + // 0x14, + // MulArgs { + // indirect_lhs: true, + // indirect_rhs: true, + // }, + // )) + // .with_prepare_script(wideint_prepare.clone()), + // ); + // + // run_group_ref( + // &mut c.benchmark_group("wqdv"), + // "wqdv", + // VmBench::new(op::wqdv_args( + // 0x10, + // 0x12, + // 0x13, + // DivArgs { indirect_rhs: true }, + // )) + // .with_prepare_script(wideint_prepare.clone()), + // ); + // + // run_group_ref( + // &mut c.benchmark_group("wqmd"), + // "wqmd", + // VmBench::new(op::wqmd(0x10, 0x12, 0x13, 0x13)) + // .with_prepare_script(wideint_prepare.clone()), + // ); + // + // run_group_ref( + // &mut c.benchmark_group("wqam"), + // "wqam", + // VmBench::new(op::wqam(0x10, 0x12, 0x13, 0x13)) + // .with_prepare_script(wideint_prepare.clone()), + // ); + // + // run_group_ref( + // &mut c.benchmark_group("wqmm"), + // "wqmm", + // VmBench::new(op::wdmm(0x10, 0x12, 0x13, 0x13)) + // .with_prepare_script(wideint_prepare.clone()), + // ); } diff --git a/benches/benches/vm_set/mem.rs b/benches/benches/vm_set/mem.rs index 328bf826680..07c7231254c 100644 --- a/benches/benches/vm_set/mem.rs +++ b/benches/benches/vm_set/mem.rs @@ -20,152 +20,152 @@ use fuel_core_types::{ }; pub fn run(c: &mut Criterion) { - run_group_ref( - &mut c.benchmark_group("lb"), - "lb", - VmBench::new(op::lb(0x10, RegId::ONE, 10)), - ); - - run_group_ref( - &mut c.benchmark_group("lw"), - "lw", - VmBench::new(op::lw(0x10, RegId::ONE, 10)), - ); - - run_group_ref( - &mut c.benchmark_group("sb"), - "sb", - VmBench::new(op::sb(0x10, 0x11, 0)).with_prepare_script(vec![ - op::aloc(RegId::ONE), - op::move_(0x10, RegId::HP), - op::movi(0x11, 50), - ]), - ); - - run_group_ref( - &mut c.benchmark_group("sw"), - "sw", - VmBench::new(op::sw(0x10, 0x11, 0)).with_prepare_script(vec![ - op::movi(0x10, 8), - op::aloc(0x10), - op::move_(0x10, RegId::HP), - op::movi(0x11, 50), - ]), - ); + // run_group_ref( + // &mut c.benchmark_group("lb"), + // "lb", + // VmBench::new(op::lb(0x10, RegId::ONE, 10)), + // ); + // + // run_group_ref( + // &mut c.benchmark_group("lw"), + // "lw", + // VmBench::new(op::lw(0x10, RegId::ONE, 10)), + // ); + // + // run_group_ref( + // &mut c.benchmark_group("sb"), + // "sb", + // VmBench::new(op::sb(0x10, 0x11, 0)).with_prepare_script(vec![ + // op::aloc(RegId::ONE), + // op::move_(0x10, RegId::HP), + // op::movi(0x11, 50), + // ]), + // ); + // + // run_group_ref( + // &mut c.benchmark_group("sw"), + // "sw", + // VmBench::new(op::sw(0x10, 0x11, 0)).with_prepare_script(vec![ + // op::movi(0x10, 8), + // op::aloc(0x10), + // op::move_(0x10, RegId::HP), + // op::movi(0x11, 50), + // ]), + // ); let linear = arb_dependent_cost_values(); - let linear_short = linear_short(); + // let linear_short = linear_short(); // cfe - { - let mut cfe = c.benchmark_group("cfe"); - - let mut cfe_linear = linear_short.clone(); - cfe_linear.push(1_000_000); - cfe_linear.push(10_000_000); - cfe_linear.push(30_000_000); - cfe_linear.push(60_000_000); - for i in cfe_linear { - let prepare_script = set_full_word(0x10, i); - let memory = MemoryInstance::from(vec![123; MEM_SIZE]); - let bench = VmBench::new(op::cfe(0x10)) - .with_prepare_script(prepare_script) - .with_memory(memory); - cfe.throughput(Throughput::Bytes(i)); - run_group_ref(&mut cfe, format!("{i}"), bench); - } - - cfe.finish(); - } - - // cfei - { - let mut cfei = c.benchmark_group("cfei"); - - let mut cfei_linear = linear_short.clone(); - cfei_linear.push(1_000_000); - cfei_linear.push(10_000_000); - for i in cfei_linear { - let memory = MemoryInstance::from(vec![123; MEM_SIZE]); - let bench = VmBench::new(op::cfei(i as u32)).with_memory(memory); - cfei.throughput(Throughput::Bytes(i)); - run_group_ref(&mut cfei, format!("{i}"), bench); - } - - cfei.finish(); - } - - let mut mem_mcl = c.benchmark_group("mcl"); - for i in &linear { - mem_mcl.throughput(Throughput::Bytes(*i as u64)); - run_group_ref( - &mut mem_mcl, - format!("{i}"), - VmBench::new(op::mcl(0x10, 0x11)).with_prepare_script(vec![ - op::movi(0x11, *i), - op::aloc(0x11), - op::move_(0x10, RegId::HP), - ]), - ); - } - mem_mcl.finish(); - - let mut mem_mcli = c.benchmark_group("mcli"); - for i in &linear { - mem_mcli.throughput(Throughput::Bytes(*i as u64)); - run_group_ref( - &mut mem_mcli, - format!("{i}"), - VmBench::new(op::mcli(0x10, *i)).with_prepare_script(vec![ - op::movi(0x11, *i), - op::aloc(0x11), - op::move_(0x10, RegId::HP), - ]), - ); - } - mem_mcli.finish(); - - let mut mem_mcp = c.benchmark_group("mcp"); - for i in &linear { - mem_mcp.throughput(Throughput::Bytes(*i as u64)); - run_group_ref( - &mut mem_mcp, - format!("{i}"), - VmBench::new(op::mcp(0x10, RegId::ZERO, 0x11)).with_prepare_script(vec![ - op::movi(0x11, *i), - op::aloc(0x11), - op::cfe(0x11), - op::move_(0x10, RegId::HP), - ]), - ); - } - mem_mcp.finish(); - - let mut mem_mcpi = c.benchmark_group("mcpi"); - - let mut imm12_linear: Vec<_> = linear - .iter() - .copied() - .take_while(|p| *p < (1 << 12)) - .collect(); - imm12_linear.push((1 << 12) - 1); - for i in &imm12_linear { - let i_as_u16: u16 = (*i).try_into().unwrap(); - mem_mcpi.throughput(Throughput::Bytes(*i as u64)); - run_group_ref( - &mut mem_mcpi, - format!("{i}"), - VmBench::new(op::mcpi(0x10, RegId::ZERO, i_as_u16)).with_prepare_script( - vec![ - op::movi(0x11, *i), - op::aloc(0x11), - op::cfe(0x11), - op::move_(0x10, RegId::HP), - ], - ), - ); - } - mem_mcpi.finish(); + // { + // let mut cfe = c.benchmark_group("cfe"); + // + // let mut cfe_linear = linear_short.clone(); + // cfe_linear.push(1_000_000); + // cfe_linear.push(10_000_000); + // cfe_linear.push(30_000_000); + // cfe_linear.push(60_000_000); + // for i in cfe_linear { + // let prepare_script = set_full_word(0x10, i); + // let memory = MemoryInstance::from(vec![123; MEM_SIZE]); + // let bench = VmBench::new(op::cfe(0x10)) + // .with_prepare_script(prepare_script) + // .with_memory(memory); + // cfe.throughput(Throughput::Bytes(i)); + // run_group_ref(&mut cfe, format!("{i}"), bench); + // } + // + // cfe.finish(); + // } + // + // // cfei + // { + // let mut cfei = c.benchmark_group("cfei"); + // + // let mut cfei_linear = linear_short.clone(); + // cfei_linear.push(1_000_000); + // cfei_linear.push(10_000_000); + // for i in cfei_linear { + // let memory = MemoryInstance::from(vec![123; MEM_SIZE]); + // let bench = VmBench::new(op::cfei(i as u32)).with_memory(memory); + // cfei.throughput(Throughput::Bytes(i)); + // run_group_ref(&mut cfei, format!("{i}"), bench); + // } + // + // cfei.finish(); + // } + // + // let mut mem_mcl = c.benchmark_group("mcl"); + // for i in &linear { + // mem_mcl.throughput(Throughput::Bytes(*i as u64)); + // run_group_ref( + // &mut mem_mcl, + // format!("{i}"), + // VmBench::new(op::mcl(0x10, 0x11)).with_prepare_script(vec![ + // op::movi(0x11, *i), + // op::aloc(0x11), + // op::move_(0x10, RegId::HP), + // ]), + // ); + // } + // mem_mcl.finish(); + // + // let mut mem_mcli = c.benchmark_group("mcli"); + // for i in &linear { + // mem_mcli.throughput(Throughput::Bytes(*i as u64)); + // run_group_ref( + // &mut mem_mcli, + // format!("{i}"), + // VmBench::new(op::mcli(0x10, *i)).with_prepare_script(vec![ + // op::movi(0x11, *i), + // op::aloc(0x11), + // op::move_(0x10, RegId::HP), + // ]), + // ); + // } + // mem_mcli.finish(); + // + // let mut mem_mcp = c.benchmark_group("mcp"); + // for i in &linear { + // mem_mcp.throughput(Throughput::Bytes(*i as u64)); + // run_group_ref( + // &mut mem_mcp, + // format!("{i}"), + // VmBench::new(op::mcp(0x10, RegId::ZERO, 0x11)).with_prepare_script(vec![ + // op::movi(0x11, *i), + // op::aloc(0x11), + // op::cfe(0x11), + // op::move_(0x10, RegId::HP), + // ]), + // ); + // } + // mem_mcp.finish(); + // + // let mut mem_mcpi = c.benchmark_group("mcpi"); + // + // let mut imm12_linear: Vec<_> = linear + // .iter() + // .copied() + // .take_while(|p| *p < (1 << 12)) + // .collect(); + // imm12_linear.push((1 << 12) - 1); + // for i in &imm12_linear { + // let i_as_u16: u16 = (*i).try_into().unwrap(); + // mem_mcpi.throughput(Throughput::Bytes(*i as u64)); + // run_group_ref( + // &mut mem_mcpi, + // format!("{i}"), + // VmBench::new(op::mcpi(0x10, RegId::ZERO, i_as_u16)).with_prepare_script( + // vec![ + // op::movi(0x11, *i), + // op::aloc(0x11), + // op::cfe(0x11), + // op::move_(0x10, RegId::HP), + // ], + // ), + // ); + // } + // mem_mcpi.finish(); let mut mem_meq = c.benchmark_group("meq"); for i in &linear { @@ -186,37 +186,37 @@ pub fn run(c: &mut Criterion) { } mem_meq.finish(); - let full_mask = (1 << 24) - 1; - - // poph - let prepare_script = vec![op::pshh(full_mask)]; - run_group_ref( - &mut c.benchmark_group("poph"), - "poph", - VmBench::new(op::poph(full_mask)).with_prepare_script(prepare_script), - ); - - // popl - let prepare_script = vec![op::pshl(full_mask)]; - run_group_ref( - &mut c.benchmark_group("popl"), - "popl", - VmBench::new(op::popl(full_mask)).with_prepare_script(prepare_script), - ); - - // pshh - run_group_ref( - &mut c.benchmark_group("pshh"), - "pshh", - VmBench::new(op::pshh(full_mask)) - .with_prepare_script(vec![op::pshh(full_mask); 10000]), - ); - - // pshl - run_group_ref( - &mut c.benchmark_group("pshl"), - "pshl", - VmBench::new(op::pshl(full_mask)) - .with_prepare_script(vec![op::pshl(full_mask); 10000]), - ); + // let full_mask = (1 << 24) - 1; + // + // // poph + // let prepare_script = vec![op::pshh(full_mask)]; + // run_group_ref( + // &mut c.benchmark_group("poph"), + // "poph", + // VmBench::new(op::poph(full_mask)).with_prepare_script(prepare_script), + // ); + // + // // popl + // let prepare_script = vec![op::pshl(full_mask)]; + // run_group_ref( + // &mut c.benchmark_group("popl"), + // "popl", + // VmBench::new(op::popl(full_mask)).with_prepare_script(prepare_script), + // ); + // + // // pshh + // run_group_ref( + // &mut c.benchmark_group("pshh"), + // "pshh", + // VmBench::new(op::pshh(full_mask)) + // .with_prepare_script(vec![op::pshh(full_mask); 10000]), + // ); + // + // // pshl + // run_group_ref( + // &mut c.benchmark_group("pshl"), + // "pshl", + // VmBench::new(op::pshl(full_mask)) + // .with_prepare_script(vec![op::pshl(full_mask); 10000]), + // ); }