Skip to content

Commit df53193

Browse files
rename PlacerContext to PlacerState
1 parent 1b40e0c commit df53193

38 files changed

+289
-290
lines changed

vpr/src/base/read_place.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include <string>
77

88

9-
class PlacerContext;
9+
class PlacerState;
1010
class ClusterBlockId;
1111
struct t_block_loc;
1212

vpr/src/place/RL_agent_util.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include "static_move_generator.h"
33
#include "manual_move_generator.h"
44

5-
std::pair<std::unique_ptr<MoveGenerator>, std::unique_ptr<MoveGenerator>> create_move_generators(PlacerContext& placer_ctx,
5+
std::pair<std::unique_ptr<MoveGenerator>, std::unique_ptr<MoveGenerator>> create_move_generators(PlacerState& placer_state,
66
const t_placer_opts& placer_opts,
77
int move_lim,
88
double noc_attraction_weight) {
@@ -20,8 +20,8 @@ std::pair<std::unique_ptr<MoveGenerator>, std::unique_ptr<MoveGenerator>> create
2020
move_name.c_str(),
2121
placer_opts.place_static_move_prob[move_type]);
2222
}
23-
move_generators.first = std::make_unique<StaticMoveGenerator>(placer_ctx, placer_opts.place_static_move_prob);
24-
move_generators.second = std::make_unique<StaticMoveGenerator>(placer_ctx, placer_opts.place_static_move_prob);
23+
move_generators.first = std::make_unique<StaticMoveGenerator>(placer_state, placer_opts.place_static_move_prob);
24+
move_generators.second = std::make_unique<StaticMoveGenerator>(placer_state, placer_opts.place_static_move_prob);
2525
} else { //RL based placement
2626
/* For the non timing driven placement: the agent has a single state *
2727
* - Available moves are (Uniform / Median / Centroid) *
@@ -73,7 +73,7 @@ std::pair<std::unique_ptr<MoveGenerator>, std::unique_ptr<MoveGenerator>> create
7373
placer_opts.place_agent_epsilon);
7474
}
7575
karmed_bandit_agent1->set_step(placer_opts.place_agent_gamma, move_lim);
76-
move_generators.first = std::make_unique<SimpleRLMoveGenerator>(placer_ctx,
76+
move_generators.first = std::make_unique<SimpleRLMoveGenerator>(placer_state,
7777
karmed_bandit_agent1,
7878
noc_attraction_weight,
7979
placer_opts.place_high_fanout_net);
@@ -82,7 +82,7 @@ std::pair<std::unique_ptr<MoveGenerator>, std::unique_ptr<MoveGenerator>> create
8282
e_agent_space::MOVE_TYPE,
8383
placer_opts.place_agent_epsilon);
8484
karmed_bandit_agent2->set_step(placer_opts.place_agent_gamma, move_lim);
85-
move_generators.second = std::make_unique<SimpleRLMoveGenerator>(placer_ctx,
85+
move_generators.second = std::make_unique<SimpleRLMoveGenerator>(placer_state,
8686
karmed_bandit_agent2,
8787
noc_attraction_weight,
8888
placer_opts.place_high_fanout_net);
@@ -99,15 +99,15 @@ std::pair<std::unique_ptr<MoveGenerator>, std::unique_ptr<MoveGenerator>> create
9999
e_agent_space::MOVE_TYPE);
100100
}
101101
karmed_bandit_agent1->set_step(placer_opts.place_agent_gamma, move_lim);
102-
move_generators.first = std::make_unique<SimpleRLMoveGenerator>(placer_ctx,
102+
move_generators.first = std::make_unique<SimpleRLMoveGenerator>(placer_state,
103103
karmed_bandit_agent1,
104104
noc_attraction_weight,
105105
placer_opts.place_high_fanout_net);
106106
//agent's 2nd state
107107
karmed_bandit_agent2 = std::make_unique<SoftmaxAgent>(second_state_avail_moves,
108108
e_agent_space::MOVE_TYPE);
109109
karmed_bandit_agent2->set_step(placer_opts.place_agent_gamma, move_lim);
110-
move_generators.second = std::make_unique<SimpleRLMoveGenerator>(placer_ctx,
110+
move_generators.second = std::make_unique<SimpleRLMoveGenerator>(placer_state,
111111
karmed_bandit_agent2,
112112
noc_attraction_weight,
113113
placer_opts.place_high_fanout_net);

vpr/src/place/RL_agent_util.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ enum class e_agent_state {
1616
* type selected in placer_opts.
1717
* It returns a unique pointer for each move generator in move_generator and move_generator2
1818
*
19-
* @param placer_ctx Move generators store a reference to the placer context to avoid global state access.
19+
* @param placer_state Move generators store a reference to the placer context to avoid global state access.
2020
* @param placer_opts Contains information about the placement algorithm and its parameters.
2121
* @param move_lim represents the num of moves per temp.
2222
* @param noc_attraction_weight The attraction weight by which the NoC-biased centroid move adjust the computed location
@@ -26,7 +26,7 @@ enum class e_agent_state {
2626
* in the first and second states of the agent.
2727
*
2828
*/
29-
std::pair<std::unique_ptr<MoveGenerator>, std::unique_ptr<MoveGenerator>> create_move_generators(PlacerContext& placer_ctx,
29+
std::pair<std::unique_ptr<MoveGenerator>, std::unique_ptr<MoveGenerator>> create_move_generators(PlacerState& placer_state,
3030
const t_placer_opts& placer_opts,
3131
int move_lim,
3232
double noc_attraction_weight);

vpr/src/place/centroid_move_generator.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ vtr::vector<ClusterBlockId, NocGroupId> CentroidMoveGenerator::cluster_to_noc_gr
1616
std::map<ClusterBlockId, NocGroupId> CentroidMoveGenerator::noc_router_to_noc_group_;
1717

1818

19-
CentroidMoveGenerator::CentroidMoveGenerator(PlacerContext& placer_ctx)
20-
: MoveGenerator(placer_ctx)
19+
CentroidMoveGenerator::CentroidMoveGenerator(PlacerState& placer_state)
20+
: MoveGenerator(placer_state)
2121
, noc_attraction_w_(0.0f)
2222
, noc_attraction_enabled_(false) {}
2323

24-
CentroidMoveGenerator::CentroidMoveGenerator(PlacerContext& placer_ctx,
24+
CentroidMoveGenerator::CentroidMoveGenerator(PlacerState& placer_state,
2525
float noc_attraction_weight,
2626
size_t high_fanout_net)
27-
: MoveGenerator(placer_ctx)
27+
: MoveGenerator(placer_state)
2828
, noc_attraction_w_(noc_attraction_weight)
2929
, noc_attraction_enabled_(true) {
3030
VTR_ASSERT(noc_attraction_weight > 0.0 && noc_attraction_weight <= 1.0);
@@ -44,20 +44,20 @@ e_create_move CentroidMoveGenerator::propose_move(t_pl_blocks_to_be_moved& block
4444
float rlim,
4545
const t_placer_opts& placer_opts,
4646
const PlacerCriticalities* /*criticalities*/) {
47-
auto& placer_ctx = placer_ctx_.get();
48-
const auto& block_locs = placer_ctx.block_locs();
47+
auto& placer_state = placer_state_.get();
48+
const auto& block_locs = placer_state.block_locs();
4949
const auto& device_ctx = g_vpr_ctx.device();
5050
const auto& cluster_ctx = g_vpr_ctx.clustering();
51-
const auto& place_move_ctx = placer_ctx.move();
52-
const auto& blk_loc_registry = placer_ctx.blk_loc_registry();
51+
const auto& place_move_ctx = placer_state.move();
52+
const auto& blk_loc_registry = placer_state.blk_loc_registry();
5353

5454
// Find a movable block based on blk_type
5555
ClusterBlockId b_from = propose_block_to_move(placer_opts,
5656
proposed_action.logical_blk_type_index,
5757
/*highly_crit_block=*/false,
5858
/*net_from=*/nullptr,
5959
/*pin_from=*/nullptr,
60-
placer_ctx);
60+
placer_state);
6161

6262
VTR_LOGV_DEBUG(g_vpr_ctx.placement().f_placer_debug,
6363
"Centroid Move Choose Block %d - rlim %f\n",

vpr/src/place/centroid_move_generator.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class CentroidMoveGenerator : public MoveGenerator {
2424
* The move generator created by calling this constructor only consider
2525
* netlist connectivity for computing the centroid location.
2626
*/
27-
explicit CentroidMoveGenerator(PlacerContext& placer_ctx);
27+
explicit CentroidMoveGenerator(PlacerState& placer_state);
2828

2929
/**
3030
* The move generator created by calling this constructor considers both
@@ -39,7 +39,7 @@ class CentroidMoveGenerator : public MoveGenerator {
3939
* @param high_fanout_net All nets with a fanout larger than this number are
4040
* ignored when forming NoC groups.
4141
*/
42-
CentroidMoveGenerator(PlacerContext& placer_ctx,
42+
CentroidMoveGenerator(PlacerState& placer_state,
4343
float noc_attraction_weight,
4444
size_t high_fanout_net);
4545

vpr/src/place/critical_uniform_move_generator.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@
44
#include "placer_state.h"
55
#include "move_utils.h"
66

7-
CriticalUniformMoveGenerator::CriticalUniformMoveGenerator(PlacerContext& placer_ctx)
8-
: MoveGenerator(placer_ctx) {}
7+
CriticalUniformMoveGenerator::CriticalUniformMoveGenerator(PlacerState& placer_state)
8+
: MoveGenerator(placer_state) {}
99

1010
e_create_move CriticalUniformMoveGenerator::propose_move(t_pl_blocks_to_be_moved& blocks_affected,
1111
t_propose_action& proposed_action,
1212
float rlim,
1313
const t_placer_opts& placer_opts,
1414
const PlacerCriticalities* /*criticalities*/) {
1515
auto& cluster_ctx = g_vpr_ctx.clustering();
16-
const auto& placer_ctx = placer_ctx_.get();
17-
const auto& block_locs = placer_ctx.block_locs();
18-
const auto& blk_loc_registry = placer_ctx.blk_loc_registry();
16+
const auto& placer_state = placer_state_.get();
17+
const auto& block_locs = placer_state.block_locs();
18+
const auto& blk_loc_registry = placer_state.blk_loc_registry();
1919

2020
ClusterNetId net_from;
2121
int pin_from;
@@ -25,7 +25,7 @@ e_create_move CriticalUniformMoveGenerator::propose_move(t_pl_blocks_to_be_moved
2525
/*highly_crit_block=*/true,
2626
&net_from,
2727
&pin_from,
28-
placer_ctx);
28+
placer_state);
2929

3030
VTR_LOGV_DEBUG(g_vpr_ctx.placement().f_placer_debug, "Critical Uniform Move Choose Block %d - rlim %f\n", size_t(b_from), rlim);
3131

vpr/src/place/critical_uniform_move_generator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
class CriticalUniformMoveGenerator : public MoveGenerator {
1818
public:
1919
CriticalUniformMoveGenerator() = delete;
20-
explicit CriticalUniformMoveGenerator(PlacerContext& placer_ctx);
20+
explicit CriticalUniformMoveGenerator(PlacerState& placer_state);
2121

2222
private:
2323
e_create_move propose_move(t_pl_blocks_to_be_moved& blocks_affected,

vpr/src/place/feasible_region_move_generator.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@
88
#include <algorithm>
99
#include <cmath>
1010

11-
FeasibleRegionMoveGenerator::FeasibleRegionMoveGenerator(PlacerContext& placer_ctx)
12-
: MoveGenerator(placer_ctx) {}
11+
FeasibleRegionMoveGenerator::FeasibleRegionMoveGenerator(PlacerState& placer_state)
12+
: MoveGenerator(placer_state) {}
1313

1414
e_create_move FeasibleRegionMoveGenerator::propose_move(t_pl_blocks_to_be_moved& blocks_affected,
1515
t_propose_action& proposed_action,
1616
float rlim,
1717
const t_placer_opts& placer_opts,
1818
const PlacerCriticalities* criticalities) {
1919
const auto& cluster_ctx = g_vpr_ctx.clustering();
20-
auto& placer_ctx = placer_ctx_.get();
21-
auto& place_move_ctx = placer_ctx.mutable_move();
22-
const auto& block_locs = placer_ctx.block_locs();
23-
const auto& blk_loc_registry = placer_ctx.blk_loc_registry();
20+
auto& placer_state = placer_state_.get();
21+
auto& place_move_ctx = placer_state.mutable_move();
22+
const auto& block_locs = placer_state.block_locs();
23+
const auto& blk_loc_registry = placer_state.blk_loc_registry();
2424

2525
ClusterNetId net_from;
2626
int pin_from;
@@ -30,7 +30,7 @@ e_create_move FeasibleRegionMoveGenerator::propose_move(t_pl_blocks_to_be_moved&
3030
/*highly_crit_block=*/true,
3131
&net_from,
3232
&pin_from,
33-
placer_ctx);
33+
placer_state);
3434

3535
VTR_LOGV_DEBUG(g_vpr_ctx.placement().f_placer_debug, "Feasible Region Move Choose Block %di - rlim %f\n", size_t(b_from), rlim);
3636

vpr/src/place/feasible_region_move_generator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
class FeasibleRegionMoveGenerator : public MoveGenerator {
2222
public:
2323
FeasibleRegionMoveGenerator() = delete;
24-
explicit FeasibleRegionMoveGenerator(PlacerContext& placer_ctx);
24+
explicit FeasibleRegionMoveGenerator(PlacerState& placer_state);
2525

2626
private:
2727
e_create_move propose_move(t_pl_blocks_to_be_moved& blocks_affected,

vpr/src/place/manual_move_generator.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
# include "draw.h"
1919
#endif //NO_GRAPHICS
2020

21-
ManualMoveGenerator::ManualMoveGenerator(PlacerContext& placer_ctx)
22-
: MoveGenerator(placer_ctx) {}
21+
ManualMoveGenerator::ManualMoveGenerator(PlacerState& placer_state)
22+
: MoveGenerator(placer_state) {}
2323

2424
//Manual Move Generator function
2525
e_create_move ManualMoveGenerator::propose_move(t_pl_blocks_to_be_moved& blocks_affected,
@@ -30,7 +30,7 @@ e_create_move ManualMoveGenerator::propose_move(t_pl_blocks_to_be_moved& blocks_
3030
auto& place_ctx = g_vpr_ctx.placement();
3131
auto& cluster_ctx = g_vpr_ctx.clustering();
3232
auto& device_ctx = g_vpr_ctx.device();
33-
auto& block_locs = placer_ctx_.get().block_locs();
33+
auto& block_locs = placer_state_.get().block_locs();
3434

3535
int block_id = -1;
3636
t_pl_loc to;

vpr/src/place/manual_move_generator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
class ManualMoveGenerator : public MoveGenerator {
2828
public:
2929
ManualMoveGenerator() = delete;
30-
explicit ManualMoveGenerator(PlacerContext& placer_ctx);
30+
explicit ManualMoveGenerator(PlacerState& placer_state);
3131

3232
//Evaluates if move is successful and legal or unable to do.
3333
e_create_move propose_move(t_pl_blocks_to_be_moved& blocks_affected,

vpr/src/place/median_move_generator.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
#include <algorithm>
99

10-
MedianMoveGenerator::MedianMoveGenerator(PlacerContext& placer_ctx)
11-
: MoveGenerator(placer_ctx) {}
10+
MedianMoveGenerator::MedianMoveGenerator(PlacerState& placer_state)
11+
: MoveGenerator(placer_state) {}
1212

1313
e_create_move MedianMoveGenerator::propose_move(t_pl_blocks_to_be_moved& blocks_affected,
1414
t_propose_action& proposed_action,
@@ -17,18 +17,18 @@ e_create_move MedianMoveGenerator::propose_move(t_pl_blocks_to_be_moved& blocks_
1717
const PlacerCriticalities* /*criticalities*/) {
1818
const auto& cluster_ctx = g_vpr_ctx.clustering();
1919
const auto& device_ctx = g_vpr_ctx.device();
20-
auto& placer_ctx = placer_ctx_.get();
21-
auto& place_move_ctx = placer_ctx.mutable_move();
22-
const auto& block_locs = placer_ctx.block_locs();
23-
const auto& blk_loc_registry = placer_ctx.blk_loc_registry();
20+
auto& placer_state = placer_state_.get();
21+
auto& place_move_ctx = placer_state.mutable_move();
22+
const auto& block_locs = placer_state.block_locs();
23+
const auto& blk_loc_registry = placer_state.blk_loc_registry();
2424

2525
//Find a movable block based on blk_type
2626
ClusterBlockId b_from = propose_block_to_move(placer_opts,
2727
proposed_action.logical_blk_type_index,
2828
/*highly_crit_block=*/false,
2929
/*net_from=*/nullptr,
3030
/*pin_from=*/nullptr,
31-
placer_ctx);
31+
placer_state);
3232

3333
VTR_LOGV_DEBUG(g_vpr_ctx.placement().f_placer_debug, "Median Move Choose Block %d - rlim %f\n", size_t(b_from), rlim);
3434

@@ -201,8 +201,8 @@ void MedianMoveGenerator::get_bb_from_scratch_excluding_block(ClusterNetId net_i
201201
ClusterBlockId block_id,
202202
bool& skip_net) {
203203
//TODO: account for multiple physical pin instances per logical pin
204-
const auto& placer_ctx = placer_ctx_.get();
205-
const auto& block_locs = placer_ctx.block_locs();
204+
const auto& placer_state = placer_state_.get();
205+
const auto& block_locs = placer_state.block_locs();
206206

207207
skip_net = true;
208208

@@ -224,7 +224,7 @@ void MedianMoveGenerator::get_bb_from_scratch_excluding_block(ClusterNetId net_i
224224

225225
if (bnum != block_id) {
226226
skip_net = false;
227-
pnum = placer_ctx.blk_loc_registry().net_pin_to_tile_pin_index(net_id, 0);
227+
pnum = placer_state.blk_loc_registry().net_pin_to_tile_pin_index(net_id, 0);
228228
const t_pl_loc& block_loc = block_locs[bnum].loc;
229229
int src_x = block_loc.x + physical_tile_type(block_loc)->pin_width_offset[pnum];
230230
int src_y = block_loc.y + physical_tile_type(block_loc)->pin_height_offset[pnum];
@@ -241,7 +241,7 @@ void MedianMoveGenerator::get_bb_from_scratch_excluding_block(ClusterNetId net_i
241241

242242
for (ClusterPinId pin_id : cluster_ctx.clb_nlist.net_sinks(net_id)) {
243243
bnum = cluster_ctx.clb_nlist.pin_block(pin_id);
244-
pnum = placer_ctx.blk_loc_registry().tile_pin_index(pin_id);
244+
pnum = placer_state.blk_loc_registry().tile_pin_index(pin_id);
245245
if (bnum == block_id)
246246
continue;
247247
skip_net = false;
@@ -318,7 +318,7 @@ bool MedianMoveGenerator::get_bb_incrementally(ClusterNetId net_id,
318318
//TODO: account for multiple physical pin instances per logical pin
319319

320320
auto& device_ctx = g_vpr_ctx.device();
321-
auto& place_move_ctx = placer_ctx_.get().move();
321+
auto& place_move_ctx = placer_state_.get().move();
322322

323323
xnew = std::max(std::min<int>(xnew, device_ctx.grid.width() - 2), 1); //-2 for no perim channels
324324
ynew = std::max(std::min<int>(ynew, device_ctx.grid.height() - 2), 1); //-2 for no perim channels

vpr/src/place/median_move_generator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
class MedianMoveGenerator : public MoveGenerator {
1919
public:
2020
MedianMoveGenerator() = delete;
21-
explicit MedianMoveGenerator(PlacerContext& placer_ctx);
21+
explicit MedianMoveGenerator(PlacerState& placer_state);
2222

2323
private:
2424
e_create_move propose_move(t_pl_blocks_to_be_moved& blocks_affected,

0 commit comments

Comments
 (0)