2013-03-27 22:10:02 +00:00
|
|
|
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
|
|
|
|
/*
|
2018-02-16 12:13:17 -07:00
|
|
|
* Copyright (c) 2011-2018 Los Alamos National Security, LLC. All rights
|
2013-03-27 22:10:02 +00:00
|
|
|
* reserved.
|
2014-10-15 21:47:32 -04:00
|
|
|
* Copyright (c) 2014 The University of Tennessee and The University
|
|
|
|
* of Tennessee Research Foundation. All rights
|
|
|
|
* reserved.
|
2013-03-27 22:10:02 +00:00
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
2014-09-23 18:11:22 +00:00
|
|
|
#include "btl_vader.h"
|
|
|
|
|
2013-03-27 22:10:02 +00:00
|
|
|
#include "opal/include/opal/align.h"
|
2013-10-22 15:33:32 +00:00
|
|
|
#include "opal/mca/memchecker/base/base.h"
|
2013-03-27 22:10:02 +00:00
|
|
|
|
George did the work and deserves all the credit for it. Ralph did the merge, and deserves whatever blame results from errors in it :-)
WHAT: Open our low-level communication infrastructure by moving all necessary components (btl/rcache/allocator/mpool) down in OPAL
All the components required for inter-process communications are currently deeply integrated in the OMPI layer. Several groups/institutions have express interest in having a more generic communication infrastructure, without all the OMPI layer dependencies. This communication layer should be made available at a different software level, available to all layers in the Open MPI software stack. As an example, our ORTE layer could replace the current OOB and instead use the BTL directly, gaining access to more reactive network interfaces than TCP. Similarly, external software libraries could take advantage of our highly optimized AM (active message) communication layer for their own purpose. UTK with support from Sandia, developped a version of Open MPI where the entire communication infrastucture has been moved down to OPAL (btl/rcache/allocator/mpool). Most of the moved components have been updated to match the new schema, with few exceptions (mainly BTLs where I have no way of compiling/testing them). Thus, the completion of this RFC is tied to being able to completing this move for all BTLs. For this we need help from the rest of the Open MPI community, especially those supporting some of the BTLs. A non-exhaustive list of BTLs that qualify here is: mx, portals4, scif, udapl, ugni, usnic.
This commit was SVN r32317.
2014-07-26 00:47:28 +00:00
|
|
|
#if OPAL_BTL_VADER_HAVE_XPMEM
|
2014-01-06 19:51:44 +00:00
|
|
|
|
2014-12-12 09:09:01 -07:00
|
|
|
int mca_btl_vader_xpmem_init (void)
|
|
|
|
{
|
|
|
|
mca_btl_vader_component.my_seg_id = xpmem_make (0, VADER_MAX_ADDRESS, XPMEM_PERMIT_MODE, (void *)0666);
|
|
|
|
if (-1 == mca_btl_vader_component.my_seg_id) {
|
|
|
|
return OPAL_ERR_NOT_AVAILABLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
mca_btl_vader.super.btl_get = mca_btl_vader_get_xpmem;
|
2015-01-08 12:52:38 -07:00
|
|
|
mca_btl_vader.super.btl_put = mca_btl_vader_put_xpmem;
|
2014-12-12 09:09:01 -07:00
|
|
|
|
|
|
|
return OPAL_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2016-10-27 10:09:43 -06:00
|
|
|
struct vader_check_reg_ctx_t {
|
|
|
|
mca_btl_base_endpoint_t *ep;
|
|
|
|
mca_rcache_base_registration_t **reg;
|
|
|
|
uintptr_t base;
|
|
|
|
uintptr_t bound;
|
|
|
|
};
|
|
|
|
typedef struct vader_check_reg_ctx_t vader_check_reg_ctx_t;
|
|
|
|
|
|
|
|
static int vader_check_reg (mca_rcache_base_registration_t *reg, void *ctx)
|
|
|
|
{
|
|
|
|
vader_check_reg_ctx_t *vader_ctx = (vader_check_reg_ctx_t *) ctx;
|
|
|
|
|
|
|
|
if ((intptr_t) reg->alloc_base != vader_ctx->ep->peer_smp_rank ||
|
|
|
|
(reg->flags & MCA_RCACHE_FLAGS_PERSIST)) {
|
|
|
|
/* ignore this registration */
|
|
|
|
return OPAL_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
vader_ctx->reg[0] = reg;
|
|
|
|
|
|
|
|
if (vader_ctx->bound <= (uintptr_t) reg->bound && vader_ctx->base >= (uintptr_t) reg->base) {
|
2017-11-30 09:25:21 -07:00
|
|
|
opal_atomic_add (®->ref_count, 1);
|
2016-10-27 10:09:43 -06:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
2018-02-16 12:13:17 -07:00
|
|
|
void vader_return_registration (mca_rcache_base_registration_t *reg, struct mca_btl_base_endpoint_t *ep)
|
|
|
|
{
|
|
|
|
mca_rcache_base_vma_module_t *vma_module = mca_btl_vader_component.vma_module;
|
|
|
|
int32_t ref_count;
|
|
|
|
|
|
|
|
ref_count = opal_atomic_add_fetch_32 (®->ref_count, -1);
|
|
|
|
if (OPAL_UNLIKELY(0 == ref_count && !(reg->flags & MCA_RCACHE_FLAGS_PERSIST))) {
|
|
|
|
mca_rcache_base_vma_delete (vma_module, reg);
|
|
|
|
|
|
|
|
opal_memchecker_base_mem_noaccess (reg->rcache_context, (uintptr_t)(reg->bound - reg->base));
|
|
|
|
(void)xpmem_detach (reg->rcache_context);
|
|
|
|
OBJ_RELEASE (reg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-27 22:10:02 +00:00
|
|
|
/* look up the remote pointer in the peer rcache and attach if
|
|
|
|
* necessary */
|
2015-11-02 12:07:08 -07:00
|
|
|
mca_rcache_base_registration_t *vader_get_registation (struct mca_btl_base_endpoint_t *ep, void *rem_ptr,
|
|
|
|
size_t size, int flags, void **local_ptr)
|
2013-03-27 22:10:02 +00:00
|
|
|
{
|
2016-10-27 10:09:43 -06:00
|
|
|
mca_rcache_base_vma_module_t *vma_module = mca_btl_vader_component.vma_module;
|
|
|
|
uint64_t attach_align = 1 << mca_btl_vader_component.log_attach_align;
|
|
|
|
mca_rcache_base_registration_t *reg = NULL;
|
2018-02-16 12:13:17 -07:00
|
|
|
vader_check_reg_ctx_t check_ctx = {.ep = ep, .reg = ®};
|
2014-01-29 18:35:47 +00:00
|
|
|
xpmem_addr_t xpmem_addr;
|
2013-03-27 22:10:02 +00:00
|
|
|
uintptr_t base, bound;
|
2016-11-21 14:58:34 -06:00
|
|
|
int rc;
|
2013-03-27 22:10:02 +00:00
|
|
|
|
2015-11-02 12:07:08 -07:00
|
|
|
base = OPAL_DOWN_ALIGN((uintptr_t) rem_ptr, attach_align, uintptr_t);
|
|
|
|
bound = OPAL_ALIGN((uintptr_t) rem_ptr + size - 1, attach_align, uintptr_t) + 1;
|
2013-03-27 22:10:02 +00:00
|
|
|
if (OPAL_UNLIKELY(bound > VADER_MAX_ADDRESS)) {
|
|
|
|
bound = VADER_MAX_ADDRESS;
|
|
|
|
}
|
|
|
|
|
2016-10-27 10:09:43 -06:00
|
|
|
check_ctx.base = base;
|
|
|
|
check_ctx.bound = bound;
|
2013-03-27 22:10:02 +00:00
|
|
|
|
2016-10-27 10:09:43 -06:00
|
|
|
/* several segments may match the base pointer */
|
2018-02-16 12:13:17 -07:00
|
|
|
rc = mca_rcache_base_vma_iterate (vma_module, (void *) base, bound - base, true, vader_check_reg, &check_ctx);
|
2016-10-27 10:09:43 -06:00
|
|
|
if (2 == rc) {
|
2018-02-16 12:13:17 -07:00
|
|
|
/* remove this pointer from the rcache and decrement its reference count
|
|
|
|
(so it is detached later) */
|
|
|
|
mca_rcache_base_vma_delete (vma_module, reg);
|
|
|
|
|
2013-03-27 22:10:02 +00:00
|
|
|
/* start the new segment from the lower of the two bases */
|
2016-10-27 10:09:43 -06:00
|
|
|
base = (uintptr_t) reg->base < base ? (uintptr_t) reg->base : base;
|
2013-03-27 22:10:02 +00:00
|
|
|
|
2018-02-16 12:13:17 -07:00
|
|
|
/* remove the last reference to this registration */
|
|
|
|
vader_return_registration (reg, ep);
|
2013-03-27 22:10:02 +00:00
|
|
|
|
2016-10-27 10:09:43 -06:00
|
|
|
reg = NULL;
|
2013-03-27 22:10:02 +00:00
|
|
|
}
|
|
|
|
|
2016-10-27 10:09:43 -06:00
|
|
|
if (NULL == reg) {
|
|
|
|
reg = OBJ_NEW(mca_rcache_base_registration_t);
|
|
|
|
if (OPAL_LIKELY(NULL != reg)) {
|
|
|
|
/* stick around for awhile */
|
|
|
|
reg->ref_count = 2;
|
|
|
|
reg->base = (unsigned char *) base;
|
|
|
|
reg->bound = (unsigned char *) bound;
|
|
|
|
reg->flags = flags;
|
|
|
|
reg->alloc_base = (void *) (intptr_t) ep->peer_smp_rank;
|
2014-01-29 18:35:47 +00:00
|
|
|
|
|
|
|
#if defined(HAVE_SN_XPMEM_H)
|
2016-10-27 10:09:43 -06:00
|
|
|
xpmem_addr.id = ep->segment_data.xpmem.apid;
|
2014-01-29 18:35:47 +00:00
|
|
|
#else
|
2016-10-27 10:09:43 -06:00
|
|
|
xpmem_addr.apid = ep->segment_data.xpmem.apid;
|
2014-01-29 18:35:47 +00:00
|
|
|
#endif
|
2016-10-27 10:09:43 -06:00
|
|
|
xpmem_addr.offset = base;
|
2013-03-27 22:10:02 +00:00
|
|
|
|
2016-10-27 10:09:43 -06:00
|
|
|
reg->rcache_context = xpmem_attach (xpmem_addr, bound - base, NULL);
|
|
|
|
if (OPAL_UNLIKELY((void *)-1 == reg->rcache_context)) {
|
|
|
|
OBJ_RELEASE(reg);
|
|
|
|
return NULL;
|
|
|
|
}
|
2013-07-11 20:54:12 +00:00
|
|
|
|
2016-10-27 10:09:43 -06:00
|
|
|
opal_memchecker_base_mem_defined (reg->rcache_context, bound - base);
|
2013-10-22 15:33:32 +00:00
|
|
|
|
2018-02-16 12:13:17 -07:00
|
|
|
if (!(flags & MCA_RCACHE_FLAGS_PERSIST)) {
|
|
|
|
mca_rcache_base_vma_insert (vma_module, reg, 0);
|
|
|
|
}
|
2016-10-27 10:09:43 -06:00
|
|
|
}
|
2013-03-27 22:10:02 +00:00
|
|
|
}
|
|
|
|
|
2013-07-11 20:54:12 +00:00
|
|
|
opal_atomic_wmb ();
|
2015-11-02 12:07:08 -07:00
|
|
|
*local_ptr = (void *) ((uintptr_t) reg->rcache_context +
|
2013-07-11 20:54:12 +00:00
|
|
|
(ptrdiff_t)((uintptr_t) rem_ptr - (uintptr_t) reg->base));
|
|
|
|
|
2013-03-27 22:10:02 +00:00
|
|
|
return reg;
|
|
|
|
}
|
|
|
|
|
2016-10-27 10:09:43 -06:00
|
|
|
static int mca_btl_vader_endpoint_xpmem_rcache_cleanup (mca_rcache_base_registration_t *reg, void *ctx)
|
|
|
|
{
|
|
|
|
mca_rcache_base_vma_module_t *vma_module = mca_btl_vader_component.vma_module;
|
|
|
|
mca_btl_vader_endpoint_t *ep = (mca_btl_vader_endpoint_t *) ctx;
|
|
|
|
if ((intptr_t) reg->alloc_base == ep->peer_smp_rank) {
|
|
|
|
/* otherwise dereg will fail on assert */
|
|
|
|
reg->ref_count = 0;
|
|
|
|
OBJ_RELEASE(reg);
|
|
|
|
}
|
|
|
|
|
|
|
|
return OPAL_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
void mca_btl_vader_xpmem_cleanup_endpoint (struct mca_btl_base_endpoint_t *ep)
|
|
|
|
{
|
|
|
|
/* clean out the registration cache */
|
|
|
|
(void) mca_rcache_base_vma_iterate (mca_btl_vader_component.vma_module,
|
2018-02-16 12:13:17 -07:00
|
|
|
NULL, (size_t) -1, true,
|
2016-10-27 10:09:43 -06:00
|
|
|
mca_btl_vader_endpoint_xpmem_rcache_cleanup,
|
|
|
|
(void *) ep);
|
|
|
|
if (ep->segment_base) {
|
|
|
|
xpmem_release (ep->segment_data.xpmem.apid);
|
|
|
|
ep->segment_data.xpmem.apid = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
George did the work and deserves all the credit for it. Ralph did the merge, and deserves whatever blame results from errors in it :-)
WHAT: Open our low-level communication infrastructure by moving all necessary components (btl/rcache/allocator/mpool) down in OPAL
All the components required for inter-process communications are currently deeply integrated in the OMPI layer. Several groups/institutions have express interest in having a more generic communication infrastructure, without all the OMPI layer dependencies. This communication layer should be made available at a different software level, available to all layers in the Open MPI software stack. As an example, our ORTE layer could replace the current OOB and instead use the BTL directly, gaining access to more reactive network interfaces than TCP. Similarly, external software libraries could take advantage of our highly optimized AM (active message) communication layer for their own purpose. UTK with support from Sandia, developped a version of Open MPI where the entire communication infrastucture has been moved down to OPAL (btl/rcache/allocator/mpool). Most of the moved components have been updated to match the new schema, with few exceptions (mainly BTLs where I have no way of compiling/testing them). Thus, the completion of this RFC is tied to being able to completing this move for all BTLs. For this we need help from the rest of the Open MPI community, especially those supporting some of the BTLs. A non-exhaustive list of BTLs that qualify here is: mx, portals4, scif, udapl, ugni, usnic.
This commit was SVN r32317.
2014-07-26 00:47:28 +00:00
|
|
|
#endif /* OPAL_BTL_VADER_HAVE_XPMEM */
|