PandA-2024.02
ASLAP.cpp
Go to the documentation of this file.
1 /*
2  *
3  * _/_/_/ _/_/ _/ _/ _/_/_/ _/_/
4  * _/ _/ _/ _/ _/_/ _/ _/ _/ _/ _/
5  * _/_/_/ _/_/_/_/ _/ _/_/ _/ _/ _/_/_/_/
6  * _/ _/ _/ _/ _/ _/ _/ _/ _/
7  * _/ _/ _/ _/ _/ _/_/_/ _/ _/
8  *
9  * ***********************************************
10  * PandA Project
11  * URL: http://panda.dei.polimi.it
12  * Politecnico di Milano - DEIB
13  * System Architectures Group
14  * ***********************************************
15  * Copyright (C) 2004-2024 Politecnico di Milano
16  *
17  * This file is part of the PandA framework.
18  *
19  * The PandA framework is free software; you can redistribute it and/or modify
20  * it under the terms of the GNU General Public License as published by
21  * the Free Software Foundation; either version 3 of the License, or
22  * (at your option) any later version.
23  *
24  * This program is distributed in the hope that it will be useful,
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27  * GNU General Public License for more details.
28  *
29  * You should have received a copy of the GNU General Public License
30  * along with this program. If not, see <http://www.gnu.org/licenses/>.
31  *
32  */
46 #include "ASLAP.hpp"
47 #include "allocation.hpp"
48 #include "basic_block.hpp"
49 #include "exceptions.hpp"
50 #include "function_behavior.hpp"
51 #include "graph.hpp"
52 #include "hls.hpp"
53 #include "hls_constraints.hpp"
54 #include "hls_manager.hpp"
55 #include "op_graph.hpp"
56 #include "technology_node.hpp"
57 #include "utility.hpp"
58 
59 #include "Vertex.hpp"
60 #include "fu_binding.hpp"
61 #include "schedule.hpp"
62 
64 #include "Parameter.hpp"
65 
67 #include <boost/graph/reverse_graph.hpp>
68 
71 
73 #include <cmath>
74 
76 #include "behavioral_helper.hpp"
77 
78 #include "cpu_time.hpp"
79 #include "dbgPrintHelper.hpp" // for DEBUG_LEVEL_
80 #include "string_manipulation.hpp" // for GET_CLASS
81 
82 // in case asap and alap are computed with/without constraints on the resources available
83 #define WITH_CONSTRAINT 0
84 
85 ASLAP::ASLAP(const HLS_managerConstRef _hls_manager, const hlsRef HLS, const bool _speculation,
86  const CustomUnorderedSet<vertex>& _operations, const ParameterConstRef _parameters,
87  unsigned int _ctrl_step_multiplier)
88  : ASAP(ScheduleRef(new Schedule(
89  _hls_manager,
90  _hls_manager->CGetFunctionBehavior(HLS->functionId)->CGetBehavioralHelper()->get_function_index(),
91  _hls_manager->CGetFunctionBehavior(HLS->functionId)->CGetOpGraph(FunctionBehavior::FLSAODG), _parameters))),
92  ALAP(ScheduleRef(new Schedule(
93  _hls_manager,
94  _hls_manager->CGetFunctionBehavior(HLS->functionId)->CGetBehavioralHelper()->get_function_index(),
95  _hls_manager->CGetFunctionBehavior(HLS->functionId)->CGetOpGraph(FunctionBehavior::FLSAODG), _parameters))),
96  min_tot_csteps(0u),
97  max_tot_csteps(0u),
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)
105 {
106  if(speculation)
107  {
108  beh_graph = _hls_manager->CGetFunctionBehavior(HLS->functionId)->CGetOpGraph(FunctionBehavior::SG);
109  }
110  else
111  {
112  beh_graph = _hls_manager->CGetFunctionBehavior(HLS->functionId)->CGetOpGraph(FunctionBehavior::FLSAODG);
113  }
114  VertexIterator it, end_it;
115  for(boost::tie(it, end_it) = boost::vertices(*beh_graph); !has_branching_blocks && it != end_it; it++)
116  {
118  {
119  has_branching_blocks = true;
120  }
121  }
122  const std::deque<vertex>& ls = _hls_manager->CGetFunctionBehavior(HLS->functionId)->get_levels();
123  for(auto l : ls)
124  {
125  if(_operations.find(l) != _operations.end())
126  {
127  levels.push_back(l);
128  }
129  }
130 }
131 
133 {
134  return beh_graph;
135 }
136 
137 void ASLAP::print(std::ostream& os) const
138 {
139  if(ASAP->num_scheduled())
140  {
141  os << "ASAP\n";
142  ASAP->print();
143  os << std::endl;
144  }
145  if(ALAP->num_scheduled())
146  {
147  os << "ALAP\n";
148  ALAP->print();
149  os << std::endl;
150  }
151 }
152 
156 struct p_update_check : public boost::dfs_visitor<>
157 {
158  private:
162  const std::string& op_name;
167 
168  public:
172  p_update_check(vertex v, const std::string& name, vertex2int& A_p, const OpGraphConstRef g)
173  : s(v), op_name(name), ASAP_p(A_p), beh_graph(g)
174  {
175  }
176 
180  template <class Vertex, class Graph>
181  void discover_vertex(Vertex v, const Graph&) const
182  {
183  if(v != s && beh_graph->CGetOpNodeInfo(v)->GetOperation() == op_name)
184  {
185  ASAP_p[v]++;
186  }
187  }
188 };
189 
191 {
192  InEdgeIterator ei, ei_end;
193  unsigned int m_k;
194  auto cur_et = ControlStep(0u);
195 
197  vertex2int ASAP_nip;
198 
200  vertex2int ASAP_p;
201 
202  ASAP_nip.resize(levels.begin(), levels.end(), 0);
203  ASAP_p.resize(levels.begin(), levels.end(), 0);
204 
205  for(auto level : levels)
206  {
207  // Updating ASAP_p information
208  p_update_check vis(level, beh_graph->CGetOpNodeInfo(level)->GetOperation(), ASAP_p, beh_graph);
209  std::vector<boost::default_color_type> color_vec(boost::num_vertices(*beh_graph));
210  boost::depth_first_visit(*beh_graph, level, vis,
211  boost::make_iterator_property_map(color_vec.begin(),
212  boost::get(boost::vertex_index_t(), *beh_graph),
213  boost::white_color));
214  ASAP_nip[level] = ASAP_p[level];
215  for(boost::tie(ei, ei_end) = boost::in_edges(level, *beh_graph); ei != ei_end; ei++)
216  {
217  auto v = boost::source(*ei, *beh_graph);
218  if(!operations.contains(v))
219  {
220  continue;
221  }
222  if(beh_graph->CGetOpNodeInfo(v)->GetOperation() == beh_graph->CGetOpNodeInfo(level)->GetOperation())
223  {
224  ASAP_nip[level]--;
225  }
226  }
227  }
228 
229  VertexIterator vi, vi_end;
230 
231  for(auto v : levels)
232  {
233  if(ASAP_p[v] == 0)
234  {
235  continue;
236  }
237  m_k = allocation_information->max_number_of_resources(v);
238  cur_et = ControlStep(
239  static_cast<unsigned int>(ceil(from_strongtype_cast<double>(GetCycleLatency(v, Allocation_MinMax::MIN)) /
240  static_cast<double>(ctrl_step_multiplier))) *
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)))));
243  if(cur_et > 0u)
244  {
245  --cur_et;
246  }
247  min_tot_csteps = min_tot_csteps < cur_et ? cur_et : min_tot_csteps;
248  const auto schedule = ASAP->get_cstep(v).second < cur_et ? cur_et : ASAP->get_cstep(v).second;
249  ASAP->set_execution(v, schedule);
250  }
252  {
254  vertex2int::const_iterator i_end = ASAP_p.end();
255  for(vertex2int::const_iterator i = ASAP_p.begin(); i != i_end; ++i)
256  {
258  GET_NAME(beh_graph, i->first) + " - " + std::to_string(i->second));
259  }
261 
263  vertex2int::const_iterator ai_end = ASAP_nip.end();
264  for(vertex2int::const_iterator ai = ASAP_nip.begin(); ai != ai_end; ++ai)
265  {
267  GET_NAME(beh_graph, ai->first) + " - " + std::to_string(ai->second));
268  }
270  }
271 }
272 
273 void ASLAP::compute_ASAP(const ScheduleConstRef partial_schedule)
274 {
275  vertex vi;
276  InEdgeIterator ei, ei_end;
277  // Store the current execution time
278  double cur_start;
279  vertex2float finish_time; //
280  VertexIterator vI, vI_end;
281  boost::tie(vI, vI_end) = boost::vertices(*beh_graph);
282 
283  ASAP->clear();
284  finish_time.resize(vI, vI_end, 0); //
285  min_tot_csteps = ControlStep(0u);
286  if(partial_schedule)
287  {
288  for(auto level : levels)
289  {
290  if(partial_schedule && partial_schedule->is_scheduled(level))
291  {
292  ASAP->set_execution(level, partial_schedule->get_cstep(level).second);
293  }
294  }
295  }
296  if(WITH_CONSTRAINT && !has_branching_blocks) // When no IF statements are present this function returns 1.
297  {
298  PRINT_DBG_MEX(DEBUG_LEVEL_PEDANTIC, debug_level, "ASAP: add_constraints_to_ASAP");
300  }
301 
302  for(auto level : levels)
303  {
304  const auto op_cycles = GetCycleLatency(level, Allocation_MinMax::MIN);
305  cur_start = 0.0;
306 
307  for(boost::tie(ei, ei_end) = boost::in_edges(level, *beh_graph); ei != ei_end; ei++)
308  {
309  vi = boost::source(*ei, *beh_graph);
310  cur_start = finish_time.at(vi) < cur_start ? cur_start : finish_time.at(vi);
311  // PRINT_DBG_MEX(DEBUG_LEVEL_VERBOSE, debug_level, GET_NAME(beh_graph, vi) + " -> " +GET_NAME(beh_graph,
312  // level) + " cur_start " + std::to_string(cur_start));
313  }
314 
315  finish_time.at(level) = cur_start + from_strongtype_cast<double>(op_cycles);
316  ControlStep curr_asap = ASAP->is_scheduled(level) ? ASAP->get_cstep(level).second : ControlStep(0u);
317  curr_asap = ControlStep(static_cast<unsigned int>(cur_start / ctrl_step_multiplier)) > curr_asap ?
318  ControlStep(static_cast<unsigned int>(cur_start / ctrl_step_multiplier)) :
319  curr_asap;
320  ASAP->set_execution(level, curr_asap);
322  GET_NAME(beh_graph, level) + " cur_start " + std::to_string(cur_start) + " finish_time[level] " +
323  std::to_string(finish_time[level]));
324  min_tot_csteps = min_tot_csteps < curr_asap ? curr_asap : min_tot_csteps;
326  GET_NAME(beh_graph, level) + " - " + STR(ASAP->get_cstep(level).second));
327  }
329 }
330 
332 {
333  //
334  // ALAP is computed as ASAP: 0 is the last step and at this point of the implementation ALAP[*i] is the distance from
335  // last step
336  OutEdgeIterator ei, ei_end;
337  unsigned int m_k;
338 
340  vertex2int ALAP_nip;
342  vertex2int ALAP_p;
343  const boost::reverse_graph<graph> R(*beh_graph);
344 
345  ALAP_nip.resize(levels.begin(), levels.end(), 0);
346  ALAP_p.resize(levels.begin(), levels.end(), 0);
347  auto iend = levels.rend();
348  for(auto i = levels.rbegin(); i != iend; ++i)
349  {
350  p_update_check vis(*i, beh_graph->CGetOpNodeInfo(*i)->GetOperation(), ALAP_p, beh_graph);
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++)
357  {
358  auto v = boost::target(*ei, *beh_graph);
359  if(!operations.contains(v))
360  {
361  continue;
362  }
363  if(beh_graph->CGetOpNodeInfo(v)->GetOperation() == beh_graph->CGetOpNodeInfo(*i)->GetOperation())
364  {
365  ALAP_nip[*i]--;
366  }
367  }
368  }
369  auto cur_et = ControlStep(0u);
370  VertexIterator vi, vi_end;
371  for(auto v : levels)
372  {
373  if(ALAP_p(v) == 0)
374  {
375  continue;
376  }
377  m_k = allocation_information->min_number_of_resources(v);
378  cur_et = ControlStep(static_cast<unsigned int>(
379  (ceil(from_strongtype_cast<double>(GetCycleLatency(v, Allocation_MinMax::MIN)) /
380  static_cast<double>(ctrl_step_multiplier))) *
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))))));
383  max_tot_csteps = max_tot_csteps < cur_et ? cur_et : max_tot_csteps;
384 
385  const auto schedule = ALAP->get_cstep(v).second < cur_et ? cur_et : ALAP->get_cstep(v).second;
386  ALAP->set_execution(v, schedule);
387  }
389  {
391  vertex2int::const_iterator i_end = ALAP_p.end();
392  for(vertex2int::const_iterator i = ALAP_p.begin(); i != i_end; ++i)
393  {
395  GET_NAME(beh_graph, i->first) + " - " + std::to_string(i->second));
396  }
398 
400  vertex2int::const_iterator ai_end = ALAP_nip.end();
401  for(vertex2int::const_iterator ai = ALAP_nip.begin(); ai != ai_end; ++ai)
402  {
404  GET_NAME(beh_graph, ai->first) + " - " + std::to_string(ai->second));
405  }
407 
409 #ifndef NDEBUG
410  for(auto level : levels)
411  {
413  GET_NAME(beh_graph, level) + " - " + STR(ALAP->get_cstep(level).second));
414  }
415 #endif
417  }
418 }
419 
420 void ASLAP::compute_ALAP(ALAP_method met, const ScheduleConstRef partial_schedule, bool* feasible,
421  const ControlStep est_upper_bound)
422 {
423  switch(met)
424  {
425  case ALAP_fast:
426  max_tot_csteps = ControlStep(0u);
427  THROW_ASSERT(!partial_schedule, "ASLAP::compute_ALAP - partial_schedule not expected");
428  update_ALAP(ControlStep(0u), feasible);
429  break;
430  case ALAP_worst_case:
431  // THROW_ASSERT(!part_sch, "ASLAP::compute_ALAP - !part_sch failed into ALAP_worst_case");
432  ALAP->clear();
433  max_tot_csteps = ControlStep(0u);
435  break;
436  case ALAP_with_upper:
437  {
438  PRINT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "Computing alap starting from list based");
439  THROW_ASSERT(partial_schedule, "ASLAP::compute_ALAP - partial_schedule expected");
440  max_tot_csteps = partial_schedule->get_csteps() - 1u;
443  break;
444  }
446  {
447  PRINT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "Computing alap starting from list based minus one");
448  THROW_ASSERT(partial_schedule, "ASLAP::compute_ALAP - partial_schedule expected");
449  if(partial_schedule->get_csteps() < 2u)
450  {
451  *feasible = false;
452  }
453  else
454  {
455  max_tot_csteps = partial_schedule->get_csteps() - 2u;
456  update_ALAP(max_tot_csteps, feasible);
457  }
459  break;
460  }
462  {
463  THROW_ASSERT(partial_schedule, "ASLAP::compute_ALAP - partial_schedule expected");
464  update_ALAP(est_upper_bound - 1u, feasible, partial_schedule);
466  break;
467  }
468  default:
469  THROW_ERROR("InconsistentDataStructure");
470  break;
471  }
473 }
474 
475 void ASLAP::update_ALAP(const ControlStep maxc, bool* feasible, const ScheduleConstRef partial_schedule)
476 {
477  ALAP->clear();
478  max_tot_csteps = maxc;
479  if(partial_schedule)
480  {
481  for(auto level : levels)
482  {
483  if(partial_schedule && partial_schedule->is_scheduled(level))
484  {
485  ALAP->set_execution(level, max_tot_csteps - partial_schedule->get_cstep(level).second);
486  }
487  }
488  }
489  if(WITH_CONSTRAINT && !has_branching_blocks) // When no IF statements are present this function returns 1.
490  {
491  PRINT_DBG_MEX(DEBUG_LEVEL_PEDANTIC, debug_level, "ALAP: add_constraints_to_ALAP");
493  }
494  compute_ALAP_fast(feasible);
495  if(feasible && *feasible && max_tot_csteps > maxc)
496  {
497  *feasible = false;
498  }
499 }
500 
501 void ASLAP::compute_ALAP_fast(bool* feasible)
502 {
503  // This function is used both in fast case and
504  vertex vi;
505  OutEdgeIterator ei, ei_end;
506  double cur_rev_start;
507  vertex2float Rev_finish_time;
508  VertexIterator vI, vI_end;
509  boost::tie(vI, vI_end) = boost::vertices(*beh_graph);
510  Rev_finish_time.resize(vI, vI_end, 0);
511 
512  auto i_end = levels.rend();
513  for(auto i = levels.rbegin(); i != i_end; ++i)
514  {
515  const auto op_cycles = GetCycleLatency(*i, Allocation_MinMax::MIN);
516  cur_rev_start = 0.0;
517  for(boost::tie(ei, ei_end) = boost::out_edges(*i, *beh_graph); ei != ei_end; ei++)
518  {
519  vi = boost::target(*ei, *beh_graph);
520  cur_rev_start = Rev_finish_time.at(vi) < cur_rev_start ? cur_rev_start : Rev_finish_time.at(vi);
521  }
522  Rev_finish_time.at(*i) = cur_rev_start + from_strongtype_cast<double>(op_cycles);
523 
524  ControlStep rev_curr_alap = ALAP->is_scheduled(*i) ? ALAP->get_cstep(*i).second : ControlStep(0u);
525  const auto rev_finish_time =
526  ControlStep(static_cast<unsigned int>((Rev_finish_time.at(*i) - 1) / ctrl_step_multiplier));
527  rev_curr_alap = rev_finish_time > rev_curr_alap ? rev_finish_time : rev_curr_alap;
528  ALAP->set_execution(*i, rev_curr_alap);
529  max_tot_csteps = max_tot_csteps < rev_curr_alap ? rev_curr_alap : max_tot_csteps;
530  }
531 
533  for(auto level : levels)
534  {
536  if(feasible && *feasible)
537  {
538  *feasible = ALAP->get_cstep(level) >= ASAP->get_cstep(level);
539  }
541  GET_NAME(beh_graph, level) + " - " + STR(ALAP->get_cstep(level).second));
542  }
543 }
544 
546 {
547  vertex vi;
548  OutEdgeIterator ei, ei_end;
549  // Store the max reverse level
550  auto max_rev_level = ControlStep(0u);
551  // Store the current reverse level
552  std::map<ControlStep, ControlStep> rev_levels_to_cycles;
553  std::map<ControlStep, ControlStep> max_et;
554 
555  auto i_end = levels.rend();
556  for(auto i = levels.rbegin(); i != i_end; ++i)
557  {
558  for(boost::tie(ei, ei_end) = boost::out_edges(*i, *beh_graph); ei != ei_end; ei++)
559  {
560  vi = boost::target(*ei, *beh_graph);
561  if(!operations.contains(vi))
562  {
563  continue;
564  }
565  const ControlStep cur_rev_level = ALAP->get_cstep(vi).second + 1u;
566  max_rev_level = std::max(max_rev_level, cur_rev_level);
567  const auto schedule = ALAP->get_cstep(*i).second < cur_rev_level ? cur_rev_level : ALAP->get_cstep(*i).second;
568  ALAP->set_execution(*i, schedule);
569  }
570  if(rev_levels_to_cycles.find(ALAP->get_cstep(*i).second) == rev_levels_to_cycles.end())
571  {
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)));
574  }
575  rev_levels_to_cycles.find(ALAP->get_cstep(*i).second)->second +=
576  static_cast<unsigned int>(allocation_information->get_attribute_of_fu_per_op(
578  max_et.insert(std::pair<ControlStep, ControlStep>(
579  ALAP->get_cstep(*i).second,
580  std::max(max_et.find(ALAP->get_cstep(*i).second)->second,
581  ControlStep(static_cast<unsigned int>(
582  ceil(from_strongtype_cast<double>(GetCycleLatency(*i, Allocation_MinMax::MAX)) /
583  static_cast<double>(ctrl_step_multiplier)))))));
584  }
585  auto levelr = max_rev_level - 1u;
586  do
587  {
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);
591  for(auto level : levels)
592  {
594  rev_levels_to_cycles.find(ALAP->get_cstep(level).second)->second -
595  ControlStep(static_cast<unsigned int>(allocation_information->get_attribute_of_fu_per_op(
598  }
599 }
600 
602 {
603  const CustomOrderedSet<unsigned int>& fu_set = allocation_information->can_implement_set(operation);
604  double execution_time = allocation_information->get_attribute_of_fu_per_op(operation, beh_graph, minmax,
606  PRINT_DBG_MEX(DEBUG_LEVEL_PEDANTIC, debug_level, GET_NAME(beh_graph, operation) + " - ex=" + STR(execution_time));
607  if(execution_time > 0.0)
608  {
609  return allocation_information->op_et_to_cycles(execution_time, clock_period / ctrl_step_multiplier);
610  }
611  else
612  {
613  for(auto const fu_type : fu_set)
614  {
615  if(allocation_information->get_stage_period(fu_type, operation, beh_graph) != 0.0)
616  {
617  return ControlStep(ctrl_step_multiplier) *
618  allocation_information->get_cycles(fu_type, operation, beh_graph);
619  }
620  if(not allocation_information->is_operation_bounded(beh_graph, operation, fu_type))
621  {
622  return ControlStep(ctrl_step_multiplier);
623  }
624  }
625  }
626  return ControlStep(0u);
627 }
#define TYPE_SWITCH
constant identifying the node type of a SWITCH operation.
Definition: op_graph.hpp:105
#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.
Definition: graph.hpp:1312
#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.
string target
Definition: lenet_tvm.py:16
#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.
Definition: op_graph.hpp:100
#define R
Definition: mips.c:40
Class managing the schedule of the operations.
Definition: schedule.hpp:118
const AllocationInformationConstRef allocation_information
The allocation data structure.
Definition: ASLAP.hpp:101
AbsControlStep get_cstep(const vertex &op) const
Returns the clock cycle where the given operation has been scheduled.
Definition: schedule.cpp:270
unsigned int num_scheduled() const
Returns the number of scheduled operations.
Definition: schedule.cpp:324
void set_csteps(ControlStep cs)
This method sets the number of control steps.
Definition: schedule.hpp:225
ControlStep min_tot_csteps
variable storing the minimum number of control steps required to schedule the graph.
Definition: ASLAP.hpp:85
#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.
Definition: graph.hpp:1310
exceptions managed by PandA
ScheduleRef ALAP
Array storing the ALAP values of the nodes in the graph.
Definition: ASLAP.hpp:82
#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...
Definition: ASLAP.cpp:156
Allocation_MinMax
Definition: allocation.hpp:89
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.
Definition: ASLAP.cpp:420
ScheduleRef ASAP
Array storing the ASAP values of the nodes in the graph.
Definition: ASLAP.hpp:79
vertex s
vertex
Definition: ASLAP.cpp:160
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.
#define max
Definition: backprop.h:17
const OpNodeInfoConstRef CGetOpNodeInfo(const vertex node) const
Returns the info associated with a node.
Definition: op_graph.hpp:843
Class specifying ALAP and ASAP algorithms.
p_update_check(vertex v, const std::string &name, vertex2int &A_p, const OpGraphConstRef g)
Constructor.
Definition: ASLAP.cpp:172
int debug_level
debug level
Definition: ASLAP.hpp:110
void print(std::ostream &os) const
Function that prints the class ASLAP.
Definition: ASLAP.cpp:137
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.
Definition: ASLAP.cpp:273
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.
Definition: ASLAP.cpp:190
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
Definition: ASLAP.hpp:98
bool speculation
speculation
Definition: ASLAP.hpp:104
boost::graph_traits< graph >::vertex_descriptor vertex
vertex definition.
Definition: graph.hpp:1303
void resize(Iterator left, Iterator right, data_type val)
Definition: Vertex.hpp:132
#define TYPE_FOR
constant string identifying the node type of an WHILE operation.
Definition: op_graph.hpp:115
boost::graph_traits< graph >::vertex_iterator VertexIterator
vertex_iterator definition.
Definition: graph.hpp:1307
ControlStep GetCycleLatency(const vertex operation, Allocation_MinMax minmax) const
Return the number of cycles required to execute an operation.
Definition: ASLAP.cpp:601
This package is used by all HLS packages to manage resource constraints and characteristics.
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.
Definition: ASLAP.cpp:85
const OpGraphConstRef CGetOpGraph() const
Gets graph.
Definition: ASLAP.cpp:132
#define THROW_ERROR(str_expr)
helper function used to throw an error in a standard way
Definition: exceptions.hpp:263
Data structure definition for HLS constraints.
ControlStep max_tot_csteps
variable storing the maximum number of control steps required to schedule the graph.
Definition: ASLAP.hpp:88
unsigned int ctrl_step_multiplier
multiplier used to take into account chaining during asap/alap computation
Definition: ASLAP.hpp:113
std::deque< vertex > levels
constant variable storing the reference to the array of vertexes sorted by topological order associat...
Definition: ASLAP.hpp:95
void discover_vertex(Vertex v, const Graph &) const
Template function used to discover vertex.
Definition: ASLAP.cpp:181
void print(fu_bindingRef Rfu=fu_bindingRef()) const
Function that prints the class schedule.
Definition: schedule.cpp:126
void add_constraints_to_ALAP()
Modify the ALAP scheduling taking into account also technology constraints.
Definition: ASLAP.cpp:331
vertex2int & ASAP_p
asap values
Definition: ASLAP.cpp:164
void compute_ALAP_worst_case()
Compute ALAP using list based euristic to identify the total number of control steps.
Definition: ASLAP.cpp:545
Speculation graph.
bool is_scheduled(const vertex &op) const
Returns true if the given operation has been already scheduled, false otherwise.
Definition: schedule.cpp:259
void compute_ALAP_fast(bool *feasible=nullptr)
Compute the standard ALAP scheduling with uncontrained resource.
Definition: ASLAP.cpp:501
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.
Definition: ASLAP.cpp:475
Data structures used in operations graph.
Template borrowed from the ANTLR library by Terence Parr (http://www.jGuru.com - Software rights: htt...
Definition: refcount.hpp:94
void clear()
Erases the current results.
Definition: schedule.cpp:329
#define TYPE_WHILE
constant string identifying the node type of an WHILE operation.
Definition: op_graph.hpp:110
int level
Definition: main.c:98
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
Definition: ASLAP.cpp:83
OpGraphConstRef beh_graph
the graph to be scheduled
Definition: ASLAP.hpp:91
unsigned int functionId
this is the identifier of the function to be implemented
Definition: hls.hpp:87
const CustomUnorderedSet< vertex > & operations
relevant vertex for the aslap scheduling
Definition: ASLAP.hpp:116
ALAP_method
Possible type of ALAP method currently implemented.
Definition: ASLAP.hpp:209
This package is used by all HLS packages to manage resource constraints and characteristics.
const std::string & op_name
string that identifies operation name
Definition: ASLAP.cpp:162
#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.
Definition: schedule.cpp:232
A brief description of the C++ Header File.
const OpGraphConstRef beh_graph
behavioral specification in terms of graph
Definition: ASLAP.cpp:166
const double clock_period
The clock period.
Definition: ASLAP.hpp:107
#define THROW_ASSERT(cond, str_expr)
helper function used to check an assert and if needed to throw an error in a standard way ...
Definition: exceptions.hpp:289

Generated on Mon Feb 12 2024 13:02:54 for PandA-2024.02 by doxygen 1.8.13