C++ example based on <rsb.hpp> for performance-benchmarking a matrix from file using RsbMatrix.spmm(), for various right-hand side counts.
- Author
- Michele Martone
#include <complex>
#include <array>
#include <vector>
#include <iomanip>
#include <iostream>
#include <string>
template <typename nt_t>
std::cout <<
"# Librsb initialized with " <<
rnt <<
" threads." << std::endl;
std::cout <<
"# detected custom memory hierarchy info: " <<
mhis << std::endl;
std::cout <<
"# Read matrix " << std::quoted(
mtxname) <<
" : " <<
mtx._info() << std::endl <<
"#" << std::endl;
std::cout <<
"# Matrix file " << std::quoted(
filename) <<
" read in " <<
dt <<
" s " << std::endl;
std::cout <<
"# Matrix occupies " <<
mtxocc <<
" bytes " << std::endl;
std::cout <<
"#" << std::endl <<
"# Operands occupy " <<
opocc <<
" bytes now ( with " <<
nrhs <<
" nrhs )" << std::endl;
#if defined(RSB_LIBRSB_VER_DATE) && (RSB_LIBRSB_VER_DATE)
#endif
} )
{
const std::vector<nt_t>
B(
nrhs*
mtx.cols(),1.);
std::vector<nt_t>
C(
nrhs*
mtx.rows(),0.);
const std::string
tag { std::string() +
mtx.rsbtype() +
':' + std::to_string(
nrhs) +
'-' +
oc +
':' +
mtxname };
dt = std::numeric_limits<
decltype(
dt)>
::max();
do {
std::cout <<
"# rsb_spmm-" <<
nrhs <<
"-" <<
oc <<
" took " <<
dt <<
" s, for " <<
nnzA/
dt <<
" nnz/s, " <<
flops_u <<
" flops/s on " <<
its <<
" samples\n";
}
}
std::cout << "# Done." << std::endl;
}
{
std::cout << "MTX"<< "\t" << "FLOPS" << std::endl;
#ifdef RSB_NUMERICAL_TYPE_FLOAT
#endif
#ifdef RSB_NUMERICAL_TYPE_DOUBLE
#endif
#ifdef RSB_NUMERICAL_TYPE_FLOAT_COMPLEX
#endif
#ifdef RSB_NUMERICAL_TYPE_DOUBLE_COMPLEX
#endif
}
auto main() -> int
Definition assemble.cpp:38
void bench(const std::string filename, rsb_flags_t order)
Definition autotune.cpp:42
Class initializing/finalizing librsb state.
Definition rsb.hpp:272
Represent a sparse matrix in RSB format by means of librsb.
Definition rsb.hpp:532
rsb_time_t rsb_time(void)
Definition rsb_rsb.c:1697
@ RSB_ELOPF_POW
Definition rsb.h:947
@ RSB_IO_WANT_MEMORY_HIERARCHY_INFO_STRING
Definition rsb.h:747
#define RSB_FLAG_SYMMETRIC
Definition rsb.h:554
rsb_flags_t rsb_trans_t
Definition rsb.h:400
signed int rsb_nnz_idx_t
Definition rsb.h:362
signed int rsb_coo_idx_t
Definition rsb.h:349
signed int rsb_flags_t
Definition rsb.h:373
#define RSB_FLAG_WANT_COLUMN_MAJOR_ORDER
Definition rsb.h:496
#define RSB_FLAG_WANT_ROW_MAJOR_ORDER
Definition rsb.h:493
double rsb_real_t
Definition rsb.h:403
rsb_real_t rsb_time_t
Definition rsb.h:411
#define RSB_FLAG_HERMITIAN
Definition rsb.h:557
signed int rsb_int_t
Definition rsb.h:392
Classes RsbLib and RsbMatrix provide native C++ access to librsb.
#define RSB_TRANSPOSITION_N
N: Non transposed flag, valid for rsb_trans_t typed variables.
Definition rsb_types.h:138