Skip to content

Commit 18cde89

Browse files
Type fix (#31)
* added compiler warning flags * virtual destructors and some float compare * fixed pedantic warnings * wshadow * wfloat-equal * compiler flags * changed old style c conversion to modern cpp * small warning fixes * added test that breaks things * update * update * removed Compact Sparse Graph warnings * update * added work weights * type fix graph implementation * pr comments * fun with (more) flags * Wsign-compare * Sarkar Default fix * old cast style fix --------- Co-authored-by: Raphael Steiner <[email protected]>
1 parent 8e17bbe commit 18cde89

File tree

108 files changed

+789
-544
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+789
-544
lines changed

CMakeLists.txt

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,62 @@ add_subdirectory(.githooks)
3131
# --- Compile Options Configuration ---
3232
# Common compile options including strict warnings and error-on-warning
3333
set(COMMON_CXX_WARNING_FLAGS
34-
"-Wall"
35-
"-Wextra"
3634
"-Wfatal-errors"
3735
"-Wconversion"
3836
"-Wsign-conversion"
39-
"-Wunused"
4037
"-Wunreachable-code"
4138
"-Wuninitialized"
39+
"-pedantic"
40+
"-Wpedantic"
41+
"-Wold-style-cast"
42+
"-Wcast-align"
4243
"-Werror"
44+
"-Wall"
45+
"-Wextra"
46+
"-Wundef"
47+
"-Wunused"
48+
"-Wcast-qual"
49+
"-Wpointer-arith"
50+
"-Wdate-time"
51+
"-Wfloat-equal"
52+
"-Wformat=2"
53+
"-Wshadow"
54+
"-Wsign-compare"
55+
"-Wunused-macros"
56+
"-Wvla"
57+
"-Wdisabled-optimization"
58+
"-Wempty-body"
59+
"-Wignored-qualifiers"
60+
"-Wtype-limits"
61+
"-Wshift-negative-value"
62+
"-Wswitch-default"
63+
"-Woverloaded-virtual"
64+
"-Wnon-virtual-dtor"
65+
"-Wshift-overflow=2"
66+
"-Wshift-count-overflow"
67+
"-Wwrite-strings"
68+
"-Wmissing-format-attribute"
69+
"-Wformat-nonliteral"
70+
"-Wduplicated-cond"
71+
"-Wtrampolines"
72+
"-Wsized-deallocation"
73+
"-Wlogical-op"
74+
"-Wsuggest-attribute=format"
75+
"-Wduplicated-branches"
76+
"-Wmissing-include-dirs"
77+
"-Wformat-signedness"
78+
"-Wreturn-local-addr"
79+
"-Wredundant-decls"
80+
"-Wfloat-conversion"
81+
"-fno-common"
82+
"-fno-strict-aliasing"
83+
"-Wno-return-type"
84+
"-Wno-array-bounds"
85+
"-Wno-maybe-uninitialized"
86+
"-Wno-unused-but-set-variable"
87+
"-Wno-unused-variable"
88+
"-Wno-unused-parameter"
89+
"-Wno-unused-result"
4390
)
4491

4592
# --- Project-specific Compile Flags ---

apps/coarser_plotter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,4 @@ int main(int argc, char *argv[]) {
100100
}
101101

102102
return 0;
103-
};
103+
}

