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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6112 - (show annotations)
Thu Mar 31 09:40:10 2016 UTC (3 years ago) by jfenwick
File size: 6147 byte(s)
Relicense all the things!


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

  ViewVC Help
Powered by ViewVC 1.1.26