Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into mm/pg-refactor-new
Browse files Browse the repository at this point in the history
  • Loading branch information
codygunton committed Feb 23, 2024
2 parents 6a339fe + faa9586 commit 26118e6
Show file tree
Hide file tree
Showing 124 changed files with 1,256 additions and 3,284 deletions.
4 changes: 2 additions & 2 deletions barretenberg/.gitrepo
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[subrepo]
remote = https://github.com/AztecProtocol/barretenberg
branch = master
commit = b4344455d2a3dddd51ba14f62294c8d5f5689008
parent = 319eea9e4caf1d1ade00fedface5fab9bbf9db16
commit = 3eac14010f3f355109e8c85d7dbffdf1bc7a1eca
parent = a2c0caed4c48ce2d37d2370040ea059d80d93bfe
method = merge
cmdver = 0.4.6
16 changes: 0 additions & 16 deletions barretenberg/cpp/CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -274,16 +274,6 @@
"MULTITHREADING": "ON"
}
},
{
"name": "wasm-bench",
"displayName": "WASM benchmarking.",
"description": "WASM benchmarking.",
"inherits": "wasm-threads",
"binaryDir": "build-wasm-bench",
"environment": {
"CXXFLAGS": "-DWASMTIME_ENV_HACK"
}
},
{
"name": "xray",
"displayName": "Build with multi-threaded XRay Profiling",
Expand Down Expand Up @@ -444,12 +434,6 @@
"jobs": 0,
"targets": ["barretenberg.wasm"]
},
{
"name": "wasm-bench",
"configurePreset": "wasm-bench",
"inheritConfigureEnvironment": true,
"jobs": 0
},
{
"name": "xray",
"configurePreset": "xray",
Expand Down
1 change: 1 addition & 0 deletions barretenberg/cpp/scripts/_benchmark_remote_lock.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ echo "Benchmarking lock created at ~/BENCHMARK_IN_PROGRESS."

# Trap to ensure cleanup runs on ANY exit, including from a signal
trap cleanup EXIT
trap cleanup INT # handle ctrl-c

# don't exit, the caller script will run
3 changes: 2 additions & 1 deletion barretenberg/cpp/scripts/benchmark_remote.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ BENCHMARK=${1:-goblin_bench}
COMMAND=${2:-./$BENCHMARK}
PRESET=${3:-clang16}
BUILD_DIR=${4:-build}
HARDWARE_CONCURRENCY=${HARDWARE_CONCURRENCY:-16}

# Move above script dir.
cd $(dirname $0)/..
Expand All @@ -24,4 +25,4 @@ source scripts/_benchmark_remote_lock.sh
cd $BUILD_DIR
scp $BB_SSH_KEY ./bin/$BENCHMARK $BB_SSH_INSTANCE:$BB_SSH_CPP_PATH/build
ssh $BB_SSH_KEY $BB_SSH_INSTANCE \
"cd $BB_SSH_CPP_PATH/build ; $COMMAND"
"cd $BB_SSH_CPP_PATH/build ; HARDWARE_CONCURRENCY=$HARDWARE_CONCURRENCY $COMMAND"
9 changes: 5 additions & 4 deletions barretenberg/cpp/scripts/benchmark_wasm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ set -eu

BENCHMARK=${1:-goblin_bench}
COMMAND=${2:-./bin/$BENCHMARK}
HARDWARE_CONCURRENCY=${HARDWARE_CONCURRENCY:-16}

# Move above script dir.
cd $(dirname $0)/..

# Configure and build.
cmake --preset wasm-bench
cmake --build --preset wasm-bench --target $BENCHMARK
cmake --preset wasm-threads
cmake --build --preset wasm-threads --target $BENCHMARK

cd build-wasm-bench
cd build-wasm-threads
# Consistency with _wasm.sh targets / shorter $COMMAND.
cp ./bin/$BENCHMARK .
wasmtime run -Wthreads=y -Sthreads=y $COMMAND
wasmtime run --env HARDWARE_CONCURRENCY=$HARDWARE_CONCURRENCY -Wthreads=y -Sthreads=y --dir=.. $COMMAND
15 changes: 10 additions & 5 deletions barretenberg/cpp/scripts/benchmark_wasm_remote.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,22 @@ set -eu

BENCHMARK=${1:-goblin_bench}
COMMAND=${2:-./$BENCHMARK}
HARDWARE_CONCURRENCY=${HARDWARE_CONCURRENCY:-16}

# Move above script dir.
cd $(dirname $0)/..

# Configure and build.
cmake --preset wasm-bench
cmake --build --preset wasm-bench --target $BENCHMARK
cmake --preset wasm-threads
cmake --build --preset wasm-threads --target $BENCHMARK

source scripts/_benchmark_remote_lock.sh

cd build-wasm-bench
scp $BB_SSH_KEY ./bin/$BENCHMARK $BB_SSH_INSTANCE:$BB_SSH_CPP_PATH/build-wasm-bench
cd build-wasm-threads
# ensure folder structure
ssh $BB_SSH_KEY $BB_SSH_INSTANCE "mkdir -p $BB_SSH_CPP_PATH/build-wasm-threads"
# copy build wasm threads
scp $BB_SSH_KEY ./bin/$BENCHMARK $BB_SSH_INSTANCE:$BB_SSH_CPP_PATH/build-wasm-threads
# run wasm benchmarking
ssh $BB_SSH_KEY $BB_SSH_INSTANCE \
"cd $BB_SSH_CPP_PATH/build-wasm-bench ; /home/ubuntu/.wasmtime/bin/wasmtime run -Wthreads=y -Sthreads=y $COMMAND"
"cd $BB_SSH_CPP_PATH/build-wasm-threads ; /home/ubuntu/.wasmtime/bin/wasmtime run --env HARDWARE_CONCURRENCY=$HARDWARE_CONCURRENCY -Wthreads=y -Sthreads=y --dir=.. $COMMAND"
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,9 @@ template <typename Curve> class IPA {
// Compute G_zero
// First construct s_vec
std::vector<Fr> s_vec(poly_degree);
// TODO(https://github.com/AztecProtocol/barretenberg/issues/857): This code is not efficient as its O(nlogn).
// This can be optimized to be linear by computing a tree of products. Its very readable, so we're
// leaving it unoptimized for now.
run_loop_in_parallel_if_effective(
poly_degree,
[&s_vec, &round_challenges_inv, log_poly_degree](size_t start, size_t end) {
Expand Down
12 changes: 4 additions & 8 deletions barretenberg/cpp/src/barretenberg/env/hardware_concurrency.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "hardware_concurrency.hpp"
#include <barretenberg/common/throw_or_abort.hpp>
#include <cstdlib>
#include <iostream>
#include <stdexcept>
#include <string>
#include <thread>
Expand All @@ -12,14 +13,9 @@ uint32_t env_hardware_concurrency()
#ifndef __wasm__
try {
#endif
#ifdef WASMTIME_ENV_HACK
// TODO(https://github.com/AztecProtocol/barretenberg/issues/837): Undo this hack, rely on WASI.
return 16;
#else
static auto val = std::getenv("HARDWARE_CONCURRENCY");
static const uint32_t cores = val ? (uint32_t)std::stoul(val) : std::thread::hardware_concurrency();
return cores;
#endif
static auto val = std::getenv("HARDWARE_CONCURRENCY");
static const uint32_t cores = val ? (uint32_t)std::stoul(val) : std::thread::hardware_concurrency();
return cores;
#ifndef __wasm__
} catch (std::exception const&) {
throw std::runtime_error("HARDWARE_CONCURRENCY invalid.");
Expand Down
Loading

0 comments on commit 26118e6

Please sign in to comment.