Skip to content

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 18 commits into from
Jul 30, 2021
Merged
Show file tree
Hide file tree
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 Jul 5, 2021
d2c2349
Load attraction groups during prepacking
sfkhalid Jul 6, 2021
18966b5
Return highest gain molecule that also matches cluster's attraction g…
sfkhalid Jul 14, 2021
c080163
Added attraction gain to relevent atoms in update_total_gain during c…
sfkhalid Jul 14, 2021
ad5421f
Ran make format and added a routine to add cluster molecule candidate…
sfkhalid Jul 15, 2021
5653598
Added comment to routine for adding cluster molecule candidates by at…
sfkhalid Jul 15, 2021
9f6a324
Used attraction groups class constructor to create attraction groups …
sfkhalid Jul 21, 2021
95cdf56
Added changes to attraction groups class - made some functions inline…
sfkhalid Jul 21, 2021
683a3a9
Added comments to attraction groups class
sfkhalid Jul 21, 2021
f17da20
Got rid of unnecssary variables such as has_attraction_group in t_pb_…
sfkhalid Jul 21, 2021
59afa1c
Made a couple of fixes to get rid of warnings about variables being u…
sfkhalid Jul 22, 2021
b6217be
Refactored the functions that add cluster molecule candidates by movi…
sfkhalid Jul 22, 2021
1ae7dc3
Removed an unused variable to fix compiler warning
sfkhalid Jul 22, 2021
f262a97
Added comments to clarify attraction groups-related code
sfkhalid Jul 26, 2021
4dc0fe4
Added command line option to turn attraction groups on or off
sfkhalid Jul 27, 2021
c928ade
Added comment to attraction groups constructor to explain how it will…
sfkhalid Jul 29, 2021
fbb9337
Changed attraction group default gain
sfkhalid Jul 29, 2021
07127de
Added comments for functions related to adding cluster molecule candi…
sfkhalid Jul 30, 2021
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
49 changes: 49 additions & 0 deletions vpr/src/pack/attraction_groups.cpp
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);
}
105 changes: 105 additions & 0 deletions vpr/src/pack/attraction_groups.h
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.
*/

/// @brief Type tag for AttractGroupId
struct attraction_id_tag;

/// @brief A unique identifier for a partition
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;
};

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);

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
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_ */
Loading