Skip to content

Commit

Permalink
shared: enable MMAP shmem_ptr and fix bounds check
Browse files Browse the repository at this point in the history
  • Loading branch information
davidozog committed Oct 9, 2024
1 parent 79c656a commit 861384a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 2 additions & 0 deletions src/shmem_remote_pointer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions src/transport_mmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/transport_xpmem.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; \
Expand Down

0 comments on commit 861384a

Please sign in to comment.