-
Notifications
You must be signed in to change notification settings - Fork 415
Cluster attraction groups #1802
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
Changes from 13 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
04c3d8a
Add comment for attraction group gain in clusterer
sfkhalid d2c2349
Load attraction groups during prepacking
sfkhalid 18966b5
Return highest gain molecule that also matches cluster's attraction g…
sfkhalid c080163
Added attraction gain to relevent atoms in update_total_gain during c…
sfkhalid ad5421f
Ran make format and added a routine to add cluster molecule candidate…
sfkhalid 5653598
Added comment to routine for adding cluster molecule candidates by at…
sfkhalid 9f6a324
Used attraction groups class constructor to create attraction groups …
sfkhalid 95cdf56
Added changes to attraction groups class - made some functions inline…
sfkhalid 683a3a9
Added comments to attraction groups class
sfkhalid f17da20
Got rid of unnecssary variables such as has_attraction_group in t_pb_…
sfkhalid 59afa1c
Made a couple of fixes to get rid of warnings about variables being u…
sfkhalid b6217be
Refactored the functions that add cluster molecule candidates by movi…
sfkhalid 1ae7dc3
Removed an unused variable to fix compiler warning
sfkhalid f262a97
Added comments to clarify attraction groups-related code
sfkhalid 4dc0fe4
Added command line option to turn attraction groups on or off
sfkhalid c928ade
Added comment to attraction groups constructor to explain how it will…
sfkhalid fbb9337
Changed attraction group default gain
sfkhalid 07127de
Added comments for functions related to adding cluster molecule candi…
sfkhalid File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#include "attraction_groups.h" | ||
|
||
AttractionInfo::AttractionInfo() { | ||
auto& floorplanning_ctx = g_vpr_ctx.mutable_floorplanning(); | ||
auto& atom_ctx = g_vpr_ctx.atom(); | ||
int num_parts = floorplanning_ctx.constraints.get_num_partitions(); | ||
|
||
//Create an attraction group for each partition in the floorplanning constraints | ||
for (int ipart = 0; ipart < num_parts; ipart++) { | ||
PartitionId partid(ipart); | ||
Partition part = floorplanning_ctx.constraints.get_partition(partid); | ||
|
||
AttractionGroup group_info; | ||
group_info.group_atoms = floorplanning_ctx.constraints.get_part_atoms(partid); | ||
|
||
attraction_groups.push_back(group_info); | ||
} | ||
|
||
//Initialize every atom to have no attraction group id | ||
int num_atoms = atom_ctx.nlist.blocks().size(); | ||
|
||
atom_attraction_group.resize(num_atoms); | ||
fill(atom_attraction_group.begin(), atom_attraction_group.end(), AttractGroupId::INVALID()); | ||
|
||
//Then, fill in the group id for the atoms that do have an attraction group | ||
int num_att_grps = attraction_groups.size(); | ||
|
||
for (int igroup = 0; igroup < num_att_grps; igroup++) { | ||
AttractGroupId group_id(igroup); | ||
|
||
AttractionGroup att_group = attraction_groups[group_id]; | ||
|
||
for (unsigned int iatom = 0; iatom < att_group.group_atoms.size(); iatom++) { | ||
atom_attraction_group[att_group.group_atoms[iatom]] = group_id; | ||
} | ||
} | ||
} | ||
|
||
AttractionGroup AttractionInfo::get_attraction_group_info(const AttractGroupId group_id) { | ||
return attraction_groups[group_id]; | ||
} | ||
|
||
void AttractionInfo::set_attraction_group_info(AttractGroupId group_id, const AttractionGroup& group_info) { | ||
attraction_groups[group_id] = group_info; | ||
} | ||
|
||
void AttractionInfo::add_attraction_group(const AttractionGroup& group_info) { | ||
attraction_groups.push_back(group_info); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
/* | ||
* attraction_groups.h | ||
* | ||
* Created on: Jun. 13, 2021 | ||
* Author: khalid88 | ||
*/ | ||
|
||
#ifndef VPR_SRC_PACK_ATTRACTION_GROUPS_H_ | ||
#define VPR_SRC_PACK_ATTRACTION_GROUPS_H_ | ||
|
||
#include "vtr_strong_id.h" | ||
#include "vtr_vector.h" | ||
#include "atom_netlist.h" | ||
#include "globals.h" | ||
|
||
/** | ||
* @file | ||
* @brief This file defines the AttractionInfo class, which is used to store atoms in attraction groups, which are | ||
* used during the clustering process. | ||
* | ||
* Overview | ||
* ======== | ||
* Attraction groups are used during the clustering process to tell the clusterer which atoms should be packed | ||
* in the same cluster by virtue of having the same floorplan constraints. The attraction groups may also be | ||
* used to cluster similar atoms together in other ways in the future. | ||
*/ | ||
|
||
sfkhalid marked this conversation as resolved.
Show resolved
Hide resolved
|
||
/// @brief Type tag for AttractGroupId | ||
struct attraction_id_tag; | ||
|
||
/// @brief A unique identifier for a partition | ||
sfkhalid marked this conversation as resolved.
Show resolved
Hide resolved
|
||
typedef vtr::StrongId<attraction_id_tag> AttractGroupId; | ||
|
||
struct AttractionGroup { | ||
//stores all atoms in the attraction group | ||
std::vector<AtomBlockId> group_atoms; | ||
|
||
/* | ||
* Atoms belonging to this attraction group will receive this gain if they | ||
* are potential candidates to be put in a cluster with the same attraction group. | ||
*/ | ||
float gain = 3; | ||
|
||
/* | ||
* If the group is made up from a partition of atoms that are confined to a size one spot | ||
* (i.e. one x, y grid location), the clusterer will immediately put all atoms in the group | ||
* into the same cluster | ||
*/ | ||
/* TODO: Add the code in the clusterer that will do the above steps. */ | ||
bool region_size_one = false; | ||
sfkhalid marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}; | ||
|
||
class AttractionInfo { | ||
public: | ||
//Constructor that fills in the attraction groups based on vpr's floorplan constraints. | ||
//If no constraints were specified, then no attraction groups will be created. | ||
AttractionInfo(); | ||
|
||
//Setters and getters for the class | ||
AttractGroupId get_atom_attraction_group(const AtomBlockId atom_id); | ||
|
||
AttractionGroup get_attraction_group_info(const AttractGroupId group_id); | ||
sfkhalid marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
void set_atom_attraction_group(const AtomBlockId atom_id, const AttractGroupId group_id); | ||
|
||
void set_attraction_group_info(AttractGroupId group_id, const AttractionGroup& group_info); | ||
|
||
float get_attraction_group_gain(const AttractGroupId group_id); | ||
|
||
void set_attraction_group_gain(const AttractGroupId group_id, const float new_gain); | ||
|
||
void add_attraction_group(const AttractionGroup& group_info); | ||
|
||
int num_attraction_groups(); | ||
|
||
private: | ||
//Store each atom's attraction group assuming each atom is in at most one attraction group | ||
sfkhalid marked this conversation as resolved.
Show resolved
Hide resolved
|
||
vtr::vector<AtomBlockId, AttractGroupId> atom_attraction_group; | ||
|
||
//Store atoms and gain value that belong to each attraction group | ||
vtr::vector<AttractGroupId, AttractionGroup> attraction_groups; | ||
}; | ||
|
||
inline AttractGroupId AttractionInfo::get_atom_attraction_group(const AtomBlockId atom_id) { | ||
return atom_attraction_group[atom_id]; | ||
} | ||
|
||
inline void AttractionInfo::set_atom_attraction_group(const AtomBlockId atom_id, const AttractGroupId group_id) { | ||
atom_attraction_group[atom_id] = group_id; | ||
attraction_groups[group_id].group_atoms.push_back(atom_id); | ||
} | ||
|
||
inline int AttractionInfo::num_attraction_groups() { | ||
return attraction_groups.size(); | ||
} | ||
|
||
inline float AttractionInfo::get_attraction_group_gain(const AttractGroupId group_id) { | ||
return attraction_groups[group_id].gain; | ||
} | ||
|
||
inline void AttractionInfo::set_attraction_group_gain(const AttractGroupId group_id, const float new_gain) { | ||
attraction_groups[group_id].gain = new_gain; | ||
} | ||
|
||
#endif /* VPR_SRC_PACK_ATTRACTION_GROUPS_H_ */ |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.