/************************************************************************************* Grid physics library, www.github.com/paboyle/Grid Source file: ./tests/debug/Test_multi_reduction.cc Copyright (C) 2026 Author: Peter Boyle This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. See the full license in the file "LICENSE" in the top level distribution directory *************************************************************************************/ /* END LEGAL */ ////////////////////////////////////////////////////////////////////////////// // Gate for the batched Krylov linear algebra in Lattice_reduction.h: // innerProductMulti vs innerProduct, one j at a time // axpyMulti vs sequential axpy // axpyMultiNorm vs sequential axpy + norm2 // on TWO field types through the SAME code path: // fine : LatticeFermionD on the 4D grid (vSpinColourVector) // coarse: Lattice> on a 5D grid with the extra // dimension standing in for nrhs, as the coarse mRHS solver does. // Batch sizes cover every template width and the >16 chunking path. // // mpirun -n 1 ./Test_multi_reduction --grid 8.8.8.8 --mpi 1.1.1.1 ////////////////////////////////////////////////////////////////////////////// #include using namespace Grid; static int failures = 0; static void Report(const std::string &name, bool pass, const std::string &detail="") { std::cout << GridLogMessage << " " << name << (pass ? " PASS" : " ** FAIL **"); if ( detail.size() ) std::cout << " " << detail; std::cout << std::endl; if ( !pass ) failures++; } static double Cabs(const ComplexD &z){ double re=z.real(), im=z.imag(); return std::sqrt(re*re+im*im); } template void Check(const std::string &tag, GridBase *grid, GridParallelRNG &RNG, const std::vector &batches) { const int Mmax = 20; std::vector x; for(int j=0;j win(m); std::vector b(m); for(int j=0;j ip; innerProductMulti(ip,win,r); double worst=0.0; for(int j=0;j seeds({1,2,3,4}); GridParallelRNG RNG4(UGrid); RNG4.SeedFixedIntegers(seeds); GridParallelRNG RNG5(CGrid); RNG5.SeedFixedIntegers(seeds); std::vector batches({1,2,3,4,5,8,9,16,17,20}); Check("fine ", UGrid, RNG4, batches); const int nbasis = 8; typedef iVector>>,nbasis> CoarseSiteVector; typedef Lattice CoarseField; Check("coarse", CGrid, RNG5, batches); std::cout << GridLogMessage << (failures ? "Test_multi_reduction: FAILURES" : "Test_multi_reduction: ALL PASS") << std::endl; Grid_finalize(); return failures ? 1 : 0; }