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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5997 - (hide annotations)
Mon Feb 29 07:24:47 2016 UTC (3 years, 1 month ago) by caltinay
File size: 6208 byte(s)
moved esys MPI to escript.

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

  ViewVC Help
Powered by ViewVC 1.1.26