Skip to content

Commit

Permalink
Merge pull request #2876 from AlexandreSinger/feature-appack
Browse files Browse the repository at this point in the history
[APPack] Added Max Displacement Metric
  • Loading branch information
vaughnbetz authored Feb 6, 2025
2 parents 3f500fb + e9b04ab commit 1279554
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions vpr/src/base/load_flat_place.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include "load_flat_place.h"

#include <algorithm>
#include <fstream>
#include <unordered_set>
#include "atom_lookup.h"
Expand Down Expand Up @@ -254,7 +255,8 @@ void log_flat_placement_reconstruction_info(
// Go through each atom and compute how much it has displaced and count
// how many have been displaced beyond some threshold.
constexpr float disp_threashold = 0.5f;
float total_disp = 0;
float total_disp = 0.f;
float max_disp = 0.f;
unsigned num_atoms_missplaced = 0;
for (AtomBlockId atom_blk_id : atom_netlist.blocks()) {
// TODO: Currently only handle the case when all of the position
Expand All @@ -279,7 +281,11 @@ void log_flat_placement_reconstruction_info(
float dx = blk_x - clb_loc.loc.x;
float dy = blk_y - clb_loc.loc.y;
float dlayer = blk_layer - clb_loc.loc.layer;
float dist = std::sqrt((dx * dx) + (dy * dy) + (dlayer * dlayer));
// Using the Manhattan distance (L1 norm)
float dist = std::abs(dx) + std::abs(dy) + std::abs(dlayer);

// Collect the max displacement.
max_disp = std::max(max_disp, dist);

// Accumulate into the total displacement.
total_disp += dist;
Expand Down Expand Up @@ -311,6 +317,8 @@ void log_flat_placement_reconstruction_info(
total_disp);
VTR_LOG("\tAverage atom displacement of initial placement from flat placement: %f\n",
total_disp / static_cast<float>(num_atoms));
VTR_LOG("\tMax atom displacement of initial placement from flat placement: %f\n",
max_disp);
VTR_LOG("\tPercent of atoms misplaced from the flat placement: %f\n",
static_cast<float>(num_atoms_missplaced) / static_cast<float>(num_atoms));
}
Expand Down

0 comments on commit 1279554

Please sign in to comment.