Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,6 @@ namespace Chroma

loadCloverQuda( (void*)(clover) , (void*)(cloverInv) ,&quda_inv_param);
#endif
printQudaInvertParam(&quda_inv_param);
}

//! Destructor is automatic
Expand Down
31 changes: 13 additions & 18 deletions mainprogs/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,19 @@ set(ChromaSingleExecs
t_io t_mesons_w
t_conslinop
t_hypsmear
t_ape_smear
t_dwf4d
t_propagator_s
t_disc_loop_s
t_ritz
t_dwflocality
t_precact_4d
t_precact_5d
t_gauge_force
t_stout_state
t_aniso_gaugeact
t_temp_prec
t_ape_smear
t_dwf4d
t_propagator_s
t_disc_loop_s
t_ritz
t_dwflocality
t_precact_4d
t_precact_5d
t_gauge_force
t_stout_state
t_aniso_gaugeact
t_temp_prec
t_multishift_quda # Not really QUDA Specific. Can call syssolvers
)

if( GMP_FOUND )
Expand Down Expand Up @@ -132,9 +133,3 @@ endif()
target_link_libraries( t_inv_fgmres_dr PRIVATE Chroma::chromalib GTest)
target_include_directories(t_inv_fgmres_dr PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
endif()

if( Chroma_ENABLE_QUDA )
add_executable(t_multishift_quda t_multishift_quda.cc)
target_link_libraries( t_multishift_quda PRIVATE Chroma::chromalib GTest)
target_include_directories(t_multishift_quda PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
endif()
73 changes: 43 additions & 30 deletions mainprogs/tests/t_multishift_quda.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ struct InputParam {
GroupXML_t fermact;
GroupXML_t inv_param;
multi1d<Real> shifts;
int iters;
QDP::Seed rng_seed;
};

Expand All @@ -36,6 +37,16 @@ void read(XMLReader& xml, const std::string& path, InputParam& p)
p.fermact = readXMLGroup(paramtop, "FermionAction", "FermAct");
p.inv_param = readXMLGroup(paramtop, "InvertParam", "invType");
read(paramtop, "shifts", p.shifts);
if( paramtop.count("iters") == 0 ) {
p.iters = 5;
}
else {
read(paramtop, "iters", p.iters);
}
if (paramtop.count("RNG") > 0)
read(paramtop, "RNG", p.rng_seed);
else
p.rng_seed = 11; // default seed
}


Expand Down Expand Up @@ -67,7 +78,6 @@ int main(int argc, char *argv[])
Handle<FermState<T,P,Q> > state;
InputParam p;
Handle<LinOpAsymm_T> M_asymm;
Handle<MdagMMultiSystemSolver<T>> solver;

Chroma::initialize(&argc, &argv);
QDPIO::cout << "Linkage = " << linkageHack() << std::endl;
Expand Down Expand Up @@ -142,51 +152,54 @@ int main(int argc, char *argv[])
QDPIO::cout << "Creating State" << std::endl;
state = S_asymm->createState(u);
M_asymm =dynamic_cast<LinOpAsymm_T *>(S_asymm->linOp(state));
solver = dynamic_cast<MdagMMultiSystemSolver<T>*>(S_asymm->mInvMdagM(state,p.inv_param));


// Do tests here

T rhs= zero;
gaussian(rhs,rb[1]);
int success = 0;

// Zero the initial guesses
auto n_shift = p.shifts.size();
multi1d<T> solns(n_shift);
for(int shift=0; shift < n_shift; ++shift) {
solns[shift] = zero; // Zero all lattice
//(solns[shift])[rb[1]]=zero;
}
for(int i=0 ; i < p.iters; i++) {
QDPIO::cout << "Doing test " << i+1 << " of " << p.iters << std::endl;
// Zero the initial guesses
Handle<MdagMMultiSystemSolver<T>> solver = dynamic_cast<MdagMMultiSystemSolver<T>*>(S_asymm->mInvMdagM(state,p.inv_param));

(*solver)(solns,p.shifts,rhs);
auto n_shift = p.shifts.size();
multi1d<T> solns(n_shift);
for(int shift=0; shift < n_shift; ++shift) {
solns[shift] = zero; // Zero all lattice
//(solns[shift])[rb[1]]=zero;
}

int success = 0;
for(int shift = 0; shift < n_shift; ++shift) {
T r;
r[rb[1]] = zero;
T tmp;
tmp[rb[1]] = zero;
(*solver)(solns,p.shifts,rhs);

(*M_asymm)(tmp,solns[shift],PLUS);
(*M_asymm)(r, tmp, MINUS);
for(int shift = 0; shift < n_shift; ++shift) {
T r;
r[rb[1]] = zero;
T tmp;
tmp[rb[1]] = zero;

r[rb[1]] += p.shifts[shift]*solns[shift];
(*M_asymm)(tmp,solns[shift],PLUS);
(*M_asymm)(r, tmp, MINUS);

// -residudum
r[rb[1]] -= rhs;
r[rb[1]] += p.shifts[shift]*solns[shift];

Double resid_rel = sqrt(norm2(r,rb[1])/norm2(rhs,rb[1]));
QDPIO::cout << "shift="<<shift << " || r || / || b ||=" << resid_rel << " ";
if ( toDouble(resid_rel) >= 1.0e-8 ) {
QDPIO::cout << "FAILED " << std::endl;
success--;
}
else {
QDPIO::cout << "PASSED " << std::endl;
// -residudum
r[rb[1]] -= rhs;

Double resid_rel = sqrt(norm2(r,rb[1])/norm2(rhs,rb[1]));
QDPIO::cout << "shift="<<shift << " || r || / || b ||=" << resid_rel << " ";
if ( toDouble(resid_rel) >= 1.0e-8 ) {
QDPIO::cout << "FAILED " << std::endl;
success--;
}
else {
QDPIO::cout << "PASSED " << std::endl;
}
}
}


// Done with tests
Chroma::finalize();
exit(success);
Expand Down