PandA-2024.02
port_swapping.hpp
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  */
43 #ifndef PORT_SWAPPING_HPP
44 #define PORT_SWAPPING_HPP
45 
47 #include "hls_function_step.hpp"
48 #include <boost/graph/adjacency_list.hpp>
49 
54 {
55  private:
56  using PSGraph = boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS, boost::no_property,
57  boost::property<boost::edge_color_t, boost::default_color_type>>;
58  using PSEdge = boost::graph_traits<PSGraph>::edge_descriptor;
59  using PSVertex = boost::graph_traits<PSGraph>::vertex_descriptor;
60  using PSE = std::pair<unsigned int, unsigned int>;
61  using PSVSet = struct
62  {
64  int belongs;
65  int level;
66  };
67  using PSMultiStart = struct
68  {
69  std::vector<PSVSet> vset;
70  std::vector<PSE> spt_vector_edges;
71  std::vector<PSE> co_tree_vector_edges;
72  std::vector<PSE> odd_co_tree_vector_edges;
73  long unsigned int cardinality;
74  };
75 
76  protected:
83  ComputeHLSRelationships(const DesignFlowStep::RelationshipType relationship_type) const override;
84 
85  public:
90  port_swapping(const ParameterConstRef Param, const HLS_managerRef HLSMgr, unsigned int funId,
91  const DesignFlowManagerConstRef design_flow_manager);
92 
96  ~port_swapping() override;
97 
105  void vertex_levels(const std::vector<PSE>& spt_edges, PSVertex root, size_t num_vertices_g,
106  std::vector<PSVSet>& vset);
107 
115  int vertex_distance(const std::vector<PSE>& spt_edges, PSVertex root, PSVertex dest, std::vector<PSVSet>& vset);
116 
122  PSVertex find_max_degree(const CustomOrderedSet<std::pair<PSVertex, unsigned int>>& dSet);
123 
129  void update_degree(PSGraph g2, CustomOrderedSet<std::pair<PSVertex, unsigned int>>& dSet);
130 
137  PSVertex get_co_tree_vertex(PSVertex vertex, const std::vector<PSE>& edges);
138 
146  void port_swapping_algorithm(PSGraph& g, std::vector<PSMultiStart>& vector_sets, size_t num_vertices_g,
147  PSVertex root);
148 
154  std::vector<std::pair<PSVertex, unsigned int>> p_swap(PSGraph& g);
155 
161  bool is_commutative_op(const std::string& operation);
162 
169  unsigned int get_results(PSVertex operand, const std::vector<std::pair<PSVertex, unsigned int>>& results);
170 
176 };
177 #endif
const HLS_managerRef HLSMgr
information about all the HLS synthesis
Definition: hls_step.hpp:205
PSVertex find_max_degree(const CustomOrderedSet< std::pair< PSVertex, unsigned int >> &dSet)
This function finds the maximum degree (out_edges) of a vertex.
~port_swapping() override
Destructor.
std::vector< PSE > spt_vector_edges
RelationshipType
The relationship type.
const unsigned int funId
identifier of the function to be processed (0 means that it is a global step)
long unsigned int cardinality
struct { PSVertex v PSVSet
std::vector< PSE > co_tree_vector_edges
struct { std::vector< PSVSet > vset PSMultiStart
DesignFlowStep_Status InternalExec() override
Execute the step.
port_swapping(const ParameterConstRef Param, const HLS_managerRef HLSMgr, unsigned int funId, const DesignFlowManagerConstRef design_flow_manager)
Constructor.
unsigned edges[4545]
Definition: graph.h:25
boost::graph_traits< PSGraph >::vertex_descriptor PSVertex
This class specifies the characteristic of a particular operation working on a given functional unit...
std::pair< unsigned int, unsigned int > PSE
unsigned int get_results(PSVertex operand, const std::vector< std::pair< PSVertex, unsigned int >> &results)
This function returns the belonging set of a given vertex.
std::vector< std::pair< PSVertex, unsigned int > > p_swap(PSGraph &g)
This function is the wrapper that executes port_swapping_algorithms and extracts the best solution...
boost::graph_traits< graph >::vertex_descriptor vertex
vertex definition.
Definition: graph.hpp:1303
const Wrefcount< const DesignFlowManager > design_flow_manager
The design flow manager.
bool is_commutative_op(const std::string &operation)
This function checks if an operation is commutative or not.
DesignFlowStep_Status
The status of a step.
PSVertex get_co_tree_vertex(PSVertex vertex, const std::vector< PSE > &edges)
This function selects the right vertex from the co_tree_edges vector.
boost::adjacency_list< boost::vecS, boost::vecS, boost::undirectedS, boost::no_property, boost::property< boost::edge_color_t, boost::default_color_type > > PSGraph
const CustomUnorderedSet< std::tuple< HLSFlowStep_Type, HLSFlowStepSpecializationConstRef, HLSFlowStep_Relationship > > ComputeHLSRelationships(const DesignFlowStep::RelationshipType relationship_type) const override
Compute the relationship of this step.
boost::graph_traits< PSGraph >::edge_descriptor PSEdge
superclass include
int vertex_distance(const std::vector< PSE > &spt_edges, PSVertex root, PSVertex dest, std::vector< PSVSet > &vset)
This function calculates the distances between two vertices in a spanning tree.
Template borrowed from the ANTLR library by Terence Parr (http://www.jGuru.com - Software rights: htt...
Definition: refcount.hpp:94
void update_degree(PSGraph g2, CustomOrderedSet< std::pair< PSVertex, unsigned int >> &dSet)
This function updates the degree of all the vertices.
std::vector< PSE > odd_co_tree_vector_edges
Superclass include.
void vertex_levels(const std::vector< PSE > &spt_edges, PSVertex root, size_t num_vertices_g, std::vector< PSVSet > &vset)
This function calculates the levels of all te vertices starting from root.
void port_swapping_algorithm(PSGraph &g, std::vector< PSMultiStart > &vector_sets, size_t num_vertices_g, PSVertex root)
This function computes the port_swapping.

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