@@ -161,7 +161,7 @@ TACO_BENCH_ARGS(bench_ufunc_sparse, rightShift_0.01, 0.01, ">>")->Apply(applyBen
161
161
// time from caching these inputs.
162
162
struct UfuncInputCache {
163
163
template <typename U>
164
- std::pair<taco::Tensor<int64_t >, taco::Tensor<int64_t >> getUfuncInput (std::string path, U format) {
164
+ std::pair<taco::Tensor<int64_t >, taco::Tensor<int64_t >> getUfuncInput (std::string path, U format, bool countNNZ = false ) {
165
165
// See if the paths match.
166
166
if (this ->lastPath == path) {
167
167
// TODO (rohany): Not worrying about whether the format was the same as what was asked for.
@@ -175,6 +175,12 @@ struct UfuncInputCache {
175
175
this ->lastPath = path;
176
176
this ->inputTensor = castToType<int64_t >(" A" , this ->lastLoaded );
177
177
this ->otherTensor = shiftLastMode<int64_t , int64_t >(" B" , this ->inputTensor );
178
+ if (countNNZ) {
179
+ this ->nnz = 0 ;
180
+ for (auto & it : iterate<int64_t >(this ->inputTensor )) {
181
+ this ->nnz ++;
182
+ }
183
+ }
178
184
return std::make_pair (this ->inputTensor , this ->otherTensor );
179
185
}
180
186
@@ -183,6 +189,7 @@ struct UfuncInputCache {
183
189
184
190
taco::Tensor<int64_t > inputTensor;
185
191
taco::Tensor<int64_t > otherTensor;
192
+ int64_t nnz;
186
193
};
187
194
UfuncInputCache inputCache;
188
195
@@ -295,29 +302,32 @@ static void bench_suitesparse_ufunc(benchmark::State& state, Func op) {
295
302
// Counters must be present in every run to get reported to the CSV.
296
303
state.counters [" dimx" ] = 0 ;
297
304
state.counters [" dimy" ] = 0 ;
298
- if (ssTensors.tensors .size () == 0 ) {
305
+ state.counters [" nnz" ] = 0 ;
306
+
307
+ auto tensorPath = getEnvVar (" SUITESPARSE_TENSOR_PATH" );
308
+ if (tensorPath == " " ) {
299
309
state.error_occurred ();
300
310
return ;
301
311
}
302
- int tensorIdx = state.range (0 );
303
- auto tensorPath = ssTensors.tensors [tensorIdx];
312
+
304
313
auto pathSplit = taco::util::split (tensorPath, " /" );
305
314
auto filename = pathSplit[pathSplit.size () - 1 ];
306
315
auto tensorName = taco::util::split (filename, " ." )[0 ];
307
316
state.SetLabel (tensorName);
308
317
309
318
taco::Tensor<int64_t > ssTensor, other;
310
319
try {
311
- std::tie (ssTensor, other) = inputCache.getUfuncInput (tensorPath, CSR);
320
+ std::tie (ssTensor, other) = inputCache.getUfuncInput (tensorPath, CSR, true /* countNNZ */ );
312
321
} catch (TacoException& e) {
313
322
// Counters don't show up in the generated CSV if we used SkipWithError, so
314
323
// just add in the label that this run is skipped.
315
- state.SetLabel (tensorName+" - SKIPPED-FAILED-READ" );
324
+ state.SetLabel (tensorName+" / SKIPPED-FAILED-READ" );
316
325
return ;
317
326
}
318
327
319
328
state.counters [" dimx" ] = ssTensor.getDimension (0 );
320
329
state.counters [" dimy" ] = ssTensor.getDimension (1 );
330
+ state.counters [" nnz" ] = inputCache.nnz ;
321
331
322
332
for (auto _ : state) {
323
333
state.PauseTiming ();
@@ -339,12 +349,6 @@ static void bench_suitesparse_ufunc(benchmark::State& state, Func op) {
339
349
}
340
350
}
341
351
342
- static void applySuiteSparse (benchmark::internal::Benchmark* b) {
343
- for (int i = 0 ; i < ssTensors.tensors .size (); i++) {
344
- b->Arg (i);
345
- }
346
- }
347
-
348
- TACO_BENCH_ARGS (bench_suitesparse_ufunc, xor , xorOp)->Apply(applySuiteSparse);
349
- TACO_BENCH_ARGS (bench_suitesparse_ufunc, ldExp, ldExp)->Apply(applySuiteSparse);
350
- TACO_BENCH_ARGS (bench_suitesparse_ufunc, rightShift, rightShift)->Apply(applySuiteSparse);
352
+ TACO_BENCH_ARGS (bench_suitesparse_ufunc, xor , xorOp);
353
+ TACO_BENCH_ARGS (bench_suitesparse_ufunc, ldExp, ldExp);
354
+ TACO_BENCH_ARGS (bench_suitesparse_ufunc, rightShift, rightShift);
0 commit comments