PandA-2024.02
chaining_information.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  */
39 #include "chaining_information.hpp"
41 
43 #include "op_graph.hpp"
44 
46 #include <boost/pending/disjoint_sets.hpp>
47 
49 #include "hls.hpp"
50 #include "hls_manager.hpp"
51 
53 {
54  using const_vertex_index_pmap_t = boost::property_map<OpGraph, boost::vertex_index_t>::const_type;
55  using rank_pmap_type = boost::iterator_property_map<std::vector<std::size_t>::iterator, boost::identity_property_map,
56  std::vector<std::size_t>::value_type>;
57  using pred_pmap_type = boost::iterator_property_map<std::vector<std::size_t>::iterator, boost::identity_property_map,
58  std::vector<std::size_t>::value_type>;
59 
61 
62  boost::graph_traits<graph>::vertices_size_type n_vert;
63  std::vector<std::size_t> rank_map;
64  std::vector<std::size_t> pred_map;
67  boost::disjoint_sets<rank_pmap_type, pred_pmap_type> ds;
68 
69  explicit ChainingSet(const OpGraphConstRef flow_graph)
70  : cindex_pmap(boost::get(boost::vertex_index_t(), *flow_graph)),
71  n_vert(boost::num_vertices(*flow_graph)),
72  rank_map(2 * n_vert),
73  pred_map(2 * n_vert),
74  rank_pmap(rank_map.begin()),
75  pred_pmap(pred_map.begin()),
76  ds(boost::disjoint_sets<rank_pmap_type, pred_pmap_type>(rank_pmap, pred_pmap))
77  {
78  }
79 
81  {
82  return cindex_pmap[v] * 2;
83  }
85  {
86  return cindex_pmap[v] * 2 + 1;
87  }
88 };
89 
90 ChainingInformation::ChainingInformation(const HLS_managerConstRef _HLS_mgr, const unsigned int _function_id)
91  : HLS_mgr(_HLS_mgr), function_id(_function_id)
92 {
93 }
94 
96 {
97  return chaining_relation->ds.find_set(chaining_relation->get_index0(op1));
98 }
99 
101 {
102  return chaining_relation->ds.find_set(chaining_relation->get_index1(op1));
103 }
104 
106 {
107  const OpGraphConstRef flow_graph =
108  HLS_mgr.lock()->CGetFunctionBehavior(function_id)->CGetOpGraph(FunctionBehavior::FLSAODG);
109  const hlsRef HLS = HLS_mgr.lock()->get_HLS(function_id);
110 
111  HLS->chaining_information->chaining_relation = ChainingSetRef(new ChainingSet(flow_graph));
112  VertexIterator vi, vi_end;
113  for(boost::tie(vi, vi_end) = boost::vertices(*flow_graph); vi != vi_end; ++vi)
114  {
115  vertex s = *vi;
116  HLS->chaining_information->chaining_relation->ds.make_set(chaining_relation->get_index0(s));
117  HLS->chaining_information->chaining_relation->ds.make_set(chaining_relation->get_index1(s));
118  }
119 }
120 
122 {
123  return is_chained_with.find(v) != is_chained_with.end();
124 }
125 
127 {
128  return (chaining_relation->ds.find_set(chaining_relation->get_index0(tgt)) ==
129  chaining_relation->ds.find_set(chaining_relation->get_index1(src)) ||
130  chaining_relation->ds.find_set(chaining_relation->get_index1(tgt)) ==
131  chaining_relation->ds.find_set(chaining_relation->get_index0(src)));
132 }
133 
135 {
136  chaining_relation->ds.union_set(chaining_relation->get_index0(op1), chaining_relation->get_index1(src));
137 }
138 
140 {
141  chaining_relation->ds.union_set(chaining_relation->get_index1(op1), chaining_relation->get_index0(tgt));
142 }
Data structure representing the entire HLS information.
const_vertex_index_pmap_t cindex_pmap
class containing information about chaining
size_t get_representative_out(vertex op1) const
Return the representative vertex associated with the chained vertices set in output.
void add_chained_vertices_in(vertex op1, vertex src)
put into relation the vertices whith respect the chained vertices connected with the input ...
boost::disjoint_sets< rank_pmap_type, pred_pmap_type > ds
This algorithm is to find coloring of a graph Algorithm: Let G = (V,E) be a graph with vertices v_1...
boost::iterator_property_map< std::vector< std::size_t >::iterator, boost::identity_property_map, std::vector< std::size_t >::value_type > pred_pmap_type
void Initialize()
Initialize the object (i.e., like a constructor, but executed just before exec of a step) ...
boost::property_map< OpGraph, boost::vertex_index_t >::const_type const_vertex_index_pmap_t
bool is_chained_vertex(vertex v) const
return true in case the vertex is in chaining with something
ChainingInformation(const HLS_managerConstRef HLS_mgr, const unsigned int function_id)
Constructor.
const unsigned int function_id
The index of the function.
void add_chained_vertices_out(vertex op1, vertex tgt)
put into relation the vertices whith respect the chained vertices connected with the output ...
pred_pmap_type pred_pmap
bool may_be_chained_ops(vertex tgt, vertex src) const
check if two operations are chained in at least one state
boost::graph_traits< graph >::vertex_descriptor vertex
vertex definition.
Definition: graph.hpp:1303
boost::graph_traits< graph >::vertex_iterator VertexIterator
vertex_iterator definition.
Definition: graph.hpp:1307
ChainingSet(const OpGraphConstRef flow_graph)
refcount< T > lock() const
Definition: refcount.hpp:212
const Wrefcount< const HLS_manager > HLS_mgr
The HLS manager.
std::size_t get_index1(vertex v) const
CustomOrderedSet< vertex > is_chained_with
set of vertices chained with something
ChainingSetRef chaining_relation
relation between vertices in terms of chaining in input or in output
rank_pmap_type rank_pmap
unsigned int size_t
Definition: test.c:1
size_t get_representative_in(vertex op1) const
Return the representative vertex associated with the chained vertices set in input.
Header include.
Data structures used in operations graph.
System dependence + anti-dependence + output dependence graph + flow graph.
boost::iterator_property_map< std::vector< std::size_t >::iterator, boost::identity_property_map, std::vector< std::size_t >::value_type > rank_pmap_type
boost::graph_traits< graph >::vertices_size_type n_vert
Data structure definition for high-level synthesis flow.
std::size_t get_index0(vertex v) const
std::vector< std::size_t > pred_map
ChainingInformationRef chaining_information
Store the refcounted chaining info.
Definition: hls.hpp:142
std::vector< std::size_t > rank_map

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