From 77c50efb95f6ed5b2ad7b952008a75ab6358b053 Mon Sep 17 00:00:00 2001 From: Boris Karasev Date: Fri, 14 Jul 2017 10:28:32 +0600 Subject: [PATCH] Yoda SPML is removed Signed-off-by: Boris Karasev --- opal/mca/common/verbs/common_verbs.h | 2 +- oshmem/mca/spml/base/spml_base.c | 3 - oshmem/mca/spml/base/spml_base_frame.c | 1 - oshmem/mca/spml/base/spml_base_select.c | 7 +- oshmem/mca/spml/yoda/Makefile.am | 45 - .../mca/spml/yoda/help-oshmem-spml-yoda.txt | 17 - oshmem/mca/spml/yoda/post_configure.sh | 4 - oshmem/mca/spml/yoda/spml_yoda.c | 1269 ----------------- oshmem/mca/spml/yoda/spml_yoda.h | 150 -- oshmem/mca/spml/yoda/spml_yoda_component.c | 140 -- oshmem/mca/spml/yoda/spml_yoda_component.h | 25 - oshmem/mca/spml/yoda/spml_yoda_getreq.c | 128 -- oshmem/mca/spml/yoda/spml_yoda_getreq.h | 70 - oshmem/mca/spml/yoda/spml_yoda_putreq.c | 113 -- oshmem/mca/spml/yoda/spml_yoda_putreq.h | 63 - oshmem/mca/spml/yoda/spml_yoda_rdmafrag.h | 45 - 16 files changed, 2 insertions(+), 2080 deletions(-) delete mode 100644 oshmem/mca/spml/yoda/Makefile.am delete mode 100644 oshmem/mca/spml/yoda/help-oshmem-spml-yoda.txt delete mode 100644 oshmem/mca/spml/yoda/post_configure.sh delete mode 100644 oshmem/mca/spml/yoda/spml_yoda.c delete mode 100644 oshmem/mca/spml/yoda/spml_yoda.h delete mode 100644 oshmem/mca/spml/yoda/spml_yoda_component.c delete mode 100644 oshmem/mca/spml/yoda/spml_yoda_component.h delete mode 100644 oshmem/mca/spml/yoda/spml_yoda_getreq.c delete mode 100644 oshmem/mca/spml/yoda/spml_yoda_getreq.h delete mode 100644 oshmem/mca/spml/yoda/spml_yoda_putreq.c delete mode 100644 oshmem/mca/spml/yoda/spml_yoda_putreq.h delete mode 100644 oshmem/mca/spml/yoda/spml_yoda_rdmafrag.h diff --git a/opal/mca/common/verbs/common_verbs.h b/opal/mca/common/verbs/common_verbs.h index 36ce3d85d1..f68bea086e 100644 --- a/opal/mca/common/verbs/common_verbs.h +++ b/opal/mca/common/verbs/common_verbs.h @@ -172,7 +172,7 @@ OPAL_DECLSPEC int opal_common_verbs_qp_test(struct ibv_context *device_context, * Known limitations: * If ibv_fork_init is called after ibv_create_* functions - it will have no effect. * OMPI initializes verbs many times during initialization in the following verbs components: - * oob/ud, btl/openib, mtl/mxm, pml/yalla, oshmem/ikrit, oshmem/yoda, ompi/mca/coll/{fca,hcoll} + * oob/ud, btl/openib, mtl/mxm, pml/yalla, oshmem/ikrit, ompi/mca/coll/{fca,hcoll} * * So, ibv_fork_init should be called once, in the beginning of the init flow of every verb component * to proper request fork support. diff --git a/oshmem/mca/spml/base/spml_base.c b/oshmem/mca/spml/base/spml_base.c index c7b1f83381..ce156be4e6 100644 --- a/oshmem/mca/spml/base/spml_base.c +++ b/oshmem/mca/spml/base/spml_base.c @@ -14,11 +14,8 @@ #include "opal/datatype/opal_convertor.h" #include "orte/include/orte/types.h" #include "orte/runtime/orte_globals.h" -#include "oshmem/mca/spml/yoda/spml_yoda.h" #include "oshmem/proc/proc.h" #include "oshmem/mca/spml/base/base.h" -#include "oshmem/mca/spml/yoda/spml_yoda_putreq.h" -#include "oshmem/mca/spml/yoda/spml_yoda_getreq.h" #include "opal/mca/btl/btl.h" #define SPML_BASE_DO_CMP(_res, _addr, _op, _val) \ diff --git a/oshmem/mca/spml/base/spml_base_frame.c b/oshmem/mca/spml/base/spml_base_frame.c index 2c230bf182..2ba4b0bb9d 100644 --- a/oshmem/mca/spml/base/spml_base_frame.c +++ b/oshmem/mca/spml/base/spml_base_frame.c @@ -144,7 +144,6 @@ static int mca_spml_base_open(mca_base_open_flag_t flags) if( (NULL == default_spml || NULL == default_spml[0] || 0 == strlen(default_spml[0])) || (default_spml[0][0] == '^') ) { opal_pointer_array_add(&mca_spml_base_spml, strdup("ikrit")); - opal_pointer_array_add(&mca_spml_base_spml, strdup("yoda")); } else { opal_pointer_array_add(&mca_spml_base_spml, strdup(default_spml[0])); } diff --git a/oshmem/mca/spml/base/spml_base_select.c b/oshmem/mca/spml/base/spml_base_select.c index 5fdd773a4d..fd46f796aa 100644 --- a/oshmem/mca/spml/base/spml_base_select.c +++ b/oshmem/mca/spml/base/spml_base_select.c @@ -147,12 +147,7 @@ int mca_spml_base_select(bool enable_progress_threads, bool enable_mpi_threads) if (NULL == tmp_val) { continue; } - if (0 == strncmp(tmp_val, "yoda", 4) && !mca_bml_base_inited()) { - orte_errmgr.abort(1, "SPML %s cannot be selected becasue no btls are available. Please make sure that ob1 pml is selected by ompi (-mca pml ob1)", tmp_val); - } - else { - orte_errmgr.abort(1, "SPML %s cannot be selected", tmp_val); - } + orte_errmgr.abort(1, "SPML %s cannot be selected", tmp_val); } if (0 == i) { orte_errmgr.abort(2, diff --git a/oshmem/mca/spml/yoda/Makefile.am b/oshmem/mca/spml/yoda/Makefile.am deleted file mode 100644 index e0d48bfdb2..0000000000 --- a/oshmem/mca/spml/yoda/Makefile.am +++ /dev/null @@ -1,45 +0,0 @@ -# -# Copyright (c) 2013 Mellanox Technologies, Inc. -# All rights reserved. -# -# $COPYRIGHT$ -# -# Additional copyrights may follow -# -# $HEADER$ -# - -dist_oshmemdata_DATA = \ - help-oshmem-spml-yoda.txt - -EXTRA_DIST = post_configure.sh - -AM_CFLAGS = $(btl_sm_CPPFLAGS) - -yoda_sources = \ - spml_yoda.c \ - spml_yoda.h \ - spml_yoda_component.c \ - spml_yoda_component.h \ - spml_yoda_rdmafrag.h \ - spml_yoda_putreq.c \ - spml_yoda_putreq.h \ - spml_yoda_getreq.c \ - spml_yoda_getreq.h - -if MCA_BUILD_ompi_pml_ob1_DSO -component_noinst = -component_install = mca_spml_yoda.la -else -component_noinst = libmca_spml_yoda.la -component_install = -endif - -mcacomponentdir = $(oshmemlibdir) -mcacomponent_LTLIBRARIES = $(component_install) -mca_spml_yoda_la_SOURCES = $(yoda_sources) -mca_spml_yoda_la_LDFLAGS = -module -avoid-version - -noinst_LTLIBRARIES = $(component_noinst) -libmca_spml_yoda_la_SOURCES = $(yoda_sources) -libmca_spml_yoda_la_LDFLAGS = -module -avoid-version diff --git a/oshmem/mca/spml/yoda/help-oshmem-spml-yoda.txt b/oshmem/mca/spml/yoda/help-oshmem-spml-yoda.txt deleted file mode 100644 index ac185cdd3f..0000000000 --- a/oshmem/mca/spml/yoda/help-oshmem-spml-yoda.txt +++ /dev/null @@ -1,17 +0,0 @@ -# -*- text -*- -# -# Copyright (c) 2013 Mellanox Technologies, Inc. -# All rights reserved. -# $COPYRIGHT$ -# -# Additional copyrights may follow -# -# $HEADER$ -# -[internal_oom_error] -'%s' operation failed. Unable to allocate buffer, need %d bytes. -Try increasing 'spml_yoda_bml_alloc_threshold' value or setting it to '0' to -force waiting for all puts completion. - - spml_yoda_bml_alloc_threshold: %d - diff --git a/oshmem/mca/spml/yoda/post_configure.sh b/oshmem/mca/spml/yoda/post_configure.sh deleted file mode 100644 index d7d3db8278..0000000000 --- a/oshmem/mca/spml/yoda/post_configure.sh +++ /dev/null @@ -1,4 +0,0 @@ -# Copyright (c) 2013 Mellanox Technologies, Inc. -# All rights reserved -# $COPYRIGHT$ -DIRECT_CALL_HEADER="oshmem/mca/spml/yoda/spml_yoda.h" diff --git a/oshmem/mca/spml/yoda/spml_yoda.c b/oshmem/mca/spml/yoda/spml_yoda.c deleted file mode 100644 index ebdceab8c9..0000000000 --- a/oshmem/mca/spml/yoda/spml_yoda.c +++ /dev/null @@ -1,1269 +0,0 @@ -/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ -/* - * Copyright (c) 2013-2015 Mellanox Technologies, Inc. - * All rights reserved. - * Copyright (c) 2014-2016 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 - * - * $HEADER$ - */ - -#include "oshmem_config.h" - -#include "opal/util/show_help.h" -#include "orte/include/orte/types.h" -#include "orte/runtime/orte_globals.h" - -#include "opal/datatype/opal_convertor.h" - -#include "ompi/datatype/ompi_datatype.h" -#include "ompi/mca/pml/pml.h" -#include "opal/mca/btl/btl.h" -#include "opal/mca/btl/base/base.h" -#include "opal/mca/btl/sm/btl_sm_frag.h" - -#include "oshmem/proc/proc.h" -#include "oshmem/mca/memheap/memheap.h" -#include "oshmem/mca/memheap/base/base.h" -#include "oshmem/mca/spml/spml.h" - -#include "spml_yoda.h" -#include "spml_yoda_putreq.h" -#include "spml_yoda_getreq.h" -#ifdef HAVE_UNISTD_H -#include -#endif -#include "oshmem/runtime/runtime.h" - -/* Turn ON/OFF debug output from build (default 0) */ -#ifndef SPML_YODA_DEBUG -#define SPML_YODA_DEBUG 0 -#endif - -mca_spml_yoda_module_t mca_spml_yoda = { - { - /* Init mca_spml_base_module_t */ - mca_spml_yoda_add_procs, - mca_spml_yoda_del_procs, - mca_spml_yoda_enable, - mca_spml_yoda_register, - mca_spml_yoda_deregister, - mca_spml_base_oob_get_mkeys, - mca_spml_yoda_put, - mca_spml_yoda_put_nb, - mca_spml_yoda_get, - mca_spml_yoda_get_nb, - mca_spml_yoda_recv, - mca_spml_yoda_send, - mca_spml_base_wait, - mca_spml_base_wait_nb, - mca_spml_yoda_fence, - mca_spml_base_rmkey_unpack, - mca_spml_base_rmkey_free, - mca_spml_base_memuse_hook, - - (void *)&mca_spml_yoda - } -}; - -static inline mca_bml_base_btl_t *get_next_btl(int dst, int *btl_id); - -static inline void spml_yoda_prepare_for_get(void* buffer, size_t size, void* p_src, int dst, void* p_dst, void* p_getreq); - -static int btl_name_to_id(char *btl_name) -{ - if (0 == strcmp(btl_name, "sm")) { - return YODA_BTL_SM; - } else if (0 == strcmp(btl_name, "openib")) { - return YODA_BTL_OPENIB; - } else if (0 == strcmp(btl_name, "self")) { - return YODA_BTL_SELF; - } else if (0 == strcmp(btl_name, "vader")) { - return YODA_BTL_VADER; - } else if (0 == strcmp(btl_name, "ugni")) { - return YODA_BTL_UGNI; - } - return YODA_BTL_UNKNOWN; -} - -static char *btl_type2str(int btl_type) -{ - switch (btl_type) { - case YODA_BTL_UNKNOWN: - return "unknown btl"; - case YODA_BTL_SELF: - return "self"; - case YODA_BTL_OPENIB: - return "openib"; - case YODA_BTL_SM: - return "sm"; - case YODA_BTL_VADER: - return "vader"; - case YODA_BTL_UGNI: - return "ugni"; - } - return "bad_btl_type"; -} - -static inline void calc_nfrags_put (mca_bml_base_btl_t* bml_btl, - size_t size, - unsigned int *frag_size, - int *nfrags, - int use_send) -{ - if (use_send) { - *frag_size = bml_btl->btl->btl_max_send_size - SPML_YODA_SEND_CONTEXT_SIZE; - } - else { - *frag_size = bml_btl->btl->btl_max_send_size; - } - *nfrags = 1 + (size - 1) / (*frag_size); -} - -static inline void calc_nfrags_get (mca_bml_base_btl_t* bml_btl, - size_t size, - unsigned int *frag_size, - int *nfrags, - int use_send) -{ - if (use_send) { - *frag_size = bml_btl->btl->btl_max_send_size - SPML_YODA_SEND_CONTEXT_SIZE; - } - else { - *frag_size = bml_btl->btl->btl_max_send_size; - } - *nfrags = 1 + (size - 1) / (*frag_size); -} - -static int mca_spml_yoda_fence_internal(int puts_wait) -{ - int n_puts_wait; - - /* Waiting for certain number of puts : 'puts_wait' - * if 'puts_wait' == 0 waiting for all puts ('n_active_puts') - * if 'puts_wait' > 'n_active_puts' waiting for 'n_active_puts' */ - - n_puts_wait = puts_wait > 0 ? mca_spml_yoda.n_active_puts - puts_wait : 0; - - if (n_puts_wait < 0) { - n_puts_wait = 0; - } - - while (n_puts_wait < mca_spml_yoda.n_active_puts) { - oshmem_request_wait_any_completion(); - } - return OSHMEM_SUCCESS; -} - -static inline void mca_spml_yoda_bml_alloc( mca_bml_base_btl_t* bml_btl, - mca_btl_base_descriptor_t** des, - uint8_t order, size_t size, uint32_t flags, - int use_send) -{ - bool is_done; - bool is_fence_complete; - - is_done = false; - is_fence_complete = false; - - if (use_send) { - size = (0 == size ? size : size + SPML_YODA_SEND_CONTEXT_SIZE); - } - - do { - mca_bml_base_alloc(bml_btl, - des, - MCA_BTL_NO_ORDER, - size, - flags); - - if (OPAL_UNLIKELY(!(*des) || !(*des)->des_segments ) && !is_fence_complete) { - mca_spml_yoda_fence_internal(mca_spml_yoda.bml_alloc_threshold); - - is_fence_complete = true; - } else { - is_done = true; - } - - } while (!is_done); -} - -static inline void spml_yoda_prepare_for_put(void* buffer, size_t size, void* p_src, void* p_dst, int use_send) -{ - if (use_send) { - memcpy((void*) buffer, &size, sizeof(size)); - memcpy((void*) (((char*) buffer) + sizeof(size)), &p_dst, sizeof(void *)); - memcpy((void*) (((char*) buffer) + sizeof(size) + sizeof(void *)), p_src, size); - } - else { - memcpy((void*) ((unsigned char*) buffer), p_src, size); - } -} - -static inline void spml_yoda_prepare_for_get_response(void* buffer, size_t size, void* p_src, void* p_dst, void* p_getreq, int use_send) -{ - if (use_send) { - memcpy((void*) buffer, &size, sizeof(size)); - memcpy((void*) (((char*) buffer) + sizeof(size)), &p_dst, sizeof(void *)); - memcpy((void*) (((char*) buffer) + sizeof(size) + sizeof(void *)), p_src, size); - memcpy((void*) (((char*) buffer) + sizeof(size) + sizeof(void *) + size), &p_getreq, sizeof(void *)); - } - else { - memcpy((void*) ( (unsigned char*) buffer), p_src, size); - } -} - -static inline void spml_yoda_prepare_for_get(void* buffer, size_t size, void* p_src, int dst, void* p_dst, void* p_getreq) -{ - memcpy((void*) buffer, &p_src, sizeof(void *)); - memcpy((void*) (((unsigned char*) buffer) + sizeof(void *)), &size, sizeof(size)); - memcpy((void*) (((unsigned char*) buffer) + sizeof(void *) + sizeof(size) ), &dst, sizeof(dst)); - memcpy((void*) (((unsigned char*) buffer) + sizeof(void *) + sizeof(size) + sizeof(dst)), &p_dst, sizeof(void *)); - memcpy((void*) (((unsigned char*) buffer) + sizeof(void *) + sizeof(size) + sizeof(dst) + sizeof(void *)), &p_getreq, sizeof(void *)); -} - -static void mca_yoda_put_callback(mca_btl_base_module_t* btl, - mca_btl_base_tag_t tag, - mca_btl_base_descriptor_t* des, - void* cbdata ) -{ - size_t* size; - void** l_addr; - - size = (size_t *) des->des_segments->seg_addr.pval; - l_addr = (void**) ( ((char*)size) + sizeof(*size)); - memcpy(*l_addr, ((char*)l_addr) + sizeof(*l_addr), *size); -} - -static void mca_yoda_get_callback(mca_btl_base_module_t* btl, - mca_btl_base_tag_t tag, - mca_btl_base_descriptor_t* des, - void* cbdata ) -{ - void** p, ** p_src, **p_dst; - size_t* size; - int* dst; - void** p_getreq; - mca_btl_base_descriptor_t* des_loc; - int rc; - mca_bml_base_btl_t* bml_btl; - mca_spml_yoda_rdma_frag_t* frag; - int btl_id; - mca_spml_yoda_put_request_t *putreq; - - rc = OSHMEM_SUCCESS; - btl_id = 0; - putreq = NULL; - - /* Unpack data */ - p = (void **)des->des_segments->seg_addr.pval; - p_src = (void*) p; - - size = (size_t*)((char*)p_src + sizeof(*p_src) ); - dst = (int*)( (char*)size + sizeof(*size)); - p_dst = (void*) ((char*)dst + sizeof(*dst)); - p_getreq =(void**) ( (char*)p_dst + sizeof(*p_dst)); - - /* Prepare put via send*/ - bml_btl = get_next_btl(*dst, &btl_id); - - putreq = mca_spml_yoda_putreq_alloc(*dst); - frag = &putreq->put_frag; - - mca_spml_yoda_bml_alloc(bml_btl, - &des_loc, - MCA_BTL_NO_ORDER, - *size, - MCA_BTL_DES_SEND_ALWAYS_CALLBACK, - 1); - - if (OPAL_UNLIKELY(!des_loc || !des_loc->des_segments)) { - SPML_ERROR("shmem OOM error need %d bytes", (int)*size); - oshmem_shmem_abort(-1); - } - spml_yoda_prepare_for_get_response((void*)des_loc->des_segments->seg_addr.pval, *size, (void*)*p_src, (void*) *p_dst,(void*)*p_getreq,1); - - frag->rdma_req = putreq; - - /* Initialize callback data for put*/ - des_loc->des_cbdata = frag; - des_loc->des_cbfunc = mca_spml_yoda_put_completion; - des_loc->des_segment_count = 1; - - OPAL_THREAD_ADD32(&mca_spml_yoda.n_active_puts, 1); - - /* Put via send*/ - rc = mca_bml_base_send(bml_btl, des_loc, MCA_SPML_YODA_GET_RESPONSE); - if (1 == rc) { - rc = OSHMEM_SUCCESS; - } - - if (OPAL_UNLIKELY(OSHMEM_SUCCESS != rc)) { - if (OSHMEM_ERR_OUT_OF_RESOURCE == rc) { - /* No free resources, Block on completion here */ - SPML_ERROR("shmem error: OSHMEM_ERR_OUT_OF_RESOURCE"); - oshmem_request_wait_completion(&putreq->req_put.req_base.req_oshmem); - } else { - SPML_ERROR("shmem error"); - } - /* exit with errro */ - SPML_ERROR("shmem error: ret = %i, send_pe = %i, dest_pe = %i", - rc, oshmem_my_proc_id(), *dst); - oshmem_shmem_abort(-1); - rc = OSHMEM_ERROR; - } -} - -static void mca_yoda_get_response_callback(mca_btl_base_module_t* btl, - mca_btl_base_tag_t tag, - mca_btl_base_descriptor_t* des, - void* cbdata ) -{ - size_t* size; - void** l_addr; - mca_spml_yoda_get_request_t* getreq; - - /* unpacking data*/ - size = (size_t *) ( ((char*)des->des_segments->seg_addr.pval) ); - l_addr = (void**)( ((char*)size) + sizeof(*size)); - getreq = (mca_spml_yoda_get_request_t*)*(void**)((char*)l_addr + sizeof(*l_addr) + *size); - - /* Complete get request*/ - OPAL_THREAD_ADD32(&getreq->parent->active_count, -1); - getreq->req_get.req_base.req_spml_complete = true; - oshmem_request_complete(&getreq->req_get.req_base.req_oshmem, 1); - oshmem_request_free((oshmem_request_t**) &getreq); - - memcpy(*l_addr, (char*)l_addr + sizeof(*l_addr), *size); -} - -/** - * note: we have to reg memory directly with btl because no proc will have a full btl list in proc_bml - */ -int mca_spml_yoda_deregister(sshmem_mkey_t *mkeys) -{ - int i; - struct yoda_btl *ybtl; - mca_spml_yoda_context_t* yoda_context; - - MCA_SPML_CALL(fence()); - mca_spml_yoda_wait_gets(); - - if (!mkeys) { - return OSHMEM_SUCCESS; - } - - for (i = 0; i < mca_spml_yoda.n_btls; i++) { - ybtl = &mca_spml_yoda.btl_type_map[i]; - yoda_context = (mca_spml_yoda_context_t*) mkeys[i].spml_context; - if (NULL == yoda_context) { - continue; - } - if (yoda_context->btl_src_descriptor) { - ybtl->btl->btl_free(ybtl->btl, yoda_context->btl_src_descriptor); - yoda_context->btl_src_descriptor = NULL; - } - if (yoda_context->registration) { - ybtl->btl->btl_deregister_mem (ybtl->btl, yoda_context->registration); - } - - } - free(mkeys); - - return OSHMEM_SUCCESS; -} - -sshmem_mkey_t *mca_spml_yoda_register(void* addr, - size_t size, - uint64_t shmid, - int *count) -{ - int i; - sshmem_mkey_t *mkeys; - struct yoda_btl *ybtl; - mca_spml_yoda_context_t* yoda_context; - - SPML_VERBOSE(10, "address %p len %llu", addr, (unsigned long long)size); - *count = 0; - /* make sure everything is initialized to 0 */ - mkeys = (sshmem_mkey_t *) calloc(1, - mca_spml_yoda.n_btls * sizeof(*mkeys)); - if (!mkeys) { - return NULL ; - } - - mca_bml.bml_register( MCA_SPML_YODA_PUT, - mca_yoda_put_callback, - NULL ); - mca_bml.bml_register( MCA_SPML_YODA_GET, - mca_yoda_get_callback, - NULL ); - mca_bml.bml_register( MCA_SPML_YODA_GET_RESPONSE, - mca_yoda_get_response_callback, - NULL ); - /* Register proc memory in every rdma BTL. */ - for (i = 0; i < mca_spml_yoda.n_btls; i++) { - - ybtl = &mca_spml_yoda.btl_type_map[i]; - mkeys[i].va_base = addr; - mkeys[i].u.key = MAP_SEGMENT_SHM_INVALID; - - if (!ybtl->use_cnt) { - SPML_VERBOSE(10, - "%s: present but not in use. SKIP registration", - btl_type2str(ybtl->btl_type)); - continue; - } - - /* If we have shared memory just save its id */ - if ((YODA_BTL_SM == ybtl->btl_type || YODA_BTL_VADER == ybtl->btl_type) - && MAP_SEGMENT_SHM_INVALID != (int)shmid) { - mkeys[i].u.key = shmid; - mkeys[i].va_base = 0; - continue; - } - - yoda_context = calloc(1, sizeof(*yoda_context)); - mkeys[i].spml_context = yoda_context; - - yoda_context->registration = NULL; - if (ybtl->btl->btl_flags & MCA_BTL_FLAGS_RDMA) { - if (NULL != ybtl->btl->btl_register_mem) { - yoda_context->registration = ybtl->btl->btl_register_mem (ybtl->btl, MCA_BTL_ENDPOINT_ANY, - addr, size, MCA_BTL_REG_FLAG_ACCESS_ANY); - if (NULL == yoda_context->registration) { - SPML_ERROR("%s: failed to register source memory: addr: %p, size: %u", - btl_type2str(ybtl->btl_type), addr, size); - /* FIXME some cleanup might be needed here - * yoda_context->btl_src_descriptor = NULL; - * *count = ???; - * free(spml_context); - */ - free(mkeys); - return NULL; - } - } - - yoda_context->btl_src_descriptor = NULL; - mkeys[i].u.data = yoda_context->registration; - mkeys[i].len = yoda_context->registration ? ybtl->btl->btl_registration_handle_size : 0; - } - - SPML_VERBOSE(5, - "rank %d btl %s va_base: 0x%p len: %d key %llx size %llu", - oshmem_proc_pe(oshmem_proc_local()), btl_type2str(ybtl->btl_type), - mkeys[i].va_base, mkeys[i].len, (unsigned long long)mkeys[i].u.key, (unsigned long long)size); - } - *count = mca_spml_yoda.n_btls; - return mkeys; -} - -/* - * For each proc setup a datastructure that indicates the BTLs - * that can be used to reach the destination. - */ -static void mca_spml_yoda_error_handler(struct mca_btl_base_module_t* btl, - int32_t flags, - opal_proc_t* errproc, - char* btlinfo) -{ - oshmem_shmem_abort(-1); -} - -/* make global btl list&map */ -static int create_btl_list(void) -{ - int btl_type; - char *btl_name; - int size; - opal_list_item_t *item; - mca_btl_base_selected_module_t *btl_sm; - int i; - - size = opal_list_get_size(&mca_btl_base_modules_initialized); - if (0 >= size) { - SPML_ERROR("no btl(s) available"); - return OSHMEM_ERROR; - } - SPML_VERBOSE(50, "found %d capable btls", size); - - mca_spml_yoda.btl_type_map = - (struct yoda_btl *) calloc(size, sizeof(struct yoda_btl)); - if (!mca_spml_yoda.btl_type_map) - return OSHMEM_ERROR; - - mca_spml_yoda.n_btls = 0; - for (i = 0, item = opal_list_get_first(&mca_btl_base_modules_initialized); - item != opal_list_get_end(&mca_btl_base_modules_initialized); - item = opal_list_get_next(item), i++) { - - btl_sm = (mca_btl_base_selected_module_t *) item; - btl_name = btl_sm->btl_component->btl_version.mca_component_name; - btl_type = btl_name_to_id(btl_name); - - SPML_VERBOSE(50, "found btl (%s) btl_type=%s", btl_name, btl_type2str(btl_type)); - - /* Note: we setup bml_btl in create_btl_idx() */ - mca_spml_yoda.btl_type_map[mca_spml_yoda.n_btls].bml_btl = NULL; - mca_spml_yoda.btl_type_map[mca_spml_yoda.n_btls].btl = - btl_sm->btl_module; - mca_spml_yoda.btl_type_map[mca_spml_yoda.n_btls].btl_type = btl_type; - mca_spml_yoda.n_btls++; - } - - if (0 == mca_spml_yoda.n_btls) { - SPML_ERROR("can not find any suitable btl"); - return OSHMEM_ERROR; - } - - return OSHMEM_SUCCESS; -} - -static int _find_btl_id(mca_bml_base_btl_t *bml_btl) -{ - int i; - - for (i = 0; i < mca_spml_yoda.n_btls; i++) { - if (mca_spml_yoda.btl_type_map[i].btl == bml_btl->btl) - return i; - } - return -1; -} - -/* for each proc create transport ids which are indexes into global - * btl list&map - */ -static int create_btl_idx(int dst_pe) -{ - ompi_proc_t *proc; - int btl_id; - mca_bml_base_endpoint_t* endpoint; - mca_bml_base_btl_t* bml_btl = 0; - int i, size; - mca_bml_base_btl_array_t *btl_array; - int shmem_index = -1; - - proc = oshmem_proc_group_find(oshmem_group_all, dst_pe); - endpoint = (mca_bml_base_endpoint_t*) proc->proc_endpoints[OMPI_PROC_ENDPOINT_TAG_BML]; - assert(endpoint); - size = mca_bml_base_btl_array_get_size(btl_array = &endpoint->btl_rdma); - - if (0 >= size) { - /* Possibly this is SM BTL with KNEM disabled? Then we should use send based get/put */ - /* - This hack is necessary for the case when KNEM is not available. - In this case we still want to use send/recv of SM BTL for put and get - but SM BTL is not in the rdma list anymore - */ - size = mca_bml_base_btl_array_get_size(btl_array = - &endpoint->btl_eager); - if (0 < size) { - /*Chose SHMEM capable btl from eager array. Not filter now: take the first - (but could appear on demand).*/ - shmem_index = 0; - size = 1; - } - else { - SPML_ERROR("no SHMEM capable transport for dest pe=%d", dst_pe); - return OSHMEM_ERROR; - } - } - - OSHMEM_PROC_DATA(proc)->transport_ids = (char *) malloc(size * sizeof(char)); - if (NULL == OSHMEM_PROC_DATA(proc)->transport_ids) - return OSHMEM_ERROR; - - OSHMEM_PROC_DATA(proc)->num_transports = size; - - for (i = 0; i < size; i++) { - bml_btl = mca_bml_base_btl_array_get_index(btl_array, - (shmem_index >= 0) ? - (shmem_index) : (i)); - btl_id = _find_btl_id(bml_btl); - SPML_VERBOSE(50, - "dst_pe(%d) use btl (%s) btl_id=%d", - dst_pe, bml_btl->btl->btl_component->btl_version.mca_component_name, btl_id); - if (0 > btl_id) { - SPML_ERROR("unknown btl: dst_pe(%d) use btl (%s) btl_id=%d", - dst_pe, bml_btl->btl->btl_component->btl_version.mca_component_name, btl_id); - return OSHMEM_ERROR; - } - OSHMEM_PROC_DATA(proc)->transport_ids[i] = btl_id; - mca_spml_yoda.btl_type_map[btl_id].bml_btl = bml_btl; - mca_spml_yoda.btl_type_map[btl_id].use_cnt++; - } - return OSHMEM_SUCCESS; -} - -static int destroy_btl_list(void) -{ - if (mca_spml_yoda.btl_type_map) { - free(mca_spml_yoda.btl_type_map); - } - - return OSHMEM_SUCCESS; -} - -static int destroy_btl_idx(int dst_pe) -{ - ompi_proc_t *proc; - - proc = oshmem_proc_group_find(oshmem_group_all, dst_pe); - if (NULL != OSHMEM_PROC_DATA(proc)->transport_ids) { - free(OSHMEM_PROC_DATA(proc)->transport_ids); - } - - return OSHMEM_SUCCESS; -} - -int mca_spml_yoda_add_procs(ompi_proc_t** procs, size_t nprocs) -{ - opal_bitmap_t reachable; - int rc; - size_t i; - - if (0 == nprocs) { - return OSHMEM_SUCCESS; - } - - OBJ_CONSTRUCT(&reachable, opal_bitmap_t); - rc = opal_bitmap_init(&reachable, (int) nprocs); - if (OSHMEM_SUCCESS != rc) { - return rc; - } - - rc = mca_bml.bml_register_error(mca_spml_yoda_error_handler); - if (OMPI_SUCCESS != rc) { - goto cleanup_and_return; - } - - /* create_btl_idx requires the proc was add_proc'ed, so do it now */ - rc = MCA_PML_CALL(add_procs(procs, nprocs)); - if (OMPI_SUCCESS != rc) { - goto cleanup_and_return; - } - - /* create btl index and map */ - rc = create_btl_list(); - if (OSHMEM_SUCCESS != rc) { - goto cleanup_and_return; - } - - for (i = 0; i < nprocs; i++) { - rc = create_btl_idx(i); - if (OSHMEM_SUCCESS != rc) { - goto cleanup_and_return; - } - } - -cleanup_and_return: - OBJ_DESTRUCT(&reachable); - - return rc; -} - -int mca_spml_yoda_del_procs(ompi_proc_t** procs, size_t nprocs) -{ - size_t i; - - for (i = 0; i < nprocs; i++) { - destroy_btl_idx(i); - } - destroy_btl_list(); - - return OSHMEM_SUCCESS; -} - -static inline mca_bml_base_btl_t *get_next_btl(int dst, int *btl_id) -{ - mca_bml_base_endpoint_t* endpoint; - mca_bml_base_btl_t* bml_btl = NULL; - ompi_proc_t *proc; - mca_bml_base_btl_array_t *btl_array = 0; - int shmem_index = -1; - int size = 0; - - /* get endpoint and btl */ - proc = oshmem_proc_group_all(dst); - if (!proc) { - SPML_ERROR("Can not find destination proc for pe=%d", dst); - return NULL ; - } - - endpoint = (mca_bml_base_endpoint_t*) proc->proc_endpoints[OMPI_PROC_ENDPOINT_TAG_BML]; - if (!endpoint) { - SPML_ERROR("pe=%d proc has no endpoint", dst); - return NULL ; - } - - /* At the moment always return first transport */ - size = mca_bml_base_btl_array_get_size(btl_array = &endpoint->btl_rdma); - - if (0 >= size) { - /* Possibly this is SM BTL with KNEM disabled? Then we should use send based get/put */ - /* - This hack is necessary for the case when KNEM is not available. - In this case we still want to use send/recv of SM BTL for put and get - but SM BTL is not in the rdma list anymore - */ - size = mca_bml_base_btl_array_get_size(btl_array = - &endpoint->btl_eager); - } - if (0 < size) { - shmem_index = 0; - bml_btl = mca_bml_base_btl_array_get_index(btl_array, shmem_index); - } - - *btl_id = OSHMEM_PROC_DATA(proc)->transport_ids[0]; - -#if SPML_YODA_DEBUG == 1 - assert(*btl_id >= 0 && *btl_id < YODA_BTL_MAX); - SPML_VERBOSE(100, "pe=%d reachable via btl %s %d", dst, - bml_btl->btl->btl_component->btl_version.mca_component_name, *btl_id); -#endif - return bml_btl; -} - -static inline int mca_spml_yoda_put_internal(void *dst_addr, - size_t size, - void *src_addr, - int dst, - int is_nb) -{ - int rc = OSHMEM_SUCCESS; - mca_spml_yoda_put_request_t *putreq = NULL; - mca_bml_base_btl_t* bml_btl; - mca_btl_base_descriptor_t* des = NULL; - mca_btl_base_segment_t* segment; - mca_spml_yoda_rdma_frag_t* frag; - int nfrags; - int i; - unsigned ncopied = 0; - unsigned int frag_size = 0; - char *p_src, *p_dst; - void* rva; - sshmem_mkey_t *r_mkey; - int btl_id = 0; - struct yoda_btl *ybtl; - int put_via_send; - mca_btl_base_registration_handle_t *local_handle = NULL, *remote_handle = NULL; - - /* If nothing to put its OK.*/ - if (0 >= size) { - return OSHMEM_SUCCESS; - } - - /* Find bml_btl and its global btl_id */ - bml_btl = get_next_btl(dst, &btl_id); - if (!bml_btl) { - SPML_ERROR("cannot reach %d pe: no appropriate btl found", oshmem_my_proc_id()); - rc = OSHMEM_ERR_FATAL; - goto exit_fatal; - } - /* Check if btl has PUT method. If it doesn't - use SEND*/ - put_via_send = !(bml_btl->btl->btl_flags & MCA_BTL_FLAGS_PUT); - - /* Get rkey of remote PE (dst proc) which must be on memheap*/ - r_mkey = mca_memheap_base_get_cached_mkey(dst, dst_addr, btl_id, &rva); - if (!r_mkey) { - SPML_ERROR("pe=%d: %p is not address of shared variable", - dst, dst_addr); - rc = OSHMEM_ERR_FATAL; - goto exit_fatal; - } - -#if SPML_YODA_DEBUG == 1 - SPML_VERBOSE(100, "put: pe:%d dst=%p <- src: %p sz=%d. dst_rva=%p, %s", - dst, dst_addr, src_addr, (int)size, (void *)rva, mca_spml_base_mkey2str(r_mkey)); -#endif - - ybtl = &mca_spml_yoda.btl_type_map[btl_id]; - - if (ybtl->btl->btl_register_mem) { - assert (r_mkey->len == ybtl->btl->btl_registration_handle_size); - remote_handle = (mca_btl_base_registration_handle_t *) r_mkey->u.data; - } - - /* check if we doing put into shm attached segment and if so - * just do memcpy - */ - if ((YODA_BTL_SM == ybtl->btl_type || YODA_BTL_VADER == ybtl->btl_type) - && mca_memheap_base_can_local_copy(r_mkey, dst_addr)) { - memcpy((void *) (unsigned long) rva, src_addr, size); - return OSHMEM_SUCCESS; - } - - /* We support only blocking PUT now => we always need copy for src buffer*/ - calc_nfrags_put (bml_btl, size, &frag_size, &nfrags, put_via_send); - - p_src = (char*) src_addr; - p_dst = (char*) (unsigned long) rva; - for (i = 0; i < nfrags; i++) { - /* Allocating send request from free list */ - putreq = mca_spml_yoda_putreq_alloc(dst); - frag = &putreq->put_frag; - ncopied = i < nfrags - 1 ? frag_size :(unsigned) ((char *) src_addr + size - p_src); - - /* Preparing source buffer */ - - /* allocate buffer */ - mca_spml_yoda_bml_alloc(bml_btl, - &des, - MCA_BTL_NO_ORDER, - ncopied, - MCA_BTL_DES_SEND_ALWAYS_CALLBACK, - put_via_send); - - if (OPAL_UNLIKELY(!des || !des->des_segments )) { - SPML_ERROR("src=%p nfrags = %d frag_size=%d", - src_addr, nfrags, frag_size); - SPML_ERROR("shmem OOM error need %d bytes", ncopied); - opal_show_help("help-oshmem-spml-yoda.txt", - "internal_oom_error", - true, - "Put", ncopied, mca_spml_yoda.bml_alloc_threshold); - rc = OSHMEM_ERR_FATAL; - goto exit_fatal; - } - - /* copy data to allocated buffer*/ - segment = des->des_segments; - spml_yoda_prepare_for_put((void*)segment->seg_addr.pval, ncopied, - (void*)p_src, (void*)p_dst, put_via_send); - - if (!put_via_send && ybtl->btl->btl_register_mem) { - local_handle = ybtl->btl->btl_register_mem (ybtl->btl, bml_btl->btl_endpoint, - segment->seg_addr.pval, ncopied, 0); - if (NULL == local_handle) { - /* No free resources, Block on completion here */ - SPML_ERROR("shmem error: OSHMEM_ERR_OUT_OF_RESOURCE"); - oshmem_request_wait_completion(&putreq->req_put.req_base.req_oshmem); - } - } - - frag->rdma_segs[0].base_seg.seg_addr.lval = (uintptr_t) p_dst; - frag->rdma_segs[0].base_seg.seg_len = (put_via_send ? - ncopied + SPML_YODA_SEND_CONTEXT_SIZE : - ncopied); - frag->rdma_req = putreq; - - /* initialize callback data for put*/ - des->des_cbdata = frag; - des->des_cbfunc = mca_spml_yoda_put_completion; - - OPAL_THREAD_ADD32(&mca_spml_yoda.n_active_puts, 1); - /* put the data to remote side */ - if (!put_via_send) { - rc = mca_bml_base_put (bml_btl, segment->seg_addr.pval, (uint64_t) (intptr_t) p_dst, - local_handle, remote_handle, ncopied, 0, 0, mca_spml_yoda_put_completion_rdma, - des); - } else { - rc = mca_bml_base_send(bml_btl, des, MCA_SPML_YODA_PUT); - if (1 == rc) - rc = OSHMEM_SUCCESS; - } - - if (OPAL_UNLIKELY(OSHMEM_SUCCESS != rc)) { - if (OSHMEM_ERR_OUT_OF_RESOURCE == rc) { - /* No free resources, Block on completion here */ - SPML_ERROR("shmem error: OSHMEM_ERR_OUT_OF_RESOURCE"); - oshmem_request_wait_completion(&putreq->req_put.req_base.req_oshmem); - } else { - SPML_ERROR("shmem error"); - } - /* exit with errro */ - SPML_ERROR("shmem error: ret = %i, send_pe = %i, dest_pe = %i", - rc, oshmem_my_proc_id(), dst); - rc = OSHMEM_ERR_FATAL; - goto exit_fatal; - } - p_src += ncopied; - p_dst += ncopied; - } - - return rc; - -exit_fatal: - if (OSHMEM_SUCCESS != rc) { - oshmem_shmem_abort(rc); - } - return rc; -} - -int mca_spml_yoda_put(void *dst_addr, size_t size, void *src_addr, int dst) -{ - return mca_spml_yoda_put_internal(dst_addr, size, src_addr, dst, 0); -} - -int mca_spml_yoda_put_nb(void* dst_addr, - size_t size, - void* src_addr, - int dst, - void **handle) -{ - UNREFERENCED_PARAMETER(handle); - - /* TODO: real nonblocking operation is needed - */ - return mca_spml_yoda_put_internal(dst_addr, size, src_addr, dst, 1); -} - -int mca_spml_yoda_fence(void) -{ - return mca_spml_yoda_fence_internal(0); -} - -int mca_spml_yoda_wait_gets(void) -{ - - while (0 < mca_spml_yoda.n_active_gets) { - opal_progress(); - } - return OSHMEM_SUCCESS; -} - - -int mca_spml_yoda_enable(bool enable) -{ - SPML_VERBOSE(50, "*** yoda ENABLED ****"); - if (false == enable) { - return OSHMEM_SUCCESS; - } - - OBJ_CONSTRUCT(&mca_spml_yoda.lock, opal_mutex_t); - - /** - *If we get here this is the SPML who get selected for the run. We - * should get ownership for the put and get requests list, and - * initialize them with the size of our own requests. - */ - - opal_free_list_init (&mca_spml_base_put_requests, - sizeof(mca_spml_yoda_put_request_t), - opal_cache_line_size, - OBJ_CLASS(mca_spml_yoda_put_request_t), - 0, - opal_cache_line_size, - mca_spml_yoda.free_list_num, - mca_spml_yoda.free_list_max, - mca_spml_yoda.free_list_inc, - NULL, 0, NULL, NULL, NULL); - - opal_free_list_init (&mca_spml_base_get_requests, - sizeof(mca_spml_yoda_get_request_t), - opal_cache_line_size, - OBJ_CLASS(mca_spml_yoda_get_request_t), - 0, - opal_cache_line_size, - mca_spml_yoda.free_list_num, - mca_spml_yoda.free_list_max, - mca_spml_yoda.free_list_inc, - NULL, 0, NULL, NULL, NULL); - - mca_spml_yoda.enabled = true; - - /* The following line resolves the issue with BTL tcp and SPML yoda. In this case the - * atomic_basic_lock(root_rank) function may behave as DoS attack on root_rank, since - * all the procceses will do shmem_int_get from root_rank. These calls would go through - * bml active messaging and will trigger replays in libevent on root rank. If the flag - * OPAL_ENVLOOP_ONCE is not set then libevent will continously progress constantly - * incoming events thus causing root_rank to stuck in libevent loop. - */ - opal_progress_set_event_flag(OPAL_EVLOOP_NONBLOCK | OPAL_EVLOOP_ONCE); - -#if OSHMEM_WAIT_COMPLETION_DEBUG == 1 - condition_dbg_init(); -#endif - - return OSHMEM_SUCCESS; -} - -int mca_spml_yoda_get_nb(void* src_addr, - size_t size, - void* dst_addr, - int src, - void **handle) -{ - /* TODO: real nonblocking operation is needed - */ - return mca_spml_yoda_get(src_addr, size, dst_addr, src); -} - -/** - * shmem_get reads data from a remote address - * in the symmetric heap via RDMA READ. - * Get operation: - * 1. Get the rkey to the remote address. - * 2. Allocate a get request. - * 3. Allocated a temporary pre-registered buffer - * to copy the data to. - * 4. Init the request descriptor with remote side - * data and local side data. - * 5. Read the remote buffer to a pre-registered - * buffer on the local PE using RDMA READ. - * 6. Copy the received data to dst_addr if an - * intermediate pre-register buffer was used. - * 7. Clear the request and return. - * - * src_addr - address on remote pe. - * size - the amount on bytes to be read. - * dst_addr - address on the local pe. - * src - the pe of remote process. - */ -int mca_spml_yoda_get(void* src_addr, size_t size, void* dst_addr, int src) -{ - int rc = OSHMEM_SUCCESS; - sshmem_mkey_t *r_mkey, *l_mkey; - void* rva; - unsigned ncopied = 0; - unsigned int frag_size = 0; - char *p_src, *p_dst; - int i; - int nfrags; - mca_bml_base_btl_t* bml_btl = NULL; - mca_btl_base_segment_t* segment; - mca_btl_base_descriptor_t* des = NULL; - mca_spml_yoda_rdma_frag_t* frag = NULL; - struct mca_spml_yoda_getreq_parent get_holder; - struct yoda_btl *ybtl; - int btl_id = 0; - int get_via_send; - mca_btl_base_registration_handle_t *local_handle, *remote_handle = NULL; - mca_spml_yoda_get_request_t* getreq = NULL; - - /*If nothing to get its OK.*/ - if (0 >= size) { - return rc; - } - - /* Find bml_btl and its global btl_id */ - bml_btl = get_next_btl(src, &btl_id); - if (!bml_btl) { - SPML_ERROR("cannot reach %d pe: no appropriate btl found", oshmem_my_proc_id()); - rc = OSHMEM_ERR_FATAL; - goto exit_fatal; - } - /* Check if btl has GET method. If it doesn't - use SEND*/ - get_via_send = ! ( (bml_btl->btl->btl_flags & (MCA_BTL_FLAGS_GET)) && - (bml_btl->btl->btl_flags & (MCA_BTL_FLAGS_PUT)) ); - - /* Get rkey of remote PE (src proc) which must be on memheap*/ - r_mkey = mca_memheap_base_get_cached_mkey(src, src_addr, btl_id, &rva); - if (!r_mkey) { - SPML_ERROR("pe=%d: %p is not address of shared variable", - src, src_addr); - rc = OSHMEM_ERR_FATAL; - goto exit_fatal; - } - -#if SPML_YODA_DEBUG == 1 - SPML_VERBOSE(100, "get: pe:%d src=%p -> dst: %p sz=%d. src_rva=%p, %s", - src, src_addr, dst_addr, (int)size, (void *)rva, mca_spml_base_mkey2str(r_mkey)); -#endif - - ybtl = &mca_spml_yoda.btl_type_map[btl_id]; - - if (ybtl->btl->btl_register_mem) { - assert(ybtl->btl->btl_registration_handle_size == r_mkey->len); - remote_handle = (mca_btl_base_registration_handle_t *) r_mkey->u.data; - } - - nfrags = 1; - - /* check if we doing get into shm attached segment and if so - * just do memcpy - */ - if ((YODA_BTL_SM == ybtl->btl_type || YODA_BTL_VADER == ybtl->btl_type) - && mca_memheap_base_can_local_copy(r_mkey, src_addr)) { - memcpy(dst_addr, (void *) rva, size); - /* must call progress here to avoid deadlock. Scenarion: - * pe1 pols pe2 via shm get. pe2 tries to get static variable from node one, which goes to sm btl - * In this case pe2 is stuck forever because pe1 never calls opal_progress. - * May be we do not need to call progress on every get() here but rather once in a while. - */ - opal_progress(); - return OSHMEM_SUCCESS; - } - - l_mkey = mca_memheap.memheap_get_local_mkey(dst_addr, - btl_id); - /* - * Need a copy if local memory has not been registered or - * we make GET via SEND - */ - frag_size = ncopied; - if ((NULL == l_mkey) || get_via_send) { - calc_nfrags_get (bml_btl, size, &frag_size, &nfrags, get_via_send); - } - - p_src = (char*) (unsigned long) rva; - p_dst = (char*) dst_addr; - get_holder.active_count = 0; - - for (i = 0; i < nfrags; i++) { - /** - * Allocating a get request from a pre-allocated - * and pre-registered free list. - */ - getreq = mca_spml_yoda_getreq_alloc(src); - assert(getreq); - getreq->p_dst = NULL; - frag = &getreq->get_frag; - getreq->parent = &get_holder; - - ncopied = i < nfrags - 1 ? frag_size :(unsigned) ((char *) dst_addr + size - p_dst); - frag->allocated = 0; - /* Prepare destination descriptor*/ - memcpy(&frag->rdma_segs[0].base_seg, - r_mkey->u.data, - r_mkey->len); - - frag->rdma_segs[0].base_seg.seg_len = (get_via_send ? ncopied + SPML_YODA_SEND_CONTEXT_SIZE : ncopied); - if (get_via_send) { - frag->use_send = 1; - frag->allocated = 1; - /** - * Allocate a temporary buffer on the local PE. - * The local buffer will store the data read - * from the remote address. - */ - mca_spml_yoda_bml_alloc(bml_btl, - &des, - MCA_BTL_NO_ORDER, - (int)frag_size, - MCA_BTL_DES_SEND_ALWAYS_CALLBACK, - get_via_send); - if (OPAL_UNLIKELY(!des || !des->des_segments)) { - SPML_ERROR("shmem OOM error need %d bytes", ncopied); - SPML_ERROR("src=%p nfrags = %d frag_size=%d", - src_addr, nfrags, frag_size); - rc = OSHMEM_ERR_FATAL; - goto exit_fatal; - } - - segment = des->des_segments; - spml_yoda_prepare_for_get((void*)segment->seg_addr.pval, ncopied, (void*)p_src, oshmem_my_proc_id(), (void*)p_dst, (void*) getreq); - des->des_cbfunc = mca_spml_yoda_get_response_completion; - des->des_cbdata = frag; - - OPAL_THREAD_ADD32(&mca_spml_yoda.n_active_gets, 1); - } - else { - /* - * Register src memory if do GET via GET - */ - if (NULL == l_mkey && ybtl->btl->btl_register_mem) { - local_handle = ybtl->btl->btl_register_mem (ybtl->btl, bml_btl->btl_endpoint, p_dst, ncopied, - MCA_BTL_REG_FLAG_LOCAL_WRITE); - - if (NULL == local_handle) { - SPML_ERROR("%s: failed to register destination memory %p.", - btl_type2str(ybtl->btl_type), p_dst); - } - - frag->local_handle = local_handle; - } else if (NULL == l_mkey) { - local_handle = NULL; - frag->local_handle = NULL; - } else { - local_handle = ((mca_spml_yoda_context_t*)l_mkey->spml_context)->registration; - frag->local_handle = NULL; - } - - frag->rdma_segs[0].base_seg.seg_addr.lval = (uintptr_t) p_src; - getreq->p_dst = (uint64_t*) p_dst; - frag->size = ncopied; - - OPAL_THREAD_ADD32(&mca_spml_yoda.n_active_gets, 1); - } - - /** - * Initialize the remote data fragment - * with remote address data required for - * executing RDMA READ from a remote buffer. - */ - - frag->rdma_req = getreq; - - /** - * Do GET operation - */ - if (get_via_send) { - rc = mca_bml_base_send(bml_btl, des, MCA_SPML_YODA_GET); - if (1 == rc) - rc = OSHMEM_SUCCESS; - } else { - rc = mca_bml_base_get(bml_btl, p_dst, (uint64_t) (intptr_t) p_src, local_handle, - remote_handle, ncopied, 0, 0, mca_spml_yoda_get_completion, frag); - } - - if (OPAL_UNLIKELY(OSHMEM_SUCCESS != rc)) { - if (OSHMEM_ERR_OUT_OF_RESOURCE == rc) { - /* No free resources, Block on completion here */ - oshmem_request_wait_completion(&getreq->req_get.req_base.req_oshmem); - return OSHMEM_SUCCESS; - } else { - SPML_ERROR("oshmem_get: error %d", rc); - goto exit_fatal; - } - } - p_dst += ncopied; - p_src += ncopied; - OPAL_THREAD_ADD32(&get_holder.active_count, 1); - } - - /* revisit if we really need this for self and sm */ - /* if (YODA_BTL_SELF == ybtl->btl_type) */ - opal_progress(); - - /* Wait for completion on request */ - while (get_holder.active_count > 0) - oshmem_request_wait_completion(&getreq->req_get.req_base.req_oshmem); - - return rc; - -exit_fatal: - if (OSHMEM_SUCCESS != rc) { - oshmem_shmem_abort(rc); - } - return rc; -} - -int mca_spml_yoda_send(void* buf, - size_t size, - int dst, - mca_spml_base_put_mode_t sendmode) -{ - int rc = OSHMEM_SUCCESS; - - rc = MCA_PML_CALL(send(buf, - size, - &(ompi_mpi_unsigned_char.dt), - dst, - 0, - (mca_pml_base_send_mode_t)sendmode, - &(ompi_mpi_comm_world.comm))); - - return rc; -} - -int mca_spml_yoda_recv(void* buf, size_t size, int src) -{ - int rc = OSHMEM_SUCCESS; - - rc = MCA_PML_CALL(recv(buf, - size, - &(ompi_mpi_unsigned_char.dt), - src, - 0, - &(ompi_mpi_comm_world.comm), - NULL)); - - return rc; -} - diff --git a/oshmem/mca/spml/yoda/spml_yoda.h b/oshmem/mca/spml/yoda/spml_yoda.h deleted file mode 100644 index 13c6cac4e5..0000000000 --- a/oshmem/mca/spml/yoda/spml_yoda.h +++ /dev/null @@ -1,150 +0,0 @@ -/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ -/* - * Copyright (c) 2013 Mellanox Technologies, Inc. - * All rights reserved. - * Copyright (c) 2015 Los Alamos National Security, LLC. All rights - * reserved. - * Copyright (c) 2016 Research Organization for Information Science - * and Technology (RIST). All rights reserved. - * $COPYRIGHT$ - * - * Additional copyrights may follow - * - * $HEADER$ - */ -/** - * @file - */ - -#ifndef MCA_SPML_YODA_H -#define MCA_SPML_YODA_H - -#include "oshmem_config.h" -#include "oshmem/request/request.h" -#include "oshmem/mca/spml/spml.h" -#include "oshmem/util/oshmem_util.h" -#include "oshmem/mca/spml/base/spml_base_putreq.h" -#include "oshmem/proc/proc.h" -#include "oshmem/mca/spml/base/spml_base_request.h" -#include "oshmem/mca/spml/base/spml_base_getreq.h" - -#include "orte/runtime/orte_globals.h" - -#include "ompi/mca/bml/base/base.h" -#include "opal/mca/btl/btl.h" -#include "opal/class/opal_free_list.h" - -/* Turn ON/OFF debug output from build (default 0) */ -#ifndef OSHMEM_WAIT_COMPLETION_DEBUG -#define OSHMEM_WAIT_COMPLETION_DEBUG 0 -#endif - -#define MCA_SPML_YODA_PUT (MCA_BTL_TAG_USR + 0x0A) -#define MCA_SPML_YODA_GET (MCA_BTL_TAG_USR + 0x0B) -#define MCA_SPML_YODA_GET_RESPONSE (MCA_BTL_TAG_USR + 0x0C) - -#define SPML_YODA_SEND_CONTEXT_SIZE (sizeof(size_t) + 3*sizeof(void*) + sizeof(int)) -BEGIN_C_DECLS - -/** - * YODA SPML module - */ - -enum { - YODA_BTL_UNKNOWN = -1, - YODA_BTL_SELF = 0, - YODA_BTL_SM, - YODA_BTL_OPENIB, - YODA_BTL_VADER, - YODA_BTL_UGNI, - YODA_BTL_MAX -}; - -struct yoda_btl { - mca_btl_base_module_t *btl; - mca_bml_base_btl_t *bml_btl; - int btl_type; - int use_cnt; -}; - -struct mca_spml_yoda_t { - mca_spml_base_module_t super; - - int priority; - int free_list_num; /* initial size of free list */ - int free_list_max; /* maximum size of free list */ - int free_list_inc; /* number of elements to grow free list */ - int bml_alloc_threshold; /* number of puts to wait - in case of put/get temporary buffer allocation failture */ - - /* lock queue access */ - opal_mutex_t lock; - - /* free lists */ - opal_free_list_t rdma_frags; - /* number of outstanding put requests */ - int32_t n_active_puts; - int32_t n_active_gets; - bool enabled; - struct yoda_btl *btl_type_map; - int n_btls; -}; -typedef struct mca_spml_yoda_t mca_spml_yoda_module_t; - -struct mca_spml_yoda_context_t { - mca_btl_base_descriptor_t* btl_src_descriptor; - mca_btl_base_registration_handle_t *registration; -}; -typedef struct mca_spml_yoda_context_t mca_spml_yoda_context_t; - -extern mca_spml_yoda_module_t mca_spml_yoda; - -extern int mca_spml_yoda_enable(bool enable); -extern int mca_spml_yoda_get(void* dst_addr, - size_t size, - void* src_addr, - int src); -extern int mca_spml_yoda_get_nb(void* dst_addr, - size_t size, - void* src_addr, - int dst, - void **handle); -extern int mca_spml_yoda_put(void* dst_addr, - size_t size, - void* src_addr, - int dst); -extern int mca_spml_yoda_put_nb(void* dst_addr, - size_t size, - void* src_addr, - int dst, - void **handle); -extern int mca_spml_yoda_recv(void* buf, size_t size, int src); -extern int mca_spml_yoda_send(void* buf, - size_t size, - int dst, - mca_spml_base_put_mode_t mode); -extern sshmem_mkey_t *mca_spml_yoda_register(void* addr, - size_t size, - uint64_t shmid, - int *count); -extern int mca_spml_yoda_deregister(sshmem_mkey_t *mkeys); -extern int mca_spml_yoda_add_procs(ompi_proc_t** procs, - size_t nprocs); -extern int mca_spml_yoda_del_procs(ompi_proc_t** procs, - size_t nprocs); -extern int mca_spml_yoda_fence(void); -extern void* mca_spml_yoda_get_remote_context(void*); -extern void mca_spml_yoda_set_remote_context(void**, void*); -extern int mca_spml_yoda_get_remote_context_size(void*); -extern void mca_spml_yoda_set_remote_context_size(void**, int); -extern int mca_spml_yoda_wait_gets(void); - -#if OSHMEM_WAIT_COMPLETION_DEBUG == 1 -extern void condition_dbg_init(void); -extern void condition_dbg_finalize(void); -#endif - -END_C_DECLS - -#endif - diff --git a/oshmem/mca/spml/yoda/spml_yoda_component.c b/oshmem/mca/spml/yoda/spml_yoda_component.c deleted file mode 100644 index 26f67fbc39..0000000000 --- a/oshmem/mca/spml/yoda/spml_yoda_component.c +++ /dev/null @@ -1,140 +0,0 @@ -/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ -/* - * Copyright (c) 2013 Mellanox Technologies, Inc. - * All rights reserved. - * Copyright (c) 2015 Los Alamos National Security, LLC. All rights - * reserved. - * $COPYRIGHT$ - * - * Additional copyrights may follow - * - * $HEADER$ - */ - -#include "oshmem_config.h" -#include "oshmem/runtime/params.h" -#include "oshmem/mca/spml/spml.h" -#include "spml_yoda_component.h" -#include "oshmem/mca/spml/yoda/spml_yoda_rdmafrag.h" -#include "oshmem/mca/spml/yoda/spml_yoda_putreq.h" -#include "oshmem/mca/spml/yoda/spml_yoda.h" - -static int mca_spml_yoda_component_register(void); -static int mca_spml_yoda_component_open(void); -static int mca_spml_yoda_component_close(void); -static mca_spml_base_module_t* -mca_spml_yoda_component_init(int* priority, - bool enable_progress_threads, - bool enable_mpi_threads); -static int mca_spml_yoda_component_fini(void); - -mca_spml_base_component_2_0_0_t mca_spml_yoda_component = { - - /* First, the mca_base_component_t struct containing meta - information about the component itself */ - - .spmlm_version = { - MCA_SPML_BASE_VERSION_2_0_0, - - .mca_component_name = "yoda", - MCA_BASE_MAKE_VERSION(component, OSHMEM_MAJOR_VERSION, OSHMEM_MINOR_VERSION, - OSHMEM_RELEASE_VERSION), - .mca_open_component = mca_spml_yoda_component_open, - .mca_close_component = mca_spml_yoda_component_close, - .mca_register_component_params = mca_spml_yoda_component_register, - }, - .spmlm_data = { - /* The component is checkpoint ready */ - MCA_BASE_METADATA_PARAM_CHECKPOINT - }, - - .spmlm_init = mca_spml_yoda_component_init, - .spmlm_finalize = mca_spml_yoda_component_fini, -}; - -static inline void mca_spml_yoda_param_register_int(const char *param_name, - int default_value, - const char *help_msg, - int *storage) -{ - *storage = default_value; - (void) mca_base_component_var_register(&mca_spml_yoda_component.spmlm_version, - param_name, - help_msg, - MCA_BASE_VAR_TYPE_INT, NULL, 0, MCA_BASE_VAR_FLAG_SETTABLE, - OPAL_INFO_LVL_9, - MCA_BASE_VAR_SCOPE_READONLY, - storage); -} - -static int mca_spml_yoda_component_register(void) -{ - mca_spml_yoda_param_register_int("free_list_num", 1024, - 0, - &mca_spml_yoda.free_list_num); - mca_spml_yoda_param_register_int("free_list_max", 1024, - 0, - &mca_spml_yoda.free_list_max); - mca_spml_yoda_param_register_int("free_list_inc", 16, - 0, - &mca_spml_yoda.free_list_inc); - mca_spml_yoda_param_register_int("bml_alloc_threshold", 3, - "number of puts to wait \ - in case of put/get temporary buffer \ - allocation failture", - &mca_spml_yoda.bml_alloc_threshold); - mca_spml_yoda_param_register_int("priority", 10, - "[integer] yoda priority", - &mca_spml_yoda.priority); - return OSHMEM_SUCCESS; -} - -static int mca_spml_yoda_component_open(void) -{ - return OSHMEM_SUCCESS; -} - -static int mca_spml_yoda_component_close(void) -{ - return OSHMEM_SUCCESS; -} - -static mca_spml_base_module_t* -mca_spml_yoda_component_init(int* priority, - bool enable_progress_threads, - bool enable_mpi_threads) -{ - SPML_VERBOSE( 10, "in yoda, my priority is %d\n", mca_spml_yoda.priority); - - *priority = mca_spml_yoda.priority; - if ((*priority) > mca_spml_yoda.priority) { - return NULL ; - } - - /* We use BML/BTL and need to start it */ - if (!mca_bml_base_inited()) { - SPML_VERBOSE(10, "can not select yoda because ompi has no bml component"); - return NULL; - } - - mca_spml_yoda.n_active_puts = 0; - mca_spml_yoda.n_active_gets = 0; - - return &mca_spml_yoda.super; -} - -int mca_spml_yoda_component_fini(void) -{ - if (!mca_spml_yoda.enabled) { - return OSHMEM_SUCCESS; /* never selected.. return success.. */ - } - mca_spml_yoda.enabled = false; /* not anymore */ - - OBJ_DESTRUCT(&mca_spml_yoda.lock); -#if OSHMEM_WAIT_COMPLETION_DEBUG == 1 - condition_dbg_finalize(); -#endif - - return OSHMEM_SUCCESS; -} - diff --git a/oshmem/mca/spml/yoda/spml_yoda_component.h b/oshmem/mca/spml/yoda/spml_yoda_component.h deleted file mode 100644 index 01c3c08952..0000000000 --- a/oshmem/mca/spml/yoda/spml_yoda_component.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2013 Mellanox Technologies, Inc. - * All rights reserved. - * $COPYRIGHT$ - * - * Additional copyrights may follow - * - * $HEADER$ - */ -/** - * @file - */ - -#ifndef MCA_SPML_YODA_COMPONENT_H -#define MCA_SPML_YODA_COMPONENT_H - -BEGIN_C_DECLS - -/* - * SPML module functions. - */ -OSHMEM_MODULE_DECLSPEC extern mca_spml_base_component_2_0_0_t mca_spml_yoda_component; -END_C_DECLS - -#endif diff --git a/oshmem/mca/spml/yoda/spml_yoda_getreq.c b/oshmem/mca/spml/yoda/spml_yoda_getreq.c deleted file mode 100644 index 657beb15a6..0000000000 --- a/oshmem/mca/spml/yoda/spml_yoda_getreq.c +++ /dev/null @@ -1,128 +0,0 @@ -/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ -/* - * Copyright (c) 2013 Mellanox Technologies, Inc. - * All rights reserved. - * Copyright (c) 2014 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 - * - * $HEADER$ - */ - -#include "oshmem_config.h" -#include "opal/prefetch.h" -#include "oshmem/constants.h" -#include "oshmem/mca/spml/spml.h" -#include "opal/mca/btl/btl.h" -#include "orte/mca/errmgr/errmgr.h" -#include "opal/mca/mpool/mpool.h" -#include "ompi/mca/bml/base/base.h" -#include "oshmem/mca/spml/yoda/spml_yoda.h" -#include "oshmem/mca/spml/yoda/spml_yoda_putreq.h" -#include "oshmem/mca/spml/yoda/spml_yoda_getreq.h" -#include "oshmem/mca/spml/yoda/spml_yoda_rdmafrag.h" - -/* - * The free call mark the final stage in a request life-cycle. Starting from this - * point the request is completed at both SPML and user level, and can be used - * for others one sided communications. Therefore, in the case of the YODA SPML it should - * be added to the free request list. - */ -static int mca_spml_yoda_get_request_free(struct oshmem_request_t** request) -{ - mca_spml_yoda_get_request_t* getreq = - *(mca_spml_yoda_get_request_t**) request; - - assert( false == getreq->req_get.req_base.req_free_called); - - OPAL_THREAD_LOCK(&oshmem_request_lock); - getreq->req_get.req_base.req_free_called = true; - - opal_free_list_return (&mca_spml_base_get_requests, - (opal_free_list_item_t*)getreq); - - OPAL_THREAD_UNLOCK(&oshmem_request_lock); - - *request = SHMEM_REQUEST_NULL; /*MPI_REQUEST_NULL;*/ - return OSHMEM_SUCCESS; -} - -static int mca_spml_yoda_get_request_cancel(struct oshmem_request_t* request, - int complete) -{ - /* we dont cancel get requests by now */ - return OSHMEM_SUCCESS; -} - -static void mca_spml_yoda_get_request_construct(mca_spml_yoda_get_request_t* req) -{ - req->req_get.req_base.req_type = MCA_SPML_REQUEST_GET; - req->req_get.req_base.req_oshmem.req_free = mca_spml_yoda_get_request_free; - req->req_get.req_base.req_oshmem.req_cancel = - mca_spml_yoda_get_request_cancel; -} - -static void mca_spml_yoda_get_request_destruct(mca_spml_yoda_get_request_t* req) -{ -} - -OBJ_CLASS_INSTANCE( mca_spml_yoda_get_request_t, - mca_spml_base_get_request_t, - mca_spml_yoda_get_request_construct, - mca_spml_yoda_get_request_destruct); - -void mca_spml_yoda_get_completion (struct mca_btl_base_module_t* module, - struct mca_btl_base_endpoint_t* endpoint, - void *local_address, - struct mca_btl_base_registration_handle_t *local_handle, - void *context, void *cbdata, int status) -{ - mca_spml_yoda_rdma_frag_t* frag = - (mca_spml_yoda_rdma_frag_t*) cbdata; - mca_spml_yoda_get_request_t* getreq = - (mca_spml_yoda_get_request_t*) frag->rdma_req; - mca_bml_base_btl_t* bml_btl = (mca_bml_base_btl_t*) context; - - /* check completion status */ - if (OPAL_UNLIKELY(OPAL_SUCCESS != status)) { - /* shmem has no way to propagate errors. cry&die */ - SPML_ERROR("FATAL get completion error"); - abort(); - } - - if (getreq->parent) { - OPAL_THREAD_ADD32(&getreq->parent->active_count, -1); - } - getreq->req_get.req_base.req_spml_complete = true; - oshmem_request_complete(&getreq->req_get.req_base.req_oshmem, 1); - oshmem_request_free((oshmem_request_t**) &getreq); - - if (bml_btl->btl->btl_register_mem && frag->local_handle) { - bml_btl->btl->btl_deregister_mem (bml_btl->btl, frag->local_handle); - } - - OPAL_THREAD_ADD32(&mca_spml_yoda.n_active_gets, -1); -} - -void mca_spml_yoda_get_response_completion(mca_btl_base_module_t* btl, - struct mca_btl_base_endpoint_t* ep, - struct mca_btl_base_descriptor_t* des, - int status) -{ - mca_bml_base_btl_t* bml_btl = (mca_bml_base_btl_t*) des->des_context; - - /* check completion status */ - if (OPAL_UNLIKELY(OSHMEM_SUCCESS != status)) { - /* shmem has no way to propagate errors. cry&die */ - SPML_ERROR("FATAL get completion error"); - abort(); - } - - mca_bml_base_free(bml_btl, des); - - OPAL_THREAD_ADD32(&mca_spml_yoda.n_active_gets, -1); -} diff --git a/oshmem/mca/spml/yoda/spml_yoda_getreq.h b/oshmem/mca/spml/yoda/spml_yoda_getreq.h deleted file mode 100644 index 765f2e3df9..0000000000 --- a/oshmem/mca/spml/yoda/spml_yoda_getreq.h +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ -/* - * Copyright (c) 2013 Mellanox Technologies, Inc. - * All rights reserved. - * Copyright (c) 2015 Los Alamos National Security, LLC. All rights - * reserved. - * Copyright (c) 2015 Research Organization for Information Science - * and Technology (RIST). All rights reserved. - * $COPYRIGHT$ - * - * Additional copyrights may follow - * - * $HEADER$ - */ - -#ifndef OSHMEM_SPML_YODA_GET_REQUEST_H -#define OSHMEM_SPML_YODA_GET_REQUEST_H - -#include "opal/mca/btl/btl.h" -#include "oshmem/mca/spml/base/spml_base_putreq.h" -#include "opal/mca/mpool/base/base.h" -#include "ompi/mca/bml/bml.h" -#include "oshmem/mca/spml/yoda/spml_yoda_rdmafrag.h" -#include "oshmem/mca/spml/yoda/spml_yoda.h" -#include "orte/runtime/orte_globals.h" -#include "oshmem/mca/spml/base/spml_base_getreq.h" - -BEGIN_C_DECLS - -struct mca_spml_yoda_getreq_parent { - int32_t active_count; -}; - -struct mca_spml_yoda_get_request_t { - mca_spml_base_get_request_t req_get; - uint64_t *p_dst; - struct mca_spml_yoda_getreq_parent *parent; - mca_spml_yoda_rdma_frag_t get_frag; -}; - -typedef struct mca_spml_yoda_get_request_t mca_spml_yoda_get_request_t; -OBJ_CLASS_DECLARATION(mca_spml_yoda_get_request_t); - -static inline mca_spml_yoda_get_request_t *mca_spml_yoda_getreq_alloc(int dst) -{ - opal_free_list_item_t *item; - mca_spml_yoda_get_request_t *getreq; - - item = opal_free_list_wait (&mca_spml_base_get_requests); - getreq = (mca_spml_yoda_get_request_t*) item; - assert(getreq); - getreq->req_get.req_base.req_free_called = false; - getreq->req_get.req_base.req_oshmem.req_complete = false; - - return getreq; -} - -void mca_spml_yoda_get_completion (struct mca_btl_base_module_t* module, - struct mca_btl_base_endpoint_t* endpoint, - void *local_address, - struct mca_btl_base_registration_handle_t *local_handle, - void *context, void *cbdata, int status); - -void mca_spml_yoda_get_response_completion(mca_btl_base_module_t* btl, - struct mca_btl_base_endpoint_t* ep, - struct mca_btl_base_descriptor_t* des, - int status); - -END_C_DECLS -#endif /* OSHMEM_SPML_YODA_GET_REQUEST_H */ diff --git a/oshmem/mca/spml/yoda/spml_yoda_putreq.c b/oshmem/mca/spml/yoda/spml_yoda_putreq.c deleted file mode 100644 index c1dca77089..0000000000 --- a/oshmem/mca/spml/yoda/spml_yoda_putreq.c +++ /dev/null @@ -1,113 +0,0 @@ -/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ -/* - * Copyright (c) 2013 Mellanox Technologies, Inc. - * All rights reserved. - * Copyright (c) 2015 Los Alamos National Security, LLC. All rights - * reserved. - * $COPYRIGHT$ - * - * Additional copyrights may follow - * - * $HEADER$ - */ - -#include "oshmem_config.h" -#include "opal/prefetch.h" -#include "oshmem/constants.h" -#include "oshmem/mca/spml/spml.h" -#include "opal/mca/btl/btl.h" -#include "orte/mca/errmgr/errmgr.h" -#include "opal/mca/mpool/mpool.h" -#include "ompi/mca/bml/base/base.h" -#include "oshmem/mca/spml/yoda/spml_yoda.h" -#include "oshmem/mca/spml/yoda/spml_yoda_putreq.h" -#include "oshmem/mca/spml/yoda/spml_yoda_rdmafrag.h" -#include "oshmem/runtime/runtime.h" -/* - * The free call mark the final stage in a request life-cycle. Starting from this - * point the request is completed at both SPML and user level, and can be used - * for others p2p communications. Therefore, in the case of the YODA SPML it should - * be added to the free request list. - */ -static int mca_spml_yoda_put_request_free(struct oshmem_request_t** request) -{ - mca_spml_yoda_put_request_t* putreq = - *(mca_spml_yoda_put_request_t**) request; - - assert( false == putreq->req_put.req_base.req_free_called); - - OPAL_THREAD_LOCK(&oshmem_request_lock); - putreq->req_put.req_base.req_free_called = true; - opal_free_list_return (&mca_spml_base_put_requests, - (opal_free_list_item_t*)putreq); - OPAL_THREAD_UNLOCK(&oshmem_request_lock); - - *request = SHMEM_REQUEST_NULL; - return OSHMEM_SUCCESS; -} - -static int mca_spml_yoda_put_request_cancel(struct oshmem_request_t* request, - int complete) -{ - /* we dont cancel put requests by now */ - return OSHMEM_SUCCESS; -} - -static void mca_spml_yoda_put_request_construct(mca_spml_yoda_put_request_t* req) -{ - req->req_put.req_base.req_type = MCA_SPML_REQUEST_PUT; - req->req_put.req_base.req_oshmem.req_free = mca_spml_yoda_put_request_free; - req->req_put.req_base.req_oshmem.req_cancel = - mca_spml_yoda_put_request_cancel; -} - -static void mca_spml_yoda_put_request_destruct(mca_spml_yoda_put_request_t* req) -{ -} - -OBJ_CLASS_INSTANCE( mca_spml_yoda_put_request_t, - mca_spml_base_put_request_t, - mca_spml_yoda_put_request_construct, - mca_spml_yoda_put_request_destruct); - -void mca_spml_yoda_put_completion(mca_btl_base_module_t* btl, - struct mca_btl_base_endpoint_t* ep, - struct mca_btl_base_descriptor_t* des, - int status) -{ - mca_spml_yoda_rdma_frag_t* frag = - (mca_spml_yoda_rdma_frag_t*) des->des_cbdata; - mca_spml_yoda_put_request_t* putreq = - (mca_spml_yoda_put_request_t*) frag->rdma_req; - mca_bml_base_btl_t* bml_btl = (mca_bml_base_btl_t*) des->des_context; - - OPAL_THREAD_ADD32(&mca_spml_yoda.n_active_puts, -1); - /* check completion status */ - if (OPAL_UNLIKELY(OSHMEM_SUCCESS != status)) { - /* no way to propagete errors. die */ - SPML_ERROR("FATAL put completion error"); - oshmem_shmem_abort(-1); - } - - putreq->req_put.req_base.req_spml_complete = true; - oshmem_request_complete(&putreq->req_put.req_base.req_oshmem, 1); - oshmem_request_free((oshmem_request_t**) &putreq); - mca_bml_base_free(bml_btl, des); -} - -void mca_spml_yoda_put_completion_rdma (struct mca_btl_base_module_t* module, - struct mca_btl_base_endpoint_t* endpoint, - void *local_address, - struct mca_btl_base_registration_handle_t *local_handle, - void *context, void *cbdata, int status) -{ - mca_btl_base_descriptor_t *des = (mca_btl_base_descriptor_t *) cbdata; - mca_bml_base_btl_t *bml_btl = (mca_bml_base_btl_t *) context; - des->des_context = context; - - if (bml_btl->btl->btl_register_mem) { - bml_btl->btl->btl_deregister_mem (bml_btl->btl, local_handle); - } - - des->des_cbfunc (module, endpoint, des, status); -} diff --git a/oshmem/mca/spml/yoda/spml_yoda_putreq.h b/oshmem/mca/spml/yoda/spml_yoda_putreq.h deleted file mode 100644 index 9bdb1b8651..0000000000 --- a/oshmem/mca/spml/yoda/spml_yoda_putreq.h +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ -/* - * Copyright (c) 2013 Mellanox Technologies, Inc. - * All rights reserved. - * Copyright (c) 2015 Los Alamos National Security, LLC. All rights - * reserved. - * $COPYRIGHT$ - * - * Additional copyrights may follow - * - * $HEADER$ - */ - -#ifndef OSHMEM_SPML_YODA_PUT_REQUEST_H -#define OSHMEM_SPML_YODA_PUT_REQUEST_H - -#include "opal/mca/btl/btl.h" -#include "oshmem/mca/spml/base/base.h" -#include "oshmem/mca/spml/base/spml_base_putreq.h" -#include "opal/mca/mpool/base/base.h" -#include "ompi/mca/bml/bml.h" -#include "oshmem/mca/spml/yoda/spml_yoda_rdmafrag.h" -#include "oshmem/mca/spml/yoda/spml_yoda.h" -#include "orte/runtime/orte_globals.h" - -BEGIN_C_DECLS - -struct mca_spml_yoda_put_request_t { - mca_spml_base_put_request_t req_put; - mca_spml_yoda_rdma_frag_t put_frag; -}; - -typedef struct mca_spml_yoda_put_request_t mca_spml_yoda_put_request_t; - -OBJ_CLASS_DECLARATION(mca_spml_yoda_put_request_t); - -static inline mca_spml_yoda_put_request_t *mca_spml_yoda_putreq_alloc(int dst) { - opal_free_list_item_t *item; - mca_spml_yoda_put_request_t *putreq; - - item = opal_free_list_wait (&mca_spml_base_put_requests); - putreq = (mca_spml_yoda_put_request_t*) item; - assert(putreq); - putreq->req_put.req_base.req_free_called = false; - putreq->req_put.req_base.req_oshmem.req_complete = false; - - return putreq; -} - -void mca_spml_yoda_put_completion(mca_btl_base_module_t* btl, - struct mca_btl_base_endpoint_t* ep, - struct mca_btl_base_descriptor_t* des, - int status); - -void mca_spml_yoda_put_completion_rdma (struct mca_btl_base_module_t* module, - struct mca_btl_base_endpoint_t* endpoint, - void *local_address, - struct mca_btl_base_registration_handle_t *local_handle, - void *context, void *cbdata, int status); - -END_C_DECLS - -#endif /* OSHMEM_SPML_YODA_PUT_REQUEST_H */ diff --git a/oshmem/mca/spml/yoda/spml_yoda_rdmafrag.h b/oshmem/mca/spml/yoda/spml_yoda_rdmafrag.h deleted file mode 100644 index d04067521c..0000000000 --- a/oshmem/mca/spml/yoda/spml_yoda_rdmafrag.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2013 Mellanox Technologies, Inc. - * All rights reserved. - * $COPYRIGHT$ - * - * Additional copyrights may follow - * - * $HEADER$ - */ -/** - * @file - */ - -#ifndef MCA_SPML_YODA_RDMAFRAG_H -#define MCA_SPML_YODA_RDMAFRAG_H - -#include "opal/mca/btl/btl.h" -#include "opal/types.h" -#include "opal/util/arch.h" -#include "oshmem/proc/proc.h" - -BEGIN_C_DECLS - -typedef enum { - MCA_SPML_YODA_RDMA_PUT, - MCA_SPML_YODA_RDMA_GET -} mca_spml_yoda_rdma_state_t; - -typedef union mca_spml_yoda_segment_t { - mca_btl_base_segment_t base_seg; -} mca_spml_yoda_segment_t; - -struct mca_spml_yoda_rdma_frag_t { - mca_spml_yoda_segment_t rdma_segs[2]; - mca_btl_base_registration_handle_t *local_handle; - void *rdma_req; - int allocated; - int use_send; - int size; -}; - -typedef struct mca_spml_yoda_rdma_frag_t mca_spml_yoda_rdma_frag_t; -END_C_DECLS -#endif -