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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5593 - (hide annotations)
Fri Apr 24 01:36:26 2015 UTC (3 years, 11 months ago) by jfenwick
File size: 6294 byte(s)
Fixing institution name to comply with policy
1 jfenwick 1897
2    
3 jfenwick 3981 /*****************************************************************************
4 jfenwick 1897 *
5 jfenwick 5593 * Copyright (c) 2003-2015 by The 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 5464 #define ESNEEDPYTHON
19     #include "esysUtils/first.h"
20    
21    
22 jfenwick 2142 #include "EscriptParams.h"
23 jfenwick 1897 #include <cstring>
24 jfenwick 2142 #include <boost/python/tuple.hpp>
25 sshaw 5320 #include <cmath> // to test if we know how to check for nan
26 jfenwick 1897
27 sshaw 5339 #include "esysUtils/EsysException.h"
28 jfenwick 4713 #include "esysUtils/Esys_MPI.h"
29    
30 jfenwick 1897 namespace escript
31     {
32    
33 sshaw 5320 EscriptParams escriptParams; // externed in header file
34 jfenwick 1897
35    
36     EscriptParams::EscriptParams()
37     {
38     too_many_lines=80;
39 jfenwick 2146 autolazy=0;
40 jfenwick 2501 too_many_levels=70;
41 jfenwick 2795 lazy_str_fmt=0;
42     lazy_verbose=0;
43 jfenwick 5322 #ifdef USE_NETCDF
44     has_netcdf=1;
45     #else
46     has_netcdf=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 sshaw 5320 if (!strcmp(name, "GMSH_SUPPORT"))
174     return gmsh;
175     if (!strcmp(name, "GMSH_MPI"))
176     return gmsh_mpi;
177 jfenwick 1897 return sentinel;
178     }
179    
180     void
181     EscriptParams::setInt(const char* name, int value)
182     {
183 sshaw 5339 // Note: there is no way to modify the LAPACK_SUPPORT variable ATM
184     if (!strcmp(name,"TOO_MANY_LINES"))
185 sshaw 5320 too_many_lines=value;
186 sshaw 5339 else if (!strcmp(name,"AUTOLAZY"))
187 sshaw 5320 autolazy=!(value==0); // set to 1 or zero
188 sshaw 5339 else if (!strcmp(name,"TOO_MANY_LEVELS"))
189 sshaw 5320 too_many_levels=value;
190 sshaw 5339 else if (!strcmp(name,"RESOLVE_COLLECTIVE"))
191 sshaw 5320 resolve_collective=value;
192 sshaw 5339 else if (!strcmp(name,"LAZY_STR_FMT"))
193 sshaw 5320 lazy_str_fmt=value;
194 sshaw 5339 else if (!strcmp(name,"LAZY_VERBOSE"))
195 sshaw 5320 lazy_verbose=value;
196 sshaw 5339 else
197     throw esysUtils::EsysException("Invalid parameter name");
198 jfenwick 1897 }
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 jfenwick 2142 boost::python::list
214 jfenwick 2721 EscriptParams::listEscriptParams()
215 jfenwick 2142 {
216     using namespace boost::python;
217     boost::python::list l;
218 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."));
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 jfenwick 2795 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 jfenwick 3906 l.append(make_tuple("DISABLE_AMG", amg_disabled, "{0,1} AMG is disabled."));
225 jfenwick 5322 l.append(make_tuple("NETCDF_BUILD", has_netcdf, "{0,1} Was this build made with netcdf libraries?"));
226 jfenwick 5336 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 jfenwick 2142 return l;
229     }
230 jfenwick 1897
231 jfenwick 2142
232 jfenwick 2721
233    
234 sshaw 5320 } // end namespace

  ViewVC Help
Powered by ViewVC 1.1.26