Skip to content

Commit

Permalink
opal: rework mpool and rcache frameworks
Browse files Browse the repository at this point in the history
This commit rewrites both the mpool and rcache frameworks. Summary of
changes:

 - Before this change a significant portion of the rcache
   functionality lived in mpool components. This meant that it was
   impossible to add a new memory pool to use with rdma networks
   (ugni, openib, etc) without duplicating the functionality of an
   existing mpool component. All the registration functionality has
   been removed from the mpool and placed in the rcache framework.

 - All registration cache mpools components (udreg, grdma, gpusm,
   rgpusm) have been changed to rcache components. rcaches are
   allocated and released in the same way mpool components were.

 - It is now valid to pass NULL as the resources argument when
   creating an rcache. At this time the gpusm and rgpusm components
   support this. All other rcache components require non-NULL
   resources.

 - A new mpool component has been added: hugepage. This component
   supports huge page allocations on linux.

 - Memory pools are now allocated using "hints". Each mpool component
   is queried with the hints and returns a priority. The current hints
   supported are NULL (uses posix_memalign/malloc), page_size=x (huge
   page mpool), and mpool=x.

 - The sm mpool has been moved to common/sm. This reflects that the sm
   mpool is specialized and not meant for any general
   allocations. This mpool may be moved back into the mpool framework
   if there is any objection.

 - The opal_free_list_init arguments have been updated. The unused0
   argument is not used to pass in the registration cache module. The
   mpool registration flags are now rcache registration flags.

 - All components have been updated to make use of the new framework
   interfaces.

As this commit makes significant changes to both the mpool and rcache
frameworks both versions have been bumped to 3.0.0.

Signed-off-by: Nathan Hjelm <[email protected]>
  • Loading branch information
