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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

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 jfenwick 2742 #ifdef USE_LAPACK
49     lapack_support=1;
50     #else
51     lapack_support=0;
52     #endif
53 jfenwick 2721
54 sshaw 5320 gmsh = gmsh_mpi = 0;
55     #if defined(GMSH) || defined(GMSH_MPI)
56     gmsh = 1;
57 jfenwick 2721 #endif
58 sshaw 5320 //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 jfenwick 2721 #endif
63    
64 jfenwick 3906 #ifdef ESYS_MPI
65 sshaw 5320 amg_disabled=true;
66 jfenwick 3906 #else
67 sshaw 5320 amg_disabled=false;
68 jfenwick 3906 #endif
69    
70 sshaw 5320 temp_direct_solver=false; // This variable is to be removed once proper
71     // SolverOptions support is in place
72 jfenwick 4713 #ifdef MKL
73     temp_direct_solver=true;
74     #endif
75 caltinay 5228 #ifdef USE_UMFPACK
76     temp_direct_solver=true;
77 jfenwick 4713 #endif
78     #ifdef PASTIX
79     temp_direct_solver=true;
80     #endif
81 jfenwick 3906
82 sshaw 5320 // 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 jfenwick 1897 }
100    
101     int
102     EscriptParams::getInt(const char* name, int sentinel) const
103     {
104     if (!strcmp(name,"TOO_MANY_LINES"))
105     {
106 sshaw 5320 return too_many_lines;
107 jfenwick 1897 }
108 jfenwick 2146 if (!strcmp(name,"AUTOLAZY"))
109     {
110 sshaw 5320 return autolazy;
111 jfenwick 2146 }
112 jfenwick 2472 if (!strcmp(name,"TOO_MANY_LEVELS"))
113     {
114 sshaw 5320 return too_many_levels;
115 jfenwick 2472 }
116 jfenwick 2721 if (!strcmp(name,"RESOLVE_COLLECTIVE"))
117     {
118 sshaw 5320 return resolve_collective;
119 jfenwick 2721 }
120 jfenwick 2795 if (!strcmp(name,"LAZY_STR_FMT"))
121 jfenwick 2737 {
122 sshaw 5320 return lazy_str_fmt;
123 jfenwick 2737 }
124 jfenwick 2742 if (!strcmp(name,"LAPACK_SUPPORT"))
125     {
126 sshaw 5320 return lapack_support;
127 jfenwick 2742 }
128 jfenwick 2769 if (!strcmp(name, "NAN_CHECK"))
129     {
130 sshaw 5320 #ifdef isnan
131     return 1;
132 jfenwick 2769 #else
133 sshaw 5320 return 0;
134 jfenwick 2769 #endif
135     }
136 jfenwick 2795 if (!strcmp(name,"LAZY_VERBOSE"))
137     {
138 sshaw 5320 return lazy_verbose;
139 jfenwick 2795 }
140 jfenwick 3906 if (!strcmp(name, "DISABLE_AMG"))
141     {
142 sshaw 5320 return amg_disabled;
143 jfenwick 3906 }
144 jfenwick 3940 if (!strcmp(name, "MPIBUILD"))
145     {
146 sshaw 5320 #ifdef ESYS_MPI
147     return 1;
148 jfenwick 3940 #else
149 sshaw 5320 return 0;
150 jfenwick 3940 #endif
151     }
152 jfenwick 4713 if (!strcmp(name, "PASO_DIRECT"))
153     {
154 sshaw 5320 // 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 jfenwick 4713 }
169 jfenwick 5322 if (!strcmp(name, "NETCDF_BUILD"))
170     {
171     return has_netcdf;
172     }
173 caltinay 6120 if (!strcmp(name, "HAVE_TRILINOS"))
174     return have_trilinos;
175 sshaw 5320 if (!strcmp(name, "GMSH_SUPPORT"))
176     return gmsh;
177     if (!strcmp(name, "GMSH_MPI"))
178     return gmsh_mpi;
179 jfenwick 1897 return sentinel;
180     }
181    
182     void
183     EscriptParams::setInt(const char* name, int value)
184     {
185 sshaw 5339 // Note: there is no way to modify the LAPACK_SUPPORT variable ATM
186     if (!strcmp(name,"TOO_MANY_LINES"))
187 sshaw 5320 too_many_lines=value;
188 sshaw 5339 else if (!strcmp(name,"AUTOLAZY"))
189 sshaw 5320 autolazy=!(value==0); // set to 1 or zero
190 sshaw 5339 else if (!strcmp(name,"TOO_MANY_LEVELS"))
191 sshaw 5320 too_many_levels=value;
192 sshaw 5339 else if (!strcmp(name,"RESOLVE_COLLECTIVE"))
193 sshaw 5320 resolve_collective=value;
194 sshaw 5339 else if (!strcmp(name,"LAZY_STR_FMT"))
195 sshaw 5320 lazy_str_fmt=value;
196 sshaw 5339 else if (!strcmp(name,"LAZY_VERBOSE"))
197 sshaw 5320 lazy_verbose=value;
198 sshaw 5339 else
199 caltinay 5972 throw EsysException("Invalid parameter name");
200 jfenwick 1897 }
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 jfenwick 2142 boost::python::list
216 jfenwick 2721 EscriptParams::listEscriptParams()
217 jfenwick 2142 {
218     using namespace boost::python;
219     boost::python::list l;
220 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."));
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 jfenwick 2795 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 jfenwick 3906 l.append(make_tuple("DISABLE_AMG", amg_disabled, "{0,1} AMG is disabled."));
227 jfenwick 5322 l.append(make_tuple("NETCDF_BUILD", has_netcdf, "{0,1} Was this build made with netcdf libraries?"));
228 caltinay 6120 l.append(make_tuple("HAVE_TRILINOS", have_trilinos, "{0,1} Was this build made with trilinos libraries?"));
229 jfenwick 5336 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 jfenwick 2142 return l;
232     }
233 jfenwick 1897
234 caltinay 5997 } // end namespace
235 jfenwick 2142

  ViewVC Help
Powered by ViewVC 1.1.26