Commit 2d6f542f by Francois Gygi

Use vector swap in BasisMapping for single-node

parent e9d96319
......@@ -428,19 +428,22 @@ void BasisMapping::transpose_bwd(const complex<double> *zvec,
// segments of z-vectors are now in sbuf
// transpose
#if USE_MPI
int status = MPI_Alltoallv((double*)&sbuf[0],&scounts[0],&sdispl[0],
if ( nprocs_ == 1 )
{
assert(sbuf.size()==rbuf.size());
rbuf.swap(sbuf);
}
else
{
int status = MPI_Alltoallv((double*)&sbuf[0],&scounts[0],&sdispl[0],
MPI_DOUBLE,(double*)&rbuf[0],&rcounts[0],&rdispl[0],MPI_DOUBLE,
basis_.comm());
if ( status != 0 )
{
cout << " BasisMapping: status = " << status << endl;
MPI_Abort(basis_.comm(),2);
if ( status != 0 )
{
cout << " BasisMapping: status = " << status << endl;
MPI_Abort(basis_.comm(),2);
}
}
#else
assert(sbuf.size()==rbuf.size());
rbuf = sbuf;
#endif
// clear ct
memset((void*)ct,0,np012loc_*sizeof(complex<double>));
......@@ -505,15 +508,22 @@ void BasisMapping::transpose_fwd(const complex<double> *ct,
#endif
// transpose
#if USE_MPI
int status = MPI_Alltoallv((double*)&rbuf[0],&rcounts[0],&rdispl[0],
if ( nprocs_ == 1 )
{
assert(sbuf.size()==rbuf.size());
sbuf.swap(rbuf);
}
else
{
int status = MPI_Alltoallv((double*)&rbuf[0],&rcounts[0],&rdispl[0],
MPI_DOUBLE,(double*)&sbuf[0],&scounts[0],&sdispl[0],MPI_DOUBLE,
basis_.comm());
assert ( status == 0 );
#else
assert(sbuf.size()==rbuf.size());
sbuf = rbuf;
#endif
if ( status != 0 )
{
cout << " BasisMapping: status = " << status << endl;
MPI_Abort(basis_.comm(),2);
}
}
// segments of z-vectors are now in sbuf
// gather sbuf into zvec_
......
......@@ -38,7 +38,7 @@ class BasisMapping
std::vector<int> np2_first_; // np2_first_[iproc], iproc=0, nprocs_-1
std::vector<int> scounts, sdispl, rcounts, rdispl;
std::vector<std::complex<double> > sbuf, rbuf;
mutable std::vector<std::complex<double> > sbuf, rbuf;
std::vector<int> ip_, im_;
std::vector<int> ipack_, iunpack_;
......
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