Skip to content

Commit

Permalink
move DEFAULT_MAX_TRAFFIC_FLOW_LATENCY to NocTrafficFlows
Browse files Browse the repository at this point in the history
  • Loading branch information
soheilshahrouz committed Jun 5, 2024
1 parent 2fe22e8 commit 09b5802
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 41 deletions.
22 changes: 6 additions & 16 deletions vpr/src/noc/noc_traffic_flows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ NocTrafficFlows::NocTrafficFlows() {

// getters for the traffic flows

int NocTrafficFlows::get_number_of_traffic_flows(void) const {
int NocTrafficFlows::get_number_of_traffic_flows() const {
return noc_traffic_flows.size();
}

Expand All @@ -33,7 +33,7 @@ const std::vector<NocTrafficFlowId>& NocTrafficFlows::get_traffic_flows_associat
}
}

int NocTrafficFlows::get_number_of_routers_used_in_traffic_flows(void) {
int NocTrafficFlows::get_number_of_routers_used_in_traffic_flows() {
return traffic_flows_associated_to_router_blocks.size();
}

Expand All @@ -49,11 +49,11 @@ const vtr::vector<NocTrafficFlowId, std::vector<NocLinkId>>& NocTrafficFlows::ge
return traffic_flow_routes;
}

const std::vector<ClusterBlockId>& NocTrafficFlows::get_router_clusters_in_netlist(void) const {
const std::vector<ClusterBlockId>& NocTrafficFlows::get_router_clusters_in_netlist() const {
return router_cluster_in_netlist;
}

const std::vector<NocTrafficFlowId>& NocTrafficFlows::get_all_traffic_flow_id(void) const {
const std::vector<NocTrafficFlowId>& NocTrafficFlows::get_all_traffic_flow_id() const {
return noc_traffic_flows_ids;
}

Expand Down Expand Up @@ -84,8 +84,6 @@ void NocTrafficFlows::create_noc_traffic_flow(const std::string& source_router_m
// now add the new traffic flow to flows associated with the current source and sink router
add_traffic_flow_to_associated_routers(curr_traffic_flow_id, source_router_cluster_id);
add_traffic_flow_to_associated_routers(curr_traffic_flow_id, sink_router_cluster_id);

return;
}

void NocTrafficFlows::set_router_cluster_in_netlist(const std::vector<ClusterBlockId>& routers_cluster_id_in_netlist) {
Expand All @@ -98,18 +96,16 @@ void NocTrafficFlows::set_router_cluster_in_netlist(const std::vector<ClusterBlo

// utility functions for the noc traffic flows

void NocTrafficFlows::finished_noc_traffic_flows_setup(void) {
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);

return;
}

void NocTrafficFlows::clear_traffic_flows(void) {
void NocTrafficFlows::clear_traffic_flows() {
// delete any information from internal datastructures
noc_traffic_flows.clear();
noc_traffic_flows_ids.clear();
Expand All @@ -119,8 +115,6 @@ void NocTrafficFlows::clear_traffic_flows(void) {

// indicate that traffic flows need to be added again after clear
built_traffic_flows = false;

return;
}

bool NocTrafficFlows::check_if_cluster_block_has_traffic_flows(ClusterBlockId block_id) const {
Expand All @@ -144,8 +138,6 @@ void NocTrafficFlows::add_traffic_flow_to_associated_routers(NocTrafficFlowId tr
// there already is a vector associated of traffic flows for the current router, so add it
router_traffic_flows->second.emplace_back(traffic_flow_id);
}

return;
}

void NocTrafficFlows::echo_noc_traffic_flows(char* file_name) {
Expand Down Expand Up @@ -208,6 +200,4 @@ void NocTrafficFlows::echo_noc_traffic_flows(char* file_name) {
}

vtr::fclose(fp);

return;
}
26 changes: 20 additions & 6 deletions vpr/src/noc/noc_traffic_flows.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class NocTrafficFlows {
* @return int An integer that represents the number of unique traffic
* flows within the NoC.
*/
int get_number_of_traffic_flows(void) const;
int get_number_of_traffic_flows() const;

/**
* @brief Given a unique id of a traffic flow (t_noc_traffic_flow)
Expand Down Expand Up @@ -192,7 +192,7 @@ class NocTrafficFlows {
* @return int The total number of unique routers used in
* the traffic flows provided by the user.
*/
int get_number_of_routers_used_in_traffic_flows(void);
int get_number_of_routers_used_in_traffic_flows();

/**
* @brief Gets the routed path of traffic flow. This cannot be
Expand Down Expand Up @@ -229,13 +229,13 @@ class NocTrafficFlows {
* @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.
*/
const std::vector<ClusterBlockId>& get_router_clusters_in_netlist(void) const;
const std::vector<ClusterBlockId>& get_router_clusters_in_netlist() const;

/**
* @return provides access to all traffic flows' ids to allow a range-based
* loop through all traffic flows, used in noc_place_utils.cpp functions.
*/
const std::vector<NocTrafficFlowId>& get_all_traffic_flow_id(void) const;
const std::vector<NocTrafficFlowId>& get_all_traffic_flow_id() const;

// setters

Expand Down Expand Up @@ -294,14 +294,14 @@ class NocTrafficFlows {
*
*/

void finished_noc_traffic_flows_setup(void);
void finished_noc_traffic_flows_setup();

/**
* @brief Resets the class by clearing internal
* datastructures.
*
*/
void clear_traffic_flows(void);
void clear_traffic_flows();

/**
* @brief Given a block from the clustered netlist, determine
Expand Down Expand Up @@ -331,6 +331,20 @@ class NocTrafficFlows {
* traffic flow information
*/
void echo_noc_traffic_flows(char* file_name);


/**
* @brief Defines the latency constraint of a traffic flow
* when not provided by the user.
*
* This value has to be significantly larger than latencies
* seen within the NoC so that the net effect in the placement
* cost is 0 (the latency constraint has no effect since there is none).
* Since the traffic flow latencies will be in nanoseconds,
* setting this value to 1 second which is significantly larger
* than what will be seen in the NoC.
*/
static constexpr double DEFAULT_MAX_TRAFFIC_FLOW_LATENCY = 1.;
};

#endif
14 changes: 2 additions & 12 deletions vpr/src/noc/read_xml_noc_traffic_flows_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

void read_xml_noc_traffic_flows_file(const char* noc_flows_file) {
// start by checking that the provided file is a ".flows" file
if (vtr::check_file_name_extension(noc_flows_file, ".flows") == false) {
if (!vtr::check_file_name_extension(noc_flows_file, ".flows")) {
VPR_FATAL_ERROR(VPR_ERROR_OTHER, "NoC traffic flows file '%s' has an unknown extension. Expecting .flows for NoC traffic flow files.", noc_flows_file);
}

Expand Down Expand Up @@ -72,8 +72,6 @@ void read_xml_noc_traffic_flows_file(const char* noc_flows_file) {
if (getEchoEnabled() && isEchoFileEnabled(E_ECHO_NOC_TRAFFIC_FLOWS)) {
noc_ctx.noc_traffic_flows_storage.echo_noc_traffic_flows(getEchoFileName(E_ECHO_NOC_TRAFFIC_FLOWS));
}

return;
}

void process_single_flow(pugi::xml_node single_flow_tag,
Expand Down Expand Up @@ -125,8 +123,6 @@ void process_single_flow(pugi::xml_node single_flow_tag,
traffic_flow_bandwidth,
max_traffic_flow_latency,
traffic_flow_priority);

return;
}

double get_traffic_flow_bandwidth(pugi::xml_node single_flow_tag, const pugiutil::loc_data& loc_data) {
Expand All @@ -144,7 +140,7 @@ double get_traffic_flow_bandwidth(pugi::xml_node single_flow_tag, const pugiutil

double get_max_traffic_flow_latency(pugi::xml_node single_flow_tag, const pugiutil::loc_data& loc_data) {
// "set to large value, indicating no constraint
double max_traffic_flow_latency = DEFAULT_MAX_TRAFFIC_FLOW_LATENCY;
double max_traffic_flow_latency = NocTrafficFlows::DEFAULT_MAX_TRAFFIC_FLOW_LATENCY;

// holds the latency value as a string so that it can be used to convert to a floating point value (this is done so that scientific notation is supported)
std::string max_traffic_flow_latency_intermediate_val;
Expand Down Expand Up @@ -194,8 +190,6 @@ void verify_traffic_flow_router_modules(const std::string& source_router_name, c
// Cannot have the source and sink routers have the same name (they need to be different). A flow cant go to a single router.
vpr_throw(VPR_ERROR_OTHER, loc_data.filename_c_str(), loc_data.line(single_flow_tag), "Source and sink NoC routers cannot be the same modules.");
}

return;
}

void verify_traffic_flow_properties(double traffic_flow_bandwidth, double max_traffic_flow_latency, int traffic_flow_priority, pugi::xml_node single_flow_tag, const pugiutil::loc_data& loc_data) {
Expand All @@ -213,8 +207,6 @@ void verify_traffic_flow_properties(double traffic_flow_bandwidth, double max_tr
if (traffic_flow_priority <= 0) {
vpr_throw(VPR_ERROR_OTHER, loc_data.filename_c_str(), loc_data.line(single_flow_tag), "The traffic flow priorities expected to be positive, non-zero integer values.");
}

return;
}

ClusterBlockId get_router_module_cluster_id(const std::string& router_module_name,
Expand Down Expand Up @@ -254,8 +246,6 @@ void check_traffic_flow_router_module_type(const std::string& router_module_name
if (!is_tile_compatible(noc_router_tile_type, router_module_logical_type)) {
vpr_throw(VPR_ERROR_OTHER, loc_data.filename_c_str(), loc_data.line(single_flow_tag), "The supplied module name '%s' is not a NoC router.", router_module_name.c_str());
}

return;
}

t_physical_tile_type_ptr get_physical_type_of_noc_router_tile(const DeviceContext& device_ctx, NocContext& noc_ctx) {
Expand Down
5 changes: 0 additions & 5 deletions vpr/src/noc/read_xml_noc_traffic_flows_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,6 @@
// identifier when an integer conversion failed while reading an attribute value in an xml file
constexpr int NUMERICAL_ATTRIBUTE_CONVERSION_FAILURE = -1;

// defines the latency constraint of a traffic flow when not provided by the user
// This value has to be significantly larger than latencies seen within the NoC so that the net effect in the placement cost is 0 (the latency constraint has no effect since there is none)
// Since the traffic flow latencies will be in nanoseconds, setting this value to 1 second which is significantly larger that what will be seen in the NoC
constexpr double DEFAULT_MAX_TRAFFIC_FLOW_LATENCY = 1.;

// defines the priority of a traffic flow when not specified by a user
constexpr int DEFAULT_TRAFFIC_FLOW_PRIORITY = 1;

Expand Down
4 changes: 2 additions & 2 deletions vpr/src/noc/sat_routing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ static void create_flow_link_vars(orsat::CpModelBuilder& cp_model,
const auto& traffic_flow = traffic_flow_storage.get_single_noc_traffic_flow(traffic_flow_id);

// create an integer variable for each latency-constrained traffic flow
if (traffic_flow.max_traffic_flow_latency < 0.1) {
if (traffic_flow.max_traffic_flow_latency < NocTrafficFlows::DEFAULT_MAX_TRAFFIC_FLOW_LATENCY) {
latency_overrun_vars[traffic_flow_id] = cp_model.NewIntVar(latency_overrun_domain);
}

Expand Down Expand Up @@ -530,7 +530,7 @@ static int comp_max_number_of_traversed_links(NocTrafficFlowId traffic_flow_id)

const double traffic_flow_latency_constraint = traffic_flow.max_traffic_flow_latency;

VTR_ASSERT(traffic_flow_latency_constraint < 0.1);
VTR_ASSERT(traffic_flow_latency_constraint < NocTrafficFlows::DEFAULT_MAX_TRAFFIC_FLOW_LATENCY);

int n_max_links = std::floor((traffic_flow_latency_constraint - noc_router_latency) / (noc_link_latency + noc_router_latency));

Expand Down

0 comments on commit 09b5802

Please sign in to comment.