Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
execution_trace_usage_tracker.test.cpp
Go to the documentation of this file.
2
3#include <gtest/gtest.h>
4
5using namespace bb;
6
12class ExecutionTraceUsageTrackerTest : public ::testing::Test {};
13
14// Test construction of the sorted disjoint union of active ranges from a more general set of ranges
16{
18
19 std::vector<Range> active_ranges = { { 4, 7 }, { 9, 13 }, { 1, 12 }, { 23, 40 }, { 17, 19 } };
20
21 std::vector<Range> expected_union_ranges = { { 1, 13 }, { 17, 19 }, { 23, 40 } };
22
23 std::vector<Range> union_ranges = ExecutionTraceUsageTracker::construct_union_of_ranges(active_ranges);
24
25 EXPECT_EQ(union_ranges, expected_union_ranges);
26}
27
28// Test construction of ranges of indices for each thread that evenly distribute work according to the provided ranges
30{
32
33 std::vector<Range> union_ranges = { { 2, 8 }, { 13, 34 }, { 36, 45 }, { 50, 60 } };
34
35 std::vector<std::vector<Range>> expected_thread_ranges = { { { 2, 4 }, { 13, 19 }, { 36, 39 }, { 50, 53 } },
36 { { 4, 6 }, { 19, 24 }, { 39, 41 }, { 53, 56 } },
37 { { 6, 7 }, { 24, 29 }, { 41, 43 }, { 56, 58 } },
38 { { 7, 8 }, { 29, 34 }, { 43, 45 }, { 58, 60 } } };
39
40 const size_t num_threads = 4;
41 std::vector<std::vector<Range>> thread_ranges =
43
44 EXPECT_EQ(thread_ranges, expected_thread_ranges);
45}
46
47TEST_F(ExecutionTraceUsageTrackerTest, ConstructThreadRangesMoreThreadsThanWork)
48{
50
51 std::vector<Range> union_ranges = { { 2, 3 }, { 13, 14 } };
52
53 std::vector<std::vector<Range>> expected_thread_ranges = { { { 2, 3 }, { 13, 14 } }, {}, {}, {} };
54
55 const size_t num_threads = 4;
56 std::vector<std::vector<Range>> thread_ranges =
58
59 EXPECT_EQ(thread_ranges, expected_thread_ranges);
60}
61
62// Test that a large range is properly split across multiple threads
63TEST_F(ExecutionTraceUsageTrackerTest, ConstructThreadRangesSplitsLargeRange)
64{
66
67 // Single range that is too large to fit in a single thread
68 std::vector<Range> union_ranges = { { 0, 1 }, { 2, 101 } };
69
70 std::vector<std::vector<Range>> expected_thread_ranges = { { { 0, 1 }, { 2, 35 } },
71 { { 35, 68 } },
72 { { 68, 101 } } };
73
74 const size_t num_threads = 3;
75 std::vector<std::vector<Range>> thread_ranges =
77
78 EXPECT_EQ(thread_ranges, expected_thread_ranges);
79}
Tests for some of the utility methods in ExecutionTraceUsageTrackerTest for equally distributing work...
Entry point for Barretenberg command-line interface.
TEST_F(IPATest, ChallengesAreZero)
Definition ipa.test.cpp:123
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
static std::vector< Range > construct_union_of_ranges(std::vector< Range > &ranges)
Construct sorted disjoint ranges representing the union of an arbitrary set of ranges.
static std::vector< std::vector< Range > > construct_ranges_for_equal_content_distribution(const std::vector< Range > &union_ranges, const size_t num_threads)
Given a set of ranges indicating "active" regions of an ambient space, define a given number of new r...