From fcc412a1c2b9bb546e05ec30c2bb1913cd6a97f5 Mon Sep 17 00:00:00 2001 From: Michael Marshall <43034299+mmphys@users.noreply.github.com> Date: Wed, 13 Nov 2019 11:32:23 +0000 Subject: [PATCH] Remove conditional compilation to support GPU build --- Hadrons/Modules/MDistil/Distil.hpp | 33 +++++++++++------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/Hadrons/Modules/MDistil/Distil.hpp b/Hadrons/Modules/MDistil/Distil.hpp index 0cfd31b4..ca5b3de8 100644 --- a/Hadrons/Modules/MDistil/Distil.hpp +++ b/Hadrons/Modules/MDistil/Distil.hpp @@ -105,33 +105,24 @@ inline void RotateEigen(std::vector & evec) auto grid = evec[0].Grid(); Coordinate siteFirst(grid->Nd(),0); peekSite(cv0, evec[0], siteFirst); - Grid::Complex cplx0 = cv0()()(0); + const std::complex cplx0{cv0()()(0).real(), cv0()()(0).imag()}; if( cplx0.imag() == 0 ) - std::cout << GridLogMessage << "RotateEigen() : Site 0 : " << cplx0 << " => already meets phase convention" << std::endl; + LOG(Message) << "RotateEigen() : Site 0 : " << cplx0 << " => already meets phase convention" << std::endl; else { - const Real cplx0_mag = Grid::sqrt(cplx0.real()*cplx0.real()+cplx0.imag()*cplx0.imag()); - Grid::Complex phase{cplx0 / Grid::Complex(cplx0_mag, 0) }; - phase.imag(-phase.imag()); -#ifdef GRID_NVCC - //const Real cplx0_mag = thrust::abs(cplx0); - //const Grid::Complex phase = thrust::conj(cplx0 / cplx0_mag); - const Real argphase = thrust::arg(phase); -#else - //const Real cplx0_mag = std::abs(cplx0); - //const Grid::Complex phase = std::conj(cplx0 / cplx0_mag); - const Real argphase = std::arg(phase); -#endif - std::cout << GridLogMessage << "RotateEigen() : Site 0 : |" << cplx0 << "|=" << cplx0_mag << " => phase=" << (argphase / M_PI) << " pi" << std::endl; + const Real cplx0_mag{ std::abs(cplx0) }; + const std::complex std_phase{std::conj(cplx0/cplx0_mag)}; + LOG(Message) << "RotateEigen() : Site 0 : |" << cplx0 << "|=" << cplx0_mag + << " => phase=" << (std::arg(std_phase) / M_PI) << " pi" << std::endl; { - // TODO: Only really needed on the master slice + const Grid::Complex phase{std_phase.real(),std_phase.imag()}; for( int k = 0 ; k < evec.size() ; k++ ) evec[k] *= phase; - if(grid->IsBoss()){ - for( int c = 0 ; c < Nc ; c++ ) - cv0()()(c) *= phase; - cplx0.imag(0); // This assumes phase convention is real, positive (so I get rid of rounding error) - //pokeSite(cv0, evec[0], siteFirst); + // Get rid of the rounding error in imaginary phase on the very first site + if(grid->IsBoss()) + { + peekSite(cv0, evec[0], siteFirst); + cv0()()(0).imag(0); // this should be zero after the phase multiply - force it to be so pokeLocalSite(cv0, evec[0], siteFirst); } }