32 const int latt_coord[4],
40 multi1d<LatticeColorMatrix>&
u = *(multi1d<LatticeColorMatrix>*)env;
45 int node = Layout::nodeNumber(
coord);
46 int linear = Layout::linearSiteIndex(
coord);
48 if (node != Layout::nodeNumber()) {
50 QDPIO::cerr << __func__ <<
": wrong coordinates for this node" << std::endl;
58 double val = (reim == 0) ?
59 toDouble(
u[
mu].elem(linear).elem().elem(row,col).real()) :
60 toDouble(
u[
mu].elem(linear).elem().elem(row,col).imag());
70 double fermionReader(
const int latt_coord[5],
79 multi1d<LatticeFermion>&
psi = *(multi1d<LatticeFermion>*)env;
82 int s = latt_coord[
Nd];
85 int node = Layout::nodeNumber(
coord);
86 int linear = Layout::linearSiteIndex(
coord);
88 if (node != Layout::nodeNumber()) {
90 QDPIO::cerr << __func__ <<
": wrong coordinates for this node" << std::endl;
98 double val = (reim == 0) ?
99 double(
psi[
s].elem(linear).elem(spin).elem(color).real()) :
100 double(
psi[
s].elem(linear).elem(spin).elem(color).imag());
113 void fermionWriter(
const int latt_coord[5],
124 multi1d<LatticeFermion>&
psi = *(multi1d<LatticeFermion>*)env;
127 int s = latt_coord[
Nd];
130 int node = Layout::nodeNumber(
coord);
131 int linear = Layout::linearSiteIndex(
coord);
133 if (node != Layout::nodeNumber()) {
134 QDPIO::cerr << __func__ <<
": wrong coordinates for this node" << std::endl;
149 psi[
s].elem(linear).elem(spin).elem(color).real() = val;
151 psi[
s].elem(linear).elem(spin).elem(color).imag() = val;
158 void sublattice_func(
int lo[],
169 const multi1d<int>& local_subgrid=Layout::subgridLattSize();
170 for(
int i=0;
i <
Nd;
i++) {
173 lo[
i]=node[
i]*local_subgrid[
i];
178 hi[
i]=(node[
i]+1)*local_subgrid[
i];
193 const multi1d<LatticeFermion>&
chi)
const
199 int out_iters_single=0;
200 int out_iters_double=0;
211 double out_eps_single;
215 QOP_F3_MDWF_Gauge *sprec_gauge = NULL;
216 if ( QOP_F3_MDWF_import_gauge(&sprec_gauge,
220 QDPIO::cerr <<
"MDWF Error: "<< QOP_MDWF_error(
state) << std::endl;
225 QOP_F3_MDWF_Fermion *sprec_rhs;
226 QOP_F3_MDWF_Fermion *sprec_x0;
227 QOP_F3_MDWF_Fermion *sprec_soln;
229 if( QOP_F3_MDWF_import_fermion(&sprec_rhs,
232 (
void *)&
chi) != 0 ) {
233 QDPIO::cerr <<
"MDWF Error: "<< QOP_MDWF_error(
state) << std::endl;
237 if( QOP_F3_MDWF_import_fermion(&sprec_x0,
240 (
void *)&
psi) != 0 ) {
241 QDPIO::cerr <<
"MDWF Error: "<< QOP_MDWF_error(
state) << std::endl;
245 if( QOP_F3_MDWF_allocate_fermion(&sprec_soln,
247 QDPIO::cerr <<
"MDWF Error: "<< QOP_MDWF_error(
state) << std::endl;
253 double target_epsilon = toDouble(invParam.RsdCG*invParam.RsdCG);
254 int max_iteration = invParam.MaxCG;
257 QDPIO::cout <<
"MDWFQpropT: Beginning Single Precision Solve" << std::endl;
258 if( ( status=QOP_F3_MDWF_DDW_CG(sprec_soln,
267 QOP_MDWF_LOG_NONE)) != 0 ) {
268 QDPIO::cerr <<
"MDWF Error: "<< QOP_MDWF_error(
state) << std::endl;
273 if( QOP_MDWF_performance(&time_sec,
278 QDPIO::cerr <<
"MDWF_Error: "<< QOP_MDWF_error(
state) << std::endl;
283 QDPIO::cout <<
"MDWFQpropT Single Prec : status=" << status
284 <<
" iterations=" << out_iters_single
285 <<
" resulting epsilon=" << sqrt(out_eps_single) << std::endl;
288 FlopCounter flopcount_single;
289 flopcount_single.reset();
290 flopcount_single.addFlops(flops);
291 flopcount_single.report(
"MDWFQpropT_Single_Prec:", time_sec);
294 if( QOP_F3_MDWF_export_fermion(fermionWriter,
297 QDPIO::cerr <<
"MDWF Error: "<< QOP_MDWF_error(
state) << std::endl;
302 QOP_F3_MDWF_free_fermion(&sprec_soln);
303 QOP_F3_MDWF_free_fermion(&sprec_x0);
304 QOP_F3_MDWF_free_fermion(&sprec_rhs);
305 QOP_F3_MDWF_free_gauge(&sprec_gauge);
307 res.
n_count = out_iters_single;
313 double out_eps_double;
317 QOP_D3_MDWF_Gauge *dprec_gauge = NULL;
318 if ( QOP_D3_MDWF_import_gauge(&dprec_gauge,
322 QDPIO::cerr <<
"MDWF Error: "<< QOP_MDWF_error(
state) << std::endl;
327 QOP_D3_MDWF_Fermion *dprec_rhs;
328 QOP_D3_MDWF_Fermion *dprec_x0;
329 QOP_D3_MDWF_Fermion *dprec_soln;
331 if( QOP_D3_MDWF_import_fermion(&dprec_rhs,
334 (
void *)&
chi) != 0 ) {
335 QDPIO::cerr <<
"MDWF Error: "<< QOP_MDWF_error(
state) << std::endl;
339 if( QOP_D3_MDWF_import_fermion(&dprec_x0,
342 (
void *)&
psi) != 0 ) {
343 QDPIO::cerr <<
"MDWF Error: "<< QOP_MDWF_error(
state) << std::endl;
347 if( QOP_D3_MDWF_allocate_fermion(&dprec_soln,
349 QDPIO::cerr <<
"MDWF Error: "<< QOP_MDWF_error(
state) << std::endl;
354 double target_epsilon = toDouble(invParam.RsdCGRestart*invParam.RsdCGRestart);
355 int max_iteration = invParam.MaxCGRestart;
359 QDPIO::cout <<
"MDWFQpropT: Beginning Double Precision Solve" << std::endl;
360 if( ( status=QOP_D3_MDWF_DDW_CG(dprec_soln,
369 QOP_MDWF_LOG_NONE)) != 0 ) {
370 QDPIO::cerr <<
"MDWF Error: "<< QOP_MDWF_error(
state) << std::endl;
375 if( QOP_MDWF_performance(&time_sec,
380 QDPIO::cerr <<
"MDWF_Error: "<< QOP_MDWF_error(
state) << std::endl;
384 QDPIO::cout <<
"MDWFQpropT Double Prec: status=" << status
385 <<
" iterations=" << out_iters_double
386 <<
" resulting epsilon=" << sqrt(out_eps_double) << std::endl;
389 FlopCounter flopcount_double;
390 flopcount_double.reset();
391 flopcount_double.addFlops(flops);
392 flopcount_double.report(
"MDWFQpropT_Double_Prec:", time_sec);
395 if( QOP_D3_MDWF_export_fermion(fermionWriter,
398 QDPIO::cerr <<
"MDWF Error: "<< QOP_MDWF_error(
state) << std::endl;
403 QOP_D3_MDWF_free_fermion(&dprec_soln);
404 QOP_D3_MDWF_free_fermion(&dprec_x0);
405 QOP_D3_MDWF_free_fermion(&dprec_rhs);
406 QOP_D3_MDWF_free_gauge(&dprec_gauge);
409 res.
n_count += out_iters_double;
414 multi1d<LatticeFermion>
r(
N5);
417 res.
resid = sqrt(norm2(
r));
419 QDPIO::cout <<
"MDWF Final: single_iters=" << out_iters_single <<
" double_iters=" << out_iters_double <<
" total_iters=" << res.
n_count << std::endl;
420 QDPIO::cout <<
"MDWF Final: final absolute unprec residuum="<<res.
resid<<std::endl;
433 QDPIO::cout <<
"This will only work for Nd=4" << std::endl;
438 QDPIO::cout <<
"This will only work for Nc=3" << std::endl;
444 std::istringstream is(inv.
xml);
445 XMLReader paramtop(is);
449 QDPIO::cerr <<
"CGDWFQpropT: only support a CG inverter" << std::endl;
456 multi1d<int> lattice(5);
457 multi1d<int> network(4);
458 multi1d<int> node_coords(4);
463 lattice[
mu] = Layout::lattSize()[
mu];
468 network[
mu] = Layout::logicalSize()[
mu];
469 node_coords[
mu] = Layout::nodeCoord()[
mu];
474 if( Layout::primaryNode() ) {
482 QDPIO::cout <<
"MDWFQpropT: Initializing MDWF Library Version " << QOP_MDWF_version() << std::endl;
485 if( QOP_MDWF_init(&
state, lattice.slice(), network.slice(),
486 node_coords.slice(), master_p, sublattice_func,
489 QDPIO::cerr <<
"MDWF Error: " << QOP_MDWF_error(
state) << std::endl;
495 u = fermstate->getLinks();
498 if (anisoParam.anisoP) {
499 ff = where(anisoParam.anisoP, anisoParam.nu / anisoParam.xi_0, Real(1));
500 for(
int mu=0;
mu <
u.size(); ++
mu) {
501 if (
mu != anisoParam.t_dir)
508 double a5 = (double)1;
513 double M5 = (double)(-5) + toDouble((
double)1 +
a5*((
double)1 + (
double)(
Nd-1)*ff -
OverMass));
515 double m_f = toDouble(
Mass);
518 QDPIO::cerr <<
"MDWF Error: " << QOP_MDWF_error(
state)<< std::endl;
529 void MDWFQpropT::fini(
void)
532 QDPIO::cout <<
"MDWFQpropT: Finalizing MDWF Library Version " << QOP_MDWF_version() << std::endl;
535 QOP_MDWF_free_parameters(&
params);
539 QOP_MDWF_fini(&
state);
Support class for fermion actions and linear operators.
Class for counted reference semantics.
Even-odd const determinant Wilson-like fermact.
void read(XMLReader &xml, const std::string &path, AsqtadFermActParams ¶m)
Read parameters.
DWF/SSE double-prec solver.
double gaugeReader(const void *OuterGauge, void *env, const int latt_coord[4], int mu, int row, int col, int reim)
void init(MesonSpecData_t &data, XMLWriter &xml, const std::string &path, const std::string &id_tag, const Params ¶ms)
Do some initialization.
multi1d< Hadron2PtContraction_t > operator()(const multi1d< LatticeColorMatrix > &u)
Asqtad Staggered-Dirac operator.
static multi1d< LatticeColorMatrix > u
const WilsonTypeFermAct< multi1d< LatticeFermion > > Handle< const ConnectState > state
multi1d< LatticeFermion > r(Ncb)
Hold group xml and type id.
Holds return info from SystemSolver call.