/[escript]/branches/diaplayground/ripley/src/RipleySystemMatrix.h
ViewVC logotype

Contents of /branches/diaplayground/ripley/src/RipleySystemMatrix.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5146 - (show annotations)
Thu Sep 11 06:29:28 2014 UTC (4 years, 9 months ago) by caltinay
File MIME type: text/plain
File size: 2598 byte(s)
Check for CUDA devices only once when target=GPU.

1
2 /*****************************************************************************
3 *
4 * Copyright (c) 2014 by University of Queensland
5 * http://www.uq.edu.au
6 *
7 * Primary Business: Queensland, Australia
8 * Licensed under the Open Software License version 3.0
9 * http://www.opensource.org/licenses/osl-3.0.php
10 *
11 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 * Development 2012-2013 by School of Earth Sciences
13 * Development from 2014 by Centre for Geoscience Computing (GeoComp)
14 *
15 *****************************************************************************/
16
17 #ifndef __RIPLEY_SYSTEMMATRIX_H__
18 #define __RIPLEY_SYSTEMMATRIX_H__
19
20 #include <escript/AbstractSystemMatrix.h>
21 #include <escript/FunctionSpace.h>
22
23 #include <ripley/Ripley.h>
24
25 namespace escript {
26 class SolverBuddy;
27 }
28
29 #include <cusp/cds_matrix.h>
30
31 namespace ripley {
32
33 typedef cusp::cds_matrix<int, double, cusp::host_memory> HostMatrixType;
34 typedef cusp::cds_matrix<int, double, cusp::device_memory> DeviceMatrixType;
35 typedef cusp::array1d<double, cusp::host_memory> HostVectorType;
36 typedef cusp::array1d<double, cusp::device_memory> DeviceVectorType;
37
38 class SystemMatrix : public escript::AbstractSystemMatrix
39 {
40 public:
41 SystemMatrix(esysUtils::JMPI mpiInfo, int blocksize,
42 const escript::FunctionSpace& fs, int nRows,
43 const IndexVector& diagonalOffsets);
44
45 virtual ~SystemMatrix() {}
46
47 virtual void nullifyRowsAndCols(escript::Data& row_q,
48 escript::Data& col_q,
49 double mdv);
50
51 virtual void saveMM(const std::string& filename) const;
52
53 virtual void saveHB(const std::string& filename) const;
54
55 virtual void resetValues();
56
57 void add(const IndexVector& rowIndex, const std::vector<double>& array);
58
59 inline int getBlockSize() const { return getRowBlockSize(); }
60
61 private:
62 template<class LinearOperator, class Vector, class Preconditioner>
63 void runSolver(LinearOperator& A, Vector& x, Vector& b, Preconditioner& M,
64 escript::SolverBuddy& sb) const;
65
66 virtual void setToSolution(escript::Data& out, escript::Data& in,
67 boost::python::object& options) const;
68
69 virtual void ypAx(escript::Data& y, escript::Data& x) const;
70
71 static void checkCUDA();
72
73 /// GPU device IDs supporting CUDA
74 static std::vector<int> cudaDevices;
75
76 esysUtils::JMPI m_mpiInfo;
77 HostMatrixType mat;
78 mutable DeviceMatrixType dmat;
79 mutable bool matrixAltered;
80 };
81
82 } // namespace ripley
83
84 #endif // __RIPLEY_SYSTEMMATRIX_H__
85

  ViewVC Help
Powered by ViewVC 1.1.26