From b49bec0cec4a876462fa1f042556d595f3d88416 Mon Sep 17 00:00:00 2001 From: paboyle Date: Sun, 20 Aug 2017 03:08:54 +0100 Subject: [PATCH] MAP_HUGETLB portability fix --- lib/communicator/Communicator_base.cc | 2 ++ lib/communicator/Communicator_mpi3.cc | 15 +++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/communicator/Communicator_base.cc b/lib/communicator/Communicator_base.cc index 2e6626be..3378c56a 100644 --- a/lib/communicator/Communicator_base.cc +++ b/lib/communicator/Communicator_base.cc @@ -149,7 +149,9 @@ void CartesianCommunicator::ShmInitGeneric(void){ #if 1 int mmap_flag = MAP_SHARED | MAP_ANONYMOUS; +#ifdef MAP_HUGETLB if ( Hugepages ) mmap_flag |= MAP_HUGETLB; +#endif ShmCommBuf =(void *) mmap(NULL, MAX_MPI_SHM_BYTES, PROT_READ | PROT_WRITE, mmap_flag, -1, 0); if (ShmCommBuf == (void *)MAP_FAILED) exit(EXIT_FAILURE); std::cout << "ShmCommBuf "< #include #endif -// Make up for linex deficiencies -#ifndef SHM_HUGETLB -#define SHM_HUGETLB 0x0 -#endif -#ifndef MAP_HUGETLB -#define MAP_HUGETLB 0x0 -#endif namespace Grid { @@ -220,7 +213,9 @@ void CartesianCommunicator::Init(int *argc, char ***argv) { ftruncate(fd, size); int mmap_flag = MAP_SHARED; +#ifdef MAP_HUGETLB if (Hugepages) mmap_flag |= MAP_HUGETLB; +#endif void * ptr = mmap(NULL,size, PROT_READ | PROT_WRITE, mmap_flag, fd, 0); if ( ptr == MAP_FAILED ) { perror("failed mmap"); assert(0); } @@ -274,7 +269,11 @@ void CartesianCommunicator::Init(int *argc, char ***argv) { for(int r=0;r