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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5339 - (show annotations)
Thu Dec 11 00:08:58 2014 UTC (4 years, 4 months ago) by sshaw
File size: 6238 byte(s)
added an exception for trying to set an escript param that doesn't exist
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 #include "esysUtils/EsysException.h"
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 lazy_str_fmt=0;
38 lazy_verbose=0;
39 #ifdef USE_NETCDF
40 has_netcdf=1;
41 #else
42 has_netcdf=0;
43 #endif
44 #ifdef USE_LAPACK
45 lapack_support=1;
46 #else
47 lapack_support=0;
48 #endif
49
50 gmsh = gmsh_mpi = 0;
51 #if defined(GMSH) || defined(GMSH_MPI)
52 gmsh = 1;
53 #endif
54 //only mark gmsh as mpi if escript built with mpi, otherwise comm_spawns
55 //might just fail terribly
56 #if defined(GMSH_MPI) && defined(ESYS_MPI)
57 gmsh_mpi = 1;
58 #endif
59
60 #ifdef ESYS_MPI
61 amg_disabled=true;
62 #else
63 amg_disabled=false;
64 #endif
65
66 temp_direct_solver=false; // This variable is to be removed once proper
67 // SolverOptions support is in place
68 #ifdef MKL
69 temp_direct_solver=true;
70 #endif
71 #ifdef USE_UMFPACK
72 temp_direct_solver=true;
73 #endif
74 #ifdef PASTIX
75 temp_direct_solver=true;
76 #endif
77
78 // These #defs are for performance testing only
79 // in general, I don't want people tweaking the
80 // default value using compiler options
81 // I've provided a python interface for that
82 #ifdef FAUTOLAZYON
83 autolazy=1;
84 #endif
85 #ifdef FAUTOLAZYOFF
86 autolazy=0;
87 #endif
88
89 #ifdef FRESCOLLECTON
90 resolve_collective=1;
91 #endif
92 #ifdef FRESCOLLECTOFF
93 resolve_collective=0;
94 #endif
95 }
96
97 int
98 EscriptParams::getInt(const char* name, int sentinel) const
99 {
100 if (!strcmp(name,"TOO_MANY_LINES"))
101 {
102 return too_many_lines;
103 }
104 if (!strcmp(name,"AUTOLAZY"))
105 {
106 return autolazy;
107 }
108 if (!strcmp(name,"TOO_MANY_LEVELS"))
109 {
110 return too_many_levels;
111 }
112 if (!strcmp(name,"RESOLVE_COLLECTIVE"))
113 {
114 return resolve_collective;
115 }
116 if (!strcmp(name,"LAZY_STR_FMT"))
117 {
118 return lazy_str_fmt;
119 }
120 if (!strcmp(name,"LAPACK_SUPPORT"))
121 {
122 return lapack_support;
123 }
124 if (!strcmp(name, "NAN_CHECK"))
125 {
126 #ifdef isnan
127 return 1;
128 #else
129 return 0;
130 #endif
131 }
132 if (!strcmp(name,"LAZY_VERBOSE"))
133 {
134 return lazy_verbose;
135 }
136 if (!strcmp(name, "DISABLE_AMG"))
137 {
138 return amg_disabled;
139 }
140 if (!strcmp(name, "MPIBUILD"))
141 {
142 #ifdef ESYS_MPI
143 return 1;
144 #else
145 return 0;
146 #endif
147 }
148 if (!strcmp(name, "PASO_DIRECT"))
149 {
150 // This is not in the constructor because escriptparams could be constructed
151 // before main (and hence no opportunity to call INIT)
152 #ifdef ESYS_MPI
153 int size;
154 if (MPI_Comm_size(MPI_COMM_WORLD, &size)!=MPI_SUCCESS) // This would break in a subworld
155 {
156 temp_direct_solver=false;
157 }
158 if (size>1)
159 {
160 temp_direct_solver=false;
161 }
162 #endif
163 return temp_direct_solver;
164 }
165 if (!strcmp(name, "NETCDF_BUILD"))
166 {
167 return has_netcdf;
168 }
169 if (!strcmp(name, "GMSH_SUPPORT"))
170 return gmsh;
171 if (!strcmp(name, "GMSH_MPI"))
172 return gmsh_mpi;
173 return sentinel;
174 }
175
176 void
177 EscriptParams::setInt(const char* name, int value)
178 {
179 // Note: there is no way to modify the LAPACK_SUPPORT variable ATM
180 if (!strcmp(name,"TOO_MANY_LINES"))
181 too_many_lines=value;
182 else if (!strcmp(name,"AUTOLAZY"))
183 autolazy=!(value==0); // set to 1 or zero
184 else if (!strcmp(name,"TOO_MANY_LEVELS"))
185 too_many_levels=value;
186 else if (!strcmp(name,"RESOLVE_COLLECTIVE"))
187 resolve_collective=value;
188 else if (!strcmp(name,"LAZY_STR_FMT"))
189 lazy_str_fmt=value;
190 else if (!strcmp(name,"LAZY_VERBOSE"))
191 lazy_verbose=value;
192 else
193 throw esysUtils::EsysException("Invalid parameter name");
194 }
195
196 void
197 setEscriptParamInt(const char* name, int value)
198 {
199 escriptParams.setInt(name,value);
200 }
201
202
203 int
204 getEscriptParamInt(const char* name, int sentinel)
205 {
206 return escriptParams.getInt(name, sentinel);
207 }
208
209 boost::python::list
210 EscriptParams::listEscriptParams()
211 {
212 using namespace boost::python;
213 boost::python::list l;
214 l.append(make_tuple("TOO_MANY_LINES", too_many_lines, "Maximum number of lines to output when printing data before printing a summary instead."));
215 l.append(make_tuple("AUTOLAZY", autolazy, "{0,1} Operations involving Expanded Data will create lazy results."));
216 l.append(make_tuple("RESOLVE_COLLECTIVE",resolve_collective ,"(TESTING ONLY) {0.1} Collective operations will resolve their data."));
217 l.append(make_tuple("TOO_MANY_LEVELS", too_many_levels, "(TESTING ONLY) maximum levels allowed in an 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 l.append(make_tuple("NETCDF_BUILD", has_netcdf, "{0,1} Was this build made with netcdf libraries?"));
222 l.append(make_tuple("GMSH_SUPPORT", gmsh, "{0,1} Non-python GMSH support is available."));
223 l.append(make_tuple("GMSH_MPI", gmsh_mpi, "{0,1} Both GMSH and escript have MPI capabilities."));
224 return l;
225 }
226
227
228
229
230 } // end namespace

  ViewVC Help
Powered by ViewVC 1.1.26