From a2afee97e1505e8985d7e48b02e48ffe9057b7d1 Mon Sep 17 00:00:00 2001 From: AlexandreSinger Date: Sun, 23 Jun 2024 23:19:17 -0400 Subject: [PATCH 1/9] [Warnings] Fixed Incorrect Forward Declaration In RoutePathManager, the forward declaration of the RoutingContext was incorrectly made a class instead of a struct. This was causing several warnings in the Clang build (but not in the GCC build). Fixed since the forward declaration should match the declaration. --- vpr/src/route/route_path_manager.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vpr/src/route/route_path_manager.h b/vpr/src/route/route_path_manager.h index 73f0ddae9ef..c3f69980b67 100644 --- a/vpr/src/route/route_path_manager.h +++ b/vpr/src/route/route_path_manager.h @@ -28,7 +28,7 @@ struct t_heap_path { }; // Forward declaration of RoutingContext needed for traceback insertion -class RoutingContext; +struct RoutingContext; /* A class to manage the extra data required for RCV * It manages a set containing all the nodes that currently exist in the route tree @@ -117,4 +117,4 @@ class PathManager { std::set route_tree_nodes_; }; -#endif \ No newline at end of file +#endif From 709e5b43744ab46a8306ca0b4aa0f7700452835d Mon Sep 17 00:00:00 2001 From: AlexandreSinger Date: Mon, 24 Jun 2024 13:41:40 -0400 Subject: [PATCH 2/9] [Warnings] Fixed Ambiguous Unique Pointer Allocation --- vpr/test/test_post_verilog.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vpr/test/test_post_verilog.cpp b/vpr/test/test_post_verilog.cpp index 514374b7cbb..2222f861eac 100644 --- a/vpr/test/test_post_verilog.cpp +++ b/vpr/test/test_post_verilog.cpp @@ -4,6 +4,7 @@ #include "timing_place_lookup.h" #include +#include namespace { @@ -87,7 +88,7 @@ void copy_file(const std::string& src_fname, const std::string& dst_fname) { size_t size = src_file.tellg(); src_file.seekg(0, std::ios_base::beg); - auto buf = std::unique_ptr(new uint8_t[size]); + auto buf = std::make_unique(size); src_file.read((char*)buf.get(), size); dst_file.write((char*)buf.get(), size); } From d7d43fa97d227166a8ce37d34b231718cdc7cf42 Mon Sep 17 00:00:00 2001 From: AlexandreSinger Date: Mon, 24 Jun 2024 13:49:20 -0400 Subject: [PATCH 3/9] [Warnings] Converted an int into a size_t This code previously used an int to calculate the size of an allocation, which was done by shifting a bit; however, this is technically ill-formed since this could generate a negative value. This was causing a warning to appear in the most recent version of GCC. Although this is technically ok, its best that this properly uses size_t instead. --- vpr/src/power/power_util.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/vpr/src/power/power_util.cpp b/vpr/src/power/power_util.cpp index e32948a60cb..012c539c2c6 100644 --- a/vpr/src/power/power_util.cpp +++ b/vpr/src/power/power_util.cpp @@ -213,17 +213,17 @@ float calc_buffer_stage_effort(int N, float final_stage_size) { */ char* alloc_SRAM_values_from_truth_table(int LUT_size, const AtomNetlist::TruthTable& truth_table) { - int num_SRAM_bits = 1 << LUT_size; + size_t num_SRAM_bits = 1 << LUT_size; //SRAM value stored as a string of '0' and '1' characters // Initialize to all zeros char* SRAM_values = new char[num_SRAM_bits + 1]; - for (int i = 0; i < num_SRAM_bits + 1; i++) + for (size_t i = 0; i < num_SRAM_bits + 1; i++) SRAM_values[i] = '0'; SRAM_values[num_SRAM_bits] = '\0'; if (truth_table.empty()) { - for (int i = 0; i < num_SRAM_bits; i++) { + for (size_t i = 0; i < num_SRAM_bits; i++) { SRAM_values[i] = '1'; } return SRAM_values; @@ -237,7 +237,7 @@ char* alloc_SRAM_values_from_truth_table(int LUT_size, if (truth_table[0].size() == 1) { if (truth_table[0][0] == vtr::LogicValue::TRUE) { //Mark all the SRAM values as ON - for (int i = 0; i < num_SRAM_bits; i++) { + for (size_t i = 0; i < num_SRAM_bits; i++) { SRAM_values[i] = '1'; } return SRAM_values; @@ -250,7 +250,7 @@ char* alloc_SRAM_values_from_truth_table(int LUT_size, auto expanded_truth_table = expand_truth_table(truth_table, LUT_size); std::vector lut_mask = truth_table_to_lut_mask(expanded_truth_table, LUT_size); - VTR_ASSERT(lut_mask.size() == (size_t)num_SRAM_bits); + VTR_ASSERT(lut_mask.size() == num_SRAM_bits); //Convert to string for (size_t i = 0; i < lut_mask.size(); ++i) { From 7f262829e74e938b1de933e0f450a32aa20b4c22 Mon Sep 17 00:00:00 2001 From: AlexandreSinger Date: Mon, 24 Jun 2024 13:59:52 -0400 Subject: [PATCH 4/9] [Warnings] Fixed Array Access out of Bounds The way this section of code was written could potentially lead to an array access out of bounds. This was causing a warning in future versions of GCC. Simply fixed this issue. --- vpr/src/draw/draw_rr.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/vpr/src/draw/draw_rr.cpp b/vpr/src/draw/draw_rr.cpp index f17812df9c9..f2b573f69e7 100644 --- a/vpr/src/draw/draw_rr.cpp +++ b/vpr/src/draw/draw_rr.cpp @@ -926,8 +926,7 @@ void draw_get_rr_pin_coords(const t_rr_node& node, float* xcen, float* ycen, con default: vpr_throw(VPR_ERROR_OTHER, __FILE__, __LINE__, - "in draw_get_rr_pin_coords: Unexpected side %s.\n", - SIDE_STRING[pin_side]); + "in draw_get_rr_pin_coords: Unexpected side.\n"); break; } From 574875f5b11e7de03db827838174fcadd6deacde Mon Sep 17 00:00:00 2001 From: AlexandreSinger Date: Mon, 24 Jun 2024 14:21:16 -0400 Subject: [PATCH 5/9] [Warnings] Fixed Potential Memory Leak This line of code was likely a mistake; the src of a strcpy should never be a freshly allocated pointer. Fixed the line to likely what the coder intended. --- libs/libvqm/vqm_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/libvqm/vqm_common.c b/libs/libvqm/vqm_common.c index 57c905db58c..ba6199d178a 100644 --- a/libs/libvqm/vqm_common.c +++ b/libs/libvqm/vqm_common.c @@ -559,7 +559,7 @@ void add_node(char* type, char *name, t_array_ref **ports, t_parse_info* parse_i new_assoc->associated_net = net; new_assoc->port_index = counter; new_assoc->port_name = (char *) malloc(strlen(association->port_name)+1); - strcpy(new_assoc->port_name, (char*)malloc(strlen(association->port_name))); + strcpy(new_assoc->port_name, association->port_name); new_assoc->wire_index = wire_index; wire_index += change; m_ports->array_size = insert_element_at_index((intptr_t) new_assoc, m_ports, counter); From 5ee67218e452e608d8a635de5de65d3e84ca13b0 Mon Sep 17 00:00:00 2001 From: AlexandreSinger Date: Mon, 5 Aug 2024 00:19:02 -0400 Subject: [PATCH 6/9] [Warnings] Changed C String to STD String GCC sometimes gets confused with how strings are allocated, when they are C strings allocated by hand. Changed to an std string since it is easier to work with and removes the warning. --- vpr/src/power/power.cpp | 3 +-- vpr/src/power/power_components.cpp | 3 ++- vpr/src/power/power_components.h | 3 ++- vpr/src/power/power_util.cpp | 10 ++++------ vpr/src/power/power_util.h | 5 +++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/vpr/src/power/power.cpp b/vpr/src/power/power.cpp index 847930433c7..f2df57f8e88 100644 --- a/vpr/src/power/power.cpp +++ b/vpr/src/power/power.cpp @@ -138,7 +138,7 @@ static void power_usage_primitive(t_power_usage* power_usage, t_pb* pb, t_pb_gra if (strcmp(pb_graph_node->pb_type->blif_model, MODEL_NAMES) == 0) { /* LUT */ - char* SRAM_values; + std::string SRAM_values; float* input_probabilities; float* input_densities; int LUT_size; @@ -174,7 +174,6 @@ static void power_usage_primitive(t_power_usage* power_usage, t_pb* pb, t_pb_gra power_ctx.arch->LUT_transistor_size, SRAM_values, input_probabilities, input_densities, power_ctx.solution_inf.T_crit); power_add_usage(power_usage, &sub_power_usage); - delete[] SRAM_values; delete[] input_probabilities; delete[] input_densities; } else if (strcmp(pb_graph_node->pb_type->blif_model, MODEL_LATCH) == 0) { diff --git a/vpr/src/power/power_components.cpp b/vpr/src/power/power_components.cpp index 10793b83e15..0a6b22e0786 100644 --- a/vpr/src/power/power_components.cpp +++ b/vpr/src/power/power_components.cpp @@ -23,6 +23,7 @@ /************************* INCLUDES *********************************/ #include #include +#include #include "vtr_math.h" #include "vtr_assert.h" @@ -203,7 +204,7 @@ void power_usage_ff(t_power_usage* power_usage, float size, float D_prob, float * 7 _Z_| * */ -void power_usage_lut(t_power_usage* power_usage, int lut_size, float transistor_size, char* SRAM_values, float* input_prob, float* input_dens, float period) { +void power_usage_lut(t_power_usage* power_usage, int lut_size, float transistor_size, std::string SRAM_values, float* input_prob, float* input_dens, float period) { float** internal_prob; float** internal_dens; float** internal_v; diff --git a/vpr/src/power/power_components.h b/vpr/src/power/power_components.h index 110e5c15434..dd235450603 100644 --- a/vpr/src/power/power_components.h +++ b/vpr/src/power/power_components.h @@ -24,6 +24,7 @@ #define __POWER_COMPONENTS_H__ /************************* INCLUDES *********************************/ +#include #include "power.h" #include "clustered_netlist.h" @@ -82,7 +83,7 @@ void power_component_add_usage(t_power_usage* power_usage, float power_component_get_usage_sum(e_power_component_type component_idx); void power_usage_ff(t_power_usage* power_usage, float size, float D_prob, float D_dens, float Q_prob, float Q_dens, float clk_prob, float clk_dens, float period); -void power_usage_lut(t_power_usage* power_usage, int LUT_size, float transistor_size, char* SRAM_values, float* input_densities, float* input_probabilities, float period); +void power_usage_lut(t_power_usage* power_usage, int LUT_size, float transistor_size, std::string SRAM_values, float* input_densities, float* input_probabilities, float period); void power_usage_local_interc_mux(t_power_usage* power_usage, t_pb* pb, t_interconnect_pins* interc_pins, ClusterBlockId iblk); void power_usage_mux_multilevel(t_power_usage* power_usage, t_mux_arch* mux_arch, diff --git a/vpr/src/power/power_util.cpp b/vpr/src/power/power_util.cpp index 012c539c2c6..52556dac0aa 100644 --- a/vpr/src/power/power_util.cpp +++ b/vpr/src/power/power_util.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include "vtr_assert.h" #include "vtr_memory.h" @@ -211,16 +212,13 @@ float calc_buffer_stage_effort(int N, float final_stage_size) { * - LUT_size: The number of LUT inputs * - truth_table: The logic terms saved from the BLIF file */ -char* alloc_SRAM_values_from_truth_table(int LUT_size, - const AtomNetlist::TruthTable& truth_table) { +std::string alloc_SRAM_values_from_truth_table(int LUT_size, + const AtomNetlist::TruthTable& truth_table) { size_t num_SRAM_bits = 1 << LUT_size; //SRAM value stored as a string of '0' and '1' characters // Initialize to all zeros - char* SRAM_values = new char[num_SRAM_bits + 1]; - for (size_t i = 0; i < num_SRAM_bits + 1; i++) - SRAM_values[i] = '0'; - SRAM_values[num_SRAM_bits] = '\0'; + std::string SRAM_values(num_SRAM_bits, '0'); if (truth_table.empty()) { for (size_t i = 0; i < num_SRAM_bits; i++) { diff --git a/vpr/src/power/power_util.h b/vpr/src/power/power_util.h index 35ed22cc67f..7589af621ad 100644 --- a/vpr/src/power/power_util.h +++ b/vpr/src/power/power_util.h @@ -23,6 +23,7 @@ #define __POWER_UTIL_H__ /************************* INCLUDES *********************************/ +#include #include "power.h" #include "power_components.h" #include "atom_netlist.h" @@ -63,8 +64,8 @@ bool power_method_is_transistor_level(e_power_estimation_method estimation_metho bool power_method_is_recursive(e_power_estimation_method method); const char* transistor_type_name(e_tx_type type); -char* alloc_SRAM_values_from_truth_table(int LUT_size, - const AtomNetlist::TruthTable& truth_table); +std::string alloc_SRAM_values_from_truth_table(int LUT_size, + const AtomNetlist::TruthTable& truth_table); float clb_net_density(ClusterNetId net_idx); const char* interconnect_type_name(enum e_interconnect type); float clb_net_prob(ClusterNetId net_idx); From ead1091ef84848d7d75217d92d5451257812be93 Mon Sep 17 00:00:00 2001 From: AlexandreSinger Date: Mon, 5 Aug 2024 09:48:21 -0400 Subject: [PATCH 7/9] [Warnings] Fixed Const Reference When a class returns a reference to a dereferenced pointer, if the pointer does not point to a const object, returning that pointer as a const has no effect. This was causing warnings. To fix this, we want a refernece to a const object not a const reference to an object (silly, I know). So we need to make this more clear in the class. --- libs/EXTERNAL/libtatum/libtatum/tatum/tags/TimingTags.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libs/EXTERNAL/libtatum/libtatum/tatum/tags/TimingTags.hpp b/libs/EXTERNAL/libtatum/libtatum/tatum/tags/TimingTags.hpp index afab50fb1be..e24765afa7b 100644 --- a/libs/EXTERNAL/libtatum/libtatum/tatum/tags/TimingTags.hpp +++ b/libs/EXTERNAL/libtatum/libtatum/tatum/tags/TimingTags.hpp @@ -113,6 +113,7 @@ class TimingTags { using value_type = T; using pointer = T*; using reference = T&; + using const_reference = const T&; Iterator(): p_(nullptr) {} Iterator(pointer p): p_(p) {} @@ -123,7 +124,7 @@ class TimingTags { friend bool operator!=(Iterator a, Iterator b) { return a.p_ != b.p_; } reference operator*() { return *p_; } - const reference operator*() const { return *p_; } //Required for MSVC (gcc/clang are fine with only the non-cost version) + const_reference operator*() const { return *p_; } //Required for MSVC (gcc/clang are fine with only the non-cost version) pointer operator->() { return p_; } reference operator[](size_t n) { return *(p_ + n); } From 0afbfd4789ae84cb1dd9f9f0e9914a3daa7437c9 Mon Sep 17 00:00:00 2001 From: AlexandreSinger Date: Mon, 5 Aug 2024 09:58:58 -0400 Subject: [PATCH 8/9] [Warnings] Removed -lz Flag from Compilation The -lz flag is used to link with the ZLIB library, but the library was already being linked; so there was no reason to add the flag. This was causing an insane number of warnings in the Clang build. If this is added back for any reason, this should be checked. Also cleaned up how ZLIB was being linked. ZLIB is required for reading and processing the atom circuit; so it should always be linked with VPR. --- CMakeLists.txt | 6 +----- vpr/CMakeLists.txt | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dfc90c3e851..3109cf362fa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -130,11 +130,6 @@ endif() # Build type flags # -set(EXTRA_FLAGS "") -if(VPR_ENABLE_INTERCHANGE) - set(EXTRA_FLAGS "-lz") -endif() - if(NOT MSVC) # for GCC and Clang set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -g3") @@ -298,6 +293,7 @@ endif() # # Increased debugging vebosity # +set(EXTRA_FLAGS "") if(VTR_ENABLE_VERBOSE) set(EXTRA_FLAGS "${EXTRA_FLAGS} -DVTR_ENABLE_DEBUG_LOGGING") message(STATUS "Enabling increased debugging verbosity") diff --git a/vpr/CMakeLists.txt b/vpr/CMakeLists.txt index 226822084f3..0cbaec216a6 100644 --- a/vpr/CMakeLists.txt +++ b/vpr/CMakeLists.txt @@ -109,21 +109,22 @@ endif () set_target_properties(libvpr PROPERTIES PREFIX "") #Avoid extra 'lib' prefix #Specify link-time dependencies +find_package(ZLIB) target_link_libraries(libvpr - libvtrutil - libarchfpga - libsdcparse - libblifparse - libtatum - libargparse - libpugixml - librrgraph + libvtrutil + libarchfpga + libsdcparse + libblifparse + libtatum + libargparse + libpugixml + librrgraph + ZLIB::ZLIB ) if(VPR_USE_SERVER) target_link_libraries(libvpr sockpp-static - -lz ) endif() From 29cfb1c3de45d513b2bf339cac765ee5ae85ffbe Mon Sep 17 00:00:00 2001 From: AlexandreSinger Date: Tue, 20 Aug 2024 23:43:27 -0400 Subject: [PATCH 9/9] [Warnings] Added Missing Headers --- vpr/src/base/ShowSetup.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/vpr/src/base/ShowSetup.h b/vpr/src/base/ShowSetup.h index 4abef99da81..2991a1f42fe 100644 --- a/vpr/src/base/ShowSetup.h +++ b/vpr/src/base/ShowSetup.h @@ -1,6 +1,13 @@ #ifndef SHOWSETUP_H #define SHOWSETUP_H +#include +#include +#include + +class t_logical_block_type; +class t_vpr_setup; + struct ClusteredNetlistStats { private: void writeHuman(std::ostream& output) const;