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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

1 jfenwick 1897
2    
3 jfenwick 3981 /*****************************************************************************
4 jfenwick 1897 *
5 jfenwick 5863 * Copyright (c) 2003-2016 by The University of Queensland
6 jfenwick 3981 * http://www.uq.edu.au
7 jfenwick 1897 *
8     * Primary Business: Queensland, Australia
9 jfenwick 6112 * Licensed under the Apache License, version 2.0
10     * http://www.apache.org/licenses/LICENSE-2.0
11 jfenwick 1897 *
12 jfenwick 3981 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
13 jfenwick 4657 * Development 2012-2013 by School of Earth Sciences
14     * Development from 2014 by Centre for Geoscience Computing (GeoComp)
15 jfenwick 3981 *
16     *****************************************************************************/
17 jfenwick 1897
18 caltinay 5972 #include "EscriptParams.h"
19     #include "EsysException.h"
20 jfenwick 5464
21 jfenwick 1897 #include <cstring>
22 caltinay 5997 #include <cmath> // to test if we know how to check for nan
23 jfenwick 2142 #include <boost/python/tuple.hpp>
24 jfenwick 1897
25     namespace escript
26     {
27    
28 sshaw 5320 EscriptParams escriptParams; // externed in header file
29 jfenwick 1897
30    
31     EscriptParams::EscriptParams()
32     {
33     too_many_lines=80;
34 jfenwick 2146 autolazy=0;
35 jfenwick 2501 too_many_levels=70;
36 jfenwick 2795 lazy_str_fmt=0;
37     lazy_verbose=0;
38 jfenwick 5322 #ifdef USE_NETCDF
39     has_netcdf=1;
40     #else
41     has_netcdf=0;
42     #endif
43 caltinay 6120 #ifdef USE_TRILINOS
44     have_trilinos=1;
45     #else
46     have_trilinos=0;
47     #endif
48 caltinay 6141 #ifdef ESYS_HAVE_BOOST_IO
49     have_unzip = 1;
50     #else
51     have_unzip = 0;
52     #endif
53 jfenwick 2742 #ifdef USE_LAPACK
54     lapack_support=1;
55     #else
56     lapack_support=0;
57     #endif
58 jfenwick 2721
59 caltinay 6141 #ifdef ESYS_HAVE_GMSH
60 sshaw 5320 gmsh = 1;
61 caltinay 6141 #else
62     gmsh = 0;
63 jfenwick 2721 #endif
64 sshaw 5320 //only mark gmsh as mpi if escript built with mpi, otherwise comm_spawns
65     //might just fail terribly
66 caltinay 6141 #if defined(ESYS_GMSH_MPI) && defined(ESYS_MPI)
67 sshaw 5320 gmsh_mpi = 1;
68 caltinay 6141 #else
69     gmsh_mpi = 0;
70 jfenwick 2721 #endif
71    
72 jfenwick 3906 #ifdef ESYS_MPI
73 sshaw 5320 amg_disabled=true;
74 jfenwick 3906 #else
75 sshaw 5320 amg_disabled=false;
76 jfenwick 3906 #endif
77    
78 sshaw 5320 temp_direct_solver=false; // This variable is to be removed once proper
79     // SolverOptions support is in place
80 caltinay 6138 #ifdef ESYS_HAVE_MKL
81 jfenwick 4713 temp_direct_solver=true;
82     #endif
83 caltinay 5228 #ifdef USE_UMFPACK
84     temp_direct_solver=true;
85 jfenwick 4713 #endif
86     #ifdef PASTIX
87     temp_direct_solver=true;
88     #endif
89 jfenwick 3906
90 sshaw 5320 // 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 jfenwick 1897 }
108    
109     int
110     EscriptParams::getInt(const char* name, int sentinel) const
111     {
112     if (!strcmp(name,"TOO_MANY_LINES"))
113     {
114 sshaw 5320 return too_many_lines;
115 jfenwick 1897 }
116 jfenwick 2146 if (!strcmp(name,"AUTOLAZY"))
117     {
118 sshaw 5320 return autolazy;
119 jfenwick 2146 }
120 jfenwick 2472 if (!strcmp(name,"TOO_MANY_LEVELS"))
121     {
122 sshaw 5320 return too_many_levels;
123 jfenwick 2472 }
124 jfenwick 2721 if (!strcmp(name,"RESOLVE_COLLECTIVE"))
125     {
126 sshaw 5320 return resolve_collective;
127 jfenwick 2721 }
128 jfenwick 2795 if (!strcmp(name,"LAZY_STR_FMT"))
129 jfenwick 2737 {
130 sshaw 5320 return lazy_str_fmt;
131 jfenwick 2737 }
132 jfenwick 2742 if (!strcmp(name,"LAPACK_SUPPORT"))
133     {
134 sshaw 5320 return lapack_support;
135 jfenwick 2742 }
136 jfenwick 2769 if (!strcmp(name, "NAN_CHECK"))
137     {
138 sshaw 5320 #ifdef isnan
139     return 1;
140 jfenwick 2769 #else
141 sshaw 5320 return 0;
142 jfenwick 2769 #endif
143     }
144 jfenwick 2795 if (!strcmp(name,"LAZY_VERBOSE"))
145     {
146 sshaw 5320 return lazy_verbose;
147 jfenwick 2795 }
148 jfenwick 3906 if (!strcmp(name, "DISABLE_AMG"))
149     {
150 sshaw 5320 return amg_disabled;
151 jfenwick 3906 }
152 jfenwick 3940 if (!strcmp(name, "MPIBUILD"))
153     {
154 sshaw 5320 #ifdef ESYS_MPI
155     return 1;
156 jfenwick 3940 #else
157 sshaw 5320 return 0;
158 jfenwick 3940 #endif
159     }
160 jfenwick 4713 if (!strcmp(name, "PASO_DIRECT"))
161     {
162 sshaw 5320 // 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 jfenwick 4713 }
177 jfenwick 5322 if (!strcmp(name, "NETCDF_BUILD"))
178     {
179     return has_netcdf;
180     }
181 caltinay 6120 if (!strcmp(name, "HAVE_TRILINOS"))
182     return have_trilinos;
183 caltinay 6141 if (!strcmp(name, "HAVE_UNZIP"))
184     return have_unzip;
185 sshaw 5320 if (!strcmp(name, "GMSH_SUPPORT"))
186     return gmsh;
187     if (!strcmp(name, "GMSH_MPI"))
188     return gmsh_mpi;
189 jfenwick 1897 return sentinel;
190     }
191    
192     void
193     EscriptParams::setInt(const char* name, int value)
194     {
195 sshaw 5339 // Note: there is no way to modify the LAPACK_SUPPORT variable ATM
196     if (!strcmp(name,"TOO_MANY_LINES"))
197 sshaw 5320 too_many_lines=value;
198 sshaw 5339 else if (!strcmp(name,"AUTOLAZY"))
199 sshaw 5320 autolazy=!(value==0); // set to 1 or zero
200 sshaw 5339 else if (!strcmp(name,"TOO_MANY_LEVELS"))
201 sshaw 5320 too_many_levels=value;
202 sshaw 5339 else if (!strcmp(name,"RESOLVE_COLLECTIVE"))
203 sshaw 5320 resolve_collective=value;
204 sshaw 5339 else if (!strcmp(name,"LAZY_STR_FMT"))
205 sshaw 5320 lazy_str_fmt=value;
206 sshaw 5339 else if (!strcmp(name,"LAZY_VERBOSE"))
207 sshaw 5320 lazy_verbose=value;
208 sshaw 5339 else
209 caltinay 5972 throw EsysException("Invalid parameter name");
210 jfenwick 1897 }
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 jfenwick 2142 boost::python::list
226 jfenwick 2721 EscriptParams::listEscriptParams()
227 jfenwick 2142 {
228     using namespace boost::python;
229     boost::python::list l;
230 jfenwick 2721 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 jfenwick 2795 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 jfenwick 3906 l.append(make_tuple("DISABLE_AMG", amg_disabled, "{0,1} AMG is disabled."));
237 jfenwick 5322 l.append(make_tuple("NETCDF_BUILD", has_netcdf, "{0,1} Was this build made with netcdf libraries?"));
238 caltinay 6120 l.append(make_tuple("HAVE_TRILINOS", have_trilinos, "{0,1} Was this build made with trilinos libraries?"));
239 caltinay 6141 l.append(make_tuple("HAVE_UNZIP", have_unzip, "{0,1} Was this build made with unzip libraries (boost::iostreams)?"));
240 jfenwick 5336 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 jfenwick 2142 return l;
243     }
244 jfenwick 1897
245 caltinay 5997 } // end namespace
246 jfenwick 2142

  ViewVC Help
Powered by ViewVC 1.1.26