PandA-2024.02
values_scheme.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 "values_scheme.hpp"
41 
43 #include "Parameter.hpp"
44 
46 #include "hls.hpp"
47 #include "hls_manager.hpp"
48 
52 
54 #include "liveness.hpp"
55 
57 #include "behavioral_helper.hpp"
58 #include "tree_helper.hpp"
59 
61 #include "cpu_time.hpp"
62 
66 
67 values_scheme::values_scheme(const ParameterConstRef _Param, const HLS_managerRef _HLSMgr, unsigned int _funId,
68  const DesignFlowManagerConstRef _design_flow_manager)
69  : storage_value_insertion(_Param, _HLSMgr, _funId, _design_flow_manager,
71 {
72 }
73 
75 
77 {
79  if(HLSMgr->CGetFunctionBehavior(HLS->functionId)->is_simple_pipeline())
80  {
83  }
84  else
85  {
87  }
89 }
90 
92 {
93  long step_time = 0;
95  {
96  START_TIME(step_time);
97  }
98  THROW_ASSERT(HLS->Rliv, "Liveness analysis not yet computed");
99  const tree_managerRef TreeM = HLSMgr->get_tree_manager();
100  unsigned int i = 0;
101  vertex current_vertex;
102  vertex start_state = HLS->STG->get_entry_state();
103  const std::list<vertex>& support = HLS->Rliv->get_support();
104  last_intermediate_state fetch_previous(HLS->STG->GetStg(),
105  HLSMgr->CGetFunctionBehavior(funId)->is_simple_pipeline());
106  next_unique_state get_next(HLS->STG->GetStg());
107 
108  const auto vEnd = support.end();
109  for(auto vIt = support.begin(); vIt != vEnd; ++vIt)
110  {
111  // std::cerr << "current state for sv " << HLS->Rliv->get_name(*vIt) << std::endl;
112  const CustomOrderedSet<unsigned int>& live = HLS->Rliv->get_live_in(*vIt);
113  const CustomOrderedSet<unsigned int>::const_iterator k_end = live.end();
114  for(auto k = live.begin(); k != k_end; ++k)
115  {
117  {
120  i++;
121  }
122  }
123  if(HLSMgr->CGetFunctionBehavior(HLS->functionId)->is_simple_pipeline())
124  {
125  std::list<vertex> running_ops = HLS->STG->GetStg()->GetStateInfo(*vIt)->executing_operations;
126  const auto opEnd = running_ops.end();
127  vertex state_0 = get_next(start_state);
128  for(auto opIt = running_ops.begin(); opIt != opEnd; ++opIt)
129  {
130  std::vector<HLS_manager::io_binding_type> inVars = HLSMgr->get_required_values(HLS->functionId, *opIt);
131  for(unsigned int num = 0; num != inVars.size(); num++)
132  {
133  unsigned int var = std::get<0>(inVars[num]);
134  if(var != 0 && tree_helper::is_parameter(TreeM, var))
135  {
136  current_vertex = *vIt;
137  while(current_vertex != state_0)
138  {
139  if(!HLS->storage_value_information->is_a_storage_value(current_vertex, var))
140  {
141  HLS->storage_value_information->set_storage_value_index(current_vertex, var, i);
143  i++;
144  }
145  current_vertex = fetch_previous(start_state, current_vertex);
146  }
147  }
148  }
149  }
150  }
151  }
154  {
156  }
158  "-->Storage Value Information of function " +
159  HLSMgr->CGetFunctionBehavior(funId)->CGetBehavioralHelper()->get_function_name() + ":");
160  INDENT_OUT_MEX(OUTPUT_LEVEL_MINIMUM, output_level, "---Number of storage values inserted: " + std::to_string(i));
162  {
163  STOP_TIME(step_time);
165  "Time to compute storage value information: " + print_cpu_time(step_time) + " seconds");
166  }
169  {
171  }
173 }
void Initialize() override
Initialize the step (i.e., like a constructor, but executed just before exec.
Class specification to contain liveness information.
const HLS_managerRef HLSMgr
information about all the HLS synthesis
Definition: hls_step.hpp:205
Data structure representing the entire HLS information.
This file contains the structures needed to manage a graph that will represent the state transition g...
const int output_level
The output level.
vertex get_entry_state() const
Gets vertex that represents state that contains entry node.
#define INDENT_OUT_MEX(outLevel, curOutLevel, mex)
const unsigned int funId
identifier of the function to be processed (0 means that it is a global step)
static bool is_parameter(const tree_managerConstRef &TM, const unsigned int index)
return true in case the index corresponds to a parameter in ssa form or not
DesignFlowStep_Status InternalExec() override
Execute the step.
refcount< StorageValueInformationPipeline > StorageValueInformationPipelineRef
virtual bool is_a_storage_value(vertex curr_vertex, unsigned int var_index)=0
return true in case a storage value exist for the pair vertex variable
#define OUTPUT_LEVEL_MINIMUM
minimum debugging print is performed.
Include a set of utilities used to manage CPU time measures.
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
StorageValueInformationRef storage_value_information
data-structure for storage values
Definition: hls.hpp:130
virtual void set_storage_value_index(vertex curr_state, unsigned int variable, unsigned int sv)=0
assign a storage value to a couple state-variable
static const uint32_t k[]
Definition: sha-256.c:22
HLSFlowStep_Type
Definition: hls_step.hpp:95
values_scheme(const ParameterConstRef Param, const HLS_managerRef HLSMgr, unsigned int funId, const DesignFlowManagerConstRef design_flow_manager)
Constructor of the class.
#define STOP_TIME(time_var)
Macro used to store the elapsed time into time_var.
Definition: cpu_time.hpp:136
boost::graph_traits< graph >::vertex_descriptor vertex
vertex definition.
Definition: graph.hpp:1303
This file contains the structures needed to manage a graph that will represent the state transition g...
DesignFlowStep_Status
The status of a step.
livenessRef Rliv
data-structure containing the variable liveness
Definition: hls.hpp:127
This file collects some utility functions.
refcount< StorageValueInformationFsm > StorageValueInformationFsmRef
Class specification of values scheme for the storage value insertion phase.
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
void Initialize()
Initialize the step (i.e., like a constructor)
~values_scheme() override
Destructor of the class.
#define OUTPUT_LEVEL_PEDANTIC
verbose debugging print is performed.
hlsRef HLS
HLS data structure of the function to be analyzed.
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.
StateTransitionGraphRef GetStg()
Returns pointer to state transition graph created.
unsigned int functionId
this is the identifier of the function to be implemented
Definition: hls.hpp:87
StateTransitionGraphManagerRef STG
Store the refcounted state transition graph.
Definition: hls.hpp:124
void Initialize() override
Initialize the step (i.e., like a constructor, but executed just before exec.
CustomUnorderedMap< unsigned int, unsigned int > variable_index_map
put into relation storage value index with variables
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
This package is used to define the storage value scheme adopted by the register allocation algorithms...
unsigned int number_of_storage_values
current number of storage values
#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