PandA-2024.02
conflict_based_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 "hls.hpp"
46 
47 #include "liveness.hpp"
48 #include "op_graph.hpp"
49 #include "tree_helper.hpp"
50 
51 #include "Parameter.hpp"
52 #include "dbgPrintHelper.hpp"
53 
54 #include <vector>
55 
58 
60  unsigned int _funId,
61  const DesignFlowManagerConstRef _design_flow_manager,
62  const HLSFlowStep_Type _hls_flow_step_type)
63  : reg_binding_creator(_Param, _HLSMgr, _funId, _design_flow_manager, _hls_flow_step_type), cg(nullptr)
64 {
65 }
66 
68 
70 {
71  THROW_ASSERT(HLS->Rliv, "Liveness analysis not yet computed");
72 
73  unsigned int cg_num_vertices = HLS->storage_value_information->get_number_of_storage_values();
74  cg = new conflict_graph(cg_num_vertices);
75  color_vec.resize(cg_num_vertices);
76  color =
77  boost::iterator_property_map<cg_vertices_size_type*, cg_vertex_index_map, cg_vertices_size_type,
78  cg_vertices_size_type&>(&color_vec.front(), boost::get(boost::vertex_index, *cg));
80  const std::list<vertex>& support = HLS->Rliv->get_support();
81 
82  const auto vEnd = support.end();
83  for(auto vIt = support.begin(); vIt != vEnd; ++vIt)
84  {
85  const CustomOrderedSet<unsigned int>& live = HLS->Rliv->get_live_in(*vIt);
86  register_lower_bound = std::max(static_cast<unsigned int>(live.size()), register_lower_bound);
87  const CustomOrderedSet<unsigned int>::const_iterator k_end = live.end();
88  for(auto k = live.begin(); k != k_end; ++k)
89  {
90  auto k_inner = k;
91  ++k_inner;
92  while(k_inner != k_end)
93  {
94  boost::graph_traits<conflict_graph>::edge_descriptor e1;
95  unsigned int tail = HLS->storage_value_information->get_storage_value_index(*vIt, *k);
96  THROW_ASSERT(tail < cg_num_vertices, "wrong conflict graph index");
97  unsigned int head = HLS->storage_value_information->get_storage_value_index(*vIt, *k_inner);
98  THROW_ASSERT(head < cg_num_vertices, "wrong conflict graph index");
99  boost::add_edge(boost::vertex(tail, *cg), boost::vertex(head, *cg), *cg);
100  ++k_inner;
101  }
102  }
103  }
105  for(unsigned int vj = 1; vj < cg_num_vertices; ++vj)
106  {
107  for(unsigned int vi = 0; vi < vj; ++vi)
108  {
110  {
111  boost::graph_traits<conflict_graph>::edge_descriptor e1;
112  boost::add_edge(boost::vertex(vi, *cg), boost::vertex(vj, *cg), *cg);
113  }
114  }
115  }
116 }
Class specification to contain liveness information.
std::vector< cg_vertices_size_type > color_vec
boost::iterator_property_map< cg_vertices_size_type *, cg_vertex_index_map, cg_vertices_size_type, cg_vertices_size_type & > color
File containing functions and utilities to support the printing of debug messagges.
boost::adjacency_matrix< boost::undirectedS > conflict_graph
conflict_graph * cg
conflict graph
#define max
Definition: backprop.h:17
bool are_value_bitsize_compatible(unsigned int storage_value_index1, unsigned int storage_value_index2) const
return the in case the storage values have compatible size
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
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
boost::graph_traits< graph >::vertex_descriptor vertex
vertex definition.
Definition: graph.hpp:1303
Generic class managing the different register allocation algorithms.
unsigned int register_lower_bound
lower bound
~conflict_based_register() override
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
This file collects some utility functions.
boost::property_map< conflict_graph, boost::vertex_index_t >::const_type cg_vertex_index_map
conflict_based_register(const ParameterConstRef Param, const HLS_managerRef HLSMgr, unsigned int funId, const DesignFlowManagerConstRef design_flow_manager, const HLSFlowStep_Type hls_flow_step_type)
Constructor of the class.
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.
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
Base class specification for register allocation algorithm based on a conflict graph.
this class is used to manage the command-line or XML options.
unsigned int get_number_of_storage_values() const
Returns the number of storage values inserted.
Data structure definition for high-level synthesis flow.
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
#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:53 for PandA-2024.02 by doxygen 1.8.13