From 46084e1413f26df392632126971b2351ed0b5953 Mon Sep 17 00:00:00 2001 From: Balazs Komuves Date: Tue, 17 Oct 2023 11:22:11 +0200 Subject: [PATCH] clean up benchmarking scripts --- .gitignore | 2 +- hash/cpu/bench/Blake3/Unix/build.sh | 9 ++++--- hash/cpu/bench/Blake3/Unix/run.sh | 14 +++++++++- hash/cpu/bench/Poseidon2/Zikkurat/build.sh | 4 ++- hash/cpu/bench/Poseidon2/Zikkurat/run.sh | 13 +++++++++- hash/cpu/bench/Poseidon2/Zikkurat/setup.sh | 2 -- hash/cpu/bench/SHA256/C/build.sh | 6 +++-- hash/cpu/bench/SHA256/C/run.sh | 30 ++++++++++++++++++++++ hash/cpu/bench/SHA256/C/setup.sh | 2 -- hash/cpu/bench/SHA256/C/sha2.c | 0 hash/cpu/bench/SHA256/C/sha2.h | 0 hash/cpu/bench/SHA256/Unix/build.sh | 4 ++- hash/cpu/bench/SHA256/Unix/run.sh | 8 +++++- hash/cpu/bench/SHA256/Unix/setup.sh | 2 -- 14 files changed, 79 insertions(+), 17 deletions(-) mode change 100644 => 100755 hash/cpu/bench/Blake3/Unix/run.sh delete mode 100755 hash/cpu/bench/Poseidon2/Zikkurat/setup.sh create mode 100755 hash/cpu/bench/SHA256/C/run.sh delete mode 100755 hash/cpu/bench/SHA256/C/setup.sh mode change 100755 => 100644 hash/cpu/bench/SHA256/C/sha2.c mode change 100755 => 100644 hash/cpu/bench/SHA256/C/sha2.h delete mode 100755 hash/cpu/bench/SHA256/Unix/setup.sh diff --git a/.gitignore b/.gitignore index 1af3c9c..9479611 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ .DS_store -a.out build target +a.out diff --git a/hash/cpu/bench/Blake3/Unix/build.sh b/hash/cpu/bench/Blake3/Unix/build.sh index 98984ae..de9a3c4 100755 --- a/hash/cpu/bench/Blake3/Unix/build.sh +++ b/hash/cpu/bench/Blake3/Unix/build.sh @@ -1,7 +1,7 @@ #!/bin/bash ORIG=`pwd` -cd ../../src/Blake3/ +cd ../../../src/Blake3/ IMPL=`pwd` cd $IMPL @@ -11,7 +11,10 @@ cd $IMPL/b3sum cargo build --release cd $ORIG -cp $IMPL/b3sum/target/release/b3sum . -gcc -O3 fakedata.c -o fakedata +mkdir -p build + +cp $IMPL/b3sum/target/release/b3sum build/ + +gcc -O3 fakedata.c -o build/fakedata diff --git a/hash/cpu/bench/Blake3/Unix/run.sh b/hash/cpu/bench/Blake3/Unix/run.sh old mode 100644 new mode 100755 index eec4f89..ba8ed0e --- a/hash/cpu/bench/Blake3/Unix/run.sh +++ b/hash/cpu/bench/Blake3/Unix/run.sh @@ -1,2 +1,14 @@ #!/bin/bash -./fakedata $ZKBENCH_MEGABYTES | ./b3sum --num-threads $ZKBENCH_NTHREADS - \ No newline at end of file + +if [ -z ${ZKBENCH_NTHREADS} ]; then +ZKBENCH_NTHREADS=1 +fi + +if [ -z ${ZKBENCH_MEGABYTES} ]; then +ZKBENCH_MEGABYTES=256 +fi + +echo "NTHREADS = $ZKBENCH_NTHREADS" +echo "MEGABYTES = $ZKBENCH_MEGABYTES" + +./build/fakedata $ZKBENCH_MEGABYTES | ./build/b3sum --num-threads $ZKBENCH_NTHREADS - diff --git a/hash/cpu/bench/Poseidon2/Zikkurat/build.sh b/hash/cpu/bench/Poseidon2/Zikkurat/build.sh index d022657..2113157 100755 --- a/hash/cpu/bench/Poseidon2/Zikkurat/build.sh +++ b/hash/cpu/bench/Poseidon2/Zikkurat/build.sh @@ -3,6 +3,8 @@ echo "build" ZIK_PATH="../../../src/zikkurat-algebra/" +mkdir -p build + gcc -O3 \ -I ${ZIK_PATH}/lib/cbits/bigint/ \ -I ${ZIK_PATH}/lib/cbits/curves/fields/std/ \ @@ -11,4 +13,4 @@ gcc -O3 \ ${ZIK_PATH}/lib/cbits/curves/fields/std/bn128_r_std.c \ ${ZIK_PATH}/lib/cbits/curves/fields/mont/bn128_r_mont.c \ poseidon2.c \ - -o a.out + -o build/a.out diff --git a/hash/cpu/bench/Poseidon2/Zikkurat/run.sh b/hash/cpu/bench/Poseidon2/Zikkurat/run.sh index 4540b8e..a17a67b 100755 --- a/hash/cpu/bench/Poseidon2/Zikkurat/run.sh +++ b/hash/cpu/bench/Poseidon2/Zikkurat/run.sh @@ -1,3 +1,14 @@ #!/bin/bash -./a.out $ZKBENCH_TREE_DEPTH $ZKBENCH_NTHREADS \ No newline at end of file +if [ -z ${ZKBENCH_NTHREADS} ]; then +ZKBENCH_NTHREADS=1 +fi + +if [ -z ${ZKBENCH_TREE_DEPTH} ]; then +ZKBENCH_TREE_DEPTH=16 +fi + +echo "NTHREADS = $ZKBENCH_NTHREADS" +echo "TREE_DEPTH = $ZKBENCH_TREE_DEPTH" + +./build/a.out $ZKBENCH_TREE_DEPTH $ZKBENCH_NTHREADS \ No newline at end of file diff --git a/hash/cpu/bench/Poseidon2/Zikkurat/setup.sh b/hash/cpu/bench/Poseidon2/Zikkurat/setup.sh deleted file mode 100755 index 934e19e..0000000 --- a/hash/cpu/bench/Poseidon2/Zikkurat/setup.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -echo "setup" \ No newline at end of file diff --git a/hash/cpu/bench/SHA256/C/build.sh b/hash/cpu/bench/SHA256/C/build.sh index bb1c9b5..9b99e35 100755 --- a/hash/cpu/bench/SHA256/C/build.sh +++ b/hash/cpu/bench/SHA256/C/build.sh @@ -1,4 +1,6 @@ #!/bin/bash -gcc -O3 sha2.c bench_linear.c -o bench_linear -gcc -O3 sha2.c bench_merkle.c -o bench_merkle +mkdir -p build + +gcc -O3 sha2.c bench_linear.c -o build/bench_linear +gcc -O3 sha2.c bench_merkle.c -o build/bench_merkle diff --git a/hash/cpu/bench/SHA256/C/run.sh b/hash/cpu/bench/SHA256/C/run.sh new file mode 100755 index 0000000..274b2e6 --- /dev/null +++ b/hash/cpu/bench/SHA256/C/run.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +if [ -z ${ZKBENCH_WHICH} ]; then +ZKBENCH_WHICH="LINEAR" +fi + +if [ -z ${ZKBENCH_NTHREADS} ]; then +ZKBENCH_NTHREADS=1 +fi + +if [ -z ${ZKBENCH_MEGABYTES} ]; then +ZKBENCH_MEGABYTES=128 +fi + +echo "WHICH = $ZKBENCH_WHICH" +echo "NTHREADS = $ZKBENCH_NTHREADS" +echo "MEGABYTES = $ZKBENCH_MEGABYTES" + +case $ZKBENCH_WHICH in + LINEAR) + build/bench_linear $ZKBENCH_MEGABYTES + ;; + MERKLE) + build/bench_merkle $ZKBENCH_MEGABYTES $ZKBENCH_NTHREADS + ;; + *) + echo "unknown selector: \`$ZKBENCH_WHICH\`" + exit 99 + ;; +esac diff --git a/hash/cpu/bench/SHA256/C/setup.sh b/hash/cpu/bench/SHA256/C/setup.sh deleted file mode 100755 index 934e19e..0000000 --- a/hash/cpu/bench/SHA256/C/setup.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -echo "setup" \ No newline at end of file diff --git a/hash/cpu/bench/SHA256/C/sha2.c b/hash/cpu/bench/SHA256/C/sha2.c old mode 100755 new mode 100644 diff --git a/hash/cpu/bench/SHA256/C/sha2.h b/hash/cpu/bench/SHA256/C/sha2.h old mode 100755 new mode 100644 diff --git a/hash/cpu/bench/SHA256/Unix/build.sh b/hash/cpu/bench/SHA256/Unix/build.sh index e28c492..40147ac 100755 --- a/hash/cpu/bench/SHA256/Unix/build.sh +++ b/hash/cpu/bench/SHA256/Unix/build.sh @@ -1,3 +1,5 @@ #!/bin/bash -gcc -O3 fakedata.c -o fakedata +mkdir -p build + +gcc -O3 fakedata.c -o build/fakedata diff --git a/hash/cpu/bench/SHA256/Unix/run.sh b/hash/cpu/bench/SHA256/Unix/run.sh index 6187869..e3562c7 100755 --- a/hash/cpu/bench/SHA256/Unix/run.sh +++ b/hash/cpu/bench/SHA256/Unix/run.sh @@ -1,3 +1,9 @@ #!/bin/bash -./fakedata $ZKBENCH_MEGABYTES | shasum -a256 -b - \ No newline at end of file +if [ -z ${ZKBENCH_MEGABYTES} ]; then +ZKBENCH_MEGABYTES=128 +fi + +echo "MEGABYTES = $ZKBENCH_MEGABYTES" + +./build/fakedata $ZKBENCH_MEGABYTES | shasum -a256 -b - \ No newline at end of file diff --git a/hash/cpu/bench/SHA256/Unix/setup.sh b/hash/cpu/bench/SHA256/Unix/setup.sh deleted file mode 100755 index 934e19e..0000000 --- a/hash/cpu/bench/SHA256/Unix/setup.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -echo "setup" \ No newline at end of file