mirror of
https://github.com/paboyle/Grid.git
synced 2025-06-12 20:27:06 +01:00
Optional host buffer bounce for no CUDA aware MPI
This commit is contained in:
@ -42,6 +42,11 @@ Author: Christoph Lehner <christoph@lhnr.de>
|
||||
#ifdef ACCELERATOR_AWARE_MPI
|
||||
#define GRID_SYCL_LEVEL_ZERO_IPC
|
||||
#define SHM_SOCKETS
|
||||
#else
|
||||
#undef NUMA_PLACE_HOSTBUF
|
||||
#ifdef NUMA_PLACE_HOSTBUF
|
||||
#include <numaif.h>
|
||||
#endif
|
||||
#endif
|
||||
#include <syscall.h>
|
||||
#endif
|
||||
@ -537,7 +542,30 @@ void GlobalSharedMemory::SharedMemoryAllocate(uint64_t bytes, int flags)
|
||||
// Each MPI rank should allocate our own buffer
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef ACCELERATOR_AWARE_MPI
|
||||
printf("Host buffer allocate for GPU non-aware MPI\n");
|
||||
HostCommBuf= malloc(bytes);
|
||||
#ifdef NUMA_PLACE_HOSTBUF
|
||||
int numa;
|
||||
char *numa_name=(char *)getenv("MPI_BUF_NUMA");
|
||||
if(numa_name) {
|
||||
page_size = sysconf(_SC_PAGESIZE);
|
||||
numa = atoi(numa_name);
|
||||
unsigned long page_count = bytes/page_size;
|
||||
std::vector<void *> pages(pcount);
|
||||
std::vector<int> nodes(pcount,numa);
|
||||
std::vector<int> status(pcount,-1);
|
||||
for(unsigned long p=0;p<page_count;p++){
|
||||
pages[p] = HostCommBuf + p*page_size;
|
||||
}
|
||||
int ret = move_pages(0,
|
||||
page_count,
|
||||
&pages[0],
|
||||
&nodes[0],
|
||||
&status[0],
|
||||
MPOL_MF_MOVE);
|
||||
printf("Host buffer move to numa domain %d : move_pages returned %d\n",numa,ret);
|
||||
if (ret) perror(" move_pages failed for reason:");
|
||||
#endif
|
||||
#endif
|
||||
ShmCommBuf = acceleratorAllocDevice(bytes);
|
||||
if (ShmCommBuf == (void *)NULL ) {
|
||||
|
@ -368,6 +368,7 @@ public:
|
||||
// accelerator_barrier(); // All kernels should ALREADY be complete
|
||||
// _grid->StencilBarrier(); // Everyone is here, so noone running slow and still using receive buffer
|
||||
// But the HaloGather had a barrier too.
|
||||
#ifdef ACCELERATOR_AWARE_MPI
|
||||
for(int i=0;i<Packets.size();i++){
|
||||
_grid->StencilSendToRecvFromBegin(MpiReqs,
|
||||
Packets[i].send_buf,
|
||||
@ -376,6 +377,23 @@ public:
|
||||
Packets[i].from_rank,Packets[i].do_recv,
|
||||
Packets[i].xbytes,Packets[i].rbytes,i);
|
||||
}
|
||||
#else
|
||||
#warning "Using COPY VIA HOST BUFFERS IN STENCIL"
|
||||
for(int i=0;i<Packets.size();i++){
|
||||
// Introduce a host buffer with a cheap slab allocator and zero cost wipe all
|
||||
Packets[i].host_send_buf = _grid->HostBufferMalloc(Packets[i].xbytes);
|
||||
Packets[i].host_recv_buf = _grid->HostBufferMalloc(Packets[i].rbytes);
|
||||
if ( Packets[i].do_send ) {
|
||||
acceleratorCopyFromDevice(Packets[i].send_buf, Packets[i].host_send_buf,Packets[i].xbytes);
|
||||
}
|
||||
_grid->StencilSendToRecvFromBegin(MpiReqs,
|
||||
Packets[i].host_send_buf,
|
||||
Packets[i].to_rank,Packets[i].do_send,
|
||||
Packets[i].host_recv_buf,
|
||||
Packets[i].from_rank,Packets[i].do_recv,
|
||||
Packets[i].xbytes,Packets[i].rbytes,i);
|
||||
}
|
||||
#endif
|
||||
// Get comms started then run checksums
|
||||
// Having this PRIOR to the dslash seems to make Sunspot work... (!)
|
||||
for(int i=0;i<Packets.size();i++){
|
||||
@ -393,8 +411,16 @@ public:
|
||||
else DslashLogFull();
|
||||
// acceleratorCopySynchronise();// is in the StencilSendToRecvFromComplete
|
||||
// accelerator_barrier();
|
||||
#ifndef ACCELERATOR_AWARE_MPI
|
||||
#warning "Using COPY VIA HOST BUFFERS IN STENCIL"
|
||||
for(int i=0;i<Packets.size();i++){
|
||||
if ( Packets[i].do_recv ) {
|
||||
acceleratorCopyToDevice(Packets[i].host_recv_buf, Packets[i].recv_buf,Packets[i].rbytes);
|
||||
}
|
||||
}
|
||||
_grid->HostBufferFreeAll();
|
||||
#endif // run any checksums
|
||||
_grid->StencilBarrier();
|
||||
// run any checksums
|
||||
for(int i=0;i<Packets.size();i++){
|
||||
if ( Packets[i].do_recv )
|
||||
FlightRecorder::recvLog(Packets[i].recv_buf,Packets[i].rbytes,Packets[i].from_rank);
|
||||
|
Reference in New Issue
Block a user