Skip to content

Commit dbee808

Browse files
committed
taco: parametrize striding benchmark by stride width
1 parent 7728f33 commit dbee808

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

taco/windowing.cpp

+12-15
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,8 @@
77

88
using namespace taco;
99

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});
1612

1713
// WindowConfig corresponds to what sort of window size should be used
1814
// 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
8682
}
8783

8884
#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});
9187

9288
FOREACH_WINDOW_CONFIG(DECLARE_ADD_SPARSE_WINDOW_BENCH)
9389

9490
static void bench_add_sparse_strided_window(benchmark::State& state, const Format& f) {
9591
int dim = state.range(0);
92+
int strideWidth = state.range(1);
9693
auto sparsity = 0.01;
9794
Tensor<double> matrix = loadRandomTensor("A", {dim, dim}, sparsity, f);
9895
matrix.pack();
9996

10097
for (auto _ : state) {
10198
// Setup.
10299
state.PauseTiming();
103-
Tensor<double> result("B", {(dim-2)/4, (dim-2)/4}, f);
100+
Tensor<double> result("B", {dim/strideWidth, dim/strideWidth}, f);
104101
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));
106103
result.compile();
107104
result.assemble();
108105
state.ResumeTiming();
109106
// The actual computation.
110107
result.compute();
111108
}
112109
}
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

Comments
 (0)