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 <christgau@cs.uni-potsdam.de> for
this contribution.
Signed-off-by: Pavan Balaji's avatarPavan Balaji <balaji@anl.gov>
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);
#ifdef MPIDI_CH3I_HAS_ALLOC_MEM
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 */
#else
#define MPIDI_CH3I_Alloc_mem(size, info_ptr) MPIU_Malloc(size)
#endif
#ifdef MPIDI_CH3I_HAS_FREE_MEM
int MPIDI_CH3I_Free_mem(void *ptr);
#else
#define MPIDI_CH3I_Free_mem(ptr) MPIU_Free(ptr);
#endif
/* 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)
MPIDI_FUNC_ENTER(MPID_STATE_MPIDI_ALLOC_MEM);
ap = MPIU_Malloc(size);
ap = MPIDI_CH3I_Alloc_mem(size, info_ptr);
MPIDI_FUNC_EXIT(MPID_STATE_MPIDI_ALLOC_MEM);
return ap;
......@@ -322,7 +322,7 @@ int MPIDI_Free_mem(void *ptr)
MPIDI_FUNC_ENTER(MPID_STATE_MPIDI_FREE_MEM);
MPIU_Free(ptr);
MPIDI_CH3I_Free_mem(ptr);
MPIDI_FUNC_EXIT(MPID_STATE_MPIDI_FREE_MEM);
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