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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2769 - (hide annotations)
Tue Nov 24 00:36:22 2009 UTC (9 years, 4 months ago) by jfenwick
Original Path: trunk/escript/src/EscriptParams.cpp
File size: 3546 byte(s)
Unit tests for NaN handling
1 jfenwick 1897
2    
3     /*******************************************************
4     *
5 jfenwick 2548 * Copyright (c) 2003-2009 by University of Queensland
6 jfenwick 1897 * 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 jfenwick 2142 #include "EscriptParams.h"
16 jfenwick 1897 #include <cstring>
17 jfenwick 2142 #include <boost/python/tuple.hpp>
18 jfenwick 2769 #include <cmath> // to test if we know how to check for nan
19 jfenwick 1897
20     namespace escript
21     {
22    
23     EscriptParams escriptParams; // externed in header file
24    
25    
26     EscriptParams::EscriptParams()
27     {
28     too_many_lines=80;
29 jfenwick 2146 autolazy=0;
30 jfenwick 2501 too_many_levels=70;
31     too_many_nodes=15000;
32 jfenwick 2721 resolve_collective=0;
33 jfenwick 2737 print_lazy_tree=0;
34 jfenwick 2742
35     #ifdef USE_LAPACK
36     lapack_support=1;
37     #else
38     lapack_support=0;
39     #endif
40 jfenwick 2273 // 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 jfenwick 2721
51     #ifdef FRESCOLLECTON
52     resolve_collective=1;
53     #endif
54     #ifdef FRESCOLLECTOFF
55     resolve_collective=0;
56     #endif
57    
58 jfenwick 1897 }
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 jfenwick 2146 if (!strcmp(name,"AUTOLAZY"))
68     {
69     return autolazy;
70     }
71 jfenwick 2472 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 jfenwick 2721 if (!strcmp(name,"RESOLVE_COLLECTIVE"))
80     {
81     return resolve_collective;
82     }
83 jfenwick 2737 if (!strcmp(name,"PRINT_LAZY_TREE"))
84     {
85     return print_lazy_tree;
86     }
87 jfenwick 2742 if (!strcmp(name,"LAPACK_SUPPORT"))
88     {
89     return lapack_support;
90     }
91 jfenwick 2769 if (!strcmp(name, "NAN_CHECK"))
92     {
93     #ifdef FP_NAN
94     return 1;
95     #else
96     return 0;
97     #endif
98     }
99 jfenwick 1897 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 jfenwick 2146 if (!strcmp(name,"AUTOLAZY"))
110     {
111     autolazy=!(value==0); // set to 1 or zero
112     }
113 jfenwick 2472 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 jfenwick 2721 if (!strcmp(name,"RESOLVE_COLLECTIVE"))
122     {
123     resolve_collective=value;
124     }
125 jfenwick 2737 if (!strcmp(name,"PRINT_LAZY_TREE"))
126     {
127     print_lazy_tree=value;
128     }
129 jfenwick 2742 // Note: there is no way to modifiy the LAPACK_SUPPORT variable atm
130 jfenwick 1897 }
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 jfenwick 2142 boost::python::list
146 jfenwick 2721 EscriptParams::listEscriptParams()
147 jfenwick 2142 {
148     using namespace boost::python;
149     boost::python::list l;
150 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."));
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 jfenwick 2142 return l;
156     }
157 jfenwick 1897
158 jfenwick 2142
159 jfenwick 2721
160    
161 jfenwick 1897 } // end namespace

  ViewVC Help
Powered by ViewVC 1.1.26