diff --git a/barretenberg/cpp/scripts/benchmark_example_ivc_flow_remote.sh b/barretenberg/cpp/scripts/benchmark_example_ivc_flow_remote.sh index 514240c14af3..174f42f13640 100755 --- a/barretenberg/cpp/scripts/benchmark_example_ivc_flow_remote.sh +++ b/barretenberg/cpp/scripts/benchmark_example_ivc_flow_remote.sh @@ -7,7 +7,7 @@ TARGET=${1:-"bb"} #FLOW=${2:-"ecdsar1+transfer_1_recursions+sponsored_fpc"} #FLOW=${2:-"ecdsar1+transfer_1_recursions+sponsored_fpc"} FLOW=${2:-"schnorr+deploy_tokenContract_with_registration+sponsored_fpc"} -BUILD_DIR="build-no-avm" +BUILD_DIR="build" # Move above script dir. cd $(dirname $0)/.. diff --git a/barretenberg/cpp/src/barretenberg/honk/composer/permutation_lib.hpp b/barretenberg/cpp/src/barretenberg/honk/composer/permutation_lib.hpp index 619843b7753a..4ffb8ff61850 100644 --- a/barretenberg/cpp/src/barretenberg/honk/composer/permutation_lib.hpp +++ b/barretenberg/cpp/src/barretenberg/honk/composer/permutation_lib.hpp @@ -125,6 +125,8 @@ PermutationMapping compute_permutation_mapping( const std::vector& wire_copy_cycles) { + BB_BENCH_NAME("compute_permutation_mapping"); + // Initialize the table of permutations so that every element points to itself PermutationMapping mapping(dyadic_size); @@ -132,43 +134,45 @@ PermutationMapping compute_permutation_mapping( std::span real_variable_tags = circuit_constructor.real_variable_tags; // Go through each cycle - for (size_t cycle_idx = 0; cycle_idx < wire_copy_cycles.size(); ++cycle_idx) { - // We go through the cycle and fill-out/modify `mapping`. Following the generalized permutation algorithm, we - // take separate care of first/last node handling. - const CyclicPermutation& cycle = wire_copy_cycles[cycle_idx]; - const auto cycle_size = cycle.size(); - if (cycle_size == 0) { - continue; - } + parallel_for([&](const ThreadChunk& chunk) { + for (size_t cycle_idx : chunk.range(wire_copy_cycles.size())) { + // We go through the cycle and fill-out/modify `mapping`. Following the generalized permutation + // algorithm, we take separate care of first/last node handling. + const CyclicPermutation& cycle = wire_copy_cycles[cycle_idx]; + const auto cycle_size = cycle.size(); + if (cycle_size == 0) { + continue; + } - const cycle_node& first_node = cycle[0]; - const cycle_node& last_node = cycle[cycle_size - 1]; + const cycle_node& first_node = cycle[0]; + const cycle_node& last_node = cycle[cycle_size - 1]; - const auto first_row = static_cast(first_node.gate_idx); - const auto first_col = first_node.wire_idx; - const auto last_row = static_cast(last_node.gate_idx); - const auto last_col = last_node.wire_idx; + const auto first_row = static_cast(first_node.gate_idx); + const auto first_col = first_node.wire_idx; + const auto last_row = static_cast(last_node.gate_idx); + const auto last_col = last_node.wire_idx; - // First node: id gets tagged with the cycle's variable tag - mapping.ids[first_col].is_tag[first_row] = true; - mapping.ids[first_col].row_idx[first_row] = real_variable_tags[cycle_idx]; + // First node: id gets tagged with the cycle's variable tag + mapping.ids[first_col].is_tag[first_row] = true; + mapping.ids[first_col].row_idx[first_row] = real_variable_tags[cycle_idx]; - // Last node: sigma gets tagged and points to tau(tag) instead of wrapping to first node - mapping.sigmas[last_col].is_tag[last_row] = true; - mapping.sigmas[last_col].row_idx[last_row] = circuit_constructor.tau().at(real_variable_tags[cycle_idx]); + // Last node: sigma gets tagged and points to tau(tag) instead of wrapping to first node + mapping.sigmas[last_col].is_tag[last_row] = true; + mapping.sigmas[last_col].row_idx[last_row] = circuit_constructor.tau().at(real_variable_tags[cycle_idx]); - // All nodes except the last: sigma points to the next node in the cycle - for (size_t node_idx = 0; node_idx + 1 < cycle_size; ++node_idx) { - const cycle_node& current_node = cycle[node_idx]; - const cycle_node& next_node = cycle[node_idx + 1]; + // All nodes except the last: sigma points to the next node in the cycle + for (size_t node_idx = 0; node_idx + 1 < cycle_size; ++node_idx) { + const cycle_node& current_node = cycle[node_idx]; + const cycle_node& next_node = cycle[node_idx + 1]; - const auto current_row = static_cast(current_node.gate_idx); - const auto current_col = current_node.wire_idx; - // Point current node to next node. - mapping.sigmas[current_col].row_idx[current_row] = next_node.gate_idx; - mapping.sigmas[current_col].col_idx[current_row] = static_cast(next_node.wire_idx); + const auto current_row = static_cast(current_node.gate_idx); + const auto current_col = current_node.wire_idx; + // Point current node to next node. + mapping.sigmas[current_col].row_idx[current_row] = next_node.gate_idx; + mapping.sigmas[current_col].col_idx[current_row] = static_cast(next_node.wire_idx); + } } - } + }); // Add information about public inputs so that the cycles can be altered later; See the construction of the // permutation polynomials for details. This _only_ effects sigma_0, the 0th sigma polynomial, as the structure of diff --git a/barretenberg/cpp/src/barretenberg/trace_to_polynomials/trace_to_polynomials.cpp b/barretenberg/cpp/src/barretenberg/trace_to_polynomials/trace_to_polynomials.cpp index 4e062686edd2..8a82d30c2502 100644 --- a/barretenberg/cpp/src/barretenberg/trace_to_polynomials/trace_to_polynomials.cpp +++ b/barretenberg/cpp/src/barretenberg/trace_to_polynomials/trace_to_polynomials.cpp @@ -79,13 +79,15 @@ std::vector TraceToPolynomials::populate_wires_and_se RefVector> block_selectors = block.get_selectors(); // Insert the selector values for this block into the selector polynomials at the correct offset // TODO(https://github.com/AztecProtocol/barretenberg/issues/398): implicit arithmetization/flavor consistency - for (size_t selector_idx = 0; selector_idx < block_selectors.size(); selector_idx++) { - auto& selector = block_selectors[selector_idx]; - for (size_t row_idx = 0; row_idx < block_size; ++row_idx) { - size_t trace_row_idx = row_idx + offset; - selectors[selector_idx].set_if_valid_index(trace_row_idx, selector[row_idx]); + parallel_for([&](const ThreadChunk& chunk) { + for (size_t selector_idx = 0; selector_idx < block_selectors.size(); selector_idx++) { + auto& selector = block_selectors[selector_idx]; + for (size_t row_idx : chunk.range(block_size)) { + size_t trace_row_idx = row_idx + offset; + selectors[selector_idx].set_if_valid_index(trace_row_idx, selector[row_idx]); + } } - } + }); } return copy_cycles;