PandA-2024.02
hls_step.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  */
43 #include "hls_step.hpp"
45 
47 #include "Parameter.hpp"
48 
50 #include "call_graph.hpp"
51 #include "call_graph_manager.hpp"
52 #include "function_behavior.hpp"
53 
55 #include "design_flow_graph.hpp"
56 #include "design_flow_manager.hpp"
57 
61 
63 #include "hls.hpp"
64 #include "hls_device.hpp"
66 #include "hls_function_step.hpp"
67 #include "hls_manager.hpp"
68 
70 #include "memory.hpp"
71 
73 #include "custom_map.hpp"
74 #include "custom_set.hpp"
75 #include <tuple>
76 
78 #include "technology_manager.hpp"
79 
81 #include "behavioral_helper.hpp"
82 #include "dbgPrintHelper.hpp" // for DEBUG_LEVEL_
83 #include "tree_helper.hpp"
84 #include "tree_manager.hpp"
85 
87 
89 
90 HLS_step::HLS_step(const ParameterConstRef _parameters, const HLS_managerRef _HLSMgr,
91  const DesignFlowManagerConstRef _design_flow_manager, const HLSFlowStep_Type _hls_flow_step_type,
92  const HLSFlowStepSpecializationConstRef _hls_flow_step_specialization)
93  : DesignFlowStep(_design_flow_manager, _parameters),
94  HLSMgr(_HLSMgr),
95  hls_flow_step_type(_hls_flow_step_type),
96  hls_flow_step_specialization(_hls_flow_step_specialization)
97 {
98 }
99 
102 {
103  return CustomUnorderedSet<
104  std::tuple<HLSFlowStep_Type, HLSFlowStepSpecializationConstRef, HLSFlowStep_Relationship>>();
105 }
106 
107 HLS_step::~HLS_step() = default;
108 
110 
111 std::string HLS_step::GetSignature() const
112 {
114 }
115 
118 {
119  return "HLS::" + EnumToName(hls_flow_step_type) +
120  (hls_flow_step_specialization ? "::" + hls_flow_step_specialization->GetSignature() : "");
121 }
122 
123 std::string HLS_step::GetName() const
124 {
125  return "HLS::" + GetKindText();
126 }
127 
128 std::string HLS_step::GetKindText() const
129 {
131  (hls_flow_step_specialization ? "(" + hls_flow_step_specialization->GetKindText() + ")" : "");
132 }
133 
135 {
136  switch(hls_flow_step_type)
137  {
139  return "Unknown";
141  return "AddLibrary";
143  return "Allocation";
145  return "BBStgCreator";
147  return "CdfcModuleBinding";
149  return "CallGraphUnfolding";
151  return "ChordalColoringRegisterBinding";
153  return "ClassicDatapathCreator";
155  return "DatapathCreatorCS";
157  return "DatapathCreatorCSParallel";
159  return "ClassicalHLSSynthesisFlow";
161  return "ColoringRegisterBinding";
163  return "ControlFlowChecker";
165  return "CTestbenchExecution";
167  return "DominatorAllocation";
169  return "DominatorMemoryAllocation";
171  return "DominatorMemoryAllocationCS";
173  return "DominatorFunctionAllocation";
175  return "DryRunEvaluation";
177  return "EasyModuleBinding";
179  return "Evaluation";
181  return "FsmControllerCreator";
183  return "FsmCSControllerCreator";
185  return "FsmNiSsaLiveness";
187  return "GenerateHdl";
188 #if HAVE_SIMULATION_WRAPPER_BUILT
190  return "GenerateSimulationScript";
191 #endif
193  return "GenerateSynthesisScripts";
194 #if HAVE_TASTE
195  case HLSFlowStep_Type::GENERATE_TASTE_HDL_ARCHITECTURE:
196  return "GenerateTasteHDLArchitecture";
197  case HLSFlowStep_Type::GENERATE_TASTE_SYNTHESIS_SCRIPT:
198  return "GenerateTasteSynthesisScript";
199 #endif
201  return "HLSFunctionBitValue";
203  return "HLSFlow";
205  return "InitializeHLS";
207  return "InterfaceCSGeneration";
209  return "ParametricListBased";
211  return "MinimalInterfaceGeneration";
213  return "InferInterfaceGeneration";
215  return "MuxInterconnectionBinding";
216 #if HAVE_FROM_PRAGMA_BUILT
217  case HLSFlowStep_Type::OMP_ALLOCATION:
218  return "OmpAllocation";
219 #endif
220 #if HAVE_FROM_PRAGMA_BUILT
222  return "OmpBodyLoopSynthesisFlow";
223 #endif
224 #if HAVE_FROM_PRAGMA_BUILT
225  case HLSFlowStep_Type::OMP_FOR_WRAPPER_CS_SYNTHESIS_FLOW:
226  return "OmpForWrapperCSSynthesisFlow";
227 #endif
228 #if HAVE_FROM_PRAGMA_BUILT
229  case HLSFlowStep_Type::OMP_FUNCTION_ALLOCATION:
230  return "OmpFunctionAllocation";
231 #endif
232 #if HAVE_FROM_PRAGMA_BUILT
233  case HLSFlowStep_Type::OMP_FUNCTION_ALLOCATION_CS:
234  return "OmpFunctionAllocationCS";
235 #endif
237  return "PipelineControllerCreator";
239  return "PortSwapping";
241  return "SchedChaining";
242 #if HAVE_ILP_BUILT
243  case HLSFlowStep_Type::SDC_SCHEDULING:
244  return "SDCScheduling";
245 #endif
246  case HLSFlowStep_Type::SIMULATION_EVALUATION:
247  return "SimulationEvaluation";
249  return "StandardHLSFlow";
250 #if HAVE_LIBRARY_CHARACTERIZATION_BUILT
251  case HLSFlowStep_Type::SYNTHESIS_EVALUATION:
252  return "SynthesisEvaluation";
253 #endif
254 #if HAVE_TASTE
255  case HLSFlowStep_Type::TASTE_INTERFACE_GENERATION:
256  return "TasteInterfaceGeneration";
257 #endif
259  return "TestbenchGeneration";
261  return "TestVectorParser";
263  return "TopEntityCreation";
265  return "TopEntityCSCreation";
267  return "TopEntityCSParallelCreation";
269  return "TopEntityMemoryMappedCreation";
271  return "UniqueModuleBinding";
273  return "UniqueRegisterBinding";
275  return "ValuesSchemeStorageValueInsertion";
276 #if HAVE_VCD_BUILT
278  return "HWPathComputation";
280  return "HWDiscrepancyAnalysis";
281  case HLSFlowStep_Type::VCD_SIGNAL_SELECTION:
282  return "VcdSignalSelection";
283  case HLSFlowStep_Type::VCD_UTILITY:
284  return "VcdUtility";
285 #endif
287  return "VirtualDesignFlow";
289  return "WB4InterconInterfaceGeneration";
291  return "WB4InterfaceGeneration";
293  return "WeightedCliqueRegisterBinding";
295  return "WriteHLSSummary";
296  default:
297  THROW_UNREACHABLE("HLS flow step type does not exist");
298  }
299  return "";
300 }
301 
303  const DesignFlowStep::RelationshipType relationship_type)
304 {
305  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "-->Computing relationships of " + GetName());
306  const auto* hls_flow_step_factory = GetPointer<const HLSFlowStepFactory>(CGetDesignFlowStepFactory());
307  const DesignFlowGraphConstRef design_flow_graph = design_flow_manager.lock()->CGetDesignFlowGraph();
308  const CallGraphManagerConstRef call_graph_manager = HLSMgr->CGetCallGraphManager();
309  CustomOrderedSet<unsigned int> functions = call_graph_manager->GetReachedBodyFunctions();
310  const tree_managerRef TreeM = HLSMgr->get_tree_manager();
311  const HLS_deviceRef HLS_D = HLSMgr->get_HLS_device();
312  const technology_managerRef TM = HLS_D->get_technology_manager();
313 
315  if(HLSMgr->Rmem && HLSMgr->Rmem->has_implicit_memcpy())
316  {
317  const auto memcpy_function = TreeM->GetFunction(MEMCPY);
318  functions.insert(memcpy_function->index);
319  }
321  steps_to_be_created = ComputeHLSRelationships(relationship_type);
322  for(auto const& step_to_be_created : steps_to_be_created)
323  {
324  switch(std::get<2>(step_to_be_created))
325  {
327  {
328  const auto frontend_flow_step_factory = GetPointer<const FrontendFlowStepFactory>(
329  design_flow_manager.lock()->CGetDesignFlowStepFactory("Frontend"));
330  const auto call_graph_computation_step = design_flow_manager.lock()->GetDesignFlowStep(
331  ApplicationFrontendFlowStep::ComputeSignature(COMPLETE_CALL_GRAPH));
332  const auto cg_design_flow_step =
333  call_graph_computation_step ?
334  design_flow_graph->CGetDesignFlowStepInfo(call_graph_computation_step)->design_flow_step :
335  frontend_flow_step_factory->CreateApplicationFrontendFlowStep(COMPLETE_CALL_GRAPH);
336  design_flow_step_set.insert(cg_design_flow_step);
337  for(auto const function : functions)
338  {
339  std::string function_name = tree_helper::NormalizeTypename(tree_helper::name_function(TreeM, function));
341  if(false) // function already implemented
342  {
343  continue;
344  }
345  vertex hls_step = design_flow_manager.lock()->GetDesignFlowStep(HLSFunctionStep::ComputeSignature(
346  std::get<0>(step_to_be_created), std::get<1>(step_to_be_created), function));
347  const DesignFlowStepRef design_flow_step =
348  hls_step ? design_flow_graph->CGetDesignFlowStepInfo(hls_step)->design_flow_step :
349  hls_flow_step_factory->CreateHLSFlowStep(std::get<0>(step_to_be_created), function,
350  std::get<1>(step_to_be_created));
351  design_flow_step_set.insert(design_flow_step);
352  }
353  break;
354  }
357  {
359  break;
360  }
362  {
363  const auto* frontend_flow_step_factory = GetPointer<const FrontendFlowStepFactory>(
364  design_flow_manager.lock()->CGetDesignFlowStepFactory("Frontend"));
365  const vertex call_graph_computation_step = design_flow_manager.lock()->GetDesignFlowStep(
366  ApplicationFrontendFlowStep::ComputeSignature(COMPLETE_CALL_GRAPH));
367  const DesignFlowStepRef cg_design_flow_step =
368  call_graph_computation_step ?
369  design_flow_graph->CGetDesignFlowStepInfo(call_graph_computation_step)->design_flow_step :
370  frontend_flow_step_factory->CreateApplicationFrontendFlowStep(COMPLETE_CALL_GRAPH);
371  design_flow_step_set.insert(cg_design_flow_step);
373  if(boost::num_vertices(*(call_graph_manager->CGetCallGraph())) == 0)
374  {
375  break;
376  }
377  for(const auto top_function : call_graph_manager->GetRootFunctions())
378  {
379  vertex hls_step = design_flow_manager.lock()->GetDesignFlowStep(HLSFunctionStep::ComputeSignature(
380  std::get<0>(step_to_be_created), std::get<1>(step_to_be_created), top_function));
381  const DesignFlowStepRef design_flow_step =
382  hls_step ? design_flow_graph->CGetDesignFlowStepInfo(hls_step)->design_flow_step :
383  hls_flow_step_factory->CreateHLSFlowStep(std::get<0>(step_to_be_created), top_function,
384  std::get<1>(step_to_be_created));
385  design_flow_step_set.insert(design_flow_step);
386  }
387  break;
388  }
390  {
391  vertex hls_step = design_flow_manager.lock()->GetDesignFlowStep(
392  HLS_step::ComputeSignature(std::get<0>(step_to_be_created), std::get<1>(step_to_be_created)));
393  const DesignFlowStepRef design_flow_step =
394  hls_step ? design_flow_graph->CGetDesignFlowStepInfo(hls_step)->design_flow_step :
395  hls_flow_step_factory->CreateHLSFlowStep(std::get<0>(step_to_be_created), 0,
396  std::get<1>(step_to_be_created));
397  design_flow_step_set.insert(design_flow_step);
398  break;
399  }
400  default:
401  THROW_UNREACHABLE("");
402  }
403  }
404  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "<--Computing relationships of " + GetName());
405 }
406 
407 DesignFlowStepFactoryConstRef HLS_step::CGetDesignFlowStepFactory() const
408 {
409  return design_flow_manager.lock()->CGetDesignFlowStepFactory("HLS");
410 }
static const std::string ComputeSignature(const HLSFlowStep_Type hls_flow_step_type, const HLSFlowStepSpecializationConstRef hls_flow_step_specialization)
Compute the signature of a hls flow step.
Definition: hls_step.cpp:116
#define DEBUG_LEVEL_VERY_PEDANTIC
extremely verbose debugging print is performed.
const HLS_managerRef HLSMgr
information about all the HLS synthesis
Definition: hls_step.hpp:205
Data structure representing the entire HLS information.
#define INDENT_DBG_MEX(dbgLevel, curDbgLevel, mex)
We are producing a debug version of the program, so the message is printed;.
static std::string name_function(const tree_managerConstRef &tm, const unsigned int index)
Return the name of the function.
#define MEMCPY
constant string identifying the operation performed when two objects are memcopied.
Definition: op_graph.hpp:310
File containing functions and utilities to support the printing of debug messagges.
RelationshipType
The relationship type.
The base class for design step.
std::string GetName() const override
Return the name of this design step.
Definition: hls_step.cpp:123
Class specification of the manager of the technology library data structures.
const HLSFlowStep_Type hls_flow_step_type
The type of this step.
Definition: hls_step.hpp:208
static std::string ComputeSignature(const HLSFlowStep_Type hls_flow_step_type, const HLSFlowStepSpecializationConstRef hls_flow_step_specialization, const unsigned int function_id)
Compute the signature of a hls flow step.
redefinition of map to manage ordered/unordered structures
HLS_step(const ParameterConstRef _parameters, const HLS_managerRef HLSMgr, const DesignFlowManagerConstRef design_flow_manager, const HLSFlowStep_Type hls_flow_step_type, const HLSFlowStepSpecializationConstRef hls_flow_step_specialization=HLSFlowStepSpecializationConstRef())
Constructor.
Definition: hls_step.cpp:90
virtual const CustomUnorderedSet< std::tuple< HLSFlowStep_Type, HLSFlowStepSpecializationConstRef, HLSFlowStep_Relationship > > ComputeHLSRelationships(const DesignFlowStep::RelationshipType relationship_type) const
Return the set of analyses in relationship with this design step.
Definition: hls_step.cpp:101
#define THROW_UNREACHABLE(str_expr)
helper function used to specify that some points should never be reached
Definition: exceptions.hpp:292
Factory for hls flow step.
static std::string EnumToName(const HLSFlowStep_Type hls_flow_step_type)
Given a HLS flow step type, return the name of the type.
Definition: hls_step.cpp:134
absl::flat_hash_map< T, U, Hash, Eq, Alloc > CustomUnorderedMap
Definition: custom_map.hpp:148
HLSFlowStep_Type
Definition: hls_step.hpp:95
Classes to describe design flow graph.
redefinition of set to manage ordered/unordered structures
static const std::string ComputeSignature(const FrontendFlowStepType frontend_flow_step_type)
Compute the signature of a function frontend flow step.
boost::graph_traits< graph >::vertex_descriptor vertex
vertex definition.
Definition: graph.hpp:1303
const Wrefcount< const DesignFlowManager > design_flow_manager
The design flow manager.
static std::string NormalizeTypename(const std::string &id)
Return normalized name of types and variables.
Call graph hierarchy.
Wrapper of design_flow.
HLSFlowStepSpecialization()
header include
This file collects some utility functions.
DesignFlowStepFactoryConstRef CGetDesignFlowStepFactory() const final
Return the factory to create this type of steps.
Definition: hls_step.cpp:407
void ComputeRelationships(DesignFlowStepSet &design_flow_step_set, const DesignFlowStep::RelationshipType relationship_type) override
Compute the relationships of a step with other steps.
Definition: hls_step.cpp:302
std::string GetSignature() const override
Return a unified identifier of this design step.
Definition: hls_step.cpp:111
~HLS_step() override
Destructor.
refcount< T > lock() const
Definition: refcount.hpp:212
technology_managerRef get_technology_manager() const
Returns the technology manager.
This class contains the methods to create a frontend flow step.
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.
Wrapper to call graph.
int debug_level
The debug level.
virtual ~HLSFlowStepSpecialization()
Data structure definition for high-level synthesis flow.
static CustomUnorderedMap< std::string, HLSFlowStep_Type > command_line_name_to_enum
Map hls step name to enum.
Definition: hls_step.hpp:202
tree_nodeRef GetFunction(const std::string &function_name) const
Return the index of a function given its name.
This class contains the base representation for a generic frontend flow step which works on the whole...
Datastructure to represent memory information in high-level synthesis.
virtual std::string GetKindText() const
Return the name of the type of this frontend flow step.
Definition: hls_step.cpp:128
Class specification of the manager of the tree structures extracted from the raw file.
const HLSFlowStepSpecializationConstRef hls_flow_step_specialization
The information about specialization.
Definition: hls_step.hpp:211
HLS specialization of generic_device.
A brief description of the C++ Header File.

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