From 25d6eaf41dbdb423ba422438507231044920090a Mon Sep 17 00:00:00 2001 From: Nai-Yuan Chiang Date: Wed, 6 Sep 2023 20:00:17 -0700 Subject: [PATCH] try to fix the CI tests on github (#654) * try to fix the CI tests on github * try to fix the CI tests on github * add deepcheck * pass quartz CI * build on lassen * remove some unused var * fix PNNL CI v1 * try to fix ginkgo issue --- src/Drivers/Dense/NlpDenseConsEx1Driver.cpp | 3 +- src/Drivers/Dense/NlpDenseConsEx2.cpp | 2 +- src/Drivers/Dense/NlpDenseConsEx2.hpp | 2 + src/Drivers/Dense/NlpDenseConsEx3.hpp | 5 +- src/Drivers/Dense/NlpDenseConsEx4.cpp | 2 +- src/Drivers/Dense/NlpDenseConsEx4.hpp | 2 + src/Drivers/MDS/NlpMdsRajaEx1.cpp | 4 +- src/Drivers/PriDec/NlpPriDecEx1.cpp | 4 +- src/Drivers/PriDec/NlpPriDecEx1.hpp | 14 ++--- src/Drivers/PriDec/NlpPriDecEx2.cpp | 18 ++++--- src/Drivers/PriDec/NlpPriDecEx2.hpp | 20 +++---- src/Drivers/PriDec/NlpPriDecEx2Sparse.cpp | 16 +++--- src/Drivers/PriDec/NlpPriDecEx2Sparse.hpp | 20 +++---- src/Drivers/PriDec/NlpPriDecEx2SparseRaja.cpp | 10 ++-- src/Drivers/PriDec/NlpPriDecEx2SparseRaja.hpp | 20 +++---- .../PriDec/NlpPriDecEx2UserBasecase.hpp | 1 + .../PriDec/NlpPriDecEx2UserRecourseMds.hpp | 7 ++- .../PriDec/NlpPriDecEx2UserRecourseSparse.hpp | 8 +-- .../NlpPriDecEx2UserRecourseSparseRaja.hpp | 10 ++-- src/Drivers/PriDec/NlpPriDecEx3Sparse.hpp | 52 ++++++++++++------- src/Drivers/Sparse/NlpSparseEx2.cpp | 42 +++++++-------- src/Drivers/Sparse/NlpSparseEx2.hpp | 7 ++- src/Interface/chiopInterface.cpp | 3 +- src/Interface/hiopInterfacePrimalDecomp.hpp | 8 +-- src/LinAlg/hiopLinSolverSparseGinkgo.cpp | 17 +++--- src/LinAlg/hiopLinSolverSymDenseMagma.cpp | 4 -- src/LinAlg/hiopLinSolverSymSparseMA57.cpp | 7 ++- src/LinAlg/hiopLinSolverUMFPACKZ.cpp | 6 ++- src/LinAlg/hiopMatrixDenseRajaImpl.hpp | 3 -- src/LinAlg/hiopMatrixMDS.hpp | 3 +- src/LinAlg/hiopMatrixRajaSparseTriplet.hpp | 4 +- .../hiopMatrixRajaSparseTripletImpl.hpp | 33 ++++-------- src/LinAlg/hiopMatrixSparseCsrCuda.cpp | 8 --- src/LinAlg/hiopMatrixSparseTriplet.cpp | 5 -- src/LinAlg/hiopVectorCompoundPD.cpp | 7 +-- src/LinAlg/hiopVectorCuda.cpp | 4 +- src/LinAlg/hiopVectorHip.cpp | 4 +- src/LinAlg/hiopVectorRajaImpl.hpp | 4 +- src/Optimization/hiopAlgPrimalDecomp.cpp | 10 ---- src/Optimization/hiopHessianLowRank.cpp | 22 ++++---- src/Optimization/hiopKKTLinSys.cpp | 21 +++----- src/Optimization/hiopKKTLinSysMDS.cpp | 12 ++--- src/Optimization/hiopKKTLinSysSparse.cpp | 1 - .../hiopKKTLinSysSparseCondensed.cpp | 13 ++--- .../hiopKKTLinSysSparseNormalEqn.cpp | 16 +++--- src/Optimization/hiopNlpTransforms.cpp | 6 +-- src/Utils/hiopCSR_IO.hpp | 12 ++++- src/Utils/hiopKronReduction.cpp | 4 +- src/Utils/hiopRunStats.hpp | 6 ++- tests/LinAlg/matrixTestsDense.hpp | 2 - tests/LinAlg/matrixTestsSparse.hpp | 4 -- tests/test_bicgstab.cpp | 11 ++-- tests/test_pcg.cpp | 14 +++-- 53 files changed, 262 insertions(+), 281 deletions(-) diff --git a/src/Drivers/Dense/NlpDenseConsEx1Driver.cpp b/src/Drivers/Dense/NlpDenseConsEx1Driver.cpp index a5be5d3a0..4fbebc4b0 100644 --- a/src/Drivers/Dense/NlpDenseConsEx1Driver.cpp +++ b/src/Drivers/Dense/NlpDenseConsEx1Driver.cpp @@ -60,8 +60,9 @@ static void usage(const char* exeName) int main(int argc, char **argv) { - int rank=0, numRanks=1; + int rank = 0; #ifdef HIOP_USE_MPI + int numRanks = 1; int err; err = MPI_Init(&argc, &argv); assert(MPI_SUCCESS==err); err = MPI_Comm_rank(MPI_COMM_WORLD,&rank); assert(MPI_SUCCESS==err); diff --git a/src/Drivers/Dense/NlpDenseConsEx2.cpp b/src/Drivers/Dense/NlpDenseConsEx2.cpp index 4a4897508..cffbd97c2 100644 --- a/src/Drivers/Dense/NlpDenseConsEx2.cpp +++ b/src/Drivers/Dense/NlpDenseConsEx2.cpp @@ -7,12 +7,12 @@ DenseConsEx2::DenseConsEx2(int n, bool unconstrained) : n_vars_(n), n_cons_(4), - comm(MPI_COMM_WORLD), unconstrained_(unconstrained) { comm_size = 1; my_rank = 0; #ifdef HIOP_USE_MPI + comm = MPI_COMM_WORLD; int ierr = MPI_Comm_size(comm, &comm_size); assert(MPI_SUCCESS==ierr); ierr = MPI_Comm_rank(comm, &my_rank); assert(MPI_SUCCESS==ierr); #endif diff --git a/src/Drivers/Dense/NlpDenseConsEx2.hpp b/src/Drivers/Dense/NlpDenseConsEx2.hpp index 0006a8d76..b9761013c 100644 --- a/src/Drivers/Dense/NlpDenseConsEx2.hpp +++ b/src/Drivers/Dense/NlpDenseConsEx2.hpp @@ -90,7 +90,9 @@ class DenseConsEx2 : public hiop::hiopInterfaceDenseConstraints */ private: size_type n_vars_, n_cons_; +#ifdef HIOP_USE_MPI MPI_Comm comm; +#endif int my_rank; int comm_size; index_type* col_partition_; diff --git a/src/Drivers/Dense/NlpDenseConsEx3.hpp b/src/Drivers/Dense/NlpDenseConsEx3.hpp index d912db52d..d539c5c77 100644 --- a/src/Drivers/Dense/NlpDenseConsEx3.hpp +++ b/src/Drivers/Dense/NlpDenseConsEx3.hpp @@ -33,10 +33,11 @@ class DenseConsEx3 : public hiop::hiopInterfaceDenseConstraints { public: DenseConsEx3(int n) - : n_vars(n), n_cons(2), comm(MPI_COMM_WORLD) + : n_vars(n), n_cons(2) { comm_size=1; my_rank=0; #ifdef HIOP_USE_MPI + comm = MPI_COMM_WORLD; int ierr = MPI_Comm_size(comm, &comm_size); assert(MPI_SUCCESS==ierr); ierr = MPI_Comm_rank(comm, &my_rank); assert(MPI_SUCCESS==ierr); #endif @@ -226,7 +227,9 @@ class DenseConsEx3 : public hiop::hiopInterfaceDenseConstraints private: int n_vars, n_cons; +#ifdef HIOP_USE_MPI MPI_Comm comm; +#endif int my_rank, comm_size; index_type* col_partition; public: diff --git a/src/Drivers/Dense/NlpDenseConsEx4.cpp b/src/Drivers/Dense/NlpDenseConsEx4.cpp index af196a637..bcca2e40a 100644 --- a/src/Drivers/Dense/NlpDenseConsEx4.cpp +++ b/src/Drivers/Dense/NlpDenseConsEx4.cpp @@ -7,12 +7,12 @@ DenseConsEx4::DenseConsEx4() : n_vars_(2), n_cons_(4), - comm(MPI_COMM_WORLD), unconstrained_(false) { comm_size = 1; my_rank = 0; #ifdef HIOP_USE_MPI + comm = MPI_COMM_WORLD; int ierr = MPI_Comm_size(comm, &comm_size); assert(MPI_SUCCESS==ierr); ierr = MPI_Comm_rank(comm, &my_rank); assert(MPI_SUCCESS==ierr); #endif diff --git a/src/Drivers/Dense/NlpDenseConsEx4.hpp b/src/Drivers/Dense/NlpDenseConsEx4.hpp index 451bf467c..e9cc78628 100644 --- a/src/Drivers/Dense/NlpDenseConsEx4.hpp +++ b/src/Drivers/Dense/NlpDenseConsEx4.hpp @@ -87,7 +87,9 @@ class DenseConsEx4 : public hiop::hiopInterfaceDenseConstraints */ private: size_type n_vars_, n_cons_; +#ifdef HIOP_USE_MPI MPI_Comm comm; +#endif int my_rank; int comm_size; index_type* col_partition_; diff --git a/src/Drivers/MDS/NlpMdsRajaEx1.cpp b/src/Drivers/MDS/NlpMdsRajaEx1.cpp index 4533a1002..064c1d05a 100644 --- a/src/Drivers/MDS/NlpMdsRajaEx1.cpp +++ b/src/Drivers/MDS/NlpMdsRajaEx1.cpp @@ -94,8 +94,8 @@ using hiopMatrixRajaDense = hiop::hiopMatrixDenseRaja(nc_) == n); double* grad_vec = grad.local_data(); diff --git a/src/Drivers/PriDec/NlpPriDecEx1.hpp b/src/Drivers/PriDec/NlpPriDecEx1.hpp index d425560a7..a0d3663f8 100644 --- a/src/Drivers/PriDec/NlpPriDecEx1.hpp +++ b/src/Drivers/PriDec/NlpPriDecEx1.hpp @@ -151,12 +151,12 @@ class PriDecMasterProblemEx1 : public hiopInterfacePriDecProblem /** * This function returns the recourse objective, which is 0.5*(x+Se_i)(x+Se_i). */ - virtual bool eval_f_rterm(size_t idx, const int& n,const double* x, double& rval); + virtual bool eval_f_rterm(size_type idx, const int& n,const double* x, double& rval); /** * This function returns the recourse gradient. */ - virtual bool eval_grad_rterm(size_t idx, const int& n, double* x, hiopVector& grad); + virtual bool eval_grad_rterm(size_type idx, const int& n, double* x, hiopVector& grad); /** * This function sets up the approximation of the recourse objective based on the function value and gradient @@ -167,8 +167,8 @@ class PriDecMasterProblemEx1 : public hiopInterfacePriDecProblem virtual bool set_recourse_approx_evaluator(const int n, hiopInterfacePriDecProblem::RecourseApproxEvaluator* evaluator); // Returns the number S of recourse terms. - size_t get_num_rterms() const {return S_;} - size_t get_num_vars() const {return n_;} + size_type get_num_rterms() const {return S_;} + size_type get_num_vars() const {return n_;} // Returns the solution. void get_solution(double* x) const { @@ -177,9 +177,9 @@ class PriDecMasterProblemEx1 : public hiopInterfacePriDecProblem } double get_objective() {return obj_;} private: - size_t n_; - size_t S_; - size_t nc_; + size_type n_; + size_type S_; + size_type nc_; PriDecEx1* my_nlp; double obj_; double* sol_; diff --git a/src/Drivers/PriDec/NlpPriDecEx2.cpp b/src/Drivers/PriDec/NlpPriDecEx2.cpp index 7f3dd565f..906f943e7 100644 --- a/src/Drivers/PriDec/NlpPriDecEx2.cpp +++ b/src/Drivers/PriDec/NlpPriDecEx2.cpp @@ -10,7 +10,7 @@ using namespace hiop; PriDecMasterProbleEx2:: -PriDecMasterProbleEx2(size_t nx, size_t ny, size_t nS, size_t S) : nx_(nx), ny_(ny),nS_(nS),S_(S) +PriDecMasterProbleEx2(size_type nx, size_type ny, size_type nS, size_type S) : nx_(nx), ny_(ny),nS_(nS),S_(S) { assert(nx==ny); y_ = new double[ny_]; @@ -103,16 +103,17 @@ set_recourse_approx_evaluator(const int n, return true; } -bool PriDecMasterProbleEx2::eval_f_rterm(size_t idx, const int& n, const double* x, double& rval) +bool PriDecMasterProbleEx2::eval_f_rterm(size_type idx, const int& n, const double* x, double& rval) { assert(nx_==n); rval=-1e+20; - hiopSolveStatus status; double* xi; + hiopSolveStatus status; #ifdef HIOP_USE_MPI - double t3 = MPI_Wtime(); - double t4 = 0.; + // uncomment if want to monitor contingency computing time + //double t3 = MPI_Wtime(); + //double t4 = 0.; #endif // xi can be set below @@ -149,6 +150,7 @@ bool PriDecMasterProbleEx2::eval_f_rterm(size_t idx, const int& n, const double* //assert("for debugging" && false); //for debugging purpose status = solver.run(); + assert(status<=hiopSolveStatus::User_Stopped); //check solver status if necessary rval = solver.getObjective(); if(y_==NULL) { y_ = new double[ny_]; @@ -171,7 +173,7 @@ bool PriDecMasterProbleEx2::eval_f_rterm(size_t idx, const int& n, const double* }; // returns the gradient computed in eval_f_rterm -bool PriDecMasterProbleEx2::eval_grad_rterm(size_t idx, const int& n, double* x, hiopVector& grad) +bool PriDecMasterProbleEx2::eval_grad_rterm(size_type idx, const int& n, double* x, hiopVector& grad) { assert(nx_==n); double* grad_vec = grad.local_data(); @@ -181,12 +183,12 @@ bool PriDecMasterProbleEx2::eval_grad_rterm(size_t idx, const int& n, double* x, return true; }; -inline size_t PriDecMasterProbleEx2::get_num_rterms() const +inline size_type PriDecMasterProbleEx2::get_num_rterms() const { return S_; } -inline size_t PriDecMasterProbleEx2::get_num_vars() const +inline size_type PriDecMasterProbleEx2::get_num_vars() const { return nx_; } diff --git a/src/Drivers/PriDec/NlpPriDecEx2.hpp b/src/Drivers/PriDec/NlpPriDecEx2.hpp index 3d76e8399..e2e78248c 100644 --- a/src/Drivers/PriDec/NlpPriDecEx2.hpp +++ b/src/Drivers/PriDec/NlpPriDecEx2.hpp @@ -67,7 +67,7 @@ using namespace hiop; class PriDecMasterProbleEx2 : public hiop::hiopInterfacePriDecProblem { public: - PriDecMasterProbleEx2(size_t nx, size_t ny, size_t nS, size_t S); + PriDecMasterProbleEx2(size_type nx, size_type ny, size_type nS, size_type S); virtual ~PriDecMasterProbleEx2(); @@ -86,18 +86,18 @@ class PriDecMasterProbleEx2 : public hiop::hiopInterfacePriDecProblem * n is the number of coupled x, not the entire dimension of x, and might be denoted as nc_ elsewhere. * rval is the return value of the recourse solution function evaluation. */ - bool eval_f_rterm(size_t idx, const int& n, const double* x, double& rval); + bool eval_f_rterm(size_type idx, const int& n, const double* x, double& rval); /** * This function computes the gradient of the recourse solution function w.r.t x. * n is the number of coupled x, not the entire dimension of x, and * grad is the output. */ - bool eval_grad_rterm(size_t idx, const int& n, double* x, hiopVector& grad); + bool eval_grad_rterm(size_type idx, const int& n, double* x, hiopVector& grad); - inline size_t get_num_rterms() const; + inline size_type get_num_rterms() const; - inline size_t get_num_vars() const; + inline size_type get_num_vars() const; void get_solution(double* x) const; @@ -105,15 +105,15 @@ class PriDecMasterProbleEx2 : public hiop::hiopInterfacePriDecProblem private: /// dimension of primal variable `x` - size_t nx_; + size_type nx_; /// dimension of the coupled variable, nc_<=nx_ - size_t nc_; + size_type nc_; ///dimension of recourse problem primal variable `y` for each contingency - size_t ny_; + size_type ny_; /// dimension of uncertainty dimension entering the recourse problem - size_t nS_; + size_type nS_; ///number of sample to use, effectively the number of recourse terms - size_t S_; + size_type S_; double* y_; diff --git a/src/Drivers/PriDec/NlpPriDecEx2Sparse.cpp b/src/Drivers/PriDec/NlpPriDecEx2Sparse.cpp index 3ed40422f..e2dcc2565 100644 --- a/src/Drivers/PriDec/NlpPriDecEx2Sparse.cpp +++ b/src/Drivers/PriDec/NlpPriDecEx2Sparse.cpp @@ -5,7 +5,7 @@ using namespace hiop; PriDecMasterProbleEx2Sparse:: -PriDecMasterProbleEx2Sparse(size_t nx, size_t ny, size_t nS, size_t S) : nx_(nx), ny_(ny),nS_(nS),S_(S) +PriDecMasterProbleEx2Sparse(size_type nx, size_type ny, size_type nS, size_type S) : nx_(nx), ny_(ny),nS_(nS),S_(S) { assert(nx==ny); y_ = new double[ny_]; @@ -95,7 +95,7 @@ set_recourse_approx_evaluator(const int n, return true; } -bool PriDecMasterProbleEx2Sparse::eval_f_rterm(size_t idx, const int& n, const double* x, double& rval) +bool PriDecMasterProbleEx2Sparse::eval_f_rterm(size_type idx, const int& n, const double* x, double& rval) { assert(nx_==n); rval=-1e+20; @@ -103,8 +103,9 @@ bool PriDecMasterProbleEx2Sparse::eval_f_rterm(size_t idx, const int& n, const d double* xi; #ifdef HIOP_USE_MPI - double t3 = MPI_Wtime(); - double t4 = 0.; + // uncomment if want to monitor contingency computing time + //double t3 = MPI_Wtime(); + //double t4 = 0.; #endif xi = new double[nS_]; @@ -142,6 +143,7 @@ bool PriDecMasterProbleEx2Sparse::eval_f_rterm(size_t idx, const int& n, const d //assert("for debugging" && false); //for debugging purpose status = solver.run(); + assert(status<=hiopSolveStatus::User_Stopped); //check solver status if necessary rval = solver.getObjective(); if(y_==nullptr) { y_ = new double[ny_]; @@ -164,7 +166,7 @@ bool PriDecMasterProbleEx2Sparse::eval_f_rterm(size_t idx, const int& n, const d }; // returns the gradient computed in eval_f_rterm -bool PriDecMasterProbleEx2Sparse::eval_grad_rterm(size_t idx, const int& n, double* x, hiopVector& grad) +bool PriDecMasterProbleEx2Sparse::eval_grad_rterm(size_type idx, const int& n, double* x, hiopVector& grad) { assert(nx_==n); double* grad_vec = grad.local_data(); @@ -174,12 +176,12 @@ bool PriDecMasterProbleEx2Sparse::eval_grad_rterm(size_t idx, const int& n, doub return true; }; -inline size_t PriDecMasterProbleEx2Sparse::get_num_rterms() const +inline size_type PriDecMasterProbleEx2Sparse::get_num_rterms() const { return S_; } -inline size_t PriDecMasterProbleEx2Sparse::get_num_vars() const +inline size_type PriDecMasterProbleEx2Sparse::get_num_vars() const { return nx_; } diff --git a/src/Drivers/PriDec/NlpPriDecEx2Sparse.hpp b/src/Drivers/PriDec/NlpPriDecEx2Sparse.hpp index d99acc48f..47a44320e 100644 --- a/src/Drivers/PriDec/NlpPriDecEx2Sparse.hpp +++ b/src/Drivers/PriDec/NlpPriDecEx2Sparse.hpp @@ -66,7 +66,7 @@ using namespace hiop; class PriDecMasterProbleEx2Sparse : public hiop::hiopInterfacePriDecProblem { public: - PriDecMasterProbleEx2Sparse(size_t nx, size_t ny, size_t nS, size_t S); + PriDecMasterProbleEx2Sparse(size_type nx, size_type ny, size_type nS, size_type S); virtual ~PriDecMasterProbleEx2Sparse(); @@ -85,18 +85,18 @@ class PriDecMasterProbleEx2Sparse : public hiop::hiopInterfacePriDecProblem * n is the number of coupled x, not the entire dimension of x, and might be denoted as nc_ elsewhere. * rval is the return value of the recourse solution function evaluation. */ - bool eval_f_rterm(size_t idx, const int& n, const double* x, double& rval); + bool eval_f_rterm(size_type idx, const int& n, const double* x, double& rval); /** * This function computes the gradient of the recourse solution function w.r.t x. * n is the number of coupled x, not the entire dimension of x, and * grad is the output. */ - bool eval_grad_rterm(size_t idx, const int& n, double* x, hiopVector& grad); + bool eval_grad_rterm(size_type idx, const int& n, double* x, hiopVector& grad); - inline size_t get_num_rterms() const; + inline size_type get_num_rterms() const; - inline size_t get_num_vars() const; + inline size_type get_num_vars() const; void get_solution(double* x) const; @@ -104,15 +104,15 @@ class PriDecMasterProbleEx2Sparse : public hiop::hiopInterfacePriDecProblem private: /// dimension of primal variable `x` - size_t nx_; + size_type nx_; /// dimension of the coupled variable, nc_<=nx_ - size_t nc_; + size_type nc_; ///dimension of recourse problem primal variable `y` for each contingency - size_t ny_; + size_type ny_; /// dimension of uncertainty dimension entering the recourse problem - size_t nS_; + size_type nS_; ///number of sample to use, effectively the number of recourse terms - size_t S_; + size_type S_; double* y_; diff --git a/src/Drivers/PriDec/NlpPriDecEx2SparseRaja.cpp b/src/Drivers/PriDec/NlpPriDecEx2SparseRaja.cpp index abcf6c552..eaa43fe91 100644 --- a/src/Drivers/PriDec/NlpPriDecEx2SparseRaja.cpp +++ b/src/Drivers/PriDec/NlpPriDecEx2SparseRaja.cpp @@ -22,7 +22,7 @@ using ex9_raja_reduce = hiop::ExecRajaPoliciesBackend:: using namespace hiop; PriDecMasterProbleEx2Sparse:: -PriDecMasterProbleEx2Sparse(size_t nx, size_t ny, size_t nS, size_t S, std::string mem_space) +PriDecMasterProbleEx2Sparse(size_type nx, size_type ny, size_type nS, size_type S, std::string mem_space) : nx_(nx), ny_(ny), nS_(nS), @@ -118,7 +118,7 @@ set_recourse_approx_evaluator(const int n, } // all the memory management is done through umpire in the PriDecRecourseProbleEx2Sparse class -bool PriDecMasterProbleEx2Sparse::eval_f_rterm(size_t idx, const int& n, const double* x, double& rval) +bool PriDecMasterProbleEx2Sparse::eval_f_rterm(size_type idx, const int& n, const double* x, double& rval) { assert(nx_==n); rval=-1e+20; @@ -186,7 +186,7 @@ bool PriDecMasterProbleEx2Sparse::eval_f_rterm(size_t idx, const int& n, const d }; // returns the gradient computed in eval_f_rterm -bool PriDecMasterProbleEx2Sparse::eval_grad_rterm(size_t idx, const int& n, double* x, hiopVector& grad) +bool PriDecMasterProbleEx2Sparse::eval_grad_rterm(size_type idx, const int& n, double* x, hiopVector& grad) { assert(nx_==n); double* grad_vec = grad.local_data(); @@ -196,12 +196,12 @@ bool PriDecMasterProbleEx2Sparse::eval_grad_rterm(size_t idx, const int& n, doub return true; }; -inline size_t PriDecMasterProbleEx2Sparse::get_num_rterms() const +inline size_type PriDecMasterProbleEx2Sparse::get_num_rterms() const { return S_; } -inline size_t PriDecMasterProbleEx2Sparse::get_num_vars() const +inline size_type PriDecMasterProbleEx2Sparse::get_num_vars() const { return nx_; } diff --git a/src/Drivers/PriDec/NlpPriDecEx2SparseRaja.hpp b/src/Drivers/PriDec/NlpPriDecEx2SparseRaja.hpp index 91e4c1da9..f2db47de0 100644 --- a/src/Drivers/PriDec/NlpPriDecEx2SparseRaja.hpp +++ b/src/Drivers/PriDec/NlpPriDecEx2SparseRaja.hpp @@ -67,7 +67,7 @@ using namespace hiop; class PriDecMasterProbleEx2Sparse : public hiop::hiopInterfacePriDecProblem { public: - PriDecMasterProbleEx2Sparse(size_t nx, size_t ny, size_t nS, size_t S, std::string mem_space); + PriDecMasterProbleEx2Sparse(size_type nx, size_type ny, size_type nS, size_type S, std::string mem_space); virtual ~PriDecMasterProbleEx2Sparse(); @@ -86,18 +86,18 @@ class PriDecMasterProbleEx2Sparse : public hiop::hiopInterfacePriDecProblem * n is the number of coupled x, not the entire dimension of x, and might be denoted as nc_ elsewhere. * rval is the return value of the recourse solution function evaluation. */ - bool eval_f_rterm(size_t idx, const int& n, const double* x, double& rval); + bool eval_f_rterm(size_type idx, const int& n, const double* x, double& rval); /** * This function computes the gradient of the recourse solution function w.r.t x. * n is the number of coupled x, not the entire dimension of x, and * grad is the output. */ - bool eval_grad_rterm(size_t idx, const int& n, double* x, hiopVector& grad); + bool eval_grad_rterm(size_type idx, const int& n, double* x, hiopVector& grad); - inline size_t get_num_rterms() const; + inline size_type get_num_rterms() const; - inline size_t get_num_vars() const; + inline size_type get_num_vars() const; void get_solution(double* x) const; @@ -105,15 +105,15 @@ class PriDecMasterProbleEx2Sparse : public hiop::hiopInterfacePriDecProblem private: /// dimension of primal variable `x` - size_t nx_; + size_type nx_; /// dimension of the coupled variable, nc_<=nx_ - size_t nc_; + size_type nc_; ///dimension of recourse problem primal variable `y` for each contingency - size_t ny_; + size_type ny_; /// dimension of uncertainty dimension entering the recourse problem - size_t nS_; + size_type nS_; ///number of sample to use, effectively the number of recourse terms - size_t S_; + size_type S_; double* y_; diff --git a/src/Drivers/PriDec/NlpPriDecEx2UserBasecase.hpp b/src/Drivers/PriDec/NlpPriDecEx2UserBasecase.hpp index affea63eb..35ac2c258 100644 --- a/src/Drivers/PriDec/NlpPriDecEx2UserBasecase.hpp +++ b/src/Drivers/PriDec/NlpPriDecEx2UserBasecase.hpp @@ -100,6 +100,7 @@ class PriDecBasecaseProbleEx2 : public SparseEx1 void get_rec_obj(const size_type& n, const double* x, double& obj_value) { bool temp = rec_evaluator_->eval_f(n, x, false, obj_value); + assert(temp); } protected: diff --git a/src/Drivers/PriDec/NlpPriDecEx2UserRecourseMds.hpp b/src/Drivers/PriDec/NlpPriDecEx2UserRecourseMds.hpp index 910a9999e..58c0d0e11 100644 --- a/src/Drivers/PriDec/NlpPriDecEx2UserRecourseMds.hpp +++ b/src/Drivers/PriDec/NlpPriDecEx2UserRecourseMds.hpp @@ -27,7 +27,12 @@ class PriDecRecourseProbleEx2 : public hiop::hiopInterfaceMDS { public: - PriDecRecourseProbleEx2(int n, int nS, int S): nx_(n), nS_(nS),S_(S),x_(nullptr),xi_(nullptr) + PriDecRecourseProbleEx2(int n, int nS, int S) + : x_(nullptr), + xi_(nullptr), + nx_(n), + nS_(nS), + S_(S) { assert(nS_>=1); assert(nx_>=nS_); // ny = nx = n diff --git a/src/Drivers/PriDec/NlpPriDecEx2UserRecourseSparse.hpp b/src/Drivers/PriDec/NlpPriDecEx2UserRecourseSparse.hpp index 822650849..586906cc6 100644 --- a/src/Drivers/PriDec/NlpPriDecEx2UserRecourseSparse.hpp +++ b/src/Drivers/PriDec/NlpPriDecEx2UserRecourseSparse.hpp @@ -29,11 +29,11 @@ class PriDecRecourseProbleEx2Sparse : public hiop::hiopInterfaceSparse { public: PriDecRecourseProbleEx2Sparse(int n, int nS, int S) - : nx_(n), + : x_(nullptr), + xi_(nullptr), + nx_(n), nS_(nS), - S_(S), - x_(nullptr), - xi_(nullptr) + S_(S) { assert(nS_>=1); assert(nx_>=nS_); // ny = nx = n diff --git a/src/Drivers/PriDec/NlpPriDecEx2UserRecourseSparseRaja.hpp b/src/Drivers/PriDec/NlpPriDecEx2UserRecourseSparseRaja.hpp index 07aecfc63..98f54c478 100644 --- a/src/Drivers/PriDec/NlpPriDecEx2UserRecourseSparseRaja.hpp +++ b/src/Drivers/PriDec/NlpPriDecEx2UserRecourseSparseRaja.hpp @@ -50,17 +50,17 @@ class PriDecRecourseProbleEx2Sparse : public hiop::hiopInterfaceSparse { public: PriDecRecourseProbleEx2Sparse(int n, int nS, int S, std::string mem_space) - : nx_(n), - nS_(nS),S_(S), - x_(nullptr), + : x_(nullptr), xi_(nullptr), + nx_(n), + nS_(nS),S_(S), mem_space_(mem_space) { // Make sure mem_space_ is uppercase transform(mem_space_.begin(), mem_space_.end(), mem_space_.begin(), ::toupper); - auto& resmgr = umpire::ResourceManager::getInstance(); - umpire::Allocator allocator = resmgr.getAllocator(mem_space_); + //auto& resmgr = umpire::ResourceManager::getInstance(); + //umpire::Allocator allocator = resmgr.getAllocator(mem_space_); // umpire::Allocator allocator // = resmgr.getAllocator(mem_space_ == "DEFAULT" ? "HOST" : mem_space_); diff --git a/src/Drivers/PriDec/NlpPriDecEx3Sparse.hpp b/src/Drivers/PriDec/NlpPriDecEx3Sparse.hpp index 495c9a8c8..a73ceb728 100644 --- a/src/Drivers/PriDec/NlpPriDecEx3Sparse.hpp +++ b/src/Drivers/PriDec/NlpPriDecEx3Sparse.hpp @@ -35,11 +35,15 @@ class SparseEx3 : public hiop::hiopInterfaceSparse { public: SparseEx3(int nx,int S) - : nx_(nx),n_vars(nx+S*nx), n_cons{2+S*nx},S_(S) //total number of variables should be nx+S*nx + : n_vars_(nx+S*nx), + n_cons_{2+S*nx}, + nx_(nx), + S_(S) //total number of variables should be nx+S*nx { assert(nx>=3); - if(nx>3) - n_cons += nx-3; + if(nx>3) { + n_cons_ += nx-3; + } nS_ = int(nx_/2); xi_ = new double[S_*nS_]; x0_ = new double[nx_]; @@ -48,11 +52,16 @@ class SparseEx3 : public hiop::hiopInterfaceSparse } SparseEx3(int nx,int S,int nS) - : nx_(nx),n_vars(nx+S*nx), n_cons{2+S*nx},S_(S),nS_(nS) //total number of variables should be nx+S*nx + : n_vars_(nx+S*nx), + n_cons_{2+S*nx}, + nx_(nx), + S_(S), + nS_(nS) //total number of variables should be nx+S*nx { assert(nx>=3); - if(nx>3) - n_cons += nx-3; + if(nx>3) { + n_cons_ += nx-3; + } xi_ = new double[nS_*S_]; x0_ = new double[nx_]; for(int i=0;i=3); //2*(n-1) for basecase @@ -374,7 +383,7 @@ class SparseEx3 : public hiop::hiopInterfaceSparse bool get_starting_point(const size_type& n, double* x0) { - assert(n==n_vars); + assert(n==n_vars_); for(auto i=0; i=3); if(n>3) - n_cons += n-3; - n_cons += rankdefic_eq_ + rankdefic_ineq_; + n_cons_ += n-3; + n_cons_ += rankdefic_eq_ + rankdefic_ineq_; } SparseEx2::~SparseEx2() @@ -47,14 +47,14 @@ SparseEx2::~SparseEx2() bool SparseEx2::get_prob_sizes(size_type& n, size_type& m) { - n=n_vars; - m=n_cons; + n=n_vars_; + m=n_cons_; return true; } bool SparseEx2::get_vars_info(const size_type& n, double *xlow, double* xupp, NonlinearityType* type) { - assert(n==n_vars); + assert(n==n_vars_); for(index_type i=0; i=3); assert(nnzJacS == 4 + 2*(n-3) + 2*rankdefic_eq_ + 2*rankdefic_ineq_); @@ -318,7 +318,7 @@ bool SparseEx2::eval_Hess_Lagr(const size_type& n, bool SparseEx2::get_starting_point(const size_type& n, double* x0) { - assert(n==n_vars); + assert(n==n_vars_); for(auto i=0; irefcppHiop); status = solver.run(); + assert(status<=hiopSolveStatus::User_Stopped); //check solver status if necessary prob->obj_value = solver.getObjective(); solver.getSolution(prob->solution); return 0; @@ -110,7 +111,6 @@ int hiop_sparse_create_problem(cHiopSparseProblem *prob) { } int hiop_sparse_solve_problem(cHiopSparseProblem *prob) { - hiopSolveStatus status; hiopAlgFilterIPMNewton solver(prob->refcppHiop_); prob->status_ = solver.run(); prob->obj_value_ = solver.getObjective(); @@ -144,7 +144,6 @@ int hiop_dense_create_problem(cHiopDenseProblem *prob) { } int hiop_dense_solve_problem(cHiopDenseProblem *prob) { - hiopSolveStatus status; hiopAlgFilterIPMQuasiNewton solver(prob->refcppHiop); prob->status = solver.run(); prob->obj_value = solver.getObjective(); diff --git a/src/Interface/hiopInterfacePrimalDecomp.hpp b/src/Interface/hiopInterfacePrimalDecomp.hpp index 53b4eb02e..e8d4eb102 100644 --- a/src/Interface/hiopInterfacePrimalDecomp.hpp +++ b/src/Interface/hiopInterfacePrimalDecomp.hpp @@ -89,18 +89,18 @@ class hiopInterfacePriDecProblem const double* hess = 0, const char* master_options_file=nullptr) = 0; - virtual bool eval_f_rterm(size_t idx, const int& n, const double* x, double& rval) = 0; - virtual bool eval_grad_rterm(size_t idx, const int& n, double* x, hiopVector& grad) = 0; + virtual bool eval_f_rterm(size_type idx, const int& n, const double* x, double& rval) = 0; + virtual bool eval_grad_rterm(size_type idx, const int& n, double* x, hiopVector& grad) = 0; /** * Returns the number S of recourse terms */ - virtual size_t get_num_rterms() const = 0; + virtual size_type get_num_rterms() const = 0; /** * Return the number of primal optimization variables */ - virtual size_t get_num_vars() const = 0; + virtual size_type get_num_vars() const = 0; virtual void get_solution(double* x) const = 0; virtual double get_objective() = 0; diff --git a/src/LinAlg/hiopLinSolverSparseGinkgo.cpp b/src/LinAlg/hiopLinSolverSparseGinkgo.cpp index 4af6348f2..971ef699a 100644 --- a/src/LinAlg/hiopLinSolverSparseGinkgo.cpp +++ b/src/LinAlg/hiopLinSolverSparseGinkgo.cpp @@ -172,10 +172,10 @@ std::shared_ptr> transferTripletToCSR(std::shared_ delete[] nnz_each_row_tmp; } - auto val_array = gko::Array::view(exec, nnz_, kVal_); - auto row_ptrs = gko::Array::view(exec, n_ + 1, kRowPtr_); - auto col_idxs = gko::Array::view(exec, nnz_, jCol_); - auto mtx = gko::share(gko::matrix::Csr::create(exec, gko::dim<2>{n_, n_}, val_array, col_idxs, row_ptrs)); + auto val_array = gko::array::view(exec, nnz_, kVal_); + auto row_ptrs = gko::array::view(exec, n_ + 1, kRowPtr_); + auto col_idxs = gko::array::view(exec, nnz_, jCol_); + auto mtx = gko::share(gko::matrix::Csr::create(exec, gko::dim<2>{(long unsigned int)n_, (long unsigned int)n_}, val_array, col_idxs, row_ptrs)); return mtx; } @@ -189,7 +189,6 @@ void update_matrix(hiopMatrixSparse* M_, int n_ = mtx->get_size()[0]; int nnz_= mtx->get_num_stored_elements(); auto values = host_mtx->get_values(); - int rowID_tmp{0}; for(int k=0; kM()[index_covert_CSR2Triplet_[k]]; } @@ -280,10 +279,10 @@ std::shared_ptr setup_solver_factory(std::shared_ptr setup_solver_factory(std::shared_ptr(x->new_copy()); double* dx = x->local_data(); double* drhs = rhs->local_data(); - const auto size = gko::dim<2>{n_, 1}; + const auto size = gko::dim<2>{(long unsigned int)n_, 1}; auto dense_x_host = vec::create(host, size, arr::view(host, n_, dx), 1); auto dense_x = vec::create(exec_, size); dense_x->copy_from(dense_x_host.get()); diff --git a/src/LinAlg/hiopLinSolverSymDenseMagma.cpp b/src/LinAlg/hiopLinSolverSymDenseMagma.cpp index c51aa7ca9..c29ec4f78 100644 --- a/src/LinAlg/hiopLinSolverSymDenseMagma.cpp +++ b/src/LinAlg/hiopLinSolverSymDenseMagma.cpp @@ -188,7 +188,6 @@ namespace hiop { int inert[3]; int info; - int retcode; magma_uplo_t uplo=MagmaLower; // M is upper in C++ so it's lower in fortran #ifdef HIOP_USE_HIP uplo = MagmaUpper; // M is upper in C++ so it's lower in fortran @@ -226,7 +225,6 @@ namespace hiop assert(M_->n() == M_->m()); assert(x.get_size() == M_->n()); int N = M_->n(); - int LDA = N; int LDB = N; int NRHS = 1; if(N == 0) { @@ -328,7 +326,6 @@ namespace hiop assert(M_->n() == M_->m()); int N=M_->n(); int LDA = N; - int LDB=N; if(N==0) { return true; } @@ -429,7 +426,6 @@ namespace hiop assert(M_->n() == M_->m()); assert(x.get_size()==M_->n()); int N=M_->n(); - int LDA = N; int LDB=N; if(N==0) { return true; diff --git a/src/LinAlg/hiopLinSolverSymSparseMA57.cpp b/src/LinAlg/hiopLinSolverSymSparseMA57.cpp index 3c1ab476e..2d2a2b206 100644 --- a/src/LinAlg/hiopLinSolverSymSparseMA57.cpp +++ b/src/LinAlg/hiopLinSolverSymSparseMA57.cpp @@ -118,7 +118,6 @@ namespace hiop bool done{false}; bool is_singular{false}; - int num_tries{0}; //get the triplet values array and copy the entries into it (different behavior for triplet and csr implementations) double* Mvals = get_triplet_values_array(); @@ -162,10 +161,11 @@ namespace hiop }; break; default: - if( info_[0] >= 0 ) done = true; + if(info_[0] >= 0) { + done = true; + } assert( "unknown error!" && 0 ); } // end switch - num_tries++; } while( !done ); nlp_->runStats.linsolv.tmFactTime.stop(); @@ -193,7 +193,6 @@ namespace hiop nlp_->runStats.linsolv.tmTriuSolves.start(); int job = 1; // full solve - int one = 1; icntl_[9-1] = 1; // do one step of iterative refinement hiopVector* x = dynamic_cast(&x_in); diff --git a/src/LinAlg/hiopLinSolverUMFPACKZ.cpp b/src/LinAlg/hiopLinSolverUMFPACKZ.cpp index 2d8c03703..8ef8c94e9 100644 --- a/src/LinAlg/hiopLinSolverUMFPACKZ.cpp +++ b/src/LinAlg/hiopLinSolverUMFPACKZ.cpp @@ -4,7 +4,11 @@ namespace hiop { hiopLinSolverUMFPACKZ::hiopLinSolverUMFPACKZ(hiopMatrixComplexSparseTriplet& sysmat, hiopNlpFormulation* nlp_/*=NULL*/) - : m_symbolic(NULL), m_numeric(NULL), m_null(NULL), sys_mat(sysmat), nlp(nlp_) + : m_symbolic(nullptr), + m_numeric(nullptr), + m_null(nullptr), + nlp(nlp_), + sys_mat(sysmat) { n = sys_mat.n(); nnz = sys_mat.numberOfNonzeros(); diff --git a/src/LinAlg/hiopMatrixDenseRajaImpl.hpp b/src/LinAlg/hiopMatrixDenseRajaImpl.hpp index 1991a57a2..def5051e5 100644 --- a/src/LinAlg/hiopMatrixDenseRajaImpl.hpp +++ b/src/LinAlg/hiopMatrixDenseRajaImpl.hpp @@ -1099,7 +1099,6 @@ void hiopMatrixDenseRaja::addSubDiagonal(const double& assert(start+dlen<=n_local_); #endif - int diag = std::min(get_local_size_m(), get_local_size_n()); double* data = data_dev_; const double* dd = d.local_data_const(); RAJA::View> Mview(data, get_local_size_m(), get_local_size_n()); // matrix @@ -1141,7 +1140,6 @@ void hiopMatrixDenseRaja::addSubDiagonal(int start_on_d assert(start_on_dest_diag>=0 && start_on_dest_diag> Mview(data, get_local_size_m(), get_local_size_n()); @@ -1174,7 +1172,6 @@ addSubDiagonal(int start_on_dest_diag, int num_elems, const double& c) assert(n_local_ == n_global_ && "method supported only for non-distributed matrices"); assert(n_local_ == m_local_ && "method supported only for symmetric matrices"); - int diag = std::min(get_local_size_m(), get_local_size_n()); double* data = data_dev_; RAJA::View> Mview(data, get_local_size_m(), get_local_size_n()); RAJA::forall(RAJA::RangeSegment(0, num_elems), diff --git a/src/LinAlg/hiopMatrixMDS.hpp b/src/LinAlg/hiopMatrixMDS.hpp index 8882b3891..9998bc81a 100644 --- a/src/LinAlg/hiopMatrixMDS.hpp +++ b/src/LinAlg/hiopMatrixMDS.hpp @@ -91,10 +91,9 @@ class hiopMatrixMDS : public hiopMatrix assert(false && "not yet implemented"); } - virtual void timesMatTrans(double beta, [[maybe_unused]] hiopMatrix& W, double alpha, const hiopMatrix& X) const + virtual void timesMatTrans(double beta, hiopMatrix& W, double alpha, const hiopMatrix& X) const { const hiopMatrixMDS &X_mds = dynamic_cast(X); - [[maybe_unused]] hiopMatrixDense &W_d = dynamic_cast(W); mDe->timesMatTrans(beta, W, 1.0, *X_mds.de_mat()); mSp->timesMatTrans(1.0, W, 1.0, *X_mds.sp_mat()); diff --git a/src/LinAlg/hiopMatrixRajaSparseTriplet.hpp b/src/LinAlg/hiopMatrixRajaSparseTriplet.hpp index 00bc19a08..4f2cdb6e0 100644 --- a/src/LinAlg/hiopMatrixRajaSparseTriplet.hpp +++ b/src/LinAlg/hiopMatrixRajaSparseTriplet.hpp @@ -395,8 +395,8 @@ class hiopMatrixRajaSparseTriplet : public hiopMatrixSparse std::string mem_space_; RowStartsInfo() : idx_start_(nullptr), - num_rows_(0), - register_row_st_{0} + register_row_st_{0}, + num_rows_(0) {} RowStartsInfo(size_type n_rows, std::string memspace); virtual ~RowStartsInfo(); diff --git a/src/LinAlg/hiopMatrixRajaSparseTripletImpl.hpp b/src/LinAlg/hiopMatrixRajaSparseTripletImpl.hpp index fd538740f..5cf34506d 100644 --- a/src/LinAlg/hiopMatrixRajaSparseTripletImpl.hpp +++ b/src/LinAlg/hiopMatrixRajaSparseTripletImpl.hpp @@ -79,8 +79,8 @@ hiopMatrixRajaSparseTriplet(int rows, int _nnz, std::string memspace) : hiopMatrixSparse(rows, cols, _nnz), - row_starts_(nullptr), - mem_space_(memspace) + mem_space_(memspace), + row_starts_(nullptr) { if(rows==0 || cols==0) { @@ -517,13 +517,14 @@ transAddToSymDenseMatrixUpperTriangle(int row_start, double alpha, hiopMatrixDense& W) const { - assert(row_start>=0 && row_start+ncols_<=W.m()); - assert(col_start>=0 && col_start+nrows_<=W.n()); - assert(W.n()==W.m()); - - RAJA::View> WM(W.local_data(), W.m(), W.n()); auto Wm = W.m(); auto Wn = W.n(); + + assert(row_start>=0 && row_start+ncols_<=Wm); + assert(col_start>=0 && col_start+nrows_<=Wn); + assert(Wn==Wm); + + RAJA::View> WM(W.local_data(), W.m(), W.n()); int* iRow = iRow_; int* jCol = jCol_; double* values = values_; @@ -1029,12 +1030,9 @@ copyRowsFrom(const hiopMatrix& src_gen, assert(this->n() == src.n()); assert(n_rows <= src.m()); - const int* iRow_src = src.i_row(); const int* jCol_src = src.j_col(); const double* values_src = src.M(); - size_type nnz_src = src.numberOfNonzeros(); - size_type m_src = src.m(); if(src.row_starts_ == nullptr) { src.row_starts_ = src.allocAndBuildRowStarts(); } @@ -1044,7 +1042,6 @@ copyRowsFrom(const hiopMatrix& src_gen, index_type* iRow = iRow_; index_type* jCol = jCol_; double* values = values_; - size_type nnz_dst = numberOfNonzeros(); // this function only set up sparsity in the first run. Sparsity won't change after the first run. if(row_starts_ == nullptr) { @@ -1123,17 +1120,13 @@ copyRowsBlockFrom(const hiopMatrix& src_gen, assert(n_rows + rows_src_idx_st <= src.m()); assert(n_rows + rows_dst_idx_st <= this->m()); - const index_type* iRow_src = src.i_row(); const index_type* jCol_src = src.j_col(); const double* values_src = src.M(); - size_type nnz_src = src.numberOfNonzeros(); // local copy of member variable/function, for RAJA access index_type* iRow = iRow_; index_type* jCol = jCol_; double* values = values_; - size_type nnz_dst = numberOfNonzeros(); - size_type n_rows_src = src.m(); size_type n_rows_dst = this->m(); if(src.row_starts_ == nullptr) { @@ -1285,9 +1278,9 @@ void hiopMatrixRajaSparseTriplet::copyFromDev() const template hiopMatrixRajaSparseTriplet::RowStartsInfo:: RowStartsInfo(size_type n_rows, std::string memspace) - : num_rows_(n_rows), - mem_space_(memspace), - register_row_st_{0} + : register_row_st_{0}, + num_rows_(n_rows), + mem_space_(memspace) { auto& resmgr = umpire::ResourceManager::getInstance(); umpire::Allocator alloc = resmgr.getAllocator(mem_space_); @@ -2151,7 +2144,6 @@ set_Hess_FR(const hiopMatrixSparse& Hess, assert(m_row==m2 || m2==0); int nnz1 = m_row + M2.numberOfOffDiagNonzeros(); - int nnz2 = M2.numberOfNonzeros(); assert(this->nnz_ == nnz1); @@ -2159,8 +2151,6 @@ set_Hess_FR(const hiopMatrixSparse& Hess, M2.row_starts_ = M2.allocAndBuildRowStarts(); } assert(M2.row_starts_); - const int* M2iRow_host = M2.i_row_host(); - const int* M2jCol_host = M2.j_col_host(); index_type* M1_row_start{nullptr}; index_type* M2_row_start = M2.row_starts_->idx_start_; @@ -2266,7 +2256,6 @@ set_Hess_FR(const hiopMatrixSparse& Hess, double* M1values = M1.M(); const double* M2values = M2.M(); - const auto& diag_x = dynamic_cast&>(add_diag); const double* diag_data = add_diag.local_data_const(); if(m2 > 0) { diff --git a/src/LinAlg/hiopMatrixSparseCsrCuda.cpp b/src/LinAlg/hiopMatrixSparseCsrCuda.cpp index 98238f5c4..7a3d558d3 100644 --- a/src/LinAlg/hiopMatrixSparseCsrCuda.cpp +++ b/src/LinAlg/hiopMatrixSparseCsrCuda.cpp @@ -376,20 +376,12 @@ double hiopMatrixSparseCSRCUDA::max_abs_value() void hiopMatrixSparseCSRCUDA::row_max_abs_value(hiopVector &ret_vec) { assert(ret_vec.get_local_size() == nrows_); - - hiopVectorPar& yy = dynamic_cast(ret_vec); - yy.setToZero(); - double* y_data = yy.local_data(); - assert(false && "not yet implemented"); } void hiopMatrixSparseCSRCUDA::scale_row(hiopVector &vec_scal, const bool inv_scale) { assert(vec_scal.get_local_size() == nrows_); - - hiopVectorPar& vscal = dynamic_cast(vec_scal); - double* vd = vscal.local_data(); assert(false && "not yet implemented"); } diff --git a/src/LinAlg/hiopMatrixSparseTriplet.cpp b/src/LinAlg/hiopMatrixSparseTriplet.cpp index d2926c07f..6b81c4f04 100644 --- a/src/LinAlg/hiopMatrixSparseTriplet.cpp +++ b/src/LinAlg/hiopMatrixSparseTriplet.cpp @@ -1204,7 +1204,6 @@ void hiopMatrixSparseTriplet::convert_to_csr_arrays(int &csr_nnz, * Note that input is in lower triangular triplet form. First part is the sparse matrix, and the 2nd part containts additional * diagonal elements. */ - [[maybe_unused]] int n_diag_val=0; std::unordered_map extra_diag_nnz_map_temp; int *diag_defined = new int[n]; @@ -1222,7 +1221,6 @@ void hiopMatrixSparseTriplet::convert_to_csr_arrays(int &csr_nnz, diag_defined[iRow_[k]] = k; csr_kRowPtr[iRow_[k]+1]++; csr_nnz++; - n_diag_val++; }else{ extra_diag_nnz_map_temp[iRow_[k]] = k; } @@ -1256,7 +1254,6 @@ void hiopMatrixSparseTriplet::convert_to_csr_arrays(int &csr_nnz, diag_defined[i] = -1; } - [[maybe_unused]] int total_nnz_tmp{0}; int nnz_tmp{0}, rowID_tmp, colID_tmp; for(int k=0;k=0) { int err = MPI_Comm_rank(comm_, &myrank_); assert(err==MPI_SUCCESS); err = MPI_Comm_size(comm_, &numranks); assert(err==MPI_SUCCESS); diff --git a/src/LinAlg/hiopVectorCuda.cpp b/src/LinAlg/hiopVectorCuda.cpp index 3d387f5a7..4584c697f 100644 --- a/src/LinAlg/hiopVectorCuda.cpp +++ b/src/LinAlg/hiopVectorCuda.cpp @@ -71,8 +71,8 @@ namespace hiop hiopVectorCuda::hiopVectorCuda(const size_type& glob_n, index_type* col_part, MPI_Comm comm) : hiopVector(), - idx_cumsum_{nullptr}, - comm_(comm) + comm_(comm), + idx_cumsum_{nullptr} { n_ = glob_n; diff --git a/src/LinAlg/hiopVectorHip.cpp b/src/LinAlg/hiopVectorHip.cpp index 0b1917067..d55f2d421 100644 --- a/src/LinAlg/hiopVectorHip.cpp +++ b/src/LinAlg/hiopVectorHip.cpp @@ -71,8 +71,8 @@ namespace hiop hiopVectorHip::hiopVectorHip(const size_type& glob_n, index_type* col_part, MPI_Comm comm) : hiopVector(), - idx_cumsum_{nullptr}, - comm_(comm) + comm_(comm), + idx_cumsum_{nullptr} { n_ = glob_n; diff --git a/src/LinAlg/hiopVectorRajaImpl.hpp b/src/LinAlg/hiopVectorRajaImpl.hpp index b42e77102..f1a950226 100644 --- a/src/LinAlg/hiopVectorRajaImpl.hpp +++ b/src/LinAlg/hiopVectorRajaImpl.hpp @@ -98,9 +98,9 @@ hiopVectorRaja(const size_type& glob_n, : hiopVector(), exec_space_(ExecSpace(MEMBACKEND(mem_space))), exec_space_host_(ExecSpace(MEMBACKENDHOST::new_backend_host())), - idx_cumsum_{nullptr}, mem_space_(mem_space), - comm_(comm) + comm_(comm), + idx_cumsum_{nullptr} { n_ = glob_n; diff --git a/src/Optimization/hiopAlgPrimalDecomp.cpp b/src/Optimization/hiopAlgPrimalDecomp.cpp index c708adf56..9b3eea835 100644 --- a/src/Optimization/hiopAlgPrimalDecomp.cpp +++ b/src/Optimization/hiopAlgPrimalDecomp.cpp @@ -821,7 +821,6 @@ void hiopAlgPrimalDecomposition::set_local_accum(const std::string local_accum) hiopVector* hess_appx = grad_r->alloc_clone(); hess_appx->setToZero(); - [[maybe_unused]] double* hess_appx_vec = hess_appx->local_data(); hiopVector* x0 = grad_r->alloc_clone(); x0->setToZero(); @@ -929,12 +928,10 @@ void hiopAlgPrimalDecomposition::set_local_accum(const std::string local_accum) // log_->printf(hovIteration, "rank %d to get contingency index %d\n", r, cur_idx); //verbosity level 10 idx += 1; } - [[maybe_unused]] int mpi_test_flag; // for testing if the send/recv is completed // Posting initial receive of recourse solutions from evaluators for(int r=1; rpost_recv(2,r,comm_world_);// 2 is the tag, r is the rank source - // log_->printf(hovIteration, "receive flag for contingency value %d\n", mpi_test_flag); } // Both finish_flag and last_loop are used to deal with the final round remaining contingencies/recourse problems. // Some ranks are finished while others are not. The loop needs to continue to fetch the results. @@ -1123,7 +1120,6 @@ void hiopAlgPrimalDecomposition::set_local_accum(const std::string local_accum) } if(my_rank_==0) { - [[maybe_unused]] int mpi_test_flag = 0; for(int r=1; rwait(); req_cont_idx[r]->wait(); @@ -1306,7 +1302,6 @@ void hiopAlgPrimalDecomposition::set_local_accum(const std::string local_accum) double* grad_r_main_vec=grad_r_main->local_data(); hiopVector* hess_appx = grad_r->alloc_clone(); - [[maybe_unused]] double* hess_appx_vec = hess_appx->local_data(); hess_appx->setToZero(); hiopVector* x0 = grad_r->alloc_clone(); @@ -1417,12 +1412,10 @@ void hiopAlgPrimalDecomposition::set_local_accum(const std::string local_accum) // log_->printf(hovIteration, "rank %d to get contingency index %d\n", r, cur_idx); //verbosity level 10 idx += 1; } - [[maybe_unused]] int mpi_test_flag; // for testing if the send/recv is completed // Posting initial receive of recourse solutions from evaluators for(int r=1; rpost_recv(2,r,comm_world_);// 2 is the tag, r is the rank source rec_prob[r]->post_recv_end_signal(2,r,comm_world_);// 2 is the tag, r is the rank source - // log_->printf(hovIteration, "receive flag for contingency value %d\n", mpi_test_flag); } // Both finish_flag and last_loop are used to deal with the final round remaining contingencies/recourse problems. // Some ranks are finished while others are not. The loop needs to continue to fetch the results. @@ -1820,11 +1813,9 @@ hiopSolveStatus hiopAlgPrimalDecomposition::run_single() // double grad_r[nc_]; hiopVector* grad_r; grad_r = LinearAlgebraFactory::create_vector(options_->GetString("mem_space"), nc_) ; - [[maybe_unused]] double* grad_r_vec = grad_r->local_data(); hiopVector* hess_appx; hess_appx = grad_r->alloc_clone(); - [[maybe_unused]] double* hess_appx_vec=hess_appx->local_data(); hiopVector* x0 = grad_r->alloc_clone(); double* x0_vec = x0->local_data(); @@ -1847,7 +1838,6 @@ hiopSolveStatus hiopAlgPrimalDecomposition::run_single() double convg_f = 1e20; double convg_g = 1e20; int accp_count = 0; - [[maybe_unused]] double* x_vec = x_->local_data(); std::string options_file_master_prob; diff --git a/src/Optimization/hiopHessianLowRank.cpp b/src/Optimization/hiopHessianLowRank.cpp index b51c9843b..a18af6d9b 100644 --- a/src/Optimization/hiopHessianLowRank.cpp +++ b/src/Optimization/hiopHessianLowRank.cpp @@ -887,9 +887,8 @@ hiopMatrixDense& hiopHessianLowRank::new_S1(const hiopMatrixDense& X, const hiop { //S1 is X*some_diag*S (kxl). Here St=S^T is lxn and X is kxn (l BFGS memory size, k number of constraints) size_type k=X.m(), l=St.m(); - [[maybe_unused]] const size_type n=St.n(); #ifdef HIOP_DEEPCHECKS - assert(n==X.n()); + assert(St.n()==X.n()); if(_S1!=NULL) assert(_S1->m()==k); #endif @@ -904,9 +903,8 @@ hiopMatrixDense& hiopHessianLowRank::new_Y1(const hiopMatrixDense& X, const hiop { //Y1 is X*somediag*Y (kxl). Here Yt=Y^T is lxn, X is kxn size_type k=X.m(), l=Yt.m(); - [[maybe_unused]] size_type n=Yt.n(); #ifdef HIOP_DEEPCHECKS - assert(X.n()==n); + assert(X.n()==Yt.n()); if(_Y1!=NULL) assert(_Y1->m()==k); #endif @@ -1034,14 +1032,13 @@ symmMatTimesDiagTimesMatTrans_local(double beta, hiopMatrixDense& W, const hiopVector& d) { size_type k=W.m(); - [[maybe_unused]] const size_type n=X.n(); - size_t n_local=X.get_local_size_n(); + size_type n_local=X.get_local_size_n(); assert(X.m()==k); #ifdef HIOP_DEEPCHECKS assert(W.n()==k); - assert(d.get_size()==n); + assert(d.get_size()==X.n()); assert(d.get_local_size()==n_local); #endif @@ -1059,7 +1056,7 @@ symmMatTimesDiagTimesMatTrans_local(double beta, hiopMatrixDense& W, xj=Xdata+j*n_local; //compute W[i,j] = sum {X[i,p]*d[p]*X[j,p] : p=1,...,n_local} acc=0.0; - for(size_t p=0; pm(); assert(nx==Hess_->n()); assert(nx==Jac_c_->n()); assert(nx==Jac_d_->n()); - [[maybe_unused]] int neq = Jac_c_->m(), nineq = Jac_d_->m(); //compute and put the barrier diagonals in //Dx=(Sxl)^{-1}Zl + (Sxu)^{-1}Zu @@ -685,10 +684,10 @@ bool hiopKKTLinSysCompressedXYcYd::computeDirections(const hiopResidual* resid, return false; } - [[maybe_unused]] const bool bret = compute_directions_for_full_space(resid, dir); + const bool bret = compute_directions_for_full_space(resid, dir); nlp_->runStats.tmSolverInternal.stop(); - return true; + return bret; } #ifdef HIOP_DEEPCHECKS @@ -790,7 +789,6 @@ bool hiopKKTLinSysCompressedXDYcYd::update( const hiopIterate* iter, Hess_=Hess; int nx = Hess_->m(); assert(nx==Hess_->n()); assert(nx==Jac_c_->n()); assert(nx==Jac_d_->n()); - [[maybe_unused]] const int neq = Jac_c_->m(), nineq = Jac_d_->m(); // compute barrier diagonals (these change only between outer optimiz iterations) // Dx=(Sxl)^{-1}Zl + (Sxu)^{-1}Zu @@ -903,10 +901,10 @@ bool hiopKKTLinSysCompressedXDYcYd::computeDirections(const hiopResidual* resid, return false; } - [[maybe_unused]] const bool bret = compute_directions_for_full_space(resid, dir); + const bool bret = compute_directions_for_full_space(resid, dir); nlp_->runStats.tmSolverInternal.stop(); - return true; + return bret; } @@ -1509,7 +1507,6 @@ errorCompressedLinsys(const hiopVector& rx, const hiopVector& ryc, const hiopVec double hiopKKTLinSysLowRank::solveError(const hiopMatrixDense& M, const hiopVector& x, hiopVector& rhs) { double relError; - double rhsnorm=rhs.infnorm(); M.timesVec(1.0,rhs,-1.0,x); double resnorm=rhs.infnorm(); @@ -1905,11 +1902,11 @@ bool hiopPrecondKKTOpr::times_vec(hiopVector& y, const hiopVector& x) { res_cv_->copyFrom(x); - [[maybe_unused]] const bool bret = kkt_->computeDirections(resid_, dir_); + const bool bret = kkt_->computeDirections(resid_, dir_); y.copyFrom(*dir_cv_); - return true; + return bret; } bool hiopPrecondKKTOpr::trans_times_vec(hiopVector& y, const hiopVector& x) @@ -1959,8 +1956,6 @@ bool hiopKKTLinSysNormalEquation::update(const hiopIterate* iter, Hess_ = Hess; size_type nx = Hess_->m(); - [[maybe_unused]] const size_type neq = Jac_c_->m(); - [[maybe_unused]] const size_type nineq = Jac_d_->m(); assert(nx==Hess_->n()); assert(nx==Jac_c_->n()); assert(nx==Jac_d_->n()); @@ -2100,10 +2095,10 @@ bool hiopKKTLinSysNormalEquation::computeDirections(const hiopResidual* resid, h return false; } - [[maybe_unused]] const bool bret = compute_directions_for_full_space(resid, dir); + const bool bret = compute_directions_for_full_space(resid, dir); nlp_->runStats.tmSolverInternal.stop(); - return true; + return bret; } diff --git a/src/Optimization/hiopKKTLinSysMDS.cpp b/src/Optimization/hiopKKTLinSysMDS.cpp index b9e3c8d78..40830c13a 100644 --- a/src/Optimization/hiopKKTLinSysMDS.cpp +++ b/src/Optimization/hiopKKTLinSysMDS.cpp @@ -77,8 +77,6 @@ namespace hiop int hiopKKTLinSysCompressedMDSXYcYd::factorizeWithCurvCheck() { - [[maybe_unused]] int nxs = HessMDS_->n_sp(), nxd = HessMDS_->n_de(), nx = HessMDS_->n(); - [[maybe_unused]] int neq = Jac_cMDS_->m(), nineq = Jac_dMDS_->m(); //factorization int n_neg_eig = hiopKKTLinSysCurvCheck::factorizeWithCurvCheck(); @@ -164,10 +162,10 @@ namespace hiop // //factorization + inertia correction if needed // - [[maybe_unused]] const bool retval = factorize(); + const bool retval = factorize(); nlp_->runStats.tmSolverInternal.stop(); - return true; + return retval; } @@ -183,7 +181,6 @@ namespace hiop delta_cd_ = perturb_calc_->get_curr_delta_cd(); int nxs = HessMDS_->n_sp(), nxd = HessMDS_->n_de(); - [[maybe_unused]] const int nx = HessMDS_->n(); int neq = Jac_cMDS_->m(), nineq = Jac_dMDS_->m(); hiopMatrixDense& Msys = linSys->sysMatrix(); @@ -407,9 +404,8 @@ namespace hiop hiopLinSolverSymDense* hiopKKTLinSysCompressedMDSXYcYd::determineAndCreateLinsys(int nxd, int neq, int nineq) { - - [[maybe_unused]] bool switched_linsolvers = false; -#ifdef HIOP_USE_MAGMA +#ifdef HIOP_USE_MAGMA + bool switched_linsolvers = false; if(safe_mode_) { hiopLinSolverSymDenseMagmaBuKa* p = dynamic_cast(linSys_); if(p==NULL) { diff --git a/src/Optimization/hiopKKTLinSysSparse.cpp b/src/Optimization/hiopKKTLinSysSparse.cpp index 5ff1e20b7..c41a8579a 100644 --- a/src/Optimization/hiopKKTLinSysSparse.cpp +++ b/src/Optimization/hiopKKTLinSysSparse.cpp @@ -890,7 +890,6 @@ namespace hiop size_type nxu = nlp_->n_upp(); // note that hess may be saved as a triangular matrix - int n1st = 0; int n2st = nx + neq + nineq; int n3st = n2st + nd; int n4st = n3st + ndl + ndu + nxl + nxu; // shortcut for each subbloock diff --git a/src/Optimization/hiopKKTLinSysSparseCondensed.cpp b/src/Optimization/hiopKKTLinSysSparseCondensed.cpp index 7578f8443..67b1d26d4 100644 --- a/src/Optimization/hiopKKTLinSysSparseCondensed.cpp +++ b/src/Optimization/hiopKKTLinSysSparseCondensed.cpp @@ -72,15 +72,15 @@ hiopKKTLinSysCondensedSparse::hiopKKTLinSysCondensedSparse(hiopNlpFormulation* n : hiopKKTLinSysCompressedSparseXDYcYd(nlp), JacD_(nullptr), JacDt_(nullptr), - JtDiagJ_(nullptr), Hess_lower_csr_(nullptr), Hess_upper_csr_(nullptr), Hess_csr_(nullptr), + JtDiagJ_(nullptr), M_condensed_(nullptr), Hess_upper_plus_diag_(nullptr), - deltawx_(nullptr), - Dx_plus_deltawx_(nullptr), Diag_Dx_deltawx_(nullptr), + Dx_plus_deltawx_(nullptr), + deltawx_(nullptr), Hd_copy_(nullptr) { } @@ -110,8 +110,6 @@ bool hiopKKTLinSysCondensedSparse::build_kkt_matrix(const hiopPDPerturbation& pd const hiopVector& delta_wx_in = *delta_wx_; const hiopVector& delta_wd_in = *delta_wd_; - const hiopVector& dcc = *delta_cc_; - const hiopVector& dcd = *delta_cd_; nlp_->runStats.kkt.tmUpdateInit.start(); @@ -300,7 +298,6 @@ bool hiopKKTLinSysCondensedSparse::build_kkt_matrix(const hiopPDPerturbation& pd //t.stop(); printf("ADD-symb took %.5f\n", t.getElapsedTime()); } else { - auto* lins_sys_sparse = dynamic_cast(linSys_); assert(linSys_); assert(M_condensed_); //todo assert(M_condensed_ == linSys_->sys_matrix()); @@ -360,8 +357,6 @@ bool hiopKKTLinSysCondensedSparse::solve_compressed_direct(hiopVector& rx, assert(0 == ryc.get_size() && "this KKT does not support equality constraints"); size_type nx = rx.get_size(); - size_type nd = rd.get_size(); - size_type nyd = ryd.get_size(); assert(rhs_); assert(rhs_->get_size() == nx); @@ -420,8 +415,6 @@ bool hiopKKTLinSysCondensedSparse::solveCompressed(hiopVector& rx, nlp_->runStats.kkt.tmSolveInner.start(); size_type nx = rx.get_size(); - size_type nd = rd.get_size(); - size_type nyd = ryd.get_size(); // this is rhs used by the direct "condensed" solve if(rhs_ == NULL) { diff --git a/src/Optimization/hiopKKTLinSysSparseNormalEqn.cpp b/src/Optimization/hiopKKTLinSysSparseNormalEqn.cpp index e7bffbc0e..a56553659 100644 --- a/src/Optimization/hiopKKTLinSysSparseNormalEqn.cpp +++ b/src/Optimization/hiopKKTLinSysSparseNormalEqn.cpp @@ -68,10 +68,6 @@ namespace hiop { hiopKKTLinSysSparseNormalEqn::hiopKKTLinSysSparseNormalEqn(hiopNlpFormulation* nlp) : hiopKKTLinSysNormalEquation(nlp), - nlpSp_{nullptr}, - HessSp_{nullptr}, - Jac_cSp_{nullptr}, - Jac_dSp_{nullptr}, rhs_{nullptr}, Hess_diag_{nullptr}, deltawx_{nullptr}, @@ -83,13 +79,17 @@ hiopKKTLinSysSparseNormalEqn::hiopKKTLinSysSparseNormalEqn(hiopNlpFormulation* n Hx_copy_{nullptr}, Hd_copy_{nullptr}, Hxd_inv_copy_{nullptr}, + write_linsys_counter_(-1), + csr_writer_(nlp), + nlpSp_{nullptr}, + HessSp_{nullptr}, + Jac_cSp_{nullptr}, + Jac_dSp_{nullptr}, JacD_{nullptr}, JacDt_{nullptr}, JDiagJt_{nullptr}, Diag_dualreg_{nullptr}, - M_normaleqn_{nullptr}, - write_linsys_counter_(-1), - csr_writer_(nlp) + M_normaleqn_{nullptr} { nlpSp_ = dynamic_cast(nlp_); assert(nlpSp_); @@ -151,8 +151,6 @@ bool hiopKKTLinSysSparseNormalEqn::build_kkt_matrix(const hiopPDPerturbation& pd assert(HessSp_->is_diagonal()); hiopMatrixSymSparseTriplet* Hess_triplet = dynamic_cast(Hess_); - const hiopMatrixSparseTriplet* Jac_c_triplet = dynamic_cast(Jac_c_); - const hiopMatrixSparseTriplet* Jac_d_triplet = dynamic_cast(Jac_d_); assert(HessSp_ && Jac_cSp_ && Jac_dSp_); if(nullptr==Jac_dSp_ || nullptr==HessSp_) { diff --git a/src/Optimization/hiopNlpTransforms.cpp b/src/Optimization/hiopNlpTransforms.cpp index 8b2a7d92f..d97696b56 100644 --- a/src/Optimization/hiopNlpTransforms.cpp +++ b/src/Optimization/hiopNlpTransforms.cpp @@ -105,7 +105,7 @@ void hiopFixedVarsRemover::setFSVectorDistrib(index_type* vec_distrib_in, int nu /* allocates and returns the reduced-space column partitioning to be used internally by HiOp */ index_type* hiopFixedVarsRemover::allocRSVectorDistrib() { - size_t nlen = fs_vec_distrib.size(); //nlen==nranks+1 + size_type nlen = fs_vec_distrib.size(); //nlen==nranks+1 assert(nlen>=1); index_type* rsVecDistrib = new index_type[nlen]; rsVecDistrib[0]=0; @@ -468,10 +468,6 @@ hiopNLPObjGradScaling::hiopNLPObjGradScaling(hiopNlpFormulation* nlp, scale_factor_d->component_max(1.0); scale_factor_d->invert(); - [[maybe_unused]] const double* eq_arr = scale_factor_c->local_data_const(); - [[maybe_unused]] const double* ineq_arr = scale_factor_d->local_data_const(); - [[maybe_unused]] double* scale_factor_cd_arr = scale_factor_cd->local_data(); - scale_factor_cd->copy_from_two_vec_w_pattern(*scale_factor_c, cons_eq_mapping, *scale_factor_d, cons_ineq_mapping); Jac_c.row_max_abs_value(*scale_factor_c); diff --git a/src/Utils/hiopCSR_IO.hpp b/src/Utils/hiopCSR_IO.hpp index bb0226727..c28d32c48 100644 --- a/src/Utils/hiopCSR_IO.hpp +++ b/src/Utils/hiopCSR_IO.hpp @@ -22,7 +22,12 @@ namespace hiop public: // masterrank=-1 means all ranks save hiopCSR_IO(hiopNlpFormulation* nlp, int masterrank=0) - : _nlp(nlp), _master_rank(masterrank), m(-1), last_counter(-1) + : _nlp(nlp), +#ifdef HIOP_USE_MPI + _master_rank(masterrank), +#endif + m(-1), + last_counter(-1) { } @@ -227,8 +232,11 @@ namespace hiop private: hiopNlpFormulation* _nlp; +#ifdef HIOP_USE_MPI int _master_rank; - int m, last_counter; //used only for consistency (such as order of calls) checks +#endif + int m; + int last_counter; //used only for consistency (such as order of calls) checks }; } // end namespace diff --git a/src/Utils/hiopKronReduction.cpp b/src/Utils/hiopKronReduction.cpp index 392c22353..05e6a4678 100644 --- a/src/Utils/hiopKronReduction.cpp +++ b/src/Utils/hiopKronReduction.cpp @@ -102,8 +102,8 @@ namespace hiop assert(map_nonaux_to_aux_); if(NULL==map_nonaux_to_aux_) return false; - assert(v_nonaux_in.size() == map_nonaux_to_aux_->n()); - assert(v_aux_out.size() == map_nonaux_to_aux_->m()); + assert((size_type) v_nonaux_in.size() == map_nonaux_to_aux_->n()); + assert((size_type) v_aux_out.size() == map_nonaux_to_aux_->m()); map_nonaux_to_aux_->timesVec(std::complex(0.,0.), v_aux_out.data(), diff --git a/src/Utils/hiopRunStats.hpp b/src/Utils/hiopRunStats.hpp index bbecacf6f..9d02b64cc 100644 --- a/src/Utils/hiopRunStats.hpp +++ b/src/Utils/hiopRunStats.hpp @@ -305,7 +305,9 @@ class hiopRunStats { public: hiopRunStats(MPI_Comm comm_=MPI_COMM_WORLD) +#ifdef HIOP_USE_MPI : comm(comm_) +#endif { initialize(); }; @@ -388,9 +390,11 @@ class hiopRunStats return ss.str(); } + +#ifdef HIOP_USE_MPI private: MPI_Comm comm; - +#endif }; } diff --git a/tests/LinAlg/matrixTestsDense.hpp b/tests/LinAlg/matrixTestsDense.hpp index fd3c06d09..582afb52b 100644 --- a/tests/LinAlg/matrixTestsDense.hpp +++ b/tests/LinAlg/matrixTestsDense.hpp @@ -1169,7 +1169,6 @@ class MatrixTestsDense : public TestBase int matrixOverwriteUpperTriangleWithLower(hiop::hiopMatrixDense& A, const int rank=0) { const local_ordinal_type M = getNumLocRows(&A); - const local_ordinal_type N = getNumLocCols(&A); for (int i = 0; i < M; i++) { @@ -1190,7 +1189,6 @@ class MatrixTestsDense : public TestBase int matrixOverwriteLowerTriangleWithUpper(hiop::hiopMatrixDense& A, const int rank=0) { const local_ordinal_type M = getNumLocRows(&A); - const local_ordinal_type N = getNumLocCols(&A); for (int i = 0; i < M; i++) { diff --git a/tests/LinAlg/matrixTestsSparse.hpp b/tests/LinAlg/matrixTestsSparse.hpp index 6cc2a584c..f6f74d161 100644 --- a/tests/LinAlg/matrixTestsSparse.hpp +++ b/tests/LinAlg/matrixTestsSparse.hpp @@ -257,8 +257,6 @@ class MatrixTestsSparse : public TestBase hiop::hiopVector& x, const int rank=0) { - [[maybe_unused]] const auto val = getMatrixData(&A); - const real_type A_val = two; const real_type x_val = three; int fail = 0; @@ -1049,8 +1047,6 @@ class MatrixTestsSparse : public TestBase B.copyRowsBlockFrom(A, A_rows_st, n_rows, B_rows_st, B_nnz_st); - [[maybe_unused]] const auto val = getMatrixData(&B); - fail += verifyAnswer(&B,0,B_nnz_st,B_val); fail += verifyAnswer(&B,B_nnz_st,B_nnz_st+nnz_A_need_to_copy,A_val); fail += verifyAnswer(&B,B_nnz_st+nnz_A_need_to_copy,B_nnz,B_val); diff --git a/tests/test_bicgstab.cpp b/tests/test_bicgstab.cpp index e4dd3bf9a..6f6b7c55d 100644 --- a/tests/test_bicgstab.cpp +++ b/tests/test_bicgstab.cpp @@ -85,7 +85,6 @@ void initializeRajaSymSparseMat(hiop::hiopMatrixSparse* mat, bool is_diag_pred) int nonZerosUsed = 0; size_type m = A->m(); - size_type n = A->n(); for (auto i = 0; i < m; i++) { @@ -121,8 +120,10 @@ void initializeRajaSymSparseMat(hiop::hiopMatrixSparse* mat, bool is_diag_pred) int main(int argc, char **argv) { - int rank=0, numRanks=1; + #ifdef HIOP_USE_MPI + int rank = 0; + int numRanks = 1; int err; err = MPI_Init(&argc, &argv); assert(MPI_SUCCESS==err); err = MPI_Comm_rank(MPI_COMM_WORLD,&rank); assert(MPI_SUCCESS==err); @@ -211,7 +212,11 @@ int main(int argc, char **argv) bool is_solved = bicgstab_solver.solve(rhs); - std::cout << mem_space << ": " << bicgstab_solver.get_convergence_info() << std::endl; + if(is_solved) { + std::cout << mem_space << ": " << bicgstab_solver.get_convergence_info() << std::endl; + } else { + std::cout << "Failed! " << mem_space << ": " << bicgstab_solver.get_convergence_info() << std::endl; + } // Destroy testing objects delete A_opr; diff --git a/tests/test_pcg.cpp b/tests/test_pcg.cpp index 65345b7fa..732ebf27d 100644 --- a/tests/test_pcg.cpp +++ b/tests/test_pcg.cpp @@ -84,7 +84,6 @@ void initializeRajaSymSparseMat(hiop::hiopMatrixSparse* mat, bool is_diag_pred) int nonZerosUsed = 0; size_type m = A->m(); - size_type n = A->n(); for (auto i = 0; i < m; i++) { @@ -121,8 +120,9 @@ void initializeRajaSymSparseMat(hiop::hiopMatrixSparse* mat, bool is_diag_pred) int main(int argc, char **argv) { - int rank=0, numRanks=1; #ifdef HIOP_USE_MPI + int rank = 0; + int numRanks = 1; int err; err = MPI_Init(&argc, &argv); assert(MPI_SUCCESS==err); err = MPI_Comm_rank(MPI_COMM_WORLD,&rank); assert(MPI_SUCCESS==err); @@ -211,9 +211,13 @@ int main(int argc, char **argv) hiopPCGSolver pcg_solver(N_local, A_opr, Minv_opr, nullptr, nullptr); bool is_solved = pcg_solver.solve(rhs); - - std::cout << mem_space << ": " << pcg_solver.get_convergence_info() << std::endl; - + + if(is_solved) { + std::cout << mem_space << ": " << pcg_solver.get_convergence_info() << std::endl; + } else { + std::cout << "Failed! " << mem_space << ": " << pcg_solver.get_convergence_info() << std::endl; + } + // Destroy testing objects delete A_opr; delete Minv_opr;