1
0
mirror of https://github.com/paboyle/Grid.git synced 2024-11-15 10:15:36 +00:00

Merge branch 'develop' of https://github.com/paboyle/Grid into feature/Lanczos

This commit is contained in:
Chulwoo Jung 2017-10-30 15:49:17 -04:00
commit 5d44346be3
4 changed files with 40 additions and 16 deletions

View File

@ -274,12 +274,16 @@ class CartesianCommunicator {
// std::cerr << " AllToAll in.size() "<<in.size()<<std::endl; // std::cerr << " AllToAll in.size() "<<in.size()<<std::endl;
// std::cerr << " AllToAll out.size() "<<out.size()<<std::endl; // std::cerr << " AllToAll out.size() "<<out.size()<<std::endl;
assert(in.size()==out.size()); assert(in.size()==out.size());
size_t bytes=(in.size()*sizeof(T))/numnode; uint64_t bytes=sizeof(T);
assert((bytes*numnode) == in.size()*sizeof(T)); uint64_t words=in.size()/numnode;
AllToAll(dim,(void *)&in[0],(void *)&out[0],bytes);
assert(numnode * words == in.size());
assert(words < (1ULL<<32));
AllToAll(dim,(void *)&in[0],(void *)&out[0],words,bytes);
} }
void AllToAll(int dim ,void *in,void *out,int bytes); void AllToAll(int dim ,void *in,void *out,uint64_t words,uint64_t bytes);
void AllToAll(void *in,void *out,int bytes); void AllToAll(void *in,void *out,uint64_t words ,uint64_t bytes);
template<class obj> void Broadcast(int root,obj &data) template<class obj> void Broadcast(int root,obj &data)
{ {

View File

@ -55,7 +55,9 @@ void CartesianCommunicator::Init(int *argc, char ***argv) {
CartesianCommunicator::~CartesianCommunicator() CartesianCommunicator::~CartesianCommunicator()
{ {
if (communicator && !MPI::Is_finalized()) int MPI_is_finalised;
MPI_Finalized(&MPI_is_finalised);
if (communicator && MPI_is_finalised)
MPI_Comm_free(&communicator); MPI_Comm_free(&communicator);
} }
@ -195,7 +197,7 @@ void CartesianCommunicator::Broadcast(int root,void* data, int bytes)
communicator); communicator);
assert(ierr==0); assert(ierr==0);
} }
void CartesianCommunicator::AllToAll(int dim,void *in,void *out,int bytes) void CartesianCommunicator::AllToAll(int dim,void *in,void *out,uint64_t words,uint64_t bytes)
{ {
std::vector<int> row(_ndimension,1); std::vector<int> row(_ndimension,1);
assert(dim>=0 && dim<_ndimension); assert(dim>=0 && dim<_ndimension);
@ -204,11 +206,25 @@ void CartesianCommunicator::AllToAll(int dim,void *in,void *out,int bytes)
row[dim] = _processors[dim]; row[dim] = _processors[dim];
CartesianCommunicator Comm(row,*this); CartesianCommunicator Comm(row,*this);
Comm.AllToAll(in,out,bytes); Comm.AllToAll(in,out,words,bytes);
} }
void CartesianCommunicator::AllToAll(void *in,void *out,int bytes) void CartesianCommunicator::AllToAll(void *in,void *out,uint64_t words,uint64_t bytes)
{ {
MPI_Alltoall(in ,bytes,MPI_BYTE,out,bytes,MPI_BYTE,communicator); // MPI is a pain and uses "int" arguments
// 64*64*64*128*16 == 500Million elements of data.
// When 24*4 bytes multiples get 50x 10^9 >>> 2x10^9 Y2K bug.
// (Turns up on 32^3 x 64 Gparity too)
MPI_Datatype object;
int iwords;
int ibytes;
iwords = words;
ibytes = bytes;
assert(words == iwords); // safe to cast to int ?
assert(bytes == ibytes); // safe to cast to int ?
MPI_Type_contiguous(ibytes,MPI_BYTE,&object);
MPI_Type_commit(&object);
MPI_Alltoall(in,iwords,object,out,iwords,object,communicator);
MPI_Type_free(&object);
} }
/////////////////////////////////////////////////////// ///////////////////////////////////////////////////////
// Should only be used prior to Grid Init finished. // Should only be used prior to Grid Init finished.

View File

@ -100,9 +100,13 @@ void CartesianCommunicator::SendToRecvFromComplete(std::vector<CommsRequest_t> &
{ {
assert(0); assert(0);
} }
void CartesianCommunicator::AllToAll(int dim,void *in,void *out,int bytes) void CartesianCommunicator::AllToAll(int dim,void *in,void *out,uint64_t words,uint64_t bytes)
{ {
bcopy(in,out,bytes); bcopy(in,out,bytes*words);
}
void CartesianCommunicator::AllToAll(void *in,void *out,uint64_t words,uint64_t bytes)
{
bcopy(in,out,bytes*words);
} }
int CartesianCommunicator::RankWorld(void){return 0;} int CartesianCommunicator::RankWorld(void){return 0;}

View File

@ -790,8 +790,8 @@ void Grid_split(std::vector<Lattice<Vobj> > & full,Lattice<Vobj> & split)
ratio[d] = full_grid->_processors[d]/ split_grid->_processors[d]; ratio[d] = full_grid->_processors[d]/ split_grid->_processors[d];
} }
int lsites = full_grid->lSites(); uint64_t lsites = full_grid->lSites();
Integer sz = lsites * nvector; uint64_t sz = lsites * nvector;
std::vector<Sobj> tmpdata(sz); std::vector<Sobj> tmpdata(sz);
std::vector<Sobj> alldata(sz); std::vector<Sobj> alldata(sz);
std::vector<Sobj> scalardata(lsites); std::vector<Sobj> scalardata(lsites);
@ -908,8 +908,8 @@ void Grid_unsplit(std::vector<Lattice<Vobj> > & full,Lattice<Vobj> & split)
ratio[d] = full_grid->_processors[d]/ split_grid->_processors[d]; ratio[d] = full_grid->_processors[d]/ split_grid->_processors[d];
} }
int lsites = full_grid->lSites(); uint64_t lsites = full_grid->lSites();
Integer sz = lsites * nvector; uint64_t sz = lsites * nvector;
std::vector<Sobj> tmpdata(sz); std::vector<Sobj> tmpdata(sz);
std::vector<Sobj> alldata(sz); std::vector<Sobj> alldata(sz);
std::vector<Sobj> scalardata(lsites); std::vector<Sobj> scalardata(lsites);