From 95b3ba346c184d3e90762829dd18f14429110d1c Mon Sep 17 00:00:00 2001 From: william-dawson Date: Wed, 15 Nov 2023 17:12:09 +0900 Subject: [PATCH] Extra warnings added and fixes to make them clear (#223) * Extra warnings added and fixes to make them clear Credit to ChatGPT * Make comm parameters intent in * A few more places * Remove ' from comments, because that's apparently a thing... * More places with ' * Turn off Werror Apparently the version of gfortran on github CI is so absurdly broken that it gives a warning about C++ style comments in a Fortran file... * I think my build conditionals are wrong * Maybe we need to reduce the number of threads, CI is slow * Simplify thread setting * typo --- .github/workflows/ci.yml | 14 ++--- CMakeLists.txt | 2 +- Source/C/TripletList_c.h | 4 +- Source/CPlusPlus/EigenBounds.h | 2 +- Source/CPlusPlus/InverseSolvers.h | 4 +- Source/CPlusPlus/Logging.cc | 2 +- Source/CPlusPlus/PSMatrix.cc | 8 +-- Source/CPlusPlus/Permutation.cc | 4 +- Source/CPlusPlus/Polynomial.h | 4 +- Source/CPlusPlus/ProcessGrid.h | 6 +++ Source/CPlusPlus/SMatrix.cc | 8 +-- Source/Fortran/CholeskySolversModule.F90 | 4 +- Source/Fortran/ConvergenceMonitorModule.F90 | 12 ++--- Source/Fortran/EigenBoundsModule.F90 | 4 +- Source/Fortran/EigenExaModule.F90 | 2 +- Source/Fortran/FermiOperatorModule.F90 | 2 +- Source/Fortran/MatrixReduceModule.F90 | 54 +++++++++---------- Source/Fortran/PSMatrixModule.F90 | 6 +-- Source/Fortran/TripletListModule.F90 | 4 +- .../Wrapper/PolynomialSolversModule_wrp.F90 | 4 +- Targets/Linux.cmake | 10 +++- UnitTests/run_ci_test.sh | 5 +- UnitTests/run_cmake.sh | 11 ++-- 23 files changed, 92 insertions(+), 84 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dd5412ec..4dff17b3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,7 @@ jobs: debug: 0 noalligather: 0 mpich: 0 - threadoff: 0 + numthread: 1 elsi: 0 - name: ubuntu-debug os: ubuntu-latest @@ -27,7 +27,7 @@ jobs: debug: 1 noalligather: 0 mpich: 0 - threadoff: 0 + numthread: 1 elsi: 0 - name: ubuntu-nogather os: ubuntu-latest @@ -37,7 +37,7 @@ jobs: debug: 0 noalligather: 1 mpich: 0 - threadoff: 0 + numthread: 1 elsi: 0 - name: ubuntu-mpich os: ubuntu-latest @@ -47,7 +47,7 @@ jobs: debug: 0 noalligather: 0 mpich: 1 - threadoff: 0 + numthread: 3 elsi: 0 - name: mac-thread-cap os: macos-latest @@ -57,7 +57,7 @@ jobs: debug: 0 noalligather: 0 mpich: 0 - threadoff: 1 + numthread: 3 elsi: 0 - name: mac os: macos-latest @@ -68,7 +68,7 @@ jobs: noalligather: 0 mpich: 0 lint: 1 - threadoff: 0 + numthread: 3 elsi: 1 runs-on: ${{ matrix.os }} steps: @@ -92,7 +92,7 @@ jobs: env: MAKETEST: ${{ matrix.maketest }} TESTOS: ${{ matrix.testos }} - THREADOFF: ${{ matrix.threadoff }} + OMP_NUM_THREADS: ${{ matrix.numthread }} - name: check examples run: | bash -l UnitTests/check_examples.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index c8db3eb7..eab501df 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ ################################################################################ ## Basic Setup cmake_minimum_required (VERSION 3.9) -project(NTPoly VERSION 2.7.0 DESCRIPTION +project(NTPoly VERSION 3.1.0 DESCRIPTION "A parallel library for computing the functions of sparse matrices") enable_language(Fortran) diff --git a/Source/C/TripletList_c.h b/Source/C/TripletList_c.h index d63af3a6..0a836403 100644 --- a/Source/C/TripletList_c.h +++ b/Source/C/TripletList_c.h @@ -8,7 +8,7 @@ void AppendToTripletList_r_wrp(int *ih_this, const int *index_column, void SetTripletAt_r_wrp(int *ih_this, const int *index, const int *index_column, const int *index_row, const double *point_value); void GetTripletAt_r_wrp(const int *ih_this, const int *index, int *index_column, - const int *index_row, double *point_value); + int *index_row, double *point_value); void DestructTripletList_r_wrp(int *ih_this); void SortTripletList_r_wrp(const int *ih_this, const int *matrix_size, int *h_sorted); @@ -24,7 +24,7 @@ void SetTripletAt_c_wrp(int *ih_this, const int *index, const int *index_column, const int *index_row, const double *point_value_real, const double *point_value_imag); void GetTripletAt_c_wrp(const int *ih_this, const int *index, int *index_column, - const int *index_row, const double *point_value_real, + int *index_row, const double *point_value_real, const double *point_value_imag); void DestructTripletList_c_wrp(int *ih_this); void SortTripletList_c_wrp(const int *ih_this, const int *matrix_size, diff --git a/Source/CPlusPlus/EigenBounds.h b/Source/CPlusPlus/EigenBounds.h index 592e808f..6c3c3304 100644 --- a/Source/CPlusPlus/EigenBounds.h +++ b/Source/CPlusPlus/EigenBounds.h @@ -11,7 +11,7 @@ class Matrix_ps; class EigenBounds : public SolverBase { public: //! Compute a bounds on the minimum and maximum eigenvalue of a matrix. - //! Uses Gershgorin's theorem. + //! Uses Gershgorin theorem. //!\param matrix the matrix to compute the min/max of. //!\param min_ger_eig a lower bound on the eigenspectrum. //!\param max_ger_eig an uppder bound on the eigenspectrum. diff --git a/Source/CPlusPlus/InverseSolvers.h b/Source/CPlusPlus/InverseSolvers.h index 19d241bd..de0c3ef1 100644 --- a/Source/CPlusPlus/InverseSolvers.h +++ b/Source/CPlusPlus/InverseSolvers.h @@ -11,7 +11,7 @@ class Matrix_ps; class InverseSolvers : public SolverBase { public: //! Compute the inverse of a matrix. - //! An implementation of Hotelling's method. + //! An implementation of Hotelling method. //!\param Overlap the matrix to invert. //!\param InverseMat = Overlap^-1. //!\param solver_parameters parameters for the solver @@ -24,7 +24,7 @@ class InverseSolvers : public SolverBase { static void DenseInvert(const Matrix_ps &Overlap, Matrix_ps &InverseMat, const SolverParameters &solver_parameters); //! Compute the pseudoinverse of a matrix. - //! An implementation of Hotelling's method, with a different convergence + //! An implementation of Hotelling method, with a different convergence //! criteria. //!\param Overlap the matrix to invert. //!\param InverseMat = Overlap^-1. diff --git a/Source/CPlusPlus/Logging.cc b/Source/CPlusPlus/Logging.cc index 65c7e3cc..87cb667d 100644 --- a/Source/CPlusPlus/Logging.cc +++ b/Source/CPlusPlus/Logging.cc @@ -13,7 +13,7 @@ void NTPoly::ActivateLogger(bool start_document) { //////////////////////////////////////////////////////////////////////////////// void NTPoly::ActivateLogger(const string file_name, bool start_document) { - int string_length = file_name.length(); + int string_length = static_cast(file_name.length()); string temp = file_name; ActivateLoggerFile_wrp(&start_document, &temp.c_str()[0], &string_length); } diff --git a/Source/CPlusPlus/PSMatrix.cc b/Source/CPlusPlus/PSMatrix.cc index fc51b1a0..c2c296bd 100644 --- a/Source/CPlusPlus/PSMatrix.cc +++ b/Source/CPlusPlus/PSMatrix.cc @@ -27,7 +27,7 @@ Matrix_ps::Matrix_ps(int matrix_dimension, const ProcessGrid &grid) { ////////////////////////////////////////////////////////////////////////////// Matrix_ps::Matrix_ps(std::string file_name, bool is_binary) { - int string_length = file_name.length(); + int string_length = static_cast(file_name.length()); if (is_binary) { ConstructMatrixFromBinary_ps_wrp(ih_this, &file_name.c_str()[0], &string_length); @@ -40,7 +40,7 @@ Matrix_ps::Matrix_ps(std::string file_name, bool is_binary) { ////////////////////////////////////////////////////////////////////////////// Matrix_ps::Matrix_ps(std::string file_name, const ProcessGrid &grid, bool is_binary) { - int string_length = file_name.length(); + int string_length = static_cast(file_name.length()); if (is_binary) { ConstructMatrixFromBinaryPG_ps_wrp(ih_this, &file_name.c_str()[0], &string_length, grid.ih_this); @@ -61,13 +61,13 @@ Matrix_ps::Matrix_ps(const Matrix_ps &matB) { ////////////////////////////////////////////////////////////////////////////// void Matrix_ps::WriteToBinary(std::string file_name) const { - int string_length = file_name.length(); + int string_length = static_cast(file_name.length()); WriteMatrixToBinary_ps_wrp(ih_this, &file_name.c_str()[0], &string_length); } ////////////////////////////////////////////////////////////////////////////// void Matrix_ps::WriteToMatrixMarket(string file_name) const { - int string_length = file_name.length(); + int string_length = static_cast(file_name.length()); WriteMatrixToMatrixMarket_ps_wrp(ih_this, &file_name.c_str()[0], &string_length); } diff --git a/Source/CPlusPlus/Permutation.cc b/Source/CPlusPlus/Permutation.cc index aeb97dd2..88af79d6 100644 --- a/Source/CPlusPlus/Permutation.cc +++ b/Source/CPlusPlus/Permutation.cc @@ -9,9 +9,9 @@ extern "C" { //////////////////////////////////////////////////////////////////////////////// namespace NTPoly { //////////////////////////////////////////////////////////////////////////////// -Permutation::Permutation(int matrix_dimension) { +Permutation::Permutation(int dimension) { was_filled = false; - this->matrix_dimension = matrix_dimension; + this->matrix_dimension = dimension; } //////////////////////////////////////////////////////////////////////////////// diff --git a/Source/CPlusPlus/Polynomial.h b/Source/CPlusPlus/Polynomial.h index 1ac22e31..50308038 100644 --- a/Source/CPlusPlus/Polynomial.h +++ b/Source/CPlusPlus/Polynomial.h @@ -23,13 +23,13 @@ class Polynomial : public SolverBase { void SetCoefficient(int degree, double coefficient); public: - //! Compute A Matrix Polynomial Using Horner's Method. + //! Compute A Matrix Polynomial Using Horner Method. //!\param InputMat input matrix. //!\param OutputMat = p(InputMat) //!\param solver_parameters parameters for the solver void HornerCompute(const Matrix_ps &InputMat, Matrix_ps &OutputMat, const SolverParameters &solver_parameters) const; - //! Compute A Matrix Polynomial Using Paterson and Stockmeyer's Method. + //! Compute A Matrix Polynomial Using Paterson and Stockmeyer Method. //!\param InputMat input matrix. //!\param OutputMat = p(InputMat) //!\param solver_parameters parameters for the solver diff --git a/Source/CPlusPlus/ProcessGrid.h b/Source/CPlusPlus/ProcessGrid.h index a4b0f6e6..f5f98803 100644 --- a/Source/CPlusPlus/ProcessGrid.h +++ b/Source/CPlusPlus/ProcessGrid.h @@ -1,6 +1,12 @@ #ifndef PROCESSGRID_h #define PROCESSGRID_h + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wcast-function-type" +#pragma GCC diagnostic ignored "-Wuseless-cast" +#pragma GCC diagnostic ignored "-Wold-style-cast" #include +#pragma GCC diagnostic pop #include "Wrapper.h" diff --git a/Source/CPlusPlus/SMatrix.cc b/Source/CPlusPlus/SMatrix.cc index 0e80db27..521d6546 100644 --- a/Source/CPlusPlus/SMatrix.cc +++ b/Source/CPlusPlus/SMatrix.cc @@ -21,12 +21,12 @@ Matrix_lsc::Matrix_lsc(int columns, int rows) { //////////////////////////////////////////////////////////////////////////////// Matrix_lsr::Matrix_lsr(std::string file_name) { - int string_length = file_name.length(); + int string_length = static_cast(file_name.length()); ConstructMatrixFromFile_lsr_wrp(ih_this, &file_name.c_str()[0], &string_length); } Matrix_lsc::Matrix_lsc(std::string file_name) { - int string_length = file_name.length(); + int string_length = static_cast(file_name.length()); ConstructMatrixFromFile_lsc_wrp(ih_this, &file_name.c_str()[0], &string_length); } @@ -193,12 +193,12 @@ void Matrix_lsc::Print() const { PrintMatrix_lsc_wrp(ih_this); } //////////////////////////////////////////////////////////////////////////////// void Matrix_lsr::WriteToMatrixMarket(string file_name) const { - int string_length = file_name.length(); + int string_length = static_cast(file_name.length()); PrintMatrixF_lsr_wrp(ih_this, &file_name.c_str()[0], &string_length); } void Matrix_lsc::WriteToMatrixMarket(string file_name) const { - int string_length = file_name.length(); + int string_length = static_cast(file_name.length()); PrintMatrixF_lsc_wrp(ih_this, &file_name.c_str()[0], &string_length); } diff --git a/Source/Fortran/CholeskySolversModule.F90 b/Source/Fortran/CholeskySolversModule.F90 index d87a270a..babc4b4e 100644 --- a/Source/Fortran/CholeskySolversModule.F90 +++ b/Source/Fortran/CholeskySolversModule.F90 @@ -79,7 +79,7 @@ SUBROUTINE BroadcastVector_r(num_values, indices, values, root, comm) !> Root from which we broadcast. INTEGER, INTENT(IN) :: root !> Communicator to broadcast along. - INTEGER, INTENT(INOUT) :: comm + INTEGER, INTENT(IN) :: comm !! Local INTEGER :: err @@ -153,7 +153,7 @@ SUBROUTINE DotAllHelper_r(num_values_i, indices_i, values_i, num_values_j, & !> The dot product values for each vector j. REAL(NTREAL), DIMENSION(:), INTENT(OUT) :: out_values !> The communicator to reduce along. - INTEGER, INTENT(INOUT) :: comm + INTEGER, INTENT(IN) :: comm #include "solver_includes/DotAllHelper.f90" diff --git a/Source/Fortran/ConvergenceMonitorModule.F90 b/Source/Fortran/ConvergenceMonitorModule.F90 index e0daf25f..92c6ac52 100644 --- a/Source/Fortran/ConvergenceMonitorModule.F90 +++ b/Source/Fortran/ConvergenceMonitorModule.F90 @@ -1,9 +1,9 @@ !> A module for monitoring convergence of an iterative algorithim. -!! In basic mode, we monitor that the last value isn't below the tight cutoff. +!! In basic mode, we monitor that the last value is not below the tight cutoff. !! In automatic mode we monitor the following conditions: -!! o The last value can't be negative +!! o The last value can not be negative !! o The moving average is within an order of magnitude -!! o The value isn't above the loose cutoff +!! o The value is not above the loose cutoff MODULE ConvergenceMonitor USE DataTypesModule, ONLY : NTREAL USE LoggingModule, ONLY : EnterSubLog, ExitSubLog, WriteElement, & @@ -18,7 +18,7 @@ MODULE ConvergenceMonitor REAL(NTREAL), DIMENSION(:), ALLOCATABLE :: win_long !> The number of values that have been added INTEGER :: nval - !> We aren't converged if the average isn't below this. + !> We are not converged if the average is not below this. REAL(NTREAL) :: loose_cutoff !> We definitely are converged if the last value is below this. REAL(NTREAL) :: tight_cutoff @@ -40,7 +40,7 @@ PURE SUBROUTINE ConstructMonitor(this, short_len_in, long_len_in, & INTEGER, INTENT(IN), OPTIONAL :: short_len_in !> The length of the long window (default: 6) INTEGER, INTENT(IN), OPTIONAL :: long_len_in - !> If the average is greater than this than we aren't + !> If the average is greater than this than we are not !! converged (default: 0.01) REAL(NTREAL), INTENT(IN), OPTIONAL :: loose_cutoff_in !> If the last value is less than this, we definitely are converged @@ -149,7 +149,7 @@ FUNCTION CheckConverged(this, be_verbose) RESULT(conv) !! Automatic disabled conv = .TRUE. - !! First check that we've seen enough values to make a judgement. + !! First check that we have seen enough values to make a judgement. IF (this%nval .LT. SIZE(this%win_long)) conv = .FALSE. !! Compute Averages diff --git a/Source/Fortran/EigenBoundsModule.F90 b/Source/Fortran/EigenBoundsModule.F90 index 7c14a4d7..2048c418 100644 --- a/Source/Fortran/EigenBoundsModule.F90 +++ b/Source/Fortran/EigenBoundsModule.F90 @@ -135,7 +135,7 @@ SUBROUTINE PowerBounds(this, max_value, solver_parameters_in) CALL ScaleMatrix(vector2, scale_value) CALL CopyMatrix(vector2, vector) - !! Aitken's Extrapolation + !! Aitken Extrapolation ritz_values(1) = ritz_values(2) ritz_values(2) = ritz_values(3) ritz_values(3) = max_value @@ -154,7 +154,7 @@ SUBROUTINE PowerBounds(this, max_value, solver_parameters_in) aitken_values(3) = ritz_values(3) END IF - !! Check if Converged - pass the negative value because we're looking + !! Check if Converged - pass the negative value because we are looking !! for the largest eigenvalue value. CALL AppendValue(params%monitor, & & - (aitken_values(3) - aitken_values(2))) diff --git a/Source/Fortran/EigenExaModule.F90 b/Source/Fortran/EigenExaModule.F90 index c94b3e91..19c31db0 100644 --- a/Source/Fortran/EigenExaModule.F90 +++ b/Source/Fortran/EigenExaModule.F90 @@ -164,7 +164,7 @@ END SUBROUTINE EigenExa_c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Setup the eigen exa data structures. SUBROUTINE InitializeEigenExa(A, nvals, eigenvectors, exa) - !> The matrix we're working on. + !> The matrix we are working on. TYPE(Matrix_ps), INTENT(IN) :: A !> Number of eigenvalues to compute. INTEGER, INTENT(IN) :: nvals diff --git a/Source/Fortran/FermiOperatorModule.F90 b/Source/Fortran/FermiOperatorModule.F90 index e428632b..1ab0a666 100644 --- a/Source/Fortran/FermiOperatorModule.F90 +++ b/Source/Fortran/FermiOperatorModule.F90 @@ -522,7 +522,7 @@ SUBROUTINE ComputeX(W, I, pool, threshold, Out, W2_out) REAL(NTREAL), INTENT(IN) :: threshold !> The result matrix. TYPE(Matrix_ps), INTENT(INOUT) :: Out - !> If you want the wave operator's square + !> If you want square of the wave operator TYPE(Matrix_ps), INTENT(INOUT), OPTIONAL :: W2_out !! Local matrices. TYPE(Matrix_ps) :: W2, Temp diff --git a/Source/Fortran/MatrixReduceModule.F90 b/Source/Fortran/MatrixReduceModule.F90 index 78b8ce64..3ca55e31 100644 --- a/Source/Fortran/MatrixReduceModule.F90 +++ b/Source/Fortran/MatrixReduceModule.F90 @@ -89,9 +89,9 @@ MODULE MatrixReduceModule SUBROUTINE ReduceAndComposeMatrixSizes_lsr(matrix, comm, gathered_matrix, & & helper) !> The matrix to send. - TYPE(Matrix_lsr), INTENT(IN) :: matrix + TYPE(Matrix_lsr), INTENT(IN) :: matrix !> The communicator to send along. - INTEGER, INTENT(INOUT) :: comm + INTEGER, INTENT(IN) :: comm !> The matrix we are gathering. TYPE(Matrix_lsr), INTENT(INOUT) :: gathered_matrix !> The helper associated with this gather. @@ -107,9 +107,9 @@ END SUBROUTINE ReduceAndComposeMatrixSizes_lsr SUBROUTINE ReduceAndComposeMatrixSizes_lsc(matrix, comm, gathered_matrix, & & helper) !! The matrix to send. - TYPE(Matrix_lsc), INTENT(IN) :: matrix + TYPE(Matrix_lsc), INTENT(IN) :: matrix !! The communicator to send along. - INTEGER, INTENT(INOUT) :: comm + INTEGER, INTENT(IN) :: comm !> The matrix we are gathering. TYPE(Matrix_lsc), INTENT(INOUT) :: gathered_matrix !! The helper associated with this gather. @@ -126,11 +126,11 @@ END SUBROUTINE ReduceAndComposeMatrixSizes_lsc SUBROUTINE ReduceAndComposeMatrixData_lsr(matrix, comm, gathered_matrix, & & helper) !> The matrix to send. - TYPE(Matrix_lsr), INTENT(IN) :: matrix + TYPE(Matrix_lsr), INTENT(IN) :: matrix !> The communicator to send along. - INTEGER, INTENT(INOUT) :: comm + INTEGER, INTENT(IN) :: comm !> The matrix we are gathering. - TYPE(Matrix_lsr), INTENT(INOUT) :: gathered_matrix + TYPE(Matrix_lsr), INTENT(INOUT) :: gathered_matrix !> The helper associated with this gather. TYPE(ReduceHelper_t), INTENT(INOUT) :: helper #ifdef NOIALLGATHER @@ -157,11 +157,11 @@ END SUBROUTINE ReduceAndComposeMatrixData_lsr SUBROUTINE ReduceAndComposeMatrixData_lsc(matrix, comm, gathered_matrix, & & helper) !> The matrix to send. - TYPE(Matrix_lsc), INTENT(IN) :: matrix + TYPE(Matrix_lsc), INTENT(IN) :: matrix !> The communicator to send along. - INTEGER, INTENT(INOUT) :: comm + INTEGER, INTENT(IN) :: comm !> The matrix we are gathering. - TYPE(Matrix_lsc), INTENT(INOUT) :: gathered_matrix + TYPE(Matrix_lsc), INTENT(INOUT) :: gathered_matrix !> The helper associated with this gather. TYPE(ReduceHelper_t), INTENT(INOUT) :: helper #ifdef NOIALLGATHER @@ -256,9 +256,9 @@ END SUBROUTINE ReduceAndComposeMatrixCleanup_lsc !> lose the opportunity for overlapping communication. SUBROUTINE ReduceAndComposeMatrix_lsr(matrix, comm, gathered_matrix) !> The matrix to send. - TYPE(Matrix_lsr), INTENT(IN) :: matrix + TYPE(Matrix_lsr), INTENT(IN) :: matrix !> The communicator to send along. - INTEGER, INTENT(INOUT) :: comm + INTEGER, INTENT(IN) :: comm !> The matrix we are gathering. TYPE(Matrix_lsr), INTENT(INOUT) :: gathered_matrix !! Local Variables @@ -272,9 +272,9 @@ END SUBROUTINE ReduceAndComposeMatrix_lsr !> lose the opportunity for overlapping communication. SUBROUTINE ReduceAndComposeMatrix_lsc(matrix, comm, gathered_matrix) !> The matrix to send. - TYPE(Matrix_lsc), INTENT(IN) :: matrix + TYPE(Matrix_lsc), INTENT(IN) :: matrix !> The communicator to send along. - INTEGER, INTENT(INOUT) :: comm + INTEGER, INTENT(IN) :: comm !> The matrix we are gathering. TYPE(Matrix_lsc), INTENT(INOUT) :: gathered_matrix !! Local Variables @@ -287,11 +287,11 @@ END SUBROUTINE ReduceAndComposeMatrix_lsc !> The first routine to call, gathers the sizes of the data to be sent. SUBROUTINE ReduceAndSumMatrixSizes_lsr(matrix, comm, gathered_matrix, helper) !> The matrix to send. - TYPE(Matrix_lsr), INTENT(IN) :: matrix + TYPE(Matrix_lsr), INTENT(IN) :: matrix !> The communicator to send along. - INTEGER, INTENT(INOUT) :: comm + INTEGER, INTENT(IN) :: comm !> The matrix we are gathering. - TYPE(Matrix_lsr), INTENT(INOUT) :: gathered_matrix + TYPE(Matrix_lsr), INTENT(INOUT) :: gathered_matrix !> The helper associated with this gather. TYPE(ReduceHelper_t), INTENT(INOUT) :: helper #ifdef NOIALLGATHER @@ -304,9 +304,9 @@ END SUBROUTINE ReduceAndSumMatrixSizes_lsr !> The first routine to call, gathers the sizes of the data to be sent. SUBROUTINE ReduceAndSumMatrixSizes_lsc(matrix, comm, gathered_matrix, helper) !> The matrix to send. - TYPE(Matrix_lsc), INTENT(IN) :: matrix + TYPE(Matrix_lsc), INTENT(IN) :: matrix !> The communicator to send along. - INTEGER, INTENT(INOUT) :: comm + INTEGER, INTENT(IN) :: comm !> The matrix we are gathering. TYPE(Matrix_lsc), INTENT(INOUT) :: gathered_matrix !> The helper associated with this gather. @@ -321,9 +321,9 @@ END SUBROUTINE ReduceAndSumMatrixSizes_lsc !> Second routine to call for gathering and summing up the data. SUBROUTINE ReduceAndSumMatrixData_lsr(matrix, comm, gathered_matrix, helper) !> The matrix to send. - TYPE(Matrix_lsr), INTENT(IN) :: matrix + TYPE(Matrix_lsr), INTENT(IN) :: matrix !> The communicator to send along. - INTEGER, INTENT(INOUT) :: comm + INTEGER, INTENT(IN) :: comm !> The matrix we are gathering. TYPE(Matrix_lsr), INTENT(INOUT) :: gathered_matrix !> The helper associated with this gather. @@ -350,9 +350,9 @@ END SUBROUTINE ReduceAndSumMatrixData_lsr !> Second routine to call for gathering and summing up the data. SUBROUTINE ReduceAndSumMatrixData_lsc(matrix, comm, gathered_matrix, helper) !> The matrix to send. - TYPE(Matrix_lsc), INTENT(IN) :: matrix + TYPE(Matrix_lsc), INTENT(IN) :: matrix !> The communicator to send along. - INTEGER, INTENT(INOUT) :: comm + INTEGER, INTENT(IN) :: comm !> The matrix we are gathering. TYPE(Matrix_lsc), INTENT(INOUT) :: gathered_matrix !> The helper associated with this gather. @@ -455,9 +455,9 @@ END SUBROUTINE ReduceAndSumMatrixCleanup_lsc !> lose the opportunity for overlapping communication. SUBROUTINE ReduceAndSumMatrix_lsr(matrix, comm, gathered_matrix, threshold) !> The matrix to send. - TYPE(Matrix_lsr), INTENT(IN) :: matrix + TYPE(Matrix_lsr), INTENT(IN) :: matrix !> The communicator to send along. - INTEGER, INTENT(INOUT) :: comm + INTEGER, INTENT(IN) :: comm !> The gathered_matrix the matrix being gathered. TYPE(Matrix_lsr), INTENT(INOUT) :: gathered_matrix !> The threshold the threshold for flushing values. @@ -472,9 +472,9 @@ END SUBROUTINE ReduceAndSumMatrix_lsr !> lose the opportunity for overlapping communication. SUBROUTINE ReduceAndSumMatrix_lsc(matrix, comm, gathered_matrix, threshold) !> The matrix to send. - TYPE(Matrix_lsc), INTENT(IN) :: matrix + TYPE(Matrix_lsc), INTENT(IN) :: matrix !> The communicator to send along. - INTEGER, INTENT(INOUT) :: comm + INTEGER, INTENT(IN) :: comm !> The threshold the threshold for flushing values. TYPE(Matrix_lsc), INTENT(INOUT) :: gathered_matrix !> The threshold the threshold for flushing values. diff --git a/Source/Fortran/PSMatrixModule.F90 b/Source/Fortran/PSMatrixModule.F90 index a9783ffe..19812a28 100644 --- a/Source/Fortran/PSMatrixModule.F90 +++ b/Source/Fortran/PSMatrixModule.F90 @@ -398,7 +398,7 @@ RECURSIVE SUBROUTINE ConstructMatrixFromMatrixMarket_ps(this, file_name, & OPEN(local_file_handler, file = file_name, iostat = ierr, & & status = "old") IF (ierr .NE. 0) THEN - CALL SetGenericError(err, TRIM(file_name) // " doesn't exist", & + CALL SetGenericError(err, TRIM(file_name) // " does not exist", & & .TRUE.) END IF !! Parse the header. @@ -600,7 +600,7 @@ RECURSIVE SUBROUTINE ConstructMatrixFromBinary_ps(this, file_name, & CALL ConstructError(err) CALL MPI_File_open(process_grid_in%global_comm, file_name, & & MPI_MODE_RDONLY, MPI_INFO_NULL, mpi_file_handler, ierr) - error_occured = CheckMPIError(err, TRIM(file_name)//" doesn't exist", & + error_occured = CheckMPIError(err, TRIM(file_name)//" does not exist", & & ierr, .TRUE.) !! General Sizes @@ -650,7 +650,7 @@ RECURSIVE SUBROUTINE ConstructMatrixFromBinary_ps(this, file_name, & END IF !! Compute Offset - local_triplets = total_values / this%process_grid%total_processors + local_triplets = INT(total_values / this%process_grid%total_processors) local_offset = INT(local_triplets, KIND=NTLONG) * & & this%process_grid%global_rank header_size = 3 * bytes_per_int + bytes_per_long diff --git a/Source/Fortran/TripletListModule.F90 b/Source/Fortran/TripletListModule.F90 index 9caaa264..29c0de68 100644 --- a/Source/Fortran/TripletListModule.F90 +++ b/Source/Fortran/TripletListModule.F90 @@ -331,7 +331,7 @@ SUBROUTINE RedistributeTripletLists_r(triplet_lists, comm, local_data_out) !> A list of triplet lists, one for each process. TYPE(TripletList_r), DIMENSION(:), INTENT(IN) :: triplet_lists !> The mpi communicator to redistribute along. - INTEGER, INTENT(INOUT) :: comm + INTEGER, INTENT(IN) :: comm !> The resulting local triplet list. TYPE(TripletList_r), INTENT(INOUT) :: local_data_out !! Local data (type specific) @@ -352,7 +352,7 @@ SUBROUTINE RedistributeTripletLists_c(triplet_lists, comm, local_data_out) !> A list of triplet lists, one for each process. TYPE(TripletList_c), DIMENSION(:), INTENT(IN) :: triplet_lists !> The mpi communicator to redistribute along. - INTEGER, INTENT(INOUT) :: comm + INTEGER, INTENT(IN) :: comm !> The resulting local triplet list. TYPE(TripletList_c), INTENT(INOUT) :: local_data_out !! Local data (type specific) diff --git a/Source/Wrapper/PolynomialSolversModule_wrp.F90 b/Source/Wrapper/PolynomialSolversModule_wrp.F90 index ba0b869c..1fec990b 100644 --- a/Source/Wrapper/PolynomialSolversModule_wrp.F90 +++ b/Source/Wrapper/PolynomialSolversModule_wrp.F90 @@ -58,7 +58,7 @@ SUBROUTINE SetCoefficient_wrp(ih_this, degree, coefficient) & CALL SetCoefficient(h_this%DATA, degree, coefficient) END SUBROUTINE SetCoefficient_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !> Compute A Matrix Polynomial Using Horner's Method. + !> Compute A Matrix Polynomial Using Horner Method. SUBROUTINE HornerCompute_wrp(ih_InputMat, ih_OutputMat, ih_polynomial, & & ih_solver_parameters) BIND(c,name="HornerCompute_wrp") INTEGER(kind=c_int), INTENT(IN) :: ih_InputMat(SIZE_wrp) @@ -79,7 +79,7 @@ SUBROUTINE HornerCompute_wrp(ih_InputMat, ih_OutputMat, ih_polynomial, & & h_polynomial%DATA, h_solver_parameters%DATA) END SUBROUTINE HornerCompute_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !> Compute A Matrix Polynomial Using Paterson and Stockmeyer's method. + !> Compute A Matrix Polynomial Using Paterson and Stockmeyer method. SUBROUTINE PatersonStockmeyerCompute_wrp(ih_InputMat, ih_OutputMat, & & ih_polynomial, ih_solver_parameters) & & BIND(c,name="PatersonStockmeyerCompute_wrp") diff --git a/Targets/Linux.cmake b/Targets/Linux.cmake index 69989110..8fb93c1e 100644 --- a/Targets/Linux.cmake +++ b/Targets/Linux.cmake @@ -13,5 +13,11 @@ set(CXX_TOOLCHAINFLAGS_RELEASE "-O3 -fopenmp") set(F_TOOLCHAINFLAGS_RELEASE "-O3 -cpp -fopenmp") # Debug suggestions -set(CXX_TOOLCHAINFLAGS_DEBUG "-O0 -fopenmp -Wall") -set(F_TOOLCHAINFLAGS_DEBUG "-O0 -cpp -fcheck=all -Wall -std=f2003") +set(CXX_TOOLCHAINFLAGS_DEBUG "-O0 -fopenmp -Wall -Wextra \ + -pedantic -pedantic-errors -Wshadow -Wnull-dereference \ + -Wdouble-promotion -Woverloaded-virtual -Wmisleading-indentation \ + -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Wuseless-cast \ + -Wsign-conversion -Wconversion -Wcast-align -Wold-style-cast") +set(F_TOOLCHAINFLAGS_DEBUG "-O0 -cpp -fcheck=all -Wall -Wextra \ + -pedantic -fimplicit-none -ffpe-trap=invalid,zero,overflow,underflow \ + -std=f2003") diff --git a/UnitTests/run_ci_test.sh b/UnitTests/run_ci_test.sh index c3c773d0..6714d643 100644 --- a/UnitTests/run_ci_test.sh +++ b/UnitTests/run_ci_test.sh @@ -4,10 +4,7 @@ if [[ "$TESTOS" == "LINUX" ]]; then conda activate ntpoly-conda fi -if [[ "$THREADOFF" == "1" ]]; then - export OMP_NUM_THREADS=1 - echo "Setting threads to 1" -fi +echo "Setting threads to $OMP_NUM_THREADS" cd Build export CTEST_OUTPUT_ON_FAILURE=1 diff --git a/UnitTests/run_cmake.sh b/UnitTests/run_cmake.sh index 41e08975..5c324b2e 100644 --- a/UnitTests/run_cmake.sh +++ b/UnitTests/run_cmake.sh @@ -10,15 +10,14 @@ if [[ "$TESTOS" == "OSX" ]]; then cmake -G Ninja .. -DCMAKE_TOOLCHAIN_FILE=../Targets/Mac-python3.cmake \ -DCMAKE_BUILD_TYPE=Release ; else - if [ ! -z ${NOIALLGATHER+x} ]; then - cmake -G Ninja .. \ - -DCMAKE_BUILD_TYPE=Debug -DNOIALLGATHER=YES; - elif [ ! -z ${DEBUG+x} ]; then + if [[ "${NOIALLGATHER:-0}" -eq 1 ]]; then + cmake -G Ninja .. -DCMAKE_BUILD_TYPE=Debug -DNOIALLGATHER=YES; + elif [[ "${DEBUG:-0}" -eq 1 ]]; then cmake -G Ninja .. -DCMAKE_TOOLCHAIN_FILE=../Targets/Linux.cmake \ - -DCMAKE_BUILD_TYPE=Debug ; + -DCMAKE_BUILD_TYPE=Debug; else cmake -G Ninja .. -DCMAKE_TOOLCHAIN_FILE=../Targets/Linux.cmake \ - -DCMAKE_BUILD_TYPE=Release ; + -DCMAKE_BUILD_TYPE=Release; fi fi