67 #include <boost/graph/reverse_graph.hpp> 83 #define WITH_CONSTRAINT 0 87 unsigned int _ctrl_step_multiplier)
90 _hls_manager->CGetFunctionBehavior(HLS->functionId)->CGetBehavioralHelper()->get_function_index(),
91 _hls_manager->CGetFunctionBehavior(HLS->functionId)->CGetOpGraph(
FunctionBehavior::FLSAODG), _parameters))),
94 _hls_manager->CGetFunctionBehavior(HLS->functionId)->CGetBehavioralHelper()->get_function_index(),
95 _hls_manager->CGetFunctionBehavior(HLS->functionId)->CGetOpGraph(
FunctionBehavior::FLSAODG), _parameters))),
98 has_branching_blocks(
false),
99 allocation_information(HLS->allocation_information),
100 speculation(_speculation),
101 clock_period(HLS->HLS_C->get_clock_period() * HLS->HLS_C->get_clock_period_resource_fraction()),
102 debug_level(_parameters->get_class_debug_level(
GET_CLASS(*this))),
103 ctrl_step_multiplier(_ctrl_step_multiplier),
104 operations(_operations)
122 const std::deque<vertex>& ls = _hls_manager->CGetFunctionBehavior(HLS->
functionId)->get_levels();
125 if(_operations.find(l) != _operations.end())
173 : s(v), op_name(name), ASAP_p(A_p), beh_graph(g)
180 template <
class Vertex,
class Graph>
183 if(v != s && beh_graph->
CGetOpNodeInfo(v)->GetOperation() == op_name)
194 auto cur_et = ControlStep(0u);
209 std::vector<boost::default_color_type> color_vec(boost::num_vertices(*
beh_graph));
211 boost::make_iterator_property_map(color_vec.begin(),
212 boost::get(boost::vertex_index_t(), *
beh_graph),
213 boost::white_color));
215 for(boost::tie(ei, ei_end) = boost::in_edges(
level, *
beh_graph); ei != ei_end; ei++)
238 cur_et = ControlStep(
241 std::max(static_cast<unsigned int>(ceil(static_cast<double>(ASAP_p[v]) / m_k)),
242 (1 + static_cast<unsigned int>(ceil(static_cast<double>(ASAP_nip[v]) / m_k)))));
254 vertex2int::const_iterator i_end = ASAP_p.end();
255 for(vertex2int::const_iterator i = ASAP_p.begin(); i != i_end; ++i)
263 vertex2int::const_iterator ai_end = ASAP_nip.end();
264 for(vertex2int::const_iterator ai = ASAP_nip.begin(); ai != ai_end; ++ai)
281 boost::tie(vI, vI_end) = boost::vertices(*
beh_graph);
284 finish_time.
resize(vI, vI_end, 0);
290 if(partial_schedule && partial_schedule->is_scheduled(
level))
307 for(boost::tie(ei, ei_end) = boost::in_edges(
level, *
beh_graph); ei != ei_end; ei++)
310 cur_start = finish_time.at(vi) < cur_start ? cur_start : finish_time.at(vi);
317 curr_asap = ControlStep(static_cast<unsigned int>(cur_start /
ctrl_step_multiplier)) > curr_asap ?
323 std::to_string(finish_time[
level]));
343 const boost::reverse_graph<graph>
R(*
beh_graph);
347 auto iend =
levels.rend();
348 for(
auto i =
levels.rbegin(); i != iend; ++i)
351 std::vector<boost::default_color_type> color_vec(boost::num_vertices(R));
352 boost::depth_first_visit(R, *i, vis,
353 boost::make_iterator_property_map(
354 color_vec.begin(), boost::get(boost::vertex_index_t(), R), boost::white_color));
355 ALAP_nip[*i] = ALAP_p[*i];
356 for(boost::tie(ei, ei_end) = boost::out_edges(*i, *
beh_graph); ei != ei_end; ei++)
369 auto cur_et = ControlStep(0u);
378 cur_et = ControlStep(static_cast<unsigned int>(
381 std::max(static_cast<unsigned int>(ceil(static_cast<double>(ALAP_p[v]) / m_k)),
382 (1 + static_cast<unsigned int>(ceil(static_cast<double>(ALAP_nip[v]) / m_k))))));
391 vertex2int::const_iterator i_end = ALAP_p.end();
392 for(vertex2int::const_iterator i = ALAP_p.begin(); i != i_end; ++i)
400 vertex2int::const_iterator ai_end = ALAP_nip.end();
401 for(vertex2int::const_iterator ai = ALAP_nip.begin(); ai != ai_end; ++ai)
410 for(
auto level : levels)
421 const ControlStep est_upper_bound)
427 THROW_ASSERT(!partial_schedule,
"ASLAP::compute_ALAP - partial_schedule not expected");
439 THROW_ASSERT(partial_schedule,
"ASLAP::compute_ALAP - partial_schedule expected");
448 THROW_ASSERT(partial_schedule,
"ASLAP::compute_ALAP - partial_schedule expected");
449 if(partial_schedule->get_csteps() < 2u)
463 THROW_ASSERT(partial_schedule,
"ASLAP::compute_ALAP - partial_schedule expected");
464 update_ALAP(est_upper_bound - 1u, feasible, partial_schedule);
483 if(partial_schedule && partial_schedule->is_scheduled(
level))
506 double cur_rev_start;
509 boost::tie(vI, vI_end) = boost::vertices(*
beh_graph);
510 Rev_finish_time.
resize(vI, vI_end, 0);
512 auto i_end =
levels.rend();
513 for(
auto i =
levels.rbegin(); i != i_end; ++i)
517 for(boost::tie(ei, ei_end) = boost::out_edges(*i, *
beh_graph); ei != ei_end; ei++)
520 cur_rev_start = Rev_finish_time.at(vi) < cur_rev_start ? cur_rev_start : Rev_finish_time.at(vi);
525 const auto rev_finish_time =
527 rev_curr_alap = rev_finish_time > rev_curr_alap ? rev_finish_time : rev_curr_alap;
536 if(feasible && *feasible)
550 auto max_rev_level = ControlStep(0u);
552 std::map<ControlStep, ControlStep> rev_levels_to_cycles;
553 std::map<ControlStep, ControlStep> max_et;
555 auto i_end =
levels.rend();
556 for(
auto i =
levels.rbegin(); i != i_end; ++i)
558 for(boost::tie(ei, ei_end) = boost::out_edges(*i, *
beh_graph); ei != ei_end; ei++)
565 const ControlStep cur_rev_level =
ALAP->
get_cstep(vi).second + 1u;
566 max_rev_level =
std::max(max_rev_level, cur_rev_level);
570 if(rev_levels_to_cycles.find(
ALAP->
get_cstep(*i).second) == rev_levels_to_cycles.end())
572 rev_levels_to_cycles.insert(std::pair<ControlStep, ControlStep>(
ALAP->
get_cstep(*i).second, ControlStep(0u)));
573 max_et.insert(std::pair<ControlStep, ControlStep>(
ALAP->
get_cstep(*i).second, ControlStep(0u)));
575 rev_levels_to_cycles.find(
ALAP->
get_cstep(*i).second)->second +=
578 max_et.insert(std::pair<ControlStep, ControlStep>(
581 ControlStep(static_cast<unsigned int>(
585 auto levelr = max_rev_level - 1u;
588 rev_levels_to_cycles.find(levelr)->second +=
589 std::max(rev_levels_to_cycles.find(levelr + 1u)->second, max_et.find(levelr + 1u)->second);
590 }
while(levelr != 0u);
607 if(execution_time > 0.0)
613 for(
auto const fu_type : fu_set)
626 return ControlStep(0u);
#define TYPE_SWITCH
constant identifying the node type of a SWITCH operation.
#define DEBUG_LEVEL_VERY_PEDANTIC
extremely verbose debugging print is performed.
Data structure representing the entire HLS information.
boost::graph_traits< graph >::out_edge_iterator OutEdgeIterator
out_edge_iterator definition.
#define GET_TYPE(data, vertex_index)
Helper macro returning the type associated with a node.
File containing functions and utilities to support the printing of debug messagges.
#define PRINT_DBG_MEX(dbgLevel, curDbgLevel, mex)
We are producing a debug version of the program, so the message is printed;.
#define DEBUG_LEVEL_PEDANTIC
very verbose debugging print is performed.
#define GET_CLASS(obj)
Macro returning the actual type of an object.
Dest from_strongtype_cast(Source source)
#define TYPE_IF
constant identifying the node type of an IF operation.
Class managing the schedule of the operations.
const AllocationInformationConstRef allocation_information
The allocation data structure.
AbsControlStep get_cstep(const vertex &op) const
Returns the clock cycle where the given operation has been scheduled.
unsigned int num_scheduled() const
Returns the number of scheduled operations.
void set_csteps(ControlStep cs)
This method sets the number of control steps.
ControlStep min_tot_csteps
variable storing the minimum number of control steps required to schedule the graph.
#define GET_NAME(data, vertex_index)
Helper macro returning the name associated with a node.
Class specification of the graph structures.
Data structures used to manage set of vertexes.
boost::graph_traits< graph >::in_edge_iterator InEdgeIterator
in_edge_iterator definition.
exceptions managed by PandA
ScheduleRef ALAP
Array storing the ALAP values of the nodes in the graph.
#define PRINT_DBG_STRING(dbgLevel, curDbgLevel, mex)
We are producing a debug version of the program, so the message is printed; no newline is added;...
Terminate function used during improve_ASAP_with_constraints visiting and updating of ASAP_p vector...
void compute_ALAP(ALAP_method met, const ScheduleConstRef partial_schedule=ScheduleConstRef(), bool *feasible=nullptr, const ControlStep=ControlStep(0u))
Function that computes the ALAP scheduling of the graph.
ScheduleRef ASAP
Array storing the ASAP values of the nodes in the graph.
Include a set of utilities used to manage CPU time measures.
#define STR(s)
Macro which performs a lexical_cast to a string.
Auxiliary methods for manipulating string.
const OpNodeInfoConstRef CGetOpNodeInfo(const vertex node) const
Returns the info associated with a node.
Class specifying ALAP and ASAP algorithms.
p_update_check(vertex v, const std::string &name, vertex2int &A_p, const OpGraphConstRef g)
Constructor.
int debug_level
debug level
void print(std::ostream &os) const
Function that prints the class ASLAP.
This class specifies the characteristic of a particular operation working on a given functional unit...
void compute_ASAP(const ScheduleConstRef partial_schedule=ScheduleConstRef())
Function that computes the ASAP scheduling of the graph.
Data structure used to store the schedule of the operations.
void add_constraints_to_ASAP()
Modify the ASAP scheduling taking into account also technology constraints.
Class specification of the data structures used to manage technology information. ...
bool has_branching_blocks
is true if the beh_graph has at least one branching block
bool speculation
speculation
boost::graph_traits< graph >::vertex_descriptor vertex
vertex definition.
void resize(Iterator left, Iterator right, data_type val)
#define TYPE_FOR
constant string identifying the node type of an WHILE operation.
boost::graph_traits< graph >::vertex_iterator VertexIterator
vertex_iterator definition.
ControlStep GetCycleLatency(const vertex operation, Allocation_MinMax minmax) const
Return the number of cycles required to execute an operation.
This file collects some utility functions and macros.
ASLAP(const HLS_managerConstRef hls_manager, const hlsRef HLS, const bool speculation, const CustomUnorderedSet< vertex > &operations, const ParameterConstRef parameters, unsigned int _ctrl_step_multiplier)
Constructor.
const OpGraphConstRef CGetOpGraph() const
Gets graph.
#define THROW_ERROR(str_expr)
helper function used to throw an error in a standard way
Data structure definition for HLS constraints.
ControlStep max_tot_csteps
variable storing the maximum number of control steps required to schedule the graph.
unsigned int ctrl_step_multiplier
multiplier used to take into account chaining during asap/alap computation
std::deque< vertex > levels
constant variable storing the reference to the array of vertexes sorted by topological order associat...
void discover_vertex(Vertex v, const Graph &) const
Template function used to discover vertex.
void print(fu_bindingRef Rfu=fu_bindingRef()) const
Function that prints the class schedule.
void add_constraints_to_ALAP()
Modify the ALAP scheduling taking into account also technology constraints.
vertex2int & ASAP_p
asap values
void compute_ALAP_worst_case()
Compute ALAP using list based euristic to identify the total number of control steps.
bool is_scheduled(const vertex &op) const
Returns true if the given operation has been already scheduled, false otherwise.
void compute_ALAP_fast(bool *feasible=nullptr)
Compute the standard ALAP scheduling with uncontrained resource.
Data structure used to store the functional-unit binding of the vertexes.
Class specification of the basic_block structure.
void update_ALAP(const ControlStep maxc, bool *feasible=nullptr, const ScheduleConstRef partial_schedule=ScheduleConstRef())
Update the ALAP by using maxc as upper bound.
Data structures used in operations graph.
Template borrowed from the ANTLR library by Terence Parr (http://www.jGuru.com - Software rights: htt...
void clear()
Erases the current results.
#define TYPE_WHILE
constant string identifying the node type of an WHILE operation.
System dependence + anti-dependence + output dependence graph + flow graph.
this class is used to manage the command-line or XML options.
#define WITH_CONSTRAINT
. include
OpGraphConstRef beh_graph
the graph to be scheduled
unsigned int functionId
this is the identifier of the function to be implemented
const CustomUnorderedSet< vertex > & operations
relevant vertex for the aslap scheduling
ALAP_method
Possible type of ALAP method currently implemented.
This package is used by all HLS packages to manage resource constraints and characteristics.
const std::string & op_name
string that identifies operation name
#define DEBUG_LEVEL_VERBOSE
verbose debugging print is performed.
Data structure definition for high-level synthesis flow.
void set_execution(const vertex &op, ControlStep c_step)
Sets the starting clock cycle for the given operation.
A brief description of the C++ Header File.
const OpGraphConstRef beh_graph
behavioral specification in terms of graph
const double clock_period
The clock period.
#define THROW_ASSERT(cond, str_expr)
helper function used to check an assert and if needed to throw an error in a standard way ...