47 #include "config_HAVE_HOST_PROFILING_BUILT.hpp" 68 #if HAVE_HOST_PROFILING_BUILT 73 #include <boost/graph/adjacency_list.hpp> 74 #include <boost/graph/filtered_graph.hpp> 75 #include <boost/iterator/filter_iterator.hpp> 76 #include <boost/iterator/iterator_facade.hpp> 77 #include <boost/tuple/tuple.hpp> 83 #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) 84 #pragma GCC diagnostic push 85 #pragma GCC diagnostic error "-Weffc++" 88 : node_id(_node_id), base_address(_base_address),
offset(_offset)
122 flsaoddg(new
OpGraph(op_graphs_collection,
132 #if HAVE_HOST_PROFILING_BUILT
146 dereference_unknown_address(
false),
147 unaligned_accesses(
false),
151 has_undefined_function_receiveing_pointers(
false),
153 pipeline_enabled(
false),
154 simple_pipeline(
false),
157 _parameters->isOption(OPT_channels_number) ? _parameters->getOption<unsigned int>(OPT_channels_number) : 0),
161 feedback_bb_reachability(),
167 post_dominators(nullptr),
171 THROW_ASSERT(_AppM->get_tree_manager()->GetTreeNode(_helper->get_function_index())->get_kind() == function_decl_K,
172 "Called function_behavior on a node which is not a function_decl");
173 auto*
decl_node = GetPointer<function_decl>(_AppM->get_tree_manager()->GetTreeNode(_helper->get_function_index()));
175 if(!_parameters->isOption(OPT_pipelining))
183 "Required pipelining with II=1 for function: " + fname);
193 auto tmp_string = _parameters->getOption<std::string>(OPT_pipelining);
194 if(tmp_string ==
"no-@ll")
198 else if(tmp_string ==
"@ll")
203 "Required pipelining with II=1 for function: " + fname);
207 const auto funcs_values = string_to_container<std::vector<std::string>>(tmp_string,
",");
208 for(
auto fun_pipeline : funcs_values)
210 if(!fun_pipeline.empty() && fun_pipeline.at(0) ==
'=')
212 fun_pipeline = fun_pipeline.substr(1);
214 const auto splitted =
SplitString(fun_pipeline,
"=");
215 if(!splitted.empty() &&
216 (fname == splitted.at(0) || (fname.find(
"__float") == 0 && fname.find(splitted.at(0)) == 0)))
218 if(splitted.size() == 1)
223 "Required pipelining with II=1 for function: " + fname);
225 else if(splitted.size() == 2)
386 subset.insert(statements.begin(), statements.end());
523 os <<
"Function " <<
helper->get_function_name();
550 ppg->GetBBEdgeInfo(e)->set_epp_value(value);
563 #if HAVE_HOST_PROFILING_BUILT 564 const ProfilingInformationConstRef FunctionBehavior::CGetProfilingInformation()
const 566 return profiling_information;
662 for(boost::tie(v, vEnd) = boost::vertices(*
cfg); v != vEnd; v++)
664 const auto& varsTemp =
cfg->CGetOpNodeInfo(*v)->cited_variables;
665 vars.insert(varsTemp.begin(), varsTemp.end());
667 for(
const auto& funParam :
helper->GetParameters())
669 vars.erase(funParam->index);
671 for(
const auto& gblVariable : AppM->GetGlobalVariables())
673 vars.erase(gblVariable->index);
680 THROW_ASSERT(ref.find(x) != ref.end(),
"Vertex " +
GET_NAME(g, x) +
" is not in topological_sort");
681 THROW_ASSERT(ref.find(y) != ref.end(),
"Second " +
GET_NAME(g, y) +
" vertex is not in topological_sort");
682 return ref.find(x)->second < ref.find(y)->second;
688 bb_reachability.find(first_basic_block)->second.find(second_basic_block) !=
700 const vertex second_basic_block)
const 721 const unsigned int first_bb_index =
cfg->CGetOpNodeInfo(first_operation)->bb_index;
722 const unsigned int second_bb_index =
cfg->CGetOpNodeInfo(second_operation)->bb_index;
723 const vertex first_bb_vertex = bb_index_map.find(first_bb_index)->second;
724 const vertex second_bb_vertex = bb_index_map.find(second_bb_index)->second;
729 if(first_bb_vertex == second_bb_vertex)
733 "Level of " +
GET_NAME(
cfg, first_operation) +
" not found");
735 "Level of " +
GET_NAME(
cfg, second_operation) +
" not found");
747 const unsigned int first_bb_index =
cfg->CGetOpNodeInfo(first_operation)->bb_index;
748 const unsigned int second_bb_index =
cfg->CGetOpNodeInfo(second_operation)->bb_index;
749 const vertex first_bb_vertex = bb_index_map.find(first_bb_index)->second;
750 const vertex second_bb_vertex = bb_index_map.find(second_bb_index)->second;
806 #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) 807 #pragma GCC diagnostic pop const OpGraphRef flg
The flow edge operation graph.
#define FLG_SELECTOR
Flow edge selector.
Anti + Data flow graph dependence between aggregates.
~FunctionBehavior()
Destructor.
const BBGraphRef dj
The dj graph (used for loop computation)
unsigned int GetBitValueVersion() const
Return the version of the bitvalue information.
Basic block control flow graph.
Anti dependence + data dependence + output dependence + flow graph with feedback. ...
unsigned int UpdateBBVersion()
Update the version of the basic block intermediate representation.
void SetChannelsNumber(unsigned int val)
Definition of the class representing a generic C application.
const std::vector< std::string > SplitString(const std::string &input, const std::string &separators)
Function which splits a string into tokens.
class providing methods to manage an operations graph.
bool CheckFeedbackReachability(const vertex first_operation, const vertex second_operation) const
Check if a path from first_operation to second_operation exists in control flow graph with feedback...
bool operator()(const vertex x, const vertex y) const
Compare position of two vertices in topological sorted.
Data structore used to build the topological order of the operations vertices.
MemoryAllocation_ChannelsType GetChannelsType() const
CustomOrderedSet< unsigned int > get_local_variables(const application_managerConstRef AppM) const
Returns the set of local variables.
const OpGraphRef cdg
The control dependence graph.
void clean_parm_decl_loaded()
clean_parm_decl_loaded clean parm_decl_loaded data structure
#define INDENT_OUT_MEX(outLevel, curOutLevel, mex)
const OpGraphRef odg
The output-dependencies flow graph.
Anti-dependence graph with feedback.
const OpGraphRef saodg
The system dependence, antidependence and output dependence graph.
#define GET_NAME(data, vertex_index)
Helper macro returning the name associated with a node.
Class specification of the graph structures.
unsigned int bb_version
The version of basic block intermediate representation.
const OpGraphRef fodg
The output-dependencies flow graph with feedback.
void clean_dynamic_address()
remove all variables from the dynamic address set
exceptions managed by PandA
MemoryAllocation_ChannelsType
The number of channels.
#define FCFG_SELECTOR
Control flow graph with feedback edges.
#define DEBUG_SELECTOR
Debug selector.
void add_parm_decl_stored(unsigned int node_id)
add a formal parameter that has to be initialized from the actual value
const OpGraphRef fdfg
The data flow graph with feedback.
const std::deque< vertex > & get_bb_levels() const
Return the vector of bb vertex index sorted in topological order.
#define D_SELECTOR
Selectors used only in basic block graphs; numbers continue from cdfg_edge_info.hpp.
bool CheckBBReachability(const vertex first_basic_block, const vertex second_basic_block) const
Check if a path from the first basic block to the second basic block exists in control flow graph (wi...
Basic block control flow graph with edges imposing that basic block inside a loop are executed before...
CustomOrderedSet< unsigned int > dynamic_address
store memory objects which can be indirectly addressed through a dynamic address computation ...
refcount< const OpGraph > OpGraphConstRef
#define FADG_SELECTOR
Anti-dependence graph selector with feedback edges.
MemoryAllocation_Policy _allocation_policy
const BehavioralHelperRef helper
Behavioral helper associated with this behavioral_graph_manager.
Basic block post-dominator tree.
const OpGraphRef fcfg
The control flow graph with feedback.
This class provides methods to build a basic blocks graph.
const OpGraphRef fsdg
The system dependence graph with feedback.
Base class description of data information associated with each node of a graph.
#define OUTPUT_LEVEL_MINIMUM
minimum debugging print is performed.
dominance< BBGraph > * post_dominators
This class stores post-dominator information.
A set of operation vertices.
const std::map< vertex, unsigned int > & get_bb_map_levels() const
Return the map of bb vertex index sorted in topological order.
static std::string GetMangledFunctionName(const function_decl *fd)
Return the mangled function name.
#define STR(s)
Macro which performs a lexical_cast to a string.
const BBGraphRef bb
The basic block CFG.
System dependence + anti-dependence + output dependence graph + flow graph + debug graph...
const BBGraphRef dt
The dominator tree of the CFG on basic blocks.
const OpGraphRef adg
The anti-dependencies graph.
const OpGraphRef sdg
The system dependence graph.
void clean_function_mem()
clean the function mem data structure
information associated with the whole graph
std::deque< vertex > bb_deque_levels
list of operations vertices sorted by topological order in control flow graph; in the sorting then pa...
unsigned int UpdateBitValueVersion()
Update the version of the bitvalue information.
const BBGraphRef cdg_bb
The control dependence graph among basic blocks.
graph_type
Declaration of enum representing the type of graph.
#define THROW_UNREACHABLE(str_expr)
helper function used to specify that some points should never be reached
System dependence graph with feedback.
void add_parm_decl_copied(unsigned int node_id)
Adds an identifier to the set of memory variables.
CustomOrderedSet< unsigned int > mem_nodeID
this set represents the memory variables accessed by the function
bool CheckBBFeedbackReachability(const vertex first_basic_block, const vertex second_basic_block) const
Check if a path from the first basic block to the second basic block exists in control flow graph wit...
const std::deque< vertex > & get_levels() const
Return the vector of vertex index sorted in topological order.
System dependence + anti-dependence graph + output dependence graph with feedback.
#define J_SELECTOR
j graph edge selector for dj graph (used during loop computation)
Class used to describe a particular graph with basic blocks as nodes.
#define SAODG_SELECTOR
Control and Data dependence and antidependence graph edge selector.
Control dependence graph.
#define PP_SELECTOR
Path Profiling Basic Block edge selector.
absl::flat_hash_map< T, U, Hash, Eq, Alloc > CustomUnorderedMap
#define CDG_SELECTOR
Control dependence edge selector.
const OpGraphRef flaoddg
The anti-dependence + data dependence + output dependence + flow graph.
const LoopsRef GetLoops() const
Return the loops.
const OpGraphRef sg
The speculation graph.
const OpGraphRef fflaoddg
The anti-dependence + data dependence + output dependence + flow graph with freedback.
#define SDG_SELECTOR
Control and Data dependence graph edge selector.
const OpGraphRef cfg
The control flow graph.
#define ODG_SELECTOR
Output-dependence graph edge selector.
const BBGraphRef extended_bb
The basic block Control Flow Graph extended with edges that impose that basic block inside a loop are...
const OpGraphRef dfg
The data flow graph.
Basic block dominator tree.
Information associated with the whole basic-block graph.
CustomUnorderedMapStable< vertex, CustomUnorderedSet< vertex > > feedback_bb_reachability
Reachability between basic blocks based on control flow graph with feedback.
OpGraphRef GetOpGraph(FunctionBehavior::graph_type gt)
This method returns the operation graphs.
Basic block control flow graph with feedback.
Extended control flow graph.
Control dependence graph with feedback.
redefinition of set to manage ordered/unordered structures
void print(std::ostream &os) const
Function that prints the class behavioral_manager.
void set_epp(EdgeDescriptor e, unsigned long long value)
Set epp associated with an edges.
boost::graph_traits< graph >::vertex_descriptor vertex
vertex definition.
memory_access(unsigned int _node_id, unsigned int _base_address, unsigned int _offset=0)
FunctionBehavior(const application_managerConstRef AppM, const BehavioralHelperRef _helper, const ParameterConstRef parameters)
Constructor.
unsigned offset[NUM_VERTICES+1]
const OpGraphRef flsaodg
The system dependence, antidependence, output dependence and flow graph.
const OpGraphRef agg_virtualg
Anti + Data flow graph on aggregates.
Support basic block for path profiling.
const BehavioralHelperConstRef CGetBehavioralHelper() const
Returns the helper associated with the function.
boost::graph_traits< graph >::vertex_iterator VertexIterator
vertex_iterator definition.
Classes specification of the tree_node data structures.
#define FDFG_SELECTOR
Data flow graph with feedback edges.
const OpGraphRef extended_cfg
The extended control flow graph.
BehavioralHelperRef GetBehavioralHelper()
Returns the helper associated with the function.
Basic block control dependence graph.
This file collects some utility functions and macros.
CustomOrderedSet< unsigned int > parm_decl_copied
this set represents the parameters that have to be copied from the caller
const OpGraphRef fsaodg
The system dependence, antidependence and output dependence graph with feedback.
#define FSDG_SELECTOR
Control and Data dependence graph and dependence edge selector.
const std::map< vertex, unsigned int > & get_map_levels() const
Return the map of vertex index sorted in topological order.
int initiation_time
used only for stallable pipelines
#define DFG_SELECTOR
Data flow graph edge selector.
#define ADG_SELECTOR
Anti-dependence graph edge selector.
class providing methods to manage a basic blocks graph.
MemoryAllocation_ChannelsType _channels_type
Function scope channels type.
bool CheckReachability(const vertex first_operation, const vertex second_operation) const
Check if a path from first_operation to second_operation exists in control flow graph (without feedba...
This file collects some utility functions.
std::deque< vertex > deque_levels
list of operations vertices sorted by topological order in control flow graph; in the sorting then pa...
Output dependence graph with feedback.
void add_dynamic_address(unsigned int node_id)
Add the node_id to the set of object for which a dynamic address computation could be used...
dominance< BBGraph > * dominators
This class stores dominator information.
std::map< vertex, unsigned int > map_levels
Map operation vertex to position in topological order in control flow graph; in the sorting then part...
Data structures used to represent an edge in operation and basic block graphs.
#define FODG_SELECTOR
Output-dependence graph selector with feedback edges.
bb_graph_type
Declaration of enum representing the type of bb_graph.
const BBGraphRef fbb
The basic block CFG with feedback.
CustomUnorderedMapStable< vertex, CustomUnorderedSet< vertex > > bb_reachability
Mutual exclusion between basic blocks (based on control flow graph with flow edges) ...
Data flow graph with feedback.
void SetChannelsType(MemoryAllocation_ChannelsType val)
#define SG_SELECTOR
Speculation graph.
BBGraphRef GetBBGraph(FunctionBehavior::bb_graph_type gt=FunctionBehavior::BB)
This method returns the basic block graphs.
std::map< vertex, unsigned int > bb_map_levels
Map basic block vertex to position in topological order in control flow graph; in the sorting then pa...
DJ basic block graph (used for loop computation)
const OpGraphRef fadg
The anti-dependencies graph with feedback.
const OpGraphConstRef CGetOpGraph(FunctionBehavior::graph_type gt) const
This method returns the operation graphs.
CustomOrderedSet< unsigned int > parm_decl_loaded
this set represents the actual parameters that has to be loaded into the formal parameter from the ac...
Class specification of the basic_block structure.
bool is_variable_mem(unsigned int node_id) const
Checks if a variable has been allocated in memory.
unsigned int GetBBVersion() const
Return the version of the basic block intermediate representation.
unsigned int _channels_number
Function scope channels number.
Anti-dependence + data dependence + output dependence + flow graph.
#define PD_SELECTOR
post-dominator graph edge selector
const BBGraphRef ppg
The support basic block graph for path profiling.
LoopsRef loops
Loops of the function.
bool pipeline_enabled
true when pipelining is enabled for the function
Data structures used in operations graph.
Template borrowed from the ANTLR library by Terence Parr (http://www.jGuru.com - Software rights: htt...
unsigned int bitvalue_version
Version of the bitvalue information.
const BBGraphConstRef CGetBBGraph(FunctionBehavior::bb_graph_type gt=FunctionBehavior::BB) const
This method returns the basic block graphs.
const LoopsConstRef CGetLoops() const
Return the loops.
interface of loops finding algorithm
System dependence + anti-dependence + output dependence graph + flow graph.
this class is used to manage the command-line or XML options.
const CustomOrderedSet< unsigned int > & get_parm_decl_stored() const
Returns the set of the formal parameters that has to be stored into the formal parameter.
const CustomOrderedSet< unsigned int > & get_parm_decl_copied() const
Returns the set of parameters to be copied.
unsigned int GetChannelsNumber() const
const OpGraphRef flsaoddg
The system dependence, antidependence, output dependence, flow and debug graph.
bool simple_pipeline
true when the requested pipeline does not include unbounded functions
const OpGraphRef fcdg
The control dependence graph with feedback.
void clean_parm_decl_stored()
clean_parm_decl_stored clean parm_decl_stored data structure
const OpGraphsCollectionRef op_graphs_collection
Global graph storing CFG, DFG, FCFG, FDFG, SDG, FSDG, CDG. The nodes of this graph are operations...
#define DFG_AGG_SELECTOR
Data flow graph edge selector between computed on aggregates.
Control flow graph with feedback.
x
Return the smallest n such that 2^n >= _x.
void clean_parm_decl_copied()
clean_parm_decl_copied clean parm_decl_copied data structure
void SetMemoryAllocationPolicy(MemoryAllocation_Policy val)
Class used to describe a particular graph with operations as nodes.
refcount< OpGraph > OpGraphRef
refcount definition of the class
This class provides methods to build an operations graph.
const BBGraphRef pdt
The post-dominator tree of the CFG on basic blocks.
#define ADG_AGG_SELECTOR
Anti-dependence graph edge selector computed on aggregates.
const CustomOrderedSet< unsigned int > & get_parm_decl_loaded() const
Returns the set of the actual parameters that has to be loaded into the formal parameter.
#define CFG_SELECTOR
Control flow graph edge selector.
const CustomOrderedSet< unsigned int > & get_function_mem() const
Returns the set of memory variables.
System dependence + anti-dependence graph + output dependence graph.
System dependence + anti-dependence + output dependence graph + flow graph with feedback.
This structure defines graphs where nodes are operations.
#define ECFG_SELECTOR
Extended control flow graph selector.
MemoryAllocation_Policy GetMemoryAllocationPolicy() const
const CustomOrderedSet< unsigned int > & get_dynamic_address() const
Returns the set of variables for which a dynamic address computation maybe required.
struct definition of the declaration node structures.
MemoryAllocation_Policy
The allocation memory polycy.
void add_parm_decl_loaded(unsigned int node_id)
add an actual parameter that has to be loaded into the formal parameter
Class specification of the manager of the tree structures extracted from the raw file.
A brief description of the C++ Header File.
void add_function_mem(unsigned int node_id)
Adds a memory variable to the function.
#define FB_ADG_SELECTOR
Feedback anti-dependence graph edge selector.
const OpGraphRef fflsaodg
The system dependence, antidependence, output dependence and flow graph with feedback;.
refcount< BBGraph > BBGraphRef
refcount definition of the class
#define FCDG_SELECTOR
Control dependence graph selector with feedback edges.
CustomOrderedSet< unsigned int > parm_decl_stored
this set represents the formal parameters that has to be stored into the formal parameter from the ac...
This structure defines graphs where nodes are basic_blocks.
boost::graph_traits< graph >::edge_descriptor EdgeDescriptor
edge definition.
#define THROW_ASSERT(cond, str_expr)
helper function used to check an assert and if needed to throw an error in a standard way ...