Skip to content

Commit

Permalink
Force the user to unpack the spinors before
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-ueding committed Nov 3, 2017
1 parent 20032e1 commit 9d27332
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 36 deletions.
18 changes: 3 additions & 15 deletions tests/compare_qdp_spinors.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,14 @@ void expect_near(QdpSpinor &spinor_a,
if (message != nullptr) {
QDPIO::cout << "Spinor comparison: " << message << ": ";
}
QDPIO::cout << "diff/volume = " << diff_norm << ", limit = " << abs_err
<< "\nA = control, B = candidate" << std::endl;
QDPIO::cout << "diff/volume = " << diff_norm << ", limit = " << abs_err << std::endl;

if (QDP::toBool(diff_norm < abs_err)) {
return;
}

QDPIO::cout << "A = control, B = candidate" << std::endl;

uint64_t printed_out = 0;

for (int t = 0; t < geom.Nt(); t++) {
Expand Down Expand Up @@ -134,16 +135,3 @@ void expect_near(QdpSpinor &spinor_a,
assertion(false);
#endif
}

template <typename FT, int veclen, int soalen, bool compress12, typename QdpSpinor>
void expect_near(HybridSpinor<FT, veclen, soalen, compress12, QdpSpinor> &spinor_a,
HybridSpinor<FT, veclen, soalen, compress12, QdpSpinor> &spinor_b,
double const abs_err,
QPhiX::Geometry<FT, veclen, soalen, compress12> &geom,
int const target_cb,
char const *const message = nullptr)
{
spinor_a.unpack();
spinor_b.unpack();
expect_near(spinor_a.qdp(), spinor_b.qdp(), abs_err, geom, target_cb, message);
}
32 changes: 26 additions & 6 deletions tests/testClovDslashFull.cc
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ void TestClover::operator()()
}
hs_source.pack();

{
double norm;
norm2Spinor(norm, hs_source[0], geom, 1);
masterPrintf("Norm-sq of source: %g\n", norm);
assert(norm > 0.0 && "Norm-sq of source must be positive");
}

#if 1
// Test only Dslash operator.
// For clover this will be: A^{-1}_(1-cb,1-cb) D_(1-cb, cb) psi_cb
Expand Down Expand Up @@ -137,8 +144,21 @@ void TestClover::operator()()
dslash(hs_qdp1.qdp(), gauge.u_aniso, hs_source.qdp(), isign, target_cb);
gauge.invclov_qdp.apply(hs_qdp2.qdp(), hs_qdp1.qdp(), isign, target_cb);

expect_near(hs_qdp2,
hs_qphix1,
{
hs_qdp1.pack();
hs_qdp2.pack();

double norm;

norm2Spinor(norm, hs_qdp1[target_cb], geom, 1);
masterPrintf("Norm-sq of hs_qdp1[target_cb]: %g\n", norm);

norm2Spinor(norm, hs_qdp2[target_cb], geom, 1);
masterPrintf("Norm-sq of hs_qdp2[target_cb]: %g\n", norm);
}

expect_near(hs_qdp2.qdp(),
hs_qphix1.qdp(),
1e-6,
geom,
target_cb,
Expand Down Expand Up @@ -225,8 +245,8 @@ void TestClover::operator()()
dslash(hs_qdp1.qdp(), gauge_antip.u_aniso, hs_source.qdp(), isign, target_cb);
gauge_antip.invclov_qdp.apply(hs_qdp2.qdp(), hs_qdp1.qdp(), isign, target_cb);

expect_near(hs_qdp2,
hs_qphix1,
expect_near(hs_qdp2.qdp(),
hs_qphix1.qdp(),
1e-6,
geom,
target_cb,
Expand Down Expand Up @@ -307,8 +327,8 @@ void TestClover::operator()()

hs_qdp1.qdp()[rb[target_cb]] -= betaFactor * ltmp;

expect_near(hs_qdp1,
hs_qphix1,
expect_near(hs_qdp1.qdp(),
hs_qphix1.qdp(),
1e-6,
geom,
target_cb,
Expand Down
8 changes: 6 additions & 2 deletions tests/testDslashFull.cc
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,12 @@ void TestDslash::testDslash(const multi1d<U> &u, int t_bc)

dslash(hs_qdp1.qdp(), gauge.u_aniso, hs_source.qdp(), isign, target_cb);

expect_near(
hs_qdp1, hs_qphix1, tolerance<T>::value, geom, target_cb, "Wilson::Dslash");
expect_near(hs_qdp1.qdp(),
hs_qphix1.qdp(),
tolerance<T>::value,
geom,
target_cb,
"Wilson::Dslash");
} // cb
} // isign
}
Expand Down
23 changes: 15 additions & 8 deletions tests/testTWMCloverFull.cc
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ void TestTMClover::operator()()
gauge_inv_clov_array[target_cb],
isign,
target_cb);
hs_qphix1.unpack();

// (b) Apply QDP Dslash
qdp_dslash(hs_qdp1.qdp(),
Expand All @@ -165,8 +166,12 @@ void TestTMClover::operator()()
isign,
target_cb);

expect_near(
hs_qdp1, hs_qphix1, 1e-6, geom, target_cb, "Twisted-mass clover dslash");
expect_near(hs_qdp1.qdp(),
hs_qphix1.qdp(),
1e-6,
geom,
target_cb,
"Twisted-mass clover dslash");
} // cb
} // isign
#endif
Expand All @@ -190,7 +195,7 @@ void TestTMClover::operator()()
beta,
isign,
target_cb);

