8
8
9
9
#include " load_flat_place.h"
10
10
11
+ #include < algorithm>
11
12
#include < fstream>
12
13
#include < unordered_set>
13
14
#include " atom_lookup.h"
@@ -254,7 +255,8 @@ void log_flat_placement_reconstruction_info(
254
255
// Go through each atom and compute how much it has displaced and count
255
256
// how many have been displaced beyond some threshold.
256
257
constexpr float disp_threashold = 0 .5f ;
257
- float total_disp = 0 ;
258
+ float total_disp = 0 .f ;
259
+ float max_disp = 0 .f ;
258
260
unsigned num_atoms_missplaced = 0 ;
259
261
for (AtomBlockId atom_blk_id : atom_netlist.blocks ()) {
260
262
// TODO: Currently only handle the case when all of the position
@@ -279,7 +281,11 @@ void log_flat_placement_reconstruction_info(
279
281
float dx = blk_x - clb_loc.loc .x ;
280
282
float dy = blk_y - clb_loc.loc .y ;
281
283
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);
283
289
284
290
// Accumulate into the total displacement.
285
291
total_disp += dist;
@@ -311,6 +317,8 @@ void log_flat_placement_reconstruction_info(
311
317
total_disp);
312
318
VTR_LOG (" \t Average atom displacement of initial placement from flat placement: %f\n " ,
313
319
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);
314
322
VTR_LOG (" \t Percent of atoms misplaced from the flat placement: %f\n " ,
315
323
static_cast <float >(num_atoms_missplaced) / static_cast <float >(num_atoms));
316
324
}
0 commit comments