43 #define _DEBUG_BB_C_ 0
50 "$Header: /home/bjoo/fromJLAB/cvsroot/chroma_base/lib/meas/hadron/BuildingBlocks_w.cc,v 3.7 2007-06-10 14:40:23 edwards Exp $";
67 const LatticePropagator &
F,
70 const SftMom & PhasesCanonical,
71 multi2d< BinaryFileWriter > & BinaryWriters,
72 multi1d< int > & GBB_NLinkPatterns,
73 multi2d< int > & GBB_NMomPerms,
75 const multi1d< unsigned short int > & LinkDirs,
76 const signed short int T1,
77 const signed short int T2,
78 const signed short int Tsrc,
79 const signed short int Tsnk,
80 const bool TimeReverse,
81 const bool ShiftFlag )
99 const unsigned short int NLinks = LinkDirs.size();
100 unsigned short int Link;
101 const int NumQ = Phases.
numMom();
102 const int NumO = BinaryWriters.size1();
112 for(
int o = 0; o < NumO; o ++ )
114 BinaryWriters(f,o).write( NLinks );
116 #if _DEBUG_BB_C_ == 1
118 QDPIO::cout <<
"DEBUG: " << __FILE__ <<
" " << __LINE__ <<
"\n";
119 QDPIO::cout <<
"q = " << o <<
"\n";
120 QDPIO::cout <<
"f = " << f <<
"\n";
121 QDPIO::cout <<
"NLinks = " << NLinks <<
"\n";
125 for( Link = 0; Link < NLinks; Link ++ )
128 if( ( TimeReverse ==
true ) & ( ( LinkDirs[ Link ] == 3 ) || ( LinkDirs[ Link ] == 7 ) ) )
130 BinaryWriters(f,o).write( (
unsigned short int)(( LinkDirs[ Link ] + 4 ) % 8) );
134 BinaryWriters(f,o).write( LinkDirs[ Link ] );
137 #if _DEBUG_BB_C_ == 1
139 QDPIO::cout <<
"Link = " << Link <<
"\n";
140 QDPIO::cout <<
"LinkDirs[ Link ] = " << LinkDirs[ Link ] <<
"\n";
146 GBB_NLinkPatterns[f] ++;
150 IOTime += Timer.getTimeInSeconds();
152 for(
int i = 0;
i < Ns * Ns;
i ++ )
158 LatticePropagator GFG = Gamma(
i) *
F * Gamma( GammaInsertion );
165 if( ( TimeReverse ==
true ) & (
i < 8 ) ) GFG *= -1;
169 GFGTime += Timer.getTimeInSeconds();
177 IPTime += Timer.getTimeInSeconds();
181 multi2d< DComplex > Projections = Phases.
sft( Trace );
184 FTTime += Timer.getTimeInSeconds();
190 for(
int q = 0;
q < NumQ;
q ++ )
192 multi1d< DComplex > Projection = Projections[
q ];
198 QDPIO::cerr << __func__ <<
": internal error: failed to find index of ordered momentum" << std::endl;
202 const signed short int QX =
Q[0];
203 const signed short int QY =
Q[1];
204 const signed short int QZ =
Q[2];
205 BinaryWriters(f,o).write( QX );
206 BinaryWriters(f,o).write( QY );
207 BinaryWriters(f,o).write( QZ );
210 GBB_NMomPerms(f,o) ++;
212 float real_part[ T2 - T1 + 1 ];
213 float imag_part[ T2 - T1 + 1 ];
216 for(
int t = T1;
t <= T2;
t ++ )
218 float r = toFloat( real( Projection[
t ] ) );
219 float i = toFloat( imag( Projection[
t ] ) );
223 if( TimeReverse ==
true ){
226 int t_shifted = (
t - Tsrc + NT )%NT ;
228 int t_reversed = (NT - t_shifted)%NT;
233 t_prime = (t_reversed + Tsrc)%NT ;
235 t_prime = t_reversed ;
241 if((ShiftFlag==
true)&&(TimeReverse==
false))
242 t_prime = (
t - Tsrc + NT )%NT ;
247 real_part[ t_prime ] =
r;
248 imag_part[ t_prime ] =
i;
250 #if _DEBUG_BB_C_ == 1
252 QDPIO::cout <<
"DEBUG: " << __FILE__ <<
" " << __LINE__ <<
"\n";
253 QDPIO::cout <<
"q = " <<
q <<
"\n";
254 QDPIO::cout <<
"o = " << o <<
"\n";
255 QDPIO::cout <<
"f = " << f <<
"\n";
256 QDPIO::cout <<
"t = " <<
t <<
"\n";
257 QDPIO::cout <<
"r = " <<
r <<
"\n";
258 QDPIO::cout <<
"i = " <<
i <<
"\n";
264 for(
int t = 0;
t < (T2-T1+1);
t ++ )
266 BinaryWriters(f,o).write( real_part[
t] );
267 BinaryWriters(f,o).write( imag_part[
t] );
272 IOTime += Timer.getTimeInSeconds();
275 QDPIO::cout << __func__ <<
": io time = " << IOTime <<
" seconds" << std::endl;
276 QDPIO::cout << __func__ <<
": gfg time = " << GFGTime / (double) GFGCalls <<
" seconds" << std::endl;
277 QDPIO::cout << __func__ <<
": ip time = " << IPTime / (double) IPCalls <<
" seconds" << std::endl;
278 QDPIO::cout << __func__ <<
": ft time = " << FTTime / (double) FTCalls <<
" seconds" << std::endl;
280 QDPIO::cout << __func__ <<
": total time = " << TotalTime.getTimeInSeconds() <<
" seconds" << std::endl;
289 void AddLinks(
const multi1d< LatticePropagator > & B,
290 const LatticePropagator &
F,
291 const multi1d< LatticeColorMatrix > &
U,
292 const multi1d< int > & GammaInsertions,
294 const SftMom & PhasesCanonical,
295 multi1d< unsigned short int > & LinkDirs,
296 const unsigned short int MaxNLinks,
298 const short int PreviousDir,
299 const short int PreviousMu,
300 multi2d< BinaryFileWriter > & BinaryWriters,
301 multi1d< int > & GBB_NLinkPatterns,
302 multi2d< int > & GBB_NMomPerms,
303 const signed short int T1,
304 const signed short int T2,
305 const signed short int Tsrc,
306 const signed short int Tsnk,
307 const bool TimeReverse,
308 const bool ShiftFlag )
312 double ShiftTime = 0.0;
314 const unsigned short int NLinks = LinkDirs.size();
316 if( NLinks == MaxNLinks )
321 LatticePropagator F_mu;
322 const int NF = B.size();
323 multi1d< unsigned short int > NextLinkDirs( NLinks + 1 );
326 for( Link = 0; Link < NLinks; Link ++ )
328 NextLinkDirs[ Link ] = LinkDirs[ Link ];
335 if( ( PreviousDir != -1 ) || ( PreviousMu !=
mu ) )
337 bool DoThisPattern =
true;
338 bool DoFurtherPatterns =
true;
340 NextLinkDirs[ NLinks ] =
mu;
342 LinkPattern( DoThisPattern, DoFurtherPatterns, NextLinkDirs );
344 if( DoFurtherPatterns ==
true )
353 ShiftTime += Timer.getTimeInSeconds();
357 if( DoThisPattern ==
true )
360 for(
int f = 0; f < NF; f ++ )
362 BkwdFrwdTr( B[ f ], F_mu, GammaInsertions[ f ], Phases, PhasesCanonical,
363 BinaryWriters, GBB_NLinkPatterns, GBB_NMomPerms,
364 f, NextLinkDirs, T1, T2, Tsrc, Tsnk, TimeReverse, ShiftFlag );
368 if( DoFurtherPatterns ==
true )
372 Phases, PhasesCanonical,
373 NextLinkDirs, MaxNLinks, LinkPattern, 1,
mu,
374 BinaryWriters, GBB_NLinkPatterns, GBB_NMomPerms,
375 T1, T2, Tsrc, Tsnk, TimeReverse, ShiftFlag );
384 if( ( PreviousDir != 1 ) || ( PreviousMu !=
mu ) )
386 bool DoThisPattern =
true;
387 bool DoFurtherPatterns =
true;
389 NextLinkDirs[ NLinks ] =
mu +
Nd;
391 LinkPattern( DoThisPattern, DoFurtherPatterns, NextLinkDirs );
393 if( DoFurtherPatterns ==
true )
402 ShiftTime += Timer.getTimeInSeconds();
406 if( DoThisPattern ==
true )
409 for(
int f = 0; f < NF; f ++ )
411 BkwdFrwdTr( B[ f ], F_mu, GammaInsertions[ f ], Phases, PhasesCanonical,
412 BinaryWriters, GBB_NLinkPatterns, GBB_NMomPerms,
413 f, NextLinkDirs, T1, T2, Tsrc, Tsnk, TimeReverse, ShiftFlag );
417 if( DoFurtherPatterns ==
true )
420 AddLinks( B, F_mu,
U, GammaInsertions, Phases, PhasesCanonical,
421 NextLinkDirs, MaxNLinks, LinkPattern, -1,
mu, BinaryWriters,
422 GBB_NLinkPatterns, GBB_NMomPerms,
423 T1, T2, Tsrc, Tsnk, TimeReverse, ShiftFlag );
428 QDPIO::cout << __func__ <<
": shift time = "
430 <<
" seconds with shift calls = "
442 const LatticePropagator &
F,
443 const multi1d< LatticeColorMatrix > &
U,
444 const multi1d< int > & GammaInsertions,
445 const multi1d< int > & Flavors,
446 const unsigned short int MaxNLinks,
449 const SftMom & PhasesCanonical,
450 const multi2d< std::string > & BinaryDataFileNames,
451 const signed short int T1,
452 const signed short int T2,
453 const signed short int Tsrc,
454 const signed short int Tsnk,
456 const multi1d< int >& SnkMom,
457 const signed short int DecayDir,
458 const bool TimeReverse,
459 const bool ShiftFlag )
474 if ( BinaryDataFileNames.size1() != PhasesCanonical.
numMom() )
476 QDPIO::cerr << __func__ <<
": number of datafile names incompatible with number of momenta"
481 const int NumF = B.size();
482 const int NumO = BinaryDataFileNames.size1();
483 multi2d< BinaryFileWriter > BinaryWriters( NumF, NumO );
484 multi1d< int > GBB_NLinkPatterns( NumF );
485 multi2d< int > GBB_NMomPerms( NumF, NumO );
487 for(
int f = 0; f < NumF; f ++ )
489 GBB_NLinkPatterns[f] = 0;
490 for(
int o = 0; o < NumO; o ++ )
492 BinaryWriters(f,o).open( BinaryDataFileNames(f,o) );
493 GBB_NMomPerms(f,o) = 0;
498 QDPIO::cout << __func__ <<
": time to open files = "
499 << Timer.getTimeInSeconds()
500 <<
" seconds" << std::endl;
509 QDPIO::cout << __func__ <<
": start BkwdFrwdTr" << std::endl;
511 const unsigned short int NLinks = 0;
512 multi1d< unsigned short int > LinkDirs( 0 );
514 for(
int f = 0; f < NumF; f ++ )
516 BkwdFrwdTr( B[ f ],
F, GammaInsertions[ f ], Phases, PhasesCanonical,
517 BinaryWriters, GBB_NLinkPatterns, GBB_NMomPerms, f, LinkDirs,
519 TimeReverse, ShiftFlag );
523 QDPIO::cout << __func__ <<
": total time for 0 links (single BkwdFrwdTr call) = "
524 << Timer.getTimeInSeconds()
525 <<
" seconds" << std::endl;
530 QDPIO::cout << __func__ <<
": start AddLinks" << std::endl;
533 Phases, PhasesCanonical,
534 LinkDirs, MaxNLinks, LinkPattern, 0, -1,
535 BinaryWriters, GBB_NLinkPatterns, GBB_NMomPerms,
536 T1, T2, Tsrc, Tsnk, TimeReverse, ShiftFlag );
539 QDPIO::cout << __func__ <<
": total time for remaining links (outermost AddLinks call) = "
540 << Timer.getTimeInSeconds()
541 <<
" seconds" << std::endl;
550 const unsigned short int Id = 0;
551 const unsigned short int Version = 3;
552 const unsigned short int Contraction = 0;
553 const unsigned short int NX = Layout::lattSize()[0];
554 const unsigned short int NY = Layout::lattSize()[1];
555 const unsigned short int NZ = Layout::lattSize()[2];
556 const unsigned short int NT = Layout::lattSize()[3];
557 const signed short int PX = SnkMom[0];
558 const signed short int PY = SnkMom[1];
559 const signed short int PZ = SnkMom[2];
560 const signed short int SeqSourceLen = 64;
562 SeqSource.resize(SeqSourceLen, 0);
564 for(
int f = 0; f < NumF; f ++ )
566 const signed short int Flavor = Flavors[f];
567 const signed short int GammaInsertion = GammaInsertions[f];
568 const unsigned short int NLinkPatterns = GBB_NLinkPatterns[f] / NumO;
570 for(
int o = 0; o < NumO; o ++ )
572 const unsigned short int NMomPerms = GBB_NMomPerms(f,o) / (Ns * Ns * NLinkPatterns);
574 #if _DEBUG_BB_C_ == 1
576 multi1d< int >
Q = PhasesCanonical.
numToMom( o );
577 const signed short int QX =
Q[0];
578 const signed short int QY =
Q[1];
579 const signed short int QZ =
Q[2];
581 QDPIO::cout <<
"DEBUG: " << __FILE__ <<
" " << __LINE__ <<
"\n";
583 QDPIO::cout <<
"Id = " << Id <<
"\n";
584 QDPIO::cout <<
"Version = " << Version <<
"\n";
585 QDPIO::cout <<
"Flavor = " <<
Flavor <<
"\n";
586 QDPIO::cout <<
"Contraction = " << Contraction <<
"\n";
587 QDPIO::cout <<
"SeqSource = " << SeqSource <<
"\n";
588 QDPIO::cout <<
"GammaInsertion = " << GammaInsertion<<
"\n";
589 QDPIO::cout <<
"NX = " << NX <<
"\n";
590 QDPIO::cout <<
"NY = " << NY <<
"\n";
591 QDPIO::cout <<
"NZ = " << NZ <<
"\n";
592 QDPIO::cout <<
"NT = " << NT <<
"\n";
593 QDPIO::cout <<
"T1 = " << T1 <<
"\n";
594 QDPIO::cout <<
"T2 = " << T2 <<
"\n";
595 QDPIO::cout <<
"MaxNLinks = " << MaxNLinks <<
"\n";
596 QDPIO::cout <<
"NLinkPatterns = " << NLinkPatterns <<
"\n";
597 QDPIO::cout <<
"NMomPerms = " << NMomPerms <<
"\n";
598 QDPIO::cout <<
"Canonical Index = " << o <<
"\n";
599 QDPIO::cout <<
"QX = " << QX <<
"\n";
600 QDPIO::cout <<
"QY = " << QY <<
"\n";
601 QDPIO::cout <<
"QZ = " << QZ <<
"\n";
602 QDPIO::cout <<
"PX = " << PX <<
"\n";
603 QDPIO::cout <<
"PY = " << PY <<
"\n";
604 QDPIO::cout <<
"PZ = " << PZ <<
"\n";
609 BinaryWriters(f,o).write(
Flavor );
610 BinaryWriters(f,o).write( Contraction );
611 BinaryWriters(f,o).writeArray( SeqSource.data(), 1, SeqSourceLen );
612 BinaryWriters(f,o).write( GammaInsertion );
613 BinaryWriters(f,o).write( NX );
614 BinaryWriters(f,o).write( NY );
615 BinaryWriters(f,o).write( NZ );
616 BinaryWriters(f,o).write( NT );
617 BinaryWriters(f,o).write( DecayDir );
618 BinaryWriters(f,o).write( T1 );
619 BinaryWriters(f,o).write( T2 );
620 BinaryWriters(f,o).write( MaxNLinks );
621 BinaryWriters(f,o).write( NLinkPatterns );
622 BinaryWriters(f,o).write( NMomPerms );
623 BinaryWriters(f,o).write( PX );
624 BinaryWriters(f,o).write( PY );
625 BinaryWriters(f,o).write( PZ );
626 BinaryWriters(f,o).write( BinaryWriters(f,o).getChecksum() );
628 BinaryWriters(f,o).write( Id );
629 BinaryWriters(f,o).write( Version );
631 BinaryWriters(f,o).close();
636 QDPIO::cout << __func__ <<
": time to write footer = "
637 << Timer.getTimeInSeconds()
638 <<
" seconds" << std::endl;
641 QDPIO::cout << __func__ <<
": total time = "
642 << TotalTime.getTimeInSeconds()
643 <<
" seconds" << std::endl;
Primary include file for CHROMA library code.
Fourier transform phase factor support.
int numSubsets() const
Number of subsets - length in decay direction.
multi1d< int > numToMom(int mom_num) const
Convert momenta id to actual array of momenta.
int momToNum(const multi1d< int > &mom_in) const
Convert array of momenta to momenta id.
multi2d< DComplex > sft(const LatticeComplex &cf) const
Do a sumMulti(cf*phases,getSet())
int numMom() const
Number of momenta.
void(* BBLinkPattern)(bool &DoThisPattern, bool &DoFurtherPatterns, multi1d< unsigned short int > &LinkPattern)
Used to Set Requested Link Patterns.
QDPSubTypeTrait< typename BinaryReturn< C1, C2, FnLocalInnerProduct >::Type_t >::Type_t localInnerProduct(const QDPSubType< T1, C1 > &l, const QDPType< T2, C2 > &r)
Asqtad Staggered-Dirac operator.
LinOpSysSolverMGProtoClover::Q Q
static const char *const CVSBuildingBlocks_hh
void BuildingBlocks(const multi1d< LatticePropagator > &B, const LatticePropagator &F, const multi1d< LatticeColorMatrix > &U, const multi1d< int > &GammaInsertions, const multi1d< int > &Flavors, const unsigned short int MaxNLinks, const BBLinkPattern LinkPattern, const SftMom &Phases, const SftMom &PhasesCanonical, const multi2d< std::string > &BinaryDataFileNames, const signed short int T1, const signed short int T2, const signed short int Tsrc, const signed short int Tsnk, const std::string &SeqSourceType, const multi1d< int > &SnkMom, const signed short int DecayDir, const bool TimeReverse, const bool ShiftFlag)
void AddLinks(const multi1d< LatticePropagator > &B, const LatticePropagator &F, const multi1d< LatticeColorMatrix > &U, const multi1d< int > &GammaInsertions, const SftMom &Phases, const SftMom &PhasesCanonical, multi1d< unsigned short int > &LinkDirs, const unsigned short int MaxNLinks, BBLinkPattern LinkPattern, const short int PreviousDir, const short int PreviousMu, multi2d< BinaryFileWriter > &BinaryWriters, multi1d< int > &GBB_NLinkPatterns, multi2d< int > &GBB_NMomPerms, const signed short int T1, const signed short int T2, const signed short int Tsrc, const signed short int Tsnk, const bool TimeReverse, const bool ShiftFlag)
void BkwdFrwdTr(const LatticePropagator &B, const LatticePropagator &F, int GammaInsertion, const SftMom &Phases, const SftMom &PhasesCanonical, multi2d< BinaryFileWriter > &BinaryWriters, multi1d< int > &GBB_NLinkPatterns, multi2d< int > &GBB_NMomPerms, const int f, const multi1d< unsigned short int > &LinkDirs, const signed short int T1, const signed short int T2, const signed short int Tsrc, const signed short int Tsnk, const bool TimeReverse, const bool ShiftFlag)
static const char *const CVSBuildingBlocks_cc
void CVSBuildingBlocks(TextWriter &Out)
Fourier transform phase factor support.
multi1d< LatticeColorMatrix > U
static INTERNAL_PRECISION F