Skip to content

Commit e21e132

Browse files
enum class e_move_result
1 parent 884f616 commit e21e132

File tree

7 files changed

+40
-26
lines changed

7 files changed

+40
-26
lines changed

vpr/src/draw/manual_moves.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,16 +254,16 @@ void manual_move_cost_summary_dialog() {
254254
switch (result) {
255255
//If the user accepts the manual move
256256
case GTK_RESPONSE_ACCEPT:
257-
draw_state->manual_moves_state.manual_move_info.user_move_outcome = ACCEPTED;
257+
draw_state->manual_moves_state.manual_move_info.user_move_outcome = e_move_result::ACCEPTED;
258258
application.update_message(msg);
259259
break;
260260
//If the user rejects the manual move
261261
case GTK_RESPONSE_REJECT:
262-
draw_state->manual_moves_state.manual_move_info.user_move_outcome = REJECTED;
262+
draw_state->manual_moves_state.manual_move_info.user_move_outcome = e_move_result::REJECTED;
263263
application.update_message("Manual move was rejected");
264264
break;
265265
default:
266-
draw_state->manual_moves_state.manual_move_info.user_move_outcome = ABORTED;
266+
draw_state->manual_moves_state.manual_move_info.user_move_outcome = e_move_result::ABORTED;
267267
break;
268268
}
269269

vpr/src/draw/manual_moves.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ struct ManualMovesInfo {
5656
double delta_bounding_box = 0;
5757
bool valid_input = true;
5858
t_pl_loc to_location;
59-
e_move_result placer_move_outcome = ABORTED;
60-
e_move_result user_move_outcome = ABORTED;
59+
e_move_result placer_move_outcome = e_move_result::ABORTED;
60+
e_move_result user_move_outcome = e_move_result::ABORTED;
6161
};
6262

6363
/**

vpr/src/place/annealer.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -339,12 +339,12 @@ float PlacementAnnealer::estimate_starting_temperature() {
339339
e_move_result swap_result = try_swap(move_generator_1_, placer_opts_.place_algorithm,
340340
REWARD_BB_TIMING_RELATIVE_WEIGHT, manual_move_enabled);
341341

342-
if (swap_result == ACCEPTED) {
342+
if (swap_result == e_move_result::ACCEPTED) {
343343
num_accepted++;
344344
av += costs_.cost;
345345
sum_of_squares += costs_.cost * costs_.cost;
346346
swap_stats_.num_swap_accepted++;
347-
} else if (swap_result == ABORTED) {
347+
} else if (swap_result == e_move_result::ABORTED) {
348348
swap_stats_.num_swap_aborted++;
349349
} else {
350350
swap_stats_.num_swap_rejected++;
@@ -455,7 +455,7 @@ e_move_result PlacementAnnealer::try_swap(MoveGenerator& move_generator,
455455
"illegal move");
456456
}
457457

458-
move_outcome = ABORTED;
458+
move_outcome = e_move_result::ABORTED;
459459

460460
} else {
461461
VTR_ASSERT(create_move_outcome == e_create_move::VALID);
@@ -553,7 +553,7 @@ e_move_result PlacementAnnealer::try_swap(MoveGenerator& move_generator,
553553
}
554554
#endif //NO_GRAPHICS
555555

556-
if (move_outcome == ACCEPTED) {
556+
if (move_outcome == e_move_result::ACCEPTED) {
557557
costs_.cost += delta_c;
558558
costs_.bb_cost += bb_delta_c;
559559

@@ -601,7 +601,7 @@ e_move_result PlacementAnnealer::try_swap(MoveGenerator& move_generator,
601601
#endif //NO_GRAPHICS
602602

603603
} else {
604-
VTR_ASSERT_SAFE(move_outcome == REJECTED);
604+
VTR_ASSERT_SAFE(move_outcome == e_move_result::REJECTED);
605605

606606
// Reset the net cost function flags first.
607607
net_cost_handler_.reset_move_nets();
@@ -652,7 +652,7 @@ e_move_result PlacementAnnealer::try_swap(MoveGenerator& move_generator,
652652
move_outcome_stats.delta_timing_cost_abs = timing_delta_c;
653653

654654
if constexpr (VTR_ENABLE_DEBUG_LOGGING_CONST_EXPR) {
655-
LOG_MOVE_STATS_OUTCOME(delta_c, bb_delta_c, timing_delta_c, (move_outcome ? "ACCEPTED" : "REJECTED"), "");
655+
LOG_MOVE_STATS_OUTCOME(delta_c, bb_delta_c, timing_delta_c, (move_outcome == e_move_result::ACCEPTED ? "ACCEPTED" : "REJECTED"), "");
656656
}
657657
}
658658
move_outcome_stats.outcome = move_outcome;
@@ -721,11 +721,11 @@ void PlacementAnnealer::placement_inner_loop(MoveGenerator& move_generator,
721721
e_move_result swap_result = try_swap(move_generator, placer_opts_.place_algorithm,
722722
timing_bb_factor, manual_move_enabled);
723723

724-
if (swap_result == ACCEPTED) {
724+
if (swap_result == e_move_result::ACCEPTED) {
725725
// Move was accepted. Update statistics that are useful for the annealing schedule.
726726
placer_stats_.single_swap_update(costs_);
727727
swap_stats_.num_swap_accepted++;
728-
} else if (swap_result == ABORTED) {
728+
} else if (swap_result == e_move_result::ABORTED) {
729729
swap_stats_.num_swap_aborted++;
730730
} else { // swap_result == REJECTED
731731
swap_stats_.num_swap_rejected++;
@@ -879,20 +879,20 @@ e_move_result PlacementAnnealer::assess_swap_(double delta_c, double t) {
879879
VTR_LOGV_DEBUG(g_vpr_ctx.placement().f_placer_debug, "\tTemperature is: %e delta_c is %e\n", t, delta_c);
880880
if (delta_c <= 0) {
881881
VTR_LOGV_DEBUG(g_vpr_ctx.placement().f_placer_debug, "\t\tMove is accepted(delta_c < 0)\n");
882-
return ACCEPTED;
882+
return e_move_result::ACCEPTED;
883883
}
884884

885885
if (t == 0.) {
886886
VTR_LOGV_DEBUG(g_vpr_ctx.placement().f_placer_debug, "\t\tMove is rejected(t == 0)\n");
887-
return REJECTED;
887+
return e_move_result::REJECTED;
888888
}
889889

890890
float fnum = rng_.frand();
891891
float prob_fac = std::exp(-delta_c / t);
892892
if (prob_fac > fnum) {
893893
VTR_LOGV_DEBUG(g_vpr_ctx.placement().f_placer_debug, "\t\tMove is accepted(hill climbing)\n");
894-
return ACCEPTED;
894+
return e_move_result::ACCEPTED;
895895
}
896896
VTR_LOGV_DEBUG(g_vpr_ctx.placement().f_placer_debug, "\t\tMove is rejected(hill climbing)\n");
897-
return REJECTED;
897+
return e_move_result::REJECTED;
898898
}

vpr/src/place/move_generator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ struct MoveOutcomeStats {
1717
float delta_bb_cost_abs = std::numeric_limits<float>::quiet_NaN();
1818
float delta_timing_cost_abs = std::numeric_limits<float>::quiet_NaN();
1919

20-
e_move_result outcome = ABORTED;
20+
e_move_result outcome = e_move_result::ABORTED;
2121
float elapsed_time = std::numeric_limits<float>::quiet_NaN();
2222
};
2323

vpr/src/place/move_utils.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,8 +1265,23 @@ bool intersect_range_limit_with_floorplan_constraints(ClusterBlockId b_from,
12651265
}
12661266

12671267
std::string e_move_result_to_string(e_move_result move_outcome) {
1268-
std::string move_result_to_string[] = {"Rejected", "Accepted", "Aborted"};
1269-
return move_result_to_string[move_outcome];
1268+
switch (move_outcome) {
1269+
case e_move_result::REJECTED:
1270+
return "Rejected";
1271+
break;
1272+
1273+
case e_move_result::ACCEPTED:
1274+
return "Accepted";
1275+
break;
1276+
1277+
case e_move_result::ABORTED:
1278+
return "Aborted";
1279+
break;
1280+
1281+
default:
1282+
return "Unsupported Move Outcome!";
1283+
break;
1284+
}
12701285
}
12711286

12721287
int find_free_layer(t_logical_block_type_ptr logical_block,

vpr/src/place/move_utils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ constexpr size_t SMALL_NET = 4;
1919
/* This is for the placement swap routines. A swap attempt could be *
2020
* rejected, accepted or aborted (due to the limitations placed on the *
2121
* carry chain support at this point). */
22-
enum e_move_result {
22+
enum class e_move_result {
2323
REJECTED,
2424
ACCEPTED,
2525
ABORTED

vpr/src/place/placer_breakpoint.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@ void transform_blocks_affected(const t_pl_blocks_to_be_moved& blocksAffected) {
1111
BreakpointState* bp_state = get_bp_state_globals()->get_glob_breakpoint_state();
1212

1313
bp_state->blocks_affected_by_move.clear();
14-
for (size_t i = 0; i < blocksAffected.moved_blocks.size(); i++) {
14+
for (const t_pl_moved_block& moved_block : blocksAffected.moved_blocks) {
1515
//size_t conversion is required since block_num is of type ClusterBlockId and can't be cast to an int. And this vector has to be of type int to be recognized in expr_eval class
16-
17-
bp_state->blocks_affected_by_move.push_back(size_t(blocksAffected.moved_blocks[i].block_num));
16+
bp_state->blocks_affected_by_move.push_back(size_t(moved_block.block_num));
1817
}
1918
}
2019

@@ -40,9 +39,9 @@ void stop_placement_and_check_breakpoints(t_pl_blocks_to_be_moved& blocks_affect
4039

4140
if (placer_breakpoint_reached() && draw_state->show_graphics) {
4241
std::string msg = available_move_types[0];
43-
if (move_outcome == 0) {
42+
if (move_outcome == e_move_result::REJECTED) {
4443
msg += vtr::string_fmt(", Rejected");
45-
} else if (move_outcome == 1) {
44+
} else if (move_outcome == e_move_result::ACCEPTED) {
4645
msg += vtr::string_fmt(", Accepted");
4746
} else {
4847
msg += vtr::string_fmt(", Aborted");

0 commit comments

Comments
 (0)