@@ -1112,12 +1112,8 @@ e_block_pack_status try_pack_molecule(t_cluster_placement_stats* cluster_placeme
1112
1112
for (int i = 0 ; i < molecule_size; i++) {
1113
1113
if (molecule->atom_block_ids [i]) {
1114
1114
/* invalidate all molecules that share atom block with current molecule */
1115
-
1116
- auto mol_rng = atom_ctx.prepacker .get_atom_molecules (molecule->atom_block_ids [i]);
1117
- for (const auto & kv : mol_rng) {
1118
- t_pack_molecule* cur_molecule = kv.second ;
1119
- cur_molecule->valid = false ;
1120
- }
1115
+ t_pack_molecule* cur_molecule = atom_ctx.prepacker .get_atom_molecule (molecule->atom_block_ids [i]);
1116
+ cur_molecule->valid = false ;
1121
1117
1122
1118
commit_primitive (cluster_placement_stats_ptr, primitives_list[i]);
1123
1119
}
@@ -2317,15 +2313,12 @@ void add_cluster_molecule_candidates_by_connectivity_and_timing(t_pb* cur_pb,
2317
2313
2318
2314
for (AtomBlockId blk_id : cur_pb->pb_stats ->marked_blocks ) {
2319
2315
if (atom_ctx.lookup .atom_clb (blk_id) == ClusterBlockId::INVALID ()) {
2320
- auto mol_rng = atom_ctx.prepacker .get_atom_molecules (blk_id);
2321
- for (const auto & kv : mol_rng) {
2322
- t_pack_molecule* molecule = kv.second ;
2323
- if (molecule->valid ) {
2324
- bool success = check_free_primitives_for_molecule_atoms (molecule, cluster_placement_stats_ptr);
2325
- if (success) {
2326
- add_molecule_to_pb_stats_candidates (molecule,
2327
- cur_pb->pb_stats ->gain , cur_pb, feasible_block_array_size, attraction_groups);
2328
- }
2316
+ t_pack_molecule* molecule = atom_ctx.prepacker .get_atom_molecule (blk_id);
2317
+ if (molecule->valid ) {
2318
+ bool success = check_free_primitives_for_molecule_atoms (molecule, cluster_placement_stats_ptr);
2319
+ if (success) {
2320
+ add_molecule_to_pb_stats_candidates (molecule,
2321
+ cur_pb->pb_stats ->gain , cur_pb, feasible_block_array_size, attraction_groups);
2329
2322
}
2330
2323
}
2331
2324
}
@@ -2355,16 +2348,13 @@ void add_cluster_molecule_candidates_by_highfanout_connectivity(t_pb* cur_pb,
2355
2348
AtomBlockId blk_id = atom_ctx.nlist .pin_block (pin_id);
2356
2349
2357
2350
if (atom_ctx.lookup .atom_clb (blk_id) == ClusterBlockId::INVALID ()) {
2358
- auto mol_rng = atom_ctx.prepacker .get_atom_molecules (blk_id);
2359
- for (const auto & kv : mol_rng) {
2360
- t_pack_molecule* molecule = kv.second ;
2361
- if (molecule->valid ) {
2362
- bool success = check_free_primitives_for_molecule_atoms (molecule, cluster_placement_stats_ptr);
2363
- if (success) {
2364
- add_molecule_to_pb_stats_candidates (molecule,
2365
- cur_pb->pb_stats ->gain , cur_pb, std::min (feasible_block_array_size, AAPACK_MAX_HIGH_FANOUT_EXPLORE), attraction_groups);
2366
- count++;
2367
- }
2351
+ t_pack_molecule* molecule = atom_ctx.prepacker .get_atom_molecule (blk_id);
2352
+ if (molecule->valid ) {
2353
+ bool success = check_free_primitives_for_molecule_atoms (molecule, cluster_placement_stats_ptr);
2354
+ if (success) {
2355
+ add_molecule_to_pb_stats_candidates (molecule,
2356
+ cur_pb->pb_stats ->gain , cur_pb, std::min (feasible_block_array_size, AAPACK_MAX_HIGH_FANOUT_EXPLORE), attraction_groups);
2357
+ count++;
2368
2358
}
2369
2359
}
2370
2360
}
@@ -2444,15 +2434,12 @@ void add_cluster_molecule_candidates_by_attraction_group(t_pb* cur_pb,
2444
2434
// Only consider molecules that are unpacked and of the correct type
2445
2435
if (atom_ctx.lookup .atom_clb (atom_id) == ClusterBlockId::INVALID ()
2446
2436
&& std::find (candidate_types.begin (), candidate_types.end (), cluster_type) != candidate_types.end ()) {
2447
- auto mol_rng = atom_ctx.prepacker .get_atom_molecules (atom_id);
2448
- for (const auto & kv : mol_rng) {
2449
- t_pack_molecule* molecule = kv.second ;
2450
- if (molecule->valid ) {
2451
- bool success = check_free_primitives_for_molecule_atoms (molecule, cluster_placement_stats_ptr);
2452
- if (success) {
2453
- add_molecule_to_pb_stats_candidates (molecule,
2454
- cur_pb->pb_stats ->gain , cur_pb, feasible_block_array_size, attraction_groups);
2455
- }
2437
+ t_pack_molecule* molecule = atom_ctx.prepacker .get_atom_molecule (atom_id);
2438
+ if (molecule->valid ) {
2439
+ bool success = check_free_primitives_for_molecule_atoms (molecule, cluster_placement_stats_ptr);
2440
+ if (success) {
2441
+ add_molecule_to_pb_stats_candidates (molecule,
2442
+ cur_pb->pb_stats ->gain , cur_pb, feasible_block_array_size, attraction_groups);
2456
2443
}
2457
2444
}
2458
2445
}
@@ -2479,15 +2466,12 @@ void add_cluster_molecule_candidates_by_attraction_group(t_pb* cur_pb,
2479
2466
// Only consider molecules that are unpacked and of the correct type
2480
2467
if (atom_ctx.lookup .atom_clb (blk_id) == ClusterBlockId::INVALID ()
2481
2468
&& std::find (candidate_types.begin (), candidate_types.end (), cluster_type) != candidate_types.end ()) {
2482
- auto mol_rng = atom_ctx.prepacker .get_atom_molecules (blk_id);
2483
- for (const auto & kv : mol_rng) {
2484
- t_pack_molecule* molecule = kv.second ;
2485
- if (molecule->valid ) {
2486
- bool success = check_free_primitives_for_molecule_atoms (molecule, cluster_placement_stats_ptr);
2487
- if (success) {
2488
- add_molecule_to_pb_stats_candidates (molecule,
2489
- cur_pb->pb_stats ->gain , cur_pb, feasible_block_array_size, attraction_groups);
2490
- }
2469
+ t_pack_molecule* molecule = atom_ctx.prepacker .get_atom_molecule (blk_id);
2470
+ if (molecule->valid ) {
2471
+ bool success = check_free_primitives_for_molecule_atoms (molecule, cluster_placement_stats_ptr);
2472
+ if (success) {
2473
+ add_molecule_to_pb_stats_candidates (molecule,
2474
+ cur_pb->pb_stats ->gain , cur_pb, feasible_block_array_size, attraction_groups);
2491
2475
}
2492
2476
}
2493
2477
}
@@ -2686,18 +2670,9 @@ std::vector<AtomBlockId> initialize_seed_atoms(const e_cluster_seed seed_type,
2686
2670
} else if (seed_type == e_cluster_seed::MAX_INPUTS) {
2687
2671
// By number of used molecule input pins
2688
2672
for (auto blk : atom_ctx.nlist .blocks ()) {
2689
- int max_molecule_inputs = 0 ;
2690
- auto mol_rng = atom_ctx.prepacker .get_atom_molecules (blk);
2691
- for (const auto & kv : mol_rng) {
2692
- const t_pack_molecule* blk_mol = kv.second ;
2693
-
2694
- const t_molecule_stats molecule_stats = calc_molecule_stats (blk_mol, atom_ctx.nlist );
2695
-
2696
- // Keep the max over all molecules associated with the atom
2697
- max_molecule_inputs = std::max (max_molecule_inputs, molecule_stats.num_used_ext_inputs );
2698
- }
2699
-
2700
- atom_gains[blk] = max_molecule_inputs;
2673
+ const t_pack_molecule* blk_mol = atom_ctx.prepacker .get_atom_molecule (blk);
2674
+ const t_molecule_stats molecule_stats = calc_molecule_stats (blk_mol, atom_ctx.nlist );
2675
+ atom_gains[blk] = molecule_stats.num_used_ext_inputs ;
2701
2676
}
2702
2677
2703
2678
} else if (seed_type == e_cluster_seed::BLEND) {
@@ -2706,96 +2681,72 @@ std::vector<AtomBlockId> initialize_seed_atoms(const e_cluster_seed seed_type,
2706
2681
/* Score seed gain of each block as a weighted sum of timing criticality,
2707
2682
* number of tightly coupled blocks connected to it, and number of external inputs */
2708
2683
float seed_blend_fac = 0.5 ;
2709
- float max_blend_gain = 0 ;
2710
-
2711
- auto mol_rng = atom_ctx.prepacker .get_atom_molecules (blk);
2712
- for (const auto & kv : mol_rng) {
2713
- const t_pack_molecule* blk_mol = kv.second ;
2714
-
2715
- const t_molecule_stats molecule_stats = calc_molecule_stats (blk_mol, atom_ctx.nlist );
2716
-
2717
- VTR_ASSERT (max_molecule_stats.num_used_ext_inputs > 0 );
2718
2684
2719
- float blend_gain = (seed_blend_fac * atom_criticality[ blk]
2720
- + ( 1 - seed_blend_fac) * (molecule_stats. num_used_ext_inputs / max_molecule_stats. num_used_ext_inputs ) );
2721
- blend_gain *= ( 1 + 0.2 * (molecule_stats. num_blocks - 1 ) );
2685
+ const t_pack_molecule* blk_mol = atom_ctx. prepacker . get_atom_molecule ( blk);
2686
+ const t_molecule_stats molecule_stats = calc_molecule_stats (blk_mol, atom_ctx. nlist );
2687
+ VTR_ASSERT (max_molecule_stats. num_used_ext_inputs > 0 );
2722
2688
2723
- // Keep the max over all molecules associated with the atom
2724
- max_blend_gain = std::max (max_blend_gain, blend_gain );
2725
- }
2726
- atom_gains[blk] = max_blend_gain ;
2689
+ float blend_gain = (seed_blend_fac * atom_criticality[blk]
2690
+ + ( 1 - seed_blend_fac) * (molecule_stats. num_used_ext_inputs / max_molecule_stats. num_used_ext_inputs ) );
2691
+ blend_gain *= ( 1 + 0.2 * (molecule_stats. num_blocks - 1 ));
2692
+ atom_gains[blk] = blend_gain ;
2727
2693
}
2728
2694
2729
2695
} else if (seed_type == e_cluster_seed::MAX_PINS || seed_type == e_cluster_seed::MAX_INPUT_PINS) {
2730
2696
// By pins per molecule (i.e. available pins on primitives, not pins in use)
2731
2697
2732
2698
for (auto blk : atom_ctx.nlist .blocks ()) {
2733
- int max_molecule_pins = 0 ;
2734
- auto mol_rng = atom_ctx.prepacker .get_atom_molecules (blk);
2735
- for (const auto & kv : mol_rng) {
2736
- const t_pack_molecule* mol = kv.second ;
2737
-
2738
- const t_molecule_stats molecule_stats = calc_molecule_stats (mol, atom_ctx.nlist );
2739
-
2740
- // Keep the max over all molecules associated with the atom
2741
- int molecule_pins = 0 ;
2742
- if (seed_type == e_cluster_seed::MAX_PINS) {
2743
- // All pins
2744
- molecule_pins = molecule_stats.num_pins ;
2745
- } else {
2746
- VTR_ASSERT (seed_type == e_cluster_seed::MAX_INPUT_PINS);
2747
- // Input pins only
2748
- molecule_pins = molecule_stats.num_input_pins ;
2749
- }
2699
+ const t_pack_molecule* mol = atom_ctx.prepacker .get_atom_molecule (blk);
2700
+ const t_molecule_stats molecule_stats = calc_molecule_stats (mol, atom_ctx.nlist );
2750
2701
2751
- // Keep the max over all molecules associated with the atom
2752
- max_molecule_pins = std::max (max_molecule_pins, molecule_pins);
2702
+ int molecule_pins = 0 ;
2703
+ if (seed_type == e_cluster_seed::MAX_PINS) {
2704
+ // All pins
2705
+ molecule_pins = molecule_stats.num_pins ;
2706
+ } else {
2707
+ VTR_ASSERT (seed_type == e_cluster_seed::MAX_INPUT_PINS);
2708
+ // Input pins only
2709
+ molecule_pins = molecule_stats.num_input_pins ;
2753
2710
}
2754
- atom_gains[blk] = max_molecule_pins;
2711
+
2712
+ atom_gains[blk] = molecule_pins;
2755
2713
}
2756
2714
2757
2715
} else if (seed_type == e_cluster_seed::BLEND2) {
2758
2716
for (auto blk : atom_ctx.nlist .blocks ()) {
2759
- float max_gain = 0 ;
2760
- auto mol_rng = atom_ctx.prepacker .get_atom_molecules (blk);
2761
- for (const auto & kv : mol_rng) {
2762
- const t_pack_molecule* mol = kv.second ;
2717
+ const t_pack_molecule* mol = atom_ctx.prepacker .get_atom_molecule (blk);
2718
+ const t_molecule_stats molecule_stats = calc_molecule_stats (mol, atom_ctx.nlist );
2763
2719
2764
- const t_molecule_stats molecule_stats = calc_molecule_stats (mol, atom_ctx.nlist );
2720
+ float pin_ratio = vtr::safe_ratio<float >(molecule_stats.num_pins , max_molecule_stats.num_pins );
2721
+ float input_pin_ratio = vtr::safe_ratio<float >(molecule_stats.num_input_pins , max_molecule_stats.num_input_pins );
2722
+ float output_pin_ratio = vtr::safe_ratio<float >(molecule_stats.num_output_pins , max_molecule_stats.num_output_pins );
2723
+ float used_ext_pin_ratio = vtr::safe_ratio<float >(molecule_stats.num_used_ext_pins , max_molecule_stats.num_used_ext_pins );
2724
+ float used_ext_input_pin_ratio = vtr::safe_ratio<float >(molecule_stats.num_used_ext_inputs , max_molecule_stats.num_used_ext_inputs );
2725
+ float used_ext_output_pin_ratio = vtr::safe_ratio<float >(molecule_stats.num_used_ext_outputs , max_molecule_stats.num_used_ext_outputs );
2726
+ float num_blocks_ratio = vtr::safe_ratio<float >(molecule_stats.num_blocks , max_molecule_stats.num_blocks );
2727
+ float criticality = atom_criticality[blk];
2765
2728
2766
- float pin_ratio = vtr::safe_ratio< float >(molecule_stats. num_pins , max_molecule_stats. num_pins ) ;
2767
- float input_pin_ratio = vtr::safe_ratio< float >(molecule_stats. num_input_pins , max_molecule_stats. num_input_pins ) ;
2768
- float output_pin_ratio = vtr::safe_ratio< float >(molecule_stats. num_output_pins , max_molecule_stats. num_output_pins ) ;
2769
- float used_ext_pin_ratio = vtr::safe_ratio< float >(molecule_stats. num_used_ext_pins , max_molecule_stats. num_used_ext_pins ) ;
2770
- float used_ext_input_pin_ratio = vtr::safe_ratio< float >(molecule_stats. num_used_ext_inputs , max_molecule_stats. num_used_ext_inputs ) ;
2771
- float used_ext_output_pin_ratio = vtr::safe_ratio< float >(molecule_stats. num_used_ext_outputs , max_molecule_stats. num_used_ext_outputs ) ;
2772
- float num_blocks_ratio = vtr::safe_ratio< float >(molecule_stats. num_blocks , max_molecule_stats. num_blocks ) ;
2773
- float criticality = atom_criticality[blk] ;
2729
+ constexpr float PIN_WEIGHT = 0 . ;
2730
+ constexpr float INPUT_PIN_WEIGHT = 0.5 ;
2731
+ constexpr float OUTPUT_PIN_WEIGHT = 0 . ;
2732
+ constexpr float USED_PIN_WEIGHT = 0 . ;
2733
+ constexpr float USED_INPUT_PIN_WEIGHT = 0.2 ;
2734
+ constexpr float USED_OUTPUT_PIN_WEIGHT = 0 . ;
2735
+ constexpr float BLOCKS_WEIGHT = 0.2 ;
2736
+ constexpr float CRITICALITY_WEIGHT = 0.1 ;
2774
2737
2775
- constexpr float PIN_WEIGHT = 0 .;
2776
- constexpr float INPUT_PIN_WEIGHT = 0.5 ;
2777
- constexpr float OUTPUT_PIN_WEIGHT = 0 .;
2778
- constexpr float USED_PIN_WEIGHT = 0 .;
2779
- constexpr float USED_INPUT_PIN_WEIGHT = 0.2 ;
2780
- constexpr float USED_OUTPUT_PIN_WEIGHT = 0 .;
2781
- constexpr float BLOCKS_WEIGHT = 0.2 ;
2782
- constexpr float CRITICALITY_WEIGHT = 0.1 ;
2738
+ float gain = PIN_WEIGHT * pin_ratio
2739
+ + INPUT_PIN_WEIGHT * input_pin_ratio
2740
+ + OUTPUT_PIN_WEIGHT * output_pin_ratio
2783
2741
2784
- float gain = PIN_WEIGHT * pin_ratio
2785
- + INPUT_PIN_WEIGHT * input_pin_ratio
2786
- + OUTPUT_PIN_WEIGHT * output_pin_ratio
2742
+ + USED_PIN_WEIGHT * used_ext_pin_ratio
2743
+ + USED_INPUT_PIN_WEIGHT * used_ext_input_pin_ratio
2744
+ + USED_OUTPUT_PIN_WEIGHT * used_ext_output_pin_ratio
2787
2745
2788
- + USED_PIN_WEIGHT * used_ext_pin_ratio
2789
- + USED_INPUT_PIN_WEIGHT * used_ext_input_pin_ratio
2790
- + USED_OUTPUT_PIN_WEIGHT * used_ext_output_pin_ratio
2746
+ + BLOCKS_WEIGHT * num_blocks_ratio
2747
+ + CRITICALITY_WEIGHT * criticality;
2791
2748
2792
- + BLOCKS_WEIGHT * num_blocks_ratio
2793
- + CRITICALITY_WEIGHT * criticality;
2794
-
2795
- max_gain = std::max (max_gain, gain);
2796
- }
2797
-
2798
- atom_gains[blk] = max_gain;
2749
+ atom_gains[blk] = gain;
2799
2750
}
2800
2751
2801
2752
} else {
@@ -2832,15 +2783,10 @@ t_pack_molecule* get_highest_gain_seed_molecule(int& seed_index, const std::vect
2832
2783
if (atom_ctx.lookup .atom_clb (blk_id) == ClusterBlockId::INVALID ()) {
2833
2784
t_pack_molecule* best = nullptr ;
2834
2785
2835
- // Iterate over all the molecules associated with the selected atom
2836
- // and select the one with the highest gain
2837
- auto mol_rng = atom_ctx.prepacker .get_atom_molecules (blk_id);
2838
- for (const auto & kv : mol_rng) {
2839
- t_pack_molecule* molecule = kv.second ;
2840
- if (molecule->valid ) {
2841
- if (best == nullptr || (best->base_gain ) < (molecule->base_gain )) {
2842
- best = molecule;
2843
- }
2786
+ t_pack_molecule* molecule = atom_ctx.prepacker .get_atom_molecule (blk_id);
2787
+ if (molecule->valid ) {
2788
+ if (best == nullptr || (best->base_gain ) < (molecule->base_gain )) {
2789
+ best = molecule;
2844
2790
}
2845
2791
}
2846
2792
VTR_ASSERT (best != nullptr );
@@ -3304,12 +3250,9 @@ void load_transitive_fanout_candidates(ClusterBlockId clb_index,
3304
3250
} else {
3305
3251
pb_stats->gain [blk_id] += 0.001 ;
3306
3252
}
3307
- auto mol_rng = atom_ctx.prepacker .get_atom_molecules (blk_id);
3308
- for (const auto & kv : mol_rng) {
3309
- t_pack_molecule* molecule = kv.second ;
3310
- if (molecule->valid ) {
3311
- transitive_fanout_candidates.insert ({molecule->atom_block_ids [molecule->root ], molecule});
3312
- }
3253
+ t_pack_molecule* molecule = atom_ctx.prepacker .get_atom_molecule (blk_id);
3254
+ if (molecule->valid ) {
3255
+ transitive_fanout_candidates.insert ({molecule->atom_block_ids [molecule->root ], molecule});
3313
3256
}
3314
3257
}
3315
3258
}
0 commit comments