From 9ed704973641c3a2206a87e5bbd77031caa43b3e Mon Sep 17 00:00:00 2001 From: Peter Boyle Date: Sun, 23 Aug 2026 22:58:06 -0400 Subject: [PATCH] COMpile fixes --- tests/debug/Test_allgather.cc | 8 ++++---- tests/debug/Test_schur2d.cc | 27 ++++++++++++++++++--------- tests/debug/Test_schur2d_redist.cc | 19 ++++++++++++++----- tests/debug/Test_schur2d_scale.cc | 13 +++++++++++-- tests/debug/Test_summa.cc | 19 ++++++++++++++----- 5 files changed, 61 insertions(+), 25 deletions(-) diff --git a/tests/debug/Test_allgather.cc b/tests/debug/Test_allgather.cc index 623fdd2c2..2709450fa 100644 --- a/tests/debug/Test_allgather.cc +++ b/tests/debug/Test_allgather.cc @@ -21,10 +21,10 @@ Author: Peter Boyle // Regression gate for CartesianCommunicator::AllGather / AllGatherV. // // CPU build under mpirun: -// mpirun -n 1 ./Test_allgather --grid 8.8.8.8 --mpi 1.1.1.1 -// mpirun -n 2 ./Test_allgather --grid 8.8.8.8 --mpi 1.1.1.2 -// mpirun -n 3 ./Test_allgather --grid 8.8.8.12 --mpi 1.1.1.3 -// mpirun -n 4 ./Test_allgather --grid 8.8.8.8 --mpi 1.1.1.4 +// mpirun -n 1 ./Test_allgather --grid 16.16.16.32 --mpi 1.1.1.1 +// mpirun -n 2 ./Test_allgather --grid 16.16.16.32 --mpi 1.1.1.2 +// mpirun -n 3 ./Test_allgather --grid 16.16.16.48 --mpi 1.1.1.3 +// mpirun -n 4 ./Test_allgather --grid 16.16.16.32 --mpi 1.1.1.4 // // T1 : uniform AllGather, rank-ordered concatenation. // T2 : AllGatherV with non-uniform counts and displacements. diff --git a/tests/debug/Test_schur2d.cc b/tests/debug/Test_schur2d.cc index 545ad2c63..36553b609 100644 --- a/tests/debug/Test_schur2d.cc +++ b/tests/debug/Test_schur2d.cc @@ -22,10 +22,10 @@ Author: Peter Boyle // Regression gate for BlockCyclicSchurInverse -- stage 3 of the 2D // distributed dense inverse. CPU build under mpirun: // -// mpirun -n 1 ./Test_schur2d --grid 8.8.8.8 --mpi 1.1.1.1 -// mpirun -n 2 ./Test_schur2d --grid 8.8.8.8 --mpi 1.1.1.2 -// mpirun -n 3 ./Test_schur2d --grid 8.8.8.12 --mpi 1.1.1.3 -// mpirun -n 4 ./Test_schur2d --grid 8.8.8.8 --mpi 1.1.1.4 +// mpirun -n 1 ./Test_schur2d --grid 16.16.16.32 --mpi 1.1.1.1 +// mpirun -n 2 ./Test_schur2d --grid 16.16.16.32 --mpi 1.1.1.2 +// mpirun -n 3 ./Test_schur2d --grid 16.16.16.48 --mpi 1.1.1.3 +// mpirun -n 4 ./Test_schur2d --grid 16.16.16.32 --mpi 1.1.1.4 // // Sweeps all process-grid factorisations of P and a battery of (N,nb) // including ragged trailing blocks, a single-leaf matrix (nblocks==1), @@ -48,6 +48,15 @@ using namespace Grid; static int failures = 0; +// Portable |z|: ComplexD is std::complex on CPU builds and thrust::complex +// under HIP, where std::abs does not resolve (same trap RecursiveSchurInverse +// documents at FrobNorm2Local). Member real()/imag() work on both. +static double Cabs(const ComplexD &z) +{ + double re = z.real(), im = z.imag(); + return std::sqrt(re*re + im*im); +} + static void Report(const std::string &name, bool pass, const std::string &detail="") { std::cout << GridLogMessage << " " << name << (pass ? " PASS" : " ** FAIL **"); @@ -78,9 +87,9 @@ static void HostInverse(std::vector A, std::vector &X, int64 X.assign((uint64_t)N*N, ComplexD(0.0,0.0)); for(int64_t i=0;i mx ){ mx=std::abs(A[r+c*N]); piv=r; } + if ( Cabs(A[r+c*N]) > mx ){ mx=Cabs(A[r+c*N]); piv=r; } GRID_ASSERT( mx > 0.0 ); if ( piv != c ) for(int64_t j=0;j 1.0e-10 ) okC = false; @@ -160,8 +169,8 @@ int main(int argc, char **argv) // reference: element-wise, scaled by the largest inverse entry A.ExportGlobal(Ainv); double mxref = 0.0, dr = 0.0; - for(uint64_t i=0;i 1.0e-9 ) okR = false; diff --git a/tests/debug/Test_schur2d_redist.cc b/tests/debug/Test_schur2d_redist.cc index 689b2d5eb..784fe2c56 100644 --- a/tests/debug/Test_schur2d_redist.cc +++ b/tests/debug/Test_schur2d_redist.cc @@ -46,6 +46,15 @@ using namespace Grid; static int failures = 0; +// Portable |z|: ComplexD is std::complex on CPU builds and thrust::complex +// under HIP, where std::abs does not resolve (same trap RecursiveSchurInverse +// documents at FrobNorm2Local). Member real()/imag() work on both. +static double Cabs(const ComplexD &z) +{ + double re = z.real(), im = z.imag(); + return std::sqrt(re*re + im*im); +} + static void Report(const std::string &name, bool pass, const std::string &detail="") { std::cout << GridLogMessage << " " << name << (pass ? " PASS" : " ** FAIL **"); @@ -72,9 +81,9 @@ static void HostInverse(std::vector A, std::vector &X, int64 X.assign((uint64_t)N*N, ComplexD(0.0,0.0)); for(int64_t i=0;i mx ){ mx=std::abs(A[r+c*N]); piv=r; } + if ( Cabs(A[r+c*N]) > mx ){ mx=Cabs(A[r+c*N]); piv=r; } GRID_ASSERT( mx > 0.0 ); if ( piv != c ) for(int64_t j=0;j cyclic -> invert -> rows ---- std::vector h2d(h.size()); @@ -219,7 +228,7 @@ int main(int argc, char **argv) } for(int64_t j=0;j 1.0e-9 ) ok3 = false; } @@ -235,7 +244,7 @@ int main(int argc, char **argv) acceleratorCopyFromDevice(&Ar.data[0], &h1d[0], h1d.size()*sizeof(ComplexD)); for(int64_t j=0;j 1.0e-9 ) ok4 = false; } diff --git a/tests/debug/Test_schur2d_scale.cc b/tests/debug/Test_schur2d_scale.cc index 341111cd4..91fda5650 100644 --- a/tests/debug/Test_schur2d_scale.cc +++ b/tests/debug/Test_schur2d_scale.cc @@ -54,6 +54,15 @@ Author: Peter Boyle using namespace Grid; +// Portable |z|: ComplexD is std::complex on CPU builds and thrust::complex +// under HIP, where std::abs does not resolve (same trap RecursiveSchurInverse +// documents at FrobNorm2Local). Member real()/imag() work on both. +static double Cabs(const ComplexD &z) +{ + double re = z.real(), im = z.imag(); + return std::sqrt(re*re + im*im); +} + static ComplexD Fill(int64_t i, int64_t j, int64_t N) { double x = std::sin(0.7*i + 1.3*j); @@ -61,7 +70,7 @@ static ComplexD Fill(int64_t i, int64_t j, int64_t N) if ( i==j ) return ComplexD(3.0*64 + x, 0.5); // dominance independent of N // band-limit the off-diagonal so row sums stay bounded as N grows: // only |i-j| <= 64 entries are non-zero => sum |offdiag| <= 128*1.42 < 3*64 - if ( std::abs((double)(i-j)) > 64.0 ) return ComplexD(0.0,0.0); + if ( std::fabs((double)(i-j)) > 64.0 ) return ComplexD(0.0,0.0); return ComplexD(x,y); } @@ -149,7 +158,7 @@ int main(int argc, char **argv) for(int64_t li=0;liGlobalMax(gmx); diff --git a/tests/debug/Test_summa.cc b/tests/debug/Test_summa.cc index b96c14a5f..3068bd9ed 100644 --- a/tests/debug/Test_summa.cc +++ b/tests/debug/Test_summa.cc @@ -22,10 +22,10 @@ Author: Peter Boyle // Regression gate for BlockCyclicSumma -- stage 2 of the 2D distributed // dense inverse. CPU build under mpirun: // -// mpirun -n 1 ./Test_summa --grid 8.8.8.8 --mpi 1.1.1.1 -// mpirun -n 2 ./Test_summa --grid 8.8.8.8 --mpi 1.1.1.2 -// mpirun -n 3 ./Test_summa --grid 8.8.8.12 --mpi 1.1.1.3 -// mpirun -n 4 ./Test_summa --grid 8.8.8.8 --mpi 1.1.1.4 +// mpirun -n 1 ./Test_summa --grid 16.16.16.32 --mpi 1.1.1.1 +// mpirun -n 2 ./Test_summa --grid 16.16.16.32 --mpi 1.1.1.2 +// mpirun -n 3 ./Test_summa --grid 16.16.16.48 --mpi 1.1.1.3 +// mpirun -n 4 ./Test_summa --grid 16.16.16.32 --mpi 1.1.1.4 // // Every stage sweeps all process-grid factorisations of P (including the // degenerate 1xP and Px1 rings) and a battery of (N,nb) with ragged @@ -49,6 +49,15 @@ using namespace Grid; static int failures = 0; +// Portable |z|: ComplexD is std::complex on CPU builds and thrust::complex +// under HIP, where std::abs does not resolve (same trap RecursiveSchurInverse +// documents at FrobNorm2Local). Member real()/imag() work on both. +static double Cabs(const ComplexD &z) +{ + double re = z.real(), im = z.imag(); + return std::sqrt(re*re + im*im); +} + static void Report(const std::string &name, bool pass, const std::string &detail="") { std::cout << GridLogMessage << " " << name << (pass ? " PASS" : " ** FAIL **"); @@ -83,7 +92,7 @@ static void RefGemm(ComplexD alpha, const std::vector &A, static double MaxDiff(const std::vector &X, const std::vector &Y) { double m = 0.0; - for(uint64_t i=0;i