diff --git a/BLAS_benchmark/BatchBlasBench.cc b/BLAS_benchmark/BatchBlasBench.cc index 77f9e75d..6db7160a 100644 --- a/BLAS_benchmark/BatchBlasBench.cc +++ b/BLAS_benchmark/BatchBlasBench.cc @@ -120,7 +120,7 @@ inline void acceleratorMemSet(void *base,int value,size_t bytes) { cudaMemset(ba cudaGetErrorString( err )); \ printf("File %s Line %d\n",__FILE__,__LINE__); \ fflush(stdout); \ - if (acceleratorAbortOnGpuError) assert(err==cudaSuccess); \ + if (acceleratorAbortOnGpuError) GRID_ASSERT(err==cudaSuccess); \ } \ } @@ -168,7 +168,7 @@ public: if ( (_Tp*)ptr == (_Tp *) NULL ) { printf("Grid Device Allocator got NULL for %lu bytes\n",(unsigned long) bytes ); } - assert( ( (_Tp*)ptr != (_Tp *)NULL ) ); + GRID_ASSERT( ( (_Tp*)ptr != (_Tp *)NULL ) ); return ptr; } @@ -276,11 +276,11 @@ public: { #ifdef GRID_HIP auto err = hipDeviceSynchronize(); - assert(err==hipSuccess); + GRID_ASSERT(err==hipSuccess); #endif #ifdef GRID_CUDA auto err = cudaDeviceSynchronize(); - assert(err==cudaSuccess); + GRID_ASSERT(err==cudaSuccess); #endif #ifdef GRID_SYCL accelerator_barrier(); @@ -305,8 +305,8 @@ public: { RealD t2=usecond(); - assert(OpA!=GridBLAS_OP_T); // Complex case expect no transpose - assert(OpB!=GridBLAS_OP_T); + GRID_ASSERT(OpA!=GridBLAS_OP_T); // Complex case expect no transpose + GRID_ASSERT(OpB!=GridBLAS_OP_T); int lda = m; // m x k column major int ldb = k; // k x n column major @@ -341,7 +341,7 @@ public: (hipblasDoubleComplex *) Bkn, ldb, (hipblasDoubleComplex *) &beta_p[0], (hipblasDoubleComplex *) Cmn, ldc); - assert(err==HIPBLAS_STATUS_SUCCESS); + GRID_ASSERT(err==HIPBLAS_STATUS_SUCCESS); #endif #ifdef GRID_CUDA cublasOperation_t hOpA; @@ -361,7 +361,7 @@ public: (cuDoubleComplex *) Bkn, ldb, (cuDoubleComplex *) &beta_p[0], (cuDoubleComplex *) Cmn, ldc); - assert(err==CUBLAS_STATUS_SUCCESS); + GRID_ASSERT(err==CUBLAS_STATUS_SUCCESS); #endif #ifdef GRID_SYCL int64_t m64=m; @@ -433,8 +433,8 @@ public: { RealD t2=usecond(); - assert(OpA!=GridBLAS_OP_T); // Complex case expect no transpose - assert(OpB!=GridBLAS_OP_T); + GRID_ASSERT(OpA!=GridBLAS_OP_T); // Complex case expect no transpose + GRID_ASSERT(OpB!=GridBLAS_OP_T); int lda = m; // m x k column major int ldb = k; // k x n column major @@ -469,7 +469,7 @@ public: (hipblasComplex *) Bkn, ldb, (hipblasComplex *) &beta_p[0], (hipblasComplex *) Cmn, ldc); - assert(err==HIPBLAS_STATUS_SUCCESS); + GRID_ASSERT(err==HIPBLAS_STATUS_SUCCESS); #endif #ifdef GRID_CUDA cublasOperation_t hOpA; @@ -489,7 +489,7 @@ public: (cuComplex *) Bkn, ldb, (cuComplex *) &beta_p[0], (cuComplex *) Cmn, ldc); - assert(err==CUBLAS_STATUS_SUCCESS); + GRID_ASSERT(err==CUBLAS_STATUS_SUCCESS); #endif #ifdef GRID_SYCL int64_t m64=m; @@ -595,11 +595,11 @@ public: { RealD t2=usecond(); int32_t batchCount = Amk.size(); - assert(Bkn.size()==batchCount); - assert(Cmn.size()==batchCount); + GRID_ASSERT(Bkn.size()==batchCount); + GRID_ASSERT(Cmn.size()==batchCount); - assert(OpA!=GridBLAS_OP_T); // Complex case expect no transpose - assert(OpB!=GridBLAS_OP_T); + GRID_ASSERT(OpA!=GridBLAS_OP_T); // Complex case expect no transpose + GRID_ASSERT(OpB!=GridBLAS_OP_T); int lda = m; // m x k column major int ldb = k; // k x n column major @@ -636,7 +636,7 @@ public: (hipblasDoubleComplex **)&Cmn[0], ldc, batchCount); // std::cout << " hipblas return code " <<(int)err< #include #include @@ -16,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -23,11 +32,35 @@ #include #include #include +#ifdef HAVE_EXECINFO_H +#include +#endif + +void GridAbort(void); + +#define ASSLOG(A) ::write(STDERR_FILENO,A,strlen(A)); +#ifdef HAVE_EXECINFO_H +#define GRID_ASSERT(b) if(!(b)) { \ + ASSLOG(" GRID_ASSERT failure: "); \ + ASSLOG(__FILE__); \ + ASSLOG(" : "); \ + ASSLOG(#b); \ + ASSLOG(" : "); \ + int symbols = backtrace(Grid_backtrace_buffer,_NBACKTRACE); \ + backtrace_symbols_fd(Grid_backtrace_buffer,symbols,STDERR_FILENO); \ + GridAbort(); \ + }; +#else +#define GRID_ASSERT(b) if(!(b)) { \ + ASSLOG(" GRID_ASSERT failure: "); \ + ASSLOG(__FILE__); \ + ASSLOG(" : "); \ + ASSLOG(#b); \ + ASSLOG(" : "); \ + GridAbort(); \ + }; +#endif -/////////////////// -// Grid config -/////////////////// -#include "Config.h" #ifdef TOFU #undef GRID_COMMS_THREADS diff --git a/Grid/Namespace.h b/Grid/Namespace.h index c42b46b3..be90e2c8 100644 --- a/Grid/Namespace.h +++ b/Grid/Namespace.h @@ -29,8 +29,8 @@ directory #pragma once #include -#include #include +#include #define NAMESPACE_BEGIN(A) namespace A { #define NAMESPACE_END(A) } diff --git a/Grid/algorithms/Algorithms.h b/Grid/algorithms/Algorithms.h index 38f6587c..228563dd 100644 --- a/Grid/algorithms/Algorithms.h +++ b/Grid/algorithms/Algorithms.h @@ -51,6 +51,7 @@ NAMESPACE_CHECK(approx); #include #include #include +#include NAMESPACE_CHECK(deflation); #include NAMESPACE_CHECK(ConjGrad); diff --git a/Grid/algorithms/FFT.h b/Grid/algorithms/FFT.h index 329d1d46..36a30d38 100644 --- a/Grid/algorithms/FFT.h +++ b/Grid/algorithms/FFT.h @@ -169,7 +169,7 @@ public: void FFT_dim(Lattice &result,const Lattice &source,int dim, int sign){ #ifndef HAVE_FFTW std::cerr << "FFTW is not compiled but is called"< &out){ - assert(0); + GRID_ASSERT(0); }; void Op (const Field &in, Field &out){ _Mat.M(in,out); - assert(0); + GRID_ASSERT(0); } void AdjOp (const Field &in, Field &out){ _Mat.Mdag(in,out); - assert(0); + GRID_ASSERT(0); } void HermOpAndNorm(const Field &in, Field &out,RealD &n1,RealD &n2){ HermOp(in,out); @@ -188,13 +188,13 @@ public: ShiftedHermOpLinearOperator(LinearOperatorBase &Mat,RealD shift): _Mat(Mat), _shift(shift){}; // Support for coarsening to a multigrid void OpDiag (const Field &in, Field &out) { - assert(0); + GRID_ASSERT(0); } void OpDir (const Field &in, Field &out,int dir,int disp) { - assert(0); + GRID_ASSERT(0); } void OpDirAll (const Field &in, std::vector &out){ - assert(0); + GRID_ASSERT(0); }; void Op (const Field &in, Field &out){ HermOp(in,out); @@ -271,10 +271,10 @@ public: _Mat.Mdag(in,out); } void HermOpAndNorm(const Field &in, Field &out,RealD &n1,RealD &n2){ - assert(0); + GRID_ASSERT(0); } void HermOp(const Field &in, Field &out){ - assert(0); + GRID_ASSERT(0); } }; template @@ -303,10 +303,10 @@ public: out = out + shift * in; } void HermOpAndNorm(const Field &in, Field &out,RealD &n1,RealD &n2){ - assert(0); + GRID_ASSERT(0); } void HermOp(const Field &in, Field &out){ - assert(0); + GRID_ASSERT(0); } }; @@ -345,13 +345,13 @@ class SchurOperatorBase : public LinearOperatorBase { } // Support for coarsening to a multigrid void OpDiag (const Field &in, Field &out) { - assert(0); // must coarsen the unpreconditioned system + GRID_ASSERT(0); // must coarsen the unpreconditioned system } void OpDir (const Field &in, Field &out,int dir,int disp) { - assert(0); + GRID_ASSERT(0); } void OpDirAll (const Field &in, std::vector &out){ - assert(0); + GRID_ASSERT(0); }; }; template @@ -447,10 +447,10 @@ class NonHermitianSchurOperatorBase : public LinearOperatorBase MpcDag(tmp,out); } virtual void HermOpAndNorm(const Field& in, Field& out, RealD& n1, RealD& n2) { - assert(0); + GRID_ASSERT(0); } virtual void HermOp(const Field& in, Field& out) { - assert(0); + GRID_ASSERT(0); } void Op(const Field& in, Field& out) { Mpc(in, out); @@ -460,13 +460,13 @@ class NonHermitianSchurOperatorBase : public LinearOperatorBase } // Support for coarsening to a multigrid void OpDiag(const Field& in, Field& out) { - assert(0); // must coarsen the unpreconditioned system + GRID_ASSERT(0); // must coarsen the unpreconditioned system } void OpDir(const Field& in, Field& out, int dir, int disp) { - assert(0); + GRID_ASSERT(0); } void OpDirAll(const Field& in, std::vector& out){ - assert(0); + GRID_ASSERT(0); }; }; @@ -580,7 +580,7 @@ class SchurStaggeredOperator : public SchurOperatorBase { public: SchurStaggeredOperator (Matrix &Mat): _Mat(Mat), tmp(_Mat.RedBlackGrid()) { - assert( _Mat.isTrivialEE() ); + GRID_ASSERT( _Mat.isTrivialEE() ); mass = _Mat.Mass(); } virtual void HermOpAndNorm(const Field &in, Field &out,RealD &n1,RealD &n2){ @@ -611,7 +611,7 @@ class SchurStaggeredOperator : public SchurOperatorBase { Mpc(in,out); } virtual void MpcDagMpc(const Field &in, Field &out) { - assert(0);// Never need with staggered + GRID_ASSERT(0);// Never need with staggered } }; template using SchurStagOperator = SchurStaggeredOperator; @@ -623,7 +623,7 @@ template class OperatorFunction { public: virtual void operator() (LinearOperatorBase &Linop, const Field &in, Field &out) = 0; virtual void operator() (LinearOperatorBase &Linop, const std::vector &in,std::vector &out) { - assert(in.size()==out.size()); + GRID_ASSERT(in.size()==out.size()); for(int k=0;k &in, std::vector &out) { - assert(in.size() == out.size()); + GRID_ASSERT(in.size() == out.size()); for (unsigned int i = 0; i < in.size(); ++i) { diff --git a/Grid/algorithms/approx/Remez.cc b/Grid/algorithms/approx/Remez.cc index 6fbaadc9..19f7742e 100644 --- a/Grid/algorithms/approx/Remez.cc +++ b/Grid/algorithms/approx/Remez.cc @@ -121,7 +121,7 @@ double AlgRemez::generateApprox(int num_degree, int den_degree, // Reallocate arrays, since degree has changed if (num_degree != n || den_degree != d) allocate(num_degree,den_degree); - assert(a_len<=SUM_MAX); + GRID_ASSERT(a_len<=SUM_MAX); step = new bigfloat[num_degree+den_degree+2]; @@ -151,9 +151,9 @@ double AlgRemez::generateApprox(int num_degree, int den_degree, equations(); if (delta < tolerance) { std::cout<<"Delta too small, try increasing precision\n"; - assert(0); + GRID_ASSERT(0); }; - assert( delta>= tolerance); + GRID_ASSERT( delta>= tolerance); search(step); } diff --git a/Grid/algorithms/approx/Remez.h b/Grid/algorithms/approx/Remez.h index 71b1093b..85720b5a 100644 --- a/Grid/algorithms/approx/Remez.h +++ b/Grid/algorithms/approx/Remez.h @@ -134,7 +134,7 @@ class AlgRemez virtual ~AlgRemez(); int getDegree(void){ - assert(n==d); + GRID_ASSERT(n==d); return n; } // Reset the bounds of the approximation diff --git a/Grid/algorithms/approx/RemezGeneral.cc b/Grid/algorithms/approx/RemezGeneral.cc index e41b4ed2..c534aba7 100644 --- a/Grid/algorithms/approx/RemezGeneral.cc +++ b/Grid/algorithms/approx/RemezGeneral.cc @@ -28,11 +28,11 @@ void AlgRemezGeneral::setupPolyProperties(int num_degree, int den_degree, PolyTy pow_n = num_degree; pow_d = den_degree; - if(pow_n % 2 == 0 && num_type_in == PolyType::Odd) assert(0); - if(pow_n % 2 == 1 && num_type_in == PolyType::Even) assert(0); + if(pow_n % 2 == 0 && num_type_in == PolyType::Odd) GRID_ASSERT(0); + if(pow_n % 2 == 1 && num_type_in == PolyType::Even) GRID_ASSERT(0); - if(pow_d % 2 == 0 && den_type_in == PolyType::Odd) assert(0); - if(pow_d % 2 == 1 && den_type_in == PolyType::Even) assert(0); + if(pow_d % 2 == 0 && den_type_in == PolyType::Odd) GRID_ASSERT(0); + if(pow_d % 2 == 1 && den_type_in == PolyType::Even) GRID_ASSERT(0); num_type = num_type_in; den_type = den_type_in; @@ -112,9 +112,9 @@ double AlgRemezGeneral::generateApprox(const int num_degree, const int den_degre equations(); if (delta < tolerance) { std::cout<<"Iteration " << iter-1 << " delta too small (" << delta << "<" << tolerance << "), try increasing precision\n"; - assert(0); + GRID_ASSERT(0); }; - assert( delta>= tolerance ); + GRID_ASSERT( delta>= tolerance ); search(); } @@ -278,7 +278,7 @@ void AlgRemezGeneral::equations(){ if(num_pows[j] != -1){ *aa++ = z; t++; } z *= x; } - assert(t == n+1); + GRID_ASSERT(t == n+1); z = (bigfloat)1l; t = 0; @@ -286,7 +286,7 @@ void AlgRemezGeneral::equations(){ if(den_pows[j] != -1){ *aa++ = -y * z; t++; } z *= x; } - assert(t == d); + GRID_ASSERT(t == d); B[i] = y * z; // Right hand side vector } diff --git a/Grid/algorithms/approx/RemezGeneral.h b/Grid/algorithms/approx/RemezGeneral.h index 92553ca5..f83d3c8f 100644 --- a/Grid/algorithms/approx/RemezGeneral.h +++ b/Grid/algorithms/approx/RemezGeneral.h @@ -106,7 +106,7 @@ class AlgRemezGeneral{ bigfloat (*f)(bigfloat x, void *data), void *data); inline int getDegree(void) const{ - assert(n==d); + GRID_ASSERT(n==d); return n; } // Reset the bounds of the approximation diff --git a/Grid/algorithms/approx/ZMobius.cc b/Grid/algorithms/approx/ZMobius.cc index 65af901f..a7d7d282 100644 --- a/Grid/algorithms/approx/ZMobius.cc +++ b/Grid/algorithms/approx/ZMobius.cc @@ -74,7 +74,7 @@ bigfloat epsilonMobius(bigfloat x, void* data){ void computeZmobiusOmega(std::vector &omega_out, const int Ls_out, const std::vector &omega_in, const int Ls_in, const RealD lambda_bound){ - assert(omega_in.size() == Ls_in); + GRID_ASSERT(omega_in.size() == Ls_in); omega_out.resize(Ls_out); //Use the Remez algorithm to generate the appropriate rational polynomial diff --git a/Grid/algorithms/blas/BatchedBlas.h b/Grid/algorithms/blas/BatchedBlas.h index c1025b59..d79da095 100644 --- a/Grid/algorithms/blas/BatchedBlas.h +++ b/Grid/algorithms/blas/BatchedBlas.h @@ -109,7 +109,7 @@ public: case GridBLAS_PRECISION_TF32: return CUBLAS_COMPUTE_32F_FAST_TF32; default: - assert(0); + GRID_ASSERT(0); } } #endif @@ -134,11 +134,11 @@ public: { #ifdef GRID_HIP auto err = hipDeviceSynchronize(); - assert(err==hipSuccess); + GRID_ASSERT(err==hipSuccess); #endif #ifdef GRID_CUDA auto err = cudaDeviceSynchronize(); - assert(err==cudaSuccess); + GRID_ASSERT(err==cudaSuccess); #endif #ifdef GRID_SYCL accelerator_barrier(); @@ -156,7 +156,7 @@ public: deviceVector &Cmn, GridBLASPrecision_t precision = GridBLAS_PRECISION_DEFAULT) { - assert(precision == GridBLAS_PRECISION_DEFAULT); + GRID_ASSERT(precision == GridBLAS_PRECISION_DEFAULT); gemmBatched(GridBLAS_OP_N,GridBLAS_OP_N, m,n,k, alpha, @@ -221,11 +221,11 @@ public: deviceVector &Cmn, GridBLASPrecision_t precision = GridBLAS_PRECISION_DEFAULT) { - assert(precision == GridBLAS_PRECISION_DEFAULT); + GRID_ASSERT(precision == GridBLAS_PRECISION_DEFAULT); RealD t2=usecond(); int32_t batchCount = Amk.size(); - assert(Bkn.size()==batchCount); - assert(Cmn.size()==batchCount); + GRID_ASSERT(Bkn.size()==batchCount); + GRID_ASSERT(Cmn.size()==batchCount); //assert(OpA!=GridBLAS_OP_T); // Complex case expect no transpose //assert(OpB!=GridBLAS_OP_T); @@ -265,7 +265,7 @@ public: (hipblasDoubleComplex **)&Cmn[0], ldc, batchCount); // std::cout << " hipblas return code " <<(int)err< &Cnn) { int64_t batchCount = Ann.size(); - assert(batchCount == Cnn.size()); + GRID_ASSERT(batchCount == Cnn.size()); thread_for(p,batchCount, { Eigen::Map eAnn(Ann[p],n,n); Eigen::Map eCnn(Cnn[p],n,n); @@ -1015,7 +1015,7 @@ public: deviceVector &Cnn) { int64_t batchCount = Ann.size(); - assert(batchCount == Cnn.size()); + GRID_ASSERT(batchCount == Cnn.size()); thread_for(p,batchCount, { Eigen::Map eAnn(Ann[p],n,n); Eigen::Map eCnn(Cnn[p],n,n); @@ -1028,7 +1028,7 @@ public: deviceVector &C) { int64_t batchCount = Ann.size(); - assert(batchCount == C.size()); + GRID_ASSERT(batchCount == C.size()); thread_for(p,batchCount, { Eigen::Map eAnn(Ann[p],n,n); *C[p] = eAnn.determinant(); @@ -1040,7 +1040,7 @@ public: deviceVector &C) { int64_t batchCount = Ann.size(); - assert(batchCount == C.size()); + GRID_ASSERT(batchCount == C.size()); thread_for(p,batchCount, { Eigen::Map eAnn(Ann[p],n,n); *C[p] = eAnn.determinant(); @@ -1089,8 +1089,8 @@ public: deviceVector &info) { int64_t batchCount = Ann.size(); - assert(ipiv.size()==batchCount*n); - assert(info.size()==batchCount); + GRID_ASSERT(ipiv.size()==batchCount*n); + GRID_ASSERT(info.size()==batchCount); #ifdef GRID_HIP auto err = hipblasZgetrfBatched(gridblasHandle,(int)n, @@ -1098,7 +1098,7 @@ public: (int*) &ipiv[0], (int*) &info[0], (int)batchCount); - assert(err==HIPBLAS_STATUS_SUCCESS); + GRID_ASSERT(err==HIPBLAS_STATUS_SUCCESS); #endif #ifdef GRID_CUDA auto err = cublasZgetrfBatched(gridblasHandle, (int)n, @@ -1106,7 +1106,7 @@ public: (int*) &ipiv[0], (int*) &info[0], (int)batchCount); - assert(err==CUBLAS_STATUS_SUCCESS); + GRID_ASSERT(err==CUBLAS_STATUS_SUCCESS); #endif #ifdef GRID_SYCL getrfBatchedSYCL(n, Ann, ipiv, info); @@ -1119,8 +1119,8 @@ public: deviceVector &info) { int64_t batchCount = Ann.size(); - assert(ipiv.size()==batchCount*n); - assert(info.size()==batchCount); + GRID_ASSERT(ipiv.size()==batchCount*n); + GRID_ASSERT(info.size()==batchCount); #ifdef GRID_HIP auto err = hipblasCgetrfBatched(gridblasHandle,(int)n, @@ -1128,7 +1128,7 @@ public: (int*) &ipiv[0], (int*) &info[0], (int)batchCount); - assert(err==HIPBLAS_STATUS_SUCCESS); + GRID_ASSERT(err==HIPBLAS_STATUS_SUCCESS); #endif #ifdef GRID_CUDA auto err = cublasCgetrfBatched(gridblasHandle, (int)n, @@ -1136,7 +1136,7 @@ public: (int*) &ipiv[0], (int*) &info[0], (int)batchCount); - assert(err==CUBLAS_STATUS_SUCCESS); + GRID_ASSERT(err==CUBLAS_STATUS_SUCCESS); #endif #ifdef GRID_SYCL getrfBatchedSYCL(n, Ann, ipiv, info); @@ -1195,9 +1195,9 @@ public: deviceVector &Cnn) { int64_t batchCount = Ann.size(); - assert(ipiv.size()==batchCount*n); - assert(info.size()==batchCount); - assert(Cnn.size()==batchCount); + GRID_ASSERT(ipiv.size()==batchCount*n); + GRID_ASSERT(info.size()==batchCount); + GRID_ASSERT(Cnn.size()==batchCount); #ifdef GRID_HIP auto err = hipblasZgetriBatched(gridblasHandle,(int)n, @@ -1206,7 +1206,7 @@ public: (hipblasDoubleComplex **)&Cnn[0], (int)n, (int*) &info[0], (int)batchCount); - assert(err==HIPBLAS_STATUS_SUCCESS); + GRID_ASSERT(err==HIPBLAS_STATUS_SUCCESS); #endif #ifdef GRID_CUDA auto err = cublasZgetriBatched(gridblasHandle, (int)n, @@ -1215,7 +1215,7 @@ public: (cuDoubleComplex **)&Cnn[0], (int)n, (int*) &info[0], (int)batchCount); - assert(err==CUBLAS_STATUS_SUCCESS); + GRID_ASSERT(err==CUBLAS_STATUS_SUCCESS); #endif #ifdef GRID_SYCL getriBatchedSYCL(n, Ann, ipiv, info, Cnn); @@ -1229,9 +1229,9 @@ public: deviceVector &Cnn) { int64_t batchCount = Ann.size(); - assert(ipiv.size()==batchCount*n); - assert(info.size()==batchCount); - assert(Cnn.size()==batchCount); + GRID_ASSERT(ipiv.size()==batchCount*n); + GRID_ASSERT(info.size()==batchCount); + GRID_ASSERT(Cnn.size()==batchCount); #ifdef GRID_HIP auto err = hipblasCgetriBatched(gridblasHandle,(int)n, @@ -1240,7 +1240,7 @@ public: (hipblasComplex **)&Cnn[0], (int)n, (int*) &info[0], (int)batchCount); - assert(err==HIPBLAS_STATUS_SUCCESS); + GRID_ASSERT(err==HIPBLAS_STATUS_SUCCESS); #endif #ifdef GRID_CUDA auto err = cublasCgetriBatched(gridblasHandle, (int)n, @@ -1249,7 +1249,7 @@ public: (cuComplex **)&Cnn[0], (int)n, (int*) &info[0], (int)batchCount); - assert(err==CUBLAS_STATUS_SUCCESS); + GRID_ASSERT(err==CUBLAS_STATUS_SUCCESS); #endif #ifdef GRID_SYCL getriBatchedSYCL(n, Ann, ipiv, info, Cnn); diff --git a/Grid/algorithms/deflation/Deflation.h b/Grid/algorithms/deflation/Deflation.h index 1a8f97c9..8dad88ae 100644 --- a/Grid/algorithms/deflation/Deflation.h +++ b/Grid/algorithms/deflation/Deflation.h @@ -69,8 +69,8 @@ public: DeflatedGuesser(const std::vector & _evec, const std::vector & _eval, const unsigned int _N) : evec(_evec), eval(_eval), N(_N) { - assert(evec.size()==eval.size()); - assert(N <= evec.size()); + GRID_ASSERT(evec.size()==eval.size()); + GRID_ASSERT(N <= evec.size()); } virtual void operator()(const Field &src,Field &guess) { @@ -141,11 +141,10 @@ public: } //postprocessing std::cout << GridLogMessage << "Start BlockPromote for loop" << std::endl; - for (int j=0;joSites()/rd0; words = rd0*sizeof(vector_object)/sizeof(scalar); int64_t vw = vol * words; - assert(vw == grid->lSites()*sizeof(scalar_object)/sizeof(scalar)); + GRID_ASSERT(vw == grid->lSites()*sizeof(scalar_object)/sizeof(scalar)); RealD t0 = usecond(); BLAS_X.resize(nrhs * vw); // cost free if size doesn't change diff --git a/Grid/algorithms/deflation/MultiRHSBlockProject.h b/Grid/algorithms/deflation/MultiRHSBlockProject.h index d9b4acb5..8212189c 100644 --- a/Grid/algorithms/deflation/MultiRHSBlockProject.h +++ b/Grid/algorithms/deflation/MultiRHSBlockProject.h @@ -131,12 +131,12 @@ public: typedef typename Field::vector_object vobj; // std::cout << GridLogMessage <<" BlockProjector importing "<_ndimension; - assert(block_vol == fine_grid->oSites() / coarse_grid->oSites()); + GRID_ASSERT(block_vol == fine_grid->oSites() / coarse_grid->oSites()); Coordinate block_r (_ndimension); for(int d=0 ; d<_ndimension;d++){ @@ -164,7 +164,7 @@ public: const int Nsimd = vobj::Nsimd(); // std::cout << "sz "<oSites() * block_vol * nvec * words<oSites() * block_vol * nvec * words); + GRID_ASSERT(sz == Nsimd * coarse_grid->oSites() * block_vol * nvec * words); uint64_t lwords= words; // local variable for copy in to GPU accelerator_for(sf,osites,Nsimd,{ #ifdef GRID_SIMT @@ -198,7 +198,7 @@ public: + v*bv + sb; - // assert(site*lwords_ndimension; - assert(block_vol == fine_grid->oSites() / coarse_grid->oSites()); + GRID_ASSERT(block_vol == fine_grid->oSites() / coarse_grid->oSites()); Coordinate block_r (_ndimension); for(int d=0 ; d<_ndimension;d++){ @@ -299,7 +299,7 @@ public: // std::cout << " BlockProjector importing "<_ndimension; @@ -320,7 +320,7 @@ public: // loop over fine sites const int Nsimd = vobj::Nsimd(); uint64_t cwords=sizeof(typename vobj::scalar_object)/sizeof(scalar); - assert(cwords==nbasis); + GRID_ASSERT(cwords==nbasis); accelerator_for(sc,osites,Nsimd,{ #ifdef GRID_SIMT @@ -353,7 +353,7 @@ public: typedef typename vobj::scalar_object coarse_scalar_object; // std::cout << GridLogMessage<<" BlockProjector exporting "<_ndimension; @@ -375,7 +375,7 @@ public: // loop over fine sites const int Nsimd = vobj::Nsimd(); uint64_t cwords=sizeof(typename vobj::scalar_object)/sizeof(scalar); - assert(cwords==nbasis); + GRID_ASSERT(cwords==nbasis); accelerator_for(sc,osites,Nsimd,{ // Wrap in a macro "FOR_ALL_LANES(lane,{ ... }); @@ -409,7 +409,7 @@ public: int nrhs=fine.size(); int _nbasis = sizeof(typename cobj::scalar_object)/sizeof(scalar); // std::cout << "blockProject nbasis " < &evec,std::vector &_eval, int _ev0, int _nev) { - assert(_ev0+_nev<=evec.size()); + GRID_ASSERT(_ev0+_nev<=evec.size()); Allocate(_nev,evec[0].Grid()); @@ -126,8 +126,8 @@ public: void DeflateSources(std::vector &source,std::vector & guess) { int nrhs = source.size(); - assert(source.size()==guess.size()); - assert(grid == guess[0].Grid()); + GRID_ASSERT(source.size()==guess.size()); + GRID_ASSERT(grid == guess[0].Grid()); conformable(guess[0],source[0]); int64_t vw = vol * words; @@ -189,7 +189,7 @@ public: Cd); BLAS.synchronise(); - assert(BLAS_C.size()==nev*nrhs); + GRID_ASSERT(BLAS_C.size()==nev*nrhs); std::vector HOST_C(BLAS_C.size()); // nrhs . nev -- the coefficients acceleratorCopyFromDevice(&BLAS_C[0],&HOST_C[0],BLAS_C.size()*sizeof(scalar)); diff --git a/Grid/algorithms/iterative/AdefGeneric.h b/Grid/algorithms/iterative/AdefGeneric.h index e0b99fcb..9ae1e611 100644 --- a/Grid/algorithms/iterative/AdefGeneric.h +++ b/Grid/algorithms/iterative/AdefGeneric.h @@ -270,7 +270,7 @@ class TwoLevelCG : public LinearFunction std::vector src_nrm(nrhs); for(int rhs=0;rhs tn(nrhs); diff --git a/Grid/algorithms/iterative/AdefMrhs.h b/Grid/algorithms/iterative/AdefMrhs.h index 810d7391..48034d83 100644 --- a/Grid/algorithms/iterative/AdefMrhs.h +++ b/Grid/algorithms/iterative/AdefMrhs.h @@ -161,7 +161,7 @@ class TwoLevelCGmrhs //////////////////////////////////////////// std::vector ssq(nrhs); for(int rhs=0;rhs &src, std::vector &x) @@ -415,7 +415,7 @@ class TwoLevelCGmrhs std::vector src_nrm(nrhs); for(int rhs=0;rhs tn(nrhs); diff --git a/Grid/algorithms/iterative/BiCGSTAB.h b/Grid/algorithms/iterative/BiCGSTAB.h index f4e5cdda..d5f8c359 100644 --- a/Grid/algorithms/iterative/BiCGSTAB.h +++ b/Grid/algorithms/iterative/BiCGSTAB.h @@ -47,7 +47,7 @@ class BiCGSTAB : public OperatorFunction public: using OperatorFunction::operator(); - bool ErrorOnNoConverge; // throw an assert when the CG fails to converge. + bool ErrorOnNoConverge; // throw an GRID_ASSERT when the CG fails to converge. // Defaults true. RealD Tolerance; Integer MaxIterations; @@ -77,7 +77,7 @@ class BiCGSTAB : public OperatorFunction // Initial residual computation & set up RealD guess = norm2(psi); - assert(std::isnan(guess) == 0); + GRID_ASSERT(std::isnan(guess) == 0); Linop.Op(psi, v); b = norm2(v); @@ -214,7 +214,7 @@ class BiCGSTAB : public OperatorFunction std::cout << GridLogMessage << "\tAxpyNorm " << AxpyNormTimer.Elapsed() << std::endl; std::cout << GridLogMessage << "\tLinearComb " << LinearCombTimer.Elapsed() << std::endl; - if(ErrorOnNoConverge){ assert(true_residual / Tolerance < 10000.0); } + if(ErrorOnNoConverge){ GRID_ASSERT(true_residual / Tolerance < 10000.0); } IterationsToComplete = k; @@ -224,7 +224,7 @@ class BiCGSTAB : public OperatorFunction std::cout << GridLogMessage << "BiCGSTAB did NOT converge" << std::endl; - if(ErrorOnNoConverge){ assert(0); } + if(ErrorOnNoConverge){ GRID_ASSERT(0); } IterationsToComplete = k; } }; diff --git a/Grid/algorithms/iterative/BlockConjugateGradient.h b/Grid/algorithms/iterative/BlockConjugateGradient.h index d194bb06..2497dbf3 100644 --- a/Grid/algorithms/iterative/BlockConjugateGradient.h +++ b/Grid/algorithms/iterative/BlockConjugateGradient.h @@ -98,7 +98,7 @@ class BlockConjugateGradient : public OperatorFunction { int Nblock; BlockCGtype CGtype; - bool ErrorOnNoConverge; // throw an assert when the CG fails to converge. + bool ErrorOnNoConverge; // throw an GRID_ASSERT when the CG fails to converge. // Defaults true. RealD Tolerance; Integer MaxIterations; @@ -201,7 +201,7 @@ void operator()(LinearOperatorBase &Linop, const Field &Src, Field &Psi) } else if (CGtype == CGmultiRHS ) { CGmultiRHSsolve(Linop,Src,Psi); } else { - assert(0); + GRID_ASSERT(0); } } virtual void operator()(LinearOperatorBase &Linop, const std::vector &Src, std::vector &Psi) @@ -209,7 +209,7 @@ virtual void operator()(LinearOperatorBase &Linop, const std::vector &Linop, const Field &B, Field &X) for(int b=0;b &Linop, const Field &B, Field &X) std::cout << GridLogMessage << "BlockConjugateGradient(rQ) did NOT converge "< &Linop, const Field &Src, Field & for(int b=0;b &Linop, const Field &Src, Field & } std::cout << GridLogMessage << "MultiRHSConjugateGradient did NOT converge" << std::endl; - if (ErrorOnNoConverge) assert(0); + if (ErrorOnNoConverge) GRID_ASSERT(0); IterationsToComplete = k; } @@ -554,7 +554,7 @@ void CGmultiRHSsolve(LinearOperatorBase &Linop, const Field &Src, Field & void BlockCGrQsolveVec(LinearOperatorBase &Linop, const std::vector &B, std::vector &X) { Nblock = B.size(); - assert(Nblock == X.size()); + GRID_ASSERT(Nblock == X.size()); std::cout< &Linop, const std::vector &Linop, const std::vector::operator(); - bool ErrorOnNoConverge; // Throw an assert when CAGMRES fails to converge, + bool ErrorOnNoConverge; // Throw an GRID_ASSERT when CAGMRES fails to converge, // defaults to true RealD Tolerance; @@ -82,7 +82,7 @@ class CommunicationAvoidingGeneralisedMinimalResidual : public OperatorFunction< conformable(psi, src); RealD guess = norm2(psi); - assert(std::isnan(guess) == 0); + GRID_ASSERT(std::isnan(guess) == 0); RealD cp; RealD ssq = norm2(src); @@ -137,7 +137,7 @@ class CommunicationAvoidingGeneralisedMinimalResidual : public OperatorFunction< std::cout << GridLogMessage << "CommunicationAvoidingGeneralisedMinimalResidual did NOT converge" << std::endl; if (ErrorOnNoConverge) - assert(0); + GRID_ASSERT(0); } RealD outerLoopBody(LinearOperatorBase &LinOp, const Field &src, Field &psi, RealD rsq) { @@ -185,7 +185,7 @@ class CommunicationAvoidingGeneralisedMinimalResidual : public OperatorFunction< } } - assert(0); // Never reached + GRID_ASSERT(0); // Never reached return cp; } diff --git a/Grid/algorithms/iterative/ConjugateGradient.h b/Grid/algorithms/iterative/ConjugateGradient.h index 65a77d83..75ed11f1 100644 --- a/Grid/algorithms/iterative/ConjugateGradient.h +++ b/Grid/algorithms/iterative/ConjugateGradient.h @@ -45,7 +45,7 @@ public: using OperatorFunction::operator(); - bool ErrorOnNoConverge; // throw an assert when the CG fails to converge. + bool ErrorOnNoConverge; // throw an GRID_ASSERT when the CG fails to converge. // Defaults true. RealD Tolerance; Integer MaxIterations; @@ -94,7 +94,7 @@ public: ssq = norm2(src); RealD guess = norm2(psi); NormTimer.Stop(); - assert(std::isnan(guess) == 0); + GRID_ASSERT(std::isnan(guess) == 0); AssignTimer.Start(); if ( guess == 0.0 ) { r = src; @@ -222,7 +222,7 @@ public: std::cout << GridLogDebug << "\tMobius flop rate " << DwfFlops/ usecs<< " Gflops " < &src_d_in, std::vector &sol_d){ - assert(src_d_in.size() == sol_d.size()); + GRID_ASSERT(src_d_in.size() == sol_d.size()); int NBatch = src_d_in.size(); std::cout << GridLogMessage << "NBatch = " << NBatch << std::endl; diff --git a/Grid/algorithms/iterative/ConjugateGradientMultiShift.h b/Grid/algorithms/iterative/ConjugateGradientMultiShift.h index e00e94c9..4e84593b 100644 --- a/Grid/algorithms/iterative/ConjugateGradientMultiShift.h +++ b/Grid/algorithms/iterative/ConjugateGradientMultiShift.h @@ -98,9 +98,9 @@ public: std::vector alpha(nshift,1.0); std::vector ps(nshift,grid);// Search directions - assert(psi.size()==nshift); - assert(mass.size()==nshift); - assert(mresidual.size()==nshift); + GRID_ASSERT(psi.size()==nshift); + GRID_ASSERT(mass.size()==nshift); + GRID_ASSERT(mresidual.size()==nshift); // remove dynamic sized arrays on stack; 2d is a pain with vector std::vector bs(nshift); @@ -122,7 +122,7 @@ public: // Check lightest mass for(int s=0;s= mass[primary] ); + GRID_ASSERT( mass[s]>= mass[primary] ); converged[s]=0; } @@ -338,7 +338,7 @@ public: } // ugly hack std::cout< bs(nshift); @@ -141,7 +141,7 @@ public: // Check lightest mass for(int s=0;s= mass[primary] ); + GRID_ASSERT( mass[s]>= mass[primary] ); converged[s]=0; } @@ -179,7 +179,7 @@ public: Linop_d.HermOpAndNorm(p_d,mmp_d,d,qq); // mmp = MdagM p d=real(dot(p, mmp)), qq=norm2(mmp) tmp_d = tmp_d - mmp_d; std::cout << " Testing operators match "< &_linop_base, RealD _shift): linop_base(_linop_base), shift(_shift){} - void OpDiag (const Field &in, Field &out){ assert(0); } - void OpDir (const Field &in, Field &out,int dir,int disp){ assert(0); } - void OpDirAll (const Field &in, std::vector &out){ assert(0); } + void OpDiag (const Field &in, Field &out){ GRID_ASSERT(0); } + void OpDir (const Field &in, Field &out,int dir,int disp){ GRID_ASSERT(0); } + void OpDirAll (const Field &in, std::vector &out){ GRID_ASSERT(0); } - void Op (const Field &in, Field &out){ assert(0); } - void AdjOp (const Field &in, Field &out){ assert(0); } + void Op (const Field &in, Field &out){ GRID_ASSERT(0); } + void AdjOp (const Field &in, Field &out){ GRID_ASSERT(0); } void HermOp(const Field &in, Field &out){ linop_base.HermOp(in, out); @@ -151,9 +151,9 @@ public: FieldD r_d(DoublePrecGrid); FieldD mmp_d(DoublePrecGrid); - assert(psi_d.size()==nshift); - assert(mass.size()==nshift); - assert(mresidual.size()==nshift); + GRID_ASSERT(psi_d.size()==nshift); + GRID_ASSERT(mass.size()==nshift); + GRID_ASSERT(mresidual.size()==nshift); // dynamic sized arrays on stack; 2d is a pain with vector std::vector bs(nshift); @@ -174,7 +174,7 @@ public: // Check lightest mass for(int s=0;s= mass[primary] ); + GRID_ASSERT( mass[s]>= mass[primary] ); converged[s]=0; } @@ -211,7 +211,7 @@ public: Linop_d.HermOpAndNorm(p_d,mmp_d,d,qq); // mmp = MdagM p d=real(dot(p, mmp)), qq=norm2(mmp) tmp_d = tmp_d - mmp_d; std::cout << " Testing operators match "<::value == 1, int>::type = 0> class ConjugateGradientReliableUpdate : public LinearFunction { public: - bool ErrorOnNoConverge; // throw an assert when the CG fails to converge. + bool ErrorOnNoConverge; // throw an GRID_ASSERT when the CG fails to converge. // Defaults true. RealD Tolerance; Integer MaxIterations; @@ -66,7 +66,7 @@ public: DoFinalCleanup(true), Linop_fallback(NULL) { - assert(Delta > 0. && Delta < 1. && "Expect 0 < Delta < 1"); + GRID_ASSERT(Delta > 0. && Delta < 1. && "Expect 0 < Delta < 1"); }; void setFallbackLinop(LinearOperatorBase &_Linop_fallback, const RealD _fallback_transition_tol){ @@ -90,7 +90,7 @@ public: // Initial residual computation & set up RealD guess = norm2(psi); - assert(std::isnan(guess) == 0); + GRID_ASSERT(std::isnan(guess) == 0); Linop_d.HermOpAndNorm(psi, mmp, d, b); @@ -217,7 +217,7 @@ public: CG(Linop_d,src,psi); IterationsToCleanup = CG.IterationsToComplete; } - else if (ErrorOnNoConverge) assert(true_residual / Tolerance < 10000.0); + else if (ErrorOnNoConverge) GRID_ASSERT(true_residual / Tolerance < 10000.0); std::cout << GridLogMessage << "ConjugateGradientReliableUpdate complete.\n"; return; @@ -263,7 +263,7 @@ public: std::cout << GridLogMessage << "ConjugateGradientReliableUpdate did NOT converge" << std::endl; - if (ErrorOnNoConverge) assert(0); + if (ErrorOnNoConverge) GRID_ASSERT(0); IterationsToComplete = k; ReliableUpdatesPerformed = l; } diff --git a/Grid/algorithms/iterative/ConjugateResidual.h b/Grid/algorithms/iterative/ConjugateResidual.h index e0c3b69d..ece1b485 100644 --- a/Grid/algorithms/iterative/ConjugateResidual.h +++ b/Grid/algorithms/iterative/ConjugateResidual.h @@ -106,7 +106,7 @@ public: } std::cout<::operator(); - bool ErrorOnNoConverge; // Throw an assert when FCAGMRES fails to converge, + bool ErrorOnNoConverge; // Throw an GRID_ASSERT when FCAGMRES fails to converge, // defaults to true RealD Tolerance; @@ -87,7 +87,7 @@ class FlexibleCommunicationAvoidingGeneralisedMinimalResidual : public OperatorF conformable(psi, src); RealD guess = norm2(psi); - assert(std::isnan(guess) == 0); + GRID_ASSERT(std::isnan(guess) == 0); RealD cp; RealD ssq = norm2(src); @@ -144,7 +144,7 @@ class FlexibleCommunicationAvoidingGeneralisedMinimalResidual : public OperatorF std::cout << GridLogMessage << "FlexibleCommunicationAvoidingGeneralisedMinimalResidual did NOT converge" << std::endl; if (ErrorOnNoConverge) - assert(0); + GRID_ASSERT(0); } RealD outerLoopBody(LinearOperatorBase &LinOp, const Field &src, Field &psi, RealD rsq) { @@ -191,7 +191,7 @@ class FlexibleCommunicationAvoidingGeneralisedMinimalResidual : public OperatorF } } - assert(0); // Never reached + GRID_ASSERT(0); // Never reached return cp; } diff --git a/Grid/algorithms/iterative/FlexibleGeneralisedMinimalResidual.h b/Grid/algorithms/iterative/FlexibleGeneralisedMinimalResidual.h index cf108846..2f0de242 100644 --- a/Grid/algorithms/iterative/FlexibleGeneralisedMinimalResidual.h +++ b/Grid/algorithms/iterative/FlexibleGeneralisedMinimalResidual.h @@ -36,7 +36,7 @@ class FlexibleGeneralisedMinimalResidual : public OperatorFunction { public: using OperatorFunction::operator(); - bool ErrorOnNoConverge; // Throw an assert when FGMRES fails to converge, + bool ErrorOnNoConverge; // Throw an GRID_ASSERT when FGMRES fails to converge, // defaults to true RealD Tolerance; @@ -85,7 +85,7 @@ class FlexibleGeneralisedMinimalResidual : public OperatorFunction { conformable(psi, src); RealD guess = norm2(psi); - assert(std::isnan(guess) == 0); + GRID_ASSERT(std::isnan(guess) == 0); RealD cp; RealD ssq = norm2(src); @@ -142,7 +142,7 @@ class FlexibleGeneralisedMinimalResidual : public OperatorFunction { std::cout << GridLogMessage << "FlexibleGeneralisedMinimalResidual did NOT converge" << std::endl; if (ErrorOnNoConverge) - assert(0); + GRID_ASSERT(0); } RealD outerLoopBody(LinearOperatorBase &LinOp, const Field &src, Field &psi, RealD rsq) { @@ -189,7 +189,7 @@ class FlexibleGeneralisedMinimalResidual : public OperatorFunction { } } - assert(0); // Never reached + GRID_ASSERT(0); // Never reached return cp; } diff --git a/Grid/algorithms/iterative/GeneralisedMinimalResidual.h b/Grid/algorithms/iterative/GeneralisedMinimalResidual.h index 0596e91e..98b891bd 100644 --- a/Grid/algorithms/iterative/GeneralisedMinimalResidual.h +++ b/Grid/algorithms/iterative/GeneralisedMinimalResidual.h @@ -36,7 +36,7 @@ class GeneralisedMinimalResidual : public OperatorFunction { public: using OperatorFunction::operator(); - bool ErrorOnNoConverge; // Throw an assert when GMRES fails to converge, + bool ErrorOnNoConverge; // Throw an GRID_ASSERT when GMRES fails to converge, // defaults to true RealD Tolerance; @@ -80,7 +80,7 @@ class GeneralisedMinimalResidual : public OperatorFunction { conformable(psi, src); RealD guess = norm2(psi); - assert(std::isnan(guess) == 0); + GRID_ASSERT(std::isnan(guess) == 0); RealD cp; RealD ssq = norm2(src); @@ -135,7 +135,7 @@ class GeneralisedMinimalResidual : public OperatorFunction { std::cout << GridLogMessage << "GeneralisedMinimalResidual did NOT converge" << std::endl; if (ErrorOnNoConverge) - assert(0); + GRID_ASSERT(0); } RealD outerLoopBody(LinearOperatorBase &LinOp, const Field &src, Field &psi, RealD rsq) { @@ -181,7 +181,7 @@ class GeneralisedMinimalResidual : public OperatorFunction { } } - assert(0); // Never reached + GRID_ASSERT(0); // Never reached return cp; } diff --git a/Grid/algorithms/iterative/ImplicitlyRestartedBlockLanczos.h b/Grid/algorithms/iterative/ImplicitlyRestartedBlockLanczos.h index c5d00722..8e0641f4 100644 --- a/Grid/algorithms/iterative/ImplicitlyRestartedBlockLanczos.h +++ b/Grid/algorithms/iterative/ImplicitlyRestartedBlockLanczos.h @@ -175,7 +175,7 @@ public: eresid(_eresid), MaxIter(_MaxIter), diagonalisation(_diagonalisation),split_test(0), Nevec_acc(_Nu) - { assert( (Nk%Nu==0) && (Nm%Nu==0) ); }; + { GRID_ASSERT( (Nk%Nu==0) && (Nm%Nu==0) ); }; //////////////////////////////// // Helpers @@ -206,7 +206,7 @@ public: Glog<<"orthogonalize after: "<& evec, int k) { @@ -225,7 +225,7 @@ public: w[i] = w[i] - ip * evec[j]; }} for(int i=0; i<_Nu; ++i) - assert(normalize(w[i],if_print) !=0); + GRID_ASSERT(normalize(w[i],if_print) !=0); } @@ -244,7 +244,7 @@ public: const uint64_t sites = grid->lSites(); int Nbatch = R/Nevec_acc; - assert( R%Nevec_acc == 0 ); + GRID_ASSERT( R%Nevec_acc == 0 ); // Glog << "nBatch, Nevec_acc, R, Nu = " // << Nbatch << "," << Nevec_acc << "," << R << "," << Nu << std::endl; @@ -302,7 +302,7 @@ public: } } for (int i=0; i> lmd(Nu,std::vector(Nm,0.0)); std::vector> lme(Nu,std::vector(Nm,0.0)); @@ -579,8 +579,8 @@ cudaStat = cudaMallocManaged((void **)&evec_acc, Nevec_acc*sites*12*sizeof(CUDA_ { std::string fname = std::string(cname+"::calc_rbl()"); GridBase *grid = evec[0].Grid(); - assert(grid == src[0].Grid()); - assert( Nu = src.size() ); + GRID_ASSERT(grid == src[0].Grid()); + GRID_ASSERT( Nu = src.size() ); int Np = (Nm-Nk); if (Np > 0 && MaxIter > 1) Np /= MaxIter; @@ -607,7 +607,7 @@ cudaStat = cudaMallocManaged((void **)&evec_acc, Nevec_acc*sites*12*sizeof(CUDA_ } Glog << std::string(74,'*') << std::endl; - assert(Nm == evec.size() && Nm == eval.size()); + GRID_ASSERT(Nm == evec.size() && Nm == eval.size()); std::vector> lmd(Nu,std::vector(Nm,0.0)); std::vector> lme(Nu,std::vector(Nm,0.0)); @@ -785,7 +785,7 @@ private: int Nu = w.size(); int Nm = evec.size(); - assert( b < Nm/Nu ); + GRID_ASSERT( b < Nm/Nu ); // GridCartesian *grid = evec[0]._grid; // converts block index to full indicies for an interval [L,R) @@ -796,7 +796,7 @@ private: Glog << "Using split grid"<< std::endl; // LatticeGaugeField s_Umu(SGrid); - assert((Nu%mrhs)==0); + GRID_ASSERT((Nu%mrhs)==0); std::vector in(mrhs,f_grid); Field s_in(sf_grid); @@ -906,7 +906,7 @@ if(split_test){ for (int u=0; u& evec, int k) { @@ -169,7 +169,7 @@ public: w[i] = w[i] - ip * evec[j]; }} for(int i=0; i<_Nu; ++i) - assert(normalize(w[i],if_print) !=0); + GRID_ASSERT(normalize(w[i],if_print) !=0); } void orthogonalize_blockhead(Field& w, std::vector& evec, int k, int Nu) @@ -205,8 +205,8 @@ public: { std::string fname = std::string(cname+"::calc_irbl()"); GridBase *grid = evec[0].Grid(); - assert(grid == src[0].Grid()); - assert( Nu = src.size() ); + GRID_ASSERT(grid == src[0].Grid()); + GRID_ASSERT( Nu = src.size() ); Glog << std::string(74,'*') << std::endl; Glog << fname + " starting iteration 0 / "<< MaxIter<< std::endl; @@ -227,7 +227,7 @@ public: } Glog << std::string(74,'*') << std::endl; - assert(Nm == evec.size() && Nm == eval.size()); + GRID_ASSERT(Nm == evec.size() && Nm == eval.size()); std::vector> lmd(Nu,std::vector(Nm,0.0)); std::vector> lme(Nu,std::vector(Nm,0.0)); @@ -413,8 +413,8 @@ public: { std::string fname = std::string(cname+"::calc_rbl()"); GridBase *grid = evec[0].Grid(); - assert(grid == src[0].Grid()); - assert( Nu = src.size() ); + GRID_ASSERT(grid == src[0].Grid()); + GRID_ASSERT( Nu = src.size() ); int Np = (Nm-Nk); if (Np > 0 && MaxIter > 1) Np /= MaxIter; @@ -441,7 +441,7 @@ public: } Glog << std::string(74,'*') << std::endl; - assert(Nm == evec.size() && Nm == eval.size()); + GRID_ASSERT(Nm == evec.size() && Nm == eval.size()); std::vector> lmd(Nu,std::vector(Nm,0.0)); std::vector> lme(Nu,std::vector(Nm,0.0)); @@ -622,7 +622,7 @@ private: int Nu = w.size(); int Nm = evec.size(); - assert( b < Nm/Nu ); + GRID_ASSERT( b < Nm/Nu ); // converts block index to full indicies for an interval [L,R) int L = Nu*b; @@ -630,7 +630,7 @@ private: Real beta; - assert((Nu%mrhs)==0); + GRID_ASSERT((Nu%mrhs)==0); std::vector in(mrhs,f_grid); std::vector out(mrhs,f_grid); @@ -711,7 +711,7 @@ private: for (int u=0; u& eval, std::vector& evec, const Field& src, int& Nconv, bool reverse=false) { GridBase *grid = src.Grid(); - assert(grid == evec[0].Grid()); + GRID_ASSERT(grid == evec[0].Grid()); // GridLogIRL.TimingMode(1); std::cout << GridLogIRL <<"**************************************************************************"<< std::endl; @@ -231,7 +231,7 @@ until convergence } std::cout << GridLogIRL <<"**************************************************************************"<< std::endl; - assert(Nm <= evec.size() && Nm <= eval.size()); + GRID_ASSERT(Nm <= evec.size() && Nm <= eval.size()); // quickly get an idea of the largest eigenvalue to more properly normalize the residuum RealD evalMaxApprox = 0.0; @@ -337,7 +337,7 @@ until convergence } std::cout<0); + GRID_ASSERT(k20); basisRotate(evec,Qt,k1-1,k2+1,0,Nm,Nm); /// big constraint on the basis std::cout<& lmd, } } #else - assert(0); + GRID_ASSERT(0); #endif } diff --git a/Grid/algorithms/iterative/LocalCoherenceLanczos.h b/Grid/algorithms/iterative/LocalCoherenceLanczos.h index 344a785a..f7da43c1 100644 --- a/Grid/algorithms/iterative/LocalCoherenceLanczos.h +++ b/Grid/algorithms/iterative/LocalCoherenceLanczos.h @@ -80,7 +80,7 @@ public: ProjectedHermOp(LinearOperatorBase& linop, std::vector & _subspace) : _Linop(linop), subspace(_subspace) { - assert(subspace.size() >0); + GRID_ASSERT(subspace.size() >0); }; void operator()(const CoarseField& in, CoarseField& out) { @@ -346,12 +346,12 @@ public: void testFine(RealD resid) { - assert(evals_fine.size() == nbasis); - assert(subspace.size() == nbasis); + GRID_ASSERT(evals_fine.size() == nbasis); + GRID_ASSERT(subspace.size() == nbasis); PlainHermOp Op(_FineOp); ImplicitlyRestartedLanczosHermOpTester SimpleTester(Op); for(int k=0;k Cheby(cheby_parms); FunctionHermOp ChebyOp(Cheby,_FineOp); PlainHermOp Op(_FineOp); @@ -400,8 +400,8 @@ public: IRL.calc(evals_fine,subspace,src,Nconv,false); // Shrink down to number saved - assert(Nstop>=nbasis); - assert(Nconv>=nbasis); + GRID_ASSERT(Nstop>=nbasis); + GRID_ASSERT(Nconv>=nbasis); evals_fine.resize(nbasis); subspace.resize(nbasis,_FineGrid); } @@ -433,7 +433,7 @@ public: ImplicitlyRestartedLanczos IRL(ChebyOp,ChebyOp,ChebySmoothTester,Nstop,Nk,Nm,resid,MaxIt,betastp,MinRes); int Nconv=0; IRL.calc(evals_coarse,evec_coarse,src,Nconv,false); - assert(Nconv>=Nstop); + GRID_ASSERT(Nconv>=Nstop); evals_coarse.resize(Nstop); evec_coarse.resize (Nstop,_CoarseGrid); for (int i=0;i class MinimalResidual : public OperatorFunction { public: using OperatorFunction::operator(); - bool ErrorOnNoConverge; // throw an assert when the MR fails to converge. + bool ErrorOnNoConverge; // throw an GRID_ASSERT when the MR fails to converge. // Defaults true. RealD Tolerance; Integer MaxIterations; @@ -59,7 +59,7 @@ template class MinimalResidual : public OperatorFunction { // Initial residual computation & set up RealD guess = norm2(psi); - assert(std::isnan(guess) == 0); + GRID_ASSERT(std::isnan(guess) == 0); RealD ssq = norm2(src); RealD rsq = Tolerance * Tolerance * ssq; @@ -136,7 +136,7 @@ template class MinimalResidual : public OperatorFunction { std::cout << GridLogMessage << "MR Time elapsed: Linalg " << LinalgTimer.Elapsed() << std::endl; if (ErrorOnNoConverge) - assert(true_residual / Tolerance < 10000.0); + GRID_ASSERT(true_residual / Tolerance < 10000.0); IterationsToComplete = k; @@ -148,7 +148,7 @@ template class MinimalResidual : public OperatorFunction { << std::endl; if (ErrorOnNoConverge) - assert(0); + GRID_ASSERT(0); IterationsToComplete = k; } diff --git a/Grid/algorithms/iterative/MixedPrecisionFlexibleGeneralisedMinimalResidual.h b/Grid/algorithms/iterative/MixedPrecisionFlexibleGeneralisedMinimalResidual.h index d75fdb63..7a297836 100644 --- a/Grid/algorithms/iterative/MixedPrecisionFlexibleGeneralisedMinimalResidual.h +++ b/Grid/algorithms/iterative/MixedPrecisionFlexibleGeneralisedMinimalResidual.h @@ -37,7 +37,7 @@ class MixedPrecisionFlexibleGeneralisedMinimalResidual : public OperatorFunction using OperatorFunction::operator(); - bool ErrorOnNoConverge; // Throw an assert when MPFGMRES fails to converge, + bool ErrorOnNoConverge; // Throw an GRID_ASSERT when MPFGMRES fails to converge, // defaults to true RealD Tolerance; @@ -91,7 +91,7 @@ class MixedPrecisionFlexibleGeneralisedMinimalResidual : public OperatorFunction conformable(psi, src); RealD guess = norm2(psi); - assert(std::isnan(guess) == 0); + GRID_ASSERT(std::isnan(guess) == 0); RealD cp; RealD ssq = norm2(src); @@ -150,7 +150,7 @@ class MixedPrecisionFlexibleGeneralisedMinimalResidual : public OperatorFunction std::cout << GridLogMessage << "MPFGMRES did NOT converge" << std::endl; if (ErrorOnNoConverge) - assert(0); + GRID_ASSERT(0); } RealD outerLoopBody(LinearOperatorBase &LinOp, const FieldD &src, FieldD &psi, RealD rsq) { @@ -197,7 +197,7 @@ class MixedPrecisionFlexibleGeneralisedMinimalResidual : public OperatorFunction } } - assert(0); // Never reached + GRID_ASSERT(0); // Never reached return cp; } diff --git a/Grid/algorithms/iterative/PrecConjugateResidual.h b/Grid/algorithms/iterative/PrecConjugateResidual.h index b6178833..91f41495 100644 --- a/Grid/algorithms/iterative/PrecConjugateResidual.h +++ b/Grid/algorithms/iterative/PrecConjugateResidual.h @@ -112,7 +112,7 @@ public: } std::cout<(mmax-1))?(mmax-1):(kp); // if more than mmax done, we orthog all mmax history. for(int back=0;back=0); + int peri_back=(k-back)%mmax; GRID_ASSERT((k-back)>=0); b=-real(innerProduct(q[peri_back],Az))/qq[peri_back]; p[peri_kp]=p[peri_kp]+b*p[peri_back]; @@ -231,7 +231,7 @@ public: qq[peri_kp]=norm2(q[peri_kp]); // could use axpy_norm LinalgTimer.Stop(); } - assert(0); // never reached + GRID_ASSERT(0); // never reached return cp; } }; diff --git a/Grid/algorithms/iterative/PrecGeneralisedConjugateResidualNonHermitian.h b/Grid/algorithms/iterative/PrecGeneralisedConjugateResidualNonHermitian.h index 21ac66b9..0c6d41d6 100644 --- a/Grid/algorithms/iterative/PrecGeneralisedConjugateResidualNonHermitian.h +++ b/Grid/algorithms/iterative/PrecGeneralisedConjugateResidualNonHermitian.h @@ -113,7 +113,7 @@ public: } GCRLogLevel<<"Variable Preconditioned GCR did not converge"<(mmax-1))?(mmax-1):(kp); // if more than mmax done, we orthog all mmax history. for(int back=0;back=0); + int peri_back=(k-back)%mmax; GRID_ASSERT((k-back)>=0); b=-real(innerProduct(q[peri_back],Az))/qq[peri_back]; p[peri_kp]=p[peri_kp]+b*p[peri_back]; @@ -234,7 +234,7 @@ public: qq[peri_kp]=norm2(q[peri_kp]); // could use axpy_norm LinalgTimer.Stop(); } - assert(0); // never reached + GRID_ASSERT(0); // never reached return cp; } }; diff --git a/Grid/algorithms/iterative/QuasiMinimalResidual.h b/Grid/algorithms/iterative/QuasiMinimalResidual.h index ea5531b6..97a82cf9 100644 --- a/Grid/algorithms/iterative/QuasiMinimalResidual.h +++ b/Grid/algorithms/iterative/QuasiMinimalResidual.h @@ -79,7 +79,7 @@ class QuasiMinimalResidual : public OperatorFunction { LinOp.Op(x,r); r = b - r; - assert(normb> 0.0); + GRID_ASSERT(normb> 0.0); resid = norm2(r)/normb; if (resid <= Tolerance) { @@ -105,8 +105,8 @@ class QuasiMinimalResidual : public OperatorFunction { for (int i = 1; i <= MaxIterations; i++) { // Breakdown tests - assert( rho != 0.0); - assert( xi != 0.0); + GRID_ASSERT( rho != 0.0); + GRID_ASSERT( xi != 0.0); v = (1. / rho) * v_tld; y = (1. / rho) * y; @@ -134,10 +134,10 @@ class QuasiMinimalResidual : public OperatorFunction { ep=Zep.real(); std::cout << "Zep "<0); + GRID_ASSERT(abs(ep)>0); beta = ep / delta; - assert(abs(beta)>0); + GRID_ASSERT(abs(beta)>0); v_tld = p_tld - beta * v; y = v_tld; @@ -158,7 +158,7 @@ class QuasiMinimalResidual : public OperatorFunction { std::cout << "theta "< 0.0); + GRID_ASSERT(abs(gamma)> 0.0); eta = -eta * rho_1 * gamma* gamma / (beta * gamma_1 * gamma_1); @@ -178,7 +178,7 @@ class QuasiMinimalResidual : public OperatorFunction { } std::cout << "Iteration "< _HermOpEO(_Matrix); - this->_HermitianRBSolver(_HermOpEO,src_o,sol_o); assert(sol_o.Checkerboard()==Odd); + this->_HermitianRBSolver(_HermOpEO,src_o,sol_o); GRID_ASSERT(sol_o.Checkerboard()==Odd); }; virtual void RedBlackSolve (Matrix & _Matrix,const std::vector &src_o, std::vector &sol_o) { @@ -396,13 +396,13 @@ namespace Grid { ///////////////////////////////////////////////////// // src_o = Mdag * (source_o - Moe MeeInv source_e) ///////////////////////////////////////////////////// - _Matrix.MooeeInv(src_e,tmp); assert( tmp.Checkerboard() ==Even); - _Matrix.Meooe (tmp,Mtmp); assert( Mtmp.Checkerboard() ==Odd); - tmp=src_o-Mtmp; assert( tmp.Checkerboard() ==Odd); + _Matrix.MooeeInv(src_e,tmp); GRID_ASSERT( tmp.Checkerboard() ==Even); + _Matrix.Meooe (tmp,Mtmp); GRID_ASSERT( Mtmp.Checkerboard() ==Odd); + tmp=src_o-Mtmp; GRID_ASSERT( tmp.Checkerboard() ==Odd); // get the right MpcDag SchurDiagMooeeOperator _HermOpEO(_Matrix); - _HermOpEO.MpcDag(tmp,src_o); assert(src_o.Checkerboard() ==Odd); + _HermOpEO.MpcDag(tmp,src_o); GRID_ASSERT(src_o.Checkerboard() ==Odd); } virtual void RedBlackSolution(Matrix & _Matrix,const Field &sol_o, const Field &src_e,Field &sol) @@ -416,17 +416,17 @@ namespace Grid { /////////////////////////////////////////////////// // sol_e = M_ee^-1 * ( src_e - Meo sol_o )... /////////////////////////////////////////////////// - _Matrix.Meooe(sol_o,tmp); assert( tmp.Checkerboard() ==Even); - src_e_i = src_e-tmp; assert( src_e_i.Checkerboard() ==Even); - _Matrix.MooeeInv(src_e_i,sol_e); assert( sol_e.Checkerboard() ==Even); + _Matrix.Meooe(sol_o,tmp); GRID_ASSERT( tmp.Checkerboard() ==Even); + src_e_i = src_e-tmp; GRID_ASSERT( src_e_i.Checkerboard() ==Even); + _Matrix.MooeeInv(src_e_i,sol_e); GRID_ASSERT( sol_e.Checkerboard() ==Even); - setCheckerboard(sol,sol_e); assert( sol_e.Checkerboard() ==Even); - setCheckerboard(sol,sol_o); assert( sol_o.Checkerboard() ==Odd ); + setCheckerboard(sol,sol_e); GRID_ASSERT( sol_e.Checkerboard() ==Even); + setCheckerboard(sol,sol_o); GRID_ASSERT( sol_o.Checkerboard() ==Odd ); } virtual void RedBlackSolve (Matrix & _Matrix,const Field &src_o, Field &sol_o) { SchurDiagMooeeOperator _HermOpEO(_Matrix); - this->_HermitianRBSolver(_HermOpEO,src_o,sol_o); assert(sol_o.Checkerboard()==Odd); + this->_HermitianRBSolver(_HermOpEO,src_o,sol_o); GRID_ASSERT(sol_o.Checkerboard()==Odd); }; virtual void RedBlackSolve (Matrix & _Matrix,const std::vector &src_o, std::vector &sol_o) { @@ -461,9 +461,9 @@ namespace Grid { ///////////////////////////////////////////////////// // src_o = Mdag * (source_o - Moe MeeInv source_e) ///////////////////////////////////////////////////// - _Matrix.MooeeInv(src_e, tmp); assert( tmp.Checkerboard() == Even ); - _Matrix.Meooe (tmp, Mtmp); assert( Mtmp.Checkerboard() == Odd ); - src_o -= Mtmp; assert( src_o.Checkerboard() == Odd ); + _Matrix.MooeeInv(src_e, tmp); GRID_ASSERT( tmp.Checkerboard() == Even ); + _Matrix.Meooe (tmp, Mtmp); GRID_ASSERT( Mtmp.Checkerboard() == Odd ); + src_o -= Mtmp; GRID_ASSERT( src_o.Checkerboard() == Odd ); } virtual void RedBlackSolution(Matrix& _Matrix, const Field& sol_o, const Field& src_e, Field& sol) @@ -478,18 +478,18 @@ namespace Grid { /////////////////////////////////////////////////// // sol_e = M_ee^-1 * ( src_e - Meo sol_o )... /////////////////////////////////////////////////// - _Matrix.Meooe(sol_o, tmp); assert( tmp.Checkerboard() == Even ); - src_e_i = src_e - tmp; assert( src_e_i.Checkerboard() == Even ); - _Matrix.MooeeInv(src_e_i, sol_e); assert( sol_e.Checkerboard() == Even ); + _Matrix.Meooe(sol_o, tmp); GRID_ASSERT( tmp.Checkerboard() == Even ); + src_e_i = src_e - tmp; GRID_ASSERT( src_e_i.Checkerboard() == Even ); + _Matrix.MooeeInv(src_e_i, sol_e); GRID_ASSERT( sol_e.Checkerboard() == Even ); - setCheckerboard(sol, sol_e); assert( sol_e.Checkerboard() == Even ); - setCheckerboard(sol, sol_o); assert( sol_o.Checkerboard() == Odd ); + setCheckerboard(sol, sol_e); GRID_ASSERT( sol_e.Checkerboard() == Even ); + setCheckerboard(sol, sol_o); GRID_ASSERT( sol_o.Checkerboard() == Odd ); } virtual void RedBlackSolve(Matrix& _Matrix, const Field& src_o, Field& sol_o) { NonHermitianSchurDiagMooeeOperator _OpEO(_Matrix); - this->_HermitianRBSolver(_OpEO, src_o, sol_o); assert(sol_o.Checkerboard() == Odd); + this->_HermitianRBSolver(_OpEO, src_o, sol_o); GRID_ASSERT(sol_o.Checkerboard() == Odd); } virtual void RedBlackSolve(Matrix& _Matrix, const std::vector& src_o, std::vector& sol_o) @@ -539,13 +539,13 @@ namespace Grid { ///////////////////////////////////////////////////// // src_o = Mpcdag *MooeeInv * (source_o - Moe MeeInv source_e) ///////////////////////////////////////////////////// - _Matrix.MooeeInv(src_e,tmp); assert( tmp.Checkerboard() ==Even); - _Matrix.Meooe (tmp,Mtmp); assert( Mtmp.Checkerboard() ==Odd); + _Matrix.MooeeInv(src_e,tmp); GRID_ASSERT( tmp.Checkerboard() ==Even); + _Matrix.Meooe (tmp,Mtmp); GRID_ASSERT( Mtmp.Checkerboard() ==Odd); Mtmp=src_o-Mtmp; - _Matrix.MooeeInv(Mtmp,tmp); assert( tmp.Checkerboard() ==Odd); + _Matrix.MooeeInv(Mtmp,tmp); GRID_ASSERT( tmp.Checkerboard() ==Odd); // get the right MpcDag - _HermOpEO.MpcDag(tmp,src_o); assert(src_o.Checkerboard() ==Odd); + _HermOpEO.MpcDag(tmp,src_o); GRID_ASSERT(src_o.Checkerboard() ==Odd); } virtual void RedBlackSolution(Matrix & _Matrix,const Field &sol_o, const Field &src_e,Field &sol) @@ -560,12 +560,12 @@ namespace Grid { /////////////////////////////////////////////////// // sol_e = M_ee^-1 * ( src_e - Meo sol_o )... /////////////////////////////////////////////////// - _Matrix.Meooe(sol_o,tmp); assert( tmp.Checkerboard() ==Even); - tmp = src_e-tmp; assert( src_e.Checkerboard() ==Even); - _Matrix.MooeeInv(tmp,sol_e); assert( sol_e.Checkerboard() ==Even); + _Matrix.Meooe(sol_o,tmp); GRID_ASSERT( tmp.Checkerboard() ==Even); + tmp = src_e-tmp; GRID_ASSERT( src_e.Checkerboard() ==Even); + _Matrix.MooeeInv(tmp,sol_e); GRID_ASSERT( sol_e.Checkerboard() ==Even); - setCheckerboard(sol,sol_e); assert( sol_e.Checkerboard() ==Even); - setCheckerboard(sol,sol_o); assert( sol_o.Checkerboard() ==Odd ); + setCheckerboard(sol,sol_e); GRID_ASSERT( sol_e.Checkerboard() ==Even); + setCheckerboard(sol,sol_o); GRID_ASSERT( sol_o.Checkerboard() ==Odd ); }; virtual void RedBlackSolve (Matrix & _Matrix,const Field &src_o, Field &sol_o) @@ -612,12 +612,12 @@ namespace Grid { ///////////////////////////////////////////////////// // src_o = Mdag * (source_o - Moe MeeInv source_e) ///////////////////////////////////////////////////// - _Matrix.MooeeInv(src_e,tmp); assert( tmp.Checkerboard() ==Even); - _Matrix.Meooe (tmp,Mtmp); assert( Mtmp.Checkerboard() ==Odd); - tmp=src_o-Mtmp; assert( tmp.Checkerboard() ==Odd); + _Matrix.MooeeInv(src_e,tmp); GRID_ASSERT( tmp.Checkerboard() ==Even); + _Matrix.Meooe (tmp,Mtmp); GRID_ASSERT( Mtmp.Checkerboard() ==Odd); + tmp=src_o-Mtmp; GRID_ASSERT( tmp.Checkerboard() ==Odd); // get the right MpcDag - _HermOpEO.MpcDag(tmp,src_o); assert(src_o.Checkerboard() ==Odd); + _HermOpEO.MpcDag(tmp,src_o); GRID_ASSERT(src_o.Checkerboard() ==Odd); } virtual void RedBlackSolution(Matrix & _Matrix,const Field &sol_o, const Field &src_e,Field &sol) @@ -638,12 +638,12 @@ namespace Grid { /////////////////////////////////////////////////// // sol_e = M_ee^-1 * ( src_e - Meo sol_o )... /////////////////////////////////////////////////// - _Matrix.Meooe(sol_o_i,tmp); assert( tmp.Checkerboard() ==Even); - tmp = src_e-tmp; assert( src_e.Checkerboard() ==Even); - _Matrix.MooeeInv(tmp,sol_e); assert( sol_e.Checkerboard() ==Even); + _Matrix.Meooe(sol_o_i,tmp); GRID_ASSERT( tmp.Checkerboard() ==Even); + tmp = src_e-tmp; GRID_ASSERT( src_e.Checkerboard() ==Even); + _Matrix.MooeeInv(tmp,sol_e); GRID_ASSERT( sol_e.Checkerboard() ==Even); - setCheckerboard(sol,sol_e); assert( sol_e.Checkerboard() ==Even); - setCheckerboard(sol,sol_o_i); assert( sol_o_i.Checkerboard() ==Odd ); + setCheckerboard(sol,sol_e); GRID_ASSERT( sol_e.Checkerboard() ==Even); + setCheckerboard(sol,sol_o_i); GRID_ASSERT( sol_o_i.Checkerboard() ==Odd ); }; virtual void RedBlackSolve (Matrix & _Matrix,const Field &src_o, Field &sol_o) @@ -684,9 +684,9 @@ namespace Grid { ///////////////////////////////////////////////////// // src_o = Mdag * (source_o - Moe MeeInv source_e) ///////////////////////////////////////////////////// - _Matrix.MooeeInv(src_e, tmp); assert( tmp.Checkerboard() == Even ); - _Matrix.Meooe (tmp, Mtmp); assert( Mtmp.Checkerboard() == Odd ); - src_o -= Mtmp; assert( src_o.Checkerboard() == Odd ); + _Matrix.MooeeInv(src_e, tmp); GRID_ASSERT( tmp.Checkerboard() == Even ); + _Matrix.Meooe (tmp, Mtmp); GRID_ASSERT( Mtmp.Checkerboard() == Odd ); + src_o -= Mtmp; GRID_ASSERT( src_o.Checkerboard() == Odd ); } virtual void RedBlackSolution(Matrix& _Matrix, const Field& sol_o, const Field& src_e, Field& sol) @@ -707,12 +707,12 @@ namespace Grid { /////////////////////////////////////////////////// // sol_e = M_ee^-1 * ( src_e - Meo sol_o )... /////////////////////////////////////////////////// - _Matrix.Meooe(sol_o_i, tmp); assert( tmp.Checkerboard() == Even ); - tmp = src_e - tmp; assert( src_e.Checkerboard() == Even ); - _Matrix.MooeeInv(tmp, sol_e); assert( sol_e.Checkerboard() == Even ); + _Matrix.Meooe(sol_o_i, tmp); GRID_ASSERT( tmp.Checkerboard() == Even ); + tmp = src_e - tmp; GRID_ASSERT( src_e.Checkerboard() == Even ); + _Matrix.MooeeInv(tmp, sol_e); GRID_ASSERT( sol_e.Checkerboard() == Even ); - setCheckerboard(sol, sol_e); assert( sol_e.Checkerboard() == Even ); - setCheckerboard(sol, sol_o_i); assert( sol_o_i.Checkerboard() == Odd ); + setCheckerboard(sol, sol_e); GRID_ASSERT( sol_e.Checkerboard() == Even ); + setCheckerboard(sol, sol_o_i); GRID_ASSERT( sol_o_i.Checkerboard() == Odd ); }; virtual void RedBlackSolve(Matrix& _Matrix, const Field& src_o, Field& sol_o) diff --git a/Grid/algorithms/multigrid/Aggregates.h b/Grid/algorithms/multigrid/Aggregates.h index 4a4c4816..bb73135a 100644 --- a/Grid/algorithms/multigrid/Aggregates.h +++ b/Grid/algorithms/multigrid/Aggregates.h @@ -292,7 +292,7 @@ public: } } - assert(b==nn); + GRID_ASSERT(b==nn); } diff --git a/Grid/algorithms/multigrid/CoarsenedMatrix.h b/Grid/algorithms/multigrid/CoarsenedMatrix.h index 60a5920c..aff84988 100644 --- a/Grid/algorithms/multigrid/CoarsenedMatrix.h +++ b/Grid/algorithms/multigrid/CoarsenedMatrix.h @@ -309,7 +309,7 @@ public: if ((out.size()!=ndir)&&(out.size()!=ndir+1)) { std::cout <<"MdirAll out size "<< out.size()<_isCheckerBoarded) { @@ -406,7 +406,7 @@ public: Aself = (inv) ? &AselfInv : &A[geom.npoint-1]; DselfInternal(Stencil, *Aself, in, out, dag); } - assert(Aself != nullptr); + GRID_ASSERT(Aself != nullptr); } void DselfInternal(CartesianStencil &st, CoarseMatrix &a, @@ -697,7 +697,7 @@ public: evenmask = where(mod(bcb,2)==(Integer)0,one,zero); oddmask = one-evenmask; - assert(self_stencil!=-1); + GRID_ASSERT(self_stencil!=-1); for(int i=0;i &out){assert(0);}; }; diff --git a/Grid/algorithms/multigrid/GeneralCoarsenedMatrixMultiRHS.h b/Grid/algorithms/multigrid/GeneralCoarsenedMatrixMultiRHS.h index 98f4b22c..c5de17a4 100644 --- a/Grid/algorithms/multigrid/GeneralCoarsenedMatrixMultiRHS.h +++ b/Grid/algorithms/multigrid/GeneralCoarsenedMatrixMultiRHS.h @@ -80,12 +80,12 @@ public: // Can be used to do I/O on the operator matrices externally void SetMatrix (int p,CoarseMatrix & A) { - assert(A.size()==geom_srhs.npoint); + GRID_ASSERT(A.size()==geom_srhs.npoint); GridtoBLAS(A[p],BLAS_A[p]); } void GetMatrix (int p,CoarseMatrix & A) { - assert(A.size()==geom_srhs.npoint); + GRID_ASSERT(A.size()==geom_srhs.npoint); BLAStoGrid(A[p],BLAS_A[p]); } void CopyMatrix (GeneralCoarseOp &_Op) @@ -178,14 +178,14 @@ public: for(int32_t point = 0 ; point < geom.npoint; point++){ int i=s*orhs*geom.npoint+point; int32_t nbr = Stencil._entries[i]._offset*CComplex::Nsimd(); // oSite -> lSite - assert(nbr void GridtoBLAS(const Lattice &from,deviceVector &to) { @@ -194,7 +194,7 @@ public: typedef typename vobj::vector_type vector_type; GridBase *Fg = from.Grid(); - assert(!Fg->_isCheckerBoarded); + GRID_ASSERT(!Fg->_isCheckerBoarded); int nd = Fg->_ndimension; to.resize(Fg->lSites()); @@ -241,10 +241,10 @@ public: typedef typename vobj::vector_type vector_type; GridBase *Tg = grid.Grid(); - assert(!Tg->_isCheckerBoarded); + GRID_ASSERT(!Tg->_isCheckerBoarded); int nd = Tg->_ndimension; - assert(in.size()==Tg->lSites()); + GRID_ASSERT(in.size()==Tg->lSites()); Coordinate LocalLatt = Tg->LocalDimensions(); size_t nsite = 1; @@ -669,7 +669,7 @@ Grid : Message : 328.193436 s : CoarsenOperator mat 122213270 us const int Nsimd = CComplex::Nsimd(); int64_t nrhs =pin.Grid()->GlobalDimensions()[0]; - assert(nrhs>=1); + GRID_ASSERT(nrhs>=1); RealD flops,bytes; int64_t osites=in.Grid()->oSites(); // unpadded @@ -721,7 +721,7 @@ Grid : Message : 328.193436 s : CoarsenOperator mat 122213270 us // std::cout << GridLogMessage<<"Coarse overall flops/s "<< flops/t_tot<<" mflop/s"< &out){assert(0);}; }; diff --git a/Grid/algorithms/multigrid/Geometry.h b/Grid/algorithms/multigrid/Geometry.h index e239484a..11942d94 100644 --- a/Grid/algorithms/multigrid/Geometry.h +++ b/Grid/algorithms/multigrid/Geometry.h @@ -67,8 +67,8 @@ public: } int point(int dir, int disp) { - assert(disp == -1 || disp == 0 || disp == 1); - assert(base+0 <= dir && dir < base+4); + GRID_ASSERT(disp == -1 || disp == 0 || disp == 1); + GRID_ASSERT(base+0 <= dir && dir < base+4); // directions faster index = new indexing // 4d (base = 0): @@ -131,7 +131,7 @@ public: return p; } } - assert(0); + GRID_ASSERT(0); return -1; } void BuildShifts(void) diff --git a/Grid/allocator/AlignedAllocator.h b/Grid/allocator/AlignedAllocator.h index 316f201c..648b6d90 100644 --- a/Grid/allocator/AlignedAllocator.h +++ b/Grid/allocator/AlignedAllocator.h @@ -57,7 +57,7 @@ public: if ( (_Tp*)ptr == (_Tp *) NULL ) { printf("Grid CPU Allocator got NULL for %lu bytes\n",(unsigned long) bytes ); } - assert( ( (_Tp*)ptr != (_Tp *)NULL ) ); + GRID_ASSERT( ( (_Tp*)ptr != (_Tp *)NULL ) ); return ptr; } @@ -106,7 +106,7 @@ public: if ( (_Tp*)ptr == (_Tp *) NULL ) { printf("Grid Shared Allocator got NULL for %lu bytes\n",(unsigned long) bytes ); } - assert( ( (_Tp*)ptr != (_Tp *)NULL ) ); + GRID_ASSERT( ( (_Tp*)ptr != (_Tp *)NULL ) ); return ptr; } @@ -154,7 +154,7 @@ public: if ( (_Tp*)ptr == (_Tp *) NULL ) { printf("Grid Device Allocator got NULL for %lu bytes\n",(unsigned long) bytes ); } - assert( ( (_Tp*)ptr != (_Tp *)NULL ) ); + GRID_ASSERT( ( (_Tp*)ptr != (_Tp *)NULL ) ); return ptr; } diff --git a/Grid/allocator/MemoryManager.cc b/Grid/allocator/MemoryManager.cc index 30a24c9c..008313b8 100644 --- a/Grid/allocator/MemoryManager.cc +++ b/Grid/allocator/MemoryManager.cc @@ -292,7 +292,7 @@ void *MemoryManager::Insert(void *ptr,size_t bytes,int type) void *MemoryManager::Insert(void *ptr,size_t bytes,AllocationCacheEntry *entries,int ncache,int &victim, uint64_t &cacheBytes) { #ifdef GRID_OMP - assert(omp_in_parallel()==0); + GRID_ASSERT(omp_in_parallel()==0); #endif if (ncache == 0) return ptr; @@ -345,7 +345,7 @@ void *MemoryManager::Lookup(size_t bytes,int type) void *MemoryManager::Lookup(size_t bytes,AllocationCacheEntry *entries,int ncache,uint64_t & cacheBytes) { #ifdef GRID_OMP - assert(omp_in_parallel()==0); + GRID_ASSERT(omp_in_parallel()==0); #endif for(int e=0;e CpuPtr %lx",(uint64_t)AccCache.bytes,(uint64_t)AccCache.AccPtr,(uint64_t)AccCache.CpuPtr); fflush(stdout); DeviceToHostBytes+=AccCache.bytes; @@ -175,10 +175,10 @@ void MemoryManager::Flush(AcceleratorViewEntry &AccCache) } void MemoryManager::Clone(AcceleratorViewEntry &AccCache) { - assert(AccCache.state==CpuDirty); - assert(AccCache.cpuLock==0); - assert(AccCache.accLock==0); - assert(AccCache.CpuPtr!=(uint64_t)NULL); + GRID_ASSERT(AccCache.state==CpuDirty); + GRID_ASSERT(AccCache.cpuLock==0); + GRID_ASSERT(AccCache.accLock==0); + GRID_ASSERT(AccCache.CpuPtr!=(uint64_t)NULL); if(AccCache.AccPtr==(uint64_t)NULL){ AccCache.AccPtr=(uint64_t)AcceleratorAllocate(AccCache.bytes); DeviceBytes+=AccCache.bytes; @@ -194,10 +194,10 @@ void MemoryManager::Clone(AcceleratorViewEntry &AccCache) void MemoryManager::CpuDiscard(AcceleratorViewEntry &AccCache) { - assert(AccCache.state!=Empty); - assert(AccCache.cpuLock==0); - assert(AccCache.accLock==0); - assert(AccCache.CpuPtr!=(uint64_t)NULL); + GRID_ASSERT(AccCache.state!=Empty); + GRID_ASSERT(AccCache.cpuLock==0); + GRID_ASSERT(AccCache.accLock==0); + GRID_ASSERT(AccCache.CpuPtr!=(uint64_t)NULL); if(AccCache.AccPtr==(uint64_t)NULL){ AccCache.AccPtr=(uint64_t)AcceleratorAllocate(AccCache.bytes); DeviceBytes+=AccCache.bytes; @@ -216,7 +216,7 @@ void MemoryManager::ViewClose(void* Ptr,ViewMode mode) } else if( (mode==CpuRead)||(mode==CpuWrite)){ CpuViewClose((uint64_t)Ptr); } else { - assert(0); + GRID_ASSERT(0); } } void *MemoryManager::ViewOpen(void* _CpuPtr,size_t bytes,ViewMode mode,ViewAdvise hint) @@ -228,7 +228,7 @@ void *MemoryManager::ViewOpen(void* _CpuPtr,size_t bytes,ViewMode mode,ViewAdvis } else if( (mode==CpuRead)||(mode==CpuWrite)){ return (void *)CpuViewOpen(CpuPtr,bytes,mode,hint); } else { - assert(0); + GRID_ASSERT(0); return NULL; } } @@ -237,10 +237,10 @@ void MemoryManager::EvictVictims(uint64_t bytes) if(bytes>=DeviceMaxBytes) { printf("EvictVictims bytes %ld DeviceMaxBytes %ld\n",bytes,DeviceMaxBytes); } - assert(bytes DeviceMaxBytes){ if ( DeviceLRUBytes > 0){ - assert(LRU.size()>0); + GRID_ASSERT(LRU.size()>0); uint64_t victim = LRU.back(); // From the LRU auto AccCacheIterator = EntryLookup(victim); auto & AccCache = AccCacheIterator->second; @@ -264,9 +264,9 @@ uint64_t MemoryManager::AcceleratorViewOpen(uint64_t CpuPtr,size_t bytes,ViewMod if (!AccCache.AccPtr) { EvictVictims(bytes); } - assert((mode==AcceleratorRead)||(mode==AcceleratorWrite)||(mode==AcceleratorWriteDiscard)); + GRID_ASSERT((mode==AcceleratorRead)||(mode==AcceleratorWrite)||(mode==AcceleratorWriteDiscard)); - assert(AccCache.cpuLock==0); // Programming error + GRID_ASSERT(AccCache.cpuLock==0); // Programming error if(AccCache.state!=Empty) { dprintf("ViewOpen found entry %lx %lx : sizes %ld %ld accLock %ld", @@ -275,8 +275,8 @@ uint64_t MemoryManager::AcceleratorViewOpen(uint64_t CpuPtr,size_t bytes,ViewMod (uint64_t)AccCache.bytes, (uint64_t)bytes, (uint64_t)AccCache.accLock); - assert(AccCache.CpuPtr == CpuPtr); - assert(AccCache.bytes ==bytes); + GRID_ASSERT(AccCache.CpuPtr == CpuPtr); + GRID_ASSERT(AccCache.bytes ==bytes); } /* * State transitions and actions @@ -293,7 +293,7 @@ uint64_t MemoryManager::AcceleratorViewOpen(uint64_t CpuPtr,size_t bytes,ViewMod * AccWrite AccDirty AccDirty - - */ if(AccCache.state==Empty) { - assert(AccCache.LRU_valid==0); + GRID_ASSERT(AccCache.LRU_valid==0); AccCache.CpuPtr = CpuPtr; AccCache.AccPtr = (uint64_t)NULL; AccCache.bytes = bytes; @@ -338,10 +338,10 @@ uint64_t MemoryManager::AcceleratorViewOpen(uint64_t CpuPtr,size_t bytes,ViewMod AccCache.accLock++; dprintf("AccDirty entry ++accLock= %d",AccCache.accLock); } else { - assert(0); + GRID_ASSERT(0); } - assert(AccCache.accLock>0); + GRID_ASSERT(AccCache.accLock>0); // If view is opened on device must remove from LRU if(AccCache.LRU_valid==1){ // must possibly remove from LRU as now locked on GPU @@ -362,8 +362,8 @@ void MemoryManager::AcceleratorViewClose(uint64_t CpuPtr) auto AccCacheIterator = EntryLookup(CpuPtr); auto & AccCache = AccCacheIterator->second; - assert(AccCache.cpuLock==0); - assert(AccCache.accLock>0); + GRID_ASSERT(AccCache.cpuLock==0); + GRID_ASSERT(AccCache.accLock>0); AccCache.accLock--; // Move to LRU queue if not locked and close on device @@ -379,8 +379,8 @@ void MemoryManager::CpuViewClose(uint64_t CpuPtr) auto AccCacheIterator = EntryLookup(CpuPtr); auto & AccCache = AccCacheIterator->second; - assert(AccCache.cpuLock>0); - assert(AccCache.accLock==0); + GRID_ASSERT(AccCache.cpuLock>0); + GRID_ASSERT(AccCache.accLock==0); AccCache.cpuLock--; } @@ -413,12 +413,12 @@ uint64_t MemoryManager::CpuViewOpen(uint64_t CpuPtr,size_t bytes,ViewMode mode,V // EvictVictims(bytes); // } - assert((mode==CpuRead)||(mode==CpuWrite)); - assert(AccCache.accLock==0); // Programming error + GRID_ASSERT((mode==CpuRead)||(mode==CpuWrite)); + GRID_ASSERT(AccCache.accLock==0); // Programming error if(AccCache.state!=Empty) { - assert(AccCache.CpuPtr == CpuPtr); - assert(AccCache.bytes==bytes); + GRID_ASSERT(AccCache.CpuPtr == CpuPtr); + GRID_ASSERT(AccCache.bytes==bytes); } if(AccCache.state==Empty) { @@ -433,20 +433,20 @@ uint64_t MemoryManager::CpuViewOpen(uint64_t CpuPtr,size_t bytes,ViewMode mode,V AccCache.state = CpuDirty; // CpuDirty +CpuRead/CpuWrite => CpuDirty AccCache.cpuLock++; } else if(AccCache.state==Consistent) { - assert(AccCache.AccPtr != (uint64_t)NULL); + GRID_ASSERT(AccCache.AccPtr != (uint64_t)NULL); if(mode==CpuWrite) AccCache.state = CpuDirty; // Consistent +CpuWrite => CpuDirty else AccCache.state = Consistent; // Consistent +CpuRead => Consistent AccCache.cpuLock++; } else if(AccCache.state==AccDirty) { - assert(AccCache.AccPtr != (uint64_t)NULL); + GRID_ASSERT(AccCache.AccPtr != (uint64_t)NULL); Flush(AccCache); if(mode==CpuWrite) AccCache.state = CpuDirty; // AccDirty +CpuWrite => CpuDirty, Flush else AccCache.state = Consistent; // AccDirty +CpuRead => Consistent, Flush AccCache.cpuLock++; } else { - assert(0); // should be unreachable + GRID_ASSERT(0); // should be unreachable } AccCache.transient= transient? EvictNext : 0; @@ -528,12 +528,12 @@ void MemoryManager::Audit(std::string s) std::cout << " Memory Manager::Audit() from "<second; LruBytes2+=AccCache.bytes; - assert(AccCache.LRU_valid==1); - assert(AccCache.LRU_entry==it); + GRID_ASSERT(AccCache.LRU_valid==1); + GRID_ASSERT(AccCache.LRU_entry==it); } std::cout << " Memory Manager::Audit() LRU queue matches table entries "<= 0); + GRID_ASSERT(fd >= 0); const int page_size = 4096; uint64_t virt_pfn = (uint64_t)Buf / page_size; off_t offset = sizeof(uint64_t) * virt_pfn; uint64_t npages = (BYTES + page_size-1) / page_size; std::vector pagedata(npages); uint64_t ret = lseek(fd, offset, SEEK_SET); - assert(ret == offset); + GRID_ASSERT(ret == offset); ret = ::read(fd, &pagedata[0], sizeof(uint64_t)*npages); - assert(ret == sizeof(uint64_t) * npages); + GRID_ASSERT(ret == sizeof(uint64_t) * npages); int nhugepages = npages / 512; int n4ktotal, nnothuge; n4ktotal = 0; diff --git a/Grid/cartesian/Cartesian_base.h b/Grid/cartesian/Cartesian_base.h index 66400787..1a5049ca 100644 --- a/Grid/cartesian/Cartesian_base.h +++ b/Grid/cartesian/Cartesian_base.h @@ -165,7 +165,7 @@ public: // if ( _simd_layout[dimension] > 2 ) { for(int d=0;d<_ndimension;d++){ - if ( d != dimension ) assert ( (_simd_layout[d]==1) ); + if ( d != dimension ) GRID_ASSERT ( (_simd_layout[d]==1) ); } permute_type = RotateBit; // How to specify distance; this is not just direction. return permute_type; @@ -187,7 +187,7 @@ public: inline int64_t gSites(void) const { return (int64_t)_isites*(int64_t)_osites*(int64_t)_Nprocessors; }; inline int Nd (void) const { return _ndimension;}; - inline const Coordinate LocalStarts(void) { return _lstart; }; + inline const Coordinate &LocalStarts(void) { return _lstart; }; inline const Coordinate &FullDimensions(void) { return _fdimensions;}; inline const Coordinate &GlobalDimensions(void) { return _gdimensions;}; inline const Coordinate &LocalDimensions(void) { return _ldimensions;}; @@ -216,11 +216,11 @@ public: // Global addressing //////////////////////////////////////////////////////////////// void GlobalIndexToGlobalCoor(int64_t gidx,Coordinate &gcoor){ - assert(gidx< gSites()); + GRID_ASSERT(gidx< gSites()); Lexicographic::CoorFromIndex(gcoor,gidx,_gdimensions); } void LocalIndexToLocalCoor(int lidx,Coordinate &lcoor){ - assert(lidx 0); + GRID_ASSERT(_rdimensions[d] * _simd_layout[d] == _ldimensions[d]); + GRID_ASSERT(_rdimensions[d] > 0); // all elements of a simd vector must have same checkerboard. // If Ls vectorised, this must still be the case; e.g. dwf rb5d diff --git a/Grid/communicator/Communicator_base.h b/Grid/communicator/Communicator_base.h index 8fd8ec34..ef756591 100644 --- a/Grid/communicator/Communicator_base.h +++ b/Grid/communicator/Communicator_base.h @@ -149,7 +149,7 @@ public: sizeof(obj),d*100+p); } - if (!list.empty()) // avoid triggering assert in comms == none + if (!list.empty()) // avoid triggering GRID_ASSERT in comms == none CommsComplete(list); for(int p=1;p<_processors[d];p++){ accum = accum + column[p]; @@ -226,14 +226,14 @@ public: // All2All down one dimension //////////////////////////////////////////////////////////// template void AllToAll(int dim,std::vector &in, std::vector &out){ - assert(dim>=0); - assert(dim<_ndimension); - assert(in.size()==out.size()); + GRID_ASSERT(dim>=0); + GRID_ASSERT(dim<_ndimension); + GRID_ASSERT(in.size()==out.size()); int numnode = _processors[dim]; uint64_t bytes=sizeof(T); uint64_t words=in.size()/numnode; - assert(numnode * words == in.size()); - assert(words < (1ULL<<31)); + GRID_ASSERT(numnode * words == in.size()); + GRID_ASSERT(words < (1ULL<<31)); AllToAll(dim,(void *)&in[0],(void *)&out[0],words,bytes); } void AllToAll(int dim ,void *in,void *out,uint64_t words,uint64_t bytes); diff --git a/Grid/communicator/Communicator_mpi3.cc b/Grid/communicator/Communicator_mpi3.cc index 0f03aba5..750a9152 100644 --- a/Grid/communicator/Communicator_mpi3.cc +++ b/Grid/communicator/Communicator_mpi3.cc @@ -28,15 +28,18 @@ Author: Peter Boyle #include #include +void GridAbort(void) { MPI_Abort(MPI_COMM_WORLD,SIGABRT); } +extern void * Grid_backtrace_buffer[_NBACKTRACE]; + NAMESPACE_BEGIN(Grid); Grid_MPI_Comm CartesianCommunicator::communicator_world; #ifdef GRID_CHECKSUM_COMMS -extern void * Grid_backtrace_buffer[_NBACKTRACE]; uint64_t checksum_index = 1; #endif + //////////////////////////////////////////// // First initialise of comms system //////////////////////////////////////////// @@ -60,11 +63,11 @@ void CartesianCommunicator::Init(int *argc, char ***argv) #endif //If only 1 comms thread we require any threading mode other than SINGLE, but for multiple comms threads we need MULTIPLE if( (nCommThreads == 1) && (provided == MPI_THREAD_SINGLE) ) { - assert(0); + GRID_ASSERT(0); } if( (nCommThreads > 1) && (provided != MPI_THREAD_MULTIPLE) ) { - assert(0); + GRID_ASSERT(0); } } @@ -85,20 +88,20 @@ void CartesianCommunicator::Init(int *argc, char ***argv) void CartesianCommunicator::ShiftedRanks(int dim,int shift,int &source,int &dest) { int ierr=MPI_Cart_shift(communicator,dim,shift,&source,&dest); - assert(ierr==0); + GRID_ASSERT(ierr==0); } int CartesianCommunicator::RankFromProcessorCoor(Coordinate &coor) { int rank; int ierr=MPI_Cart_rank (communicator, &coor[0], &rank); - assert(ierr==0); + GRID_ASSERT(ierr==0); return rank; } void CartesianCommunicator::ProcessorCoorFromRank(int rank, Coordinate &coor) { coor.resize(_ndimension); int ierr=MPI_Cart_coords (communicator, rank, _ndimension,&coor[0]); - assert(ierr==0); + GRID_ASSERT(ierr==0); } //////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -125,8 +128,8 @@ CartesianCommunicator::CartesianCommunicator(const Coordinate &processors) ////////////////////////////////// CartesianCommunicator::CartesianCommunicator(const Coordinate &processors,const CartesianCommunicator &parent,int &srank) { - _ndimension = processors.size(); assert(_ndimension>=1); - int parent_ndimension = parent._ndimension; assert(_ndimension >= parent._ndimension); + _ndimension = processors.size(); GRID_ASSERT(_ndimension>=1); + int parent_ndimension = parent._ndimension; GRID_ASSERT(_ndimension >= parent._ndimension); Coordinate parent_processor_coor(_ndimension,0); Coordinate parent_processors (_ndimension,1); Coordinate shm_processors (_ndimension,1); @@ -150,7 +153,7 @@ CartesianCommunicator::CartesianCommunicator(const Coordinate &processors,const childsize *= processors[d]; } int Nchild = Nparent/childsize; - assert (childsize * Nchild == Nparent); + GRID_ASSERT (childsize * Nchild == Nparent); Coordinate ccoor(_ndimension); // coor within subcommunicator Coordinate scoor(_ndimension); // coor of split within parent @@ -176,12 +179,12 @@ CartesianCommunicator::CartesianCommunicator(const Coordinate &processors,const // Split the communicator //////////////////////////////////////////////////////////////// int ierr= MPI_Comm_split(parent.communicator,srank,crank,&comm_split); - assert(ierr==0); + GRID_ASSERT(ierr==0); } else { srank = 0; int ierr = MPI_Comm_dup (parent.communicator,&comm_split); - assert(ierr==0); + GRID_ASSERT(ierr==0); } ////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -206,7 +209,7 @@ CartesianCommunicator::CartesianCommunicator(const Coordinate &processors,const } } for(int d=0;d &list, @@ -344,19 +347,19 @@ void CartesianCommunicator::SendToRecvFromBegin(std::vector & MPI_Request xrq; MPI_Request rrq; - assert(dest != _processor); - assert(from != _processor); + GRID_ASSERT(dest != _processor); + GRID_ASSERT(from != _processor); int tag; tag= dir+from*32; int ierr=MPI_Irecv(recv, bytes, MPI_CHAR,from,tag,communicator,&rrq); - assert(ierr==0); + GRID_ASSERT(ierr==0); list.push_back(rrq); tag= dir+_processor*32; ierr =MPI_Isend(xmit, bytes, MPI_CHAR,dest,tag,communicator,&xrq); - assert(ierr==0); + GRID_ASSERT(ierr==0); list.push_back(xrq); } void CartesianCommunicator::CommsComplete(std::vector &list) @@ -367,7 +370,7 @@ void CartesianCommunicator::CommsComplete(std::vector &list) std::vector status(nreq); int ierr = MPI_Waitall(nreq,&list[0],&status[0]); - assert(ierr==0); + GRID_ASSERT(ierr==0); list.resize(0); } @@ -384,15 +387,15 @@ void CartesianCommunicator::SendToRecvFrom(void *xmit, int ierr; // Enforce no UVM in comms, device or host OK - assert(acceleratorIsCommunicable(xmit)); - assert(acceleratorIsCommunicable(recv)); + GRID_ASSERT(acceleratorIsCommunicable(xmit)); + GRID_ASSERT(acceleratorIsCommunicable(recv)); // Give the CPU to MPI immediately; can use threads to overlap optionally // printf("proc %d SendToRecvFrom %d bytes Sendrecv \n",_processor,bytes); ierr=MPI_Sendrecv(xmit,bytes,MPI_CHAR,dest,myrank, recv,bytes,MPI_CHAR,from, from, communicator,MPI_STATUS_IGNORE); - assert(ierr==0); + GRID_ASSERT(ierr==0); } // Basic Halo comms primitive @@ -445,9 +448,9 @@ double CartesianCommunicator::StencilSendToRecvFromBegin(std::vectorShmBufferTranslate(from,xmit); - assert(shm!=NULL); + GRID_ASSERT(shm!=NULL); // std::cout << " StencilSendToRecvFrom "<ShmBufferTranslate(dest,recv); - assert(shm!=NULL); + GRID_ASSERT(shm!=NULL); acceleratorCopyDeviceToDeviceAsynch(xmit,shm,xbytes); #endif } @@ -497,7 +500,7 @@ void CartesianCommunicator::StencilSendToRecvFromComplete(std::vector status(nreq); int ierr = MPI_Waitall(nreq,&list[0],&status[0]); - assert(ierr==0); + GRID_ASSERT(ierr==0); list.resize(0); this->StencilBarrier(); } @@ -557,9 +560,9 @@ double CartesianCommunicator::StencilSendToRecvFromPrepare(std::vectorHostBufferMalloc(rbytes); ierr=MPI_Irecv(host_recv, rbytes, MPI_CHAR,from,tag,communicator_halo[commdir],&rrq); - assert(ierr==0); + GRID_ASSERT(ierr==0); CommsRequest_t srq; srq.PacketType = InterNodeRecv; srq.bytes = rbytes; @@ -606,7 +609,7 @@ double CartesianCommunicator::StencilSendToRecvFromPrepare(std::vectorShmBufferTranslate(from,xmit); - assert(shm!=NULL); + GRID_ASSERT(shm!=NULL); CommsRequest_t srq; @@ -774,7 +777,7 @@ double CartesianCommunicator::StencilSendToRecvFromBegin(std::vectorShmBufferTranslate(dest,recv); - assert(shm!=NULL); + GRID_ASSERT(shm!=NULL); CommsRequest_t srq; @@ -813,7 +816,7 @@ void CartesianCommunicator::StencilSendToRecvFromComplete(std::vector0) { status.resize(MpiRequests.size()); int ierr = MPI_Waitall(MpiRequests.size(),&MpiRequests[0],&status[0]); // Sends are guaranteed in order. No harm in not completing. - assert(ierr==0); + GRID_ASSERT(ierr==0); } // for(int r=0;r=0 && dim<_ndimension); + GRID_ASSERT(dim>=0 && dim<_ndimension); // Split the communicator row[dim] = _processors[dim]; @@ -936,8 +939,8 @@ void CartesianCommunicator::AllToAll(void *in,void *out,uint64_t words,uint64_t int ibytes; iwords = words; ibytes = bytes; - assert(words == iwords); // safe to cast to int ? - assert(bytes == ibytes); // safe to cast to int ? + GRID_ASSERT(words == iwords); // safe to cast to int ? + GRID_ASSERT(bytes == ibytes); // safe to cast to int ? MPI_Type_contiguous(ibytes,MPI_BYTE,&object); MPI_Type_commit(&object); MPI_Alltoall(in,iwords,object,out,iwords,object,communicator); diff --git a/Grid/communicator/Communicator_none.cc b/Grid/communicator/Communicator_none.cc index 350b967c..44ce9868 100644 --- a/Grid/communicator/Communicator_none.cc +++ b/Grid/communicator/Communicator_none.cc @@ -34,6 +34,8 @@ NAMESPACE_BEGIN(Grid); /////////////////////////////////////////////////////////////////////////////////////////////////// Grid_MPI_Comm CartesianCommunicator::communicator_world; +void GridAbort(void) { abort(); } + void CartesianCommunicator::Init(int *argc, char *** arv) { GlobalSharedMemory::Init(communicator_world); @@ -54,14 +56,14 @@ CartesianCommunicator::CartesianCommunicator(const Coordinate &processors) { _shm_processors = Coordinate(processors.size(),1); _processors = processors; - _ndimension = processors.size(); assert(_ndimension>=1); + _ndimension = processors.size(); GRID_ASSERT(_ndimension>=1); _processor_coor.resize(_ndimension); // Require 1^N processor grid for fake _Nprocessors=1; _processor = 0; for(int d=0;d<_ndimension;d++) { - assert(_processors[d]==1); + GRID_ASSERT(_processors[d]==1); _processor_coor[d] = 0; } SetCommunicator(communicator_world); @@ -89,9 +91,9 @@ void CartesianCommunicator::SendToRecvFrom(void *xmit, int from, int bytes) { - assert(0); + GRID_ASSERT(0); } -void CartesianCommunicator::CommsComplete(std::vector &list){ assert(list.size()==0);} +void CartesianCommunicator::CommsComplete(std::vector &list){ GRID_ASSERT(list.size()==0);} void CartesianCommunicator::SendToRecvFromBegin(std::vector &list, void *xmit, int dest, @@ -99,7 +101,7 @@ void CartesianCommunicator::SendToRecvFromBegin(std::vector &lis int from, int bytes,int dir) { - assert(0); + GRID_ASSERT(0); } void CartesianCommunicator::AllToAll(int dim,void *in,void *out,uint64_t words,uint64_t bytes) diff --git a/Grid/communicator/SharedMemory.cc b/Grid/communicator/SharedMemory.cc index 3445b077..662f319f 100644 --- a/Grid/communicator/SharedMemory.cc +++ b/Grid/communicator/SharedMemory.cc @@ -58,8 +58,8 @@ int GlobalSharedMemory::WorldNode; void GlobalSharedMemory::SharedMemoryFree(void) { - assert(_ShmAlloc); - assert(_ShmAllocBytes>0); + GRID_ASSERT(_ShmAlloc); + GRID_ASSERT(_ShmAllocBytes>0); for(int r=0;r IntShmDims; GridCmdOptionIntVector(std::string(str),IntShmDims); - assert(IntShmDims.size() == WorldDims.size()); + GRID_ASSERT(IntShmDims.size() == WorldDims.size()); long ShmSize = 1; for (int dim=0;dim0); + sock = socket(AF_UNIX, SOCK_DGRAM, 0); GRID_ASSERT(sock>0); struct sockaddr_un sa_un = { 0 }; sa_un.sun_family = AF_UNIX; @@ -158,7 +158,7 @@ public: /*Construct from an MPI communicator*/ void GlobalSharedMemory::Init(Grid_MPI_Comm comm) { - assert(_ShmSetup==0); + GRID_ASSERT(_ShmSetup==0); WorldComm = comm; MPI_Comm_rank(WorldComm,&WorldRank); MPI_Comm_size(WorldComm,&WorldSize); @@ -184,7 +184,7 @@ void GlobalSharedMemory::Init(Grid_MPI_Comm comm) // WorldNodes WorldNodes = WorldSize/WorldShmSize; - assert( (WorldNodes * WorldShmSize) == WorldSize ); + GRID_ASSERT( (WorldNodes * WorldShmSize) == WorldSize ); // FIXME: Check all WorldShmSize are the same ? @@ -209,7 +209,7 @@ void GlobalSharedMemory::Init(Grid_MPI_Comm comm) MyGroup.resize(WorldShmSize); for(int rank=0;rank=0); + GRID_ASSERT(hypercoor=0); ////////////////////////////////////// // Printing @@ -382,7 +382,7 @@ void GlobalSharedMemory::OptimalCommunicatorHypercube(const Coordinate &processo for(int i=0;i void Scatter_plane_merge(Lattice &rhs,ExtractPointerA // Case of SIMD split AND checker dim cannot currently be hit, except in // Test_cshift_red_black code. - std::cout << "Scatter_plane merge assert(0); think this is buggy FIXME "<< std::endl;// think this is buggy FIXME + std::cout << "Scatter_plane merge GRID_ASSERT(0); think this is buggy FIXME "<< std::endl;// think this is buggy FIXME std::cout<<" Unthreaded warning -- buffer is not densely packed ??"< void Cshift_comms(Lattice &ret,const Lattice &r int pd = rhs.Grid()->_processors[dimension]; int simd_layout = rhs.Grid()->_simd_layout[dimension]; int comm_dim = rhs.Grid()->_processors[dimension] >1 ; - assert(simd_layout==1); - assert(comm_dim==1); - assert(shift>=0); - assert(shift=0); + GRID_ASSERT(shift_slice_nblock[dimension]*rhs.Grid()->_slice_block[dimension]; static deviceVector send_buf; send_buf.resize(buffer_size); @@ -187,7 +187,7 @@ template void Cshift_comms(Lattice &ret,const Lattice &r acceleratorCopyFromDevice(&send_buf[0],&hsend_buf[0],bytes); #ifdef GRID_CHECKSUM_COMMS - assert(bytes % 8 == 0); + GRID_ASSERT(bytes % 8 == 0); checksum_index++; uint64_t xsum = checksum_gpu((uint64_t*)&send_buf[0], bytes / 8) ^ (1 + checksum_index); *(uint64_t*)(((char*)&hsend_buf[0]) + bytes) = xsum; @@ -213,7 +213,7 @@ template void Cshift_comms(Lattice &ret,const Lattice &r <<" send "< void Cshift_comms_simd(Lattice &ret,const Lattice=0); - assert(shift=0); + GRID_ASSERT(shift void Cshift_comms_simd(Lattice &ret,const LatticeShiftedRanks(dimension,nbr_proc,xmit_to_rank,recv_from_rank); diff --git a/Grid/lattice/Lattice_ET.h b/Grid/lattice/Lattice_ET.h index 2ad93d30..0bcad224 100644 --- a/Grid/lattice/Lattice_ET.h +++ b/Grid/lattice/Lattice_ET.h @@ -245,7 +245,7 @@ template ::value, T1>::type * = inline void CBFromExpression(int &cb, const T1 &lat) // Lattice leaf { if ((cb == Odd) || (cb == Even)) { - assert(cb == lat.Checkerboard()); + GRID_ASSERT(cb == lat.Checkerboard()); } cb = lat.Checkerboard(); } diff --git a/Grid/lattice/Lattice_base.h b/Grid/lattice/Lattice_base.h index d8b9a618..7044f4a6 100644 --- a/Grid/lattice/Lattice_base.h +++ b/Grid/lattice/Lattice_base.h @@ -120,12 +120,12 @@ public: GRID_TRACE("ExpressionTemplateEval"); GridBase *egrid(nullptr); GridFromExpression(egrid,expr); - assert(egrid!=nullptr); + GRID_ASSERT(egrid!=nullptr); conformable(this->_grid,egrid); int cb=-1; CBFromExpression(cb,expr); - assert( (cb==Odd) || (cb==Even)); + GRID_ASSERT( (cb==Odd) || (cb==Even)); this->checkerboard=cb; auto exprCopy = expr; @@ -144,12 +144,12 @@ public: GRID_TRACE("ExpressionTemplateEval"); GridBase *egrid(nullptr); GridFromExpression(egrid,expr); - assert(egrid!=nullptr); + GRID_ASSERT(egrid!=nullptr); conformable(this->_grid,egrid); int cb=-1; CBFromExpression(cb,expr); - assert( (cb==Odd) || (cb==Even)); + GRID_ASSERT( (cb==Odd) || (cb==Even)); this->checkerboard=cb; auto exprCopy = expr; @@ -168,12 +168,12 @@ public: GRID_TRACE("ExpressionTemplateEval"); GridBase *egrid(nullptr); GridFromExpression(egrid,expr); - assert(egrid!=nullptr); + GRID_ASSERT(egrid!=nullptr); conformable(this->_grid,egrid); int cb=-1; CBFromExpression(cb,expr); - assert( (cb==Odd) || (cb==Even)); + GRID_ASSERT( (cb==Odd) || (cb==Even)); this->checkerboard=cb; auto exprCopy = expr; ExpressionViewOpen(exprCopy); @@ -191,11 +191,11 @@ public: Lattice(const LatticeUnaryExpression & expr) { this->_grid = nullptr; GridFromExpression(this->_grid,expr); - assert(this->_grid!=nullptr); + GRID_ASSERT(this->_grid!=nullptr); int cb=-1; CBFromExpression(cb,expr); - assert( (cb==Odd) || (cb==Even)); + GRID_ASSERT( (cb==Odd) || (cb==Even)); this->checkerboard=cb; resize(this->_grid->oSites()); @@ -206,11 +206,11 @@ public: Lattice(const LatticeBinaryExpression & expr) { this->_grid = nullptr; GridFromExpression(this->_grid,expr); - assert(this->_grid!=nullptr); + GRID_ASSERT(this->_grid!=nullptr); int cb=-1; CBFromExpression(cb,expr); - assert( (cb==Odd) || (cb==Even)); + GRID_ASSERT( (cb==Odd) || (cb==Even)); this->checkerboard=cb; resize(this->_grid->oSites()); @@ -221,11 +221,11 @@ public: Lattice(const LatticeTrinaryExpression & expr) { this->_grid = nullptr; GridFromExpression(this->_grid,expr); - assert(this->_grid!=nullptr); + GRID_ASSERT(this->_grid!=nullptr); int cb=-1; CBFromExpression(cb,expr); - assert( (cb==Odd) || (cb==Even)); + GRID_ASSERT( (cb==Odd) || (cb==Even)); this->checkerboard=cb; resize(this->_grid->oSites()); @@ -264,7 +264,7 @@ public: Lattice(GridBase *grid,ViewMode mode=AcceleratorWriteDiscard) { this->_grid = grid; resize(this->_grid->oSites()); - assert((((uint64_t)&this->_odata[0])&0xF) ==0); + GRID_ASSERT((((uint64_t)&this->_odata[0])&0xF) ==0); this->checkerboard=0; SetViewMode(mode); } diff --git a/Grid/lattice/Lattice_basis.h b/Grid/lattice/Lattice_basis.h index c9c65928..0d556bc0 100644 --- a/Grid/lattice/Lattice_basis.h +++ b/Grid/lattice/Lattice_basis.h @@ -166,9 +166,9 @@ void basisReorderInPlace(std::vector &_v,std::vector& sort_vals, s { int vlen = idx.size(); - assert(vlen>=1); - assert(vlen<=sort_vals.size()); - assert(vlen<=_v.size()); + GRID_ASSERT(vlen>=1); + GRID_ASSERT(vlen<=sort_vals.size()); + GRID_ASSERT(vlen<=_v.size()); for (size_t i=0;i &_v,std::vector& sort_vals, s if (idx[j]==i) break; - assert(idx[i] > i); assert(j!=idx.size()); assert(idx[j]==i); + GRID_ASSERT(idx[i] > i); GRID_ASSERT(j!=idx.size()); GRID_ASSERT(idx[j]==i); swap(_v[i],_v[idx[i]]); // should use vector move constructor, no data copy std::swap(sort_vals[i],sort_vals[idx[i]]); @@ -224,7 +224,7 @@ void basisSortInPlace(std::vector & _v,std::vector& sort_vals, boo template void basisDeflate(const std::vector &_v,const std::vector& eval,const Field& src_orig,Field& result) { result = Zero(); - assert(_v.size()==eval.size()); + GRID_ASSERT(_v.size()==eval.size()); int N = (int)_v.size(); for (int i=0;i void conformable(const Lattice &lhs,const Lattice &rhs) { - assert(lhs.Grid() == rhs.Grid()); - assert(lhs.Checkerboard() == rhs.Checkerboard()); + GRID_ASSERT(lhs.Grid() == rhs.Grid()); + GRID_ASSERT(lhs.Checkerboard() == rhs.Checkerboard()); } NAMESPACE_END(Grid); diff --git a/Grid/lattice/Lattice_matrix_reduction.h b/Grid/lattice/Lattice_matrix_reduction.h index abebbfd6..cb3600fe 100644 --- a/Grid/lattice/Lattice_matrix_reduction.h +++ b/Grid/lattice/Lattice_matrix_reduction.h @@ -42,7 +42,7 @@ static void sliceMaddMatrix (Lattice &R,Eigen::MatrixXcd &aa,const Lattice // Lattice Xslice(SliceGrid); // Lattice Rslice(SliceGrid); - assert( FullGrid->_simd_layout[Orthog]==1); + GRID_ASSERT( FullGrid->_simd_layout[Orthog]==1); //FIXME package in a convenient iterator //Should loop over a plane orthogonal to direction "Orthog" @@ -86,7 +86,7 @@ static void sliceMulMatrix (Lattice &R,Eigen::MatrixXcd &aa,const Lattice< int Nblock = X.Grid()->GlobalDimensions()[Orthog]; GridBase *FullGrid = X.Grid(); - assert( FullGrid->_simd_layout[Orthog]==1); + GRID_ASSERT( FullGrid->_simd_layout[Orthog]==1); //FIXME package in a convenient iterator //Should loop over a plane orthogonal to direction "Orthog" @@ -140,7 +140,7 @@ static void sliceInnerProductMatrix( Eigen::MatrixXcd &mat, const Lattice mat = Eigen::MatrixXcd::Zero(Nblock,Nblock); - assert( FullGrid->_simd_layout[Orthog]==1); + GRID_ASSERT( FullGrid->_simd_layout[Orthog]==1); // int nh = FullGrid->_ndimension; // int nl = SliceGrid->_ndimension; // int nl = nh-1; diff --git a/Grid/lattice/Lattice_peekpoke.h b/Grid/lattice/Lattice_peekpoke.h index 6106962c..66fd6bea 100644 --- a/Grid/lattice/Lattice_peekpoke.h +++ b/Grid/lattice/Lattice_peekpoke.h @@ -98,8 +98,8 @@ void pokeSite(const sobj &s,Lattice &l,const Coordinate &site){ int Nsimd = grid->Nsimd(); - assert( l.Checkerboard()== l.Grid()->CheckerBoard(site)); - assert( sizeof(sobj)*Nsimd == sizeof(vobj)); + GRID_ASSERT( l.Checkerboard()== l.Grid()->CheckerBoard(site)); + GRID_ASSERT( sizeof(sobj)*Nsimd == sizeof(vobj)); int rank,odx,idx; // Optional to broadcast from node 0. @@ -135,7 +135,7 @@ void peekSite(sobj &s,const Lattice &l,const Coordinate &site){ int Nsimd = grid->Nsimd(); - assert( l.Checkerboard() == l.Grid()->CheckerBoard(site)); + GRID_ASSERT( l.Checkerboard() == l.Grid()->CheckerBoard(site)); int rank,odx,idx; grid->GlobalCoorToRankIndex(rank,odx,idx,site); @@ -159,14 +159,14 @@ template inline void peekLocalSite(sobj &s,const LatticeView &l,Coordinate &site) { GridBase *grid = l.getGrid(); - assert(l.mode==CpuRead); + GRID_ASSERT(l.mode==CpuRead); typedef typename vobj::scalar_type scalar_type; typedef typename vobj::vector_type vector_type; int Nsimd = grid->Nsimd(); - // assert( l.Checkerboard()== grid->CheckerBoard(site)); - assert( sizeof(sobj)*Nsimd == sizeof(vobj)); + // GRID_ASSERT( l.Checkerboard()== grid->CheckerBoard(site)); + GRID_ASSERT( sizeof(sobj)*Nsimd == sizeof(vobj)); static const int words=sizeof(vobj)/sizeof(vector_type); int odx,idx; @@ -195,15 +195,15 @@ template inline void pokeLocalSite(const sobj &s,LatticeView &l,Coordinate &site) { GridBase *grid=l.getGrid(); - assert(l.mode==CpuWrite); + GRID_ASSERT(l.mode==CpuWrite); typedef typename vobj::scalar_type scalar_type; typedef typename vobj::vector_type vector_type; int Nsimd = grid->Nsimd(); - // assert( l.Checkerboard()== grid->CheckerBoard(site)); - assert( sizeof(sobj)*Nsimd == sizeof(vobj)); + // GRID_ASSERT( l.Checkerboard()== grid->CheckerBoard(site)); + GRID_ASSERT( sizeof(sobj)*Nsimd == sizeof(vobj)); static const int words=sizeof(vobj)/sizeof(vector_type); int odx,idx; diff --git a/Grid/lattice/Lattice_reduction.h b/Grid/lattice/Lattice_reduction.h index 691faee6..861f3f06 100644 --- a/Grid/lattice/Lattice_reduction.h +++ b/Grid/lattice/Lattice_reduction.h @@ -292,26 +292,26 @@ inline ComplexD innerProduct(const Lattice &left,const Lattice &righ bool ok; #ifdef GRID_SYCL - uint64_t csum=0; - uint64_t csum2=0; - if ( FlightRecorder::LoggingMode != FlightRecorder::LoggingModeNone) - { - // Hack - // Fast integer xor checksum. Can also be used in comms now. - autoView(l_v,left,AcceleratorRead); - Integer words = left.Grid()->oSites()*sizeof(vobj)/sizeof(uint64_t); - uint64_t *base= (uint64_t *)&l_v[0]; - csum=svm_xor(base,words); - ok = FlightRecorder::CsumLog(csum); - if ( !ok ) { - csum2=svm_xor(base,words); - std::cerr<< " Bad CSUM " << std::hex<< csum << " recomputed as "<oSites()*sizeof(vobj)/sizeof(uint64_t); + // uint64_t *base= (uint64_t *)&l_v[0]; + // csum=svm_xor(base,words); + // ok = FlightRecorder::CsumLog(csum); + // if ( !ok ) { + // csum2=svm_xor(base,words); + // std::cerr<< " Bad CSUM " << std::hex<< csum << " recomputed as "< &left,const Lattice &righ ComplexD nrm2 = rankInnerProduct(left,right); RealD local2 = real(nrm2); std::cerr<< " Bad NORM " << local << " recomputed as "<GlobalSumP2P(nrm); @@ -376,40 +376,9 @@ axpby_norm_fast(Lattice &z,sobj a,sobj b,const Lattice &x,const Latt coalescedWrite(z_v[ss],tmp); }); bool ok; -#ifdef GRID_SYCL - uint64_t csum=0; - uint64_t csum2=0; - if ( FlightRecorder::LoggingMode != FlightRecorder::LoggingModeNone) - { - // z_v - { - Integer words = sites*sizeof(vobj)/sizeof(uint64_t); - uint64_t *base= (uint64_t *)&z_v[0]; - csum=svm_xor(base,words); - ok = FlightRecorder::CsumLog(csum); - if ( !ok ) { - csum2=svm_xor(base,words); - std::cerr<< " Bad z_v CSUM " << std::hex<< csum << " recomputed as "<GlobalSum(nrm); FlightRecorder::ReductionLog(local,real(nrm)); @@ -495,13 +464,13 @@ template inline void sliceSum(const Lattice &Data, typedef typename vobj::scalar_object sobj; typedef typename vobj::scalar_object::scalar_type scalar_type; GridBase *grid = Data.Grid(); - assert(grid!=NULL); + GRID_ASSERT(grid!=NULL); const int Nd = grid->_ndimension; const int Nsimd = grid->Nsimd(); - assert(orthogdim >= 0); - assert(orthogdim < Nd); + GRID_ASSERT(orthogdim >= 0); + GRID_ASSERT(orthogdim < Nd); int fd=grid->_fdimensions[orthogdim]; int ld=grid->_ldimensions[orthogdim]; @@ -588,14 +557,14 @@ static void sliceInnerProductVector( std::vector & result, const Latti typedef typename vobj::vector_type vector_type; typedef typename vobj::scalar_type scalar_type; GridBase *grid = lhs.Grid(); - assert(grid!=NULL); + GRID_ASSERT(grid!=NULL); conformable(grid,rhs.Grid()); const int Nd = grid->_ndimension; const int Nsimd = grid->Nsimd(); - assert(orthogdim >= 0); - assert(orthogdim < Nd); + GRID_ASSERT(orthogdim >= 0); + GRID_ASSERT(orthogdim < Nd); int fd=grid->_fdimensions[orthogdim]; int ld=grid->_ldimensions[orthogdim]; diff --git a/Grid/lattice/Lattice_reduction_gpu.h b/Grid/lattice/Lattice_reduction_gpu.h index 91cb8226..849f5309 100644 --- a/Grid/lattice/Lattice_reduction_gpu.h +++ b/Grid/lattice/Lattice_reduction_gpu.h @@ -208,7 +208,7 @@ inline typename vobj::scalar_objectD sumD_gpu_small(const vobj *lat, Integer osi Integer numThreads, numBlocks; int ok = getNumBlocksAndThreads(size, sizeof(sobj), numThreads, numBlocks); - assert(ok); + GRID_ASSERT(ok); Integer smemSize = numThreads * sizeof(sobj); // Move out of UVM diff --git a/Grid/lattice/Lattice_rng.h b/Grid/lattice/Lattice_rng.h index 292722c9..6d407036 100644 --- a/Grid/lattice/Lattice_rng.h +++ b/Grid/lattice/Lattice_rng.h @@ -53,10 +53,10 @@ inline int RNGfillable(GridBase *coarse,GridBase *fine) // trivially extended in higher dims, with locality guaranteeing RNG state is local to node int lowerdims = fine->_ndimension - coarse->_ndimension; - assert(lowerdims >= 0); + GRID_ASSERT(lowerdims >= 0); for(int d=0;d_simd_layout[d]==1); - assert(fine->_processors[d]==1); + GRID_ASSERT(fine->_simd_layout[d]==1); + GRID_ASSERT(fine->_processors[d]==1); } int multiplicity=1; @@ -66,9 +66,9 @@ inline int RNGfillable(GridBase *coarse,GridBase *fine) // local and global volumes subdivide cleanly after SIMDization for(int d=0;d_processors[d] == fine->_processors[fd]); - assert(coarse->_simd_layout[d] == fine->_simd_layout[fd]); - assert(((fine->_rdimensions[fd] / coarse->_rdimensions[d])* coarse->_rdimensions[d])==fine->_rdimensions[fd]); + GRID_ASSERT(coarse->_processors[d] == fine->_processors[fd]); + GRID_ASSERT(coarse->_simd_layout[d] == fine->_simd_layout[fd]); + GRID_ASSERT(((fine->_rdimensions[fd] / coarse->_rdimensions[d])* coarse->_rdimensions[d])==fine->_rdimensions[fd]); multiplicity = multiplicity *fine->_rdimensions[fd] / coarse->_rdimensions[d]; } @@ -83,18 +83,18 @@ inline int RNGfillable_general(GridBase *coarse,GridBase *fine) int rngdims = coarse->_ndimension; // trivially extended in higher dims, with locality guaranteeing RNG state is local to node - int lowerdims = fine->_ndimension - coarse->_ndimension; assert(lowerdims >= 0); + int lowerdims = fine->_ndimension - coarse->_ndimension; GRID_ASSERT(lowerdims >= 0); // assumes that the higher dimensions are not using more processors // all further divisions are local - for(int d=0;d_processors[d]==1); - for(int d=0;d_processors[d] == fine->_processors[d+lowerdims]); + for(int d=0;d_processors[d]==1); + for(int d=0;d_processors[d] == fine->_processors[d+lowerdims]); // then divide the number of local sites // check that the total number of sims agree, meanse the iSites are the same - assert(fine->Nsimd() == coarse->Nsimd()); + GRID_ASSERT(fine->Nsimd() == coarse->Nsimd()); // check that the two grids divide cleanly - assert( (fine->lSites() / coarse->lSites() ) * coarse->lSites() == fine->lSites() ); + GRID_ASSERT( (fine->lSites() / coarse->lSites() ) * coarse->lSites() == fine->lSites() ); return fine->lSites() / coarse->lSites(); } @@ -177,7 +177,7 @@ public: skip = skip<> shift)==site); // check for overflow + GRID_ASSERT((skip >> shift)==site); // check for overflow eng.discard(skip); #else @@ -218,7 +218,7 @@ public: GetState(saved,_generators[gen]); } void SetState(std::vector & saved,RngEngine &eng){ - assert(saved.size()==RngStateCount); + GRID_ASSERT(saved.size()==RngStateCount); std::stringstream ss; for(int i=0;i_ndimension == fine->_ndimension); + GRID_ASSERT(coarse->_ndimension == fine->_ndimension); int _ndimension = coarse->_ndimension; // local and global volumes subdivide cleanly after SIMDization for(int d=0;d<_ndimension;d++){ - assert(coarse->_processors[d] == fine->_processors[d]); - assert(coarse->_simd_layout[d] == fine->_simd_layout[d]); - assert((fine->_rdimensions[d] / coarse->_rdimensions[d])* coarse->_rdimensions[d]==fine->_rdimensions[d]); + GRID_ASSERT(coarse->_processors[d] == fine->_processors[d]); + GRID_ASSERT(coarse->_simd_layout[d] == fine->_simd_layout[d]); + GRID_ASSERT((fine->_rdimensions[d] / coarse->_rdimensions[d])* coarse->_rdimensions[d]==fine->_rdimensions[d]); } } @@ -102,7 +102,7 @@ template inline void acceleratorPickCheckerboard(int cb,Lattice inline void acceleratorSetCheckerboard(Lattice &full, int linear=0; Lexicographic::CoorFromIndex(coor,ss,rdim_full); - assert(coor.size()==ndim_half); + GRID_ASSERT(coor.size()==ndim_half); for(int d=0;d>> &co const VLattice &Basis) { int NBatch = fineData.size(); - assert(coarseData.size() == NBatch); + GRID_ASSERT(coarseData.size() == NBatch); GridBase * fine = fineData[0].Grid(); GridBase * coarse= coarseData[0].Grid(); @@ -344,7 +344,7 @@ template GridBase * coarse= coarseA.Grid(); fineZ.Checkerboard()=fineX.Checkerboard(); - assert(fineX.Checkerboard()==fineY.Checkerboard()); + GRID_ASSERT(fineX.Checkerboard()==fineY.Checkerboard()); subdivides(coarse,fine); // require they map conformable(fineX,fineY); conformable(fineX,fineZ); @@ -356,7 +356,7 @@ template // FIXME merge with subdivide checking routine as this is redundant for(int d=0 ; d<_ndimension;d++){ block_r[d] = fine->_rdimensions[d] / coarse->_rdimensions[d]; - assert(block_r[d]*coarse->_rdimensions[d]==fine->_rdimensions[d]); + GRID_ASSERT(block_r[d]*coarse->_rdimensions[d]==fine->_rdimensions[d]); } autoView( fineZ_ , fineZ, AcceleratorWrite); @@ -613,7 +613,7 @@ inline void blockPromote(const Lattice > &coarseData, int _ndimension = coarse->_ndimension; // checks - assert( nbasis == Basis.size() ); + GRID_ASSERT( nbasis == Basis.size() ); subdivides(coarse,fine); for(int i=0;i const VLattice &Basis) { int NBatch = coarseData.size(); - assert(fineData.size() == NBatch); + GRID_ASSERT(fineData.size() == NBatch); GridBase * fine = fineData[0].Grid(); GridBase * coarse = coarseData[0].Grid(); @@ -715,12 +715,12 @@ void localConvert(const Lattice &in,Lattice &out) int ni = ig->_ndimension; int no = og->_ndimension; - assert(ni == no); + GRID_ASSERT(ni == no); for(int d=0;d_processors[d] == og->_processors[d]); - assert(ig->_ldimensions[d] == og->_ldimensions[d]); - assert(ig->lSites() == og->lSites()); + GRID_ASSERT(ig->_processors[d] == og->_processors[d]); + GRID_ASSERT(ig->_ldimensions[d] == og->_ldimensions[d]); + GRID_ASSERT(ig->lSites() == og->lSites()); } autoView(in_v,in,CpuRead); @@ -752,16 +752,16 @@ void localCopyRegion(const Lattice &From,Lattice & To,Coordinate Fro GridBase *Fg = From.Grid(); GridBase *Tg = To.Grid(); - assert(!Fg->_isCheckerBoarded); - assert(!Tg->_isCheckerBoarded); + GRID_ASSERT(!Fg->_isCheckerBoarded); + GRID_ASSERT(!Tg->_isCheckerBoarded); int Nsimd = Fg->Nsimd(); int nF = Fg->_ndimension; int nT = Tg->_ndimension; int nd = nF; - assert(nF == nT); + GRID_ASSERT(nF == nT); for(int d=0;d_processors[d] == Tg->_processors[d]); + GRID_ASSERT(Fg->_processors[d] == Tg->_processors[d]); } /////////////////////////////////////////////////////////// @@ -821,12 +821,12 @@ void InsertSliceFast(const Lattice &From,Lattice & To,int slice, int ////////////////////////////////////////////////////////////////////////////////////////// GridBase *Fg = From.Grid(); GridBase *Tg = To.Grid(); - assert(!Fg->_isCheckerBoarded); - assert(!Tg->_isCheckerBoarded); + GRID_ASSERT(!Fg->_isCheckerBoarded); + GRID_ASSERT(!Tg->_isCheckerBoarded); int Nsimd = Fg->Nsimd(); int nF = Fg->_ndimension; int nT = Tg->_ndimension; - assert(nF+1 == nT); + GRID_ASSERT(nF+1 == nT); /////////////////////////////////////////////////////////// // do the index calc on the GPU @@ -890,12 +890,12 @@ void ExtractSliceFast(Lattice &To,const Lattice & From,int slice, in ////////////////////////////////////////////////////////////////////////////////////////// GridBase *Fg = From.Grid(); GridBase *Tg = To.Grid(); - assert(!Fg->_isCheckerBoarded); - assert(!Tg->_isCheckerBoarded); + GRID_ASSERT(!Fg->_isCheckerBoarded); + GRID_ASSERT(!Tg->_isCheckerBoarded); int Nsimd = Fg->Nsimd(); int nF = Fg->_ndimension; int nT = Tg->_ndimension; - assert(nT+1 == nF); + GRID_ASSERT(nT+1 == nF); /////////////////////////////////////////////////////////// // do the index calc on the GPU @@ -955,16 +955,16 @@ void InsertSlice(const Lattice &lowDim,Lattice & higherDim,int slice int nl = lg->_ndimension; int nh = hg->_ndimension; - assert(nl+1 == nh); - assert(orthog=0); - assert(hg->_processors[orthog]==1); + GRID_ASSERT(nl+1 == nh); + GRID_ASSERT(orthog=0); + GRID_ASSERT(hg->_processors[orthog]==1); int dl; dl = 0; for(int d=0;d_processors[dl] == hg->_processors[d]); - assert(lg->_ldimensions[dl] == hg->_ldimensions[d]); + GRID_ASSERT(lg->_processors[dl] == hg->_processors[d]); + GRID_ASSERT(lg->_ldimensions[dl] == hg->_ldimensions[d]); dl++; } } @@ -1005,17 +1005,17 @@ void ExtractSlice(Lattice &lowDim,const Lattice & higherDim,int slic int nl = lg->_ndimension; int nh = hg->_ndimension; - assert(nl+1 == nh); - assert(orthog=0); - assert(hg->_processors[orthog]==1); + GRID_ASSERT(nl+1 == nh); + GRID_ASSERT(orthog=0); + GRID_ASSERT(hg->_processors[orthog]==1); lowDim.Checkerboard() = higherDim.Checkerboard(); int dl; dl = 0; for(int d=0;d_processors[dl] == hg->_processors[d]); - assert(lg->_ldimensions[dl] == hg->_ldimensions[d]); + GRID_ASSERT(lg->_processors[dl] == hg->_processors[d]); + GRID_ASSERT(lg->_ldimensions[dl] == hg->_ldimensions[d]); dl++; } } @@ -1056,14 +1056,14 @@ void InsertSliceLocal(const Lattice &lowDim, Lattice & higherDim,int int nl = lg->_ndimension; int nh = hg->_ndimension; - assert(nl == nh); - assert(orthog=0); + GRID_ASSERT(nl == nh); + GRID_ASSERT(orthog=0); for(int d=0;d_processors[d] == hg->_processors[d]); - assert(lg->_ldimensions[d] == hg->_ldimensions[d]); + GRID_ASSERT(lg->_processors[d] == hg->_processors[d]); + GRID_ASSERT(lg->_ldimensions[d] == hg->_ldimensions[d]); } } Coordinate sz = lg->_ldimensions; @@ -1093,7 +1093,7 @@ void Replicate(const Lattice &coarse,Lattice & fine) subdivides(cg,fg); - assert(cg->_ndimension==fg->_ndimension); + GRID_ASSERT(cg->_ndimension==fg->_ndimension); Coordinate ratio(cg->_ndimension); @@ -1157,7 +1157,7 @@ unvectorizeToLexOrdArray(std::vector &out, const Lattice &in) int lex; Lexicographic::IndexFromCoor(lcoor, lex, in_grid->_ldimensions); - assert(lex < out.size()); + GRID_ASSERT(lex < out.size()); out_ptrs[lane] = &out[lex]; } @@ -1221,7 +1221,7 @@ vectorizeFromLexOrdArray( std::vector &in, Lattice &out) typedef typename vobj::vector_type vtype; GridBase* grid = out.Grid(); - assert(in.size()==grid->lSites()); + GRID_ASSERT(in.size()==grid->lSites()); const int ndim = grid->Nd(); constexpr int nsimd = vtype::Nsimd(); @@ -1268,7 +1268,7 @@ vectorizeFromRevLexOrdArray( std::vector &in, Lattice &out) typedef typename vobj::vector_type vtype; GridBase* grid = out._grid; - assert(in.size()==grid->lSites()); + GRID_ASSERT(in.size()==grid->lSites()); int ndim = grid->Nd(); int nsimd = vtype::Nsimd(); @@ -1329,9 +1329,9 @@ void precisionChangeFast(Lattice &out, const Lattice &in) template void precisionChangeOrig(Lattice &out, const Lattice &in) { - assert(out.Grid()->Nd() == in.Grid()->Nd()); + GRID_ASSERT(out.Grid()->Nd() == in.Grid()->Nd()); for(int d=0;dNd();d++){ - assert(out.Grid()->FullDimensions()[d] == in.Grid()->FullDimensions()[d]); + GRID_ASSERT(out.Grid()->FullDimensions()[d] == in.Grid()->FullDimensions()[d]); } out.Checkerboard() = in.Checkerboard(); GridBase *in_grid=in.Grid(); @@ -1382,9 +1382,9 @@ class precisionChangeWorkspace{ public: precisionChangeWorkspace(GridBase *out_grid, GridBase *in_grid): _out_grid(out_grid), _in_grid(in_grid){ //Build a map between the sites and lanes of the output field and the input field as we cannot use the Grids on the device - assert(out_grid->Nd() == in_grid->Nd()); + GRID_ASSERT(out_grid->Nd() == in_grid->Nd()); for(int d=0;dNd();d++){ - assert(out_grid->FullDimensions()[d] == in_grid->FullDimensions()[d]); + GRID_ASSERT(out_grid->FullDimensions()[d] == in_grid->FullDimensions()[d]); } int Nsimd_out = out_grid->Nsimd(); @@ -1549,7 +1549,7 @@ void Grid_split(std::vector > & full,Lattice & split) int full_vecs = full.size(); - assert(full_vecs>=1); + GRID_ASSERT(full_vecs>=1); GridBase * full_grid = full[0].Grid(); GridBase *split_grid = split.Grid(); @@ -1567,18 +1567,18 @@ void Grid_split(std::vector > & full,Lattice & split) ////////////////////////////// // Checks ////////////////////////////// - assert(full_grid->_ndimension==split_grid->_ndimension); + GRID_ASSERT(full_grid->_ndimension==split_grid->_ndimension); for(int n=0;n_gdimensions[d]==split.Grid()->_gdimensions[d]); - assert(full[n].Grid()->_fdimensions[d]==split.Grid()->_fdimensions[d]); + GRID_ASSERT(full[n].Grid()->_gdimensions[d]==split.Grid()->_gdimensions[d]); + GRID_ASSERT(full[n].Grid()->_fdimensions[d]==split.Grid()->_fdimensions[d]); } } int nvector =full_nproc/split_nproc; - assert(nvector*split_nproc==full_nproc); - assert(nvector == full_vecs); + GRID_ASSERT(nvector*split_nproc==full_nproc); + GRID_ASSERT(nvector == full_vecs); Coordinate ratio(ndim); for(int d=0;d > & full,Lattice & split) int fvol = lsites; - int chunk = (nvec*fvol)/sP; assert(chunk*sP == nvec*fvol); + int chunk = (nvec*fvol)/sP; GRID_ASSERT(chunk*sP == nvec*fvol); // Loop over reordered data post A2A thread_for(c, chunk, { @@ -1675,7 +1675,7 @@ void Grid_unsplit(std::vector > & full,Lattice & split) int full_vecs = full.size(); - assert(full_vecs>=1); + GRID_ASSERT(full_vecs>=1); GridBase * full_grid = full[0].Grid(); GridBase *split_grid = split.Grid(); @@ -1693,18 +1693,18 @@ void Grid_unsplit(std::vector > & full,Lattice & split) ////////////////////////////// // Checks ////////////////////////////// - assert(full_grid->_ndimension==split_grid->_ndimension); + GRID_ASSERT(full_grid->_ndimension==split_grid->_ndimension); for(int n=0;n_gdimensions[d]==split.Grid()->_gdimensions[d]); - assert(full[n].Grid()->_fdimensions[d]==split.Grid()->_fdimensions[d]); + GRID_ASSERT(full[n].Grid()->_gdimensions[d]==split.Grid()->_gdimensions[d]); + GRID_ASSERT(full[n].Grid()->_fdimensions[d]==split.Grid()->_fdimensions[d]); } } int nvector =full_nproc/split_nproc; - assert(nvector*split_nproc==full_nproc); - assert(nvector == full_vecs); + GRID_ASSERT(nvector*split_nproc==full_nproc); + GRID_ASSERT(nvector == full_vecs); Coordinate ratio(ndim); for(int d=0;d > & full,Lattice & split) auto lsites= rsites/M; // Decreases rsites by M int fvol = lsites; - int chunk = (nvec*fvol)/sP; assert(chunk*sP == nvec*fvol); + int chunk = (nvec*fvol)/sP; GRID_ASSERT(chunk*sP == nvec*fvol); { // Loop over reordered data post A2A diff --git a/Grid/lattice/Lattice_view.h b/Grid/lattice/Lattice_view.h index 1df4e6e0..a1b46347 100644 --- a/Grid/lattice/Lattice_view.h +++ b/Grid/lattice/Lattice_view.h @@ -10,7 +10,7 @@ class LatticeBase {}; ///////////////////////////////////////////////////////////////////////////////////////// void accelerator_inline conformable(GridBase *lhs,GridBase *rhs) { - assert(lhs == rhs); + GRID_ASSERT(lhs == rhs); } //////////////////////////////////////////////////////////////////////////// @@ -123,7 +123,7 @@ public: case AcceleratorWrite: case CpuRead: case CpuWrite: - ViewLogger::Log(filename, line, 1, mode, &v[0], v.size() * sizeof(v[0])); + ViewLogger::LogOpen(filename, line, 1, mode, &v[0], v.size() * sizeof(v[0])); break; } @@ -134,7 +134,7 @@ public: case AcceleratorWriteDiscard: case AcceleratorWrite: case CpuWrite: - ViewLogger::Log(filename, line, -1, mode, &v[0], v.size() * sizeof(v[0])); + ViewLogger::LogClose(filename, line, -1, mode, &v[0], v.size() * sizeof(v[0])); break; } diff --git a/Grid/lattice/PaddedCell.h b/Grid/lattice/PaddedCell.h index 0340698c..23f6c13a 100644 --- a/Grid/lattice/PaddedCell.h +++ b/Grid/lattice/PaddedCell.h @@ -82,10 +82,10 @@ template inline void ScatterSlice(const deviceVector &buf, int rNsimd = 1; for(int d=0;d inline void GatherSlice(deviceVector &buf, int face_ovol=block*nblock; - // assert(buf.size()==face_ovol*rNsimd); + // GRID_ASSERT(buf.size()==face_ovol*rNsimd); /*This will work GPU ONLY unless rNsimd is put in the lexico index*/ //Let's make it work on GPU and then make a special accelerator_for that @@ -247,7 +247,7 @@ public: Coordinate local =unpadded_grid->LocalDimensions(); Coordinate procs =unpadded_grid->ProcessorGrid(); for(int d=0;d 1 ) assert(local[d]>=depth); + if ( procs[d] > 1 ) GRID_ASSERT(local[d]>=depth); } } void DeleteGrids(void) @@ -448,9 +448,9 @@ public: int nld = to.Grid()->_ldimensions[dimension]; const int Nsimd = vobj::Nsimd(); - assert(depth<=lds[dimension]); // A must be on neighbouring node - assert(depth>0); // A caller bug if zero - assert(ld+2*depth==nld); + GRID_ASSERT(depth<=lds[dimension]); // A must be on neighbouring node + GRID_ASSERT(depth>0); // A caller bug if zero + GRID_ASSERT(ld+2*depth==nld); //////////////////////////////////////////////////////////////////////////// // Face size and byte calculations //////////////////////////////////////////////////////////////////////////// @@ -460,7 +460,7 @@ public: } buffer_size = buffer_size / Nsimd; int rNsimd = Nsimd / simd[dimension]; - assert( buffer_size == from.Grid()->_slice_nblock[dimension]*from.Grid()->_slice_block[dimension] / simd[dimension]); + GRID_ASSERT( buffer_size == from.Grid()->_slice_nblock[dimension]*from.Grid()->_slice_block[dimension] / simd[dimension]); static deviceVector send_buf; static deviceVector recv_buf; diff --git a/Grid/log/Log.h b/Grid/log/Log.h index ec6becd6..c761db00 100644 --- a/Grid/log/Log.h +++ b/Grid/log/Log.h @@ -33,10 +33,6 @@ #ifndef GRID_LOG_H #define GRID_LOG_H -#ifdef HAVE_EXECINFO_H -#include -#endif - NAMESPACE_BEGIN(Grid); ////////////////////////////////////////////////////////////////////////////////////////////////// @@ -227,8 +223,6 @@ inline void Grid_pass(Args&&... args) { std::cout << "\033[32m" << GridLogMessage << msg << "\033[0m" << std::endl; } -#define _NBACKTRACE (256) -extern void * Grid_backtrace_buffer[_NBACKTRACE]; #define BACKTRACEFILE() { \ char string[20]; \ diff --git a/Grid/parallelIO/BinaryIO.h b/Grid/parallelIO/BinaryIO.h index 32964565..476a6513 100644 --- a/Grid/parallelIO/BinaryIO.h +++ b/Grid/parallelIO/BinaryIO.h @@ -293,9 +293,9 @@ class BinaryIO { // Flatten the file uint64_t lsites = grid->lSites(); if ( control & BINARYIO_MASTER_APPEND ) { - assert(iodata.size()==1); + GRID_ASSERT(iodata.size()==1); } else { - assert(lsites==iodata.size()); + GRID_ASSERT(lsites==iodata.size()); } for(int d=0;d 1) ) { #ifdef USE_MPI_IO std::cout<< GridLogMessage<<"IOobject: MPI read I/O "<< file<< std::endl; - ierr=MPI_File_open(grid->communicator,(char *) file.c_str(), MPI_MODE_RDONLY, MPI_INFO_NULL, &fh); assert(ierr==0); - ierr=MPI_File_set_view(fh, disp, mpiObject, fileArray, "native", MPI_INFO_NULL); assert(ierr==0); - ierr=MPI_File_read_all(fh, &iodata[0], 1, localArray, &status); assert(ierr==0); + ierr=MPI_File_open(grid->communicator,(char *) file.c_str(), MPI_MODE_RDONLY, MPI_INFO_NULL, &fh); GRID_ASSERT(ierr==0); + ierr=MPI_File_set_view(fh, disp, mpiObject, fileArray, "native", MPI_INFO_NULL); GRID_ASSERT(ierr==0); + ierr=MPI_File_read_all(fh, &iodata[0], 1, localArray, &status); GRID_ASSERT(ierr==0); MPI_File_close(&fh); MPI_Type_free(&fileArray); MPI_Type_free(&localArray); @@ -384,7 +384,7 @@ class BinaryIO { fin.seekg(offset + myrank * lsites * sizeof(fobj)); } fin.read((char *)&iodata[0], iodata.size() * sizeof(fobj)); - assert(fin.fail() == 0); + GRID_ASSERT(fin.fail() == 0); fin.close(); } timer.Stop(); @@ -435,11 +435,11 @@ class BinaryIO { std::cout << GridLogDebug << "MPI write I/O set view " << file << std::endl; ierr = MPI_File_set_view(fh, disp, mpiObject, fileArray, "native", MPI_INFO_NULL); - assert(ierr == 0); + GRID_ASSERT(ierr == 0); std::cout << GridLogDebug << "MPI write I/O write all " << file << std::endl; ierr = MPI_File_write_all(fh, &iodata[0], 1, localArray, &status); - assert(ierr == 0); + GRID_ASSERT(ierr == 0); MPI_Offset os; MPI_File_get_position(fh, &os); diff --git a/Grid/parallelIO/IldgIO.h b/Grid/parallelIO/IldgIO.h index 688d1ac9..8ed7df5b 100644 --- a/Grid/parallelIO/IldgIO.h +++ b/Grid/parallelIO/IldgIO.h @@ -289,7 +289,7 @@ class GridLimeReader : public BinaryIO { return; } } - assert(0); + GRID_ASSERT(0); } //////////////////////////////////////////// // Read a generic serialisable object @@ -314,7 +314,7 @@ class GridLimeReader : public BinaryIO { } } - assert(0); + GRID_ASSERT(0); } template @@ -348,7 +348,7 @@ class GridLimeWriter : public BinaryIO filename= _filename; if ( boss_node ) { File = fopen(filename.c_str(), "w"); - LimeW = limeCreateWriter(File); assert(LimeW != NULL ); + LimeW = limeCreateWriter(File); GRID_ASSERT(LimeW != NULL ); } } ///////////////////////////////////////////// @@ -368,7 +368,7 @@ class GridLimeWriter : public BinaryIO if ( boss_node ) { LimeRecordHeader *h; h = limeCreateHeader(MB, ME, const_cast(message.c_str()), PayloadSize); - assert(limeWriteRecordHeader(h, LimeW) >= 0); + GRID_ASSERT(limeWriteRecordHeader(h, LimeW) >= 0); limeDestroyHeader(h); } return LIME_SUCCESS; @@ -386,11 +386,11 @@ class GridLimeWriter : public BinaryIO // std::cout << " xmlstring "<< nbytes<< " " << xmlstring <(record_name.c_str()), nbytes); - assert(h!= NULL); + GRID_ASSERT(h!= NULL); - err=limeWriteRecordHeader(h, LimeW); assert(err>=0); - err=limeWriteRecordData(&xmlstring[0], &nbytes, LimeW); assert(err>=0); - err=limeWriterCloseRecord(LimeW); assert(err>=0); + err=limeWriteRecordHeader(h, LimeW); GRID_ASSERT(err>=0); + err=limeWriteRecordData(&xmlstring[0], &nbytes, LimeW); GRID_ASSERT(err>=0); + err=limeWriterCloseRecord(LimeW); GRID_ASSERT(err>=0); limeDestroyHeader(h); } } @@ -431,7 +431,7 @@ class GridLimeWriter : public BinaryIO //////////////////////////////////////////////////////////////////// GridBase *grid = field.Grid(); - assert(boss_node == field.Grid()->IsBoss() ); + GRID_ASSERT(boss_node == field.Grid()->IsBoss() ); FieldNormMetaData FNMD; FNMD.norm2 = norm2(field); @@ -473,7 +473,7 @@ class GridLimeWriter : public BinaryIO if ( boss_node ) { fseek(File,0,SEEK_END); uint64_t offset2 = ftello(File); // std::cout << " now at offset "<=0); + err=limeWriterCloseRecord(LimeW); GRID_ASSERT(err>=0); } //////////////////////////////////////// // Write checksum element, propagaing forward from the BinaryIO @@ -621,8 +621,8 @@ class IldgWriter : public ScidacWriter { uint64_t PayloadSize = LFN.size(); int err; createLimeRecordHeader(ILDG_DATA_LFN, 0 , 0, PayloadSize); - err=limeWriteRecordData(const_cast(LFN.c_str()), &PayloadSize,LimeW); assert(err>=0); - err=limeWriterCloseRecord(LimeW); assert(err>=0); + err=limeWriteRecordData(const_cast(LFN.c_str()), &PayloadSize,LimeW); GRID_ASSERT(err>=0); + err=limeWriterCloseRecord(LimeW); GRID_ASSERT(err>=0); } //////////////////////////////////////////////////////////////// @@ -656,7 +656,7 @@ class IldgWriter : public ScidacWriter { header.sequence_number = sequence; header.ildg_lfn = LFN; - assert ( (format == std::string("IEEE32BIG")) + GRID_ASSERT ( (format == std::string("IEEE32BIG")) ||(format == std::string("IEEE64BIG")) ); ////////////////////////////////////////////////////// @@ -676,8 +676,8 @@ class IldgWriter : public ScidacWriter { ildgfmt.ly = header.dimension[1]; ildgfmt.lz = header.dimension[2]; ildgfmt.lt = header.dimension[3]; - assert(header.nd==4); - assert(header.nd==header.dimension.size()); + GRID_ASSERT(header.nd==4); + GRID_ASSERT(header.nd==header.dimension.size()); ////////////////////////////////////////////////////////////////////////////// // Field norm tests @@ -734,7 +734,7 @@ class IldgReader : public GridLimeReader { Coordinate dims = Umu.Grid()->FullDimensions(); - assert(dims.size()==4); + GRID_ASSERT(dims.size()==4); // Metadata holders ildgFormat ildgFormat_ ; @@ -793,10 +793,10 @@ class IldgReader : public GridLimeReader { if ( ildgFormat_.precision == 64 ) format = std::string("IEEE64BIG"); if ( ildgFormat_.precision == 32 ) format = std::string("IEEE32BIG"); - assert( ildgFormat_.lx == dims[0]); - assert( ildgFormat_.ly == dims[1]); - assert( ildgFormat_.lz == dims[2]); - assert( ildgFormat_.lt == dims[3]); + GRID_ASSERT( ildgFormat_.lx == dims[0]); + GRID_ASSERT( ildgFormat_.ly == dims[1]); + GRID_ASSERT( ildgFormat_.lz == dims[2]); + GRID_ASSERT( ildgFormat_.lt == dims[3]); found_ildgFormat = 1; } @@ -813,10 +813,10 @@ class IldgReader : public GridLimeReader { format = FieldMetaData_.floating_point; - assert(FieldMetaData_.dimension[0] == dims[0]); - assert(FieldMetaData_.dimension[1] == dims[1]); - assert(FieldMetaData_.dimension[2] == dims[2]); - assert(FieldMetaData_.dimension[3] == dims[3]); + GRID_ASSERT(FieldMetaData_.dimension[0] == dims[0]); + GRID_ASSERT(FieldMetaData_.dimension[1] == dims[1]); + GRID_ASSERT(FieldMetaData_.dimension[2] == dims[2]); + GRID_ASSERT(FieldMetaData_.dimension[3] == dims[3]); found_FieldMetaData = 1; } @@ -866,13 +866,13 @@ class IldgReader : public GridLimeReader { // Minimally must find binary segment and checksum // Since this is an ILDG reader require ILDG format ////////////////////////////////////////////////////// - assert(found_ildgLFN); - assert(found_ildgBinary); - assert(found_ildgFormat); - assert(found_scidacChecksum); + GRID_ASSERT(found_ildgLFN); + GRID_ASSERT(found_ildgBinary); + GRID_ASSERT(found_ildgFormat); + GRID_ASSERT(found_scidacChecksum); // Must find something with the lattice dimensions - assert(found_FieldMetaData||found_ildgFormat); + GRID_ASSERT(found_FieldMetaData||found_ildgFormat); if ( found_FieldMetaData ) { @@ -880,9 +880,9 @@ class IldgReader : public GridLimeReader { } else { - assert(found_ildgFormat); + GRID_ASSERT(found_ildgFormat); const std::string stNC = std::to_string( Nc ) ; - assert ( ildgFormat_.field == std::string("su"+stNC+"gauge") ); + GRID_ASSERT ( ildgFormat_.field == std::string("su"+stNC+"gauge") ); /////////////////////////////////////////////////////////////////////////////////////// // Populate our Grid metadata as best we can @@ -927,20 +927,20 @@ class IldgReader : public GridLimeReader { FieldMetaData_.scidac_checksuma = stoull(scidacChecksum_.suma,0,16); FieldMetaData_.scidac_checksumb = stoull(scidacChecksum_.sumb,0,16); scidacChecksumVerify(scidacChecksum_,scidac_csuma,scidac_csumb); - assert( scidac_csuma ==FieldMetaData_.scidac_checksuma); - assert( scidac_csumb ==FieldMetaData_.scidac_checksumb); + GRID_ASSERT( scidac_csuma ==FieldMetaData_.scidac_checksuma); + GRID_ASSERT( scidac_csumb ==FieldMetaData_.scidac_checksumb); std::cout << GridLogMessage<<"SciDAC checksums match " << std::endl; } else { std::cout << GridLogWarning<<"SciDAC checksums not found. This is unsafe. " << std::endl; - assert(0); // Can I insist always checksum ? + GRID_ASSERT(0); // Can I insist always checksum ? } if ( found_FieldMetaData || found_usqcdInfo ) { FieldMetaData checker; stats Stats; Stats(Umu,checker); - assert(fabs(checker.plaquette - FieldMetaData_.plaquette )<1.0e-5); - assert(fabs(checker.link_trace - FieldMetaData_.link_trace)<1.0e-5); + GRID_ASSERT(fabs(checker.plaquette - FieldMetaData_.plaquette )<1.0e-5); + GRID_ASSERT(fabs(checker.link_trace - FieldMetaData_.link_trace)<1.0e-5); std::cout << GridLogMessage<<"Plaquette and link trace match " << std::endl; } } diff --git a/Grid/parallelIO/MetaData.h b/Grid/parallelIO/MetaData.h index 6b9d8708..1fc3fe31 100644 --- a/Grid/parallelIO/MetaData.h +++ b/Grid/parallelIO/MetaData.h @@ -203,7 +203,7 @@ template<> inline void PrepareMetaData(Lattice 1 ) ; + GRID_ASSERT( Nc < 4 && Nc > 1 ) ; for(int mu=0;mu_ndimension == 4); + GRID_ASSERT(grid->_ndimension == 4); for(int d=0;d<4;d++){ - assert(grid->_fdimensions[d]==field.dimension[d]); + GRID_ASSERT(grid->_fdimensions[d]==field.dimension[d]); } field.link_trace = std::stod(header["LINK_TRACE"]); @@ -183,7 +183,7 @@ public: nersc_csum,scidac_csuma,scidac_csumb); } } else { - assert(0); + GRID_ASSERT(0); } GaugeStats Stats; Stats(Umu,clone); @@ -205,9 +205,9 @@ public: std::cerr << " nersc_csum " <(&header), sizeof(OpenQcdHeader)); - assert(!fin.fail()); + GRID_ASSERT(!fin.fail()); field.data_start = fin.tellg(); fin.close(); } @@ -57,10 +57,10 @@ public: header.plaq /= normalisationFactor; // sanity check (should trigger on endian issues) - assert(0 < header.Nt && header.Nt <= 1024); - assert(0 < header.Nx && header.Nx <= 1024); - assert(0 < header.Ny && header.Ny <= 1024); - assert(0 < header.Nz && header.Nz <= 1024); + GRID_ASSERT(0 < header.Nt && header.Nt <= 1024); + GRID_ASSERT(0 < header.Nx && header.Nx <= 1024); + GRID_ASSERT(0 < header.Ny && header.Ny <= 1024); + GRID_ASSERT(0 < header.Nz && header.Nz <= 1024); field.dimension[0] = header.Nx; field.dimension[1] = header.Ny; @@ -71,9 +71,9 @@ public: std::cout << GridLogDebug << "grid dimensions: " << grid->_fdimensions << std::endl; std::cout << GridLogDebug << "file dimensions: " << field.dimension << std::endl; - assert(grid->_ndimension == Nd); + GRID_ASSERT(grid->_ndimension == Nd); for(int d = 0; d < Nd; d++) - assert(grid->_fdimensions[d] == field.dimension[d]); + GRID_ASSERT(grid->_fdimensions[d] == field.dimension[d]); field.plaquette = header.plaq; @@ -86,10 +86,10 @@ public: std::string file) { typedef Lattice> DoubleStoredGaugeField; - assert(Ns == 4 and Nd == 4 and Nc == 3); + GRID_ASSERT(Ns == 4 and Nd == 4 and Nc == 3); auto grid = dynamic_cast(Umu.Grid()); - assert(grid != nullptr); assert(grid->_ndimension == Nd); + GRID_ASSERT(grid != nullptr); GRID_ASSERT(grid->_ndimension == Nd); uint64_t offset = readHeader(file, Umu.Grid(), header); @@ -171,7 +171,7 @@ public: if(plaq_diff >= tol) std::cout << " Plaquette mismatch (diff = " << plaq_diff << ", tol = " << tol << ")" << std::endl; - assert(plaq_diff < tol); + GRID_ASSERT(plaq_diff < tol); std::cout << GridLogMessage << "OpenQcd Configuration " << file << " and plaquette agree" << std::endl; } diff --git a/Grid/parallelIO/OpenQcdIOChromaReference.h b/Grid/parallelIO/OpenQcdIOChromaReference.h index 886536ad..c2bf22e7 100644 --- a/Grid/parallelIO/OpenQcdIOChromaReference.h +++ b/Grid/parallelIO/OpenQcdIOChromaReference.h @@ -62,7 +62,7 @@ public: : swap(false) , grid(gridPtr) { err = MPI_File_open(comm, const_cast(filename.c_str()), MPI_MODE_RDONLY, MPI_INFO_NULL, &fp); - assert(err == MPI_SUCCESS); + GRID_ASSERT(err == MPI_SUCCESS); } virtual ~ParRdr() { MPI_File_close(&fp); } @@ -76,8 +76,8 @@ public: } int readHeader(FieldMetaData& field) { - assert((grid->_ndimension == Nd) && (Nd == 4)); - assert(Nc == 3); + GRID_ASSERT((grid->_ndimension == Nd) && (Nd == 4)); + GRID_ASSERT(Nc == 3); OpenQcdHeader header; @@ -86,10 +86,10 @@ public: header.plaq /= 3.; // TODO change this into normalizationfactor // sanity check (should trigger on endian issues) TODO remove? - assert(0 < header.Nt && header.Nt <= 1024); - assert(0 < header.Nx && header.Nx <= 1024); - assert(0 < header.Ny && header.Ny <= 1024); - assert(0 < header.Nz && header.Nz <= 1024); + GRID_ASSERT(0 < header.Nt && header.Nt <= 1024); + GRID_ASSERT(0 < header.Nx && header.Nx <= 1024); + GRID_ASSERT(0 < header.Ny && header.Ny <= 1024); + GRID_ASSERT(0 < header.Nz && header.Nz <= 1024); field.dimension[0] = header.Nx; field.dimension[1] = header.Ny; @@ -97,7 +97,7 @@ public: field.dimension[3] = header.Nt; for(int d = 0; d < Nd; d++) - assert(grid->FullDimensions()[d] == field.dimension[d]); + GRID_ASSERT(grid->FullDimensions()[d] == field.dimension[d]); field.plaquette = header.plaq; @@ -114,15 +114,15 @@ public: int read = -1; MPI_Get_count(&status, datatype, &read); // CHECK_VAR(read) - assert(nbytes == (uint64_t)read); - assert(err == MPI_SUCCESS); + GRID_ASSERT(nbytes == (uint64_t)read); + GRID_ASSERT(err == MPI_SUCCESS); } void createTypes() { constexpr int elem_size = Nd * 2 * 2 * Nc * Nc * sizeof(double); // 2_complex 2_fwdbwd - err = MPI_Type_contiguous(elem_size, MPI_BYTE, &oddSiteType); assert(err == MPI_SUCCESS); - err = MPI_Type_commit(&oddSiteType); assert(err == MPI_SUCCESS); + err = MPI_Type_contiguous(elem_size, MPI_BYTE, &oddSiteType); GRID_ASSERT(err == MPI_SUCCESS); + err = MPI_Type_commit(&oddSiteType); GRID_ASSERT(err == MPI_SUCCESS); Coordinate const L = grid->GlobalDimensions(); Coordinate const l = grid->LocalDimensions(); @@ -132,20 +132,20 @@ public: Coordinate subsizes({l[2] / 2, l[1], l[0], l[3]}); Coordinate starts({i[2] * l[2] / 2, i[1] * l[1], i[0] * l[0], i[3] * l[3]}); - err = MPI_Type_create_subarray(grid->_ndimension, &sizes[0], &subsizes[0], &starts[0], MPI_ORDER_FORTRAN, oddSiteType, &fileViewType); assert(err == MPI_SUCCESS); - err = MPI_Type_commit(&fileViewType); assert(err == MPI_SUCCESS); + err = MPI_Type_create_subarray(grid->_ndimension, &sizes[0], &subsizes[0], &starts[0], MPI_ORDER_FORTRAN, oddSiteType, &fileViewType); GRID_ASSERT(err == MPI_SUCCESS); + err = MPI_Type_commit(&fileViewType); GRID_ASSERT(err == MPI_SUCCESS); } void freeTypes() { - err = MPI_Type_free(&fileViewType); assert(err == MPI_SUCCESS); - err = MPI_Type_free(&oddSiteType); assert(err == MPI_SUCCESS); + err = MPI_Type_free(&fileViewType); GRID_ASSERT(err == MPI_SUCCESS); + err = MPI_Type_free(&oddSiteType); GRID_ASSERT(err == MPI_SUCCESS); } bool readGauge(std::vector& domain_buff, FieldMetaData& meta) { auto hdr_offset = readHeader(meta); CHECK createTypes(); - err = MPI_File_set_view(fp, hdr_offset, oddSiteType, fileViewType, "native", MPI_INFO_NULL); errInfo(err, "MPI_File_set_view0"); assert(err == MPI_SUCCESS); + err = MPI_File_set_view(fp, hdr_offset, oddSiteType, fileViewType, "native", MPI_INFO_NULL); errInfo(err, "MPI_File_set_view0"); GRID_ASSERT(err == MPI_SUCCESS); CHECK int const domainSites = grid->lSites(); domain_buff.resize(Nd * domainSites); // 2_fwdbwd * 4_Nd * domainSites / 2_onlyodd @@ -166,7 +166,7 @@ public: CHECK err = MPI_File_set_view(fp, 0, MPI_BYTE, MPI_BYTE, "native", MPI_INFO_NULL); errInfo(err, "MPI_File_set_view1"); - assert(err == MPI_SUCCESS); + GRID_ASSERT(err == MPI_SUCCESS); freeTypes(); std::cout << GridLogMessage << "read sum: " << n_os * os_size << " bytes" << std::endl; @@ -182,7 +182,7 @@ public: std::string file) { typedef Lattice> DoubledGaugeField; - assert(Ns == 4 and Nd == 4 and Nc == 3); + GRID_ASSERT(Ns == 4 and Nd == 4 and Nc == 3); auto grid = Umu.Grid(); @@ -225,7 +225,7 @@ public: if(plaq_diff >= tol) std::cout << " Plaquette mismatch (diff = " << plaq_diff << ", tol = " << tol << ")" << std::endl; - assert(plaq_diff < tol); + GRID_ASSERT(plaq_diff < tol); std::cout << GridLogMessage << "OpenQcd Configuration " << file << " and plaquette agree" << std::endl; } @@ -246,7 +246,7 @@ private: static inline void copyToLatticeObject(std::vector& u_fb, std::vector const& node_buff, GridBase* grid) { - assert(node_buff.size() == Nd * grid->lSites()); + GRID_ASSERT(node_buff.size() == Nd * grid->lSites()); Coordinate const& l = grid->LocalDimensions(); @@ -274,7 +274,7 @@ private: buff_idx += 2 * Nd; } - assert(node_buff.size() == buff_idx); + GRID_ASSERT(node_buff.size() == buff_idx); } }; diff --git a/Grid/perfmon/PerfCount.h b/Grid/perfmon/PerfCount.h index 62b2a740..57bcc538 100644 --- a/Grid/perfmon/PerfCount.h +++ b/Grid/perfmon/PerfCount.h @@ -146,8 +146,8 @@ public: PerformanceCounter(int _pct) { #ifdef __linux__ - assert(_pct>=0); - assert(_pct=0); + GRID_ASSERT(_pct(GridClock::now()-start); #endif @@ -111,11 +111,11 @@ public: accumulator = std::chrono::duration_cast(start-start); } GridTime Elapsed(void) const { - assert(running == false); + GRID_ASSERT(running == false); return std::chrono::duration_cast( accumulator ); } uint64_t useconds(void) const { - assert(running == false); + GRID_ASSERT(running == false); return (uint64_t) accumulator.count(); } bool isRunning(void) const { diff --git a/Grid/qcd/action/ActionBase.h b/Grid/qcd/action/ActionBase.h index c3a46729..96afea0a 100644 --- a/Grid/qcd/action/ActionBase.h +++ b/Grid/qcd/action/ActionBase.h @@ -136,9 +136,9 @@ class EmptyAction : public Action using Action::Sinitial; using Action::deriv; - virtual void refresh(const GaugeField& U, GridSerialRNG &sRNG, GridParallelRNG& pRNG) { assert(0);}; // refresh pseudofermions + virtual void refresh(const GaugeField& U, GridSerialRNG &sRNG, GridParallelRNG& pRNG) { GRID_ASSERT(0);}; // refresh pseudofermions virtual RealD S(const GaugeField& U) { return 0.0;}; // evaluate the action - virtual void deriv(const GaugeField& U, GaugeField& dSdU) { assert(0); }; // evaluate the action derivative + virtual void deriv(const GaugeField& U, GaugeField& dSdU) { GRID_ASSERT(0); }; // evaluate the action derivative /////////////////////////////// // Logging diff --git a/Grid/qcd/action/ActionSet.h b/Grid/qcd/action/ActionSet.h index e6879fe5..871893af 100644 --- a/Grid/qcd/action/ActionSet.h +++ b/Grid/qcd/action/ActionSet.h @@ -77,7 +77,7 @@ public: actions(std::get<0>(actions_hirep)), multiplier(mul) { // initialize the hirep vectors to zero. // apply(this->resize, actions_hirep, 0); //need a working resize - assert(mul >= 1); + GRID_ASSERT(mul >= 1); } template < class GenField > diff --git a/Grid/qcd/action/fermion/CayleyFermion5D.h b/Grid/qcd/action/fermion/CayleyFermion5D.h index ec80b692..77491def 100644 --- a/Grid/qcd/action/fermion/CayleyFermion5D.h +++ b/Grid/qcd/action/fermion/CayleyFermion5D.h @@ -126,7 +126,7 @@ public: // possible boost std::vector qmu; - void set_qmu(std::vector _qmu) { qmu=_qmu; assert(qmu.size()==Nd);}; + void set_qmu(std::vector _qmu) { qmu=_qmu; GRID_ASSERT(qmu.size()==Nd);}; void addQmu(const FermionField &in, FermionField &out, int dag); // Cayley form Moebius (tanh and zolotarev) diff --git a/Grid/qcd/action/fermion/CloverHelpers.h b/Grid/qcd/action/fermion/CloverHelpers.h index d94f31d4..cee2bc2f 100644 --- a/Grid/qcd/action/fermion/CloverHelpers.h +++ b/Grid/qcd/action/fermion/CloverHelpers.h @@ -181,7 +181,7 @@ public: } static GaugeLinkField Cmunu(std::vector &U, GaugeLinkField &lambda, int mu, int nu) { - assert(0); + GRID_ASSERT(0); return lambda; } @@ -324,7 +324,7 @@ public: } static GaugeLinkField Cmunu(std::vector &U, GaugeLinkField &lambda, int mu, int nu) { - assert(0); + GRID_ASSERT(0); return lambda; } diff --git a/Grid/qcd/action/fermion/CompactWilsonCloverFermion.h b/Grid/qcd/action/fermion/CompactWilsonCloverFermion.h index d79b34d4..18287d8a 100644 --- a/Grid/qcd/action/fermion/CompactWilsonCloverFermion.h +++ b/Grid/qcd/action/fermion/CompactWilsonCloverFermion.h @@ -210,8 +210,8 @@ private: template void ApplyBoundaryMask(Field& f) { - const MaskField* m = getCorrectMaskField(f); assert(m != nullptr); - assert(m != nullptr); + const MaskField* m = getCorrectMaskField(f); GRID_ASSERT(m != nullptr); + GRID_ASSERT(m != nullptr); CompactHelpers::ApplyBoundaryMask(f, *m); } diff --git a/Grid/qcd/action/fermion/CompactWilsonCloverFermion5D.h b/Grid/qcd/action/fermion/CompactWilsonCloverFermion5D.h index 2c6aa587..467a5d48 100644 --- a/Grid/qcd/action/fermion/CompactWilsonCloverFermion5D.h +++ b/Grid/qcd/action/fermion/CompactWilsonCloverFermion5D.h @@ -164,8 +164,8 @@ private: template void ApplyBoundaryMask(Field& f) { - const MaskField* m = getCorrectMaskField(f); assert(m != nullptr); - assert(m != nullptr); + const MaskField* m = getCorrectMaskField(f); GRID_ASSERT(m != nullptr); + GRID_ASSERT(m != nullptr); CompactHelpers::ApplyBoundaryMask(f, *m); } diff --git a/Grid/qcd/action/fermion/ContinuedFractionFermion5D.h b/Grid/qcd/action/fermion/ContinuedFractionFermion5D.h index 3fb84cd5..6a658672 100644 --- a/Grid/qcd/action/fermion/ContinuedFractionFermion5D.h +++ b/Grid/qcd/action/fermion/ContinuedFractionFermion5D.h @@ -74,8 +74,8 @@ public: FermionField in_buf(in.Grid()); in_buf = Zero(); typedef typename Simd::scalar_type Scalar; Scalar ci(0.0,1.0); - assert(twist.size() == Nd);//check that twist is Nd - assert(boundary.size() == Nd);//check that boundary conditions is Nd + GRID_ASSERT(twist.size() == Nd);//check that twist is Nd + GRID_ASSERT(boundary.size() == Nd);//check that boundary conditions is Nd int shift = 0; for(unsigned int nu = 0; nu < Nd; nu++) { diff --git a/Grid/qcd/action/fermion/DWFSlow.h b/Grid/qcd/action/fermion/DWFSlow.h index 61298504..0ffc3ec6 100644 --- a/Grid/qcd/action/fermion/DWFSlow.h +++ b/Grid/qcd/action/fermion/DWFSlow.h @@ -110,9 +110,9 @@ public: // Derivative interface //////////////////////// // Interface calls an internal routine - void DhopDeriv(GaugeField &mat,const FermionField &U,const FermionField &V,int dag) { assert(0);}; - void DhopDerivOE(GaugeField &mat,const FermionField &U,const FermionField &V,int dag){ assert(0);}; - void DhopDerivEO(GaugeField &mat,const FermionField &U,const FermionField &V,int dag){ assert(0);}; + void DhopDeriv(GaugeField &mat,const FermionField &U,const FermionField &V,int dag) { GRID_ASSERT(0);}; + void DhopDerivOE(GaugeField &mat,const FermionField &U,const FermionField &V,int dag){ GRID_ASSERT(0);}; + void DhopDerivEO(GaugeField &mat,const FermionField &U,const FermionField &V,int dag){ GRID_ASSERT(0);}; /////////////////////////////////////////////////////////////// // non-hermitian hopping term; half cb or both @@ -128,7 +128,7 @@ public: void DhopOE(const FermionField &in, FermionField &out, int dag) { FermionField tmp(in.Grid()); - assert(in.Checkerboard()==Even); + GRID_ASSERT(in.Checkerboard()==Even); Dhop5(in,out,MassFieldOdd,MassFieldEven,dag); for(int mu=0;mu<4;mu++){ DhopDirU(in,UmuOdd[mu],UmuEven[mu],tmp,mu,dag ); out = out + tmp; @@ -137,7 +137,7 @@ public: void DhopEO(const FermionField &in, FermionField &out, int dag) { FermionField tmp(in.Grid()); - assert(in.Checkerboard()==Odd); + GRID_ASSERT(in.Checkerboard()==Odd); Dhop5(in,out, MassFieldEven,MassFieldOdd ,dag ); for(int mu=0;mu<4;mu++){ DhopDirU(in,UmuEven[mu],UmuOdd[mu],tmp,mu,dag ); out = out + tmp; @@ -147,11 +147,11 @@ public: /////////////////////////////////////////////////////////////// // Multigrid assistance; force term uses too /////////////////////////////////////////////////////////////// - void Mdir(const FermionField &in, FermionField &out, int dir, int disp){ assert(0);}; - void MdirAll(const FermionField &in, std::vector &out) { assert(0);}; - void DhopDir(const FermionField &in, FermionField &out, int dir, int disp) { assert(0);}; - void DhopDirAll(const FermionField &in, std::vector &out) { assert(0);}; - void DhopDirCalc(const FermionField &in, FermionField &out, int dirdisp,int gamma, int dag) { assert(0);}; + void Mdir(const FermionField &in, FermionField &out, int dir, int disp){ GRID_ASSERT(0);}; + void MdirAll(const FermionField &in, std::vector &out) { GRID_ASSERT(0);}; + void DhopDir(const FermionField &in, FermionField &out, int dir, int disp) { GRID_ASSERT(0);}; + void DhopDirAll(const FermionField &in, std::vector &out) { GRID_ASSERT(0);}; + void DhopDirCalc(const FermionField &in, FermionField &out, int dirdisp,int gamma, int dag) { GRID_ASSERT(0);}; void DhopDirU(const FermionField &in, const GaugeLinkField &U5e, const GaugeLinkField &U5o, FermionField &out, int mu, int dag) { diff --git a/Grid/qcd/action/fermion/DomainWallFermion.h b/Grid/qcd/action/fermion/DomainWallFermion.h index 5639debe..540ba3a6 100644 --- a/Grid/qcd/action/fermion/DomainWallFermion.h +++ b/Grid/qcd/action/fermion/DomainWallFermion.h @@ -123,7 +123,7 @@ public: RealD eps = 1.0; Approx::zolotarev_data *zdata = Approx::higham(eps,this->Ls);// eps is ignored for higham - assert(zdata->n==this->Ls); + GRID_ASSERT(zdata->n==this->Ls); // std::cout<Ls);// eps is ignored for higham - assert(zdata->n==this->Ls); + GRID_ASSERT(zdata->n==this->Ls); // Call base setter this->SetCoefficientsTanh(zdata,b,c); diff --git a/Grid/qcd/action/fermion/MobiusZolotarevFermion.h b/Grid/qcd/action/fermion/MobiusZolotarevFermion.h index 48496773..53807fce 100644 --- a/Grid/qcd/action/fermion/MobiusZolotarevFermion.h +++ b/Grid/qcd/action/fermion/MobiusZolotarevFermion.h @@ -61,7 +61,7 @@ public: RealD eps = lo/hi; Approx::zolotarev_data *zdata = Approx::zolotarev(eps,this->Ls,0); - assert(zdata->n==this->Ls); + GRID_ASSERT(zdata->n==this->Ls); std::cout<Ls&0x1)==1); // Odd Ls required + GRID_ASSERT((this->Ls&0x1)==1); // Odd Ls required int nrational=this->Ls-1;// Even rational order Approx::zolotarev_data *zdata = Approx::higham(1.0,nrational);// eps is ignored for higham this->SetCoefficientsTanh(zdata,scale); diff --git a/Grid/qcd/action/fermion/OverlapWilsonContfracZolotarevFermion.h b/Grid/qcd/action/fermion/OverlapWilsonContfracZolotarevFermion.h index 747cb508..7e723d99 100644 --- a/Grid/qcd/action/fermion/OverlapWilsonContfracZolotarevFermion.h +++ b/Grid/qcd/action/fermion/OverlapWilsonContfracZolotarevFermion.h @@ -59,7 +59,7 @@ public: FourDimGrid, FourDimRedBlackGrid,_mass,_M5,p) { - assert((this->Ls&0x1)==1); // Odd Ls required + GRID_ASSERT((this->Ls&0x1)==1); // Odd Ls required int nrational=this->Ls;// Odd rational order RealD eps = lo/hi; diff --git a/Grid/qcd/action/fermion/OverlapWilsonPartialFractionTanhFermion.h b/Grid/qcd/action/fermion/OverlapWilsonPartialFractionTanhFermion.h index 7210d6af..f3e3d934 100644 --- a/Grid/qcd/action/fermion/OverlapWilsonPartialFractionTanhFermion.h +++ b/Grid/qcd/action/fermion/OverlapWilsonPartialFractionTanhFermion.h @@ -60,7 +60,7 @@ public: FourDimGrid, FourDimRedBlackGrid,_mass,_M5,p) { - assert((this->Ls&0x1)==1); // Odd Ls required + GRID_ASSERT((this->Ls&0x1)==1); // Odd Ls required int nrational=this->Ls-1;// Even rational order Approx::zolotarev_data *zdata = Approx::higham(1.0,nrational);// eps is ignored for higham this->SetCoefficientsTanh(zdata,scale); diff --git a/Grid/qcd/action/fermion/OverlapWilsonPartialFractionZolotarevFermion.h b/Grid/qcd/action/fermion/OverlapWilsonPartialFractionZolotarevFermion.h index f0be4388..2558bb84 100644 --- a/Grid/qcd/action/fermion/OverlapWilsonPartialFractionZolotarevFermion.h +++ b/Grid/qcd/action/fermion/OverlapWilsonPartialFractionZolotarevFermion.h @@ -61,7 +61,7 @@ public: FourDimGrid, FourDimRedBlackGrid,_mass,_M5,p) { - assert((this->Ls&0x1)==1); // Odd Ls required + GRID_ASSERT((this->Ls&0x1)==1); // Odd Ls required int nrational=this->Ls;// Odd rational order RealD eps = lo/hi; diff --git a/Grid/qcd/action/fermion/PartialFractionFermion5D.h b/Grid/qcd/action/fermion/PartialFractionFermion5D.h index a71fc3f3..f2656a45 100644 --- a/Grid/qcd/action/fermion/PartialFractionFermion5D.h +++ b/Grid/qcd/action/fermion/PartialFractionFermion5D.h @@ -104,8 +104,8 @@ public: FermionField in_buf(in.Grid()); in_buf = Zero(); typedef typename Simd::scalar_type Scalar; Scalar ci(0.0,1.0); - assert(twist.size() == Nd);//check that twist is Nd - assert(boundary.size() == Nd);//check that boundary conditions is Nd + GRID_ASSERT(twist.size() == Nd);//check that twist is Nd + GRID_ASSERT(boundary.size() == Nd);//check that boundary conditions is Nd int shift = 0; for(unsigned int nu = 0; nu < Nd; nu++) { @@ -137,7 +137,7 @@ public: FreePropagator(in,out,mass,boundary,twist); }; - void set_qmu(std::vector _qmu) { qmu=_qmu; assert(qmu.size()==Nd);}; + void set_qmu(std::vector _qmu) { qmu=_qmu; GRID_ASSERT(qmu.size()==Nd);}; void addQmu(const FermionField &in, FermionField &out, int dag); protected: diff --git a/Grid/qcd/action/fermion/SchurDiagTwoKappa.h b/Grid/qcd/action/fermion/SchurDiagTwoKappa.h index 00ac222f..3fe2be27 100644 --- a/Grid/qcd/action/fermion/SchurDiagTwoKappa.h +++ b/Grid/qcd/action/fermion/SchurDiagTwoKappa.h @@ -51,7 +51,7 @@ public: void sscale(const Lattice& in, Lattice& out, Coeff_t* s) { GridBase *grid=out.Grid(); out.Checkerboard() = in.Checkerboard(); - assert(grid->_simd_layout[0] == 1); // should be fine for ZMobius for now + GRID_ASSERT(grid->_simd_layout[0] == 1); // should be fine for ZMobius for now int Ls = grid->_rdimensions[0]; thread_for(ss, grid->oSites(), { diff --git a/Grid/qcd/action/fermion/StaggeredImpl.h b/Grid/qcd/action/fermion/StaggeredImpl.h index f44d12f4..fee7613f 100644 --- a/Grid/qcd/action/fermion/StaggeredImpl.h +++ b/Grid/qcd/action/fermion/StaggeredImpl.h @@ -168,7 +168,7 @@ public: } inline void InsertForce5D(GaugeField &mat, FermionField &Btilde, FermionField Ã,int mu){ - assert (0); + GRID_ASSERT (0); // Must never hit } }; diff --git a/Grid/qcd/action/fermion/StaggeredVec5dImpl.h b/Grid/qcd/action/fermion/StaggeredVec5dImpl.h index 18fe993c..b2e215e3 100644 --- a/Grid/qcd/action/fermion/StaggeredVec5dImpl.h +++ b/Grid/qcd/action/fermion/StaggeredVec5dImpl.h @@ -113,7 +113,7 @@ public: inline void InsertGaugeField(DoubledGaugeField &U_ds,const GaugeLinkField &U,int mu) { - assert(0); + GRID_ASSERT(0); } inline void DoubleStore(GridBase *GaugeGrid, DoubledGaugeField &UUUds, // for Naik term @@ -176,11 +176,11 @@ public: } inline void InsertForce4D(GaugeField &mat, FermionField &Btilde, FermionField &A,int mu){ - assert(0); + GRID_ASSERT(0); } inline void InsertForce5D(GaugeField &mat, FermionField &Btilde, FermionField Ã,int mu){ - assert (0); + GRID_ASSERT (0); } }; typedef StaggeredVec5dImpl StaggeredVec5dImplR; // Real.. whichever prec diff --git a/Grid/qcd/action/fermion/WilsonCloverHelpers.h b/Grid/qcd/action/fermion/WilsonCloverHelpers.h index c221d5f0..eaae31e9 100644 --- a/Grid/qcd/action/fermion/WilsonCloverHelpers.h +++ b/Grid/qcd/action/fermion/WilsonCloverHelpers.h @@ -222,7 +222,7 @@ public: #if 0 static accelerator_inline typename SiteCloverTriangle::vector_type triangle_elem(const SiteCloverTriangle& triangle, int block, int i, int j) { - assert(i != j); + GRID_ASSERT(i != j); if(i < j) { return triangle()(block)(triangle_index(i, j)); } else { // i > j @@ -232,7 +232,7 @@ public: #else template static accelerator_inline vobj triangle_elem(const iImplCloverTriangle& triangle, int block, int i, int j) { - assert(i != j); + GRID_ASSERT(i != j); if(i < j) { return triangle()(block)(triangle_index(i, j)); } else { // i > j @@ -740,9 +740,9 @@ public: template static void SetupMasks(MaskField& full, MaskField& even, MaskField& odd) { - assert(even.Grid()->_isCheckerBoarded && even.Checkerboard() == Even); - assert(odd.Grid()->_isCheckerBoarded && odd.Checkerboard() == Odd); - assert(!full.Grid()->_isCheckerBoarded); + GRID_ASSERT(even.Grid()->_isCheckerBoarded && even.Checkerboard() == Even); + GRID_ASSERT(odd.Grid()->_isCheckerBoarded && odd.Checkerboard() == Odd); + GRID_ASSERT(!full.Grid()->_isCheckerBoarded); GridBase* grid = full.Grid(); int t_dir = Nd-1; diff --git a/Grid/qcd/action/fermion/WilsonCompressor.h b/Grid/qcd/action/fermion/WilsonCompressor.h index 458f2c83..c3a5e4cf 100644 --- a/Grid/qcd/action/fermion/WilsonCompressor.h +++ b/Grid/qcd/action/fermion/WilsonCompressor.h @@ -241,7 +241,7 @@ public: this->_grid->StencilBarrier(); - assert(source.Grid()==this->_grid); + GRID_ASSERT(source.Grid()==this->_grid); this->u_comm_offset=0; @@ -278,7 +278,7 @@ public: vet_same_node(this->same_node[Tm],this->HaloGatherDir(source,TpCompress,Tm,face_idx)); } this->face_table_computed=1; - assert(this->u_comm_offset==this->_unified_buffer_size); + GRID_ASSERT(this->u_comm_offset==this->_unified_buffer_size); accelerator_barrier(); #ifdef NVLINK_GET this->_grid->StencilBarrier(); // He can now get mu local gather, I can get his diff --git a/Grid/qcd/action/fermion/WilsonImpl.h b/Grid/qcd/action/fermion/WilsonImpl.h index 07248160..3643e581 100644 --- a/Grid/qcd/action/fermion/WilsonImpl.h +++ b/Grid/qcd/action/fermion/WilsonImpl.h @@ -77,7 +77,7 @@ public: ImplParams Params; WilsonImpl(const ImplParams &p = ImplParams()) : Params(p){ - assert(Params.boundary_phases.size() == Nd); + GRID_ASSERT(Params.boundary_phases.size() == Nd); }; template diff --git a/Grid/qcd/action/fermion/WilsonTMFermion5D.h b/Grid/qcd/action/fermion/WilsonTMFermion5D.h index 982e722a..e1f07e23 100644 --- a/Grid/qcd/action/fermion/WilsonTMFermion5D.h +++ b/Grid/qcd/action/fermion/WilsonTMFermion5D.h @@ -136,8 +136,8 @@ class WilsonTMFermion5D : public WilsonFermion5D // needed for fast PV void update(const std::vector& _mass, const std::vector& _mu) { - assert(_mass.size() == _mu.size()); - assert(_mass.size() == this->FermionGrid()->_fdimensions[0]); + GRID_ASSERT(_mass.size() == _mu.size()); + GRID_ASSERT(_mass.size() == this->FermionGrid()->_fdimensions[0]); this->mass = _mass; this->mu = _mu; } diff --git a/Grid/qcd/action/fermion/deprecated/CayleyFermion5Ddense.h b/Grid/qcd/action/fermion/deprecated/CayleyFermion5Ddense.h index f1acb50c..308581c4 100644 --- a/Grid/qcd/action/fermion/deprecated/CayleyFermion5Ddense.h +++ b/Grid/qcd/action/fermion/deprecated/CayleyFermion5Ddense.h @@ -59,7 +59,7 @@ void CayleyFermion5D::MooeeInternal(const FermionField &psi, FermionField chi.Checkerboard()=psi.Checkerboard(); - assert(Ls==LLs); + GRID_ASSERT(Ls==LLs); Eigen::MatrixXd Pplus = Eigen::MatrixXd::Zero(Ls,Ls); Eigen::MatrixXd Pminus = Eigen::MatrixXd::Zero(Ls,Ls); diff --git a/Grid/qcd/action/fermion/deprecated/CayleyFermion5Dvec.h b/Grid/qcd/action/fermion/deprecated/CayleyFermion5Dvec.h index 478fbb8b..75c53eb2 100644 --- a/Grid/qcd/action/fermion/deprecated/CayleyFermion5Dvec.h +++ b/Grid/qcd/action/fermion/deprecated/CayleyFermion5Dvec.h @@ -78,8 +78,8 @@ CayleyFermion5D::M5D(const FermionField &psi_i, Vector > l(LLs); Vector > d(LLs); - assert(Ls/LLs==nsimd); - assert(phi.Checkerboard() == psi.Checkerboard()); + GRID_ASSERT(Ls/LLs==nsimd); + GRID_ASSERT(phi.Checkerboard() == psi.Checkerboard()); // just directly address via type pun typedef typename Simd::scalar_type scalar_type; @@ -96,7 +96,7 @@ CayleyFermion5D::M5D(const FermionField &psi_i, d_p[ss] = diag[s]; }} - assert(Nc==3); + GRID_ASSERT(Nc==3); thread_loop( (int ss=0;ssoSites();ss+=LLs),{ // adds LLs #if 0 @@ -221,8 +221,8 @@ CayleyFermion5D::M5Ddag(const FermionField &psi_i, Vector > l(LLs); Vector > d(LLs); - assert(Ls/LLs==nsimd); - assert(phi.Checkerboard() == psi.Checkerboard()); + GRID_ASSERT(Ls/LLs==nsimd); + GRID_ASSERT(phi.Checkerboard() == psi.Checkerboard()); // just directly address via type pun typedef typename Simd::scalar_type scalar_type; @@ -805,7 +805,7 @@ CayleyFermion5D::MooeeInternal(const FermionField &psi, FermionField &chi, _Matp = &Matp; _Matm = &Matm; } - assert(_Matp->size()==Ls*LLs); + GRID_ASSERT(_Matp->size()==Ls*LLs); if ( switcheroo::iscomplex() ) { thread_loop( (auto site=0;site::MooeeInternal(const FermionField& psi, Fermion chi.Checkerboard() = psi.Checkerboard(); - assert(Ls==LLs); + GRID_ASSERT(Ls==LLs); Eigen::MatrixXd Pplus = Eigen::MatrixXd::Zero(Ls,Ls); Eigen::MatrixXd Pminus = Eigen::MatrixXd::Zero(Ls,Ls); diff --git a/Grid/qcd/action/fermion/deprecated/Lebesgue.cc b/Grid/qcd/action/fermion/deprecated/Lebesgue.cc index 480483ed..f36590db 100644 --- a/Grid/qcd/action/fermion/deprecated/Lebesgue.cc +++ b/Grid/qcd/action/fermion/deprecated/Lebesgue.cc @@ -98,8 +98,8 @@ void LebesgueOrder::CartesianBlocking(void) IndexInteger ND = grid->_ndimension; - assert(ND==4); - assert(ND==Block.size()); + GRID_ASSERT(ND==4); + GRID_ASSERT(ND==Block.size()); Coordinate dims(ND); Coordinate xo(ND,0); @@ -164,7 +164,7 @@ void LebesgueOrder::ZGraph(void) for(IndexInteger mu=0;mu_rdimensions[mu]; - assert ( dims[mu] != 0 ); + GRID_ASSERT ( dims[mu] != 0 ); adims[mu] = alignup(dims[mu]); } @@ -221,11 +221,11 @@ void LebesgueOrder::ZGraph(void) +dims[0]*dims[1]*ax[2] +dims[0]*dims[1]*dims[2]*ax[3]; - assert(site < vol); + GRID_ASSERT(site < vol); _LebesgueReorder.push_back(site); } } - assert( _LebesgueReorder.size() == vol ); + GRID_ASSERT( _LebesgueReorder.size() == vol ); /* std::vector coor(4); diff --git a/Grid/qcd/action/fermion/deprecated/MobiusEOFAFermiondense.h b/Grid/qcd/action/fermion/deprecated/MobiusEOFAFermiondense.h index 8091f344..456cecc1 100644 --- a/Grid/qcd/action/fermion/deprecated/MobiusEOFAFermiondense.h +++ b/Grid/qcd/action/fermion/deprecated/MobiusEOFAFermiondense.h @@ -78,7 +78,7 @@ void MobiusEOFAFermion::MooeeInternal(const FermionField& psi, FermionFiel chi.Checkerboard() = psi.Checkerboard(); - assert(Ls==LLs); + GRID_ASSERT(Ls==LLs); Eigen::MatrixXd Pplus = Eigen::MatrixXd::Zero(Ls,Ls); Eigen::MatrixXd Pminus = Eigen::MatrixXd::Zero(Ls,Ls); diff --git a/Grid/qcd/action/fermion/implementation/CayleyFermion5DImplementation.h b/Grid/qcd/action/fermion/implementation/CayleyFermion5DImplementation.h index 2ace6c18..60f6c223 100644 --- a/Grid/qcd/action/fermion/implementation/CayleyFermion5DImplementation.h +++ b/Grid/qcd/action/fermion/implementation/CayleyFermion5DImplementation.h @@ -285,7 +285,7 @@ void CayleyFermion5D::addQmu(const FermionField &psi,FermionField &chi, in std::vector coeff(Nd); ComplexD ci(0,1); - assert(qmu.size()==Nd); + GRID_ASSERT(qmu.size()==Nd); for(int mu=0;mu::SetCoefficientsInternal(RealD zolo_hi,std::vector::SetCoefficientsInternal(RealD zolo_hi,std::vector::SetCoefficientsInternal(RealD zolo_hi,std::vectorM5) +1.0); - assert(bee[i]!=Coeff_t(0.0)); + GRID_ASSERT(bee[i]!=Coeff_t(0.0)); cee[i]=as[i]*(1.0-cs[i]*(4.0-this->M5)); beo[i]=as[i]*bs[i]; ceo[i]=-as[i]*cs[i]; @@ -531,8 +531,8 @@ void CayleyFermion5D::SetCoefficientsInternal(RealD zolo_hi,std::vector::SetCoefficientsInternal(RealD zolo_hi,std::vector::ContractConservedCurrent( PropagatorField &q_in_1, unsigned int mu) { - assert(mass_plus == mass_minus); + GRID_ASSERT(mass_plus == mass_minus); RealD mass = mass_plus; Gamma::Algebra Gmu [] = { @@ -773,10 +773,10 @@ void CayleyFermion5D::SeqConservedCurrent(PropagatorField &q_in, unsigned int tmax, ComplexField &ph)// Complex phase factor { - assert(mu>=0); - assert(mu=0); + GRID_ASSERT(mu::SeqConservedCurrent(PropagatorField &q_in, } else { std::cerr << "Error: Tadpole implementation currently unavailable for non-Shamir actions." << std::endl; - assert(b==1 && c==0); + GRID_ASSERT(b==1 && c==0); } } diff --git a/Grid/qcd/action/fermion/implementation/CayleyFermion5Dcache.h b/Grid/qcd/action/fermion/implementation/CayleyFermion5Dcache.h index 5fbc7612..4bc703a3 100644 --- a/Grid/qcd/action/fermion/implementation/CayleyFermion5Dcache.h +++ b/Grid/qcd/action/fermion/implementation/CayleyFermion5Dcache.h @@ -53,7 +53,7 @@ CayleyFermion5D::M5D(const FermionField &psi_i, autoView(psi , psi_i,AcceleratorRead); autoView(phi , phi_i,AcceleratorRead); autoView(chi , chi_i,AcceleratorWrite); - assert(phi.Checkerboard() == psi.Checkerboard()); + GRID_ASSERT(phi.Checkerboard() == psi.Checkerboard()); int Ls =this->Ls; @@ -95,7 +95,7 @@ CayleyFermion5D::M5Ddag(const FermionField &psi_i, autoView(psi , psi_i,AcceleratorRead); autoView(phi , phi_i,AcceleratorRead); autoView(chi , chi_i,AcceleratorWrite); - assert(phi.Checkerboard() == psi.Checkerboard()); + GRID_ASSERT(phi.Checkerboard() == psi.Checkerboard()); int Ls=this->Ls; @@ -208,7 +208,7 @@ CayleyFermion5D::MooeeInvDag (const FermionField &psi_i, FermionField &chi auto pleem = & d_leem[0]; auto pueem = & d_ueem[0]; - assert(psi.Checkerboard() == psi.Checkerboard()); + GRID_ASSERT(psi.Checkerboard() == psi.Checkerboard()); uint64_t nloop = grid->oSites()/Ls; accelerator_for(sss,nloop,Simd::Nsimd(),{ diff --git a/Grid/qcd/action/fermion/implementation/CompactWilsonCloverFermion5DImplementation.h b/Grid/qcd/action/fermion/implementation/CompactWilsonCloverFermion5DImplementation.h index e65fb6d6..751efee2 100644 --- a/Grid/qcd/action/fermion/implementation/CompactWilsonCloverFermion5DImplementation.h +++ b/Grid/qcd/action/fermion/implementation/CompactWilsonCloverFermion5DImplementation.h @@ -61,7 +61,7 @@ CompactWilsonCloverFermion5D::CompactWilsonCloverFermion5D( , BoundaryMask(&FiveDimGrid) , BoundaryMaskEven(&FiveDimRedBlackGrid), BoundaryMaskOdd(&FiveDimRedBlackGrid) { - assert(Nd == 4 && Nc == 3 && Ns == 4 && Impl::Dimension == 3); + GRID_ASSERT(Nd == 4 && Nc == 3 && Ns == 4 && Impl::Dimension == 3); csw_r *= 0.5; csw_t *= 0.5; @@ -188,7 +188,7 @@ void CompactWilsonCloverFermion5D::MdirAll(const FermionFie template void CompactWilsonCloverFermion5D::MDeriv(GaugeField& force, const FermionField& X, const FermionField& Y, int dag) { - assert(!fixedBoundaries); // TODO check for changes required for open bc + GRID_ASSERT(!fixedBoundaries); // TODO check for changes required for open bc // NOTE: code copied from original clover term conformable(X.Grid(), Y.Grid()); @@ -271,12 +271,12 @@ void CompactWilsonCloverFermion5D::MDeriv(GaugeField& force template void CompactWilsonCloverFermion5D::MooDeriv(GaugeField& mat, const FermionField& U, const FermionField& V, int dag) { - assert(0); + GRID_ASSERT(0); } template void CompactWilsonCloverFermion5D::MeeDeriv(GaugeField& mat, const FermionField& U, const FermionField& V, int dag) { - assert(0); + GRID_ASSERT(0); } template @@ -284,7 +284,7 @@ void CompactWilsonCloverFermion5D::MooeeInternal(const Ferm FermionField& out, const CloverDiagonalField& diagonal, const CloverTriangleField& triangle) { - assert(in.Checkerboard() == Odd || in.Checkerboard() == Even); + GRID_ASSERT(in.Checkerboard() == Odd || in.Checkerboard() == Even); out.Checkerboard() = in.Checkerboard(); conformable(in, out); CompactHelpers::MooeeKernel(diagonal.oSites(), this->Ls, in, out, diagonal, triangle); diff --git a/Grid/qcd/action/fermion/implementation/CompactWilsonCloverFermionImplementation.h b/Grid/qcd/action/fermion/implementation/CompactWilsonCloverFermionImplementation.h index 7e3b7f00..a4f32850 100644 --- a/Grid/qcd/action/fermion/implementation/CompactWilsonCloverFermionImplementation.h +++ b/Grid/qcd/action/fermion/implementation/CompactWilsonCloverFermionImplementation.h @@ -59,7 +59,7 @@ CompactWilsonCloverFermion::CompactWilsonCloverFermion(Gaug , BoundaryMask(&Fgrid) , BoundaryMaskEven(&Hgrid), BoundaryMaskOdd(&Hgrid) { - assert(Nd == 4 && Nc == 3 && Ns == 4 && Impl::Dimension == 3); + GRID_ASSERT(Nd == 4 && Nc == 3 && Ns == 4 && Impl::Dimension == 3); csw_r *= 0.5; csw_t *= 0.5; @@ -186,7 +186,7 @@ void CompactWilsonCloverFermion::MdirAll(const FermionField template void CompactWilsonCloverFermion::MDeriv(GaugeField& force, const FermionField& X, const FermionField& Y, int dag) { - assert(!fixedBoundaries); // TODO check for changes required for open bc + GRID_ASSERT(!fixedBoundaries); // TODO check for changes required for open bc // NOTE: code copied from original clover term conformable(X.Grid(), Y.Grid()); @@ -269,12 +269,12 @@ void CompactWilsonCloverFermion::MDeriv(GaugeField& force, template void CompactWilsonCloverFermion::MooDeriv(GaugeField& mat, const FermionField& U, const FermionField& V, int dag) { - assert(0); + GRID_ASSERT(0); } template void CompactWilsonCloverFermion::MeeDeriv(GaugeField& mat, const FermionField& U, const FermionField& V, int dag) { - assert(0); + GRID_ASSERT(0); } template @@ -282,7 +282,7 @@ void CompactWilsonCloverFermion::MooeeInternal(const Fermio FermionField& out, const CloverDiagonalField& diagonal, const CloverTriangleField& triangle) { - assert(in.Checkerboard() == Odd || in.Checkerboard() == Even); + GRID_ASSERT(in.Checkerboard() == Odd || in.Checkerboard() == Even); out.Checkerboard() = in.Checkerboard(); conformable(in, out); conformable(in, diagonal); diff --git a/Grid/qcd/action/fermion/implementation/ContinuedFractionFermion5DImplementation.h b/Grid/qcd/action/fermion/implementation/ContinuedFractionFermion5DImplementation.h index 4bfbd31e..f0f8bb63 100644 --- a/Grid/qcd/action/fermion/implementation/ContinuedFractionFermion5DImplementation.h +++ b/Grid/qcd/action/fermion/implementation/ContinuedFractionFermion5DImplementation.h @@ -49,7 +49,7 @@ void ContinuedFractionFermion5D::SetCoefficientsZolotarev(RealD zolo_hi,Ap std::cout<dd << " -dd"<Ls; std::cout<db==Ls);// Beta has Ls coeffs + GRID_ASSERT(zdata->db==Ls);// Beta has Ls coeffs R=(1+this->mass)/(1-this->mass); @@ -311,7 +311,7 @@ ContinuedFractionFermion5D::ContinuedFractionFermion5D( mass(_mass) { int Ls = this->Ls; - assert((Ls&0x1)==1); // Odd Ls required + GRID_ASSERT((Ls&0x1)==1); // Odd Ls required } template diff --git a/Grid/qcd/action/fermion/implementation/DomainWallEOFAFermionCache.h b/Grid/qcd/action/fermion/implementation/DomainWallEOFAFermionCache.h index ae126bb5..589c6fdd 100644 --- a/Grid/qcd/action/fermion/implementation/DomainWallEOFAFermionCache.h +++ b/Grid/qcd/action/fermion/implementation/DomainWallEOFAFermionCache.h @@ -49,7 +49,7 @@ void DomainWallEOFAFermion::M5D(const FermionField& psi_i, const FermionFi autoView( phi , phi_i, AcceleratorRead); autoView( psi , psi_i, AcceleratorRead); autoView( chi , chi_i, AcceleratorWrite); - assert(phi.Checkerboard() == psi.Checkerboard()); + GRID_ASSERT(phi.Checkerboard() == psi.Checkerboard()); auto pdiag = &this->d_diag[0]; auto pupper = &this->d_upper[0]; @@ -88,7 +88,7 @@ void DomainWallEOFAFermion::M5Ddag(const FermionField& psi_i, const Fermio autoView( psi , psi_i, AcceleratorRead); autoView( phi , phi_i, AcceleratorRead); autoView( chi , chi_i, AcceleratorWrite); - assert(phi.Checkerboard() == psi.Checkerboard()); + GRID_ASSERT(phi.Checkerboard() == psi.Checkerboard()); auto pdiag = &this->d_diag[0]; auto pupper = &this->d_upper[0]; @@ -190,7 +190,7 @@ void DomainWallEOFAFermion::MooeeInvDag(const FermionField& psi_i, Fermion auto pleem = & this->leem[0]; auto pueem = & this->ueem[0]; - assert(psi.Checkerboard() == psi.Checkerboard()); + GRID_ASSERT(psi.Checkerboard() == psi.Checkerboard()); auto nloop = grid->oSites()/Ls; accelerator_for(sss,nloop,Simd::Nsimd(),{ diff --git a/Grid/qcd/action/fermion/implementation/DomainWallEOFAFermionImplementation.h b/Grid/qcd/action/fermion/implementation/DomainWallEOFAFermionImplementation.h index 53b44ca2..8bb98d8b 100644 --- a/Grid/qcd/action/fermion/implementation/DomainWallEOFAFermionImplementation.h +++ b/Grid/qcd/action/fermion/implementation/DomainWallEOFAFermionImplementation.h @@ -53,7 +53,7 @@ DomainWallEOFAFermion::DomainWallEOFAFermion( { RealD eps = 1.0; Approx::zolotarev_data *zdata = Approx::higham(eps,this->Ls); - assert(zdata->n == this->Ls); + GRID_ASSERT(zdata->n == this->Ls); std::cout << GridLogMessage << "DomainWallEOFAFermion with Ls=" << this->Ls << std::endl; this->SetCoefficientsTanh(zdata, 1.0, 0.0); diff --git a/Grid/qcd/action/fermion/implementation/ImprovedStaggeredFermion5DImplementation.h b/Grid/qcd/action/fermion/implementation/ImprovedStaggeredFermion5DImplementation.h index d2b4450e..fe05b627 100644 --- a/Grid/qcd/action/fermion/implementation/ImprovedStaggeredFermion5DImplementation.h +++ b/Grid/qcd/action/fermion/implementation/ImprovedStaggeredFermion5DImplementation.h @@ -64,32 +64,32 @@ ImprovedStaggeredFermion5D::ImprovedStaggeredFermion5D(GridCartesian _tmp(&FiveDimRedBlackGrid) { - // some assertions - assert(FiveDimGrid._ndimension==5); - assert(FourDimGrid._ndimension==4); - assert(FourDimRedBlackGrid._ndimension==4); - assert(FiveDimRedBlackGrid._ndimension==5); - assert(FiveDimRedBlackGrid._checker_dim==1); // Don't checker the s direction + // some GRID_ASSERTions + GRID_ASSERT(FiveDimGrid._ndimension==5); + GRID_ASSERT(FourDimGrid._ndimension==4); + GRID_ASSERT(FourDimRedBlackGrid._ndimension==4); + GRID_ASSERT(FiveDimRedBlackGrid._ndimension==5); + GRID_ASSERT(FiveDimRedBlackGrid._checker_dim==1); // Don't checker the s direction // extent of fifth dim and not spread out Ls=FiveDimGrid._fdimensions[0]; - assert(FiveDimRedBlackGrid._fdimensions[0]==Ls); - assert(FiveDimGrid._processors[0] ==1); - assert(FiveDimRedBlackGrid._processors[0] ==1); + GRID_ASSERT(FiveDimRedBlackGrid._fdimensions[0]==Ls); + GRID_ASSERT(FiveDimGrid._processors[0] ==1); + GRID_ASSERT(FiveDimRedBlackGrid._processors[0] ==1); // Other dimensions must match the decomposition of the four-D fields for(int d=0;d<4;d++){ - assert(FiveDimGrid._processors[d+1] ==FourDimGrid._processors[d]); - assert(FiveDimRedBlackGrid._processors[d+1] ==FourDimGrid._processors[d]); - assert(FourDimRedBlackGrid._processors[d] ==FourDimGrid._processors[d]); + GRID_ASSERT(FiveDimGrid._processors[d+1] ==FourDimGrid._processors[d]); + GRID_ASSERT(FiveDimRedBlackGrid._processors[d+1] ==FourDimGrid._processors[d]); + GRID_ASSERT(FourDimRedBlackGrid._processors[d] ==FourDimGrid._processors[d]); - assert(FiveDimGrid._fdimensions[d+1] ==FourDimGrid._fdimensions[d]); - assert(FiveDimRedBlackGrid._fdimensions[d+1]==FourDimGrid._fdimensions[d]); - assert(FourDimRedBlackGrid._fdimensions[d] ==FourDimGrid._fdimensions[d]); + GRID_ASSERT(FiveDimGrid._fdimensions[d+1] ==FourDimGrid._fdimensions[d]); + GRID_ASSERT(FiveDimRedBlackGrid._fdimensions[d+1]==FourDimGrid._fdimensions[d]); + GRID_ASSERT(FourDimRedBlackGrid._fdimensions[d] ==FourDimGrid._fdimensions[d]); - assert(FiveDimGrid._simd_layout[d+1] ==FourDimGrid._simd_layout[d]); - assert(FiveDimRedBlackGrid._simd_layout[d+1]==FourDimGrid._simd_layout[d]); - assert(FourDimRedBlackGrid._simd_layout[d] ==FourDimGrid._simd_layout[d]); + GRID_ASSERT(FiveDimGrid._simd_layout[d+1] ==FourDimGrid._simd_layout[d]); + GRID_ASSERT(FiveDimRedBlackGrid._simd_layout[d+1]==FourDimGrid._simd_layout[d]); + GRID_ASSERT(FourDimRedBlackGrid._simd_layout[d] ==FourDimGrid._simd_layout[d]); } if (Impl::LsVectorised) { @@ -97,20 +97,20 @@ ImprovedStaggeredFermion5D::ImprovedStaggeredFermion5D(GridCartesian int nsimd = Simd::Nsimd(); // Dimension zero of the five-d is the Ls direction - assert(FiveDimGrid._simd_layout[0] ==nsimd); - assert(FiveDimRedBlackGrid._simd_layout[0]==nsimd); + GRID_ASSERT(FiveDimGrid._simd_layout[0] ==nsimd); + GRID_ASSERT(FiveDimRedBlackGrid._simd_layout[0]==nsimd); for(int d=0;d<4;d++){ - assert(FourDimGrid._simd_layout[d]==1); - assert(FourDimRedBlackGrid._simd_layout[d]==1); - assert(FiveDimRedBlackGrid._simd_layout[d+1]==1); + GRID_ASSERT(FourDimGrid._simd_layout[d]==1); + GRID_ASSERT(FourDimRedBlackGrid._simd_layout[d]==1); + GRID_ASSERT(FiveDimRedBlackGrid._simd_layout[d+1]==1); } } else { // Dimension zero of the five-d is the Ls direction - assert(FiveDimRedBlackGrid._simd_layout[0]==1); - assert(FiveDimGrid._simd_layout[0] ==1); + GRID_ASSERT(FiveDimRedBlackGrid._simd_layout[0]==1); + GRID_ASSERT(FiveDimGrid._simd_layout[0] ==1); } int LLs = FiveDimGrid._rdimensions[0]; @@ -242,7 +242,7 @@ void ImprovedStaggeredFermion5D::DerivInternal(StencilImpl & st, int dag) { // No force terms in multi-rhs solver staggered - assert(0); + GRID_ASSERT(0); } template @@ -251,7 +251,7 @@ void ImprovedStaggeredFermion5D::DhopDeriv(GaugeField &mat, const FermionField &B, int dag) { - assert(0); + GRID_ASSERT(0); } template @@ -260,7 +260,7 @@ void ImprovedStaggeredFermion5D::DhopDerivEO(GaugeField &mat, const FermionField &B, int dag) { - assert(0); + GRID_ASSERT(0); } @@ -270,7 +270,7 @@ void ImprovedStaggeredFermion5D::DhopDerivOE(GaugeField &mat, const FermionField &B, int dag) { - assert(0); + GRID_ASSERT(0); } /*CHANGE */ @@ -290,7 +290,7 @@ void ImprovedStaggeredFermion5D::DhopInternalOverlappedComms(StencilImpl & DoubledGaugeField & U,DoubledGaugeField & UUU, const FermionField &in, FermionField &out,int dag) { - // assert((dag==DaggerNo) ||(dag==DaggerYes)); + // GRID_ASSERT((dag==DaggerNo) ||(dag==DaggerYes)); Compressor compressor; int LLs = in.Grid()->_rdimensions[0]; @@ -352,7 +352,7 @@ void ImprovedStaggeredFermion5D::DhopOE(const FermionField &in, FermionFie conformable(in.Grid(),FermionRedBlackGrid()); // verifies half grid conformable(in.Grid(),out.Grid()); // drops the cb check - assert(in.Checkerboard()==Even); + GRID_ASSERT(in.Checkerboard()==Even); out.Checkerboard() = Odd; DhopInternal(StencilEven,UmuOdd,UUUmuOdd,in,out,dag); @@ -363,7 +363,7 @@ void ImprovedStaggeredFermion5D::DhopEO(const FermionField &in, FermionFie conformable(in.Grid(),FermionRedBlackGrid()); // verifies half grid conformable(in.Grid(),out.Grid()); // drops the cb check - assert(in.Checkerboard()==Odd); + GRID_ASSERT(in.Checkerboard()==Odd); out.Checkerboard() = Even; DhopInternal(StencilOdd,UmuEven,UUUmuEven,in,out,dag); @@ -390,7 +390,7 @@ void ImprovedStaggeredFermion5D::Mdir(const FermionField &in, FermionField template void ImprovedStaggeredFermion5D::MdirAll(const FermionField &in, std::vector &out) { - assert(0); + GRID_ASSERT(0); } template void ImprovedStaggeredFermion5D::M(const FermionField &in, FermionField &out) @@ -467,7 +467,7 @@ void ImprovedStaggeredFermion5D::ContractConservedCurrent(PropagatorField Current curr_type, unsigned int mu) { - assert(0); + GRID_ASSERT(0); } template @@ -480,7 +480,7 @@ void ImprovedStaggeredFermion5D::SeqConservedCurrent(PropagatorField &q_in unsigned int tmax, ComplexField &lattice_cmplx) { - assert(0); + GRID_ASSERT(0); } diff --git a/Grid/qcd/action/fermion/implementation/ImprovedStaggeredFermionImplementation.h b/Grid/qcd/action/fermion/implementation/ImprovedStaggeredFermionImplementation.h index bd9dd132..a1eebf2f 100644 --- a/Grid/qcd/action/fermion/implementation/ImprovedStaggeredFermionImplementation.h +++ b/Grid/qcd/action/fermion/implementation/ImprovedStaggeredFermionImplementation.h @@ -241,7 +241,7 @@ void ImprovedStaggeredFermion::DerivInternal(StencilImpl &st, DoubledGauge GaugeField & mat, const FermionField &A, const FermionField &B, int dag) { - assert((dag == DaggerNo) || (dag == DaggerYes)); + GRID_ASSERT((dag == DaggerNo) || (dag == DaggerYes)); Compressor compressor; @@ -284,7 +284,7 @@ void ImprovedStaggeredFermion::DerivInternal(StencilImpl &st, DoubledGauge // mat+= outer ( AU, UUB) <-- and then use covariant cshift? // mat+= outer ( AUU, UB) <-- Returned from call to DhopDir - assert(0);// need to figure out the force interface with a blasted three link term. + GRID_ASSERT(0);// need to figure out the force interface with a blasted three link term. } } @@ -308,8 +308,8 @@ void ImprovedStaggeredFermion::DhopDerivOE(GaugeField &mat, const FermionF conformable(U.Grid(), V.Grid()); conformable(U.Grid(), mat.Grid()); - assert(V.Checkerboard() == Even); - assert(U.Checkerboard() == Odd); + GRID_ASSERT(V.Checkerboard() == Even); + GRID_ASSERT(U.Checkerboard() == Odd); mat.Checkerboard() = Odd; DerivInternal(StencilEven, UmuOdd, UUUmuOdd, mat, U, V, dag); @@ -322,8 +322,8 @@ void ImprovedStaggeredFermion::DhopDerivEO(GaugeField &mat, const FermionF conformable(U.Grid(), V.Grid()); conformable(U.Grid(), mat.Grid()); - assert(V.Checkerboard() == Odd); - assert(U.Checkerboard() == Even); + GRID_ASSERT(V.Checkerboard() == Odd); + GRID_ASSERT(U.Checkerboard() == Even); mat.Checkerboard() = Even; DerivInternal(StencilOdd, UmuEven, UUUmuEven, mat, U, V, dag); @@ -346,7 +346,7 @@ void ImprovedStaggeredFermion::DhopOE(const FermionField &in, FermionField conformable(in.Grid(), _cbgrid); // verifies half grid conformable(in.Grid(), out.Grid()); // drops the cb check - assert(in.Checkerboard() == Even); + GRID_ASSERT(in.Checkerboard() == Even); out.Checkerboard() = Odd; DhopInternal(StencilEven, UmuOdd, UUUmuOdd, in, out, dag); @@ -358,7 +358,7 @@ void ImprovedStaggeredFermion::DhopEO(const FermionField &in, FermionField conformable(in.Grid(), _cbgrid); // verifies half grid conformable(in.Grid(), out.Grid()); // drops the cb check - assert(in.Checkerboard() == Odd); + GRID_ASSERT(in.Checkerboard() == Odd); out.Checkerboard() = Even; DhopInternal(StencilOdd, UmuEven, UUUmuEven, in, out, dag); @@ -372,7 +372,7 @@ void ImprovedStaggeredFermion::Mdir(const FermionField &in, FermionField & template void ImprovedStaggeredFermion::MdirAll(const FermionField &in, std::vector &out) { - assert(0); // Not implemented yet + GRID_ASSERT(0); // Not implemented yet } template @@ -450,7 +450,7 @@ void ImprovedStaggeredFermion::DhopInternalSerialComms(StencilImpl &st, const FermionField &in, FermionField &out, int dag) { - assert((dag == DaggerNo) || (dag == DaggerYes)); + GRID_ASSERT((dag == DaggerNo) || (dag == DaggerYes)); Compressor compressor; st.HaloExchange(in, compressor); @@ -473,7 +473,7 @@ void ImprovedStaggeredFermion::ContractConservedCurrent(PropagatorField &q Current curr_type, unsigned int mu) { - assert(0); + GRID_ASSERT(0); } template @@ -486,7 +486,7 @@ void ImprovedStaggeredFermion::SeqConservedCurrent(PropagatorField &q_in, unsigned int tmax, ComplexField &lattice_cmplx) { - assert(0); + GRID_ASSERT(0); } diff --git a/Grid/qcd/action/fermion/implementation/MobiusEOFAFermionCache.h b/Grid/qcd/action/fermion/implementation/MobiusEOFAFermionCache.h index b9165edb..105fc4c7 100644 --- a/Grid/qcd/action/fermion/implementation/MobiusEOFAFermionCache.h +++ b/Grid/qcd/action/fermion/implementation/MobiusEOFAFermionCache.h @@ -48,7 +48,7 @@ void MobiusEOFAFermion::M5D(const FermionField &psi_i, const FermionField autoView(phi , phi_i, AcceleratorRead); autoView(chi , chi_i, AcceleratorWrite); - assert(phi.Checkerboard() == psi.Checkerboard()); + GRID_ASSERT(phi.Checkerboard() == psi.Checkerboard()); auto pdiag = &this->d_diag[0]; auto pupper = &this->d_upper[0]; @@ -91,7 +91,7 @@ void MobiusEOFAFermion::M5D_shift(const FermionField &psi_i, const Fermion auto pm = this->pm; int shift_s = (pm == 1) ? (Ls-1) : 0; // s-component modified by shift operator - assert(phi.Checkerboard() == psi.Checkerboard()); + GRID_ASSERT(phi.Checkerboard() == psi.Checkerboard()); auto pdiag = &this->d_diag[0]; auto pupper = &this->d_upper[0]; @@ -137,7 +137,7 @@ void MobiusEOFAFermion::M5Ddag(const FermionField &psi_i, const FermionFie autoView(phi , phi_i, AcceleratorRead); autoView(chi , chi_i, AcceleratorWrite); - assert(phi.Checkerboard() == psi.Checkerboard()); + GRID_ASSERT(phi.Checkerboard() == psi.Checkerboard()); auto pdiag = &this->d_diag[0]; auto pupper = &this->d_upper[0]; @@ -178,7 +178,7 @@ void MobiusEOFAFermion::M5Ddag_shift(const FermionField &psi_i, const Ferm autoView(phi , phi_i, AcceleratorRead); autoView(chi , chi_i, AcceleratorWrite); - assert(phi.Checkerboard() == psi.Checkerboard()); + GRID_ASSERT(phi.Checkerboard() == psi.Checkerboard()); auto pdiag = &this->d_diag[0]; auto pupper = &this->d_upper[0]; diff --git a/Grid/qcd/action/fermion/implementation/MobiusEOFAFermionImplementation.h b/Grid/qcd/action/fermion/implementation/MobiusEOFAFermionImplementation.h index 70f06dfc..05d94a0a 100644 --- a/Grid/qcd/action/fermion/implementation/MobiusEOFAFermionImplementation.h +++ b/Grid/qcd/action/fermion/implementation/MobiusEOFAFermionImplementation.h @@ -55,7 +55,7 @@ MobiusEOFAFermion::MobiusEOFAFermion( RealD eps = 1.0; Approx::zolotarev_data *zdata = Approx::higham(eps, this->Ls); - assert(zdata->n == this->Ls); + GRID_ASSERT(zdata->n == this->Ls); std::cout << GridLogMessage << "MobiusEOFAFermion (b=" << _b << ",c=" << _c << ") with Ls=" << Ls << std::endl; diff --git a/Grid/qcd/action/fermion/implementation/NaiveStaggeredFermionImplementation.h b/Grid/qcd/action/fermion/implementation/NaiveStaggeredFermionImplementation.h index b596dc44..4fd8d09e 100644 --- a/Grid/qcd/action/fermion/implementation/NaiveStaggeredFermionImplementation.h +++ b/Grid/qcd/action/fermion/implementation/NaiveStaggeredFermionImplementation.h @@ -191,7 +191,7 @@ void NaiveStaggeredFermion::DerivInternal(StencilImpl &st, DoubledGaugeFie GaugeField & mat, const FermionField &A, const FermionField &B, int dag) { - assert((dag == DaggerNo) || (dag == DaggerYes)); + GRID_ASSERT((dag == DaggerNo) || (dag == DaggerYes)); Compressor compressor; @@ -213,7 +213,7 @@ void NaiveStaggeredFermion::DerivInternal(StencilImpl &st, DoubledGaugeFie Kernels::DhopDirKernel(st, U_v, U_v, st.CommBuf(), sss, sss, B_v, Btilde_v, mu,1); }); - assert(0);// need to figure out the force interface with a blasted three link term. + GRID_ASSERT(0);// need to figure out the force interface with a blasted three link term. } } @@ -237,8 +237,8 @@ void NaiveStaggeredFermion::DhopDerivOE(GaugeField &mat, const FermionFiel conformable(U.Grid(), V.Grid()); conformable(U.Grid(), mat.Grid()); - assert(V.Checkerboard() == Even); - assert(U.Checkerboard() == Odd); + GRID_ASSERT(V.Checkerboard() == Even); + GRID_ASSERT(U.Checkerboard() == Odd); mat.Checkerboard() = Odd; DerivInternal(StencilEven, UmuOdd, mat, U, V, dag); @@ -251,8 +251,8 @@ void NaiveStaggeredFermion::DhopDerivEO(GaugeField &mat, const FermionFiel conformable(U.Grid(), V.Grid()); conformable(U.Grid(), mat.Grid()); - assert(V.Checkerboard() == Odd); - assert(U.Checkerboard() == Even); + GRID_ASSERT(V.Checkerboard() == Odd); + GRID_ASSERT(U.Checkerboard() == Even); mat.Checkerboard() = Even; DerivInternal(StencilOdd, UmuEven, mat, U, V, dag); @@ -275,7 +275,7 @@ void NaiveStaggeredFermion::DhopOE(const FermionField &in, FermionField &o conformable(in.Grid(), _cbgrid); // verifies half grid conformable(in.Grid(), out.Grid()); // drops the cb check - assert(in.Checkerboard() == Even); + GRID_ASSERT(in.Checkerboard() == Even); out.Checkerboard() = Odd; DhopInternal(StencilEven, UmuOdd, in, out, dag); @@ -287,7 +287,7 @@ void NaiveStaggeredFermion::DhopEO(const FermionField &in, FermionField &o conformable(in.Grid(), _cbgrid); // verifies half grid conformable(in.Grid(), out.Grid()); // drops the cb check - assert(in.Checkerboard() == Odd); + GRID_ASSERT(in.Checkerboard() == Odd); out.Checkerboard() = Even; DhopInternal(StencilOdd, UmuEven, in, out, dag); @@ -301,7 +301,7 @@ void NaiveStaggeredFermion::Mdir(const FermionField &in, FermionField &out template void NaiveStaggeredFermion::MdirAll(const FermionField &in, std::vector &out) { - assert(0); // Not implemented yet + GRID_ASSERT(0); // Not implemented yet } template @@ -316,7 +316,7 @@ void NaiveStaggeredFermion::DhopDir(const FermionField &in, FermionField & // thread_for( sss, in.Grid()->oSites(),{ // Kernels::DhopDirKernel(Stencil, Umu_v, Stencil.CommBuf(), sss, sss, in_v, out_v, dir, disp); // }); - assert(0); + GRID_ASSERT(0); }; @@ -375,7 +375,7 @@ void NaiveStaggeredFermion::DhopInternalSerialComms(StencilImpl &st, const FermionField &in, FermionField &out, int dag) { - assert((dag == DaggerNo) || (dag == DaggerYes)); + GRID_ASSERT((dag == DaggerNo) || (dag == DaggerYes)); Compressor compressor; st.HaloExchange(in, compressor); @@ -398,7 +398,7 @@ void NaiveStaggeredFermion::ContractConservedCurrent(PropagatorField &q_in Current curr_type, unsigned int mu) { - assert(0); + GRID_ASSERT(0); } template @@ -411,7 +411,7 @@ void NaiveStaggeredFermion::SeqConservedCurrent(PropagatorField &q_in, unsigned int tmax, ComplexField &lattice_cmplx) { - assert(0); + GRID_ASSERT(0); } diff --git a/Grid/qcd/action/fermion/implementation/PartialFractionFermion5DImplementation.h b/Grid/qcd/action/fermion/implementation/PartialFractionFermion5DImplementation.h index 84884c6d..6115bf9b 100644 --- a/Grid/qcd/action/fermion/implementation/PartialFractionFermion5DImplementation.h +++ b/Grid/qcd/action/fermion/implementation/PartialFractionFermion5DImplementation.h @@ -245,7 +245,7 @@ void PartialFractionFermion5D::M_internal(const FermionField &psi, Fermi if ( qmu.size() ) { std::cout<< "Mat" << "qmu ("<::SetCoefficientsZolotarev(RealD zolo_hi,App // std::cout<dd << " -dd"<Ls; - assert(Ls == (2*zdata->da -1) ); + GRID_ASSERT(Ls == (2*zdata->da -1) ); // Part frac // RealD R; @@ -509,7 +509,7 @@ PartialFractionFermion5D::PartialFractionFermion5D(GaugeField &_Umu, { int Ls = this->Ls; qmu.resize(0); - assert((Ls&0x1)==1); // Odd Ls required + GRID_ASSERT((Ls&0x1)==1); // Odd Ls required int nrational=Ls-1; diff --git a/Grid/qcd/action/fermion/implementation/StaggeredKernelsAsm.h b/Grid/qcd/action/fermion/implementation/StaggeredKernelsAsm.h index e9cacbcf..4857c25a 100644 --- a/Grid/qcd/action/fermion/implementation/StaggeredKernelsAsm.h +++ b/Grid/qcd/action/fermion/implementation/StaggeredKernelsAsm.h @@ -624,7 +624,7 @@ void StaggeredKernels::DhopSiteAsm(StencilView &st, SiteSpinor *buf, int sF, int sU, const FermionFieldView &in, FermionFieldView &out,int dag) { - assert(0); + GRID_ASSERT(0); }; @@ -733,7 +733,7 @@ template <> void StaggeredKernels::DhopSiteAsm(StencilView } } #else - assert(0); + GRID_ASSERT(0); #endif } @@ -787,7 +787,7 @@ template <> void StaggeredKernels::DhopSiteAsm(StencilView } } #else - assert(0); + GRID_ASSERT(0); #endif } @@ -889,7 +889,7 @@ template <> void StaggeredKernels::DhopSiteAsm(StencilView &st, } } #else - assert(0); + GRID_ASSERT(0); #endif } @@ -958,7 +958,7 @@ template <> void StaggeredKernels::DhopSiteAsm(StencilView &st, } } #else - assert(0); + GRID_ASSERT(0); #endif } diff --git a/Grid/qcd/action/fermion/implementation/StaggeredKernelsImplementation.h b/Grid/qcd/action/fermion/implementation/StaggeredKernelsImplementation.h index 05dbf3b2..7a981eb5 100644 --- a/Grid/qcd/action/fermion/implementation/StaggeredKernelsImplementation.h +++ b/Grid/qcd/action/fermion/implementation/StaggeredKernelsImplementation.h @@ -234,7 +234,7 @@ void StaggeredKernels::DhopDirKernel(StencilImpl &st, DoubledGaugeFieldVie // What about "dag" ? // Because we work out pU . dS/dU // U - assert(0); + GRID_ASSERT(0); } #define KERNEL_CALLNB(A,improved) \ @@ -291,7 +291,7 @@ void StaggeredKernels::DhopImproved(StencilImpl &st, if (Opt == OptGeneric ) { KERNEL_CALL(DhopSiteGenericExt,1); return;} if (Opt == OptHandUnroll ) { KERNEL_CALL(DhopSiteHandExt,1); return;} } - assert(0 && " Kernel optimisation case not covered "); + GRID_ASSERT(0 && " Kernel optimisation case not covered "); } template void StaggeredKernels::DhopNaive(StencilImpl &st, diff --git a/Grid/qcd/action/fermion/implementation/WilsonCloverFermionImplementation.h b/Grid/qcd/action/fermion/implementation/WilsonCloverFermionImplementation.h index 2a7e7535..a4cda1b1 100644 --- a/Grid/qcd/action/fermion/implementation/WilsonCloverFermionImplementation.h +++ b/Grid/qcd/action/fermion/implementation/WilsonCloverFermionImplementation.h @@ -54,7 +54,7 @@ WilsonCloverFermion::WilsonCloverFermion(GaugeField& , CloverTermDagOdd(&Hgrid) , CloverTermInvDagEven(&Hgrid) , CloverTermInvDagOdd(&Hgrid) { - assert(Nd == 4); // require 4 dimensions + GRID_ASSERT(Nd == 4); // require 4 dimensions if(clover_anisotropy.isAnisotropic) { csw_r = _csw_r * 0.5 / clover_anisotropy.xi_0; @@ -189,7 +189,7 @@ void WilsonCloverFermion::MooeeInternal(const FermionField { out.Checkerboard() = in.Checkerboard(); CloverField *Clover; - assert(in.Checkerboard() == Odd || in.Checkerboard() == Even); + GRID_ASSERT(in.Checkerboard() == Odd || in.Checkerboard() == Even); if (dag) { @@ -323,14 +323,14 @@ void WilsonCloverFermion::MDeriv(GaugeField &force, const F template void WilsonCloverFermion::MooDeriv(GaugeField &mat, const FermionField &X, const FermionField &Y, int dag) { - assert(0); + GRID_ASSERT(0); } // Derivative parts template void WilsonCloverFermion::MeeDeriv(GaugeField &mat, const FermionField &U, const FermionField &V, int dag) { - assert(0); // not implemented yet + GRID_ASSERT(0); // not implemented yet } NAMESPACE_END(Grid); diff --git a/Grid/qcd/action/fermion/implementation/WilsonFermion5DImplementation.h b/Grid/qcd/action/fermion/implementation/WilsonFermion5DImplementation.h index 9598552f..48ec71bf 100644 --- a/Grid/qcd/action/fermion/implementation/WilsonFermion5DImplementation.h +++ b/Grid/qcd/action/fermion/implementation/WilsonFermion5DImplementation.h @@ -62,33 +62,33 @@ WilsonFermion5D::WilsonFermion5D(GaugeField &_Umu, _tmp(&FiveDimRedBlackGrid), Dirichlet(0) { - // some assertions - assert(FiveDimGrid._ndimension==5); - assert(FourDimGrid._ndimension==4); - assert(FourDimRedBlackGrid._ndimension==4); - assert(FiveDimRedBlackGrid._ndimension==5); - assert(FiveDimRedBlackGrid._checker_dim==1); // Don't checker the s direction + // some GRID_ASSERTions + GRID_ASSERT(FiveDimGrid._ndimension==5); + GRID_ASSERT(FourDimGrid._ndimension==4); + GRID_ASSERT(FourDimRedBlackGrid._ndimension==4); + GRID_ASSERT(FiveDimRedBlackGrid._ndimension==5); + GRID_ASSERT(FiveDimRedBlackGrid._checker_dim==1); // Don't checker the s direction // extent of fifth dim and not spread out Ls=FiveDimGrid._fdimensions[0]; - assert(FiveDimRedBlackGrid._fdimensions[0]==Ls); - assert(FiveDimGrid._processors[0] ==1); - assert(FiveDimRedBlackGrid._processors[0] ==1); + GRID_ASSERT(FiveDimRedBlackGrid._fdimensions[0]==Ls); + GRID_ASSERT(FiveDimGrid._processors[0] ==1); + GRID_ASSERT(FiveDimRedBlackGrid._processors[0] ==1); // Other dimensions must match the decomposition of the four-D fields for(int d=0;d<4;d++){ - assert(FiveDimGrid._processors[d+1] ==FourDimGrid._processors[d]); - assert(FiveDimRedBlackGrid._processors[d+1] ==FourDimGrid._processors[d]); - assert(FourDimRedBlackGrid._processors[d] ==FourDimGrid._processors[d]); + GRID_ASSERT(FiveDimGrid._processors[d+1] ==FourDimGrid._processors[d]); + GRID_ASSERT(FiveDimRedBlackGrid._processors[d+1] ==FourDimGrid._processors[d]); + GRID_ASSERT(FourDimRedBlackGrid._processors[d] ==FourDimGrid._processors[d]); - assert(FiveDimGrid._fdimensions[d+1] ==FourDimGrid._fdimensions[d]); - assert(FiveDimRedBlackGrid._fdimensions[d+1]==FourDimGrid._fdimensions[d]); - assert(FourDimRedBlackGrid._fdimensions[d] ==FourDimGrid._fdimensions[d]); + GRID_ASSERT(FiveDimGrid._fdimensions[d+1] ==FourDimGrid._fdimensions[d]); + GRID_ASSERT(FiveDimRedBlackGrid._fdimensions[d+1]==FourDimGrid._fdimensions[d]); + GRID_ASSERT(FourDimRedBlackGrid._fdimensions[d] ==FourDimGrid._fdimensions[d]); - assert(FiveDimGrid._simd_layout[d+1] ==FourDimGrid._simd_layout[d]); - assert(FiveDimRedBlackGrid._simd_layout[d+1]==FourDimGrid._simd_layout[d]); - assert(FourDimRedBlackGrid._simd_layout[d] ==FourDimGrid._simd_layout[d]); + GRID_ASSERT(FiveDimGrid._simd_layout[d+1] ==FourDimGrid._simd_layout[d]); + GRID_ASSERT(FiveDimRedBlackGrid._simd_layout[d+1]==FourDimGrid._simd_layout[d]); + GRID_ASSERT(FourDimRedBlackGrid._simd_layout[d] ==FourDimGrid._simd_layout[d]); } if ( p.dirichlet.size() == Nd+1) { @@ -109,20 +109,20 @@ WilsonFermion5D::WilsonFermion5D(GaugeField &_Umu, int nsimd = Simd::Nsimd(); // Dimension zero of the five-d is the Ls direction - assert(FiveDimGrid._simd_layout[0] ==nsimd); - assert(FiveDimRedBlackGrid._simd_layout[0]==nsimd); + GRID_ASSERT(FiveDimGrid._simd_layout[0] ==nsimd); + GRID_ASSERT(FiveDimRedBlackGrid._simd_layout[0]==nsimd); for(int d=0;d<4;d++){ - assert(FourDimGrid._simd_layout[d]==1); - assert(FourDimRedBlackGrid._simd_layout[d]==1); - assert(FiveDimRedBlackGrid._simd_layout[d+1]==1); + GRID_ASSERT(FourDimGrid._simd_layout[d]==1); + GRID_ASSERT(FourDimRedBlackGrid._simd_layout[d]==1); + GRID_ASSERT(FiveDimRedBlackGrid._simd_layout[d+1]==1); } } else { // Dimension zero of the five-d is the Ls direction - assert(FiveDimRedBlackGrid._simd_layout[0]==1); - assert(FiveDimGrid._simd_layout[0] ==1); + GRID_ASSERT(FiveDimRedBlackGrid._simd_layout[0]==1); + GRID_ASSERT(FiveDimGrid._simd_layout[0] ==1); } @@ -157,7 +157,7 @@ void WilsonFermion5D::ImportGauge(const GaugeField &_Umu) for(int d=0;dLocalDimensions()[d]; - if (GaugeBlock) assert( (GaugeBlock%ldim)==0); + if (GaugeBlock) GRID_ASSERT( (GaugeBlock%ldim)==0); } if (!this->Params.partialDirichlet) { @@ -179,8 +179,8 @@ void WilsonFermion5D::DhopDir(const FermionField &in, FermionField &out,in { int dir = dir5-1; // Maps to the ordering above in "directions" that is passed to stencil // we drop off the innermost fifth dimension - // assert( (disp==1)||(disp==-1) ); - // assert( (dir>=0)&&(dir<4) ); //must do x,y,z or t; + // GRID_ASSERT( (disp==1)||(disp==-1) ); + // GRID_ASSERT( (dir>=0)&&(dir<4) ); //must do x,y,z or t; int skip = (disp==1) ? 0 : 1; int dirdisp = dir+skip*4; @@ -211,7 +211,7 @@ void WilsonFermion5D::DerivInternal(StencilImpl & st, const FermionField &B, int dag) { - assert((dag==DaggerNo) ||(dag==DaggerYes)); + GRID_ASSERT((dag==DaggerNo) ||(dag==DaggerYes)); conformable(st.Grid(),A.Grid()); conformable(st.Grid(),B.Grid()); @@ -275,8 +275,8 @@ void WilsonFermion5D::DhopDerivEO(GaugeField &mat, conformable(A.Grid(),FermionRedBlackGrid()); conformable(A.Grid(),B.Grid()); - assert(B.Checkerboard()==Odd); - assert(A.Checkerboard()==Even); + GRID_ASSERT(B.Checkerboard()==Odd); + GRID_ASSERT(A.Checkerboard()==Even); mat.Checkerboard() = Even; DerivInternal(StencilOdd,UmuEven,mat,A,B,dag); @@ -292,8 +292,8 @@ void WilsonFermion5D::DhopDerivOE(GaugeField &mat, conformable(A.Grid(),FermionRedBlackGrid()); conformable(A.Grid(),B.Grid()); - assert(B.Checkerboard()==Even); - assert(A.Checkerboard()==Odd); + GRID_ASSERT(B.Checkerboard()==Even); + GRID_ASSERT(A.Checkerboard()==Odd); mat.Checkerboard() = Odd; DerivInternal(StencilEven,UmuOdd,mat,A,B,dag); @@ -429,7 +429,7 @@ void WilsonFermion5D::DhopOE(const FermionField &in, FermionField &out,int conformable(in.Grid(),FermionRedBlackGrid()); // verifies half grid conformable(in.Grid(),out.Grid()); // drops the cb check - assert(in.Checkerboard()==Even); + GRID_ASSERT(in.Checkerboard()==Even); out.Checkerboard() = Odd; DhopInternal(StencilEven,UmuOdd,in,out,dag); @@ -440,7 +440,7 @@ void WilsonFermion5D::DhopEO(const FermionField &in, FermionField &out,int conformable(in.Grid(),FermionRedBlackGrid()); // verifies half grid conformable(in.Grid(),out.Grid()); // drops the cb check - assert(in.Checkerboard()==Odd); + GRID_ASSERT(in.Checkerboard()==Odd); out.Checkerboard() = Even; DhopInternal(StencilOdd,UmuEven,in,out,dag); diff --git a/Grid/qcd/action/fermion/implementation/WilsonFermionImplementation.h b/Grid/qcd/action/fermion/implementation/WilsonFermionImplementation.h index 8c58f692..cba9b48c 100644 --- a/Grid/qcd/action/fermion/implementation/WilsonFermionImplementation.h +++ b/Grid/qcd/action/fermion/implementation/WilsonFermionImplementation.h @@ -233,7 +233,7 @@ template void WilsonFermion::DerivInternal(StencilImpl &st, DoubledGaugeField &U, GaugeField &mat, const FermionField &A, const FermionField &B, int dag) { - assert((dag == DaggerNo) || (dag == DaggerYes)); + GRID_ASSERT((dag == DaggerNo) || (dag == DaggerYes)); Compressor compressor(dag); @@ -280,8 +280,8 @@ void WilsonFermion::DhopDerivOE(GaugeField &mat, const FermionField &U, co //conformable(U.Grid(), mat.Grid()); not general, leaving as a comment (Guido) // Motivation: look at the SchurDiff operator - assert(V.Checkerboard() == Even); - assert(U.Checkerboard() == Odd); + GRID_ASSERT(V.Checkerboard() == Even); + GRID_ASSERT(U.Checkerboard() == Odd); mat.Checkerboard() = Odd; DerivInternal(StencilEven, UmuOdd, mat, U, V, dag); @@ -294,8 +294,8 @@ void WilsonFermion::DhopDerivEO(GaugeField &mat, const FermionField &U, co conformable(U.Grid(), V.Grid()); //conformable(U.Grid(), mat.Grid()); - assert(V.Checkerboard() == Odd); - assert(U.Checkerboard() == Even); + GRID_ASSERT(V.Checkerboard() == Odd); + GRID_ASSERT(U.Checkerboard() == Even); mat.Checkerboard() = Even; DerivInternal(StencilOdd, UmuEven, mat, U, V, dag); @@ -318,7 +318,7 @@ void WilsonFermion::DhopOE(const FermionField &in, FermionField &out, int conformable(in.Grid(), _cbgrid); // verifies half grid conformable(in.Grid(), out.Grid()); // drops the cb check - assert(in.Checkerboard() == Even); + GRID_ASSERT(in.Checkerboard() == Even); out.Checkerboard() = Odd; DhopInternal(StencilEven, UmuOdd, in, out, dag); @@ -330,7 +330,7 @@ void WilsonFermion::DhopEO(const FermionField &in, FermionField &out,int d conformable(in.Grid(), _cbgrid); // verifies half grid conformable(in.Grid(), out.Grid()); // drops the cb check - assert(in.Checkerboard() == Odd); + GRID_ASSERT(in.Checkerboard() == Odd); out.Checkerboard() = Even; DhopInternal(StencilOdd, UmuEven, in, out, dag); @@ -365,7 +365,7 @@ void WilsonFermion::DhopDirAll(const FermionField &in, std::vector::DhopInternalOverlappedComms(StencilImpl &st, FermionField &out, int dag) { GRID_TRACE("DhopOverlapped"); - assert((dag == DaggerNo) || (dag == DaggerYes)); + GRID_ASSERT((dag == DaggerNo) || (dag == DaggerYes)); Compressor compressor(dag); int len = U.Grid()->oSites(); @@ -475,7 +475,7 @@ void WilsonFermion::DhopInternalSerial(StencilImpl &st, FermionField &out, int dag) { GRID_TRACE("DhopSerial"); - assert((dag == DaggerNo) || (dag == DaggerYes)); + GRID_ASSERT((dag == DaggerNo) || (dag == DaggerYes)); Compressor compressor(dag); { GRID_TRACE("HaloExchange"); diff --git a/Grid/qcd/action/fermion/implementation/WilsonKernelsAsmImplementation.h b/Grid/qcd/action/fermion/implementation/WilsonKernelsAsmImplementation.h index 0c956f7e..ab1eba90 100644 --- a/Grid/qcd/action/fermion/implementation/WilsonKernelsAsmImplementation.h +++ b/Grid/qcd/action/fermion/implementation/WilsonKernelsAsmImplementation.h @@ -44,42 +44,42 @@ template void WilsonKernels::AsmDhopSite(StencilView &st, DoubledGaugeFieldView &U,SiteHalfSpinor *buf, int ss,int ssU,int Ls,int Ns,const FermionFieldView &in, FermionFieldView &out) { - assert(0); + GRID_ASSERT(0); } template void WilsonKernels::AsmDhopSiteDag(StencilView &st, DoubledGaugeFieldView &U,SiteHalfSpinor *buf, int ss,int ssU,int Ls,int Ns,const FermionFieldView &in, FermionFieldView &out) { - assert(0); + GRID_ASSERT(0); } template void WilsonKernels::AsmDhopSiteInt(StencilView &st, DoubledGaugeFieldView &U,SiteHalfSpinor *buf, int ss,int ssU,int Ls,int Ns,const FermionFieldView &in, FermionFieldView &out) { - assert(0); + GRID_ASSERT(0); } template void WilsonKernels::AsmDhopSiteDagInt(StencilView &st, DoubledGaugeFieldView &U,SiteHalfSpinor *buf, int ss,int ssU,int Ls,int Ns,const FermionFieldView &in, FermionFieldView &out) { - assert(0); + GRID_ASSERT(0); } template void WilsonKernels::AsmDhopSiteExt(StencilView &st, DoubledGaugeFieldView &U,SiteHalfSpinor *buf, int ss,int ssU,int Ls,int Ns,const FermionFieldView &in, FermionFieldView &out) { - assert(0); + GRID_ASSERT(0); } template void WilsonKernels::AsmDhopSiteDagExt(StencilView &st, DoubledGaugeFieldView &U,SiteHalfSpinor *buf, int ss,int ssU,int Ls,int Ns,const FermionFieldView &in, FermionFieldView &out) { - assert(0); + GRID_ASSERT(0); } NAMESPACE_END(Grid); diff --git a/Grid/qcd/action/fermion/implementation/WilsonKernelsImplementation.h b/Grid/qcd/action/fermion/implementation/WilsonKernelsImplementation.h index 54a76b07..cf8ae40e 100644 --- a/Grid/qcd/action/fermion/implementation/WilsonKernelsImplementation.h +++ b/Grid/qcd/action/fermion/implementation/WilsonKernelsImplementation.h @@ -375,8 +375,8 @@ template void WilsonKernels::DhopDirKernel( StencilImpl &st, DoubledGaugeField &U,SiteHalfSpinor *buf, int Ls, int Nsite, const FermionField &in, FermionField &out, int dirdisp, int gamma) { - assert(dirdisp<=7); - assert(dirdisp>=0); + GRID_ASSERT(dirdisp<=7); + GRID_ASSERT(dirdisp>=0); autoView(U_v ,U ,AcceleratorRead); autoView(in_v ,in ,AcceleratorRead); @@ -405,7 +405,7 @@ void WilsonKernels::DhopDirKernel( StencilImpl &st, DoubledGaugeField &U,S LoopBody(Zm); LoopBody(Tm); default: - assert(0); + GRID_ASSERT(0); break; } #undef LoopBody @@ -525,7 +525,7 @@ void WilsonKernels::DhopKernel(int Opt,StencilImpl &st, DoubledGaugeField if (Opt == WilsonKernelsStatic::OptInlineAsm ) { ASM_CALL(AsmDhopSiteExt); return;} #endif } - assert(0 && " Kernel optimisation case not covered "); + GRID_ASSERT(0 && " Kernel optimisation case not covered "); } template @@ -571,7 +571,7 @@ void WilsonKernels::DhopKernel(int Opt,StencilImpl &st, DoubledGaugeField if (Opt == WilsonKernelsStatic::OptInlineAsm ) { ASM_CALL(AsmDhopSiteDagExt); return;} #endif } - assert(0 && " Kernel optimisation case not covered "); + GRID_ASSERT(0 && " Kernel optimisation case not covered "); } #undef KERNEL_CALLNB diff --git a/Grid/qcd/action/gauge/Gauge.h b/Grid/qcd/action/gauge/Gauge.h index 7a72d087..2b6b0e6b 100644 --- a/Grid/qcd/action/gauge/Gauge.h +++ b/Grid/qcd/action/gauge/Gauge.h @@ -51,6 +51,9 @@ typedef IwasakiGaugeAction IwasakiGaugeActionD; typedef SymanzikGaugeAction SymanzikGaugeActionR; typedef SymanzikGaugeAction SymanzikGaugeActionF; typedef SymanzikGaugeAction SymanzikGaugeActionD; +typedef DBW2GaugeAction DBW2GaugeActionR; +typedef DBW2GaugeAction DBW2GaugeActionF; +typedef DBW2GaugeAction DBW2GaugeActionD; typedef WilsonGaugeAction ConjugateWilsonGaugeActionR; diff --git a/Grid/qcd/action/gauge/GaugeImplementations.h b/Grid/qcd/action/gauge/GaugeImplementations.h index 312e889c..62141c83 100644 --- a/Grid/qcd/action/gauge/GaugeImplementations.h +++ b/Grid/qcd/action/gauge/GaugeImplementations.h @@ -97,7 +97,7 @@ public: static Lattice CovShiftForward(const GaugeLinkField &Link, int mu, const Lattice &field) { - assert(_conjDirs.size() == Nd); + GRID_ASSERT(_conjDirs.size() == Nd); if(_conjDirs[mu]) return ConjugateBC::CovShiftForward(Link, mu, field); else @@ -108,7 +108,7 @@ public: static Lattice CovShiftBackward(const GaugeLinkField &Link, int mu, const Lattice &field) { - assert(_conjDirs.size() == Nd); + GRID_ASSERT(_conjDirs.size() == Nd); if(_conjDirs[mu]) return ConjugateBC::CovShiftBackward(Link, mu, field); else @@ -123,7 +123,7 @@ public: static inline GaugeLinkField CovShiftIdentityBackward(const GaugeLinkField &Link, int mu) { - assert(_conjDirs.size() == Nd); + GRID_ASSERT(_conjDirs.size() == Nd); if(_conjDirs[mu]) return ConjugateBC::CovShiftIdentityBackward(Link, mu); else @@ -132,7 +132,7 @@ public: static inline GaugeLinkField CovShiftIdentityForward(const GaugeLinkField &Link, int mu) { - assert(_conjDirs.size() == Nd); + GRID_ASSERT(_conjDirs.size() == Nd); if(_conjDirs[mu]) return ConjugateBC::CovShiftIdentityForward(Link,mu); else @@ -148,7 +148,7 @@ public: //Note: While this is used for Staples it is also applicable for shifting gauge links or gauge transformation matrices static inline GaugeLinkField ShiftStaple(const GaugeLinkField &Link, int mu) { - assert(_conjDirs.size() == Nd); + GRID_ASSERT(_conjDirs.size() == Nd); if(_conjDirs[mu]) return ConjugateBC::ShiftStaple(Link,mu); else @@ -169,7 +169,7 @@ public: //shift = -1 //Out(x) = U_\mu(x-\hat\mu mod L) static inline GaugeLinkField CshiftLink(const GaugeLinkField &Link, int mu, int shift){ - assert(_conjDirs.size() == Nd); + GRID_ASSERT(_conjDirs.size() == Nd); if(_conjDirs[mu]) return ConjugateBC::CshiftLink(Link,mu,shift); else diff --git a/Grid/qcd/action/gauge/Photon.h b/Grid/qcd/action/gauge/Photon.h index 3d4baccd..34107fcd 100644 --- a/Grid/qcd/action/gauge/Photon.h +++ b/Grid/qcd/action/gauge/Photon.h @@ -193,7 +193,7 @@ NAMESPACE_BEGIN(Grid); break; } default: - assert(0); + GRID_ASSERT(0); break; } } @@ -246,10 +246,10 @@ NAMESPACE_BEGIN(Grid); transverseProjectSpatial(out); break; case Gauge::landau: - assert(0); + GRID_ASSERT(0); break; default: - assert(0); + GRID_ASSERT(0); break; } } diff --git a/Grid/qcd/action/pseudofermion/Bounds.h b/Grid/qcd/action/pseudofermion/Bounds.h index 8864b1d7..fc22fa57 100644 --- a/Grid/qcd/action/pseudofermion/Bounds.h +++ b/Grid/qcd/action/pseudofermion/Bounds.h @@ -11,7 +11,7 @@ NAMESPACE_BEGIN(Grid); PowerMethod power_method; auto lambda_max = power_method(HermOp,Phi); std::cout << GridLogMessage << "Pseudofermion action lamda_max "< void ChebyBoundsCheck(LinearOperatorBase &HermOp, @@ -36,7 +36,7 @@ NAMESPACE_BEGIN(Grid); std::cout << " Cheb x noise = "< void InverseSqrtBoundsCheck(int MaxIter,double tol, @@ -71,7 +71,7 @@ NAMESPACE_BEGIN(Grid); std::cout << " | noise - MdagM (MdagM^-1/2)^2 noise |^2 = "<_Mat.MooeeInvDag(tmp1,tmp2); // even->even this->_Mat.MeoDeriv(ForceE,tmp2,V,DaggerNo); - assert(ForceE.Checkerboard()==Even); - assert(ForceO.Checkerboard()==Odd); + GRID_ASSERT(ForceE.Checkerboard()==Even); + GRID_ASSERT(ForceO.Checkerboard()==Odd); setCheckerboard(Force,ForceE); setCheckerboard(Force,ForceO); @@ -106,8 +106,8 @@ public: conformable(fcbgrid,V.Grid()); // Assert the checkerboard?? or code for either - assert(V.Checkerboard()==Odd); - assert(V.Checkerboard()==V.Checkerboard()); + GRID_ASSERT(V.Checkerboard()==Odd); + GRID_ASSERT(V.Checkerboard()==V.Checkerboard()); // NOTE Guido: WE DO NOT WANT TO USE THE ucbgrid GRID FOR THE FORCE // it is not conformable with the HMC force field @@ -127,8 +127,8 @@ public: this->_Mat.MooeeInv(tmp1,tmp2); // even->even this->_Mat.MeoDeriv(ForceE,tmp2,V,DaggerYes); - assert(ForceE.Checkerboard()==Even); - assert(ForceO.Checkerboard()==Odd); + GRID_ASSERT(ForceE.Checkerboard()==Even); + GRID_ASSERT(ForceO.Checkerboard()==Odd); setCheckerboard(Force,ForceE); setCheckerboard(Force,ForceO); diff --git a/Grid/qcd/action/pseudofermion/ExactOneFlavourRatio.h b/Grid/qcd/action/pseudofermion/ExactOneFlavourRatio.h index 9d4df1d3..5c7e5a0d 100644 --- a/Grid/qcd/action/pseudofermion/ExactOneFlavourRatio.h +++ b/Grid/qcd/action/pseudofermion/ExactOneFlavourRatio.h @@ -400,7 +400,7 @@ NAMESPACE_BEGIN(Grid); std::cout << GridLogMessage << action_name() << " initial action " << action << " expect " << norm2_eta << "; diff " << diff << std::endl; std::cout << GridLogMessage << action_name() << "[ eta^dag ( M^{-1/2} M M^{-1/2} - 1 ) eta ]/|eta^2| = " << test << " expect 0 (tol " << param.BoundsCheckTol << ")" << std::endl; - assert( ( test < param.BoundsCheckTol ) && " Initial action check failed" ); + GRID_ASSERT( ( test < param.BoundsCheckTol ) && " Initial action check failed" ); initial_action = false; } diff --git a/Grid/qcd/action/pseudofermion/OneFlavourEvenOddRational.h b/Grid/qcd/action/pseudofermion/OneFlavourEvenOddRational.h index 656e9b2f..ee0110db 100644 --- a/Grid/qcd/action/pseudofermion/OneFlavourEvenOddRational.h +++ b/Grid/qcd/action/pseudofermion/OneFlavourEvenOddRational.h @@ -135,7 +135,7 @@ public: // FIXME : Clover term not yet.. ////////////////////////////////////////////////////// - assert(FermOp.ConstEE() == 1); + GRID_ASSERT(FermOp.ConstEE() == 1); PhiEven = Zero(); }; diff --git a/Grid/qcd/action/pseudofermion/TwoFlavourEvenOdd.h b/Grid/qcd/action/pseudofermion/TwoFlavourEvenOdd.h index 2e5208a8..78e7fff4 100644 --- a/Grid/qcd/action/pseudofermion/TwoFlavourEvenOdd.h +++ b/Grid/qcd/action/pseudofermion/TwoFlavourEvenOdd.h @@ -168,7 +168,7 @@ public: // FermOp.MeeDeriv(tmp , Y, X,DaggerNo ); dSdU=tmp; // FermOp.MeeDeriv(tmp , X, Y,DaggerYes); dSdU=dSdU+tmp; - assert(FermOp.ConstEE() == 1); + GRID_ASSERT(FermOp.ConstEE() == 1); /* FermOp.MooeeInvDag(PhiOdd,Y); diff --git a/Grid/qcd/action/pseudofermion/TwoFlavourEvenOddRatio.h b/Grid/qcd/action/pseudofermion/TwoFlavourEvenOddRatio.h index ff9a6496..6c9cba6e 100644 --- a/Grid/qcd/action/pseudofermion/TwoFlavourEvenOddRatio.h +++ b/Grid/qcd/action/pseudofermion/TwoFlavourEvenOddRatio.h @@ -231,8 +231,8 @@ NAMESPACE_BEGIN(Grid); // FIXME No force contribution from EvenEven assumed here // Needs a fix for clover. - assert(NumOp.ConstEE() == 1); - assert(DenOp.ConstEE() == 1); + GRID_ASSERT(NumOp.ConstEE() == 1); + GRID_ASSERT(DenOp.ConstEE() == 1); dSdU = -dSdU; diff --git a/Grid/qcd/action/scalar/ScalarInteractionAction.h b/Grid/qcd/action/scalar/ScalarInteractionAction.h index 7708a489..e88f1bcd 100644 --- a/Grid/qcd/action/scalar/ScalarInteractionAction.h +++ b/Grid/qcd/action/scalar/ScalarInteractionAction.h @@ -81,7 +81,7 @@ public: virtual RealD S(const Field &p) { - assert(p.Grid()->Nd() == Ndim); + GRID_ASSERT(p.Grid()->Nd() == Ndim); static Stencil phiStencil(p.Grid(), npoint, 0, directions, displacements); phiStencil.HaloExchange(p, compressor); Field action(p.Grid()), pshift(p.Grid()), phisquared(p.Grid()); @@ -128,7 +128,7 @@ public: virtual void deriv(const Field &p, Field &force) { double t0 = usecond(); - assert(p.Grid()->Nd() == Ndim); + GRID_ASSERT(p.Grid()->Nd() == Ndim); force = (2. * Ndim + mass_square) * p - 2. * lambda * p * p * p; double interm_t = usecond(); diff --git a/Grid/qcd/gparity/GparityFlavour.h b/Grid/qcd/gparity/GparityFlavour.h index b2009235..1b4f38db 100644 --- a/Grid/qcd/gparity/GparityFlavour.h +++ b/Grid/qcd/gparity/GparityFlavour.h @@ -388,7 +388,7 @@ accelerator_inline auto operator*(const GparityFlavour &G, const iVector &arg, const GparityF rmultFlavourProjMinus(ret, arg); break; case GparityFlavour::Algebra::MinusProjMinus: rmultFlavourMinusProjMinus(ret, arg); break; - default: assert(0); + default: GRID_ASSERT(0); } return ret; diff --git a/Grid/qcd/hmc/HMCResourceManager.h b/Grid/qcd/hmc/HMCResourceManager.h index 19bee923..f34fb98e 100644 --- a/Grid/qcd/hmc/HMCResourceManager.h +++ b/Grid/qcd/hmc/HMCResourceManager.h @@ -216,7 +216,7 @@ public: } void SetMomentumFilter( MomentumFilterBase * MomFilter) { - assert(have_Filter==false); + GRID_ASSERT(have_Filter==false); Filter = std::unique_ptr >(MomFilter); have_Filter = true; } @@ -250,7 +250,7 @@ public: void AddRNGs(std::string s = "") { // Couple the RNGs to the GridModule tagged by s // the default is the first grid registered - assert(Grids.size() > 0 && !have_RNG); + GRID_ASSERT(Grids.size() > 0 && !have_RNG); if (s.empty()) s = Grids.begin()->first; std::cout << GridLogDebug << "Adding RNG to grid: " << s << std::endl; RNGs.set_pRNG(new GridParallelRNG(GetCartesian(s))); @@ -262,12 +262,12 @@ public: GridSerialRNG& GetSerialRNG() { return RNGs.get_sRNG(); } GridParallelRNG& GetParallelRNG() { - assert(have_RNG); + GRID_ASSERT(have_RNG); return RNGs.get_pRNG(); } void SeedFixedIntegers() { - assert(have_RNG); + GRID_ASSERT(have_RNG); RNGs.seed(); } diff --git a/Grid/qcd/hmc/checkpointers/BaseCheckpointer.h b/Grid/qcd/hmc/checkpointers/BaseCheckpointer.h index 72f5e39b..4169ce38 100644 --- a/Grid/qcd/hmc/checkpointers/BaseCheckpointer.h +++ b/Grid/qcd/hmc/checkpointers/BaseCheckpointer.h @@ -98,7 +98,7 @@ public: virtual void TrajectoryComplete(int traj, typename Impl::Field &U, GridSerialRNG &sRNG, - GridParallelRNG &pRNG) { assert(0); } ; // HMC should pass the smart config with smeared and unsmeared + GridParallelRNG &pRNG) { GRID_ASSERT(0); } ; // HMC should pass the smart config with smeared and unsmeared virtual void CheckpointRestore(int traj, typename Impl::Field &U, GridSerialRNG &sRNG, diff --git a/Grid/qcd/hmc/integrators/Integrator.h b/Grid/qcd/hmc/integrators/Integrator.h index 549920a0..f497f749 100644 --- a/Grid/qcd/hmc/integrators/Integrator.h +++ b/Grid/qcd/hmc/integrators/Integrator.h @@ -126,7 +126,7 @@ public: // input U actually not used in the fundamental case // Fundamental updates, include smearing - assert(as.size()==LevelForces.size()); + GRID_ASSERT(as.size()==LevelForces.size()); Field level_force(U.Grid()); level_force =Zero(); for (int a = 0; a < as[level].actions.size(); ++a) { @@ -267,13 +267,13 @@ public: void reset_timer(void) { - assert(as.size()==LevelForces.size()); + GRID_ASSERT(as.size()==LevelForces.size()); for (int level = 0; level < as.size(); ++level) { for (int actionID = 0; actionID < as[level].actions.size(); ++actionID) { as[level].actions.at(actionID)->reset_timer(); } int actionID=0; - assert(LevelForces.at(level).actions.size()==1); + GRID_ASSERT(LevelForces.at(level).actions.size()==1); LevelForces.at(level).actions.at(actionID)->reset_timer(); } } @@ -398,7 +398,7 @@ public: // Initialization of momenta and actions void refresh(Field& U, GridSerialRNG & sRNG, GridParallelRNG& pRNG) { - assert(P.Grid() == U.Grid()); + GRID_ASSERT(P.Grid() == U.Grid()); std::cout << GridLogIntegrator << "Integrator refresh" << std::endl; std::cout << GridLogIntegrator << "Generating momentum" << std::endl; @@ -455,7 +455,7 @@ public: RealD S(Field& U) { // here also U not used - assert(as.size()==LevelForces.size()); + GRID_ASSERT(as.size()==LevelForces.size()); std::cout << GridLogIntegrator << "Integrator action\n"; RealD H = - FieldImplementation::FieldSquareNorm(P)/HMC_MOMENTUM_DENOMINATOR; // - trace (P*P)/denom @@ -545,14 +545,14 @@ public: // Check the clocks all match on all levels for (int level = 0; level < as.size(); ++level) { - assert(fabs(t_U - t_P[level]) < 1.0e-6); // must be the same + GRID_ASSERT(fabs(t_U - t_P[level]) < 1.0e-6); // must be the same std::cout << GridLogIntegrator << " times[" << level << "]= " << t_P[level] << " " << t_U << std::endl; } FieldImplementation::Project(U); // and that we indeed got to the end of the trajectory - assert(fabs(t_U - Params.trajL) < 1.0e-6); + GRID_ASSERT(fabs(t_U - Params.trajL) < 1.0e-6); } diff --git a/Grid/qcd/smearing/GaugeConfigurationMasked.h b/Grid/qcd/smearing/GaugeConfigurationMasked.h index 3ee00d6c..292772a6 100644 --- a/Grid/qcd/smearing/GaugeConfigurationMasked.h +++ b/Grid/qcd/smearing/GaugeConfigurationMasked.h @@ -291,8 +291,8 @@ public: int idx=0; for(int mu=0;mu<4;mu++){ for(int nu=0;nu<4;nu++){ - if ( mu!=nu) assert(this->StoutSmearing->SmearRho[idx]==rho); - else assert(this->StoutSmearing->SmearRho[idx]==0.0); + if ( mu!=nu) GRID_ASSERT(this->StoutSmearing->SmearRho[idx]==rho); + else GRID_ASSERT(this->StoutSmearing->SmearRho[idx]==0.0); idx++; }} ////////////////////////////////////////////////////////////////// @@ -934,10 +934,10 @@ public: SmearedConfigurationMasked(GridCartesian* _UGrid, unsigned int Nsmear, Smear_Stout& Stout) : SmearedConfiguration(_UGrid, Nsmear,Stout) { - assert(Nsmear%(2*Nd)==0); // Or multiply by 8?? + GRID_ASSERT(Nsmear%(2*Nd)==0); // Or multiply by 8?? // was resized in base class - assert(this->SmearedSet.size()==Nsmear); + GRID_ASSERT(this->SmearedSet.size()==Nsmear); GridRedBlackCartesian * UrbGrid; UrbGrid = SpaceTimeGrid::makeFourDimRedBlackGrid(_UGrid); diff --git a/Grid/qcd/smearing/HISQSmearing.h b/Grid/qcd/smearing/HISQSmearing.h index e98e9b87..6ffc77ba 100644 --- a/Grid/qcd/smearing/HISQSmearing.h +++ b/Grid/qcd/smearing/HISQSmearing.h @@ -99,16 +99,16 @@ public: Smear_HISQ(GridCartesian* grid, Real c1, Real cnaik, Real c3, Real c5, Real c7, Real clp) : _grid(grid), _linkTreatment(c1,cnaik,c3,c5,c7,clp) { - assert(Nc == 3 && "HISQ smearing currently implemented only for Nc==3"); - assert(Nd == 4 && "HISQ smearing only defined for Nd==4"); + GRID_ASSERT(Nc == 3 && "HISQ smearing currently implemented only for Nc==3"); + GRID_ASSERT(Nd == 4 && "HISQ smearing only defined for Nd==4"); } // Allow to pass a pointer to a C-style, double array for MILC convenience Smear_HISQ(GridCartesian* grid, double* coeff) : _grid(grid), _linkTreatment(coeff[0],coeff[1],coeff[2],coeff[3],coeff[4],coeff[5]) { - assert(Nc == 3 && "HISQ smearing currently implemented only for Nc==3"); - assert(Nd == 4 && "HISQ smearing only defined for Nd==4"); + GRID_ASSERT(Nc == 3 && "HISQ smearing currently implemented only for Nc==3"); + GRID_ASSERT(Nd == 4 && "HISQ smearing only defined for Nd==4"); } ~Smear_HISQ() {} diff --git a/Grid/qcd/smearing/JacobianAction.h b/Grid/qcd/smearing/JacobianAction.h index 6db59bec..688e88ed 100644 --- a/Grid/qcd/smearing/JacobianAction.h +++ b/Grid/qcd/smearing/JacobianAction.h @@ -53,9 +53,9 @@ public: ////////////////////////////////// // Usual cases are not used ////////////////////////////////// - virtual void refresh(const GaugeField &U, GridSerialRNG &sRNG, GridParallelRNG &pRNG){ assert(0);}; - virtual RealD S(const GaugeField &U) { assert(0); } - virtual void deriv(const GaugeField &U, GaugeField &dSdU) { assert(0); } + virtual void refresh(const GaugeField &U, GridSerialRNG &sRNG, GridParallelRNG &pRNG){ GRID_ASSERT(0);}; + virtual RealD S(const GaugeField &U) { GRID_ASSERT(0); } + virtual void deriv(const GaugeField &U, GaugeField &dSdU) { GRID_ASSERT(0); } ////////////////////////////////// // Functions of smart configs only @@ -67,7 +67,7 @@ public: virtual RealD S(ConfigurationBase& U) { // det M = e^{ - ( - logDetM) } - assert( &U == smearer ); + GRID_ASSERT( &U == smearer ); return -smearer->logDetJacobian(); } virtual RealD Sinitial(ConfigurationBase& U) @@ -76,7 +76,7 @@ public: } virtual void deriv(ConfigurationBase& U, GaugeField& dSdU) { - assert( &U == smearer ); + GRID_ASSERT( &U == smearer ); smearer->logDetJacobianForce(dSdU); } diff --git a/Grid/qcd/smearing/StoutSmearing.h b/Grid/qcd/smearing/StoutSmearing.h index 787ef104..5ae6fbe8 100644 --- a/Grid/qcd/smearing/StoutSmearing.h +++ b/Grid/qcd/smearing/StoutSmearing.h @@ -63,20 +63,20 @@ public: /*! Stout smearing with base explicitly specified */ Smear_Stout(Smear* base) : SmearBase{base} { - assert(Nc == 3 && "Stout smearing currently implemented only for Nc==3"); + GRID_ASSERT(Nc == 3 && "Stout smearing currently implemented only for Nc==3"); } /*! Construct stout smearing object from explicitly specified rho matrix */ Smear_Stout(const std::vector& rho_) : OwnedBase{new Smear_APE(rho_)}, SmearBase{OwnedBase.get()} { std::cout << GridLogDebug << "Stout smearing constructor : Smear_Stout(const std::vector& " << rho_ << " )" << std::endl; - assert(Nc == 3 && "Stout smearing currently implemented only for Nc==3"); + GRID_ASSERT(Nc == 3 && "Stout smearing currently implemented only for Nc==3"); } /*! Default constructor. rho is constant in all directions, optionally except for orthogonal dimension */ Smear_Stout(double rho = 1.0, int orthogdim = -1) : OrthogDim{orthogdim}, SmearRho{ rho3D(rho,orthogdim) }, OwnedBase{ new Smear_APE(SmearRho) }, SmearBase{OwnedBase.get()} { - assert(Nc == 3 && "Stout smearing currently implemented only for Nc==3"); + GRID_ASSERT(Nc == 3 && "Stout smearing currently implemented only for Nc==3"); } ~Smear_Stout() {} // delete SmearBase... diff --git a/Grid/qcd/smearing/WilsonFlow.h b/Grid/qcd/smearing/WilsonFlow.h index 188c6973..70b77da9 100644 --- a/Grid/qcd/smearing/WilsonFlow.h +++ b/Grid/qcd/smearing/WilsonFlow.h @@ -37,21 +37,32 @@ class WilsonFlowBase: public Smear{ public: //Store generic measurements to take during smearing process using std::function typedef std::function FunctionType; //int: step, RealD: flow time, GaugeField : the gauge field + + INHERIT_GIMPL_TYPES(Gimpl); + + typedef Action ActionBase; protected: + std::vector< std::pair > functions; //The int maps to the measurement frequency - mutable WilsonGaugeAction SG; - -public: - INHERIT_GIMPL_TYPES(Gimpl) + + ActionBase *SG; - explicit WilsonFlowBase(unsigned int meas_interval =1): - SG(WilsonGaugeAction(3.0)) { +public: + + explicit WilsonFlowBase(unsigned int meas_interval =1) { + + SG = (ActionBase *) new WilsonGaugeAction(3.0); // WilsonGaugeAction with beta 3.0 setDefaultMeasurements(meas_interval); } - + + void setGaugeAction(ActionBase *TheAction) + { + SG = TheAction; + } + void resetActions(){ functions.clear(); } void addMeasurement(int meas_interval, FunctionType meas){ functions.push_back({meas_interval, meas}); } @@ -63,7 +74,7 @@ public: void setDefaultMeasurements(int topq_meas_interval = 1); void derivative(GaugeField&, const GaugeField&, const GaugeField&) const override{ - assert(0); + GRID_ASSERT(0); // undefined for WilsonFlow } @@ -150,7 +161,7 @@ RealD WilsonFlowBase::energyDensityCloverleaf(const RealD t, const GaugeF typedef typename Gimpl::GaugeLinkField GaugeMat; typedef typename Gimpl::GaugeField GaugeLorentz; - assert(Nd == 4); + GRID_ASSERT(Nd == 4); //E = 1/2 tr( F_munu F_munu ) //However as F_numu = -F_munu, only need to sum the trace of the squares of the following 6 field strengths: //F_01 F_02 F_03 F_12 F_13 F_23 @@ -225,17 +236,17 @@ template void WilsonFlow::evolve_step(typename Gimpl::GaugeField &U, RealD &tau) const{ GaugeField Z(U.Grid()); GaugeField tmp(U.Grid()); - this->SG.deriv(U, Z); + this->SG->deriv(U, Z); Z *= 0.25; // Z0 = 1/4 * F(U) Gimpl::update_field(Z, U, -2.0*epsilon); // U = W1 = exp(ep*Z0)*W0 Z *= -17.0/8.0; - this->SG.deriv(U, tmp); Z += tmp; // -17/32*Z0 +Z1 + this->SG->deriv(U, tmp); Z += tmp; // -17/32*Z0 +Z1 Z *= 8.0/9.0; // Z = -17/36*Z0 +8/9*Z1 Gimpl::update_field(Z, U, -2.0*epsilon); // U_= W2 = exp(ep*Z)*W1 Z *= -4.0/3.0; - this->SG.deriv(U, tmp); Z += tmp; // 4/3*(17/36*Z0 -8/9*Z1) +Z2 + this->SG->deriv(U, tmp); Z += tmp; // 4/3*(17/36*Z0 -8/9*Z1) +Z2 Z *= 3.0/4.0; // Z = 17/36*Z0 -8/9*Z1 +3/4*Z2 Gimpl::update_field(Z, U, -2.0*epsilon); // V(t+e) = exp(ep*Z)*W2 tau += epsilon; @@ -285,20 +296,20 @@ int WilsonFlowAdaptive::evolve_step_adaptive(typename Gimpl::GaugeField & Uprime = U; Usave = U; - this->SG.deriv(U, Z); + this->SG->deriv(U, Z); Zprime = -Z; Z *= 0.25; // Z0 = 1/4 * F(U) Gimpl::update_field(Z, U, -2.0*eps); // U = W1 = exp(ep*Z0)*W0 Z *= -17.0/8.0; - this->SG.deriv(U, tmp); Z += tmp; // -17/32*Z0 +Z1 + this->SG->deriv(U, tmp); Z += tmp; // -17/32*Z0 +Z1 Zprime += 2.0*tmp; Z *= 8.0/9.0; // Z = -17/36*Z0 +8/9*Z1 Gimpl::update_field(Z, U, -2.0*eps); // U_= W2 = exp(ep*Z)*W1 Z *= -4.0/3.0; - this->SG.deriv(U, tmp); Z += tmp; // 4/3*(17/36*Z0 -8/9*Z1) +Z2 + this->SG->deriv(U, tmp); Z += tmp; // 4/3*(17/36*Z0 -8/9*Z1) +Z2 Z *= 3.0/4.0; // Z = 17/36*Z0 -8/9*Z1 +3/4*Z2 Gimpl::update_field(Z, U, -2.0*eps); // V(t+e) = exp(ep*Z)*W2 diff --git a/Grid/qcd/utils/A2Autils.h b/Grid/qcd/utils/A2Autils.h index 7089fd1b..ed6023ce 100644 --- a/Grid/qcd/utils/A2Autils.h +++ b/Grid/qcd/utils/A2Autils.h @@ -156,8 +156,8 @@ void A2Autils::MesonField(TensorType &mat, int Lblock = mat.dimension(3); int Rblock = mat.dimension(4); - // assert(Lblock % block==0); - // assert(Rblock % block==0); + // GRID_ASSERT(Lblock % block==0); + // GRID_ASSERT(Rblock % block==0); GridBase *grid = lhs_wi[0].Grid(); @@ -170,7 +170,15 @@ void A2Autils::MesonField(TensorType &mat, LatticeVecSpinMatrix SpinMat(grid); LatticeVecSpinMatrix MomSpinMat(grid); - + + std::cout < MP; + std::cout < sliced; for(int i=0;i::MesonField(TensorType &mat, }// j within block // After getting the sitewise product do the mom phase loop +#if 1 + std::cout <(sliced[idx],jj); + for(int mu=0;mu::MesonField(TensorType &mat, } } } +#endif }//jo } } @@ -253,10 +281,10 @@ void A2Autils::AslashField(TensorType &mat, int Rblock = mat.dimension(4); int Nem = emB0.size(); - assert(emB1.size() == Nem); + GRID_ASSERT(emB1.size() == Nem); - // assert(Lblock % block==0); - // assert(Rblock % block==0); + // GRID_ASSERT(Lblock % block==0); + // GRID_ASSERT(Rblock % block==0); GridBase *grid = lhs_wi[0].Grid(); @@ -453,9 +481,9 @@ void A2Autils::MesonField(TensorType &mat, }}} } if (t_kernel) *t_kernel += usecond(); - assert(mat.dimension(0) == Nmom); - assert(mat.dimension(1) == Ngamma); - assert(mat.dimension(2) == Nt); + GRID_ASSERT(mat.dimension(0) == Nmom); + GRID_ASSERT(mat.dimension(1) == Ngamma); + GRID_ASSERT(mat.dimension(2) == Nt); // ld loop and local only?? int pd = grid->_processors[orthogdim]; @@ -529,7 +557,7 @@ void A2Autils::AslashField(TensorType &mat, int Nt = grid->GlobalDimensions()[orthogdim]; int Nem = emB0.size(); - assert(emB1.size() == Nem); + GRID_ASSERT(emB1.size() == Nem); int fd=grid->_fdimensions[orthogdim]; int ld=grid->_ldimensions[orthogdim]; @@ -956,7 +984,7 @@ void A2Autils::ContractFourQuarkColourDiagonal(const PropagatorField &WWV ComplexField &O_trtr, ComplexField &O_fig8) { - assert(gamma0.size()==gamma1.size()); + GRID_ASSERT(gamma0.size()==gamma1.size()); int Ng = gamma0.size(); GridBase *grid = WWVV0.Grid(); @@ -1000,7 +1028,7 @@ void A2Autils::ContractFourQuarkColourMix(const PropagatorField &WWVV0, ComplexField &O_trtr, ComplexField &O_fig8) { - assert(gamma0.size()==gamma1.size()); + GRID_ASSERT(gamma0.size()==gamma1.size()); int Ng = gamma0.size(); GridBase *grid = WWVV0.Grid(); @@ -1119,7 +1147,7 @@ void A2Autils::DeltaFeq2(int dt_min,int dt_max, int N_s = WW_sd.dimension(1); int N_d = WW_sd.dimension(2); - assert(grid->GlobalDimensions()[orthogdim] == N_t); + GRID_ASSERT(grid->GlobalDimensions()[orthogdim] == N_t); double vol = 1.0; for(int dim=0;dimGlobalDimensions()[dim]; @@ -1472,9 +1500,9 @@ void A2Autils::MesonField(TensorType &mat, }}} } if (t_kernel) *t_kernel += usecond(); - assert(mat.dimension(0) == Nmom); - assert(mat.dimension(1) == Ngamma); - assert(mat.dimension(2) == Nt); + GRID_ASSERT(mat.dimension(0) == Nmom); + GRID_ASSERT(mat.dimension(1) == Ngamma); + GRID_ASSERT(mat.dimension(2) == Nt); // ld loop and local only?? int pd = grid->_processors[orthogdim]; @@ -1637,7 +1665,7 @@ void A2Autils::PionFieldXX(Eigen::Tensor &mat, }} }); - assert(mat.dimension(0) == Nt); + GRID_ASSERT(mat.dimension(0) == Nt); // ld loop and local only?? int pd = grid->_processors[orthogdim]; int pc = grid->_processor_coor[orthogdim]; @@ -1785,8 +1813,8 @@ void A2Autils::PionFieldWVmom(Eigen::Tensor &mat, }}} }); - assert(mat.dimension(0) == Nmom); - assert(mat.dimension(1) == Nt); + GRID_ASSERT(mat.dimension(0) == Nmom); + GRID_ASSERT(mat.dimension(1) == Nt); int pd = grid->_processors[orthogdim]; int pc = grid->_processor_coor[orthogdim]; diff --git a/Grid/qcd/utils/BaryonUtils.h b/Grid/qcd/utils/BaryonUtils.h index 9a1d312b..a89d77be 100644 --- a/Grid/qcd/utils/BaryonUtils.h +++ b/Grid/qcd/utils/BaryonUtils.h @@ -508,7 +508,7 @@ void BaryonUtils::BaryonSiteMatrix(const mobj &D1, * The array wick_contractions must be of length 6 */ template void BaryonUtils::WickContractions(std::string qi, std::string qf, int &wick_contractions) { - assert(qi.size() == 3 && qf.size() == 3 && "Only sets of 3 quarks accepted."); + GRID_ASSERT(qi.size() == 3 && qf.size() == 3 && "Only sets of 3 quarks accepted."); const int epsilon[6][3] = {{0,1,2},{1,2,0},{2,0,1},{0,2,1},{2,1,0},{1,0,2}}; wick_contractions=0; for (int ie=0; ie < 6 ; ie++) { @@ -536,10 +536,10 @@ void BaryonUtils::ContractBaryons(const PropagatorField &q1_left, ComplexField &baryon_corr) { - assert(Ns==4 && "Baryon code only implemented for N_spin = 4"); - assert(Nc==3 && "Baryon code only implemented for N_colour = 3"); + GRID_ASSERT(Ns==4 && "Baryon code only implemented for N_spin = 4"); + GRID_ASSERT(Nc==3 && "Baryon code only implemented for N_colour = 3"); - assert(parity==1 || parity == -1 && "Parity must be +1 or -1"); + GRID_ASSERT(parity==1 || parity == -1 && "Parity must be +1 or -1"); GridBase *grid = q1_left.Grid(); @@ -587,8 +587,8 @@ void BaryonUtils::ContractBaryonsMatrix(const PropagatorField &q1_left, SpinMatrixField &baryon_corr) { - assert(Ns==4 && "Baryon code only implemented for N_spin = 4"); - assert(Nc==3 && "Baryon code only implemented for N_colour = 3"); + GRID_ASSERT(Ns==4 && "Baryon code only implemented for N_spin = 4"); + GRID_ASSERT(Nc==3 && "Baryon code only implemented for N_colour = 3"); GridBase *grid = q1_left.Grid(); @@ -628,10 +628,10 @@ void BaryonUtils::ContractBaryonsSliced(const mobj &D1, robj &result) { - assert(Ns==4 && "Baryon code only implemented for N_spin = 4"); - assert(Nc==3 && "Baryon code only implemented for N_colour = 3"); + GRID_ASSERT(Ns==4 && "Baryon code only implemented for N_spin = 4"); + GRID_ASSERT(Nc==3 && "Baryon code only implemented for N_colour = 3"); - assert(parity==1 || parity == -1 && "Parity must be +1 or -1"); + GRID_ASSERT(parity==1 || parity == -1 && "Parity must be +1 or -1"); for (int t=0; t::ContractBaryonsSlicedMatrix(const mobj &D1, robj &result) { - assert(Ns==4 && "Baryon code only implemented for N_spin = 4"); - assert(Nc==3 && "Baryon code only implemented for N_colour = 3"); + GRID_ASSERT(Ns==4 && "Baryon code only implemented for N_spin = 4"); + GRID_ASSERT(Nc==3 && "Baryon code only implemented for N_colour = 3"); for (int t=0; t::BaryonGamma3pt( const Gamma GammaBf, SpinMatrixField &stn_corr) { - assert(Ns==4 && "Baryon code only implemented for N_spin = 4"); - assert(Nc==3 && "Baryon code only implemented for N_colour = 3"); + GRID_ASSERT(Ns==4 && "Baryon code only implemented for N_spin = 4"); + GRID_ASSERT(Nc==3 && "Baryon code only implemented for N_colour = 3"); GridBase *grid = q_tf.Grid(); @@ -1292,8 +1292,8 @@ void BaryonUtils::SigmaToNucleonEye(const PropagatorField &qq_loop, SpinMatrixField &stn_corr) { - assert(Ns==4 && "Baryon code only implemented for N_spin = 4"); - assert(Nc==3 && "Baryon code only implemented for N_colour = 3"); + GRID_ASSERT(Ns==4 && "Baryon code only implemented for N_spin = 4"); + GRID_ASSERT(Nc==3 && "Baryon code only implemented for N_colour = 3"); GridBase *grid = qs_ti.Grid(); @@ -1327,7 +1327,7 @@ void BaryonUtils::SigmaToNucleonEye(const PropagatorField &qq_loop, coalescedWrite(vcorr[ss],result); });//end loop over lattice sites } else { - assert(0 && "Weak Operator not correctly specified"); + GRID_ASSERT(0 && "Weak Operator not correctly specified"); } } @@ -1345,8 +1345,8 @@ void BaryonUtils::SigmaToNucleonNonEye(const PropagatorField &qq_ti, SpinMatrixField &stn_corr) { - assert(Ns==4 && "Baryon code only implemented for N_spin = 4"); - assert(Nc==3 && "Baryon code only implemented for N_colour = 3"); + GRID_ASSERT(Ns==4 && "Baryon code only implemented for N_spin = 4"); + GRID_ASSERT(Nc==3 && "Baryon code only implemented for N_colour = 3"); GridBase *grid = qs_ti.Grid(); @@ -1383,7 +1383,7 @@ void BaryonUtils::SigmaToNucleonNonEye(const PropagatorField &qq_ti, coalescedWrite(vcorr[ss],result); });//end loop over lattice sites } else { - assert(0 && "Weak Operator not correctly specified"); + GRID_ASSERT(0 && "Weak Operator not correctly specified"); } } @@ -1538,8 +1538,8 @@ void BaryonUtils::XiToSigmaEye(const PropagatorField &qq_loop, SpinMatrixField &xts_corr) { - assert(Ns==4 && "Baryon code only implemented for N_spin = 4"); - assert(Nc==3 && "Baryon code only implemented for N_colour = 3"); + GRID_ASSERT(Ns==4 && "Baryon code only implemented for N_spin = 4"); + GRID_ASSERT(Nc==3 && "Baryon code only implemented for N_colour = 3"); GridBase *grid = qs_ti.Grid(); @@ -1574,7 +1574,7 @@ void BaryonUtils::XiToSigmaEye(const PropagatorField &qq_loop, coalescedWrite(vcorr[ss],result); } );//end loop over lattice sites } else { - assert(0 && "Weak Operator not correctly specified"); + GRID_ASSERT(0 && "Weak Operator not correctly specified"); } } diff --git a/Grid/qcd/utils/CovariantCshift.h b/Grid/qcd/utils/CovariantCshift.h index 583c0f2b..2583ece5 100644 --- a/Grid/qcd/utils/CovariantCshift.h +++ b/Grid/qcd/utils/CovariantCshift.h @@ -242,7 +242,7 @@ namespace ConjugateBC { { GridBase *grid = Link.Grid(); int Lmu = grid->GlobalDimensions()[mu]; - assert(abs(shift) < Lmu && "Invalid shift value"); + GRID_ASSERT(abs(shift) < Lmu && "Invalid shift value"); Lattice> coor(grid); LatticeCoordinate(coor, mu); diff --git a/Grid/qcd/utils/CovariantLaplacian.h b/Grid/qcd/utils/CovariantLaplacian.h index 94322507..e377b791 100644 --- a/Grid/qcd/utils/CovariantLaplacian.h +++ b/Grid/qcd/utils/CovariantLaplacian.h @@ -91,9 +91,9 @@ public: }; - void Mdir(const GaugeField&, GaugeField&, int, int){ assert(0);} - void MdirAll(const GaugeField&, std::vector &){ assert(0);} - void Mdiag(const GaugeField&, GaugeField&){ assert(0);} + void Mdir(const GaugeField&, GaugeField&, int, int){ GRID_ASSERT(0);} + void MdirAll(const GaugeField&, std::vector &){ GRID_ASSERT(0);} + void Mdiag(const GaugeField&, GaugeField&){ GRID_ASSERT(0);} void ImportGauge(const GaugeField& _U) { for (int mu = 0; mu < Nd; mu++) { diff --git a/Grid/qcd/utils/GaugeFix.h b/Grid/qcd/utils/GaugeFix.h index fc723fe3..95c4dd48 100644 --- a/Grid/qcd/utils/GaugeFix.h +++ b/Grid/qcd/utils/GaugeFix.h @@ -142,7 +142,7 @@ public: } std::cout << GridLogError << "Gauge fixing did not converge in " << maxiter << " iterations." << std::endl; if (err_on_no_converge) - assert(0 && "Gauge fixing did not converge within the specified number of iterations"); + GRID_ASSERT(0 && "Gauge fixing did not converge within the specified number of iterations"); }; static Real SteepestDescentStep(std::vector &U,GaugeMat &xform, Real alpha, GaugeMat & dmuAmu,int orthog) { GridBase *grid = U[0].Grid(); diff --git a/Grid/qcd/utils/GaugeGroupTwoIndex.h b/Grid/qcd/utils/GaugeGroupTwoIndex.h index 85685ddb..60d10299 100644 --- a/Grid/qcd/utils/GaugeGroupTwoIndex.h +++ b/Grid/qcd/utils/GaugeGroupTwoIndex.h @@ -165,7 +165,7 @@ public: template static void base(int Index, iGroupMatrix &eij) { // returns (e)^(ij)_{kl} necessary for change of base U_F -> U_R - assert(Index < Dimension); + GRID_ASSERT(Index < Dimension); eij = Zero(); // for the linearisation of the 2 indexes static int a[ncolour * (ncolour - 1) / 2][2]; // store the a <-> i,j @@ -243,7 +243,7 @@ public: for (int a = 0; a < NumGenerators; a++) { generator(a, i2indTa); std::cout << GridLogMessage << a << std::endl; - assert(norm2(trace(i2indTa)) < 1.0e-6); + GRID_ASSERT(norm2(trace(i2indTa)) < 1.0e-6); } std::cout << GridLogMessage << std::endl; @@ -252,7 +252,7 @@ public: for (int a = 0; a < NumGenerators; a++) { generator(a, i2indTa); std::cout << GridLogMessage << a << std::endl; - assert(norm2(adj(i2indTa) + i2indTa) < 1.0e-6); + GRID_ASSERT(norm2(adj(i2indTa) + i2indTa) < 1.0e-6); } std::cout << GridLogMessage << std::endl; @@ -269,11 +269,11 @@ public: std::cout << GridLogMessage << "a=" << a << "b=" << b << "Tr=" << Tr << std::endl; if (a == b) { - assert(real(Tr) - ((ncolour + S * 2) * 0.5) < 1e-8); + GRID_ASSERT(real(Tr) - ((ncolour + S * 2) * 0.5) < 1e-8); } else { - assert(real(Tr) < 1e-8); + GRID_ASSERT(real(Tr) < 1e-8); } - assert(imag(Tr) < 1e-8); + GRID_ASSERT(imag(Tr) < 1e-8); } } std::cout << GridLogMessage << std::endl; diff --git a/Grid/qcd/utils/SUn.impl.h b/Grid/qcd/utils/SUn.impl.h index d049fcd0..3ca3a9a6 100644 --- a/Grid/qcd/utils/SUn.impl.h +++ b/Grid/qcd/utils/SUn.impl.h @@ -119,7 +119,7 @@ static void generatorDiagonal(int diagIndex, iGroupMatrix &ta) { // Map a su2 subgroup number to the pair of rows that are non zero //////////////////////////////////////////////////////////////////////// static accelerator_inline void su2SubGroupIndex(int &i1, int &i2, int su2_index, GroupName::SU) { - assert((su2_index >= 0) && (su2_index < (ncolour * (ncolour - 1)) / 2)); + GRID_ASSERT((su2_index >= 0) && (su2_index < (ncolour * (ncolour - 1)) / 2)); int spare = su2_index; for (i1 = 0; spare >= (ncolour - 1 - i1); i1++) { @@ -313,7 +313,7 @@ static void SubGroupHeatBath( // Debug test for sanity uinv = adj(u); b = u * uinv - 1.0; - assert(norm2(b) < 1.0e-4); + GRID_ASSERT(norm2(b) < 1.0e-4); /* Measure: Haar measure dh has d^4a delta(1-|a^2|) @@ -452,22 +452,22 @@ static void SubGroupHeatBath( u = Zero(); check = ua * adj(ua) - 1.0; check = where(Accepted, check, u); - assert(norm2(check) < 1.0e-4); + GRID_ASSERT(norm2(check) < 1.0e-4); check = b * adj(b) - 1.0; check = where(Accepted, check, u); - assert(norm2(check) < 1.0e-4); + GRID_ASSERT(norm2(check) < 1.0e-4); LatticeMatrix Vcheck(grid); Vcheck = Zero(); Vcheck = where(Accepted, V * adj(V) - 1.0, Vcheck); // std::cout< &ta) { template static accelerator_inline void su2SubGroupIndex(int &i1, int &i2, int su2_index, GroupName::Sp) { const int nsp=ncolour/2; - assert((su2_index >= 0) && (su2_index < (nsp * (nsp - 1)) / 2)); + GRID_ASSERT((su2_index >= 0) && (su2_index < (nsp * (nsp - 1)) / 2)); int spare = su2_index; for (i1 = 0; spare >= (nsp - 1 - i1); i1++) { @@ -231,8 +231,8 @@ static void testGenerators(GroupName::Sp) { Complex tr = TensorRemove(trace(ta * tb)); std::cout << GridLogMessage << "(" << a << "," << b << ") = " << tr << std::endl; - if (a == b) assert(abs(tr - Complex(0.5)) < 1.0e-6); - if (a != b) assert(abs(tr) < 1.0e-6); + if (a == b) GRID_ASSERT(abs(tr - Complex(0.5)) < 1.0e-6); + if (a != b) GRID_ASSERT(abs(tr) < 1.0e-6); } } std::cout << GridLogMessage << std::endl; @@ -241,7 +241,7 @@ static void testGenerators(GroupName::Sp) { for (int a = 0; a < AlgebraDimension; a++) { generator(a, ta); std::cout << GridLogMessage << a << std::endl; - assert(norm2(ta - adj(ta)) < 1.0e-6); + GRID_ASSERT(norm2(ta - adj(ta)) < 1.0e-6); } std::cout << GridLogMessage << std::endl; std::cout << GridLogMessage << "Fundamental - Checking if traceless" @@ -250,7 +250,7 @@ static void testGenerators(GroupName::Sp) { generator(a, ta); Complex tr = TensorRemove(trace(ta)); std::cout << GridLogMessage << a << std::endl; - assert(abs(tr) < 1.0e-6); + GRID_ASSERT(abs(tr) < 1.0e-6); } } diff --git a/Grid/qcd/utils/WilsonLoops.h b/Grid/qcd/utils/WilsonLoops.h index 7466f4bf..23ad237c 100644 --- a/Grid/qcd/utils/WilsonLoops.h +++ b/Grid/qcd/utils/WilsonLoops.h @@ -168,7 +168,7 @@ public: static std::vector timesliceAvgSpatialPlaquette(const GaugeLorentz &Umu) { std::vector sumplaq = timesliceSumSpatialPlaquette(Umu); int Lt = Umu.Grid()->FullDimensions()[Nd-1]; - assert(sumplaq.size() == Lt); + GRID_ASSERT(sumplaq.size() == Lt); double vol = Umu.Grid()->gSites() / Lt; double faces = (1.0 * (Nd - 1)* (Nd - 2)) / 2.0; for(int t=0;t &staple, const std::vector &U) { - assert(staple.size() == Nd); assert(U.size() == Nd); + GRID_ASSERT(staple.size() == Nd); GRID_ASSERT(U.size() == Nd); for(int mu=0;mu= this->paddingDepth()); + GRID_ASSERT(pcell.depth >= this->paddingDepth()); if(!stencil || stencil->Grid() != (GridBase*)pcell.grids.back() ) generateStencil((GridBase*)pcell.grids.back()); return *stencil; } @@ -391,7 +391,7 @@ public: std::unique_ptr pcell; void generatePcell(GridBase* unpadded_grid){ - assert(stencil_wk.size()); + GRID_ASSERT(stencil_wk.size()); int max_depth = 0; for(auto const &s : stencil_wk) max_depth=std::max(max_depth, s->paddingDepth()); @@ -402,7 +402,7 @@ public: //Add a stencil definition. This should be done before the first call to retrieve a stencil object. //Takes ownership of the pointer void addStencil(WilsonLoopPaddedStencilWorkspace *stencil){ - assert(!pcell); + GRID_ASSERT(!pcell); stencil_wk.push_back(stencil); } @@ -469,9 +469,9 @@ public: static void StaplePaddedAll(std::vector &staple, const std::vector &U_padded, const PaddedCell &Cell, const GeneralLocalStencil &gStencil) { double t0 = usecond(); - assert(U_padded.size() == Nd); assert(staple.size() == Nd); - assert(U_padded[0].Grid() == (GridBase*)Cell.grids.back()); - assert(Cell.depth >= 1); + GRID_ASSERT(U_padded.size() == Nd); GRID_ASSERT(staple.size() == Nd); + GRID_ASSERT(U_padded[0].Grid() == (GridBase*)Cell.grids.back()); + GRID_ASSERT(Cell.depth >= 1); GridBase *ggrid = U_padded[0].Grid(); //padded cell grid int shift_mu_off = gStencil._npoints/Nd; @@ -622,7 +622,7 @@ public: static Real TopologicalCharge(const GaugeLorentz &U){ // 4d topological charge - assert(Nd==4); + GRID_ASSERT(Nd==4); // Bx = -iF(y,z), By = -iF(z,y), Bz = -iF(x,y) GaugeMat Bx(U.Grid()), By(U.Grid()), Bz(U.Grid()); FieldStrength(Bx, U, Ydir, Zdir); @@ -740,7 +740,7 @@ public: //cf https://arxiv.org/pdf/hep-lat/9701012.pdf Eq 6 //output is the charge by timeslice: sum over timeslices to obtain the total static std::vector TimesliceTopologicalChargeMxN(const GaugeLorentz &U, int M, int N){ - assert(Nd == 4); + GRID_ASSERT(Nd == 4); std::vector > F(Nd,std::vector(Nd,nullptr)); //Note F_numu = - F_munu //hence we only need to loop over mu,nu,rho,sigma that aren't related by permuting mu,nu or rho,sigma @@ -1095,7 +1095,7 @@ public: //U: Gauge links in each direction (Nd) ///////////////////////////////////////////////////// static void RectStapleAll(std::vector &Stap, const std::vector &U){ - assert(Stap.size() == Nd); assert(U.size() == Nd); + GRID_ASSERT(Stap.size() == Nd); GRID_ASSERT(U.size() == Nd); std::vector U2(Nd,U[0].Grid()); for(int mu=0;mu &staple, const std::vector &U_padded, const PaddedCell &Cell, const GeneralLocalStencil &gStencil) { double t0 = usecond(); - assert(U_padded.size() == Nd); assert(staple.size() == Nd); - assert(U_padded[0].Grid() == (GridBase*)Cell.grids.back()); - assert(Cell.depth >= 2); + GRID_ASSERT(U_padded.size() == Nd); GRID_ASSERT(staple.size() == Nd); + GRID_ASSERT(U_padded[0].Grid() == (GridBase*)Cell.grids.back()); + GRID_ASSERT(Cell.depth >= 2); GridBase *ggrid = U_padded[0].Grid(); //padded cell grid size_t nshift = gStencil._npoints; diff --git a/Grid/serialisation/BaseIO.h b/Grid/serialisation/BaseIO.h index 25481301..45f91b1d 100644 --- a/Grid/serialisation/BaseIO.h +++ b/Grid/serialisation/BaseIO.h @@ -307,14 +307,14 @@ namespace Grid { constexpr unsigned int ContainerRank{Traits::Rank}; // Only non-zero for containers constexpr unsigned int TotalRank{TensorRank + ContainerRank}; const Index NumElements{output.size()}; - assert( NumElements > 0 ); + GRID_ASSERT( NumElements > 0 ); // Get the dimensionality of the tensor std::vector TotalDims(TotalRank); for(auto i = 0; i < TensorRank; i++ ) { auto dim = output.dimension(i); TotalDims[i] = static_cast(dim); - assert( TotalDims[i] == dim ); // check we didn't lose anything in the conversion + GRID_ASSERT( TotalDims[i] == dim ); // check we didn't lose anything in the conversion } for(auto i = 0; i < ContainerRank; i++ ) TotalDims[TensorRank + i] = Traits::Dimension(i); @@ -452,7 +452,7 @@ namespace Grid { std::vector dimData; std::vector buf; upcast->readMultiDim( s, buf, dimData ); - assert(dimData.size() == TotalRank && "EigenIO: Tensor rank mismatch" ); + GRID_ASSERT(dimData.size() == TotalRank && "EigenIO: Tensor rank mismatch" ); // Make sure that the number of elements read matches dimensions read std::size_t NumContainers = 1; for( auto i = 0 ; i < TensorRank ; i++ ) @@ -460,10 +460,10 @@ namespace Grid { // If our scalar object is a Container, make sure it's dimensions match what we read back std::size_t ElementsPerContainer = 1; for( auto i = 0 ; i < ContainerRank ; i++ ) { - assert( dimData[TensorRank+i] == Traits::Dimension(i) && "Tensor Container dimensions don't match data" ); + GRID_ASSERT( dimData[TensorRank+i] == Traits::Dimension(i) && "Tensor Container dimensions don't match data" ); ElementsPerContainer *= dimData[TensorRank+i]; } - assert( NumContainers * ElementsPerContainer == buf.size() && "EigenIO: Number of elements != product of dimensions" ); + GRID_ASSERT( NumContainers * ElementsPerContainer == buf.size() && "EigenIO: Number of elements != product of dimensions" ); // Now see whether the tensor is the right shape, or can be made to be const auto & dims = output.dimensions(); bool bShapeOK = (output.data() != nullptr); @@ -487,7 +487,7 @@ namespace Grid { for( int i = TensorRank - 1; i != -1 && ++MyIndex[i] == dims[i]; i-- ) MyIndex[i] = 0; } - assert( pSource == &buf[NumContainers * ElementsPerContainer] ); + GRID_ASSERT( pSource == &buf[NumContainers * ElementsPerContainer] ); } template @@ -495,7 +495,7 @@ namespace Grid { typename std::enable_if::value, void>::type Reader::Reshape(ETensor &t, const std::array &dims ) { - assert( 0 && "EigenIO: Fixed tensor dimensions can't be changed" ); + GRID_ASSERT( 0 && "EigenIO: Fixed tensor dimensions can't be changed" ); } template @@ -505,7 +505,7 @@ namespace Grid { { #ifdef GRID_OMP // The memory counter is the reason this must be done from the primary thread - assert(omp_in_parallel()==0 && "Deserialisation which resizes Eigen tensor must happen from primary thread"); + GRID_ASSERT(omp_in_parallel()==0 && "Deserialisation which resizes Eigen tensor must happen from primary thread"); #endif EigenIO::EigenResizeCounter -= static_cast(t.size()) * sizeof(typename ETensor::Scalar); //t.reshape( dims ); @@ -561,7 +561,7 @@ namespace Grid { template static inline typename std::enable_if::value && EigenIO::is_tensor::value, bool>::type CompareMember(const T1 &lhs, const T2 &rhs) { - // First check whether dimensions match (Eigen tensor library will assert if they don't match) + // First check whether dimensions match (Eigen tensor library will GRID_ASSERT if they don't match) bool bReturnValue = (T1::NumIndices == T2::NumIndices); for( auto i = 0 ; bReturnValue && i < T1::NumIndices ; i++ ) bReturnValue = ( lhs.dimension(i) == rhs.dimension(i) ); @@ -593,7 +593,7 @@ namespace Grid { WriteMember(std::ostream &os, const T &object) { using Index = typename T::Index; const Index NumElements{object.size()}; - assert( NumElements > 0 ); + GRID_ASSERT( NumElements > 0 ); Index count = 1; os << "T<"; for( int i = 0; i < T::NumIndices; i++ ) { @@ -603,7 +603,7 @@ namespace Grid { os << ","; os << dim; } - assert( count == NumElements && "Number of elements doesn't match tensor dimensions" ); + GRID_ASSERT( count == NumElements && "Number of elements doesn't match tensor dimensions" ); os << ">{"; const typename T::Scalar * p = object.data(); for( Index i = 0; i < count; i++ ) { diff --git a/Grid/serialisation/BinaryIO.h b/Grid/serialisation/BinaryIO.h index 9ba34c16..afb23640 100644 --- a/Grid/serialisation/BinaryIO.h +++ b/Grid/serialisation/BinaryIO.h @@ -103,7 +103,7 @@ NAMESPACE_BEGIN(Grid); uint64_t tmp = 1; for( auto i = 0 ; i < rank ; i++ ) tmp *= Dimensions[i]; - assert( tmp == NumElements && "Dimensions don't match size of data being written" ); + GRID_ASSERT( tmp == NumElements && "Dimensions don't match size of data being written" ); // Total number of elements write("", tmp); // Number of dimensions @@ -158,7 +158,7 @@ NAMESPACE_BEGIN(Grid); dim[i] = tmp; count *= tmp; } - assert( count == NumElements && "Dimensions don't match size of data being read" ); + GRID_ASSERT( count == NumElements && "Dimensions don't match size of data being read" ); buf.resize(count); for( auto i = 0; i < count; ++i) read("", buf[i]); diff --git a/Grid/serialisation/Hdf5IO.h b/Grid/serialisation/Hdf5IO.h index ae5e740b..13a49f9e 100644 --- a/Grid/serialisation/Hdf5IO.h +++ b/Grid/serialisation/Hdf5IO.h @@ -174,7 +174,7 @@ namespace Grid // Now make sure overall size is not too big hsize_t OverflowCheck = ElementsPerChunk; ElementsPerChunk *= d; - assert( OverflowCheck == ElementsPerChunk / d && "Product of dimensions overflowed hsize_t" ); + GRID_ASSERT( OverflowCheck == ElementsPerChunk / d && "Product of dimensions overflowed hsize_t" ); // If product of dimensions too big, reduce by prime factors while( ElementsPerChunk > MaxElements && ( ElementsPerChunk & 1 ) == 0 ) { bTooBig = true; diff --git a/Grid/serialisation/VectorUtils.h b/Grid/serialisation/VectorUtils.h index 8f490c64..72156bc8 100644 --- a/Grid/serialisation/VectorUtils.h +++ b/Grid/serialisation/VectorUtils.h @@ -447,9 +447,9 @@ namespace Grid { using Traits = GridTypeMapper::grid_type>; const int gridRank{Traits::Rank}; const int dimRank{static_cast(dim_.size())}; - assert(dimRank >= gridRank && "Tensor rank too low for Grid tensor"); + GRID_ASSERT(dimRank >= gridRank && "Tensor rank too low for Grid tensor"); for (int i=0; i::vecRank && "Tensor rank doesn't match nested std::vector rank"); + GRID_ASSERT(dim_.size() == is_flattenable::vecRank && "Tensor rank doesn't match nested std::vector rank"); resize(vector_, 0); fill(vector_); } @@ -512,14 +512,14 @@ namespace Grid { { if( bFirst) { - assert( Dims.size() == Depth && "Bug: Delete this message after testing" ); + GRID_ASSERT( Dims.size() == Depth && "Bug: Delete this message after testing" ); Dims.push_back(v[0].size()); if (!Dims[Depth]) return false; } else { - assert( Dims.size() >= Depth + 1 && "Bug: Delete this message after testing" ); + GRID_ASSERT( Dims.size() >= Depth + 1 && "Bug: Delete this message after testing" ); } for (std::size_t i = 0; i < v.size(); ++i) { diff --git a/Grid/serialisation/XmlIO.h b/Grid/serialisation/XmlIO.h index cb9a49e7..2b568421 100644 --- a/Grid/serialisation/XmlIO.h +++ b/Grid/serialisation/XmlIO.h @@ -145,7 +145,7 @@ namespace Grid write("dim", d); count *= d; } - assert( count == NumElements && "XmlIO : element count doesn't match dimensions" ); + GRID_ASSERT( count == NumElements && "XmlIO : element count doesn't match dimensions" ); static const char sName[] = "tensor"; for( int i = 0 ; i < Rank ; i++ ) { MyIndex[i] = 0; diff --git a/Grid/stencil/GeneralLocalStencil.h b/Grid/stencil/GeneralLocalStencil.h index 66d25bc4..f8461e33 100644 --- a/Grid/stencil/GeneralLocalStencil.h +++ b/Grid/stencil/GeneralLocalStencil.h @@ -114,7 +114,7 @@ public: int ld = grid->_ldimensions[d]; int ly = grid->_simd_layout[d]; - assert((ly==1)||(ly==2)||(ly==grid->Nsimd())); + GRID_ASSERT((ly==1)||(ly==2)||(ly==grid->Nsimd())); int shift = (shifts[ii][d]+fd)%fd; // make it strictly positive 0.. L-1 int x = Coor[d]; // x in [0... rd-1] as an oSite diff --git a/Grid/stencil/SimpleCompressor.h b/Grid/stencil/SimpleCompressor.h index eca9cd3c..41c1fbe1 100644 --- a/Grid/stencil/SimpleCompressor.h +++ b/Grid/stencil/SimpleCompressor.h @@ -39,7 +39,7 @@ public: std::vector pointers,int dimension,int plane,int cbmask, compressor &compress,int type,int partial) { - assert( (table.size()&0x1)==0); + GRID_ASSERT( (table.size()&0x1)==0); int num=table.size()/2; int so = plane*rhs.Grid()->_ostride[dimension]; // base offset for start of plane diff --git a/Grid/stencil/Stencil.h b/Grid/stencil/Stencil.h index 25d194b5..a6fa1134 100644 --- a/Grid/stencil/Stencil.h +++ b/Grid/stencil/Stencil.h @@ -277,7 +277,7 @@ protected: device_heap_bytes+= bytes; if ( device_heap_bytes > device_heap_size ) { std::cout << "DeviceBufferMalloc overflow bytes "<= 4^4 subvol per node _grid->ShiftedRanks(dimension,nbr_proc,xmit_to_rank,recv_from_rank); @@ -633,7 +633,7 @@ public: // Map to always positive shift modulo global full dimension. int shift = (displacement+fd)%fd; - assert (source.Checkerboard()== this->_checkerboard); + GRID_ASSERT (source.Checkerboard()== this->_checkerboard); // the permute type int simd_layout = _grid->_simd_layout[dimension]; @@ -680,7 +680,7 @@ public: ////////////////////////////////// _grid->StencilBarrier();// Synch shared memory on a single nodes - assert(source.Grid()==_grid); + GRID_ASSERT(source.Grid()==_grid); u_comm_offset=0; @@ -697,7 +697,7 @@ public: // Or issue barrier AFTER the DMA is running #endif face_table_computed=1; - assert(u_comm_offset==_unified_buffer_size); + GRID_ASSERT(u_comm_offset==_unified_buffer_size); } ///////////////////////// @@ -812,8 +812,8 @@ public: CommsMerge(decompress,Mergers,Decompressions); } template void CommsMergeSHM(decompressor decompress) { - assert(MergersSHM.size()==0); - assert(DecompressionsSHM.size()==0); + GRID_ASSERT(MergersSHM.size()==0); + GRID_ASSERT(DecompressionsSHM.size()==0); } template @@ -1003,7 +1003,7 @@ public: int splice_dim = _grid->_simd_layout[dimension]>1 && (comm_dim); int rotate_dim = _grid->_simd_layout[dimension]>2; - assert ( (rotate_dim && comm_dim) == false) ; // Do not think spread out is supported + GRID_ASSERT ( (rotate_dim && comm_dim) == false) ; // Do not think spread out is supported int sshift[2]; ////////////////////////// @@ -1117,10 +1117,10 @@ public: int simd_layout = _grid->_simd_layout[dimension]; int comm_dim = _grid->_processors[dimension] >1 ; - assert(comm_dim==1); + GRID_ASSERT(comm_dim==1); int shift = (shiftpm + fd) %fd; - assert(shift>=0); - assert(shift=0); + GRID_ASSERT(shift_slice_nblock[dimension]*_grid->_slice_block[dimension]; @@ -1301,7 +1301,7 @@ public: // int comms_partial_send = this->_comms_partial_send[point] ; // int comms_partial_recv = this->_comms_partial_recv[point] ; - assert(rhs.Grid()==_grid); + GRID_ASSERT(rhs.Grid()==_grid); // conformable(_grid,rhs.Grid()); int fd = _grid->_fdimensions[dimension]; @@ -1309,10 +1309,10 @@ public: int pd = _grid->_processors[dimension]; int simd_layout = _grid->_simd_layout[dimension]; int comm_dim = _grid->_processors[dimension] >1 ; - assert(simd_layout==1); - assert(comm_dim==1); - assert(shift>=0); - assert(shift=0); + GRID_ASSERT(shift_slice_nblock[dimension]*_grid->_slice_block[dimension]; @@ -1450,11 +1450,11 @@ public: int pd = _grid->_processors[dimension]; int simd_layout = _grid->_simd_layout[dimension]; int comm_dim = _grid->_processors[dimension] >1 ; - assert(comm_dim==1); + GRID_ASSERT(comm_dim==1); // This will not work with a rotate dim - assert(simd_layout==maxl); - assert(shift>=0); - assert(shift=0); + GRID_ASSERT(shiftPermuteType(dimension); @@ -1465,8 +1465,8 @@ public: int buffer_size = _grid->_slice_nblock[dimension]*_grid->_slice_block[dimension]; // int words = sizeof(cobj)/sizeof(vector_type); - assert(cbmask==0x3); // Fixme think there is a latent bug if not true - // This assert will trap it if ever hit. Not hit normally so far + GRID_ASSERT(cbmask==0x3); // Fixme think there is a latent bug if not true + // This GRID_ASSERT will trap it if ever hit. Not hit normally so far int reduced_buffer_size = buffer_size; if (cbmask != 0x3) reduced_buffer_size=buffer_size>>1; @@ -1477,7 +1477,7 @@ public: int xbytes; int rbytes; - assert(bytes*simd_layout == reduced_buffer_size*datum_bytes); + GRID_ASSERT(bytes*simd_layout == reduced_buffer_size*datum_bytes); std::vector rpointers(maxl); std::vector spointers(maxl); @@ -1550,7 +1550,7 @@ public: int nbr_ox = (nbr_lcoor%rd); // outer coord of peer "x" int nbr_plane = nbr_ic; - assert (sx == nbr_ox); + GRID_ASSERT (sx == nbr_ox); auto rp = &u_simd_recv_buf[i ][comm_off]; auto sp = &u_simd_send_buf[nbr_plane][comm_off]; diff --git a/Grid/tensors/Tensor_class.h b/Grid/tensors/Tensor_class.h index e63e228c..a94dabc4 100644 --- a/Grid/tensors/Tensor_class.h +++ b/Grid/tensors/Tensor_class.h @@ -33,7 +33,7 @@ NAMESPACE_BEGIN(Grid); /////////////////////////////////////////////////// // It is useful to NOT have any constructors -// so that these classes assert "is_pod == true" +// so that these classes GRID_ASSERT "is_pod == true" // because then the standard C++ valarray container eliminates fill overhead on // new allocation and // non-move copying. diff --git a/Grid/threads/Accelerator.h b/Grid/threads/Accelerator.h index 2b91165c..2c18796d 100644 --- a/Grid/threads/Accelerator.h +++ b/Grid/threads/Accelerator.h @@ -205,7 +205,7 @@ void Lambda6Apply(uint64_t num1, uint64_t num2, uint64_t num3, cudaGetErrorString( err )); \ printf("File %s Line %d\n",__FILE__,__LINE__); \ fflush(stdout); \ - if (acceleratorAbortOnGpuError) assert(err==cudaSuccess); \ + if (acceleratorAbortOnGpuError) GRID_ASSERT(err==cudaSuccess); \ } \ } @@ -216,7 +216,7 @@ inline void *acceleratorAllocHost(size_t bytes) if( err != cudaSuccess ) { ptr = (void *) NULL; printf(" cudaMallocHost failed for %zu %s \n",bytes,cudaGetErrorString(err)); - assert(0); + GRID_ASSERT(0); } return ptr; } @@ -227,7 +227,7 @@ inline void *acceleratorAllocShared(size_t bytes) if( err != cudaSuccess ) { ptr = (void *) NULL; printf(" cudaMallocManaged failed for %zu %s \n",bytes,cudaGetErrorString(err)); - assert(0); + GRID_ASSERT(0); } return ptr; }; @@ -276,7 +276,7 @@ inline int acceleratorIsCommunicable(void *ptr) // int uvm=0; // auto // cuerr = cuPointerGetAttribute( &uvm, CU_POINTER_ATTRIBUTE_IS_MANAGED, (CUdeviceptr) ptr); - // assert(cuerr == cudaSuccess ); + // GRID_ASSERT(cuerr == cudaSuccess ); // if(uvm) return 0; // else return 1; return 1; diff --git a/Grid/threads/ThreadReduction.h b/Grid/threads/ThreadReduction.h index f0d24d50..8ef84c22 100644 --- a/Grid/threads/ThreadReduction.h +++ b/Grid/threads/ThreadReduction.h @@ -61,7 +61,7 @@ public: _threads = 1; #endif }; - static int GetHyperThreads(void) { assert(_threads%_cores ==0); return _threads/_cores; }; + static int GetHyperThreads(void) { GRID_ASSERT(_threads%_cores ==0); return _threads/_cores; }; static int GetCores(void) { return _cores; }; static int GetThreads(void) { return _threads; }; static int SumArraySize(void) {return _threads;}; diff --git a/Grid/threads/Threads.h b/Grid/threads/Threads.h index cdb4fa62..c517ca13 100644 --- a/Grid/threads/Threads.h +++ b/Grid/threads/Threads.h @@ -77,7 +77,7 @@ inline void thread_bcopy(const void *from, void *to,size_t bytes) { const uint64_t *ufrom = (const uint64_t *)from; uint64_t *uto = (uint64_t *)to; - assert(bytes%8==0); + GRID_ASSERT(bytes%8==0); uint64_t words=bytes/8; thread_for(w,words,{ uto[w] = ufrom[w]; diff --git a/Grid/util/FlightRecorder.cc b/Grid/util/FlightRecorder.cc index 466ce071..b5baeea9 100644 --- a/Grid/util/FlightRecorder.cc +++ b/Grid/util/FlightRecorder.cc @@ -47,6 +47,7 @@ int32_t FlightRecorder::CsumLoggingCounter; int32_t FlightRecorder::NormLoggingCounter; int32_t FlightRecorder::ReductionLoggingCounter; uint64_t FlightRecorder::ErrorCounter; + std::vector FlightRecorder::NormLogVector; std::vector FlightRecorder::ReductionLogVector; std::vector FlightRecorder::CsumLogVector; @@ -89,7 +90,7 @@ void FlightRecorder::SetLoggingMode(FlightRecorder::LoggingMode_t mode) Truncate(); break; default: - assert(0); + GRID_ASSERT(0); } } bool FlightRecorder::StepLog(const char *name) @@ -260,7 +261,7 @@ void FlightRecorder::ReductionLog(double local,double global) global, local, ReductionLogVector[ReductionLoggingCounter]); fflush(stderr); BACKTRACEFP(stderr); - if ( !ContinueOnFail ) assert(0); + if ( !ContinueOnFail ) GRID_ASSERT(0); ErrorCounter++; } else { @@ -308,7 +309,7 @@ void FlightRecorder::xmitLog(void *buf,uint64_t bytes) _xor, XmitLogVector[XmitLoggingCounter]); fflush(stderr); BACKTRACEFP(stderr); - if ( !ContinueOnFail ) assert(0); + if ( !ContinueOnFail ) GRID_ASSERT(0); ErrorCounter++; } else { @@ -354,7 +355,7 @@ void FlightRecorder::recvLog(void *buf,uint64_t bytes,int rank) _xor, RecvLogVector[RecvLoggingCounter],rank); fflush(stderr); BACKTRACEFP(stderr); - if ( !ContinueOnFail ) assert(0); + if ( !ContinueOnFail ) GRID_ASSERT(0); ErrorCounter++; } else { @@ -379,8 +380,12 @@ std::vector ViewLogger::LogVector; void ViewLogger::Begin() { Enabled = true; LogVector.resize(0); } void ViewLogger::End() { Enabled = false; } - -void ViewLogger::Log(const char* filename, int line, int index, int mode, void* data, uint64_t bytes) +#ifdef GRID_LOG_VIEWS_FENCEPOST +void ViewLogger::LogOpen(const char* filename, int line, int index, int mode, void* data, uint64_t bytes) +{ + ViewLogger::LogClose(filename,line,index,mode,data,bytes); +} +void ViewLogger::LogClose(const char* filename, int line, int index, int mode, void* data, uint64_t bytes) { if (!Enabled) return; @@ -416,6 +421,27 @@ void ViewLogger::Log(const char* filename, int line, int index, int mode, void* } } } +#else +void ViewLogger::LogOpen(const char* filename, int line, int index, int mode, void* data, uint64_t bytes){ } +void ViewLogger::LogClose(const char* filename, int line, int index, int mode, void* data, uint64_t bytes) +{ + if (!Enabled) + return; + + if (bytes < sizeof(uint64_t)) return; + +#ifdef GRID_SYCL + uint64_t *u_data = (uint64_t *)data; + switch (mode) { + case AcceleratorWrite: + case AcceleratorWriteDiscard: + uint64_t csum = checksum_gpu(u_data,bytes/sizeof(uint64_t)); + FlightRecorder::CsumLog(csum); + break; + } +#endif +} +#endif #endif diff --git a/Grid/util/FlightRecorder.h b/Grid/util/FlightRecorder.h index 7cad5a61..63ff2d04 100644 --- a/Grid/util/FlightRecorder.h +++ b/Grid/util/FlightRecorder.h @@ -56,7 +56,8 @@ public: static std::vector LogVector; static void Begin(); static void End(); - static void Log(const char* filename, int line, int index, int mode, void* data, uint64_t bytes); + static void LogOpen(const char* filename, int line, int index, int mode, void* data, uint64_t bytes); + static void LogClose(const char* filename, int line, int index, int mode, void* data, uint64_t bytes); }; #endif NAMESPACE_END(Grid); diff --git a/Grid/util/Init.cc b/Grid/util/Init.cc index 90f48b7f..23061372 100644 --- a/Grid/util/Init.cc +++ b/Grid/util/Init.cc @@ -85,6 +85,8 @@ feenableexcept (unsigned int excepts) #define HOST_NAME_MAX _POSIX_HOST_NAME_MAX #endif +void * Grid_backtrace_buffer[_NBACKTRACE]; + NAMESPACE_BEGIN(Grid); ////////////////////////////////////////////////////// @@ -118,7 +120,7 @@ const Coordinate GridDefaultSimd(int dims,int nsimd) layout[d]=1; } } - assert(nn==1); + GRID_ASSERT(nn==1); return layout; } @@ -213,14 +215,14 @@ void GridParseLayout(char **argv,int argc, #endif arg= GridCmdOptionPayload(argv,argv+argc,"--threads"); GridCmdOptionIntVector(arg,ompthreads); - assert(ompthreads.size()==1); + GRID_ASSERT(ompthreads.size()==1); GridThread::SetThreads(ompthreads[0]); } if( GridCmdOptionExists(argv,argv+argc,"--accelerator-threads") ){ std::vector gputhreads(0); arg= GridCmdOptionPayload(argv,argv+argc,"--accelerator-threads"); GridCmdOptionIntVector(arg,gputhreads); - assert(gputhreads.size()==1); + GRID_ASSERT(gputhreads.size()==1); acceleratorThreads(gputhreads[0]); } @@ -232,7 +234,7 @@ void GridParseLayout(char **argv,int argc, } // Copy back into coordinate format int nd = mpi.size(); - assert(latt.size()==nd); + GRID_ASSERT(latt.size()==nd); latt_c.resize(nd); mpi_c.resize(nd); for(int d=0;d dlMap; void Grid_init(int *argc,char ***argv) { - - assert(Grid_is_initialised == 0); + + GRID_ASSERT(Grid_is_initialised == 0); GridLogger::GlobalStopWatch.Start(); @@ -361,24 +363,6 @@ void Grid_init(int *argc,char ***argv) GlobalSharedMemory::Hugepages = 1; } - - if( GridCmdOptionExists(*argv,*argv+*argc,"--debug-signals") ){ - Grid_debug_handler_init(); - } - // Sleep n-seconds at end of handler - if( GridCmdOptionExists(*argv,*argv+*argc,"--signal-delay") ){ - arg= GridCmdOptionPayload(*argv,*argv+*argc,"--signal-delay"); - GridCmdOptionInt(arg,signal_delay); - } - // periodic wakeup with stack trace printed - if( GridCmdOptionExists(*argv,*argv+*argc,"--debug-heartbeat") ){ - Grid_debug_heartbeat(); - } - // periodic wakeup with empty handler (interrupts some system calls) - if( GridCmdOptionExists(*argv,*argv+*argc,"--heartbeat") ){ - Grid_heartbeat(); - } - #if defined(A64FX) if( GridCmdOptionExists(*argv,*argv+*argc,"--comms-overlap") ){ std::cout << "Option --comms-overlap currently not supported on QPACE4. Exiting." << std::endl; @@ -418,7 +402,7 @@ void Grid_init(int *argc,char ***argv) std::ostringstream fname; int rank = CartesianCommunicator::RankWorld(); - int radix=64; + int radix=32; char* root = getenv("GRID_STDOUT_ROOT"); if (root) { fname << root ; @@ -430,8 +414,11 @@ void Grid_init(int *argc,char ***argv) fname << "/"; fname<<"Grid.stdout."; fname<=2*1024*1024*1024LL ){ // std::cout << " IndexFromCoorReversed " << coor<<" index " << index64<< " dims "< diff --git a/HMC/ComputeWilsonFlow.cc b/HMC/ComputeWilsonFlow.cc index b273ee40..9bc93536 100644 --- a/HMC/ComputeWilsonFlow.cc +++ b/HMC/ComputeWilsonFlow.cc @@ -38,6 +38,7 @@ namespace Grid{ int, meas_interval, double, maxTau, // for the adaptive algorithm int, meas_interval_density, + std::string, flow_type, std::string, path); @@ -127,13 +128,21 @@ int main(int argc, char **argv) { std::string file_post = CPar.conf_prefix + "." + std::to_string(conf); WilsonFlow WF(WFPar.step_size,WFPar.steps,WFPar.meas_interval); - + WilsonGaugeAction WGA(3.0); + IwasakiGaugeAction IWGA(3.0); + SymanzikGaugeAction SZGA(3.0); + DBW2GaugeAction DBGA(3.0); + if ( WFPar.flow_type == std::string("Wilson")) WF.setGaugeAction(&WGA); + else if (WFPar.flow_type == std::string("Iwasaki" )) WF.setGaugeAction(&IWGA); + else if (WFPar.flow_type == std::string("Symanzik")) WF.setGaugeAction(&SZGA); + else if (WFPar.flow_type == std::string("DBW2")) WF.setGaugeAction(&DBGA); + WF.addMeasurement(WFPar.meas_interval_density, [&file_pre,&file_post,&conf](int step, RealD t, const typename PeriodicGimplR::GaugeField &U){ typedef typename PeriodicGimplR::GaugeLinkField GaugeMat; typedef typename PeriodicGimplR::ComplexField ComplexField; - assert(Nd == 4); + GRID_ASSERT(Nd == 4); // NOTE: // Ideally, turn the folloing into methods of the appropriate class diff --git a/HMC/Mobius2p1fEOFA.cc b/HMC/Mobius2p1fEOFA.cc index c961cbc9..e7b0e473 100644 --- a/HMC/Mobius2p1fEOFA.cc +++ b/HMC/Mobius2p1fEOFA.cc @@ -107,7 +107,7 @@ NAMESPACE_BEGIN(Grid); // std::cout << GridLogMessage << " Mixed precision CG wrapper operator() FermOpD " <_Mat)==&(LinOpD._Mat)); + GRID_ASSERT(&(SchurOpU->_Mat)==&(LinOpD._Mat)); //////////////////////////////////////////////////////////////////////////////////// // Must snarf a single precision copy of the gauge field in Linop_d argument diff --git a/HMC/Mobius2p1fEOFA_F1.cc b/HMC/Mobius2p1fEOFA_F1.cc index f910d69e..d9fec4fa 100644 --- a/HMC/Mobius2p1fEOFA_F1.cc +++ b/HMC/Mobius2p1fEOFA_F1.cc @@ -107,7 +107,7 @@ NAMESPACE_BEGIN(Grid); // std::cout << GridLogMessage << " Mixed precision CG wrapper operator() FermOpD " <_Mat)==&(LinOpD._Mat)); + GRID_ASSERT(&(SchurOpU->_Mat)==&(LinOpD._Mat)); //////////////////////////////////////////////////////////////////////////////////// // Must snarf a single precision copy of the gauge field in Linop_d argument diff --git a/HMC/Mobius2p1fIDSDRGparityEOFA_40ID.cc b/HMC/Mobius2p1fIDSDRGparityEOFA_40ID.cc index 35ec2246..2825d403 100644 --- a/HMC/Mobius2p1fIDSDRGparityEOFA_40ID.cc +++ b/HMC/Mobius2p1fIDSDRGparityEOFA_40ID.cc @@ -176,7 +176,7 @@ void computeEigenvalues(std::string param_file, SchurDiagMooeeOperator hermop(action); PlainHermOp hermop_wrap(hermop); //ChebyshevLanczos Cheb(params.alpha, params.beta, params.mu, params.ord); - assert(params.mu == 0.0); + GRID_ASSERT(params.mu == 0.0); Chebyshev Cheb(params.beta*params.beta, params.alpha*params.alpha, params.ord+1); FunctionHermOp Cheb_wrap(Cheb, hermop); @@ -202,7 +202,7 @@ template void checkRHMC(GridCartesian* Grid, GridRedBlackCartesian* rbGrid, const LatticeGaugeFieldD &latt, //expect lattice to have been initialized to something FermionActionD &numOp, FermionActionD &denOp, RHMCtype &rhmc, GridParallelRNG &rng, int inv_pow, const std::string &quark_descr, int action_or_md){ - assert(action_or_md == 0 || action_or_md == 1 || action_or_md == 2); + GRID_ASSERT(action_or_md == 0 || action_or_md == 1 || action_or_md == 2); FermionFieldD gauss_o(rbGrid); FermionFieldD gauss(Grid); @@ -291,13 +291,13 @@ public: EOFAlinop(ExactOneFlavourRatioPseudoFermionAction &EOFA, LatticeGaugeFieldD &U): EOFA(EOFA), U(U){} typedef typename FermionImplPolicy::FermionField Field; - void OpDiag (const Field &in, Field &out){ assert(0); } - void OpDir (const Field &in, Field &out,int dir,int disp){ assert(0); } - void OpDirAll (const Field &in, std::vector &out){ assert(0); } + void OpDiag (const Field &in, Field &out){ GRID_ASSERT(0); } + void OpDir (const Field &in, Field &out,int dir,int disp){ GRID_ASSERT(0); } + void OpDirAll (const Field &in, std::vector &out){ GRID_ASSERT(0); } - void Op (const Field &in, Field &out){ assert(0); } - void AdjOp (const Field &in, Field &out){ assert(0); } - void HermOpAndNorm(const Field &in, Field &out,RealD &n1,RealD &n2){ assert(0); } + void Op (const Field &in, Field &out){ GRID_ASSERT(0); } + void AdjOp (const Field &in, Field &out){ GRID_ASSERT(0); } + void HermOpAndNorm(const Field &in, Field &out,RealD &n1,RealD &n2){ GRID_ASSERT(0); } void HermOp(const Field &in, Field &out){ EOFA.Meofa(U, in, out); } }; @@ -322,13 +322,13 @@ public: EOFAinvLinop(ExactOneFlavourRatioPseudoFermionAction &EOFA, LatticeGaugeFieldD &U): EOFA(EOFA), U(U){} typedef typename FermionImplPolicy::FermionField Field; - void OpDiag (const Field &in, Field &out){ assert(0); } - void OpDir (const Field &in, Field &out,int dir,int disp){ assert(0); } - void OpDirAll (const Field &in, std::vector &out){ assert(0); } + void OpDiag (const Field &in, Field &out){ GRID_ASSERT(0); } + void OpDir (const Field &in, Field &out,int dir,int disp){ GRID_ASSERT(0); } + void OpDirAll (const Field &in, std::vector &out){ GRID_ASSERT(0); } - void Op (const Field &in, Field &out){ assert(0); } - void AdjOp (const Field &in, Field &out){ assert(0); } - void HermOpAndNorm(const Field &in, Field &out,RealD &n1,RealD &n2){ assert(0); } + void Op (const Field &in, Field &out){ GRID_ASSERT(0); } + void AdjOp (const Field &in, Field &out){ GRID_ASSERT(0); } + void HermOpAndNorm(const Field &in, Field &out,RealD &n1,RealD &n2){ GRID_ASSERT(0); } void HermOp(const Field &in, Field &out){ EOFA.MeofaInv(U, in, out); } }; @@ -400,7 +400,7 @@ NAMESPACE_BEGIN(Grid); std::cout << GridLogMessage << " Mixed precision CG wrapper operator() "<(&LinOpU); - assert(&(SchurOpU->_Mat)==&(LinOpD._Mat)); + GRID_ASSERT(&(SchurOpU->_Mat)==&(LinOpD._Mat)); precisionChange(FermOpF.Umu, FermOpD.Umu); @@ -466,7 +466,7 @@ NAMESPACE_BEGIN(Grid); std::cout << GridLogMessage << " Mixed precision reliable CG update wrapper operator() "<(&LinOpU); - assert(&(SchurOpU->_Mat)==&(LinOpD._Mat)); + GRID_ASSERT(&(SchurOpU->_Mat)==&(LinOpD._Mat)); precisionChange(FermOpF.Umu, FermOpD.Umu); @@ -508,14 +508,14 @@ int main(int argc, char **argv) { while(i < argc){ std::string sarg(argv[i]); if(sarg == "--param_file"){ - assert(i!=argc-1); + GRID_ASSERT(i!=argc-1); param_file = argv[i+1]; i+=2; }else if(sarg == "--read_check"){ //check the fields load correctly and pass checksum/plaquette repro file_load_check = true; i++; }else if(sarg == "--set_seeds"){ //set the rng seeds. Expects two vector args, e.g. --set_seeds 1.2.3.4 5.6.7.8 - assert(i < argc-2); + GRID_ASSERT(i < argc-2); std::vector tmp; GridCmdOptionIntVector(argv[i+1],tmp); { @@ -713,7 +713,7 @@ int main(int argc, char **argv) { std::vector eofa_light_masses = { light_mass , 0.004, 0.016, 0.064, 0.256 }; std::vector eofa_pv_masses = { 0.004 , 0.016, 0.064, 0.256, 1.0 }; int n_light_hsb = 5; - assert(user_params.eofa_l.size() == n_light_hsb); + GRID_ASSERT(user_params.eofa_l.size() == n_light_hsb); EOFAmixPrecPFaction* EOFA_pfactions[n_light_hsb]; @@ -837,42 +837,42 @@ int main(int argc, char **argv) { for(int i=1;i= 0 && eofa_which_hsb < n_light_hsb) ); + GRID_ASSERT(eofa_which_hsb == -1 || (eofa_which_hsb >= 0 && eofa_which_hsb < n_light_hsb) ); } else if(sarg == "--upper_bound_eofa"){ - assert(i < argc-1); + GRID_ASSERT(i < argc-1); upper_bound_eofa = true; eofa_which_hsb = std::stoi(argv[i+1]); - assert(eofa_which_hsb >= 0 && eofa_which_hsb < n_light_hsb); + GRID_ASSERT(eofa_which_hsb >= 0 && eofa_which_hsb < n_light_hsb); } else if(sarg == "--lower_bound_eofa"){ - assert(i < argc-1); + GRID_ASSERT(i < argc-1); lower_bound_eofa = true; eofa_which_hsb = std::stoi(argv[i+1]); - assert(eofa_which_hsb >= 0 && eofa_which_hsb < n_light_hsb); + GRID_ASSERT(eofa_which_hsb >= 0 && eofa_which_hsb < n_light_hsb); } } if(tune_rhmc_s || eigenrange_s || tune_rhmc_DSDR || eigenrange_DSDR ||check_eofa || upper_bound_eofa || lower_bound_eofa) { diff --git a/HMC/Mobius2p1fIDSDRGparityEOFA_48ID.cc b/HMC/Mobius2p1fIDSDRGparityEOFA_48ID.cc index 004a0953..4c1b5856 100644 --- a/HMC/Mobius2p1fIDSDRGparityEOFA_48ID.cc +++ b/HMC/Mobius2p1fIDSDRGparityEOFA_48ID.cc @@ -176,7 +176,7 @@ void computeEigenvalues(std::string param_file, SchurDiagMooeeOperator hermop(action); PlainHermOp hermop_wrap(hermop); //ChebyshevLanczos Cheb(params.alpha, params.beta, params.mu, params.ord); - assert(params.mu == 0.0); + GRID_ASSERT(params.mu == 0.0); Chebyshev Cheb(params.beta*params.beta, params.alpha*params.alpha, params.ord+1); FunctionHermOp Cheb_wrap(Cheb, hermop); @@ -202,7 +202,7 @@ template void checkRHMC(GridCartesian* Grid, GridRedBlackCartesian* rbGrid, const LatticeGaugeFieldD &latt, //expect lattice to have been initialized to something FermionActionD &numOp, FermionActionD &denOp, RHMCtype &rhmc, GridParallelRNG &rng, int inv_pow, const std::string &quark_descr, int action_or_md){ - assert(action_or_md == 0 || action_or_md == 1 || action_or_md == 2); + GRID_ASSERT(action_or_md == 0 || action_or_md == 1 || action_or_md == 2); FermionFieldD gauss_o(rbGrid); FermionFieldD gauss(Grid); @@ -291,13 +291,13 @@ public: EOFAlinop(ExactOneFlavourRatioPseudoFermionAction &EOFA, LatticeGaugeFieldD &U): EOFA(EOFA), U(U){} typedef typename FermionImplPolicy::FermionField Field; - void OpDiag (const Field &in, Field &out){ assert(0); } - void OpDir (const Field &in, Field &out,int dir,int disp){ assert(0); } - void OpDirAll (const Field &in, std::vector &out){ assert(0); } + void OpDiag (const Field &in, Field &out){ GRID_ASSERT(0); } + void OpDir (const Field &in, Field &out,int dir,int disp){ GRID_ASSERT(0); } + void OpDirAll (const Field &in, std::vector &out){ GRID_ASSERT(0); } - void Op (const Field &in, Field &out){ assert(0); } - void AdjOp (const Field &in, Field &out){ assert(0); } - void HermOpAndNorm(const Field &in, Field &out,RealD &n1,RealD &n2){ assert(0); } + void Op (const Field &in, Field &out){ GRID_ASSERT(0); } + void AdjOp (const Field &in, Field &out){ GRID_ASSERT(0); } + void HermOpAndNorm(const Field &in, Field &out,RealD &n1,RealD &n2){ GRID_ASSERT(0); } void HermOp(const Field &in, Field &out){ EOFA.Meofa(U, in, out); } }; @@ -322,13 +322,13 @@ public: EOFAinvLinop(ExactOneFlavourRatioPseudoFermionAction &EOFA, LatticeGaugeFieldD &U): EOFA(EOFA), U(U){} typedef typename FermionImplPolicy::FermionField Field; - void OpDiag (const Field &in, Field &out){ assert(0); } - void OpDir (const Field &in, Field &out,int dir,int disp){ assert(0); } - void OpDirAll (const Field &in, std::vector &out){ assert(0); } + void OpDiag (const Field &in, Field &out){ GRID_ASSERT(0); } + void OpDir (const Field &in, Field &out,int dir,int disp){ GRID_ASSERT(0); } + void OpDirAll (const Field &in, std::vector &out){ GRID_ASSERT(0); } - void Op (const Field &in, Field &out){ assert(0); } - void AdjOp (const Field &in, Field &out){ assert(0); } - void HermOpAndNorm(const Field &in, Field &out,RealD &n1,RealD &n2){ assert(0); } + void Op (const Field &in, Field &out){ GRID_ASSERT(0); } + void AdjOp (const Field &in, Field &out){ GRID_ASSERT(0); } + void HermOpAndNorm(const Field &in, Field &out,RealD &n1,RealD &n2){ GRID_ASSERT(0); } void HermOp(const Field &in, Field &out){ EOFA.MeofaInv(U, in, out); } }; @@ -400,7 +400,7 @@ NAMESPACE_BEGIN(Grid); std::cout << GridLogMessage << " Mixed precision CG wrapper operator() "<(&LinOpU); - assert(&(SchurOpU->_Mat)==&(LinOpD._Mat)); + GRID_ASSERT(&(SchurOpU->_Mat)==&(LinOpD._Mat)); precisionChange(FermOpF.Umu, FermOpD.Umu); @@ -465,7 +465,7 @@ NAMESPACE_BEGIN(Grid); std::cout << GridLogMessage << " Mixed precision reliable CG update wrapper operator() "<(&LinOpU); - assert(&(SchurOpU->_Mat)==&(LinOpD._Mat)); + GRID_ASSERT(&(SchurOpU->_Mat)==&(LinOpD._Mat)); precisionChange(FermOpF.Umu, FermOpD.Umu); @@ -502,7 +502,7 @@ int main(int argc, char **argv) { for(int i=1;i eofa_light_masses = { light_mass , 0.004, 0.016, 0.064, 0.256 }; std::vector eofa_pv_masses = { 0.004 , 0.016, 0.064, 0.256, 1.0 }; int n_light_hsb = 5; - assert(user_params.eofa_l.size() == n_light_hsb); + GRID_ASSERT(user_params.eofa_l.size() == n_light_hsb); EOFAmixPrecPFaction* EOFA_pfactions[n_light_hsb]; @@ -791,42 +791,42 @@ int main(int argc, char **argv) { for(int i=1;i= 0 && eofa_which_hsb < n_light_hsb) ); + GRID_ASSERT(eofa_which_hsb == -1 || (eofa_which_hsb >= 0 && eofa_which_hsb < n_light_hsb) ); } else if(sarg == "--upper_bound_eofa"){ - assert(i < argc-1); + GRID_ASSERT(i < argc-1); upper_bound_eofa = true; eofa_which_hsb = std::stoi(argv[i+1]); - assert(eofa_which_hsb >= 0 && eofa_which_hsb < n_light_hsb); + GRID_ASSERT(eofa_which_hsb >= 0 && eofa_which_hsb < n_light_hsb); } else if(sarg == "--lower_bound_eofa"){ - assert(i < argc-1); + GRID_ASSERT(i < argc-1); lower_bound_eofa = true; eofa_which_hsb = std::stoi(argv[i+1]); - assert(eofa_which_hsb >= 0 && eofa_which_hsb < n_light_hsb); + GRID_ASSERT(eofa_which_hsb >= 0 && eofa_which_hsb < n_light_hsb); } } if(tune_rhmc_s || eigenrange_s || tune_rhmc_DSDR || eigenrange_DSDR ||check_eofa || upper_bound_eofa || lower_bound_eofa) { diff --git a/HMC/Mobius2p1f_DD_EOFA_96I_3level.cc b/HMC/Mobius2p1f_DD_EOFA_96I_3level.cc index c305567c..c0b5ced1 100644 --- a/HMC/Mobius2p1f_DD_EOFA_96I_3level.cc +++ b/HMC/Mobius2p1f_DD_EOFA_96I_3level.cc @@ -95,7 +95,7 @@ template_Mat)==&(LinOpD._Mat)); + GRID_ASSERT(&(SchurOpU->_Mat)==&(LinOpD._Mat)); //////////////////////////////////////////////////////////////////////////////////// // Must snarf a single precision copy of the gauge field in Linop_d argument diff --git a/HMC/Mobius2p1f_DD_EOFA_96I_mixed.cc b/HMC/Mobius2p1f_DD_EOFA_96I_mixed.cc index 83f20b92..becfac53 100644 --- a/HMC/Mobius2p1f_DD_EOFA_96I_mixed.cc +++ b/HMC/Mobius2p1f_DD_EOFA_96I_mixed.cc @@ -95,7 +95,7 @@ template_Mat)==&(LinOpD._Mat)); + GRID_ASSERT(&(SchurOpU->_Mat)==&(LinOpD._Mat)); //////////////////////////////////////////////////////////////////////////////////// // Must snarf a single precision copy of the gauge field in Linop_d argument diff --git a/HMC/Mobius2p1f_DD_EOFA_96I_mshift.cc b/HMC/Mobius2p1f_DD_EOFA_96I_mshift.cc index c69c70c7..7ae96dcd 100644 --- a/HMC/Mobius2p1f_DD_EOFA_96I_mshift.cc +++ b/HMC/Mobius2p1f_DD_EOFA_96I_mshift.cc @@ -95,7 +95,7 @@ template_Mat)==&(LinOpD._Mat)); + GRID_ASSERT(&(SchurOpU->_Mat)==&(LinOpD._Mat)); //////////////////////////////////////////////////////////////////////////////////// // Must snarf a single precision copy of the gauge field in Linop_d argument diff --git a/HMC/Mobius2p1f_DD_RHMC_96I_mixed.cc b/HMC/Mobius2p1f_DD_RHMC_96I_mixed.cc index 36528c9f..864cefcc 100644 --- a/HMC/Mobius2p1f_DD_RHMC_96I_mixed.cc +++ b/HMC/Mobius2p1f_DD_RHMC_96I_mixed.cc @@ -95,7 +95,7 @@ template_Mat)==&(LinOpD._Mat)); + GRID_ASSERT(&(SchurOpU->_Mat)==&(LinOpD._Mat)); //////////////////////////////////////////////////////////////////////////////////// // Must snarf a single precision copy of the gauge field in Linop_d argument diff --git a/HMC/Mobius2p1f_EOFA_96I_hmc.cc b/HMC/Mobius2p1f_EOFA_96I_hmc.cc index 91f0bd95..d967d55a 100644 --- a/HMC/Mobius2p1f_EOFA_96I_hmc.cc +++ b/HMC/Mobius2p1f_EOFA_96I_hmc.cc @@ -95,7 +95,7 @@ template_Mat)==&(LinOpD._Mat)); + GRID_ASSERT(&(SchurOpU->_Mat)==&(LinOpD._Mat)); //////////////////////////////////////////////////////////////////////////////////// // Must snarf a single precision copy of the gauge field in Linop_d argument diff --git a/MPI_benchmark/halo_mpi.cc b/MPI_benchmark/halo_mpi.cc index 9e11c473..b9b08c14 100644 --- a/MPI_benchmark/halo_mpi.cc +++ b/MPI_benchmark/halo_mpi.cc @@ -47,7 +47,7 @@ void *acceleratorAllocDevice(size_t bytes) { void *ptr=NULL; auto err = cudaMalloc((void **)&ptr,bytes); - assert(err==cudaSuccess); + GRID_ASSERT(err==cudaSuccess); return ptr; } void acceleratorFreeDevice(void *ptr){ cudaFree(ptr);} diff --git a/benchmarks/Benchmark_IO.cc b/benchmarks/Benchmark_IO.cc index 01325c53..8474c4b2 100644 --- a/benchmarks/Benchmark_IO.cc +++ b/benchmarks/Benchmark_IO.cc @@ -37,7 +37,7 @@ void stats(Mat &mean, Mat &stdDev, const std::vector &data) Eigen::MatrixXd sqSum(nr, nc); double n = static_cast(data.size()); - assert(n > 1.); + GRID_ASSERT(n > 1.); mean = Mat::Zero(nr, nc); sqSum = Mat::Zero(nr, nc); for (auto &d: data) diff --git a/benchmarks/Benchmark_ITT.cc b/benchmarks/Benchmark_ITT.cc index c42136b6..48980b2c 100644 --- a/benchmarks/Benchmark_ITT.cc +++ b/benchmarks/Benchmark_ITT.cc @@ -325,7 +325,7 @@ public: // Set/Get the layout & grid size /////////////////////////////////////////////////////// int threads = GridThread::GetThreads(); - Coordinate mpi = GridDefaultMpi(); assert(mpi.size()==4); + Coordinate mpi = GridDefaultMpi(); GRID_ASSERT(mpi.size()==4); Coordinate local({L,L,L,L}); Coordinate latt4({local[0]*mpi[0],local[1]*mpi[1],local[2]*mpi[2],local[3]*mpi[3]}); @@ -492,7 +492,7 @@ public: // Set/Get the layout & grid size /////////////////////////////////////////////////////// int threads = GridThread::GetThreads(); - Coordinate mpi = GridDefaultMpi(); assert(mpi.size()==4); + Coordinate mpi = GridDefaultMpi(); GRID_ASSERT(mpi.size()==4); Coordinate local({L,L,L,L}); Coordinate latt4({local[0]*mpi[0],local[1]*mpi[1],local[2]*mpi[2],local[3]*mpi[3]}); diff --git a/benchmarks/Benchmark_dwf.cc b/benchmarks/Benchmark_dwf.cc index 29772141..d7403705 100644 --- a/benchmarks/Benchmark_dwf.cc +++ b/benchmarks/Benchmark_dwf.cc @@ -312,7 +312,7 @@ void Benchmark(int Ls, Coordinate Dirichlet,bool sloppy) FGrid->Barrier(); exit(-1); } - assert (n2e< 1.0e-4 ); + GRID_ASSERT (n2e< 1.0e-4 ); } if (1) @@ -370,7 +370,7 @@ void Benchmark(int Ls, Coordinate Dirichlet,bool sloppy) n2e= norm2(err); std::cout<Barrier(); exit(-1); } - assert (n2e< 1.0e-4 ); + GRID_ASSERT (n2e< 1.0e-4 ); } if (1) @@ -370,7 +370,7 @@ void Benchmark(int Ls, Coordinate Dirichlet,bool sloppy) n2e= norm2(err); std::cout<Barrier(); @@ -244,7 +244,7 @@ int main (int argc, char ** argv) FGrid->Barrier(); exit(-1); } - assert (norm2(err)< 1.0e-4 ); + GRID_ASSERT (norm2(err)< 1.0e-4 ); } if (1) @@ -380,8 +380,8 @@ int main (int argc, char ** argv) std::cout< > &mat, const int Nsimd = grid->Nsimd(); int Nt = grid->GlobalDimensions()[orthogdim]; - assert(mat.size()==Lblock*Rblock); + GRID_ASSERT(mat.size()==Lblock*Rblock); for(int t=0;t_fdimensions[orthogdim]; @@ -181,9 +181,9 @@ void sliceInnerProductMesonFieldGamma(std::vector< std::vector > &mat, int Nt = grid->GlobalDimensions()[orthogdim]; int Ngamma = gammas.size(); - assert(mat.size()==Lblock*Rblock*Ngamma); + GRID_ASSERT(mat.size()==Lblock*Rblock*Ngamma); for(int t=0;t_fdimensions[orthogdim]; @@ -329,9 +329,9 @@ void sliceInnerProductMesonFieldGamma1(std::vector< std::vector > &mat int Nt = grid->GlobalDimensions()[orthogdim]; int Ngamma = gammas.size(); - assert(mat.size()==Lblock*Rblock*Ngamma); + GRID_ASSERT(mat.size()==Lblock*Rblock*Ngamma); for(int t=0;t_fdimensions[orthogdim]; @@ -472,9 +472,9 @@ void sliceInnerProductMesonFieldGammaMom(std::vector< std::vector > &m int Ngamma = gammas.size(); int Nmom = mom.size(); - assert(mat.size()==Lblock*Rblock*Ngamma*Nmom); + GRID_ASSERT(mat.size()==Lblock*Rblock*Ngamma*Nmom); for(int t=0;t_fdimensions[orthogdim]; diff --git a/benchmarks/Benchmark_usqcd.cc b/benchmarks/Benchmark_usqcd.cc index 4b50121e..70489419 100644 --- a/benchmarks/Benchmark_usqcd.cc +++ b/benchmarks/Benchmark_usqcd.cc @@ -397,7 +397,7 @@ public: // Set/Get the layout & grid size /////////////////////////////////////////////////////// int threads = GridThread::GetThreads(); - Coordinate mpi = GridDefaultMpi(); assert(mpi.size()==4); + Coordinate mpi = GridDefaultMpi(); GRID_ASSERT(mpi.size()==4); Coordinate local({L,L,L,L}); Coordinate latt4({local[0]*mpi[0],local[1]*mpi[1],local[2]*mpi[2],local[3]*mpi[3]}); @@ -568,7 +568,7 @@ public: // Set/Get the layout & grid size /////////////////////////////////////////////////////// int threads = GridThread::GetThreads(); - Coordinate mpi = GridDefaultMpi(); assert(mpi.size()==4); + Coordinate mpi = GridDefaultMpi(); GRID_ASSERT(mpi.size()==4); Coordinate local({L,L,L,L}); Coordinate latt4({local[0]*mpi[0],local[1]*mpi[1],local[2]*mpi[2],local[3]*mpi[3]}); @@ -723,7 +723,7 @@ public: // Set/Get the layout & grid size /////////////////////////////////////////////////////// int threads = GridThread::GetThreads(); - Coordinate mpi = GridDefaultMpi(); assert(mpi.size()==4); + Coordinate mpi = GridDefaultMpi(); GRID_ASSERT(mpi.size()==4); Coordinate local({L,L,L,L}); Coordinate latt4({local[0]*mpi[0],local[1]*mpi[1],local[2]*mpi[2],local[3]*mpi[3]}); diff --git a/benchmarks/Benchmark_wilson.cc b/benchmarks/Benchmark_wilson.cc index 4510388b..3572f6b1 100644 --- a/benchmarks/Benchmark_wilson.cc +++ b/benchmarks/Benchmark_wilson.cc @@ -253,8 +253,8 @@ int main (int argc, char ** argv) // guard double err1 = norm2(err); - assert(fabs(err0) < 1.0e-3); - assert(fabs(err1) < 1.0e-3); + GRID_ASSERT(fabs(err0) < 1.0e-3); + GRID_ASSERT(fabs(err1) < 1.0e-3); Grid_finalize(); } diff --git a/examples/Example_Laplacian_solver.cc b/examples/Example_Laplacian_solver.cc index 9a584c0f..77313052 100644 --- a/examples/Example_Laplacian_solver.cc +++ b/examples/Example_Laplacian_solver.cc @@ -41,7 +41,7 @@ void SimpleConjugateGradient(LinearOperatorBase &HPDop,const Field &b, Fi return; } } - assert(0); + GRID_ASSERT(0); } diff --git a/examples/Example_Mobius_spectrum.cc b/examples/Example_Mobius_spectrum.cc index b604eec4..65b7b7de 100644 --- a/examples/Example_Mobius_spectrum.cc +++ b/examples/Example_Mobius_spectrum.cc @@ -115,8 +115,8 @@ void GaussianWallSource(GridParallelRNG &RNG,int tslice,LatticeGaugeField &U,Lat } void SequentialSource(int tslice,Coordinate &mom,LatticePropagator &spectator,LatticePropagator &source) { - assert(mom.size()==Nd); - assert(mom[Tdir] == 0); + GRID_ASSERT(mom.size()==Nd); + GRID_ASSERT(mom[Tdir] == 0); GridBase * grid = spectator.Grid(); diff --git a/examples/Example_christoph.cc b/examples/Example_christoph.cc index f8d83fa4..140491db 100644 --- a/examples/Example_christoph.cc +++ b/examples/Example_christoph.cc @@ -119,8 +119,8 @@ void GaussianWallSource(GridParallelRNG &RNG,int tslice,LatticeGaugeField &U,Lat } void SequentialSource(int tslice,Coordinate &mom,LatticePropagator &spectator,LatticePropagator &source) { - assert(mom.size()==Nd); - assert(mom[Tdir] == 0); + GRID_ASSERT(mom.size()==Nd); + GRID_ASSERT(mom[Tdir] == 0); GridBase * grid = spectator.Grid(); diff --git a/examples/Example_wall_wall_3pt.cc b/examples/Example_wall_wall_3pt.cc index ac8d44bb..52f9cf42 100644 --- a/examples/Example_wall_wall_3pt.cc +++ b/examples/Example_wall_wall_3pt.cc @@ -157,8 +157,8 @@ void GaussianWallSource(GridParallelRNG &RNG,int tslice,LatticeGaugeField &U,Lat } void SequentialSource(int tslice,Coordinate &mom,LatticePropagator &spectator,LatticePropagator &source) { - assert(mom.size()==Nd); - assert(mom[Tdir] == 0); + GRID_ASSERT(mom.size()==Nd); + GRID_ASSERT(mom[Tdir] == 0); GridBase * grid = spectator.Grid(); @@ -331,7 +331,7 @@ void WallSinkMesonTrace(std::string file,std::vector &q1,std::vector int make_idx(int p, int m,int nmom) { if (m==0) return p; - assert(p==0); + GRID_ASSERT(p==0); return nmom + m - 1; } diff --git a/examples/Example_wall_wall_spectrum.cc b/examples/Example_wall_wall_spectrum.cc index d4914213..97ae1e06 100644 --- a/examples/Example_wall_wall_spectrum.cc +++ b/examples/Example_wall_wall_spectrum.cc @@ -157,8 +157,8 @@ void GaussianWallSource(GridParallelRNG &RNG,int tslice,LatticeGaugeField &U,Lat } void SequentialSource(int tslice,Coordinate &mom,LatticePropagator &spectator,LatticePropagator &source) { - assert(mom.size()==Nd); - assert(mom[Tdir] == 0); + GRID_ASSERT(mom.size()==Nd); + GRID_ASSERT(mom[Tdir] == 0); GridBase * grid = spectator.Grid(); diff --git a/systems/Aurora/config-command b/systems/Aurora/config-command index 500b2866..bfa48c0f 100644 --- a/systems/Aurora/config-command +++ b/systems/Aurora/config-command @@ -2,7 +2,7 @@ export MPFR=`spack find --paths mpfr | grep ^mpfr | awk '{print $2}' ` export GMP=`spack find --paths gmp | grep ^gmp | awk '{print $2}' ` export CLIME=`spack find --paths c-lime | grep ^c-lime | awk '{print $2}' ` export UNWIND=`spack find --paths libunwind | grep ^libunwind | awk '{print $2}' ` - +export HDF5=/opt/cray/pe/hdf5/1.12.2.3/gnu/9.1 ../../configure \ --enable-simd=GPU \ --enable-gen-simd-width=64 \ @@ -16,6 +16,7 @@ export UNWIND=`spack find --paths libunwind | grep ^libunwind | awk '{print $2 --enable-accelerator-aware-mpi=no \ --enable-unified=no \ --with-lime=$CLIME \ + --with-hdf5=${HDF5} \ --with-gmp=$GMP \ --with-mpfr=$MPFR \ --with-unwind=$UNWIND \ diff --git a/systems/Aurora/tests/reproBigJob.pbs b/systems/Aurora/tests/reproBigJob.pbs index 1d880f0d..d455c590 100644 --- a/systems/Aurora/tests/reproBigJob.pbs +++ b/systems/Aurora/tests/reproBigJob.pbs @@ -1,30 +1,21 @@ #!/bin/bash #PBS -l select=32 -#PBS -q EarlyAppAccess +#PBS -q prod #PBS -A LatticeQCD_aesp_CNDA #PBS -l walltime=02:00:00 #PBS -N reproBigJob #PBS -k doe +#PBS -l filesystems=flare +#PBS -l filesystems=home #export OMP_PROC_BIND=spread #unset OMP_PLACES -#module load oneapi/eng-compiler/2023.05.15.003 -#module load mpich/51.2/icc-all-deterministic-pmix-gpu # 56 cores / 6 threads ~9 export OMP_NUM_THREADS=6 -export MPIR_CVAR_CH4_OFI_ENABLE_GPU_PIPELINE=1 -export MPIR_CVAR_CH4_OFI_GPU_PIPELINE_D2H_ENGINE_TYPE=0 -export MPIR_CVAR_CH4_OFI_GPU_PIPELINE_H2D_ENGINE_TYPE=0 -export MPIR_CVAR_CH4_OFI_GPU_PIPELINE_BUFFER_SZ=10485760 -export MPIR_CVAR_CH4_OFI_GPU_PIPELINE_THRESHOLD=131072 -export MPIR_CVAR_CH4_OFI_GPU_PIPELINE_NUM_BUFFERS_PER_CHUNK=16 -export MPIR_CVAR_CH4_OFI_GPU_PIPELINE_MAX_NUM_BUFFERS=16 -#export MPIR_CVAR_GPU_USE_IMMEDIATE_COMMAND_LIST=1 -#export SYCL_PI_LEVEL_ZERO_USE_IMMEDIATE_COMMANDLISTS=1 export SYCL_PI_LEVEL_ZERO_USE_COPY_ENGINE=1 export SYCL_PI_LEVEL_ZERO_USE_COPY_ENGINE_FOR_D2D_COPY=1 export SYCL_PROGRAM_COMPILE_OPTIONS="-ze-opt-large-register-file" @@ -33,17 +24,12 @@ export GRID_PRINT_ENTIRE_LOG=0 export GRID_CHECKSUM_RECV_BUF=0 export GRID_CHECKSUM_SEND_BUF=0 -export MPICH_OFI_NIC_POLICY=GPU - -#export MPIR_CVAR_ALLREDUCE_DEVICE_COLLECTIVE=0 -#export MPIR_CVAR_REDUCE_DEVICE_COLLECTIVE=0 -#export MPIR_CVAR_ALLREDUCE_INTRA_ALGORITHM=recursive_doubling -#unset MPIR_CVAR_CH4_COLL_SELECTION_TUNING_JSON_FILE -#unset MPIR_CVAR_COLL_SELECTION_TUNING_JSON_FILE -#unset MPIR_CVAR_CH4_POSIX_COLL_SELECTION_TUNING_JSON_FILE cd $PBS_O_WORKDIR +source ../source.sh + + cp $PBS_NODEFILE nodefile DIR=reproBigJob.$PBS_JOBID @@ -58,17 +44,17 @@ BINARY=../Test_dwf_mixedcg_prec echo > pingjob < command-line env > environment $CMD -grep Oops Grid.stderr.* > failures.$PBS_JOBID -rm core.* +grep Oops */Grid.stderr.* > failures.$PBS_JOBID + diff --git a/tests/IO/Test_field_array_io.cc b/tests/IO/Test_field_array_io.cc index 51ea7893..b186b42f 100644 --- a/tests/IO/Test_field_array_io.cc +++ b/tests/IO/Test_field_array_io.cc @@ -103,7 +103,7 @@ template void readFieldArray(std::vector &data, const std::string &file){ typedef typename FieldType::vector_object vobj; typedef typename FieldType::scalar_object sobj; - assert(data.size() > 0); + GRID_ASSERT(data.size() > 0); GridBase* grid = data[0].Grid(); //assume all fields have the same Grid BinarySimpleUnmunger munge; //straight copy @@ -113,7 +113,7 @@ void readFieldArray(std::vector &data, const std::string &file){ std::cout << "Data offset read " << offset << std::endl; std::cout << "Data size read " << hdr_size << std::endl; - assert(data.size() == hdr_size); + GRID_ASSERT(data.size() == hdr_size); uint64_t field_size = uint64_t(grid->gSites()) * sizeof(sobj); @@ -132,7 +132,7 @@ void readFieldArray(std::vector &data, const std::string &file){ std::cout << "Read checksum " << checksum << std::endl; - assert( hdr_checksum == checksum ); + GRID_ASSERT( hdr_checksum == checksum ); } diff --git a/tests/IO/Test_openqcd_io.cc b/tests/IO/Test_openqcd_io.cc index 765509a9..e9797e77 100644 --- a/tests/IO/Test_openqcd_io.cc +++ b/tests/IO/Test_openqcd_io.cc @@ -61,7 +61,7 @@ int main(int argc, char** argv) { if(GridCmdOptionExists(argv, argv + argc, "--config")) { file = GridCmdOptionPayload(argv, argv + argc, "--config"); std::cout << "file: " << file << std::endl; - assert(!file.empty()); + GRID_ASSERT(!file.empty()); } OpenQcdIOChromaReference::readConfiguration(Umu_ref, header_ref, file); diff --git a/tests/Test_compressed_lanczos_hot_start.cc b/tests/Test_compressed_lanczos_hot_start.cc index fc7775dd..1282c9e8 100644 --- a/tests/Test_compressed_lanczos_hot_start.cc +++ b/tests/Test_compressed_lanczos_hot_start.cc @@ -56,7 +56,7 @@ public: void checkpointFine(std::string evecs_file,std::string evals_file) { #ifdef HAVE_LIME - assert(this->subspace.size()==nbasis); + GRID_ASSERT(this->subspace.size()==nbasis); emptyUserRecord record; Grid::ScidacWriter WR(this->_FineGrid->IsBoss()); WR.open(evecs_file); @@ -68,7 +68,7 @@ public: XmlWriter WRx(evals_file); write(WRx,"evals",this->evals_fine); #else - assert(0); + GRID_ASSERT(0); #endif } @@ -82,7 +82,7 @@ public: XmlReader RDx(evals_file); read(RDx,"evals",this->evals_fine); - assert(this->evals_fine.size()==nbasis); + GRID_ASSERT(this->evals_fine.size()==nbasis); std::cout << GridLogIRL<< "checkpointFineRestore: Reading evecs from "<evals_coarse); #else - assert(0); + GRID_ASSERT(0); #endif } @@ -128,7 +128,7 @@ public: XmlReader RDx(evals_file); read(RDx,"evals",this->evals_coarse); - assert(this->evals_coarse.size()==nvec); + GRID_ASSERT(this->evals_coarse.size()==nvec); emptyUserRecord record; std::cout << GridLogIRL<< "checkpointCoarseRestore: Reading evecs from "< fineLatt = latt; int dims=fineLatt.size(); - assert(blockSize.size()==dims+1); + GRID_ASSERT(blockSize.size()==dims+1); std::vector coarseLatt(dims); std::vector coarseLatt5d ; for (int d=0;d= Nm1); + GRID_ASSERT(Nm2 >= Nm1); const int nbasis= 60; - assert(nbasis==Ns1); + GRID_ASSERT(nbasis==Ns1); LocalCoherenceLanczosScidac _LocalCoherenceLanczos(FrbGrid,CoarseGrid5,HermOp,Odd); std::cout << GridLogMessage << "Constructed LocalCoherenceLanczos" << std::endl; - assert( (Params.doFine)||(Params.doFineRead)); + GRID_ASSERT( (Params.doFine)||(Params.doFineRead)); if ( Params.doFine ) { std::cout << GridLogMessage << "Performing fine grid IRL Nstop "<< Ns1 << " Nk "<Broadcast(0,(void *)&now,sizeof(now)); i++; @@ -218,7 +218,7 @@ int main (int argc, char ** argv) RealD diff = axpy_norm(diff_o, -1.0, result_o, result_o_2); std::cout << GridLogMessage << "::::::::::::: Diff between mixed and regular CG: " << diff << std::endl; - assert(diff < 1e-4); + GRID_ASSERT(diff < 1e-4); Grid_finalize(); } diff --git a/tests/Test_innerproduct_norm.cc b/tests/Test_innerproduct_norm.cc index a8718c6b..dc4d6c0c 100644 --- a/tests/Test_innerproduct_norm.cc +++ b/tests/Test_innerproduct_norm.cc @@ -84,8 +84,8 @@ int main(int argc, char** argv) { std::cout << GridLogMessage << "Double: time_ref = " << sw_ref.Elapsed() << " time_res = " << sw_res.Elapsed() << std::endl; // clang-format on - assert(diff_ip_d == 0.); - assert(diff_norm2_d == 0.); + GRID_ASSERT(diff_ip_d == 0.); + GRID_ASSERT(diff_norm2_d == 0.); std::cout << GridLogMessage << "Double: all checks passed" << std::endl; } @@ -116,8 +116,8 @@ int main(int argc, char** argv) { std::cout << GridLogMessage << "Single: time_ref = " << sw_ref.Elapsed() << " time_res = " << sw_res.Elapsed() << std::endl; // clang-format on - assert(diff_ip_f == 0.); - assert(diff_norm2_f == 0.); + GRID_ASSERT(diff_ip_f == 0.); + GRID_ASSERT(diff_norm2_f == 0.); std::cout << GridLogMessage << "Single: all checks passed" << std::endl; } diff --git a/tests/Test_simd.cc b/tests/Test_simd.cc index 16205ee1..d8cd1dd6 100644 --- a/tests/Test_simd.cc +++ b/tests/Test_simd.cc @@ -175,7 +175,7 @@ void Tester(const functor &func) } else { std::cout< @@ -234,7 +234,7 @@ void IntTester(const functor &func) } else { std::cout<= 5); + GRID_ASSERT(argc >= 5); Coordinate latt(4,0); latt[0] = toint(argv[1]); diff --git a/tests/core/Test_compact_wilson_clover_speedup.cc b/tests/core/Test_compact_wilson_clover_speedup.cc index d09b4c1d..8aa15026 100644 --- a/tests/core/Test_compact_wilson_clover_speedup.cc +++ b/tests/core/Test_compact_wilson_clover_speedup.cc @@ -205,7 +205,7 @@ void runBenchmark(int* argc, char*** argv) { double secs_res = (t5-t4)/1e6; \ grid_printf_msg("Performance(%35s, %s): %2.4f s, %6.0f GFlop/s, %6.0f GByte/s, speedup vs ref = %.2f, fraction of hop = %.2f\n", \ "compact_"#KERNEL, precision.c_str(), secs_res, clov_gflop_total/secs_res, clov_gbyte_total/secs_res, secs_ref/secs_res, secs_res/secs_hop); \ - assert(resultsAgree(ref, res, #KERNEL)); \ + GRID_ASSERT(resultsAgree(ref, res, #KERNEL)); \ } BENCH_CLOVER_KERNEL(Mooee); diff --git a/tests/core/Test_fft.cc b/tests/core/Test_fft.cc index 16ee5a0f..23509b98 100644 --- a/tests/core/Test_fft.cc +++ b/tests/core/Test_fft.cc @@ -279,7 +279,7 @@ int main (int argc, char ** argv) result5 = result5 - Kinetic; std::cout<<"diff "<< norm2(result5)<> alpha; } } diff --git a/tests/core/Test_lie_generators.cc b/tests/core/Test_lie_generators.cc index 7792b743..2250747e 100644 --- a/tests/core/Test_lie_generators.cc +++ b/tests/core/Test_lie_generators.cc @@ -171,7 +171,7 @@ int main(int argc, char** argv) { Complex tr2 = TRa()()(b,c) * Complex(0,1); std::cout << " 2 Tr( Tc[Ta,Tb]) " << 2.0*tr1<oSites(),1,{ - // assert(B[v]==A_v[ss]()()().getlane(0)); + // GRID_ASSERT(B[v]==A_v[ss]()()().getlane(0)); }); // std::cout << "["<oSites(),{ - assert(B[v]==A_v[ss]()()().getlane(0)); + GRID_ASSERT(B[v]==A_v[ss]()()().getlane(0)); }); // std::cout << "["< inline void sliceSumCPU(const Grid::Lattice &Data,std typedef typename vobj::scalar_object sobj; typedef typename vobj::scalar_object::scalar_type scalar_type; GridBase *grid = Data.Grid(); - assert(grid!=NULL); + GRID_ASSERT(grid!=NULL); const int Nd = grid->_ndimension; const int Nsimd = grid->Nsimd(); - assert(orthogdim >= 0); - assert(orthogdim < Nd); + GRID_ASSERT(orthogdim >= 0); + GRID_ASSERT(orthogdim < Nd); int fd=grid->_fdimensions[orthogdim]; int ld=grid->_ldimensions[orthogdim]; @@ -134,7 +134,7 @@ int main (int argc, char ** argv) { for(int t=0;t LinearOperatorBase & wrapped; public: HermOpAdaptor(LinearOperatorBase &wrapme) : wrapped(wrapme) {}; - void OpDiag (const Field &in, Field &out) { assert(0); } - void OpDir (const Field &in, Field &out,int dir,int disp) { assert(0); } - void OpDirAll (const Field &in, std::vector &out){ assert(0); }; + void OpDiag (const Field &in, Field &out) { GRID_ASSERT(0); } + void OpDir (const Field &in, Field &out,int dir,int disp) { GRID_ASSERT(0); } + void OpDirAll (const Field &in, std::vector &out){ GRID_ASSERT(0); }; void Op (const Field &in, Field &out){ wrapped.HermOp(in,out); } void AdjOp (const Field &in, Field &out){ wrapped.HermOp(in,out); } - void HermOpAndNorm(const Field &in, Field &out,RealD &n1,RealD &n2){ assert(0); } + void HermOpAndNorm(const Field &in, Field &out,RealD &n1,RealD &n2){ GRID_ASSERT(0); } void HermOp(const Field &in, Field &out){ wrapped.HermOp(in,out); } @@ -286,7 +286,7 @@ int main (int argc, char ** argv) chi=chi-Aphi; RealD diff =norm2(chi); std::cout << r << " diff " << diff< &out) { assert(0); }; - void HermOpAndNorm(const Field &in, Field &out,RealD &n1,RealD &n2){ assert(0); } + void OpDiag (const Field &in, Field &out) { GRID_ASSERT(0); } + void OpDir (const Field &in, Field &out,int dir,int disp) { GRID_ASSERT(0); } + void OpDirAll (const Field &in, std::vector &out) { GRID_ASSERT(0); }; + void HermOpAndNorm(const Field &in, Field &out,RealD &n1,RealD &n2){ GRID_ASSERT(0); } }; template class CGSmoother : public LinearFunction diff --git a/tests/debug/Test_general_coarse_hdcg_phys.cc b/tests/debug/Test_general_coarse_hdcg_phys.cc index 3ec42fad..88118173 100644 --- a/tests/debug/Test_general_coarse_hdcg_phys.cc +++ b/tests/debug/Test_general_coarse_hdcg_phys.cc @@ -40,7 +40,7 @@ void SaveOperator(Coarsened &Operator,std::string file) #ifdef HAVE_LIME emptyUserRecord record; ScidacWriter WR(Operator.Grid()->IsBoss()); - assert(Operator._A.size()==Operator.geom.npoint); + GRID_ASSERT(Operator._A.size()==Operator.geom.npoint); WR.open(file); for(int p=0;p &out) { assert(0); }; - void HermOpAndNorm(const Field &in, Field &out,RealD &n1,RealD &n2){ assert(0); } + void OpDiag (const Field &in, Field &out) { GRID_ASSERT(0); } + void OpDir (const Field &in, Field &out,int dir,int disp) { GRID_ASSERT(0); } + void OpDirAll (const Field &in, std::vector &out) { GRID_ASSERT(0); }; + void HermOpAndNorm(const Field &in, Field &out,RealD &n1,RealD &n2){ GRID_ASSERT(0); } }; /* template class ChebyshevSmoother : public LinearFunction diff --git a/tests/debug/Test_general_coarse_hdcg_phys48.cc b/tests/debug/Test_general_coarse_hdcg_phys48.cc index 20772eb5..5383ff60 100644 --- a/tests/debug/Test_general_coarse_hdcg_phys48.cc +++ b/tests/debug/Test_general_coarse_hdcg_phys48.cc @@ -44,7 +44,7 @@ void SaveOperator(Coarsened &Operator,std::string file) #ifdef HAVE_LIME emptyUserRecord record; ScidacWriter WR(Operator.Grid()->IsBoss()); - assert(Operator._A.size()==Operator.geom.npoint); + GRID_ASSERT(Operator._A.size()==Operator.geom.npoint); WR.open(file); for(int p=0;p &eval, Grid::ScidacReader RD ; RD.open(evec_file); - assert(evec.size()==eval.size()); + GRID_ASSERT(evec.size()==eval.size()); for(int k=0;k &out) { assert(0); }; - void HermOpAndNorm(const Field &in, Field &out,RealD &n1,RealD &n2){ assert(0); } + void OpDiag (const Field &in, Field &out) { GRID_ASSERT(0); } + void OpDir (const Field &in, Field &out,int dir,int disp) { GRID_ASSERT(0); } + void OpDirAll (const Field &in, std::vector &out) { GRID_ASSERT(0); }; + void HermOpAndNorm(const Field &in, Field &out,RealD &n1,RealD &n2){ GRID_ASSERT(0); } }; template class CGSmoother : public LinearFunction diff --git a/tests/debug/Test_general_coarse_hdcg_phys48_blockcg.cc b/tests/debug/Test_general_coarse_hdcg_phys48_blockcg.cc index 4a7890f4..722253ea 100644 --- a/tests/debug/Test_general_coarse_hdcg_phys48_blockcg.cc +++ b/tests/debug/Test_general_coarse_hdcg_phys48_blockcg.cc @@ -148,7 +148,7 @@ void LoadEigenvectors(std::vector &eval, Grid::ScidacReader RD ; RD.open(evec_file); - assert(evec.size()==eval.size()); + GRID_ASSERT(evec.size()==eval.size()); for(int k=0;k &out) { assert(0); }; - void HermOpAndNorm(const Field &in, Field &out,RealD &n1,RealD &n2){ assert(0); } + void OpDiag (const Field &in, Field &out) { GRID_ASSERT(0); } + void OpDir (const Field &in, Field &out,int dir,int disp) { GRID_ASSERT(0); } + void OpDirAll (const Field &in, std::vector &out) { GRID_ASSERT(0); }; + void HermOpAndNorm(const Field &in, Field &out,RealD &n1,RealD &n2){ GRID_ASSERT(0); } }; template class FixedCGPolynomial : public LinearFunction diff --git a/tests/debug/Test_general_coarse_hdcg_phys48_lanczos.cc b/tests/debug/Test_general_coarse_hdcg_phys48_lanczos.cc index 240c2d6b..6ac65c5f 100644 --- a/tests/debug/Test_general_coarse_hdcg_phys48_lanczos.cc +++ b/tests/debug/Test_general_coarse_hdcg_phys48_lanczos.cc @@ -148,7 +148,7 @@ void LoadEigenvectors(std::vector &eval, Grid::ScidacReader RD ; RD.open(evec_file); - assert(evec.size()==eval.size()); + GRID_ASSERT(evec.size()==eval.size()); for(int k=0;k &out) { assert(0); }; - void HermOpAndNorm(const Field &in, Field &out,RealD &n1,RealD &n2){ assert(0); } + void OpDiag (const Field &in, Field &out) { GRID_ASSERT(0); } + void OpDir (const Field &in, Field &out,int dir,int disp) { GRID_ASSERT(0); } + void OpDirAll (const Field &in, std::vector &out) { GRID_ASSERT(0); }; + void HermOpAndNorm(const Field &in, Field &out,RealD &n1,RealD &n2){ GRID_ASSERT(0); } }; template class FixedCGPolynomial : public LinearFunction diff --git a/tests/debug/Test_general_coarse_hdcg_phys48_lanczos_subspace.cc b/tests/debug/Test_general_coarse_hdcg_phys48_lanczos_subspace.cc index 6efe53bd..77f1b091 100644 --- a/tests/debug/Test_general_coarse_hdcg_phys48_lanczos_subspace.cc +++ b/tests/debug/Test_general_coarse_hdcg_phys48_lanczos_subspace.cc @@ -119,7 +119,7 @@ void LoadEigenvectors(std::vector &eval, Grid::ScidacReader RD ; RD.open(evec_file); - assert(evec.size()==eval.size()); + GRID_ASSERT(evec.size()==eval.size()); for(int k=0;k &out) { assert(0); }; - void HermOpAndNorm(const Field &in, Field &out,RealD &n1,RealD &n2){ assert(0); } + void OpDiag (const Field &in, Field &out) { GRID_ASSERT(0); } + void OpDir (const Field &in, Field &out,int dir,int disp) { GRID_ASSERT(0); } + void OpDirAll (const Field &in, std::vector &out) { GRID_ASSERT(0); }; + void HermOpAndNorm(const Field &in, Field &out,RealD &n1,RealD &n2){ GRID_ASSERT(0); } }; template class CGSmoother : public LinearFunction diff --git a/tests/debug/Test_general_coarse_hdcg_phys48_mixed.cc b/tests/debug/Test_general_coarse_hdcg_phys48_mixed.cc index 054b4c66..fb806bf2 100644 --- a/tests/debug/Test_general_coarse_hdcg_phys48_mixed.cc +++ b/tests/debug/Test_general_coarse_hdcg_phys48_mixed.cc @@ -92,7 +92,7 @@ void LoadEigenvectors(std::vector &eval, Grid::ScidacReader RD ; RD.open(evec_file); - assert(evec.size()==eval.size()); + GRID_ASSERT(evec.size()==eval.size()); for(int k=0;k &out) { assert(0); }; - void HermOpAndNorm(const Field &in, Field &out,RealD &n1,RealD &n2){ assert(0); } + void OpDiag (const Field &in, Field &out) { GRID_ASSERT(0); } + void OpDir (const Field &in, Field &out,int dir,int disp) { GRID_ASSERT(0); } + void OpDirAll (const Field &in, std::vector &out) { GRID_ASSERT(0); }; + void HermOpAndNorm(const Field &in, Field &out,RealD &n1,RealD &n2){ GRID_ASSERT(0); } }; template class CGSmoother : public LinearFunction diff --git a/tests/debug/Test_general_coarse_hdcg_phys96_mixed.cc b/tests/debug/Test_general_coarse_hdcg_phys96_mixed.cc index c45b2cb1..abfb0afe 100644 --- a/tests/debug/Test_general_coarse_hdcg_phys96_mixed.cc +++ b/tests/debug/Test_general_coarse_hdcg_phys96_mixed.cc @@ -92,7 +92,7 @@ void LoadEigenvectors(std::vector &eval, Grid::ScidacReader RD ; RD.open(evec_file); - assert(evec.size()==eval.size()); + GRID_ASSERT(evec.size()==eval.size()); for(int k=0;k &out) { assert(0); }; - void HermOpAndNorm(const Field &in, Field &out,RealD &n1,RealD &n2){ assert(0); } + void OpDiag (const Field &in, Field &out) { GRID_ASSERT(0); } + void OpDir (const Field &in, Field &out,int dir,int disp) { GRID_ASSERT(0); } + void OpDirAll (const Field &in, std::vector &out) { GRID_ASSERT(0); }; + void HermOpAndNorm(const Field &in, Field &out,RealD &n1,RealD &n2){ GRID_ASSERT(0); } }; template class CGSmoother : public LinearFunction diff --git a/tests/debug/Test_general_coarse_pvdagm.cc b/tests/debug/Test_general_coarse_pvdagm.cc index 096574d0..7c3db4ea 100644 --- a/tests/debug/Test_general_coarse_pvdagm.cc +++ b/tests/debug/Test_general_coarse_pvdagm.cc @@ -43,9 +43,9 @@ class PVdagMLinearOperator : public LinearOperatorBase { public: PVdagMLinearOperator(Matrix &Mat,Matrix &PV): _Mat(Mat),_PV(PV){}; - void OpDiag (const Field &in, Field &out) { assert(0); } - void OpDir (const Field &in, Field &out,int dir,int disp) { assert(0); } - void OpDirAll (const Field &in, std::vector &out){ assert(0); }; + void OpDiag (const Field &in, Field &out) { GRID_ASSERT(0); } + void OpDir (const Field &in, Field &out,int dir,int disp) { GRID_ASSERT(0); } + void OpDirAll (const Field &in, std::vector &out){ GRID_ASSERT(0); }; void Op (const Field &in, Field &out){ // std::cout << "Op: PVdag M "< { public: ShiftedPVdagMLinearOperator(RealD _shift,Matrix &Mat,Matrix &PV): shift(_shift),_Mat(Mat),_PV(PV){}; - void OpDiag (const Field &in, Field &out) { assert(0); } - void OpDir (const Field &in, Field &out,int dir,int disp) { assert(0); } - void OpDirAll (const Field &in, std::vector &out){ assert(0); }; + void OpDiag (const Field &in, Field &out) { GRID_ASSERT(0); } + void OpDir (const Field &in, Field &out,int dir,int disp) { GRID_ASSERT(0); } + void OpDirAll (const Field &in, std::vector &out){ GRID_ASSERT(0); }; void Op (const Field &in, Field &out){ // std::cout << "Op: PVdag M "< &action,LatticeGaugeField & U,MomentumF std::cout<< GridLogMessage << "dSpred : "<< dSpred.real() < &action,LatticeGaugeField & U,MomentumF std::cout<< GridLogMessage << "dSpred : "<< dSpred.real() < &action,ConfigurationBaseFullDimensions()[nu]; int L_1f = UGrid_1f->FullDimensions()[nu]; - assert(L_1f == 2 * L_2f); + GRID_ASSERT(L_1f == 2 * L_2f); //Coordinate grid for reference LatticeInteger xcoor_1f(UGrid_1f); @@ -73,7 +73,7 @@ void convertFermion1f_from_2f(FermionField1f &out_1f, const FermionField2f &in_2 Integer L_2f = FGrid_2f->FullDimensions()[nu+nuoff]; Integer L_1f = FGrid_1f->FullDimensions()[nu+nuoff]; - assert(L_1f == 2 * L_2f); + GRID_ASSERT(L_1f == 2 * L_2f); auto in_f0_2fgrid = PeekIndex(in_2f,0); //flavor 0 on 2f Grid FermionField1f in_f0_1fgrid(FGrid_1f); @@ -442,7 +442,7 @@ int main (int argc, char ** argv) }else if(action == "DSDR"){ runTest(argc,argv); }else{ - assert(0); + GRID_ASSERT(0); } } diff --git a/tests/forces/Test_gpwilson_force.cc b/tests/forces/Test_gpwilson_force.cc index 8bd26a35..436ee6b0 100644 --- a/tests/forces/Test_gpwilson_force.cc +++ b/tests/forces/Test_gpwilson_force.cc @@ -152,7 +152,7 @@ int main (int argc, char ** argv) std::cout << GridLogMessage << "dS "<(&LinOpU); - assert(&(SchurOpU->_Mat)==&(LinOpD._Mat)); + GRID_ASSERT(&(SchurOpU->_Mat)==&(LinOpD._Mat)); precisionChange(FermOpF.Umu, FermOpD.Umu); @@ -210,14 +210,14 @@ int main (int argc, char** argv) std::cout << GridLogMessage << "Phi(double)=" << norm2(MeofaD.getPhi()) << " Phi(mixed)=" << norm2(MeofaMx.getPhi()) << " diff=" << n << std::endl; - assert(n < 1e-8); + GRID_ASSERT(n < 1e-8); RealD Sd = MeofaD.S(Ud); RealD Smx = MeofaMx.S(Ud); std::cout << GridLogMessage << "Initial action double=" << Sd << " mixed=" << Smx << " diff=" << Sd-Smx << std::endl; - assert(fabs(Sd-Smx) < 1e-6); + GRID_ASSERT(fabs(Sd-Smx) < 1e-6); SU::HotConfiguration(RNG4,Ud); precisionChange(Uf, Ud); @@ -227,7 +227,7 @@ int main (int argc, char** argv) std::cout << GridLogMessage << "After randomizing U, action double=" << Sd << " mixed=" << Smx << " diff=" << Sd-Smx << std::endl; - assert(fabs(Sd-Smx) < 1e-6); + GRID_ASSERT(fabs(Sd-Smx) < 1e-6); std::cout << GridLogMessage << "Done" << std::endl; Grid_finalize(); diff --git a/tests/forces/Test_mobius_gpforce_eofa.cc b/tests/forces/Test_mobius_gpforce_eofa.cc index c0b7117a..c668780a 100644 --- a/tests/forces/Test_mobius_gpforce_eofa.cc +++ b/tests/forces/Test_mobius_gpforce_eofa.cc @@ -167,7 +167,7 @@ int main (int argc, char** argv) printf("real(dS_predict) = %1.15e\n", dSpred.real()); printf("imag(dS_predict) = %1.15e\n\n", dSpred.imag()); - assert( fabs(real(Sprime-S-dSpred)) < 1.0 ) ; + GRID_ASSERT( fabs(real(Sprime-S-dSpred)) < 1.0 ) ; std::cout << GridLogMessage << "Done" << std::endl; Grid_finalize(); diff --git a/tests/forces/Test_partfrac_force.cc b/tests/forces/Test_partfrac_force.cc index 173f7626..7d6fc2c2 100644 --- a/tests/forces/Test_partfrac_force.cc +++ b/tests/forces/Test_partfrac_force.cc @@ -149,7 +149,7 @@ int main (int argc, char ** argv) std::cout << GridLogMessage << "dS "<subspace.size()==nbasis); + GRID_ASSERT(this->subspace.size()==nbasis); emptyUserRecord record; Grid::ScidacWriter WR(this->_FineGrid->IsBoss()); WR.open(evecs_file); @@ -79,7 +79,7 @@ public: XmlReader RDx(evals_file); read(RDx,"evals",this->evals_fine); - assert(this->evals_fine.size()==nbasis); + GRID_ASSERT(this->evals_fine.size()==nbasis); std::cout << GridLogIRL<< "checkpointFineRestore: Reading evecs from "<evals_coarse); - assert(this->evals_coarse.size()==nvec); + GRID_ASSERT(this->evals_coarse.size()==nvec); emptyUserRecord record; std::cout << GridLogIRL<< "checkpointCoarseRestore: Reading evecs from "<= Nm1); + GRID_ASSERT(Nm2 >= Nm1); const int nbasis= 60; - assert(nbasis==Ns1); + GRID_ASSERT(nbasis==Ns1); LocalCoherenceLanczosScidac _LocalCoherenceLanczos(FrbGrid,CoarseGrid5,HermOp,Odd); std::cout << GridLogMessage << "Constructed LocalCoherenceLanczos" << std::endl; - assert( (Params.doFine)||(Params.doFineRead)); + GRID_ASSERT( (Params.doFine)||(Params.doFineRead)); if ( Params.doFine ) { std::cout << GridLogMessage << "Performing fine grid IRL Nstop "<< Ns1 << " Nk "<subspace.size()==nbasis); + GRID_ASSERT(this->subspace.size()==nbasis); emptyUserRecord record; Grid::ScidacWriter WR(this->_FineGrid->IsBoss()); WR.open(evecs_file); @@ -122,7 +122,7 @@ public: XmlReader RDx(evals_file); read(RDx,"evals",this->evals_fine); - if(this->evals_fine.size() < nbasis) assert(0 && "Not enough fine evals to complete basis"); + if(this->evals_fine.size() < nbasis) GRID_ASSERT(0 && "Not enough fine evals to complete basis"); if(this->evals_fine.size() > nbasis){ //allow the use of precomputed evecs with a larger #evecs std::cout << GridLogMessage << "Truncating " << this->evals_fine.size() << " evals to basis size " << nbasis << std::endl; this->evals_fine.resize(nbasis); @@ -164,7 +164,7 @@ public: XmlReader RDx(evals_file); read(RDx,"evals",this->evals_coarse); - assert(this->evals_coarse.size()==nvec); + GRID_ASSERT(this->evals_coarse.size()==nvec); emptyUserRecord record; std::cout << GridLogIRL<< "checkpointCoarseRestore: Reading evecs from "< dirs4(4); for(int i=0;i<3;i++) dirs4[i] = opt.GparityDirs[i]; dirs4[3] = 0; //periodic gauge BC in time @@ -273,14 +273,14 @@ void runTest(const Options &opt){ auto fineLatt = GridDefaultLatt(); Coordinate coarseLatt(4); for (int d=0;d<4;d++){ - coarseLatt[d] = fineLatt[d]/opt.blockSize[d]; assert(coarseLatt[d]*opt.blockSize[d]==fineLatt[d]); + coarseLatt[d] = fineLatt[d]/opt.blockSize[d]; GRID_ASSERT(coarseLatt[d]*opt.blockSize[d]==fineLatt[d]); } std::cout << GridLogMessage<< " 5d coarse lattice is "; for (int i=0;i<4;i++){ std::cout << coarseLatt[i]<<"x"; } - int cLs = opt.Ls/opt.blockSize[4]; assert(cLs*opt.blockSize[4]==opt.Ls); + int cLs = opt.Ls/opt.blockSize[4]; GRID_ASSERT(cLs*opt.blockSize[4]==opt.Ls); std::cout << cLs<= fine.N_true_get); + GRID_ASSERT(coarse.N_true_get >= fine.N_true_get); - assert(nbasis<=fine.N_true_get); + GRID_ASSERT(nbasis<=fine.N_true_get); LocalCoherenceLanczosScidac _LocalCoherenceLanczos(FrbGrid,CoarseGrid5,SchurOp,Odd); std::cout << GridLogMessage << "Constructed LocalCoherenceLanczos" << std::endl; @@ -411,7 +411,7 @@ int main (int argc, char ** argv) } opt.config = argv[1]; GridCmdOptionIntVector(argv[2], opt.GparityDirs); - assert(opt.GparityDirs.size() == 3); + GRID_ASSERT(opt.GparityDirs.size() == 3); for(int i=3;i(opt); break; default: std::cout << GridLogMessage << "Unsupported basis size " << basis_size << std::endl; - assert(0); + GRID_ASSERT(0); } Grid_finalize(); diff --git a/tests/lanczos/Test_dwf_G5R5.cc b/tests/lanczos/Test_dwf_G5R5.cc index 3cda760a..f0c65495 100644 --- a/tests/lanczos/Test_dwf_G5R5.cc +++ b/tests/lanczos/Test_dwf_G5R5.cc @@ -386,7 +386,7 @@ int main(int argc, char** argv) { } } - FILE *fp = fopen("lego-plot.py","w"); assert(fp!=NULL); + FILE *fp = fopen("lego-plot.py","w"); GRID_ASSERT(fp!=NULL); #define PYTHON_LINE(A) fprintf(fp,A"\n"); PYTHON_LINE("import matplotlib.pyplot as plt"); PYTHON_LINE("import numpy as np"); diff --git a/tests/lanczos/Test_dwf_block_lanczos.cc b/tests/lanczos/Test_dwf_block_lanczos.cc index 671f2fa6..64931417 100644 --- a/tests/lanczos/Test_dwf_block_lanczos.cc +++ b/tests/lanczos/Test_dwf_block_lanczos.cc @@ -95,13 +95,13 @@ void CmdJobParams::Parse(char **argv,int argc) if( GridCmdOptionExists(argv,argv+argc,"--phase") ){ arg = GridCmdOptionPayload(argv,argv+argc,"--phase"); pfile.open(arg); - assert(pfile); + GRID_ASSERT(pfile); expect = 0; while( pfile >> vstr ) { if ( vstr.compare("boundary_phase") == 0 ) { pfile >> vstr; GridCmdOptionInt(vstr,idx); - assert(expect==idx); + GRID_ASSERT(expect==idx); pfile >> vstr; GridCmdOptionFloat(vstr,re); pfile >> vstr; @@ -118,13 +118,13 @@ void CmdJobParams::Parse(char **argv,int argc) if( GridCmdOptionExists(argv,argv+argc,"--omega") ){ arg = GridCmdOptionPayload(argv,argv+argc,"--omega"); pfile.open(arg); - assert(pfile); + GRID_ASSERT(pfile); Ls = 0; while( pfile >> vstr ) { if ( vstr.compare("omega") == 0 ) { pfile >> vstr; GridCmdOptionInt(vstr,idx); - assert(Ls==idx); + GRID_ASSERT(Ls==idx); pfile >> vstr; GridCmdOptionFloat(vstr,re); pfile >> vstr; @@ -324,7 +324,7 @@ int main (int argc, char ** argv) std::cout << GridLogMessage << "mpi_layout= " << mpi_layout << std::endl; std::cout << GridLogMessage << "mpi_split= " << mpi_split << std::endl; std::cout << GridLogMessage << "mrhs= " << mrhs << std::endl; -// assert(JP.Nu==tmp); +// GRID_ASSERT(JP.Nu==tmp); ///////////////////////////////////////////// // Split into 1^4 mpi communicators, keeping it explicitly single diff --git a/tests/lanczos/Test_dwf_compressed_lanczos_reorg.cc b/tests/lanczos/Test_dwf_compressed_lanczos_reorg.cc index 7a84a465..973e9159 100644 --- a/tests/lanczos/Test_dwf_compressed_lanczos_reorg.cc +++ b/tests/lanczos/Test_dwf_compressed_lanczos_reorg.cc @@ -57,7 +57,7 @@ public: void checkpointFine(std::string evecs_file,std::string evals_file) { - assert(this->subspace.size()==nbasis); + GRID_ASSERT(this->subspace.size()==nbasis); emptyUserRecord record; Grid::ScidacWriter WR(this->_FineGrid->IsBoss()); WR.open(evecs_file); @@ -79,7 +79,7 @@ public: XmlReader RDx(evals_file); read(RDx,"evals",this->evals_fine); - assert(this->evals_fine.size()==nbasis); + GRID_ASSERT(this->evals_fine.size()==nbasis); std::cout << GridLogIRL<< "checkpointFineRestore: Reading evecs from "<evals_coarse); - assert(this->evals_coarse.size()==nvec); + GRID_ASSERT(this->evals_coarse.size()==nvec); emptyUserRecord record; std::cout << GridLogIRL<< "checkpointCoarseRestore: Reading evecs from "<= Nm1); + GRID_ASSERT(Nm2 >= Nm1); const int nbasis= 60; - assert(nbasis==Ns1); + GRID_ASSERT(nbasis==Ns1); LocalCoherenceLanczosScidac _LocalCoherenceLanczos(FrbGrid,CoarseGrid5,HermOp,Odd); std::cout << GridLogMessage << "Constructed LocalCoherenceLanczos" << std::endl; - assert( (Params.doFine)||(Params.doFineRead)); + GRID_ASSERT( (Params.doFine)||(Params.doFineRead)); if ( Params.doFine ) { std::cout << GridLogMessage << "Performing fine grid IRL Nstop "<< Ns1 << " Nk "< Cheby(alpha,beta,Npoly); FunctionHermOp ChebyOp(Cheby,_FineOp); PlainHermOp Op(_FineOp); @@ -269,19 +269,19 @@ int main (int argc, char ** argv) { Coordinate fineLatt = GridDefaultLatt(); int dims=fineLatt.size(); - assert(blockSize.size()==dims+1); + GRID_ASSERT(blockSize.size()==dims+1); Coordinate coarseLatt(dims); Coordinate coarseLatt5d ; for (int d=0;d= Nm1); + GRID_ASSERT(Nm2 >= Nm1); const int nbasis= 32; CoarseFineIRL IRL(FrbGrid,CoarseGrid5rb,HermOp,Odd); diff --git a/tests/lanczos/Test_evec_compression.cc b/tests/lanczos/Test_evec_compression.cc index 5ba1597c..b3b937d7 100644 --- a/tests/lanczos/Test_evec_compression.cc +++ b/tests/lanczos/Test_evec_compression.cc @@ -96,7 +96,7 @@ public: GridBase *FineGrid, GridBase *CoarseGrid){ int nevecs = evecs_in.size(); - assert(nevecs > nbasis); + GRID_ASSERT(nevecs > nbasis); //Construct the basis basis.resize(nbasis, FineGrid); @@ -273,7 +273,7 @@ struct Args{ GparityWilsonImplD::ImplParams setupGparityParams(const std::vector &GparityDirs){ //Setup G-parity BCs - assert(Nd == 4); + GRID_ASSERT(Nd == 4); std::vector dirs4(4); for(int i=0;i<3;i++) dirs4[i] = GparityDirs[i]; dirs4[3] = 0; //periodic gauge BC in time @@ -309,14 +309,14 @@ void run_b(ActionType &action, const std::string &config, const Args &args){ auto fineLatt = GridDefaultLatt(); Coordinate coarseLatt(4); for (int d=0;d<4;d++){ - coarseLatt[d] = fineLatt[d]/args.blockSize[d]; assert(coarseLatt[d]*args.blockSize[d]==fineLatt[d]); + coarseLatt[d] = fineLatt[d]/args.blockSize[d]; GRID_ASSERT(coarseLatt[d]*args.blockSize[d]==fineLatt[d]); } std::cout << GridLogMessage<< " 5d coarse lattice is "; for (int i=0;i<4;i++){ std::cout << coarseLatt[i]<<"x"; } - int cLs = args.Ls/args.blockSize[4]; assert(cLs*args.blockSize[4]==args.Ls); + int cLs = args.Ls/args.blockSize[4]; GRID_ASSERT(cLs*args.blockSize[4]==args.Ls); std::cout << cLs< Cheby(fine.getChebyParams()); FunctionHermOp ChebyOp(Cheby,SchurOp); PlainHermOp Op(SchurOp); @@ -386,7 +386,7 @@ void run_b(ActionType &action, const std::string &config, const Args &args){ int Nconv; IRL.calc(evals, evecs,src,Nconv,false); - if(Nconv < Nstop) assert(0 && "Fine lanczos failed to converge the required number of evecs"); //algorithm doesn't consider this a failure + if(Nconv < Nstop) GRID_ASSERT(0 && "Fine lanczos failed to converge the required number of evecs"); //algorithm doesn't consider this a failure if(Nconv > Nstop){ //Yes this potentially throws away some evecs but it is better than having a random number of evecs between Nstop and Nm! evals.resize(Nstop); @@ -430,7 +430,7 @@ void run_b(ActionType &action, const std::string &config, const Args &args){ Chebyshev smoother(fine.getChebyParams()); //Test the quality of the uncompressed evecs - assert( compressor.testCompression(SchurOp, smoother, basis, compressed_evecs, evals, fine.stop_rsd, args.coarse_relax_tol) ); + GRID_ASSERT( compressor.testCompression(SchurOp, smoother, basis, compressed_evecs, evals, fine.stop_rsd, args.coarse_relax_tol) ); } template @@ -453,7 +453,7 @@ void run(ActionType &action, const std::string &config, const Args &args){ case 400: return run_b<400>(action,config,args); default: - assert(0 && "Unsupported basis size: allowed values are 50,100,200,250,300,350,400"); + GRID_ASSERT(0 && "Unsupported basis size: allowed values are 50,100,200,250,300,350,400"); } } @@ -489,7 +489,7 @@ int main (int argc, char ** argv) { Args args; GridCmdOptionIntVector(argv[2], args.GparityDirs); - assert(args.GparityDirs.size() == 3); + GRID_ASSERT(args.GparityDirs.size() == 3); std::string action_s = "Mobius"; @@ -503,7 +503,7 @@ int main (int argc, char ** argv) { std::cout << GridLogMessage << "Set quark mass to " << args.mass << std::endl; }else if(sarg == "--block"){ GridCmdOptionIntVector(argv[i+1], args.blockSize); - assert(args.blockSize.size() == 5); + GRID_ASSERT(args.blockSize.size() == 5); std::cout << GridLogMessage << "Set block size to "; for(int q=0;q<5;q++) std::cout << args.blockSize[q] << " "; std::cout << std::endl; @@ -567,7 +567,7 @@ int main (int argc, char ** argv) { run(action, config, args); } #else - assert(0); + GRID_ASSERT(0); #endif }else{ WilsonImplD::ImplParams Params = setupParams(); diff --git a/tests/lanczos/Test_wilson_DWFKernel.cc b/tests/lanczos/Test_wilson_DWFKernel.cc index 30cbd1b3..8a1fb736 100644 --- a/tests/lanczos/Test_wilson_DWFKernel.cc +++ b/tests/lanczos/Test_wilson_DWFKernel.cc @@ -71,23 +71,23 @@ public: // Support for coarsening to a multigrid void OpDiag (const Field &in, Field &out) { - assert(0); + GRID_ASSERT(0); _Mat.Mdiag(in,out); } void OpDir (const Field &in, Field &out,int dir,int disp) { - assert(0); + GRID_ASSERT(0); _Mat.Mdir(in,out,dir,disp); } void OpDirAll (const Field &in, std::vector &out){ - assert(0); + GRID_ASSERT(0); _Mat.MdirAll(in,out); }; void Op (const Field &in, Field &out){ - assert(0); + GRID_ASSERT(0); _Mat.M(in,out); } void AdjOp (const Field &in, Field &out){ - assert(0); + GRID_ASSERT(0); _Mat.Mdag(in,out); } void HermOpAndNorm(const Field &in, Field &out,RealD &n1,RealD &n2){ diff --git a/tests/qdpxx/Test_qdpxx_munprec.cc b/tests/qdpxx/Test_qdpxx_munprec.cc index c6ce2800..734aa1db 100644 --- a/tests/qdpxx/Test_qdpxx_munprec.cc +++ b/tests/qdpxx/Test_qdpxx_munprec.cc @@ -387,7 +387,7 @@ public: Handle< LinearOperatorArray > M(S_f.linOp(fs)); return M; } - assert(0); + GRID_ASSERT(0); } static Chroma::Handle< Chroma::SystemSolver > GetSolver(QDP::multi1d &u, ChromaAction parms) @@ -745,7 +745,7 @@ void calc_grid(ChromaAction action,Grid::LatticeGaugeField & Umu, Grid::LatticeF return; } - assert(0); + GRID_ASSERT(0); } diff --git a/tests/qdpxx/Test_qdpxx_wilson.cc b/tests/qdpxx/Test_qdpxx_wilson.cc index 8ce28dca..e49b95d6 100644 --- a/tests/qdpxx/Test_qdpxx_wilson.cc +++ b/tests/qdpxx/Test_qdpxx_wilson.cc @@ -440,7 +440,7 @@ void calc_grid(ChromaAction action, Grid::LatticeGaugeField &Umu, Grid::LatticeF return; } - assert(0); + GRID_ASSERT(0); } int main(int argc, char **argv) diff --git a/tests/smearing/Test_WilsonFlow_adaptive.cc b/tests/smearing/Test_WilsonFlow_adaptive.cc index 23123eb9..48b64734 100644 --- a/tests/smearing/Test_WilsonFlow_adaptive.cc +++ b/tests/smearing/Test_WilsonFlow_adaptive.cc @@ -47,7 +47,7 @@ RealD interpolate(const RealD t_int, const std::vector > } else if(diff < tdiff2){ tdiff2 = diff; t2_idx = i; } } - assert(t1_idx != -1 && t2_idx != -1); + GRID_ASSERT(t1_idx != -1 && t2_idx != -1); RealD t2 = data[t2_idx].first, v2 = data[t2_idx].second; RealD t1 = data[t1_idx].first, v1 = data[t1_idx].second; diff --git a/tests/solver/Test_coarse_even_odd.cc b/tests/solver/Test_coarse_even_odd.cc index 60e5c372..f333e2c1 100644 --- a/tests/solver/Test_coarse_even_odd.cc +++ b/tests/solver/Test_coarse_even_odd.cc @@ -169,7 +169,7 @@ int main(int argc, char** argv) { std::cout << GridLogMessage << "norm2(Munprec), norm2(Dhop + Mdiag), abs. deviation, rel. deviation: " << norm2(ref) << " " << norm2(res) << " " << absDev << " " << relDev << " -> check " << ((relDev < checkTolerance) ? "passed" : "failed") << std::endl; - assert(relDev <= checkTolerance); + GRID_ASSERT(relDev <= checkTolerance); } { @@ -200,7 +200,7 @@ int main(int argc, char** argv) { std::cout << GridLogMessage << "norm2(Dhop), norm2(Meo + Moe), abs. deviation, rel. deviation: " << norm2(ref) << " " << norm2(res) << " " << absDev << " " << relDev << " -> check " << ((relDev < checkTolerance) ? "passed" : "failed") << std::endl; - assert(relDev <= checkTolerance); + GRID_ASSERT(relDev <= checkTolerance); } { @@ -222,7 +222,7 @@ int main(int argc, char** argv) { std::cout << GridLogMessage << "Re(v^dag M^dag M v), Im(v^dag M^dag M v), rel.deviation: " << real(dot) << " " << imag(dot) << " " << relDev << " -> check " << ((relDev < checkTolerance) ? "passed" : "failed") << std::endl; - assert(relDev <= checkTolerance); + GRID_ASSERT(relDev <= checkTolerance); } { @@ -242,7 +242,7 @@ int main(int argc, char** argv) { std::cout << GridLogMessage << "Re(v^dag Mooee^dag Mooee v), Im(v^dag Mooee^dag Mooee v), rel.deviation: " << real(dot) << " " << imag(dot) << " " << relDev << " -> check " << ((relDev < checkTolerance) ? "passed" : "failed") << std::endl; - assert(relDev <= checkTolerance); + GRID_ASSERT(relDev <= checkTolerance); } { @@ -262,7 +262,7 @@ int main(int argc, char** argv) { std::cout << GridLogMessage << "norm2(src), norm2(MooeeInv Mooee src), abs. deviation, rel. deviation: " << norm2(src) << " " << norm2(phi) << " " << absDev << " " << relDev << " -> check " << ((relDev < checkTolerance) ? "passed" : "failed") << std::endl; - assert(relDev <= checkTolerance); + GRID_ASSERT(relDev <= checkTolerance); } { @@ -343,7 +343,7 @@ int main(int argc, char** argv) { std::cout << GridLogMessage << "norm2(chi), norm2(MeeInv Mee chi), abs. deviation, rel. deviation: " << norm2(chi) << " " << norm2(phi) << " " << absDev << " " << relDev << " -> check " << ((relDev < checkTolerance) ? "passed" : "failed") << std::endl; - assert(relDev <= checkTolerance); + GRID_ASSERT(relDev <= checkTolerance); } { @@ -380,7 +380,7 @@ int main(int argc, char** argv) { std::cout << GridLogMessage << "norm2(chi), norm2(MeeDag MeeInvDag chi), abs. deviation, rel. deviation: " << norm2(chi) << " " << norm2(phi) << " " << absDev << " " << relDev << " -> check " << ((relDev < checkTolerance) ? "passed" : "failed") << std::endl; - assert(relDev <= checkTolerance); + GRID_ASSERT(relDev <= checkTolerance); } { @@ -429,7 +429,7 @@ int main(int argc, char** argv) { std::cout << GridLogMessage << "norm2(Dunprec), norm2(Deoprec), abs. deviation, rel. deviation: " << norm2(ref) << " " << norm2(phi) << " " << absDev << " " << relDev << " -> check " << ((relDev < checkTolerance) ? "passed" : "failed") << std::endl; - assert(relDev <= checkTolerance); + GRID_ASSERT(relDev <= checkTolerance); } { diff --git a/tests/solver/Test_dwf_cg_prec.cc b/tests/solver/Test_dwf_cg_prec.cc index efbd7fc6..7ebae9d8 100644 --- a/tests/solver/Test_dwf_cg_prec.cc +++ b/tests/solver/Test_dwf_cg_prec.cc @@ -95,7 +95,7 @@ int main(int argc, char** argv) { GridStopWatch CGTimer; SchurDiagMooeeOperator HermOpEO(Ddwf); - ConjugateGradient CG(1.0e-5, 10000, 0);// switch off the assert + ConjugateGradient CG(1.0e-5, 10000, 0);// switch off the GRID_ASSERT CGTimer.Start(); CG(HermOpEO, src_o, result_o); diff --git a/tests/solver/Test_dwf_hdcr.cc b/tests/solver/Test_dwf_hdcr.cc index 31b58284..1b8bc3c9 100644 --- a/tests/solver/Test_dwf_hdcr.cc +++ b/tests/solver/Test_dwf_hdcr.cc @@ -267,7 +267,7 @@ int main (int argc, char ** argv) Subspace Aggregates(Coarse5d,FGrid,0); - assert ( (nbasis & 0x1)==0); + GRID_ASSERT ( (nbasis & 0x1)==0); { int nb=nbasis/2; Aggregates.CreateSubspaceChebyshev(RNG5,HermDefOp,nb,60.0,0.02,500,100,100,0.0); diff --git a/tests/solver/Test_dwf_hdcr_16_rb.cc b/tests/solver/Test_dwf_hdcr_16_rb.cc index ae8e7ae5..ee613aad 100644 --- a/tests/solver/Test_dwf_hdcr_16_rb.cc +++ b/tests/solver/Test_dwf_hdcr_16_rb.cc @@ -281,7 +281,7 @@ int main (int argc, char ** argv) Subspace Aggregates(Coarse5d,FGrid,0); - assert ( (nbasis & 0x1)==0); + GRID_ASSERT ( (nbasis & 0x1)==0); { int nb=nbasis/2; LatticeFermion A(FGrid); diff --git a/tests/solver/Test_dwf_hdcr_24_regression.cc b/tests/solver/Test_dwf_hdcr_24_regression.cc index 88ae7fd2..023a9e8b 100644 --- a/tests/solver/Test_dwf_hdcr_24_regression.cc +++ b/tests/solver/Test_dwf_hdcr_24_regression.cc @@ -263,7 +263,7 @@ int main (int argc, char ** argv) Subspace Aggregates(Coarse5d,FGrid,0); - assert ( (nbasis & 0x1)==0); + GRID_ASSERT ( (nbasis & 0x1)==0); { int nb=nbasis/2; LatticeFermion A(FGrid); diff --git a/tests/solver/Test_dwf_hdcr_2level.cc b/tests/solver/Test_dwf_hdcr_2level.cc index 47e129f3..0975fa40 100644 --- a/tests/solver/Test_dwf_hdcr_2level.cc +++ b/tests/solver/Test_dwf_hdcr_2level.cc @@ -301,7 +301,7 @@ int main (int argc, char ** argv) Subspace Aggregates(Coarse5d,FGrid,0); - assert ( (nbasis & 0x1)==0); + GRID_ASSERT ( (nbasis & 0x1)==0); { int nb=nbasis/2; // Aggregates.CreateSubspaceChebyshev(RNG5,HermDefOp,nb,60.0,0.05,500,200,100,0.0);// 18s diff --git a/tests/solver/Test_dwf_hdcr_48_rb.cc b/tests/solver/Test_dwf_hdcr_48_rb.cc index 25ac1dac..3fef75ca 100644 --- a/tests/solver/Test_dwf_hdcr_48_rb.cc +++ b/tests/solver/Test_dwf_hdcr_48_rb.cc @@ -277,7 +277,7 @@ int main (int argc, char ** argv) Subspace Aggregates(Coarse5d,FGrid,0); - assert ( (nbasis & 0x1)==0); + GRID_ASSERT ( (nbasis & 0x1)==0); { int nb=nbasis/2; LatticeFermion A(FGrid); diff --git a/tests/solver/Test_dwf_hdcr_48_regression.cc b/tests/solver/Test_dwf_hdcr_48_regression.cc index 8c56c8f9..616ab7ca 100644 --- a/tests/solver/Test_dwf_hdcr_48_regression.cc +++ b/tests/solver/Test_dwf_hdcr_48_regression.cc @@ -261,7 +261,7 @@ int main (int argc, char ** argv) Subspace Aggregates(Coarse5d,FGrid,0); - assert ( (nbasis & 0x1)==0); + GRID_ASSERT ( (nbasis & 0x1)==0); { int nb=nbasis/2; LatticeFermion A(FGrid); diff --git a/tests/solver/Test_dwf_multigrid.cc b/tests/solver/Test_dwf_multigrid.cc index 1cd83375..0f933971 100644 --- a/tests/solver/Test_dwf_multigrid.cc +++ b/tests/solver/Test_dwf_multigrid.cc @@ -85,13 +85,13 @@ public: PVdagMLinearOperator(Matrix &Mat,Matrix &PV): _Mat(Mat),_PV(PV){}; void OpDiag (const Field &in, Field &out) { - assert(0); + GRID_ASSERT(0); } void OpDir (const Field &in, Field &out,int dir,int disp) { - assert(0); + GRID_ASSERT(0); } void OpDirAll (const Field &in, std::vector &out){ - assert(0); + GRID_ASSERT(0); }; void Op (const Field &in, Field &out){ Field tmp(in.Grid()); @@ -104,10 +104,10 @@ public: _Mat.Mdag(in,tmp); } void HermOpAndNorm(const Field &in, Field &out,RealD &n1,RealD &n2){ - assert(0); + GRID_ASSERT(0); } void HermOp(const Field &in, Field &out){ - assert(0); + GRID_ASSERT(0); } }; @@ -411,7 +411,7 @@ int main (int argc, char ** argv) Subspace Aggregates(Coarse5d,FGrid,0); - assert ( (nbasis & 0x1)==0); + GRID_ASSERT ( (nbasis & 0x1)==0); { int nb=nbasis/2; Aggregates.CreateSubspaceChebyshev(RNG5,HermDefOp,nb,60.0,0.02,500,100,100,0.0); diff --git a/tests/solver/Test_dwf_multishift_mixedprec.cc b/tests/solver/Test_dwf_multishift_mixedprec.cc index 63ffe1c6..ba46b597 100644 --- a/tests/solver/Test_dwf_multishift_mixedprec.cc +++ b/tests/solver/Test_dwf_multishift_mixedprec.cc @@ -69,7 +69,7 @@ void run_test(int argc, char ** argv, const typename SpeciesD::ImplParams ¶m bool cfg_loaded=false; for(int i=1;i= 0 && gpdir <= 2); //spatial! + GRID_ASSERT(gpdir >= 0 && gpdir <= 2); //spatial! gparity = true; } } diff --git a/tests/solver/Test_eofa_inv.cc b/tests/solver/Test_eofa_inv.cc index 71952b97..de4ee49e 100644 --- a/tests/solver/Test_eofa_inv.cc +++ b/tests/solver/Test_eofa_inv.cc @@ -106,7 +106,7 @@ int main (int argc, char** argv) LatticeFermion diff = MinvMeta - eta; std::cout << GridLogMessage << "eta: " << norm2(eta) << " M*eta: " << norm2(Meta) << " M^{-1}*M*eta: " << norm2(MinvMeta) << " M^{-1}*M*eta - eta: " << norm2(diff) << " (expect 0)" << std::endl; - assert(norm2(diff) < 1e-8); + GRID_ASSERT(norm2(diff) < 1e-8); //Check right inverse LatticeFermion MinvEta(FGrid); @@ -118,7 +118,7 @@ int main (int argc, char** argv) diff = MMinvEta - eta; std::cout << GridLogMessage << "eta: " << norm2(eta) << " M^{-1}*eta: " << norm2(MinvEta) << " M*M^{-1}*eta: " << norm2(MMinvEta) << " M*M^{-1}*eta - eta: " << norm2(diff) << " (expect 0)" << std::endl; - assert(norm2(diff) < 1e-8); + GRID_ASSERT(norm2(diff) < 1e-8); std::cout << GridLogMessage << "Done" << std::endl; Grid_finalize(); diff --git a/tests/solver/Test_hw_multigrid.cc b/tests/solver/Test_hw_multigrid.cc index fd30bca7..6714d7f2 100644 --- a/tests/solver/Test_hw_multigrid.cc +++ b/tests/solver/Test_hw_multigrid.cc @@ -82,13 +82,13 @@ public: PVdagMLinearOperator(Matrix &Mat,Matrix &PV): _Mat(Mat),_PV(PV){}; void OpDiag (const Field &in, Field &out) { - assert(0); + GRID_ASSERT(0); } void OpDir (const Field &in, Field &out,int dir,int disp) { - assert(0); + GRID_ASSERT(0); } void OpDirAll (const Field &in, std::vector &out){ - assert(0); + GRID_ASSERT(0); }; void Op (const Field &in, Field &out){ Field tmp(in.Grid()); @@ -101,10 +101,10 @@ public: _Mat.Mdag(in,tmp); } void HermOpAndNorm(const Field &in, Field &out,RealD &n1,RealD &n2){ - assert(0); + GRID_ASSERT(0); } void HermOp(const Field &in, Field &out){ - assert(0); + GRID_ASSERT(0); } }; @@ -309,7 +309,7 @@ int main (int argc, char ** argv) Subspace Aggregates4D(Coarse4d,UGrid,0); Subspace Aggregates5D(Coarse5d,FGrid,0); - assert ( (nbasis & 0x1)==0); + GRID_ASSERT ( (nbasis & 0x1)==0); std::cout<M5) +1.0); - assert(bee[i]!=Coeff_t(0.0)); + GRID_ASSERT(bee[i]!=Coeff_t(0.0)); cee[i]=as[i]*(1.0-cs[i]*(4.0-this->M5)); beo[i]=as[i]*bs[i]; ceo[i]=-as[i]*cs[i]; @@ -174,7 +174,7 @@ public: leem[i]=mass*cee[Ls-1]/bee[0]; for(int j=0;j &out) { @@ -679,13 +679,13 @@ public: virtual std::vector Displacements(void){ return _Mat.Displacements();}; void OpDiag (const Field &in, Field &out) { - assert(0); + GRID_ASSERT(0); } void OpDir (const Field &in, Field &out,int dir,int disp) { - assert(0); + GRID_ASSERT(0); } void OpDirAll (const Field &in, std::vector &out){ - assert(0); + GRID_ASSERT(0); }; void Op (const Field &in, Field &out){ Field tmp(in.Grid()); @@ -698,10 +698,10 @@ public: _Mat.Mdag(in,tmp); } void HermOpAndNorm(const Field &in, Field &out,RealD &n1,RealD &n2){ - assert(0); + GRID_ASSERT(0); } void HermOp(const Field &in, Field &out){ - assert(0); + GRID_ASSERT(0); } }; @@ -1024,7 +1024,7 @@ int main (int argc, char ** argv) std::cout<M5) +1.0); - assert(bee[i]!=Coeff_t(0.0)); + GRID_ASSERT(bee[i]!=Coeff_t(0.0)); cee[i]=as[i]*(1.0-cs[i]*(4.0-this->M5)); beo[i]=as[i]*bs[i]; ceo[i]=-as[i]*cs[i]; @@ -174,7 +174,7 @@ public: leem[i]=mass*cee[Ls-1]/bee[0]; for(int j=0;j &out) { @@ -699,13 +699,13 @@ public: virtual std::vector Displacements(void){ return _Mat.Displacements();}; void OpDiag (const Field &in, Field &out) { - assert(0); + GRID_ASSERT(0); } void OpDir (const Field &in, Field &out,int dir,int disp) { - assert(0); + GRID_ASSERT(0); } void OpDirAll (const Field &in, std::vector &out){ - assert(0); + GRID_ASSERT(0); }; void Op (const Field &in, Field &out){ Field tmp(in.Grid()); @@ -718,10 +718,10 @@ public: _Mat.Mdag(in,tmp); } void HermOpAndNorm(const Field &in, Field &out,RealD &n1,RealD &n2){ - assert(0); + GRID_ASSERT(0); } void HermOp(const Field &in, Field &out){ - assert(0); + GRID_ASSERT(0); } }; @@ -1048,7 +1048,7 @@ int main (int argc, char ** argv) std::cout<_ndimension; auto tmp = Grids[level - 1]->_fdimensions; - assert(tmp.size() == Nd); + GRID_ASSERT(tmp.size() == Nd); Seeds.push_back(std::vector(Nd)); diff --git a/tests/solver/Test_wilson_mg.cc b/tests/solver/Test_wilson_mg.cc index 875bf32a..6ab2295e 100644 --- a/tests/solver/Test_wilson_mg.cc +++ b/tests/solver/Test_wilson_mg.cc @@ -56,7 +56,7 @@ int main(int argc, char **argv) { if(GridCmdOptionExists(argv, argv + argc, "--inputxml")) { inputXml = GridCmdOptionPayload(argv, argv + argc, "--inputxml"); - assert(inputXml.length() != 0); + GRID_ASSERT(inputXml.length() != 0); } { diff --git a/tests/solver/Test_wilson_mg_mp.cc b/tests/solver/Test_wilson_mg_mp.cc index 89bbbf74..9161593c 100644 --- a/tests/solver/Test_wilson_mg_mp.cc +++ b/tests/solver/Test_wilson_mg_mp.cc @@ -63,7 +63,7 @@ int main(int argc, char **argv) { if(GridCmdOptionExists(argv, argv + argc, "--inputxml")) { inputXml = GridCmdOptionPayload(argv, argv + argc, "--inputxml"); - assert(inputXml.length() != 0); + GRID_ASSERT(inputXml.length() != 0); } { diff --git a/tests/solver/Test_wilsonclover_mg.cc b/tests/solver/Test_wilsonclover_mg.cc index 1b0e8bb7..116a379c 100644 --- a/tests/solver/Test_wilsonclover_mg.cc +++ b/tests/solver/Test_wilsonclover_mg.cc @@ -59,7 +59,7 @@ int main(int argc, char **argv) { if(GridCmdOptionExists(argv, argv + argc, "--inputxml")) { inputXml = GridCmdOptionPayload(argv, argv + argc, "--inputxml"); - assert(inputXml.length() != 0); + GRID_ASSERT(inputXml.length() != 0); } { diff --git a/tests/solver/Test_wilsonclover_mg_lime.cc b/tests/solver/Test_wilsonclover_mg_lime.cc index 0a29c034..12d84f4d 100644 --- a/tests/solver/Test_wilsonclover_mg_lime.cc +++ b/tests/solver/Test_wilsonclover_mg_lime.cc @@ -89,7 +89,7 @@ int main(int argc, char **argv) { if(GridCmdOptionExists(argv, argv + argc, "--inputxml")) { inputXml = GridCmdOptionPayload(argv, argv + argc, "--inputxml"); - assert(inputXml.length() != 0); + GRID_ASSERT(inputXml.length() != 0); } { diff --git a/tests/solver/Test_wilsonclover_mg_mp.cc b/tests/solver/Test_wilsonclover_mg_mp.cc index 2efe5f08..02322a82 100644 --- a/tests/solver/Test_wilsonclover_mg_mp.cc +++ b/tests/solver/Test_wilsonclover_mg_mp.cc @@ -65,7 +65,7 @@ int main(int argc, char **argv) { if(GridCmdOptionExists(argv, argv + argc, "--inputxml")) { inputXml = GridCmdOptionPayload(argv, argv + argc, "--inputxml"); - assert(inputXml.length() != 0); + GRID_ASSERT(inputXml.length() != 0); } { diff --git a/tests/solver/Test_zMADWF_prec.cc b/tests/solver/Test_zMADWF_prec.cc index d1168764..eb1be6e2 100644 --- a/tests/solver/Test_zMADWF_prec.cc +++ b/tests/solver/Test_zMADWF_prec.cc @@ -176,7 +176,7 @@ void run(const TestParams ¶ms){ NerscIO::readConfiguration(Umu, header, params.config_file); for(int i=0;i::HotConfiguration(RNG4, Umu); @@ -297,7 +297,7 @@ int main(int argc, char** argv) { run(params); }else if(params.outer_precon == "DiagTwo" && params.inner_precon == "DiagTwo"){ run(params); - }else assert(0); + }else GRID_ASSERT(0); Grid_finalize(); } diff --git a/tests/solver/Test_zmobius_cg_prec.cc b/tests/solver/Test_zmobius_cg_prec.cc index 7f1f98b8..bd56bc2f 100644 --- a/tests/solver/Test_zmobius_cg_prec.cc +++ b/tests/solver/Test_zmobius_cg_prec.cc @@ -111,7 +111,7 @@ int main(int argc, char** argv) { GridStopWatch CGTimer; SchurDiagMooeeOperator HermOpEO(Ddwf); - ConjugateGradient CG(1.0e-8, 10000, 0);// switch off the assert + ConjugateGradient CG(1.0e-8, 10000, 0);// switch off the GRID_ASSERT CGTimer.Start(); CG(HermOpEO, src_o, result_o); diff --git a/tests/sp2n/Test_2as_base.cc b/tests/sp2n/Test_2as_base.cc index 3aeccae0..b1ca7d6b 100644 --- a/tests/sp2n/Test_2as_base.cc +++ b/tests/sp2n/Test_2as_base.cc @@ -16,7 +16,7 @@ static void check_dimensions() { std::cout << GridLogMessage << "Nc = " << this_n << " algebra dimension is " << this_algebra_dim << std::endl; realA = Sp_TwoIndex::Dimension + Sp_TwoIndex::Dimension; std::cout << GridLogMessage << "Checking dim(2AS) + dim(AS) + 1 = Nc * Nc " << this_algebra_dim << std::endl; - assert ( realA == this_nc * this_nc - 1); // Nc x Nc = dim(2indxS) + dim(2indxAS) + dim(singlet) + GRID_ASSERT ( realA == this_nc * this_nc - 1); // Nc x Nc = dim(2indxS) + dim(2indxAS) + dim(singlet) } template @@ -35,7 +35,7 @@ static void run_symmetry_checks() { Sp_TwoIndex::base(a, eij_c); e_sum = eij_c - realS * transpose(eij_c); std::cout << GridLogMessage << "e_ab - (" << S << " * e_ab^T ) = " << norm2(e_sum) << std::endl; - assert(norm2(e_sum) < 1e-8); + GRID_ASSERT(norm2(e_sum) < 1e-8); } } @@ -59,7 +59,7 @@ static void run_traces_checks() { realA = norm2(trace(Omega*eij_a)); std::cout << GridLogMessage << "Checkig Omega-trace for e_{ab=" << a << "} " << std::endl; //std::cout << GridLogMessage << "Tr ( Omega e_{ab=" << a << "} ) = " << realA << std::endl; - assert(realA < 1e-8); + GRID_ASSERT(realA < 1e-8); for (int b=0; b < Sp_TwoIndex::Dimension; b++) { Sp_TwoIndex::base(b, eij_b); auto d_ab = TensorRemove(trace(eij_a * eij_b)); @@ -68,12 +68,12 @@ static void run_traces_checks() { #endif std::cout << GridLogMessage << "Checking orthonormality for e_{ab = " << a << "} " << std::endl; if (a==b) { - assert(real(d_ab) - realS < 1e-8); + GRID_ASSERT(real(d_ab) - realS < 1e-8); } else { - assert(real(d_ab) < 1e-8); + GRID_ASSERT(real(d_ab) < 1e-8); } - assert(imag(d_ab) < 1e-8); - assert(imag(d_ab) < 1e-8); + GRID_ASSERT(imag(d_ab) < 1e-8); + GRID_ASSERT(imag(d_ab) < 1e-8); } } @@ -118,8 +118,8 @@ static void run_generators_checks() { sum_im += imag(TensorRemove(trace(tmp_l+tmp_r))); } std::cout << GridLogMessage << "re-evaluated trace of the generator " << gen_id << " is " << sum << " " << sum_im << std::endl; - assert ( sum < 1e-8) ; - assert ( sum_im < 1e-8) ; + GRID_ASSERT ( sum < 1e-8) ; + GRID_ASSERT ( sum_im < 1e-8) ; } } diff --git a/tests/sp2n/Test_Sp_start.cc b/tests/sp2n/Test_Sp_start.cc index dab5819e..ba21902b 100644 --- a/tests/sp2n/Test_Sp_start.cc +++ b/tests/sp2n/Test_Sp_start.cc @@ -19,9 +19,9 @@ bool has_correct_group_block_structure(const T& U) { auto Ww = conjugate(Wstar); auto amizero = sum(W - Ww); auto amizeroo = TensorRemove(amizero); - assert(amizeroo.real() < 10e-6); + GRID_ASSERT(amizeroo.real() < 10e-6); amizeroo *= i; - assert(amizeroo.real() < 10e-6); + GRID_ASSERT(amizeroo.real() < 10e-6); } } @@ -32,9 +32,9 @@ bool has_correct_group_block_structure(const T& U) { auto minusXx = conjugate(minusXstar); auto amizero = sum(X + minusXx); auto amizeroo = TensorRemove(amizero); - assert(amizeroo.real() < 10e-6); + GRID_ASSERT(amizeroo.real() < 10e-6); amizeroo *= i; - assert(amizeroo.real() < 10e-6); + GRID_ASSERT(amizeroo.real() < 10e-6); } } return true; @@ -49,22 +49,22 @@ bool is_element_of_sp2n_group(const T& U) { Sp::Omega(Omega); std::cout << GridLogMessage << "Check matrix is non-zero " << std::endl; - assert(norm2(U) > 1e-8); + GRID_ASSERT(norm2(U) > 1e-8); std::cout << GridLogMessage << "Unitary check" << std::endl; aux = U * adj(U) - identity; std::cout << GridLogMessage << "U adjU - 1 = " << norm2(aux) << std::endl; - assert(norm2(aux) < 1e-8); + GRID_ASSERT(norm2(aux) < 1e-8); aux = Omega - (U * Omega * transpose(U)); std::cout << GridLogMessage << "Omega - U Omega transpose(U) = " << norm2(aux) << std::endl; - assert(norm2(aux) < 1e-8); + GRID_ASSERT(norm2(aux) < 1e-8); std::cout << GridLogMessage << "|Det| = " << norm2(Determinant(U)) / U.Grid()->gSites() << std::endl; - assert(norm2(Determinant(U)) / U.Grid()->gSites() - 1 < 1e-8); + GRID_ASSERT(norm2(Determinant(U)) / U.Grid()->gSites() - 1 < 1e-8); return has_correct_group_block_structure(U); } @@ -91,17 +91,17 @@ int main (int argc, char **argv) std::cout << GridLogMessage << "Checking Cold Configuration " << std::endl; Sp::ColdConfiguration(pRNG,Umu); U = PeekIndex(Umu,1); - assert(is_element_of_sp2n_group(U)); + GRID_ASSERT(is_element_of_sp2n_group(U)); std::cout << GridLogMessage << "Checking Hot Configuration" << std::endl; Sp::HotConfiguration(pRNG,Umu); U = PeekIndex(Umu,1); - assert(is_element_of_sp2n_group(U)); + GRID_ASSERT(is_element_of_sp2n_group(U)); std::cout << GridLogMessage << "Checking Tepid Configuration" << std::endl; Sp::TepidConfiguration(pRNG,Umu); U = PeekIndex(Umu,1); - assert(is_element_of_sp2n_group(U)); + GRID_ASSERT(is_element_of_sp2n_group(U)); Grid_finalize(); diff --git a/tests/sp2n/Test_project_on_Sp.cc b/tests/sp2n/Test_project_on_Sp.cc index 63032a68..28e23b62 100644 --- a/tests/sp2n/Test_project_on_Sp.cc +++ b/tests/sp2n/Test_project_on_Sp.cc @@ -19,9 +19,9 @@ bool has_correct_group_block_structure(const T& U) { auto Ww = conjugate(Wstar); auto amizero = sum(W - Ww); auto amizeroo = TensorRemove(amizero); - assert(amizeroo.real() < 10e-6); + GRID_ASSERT(amizeroo.real() < 10e-6); amizeroo *= i; - assert(amizeroo.real() < 10e-6); + GRID_ASSERT(amizeroo.real() < 10e-6); } } @@ -32,9 +32,9 @@ bool has_correct_group_block_structure(const T& U) { auto minusXx = conjugate(minusXstar); auto amizero = sum(X + minusXx); auto amizeroo = TensorRemove(amizero); - assert(amizeroo.real() < 10e-6); + GRID_ASSERT(amizeroo.real() < 10e-6); amizeroo *= i; - assert(amizeroo.real() < 10e-6); + GRID_ASSERT(amizeroo.real() < 10e-6); } } return true; @@ -49,22 +49,22 @@ bool is_element_of_sp2n_group(const T& U) { Sp::Omega(Omega); std::cout << GridLogMessage << "Check matrix is non-zero " << std::endl; - assert(norm2(U) > 1e-8); + GRID_ASSERT(norm2(U) > 1e-8); std::cout << GridLogMessage << "Unitary check" << std::endl; aux = U * adj(U) - identity; std::cout << GridLogMessage << "U adjU - 1 = " << norm2(aux) << std::endl; - assert(norm2(aux) < 1e-8); + GRID_ASSERT(norm2(aux) < 1e-8); aux = Omega - (U * Omega * transpose(U)); std::cout << GridLogMessage << "Omega - U Omega transpose(U) = " << norm2(aux) << std::endl; - assert(norm2(aux) < 1e-8); + GRID_ASSERT(norm2(aux) < 1e-8); std::cout << GridLogMessage << "|Det| = " << norm2(Determinant(U)) / U.Grid()->gSites() << std::endl; - assert(norm2(Determinant(U)) / U.Grid()->gSites() - 1 < 1e-8); + GRID_ASSERT(norm2(Determinant(U)) / U.Grid()->gSites() - 1 < 1e-8); return has_correct_group_block_structure(U); } @@ -86,7 +86,7 @@ void test_group_projections(T U) { U = U + Delta * identity; U = ProjectOnSpGroup(U); - assert(is_element_of_sp2n_group(U)); + GRID_ASSERT(is_element_of_sp2n_group(U)); name = "ProjectOnGeneralGroup"; std::cout << GridLogMessage << "Testing " << name << std::endl; @@ -94,7 +94,7 @@ void test_group_projections(T U) { U = U + Delta * identity; U = Sp::ProjectOnGeneralGroup(U); - assert(is_element_of_sp2n_group(U)); + GRID_ASSERT(is_element_of_sp2n_group(U)); name = "ProjectOnSpecialGroup"; std::cout << GridLogMessage << "Testing " << name << std::endl; @@ -102,7 +102,7 @@ void test_group_projections(T U) { U = U + Delta * identity; Sp::ProjectOnSpecialGroup(U); - assert(is_element_of_sp2n_group(U)); + GRID_ASSERT(is_element_of_sp2n_group(U)); name = "ProjectSpn"; std::cout << GridLogMessage << "Testing " << name << std::endl; @@ -110,7 +110,7 @@ void test_group_projections(T U) { U = U + Delta * identity; ProjectSpn(U); - assert(is_element_of_sp2n_group(U)); + GRID_ASSERT(is_element_of_sp2n_group(U)); } template @@ -129,9 +129,9 @@ bool has_correct_algebra_block_structure(const T& U) { auto Ww = conjugate(Wstar); auto amizero = sum(W - Ww); auto amizeroo = TensorRemove(amizero); - assert(amizeroo.real() < 10e-6); + GRID_ASSERT(amizeroo.real() < 10e-6); amizeroo *= i; - assert(amizeroo.real() < 10e-6); + GRID_ASSERT(amizeroo.real() < 10e-6); } } for (int c1 = 0; c1 < nsp; c1++) { @@ -141,9 +141,9 @@ bool has_correct_algebra_block_structure(const T& U) { auto minusXx = conjugate(minusXstar); auto amizero = sum(X + minusXx); auto amizeroo = TensorRemove(amizero); - assert(amizeroo.real() < 10e-6); + GRID_ASSERT(amizeroo.real() < 10e-6); amizeroo *= i; - assert(amizeroo.real() < 10e-6); + GRID_ASSERT(amizeroo.real() < 10e-6); } } @@ -159,7 +159,7 @@ bool is_element_of_sp2n_algebra(const T& U) { Sp::Omega(Omega); std::cout << GridLogMessage << "Check matrix is non-zero " << std::endl; - assert(norm2(U) > 1e-8); + GRID_ASSERT(norm2(U) > 1e-8); aux = U - adj(U); std::cout << GridLogMessage << "T - Tda = " << norm2(aux) @@ -168,12 +168,12 @@ bool is_element_of_sp2n_algebra(const T& U) { aux = U + adj(U); std::cout << GridLogMessage << "T + Tda = " << norm2(aux) << " (supposed to vanish)" << std::endl; - assert(norm2(aux) - 1 < 1e-8); + GRID_ASSERT(norm2(aux) - 1 < 1e-8); std::cout << GridLogMessage << "Check that Omega T Omega + conj(T) = 0 " << std::endl; aux = Omega * U * Omega + conjugate(U); - assert(norm2(aux) < 1e-8); + GRID_ASSERT(norm2(aux) < 1e-8); return has_correct_algebra_block_structure(U); } @@ -196,7 +196,7 @@ void test_algebra_projections(T U) { U = U + Delta * identity; U = SpTa(U); - assert(is_element_of_sp2n_algebra(U)); + GRID_ASSERT(is_element_of_sp2n_algebra(U)); name = "TaProj"; std::cout << GridLogMessage << "Testing " << name << std::endl; @@ -205,7 +205,7 @@ void test_algebra_projections(T U) { U = U + Delta * identity; Sp::taProj(U, tmp); U = tmp; - assert(is_element_of_sp2n_algebra(U)); + GRID_ASSERT(is_element_of_sp2n_algebra(U)); } int main(int argc, char** argv) {