Skip to content

Fix the crash in graphics when run-flat is used #2524

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 12 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from 7 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
51 changes: 25 additions & 26 deletions libs/libarchfpga/src/read_fpga_interchange_arch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,28 @@

#ifdef VTR_ENABLE_CAPNPROTO

#include <algorithm>
#include <kj/std/iostream.h>
#include <limits>
#include <map>
#include <regex>
#include <set>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <zlib.h>
#include <sstream>

#include "vtr_assert.h"
#include "vtr_digest.h"
#include "vtr_log.h"
#include "vtr_memory.h"
#include "vtr_util.h"

#include "arch_check.h"
#include "arch_error.h"
#include "arch_util.h"
#include "arch_types.h"

# include <algorithm>
# include <kj/std/iostream.h>
# include <limits>
# include <map>
# include <regex>
# include <set>
# include <stdlib.h>
# include <string>
# include <string.h>
# include <zlib.h>
# include <sstream>

# include "vtr_assert.h"
# include "vtr_digest.h"
# include "vtr_log.h"
# include "vtr_memory.h"
# include "vtr_util.h"

# include "arch_check.h"
# include "arch_error.h"
# include "arch_util.h"
# include "arch_types.h"

/*
* FPGA Interchange Device frontend
Expand Down Expand Up @@ -2503,7 +2502,7 @@ struct ArchReader {
}
};

#endif // VTR_ENABLE_CAPNPROTO
#endif // VTR_ENABLE_CAPNPROTO

void FPGAInterchangeReadArch(const char* FPGAInterchangeDeviceFile,
const bool /*timing_enabled*/,
Expand Down Expand Up @@ -2551,12 +2550,12 @@ void FPGAInterchangeReadArch(const char* FPGAInterchangeDeviceFile,

ArchReader reader(arch, device_reader, FPGAInterchangeDeviceFile, PhysicalTileTypes, LogicalBlockTypes);
reader.read_arch();
#else // VTR_ENABLE_CAPNPROTO
#else // VTR_ENABLE_CAPNPROTO
// If CAPNPROTO is disabled, throw an error.
(void)FPGAInterchangeDeviceFile;
(void)arch;
(void)PhysicalTileTypes;
(void)LogicalBlockTypes;
throw vtr::VtrError("Unable to read FPGA interchange if CAPNPROTO is not enabled", __FILE__, __LINE__);
#endif // VTR_ENABLE_CAPNPROTO
#endif // VTR_ENABLE_CAPNPROTO
}
16 changes: 8 additions & 8 deletions libs/libarchfpga/src/read_fpga_interchange_arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@

#ifdef VTR_ENABLE_CAPNPROTO

#include "DeviceResources.capnp.h"
#include "LogicalNetlist.capnp.h"
#include "capnp/serialize.h"
#include "capnp/serialize-packed.h"
#include <fcntl.h>
#include <unistd.h>

#endif // VTR_ENABLE_CAPNPROTO
# include "DeviceResources.capnp.h"
# include "LogicalNetlist.capnp.h"
# include "capnp/serialize.h"
# include "capnp/serialize-packed.h"
# include <fcntl.h>
# include <unistd.h>

#endif // VTR_ENABLE_CAPNPROTO

