2005-06-30 22:21:55 +04:00
|
|
|
/*
|
2007-03-17 02:11:45 +03:00
|
|
|
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
|
2005-11-05 22:57:48 +03:00
|
|
|
* University Research and Technology
|
|
|
|
* Corporation. All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The University of Tennessee and The University
|
|
|
|
* of Tennessee Research Foundation. All rights
|
|
|
|
* reserved.
|
2005-06-30 22:21:55 +04:00
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
|
|
* University of Stuttgart. All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
2007-01-29 23:24:31 +03:00
|
|
|
* Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
|
2005-06-30 22:21:55 +04:00
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include "ompi_config.h"
|
2006-02-12 04:33:29 +03:00
|
|
|
#include "ompi/constants.h"
|
2005-07-04 03:09:55 +04:00
|
|
|
#include "opal/event/event.h"
|
2005-07-04 05:36:20 +04:00
|
|
|
#include "opal/util/if.h"
|
2005-07-04 04:13:44 +04:00
|
|
|
#include "opal/util/argv.h"
|
2005-07-04 03:31:27 +04:00
|
|
|
#include "opal/util/output.h"
|
2005-09-13 01:52:44 +04:00
|
|
|
#include "ompi/mca/pml/pml.h"
|
|
|
|
#include "ompi/mca/btl/btl.h"
|
2006-03-02 03:39:07 +03:00
|
|
|
#include "ompi/request/request.h"
|
2005-06-30 22:21:55 +04:00
|
|
|
|
2007-05-24 01:19:26 +04:00
|
|
|
#ifdef HAVE_INTTYPES_H
|
|
|
|
#include <inttypes.h>
|
|
|
|
#endif
|
|
|
|
|
2005-09-13 01:52:44 +04:00
|
|
|
#include "opal/mca/base/mca_base_param.h"
|
2006-02-12 04:33:29 +03:00
|
|
|
#include "orte/mca/errmgr/errmgr.h"
|
|
|
|
#include "ompi/mca/mpool/base/base.h"
|
2006-12-17 15:26:41 +03:00
|
|
|
#include "ompi/mca/mpool/rdma/mpool_rdma.h"
|
2005-06-30 22:21:55 +04:00
|
|
|
#include "btl_gm.h"
|
|
|
|
#include "btl_gm_frag.h"
|
|
|
|
#include "btl_gm_endpoint.h"
|
2005-09-13 01:52:44 +04:00
|
|
|
#include "ompi/mca/btl/base/base.h"
|
2005-09-30 08:39:44 +04:00
|
|
|
#include "ompi/mca/btl/base/btl_base_error.h"
|
2005-09-13 01:52:44 +04:00
|
|
|
#include "ompi/datatype/convertor.h"
|
2005-06-30 22:21:55 +04:00
|
|
|
#include "btl_gm_endpoint.h"
|
2005-09-13 01:52:44 +04:00
|
|
|
#include "orte/util/proc_info.h"
|
2007-07-09 21:16:34 +04:00
|
|
|
#include "ompi/runtime/ompi_module_exchange.h"
|
2005-06-30 22:21:55 +04:00
|
|
|
|
2006-03-02 03:39:07 +03:00
|
|
|
|
|
|
|
#if OMPI_ENABLE_PROGRESS_THREADS
|
|
|
|
static void* mca_btl_gm_progress_thread( opal_object_t* arg );
|
|
|
|
#endif
|
2006-12-17 15:26:41 +03:00
|
|
|
static int gm_reg_mr(void *reg_data, void *base, size_t size,
|
|
|
|
mca_mpool_base_registration_t *reg);
|
|
|
|
static int gm_dereg_mr(void *reg_data, mca_mpool_base_registration_t *reg);
|
2006-03-02 03:39:07 +03:00
|
|
|
|
|
|
|
|
2005-06-30 22:21:55 +04:00
|
|
|
mca_btl_gm_component_t mca_btl_gm_component = {
|
|
|
|
{
|
|
|
|
/* First, the mca_base_component_t struct containing meta information
|
|
|
|
about the component itself */
|
|
|
|
|
|
|
|
{
|
|
|
|
/* Indicate that we are a pml v1.0.0 component (which also implies a
|
|
|
|
specific MCA version) */
|
|
|
|
|
2006-08-18 02:02:01 +04:00
|
|
|
MCA_BTL_BASE_VERSION_1_0_1,
|
2005-06-30 22:21:55 +04:00
|
|
|
|
2005-07-07 20:56:58 +04:00
|
|
|
"gm", /* MCA component name */
|
Major simplifications to component versioning:
- After long discussions and ruminations on how we run components in
LAM/MPI, made the decision that, by default, all components included
in Open MPI will use the version number of their parent project
(i.e., OMPI or ORTE). They are certaint free to use a different
number, but this simplification makes the common cases easy:
- components are only released when the parent project is released
- it is easy (trivial?) to distinguish which version component goes
with with version of the parent project
- removed all autogen/configure code for templating the version .h
file in components
- made all ORTE components use ORTE_*_VERSION for version numbers
- made all OMPI components use OMPI_*_VERSION for version numbers
- removed all VERSION files from components
- configure now displays OPAL, ORTE, and OMPI version numbers
- ditto for ompi_info
- right now, faking it -- OPAL and ORTE and OMPI will always have the
same version number (i.e., they all come from the same top-level
VERSION file). But this paves the way for the Great Configure
Reorganization, where, among other things, each project will have
its own version number.
So all in all, we went from a boatload of version numbers to
[effectively] three. That's pretty good. :-)
This commit was SVN r6344.
2005-07-05 00:12:36 +04:00
|
|
|
OMPI_MAJOR_VERSION, /* MCA component major version */
|
|
|
|
OMPI_MINOR_VERSION, /* MCA component minor version */
|
|
|
|
OMPI_RELEASE_VERSION, /* MCA component release version */
|
2005-06-30 22:21:55 +04:00
|
|
|
mca_btl_gm_component_open, /* component open */
|
|
|
|
mca_btl_gm_component_close /* component close */
|
|
|
|
},
|
|
|
|
|
|
|
|
/* Next the MCA v1.0.0 component meta data */
|
|
|
|
|
|
|
|
{
|
2007-03-17 02:11:45 +03:00
|
|
|
/* The component is not checkpoint ready */
|
|
|
|
MCA_BASE_METADATA_PARAM_NONE
|
2005-06-30 22:21:55 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
mca_btl_gm_component_init,
|
|
|
|
mca_btl_gm_component_progress,
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* utility routines for parameter registration
|
|
|
|
*/
|
|
|
|
|
|
|
|
static inline char* mca_btl_gm_param_register_string(
|
|
|
|
const char* param_name,
|
|
|
|
const char* default_value)
|
|
|
|
{
|
|
|
|
char *param_value;
|
2005-07-07 20:56:58 +04:00
|
|
|
int id = mca_base_param_register_string("btl","gm",param_name,NULL,default_value);
|
2005-06-30 22:21:55 +04:00
|
|
|
mca_base_param_lookup_string(id, ¶m_value);
|
|
|
|
return param_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int mca_btl_gm_param_register_int(
|
|
|
|
const char* param_name,
|
|
|
|
int default_value)
|
|
|
|
{
|
2005-07-07 20:56:58 +04:00
|
|
|
int id = mca_base_param_register_int("btl","gm",param_name,NULL,default_value);
|
2005-06-30 22:21:55 +04:00
|
|
|
int param_value = default_value;
|
|
|
|
mca_base_param_lookup_int(id,¶m_value);
|
|
|
|
return param_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Called by MCA framework to open the component, registers
|
|
|
|
* component parameters.
|
|
|
|
*/
|
|
|
|
|
|
|
|
int mca_btl_gm_component_open(void)
|
2005-07-07 20:56:58 +04:00
|
|
|
{
|
2005-06-30 22:21:55 +04:00
|
|
|
/* initialize state */
|
|
|
|
mca_btl_gm_component.gm_num_btls=0;
|
|
|
|
mca_btl_gm_component.gm_btls=NULL;
|
|
|
|
|
|
|
|
/* initialize objects */
|
2005-07-03 20:22:16 +04:00
|
|
|
OBJ_CONSTRUCT(&mca_btl_gm_component.gm_procs, opal_list_t);
|
2005-07-04 02:45:48 +04:00
|
|
|
OBJ_CONSTRUCT(&mca_btl_gm_component.gm_lock, opal_mutex_t);
|
2005-06-30 22:21:55 +04:00
|
|
|
|
|
|
|
/* register GM component parameters */
|
|
|
|
mca_btl_gm_component.gm_free_list_num =
|
|
|
|
mca_btl_gm_param_register_int ("free_list_num", 8);
|
|
|
|
mca_btl_gm_component.gm_free_list_max =
|
2005-07-07 20:56:58 +04:00
|
|
|
mca_btl_gm_param_register_int ("free_list_max", -1);
|
2005-06-30 22:21:55 +04:00
|
|
|
mca_btl_gm_component.gm_free_list_inc =
|
2005-07-07 20:56:58 +04:00
|
|
|
mca_btl_gm_param_register_int ("free_list_inc", 8);
|
|
|
|
mca_btl_gm_component.gm_debug =
|
|
|
|
mca_btl_gm_param_register_int("debug", 0);
|
2005-06-30 22:21:55 +04:00
|
|
|
mca_btl_gm_component.gm_mpool_name =
|
2006-12-17 15:26:41 +03:00
|
|
|
mca_btl_gm_param_register_string("mpool", "rdma");
|
2005-07-02 02:24:58 +04:00
|
|
|
mca_btl_gm_component.gm_max_ports =
|
|
|
|
mca_btl_gm_param_register_int("max_ports", 16);
|
|
|
|
mca_btl_gm_component.gm_max_boards =
|
|
|
|
mca_btl_gm_param_register_int("max_boards", 4);
|
|
|
|
mca_btl_gm_component.gm_max_btls =
|
|
|
|
mca_btl_gm_param_register_int("max_modules", 4);
|
|
|
|
mca_btl_gm_component.gm_num_high_priority =
|
|
|
|
mca_btl_gm_param_register_int("num_high_priority", 8);
|
2005-07-14 01:39:41 +04:00
|
|
|
mca_btl_gm_component.gm_num_repost =
|
|
|
|
mca_btl_gm_param_register_int("num_repost", 4);
|
2005-07-07 20:56:58 +04:00
|
|
|
mca_btl_gm_component.gm_port_name=
|
|
|
|
mca_btl_gm_param_register_string("port_name", "OMPI");
|
2005-06-30 22:21:55 +04:00
|
|
|
|
|
|
|
/* register gm module parameters */
|
2007-05-17 11:54:27 +04:00
|
|
|
mca_btl_gm_module.super.btl_exclusivity = MCA_BTL_EXCLUSIVITY_DEFAULT;
|
|
|
|
mca_btl_gm_module.super.btl_eager_limit = 32*1024;
|
|
|
|
mca_btl_gm_module.super.btl_min_send_size = 32*1024;
|
|
|
|
mca_btl_gm_module.super.btl_max_send_size = 64*1024;
|
2007-06-21 11:12:40 +04:00
|
|
|
mca_btl_gm_module.super.btl_rdma_pipeline_send_length = 512*1024;
|
2007-05-17 11:54:27 +04:00
|
|
|
mca_btl_gm_module.super.btl_rdma_pipeline_frag_size = 128*1024;
|
|
|
|
mca_btl_gm_module.super.btl_min_rdma_pipeline_size = 128*1024;
|
2005-10-04 18:33:26 +04:00
|
|
|
#if OMPI_MCA_BTL_GM_HAVE_RDMA_PUT
|
2007-05-17 11:54:27 +04:00
|
|
|
mca_btl_gm_module.super.btl_flags = MCA_BTL_FLAGS_PUT |
|
|
|
|
MCA_BTL_FLAGS_NEED_ACK | MCA_BTL_FLAGS_NEED_CSUM;
|
2005-07-01 00:39:24 +04:00
|
|
|
#else
|
2005-07-07 20:56:58 +04:00
|
|
|
mca_btl_gm_module.super.btl_flags = MCA_BTL_FLAGS_SEND;
|
2005-07-01 00:39:24 +04:00
|
|
|
#endif
|
2007-05-17 11:54:27 +04:00
|
|
|
mca_btl_gm_module.super.btl_bandwidth = 250;
|
|
|
|
mca_btl_gm_module.super.btl_latency = 0;
|
|
|
|
mca_btl_base_param_register(&mca_btl_gm_component.super.btl_version,
|
|
|
|
&mca_btl_gm_module.super);
|
|
|
|
|
2005-07-07 20:56:58 +04:00
|
|
|
/* compute the eager frag size */
|
|
|
|
mca_btl_gm_component.gm_eager_frag_size =
|
2005-07-08 01:38:37 +04:00
|
|
|
gm_min_size_for_length(mca_btl_gm_module.super.btl_eager_limit) - 1;
|
2005-07-07 20:56:58 +04:00
|
|
|
mca_btl_gm_module.super.btl_eager_limit =
|
2005-07-08 01:38:37 +04:00
|
|
|
gm_max_length_for_size(mca_btl_gm_component.gm_eager_frag_size) -
|
|
|
|
sizeof(mca_btl_base_header_t);
|
2005-07-07 20:56:58 +04:00
|
|
|
|
|
|
|
/* compute the max frag size */
|
|
|
|
mca_btl_gm_component.gm_max_frag_size =
|
2005-07-08 01:38:37 +04:00
|
|
|
gm_min_size_for_length(mca_btl_gm_module.super.btl_max_send_size) - 1;
|
2005-07-07 20:56:58 +04:00
|
|
|
mca_btl_gm_module.super.btl_max_send_size =
|
|
|
|
gm_max_length_for_size(mca_btl_gm_component.gm_max_frag_size) -
|
|
|
|
sizeof(mca_btl_base_header_t);
|
2005-07-08 00:58:57 +04:00
|
|
|
|
2005-06-30 22:21:55 +04:00
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* component cleanup - sanity checking of queue lengths
|
|
|
|
*/
|
|
|
|
|
|
|
|
int mca_btl_gm_component_close(void)
|
|
|
|
{
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2006-12-17 15:26:41 +03:00
|
|
|
static int gm_reg_mr(void *reg_data, void *base, size_t size,
|
|
|
|
mca_mpool_base_registration_t *reg)
|
|
|
|
{
|
|
|
|
struct gm_port *port = (struct gm_port*)reg_data;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
rc = gm_register_memory(port, base, size);
|
|
|
|
|
|
|
|
if(rc != GM_SUCCESS)
|
|
|
|
return OMPI_ERR_OUT_OF_RESOURCE;
|
|
|
|
|
|
|
|
return MPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int gm_dereg_mr(void *reg_data, mca_mpool_base_registration_t *reg)
|
|
|
|
{
|
|
|
|
struct gm_port *port = (struct gm_port*)reg_data;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
rc = gm_deregister_memory(port, reg->base, reg->bound - reg->base + 1);
|
|
|
|
|
|
|
|
if(rc != GM_SUCCESS) {
|
|
|
|
opal_output(0, "%s: error unpinning gm memory errno says %s\n",
|
|
|
|
__func__, strerror(errno));
|
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
2005-06-30 22:21:55 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize module instance
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int
|
|
|
|
mca_btl_gm_module_init (mca_btl_gm_module_t * btl)
|
|
|
|
{
|
|
|
|
mca_mpool_base_resources_t resources;
|
2005-07-16 00:56:29 +04:00
|
|
|
int32_t num_high_priority;
|
|
|
|
int32_t i;
|
2005-06-30 22:21:55 +04:00
|
|
|
int rc;
|
|
|
|
|
|
|
|
/* initialize objects */
|
|
|
|
OBJ_CONSTRUCT(&btl->gm_frag_eager, ompi_free_list_t);
|
|
|
|
OBJ_CONSTRUCT(&btl->gm_frag_max, ompi_free_list_t);
|
2005-07-01 01:42:05 +04:00
|
|
|
OBJ_CONSTRUCT(&btl->gm_frag_user, ompi_free_list_t);
|
2005-07-03 20:22:16 +04:00
|
|
|
OBJ_CONSTRUCT(&btl->gm_pending, opal_list_t);
|
2005-07-14 01:39:41 +04:00
|
|
|
OBJ_CONSTRUCT(&btl->gm_repost, opal_list_t);
|
2006-03-11 06:20:50 +03:00
|
|
|
#if OMPI_ENABLE_PROGRESS_THREADS
|
2006-03-02 03:39:07 +03:00
|
|
|
OBJ_CONSTRUCT(&btl->gm_thread, opal_thread_t);
|
2006-03-11 06:20:50 +03:00
|
|
|
#endif
|
|
|
|
|
2006-08-17 00:21:38 +04:00
|
|
|
btl->error_cb = NULL;
|
2005-06-30 22:21:55 +04:00
|
|
|
/* query nic tokens */
|
2005-07-07 20:56:58 +04:00
|
|
|
btl->gm_num_send_tokens = gm_num_send_tokens (btl->port);
|
2005-06-30 22:21:55 +04:00
|
|
|
btl->gm_max_send_tokens = btl->gm_num_send_tokens;
|
2005-07-07 20:56:58 +04:00
|
|
|
btl->gm_num_recv_tokens = gm_num_receive_tokens (btl->port);
|
2005-06-30 22:21:55 +04:00
|
|
|
btl->gm_max_recv_tokens = btl->gm_num_recv_tokens;
|
2005-07-02 02:24:58 +04:00
|
|
|
|
2005-07-07 20:56:58 +04:00
|
|
|
/* dont allow high priority to exceed 1/2 of available recv tokens */
|
2005-07-02 02:24:58 +04:00
|
|
|
num_high_priority = mca_btl_gm_component.gm_num_high_priority;
|
2005-07-07 20:56:58 +04:00
|
|
|
if(num_high_priority > (btl->gm_num_recv_tokens >> 1)) {
|
|
|
|
num_high_priority = btl->gm_num_recv_tokens >> 1;
|
2005-07-02 02:24:58 +04:00
|
|
|
}
|
2005-07-14 01:39:41 +04:00
|
|
|
if(mca_btl_gm_component.gm_num_repost > num_high_priority >> 1) {
|
|
|
|
btl->gm_num_repost = (num_high_priority >> 1);
|
|
|
|
} else {
|
|
|
|
btl->gm_num_repost = mca_btl_gm_component.gm_num_repost;
|
|
|
|
}
|
2005-06-30 22:21:55 +04:00
|
|
|
|
|
|
|
/* initialize memory pool */
|
2006-12-17 15:26:41 +03:00
|
|
|
resources.reg_data = (void*)btl->port;
|
|
|
|
resources.sizeof_reg = sizeof(mca_mpool_base_registration_t);
|
|
|
|
resources.register_mem = gm_reg_mr;
|
|
|
|
resources.deregister_mem = gm_dereg_mr;
|
2005-09-13 02:28:23 +04:00
|
|
|
btl->super.btl_mpool = mca_mpool_base_module_create(
|
2005-06-30 22:21:55 +04:00
|
|
|
mca_btl_gm_component.gm_mpool_name,
|
|
|
|
&btl->super,
|
|
|
|
&resources);
|
2005-09-13 02:28:23 +04:00
|
|
|
if(NULL == btl->super.btl_mpool) {
|
2005-07-04 03:31:27 +04:00
|
|
|
opal_output (0, "[%s:%d] unable to initialize mpool", __FILE__, __LINE__);
|
2005-06-30 22:21:55 +04:00
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* initialize free lists */
|
|
|
|
ompi_free_list_init( &btl->gm_frag_eager,
|
2007-05-16 16:20:58 +04:00
|
|
|
sizeof (mca_btl_gm_frag_eager_t) + (1 << mca_btl_gm_component.gm_eager_frag_size) + sizeof (uintptr_t),
|
2005-06-30 22:21:55 +04:00
|
|
|
OBJ_CLASS (mca_btl_gm_frag_eager_t),
|
2005-07-07 20:56:58 +04:00
|
|
|
btl->gm_max_send_tokens,
|
2005-06-30 22:21:55 +04:00
|
|
|
mca_btl_gm_component.gm_free_list_max,
|
|
|
|
mca_btl_gm_component.gm_free_list_inc,
|
2005-09-13 02:28:23 +04:00
|
|
|
btl->super.btl_mpool );
|
2005-06-30 22:21:55 +04:00
|
|
|
|
|
|
|
ompi_free_list_init( &btl->gm_frag_max,
|
2007-05-16 16:20:58 +04:00
|
|
|
sizeof (mca_btl_gm_frag_max_t) + (1 << mca_btl_gm_component.gm_max_frag_size) + sizeof (uintptr_t),
|
2005-06-30 22:21:55 +04:00
|
|
|
OBJ_CLASS (mca_btl_gm_frag_max_t),
|
2005-07-07 20:56:58 +04:00
|
|
|
btl->gm_max_recv_tokens,
|
2005-06-30 22:21:55 +04:00
|
|
|
mca_btl_gm_component.gm_free_list_max,
|
|
|
|
mca_btl_gm_component.gm_free_list_inc,
|
2005-09-13 02:28:23 +04:00
|
|
|
btl->super.btl_mpool );
|
2005-06-30 22:21:55 +04:00
|
|
|
|
|
|
|
ompi_free_list_init( &btl->gm_frag_user,
|
|
|
|
sizeof (mca_btl_gm_frag_user_t),
|
|
|
|
OBJ_CLASS (mca_btl_gm_frag_user_t),
|
|
|
|
mca_btl_gm_component.gm_free_list_num,
|
|
|
|
mca_btl_gm_component.gm_free_list_max,
|
|
|
|
mca_btl_gm_component.gm_free_list_inc,
|
2005-07-07 20:56:58 +04:00
|
|
|
NULL );
|
|
|
|
|
2005-06-30 22:21:55 +04:00
|
|
|
|
|
|
|
/* post receive buffers */
|
2005-07-02 02:24:58 +04:00
|
|
|
for(i=0; i<num_high_priority; i++) {
|
2005-06-30 22:21:55 +04:00
|
|
|
mca_btl_gm_frag_t* frag;
|
|
|
|
MCA_BTL_GM_FRAG_ALLOC_EAGER(btl, frag, rc);
|
|
|
|
if(NULL == frag) {
|
|
|
|
return rc;
|
|
|
|
}
|
2006-10-10 18:56:55 +04:00
|
|
|
frag->type = MCA_BTL_GM_EAGER;
|
2005-07-07 20:56:58 +04:00
|
|
|
frag->base.des_src = NULL;
|
|
|
|
frag->base.des_src_cnt = 0;
|
|
|
|
frag->base.des_dst = &frag->segment;
|
|
|
|
frag->base.des_dst_cnt = 1;
|
2005-07-15 01:19:16 +04:00
|
|
|
frag->priority = GM_HIGH_PRIORITY;
|
|
|
|
gm_provide_receive_buffer(btl->port, frag->hdr, frag->size, frag->priority);
|
2005-06-30 22:21:55 +04:00
|
|
|
}
|
2005-07-07 20:56:58 +04:00
|
|
|
|
2005-06-30 22:21:55 +04:00
|
|
|
for(i=mca_btl_gm_component.gm_num_high_priority; i<btl->gm_max_recv_tokens; i++) {
|
|
|
|
mca_btl_gm_frag_t* frag;
|
|
|
|
MCA_BTL_GM_FRAG_ALLOC_MAX(btl, frag, rc);
|
|
|
|
if(NULL == frag) {
|
|
|
|
return rc;
|
|
|
|
}
|
2006-10-10 18:56:55 +04:00
|
|
|
frag->type = MCA_BTL_GM_SEND;
|
2005-07-07 20:56:58 +04:00
|
|
|
frag->base.des_src = NULL;
|
|
|
|
frag->base.des_src_cnt = 0;
|
|
|
|
frag->base.des_dst = &frag->segment;
|
|
|
|
frag->base.des_dst_cnt = 1;
|
2005-07-14 01:39:41 +04:00
|
|
|
frag->priority = GM_LOW_PRIORITY;
|
2005-07-15 01:19:16 +04:00
|
|
|
gm_provide_receive_buffer(btl->port, frag->hdr, frag->size, frag->priority);
|
2005-06-30 22:21:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* enable rdma */
|
2005-07-07 20:56:58 +04:00
|
|
|
if( GM_SUCCESS != gm_allow_remote_memory_access (btl->port) ) {
|
2005-07-04 03:31:27 +04:00
|
|
|
opal_output (0, "[%s:%d] unable to allow remote memory access", __FILE__, __LINE__);
|
2005-06-30 22:21:55 +04:00
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
2006-03-02 03:39:07 +03:00
|
|
|
|
|
|
|
#if OMPI_ENABLE_PROGRESS_THREADS
|
|
|
|
/* start progress thread */
|
2006-03-16 03:05:39 +03:00
|
|
|
btl->gm_progress = true;
|
2006-03-02 03:39:07 +03:00
|
|
|
btl->gm_thread.t_run = mca_btl_gm_progress_thread;
|
|
|
|
btl->gm_thread.t_arg = btl;
|
|
|
|
if(OPAL_SUCCESS != (rc = opal_thread_start(&btl->gm_thread))) {
|
|
|
|
opal_output (0, "[%s:%d] unable to create progress thread, retval=%d", __FILE__, __LINE__, rc);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
#endif
|
2005-06-30 22:21:55 +04:00
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Scan all ports on the boards. As it's difficult to find the total number of boards
|
|
|
|
* so we use a predefined maximum.
|
|
|
|
*/
|
|
|
|
static int mca_btl_gm_discover( void )
|
|
|
|
{
|
|
|
|
uint32_t board_no;
|
|
|
|
uint32_t port_no;
|
2005-07-07 20:56:58 +04:00
|
|
|
uint32_t node_id;
|
|
|
|
struct gm_port* port;
|
2005-06-30 22:21:55 +04:00
|
|
|
#if GM_API_VERSION > 0x200
|
|
|
|
uint32_t global_id;
|
|
|
|
#else
|
|
|
|
char global_id[GM_MAX_HOST_NAME_LEN];
|
|
|
|
#endif /* GM_API_VERSION > 0x200 */
|
|
|
|
int rc;
|
2006-03-02 03:39:07 +03:00
|
|
|
|
2005-06-30 22:21:55 +04:00
|
|
|
for( board_no = 0; board_no < mca_btl_gm_component.gm_max_boards; board_no++ ) {
|
|
|
|
mca_btl_gm_module_t *btl;
|
|
|
|
|
|
|
|
/* open the first available gm port for this board */
|
2005-07-07 20:56:58 +04:00
|
|
|
for( port_no = 4; port_no < mca_btl_gm_component.gm_max_ports; port_no++ ) {
|
2005-06-30 22:21:55 +04:00
|
|
|
if (3 == port_no) {
|
|
|
|
continue; /* port 0,1,3 reserved */
|
2005-07-07 20:56:58 +04:00
|
|
|
} else if (GM_SUCCESS == gm_open(&port, board_no, port_no,
|
|
|
|
mca_btl_gm_component.gm_port_name, GM_API_VERSION) ) {
|
|
|
|
break;
|
2005-06-30 22:21:55 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if( port_no == mca_btl_gm_component.gm_max_ports ) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get node local Id */
|
2005-07-07 20:56:58 +04:00
|
|
|
if( GM_SUCCESS != gm_get_node_id( port, &node_id) ) {
|
|
|
|
opal_output (0, " failure to get node_id \n");
|
2005-06-30 22:21:55 +04:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
/* Gather an unique id for the node */
|
|
|
|
#if GM_API_VERSION > 0x200
|
2005-07-07 20:56:58 +04:00
|
|
|
if (GM_SUCCESS != gm_node_id_to_global_id( port, node_id, &global_id) ) {
|
2005-07-04 03:31:27 +04:00
|
|
|
opal_output (0, "[%s:%d] Unable to get my GM global unique id", __FILE__, __LINE__);
|
2005-06-30 22:21:55 +04:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
#else
|
2005-07-07 20:56:58 +04:00
|
|
|
if( GM_SUCCESS != gm_get_host_name( port, global_id ) ) {
|
2005-07-04 03:31:27 +04:00
|
|
|
opal_output( 0, "[%s:%d] Unable to get the GM host name\n", __FILE__, __LINE__);
|
2005-06-30 22:21:55 +04:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
#endif /* GM_API_VERSION > 0x200 */
|
|
|
|
|
|
|
|
/* create the btl module */
|
|
|
|
btl = (mca_btl_gm_module_t *)malloc( sizeof(mca_btl_gm_module_t) );
|
|
|
|
if (NULL == btl) {
|
2005-07-04 03:31:27 +04:00
|
|
|
opal_output( 0, "[%s:%d] out of resources", __FILE__, __LINE__);
|
2005-06-30 22:21:55 +04:00
|
|
|
return OMPI_ERR_OUT_OF_RESOURCE;
|
|
|
|
}
|
2005-07-02 02:24:58 +04:00
|
|
|
/* copy the basic informations into the new BTL */
|
|
|
|
memcpy (btl, &mca_btl_gm_module, sizeof(mca_btl_gm_module_t));
|
2005-06-30 22:21:55 +04:00
|
|
|
|
|
|
|
/* setup local address */
|
2005-07-07 20:56:58 +04:00
|
|
|
btl->port = port;
|
|
|
|
btl->gm_addr.port_id = port_no;
|
|
|
|
btl->gm_addr.node_id = node_id;
|
2005-06-30 22:21:55 +04:00
|
|
|
#if GM_API_VERSION > 0x200
|
|
|
|
btl->gm_addr.global_id = global_id;
|
|
|
|
#else
|
|
|
|
strncpy( btl->gm_addr.global_id, global_id, GM_MAX_HOST_NAME_LEN );
|
|
|
|
#endif /* GM_API_VERSION > 0x200 */
|
|
|
|
|
2005-07-07 20:56:58 +04:00
|
|
|
if(mca_btl_gm_component.gm_debug > 0) {
|
2007-05-24 01:19:26 +04:00
|
|
|
opal_output(0,
|
2007-07-20 05:10:34 +04:00
|
|
|
"[%ld,%ld,%ld] gm_port %08lX, "
|
2007-05-24 01:19:26 +04:00
|
|
|
"board %" PRIu32 ", global %" PRIu32 " "
|
|
|
|
"node %" PRIu32 "port %" PRIu32 "\n",
|
2007-07-20 05:10:34 +04:00
|
|
|
ORTE_NAME_ARGS(orte_process_info.my_name),
|
2007-05-24 01:19:26 +04:00
|
|
|
(unsigned long) port, board_no, global_id, node_id, port_no);
|
2005-07-07 20:56:58 +04:00
|
|
|
}
|
|
|
|
|
2005-06-30 22:21:55 +04:00
|
|
|
if((rc = mca_btl_gm_module_init(btl)) != OMPI_SUCCESS) {
|
2005-07-04 03:31:27 +04:00
|
|
|
opal_output(0, "[%s:%d] unable to initialze gm port", __FILE__, __LINE__);
|
2005-06-30 22:21:55 +04:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* everything is OK let's mark it as usable and go to the next one */
|
2005-07-07 20:56:58 +04:00
|
|
|
mca_btl_gm_component.gm_btls[mca_btl_gm_component.gm_num_btls] = btl;
|
|
|
|
if(++mca_btl_gm_component.gm_num_btls >= mca_btl_gm_component.gm_max_btls ) {
|
2005-06-30 22:21:55 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Register GM component addressing information. The MCA framework
|
|
|
|
* will make this available to all peers.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int
|
|
|
|
mca_btl_gm_modex_send(void)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
size_t i;
|
|
|
|
size_t size;
|
2005-09-30 08:39:44 +04:00
|
|
|
mca_btl_gm_addr_t *addrs = NULL;
|
2005-06-30 22:21:55 +04:00
|
|
|
|
|
|
|
size = mca_btl_gm_component.gm_num_btls * sizeof (mca_btl_gm_addr_t);
|
2005-09-30 08:39:44 +04:00
|
|
|
if (0 != size) {
|
|
|
|
addrs = (mca_btl_gm_addr_t *)malloc (size);
|
|
|
|
if (NULL == addrs) {
|
|
|
|
return OMPI_ERR_OUT_OF_RESOURCE;
|
|
|
|
}
|
2005-06-30 22:21:55 +04:00
|
|
|
|
2005-09-30 08:39:44 +04:00
|
|
|
for (i = 0; i < mca_btl_gm_component.gm_num_btls; i++) {
|
|
|
|
mca_btl_gm_module_t *btl = mca_btl_gm_component.gm_btls[i];
|
|
|
|
addrs[i] = btl->gm_addr;
|
2006-02-28 05:03:46 +03:00
|
|
|
MCA_BTL_GM_ADDR_HTON(addrs[i]);
|
2005-09-30 08:39:44 +04:00
|
|
|
}
|
2005-06-30 22:21:55 +04:00
|
|
|
}
|
2007-07-09 21:16:34 +04:00
|
|
|
rc = ompi_modex_send (&mca_btl_gm_component.super.btl_version, addrs, size);
|
2005-09-30 08:39:44 +04:00
|
|
|
if (NULL != addrs) {
|
|
|
|
free (addrs);
|
|
|
|
}
|
2005-06-30 22:21:55 +04:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize the GM component,
|
|
|
|
* check how many boards are available and open ports on them.
|
|
|
|
*/
|
|
|
|
|
|
|
|
mca_btl_base_module_t **
|
|
|
|
mca_btl_gm_component_init (int *num_btl_modules,
|
|
|
|
bool enable_progress_threads,
|
|
|
|
bool enable_mpi_threads)
|
|
|
|
{
|
|
|
|
mca_btl_base_module_t **btls;
|
|
|
|
*num_btl_modules = 0;
|
|
|
|
|
2006-03-02 03:39:07 +03:00
|
|
|
OPAL_THREAD_LOCK(&mca_btl_gm_component.gm_lock);
|
|
|
|
|
2005-07-07 20:56:58 +04:00
|
|
|
/* try to initialize GM */
|
2005-06-30 22:21:55 +04:00
|
|
|
if( GM_SUCCESS != gm_init() ) {
|
2005-07-04 03:31:27 +04:00
|
|
|
opal_output( 0, "[%s:%d] error in initializing the gm library\n", __FILE__, __LINE__ );
|
2005-09-30 08:39:44 +04:00
|
|
|
mca_btl_gm_component.gm_num_btls = 0;
|
|
|
|
mca_btl_gm_modex_send();
|
2006-03-02 03:39:07 +03:00
|
|
|
OPAL_THREAD_UNLOCK(&mca_btl_gm_component.gm_lock);
|
2005-06-30 22:21:55 +04:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* First discover all available boards. For each board we create a unique BTL */
|
|
|
|
mca_btl_gm_component.gm_btls = malloc( mca_btl_gm_component.gm_max_btls * sizeof (mca_btl_gm_module_t *));
|
|
|
|
if (NULL == mca_btl_gm_component.gm_btls) {
|
2005-07-04 03:31:27 +04:00
|
|
|
opal_output( 0, "[%s:%d] out of resources.", __FILE__, __LINE__ );
|
2006-03-02 03:39:07 +03:00
|
|
|
OPAL_THREAD_UNLOCK(&mca_btl_gm_component.gm_lock);
|
2005-06-30 22:21:55 +04:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* initialize gm */
|
|
|
|
if (OMPI_SUCCESS != mca_btl_gm_discover()) {
|
2005-09-30 08:39:44 +04:00
|
|
|
mca_btl_base_error_no_nics("Myrinet/GM", "NIC");
|
|
|
|
mca_btl_gm_component.gm_num_btls = 0;
|
|
|
|
mca_btl_gm_modex_send();
|
2006-03-02 03:39:07 +03:00
|
|
|
OPAL_THREAD_UNLOCK(&mca_btl_gm_component.gm_lock);
|
2005-06-30 22:21:55 +04:00
|
|
|
return NULL;
|
|
|
|
}
|
2005-07-02 02:24:58 +04:00
|
|
|
if (mca_btl_gm_component.gm_num_btls == 0) {
|
2005-09-30 08:39:44 +04:00
|
|
|
mca_btl_base_error_no_nics("Myrinet/GM", "NIC");
|
|
|
|
mca_btl_gm_component.gm_num_btls = 0;
|
|
|
|
mca_btl_gm_modex_send();
|
2006-03-02 03:39:07 +03:00
|
|
|
OPAL_THREAD_UNLOCK(&mca_btl_gm_component.gm_lock);
|
2005-07-02 02:24:58 +04:00
|
|
|
return NULL;
|
|
|
|
}
|
2005-06-30 22:21:55 +04:00
|
|
|
|
|
|
|
/* publish GM parameters with the MCA framework */
|
|
|
|
if (OMPI_SUCCESS != mca_btl_gm_modex_send()) {
|
2006-03-02 03:39:07 +03:00
|
|
|
OPAL_THREAD_UNLOCK(&mca_btl_gm_component.gm_lock);
|
2005-06-30 22:21:55 +04:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* return array of BTLs */
|
|
|
|
btls = (mca_btl_base_module_t**) malloc (
|
|
|
|
mca_btl_gm_component.gm_num_btls * sizeof(mca_btl_base_module_t *));
|
|
|
|
if (NULL == btls) {
|
2006-03-02 03:39:07 +03:00
|
|
|
OPAL_THREAD_UNLOCK(&mca_btl_gm_component.gm_lock);
|
2005-06-30 22:21:55 +04:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy(btls, mca_btl_gm_component.gm_btls,
|
|
|
|
mca_btl_gm_component.gm_num_btls * sizeof(mca_btl_gm_module_t *));
|
|
|
|
*num_btl_modules = mca_btl_gm_component.gm_num_btls;
|
2006-03-02 03:39:07 +03:00
|
|
|
OPAL_THREAD_UNLOCK(&mca_btl_gm_component.gm_lock);
|
2005-06-30 22:21:55 +04:00
|
|
|
return btls;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* GM component progress.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
int mca_btl_gm_component_progress()
|
|
|
|
{
|
2005-10-12 19:54:35 +04:00
|
|
|
static int32_t inprogress = 0;
|
2005-07-07 20:56:58 +04:00
|
|
|
int count = 0;
|
|
|
|
size_t i;
|
|
|
|
|
2005-10-17 22:59:28 +04:00
|
|
|
/* could get into deadlock in this case as we post recvs after callback completes */
|
2005-11-14 02:31:20 +03:00
|
|
|
if(OPAL_THREAD_ADD32(&inprogress, 1) > 1) {
|
2005-10-12 19:54:35 +04:00
|
|
|
OPAL_THREAD_ADD32(&inprogress, -1);
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2006-03-02 03:39:07 +03:00
|
|
|
OPAL_THREAD_LOCK(&mca_btl_gm_component.gm_lock);
|
2005-06-30 22:21:55 +04:00
|
|
|
for( i = 0; i < mca_btl_gm_component.gm_num_btls; ) {
|
|
|
|
mca_btl_gm_module_t* btl = mca_btl_gm_component.gm_btls[i];
|
2005-07-07 20:56:58 +04:00
|
|
|
gm_recv_event_t* event = gm_receive(btl->port);
|
2005-06-30 22:21:55 +04:00
|
|
|
|
|
|
|
/* If there are no receive events just skip the function call */
|
|
|
|
switch(gm_ntohc(event->recv.type)) {
|
|
|
|
case GM_FAST_RECV_EVENT:
|
|
|
|
case GM_FAST_PEER_RECV_EVENT:
|
|
|
|
case GM_FAST_HIGH_RECV_EVENT:
|
|
|
|
case GM_FAST_HIGH_PEER_RECV_EVENT:
|
|
|
|
{
|
2006-03-02 03:39:07 +03:00
|
|
|
unsigned char* buffer = (unsigned char*)gm_ntohp(event->recv.buffer);
|
2007-05-16 16:20:58 +04:00
|
|
|
mca_btl_gm_frag_t* frag = (mca_btl_gm_frag_t*)*((uintptr_t*)(buffer - sizeof(uintptr_t)));
|
2006-03-02 03:39:07 +03:00
|
|
|
mca_btl_base_header_t* hdr = (mca_btl_base_header_t *)gm_ntohp(event->recv.message);
|
2005-06-30 22:21:55 +04:00
|
|
|
mca_btl_base_recv_reg_t* reg;
|
2007-01-05 01:07:37 +03:00
|
|
|
frag->segment.seg_addr.pval = (hdr+1);
|
2005-07-07 20:56:58 +04:00
|
|
|
frag->segment.seg_len = gm_ntohl(event->recv.length) - sizeof(mca_btl_base_header_t);
|
2005-06-30 22:21:55 +04:00
|
|
|
reg = &btl->gm_reg[hdr->tag];
|
2006-03-02 03:39:07 +03:00
|
|
|
|
2006-08-17 00:21:38 +04:00
|
|
|
/* cbfunc may be null if interface goes down.. */
|
|
|
|
if(reg->cbfunc) {
|
|
|
|
OPAL_THREAD_UNLOCK(&mca_btl_gm_component.gm_lock);
|
|
|
|
reg->cbfunc(&btl->super, hdr->tag, &frag->base, reg->cbdata);
|
|
|
|
OPAL_THREAD_LOCK(&mca_btl_gm_component.gm_lock);
|
|
|
|
} else {
|
|
|
|
btl->error_cb(&btl->super,
|
|
|
|
MCA_BTL_ERROR_FLAGS_FATAL);
|
|
|
|
return 0;
|
|
|
|
}
|
2005-07-14 01:39:41 +04:00
|
|
|
MCA_BTL_GM_FRAG_POST(btl,frag);
|
2005-06-30 22:21:55 +04:00
|
|
|
count++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case GM_RECV_EVENT:
|
|
|
|
case GM_PEER_RECV_EVENT:
|
|
|
|
case GM_HIGH_RECV_EVENT:
|
|
|
|
case GM_HIGH_PEER_RECV_EVENT:
|
|
|
|
{
|
2006-03-02 03:39:07 +03:00
|
|
|
unsigned char* buffer = (unsigned char*)gm_ntohp(event->recv.buffer);
|
2007-05-16 16:20:58 +04:00
|
|
|
mca_btl_gm_frag_t* frag = (mca_btl_gm_frag_t*)*((uintptr_t*)(buffer - sizeof(uintptr_t)));
|
2006-03-02 03:39:07 +03:00
|
|
|
mca_btl_base_header_t* hdr = (mca_btl_base_header_t*)buffer;
|
2005-06-30 22:21:55 +04:00
|
|
|
mca_btl_base_recv_reg_t* reg;
|
2007-01-05 01:07:37 +03:00
|
|
|
frag->segment.seg_addr.pval = (hdr+1);
|
2005-07-07 20:56:58 +04:00
|
|
|
frag->segment.seg_len = gm_ntohl(event->recv.length) - sizeof(mca_btl_base_header_t);
|
2005-06-30 22:21:55 +04:00
|
|
|
reg = &btl->gm_reg[hdr->tag];
|
2006-08-17 00:21:38 +04:00
|
|
|
if(reg->cbfunc) {
|
|
|
|
OPAL_THREAD_UNLOCK(&mca_btl_gm_component.gm_lock);
|
|
|
|
reg->cbfunc(&btl->super, hdr->tag, &frag->base, reg->cbdata);
|
|
|
|
OPAL_THREAD_LOCK(&mca_btl_gm_component.gm_lock);
|
|
|
|
|
|
|
|
MCA_BTL_GM_FRAG_POST(btl,frag);
|
|
|
|
} else {
|
|
|
|
btl->error_cb(&btl->super,
|
|
|
|
MCA_BTL_ERROR_FLAGS_FATAL);
|
|
|
|
return 0;
|
|
|
|
}
|
2005-06-30 22:21:55 +04:00
|
|
|
count++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case GM_NO_RECV_EVENT:
|
|
|
|
i++;
|
|
|
|
break;
|
|
|
|
default:
|
2005-07-07 20:56:58 +04:00
|
|
|
gm_unknown(btl->port, event);
|
2005-06-30 22:21:55 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2006-03-02 03:39:07 +03:00
|
|
|
OPAL_THREAD_UNLOCK(&mca_btl_gm_component.gm_lock);
|
2005-10-12 19:54:35 +04:00
|
|
|
OPAL_THREAD_ADD32(&inprogress, -1);
|
2005-06-30 22:21:55 +04:00
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2006-03-02 03:39:07 +03:00
|
|
|
|
|
|
|
#if OMPI_ENABLE_PROGRESS_THREADS
|
|
|
|
static void* mca_btl_gm_progress_thread( opal_object_t* arg )
|
|
|
|
{
|
|
|
|
opal_thread_t* thread = (opal_thread_t*)arg;
|
|
|
|
mca_btl_gm_module_t* btl = thread->t_arg;
|
|
|
|
|
|
|
|
/* This thread enter in a cancel enabled state */
|
|
|
|
pthread_setcancelstate( PTHREAD_CANCEL_ENABLE, NULL );
|
|
|
|
pthread_setcanceltype( PTHREAD_CANCEL_ASYNCHRONOUS, NULL );
|
|
|
|
|
|
|
|
OPAL_THREAD_LOCK(&mca_btl_gm_component.gm_lock);
|
2006-03-16 03:05:39 +03:00
|
|
|
while(btl->gm_progress) {
|
2006-03-02 03:39:07 +03:00
|
|
|
gm_recv_event_t* event;
|
|
|
|
|
|
|
|
/* dont process events while the app is in the library */
|
|
|
|
while(opal_progress_threads()) {
|
|
|
|
OPAL_THREAD_UNLOCK(&mca_btl_gm_component.gm_lock);
|
|
|
|
while(opal_progress_threads())
|
|
|
|
sched_yield();
|
|
|
|
usleep(100); /* give app a chance to re-enter library */
|
|
|
|
OPAL_THREAD_LOCK(&mca_btl_gm_component.gm_lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* otherwise processes any pending events */
|
|
|
|
event = gm_blocking_receive_no_spin(btl->port);
|
|
|
|
switch(gm_ntohc(event->recv.type)) {
|
|
|
|
case GM_FAST_RECV_EVENT:
|
|
|
|
case GM_FAST_PEER_RECV_EVENT:
|
|
|
|
case GM_FAST_HIGH_RECV_EVENT:
|
|
|
|
case GM_FAST_HIGH_PEER_RECV_EVENT:
|
|
|
|
{
|
|
|
|
unsigned char* buffer = (unsigned char*)gm_ntohp(event->recv.buffer);
|
2007-05-16 16:20:58 +04:00
|
|
|
mca_btl_gm_frag_t* frag = (mca_btl_gm_frag_t*)*((uintptr_t*)(buffer - sizeof(uintptr_t)));
|
2006-03-02 03:39:07 +03:00
|
|
|
mca_btl_base_header_t* hdr = (mca_btl_base_header_t *)gm_ntohp(event->recv.message);
|
|
|
|
mca_btl_base_recv_reg_t* reg;
|
2007-01-05 01:07:37 +03:00
|
|
|
frag->segment.seg_addr.pval = (hdr+1);
|
2006-03-02 03:39:07 +03:00
|
|
|
frag->segment.seg_len = gm_ntohl(event->recv.length) - sizeof(mca_btl_base_header_t);
|
|
|
|
reg = &btl->gm_reg[hdr->tag];
|
|
|
|
|
|
|
|
OPAL_THREAD_UNLOCK(&mca_btl_gm_component.gm_lock);
|
|
|
|
reg->cbfunc(&btl->super, hdr->tag, &frag->base, reg->cbdata);
|
|
|
|
OPAL_THREAD_LOCK(&mca_btl_gm_component.gm_lock);
|
|
|
|
|
|
|
|
MCA_BTL_GM_FRAG_POST(btl,frag);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case GM_RECV_EVENT:
|
|
|
|
case GM_PEER_RECV_EVENT:
|
|
|
|
case GM_HIGH_RECV_EVENT:
|
|
|
|
case GM_HIGH_PEER_RECV_EVENT:
|
|
|
|
{
|
|
|
|
unsigned char* buffer = (unsigned char*)gm_ntohp(event->recv.buffer);
|
2007-05-16 16:20:58 +04:00
|
|
|
mca_btl_gm_frag_t* frag = (mca_btl_gm_frag_t*)*((uintptr_t*)(buffer - sizeof(uintptr_t)));
|
2006-03-02 03:39:07 +03:00
|
|
|
mca_btl_base_header_t* hdr = (mca_btl_base_header_t*)buffer;
|
|
|
|
mca_btl_base_recv_reg_t* reg;
|
2007-01-05 01:07:37 +03:00
|
|
|
frag->segment.seg_addr.pval = (hdr+1);
|
2006-03-02 03:39:07 +03:00
|
|
|
frag->segment.seg_len = gm_ntohl(event->recv.length) - sizeof(mca_btl_base_header_t);
|
|
|
|
reg = &btl->gm_reg[hdr->tag];
|
|
|
|
|
|
|
|
OPAL_THREAD_UNLOCK(&mca_btl_gm_component.gm_lock);
|
|
|
|
reg->cbfunc(&btl->super, hdr->tag, &frag->base, reg->cbdata);
|
|
|
|
OPAL_THREAD_LOCK(&mca_btl_gm_component.gm_lock);
|
|
|
|
|
|
|
|
MCA_BTL_GM_FRAG_POST(btl,frag);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case _GM_SLEEP_EVENT:
|
|
|
|
OPAL_THREAD_UNLOCK(&mca_btl_gm_component.gm_lock);
|
|
|
|
gm_unknown(btl->port, event);
|
|
|
|
OPAL_THREAD_LOCK(&mca_btl_gm_component.gm_lock);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
gm_unknown(btl->port, event);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
OPAL_THREAD_UNLOCK(&mca_btl_gm_component.gm_lock);
|
|
|
|
return PTHREAD_CANCELED;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|