diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3bb0dda..22e9192 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -38,6 +38,12 @@ set(SRC_FILES add_executable(dphpc ${SRC_FILES}) +if(MSVC) + target_compile_options(dphpc PRIVATE /W4) +else() + target_compile_options(dphpc PRIVATE -Wall) +endif() + if(MSVC) source_group(TREE ${CMAKE_SOURCE_DIR} FILES ${SRC_FILES}) endif() diff --git a/src/competitors/cpu/cpu_basic.hpp b/src/competitors/cpu/cpu_basic.hpp index 09d4a81..c03c669 100644 --- a/src/competitors/cpu/cpu_basic.hpp +++ b/src/competitors/cpu/cpu_basic.hpp @@ -16,8 +16,8 @@ namespace Competitors { {} virtual inline void run_csr(Dense &A, Dense &B, CSR &S, CSR &P) { - const unsigned int K = B.getCols(); - const unsigned int M = S.getRows(); + const int K = B.getCols(); + const int M = S.getRows(); for (int i = 0; i < M; i++) { for (int j = S.getRowPositions()[i]; j < S.getRowPositions()[i+1]; j++) { @@ -28,7 +28,7 @@ namespace Competitors { } } - for (int i = 0; i < S.getRowPositions().size() - 1; i++) { + for (uint32_t i = 0; i < S.getRowPositions().size() - 1; i++) { for (int j = S.getRowPositions()[i]; j < S.getRowPositions()[i+1]; j++) { (*P.getValue(j)) *= S.getValues()[j]; } @@ -37,17 +37,16 @@ namespace Competitors { } virtual inline void run_coo(Dense &A, Dense &B, COO &S, COO &P) { - const unsigned int K = B.getCols(); - const unsigned int M = S.getRows(); + const int K = B.getCols(); - for (int i = 0; i < S.getValues().size(); i++) { + for (uint32_t i = 0; i < S.getValues().size(); i++) { *P.getValue(i) = static_cast(0); for (int k = 0; k < K; k++) { (*P.getValue(i)) += A.getValue(S.getRowPositions()[i], k) * B.getValue(S.getColPositions()[i], k); } } - for (int i = 0; i < S.getValues().size(); i++) { + for (uint32_t i = 0; i < S.getValues().size(); i++) { (*P.getValue(i)) *= S.getValues()[i]; } } diff --git a/src/main.cpp b/src/main.cpp index 529a4f9..df3f9a9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -77,7 +77,7 @@ static void print_config(Config config) { DEBUG_OUT("----------------------------------------" << std::endl); } -static void usage(const char *argv0) { +static void usage() { std::cout << "----------------------------------------" << std::endl; std::cout << "Options:" << std::endl; std::cout << " -d, --data_folder (folder to read datasets from)" << std::endl; @@ -97,7 +97,6 @@ int main(int argc, char* argv[]) { }; #ifndef _WIN32 - int K = 32; static struct option long_options[] = { { .name = "data_folder", .has_arg = 1, .val = 'd' }, { .name = "K", .has_arg = 1, .val = 'k' }, @@ -111,7 +110,7 @@ int main(int argc, char* argv[]) { } else if (c == 'k') { config.K = std::stoi(optarg); } else { - usage(argv[0]); + usage(); return 1; } } diff --git a/src/matrices/COO.hpp b/src/matrices/COO.hpp index 42c8d77..1b2e158 100644 --- a/src/matrices/COO.hpp +++ b/src/matrices/COO.hpp @@ -20,21 +20,14 @@ template class COO { public: - COO() { - this->rows = 0; - this->cols = 0; - - this->rowPositions = std::vector(0); - this->colPositions = std::vector(0); - this->values = std::vector(0); - } + COO() + : rows(0), cols(0), rowPositions(std::vector(0)), colPositions(std::vector(0)), values(std::vector(0)) + { } - COO(int rows, int cols, std::vector> values) { + COO(int rows, int cols, std::vector> values) + : rows(rows), cols(cols) { assert(values.size() > 0); - this->rows = rows; - this->cols = cols; - this->rowPositions = std::vector(0); this->colPositions = std::vector(0); this->values = std::vector(0); @@ -50,7 +43,9 @@ class COO { } } - COO(const COO &other) : rows(other.rows), cols(other.cols), values(other.values), colPositions(other.colPositions), rowPositions(other.rowPositions) {} + COO(const COO &other) + : rows(other.rows), cols(other.cols), rowPositions(other.rowPositions), colPositions(other.colPositions), values(other.values) + {} COO(CSR &csr) { this->rows = csr.getRows(); @@ -107,7 +102,7 @@ class COO { return false; } - for(int i = 0; i < lhs.values.size();i++) { + for(uint32_t i = 0; i < lhs.values.size();i++) { valMatch &= abs(rhs.values[i] - lhs.values[i]) <= 1e-6; } } @@ -156,11 +151,11 @@ class COO { } private: - std::vector colPositions; - std::vector rowPositions; - std::vector values; int rows; int cols; + std::vector rowPositions; + std::vector colPositions; + std::vector values; }; diff --git a/src/matrices/CSR.hpp b/src/matrices/CSR.hpp index 3b6a5f1..2fe4d49 100644 --- a/src/matrices/CSR.hpp +++ b/src/matrices/CSR.hpp @@ -20,23 +20,18 @@ template class CSR { public: - CSR() { - this->rows = 0; - this->cols = 0; - - this->rowPositions = std::vector(0); - this->colPositions = std::vector(0); - this->values = std::vector(0); - } - - CSR(int rows, int cols, std::vector> triplets) { - this->rows = rows; - this->cols = cols; + CSR() + : rows(0), cols(0), rowPositions(std::vector(0)), colPositions(std::vector(0)), values(std::vector(0)) + {} + CSR(int rows, int cols, std::vector> triplets) + : rows(rows), cols(cols) { init_csr(triplets); } - CSR(const CSR &other) : rows(other.rows), cols(other.cols), values(other.values), colPositions(other.colPositions), rowPositions(other.rowPositions) {} + CSR(const CSR &other) + : rows(other.rows), cols(other.cols), rowPositions(other.rowPositions), colPositions(other.colPositions), values(other.values) + {} CSR(COO &coo) { this->rows = coo.getRows(); @@ -44,7 +39,7 @@ class CSR { std::vector> triplets(coo.getValues().size()); - for (int i = 0; i < coo.getValues().size(); i++) { + for (uint32_t i = 0; i < coo.getValues().size(); i++) { triplets[i].row = coo.getRowPositions()[i]; triplets[i].col = coo.getColPositions()[i]; triplets[i].value = coo.getValues()[i]; @@ -86,7 +81,7 @@ class CSR { return false; } - for(int i = 0; i < lhs.values.size();i++) { + for(uint32_t i = 0; i < lhs.values.size();i++) { valMatch &= abs(rhs.values[i] - lhs.values[i]) <= 1e-6; } } @@ -135,11 +130,11 @@ class CSR { } private: - std::vector colPositions; - std::vector rowPositions; - std::vector values; int rows; int cols; + std::vector rowPositions; + std::vector colPositions; + std::vector values; void init_csr(std::vector> triplets) { assert(triplets.size() > 0);