36 #define BENCHMARK_RUNS 10 
   39 inline void printOps(
double num_ops, 
double exec_time)
 
   41   std::cout << 
"GFLOPs: " << num_ops / (1000000 * exec_time * 1000) << std::endl;
 
   45 template<
typename NumericT>
 
   50   for (std::size_t i = 0; i < mat.
size1(); ++i)
 
   52     for (std::size_t j = 0; j < mat.
size2(); ++j)
 
   53       mat(i, j) = 
static_cast<NumericT>(-0.5) * randomNumber();
 
   58 template<
typename NumericT>
 
   63   for (std::size_t i = 0; i < vec.
size(); ++i)
 
   67 template<
typename NumericT,
typename MatrixT1, 
typename MatrixT2,
typename MatrixT3, 
typename SolverTag>
 
   68 void run_solver_matrix(MatrixT1 
const & matrix1, MatrixT2 
const & matrix2,MatrixT3 & result, SolverTag)
 
   70   std::cout << 
"------- Solver tag: " <<SolverTag::name()<<
" ----------" << std::endl;
 
   80   double exec_time = timer.
get();
 
   82   std::cout << 
"GPU: ";
printOps(
double(matrix1.size1() * matrix1.size1() * matrix2.size2()),(static_cast<double>(exec_time) / 
static_cast<double>(
BENCHMARK_RUNS)));
 
   83   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;
 
   84   std::cout << 
"Execution time: " << exec_time/BENCHMARK_RUNS << std::endl;
 
   85   std::cout << 
"------- Finnished: " << SolverTag::name() << 
" ----------" << std::endl;
 
   88 template<
typename NumericT,
typename VectorT, 
typename VectorT2,
typename MatrixT, 
typename SolverTag>
 
   89 void run_solver_vector(MatrixT 
const & matrix, VectorT2 
const & vector2,VectorT & result, SolverTag)
 
   91   std::cout << 
"------- Solver tag: " <<SolverTag::name()<<
" ----------" << std::endl;
 
  102   double exec_time = timer.
get();
 
  104   std::cout << 
"GPU: ";
printOps(
double(matrix.size1() * matrix.size1()),(static_cast<double>(exec_time) / 
static_cast<double>(
BENCHMARK_RUNS)));
 
  105   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;
 
  106   std::cout << 
"Execution time: " << exec_time/BENCHMARK_RUNS << std::endl;
 
  107   std::cout << 
"------- Finished: " << SolverTag::name() << 
" ----------" << std::endl;
 
  110 template<
typename NumericT,
typename F_A, 
typename F_B>
 
  113   std::size_t matrix_size = 1500;  
 
  114   std::size_t rhs_num = 153;
 
  127   std::cout << 
"------- Solve Matrix-Matrix: ----------\n" << std::endl;
 
  132   std::cout << 
"------- End Matrix-Matrix: ----------\n" << std::endl;
 
  134   std::cout << 
"------- Solve Matrix-Vector: ----------\n" << std::endl;
 
  139   std::cout << 
"------- End Matrix-Vector: ----------\n" << std::endl;
 
  144   std::cout << std::endl;
 
  145   std::cout << 
"----------------------------------------------" << std::endl;
 
  146   std::cout << 
"               Device Info" << std::endl;
 
  147   std::cout << 
"----------------------------------------------" << std::endl;
 
  149 #ifdef VIENNACL_WITH_OPENCL 
  152   std::cout << std::endl;
 
  153   std::cout << 
"----------------------------------------------" << std::endl;
 
  154   std::cout << 
"----------------------------------------------" << std::endl;
 
  155   std::cout << 
"## Benchmark :: Direct solve" << std::endl;
 
  156   std::cout << 
"----------------------------------------------" << std::endl;
 
  157   std::cout << std::endl;
 
  158   std::cout << 
"   -------------------------------" << std::endl;
 
  159   std::cout << 
"   # benchmarking single-precision" << std::endl;
 
  160   std::cout << 
"   -------------------------------" << std::endl;
 
  161   run_benchmark<float,viennacl::row_major,viennacl::row_major>();
 
  162 #ifdef VIENNACL_WITH_OPENCL 
  166     std::cout << std::endl;
 
  167     std::cout << 
"   -------------------------------" << std::endl;
 
  168     std::cout << 
"   # benchmarking double-precision" << std::endl;
 
  169     std::cout << 
"   -------------------------------" << std::endl;
 
  170     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 fill_matrix(viennacl::matrix< NumericT > &mat)
VectorT solve(MatrixT const &matrix, VectorT const &rhs, bicgstab_tag const &tag, PreconditionerT const &precond)
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...
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. 
void printOps(double num_ops, double exec_time)
size_type size1() const 
Returns the number of rows. 
Implementations of dense direct solvers are found here. 
A simple, yet (mostly) sufficiently accurate timer for benchmarking and profiling. 
Proxy classes for matrices. 
The vector type with operator-overloads and proxy classes is defined here. Linear algebra operations ...
A small collection of sequential random number generators. 
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.