apps/graph_analyser.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ void add_graph_stats(const ComputationalDag &graph, std::ofstream &outfile) {
5858
Get_Median(edge_lengths);
5959

6060
if (graph.num_edges() != 0) {
61-
avg_edge_length = (float)sum_edge_length / (float)graph.num_edges();
61+
avg_edge_length = static_cast<float>(sum_edge_length) / static_cast<float>(graph.num_edges());
6262
}
6363

6464
// Longest Path
@@ -72,15 +72,15 @@ void add_graph_stats(const ComputationalDag &graph, std::ofstream &outfile) {
7272
// wavefront[top_level[i]] = 1;
7373
// }
7474
}
75-
float avg_wavefront = (float)graph.num_vertices() / (float)longest_path;
75+
float avg_wavefront = static_cast<float>(graph.num_vertices()) / static_cast<float>(longest_path);
7676

7777
// Average bottom distance
7878
std::vector<unsigned> bot_level = get_bottom_node_distance(graph);
7979
size_t bot_level_sum = 0;
8080
for (size_t i = 0; i < bot_level.size(); i++) {
8181
bot_level_sum += bot_level[i];
8282
}
83-
float avg_bot_level = (float)bot_level_sum / (float)bot_level.size();
83+
float avg_bot_level = static_cast<float>(bot_level_sum) / static_cast<float>(bot_level.size());
8484

8585
// // Number of Triangles
8686
// size_t number_triangles = 0;

apps/graph_generator/gen_Erdos-Renyi_graph.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ int main(int argc, char *argv[]) {
5353
std::uniform_real_distribution<double> unif_log(-std::log(upper_bound), std::log(upper_bound));
5454
std::default_random_engine re;
5555

56-
for (size_t i = 0; i < num_graphs; i++) {
56+
for (size_t j = 0; j < num_graphs; j++) {
5757
// Generating the graph
5858
ComputationalDag graph;
5959
erdos_renyi_graph_gen(graph, num_vert, chance);
@@ -78,7 +78,7 @@ int main(int argc, char *argv[]) {
7878
}
7979
graph_name += graph_edge_size;
8080

81-
graph_name += std::to_string(i);
81+
graph_name += std::to_string(j);
8282

8383
graph_name += ".mtx";
8484

apps/graph_generator/gen_near_diag_random_graph.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ int main(int argc, char *argv[]) {
6464

6565
// Generating graph name
6666
std::string graph_name = "RandomBand_";
67-
graph_name += "p" + std::to_string((int)(100 * prob)) + "_";
68-
graph_name += "b" + std::to_string((int)bandwidth) + "_";
67+
graph_name += "p" + std::to_string(static_cast<int>(100 * prob)) + "_";
68+
graph_name += "b" + std::to_string(static_cast<int>(bandwidth)) + "_";
6969
std::string graph_size_name;
7070
if (graph.num_vertices() < 1000) {
7171
graph_size_name = std::to_string(graph.num_vertices()) + "_";
@@ -105,12 +105,12 @@ int main(int argc, char *argv[]) {
105105
graph_write << header;
106106
graph_write << std::to_string(graph.num_vertices()) + " " + std::to_string(graph.num_vertices()) + " " +
107107
std::to_string(graph.num_edges() + graph.num_vertices()) + "\n";
108-
for (VertexType i = 0; i < num_vert; i++) {
108+
for (VertexType j = 0; j < num_vert; j++) {
109109
double val = (1 - 2 * randInt(2)) * std::exp(unif_log(re));
110-
graph_write << std::to_string(i + 1) + " " + std::to_string(i + 1) + " " + std::to_string(val) + "\n";
111-
for (const auto &chld : graph.children(i)) {
110+
graph_write << std::to_string(j + 1) + " " + std::to_string(j + 1) + " " + std::to_string(val) + "\n";
111+
for (const auto &chld : graph.children(j)) {
112112
val = unif(re);
113-
graph_write << std::to_string(chld + 1) + " " + std::to_string(i + 1) + " " + std::to_string(val) +
113+
graph_write << std::to_string(chld + 1) + " " + std::to_string(j + 1) + " " + std::to_string(val) +
114114
"\n";
115115
}
116116
}

apps/test_suite_runner/StatsModules/BspSptrsvStatsModule.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,13 @@ bool compare_vectors(Eigen::VectorXd &v1, Eigen::VectorXd &v2) {
6666
}
6767
}
6868
return same;
69-
};
69+
}
7070

7171
template<typename TargetObjectType>
7272
class BspSptrsvStatsModule : public IStatisticModule<TargetObjectType> {
7373
public:
74-
explicit BspSptrsvStatsModule(SCHEDULE_NODE_PERMUTATION_MODES mode = NO_PERMUTE)
75-
: mode(mode) {}
74+
explicit BspSptrsvStatsModule(SCHEDULE_NODE_PERMUTATION_MODES _mode = NO_PERMUTE)
75+
: mode(_mode) {}
7676

7777

7878
std::vector<std::string> get_metric_headers() const override {

apps/test_suite_runner/StringToScheduler/run_bsp_recomp_scheduler.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,6 @@ RETURN_STATUS run_bsp_recomp_scheduler(const ConfigParser &parser, const boost::
6565

6666
throw std::invalid_argument("Parameter error: Unknown algorithm.\n");
6767
}
68-
};
68+
}
6969

7070
} // namespace osp

apps/test_suite_runner/StringToScheduler/run_bsp_scheduler.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,6 @@ RETURN_STATUS run_bsp_scheduler(const ConfigParser &parser, const boost::propert
242242
auto scheduler = get_base_bsp_scheduler_by_name<Graph_t>(parser, algorithm);
243243
return scheduler->computeSchedule(schedule);
244244
}
245-
};
245+
}
246246

247247
} // namespace osp

include/osp/auxiliary/Balanced_Coin_Flips.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ class BalancedCoinFlips {
3333
/// @brief Returns true/false in a pseudo-random balanced manner
3434
/// @return true/false
3535
virtual bool get_flip() = 0;
36+
37+
virtual ~BalancedCoinFlips() = default;
3638
};
3739

3840
class Biased_Random : public BalancedCoinFlips {

include/osp/auxiliary/io/arch_file_reader.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ bool readBspArchitecture(std::ifstream &infile, BspArchitecture<Graph_t> &archit
7373
architecture.setMemoryConstraintType(MEMORY_CONSTRAINT_TYPE::PERSISTENT_AND_TRANSIENT);
7474
architecture.setMemoryBound(static_cast<memw_t>(M));
7575
break;
76+
default:
77+
std::cerr << "Invalid memory type.\n";
78+
return false;
7679
}
7780
} else if (mem_type == -1) {
7881
std::cout << "No memory type specified. Assuming \"NONE\".\n";

0 commit comments

Comments
 (0)