diff --git a/CMakeLists.txt b/CMakeLists.txt index 9e34ab785..5b5c03106 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,7 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) set(CMAKE_CUDA_SEPARABLE_COMPILATION ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) -set(CMAKE_CXX_FLAGS "-Wall -Werror") +set(CMAKE_CXX_FLAGS "-Wall -Werror -DNDEBUG") if (POLICY CMP0074) cmake_policy(SET CMP0074 NEW) diff --git a/src/Drivers/Dense/NlpDenseConsEx1.cpp b/src/Drivers/Dense/NlpDenseConsEx1.cpp index df97ee21e..2ef583cc4 100644 --- a/src/Drivers/Dense/NlpDenseConsEx1.cpp +++ b/src/Drivers/Dense/NlpDenseConsEx1.cpp @@ -12,8 +12,8 @@ Ex1Meshing1D::Ex1Meshing1D(double a, double b, size_type glob_n, double r, MPI_C comm=comm_; comm_size=1; my_rank=0; #ifdef HIOP_USE_MPI - int ierr = MPI_Comm_size(comm, &comm_size); assert(MPI_SUCCESS==ierr); - ierr = MPI_Comm_rank(comm, &my_rank); assert(MPI_SUCCESS==ierr); + int ierr = MPI_Comm_size(comm, &comm_size); assert(MPI_SUCCESS==ierr); (void)ierr; + ierr = MPI_Comm_rank(comm, &my_rank); assert(MPI_SUCCESS==ierr); (void)ierr; #endif // set up vector distribution for primal variables - easier to store it as a member in this simple example col_partition = new index_type[comm_size+1]; @@ -121,7 +121,7 @@ double DiscretizedFunction::dotProductWith( const hiopVector& v_ ) const #ifdef HIOP_USE_MPI double dotprodG; - int ierr = MPI_Allreduce(&dot, &dotprodG, 1, MPI_DOUBLE, MPI_SUM, comm_); assert(MPI_SUCCESS==ierr); + int ierr = MPI_Allreduce(&dot, &dotprodG, 1, MPI_DOUBLE, MPI_SUM, comm_); assert(MPI_SUCCESS==ierr); (void)ierr; dot=dotprodG; #endif return dot; @@ -150,7 +150,7 @@ double DiscretizedFunction::twonorm() const #ifdef HIOP_USE_MPI double nrm_squareG; - int ierr = MPI_Allreduce(&nrm_square, &nrm_squareG, 1, MPI_DOUBLE, MPI_SUM, comm_); assert(MPI_SUCCESS==ierr); + int ierr = MPI_Allreduce(&nrm_square, &nrm_squareG, 1, MPI_DOUBLE, MPI_SUM, comm_); assert(MPI_SUCCESS==ierr); (void)ierr; nrm_square=nrm_squareG; #endif return sqrt(nrm_square); diff --git a/src/Drivers/Dense/NlpDenseConsEx1Driver.cpp b/src/Drivers/Dense/NlpDenseConsEx1Driver.cpp index 4fbebc4b0..2292e8cea 100644 --- a/src/Drivers/Dense/NlpDenseConsEx1Driver.cpp +++ b/src/Drivers/Dense/NlpDenseConsEx1Driver.cpp @@ -63,7 +63,7 @@ int main(int argc, char **argv) int rank = 0; #ifdef HIOP_USE_MPI int numRanks = 1; - int err; + int err; (void)err; err = MPI_Init(&argc, &argv); assert(MPI_SUCCESS==err); err = MPI_Comm_rank(MPI_COMM_WORLD,&rank); assert(MPI_SUCCESS==err); err = MPI_Comm_size(MPI_COMM_WORLD,&numRanks); assert(MPI_SUCCESS==err); diff --git a/src/Drivers/Dense/NlpDenseConsEx2.cpp b/src/Drivers/Dense/NlpDenseConsEx2.cpp index cffbd97c2..b51beca97 100644 --- a/src/Drivers/Dense/NlpDenseConsEx2.cpp +++ b/src/Drivers/Dense/NlpDenseConsEx2.cpp @@ -13,8 +13,8 @@ DenseConsEx2::DenseConsEx2(int n, bool unconstrained) 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); + int ierr = MPI_Comm_size(comm, &comm_size); assert(MPI_SUCCESS==ierr); (void)ierr; + ierr = MPI_Comm_rank(comm, &my_rank); assert(MPI_SUCCESS==ierr); (void)ierr; #endif if(unconstrained_) { @@ -111,7 +111,7 @@ bool DenseConsEx2::eval_f(const size_type& n, const double* x, bool new_x, doubl } #ifdef HIOP_USE_MPI double obj_global; - int ierr = MPI_Allreduce(&obj_value, &obj_global, 1, MPI_DOUBLE, MPI_SUM, comm); assert(ierr==MPI_SUCCESS); + int ierr = MPI_Allreduce(&obj_value, &obj_global, 1, MPI_DOUBLE, MPI_SUM, comm); assert(MPI_SUCCESS==ierr); (void)ierr; obj_value = obj_global; #endif return true; @@ -212,7 +212,7 @@ bool DenseConsEx2::eval_cons(const size_type& n, #ifdef HIOP_USE_MPI if(num_cons>0) { double* cons_global = new double[num_cons]; - int ierr = MPI_Allreduce(cons, cons_global, num_cons, MPI_DOUBLE, MPI_SUM, comm); assert(ierr==MPI_SUCCESS); + int ierr = MPI_Allreduce(cons, cons_global, num_cons, MPI_DOUBLE, MPI_SUM, comm); assert(MPI_SUCCESS==ierr); (void)ierr; memcpy(cons, cons_global, num_cons*sizeof(double)); delete[] cons_global; } diff --git a/src/Drivers/Dense/NlpDenseConsEx2Driver.cpp b/src/Drivers/Dense/NlpDenseConsEx2Driver.cpp index 7aad10fbf..1b1b3edd8 100644 --- a/src/Drivers/Dense/NlpDenseConsEx2Driver.cpp +++ b/src/Drivers/Dense/NlpDenseConsEx2Driver.cpp @@ -67,7 +67,7 @@ int main(int argc, char **argv) #ifdef HIOP_USE_MPI MPI_Init(&argc, &argv); int ierr = MPI_Comm_rank(MPI_COMM_WORLD,&rank); - assert(MPI_SUCCESS==ierr); + assert(MPI_SUCCESS==ierr); (void)ierr; //if(0==rank) printf("Support for MPI is enabled\n"); #endif bool selfCheck; diff --git a/src/Drivers/Dense/NlpDenseConsEx3.hpp b/src/Drivers/Dense/NlpDenseConsEx3.hpp index d539c5c77..70b3156b7 100644 --- a/src/Drivers/Dense/NlpDenseConsEx3.hpp +++ b/src/Drivers/Dense/NlpDenseConsEx3.hpp @@ -38,8 +38,8 @@ class DenseConsEx3 : public hiop::hiopInterfaceDenseConstraints 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); + int ierr = MPI_Comm_size(comm, &comm_size); assert(MPI_SUCCESS==ierr); (void)ierr; + ierr = MPI_Comm_rank(comm, &my_rank); assert(MPI_SUCCESS==ierr); (void)ierr; #endif // set up vector distribution for primal variables - easier to store it as a member in this simple example @@ -103,7 +103,7 @@ class DenseConsEx3 : public hiop::hiopInterfaceDenseConstraints for(int i=0;i0) { double* cons_global = new double[num_cons]; - int ierr = MPI_Allreduce(cons, cons_global, num_cons, MPI_DOUBLE, MPI_SUM, comm); assert(ierr==MPI_SUCCESS); + int ierr = MPI_Allreduce(cons, cons_global, num_cons, MPI_DOUBLE, MPI_SUM, comm); assert(MPI_SUCCESS==ierr); (void)ierr; memcpy(cons, cons_global, num_cons*sizeof(double)); delete[] cons_global; } diff --git a/src/Drivers/Dense/NlpDenseConsEx4Driver.cpp b/src/Drivers/Dense/NlpDenseConsEx4Driver.cpp index 7c2cccc08..4d6b7f5ca 100644 --- a/src/Drivers/Dense/NlpDenseConsEx4Driver.cpp +++ b/src/Drivers/Dense/NlpDenseConsEx4Driver.cpp @@ -46,7 +46,7 @@ int main(int argc, char **argv) #ifdef HIOP_USE_MPI MPI_Init(&argc, &argv); int ierr = MPI_Comm_rank(MPI_COMM_WORLD,&rank); - assert(MPI_SUCCESS==ierr); + assert(MPI_SUCCESS==ierr); (void)ierr; //if(0==rank) printf("Support for MPI is enabled\n"); #endif bool selfCheck; diff --git a/src/Drivers/MDS/NlpMdsEx1.c b/src/Drivers/MDS/NlpMdsEx1.c index 7f13481e2..58e1e084d 100644 --- a/src/Drivers/MDS/NlpMdsEx1.c +++ b/src/Drivers/MDS/NlpMdsEx1.c @@ -291,8 +291,8 @@ int main(int argc, char **argv) { #ifdef HIOP_USE_MPI MPI_Init(&argc, &argv); int comm_size; - int ierr = MPI_Comm_size(MPI_COMM_WORLD, &comm_size); assert(MPI_SUCCESS==ierr); - //int ierr = MPI_Comm_rank(MPI_COMM_WORLD, &rank); assert(MPI_SUCCESS==ierr); + int ierr = MPI_Comm_size(MPI_COMM_WORLD, &comm_size); assert(MPI_SUCCESS==ierr); (void)ierr; + //int ierr = MPI_Comm_rank(MPI_COMM_WORLD, &rank); assert(MPI_SUCCESS==ierr); (void)ierr; if(comm_size != 1) { printf("[error] driver detected more than one rank but the driver should be run " "in serial only; will exit\n"); diff --git a/src/Drivers/MDS/NlpMdsEx1Driver.cpp b/src/Drivers/MDS/NlpMdsEx1Driver.cpp index 610dd1928..bfb18144a 100644 --- a/src/Drivers/MDS/NlpMdsEx1Driver.cpp +++ b/src/Drivers/MDS/NlpMdsEx1Driver.cpp @@ -92,8 +92,8 @@ int main(int argc, char **argv) #ifdef HIOP_USE_MPI MPI_Init(&argc, &argv); int comm_size; - int ierr = MPI_Comm_size(MPI_COMM_WORLD, &comm_size); assert(MPI_SUCCESS==ierr); - //int ierr = MPI_Comm_rank(MPI_COMM_WORLD, &rank); assert(MPI_SUCCESS==ierr); + int ierr = MPI_Comm_size(MPI_COMM_WORLD, &comm_size); assert(MPI_SUCCESS==ierr); (void)ierr; + //int ierr = MPI_Comm_rank(MPI_COMM_WORLD, &rank); assert(MPI_SUCCESS==ierr); (void)ierr; if(comm_size != 1) { printf("[error] driver detected more than one rank but the driver should be run " "in serial only; will exit\n"); diff --git a/src/Drivers/MDS/NlpMdsEx1RajaDriver.cpp b/src/Drivers/MDS/NlpMdsEx1RajaDriver.cpp index 05e90d9af..fa8dd1a7a 100644 --- a/src/Drivers/MDS/NlpMdsEx1RajaDriver.cpp +++ b/src/Drivers/MDS/NlpMdsEx1RajaDriver.cpp @@ -95,8 +95,8 @@ int main(int argc, char **argv) #ifdef HIOP_USE_MPI MPI_Init(&argc, &argv); int comm_size; - int ierr = MPI_Comm_size(MPI_COMM_WORLD, &comm_size); assert(MPI_SUCCESS==ierr); - //int ierr = MPI_Comm_rank(MPI_COMM_WORLD, &rank); assert(MPI_SUCCESS==ierr); + int ierr = MPI_Comm_size(MPI_COMM_WORLD, &comm_size); assert(MPI_SUCCESS==ierr); (void)ierr; + //int ierr = MPI_Comm_rank(MPI_COMM_WORLD, &rank); assert(MPI_SUCCESS==ierr); (void)ierr; if(comm_size != 1) { printf("[error] driver detected more than one rank but the driver should be run " "in serial only; will exit\n"); diff --git a/src/Drivers/MDS/NlpMdsEx2.hpp b/src/Drivers/MDS/NlpMdsEx2.hpp index b92d0bfda..6460c8e6b 100644 --- a/src/Drivers/MDS/NlpMdsEx2.hpp +++ b/src/Drivers/MDS/NlpMdsEx2.hpp @@ -429,7 +429,7 @@ class MdsEx2 : public hiop::hiopInterfaceMDS //values for sparse Jacobian if requested by the solver if(MJacS!=NULL) { int nnzit=0; - int con_idx=0; + int con_idx=0; (void)con_idx; //sparse Jacobian EQ w.r.t. x and s for(int i=0; ieval_f(n, x, false, obj_value); + bool temp = rec_evaluator_->eval_f(n, x, false, obj_value); (void)temp; assert(temp); } diff --git a/src/Drivers/PriDec/NlpPriDecEx3SparseDriver.cpp b/src/Drivers/PriDec/NlpPriDecEx3SparseDriver.cpp index a7c9cf82b..68e76c0e9 100644 --- a/src/Drivers/PriDec/NlpPriDecEx3SparseDriver.cpp +++ b/src/Drivers/PriDec/NlpPriDecEx3SparseDriver.cpp @@ -33,8 +33,8 @@ int main(int argc, char **argv) #ifdef HIOP_USE_MPI MPI_Init(&argc, &argv); int comm_size; - int ierr = MPI_Comm_size(MPI_COMM_WORLD, &comm_size); assert(MPI_SUCCESS==ierr); - ierr = MPI_Comm_rank(MPI_COMM_WORLD, &rank); assert(MPI_SUCCESS==ierr); + int ierr = MPI_Comm_size(MPI_COMM_WORLD, &comm_size); assert(MPI_SUCCESS==ierr); (void)ierr; + ierr = MPI_Comm_rank(MPI_COMM_WORLD, &rank); assert(MPI_SUCCESS==ierr); (void)ierr; double t3 = MPI_Wtime(); double t4 = 0.; #endif diff --git a/src/Drivers/Sparse/NlpSparseCEx1.c b/src/Drivers/Sparse/NlpSparseCEx1.c index 6715c6cdf..f81d0eafb 100644 --- a/src/Drivers/Sparse/NlpSparseCEx1.c +++ b/src/Drivers/Sparse/NlpSparseCEx1.c @@ -218,8 +218,8 @@ int main(int argc, char **argv) { #ifdef HIOP_USE_MPI MPI_Init(&argc, &argv); int comm_size; - int ierr = MPI_Comm_size(MPI_COMM_WORLD, &comm_size); assert(MPI_SUCCESS==ierr); - //int ierr = MPI_Comm_rank(MPI_COMM_WORLD, &rank); assert(MPI_SUCCESS==ierr); + int ierr = MPI_Comm_size(MPI_COMM_WORLD, &comm_size); assert(MPI_SUCCESS==ierr); (void)ierr; + //int ierr = MPI_Comm_rank(MPI_COMM_WORLD, &rank); assert(MPI_SUCCESS==ierr); (void)ierr; if(comm_size != 1) { printf("[error] driver detected more than one rank but the driver should be run " "in serial only; will exit\n"); diff --git a/src/Drivers/Sparse/NlpSparseEx1Driver.cpp b/src/Drivers/Sparse/NlpSparseEx1Driver.cpp index 3131fc024..6246971ff 100644 --- a/src/Drivers/Sparse/NlpSparseEx1Driver.cpp +++ b/src/Drivers/Sparse/NlpSparseEx1Driver.cpp @@ -175,7 +175,7 @@ int main(int argc, char **argv) #ifdef HIOP_USE_MPI MPI_Init(&argc, &argv); int comm_size; - int ierr = MPI_Comm_size(MPI_COMM_WORLD, &comm_size); assert(MPI_SUCCESS==ierr); + int ierr = MPI_Comm_size(MPI_COMM_WORLD, &comm_size); assert(MPI_SUCCESS==ierr); (void)ierr; if(comm_size != 1) { printf("[error] driver detected more than one rank but the driver should be run " "in serial only; will exit\n"); diff --git a/src/Drivers/Sparse/NlpSparseEx2Driver.cpp b/src/Drivers/Sparse/NlpSparseEx2Driver.cpp index e61b866a0..12127e3f9 100644 --- a/src/Drivers/Sparse/NlpSparseEx2Driver.cpp +++ b/src/Drivers/Sparse/NlpSparseEx2Driver.cpp @@ -192,7 +192,7 @@ int main(int argc, char **argv) #ifdef HIOP_USE_MPI MPI_Init(&argc, &argv); int comm_size; - int ierr = MPI_Comm_size(MPI_COMM_WORLD, &comm_size); assert(MPI_SUCCESS==ierr); + int ierr = MPI_Comm_size(MPI_COMM_WORLD, &comm_size); assert(MPI_SUCCESS==ierr); (void)ierr; if(comm_size != 1) { printf("[error] driver detected more than one rank but the driver should be run " "in serial only; will exit\n"); diff --git a/src/Drivers/Sparse/NlpSparseEx3Driver.cpp b/src/Drivers/Sparse/NlpSparseEx3Driver.cpp index 447dde583..ab1eb31ca 100644 --- a/src/Drivers/Sparse/NlpSparseEx3Driver.cpp +++ b/src/Drivers/Sparse/NlpSparseEx3Driver.cpp @@ -149,7 +149,7 @@ int main(int argc, char **argv) #ifdef HIOP_USE_MPI MPI_Init(&argc, &argv); int comm_size; - int ierr = MPI_Comm_size(MPI_COMM_WORLD, &comm_size); assert(MPI_SUCCESS==ierr); + int ierr = MPI_Comm_size(MPI_COMM_WORLD, &comm_size); assert(MPI_SUCCESS==ierr); (void)ierr; if(comm_size != 1) { printf("[error] driver detected more than one rank but the driver should be run " "in serial only; will exit\n"); diff --git a/src/Drivers/Sparse/NlpSparseEx4Driver.cpp b/src/Drivers/Sparse/NlpSparseEx4Driver.cpp index 0200284f6..4beec0f36 100644 --- a/src/Drivers/Sparse/NlpSparseEx4Driver.cpp +++ b/src/Drivers/Sparse/NlpSparseEx4Driver.cpp @@ -175,7 +175,7 @@ int main(int argc, char **argv) #ifdef HIOP_USE_MPI MPI_Init(&argc, &argv); int comm_size; - int ierr = MPI_Comm_size(MPI_COMM_WORLD, &comm_size); assert(MPI_SUCCESS==ierr); + int ierr = MPI_Comm_size(MPI_COMM_WORLD, &comm_size); assert(MPI_SUCCESS==ierr); (void)ierr; if(comm_size != 1) { printf("[error] driver detected more than one rank but the driver should be run " "in serial only; will exit\n"); diff --git a/src/Drivers/Sparse/NlpSparseRajaEx2Driver.cpp b/src/Drivers/Sparse/NlpSparseRajaEx2Driver.cpp index a2455ebe1..d7780cc7b 100644 --- a/src/Drivers/Sparse/NlpSparseRajaEx2Driver.cpp +++ b/src/Drivers/Sparse/NlpSparseRajaEx2Driver.cpp @@ -209,7 +209,7 @@ int main(int argc, char **argv) #ifdef HIOP_USE_MPI MPI_Init(&argc, &argv); int comm_size; - int ierr = MPI_Comm_size(MPI_COMM_WORLD, &comm_size); assert(MPI_SUCCESS==ierr); + int ierr = MPI_Comm_size(MPI_COMM_WORLD, &comm_size); assert(MPI_SUCCESS==ierr); (void)ierr; if(comm_size != 1) { printf("[error] driver detected more than one rank but the driver should be run " "in serial only; will exit\n"); diff --git a/src/ExecBackends/MemBackendCudaImpl.hpp b/src/ExecBackends/MemBackendCudaImpl.hpp index fecc5978a..89091efe9 100644 --- a/src/ExecBackends/MemBackendCudaImpl.hpp +++ b/src/ExecBackends/MemBackendCudaImpl.hpp @@ -76,7 +76,7 @@ struct AllocImpl inline static T* alloc(MemBackendCuda& mb, const I& n) { T* p; - auto err = cudaMalloc((void**)&p, n*sizeof(T)); + auto err = cudaMalloc((void**)&p, n*sizeof(T)); (void)err; assert(cudaSuccess==err); return p; } @@ -87,7 +87,7 @@ struct DeAllocImpl { inline static void dealloc(MemBackendCuda& mb, T* p) { - auto err = cudaFree((void*)p); + auto err = cudaFree((void*)p); (void)err; assert(cudaSuccess==err); } }; @@ -105,7 +105,7 @@ struct TransferImpl inline static T* alloc(MemBackendHip& mb, const I& n) { T* p = nullptr; - auto err = hipMalloc((void**)&p, n*sizeof(T)); + auto err = hipMalloc((void**)&p, n*sizeof(T)); (void)err; assert(hipSuccess==err); return p; } @@ -86,7 +86,7 @@ struct DeAllocImpl { inline static void dealloc(MemBackendHip& mb, T* p) { - auto err = hipFree((void*)p); + auto err = hipFree((void*)p); (void)err; assert(hipSuccess==err); } }; diff --git a/src/Interface/chiopInterface.cpp b/src/Interface/chiopInterface.cpp index 50a68af1f..a8d991e4e 100644 --- a/src/Interface/chiopInterface.cpp +++ b/src/Interface/chiopInterface.cpp @@ -79,7 +79,7 @@ int hiop_mds_create_problem(cHiopMDSProblem *prob) { } int hiop_mds_solve_problem(cHiopMDSProblem *prob) { - hiopSolveStatus status; + hiopSolveStatus status; (void)status; hiopAlgFilterIPMNewton solver(prob->refcppHiop); status = solver.run(); assert(status<=hiopSolveStatus::User_Stopped); //check solver status if necessary diff --git a/src/LinAlg/hiopLinSolverSymDenseMagma.cpp b/src/LinAlg/hiopLinSolverSymDenseMagma.cpp index c29ec4f78..629ecfcc0 100644 --- a/src/LinAlg/hiopLinSolverSymDenseMagma.cpp +++ b/src/LinAlg/hiopLinSolverSymDenseMagma.cpp @@ -70,7 +70,7 @@ namespace hiop magma_queue_create(devices[device], &magma_device_queue_); - int magmaRet; + int magmaRet; (void)magmaRet; const int align=32; ldda_ = magma_roundup(n, align ); // multiple of 'align', small power of 2 (i.e., 32) @@ -286,7 +286,7 @@ namespace hiop magma_queue_create(devices[device], &magma_device_queue_); - int magmaRet; + int magmaRet; (void)magmaRet; const int align=32; const int nrhs=1; diff --git a/src/LinAlg/hiopMatrixComplexDense.cpp b/src/LinAlg/hiopMatrixComplexDense.cpp index ec3dbea25..0df59580b 100644 --- a/src/LinAlg/hiopMatrixComplexDense.cpp +++ b/src/LinAlg/hiopMatrixComplexDense.cpp @@ -17,7 +17,7 @@ namespace hiop int P=0; if(col_part) { #ifdef HIOP_USE_MPI - int ierr=MPI_Comm_rank(comm_, &P); assert(ierr==MPI_SUCCESS); + int ierr=MPI_Comm_rank(comm_, &P); assert(MPI_SUCCESS==ierr); (void)ierr; #endif glob_jl_=col_part[P]; glob_ju_=col_part[P+1]; } else { diff --git a/src/LinAlg/hiopMatrixComplexSparseTriplet.cpp b/src/LinAlg/hiopMatrixComplexSparseTriplet.cpp index ec322a3b9..79275845d 100644 --- a/src/LinAlg/hiopMatrixComplexSparseTriplet.cpp +++ b/src/LinAlg/hiopMatrixComplexSparseTriplet.cpp @@ -79,7 +79,9 @@ namespace hiop int* iRow = stM->i_row(); int* jCol = stM->j_col(); int nnz = stM->numberOfNonzeros(); +#ifndef NDEBUG int ncols = stM->n(); +#endif // y += alpha*this*x for(int i=0; i::shiftRows(size_type shift) assert(m_local_ - abs(shift) >= 1); #if defined(HIOP_DEEPCHECKS) && !defined(NDEBUG) copyFromDev(); - double test1 = 8.3, test2 = -98.3; + double test1 = 8.3, test2 = -98.3; (void)test1; (void)test2; if(n_local_>0) { //not sure if memcpy is copying sequentially on all systems. we check this. @@ -706,7 +706,7 @@ void hiopMatrixDenseRaja::timesVec(double beta, //here m_local_ is > 0 exec_space_host_.copy(ya_host_, ya, m_local_, exec_space_); int ierr = MPI_Allreduce(ya_host_, yglob_host_, m_local_, MPI_DOUBLE, MPI_SUM, comm_); - assert(MPI_SUCCESS==ierr); + assert(MPI_SUCCESS==ierr); (void)ierr; exec_space_.copy(ya, yglob_host_, m_local_, exec_space_host_); #endif } @@ -832,7 +832,7 @@ void hiopMatrixDenseRaja::timesMat(double beta, // int n2Red=W.m()*W.n(); // double* Wglob = new_mxnlocal_buff(); //[n2Red]; - // int ierr = MPI_Allreduce(WM[0], Wglob, n2Red, MPI_DOUBLE, MPI_SUM,comm); assert(ierr==MPI_SUCCESS); + // int ierr = MPI_Allreduce(WM[0], Wglob, n2Red, MPI_DOUBLE, MPI_SUM,comm); assert(MPI_SUCCESS==ierr); (void)ierr; // memcpy(WM[0], Wglob, n2Red*sizeof(double)); #endif // HIOP_USE_MPI } @@ -994,7 +994,7 @@ timesMatTrans(double beta, hiopMatrix& Wmat, double alpha, const hiopMatrix& Xma auto& W = dynamic_cast(Wmat); assert(W.n_local_==W.n_global_ && "not intended for the case when the result matrix is distributed."); #ifdef HIOP_DEEPCHECKS - const auto& X = dynamic_cast(Xmat); + const auto& X = dynamic_cast(Xmat); (void)X; assert(W.isfinite()); assert(X.isfinite()); assert(this->n()==X.n()); @@ -1017,7 +1017,7 @@ timesMatTrans(double beta, hiopMatrix& Wmat, double alpha, const hiopMatrix& Xma double* Wdata_host = W.data_host_; W.copyFromDev(); double* Wglob = W.new_mxnlocal_host_buff(); - int ierr = MPI_Allreduce(Wdata_host, Wglob, n2Red, MPI_DOUBLE, MPI_SUM, comm_); assert(ierr==MPI_SUCCESS); + int ierr = MPI_Allreduce(Wdata_host, Wglob, n2Red, MPI_DOUBLE, MPI_SUM, comm_); assert(MPI_SUCCESS==ierr); (void)ierr; memcpy(Wdata_host, Wglob, n2Red * sizeof(double)); W.copyToDev(); #endif @@ -1354,7 +1354,7 @@ double hiopMatrixDenseRaja::max_abs_value() #ifdef HIOP_USE_MPI double maxvg; - int ierr=MPI_Allreduce(&maxv,&maxvg,1,MPI_DOUBLE,MPI_MAX,comm_); assert(ierr==MPI_SUCCESS); + int ierr=MPI_Allreduce(&maxv,&maxvg,1,MPI_DOUBLE,MPI_MAX,comm_); assert(MPI_SUCCESS==ierr); (void)ierr; return maxvg; #endif return maxv; @@ -1404,7 +1404,7 @@ void hiopMatrixDenseRaja::row_max_abs_value(hiopVector MPI_DOUBLE, MPI_MAX, comm_); - assert(ierr==MPI_SUCCESS); + assert(MPI_SUCCESS==ierr); (void)ierr; vec.copy_from_vectorpar(maxvg); #endif } diff --git a/src/LinAlg/hiopMatrixDenseRowMajor.cpp b/src/LinAlg/hiopMatrixDenseRowMajor.cpp index 478ac897b..1a557cc05 100644 --- a/src/LinAlg/hiopMatrixDenseRowMajor.cpp +++ b/src/LinAlg/hiopMatrixDenseRowMajor.cpp @@ -72,8 +72,8 @@ hiopMatrixDenseRowMajor::hiopMatrixDenseRowMajor(const size_type& m, comm_size_ = 1; if(col_part) { #ifdef HIOP_USE_MPI - int ierr = MPI_Comm_rank(comm_, &P); assert(ierr==MPI_SUCCESS); - ierr = MPI_Comm_size(comm_, &comm_size_); assert(MPI_SUCCESS==ierr); + int ierr = MPI_Comm_rank(comm_, &P); assert(MPI_SUCCESS==ierr); (void)ierr; + ierr = MPI_Comm_size(comm_, &comm_size_); assert(MPI_SUCCESS==ierr); (void)ierr; #endif glob_jl_=col_part[P]; glob_ju_=col_part[P+1]; } else { @@ -248,7 +248,7 @@ void hiopMatrixDenseRowMajor::shiftRows(size_type shift) //and assert(m_local_-std::abs(shift)>=1); #ifdef HIOP_DEEPCHECKS - double test1=8.3, test2=-98.3; + double test1=8.3, test2=-98.3; (void)test1; (void)test2; if(n_local_>0) { //not sure if memcpy is copying sequentially on all systems. we check this. //let's at least check it @@ -484,7 +484,7 @@ timesVec(double beta, double* ya, double alpha, const double* xa) const #ifdef HIOP_USE_MPI //here m_local_ is > 0 double yglob[m_local_]; - int ierr=MPI_Allreduce(ya, yglob, m_local_, MPI_DOUBLE, MPI_SUM, comm_); assert(MPI_SUCCESS==ierr); + int ierr=MPI_Allreduce(ya, yglob, m_local_, MPI_DOUBLE, MPI_SUM, comm_); assert(MPI_SUCCESS==ierr); (void)ierr; memcpy(ya, yglob, m_local_*sizeof(double)); #endif @@ -565,7 +565,7 @@ void hiopMatrixDenseRowMajor::timesMat(double beta, hiopMatrix& W_, double alpha // int n2Red=W.m()*W.n(); // double* Wglob = new_mxnlocal_buff(); //[n2Red]; - // int ierr = MPI_Allreduce(WM[0], Wglob, n2Red, MPI_DOUBLE, MPI_SUM,comm); assert(ierr==MPI_SUCCESS); + // int ierr = MPI_Allreduce(WM[0], Wglob, n2Red, MPI_DOUBLE, MPI_SUM,comm); assert(MPI_SUCCESS==ierr); (void)ierr; // memcpy(WM[0], Wglob, n2Red*sizeof(double)); #endif @@ -678,7 +678,7 @@ void hiopMatrixDenseRowMajor::timesMatTrans(double beta, hiopMatrix& W_, double auto& W = dynamic_cast(W_); assert(W.n_local_==W.n_global_ && "not intended for the case when the result matrix is distributed."); #ifdef HIOP_DEEPCHECKS - const auto& X = dynamic_cast(X_); + const auto& X = dynamic_cast(X_); (void)X; assert(W.isfinite()); assert(X.isfinite()); assert(this->n()==X.n()); @@ -696,7 +696,7 @@ void hiopMatrixDenseRowMajor::timesMatTrans(double beta, hiopMatrix& W_, double int n2Red=W.m()*W.n(); double* WM=W.local_data(); double* Wglob= W.new_mxnlocal_buff(); - int ierr = MPI_Allreduce(WM, Wglob, n2Red, MPI_DOUBLE, MPI_SUM, comm_); assert(ierr==MPI_SUCCESS); + int ierr = MPI_Allreduce(WM, Wglob, n2Red, MPI_DOUBLE, MPI_SUM, comm_); assert(MPI_SUCCESS==ierr); (void)ierr; memcpy(WM, Wglob, n2Red*sizeof(double)); #endif } @@ -835,7 +835,7 @@ double hiopMatrixDenseRowMajor::max_abs_value() double maxv = DLANGE(&norm, &n_local_, &m_local_, M_[0], &n_local_, NULL); #ifdef HIOP_USE_MPI double maxvg; - int ierr=MPI_Allreduce(&maxv,&maxvg,1,MPI_DOUBLE,MPI_MAX,comm_); assert(ierr==MPI_SUCCESS); + int ierr=MPI_Allreduce(&maxv,&maxvg,1,MPI_DOUBLE,MPI_MAX,comm_); assert(MPI_SUCCESS==ierr); (void)ierr; return maxvg; #endif return maxv; @@ -855,7 +855,7 @@ void hiopMatrixDenseRowMajor::row_max_abs_value(hiopVector &ret_vec) maxv = DLANGE(&norm, &one, &n_local_, M_[0]+(irow*n_local_), &one, nullptr); #ifdef HIOP_USE_MPI double maxvg; - int ierr=MPI_Allreduce(&maxv,&maxvg,1,MPI_DOUBLE,MPI_MAX,comm_); assert(ierr==MPI_SUCCESS); + int ierr=MPI_Allreduce(&maxv,&maxvg,1,MPI_DOUBLE,MPI_MAX,comm_); assert(MPI_SUCCESS==ierr); (void)ierr; maxv = maxvg; #endif vec.local_data()[irow] = maxv; diff --git a/src/LinAlg/hiopMatrixRajaSparseTripletImpl.hpp b/src/LinAlg/hiopMatrixRajaSparseTripletImpl.hpp index d3b1b7094..fa3059a13 100644 --- a/src/LinAlg/hiopMatrixRajaSparseTripletImpl.hpp +++ b/src/LinAlg/hiopMatrixRajaSparseTripletImpl.hpp @@ -517,12 +517,13 @@ transAddToSymDenseMatrixUpperTriangle(int row_start, double alpha, hiopMatrixDense& W) const { +#ifndef NDEBUG 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); +#endif RAJA::View> WM(W.local_data(), W.m(), W.n()); int* iRow = iRow_; @@ -534,9 +535,11 @@ transAddToSymDenseMatrixUpperTriangle(int row_start, const int i = jCol[it] + row_start; const int j = iRow[it] + col_start; #ifdef HIOP_DEEPCHECKS +#ifndef NDEBUG assert(i < Wm && j < Wn); assert(i>=0 && j>=0); assert(i<=j && "source entries need to map inside the upper triangular part of destination"); +#endif #endif WM(i, j) += alpha * values[it]; }); @@ -714,8 +717,10 @@ copy_to(hiopMatrixDense& W) RAJA::View> WM(W.local_data(), W.m(), W.n()); size_type nnz = this->nnz_; +#ifndef NDEBUG size_type nrows = this->nrows_; size_type ncols = this->ncols_; +#endif index_type* jCol = jCol_; index_type* iRow = iRow_; double* values = values_; @@ -1349,7 +1354,9 @@ set_Jac_FR(const hiopMatrixSparse& Jac_c, // assuming original Jac is sorted! int nnz_Jac_c = J_c.numberOfNonzeros(); +#ifndef NDEBUG int nnz_Jac_d = J_d.numberOfNonzeros(); +#endif int m_c = J_c.nrows_; int m_d = J_d.nrows_; int n_c = J_c.ncols_; @@ -1505,8 +1512,10 @@ copySubmatrixFrom(const hiopMatrix& src_gen, const bool offdiag_only) { const hiopMatrixRajaSparseTriplet& src = dynamic_cast(src_gen); +#ifndef NDEBUG auto m_rows = src.m(); auto n_cols = src.n(); +#endif assert(this->numberOfNonzeros() >= src.numberOfNonzeros()); assert(n_cols + dest_col_st <= this->n() ); @@ -1548,9 +1557,10 @@ copySubmatrixFromTrans(const hiopMatrix& src_gen, const bool offdiag_only) { const hiopMatrixRajaSparseTriplet& src = dynamic_cast(src_gen); +#ifndef NDEBUG auto m_rows = src.m(); auto n_cols = src.n(); - +#endif assert(this->numberOfNonzeros() >= src.numberOfNonzeros()); assert(n_cols + dest_col_st <= this->n() ); assert(m_rows + dest_row_st <= this->m()); @@ -1620,7 +1630,7 @@ setSubmatrixToConstantDiag_w_colpattern(const double& scalar, sum += 1; } }); - size_type nrm = sum.get(); + size_type nrm = sum.get(); (void)nrm; assert(nrm == nnz_to_copy); #endif @@ -1708,7 +1718,7 @@ setSubmatrixToConstantDiag_w_rowpattern(const double& scalar, sum += 1; } }); - size_type nrm = sum.get(); + size_type nrm = sum.get(); (void)nrm; assert(nrm == nnz_to_copy); #endif @@ -1838,7 +1848,7 @@ copyDiagMatrixToSubblock_w_pattern(const hiopVector& dx, sum += 1; } }); - size_type nrm = sum.get(); + size_type nrm = sum.get(); (void)nrm; assert(nrm == nnz_to_copy); #endif @@ -2017,8 +2027,10 @@ addUpperTriangleToSymDenseMatrixUpperTriangle(int diag_start, RAJA::View> WM(W.local_data(), W.get_local_size_m(), W.get_local_size_n()); +#ifndef NDEBUG auto Wm = W.m(); auto Wn = W.n(); +#endif auto iRow = this->iRow_; auto jCol = this->jCol_; auto values = this->values_; @@ -2071,7 +2083,9 @@ startingAtAddSubDiagonalToStartingAt(int diag_src_start, assert(diag_src_start>=0 && diag_src_start+num_elems<=this->nrows_); double* v = vd.local_data(); +#ifndef NDEBUG auto vds = vd.get_size(); +#endif auto iRow = this->iRow_; auto jCol = this->jCol_; auto values = this->values_; @@ -2133,10 +2147,12 @@ set_Hess_FR(const hiopMatrixSparse& Hess, const auto& M2 = dynamic_cast&>(Hess); // assuming original Hess is sorted, and in upper-triangle format - const int m1 = M1.m(); +#ifndef NDEBUG const int n1 = M1.n(); - const int m2 = M2.m(); const int n2 = M2.n(); +#endif + const int m1 = M1.m(); + const int m2 = M2.m(); int m_row = add_diag.get_size(); assert(n1==m1); @@ -2147,8 +2163,9 @@ set_Hess_FR(const hiopMatrixSparse& Hess, // Hence we use add_diag.get_size() to detect the length of x in the base problem assert(m_row==m2 || m2==0); +#ifndef NDEBUG int nnz1 = m_row + M2.numberOfOffDiagNonzeros(); - +#endif assert(this->nnz_ == nnz1); if(M2.row_starts_==NULL) { diff --git a/src/LinAlg/hiopMatrixSparseCSRSeq.cpp b/src/LinAlg/hiopMatrixSparseCSRSeq.cpp index e7eceb749..98a086291 100644 --- a/src/LinAlg/hiopMatrixSparseCSRSeq.cpp +++ b/src/LinAlg/hiopMatrixSparseCSRSeq.cpp @@ -402,7 +402,7 @@ void hiopMatrixSparseCSRSeq::copyRowsFrom(const hiopMatrix& src_gen, const index_type* rows_idxs, size_type n_rows) { - const hiopMatrixSparseCSRSeq& src = dynamic_cast(src_gen); + const hiopMatrixSparseCSRSeq& src = dynamic_cast(src_gen); (void)src; assert(this->m() == n_rows); assert(this->numberOfNonzeros() <= src.numberOfNonzeros()); assert(this->n() == src.n()); @@ -422,7 +422,7 @@ void hiopMatrixSparseCSRSeq::copyRowsBlockFrom(const hiopMatrix& src_gen, const index_type& rows_src_idx_st, const size_type& n_rows, const index_type& rows_dest_idx_st, const size_type& dest_nnz_st) { - const hiopMatrixSparseCSRSeq& src = dynamic_cast(src_gen); + const hiopMatrixSparseCSRSeq& src = dynamic_cast(src_gen); (void)src; assert(this->numberOfNonzeros() >= src.numberOfNonzeros()); assert(this->n() >= src.n()); assert(n_rows + rows_src_idx_st <= src.m()); @@ -438,8 +438,8 @@ void hiopMatrixSparseCSRSeq::copySubmatrixFrom(const hiopMatrix& src_gen, const bool offdiag_only) { const hiopMatrixSparseCSRSeq& src = dynamic_cast(src_gen); - auto m_rows = src.m(); - auto n_cols = src.n(); + auto m_rows = src.m(); (void)m_rows; + auto n_cols = src.n(); (void)n_cols; assert(this->numberOfNonzeros() >= src.numberOfNonzeros()); assert(n_cols + dest_col_st <= this->n() ); @@ -456,8 +456,8 @@ void hiopMatrixSparseCSRSeq::copySubmatrixFromTrans(const hiopMatrix& src_gen, const bool offdiag_only) { const auto& src = dynamic_cast(src_gen); - auto m_rows = src.n(); - auto n_cols = src.m(); + auto m_rows = src.n(); (void)m_rows; + auto n_cols = src.m(); (void)n_cols; assert(this->numberOfNonzeros() >= src.numberOfNonzeros()); assert(n_cols + dest_col_st <= this->n() ); @@ -598,8 +598,10 @@ hiopMatrixSparseCSR* hiopMatrixSparseCSRSeq::times_mat_alloc(const hiopMatrixSpa const index_type m = this->m(); const index_type n = Y.n(); +#ifndef NDEBUG const index_type K = this->n(); assert(Y.m() == K); +#endif index_type nnzM = 0; // count the number of entries in the result M @@ -663,12 +665,14 @@ void hiopMatrixSparseCSRSeq::times_mat_symbolic(hiopMatrixSparseCSR& M_in, index_type* jcolindM = M.j_col(); const index_type m = this->m(); +#ifndef NDEBUG const index_type n = Y.n(); assert(M.m()==m && M.n()==n); - + const index_type K = this->n(); assert(Y.m() == K); - +#endif + //if(nullptr == M.buf_col_) { // M.buf_col_ = new double[n]; //} @@ -747,9 +751,11 @@ void hiopMatrixSparseCSRSeq::times_mat_numeric(double beta, const index_type m = this->m(); const index_type n = Y.n(); assert(M.m()==m && M.n()==n); - + +#ifndef NDEBUG const index_type K = this->n(); assert(Y.m() == K); +#endif if(beta!=1.0) { int NN = M.numberOfNonzeros(); @@ -976,7 +982,7 @@ void hiopMatrixSparseCSRSeq::form_transpose_from_numeric(const hiopMatrixSparseT } } #endif - const index_type* Mirow = M.i_row(); + const index_type* Mirow = M.i_row(); (void)Mirow; const index_type* Mjcol = M.j_col(); const double* Mvalues = M.M(); @@ -1363,8 +1369,8 @@ void hiopMatrixSparseCSRSeq::add_matrix_numeric(hiopMatrixSparseCSR& M_in, const double* valuesX = values_; #ifdef HIOP_DEEPCHECKS - index_type* irowptrM = M.i_row(); - index_type* jcolindM = M.j_col(); + index_type* irowptrM = M.i_row(); (void)irowptrM; + index_type* jcolindM = M.j_col(); (void)jcolindM; #endif double* valuesM = M.M(); @@ -1425,7 +1431,7 @@ void hiopMatrixSparseCSRSeq::add_matrix_numeric(hiopMatrixSparseCSR& M_in, // iterate over remaining col indexes of (i row of) X for(; ptX CUSPARSE_MATRIX_TYPE_GENERAL // - IndexBase -> CUSPARSE_INDEX_BASE_ZERO // - leaves other fields uninitialized - cusparseStatus_t st = cusparseCreateMatDescr(&mat_descr_); + cusparseStatus_t st = cusparseCreateMatDescr(&mat_descr_); (void)st; assert(st == CUSPARSE_STATUS_SUCCESS); alloc(); @@ -118,14 +118,14 @@ hiopMatrixSparseCSRCUDA::hiopMatrixSparseCSRCUDA() buffer_gemm5_(nullptr), mat_sp_descr_(nullptr) { - cusparseStatus_t ret_sp = cusparseCreate(&h_cusparse_); + cusparseStatus_t ret_sp = cusparseCreate(&h_cusparse_); (void)ret_sp; assert(ret_sp == CUSPARSE_STATUS_SUCCESS); // the call below initializes the fields of mat_descr_ to what we need // - MatrixType -> CUSPARSE_MATRIX_TYPE_GENERAL // - IndexBase -> CUSPARSE_INDEX_BASE_ZERO // - leaves other fields uninitialized - cusparseStatus_t st = cusparseCreateMatDescr(&mat_descr_); + cusparseStatus_t st = cusparseCreateMatDescr(&mat_descr_); (void)st; assert(st == CUSPARSE_STATUS_SUCCESS); st = cusparseSpGEMM_createDescr(&gemm_sp_descr_); @@ -136,7 +136,7 @@ hiopMatrixSparseCSRCUDA::~hiopMatrixSparseCSRCUDA() { dealloc(); - auto cret = cudaFree(buffer_gemm5_); + auto cret = cudaFree(buffer_gemm5_); (void)cret; assert(cudaSuccess == cret); cret = cudaFree(buffer_gemm4_); assert(cudaSuccess == cret); @@ -151,7 +151,7 @@ hiopMatrixSparseCSRCUDA::~hiopMatrixSparseCSRCUDA() cusparseDestroy(h_cusparse_); //cusolverSpDestroy(h_cusolver_); - cusparseStatus_t st = cusparseDestroyMatDescr(mat_descr_); + cusparseStatus_t st = cusparseDestroyMatDescr(mat_descr_); (void)st; assert(st == CUSPARSE_STATUS_SUCCESS); st = cusparseSpGEMM_destroyDescr(gemm_sp_descr_); @@ -160,7 +160,7 @@ hiopMatrixSparseCSRCUDA::~hiopMatrixSparseCSRCUDA() void hiopMatrixSparseCSRCUDA::alloc() { - cudaError_t err; + cudaError_t err; (void)err; err = cudaMalloc(&irowptr_, (nrows_+1)*sizeof(index_type)); assert(cudaSuccess == err && irowptr_); @@ -182,16 +182,17 @@ void hiopMatrixSparseCSRCUDA::alloc() CUSPARSE_INDEX_32I, CUSPARSE_INDEX_BASE_ZERO, CUDA_R_64F); + (void)st; assert(st == CUSPARSE_STATUS_SUCCESS); } void hiopMatrixSparseCSRCUDA::dealloc() { - auto st = cusparseDestroySpMat(mat_sp_descr_); + auto st = cusparseDestroySpMat(mat_sp_descr_); (void)st; assert(st == CUSPARSE_STATUS_SUCCESS); mat_sp_descr_ = nullptr; - cudaError_t err; + cudaError_t err; (void)err; err = cudaFree(values_); assert(cudaSuccess == err); values_ = nullptr; @@ -465,6 +466,7 @@ void hiopMatrixSparseCSRCUDA::copyRowsFrom(const hiopMatrix& src_gen, const index_type* rows_idxs, size_type n_rows) { +#ifndef NDEBUG const hiopMatrixSparseCSRCUDA& src = dynamic_cast(src_gen); assert(this->m() == n_rows); assert(this->numberOfNonzeros() <= src.numberOfNonzeros()); @@ -472,6 +474,7 @@ void hiopMatrixSparseCSRCUDA::copyRowsFrom(const hiopMatrix& src_gen, assert(n_rows <= src.m()); assert(false && "not yet implemented"); +#endif } /** @@ -485,6 +488,7 @@ void hiopMatrixSparseCSRCUDA::copyRowsBlockFrom(const hiopMatrix& src_gen, const index_type& rows_src_idx_st, const size_type& n_rows, const index_type& rows_dest_idx_st, const size_type& dest_nnz_st) { +#ifndef NDEBUG const hiopMatrixSparseCSRCUDA& src = dynamic_cast(src_gen); assert(this->numberOfNonzeros() >= src.numberOfNonzeros()); assert(this->n() >= src.n()); @@ -492,6 +496,7 @@ void hiopMatrixSparseCSRCUDA::copyRowsBlockFrom(const hiopMatrix& src_gen, assert(n_rows + rows_dest_idx_st <= this->m()); assert(false && "not yet implemented"); +#endif } void hiopMatrixSparseCSRCUDA::copySubmatrixFrom(const hiopMatrix& src_gen, @@ -500,6 +505,7 @@ void hiopMatrixSparseCSRCUDA::copySubmatrixFrom(const hiopMatrix& src_gen, const size_type& dest_nnz_st, const bool offdiag_only) { +#ifndef NDEBUG const hiopMatrixSparseCSRCUDA& src = dynamic_cast(src_gen); auto m_rows = src.m(); auto n_cols = src.n(); @@ -510,6 +516,7 @@ void hiopMatrixSparseCSRCUDA::copySubmatrixFrom(const hiopMatrix& src_gen, assert(dest_nnz_st <= this->numberOfNonzeros()); assert(false && "not yet implemented"); +#endif } void hiopMatrixSparseCSRCUDA::copySubmatrixFromTrans(const hiopMatrix& src_gen, @@ -518,6 +525,7 @@ void hiopMatrixSparseCSRCUDA::copySubmatrixFromTrans(const hiopMatrix& src_gen, const size_type& dest_nnz_st, const bool offdiag_only) { +#ifndef NDEBUG const auto& src = dynamic_cast(src_gen); auto m_rows = src.n(); auto n_cols = src.m(); @@ -528,6 +536,7 @@ void hiopMatrixSparseCSRCUDA::copySubmatrixFromTrans(const hiopMatrix& src_gen, assert(dest_nnz_st <= this->numberOfNonzeros()); assert(false && "not yet implemented"); +#endif } void hiopMatrixSparseCSRCUDA:: @@ -672,8 +681,8 @@ hiopMatrixSparseCSR* hiopMatrixSparseCSRCUDA::times_mat_alloc(const hiopMatrixSp assert(ncols_ == Y.m()); - cusparseStatus_t st; - cudaError_t cret; + cusparseStatus_t st; (void)st; + cudaError_t cret; (void)cret; // // create a temporary matrix descriptor for M @@ -809,7 +818,7 @@ void hiopMatrixSparseCSRCUDA::times_mat_symbolic(hiopMatrixSparseCSR& M_in, auto& Y = dynamic_cast(Y_in); auto& X = *this; - auto cret = cudaMemset(M.values_, 0x0, M.nnz_*sizeof(double)); + auto cret = cudaMemset(M.values_, 0x0, M.nnz_*sizeof(double)); (void)cret; assert(cudaSuccess == cret); cusparseOperation_t opX = CUSPARSE_OPERATION_NON_TRANSPOSE; @@ -826,7 +835,7 @@ void hiopMatrixSparseCSRCUDA::times_mat_symbolic(hiopMatrixSparseCSR& M_in, CUSPARSE_SPGEMM_DEFAULT, M.gemm_sp_descr_, &buff_size5, - nullptr); + nullptr); (void)st; assert(st == CUSPARSE_STATUS_SUCCESS); //allocate buffer5 @@ -860,7 +869,7 @@ void hiopMatrixSparseCSRCUDA::times_mat_numeric(double beta, auto& X = *this; if(beta==0.0) { - auto cret = cudaMemset(M.values_, 0x0, M.nnz_*sizeof(double)); + auto cret = cudaMemset(M.values_, 0x0, M.nnz_*sizeof(double)); (void)cret; assert(cudaSuccess == cret); } @@ -879,6 +888,7 @@ void hiopMatrixSparseCSRCUDA::times_mat_numeric(double beta, compute_type, CUSPARSE_SPGEMM_DEFAULT, M.gemm_sp_descr_); + (void)st; assert(st == CUSPARSE_STATUS_SUCCESS); } @@ -916,6 +926,7 @@ void hiopMatrixSparseCSRCUDA::form_from_symbolic(const hiopMatrixSparseTriplet& nrows_, irowptr_, CUSPARSE_INDEX_BASE_ZERO); + (void)st; assert(CUSPARSE_STATUS_SUCCESS == st); exec_space_.dealloc_array(d_rowind); @@ -965,7 +976,7 @@ void hiopMatrixSparseCSRCUDA::form_transpose_from_symbolic(const hiopMatrixSpars assert(jcolind_); assert(values_); - cusparseStatus_t st; + cusparseStatus_t st; (void)st; size_t buffer_size; st = cusparseCsr2cscEx2_bufferSize(h_cusparse_, M.m(), @@ -984,6 +995,7 @@ void hiopMatrixSparseCSRCUDA::form_transpose_from_symbolic(const hiopMatrixSpars &buffer_size); assert(CUSPARSE_STATUS_SUCCESS == st); cudaError_t ret = cudaMalloc(&buffer_csc2csr_, sizeof(char)*buffer_size); + (void)ret; assert(cudaSuccess == ret); } @@ -995,7 +1007,7 @@ void hiopMatrixSparseCSRCUDA::form_transpose_from_numeric(const hiopMatrixSparse assert(nnz_ == M.numberOfNonzeros()); assert(buffer_csc2csr_); - cusparseStatus_t st; + cusparseStatus_t st; (void)st; st = cusparseCsr2cscEx2(h_cusparse_, M.m(), M.n(), @@ -1044,6 +1056,7 @@ void hiopMatrixSparseCSRCUDA::form_diag_from_numeric(const hiopVector& D) D.local_data_const(), nrows_*sizeof(double), cudaMemcpyDeviceToDevice); + (void)ret; assert(cudaSuccess == ret); } @@ -1080,8 +1093,8 @@ hiopMatrixSparseCSR* hiopMatrixSparseCSRCUDA::add_matrix_alloc(const hiopMatrixS assert(nrows_ == Y.m()); assert(ncols_ == Y.n()); - cusparseStatus_t st; - cudaError_t cret; + cusparseStatus_t st; (void)st; + cudaError_t cret; (void)cret; double alpha = 1.0; //dummy double beta = 1.0; @@ -1181,6 +1194,7 @@ hiopMatrixSparseCSR* hiopMatrixSparseCSRCUDA::add_matrix_alloc(const hiopMatrixS void hiopMatrixSparseCSRCUDA:: add_matrix_symbolic(hiopMatrixSparseCSR& M_in, const hiopMatrixSparseCSR& Y_in) const { +#ifndef NDEBUG auto& M = dynamic_cast(M_in); auto& Y = dynamic_cast(Y_in); @@ -1189,7 +1203,7 @@ add_matrix_symbolic(hiopMatrixSparseCSR& M_in, const hiopMatrixSparseCSR& Y_in) assert(M.n() == Y.n()); assert(M.m() == Y.m()); - +#endif // //nothing to do for this CUDA, geam2-based implementation // @@ -1215,7 +1229,7 @@ void hiopMatrixSparseCSRCUDA::add_matrix_numeric(hiopMatrixSparseCSR& M_in, assert(M.buffer_geam2_); - cusparseStatus_t st; + cusparseStatus_t st; (void)st; st = cusparseDcsrgeam2(h_cusparse_, nrows_, ncols_, diff --git a/src/LinAlg/hiopMatrixSparseCsrCuda.hpp b/src/LinAlg/hiopMatrixSparseCsrCuda.hpp index a6bae1cb0..dca0df361 100644 --- a/src/LinAlg/hiopMatrixSparseCsrCuda.hpp +++ b/src/LinAlg/hiopMatrixSparseCsrCuda.hpp @@ -602,6 +602,7 @@ class hiopMatrixSparseCSRCUDA : public hiopMatrixSparseCSR inline void use_sparse_gemm_descriptor(cusparseSpGEMMDescr_t gemm_sp_descr_in) { auto st = cusparseSpGEMM_destroyDescr(gemm_sp_descr_); + (void)st; assert(st == CUSPARSE_STATUS_SUCCESS); gemm_sp_descr_ = gemm_sp_descr_in; } @@ -611,7 +612,7 @@ class hiopMatrixSparseCSRCUDA : public hiopMatrixSparseCSR */ inline void use_sparse_mat_descriptor(cusparseSpMatDescr_t sp_mat_descr) { - auto st = cusparseDestroySpMat(mat_sp_descr_); + auto st = cusparseDestroySpMat(mat_sp_descr_); (void)st; assert(st == CUSPARSE_STATUS_SUCCESS); mat_sp_descr_ = sp_mat_descr; @@ -632,6 +633,7 @@ class hiopMatrixSparseCSRCUDA : public hiopMatrixSparseCSR inline void dealloc_gemm_buffer3() { auto ret = cudaFree(buffer_gemm3_); + (void)ret; assert(cudaSuccess == ret); buffer_gemm3_ = nullptr; } @@ -650,6 +652,7 @@ class hiopMatrixSparseCSRCUDA : public hiopMatrixSparseCSR { assert(buffer_gemm5_ == nullptr); auto cret = cudaMalloc((void**)&(buffer_gemm5_), buff_size); + (void)cret; assert(cudaSuccess == cret); return buffer_gemm5_; } diff --git a/src/LinAlg/hiopMatrixSparseTriplet.cpp b/src/LinAlg/hiopMatrixSparseTriplet.cpp index 6b81c4f04..b466bb89d 100644 --- a/src/LinAlg/hiopMatrixSparseTriplet.cpp +++ b/src/LinAlg/hiopMatrixSparseTriplet.cpp @@ -149,7 +149,10 @@ void hiopMatrixSparseTriplet::timesMatTrans(double beta, auto& W = dynamic_cast(Wmat); const auto& M2 = dynamic_cast(M2mat); const hiopMatrixSparseTriplet& M1 = *this; - const int m1 = M1.nrows_, nx = M1.ncols_, m2 = M2.nrows_; +#ifndef NDEBUG + const int nx = M1.ncols_; +#endif + const int m1 = M1.nrows_, m2 = M2.nrows_; assert(nx==M1.ncols_); assert(nx==M2.ncols_); assert(M2.ncols_ == nx); @@ -393,7 +396,9 @@ addMDinvMtransToDiagBlockOfSymDeMatUTri(int rowAndCol_dest_start, const hiopVector& D, hiopMatrixDense& W) const { const int row_dest_start = rowAndCol_dest_start, col_dest_start = rowAndCol_dest_start; +#ifndef NDEBUG int n = this->nrows_; +#endif assert(row_dest_start>=0 && row_dest_start+n<=W.m()); assert(col_dest_start>=0 && col_dest_start+nrows_<=W.n()); assert(D.get_size() == this->ncols_); @@ -452,7 +457,10 @@ addMDinvNtransToSymDeMatUTri(int row_dest_start, int col_dest_start, { const hiopMatrixSparseTriplet& M2 = dynamic_cast(M2mat); const hiopMatrixSparseTriplet& M1 = *this; - const int m1 = M1.nrows_, nx = M1.ncols_, m2 = M2.nrows_; +#ifndef NDEBUG + const int nx = M1.ncols_, +#endif + const int m1 = M1.nrows_, m2 = M2.nrows_; assert(nx==M1.ncols_); assert(nx==M2.ncols_); assert(D.get_size() == nx); @@ -797,18 +805,20 @@ void hiopMatrixSparseTriplet::set_Jac_FR(const hiopMatrixSparse& Jac_c, const auto& J_d = dynamic_cast(Jac_d); // assuming original Jac is sorted! - int nnz_Jac_c = J_c.numberOfNonzeros(); - int nnz_Jac_d = J_d.numberOfNonzeros(); int m_c = J_c.m(); int m_d = J_d.m(); int n_c = J_c.n(); int n_d = J_d.n(); assert(n_c == n_d); +#ifndef NDEBUG + int nnz_Jac_c = J_c.numberOfNonzeros(); + int nnz_Jac_d = J_d.numberOfNonzeros(); int nnz_Jac_c_new = nnz_Jac_c + 2*m_c; int nnz_Jac_d_new = nnz_Jac_d + 2*m_d; assert(nnz_ == nnz_Jac_c_new + nnz_Jac_d_new); +#endif if(J_c.row_starts_ == nullptr){ J_c.row_starts_ = J_c.allocAndBuildRowStarts(); @@ -1046,8 +1056,10 @@ void hiopMatrixSparseTriplet::copySubmatrixFrom(const hiopMatrix& src_gen, const bool offdiag_only) { const hiopMatrixSparseTriplet& src = dynamic_cast(src_gen); +#ifndef NDEBUG auto m_rows = src.m(); auto n_cols = src.n(); +#endif assert(this->numberOfNonzeros() >= src.numberOfNonzeros()); assert(n_cols + dest_col_st <= this->n() ); @@ -1080,9 +1092,10 @@ void hiopMatrixSparseTriplet::copySubmatrixFromTrans(const hiopMatrix& src_gen, const bool offdiag_only) { const hiopMatrixSparseTriplet& src = dynamic_cast(src_gen); +#ifndef NDEBUG auto m_rows = src.n(); auto n_cols = src.m(); - +#endif assert(this->numberOfNonzeros() >= src.numberOfNonzeros()); assert(n_cols + dest_col_st <= this->n() ); assert(m_rows + dest_row_st <= this->m()); @@ -1354,9 +1367,10 @@ bool hiopMatrixSparseTriplet::is_diagonal() const void hiopMatrixSparseTriplet::extract_diagonal(hiopVector& diag_out) const { +#ifndef NDEBUG size_type vec_dim = diag_out.get_local_size(); assert( vec_dim == nrows_ && vec_dim == ncols_); - +#endif hiopVectorPar& vec = dynamic_cast(diag_out); double* v_data = vec.local_data(); @@ -1386,14 +1400,15 @@ void hiopMatrixSymSparseTriplet::set_Hess_FR(const hiopMatrixSparse& Hess, // assuming original Hess is sorted, and in upper-triangle format int m_h = Hess.m(); +#ifndef NDEBUG int n_h = Hess.n(); assert(n_h == m_h); +#endif // note that n_h can be zero, i.e., original hess is empty. // Hence we use add_diag.get_size() to detect the length of x in the base problem - int nnz_h_FR = add_diag.get_size() + Hess_base.numberOfOffDiagNonzeros() ; - - assert(nnz_ == nnz_h_FR); + int nnz_h_FR = add_diag.get_size() + Hess_base.numberOfOffDiagNonzeros(); + assert(nnz_ == nnz_h_FR); (void)nnz_h_FR; if(Hess_base.row_starts_ == nullptr){ Hess_base.row_starts_ = Hess_base.allocAndBuildRowStarts(); diff --git a/src/LinAlg/hiopVectorCompoundPD.cpp b/src/LinAlg/hiopVectorCompoundPD.cpp index 9f7d31fe5..e815273a1 100644 --- a/src/LinAlg/hiopVectorCompoundPD.cpp +++ b/src/LinAlg/hiopVectorCompoundPD.cpp @@ -956,7 +956,7 @@ void hiopVectorCompoundPD::print(FILE* file/*=nullptr*/, const char* msg/*=nullp int numranks = 1; MPI_Comm comm_ = MPI_COMM_SELF; if(rank>=0) { - int err = MPI_Comm_rank(comm_, &myrank_); assert(err==MPI_SUCCESS); + int err = MPI_Comm_rank(comm_, &myrank_); assert(err==MPI_SUCCESS); (void)err; err = MPI_Comm_size(comm_, &numranks); assert(err==MPI_SUCCESS); } #endif @@ -1008,6 +1008,7 @@ void hiopVectorCompoundPD::set_array_from_to(hiopInterfaceBase::NonlinearityType bool hiopVectorCompoundPD::is_equal(const hiopVector& vec) const { assert(0 && "not required."); + return false; } void hiopVectorCompoundPD::addVector(hiopVector *v) diff --git a/src/LinAlg/hiopVectorCuda.cpp b/src/LinAlg/hiopVectorCuda.cpp index 4584c697f..4267cf69d 100644 --- a/src/LinAlg/hiopVectorCuda.cpp +++ b/src/LinAlg/hiopVectorCuda.cpp @@ -86,7 +86,7 @@ hiopVectorCuda::hiopVectorCuda(const size_type& glob_n, index_type* col_part, MP int P = 0; if(col_part) { #ifdef HIOP_USE_MPI - int ierr=MPI_Comm_rank(comm_, &P); assert(ierr==MPI_SUCCESS); + int ierr=MPI_Comm_rank(comm_, &P); assert(MPI_SUCCESS==ierr); (void)ierr; #endif glob_il_ = col_part[P]; glob_iu_ = col_part[P+1]; @@ -98,8 +98,12 @@ hiopVectorCuda::hiopVectorCuda(const size_type& glob_n, index_type* col_part, MP n_local_ = glob_iu_ - glob_il_; data_ = exec_space_.alloc_array(n_local_); - // Create host mirror if the memory space is on device - data_host_mirror_ = exec_space_host_.alloc_array(n_local_); + if(exec_space_.mem_backend().is_device()) { + // Create host mirror if the memory space is on device + data_host_mirror_ = exec_space_host_.alloc_array(n_local_); + } else { + data_host_mirror_ = data_; + } // handles cublasCreate(&handle_cublas_); @@ -170,6 +174,7 @@ void hiopVectorCuda::copyFrom(const hiopVector& v_in) assert(v.n_local_ == n_local_); auto b = exec_space_.copy(data_, v.data_, n_local_, v.exec_space()); + (void)b; assert(b); } @@ -178,6 +183,7 @@ void hiopVectorCuda::copyFrom(const double* v_local_data) { if(v_local_data) { auto b = exec_space_.copy(data_, v_local_data, n_local_); + (void)b; assert(b); } } @@ -206,6 +212,7 @@ void hiopVectorCuda::copyFromStarting(int start_index_in_dest, const double* v, { assert(start_index_in_dest+nv <= n_local_); auto b = exec_space_.copy(data_+start_index_in_dest, v, nv); + (void)b; assert(b); } @@ -220,6 +227,7 @@ void hiopVectorCuda::copyFromStarting(int start_index_in_dest, const hiopVector& v.data_, v.n_local_, v.exec_space()); + (void)b; assert(b); } @@ -227,6 +235,7 @@ void hiopVectorCuda::copyFromStarting(int start_index_in_dest, const hiopVector& void hiopVectorCuda::copy_from_starting_at(const double* v, int start_index_in_v, int nv) { auto b = exec_space_.copy(data_, v+start_index_in_v, nv); + (void)b; assert(b); } @@ -281,6 +290,7 @@ void hiopVectorCuda::copyTo(double* dest) const auto* this_nonconst = const_cast(this); assert(nullptr != this_nonconst); auto b = this_nonconst->exec_space_.copy(dest, data_, n_local_); + (void)b; assert(b); } @@ -304,8 +314,10 @@ void hiopVectorCuda::copyToStarting(int start_index, hiopVector& dst) const /// @brief Copy `this` to `dst` starting at `start_index` in `dst`. void hiopVectorCuda::copyToStarting(hiopVector& dst, int start_index) const { +#ifndef NDEBUG int v_size = dst.get_local_size(); assert(start_index+n_local_ <= v_size); +#endif // If there is nothing to copy, return. if(n_local_ == 0) @@ -432,14 +444,14 @@ double hiopVectorCuda::twonorm() const int one = 1; double nrm = 0.; if(n_local_>0) { - cublasStatus_t ret_cublas = cublasDnrm2(handle_cublas_, n_local_, data_, one, &nrm); + cublasStatus_t ret_cublas = cublasDnrm2(handle_cublas_, n_local_, data_, one, &nrm); (void)ret_cublas; assert(ret_cublas == CUBLAS_STATUS_SUCCESS); } #ifdef HIOP_USE_MPI nrm *= nrm; double nrmG; - int ierr = MPI_Allreduce(&nrm, &nrmG, 1, MPI_DOUBLE, MPI_SUM, comm_); assert(MPI_SUCCESS==ierr); + int ierr = MPI_Allreduce(&nrm, &nrmG, 1, MPI_DOUBLE, MPI_SUM, comm_); assert(MPI_SUCCESS==ierr); (void)ierr; nrm = std::sqrt(nrmG); #endif return nrm; @@ -452,7 +464,7 @@ double hiopVectorCuda::infnorm() const #ifdef HIOP_USE_MPI double nrm_global; int ierr = MPI_Allreduce(&nrm, &nrm_global, 1, MPI_DOUBLE, MPI_MAX, comm_); - assert(MPI_SUCCESS==ierr); + assert(MPI_SUCCESS==ierr); (void)ierr; return nrm_global; #endif @@ -471,7 +483,7 @@ double hiopVectorCuda::onenorm() const double norm1 = onenorm_local(); #ifdef HIOP_USE_MPI double nrm1_global; - int ierr = MPI_Allreduce(&norm1, &nrm1_global, 1, MPI_DOUBLE, MPI_SUM, comm_); assert(MPI_SUCCESS==ierr); + int ierr = MPI_Allreduce(&norm1, &nrm1_global, 1, MPI_DOUBLE, MPI_SUM, comm_); assert(MPI_SUCCESS==ierr); (void)ierr; return nrm1_global; #endif return norm1; @@ -559,7 +571,7 @@ void hiopVectorCuda::component_sqrt() void hiopVectorCuda::scale(double alpha) { int one = 1; - cublasStatus_t ret_cublas = cublasDscal(handle_cublas_, n_local_, &alpha, data_, one); + cublasStatus_t ret_cublas = cublasDscal(handle_cublas_, n_local_, &alpha, data_, one); (void)ret_cublas; assert(ret_cublas == CUBLAS_STATUS_SUCCESS); } @@ -567,7 +579,7 @@ void hiopVectorCuda::scale(double alpha) void hiopVectorCuda::axpy(double alpha, const hiopVector& xvec) { int one = 1; - cublasStatus_t ret_cublas = cublasDaxpy(handle_cublas_, n_local_, &alpha, xvec.local_data_const(), one, data_, one); + cublasStatus_t ret_cublas = cublasDaxpy(handle_cublas_, n_local_, &alpha, xvec.local_data_const(), one, data_, one); (void)ret_cublas; assert(ret_cublas == CUBLAS_STATUS_SUCCESS); } @@ -658,13 +670,13 @@ double hiopVectorCuda::dotProductWith( const hiopVector& v ) const { int one = 1; double retval; - cublasStatus_t ret_cublas = cublasDdot(handle_cublas_, n_local_, v.local_data_const(), one, data_, one, &retval); + cublasStatus_t ret_cublas = cublasDdot(handle_cublas_, n_local_, v.local_data_const(), one, data_, one, &retval); (void)ret_cublas; assert(ret_cublas == CUBLAS_STATUS_SUCCESS); #ifdef HIOP_USE_MPI double dotprodG; int ierr = MPI_Allreduce(&retval, &dotprodG, 1, MPI_DOUBLE, MPI_SUM, comm_); - assert(MPI_SUCCESS==ierr); + assert(MPI_SUCCESS==ierr); (void)ierr; retval = dotprodG; #endif @@ -762,7 +774,7 @@ int hiopVectorCuda::allPositive() #ifdef HIOP_USE_MPI int allPosG; - int ierr=MPI_Allreduce(&allPos, &allPosG, 1, MPI_INT, MPI_MIN, comm_); assert(MPI_SUCCESS==ierr); + int ierr=MPI_Allreduce(&allPos, &allPosG, 1, MPI_INT, MPI_MIN, comm_); assert(MPI_SUCCESS==ierr); (void)ierr; return allPosG; #endif return allPos; @@ -785,7 +797,7 @@ int hiopVectorCuda::allPositive_w_patternSelect(const hiopVector& wvec) #ifdef HIOP_USE_MPI int allPosG; int ierr = MPI_Allreduce(&allPos, &allPosG, 1, MPI_INT, MPI_MIN, comm_); - assert(MPI_SUCCESS==ierr); + assert(MPI_SUCCESS==ierr); (void)ierr; return allPosG; #endif return allPos; @@ -798,7 +810,7 @@ double hiopVectorCuda::min() const #ifdef HIOP_USE_MPI double resultG; - double ierr=MPI_Allreduce(&result, &resultG, 1, MPI_DOUBLE, MPI_MIN, comm_); assert(MPI_SUCCESS==ierr); + double ierr=MPI_Allreduce(&result, &resultG, 1, MPI_DOUBLE, MPI_MIN, comm_); assert(MPI_SUCCESS==ierr); (void)ierr; return resultG; #endif return result; @@ -816,7 +828,7 @@ double hiopVectorCuda::min_w_pattern(const hiopVector& select) const #ifdef HIOP_USE_MPI double resultG; - double ierr=MPI_Allreduce(&result, &resultG, 1, MPI_DOUBLE, MPI_MIN, comm_); assert(MPI_SUCCESS==ierr); + double ierr=MPI_Allreduce(&result, &resultG, 1, MPI_DOUBLE, MPI_MIN, comm_); assert(MPI_SUCCESS==ierr); (void)ierr; return resultG; #endif return result; @@ -928,7 +940,7 @@ bool hiopVectorCuda::matchesPattern(const hiopVector& pattern) #ifdef HIOP_USE_MPI int mismatch_glob = bret; int ierr = MPI_Allreduce(&bret, &mismatch_glob, 1, MPI_INT, MPI_MIN, comm_); - assert(MPI_SUCCESS==ierr); + assert(MPI_SUCCESS==ierr); (void)ierr; return (mismatch_glob != 0); #endif return bret; @@ -1085,6 +1097,7 @@ void hiopVectorCuda::set_array_from_to(hiopInterfaceBase::NonlinearityType* arr, bool hiopVectorCuda::is_equal(const hiopVector& vec) const { assert(false&&"NOT needed. Remove this func. TODO"); + return false; } diff --git a/src/LinAlg/hiopVectorHip.cpp b/src/LinAlg/hiopVectorHip.cpp index d55f2d421..620c1140e 100644 --- a/src/LinAlg/hiopVectorHip.cpp +++ b/src/LinAlg/hiopVectorHip.cpp @@ -86,7 +86,7 @@ hiopVectorHip::hiopVectorHip(const size_type& glob_n, index_type* col_part, MPI_ int P = 0; if(col_part) { #ifdef HIOP_USE_MPI - int ierr=MPI_Comm_rank(comm_, &P); assert(ierr==MPI_SUCCESS); + int ierr=MPI_Comm_rank(comm_, &P); assert(MPI_SUCCESS==ierr); (void)ierr; #endif glob_il_ = col_part[P]; glob_iu_ = col_part[P+1]; @@ -174,6 +174,7 @@ void hiopVectorHip::copyFrom(const hiopVector& v_in) assert(v.n_local_ == n_local_); auto b = exec_space_.copy(data_, v.data_, n_local_, v.exec_space()); + (void)b; assert(b); } @@ -182,6 +183,7 @@ void hiopVectorHip::copyFrom(const double* v_local_data) { if(v_local_data) { auto b = exec_space_.copy(data_, v_local_data, n_local_); + (void)b; assert(b); } } @@ -210,6 +212,7 @@ void hiopVectorHip::copyFromStarting(int start_index_in_dest, const double* v, i { assert(start_index_in_dest+nv <= n_local_); auto b = exec_space_.copy(data_+start_index_in_dest, v, nv); + (void)b; assert(b); } @@ -218,11 +221,13 @@ void hiopVectorHip::copyFromStarting(int start_index_in_dest, const hiopVector& { assert(n_local_==n_ && "only for local/non-distributed vectors"); assert(start_index_in_dest+v_src.get_local_size() <= n_local_); + const hiopVectorHip& v = dynamic_cast(v_src); auto b = exec_space_.copy(data_+start_index_in_dest, v.data_, v.n_local_, v.exec_space()); + (void)b; assert(b); } @@ -230,6 +235,7 @@ void hiopVectorHip::copyFromStarting(int start_index_in_dest, const hiopVector& void hiopVectorHip::copy_from_starting_at(const double* v, int start_index_in_v, int nv) { auto b = exec_space_.copy(data_, v+start_index_in_v, nv); + (void)b; assert(b); } @@ -284,6 +290,7 @@ void hiopVectorHip::copyTo(double* dest) const auto* this_nonconst = const_cast(this); assert(nullptr != this_nonconst); auto b = this_nonconst->exec_space_.copy(dest, data_, n_local_); + (void)b; assert(b); } @@ -307,8 +314,10 @@ void hiopVectorHip::copyToStarting(int start_index, hiopVector& dst) const /// @brief Copy 'this' to dst starting at start_index in 'dst'. void hiopVectorHip::copyToStarting(hiopVector& dst, int start_index) const { +#ifndef NDEBUG int v_size = dst.get_local_size(); assert(start_index+n_local_ <= v_size); +#endif // If there is nothing to copy, return. if(n_local_ == 0) @@ -436,14 +445,14 @@ double hiopVectorHip::twonorm() const int one = 1; double nrm = 0.; if(n_local_>0) { - hipblasStatus_t ret_hipblas = hipblasDnrm2(handle_hipblas_, n_local_, data_, one, &nrm); + hipblasStatus_t ret_hipblas = hipblasDnrm2(handle_hipblas_, n_local_, data_, one, &nrm); (void)ret_hipblas; assert(ret_hipblas == HIPBLAS_STATUS_SUCCESS); } #ifdef HIOP_USE_MPI nrm *= nrm; double nrmG; - int ierr = MPI_Allreduce(&nrm, &nrmG, 1, MPI_DOUBLE, MPI_SUM, comm_); assert(MPI_SUCCESS==ierr); + int ierr = MPI_Allreduce(&nrm, &nrmG, 1, MPI_DOUBLE, MPI_SUM, comm_); assert(MPI_SUCCESS==ierr); (void)ierr; nrm = std::sqrt(nrmG); #endif return nrm; @@ -456,7 +465,7 @@ double hiopVectorHip::infnorm() const #ifdef HIOP_USE_MPI double nrm_global; int ierr = MPI_Allreduce(&nrm, &nrm_global, 1, MPI_DOUBLE, MPI_MAX, comm_); - assert(MPI_SUCCESS==ierr); + assert(MPI_SUCCESS==ierr); (void)ierr; return nrm_global; #endif @@ -475,7 +484,7 @@ double hiopVectorHip::onenorm() const double norm1 = onenorm_local(); #ifdef HIOP_USE_MPI double nrm1_global; - int ierr = MPI_Allreduce(&norm1, &nrm1_global, 1, MPI_DOUBLE, MPI_SUM, comm_); assert(MPI_SUCCESS==ierr); + int ierr = MPI_Allreduce(&norm1, &nrm1_global, 1, MPI_DOUBLE, MPI_SUM, comm_); assert(MPI_SUCCESS==ierr); (void)ierr; return nrm1_global; #endif return norm1; @@ -563,7 +572,7 @@ void hiopVectorHip::component_sqrt() void hiopVectorHip::scale(double alpha) { int one = 1; - hipblasStatus_t ret_hipblas = hipblasDscal(handle_hipblas_, n_local_, &alpha, data_, one); + hipblasStatus_t ret_hipblas = hipblasDscal(handle_hipblas_, n_local_, &alpha, data_, one); (void)ret_hipblas; assert(ret_hipblas == HIPBLAS_STATUS_SUCCESS); } @@ -571,7 +580,7 @@ void hiopVectorHip::scale(double alpha) void hiopVectorHip::axpy(double alpha, const hiopVector& xvec) { int one = 1; - hipblasStatus_t ret_hipblas = hipblasDaxpy(handle_hipblas_, n_local_, &alpha, xvec.local_data_const(), one, data_, one); + hipblasStatus_t ret_hipblas = hipblasDaxpy(handle_hipblas_, n_local_, &alpha, xvec.local_data_const(), one, data_, one); (void)ret_hipblas; assert(ret_hipblas == HIPBLAS_STATUS_SUCCESS); } @@ -662,13 +671,13 @@ double hiopVectorHip::dotProductWith( const hiopVector& v ) const { int one = 1; double retval; - hipblasStatus_t ret_hipblas = hipblasDdot(handle_hipblas_, n_local_, v.local_data_const(), one, data_, one, &retval); + hipblasStatus_t ret_hipblas = hipblasDdot(handle_hipblas_, n_local_, v.local_data_const(), one, data_, one, &retval); (void)ret_hipblas; assert(ret_hipblas == HIPBLAS_STATUS_SUCCESS); #ifdef HIOP_USE_MPI double dotprodG; int ierr = MPI_Allreduce(&retval, &dotprodG, 1, MPI_DOUBLE, MPI_SUM, comm_); - assert(MPI_SUCCESS==ierr); + assert(MPI_SUCCESS==ierr); (void)ierr; retval = dotprodG; #endif @@ -766,7 +775,7 @@ int hiopVectorHip::allPositive() #ifdef HIOP_USE_MPI int allPosG; - int ierr=MPI_Allreduce(&allPos, &allPosG, 1, MPI_INT, MPI_MIN, comm_); assert(MPI_SUCCESS==ierr); + int ierr=MPI_Allreduce(&allPos, &allPosG, 1, MPI_INT, MPI_MIN, comm_); assert(MPI_SUCCESS==ierr); (void)ierr; return allPosG; #endif return allPos; @@ -789,7 +798,7 @@ int hiopVectorHip::allPositive_w_patternSelect(const hiopVector& wvec) #ifdef HIOP_USE_MPI int allPosG; int ierr = MPI_Allreduce(&allPos, &allPosG, 1, MPI_INT, MPI_MIN, comm_); - assert(MPI_SUCCESS==ierr); + assert(MPI_SUCCESS==ierr); (void)ierr; return allPosG; #endif return allPos; @@ -802,7 +811,7 @@ double hiopVectorHip::min() const #ifdef HIOP_USE_MPI double resultG; - double ierr=MPI_Allreduce(&result, &resultG, 1, MPI_DOUBLE, MPI_MIN, comm_); assert(MPI_SUCCESS==ierr); + double ierr=MPI_Allreduce(&result, &resultG, 1, MPI_DOUBLE, MPI_MIN, comm_); assert(MPI_SUCCESS==ierr); (void)ierr; return resultG; #endif return result; @@ -820,7 +829,7 @@ double hiopVectorHip::min_w_pattern(const hiopVector& select) const #ifdef HIOP_USE_MPI double resultG; - double ierr=MPI_Allreduce(&result, &resultG, 1, MPI_DOUBLE, MPI_MIN, comm_); assert(MPI_SUCCESS==ierr); + double ierr=MPI_Allreduce(&result, &resultG, 1, MPI_DOUBLE, MPI_MIN, comm_); assert(MPI_SUCCESS==ierr); (void)ierr; return resultG; #endif return result; @@ -932,7 +941,7 @@ bool hiopVectorHip::matchesPattern(const hiopVector& pattern) #ifdef HIOP_USE_MPI int mismatch_glob = bret; int ierr = MPI_Allreduce(&bret, &mismatch_glob, 1, MPI_INT, MPI_MIN, comm_); - assert(MPI_SUCCESS==ierr); + assert(MPI_SUCCESS==ierr); (void)ierr; return (mismatch_glob != 0); #endif return bret; @@ -1089,6 +1098,7 @@ void hiopVectorHip::set_array_from_to(hiopInterfaceBase::NonlinearityType* arr, bool hiopVectorHip::is_equal(const hiopVector& vec) const { assert(false&&"NOT needed. Remove this func. TODO"); + return false; } diff --git a/src/LinAlg/hiopVectorIntCuda.cpp b/src/LinAlg/hiopVectorIntCuda.cpp index f76b8285e..f1bb4f0dc 100644 --- a/src/LinAlg/hiopVectorIntCuda.cpp +++ b/src/LinAlg/hiopVectorIntCuda.cpp @@ -52,14 +52,13 @@ * */ #include "hiopVectorIntCuda.hpp" +#include "hiopVectorIntSeq.hpp" #include "MemBackendCudaImpl.hpp" #include "MemBackendCppImpl.hpp" #include "VectorCudaKernels.hpp" #include - -#include "hiopVectorIntSeq.hpp" #include namespace hiop @@ -92,6 +91,7 @@ void hiopVectorIntCuda::copy_from_vectorseq(const hiopVectorIntSeq& src) { assert(src.get_local_size() == sz_); auto b = exec_space_.copy(buf_, src.local_data_const(), sz_, src.exec_space()); + (void)b; assert(b); } @@ -99,12 +99,14 @@ void hiopVectorIntCuda::copy_to_vectorseq(hiopVectorIntSeq& dest) const { assert(dest.get_local_size() == sz_); auto b = dest.exec_space().copy(dest.local_data(), buf_, sz_, exec_space_); + (void)b; assert(b); } void hiopVectorIntCuda::set_to_zero() { cudaError_t cuerr = cudaMemset(buf_, 0, sz_); + (void)cuerr; assert(cuerr == cudaSuccess); } @@ -112,6 +114,7 @@ void hiopVectorIntCuda::set_to_zero() void hiopVectorIntCuda::set_to_constant(const index_type c) { cudaError_t cuerr = cudaMemset(buf_, c, sz_); + (void)cuerr; assert(cuerr == cudaSuccess); } diff --git a/src/LinAlg/hiopVectorIntHip.cpp b/src/LinAlg/hiopVectorIntHip.cpp index 48fd6a89e..108b8210a 100644 --- a/src/LinAlg/hiopVectorIntHip.cpp +++ b/src/LinAlg/hiopVectorIntHip.cpp @@ -91,6 +91,7 @@ void hiopVectorIntHip::copy_from_vectorseq(const hiopVectorIntSeq& src) { assert(src.get_local_size() == sz_); auto b = exec_space_.copy(buf_, src.local_data_const(), sz_, src.exec_space()); + (void)b; assert(b); } @@ -98,12 +99,14 @@ void hiopVectorIntHip::copy_to_vectorseq(hiopVectorIntSeq& dest) const { assert(dest.get_local_size() == sz_); auto b = dest.exec_space().copy(dest.local_data(), buf_, sz_, exec_space_); + (void)b; assert(b); } void hiopVectorIntHip::set_to_zero() { hipError_t cuerr = hipMemset(buf_, 0, sz_); + (void)cuerr; assert(cuerr == hipSuccess); } @@ -112,6 +115,7 @@ void hiopVectorIntHip::set_to_constant(const index_type c) { hipError_t cuerr = hipMemset(buf_, c, sz_); assert(cuerr == hipSuccess); + (void)cuerr; } /** diff --git a/src/LinAlg/hiopVectorPar.cpp b/src/LinAlg/hiopVectorPar.cpp index d3587e22f..2013bb5c8 100644 --- a/src/LinAlg/hiopVectorPar.cpp +++ b/src/LinAlg/hiopVectorPar.cpp @@ -78,7 +78,7 @@ hiopVectorPar::hiopVectorPar(const size_type& glob_n, index_type* col_part/*=NUL int P=0; if(col_part) { #ifdef HIOP_USE_MPI - int ierr=MPI_Comm_rank(comm_, &P); assert(ierr==MPI_SUCCESS); + int ierr=MPI_Comm_rank(comm_, &P); assert(MPI_SUCCESS==ierr); (void)ierr; #endif glob_il_=col_part[P]; glob_iu_=col_part[P+1]; } else { @@ -199,7 +199,9 @@ void hiopVectorPar::copy_from_indexes(const hiopVector& vv, const hiopVectorInt& assert(indexes.get_local_size() == n_local_); const index_type* index_arr = indexes.local_data_const(); +#ifndef NDEBUG size_type nv = v.get_local_size(); +#endif for(index_type i=0; idata_[i] = v.data_[index_arr[i]]; @@ -471,7 +473,7 @@ double hiopVectorPar::twonorm() const #ifdef HIOP_USE_MPI nrm *= nrm; double nrmG; - int ierr = MPI_Allreduce(&nrm, &nrmG, 1, MPI_DOUBLE, MPI_SUM, comm_); assert(MPI_SUCCESS==ierr); + int ierr = MPI_Allreduce(&nrm, &nrmG, 1, MPI_DOUBLE, MPI_SUM, comm_); assert(MPI_SUCCESS==ierr); (void)ierr; nrm=sqrt(nrmG); #endif return nrm; @@ -491,7 +493,7 @@ double hiopVectorPar::dotProductWith(const hiopVector& v_) const } #ifdef HIOP_USE_MPI double dotprodG; - int ierr = MPI_Allreduce(&dotprod, &dotprodG, 1, MPI_DOUBLE, MPI_SUM, comm_); assert(MPI_SUCCESS==ierr); + int ierr = MPI_Allreduce(&dotprod, &dotprodG, 1, MPI_DOUBLE, MPI_SUM, comm_); assert(MPI_SUCCESS==ierr); (void)ierr; dotprod=dotprodG; #endif @@ -513,7 +515,7 @@ double hiopVectorPar::infnorm() const } #ifdef HIOP_USE_MPI double nrm_glob; - int ierr = MPI_Allreduce(&nrm, &nrm_glob, 1, MPI_DOUBLE, MPI_MAX, comm_); assert(MPI_SUCCESS==ierr); + int ierr = MPI_Allreduce(&nrm, &nrm_glob, 1, MPI_DOUBLE, MPI_MAX, comm_); assert(MPI_SUCCESS==ierr); (void)ierr; return nrm_glob; #endif @@ -546,7 +548,7 @@ double hiopVectorPar::onenorm() const #ifdef HIOP_USE_MPI double nrm1_global; int ierr = MPI_Allreduce(&nrm1, &nrm1_global, 1, MPI_DOUBLE, MPI_SUM, comm_); - assert(MPI_SUCCESS==ierr); + assert(MPI_SUCCESS==ierr); (void)ierr; return nrm1_global; #endif return nrm1; @@ -812,7 +814,7 @@ double hiopVectorPar::min() const #ifdef HIOP_USE_MPI double ret_val_g; int ierr=MPI_Allreduce(&ret_val, &ret_val_g, 1, MPI_DOUBLE, MPI_MIN, comm_); - assert(MPI_SUCCESS==ierr); + assert(MPI_SUCCESS==ierr); (void)ierr; ret_val = ret_val_g; #endif return ret_val; @@ -832,7 +834,7 @@ double hiopVectorPar::min_w_pattern(const hiopVector& select) const } #ifdef HIOP_USE_MPI double ret_val_g; - int ierr=MPI_Allreduce(&ret_val, &ret_val_g, 1, MPI_DOUBLE, MPI_MIN, comm_); assert(MPI_SUCCESS==ierr); + int ierr=MPI_Allreduce(&ret_val, &ret_val_g, 1, MPI_DOUBLE, MPI_MIN, comm_); assert(MPI_SUCCESS==ierr); (void)ierr; ret_val = ret_val_g; #endif return ret_val; @@ -955,7 +957,7 @@ int hiopVectorPar::allPositive() #ifdef HIOP_USE_MPI int allPosG; - int ierr=MPI_Allreduce(&allPos, &allPosG, 1, MPI_INT, MPI_MIN, comm_); assert(MPI_SUCCESS==ierr); + int ierr=MPI_Allreduce(&allPos, &allPosG, 1, MPI_INT, MPI_MIN, comm_); assert(MPI_SUCCESS==ierr); (void)ierr; return allPosG; #endif return allPos; @@ -1086,7 +1088,7 @@ bool hiopVectorPar::matchesPattern(const hiopVector& ix_) #ifdef HIOP_USE_MPI int bmatches_glob=bmatches; int ierr=MPI_Allreduce(&bmatches, &bmatches_glob, 1, MPI_INT, MPI_LAND, comm_); - assert(MPI_SUCCESS==ierr); + assert(MPI_SUCCESS==ierr); (void)ierr; return bmatches_glob; #endif return bmatches; @@ -1108,7 +1110,7 @@ int hiopVectorPar::allPositive_w_patternSelect(const hiopVector& w_) #ifdef HIOP_USE_MPI int allPosG=allPos; int ierr = MPI_Allreduce(&allPos, &allPosG, 1, MPI_INT, MPI_MIN, comm_); - assert(MPI_SUCCESS==ierr); + assert(MPI_SUCCESS==ierr); (void)ierr; return allPosG; #endif return allPos; @@ -1158,7 +1160,7 @@ bool hiopVectorPar::is_zero() const } #ifdef HIOP_USE_MPI int all_zero_G; - int ierr=MPI_Allreduce(&all_zero, &all_zero_G, 1, MPI_INT, MPI_MIN, comm_); assert(MPI_SUCCESS==ierr); + int ierr=MPI_Allreduce(&all_zero, &all_zero_G, 1, MPI_INT, MPI_MIN, comm_); assert(MPI_SUCCESS==ierr); (void)ierr; return all_zero_G; #endif return all_zero; @@ -1192,7 +1194,7 @@ void hiopVectorPar::print(FILE* file/*=nullptr*/, const char* msg/*=nullptr*/, i #ifdef HIOP_USE_MPI if(rank>=0) { - int err = MPI_Comm_rank(comm_, &myrank_); assert(err==MPI_SUCCESS); + int err = MPI_Comm_rank(comm_, &myrank_); assert(err==MPI_SUCCESS); (void)err; err = MPI_Comm_size(comm_, &numranks); assert(err==MPI_SUCCESS); } #endif @@ -1231,7 +1233,7 @@ size_type hiopVectorPar::numOfElemsLessThan(const double &val) const #ifdef HIOP_USE_MPI size_type ret_num_global; int ierr = MPI_Allreduce(&ret_num, &ret_num_global, 1, MPI_HIOP_SIZE_TYPE, MPI_SUM, comm_); - assert(MPI_SUCCESS==ierr); + assert(MPI_SUCCESS==ierr); (void)ierr; ret_num = ret_num_global; #endif @@ -1250,7 +1252,7 @@ size_type hiopVectorPar::numOfElemsAbsLessThan(const double &val) const #ifdef HIOP_USE_MPI size_type ret_num_global; int ierr=MPI_Allreduce(&ret_num, &ret_num_global, 1, MPI_HIOP_SIZE_TYPE, MPI_SUM, comm_); - assert(MPI_SUCCESS==ierr); + assert(MPI_SUCCESS==ierr); (void)ierr; ret_num = ret_num_global; #endif @@ -1300,7 +1302,7 @@ bool hiopVectorPar::is_equal(const hiopVector& vec) const #ifdef HIOP_USE_MPI int all_equalG; - int ierr=MPI_Allreduce(&all_equal, &all_equalG, 1, MPI_INT, MPI_MIN, comm_); assert(MPI_SUCCESS==ierr); + int ierr=MPI_Allreduce(&all_equal, &all_equalG, 1, MPI_INT, MPI_MIN, comm_); assert(MPI_SUCCESS==ierr); (void)ierr; return all_equalG; #endif return all_equal; diff --git a/src/LinAlg/hiopVectorRajaImpl.hpp b/src/LinAlg/hiopVectorRajaImpl.hpp index f1a950226..0af82b48e 100644 --- a/src/LinAlg/hiopVectorRajaImpl.hpp +++ b/src/LinAlg/hiopVectorRajaImpl.hpp @@ -114,7 +114,7 @@ hiopVectorRaja(const size_type& glob_n, if(col_part) { #ifdef HIOP_USE_MPI - int ierr=MPI_Comm_rank(comm_, &P); assert(ierr==MPI_SUCCESS); + int ierr=MPI_Comm_rank(comm_, &P); assert(MPI_SUCCESS==ierr); (void)ierr; #endif glob_il_ = col_part[P]; glob_iu_ = col_part[P+1]; @@ -329,8 +329,10 @@ void hiopVectorRaja::copy_from_indexes(const hiopVector& vv, const hio double* dd = data_dev_; double* vd = v.data_dev_; +#ifndef NDEBUG size_type nv = v.get_local_size(); - +#endif + RAJA::forall< hiop_raja_exec >(RAJA::RangeSegment(0, n_local_), RAJA_LAMBDA(RAJA::Index_type i) { @@ -568,7 +570,9 @@ copyToStartingAt_w_pattern(hiopVector& vec, int start_index_in_dest, const hiopV } index_type* nnz_cumsum = idx_cumsum_->local_data(); +#ifndef NDEBUG index_type v_n_local = v.n_local_; +#endif RAJA::forall( RAJA::RangeSegment(1, n_local_+1), RAJA_LAMBDA(RAJA::Index_type i) @@ -829,7 +833,7 @@ double hiopVectorRaja::twonorm() const #ifdef HIOP_USE_MPI double nrm_global; int ierr = MPI_Allreduce(&nrm, &nrm_global, 1, MPI_DOUBLE, MPI_SUM, comm_); - assert(MPI_SUCCESS == ierr); + assert(MPI_SUCCESS==ierr); (void)ierr; return std::sqrt(nrm_global); #endif return std::sqrt(nrm); @@ -863,7 +867,7 @@ double hiopVectorRaja::dotProductWith(const hiopVector& vec) const #ifdef HIOP_USE_MPI double dotprodG; int ierr = MPI_Allreduce(&dotprod, &dotprodG, 1, MPI_DOUBLE, MPI_SUM, comm_); - assert(MPI_SUCCESS==ierr); + assert(MPI_SUCCESS==ierr); (void)ierr; dotprod=dotprodG; #endif @@ -883,7 +887,7 @@ double hiopVectorRaja::infnorm() const #ifdef HIOP_USE_MPI double nrm_global; int ierr = MPI_Allreduce(&nrm, &nrm_global, 1, MPI_DOUBLE, MPI_MAX, comm_); - assert(MPI_SUCCESS==ierr); + assert(MPI_SUCCESS==ierr); (void)ierr; return nrm_global; #endif @@ -923,7 +927,7 @@ double hiopVectorRaja::onenorm() const double norm1 = onenorm_local(); #ifdef HIOP_USE_MPI double nrm1_global; - int ierr = MPI_Allreduce(&norm1, &nrm1_global, 1, MPI_DOUBLE, MPI_SUM, comm_); assert(MPI_SUCCESS==ierr); + int ierr = MPI_Allreduce(&norm1, &nrm1_global, 1, MPI_DOUBLE, MPI_SUM, comm_); assert(MPI_SUCCESS==ierr); (void)ierr; return nrm1_global; #endif return norm1; @@ -1216,8 +1220,9 @@ void hiopVectorRaja::axpy(double alpha, const hiopVector& xvec, const double* dd = data_dev_; double* xd = const_cast(x.data_dev_); index_type* id = const_cast(idxs.local_data_const()); +#ifndef NDEBUG auto tmp_n_local = n_local_; - +#endif RAJA::forall< hiop_raja_exec >( RAJA::RangeSegment(0, n_local_), RAJA_LAMBDA(RAJA::Index_type i) { @@ -1384,7 +1389,7 @@ double hiopVectorRaja::min() const #ifdef HIOP_USE_MPI double ret_val_g; - int ierr=MPI_Allreduce(&ret_val, &ret_val_g, 1, MPI_DOUBLE, MPI_MIN, comm_); assert(MPI_SUCCESS==ierr); + int ierr=MPI_Allreduce(&ret_val, &ret_val_g, 1, MPI_DOUBLE, MPI_MIN, comm_); assert(MPI_SUCCESS==ierr); (void)ierr; ret_val = ret_val_g; #endif return ret_val; @@ -1413,7 +1418,7 @@ double hiopVectorRaja::min_w_pattern(const hiopVector& select) const #ifdef HIOP_USE_MPI double ret_val_g; - int ierr=MPI_Allreduce(&ret_val, &ret_val_g, 1, MPI_DOUBLE, MPI_MIN, comm_); assert(MPI_SUCCESS==ierr); + int ierr=MPI_Allreduce(&ret_val, &ret_val_g, 1, MPI_DOUBLE, MPI_MIN, comm_); assert(MPI_SUCCESS==ierr); (void)ierr; ret_val = ret_val_g; #endif return ret_val; @@ -1630,7 +1635,7 @@ int hiopVectorRaja::allPositive() #ifdef HIOP_USE_MPI int allPosG; - int ierr=MPI_Allreduce(&allPos, &allPosG, 1, MPI_INT, MPI_MIN, comm_); assert(MPI_SUCCESS==ierr); + int ierr=MPI_Allreduce(&allPos, &allPosG, 1, MPI_INT, MPI_MIN, comm_); assert(MPI_SUCCESS==ierr); (void)ierr; return allPosG; #endif return allPos; @@ -1851,7 +1856,7 @@ bool hiopVectorRaja::matchesPattern(const hiopVector& pattern) #ifdef HIOP_USE_MPI int mismatch_glob = mismatch; int ierr = MPI_Allreduce(&mismatch, &mismatch_glob, 1, MPI_INT, MPI_SUM, comm_); - assert(MPI_SUCCESS==ierr); + assert(MPI_SUCCESS==ierr); (void)ierr; return (mismatch_glob == 0); #endif return (mismatch == 0); @@ -1887,7 +1892,7 @@ int hiopVectorRaja::allPositive_w_patternSelect(const hiopVector& sele #ifdef HIOP_USE_MPI int allPosG; int ierr = MPI_Allreduce(&allPos, &allPosG, 1, MPI_INT, MPI_MIN, comm_); - assert(MPI_SUCCESS==ierr); + assert(MPI_SUCCESS==ierr); (void)ierr; return allPosG; #endif return allPos; @@ -1964,7 +1969,7 @@ bool hiopVectorRaja::is_zero() const #ifdef HIOP_USE_MPI int all_zero_G; - int ierr=MPI_Allreduce(&all_zero, &all_zero_G, 1, MPI_INT, MPI_MIN, comm_); assert(MPI_SUCCESS==ierr); + int ierr=MPI_Allreduce(&all_zero, &all_zero_G, 1, MPI_INT, MPI_MIN, comm_); assert(MPI_SUCCESS==ierr); (void)ierr; return all_zero_G; #endif return all_zero; @@ -2045,7 +2050,7 @@ print(FILE* file, const char* msg/*=NULL*/, int max_elems/*=-1*/, int rank/*=-1* int myrank=0, numranks=1; #ifdef HIOP_USE_MPI if(rank >= 0) { - int err = MPI_Comm_rank(comm_, &myrank); assert(err==MPI_SUCCESS); + int err = MPI_Comm_rank(comm_, &myrank); assert(err==MPI_SUCCESS); (void)err; err = MPI_Comm_size(comm_, &numranks); assert(err==MPI_SUCCESS); } #endif @@ -2129,7 +2134,7 @@ size_type hiopVectorRaja::numOfElemsLessThan(const double &val) const #ifdef HIOP_USE_MPI size_type nrm_global; int ierr = MPI_Allreduce(&nrm, &nrm_global, 1, MPI_HIOP_SIZE_TYPE, MPI_SUM, comm_); - assert(MPI_SUCCESS == ierr); + assert(MPI_SUCCESS==ierr); (void)ierr; nrm = nrm_global; #endif @@ -2152,7 +2157,7 @@ size_type hiopVectorRaja::numOfElemsAbsLessThan(const double &val) con #ifdef HIOP_USE_MPI size_type nrm_global; int ierr = MPI_Allreduce(&nrm, &nrm_global, 1, MPI_HIOP_SIZE_TYPE, MPI_SUM, comm_); - assert(MPI_SUCCESS == ierr); + assert(MPI_SUCCESS==ierr); (void)ierr; nrm = nrm_global; #endif @@ -2207,7 +2212,7 @@ template bool hiopVectorRaja::is_equal(const hiopVector& vec) const { #ifdef HIOP_DEEPCHECKS - const hiopVectorRaja& v = dynamic_cast&>(vec); + const hiopVectorRaja& v = dynamic_cast&>(vec); (void)v; assert(v.n_local_ == n_local_); #endif @@ -2226,7 +2231,7 @@ bool hiopVectorRaja::is_equal(const hiopVector& vec) const #ifdef HIOP_USE_MPI int all_equalG; int ierr = MPI_Allreduce(&all_equal, &all_equalG, 1, MPI_INT, MPI_MIN, comm_); - assert(MPI_SUCCESS==ierr); + assert(MPI_SUCCESS==ierr); (void)ierr; return all_equalG; #endif return all_equal; diff --git a/src/Optimization/hiopAlgFilterIPM.cpp b/src/Optimization/hiopAlgFilterIPM.cpp index d3bbee0a8..aaa91d1ec 100644 --- a/src/Optimization/hiopAlgFilterIPM.cpp +++ b/src/Optimization/hiopAlgFilterIPM.cpp @@ -601,7 +601,7 @@ bool hiopAlgFilterIPMBase::update_log_barrier_params(hiopIterate& it, // adjust duals bool bret = it.adjustDuals_primalLogHessian(mu_new,kappa_Sigma); - assert(bret); + assert(bret); (void)bret; } } //compute infeasibility theta at trial point, since slacks and/or bounds are modified @@ -1170,7 +1170,7 @@ hiopSolveStatus hiopAlgFilterIPMQuasiNewton::run() } } else { auto* fact_acceptor_dwd = dynamic_cast (fact_acceptor_); - assert(fact_acceptor_dwd); + assert(fact_acceptor_dwd); (void)fact_acceptor_dwd; //compute_search_direction call below updates linsol safe mode flag and linsol_safe_mode_lastiter if(!compute_search_direction_inertia_free(kkt, linsol_safe_mode_on, linsol_forcequick, iter_num)) { //it failed under safe mode @@ -2135,7 +2135,7 @@ hiopSolveStatus hiopAlgFilterIPMNewton::run() } } else { auto* fact_acceptor_dwd = dynamic_cast (fact_acceptor_); - assert(fact_acceptor_dwd); + assert(fact_acceptor_dwd); (void)fact_acceptor_dwd; bool linsol_safe_mode_on_before = linsol_safe_mode_on; //compute_search_direction call below updates linsol safe mode flag and linsol_safe_mode_lastiter if(!compute_search_direction_inertia_free(kkt, linsol_safe_mode_on, linsol_forcequick, iter_num)) { @@ -2623,7 +2623,7 @@ int hiopAlgFilterIPMBase::apply_second_order_correction(hiopKKTLinSys* kkt, double alpha_dual_soc = alpha_primal_soc; int num_soc = 0; - bool bret = true; + bool bret = true; (void)bret; int ls_status = 0; // set initial c/d for soc @@ -2704,7 +2704,7 @@ bool hiopAlgFilterIPMBase::apply_feasibility_restoration(hiopKKTLinSys* kkt) if (nlpMDS == nullptr) { hiopNlpSparse* nlpSp = dynamic_cast(nlp); if(nullptr == nlpSp) { - hiopNlpDenseConstraints* nlpD = dynamic_cast(nlp); + hiopNlpDenseConstraints* nlpD = dynamic_cast(nlp); (void)nlpD; assert(nlpD && "Unkown system is provided. Please pick one from Dense, Sparse or MDS. "); // this is Dense system hiopFRProbDense nlp_fr_interface(*this); @@ -2848,7 +2848,7 @@ bool hiopAlgFilterIPMBase::reset_var_from_fr_sol(hiopKKTLinSys* kkt, bool reset_ double alpha_primal_temp = 1.0; double alpha_dual_temp = 1.0; bool bret = it_curr->fractionToTheBdry(*dir, _tau, alpha_primal_temp, alpha_dual_temp); - assert(bret); + assert(bret); (void)bret; it_trial->takeStep_duals(*it_curr, *dir, alpha_primal_temp, alpha_dual_temp); diff --git a/src/Optimization/hiopAlgPrimalDecomp.cpp b/src/Optimization/hiopAlgPrimalDecomp.cpp index 9b3eea835..234aa873c 100644 --- a/src/Optimization/hiopAlgPrimalDecomp.cpp +++ b/src/Optimization/hiopAlgPrimalDecomp.cpp @@ -87,7 +87,7 @@ namespace hiop { int mpi_test_flag; MPI_Status mpi_status; int ierr = MPI_Test(&request_, &mpi_test_flag, &mpi_status); - assert(MPI_SUCCESS == ierr); + assert(MPI_SUCCESS==ierr); (void)ierr; if (mpi_test_flag) { request_ = MPI_REQUEST_NULL; } @@ -96,7 +96,7 @@ namespace hiop void wait() { auto ierr = MPI_Wait(&request_, MPI_STATUS_IGNORE); - assert(MPI_SUCCESS == ierr); + assert(MPI_SUCCESS==ierr); (void)ierr; request_ = MPI_REQUEST_NULL; } @@ -106,7 +106,7 @@ namespace hiop assert(request_ == MPI_REQUEST_NULL); int recv_sign = 0; int ierr = MPI_Irecv(&recv_sign, 1, MPI_INT, rank_from, tag, comm, &request_); - assert(MPI_SUCCESS == ierr); + assert(MPI_SUCCESS==ierr); (void)ierr; } // only sende signal (that computation is finished), no actual functional information void post_send_end_signal(int tag, int rank_to, MPI_Comm comm) @@ -114,7 +114,7 @@ namespace hiop assert(request_ == MPI_REQUEST_NULL); int send_sign = 0; int ierr = MPI_Isend(&send_sign, 1, MPI_INT, rank_to, tag, comm, &request_); - assert(MPI_SUCCESS == ierr); + assert(MPI_SUCCESS==ierr); (void)ierr; } void post_recv(int tag, int rank_from, MPI_Comm comm) @@ -122,14 +122,14 @@ namespace hiop assert(request_ == MPI_REQUEST_NULL); double* buffer_arr = buffer->local_data(); int ierr = MPI_Irecv(buffer_arr, n_+1, MPI_DOUBLE, rank_from, tag, comm, &request_); - assert(MPI_SUCCESS == ierr); + assert(MPI_SUCCESS==ierr); (void)ierr; } void post_send(int tag, int rank_to, MPI_Comm comm) { assert(request_ == MPI_REQUEST_NULL); double* buffer_arr = buffer->local_data(); int ierr = MPI_Isend(buffer_arr, n_+1, MPI_DOUBLE, rank_to, tag, comm, &request_); - assert(MPI_SUCCESS == ierr); + assert(MPI_SUCCESS==ierr); (void)ierr; } double value(){return buffer->local_data()[0];} void set_value(const double v){buffer->local_data()[0]=v;} @@ -160,7 +160,7 @@ namespace hiop int test() { int mpi_test_flag; MPI_Status mpi_status; int ierr = MPI_Test(&request_, &mpi_test_flag, &mpi_status); - assert(MPI_SUCCESS == ierr); + assert(MPI_SUCCESS==ierr); (void)ierr; if (mpi_test_flag) { request_ = MPI_REQUEST_NULL; } @@ -168,20 +168,20 @@ namespace hiop } void wait() { int ierr = MPI_Wait(&request_, MPI_STATUS_IGNORE); - assert(MPI_SUCCESS == ierr); + assert(MPI_SUCCESS==ierr); (void)ierr; request_ = MPI_REQUEST_NULL; } void post_recv(int tag, int rank_from, MPI_Comm comm) { assert(request_ == MPI_REQUEST_NULL); int ierr = MPI_Irecv(&idx, 1, MPI_INT, rank_from, tag, comm, &request_); - assert(MPI_SUCCESS == ierr); + assert(MPI_SUCCESS==ierr); (void)ierr; } void post_send(int tag, int rank_to, MPI_Comm comm) { assert(request_ == MPI_REQUEST_NULL); int ierr = MPI_Isend(&idx, 1, MPI_INT, rank_to, tag, comm, &request_); - assert(MPI_SUCCESS == ierr); + assert(MPI_SUCCESS==ierr); (void)ierr; } int value(){return idx;} void set_idx(const int& i){idx = i;} @@ -573,8 +573,8 @@ hiopAlgPrimalDecomposition(hiopInterfacePriDecProblem* prob_in, // only two rank types for now, master and evaluator/worker #ifdef HIOP_USE_MPI - int ierr = MPI_Comm_rank(comm_world_, &my_rank_); assert(ierr == MPI_SUCCESS); - int ret = MPI_Comm_size(comm_world, &comm_size_); assert(ret==MPI_SUCCESS); + int ierr = MPI_Comm_rank(comm_world_, &my_rank_); assert(MPI_SUCCESS==ierr); (void)ierr; + int ret = MPI_Comm_size(comm_world, &comm_size_); assert(ret==MPI_SUCCESS); (void)ret; if(my_rank_==0) { my_rank_type_ = 0; } else { @@ -628,8 +628,8 @@ hiopAlgPrimalDecomposition(hiopInterfacePriDecProblem* prob_in, // only two rank types for now, master and evaluator/worker #ifdef HIOP_USE_MPI - int ierr = MPI_Comm_rank(comm_world_, &my_rank_); assert(ierr == MPI_SUCCESS); - int ret = MPI_Comm_size(comm_world_, &comm_size_); assert(ret==MPI_SUCCESS); + int ierr = MPI_Comm_rank(comm_world_, &my_rank_); assert(MPI_SUCCESS==ierr); (void)ierr; + int ret = MPI_Comm_size(comm_world_, &comm_size_); assert(ret==MPI_SUCCESS); (void)ret; if(my_rank_==0) { my_rank_type_ = 0; } else { @@ -892,7 +892,7 @@ void hiopAlgPrimalDecomposition::set_local_accum(const std::string local_accum) // send basecase solutions to all ranks int ierr = MPI_Bcast(x_vec, n_, MPI_DOUBLE, rank_master, comm_world_); - assert(ierr == MPI_SUCCESS); + assert(MPI_SUCCESS==ierr); (void)ierr; // set up recourse problem send/recv interface std::vector rec_prob; @@ -924,7 +924,7 @@ void hiopAlgPrimalDecomposition::set_local_accum(const std::string local_accum) for(int r=1; r< comm_size_;r++) { int cur_idx = cont_idx[idx]; int ierr = MPI_Send(&cur_idx, 1, MPI_INT, r, 1,comm_world_); - assert(MPI_SUCCESS == ierr); + assert(MPI_SUCCESS==ierr); (void)ierr; // log_->printf(hovIteration, "rank %d to get contingency index %d\n", r, cur_idx); //verbosity level 10 idx += 1; } @@ -1015,7 +1015,7 @@ void hiopAlgPrimalDecomposition::set_local_accum(const std::string local_accum) // Receive the index of the contingency to evaluate int mpi_test_flag = 0; int ierr = MPI_Recv(&cont_i, 1, MPI_INT, rank_master, 1, comm_world_, &status_); - assert(MPI_SUCCESS == ierr); + assert(MPI_SUCCESS==ierr); (void)ierr; cont_idx[0] = cont_i; // log_->printf(hovIteration, "contingency index %d, rank %d)\n", cont_idx[0],my_rank_); // compute the recourse function values and gradients @@ -1231,7 +1231,7 @@ void hiopAlgPrimalDecomposition::set_local_accum(const std::string local_accum) end_signal = 1; } ierr = MPI_Bcast(&end_signal, 1, MPI_INT, rank_master, comm_world_); - assert(ierr == MPI_SUCCESS); + assert(MPI_SUCCESS==ierr); (void)ierr; for(auto it : rec_prob) { delete it; @@ -1371,7 +1371,7 @@ void hiopAlgPrimalDecomposition::set_local_accum(const std::string local_accum) // send basecase solutions to all ranks int ierr = MPI_Bcast(x_vec, n_, MPI_DOUBLE, rank_master, comm_world_); - assert(ierr == MPI_SUCCESS); + assert(MPI_SUCCESS==ierr); (void)ierr; // set up recourse problem send/recv interface std::vector rec_prob; @@ -1408,7 +1408,7 @@ void hiopAlgPrimalDecomposition::set_local_accum(const std::string local_accum) for(int r=1; r< comm_size_;r++) { int cur_idx = cont_idx[idx]; int ierr = MPI_Send(&cur_idx, 1, MPI_INT, r, 1,comm_world_); - assert(MPI_SUCCESS == ierr); + assert(MPI_SUCCESS==ierr); (void)ierr; // log_->printf(hovIteration, "rank %d to get contingency index %d\n", r, cur_idx); //verbosity level 10 idx += 1; } @@ -1505,7 +1505,7 @@ void hiopAlgPrimalDecomposition::set_local_accum(const std::string local_accum) // Receive the index of the contingency to evaluate int mpi_test_flag = 0; int ierr = MPI_Recv(&cont_i, 1, MPI_INT, rank_master, 1, comm_world_, &status_); - assert(MPI_SUCCESS == ierr); + assert(MPI_SUCCESS==ierr); (void)ierr; cont_idx[0] = cont_i; // log_->printf(hovIteration, "contingency index %d, rank %d)\n", cont_idx[0],my_rank_); // compute the recourse function values and gradients @@ -1754,7 +1754,7 @@ void hiopAlgPrimalDecomposition::set_local_accum(const std::string local_accum) end_signal = 1; } ierr = MPI_Bcast(&end_signal, 1, MPI_INT, rank_master, comm_world_); - assert(ierr == MPI_SUCCESS); + assert(MPI_SUCCESS==ierr); (void)ierr; for(auto it : rec_prob) { delete it; diff --git a/src/Optimization/hiopDualsUpdater.cpp b/src/Optimization/hiopDualsUpdater.cpp index 510fae0cf..ed14a0677 100644 --- a/src/Optimization/hiopDualsUpdater.cpp +++ b/src/Optimization/hiopDualsUpdater.cpp @@ -122,7 +122,7 @@ bool hiopDualsLsqUpdate::go(const hiopIterate& iter, const double& infeas_nrm_trial) { hiopNlpDenseConstraints* nlpd = dynamic_cast(nlp_); - assert(nullptr!=nlpd); + assert(nullptr!=nlpd); (void)nlpd; //first update the duals using steplength along the search directions. This is fine for //signed duals z_l, z_u, v_l, and v_u. The rest of the duals, yc and yd, will be found as a @@ -543,7 +543,7 @@ bool hiopDualsLsqUpdateLinsysAugSparse::do_lsq_update(hiopIterate& iter, const hiopMatrix& jac_d) { hiopNlpSparse* nlpsp = dynamic_cast(nlp_); - assert(nullptr!=nlpsp); + assert(nullptr!=nlpsp); (void)nlpsp; const hiopMatrixSparse& Jac_cSp = dynamic_cast(jac_c); const hiopMatrixSparse& Jac_dSp = dynamic_cast(jac_d); diff --git a/src/Optimization/hiopFRProb.cpp b/src/Optimization/hiopFRProb.cpp index d9039ccd7..efa430c48 100644 --- a/src/Optimization/hiopFRProb.cpp +++ b/src/Optimization/hiopFRProb.cpp @@ -1609,7 +1609,7 @@ bool hiopFRProbDense::eval_f(const size_type& n, const double* x, bool new_x, do #ifdef HIOP_USE_MPI double obj_global; - int ierr = MPI_Allreduce(&obj_value, &obj_global, 1, MPI_DOUBLE, MPI_SUM, comm_); assert(ierr==MPI_SUCCESS); + int ierr = MPI_Allreduce(&obj_value, &obj_global, 1, MPI_DOUBLE, MPI_SUM, comm_); assert(MPI_SUCCESS==ierr); (void)ierr; obj_value = obj_global; #endif @@ -1676,7 +1676,7 @@ bool hiopFRProbDense::eval_cons(const size_type& n, wrk_c_->axpy(1.0, *wrk_eq_); } int ierr = MPI_Bcast(wrk_c_->local_data(), m_eq_, MPI_DOUBLE, comm_size_-1, comm_); - assert(ierr==MPI_SUCCESS); + assert(MPI_SUCCESS==ierr); (void)ierr; } // compute FR equality constratint body d-pi+ni @@ -1688,7 +1688,7 @@ bool hiopFRProbDense::eval_cons(const size_type& n, wrk_d_->axpy(1.0, *wrk_ineq_); } int ierr = MPI_Bcast(wrk_d_->local_data(), m_ineq_, MPI_DOUBLE, comm_size_-1, comm_); - assert(ierr==MPI_SUCCESS); + assert(MPI_SUCCESS==ierr); (void)ierr; } #else // compute FR equality constratint body c-pe+ne diff --git a/src/Optimization/hiopHessianLowRank.cpp b/src/Optimization/hiopHessianLowRank.cpp index a18af6d9b..26883b599 100644 --- a/src/Optimization/hiopHessianLowRank.cpp +++ b/src/Optimization/hiopHessianLowRank.cpp @@ -419,7 +419,7 @@ void hiopHessianLowRank::updateInternalBFGSRepresentation() #ifdef HIOP_USE_MPI int ierr; - ierr = MPI_Allreduce(_buff1_lxlx3, _buff2_lxlx3, 3*l*l, MPI_DOUBLE, MPI_SUM, nlp->get_comm()); assert(ierr==MPI_SUCCESS); + ierr = MPI_Allreduce(_buff1_lxlx3, _buff2_lxlx3, 3*l*l, MPI_DOUBLE, MPI_SUM, nlp->get_comm()); assert(MPI_SUCCESS==ierr); (void)ierr; // - block (2,2) DpYtDhInvY.copyFrom(_buff2_lxlx3); @@ -547,8 +547,8 @@ symMatTimesInverseTimesMatTrans(double beta, hiopMatrixDense& W, S2Y2.copyBlockFromMatrix(0,l,Y1); #ifdef HIOP_USE_MPI int ierr; - ierr = MPI_Allreduce(S2Y2.local_data(), _buff_2lxk, 2*l*k, MPI_DOUBLE, MPI_SUM, nlp->get_comm()); assert(ierr==MPI_SUCCESS); - ierr = MPI_Allreduce(W.local_data(), _buff_kxk, k*k, MPI_DOUBLE, MPI_SUM, nlp->get_comm()); assert(ierr==MPI_SUCCESS); + ierr = MPI_Allreduce(S2Y2.local_data(), _buff_2lxk, 2*l*k, MPI_DOUBLE, MPI_SUM, nlp->get_comm()); assert(MPI_SUCCESS==ierr); (void)ierr; + ierr = MPI_Allreduce(W.local_data(), _buff_kxk, k*k, MPI_DOUBLE, MPI_SUM, nlp->get_comm()); assert(MPI_SUCCESS==ierr); (void)ierr; S2Y2.copyFrom(_buff_2lxk); W.copyFrom(_buff_kxk); //also copy S1 and Y1 @@ -925,7 +925,9 @@ void hiopHessianLowRank::timesVec_noLogBarrierTerm(double beta, hiopVector& y, d void hiopHessianLowRank::timesVecCmn(double beta, hiopVector& y, double alpha, const hiopVector& x, bool addLogTerm) const { +#ifndef NDEBUG size_type n=St->n(); +#endif assert(l_curr==St->m()); assert(y.get_size()==n); assert(St->get_local_size_n() == Yt->get_local_size_n()); @@ -1362,17 +1364,21 @@ void hiopHessianInvLowRank_obsolette:: symmetricTimesMat(double beta, hiopMatrixDense& W, double alpha, const hiopMatrixDense& X) { - size_type n=St->n(), l=St->m(), k=W.m(); - assert(n==H0->get_size()); + size_type l = St->m(); (void)l; + size_type k = W.m(); (void)k; +#ifndef NDEBUG + size_type n=St->n(); assert(k==W.n()); - assert(l==Yt->m()); + assert(l==Yt->m()); + assert(n==H0->get_size()); assert(n==Yt->n()); assert(n==St->n()); assert(k==X.m()); assert(n==X.n()); +#endif //1.--compute W = beta*W + alpha*X*HO*X^T by calling symmMatTransTimesDiagTimesMat_local #ifdef HIOP_USE_MPI int myrank, ierr; - ierr=MPI_Comm_rank(nlp->get_comm(),&myrank); assert(MPI_SUCCESS==ierr); + ierr=MPI_Comm_rank(nlp->get_comm(),&myrank); assert(MPI_SUCCESS==ierr); (void)ierr; if(0==myrank) symmMatTimesDiagTimesMatTrans_local(beta,W,alpha,X,*H0); else @@ -1393,14 +1399,14 @@ symmetricTimesMat(double beta, hiopMatrixDense& W, symmMatTimesDiagTimesMatTrans_local(0.0,DpYtH0Y, 1.0,*Yt,*H0); #ifdef HIOP_USE_MPI //!opt - use one buffer and one reduce call - ierr=MPI_Allreduce(S1.local_data(), _buff_lxk,l*k, MPI_DOUBLE,MPI_SUM,nlp->get_comm()); assert(ierr==MPI_SUCCESS); + ierr=MPI_Allreduce(S1.local_data(), _buff_lxk,l*k, MPI_DOUBLE,MPI_SUM,nlp->get_comm()); assert(MPI_SUCCESS==ierr); (void)ierr; S1.copyFrom(_buff_lxk); - ierr=MPI_Allreduce(Y1.local_data(), _buff_lxk,l*k, MPI_DOUBLE,MPI_SUM,nlp->get_comm()); assert(ierr==MPI_SUCCESS); + ierr=MPI_Allreduce(Y1.local_data(), _buff_lxk,l*k, MPI_DOUBLE,MPI_SUM,nlp->get_comm()); assert(MPI_SUCCESS==ierr); (void)ierr; Y1.copyFrom(_buff_lxk); - ierr=MPI_Allreduce(W.local_data(), _buff_kxk,k*k, MPI_DOUBLE,MPI_SUM,nlp->get_comm()); assert(ierr==MPI_SUCCESS); + ierr=MPI_Allreduce(W.local_data(), _buff_kxk,k*k, MPI_DOUBLE,MPI_SUM,nlp->get_comm()); assert(MPI_SUCCESS==ierr); (void)ierr; W.copyFrom(_buff_kxk); - ierr=MPI_Allreduce(DpYtH0Y.local_data(), _buff_lxl,l*l, MPI_DOUBLE,MPI_SUM,nlp->get_comm()); assert(ierr==MPI_SUCCESS); + ierr=MPI_Allreduce(DpYtH0Y.local_data(), _buff_lxl,l*l, MPI_DOUBLE,MPI_SUM,nlp->get_comm()); assert(MPI_SUCCESS==ierr); (void)ierr; DpYtH0Y.copyFrom(_buff_lxl); #endif //add D to finish calculating D+Y^T*H0*Y @@ -1666,7 +1672,7 @@ hiopMatrixDense& hiopHessianInvLowRank_obsolette::new_S1(const hiopMatrixDense& //S1 is St*X^T (lxk), where 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(); #ifdef HIOP_DEEPCHECKS - const size_type n=St.n(); + const size_type n=St.n(); (void)n; assert(n==X.n()); if(_S1!=NULL) assert(_S1->n()==k); @@ -1683,7 +1689,7 @@ hiopMatrixDense& hiopHessianInvLowRank_obsolette::new_Y1(const hiopMatrixDense& //Y1 is Yt*H0*X^T = Y^T*H0*X^T, where Y^T is lxn, H0 is diag nxn, X is kxn size_type k=X.m(), l=Yt.m(); #ifdef HIOP_DEEPCHECKS - const size_type n=Yt.n(); + const size_type n=Yt.n(); (void)n; assert(X.n()==n); if(_Y1!=NULL) assert(_Y1->n()==k); #endif diff --git a/src/Optimization/hiopIterate.cpp b/src/Optimization/hiopIterate.cpp index 2cff027ff..74a748ba8 100644 --- a/src/Optimization/hiopIterate.cpp +++ b/src/Optimization/hiopIterate.cpp @@ -210,7 +210,7 @@ double hiopIterate::normOneOfBoundDuals() const double nrm1=zl->onenorm_local() + zu->onenorm_local(); #ifdef HIOP_USE_MPI double nrm1_global; - int ierr=MPI_Allreduce(&nrm1, &nrm1_global, 1, MPI_DOUBLE, MPI_SUM, nlp->get_comm()); assert(MPI_SUCCESS==ierr); + int ierr=MPI_Allreduce(&nrm1, &nrm1_global, 1, MPI_DOUBLE, MPI_SUM, nlp->get_comm()); assert(MPI_SUCCESS==ierr); (void)ierr; nrm1=nrm1_global; #endif nrm1 += vl->onenorm_local() + vu->onenorm_local(); @@ -229,7 +229,7 @@ double hiopIterate::normOneOfEqualityDuals() const double nrm1=zl->onenorm_local() + zu->onenorm_local(); #ifdef HIOP_USE_MPI double nrm1_global; - int ierr=MPI_Allreduce(&nrm1, &nrm1_global, 1, MPI_DOUBLE, MPI_SUM, nlp->get_comm()); assert(MPI_SUCCESS==ierr); + int ierr=MPI_Allreduce(&nrm1, &nrm1_global, 1, MPI_DOUBLE, MPI_SUM, nlp->get_comm()); assert(MPI_SUCCESS==ierr); (void)ierr; nrm1=nrm1_global; #endif nrm1 += vl->onenorm_local() + vu->onenorm_local() + yc->onenorm_local() + yd->onenorm_local(); @@ -249,7 +249,7 @@ void hiopIterate::normOneOfDuals(double& nrm1Eq, double& nrm1Bnd) const #ifdef HIOP_USE_MPI double nrm1_global; int ierr=MPI_Allreduce(&nrm1Bnd, &nrm1_global, 1, MPI_DOUBLE, MPI_SUM, nlp->get_comm()); - assert(MPI_SUCCESS==ierr); + assert(MPI_SUCCESS==ierr); (void)ierr; nrm1Bnd=nrm1_global; #endif nrm1Bnd += vl->onenorm_local() + vu->onenorm_local(); @@ -356,7 +356,7 @@ fractionToTheBdry(const hiopIterate& dir, const double& tau, double& alphaprimal alphadual=fmin(alphadual,alpha); #ifdef HIOP_USE_MPI double aux[2]={alphaprimal,alphadual}, aux_g[2]; - int ierr=MPI_Allreduce(aux, aux_g, 2, MPI_DOUBLE, MPI_MIN, nlp->get_comm()); assert(MPI_SUCCESS==ierr); + int ierr=MPI_Allreduce(aux, aux_g, 2, MPI_DOUBLE, MPI_MIN, nlp->get_comm()); assert(MPI_SUCCESS==ierr); (void)ierr; alphaprimal=aux_g[0]; alphadual=aux_g[1]; #endif @@ -527,7 +527,7 @@ double hiopIterate::evalLogBarrier() const barrier+= sxu->logBarrier_local(nlp->get_ixu()); #ifdef HIOP_USE_MPI double res; - int ierr = MPI_Allreduce(&barrier, &res, 1, MPI_DOUBLE, MPI_SUM, nlp->get_comm()); assert(ierr==MPI_SUCCESS); + int ierr = MPI_Allreduce(&barrier, &res, 1, MPI_DOUBLE, MPI_SUM, nlp->get_comm()); assert(MPI_SUCCESS==ierr); (void)ierr; barrier=res; #endif barrier+= sdl->logBarrier_local(nlp->get_idl()); @@ -556,7 +556,7 @@ double hiopIterate::linearDampingTerm(const double& mu, const double& kappa_d) c term += sxu->linearDampingTerm_local(nlp->get_ixu(), nlp->get_ixl(), mu, kappa_d); #ifdef HIOP_USE_MPI double res; - int ierr = MPI_Allreduce(&term, &res, 1, MPI_DOUBLE, MPI_SUM, nlp->get_comm()); assert(ierr==MPI_SUCCESS); + int ierr = MPI_Allreduce(&term, &res, 1, MPI_DOUBLE, MPI_SUM, nlp->get_comm()); assert(MPI_SUCCESS==ierr); (void)ierr; term = res; #endif term += sdl->linearDampingTerm_local(nlp->get_idl(), nlp->get_idu(), mu, kappa_d); diff --git a/src/Optimization/hiopKKTLinSys.cpp b/src/Optimization/hiopKKTLinSys.cpp index 12e265003..10acd5f27 100644 --- a/src/Optimization/hiopKKTLinSys.cpp +++ b/src/Optimization/hiopKKTLinSys.cpp @@ -555,8 +555,10 @@ bool hiopKKTLinSysCompressedXYcYd::update(const hiopIterate* iter, Jac_c_ = Jac_c; Jac_d_ = Jac_d; Hess_=Hess; +#ifndef NDEBUG int nx = Hess_->m(); assert(nx==Hess_->n()); assert(nx==Jac_c_->n()); assert(nx==Jac_d_->n()); +#endif //compute and put the barrier diagonals in //Dx=(Sxl)^{-1}Zl + (Sxu)^{-1}Zu @@ -788,7 +790,9 @@ bool hiopKKTLinSysCompressedXDYcYd::update( const hiopIterate* iter, Hess_=Hess; +#ifndef NDEBUG int nx = Hess_->m(); assert(nx==Hess_->n()); assert(nx==Jac_c_->n()); assert(nx==Jac_d_->n()); +#endif // compute barrier diagonals (these change only between outer optimiz iterations) // Dx=(Sxl)^{-1}Zl + (Sxu)^{-1}Zu @@ -1955,10 +1959,12 @@ bool hiopKKTLinSysNormalEquation::update(const hiopIterate* iter, Jac_d_ = Jac_d; Hess_ = Hess; +#ifndef NDEBUG size_type nx = Hess_->m(); assert(nx==Hess_->n()); assert(nx==Jac_c_->n()); assert(nx==Jac_d_->n()); +#endif // compute barrier diagonals (these change only between outer optimiz iterations) // Dx=(Sxl)^{-1}Zl + (Sxu)^{-1}Zu diff --git a/src/Optimization/hiopKKTLinSysMDS.cpp b/src/Optimization/hiopKKTLinSysMDS.cpp index 40830c13a..47dc9098e 100644 --- a/src/Optimization/hiopKKTLinSysMDS.cpp +++ b/src/Optimization/hiopKKTLinSysMDS.cpp @@ -134,8 +134,13 @@ namespace hiop Jac_dMDS_ = dynamic_cast(Jac_d); if(!Jac_dMDS_) { assert(false); return false; } - int nxs = HessMDS_->n_sp(), nxd = HessMDS_->n_de(), nx = HessMDS_->n(); - int neq = Jac_cMDS_->m(), nineq = Jac_dMDS_->m(); +#ifndef NDEBUG + int nxs = HessMDS_->n_sp(); + int nx = HessMDS_->n(); +#endif + int nxd = HessMDS_->n_de(); + int neq = Jac_cMDS_->m(); + int nineq = Jac_dMDS_->m(); assert(nx==nxs+nxd); assert(nx==Jac_cMDS_->n_sp()+Jac_cMDS_->n_de()); @@ -317,7 +322,10 @@ namespace hiop nlp_->runStats.kkt.tmSolveRhsManip.start(); - int nx=rx.get_size(), nyc=ryc.get_size(), nyd=ryd.get_size(); +#ifndef NDEBUG + int nx=rx.get_size(); +#endif + int nyc=ryc.get_size(), nyd=ryd.get_size(); int nxsp=Hxs_->get_size(); assert(nxsp<=nx); int nxde = nlpMDS_->nx_de(); assert(nxsp+nxde==nx); diff --git a/src/Optimization/hiopKKTLinSysSparse.cpp b/src/Optimization/hiopKKTLinSysSparse.cpp index c41a8579a..a286cf890 100644 --- a/src/Optimization/hiopKKTLinSysSparse.cpp +++ b/src/Optimization/hiopKKTLinSysSparse.cpp @@ -208,8 +208,10 @@ namespace hiop nlp_->runStats.kkt.tmSolveRhsManip.start(); int nx=rx.get_size(), nyc=ryc.get_size(), nyd=ryd.get_size(); +#ifndef NDEBUG int nxsp=Hx_->get_size(); assert(nxsp==nx); +#endif if(rhs_ == NULL) { rhs_ = LinearAlgebraFactory::create_vector(nlp_->options->GetString("mem_space"), nx+nyc+nyd); @@ -538,8 +540,10 @@ namespace hiop nlp_->runStats.kkt.tmSolveRhsManip.start(); int nx=rx.get_size(), nd=rd.get_size(), nyc=ryc.get_size(), nyd=ryd.get_size(); +#ifndef NDEBUG int nxsp=Hx_->get_size(); assert(nxsp==nx); +#endif if(rhs_ == NULL) { rhs_ = LinearAlgebraFactory::create_vector(nlp_->options->GetString("mem_space"), nx+nd+nyc+nyd); @@ -1083,8 +1087,10 @@ namespace hiop size_type nx=rx.get_size(), nd=rd.get_size(), neq=ryc.get_size(), nineq=ryd.get_size(), ndl = nlp_->m_ineq_low(), ndu = nlp_->m_ineq_upp(), nxl = nlp_->n_low(), nxu = nlp_->n_upp(); +#ifndef NDEBUG size_type nxsp=Hx_->get_size(); assert(nxsp==nx); +#endif int n = nx + neq + nineq + nd + ndl + ndu + nxl + nxu + ndl + ndu + nxl + nxu; if(rhs_ == nullptr) { diff --git a/src/Optimization/hiopKKTLinSysSparseCondensed.cpp b/src/Optimization/hiopKKTLinSysSparseCondensed.cpp index 67b1d26d4..a34c32b4f 100644 --- a/src/Optimization/hiopKKTLinSysSparseCondensed.cpp +++ b/src/Optimization/hiopKKTLinSysSparseCondensed.cpp @@ -356,10 +356,11 @@ bool hiopKKTLinSysCondensedSparse::solve_compressed_direct(hiopVector& rx, assert(Jac_dSp_); assert(0 == ryc.get_size() && "this KKT does not support equality constraints"); +#ifndef NDEBUG size_type nx = rx.get_size(); - assert(rhs_); assert(rhs_->get_size() == nx); +#endif /* (H+Dx+Jd^T*(Dd+delta_wd*I)*Jd)dx = rx + Jd^T*Dd*ryd + Jd^T*rd * dd = Jd*dx - ryd diff --git a/src/Optimization/hiopNlpFormulation.cpp b/src/Optimization/hiopNlpFormulation.cpp index 8de42371e..53a3466b9 100644 --- a/src/Optimization/hiopNlpFormulation.cpp +++ b/src/Optimization/hiopNlpFormulation.cpp @@ -81,11 +81,11 @@ hiopNlpFormulation::hiopNlpFormulation(hiopInterfaceBase& interface_, const char { strFixedVars_ = ""; //uninitialized dFixedVarsTol_ = -1.; //uninitialized - bool bret; + bool bret; (void) bret; #ifdef HIOP_USE_MPI bret = interface_base.get_MPI_comm(comm_); assert(bret); - int nret; + int nret; (void) nret; //MPI may not be initialized: this occurs when a serial driver call HiOp built with MPI support on int initialized; nret = MPI_Initialized( &initialized ); @@ -262,7 +262,7 @@ bool hiopNlpFormulation::finalizeInitialization() size_type nfixed_vars=nfixed_vars_local; #ifdef HIOP_USE_MPI int ierr = MPI_Allreduce(&nfixed_vars_local, &nfixed_vars, 1, MPI_HIOP_SIZE_TYPE, MPI_SUM, comm_); - assert(MPI_SUCCESS==ierr); + assert(MPI_SUCCESS==ierr); (void)ierr; #endif hiopFixedVarsRemover* fixedVarsRemover = NULL; if(nfixed_vars>0) { @@ -383,7 +383,7 @@ bool hiopNlpFormulation::finalizeInitialization() size_type aux[3]={n_bnds_low_local_, n_bnds_upp_local_, n_bnds_lu_}; size_type aux_g[3]; ierr=MPI_Allreduce(aux, aux_g, 3, MPI_HIOP_SIZE_TYPE, MPI_SUM, comm_); - assert(MPI_SUCCESS==ierr); + assert(MPI_SUCCESS==ierr); (void)ierr; n_bnds_low_ = aux_g[0]; n_bnds_upp_ = aux_g[1]; n_bnds_lu_ = aux_g[2]; @@ -1284,7 +1284,7 @@ bool hiopNlpFormulation::user_force_update(int iter, double& alpha_du, double& alpha_pr) { - bool retval; + bool retval; (void)retval; assert(x.get_size()==n_vars_); assert(c.get_size()+d.get_size()==n_cons_); @@ -1304,7 +1304,7 @@ void hiopNlpFormulation::print(FILE* f, const char* msg, int rank) const int myrank=0; #ifdef HIOP_USE_MPI if(rank>=0) { - int ierr = MPI_Comm_rank(comm_, &myrank); assert(ierr==MPI_SUCCESS); + int ierr = MPI_Comm_rank(comm_, &myrank); assert(MPI_SUCCESS==ierr); (void)ierr; } #endif if(myrank==rank || rank==-1) { @@ -1436,7 +1436,9 @@ bool hiopNlpDenseConstraints::eval_Jac_c_d_interface_impl(hiopVector& x, bool ne } hiopVector* x_user = nlp_transformations_.apply_inv_to_x(x, new_x); +#ifndef NDEBUG double* Jac_consde = cons_Jac_de->local_data(); +#endif hiopMatrix* Jac_user = nlp_transformations_.apply_inv_to_jacob_cons(*cons_Jac_, n_cons_); hiopMatrixDense* cons_Jac_user_de = dynamic_cast(Jac_user); diff --git a/src/Optimization/hiopNlpTransforms.cpp b/src/Optimization/hiopNlpTransforms.cpp index d97696b56..5e69c8fc1 100644 --- a/src/Optimization/hiopNlpTransforms.cpp +++ b/src/Optimization/hiopNlpTransforms.cpp @@ -129,7 +129,7 @@ index_type* hiopFixedVarsRemover::allocRSVectorDistrib() 1, MPI_HIOP_INDEX_TYPE, comm); - assert(ierr==MPI_SUCCESS); + assert(MPI_SUCCESS==ierr); (void)ierr; #else assert(nlen==1); #endif diff --git a/src/Optimization/hiopResidual.cpp b/src/Optimization/hiopResidual.cpp index f5a56c048..12d4b2c28 100644 --- a/src/Optimization/hiopResidual.cpp +++ b/src/Optimization/hiopResidual.cpp @@ -356,7 +356,7 @@ int hiopResidual::update(const hiopIterate& it, nrmInf_bar_complem}; double aux_g[6]; int ierr = MPI_Allreduce(aux, aux_g, 6, MPI_DOUBLE, MPI_MAX, nlp->get_comm()); - assert(MPI_SUCCESS==ierr); + assert(MPI_SUCCESS==ierr); (void)ierr; nrmInf_nlp_optim=aux_g[0]; nrmInf_nlp_feasib=aux_g[1]; nrmInf_nlp_complem=aux_g[2]; @@ -606,7 +606,7 @@ void hiopResidual::update_soc(const hiopIterate& it, //otherwise, if calling infnorm() for each vector, there will be 12 Allreduce's, each of 1 double double aux[6] = {nrmInf_nlp_optim,nrmInf_nlp_feasib,nrmInf_nlp_complem,nrmInf_bar_optim,nrmInf_bar_feasib,nrmInf_bar_complem}, aux_g[6]; int ierr = MPI_Allreduce(aux, aux_g, 6, MPI_DOUBLE, MPI_MAX, nlp->get_comm()); - assert(MPI_SUCCESS==ierr); + assert(MPI_SUCCESS==ierr); (void)ierr; nrmInf_nlp_optim = aux_g[0]; nrmInf_nlp_feasib = aux_g[1]; nrmInf_nlp_complem = aux_g[2]; diff --git a/src/Utils/hiopLogger.hpp b/src/Utils/hiopLogger.hpp index 2b2111793..d8004f458 100644 --- a/src/Utils/hiopLogger.hpp +++ b/src/Utils/hiopLogger.hpp @@ -93,7 +93,7 @@ class hiopLogger { #ifdef HIOP_USE_MPI int ierr = MPI_Comm_rank(comm_wrld, &my_rank_); - assert(MPI_SUCCESS == ierr); + assert(MPI_SUCCESS==ierr); (void)ierr; (void)ierr; #else my_rank_ = 0; #endif diff --git a/src/Utils/hiopRunStats.hpp b/src/Utils/hiopRunStats.hpp index 9d02b64cc..6e61c86d7 100644 --- a/src/Utils/hiopRunStats.hpp +++ b/src/Utils/hiopRunStats.hpp @@ -345,14 +345,14 @@ class hiopRunStats << " avg iter " << (tmSolverInternal.getElapsedTime()/nIter) << "s " << std::endl; #ifdef HIOP_USE_MPI int nranks; - int ierr = MPI_Comm_size(comm, &nranks); assert(MPI_SUCCESS==ierr); + int ierr = MPI_Comm_size(comm, &nranks); assert(MPI_SUCCESS==ierr); (void)ierr; double loc=tmSolverInternal.getElapsedTime(), mean; - ierr = MPI_Allreduce(&loc, &mean, 1, MPI_DOUBLE, MPI_SUM, comm); assert(MPI_SUCCESS==ierr); + ierr = MPI_Allreduce(&loc, &mean, 1, MPI_DOUBLE, MPI_SUM, comm); assert(MPI_SUCCESS==ierr); (void)ierr; mean = mean/nranks; loc = tmSolverInternal.getElapsedTime()-mean; loc = loc*loc; double stddev; - ierr = MPI_Allreduce(&loc, &stddev, 1, MPI_DOUBLE, MPI_SUM, comm); assert(MPI_SUCCESS==ierr); + ierr = MPI_Allreduce(&loc, &stddev, 1, MPI_DOUBLE, MPI_SUM, comm); assert(MPI_SUCCESS==ierr); (void)ierr; stddev = sqrt(stddev); stddev /= nranks; ss << " internal total std dev across ranks " << (stddev/mean*100) << " percent" << std::endl; @@ -373,12 +373,12 @@ class hiopRunStats #ifdef HIOP_USE_MPI loc=tmEvalObj.getElapsedTime() + tmEvalGrad_f.getElapsedTime() + tmEvalCons.getElapsedTime() + tmEvalJac_con.getElapsedTime(); - ierr = MPI_Allreduce(&loc, &mean, 1, MPI_DOUBLE, MPI_SUM, comm); assert(MPI_SUCCESS==ierr); + ierr = MPI_Allreduce(&loc, &mean, 1, MPI_DOUBLE, MPI_SUM, comm); assert(MPI_SUCCESS==ierr); (void)ierr; mean = mean/nranks; loc = tmEvalObj.getElapsedTime() + tmEvalGrad_f.getElapsedTime() + tmEvalCons.getElapsedTime() + tmEvalJac_con.getElapsedTime() - mean; loc = loc*loc; - ierr = MPI_Allreduce(&loc, &stddev, 1, MPI_DOUBLE, MPI_SUM, comm); assert(MPI_SUCCESS==ierr); + ierr = MPI_Allreduce(&loc, &stddev, 1, MPI_DOUBLE, MPI_SUM, comm); assert(MPI_SUCCESS==ierr); (void)ierr; stddev = sqrt(stddev); stddev /= nranks; ss << " Fcn/deriv total std dev across ranks " << (stddev/mean*100) << " percent" << std::endl; diff --git a/tests/LinAlg/matrixTestsSparse.hpp b/tests/LinAlg/matrixTestsSparse.hpp index 33dae1633..db5984507 100644 --- a/tests/LinAlg/matrixTestsSparse.hpp +++ b/tests/LinAlg/matrixTestsSparse.hpp @@ -939,9 +939,8 @@ class MatrixTestsSparse : public TestBase int matrix_copy_rows_from( hiop::hiopMatrixSparse& A, hiop::hiopMatrixSparse& B, hiop::hiopVectorInt& select) { int n_A_rows = A.m(); - int n_B_rows = B.m(); assert(A.n() == B.n()); - assert(n_A_rows <= n_B_rows); + assert(A.m() <= B.m()); const real_type A_val = one; const real_type B_val = two; diff --git a/tests/LinAlg/vectorTests.hpp b/tests/LinAlg/vectorTests.hpp index dfe0ed29f..64acb269b 100644 --- a/tests/LinAlg/vectorTests.hpp +++ b/tests/LinAlg/vectorTests.hpp @@ -500,16 +500,16 @@ class VectorTests : public TestBase hiop::hiopVectorInt& d_map, const int rank=0) { - const local_ordinal_type cd_size = getLocalSize(&cd); const local_ordinal_type c_size = getLocalSize(&c); + #ifndef NDEBUG + const local_ordinal_type cd_size = getLocalSize(&cd); const local_ordinal_type d_size = getLocalSize(&d); const local_ordinal_type c_map_size = c_map.get_local_size(); const local_ordinal_type d_map_size = d_map.get_local_size(); - assert(c_size == c_map_size && "size doesn't match"); assert(d_size == d_map_size && "size doesn't match"); assert(c_size + d_size == cd_size && "size doesn't match"); - +#endif const real_type c_val = one; const real_type d_val = two; @@ -544,16 +544,16 @@ class VectorTests : public TestBase hiop::hiopVectorInt& d_map, const int rank=0) { + const local_ordinal_type c_size = getLocalSize(&c); +#ifndef NDEBUG const local_ordinal_type cd_size = getLocalSize(&cd); - const local_ordinal_type c_size = getLocalSize(&c); const local_ordinal_type d_size = getLocalSize(&d); - const local_ordinal_type c_map_size = c_map.get_local_size(); const local_ordinal_type d_map_size = d_map.get_local_size(); assert(c_size == c_map_size && "size doesn't match"); assert(d_size == d_map_size && "size doesn't match"); assert(c_size + d_size == cd_size && "size doesn't match"); - +#endif const real_type cd_val = two; c_map.linspace(0, 1); @@ -1076,10 +1076,11 @@ class VectorTests : public TestBase */ bool vectorAxpy(hiop::hiopVector& v, hiop::hiopVector& x, const int rank) { - const local_ordinal_type N = getLocalSize(&v); assert(v.get_size() == x.get_size()); +#ifndef NDEBUG + const local_ordinal_type N = getLocalSize(&v); assert(N == getLocalSize(&x)); - +#endif const real_type alpha = half; const real_type x_val = two; const real_type v_val = two; @@ -1106,10 +1107,11 @@ class VectorTests : public TestBase hiop::hiopVector& z, const int rank) { - const local_ordinal_type N = getLocalSize(&v); assert(v.get_size() == x.get_size()); +#ifndef NDEBUG + const local_ordinal_type N = getLocalSize(&v); assert(N == getLocalSize(&x)); - +#endif const real_type alpha = half; const real_type x_val = two; const real_type v_val = two; @@ -1138,10 +1140,11 @@ class VectorTests : public TestBase hiop::hiopVector& z, const int rank) { - const local_ordinal_type N = getLocalSize(&v); assert(v.get_size() == x.get_size()); +#ifndef NDEBUG + const local_ordinal_type N = getLocalSize(&v); assert(N == getLocalSize(&x)); - +#endif const real_type alpha = three; const real_type x_val = half; const real_type v_val = two; @@ -1662,11 +1665,13 @@ class VectorTests : public TestBase const int rank) { // setup constants and make assertions +#ifndef NDEBUG const local_ordinal_type N = getLocalSize(&x); assert(N == getLocalSize(&lower)); assert(N == getLocalSize(&upper)); assert(N == getLocalSize(&lower_pattern)); assert(N == getLocalSize(&upper_pattern)); +#endif static const real_type kappa1 = half; static const real_type kappa2 = half; int fail = 0; diff --git a/tests/test_bicgstab.cpp b/tests/test_bicgstab.cpp index 6f6b7c55d..29445f11e 100644 --- a/tests/test_bicgstab.cpp +++ b/tests/test_bicgstab.cpp @@ -17,7 +17,7 @@ void initializeSymSparseMat(hiop::hiopMatrixSparse* mat, bool is_diag_pred) size_type* iRow = A->i_row(); size_type* jCol = A->j_col(); double* val = A->M(); - const auto nnz = A->numberOfNonzeros(); + const auto nnz = A->numberOfNonzeros(); (void)nnz; int nonZerosUsed = 0; size_type m = A->m(); @@ -81,7 +81,9 @@ void initializeRajaSymSparseMat(hiop::hiopMatrixSparse* mat, bool is_diag_pred) size_type* iRow = A->i_row_host(); size_type* jCol = A->j_col_host(); double* val = A->M_host(); +#ifndef NDEBUG const auto nnz = A->numberOfNonzeros(); +#endif int nonZerosUsed = 0; size_type m = A->m(); @@ -124,7 +126,7 @@ int main(int argc, char **argv) #ifdef HIOP_USE_MPI int rank = 0; int numRanks = 1; - int err; + int err; (void)err; err = MPI_Init(&argc, &argv); assert(MPI_SUCCESS==err); err = MPI_Comm_rank(MPI_COMM_WORLD,&rank); assert(MPI_SUCCESS==err); err = MPI_Comm_size(MPI_COMM_WORLD,&numRanks); assert(MPI_SUCCESS==err); diff --git a/tests/test_pcg.cpp b/tests/test_pcg.cpp index 732ebf27d..ce13bcde0 100644 --- a/tests/test_pcg.cpp +++ b/tests/test_pcg.cpp @@ -17,7 +17,7 @@ void initializeSymSparseMat(hiop::hiopMatrixSparse* mat, bool is_diag_pred) size_type* iRow = A->i_row(); size_type* jCol = A->j_col(); double* val = A->M(); - const auto nnz = A->numberOfNonzeros(); + const auto nnz = A->numberOfNonzeros(); (void)nnz; int nonZerosUsed = 0; size_type m = A->m(); @@ -80,7 +80,9 @@ void initializeRajaSymSparseMat(hiop::hiopMatrixSparse* mat, bool is_diag_pred) size_type* iRow = A->i_row_host(); size_type* jCol = A->j_col_host(); double* val = A->M_host(); +#ifndef NDEBUG const auto nnz = A->numberOfNonzeros(); +#endif int nonZerosUsed = 0; size_type m = A->m(); @@ -123,7 +125,7 @@ int main(int argc, char **argv) #ifdef HIOP_USE_MPI int rank = 0; int numRanks = 1; - int err; + int err; (void)err; err = MPI_Init(&argc, &argv); assert(MPI_SUCCESS==err); err = MPI_Comm_rank(MPI_COMM_WORLD,&rank); assert(MPI_SUCCESS==err); err = MPI_Comm_size(MPI_COMM_WORLD,&numRanks); assert(MPI_SUCCESS==err);