forked from succinctlabs/zkvm-perf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
eval.sh
executable file
·125 lines (107 loc) · 3.62 KB
/
eval.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/bin/bash
set -e
echo "Running $1, $2, $3, $4, $5"
# If $2 == nexus, append precompiles to Cargo.toml
if [ "$2" = "nexus" ]; then
cp Cargo.toml Cargo.toml.bak
cat precompiles_nexus.txt >> Cargo.toml
fi
# If $2 == jolt, append precompiles to Cargo.toml
if [ "$2" = "jolt" ]; then
cp Cargo.toml Cargo.toml.bak
cat precompiles_jolt.txt >> Cargo.toml
fi
# Get program directory name as $1 and append "-$2" to it if $1 == "tendermint"
if [ "$1" = "tendermint" ] || [ "$1" = "reth" ]; then
program_directory="${1}-$2"
else
program_directory="$1"
fi
echo "Building program"
# cd to program directory computed above
cd "programs/$program_directory"
# If the prover is sp1, then build the program.
if [ "$2" == "sp1" ]; then
# The reason we don't just use `cargo prove build` from the SP1 CLI is we need to pass a --features ...
# flag to select between sp1 and risc0.
RUSTFLAGS="-C passes=loweratomic -C link-arg=-Ttext=0x00200800 -C panic=abort" \
RUSTUP_TOOLCHAIN=succinct \
CARGO_BUILD_TARGET=riscv32im-succinct-zkvm-elf \
cargo build --release --ignore-rust-version --features $2
fi
# If the prover is risc0, then build the program.
if [ "$2" == "risc0" ]; then
echo "Building Risc0"
# Use the risc0 toolchain.
RUSTFLAGS="-C passes=loweratomic -C link-arg=-Ttext=0x00200800 -C panic=abort" \
RUSTUP_TOOLCHAIN=risc0 \
CARGO_BUILD_TARGET=riscv32im-risc0-zkvm-elf \
cargo build --release --ignore-rust-version --features $2
fi
if [ "$2" == "lita" ]; then
echo "Building Lita"
# Use the lita toolchain.
CC_valida_unknown_baremetal_gnu="/valida-toolchain/bin/clang" \
CFLAGS_valida_unknown_baremetal_gnu="--sysroot=/valida-toolchain -isystem /valida-toolchain/include" \
RUSTUP_TOOLCHAIN=valida \
CARGO_BUILD_TARGET=valida-unknown-baremetal-gnu \
cargo build --release --ignore-rust-version --features $2
# Lita does not have any hardware acceleration. Also it does not have an SDK
# or a crate to be used on rust. We need to benchmark it without rust
cd ../../
./eval_lita.sh $1 $2 $3 $program_directory $6
exit
fi
if [ "$2" == "nexus" ]; then
echo "Building Nexus"
# Hardcode the memlimit to 8 MB
RUSTFLAGS="-C link-arg=--defsym=MEMORY_LIMIT=0x80000 -C link-arg=-T../../nova.x" \
CARGO_BUILD_TARGET=riscv32i-unknown-none-elf \
RUSTUP_TOOLCHAIN=1.77.0 \
cargo build --release --ignore-rust-version --features $2
fi
cd ../../
echo "Running eval script"
# Detect whether we're on an instance with a GPU.
if nvidia-smi > /dev/null 2>&1; then
GPU_EXISTS=true
else
GPU_EXISTS=false
fi
# Check for AVX-512 support
if lscpu | grep -q avx512; then
# If AVX-512 is supported, add the specific features to RUSTFLAGS
export RUSTFLAGS="-C target-cpu=native -C target-feature=+avx512ifma,+avx512vl"
else
# If AVX-512 is not supported, just set target-cpu=native
export RUSTFLAGS="-C target-cpu=native"
fi
# Set the logging level.
export RUST_LOG=info
# Determine the features based on GPU existence.
if [ "$GPU_EXISTS" = true ]; then
FEATURES="$2, cuda"
else
FEATURES="$2"
fi
if [ "$2" = "jolt" ]; then
export RUSTFLAGS=""
export RUSTUP_TOOLCHAIN="nightly-2024-09-30"
fi
# Run the benchmark.
cargo run \
-p sp1-benchmarks-eval \
--release \
--no-default-features \
--features "$FEATURES" \
-- \
--program "$1" \
--prover "$2" \
--hashfn "$3" \
--shard-size "$4" \
--filename "$5" \
${6:+$([[ "$1" == "fibonacci" ]] && echo "--fibonacci-input" || echo "--block-number") $6}
# Revert Cargo.toml as the last step
if [ "$2" = "nexus" ] || [ "$2" = "jolt" ]; then
mv Cargo.toml.bak Cargo.toml
fi