Skip to content

Commit

Permalink
feat: execute mode on perf (#62)
Browse files Browse the repository at this point in the history
* add execute mode

* Update crates/perf/src/main.rs

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
tamirhemo and github-actions[bot] authored Nov 8, 2024
1 parent c9662c4 commit 2614e21
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
18 changes: 13 additions & 5 deletions crates/perf/run_s3.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
#!/bin/bash

# Check if both arguments are provided
if [ $# -ne 2 ]; then
echo "Usage: $0 <s3_path> <cpu|cuda>"
# Set the default value for the stage argument
stage="prove"

# Check the number of arguments
if [ $# -lt 2 ] || [ $# -gt 3 ]; then
echo "Usage: $0 <s3_path> <cpu|cuda> [execute|prove]"
exit 1
fi

# If the third argument is provided, override the default value
if [ $# -eq 3 ]; then
stage="$3"
fi

s3_path=$1
stage=$2
kind=$2

# Download files from S3
aws s3 cp s3://sp1-testing-suite/$s3_path/program.bin /tmp/program.bin
Expand All @@ -20,4 +28,4 @@ export RUST_LOG=debug
export SP1_DEBUG=1

# Run moongate-perf
cargo run -p sp1-perf -- --program /tmp/program.bin --stdin /tmp/stdin.bin --mode $stage
cargo run -p sp1-perf -- --program /tmp/program.bin --stdin /tmp/stdin.bin --mode $kind --stage $stage
13 changes: 13 additions & 0 deletions crates/perf/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ struct PerfArgs {
pub stdin: String,
#[arg(short, long)]
pub mode: ProverMode,
#[arg(short, long, default_value = "prove")]
pub stage: Stage,
}

#[derive(Default, Debug, Clone)]
Expand All @@ -41,6 +43,12 @@ enum ProverMode {
Network,
}

#[derive(Debug, Clone, ValueEnum, PartialEq, Eq)]
enum Stage {
Execute,
Prove,
}

pub fn time_operation<T, F: FnOnce() -> T>(operation: F) -> (T, std::time::Duration) {
let start = Instant::now();
let result = operation();
Expand All @@ -59,6 +67,11 @@ fn main() {
let prover = SP1Prover::<DefaultProverComponents>::new();
let (pk, vk) = prover.setup(&elf);
let cycles = sp1_prover::utils::get_cycles(&elf, &stdin);
let stage = args.stage;
if stage == Stage::Execute {
println!("Program executed successfully, number of cycles: {}", cycles);
return;
}
let opts = SP1ProverOpts::default();

match args.mode {
Expand Down

0 comments on commit 2614e21

Please sign in to comment.