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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6120 - (show annotations)
Mon Apr 4 01:33:51 2016 UTC (3 years ago) by caltinay
File size: 6408 byte(s)
guilty as charged.

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

  ViewVC Help
Powered by ViewVC 1.1.26