Skip to content

vpr: Add fix_clusters option to allow users to lock down any block to… #1433

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jul 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions libs/EXTERNAL/libargparse/argparse_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ struct Args {
ArgValue<float> exit_t;
ArgValue<float> alpha_t;
ArgValue<std::string> fix_pins;
ArgValue<std::string> fix_clusters;
ArgValue<std::string> place_algorithm;
ArgValue<size_t> place_chan_width;

Expand Down Expand Up @@ -302,6 +303,13 @@ int main(
" or a file specifying the pad locations.")
.default_value("off")
.show_in(argparse::ShowIn::HELP_ONLY);
place_grp.add_argument(args.fix_clusters, "--fix_clusters")
.help("Fixes block locations during placement."
" Can be 'random' for a random initial assignment,"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to remove random option.

" 'off' to allow the place to optimize block locations,"
" or a file specifying the block locations.")
.default_value("off")
.show_in(argparse::ShowIn::HELP_ONLY);
place_grp.add_argument(args.place_algorithm, "--place_algorithm")
.help("Controls which placement algorithm is used")
.default_value("path_timing_driven")
Expand Down
4 changes: 2 additions & 2 deletions vpr/src/base/CheckSetup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ void CheckSetup(const t_packer_opts& PackerOpts,
"Timing analysis must be enabled for timing-driven placement.\n");
}

if (!PlacerOpts.doPlacement && (USER == PlacerOpts.pad_loc_type)) {
if (!PlacerOpts.doPlacement && (LOCKED == PlacerOpts.block_loc_type)) {
VPR_FATAL_ERROR(VPR_ERROR_OTHER,
"A pad location file requires that placement is enabled.\n");
"A block location file requires that placement is enabled.\n");
}

