#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;
const long long nnz_ops = ( is_sym ? 2 : 1 ) * ( mtx._is_complex() ? 8 : 2 );
const rsb_real_t mtxocc = mtx._get_storage_bytes();
std::cout << "Read matrix " << std::quoted(filename) << " : " << mtx._info() << std::endl << std::endl;
std::cout << "Matrix occupies " << mtxocc << " bytes " << std::endl;
{
const rsb_real_t opocc =
sizeof(nt_t)*nrhs*(mtx.cols()+mtx.rows());
std::cout << std::endl << "Operands occupy " << opocc << " bytes now ( with " << nrhs << " nrhs )" << std::endl;
const std::vector<nt_t> B(nrhs*mtx.cols(),1.);
std::vector<nt_t> C(nrhs*mtx.rows(),0.);
const nt_t alpha { 1.}, beta { 1.};
mtx.spmm(transA,&alpha,nrhs,order,B.data(),ldB,&beta,C.data(),ldC);
mtx.spmm(transA,&alpha,nrhs,order,B.data(),ldB,&beta,C.data(),ldC);
const auto flops_u = (nnz_ops*nnzA*nrhs)/dt;
std::cout << "rsb_spmm-" << nrhs << "-" << oc << " took " << dt << " s, for " << nnzA/dt << " nnz/s, " << flops_u << " flops/s\n";
if(true)
{
if(false)
mtx.tune_spmm(&sf,&tn,maxr,tmax,transA,&alpha,nrhs,order,B.data(),ldB,&beta,C.data(),ldC);
auto nnsmA {mtx.blocks()};
std::cout << "Tuning took " << tt << " s ( " << tt / dt << " ops ) and changed " << nsmA << " to " << nnsmA << " blocks" << std::endl;
mtx.spmm(transA,&alpha,nrhs,order,B.data(),ldB,&beta,C.data(),ldC);
mtx.spmm(transA,&alpha,nrhs,order,B.data(),ldB,&beta,C.data(),ldC);
const auto flops_o = (nnz_ops*nnzA*nrhs)/dt;
std::cout << "rsb_spmm-" << nrhs << "-" << oc << " took " << dt << " s, for " << nnzA/dt << " nnz/s, " << flops_o << " flops/s\n";
if ( sf > 1.0 && flops_o > flops_u )
std::cout << "Tuning brought a " << std::max(flops_o / flops_u,sf) << " x speedup" << std::endl;
else
std::cout << "Tuning brought no speedup" << std::endl;
}
}
std::cout << "Done." << std::endl;
}
auto main(
const int argc,
char * argv[]) ->
int
{
const std::string filename{ argc > 1 ? argv[1] : "../A.mtx"};
#if defined(RSB_LIBRSB_VER_DATE) && (RSB_LIBRSB_VER_DATE)
#endif
} )
{
#ifdef RSB_NUMERICAL_TYPE_FLOAT
bench<float>(filename,order);
#endif
#ifdef RSB_NUMERICAL_TYPE_DOUBLE
bench<double>(filename,order);
#endif
#ifdef RSB_NUMERICAL_TYPE_FLOAT_COMPLEX
bench<std::complex<float>>(filename,order);
#endif
#ifdef RSB_NUMERICAL_TYPE_DOUBLE_COMPLEX
bench<std::complex<double>>(filename,order);
#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
RSBP_RVT Err_t set_opt(enum rsb_opt_t iof, const void *iop)
Definition: rsb.hpp:309
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_IO_WANT_VERBOSE_TUNING
Definition: rsb.h:779
#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
signed int rsb_blk_idx_t
Definition: rsb.h:338
#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