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

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.