mirror of
https://github.com/paboyle/Grid.git
synced 2026-09-03 08:19:36 +01:00
Merge with Christoph GPT checksum debug
This commit is contained in:
@@ -202,7 +202,7 @@ template<class vobj> void Scatter_plane_simple (Lattice<vobj> &rhs,deviceVector<
|
||||
{
|
||||
auto buffer_p = & buffer[0];
|
||||
auto table = MapCshiftTable();
|
||||
autoView( rhs_v, rhs, AcceleratorWrite);
|
||||
autoView( rhs_v, rhs, AcceleratorWriteDiscard);
|
||||
accelerator_for(i,ent,vobj::Nsimd(),{
|
||||
coalescedWrite(rhs_v[table[i].first],coalescedRead(buffer_p[table[i].second]));
|
||||
});
|
||||
@@ -228,7 +228,7 @@ template<class vobj> void Scatter_plane_merge(Lattice<vobj> &rhs,ExtractPointerA
|
||||
if(cbmask ==0x3 ) {
|
||||
int _slice_stride = rhs.Grid()->_slice_stride[dimension];
|
||||
int _slice_block = rhs.Grid()->_slice_block[dimension];
|
||||
autoView( rhs_v , rhs, AcceleratorWrite);
|
||||
autoView( rhs_v , rhs, AcceleratorWriteDiscard);
|
||||
accelerator_for(nn,e1*e2,1,{
|
||||
int n = nn%e1;
|
||||
int b = nn/e1;
|
||||
@@ -302,7 +302,7 @@ template<class vobj> void Copy_plane(Lattice<vobj>& lhs,const Lattice<vobj> &rhs
|
||||
{
|
||||
auto table = MapCshiftTable();
|
||||
autoView(rhs_v , rhs, AcceleratorRead);
|
||||
autoView(lhs_v , lhs, AcceleratorWrite);
|
||||
autoView(lhs_v , lhs, AcceleratorWriteDiscard);
|
||||
accelerator_for(i,ent,vobj::Nsimd(),{
|
||||
coalescedWrite(lhs_v[table[i].first],coalescedRead(rhs_v[table[i].second]));
|
||||
});
|
||||
|
||||
@@ -29,8 +29,12 @@ Author: paboyle <paboyle@ph.ed.ac.uk>
|
||||
#ifndef _GRID_CSHIFT_MPI_H_
|
||||
#define _GRID_CSHIFT_MPI_H_
|
||||
|
||||
|
||||
NAMESPACE_BEGIN(Grid);
|
||||
|
||||
#ifdef GRID_CHECKSUM_COMMS
|
||||
extern uint64_t checksum_index;
|
||||
#endif
|
||||
|
||||
const int Cshift_verbose=0;
|
||||
template<class vobj> Lattice<vobj> Cshift(const Lattice<vobj> &rhs,int dimension,int shift)
|
||||
{
|
||||
@@ -126,8 +130,9 @@ template<class vobj> void Cshift_comms(Lattice<vobj> &ret,const Lattice<vobj> &r
|
||||
static deviceVector<vobj> send_buf; send_buf.resize(buffer_size);
|
||||
static deviceVector<vobj> recv_buf; recv_buf.resize(buffer_size);
|
||||
#ifndef ACCELERATOR_AWARE_MPI
|
||||
static hostVector<vobj> hsend_buf; hsend_buf.resize(buffer_size);
|
||||
static hostVector<vobj> hrecv_buf; hrecv_buf.resize(buffer_size);
|
||||
int pad = (8 + sizeof(vobj) - 1) / sizeof(vobj);
|
||||
static hostVector<vobj> hsend_buf; hsend_buf.resize(buffer_size+pad);
|
||||
static hostVector<vobj> hrecv_buf; hrecv_buf.resize(buffer_size+pad);
|
||||
#endif
|
||||
|
||||
int cb= (cbmask==0x2)? Odd : Even;
|
||||
@@ -180,20 +185,39 @@ template<class vobj> void Cshift_comms(Lattice<vobj> &ret,const Lattice<vobj> &r
|
||||
#else
|
||||
// bouncy bouncy
|
||||
acceleratorCopyFromDevice(&send_buf[0],&hsend_buf[0],bytes);
|
||||
|
||||
#ifdef GRID_CHECKSUM_COMMS
|
||||
assert(bytes % 8 == 0);
|
||||
checksum_index++;
|
||||
uint64_t xsum = checksum_gpu((uint64_t*)&send_buf[0], bytes / 8) ^ (1 + checksum_index);
|
||||
*(uint64_t*)(((char*)&hsend_buf[0]) + bytes) = xsum;
|
||||
bytes += 8;
|
||||
#endif
|
||||
|
||||
grid->SendToRecvFrom((void *)&hsend_buf[0],
|
||||
xmit_to_rank,
|
||||
(void *)&hrecv_buf[0],
|
||||
recv_from_rank,
|
||||
bytes);
|
||||
|
||||
#ifdef GRID_CHECKSUM_COMMS
|
||||
bytes -= 8;
|
||||
acceleratorCopyToDevice(&hrecv_buf[0],&recv_buf[0],bytes);
|
||||
uint64_t expected_cs = *(uint64_t*)(((char*)&hrecv_buf[0]) + bytes);
|
||||
uint64_t computed_cs = checksum_gpu((uint64_t*)&recv_buf[0], bytes / 8) ^ (1 + checksum_index);
|
||||
std::cout << GridLogComms<< " Cshift: "
|
||||
<<" dim"<<dimension
|
||||
<<" shift "<<shift
|
||||
<< " rank "<< grid->ThisRank()
|
||||
<<" Coor "<<grid->ThisProcessorCoor()
|
||||
<<" send "<<hsend_buf[0]<<" to "<<xmit_to_rank
|
||||
<<" recv "<<hrecv_buf[0]<<" from "<<recv_from_rank
|
||||
<<" send "<<xsum<<" to "<<xmit_to_rank
|
||||
<<" recv "<<computed_cs<<" from "<<recv_from_rank
|
||||
<<std::endl;
|
||||
assert(expected_cs == computed_cs);
|
||||
#else
|
||||
acceleratorCopyToDevice(&hrecv_buf[0],&recv_buf[0],bytes);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
FlightRecorder::StepLog("Cshift_SendRecv_complete");
|
||||
|
||||
@@ -264,8 +288,16 @@ template<class vobj> void Cshift_comms_simd(Lattice<vobj> &ret,const Lattice<vo
|
||||
recv_buf_extract[s].resize(buffer_size);
|
||||
}
|
||||
#ifndef ACCELERATOR_AWARE_MPI
|
||||
hostVector<scalar_object> hsend_buf; hsend_buf.resize(buffer_size);
|
||||
hostVector<scalar_object> hrecv_buf; hrecv_buf.resize(buffer_size);
|
||||
#ifdef GRID_CHECKSUM_COMMS
|
||||
buffer_size += (8 + sizeof(vobj) - 1) / sizeof(vobj);
|
||||
#endif
|
||||
|
||||
static hostVector<vobj> hsend_buf; hsend_buf.resize(buffer_size);
|
||||
static hostVector<vobj> hrecv_buf; hrecv_buf.resize(buffer_size);
|
||||
|
||||
#ifdef GRID_CHECKSUM_COMMS
|
||||
buffer_size -= (8 + sizeof(vobj) - 1) / sizeof(vobj);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
int bytes = buffer_size*sizeof(scalar_object);
|
||||
@@ -328,21 +360,37 @@ template<class vobj> void Cshift_comms_simd(Lattice<vobj> &ret,const Lattice<vo
|
||||
#else
|
||||
// bouncy bouncy
|
||||
acceleratorCopyFromDevice((void *)send_buf_extract_mpi,(void *)&hsend_buf[0],bytes);
|
||||
#ifdef GRID_CHECKSUM_COMMS
|
||||
assert(bytes % 8 == 0);
|
||||
checksum_index++;
|
||||
uint64_t xsum = checksum_gpu((uint64_t*)send_buf_extract_mpi, bytes / 8) ^ (1 + checksum_index);
|
||||
*(uint64_t*)(((char*)&hsend_buf[0]) + bytes) = xsum;
|
||||
bytes += 8;
|
||||
#endif
|
||||
grid->SendToRecvFrom((void *)&hsend_buf[0],
|
||||
xmit_to_rank,
|
||||
(void *)&hrecv_buf[0],
|
||||
recv_from_rank,
|
||||
bytes);
|
||||
#ifdef GRID_CHECKSUM_COMMS
|
||||
bytes -= 8;
|
||||
acceleratorCopyToDevice((void *)&hrecv_buf[0],(void *)recv_buf_extract_mpi,bytes);
|
||||
uint64_t expected_cs = *(uint64_t*)(((char*)&hrecv_buf[0]) + bytes);
|
||||
uint64_t computed_cs = checksum_gpu((uint64_t*)recv_buf_extract_mpi, bytes / 8) ^ (1 + checksum_index);
|
||||
|
||||
std::cout << GridLogComms<< " Cshift_comms_simd: "
|
||||
<<" dim"<<dimension
|
||||
<<" shift "<<shift
|
||||
<< " rank "<< grid->ThisRank()
|
||||
<<" Coor "<<grid->ThisProcessorCoor()
|
||||
<<" send "<<hsend_buf[0]<<" to "<<xmit_to_rank
|
||||
<<" recv "<<hrecv_buf[0]<<" from "<<recv_from_rank
|
||||
<<" send "<<xsum<<" to "<<xmit_to_rank
|
||||
<<" recv "<<computed_cs<<" from "<<recv_from_rank
|
||||
<<std::endl;
|
||||
assert(expected_cs == computed_cs);
|
||||
#else
|
||||
acceleratorCopyToDevice((void *)&hrecv_buf[0],(void *)recv_buf_extract_mpi,bytes);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
xbytes+=bytes;
|
||||
|
||||
Reference in New Issue
Block a user