From f02c7ea534d3a9140f0b1828e03cbfddeb1b12b7 Mon Sep 17 00:00:00 2001 From: Peter Boyle Date: Mon, 10 Sep 2018 11:26:20 +0100 Subject: [PATCH] Peer to peer on GPU's setup --- lib/communicator/SharedMemory.h | 3 + lib/communicator/SharedMemoryMPI.cc | 127 +++++++++++++++++++++------- 2 files changed, 101 insertions(+), 29 deletions(-) diff --git a/lib/communicator/SharedMemory.h b/lib/communicator/SharedMemory.h index 7ce14d9b..1c3953d0 100644 --- a/lib/communicator/SharedMemory.h +++ b/lib/communicator/SharedMemory.h @@ -96,6 +96,8 @@ public: /////////////////////////////////////////////////// static void SharedMemoryAllocate(uint64_t bytes, int flags); static void SharedMemoryFree(void); + static void SharedMemoryCopy(void *dest,const void *src,size_t bytes); + static void SharedMemoryZero(void *dest,size_t bytes); }; @@ -135,6 +137,7 @@ public: // Call on any instance /////////////////////////////////////////////////// void SharedMemoryTest(void); + void *ShmBufferSelf(void); void *ShmBuffer (int rank); void *ShmBufferTranslate(int rank,void * local_p); diff --git a/lib/communicator/SharedMemoryMPI.cc b/lib/communicator/SharedMemoryMPI.cc index dea913bc..3ef5f5c7 100644 --- a/lib/communicator/SharedMemoryMPI.cc +++ b/lib/communicator/SharedMemoryMPI.cc @@ -28,6 +28,10 @@ Author: Peter Boyle #include +#ifdef GRID_NVCC +#include +#endif + NAMESPACE_BEGIN(Grid); /*Construct from an MPI communicator*/ @@ -42,15 +46,12 @@ void GlobalSharedMemory::Init(Grid_MPI_Comm comm) ///////////////////////////////////////////////////////////////////// // Split into groups that can share memory ///////////////////////////////////////////////////////////////////// -#ifdef GRID_NVCC - MPI_Comm_split(comm, WorldRank , 0,&WorldShmComm); -#else MPI_Comm_split_type(comm, MPI_COMM_TYPE_SHARED, 0, MPI_INFO_NULL,&WorldShmComm); -#endif MPI_Comm_rank(WorldShmComm ,&WorldShmRank); MPI_Comm_size(WorldShmComm ,&WorldShmSize); - std::cout << " World communicator of size " < ranks(size); for(int r=0;r