mirror of
https://github.com/paboyle/Grid.git
synced 2026-08-19 08:59:36 +01:00
FFT offload to GPU and MUCH faster comms.
40x speed up on Frontier
This commit is contained in:
@@ -49,6 +49,20 @@ template<class vobj> Lattice<vobj> Cshift(const Lattice<vobj> &rhs,int dimension
|
||||
// Map to always positive shift modulo global full dimension.
|
||||
shift = (shift+fd)%fd;
|
||||
|
||||
if( shift ==0 ) {
|
||||
ret = rhs;
|
||||
return ret;
|
||||
}
|
||||
//
|
||||
// Potential easy fast cases:
|
||||
// Shift is a multiple of the local lattice extent.
|
||||
// Then need only to shift whole subvolumes
|
||||
int L = rhs.Grid()->_ldimensions[dimension];
|
||||
if ( (shift%L )==0 && !rhs.Grid()->CheckerBoarded(dimension) ) {
|
||||
Cshift_simple(ret,rhs,dimension,shift);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret.Checkerboard() = rhs.Grid()->CheckerBoardDestination(rhs.Checkerboard(),shift,dimension);
|
||||
|
||||
// the permute type
|
||||
@@ -73,6 +87,55 @@ template<class vobj> Lattice<vobj> Cshift(const Lattice<vobj> &rhs,int dimension
|
||||
return ret;
|
||||
}
|
||||
|
||||
template<class vobj> void Cshift_simple(Lattice<vobj>& ret,const Lattice<vobj> &rhs,int dimension,int shift)
|
||||
{
|
||||
GridBase *grid=rhs.Grid();
|
||||
int comm_proc, xmit_to_rank, recv_from_rank;
|
||||
|
||||
int fd = rhs.Grid()->_fdimensions[dimension];
|
||||
int rd = rhs.Grid()->_rdimensions[dimension];
|
||||
int ld = rhs.Grid()->_ldimensions[dimension];
|
||||
int pd = rhs.Grid()->_processors[dimension];
|
||||
int simd_layout = rhs.Grid()->_simd_layout[dimension];
|
||||
int comm_dim = rhs.Grid()->_processors[dimension] >1 ;
|
||||
|
||||
comm_proc = ((shift)/ld)%pd;
|
||||
|
||||
grid->ShiftedRanks(dimension,comm_proc,xmit_to_rank,recv_from_rank);
|
||||
if(comm_dim) {
|
||||
|
||||
int64_t bytes = sizeof(vobj) * grid->oSites();
|
||||
|
||||
autoView(rhs_v , rhs, AcceleratorRead);
|
||||
autoView(ret_v , ret, AcceleratorWrite);
|
||||
void *send_buf = (void *)&rhs_v[0];
|
||||
void *recv_buf = (void *)&ret_v[0];
|
||||
|
||||
#ifdef ACCELERATOR_AWARE_MPI
|
||||
grid->SendToRecvFrom(send_buf,
|
||||
xmit_to_rank,
|
||||
recv_buf,
|
||||
recv_from_rank,
|
||||
bytes);
|
||||
#else
|
||||
static hostVector<vobj> hrhs; hrhs.resize(grid->oSites());
|
||||
static hostVector<vobj> hret; hret.resize(grid->oSites());
|
||||
|
||||
void *hsend_buf = (void *)&hrhs[0];
|
||||
void *hrecv_buf = (void *)&hret[0];
|
||||
|
||||
acceleratorCopyFromDevice(&send_buf[0],&hsend_buf[0],bytes);
|
||||
|
||||
grid->SendToRecvFrom(hsend_buf,
|
||||
xmit_to_rank,
|
||||
hrecv_buf,
|
||||
recv_from_rank,
|
||||
bytes);
|
||||
|
||||
acceleratorCopyToDevice(&hrecv_buf[0],&recv_buf[0],bytes);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
template<class vobj> void Cshift_comms(Lattice<vobj>& ret,const Lattice<vobj> &rhs,int dimension,int shift)
|
||||
{
|
||||
int sshift[2];
|
||||
|
||||
Reference in New Issue
Block a user