/[escript]/trunk/paso/src/Options.cpp
ViewVC logotype

Contents of /trunk/paso/src/Options.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5148 - (show annotations)
Mon Sep 15 01:25:23 2014 UTC (5 years ago) by caltinay
File size: 11385 byte(s)
Merging ripley diagonal storage + CUDA support into trunk.
Options file version has been incremented due to new options
'cuda' and 'nvccflags'.

1
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
18 /****************************************************************************/
19
20 /* Paso: solver options */
21
22 /****************************************************************************/
23
24 /* Copyrights by ACcESS Australia, 2003,2004 */
25 /* author: l.gross@uq.edu.au */
26
27 /****************************************************************************/
28
29 #include "Paso.h"
30 #include "Options.h"
31
32 namespace paso {
33
34 void Options::setDefaults()
35 {
36 verbose = false;
37 method = PASO_DEFAULT;
38 package = PASO_DEFAULT;
39 symmetric = false;
40 reordering = PASO_NO_REORDERING;
41 tolerance = 1.e-8;
42 absolute_tolerance = 0.;
43 inner_tolerance = 0.9;
44 adapt_inner_tolerance = true;
45 preconditioner = PASO_JACOBI;
46 iter_max = 10000;
47 inner_iter_max = 10;
48 drop_tolerance = 0.01;
49 drop_storage = 2.;
50 restart = -1;
51 truncation = 20;
52 sweeps = 2;
53 pre_sweeps = 2;
54 post_sweeps = 2;
55 coarsening_threshold = 0.25;
56 min_coarse_matrix_size = 500;
57 level_max = 100;
58 accept_failed_convergence = false;
59 coarsening_method = PASO_DEFAULT;
60 relaxation_factor = 0.95;
61 smoother = PASO_GS;
62 use_local_preconditioner = false;
63 min_coarse_sparsity = 0.05;
64 refinements = 2;
65 coarse_matrix_refinements = 0;
66 diagonal_dominance_threshold = 0.5;
67 cycle_type = 1;
68 usePanel = true;
69 interpolation_method = PASO_DIRECT_INTERPOLATION;
70 ode_solver = PASO_LINEAR_CRANK_NICOLSON;
71
72 // diagnostic values
73 num_iter = -1;
74 num_level = -1;
75 num_inner_iter = -1;
76 time = -1.;
77 set_up_time = -1.;
78 coarsening_selection_time = -1.;
79 coarsening_matrix_time = -1;
80 net_time = -1.;
81 residual_norm = -1.;
82 converged = false;
83 preconditioner_size = -1.;
84 time_step_backtracking_used = false;
85 coarse_level_sparsity = -1.;
86 num_coarse_unknowns = -1;
87 }
88
89 void Options::showDiagnostics() const
90 {
91 printf("Paso diagnostics:\n");
92 printf("\tnum_iter = %d\n", num_iter);
93 printf("\tnum_level = %d\n", num_level);
94 printf("\tnum_inner_iter = %d\n", num_inner_iter);
95 printf("\ttime = %e\n", time);
96 printf("\tset_up_time = %e\n", set_up_time);
97 printf("\tcoarsening_selection_time = %e\n", coarsening_selection_time);
98 printf("\tcoarsening_matrix_time = %e\n", coarsening_matrix_time);
99 printf("\tnet_time = %e\n", net_time);
100 printf("\tresidual_norm = %e\n", residual_norm);
101 printf("\tconverged = %d\n", converged);
102 printf("\tpreconditioner_size = %e Mbytes\n", preconditioner_size);
103 printf("\ttime_step_backtracking_used = %d\n", time_step_backtracking_used);
104 }
105
106 void Options::show() const
107 {
108 printf("Paso options settings:\n");
109 printf("\tverbose = %d\n", verbose);
110 printf("\tmethod = %s (%d)\n", name(method), method);
111 printf("\tpackage = %s (%d)\n", name(package), package);
112 printf("\tsymmetric = %d\n", symmetric);
113 printf("\treordering = %s (%d)\n", name(reordering), reordering);
114 printf("\ttolerance = %e\n", tolerance);
115 printf("\tabsolute_tolerance = %e\n", absolute_tolerance);
116 printf("\tinner_tolerance = %e\n", inner_tolerance);
117 printf("\tadapt_inner_tolerance = %d\n", adapt_inner_tolerance);
118 printf("\tpreconditioner = %s (%d)\n", name(preconditioner), preconditioner);
119 printf("\titer_max = %d\n", iter_max);
120 printf("\tinner_iter_max = %d\n", inner_iter_max);
121 printf("\tdrop_tolerance = %e\n", drop_tolerance);
122 printf("\tdrop_storage = %e\n", drop_storage);
123 printf("\trestart = %d\n", restart);
124 printf("\ttruncation = %d\n", truncation);
125 printf("\tsweeps = %d\n", sweeps);
126 printf("\tpre_sweeps = %d\n", pre_sweeps);
127 printf("\tpost_sweeps = %d\n", post_sweeps);
128 printf("\tcoarsening_threshold = %e\n", coarsening_threshold);
129 printf("\tlevel_max = %d\n", level_max);
130 printf("\taccept_failed_convergence = %d\n", accept_failed_convergence);
131 printf("\tcoarsening_method = %s (%d)\n", name(coarsening_method), coarsening_method);
132 printf("\trelaxation_factor = %e\n", relaxation_factor);
133 printf("\tuse_local_preconditioner = %d\n", use_local_preconditioner);
134 printf("\tmin_coarse_sparsity = %e\n", min_coarse_sparsity);
135 printf("\trefinements = %d\n", refinements);
136 printf("\tcoarse_matrix_refinements = %d\n", coarse_matrix_refinements);
137 printf("\tcycle_type = %d\n", cycle_type);
138 printf("\tode_solver = %d\n", ode_solver);
139 }
140
141 const char* Options::name(index_t key)
142 {
143 switch (key) {
144 case PASO_DEFAULT:
145 return "DEFAULT";
146 case PASO_DIRECT:
147 return "DIRECT";
148 case PASO_CHOLEVSKY:
149 return "CHOLEVSKY";
150 case PASO_PCG:
151 return "PCG";
152 case PASO_CR:
153 return "CR";
154 case PASO_CGS:
155 return "CGS";
156 case PASO_BICGSTAB:
157 return "BICGSTAB";
158 case PASO_ILU0:
159 return "ILU0";
160 case PASO_ILUT:
161 return "ILUT";
162 case PASO_JACOBI:
163 return "JACOBI";
164 case PASO_GMRES:
165 return "GMRES";
166 case PASO_PRES20:
167 return "PRES20";
168 case PASO_NO_REORDERING:
169 return "NO_REORDERING";
170 case PASO_MINIMUM_FILL_IN:
171 return "MINIMUM_FILL_IN";
172 case PASO_NESTED_DISSECTION:
173 return "NESTED_DISSECTION";
174 case PASO_MKL:
175 return "MKL";
176 case PASO_UMFPACK:
177 return "UMFPACK";
178 case PASO_BOOMERAMG:
179 return "BOOMERAMG";
180 case PASO_ITERATIVE:
181 return "ITERATIVE";
182 case PASO_PASO:
183 return "PASO";
184 case PASO_AMG:
185 return "AMG";
186 case PASO_AMLI:
187 return "AMLI";
188 case PASO_REC_ILU:
189 return "REC_ILU";
190 case PASO_TRILINOS:
191 return "TRILINOS";
192 case PASO_NONLINEAR_GMRES:
193 return "NONLINEAR_GMRES";
194 case PASO_TFQMR :
195 return "TFQMR";
196 case PASO_MINRES:
197 return "MINRES";
198 case PASO_GAUSS_SEIDEL:
199 return "GAUSS_SEIDEL";
200 case PASO_RILU:
201 return "RILU";
202 case PASO_DEFAULT_REORDERING:
203 return "DEFAULT_REORDERING";
204 case PASO_SUPER_LU:
205 return "SUPER_LU";
206 case PASO_PASTIX:
207 return "PASTIX";
208 case PASO_YAIR_SHAPIRA_COARSENING:
209 return "YAIR_SHAPIRA_COARSENING";
210 case PASO_RUGE_STUEBEN_COARSENING:
211 return "RUGE_STUEBEN_COARSENING";
212 case PASO_AGGREGATION_COARSENING:
213 return "AGGREGATION_COARSENING";
214 case PASO_STANDARD_COARSENING:
215 return "STANDARD_COARSENING";
216 case PASO_NO_PRECONDITIONER:
217 return "NO_PRECONDITIONER";
218 case PASO_CIJP_FIXED_RANDOM_COARSENING:
219 return "CIJP_FIXED_RANDOM_COARSENING";
220 case PASO_CIJP_COARSENING:
221 return "CIJP_COARSENING";
222 case PASO_FALGOUT_COARSENING:
223 return "FALGOUT_COARSENING";
224 case PASO_PMIS_COARSENING:
225 return "PMIS_COARSENING";
226 case PASO_HMIS_COARSENING:
227 return "HMIS_COARSENING";
228 case PASO_CRANK_NICOLSON:
229 return "PASO_CRANK_NICOLSON";
230 case PASO_LINEAR_CRANK_NICOLSON:
231 return "PASO_CRANK_NICOLSON";
232 case PASO_BACKWARD_EULER:
233 return "PASO_BACKWARD_EULER";
234 default:
235 return "<unknown>";
236 }
237 }
238
239 index_t Options::getSolver(index_t solver, index_t pack, bool symmetry,
240 const esysUtils::JMPI& mpi_info)
241 {
242 index_t out = PASO_DEFAULT;
243 // PASO //
244 if (pack==PASO_PASO) {
245 switch (solver) {
246 case PASO_BICGSTAB:
247 out=PASO_BICGSTAB;
248 break;
249 case PASO_PCG:
250 out=PASO_PCG;
251 break;
252 case PASO_PRES20:
253 out=PASO_PRES20;
254 break;
255 case PASO_GMRES:
256 out=PASO_GMRES;
257 break;
258 case PASO_NONLINEAR_GMRES:
259 out=PASO_NONLINEAR_GMRES;
260 break;
261 case PASO_TFQMR:
262 out=PASO_TFQMR;
263 break;
264 case PASO_MINRES:
265 out=PASO_MINRES;
266 break;
267 default:
268 if (symmetry) {
269 out=PASO_PCG;
270 } else {
271 out=PASO_BICGSTAB;
272 }
273 break;
274 }
275 // MKL //
276 } else if (pack==PASO_MKL) {
277 switch (solver) {
278 case PASO_CHOLEVSKY:
279 out=PASO_CHOLEVSKY;
280 break;
281 case PASO_DIRECT:
282 out=PASO_DIRECT;
283 break;
284 default:
285 if (symmetry) {
286 out=PASO_CHOLEVSKY;
287 } else {
288 out=PASO_DIRECT;
289 }
290 break;
291 }
292 // TRILINOS //
293 } else if (pack==PASO_TRILINOS) {
294 switch (solver) {
295 case PASO_BICGSTAB:
296 out=PASO_BICGSTAB;
297 break;
298 case PASO_PCG:
299 out=PASO_PCG;
300 break;
301 case PASO_PRES20:
302 out=PASO_PRES20;
303 break;
304 case PASO_GMRES:
305 out=PASO_GMRES;
306 break;
307 case PASO_TFQMR:
308 out=PASO_TFQMR;
309 break;
310 case PASO_MINRES:
311 out=PASO_MINRES;
312 break;
313 default:
314 if (symmetry) {
315 out=PASO_PCG;
316 } else {
317 out=PASO_BICGSTAB;
318 }
319 break;
320 }
321 // UMFPACK //
322 } else if (pack==PASO_UMFPACK) {
323 out=PASO_DIRECT;
324 } else {
325 Esys_setError(VALUE_ERROR, "Options::getSolver: Unidentified package.");
326 }
327 return out;
328 }
329
330 index_t Options::getPackage(index_t solver, index_t pack, bool symmetry,
331 const esysUtils::JMPI& mpi_info)
332 {
333 index_t out = PASO_PASO;
334
335 switch (pack) {
336 case PASO_DEFAULT:
337 if (solver == PASO_DIRECT) {
338 // these packages require CSC which is not supported with MPI
339 if (mpi_info->size == 1) {
340 #if defined MKL
341 out = PASO_MKL;
342 #elif defined UMFPACK
343 out = PASO_UMFPACK;
344 #elif defined PASTIX
345 out = PASO_PASTIX
346 #endif
347 }
348 }
349 break;
350
351 case PASO_PASO:
352 break;
353
354 case PASO_MKL:
355 case PASO_UMFPACK:
356 case PASO_PASTIX:
357 case PASO_TRILINOS:
358 out = pack;
359 break;
360
361 default:
362 Esys_setError(VALUE_ERROR, "Options::getPackage: Unidentified package.");
363 }
364 return out;
365 }
366
367 } // namespace paso
368

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision
svn:mergeinfo /branches/amg_from_3530/paso/src/Options_setDefaults.cpp:3531-3826 /branches/diaplayground/paso/src/Options.cpp:4940-5147 /branches/lapack2681/paso/src/Options_setDefaults.cpp:2682-2741 /branches/pasowrap/paso/src/Options_setDefaults.cpp:3661-3674 /branches/py3_attempt2/paso/src/Options_setDefaults.cpp:3871-3891 /branches/restext/paso/src/Options_setDefaults.cpp:2610-2624 /branches/ripleygmg_from_3668/paso/src/Options_setDefaults.cpp:3669-3791 /branches/stage3.0/paso/src/Options_setDefaults.cpp:2569-2590 /branches/symbolic_from_3470/paso/src/Options_setDefaults.cpp:3471-3974 /branches/symbolic_from_3470/ripley/test/python/paso/src/Options_setDefaults.cpp:3517-3974 /release/3.0/paso/src/Options_setDefaults.cpp:2591-2601 /trunk/paso/src/Options_setDefaults.cpp:4257-4344 /trunk/ripley/test/python/paso/src/Options_setDefaults.cpp:3480-3515

  ViewVC Help
Powered by ViewVC 1.1.26