From cbe7bf661f929506c8462f95adc3153f99f5f1dc Mon Sep 17 00:00:00 2001 From: David Ozog Date: Wed, 5 Jun 2024 15:44:47 -0400 Subject: [PATCH] shared: enable MMAP shmem_ptr and fix bounds check --- src/shmem_remote_pointer.h | 2 ++ src/transport_mmap.h | 14 +++++++------- src/transport_xpmem.h | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/shmem_remote_pointer.h b/src/shmem_remote_pointer.h index 9ca618316..e9cacb694 100644 --- a/src/shmem_remote_pointer.h +++ b/src/shmem_remote_pointer.h @@ -34,6 +34,8 @@ shmem_internal_ptr(const void *target, int pe) if (-1 != (node_rank = shmem_internal_get_shr_rank(pe))) { #if USE_XPMEM return shmem_transport_xpmem_ptr(target, pe, node_rank); +#elif USE_MMAP + return shmem_transport_mmap_ptr(target, pe, node_rank); #else return NULL; #endif diff --git a/src/transport_mmap.h b/src/transport_mmap.h index e09a7e51c..cf4b9c373 100644 --- a/src/transport_mmap.h +++ b/src/transport_mmap.h @@ -29,29 +29,29 @@ struct shmem_transport_mmap_peer_info_t { extern struct shmem_transport_mmap_peer_info_t *shmem_transport_mmap_peers; #ifdef ENABLE_ERROR_CHECKING -#define MMAP_GET_REMOTE_ACCESS(target, rank, ptr) \ +#define MMAP_GET_REMOTE_ACCESS(target, rank, ptr) \ do { \ if (((void*) target > shmem_internal_data_base) && \ ((char*) target < (char*) shmem_internal_data_base + shmem_internal_data_length)) { \ ptr = (char*) target - (char*) shmem_internal_data_base + \ - (char*) shmem_transport_mmap_peers[rank].data_ptr; \ - } else if (((void*) target > shmem_internal_heap_base) && \ + (char*) shmem_transport_mmap_peers[rank].data_ptr; \ + } else if (((void*) target >= shmem_internal_heap_base) && \ ((char*) target < (char*) shmem_internal_heap_base + shmem_internal_heap_length)) { \ ptr = (char*) target - (char*) shmem_internal_heap_base + \ - (char*) shmem_transport_mmap_peers[rank].heap_ptr; \ + (char*) shmem_transport_mmap_peers[rank].heap_ptr; \ } else { \ ptr = NULL; \ } \ } while (0) #else -#define MMAP_GET_REMOTE_ACCESS(target, rank, ptr) \ +#define MMAP_GET_REMOTE_ACCESS(target, rank, ptr) \ do { \ if ((void*) target < shmem_internal_heap_base) { \ ptr = (char*) target - (char*) shmem_internal_data_base + \ - (char*) shmem_transport_mmap_peers[rank].data_ptr; \ + (char*) shmem_transport_mmap_peers[rank].data_ptr; \ } else { \ ptr = (char*) target - (char*) shmem_internal_heap_base + \ - (char*) shmem_transport_mmap_peers[rank].heap_ptr; \ + (char*) shmem_transport_mmap_peers[rank].heap_ptr; \ } \ } while (0) #endif diff --git a/src/transport_xpmem.h b/src/transport_xpmem.h index ba795d2f6..8d9fbe8a8 100644 --- a/src/transport_xpmem.h +++ b/src/transport_xpmem.h @@ -38,7 +38,7 @@ extern struct shmem_transport_xpmem_peer_info_t *shmem_transport_xpmem_peers; ((char*) target < (char*) shmem_internal_data_base + shmem_internal_data_length)) { \ ptr = (char*) target - (char*) shmem_internal_data_base + \ (char*) shmem_transport_xpmem_peers[rank].data_ptr; \ - } else if (((void*) target > shmem_internal_heap_base) && \ + } else if (((void*) target >= shmem_internal_heap_base) && \ ((char*) target < (char*) shmem_internal_heap_base + shmem_internal_heap_length)) { \ ptr = (char*) target - (char*) shmem_internal_heap_base + \ (char*) shmem_transport_xpmem_peers[rank].heap_ptr; \