Skip to content

Commit 2102256

Browse files
committed
Changed comments and created new golden result for one of the nightly reg tests
1 parent 724f717 commit 2102256

File tree

5 files changed

+49
-42
lines changed

5 files changed

+49
-42
lines changed

vpr/src/base/read_place.cpp

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,16 @@ void read_place(
3232
const char* net_file,
3333
const char* place_file,
3434
bool verify_file_digests,
35-
const DeviceGrid& grid,
36-
bool is_place_file) {
35+
const DeviceGrid& grid) {
3736
std::ifstream fstream(place_file);
3837
if (!fstream) {
3938
VPR_FATAL_ERROR(VPR_ERROR_PLACE_F,
4039
"'%s' - Cannot open place file.\n",
4140
place_file);
4241
}
4342

43+
bool is_place_file = true;
44+
4445
VTR_LOG("Reading %s.\n", place_file);
4546
VTR_LOG("\n");
4647

@@ -51,15 +52,16 @@ void read_place(
5152
VTR_LOG("\n");
5253
}
5354

54-
void read_constraints(const char* constraints_file,
55-
bool is_place_file) {
55+
void read_constraints(const char* constraints_file) {
5656
std::ifstream fstream(constraints_file);
5757
if (!fstream) {
5858
VPR_FATAL_ERROR(VPR_ERROR_PLACE_F,
5959
"'%s' - Cannot open constraints file.\n",
6060
constraints_file);
6161
}
6262

63+
bool is_place_file = false;
64+
6365
VTR_LOG("Reading %s.\n", constraints_file);
6466
VTR_LOG("\n");
6567

@@ -226,13 +228,16 @@ void read_place_body(std::ifstream& placement_file,
226228
if (atom_blk_id == AtomBlockId::INVALID()) {
227229
VPR_THROW(VPR_ERROR_PLACE, "Block %s has an invalid name.\n", c_block_name);
228230
} else {
229-
blk_id = atom_ctx.lookup.atom_clb(atom_blk_id);
231+
blk_id = atom_ctx.lookup.atom_clb(atom_blk_id); //getting the ClusterBlockId of the cluster that the atom is in
230232
}
231233
}
232234

233-
//Check if block is listed twice in constraints file
234-
if (seen_blocks[blk_id] != 0) {
235-
VPR_THROW(VPR_ERROR_PLACE, "Block %s with ID %d is listed twice in the constraints file.\n", c_block_name, blk_id);
235+
//Check if block is listed multiple times with conflicting locations in constraints file
236+
if (seen_blocks[blk_id] > 0) {
237+
if (block_x != place_ctx.block_locs[blk_id].loc.x || block_y != place_ctx.block_locs[blk_id].loc.y || sub_tile_index != place_ctx.block_locs[blk_id].loc.sub_tile) {
238+
VPR_THROW(VPR_ERROR_PLACE, "The location of cluster %d is specified %d times in the constraints file with conflicting locations. \n"
239+
"Its location was last specified with block %s. \n", blk_id, seen_blocks[blk_id] + 1, c_block_name);
240+
}
236241
}
237242

238243
//Check if block location is out of range of grid dimensions
@@ -260,14 +265,17 @@ void read_place_body(std::ifstream& placement_file,
260265
}
261266

262267
//need to lock down blocks and mark grid block usage if it is a constraints file
268+
//for a place file, grid usage is marked during initial placement instead
263269
if (!is_place_file) {
264270
place_ctx.block_locs[blk_id].is_fixed = true;
265271
place_ctx.grid_blocks[block_x][block_y].blocks[sub_tile_index] = blk_id;
266-
place_ctx.grid_blocks[block_x][block_y].usage++;
272+
if (seen_blocks[blk_id] == 0) {
273+
place_ctx.grid_blocks[block_x][block_y].usage++;
274+
}
267275
}
268276

269277
//mark the block as seen
270-
seen_blocks[blk_id] = 1;
278+
seen_blocks[blk_id]++;
271279

272280
} else {
273281
//Unrecognized
@@ -278,6 +286,7 @@ void read_place_body(std::ifstream& placement_file,
278286
}
279287

280288
//For place files, check that all blocks have been read
289+
//For constraints files, not all blocks need to be read
281290
if (is_place_file) {
282291
for (auto block_id : cluster_ctx.clb_nlist.blocks()) {
283292
if (seen_blocks[block_id] == 0) {
@@ -286,6 +295,7 @@ void read_place_body(std::ifstream& placement_file,
286295
}
287296
}
288297

298+
//Want to make a hash for place file to be used during routing for error checking
289299
if (is_place_file) {
290300
place_ctx.placement_id = vtr::secure_digest_file(place_file);
291301
}

vpr/src/base/read_place.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,20 @@
22
#define READ_PLACE_H
33

44
/**
5-
* This function is used to read a placement file.
5+
* This function is for reading a place file when placement is skipped.
6+
* It takes in the current netlist file and grid dimensions to check that they match those that were used when placement was generated.
7+
* The verify_file_hashes bool is used to decide whether to give a warning or an error if the netlist files do not match.
68
*/
79
void read_place(
810
const char* net_file,
911
const char* place_file,
1012
bool verify_file_hashes,
11-
const DeviceGrid& grid,
12-
bool is_place_file);
13+
const DeviceGrid& grid);
1314

1415
/**
1516
* This function is used to read a constraints file that specifies the desired locations of blocks.
1617
*/
17-
void read_constraints(
18-
const char* constraints_file,
19-
bool is_place_file);
18+
void read_constraints(const char* constraints_file);
2019

2120
void print_place(const char* net_file,
2221
const char* net_id,

vpr/src/base/vpr_api.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -661,10 +661,9 @@ void vpr_load_placement(t_vpr_setup& vpr_setup, const t_arch& arch) {
661661
const auto& device_ctx = g_vpr_ctx.device();
662662
auto& place_ctx = g_vpr_ctx.mutable_placement();
663663
const auto& filename_opts = vpr_setup.FileNameOpts;
664-
bool is_a_placement_file = true;
665664

666665
//Load an existing placement from a file
667-
read_place(filename_opts.NetFile.c_str(), filename_opts.PlaceFile.c_str(), filename_opts.verify_file_digests, device_ctx.grid, is_a_placement_file);
666+
read_place(filename_opts.NetFile.c_str(), filename_opts.PlaceFile.c_str(), filename_opts.verify_file_digests, device_ctx.grid);
668667

669668
//Ensure placement macros are loaded so that they can be drawn after placement (e.g. during routing)
670669
place_ctx.pl_macros = alloc_and_load_placement_macros(arch.Directs, arch.num_directs);

vpr/src/place/initial_placement.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,8 +451,7 @@ void initial_placement(enum e_pad_loc_type pad_loc_type, const char* constraints
451451

452452
/*Check whether the constraint file is NULL, if not, read in the block locations from the constraints file here*/
453453
if (strlen(constraints_file) != 0) {
454-
bool is_a_place_file = false; //specifies that this is a constraints file, not a place file and should be read as such
455-
read_constraints(constraints_file, is_a_place_file);
454+
read_constraints(constraints_file);
456455
}
457456

458457
initial_placement_pl_macros(MAX_NUM_TRIES_TO_PLACE_MACROS_RANDOMLY, free_locations);

0 commit comments

Comments
 (0)