Skip to content

Commit 12093d6

Browse files
move print_placement_move_types_stats() to move_generator.cpp
1 parent c710d8e commit 12093d6

File tree

3 files changed

+57
-55
lines changed

3 files changed

+57
-55
lines changed

vpr/src/place/move_generator.cpp

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,55 @@ void MoveGenerator::calculate_reward_and_process_outcome(const MoveOutcomeStats&
3131
VPR_ERROR(VPR_ERROR_PLACE, "Undefined reward function!\n");
3232
}
3333
}
34+
35+
void MoveTypeStat::print_placement_move_types_stats() {
36+
VTR_LOG("\n\nPlacement perturbation distribution by block and move type: \n");
37+
38+
VTR_LOG(
39+
"------------------ ----------------- ---------------- ---------------- --------------- ------------ \n");
40+
VTR_LOG(
41+
" Block Type Move Type (%%) of Total Accepted(%%) Rejected(%%) Aborted(%%)\n");
42+
VTR_LOG(
43+
"------------------ ----------------- ---------------- ---------------- --------------- ------------ \n");
44+
45+
int total_moves = 0;
46+
for (size_t i = 0; i < blk_type_moves.size(); ++i) {
47+
total_moves += blk_type_moves.get(i);
48+
}
49+
50+
auto& device_ctx = g_vpr_ctx.device();
51+
int count = 0;
52+
int num_of_avail_moves = blk_type_moves.size() / device_ctx.logical_block_types.size();
53+
54+
//Print placement information for each block type
55+
for (const auto& itype : device_ctx.logical_block_types) {
56+
//Skip non-existing block types in the netlist
57+
if (itype.index == 0 || movable_blocks_per_type(itype).empty()) {
58+
continue;
59+
}
60+
61+
count = 0;
62+
for (int imove = 0; imove < num_of_avail_moves; imove++) {
63+
const auto& move_name = move_type_to_string(e_move_type(imove));
64+
int moves = blk_type_moves[itype.index][imove];
65+
if (moves != 0) {
66+
int accepted = accepted_moves[itype.index][imove];
67+
int rejected = rejected_moves[itype.index][imove];
68+
int aborted = moves - (accepted + rejected);
69+
if (count == 0) {
70+
VTR_LOG("%-18.20s", itype.name);
71+
} else {
72+
VTR_LOG(" ");
73+
}
74+
VTR_LOG(
75+
" %-22.20s %-16.2f %-15.2f %-14.2f %-13.2f\n",
76+
move_name.c_str(), 100.0f * (float)moves / (float)total_moves,
77+
100.0f * (float)accepted / (float)moves, 100.0f * (float)rejected / (float)moves,
78+
100.0f * (float)aborted / (float)moves);
79+
}
80+
count++;
81+
}
82+
VTR_LOG("\n");
83+
}
84+
VTR_LOG("\n");
85+
}

vpr/src/place/move_generator.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ struct MoveTypeStat {
3434
vtr::NdMatrix<int, 2> blk_type_moves;
3535
vtr::NdMatrix<int, 2> accepted_moves;
3636
vtr::NdMatrix<int, 2> rejected_moves;
37+
38+
void print_placement_move_types_stats();
3739
};
3840

3941
/**
@@ -49,6 +51,8 @@ class MoveGenerator {
4951
, reward_func_(reward_function) {}
5052

5153
MoveGenerator() = delete;
54+
MoveGenerator(const MoveGenerator&) = delete;
55+
MoveGenerator& operator=(const MoveGenerator&) = delete;
5256
virtual ~MoveGenerator() = default;
5357

5458
/**

vpr/src/place/place.cpp

Lines changed: 1 addition & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,6 @@ static void print_resources_utilization(const BlkLocRegistry& blk_loc_registry);
332332

333333
static void print_placement_swaps_stats(const t_annealing_state& state, const t_swap_stats& swap_stats);
334334

335-
static void print_placement_move_types_stats(const MoveTypeStat& move_type_stat);
336-
337335
/**
338336
* @brief Copies the placement location variables into the global placement context.
339337
* @param blk_loc_registry The placement location variables to be copied.
@@ -953,7 +951,7 @@ void try_place(const Netlist<>& net_list,
953951

954952
print_placement_swaps_stats(state, swap_stats);
955953

956-
print_placement_move_types_stats(move_type_stat);
954+
move_type_stat.print_placement_move_types_stats();
957955

958956
if (noc_opts.noc) {
959957
write_noc_placement_file(noc_opts.noc_placement_file_name, blk_loc_registry.block_locs());
@@ -2271,58 +2269,6 @@ static void print_placement_swaps_stats(const t_annealing_state& state, const t_
22712269
swap_stats.num_swap_aborted, 100 * abort_rate);
22722270
}
22732271

2274-
static void print_placement_move_types_stats(const MoveTypeStat& move_type_stat) {
2275-
VTR_LOG("\n\nPlacement perturbation distribution by block and move type: \n");
2276-
2277-
VTR_LOG(
2278-
"------------------ ----------------- ---------------- ---------------- --------------- ------------ \n");
2279-
VTR_LOG(
2280-
" Block Type Move Type (%%) of Total Accepted(%%) Rejected(%%) Aborted(%%)\n");
2281-
VTR_LOG(
2282-
"------------------ ----------------- ---------------- ---------------- --------------- ------------ \n");
2283-
2284-
int total_moves = 0;
2285-
for (size_t i = 0; i < move_type_stat.blk_type_moves.size(); ++i) {
2286-
total_moves += move_type_stat.blk_type_moves.get(i);
2287-
}
2288-
2289-
auto& device_ctx = g_vpr_ctx.device();
2290-
int count = 0;
2291-
int num_of_avail_moves = move_type_stat.blk_type_moves.size() / device_ctx.logical_block_types.size();
2292-
2293-
//Print placement information for each block type
2294-
for (const auto& itype : device_ctx.logical_block_types) {
2295-
//Skip non-existing block types in the netlist
2296-
if (itype.index == 0 || movable_blocks_per_type(itype).empty()) {
2297-
continue;
2298-
}
2299-
2300-
count = 0;
2301-
for (int imove = 0; imove < num_of_avail_moves; imove++) {
2302-
const auto& move_name = move_type_to_string(e_move_type(imove));
2303-
int moves = move_type_stat.blk_type_moves[itype.index][imove];
2304-
if (moves != 0) {
2305-
int accepted = move_type_stat.accepted_moves[itype.index][imove];
2306-
int rejected = move_type_stat.rejected_moves[itype.index][imove];
2307-
int aborted = moves - (accepted + rejected);
2308-
if (count == 0) {
2309-
VTR_LOG("%-18.20s", itype.name);
2310-
} else {
2311-
VTR_LOG(" ");
2312-
}
2313-
VTR_LOG(
2314-
" %-22.20s %-16.2f %-15.2f %-14.2f %-13.2f\n",
2315-
move_name.c_str(), 100.0f * (float)moves / (float)total_moves,
2316-
100.0f * (float)accepted / (float)moves, 100.0f * (float)rejected / (float)moves,
2317-
100.0f * (float)aborted / (float)moves);
2318-
}
2319-
count++;
2320-
}
2321-
VTR_LOG("\n");
2322-
}
2323-
VTR_LOG("\n");
2324-
}
2325-
23262272
static void copy_locs_to_global_state(const BlkLocRegistry& blk_loc_registry) {
23272273
auto& place_ctx = g_vpr_ctx.mutable_placement();
23282274

0 commit comments

Comments
 (0)