Skip to content

Commit c74ed3b

Browse files
fix segault in SimpleRLMoveGenerator::propose_move() when noc centroid move is enabled
1 parent b0211ab commit c74ed3b

File tree

4 files changed

+14
-13
lines changed

4 files changed

+14
-13
lines changed

vpr/src/place/RL_agent_util.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ void create_move_generators(std::unique_ptr<MoveGenerator>& move_generator,
8383
e_agent_space::MOVE_TYPE,
8484
placer_opts.place_agent_epsilon);
8585
karmed_bandit_agent2->set_step(placer_opts.place_agent_gamma, move_lim);
86-
move_generator2 = std::make_unique<SimpleRLMoveGenerator>(karmed_bandit_agent2, 0.0f);
86+
move_generator2 = std::make_unique<SimpleRLMoveGenerator>(karmed_bandit_agent2, noc_attraction_weight);
8787
} else {
8888
std::unique_ptr<SoftmaxAgent> karmed_bandit_agent1, karmed_bandit_agent2;
8989
//agent's 1st state
@@ -102,7 +102,7 @@ void create_move_generators(std::unique_ptr<MoveGenerator>& move_generator,
102102
karmed_bandit_agent2 = std::make_unique<SoftmaxAgent>(second_state_avail_moves,
103103
e_agent_space::MOVE_TYPE);
104104
karmed_bandit_agent2->set_step(placer_opts.place_agent_gamma, move_lim);
105-
move_generator2 = std::make_unique<SimpleRLMoveGenerator>(karmed_bandit_agent2,0.0f);
105+
move_generator2 = std::make_unique<SimpleRLMoveGenerator>(karmed_bandit_agent2, noc_attraction_weight);
106106
}
107107
}
108108
}

vpr/src/place/move_generator.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ class MoveGenerator {
4747
/**
4848
* @brief Updates affected_blocks with the proposed move, while respecting the current rlim
4949
*
50-
* This function proposes a new move and updates blocks affected and move_type accorrdingly. The function interface is general
50+
* This function proposes a new move and updates blocks affected and move_type accordingly. The function interface is general
5151
* to match the parameters needed by all move generators
5252
*
53-
* @param blocks_affectedt: the output of the move
53+
* @param blocks_affected: the output of the move
5454
* @param proposed_action: Contains the move type and block type. If the block type is specified,
5555
* the proposed move swaps instances of the given block type. Otherwise, the selected block type
5656
* by the move generator is written to proposed_action.logical_blk_type_index.

vpr/src/place/move_utils.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1003,14 +1003,15 @@ bool find_to_loc_centroid(t_logical_block_type_ptr blk_type,
10031003
}
10041004

10051005
//Array of move type strings
1006-
static const std::array<std::string, NUM_PL_MOVE_TYPES + 1> move_type_strings = {
1006+
static const std::array<std::string, NUM_PL_MOVE_TYPES + 2> move_type_strings = {
10071007
"Uniform",
10081008
"Median",
10091009
"Centroid",
10101010
"W. Centroid",
10111011
"W. Median",
10121012
"Crit. Uniform",
10131013
"Feasible Region",
1014+
"NoC Centroid",
10141015
"Manual Move"};
10151016

10161017
//To convert enum move type to string

vpr/src/place/place.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -938,9 +938,9 @@ void try_place(const Netlist<>& net_list,
938938

939939
//allocate move type statistics vectors
940940
MoveTypeStat move_type_stat;
941-
move_type_stat.blk_type_moves.resize(device_ctx.logical_block_types.size() * placer_opts.place_static_move_prob.size(), 0);
942-
move_type_stat.accepted_moves.resize(device_ctx.logical_block_types.size() * placer_opts.place_static_move_prob.size(), 0);
943-
move_type_stat.rejected_moves.resize(device_ctx.logical_block_types.size() * placer_opts.place_static_move_prob.size(), 0);
941+
move_type_stat.blk_type_moves.resize(device_ctx.logical_block_types.size() * (int)e_move_type::NUMBER_OF_AUTO_MOVES, 0);
942+
move_type_stat.accepted_moves.resize(device_ctx.logical_block_types.size() * (int)e_move_type::NUMBER_OF_AUTO_MOVES, 0);
943+
move_type_stat.rejected_moves.resize(device_ctx.logical_block_types.size() * (int)e_move_type::NUMBER_OF_AUTO_MOVES, 0);
944944

945945
/* Get the first range limiter */
946946
first_rlim = (float)max(device_ctx.grid.width() - 1,
@@ -1067,7 +1067,7 @@ void try_place(const Netlist<>& net_list,
10671067
//#endif
10681068
} while (state.outer_loop_update(stats.success_rate, costs, placer_opts,
10691069
annealing_sched));
1070-
/* Outer loop of the simmulated annealing ends */
1070+
/* Outer loop of the simulated annealing ends */
10711071
} //skip_anneal ends
10721072

10731073
/* Start Quench */
@@ -1085,7 +1085,7 @@ void try_place(const Netlist<>& net_list,
10851085
placer_setup_slacks.get(), pin_timing_invalidator.get(),
10861086
timing_info.get());
10871087

1088-
//move the appropoiate move_generator to be the current used move generator
1088+
//move the appropriate move_generator to be the current used move generator
10891089
assign_current_move_generator(move_generator, move_generator2,
10901090
agent_state, placer_opts, true, current_move_generator);
10911091

@@ -1726,7 +1726,7 @@ static e_move_result try_swap(const t_annealing_state* state,
17261726
}
17271727

17281728
if (proposed_action.logical_blk_type_index != -1) { //if the agent proposed the block type, then collect the block type stat
1729-
++move_type_stat.blk_type_moves[(proposed_action.logical_blk_type_index * (placer_opts.place_static_move_prob.size())) + (int)proposed_action.move_type];
1729+
++move_type_stat.blk_type_moves[(proposed_action.logical_blk_type_index * (int)e_move_type::NUMBER_OF_AUTO_MOVES) + (int)proposed_action.move_type];
17301730
}
17311731
LOG_MOVE_STATS_PROPOSED(t, blocks_affected);
17321732

@@ -1877,7 +1877,7 @@ static e_move_result try_swap(const t_annealing_state* state,
18771877
commit_move_blocks(blocks_affected);
18781878

18791879
if (proposed_action.logical_blk_type_index != -1) { //if the agent proposed the block type, then collect the block type stat
1880-
++move_type_stat.accepted_moves[(proposed_action.logical_blk_type_index * (placer_opts.place_static_move_prob.size())) + (int)proposed_action.move_type];
1880+
++move_type_stat.accepted_moves[(proposed_action.logical_blk_type_index * (int)e_move_type::NUMBER_OF_AUTO_MOVES) + (int)proposed_action.move_type];
18811881
}
18821882
if (noc_opts.noc) {
18831883
commit_noc_costs();
@@ -1928,7 +1928,7 @@ static e_move_result try_swap(const t_annealing_state* state,
19281928
}
19291929

19301930
if (proposed_action.logical_blk_type_index != -1) { //if the agent proposed the block type, then collect the block type stat
1931-
++move_type_stat.rejected_moves[(proposed_action.logical_blk_type_index * (placer_opts.place_static_move_prob.size())) + (int)proposed_action.move_type];
1931+
++move_type_stat.rejected_moves[(proposed_action.logical_blk_type_index * (int)e_move_type::NUMBER_OF_AUTO_MOVES) + (int)proposed_action.move_type];
19321932
}
19331933
/* Revert the traffic flow routes within the NoC*/
19341934
if (noc_opts.noc) {

0 commit comments

Comments
 (0)