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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5070 - (hide annotations)
Mon Jun 23 03:38:45 2014 UTC (4 years, 11 months ago) by caltinay
File MIME type: text/plain
File size: 3022 byte(s)
Use Jacobi preconditioner if requested and don't be verbose unless
set by user. Also, avoid copying matrix to device if unmodified.
Plus store list of available CUDA devices so a future option can set
which ones to use.

1 caltinay 4941
2     /*****************************************************************************
3     *
4     * Copyright (c) 2003-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 caltinay 5065 namespace cusp {
26     template <typename IndexType, typename ValueType, class MemorySpace> class dia_matrix;
27     }
28    
29     namespace escript {
30     class SolverBuddy;
31     }
32    
33     #ifdef USE_CUDA
34     #define THRUST_DEVICE_SYSTEM THRUST_DEVICE_SYSTEM_CUDA
35     #elif defined _OPENMP
36     #define THRUST_DEVICE_SYSTEM THRUST_DEVICE_SYSTEM_OMP
37     #else
38     #define THRUST_DEVICE_SYSTEM THRUST_DEVICE_SYSTEM_CPP
39     #endif
40    
41     #include <cusp/dia_matrix.h>
42    
43 caltinay 4941 namespace ripley {
44    
45 caltinay 5065 typedef cusp::dia_matrix<int, double, cusp::host_memory> HostMatrixType;
46     typedef cusp::dia_matrix<int, double, cusp::device_memory> DeviceMatrixType;
47     typedef cusp::array1d<double, cusp::host_memory> HostVectorType;
48     typedef cusp::array1d<double, cusp::device_memory> DeviceVectorType;
49    
50 caltinay 4941 class SystemMatrix : public escript::AbstractSystemMatrix
51     {
52     public:
53     SystemMatrix();
54    
55 caltinay 4944 SystemMatrix(int blocksize, const escript::FunctionSpace& fs,
56 caltinay 4941 int nRows, const IndexVector& diagonalOffsets);
57    
58     virtual ~SystemMatrix() {}
59    
60     virtual void nullifyRowsAndCols(escript::Data& row_q,
61     escript::Data& col_q,
62     double mdv);
63    
64     virtual void saveMM(const std::string& filename) const;
65    
66     virtual void saveHB(const std::string& filename) const;
67    
68     virtual void resetValues();
69    
70     void add(const IndexVector& rowIndex, const std::vector<double>& array);
71    
72     void matrixVector(const double* x, double beta, double* y) const;
73    
74 caltinay 4944 inline int getBlockSize() const { return getRowBlockSize(); }
75    
76 caltinay 4941 private:
77 caltinay 5070 template<class LinearOperator, class Vector, class Preconditioner>
78     void runSolver(LinearOperator& A, Vector& x, Vector& b, Preconditioner& M,
79 caltinay 5065 escript::SolverBuddy& sb) const;
80 caltinay 4941
81     virtual void setToSolution(escript::Data& out, escript::Data& in,
82     boost::python::object& options) const;
83    
84     virtual void ypAx(escript::Data& y, escript::Data& x) const;
85    
86 caltinay 5070 void checkCUDA();
87    
88     /// GPU device IDs supporting CUDA
89     static std::vector<int> cudaDevices;
90    
91 caltinay 5065 HostMatrixType mat;
92 caltinay 5070 mutable DeviceMatrixType dmat;
93     mutable bool matrixAltered;
94 caltinay 5065 //int numRows;
95     //std::vector<int> offsets;
96     //std::vector<double> values;
97 caltinay 4941 };
98    
99     } // namespace ripley
100    
101     #endif // __RIPLEY_SYSTEMMATRIX_H__
102    

  ViewVC Help
Powered by ViewVC 1.1.26