Commit b536038a by Francois Gygi

Optimized Bisection::overlap.

Added timers to ExchangeOperator.C


git-svn-id: http://qboxcode.org/svn/qb/trunk@1644 cba15fb0-1239-40c8-b417-11db7ca47a34
parent d72fe507
......@@ -706,13 +706,13 @@ void Bisection::trim_amat(const vector<double>& occ)
}
////////////////////////////////////////////////////////////////////////////////
bool Bisection::overlap(int i, int j)
bool Bisection::overlap(int i, int j) const
{
return overlap(localization_,i,j);
}
////////////////////////////////////////////////////////////////////////////////
bool Bisection::overlap(vector<long int> loc_, int i, int j)
bool Bisection::overlap(const vector<long int>& loc_, int i, int j) const
{
// overlap: return true if the functions i and j overlap according
// to the localization vector loc_
......@@ -739,7 +739,7 @@ bool Bisection::overlap(vector<long int> loc_, int i, int j)
}
////////////////////////////////////////////////////////////////////////////////
double Bisection::pair_fraction(void)
double Bisection::pair_fraction(void) const
{
// pair_fraction: return fraction of pairs having non-zero overlap
int sum = 0;
......@@ -757,7 +757,7 @@ double Bisection::pair_fraction(void)
}
////////////////////////////////////////////////////////////////////////////////
double Bisection::size(int i)
double Bisection::size(int i) const
{
// size: return fraction of the domain on which state i is non-zero
long int loc = localization_[i];
......@@ -780,7 +780,7 @@ double Bisection::size(int i)
}
////////////////////////////////////////////////////////////////////////////////
double Bisection::total_size(void)
double Bisection::total_size(void) const
{
// total_size: return normalized sum of sizes
double sum = 0.0;
......
......@@ -79,13 +79,14 @@ class Bisection
int nmat(void) const { return nmat_; }
long int localization(int i) const { return localization_[i]; }
std::vector<long int> localization(void) const { return localization_; }
bool overlap(int i, int j);
bool overlap(std::vector<long int> loc, int i, int j);
const std::vector<long int>& localization(void) const
{ return localization_; }
bool overlap(int i, int j) const;
bool overlap(const std::vector<long int>& loc, int i, int j) const;
const DoubleMatrix& u(void) const { return *u_; }
double pair_fraction(void);
double size(int i);
double total_size(void);
double pair_fraction(void) const;
double size(int i) const;
double total_size(void) const;
~Bisection();
};
#endif
......@@ -998,18 +998,44 @@ double ExchangeOperator::compute_exchange_at_gamma_(const Wavefunction &wf,
cout << " override bisection tol value: tol = " << tol << endl;
assert(tol > 0.0);
}
#if TIMING
Timer tmbtransf;
tmbtransf.start();
#endif
bisection_[ispin]->compute_transform(*wfc_.sd(ispin,0),maxsweep,tol);
#if TIMING
tmbtransf.stop();
Timer tmbcomploc;
tmbcomploc.start();
#endif
bisection_[ispin]->compute_localization(s_.ctrl.btHF);
#if TIMING
tmbcomploc.stop();
#endif
// copy of localization vector from Bisection object
localization_ = bisection_[ispin]->localization();
#if TIMING
Timer tmbsize, tmbpair;
tmbsize.start();
#endif
if ( gcontext_.onpe0() )
{
cout << " ExchangeOperator: bisection size: ispin=" << ispin
<< ": " << bisection_[ispin]->total_size() << endl;
}
#if TIMING
tmbsize.stop();
tmbpair.start();
#endif
if ( gcontext_.onpe0() )
{
cout << " ExchangeOperator: pair fraction: ispin=" << ispin
<< ": " << bisection_[ispin]->pair_fraction() << endl;
}
#if TIMING
tmbpair.stop();
#endif
// copy the orthogonal transformation u to uc_[ispin]
*uc_[ispin] = bisection_[ispin]->u();
......@@ -1023,6 +1049,10 @@ double ExchangeOperator::compute_exchange_at_gamma_(const Wavefunction &wf,
// compute the degree of the vertices of the exchange graph
// using the localization vector
#if TIMING
Timer tmb_ov;
tmb_ov.start();
#endif
vector<int> degree(nst);
for ( int i = 0; i < nst; i++ )
{
......@@ -1034,6 +1064,15 @@ double ExchangeOperator::compute_exchange_at_gamma_(const Wavefunction &wf,
}
degree[i] = count;
}
#if TIMING
tmb_ov.stop();
if ( gcontext_.onpe0() )
{
cout << setprecision(3);
cout << " ExchangeOperator: bisection overlap time: "
<< tmb_ov.real() << " s" << endl;
}
#endif
// permutation index
vector<int> index(nst);
......@@ -1190,8 +1229,27 @@ double ExchangeOperator::compute_exchange_at_gamma_(const Wavefunction &wf,
}
#endif
#if TIMING
Timer tmblapiv;
tmblapiv.start();
#endif
// apply the permutation to the columns of uc
uc_[ispin]->lapiv('B','C',&locpivot[0]);
#if TIMING
tmblapiv.stop();
if ( gcontext_.onpe0() )
{
cout << setprecision(3);
cout << " ExchangeOperator: bisection size time: "
<< tmbsize.real() << " s" << endl;
cout << setprecision(3);
cout << " ExchangeOperator: bisection pair time: "
<< tmbpair.real() << " s" << endl;
cout << setprecision(3);
cout << " ExchangeOperator: bisection lapiv time: "
<< tmblapiv.real() << " s" << endl;
}
#endif
#if DEBUG
// recompute the degree of the vertices of the exchange graph
......@@ -1244,11 +1302,29 @@ double ExchangeOperator::compute_exchange_at_gamma_(const Wavefunction &wf,
cout << " ExchangeOperator: bisection distribution disabled" << endl;
} // if distribute
#if TIMING
Timer tmbfwd;
tmbfwd.start();
#endif
bisection_[ispin]->forward(*uc_[ispin], *wfc_.sd(ispin,0));
#if TIMING
tmbfwd.stop();
#endif
tmb.stop();
if ( gcontext_.onpe0() )
{
#if TIMING
cout << setprecision(3);
cout << " ExchangeOperator: bisection compute transform time: "
<< tmbtransf.real() << " s" << endl;
cout << setprecision(3);
cout << " ExchangeOperator: bisection compute localization time: "
<< tmbcomploc.real() << " s" << endl;
cout << setprecision(3);
cout << " ExchangeOperator: bisection forward time: "
<< tmbfwd.real() << " s" << endl;
#endif
cout << setprecision(3);
cout << " ExchangeOperator: bisection time: "
<< tmb.real() << " s" << endl;
......@@ -2206,13 +2282,15 @@ double ExchangeOperator::compute_exchange_at_gamma_(const Wavefunction &wf,
tm.stop();
#ifdef DEBUG
if ( gcontext_.onpe0() )
{
cout << setprecision(10);
cout << " total exchange = " << extot << " (a.u.)\n";
cout << setprecision(3);
cout << " total exchange computation time: " << tm.real()
<< " s" << endl;
}
#ifdef DEBUG
if ( gcontext_.onpe0() )
{
if ( compute_stress )
{
cout << " exchange stress (a.u.) " << endl;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment