PandA-2024.02
synthesis_evaluation.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 "synthesis_evaluation.hpp"
44 
45 #include "BackendFlow.hpp"
46 #include "Parameter.hpp"
47 #include "area_info.hpp"
48 #include "call_graph_manager.hpp"
49 #include "hls.hpp"
50 #include "hls_constraints.hpp"
51 #include "hls_manager.hpp"
52 #include "time_info.hpp"
53 #include "tree_manager.hpp"
54 #include "tree_reindex.hpp"
55 #include "utility.hpp"
56 
58  const DesignFlowManagerConstRef _design_flow_manager)
59  : EvaluationBaseStep(_Param, _hls_mgr, _design_flow_manager, HLSFlowStep_Type::SYNTHESIS_EVALUATION)
60 {
61 }
62 
64 
67 {
69  switch(relationship_type)
70  {
72  {
75 #if HAVE_TASTE
76  if(parameters->getOption<bool>(OPT_generate_taste_architecture))
77  {
78  ret.insert(std::make_tuple(HLSFlowStep_Type::GENERATE_TASTE_SYNTHESIS_SCRIPT,
81  }
82  else
83 #endif
84  {
87  }
88  break;
89  }
91  {
92 #if HAVE_SIMULATION_WRAPPER_BUILT
93  ret.insert(std::make_tuple(HLSFlowStep_Type::SIMULATION_EVALUATION, HLSFlowStepSpecializationConstRef(),
95 #endif
96 #if HAVE_VCD_BUILT
97  if(parameters->isOption(OPT_discrepancy) && parameters->getOption<bool>(OPT_discrepancy))
98  {
99  ret.insert(std::make_tuple(HLSFlowStep_Type::VCD_UTILITY, HLSFlowStepSpecializationConstRef(),
101  }
102 #endif
103  break;
104  }
106  {
107  break;
108  }
109  default:
110  THROW_UNREACHABLE("");
111  }
112  return ret;
113 }
114 
116 {
117  HLSMgr->get_backend_flow()->ExecuteSynthesis();
118  auto objective_string = parameters->getOption<std::string>(OPT_evaluation_objectives);
119  const auto objective_vector = string_to_container<std::vector<std::string>>(objective_string, ",");
120  bool printed_area = false;
121  for(const auto& objective : objective_vector)
122  {
123  if((objective == "AREA" or objective == "AREAxTIME") and !printed_area)
124  {
125  printed_area = true;
127  area_infoRef area_m = HLSMgr->get_backend_flow()->get_used_resources();
128 
129  if(area_m)
130  {
131  double slices = area_m ? area_m->get_resource_value(area_info::SLICE) : 0;
132  if(slices != 0.0)
133  {
134  HLSMgr->evaluations["SLICE"] = slices;
135  }
136  double sliceLuts = area_m ? area_m->get_resource_value(area_info::SLICE_LUTS) : 0;
137  if(sliceLuts != 0.0)
138  {
139  HLSMgr->evaluations["SLICE_LUTS"] = sliceLuts;
140  }
141  double lut_ff_pairs = area_m ? area_m->get_resource_value(area_info::LUT_FF_PAIRS) : 0;
142  if(lut_ff_pairs != 0.0)
143  {
144  HLSMgr->evaluations["LUT_FF_PAIRS"] = lut_ff_pairs;
145  }
146  double logic_elements = area_m ? area_m->get_resource_value(area_info::LOGIC_ELEMENTS) : 0;
147  if(logic_elements != 0.0)
148  {
149  HLSMgr->evaluations["LOGIC_ELEMENTS"] = logic_elements;
150  }
151  double functional_elements = area_m ? area_m->get_resource_value(area_info::FUNCTIONAL_ELEMENTS) : 0;
152  if(functional_elements != 0.0)
153  {
154  HLSMgr->evaluations["FUNCTIONAL_ELEMENTS"] = functional_elements;
155  }
156  double logic_area = area_m ? area_m->get_resource_value(area_info::LOGIC_AREA) : 0;
157  if(logic_area != 0.0)
158  {
159  HLSMgr->evaluations["LOGIC_AREA"] = logic_area;
160  }
161  double power = area_m ? area_m->get_resource_value(area_info::POWER) : 0;
162  if(power != 0.0)
163  {
164  HLSMgr->evaluations["POWER"] = power;
165  }
166  double alms = area_m ? area_m->get_resource_value(area_info::ALMS) : 0;
167  if(alms != 0.0)
168  {
169  HLSMgr->evaluations["ALMS"] = alms;
170  }
171  double urams = area_m ? area_m->get_resource_value(area_info::URAM) : 0;
172  if(urams != 0.0)
173  {
174  HLSMgr->evaluations["URAMS"] = urams;
175  }
176  }
177  HLSMgr->evaluations["AREA"] = area_m->get_area_value();
178  }
179  else if(objective == "BRAMS")
180  {
181  area_infoRef area_m = HLSMgr->get_backend_flow()->get_used_resources();
182  double brams = 0;
183  if(area_m)
184  {
185  brams = area_m->get_resource_value(area_info::BRAM);
186  }
187  HLSMgr->evaluations["BRAMS"] = brams;
188  }
189  else if(objective == "DRAMS")
190  {
191  area_infoRef area_m = HLSMgr->get_backend_flow()->get_used_resources();
192  double drams = 0;
193  if(area_m)
194  {
195  drams = area_m->get_resource_value(area_info::DRAM);
196  }
197  HLSMgr->evaluations["DRAMS"] = drams;
198  }
199  else if(objective == "CLOCK_SLACK")
200  {
202  const auto time_m = HLSMgr->get_backend_flow()->get_timing_results();
203  const auto minimum_period = time_m->get_execution_time();
204  const auto clock_period = parameters->getOption<double>(OPT_clock_period);
205  const auto slack = clock_period - minimum_period;
206  if(parameters->getOption<bool>(OPT_timing_violation_abort) && slack < 0.0)
207  {
208  THROW_UNREACHABLE("Slack is " + STR(slack));
209  }
210  HLSMgr->evaluations["CLOCK_SLACK"] = slack;
211  }
212  else if(objective == "PERIOD")
213  {
215  time_infoRef time_m = HLSMgr->get_backend_flow()->get_timing_results();
216  double minimum_period = time_m->get_execution_time();
217  HLSMgr->evaluations["PERIOD"] = minimum_period;
218  }
219  else if(objective == "DSPS")
220  {
222  area_infoRef area_m = HLSMgr->get_backend_flow()->get_used_resources();
223  double dsps = 0;
224  if(area_m)
225  {
226  dsps = area_m->get_resource_value(area_info::DSP);
227  }
228  HLSMgr->evaluations["DSPS"] = dsps;
229  }
230  else if(objective == "FREQUENCY" or objective == "TIME" or objective == "TOTAL_TIME" or objective == "AREAxTIME")
231  {
233  time_infoRef time_m = HLSMgr->get_backend_flow()->get_timing_results();
234  double minimum_period = time_m->get_execution_time();
235 
236  double maximum_frequency = 1000.0 / minimum_period;
237  HLSMgr->evaluations["FREQUENCY"] = maximum_frequency;
238  }
239  else if(objective == "REGISTERS")
240  {
242  area_infoRef area_m = HLSMgr->get_backend_flow()->get_used_resources();
243  double reg = 0;
244  reg = area_m->get_resource_value(area_info::REGISTERS);
245  HLSMgr->evaluations["REGISTERS"] = reg;
246  }
247  }
249 }
const HLS_managerRef HLSMgr
information about all the HLS synthesis
Definition: hls_step.hpp:205
Data structure representing the entire HLS information.
const CustomUnorderedSet< std::tuple< HLSFlowStep_Type, HLSFlowStepSpecializationConstRef, HLSFlowStep_Relationship > > ComputeHLSRelationships(const DesignFlowStep::RelationshipType relationship_type) const override
Return the set of analyses in relationship with this design step.
Collect information about resource area.
RelationshipType
The relationship type.
Source must be executed to satisfy target.
Collect information about resource performance.
DesignFlowStep_Status Exec() override
Execute the step.
#define STR(s)
Macro which performs a lexical_cast to a string.
#define THROW_UNREACHABLE(str_expr)
helper function used to specify that some points should never be reached
Definition: exceptions.hpp:292
double get_resource_value(value_t val) const
Definition: area_info.cpp:77
HLSFlowStep_Type
Definition: hls_step.hpp:95
double get_area_value() const
Return the nominal value for the area of the component.
Definition: area_info.cpp:57
~SynthesisEvaluation() override
Destructor of the class.
double get_execution_time() const
Definition: time_info.cpp:80
const ParameterConstRef parameters
Set of input parameters.
DesignFlowStep_Status
The status of a step.
This file collects some utility functions and macros.
Data structure definition for HLS constraints.
This file contains the definition of the configurable flow for generating and executing synthesis scr...
Class specification of the tree_reindex support class.
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.
refcount< const HLSFlowStepSpecialization > HLSFlowStepSpecializationConstRef
const refcount definition of the class
Definition: hls_step.hpp:93
Data structure definition for high-level synthesis flow.
Superclass include.
Class specification of the manager of the tree structures extracted from the raw file.
SynthesisEvaluation(const ParameterConstRef Param, const HLS_managerRef hls_mgr, const DesignFlowManagerConstRef design_flow_manager)
Constructor of the class.

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