Skip to content

Commit 9f14605

Browse files
committed
Changed vpr command line options used for generating test constraints files. Cleaned up attraction groups class
1 parent 9bdc971 commit 9f14605

File tree

9 files changed

+51
-184
lines changed

9 files changed

+51
-184
lines changed

vpr/src/base/SetupVPR.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,8 @@ static void SetupPlacerOpts(const t_options& Options, t_placer_opts* PlacerOpts)
612612
PlacerOpts->place_agent_algorithm = Options.place_agent_algorithm;
613613
PlacerOpts->place_constraint_expand = Options.place_constraint_expand;
614614
PlacerOpts->place_constraint_subtile = Options.place_constraint_subtile;
615-
PlacerOpts->floorplan_split = Options.floorplan_split;
615+
PlacerOpts->floorplan_num_horizontal_partitions = Options.floorplan_num_horizontal_partitions;
616+
PlacerOpts->floorplan_num_vertical_partitions = Options.floorplan_num_vertical_partitions;
616617
}
617618

618619
static void SetupAnalysisOpts(const t_options& Options, t_analysis_opts& analysis_opts) {

vpr/src/base/read_options.cpp

Lines changed: 13 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -491,45 +491,6 @@ struct ParseFixPins {
491491
}
492492
};
493493

494-
struct ParseFloorplanSplit {
495-
ConvertedValue<constraints_split_factor> from_str(std::string str) {
496-
ConvertedValue<constraints_split_factor> conv_value;
497-
if (str == "halves")
498-
conv_value.set_value(HALVES);
499-
else if (str == "quadrants")
500-
conv_value.set_value(QUADRANTS);
501-
else if (str == "sixteenths")
502-
conv_value.set_value(SIXTEENTHS);
503-
else if (str == "one_spot")
504-
conv_value.set_value(ONE_SPOT);
505-
else {
506-
std::stringstream msg;
507-
msg << "Invalid conversion from '" << str << "' to constraints_split_factor (expected one of: " << argparse::join(default_choices(), ", ") << ")";
508-
conv_value.set_error(msg.str());
509-
}
510-
return conv_value;
511-
}
512-
513-
ConvertedValue<std::string> to_str(constraints_split_factor val) {
514-
ConvertedValue<std::string> conv_value;
515-
if (val == HALVES)
516-
conv_value.set_value("halves");
517-
else if (val == QUADRANTS)
518-
conv_value.set_value("quadrants");
519-
else if (val == SIXTEENTHS)
520-
conv_value.set_value("sixteenths");
521-
else {
522-
VTR_ASSERT(val == ONE_SPOT);
523-
conv_value.set_value("one_spot");
524-
}
525-
return conv_value;
526-
}
527-
528-
std::vector<std::string> default_choices() {
529-
return {"halves", "quadrants", "sixteenths", "one_spot"};
530-
}
531-
};
532-
533494
struct ParseClusterSeed {
534495
ConvertedValue<e_cluster_seed> from_str(std::string str) {
535496
ConvertedValue<e_cluster_seed> conv_value;
@@ -2059,13 +2020,20 @@ argparse::ArgumentParser create_arg_parser(std::string prog_name, t_options& arg
20592020
.default_value("off")
20602021
.show_in(argparse::ShowIn::HELP_ONLY);
20612022

2062-
place_grp.add_argument<constraints_split_factor, ParseFloorplanSplit>(args.floorplan_split, "--floorplan_split")
2063-
.help(
2064-
"Specifies how many partitions are created from a placement when a floorplan constraint file is generated "
2065-
"via the --write_vpr_constraints option.")
2066-
.default_value("halves")
2067-
.choices({"halves", "quadrants", "sixteenths", "one_spot"})
2023+
place_grp.add_argument(args.floorplan_num_horizontal_partitions, "--floorplan_num_horizontal_partitions")
2024+
.help("An argument used for generating test constraints files. Specifies how many partitions to "
2025+
"make in the horizontal dimension. Must be used in conjunction with "
2026+
"--floorplan_num_vertical_partitions")
2027+
.default_value("0")
20682028
.show_in(argparse::ShowIn::HELP_ONLY);
2029+
2030+
place_grp.add_argument(args.floorplan_num_vertical_partitions, "--floorplan_num_vertical_partitions")
2031+
.help("An argument used for generating test constraints files. Specifies how many partitions to "
2032+
"make in the vertical dimension. Must be used in conjunction with "
2033+
"--floorplan_num_horizontal_partitions")
2034+
.default_value("0")
2035+
.show_in(argparse::ShowIn::HELP_ONLY);
2036+
20692037
/*
20702038
* place_grp.add_argument(args.place_timing_cost_func, "--place_timing_cost_func")
20712039
* .help(

vpr/src/base/read_options.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@ struct t_options {
133133
argparse::ArgValue<float> place_crit_limit;
134134
argparse::ArgValue<int> place_constraint_expand;
135135
argparse::ArgValue<bool> place_constraint_subtile;
136-
argparse::ArgValue<constraints_split_factor> floorplan_split;
136+
argparse::ArgValue<int> floorplan_num_horizontal_partitions;
137+
argparse::ArgValue<int> floorplan_num_vertical_partitions;
137138

138139
/* Timing-driven placement options only */
139140
argparse::ArgValue<float> PlaceTimingTradeoff;

vpr/src/base/vpr_api.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,8 @@ bool vpr_place_flow(t_vpr_setup& vpr_setup, const t_arch& arch) {
632632

633633
//Write out a vpr floorplanning constraints file if the option is specified
634634
if (!filename_opts.write_vpr_constraints_file.empty()) {
635-
write_vpr_floorplan_constraints(filename_opts.write_vpr_constraints_file.c_str(), placer_opts.place_constraint_expand, placer_opts.place_constraint_subtile, placer_opts.floorplan_split);
635+
write_vpr_floorplan_constraints(filename_opts.write_vpr_constraints_file.c_str(), placer_opts.place_constraint_expand, placer_opts.place_constraint_subtile,
636+
placer_opts.floorplan_num_horizontal_partitions, placer_opts.floorplan_num_vertical_partitions);
636637
}
637638

638639
return true;

vpr/src/base/vpr_constraints_writer.cpp

Lines changed: 6 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,13 @@
1919
#include "vpr_constraints_writer.h"
2020
#include "region.h"
2121

22-
void write_vpr_floorplan_constraints(const char* file_name, int expand, bool subtile, enum constraints_split_factor floorplan_split) {
22+
void write_vpr_floorplan_constraints(const char* file_name, int expand, bool subtile, int horizontal_partitions, int vertical_partitions) {
2323
VprConstraints constraints;
2424

25-
if (floorplan_split == HALVES) {
26-
setup_vpr_floorplan_constraints_cutpoints(constraints, 2, 1);
27-
} else if (floorplan_split == QUADRANTS) {
28-
setup_vpr_floorplan_constraints_cutpoints(constraints, 2, 2);
29-
} else if (floorplan_split == SIXTEENTHS) {
30-
setup_vpr_floorplan_constraints_cutpoints(constraints, 4, 4);
31-
} else { //one_spot
32-
setup_vpr_floorplan_constraints(constraints, expand, subtile);
25+
if (horizontal_partitions != 0 && vertical_partitions != 0) {
26+
setup_vpr_floorplan_constraints_cutpoints(constraints, horizontal_partitions, vertical_partitions);
27+
} else {
28+
setup_vpr_floorplan_constraints_one_loc(constraints, expand, subtile);
3329
}
3430

3531
VprConstraintsSerializer writer(constraints);
@@ -47,71 +43,18 @@ void write_vpr_floorplan_constraints(const char* file_name, int expand, bool sub
4743
}
4844
}
4945

50-
void setup_vpr_floorplan_constraints(VprConstraints& constraints, int expand, bool subtile) {
51-
auto& cluster_ctx = g_vpr_ctx.clustering();
52-
auto& place_ctx = g_vpr_ctx.placement();
53-
ClusterAtomsLookup atoms_lookup;
54-
55-
int part_id = 0;
56-
/*
57-
* For each cluster block, create a partition filled with the atoms that are currently in the cluster.
58-
* The PartitionRegion will be the location of the block in current placement, modified by the expansion factor.
59-
* The subtile can also optionally be set in the PartitionRegion, based on the value passed in by the user.
60-
*/
61-
for (auto blk_id : cluster_ctx.clb_nlist.blocks()) {
62-
std::string part_name;
63-
part_name = cluster_ctx.clb_nlist.block_name(blk_id);
64-
PartitionId partid(part_id);
65-
66-
Partition part;
67-
part.set_name(part_name);
68-
69-
PartitionRegion pr;
70-
Region reg;
71-
72-
auto loc = place_ctx.block_locs[blk_id].loc;
73-
74-
reg.set_region_rect(loc.x - expand, loc.y - expand, loc.x + expand, loc.y + expand);
75-
if (subtile) {
76-
int st = loc.sub_tile;
77-
reg.set_sub_tile(st);
78-
}
79-
80-
pr.add_to_part_region(reg);
81-
part.set_part_region(pr);
82-
constraints.add_partition(part);
83-
84-
std::vector<AtomBlockId> atoms = atoms_lookup.atoms_in_cluster(blk_id);
85-
int num_atoms = atoms.size();
86-
87-
for (auto atm = 0; atm < num_atoms; atm++) {
88-
AtomBlockId atom_id = atoms[atm];
89-
constraints.add_constrained_atom(atom_id, partid);
90-
}
91-
part_id++;
92-
}
93-
}
94-
95-
void setup_vpr_floorplan_constraints_half(VprConstraints& constraints, int expand, bool subtile) {
46+
void setup_vpr_floorplan_constraints_one_loc(VprConstraints& constraints, int expand, bool subtile) {
9647
auto& cluster_ctx = g_vpr_ctx.clustering();
9748
auto& place_ctx = g_vpr_ctx.placement();
9849
ClusterAtomsLookup atoms_lookup;
9950

10051
int part_id = 0;
101-
int block_count = 0;
102-
10352
/*
10453
* For each cluster block, create a partition filled with the atoms that are currently in the cluster.
10554
* The PartitionRegion will be the location of the block in current placement, modified by the expansion factor.
10655
* The subtile can also optionally be set in the PartitionRegion, based on the value passed in by the user.
10756
*/
10857
for (auto blk_id : cluster_ctx.clb_nlist.blocks()) {
109-
if (block_count % 2 == 0) {
110-
block_count++;
111-
continue;
112-
}
113-
block_count++;
114-
11558
std::string part_name;
11659
part_name = cluster_ctx.clb_nlist.block_name(blk_id);
11760
PartitionId partid(part_id);

vpr/src/base/vpr_constraints_writer.h

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,14 @@
1212
*
1313
* The option --write_vpr_constraints can be used to generate the constraints files.
1414
*
15-
* Users can also use the VPR option --floorplan_split to specify which constraints files they would like to generate.
16-
* The options for floorplan_split include halves, quadrants, sixteenths and one_spot. One constraints file will be generated
17-
* in each case. The default setting for floorplan_split is halves.
15+
* The routines in this file are currently used to generate floorplan constraints for testing purposes.
16+
* The constraints files they generate are used to determine whether VPR is correctly adhering to
17+
* floorplan constraints during its packing and placement stages.
1818
*
19-
* If the user specified halves, two floorplanning partitions would be created which each take up one half of the grid.
20-
* The generated constraints file would assign all primitives to one of the two partitions that were created.
21-
* The same idea applies for the quadrants and sixteenths options, except that the floorplan partitions would split the
22-
* grid into quadrants and sixteenths respectively, as the names imply.
23-
*
24-
* If the one_spot option is specified, all blocks will be locked to their original placement spot.The vpr options
25-
* --place_constraint_subtile and --place_constraint_expand can be used in this case to specify whether
26-
* the blocks should also be locked down to a particular subtile, or whether the constraint region should expand beyond one spot.
19+
* The placer options --floorplan_num_horizontal_partitions (int) and --floorplan_num_vertical_partitions (int) can be used
20+
* to specify how many partitions should be created in the test constraints file.
21+
* For example, if both options are 2, the constraints file will split the grid into quadrants, dividing the blocks between
22+
* four partitions - two partitions in the horizontal dimension, and two partitions in the vertical dimension.
2723
*/
2824

2925
#ifndef VPR_SRC_BASE_VPR_CONSTRAINTS_WRITER_H_
@@ -39,14 +35,16 @@
3935
* @param subtile Specifies whether to write out the constraint regions with or without
4036
* subtile values.
4137
*/
42-
void write_vpr_floorplan_constraints(const char* file_name, int expand, bool subtile, enum constraints_split_factor floorplan_split);
38+
void write_vpr_floorplan_constraints(const char* file_name, int expand, bool subtile, int horizontal_partitions, int vertical_partitions);
4339

44-
void setup_vpr_floorplan_constraints(VprConstraints& constraints, int expand, bool subtile);
40+
//Generate constraints which lock all blocks to one location.
41+
void setup_vpr_floorplan_constraints_one_loc(VprConstraints& constraints, int expand, bool subtile);
4542

43+
/* Generate constraints which divide the grid into partition according to the horizontal and vertical partition values passed in
44+
* and lock down blocks to their appropriate partition.
45+
*/
4646
void setup_vpr_floorplan_constraints_cutpoints(VprConstraints& constraints, int horizontal_cutpoints, int vertical_cutpoints);
4747

48-
void setup_vpr_floorplan_constraints_half(VprConstraints& constraints, int expand, bool subtile);
49-
5048
void create_partition(Partition& part, std::string part_name, int xmin, int ymin, int xmax, int ymax);
5149

5250
#endif /* VPR_SRC_BASE_VPR_CONSTRAINTS_WRITER_H_ */

vpr/src/base/vpr_types.h

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -928,13 +928,6 @@ enum e_pad_loc_type {
928928
RANDOM
929929
};
930930

931-
enum constraints_split_factor {
932-
HALVES,
933-
QUADRANTS,
934-
SIXTEENTHS,
935-
ONE_SPOT
936-
};
937-
938931
/**
939932
* @brief Used to determine the RL agent's algorithm
940933
*
@@ -1029,9 +1022,6 @@ enum class e_place_delta_delay_algorithm {
10291022
* @param place_constraint_subtile
10301023
* True if subtiles should be specified when printing floorplan
10311024
* constraints. False if not.
1032-
* @param floorplan split
1033-
* Option specifying whether to split floorplan constraint regions into
1034-
* halves, quadrants, sixteenths, or one_spot.
10351025
*/
10361026
struct t_placer_opts {
10371027
t_place_algorithm place_algorithm;
@@ -1085,7 +1075,8 @@ struct t_placer_opts {
10851075
float place_crit_limit;
10861076
int place_constraint_expand;
10871077
bool place_constraint_subtile;
1088-
enum constraints_split_factor floorplan_split;
1078+
int floorplan_num_horizontal_partitions;
1079+
int floorplan_num_vertical_partitions;
10891080

10901081
/**
10911082
* @brief Tile types that should be used during delay sampling.

vpr/src/pack/attraction_groups.cpp

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -42,45 +42,6 @@ AttractionInfo::AttractionInfo(bool attraction_groups_on) {
4242
}
4343
}
4444

45-
void AttractionInfo::reset_attraction_groups() {
46-
auto& floorplanning_ctx = g_vpr_ctx.mutable_floorplanning();
47-
auto& atom_ctx = g_vpr_ctx.atom();
48-
int num_parts = floorplanning_ctx.constraints.get_num_partitions();
49-
50-
//clear the data structures before continuing
51-
atom_attraction_group.clear();
52-
attraction_groups.clear();
53-
//Initialize every atom to have no attraction group id
54-
int num_atoms = atom_ctx.nlist.blocks().size();
55-
56-
atom_attraction_group.resize(num_atoms);
57-
fill(atom_attraction_group.begin(), atom_attraction_group.end(), AttractGroupId::INVALID());
58-
59-
for (int ipart = 0; ipart < num_parts; ipart++) {
60-
PartitionId partid(ipart);
61-
62-
AttractionGroup group_info;
63-
group_info.group_atoms = floorplanning_ctx.constraints.get_part_atoms(partid);
64-
65-
attraction_groups.push_back(group_info);
66-
}
67-
68-
//Then, fill in the group id for the atoms that do have an attraction group
69-
int num_att_grps = attraction_groups.size();
70-
71-
for (int igroup = 0; igroup < num_att_grps; igroup++) {
72-
AttractGroupId group_id(igroup);
73-
74-
AttractionGroup att_group = attraction_groups[group_id];
75-
76-
for (unsigned int iatom = 0; iatom < att_group.group_atoms.size(); iatom++) {
77-
atom_attraction_group[att_group.group_atoms[iatom]] = group_id;
78-
}
79-
}
80-
81-
VTR_LOG("%d attraction groups were created \n", num_att_grps);
82-
}
83-
8445
void AttractionInfo::create_att_groups_for_overfull_regions() {
8546
auto& floorplanning_ctx = g_vpr_ctx.mutable_floorplanning();
8647
auto& atom_ctx = g_vpr_ctx.atom();
@@ -143,11 +104,7 @@ void AttractionInfo::create_att_groups_for_overfull_regions() {
143104

144105
att_group_pulls = 1;
145106

146-
VTR_LOG("Number of attraction groups created is %d \n", num_att_grps);
147-
}
148-
149-
AttractionGroup& AttractionInfo::get_attraction_group_info(const AttractGroupId group_id) {
150-
return attraction_groups[group_id];
107+
VTR_LOG("%d clustering attraction groups created. \n", num_att_grps);
151108
}
152109

153110
void AttractionInfo::set_attraction_group_info(AttractGroupId group_id, const AttractionGroup& group_info) {

vpr/src/pack/attraction_groups.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ class AttractionInfo {
5050
//If no constraints were specified, then no attraction groups will be created.
5151
AttractionInfo(bool attraction_groups_on);
5252

53-
void reset_attraction_groups();
54-
5553
void create_att_groups_for_overfull_regions();
5654

5755
//Setters and getters for the class
@@ -83,7 +81,12 @@ class AttractionInfo {
8381
//Store atoms and gain value that belong to each attraction group
8482
vtr::vector<AttractGroupId, AttractionGroup> attraction_groups;
8583

86-
//The number of times we explore a cluster's attraction group molecules when packing a cluster
84+
/* When packing a cluster with molecules, we have various ways of seeking candidates molecule
85+
* candidates for the cluster. The att_group_pulls value is a way of keeping count of how many
86+
* times a cluster has searched for candidate molecules from its attraction group. We can increase
87+
* this value if we want to pack the cluster more densely (i.e. fill it with more molecules from
88+
* its attraction group).
89+
*/
8790
int att_group_pulls = 1;
8891
};
8992

@@ -116,4 +119,8 @@ inline void AttractionInfo::set_attraction_group_gain(const AttractGroupId group
116119
attraction_groups[group_id].gain = new_gain;
117120
}
118121

122+
inline AttractionGroup& AttractionInfo::get_attraction_group_info(const AttractGroupId group_id) {
123+
return attraction_groups[group_id];
124+
}
125+
119126
#endif /* VPR_SRC_PACK_ATTRACTION_GROUPS_H_ */

0 commit comments

Comments
 (0)