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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6141 - (show annotations)
Wed Apr 6 03:51:30 2016 UTC (2 years, 8 months ago) by caltinay
File size: 6688 byte(s)
more namespacing of defines.

1
2
3 /*****************************************************************************
4 *
5 * Copyright (c) 2003-2016 by The University of Queensland
6 * http://www.uq.edu.au
7 *
8 * Primary Business: Queensland, Australia
9 * Licensed under the Apache License, version 2.0
10 * http://www.apache.org/licenses/LICENSE-2.0
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 "EsysException.h"
20
21 #include <cstring>
22 #include <cmath> // to test if we know how to check for nan
23 #include <boost/python/tuple.hpp>
24
25 namespace escript
26 {
27
28 EscriptParams escriptParams; // externed in header file
29
30
31 EscriptParams::EscriptParams()
32 {
33 too_many_lines=80;
34 autolazy=0;
35 too_many_levels=70;
36 lazy_str_fmt=0;
37 lazy_verbose=0;
38 #ifdef USE_NETCDF
39 has_netcdf=1;
40 #else
41 has_netcdf=0;
42 #endif
43 #ifdef USE_TRILINOS
44 have_trilinos=1;
45 #else
46 have_trilinos=0;
47 #endif
48 #ifdef ESYS_HAVE_BOOST_IO
49 have_unzip = 1;
50 #else
51 have_unzip = 0;
52 #endif
53 #ifdef USE_LAPACK
54 lapack_support=1;
55 #else
56 lapack_support=0;
57 #endif
58
59 #ifdef ESYS_HAVE_GMSH
60 gmsh = 1;
61 #else
62 gmsh = 0;
63 #endif
64 //only mark gmsh as mpi if escript built with mpi, otherwise comm_spawns
65 //might just fail terribly
66 #if defined(ESYS_GMSH_MPI) && defined(ESYS_MPI)
67 gmsh_mpi = 1;
68 #else
69 gmsh_mpi = 0;
70 #endif
71
72 #ifdef ESYS_MPI
73 amg_disabled=true;
74 #else
75 amg_disabled=false;
76 #endif
77
78 temp_direct_solver=false; // This variable is to be removed once proper
79 // SolverOptions support is in place
80 #ifdef ESYS_HAVE_MKL
81 temp_direct_solver=true;
82 #endif
83 #ifdef USE_UMFPACK
84 temp_direct_solver=true;
85 #endif
86 #ifdef PASTIX
87 temp_direct_solver=true;
88 #endif
89
90 // These #defs are for performance testing only
91 // in general, I don't want people tweaking the
92 // default value using compiler options
93 // I've provided a python interface for that
94 #ifdef FAUTOLAZYON
95 autolazy=1;
96 #endif
97 #ifdef FAUTOLAZYOFF
98 autolazy=0;
99 #endif
100
101 #ifdef FRESCOLLECTON
102 resolve_collective=1;
103 #endif
104 #ifdef FRESCOLLECTOFF
105 resolve_collective=0;
106 #endif
107 }
108
109 int
110 EscriptParams::getInt(const char* name, int sentinel) const
111 {
112 if (!strcmp(name,"TOO_MANY_LINES"))
113 {
114 return too_many_lines;
115 }
116 if (!strcmp(name,"AUTOLAZY"))
117 {
118 return autolazy;
119 }
120 if (!strcmp(name,"TOO_MANY_LEVELS"))
121 {
122 return too_many_levels;
123 }
124 if (!strcmp(name,"RESOLVE_COLLECTIVE"))
125 {
126 return resolve_collective;
127 }
128 if (!strcmp(name,"LAZY_STR_FMT"))
129 {
130 return lazy_str_fmt;
131 }
132 if (!strcmp(name,"LAPACK_SUPPORT"))
133 {
134 return lapack_support;
135 }
136 if (!strcmp(name, "NAN_CHECK"))
137 {
138 #ifdef isnan
139 return 1;
140 #else
141 return 0;
142 #endif
143 }
144 if (!strcmp(name,"LAZY_VERBOSE"))
145 {
146 return lazy_verbose;
147 }
148 if (!strcmp(name, "DISABLE_AMG"))
149 {
150 return amg_disabled;
151 }
152 if (!strcmp(name, "MPIBUILD"))
153 {
154 #ifdef ESYS_MPI
155 return 1;
156 #else
157 return 0;
158 #endif
159 }
160 if (!strcmp(name, "PASO_DIRECT"))
161 {
162 // This is not in the constructor because escriptparams could be constructed
163 // before main (and hence no opportunity to call INIT)
164 #ifdef ESYS_MPI
165 int size;
166 if (MPI_Comm_size(MPI_COMM_WORLD, &size)!=MPI_SUCCESS) // This would break in a subworld
167 {
168 temp_direct_solver=false;
169 }
170 if (size>1)
171 {
172 temp_direct_solver=false;
173 }
174 #endif
175 return temp_direct_solver;
176 }
177 if (!strcmp(name, "NETCDF_BUILD"))
178 {
179 return has_netcdf;
180 }
181 if (!strcmp(name, "HAVE_TRILINOS"))
182 return have_trilinos;
183 if (!strcmp(name, "HAVE_UNZIP"))
184 return have_unzip;
185 if (!strcmp(name, "GMSH_SUPPORT"))
186 return gmsh;
187 if (!strcmp(name, "GMSH_MPI"))
188 return gmsh_mpi;
189 return sentinel;
190 }
191
192 void
193 EscriptParams::setInt(const char* name, int value)
194 {
195 // Note: there is no way to modify the LAPACK_SUPPORT variable ATM
196 if (!strcmp(name,"TOO_MANY_LINES"))
197 too_many_lines=value;
198 else if (!strcmp(name,"AUTOLAZY"))
199 autolazy=!(value==0); // set to 1 or zero
200 else if (!strcmp(name,"TOO_MANY_LEVELS"))
201 too_many_levels=value;
202 else if (!strcmp(name,"RESOLVE_COLLECTIVE"))
203 resolve_collective=value;
204 else if (!strcmp(name,"LAZY_STR_FMT"))
205 lazy_str_fmt=value;
206 else if (!strcmp(name,"LAZY_VERBOSE"))
207 lazy_verbose=value;
208 else
209 throw EsysException("Invalid parameter name");
210 }
211
212 void
213 setEscriptParamInt(const char* name, int value)
214 {
215 escriptParams.setInt(name,value);
216 }
217
218
219 int
220 getEscriptParamInt(const char* name, int sentinel)
221 {
222 return escriptParams.getInt(name, sentinel);
223 }
224
225 boost::python::list
226 EscriptParams::listEscriptParams()
227 {
228 using namespace boost::python;
229 boost::python::list l;
230 l.append(make_tuple("TOO_MANY_LINES", too_many_lines, "Maximum number of lines to output when printing data before printing a summary instead."));
231 l.append(make_tuple("AUTOLAZY", autolazy, "{0,1} Operations involving Expanded Data will create lazy results."));
232 l.append(make_tuple("RESOLVE_COLLECTIVE",resolve_collective ,"(TESTING ONLY) {0.1} Collective operations will resolve their data."));
233 l.append(make_tuple("TOO_MANY_LEVELS", too_many_levels, "(TESTING ONLY) maximum levels allowed in an expression."));
234 l.append(make_tuple("LAZY_STR_FMT", lazy_str_fmt, "{0,1,2}(TESTING ONLY) change output format for lazy expressions."));
235 l.append(make_tuple("LAZY_VERBOSE", lazy_verbose, "{0,1} Print a warning when expressions are resolved because they are too large."));
236 l.append(make_tuple("DISABLE_AMG", amg_disabled, "{0,1} AMG is disabled."));
237 l.append(make_tuple("NETCDF_BUILD", has_netcdf, "{0,1} Was this build made with netcdf libraries?"));
238 l.append(make_tuple("HAVE_TRILINOS", have_trilinos, "{0,1} Was this build made with trilinos libraries?"));
239 l.append(make_tuple("HAVE_UNZIP", have_unzip, "{0,1} Was this build made with unzip libraries (boost::iostreams)?"));
240 l.append(make_tuple("GMSH_SUPPORT", gmsh, "{0,1} Non-python GMSH support is available."));
241 l.append(make_tuple("GMSH_MPI", gmsh_mpi, "{0,1} Both GMSH and escript have MPI capabilities."));
242 return l;
243 }
244
245 } // end namespace
246

  ViewVC Help
Powered by ViewVC 1.1.26