Commit 03d4c77b authored by Xin Zhao's avatar Xin Zhao
Browse files

Add CH3 APIs and macros to allow channel to implement Alloc_mem/Free_mem.

Originally MPIDI_Alloc_mem(size, info) and MPIDI_Free_mem(base_ptr)
in CH3 layer are implemented by calling MPIU_Malloc(size) and
MPIU_Free(base_ptr) internally. This makes the underlying hardware
be unable to develop a specific implementation of Alloc_mem and Free_mem,
which is necessary when registering memory for RDMA operations.

This patch defines new APIs, MPIDI_CH3I_Alloc_mem(size, info)
and MPIDI_CH3I_Free_mem(base_ptr), to allow channels to implement
their own memory allocators. If the channel does not have its own
implementation, MPICH will fallback to the default implementation
in CH3 layer which uses MPIU_Malloc and MPIU_Free.

Thanks to Steffen Christgau <> for
this contribution.
Signed-off-by: Pavan Balaji's avatarPavan Balaji <>
parent ee446c5c
......@@ -1226,6 +1226,19 @@ int MPIDI_Win_sync(MPID_Win *win);
void *MPIDI_Alloc_mem(size_t size, MPID_Info *info_ptr);
int MPIDI_Free_mem(void *ptr);
void* MPIDI_CH3I_Alloc_mem(size_t size, MPID_Info *info_ptr);
/* fallback to MPIU_Malloc if channel does not have its own RMA memory allocator */
#define MPIDI_CH3I_Alloc_mem(size, info_ptr) MPIU_Malloc(size)
int MPIDI_CH3I_Free_mem(void *ptr);
#define MPIDI_CH3I_Free_mem(ptr) MPIU_Free(ptr);
/* Pvars */
void MPIDI_CH3_RMA_Init_sync_pvars(void);
void MPIDI_CH3_RMA_Init_pkthandler_pvars(void);
......@@ -304,7 +304,7 @@ void *MPIDI_Alloc_mem(size_t size, MPID_Info * info_ptr)
ap = MPIU_Malloc(size);
ap = MPIDI_CH3I_Alloc_mem(size, info_ptr);
return ap;
......@@ -322,7 +322,7 @@ int MPIDI_Free_mem(void *ptr)
return mpi_errno;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment