Skip to content

Commit ca4267d

Browse files
Merge branch 'master' into update_nightly_test_results
2 parents f5eb9c7 + ceae587 commit ca4267d

15 files changed

+315
-183
lines changed

.github/workflows/nightly_test_manual.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,37 +63,44 @@ jobs:
6363
# TODO: We could expose more parallelism if we had one task list which ran
6464
# all of these.
6565
- name: 'Run Nightly Test 1'
66+
if: success() || failure()
6667
run: |
6768
source .venv/bin/activate
6869
./run_reg_test.py -j12 vtr_reg_nightly_test1
6970
7071
- name: 'Run Nightly Test 2'
72+
if: success() || failure()
7173
run: |
7274
source .venv/bin/activate
7375
./run_reg_test.py -j12 vtr_reg_nightly_test2
7476
7577
- name: 'Run Nightly Test 3'
78+
if: success() || failure()
7679
run: |
7780
source .venv/bin/activate
7881
./run_reg_test.py -j12 vtr_reg_nightly_test3
7982
8083
8184
- name: 'Run Nightly Test 4'
85+
if: success() || failure()
8286
run: |
8387
source .venv/bin/activate
8488
./run_reg_test.py -j12 vtr_reg_nightly_test4
8589
8690
- name: 'Run Nightly Test 5'
91+
if: success() || failure()
8792
run: |
8893
source .venv/bin/activate
8994
./run_reg_test.py -j12 vtr_reg_nightly_test5
9095
9196
- name: 'Run Nightly Test 6'
97+
if: success() || failure()
9298
run: |
9399
source .venv/bin/activate
94100
./run_reg_test.py -j12 vtr_reg_nightly_test6
95101
96102
- name: 'Run Nightly Test 7'
103+
if: success() || failure()
97104
run: |
98105
source .venv/bin/activate
99106
./run_reg_test.py -j12 vtr_reg_nightly_test7

vpr/src/analytical_place/full_legalizer.cpp

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -128,30 +128,12 @@ class APClusterPlacer {
128128
*/
129129
APClusterPlacer(const PlaceMacros& place_macros)
130130
: place_macros_(place_macros) {
131-
// FIXME: This was stolen from place/place.cpp
132-
// it used a static method, just taking what I think I will need.
131+
// Initialize the block loc registry.
133132
auto& blk_loc_registry = g_vpr_ctx.mutable_placement().mutable_blk_loc_registry();
133+
blk_loc_registry.init();
134134

135-
init_placement_context(blk_loc_registry);
136-
137-
// stolen from place/place.cpp:alloc_and_load_try_swap_structs
138-
// FIXME: set cube_bb to false by hand, should be passed in.
139-
g_vpr_ctx.mutable_placement().cube_bb = false;
140-
g_vpr_ctx.mutable_placement().compressed_block_grids = create_compressed_block_grids();
141-
142-
// TODO: The next few steps will be basically a direct copy of the initial
143-
// placement code since it does everything we need! It would be nice
144-
// to share the code.
145-
146-
// Clear the grid locations (stolen from initial_placement)
147-
blk_loc_registry.clear_all_grid_locs();
148-
149-
// Deal with the placement constraints.
150-
propagate_place_constraints(place_macros_);
151-
135+
// Place the fixed blocks and mark them as fixed.
152136
mark_fixed_blocks(blk_loc_registry);
153-
154-
alloc_and_load_compressed_cluster_constraints();
155137
}
156138

157139
/**
@@ -368,7 +350,6 @@ void NaiveFullLegalizer::create_clusters(const PartialPlacement& p_placement) {
368350
// FIXME: This writing and loading from a file is wasteful. Should generate
369351
// the clusters directly from the cluster legalizer.
370352
vpr_load_packing(vpr_setup_, arch_);
371-
load_cluster_constraints();
372353
const ClusteredNetlist& clb_nlist = g_vpr_ctx.clustering().clb_nlist;
373354

374355
// Verify the packing and print some info
@@ -461,16 +442,15 @@ void NaiveFullLegalizer::legalize(const PartialPlacement& p_placement) {
461442
// TODO: Eventually should be returned from the create_clusters method.
462443
const ClusteredNetlist& clb_nlist = g_vpr_ctx.clustering().clb_nlist;
463444

464-
// Alloc and load the placement macros.
465-
VTR_ASSERT(!g_vpr_ctx.placement().place_macros);
466-
g_vpr_ctx.mutable_placement().place_macros = std::make_unique<PlaceMacros>(g_vpr_ctx.device().arch->directs,
467-
g_vpr_ctx.device().physical_tile_types,
468-
g_vpr_ctx.clustering().clb_nlist,
469-
g_vpr_ctx.atom().nlist,
470-
g_vpr_ctx.atom().lookup);
445+
// Initialize the placement context.
446+
g_vpr_ctx.mutable_placement().init_placement_context(vpr_setup_.PlacerOpts,
447+
arch_.directs);
471448

472449
const PlaceMacros& place_macros = *g_vpr_ctx.placement().place_macros;
473450

451+
// Update the floorplanning context with the macro information.
452+
g_vpr_ctx.mutable_floorplanning().update_floorplanning_context_pre_place(place_macros);
453+
474454
// Place the clusters based on where the atoms want to be placed.
475455
place_clusters(clb_nlist, place_macros, p_placement);
476456

@@ -485,6 +465,12 @@ void NaiveFullLegalizer::legalize(const PartialPlacement& p_placement) {
485465
num_placement_errors);
486466
}
487467

468+
// Clean the placement context.
469+
g_vpr_ctx.mutable_placement().clean_placement_context_post_place();
470+
471+
// Clean the floorplanning context.
472+
g_vpr_ctx.mutable_floorplanning().clean_floorplanning_context_post_place();
473+
488474
// TODO: This was taken from vpr_api. Not sure why it is needed. Should be
489475
// made part of the placement and verify placement should check for
490476
// it.
@@ -521,7 +507,6 @@ void APPack::legalize(const PartialPlacement& p_placement) {
521507
// The Packer stores the clusters into a .net file. Load the packing file.
522508
// FIXME: This should be removed. Reading from a file is strange.
523509
vpr_load_packing(vpr_setup_, arch_);
524-
load_cluster_constraints();
525510
const ClusteredNetlist& clb_nlist = g_vpr_ctx.clustering().clb_nlist;
526511

527512
// Verify the packing and print some info

vpr/src/base/blk_loc_registry.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,34 @@
11

22
#include "blk_loc_registry.h"
33

4+
#include "device_grid.h"
45
#include "move_transactions.h"
56
#include "globals.h"
67
#include "physical_types_util.h"
8+
#include "vpr_context.h"
79

810
BlkLocRegistry::BlkLocRegistry()
911
: expected_transaction_(e_expected_transaction::APPLY) {}
1012

13+
void BlkLocRegistry::init() {
14+
const ClusteredNetlist& clb_nlist = g_vpr_ctx.clustering().clb_nlist;
15+
const DeviceGrid& device_grid = g_vpr_ctx.device().grid;
16+
auto& block_locs = mutable_block_locs();
17+
auto& grid_blocks = mutable_grid_blocks();
18+
19+
/* Initialize the lookup of CLB block positions */
20+
block_locs.clear();
21+
block_locs.resize(clb_nlist.blocks().size());
22+
23+
/* Initialize the reverse lookup of CLB block positions */
24+
grid_blocks.init_grid_blocks(device_grid);
25+
26+
/* Initialize the grid blocks to empty.
27+
* Initialize all the blocks to unplaced.
28+
*/
29+
clear_all_grid_locs();
30+
}
31+
1132
const vtr::vector_map<ClusterBlockId, t_block_loc>& BlkLocRegistry::block_locs() const {
1233
return block_locs_;
1334
}

