Skip to content

Commit 1279554

Browse files
authored
Merge pull request #2876 from AlexandreSinger/feature-appack
[APPack] Added Max Displacement Metric
2 parents 3f500fb + e9b04ab commit 1279554

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

vpr/src/base/load_flat_place.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include "load_flat_place.h"
1010

11+
#include <algorithm>
1112
#include <fstream>
1213
#include <unordered_set>
1314
#include "atom_lookup.h"
@@ -254,7 +255,8 @@ void log_flat_placement_reconstruction_info(
254255
// Go through each atom and compute how much it has displaced and count
255256
// how many have been displaced beyond some threshold.
256257
constexpr float disp_threashold = 0.5f;
257-
float total_disp = 0;
258+
float total_disp = 0.f;
259+
float max_disp = 0.f;
258260
unsigned num_atoms_missplaced = 0;
259261
for (AtomBlockId atom_blk_id : atom_netlist.blocks()) {
260262
// TODO: Currently only handle the case when all of the position
@@ -279,7 +281,11 @@ void log_flat_placement_reconstruction_info(
279281
float dx = blk_x - clb_loc.loc.x;
280282
float dy = blk_y - clb_loc.loc.y;
281283
float dlayer = blk_layer - clb_loc.loc.layer;
282-
float dist = std::sqrt((dx * dx) + (dy * dy) + (dlayer * dlayer));
284+
// Using the Manhattan distance (L1 norm)
285+
float dist = std::abs(dx) + std::abs(dy) + std::abs(dlayer);
286+
287+
// Collect the max displacement.
288+
max_disp = std::max(max_disp, dist);
283289

284290
// Accumulate into the total displacement.
285291
total_disp += dist;
@@ -311,6 +317,8 @@ void log_flat_placement_reconstruction_info(
311317
total_disp);
312318
VTR_LOG("\tAverage atom displacement of initial placement from flat placement: %f\n",
313319
total_disp / static_cast<float>(num_atoms));
320+
VTR_LOG("\tMax atom displacement of initial placement from flat placement: %f\n",
321+
max_disp);
314322
VTR_LOG("\tPercent of atoms misplaced from the flat placement: %f\n",
315323
static_cast<float>(num_atoms_missplaced) / static_cast<float>(num_atoms));
316324
}

0 commit comments

Comments
 (0)