53 #include <boost/range/adaptor/reversed.hpp> 70 const DesignFlowManagerConstRef _design_flow_manager)
80 auto omp_functions = GetPointer<OmpFunctions>(
HLSMgr->Rfuns);
81 const auto TM =
HLSMgr->get_tree_manager();
83 const auto call_graph_manager =
HLSMgr->CGetCallGraphManager();
84 auto root_functions = call_graph_manager->GetRootFunctions();
87 const auto top_rtldesign_function =
88 HLSMgr->get_tree_manager()->GetFunction(
parameters->getOption<std::string>(OPT_top_design_name));
89 if(top_rtldesign_function && root_functions.count(top_rtldesign_function->index))
91 root_functions.clear();
92 root_functions.insert(top_rtldesign_function->index);
96 for(
const auto f_id : root_functions)
98 for(
const auto reached_f_id : call_graph_manager->GetReachedFunctionsFrom(f_id))
100 vertex_subset.insert(call_graph_manager->GetVertex(reached_f_id));
103 const auto call_graph = call_graph_manager->CGetCallSubGraph(vertex_subset);
104 std::list<vertex> sorted_functions;
105 call_graph->TopologicalSort(sorted_functions);
107 for(
const auto function : sorted_functions)
109 const auto function_id = call_graph_manager->get_function(
function);
110 if(
HLSMgr->CGetFunctionBehavior(function_id)->CGetBehavioralHelper()->GetOmpForDegree())
113 "---Found omp for wrapper " +
114 HLSMgr->CGetFunctionBehavior(function_id)->CGetBehavioralHelper()->get_function_name());
115 omp_functions->omp_for_wrappers.insert(function_id);
119 for(boost::tie(ie, ie_end) = boost::in_edges(
function, *call_graph); ie != ie_end; ie++)
121 const auto source = boost::source(*ie, *call_graph);
122 const auto source_id = call_graph_manager->get_function(source);
123 if(omp_functions->omp_for_wrappers.find(source_id) != omp_functions->omp_for_wrappers.end() or
124 omp_functions->parallelized_functions.find(source_id) != omp_functions->parallelized_functions.end())
127 "---Found function to be parallelized: " +
128 HLSMgr->CGetFunctionBehavior(function_id)->CGetBehavioralHelper()->get_function_name());
129 omp_functions->parallelized_functions.insert(function_id);
134 const auto panda_pthread_mutex = call_graph_manager->GetVertex(TM->GetFunction(
"panda_pthread_mutex")->index);
136 for(boost::tie(ie, ie_end) = boost::in_edges(panda_pthread_mutex, *call_graph); ie != ie_end; ie++)
138 omp_functions->locking_functions.insert(call_graph_manager->get_function(boost::source(*ie, *call_graph)));
140 auto current_locks_allocation_candidates = omp_functions->locking_functions;
141 const auto reached_body_functions = call_graph_manager->GetReachedBodyFunctions();
142 for(
const auto function : boost::adaptors::reverse(sorted_functions))
144 const auto function_id = call_graph_manager->get_function(
function);
145 if(reached_body_functions.find(function_id) == reached_body_functions.end())
150 "-->Analyzing function " +
151 HLSMgr->CGetFunctionBehavior(function_id)->CGetBehavioralHelper()->get_function_name());
152 if(current_locks_allocation_candidates.find(function_id) != current_locks_allocation_candidates.end())
154 current_locks_allocation_candidates.erase(current_locks_allocation_candidates.find(function_id));
157 for(
const auto current_locks_allocation_candidate : current_locks_allocation_candidates)
160 "---" +
HLSMgr->CGetFunctionBehavior(current_locks_allocation_candidate)
161 ->CGetBehavioralHelper()
162 ->get_function_name());
165 if(current_locks_allocation_candidates.size() == 0)
168 if(omp_functions->parallelized_functions.find(function_id) != omp_functions->parallelized_functions.end())
170 for(boost::tie(ie, ie_end) = boost::in_edges(
function, *call_graph); ie != ie_end; ie++)
172 const auto source_id = call_graph_manager->get_function(boost::source(*ie, *call_graph));
173 if(reached_body_functions.find(source_id) == reached_body_functions.end())
175 current_locks_allocation_candidates.insert(source_id);
178 if(omp_functions->omp_for_wrappers.find(function_id) != omp_functions->omp_for_wrappers.end())
180 omp_functions->locks_parallel_comunication.insert(function_id);
184 omp_functions->locks_merge_communication.insert(function_id);
189 omp_functions->locks_allocation = function_id;
194 for(boost::tie(ie, ie_end) = boost::in_edges(
function, *call_graph); ie != ie_end; ie++)
196 const auto source_id = call_graph_manager->get_function(boost::source(*ie, *call_graph));
197 if(reached_body_functions.find(source_id) == reached_body_functions.end())
199 current_locks_allocation_candidates.insert(source_id);
202 if(omp_functions->omp_for_wrappers.find(function_id) != omp_functions->omp_for_wrappers.end())
204 omp_functions->locks_parallel_comunication.insert(function_id);
208 omp_functions->locks_merge_communication.insert(function_id);
#define DEBUG_LEVEL_VERY_PEDANTIC
extremely verbose debugging print is performed.
const HLS_managerRef HLSMgr
information about all the HLS synthesis
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;.
virtual void Initialize()
Initialize the step (i.e., like a constructor, but executed just before exec.
File containing functions and utilities to support the printing of debug messagges.
#define GET_CLASS(obj)
Macro returning the actual type of an object.
OmpFunctionAllocation(const ParameterConstRef _parameters, const HLS_managerRef HLSMgr, const DesignFlowManagerConstRef design_flow_manager)
Constructor.
boost::graph_traits< graph >::in_edge_iterator InEdgeIterator
in_edge_iterator definition.
refcount< functions > functionsRef
refcount definition of the class
DesignFlowStep_Status Exec() override
Execute the step.
#define STR(s)
Macro which performs a lexical_cast to a string.
~OmpFunctionAllocation() override
Destructor.
const ParameterConstRef parameters
Set of input parameters.
DesignFlowStep_Status
The status of a step.
This file collects some utility functions and macros.
DesignFlowStep_Status Exec() override
Execute the step.
Template borrowed from the ANTLR library by Terence Parr (http://www.jGuru.com - Software rights: htt...
Class to allocate function in HLS based on dominators and openmp information.
this class is used to manage the command-line or XML options.
void Initialize() override
Initialize the step (i.e., like a constructor, but executed just before exec.
int debug_level
The debug level.
Datastructure to describe functions allocation in high-level synthesis.
Class specification of the manager of the tree structures extracted from the raw file.
A brief description of the C++ Header File.