#ifdef __cplusplus
extern "C" {
Expand Down
60 changes: 30 additions & 30 deletions vpr/src/base/read_interchange_netlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,33 @@

#ifdef VTR_ENABLE_CAPNPROTO

#include <cmath>
#include <limits>
#include <kj/std/iostream.h>
#include <regex>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <zlib.h>
#include <iostream>
#include <sstream>

#include "LogicalNetlist.capnp.h"
#include "capnp/serialize.h"
#include "capnp/serialize-packed.h"

#include "vtr_assert.h"
#include "vtr_hash.h"
#include "vtr_util.h"
#include "vtr_log.h"
#include "vtr_logic.h"
#include "vtr_time.h"
#include "vtr_digest.h"

#include "vpr_types.h"
#include "vpr_error.h"
#include "globals.h"
#include "arch_types.h"
# include <cmath>
# include <limits>
# include <kj/std/iostream.h>
# include <regex>
# include <string>
# include <unordered_map>
# include <unordered_set>
# include <zlib.h>
# include <iostream>
# include <sstream>

# include "LogicalNetlist.capnp.h"
# include "capnp/serialize.h"
# include "capnp/serialize-packed.h"

# include "vtr_assert.h"
# include "vtr_hash.h"
# include "vtr_util.h"
# include "vtr_log.h"
# include "vtr_logic.h"
# include "vtr_time.h"
# include "vtr_digest.h"

# include "vpr_types.h"
# include "vpr_error.h"
# include "globals.h"
# include "arch_types.h"

struct NetlistReader {
public:
Expand Down Expand Up @@ -524,7 +524,7 @@ struct NetlistReader {
}
};

#endif // VTR_ENABLE_CAPNPROTO
#endif // VTR_ENABLE_CAPNPROTO

AtomNetlist read_interchange_netlist(const char* ic_netlist_file,
t_arch& arch) {
Expand Down Expand Up @@ -572,12 +572,12 @@ AtomNetlist read_interchange_netlist(const char* ic_netlist_file,

return netlist;

#else // VTR_ENABLE_CAPNPROTO
#else // VTR_ENABLE_CAPNPROTO

// If CAPNPROTO is not enabled, throw an error
(void)ic_netlist_file;
(void)arch;
throw vtr::VtrError("Unable to read interchange netlist with CAPNPROTO disabled", __FILE__, __LINE__);

#endif // VTR_ENABLE_CAPNPROTO
#endif // VTR_ENABLE_CAPNPROTO
}
8 changes: 8 additions & 0 deletions vpr/src/draw/draw_basic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,10 @@ void draw_partial_route(const std::vector<RRNodeId>& rr_nodes_to_draw, ezgl::ren
RRNodeId prev_node = rr_nodes_to_draw[i - 1];
auto prev_type = rr_graph.node_type(RRNodeId(prev_node));

if (!is_inter_cluster_node(rr_graph, prev_node) || !is_inter_cluster_node(rr_graph, inode)) {
continue;
}

auto iedge = find_edge(prev_node, inode);
auto switch_type = rr_graph.edge_switch(RRNodeId(prev_node), iedge);

Expand Down Expand Up @@ -773,6 +777,10 @@ bool is_edge_valid_to_draw(RRNodeId current_node, RRNodeId prev_node) {
int current_node_layer = rr_graph.node_layer(current_node);
int prev_node_layer = rr_graph.node_layer(prev_node);

if (!(is_inter_cluster_node(rr_graph, current_node)) || !(is_inter_cluster_node(rr_graph, prev_node))) {
return false;
}

if (current_node_layer != prev_node_layer) {
if (draw_state->cross_layer_display.visible && draw_state->draw_layer_display[current_node_layer].visible && draw_state->draw_layer_display[prev_node_layer].visible) {
return true; //if both layers are enabled and cross layer connections are enabled
Expand Down
6 changes: 6 additions & 0 deletions vpr/src/draw/draw_rr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,9 @@ void draw_rr_pin(RRNodeId inode, const ezgl::color& color, ezgl::renderer* g) {
char str[vtr::bufsize];
auto& device_ctx = g_vpr_ctx.device();
const auto& rr_graph = device_ctx.rr_graph;
if (!is_inter_cluster_node(rr_graph, inode)) {
return;
}

int ipin = rr_graph.node_pin_num(RRNodeId(inode));

Expand Down Expand Up @@ -581,6 +584,9 @@ void draw_rr_src_sink(RRNodeId inode, ezgl::color color, ezgl::renderer* g) {

auto& device_ctx = g_vpr_ctx.device();
const auto& rr_graph = device_ctx.rr_graph;
if (!is_inter_cluster_node(rr_graph, inode)) {
return;
}

int transparency_factor = get_rr_node_transparency(inode);

Expand Down
2 changes: 1 addition & 1 deletion vpr/src/noc/noc_link.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ NocLink::NocLink(NocLinkId link_id, NocRouterId source, NocRouterId sink, double
, source_router(source)
, sink_router(sink)
, bandwidth_usage(0.0)
, bandwidth(bw) { }
, bandwidth(bw) {}

// getters
NocRouterId NocLink::get_source_router(void) const {
Expand Down
3 changes: 1 addition & 2 deletions vpr/src/noc/noc_link.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class NocLink {
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 bandwidth; /*!< Represents the maximum bits per second that can be transmitted over the link without causing congestion*/

public:
NocLink(NocLinkId link_id, NocRouterId source_router, NocRouterId sink_router, double bw);
Expand Down Expand Up @@ -135,7 +135,6 @@ class NocLink {
*/
void set_bandwidth(double new_bandwidth);


/**
* @brief Returns the unique link ID. The ID can be used to index
* vtr::vector<NoCLinkId, ...> instances.
Expand Down
2 changes: 1 addition & 1 deletion vpr/src/noc/noc_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const NocLink& NocStorage::get_single_noc_link(NocLinkId id) const {
return link_storage[id];
}

NocLinkId NocStorage::get_single_noc_link_id(NocRouterId src_router, NocRouterId dst_router) const {
NocLinkId NocStorage::get_single_noc_link_id(NocRouterId src_router, NocRouterId dst_router) const {
NocLinkId link_id = NocLinkId::INVALID();

for (const auto& link : link_storage) {
Expand Down
2 changes: 1 addition & 1 deletion vpr/src/noc/noc_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ class NocStorage {
* to the destination router. NocLinkId::INVALID() is such a link is not
* found.
*/
NocLinkId get_single_noc_link_id(NocRouterId src_router, NocRouterId dst_router) const;
NocLinkId get_single_noc_link_id(NocRouterId src_router, NocRouterId dst_router) const;

/**
* @brief Given a unique link identifier, get the corresponding link
Expand Down
1 change: 0 additions & 1 deletion vpr/src/place/initial_noc_placement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ static void noc_routers_anneal(const t_noc_opts& noc_opts) {
const double starting_prob = 0.5;
const double prob_step = starting_prob / N_MOVES;


// The checkpoint stored the placement with the lowest cost.
NoCPlacementCheckpoint checkpoint;

Expand Down
33 changes: 15 additions & 18 deletions vpr/src/place/noc_place_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ static vtr::vector<NocTrafficFlowId, TrafficFlowPlaceCost> traffic_flow_costs, p
static std::vector<NocTrafficFlowId> affected_traffic_flows;

/* Proposed and actual congestion cost of a NoC link used for each move assessment */
static vtr::vector<NocLinkId , double> link_congestion_costs, proposed_link_congestion_costs;
static vtr::vector<NocLinkId, double> link_congestion_costs, proposed_link_congestion_costs;

/* Keeps track of NoC links whose bandwidth usage have been updated at each attempted placement move*/
static std::unordered_set<NocLinkId> affected_noc_links;
Expand Down Expand Up @@ -70,7 +70,7 @@ void initial_noc_routing() {
const t_noc_traffic_flow& curr_traffic_flow = noc_traffic_flows_storage.get_single_noc_traffic_flow(traffic_flow_id);

// update the traffic flow route based on where the router cluster blocks are placed
std::vector<NocLinkId>& curr_traffic_flow_route = route_traffic_flow(traffic_flow_id, noc_ctx.noc_model,noc_traffic_flows_storage, *noc_ctx.noc_flows_router);
std::vector<NocLinkId>& curr_traffic_flow_route = route_traffic_flow(traffic_flow_id, noc_ctx.noc_model, noc_traffic_flows_storage, *noc_ctx.noc_flows_router);

// update the links used in the found traffic flow route, links' bandwidth should be incremented since the traffic flow is routed
update_traffic_flow_link_usage(curr_traffic_flow_route, noc_ctx.noc_model, 1, curr_traffic_flow.traffic_flow_bandwidth);
Expand Down Expand Up @@ -137,7 +137,8 @@ void find_affected_noc_routers_and_update_noc_costs(const t_pl_blocks_to_be_move
// calculate the new aggregate bandwidth and latency costs for the affected traffic flow
proposed_traffic_flow_costs[traffic_flow_id].aggregate_bandwidth = calculate_traffic_flow_aggregate_bandwidth_cost(traffic_flow_route, curr_traffic_flow);
std::tie(proposed_traffic_flow_costs[traffic_flow_id].latency,
proposed_traffic_flow_costs[traffic_flow_id].latency_overrun) = calculate_traffic_flow_latency_cost(traffic_flow_route, noc_ctx.noc_model, curr_traffic_flow);
proposed_traffic_flow_costs[traffic_flow_id].latency_overrun)
= calculate_traffic_flow_latency_cost(traffic_flow_route, noc_ctx.noc_model, curr_traffic_flow);

// compute how much the aggregate bandwidth and latency costs change with this swap
delta_c.aggregate_bandwidth += proposed_traffic_flow_costs[traffic_flow_id].aggregate_bandwidth - traffic_flow_costs[traffic_flow_id].aggregate_bandwidth;
Expand Down Expand Up @@ -174,7 +175,7 @@ void commit_noc_costs() {
}

// Iterate over all the NoC links whose bandwidth utilization was affected by the proposed move
for(auto link_id : affected_noc_links) {
for (auto link_id : affected_noc_links) {
// get the affected link
const auto& link = noc_ctx.noc_model.get_single_noc_link(link_id);

Expand Down Expand Up @@ -449,7 +450,7 @@ int check_noc_placement_costs(const t_placer_costs& costs, double error_toleranc
vtr::vector<NocLinkId, NocLink> temp_noc_link_storage = noc_model.get_noc_links();

// reset bandwidth utilization for all links
std::for_each(temp_noc_link_storage.begin(), temp_noc_link_storage.end(), [](NocLink& link) {link.set_bandwidth_usage(0.0); });
std::for_each(temp_noc_link_storage.begin(), temp_noc_link_storage.end(), [](NocLink& link) { link.set_bandwidth_usage(0.0); });

// need to create a temporary noc routing algorithm
std::unique_ptr<NocRouting> temp_noc_routing_algorithm = NocRoutingAlgorithmCreator::create_routing_algorithm(noc_opts.noc_routing_algorithm);
Expand Down Expand Up @@ -494,7 +495,7 @@ int check_noc_placement_costs(const t_placer_costs& costs, double error_toleranc
}

// Iterate over all NoC links and accumulate congestion cost
for(const auto& link : temp_noc_link_storage) {
for (const auto& link : temp_noc_link_storage) {
cost_check.congestion += calculate_link_congestion_cost(link);
}

Expand Down Expand Up @@ -611,11 +612,7 @@ double calculate_noc_cost(const NocCostTerms& cost_terms,
* is computed. Weighting factors determine the contribution of each
* normalized term to the sum.
*/
cost = noc_opts.noc_placement_weighting * (
cost_terms.aggregate_bandwidth * norm_factors.aggregate_bandwidth * noc_opts.noc_aggregate_bandwidth_weighting +
cost_terms.latency * norm_factors.latency * noc_opts.noc_latency_weighting +
cost_terms.latency_overrun * norm_factors.latency_overrun * noc_opts.noc_latency_constraints_weighting +
cost_terms.congestion * norm_factors.congestion * noc_opts.noc_congestion_weighting);
cost = noc_opts.noc_placement_weighting * (cost_terms.aggregate_bandwidth * norm_factors.aggregate_bandwidth * noc_opts.noc_aggregate_bandwidth_weighting + cost_terms.latency * norm_factors.latency * noc_opts.noc_latency_weighting + cost_terms.latency_overrun * norm_factors.latency_overrun * noc_opts.noc_latency_constraints_weighting + cost_terms.congestion * norm_factors.congestion * noc_opts.noc_congestion_weighting);

return cost;
}
Expand Down Expand Up @@ -662,11 +659,11 @@ int get_number_of_congested_noc_links() {

// Iterate over all NoC links and count the congested ones
for (const auto& link : noc_links) {
double congested_bw_ratio = link.get_congested_bandwidth_ratio();
double congested_bw_ratio = link.get_congested_bandwidth_ratio();

if (congested_bw_ratio > MIN_EXPECTED_NOC_CONGESTION_COST) {
if (congested_bw_ratio > MIN_EXPECTED_NOC_CONGESTION_COST) {
num_congested_links++;
}
}
}

return num_congested_links;
Expand All @@ -680,8 +677,8 @@ double get_total_congestion_bandwidth_ratio() {

// Iterate over all NoC links and count the congested ones
for (const auto& link : noc_links) {
double congested_bw_ratio = link.get_congested_bandwidth_ratio();
accum_congestion_ratio += congested_bw_ratio;
double congested_bw_ratio = link.get_congested_bandwidth_ratio();
accum_congestion_ratio += congested_bw_ratio;
}

return accum_congestion_ratio;
Expand All @@ -695,8 +692,8 @@ std::vector<NocLink> get_top_n_congested_links(int n) {
// stable_sort is used to make sure the order is the same across different machines/compilers
// Note that when the vector is sorted, indexing it with NocLinkId does return the corresponding link
std::stable_sort(noc_links.begin(), noc_links.end(), [](const NocLink& l1, const NocLink& l2) {
return l1.get_congested_bandwidth_ratio() > l2.get_congested_bandwidth_ratio();
});
return l1.get_congested_bandwidth_ratio() > l2.get_congested_bandwidth_ratio();
});

int pick_n = std::min((int)noc_links.size(), n);

Expand Down
Loading