28 #define VIENNACL_WITH_UBLAS 
   31  #define BOOST_UBLAS_NDEBUG 
   57 #include "boost/numeric/ublas/vector.hpp" 
   58 #include "boost/numeric/ublas/matrix.hpp" 
   59 #include "boost/numeric/ublas/io.hpp" 
   67 template<
typename MatrixT, 
typename VectorT, 
typename SolverTagT, 
typename PreconditionerT>
 
   68 void run_solver(MatrixT 
const & A, VectorT 
const & b, SolverTagT 
const & solver_tag, PreconditionerT 
const & precond)
 
   71   std::cout << 
" * Solver iterations: " << solver_tag.iters() << std::endl;
 
   87 int main (
int, 
const char **)
 
   90   typedef boost::numeric::ublas::compressed_matrix<ScalarType>        MatrixType;
 
   91   typedef boost::numeric::ublas::vector<ScalarType>                   VectorType;
 
   98 #ifdef VIENNACL_WITH_OPENCL 
  101   std::vector<viennacl::ocl::device> 
const & devices = pf.
devices();
 
  107   if (devices.size() > 1)
 
  125     std::cerr<<
"ERROR: Could not read matrix file " << std::endl;
 
  129   std::cout << 
"Size of matrix: " << M.size1() << std::endl;
 
  130   std::cout << 
"Avg. Entries per row: " << double(M.nnz()) / static_cast<double>(M.size1()) << std::endl;
 
  135   VectorType rhs(M.size2());
 
  136   for (std::size_t i=0; i<rhs.size(); ++i)
 
  142   GPUMatrixType  gpu_M(M.size1(), M.size2(), ctx);
 
  143   GPUVectorType  gpu_rhs(M.size1(), ctx);
 
  158   std::cout << 
"--- Reference 1: Pure BiCGStab on CPU ---" << std::endl;
 
  160   std::cout << 
" * Solver iterations: " << solver_tag.iters() << std::endl;
 
  164   std::cout << 
"--- Reference 2: Pure BiCGStab on GPU ---" << std::endl;
 
  166   std::cout << 
" * Solver iterations: " << solver_tag.iters() << std::endl;
 
  168   gpu_residual -= gpu_rhs;
 
  175   std::cout << 
"--- Reference 2: BiCGStab with ILUT on CPU ---" << std::endl;
 
  176   std::cout << 
" * Preconditioner setup..." << std::endl;
 
  178   std::cout << 
" * Iterative solver run..." << std::endl;
 
  185   std::cout << 
"--- Test 1: CPU-based SPAI ---" << std::endl;
 
  186   std::cout << 
" * Preconditioner setup..." << std::endl;
 
  188   std::cout << 
" * Iterative solver run..." << std::endl;
 
  194   std::cout << 
"--- Test 2: CPU-based FSPAI ---" << std::endl;
 
  195   std::cout << 
" * Preconditioner setup..." << std::endl;
 
  197   std::cout << 
" * Iterative solver run..." << std::endl;
 
  203   std::cout << 
"--- Test 3: GPU-based SPAI ---" << std::endl;
 
  204   std::cout << 
" * Preconditioner setup..." << std::endl;
 
  206   std::cout << 
" * Iterative solver run..." << std::endl;
 
  207   run_solver(gpu_M, gpu_rhs, solver_tag, spai_gpu);
 
  212   std::cout << 
"--- Test 4: GPU-based FSPAI ---" << std::endl;
 
  213   std::cout << 
" * Preconditioner setup..." << std::endl;
 
  215   std::cout << 
" * Iterative solver run..." << std::endl;
 
  216   run_solver(gpu_M, gpu_rhs, solver_tag, fspai_gpu);
 
  221   std::cout << 
"!!!! TUTORIAL COMPLETED SUCCESSFULLY !!!!" << std::endl;
 
T norm_2(std::vector< T, A > const &v1)
A reader and writer for the matrix market format is implemented here. 
std::vector< platform > get_platforms()
Generic interface for the l^2-norm. See viennacl/linalg/vector_operations.hpp for implementations...
Generic interface for matrix-vector and matrix-matrix products. See viennacl/linalg/vector_operations...
Implementation of the dense matrix class. 
The stabilized bi-conjugate gradient method is implemented here. 
viennacl::ocl::device const & current_device()
Convenience function for returning the active device in the current context. 
Generic interface for the computation of inner products. See viennacl/linalg/vector_operations.hpp for implementations. 
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...
Represents a generic 'context' similar to an OpenCL context, but is backend-agnostic and thus also su...
VectorT prod(std::vector< std::vector< T, A1 >, A2 > const &matrix, VectorT const &vector)
A tag for FSPAI. Experimental. 
Implementations of incomplete factorization preconditioners. Convenience header file. 
Implementation of the Factored SParse Approximate Inverse Algorithm for a generic, uBLAS-compatible matrix type. 
A tag for incomplete LU factorization with threshold (ILUT) 
Implementation of the compressed_matrix class. 
Implementation of the SParse Approximate Inverse Algorithm for a generic, uBLAS-compatible matrix typ...
void run_solver(MatrixType const &matrix, VectorType const &rhs, VectorType const &ref_result, SolverTag const &solver, PrecondTag const &precond, long ops)
ILUT preconditioner class, can be supplied to solve()-routines. 
The conjugate gradient method is implemented here. 
void copy(std::vector< NumericT > &cpu_vec, circulant_matrix< NumericT, AlignmentV > &gpu_mat)
Copies a circulant matrix from the std::vector to the OpenCL device (either GPU or multi-core CPU) ...
Main include file for the sparse approximate inverse preconditioner family (SPAI and FSPAI)...
A sparse square matrix in compressed sparse rows format. 
A tag for the stabilized Bi-conjugate gradient solver. Used for supplying solver parameters and for d...
long read_matrix_market_file(MatrixT &mat, const char *file, long index_base=1)
Reads a sparse matrix from a file (MatrixMarket format) 
viennacl::ocl::context & get_context(long i)
Convenience function for returning the current context. 
Implementation of the ViennaCL scalar class. 
void setup_context(long i, std::vector< cl_device_id > const &devices)
Convenience function for setting devices for a context.