PandA-2024.02
liveness.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  */
45 #ifndef LIVENESS_HPP
46 #define LIVENESS_HPP
47 
49 #include "graph.hpp"
50 
52 #include <list>
53 #include <string>
54 
55 #include "custom_map.hpp"
56 #include "custom_set.hpp"
57 
59 #include "refcount.hpp"
60 
71 
72 class liveness
73 {
74  private:
77 
80 
82  std::map<vertex, CustomOrderedSet<unsigned int>> live_in;
83 
85  std::map<vertex, CustomOrderedSet<unsigned int>> live_out;
86 
88  const std::string null_vertex_string;
89 
92 
94  std::list<vertex> support_set;
95 
97  std::map<unsigned int, vertex> var_op_definition;
98 
100  std::map<vertex, CustomOrderedSet<vertex>> ending_operations;
101 
103  std::map<vertex, CustomOrderedSet<vertex>> running_operations;
104 
106  std::map<vertex, std::map<vertex, std::map<unsigned int, CustomOrderedSet<vertex>>>> state_in_definitions;
107 
109  std::map<vertex, std::map<vertex, std::map<unsigned int, CustomOrderedSet<vertex>>>> state_out_definitions;
110 
112  std::map<vertex, std::string> names;
113 
116 
118 
119  public:
125  liveness(const HLS_managerRef HLSMgr, const ParameterConstRef Param);
126 
130  ~liveness();
131 
137  void set_live_in(const vertex& v, unsigned int var);
138 
144  void set_live_in(const vertex& v, const CustomOrderedSet<unsigned int>& live_set);
145 
154 
160  void erase_el_live_in(const vertex& v, unsigned int var);
161 
167  void set_live_out(const vertex& v, const CustomOrderedSet<unsigned int>& vars);
168 
174  void set_live_out(const vertex& v, unsigned int var);
175 
184 
190  void erase_el_live_out(const vertex& v, unsigned int var);
191 
197  const CustomOrderedSet<unsigned int>& get_live_in(const vertex& v) const;
198 
204  const CustomOrderedSet<unsigned int>& get_live_out(const vertex& v) const;
205 
207  std::map<vertex, vertex> start_op;
208 
212  const std::list<vertex>& get_support() const
213  {
214  return support_set;
215  }
216 
221  vertex get_op_where_defined(unsigned int var) const;
222 
226  bool has_op_where_defined(unsigned int var) const;
227 
233  void add_op_definition(unsigned int var, vertex v)
234  {
235  var_op_definition[var] = v;
236  }
237 
242  bool is_defined(unsigned int var) const;
243 
250  const CustomOrderedSet<vertex>& get_state_in(vertex state, vertex op, unsigned int var) const;
251 
258  bool has_state_in(vertex state, vertex op, unsigned int var) const;
259 
266  void add_state_in_for_var(unsigned int var, vertex op, vertex state, vertex state_in);
267 
274  const CustomOrderedSet<vertex>& get_state_out(vertex state, vertex op, unsigned int var) const;
275 
282  bool has_state_out(vertex state, vertex op, unsigned int var) const;
283 
290  void add_state_out_for_var(unsigned int var, vertex op, vertex state, vertex state_in);
291 
297 
304  {
305  ending_operations[op].insert(v);
306  }
307 
313 
320  {
321  running_operations[op].insert(v);
322  }
323 
329  void add_name(vertex v, const std::string& name)
330  {
331  names[v] = name;
332  }
333 
338  const std::string& get_name(vertex v) const;
339 
345  {
346  support_set.push_front(v);
347  }
348 
354  bool are_in_conflict(vertex op1, vertex op2) const;
355 
356  // activate conflicts with reachability computation
357  // void compute_conflicts_with_reachability(hlsRef _HLS)
358  //{
359  // HLS = _HLS;
360  //}
361 
362  void set_HLS(hlsRef _HLS)
363  {
364  HLS = _HLS;
365  }
366 
373  vertex get_start_op(vertex state) const;
374 
380  void set_start_op(vertex state, vertex op);
381 
387  {
388  dummy_states.insert(state);
389  }
390 
397  {
398  return dummy_states.find(state) != dummy_states.end();
399  }
400 
401  bool non_in_parallel(vertex v1, vertex v2, const BBGraphConstRef cdg) const;
402 };
403 
404 // refcount definition for class
406 
407 #endif
void add_state_in_for_var(unsigned int var, vertex op, vertex state, vertex state_in)
put into relation for a given variable used in a state the state from which the variable comes ...
Definition: liveness.cpp:195
hlsRef HLS
Definition: liveness.hpp:114
void add_state_out_for_var(unsigned int var, vertex op, vertex state, vertex state_in)
put into relation for a given variable defined in a state the state to which the variable goes ...
Definition: liveness.cpp:230
std::map< vertex, std::map< vertex, std::map< unsigned int, CustomOrderedSet< vertex > > > > state_out_definitions
store along which transitions the variable has to be stored
Definition: liveness.hpp:109
~liveness()
Destructor.
void add_dummy_state(vertex state)
add a state to the set of dummy vertices
Definition: liveness.hpp:386
const CustomOrderedSet< vertex > & get_state_where_end(vertex op) const
return in which support vertex the operation is ending
Definition: liveness.cpp:235
std::map< vertex, std::map< vertex, std::map< unsigned int, CustomOrderedSet< vertex > > > > state_in_definitions
store where a variable comes from given a support state and an operation
Definition: liveness.hpp:106
void add_state_for_running_op(vertex op, vertex v)
add a running state for a given operation
Definition: liveness.hpp:319
const tree_managerRef TreeM
The tree manager.
Definition: liveness.hpp:76
bool has_op_where_defined(unsigned int var) const
return true in case there exist an operation defining it
Definition: liveness.cpp:161
void erase_el_live_out(const vertex &v, unsigned int var)
erase a variable from the live out
Definition: liveness.cpp:137
bool is_a_dummy_state(vertex state)
check if a state is a dummy state
Definition: liveness.hpp:396
const CustomOrderedSet< unsigned int > empty_set
used to return a reference to an empty set
Definition: liveness.hpp:91
This class manages the tree structures extracted from the raw file.
std::map< vertex, CustomOrderedSet< vertex > > running_operations
store where an operation run and need its input
Definition: liveness.hpp:103
void add_state_for_ending_op(vertex op, vertex v)
add an ending state for a given operation
Definition: liveness.hpp:303
Class specification of the graph structures.
const CustomOrderedSet< vertex > & get_state_in(vertex state, vertex op, unsigned int var) const
given a variable and a state it returns the set of states from which the variable may come ...
Definition: liveness.cpp:166
void add_support_state(vertex v)
add a support state
Definition: liveness.hpp:344
bool has_state_out(vertex state, vertex op, unsigned int var) const
return true in case the variable for a given op and a given state has a state out ...
Definition: liveness.cpp:212
vertex get_start_op(vertex state) const
Return the operation from which the computation start.
Definition: liveness.cpp:391
REF_FORWARD_DECL(hls)
redefinition of map to manage ordered/unordered structures
void set_live_in(const vertex &v, unsigned int var)
Store a variable alive at the input of the given vertex.
Definition: liveness.cpp:88
std::map< vertex, vertex > start_op
map a chained vertex with one of the starting operation
Definition: liveness.hpp:207
bool are_in_conflict(vertex op1, vertex op2) const
states if two operations are in conflict (i.e.
Definition: liveness.cpp:257
CONSTREF_FORWARD_DECL(Parameter)
bool non_in_parallel(vertex v1, vertex v2, const BBGraphConstRef cdg) const
Definition: liveness.cpp:403
const std::list< vertex > & get_support() const
return the support set of the live in/out
Definition: liveness.hpp:212
Class used to describe a particular graph with basic blocks as nodes.
void set_HLS(hlsRef _HLS)
Definition: liveness.hpp:362
std::map< vertex, CustomOrderedSet< unsigned int > > live_in
This is the map from each vertex to the set of variables live at the input of vertex.
Definition: liveness.hpp:82
const ParameterConstRef Param
class containing all the parameters
Definition: liveness.hpp:79
std::map< unsigned int, vertex > var_op_definition
store which operation defines the variable
Definition: liveness.hpp:97
liveness(const HLS_managerRef HLSMgr, const ParameterConstRef Param)
Constructor.
Definition: liveness.cpp:70
redefinition of set to manage ordered/unordered structures
boost::graph_traits< graph >::vertex_descriptor vertex
vertex definition.
Definition: graph.hpp:1303
const HLS_managerRef HLSMgr
Definition: liveness.hpp:115
const CustomOrderedSet< unsigned int > & get_live_out(const vertex &v) const
Get the set of variables live at the output of a vertex.
Definition: liveness.cpp:142
void erase_el_live_in(const vertex &v, unsigned int var)
erase a variable from the live in
Definition: liveness.cpp:104
std::map< vertex, CustomOrderedSet< unsigned int > > live_out
This is the map from each vertex to the set of variables live at the output of vertex.
Definition: liveness.hpp:85
Template definition of refcount.
std::list< vertex > support_set
vertex over which the live in/out is computed
Definition: liveness.hpp:94
const CustomOrderedSet< vertex > & get_state_out(vertex state, vertex op, unsigned int var) const
given a variable and a state it returns the set of destination states where the variable may be used ...
Definition: liveness.cpp:200
std::map< vertex, std::string > names
store the name of each state
Definition: liveness.hpp:112
void set_start_op(vertex state, vertex op)
Set the starting operation for a specified chained state.
Definition: liveness.cpp:398
bool has_state_in(vertex state, vertex op, unsigned int var) const
return true in case the variable for a given op and a given state has a state in
Definition: liveness.cpp:177
void set_live_out(const vertex &v, const CustomOrderedSet< unsigned int > &vars)
Store the variables alive at the output of the given vertex.
Definition: liveness.cpp:126
std::map< vertex, CustomOrderedSet< vertex > > ending_operations
store where an operation is terminating its execution
Definition: liveness.hpp:100
void add_name(vertex v, const std::string &name)
define the name of a state
Definition: liveness.hpp:329
const CustomOrderedSet< vertex > & get_state_where_run(vertex op) const
return in which support vertex the operation is running
Definition: liveness.cpp:241
const std::string null_vertex_string
null vertex string
Definition: liveness.hpp:88
CustomOrderedSet< vertex > dummy_states
Definition: liveness.hpp:117
Data structure that contains all information about high level synthesis process.
Definition: hls.hpp:83
vertex get_op_where_defined(unsigned int var) const
return which operation defines the variable
Definition: liveness.cpp:154
void add_op_definition(unsigned int var, vertex v)
add a definition vertex for a variable
Definition: liveness.hpp:233
bool is_defined(unsigned int var) const
return true in case the variable var for a given opoeration v has been defined
Definition: liveness.cpp:78
const std::string & get_name(vertex v) const
return the name of the given state
Definition: liveness.cpp:247
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