Skip to content

Commit

Permalink
add blk_loc_registry.cpp/.h
Browse files Browse the repository at this point in the history
  • Loading branch information
soheilshahrouz committed Aug 12, 2024
1 parent a6ffb7b commit 1ecf07c
Show file tree
Hide file tree
Showing 9 changed files with 101 additions and 49 deletions.
40 changes: 40 additions & 0 deletions vpr/src/base/blk_loc_registry.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@

#include "blk_loc_registry.h"
#include "globals.h"

const vtr::vector_map<ClusterBlockId, t_block_loc>& BlkLocRegistry::block_locs() const {
return block_locs_;
}

vtr::vector_map<ClusterBlockId, t_block_loc>& BlkLocRegistry::mutable_block_locs() {
return block_locs_;
}

const GridBlock& BlkLocRegistry::grid_blocks() const {
return grid_blocks_;
}

GridBlock& BlkLocRegistry::mutable_grid_blocks() {
return grid_blocks_;
}

const vtr::vector_map<ClusterPinId, int>& BlkLocRegistry::physical_pins() const {
return physical_pins_;
}

vtr::vector_map<ClusterPinId, int>& BlkLocRegistry::mutable_physical_pins() {
return physical_pins_;
}

int BlkLocRegistry::tile_pin_index(const ClusterPinId pin) const {
return physical_pins_[pin];
}

int BlkLocRegistry::net_pin_to_tile_pin_index(const ClusterNetId net_id, int net_pin_index) const {
auto& cluster_ctx = g_vpr_ctx.clustering();

// Get the logical pin index of pin within its logical block type
ClusterPinId pin_id = cluster_ctx.clb_nlist.net_pin(net_id, net_pin_index);

return this->tile_pin_index(pin_id);
}
46 changes: 46 additions & 0 deletions vpr/src/base/blk_loc_registry.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#ifndef VTR_BLK_LOC_REGISTRY_H
#define VTR_BLK_LOC_REGISTRY_H

#include "clustered_netlist_fwd.h"
#include "vtr_vector_map.h"
#include "vpr_types.h"

struct t_block_loc;

class BlkLocRegistry {
public:
BlkLocRegistry() = default;
~BlkLocRegistry() = default;
BlkLocRegistry(const BlkLocRegistry&) = delete;
BlkLocRegistry& operator=(const BlkLocRegistry&) = default;
BlkLocRegistry(BlkLocRegistry&&) = delete;
BlkLocRegistry& operator=(BlkLocRegistry&&) = delete;

private:
///@brief Clustered block placement locations
vtr::vector_map<ClusterBlockId, t_block_loc> block_locs_;

///@brief Clustered block associated with each grid location (i.e. inverse of block_locs)
GridBlock grid_blocks_;

///@brief Clustered pin placement mapping with physical pin
vtr::vector_map<ClusterPinId, int> physical_pins_;

public:
const vtr::vector_map<ClusterBlockId, t_block_loc>& block_locs() const;
vtr::vector_map<ClusterBlockId, t_block_loc>& mutable_block_locs();

const GridBlock& grid_blocks() const;
GridBlock& mutable_grid_blocks();

const vtr::vector_map<ClusterPinId, int>& physical_pins() const;
vtr::vector_map<ClusterPinId, int>& mutable_physical_pins();

///@brief Returns the physical pin of the tile, related to the given ClusterPinId
int tile_pin_index(const ClusterPinId pin) const;

///@brief Returns the physical pin of the tile, related to the given ClusterNedId, and the net pin index.
int net_pin_to_tile_pin_index(const ClusterNetId net_id, int net_pin_index) const;
};

#endif //VTR_BLK_LOC_REGISTRY_H
1 change: 1 addition & 0 deletions vpr/src/base/vpr_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "noc_traffic_flows.h"
#include "noc_routing.h"
#include "tatum/report/TimingPath.hpp"
#include "blk_loc_registry.h"

#ifndef NO_SERVER

Expand Down
9 changes: 0 additions & 9 deletions vpr/src/base/vpr_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -558,12 +558,3 @@ void t_cluster_placement_stats::free_primitives() {
}
}
}

int BlkLocRegistry::net_pin_to_tile_pin_index(const ClusterNetId net_id, int net_pin_index) const {
auto& cluster_ctx = g_vpr_ctx.clustering();

// Get the logical pin index of pin within its logical block type
ClusterPinId pin_id = cluster_ctx.clb_nlist.net_pin(net_id, net_pin_index);

return this->tile_pin_index(pin_id);
}
35 changes: 0 additions & 35 deletions vpr/src/base/vpr_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -907,41 +907,6 @@ class GridBlock {
vtr::NdMatrix<t_grid_blocks, 3> grid_blocks_;
};

