1 |
|
2 |
|
3 |
/******************************************************* |
4 |
* |
5 |
* Copyright (c) 2003-2009 by University of Queensland |
6 |
* Earth Systems Science Computational Center (ESSCC) |
7 |
* http://www.uq.edu.au/esscc |
8 |
* |
9 |
* Primary Business: Queensland, Australia |
10 |
* Licensed under the Open Software License version 3.0 |
11 |
* http://www.opensource.org/licenses/osl-3.0.php |
12 |
* |
13 |
*******************************************************/ |
14 |
|
15 |
#include "EscriptParams.h" |
16 |
#include <cstring> |
17 |
#include <boost/python/tuple.hpp> |
18 |
#include <cmath> // to test if we know how to check for nan |
19 |
|
20 |
namespace escript |
21 |
{ |
22 |
|
23 |
EscriptParams escriptParams; // externed in header file |
24 |
|
25 |
|
26 |
EscriptParams::EscriptParams() |
27 |
{ |
28 |
too_many_lines=80; |
29 |
autolazy=0; |
30 |
too_many_levels=70; |
31 |
too_many_nodes=15000; |
32 |
resolve_collective=0; |
33 |
print_lazy_tree=0; |
34 |
|
35 |
#ifdef USE_LAPACK |
36 |
lapack_support=1; |
37 |
#else |
38 |
lapack_support=0; |
39 |
#endif |
40 |
// These #defs are for performance testing only |
41 |
// in general, I don't want people tweaking the |
42 |
// default value using compiler options |
43 |
// I've provided a python interface for that |
44 |
#ifdef FAUTOLAZYON |
45 |
autolazy=1; |
46 |
#endif |
47 |
#ifdef FAUTOLAZYOFF |
48 |
autolazy=0; |
49 |
#endif |
50 |
|
51 |
#ifdef FRESCOLLECTON |
52 |
resolve_collective=1; |
53 |
#endif |
54 |
#ifdef FRESCOLLECTOFF |
55 |
resolve_collective=0; |
56 |
#endif |
57 |
|
58 |
} |
59 |
|
60 |
int |
61 |
EscriptParams::getInt(const char* name, int sentinel) const |
62 |
{ |
63 |
if (!strcmp(name,"TOO_MANY_LINES")) |
64 |
{ |
65 |
return too_many_lines; |
66 |
} |
67 |
if (!strcmp(name,"AUTOLAZY")) |
68 |
{ |
69 |
return autolazy; |
70 |
} |
71 |
if (!strcmp(name,"TOO_MANY_LEVELS")) |
72 |
{ |
73 |
return too_many_levels; |
74 |
} |
75 |
if (!strcmp(name,"TOO_MANY_NODES")) |
76 |
{ |
77 |
return too_many_nodes; |
78 |
} |
79 |
if (!strcmp(name,"RESOLVE_COLLECTIVE")) |
80 |
{ |
81 |
return resolve_collective; |
82 |
} |
83 |
if (!strcmp(name,"PRINT_LAZY_TREE")) |
84 |
{ |
85 |
return print_lazy_tree; |
86 |
} |
87 |
if (!strcmp(name,"LAPACK_SUPPORT")) |
88 |
{ |
89 |
return lapack_support; |
90 |
} |
91 |
if (!strcmp(name, "NAN_CHECK")) |
92 |
{ |
93 |
#ifdef isnan |
94 |
return 1; |
95 |
#else |
96 |
return 0; |
97 |
#endif |
98 |
} |
99 |
return sentinel; |
100 |
} |
101 |
|
102 |
void |
103 |
EscriptParams::setInt(const char* name, int value) |
104 |
{ |
105 |
if (!strcmp(name,"TOO_MANY_LINES")) |
106 |
{ |
107 |
too_many_lines=value; |
108 |
} |
109 |
if (!strcmp(name,"AUTOLAZY")) |
110 |
{ |
111 |
autolazy=!(value==0); // set to 1 or zero |
112 |
} |
113 |
if (!strcmp(name,"TOO_MANY_LEVELS")) |
114 |
{ |
115 |
too_many_levels=value; |
116 |
} |
117 |
if (!strcmp(name,"TOO_MANY_NODES")) |
118 |
{ |
119 |
too_many_nodes=value; |
120 |
} |
121 |
if (!strcmp(name,"RESOLVE_COLLECTIVE")) |
122 |
{ |
123 |
resolve_collective=value; |
124 |
} |
125 |
if (!strcmp(name,"PRINT_LAZY_TREE")) |
126 |
{ |
127 |
print_lazy_tree=value; |
128 |
} |
129 |
// Note: there is no way to modifiy the LAPACK_SUPPORT variable atm |
130 |
} |
131 |
|
132 |
void |
133 |
setEscriptParamInt(const char* name, int value) |
134 |
{ |
135 |
escriptParams.setInt(name,value); |
136 |
} |
137 |
|
138 |
|
139 |
int |
140 |
getEscriptParamInt(const char* name, int sentinel) |
141 |
{ |
142 |
return escriptParams.getInt(name, sentinel); |
143 |
} |
144 |
|
145 |
boost::python::list |
146 |
EscriptParams::listEscriptParams() |
147 |
{ |
148 |
using namespace boost::python; |
149 |
boost::python::list l; |
150 |
l.append(make_tuple("TOO_MANY_LINES", too_many_lines, "Maximum number of lines to output when printing data before printing a summary instead.")); |
151 |
l.append(make_tuple("AUTOLAZY", autolazy, "{0,1} Operations involving Expanded Data will create lazy results.")); |
152 |
l.append(make_tuple("RESOLVE_COLLECTIVE",resolve_collective ,"(TESTING ONLY) {0.1} Collective operations will resolve their data.")); |
153 |
l.append(make_tuple("TOO_MANY_LEVELS", too_many_levels, "(TESTING ONLY) maximum levels allowed in an expression.")); |
154 |
l.append(make_tuple("TOO_MANY_NODES", too_many_nodes, "(TESTING ONLY) maximum number of nodes in a expression.")); |
155 |
return l; |
156 |
} |
157 |
|
158 |
|
159 |
|
160 |
|
161 |
} // end namespace |