49 #include "config_HAVE_FROM_AADL_ASN_BUILT.hpp" 50 #include "config_HAVE_FROM_PRAGMA_BUILT.hpp" 67 #if HAVE_FROM_AADL_ASN_BUILT 72 const DesignFlowManagerConstRef _design_flow_manager)
86 switch(relationship_type)
94 #if HAVE_FROM_AADL_ASN_BUILT 97 for(
const auto& input_file :
AppM->input_files)
99 const auto file_format =
parameters->GetFileFormat(input_file);
100 if(file_format == Parameters_FileFormat::FF_AADL)
107 design_flow_graph->CGetDesignFlowStepInfo(parser_step)->design_flow_step :
109 relationship.insert(design_flow_step);
111 else if(file_format == Parameters_FileFormat::FF_ASN)
118 design_flow_graph->CGetDesignFlowStepInfo(parser_step)->design_flow_step :
120 relationship.insert(design_flow_step);
126 const auto* technology_flow_step_factory = GetPointer<const TechnologyFlowStepFactory>(
128 const std::string technology_flow_signature =
132 technology_flow_step ?
133 design_flow_graph->CGetDesignFlowStepInfo(technology_flow_step)->design_flow_step :
135 relationship.insert(technology_design_flow_step);
152 switch(relationship_type)
160 #if HAVE_FROM_PRAGMA_BUILT 174 return relationships;
184 if(GetPointer<HLS_manager>(
AppM) &&
185 (!
parameters->IsParameter(
"disable-THR") ||
parameters->GetParameter<
unsigned int>(
"disable-THR") == 0))
187 std::map<std::pair<std::string, std::string>, std::string> default_InstructionLatencyTable;
189 for(
const auto&
el : latencies)
192 THROW_ASSERT(key_value.size() == 2,
"unexpected condition");
194 THROW_ASSERT(op_bit.size() == 2,
"unexpected condition");
195 default_InstructionLatencyTable[std::make_pair(op_bit.at(0), op_bit.at(1))] = key_value.at(1);
200 double clock_period =
204 CostTable +=
",load_expr|32=" +
STR(clock_period);
205 CostTable +=
",nop_expr|32=" +
STR(clock_period);
206 for(
const std::string op_name : {
"mult_expr",
"plus_expr",
"trunc_div_expr",
"trunc_mod_expr",
"lshift_expr",
207 "rshift_expr",
"bit_and_expr",
"bit_ior_expr",
"bit_xor_expr",
"cond_expr"})
209 for(
auto fu_prec : {1, 8, 16, 32, 64})
211 auto component_name_op =
212 "ui_" + op_name + std::string(
"_FU_") +
STR(fu_prec) +
"_" +
STR(fu_prec) +
"_" +
STR(fu_prec) +
213 ((op_name ==
"mult_expr" || op_name ==
"trunc_div_expr" || op_name ==
"trunc_mod_expr") ?
"_0" :
"") +
214 (op_name ==
"cond_expr" ? (
"_" +
STR(fu_prec)) :
"");
218 auto* op_fu = GetPointer<functional_unit>(op_f_unit);
220 THROW_ASSERT(op_node,
"missing " + op_name +
" from " + component_name_op);
221 auto* op = GetPointer<operation>(op_node);
222 double op_delay = op->time_m->get_execution_time();
223 CostTable +=
"," + op_name +
"|" +
STR(fu_prec) +
"=" +
STR(op_delay);
227 THROW_ASSERT(default_InstructionLatencyTable.find(std::make_pair(op_name,
STR(fu_prec))) !=
228 default_InstructionLatencyTable.end(),
230 CostTable +=
"," + op_name +
"|" +
STR(fu_prec) +
"=" +
231 default_InstructionLatencyTable.at(std::make_pair(op_name,
STR(fu_prec)));
235 for(
const std::string op_name : {
"mult_expr",
"plus_expr",
"rdiv_expr"})
237 for(
auto fu_prec : {32, 64})
239 auto component_name_op =
"fp_" + op_name + std::string(
"_FU_") +
STR(fu_prec) +
"_" +
STR(fu_prec) +
"_" +
240 STR(fu_prec) + ((op_name ==
"mult_expr") ?
"_200" :
"_100");
244 auto* op_fu = GetPointer<functional_unit>(op_f_unit);
246 THROW_ASSERT(op_node,
"missing " + op_name +
" from " + component_name_op);
247 auto* op = GetPointer<operation>(op_node);
248 auto op_cycles = op->time_m->get_cycles();
249 double op_delay = op_cycles ? clock_period * op_cycles : op->time_m->get_execution_time();
250 CostTable +=
",F" + op_name +
"|" +
STR(fu_prec) +
"=" +
STR(op_delay);
254 THROW_ASSERT(default_InstructionLatencyTable.find(std::make_pair(
"F" + op_name,
STR(fu_prec))) !=
255 default_InstructionLatencyTable.end(),
257 CostTable +=
"," + op_name +
"|" +
STR(fu_prec) +
"=" +
258 default_InstructionLatencyTable.at(std::make_pair(
"F" + op_name,
STR(fu_prec)));
267 const auto TM =
AppM->get_tree_manager();
271 THROW_ERROR(
"At least one source file has to be passed to the tool");
278 const auto output_temporary_directory =
parameters->getOption<std::string>(OPT_output_temporary_directory);
279 const auto temp_path = output_temporary_directory +
"archives";
280 std::filesystem::create_directories(temp_path);
281 std::string
command =
"cd " + temp_path +
"\n";
282 for(
const auto& archive_file : archive_files)
285 if(!std::filesystem::exists(std::filesystem::path(archive_file)))
287 THROW_ERROR(
"File " + archive_file +
" does not exist");
289 const auto local_archive_file =
GetPath(archive_file);
291 command +=
" ar x " + local_archive_file +
" &\n";
296 THROW_ERROR(
"ar returns an error during archive extraction ");
298 for(
const auto& archive : std::filesystem::directory_iterator{temp_path})
300 const auto fileExtension = archive.path().extension().string();
301 if(fileExtension !=
".o" && fileExtension !=
".O")
307 TM->merge_tree_managers(TM_new);
309 if(!
parameters->getOption<
bool>(OPT_no_clean))
311 std::filesystem::remove_all(temp_path);
325 "*********************************************************************************");
327 "* Building internal representation from raw files *");
329 "*********************************************************************************");
335 " =============== Building internal representation from raw files ===============");
339 for(
const auto& raw_file : raw_files)
342 if(!std::filesystem::exists(std::filesystem::path(raw_file)))
344 THROW_ERROR(
"File " + raw_file +
" does not exist");
348 TM->merge_tree_managers(TM_tmp);
373 std::string raw_file_name =
374 parameters->getOption<std::string>(OPT_output_temporary_directory) +
"after_raw_merge.raw";
375 std::ofstream raw_file(raw_file_name.c_str());
382 const auto HLSMgr = GetPointer<HLS_manager>(
AppM);
384 const auto arch_filename =
386 parameters->getOption<std::string>(OPT_architecture_xml) :
387 (
parameters->getOption<std::string>(OPT_output_temporary_directory) +
"/architecture.xml");
390 for(
auto& [symbol, arch] : *HLSMgr->module_arch)
392 const auto fnode = TM->GetFunction(symbol);
395 THROW_WARNING(
"Function specified in architecture XML is missing in the IR: " + symbol);
398 const auto fd = GetPointer<function_decl>(
GET_NODE(fnode));
399 for(
auto& [
attr, val] : arch->attrs)
401 if(
attr == FunctionArchitecture::func_pipeline_style)
405 fd->set_pipelining(
false);
409 fd->set_pipelining(
true);
412 fd->set_simple_pipeline(
true);
416 else if(
attr == FunctionArchitecture::func_pipeline_ii)
418 const auto pipeline_ii = std::stoi(val);
419 fd->set_initiation_time(pipeline_ii);
#define GET_NODE(t)
Macro used to hide implementation details when accessing a tree_node from another tree_node...
#define DEBUG_LEVEL_VERY_PEDANTIC
extremely verbose debugging print is performed.
static const std::string ComputeSignature(const ParserFlowStep_Type parser_step_type, const std::string &file_name)
Compute the signature of a parser flow step.
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;.
This class contains the base representation for a generic parser step.
#define DEBUG_LEVEL_PEDANTIC
very verbose debugging print is performed.
technology_nodeRef get_fu(const std::string &fu_name, const std::string &Library) const
Return the reference to a component given its name.
Class that creates the tree_manager starting from the source code files.
#define GET_CLASS(obj)
Macro returning the actual type of an object.
Definition of the class representing a generic C application.
const int output_level
The output level.
const std::vector< std::string > SplitString(const std::string &input, const std::string &separators)
Function which splits a string into tokens.
RelationshipType
The relationship type.
Source must be executed to satisfy target.
#define INDENT_OUT_MEX(outLevel, curOutLevel, mex)
Collect information about resource performance.
DesignFlowStep_Status Exec() override
Creates the tree_manager data structure by invoking the GCC/CLANG wrapper.
Specification of the tree (GCC raw) parsing interface function.
#define LIBRARY_STD_FU
standard library where all standard HLS resources are defined
Class specification of the manager of the technology library data structures.
std::string CostTable
CostTable: string storing the operations' latency in an encoded map.
#define OUTPUT_LEVEL_MINIMUM
minimum debugging print is performed.
CompilerWrapper_OptimizationSet
Possible optimization sets.
#define THROW_WARNING(str_expr)
helper function used to throw a warning in a standard way: though it uses PRINT_DBG_MEX, the debug level used is such that the message is always printed
#define STR(s)
Macro which performs a lexical_cast to a string.
Auxiliary methods for manipulating string.
bool IsError(const int error_value)
Utility include.
#define THROW_UNREACHABLE(str_expr)
helper function used to specify that some points should never be reached
void ComputeRelationships(DesignFlowStepSet &relationship, const DesignFlowStep::RelationshipType relationship_type) override
Compute the relationships of a step with other steps.
~create_tree_manager() override
Destructor.
Class specification of the data structures used to manage technology information. ...
create_tree_manager(const ParameterConstRef _parameters, const application_managerRef AppM, const DesignFlowManagerConstRef design_flow_manager)
Constructor.
default table used by THR LLVM optimization step.
void createCostTable()
createCostTable: Fill the CostTable starting from the technology files
Classes to describe design flow graph.
Target must be reexecuted.
static const std::string ComputeSignature(const TechnologyFlowStep_Type technology_flow_step_type)
Compute the signature of a technology flow step.
Factory for technology flow step.
boost::graph_traits< graph >::vertex_descriptor vertex
vertex definition.
utility function used to read files.
CompilerWrapper_CompilerTarget
target of the compiler
const Wrefcount< const DesignFlowManager > design_flow_manager
The design flow manager.
const ParameterConstRef parameters
Set of input parameters.
DesignFlowStep_Status
The status of a step.
const CustomUnorderedSet< std::pair< FrontendFlowStepType, FunctionRelationship > > ComputeFrontendRelationships(const DesignFlowStep::RelationshipType relationship_type) const override
Return the set of analyses in relationship with this design step.
struct definition of the field attr on function_decl, field_decl, var_decl tree node.
#define DEBUG_LEVEL_NONE
no debugging print is performed.
#define THROW_ERROR(str_expr)
helper function used to throw an error in a standard way
#define STR_cost_latency_table_default
default string for latencies
int PandaSystem(const ParameterConstRef Param, const std::string &system_command, bool host_exec, const std::string &output, const unsigned int type, const bool background, const size_t timeout)
System call forcing execution with bash.
refcount< T > lock() const
void ComputeRelationships(DesignFlowStepSet &relationship, const DesignFlowStep::RelationshipType relationship_type) override
Compute the relationships of a step with other steps.
bool HasToBeExecuted() const override
Check if this step has actually to be executed.
std::string GetPath(std::filesystem::path path)
const application_managerRef AppM
The application manager.
Class specification of the tree_reindex support class.
technology_managerRef get_technology_manager() const
Returns the technology manager.
const CompilerWrapperRef compiler_wrapper
The gcc wrapper.
Template borrowed from the ANTLR library by Terence Parr (http://www.jGuru.com - Software rights: htt...
const std::string getCostTable() const
return the latency table used by THR to balance the computation
Parameters_FileFormat
File formats.
this class is used to manage the command-line or XML options.
Main class for wrapping the frontend compiler.
int debug_level
The debug level.
#define OUTPUT_LEVEL_VERBOSE
verbose debugging print is performed.
#define NULL_VERTEX
null vertex definition
tree_managerRef ParseTreeFile(const ParameterConstRef &Param, const std::string &f)
Function that parse the dump of the patched GCC.
Class specification of the manager of the tree structures extracted from the raw file.
Base class for technology flow steps.
HLS specialization of generic_device.
#define THROW_ASSERT(cond, str_expr)
helper function used to check an assert and if needed to throw an error in a standard way ...
Implementation of the wrapper to Gcc for C sources.