class BlkLocRegistry {
public:
BlkLocRegistry() = default;
~BlkLocRegistry() = default;
BlkLocRegistry(const BlkLocRegistry&) = delete;
BlkLocRegistry& operator=(const BlkLocRegistry&) = default;
BlkLocRegistry(BlkLocRegistry&&) = delete;
BlkLocRegistry& operator=(BlkLocRegistry&&) = delete;

private:
///@brief Clustered block placement locations
vtr::vector_map<ClusterBlockId, t_block_loc> block_locs_;

///@brief Clustered block associated with each grid location (i.e. inverse of block_locs)
GridBlock grid_blocks_;

///@brief Clustered pin placement mapping with physical pin
vtr::vector_map<ClusterPinId, int> physical_pins_;

public:
inline const vtr::vector_map<ClusterBlockId, t_block_loc>& block_locs() const { return block_locs_; }
inline vtr::vector_map<ClusterBlockId, t_block_loc>& mutable_block_locs() { return block_locs_; }

inline const GridBlock& grid_blocks() const { return grid_blocks_; }
inline GridBlock& mutable_grid_blocks() { return grid_blocks_; }

inline const vtr::vector_map<ClusterPinId, int>& physical_pins() const { return physical_pins_; }
inline vtr::vector_map<ClusterPinId, int>& mutable_physical_pins() { return physical_pins_; }

///@brief Returns the physical pin of the tile, related to the given ClusterPinId
inline int tile_pin_index(const ClusterPinId pin) const { return physical_pins_[pin]; }

///@brief Returns the physical pin of the tile, related to the given ClusterNedId, and the net pin index.
int net_pin_to_tile_pin_index(const ClusterNetId net_id, int net_pin_index) const;
};

///@brief Names of various files
struct t_file_name_opts {
Expand Down
2 changes: 2 additions & 0 deletions vpr/src/place/initial_noc_placement.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@

#include "initial_noc_placment.h"

#include "vpr_types.h"
#include "initial_placement.h"
#include "noc_place_utils.h"
#include "noc_place_checkpoint.h"
Expand Down
10 changes: 6 additions & 4 deletions vpr/src/place/initial_noc_placment.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@

#ifndef VTR_INITIAL_NOC_PLACMENT_H
#define VTR_INITIAL_NOC_PLACMENT_H
#ifndef VTR_INITIAL_NOC_PLACEMENT_H
#define VTR_INITIAL_NOC_PLACEMENT_H

#include "vpr_types.h"
struct t_noc_opts;
struct t_placer_opts;
class BlkLocRegistry;

/**
* @brief Randomly places NoC routers, then runs a quick simulated annealing
Expand All @@ -17,4 +19,4 @@ void initial_noc_placement(const t_noc_opts& noc_opts,
const t_placer_opts& placer_opts,
BlkLocRegistry& blk_loc_registry);

#endif //VTR_INITIAL_NOC_PLACMENT_H
#endif //VTR_INITIAL_NOC_PLACEMENT_H
5 changes: 4 additions & 1 deletion vpr/src/place/move_transactions.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#ifndef VPR_MOVE_TRANSACTIONS_H
#define VPR_MOVE_TRANSACTIONS_H

#include "vpr_types.h"
#include "clustered_netlist_utils.h"

class BlkLocRegistry;

enum class e_block_move_result {
VALID, //Move successful
ABORT, //Unable to perform move
Expand Down Expand Up @@ -30,7 +33,7 @@ struct t_pl_moved_block {
* placement. *
* Store the information on the blocks to be moved in a swap during *
* placement, in the form of array of structs instead of struct with *
* arrays for cache effifiency *
* arrays for cache efficiency *
*
* moved blocks: a list of moved blocks data structure with *
* information on the move. *
Expand Down
2 changes: 2 additions & 0 deletions vpr/src/place/move_utils.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#ifndef VPR_MOVE_UTILS_H
#define VPR_MOVE_UTILS_H

#include "vpr_types.h"
#include "move_transactions.h"
#include "compressed_grid.h"

class PlacerState;
class BlkLocRegistry;

/* Cut off for incremental bounding box updates. *
* 4 is fastest -- I checked. */
Expand Down

0 comments on commit 1ecf07c

Please sign in to comment.