vpr/src/base/blk_loc_registry.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ class BlkLocRegistry {
2626
BlkLocRegistry(BlkLocRegistry&&) = delete;
2727
BlkLocRegistry& operator=(BlkLocRegistry&&) = delete;
2828

29+
/// @brief Initialize the block loc registry's internal data. Must be called
30+
/// before any other method is called.
31+
void init();
32+
2933
private:
3034
///@brief Clustered block placement locations
3135
vtr::vector_map<ClusterBlockId, t_block_loc> block_locs_;

vpr/src/base/grid_block.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,28 @@
11

22
#include "grid_block.h"
33

4+
#include "device_grid.h"
45
#include "globals.h"
6+
#include "physical_types.h"
7+
8+
void GridBlock::init_grid_blocks(const DeviceGrid& device_grid) {
9+
size_t grid_width = device_grid.width();
10+
size_t grid_height = device_grid.height();
11+
size_t num_layers = device_grid.get_num_layers();
12+
13+
/* Structure should have the same dimensions as the grid. */
14+
grid_blocks_.resize({num_layers, grid_width, grid_height});
15+
16+
for (size_t layer_num = 0; layer_num < num_layers; layer_num++) {
17+
for (size_t x = 0; x < grid_width; x++) {
18+
for (size_t y = 0; y < grid_height; y++) {
19+
const t_physical_tile_loc tile_loc({(int)x, (int)y, (int)layer_num});
20+
auto type = device_grid.get_physical_type(tile_loc);
21+
initialized_grid_block_at_location(tile_loc, type->capacity);
22+
}
23+
}
24+
}
25+
}
526

627
void GridBlock::zero_initialize() {
728
auto& device_ctx = g_vpr_ctx.device();

vpr/src/base/grid_block.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ class GridBlock {
3838
grid_blocks_.resize({layers, width, height});
3939
}
4040

41+
/**
42+
* @brief Initialize `grid_blocks`, the inverse structure of `block_locs`.
43+
*
44+
* The container at each grid block location should have a length equal to the
45+
* subtile capacity of that block. Unused subtiles would be marked ClusterBlockId::INVALID().
46+
*/
47+
void init_grid_blocks(const DeviceGrid& device_grid);
48+
4149
inline void initialized_grid_block_at_location(const t_physical_tile_loc& loc, int num_sub_tiles) {
4250
grid_blocks_[loc.layer_num][loc.x][loc.y].blocks.resize(num_sub_tiles, ClusterBlockId::INVALID());
4351
}

vpr/src/base/vpr_api.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@
6969
#include "atom_netlist_utils.h"
7070
#include "output_clustering.h"
7171
#include "vpr_constraints_reader.h"
72-
#include "place_constraints.h"
7372
#include "place_util.h"
7473
#include "timing_fail_error.h"
7574
#include "analytical_placement_flow.h"
@@ -683,8 +682,9 @@ void vpr_load_packing(const t_vpr_setup& vpr_setup, const t_arch& arch) {
683682
report_packing_pin_usage(ofs, g_vpr_ctx);
684683
}
685684

686-
// Load cluster_constraints data structure.
687-
load_cluster_constraints();
685+
// Ater the clustered netlist has been loaded, update the floorplanning
686+
// constraints with the new information.
687+
g_vpr_ctx.mutable_floorplanning().update_floorplanning_context_post_pack();
688688

689689
/* Sanity check the resulting netlist */
690690
check_netlist(vpr_setup.PackerOpts.pack_verbosity);
@@ -843,8 +843,8 @@ void vpr_load_placement(t_vpr_setup& vpr_setup,
843843
auto& blk_loc_registry = place_ctx.mutable_blk_loc_registry();
844844
const auto& filename_opts = vpr_setup.FileNameOpts;
845845

846-
//Initialize placement data structures, which will be filled when loading placement
847-
init_placement_context(blk_loc_registry);
846+
//Initialize the block location registry, which will be filled when loading placement
847+
blk_loc_registry.init();
848848

849849
// Alloc and load the placement macros.
850850
place_ctx.place_macros = std::make_unique<PlaceMacros>(directs,

vpr/src/base/vpr_context.cpp

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
/**
2+
* @file
3+
* @author Alex Singer
4+
* @date February 2025
5+
* @brief Implementation of the more complicated context member functions.
6+
* These are methods used to initialize / clean the contexts.
7+
*/
8+
9+
#include "vpr_context.h"
10+
#include <memory>
11+
#include "compressed_grid.h"
12+
#include "globals.h"
13+
#include "physical_types.h"
14+
#include "place_constraints.h"
15+
#include "place_macro.h"
16+
#include "vpr_types.h"
17+
#include "vtr_memory.h"
18+
19+
/**
20+
* @brief determine the type of the bounding box used by the placer to predict
21+
* the wirelength.
22+
*
23+
* @param place_bb_mode The bounding box mode passed by the CLI
24+
* @param rr_graph The routing resource graph
25+
*/
26+
static bool is_cube_bb(const e_place_bounding_box_mode place_bb_mode,
27+
const RRGraphView& rr_graph);
28+
29+
void FloorplanningContext::update_floorplanning_context_post_pack() {
30+
// Initialize the cluster_constraints using the constraints loaded from the
31+
// user and clustering generated from packing.
32+
load_cluster_constraints();
33+
}
34+
35+
void FloorplanningContext::update_floorplanning_context_pre_place(
36+
const PlaceMacros& place_macros) {
37+
// Go through cluster blocks to calculate the tightest placement
38+
// floorplan constraint for each constrained block.
39+
propagate_place_constraints(place_macros);
40+
41+
// Compute and store compressed floorplanning constraints.
42+
alloc_and_load_compressed_cluster_constraints();
43+
}
44+
45+
void FloorplanningContext::clean_floorplanning_context_post_place() {
46+
// The cluster constraints are loaded in propagate_place_constraints and are
47+
// not used outside of placement.
48+
vtr::release_memory(cluster_constraints);
49+
50+
// The compressed cluster constraints are loaded in alloc_and_laod_compressed
51+
// cluster_constraints and are not used outside of placement.
52+
vtr::release_memory(compressed_cluster_constraints);
53+
}
54+
55+
void PlacementContext::init_placement_context(
56+
const t_placer_opts& placer_opts,
57+
const std::vector<t_direct_inf>& directs) {
58+
const AtomContext& atom_ctx = g_vpr_ctx.atom();
59+
const ClusteringContext& cluster_ctx = g_vpr_ctx.clustering();
60+
const DeviceContext& device_ctx = g_vpr_ctx.device();
61+
62+
cube_bb = is_cube_bb(placer_opts.place_bounding_box_mode, device_ctx.rr_graph);
63+
64+
compressed_block_grids = create_compressed_block_grids();
65+
66+
// Alloc and load the placement macros.
67+
place_macros = std::make_unique<PlaceMacros>(directs,
68+
device_ctx.physical_tile_types,
69+
cluster_ctx.clb_nlist,
70+
atom_ctx.nlist,
71+
atom_ctx.lookup);
72+
}
73+
74+
static bool is_cube_bb(const e_place_bounding_box_mode place_bb_mode,
75+
const RRGraphView& rr_graph) {
76+
bool cube_bb;
77+
const int number_layers = g_vpr_ctx.device().grid.get_num_layers();
78+
79+
if (place_bb_mode == e_place_bounding_box_mode::AUTO_BB) {
80+
// If the auto_bb is used, we analyze the RR graph to see whether is there any inter-layer connection that is not
81+
// originated from OPIN. If there is any, cube BB is chosen, otherwise, per-layer bb is chosen.
82+
if (number_layers > 1 && inter_layer_connections_limited_to_opin(rr_graph)) {
83+
cube_bb = false;
84+
} else {
85+
cube_bb = true;
86+
}
87+
} else if (place_bb_mode == e_place_bounding_box_mode::CUBE_BB) {
88+
// The user has specifically asked for CUBE_BB
89+
cube_bb = true;
90+
} else {
91+
// The user has specifically asked for PER_LAYER_BB
92+
VTR_ASSERT_SAFE(place_bb_mode == e_place_bounding_box_mode::PER_LAYER_BB);
93+
cube_bb = false;
94+
}
95+
96+
return cube_bb;
97+
}
98+
99+
void PlacementContext::clean_placement_context_post_place() {
100+
// The compressed block grids are currently only used during placement.
101+
vtr::release_memory(compressed_block_grids);
102+
}
103+

0 commit comments

Comments
 (0)