Skip to content

Commit 859198c

Browse files
authored
Merge pull request verilog-to-routing#2728 from AlexandreSinger/feature-cluster-legalizer-api
[ClusterLegalizer] Cleaned Up Cluster Placement Stats
2 parents e38c0f3 + fda766d commit 859198c

File tree

53 files changed

+3710
-3702
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+3710
-3702
lines changed

libs/libarchfpga/src/physical_types.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1293,7 +1293,6 @@ class t_pb_graph_node {
12931293
int total_pb_pins; /* only valid for top-level */
12941294

12951295
void* temp_scratch_pad; /* temporary data, useful for keeping track of things when traversing data structure */
1296-
t_cluster_placement_primitive* cluster_placement_primitive; /* pointer to indexing structure useful during packing stage */
12971296

12981297
int* input_pin_class_size; /* Stores the number of pins that belong to a particular input pin class */
12991298
int num_input_pin_class; /* number of input pin classes that this pb_graph_node has */

vpr/src/base/vpr_types.cpp

Lines changed: 0 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -452,100 +452,3 @@ void t_pb::set_atom_pin_bit_index(const t_pb_graph_pin* gpin, BitIndex atom_pin_
452452
pin_rotations_[gpin] = atom_pin_bit_idx;
453453
}
454454

455-
/**
456-
* Free linked lists found in cluster_placement_stats_list
457-
*/
458-
void free_cluster_placement_stats(t_cluster_placement_stats* cluster_placement_stats_list) {
459-
auto& device_ctx = g_vpr_ctx.device();
460-
461-
for (const auto& type : device_ctx.logical_block_types) {
462-
int index = type.index;
463-
cluster_placement_stats_list[index].free_primitives();
464-
}
465-
delete[] cluster_placement_stats_list;
466-
}
467-
468-
void t_cluster_placement_stats::move_inflight_to_tried() {
469-
tried.insert(*in_flight.begin());
470-
in_flight.clear();
471-
}
472-
473-
void t_cluster_placement_stats::invalidate_primitive_and_increment_iterator(int pb_type_index, std::unordered_multimap<int, t_cluster_placement_primitive*>::iterator& it) {
474-
invalid.insert(*it);
475-
valid_primitives[pb_type_index].erase(it++);
476-
}
477-
478-
void t_cluster_placement_stats::move_primitive_to_inflight(int pb_type_index, std::unordered_multimap<int, t_cluster_placement_primitive*>::iterator& it) {
479-
in_flight.insert(*it);
480-
valid_primitives[pb_type_index].erase(it);
481-
}
482-
483-
/**
484-
* @brief Put primitive back on the correct location of valid primitives vector based on the primitive pb type
485-
*
486-
* @note that valid status is not changed because if the primitive is not valid, it will get properly collected later
487-
*/
488-
void t_cluster_placement_stats::insert_primitive_in_valid_primitives(std::pair<int, t_cluster_placement_primitive*> cluster_placement_primitive) {
489-
int i;
490-
bool success = false;
491-
int null_index = OPEN;
492-
t_cluster_placement_primitive* input_cluster_placement_primitive = cluster_placement_primitive.second;
493-
494-
for (i = 0; i < num_pb_types && !success; i++) {
495-
if (valid_primitives[i].empty()) {
496-
null_index = i;
497-
continue;
498-
}
499-
t_cluster_placement_primitive* cur_cluster_placement_primitive = valid_primitives[i].begin()->second;
500-
if (input_cluster_placement_primitive->pb_graph_node->pb_type
501-
== cur_cluster_placement_primitive->pb_graph_node->pb_type) {
502-
success = true;
503-
valid_primitives[i].insert(cluster_placement_primitive);
504-
}
505-
}
506-
if (!success) {
507-
VTR_ASSERT(null_index != OPEN);
508-
valid_primitives[null_index].insert(cluster_placement_primitive);
509-
}
510-
}
511-
512-
void t_cluster_placement_stats::flush_queue(std::unordered_multimap<int, t_cluster_placement_primitive*>& queue) {
513-
for (auto& it : queue) {
514-
insert_primitive_in_valid_primitives(it);
515-
}
516-
queue.clear();
517-
}
518-
519-
void t_cluster_placement_stats::flush_intermediate_queues() {
520-
flush_queue(in_flight);
521-
flush_queue(tried);
522-
}
523-
524-
void t_cluster_placement_stats::flush_invalid_queue() {
525-
flush_queue(invalid);
526-
}
527-
528-
bool t_cluster_placement_stats::in_flight_empty() {
529-
return in_flight.empty();
530-
}
531-
532-
t_pb_type* t_cluster_placement_stats::in_flight_type() {
533-
return in_flight.begin()->second->pb_graph_node->pb_type;
534-
}
535-
536-
void t_cluster_placement_stats::free_primitives() {
537-
for (auto& primitive : tried)
538-
delete primitive.second;
539-
540-
for (auto& primitive : in_flight)
541-
delete primitive.second;
542-
543-
for (auto& primitive : invalid)
544-
delete primitive.second;
545-
546-
for (int j = 0; j < num_pb_types; j++) {
547-
for (auto& primitive : valid_primitives[j]) {
548-
delete primitive.second;
549-
}
550-
}
551-
}

vpr/src/base/vpr_types.h

Lines changed: 0 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -430,90 +430,6 @@ struct t_chain_info {
430430
t_pack_molecule* first_packed_molecule = nullptr;
431431
};
432432

433-
/**
434-
* @brief Stats keeper for placement information during packing
435-
*
436-
* Contains data structure of placement locations based on status of primitive
437-
*/
438-
class t_cluster_placement_stats {
439-
public:
440-
int num_pb_types; ///<num primitive pb_types inside complex block
441-
bool has_long_chain; ///<specifies if this cluster has a molecule placed in it that belongs to a long chain (a chain that spans more than one cluster)
442-
const t_pack_molecule* curr_molecule; ///<current molecule being considered for packing
443-
444-
// Vector of size num_pb_types [0.. num_pb_types-1]. Each element is an unordered_map of the cluster_placement_primitives that are of this pb_type
445-
// Each cluster_placement_primitive is associated with and index (key of the map) for easier lookup, insertion and deletion.
446-
std::vector<std::unordered_map<int, t_cluster_placement_primitive*>> valid_primitives;
447-
448-
public:
449-
// Moves primitives that are inflight to the tried map
450-
void move_inflight_to_tried();
451-
452-
/**
453-
* @brief Move the primitive at (it) to inflight and increment the current iterator.
454-
*
455-
* Because the element at (it) is deleted from valid_primitives, (it) is incremented to keep it valid and pointing at the next element.
456-
*
457-
* @param pb_type_index: is the index of this pb_type in valid_primitives vector
458-
* @param it: is the iterator pointing at the element that needs to be moved to inflight
459-
*/
460-
void move_primitive_to_inflight(int pb_type_index, std::unordered_multimap<int, t_cluster_placement_primitive*>::iterator& it);
461-
462-
/**
463-
* @brief Move the primitive at (it) to invalid and increment the current iterator
464-
*
465-
* Because the element at (it) is deleted from valid_primitives, (it) is incremented to keep it valid and pointing at the next element.
466-
*
467-
* @param pb_type_index: is the index of this pb_type in valid_primitives vector
468-
* @param it: is the iterator pointing at the element that needs to be moved to invalid
469-
*/
470-
void invalidate_primitive_and_increment_iterator(int pb_type_index, std::unordered_multimap<int, t_cluster_placement_primitive*>::iterator& it);
471-
472-
/**
473-
* @brief Add a primitive in its correct location in valid_primitives vector based on its pb_type
474-
*
475-
* @param cluster_placement_primitive: a pair of the cluster_placement_primtive and its corresponding index(for reference in pb_graph_node)
476-
*/
477-
void insert_primitive_in_valid_primitives(std::pair<int, t_cluster_placement_primitive*> cluster_placement_primitive);
478-
479-
/**
480-
* @brief Move all the primitives from (in_flight and tried) maps to valid primitives and clear (in_flight and tried)
481-
*/
482-
void flush_intermediate_queues();
483-
484-
/**
485-
* @brief Move all the primitives from invalid to valid_primitives and clear the invalid map
486-
*/
487-
void flush_invalid_queue();
488-
489-
/**
490-
* @brief Return true if the in_flight map is empty (no primitive is in_flight currently)
491-
*/
492-
bool in_flight_empty();
493-
494-
/**
495-
* @brief Return the type of the first element of the primitives currently being considered
496-
*/
497-
t_pb_type* in_flight_type();
498-
499-
/**
500-
* @brief free the dynamically allocated memory for primitives
501-
*/
502-
void free_primitives();
503-
504-
private:
505-
std::unordered_multimap<int, t_cluster_placement_primitive*> in_flight; ///<ptrs to primitives currently being considered to pack into
506-
std::unordered_multimap<int, t_cluster_placement_primitive*> tried; ///<ptrs to primitives that are already tried but current logic block unable to pack to
507-
std::unordered_multimap<int, t_cluster_placement_primitive*> invalid; ///<ptrs to primitives that are invalid (already occupied by another primitive in this cluster)
508-
509-
/**
510-
* @brief iterate over elements of a queue and move its elements to valid_primitives
511-
*
512-
* @param queue the unordered_multimap to work on (e.g. in_flight, tried, or invalid)
513-
*/
514-
void flush_queue(std::unordered_multimap<int, t_cluster_placement_primitive*>& queue);
515-
};
516-
517433
/******************************************************************
518434
* Timing data types
519435
*******************************************************************/
@@ -1841,11 +1757,6 @@ typedef vtr::vector<ClusterBlockId, std::vector<std::vector<RRNodeId>>> t_clb_op
18411757

18421758
typedef std::vector<std::map<int, int>> t_arch_switch_fanin;
18431759

1844-
/**
1845-
* @brief Free the linked lists to placement locations based on status of primitive inside placement stats data structure.
1846-
*/
1847-
void free_cluster_placement_stats(t_cluster_placement_stats* cluster_placement_stats);
1848-
18491760
struct pair_hash {
18501761
std::size_t operator()(const std::pair<ClusterBlockId, ClusterBlockId>& p) const noexcept {
18511762
return std::hash<ClusterBlockId>()(p.first) ^ (std::hash<ClusterBlockId>()(p.second) << 1);

vpr/src/pack/cluster.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa
116116

117117
enum e_block_pack_status block_pack_status;
118118

119-
t_cluster_placement_stats* cur_cluster_placement_stats_ptr = nullptr;
120119
t_pack_molecule *istart, *next_molecule, *prev_molecule;
121120

122121
auto& atom_ctx = g_vpr_ctx.atom();
@@ -275,7 +274,6 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa
275274
/*it doesn't make sense to do a timing analysis here since there*
276275
*is only one atom block clustered it would not change anything */
277276
}
278-
cur_cluster_placement_stats_ptr = cluster_legalizer.get_cluster_placement_stats(legalization_cluster_id);
279277
cluster_stats.num_unrelated_clustering_attempts = 0;
280278
next_molecule = get_molecule_for_cluster(cluster_legalizer.get_cluster_pb(legalization_cluster_id),
281279
attraction_groups,
@@ -284,7 +282,6 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa
284282
packer_opts.transitive_fanout_threshold,
285283
packer_opts.feasible_block_array_size,
286284
&cluster_stats.num_unrelated_clustering_attempts,
287-
cur_cluster_placement_stats_ptr,
288285
prepacker,
289286
cluster_legalizer,
290287
clb_inter_blk_nets,
@@ -317,7 +314,6 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa
317314
try_fill_cluster(cluster_legalizer,
318315
prepacker,
319316
packer_opts,
320-
cur_cluster_placement_stats_ptr,
321317
prev_molecule,
322318
next_molecule,
323319
num_repeated_molecules,

0 commit comments

Comments
 (0)