|
7 | 7 |
|
8 | 8 | using namespace taco;
|
9 | 9 |
|
10 |
| -// applyBenchSizes is used to configure the benchmarks to run with the |
11 |
| -// input arguments. |
12 |
| -static void applyBenchSizes(benchmark::internal::Benchmark* b) { |
13 |
| - // Currently considering these size square tensors. |
14 |
| - b->ArgsProduct({{5000, 10000, 20000}}); |
15 |
| -} |
| 10 | +// The tensor sizes that we want to run each windowing benchmark with. |
| 11 | +std::vector<int64_t> tensorSizes({5000, 10000, 20000}); |
16 | 12 |
|
17 | 13 | // WindowConfig corresponds to what sort of window size should be used
|
18 | 14 | // when evaluating standard windowing benchmarks. This should stay in
|
@@ -86,32 +82,33 @@ static void bench_add_sparse_window(benchmark::State& state, const Format& f, Wi
|
86 | 82 | }
|
87 | 83 |
|
88 | 84 | #define DECLARE_ADD_SPARSE_WINDOW_BENCH(configName, config) \
|
89 |
| - TACO_BENCH_ARGS(bench_add_sparse_window, csr/configName, CSR, config)->Apply(applyBenchSizes); \ |
90 |
| - TACO_BENCH_ARGS(bench_add_sparse_window, csc/configName, CSC, config)->Apply(applyBenchSizes); |
| 85 | + TACO_BENCH_ARGS(bench_add_sparse_window, csr/configName, CSR, config)->ArgsProduct({tensorSizes}); \ |
| 86 | + TACO_BENCH_ARGS(bench_add_sparse_window, csc/configName, CSC, config)->ArgsProduct({tensorSizes}); |
91 | 87 |
|
92 | 88 | FOREACH_WINDOW_CONFIG(DECLARE_ADD_SPARSE_WINDOW_BENCH)
|
93 | 89 |
|
94 | 90 | static void bench_add_sparse_strided_window(benchmark::State& state, const Format& f) {
|
95 | 91 | int dim = state.range(0);
|
| 92 | + int strideWidth = state.range(1); |
96 | 93 | auto sparsity = 0.01;
|
97 | 94 | Tensor<double> matrix = loadRandomTensor("A", {dim, dim}, sparsity, f);
|
98 | 95 | matrix.pack();
|
99 | 96 |
|
100 | 97 | for (auto _ : state) {
|
101 | 98 | // Setup.
|
102 | 99 | state.PauseTiming();
|
103 |
| - Tensor<double> result("B", {(dim-2)/4, (dim-2)/4}, f); |
| 100 | + Tensor<double> result("B", {dim/strideWidth, dim/strideWidth}, f); |
104 | 101 | IndexVar i, j;
|
105 |
| - result(i, j) = matrix(i(1, dim-1, 4), j(1, dim-1, 4)) + matrix(i(1, dim-1, 4), j(1, dim-1, 4)); |
| 102 | + result(i, j) = matrix(i(0, dim, strideWidth), j(0, dim, strideWidth)) + matrix(i(0, dim, strideWidth), j(0, dim, strideWidth)); |
106 | 103 | result.compile();
|
107 | 104 | result.assemble();
|
108 | 105 | state.ResumeTiming();
|
109 | 106 | // The actual computation.
|
110 | 107 | result.compute();
|
111 | 108 | }
|
112 | 109 | }
|
113 |
| - |
114 |
| -// Have benchmarking report milliseconds and run for 10 iterations. |
115 |
| -// Run an instance with both CSR and CSC formats. |
116 |
| -TACO_BENCH_ARG(bench_add_sparse_strided_window, csr, CSR)->Apply(applyBenchSizes); |
117 |
| -TACO_BENCH_ARG(bench_add_sparse_strided_window, csc, CSC)->Apply(applyBenchSizes); |
| 110 | +std::vector<int64_t> strides({2, 4, 8}); |
| 111 | +TACO_BENCH_ARG(bench_add_sparse_strided_window, csr, CSR) |
| 112 | + ->ArgsProduct({tensorSizes, strides}); |
| 113 | +TACO_BENCH_ARG(bench_add_sparse_strided_window, csc, CSC) |
| 114 | + ->ArgsProduct({tensorSizes, strides}); |
0 commit comments