37 #define BENCHMARK_RUNS 10
39 template<
typename NumericT>
42 for (std::size_t i = 0; i < mat.
size1(); ++i)
44 for (std::size_t j = 0; j < mat.
size2(); ++j)
45 mat(i, j) =
static_cast<NumericT
>(-0.5) * random<NumericT>();
46 mat(i, i) = NumericT(1.0) + NumericT(2.0) * random<NumericT>();
50 template<
typename NumericT>
53 for (std::size_t i = 0; i < vec.
size(); ++i)
54 vec(i) = NumericT(1.0) + NumericT(2.0) * random<NumericT>();
57 template<
typename NumericT,
typename MatrixT1,
typename MatrixT2,
typename MatrixT3,
typename SolverTag>
58 void run_solver_matrix(MatrixT1
const & matrix1, MatrixT2
const & matrix2,MatrixT3 & result, SolverTag)
60 std::cout <<
"------- Solver tag: " <<SolverTag::name()<<
" ----------" << std::endl;
70 double exec_time = timer.
get();
72 std::cout <<
"GPU: ";
printOps(
double(matrix1.size1() * matrix1.size1() * matrix2.size2()),(static_cast<double>(exec_time) /
static_cast<double>(
BENCHMARK_RUNS)));
73 std::cout <<
"GPU: " << double(matrix1.size1() * matrix1.size1() * matrix2.size2() *
sizeof(NumericT)) / (
static_cast<double>(exec_time) / static_cast<double>(BENCHMARK_RUNS)) / 1e9 <<
" GB/sec" << std::endl;
74 std::cout <<
"Execution time: " << exec_time/BENCHMARK_RUNS << std::endl;
75 std::cout <<
"------- Finnished: " << SolverTag::name() <<
" ----------" << std::endl;
78 template<
typename NumericT,
typename VectorT,
typename VectorT2,
typename MatrixT,
typename SolverTag>
79 void run_solver_vector(MatrixT
const & matrix, VectorT2
const & vector2,VectorT & result, SolverTag)
81 std::cout <<
"------- Solver tag: " <<SolverTag::name()<<
" ----------" << std::endl;
92 double exec_time = timer.
get();
94 std::cout <<
"GPU: ";
printOps(
double(matrix.size1() * matrix.size1()),(static_cast<double>(exec_time) /
static_cast<double>(
BENCHMARK_RUNS)));
95 std::cout <<
"GPU: "<< double(matrix.size1() * matrix.size1() *
sizeof(NumericT)) / (
static_cast<double>(exec_time) / static_cast<double>(BENCHMARK_RUNS)) / 1e9 <<
" GB/sec" << std::endl;
96 std::cout <<
"Execution time: " << exec_time/BENCHMARK_RUNS << std::endl;
97 std::cout <<
"------- Finished: " << SolverTag::name() <<
" ----------" << std::endl;
100 template<
typename NumericT,
typename F_A,
typename F_B>
103 std::size_t matrix_size = 1500;
104 std::size_t rhs_num = 153;
117 std::cout <<
"------- Solve Matrix-Matrix: ----------\n" << std::endl;
122 std::cout <<
"------- End Matrix-Matrix: ----------\n" << std::endl;
124 std::cout <<
"------- Solve Matrix-Vector: ----------\n" << std::endl;
129 std::cout <<
"------- End Matrix-Vector: ----------\n" << std::endl;
134 std::cout << std::endl;
135 std::cout <<
"----------------------------------------------" << std::endl;
136 std::cout <<
" Device Info" << std::endl;
137 std::cout <<
"----------------------------------------------" << std::endl;
139 #ifdef VIENNACL_WITH_OPENCL
142 std::cout << std::endl;
143 std::cout <<
"----------------------------------------------" << std::endl;
144 std::cout <<
"----------------------------------------------" << std::endl;
145 std::cout <<
"## Benchmark :: Direct solve" << std::endl;
146 std::cout <<
"----------------------------------------------" << std::endl;
147 std::cout << std::endl;
148 std::cout <<
" -------------------------------" << std::endl;
149 std::cout <<
" # benchmarking single-precision" << std::endl;
150 std::cout <<
" -------------------------------" << std::endl;
151 run_benchmark<float,viennacl::row_major,viennacl::row_major>();
152 #ifdef VIENNACL_WITH_OPENCL
156 std::cout << std::endl;
157 std::cout <<
" -------------------------------" << std::endl;
158 std::cout <<
" # benchmarking double-precision" << std::endl;
159 std::cout <<
" -------------------------------" << std::endl;
160 run_benchmark<double,viennacl::row_major,viennacl::row_major>();
void run_solver_vector(MatrixT const &matrix, VectorT2 const &vector2, VectorT &result, SolverTag)
Generic interface for the l^2-norm. See viennacl/linalg/vector_operations.hpp for implementations...
void run_solver_matrix(MatrixT1 const &matrix1, MatrixT2 const &matrix2, MatrixT3 &result, SolverTag)
Generic interface for matrix-vector and matrix-matrix products. See viennacl/linalg/vector_operations...
Implementation of the dense matrix class.
A tag class representing a lower triangular matrix.
void finish()
Synchronizes the execution. finish() will only return after all compute kernels (CUDA, OpenCL) have completed.
viennacl::ocl::device const & current_device()
Convenience function for returning the active device in the current context.
void printOps(double num_ops, double exec_time)
void fill_matrix(viennacl::matrix< NumericT > &mat)
std::string info(vcl_size_t indent=0, char indent_char= ' ') const
Returns an info string with a few properties of the device. Use full_info() to get all details...
viennacl::vector< NumericT > solve(viennacl::compressed_matrix< NumericT > const &A, viennacl::vector_base< NumericT > const &rhs, bicgstab_tag const &tag, viennacl::linalg::no_precond)
Overload for the pipelined BiCGStab implementation for the ViennaCL sparse matrix types...
A tag class representing an upper triangular matrix.
void fill_vector(viennacl::vector< NumericT > &vec)
bool double_support() const
ViennaCL convenience function: Returns true if the device supports double precision.
size_type size2() const
Returns the number of columns.
size_type size1() const
Returns the number of rows.
Implementations of dense direct solvers are found here.
Proxy classes for matrices.
The vector type with operator-overloads and proxy classes is defined here. Linear algebra operations ...
size_type size() const
Returns the length of the vector (cf. std::vector)
A tag class representing a lower triangular matrix with unit diagonal.
Implementation of the ViennaCL scalar class.
A tag class representing an upper triangular matrix with unit diagonal.