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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5322 - (hide annotations)
Tue Dec 9 03:53:35 2014 UTC (4 years, 4 months ago) by jfenwick
File size: 5962 byte(s)
Added NETCDF_BUILD to escript params. Tests now check this before testing netcdf dependent stuff
1 jfenwick 1897
2    
3 jfenwick 3981 /*****************************************************************************
4 jfenwick 1897 *
5 jfenwick 4657 * Copyright (c) 2003-2014 by University of Queensland
6 jfenwick 3981 * http://www.uq.edu.au
7 jfenwick 1897 *
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 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 jfenwick 2142 #include "EscriptParams.h"
19 jfenwick 1897 #include <cstring>
20 jfenwick 2142 #include <boost/python/tuple.hpp>
21 sshaw 5320 #include <cmath> // to test if we know how to check for nan
22 jfenwick 1897
23 jfenwick 4713
24     #include "esysUtils/Esys_MPI.h"
25    
26 jfenwick 1897 namespace escript
27     {
28    
29 sshaw 5320 EscriptParams escriptParams; // externed in header file
30 jfenwick 1897
31    
32     EscriptParams::EscriptParams()
33     {
34     too_many_lines=80;
35 jfenwick 2146 autolazy=0;
36 jfenwick 2501 too_many_levels=70;
37 jfenwick 2795 lazy_str_fmt=0;
38     lazy_verbose=0;
39 jfenwick 5322 #ifdef USE_NETCDF
40     has_netcdf=1;
41     #else
42     has_netcdf=0;
43     #endif
44 jfenwick 2742 #ifdef USE_LAPACK
45     lapack_support=1;
46     #else
47     lapack_support=0;
48     #endif
49 jfenwick 2721
50 sshaw 5320 gmsh = gmsh_mpi = 0;
51     #if defined(GMSH) || defined(GMSH_MPI)
52     gmsh = 1;
53 jfenwick 2721 #endif
54 sshaw 5320 //only mark gmsh as mpi if escript built with mpi, otherwise comm_spawns
55     //might just fail terribly
56     #if defined(GMSH_MPI) && defined(ESYS_MPI)
57     gmsh_mpi = 1;
58 jfenwick 2721 #endif
59    
60 jfenwick 3906 #ifdef ESYS_MPI
61 sshaw 5320 amg_disabled=true;
62 jfenwick 3906 #else
63 sshaw 5320 amg_disabled=false;
64 jfenwick 3906 #endif
65    
66 sshaw 5320 temp_direct_solver=false; // This variable is to be removed once proper
67     // SolverOptions support is in place
68 jfenwick 4713 #ifdef MKL
69     temp_direct_solver=true;
70     #endif
71 caltinay 5228 #ifdef USE_UMFPACK
72     temp_direct_solver=true;
73 jfenwick 4713 #endif
74     #ifdef PASTIX
75     temp_direct_solver=true;
76     #endif
77 jfenwick 3906
78 sshaw 5320 // These #defs are for performance testing only
79     // in general, I don't want people tweaking the
80     // default value using compiler options
81     // I've provided a python interface for that
82     #ifdef FAUTOLAZYON
83     autolazy=1;
84     #endif
85     #ifdef FAUTOLAZYOFF
86     autolazy=0;
87     #endif
88    
89     #ifdef FRESCOLLECTON
90     resolve_collective=1;
91     #endif
92     #ifdef FRESCOLLECTOFF
93     resolve_collective=0;
94     #endif
95 jfenwick 1897 }
96    
97     int
98     EscriptParams::getInt(const char* name, int sentinel) const
99     {
100     if (!strcmp(name,"TOO_MANY_LINES"))
101     {
102 sshaw 5320 return too_many_lines;
103 jfenwick 1897 }
104 jfenwick 2146 if (!strcmp(name,"AUTOLAZY"))
105     {
106 sshaw 5320 return autolazy;
107 jfenwick 2146 }
108 jfenwick 2472 if (!strcmp(name,"TOO_MANY_LEVELS"))
109     {
110 sshaw 5320 return too_many_levels;
111 jfenwick 2472 }
112 jfenwick 2721 if (!strcmp(name,"RESOLVE_COLLECTIVE"))
113     {
114 sshaw 5320 return resolve_collective;
115 jfenwick 2721 }
116 jfenwick 2795 if (!strcmp(name,"LAZY_STR_FMT"))
117 jfenwick 2737 {
118 sshaw 5320 return lazy_str_fmt;
119 jfenwick 2737 }
120 jfenwick 2742 if (!strcmp(name,"LAPACK_SUPPORT"))
121     {
122 sshaw 5320 return lapack_support;
123 jfenwick 2742 }
124 jfenwick 2769 if (!strcmp(name, "NAN_CHECK"))
125     {
126 sshaw 5320 #ifdef isnan
127     return 1;
128 jfenwick 2769 #else
129 sshaw 5320 return 0;
130 jfenwick 2769 #endif
131     }
132 jfenwick 2795 if (!strcmp(name,"LAZY_VERBOSE"))
133     {
134 sshaw 5320 return lazy_verbose;
135 jfenwick 2795 }
136 jfenwick 3906 if (!strcmp(name, "DISABLE_AMG"))
137     {
138 sshaw 5320 return amg_disabled;
139 jfenwick 3906 }
140 jfenwick 3940 if (!strcmp(name, "MPIBUILD"))
141     {
142 sshaw 5320 #ifdef ESYS_MPI
143     return 1;
144 jfenwick 3940 #else
145 sshaw 5320 return 0;
146 jfenwick 3940 #endif
147     }
148 jfenwick 4713 if (!strcmp(name, "PASO_DIRECT"))
149     {
150 sshaw 5320 // This is not in the constructor because escriptparams could be constructed
151     // before main (and hence no opportunity to call INIT)
152     #ifdef ESYS_MPI
153     int size;
154     if (MPI_Comm_size(MPI_COMM_WORLD, &size)!=MPI_SUCCESS) // This would break in a subworld
155     {
156     temp_direct_solver=false;
157     }
158     if (size>1)
159     {
160     temp_direct_solver=false;
161     }
162     #endif
163     return temp_direct_solver;
164 jfenwick 4713 }
165 jfenwick 5322 if (!strcmp(name, "NETCDF_BUILD"))
166     {
167     return has_netcdf;
168     }
169 sshaw 5320 if (!strcmp(name, "GMSH_SUPPORT"))
170     return gmsh;
171     if (!strcmp(name, "GMSH_MPI"))
172     return gmsh_mpi;
173 jfenwick 1897 return sentinel;
174     }
175    
176     void
177     EscriptParams::setInt(const char* name, int value)
178     {
179     if (!strcmp(name,"TOO_MANY_LINES"))
180     {
181 sshaw 5320 too_many_lines=value;
182 jfenwick 1897 }
183 jfenwick 2146 if (!strcmp(name,"AUTOLAZY"))
184     {
185 sshaw 5320 autolazy=!(value==0); // set to 1 or zero
186 jfenwick 2146 }
187 jfenwick 2472 if (!strcmp(name,"TOO_MANY_LEVELS"))
188     {
189 sshaw 5320 too_many_levels=value;
190 jfenwick 2472 }
191 jfenwick 2721 if (!strcmp(name,"RESOLVE_COLLECTIVE"))
192     {
193 sshaw 5320 resolve_collective=value;
194 jfenwick 2721 }
195 jfenwick 2795 if (!strcmp(name,"LAZY_STR_FMT"))
196 jfenwick 2737 {
197 sshaw 5320 lazy_str_fmt=value;
198 jfenwick 2737 }
199 jfenwick 2795 if (!strcmp(name,"LAZY_VERBOSE"))
200     {
201 sshaw 5320 lazy_verbose=value;
202 jfenwick 2795 }
203 caltinay 4286 // Note: there is no way to modify the LAPACK_SUPPORT variable ATM
204 jfenwick 1897 }
205    
206     void
207     setEscriptParamInt(const char* name, int value)
208     {
209     escriptParams.setInt(name,value);
210     }
211    
212    
213     int
214     getEscriptParamInt(const char* name, int sentinel)
215     {
216     return escriptParams.getInt(name, sentinel);
217     }
218    
219 jfenwick 2142 boost::python::list
220 jfenwick 2721 EscriptParams::listEscriptParams()
221 jfenwick 2142 {
222     using namespace boost::python;
223     boost::python::list l;
224 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."));
225     l.append(make_tuple("AUTOLAZY", autolazy, "{0,1} Operations involving Expanded Data will create lazy results."));
226     l.append(make_tuple("RESOLVE_COLLECTIVE",resolve_collective ,"(TESTING ONLY) {0.1} Collective operations will resolve their data."));
227     l.append(make_tuple("TOO_MANY_LEVELS", too_many_levels, "(TESTING ONLY) maximum levels allowed in an expression."));
228 jfenwick 2795 l.append(make_tuple("LAZY_STR_FMT", lazy_str_fmt, "{0,1,2}(TESTING ONLY) change output format for lazy expressions."));
229     l.append(make_tuple("LAZY_VERBOSE", lazy_verbose, "{0,1} Print a warning when expressions are resolved because they are too large."));
230 jfenwick 3906 l.append(make_tuple("DISABLE_AMG", amg_disabled, "{0,1} AMG is disabled."));
231 jfenwick 5322 l.append(make_tuple("NETCDF_BUILD", has_netcdf, "{0,1} Was this build made with netcdf libraries?"));
232 jfenwick 2142 return l;
233     }
234 jfenwick 1897
235 jfenwick 2142
236 jfenwick 2721
237    
238 sshaw 5320 } // end namespace

  ViewVC Help
Powered by ViewVC 1.1.26