14 #include <cusp/gallery/poisson.h>
15 #include <cusp/csr_matrix.h>
24 template <
typename IndexType,
typename ValueType,
typename MemorySpace,
27 IndexType max_its, ValueType tol,
bool verbose) {
29 cusp::csr_matrix<IndexType, ValueType, MemorySpace>
A;
32 cusp::gallery::poisson27pt(A, nx, ny, nz);
33 std::cout <<
"N =" << A.num_rows<< std::endl;
34 std::cout <<
"nnz of A = " << A.num_entries << std::endl;
37 std::cout <<
"\nSolving Ax = b with multiple RHS..." << std::endl;
40 cusp::array2d<ValueType, MemorySpace, Orientation> x(A.num_rows, nrhs, 0);
41 cusp::array2d<ValueType, MemorySpace, Orientation> b(A.num_rows, nrhs, 1);
43 std::cout <<
"numRHS = " << nrhs << std::endl;
53 std::cout <<
"\nPreconditioner statistics" << std::endl;
72 typedef int IndexType;
73 typedef double ValueType;
74 typedef cusp::device_memory MemorySpace;
84 "This example runs AMG-preconditioned block-CG with CUSP.\n");
87 CLP.
setOption(
"nx", &nx,
"Number of mesh points in the x-direction");
89 CLP.
setOption(
"ny", &ny,
"Number of mesh points in the y-direction");
91 CLP.
setOption(
"nz", &nz,
"Number of mesh points in the z-direction");
93 CLP.
setOption(
"nrhs", &nrhs,
"Number of right-hand-sides");
96 "Orientation of block RHS");
97 IndexType max_its = 100;
99 "Maximum number of CG iterations");
101 CLP.
setOption(
"tolerance", &tol,
"Convergence tolerance");
103 CLP.
setOption(
"device", &device_id,
"CUDA device ID");
104 CLP.
setOption(
"verbose",
"quiet", &verbose,
"Verbose output");
105 CLP.
parse( argc, argv );
108 cudaSetDevice(device_id);
109 cudaDeviceSetSharedMemConfig(cudaSharedMemBankSizeEightByte);
112 cusp_sa_block_cg<IndexType,ValueType,MemorySpace,cusp::row_major>(
113 nx, ny, nz, nrhs, max_its, tol, verbose);
114 else if (orient ==
COL)
115 cusp_sa_block_cg<IndexType,ValueType,MemorySpace,cusp::column_major>(
116 nx, ny, nz, nrhs, max_its, tol, verbose);
#define TEUCHOS_FUNC_TIME_MONITOR(FUNCNAME)
void blockcg(LinearOperator &A, Vector &x, Vector &b)
const Orient orient_values[]
static void summarize(Ptr< const Comm< int > > comm, std::ostream &out=std::cout, const bool alwaysWriteLocal=false, const bool writeGlobalStats=true, const bool writeZeroTimers=true, const ECounterSetOp setOp=Intersection, const std::string &filter="", const bool ignoreZeroTimers=false)
void setOption(const char option_true[], const char option_false[], bool *option_val, const char documentation[]=NULL)
#define TEUCHOS_STANDARD_CATCH_STATEMENTS(VERBOSE, ERR_STREAM, SUCCESS_FLAG)
void cusp_sa_block_cg(IndexType nx, IndexType ny, IndexType nz, IndexType nrhs, IndexType max_its, ValueType tol, bool verbose)
EParseCommandLineReturn parse(int argc, char *argv[], std::ostream *errout=&std::cerr) const
int main(int argc, char **argv)
const char * orient_names[]
void setDocString(const char doc_string[])
static void zeroOutTimers()