1 #ifndef SEGMENT_GRAPH_H_INCLUDED_
2 #define SEGMENT_GRAPH_H_INCLUDED_
9 #include "boost/graph/adjacency_list.hpp"
10 #include "boost/graph/graphviz.hpp"
11 #include "boost/algorithm/string.hpp"
12 #include "../internal_representation/module.h"
22 #define DBG_SHOW(name,id) std::cout<<"\n\ndebug id: "<< id<<" "<<#name<<" : \n"<<name->unparseToString()<<std::endl;
31 typedef boost::adjacency_list<boost::listS,
33 boost::property<boost::vertex_index_t, int> >
Graph;
55 Graph *FakeGraphHandle = NULL;
67 assert((*FakeGraphHandle)[lhs].node_id_ == (*FakeGraphHandle)[rhs].node_id_ ?
70 return (*FakeGraphHandle)[lhs].node_id_ < (*FakeGraphHandle)[rhs].node_id_;
181 std::vector<std::pair<VertexDescriptor, SgSymbol *> >
188 std::map< SgSymbol * , std::vector<VertexDescriptor> >
195 std::map< SgSymbol * , std::vector<VertexDescriptor> >
245 Thread *originating_thread,
248 bool is_simulation_process =
true,
249 std::string module_name =
"");
267 Thread *originating_thread,
270 bool is_simulation_process =
true,
271 std::string module_name =
"");
337 int stmt_type = 0, SgStatement* parent = NULL,
338 SgBasicBlock* body = NULL);
351 int stmt_type = 0, SgStatement* parent = NULL,
352 SgBasicBlock* body = NULL);
435 SgStatement *current_stmt,
467 SgFunctionDefinition *func_def,
470 bool is_registered_b_transport =
false);
503 SgFunctionCallExp *func_call_exp);
517 SgNode* boundary_node,
520 bool is_conflict_free,
534 SgFunctionDefinition *func_def);
543 SgFunctionCallExp *func_call,
544 SgVariableDefinition* socket);
557 SgFunctionCallExp *func_call,
558 SgFunctionDefinition *func_def,
559 SgVariableDefinition *socket);
570 SgFunctionCallExp *func_call,
571 SgFunctionDefinition *func_def,
572 SgVariableDefinition *socket);
582 SgFunctionCallExp *func_call,
583 SgFunctionDefinition *func_def,
584 SgVariableDefinition *socket);
669 SgFunctionDeclaration *func_decl,
724 std::unordered_map<SgFunctionDeclaration*,
732 std::unordered_map<SgFunctionCallExp*,
void print_graph_read_write_access(std::string filename)
This function prints all variables which have read or written in this segment.
Definition: segment_graph.cpp:142
Definition: function_annotation.h:53
This class represents a segment graph for a process.
Definition: segment_graph.h:79
void get_wait_and_notifying_events()
set the wait_events_ and notify_events_ for psg nodes under psg mode
Definition: segment_graph.cpp:195
void separate_variable_declaration_and_initializer_on_demand(SgBasicBlock *&bb, bool duplicate_segments, PortCallPath pcp)
This function checks if a direct or indirect boundary call is in the initializer expression of the va...
Definition: segment_graph.cpp:5293
boost::graph_traits< Graph >::vertex_iterator VertexIterator
Definition: segment_graph.h:35
SgFunctionDeclaration * contains_function_call_expression(SgExpression *expr)
In this function we look for expressions which contain a function call in the following style: foo();...
Definition: segment_graph.cpp:5061
void replace_partial_function_call_nodes()
for each partial function call node, calls integrate_psg_into_sg to replace the node with correspondi...
Definition: segment_graph.cpp:612
std::unordered_set< SgVariableSymbol * > Tlm2_containers_
including generic payload and dmi
Definition: segment_graph.h:741
boost::graph_traits< Graph >::vertex_descriptor VertexDescriptor
Definition: segment_graph.h:34
std::set< VertexDescriptor, SegmentCmp > SegmentSet
Definition: segment_graph.h:93
bool has_transition(int seg_id_from, int seg_id_to)
true, if there is a transition from 'from' to 'to'
Definition: segment_graph.cpp:7229
void add_expression_to_segment(SegmentSet segments, SgNode *expr, PortCallPath pcp)
This function adds to each segment the given expression.
Definition: segment_graph.cpp:1493
void print_graph(std::string filename)
This function prints the graph in a dot file. The name of the file is user defined by argument...
Definition: segment_graph.cpp:123
std::unordered_map< SgFunctionDeclaration *, std::vector< int > > func_socket_offset_mapping_
used for instrumenting seg id offset in b_transport implementation functions.
Definition: segment_graph.h:726
std::set< VertexDescriptor > precached_function_segments_
This set stores segments from precached functions. These segments will be deleted later...
Definition: segment_graph.h:706
void read_psg_from_file(std::string file_name)
load the .psg file from disk reconstructs nodes and connections
Definition: segment_graph.cpp:677
bool operator()(const VertexDescriptor lhs, const VertexDescriptor rhs) const
Definition: segment_graph.h:47
bool is_boundary_stmt(SgStatement const *const current_stmt)
This function checks if a given statement is a potential boundary statement.
Definition: segment_graph.cpp:4685
int total_segment_nodes_
for redaction of psg, we need to store the total number of segment nodes. The value is set in the mai...
Definition: segment_graph.h:202
bool should_decompose_function(SgExpression *expr, bool duplicate_segments, PortCallPath pcp, bool is_condition=false)
This function determines if a expression should be decomposed. This is the case if expression has the...
Definition: segment_graph.cpp:4912
std::set< SgFunctionCallExp * > port_calls_
This set stores all function calls which belong to a port. These segments will be deleted later...
Definition: segment_graph.h:712
void reference_analysis_hack_for_dmi_get_ptr(SgFunctionCallExp *func_call, SgFunctionDefinition *func_def, SgVariableDefinition *socket)
get_dmi_ptr is a special case. In this case, the 2nd parameter is a reference referring to a dmi obje...
Definition: segment_graph.cpp:6784
std::map< SgSymbol *, std::vector< VertexDescriptor > > func_symbols_and_exit_segVertex_
mapping of function symbol and its exit segment vertexes reconstructed after loading ...
Definition: segment_graph.h:196
WAIT_CONSTRUCT
Definition: function_annotation.h:7
void create_temp_variable_for_expression(SgExpression *expr, SgBasicBlock *&bb, int stmt_type=0, SgStatement *parent=NULL, SgBasicBlock *body=NULL)
This function creates a variable declaration of the type of the given expression. The variable will b...
Definition: segment_graph.cpp:5607
void clean_graph()
This function deletes all duplicated nodes in each vertex of the graph.
Definition: segment_graph.cpp:77
static int counter
This counter is used for generating variables names with unique names.
Definition: segment_graph.h:652
bool is_succesfully_created_
Is true if the segment graph is successfully created.
Definition: segment_graph.h:718
SegmentGraph()
Definition: segment_graph.cpp:50
CachedFunctionAstAttributes * build_segment_graph_for_function(SgFunctionDefinition *func_def, bool duplicate_segments, PortCallPath pcp, bool is_registered_b_transport=false)
This function generates a segment graph for a function.
Definition: segment_graph.cpp:6363
bool static_analysis_
determine if the compiler should perform static analysis or dynamic analysis
Definition: segment_graph.h:293
CachedFunctionAstAttributes * create_cached_function_attribute_for_annotated_function(SgNode *boundary_node, WAIT_CONSTRUCT wait_type, SegmentSet incoming_segments, bool is_conflict_free, PortCallPath pcp)
This function creates a cached function annotation information for based on the cached function infor...
Definition: segment_graph.cpp:6612
Definition: port_call_path.h:10
Function object (functor!?) for SegmentSet (12/15/18, RD)
Definition: segment_graph.h:46
void integrate_psg_into_sg(VertexDescriptor func_call_vertex_id, SgSymbol *func_sym)
replace a partial function call node with its psg. If the partial function call is a port call...
Definition: segment_graph.cpp:285
void mark_not_conflict_free_func_calls_in_segment(SgNode *stmt, SegmentSet segments)
This function checks if there is a not-conflict-free function call in the expression. If so, all segments marked as in conflict.
Definition: segment_graph.cpp:7178
std::set< SgFunctionDefinition * > FunctionCallBoundarySet
Definition: segment_graph.h:83
void set_all_segments_to_untouched()
This function sets the status of the flag helper_for_graph_algorithms for all nodes to 'Untouched'...
Definition: segment_graph.cpp:6434
FunctionAnnotation * analyze_prepended_pragmas_for_annotation(SgFunctionDeclaration *func_decl)
This function checks if the function has any pragma. The results are in the return value...
Definition: segment_graph.cpp:7068
void add_function(Thread *originating_thread, Function *function, bool duplicate_segments=false, bool is_simulation_process=true, std::string module_name="")
This function analyzes the given function and creates a segment graph for it. The graph will be autom...
Definition: segment_graph.cpp:1166
CCxxKeywordsBoundarySet keyword_boundaries_
Currently not used.
Definition: segment_graph.h:641
void print_psg_file(std::string file_name)
store the psg as .psg file on disk
Definition: segment_graph.cpp:162
void remove_dangling_segments()
after integration of all the psgs, the segments that does not belong to simulation processes are remo...
Definition: segment_graph.cpp:553
SegmentSet duplicate_empty_segments(SegmentSet segments)
This function dupilcates a SegmentSet. The dulicated segments will have also incoming edges...
Definition: segment_graph.cpp:1508
void insert_loop_edges(VertexDescriptor &loop_vertex, SegmentSet ¤t_segments, SegmentSet &continue_segments, SegmentSet &leaf_segments_of_loop)
This is a helper function for loop handling.
Definition: segment_graph.cpp:4726
Graph graph_
Internal data structure of the segment graph.
Definition: segment_graph.h:700
std::map< SgSymbol *, std::vector< VertexDescriptor > > func_symbols_and_entrance_segVertex_
mapping of function symbol and its entrance segment vertexes, reconstructed after loading ...
Definition: segment_graph.h:189
std::vector< std::string > channel_seg_id_array_names_
we need to instrument set_upcoming_segment_id(var_array) before port calls var_array is defined in th...
Definition: segment_graph.h:167
void forward_reference_function_parameters(SgFunctionCallExp *func_call_exp)
This function forwards the arguments which are passed by reference to the function parameters of the ...
Definition: segment_graph.cpp:7013
void reference_analysis_hack_for_nb_transport(SgFunctionCallExp *func_call, SgFunctionDefinition *func_def, SgVariableDefinition *socket)
we now also keep the pcp
Definition: segment_graph.cpp:6916
std::set< VertexDescriptor > port_call_seg_vertexs_
stores the partial function call nodes that hold port calls. are used in PSG mode.
Definition: segment_graph.h:173
std::string generate_unique_name(SgNode *node)
Generates an unique name for a varible based on the given node.
Definition: segment_graph.cpp:6342
This class stores precached information of a analyzed function. Each function definition has an assoc...
Definition: cached_function_ast_attributes.h:18
void read_write_analysis_of_segments()
The function determines which variables are read and written in the individual segments.
Definition: segment_graph.cpp:4820
void analyze_TLM2_container_final_mapping()
there may be nested b_transports, so, a reference typed gp (gp0) may refer to another reference typed...
Definition: segment_graph.cpp:7295
FunctionAnnotationAttributes * get_function_call_annotation(SgFunctionCallExp *func_call_exp)
This function takes a function call expression and checks if there is any function annotation at the ...
Definition: segment_graph.cpp:6448
std::set< VariantT > CCxxKeywordsBoundarySet
Definition: segment_graph.h:84
std::unordered_set< SgFunctionCallExp * > b_transport_calls_
Definition: segment_graph.h:736
std::set< VertexDescriptor > recursive_function_calls_
Contains the entrance vertexes of recursive function calls.
Definition: segment_graph.h:646
void add_function_method(Thread *originating_thread, Function *function, bool duplicate_segments=false, bool is_simulation_process=true, std::string module_name="")
This function analyzes the given function and creates a segment graph for it. The graph will be autom...
Definition: segment_graph.cpp:1302
SegmentSet build_graph(SgStatement *current_stmt, SegmentSet current_segments, SegmentSet &break_segments, SegmentSet &continue_segments, bool duplicate_segments, PortCallPath pcp)
This function creates the segment graph.
Definition: segment_graph.cpp:1574
void find_module_segments()
for loading PSG It adds simulation threads to module_definitions, and sets the corresponding starting...
Definition: segment_graph.cpp:628
void set_socket_call_CachedFunctionAstAttributes(SgFunctionDeclaration *func_decl, bool duplicate_segments, PortCallPath pcp)
set the CachedFunctionAstAttributes for registered b_transport functions
Definition: segment_graph.cpp:7261
bool follow_function_call(SgFunctionDeclaration *func_decl)
true, if the function be followed.
Definition: segment_graph.cpp:7220
FunctionCallBoundarySet function_boundaries_
Contains all boudaries (currently, wait statemens)
Definition: segment_graph.h:636
boost::adjacency_list< boost::listS, boost::listS, boost::bidirectionalS, Segment, Edge, boost::property< boost::vertex_index_t, int > > Graph
Definition: segment_graph.h:29
void handle_recursive_calls()
This function integrates the recursive function calls.
Definition: segment_graph.cpp:5093
Definition: function.h:14
This class provides attributes for function anotations.
Definition: function_annotation_attributes.h:17
void decompose_expression_with_boundary_calls(SgExpression *expr, SgBasicBlock *&bb, bool duplicate_segments, PortCallPath pcp, int stmt_type=0, SgStatement *parent=NULL, SgBasicBlock *body=NULL)
This function decomposes an expression into multiple statements. Functions which call directly or ind...
Definition: segment_graph.cpp:5999
void set_socket_attribute_for_dmi_object(SgFunctionCallExp *func_call, SgVariableDefinition *socket)
we need to know which module instance this dmi object connects to
Definition: segment_graph.cpp:6982
SegmentSet duplicate_segments(SegmentSet segments)
This function dupilcates a SegmentSet. the dulicated segments will have also incoming edges...
Definition: segment_graph.cpp:1541
boost::graph_traits< Graph >::edge_descriptor EdgeDescriptor
Definition: segment_graph.h:36
SgFunctionCallExp * has_function_call_with_boundary(SgExpression *expr, bool duplicate_segments, PortCallPath pcp)
This function checks if in the given expression a function call occurs which calls a functon with a b...
Definition: segment_graph.cpp:4832
std::unordered_map< SgFunctionCallExp *, std::vector< int > > bt_socket_offset_mapping_
used for instrumenting seg id offset in b_transport implementation functions.
Definition: segment_graph.h:734
VertexDescriptor id_to_vertex_descriptor(int seg_id)
Returns a vertex descriptor of the segment with the id 'seg_id'.
Definition: segment_graph.cpp:7245
void add_mapped_symbol_to_reference(SgFunctionCallExp *func_call, SgFunctionDefinition *func_def)
Let's take a look at this example: void foo(int &ref, int value, in &ref2); foo(var, some_var, other_var); This function adds the symbol of "var" to the attribute "references" of the symbol "ref". The same happens for "ref2" and "other_var".
Definition: segment_graph.cpp:6682
std::vector< std::pair< VertexDescriptor, SgSymbol * > > vertexID_symbol_pairs_of_partialFuncCallNodes_
pairs of VertexDescriptor of partial function call node and the function's symbol. used for replacing partial function call nodes with its subpsg
Definition: segment_graph.h:182
void reference_analysis_hack_for_b_transport(SgFunctionCallExp *func_call, SgFunctionDefinition *func_def, SgVariableDefinition *socket)
we now also keep the pcp
Definition: segment_graph.cpp:6849