71 : TreeM(_HLSMgr->get_tree_manager()), Param(_Param), null_vertex_string(
"NULL_VERTEX"), HLSMgr(_HLSMgr)
95 live_in[v].insert(live_set.begin(), live_set.end());
101 live_in[v].insert(first, last);
113 return live_in.find(v)->second;
128 live_out[v].insert(vars.begin(), vars.end());
170 "op never used in state " +
get_name(state));
173 "var never used in the given state. Var: " + std::to_string(var));
203 "state never used " +
get_name(state));
205 "op never used in state " +
get_name(state));
208 "var never used in the given state. Var: " + std::to_string(var));
254 return names.find(v)->second;
264 if(FB->is_pipeline_enabled() && !FB->is_simple_pipeline())
271 vertex bb_1 = bb_index_map.find(bb_index1)->second;
272 vertex bb_2 = bb_index_map.find(bb_index2)->second;
275 for(
const auto& loop : loops)
277 int initiation_time = FB->get_initiation_time();
278 THROW_ASSERT(loop->num_blocks() != 1,
"The loop has more than one basic block");
279 auto bbs = loop->get_blocks();
282 for(
auto s_pair :
HLS->
STG->
GetAstg()->GetStateTransitionGraphInfo()->vertex_to_state_id)
284 auto ids =
HLS->
STG->
CGetAstg()->CGetStateInfo(std::get<0>(s_pair))->BB_ids;
288 HLSMgr->CGetFunctionBehavior(
HLS->
functionId)->CGetBBGraph()->CGetBBNodeInfo(bb)->get_bb_index())
290 if(
HLS->
STG->
GetAstg()->GetStateInfo(std::get<0>(s_pair))->loopId != 0 &&
291 HLS->
STG->
GetAstg()->GetStateInfo(std::get<0>(s_pair))->loopId !=
294 THROW_ERROR(
"Attempting to change the loopId of state " +
295 HLS->
STG->
GetAstg()->GetStateInfo(std::get<0>(s_pair))->name);
297 HLS->
STG->
GetAstg()->GetStateInfo(std::get<0>(s_pair))->loopId =
306 if(bbs.find(bb_1) != bbs.end())
309 for(
const auto s1 : op1_run)
312 THROW_ASSERT(info->loopId == 0 || info->loopId == loop->GetId(),
313 "The same operation is performed in multiple loops");
316 if(bbs.find(bb_2) != bbs.end())
319 for(
const auto s2 : op2_run)
322 THROW_ASSERT(info->loopId == 0 || info->loopId == loop->GetId(),
323 "The same operation is performed in multiple loops");
330 for(
const auto s1 : op1_run)
332 std::queue<vertex> to_analyze;
333 std::set<vertex> analyzed;
334 std::queue<vertex> next_frontier;
338 graph::out_edge_iterator out_edge, out_edge_end;
339 while(to_analyze.size() > 0)
341 src = to_analyze.front();
343 analyzed.insert(src);
344 for(boost::tie(out_edge, out_edge_end) = boost::out_edges(src, *stg); out_edge != out_edge_end;
348 if(op1_run.find(tgt) != op1_run.end())
353 if(op2_run.find(tgt) != op2_run.end())
355 if(distance % initiation_time == 0)
362 if(analyzed.find(tgt) != analyzed.end())
364 next_frontier.push(tgt);
367 if(to_analyze.size() == 0)
369 to_analyze = next_frontier;
379 for(
const auto s1 : op1_run)
381 if(op2_run.find(s1) != op2_run.end())
394 "start_op map does not have this chained vertex " +
get_name(state));
395 return start_op.find(state)->second;
412 for(boost::tie(ie_it, ie_it_end) = boost::in_edges(v1, *cdg); ie_it != ie_it_end; ++ie_it)
414 vertex cer0_v1 = boost::source(*ie_it, *cdg);
426 for(boost::tie(ie_it, ie_it_end) = boost::in_edges(v2, *cdg); ie_it != ie_it_end; ++ie_it)
428 vertex cer0_v2 = boost::source(*ie_it, *cdg);
void add_state_in_for_var(unsigned int var, vertex op, vertex state, vertex state_in)
put into relation for a given variable used in a state the state from which the variable comes ...
Class specification to contain liveness information.
Data structure representing the entire HLS information.
void add_state_out_for_var(unsigned int var, vertex op, vertex state, vertex state_in)
put into relation for a given variable defined in a state the state to which the variable goes ...
std::map< vertex, std::map< vertex, std::map< unsigned int, CustomOrderedSet< vertex > > > > state_out_definitions
store along which transitions the variable has to be stored
std::string ToString() const
Print this node as string in gimple format.
This file contains the structures needed to manage a graph that will represent the state transition g...
const CustomOrderedSet< vertex > & get_state_where_end(vertex op) const
return in which support vertex the operation is ending
std::map< vertex, std::map< vertex, std::map< unsigned int, CustomOrderedSet< vertex > > > > state_in_definitions
store where a variable comes from given a support state and an operation
const tree_managerRef TreeM
The tree manager.
bool has_op_where_defined(unsigned int var) const
return true in case there exist an operation defining it
void erase_el_live_out(const vertex &v, unsigned int var)
erase a variable from the live out
const CustomOrderedSet< unsigned int > empty_set
used to return a reference to an empty set
std::map< vertex, CustomOrderedSet< vertex > > running_operations
store where an operation run and need its input
StateTransitionGraphRef GetAstg()
Returns pointer to state transition graph created.
boost::graph_traits< graph >::in_edge_iterator InEdgeIterator
in_edge_iterator definition.
#define GET_BB_INDEX(data, vertex_index)
Macro returning the index of the basic block which the node belongs to.
const CustomOrderedSet< vertex > & get_state_in(vertex state, vertex op, unsigned int var) const
given a variable and a state it returns the set of states from which the variable may come ...
bool has_state_out(vertex state, vertex op, unsigned int var) const
return true in case the variable for a given op and a given state has a state out ...
vertex get_start_op(vertex state) const
Return the operation from which the computation start.
void set_live_in(const vertex &v, unsigned int var)
Store a variable alive at the input of the given vertex.
std::map< vertex, vertex > start_op
map a chained vertex with one of the starting operation
bool are_in_conflict(vertex op1, vertex op2) const
states if two operations are in conflict (i.e.
const tree_nodeRef get_tree_node_const(unsigned int i) const
Return the reference to the i-th tree_node Constant version of get_tree_node.
bool non_in_parallel(vertex v1, vertex v2, const BBGraphConstRef cdg) const
absl::flat_hash_map< T, U, Hash, Eq, Alloc > CustomUnorderedMap
std::map< vertex, CustomOrderedSet< unsigned int > > live_in
This is the map from each vertex to the set of variables live at the input of vertex.
std::map< unsigned int, vertex > var_op_definition
store which operation defines the variable
liveness(const HLS_managerRef HLSMgr, const ParameterConstRef Param)
Constructor.
Basic block control flow graph with feedback.
boost::graph_traits< graph >::vertex_descriptor vertex
vertex definition.
This file contains the structures needed to manage a graph that will represent the state transition g...
const HLS_managerRef HLSMgr
const CustomOrderedSet< unsigned int > & get_live_out(const vertex &v) const
Get the set of variables live at the output of a vertex.
Classes specification of the tree_node data structures.
void erase_el_live_in(const vertex &v, unsigned int var)
erase a variable from the live in
#define THROW_ERROR(str_expr)
helper function used to throw an error in a standard way
std::map< vertex, CustomOrderedSet< unsigned int > > live_out
This is the map from each vertex to the set of variables live at the output of vertex.
const StateTransitionGraphConstRef CGetAstg() const
Returns pointer to state transition graph created.
const CustomOrderedSet< vertex > & get_state_out(vertex state, vertex op, unsigned int var) const
given a variable and a state it returns the set of destination states where the variable may be used ...
std::map< vertex, std::string > names
store the name of each state
void set_start_op(vertex state, vertex op)
Set the starting operation for a specified chained state.
bool has_state_in(vertex state, vertex op, unsigned int var) const
return true in case the variable for a given op and a given state has a state in
void set_live_out(const vertex &v, const CustomOrderedSet< unsigned int > &vars)
Store the variables alive at the output of the given vertex.
std::map< vertex, CustomOrderedSet< vertex > > ending_operations
store where an operation is terminating its execution
Class specification of the basic_block structure.
const CustomOrderedSet< vertex > & get_state_where_run(vertex op) const
return in which support vertex the operation is running
TYPE distance(TYPE position_x[nAtoms], TYPE position_y[nAtoms], TYPE position_z[nAtoms], int i, int j)
const BBNodeInfoConstRef CGetBBNodeInfo(const vertex node) const
Return the info associated with a basic block.
Template borrowed from the ANTLR library by Terence Parr (http://www.jGuru.com - Software rights: htt...
interface of loops finding algorithm
this class is used to manage the command-line or XML options.
const std::string null_vertex_string
null vertex string
unsigned int functionId
this is the identifier of the function to be implemented
StateTransitionGraphManagerRef STG
Store the refcounted state transition graph.
vertex get_op_where_defined(unsigned int var) const
return which operation defines the variable
Data structure definition for high-level synthesis flow.
bool is_defined(unsigned int var) const
return true in case the variable var for a given opoeration v has been defined
#define NULL_VERTEX
null vertex definition
const std::string & get_name(vertex v) const
return the name of the given state
Class specification of the manager of the tree structures extracted from the raw file.
const CustomOrderedSet< unsigned int > & get_live_in(const vertex &v) const
Get the set of variables live at the input of a vertex.
#define THROW_ASSERT(cond, str_expr)
helper function used to check an assert and if needed to throw an error in a standard way ...