| 1619 |
slepc |
1 |
/*
|
| 2110 |
jroman |
2 |
Method: General Davidson Method (includes GD and JD)
|
| 1619 |
slepc |
3 |
|
|
|
4 |
References:
|
|
|
5 |
- Ernest R. Davidson. Super-matrix methods. Computer Physics Communications,
|
|
|
6 |
53:49–60, May 1989.
|
|
|
7 |
|
| 2110 |
jroman |
8 |
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
9 |
SLEPc - Scalable Library for Eigenvalue Problem Computations
|
| 2575 |
eromero |
10 |
Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain
|
| 1619 |
slepc |
11 |
|
| 2110 |
jroman |
12 |
This file is part of SLEPc.
|
|
|
13 |
|
|
|
14 |
SLEPc is free software: you can redistribute it and/or modify it under the
|
|
|
15 |
terms of version 3 of the GNU Lesser General Public License as published by
|
|
|
16 |
the Free Software Foundation.
|
| 1619 |
slepc |
17 |
|
| 2110 |
jroman |
18 |
SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
19 |
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
20 |
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
|
|
|
21 |
more details.
|
| 1619 |
slepc |
22 |
|
| 2110 |
jroman |
23 |
You should have received a copy of the GNU Lesser General Public License
|
|
|
24 |
along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
|
|
|
25 |
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
| 1619 |
slepc |
26 |
*/
|
|
|
27 |
|
|
|
28 |
|
|
|
29 |
/*
|
|
|
30 |
Dashboard struct: contains the methods that will be employed and the tunning
|
|
|
31 |
options.
|
|
|
32 |
*/
|
|
|
33 |
|
| 2283 |
jroman |
34 |
#include <private/epsimpl.h> /*I "slepceps.h" I*/
|
|
|
35 |
#include <private/stimpl.h> /*I "slepcst.h" I*/
|
|
|
36 |
#include <slepcblaslapack.h>
|
| 1619 |
slepc |
37 |
|
|
|
38 |
typedef struct _dvdFunctionList {
|
| 2021 |
eromero |
39 |
PetscErrorCode (*f)(void*);
|
| 1619 |
slepc |
40 |
void *d;
|
|
|
41 |
struct _dvdFunctionList *next;
|
|
|
42 |
} dvdFunctionList;
|
| 1735 |
eromero |
43 |
|
|
|
44 |
typedef PetscInt MatType_t;
|
|
|
45 |
#define DVD_MAT_HERMITIAN (1<<1)
|
|
|
46 |
#define DVD_MAT_NEG_DEF (1<<2)
|
|
|
47 |
#define DVD_MAT_POS_DEF (1<<3)
|
|
|
48 |
#define DVD_MAT_SINGULAR (1<<4)
|
|
|
49 |
#define DVD_MAT_COMPLEX (1<<5)
|
|
|
50 |
#define DVD_MAT_IMPLICIT (1<<6)
|
|
|
51 |
#define DVD_MAT_IDENTITY (1<<7)
|
|
|
52 |
#define DVD_MAT_DIAG (1<<8)
|
|
|
53 |
#define DVD_MAT_TRIANG (1<<9)
|
| 1747 |
eromero |
54 |
#define DVD_MAT_UTRIANG (1<<9)
|
|
|
55 |
#define DVD_MAT_LTRIANG (1<<10)
|
|
|
56 |
#define DVD_MAT_UNITARY (1<<11)
|
|
|
57 |
|
| 1756 |
eromero |
58 |
typedef PetscInt EPType_t;
|
| 1960 |
eromero |
59 |
#define DVD_EP_STD (1<<1)
|
| 1756 |
eromero |
60 |
#define DVD_EP_HERMITIAN (1<<2)
|
| 2779 |
eromero |
61 |
#define DVD_EP_INDEFINITE (1<<3)
|
| 1756 |
eromero |
62 |
|
|
|
63 |
#define DVD_IS(T,P) ((T) & (P))
|
|
|
64 |
#define DVD_ISNOT(T,P) (((T) & (P)) ^ (P))
|
|
|
65 |
|
| 1883 |
eromero |
66 |
typedef enum {
|
|
|
67 |
DVD_HARM_NONE,
|
|
|
68 |
DVD_HARM_RR,
|
|
|
69 |
DVD_HARM_RRR,
|
|
|
70 |
DVD_HARM_REIGS,
|
|
|
71 |
DVD_HARM_LEIGS
|
|
|
72 |
} HarmType_t;
|
| 1795 |
eromero |
73 |
|
| 1883 |
eromero |
74 |
typedef enum {
|
|
|
75 |
DVD_INITV_CLASSIC,
|
|
|
76 |
DVD_INITV_KRYLOV
|
|
|
77 |
} InitType_t;
|
| 1795 |
eromero |
78 |
|
| 1980 |
eromero |
79 |
typedef enum {
|
| 2605 |
eromero |
80 |
DVD_PROJ_KXX,
|
|
|
81 |
DVD_PROJ_KZX
|
| 1980 |
eromero |
82 |
} ProjType_t;
|
| 1883 |
eromero |
83 |
|
| 2012 |
eromero |
84 |
typedef enum {
|
| 2605 |
eromero |
85 |
DVD_ORTHOV_I, /* V is orthonormalized */
|
|
|
86 |
DVD_ORTHOV_B, /* V is B-orthonormalized */
|
|
|
87 |
DVD_ORTHOV_BOneMV /* V is B-orthonormalized using IPBOrthogonalize */
|
| 2012 |
eromero |
88 |
} orthoV_type_t;
|
|
|
89 |
|
| 2779 |
eromero |
90 |
typedef enum {
|
|
|
91 |
DVD_METH_GD,
|
|
|
92 |
DVD_METH_JD,
|
|
|
93 |
DVD_METH_GD2
|
|
|
94 |
} Method_t;
|
| 2012 |
eromero |
95 |
|
| 1619 |
slepc |
96 |
typedef struct _dvdDashboard {
|
|
|
97 |
/**** Function steps ****/
|
|
|
98 |
/* Initialize V */
|
| 2021 |
eromero |
99 |
PetscErrorCode (*initV)(struct _dvdDashboard*);
|
| 1619 |
slepc |
100 |
void *initV_data;
|
|
|
101 |
|
|
|
102 |
/* Find the approximate eigenpairs from V */
|
| 2021 |
eromero |
103 |
PetscErrorCode (*calcPairs)(struct _dvdDashboard*);
|
| 1619 |
slepc |
104 |
void *calcPairs_data;
|
|
|
105 |
|
| 2018 |
eromero |
106 |
/* Eigenpair test for convergence */
|
| 2216 |
jroman |
107 |
PetscBool (*testConv)(struct _dvdDashboard*, PetscScalar eigvr,
|
| 1960 |
eromero |
108 |
PetscScalar eigvi, PetscReal res, PetscReal *error);
|
| 1619 |
slepc |
109 |
void *testConv_data;
|
|
|
110 |
|
|
|
111 |
/* Number of converged eigenpairs */
|
|
|
112 |
PetscInt nconv;
|
|
|
113 |
|
| 1735 |
eromero |
114 |
/* Number of pairs ready to converge */
|
|
|
115 |
PetscInt npreconv;
|
|
|
116 |
|
| 1619 |
slepc |
117 |
/* Improve the selected eigenpairs */
|
| 2021 |
eromero |
118 |
PetscErrorCode (*improveX)(struct _dvdDashboard*, Vec *D, PetscInt max_size_D,
|
| 1735 |
eromero |
119 |
PetscInt r_s, PetscInt r_e, PetscInt *size_D);
|
| 1619 |
slepc |
120 |
void *improveX_data;
|
|
|
121 |
|
|
|
122 |
/* Check for restarting */
|
| 2216 |
jroman |
123 |
PetscBool (*isRestarting)(struct _dvdDashboard*);
|
| 1619 |
slepc |
124 |
void *isRestarting_data;
|
|
|
125 |
|
|
|
126 |
/* Perform restarting */
|
| 2021 |
eromero |
127 |
PetscErrorCode (*restartV)(struct _dvdDashboard*);
|
| 1619 |
slepc |
128 |
void *restartV_data;
|
|
|
129 |
|
|
|
130 |
/* Update V */
|
| 2021 |
eromero |
131 |
PetscErrorCode (*updateV)(struct _dvdDashboard*);
|
| 1619 |
slepc |
132 |
void *updateV_data;
|
|
|
133 |
|
|
|
134 |
/**** Problem specification ****/
|
|
|
135 |
Mat A, B; /* Problem matrices */
|
| 1747 |
eromero |
136 |
MatType_t sA, sB; /* Matrix specifications */
|
| 1756 |
eromero |
137 |
EPType_t sEP; /* Problem specifications */
|
| 1619 |
slepc |
138 |
PetscInt nev; /* number of eigenpairs */
|
|
|
139 |
EPSWhich which; /* spectrum selection */
|
| 2216 |
jroman |
140 |
PetscBool
|
| 1619 |
slepc |
141 |
withTarget; /* if there is a target */
|
|
|
142 |
PetscScalar
|
| 1883 |
eromero |
143 |
target[2]; /* target value */
|
| 1619 |
slepc |
144 |
PetscReal tol; /* tolerance */
|
| 2216 |
jroman |
145 |
PetscBool
|
| 2605 |
eromero |
146 |
correctXnorm; /* if true, norm of X are computed */
|
| 1619 |
slepc |
147 |
|
|
|
148 |
/**** Subspaces specification ****/
|
|
|
149 |
Vec *V, /* searching subspace */
|
| 2605 |
eromero |
150 |
*real_V, /* original V */
|
| 1795 |
eromero |
151 |
*W, /* testing subspace */
|
| 2605 |
eromero |
152 |
*real_W, /* original W */
|
| 1751 |
eromero |
153 |
*cX, /* converged right eigenvectors */
|
|
|
154 |
*cY, /* converged left eigenvectors */
|
| 1829 |
eromero |
155 |
*BcX, /* basis of B*cX */
|
| 1735 |
eromero |
156 |
*AV, /* A*V */
|
|
|
157 |
*real_AV, /* original A*V space */
|
|
|
158 |
*BV, /* B*V */
|
| 2555 |
eromero |
159 |
*real_BV, /* original B*V space */
|
|
|
160 |
*BDS; /* B * eps->DV */
|
| 1619 |
slepc |
161 |
PetscInt size_V, /* size of V */
|
| 2605 |
eromero |
162 |
size_real_V, /* original size of V */
|
|
|
163 |
size_W, /* size of W */
|
|
|
164 |
size_real_W, /* original size of W */
|
| 1735 |
eromero |
165 |
size_AV, /* size of AV */
|
| 2605 |
eromero |
166 |
size_real_AV, /* original size of AV */
|
| 1735 |
eromero |
167 |
size_BV, /* size of BV */
|
| 2605 |
eromero |
168 |
size_BDS, /* size of BDS */
|
|
|
169 |
size_real_BV, /* original size of BV */
|
| 1619 |
slepc |
170 |
size_cX, /* size of cX */
|
| 1751 |
eromero |
171 |
size_cY, /* size of cY */
|
| 1735 |
eromero |
172 |
size_D, /* active vectors */
|
| 2605 |
eromero |
173 |
size_BcX, /* size of BcX */
|
|
|
174 |
size_real_eigr, /* size of original eigr, eigi, nR, errest */
|
| 1619 |
slepc |
175 |
max_size_V, /* max size of V */
|
| 2605 |
eromero |
176 |
max_size_W, /* max size of W */
|
|
|
177 |
max_size_X, /* max new vectors in V */
|
| 1735 |
eromero |
178 |
max_size_AV, /* max size of AV */
|
| 2555 |
eromero |
179 |
max_size_BV, /* max size of BV */
|
| 2605 |
eromero |
180 |
max_size_proj, /* max size projected problem */
|
| 2624 |
eromero |
181 |
max_cX_in_proj, /* max vectors from cX in the projected problem */
|
|
|
182 |
max_cX_in_impr, /* max vectros from cX in the projector */
|
| 2605 |
eromero |
183 |
max_size_P, /* max unconverged vectors in the projector */
|
|
|
184 |
bs; /* max vectors that expands the subspace every iteration */
|
| 1805 |
eromero |
185 |
EPS eps; /* Connection to SLEPc */
|
| 1619 |
slepc |
186 |
|
|
|
187 |
/**** Auxiliary space ****/
|
|
|
188 |
Vec *auxV; /* auxiliary vectors */
|
|
|
189 |
PetscScalar
|
|
|
190 |
*auxS; /* auxiliary scalars */
|
|
|
191 |
PetscInt
|
|
|
192 |
size_auxV, /* max size of auxV */
|
|
|
193 |
size_auxS; /* max size of auxS */
|
|
|
194 |
|
|
|
195 |
/**** Eigenvalues and errors ****/
|
|
|
196 |
PetscScalar
|
|
|
197 |
*ceigr, *ceigi, /* converged eigenvalues */
|
| 2605 |
eromero |
198 |
*eigr, *eigi, /* current eigenvalues */
|
|
|
199 |
*real_eigr,
|
|
|
200 |
*real_eigi; /* original eigr and eigi */
|
| 1619 |
slepc |
201 |
PetscReal
|
| 1735 |
eromero |
202 |
*nR, /* residual norm */
|
| 2605 |
eromero |
203 |
*real_nR, /* original nR */
|
| 1764 |
eromero |
204 |
*nX, /* X norm */
|
| 2605 |
eromero |
205 |
*real_nX, /* original nX */
|
|
|
206 |
*errest, /* relative error eigenpairs */
|
| 2779 |
eromero |
207 |
*real_errest, /* original errest */
|
|
|
208 |
*nBDS, /* B-norms of DS */
|
|
|
209 |
*nBV, /* B-norms of V */
|
|
|
210 |
*nBcX, /* B-norms of cX */
|
|
|
211 |
*nBpX, /* B-norms of pX */
|
|
|
212 |
*real_nBV; /* original nBDS, nBV and nBcX */
|
| 1619 |
slepc |
213 |
|
|
|
214 |
/**** Shared function and variables ****/
|
| 2021 |
eromero |
215 |
PetscErrorCode (*e_Vchanged)(struct _dvdDashboard*, PetscInt s_imm,
|
| 1619 |
slepc |
216 |
PetscInt e_imm, PetscInt s_new, PetscInt e_new);
|
|
|
217 |
void *e_Vchanged_data;
|
|
|
218 |
|
| 2021 |
eromero |
219 |
PetscErrorCode (*calcpairs_residual)(struct _dvdDashboard*, PetscInt s, PetscInt e,
|
| 2605 |
eromero |
220 |
Vec *R);
|
| 2682 |
jroman |
221 |
PetscErrorCode (*calcpairs_residual_eig)(struct _dvdDashboard*, PetscInt s, PetscInt e,
|
|
|
222 |
Vec *R);
|
| 2021 |
eromero |
223 |
PetscErrorCode (*calcpairs_selectPairs)(struct _dvdDashboard*, PetscInt n);
|
| 1736 |
eromero |
224 |
void *calcpairs_residual_data;
|
|
|
225 |
PetscErrorCode (*improvex_precond)(struct _dvdDashboard*, PetscInt i, Vec x,
|
|
|
226 |
Vec Px);
|
|
|
227 |
void *improvex_precond_data;
|
| 1960 |
eromero |
228 |
PetscErrorCode (*improvex_jd_proj_uv)(struct _dvdDashboard*, PetscInt i_s,
|
| 2605 |
eromero |
229 |
PetscInt i_e, Vec *u, Vec *v,
|
|
|
230 |
Vec *kr, Vec *auxV,
|
| 1965 |
eromero |
231 |
PetscScalar *theta,
|
|
|
232 |
PetscScalar *thetai,
|
|
|
233 |
PetscScalar *pX, PetscScalar *pY,
|
|
|
234 |
PetscInt ld);
|
| 1867 |
eromero |
235 |
PetscErrorCode (*improvex_jd_lit)(struct _dvdDashboard*, PetscInt i,
|
| 1960 |
eromero |
236 |
PetscScalar* theta, PetscScalar* thetai,
|
|
|
237 |
PetscInt *maxits, PetscReal *tol);
|
| 1795 |
eromero |
238 |
PetscErrorCode (*calcpairs_W)(struct _dvdDashboard*);
|
|
|
239 |
void *calcpairs_W_data;
|
|
|
240 |
PetscErrorCode (*calcpairs_proj_trans)(struct _dvdDashboard*);
|
| 1883 |
eromero |
241 |
PetscErrorCode (*calcpairs_eigs_trans)(struct _dvdDashboard*);
|
|
|
242 |
PetscErrorCode (*calcpairs_proj_res)(struct _dvdDashboard*, PetscInt r_s,
|
|
|
243 |
PetscInt r_e, Vec *R);
|
| 2018 |
eromero |
244 |
PetscErrorCode (*preTestConv)(struct _dvdDashboard*, PetscInt s, PetscInt pre,
|
|
|
245 |
PetscInt e, Vec *auxV, PetscScalar *auxS,
|
|
|
246 |
PetscInt *nConv);
|
| 1619 |
slepc |
247 |
|
| 2021 |
eromero |
248 |
PetscErrorCode (*e_newIteration)(struct _dvdDashboard*);
|
| 1619 |
slepc |
249 |
void *e_newIteration_data;
|
|
|
250 |
|
| 1751 |
eromero |
251 |
IP ipI;
|
| 1795 |
eromero |
252 |
IP ipV, /* orthogonal routine options for V subspace */
|
|
|
253 |
ipW; /* orthogonal routine options for W subspace */
|
| 1751 |
eromero |
254 |
|
| 1619 |
slepc |
255 |
dvdFunctionList
|
| 1883 |
eromero |
256 |
*startList, /* starting list */
|
|
|
257 |
*endList, /* ending list */
|
| 1619 |
slepc |
258 |
*destroyList; /* destructor list */
|
|
|
259 |
|
| 1735 |
eromero |
260 |
PetscScalar *H, /* Projected problem matrix A*/
|
|
|
261 |
*real_H, /* original H */
|
|
|
262 |
*G, /* Projected problem matrix B*/
|
|
|
263 |
*real_G, /* original G */
|
| 1750 |
eromero |
264 |
*pX, /* projected problem right eigenvectors */
|
|
|
265 |
*pY, /* projected problem left eigenvectors */
|
| 1795 |
eromero |
266 |
*MTX, /* right transformation matrix */
|
|
|
267 |
*MTY, /* left transformation matrix */
|
| 1750 |
eromero |
268 |
*S, /* first Schur matrix, S = pY'*H*pX */
|
| 1756 |
eromero |
269 |
*T, /* second Schur matrix, T = pY'*G*pX */
|
|
|
270 |
*cS, /* first Schur matrix of converged pairs */
|
|
|
271 |
*cT; /* second Schur matrix of converged pairs */
|
| 1750 |
eromero |
272 |
MatType_t
|
| 1747 |
eromero |
273 |
sH, /* H properties */
|
|
|
274 |
sG; /* G properties */
|
| 1735 |
eromero |
275 |
PetscInt ldH, /* leading dimension of H */
|
| 1750 |
eromero |
276 |
ldpX, /* leading dimension of pX */
|
|
|
277 |
ldpY, /* leading dimension of pY */
|
| 1795 |
eromero |
278 |
ldMTX, /* leading dimension of MTX */
|
|
|
279 |
ldMTY, /* leading dimension of MTY */
|
| 1750 |
eromero |
280 |
ldS, /* leading dimension of S */
|
|
|
281 |
ldT, /* leading dimension of T */
|
| 1756 |
eromero |
282 |
ldcS, /* leading dimension of cS */
|
|
|
283 |
ldcT, /* leading dimension of cT */
|
| 1742 |
eromero |
284 |
size_H, /* rows and columns in H */
|
|
|
285 |
size_G, /* rows and columns in G */
|
| 2244 |
eromero |
286 |
size_MT, /* rows in MT */
|
| 2605 |
eromero |
287 |
size_cS, /* dimension of cS */
|
|
|
288 |
size_cT, /* dimension of cT */
|
|
|
289 |
max_size_cS, /* max size of cS and cT */
|
|
|
290 |
cX_in_V, /* number of converged vectors in V */
|
|
|
291 |
cX_in_W, /* number of converged vectors in W */
|
|
|
292 |
cX_in_AV, /* number of converged vectors in AV */
|
|
|
293 |
cX_in_BV, /* number of converged vectors in BV */
|
|
|
294 |
cX_in_H, /* number of converged vectors in H */
|
| 2624 |
eromero |
295 |
cX_in_G; /* number of converged vectors in G */
|
| 1619 |
slepc |
296 |
|
| 2605 |
eromero |
297 |
PetscInt
|
| 1735 |
eromero |
298 |
V_tra_s,
|
| 2605 |
eromero |
299 |
V_tra_e, /* cX <- [cX V*MT(0:V_tra_s-1)], V <- V*MT(V_tra_s:V_tra_e) */
|
| 1735 |
eromero |
300 |
V_new_s,
|
|
|
301 |
V_new_e; /* added to V the columns V_new_s:V_new_e */
|
| 2555 |
eromero |
302 |
PetscBool
|
| 2605 |
eromero |
303 |
BV_shift, /* if true BV is shifted when vectors converge */
|
|
|
304 |
W_shift; /* if true W is shifted when vectors converge */
|
| 2555 |
eromero |
305 |
|
| 2012 |
eromero |
306 |
orthoV_type_t orthoV_type;
|
|
|
307 |
|
| 1992 |
eromero |
308 |
void* prof_data; /* profiler data */
|
| 1619 |
slepc |
309 |
} dvdDashboard;
|
|
|
310 |
|
| 2244 |
eromero |
311 |
/* Add the function fun at the beginning of list */
|
|
|
312 |
#define DVD_FL_ADD_BEGIN(list, fun) { \
|
| 1619 |
slepc |
313 |
dvdFunctionList *fl=(list); \
|
|
|
314 |
PetscErrorCode ierr; \
|
|
|
315 |
ierr = PetscMalloc(sizeof(dvdFunctionList), &(list)); CHKERRQ(ierr); \
|
| 2021 |
eromero |
316 |
(list)->f = (PetscErrorCode(*)(void*))(fun); \
|
| 1619 |
slepc |
317 |
(list)->next = fl; }
|
|
|
318 |
|
| 2244 |
eromero |
319 |
/* Add the function fun at the end of list */
|
|
|
320 |
#define DVD_FL_ADD_END(list, fun) { \
|
|
|
321 |
if ((list)) {DVD_FL_ADD_END0(list, fun);} \
|
|
|
322 |
else {DVD_FL_ADD_BEGIN(list, fun);} }
|
|
|
323 |
|
|
|
324 |
#define DVD_FL_ADD_END0(list, fun) { \
|
|
|
325 |
dvdFunctionList *fl=(list); \
|
|
|
326 |
PetscErrorCode ierr; \
|
|
|
327 |
for(;fl->next; fl = fl->next); \
|
|
|
328 |
ierr = PetscMalloc(sizeof(dvdFunctionList), &fl->next); CHKERRQ(ierr); \
|
|
|
329 |
fl->next->f = (PetscErrorCode(*)(void*))(fun); \
|
|
|
330 |
fl->next->next = PETSC_NULL; }
|
|
|
331 |
|
|
|
332 |
#define DVD_FL_ADD(list, fun) DVD_FL_ADD_END(list, fun)
|
|
|
333 |
|
| 1883 |
eromero |
334 |
#define DVD_FL_CALL(list, arg0) { \
|
| 1619 |
slepc |
335 |
dvdFunctionList *fl; \
|
| 2422 |
eromero |
336 |
for(fl=(list); fl; fl=fl->next) \
|
|
|
337 |
if(*(dvdCallback)fl->f) (*(dvdCallback)fl->f)((arg0)); }
|
| 1619 |
slepc |
338 |
|
|
|
339 |
#define DVD_FL_DEL(list) { \
|
|
|
340 |
dvdFunctionList *fl=(list), *oldfl; \
|
|
|
341 |
PetscErrorCode ierr; \
|
|
|
342 |
while(fl) { \
|
| 2422 |
eromero |
343 |
oldfl = fl; fl = fl->next; ierr = PetscFree(oldfl); CHKERRQ(ierr); } \
|
|
|
344 |
(list) = PETSC_NULL;}
|
| 1619 |
slepc |
345 |
|
|
|
346 |
/*
|
|
|
347 |
The blackboard configuration structure: saves information about the memory
|
| 2605 |
eromero |
348 |
and other requirements.
|
|
|
349 |
|
|
|
350 |
The starting memory structure:
|
|
|
351 |
|
|
|
352 |
V W? AV BV? tKZ
|
|
|
353 |
|-----------|-----------|-----------|------------|-------|
|
|
|
354 |
nev+mpd nev+mpd scP+mpd nev?+mpd sP+scP
|
|
|
355 |
scP+mpd scP+mpd
|
|
|
356 |
|
|
|
357 |
The final memory structure considering W_shift and BV_shift:
|
|
|
358 |
|
|
|
359 |
cX V cY? W? cAV AV BcX? BV? KZ tKZ
|
|
|
360 |
|---|-------|----|------|---|-------|----|-------|---|---|
|
|
|
361 |
nev mpd nev mpd scP mpd nev mpd scP sP <- shift
|
|
|
362 |
scP scP <- !shift
|
| 1619 |
slepc |
363 |
*/
|
|
|
364 |
typedef struct {
|
| 2605 |
eromero |
365 |
PetscInt max_size_V, /* max size of the searching subspace (mpd) */
|
|
|
366 |
max_size_X, /* max size of X (bs) */
|
|
|
367 |
size_V, /* real size of V (nev+size_P+mpd) */
|
| 1619 |
slepc |
368 |
max_size_oldX, /* max size of oldX */
|
|
|
369 |
max_size_auxV, /* max size of auxiliary vecs */
|
|
|
370 |
max_size_auxS, /* max size of auxiliary scalars */
|
| 1966 |
eromero |
371 |
max_nev, /* max number of converged pairs */
|
| 2605 |
eromero |
372 |
max_size_P, /* number of computed vectors for the projector */
|
|
|
373 |
max_size_cP, /* number of converged vectors in the projectors */
|
|
|
374 |
max_size_proj, /* max size projected problem */
|
| 2682 |
jroman |
375 |
max_size_cX_proj, /* max converged vectors in the projected problem */
|
| 1619 |
slepc |
376 |
own_vecs, /* number of global vecs */
|
|
|
377 |
own_scalars; /* number of local scalars */
|
|
|
378 |
Vec *free_vecs; /* free global vectors */
|
|
|
379 |
PetscScalar
|
|
|
380 |
*free_scalars; /* free scalars */
|
| 1734 |
eromero |
381 |
PetscInt state; /* method states:
|
| 1619 |
slepc |
382 |
0: preconfiguring
|
|
|
383 |
1: configuring
|
|
|
384 |
2: running
|
|
|
385 |
*/
|
|
|
386 |
} dvdBlackboard;
|
|
|
387 |
|
| 1734 |
eromero |
388 |
#define DVD_STATE_PRECONF 0
|
|
|
389 |
#define DVD_STATE_CONF 1
|
|
|
390 |
#define DVD_STATE_RUN 2
|
| 1619 |
slepc |
391 |
|
|
|
392 |
/* Shared types */
|
| 1736 |
eromero |
393 |
typedef PetscErrorCode (*dvdPrecond)(dvdDashboard*, PetscInt i, Vec x, Vec Px);
|
| 2021 |
eromero |
394 |
typedef PetscErrorCode (*dvdCallback)(dvdDashboard*);
|
|
|
395 |
typedef PetscErrorCode (*e_Vchanged_type)(dvdDashboard*, PetscInt s_imm,
|
| 1619 |
slepc |
396 |
PetscInt e_imm, PetscInt s_new, PetscInt e_new);
|
| 2216 |
jroman |
397 |
typedef PetscBool (*isRestarting_type)(dvdDashboard*);
|
| 2021 |
eromero |
398 |
typedef PetscErrorCode (*e_newIteration_type)(dvdDashboard*);
|
|
|
399 |
typedef PetscErrorCode (*improveX_type)(dvdDashboard*, Vec *D, PetscInt max_size_D,
|
| 1735 |
eromero |
400 |
PetscInt r_s, PetscInt r_e, PetscInt *size_D);
|
| 1619 |
slepc |
401 |
|
| 1753 |
eromero |
402 |
/* Structures for blas */
|
|
|
403 |
typedef PetscErrorCode (*DvdReductionPostF)(PetscScalar*,PetscInt,void*);
|
|
|
404 |
typedef struct {
|
|
|
405 |
PetscScalar
|
|
|
406 |
*out; /* final vector */
|
|
|
407 |
PetscInt
|
|
|
408 |
size_out; /* size of out */
|
|
|
409 |
DvdReductionPostF
|
|
|
410 |
f; /* function called after the reduction */
|
|
|
411 |
void *ptr;
|
|
|
412 |
} DvdReductionChunk;
|
|
|
413 |
|
|
|
414 |
typedef struct {
|
|
|
415 |
PetscScalar
|
|
|
416 |
*in, /* vector to sum-up with more nodes */
|
|
|
417 |
*out; /* final vector */
|
|
|
418 |
PetscInt size_in, /* size of in */
|
|
|
419 |
max_size_in; /* max size of in */
|
|
|
420 |
DvdReductionChunk
|
|
|
421 |
*ops; /* vector of reduction operations */
|
|
|
422 |
PetscInt
|
|
|
423 |
size_ops, /* size of ops */
|
|
|
424 |
max_size_ops; /* max size of ops */
|
|
|
425 |
MPI_Comm comm; /* MPI communicator */
|
|
|
426 |
} DvdReduction;
|
|
|
427 |
|
|
|
428 |
typedef struct {
|
|
|
429 |
PetscInt i0, i1, i2, ld, s0, e0, s1, e1;
|
|
|
430 |
PetscScalar *M;
|
|
|
431 |
} DvdMult_copy_func;
|
|
|
432 |
|
| 1619 |
slepc |
433 |
/* Routines for initV step */
|
| 2440 |
eromero |
434 |
PetscErrorCode dvd_initV(dvdDashboard *d, dvdBlackboard *b, PetscInt k,
|
| 2441 |
eromero |
435 |
PetscInt user, PetscBool krylov);
|
| 1619 |
slepc |
436 |
|
|
|
437 |
/* Routines for calcPairs step */
|
| 2605 |
eromero |
438 |
PetscErrorCode dvd_calcpairs_qz(dvdDashboard *d, dvdBlackboard *b,
|
|
|
439 |
orthoV_type_t orth, IP ipI,
|
|
|
440 |
PetscInt cX_proj, PetscBool harm);
|
| 1619 |
slepc |
441 |
|
|
|
442 |
/* Routines for improveX step */
|
| 2021 |
eromero |
443 |
PetscErrorCode dvd_improvex_jd(dvdDashboard *d, dvdBlackboard *b, KSP ksp,
|
| 2608 |
eromero |
444 |
PetscInt max_bs, PetscInt cX_impr, PetscBool dynamic);
|
| 2021 |
eromero |
445 |
PetscErrorCode dvd_improvex_jd_proj_uv(dvdDashboard *d, dvdBlackboard *b,
|
| 1980 |
eromero |
446 |
ProjType_t p);
|
| 2021 |
eromero |
447 |
PetscErrorCode dvd_improvex_jd_lit_const(dvdDashboard *d, dvdBlackboard *b,
|
| 1883 |
eromero |
448 |
PetscInt maxits, PetscReal tol,
|
|
|
449 |
PetscReal fix);
|
| 2779 |
eromero |
450 |
PetscErrorCode dvd_improvex_gd2(dvdDashboard *d,dvdBlackboard *b,KSP ksp,PetscInt max_bs);
|
|
|
451 |
PetscErrorCode dvd_improvex_get_eigenvectors(dvdDashboard *d, PetscScalar *pX,
|
|
|
452 |
PetscScalar *pY, PetscInt ld, PetscScalar *auxS, PetscInt size_auxS);
|
| 1619 |
slepc |
453 |
|
|
|
454 |
/* Routines for testConv step */
|
| 2021 |
eromero |
455 |
PetscErrorCode dvd_testconv_basic(dvdDashboard *d, dvdBlackboard *b);
|
|
|
456 |
PetscErrorCode dvd_testconv_slepc(dvdDashboard *d, dvdBlackboard *b);
|
| 1619 |
slepc |
457 |
|
|
|
458 |
/* Routines for management of V */
|
| 2021 |
eromero |
459 |
PetscErrorCode dvd_managementV_basic(dvdDashboard *d, dvdBlackboard *b,
|
| 2605 |
eromero |
460 |
PetscInt bs, PetscInt mpd,
|
|
|
461 |
PetscInt min_size_V,
|
| 2216 |
jroman |
462 |
PetscInt plusk, PetscBool harm,
|
|
|
463 |
PetscBool allResiduals);
|
| 1619 |
slepc |
464 |
|
|
|
465 |
/* Some utilities */
|
| 1764 |
eromero |
466 |
PetscErrorCode dvd_static_precond_PC(dvdDashboard *d, dvdBlackboard *b, PC pc);
|
| 1736 |
eromero |
467 |
PetscErrorCode dvd_jacobi_precond(dvdDashboard *d, dvdBlackboard *b);
|
| 1992 |
eromero |
468 |
PetscErrorCode dvd_profiler(dvdDashboard *d, dvdBlackboard *b);
|
|
|
469 |
PetscErrorCode dvd_prof_init();
|
| 1795 |
eromero |
470 |
PetscErrorCode dvd_harm_conf(dvdDashboard *d, dvdBlackboard *b,
|
| 2216 |
jroman |
471 |
HarmType_t mode, PetscBool fixedTarget,
|
| 1795 |
eromero |
472 |
PetscScalar t);
|
| 1619 |
slepc |
473 |
|
|
|
474 |
/* Methods */
|
|
|
475 |
PetscErrorCode dvd_schm_basic_preconf(dvdDashboard *d, dvdBlackboard *b,
|
| 2605 |
eromero |
476 |
PetscInt mpd, PetscInt min_size_V, PetscInt bs,
|
| 2244 |
eromero |
477 |
PetscInt ini_size_V, PetscInt size_initV, PetscInt plusk,
|
| 2605 |
eromero |
478 |
HarmType_t harmMode, KSP ksp, InitType_t init, PetscBool allResiduals,
|
| 2779 |
eromero |
479 |
orthoV_type_t orth, PetscInt cX_proj, PetscInt cX_impr, Method_t method);
|
| 1619 |
slepc |
480 |
PetscErrorCode dvd_schm_basic_conf(dvdDashboard *d, dvdBlackboard *b,
|
| 2605 |
eromero |
481 |
PetscInt mpd, PetscInt min_size_V, PetscInt bs,
|
| 2244 |
eromero |
482 |
PetscInt ini_size_V, PetscInt size_initV, PetscInt plusk,
|
| 2216 |
jroman |
483 |
IP ip, HarmType_t harmMode, PetscBool fixedTarget, PetscScalar t, KSP ksp,
|
| 2605 |
eromero |
484 |
PetscReal fix, InitType_t init, PetscBool allResiduals, orthoV_type_t orth,
|
| 2779 |
eromero |
485 |
PetscInt cX_proj, PetscInt cX_impr, PetscBool dynamic, Method_t method);
|
| 1619 |
slepc |
486 |
|
|
|
487 |
/* BLAS routines */
|
|
|
488 |
PetscErrorCode SlepcDenseMatProd(PetscScalar *C, PetscInt _ldC, PetscScalar b,
|
|
|
489 |
PetscScalar a,
|
| 2216 |
jroman |
490 |
const PetscScalar *A, PetscInt _ldA, PetscInt rA, PetscInt cA, PetscBool At,
|
|
|
491 |
const PetscScalar *B, PetscInt _ldB, PetscInt rB, PetscInt cB, PetscBool Bt);
|
| 1747 |
eromero |
492 |
PetscErrorCode SlepcDenseMatProdTriang(
|
|
|
493 |
PetscScalar *C, MatType_t sC, PetscInt ldC,
|
|
|
494 |
const PetscScalar *A, MatType_t sA, PetscInt ldA, PetscInt rA, PetscInt cA,
|
| 2216 |
jroman |
495 |
PetscBool At,
|
| 1747 |
eromero |
496 |
const PetscScalar *B, MatType_t sB, PetscInt ldB, PetscInt rB, PetscInt cB,
|
| 2216 |
jroman |
497 |
PetscBool Bt);
|
| 1750 |
eromero |
498 |
PetscErrorCode SlepcDenseNorm(PetscScalar *A, PetscInt ldA, PetscInt _rA,
|
| 1965 |
eromero |
499 |
PetscInt cA, PetscScalar *eigi);
|
| 1742 |
eromero |
500 |
PetscErrorCode SlepcDenseOrth(PetscScalar *A, PetscInt _ldA, PetscInt _rA,
|
|
|
501 |
PetscInt _cA, PetscScalar *auxS, PetscInt _lauxS,
|
|
|
502 |
PetscInt *ncA);
|
| 2779 |
eromero |
503 |
PetscErrorCode SlepcDenseIOrth(PetscScalar *A,PetscInt ldA,PetscInt rA,PetscInt cA,PetscReal *l0,PetscReal *l,PetscScalar *auxS, PetscInt lauxS);
|
| 1742 |
eromero |
504 |
PetscErrorCode SlepcDenseCopy(PetscScalar *Y, PetscInt ldY, PetscScalar *X,
|
|
|
505 |
PetscInt ldX, PetscInt rX, PetscInt cX);
|
| 1752 |
eromero |
506 |
PetscErrorCode SlepcDenseCopyTriang(PetscScalar *Y, MatType_t sY, PetscInt ldY,
|
|
|
507 |
PetscScalar *X, MatType_t sX, PetscInt ldX,
|
|
|
508 |
PetscInt rX, PetscInt cX);
|
| 1675 |
slepc |
509 |
PetscErrorCode SlepcUpdateVectorsZ(Vec *Y, PetscScalar beta, PetscScalar alpha,
|
|
|
510 |
Vec *X, PetscInt cX, const PetscScalar *M, PetscInt ldM, PetscInt rM,
|
|
|
511 |
PetscInt cM);
|
| 1960 |
eromero |
512 |
PetscErrorCode SlepcUpdateVectorsS(Vec *Y, PetscInt dY, PetscScalar beta,
|
|
|
513 |
PetscScalar alpha, Vec *X, PetscInt cX, PetscInt dX, const PetscScalar *M,
|
|
|
514 |
PetscInt ldM, PetscInt rM, PetscInt cM);
|
| 1965 |
eromero |
515 |
PetscErrorCode SlepcUpdateVectorsD(Vec *X, PetscInt cX, PetscScalar alpha,
|
|
|
516 |
const PetscScalar *M, PetscInt ldM, PetscInt rM, PetscInt cM,
|
|
|
517 |
PetscScalar *work, PetscInt lwork);
|
| 1747 |
eromero |
518 |
PetscErrorCode VecsMult(PetscScalar *M, MatType_t sM, PetscInt ldM,
|
| 1634 |
slepc |
519 |
Vec *U, PetscInt sU, PetscInt eU,
|
|
|
520 |
Vec *V, PetscInt sV, PetscInt eV,
|
| 1640 |
slepc |
521 |
PetscScalar *workS0, PetscScalar *workS1);
|
| 1753 |
eromero |
522 |
PetscErrorCode VecsMultS(PetscScalar *M, MatType_t sM, PetscInt ldM,
|
|
|
523 |
Vec *U, PetscInt sU, PetscInt eU,
|
|
|
524 |
Vec *V, PetscInt sV, PetscInt eV, DvdReduction *r,
|
|
|
525 |
DvdMult_copy_func *sr);
|
| 1795 |
eromero |
526 |
PetscErrorCode VecsMultIb(PetscScalar *M, MatType_t sM, PetscInt ldM,
|
|
|
527 |
PetscInt rM, PetscInt cM, PetscScalar *auxS,
|
|
|
528 |
Vec V);
|
|
|
529 |
PetscErrorCode VecsMultIa(PetscScalar *M, MatType_t sM, PetscInt ldM,
|
|
|
530 |
Vec *U, PetscInt sU, PetscInt eU,
|
|
|
531 |
Vec *V, PetscInt sV, PetscInt eV);
|
| 1753 |
eromero |
532 |
PetscErrorCode SlepcAllReduceSumBegin(DvdReductionChunk *ops,
|
|
|
533 |
PetscInt max_size_ops,
|
|
|
534 |
PetscScalar *in, PetscScalar *out,
|
|
|
535 |
PetscInt max_size_in, DvdReduction *r,
|
|
|
536 |
MPI_Comm comm);
|
|
|
537 |
PetscErrorCode SlepcAllReduceSum(DvdReduction *r, PetscInt size_in,
|
|
|
538 |
DvdReductionPostF f, void *ptr,
|
|
|
539 |
PetscScalar **in);
|
|
|
540 |
PetscErrorCode SlepcAllReduceSumEnd(DvdReduction *r);
|
| 1989 |
eromero |
541 |
PetscErrorCode dvd_orthV(IP ip, Vec *DS, PetscInt size_DS, Vec *cX,
|
|
|
542 |
PetscInt size_cX, Vec *V, PetscInt V_new_s,
|
| 2605 |
eromero |
543 |
PetscInt V_new_e, PetscScalar *auxS,
|
| 1989 |
eromero |
544 |
PetscRandom rand);
|
| 2779 |
eromero |
545 |
PetscErrorCode dvd_BorthV(IP ip, Vec *DS, Vec *BDS,PetscReal *BDSn, PetscInt size_DS, Vec *cX,
|
|
|
546 |
Vec *BcX, PetscReal *BcXn, PetscInt size_cX, Vec *V, Vec *BV,PetscReal *BVn,
|
| 2555 |
eromero |
547 |
PetscInt V_new_s, PetscInt V_new_e,
|
| 2605 |
eromero |
548 |
PetscScalar *auxS, PetscRandom rand);
|
| 1968 |
eromero |
549 |
PetscErrorCode dvd_compute_eigenvectors(PetscInt n_, PetscScalar *S,
|
|
|
550 |
PetscInt ldS_, PetscScalar *T, PetscInt ldT_, PetscScalar *pX,
|
|
|
551 |
PetscInt ldpX_, PetscScalar *pY, PetscInt ldpY_, PetscScalar *auxS,
|
| 2216 |
jroman |
552 |
PetscInt size_auxS, PetscBool doProd);
|
| 2568 |
eromero |
553 |
PETSC_EXTERN_CXX_BEGIN
|
| 2556 |
eromero |
554 |
PetscErrorCode EPSSortDenseHEP(EPS eps, PetscInt n, PetscInt k, PetscScalar *w, PetscScalar *V, PetscInt ldV);
|
| 2682 |
jroman |
555 |
PetscErrorCode EPSCleanDenseSchur(PetscInt n,PetscInt k,PetscScalar *S,PetscInt ldS,PetscScalar *T,PetscInt ldT,PetscScalar *eigi,PetscScalar *X,PetscInt ldX,PetscBool doProd);
|
| 2568 |
eromero |
556 |
PETSC_EXTERN_CXX_END
|
| 1976 |
eromero |
557 |
|
|
|
558 |
/* SLEPc interface routines */
|
|
|
559 |
PetscErrorCode SLEPcNotImplemented();
|
| 2324 |
jroman |
560 |
PetscErrorCode EPSCreate_Davidson(EPS eps);
|
| 2348 |
jroman |
561 |
PetscErrorCode EPSReset_Davidson(EPS eps);
|
| 2324 |
jroman |
562 |
PetscErrorCode EPSSetUp_Davidson(EPS eps);
|
|
|
563 |
PetscErrorCode EPSSolve_Davidson(EPS eps);
|
| 2555 |
eromero |
564 |
PetscErrorCode EPSComputeVectors_Davidson(EPS eps);
|
| 2324 |
jroman |
565 |
PetscErrorCode EPSDavidsonSetKrylovStart_Davidson(EPS eps,PetscBool krylovstart);
|
|
|
566 |
PetscErrorCode EPSDavidsonGetKrylovStart_Davidson(EPS eps,PetscBool *krylovstart);
|
|
|
567 |
PetscErrorCode EPSDavidsonSetBlockSize_Davidson(EPS eps,PetscInt blocksize);
|
|
|
568 |
PetscErrorCode EPSDavidsonGetBlockSize_Davidson(EPS eps,PetscInt *blocksize);
|
|
|
569 |
PetscErrorCode EPSDavidsonSetRestart_Davidson(EPS eps,PetscInt minv,PetscInt plusk);
|
|
|
570 |
PetscErrorCode EPSDavidsonGetRestart_Davidson(EPS eps,PetscInt *minv,PetscInt *plusk);
|
|
|
571 |
PetscErrorCode EPSDavidsonGetInitialSize_Davidson(EPS eps,PetscInt *initialsize);
|
|
|
572 |
PetscErrorCode EPSDavidsonSetInitialSize_Davidson(EPS eps,PetscInt initialsize);
|
|
|
573 |
PetscErrorCode EPSDavidsonGetFix_Davidson(EPS eps,PetscReal *fix);
|
|
|
574 |
PetscErrorCode EPSDavidsonSetFix_Davidson(EPS eps,PetscReal fix);
|
| 2555 |
eromero |
575 |
PetscErrorCode EPSDavidsonSetBOrth_Davidson(EPS eps,PetscBool borth);
|
|
|
576 |
PetscErrorCode EPSDavidsonGetBOrth_Davidson(EPS eps,PetscBool *borth);
|
| 2611 |
eromero |
577 |
PetscErrorCode EPSDavidsonSetConstantCorrectionTolerance_Davidson(EPS eps,PetscBool constant);
|
|
|
578 |
PetscErrorCode EPSDavidsonGetConstantCorrectionTolerance_Davidson(EPS eps,PetscBool *constant);
|
|
|
579 |
PetscErrorCode EPSDavidsonSetWindowSizes_Davidson(EPS eps,PetscInt pwindow,PetscInt qwindow);
|
|
|
580 |
PetscErrorCode EPSDavidsonGetWindowSizes_Davidson(EPS eps,PetscInt *pwindow,PetscInt *qwindow);
|
| 2779 |
eromero |
581 |
PetscErrorCode EPSDavidsonSetMethod_Davidson(EPS eps,Method_t method);
|
|
|
582 |
PetscErrorCode EPSDavidsonGetMethod_Davidson(EPS eps,Method_t *method);
|
|
|
583 |
|
|
|
584 |
/* Common inline function */
|
|
|
585 |
#undef __FUNCT__
|
|
|
586 |
#define __FUNCT__ "dvd_improvex_compute_X"
|
|
|
587 |
PETSC_STATIC_INLINE PetscErrorCode dvd_improvex_compute_X(dvdDashboard *d,PetscInt i_s,PetscInt i_e,Vec *u,PetscScalar *pX,PetscInt ld)
|
|
|
588 |
{
|
|
|
589 |
PetscErrorCode ierr;
|
|
|
590 |
PetscInt n = i_e - i_s, i;
|
|
|
591 |
|
|
|
592 |
PetscFunctionBegin;
|
|
|
593 |
ierr = SlepcUpdateVectorsZ(u, 0.0, 1.0, d->V-d->cX_in_H, d->size_V+d->cX_in_H, pX, ld, d->size_H, n); CHKERRQ(ierr);
|
|
|
594 |
/* nX(i) <- ||X(i)|| */
|
|
|
595 |
if (d->correctXnorm) {
|
|
|
596 |
for (i=0; i<n; i++) {
|
|
|
597 |
ierr = VecNormBegin(u[i], NORM_2, &d->nX[i_s+i]);CHKERRQ(ierr);
|
|
|
598 |
}
|
|
|
599 |
for (i=0; i<n; i++) {
|
|
|
600 |
ierr = VecNormEnd(u[i], NORM_2, &d->nX[i_s+i]);CHKERRQ(ierr);
|
|
|
601 |
}
|
|
|
602 |
#if !defined(PETSC_USE_COMPLEX)
|
|
|
603 |
for(i=0; i<n; i++)
|
|
|
604 |
if(d->eigi[i_s+i] != 0.0)
|
|
|
605 |
d->nX[i_s+i] = d->nX[i_s+i+1] = PetscSqrtScalar(d->nX[i_s+i]*d->nX[i_s+i]+d->nX[i_s+i+1]*d->nX[i_s+i+1]);
|
|
|
606 |
#endif
|
|
|
607 |
} else {
|
|
|
608 |
for (i=0; i<n; i++) d->nX[i_s+i] = 1.0;
|
|
|
609 |
}
|
|
|
610 |
PetscFunctionReturn(0);
|
|
|
611 |
}
|
|
|
612 |
|
|
|
613 |
|
|
|
614 |
#define _Ceil(A,B) ((A)/(B)+((A)%(B)==0?0:1))
|
|
|
615 |
#define FromIntToScalar(S) ((PetscInt)_Ceil((S)*sizeof(PetscBLASInt),sizeof(PetscScalar)))
|
|
|
616 |
#define FromRealToScalar(S) ((PetscInt)_Ceil((S)*sizeof(PetscReal),sizeof(PetscScalar)))
|