diff --git a/Grid/communicator/SharedMemory.cc b/Grid/communicator/SharedMemory.cc index ec42dd87..7f2bd324 100644 --- a/Grid/communicator/SharedMemory.cc +++ b/Grid/communicator/SharedMemory.cc @@ -40,6 +40,7 @@ int GlobalSharedMemory::_ShmAlloc; uint64_t GlobalSharedMemory::_ShmAllocBytes; std::vector GlobalSharedMemory::WorldShmCommBufs; +void * GlobalSharedMemory::HostCommBuf; Grid_MPI_Comm GlobalSharedMemory::WorldShmComm; int GlobalSharedMemory::WorldShmRank; @@ -66,6 +67,26 @@ void GlobalSharedMemory::SharedMemoryFree(void) ///////////////////////////////// // Alloc, free shmem region ///////////////////////////////// +#ifndef ACCELERATOR_AWARE_MPI +void *SharedMemory::HostBufferMalloc(size_t bytes){ + void *ptr = (void *)host_heap_top; + host_heap_top += bytes; + host_heap_bytes+= bytes; + if (host_heap_bytes >= host_heap_size) { + std::cout<< " HostBufferMalloc exceeded heap size -- try increasing with --shm flag" < WorldShmCommBufs; - +#ifndef ACCELERATOR_AWARE_MPI + static void *HostCommBuf; +#endif static Grid_MPI_Comm WorldComm; static int WorldRank; static int WorldSize; @@ -120,6 +122,13 @@ private: size_t heap_bytes; size_t heap_size; +#ifndef ACCELERATOR_AWARE_MPI + size_t host_heap_top; // set in free all + size_t host_heap_bytes;// set in free all + void *HostCommBuf; // set in SetCommunicator + size_t host_heap_size; // set in SetCommunicator +#endif + protected: Grid_MPI_Comm ShmComm; // for barriers @@ -151,7 +160,10 @@ public: void *ShmBufferTranslate(int rank,void * local_p); void *ShmBufferMalloc(size_t bytes); void ShmBufferFreeAll(void) ; - +#ifndef ACCELERATOR_AWARE_MPI + void *HostBufferMalloc(size_t bytes); + void HostBufferFreeAll(void); +#endif ////////////////////////////////////////////////////////////////////////// // Make info on Nodes & ranks and Shared memory available ////////////////////////////////////////////////////////////////////////// diff --git a/Grid/communicator/SharedMemoryMPI.cc b/Grid/communicator/SharedMemoryMPI.cc index 64a86c4b..01921f94 100644 --- a/Grid/communicator/SharedMemoryMPI.cc +++ b/Grid/communicator/SharedMemoryMPI.cc @@ -512,46 +512,6 @@ void GlobalSharedMemory::SharedMemoryAllocate(uint64_t bytes, int flags) // Hugetlbfs mapping intended //////////////////////////////////////////////////////////////////////////////////////////// #if defined(GRID_CUDA) ||defined(GRID_HIP) || defined(GRID_SYCL) - -//if defined(GRID_SYCL) -#if 0 -void GlobalSharedMemory::SharedMemoryAllocate(uint64_t bytes, int flags) -{ - void * ShmCommBuf ; - assert(_ShmSetup==1); - assert(_ShmAlloc==0); - - ////////////////////////////////////////////////////////////////////////////////////////////////////////// - // allocate the pointer array for shared windows for our group - ////////////////////////////////////////////////////////////////////////////////////////////////////////// - MPI_Barrier(WorldShmComm); - WorldShmCommBufs.resize(WorldShmSize); - - /////////////////////////////////////////////////////////////////////////////////////////////////////////// - // Each MPI rank should allocate our own buffer - /////////////////////////////////////////////////////////////////////////////////////////////////////////// - ShmCommBuf = acceleratorAllocDevice(bytes); - - if (ShmCommBuf == (void *)NULL ) { - std::cerr << " SharedMemoryMPI.cc acceleratorAllocDevice failed NULL pointer for " << bytes<<" bytes " << std::endl; - exit(EXIT_FAILURE); - } - - std::cout << WorldRank << Mheader " SharedMemoryMPI.cc acceleratorAllocDevice "<< bytes - << "bytes at "<< std::hex<< ShmCommBuf <