if (RouterOpts.doRouting) {
Expand Down
2 changes: 2 additions & 0 deletions vpr/src/base/SetupVPR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -503,8 +503,10 @@ static void SetupPlacerOpts(const t_options& Options, t_placer_opts* PlacerOpts)

PlacerOpts->place_algorithm = Options.PlaceAlgorithm;

PlacerOpts->constraints_file = Options.constraints_file;
PlacerOpts->pad_loc_file = Options.pad_loc_file;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove pad_loc_file

PlacerOpts->pad_loc_type = Options.pad_loc_type;
PlacerOpts->block_loc_type = Options.block_loc_type;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

block_loc_type isn't a great name; not obvious it goes with the constraints file.
But probably better still to simply have a NULL or empty constraints_file name mean no location constraints.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the best thing is to delete block_loc_type entirely and use a NULL constraints file name to mean no constraints. Comment it when you do the test for a NULL constraints file (means none specified).


PlacerOpts->place_chan_width = Options.PlaceChanWidth;

Expand Down
15 changes: 12 additions & 3 deletions vpr/src/base/ShowSetup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -509,13 +509,22 @@ static void ShowPlacerOpts(const t_placer_opts& PlacerOpts,
case RANDOM:
VTR_LOG("RANDOM\n");
break;
case USER:
VTR_LOG("USER '%s'\n", PlacerOpts.pad_loc_file.c_str());
break;
default:
VPR_FATAL_ERROR(VPR_ERROR_UNKNOWN, "Unknown I/O pad location type\n");
}

VTR_LOG("PlacerOpts.block_loc_type: ");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make more user friendly.
should just be PlacerOpts.constraint_file: fname

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the same time, put a blank line before the first placer option (or after last packer option). Other groups have a blank line between them; placer and packer should too.

switch (PlacerOpts.block_loc_type) {
case NOT_LOCKED:
VTR_LOG("NOT_LOCKED\n");
break;
case LOCKED:
VTR_LOG("LOCKED '%s'\n", PlacerOpts.constraints_file.c_str());
break;
default:
VPR_FATAL_ERROR(VPR_ERROR_UNKNOWN, "Unknown block location type\n");
}

VTR_LOG("PlacerOpts.place_cost_exp: %f\n", PlacerOpts.place_cost_exp);

VTR_LOG("PlacerOpts.place_chan_width: %d\n", PlacerOpts.place_chan_width);
Expand Down
25 changes: 19 additions & 6 deletions vpr/src/base/read_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1568,13 +1568,19 @@ argparse::ArgumentParser create_arg_parser(std::string prog_name, t_options& arg

place_grp.add_argument(args.pad_loc_file, "--fix_pins")
.help(
"Fixes I/O pad locations during placement. Valid options:\n"
"Fixes I/O pad locations randomly during placement. Valid options:\n"
" * 'free' allows placement to optimize pad locations\n"
" * 'random' fixes pad locations to arbitraray locations\n"
" * path to a file specifying pad locations (.place format with only pads specified).")
" * 'random' fixes pad locations to arbitrary locations\n.")
.default_value("free")
.show_in(argparse::ShowIn::HELP_ONLY);

place_grp.add_argument(args.constraints_file, "--fix_clusters")
.help(
"Fixes block locations during placement. Valid options:\n"
" * path to a file specifying block locations (.place format with block locations specified).")
.default_value("not_locked")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update this to just have a filename, default is empty string (no constraint file).

.show_in(argparse::ShowIn::HELP_ONLY);

place_grp.add_argument<e_place_algorithm, ParsePlaceAlgorithm>(args.PlaceAlgorithm, "--place_algorithm")
.help("Controls which placement algorithm is used")
.default_value("path_timing_driven")
Expand Down Expand Up @@ -2201,7 +2207,7 @@ void set_conditional_defaults(t_options& args) {
args.anneal_sched_type.set(AUTO_SCHED, Provenance::INFERRED);
}

//Are the pad locations specified?
//Are the pads free to be moved during placement or randomly locked to certain locations?
if (std::string(args.pad_loc_file) == "free") {
args.pad_loc_type.set(FREE, Provenance::INFERRED);

Expand All @@ -2211,8 +2217,15 @@ void set_conditional_defaults(t_options& args) {

args.pad_loc_file.set("", Provenance::SPECIFIED);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pad_loc_file should be removed.

} else {
args.pad_loc_type.set(USER, Provenance::INFERRED);
VTR_ASSERT(!args.pad_loc_file.value().empty());
VPR_FATAL_ERROR(VPR_ERROR_UNKNOWN, "Unknown I/O pad location type\n");
}

//Are the blocks locked to locations given by a constraints file?
if (std::string(args.constraints_file) == "not_locked") {
args.block_loc_type.set(NOT_LOCKED, Provenance::INFERRED);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove, and use constraints_file variable instead.

} else {
args.block_loc_type.set(LOCKED, Provenance::INFERRED);
VTR_ASSERT(!args.constraints_file.value().empty());
}

/*
Expand Down
2 changes: 2 additions & 0 deletions vpr/src/base/read_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ struct t_options {
argparse::ArgValue<e_circuit_format> circuit_format;

argparse::ArgValue<std::string> out_file_prefix;
argparse::ArgValue<std::string> constraints_file;
argparse::ArgValue<std::string> pad_loc_file;
argparse::ArgValue<std::string> write_rr_graph_file;
argparse::ArgValue<std::string> read_rr_graph_file;
Expand Down Expand Up @@ -100,6 +101,7 @@ struct t_options {
argparse::ArgValue<sched_type> anneal_sched_type;
argparse::ArgValue<e_place_algorithm> PlaceAlgorithm;
argparse::ArgValue<e_pad_loc_type> pad_loc_type;
argparse::ArgValue<e_block_loc_type> block_loc_type;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete

argparse::ArgValue<int> PlaceChanWidth;
argparse::ArgValue<float> place_rlim_escape_fraction;
argparse::ArgValue<std::string> place_move_stats_file;
Expand Down
42 changes: 21 additions & 21 deletions vpr/src/base/read_place.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ void read_place(const char* net_file,
place_ctx.placement_id = vtr::secure_digest_file(place_file);
}

///@brief Reads in the locations of the IO pads from a file.
void read_user_pad_loc(const char* pad_loc_file) {
void read_user_block_loc(const char* constraints_file) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This takes a comment out of doxygen. See https://www.doxygen.nl/manual/docblocks.html for how doxygen works. Should put the comment before the function, using ///@brief so doxygen finds it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should expand this comment. Comment should include:
These locations can be for any subset of the cluster-level blocks, and they will be locked to the specified locations throughout placement. The format of the file is the same as the .place format.

/* Reads in the locations of the blocks from a file. */
t_hash **hash_table, *h_ptr;
int xtmp, ytmp;
FILE* fp;
Expand All @@ -152,11 +152,11 @@ void read_user_pad_loc(const char* pad_loc_file) {
auto& place_ctx = g_vpr_ctx.mutable_placement();

VTR_LOG("\n");
VTR_LOG("Reading locations of IO pads from '%s'.\n", pad_loc_file);
fp = fopen(pad_loc_file, "r");
VTR_LOG("Reading locations of blocks from '%s'.\n", constraints_file);
fp = fopen(constraints_file, "r");
if (!fp) VPR_FATAL_ERROR(VPR_ERROR_PLACE_F,
"'%s' - Cannot find IO pads location file.\n",
pad_loc_file);
"'%s' - Cannot find block locations file.\n",
constraints_file);

hash_table = alloc_hash_table();
for (auto blk_id : cluster_ctx.clb_nlist.blocks()) {
Expand Down Expand Up @@ -189,41 +189,41 @@ void read_user_pad_loc(const char* pad_loc_file) {
if (strlen(ptr) + 1 < vtr::bufsize) {
strcpy(bname, ptr);
} else {
vpr_throw(VPR_ERROR_PLACE_F, pad_loc_file, vtr::get_file_line_number_of_last_opened_file(),
vpr_throw(VPR_ERROR_PLACE_F, constraints_file, vtr::get_file_line_number_of_last_opened_file(),
"Block name exceeded buffer size of %zu characters", vtr::bufsize);
}

ptr = vtr::strtok(nullptr, TOKENS, fp, buf);
if (ptr == nullptr) {
vpr_throw(VPR_ERROR_PLACE_F, pad_loc_file, vtr::get_file_line_number_of_last_opened_file(),
vpr_throw(VPR_ERROR_PLACE_F, constraints_file, vtr::get_file_line_number_of_last_opened_file(),
"Incomplete.\n");
}
sscanf(ptr, "%d", &xtmp);

ptr = vtr::strtok(nullptr, TOKENS, fp, buf);
if (ptr == nullptr) {
vpr_throw(VPR_ERROR_PLACE_F, pad_loc_file, vtr::get_file_line_number_of_last_opened_file(),
vpr_throw(VPR_ERROR_PLACE_F, constraints_file, vtr::get_file_line_number_of_last_opened_file(),
"Incomplete.\n");
}
sscanf(ptr, "%d", &ytmp);

ptr = vtr::strtok(nullptr, TOKENS, fp, buf);
if (ptr == nullptr) {
vpr_throw(VPR_ERROR_PLACE_F, pad_loc_file, vtr::get_file_line_number_of_last_opened_file(),
vpr_throw(VPR_ERROR_PLACE_F, constraints_file, vtr::get_file_line_number_of_last_opened_file(),
"Incomplete.\n");
}
int k;
sscanf(ptr, "%d", &k);

ptr = vtr::strtok(nullptr, TOKENS, fp, buf);
if (ptr != nullptr) {
vpr_throw(VPR_ERROR_PLACE_F, pad_loc_file, vtr::get_file_line_number_of_last_opened_file(),
vpr_throw(VPR_ERROR_PLACE_F, constraints_file, vtr::get_file_line_number_of_last_opened_file(),
"Extra characters at end of line.\n");
}

h_ptr = get_hash_entry(hash_table, bname);
if (h_ptr == nullptr) {
VTR_LOG_WARN("[Line %d] Block %s invalid, no such IO pad.\n",
VTR_LOG_WARN("[Line %d] Block %s invalid, no such block.\n",
vtr::get_file_line_number_of_last_opened_file(), bname);
ptr = vtr::fgets(buf, vtr::bufsize, fp);
continue;
Expand All @@ -233,12 +233,12 @@ void read_user_pad_loc(const char* pad_loc_file) {
int j = ytmp;

if (place_ctx.block_locs[bnum].loc.x != OPEN) {
VPR_THROW(VPR_ERROR_PLACE_F, pad_loc_file, vtr::get_file_line_number_of_last_opened_file(),
"Block %s is listed twice in pad file.\n", bname);
VPR_THROW(VPR_ERROR_PLACE_F, constraints_file, vtr::get_file_line_number_of_last_opened_file(),
"Block %s is listed twice in constraints file.\n", bname);
}

if (i < 0 || i > int(device_ctx.grid.width() - 1) || j < 0 || j > int(device_ctx.grid.height() - 1)) {
VPR_THROW(VPR_ERROR_PLACE_F, pad_loc_file, 0,
VPR_THROW(VPR_ERROR_PLACE_F, constraints_file, 0,
"Block #%zu (%s) location, (%d,%d) is out of range.\n", size_t(bnum), bname, i, j);
}

Expand All @@ -250,13 +250,13 @@ void read_user_pad_loc(const char* pad_loc_file) {
auto physical_tile = device_ctx.grid[i][j].type;
auto logical_block = cluster_ctx.clb_nlist.block_type(bnum);
if (!is_sub_tile_compatible(physical_tile, logical_block, place_ctx.block_locs[bnum].loc.sub_tile)) {
VPR_THROW(VPR_ERROR_PLACE_F, pad_loc_file, 0,
VPR_THROW(VPR_ERROR_PLACE_F, constraints_file, 0,
"Attempt to place block %s at illegal location (%d, %d).\n", bname, i, j);
}

if (k >= physical_tile->capacity || k < 0) {
VPR_THROW(VPR_ERROR_PLACE_F, pad_loc_file, vtr::get_file_line_number_of_last_opened_file(),
"Block %s subblock number (%d) is out of range.\n", bname, k);
VPR_THROW(VPR_ERROR_PLACE_F, constraints_file, vtr::get_file_line_number_of_last_opened_file(),
"Block %s subtile number (%d) is out of range.\n", bname, k);
}
place_ctx.grid_blocks[i][j].blocks[k] = bnum;
place_ctx.grid_blocks[i][j].usage++;
Expand All @@ -273,14 +273,14 @@ void read_user_pad_loc(const char* pad_loc_file) {
}

if (place_ctx.block_locs[blk_id].loc.x == OPEN) {
VPR_THROW(VPR_ERROR_PLACE_F, pad_loc_file, 0,
"IO block %s location was not specified in the pad file.\n", cluster_ctx.clb_nlist.block_name(blk_id).c_str());
VPR_THROW(VPR_ERROR_PLACE_F, constraints_file, 0,
"Block %s location was not specified in the constraints file.\n", cluster_ctx.clb_nlist.block_name(blk_id).c_str());
}
}

fclose(fp);
free_hash_table(hash_table);
VTR_LOG("Successfully read %s.\n", pad_loc_file);
VTR_LOG("Successfully read %s.\n", constraints_file);
VTR_LOG("\n");
}

Expand Down
2 changes: 1 addition & 1 deletion vpr/src/base/read_place.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ void print_place(const char* net_file,
const char* net_id,
const char* place_file);

void read_user_pad_loc(const char* pad_loc_file);
void read_user_block_loc(const char* constraints_file);

#endif
21 changes: 15 additions & 6 deletions vpr/src/base/vpr_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -504,16 +504,21 @@ enum pfreq {
};

/**
* @brief Are the pads free to be moved, locked in a random configuration, or
* locked in user-specified positions?
* @brief Are the pads free to be moved or locked in a random configuration?
*/
enum e_pad_loc_type {
FREE,
RANDOM,
USER
RANDOM
};

/*Are the blocks not locked (free to be moved) or locked in user-specified positions?*/
enum e_block_loc_type {
NOT_LOCKED,
LOCKED
};

///@brief Power data for t_netlist structure

struct t_net_power {
///@brief Signal probability - long term probability that signal is logic-high
float probability;
Expand Down Expand Up @@ -816,8 +821,10 @@ struct t_annealing_sched {
* place_chan_width: The channel width assumed if only one placement is *
* performed. *
* pad_loc_type: Are pins FREE, fixed randomly, or fixed from a file. *
* pad_loc_file: File to read pin locations form if pad_loc_type *
* is USER. *
* block_loc_type: Are blocks fixed from a file. *
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove.

* constraints_file: File to read block locations from if block_loc_type *
* is LOCKED. *
* pad_loc_file: File to read pad locations from if pad_loc_type is USER. *
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove pad_loc_file

* place_freq: Should the placement be skipped, done once, or done for each *
* channel width in the binary search. *
* recompute_crit_iter: how many temperature stages pass before we recompute *
Expand Down Expand Up @@ -870,6 +877,8 @@ struct t_placer_opts {
float place_cost_exp;
int place_chan_width;
enum e_pad_loc_type pad_loc_type;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove block_loc_type

enum e_block_loc_type block_loc_type;
std::string constraints_file;
std::string pad_loc_file;
enum pfreq place_freq;
int recompute_crit_iter;
Expand Down
9 changes: 5 additions & 4 deletions vpr/src/place/initial_placement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,9 +392,9 @@ static t_physical_tile_type_ptr pick_placement_type(t_logical_block_type_ptr log
return nullptr;
}

void initial_placement(enum e_pad_loc_type pad_loc_type,
const char* pad_loc_file) {
void initial_placement(enum e_pad_loc_type pad_loc_type, enum e_block_loc_type block_loc_type, const char* constraints_file) {
vtr::ScopedStartFinishTimer timer("Initial Placement");

/* Randomly places the blocks to create an initial placement. We rely on
* the legal_pos array already being loaded. That legal_pos[itype] is an
* array that gives every legal value of (x,y,z) that can accommodate a block.
Expand Down Expand Up @@ -445,8 +445,9 @@ void initial_placement(enum e_pad_loc_type pad_loc_type,
place_ctx.block_locs[blk_id].loc = t_pl_loc();
}

if (pad_loc_type == USER) {
read_user_pad_loc(pad_loc_file);
/*If the user specified block locations using a constraints file, read those locations in here*/
if (block_loc_type == LOCKED) {
read_user_block_loc(constraints_file);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change to just call read_user_block_loc (can have it return if constraints_file is NULL or an empty string). Or could check before calling it with this if ().

}

initial_placement_pl_macros(MAX_NUM_TRIES_TO_PLACE_MACROS_RANDOMLY, free_locations);
Expand Down
3 changes: 1 addition & 2 deletions vpr/src/place/initial_placement.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

#include "vpr_types.h"

void initial_placement(enum e_pad_loc_type pad_loc_type,
const char* pad_loc_file);
void initial_placement(enum e_pad_loc_type pad_loc_type, enum e_block_loc_type block_loc_type, const char* constraints_file);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove block_loc_type


#endif
2 changes: 1 addition & 1 deletion vpr/src/place/place.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ void try_place(const t_placer_opts& placer_opts,
alloc_and_load_placement_structs(placer_opts.place_cost_exp, placer_opts,
directs, num_directs);

initial_placement(placer_opts.pad_loc_type, placer_opts.pad_loc_file.c_str());
initial_placement(placer_opts.pad_loc_type, placer_opts.block_loc_type, placer_opts.constraints_file.c_str());

// Update physical pin values
for (auto block_id : cluster_ctx.clb_nlist.blocks()) {
Expand Down
7 changes: 7 additions & 0 deletions vtr_flow/arch/reg_test_archs/Readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
###################################################
# Architecture Files
###################################################

This directory contains architecture files that are used in regression testing.


Loading