hjelmn committed Mar 14, 2016
1 parent 6d7ada9 commit d4afb16
Show file tree
Hide file tree
Showing 127 changed files with 4,619 additions and 5,091 deletions.
7 changes: 5 additions & 2 deletions ompi/mca/crcp/base/base.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2004-2010 The Trustees of Indiana University and Indiana
* University Research and Technology
Expand All @@ -9,6 +10,8 @@
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights
* reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -145,7 +148,7 @@ BEGIN_C_DECLS
ompi_crcp_base_btl_state_t*
ompi_crcp_base_none_btl_prepare_src( struct mca_btl_base_module_t* btl,
struct mca_btl_base_endpoint_t* endpoint,
mca_mpool_base_registration_t* registration,
mca_rcache_base_registration_t* registration,
struct opal_convertor_t* convertor,
size_t reserve,
size_t* size,
Expand All @@ -154,7 +157,7 @@ BEGIN_C_DECLS
ompi_crcp_base_btl_state_t*
ompi_crcp_base_none_btl_prepare_dst( struct mca_btl_base_module_t* btl,
struct mca_btl_base_endpoint_t* endpoint,
mca_mpool_base_registration_t* registration,
mca_rcache_base_registration_t* registration,
struct opal_convertor_t* convertor,
size_t reserve,
size_t* size,
Expand Down
4 changes: 2 additions & 2 deletions ompi/mca/crcp/base/crcp_base_fns.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ ompi_crcp_base_none_btl_free( struct mca_btl_base_module_t* btl,
ompi_crcp_base_btl_state_t*
ompi_crcp_base_none_btl_prepare_src( struct mca_btl_base_module_t* btl,
struct mca_btl_base_endpoint_t* endpoint,
mca_mpool_base_registration_t* registration,
mca_rcache_base_registration_t* registration,
struct opal_convertor_t* convertor,
size_t reserve,
size_t* size,
Expand All @@ -349,7 +349,7 @@ ompi_crcp_base_none_btl_prepare_src( struct mca_btl_base_module_t* btl,
ompi_crcp_base_btl_state_t*
ompi_crcp_base_none_btl_prepare_dst( struct mca_btl_base_module_t* btl,
struct mca_btl_base_endpoint_t* endpoint,
mca_mpool_base_registration_t* registration,
mca_rcache_base_registration_t* registration,
struct opal_convertor_t* convertor,
size_t reserve,
size_t* size,
Expand Down
2 changes: 1 addition & 1 deletion ompi/mca/crcp/crcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ typedef ompi_crcp_base_btl_state_t* (*mca_crcp_base_btl_module_free_fn_t)
typedef ompi_crcp_base_btl_state_t* (*mca_crcp_base_btl_module_prepare_fn_t)
( struct mca_btl_base_module_t* btl,
struct mca_btl_base_endpoint_t* endpoint,
mca_mpool_base_registration_t* registration,
mca_rcache_base_registration_t* registration,
struct opal_convertor_t* convertor,
size_t reserve,
size_t* size,
Expand Down
15 changes: 7 additions & 8 deletions ompi/mca/pml/base/pml_base_bsend.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
Expand All @@ -12,6 +13,8 @@
* Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
* Copyright (c) 2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights
* reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -55,10 +58,7 @@ extern char *ompi_pml_base_bsend_allocator_name;
/*
* Routine to return pages to sub-allocator as needed
*/
static void* mca_pml_bsend_alloc_segment(
struct mca_mpool_base_module_t* module,
size_t* size_inout,
mca_mpool_base_registration_t** registration)
static void* mca_pml_bsend_alloc_segment(void *ctx, size_t *size_inout)
{
void *addr;
size_t size = *size_inout;
Expand All @@ -70,7 +70,6 @@ static void* mca_pml_bsend_alloc_segment(
addr = mca_pml_bsend_addr;
mca_pml_bsend_addr += size;
*size_inout = size;
if (NULL != registration) *registration = NULL;
return addr;
}

Expand Down Expand Up @@ -232,7 +231,7 @@ int mca_pml_base_bsend_request_start(ompi_request_t* request)

/* allocate a buffer to hold packed message */
sendreq->req_addr = mca_pml_bsend_allocator->alc_alloc(
mca_pml_bsend_allocator, sendreq->req_bytes_packed, 0, NULL);
mca_pml_bsend_allocator, sendreq->req_bytes_packed, 0);
if(NULL == sendreq->req_addr) {
/* release resources when request is freed */
sendreq->req_base.req_pml_complete = true;
Expand Down Expand Up @@ -287,7 +286,7 @@ int mca_pml_base_bsend_request_alloc(ompi_request_t* request)

/* allocate a buffer to hold packed message */
sendreq->req_addr = mca_pml_bsend_allocator->alc_alloc(
mca_pml_bsend_allocator, sendreq->req_bytes_packed, 0, NULL);
mca_pml_bsend_allocator, sendreq->req_bytes_packed, 0);
if(NULL == sendreq->req_addr) {
/* release resources when request is freed */
sendreq->req_base.req_pml_complete = true;
Expand Down Expand Up @@ -321,7 +320,7 @@ void* mca_pml_base_bsend_request_alloc_buf( size_t length )

/* allocate a buffer to hold packed message */
buf = mca_pml_bsend_allocator->alc_alloc(
mca_pml_bsend_allocator, length, 0, NULL);
mca_pml_bsend_allocator, length, 0);
if(NULL == buf) {
/* release resources when request is freed */
OPAL_THREAD_UNLOCK(&mca_pml_bsend_mutex);
Expand Down
16 changes: 6 additions & 10 deletions ompi/mca/pml/ob1/pml_ob1_component.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,9 @@ mca_pml_base_component_2_0_0_t mca_pml_ob1_component = {
.pmlm_finalize = mca_pml_ob1_component_fini,
};

void *mca_pml_ob1_seg_alloc( struct mca_mpool_base_module_t* mpool,
size_t* size,
mca_mpool_base_registration_t** registration);
void *mca_pml_ob1_seg_alloc (void *ctx, size_t* size);

void mca_pml_ob1_seg_free( struct mca_mpool_base_module_t* mpool,
void* segment );
void mca_pml_ob1_seg_free (void *ctx, void *segment);

static inline int mca_pml_ob1_param_register_int(
const char* param_name,
Expand Down Expand Up @@ -354,13 +351,12 @@ int mca_pml_ob1_component_fini(void)
return OMPI_SUCCESS;
}

void *mca_pml_ob1_seg_alloc( struct mca_mpool_base_module_t* mpool,
size_t* size,
mca_mpool_base_registration_t** registration) {
void *mca_pml_ob1_seg_alloc (void *ctx, size_t *size)
{
return malloc(*size);
}

void mca_pml_ob1_seg_free( struct mca_mpool_base_module_t* mpool,
void* segment ) {
void mca_pml_ob1_seg_free (void *ctx, void *segment)
{
free(segment);
}
2 changes: 1 addition & 1 deletion ompi/mca/pml/ob1/pml_ob1_recvfrag.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ do { \
buffers[0].addr = (char*) \
mca_pml_ob1.allocator->alc_alloc( mca_pml_ob1.allocator, \
buffers[0].len, \
0, NULL); \
0); \
_ptr = (unsigned char*)(buffers[0].addr); \
macro_segments[0].seg_addr.pval = buffers[0].addr; \
} \
Expand Down
8 changes: 4 additions & 4 deletions ompi/mca/vprotocol/base/vprotocol_base_request.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ int mca_vprotocol_base_request_parasite(void)
pml_fl_save.fl_max_to_alloc,
pml_fl_save.fl_num_per_alloc,
pml_fl_save.fl_mpool,
pml_fl_save.fl_mpool_reg_flags,
0,
pml_fl_save.fl_rcache_reg_flags,
pml_fl_save.fl_rcache,
pml_fl_save.item_init,
pml_fl_save.ctx);
if(OMPI_SUCCESS != ret) return ret;
Expand Down Expand Up @@ -71,8 +71,8 @@ int mca_vprotocol_base_request_parasite(void)
pml_fl_save.fl_max_to_alloc,
pml_fl_save.fl_num_per_alloc,
pml_fl_save.fl_mpool,
pml_fl_save.fl_mpool_reg_flags,
0,
pml_fl_save.fl_rcache_reg_flags,
pml_fl_save.fl_rcache,
pml_fl_save.item_init,
pml_fl_save.ctx);
if(OMPI_SUCCESS != ret) return ret;
Expand Down
16 changes: 15 additions & 1 deletion ompi/mpi/c/alloc_mem.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
* University Research and Technology
Expand All @@ -12,6 +13,8 @@
* Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights
* reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -43,6 +46,8 @@ static const char FUNC_NAME[] = "MPI_Alloc_mem";

int MPI_Alloc_mem(MPI_Aint size, MPI_Info info, void *baseptr)
{
char info_value[MPI_MAX_INFO_VAL + 1];
char *mpool_hints = NULL;

if (MPI_PARAM_CHECK) {
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
Expand All @@ -69,7 +74,16 @@ int MPI_Alloc_mem(MPI_Aint size, MPI_Info info, void *baseptr)

OPAL_CR_ENTER_LIBRARY();

*((void **) baseptr) = mca_mpool_base_alloc((size_t) size, (struct opal_info_t*)info);
if (MPI_INFO_NULL != info) {
int flag;
(void) ompi_info_get (info, "mpool_hints", MPI_MAX_INFO_VAL, info_value, &flag);
if (flag) {
mpool_hints = info_value;
}
}

*((void **) baseptr) = mca_mpool_base_alloc ((size_t) size, (struct opal_info_t*)info,
mpool_hints);
OPAL_CR_EXIT_LIBRARY();
if (NULL == *((void **) baseptr)) {
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_NO_MEM,
Expand Down
7 changes: 0 additions & 7 deletions ompi/runtime/ompi_mpi_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -628,13 +628,6 @@ int ompi_mpi_init(int argc, char **argv, int requested, int *provided)

/* Select which MPI components to use */

if (OMPI_SUCCESS !=
(ret = mca_mpool_base_init(OPAL_ENABLE_PROGRESS_THREADS,
ompi_mpi_thread_multiple))) {
error = "mca_mpool_base_init() failed";
goto error;
}

if (OMPI_SUCCESS !=
(ret = mca_pml_base_select(OPAL_ENABLE_PROGRESS_THREADS,
ompi_mpi_thread_multiple))) {
Expand Down
Loading

0 comments on commit d4afb16

Please sign in to comment.