Skip to content

NocCostHandler class #2724

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 33 commits into from
Oct 6, 2024
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
acb812c
Merge branch 'temp_net_cost_ref' into temp_remove_static_vars_noc
soheilshahrouz Sep 9, 2024
3689cca
add NocCostHandler class and move some functions to it
soheilshahrouz Sep 9, 2024
b19360e
fix compilation errors in noc_place_utils
soheilshahrouz Sep 10, 2024
65d067a
fix compilation erros in place.cpp
soheilshahrouz Sep 10, 2024
29cc099
fix compilation errors in initial_noc_placement.cpp/.h
soheilshahrouz Sep 10, 2024
fd36ecf
fix compilation errors in initial_placement.cpp
soheilshahrouz Sep 10, 2024
de0344f
fix compilation error in noc_place_checkpoint.cpp
soheilshahrouz Sep 11, 2024
2042423
add recompute_costs_from_scratch() method to NocCostHandler
soheilshahrouz Sep 11, 2024
80d98f7
temp fix for remaining compilation errors
soheilshahrouz Sep 15, 2024
ea103df
store traffic flow routes locally in NocCostHandler
soheilshahrouz Sep 15, 2024
7906b79
store a backup of the current route to avoid rerouting when a swap is…
soheilshahrouz Sep 15, 2024
e4a0722
remove block_locs argument from NocCostHandler methods
soheilshahrouz Sep 15, 2024
508e502
Merge branch 'master' into temp_remove_static_vars_noc
soheilshahrouz Sep 21, 2024
b9d9a69
remove dead code
soheilshahrouz Sep 21, 2024
26ec8cd
limit the scope of constant values declared in noc_place_utils.h
soheilshahrouz Sep 21, 2024
ca9c748
const correctness in NocCostHandler
soheilshahrouz Sep 21, 2024
bffb451
include optional in initial_placement.h
soheilshahrouz Sep 21, 2024
9660eea
fix compilation error
soheilshahrouz Sep 21, 2024
a6ad2f7
Merge branch 'master' into temp_remove_static_vars_noc
soheilshahrouz Sep 24, 2024
9fa4157
Merge branch 'master' into temp_remove_static_vars_noc
soheilshahrouz Sep 28, 2024
7fd83b6
fix most of compilation errors in test_noc_place_utils
soheilshahrouz Sep 28, 2024
5ff98e7
add get_link_used_bandwidth() to NocCostHandler
soheilshahrouz Sep 29, 2024
3eb518f
update test_revert_noc_traffic_flow_routes to be compatible with NocC…
soheilshahrouz Sep 29, 2024
2053c65
update link bandwidth utilization when traffic flow routes are reverted
soheilshahrouz Sep 29, 2024
2c7f183
fix unit test failure for check_noc_placement_costs()
soheilshahrouz Sep 29, 2024
4bd8de3
delete move assignment operator and constructor of NetCostHandler
soheilshahrouz Sep 29, 2024
a699e67
pass NoC link bandwidth utilization to graphics
soheilshahrouz Sep 29, 2024
30d9dbf
add guard for set_noc_link_bandwidth_usages_ref call
soheilshahrouz Sep 29, 2024
57ff88e
apply PR comments
soheilshahrouz Sep 30, 2024
c5a4a15
rename ERROR_TOL to PL_INCREMENTAL_COST_TOLERANCE
soheilshahrouz Oct 1, 2024
d1eea5f
Merge remote-tracking branch 'origin/master' into temp_remove_static_…
soheilshahrouz Oct 2, 2024
eace358
move clear_all_grid_locs() to BlkLocRegistry
soheilshahrouz Oct 2, 2024
169b31c
apply PR comments
soheilshahrouz Oct 2, 2024
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
10 changes: 10 additions & 0 deletions vpr/src/draw/draw_global.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ static t_draw_coords draw_coords;
*/
static std::optional<std::reference_wrapper<const BlkLocRegistry>> blk_loc_registry_ref;

static std::optional<std::reference_wrapper<const vtr::vector<NocLinkId, double>>> noc_link_bandwidth_usages_ref;

/*********************** Accessor Subroutines Definition ********************/

