/[escript]/branches/subworld2/escriptcore/src/EscriptParams.cpp
ViewVC logotype

Contents of /branches/subworld2/escriptcore/src/EscriptParams.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5504 - (show annotations)
Wed Mar 4 22:58:13 2015 UTC (4 years, 1 month ago) by jfenwick
File size: 6290 byte(s)
Again with a more up to date copy


1
2
3 /*****************************************************************************
4 *
5 * Copyright (c) 2003-2015 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 #define ESNEEDPYTHON
19 #include "esysUtils/first.h"
20
21
22 #include "EscriptParams.h"
23 #include <cstring>
24 #include <boost/python/tuple.hpp>
25 #include <cmath> // to test if we know how to check for nan
26
27 #include "esysUtils/EsysException.h"
28 #include "esysUtils/Esys_MPI.h"
29
30 namespace escript
31 {
32
33 EscriptParams escriptParams; // externed in header file
34
35
36 EscriptParams::EscriptParams()
37 {
38 too_many_lines=80;
39 autolazy=0;
40 too_many_levels=70;
41 lazy_str_fmt=0;
42 lazy_verbose=0;
43 #ifdef USE_NETCDF
44 has_netcdf=1;
45 #else
46 has_netcdf=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, "GMSH_SUPPORT"))
174 return gmsh;
175 if (!strcmp(name, "GMSH_MPI"))
176 return gmsh_mpi;
177 return sentinel;
178 }
179
180 void
181 EscriptParams::setInt(const char* name, int value)
182 {
183 // Note: there is no way to modify the LAPACK_SUPPORT variable ATM
184 if (!strcmp(name,"TOO_MANY_LINES"))
185 too_many_lines=value;
186 else if (!strcmp(name,"AUTOLAZY"))
187 autolazy=!(value==0); // set to 1 or zero
188 else if (!strcmp(name,"TOO_MANY_LEVELS"))
189 too_many_levels=value;
190 else if (!strcmp(name,"RESOLVE_COLLECTIVE"))
191 resolve_collective=value;
192 else if (!strcmp(name,"LAZY_STR_FMT"))
193 lazy_str_fmt=value;
194 else if (!strcmp(name,"LAZY_VERBOSE"))
195 lazy_verbose=value;
196 else
197 throw esysUtils::EsysException("Invalid parameter name");
198 }
199
200 void
201 setEscriptParamInt(const char* name, int value)
202 {
203 escriptParams.setInt(name,value);
204 }
205
206
207 int
208 getEscriptParamInt(const char* name, int sentinel)
209 {
210 return escriptParams.getInt(name, sentinel);
211 }
212
213 boost::python::list
214 EscriptParams::listEscriptParams()
215 {
216 using namespace boost::python;
217 boost::python::list l;
218 l.append(make_tuple("TOO_MANY_LINES", too_many_lines, "Maximum number of lines to output when printing data before printing a summary instead."));
219 l.append(make_tuple("AUTOLAZY", autolazy, "{0,1} Operations involving Expanded Data will create lazy results."));
220 l.append(make_tuple("RESOLVE_COLLECTIVE",resolve_collective ,"(TESTING ONLY) {0.1} Collective operations will resolve their data."));
221 l.append(make_tuple("TOO_MANY_LEVELS", too_many_levels, "(TESTING ONLY) maximum levels allowed in an expression."));
222 l.append(make_tuple("LAZY_STR_FMT", lazy_str_fmt, "{0,1,2}(TESTING ONLY) change output format for lazy expressions."));
223 l.append(make_tuple("LAZY_VERBOSE", lazy_verbose, "{0,1} Print a warning when expressions are resolved because they are too large."));
224 l.append(make_tuple("DISABLE_AMG", amg_disabled, "{0,1} AMG is disabled."));
225 l.append(make_tuple("NETCDF_BUILD", has_netcdf, "{0,1} Was this build made with netcdf libraries?"));
226 l.append(make_tuple("GMSH_SUPPORT", gmsh, "{0,1} Non-python GMSH support is available."));
227 l.append(make_tuple("GMSH_MPI", gmsh_mpi, "{0,1} Both GMSH and escript have MPI capabilities."));
228 return l;
229 }
230
231
232
233
234 } // end namespace

  ViewVC Help
Powered by ViewVC 1.1.26