From fe5cc346fa077bfb72acfd2ff79c29582ed3af7d Mon Sep 17 00:00:00 2001
From: Lukas Cejka <lukas.ostatek@gmail.com>
Date: Thu, 5 Dec 2019 11:52:38 +0100
Subject: [PATCH] Added benchmarked format shortcut to cuSPARSE label of
 benchmark metadata.

---
 src/Benchmarks/SpMV/spmv.h | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/src/Benchmarks/SpMV/spmv.h b/src/Benchmarks/SpMV/spmv.h
index 41ede9d0a0..6bfee5ffef 100644
--- a/src/Benchmarks/SpMV/spmv.h
+++ b/src/Benchmarks/SpMV/spmv.h
@@ -59,6 +59,18 @@ std::string getMatrixFormat( const Matrix& matrix )
     return format;
 }
 
+template< typename Matrix >
+std::string getFormatShort( const Matrix& matrix )
+{
+    std::string mtrxFullType = getType( matrix );
+    std::string mtrxType = mtrxFullType.substr( 0, mtrxFullType.find( "<" ) );
+    std::string format = mtrxType.substr( mtrxType.find( ':' ) + 2 );
+    format = format.substr( format.find(':') + 2);
+    format = format.substr( 0, 3 );
+
+    return format;
+}
+
 // Print information about the matrix.
 template< typename Matrix >
 void printMatrixInfo( const Matrix& matrix,
@@ -221,7 +233,7 @@ benchmarkSpMV( Benchmark& benchmark,
           { "non-zeros", convertToString( hostMatrix.getNumberOfNonzeroMatrixElements() ) },
           { "rows", convertToString( hostMatrix.getRows() ) },
           { "columns", convertToString( hostMatrix.getColumns() ) },
-          { "matrix format", convertToString( "CSR-cuSPARSE" ) }
+          { "matrix format", convertToString( "CSR-cuSPARSE-" + getFormatShort( hostMatrix ) ) }
        } ));
 
     benchmark.time< Devices::Cuda >( reset, "GPU", spmvCusparse );
-- 
GitLab