38 #ifndef MODULE_BINDING_CHECK_HPP 39 #define MODULE_BINDING_CHECK_HPP 46 #include <boost/property_map/property_map.hpp> 72 : tree_index_rank_pmap(tree_index_rank_map),
73 tree_index_parent_pmap(tree_index_parent_map),
74 binding(tree_index_rank_pmap, tree_index_parent_pmap)
79 template <
typename vertex_type>
127 std::vector<CustomOrderedSet<unsigned int>> variableVector;
129 std::vector<HLS_manager::io_binding_type> vars_read =
130 HLSMgr->get_required_values(HLS->
functionId, operationVertex);
131 for(
auto& port_index : vars_read)
133 unsigned int tree_var = std::get<0>(port_index);
137 variablesAtPort.insert(tree_var);
139 variableVector.push_back(variablesAtPort);
142 return variableVector;
153 if(starting_time.find(operationVertex)->second > controller_delay)
155 return slack_time.find(operationVertex)->second;
157 else if(controller_delay - starting_time.find(operationVertex)->second > slack_time.find(operationVertex)->second)
163 return (slack_time.find(operationVertex)->second -
164 (controller_delay - starting_time.find(operationVertex)->second));
179 area_resource(_area_resource),
180 tree_index_dsets(_tree_index_dsets),
183 slack_time(_slack_time),
184 starting_time(_starting_time),
185 controller_delay(_controller_delay),
186 is_disabled_slack_based_binding(
false)
191 : opSlacks(original.opSlacks),
192 input_variables(original.input_variables),
193 fu_prec(original.fu_prec),
194 area_resource(original.area_resource),
195 tree_index_dsets(original.tree_index_dsets),
197 HLSMgr(original.HLSMgr),
198 slack_time(original.slack_time),
199 starting_time(original.starting_time),
200 controller_delay(original.controller_delay),
201 is_disabled_slack_based_binding(original.is_disabled_slack_based_binding)
217 BOOST_FOREACH(
C_vertex tempVertex, boost::vertices(graph))
219 opSlacks[tempVertex] = getOpSlack(Ruv2v[tempVertex]);
220 input_variables[tempVertex] = getOperationVariablesAtPort(Ruv2v[tempVertex]);
225 for(
const auto& input_var : input_variables)
227 for(
const auto& vars : input_var.second)
229 for(
auto tree_var : vars)
231 tree_index_set.insert(tree_var);
232 tree_index_dsets.
binding.make_set(tree_var);
242 if(tree_var_resource_relation.find(std::make_pair(fu_name, fu_index)) !=
243 tree_var_resource_relation.end())
245 tree_index_dsets.
binding.union_set(
246 tree_var, tree_var_resource_relation.find(std::make_pair(fu_name, fu_index))->second);
250 tree_var_resource_relation[std::make_pair(fu_name, fu_index)] = tree_var;
260 double cost(
size_t clique_count)
override 262 double area_muxes = 0;
263 for(
const auto& input_var : input_variables)
265 for(
const auto& vars : input_var.second)
277 return area_muxes + area_resource *
static_cast<double>(clique_count);
283 for(
const auto& input_var : input_variables)
285 for(
const auto& vars : input_var.second)
289 n_muxes +=
static_cast<size_t>(vars.size()) - 1;
301 size_t port_number = input_variables[child].size();
303 std::vector<CustomOrderedSet<unsigned int>>& input_at_port = input_variables[rep];
304 std::vector<CustomOrderedSet<unsigned int>>& input_at_child = input_variables[child];
305 for(
size_t i = 0; i < port_number; i++)
308 BOOST_FOREACH(
unsigned int temp_var, input_at_child[i])
311 temp_var = tree_index_dsets.
binding.find_set(temp_var);
312 (input_at_port[i]).
insert(temp_var);
314 input_at_child[i].clear();
318 opSlacks[rep] =
std::min(opSlacks[rep], opSlacks[child]);
328 double minSlack =
std::min(opSlacks[rep], opSlacks[other]);
329 THROW_ASSERT(input_variables.find(rep) != input_variables.end(),
"unexpected case");
331 size_t port_number = input_variables[rep].size();
334 double total_area_muxes_rep = 0, total_area_muxes_other = 0, total_area_muxes = 0;
336 for(decltype(port_number) i = 0; i < port_number; i++)
338 for(
auto temp_var : input_variables[rep][i])
340 temp_var = tree_index_dsets.
binding.find_set(temp_var);
341 port_inputs.insert(temp_var);
342 port_inputs_rep.insert(temp_var);
344 for(
auto temp_var : input_variables[other][i])
346 temp_var = tree_index_dsets.
binding.find_set(temp_var);
347 port_inputs.insert(temp_var);
348 port_inputs_other.insert(temp_var);
350 auto n_mux_inputs =
static_cast<size_t>(port_inputs.size());
355 fu_prec, static_cast<unsigned int>(port_inputs_rep.size()));
357 fu_prec, static_cast<unsigned int>(port_inputs_other.size()));
359 if(!is_disabled_slack_based_binding && n_mux_inputs > 1 &&
367 fu_prec, static_cast<unsigned int>(n_mux_inputs)) > minSlack)
373 port_inputs_rep.clear();
374 port_inputs_other.clear();
379 if(!is_disabled_slack_based_binding &&
380 ((total_area_muxes + area_resource) >
381 (total_area_muxes_rep + area_resource + total_area_muxes_other + area_resource)))
391 size_t port_number = input_variables[other].size();
394 for(decltype(port_number) i = 0; i < port_number; i++)
396 for(
auto temp_var : input_variables[rep][i])
398 temp_var = tree_index_dsets.
binding.find_set(temp_var);
399 port_inputs.insert(temp_var);
401 for(
auto temp_var : input_variables[other][i])
403 temp_var = tree_index_dsets.
binding.find_set(temp_var);
404 port_inputs.insert(temp_var);
406 if(port_inputs.size() > 1)
418 template <
typename vertex_type>
425 :
module_binding_check<vertex_type>(_fu_prec, _area_resource, _HLS, _HLSMgr, _slack_time, _starting_time,
426 _controller_delay, _tree_index_dsets)
443 #endif // MODULE_BINDING_CHECK_HPP boost::associative_property_map< tree_index_parent_t > tree_index_parent_map_t
boost::associative_property_map< tree_index_rank_t > tree_index_rank_map_t
module_binding_check_no_filter(const module_binding_check_no_filter &original)
bool has_op_where_defined(unsigned int var) const
return true in case there exist an operation defining it
CustomUnorderedMap< unsigned int, std::size_t > tree_index_rank_t
unsigned int get_assign(const vertex &v) const
Returns the functional unit assigned to the vertex.
const CustomUnorderedMap< vertex, double > & slack_time
reference to the vertex slack
double controller_delay
controller delay
tree_index_parent_t tree_index_parent_map
module_binding_check(unsigned long long _fu_prec, double _area_resource, const hlsRef _HLS, const HLS_managerRef _HLSMgr, const CustomUnorderedMap< vertex, double > &_slack_time, const CustomUnorderedMap< vertex, double > &_starting_time, double _controller_delay, module_register_binding_spec &_tree_index_dsets)
const HLS_managerRef HLSMgr
reference to the HLS Manager
AllocationInformationRef allocation_information
Store the technology information.
module_binding_check(const module_binding_check &original)
void insert(node_tree **tree, int val)
absl::flat_hash_map< T, U, Hash, Eq, Alloc > CustomUnorderedMapUnstable
double area_resource
area resource
redefinition of map to manage ordered/unordered structures
unsigned long long fu_prec
resource precision
bool is_assigned(const vertex &v) const
return true in case the vertex has been previously assigned
boost::adjacency_matrix< boost::undirectedS, boost::property< boost::vertex_index_t, std::size_t >, edge_compatibility_selector > boost_cc_compatibility_graph
bulk compatibility graph
CustomUnorderedMap< C_vertex, double > opSlacks
slack associated with the Op
fu_bindingRef Rfu
Store the refcounted functional unit binding of the operations.
size_t num_mux() override
module_register_binding_spec & tree_index_dsets
store the current state for binding
double cost(size_t clique_count) override
virtual double getOpSlack(vertex &operationVertex) const
Takes as input the node representing the operation and returns the maximum number of muxes that can b...
absl::flat_hash_map< T, U, Hash, Eq, Alloc > CustomUnorderedMap
tree_index_parent_map_t tree_index_parent_pmap
CustomUnorderedMapUnstable< unsigned int, unsigned int > tree_index_parent_t
double getOpSlack(vertex &) const override
Takes as input the node representing the operation and returns the maximum number of muxes that can b...
redefinition of set to manage ordered/unordered structures
bool check_no_mux_needed(C_vertex &rep, C_vertex &other) override
boost::graph_traits< graph >::vertex_descriptor vertex
vertex definition.
General class used to describe a graph in PandA.
void update_after_join(C_vertex &rep, C_vertex &child) override
livenessRef Rliv
data-structure containing the variable liveness
module_binding_check * clone() const override
std::vector< CustomOrderedSet< unsigned int > > getOperationVariablesAtPort(vertex &operationVertex) const
Takes as input the vertex of an operation, and returns a vertex.
boost::disjoint_sets< tree_index_rank_map_t, tree_index_parent_map_t > tree_index_dsets_t
tree_index_rank_map_t tree_index_rank_pmap
void initialize_structures(boost_cc_compatibility_graph &graph, CustomUnorderedMap< C_vertex, vertex_type > &Ruv2v) override
bool check_edge_compatibility(C_vertex &rep, C_vertex &other) override
const hlsRef HLS
reference to HLS data structure
int original[DIMENSION_Y][DIMENSION_X]
module_register_binding_spec()
tree_index_rank_t tree_index_rank_map
tree_index_dsets_t binding
module_binding_check_no_filter(unsigned int _fu_prec, double _area_resource, const hlsRef _HLS, const HLS_managerRef _HLSMgr, const CustomUnorderedMap< vertex, double > &_slack_time, const CustomUnorderedMap< vertex, double > &_starting_time, double _controller_delay, module_register_binding_spec &_tree_index_dsets)
bool is_disabled_slack_based_binding
unsigned int functionId
this is the identifier of the function to be implemented
Class managing the functional-unit binding.
vertex get_op_where_defined(unsigned int var) const
return which operation defines the variable
boost::graph_traits< cc_compatibility_graph >::vertex_descriptor C_vertex
cc_compatibility_graph vertex
Data structure definition for high-level synthesis flow.
const CustomUnorderedMap< vertex, double > & starting_time
reference to the vertex starting time
unsigned int get_index(const vertex &v) const
Returns the index of functional unit assigned to the vertex.
CustomUnorderedMap< C_vertex, std::vector< CustomOrderedSet< unsigned int > > > input_variables
the set of input to every port of every clique.
#define THROW_ASSERT(cond, str_expr)
helper function used to check an assert and if needed to throw an error in a standard way ...