/* This accessor function returns pointer to the global variable
Expand All @@ -55,4 +57,12 @@ const BlkLocRegistry& get_graphics_blk_loc_registry_ref() {
return blk_loc_registry_ref->get();
}

void set_noc_link_bandwidth_usages_ref(const vtr::vector<NocLinkId, double>& noc_link_bandwidth_usages) {
noc_link_bandwidth_usages_ref = noc_link_bandwidth_usages;
}

const vtr::vector<NocLinkId, double>& get_noc_link_bandwidth_usages_ref() {
return noc_link_bandwidth_usages_ref->get();
}

#endif // NO_GRAPHICS
4 changes: 4 additions & 0 deletions vpr/src/draw/draw_global.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ void set_graphics_blk_loc_registry_ref(const BlkLocRegistry& blk_loc_registry);
*/
const BlkLocRegistry& get_graphics_blk_loc_registry_ref();

void set_noc_link_bandwidth_usages_ref(const vtr::vector<NocLinkId, double>& noc_link_bandwidth_usages);

const vtr::vector<NocLinkId, double>& get_noc_link_bandwidth_usages_ref();

#endif // NO_GRAPHICS

#endif
7 changes: 4 additions & 3 deletions vpr/src/draw/draw_noc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ void draw_noc(ezgl::renderer* g) {
void draw_noc_usage(vtr::vector<NocLinkId, ezgl::color>& noc_link_colors) {
t_draw_state* draw_state = get_draw_state_vars();
auto& noc_ctx = g_vpr_ctx.noc();
const auto& noc_link_bandwidth_usages = get_noc_link_bandwidth_usages_ref();

// check to see if a color map was already created previously
if (draw_state->noc_usage_color_map == nullptr) {
Expand All @@ -90,15 +91,15 @@ void draw_noc_usage(vtr::vector<NocLinkId, ezgl::color>& noc_link_colors) {
// represents the color to draw each noc link
ezgl::color current_noc_link_color;

for (const auto& noc_link : noc_ctx.noc_model.get_noc_links()) {
NocLinkId link_id = noc_link.get_link_id();
for (const auto& [link_id, bandwidth_usage] : noc_link_bandwidth_usages.pairs()) {

// only update the color of the link if it wasn't updated previously
if (noc_link_colors[link_id] == ezgl::BLACK) {
// if we are here then the link was not updated previously, so assign the color here

double link_bandwidth = noc_ctx.noc_model.get_single_noc_link(link_id).get_bandwidth();
//get the current link bandwidth usage (ratio calculation)
double link_bandwidth_usage_ratio = (noc_link.get_bandwidth_usage()) / noc_link.get_bandwidth();
double link_bandwidth_usage_ratio = bandwidth_usage / link_bandwidth;

// check if the link is being overused and if it is then cap it at 1.0
if (link_bandwidth_usage_ratio > 1.0) {
Expand Down
25 changes: 0 additions & 25 deletions vpr/src/noc/noc_link.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ NocLink::NocLink(NocLinkId link_id, NocRouterId source, NocRouterId sink,
: id(link_id)
, source_router(source)
, sink_router(sink)
, bandwidth_usage(0.0)
, bandwidth(bw)
, latency(lat) { }

Expand All @@ -19,10 +18,6 @@ NocRouterId NocLink::get_sink_router() const {
return sink_router;
}

double NocLink::get_bandwidth_usage() const {
return bandwidth_usage;
}

//setters
void NocLink::set_source_router(NocRouterId source) {
source_router = source;
Expand All @@ -32,10 +27,6 @@ void NocLink::set_sink_router(NocRouterId sink) {
sink_router = sink;
}

void NocLink::set_bandwidth_usage(double new_bandwidth_usage) {
bandwidth_usage = new_bandwidth_usage;
}

void NocLink::set_bandwidth(double new_bandwidth) {
bandwidth = new_bandwidth;
}
Expand All @@ -44,22 +35,6 @@ double NocLink::get_bandwidth() const {
return bandwidth;
}

double NocLink::get_congested_bandwidth() const {
double congested_bandwidth = bandwidth_usage - bandwidth;
congested_bandwidth = std::max(congested_bandwidth, 0.0);

VTR_ASSERT(congested_bandwidth >= 0.0);
return congested_bandwidth;
}

double NocLink::get_congested_bandwidth_ratio() const {
double congested_bw = get_congested_bandwidth();
double congested_bw_ratio = congested_bw / get_bandwidth();

VTR_ASSERT(congested_bw_ratio >= 0.0);
return congested_bw_ratio;
}

double NocLink::get_latency() const {
return latency;
}
Expand Down
29 changes: 0 additions & 29 deletions vpr/src/noc/noc_link.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ class NocLink {
NocRouterId source_router; /*!< The router which uses this link as an outgoing edge*/
NocRouterId sink_router; /*!< The router which uses this link as an incoming edge*/

double bandwidth_usage; /*!< Represents the bandwidth of the data being transmitted on the link. Units in bits-per-second(bps)*/
double bandwidth; /*!< Represents the maximum bits per second that can be transmitted over the link without causing congestion*/
double latency; /*!< The zero-load latency of this link in seconds.*/

Expand All @@ -73,31 +72,12 @@ class NocLink {
*/
NocRouterId get_sink_router() const;

/**
* @brief Provides the size of the data (bandwidth) being currently transmitted using the link.
* @return A numeric value of the bandwidth usage of the link
*/
double get_bandwidth_usage() const;

/**
* @brief Returns the maximum bandwidth that the link can carry without congestion.
* @return A numeric value of the bandwidth capacity of the link
*/
double get_bandwidth() const;

/**
* @brief Calculates the extent to which the current bandwidth utilization
* exceeds the link capacity. Any positive value means the link is congested.
* @return A numeric value of the bandwidth over-utilization in the link
*/
double get_congested_bandwidth() const;

/**
* @brief Computes the congested bandwidth to bandwidth capacity ratio.
* @return The congested bandwidth to bandwidth capacity of the link.
*/
double get_congested_bandwidth_ratio() const;

/**
* @brief Returns the zero-load latency of the link.
* @return double Zero-load latency of the link.
Expand Down Expand Up @@ -126,15 +106,6 @@ class NocLink {
*/
void set_sink_router(NocRouterId sink);

/**
* @brief Can modify the bandwidth usage of the link. It is expected that when the NoC is being placed
* the traffic flows will be re-routed multiple times. So the links will end up being used and un-used
* by different traffic flows and the bandwidths of the links will correspondingly change. This function
* can be used to make those changes
* @param new_bandwidth_usage The new value of the bandwidth usage of the link
*/
void set_bandwidth_usage(double new_bandwidth_usage);

/**
* @brief Sets the bandwidth capacity of the link. This function should be used when
* global NoC data structures are created and populated. The bandwidth capacity is used
Expand Down
8 changes: 3 additions & 5 deletions vpr/src/noc/noc_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@ bool NocStorage::is_noc_3d() const {
// setters for the NoC

void NocStorage::add_router(int id,
int grid_position_x, int grid_posistion_y, int layer_position,
int grid_position_x, int grid_position_y, int layer_position,
double latency) {
VTR_ASSERT_MSG(!built_noc, "NoC already built, cannot modify further.");

router_storage.emplace_back(id, grid_position_x, grid_posistion_y, layer_position, latency);
router_storage.emplace_back(id, grid_position_x, grid_position_y, layer_position, latency);

/* Get the corresponding NocRouterId for the newly added router and
* add it to the conversion table.
Expand All @@ -123,7 +123,7 @@ void NocStorage::add_router(int id,

/* need to associate the current router with its grid position */
// get the key to identify the current router
int router_key = generate_router_key_from_grid_location(grid_position_x, grid_posistion_y, layer_position);
int router_key = generate_router_key_from_grid_location(grid_position_x, grid_position_y, layer_position);
grid_location_to_router_id.insert(std::pair<int, NocRouterId>(router_key, converted_id));
}

Expand Down Expand Up @@ -205,8 +205,6 @@ bool NocStorage::remove_link(NocRouterId src_router_id, NocRouterId sink_router_

link_storage[link_to_be_removed_id].set_source_router(NocRouterId::INVALID());
link_storage[link_to_be_removed_id].set_sink_router(NocRouterId::INVALID());
link_storage[link_to_be_removed_id].set_bandwidth_usage(-1);

}

// if a link was not removed then throw warning message
Expand Down
12 changes: 8 additions & 4 deletions vpr/src/noc/noc_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,14 @@ class NocStorage {
*/
int layer_num_grid_locs;

// prevent "copying" of this object
NocStorage(const NocStorage&) = delete;
void operator=(const NocStorage&) = delete;

public:
// default constructor (clear all the elements in the vectors)
NocStorage();

// prevent "copying" of this object
NocStorage(const NocStorage&) = delete;
void operator=(const NocStorage&) = delete;

// getters for the NoC

/**
Expand Down Expand Up @@ -379,6 +379,10 @@ class NocStorage {
* tile that this router represents.
* @param grid_position_y The vertical position on the FPGA of the physical
* tile that this router represents.
* @param layer_position The layer where the physical tile that this router
* represents is located.
* @param latency The zero-load latency that a traffic flow will experience
* when it is routed through this router.
*/
void add_router(int id,
int grid_position_x, int grid_position_y, int layer_position,
Expand Down
17 changes: 0 additions & 17 deletions vpr/src/noc/noc_traffic_flows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,6 @@ int NocTrafficFlows::get_number_of_routers_used_in_traffic_flows() {
return traffic_flows_associated_to_router_blocks.size();
}

const std::vector<NocLinkId>& NocTrafficFlows::get_traffic_flow_route(NocTrafficFlowId traffic_flow_id) const {
return traffic_flow_routes[traffic_flow_id];
}

std::vector<NocLinkId>& NocTrafficFlows::get_mutable_traffic_flow_route(NocTrafficFlowId traffic_flow_id) {
return traffic_flow_routes[traffic_flow_id];
}

const vtr::vector<NocTrafficFlowId, std::vector<NocLinkId>>& NocTrafficFlows::get_all_traffic_flow_routes() const {
return traffic_flow_routes;
}

const std::vector<ClusterBlockId>& NocTrafficFlows::get_router_clusters_in_netlist() const {
return router_cluster_in_netlist;
}
Expand Down Expand Up @@ -104,10 +92,6 @@ void NocTrafficFlows::set_router_cluster_in_netlist(const std::vector<ClusterBlo
void NocTrafficFlows::finished_noc_traffic_flows_setup() {
// all the traffic flows have been added, so indicate that the class has been constructed and cannot be modified anymore
built_traffic_flows = true;

// create the storage space for all the traffic flow routes
int number_of_traffic_flows = noc_traffic_flows.size();
traffic_flow_routes.resize(number_of_traffic_flows);
}

void NocTrafficFlows::clear_traffic_flows() {
Expand All @@ -116,7 +100,6 @@ void NocTrafficFlows::clear_traffic_flows() {
noc_traffic_flows_ids.clear();
router_cluster_in_netlist.clear();
traffic_flows_associated_to_router_blocks.clear();
traffic_flow_routes.clear();

// indicate that traffic flows need to be added again after clear
built_traffic_flows = false;
Expand Down
43 changes: 0 additions & 43 deletions vpr/src/noc/noc_traffic_flows.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,17 +117,6 @@ class NocTrafficFlows {
*/
bool built_traffic_flows;

/**
* @brief Stores the routes that were found by the routing algorithm for
* all traffic flows within the NoC. This is initialized after all the
* traffic flows have been added. This datastructure should be used
* to store the path found whenever a traffic flow needs to be routed/
* re-routed. Also, this datastructure should be used to access the routed
* path of a traffic flow.
*
*/
vtr::vector<NocTrafficFlowId, std::vector<NocLinkId>> traffic_flow_routes;

// private functions

/**
Expand Down Expand Up @@ -194,37 +183,6 @@ class NocTrafficFlows {
*/
int get_number_of_routers_used_in_traffic_flows();

/**
* @brief Gets the routed path of traffic flow. This cannot be
* modified externally.
*
* @param traffic_flow_id A unique identifier that represents a
* traffic flow.
* @return std::vector<NocLinkId>& A reference to the provided
* traffic flow's routed path.
*/
const std::vector<NocLinkId>& get_traffic_flow_route(NocTrafficFlowId traffic_flow_id) const;

/**
* @brief Gets the routed path of a traffic flow. The path
* returned can and is expected to be modified externally.
*
* @param traffic_flow_id A unique identifier that represents a
* traffic flow.
* @return std::vector<NocLinkId>& A reference to the provided
* traffic flow's vector of links used from the src to dst.
*/
std::vector<NocLinkId>& get_mutable_traffic_flow_route(NocTrafficFlowId traffic_flow_id);

/**
* @brief Gets all routed paths for all traffic flows. This cannot be
* modified externally.
*
* @return vtr::vector<NocTrafficFlowId, std::vector<NocLinkId>>& A reference
* to the provided container that includes all traffic flow routes.
*/
const vtr::vector<NocTrafficFlowId, std::vector<NocLinkId>>& get_all_traffic_flow_routes() const;

/**
* @return a vector ([0..num_logical_router-1]) where each entry gives the clusterBlockId
* of a logical NoC router. Used for fast lookups in the placer.
Expand Down Expand Up @@ -305,7 +263,6 @@ class NocTrafficFlows {
/**
* @brief Resets the class by clearing internal
* datastructures.
*
*/
void clear_traffic_flows();

Expand Down
Loading
Loading