PARALUTION  1.0.0
PARALUTION
ampe_sira.hpp
Go to the documentation of this file.
1 // *************************************************************************
2 //
3 // This code is developed and maintained by NTU.
4 // The SIRA eigenvalue solver (files src/solvers/eigenvalue/amppe_sira.hpp
5 // src/solvers/eigenvalue/amppe_sira.cpp src/solvers/deflation/cg_hn.hpp
6 // src/solvers/deflation/cg_hn.cpp) are released under GNU LESSER GENERAL
7 // PUBLIC LICENSE (LGPL v3)
8 //
9 // Copyright (C) 2014 Weichung Wang (NTU)
10 // National Taiwan University, National Taiwan
11 //
12 // This program is free software: you can redistribute it and/or modify
13 // it under the terms of the GNU Lesser General Public License as
14 // published by the Free Software Foundation, either version 3 of the
15 // License, or (at your option) any later version.
16 //
17 // This program is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU General Public License for more details.
21 //
22 // You should have received a copy of the GNU Lesser General Public
23 // License along with this program.
24 // If not, see <http://www.gnu.org/licenses/>.
25 //
26 // *************************************************************************
27 
28 #ifndef PARALUTION_EIGENVALUE_AMPE_SIRA_HPP_
29 #define PARALUTION_EIGENVALUE_AMPE_SIRA_HPP_
30 
31 #include "cg_hn.hpp"
32 #include "../solver.hpp"
33 #include "../preconditioners/preconditioner_ai.hpp"
34 #include "../../base/local_matrix.hpp"
35 #include "../iter_ctrl.hpp"
36 
37 namespace paralution {
38 
39 template <class OperatorTypeH, class VectorTypeH, typename ValueTypeH,
40  class OperatorTypeL = LocalMatrix<double>, class VectorTypeL = LocalVector<double>, typename ValueTypeL = double>
41 class SIRA : public Solver <OperatorTypeH, VectorTypeH, ValueTypeH> {
42 
43 public:
44 
45  SIRA();
46  virtual ~SIRA();
47 
48  virtual void Print(void) const;
49  virtual void Build(void);
50  virtual void SetNumberOfEigenvalues(const int num);
51  virtual void Clear(void);
52 
59  virtual void Init(ValueTypeH abs_tol, int MaxOuterIter, int MaxInnerIter);
60 
64  virtual void SetInnerStoppingCriterion(const int n);
65 
69  ValueTypeH > &p);
70 
74  ValueTypeH > &p1,
77  ValueTypeL > &p2);
78 
80  virtual void SetInnerPreconditioner(int a);
81 
83  virtual void Solve(const VectorTypeH & vec_start, VectorTypeH *vec_ans);
84 
86  virtual void Solve(VectorTypeH *x);
87 
89  virtual int GetIterationCount(void);
90 
92  virtual double GetCurrentResidual(void);
93 
95  virtual int GetSolverStatus(void);
96 
98  void RecordResidualHistory(void);
99 
100  virtual void Verbose(const int verb=1);
101 protected:
102 
104  virtual void Inner();
105 
107  virtual void MvOrthogonalize(OperatorTypeH *mat, VectorTypeH *vec, const int dim);
108 
110  virtual void Locking();
111 
113  virtual void Restart();
114 
116  virtual void Givens(ValueTypeH &c, ValueTypeH &s, ValueTypeH &a, ValueTypeH &b);
117 
119  virtual void Eigpair(ValueTypeH &theta_k_);
120 
121  virtual void Init(const ValueTypeH abs_tol, const ValueTypeH rel_tol,
122  const ValueTypeH div_tol, const int max_iter);
123 
124  virtual void PrintStart_(void) const;
125  virtual void PrintEnd_(void) const;
126  virtual void MoveToHostLocalData_(void);
127  virtual void MoveToAcceleratorLocalData_(void);
128 
129  virtual void Build_(void);
130 
134  FSAI<LocalMatrix<ValueTypeH>, LocalVector<ValueTypeH>, ValueTypeH > *p_fsai_h_;
135  FSAI<LocalMatrix<ValueTypeL>, LocalVector<ValueTypeL>, ValueTypeL > *p_fsai_l_;
136 
141 
144 
145 
146 private:
147 
148  int dim_;
149  int nnz_;
151  int SubDim_;
160 
161  ValueTypeH target_;
162  ValueTypeH theta_k_;
163  ValueTypeH r_out_norm_;
164 
165  OperatorTypeH* op_h_;
166  OperatorTypeL* op_l_;
167  OperatorTypeH V_;
168  OperatorTypeH AV_;
169  OperatorTypeH VtAV_;
170  OperatorTypeH EigVecs_;
171 
172  VectorTypeH tmpUpdateVector_;
173  VectorTypeH s_out_;
174  VectorTypeH Au_;
175  VectorTypeH r_out_;
176  VectorTypeL r_out_single_;
177  VectorTypeH t_out_;
178  VectorTypeL t_out_single_;
179  VectorTypeH u_k_;
180  VectorTypeL u_k_single_;
181 
182 
183 };
184 
185 }
186 
187 #endif // PARALUTION_EIGENVALUE_AMPE_SIRA_HPP_
Factorized Approximate Inverse preconditioner.
Definition: preconditioner_ai.hpp:45
FSAI< LocalMatrix< ValueTypeL >, LocalVector< ValueTypeL >, ValueTypeL > * p_fsai_l_
Definition: ampe_sira.hpp:135
virtual void MvOrthogonalize(OperatorTypeH *mat, VectorTypeH *vec, const int dim)
Orthogonalize vector to a orthogonal matrix.
Definition: ampe_sira.cpp:917
virtual ~SIRA()
Definition: ampe_sira.cpp:160
VectorTypeH Au_
Definition: ampe_sira.hpp:174
OperatorTypeH EigVecs_
Definition: ampe_sira.hpp:170
virtual void SetInnerStoppingCriterion(const int n)
Set the stopping criteria of inner linear solver where 0: constant tolerance 1: H.N. stopping criteria.
int PrecondFlag_
Definition: ampe_sira.hpp:158
virtual void Print(void) const
Print information about the solver.
Definition: ampe_sira.cpp:171
virtual void MoveToAcceleratorLocalData_(void)
Move all local data to the accelerator.
Definition: ampe_sira.cpp:528
int SubDim_
Definition: ampe_sira.hpp:151
ValueTypeH theta_k_
Definition: ampe_sira.hpp:162
Preconditioner< LocalMatrix< ValueTypeH >, LocalVector< ValueTypeH >, ValueTypeH > * p_inner_h_
Preconditioner for inner linear solver.
Definition: ampe_sira.hpp:132
OperatorTypeH * op_h_
Definition: ampe_sira.hpp:165
VectorTypeH u_k_
Definition: ampe_sira.hpp:179
FSAI< LocalMatrix< ValueTypeH >, LocalVector< ValueTypeH >, ValueTypeH > * p_fsai_h_
Definition: ampe_sira.hpp:134
ValueTypeH target_
Definition: ampe_sira.hpp:161
virtual void Build_(void)
Iteration control for iterative solvers, monitor the residual (L2 norm) behavior. ...
Definition: iter_ctrl.hpp:11
virtual void Givens(ValueTypeH &c, ValueTypeH &s, ValueTypeH &a, ValueTypeH &b)
Givens rotation.
Definition: ampe_sira.cpp:1258
virtual void Locking()
Orthogonalize subspace to eigenspace.
Definition: ampe_sira.cpp:805
Preconditioner< LocalMatrix< ValueTypeL >, LocalVector< ValueTypeL >, ValueTypeL > * p_inner_l_
Definition: ampe_sira.hpp:133
int double_count_
Definition: ampe_sira.hpp:157
virtual int GetIterationCount(void)
Return the iteration count.
Definition: ampe_sira.cpp:1291
SIRA()
Definition: ampe_sira.cpp:49
int nnz_
Definition: ampe_sira.hpp:149
CG_HN< OperatorTypeL, VectorTypeL, ValueTypeL > * inner_cg_hn_l_
Definition: ampe_sira.hpp:140
virtual void Eigpair(ValueTypeH &theta_k_)
Solve the eigenpair of small dense matrix.
Definition: ampe_sira.cpp:1032
VectorTypeH s_out_
Definition: ampe_sira.hpp:173
OperatorTypeL * op_l_
Definition: ampe_sira.hpp:166
IterationControl iter_ctrl_
Iteration control (monitor)
Definition: ampe_sira.hpp:143
CG< OperatorTypeH, VectorTypeH, ValueTypeH > * inner_cg_h_
Inner linear solver.
Definition: ampe_sira.hpp:138
virtual void SetNumberOfEigenvalues(const int num)
Definition: ampe_sira.cpp:391
virtual void Clear(void)
Clear (free all local data) the solver.
void RecordResidualHistory(void)
Write the history to file.
Definition: ampe_sira.cpp:1279
CG_HN< OperatorTypeH, VectorTypeH, ValueTypeH > * inner_cg_hn_h_
Definition: ampe_sira.hpp:139
Base preconditioner class.
Definition: preconditioner.hpp:10
OperatorTypeH V_
Definition: ampe_sira.hpp:167
virtual void Init(ValueTypeH abs_tol, int MaxOuterIter, int MaxInnerIter)
Initialize the solver with abs_tol tolerance and number of maximum outer iteration. The maximum number of inner iteration would be default : MaxInnerIter = 0 dim*MaxInnerIter: 0 < MaxInnerIter <= 1 MaxInnerIter : 1 < MaxInnerIter.
Definition: ampe_sira.cpp:465
virtual void MoveToHostLocalData_(void)
Move all local data to the host.
Definition: ampe_sira.cpp:493
int solved_num_
Definition: ampe_sira.hpp:155
VectorTypeL t_out_single_
Definition: ampe_sira.hpp:178
int DoubleFlag_
Definition: ampe_sira.hpp:152
int target_num_
Definition: ampe_sira.hpp:154
Definition: backend_manager.cpp:43
int StoppingCriterionFlag_
Definition: ampe_sira.hpp:153
virtual void SetInnerPreconditioner(Preconditioner< LocalMatrix< ValueTypeH >, LocalVector< ValueTypeH >, ValueTypeH > &p)
Set the inner solver's preocnditioner.
Definition: ampe_sira.cpp:447
virtual void PrintEnd_(void) const
Print ending msg of the solver.
Definition: ampe_sira.cpp:191
VectorTypeH t_out_
Definition: ampe_sira.hpp:177
int dim_
Definition: ampe_sira.hpp:148
virtual void Build(void)
Build the solver (data allocation, structure computation, numerical computation)
Definition: ampe_sira.cpp:200
ValueTypeH r_out_norm_
Definition: ampe_sira.hpp:163
virtual void Restart()
Perform Subspace restrating.
Definition: ampe_sira.cpp:756
const IndexType const IndexType const IndexType const ValueType const ValueType const ValueType * x
Definition: cuda_kernels_coo.hpp:91
OperatorTypeH AV_
Definition: ampe_sira.hpp:168
virtual double GetCurrentResidual(void)
Return the current residual.
Definition: ampe_sira.cpp:1303
virtual int GetSolverStatus(void)
Return the current status.
Definition: ampe_sira.cpp:1315
Definition: ampe_sira.hpp:41
OperatorTypeH VtAV_
Definition: ampe_sira.hpp:169
VectorTypeL r_out_single_
Definition: ampe_sira.hpp:176
VectorTypeL u_k_single_
Definition: ampe_sira.hpp:180
int single_count_
Definition: ampe_sira.hpp:156
The base class for all solvers and preconditioners.
Definition: solver.hpp:12
virtual void PrintStart_(void) const
Print starting msg of the solver.
Definition: ampe_sira.cpp:180
b(1:n)
int MaxInnerIter_
Definition: ampe_sira.hpp:159
VectorTypeH tmpUpdateVector_
Definition: ampe_sira.hpp:172
int MaxSubDim_
Definition: ampe_sira.hpp:150
VectorTypeH r_out_
Definition: ampe_sira.hpp:175
virtual void Solve(const VectorTypeH &vec_start, VectorTypeH *vec_ans)
Solve the eigenvalue with initial vector vec_start.
Definition: ampe_sira.cpp:577
virtual void Verbose(const int verb=1)
Provide verbose output of the solver: verb == 0 no output verb == 1 print info about the solver (star...
Definition: ampe_sira.cpp:1327
virtual void Inner()
Solve the inner linear solver.