PandA-2024.02
vertex_coloring_register.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  */
44 
45 #include "Parameter.hpp"
46 #include "behavioral_helper.hpp"
47 #include "cpu_time.hpp"
48 #include "dbgPrintHelper.hpp"
49 #include "dsatur2_coloring.hpp"
50 #include "hls.hpp"
51 #include "hls_manager.hpp"
52 #include "liveness.hpp"
53 #include "reg_binding.hpp"
55 #include "utility.hpp"
56 
57 #include <vector>
58 
60  unsigned int _funId,
61  const DesignFlowManagerConstRef _design_flow_manager)
62  : conflict_based_register(_Param, _HLSMgr, _funId, _design_flow_manager,
64 {
65 }
66 
68 
70 {
71  long step_time = 0;
73  {
74  START_TIME(step_time);
75  }
77 
80 
83  const std::list<vertex>& support = HLS->Rliv->get_support();
84 
85  const auto vEnd = support.end();
86  for(auto vIt = support.begin(); vIt != vEnd; ++vIt)
87  {
88  const CustomOrderedSet<unsigned int>& live = HLS->Rliv->get_live_in(*vIt);
89  auto k_end = live.end();
90  for(auto k = live.begin(); k != k_end; ++k)
91  {
92  unsigned int storage_value_index = HLS->storage_value_information->get_storage_value_index(*vIt, *k);
93  HLS->Rreg->bind(storage_value_index, static_cast<unsigned int>(color[storage_value_index]));
94  }
95  }
96  delete cg;
97  HLS->Rreg->set_used_regs(static_cast<unsigned int>(num_colors));
99  {
100  STOP_TIME(step_time);
101  }
103  {
105  }
107  "-->Register binding information for function " +
108  HLSMgr->CGetFunctionBehavior(funId)->CGetBehavioralHelper()->get_function_name() + ":");
110  std::string("---Register allocation algorithm obtains ") +
111  (num_colors == register_lower_bound ? "an optimal" : "a sub-optimal") +
112  " result: " + std::to_string(num_colors) + " registers" +
113  (num_colors == register_lower_bound ? "" : ("(LB:" + STR(register_lower_bound) + ")")));
115  {
116  HLS->Rreg->print();
117  }
119  {
121  "Time to perform register binding: " + print_cpu_time(step_time) + " seconds");
122  }
125  {
127  }
129 }
Class specification to contain liveness information.
boost::iterator_property_map< cg_vertices_size_type *, cg_vertex_index_map, cg_vertices_size_type, cg_vertices_size_type & > color
const HLS_managerRef HLSMgr
information about all the HLS synthesis
Definition: hls_step.hpp:205
Data structure representing the entire HLS information.
File containing functions and utilities to support the printing of debug messagges.
refcount< reg_binding > reg_bindingRef
RefCount type definition of the reg_binding class structure.
vertex_coloring_register(const ParameterConstRef Param, const HLS_managerRef HLSMgr, unsigned int funId, const DesignFlowManagerConstRef design_flow_manager)
Constructor of the class.
const int output_level
The output level.
Class managing the register binding.
Definition: reg_binding.hpp:70
property_traits< ColorMap >::value_type dsatur2_coloring(const VertexListGraph &G, ColorMap color)
coloring of a graph following the DSATUR heuristic (version2)
#define INDENT_OUT_MEX(outLevel, curOutLevel, mex)
void set_used_regs(unsigned int regs)
sets number of used register
const unsigned int funId
identifier of the function to be processed (0 means that it is a global step)
Boost-based implementation of a heuristic sequential coloring algorithm based on the work of Daniel B...
void bind(unsigned int sv, unsigned int index)
conflict_graph * cg
conflict graph
#define OUTPUT_LEVEL_MINIMUM
minimum debugging print is performed.
Include a set of utilities used to manage CPU time measures.
#define STR(s)
Macro which performs a lexical_cast to a string.
boost::graph_traits< conflict_graph >::vertices_size_type cg_vertices_size_type
const std::list< vertex > & get_support() const
return the support set of the live in/out
Definition: liveness.hpp:212
#define START_TIME(time_var)
Macro used to store the start time into time_var.
Definition: cpu_time.hpp:133
Data structure used to store the register binding of variables.
StorageValueInformationRef storage_value_information
data-structure for storage values
Definition: hls.hpp:130
static const uint32_t k[]
Definition: sha-256.c:22
HLSFlowStep_Type
Definition: hls_step.hpp:95
#define STOP_TIME(time_var)
Macro used to store the elapsed time into time_var.
Definition: cpu_time.hpp:136
DesignFlowStep_Status
The status of a step.
This file collects some utility functions and macros.
reg_bindingRef Rreg
Store the refcounted register binding of the variables.
Definition: hls.hpp:133
unsigned int register_lower_bound
lower bound
This package is used to define the storage value scheme adopted by the register allocation algorithms...
livenessRef Rliv
data-structure containing the variable liveness
Definition: hls.hpp:127
std::string print_cpu_time(long int t)
massage a long which represents a time interval in milliseconds, into a string suitable for output ...
Definition: cpu_time.hpp:110
virtual void print() const
Function that prints the class variable2obj.
Definition: Variable.hpp:82
Class specification of a coloring based register allocation algorithm.
#define OUTPUT_LEVEL_PEDANTIC
verbose debugging print is performed.
DesignFlowStep_Status RegisterBinding() final
#define OUTPUT_LEVEL_VERY_PEDANTIC
verbose debugging print is performed.
hlsRef HLS
HLS data structure of the function to be analyzed.
virtual unsigned int get_storage_value_index(vertex curr_vertex, unsigned int var_index)=0
Returns the index of the storage value associated with the variable in a given vertex.
Template borrowed from the ANTLR library by Terence Parr (http://www.jGuru.com - Software rights: htt...
Definition: refcount.hpp:94
this class is used to manage the command-line or XML options.
Data structure definition for high-level synthesis flow.
~vertex_coloring_register() override
const CustomOrderedSet< unsigned int > & get_live_in(const vertex &v) const
Get the set of variables live at the input of a vertex.
Definition: liveness.cpp:109

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