OpenMPI 0.1.1

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

vt_filterc.h
1 /**
2 * VampirTrace
3 * http://www.tu-dresden.de/zih/vampirtrace
4 *
5 * Copyright (c) 2005-2012, ZIH, TU Dresden, Federal Republic of Germany
6 *
7 * Copyright (c) 1998-2005, Forschungszentrum Juelich, Juelich Supercomputing
8 * Centre, Federal Republic of Germany
9 *
10 * See the file COPYING in the package base directory for details
11 **/
12
13 #ifndef _VT_FILTERC_H_
14 #define _VT_FILTERC_H_
15
16 #include <set>
17 #include <map>
18 #include <stack>
19 #include <string>
20 #include <vector>
21 #include <algorithm>
22
23 #include "vt_inttypes.h"
24
25 #ifdef VT_MPI
26 # include "vt_defs.h" // to get VT_MPI_INT
27 # include "mpi.h"
28 #endif // VT_MPI
29
30 struct Function {
31
32 uint32_t id;
33
34 std::string name;
35
36 std::set<uint32_t> subFuncs;
37
38 uint64_t invocations;
39
40 /* maximum depth of functions under itself */
41 uint32_t depth;
42
43 /* accumulated duration time in ticks
44 divided by the number of invocations it is the average duration */
45 int64_t accDurationExcl;
46 int64_t accDurationIncl;
47
48
49 Function() :
50 id(0), invocations(0), depth(0), accDurationExcl(0), accDurationIncl(0) {}
51
52 Function( uint32_t _id, const std::string& nm ) :
53 id(_id), name(nm), invocations(0), depth(0), accDurationExcl(0), accDurationIncl(0) {}
54
55 bool operator<( const Function& func ) const {
56
57 /* order function by depth, subfunction count and invocation count */
58 if( depth != func.depth ) return depth < func.depth;
59 else if( subFuncs.size() != func.subFuncs.size() ) return subFuncs.size() < func.subFuncs.size();
60 else return invocations > func.invocations;
61 }
62
63 void operator+=( const Function& func ) {
64 invocations += func.invocations;
65 if( depth < func.depth ) depth = func.depth;
66 accDurationExcl += func.accDurationExcl;
67 accDurationIncl += func.accDurationIncl;
68
69 std::set<uint32_t>::const_iterator itsf;
70
71 for( itsf = func.subFuncs.begin(); itsf != func.subFuncs.end(); ++itsf ) {
72 if( subFuncs.find( *itsf ) == subFuncs.end() ) subFuncs.insert( *itsf );
73 }
74 }
75
76 #ifdef VT_MPI
77 VT_MPI_INT getPackSize( void );
78 void packBuffer( char*& buffer, const VT_MPI_INT& buffersize, VT_MPI_INT& bufferpos );
79 void unpackBuffer( char*& buffer, const VT_MPI_INT& buffersize, VT_MPI_INT& bufferpos );
80 #endif // VT_MPI
81 };
82
83
84
85 struct StackItem {
86
87 StackItem( std::map<uint32_t, Function>::iterator _it ) : it( _it ) {}
88
89 std::map<uint32_t, Function>::iterator it;
90 };
91
92
93 struct PostStackItem {
94
95 PostStackItem( uint32_t _id, const std::set<uint32_t>& vs ) :
96 id( _id ), visited( vs ) { visited.insert( _id ); }
97
98 uint32_t id;//
99
100 std::set<uint32_t> visited;
101 };
102
103
104 class Filter {
105
106 public:
107
108 Filter();
109
110 void setTimerResolution( uint64_t tickspersecond );
111 void addFunction( uint32_t func, const std::string& name );
112 void addEnter( uint32_t func, uint32_t process, uint64_t time );
113 void addLeave( uint32_t process, uint64_t time );
114
115 void incrMessageCount()
116 { ++messageCount; }
117 void incrCollectiveCount()
118 { ++collectiveCount; }
119
120
121 /* calculates 'maxStackDepth', 'totalInvocations', 'maxInvocations'
122 * calculates the 'depth' of every function
123 */
124 void postProcessing();
125
126
127
128 /* returns a set of functions ordered by their importance for filtering
129 * 1. stackdepth 2. subfunction count 3. invocation count
130 */
131 std::vector<Function> getFunctions() const;
132
133
134 /* Reduces the count of events to 'percent' percent.
135 * It does not filter functions included in 'excludesymbols'.
136 * Returns a set of function tokens, which have been filtered.
137 */
138 std::set<uint32_t> reduceTo( float* percent,
139 const std::set<uint32_t>& excludesymbols,
140 const std::set<uint32_t>& includesymbols,
141 bool includechildren,
142 uint64_t limit );
143
144
145 uint32_t getMaxStackDepth() const { return maxStackDepth; }
146 uint64_t getTotalInvocations() const { return totalInvocations; }
147 uint64_t getMaxInvocations() const { return maxInvocations; }
148 uint64_t getTimerResolution() const { return timerResolution; }
149 uint64_t getMessageCount() const { return messageCount; }
150 uint64_t getCollectiveCount() const { return collectiveCount; }
151
152 void operator+=( const Filter& filter );
153
154 const std::map<uint32_t, Function>& getFunctionMap() const { return functions; }
155
156 #ifdef VT_MPI
157 VT_MPI_INT getPackSize( void );
158 void packBuffer( char*& buffer, const VT_MPI_INT& buffersize, VT_MPI_INT& bufferpos );
159 void unpackBuffer( char*& buffer, const VT_MPI_INT& buffersize, VT_MPI_INT& bufferpos );
160 #endif // VT_MPI
161
162
163 protected:
164
165 /* visites a function and its children (recursively) to gather information
166 about the stackdepth.
167 If killed is not NULL it adds the visited functions to the set and
168 counts the killed invocations */
169 uint32_t visitFunction( std::stack<PostStackItem>& stck,
170 std::set<uint32_t>* killed, uint64_t* killedinvocations,
171 const std::set<uint32_t>* nokill );
172
173 /* visites a function and its children (recursively) in order to
174 add the parents of nokill-functions to the nokill-set as well */
175 void visitFunctionExclude( std::stack<PostStackItem>& stck,
176 std::set<uint32_t>& nokill );
177
178 protected:
179
180 uint32_t maxStackDepth;
181 uint64_t totalInvocations;
182 uint64_t maxInvocations;
183 uint64_t timerResolution;
184
185 uint64_t messageCount;
186 uint64_t collectiveCount;
187
188 /* all functions */
189 std::map<uint32_t /*token*/, Function> functions;
190
191 std::map<uint32_t /*procid*/, std::stack< StackItem > > callStack;
192 };
193
194
195 #endif /* _VT_FILTERC_H_ */
196
Filter
Definition: vt_filterc.h:104
Function
VampirTrace http://www.tu-dresden.de/zih/vampirtrace.
Definition: vt_filterc.h:30
PostStackItem
Definition: vt_filterc.h:93
StackItem
Definition: vt_filterc.h:85