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 (" \t Average atom displacement of initial placement from flat placement: %f\n " ,
313319 total_disp / static_cast <float >(num_atoms));
320+ VTR_LOG (" \t Max atom displacement of initial placement from flat placement: %f\n " ,
321+ max_disp);
314322 VTR_LOG (" \t Percent 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