C++ example based on <rsb.hpp> measuring RsbMatrix.spmm() performance of a matrix with only two elements; this is is effectively measuring performance of result vector scaling.
- Author
- Michele Martone
#include <complex>
#include <array>
#include <vector>
#include <iomanip>
#include <iostream>
#include <string>
template <typename nt_t>
const std::vector<rsb_coo_idx_t>
IA{0,
n-1};
const std::vector<rsb_coo_idx_t>
JA{0,
n-1};
const std::vector<nt_t>
VA{1,1};
std::cout <<
"# Matrix sized " <<
mtx.rows() <<
"x" <<
mtx.cols() <<
", " <<
nnzA <<
" nnz built in " <<
dt <<
" s and occupies " <<
mtxocc <<
" bytes " << std::endl;
#if defined(RSB_LIBRSB_VER_DATE) && (RSB_LIBRSB_VER_DATE)
#endif
} )
{
std::vector<rsb_time_t>
dta;
const long long nnz_ops = (
mtx._is_complex() ? 6 : 1 );
for (
const auto nt : {1,
rnt} )
{
const std::vector<nt_t>
B(
nrhs*
mtx.cols(),1.);
std::vector<nt_t>
C(
nrhs*
mtx.rows(),0.);
}
std::cout <<
"# type=" <<
mtx.rsbtype() <<
" nt=1," <<
rnt <<
" n=" <<
n <<
" nrhs=" <<
nrhs <<
" order=" <<
oc <<
" alpha=" <<
alpha <<
" beta=" <<
beta <<
" dt=" <<
dta[0] <<
".." <<
dta[1] <<
" spmm-scalability=" <<
dta[0]/
dta[1] <<
" nnz/s=" <<
nnzA/
dta[0] <<
".." <<
nnzA/
dta[1] <<
" flops=" <<
flops_c/
dta[0] <<
".." <<
flops_c/
dta[1] <<
" occ.=" <<
opocc <<
" " << std::endl;
}
}
{
#ifdef RSB_NUMERICAL_TYPE_DOUBLE_COMPLEX
#endif
#ifdef RSB_NUMERICAL_TYPE_DOUBLE
#endif
#ifdef RSB_NUMERICAL_TYPE_FLOAT_COMPLEX
#endif
#ifdef RSB_NUMERICAL_TYPE_FLOAT
#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
rsb_int_t get_num_threads(void) const
Definition rsb.hpp:360
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_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
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