/[escript]/trunk/escriptcore/src/EscriptParams.cpp
ViewVC logotype

Contents of /trunk/escriptcore/src/EscriptParams.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5228 - (show annotations)
Mon Oct 27 23:31:46 2014 UTC (4 years, 5 months ago) by caltinay
File size: 5236 byte(s)
updated UMFPACK def in places...

1
2
3 /*****************************************************************************
4 *
5 * Copyright (c) 2003-2014 by University of Queensland
6 * http://www.uq.edu.au
7 *
8 * Primary Business: Queensland, Australia
9 * Licensed under the Open Software License version 3.0
10 * http://www.opensource.org/licenses/osl-3.0.php
11 *
12 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
13 * Development 2012-2013 by School of Earth Sciences
14 * Development from 2014 by Centre for Geoscience Computing (GeoComp)
15 *
16 *****************************************************************************/
17
18 #include "EscriptParams.h"
19 #include <cstring>
20 #include <boost/python/tuple.hpp>
21 #include <cmath> // to test if we know how to check for nan
22
23
24 #include "esysUtils/Esys_MPI.h"
25
26 namespace escript
27 {
28
29 EscriptParams escriptParams; // externed in header file
30
31
32 EscriptParams::EscriptParams()
33 {
34 too_many_lines=80;
35 autolazy=0;
36 too_many_levels=70;
37 // too_many_nodes=15000;
38 resolve_collective=0;
39 lazy_str_fmt=0;
40 lazy_verbose=0;
41
42 #ifdef USE_LAPACK
43 lapack_support=1;
44 #else
45 lapack_support=0;
46 #endif
47 // These #defs are for performance testing only
48 // in general, I don't want people tweaking the
49 // default value using compiler options
50 // I've provided a python interface for that
51 #ifdef FAUTOLAZYON
52 autolazy=1;
53 #endif
54 #ifdef FAUTOLAZYOFF
55 autolazy=0;
56 #endif
57
58 #ifdef FRESCOLLECTON
59 resolve_collective=1;
60 #endif
61 #ifdef FRESCOLLECTOFF
62 resolve_collective=0;
63 #endif
64
65
66 #ifdef ESYS_MPI
67 amg_disabled=true;
68 #else
69 amg_disabled=false;
70 #endif
71
72 temp_direct_solver=false; // This variable is to be removed once proper
73 // SolverOptions support is in place
74 #ifdef MKL
75 temp_direct_solver=true;
76 #endif
77 #ifdef USE_UMFPACK
78 temp_direct_solver=true;
79 #endif
80 #ifdef PASTIX
81 temp_direct_solver=true;
82 #endif
83
84 }
85
86 int
87 EscriptParams::getInt(const char* name, int sentinel) const
88 {
89 if (!strcmp(name,"TOO_MANY_LINES"))
90 {
91 return too_many_lines;
92 }
93 if (!strcmp(name,"AUTOLAZY"))
94 {
95 return autolazy;
96 }
97 if (!strcmp(name,"TOO_MANY_LEVELS"))
98 {
99 return too_many_levels;
100 }
101 // if (!strcmp(name,"TOO_MANY_NODES"))
102 // {
103 // return too_many_nodes;
104 // }
105 if (!strcmp(name,"RESOLVE_COLLECTIVE"))
106 {
107 return resolve_collective;
108 }
109 if (!strcmp(name,"LAZY_STR_FMT"))
110 {
111 return lazy_str_fmt;
112 }
113 if (!strcmp(name,"LAPACK_SUPPORT"))
114 {
115 return lapack_support;
116 }
117 if (!strcmp(name, "NAN_CHECK"))
118 {
119 #ifdef isnan
120 return 1;
121 #else
122 return 0;
123 #endif
124 }
125 if (!strcmp(name,"LAZY_VERBOSE"))
126 {
127 return lazy_verbose;
128 }
129 if (!strcmp(name, "DISABLE_AMG"))
130 {
131 return amg_disabled;
132 }
133 if (!strcmp(name, "MPIBUILD"))
134 {
135 #ifdef ESYS_MPI
136 return 1;
137 #else
138 return 0;
139 #endif
140 }
141 if (!strcmp(name, "PASO_DIRECT"))
142 {
143 // This is not in the constructor because escriptparams could be constructed
144 // before main (and hence no opportunity to call INIT)
145 #ifdef ESYS_MPI
146 int size;
147 if (MPI_Comm_size(MPI_COMM_WORLD, &size)!=MPI_SUCCESS) // This would break in a subworld
148 {
149 temp_direct_solver=false;
150 }
151 if (size>1)
152 {
153 temp_direct_solver=false;
154 }
155 #endif
156 return temp_direct_solver;
157 }
158 return sentinel;
159 }
160
161 void
162 EscriptParams::setInt(const char* name, int value)
163 {
164 if (!strcmp(name,"TOO_MANY_LINES"))
165 {
166 too_many_lines=value;
167 }
168 if (!strcmp(name,"AUTOLAZY"))
169 {
170 autolazy=!(value==0); // set to 1 or zero
171 }
172 if (!strcmp(name,"TOO_MANY_LEVELS"))
173 {
174 too_many_levels=value;
175 }
176 // if (!strcmp(name,"TOO_MANY_NODES"))
177 // {
178 // too_many_nodes=value;
179 // }
180 if (!strcmp(name,"RESOLVE_COLLECTIVE"))
181 {
182 resolve_collective=value;
183 }
184 if (!strcmp(name,"LAZY_STR_FMT"))
185 {
186 lazy_str_fmt=value;
187 }
188 if (!strcmp(name,"LAZY_VERBOSE"))
189 {
190 lazy_verbose=value;
191 }
192 // Note: there is no way to modify the LAPACK_SUPPORT variable ATM
193 }
194
195 void
196 setEscriptParamInt(const char* name, int value)
197 {
198 escriptParams.setInt(name,value);
199 }
200
201
202 int
203 getEscriptParamInt(const char* name, int sentinel)
204 {
205 return escriptParams.getInt(name, sentinel);
206 }
207
208 boost::python::list
209 EscriptParams::listEscriptParams()
210 {
211 using namespace boost::python;
212 boost::python::list l;
213 l.append(make_tuple("TOO_MANY_LINES", too_many_lines, "Maximum number of lines to output when printing data before printing a summary instead."));
214 l.append(make_tuple("AUTOLAZY", autolazy, "{0,1} Operations involving Expanded Data will create lazy results."));
215 l.append(make_tuple("RESOLVE_COLLECTIVE",resolve_collective ,"(TESTING ONLY) {0.1} Collective operations will resolve their data."));
216 l.append(make_tuple("TOO_MANY_LEVELS", too_many_levels, "(TESTING ONLY) maximum levels allowed in an expression."));
217 // l.append(make_tuple("TOO_MANY_NODES", too_many_nodes, "(TESTING ONLY) maximum number of nodes in a expression."));
218 l.append(make_tuple("LAZY_STR_FMT", lazy_str_fmt, "{0,1,2}(TESTING ONLY) change output format for lazy expressions."));
219 l.append(make_tuple("LAZY_VERBOSE", lazy_verbose, "{0,1} Print a warning when expressions are resolved because they are too large."));
220 l.append(make_tuple("DISABLE_AMG", amg_disabled, "{0,1} AMG is disabled."));
221 return l;
222 }
223
224
225
226
227 } // end namespace

  ViewVC Help
Powered by ViewVC 1.1.26