Skip to content

Commit 93ff837

Browse files
update noc_place_utils with RngContainer args
1 parent 3e50497 commit 93ff837

File tree

3 files changed

+24
-11
lines changed

3 files changed

+24
-11
lines changed

vpr/src/place/initial_noc_placement.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,10 @@ static void noc_routers_anneal(const t_noc_opts& noc_opts,
273273
blocks_affected.clear_move_blocks();
274274
// Shrink the range limit over time
275275
float r_lim_decayed = 1.0f + (N_MOVES - i_move) * (max_r_lim / N_MOVES);
276-
e_create_move create_move_outcome = propose_router_swap(blocks_affected, r_lim_decayed, blk_loc_registry);
276+
e_create_move create_move_outcome = propose_router_swap(blocks_affected,
277+
r_lim_decayed,
278+
blk_loc_registry,
279+
rng);
277280

278281
if (create_move_outcome != e_create_move::ABORT) {
279282
blk_loc_registry.apply_move_blocks(blocks_affected);

vpr/src/place/noc_place_utils.cpp

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
static bool select_random_router_cluster(ClusterBlockId& b_from,
3535
t_pl_loc& from,
3636
t_logical_block_type_ptr& cluster_from_type,
37-
const vtr::vector_map<ClusterBlockId, t_block_loc>& block_locs);
37+
const vtr::vector_map<ClusterBlockId, t_block_loc>& block_locs,
38+
vtr::RngContainer& rng);
3839

3940
/**
4041
* @brief Given two traffic flow routes, finds links that appear
@@ -820,20 +821,22 @@ std::vector<NocLink> NocCostHandler::get_top_n_congested_links(int n) {
820821
}
821822

822823
/* Below are functions related to the feature that forces to the placer to swap router blocks for a certain percentage of the total number of swaps */
823-
bool check_for_router_swap(int user_supplied_noc_router_swap_percentage) {
824+
bool check_for_router_swap(int user_supplied_noc_router_swap_percentage,
825+
vtr::RngContainer& rng) {
824826
/* A random number between 0-100 is generated here and compared to the user
825827
* supplied value. If the random number is less than the user supplied
826828
* value we indicate that a router block should be swapped. By doing this
827829
* we now only swap router blocks for the percentage of time the user
828830
* supplied.
829831
* */
830-
return (vtr::irand(99) < user_supplied_noc_router_swap_percentage);
832+
return (rng.irand(99) < user_supplied_noc_router_swap_percentage);
831833
}
832834

833835
static bool select_random_router_cluster(ClusterBlockId& b_from,
834836
t_pl_loc& from,
835837
t_logical_block_type_ptr& cluster_from_type,
836-
const vtr::vector_map<ClusterBlockId, t_block_loc>& block_locs) {
838+
const vtr::vector_map<ClusterBlockId, t_block_loc>& block_locs,
839+
vtr::RngContainer& rng) {
837840
// need to access all the router cluster blocks in the design
838841
const auto& noc_ctx = g_vpr_ctx.noc();
839842
auto& cluster_ctx = g_vpr_ctx.clustering();
@@ -849,7 +852,7 @@ static bool select_random_router_cluster(ClusterBlockId& b_from,
849852
const int number_of_router_blocks = static_cast<int>(router_clusters.size());
850853

851854
//randomly choose a router block to move
852-
const int random_cluster_block_index = vtr::irand(number_of_router_blocks - 1);
855+
const int random_cluster_block_index = rng.irand(number_of_router_blocks - 1);
853856
b_from = router_clusters[random_cluster_block_index];
854857

855858
//check if the block is movable
@@ -867,7 +870,8 @@ static bool select_random_router_cluster(ClusterBlockId& b_from,
867870

868871
e_create_move propose_router_swap(t_pl_blocks_to_be_moved& blocks_affected,
869872
float rlim,
870-
const BlkLocRegistry& blk_loc_registry) {
873+
const BlkLocRegistry& blk_loc_registry,
874+
vtr::RngContainer& rng) {
871875
// block ID for the randomly selected router cluster
872876
ClusterBlockId b_from;
873877
// current location of the randomly selected router cluster
@@ -876,7 +880,11 @@ e_create_move propose_router_swap(t_pl_blocks_to_be_moved& blocks_affected,
876880
t_logical_block_type_ptr cluster_from_type;
877881

878882
// Randomly select a router cluster
879-
bool random_select_success = select_random_router_cluster(b_from, from, cluster_from_type, blk_loc_registry.block_locs());
883+
bool random_select_success = select_random_router_cluster(b_from,
884+
from,
885+
cluster_from_type,
886+
blk_loc_registry.block_locs(),
887+
rng);
880888

881889
// If a random router cluster could not be selected, no move can be proposed
882890
if (!random_select_success) {
@@ -886,7 +894,7 @@ e_create_move propose_router_swap(t_pl_blocks_to_be_moved& blocks_affected,
886894
// now choose a compatible block to swap with
887895
t_pl_loc to;
888896
to.layer = from.layer;
889-
if (!find_to_loc_uniform(cluster_from_type, rlim, from, to, b_from, blk_loc_registry)) {
897+
if (!find_to_loc_uniform(cluster_from_type, rlim, from, to, b_from, blk_loc_registry, rng)) {
890898
return e_create_move::ABORT;
891899
}
892900

vpr/src/place/noc_place_utils.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,8 @@ double calculate_noc_cost(const NocCostTerms& cost_terms,
640640
* @return true This indicates that a router block should be swapped
641641
* @return false This indicates that a router block should not be swapped
642642
*/
643-
bool check_for_router_swap(int user_supplied_noc_router_swap_percentage);
643+
bool check_for_router_swap(int user_supplied_noc_router_swap_percentage,
644+
vtr::RngContainer& rng);
644645

645646
/**
646647
* @brief Generates a placement move by first choosing a random router cluster
@@ -660,7 +661,8 @@ bool check_for_router_swap(int user_supplied_noc_router_swap_percentage);
660661
*/
661662
e_create_move propose_router_swap(t_pl_blocks_to_be_moved& blocks_affected,
662663
float rlim,
663-
const BlkLocRegistry& blk_loc_registry);
664+
const BlkLocRegistry& blk_loc_registry,
665+
vtr::RngContainer& rng);
664666

665667
/**
666668
* @brief Writes out the locations of the router cluster blocks in the

0 commit comments

Comments
 (0)