From 5102cc8ed7e71e17f90f0bda4e41d6a1fc50cdbd Mon Sep 17 00:00:00 2001 From: Yulang Luo Date: Sat, 13 Jul 2024 15:21:48 -0400 Subject: [PATCH 1/3] [vpr][place] refactoring variables in net_cost_handler inet_cost, proposed_net_cost, and bb_updated_before grouped in a struct. bb_updated_before renamed to bb_update_status. --- vpr/src/place/net_cost_handler.cpp | 115 +++++++++++++++-------------- 1 file changed, 58 insertions(+), 57 deletions(-) diff --git a/vpr/src/place/net_cost_handler.cpp b/vpr/src/place/net_cost_handler.cpp index f78ea1266ff..981be49d14e 100644 --- a/vpr/src/place/net_cost_handler.cpp +++ b/vpr/src/place/net_cost_handler.cpp @@ -55,14 +55,10 @@ static vtr::NdMatrix chanx_place_cost_fac({0, 0}); // [0...device_ctx. static vtr::NdMatrix chany_place_cost_fac({0, 0}); // [0...device_ctx.grid.height()-2] /** - * @brief Cost of a net, and a temporary cost of a net used during move assessment. + * @brief For the first two element in the struct: Cost of a net, and a temporary cost of a net used during move assessment. * We also use negative cost values in proposed_net_cost as a flag to indicate that * the cost of a net has not yet been updated. - */ -static vtr::vector net_cost, proposed_net_cost; - -/** * - * @brief Flag array to indicate whether the specific bounding box has been updated + * For the last one element in the struct: Flag array to indicate whether the specific bounding box has been updated * in this particular swap or not. If it has been updated before, the code * must use the updated data, instead of the out-of-date data passed into the * subroutine, particularly used in try_swap(). The value NOT_UPDATED_YET @@ -74,7 +70,12 @@ static vtr::vector net_cost, proposed_net_cost; * bounding box is got from scratch, so the bounding box would definitely be * right, DO NOT update again. */ -static vtr::vector bb_updated_before; // [0...cluster_ctx.clb_nlist.nets().size()-1] +struct NetInfo { + vtr::vector net_cost; + vtr::vector proposed_net_cost; + vtr::vector bb_update_status; // [0...cluster_ctx.clb_nlist.nets().size()-1] +} NetInfo; +static struct NetInfo net_info; /* The following arrays are used by the try_swap function for speed. */ @@ -477,7 +478,7 @@ static void update_net_bb(const ClusterNetId& net, if (cluster_ctx.clb_nlist.net_sinks(net).size() < SMALL_NET) { //For small nets brute-force bounding box update is faster - if (bb_updated_before[net] == NetUpdateState::NOT_UPDATED_YET) { //Only once per-net + if (net_info.bb_update_status[net] == NetUpdateState::NOT_UPDATED_YET) { //Only once per-net get_non_updatable_bb(net, ts_bb_coord_new[net], ts_layer_sink_pin_count[size_t(net)]); @@ -515,7 +516,7 @@ static void update_net_layer_bb(const ClusterNetId& net, if (cluster_ctx.clb_nlist.net_sinks(net).size() < SMALL_NET) { //For small nets brute-force bounding box update is faster - if (bb_updated_before[net] == NetUpdateState::NOT_UPDATED_YET) { //Only once per-net + if (net_info.bb_update_status[net] == NetUpdateState::NOT_UPDATED_YET) { //Only once per-net get_non_updatable_layer_bb(net, layer_ts_bb_coord_new[net], ts_layer_sink_pin_count[size_t(net)]); @@ -651,13 +652,13 @@ static void update_td_delta_costs(const PlaceDelayModel* delay_model, static void record_affected_net(const ClusterNetId net, int& num_affected_nets) { /* Record effected nets. */ - if (proposed_net_cost[net] < 0.) { + if (net_info.proposed_net_cost[net] < 0.) { /* Net not marked yet. */ ts_nets_to_update[num_affected_nets] = net; num_affected_nets++; /* Flag to say we've marked this net. */ - proposed_net_cost[net] = 1.; + net_info.proposed_net_cost[net] = 1.; } } @@ -875,18 +876,18 @@ static void update_bb(ClusterNetId net_id, pin_old_loc.layer_num = max(min(pin_old_loc.layer_num, device_ctx.grid.get_num_layers() - 1), 0); /* Check if the net had been updated before. */ - if (bb_updated_before[net_id] == NetUpdateState::GOT_FROM_SCRATCH) { + if (net_info.bb_update_status[net_id] == NetUpdateState::GOT_FROM_SCRATCH) { /* The net had been updated from scratch, DO NOT update again! */ return; } - vtr::NdMatrixProxy curr_num_sink_pin_layer = (bb_updated_before[net_id] == NetUpdateState::NOT_UPDATED_YET) ? place_move_ctx.num_sink_pin_layer[size_t(net_id)] : num_sink_pin_layer_new; + vtr::NdMatrixProxy curr_num_sink_pin_layer = (net_info.bb_update_status[net_id] == NetUpdateState::NOT_UPDATED_YET) ? place_move_ctx.num_sink_pin_layer[size_t(net_id)] : num_sink_pin_layer_new; - if (bb_updated_before[net_id] == NetUpdateState::NOT_UPDATED_YET) { + if (net_info.bb_update_status[net_id] == NetUpdateState::NOT_UPDATED_YET) { /* The net had NOT been updated before, could use the old values */ curr_bb_edge = &place_move_ctx.bb_num_on_edges[net_id]; curr_bb_coord = &place_move_ctx.bb_coords[net_id]; - bb_updated_before[net_id] = NetUpdateState::UPDATED_ONCE; + net_info.bb_update_status[net_id] = NetUpdateState::UPDATED_ONCE; } else { /* The net had been updated before, must use the new values */ curr_bb_coord = &bb_coord_new; @@ -902,7 +903,7 @@ static void update_bb(ClusterNetId net_id, if (pin_old_loc.x == curr_bb_coord->xmax) { /* Old position at xmax. */ if (curr_bb_edge->xmax == 1) { get_bb_from_scratch(net_id, bb_coord_new, bb_edge_new, num_sink_pin_layer_new); - bb_updated_before[net_id] = NetUpdateState::GOT_FROM_SCRATCH; + net_info.bb_update_status[net_id] = NetUpdateState::GOT_FROM_SCRATCH; return; } else { bb_edge_new.xmax = curr_bb_edge->xmax - 1; @@ -934,7 +935,7 @@ static void update_bb(ClusterNetId net_id, if (pin_old_loc.x == curr_bb_coord->xmin) { /* Old position at xmin. */ if (curr_bb_edge->xmin == 1) { get_bb_from_scratch(net_id, bb_coord_new, bb_edge_new, num_sink_pin_layer_new); - bb_updated_before[net_id] = NetUpdateState::GOT_FROM_SCRATCH; + net_info.bb_update_status[net_id] = NetUpdateState::GOT_FROM_SCRATCH; return; } else { bb_edge_new.xmin = curr_bb_edge->xmin - 1; @@ -975,7 +976,7 @@ static void update_bb(ClusterNetId net_id, if (pin_old_loc.y == curr_bb_coord->ymax) { /* Old position at ymax. */ if (curr_bb_edge->ymax == 1) { get_bb_from_scratch(net_id, bb_coord_new, bb_edge_new, num_sink_pin_layer_new); - bb_updated_before[net_id] = NetUpdateState::GOT_FROM_SCRATCH; + net_info.bb_update_status[net_id] = NetUpdateState::GOT_FROM_SCRATCH; return; } else { bb_edge_new.ymax = curr_bb_edge->ymax - 1; @@ -1007,7 +1008,7 @@ static void update_bb(ClusterNetId net_id, if (pin_old_loc.y == curr_bb_coord->ymin) { /* Old position at ymin. */ if (curr_bb_edge->ymin == 1) { get_bb_from_scratch(net_id, bb_coord_new, bb_edge_new, num_sink_pin_layer_new); - bb_updated_before[net_id] = NetUpdateState::GOT_FROM_SCRATCH; + net_info.bb_update_status[net_id] = NetUpdateState::GOT_FROM_SCRATCH; return; } else { bb_edge_new.ymin = curr_bb_edge->ymin - 1; @@ -1057,7 +1058,7 @@ static void update_bb(ClusterNetId net_id, if (pin_old_loc.layer_num == curr_bb_coord->layer_max) { if (curr_bb_edge->layer_max == 1) { get_bb_from_scratch(net_id, bb_coord_new, bb_edge_new, num_sink_pin_layer_new); - bb_updated_before[net_id] = NetUpdateState::GOT_FROM_SCRATCH; + net_info.bb_update_status[net_id] = NetUpdateState::GOT_FROM_SCRATCH; return; } else { bb_edge_new.layer_max = curr_bb_edge->layer_max - 1; @@ -1086,7 +1087,7 @@ static void update_bb(ClusterNetId net_id, if (pin_old_loc.layer_num == curr_bb_coord->layer_min) { if (curr_bb_edge->layer_min == 1) { get_bb_from_scratch(net_id, bb_coord_new, bb_edge_new, num_sink_pin_layer_new); - bb_updated_before[net_id] = NetUpdateState::GOT_FROM_SCRATCH; + net_info.bb_update_status[net_id] = NetUpdateState::GOT_FROM_SCRATCH; return; } else { bb_edge_new.layer_min = curr_bb_edge->layer_min - 1; @@ -1123,8 +1124,8 @@ static void update_bb(ClusterNetId net_id, bb_edge_new.layer_max = curr_bb_edge->layer_max; } - if (bb_updated_before[net_id] == NetUpdateState::NOT_UPDATED_YET) { - bb_updated_before[net_id] = NetUpdateState::UPDATED_ONCE; + if (net_info.bb_update_status[net_id] == NetUpdateState::NOT_UPDATED_YET) { + net_info.bb_update_status[net_id] = NetUpdateState::UPDATED_ONCE; } } @@ -1145,19 +1146,19 @@ static void update_layer_bb(ClusterNetId net_id, pin_old_loc.y = max(min(pin_old_loc.y, device_ctx.grid.height() - 2), 1); //-2 for no perim channels /* Check if the net had been updated before. */ - if (bb_updated_before[net_id] == NetUpdateState::GOT_FROM_SCRATCH) { + if (net_info.bb_update_status[net_id] == NetUpdateState::GOT_FROM_SCRATCH) { /* The net had been updated from scratch, DO NOT update again! */ return; } - const vtr::NdMatrixProxy curr_layer_pin_sink_count = (bb_updated_before[net_id] == NetUpdateState::NOT_UPDATED_YET) ? place_move_ctx.num_sink_pin_layer[size_t(net_id)] : bb_pin_sink_count_new; + const vtr::NdMatrixProxy curr_layer_pin_sink_count = (net_info.bb_update_status[net_id] == NetUpdateState::NOT_UPDATED_YET) ? place_move_ctx.num_sink_pin_layer[size_t(net_id)] : bb_pin_sink_count_new; const std::vector*curr_bb_edge, *curr_bb_coord; - if (bb_updated_before[net_id] == NetUpdateState::NOT_UPDATED_YET) { + if (net_info.bb_update_status[net_id] == NetUpdateState::NOT_UPDATED_YET) { /* The net had NOT been updated before, could use the old values */ curr_bb_edge = &place_move_ctx.layer_bb_num_on_edges[net_id]; curr_bb_coord = &place_move_ctx.layer_bb_coords[net_id]; - bb_updated_before[net_id] = NetUpdateState::UPDATED_ONCE; + net_info.bb_update_status[net_id] = NetUpdateState::UPDATED_ONCE; } else { /* The net had been updated before, must use the new values */ curr_bb_edge = &bb_edge_new; @@ -1199,8 +1200,8 @@ static void update_layer_bb(ClusterNetId net_id, bb_coord_new); } - if (bb_updated_before[net_id] == NetUpdateState::NOT_UPDATED_YET) { - bb_updated_before[net_id] = NetUpdateState::UPDATED_ONCE; + if (net_info.bb_update_status[net_id] == NetUpdateState::NOT_UPDATED_YET) { + net_info.bb_update_status[net_id] = NetUpdateState::UPDATED_ONCE; } } @@ -1231,7 +1232,7 @@ static inline void update_bb_same_layer(ClusterNetId net_id, curr_bb_coord[layer_num].xmax, bb_edge_new[layer_num].xmax, bb_coord_new[layer_num].xmax); - if (bb_updated_before[net_id] == NetUpdateState::GOT_FROM_SCRATCH) { + if (net_info.bb_update_status[net_id] == NetUpdateState::GOT_FROM_SCRATCH) { return; } } @@ -1254,7 +1255,7 @@ static inline void update_bb_same_layer(ClusterNetId net_id, curr_bb_coord[layer_num].xmin, bb_edge_new[layer_num].xmin, bb_coord_new[layer_num].xmin); - if (bb_updated_before[net_id] == NetUpdateState::GOT_FROM_SCRATCH) { + if (net_info.bb_update_status[net_id] == NetUpdateState::GOT_FROM_SCRATCH) { return; } } @@ -1278,7 +1279,7 @@ static inline void update_bb_same_layer(ClusterNetId net_id, curr_bb_coord[layer_num].ymax, bb_edge_new[layer_num].ymax, bb_coord_new[layer_num].ymax); - if (bb_updated_before[net_id] == NetUpdateState::GOT_FROM_SCRATCH) { + if (net_info.bb_update_status[net_id] == NetUpdateState::GOT_FROM_SCRATCH) { return; } } @@ -1301,7 +1302,7 @@ static inline void update_bb_same_layer(ClusterNetId net_id, curr_bb_coord[layer_num].ymin, bb_edge_new[layer_num].ymin, bb_coord_new[layer_num].ymin); - if (bb_updated_before[net_id] == NetUpdateState::GOT_FROM_SCRATCH) { + if (net_info.bb_update_status[net_id] == NetUpdateState::GOT_FROM_SCRATCH) { return; } } @@ -1346,7 +1347,7 @@ static inline void update_bb_layer_changed(ClusterNetId net_id, curr_bb_coord[old_layer_num].xmax, bb_edge_new[old_layer_num].xmax, bb_coord_new[old_layer_num].xmax); - if (bb_updated_before[net_id] == NetUpdateState::GOT_FROM_SCRATCH) { + if (net_info.bb_update_status[net_id] == NetUpdateState::GOT_FROM_SCRATCH) { return; } } else if (x_old == curr_bb_coord[old_layer_num].xmin) { @@ -1358,7 +1359,7 @@ static inline void update_bb_layer_changed(ClusterNetId net_id, curr_bb_coord[old_layer_num].xmin, bb_edge_new[old_layer_num].xmin, bb_coord_new[old_layer_num].xmin); - if (bb_updated_before[net_id] == NetUpdateState::GOT_FROM_SCRATCH) { + if (net_info.bb_update_status[net_id] == NetUpdateState::GOT_FROM_SCRATCH) { return; } } @@ -1372,7 +1373,7 @@ static inline void update_bb_layer_changed(ClusterNetId net_id, curr_bb_coord[old_layer_num].ymax, bb_edge_new[old_layer_num].ymax, bb_coord_new[old_layer_num].ymax); - if (bb_updated_before[net_id] == NetUpdateState::GOT_FROM_SCRATCH) { + if (net_info.bb_update_status[net_id] == NetUpdateState::GOT_FROM_SCRATCH) { return; } } else if (y_old == curr_bb_coord[old_layer_num].ymin) { @@ -1384,7 +1385,7 @@ static inline void update_bb_layer_changed(ClusterNetId net_id, curr_bb_coord[old_layer_num].ymin, bb_edge_new[old_layer_num].ymin, bb_coord_new[old_layer_num].ymin); - if (bb_updated_before[net_id] == NetUpdateState::GOT_FROM_SCRATCH) { + if (net_info.bb_update_status[net_id] == NetUpdateState::GOT_FROM_SCRATCH) { return; } } @@ -1424,7 +1425,7 @@ static inline void update_bb_edge(ClusterNetId net_id, bb_edge_new, bb_coord_new, bb_layer_pin_sink_count); - bb_updated_before[net_id] = NetUpdateState::GOT_FROM_SCRATCH; + net_info.bb_update_status[net_id] = NetUpdateState::GOT_FROM_SCRATCH; return; } else { new_num_block_on_edge = old_num_block_on_edge - 1; @@ -1838,7 +1839,7 @@ static double recompute_bb_cost() { for (auto net_id : cluster_ctx.clb_nlist.nets()) { /* for each net ... */ if (!cluster_ctx.clb_nlist.net_is_ignored(net_id)) { /* Do only if not ignored. */ /* Bounding boxes don't have to be recomputed; they're correct. */ - cost += net_cost[net_id]; + cost += net_info.net_cost[net_id]; } } @@ -1863,15 +1864,15 @@ static void set_bb_delta_cost(const int num_affected_nets, double& bb_delta_c) { const auto& cube_bb = g_vpr_ctx.placement().cube_bb; if (cube_bb) { - proposed_net_cost[net_id] = get_net_cost(net_id, + net_info.proposed_net_cost[net_id] = get_net_cost(net_id, ts_bb_coord_new[net_id]); } else { - proposed_net_cost[net_id] = get_net_layer_bb_wire_cost(net_id, + net_info.proposed_net_cost[net_id] = get_net_layer_bb_wire_cost(net_id, layer_ts_bb_coord_new[net_id], ts_layer_sink_pin_count[size_t(net_id)]); } - bb_delta_c += proposed_net_cost[net_id] - net_cost[net_id]; + bb_delta_c += net_info.proposed_net_cost[net_id] - net_info.net_cost[net_id]; } } @@ -1945,8 +1946,8 @@ double comp_bb_cost(e_cost_methods method) { place_move_ctx.num_sink_pin_layer[size_t(net_id)]); } - net_cost[net_id] = get_net_cost(net_id, place_move_ctx.bb_coords[net_id]); - cost += net_cost[net_id]; + net_info.net_cost[net_id] = get_net_cost(net_id, place_move_ctx.bb_coords[net_id]); + cost += net_info.net_cost[net_id]; if (method == CHECK) expected_wirelength += get_net_wirelength_estimate(net_id, place_move_ctx.bb_coords[net_id]); } @@ -1982,10 +1983,10 @@ double comp_layer_bb_cost(e_cost_methods method) { place_move_ctx.num_sink_pin_layer[size_t(net_id)]); } - net_cost[net_id] = get_net_layer_bb_wire_cost(net_id, + net_info.net_cost[net_id] = get_net_layer_bb_wire_cost(net_id, place_move_ctx.layer_bb_coords[net_id], place_move_ctx.num_sink_pin_layer[size_t(net_id)]); - cost += net_cost[net_id]; + cost += net_info.net_cost[net_id]; if (method == CHECK) expected_wirelength += get_net_wirelength_from_layer_bb(net_id, place_move_ctx.layer_bb_coords[net_id], @@ -2029,11 +2030,11 @@ void update_move_nets(int num_nets_affected, } } - net_cost[net_id] = proposed_net_cost[net_id]; + net_info.net_cost[net_id] = net_info.proposed_net_cost[net_id]; /* negative proposed_net_cost value is acting as a flag to mean not computed yet. */ - proposed_net_cost[net_id] = -1; - bb_updated_before[net_id] = NetUpdateState::NOT_UPDATED_YET; + net_info.proposed_net_cost[net_id] = -1; + net_info.bb_update_status[net_id] = NetUpdateState::NOT_UPDATED_YET; } } @@ -2042,8 +2043,8 @@ void reset_move_nets(int num_nets_affected) { for (int inet_affected = 0; inet_affected < num_nets_affected; inet_affected++) { ClusterNetId net_id = ts_nets_to_update[inet_affected]; - proposed_net_cost[net_id] = -1; - bb_updated_before[net_id] = NetUpdateState::NOT_UPDATED_YET; + net_info.proposed_net_cost[net_id] = -1; + net_info.bb_update_status[net_id] = NetUpdateState::NOT_UPDATED_YET; } } @@ -2217,18 +2218,18 @@ void free_chan_w_factors_for_place_cost () { } void init_place_move_structs(size_t num_nets) { - net_cost.resize(num_nets, -1.); - proposed_net_cost.resize(num_nets, -1.); + net_info.net_cost.resize(num_nets, -1.); + net_info.proposed_net_cost.resize(num_nets, -1.); /* Used to store costs for moves not yet made and to indicate when a net's * * cost has been recomputed. proposed_net_cost[inet] < 0 means net's cost hasn't * * been recomputed. */ - bb_updated_before.resize(num_nets, NetUpdateState::NOT_UPDATED_YET); + net_info.bb_update_status.resize(num_nets, NetUpdateState::NOT_UPDATED_YET); } void free_place_move_structs() { - vtr::release_memory(net_cost); - vtr::release_memory(proposed_net_cost); - vtr::release_memory(bb_updated_before); + vtr::release_memory(net_info.net_cost); + vtr::release_memory(net_info.proposed_net_cost); + vtr::release_memory(net_info.bb_update_status); } void init_try_swap_net_cost_structs(size_t num_nets, bool cube_bb) { From 4e44de68054cab4289b5a168899fdcca95ff18bd Mon Sep 17 00:00:00 2001 From: Yulang Luo Date: Sat, 13 Jul 2024 18:23:19 -0400 Subject: [PATCH 2/3] [vpr][place] fixing comments and better variable names --- vpr/src/place/net_cost_handler.cpp | 120 +++++++++++++++-------------- 1 file changed, 61 insertions(+), 59 deletions(-) diff --git a/vpr/src/place/net_cost_handler.cpp b/vpr/src/place/net_cost_handler.cpp index 981be49d14e..885d8172822 100644 --- a/vpr/src/place/net_cost_handler.cpp +++ b/vpr/src/place/net_cost_handler.cpp @@ -55,10 +55,12 @@ static vtr::NdMatrix chanx_place_cost_fac({0, 0}); // [0...device_ctx. static vtr::NdMatrix chany_place_cost_fac({0, 0}); // [0...device_ctx.grid.height()-2] /** - * @brief For the first two element in the struct: Cost of a net, and a temporary cost of a net used during move assessment. + * @brief For each of the vector in this struct, there is one entry per cluster level net: + * [0...cluster_ctx.clb_nlist.nets().size()-1]. + * net_cost and proposed_net_cost: Cost of a net, and a temporary cost of a net used during move assessment. * We also use negative cost values in proposed_net_cost as a flag to indicate that * the cost of a net has not yet been updated. - * For the last one element in the struct: Flag array to indicate whether the specific bounding box has been updated + * bb_update_status: Flag array to indicate whether the specific bounding box has been updated * in this particular swap or not. If it has been updated before, the code * must use the updated data, instead of the out-of-date data passed into the * subroutine, particularly used in try_swap(). The value NOT_UPDATED_YET @@ -70,12 +72,12 @@ static vtr::NdMatrix chany_place_cost_fac({0, 0}); // [0...device_ctx. * bounding box is got from scratch, so the bounding box would definitely be * right, DO NOT update again. */ -struct NetInfo { +struct PLNetCost { vtr::vector net_cost; vtr::vector proposed_net_cost; - vtr::vector bb_update_status; // [0...cluster_ctx.clb_nlist.nets().size()-1] -} NetInfo; -static struct NetInfo net_info; + vtr::vector bb_update_status; +}; +static struct PLNetCost pl_net_cost; /* The following arrays are used by the try_swap function for speed. */ @@ -161,7 +163,7 @@ static void record_affected_net(const ClusterNetId net, int& num_affected_nets); * @param num_affected_nets A pointer to the first free element of ts_nets_to_update. If a new net is added, the pointer should be increamented. * @param is_src_moving Is the moving pin the source of a net. */ -static void update_net_info_on_pin_move(const t_place_algorithm& place_algorithm, +static void update_pl_net_cost_on_pin_move(const t_place_algorithm& place_algorithm, const PlaceDelayModel* delay_model, const PlacerCriticalities* criticalities, const ClusterBlockId& blk_id, @@ -478,7 +480,7 @@ static void update_net_bb(const ClusterNetId& net, if (cluster_ctx.clb_nlist.net_sinks(net).size() < SMALL_NET) { //For small nets brute-force bounding box update is faster - if (net_info.bb_update_status[net] == NetUpdateState::NOT_UPDATED_YET) { //Only once per-net + if (pl_net_cost.bb_update_status[net] == NetUpdateState::NOT_UPDATED_YET) { //Only once per-net get_non_updatable_bb(net, ts_bb_coord_new[net], ts_layer_sink_pin_count[size_t(net)]); @@ -516,7 +518,7 @@ static void update_net_layer_bb(const ClusterNetId& net, if (cluster_ctx.clb_nlist.net_sinks(net).size() < SMALL_NET) { //For small nets brute-force bounding box update is faster - if (net_info.bb_update_status[net] == NetUpdateState::NOT_UPDATED_YET) { //Only once per-net + if (pl_net_cost.bb_update_status[net] == NetUpdateState::NOT_UPDATED_YET) { //Only once per-net get_non_updatable_layer_bb(net, layer_ts_bb_coord_new[net], ts_layer_sink_pin_count[size_t(net)]); @@ -652,17 +654,17 @@ static void update_td_delta_costs(const PlaceDelayModel* delay_model, static void record_affected_net(const ClusterNetId net, int& num_affected_nets) { /* Record effected nets. */ - if (net_info.proposed_net_cost[net] < 0.) { + if (pl_net_cost.proposed_net_cost[net] < 0.) { /* Net not marked yet. */ ts_nets_to_update[num_affected_nets] = net; num_affected_nets++; /* Flag to say we've marked this net. */ - net_info.proposed_net_cost[net] = 1.; + pl_net_cost.proposed_net_cost[net] = 1.; } } -static void update_net_info_on_pin_move(const t_place_algorithm& place_algorithm, +static void update_pl_net_cost_on_pin_move(const t_place_algorithm& place_algorithm, const PlaceDelayModel* delay_model, const PlacerCriticalities* criticalities, const ClusterBlockId& blk_id, @@ -876,18 +878,18 @@ static void update_bb(ClusterNetId net_id, pin_old_loc.layer_num = max(min(pin_old_loc.layer_num, device_ctx.grid.get_num_layers() - 1), 0); /* Check if the net had been updated before. */ - if (net_info.bb_update_status[net_id] == NetUpdateState::GOT_FROM_SCRATCH) { + if (pl_net_cost.bb_update_status[net_id] == NetUpdateState::GOT_FROM_SCRATCH) { /* The net had been updated from scratch, DO NOT update again! */ return; } - vtr::NdMatrixProxy curr_num_sink_pin_layer = (net_info.bb_update_status[net_id] == NetUpdateState::NOT_UPDATED_YET) ? place_move_ctx.num_sink_pin_layer[size_t(net_id)] : num_sink_pin_layer_new; + vtr::NdMatrixProxy curr_num_sink_pin_layer = (pl_net_cost.bb_update_status[net_id] == NetUpdateState::NOT_UPDATED_YET) ? place_move_ctx.num_sink_pin_layer[size_t(net_id)] : num_sink_pin_layer_new; - if (net_info.bb_update_status[net_id] == NetUpdateState::NOT_UPDATED_YET) { + if (pl_net_cost.bb_update_status[net_id] == NetUpdateState::NOT_UPDATED_YET) { /* The net had NOT been updated before, could use the old values */ curr_bb_edge = &place_move_ctx.bb_num_on_edges[net_id]; curr_bb_coord = &place_move_ctx.bb_coords[net_id]; - net_info.bb_update_status[net_id] = NetUpdateState::UPDATED_ONCE; + pl_net_cost.bb_update_status[net_id] = NetUpdateState::UPDATED_ONCE; } else { /* The net had been updated before, must use the new values */ curr_bb_coord = &bb_coord_new; @@ -903,7 +905,7 @@ static void update_bb(ClusterNetId net_id, if (pin_old_loc.x == curr_bb_coord->xmax) { /* Old position at xmax. */ if (curr_bb_edge->xmax == 1) { get_bb_from_scratch(net_id, bb_coord_new, bb_edge_new, num_sink_pin_layer_new); - net_info.bb_update_status[net_id] = NetUpdateState::GOT_FROM_SCRATCH; + pl_net_cost.bb_update_status[net_id] = NetUpdateState::GOT_FROM_SCRATCH; return; } else { bb_edge_new.xmax = curr_bb_edge->xmax - 1; @@ -935,7 +937,7 @@ static void update_bb(ClusterNetId net_id, if (pin_old_loc.x == curr_bb_coord->xmin) { /* Old position at xmin. */ if (curr_bb_edge->xmin == 1) { get_bb_from_scratch(net_id, bb_coord_new, bb_edge_new, num_sink_pin_layer_new); - net_info.bb_update_status[net_id] = NetUpdateState::GOT_FROM_SCRATCH; + pl_net_cost.bb_update_status[net_id] = NetUpdateState::GOT_FROM_SCRATCH; return; } else { bb_edge_new.xmin = curr_bb_edge->xmin - 1; @@ -976,7 +978,7 @@ static void update_bb(ClusterNetId net_id, if (pin_old_loc.y == curr_bb_coord->ymax) { /* Old position at ymax. */ if (curr_bb_edge->ymax == 1) { get_bb_from_scratch(net_id, bb_coord_new, bb_edge_new, num_sink_pin_layer_new); - net_info.bb_update_status[net_id] = NetUpdateState::GOT_FROM_SCRATCH; + pl_net_cost.bb_update_status[net_id] = NetUpdateState::GOT_FROM_SCRATCH; return; } else { bb_edge_new.ymax = curr_bb_edge->ymax - 1; @@ -1008,7 +1010,7 @@ static void update_bb(ClusterNetId net_id, if (pin_old_loc.y == curr_bb_coord->ymin) { /* Old position at ymin. */ if (curr_bb_edge->ymin == 1) { get_bb_from_scratch(net_id, bb_coord_new, bb_edge_new, num_sink_pin_layer_new); - net_info.bb_update_status[net_id] = NetUpdateState::GOT_FROM_SCRATCH; + pl_net_cost.bb_update_status[net_id] = NetUpdateState::GOT_FROM_SCRATCH; return; } else { bb_edge_new.ymin = curr_bb_edge->ymin - 1; @@ -1058,7 +1060,7 @@ static void update_bb(ClusterNetId net_id, if (pin_old_loc.layer_num == curr_bb_coord->layer_max) { if (curr_bb_edge->layer_max == 1) { get_bb_from_scratch(net_id, bb_coord_new, bb_edge_new, num_sink_pin_layer_new); - net_info.bb_update_status[net_id] = NetUpdateState::GOT_FROM_SCRATCH; + pl_net_cost.bb_update_status[net_id] = NetUpdateState::GOT_FROM_SCRATCH; return; } else { bb_edge_new.layer_max = curr_bb_edge->layer_max - 1; @@ -1087,7 +1089,7 @@ static void update_bb(ClusterNetId net_id, if (pin_old_loc.layer_num == curr_bb_coord->layer_min) { if (curr_bb_edge->layer_min == 1) { get_bb_from_scratch(net_id, bb_coord_new, bb_edge_new, num_sink_pin_layer_new); - net_info.bb_update_status[net_id] = NetUpdateState::GOT_FROM_SCRATCH; + pl_net_cost.bb_update_status[net_id] = NetUpdateState::GOT_FROM_SCRATCH; return; } else { bb_edge_new.layer_min = curr_bb_edge->layer_min - 1; @@ -1124,8 +1126,8 @@ static void update_bb(ClusterNetId net_id, bb_edge_new.layer_max = curr_bb_edge->layer_max; } - if (net_info.bb_update_status[net_id] == NetUpdateState::NOT_UPDATED_YET) { - net_info.bb_update_status[net_id] = NetUpdateState::UPDATED_ONCE; + if (pl_net_cost.bb_update_status[net_id] == NetUpdateState::NOT_UPDATED_YET) { + pl_net_cost.bb_update_status[net_id] = NetUpdateState::UPDATED_ONCE; } } @@ -1146,19 +1148,19 @@ static void update_layer_bb(ClusterNetId net_id, pin_old_loc.y = max(min(pin_old_loc.y, device_ctx.grid.height() - 2), 1); //-2 for no perim channels /* Check if the net had been updated before. */ - if (net_info.bb_update_status[net_id] == NetUpdateState::GOT_FROM_SCRATCH) { + if (pl_net_cost.bb_update_status[net_id] == NetUpdateState::GOT_FROM_SCRATCH) { /* The net had been updated from scratch, DO NOT update again! */ return; } - const vtr::NdMatrixProxy curr_layer_pin_sink_count = (net_info.bb_update_status[net_id] == NetUpdateState::NOT_UPDATED_YET) ? place_move_ctx.num_sink_pin_layer[size_t(net_id)] : bb_pin_sink_count_new; + const vtr::NdMatrixProxy curr_layer_pin_sink_count = (pl_net_cost.bb_update_status[net_id] == NetUpdateState::NOT_UPDATED_YET) ? place_move_ctx.num_sink_pin_layer[size_t(net_id)] : bb_pin_sink_count_new; const std::vector*curr_bb_edge, *curr_bb_coord; - if (net_info.bb_update_status[net_id] == NetUpdateState::NOT_UPDATED_YET) { + if (pl_net_cost.bb_update_status[net_id] == NetUpdateState::NOT_UPDATED_YET) { /* The net had NOT been updated before, could use the old values */ curr_bb_edge = &place_move_ctx.layer_bb_num_on_edges[net_id]; curr_bb_coord = &place_move_ctx.layer_bb_coords[net_id]; - net_info.bb_update_status[net_id] = NetUpdateState::UPDATED_ONCE; + pl_net_cost.bb_update_status[net_id] = NetUpdateState::UPDATED_ONCE; } else { /* The net had been updated before, must use the new values */ curr_bb_edge = &bb_edge_new; @@ -1200,8 +1202,8 @@ static void update_layer_bb(ClusterNetId net_id, bb_coord_new); } - if (net_info.bb_update_status[net_id] == NetUpdateState::NOT_UPDATED_YET) { - net_info.bb_update_status[net_id] = NetUpdateState::UPDATED_ONCE; + if (pl_net_cost.bb_update_status[net_id] == NetUpdateState::NOT_UPDATED_YET) { + pl_net_cost.bb_update_status[net_id] = NetUpdateState::UPDATED_ONCE; } } @@ -1232,7 +1234,7 @@ static inline void update_bb_same_layer(ClusterNetId net_id, curr_bb_coord[layer_num].xmax, bb_edge_new[layer_num].xmax, bb_coord_new[layer_num].xmax); - if (net_info.bb_update_status[net_id] == NetUpdateState::GOT_FROM_SCRATCH) { + if (pl_net_cost.bb_update_status[net_id] == NetUpdateState::GOT_FROM_SCRATCH) { return; } } @@ -1255,7 +1257,7 @@ static inline void update_bb_same_layer(ClusterNetId net_id, curr_bb_coord[layer_num].xmin, bb_edge_new[layer_num].xmin, bb_coord_new[layer_num].xmin); - if (net_info.bb_update_status[net_id] == NetUpdateState::GOT_FROM_SCRATCH) { + if (pl_net_cost.bb_update_status[net_id] == NetUpdateState::GOT_FROM_SCRATCH) { return; } } @@ -1279,7 +1281,7 @@ static inline void update_bb_same_layer(ClusterNetId net_id, curr_bb_coord[layer_num].ymax, bb_edge_new[layer_num].ymax, bb_coord_new[layer_num].ymax); - if (net_info.bb_update_status[net_id] == NetUpdateState::GOT_FROM_SCRATCH) { + if (pl_net_cost.bb_update_status[net_id] == NetUpdateState::GOT_FROM_SCRATCH) { return; } } @@ -1302,7 +1304,7 @@ static inline void update_bb_same_layer(ClusterNetId net_id, curr_bb_coord[layer_num].ymin, bb_edge_new[layer_num].ymin, bb_coord_new[layer_num].ymin); - if (net_info.bb_update_status[net_id] == NetUpdateState::GOT_FROM_SCRATCH) { + if (pl_net_cost.bb_update_status[net_id] == NetUpdateState::GOT_FROM_SCRATCH) { return; } } @@ -1347,7 +1349,7 @@ static inline void update_bb_layer_changed(ClusterNetId net_id, curr_bb_coord[old_layer_num].xmax, bb_edge_new[old_layer_num].xmax, bb_coord_new[old_layer_num].xmax); - if (net_info.bb_update_status[net_id] == NetUpdateState::GOT_FROM_SCRATCH) { + if (pl_net_cost.bb_update_status[net_id] == NetUpdateState::GOT_FROM_SCRATCH) { return; } } else if (x_old == curr_bb_coord[old_layer_num].xmin) { @@ -1359,7 +1361,7 @@ static inline void update_bb_layer_changed(ClusterNetId net_id, curr_bb_coord[old_layer_num].xmin, bb_edge_new[old_layer_num].xmin, bb_coord_new[old_layer_num].xmin); - if (net_info.bb_update_status[net_id] == NetUpdateState::GOT_FROM_SCRATCH) { + if (pl_net_cost.bb_update_status[net_id] == NetUpdateState::GOT_FROM_SCRATCH) { return; } } @@ -1373,7 +1375,7 @@ static inline void update_bb_layer_changed(ClusterNetId net_id, curr_bb_coord[old_layer_num].ymax, bb_edge_new[old_layer_num].ymax, bb_coord_new[old_layer_num].ymax); - if (net_info.bb_update_status[net_id] == NetUpdateState::GOT_FROM_SCRATCH) { + if (pl_net_cost.bb_update_status[net_id] == NetUpdateState::GOT_FROM_SCRATCH) { return; } } else if (y_old == curr_bb_coord[old_layer_num].ymin) { @@ -1385,7 +1387,7 @@ static inline void update_bb_layer_changed(ClusterNetId net_id, curr_bb_coord[old_layer_num].ymin, bb_edge_new[old_layer_num].ymin, bb_coord_new[old_layer_num].ymin); - if (net_info.bb_update_status[net_id] == NetUpdateState::GOT_FROM_SCRATCH) { + if (pl_net_cost.bb_update_status[net_id] == NetUpdateState::GOT_FROM_SCRATCH) { return; } } @@ -1425,7 +1427,7 @@ static inline void update_bb_edge(ClusterNetId net_id, bb_edge_new, bb_coord_new, bb_layer_pin_sink_count); - net_info.bb_update_status[net_id] = NetUpdateState::GOT_FROM_SCRATCH; + pl_net_cost.bb_update_status[net_id] = NetUpdateState::GOT_FROM_SCRATCH; return; } else { new_num_block_on_edge = old_num_block_on_edge - 1; @@ -1839,7 +1841,7 @@ static double recompute_bb_cost() { for (auto net_id : cluster_ctx.clb_nlist.nets()) { /* for each net ... */ if (!cluster_ctx.clb_nlist.net_is_ignored(net_id)) { /* Do only if not ignored. */ /* Bounding boxes don't have to be recomputed; they're correct. */ - cost += net_info.net_cost[net_id]; + cost += pl_net_cost.net_cost[net_id]; } } @@ -1864,15 +1866,15 @@ static void set_bb_delta_cost(const int num_affected_nets, double& bb_delta_c) { const auto& cube_bb = g_vpr_ctx.placement().cube_bb; if (cube_bb) { - net_info.proposed_net_cost[net_id] = get_net_cost(net_id, + pl_net_cost.proposed_net_cost[net_id] = get_net_cost(net_id, ts_bb_coord_new[net_id]); } else { - net_info.proposed_net_cost[net_id] = get_net_layer_bb_wire_cost(net_id, + pl_net_cost.proposed_net_cost[net_id] = get_net_layer_bb_wire_cost(net_id, layer_ts_bb_coord_new[net_id], ts_layer_sink_pin_count[size_t(net_id)]); } - bb_delta_c += net_info.proposed_net_cost[net_id] - net_info.net_cost[net_id]; + bb_delta_c += pl_net_cost.proposed_net_cost[net_id] - pl_net_cost.net_cost[net_id]; } } @@ -1904,7 +1906,7 @@ int find_affected_nets_and_update_costs( blocks_affected.num_moved_blocks, blocks_affected.moved_blocks); } - update_net_info_on_pin_move(place_algorithm, + update_pl_net_cost_on_pin_move(place_algorithm, delay_model, criticalities, blk, @@ -1946,8 +1948,8 @@ double comp_bb_cost(e_cost_methods method) { place_move_ctx.num_sink_pin_layer[size_t(net_id)]); } - net_info.net_cost[net_id] = get_net_cost(net_id, place_move_ctx.bb_coords[net_id]); - cost += net_info.net_cost[net_id]; + pl_net_cost.net_cost[net_id] = get_net_cost(net_id, place_move_ctx.bb_coords[net_id]); + cost += pl_net_cost.net_cost[net_id]; if (method == CHECK) expected_wirelength += get_net_wirelength_estimate(net_id, place_move_ctx.bb_coords[net_id]); } @@ -1983,10 +1985,10 @@ double comp_layer_bb_cost(e_cost_methods method) { place_move_ctx.num_sink_pin_layer[size_t(net_id)]); } - net_info.net_cost[net_id] = get_net_layer_bb_wire_cost(net_id, + pl_net_cost.net_cost[net_id] = get_net_layer_bb_wire_cost(net_id, place_move_ctx.layer_bb_coords[net_id], place_move_ctx.num_sink_pin_layer[size_t(net_id)]); - cost += net_info.net_cost[net_id]; + cost += pl_net_cost.net_cost[net_id]; if (method == CHECK) expected_wirelength += get_net_wirelength_from_layer_bb(net_id, place_move_ctx.layer_bb_coords[net_id], @@ -2030,11 +2032,11 @@ void update_move_nets(int num_nets_affected, } } - net_info.net_cost[net_id] = net_info.proposed_net_cost[net_id]; + pl_net_cost.net_cost[net_id] = pl_net_cost.proposed_net_cost[net_id]; /* negative proposed_net_cost value is acting as a flag to mean not computed yet. */ - net_info.proposed_net_cost[net_id] = -1; - net_info.bb_update_status[net_id] = NetUpdateState::NOT_UPDATED_YET; + pl_net_cost.proposed_net_cost[net_id] = -1; + pl_net_cost.bb_update_status[net_id] = NetUpdateState::NOT_UPDATED_YET; } } @@ -2043,8 +2045,8 @@ void reset_move_nets(int num_nets_affected) { for (int inet_affected = 0; inet_affected < num_nets_affected; inet_affected++) { ClusterNetId net_id = ts_nets_to_update[inet_affected]; - net_info.proposed_net_cost[net_id] = -1; - net_info.bb_update_status[net_id] = NetUpdateState::NOT_UPDATED_YET; + pl_net_cost.proposed_net_cost[net_id] = -1; + pl_net_cost.bb_update_status[net_id] = NetUpdateState::NOT_UPDATED_YET; } } @@ -2218,18 +2220,18 @@ void free_chan_w_factors_for_place_cost () { } void init_place_move_structs(size_t num_nets) { - net_info.net_cost.resize(num_nets, -1.); - net_info.proposed_net_cost.resize(num_nets, -1.); + pl_net_cost.net_cost.resize(num_nets, -1.); + pl_net_cost.proposed_net_cost.resize(num_nets, -1.); /* Used to store costs for moves not yet made and to indicate when a net's * * cost has been recomputed. proposed_net_cost[inet] < 0 means net's cost hasn't * * been recomputed. */ - net_info.bb_update_status.resize(num_nets, NetUpdateState::NOT_UPDATED_YET); + pl_net_cost.bb_update_status.resize(num_nets, NetUpdateState::NOT_UPDATED_YET); } void free_place_move_structs() { - vtr::release_memory(net_info.net_cost); - vtr::release_memory(net_info.proposed_net_cost); - vtr::release_memory(net_info.bb_update_status); + vtr::release_memory(pl_net_cost.net_cost); + vtr::release_memory(pl_net_cost.proposed_net_cost); + vtr::release_memory(pl_net_cost.bb_update_status); } void init_try_swap_net_cost_structs(size_t num_nets, bool cube_bb) { From 38c6a85f8d7f49a1373b863d2bfe16faf037dd77 Mon Sep 17 00:00:00 2001 From: Yulang Luo Date: Sun, 14 Jul 2024 16:14:13 -0400 Subject: [PATCH 3/3] [vpr][placer] fixed comment's grammar --- vpr/src/place/net_cost_handler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vpr/src/place/net_cost_handler.cpp b/vpr/src/place/net_cost_handler.cpp index 885d8172822..37e4f6a4a39 100644 --- a/vpr/src/place/net_cost_handler.cpp +++ b/vpr/src/place/net_cost_handler.cpp @@ -55,7 +55,7 @@ static vtr::NdMatrix chanx_place_cost_fac({0, 0}); // [0...device_ctx. static vtr::NdMatrix chany_place_cost_fac({0, 0}); // [0...device_ctx.grid.height()-2] /** - * @brief For each of the vector in this struct, there is one entry per cluster level net: + * @brief For each of the vectors in this struct, there is one entry per cluster level net: * [0...cluster_ctx.clb_nlist.nets().size()-1]. * net_cost and proposed_net_cost: Cost of a net, and a temporary cost of a net used during move assessment. * We also use negative cost values in proposed_net_cost as a flag to indicate that