This class represents a segment graph for a process. More...
#include <segment_graph.h>
Public Types | |
typedef std::set < SgFunctionDefinition * > | FunctionCallBoundarySet |
typedef std::set< VariantT > | CCxxKeywordsBoundarySet |
typedef std::set < VertexDescriptor, SegmentCmp > | SegmentSet |
Public Member Functions | |
SegmentGraph () | |
SegmentGraph (FunctionCallBoundarySet function_boundaries) | |
SegmentGraph (CCxxKeywordsBoundarySet keyword_boundaries) | |
SegmentGraph (FunctionCallBoundarySet function_boundaries, CCxxKeywordsBoundarySet keyword_boundaries) | |
void | get_wait_and_notifying_events () |
set the wait_events_ and notify_events_ for psg nodes under psg mode More... | |
void | find_module_segments () |
for loading PSG It adds simulation threads to module_definitions, and sets the corresponding starting_id_ of the thread. More... | |
void | print_psg_file (std::string file_name) |
store the psg as .psg file on disk More... | |
void | read_psg_from_file (std::string file_name) |
load the .psg file from disk reconstructs nodes and connections More... | |
void | replace_partial_function_call_nodes () |
for each partial function call node, calls integrate_psg_into_sg to replace the node with corresponding sub psg More... | |
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, the integrated psg will be cloned, and set pcp More... | |
void | remove_dangling_segments () |
after integration of all the psgs, the segments that does not belong to simulation processes are removed More... | |
void | clean_graph () |
This function deletes all duplicated nodes in each vertex of the graph. More... | |
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. More... | |
void | print_graph_read_write_access (std::string filename) |
This function prints all variables which have read or written in this segment. More... | |
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 automatically inserted in the existing graph. The flag duplicate_segments will be used to generate an instance segement graph. is_simulation_process: if set to true, meaning the function is a simulation process, and it needs a segment id. More... | |
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 automatically inserted in the existing graph. The flag duplicate_segments will be used to generate an instance segement graph. is_simulation_process: if set to true, meaning the function is a simulation process, and it needs a segment id. More... | |
void | read_write_analysis_of_segments () |
The function determines which variables are read and written in the individual segments. More... | |
void | set_all_segments_to_untouched () |
This function sets the status of the flag helper_for_graph_algorithms for all nodes to 'Untouched'. More... | |
void | analyze_TLM2_container_final_mapping () |
there may be nested b_transports, so, a reference typed gp (gp0) may refer to another reference typed gp (gp1), and gp1 refers to a real gp (gp2). The function would set gp0 referring to gp2 More... | |
bool | has_transition (int seg_id_from, int seg_id_to) |
true, if there is a transition from 'from' to 'to' More... | |
VertexDescriptor | id_to_vertex_descriptor (int seg_id) |
Returns a vertex descriptor of the segment with the id 'seg_id'. More... | |
Public Attributes | |
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 the top level channel_seg_id_array_names_ stores the names of all var_array. the names are passed to instrumentor to instrument the arrays in the top file. each name was stored in psg files and loaded back More... | |
std::set< VertexDescriptor > | port_call_seg_vertexs_ |
stores the partial function call nodes that hold port calls. are used in PSG mode. More... | |
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 More... | |
std::map< SgSymbol *, std::vector < VertexDescriptor > > | func_symbols_and_entrance_segVertex_ |
mapping of function symbol and its entrance segment vertexes, reconstructed after loading More... | |
std::map< SgSymbol *, std::vector < VertexDescriptor > > | func_symbols_and_exit_segVertex_ |
mapping of function symbol and its exit segment vertexes reconstructed after loading More... | |
int | total_segment_nodes_ |
for redaction of psg, we need to store the total number of segment nodes. The value is set in the main function More... | |
Graph | graph_ |
Internal data structure of the segment graph. More... | |
std::set< VertexDescriptor > | precached_function_segments_ |
This set stores segments from precached functions. These segments will be deleted later. More... | |
std::set< SgFunctionCallExp * > | port_calls_ |
This set stores all function calls which belong to a port. These segments will be deleted later. More... | |
bool | is_succesfully_created_ |
Is true if the segment graph is successfully created. More... | |
std::unordered_map < SgFunctionDeclaration *, std::vector< int > > | func_socket_offset_mapping_ |
used for instrumenting seg id offset in b_transport implementation functions. More... | |
std::unordered_map < SgFunctionCallExp *, std::vector< int > > | bt_socket_offset_mapping_ |
used for instrumenting seg id offset in b_transport implementation functions. More... | |
std::unordered_set < SgFunctionCallExp * > | b_transport_calls_ |
std::unordered_set < SgVariableSymbol * > | Tlm2_containers_ |
including generic payload and dmi More... | |
Private Member Functions | |
void | handle_recursive_calls () |
This function integrates the recursive function calls. More... | |
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 variable declaration. If yes, the declaration and initialization will be separated. Example: Input: int x = y + foo(); // foo() has a indirect boundary Output: int x; x = y + foo();. More... | |
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 indirectly a boundary will be separated and have temporally variables. Example: Input: x = y + foo(); // foo() has a indirect boundary Output: int temp_foo = foo(); int x = y + temp_foo();. More... | |
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 be inserted before the associated expression statement of the given expression. More... | |
std::string | generate_unique_name (SgNode *node) |
Generates an unique name for a varible based on the given node. More... | |
std::string | generate_unique_name (std::string) |
Generates an unique name for a varible based on the given string. More... | |
bool | is_boundary_stmt (SgStatement const *const current_stmt) |
This function checks if a given statement is a potential boundary statement. More... | |
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 boundary statements. More... | |
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 following structure: var = somepointer->func(); var = somevariable.func(); var = func(); and var is a global, member, or static variable. More... | |
SgFunctionDeclaration * | contains_function_call_expression (SgExpression *expr) |
In this function we look for expressions which contain a function call in the following style: foo(); this->foo(); var = foo(); var = this->foo(); The return value will be the function declaration of the called function. More... | |
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. More... | |
void | add_expression_to_segment (SegmentSet segments, SgNode *expr, PortCallPath pcp) |
This function adds to each segment the given expression. More... | |
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. More... | |
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. More... | |
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 declaration. If the function declaration has no annotation, there will be a check if a annotation must be created. More... | |
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 information. More... | |
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". More... | |
void | set_socket_attribute_for_dmi_object (SgFunctionCallExp *func_call, SgVariableDefinition *socket) |
we need to know which module instance this dmi object connects to More... | |
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 object. However, in the analysis, it should be the dmi object refering to the parameter More... | |
void | reference_analysis_hack_for_b_transport (SgFunctionCallExp *func_call, SgFunctionDefinition *func_def, SgVariableDefinition *socket) |
we now also keep the pcp More... | |
void | reference_analysis_hack_for_nb_transport (SgFunctionCallExp *func_call, SgFunctionDefinition *func_def, SgVariableDefinition *socket) |
we now also keep the pcp More... | |
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 called function. Recursively, this function traverses through the body of the function definition and follow other function calls. More... | |
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. More... | |
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. More... | |
SegmentSet | duplicate_segments (SegmentSet segments) |
This function dupilcates a SegmentSet. the dulicated segments will have also incoming edges. More... | |
SegmentSet | duplicate_empty_segments (SegmentSet segments) |
This function dupilcates a SegmentSet. The dulicated segments will have also incoming edges. Duplicated segments are not inlined_segment. More... | |
bool | follow_function_call (SgFunctionDeclaration *func_decl) |
true, if the function be followed. More... | |
void | set_socket_call_CachedFunctionAstAttributes (SgFunctionDeclaration *func_decl, bool duplicate_segments, PortCallPath pcp) |
set the CachedFunctionAstAttributes for registered b_transport functions More... | |
Private Attributes | |
bool | static_analysis_ |
determine if the compiler should perform static analysis or dynamic analysis More... | |
FunctionCallBoundarySet | function_boundaries_ |
Contains all boudaries (currently, wait statemens) More... | |
CCxxKeywordsBoundarySet | keyword_boundaries_ |
Currently not used. More... | |
std::set< VertexDescriptor > | recursive_function_calls_ |
Contains the entrance vertexes of recursive function calls. More... | |
Static Private Attributes | |
static int | counter = 0 |
This counter is used for generating variables names with unique names. More... | |
This class represents a segment graph for a process.
typedef std::set<VariantT> risc::sg::SegmentGraph::CCxxKeywordsBoundarySet |
typedef std::set<SgFunctionDefinition*> risc::sg::SegmentGraph::FunctionCallBoundarySet |
typedef std::set<VertexDescriptor, SegmentCmp> risc::sg::SegmentGraph::SegmentSet |
risc::sg::SegmentGraph::SegmentGraph | ( | ) |
risc::sg::SegmentGraph::SegmentGraph | ( | FunctionCallBoundarySet | function_boundaries | ) |
risc::sg::SegmentGraph::SegmentGraph | ( | CCxxKeywordsBoundarySet | keyword_boundaries | ) |
risc::sg::SegmentGraph::SegmentGraph | ( | FunctionCallBoundarySet | function_boundaries, |
CCxxKeywordsBoundarySet | keyword_boundaries | ||
) |
|
private |
This function adds to each segment the given expression.
segments | These segments which will contain the given expression |
expr | The expressions which will added to all segments |
pcp | add the pcp information |
risc::sg::SegmentGraph::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 automatically inserted in the existing graph. The flag duplicate_segments will be used to generate an instance segement graph. is_simulation_process: if set to true, meaning the function is a simulation process, and it needs a segment id.
risc::sg::SegmentGraph::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 automatically inserted in the existing graph. The flag duplicate_segments will be used to generate an instance segement graph. is_simulation_process: if set to true, meaning the function is a simulation process, and it needs a segment id.
|
private |
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".
|
private |
This function checks if the function has any pragma. The results are in the return value.
risc::sg::SegmentGraph::analyze_TLM2_container_final_mapping | ( | ) |
there may be nested b_transports, so, a reference typed gp (gp0) may refer to another reference typed gp (gp1), and gp1 refers to a real gp (gp2). The function would set gp0 referring to gp2
|
private |
This function creates the segment graph.
current_stmt | The first statement of the sequence which will be analyzed |
current_segments | The beginning segments |
break_segments | The break segments |
continue_segments | The continue segments |
duplicate_segments | clone or link |
pcp | The pcp information |
|
private |
This function generates a segment graph for a function.
risc::sg::SegmentGraph::clean_graph | ( | ) |
This function deletes all duplicated nodes in each vertex of the graph.
|
private |
In this function we look for expressions which contain a function call in the following style: foo(); this->foo(); var = foo(); var = this->foo(); The return value will be the function declaration of the called function.
|
private |
This function creates a cached function annotation information for based on the cached function information.
|
private |
This function creates a variable declaration of the type of the given expression. The variable will be inserted before the associated expression statement of the given expression.
|
private |
This function decomposes an expression into multiple statements. Functions which call directly or indirectly a boundary will be separated and have temporally variables. Example: Input: x = y + foo(); // foo() has a indirect boundary Output: int temp_foo = foo(); int x = y + temp_foo();.
|
private |
This function dupilcates a SegmentSet. The dulicated segments will have also incoming edges. Duplicated segments are not inlined_segment.
|
private |
This function dupilcates a SegmentSet. the dulicated segments will have also incoming edges.
risc::sg::SegmentGraph::find_module_segments | ( | ) |
for loading PSG It adds simulation threads to module_definitions, and sets the corresponding starting_id_ of the thread.
|
private |
true, if the function be followed.
|
private |
This function forwards the arguments which are passed by reference to the function parameters of the called function. Recursively, this function traverses through the body of the function definition and follow other function calls.
|
private |
Generates an unique name for a varible based on the given node.
|
private |
Generates an unique name for a varible based on the given string.
|
private |
This function takes a function call expression and checks if there is any function annotation at the declaration. If the function declaration has no annotation, there will be a check if a annotation must be created.
FA: Function annoation CF: Cached function
comment no comment
definition FA (inlining) CF (linking) no defiition FA (inlining) FA (nothing, default: no-wait conflict-free)
risc::sg::SegmentGraph::get_wait_and_notifying_events | ( | ) |
set the wait_events_ and notify_events_ for psg nodes under psg mode
|
private |
This function integrates the recursive function calls.
|
private |
This function checks if in the given expression a function call occurs which calls a functon with a boundary statements.
risc::sg::SegmentGraph::has_transition | ( | int | seg_id_from, |
int | seg_id_to | ||
) |
true, if there is a transition from 'from' to 'to'
risc::sg::SegmentGraph::id_to_vertex_descriptor | ( | int | seg_id | ) |
Returns a vertex descriptor of the segment with the id 'seg_id'.
|
private |
This is a helper function for loop handling.
risc::sg::SegmentGraph::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, the integrated psg will be cloned, and set pcp
func_call_vertex_id | vertex descriptor of the function call node |
func_sym | Symbol of the function call, used to locate the entrance and exit nodes of the sub psg |
|
private |
This function checks if a given statement is a potential boundary statement.
current_stmt | The statement which will be checked |
|
private |
This function checks if there is a not-conflict-free function call in the expression. If so, all segments marked as in conflict.
risc::sg::SegmentGraph::print_graph | ( | std::string | filename | ) |
This function prints the graph in a dot file. The name of the file is user defined by argument.
filename | The name of the file |
risc::sg::SegmentGraph::print_graph_read_write_access | ( | std::string | filename | ) |
This function prints all variables which have read or written in this segment.
filename | The name of the file |
risc::sg::SegmentGraph::print_psg_file | ( | std::string | file_name | ) |
store the psg as .psg file on disk
file_name | The name of the file |
risc::sg::SegmentGraph::read_psg_from_file | ( | std::string | file_name | ) |
load the .psg file from disk reconstructs nodes and connections
file_name | The name of the file |
risc::sg::SegmentGraph::read_write_analysis_of_segments | ( | ) |
The function determines which variables are read and written in the individual segments.
|
private |
we now also keep the pcp
|
private |
get_dmi_ptr is a special case. In this case, the 2nd parameter is a reference referring to a dmi object. However, in the analysis, it should be the dmi object refering to the parameter
|
private |
we now also keep the pcp
risc::sg::SegmentGraph::remove_dangling_segments | ( | ) |
after integration of all the psgs, the segments that does not belong to simulation processes are removed
risc::sg::SegmentGraph::replace_partial_function_call_nodes | ( | ) |
for each partial function call node, calls integrate_psg_into_sg to replace the node with corresponding sub psg
|
private |
This function checks if a direct or indirect boundary call is in the initializer expression of the variable declaration. If yes, the declaration and initialization will be separated. Example: Input: int x = y + foo(); // foo() has a indirect boundary Output: int x; x = y + foo();.
risc::sg::SegmentGraph::set_all_segments_to_untouched | ( | ) |
This function sets the status of the flag helper_for_graph_algorithms for all nodes to 'Untouched'.
|
private |
we need to know which module instance this dmi object connects to
|
private |
set the CachedFunctionAstAttributes for registered b_transport functions
|
private |
This function determines if a expression should be decomposed. This is the case if expression has the following structure: var = somepointer->func(); var = somevariable.func(); var = func(); and var is a global, member, or static variable.
std::unordered_set<SgFunctionCallExp*> risc::sg::SegmentGraph::b_transport_calls_ |
std::unordered_map<SgFunctionCallExp*, std::vector<int> > risc::sg::SegmentGraph::bt_socket_offset_mapping_ |
used for instrumenting seg id offset in b_transport implementation functions.
std::vector<std::string> risc::sg::SegmentGraph::channel_seg_id_array_names_ |
we need to instrument set_upcoming_segment_id(var_array) before port calls var_array is defined in the top level channel_seg_id_array_names_ stores the names of all var_array. the names are passed to instrumentor to instrument the arrays in the top file. each name was stored in psg files and loaded back
|
staticprivate |
This counter is used for generating variables names with unique names.
std::unordered_map<SgFunctionDeclaration*, std::vector<int> > risc::sg::SegmentGraph::func_socket_offset_mapping_ |
used for instrumenting seg id offset in b_transport implementation functions.
std::map< SgSymbol * , std::vector<VertexDescriptor> > risc::sg::SegmentGraph::func_symbols_and_entrance_segVertex_ |
mapping of function symbol and its entrance segment vertexes, reconstructed after loading
std::map< SgSymbol * , std::vector<VertexDescriptor> > risc::sg::SegmentGraph::func_symbols_and_exit_segVertex_ |
mapping of function symbol and its exit segment vertexes reconstructed after loading
|
private |
Contains all boudaries (currently, wait statemens)
Graph risc::sg::SegmentGraph::graph_ |
Internal data structure of the segment graph.
bool risc::sg::SegmentGraph::is_succesfully_created_ |
Is true if the segment graph is successfully created.
|
private |
Currently not used.
std::set<VertexDescriptor> risc::sg::SegmentGraph::port_call_seg_vertexs_ |
stores the partial function call nodes that hold port calls. are used in PSG mode.
std::set<SgFunctionCallExp*> risc::sg::SegmentGraph::port_calls_ |
This set stores all function calls which belong to a port. These segments will be deleted later.
std::set<VertexDescriptor> risc::sg::SegmentGraph::precached_function_segments_ |
This set stores segments from precached functions. These segments will be deleted later.
|
private |
Contains the entrance vertexes of recursive function calls.
|
private |
determine if the compiler should perform static analysis or dynamic analysis
std::unordered_set<SgVariableSymbol*> risc::sg::SegmentGraph::Tlm2_containers_ |
including generic payload and dmi
int risc::sg::SegmentGraph::total_segment_nodes_ |
for redaction of psg, we need to store the total number of segment nodes. The value is set in the main function
std::vector<std::pair<VertexDescriptor, SgSymbol *> > risc::sg::SegmentGraph::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