68 const DesignFlowManagerConstRef _design_flow_manager)
79 auto objective_string =
parameters->getOption<std::string>(OPT_evaluation_objectives);
80 const auto objective_vector = string_to_container<std::vector<std::string>>(objective_string,
",");
82 switch(relationship_type)
96 for(
const auto& objective : objective_vector)
101 #if HAVE_LIBRARY_CHARACTERIZATION_BUILT 102 else if(objective ==
"AREA")
104 ret.insert(std::make_tuple(HLSFlowStep_Type::SYNTHESIS_EVALUATION,
109 #if HAVE_LIBRARY_CHARACTERIZATION_BUILT && HAVE_SIMULATION_WRAPPER_BUILT 110 else if(objective ==
"AREAxTIME")
112 ret.insert(std::make_tuple(HLSFlowStep_Type::SYNTHESIS_EVALUATION,
115 ret.insert(std::make_tuple(HLSFlowStep_Type::SIMULATION_EVALUATION,
120 #if HAVE_LIBRARY_CHARACTERIZATION_BUILT 121 else if(objective ==
"BRAMS")
123 ret.insert(std::make_tuple(HLSFlowStep_Type::SYNTHESIS_EVALUATION,
127 else if(objective ==
"DRAMS")
129 ret.insert(std::make_tuple(HLSFlowStep_Type::SYNTHESIS_EVALUATION,
133 else if(objective ==
"CLOCK_SLACK")
135 ret.insert(std::make_tuple(HLSFlowStep_Type::SYNTHESIS_EVALUATION,
140 #if HAVE_SIMULATION_WRAPPER_BUILT 141 else if(objective ==
"CYCLES" || objective ==
"TOTAL_CYCLES")
143 ret.insert(std::make_tuple(HLSFlowStep_Type::SIMULATION_EVALUATION,
148 #if HAVE_LIBRARY_CHARACTERIZATION_BUILT 149 else if(objective ==
"DSPS")
151 ret.insert(std::make_tuple(HLSFlowStep_Type::SYNTHESIS_EVALUATION,
156 #if HAVE_LIBRARY_CHARACTERIZATION_BUILT 157 else if(objective ==
"FREQUENCY")
159 ret.insert(std::make_tuple(HLSFlowStep_Type::SYNTHESIS_EVALUATION,
163 else if(objective ==
"PERIOD")
165 ret.insert(std::make_tuple(HLSFlowStep_Type::SYNTHESIS_EVALUATION,
169 else if(objective ==
"REGISTERS")
171 ret.insert(std::make_tuple(HLSFlowStep_Type::SYNTHESIS_EVALUATION,
176 #if HAVE_LIBRARY_CHARACTERIZATION_BUILT && HAVE_SIMULATION_WRAPPER_BUILT 177 else if(objective ==
"TIME" || objective ==
"TOTAL_TIME")
179 ret.insert(std::make_tuple(HLSFlowStep_Type::SIMULATION_EVALUATION,
182 ret.insert(std::make_tuple(HLSFlowStep_Type::SYNTHESIS_EVALUATION,
189 THROW_ERROR(
"Evaluation objective not yet supported " + objective);
227 bool printed_area =
false;
228 bool printed_frequency =
false;
229 auto objective_string =
parameters->getOption<std::string>(OPT_evaluation_objectives);
230 const auto objective_vector = string_to_container<std::vector<std::string>>(objective_string,
",");
231 const auto& evaluations =
HLSMgr->evaluations;
232 for(
const auto& objective : objective_vector)
235 if(objective ==
"AREAxTIME" or objective ==
"TIME" or objective ==
"TOTAL_TIME")
240 const auto local_evaluations =
HLSMgr->evaluations.at(objective);
241 return local_evaluations;
243 if(objective ==
"CYCLES")
245 THROW_ASSERT(evaluations.find(
"TOTAL_CYCLES") != evaluations.end(),
"");
246 auto tot_cycles =
static_cast<unsigned long long int>(evaluations.at(
"TOTAL_CYCLES"));
247 THROW_ASSERT(evaluations.find(
"NUM_EXECUTIONS") != evaluations.end(),
"");
248 auto num_executions =
static_cast<unsigned long long int>(evaluations.at(
"NUM_EXECUTIONS"));
249 auto avg_cycles =
static_cast<unsigned long long int>(
evaluation);
251 "---Total cycles : " +
STR(tot_cycles) +
" cycles");
254 "---Average execution : " +
STR(avg_cycles) +
" cycles");
256 else if((objective ==
"AREA" or objective ==
"AREAxTIME") and !printed_area)
261 if(evaluations.find(
"SLICE") != evaluations.end())
264 "---Slices : " +
STR(evaluations.at(
"SLICE")));
266 if(evaluations.find(
"SLICE_LUTS") != evaluations.end())
269 "---Luts : " +
STR(evaluations.at(
"SLICE_LUTS")));
271 else if(evaluations.find(
"LUT_FF_PAIRS") != evaluations.end())
274 "---Luts : " +
STR(evaluations.at(
"LUT_FF_PAIRS")));
276 if(evaluations.find(
"LOGIC_ELEMENTS") != evaluations.end())
279 "---Logic Elements : " +
STR(evaluations.at(
"LOGIC_ELEMENTS")));
281 if(evaluations.find(
"FUNCTIONAL_ELEMENTS") != evaluations.end())
284 "---Functional Elements : " +
STR(evaluations.at(
"FUNCTIONAL_ELEMENTS")));
286 if(evaluations.find(
"LOGIC_AREA") != evaluations.end())
289 "---Logic Area : " +
STR(evaluations.at(
"LOGIC_AREA")));
291 if(evaluations.find(
"POWER") != evaluations.end())
294 "---Power : " +
STR(evaluations.at(
"POWER")));
296 if(evaluations.find(
"ALMS") != evaluations.end())
299 "---ALMs : " +
STR(evaluations.at(
"ALMS")));
301 if(evaluations.find(
"URAMS") != evaluations.end())
304 "---URAMs : " +
STR(evaluations.at(
"URAMS")));
307 else if(objective ==
"BRAMS")
312 else if(objective ==
"DRAMS")
317 else if(objective ==
"CLOCK_SLACK")
321 if(
parameters->getOption<
bool>(OPT_timing_violation_abort) and slack < 0.0)
327 else if(objective ==
"PERIOD")
331 auto clock_period =
parameters->getOption<
double>(OPT_clock_period);
335 else if(objective ==
"DSPS")
341 else if((objective ==
"FREQUENCY" or objective ==
"TIME" or objective ==
"TOTAL_TIME" or
342 objective ==
"AREAxTIME") and
343 not printed_frequency)
345 printed_frequency =
true;
347 THROW_ASSERT(evaluations.find(
"PERIOD") != evaluations.end(),
"");
348 double minimum_period = evaluations.at(
"PERIOD");
349 double maximum_frequency = 1000.0 / minimum_period;
352 else if(objective ==
"REGISTERS")
363 unsigned int progressive = 0
U;
364 const auto out_file_name = [&]() {
365 std::string candidate_out_file_name;
368 candidate_out_file_name =
GetPath(
"bambu_results_" +
STR(progressive++) +
".xml");
369 }
while(std::filesystem::exists(candidate_out_file_name));
370 return candidate_out_file_name;
376 std::string bench_name;
379 bench_name +=
parameters->getOption<std::string>(OPT_benchmark_name) +
":";
381 if(
parameters->isOption(OPT_configuration_name))
383 bench_name +=
parameters->getOption<std::string>(OPT_configuration_name);
385 if(bench_name ==
"" || !
parameters->IsParameter(
"simple-benchmark-name") ||
386 parameters->GetParameter<
int>(
"simple-benchmark-name") == 0)
389 if(
parameters->getOption<
bool>(OPT_generate_taste_architecture))
393 bench_name +=
"taste_architecture";
397 bench_name +=
":taste_architecture";
400 bench_name +=
"_" +
STR(progressive - 1);
410 bench_name =
"dry_run";
415 if(
parameters->isOption(OPT_top_functions_names))
419 bench_name +=
parameters->getOption<std::string>(OPT_top_functions_names);
423 bench_name +=
":" +
parameters->getOption<std::string>(OPT_top_functions_names);
426 bench_name +=
"_" +
STR(progressive - 1);
430 const auto top_symbols =
parameters->getOption<std::vector<std::string>>(OPT_top_functions_names);
431 THROW_ASSERT(top_symbols.size() == 1,
"Expected single top function name");
432 const auto top_fnode =
HLSMgr->get_tree_manager()->GetFunction(top_symbols.front());
443 bench_name +=
"_" +
STR(progressive - 1);
448 const auto bambu_args =
parameters->getOption<std::string>(OPT_cat_args);
449 const auto bambu_version =
parameters->PrintVersion();
454 WRITE_XNVM2(
"benchmark_name", bench_name, nodeRoot);
457 for(
auto const& objective : objective_vector)
460 if(objective ==
"AREAxTIME")
465 value =
STR(
HLSMgr->evaluations.find(
"AREA")->second *
HLSMgr->evaluations.find(
"CYCLES")->second /
466 HLSMgr->evaluations.find(
"FREQUENCY")->second);
469 else if(objective ==
"TIME")
473 value =
STR(
HLSMgr->evaluations.find(
"CYCLES")->second /
HLSMgr->evaluations.find(
"FREQUENCY")->second);
476 else if(objective ==
"TOTAL_TIME")
480 value =
STR(
HLSMgr->evaluations.find(
"TOTAL_CYCLES")->second /
HLSMgr->evaluations.find(
"FREQUENCY")->second);
486 "Value of " + objective +
" not found");
487 double& local_evaluations =
HLSMgr->evaluations.find(objective)->second;
488 value +=
STR(local_evaluations);
493 if(objective ==
"AREA" &&
HLSMgr->evaluations.find(
"SLICE") !=
HLSMgr->evaluations.end())
496 value =
STR(
HLSMgr->evaluations.find(
"SLICE")->second);
499 if(objective ==
"AREA" &&
HLSMgr->evaluations.find(
"SLICE_LUTS") !=
HLSMgr->evaluations.end())
502 value =
STR(
HLSMgr->evaluations.find(
"SLICE_LUTS")->second);
505 if(objective ==
"AREA" &&
HLSMgr->evaluations.find(
"URAMS") !=
HLSMgr->evaluations.end())
508 value =
STR(
HLSMgr->evaluations.find(
"URAMS")->second);
513 long double exec_time =
HLSMgr->HLS_execution_time;
Class to compute evaluations about high-level synthesis.
const HLS_managerRef HLSMgr
information about all the HLS synthesis
Data structure representing the entire HLS information.
Collect information about resource area.
File containing functions and utilities to support the printing of debug messagges.
#define GET_CLASS(obj)
Macro returning the actual type of an object.
std::string get_function_name() const
Return the name of the function.
const int output_level
The output level.
RelationshipType
The relationship type.
Source must be executed to satisfy target.
#define INDENT_OUT_MEX(outLevel, curOutLevel, mex)
~Evaluation() override
Destructor.
#define STR_XML_bambu_results_bambu_version
The attribute containing bambu version.
constant strings used in bambu results
#define OUTPUT_LEVEL_MINIMUM
minimum debugging print is performed.
#define STR(s)
Macro which performs a lexical_cast to a string.
Auxiliary methods for manipulating string.
static std::string GetCurrentTimeStamp()
Return a timestamp of the current time.
#define THROW_UNREACHABLE(str_expr)
helper function used to specify that some points should never be reached
Factory for hls flow step.
Class definition for high level synthesis result evaluationThis class is the abstract class for all k...
Target must be reexecuted.
void write_to_file_formatted(const std::filesystem::path &filename)
Write the document to a file.
xml_element * create_root_node(const std::string &_name)
Creates the root node.
utility function used to read files.
const BehavioralHelperConstRef CGetBehavioralHelper() const
Returns the helper associated with the function.
const ParameterConstRef parameters
Set of input parameters.
DesignFlowStep_Status
The status of a step.
This file collects some utility functions and macros.
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.
#define THROW_ERROR(str_expr)
helper function used to throw an error in a standard way
Data structure definition for HLS constraints.
#define WRITE_XNVM2(name, value, node)
WRITE XML Name Value Macro second version. Insert a value in an XML tree given the name of the attrib...
This file contains the definition of the configurable flow for generating and executing synthesis scr...
std::string GetPath(std::filesystem::path path)
Class specification of the tree_reindex support class.
#define STR_XML_bambu_results_bambu_args
The attribute containing bambu results.
Template borrowed from the ANTLR library by Terence Parr (http://www.jGuru.com - Software rights: htt...
this class is used to manage the command-line or XML options.
#define STR_XML_bambu_results_timestamp
The attribute containing the timestamp of the synthesis.
bool HasToBeExecuted() const override
Check if this step has actually to be executed.
Some macro used to interface with the XML library.
Evaluation(const ParameterConstRef _parameters, const HLS_managerRef HLSMgr, const DesignFlowManagerConstRef design_flow_manager)
Constructor.
int debug_level
The debug level.
refcount< const HLSFlowStepSpecialization > HLSFlowStepSpecializationConstRef
const refcount definition of the class
#define GET_INDEX_CONST_NODE(t)
Data structure definition for high-level synthesis flow.
xml_element * add_child_element(const std::string &name)
Add a child element to this node.
Class specification of the manager of the tree structures extracted from the raw file.
DesignFlowStep_Status Exec() override
Execute the step.
#define THROW_ASSERT(cond, str_expr)
helper function used to check an assert and if needed to throw an error in a standard way ...