File indexing completed on 2025-01-18 10:12:49
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 #ifndef _FGT_GRAPH_TRACE_IMPL_H
0018 #define _FGT_GRAPH_TRACE_IMPL_H
0019
0020 #include "../tbb_profiling.h"
0021 #if (_MSC_VER >= 1900)
0022 #include <intrin.h>
0023 #endif
0024
0025 namespace tbb {
0026 namespace internal {
0027
0028 #if TBB_USE_THREADING_TOOLS
0029 #if TBB_PREVIEW_FLOW_GRAPH_TRACE
0030 #if (_MSC_VER >= 1900)
0031 #define CODEPTR() (_ReturnAddress())
0032 #elif __TBB_GCC_VERSION >= 40800
0033 #define CODEPTR() ( __builtin_return_address(0))
0034 #else
0035 #define CODEPTR() NULL
0036 #endif
0037 #else
0038 #define CODEPTR() NULL
0039 #endif
0040
0041 static inline void fgt_alias_port(void *node, void *p, bool visible) {
0042 if(visible)
0043 itt_relation_add( ITT_DOMAIN_FLOW, node, FLOW_NODE, __itt_relation_is_parent_of, p, FLOW_NODE );
0044 else
0045 itt_relation_add( ITT_DOMAIN_FLOW, p, FLOW_NODE, __itt_relation_is_child_of, node, FLOW_NODE );
0046 }
0047
0048 static inline void fgt_composite ( void* codeptr, void *node, void *graph ) {
0049 itt_make_task_group( ITT_DOMAIN_FLOW, node, FLOW_NODE, graph, FLOW_GRAPH, FLOW_COMPOSITE_NODE );
0050 suppress_unused_warning( codeptr );
0051 #if TBB_PREVIEW_FLOW_GRAPH_TRACE
0052 if (codeptr != NULL) {
0053 register_node_addr(ITT_DOMAIN_FLOW, node, FLOW_NODE, CODE_ADDRESS, &codeptr);
0054 }
0055 #endif
0056 }
0057
0058 static inline void fgt_internal_alias_input_port( void *node, void *p, string_index name_index ) {
0059 itt_make_task_group( ITT_DOMAIN_FLOW, p, FLOW_INPUT_PORT, node, FLOW_NODE, name_index );
0060 itt_relation_add( ITT_DOMAIN_FLOW, node, FLOW_NODE, __itt_relation_is_parent_of, p, FLOW_INPUT_PORT );
0061 }
0062
0063 static inline void fgt_internal_alias_output_port( void *node, void *p, string_index name_index ) {
0064 itt_make_task_group( ITT_DOMAIN_FLOW, p, FLOW_OUTPUT_PORT, node, FLOW_NODE, name_index );
0065 itt_relation_add( ITT_DOMAIN_FLOW, node, FLOW_NODE, __itt_relation_is_parent_of, p, FLOW_OUTPUT_PORT );
0066 }
0067
0068 template<typename InputType>
0069 void alias_input_port(void *node, tbb::flow::receiver<InputType>* port, string_index name_index) {
0070
0071 fgt_internal_alias_input_port( node, port, name_index);
0072 }
0073
0074 template < typename PortsTuple, int N >
0075 struct fgt_internal_input_alias_helper {
0076 static void alias_port( void *node, PortsTuple &ports ) {
0077 alias_input_port( node, &(tbb::flow::get<N-1>(ports)), static_cast<tbb::internal::string_index>(FLOW_INPUT_PORT_0 + N - 1) );
0078 fgt_internal_input_alias_helper<PortsTuple, N-1>::alias_port( node, ports );
0079 }
0080 };
0081
0082 template < typename PortsTuple >
0083 struct fgt_internal_input_alias_helper<PortsTuple, 0> {
0084 static void alias_port( void * , PortsTuple & ) { }
0085 };
0086
0087 template<typename OutputType>
0088 void alias_output_port(void *node, tbb::flow::sender<OutputType>* port, string_index name_index) {
0089
0090 fgt_internal_alias_output_port( node, static_cast<void *>(port), name_index);
0091 }
0092
0093 template < typename PortsTuple, int N >
0094 struct fgt_internal_output_alias_helper {
0095 static void alias_port( void *node, PortsTuple &ports ) {
0096 alias_output_port( node, &(tbb::flow::get<N-1>(ports)), static_cast<tbb::internal::string_index>(FLOW_OUTPUT_PORT_0 + N - 1) );
0097 fgt_internal_output_alias_helper<PortsTuple, N-1>::alias_port( node, ports );
0098 }
0099 };
0100
0101 template < typename PortsTuple >
0102 struct fgt_internal_output_alias_helper<PortsTuple, 0> {
0103 static void alias_port( void * , PortsTuple & ) {
0104 }
0105 };
0106
0107 static inline void fgt_internal_create_input_port( void *node, void *p, string_index name_index ) {
0108 itt_make_task_group( ITT_DOMAIN_FLOW, p, FLOW_INPUT_PORT, node, FLOW_NODE, name_index );
0109 }
0110
0111 static inline void fgt_internal_create_output_port( void* codeptr, void *node, void *p, string_index name_index ) {
0112 itt_make_task_group(ITT_DOMAIN_FLOW, p, FLOW_OUTPUT_PORT, node, FLOW_NODE, name_index);
0113 suppress_unused_warning( codeptr );
0114 #if TBB_PREVIEW_FLOW_GRAPH_TRACE
0115 if (codeptr != NULL) {
0116 register_node_addr(ITT_DOMAIN_FLOW, node, FLOW_NODE, CODE_ADDRESS, &codeptr);
0117 }
0118 #endif
0119 }
0120
0121 template<typename InputType>
0122 void register_input_port(void *node, tbb::flow::receiver<InputType>* port, string_index name_index) {
0123
0124
0125
0126
0127 fgt_internal_create_input_port(node, static_cast<void*>(port), name_index);
0128 }
0129
0130 template < typename PortsTuple, int N >
0131 struct fgt_internal_input_helper {
0132 static void register_port( void *node, PortsTuple &ports ) {
0133 register_input_port( node, &(tbb::flow::get<N-1>(ports)), static_cast<tbb::internal::string_index>(FLOW_INPUT_PORT_0 + N - 1) );
0134 fgt_internal_input_helper<PortsTuple, N-1>::register_port( node, ports );
0135 }
0136 };
0137
0138 template < typename PortsTuple >
0139 struct fgt_internal_input_helper<PortsTuple, 1> {
0140 static void register_port( void *node, PortsTuple &ports ) {
0141 register_input_port( node, &(tbb::flow::get<0>(ports)), FLOW_INPUT_PORT_0 );
0142 }
0143 };
0144
0145 template<typename OutputType>
0146 void register_output_port(void* codeptr, void *node, tbb::flow::sender<OutputType>* port, string_index name_index) {
0147
0148 fgt_internal_create_output_port( codeptr, node, static_cast<void *>(port), name_index);
0149 }
0150
0151 template < typename PortsTuple, int N >
0152 struct fgt_internal_output_helper {
0153 static void register_port( void* codeptr, void *node, PortsTuple &ports ) {
0154 register_output_port( codeptr, node, &(tbb::flow::get<N-1>(ports)), static_cast<tbb::internal::string_index>(FLOW_OUTPUT_PORT_0 + N - 1) );
0155 fgt_internal_output_helper<PortsTuple, N-1>::register_port( codeptr, node, ports );
0156 }
0157 };
0158
0159 template < typename PortsTuple >
0160 struct fgt_internal_output_helper<PortsTuple,1> {
0161 static void register_port( void* codeptr, void *node, PortsTuple &ports ) {
0162 register_output_port( codeptr, node, &(tbb::flow::get<0>(ports)), FLOW_OUTPUT_PORT_0 );
0163 }
0164 };
0165
0166 template< typename NodeType >
0167 void fgt_multioutput_node_desc( const NodeType *node, const char *desc ) {
0168 void *addr = (void *)( static_cast< tbb::flow::receiver< typename NodeType::input_type > * >(const_cast< NodeType *>(node)) );
0169 itt_metadata_str_add( ITT_DOMAIN_FLOW, addr, FLOW_NODE, FLOW_OBJECT_NAME, desc );
0170 }
0171
0172 template< typename NodeType >
0173 void fgt_multiinput_multioutput_node_desc( const NodeType *node, const char *desc ) {
0174 void *addr = const_cast<NodeType *>(node);
0175 itt_metadata_str_add( ITT_DOMAIN_FLOW, addr, FLOW_NODE, FLOW_OBJECT_NAME, desc );
0176 }
0177
0178 template< typename NodeType >
0179 static inline void fgt_node_desc( const NodeType *node, const char *desc ) {
0180 void *addr = (void *)( static_cast< tbb::flow::sender< typename NodeType::output_type > * >(const_cast< NodeType *>(node)) );
0181 itt_metadata_str_add( ITT_DOMAIN_FLOW, addr, FLOW_NODE, FLOW_OBJECT_NAME, desc );
0182 }
0183
0184 static inline void fgt_graph_desc( void *g, const char *desc ) {
0185 itt_metadata_str_add( ITT_DOMAIN_FLOW, g, FLOW_GRAPH, FLOW_OBJECT_NAME, desc );
0186 }
0187
0188 static inline void fgt_body( void *node, void *body ) {
0189 itt_relation_add( ITT_DOMAIN_FLOW, body, FLOW_BODY, __itt_relation_is_child_of, node, FLOW_NODE );
0190 }
0191
0192 template< int N, typename PortsTuple >
0193 static inline void fgt_multioutput_node(void* codeptr, string_index t, void *g, void *input_port, PortsTuple &ports ) {
0194 itt_make_task_group( ITT_DOMAIN_FLOW, input_port, FLOW_NODE, g, FLOW_GRAPH, t );
0195 fgt_internal_create_input_port( input_port, input_port, FLOW_INPUT_PORT_0 );
0196 fgt_internal_output_helper<PortsTuple, N>::register_port(codeptr, input_port, ports );
0197 }
0198
0199 template< int N, typename PortsTuple >
0200 static inline void fgt_multioutput_node_with_body( void* codeptr, string_index t, void *g, void *input_port, PortsTuple &ports, void *body ) {
0201 itt_make_task_group( ITT_DOMAIN_FLOW, input_port, FLOW_NODE, g, FLOW_GRAPH, t );
0202 fgt_internal_create_input_port( input_port, input_port, FLOW_INPUT_PORT_0 );
0203 fgt_internal_output_helper<PortsTuple, N>::register_port( codeptr, input_port, ports );
0204 fgt_body( input_port, body );
0205 }
0206
0207 template< int N, typename PortsTuple >
0208 static inline void fgt_multiinput_node( void* codeptr, string_index t, void *g, PortsTuple &ports, void *output_port) {
0209 itt_make_task_group( ITT_DOMAIN_FLOW, output_port, FLOW_NODE, g, FLOW_GRAPH, t );
0210 fgt_internal_create_output_port( codeptr, output_port, output_port, FLOW_OUTPUT_PORT_0 );
0211 fgt_internal_input_helper<PortsTuple, N>::register_port( output_port, ports );
0212 }
0213
0214 static inline void fgt_multiinput_multioutput_node( void* codeptr, string_index t, void *n, void *g ) {
0215 itt_make_task_group( ITT_DOMAIN_FLOW, n, FLOW_NODE, g, FLOW_GRAPH, t );
0216 suppress_unused_warning( codeptr );
0217 #if TBB_PREVIEW_FLOW_GRAPH_TRACE
0218 if (codeptr != NULL) {
0219 register_node_addr(ITT_DOMAIN_FLOW, n, FLOW_NODE, CODE_ADDRESS, &codeptr);
0220 }
0221 #endif
0222 }
0223
0224 static inline void fgt_node( void* codeptr, string_index t, void *g, void *output_port ) {
0225 itt_make_task_group( ITT_DOMAIN_FLOW, output_port, FLOW_NODE, g, FLOW_GRAPH, t );
0226 fgt_internal_create_output_port( codeptr, output_port, output_port, FLOW_OUTPUT_PORT_0 );
0227 }
0228
0229 static void fgt_node_with_body( void* codeptr, string_index t, void *g, void *output_port, void *body ) {
0230 itt_make_task_group( ITT_DOMAIN_FLOW, output_port, FLOW_NODE, g, FLOW_GRAPH, t );
0231 fgt_internal_create_output_port(codeptr, output_port, output_port, FLOW_OUTPUT_PORT_0 );
0232 fgt_body( output_port, body );
0233 }
0234
0235 static inline void fgt_node( void* codeptr, string_index t, void *g, void *input_port, void *output_port ) {
0236 fgt_node( codeptr, t, g, output_port );
0237 fgt_internal_create_input_port( output_port, input_port, FLOW_INPUT_PORT_0 );
0238 }
0239
0240 static inline void fgt_node_with_body( void* codeptr, string_index t, void *g, void *input_port, void *output_port, void *body ) {
0241 fgt_node_with_body( codeptr, t, g, output_port, body );
0242 fgt_internal_create_input_port( output_port, input_port, FLOW_INPUT_PORT_0 );
0243 }
0244
0245
0246 static inline void fgt_node( void* codeptr, string_index t, void *g, void *input_port, void *decrement_port, void *output_port ) {
0247 fgt_node( codeptr, t, g, input_port, output_port );
0248 fgt_internal_create_input_port( output_port, decrement_port, FLOW_INPUT_PORT_1 );
0249 }
0250
0251 static inline void fgt_make_edge( void *output_port, void *input_port ) {
0252 itt_relation_add( ITT_DOMAIN_FLOW, output_port, FLOW_OUTPUT_PORT, __itt_relation_is_predecessor_to, input_port, FLOW_INPUT_PORT);
0253 }
0254
0255 static inline void fgt_remove_edge( void *output_port, void *input_port ) {
0256 itt_relation_add( ITT_DOMAIN_FLOW, output_port, FLOW_OUTPUT_PORT, __itt_relation_is_sibling_of, input_port, FLOW_INPUT_PORT);
0257 }
0258
0259 static inline void fgt_graph( void *g ) {
0260 itt_make_task_group( ITT_DOMAIN_FLOW, g, FLOW_GRAPH, NULL, FLOW_NULL, FLOW_GRAPH );
0261 }
0262
0263 static inline void fgt_begin_body( void *body ) {
0264 itt_task_begin( ITT_DOMAIN_FLOW, body, FLOW_BODY, NULL, FLOW_NULL, FLOW_BODY );
0265 }
0266
0267 static inline void fgt_end_body( void * ) {
0268 itt_task_end( ITT_DOMAIN_FLOW );
0269 }
0270
0271 static inline void fgt_async_try_put_begin( void *node, void *port ) {
0272 itt_task_begin( ITT_DOMAIN_FLOW, port, FLOW_OUTPUT_PORT, node, FLOW_NODE, FLOW_OUTPUT_PORT );
0273 }
0274
0275 static inline void fgt_async_try_put_end( void *, void * ) {
0276 itt_task_end( ITT_DOMAIN_FLOW );
0277 }
0278
0279 static inline void fgt_async_reserve( void *node, void *graph ) {
0280 itt_region_begin( ITT_DOMAIN_FLOW, node, FLOW_NODE, graph, FLOW_GRAPH, FLOW_NULL );
0281 }
0282
0283 static inline void fgt_async_commit( void *node, void * ) {
0284 itt_region_end( ITT_DOMAIN_FLOW, node, FLOW_NODE );
0285 }
0286
0287 static inline void fgt_reserve_wait( void *graph ) {
0288 itt_region_begin( ITT_DOMAIN_FLOW, graph, FLOW_GRAPH, NULL, FLOW_NULL, FLOW_NULL );
0289 }
0290
0291 static inline void fgt_release_wait( void *graph ) {
0292 itt_region_end( ITT_DOMAIN_FLOW, graph, FLOW_GRAPH );
0293 }
0294
0295 #else
0296
0297 #define CODEPTR() NULL
0298
0299 static inline void fgt_alias_port(void * , void * , bool ) { }
0300
0301 static inline void fgt_composite ( void* , void * , void * ) { }
0302
0303 static inline void fgt_graph( void * ) { }
0304
0305 template< typename NodeType >
0306 static inline void fgt_multioutput_node_desc( const NodeType * , const char * ) { }
0307
0308 template< typename NodeType >
0309 static inline void fgt_node_desc( const NodeType * , const char * ) { }
0310
0311 static inline void fgt_graph_desc( void * , const char * ) { }
0312
0313 static inline void fgt_body( void * , void * ) { }
0314
0315 template< int N, typename PortsTuple >
0316 static inline void fgt_multioutput_node( void* , string_index , void * , void * , PortsTuple & ) { }
0317
0318 template< int N, typename PortsTuple >
0319 static inline void fgt_multioutput_node_with_body( void* , string_index , void * , void * , PortsTuple & , void * ) { }
0320
0321 template< int N, typename PortsTuple >
0322 static inline void fgt_multiinput_node( void* , string_index , void * , PortsTuple & , void * ) { }
0323
0324 static inline void fgt_multiinput_multioutput_node( void* , string_index , void * , void * ) { }
0325
0326 static inline void fgt_node( void* , string_index , void * , void * ) { }
0327 static inline void fgt_node( void* , string_index , void * , void * , void * ) { }
0328 static inline void fgt_node( void* , string_index , void * , void * , void * , void * ) { }
0329
0330 static inline void fgt_node_with_body( void* , string_index , void * , void * , void * ) { }
0331 static inline void fgt_node_with_body( void* , string_index , void * , void * , void * , void * ) { }
0332
0333 static inline void fgt_make_edge( void * , void * ) { }
0334 static inline void fgt_remove_edge( void * , void * ) { }
0335
0336 static inline void fgt_begin_body( void * ) { }
0337 static inline void fgt_end_body( void * ) { }
0338
0339 static inline void fgt_async_try_put_begin( void * , void * ) { }
0340 static inline void fgt_async_try_put_end( void * , void * ) { }
0341 static inline void fgt_async_reserve( void * , void * ) { }
0342 static inline void fgt_async_commit( void * , void * ) { }
0343 static inline void fgt_reserve_wait( void * ) { }
0344 static inline void fgt_release_wait( void * ) { }
0345
0346 template< typename NodeType >
0347 void fgt_multiinput_multioutput_node_desc( const NodeType * , const char * ) { }
0348
0349 template < typename PortsTuple, int N >
0350 struct fgt_internal_input_alias_helper {
0351 static void alias_port( void * , PortsTuple & ) { }
0352 };
0353
0354 template < typename PortsTuple, int N >
0355 struct fgt_internal_output_alias_helper {
0356 static void alias_port( void * , PortsTuple & ) { }
0357 };
0358
0359 #endif
0360
0361 }
0362 }
0363
0364 #endif