Skip to content
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

[IntraClusterPlacement] Code Cleanup #2757

Merged
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
4 changes: 2 additions & 2 deletions vpr/src/pack/cluster_legalizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ try_place_atom_block_rec(const t_pb_graph_node* pb_graph_node,
const int max_cluster_size,
const LegalizationClusterId cluster_id,
vtr::vector_map<AtomBlockId, LegalizationClusterId>& atom_cluster,
const t_cluster_placement_stats* cluster_placement_stats_ptr,
const t_intra_cluster_placement_stats* cluster_placement_stats_ptr,
const t_pack_molecule* molecule,
t_lb_router_data* router_data,
int verbosity,
Expand Down Expand Up @@ -1475,7 +1475,7 @@ ClusterLegalizer::start_new_cluster(t_pack_molecule* molecule,
cluster_type);

// Allocate and load the cluster's placement stats
t_cluster_placement_stats* cluster_placement_stats = alloc_and_load_cluster_placement_stats(cluster_type, cluster_mode);
t_intra_cluster_placement_stats* cluster_placement_stats = alloc_and_load_cluster_placement_stats(cluster_type, cluster_mode);

// Create the new cluster
LegalizationCluster new_cluster;
Expand Down
4 changes: 2 additions & 2 deletions vpr/src/pack/cluster_legalizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include "vtr_vector_map.h"

class Prepacker;
class t_cluster_placement_stats;
class t_intra_cluster_placement_stats;
class t_pb_graph_node;
struct t_lb_router_data;

Expand Down Expand Up @@ -96,7 +96,7 @@ struct LegalizationCluster {
/// @brief The stats on where the different atoms in the cluster are currently
/// placed in the cluster. This is used when the legalizer decides
/// what sites it should try to put a new molecule into.
t_cluster_placement_stats* placement_stats;
t_intra_cluster_placement_stats* placement_stats;
};

/*
Expand Down
60 changes: 30 additions & 30 deletions vpr/src/pack/cluster_placement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,26 @@
/*Local Function Declaration */
/****************************************/

static void load_cluster_placement_stats_for_pb_graph_node(t_cluster_placement_stats* cluster_placement_stats,
static void load_cluster_placement_stats_for_pb_graph_node(t_intra_cluster_placement_stats* cluster_placement_stats,
t_pb_graph_node* pb_graph_node);

static void reset_cluster_placement_stats(t_cluster_placement_stats* cluster_placement_stats);
static void reset_cluster_placement_stats(t_intra_cluster_placement_stats* cluster_placement_stats);

static void set_mode_cluster_placement_stats(t_cluster_placement_stats* cluster_placement_stats,
static void set_mode_cluster_placement_stats(t_intra_cluster_placement_stats* cluster_placement_stats,
const t_pb_graph_node* pb_graph_node,
int mode);

static void update_primitive_cost_or_status(t_cluster_placement_stats* cluster_placement_stats,
static void update_primitive_cost_or_status(t_intra_cluster_placement_stats* cluster_placement_stats,
const t_pb_graph_node* pb_graph_node,
float incremental_cost,
bool valid);

static float try_place_molecule(t_cluster_placement_stats* cluster_placement_stats,
static float try_place_molecule(t_intra_cluster_placement_stats* cluster_placement_stats,
const t_pack_molecule* molecule,
t_pb_graph_node* root,
t_pb_graph_node** primitives_list);

static bool expand_forced_pack_molecule_placement(t_cluster_placement_stats* cluster_placement_stats,
static bool expand_forced_pack_molecule_placement(t_intra_cluster_placement_stats* cluster_placement_stats,
const t_pack_molecule* molecule,
const t_pack_pattern_block* pack_pattern_block,
t_pb_graph_node** primitives_list,
Expand All @@ -61,17 +61,17 @@ static t_pb_graph_pin* expand_pack_molecule_pin_edge(int pattern_id,
/*Function Definitions */
/****************************************/

void t_cluster_placement_stats::move_inflight_to_tried() {
void t_intra_cluster_placement_stats::move_inflight_to_tried() {
tried.insert(*in_flight.begin());
in_flight.clear();
}

void t_cluster_placement_stats::invalidate_primitive_and_increment_iterator(int pb_type_index, std::unordered_multimap<int, t_cluster_placement_primitive*>::iterator& it) {
void t_intra_cluster_placement_stats::invalidate_primitive_and_increment_iterator(int pb_type_index, std::unordered_multimap<int, t_cluster_placement_primitive*>::iterator& it) {
invalid.insert(*it);
valid_primitives[pb_type_index].erase(it++);
}

void t_cluster_placement_stats::move_primitive_to_inflight(int pb_type_index, std::unordered_multimap<int, t_cluster_placement_primitive*>::iterator& it) {
void t_intra_cluster_placement_stats::move_primitive_to_inflight(int pb_type_index, std::unordered_multimap<int, t_cluster_placement_primitive*>::iterator& it) {
in_flight.insert(*it);
valid_primitives[pb_type_index].erase(it);
}
Expand All @@ -81,7 +81,7 @@ void t_cluster_placement_stats::move_primitive_to_inflight(int pb_type_index, st
*
* @note that valid status is not changed because if the primitive is not valid, it will get properly collected later
*/
void t_cluster_placement_stats::insert_primitive_in_valid_primitives(std::pair<int, t_cluster_placement_primitive*> cluster_placement_primitive) {
void t_intra_cluster_placement_stats::insert_primitive_in_valid_primitives(std::pair<int, t_cluster_placement_primitive*> cluster_placement_primitive) {
int i;
bool success = false;
int null_index = OPEN;
Expand All @@ -105,31 +105,31 @@ void t_cluster_placement_stats::insert_primitive_in_valid_primitives(std::pair<i
}
}

void t_cluster_placement_stats::flush_queue(std::unordered_multimap<int, t_cluster_placement_primitive*>& queue) {
void t_intra_cluster_placement_stats::flush_queue(std::unordered_multimap<int, t_cluster_placement_primitive*>& queue) {
for (auto& it : queue) {
insert_primitive_in_valid_primitives(it);
}
queue.clear();
}

void t_cluster_placement_stats::flush_intermediate_queues() {
void t_intra_cluster_placement_stats::flush_intermediate_queues() {
flush_queue(in_flight);
flush_queue(tried);
}

void t_cluster_placement_stats::flush_invalid_queue() {
void t_intra_cluster_placement_stats::flush_invalid_queue() {
flush_queue(invalid);
}

bool t_cluster_placement_stats::in_flight_empty() {
bool t_intra_cluster_placement_stats::in_flight_empty() {
return in_flight.empty();
}

t_pb_type* t_cluster_placement_stats::in_flight_type() {
t_pb_type* t_intra_cluster_placement_stats::in_flight_type() {
return in_flight.begin()->second->pb_graph_node->pb_type;
}

void t_cluster_placement_stats::free_primitives() {
void t_intra_cluster_placement_stats::free_primitives() {
for (auto& primitive : tried)
delete primitive.second;

Expand All @@ -146,10 +146,10 @@ void t_cluster_placement_stats::free_primitives() {
}
}

t_cluster_placement_stats* alloc_and_load_cluster_placement_stats(t_logical_block_type_ptr cluster_type,
t_intra_cluster_placement_stats* alloc_and_load_cluster_placement_stats(t_logical_block_type_ptr cluster_type,
int cluster_mode) {
t_cluster_placement_stats* cluster_placement_stats = new t_cluster_placement_stats;
*cluster_placement_stats = t_cluster_placement_stats();
t_intra_cluster_placement_stats* cluster_placement_stats = new t_intra_cluster_placement_stats;
*cluster_placement_stats = t_intra_cluster_placement_stats();
// TODO: This initialization may be able to be made more efficient.
// The reset and setting the mode can be done while loading the placement
// stats.
Expand All @@ -165,14 +165,14 @@ t_cluster_placement_stats* alloc_and_load_cluster_placement_stats(t_logical_bloc
return cluster_placement_stats;
}

void free_cluster_placement_stats(t_cluster_placement_stats* cluster_placement_stats) {
void free_cluster_placement_stats(t_intra_cluster_placement_stats* cluster_placement_stats) {
if (cluster_placement_stats != nullptr) {
cluster_placement_stats->free_primitives();
delete cluster_placement_stats;
}
}

bool get_next_primitive_list(t_cluster_placement_stats* cluster_placement_stats,
bool get_next_primitive_list(t_intra_cluster_placement_stats* cluster_placement_stats,
const t_pack_molecule* molecule,
t_pb_graph_node** primitives_list,
int force_site) {
Expand Down Expand Up @@ -299,7 +299,7 @@ bool get_next_primitive_list(t_cluster_placement_stats* cluster_placement_stats,
/**
* Resets one cluster placement stats by clearing incremental costs and returning all primitives to valid queue
*/
static void reset_cluster_placement_stats(t_cluster_placement_stats* cluster_placement_stats) {
static void reset_cluster_placement_stats(t_intra_cluster_placement_stats* cluster_placement_stats) {
int i;

/* Requeue primitives */
Expand All @@ -321,7 +321,7 @@ static void reset_cluster_placement_stats(t_cluster_placement_stats* cluster_pla
* Add any primitives found in pb_graph_nodes to cluster_placement_stats
* Adds backward link from pb_graph_node to cluster_placement_primitive
*/
static void load_cluster_placement_stats_for_pb_graph_node(t_cluster_placement_stats* cluster_placement_stats,
static void load_cluster_placement_stats_for_pb_graph_node(t_intra_cluster_placement_stats* cluster_placement_stats,
t_pb_graph_node* pb_graph_node) {
int i, j, k;
t_cluster_placement_primitive* placement_primitive;
Expand Down Expand Up @@ -375,7 +375,7 @@ static void load_cluster_placement_stats_for_pb_graph_node(t_cluster_placement_s
}
}

void commit_primitive(t_cluster_placement_stats* cluster_placement_stats,
void commit_primitive(t_intra_cluster_placement_stats* cluster_placement_stats,
const t_pb_graph_node* primitive) {
t_pb_graph_node *pb_graph_node, *skip;
float incr_cost;
Expand Down Expand Up @@ -417,7 +417,7 @@ void commit_primitive(t_cluster_placement_stats* cluster_placement_stats,
/**
* Set mode of cluster
*/
static void set_mode_cluster_placement_stats(t_cluster_placement_stats* cluster_placement_stats,
static void set_mode_cluster_placement_stats(t_intra_cluster_placement_stats* cluster_placement_stats,
const t_pb_graph_node* pb_graph_node,
int mode) {
int i, j, k;
Expand All @@ -440,7 +440,7 @@ static void set_mode_cluster_placement_stats(t_cluster_placement_stats* cluster_
* For modes invalidated by pb_graph_node, invalidate primitive
* int distance is the distance of current pb_graph_node from original
*/
static void update_primitive_cost_or_status(t_cluster_placement_stats* cluster_placement_stats,
static void update_primitive_cost_or_status(t_intra_cluster_placement_stats* cluster_placement_stats,
const t_pb_graph_node* pb_graph_node,
const float incremental_cost,
const bool valid) {
Expand Down Expand Up @@ -470,7 +470,7 @@ static void update_primitive_cost_or_status(t_cluster_placement_stats* cluster_p
/**
* Try place molecule at root location, populate primitives list with locations of placement if successful
*/
static float try_place_molecule(t_cluster_placement_stats* cluster_placement_stats,
static float try_place_molecule(t_intra_cluster_placement_stats* cluster_placement_stats,
const t_pack_molecule* molecule,
t_pb_graph_node* root,
t_pb_graph_node** primitives_list) {
Expand Down Expand Up @@ -516,7 +516,7 @@ static float try_place_molecule(t_cluster_placement_stats* cluster_placement_sta
* Expand molecule at pb_graph_node
* Assumes molecule and pack pattern connections have fan-out 1
*/
static bool expand_forced_pack_molecule_placement(t_cluster_placement_stats* cluster_placement_stats,
static bool expand_forced_pack_molecule_placement(t_intra_cluster_placement_stats* cluster_placement_stats,
const t_pack_molecule* molecule,
const t_pack_pattern_block* pack_pattern_block,
t_pb_graph_node** primitives_list,
Expand Down Expand Up @@ -695,7 +695,7 @@ int get_array_size_of_molecule(const t_pack_molecule* molecule) {
}

/* Given atom block, determines if a free primitive exists for it */
bool exists_free_primitive_for_atom_block(t_cluster_placement_stats* cluster_placement_stats,
bool exists_free_primitive_for_atom_block(t_intra_cluster_placement_stats* cluster_placement_stats,
const AtomBlockId blk_id) {
int i;

Expand Down Expand Up @@ -724,6 +724,6 @@ bool exists_free_primitive_for_atom_block(t_cluster_placement_stats* cluster_pla
return false;
}

void reset_tried_but_unused_cluster_placements(t_cluster_placement_stats* cluster_placement_stats) {
void reset_tried_but_unused_cluster_placements(t_intra_cluster_placement_stats* cluster_placement_stats) {
cluster_placement_stats->flush_intermediate_queues();
}
14 changes: 7 additions & 7 deletions vpr/src/pack/cluster_placement.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*
* Contains data structure of placement locations based on status of primitive
*/
class t_cluster_placement_stats {
class t_intra_cluster_placement_stats {
public:
int num_pb_types; ///<num primitive pb_types inside complex block
bool has_long_chain; ///<specifies if this cluster has a molecule placed in it that belongs to a long chain (a chain that spans more than one cluster)
Expand Down Expand Up @@ -131,13 +131,13 @@ class t_cluster_placement_stats {
*
* The pointer returned by this method must be freed.
*/
t_cluster_placement_stats* alloc_and_load_cluster_placement_stats(t_logical_block_type_ptr cluster_type,
t_intra_cluster_placement_stats* alloc_and_load_cluster_placement_stats(t_logical_block_type_ptr cluster_type,
int cluster_mode);

/**
* @brief Frees the cluster placement stats of a cluster.
*/
void free_cluster_placement_stats(t_cluster_placement_stats* cluster_placement_stats);
void free_cluster_placement_stats(t_intra_cluster_placement_stats* cluster_placement_stats);

/**
* get next list of primitives for list of atom blocks
Expand All @@ -158,7 +158,7 @@ void free_cluster_placement_stats(t_cluster_placement_stats* cluster_placement_s
* If the force_site argument is set to its default value (-1), vpr selects an available site.
*/
bool get_next_primitive_list(
t_cluster_placement_stats* cluster_placement_stats,
t_intra_cluster_placement_stats* cluster_placement_stats,
const t_pack_molecule* molecule,
t_pb_graph_node** primitives_list,
int force_site = -1);
Expand All @@ -170,7 +170,7 @@ bool get_next_primitive_list(
* Side effects: All cluster_placement_primitives may be invalidated/costed in this algorithm
* Al intermediate queues are requeued
*/
void commit_primitive(t_cluster_placement_stats* cluster_placement_stats,
void commit_primitive(t_intra_cluster_placement_stats* cluster_placement_stats,
const t_pb_graph_node* primitive);

/**
Expand All @@ -182,10 +182,10 @@ int get_array_size_of_molecule(const t_pack_molecule* molecule);
* @brief Given atom block, determines if a free primitive exists for it,
*/
bool exists_free_primitive_for_atom_block(
t_cluster_placement_stats* cluster_placement_stats,
t_intra_cluster_placement_stats* cluster_placement_stats,
const AtomBlockId blk_id);

void reset_tried_but_unused_cluster_placements(
t_cluster_placement_stats* cluster_placement_stats);
t_intra_cluster_placement_stats* cluster_placement_stats);

#endif
Loading