Intel(R) Threading Building Blocks Doxygen Documentation  version 4.2.3
_flow_graph_trace_impl.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2005-2019 Intel Corporation
3 
4  Licensed under the Apache License, Version 2.0 (the "License");
5  you may not use this file except in compliance with the License.
6  You may obtain a copy of the License at
7 
8  http://www.apache.org/licenses/LICENSE-2.0
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 
16 
17 
18 
19 */
20 
21 #ifndef _FGT_GRAPH_TRACE_IMPL_H
22 #define _FGT_GRAPH_TRACE_IMPL_H
23 
24 #include "../tbb_profiling.h"
25 
26 namespace tbb {
27  namespace internal {
28 
29 #if TBB_USE_THREADING_TOOLS
30 
31 static inline void fgt_alias_port(void *node, void *p, bool visible) {
32  if(visible)
33  itt_relation_add( ITT_DOMAIN_FLOW, node, FLOW_NODE, __itt_relation_is_parent_of, p, FLOW_NODE );
34  else
35  itt_relation_add( ITT_DOMAIN_FLOW, p, FLOW_NODE, __itt_relation_is_child_of, node, FLOW_NODE );
36 }
37 
38 static inline void fgt_composite ( void *node, void *graph ) {
39  itt_make_task_group( ITT_DOMAIN_FLOW, node, FLOW_NODE, graph, FLOW_GRAPH, FLOW_COMPOSITE_NODE );
40 }
41 
42 static inline void fgt_internal_alias_input_port( void *node, void *p, string_index name_index ) {
43  itt_make_task_group( ITT_DOMAIN_FLOW, p, FLOW_INPUT_PORT, node, FLOW_NODE, name_index );
44  itt_relation_add( ITT_DOMAIN_FLOW, node, FLOW_NODE, __itt_relation_is_parent_of, p, FLOW_INPUT_PORT );
45 }
46 
47 static inline void fgt_internal_alias_output_port( void *node, void *p, string_index name_index ) {
48  itt_make_task_group( ITT_DOMAIN_FLOW, p, FLOW_OUTPUT_PORT, node, FLOW_NODE, name_index );
49  itt_relation_add( ITT_DOMAIN_FLOW, node, FLOW_NODE, __itt_relation_is_parent_of, p, FLOW_OUTPUT_PORT );
50 }
51 
52 template<typename InputType>
53 void alias_input_port(void *node, tbb::flow::receiver<InputType>* port, string_index name_index) {
54  // TODO: Make fgt_internal_alias_input_port a function template?
55  fgt_internal_alias_input_port( node, port, name_index);
56 }
57 
58 template < typename PortsTuple, int N >
59 struct fgt_internal_input_alias_helper {
60  static void alias_port( void *node, PortsTuple &ports ) {
61  alias_input_port( node, &(tbb::flow::get<N-1>(ports)), static_cast<tbb::internal::string_index>(FLOW_INPUT_PORT_0 + N - 1) );
63  }
64 };
65 
66 template < typename PortsTuple >
67 struct fgt_internal_input_alias_helper<PortsTuple, 0> {
68  static void alias_port( void * /* node */, PortsTuple & /* ports */ ) { }
69 };
70 
71 template<typename OutputType>
72 void alias_output_port(void *node, tbb::flow::sender<OutputType>* port, string_index name_index) {
73  // TODO: Make fgt_internal_alias_output_port a function template?
74  fgt_internal_alias_output_port( node, static_cast<void *>(port), name_index);
75 }
76 
77 template < typename PortsTuple, int N >
78 struct fgt_internal_output_alias_helper {
79  static void alias_port( void *node, PortsTuple &ports ) {
80  alias_output_port( node, &(tbb::flow::get<N-1>(ports)), static_cast<tbb::internal::string_index>(FLOW_OUTPUT_PORT_0 + N - 1) );
82  }
83 };
84 
85 template < typename PortsTuple >
86 struct fgt_internal_output_alias_helper<PortsTuple, 0> {
87  static void alias_port( void * /*node*/, PortsTuple &/*ports*/ ) {
88  }
89 };
90 
91 static inline void fgt_internal_create_input_port( void *node, void *p, string_index name_index ) {
92  itt_make_task_group( ITT_DOMAIN_FLOW, p, FLOW_INPUT_PORT, node, FLOW_NODE, name_index );
93 }
94 
95 static inline void fgt_internal_create_output_port( void *node, void *p, string_index name_index ) {
96  itt_make_task_group( ITT_DOMAIN_FLOW, p, FLOW_OUTPUT_PORT, node, FLOW_NODE, name_index );
97 }
98 
99 template<typename InputType>
100 void register_input_port(void *node, tbb::flow::receiver<InputType>* port, string_index name_index) {
101  // TODO: Make fgt_internal_create_input_port a function template?
102  // In C++03 dependent name lookup from the template definition context
103  // works only for function declarations with external linkage:
104  // http://www.open-std.org/JTC1/SC22/WG21/docs/cwg_defects.html#561
105  fgt_internal_create_input_port(node, static_cast<void*>(port), name_index);
106 }
107 
108 template < typename PortsTuple, int N >
109 struct fgt_internal_input_helper {
110  static void register_port( void *node, PortsTuple &ports ) {
111  register_input_port( node, &(tbb::flow::get<N-1>(ports)), static_cast<tbb::internal::string_index>(FLOW_INPUT_PORT_0 + N - 1) );
112  fgt_internal_input_helper<PortsTuple, N-1>::register_port( node, ports );
113  }
114 };
115 
116 template < typename PortsTuple >
117 struct fgt_internal_input_helper<PortsTuple, 1> {
118  static void register_port( void *node, PortsTuple &ports ) {
119  register_input_port( node, &(tbb::flow::get<0>(ports)), FLOW_INPUT_PORT_0 );
120  }
121 };
122 
123 template<typename OutputType>
124 void register_output_port(void *node, tbb::flow::sender<OutputType>* port, string_index name_index) {
125  // TODO: Make fgt_internal_create_output_port a function template?
126  fgt_internal_create_output_port( node, static_cast<void *>(port), name_index);
127 }
128 
129 template < typename PortsTuple, int N >
130 struct fgt_internal_output_helper {
131  static void register_port( void *node, PortsTuple &ports ) {
132  register_output_port( node, &(tbb::flow::get<N-1>(ports)), static_cast<tbb::internal::string_index>(FLOW_OUTPUT_PORT_0 + N - 1) );
133  fgt_internal_output_helper<PortsTuple, N-1>::register_port( node, ports );
134  }
135 };
136 
137 template < typename PortsTuple >
138 struct fgt_internal_output_helper<PortsTuple,1> {
139  static void register_port( void *node, PortsTuple &ports ) {
140  register_output_port( node, &(tbb::flow::get<0>(ports)), FLOW_OUTPUT_PORT_0 );
141  }
142 };
143 
144 template< typename NodeType >
145 void fgt_multioutput_node_desc( const NodeType *node, const char *desc ) {
146  void *addr = (void *)( static_cast< tbb::flow::receiver< typename NodeType::input_type > * >(const_cast< NodeType *>(node)) );
147  itt_metadata_str_add( ITT_DOMAIN_FLOW, addr, FLOW_NODE, FLOW_OBJECT_NAME, desc );
148 }
149 
150 template< typename NodeType >
151 void fgt_multiinput_multioutput_node_desc( const NodeType *node, const char *desc ) {
152  void *addr = const_cast<NodeType *>(node);
153  itt_metadata_str_add( ITT_DOMAIN_FLOW, addr, FLOW_NODE, FLOW_OBJECT_NAME, desc );
154 }
155 
156 template< typename NodeType >
157 static inline void fgt_node_desc( const NodeType *node, const char *desc ) {
158  void *addr = (void *)( static_cast< tbb::flow::sender< typename NodeType::output_type > * >(const_cast< NodeType *>(node)) );
159  itt_metadata_str_add( ITT_DOMAIN_FLOW, addr, FLOW_NODE, FLOW_OBJECT_NAME, desc );
160 }
161 
162 static inline void fgt_graph_desc( void *g, const char *desc ) {
163  itt_metadata_str_add( ITT_DOMAIN_FLOW, g, FLOW_GRAPH, FLOW_OBJECT_NAME, desc );
164 }
165 
166 static inline void fgt_body( void *node, void *body ) {
167  itt_relation_add( ITT_DOMAIN_FLOW, body, FLOW_BODY, __itt_relation_is_child_of, node, FLOW_NODE );
168 }
169 
170 template< int N, typename PortsTuple >
171 static inline void fgt_multioutput_node( string_index t, void *g, void *input_port, PortsTuple &ports ) {
172  itt_make_task_group( ITT_DOMAIN_FLOW, input_port, FLOW_NODE, g, FLOW_GRAPH, t );
173  fgt_internal_create_input_port( input_port, input_port, FLOW_INPUT_PORT_0 );
174  fgt_internal_output_helper<PortsTuple, N>::register_port( input_port, ports );
175 }
176 
177 template< int N, typename PortsTuple >
178 static inline void fgt_multioutput_node_with_body( string_index t, void *g, void *input_port, PortsTuple &ports, void *body ) {
179  itt_make_task_group( ITT_DOMAIN_FLOW, input_port, FLOW_NODE, g, FLOW_GRAPH, t );
180  fgt_internal_create_input_port( input_port, input_port, FLOW_INPUT_PORT_0 );
181  fgt_internal_output_helper<PortsTuple, N>::register_port( input_port, ports );
182  fgt_body( input_port, body );
183 }
184 
185 template< int N, typename PortsTuple >
186 static inline void fgt_multiinput_node( string_index t, void *g, PortsTuple &ports, void *output_port) {
187  itt_make_task_group( ITT_DOMAIN_FLOW, output_port, FLOW_NODE, g, FLOW_GRAPH, t );
188  fgt_internal_create_output_port( output_port, output_port, FLOW_OUTPUT_PORT_0 );
189  fgt_internal_input_helper<PortsTuple, N>::register_port( output_port, ports );
190 }
191 
192 static inline void fgt_multiinput_multioutput_node( string_index t, void *n, void *g ) {
193  itt_make_task_group( ITT_DOMAIN_FLOW, n, FLOW_NODE, g, FLOW_GRAPH, t );
194 }
195 
196 static inline void fgt_node( string_index t, void *g, void *output_port ) {
197  itt_make_task_group( ITT_DOMAIN_FLOW, output_port, FLOW_NODE, g, FLOW_GRAPH, t );
198  fgt_internal_create_output_port( output_port, output_port, FLOW_OUTPUT_PORT_0 );
199 }
200 
201 static inline void fgt_node_with_body( string_index t, void *g, void *output_port, void *body ) {
202  itt_make_task_group( ITT_DOMAIN_FLOW, output_port, FLOW_NODE, g, FLOW_GRAPH, t );
203  fgt_internal_create_output_port( output_port, output_port, FLOW_OUTPUT_PORT_0 );
204  fgt_body( output_port, body );
205 }
206 
207 
208 static inline void fgt_node( string_index t, void *g, void *input_port, void *output_port ) {
209  fgt_node( t, g, output_port );
210  fgt_internal_create_input_port( output_port, input_port, FLOW_INPUT_PORT_0 );
211 }
212 
213 static inline void fgt_node_with_body( string_index t, void *g, void *input_port, void *output_port, void *body ) {
214  fgt_node_with_body( t, g, output_port, body );
215  fgt_internal_create_input_port( output_port, input_port, FLOW_INPUT_PORT_0 );
216 }
217 
218 
219 static inline void fgt_node( string_index t, void *g, void *input_port, void *decrement_port, void *output_port ) {
220  fgt_node( t, g, input_port, output_port );
221  fgt_internal_create_input_port( output_port, decrement_port, FLOW_INPUT_PORT_1 );
222 }
223 
224 static inline void fgt_make_edge( void *output_port, void *input_port ) {
226 }
227 
228 static inline void fgt_remove_edge( void *output_port, void *input_port ) {
230 }
231 
232 static inline void fgt_graph( void *g ) {
233  itt_make_task_group( ITT_DOMAIN_FLOW, g, FLOW_GRAPH, NULL, FLOW_NULL, FLOW_GRAPH );
234 }
235 
236 static inline void fgt_begin_body( void *body ) {
237  itt_task_begin( ITT_DOMAIN_FLOW, body, FLOW_BODY, NULL, FLOW_NULL, FLOW_BODY );
238 }
239 
240 static inline void fgt_end_body( void * ) {
242 }
243 
244 static inline void fgt_async_try_put_begin( void *node, void *port ) {
245  itt_task_begin( ITT_DOMAIN_FLOW, port, FLOW_OUTPUT_PORT, node, FLOW_NODE, FLOW_OUTPUT_PORT );
246 }
247 
248 static inline void fgt_async_try_put_end( void *, void * ) {
250 }
251 
252 static inline void fgt_async_reserve( void *node, void *graph ) {
253  itt_region_begin( ITT_DOMAIN_FLOW, node, FLOW_NODE, graph, FLOW_GRAPH, FLOW_NULL );
254 }
255 
256 static inline void fgt_async_commit( void *node, void * /*graph*/) {
257  itt_region_end( ITT_DOMAIN_FLOW, node, FLOW_NODE );
258 }
259 
260 static inline void fgt_reserve_wait( void *graph ) {
261  itt_region_begin( ITT_DOMAIN_FLOW, graph, FLOW_GRAPH, NULL, FLOW_NULL, FLOW_NULL );
262 }
263 
264 static inline void fgt_release_wait( void *graph ) {
265  itt_region_end( ITT_DOMAIN_FLOW, graph, FLOW_GRAPH );
266 }
267 
268 #else // TBB_USE_THREADING_TOOLS
269 
270 static inline void fgt_alias_port(void * /*node*/, void * /*p*/, bool /*visible*/ ) { }
271 
272 static inline void fgt_composite ( void * /*node*/, void * /*graph*/ ) { }
273 
274 static inline void fgt_graph( void * /*g*/ ) { }
275 
276 template< typename NodeType >
277 static inline void fgt_multioutput_node_desc( const NodeType * /*node*/, const char * /*desc*/ ) { }
278 
279 template< typename NodeType >
280 static inline void fgt_node_desc( const NodeType * /*node*/, const char * /*desc*/ ) { }
281 
282 static inline void fgt_graph_desc( void * /*g*/, const char * /*desc*/ ) { }
283 
284 static inline void fgt_body( void * /*node*/, void * /*body*/ ) { }
285 
286 template< int N, typename PortsTuple >
287 static inline void fgt_multioutput_node( string_index /*t*/, void * /*g*/, void * /*input_port*/, PortsTuple & /*ports*/ ) { }
288 
289 template< int N, typename PortsTuple >
290 static inline void fgt_multioutput_node_with_body( string_index /*t*/, void * /*g*/, void * /*input_port*/, PortsTuple & /*ports*/, void * /*body*/ ) { }
291 
292 template< int N, typename PortsTuple >
293 static inline void fgt_multiinput_node( string_index /*t*/, void * /*g*/, PortsTuple & /*ports*/, void * /*output_port*/ ) { }
294 
295 static inline void fgt_multiinput_multioutput_node( string_index /*t*/, void * /*node*/, void * /*graph*/ ) { }
296 
297 static inline void fgt_node( string_index /*t*/, void * /*g*/, void * /*output_port*/ ) { }
298 static inline void fgt_node( string_index /*t*/, void * /*g*/, void * /*input_port*/, void * /*output_port*/ ) { }
299 static inline void fgt_node( string_index /*t*/, void * /*g*/, void * /*input_port*/, void * /*decrement_port*/, void * /*output_port*/ ) { }
300 
301 static inline void fgt_node_with_body( string_index /*t*/, void * /*g*/, void * /*output_port*/, void * /*body*/ ) { }
302 static inline void fgt_node_with_body( string_index /*t*/, void * /*g*/, void * /*input_port*/, void * /*output_port*/, void * /*body*/ ) { }
303 
304 static inline void fgt_make_edge( void * /*output_port*/, void * /*input_port*/ ) { }
305 static inline void fgt_remove_edge( void * /*output_port*/, void * /*input_port*/ ) { }
306 
307 static inline void fgt_begin_body( void * /*body*/ ) { }
308 static inline void fgt_end_body( void * /*body*/) { }
309 
310 static inline void fgt_async_try_put_begin( void * /*node*/, void * /*port*/ ) { }
311 static inline void fgt_async_try_put_end( void * /*node*/ , void * /*port*/ ) { }
312 static inline void fgt_async_reserve( void * /*node*/, void * /*graph*/ ) { }
313 static inline void fgt_async_commit( void * /*node*/, void * /*graph*/ ) { }
314 static inline void fgt_reserve_wait( void * /*graph*/ ) { }
315 static inline void fgt_release_wait( void * /*graph*/ ) { }
316 
317 template< typename NodeType >
318 void fgt_multiinput_multioutput_node_desc( const NodeType * /*node*/, const char * /*desc*/ ) { }
319 
320 template < typename PortsTuple, int N >
322  static void alias_port( void * /*node*/, PortsTuple & /*ports*/ ) { }
323 };
324 
325 template < typename PortsTuple, int N >
327  static void alias_port( void * /*node*/, PortsTuple & /*ports*/ ) { }
328 };
329 
330 #endif // TBB_USE_THREADING_TOOLS
331 
332  } // namespace internal
333 } // namespace tbb
334 
335 #endif
static void fgt_async_commit(void *, void *)
static void fgt_async_reserve(void *, void *)
static void fgt_make_edge(void *, void *)
void fgt_multiinput_multioutput_node_desc(const NodeType *, const char *)
static void fgt_body(void *, void *)
tbb::flow::tuple_element< N, typename JNT::input_ports_type >::type & input_port(JNT &jn)
templated function to refer to input ports of the join node
static void fgt_begin_body(void *)
static void fgt_async_try_put_end(void *, void *)
static void fgt_composite(void *, void *)
void * addr
static void fgt_async_try_put_begin(void *, void *)
static void fgt_graph_desc(void *, const char *)
void itt_region_begin(itt_domain_enum, void *, unsigned long long, void *, unsigned long long, string_index)
void const char const char int ITT_FORMAT __itt_group_sync p
static void fgt_release_wait(void *)
static void fgt_alias_port(void *, void *, bool)
Pure virtual template class that defines a receiver of messages of type T.
Definition: flow_graph.h:100
tbb::flow::tuple_element< N, typename MOP::output_ports_type >::type & output_port(MOP &op)
void itt_task_begin(itt_domain_enum, void *, unsigned long long, void *, unsigned long long, string_index)
void itt_make_task_group(itt_domain_enum, void *, unsigned long long, void *, unsigned long long, string_index)
static void fgt_graph(void *)
The graph class.
static void fgt_multiinput_multioutput_node(string_index, void *, void *)
static void fgt_remove_edge(void *, void *)
static void fgt_node_with_body(string_index, void *, void *, void *)
static void fgt_multiinput_node(string_index, void *, PortsTuple &, void *)
static void fgt_end_body(void *)
void itt_task_end(itt_domain_enum)
void itt_metadata_str_add(itt_domain_enum, void *, unsigned long long, string_index, const char *)
void itt_relation_add(itt_domain_enum, void *, unsigned long long, itt_relation, void *, unsigned long long)
static void fgt_multioutput_node(string_index, void *, void *, PortsTuple &)
static void fgt_reserve_wait(void *)
void itt_region_end(itt_domain_enum, void *, unsigned long long)
static void fgt_multioutput_node_desc(const NodeType *, const char *)
static void fgt_node(string_index, void *, void *)
static void fgt_multioutput_node_with_body(string_index, void *, void *, PortsTuple &, void *)
static void fgt_node_desc(const NodeType *, const char *)
Forward declaration section.
Definition: flow_graph.h:99

Copyright © 2005-2019 Intel Corporation. All Rights Reserved.

Intel, Pentium, Intel Xeon, Itanium, Intel XScale and VTune are registered trademarks or trademarks of Intel Corporation or its subsidiaries in the United States and other countries.

* Other names and brands may be claimed as the property of others.