hs_qphix1.unpack();

// (b) Apply QDP Dslash
qdp_achimbdpsi(hs_qdp1.qdp(),
Expand All @@ -201,7 +206,7 @@ void TestTMClover::operator()()
isign,
target_cb);

expect_near(hs_qdp1, hs_qphix1, 1e-6, geom, target_cb, "Twisted-mass clover achimbdpsi");
expect_near(hs_qdp1.qdp(), hs_qphix1.qdp(), 1e-6, geom, target_cb, "Twisted-mass clover achimbdpsi");
} // cb
} // isign
#endif
Expand All @@ -228,7 +233,8 @@ void TestTMClover::operator()()
for (int const isign : {1, -1}) {

// (a) Apply QPhiX Operator
M(hs_qphix1[1], hs_source[1], isign);
M(hs_qphix1[cb], hs_source[cb], isign);
hs_qphix1.unpack();

// (b) Apply QDP Dslash
qdp_apply_operator(hs_qdp1.qdp(),
Expand All @@ -239,7 +245,7 @@ void TestTMClover::operator()()
isign,
cb);

expect_near(hs_qdp1, hs_qphix1, 1e-6, geom, cb, "TM clover linop");
expect_near(hs_qdp1.qdp(), hs_qphix1.qdp(), 1e-6, geom, cb, "TM clover linop");

} // isign

Expand Down Expand Up @@ -282,6 +288,7 @@ void TestTMClover::operator()()
gauge.invclov_qdp,
1,
cb);
hs_qphix2.unpack();

// chi3 = M^\dagger chi2
qdp_apply_operator(hs_qdp1.qdp(),
Expand All @@ -292,7 +299,7 @@ void TestTMClover::operator()()
-1,
cb);

expect_near(hs_source, hs_qdp1, 1e-8, geom, cb, "TM Clover CG");
expect_near(hs_source.qdp(), hs_qdp1.qdp(), 1e-8, geom, cb, "TM Clover CG");

int Nxh = Nx / 2;
unsigned long num_cb_sites = Nxh * Ny * Nz * Nt;
Expand Down Expand Up @@ -344,7 +351,7 @@ void TestTMClover::operator()()
1,
cb);

expect_near(hs_source, hs_qphix2, 1e-8, geom, cb, "TM Clover BiCGStab");
expect_near(hs_source.qdp(), hs_qphix2.qdp(), 1e-8, geom, cb, "TM Clover BiCGStab");

int Nxh = Nx / 2;
unsigned long num_cb_sites = Nxh * Ny * Nz * Nt;
Expand Down
10 changes: 5 additions & 5 deletions tests/testTWMDslashFull.cc
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ void TestTMDslash::testTWMDslash(int t_bc)
isign,
target_cb);

expect_near(hs_qdp1, hs_qphix1, 1e-6, geom, target_cb, "Dslash");
expect_near(hs_qdp1.qdp(), hs_qphix1.qdp(), 1e-6, geom, target_cb, "Dslash");
} // cb
} // isign
}
Expand Down Expand Up @@ -312,7 +312,7 @@ void TestTMDslash::testTWMDslashAChiMBDPsi(int t_bc)
isign,
target_cb);

expect_near(hs_qdp1, hs_qphix1, 1e-6, geom, target_cb, "A chi - b D psi");
expect_near(hs_qdp1.qdp(), hs_qphix1.qdp(), 1e-6, geom, target_cb, "A chi - b D psi");
} // cb
} // isign
}
Expand Down Expand Up @@ -385,7 +385,7 @@ void TestTMDslash::testTWMM(int t_bc)
isign,
target_cb);

expect_near(hs_qdp1, hs_qphix1, 1e-6, geom, target_cb, "TM Fermion Matrix");
expect_near(hs_qdp1.qdp(), hs_qphix1.qdp(), 1e-6, geom, target_cb, "TM Fermion Matrix");
}
}
}
Expand Down Expand Up @@ -502,7 +502,7 @@ void TestTMDslash::testTWMCG(int t_bc)
(site_flops + (72 + 2 * 1320) * mv_apps) * num_cb_sites;
masterPrintf("GFLOPS=%e\n", 1.0e-9 * (double)(total_flops) / (end - start));

expect_near(hs_source, hs_qdp2, 1e-8, geom, source_target_cb, "CG");
expect_near(hs_source.qdp(), hs_qdp2.qdp(), 1e-8, geom, source_target_cb, "CG");
}

template <typename T, int V, int S, bool compress, typename U, typename Phi>
Expand Down Expand Up @@ -596,7 +596,7 @@ void TestTMDslash::testTWMBiCGStab(int t_bc)
isign,
cb);

expect_near(hs_source, hs_qdp1, 1e-8, geom, cb, "TM Wilson BiCGStab");
expect_near(hs_source.qdp(), hs_qdp1.qdp(), 1e-8, geom, cb, "TM Wilson BiCGStab");

unsigned long num_cb_sites = Layout::vol() / 2;
unsigned long total_flops =
Expand Down

0 comments on commit 9d27332

Please sign in to comment.