2005-05-24 02:06:50 +04:00
|
|
|
/*
|
2011-07-11 03:32:23 +04:00
|
|
|
* Copyright (c) 2004-2011 The Trustees of Indiana University and Indiana
|
2005-11-05 22:57:48 +03:00
|
|
|
* University Research and Technology
|
|
|
|
* Corporation. All rights reserved.
|
2009-12-16 02:34:09 +03:00
|
|
|
* Copyright (c) 2004-2009 The University of Tennessee and The University
|
2005-11-05 22:57:48 +03:00
|
|
|
* of Tennessee Research Foundation. All rights
|
|
|
|
* reserved.
|
2008-03-09 16:17:13 +03:00
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
2005-05-24 02:06:50 +04:00
|
|
|
* University of Stuttgart. All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
2007-10-22 16:07:22 +04:00
|
|
|
* Copyright (c) 2006-2007 Voltaire. All rights reserved.
|
2010-06-09 20:58:52 +04:00
|
|
|
* Copyright (c) 2009-2010 Cisco Systems, Inc. All rights reserved.
|
2013-01-11 20:24:56 +04:00
|
|
|
* Copyright (c) 2010-2013 Los Alamos National Security, LLC.
|
2011-06-21 19:41:57 +04:00
|
|
|
* All rights reserved.
|
2011-06-09 17:57:46 +04:00
|
|
|
* Copyright (c) 2011 NVIDIA Corporation. All rights reserved.
|
2012-03-14 10:29:09 +04:00
|
|
|
* Copyright (c) 2010-2012 IBM Corporation. All rights reserved.
|
2005-05-24 02:06:50 +04:00
|
|
|
* $COPYRIGHT$
|
2008-03-09 16:17:13 +03:00
|
|
|
*
|
2005-05-24 02:06:50 +04:00
|
|
|
* Additional copyrights may follow
|
2008-03-09 16:17:13 +03:00
|
|
|
*
|
2005-05-24 02:06:50 +04:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
#include "ompi_config.h"
|
|
|
|
#include <errno.h>
|
2005-12-11 01:04:28 +03:00
|
|
|
#ifdef HAVE_UNISTD_H
|
2005-05-24 02:06:50 +04:00
|
|
|
#include <unistd.h>
|
2005-12-11 01:04:28 +03:00
|
|
|
#endif /* HAVE_UNISTD_H */
|
|
|
|
#ifdef HAVE_STRING_H
|
2005-05-24 02:06:50 +04:00
|
|
|
#include <string.h>
|
2005-12-11 01:04:28 +03:00
|
|
|
#endif /* HAVE_STRING_H */
|
|
|
|
#ifdef HAVE_FCNTL_H
|
2005-05-24 02:06:50 +04:00
|
|
|
#include <fcntl.h>
|
2005-12-11 01:04:28 +03:00
|
|
|
#endif /* HAVE_FCNTL_H */
|
|
|
|
#ifdef HAVE_SYS_TYPES_H
|
2005-05-24 02:06:50 +04:00
|
|
|
#include <sys/types.h>
|
2005-12-11 01:04:28 +03:00
|
|
|
#endif /* HAVE_SYS_TYPES_H */
|
|
|
|
#ifdef HAVE_SYS_MMAN_H
|
2005-05-24 02:06:50 +04:00
|
|
|
#include <sys/mman.h>
|
2005-12-11 01:04:28 +03:00
|
|
|
#endif /* HAVE_SYS_MMAN_H */
|
|
|
|
#ifdef HAVE_SYS_STAT_H
|
2005-05-24 02:06:50 +04:00
|
|
|
#include <sys/stat.h> /* for mkfifo */
|
2005-12-11 01:04:28 +03:00
|
|
|
#endif /* HAVE_SYS_STAT_H */
|
2005-05-24 02:06:50 +04:00
|
|
|
|
2013-01-11 20:24:56 +04:00
|
|
|
#include "opal/mca/shmem/base/base.h"
|
|
|
|
#include "opal/mca/shmem/shmem.h"
|
- Check, whether the compiler supports __builtin_clz (count leading
zeroes);
if so, use it for bit-operations like opal_cube_dim and opal_hibit.
Implement two versions of power-of-two.
In case of opal_next_poweroftwo, this reduces the average execution
time from 83 cycles to 4 cycles (Intel Nehalem, icc, -O2, inlining,
measured rdtsc, with loop over 2^27 values).
Numbers for other functions are similar (but of course heavily depend
on the usage, e.g. opal_hibit() with a start of 4 does not save
much). The bsr instruction on AMD Opteron is also not as fast.
- Replace various places where the next power-of-two is computed.
Tested on Intel Nehalem Cluster with openib, compilers GNU-4.6.1 and
Intel-12.0.4 using mpi_testsuite -t "Collective" with 128 processes.
This commit was SVN r25270.
2011-10-12 02:49:01 +04:00
|
|
|
#include "opal/util/bit_ops.h"
|
2009-02-14 05:26:12 +03:00
|
|
|
#include "opal/util/output.h"
|
2013-02-13 01:10:11 +04:00
|
|
|
#include "opal/util/show_help.h"
|
2013-01-11 20:24:56 +04:00
|
|
|
|
|
|
|
#include "ompi/constants.h"
|
|
|
|
#include "ompi/runtime/ompi_module_exchange.h"
|
2006-02-12 04:33:29 +03:00
|
|
|
#include "ompi/mca/mpool/base/base.h"
|
2010-06-09 20:58:52 +04:00
|
|
|
#include "ompi/mca/common/sm/common_sm.h"
|
2007-02-13 15:01:36 +03:00
|
|
|
#include "ompi/mca/btl/base/btl_base_error.h"
|
2013-02-22 21:48:53 +04:00
|
|
|
#include "ompi/mca/rte/rte.h"
|
2008-10-16 19:09:00 +04:00
|
|
|
|
2010-03-13 02:57:50 +03:00
|
|
|
#if OPAL_ENABLE_FT_CR == 1
|
2008-10-16 19:09:00 +04:00
|
|
|
#include "opal/runtime/opal_cr.h"
|
|
|
|
#endif
|
|
|
|
|
2005-06-30 09:50:55 +04:00
|
|
|
#include "btl_sm.h"
|
|
|
|
#include "btl_sm_frag.h"
|
2005-07-28 20:25:09 +04:00
|
|
|
#include "btl_sm_fifo.h"
|
|
|
|
|
2010-06-09 20:58:52 +04:00
|
|
|
static int mca_btl_sm_component_open(void);
|
|
|
|
static int mca_btl_sm_component_close(void);
|
|
|
|
static int sm_register(void);
|
|
|
|
static mca_btl_base_module_t** mca_btl_sm_component_init(
|
|
|
|
int *num_btls,
|
|
|
|
bool enable_progress_threads,
|
|
|
|
bool enable_mpi_threads
|
|
|
|
);
|
|
|
|
|
2013-01-11 20:24:56 +04:00
|
|
|
typedef enum {
|
|
|
|
MCA_BTL_SM_RNDV_MOD_SM = 0,
|
|
|
|
MCA_BTL_SM_RNDV_MOD_MPOOL
|
|
|
|
} mca_btl_sm_rndv_module_type_t;
|
2010-06-09 20:58:52 +04:00
|
|
|
|
2005-05-24 02:06:50 +04:00
|
|
|
/*
|
2008-03-09 16:17:13 +03:00
|
|
|
* Shared Memory (SM) component instance.
|
2005-05-24 02:06:50 +04:00
|
|
|
*/
|
2005-06-30 09:50:55 +04:00
|
|
|
mca_btl_sm_component_t mca_btl_sm_component = {
|
2005-05-24 02:06:50 +04:00
|
|
|
{ /* super is being filled in */
|
|
|
|
/* First, the mca_base_component_t struct containing meta information
|
|
|
|
about the component itself */
|
|
|
|
{
|
2008-07-29 02:40:57 +04:00
|
|
|
MCA_BTL_BASE_VERSION_2_0_0,
|
|
|
|
|
2005-05-24 02:06:50 +04:00
|
|
|
"sm", /* 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 09:50:55 +04:00
|
|
|
mca_btl_sm_component_open, /* component open */
|
2010-06-09 20:58:52 +04:00
|
|
|
mca_btl_sm_component_close, /* component close */
|
|
|
|
NULL,
|
|
|
|
sm_register,
|
2005-05-24 02:06:50 +04:00
|
|
|
},
|
|
|
|
{
|
2008-10-16 19:09:00 +04:00
|
|
|
/* The component is checkpoint ready */
|
|
|
|
MCA_BASE_METADATA_PARAM_CHECKPOINT
|
2005-05-24 02:06:50 +04:00
|
|
|
},
|
|
|
|
|
2008-03-09 16:17:13 +03:00
|
|
|
mca_btl_sm_component_init,
|
2005-06-30 09:50:55 +04:00
|
|
|
mca_btl_sm_component_progress,
|
2005-05-24 02:06:50 +04:00
|
|
|
} /* end super */
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* utility routines for parameter registration
|
|
|
|
*/
|
|
|
|
|
2013-03-28 01:09:41 +04:00
|
|
|
static inline int mca_btl_sm_param_register_int(
|
2008-03-09 16:17:13 +03:00
|
|
|
const char* param_name,
|
2013-03-28 01:09:41 +04:00
|
|
|
int default_value,
|
2013-07-10 04:47:52 +04:00
|
|
|
int level,
|
2013-03-28 01:09:41 +04:00
|
|
|
int *storage)
|
2005-05-24 02:06:50 +04:00
|
|
|
{
|
2013-03-28 01:09:41 +04:00
|
|
|
*storage = default_value;
|
|
|
|
(void) mca_base_component_var_register (&mca_btl_sm_component.super.btl_version,
|
|
|
|
param_name, NULL, MCA_BASE_VAR_TYPE_INT,
|
2013-07-10 04:47:52 +04:00
|
|
|
NULL, 0, 0, level,
|
2013-03-28 01:09:41 +04:00
|
|
|
MCA_BASE_VAR_SCOPE_READONLY, storage);
|
|
|
|
return *storage;
|
2005-05-24 02:06:50 +04:00
|
|
|
}
|
2008-03-09 16:17:13 +03:00
|
|
|
|
2013-03-28 01:09:41 +04:00
|
|
|
static inline unsigned int mca_btl_sm_param_register_uint(
|
2008-03-09 16:17:13 +03:00
|
|
|
const char* param_name,
|
2013-03-28 01:09:41 +04:00
|
|
|
unsigned int default_value,
|
2013-07-10 04:47:52 +04:00
|
|
|
int level,
|
2013-03-28 01:09:41 +04:00
|
|
|
unsigned int *storage)
|
2005-05-24 02:06:50 +04:00
|
|
|
{
|
2013-03-28 01:09:41 +04:00
|
|
|
*storage = default_value;
|
|
|
|
(void) mca_base_component_var_register (&mca_btl_sm_component.super.btl_version,
|
|
|
|
param_name, NULL, MCA_BASE_VAR_TYPE_UNSIGNED_INT,
|
2013-07-10 04:47:52 +04:00
|
|
|
NULL, 0, 0, level,
|
2013-03-28 01:09:41 +04:00
|
|
|
MCA_BASE_VAR_SCOPE_READONLY, storage);
|
|
|
|
return *storage;
|
|
|
|
}
|
2012-10-30 23:45:18 +04:00
|
|
|
|
2013-03-28 01:09:41 +04:00
|
|
|
static int mca_btl_sm_component_verify(void) {
|
|
|
|
#if OMPI_BTL_SM_HAVE_KNEM || OMPI_BTL_SM_HAVE_CMA
|
|
|
|
if (mca_btl_sm_component.use_knem || mca_btl_sm_component.use_cma) {
|
|
|
|
mca_btl_sm.super.btl_flags |= MCA_BTL_FLAGS_GET;
|
|
|
|
}
|
2012-10-30 23:45:18 +04:00
|
|
|
|
2013-03-28 01:09:41 +04:00
|
|
|
if (mca_btl_sm_component.use_knem && mca_btl_sm_component.use_cma) {
|
|
|
|
/* Disable CMA if knem is runtime enabled */
|
|
|
|
opal_output(0, "CMA disabled because knem is enabled");
|
|
|
|
mca_btl_sm_component.use_cma = 0;
|
|
|
|
}
|
2005-05-24 02:06:50 +04:00
|
|
|
|
2013-03-28 01:09:41 +04:00
|
|
|
#endif /* OMPI_BTL_SM_HAVE_KNEM || OMPI_BTL_SM_HAVE_CMA */
|
|
|
|
|
|
|
|
return mca_btl_base_param_verify(&mca_btl_sm.super);
|
|
|
|
}
|
2005-05-24 02:06:50 +04:00
|
|
|
|
2010-06-09 20:58:52 +04:00
|
|
|
static int sm_register(void)
|
2005-05-24 02:06:50 +04:00
|
|
|
{
|
2013-03-28 01:09:41 +04:00
|
|
|
mca_base_var_flag_t var_flags;
|
2009-12-16 02:34:09 +03:00
|
|
|
|
|
|
|
if (OMPI_BTL_SM_HAVE_KNEM) {
|
2013-03-28 01:09:41 +04:00
|
|
|
var_flags = 0;
|
|
|
|
mca_btl_sm_component.use_knem = -1;
|
2009-12-16 02:34:09 +03:00
|
|
|
} else {
|
2013-03-28 01:09:41 +04:00
|
|
|
var_flags = MCA_BASE_VAR_FLAG_DEFAULT_ONLY;
|
2009-12-16 02:34:09 +03:00
|
|
|
mca_btl_sm_component.use_knem = 0;
|
|
|
|
}
|
2013-03-28 01:09:41 +04:00
|
|
|
(void) mca_base_component_var_register(&mca_btl_sm_component.super.btl_version,
|
|
|
|
"use_knem", "Whether knem support is desired or not "
|
|
|
|
"(negative = try to enable knem support, but continue "
|
|
|
|
"even if it is not available, 0 = do not enable knem "
|
|
|
|
"support, positive = try to enable knem support and "
|
|
|
|
"fail if it is not available)", MCA_BASE_VAR_TYPE_INT,
|
|
|
|
NULL, 0, var_flags, OPAL_INFO_LVL_9,
|
|
|
|
MCA_BASE_VAR_SCOPE_READONLY, &mca_btl_sm_component.use_knem);
|
|
|
|
|
2009-12-16 02:34:09 +03:00
|
|
|
/* Currently disabling DMA mode by default; it's not clear that
|
|
|
|
this is useful in all applications and architectures. */
|
2013-03-28 01:09:41 +04:00
|
|
|
mca_btl_sm_component.knem_dma_min = 0;
|
|
|
|
(void) mca_base_component_var_register(&mca_btl_sm_component.super.btl_version,
|
|
|
|
"knem_dma_min",
|
|
|
|
"Minimum message size (in bytes) to use the knem DMA mode; "
|
|
|
|
"ignored if knem does not support DMA mode (0 = do not use the "
|
|
|
|
"knem DMA mode)", MCA_BASE_VAR_TYPE_UNSIGNED_INT, NULL, 0,
|
|
|
|
0, OPAL_INFO_LVL_9, MCA_BASE_VAR_SCOPE_READONLY,
|
|
|
|
&mca_btl_sm_component.knem_dma_min);
|
|
|
|
|
|
|
|
mca_btl_sm_component.knem_max_simultaneous = 0;
|
|
|
|
(void) mca_base_component_var_register(&mca_btl_sm_component.super.btl_version,
|
|
|
|
"knem_max_simultaneous",
|
|
|
|
"Max number of simultaneous ongoing knem operations to support "
|
|
|
|
"(0 = do everything synchronously, which probably gives the "
|
|
|
|
"best large message latency; >0 means to do all operations "
|
|
|
|
"asynchronously, which supports better overlap for simultaneous "
|
|
|
|
"large message sends)", MCA_BASE_VAR_TYPE_UNSIGNED_INT, NULL, 0,
|
|
|
|
0, OPAL_INFO_LVL_9, MCA_BASE_VAR_SCOPE_READONLY,
|
|
|
|
&mca_btl_sm_component.knem_max_simultaneous);
|
2009-12-16 02:34:09 +03:00
|
|
|
|
2012-03-14 10:29:09 +04:00
|
|
|
/* CMA parameters */
|
2013-03-28 01:09:41 +04:00
|
|
|
mca_btl_sm_component.use_cma = 0;
|
|
|
|
(void) mca_base_component_var_register(&mca_btl_sm_component.super.btl_version,
|
|
|
|
"use_cma", "Whether or not to enable CMA",
|
|
|
|
MCA_BASE_VAR_TYPE_UNSIGNED_INT, NULL, 0, 0,
|
|
|
|
OPAL_INFO_LVL_9, MCA_BASE_VAR_SCOPE_READONLY,
|
|
|
|
&mca_btl_sm_component.use_cma);
|
2012-03-14 10:29:09 +04:00
|
|
|
|
2005-05-24 02:06:50 +04:00
|
|
|
/* register SM component parameters */
|
2013-07-10 04:47:52 +04:00
|
|
|
mca_btl_sm_param_register_int("free_list_num", 8, OPAL_INFO_LVL_5, &mca_btl_sm_component.sm_free_list_num);
|
|
|
|
mca_btl_sm_param_register_int("free_list_max", -1, OPAL_INFO_LVL_5, &mca_btl_sm_component.sm_free_list_max);
|
|
|
|
mca_btl_sm_param_register_int("free_list_inc", 64, OPAL_INFO_LVL_5, &mca_btl_sm_component.sm_free_list_inc);
|
|
|
|
mca_btl_sm_param_register_int("max_procs", -1, OPAL_INFO_LVL_5, &mca_btl_sm_component.sm_max_procs);
|
2013-03-28 01:09:41 +04:00
|
|
|
/* there is no practical use for the mpool name parameter since mpool resources differ
|
|
|
|
between components */
|
|
|
|
mca_btl_sm_component.sm_mpool_name = "sm";
|
2013-07-10 04:47:52 +04:00
|
|
|
mca_btl_sm_param_register_uint("fifo_size", 4096, OPAL_INFO_LVL_4, &mca_btl_sm_component.fifo_size);
|
|
|
|
mca_btl_sm_param_register_int("num_fifos", 1, OPAL_INFO_LVL_4, &mca_btl_sm_component.nfifos);
|
2013-03-28 01:09:41 +04:00
|
|
|
|
2013-07-10 04:47:52 +04:00
|
|
|
mca_btl_sm_param_register_uint("fifo_lazy_free", 120, OPAL_INFO_LVL_5, &mca_btl_sm_component.fifo_lazy_free);
|
2010-06-09 20:58:52 +04:00
|
|
|
|
|
|
|
/* default number of extra procs to allow for future growth */
|
2013-07-10 04:47:52 +04:00
|
|
|
mca_btl_sm_param_register_int("sm_extra_procs", 0, OPAL_INFO_LVL_9, &mca_btl_sm_component.sm_extra_procs);
|
2010-06-09 20:58:52 +04:00
|
|
|
|
2011-06-09 17:57:46 +04:00
|
|
|
mca_btl_sm.super.btl_exclusivity = MCA_BTL_EXCLUSIVITY_HIGH-1;
|
|
|
|
mca_btl_sm.super.btl_eager_limit = 4*1024;
|
|
|
|
mca_btl_sm.super.btl_rndv_eager_limit = 4*1024;
|
|
|
|
mca_btl_sm.super.btl_max_send_size = 32*1024;
|
|
|
|
mca_btl_sm.super.btl_rdma_pipeline_send_length = 64*1024;
|
|
|
|
mca_btl_sm.super.btl_rdma_pipeline_frag_size = 64*1024;
|
|
|
|
mca_btl_sm.super.btl_min_rdma_pipeline_size = 64*1024;
|
|
|
|
mca_btl_sm.super.btl_flags = MCA_BTL_FLAGS_SEND;
|
2012-06-21 21:09:12 +04:00
|
|
|
mca_btl_sm.super.btl_seg_size = sizeof (mca_btl_sm_segment_t);
|
2011-06-09 17:57:46 +04:00
|
|
|
mca_btl_sm.super.btl_bandwidth = 9000; /* Mbs */
|
|
|
|
mca_btl_sm.super.btl_latency = 1; /* Microsecs */
|
|
|
|
|
2010-06-09 20:58:52 +04:00
|
|
|
/* Call the BTL based to register its MCA params */
|
|
|
|
mca_btl_base_param_register(&mca_btl_sm_component.super.btl_version,
|
|
|
|
&mca_btl_sm.super);
|
|
|
|
|
2013-03-28 01:09:41 +04:00
|
|
|
return mca_btl_sm_component_verify();
|
2010-06-09 20:58:52 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Called by MCA framework to open the component, registers
|
|
|
|
* component parameters.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int mca_btl_sm_component_open(void)
|
|
|
|
{
|
2013-03-28 01:09:41 +04:00
|
|
|
if (OMPI_SUCCESS != mca_btl_sm_component_verify()) {
|
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
|
|
|
|
2010-06-09 20:58:52 +04:00
|
|
|
mca_btl_sm_component.sm_max_btls = 1;
|
- Check, whether the compiler supports __builtin_clz (count leading
zeroes);
if so, use it for bit-operations like opal_cube_dim and opal_hibit.
Implement two versions of power-of-two.
In case of opal_next_poweroftwo, this reduces the average execution
time from 83 cycles to 4 cycles (Intel Nehalem, icc, -O2, inlining,
measured rdtsc, with loop over 2^27 values).
Numbers for other functions are similar (but of course heavily depend
on the usage, e.g. opal_hibit() with a start of 4 does not save
much). The bsr instruction on AMD Opteron is also not as fast.
- Replace various places where the next power-of-two is computed.
Tested on Intel Nehalem Cluster with openib, compilers GNU-4.6.1 and
Intel-12.0.4 using mpi_testsuite -t "Collective" with 128 processes.
This commit was SVN r25270.
2011-10-12 02:49:01 +04:00
|
|
|
|
2009-02-17 18:58:15 +03:00
|
|
|
/* make sure the number of fifos is a power of 2 */
|
- Check, whether the compiler supports __builtin_clz (count leading
zeroes);
if so, use it for bit-operations like opal_cube_dim and opal_hibit.
Implement two versions of power-of-two.
In case of opal_next_poweroftwo, this reduces the average execution
time from 83 cycles to 4 cycles (Intel Nehalem, icc, -O2, inlining,
measured rdtsc, with loop over 2^27 values).
Numbers for other functions are similar (but of course heavily depend
on the usage, e.g. opal_hibit() with a start of 4 does not save
much). The bsr instruction on AMD Opteron is also not as fast.
- Replace various places where the next power-of-two is computed.
Tested on Intel Nehalem Cluster with openib, compilers GNU-4.6.1 and
Intel-12.0.4 using mpi_testsuite -t "Collective" with 128 processes.
This commit was SVN r25270.
2011-10-12 02:49:01 +04:00
|
|
|
mca_btl_sm_component.nfifos = opal_next_poweroftwo_inclusive (mca_btl_sm_component.nfifos);
|
2009-02-17 18:58:15 +03:00
|
|
|
|
|
|
|
/* make sure that queue size and lazy free parameter are compatible */
|
|
|
|
if (mca_btl_sm_component.fifo_lazy_free >= (mca_btl_sm_component.fifo_size >> 1) )
|
|
|
|
mca_btl_sm_component.fifo_lazy_free = (mca_btl_sm_component.fifo_size >> 1);
|
|
|
|
if (mca_btl_sm_component.fifo_lazy_free <= 0)
|
|
|
|
mca_btl_sm_component.fifo_lazy_free = 1;
|
2005-05-24 02:06:50 +04:00
|
|
|
|
2007-05-17 11:54:27 +04:00
|
|
|
mca_btl_sm_component.max_frag_size = mca_btl_sm.super.btl_max_send_size;
|
|
|
|
mca_btl_sm_component.eager_limit = mca_btl_sm.super.btl_eager_limit;
|
|
|
|
|
2005-05-24 02:06:50 +04:00
|
|
|
/* initialize objects */
|
2005-07-04 02:45:48 +04:00
|
|
|
OBJ_CONSTRUCT(&mca_btl_sm_component.sm_lock, opal_mutex_t);
|
2008-05-30 07:58:39 +04:00
|
|
|
OBJ_CONSTRUCT(&mca_btl_sm_component.sm_frags_eager, ompi_free_list_t);
|
|
|
|
OBJ_CONSTRUCT(&mca_btl_sm_component.sm_frags_max, ompi_free_list_t);
|
2009-12-16 02:34:09 +03:00
|
|
|
OBJ_CONSTRUCT(&mca_btl_sm_component.sm_frags_user, ompi_free_list_t);
|
2007-10-22 16:07:22 +04:00
|
|
|
OBJ_CONSTRUCT(&mca_btl_sm_component.pending_send_fl, opal_free_list_t);
|
2013-12-13 10:01:24 +04:00
|
|
|
|
|
|
|
mca_btl_sm_component.sm_seg = NULL;
|
|
|
|
#if OMPI_BTL_SM_HAVE_KNEM
|
|
|
|
mca_btl_sm.knem_fd = -1;
|
|
|
|
mca_btl_sm.knem_status_array = NULL;
|
|
|
|
mca_btl_sm.knem_frag_array = NULL;
|
|
|
|
mca_btl_sm.knem_status_num_used = 0;
|
|
|
|
mca_btl_sm.knem_status_first_avail = 0;
|
|
|
|
mca_btl_sm.knem_status_first_used = 0;
|
|
|
|
#endif
|
|
|
|
|
2005-05-24 02:06:50 +04:00
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* component cleanup - sanity checking of queue lengths
|
|
|
|
*/
|
|
|
|
|
2010-06-09 20:58:52 +04:00
|
|
|
static int mca_btl_sm_component_close(void)
|
2005-05-24 02:06:50 +04:00
|
|
|
{
|
2006-07-13 02:12:07 +04:00
|
|
|
int return_value = OMPI_SUCCESS;
|
2005-05-24 02:06:50 +04:00
|
|
|
|
2009-12-16 02:34:09 +03:00
|
|
|
#if OMPI_BTL_SM_HAVE_KNEM
|
|
|
|
if (NULL != mca_btl_sm.knem_frag_array) {
|
|
|
|
free(mca_btl_sm.knem_frag_array);
|
|
|
|
mca_btl_sm.knem_frag_array = NULL;
|
|
|
|
}
|
|
|
|
if (NULL != mca_btl_sm.knem_status_array) {
|
|
|
|
munmap(mca_btl_sm.knem_status_array,
|
|
|
|
mca_btl_sm_component.knem_max_simultaneous);
|
|
|
|
mca_btl_sm.knem_status_array = NULL;
|
|
|
|
}
|
|
|
|
if (-1 != mca_btl_sm.knem_fd) {
|
|
|
|
close(mca_btl_sm.knem_fd);
|
|
|
|
mca_btl_sm.knem_fd = -1;
|
|
|
|
}
|
2013-01-13 20:08:48 +04:00
|
|
|
#endif /* OMPI_BTL_SM_HAVE_KNEM */
|
2009-12-16 02:34:09 +03:00
|
|
|
|
2005-06-30 09:50:55 +04:00
|
|
|
OBJ_DESTRUCT(&mca_btl_sm_component.sm_lock);
|
2006-07-13 11:42:18 +04:00
|
|
|
/**
|
|
|
|
* We don't have to destroy the fragment lists. They are allocated
|
2010-03-10 00:23:21 +03:00
|
|
|
* directly into the mmapped file, they will auto-magically disappear
|
2006-07-13 11:42:18 +04:00
|
|
|
* when the file get unmapped.
|
|
|
|
*/
|
2008-05-30 07:58:39 +04:00
|
|
|
/*OBJ_DESTRUCT(&mca_btl_sm_component.sm_frags_eager);*/
|
|
|
|
/*OBJ_DESTRUCT(&mca_btl_sm_component.sm_frags_max);*/
|
2005-05-24 02:06:50 +04:00
|
|
|
|
|
|
|
/* unmap the shared memory control structure */
|
2010-06-09 20:58:52 +04:00
|
|
|
if(mca_btl_sm_component.sm_seg != NULL) {
|
|
|
|
return_value = mca_common_sm_fini( mca_btl_sm_component.sm_seg );
|
2006-07-13 02:12:07 +04:00
|
|
|
if( OMPI_SUCCESS != return_value ) {
|
2005-05-24 02:06:50 +04:00
|
|
|
return_value=OMPI_ERROR;
|
2011-06-21 19:41:57 +04:00
|
|
|
opal_output(0," mca_common_sm_fini failed\n");
|
2005-05-24 02:06:50 +04:00
|
|
|
goto CLEANUP;
|
|
|
|
}
|
2008-03-09 16:17:13 +03:00
|
|
|
|
2005-05-24 02:06:50 +04:00
|
|
|
/* unlink file, so that it will be deleted when all references
|
|
|
|
* to it are gone - no error checking, since we want all procs
|
2005-12-31 18:07:48 +03:00
|
|
|
* to call this, so that in an abnormal termination scenario,
|
2005-05-24 02:06:50 +04:00
|
|
|
* this file will still get cleaned up */
|
2010-03-13 02:57:50 +03:00
|
|
|
#if OPAL_ENABLE_FT_CR == 1
|
2008-10-16 19:09:00 +04:00
|
|
|
/* Only unlink the file if we are *not* restarting
|
|
|
|
* If we are restarting the file will be unlinked at a later time.
|
|
|
|
*/
|
|
|
|
if(OPAL_CR_STATUS_RESTART_PRE != opal_cr_checkpointing_state &&
|
|
|
|
OPAL_CR_STATUS_RESTART_POST != opal_cr_checkpointing_state ) {
|
2011-07-11 03:32:23 +04:00
|
|
|
unlink(mca_btl_sm_component.sm_seg->shmem_ds.seg_name);
|
2008-10-16 19:09:00 +04:00
|
|
|
}
|
|
|
|
#else
|
2011-06-21 19:41:57 +04:00
|
|
|
unlink(mca_btl_sm_component.sm_seg->shmem_ds.seg_name);
|
2008-10-16 19:09:00 +04:00
|
|
|
#endif
|
2010-06-09 20:58:52 +04:00
|
|
|
OBJ_RELEASE(mca_btl_sm_component.sm_seg);
|
2005-05-24 02:06:50 +04:00
|
|
|
}
|
|
|
|
|
Update libevent to the 2.0 series, currently at 2.0.7rc. We will update to their final release when it becomes available. Currently known errors exist in unused portions of the libevent code. This revision passes the IBM test suite on a Linux machine and on a standalone Mac.
This is a fairly intrusive change, but outside of the moving of opal/event to opal/mca/event, the only changes involved (a) changing all calls to opal_event functions to reflect the new framework instead, and (b) ensuring that all opal_event_t objects are properly constructed since they are now true opal_objects.
Note: Shiqing has just returned from vacation and has not yet had a chance to complete the Windows integration. Thus, this commit almost certainly breaks Windows support on the trunk. However, I want this to have a chance to soak for as long as possible before I become less available a week from today (going to be at a class for 5 days, and thus will only be sparingly available) so we can find and fix any problems.
Biggest change is moving the libevent code from opal/event to a new opal/mca/event framework. This was done to make it much easier to update libevent in the future. New versions can be inserted as a new component and tested in parallel with the current version until validated, then we can remove the earlier version if we so choose. This is a statically built framework ala installdirs, so only one component will build at a time. There is no selection logic - the sole compiled component simply loads its function pointers into the opal_event struct.
I have gone thru the code base and converted all the libevent calls I could find. However, I cannot compile nor test every environment. It is therefore quite likely that errors remain in the system. Please keep an eye open for two things:
1. compile-time errors: these will be obvious as calls to the old functions (e.g., opal_evtimer_new) must be replaced by the new framework APIs (e.g., opal_event.evtimer_new)
2. run-time errors: these will likely show up as segfaults due to missing constructors on opal_event_t objects. It appears that it became a typical practice for people to "init" an opal_event_t by simply using memset to zero it out. This will no longer work - you must either OBJ_NEW or OBJ_CONSTRUCT an opal_event_t. I tried to catch these cases, but may have missed some. Believe me, you'll know when you hit it.
There is also the issue of the new libevent "no recursion" behavior. As I described on a recent email, we will have to discuss this and figure out what, if anything, we need to do.
This commit was SVN r23925.
2010-10-24 22:35:54 +04:00
|
|
|
#if OMPI_ENABLE_PROGRESS_THREADS == 1
|
2005-05-24 02:06:50 +04:00
|
|
|
/* close/cleanup fifo create for event notification */
|
2005-06-30 09:50:55 +04:00
|
|
|
if(mca_btl_sm_component.sm_fifo_fd > 0) {
|
2005-05-24 02:06:50 +04:00
|
|
|
/* write a done message down the pipe */
|
|
|
|
unsigned char cmd = DONE;
|
2008-03-09 16:17:13 +03:00
|
|
|
if( write(mca_btl_sm_component.sm_fifo_fd,&cmd,sizeof(cmd)) !=
|
2005-05-24 02:06:50 +04:00
|
|
|
sizeof(cmd)){
|
2008-06-09 18:53:58 +04:00
|
|
|
opal_output(0, "mca_btl_sm_component_close: write fifo failed: errno=%d\n",
|
2005-05-24 02:06:50 +04:00
|
|
|
errno);
|
|
|
|
}
|
2005-07-04 02:45:48 +04:00
|
|
|
opal_thread_join(&mca_btl_sm_component.sm_fifo_thread, NULL);
|
2005-06-30 09:50:55 +04:00
|
|
|
close(mca_btl_sm_component.sm_fifo_fd);
|
|
|
|
unlink(mca_btl_sm_component.sm_fifo_path);
|
2005-05-24 02:06:50 +04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
CLEANUP:
|
|
|
|
|
|
|
|
/* return */
|
|
|
|
return return_value;
|
|
|
|
}
|
|
|
|
|
2013-01-11 20:24:56 +04:00
|
|
|
/*
|
|
|
|
* Returns the number of processes on the node.
|
|
|
|
*/
|
|
|
|
static inline int
|
|
|
|
get_num_local_procs(void)
|
|
|
|
{
|
|
|
|
/* num_local_peers does not include us in
|
|
|
|
* its calculation, so adjust for that */
|
2013-01-28 03:25:10 +04:00
|
|
|
return (int)(1 + ompi_process_info.num_local_peers);
|
2013-01-11 20:24:56 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
calc_sm_max_procs(int n)
|
|
|
|
{
|
|
|
|
/* see if need to allocate space for extra procs */
|
|
|
|
if (0 > mca_btl_sm_component.sm_max_procs) {
|
|
|
|
/* no limit */
|
|
|
|
if (0 <= mca_btl_sm_component.sm_extra_procs) {
|
|
|
|
/* limit */
|
|
|
|
mca_btl_sm_component.sm_max_procs =
|
|
|
|
n + mca_btl_sm_component.sm_extra_procs;
|
|
|
|
} else {
|
|
|
|
/* no limit */
|
|
|
|
mca_btl_sm_component.sm_max_procs = 2 * n;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
create_and_attach(mca_btl_sm_component_t *comp_ptr,
|
|
|
|
size_t size,
|
|
|
|
char *file_name,
|
|
|
|
size_t size_ctl_structure,
|
|
|
|
size_t data_seg_alignment,
|
|
|
|
mca_common_sm_module_t **out_modp)
|
|
|
|
|
|
|
|
{
|
|
|
|
if (NULL == (*out_modp =
|
|
|
|
mca_common_sm_module_create_and_attach(size, file_name,
|
|
|
|
size_ctl_structure,
|
|
|
|
data_seg_alignment))) {
|
|
|
|
opal_output(0, "create_and_attach: unable to create shared memory "
|
|
|
|
"BTL coordinating strucure :: size %lu \n",
|
|
|
|
(unsigned long)size);
|
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* SKG - I'm not happy with this, but I can't figure out a better way of
|
|
|
|
* finding the sm mpool's minimum size 8-|. The way I see it. This BTL only
|
|
|
|
* uses the sm mpool, so maybe this isn't so bad...
|
|
|
|
*
|
|
|
|
* The problem is the we need to size the mpool resources at sm BTL component
|
|
|
|
* init. That means we need to know the mpool's minimum size at create.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
get_min_mpool_size(mca_btl_sm_component_t *comp_ptr,
|
|
|
|
size_t *out_size)
|
|
|
|
{
|
2013-03-28 01:09:41 +04:00
|
|
|
const char *type_name = "mpool";
|
|
|
|
const char *param_name = "min_size";
|
|
|
|
const mca_base_var_storage_t *min_size;
|
2013-01-11 20:24:56 +04:00
|
|
|
int id = 0;
|
|
|
|
|
2013-03-28 01:09:41 +04:00
|
|
|
if (0 > (id = mca_base_var_find("ompi", type_name, comp_ptr->sm_mpool_name,
|
2013-01-11 20:24:56 +04:00
|
|
|
param_name))) {
|
2013-03-28 01:09:41 +04:00
|
|
|
opal_output(0, "mca_base_var_find: failure looking for %s_%s_%s\n",
|
2013-01-11 20:24:56 +04:00
|
|
|
type_name, comp_ptr->sm_mpool_name, param_name);
|
|
|
|
return OMPI_ERR_NOT_FOUND;
|
|
|
|
}
|
2013-03-28 01:09:41 +04:00
|
|
|
|
|
|
|
if (OPAL_SUCCESS != mca_base_var_get_value(id, &min_size, NULL, NULL)) {
|
|
|
|
opal_output(0, "mca_base_var_get_value failure\n");
|
2013-01-11 20:24:56 +04:00
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
2013-03-28 01:09:41 +04:00
|
|
|
|
|
|
|
/* the min_size variable is an unsigned long long */
|
|
|
|
*out_size = (size_t) min_size->ullval;
|
|
|
|
|
2013-01-11 20:24:56 +04:00
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
get_mpool_res_size(int32_t max_procs,
|
|
|
|
size_t *out_res_size)
|
|
|
|
{
|
|
|
|
size_t size = 0;
|
|
|
|
|
|
|
|
*out_res_size = 0;
|
|
|
|
/* determine how much memory to create */
|
|
|
|
/*
|
|
|
|
* This heuristic formula mostly says that we request memory for:
|
|
|
|
* - nfifos FIFOs, each comprising:
|
|
|
|
* . a sm_fifo_t structure
|
|
|
|
* . many pointers (fifo_size of them per FIFO)
|
|
|
|
* - eager fragments (2*n of them, allocated in sm_free_list_inc chunks)
|
|
|
|
* - max fragments (sm_free_list_num of them)
|
|
|
|
*
|
|
|
|
* On top of all that, we sprinkle in some number of
|
|
|
|
* "opal_cache_line_size" additions to account for some
|
|
|
|
* padding and edge effects that may lie in the allocator.
|
|
|
|
*/
|
|
|
|
size = FIFO_MAP_NUM(max_procs) *
|
|
|
|
(sizeof(sm_fifo_t) + sizeof(void *) *
|
|
|
|
mca_btl_sm_component.fifo_size + 4 * opal_cache_line_size) +
|
|
|
|
(2 * max_procs + mca_btl_sm_component.sm_free_list_inc) *
|
|
|
|
(mca_btl_sm_component.eager_limit + 2 * opal_cache_line_size) +
|
|
|
|
mca_btl_sm_component.sm_free_list_num *
|
|
|
|
(mca_btl_sm_component.max_frag_size + 2 * opal_cache_line_size);
|
|
|
|
|
|
|
|
/* add something for the control structure */
|
|
|
|
size += sizeof(mca_common_sm_module_t);
|
|
|
|
|
|
|
|
/* before we multiply by max_procs, make sure the result won't overflow */
|
|
|
|
/* Stick that little pad in, particularly since we'll eventually
|
|
|
|
* need a little extra space. E.g., in mca_mpool_sm_init() in
|
|
|
|
* mpool_sm_component.c when sizeof(mca_common_sm_module_t) is
|
|
|
|
* added.
|
|
|
|
*/
|
|
|
|
if (((double)size) * max_procs > LONG_MAX - 4096) {
|
|
|
|
return OMPI_ERR_VALUE_OUT_OF_BOUNDS;
|
|
|
|
}
|
|
|
|
size *= (size_t)max_procs;
|
|
|
|
*out_res_size = size;
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Generates all the unique paths for the shared-memory segments that this BTL
|
|
|
|
* needs along with other file paths used to share "connection information". */
|
|
|
|
static int
|
|
|
|
set_uniq_paths_for_init_rndv(mca_btl_sm_component_t *comp_ptr)
|
|
|
|
{
|
|
|
|
int rc = OMPI_ERR_OUT_OF_RESOURCE;
|
|
|
|
|
|
|
|
/* NOTE: don't forget to free these after init */
|
|
|
|
comp_ptr->sm_mpool_ctl_file_name = NULL;
|
|
|
|
comp_ptr->sm_mpool_rndv_file_name = NULL;
|
|
|
|
comp_ptr->sm_ctl_file_name = NULL;
|
|
|
|
comp_ptr->sm_rndv_file_name = NULL;
|
|
|
|
|
|
|
|
if (asprintf(&comp_ptr->sm_mpool_ctl_file_name,
|
|
|
|
"%s"OPAL_PATH_SEP"shared_mem_pool.%s",
|
2013-01-28 03:25:10 +04:00
|
|
|
ompi_process_info.job_session_dir,
|
|
|
|
ompi_process_info.nodename) < 0) {
|
2013-01-11 20:24:56 +04:00
|
|
|
/* rc set */
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
if (asprintf(&comp_ptr->sm_mpool_rndv_file_name,
|
|
|
|
"%s"OPAL_PATH_SEP"shared_mem_pool_rndv.%s",
|
2013-01-28 03:25:10 +04:00
|
|
|
ompi_process_info.job_session_dir,
|
|
|
|
ompi_process_info.nodename) < 0) {
|
2013-01-11 20:24:56 +04:00
|
|
|
/* rc set */
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
if (asprintf(&comp_ptr->sm_ctl_file_name,
|
|
|
|
"%s"OPAL_PATH_SEP"shared_mem_btl_module.%s",
|
2013-01-28 03:25:10 +04:00
|
|
|
ompi_process_info.job_session_dir,
|
|
|
|
ompi_process_info.nodename) < 0) {
|
2013-01-11 20:24:56 +04:00
|
|
|
/* rc set */
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
if (asprintf(&comp_ptr->sm_rndv_file_name,
|
|
|
|
"%s"OPAL_PATH_SEP"shared_mem_btl_rndv.%s",
|
2013-01-28 03:25:10 +04:00
|
|
|
ompi_process_info.job_session_dir,
|
|
|
|
ompi_process_info.nodename) < 0) {
|
2013-01-11 20:24:56 +04:00
|
|
|
/* rc set */
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
/* all is well */
|
|
|
|
rc = OMPI_SUCCESS;
|
|
|
|
|
|
|
|
out:
|
|
|
|
if (OMPI_SUCCESS != rc) {
|
|
|
|
if (comp_ptr->sm_mpool_ctl_file_name) {
|
|
|
|
free(comp_ptr->sm_mpool_ctl_file_name);
|
|
|
|
}
|
|
|
|
if (comp_ptr->sm_mpool_rndv_file_name) {
|
|
|
|
free(comp_ptr->sm_mpool_rndv_file_name);
|
|
|
|
}
|
|
|
|
if (comp_ptr->sm_ctl_file_name) {
|
|
|
|
free(comp_ptr->sm_ctl_file_name);
|
|
|
|
}
|
|
|
|
if (comp_ptr->sm_rndv_file_name) {
|
|
|
|
free(comp_ptr->sm_rndv_file_name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
create_rndv_file(mca_btl_sm_component_t *comp_ptr,
|
|
|
|
mca_btl_sm_rndv_module_type_t type)
|
|
|
|
{
|
|
|
|
size_t size = 0;
|
|
|
|
int rc = OMPI_SUCCESS;
|
|
|
|
int fd = -1;
|
|
|
|
char *fname = NULL;
|
|
|
|
/* used as a temporary store so we can extract shmem_ds info */
|
|
|
|
mca_common_sm_module_t *tmp_modp = NULL;
|
|
|
|
|
|
|
|
if (MCA_BTL_SM_RNDV_MOD_MPOOL == type) {
|
|
|
|
size_t min_size = 0;
|
|
|
|
/* get the segment size for the sm mpool. */
|
|
|
|
if (OMPI_SUCCESS != (rc = get_mpool_res_size(comp_ptr->sm_max_procs,
|
|
|
|
&size))) {
|
|
|
|
/* rc is already set */
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
/* do we need to update the size based on the sm mpool's min size? */
|
|
|
|
if (OMPI_SUCCESS != (rc = get_min_mpool_size(comp_ptr, &min_size))) {
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
/* update size if less than required minimum */
|
|
|
|
if (size < min_size) {
|
|
|
|
size = min_size;
|
|
|
|
}
|
|
|
|
/* we only need the shmem_ds info at this point. initilization will be
|
|
|
|
* completed in the mpool module code. the idea is that we just need this
|
|
|
|
* info so we can populate the rndv file (or modex when we have it). */
|
|
|
|
if (OMPI_SUCCESS != (rc =
|
|
|
|
create_and_attach(comp_ptr, size, comp_ptr->sm_mpool_ctl_file_name,
|
|
|
|
sizeof(mca_common_sm_module_t), 8, &tmp_modp))) {
|
|
|
|
/* rc is set */
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
fname = comp_ptr->sm_mpool_rndv_file_name;
|
|
|
|
}
|
|
|
|
else if (MCA_BTL_SM_RNDV_MOD_SM == type) {
|
|
|
|
/* calculate the segment size. */
|
|
|
|
size = sizeof(mca_common_sm_seg_header_t) +
|
|
|
|
comp_ptr->sm_max_procs *
|
|
|
|
(sizeof(sm_fifo_t *) +
|
|
|
|
sizeof(char *) + sizeof(uint16_t)) +
|
|
|
|
opal_cache_line_size;
|
|
|
|
|
|
|
|
if (OMPI_SUCCESS != (rc =
|
|
|
|
create_and_attach(comp_ptr, size, comp_ptr->sm_ctl_file_name,
|
|
|
|
sizeof(mca_common_sm_seg_header_t),
|
|
|
|
opal_cache_line_size, &comp_ptr->sm_seg))) {
|
|
|
|
/* rc is set */
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
fname = comp_ptr->sm_rndv_file_name;
|
|
|
|
tmp_modp = comp_ptr->sm_seg;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return OMPI_ERR_BAD_PARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* at this point, we have all the info we need to populate the rendezvous
|
|
|
|
* file containing all the meta info required for attach. */
|
|
|
|
|
|
|
|
/* now just write the contents of tmp_modp->shmem_ds to the full
|
|
|
|
* sizeof(opal_shmem_ds_t), so we know where the mpool_res_size starts. */
|
|
|
|
if (-1 == (fd = open(fname, O_CREAT | O_RDWR, 0600))) {
|
|
|
|
int err = errno;
|
2013-02-13 01:10:11 +04:00
|
|
|
opal_show_help("help-mpi-btl-sm.txt", "sys call fail", true,
|
2013-01-11 20:24:56 +04:00
|
|
|
"open(2)", strerror(err), err);
|
|
|
|
rc = OMPI_ERR_IN_ERRNO;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
if ((ssize_t)sizeof(opal_shmem_ds_t) != write(fd, &(tmp_modp->shmem_ds),
|
|
|
|
sizeof(opal_shmem_ds_t))) {
|
|
|
|
int err = errno;
|
2013-02-13 01:10:11 +04:00
|
|
|
opal_show_help("help-mpi-btl-sm.txt", "sys call fail", true,
|
2013-01-11 20:24:56 +04:00
|
|
|
"write(2)", strerror(err), err);
|
|
|
|
rc = OMPI_ERR_IN_ERRNO;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
if (MCA_BTL_SM_RNDV_MOD_MPOOL == type) {
|
|
|
|
if ((ssize_t)sizeof(size) != write(fd, &size, sizeof(size))) {
|
|
|
|
int err = errno;
|
2013-02-13 01:10:11 +04:00
|
|
|
opal_show_help("help-mpi-btl-sm.txt", "sys call fail", true,
|
2013-01-11 20:24:56 +04:00
|
|
|
"write(2)", strerror(err), err);
|
|
|
|
rc = OMPI_ERR_IN_ERRNO;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
/* only do this for the mpool case */
|
|
|
|
OBJ_RELEASE(tmp_modp);
|
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
|
|
|
if (-1 != fd) {
|
|
|
|
(void)close(fd);
|
|
|
|
}
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Creates information required for the sm modex and modex sends it.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
backing_store_init(mca_btl_sm_component_t *comp_ptr,
|
2013-02-22 21:48:53 +04:00
|
|
|
ompi_local_rank_t local_rank)
|
2013-01-11 20:24:56 +04:00
|
|
|
{
|
|
|
|
int rc = OMPI_SUCCESS;
|
|
|
|
|
|
|
|
if (OMPI_SUCCESS != (rc = set_uniq_paths_for_init_rndv(comp_ptr))) {
|
|
|
|
goto out;
|
|
|
|
}
|
2013-02-21 22:19:46 +04:00
|
|
|
/* only let the lowest rank setup the metadata */
|
|
|
|
if (0 == local_rank) {
|
2013-01-11 20:24:56 +04:00
|
|
|
/* === sm mpool === */
|
|
|
|
if (OMPI_SUCCESS != (rc =
|
|
|
|
create_rndv_file(comp_ptr, MCA_BTL_SM_RNDV_MOD_MPOOL))) {
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
/* === sm === */
|
|
|
|
if (OMPI_SUCCESS != (rc =
|
|
|
|
create_rndv_file(comp_ptr, MCA_BTL_SM_RNDV_MOD_SM))) {
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2005-05-24 02:06:50 +04:00
|
|
|
/*
|
|
|
|
* SM component initialization
|
|
|
|
*/
|
2013-01-11 20:24:56 +04:00
|
|
|
static mca_btl_base_module_t **
|
|
|
|
mca_btl_sm_component_init(int *num_btls,
|
|
|
|
bool enable_progress_threads,
|
|
|
|
bool enable_mpi_threads)
|
2005-05-24 02:06:50 +04:00
|
|
|
{
|
2013-01-11 20:24:56 +04:00
|
|
|
int num_local_procs = 0;
|
2007-05-23 18:03:52 +04:00
|
|
|
mca_btl_base_module_t **btls = NULL;
|
2013-02-22 21:48:53 +04:00
|
|
|
ompi_local_rank_t my_local_rank = OMPI_LOCAL_RANK_INVALID;
|
2009-12-16 02:34:09 +03:00
|
|
|
#if OMPI_BTL_SM_HAVE_KNEM
|
|
|
|
int rc;
|
2013-01-13 20:08:48 +04:00
|
|
|
#endif /* OMPI_BTL_SM_HAVE_KNEM */
|
2005-05-24 02:06:50 +04:00
|
|
|
|
2007-05-23 18:03:52 +04:00
|
|
|
*num_btls = 0;
|
2013-01-11 20:24:56 +04:00
|
|
|
/* lookup/create shared memory pool only when used */
|
|
|
|
mca_btl_sm_component.sm_mpool = NULL;
|
|
|
|
mca_btl_sm_component.sm_mpool_base = NULL;
|
2005-05-24 02:06:50 +04:00
|
|
|
|
2010-03-02 18:18:33 +03:00
|
|
|
/* if no session directory was created, then we cannot be used */
|
2013-01-28 03:25:10 +04:00
|
|
|
if (NULL == ompi_process_info.job_session_dir) {
|
2013-01-11 20:24:56 +04:00
|
|
|
/* SKG - this isn't true anymore. Some backing facilities don't require a
|
|
|
|
* file-backed store. Extend shmem to provide this info one day. Especially
|
|
|
|
* when we use a proper modex for init. */
|
2010-03-02 18:18:33 +03:00
|
|
|
return NULL;
|
|
|
|
}
|
2013-01-11 20:24:56 +04:00
|
|
|
/* if we don't have locality information, then we cannot be used because we
|
2013-02-21 22:19:46 +04:00
|
|
|
* need to know who the respective node ranks for initialization. note the
|
|
|
|
* use of my_local_rank here. we use this instead of my_node_rank because in
|
|
|
|
* the spawn case we need to designate a metadata creator rank within the
|
|
|
|
* set of processes that are initializing the btl, and my_local_rank seems
|
|
|
|
* to provide that for us. */
|
|
|
|
if (OMPI_LOCAL_RANK_INVALID ==
|
|
|
|
(my_local_rank = ompi_process_info.my_local_rank)) {
|
2013-02-13 01:10:11 +04:00
|
|
|
opal_show_help("help-mpi-btl-sm.txt", "no locality", true);
|
2013-01-11 20:24:56 +04:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
/* no use trying to use sm with less than two procs, so just bail. */
|
|
|
|
if ((num_local_procs = get_num_local_procs()) < 2) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
/* calculate max procs so we can figure out how large to make the
|
|
|
|
* shared-memory segment. this routine sets component sm_max_procs. */
|
|
|
|
calc_sm_max_procs(num_local_procs);
|
|
|
|
|
|
|
|
/* This is where the modex will live some day. For now, just have local rank
|
|
|
|
* 0 create a rendezvous file containing the backing store info, so the
|
|
|
|
* other local procs can read from it during add_procs. The rest will just
|
|
|
|
* stash the known paths for use later in init. */
|
|
|
|
if (OMPI_SUCCESS != backing_store_init(&mca_btl_sm_component,
|
2013-02-21 22:19:46 +04:00
|
|
|
my_local_rank)) {
|
2013-01-11 20:24:56 +04:00
|
|
|
return NULL;
|
|
|
|
}
|
2005-05-24 02:06:50 +04:00
|
|
|
|
Update libevent to the 2.0 series, currently at 2.0.7rc. We will update to their final release when it becomes available. Currently known errors exist in unused portions of the libevent code. This revision passes the IBM test suite on a Linux machine and on a standalone Mac.
This is a fairly intrusive change, but outside of the moving of opal/event to opal/mca/event, the only changes involved (a) changing all calls to opal_event functions to reflect the new framework instead, and (b) ensuring that all opal_event_t objects are properly constructed since they are now true opal_objects.
Note: Shiqing has just returned from vacation and has not yet had a chance to complete the Windows integration. Thus, this commit almost certainly breaks Windows support on the trunk. However, I want this to have a chance to soak for as long as possible before I become less available a week from today (going to be at a class for 5 days, and thus will only be sparingly available) so we can find and fix any problems.
Biggest change is moving the libevent code from opal/event to a new opal/mca/event framework. This was done to make it much easier to update libevent in the future. New versions can be inserted as a new component and tested in parallel with the current version until validated, then we can remove the earlier version if we so choose. This is a statically built framework ala installdirs, so only one component will build at a time. There is no selection logic - the sole compiled component simply loads its function pointers into the opal_event struct.
I have gone thru the code base and converted all the libevent calls I could find. However, I cannot compile nor test every environment. It is therefore quite likely that errors remain in the system. Please keep an eye open for two things:
1. compile-time errors: these will be obvious as calls to the old functions (e.g., opal_evtimer_new) must be replaced by the new framework APIs (e.g., opal_event.evtimer_new)
2. run-time errors: these will likely show up as segfaults due to missing constructors on opal_event_t objects. It appears that it became a typical practice for people to "init" an opal_event_t by simply using memset to zero it out. This will no longer work - you must either OBJ_NEW or OBJ_CONSTRUCT an opal_event_t. I tried to catch these cases, but may have missed some. Believe me, you'll know when you hit it.
There is also the issue of the new libevent "no recursion" behavior. As I described on a recent email, we will have to discuss this and figure out what, if anything, we need to do.
This commit was SVN r23925.
2010-10-24 22:35:54 +04:00
|
|
|
#if OMPI_ENABLE_PROGRESS_THREADS == 1
|
2005-05-24 02:06:50 +04:00
|
|
|
/* create a named pipe to receive events */
|
2013-01-28 03:25:10 +04:00
|
|
|
sprintf( mca_btl_sm_component.sm_fifo_path,
|
|
|
|
"%s"OPAL_PATH_SEP"sm_fifo.%lu", ompi_process_info.job_session_dir,
|
|
|
|
(unsigned long)OMPI_PROC_MY_NAME->vpid );
|
|
|
|
if(mkfifo(mca_btl_sm_component.sm_fifo_path, 0660) < 0) {
|
|
|
|
opal_output(0, "mca_btl_sm_component_init: mkfifo failed with errno=%d\n",errno);
|
2005-05-24 02:06:50 +04:00
|
|
|
return NULL;
|
|
|
|
}
|
2013-01-11 20:24:56 +04:00
|
|
|
mca_btl_sm_component.sm_fifo_fd = open(mca_btl_sm_component.sm_fifo_path,
|
|
|
|
O_RDWR);
|
2005-06-30 09:50:55 +04:00
|
|
|
if(mca_btl_sm_component.sm_fifo_fd < 0) {
|
2013-01-11 20:24:56 +04:00
|
|
|
opal_output(0, "mca_btl_sm_component_init: "
|
|
|
|
"open(%s) failed with errno=%d\n",
|
2009-12-16 02:34:09 +03:00
|
|
|
mca_btl_sm_component.sm_fifo_path, errno);
|
2005-05-24 02:06:50 +04:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2005-07-04 02:45:48 +04:00
|
|
|
OBJ_CONSTRUCT(&mca_btl_sm_component.sm_fifo_thread, opal_thread_t);
|
2013-01-11 20:24:56 +04:00
|
|
|
mca_btl_sm_component.sm_fifo_thread.t_run =
|
|
|
|
(opal_thread_fn_t)mca_btl_sm_component_event_thread;
|
2005-07-04 02:45:48 +04:00
|
|
|
opal_thread_start(&mca_btl_sm_component.sm_fifo_thread);
|
2005-05-24 02:06:50 +04:00
|
|
|
#endif
|
|
|
|
|
2013-01-11 20:24:56 +04:00
|
|
|
mca_btl_sm_component.sm_btls =
|
|
|
|
(mca_btl_sm_t **)malloc(mca_btl_sm_component.sm_max_btls *
|
|
|
|
sizeof(mca_btl_sm_t *));
|
2009-12-16 02:34:09 +03:00
|
|
|
if (NULL == mca_btl_sm_component.sm_btls) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2007-05-23 18:03:52 +04:00
|
|
|
/* allocate the Shared Memory BTL */
|
|
|
|
*num_btls = 1;
|
2008-03-09 16:22:12 +03:00
|
|
|
btls = (mca_btl_base_module_t**)malloc(sizeof(mca_btl_base_module_t*));
|
2007-05-23 18:03:52 +04:00
|
|
|
if (NULL == btls) {
|
2005-05-24 02:06:50 +04:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2007-05-23 18:03:52 +04:00
|
|
|
/* get pointer to the btls */
|
2009-12-16 02:34:09 +03:00
|
|
|
btls[0] = (mca_btl_base_module_t*)(&(mca_btl_sm));
|
|
|
|
mca_btl_sm_component.sm_btls[0] = (mca_btl_sm_t*)(&(mca_btl_sm));
|
2005-05-24 02:06:50 +04:00
|
|
|
|
2009-12-16 02:34:09 +03:00
|
|
|
/* initialize some BTL data */
|
2005-05-24 02:06:50 +04:00
|
|
|
/* start with no SM procs */
|
2005-06-30 09:50:55 +04:00
|
|
|
mca_btl_sm_component.num_smp_procs = 0;
|
2007-03-20 11:15:58 +03:00
|
|
|
mca_btl_sm_component.my_smp_rank = -1; /* not defined */
|
2009-12-16 02:34:09 +03:00
|
|
|
mca_btl_sm_component.sm_num_btls = 1;
|
2007-05-23 18:03:52 +04:00
|
|
|
/* set flag indicating btl not inited */
|
2009-12-16 02:34:09 +03:00
|
|
|
mca_btl_sm.btl_inited = false;
|
|
|
|
|
|
|
|
#if OMPI_BTL_SM_HAVE_KNEM
|
2012-03-14 10:29:09 +04:00
|
|
|
if (mca_btl_sm_component.use_knem) {
|
|
|
|
if (0 != mca_btl_sm_component.use_knem) {
|
|
|
|
/* Open the knem device. Try to print a helpful message if we
|
|
|
|
fail to open it. */
|
|
|
|
mca_btl_sm.knem_fd = open("/dev/knem", O_RDWR);
|
|
|
|
if (mca_btl_sm.knem_fd < 0) {
|
|
|
|
if (EACCES == errno) {
|
|
|
|
struct stat sbuf;
|
|
|
|
if (0 != stat("/dev/knem", &sbuf)) {
|
|
|
|
sbuf.st_mode = 0;
|
|
|
|
}
|
2013-02-13 01:10:11 +04:00
|
|
|
opal_show_help("help-mpi-btl-sm.txt", "knem permission denied",
|
2013-01-28 03:25:10 +04:00
|
|
|
true, ompi_process_info.nodename, sbuf.st_mode);
|
2012-03-14 10:29:09 +04:00
|
|
|
} else {
|
2013-02-13 01:10:11 +04:00
|
|
|
opal_show_help("help-mpi-btl-sm.txt", "knem fail open",
|
2013-01-28 03:25:10 +04:00
|
|
|
true, ompi_process_info.nodename, errno,
|
2012-03-14 10:29:09 +04:00
|
|
|
strerror(errno));
|
2009-12-16 02:34:09 +03:00
|
|
|
}
|
2012-03-14 10:29:09 +04:00
|
|
|
goto no_knem;
|
2009-12-16 02:34:09 +03:00
|
|
|
}
|
|
|
|
|
2012-03-14 10:29:09 +04:00
|
|
|
/* Check that the ABI if the kernel module running is the same
|
|
|
|
as what we were compiled against */
|
|
|
|
rc = ioctl(mca_btl_sm.knem_fd, KNEM_CMD_GET_INFO,
|
|
|
|
&mca_btl_sm_component.knem_info);
|
|
|
|
if (rc < 0) {
|
2013-02-13 01:10:11 +04:00
|
|
|
opal_show_help("help-mpi-btl-sm.txt", "knem get ABI fail",
|
2013-01-28 03:25:10 +04:00
|
|
|
true, ompi_process_info.nodename, errno,
|
2009-12-16 02:34:09 +03:00
|
|
|
strerror(errno));
|
|
|
|
goto no_knem;
|
|
|
|
}
|
2012-03-14 10:29:09 +04:00
|
|
|
if (KNEM_ABI_VERSION != mca_btl_sm_component.knem_info.abi) {
|
2013-02-13 01:10:11 +04:00
|
|
|
opal_show_help("help-mpi-btl-sm.txt", "knem ABI mismatch",
|
2013-01-28 03:25:10 +04:00
|
|
|
true, ompi_process_info.nodename, KNEM_ABI_VERSION,
|
2012-03-14 10:29:09 +04:00
|
|
|
mca_btl_sm_component.knem_info.abi);
|
2009-12-16 02:34:09 +03:00
|
|
|
goto no_knem;
|
|
|
|
}
|
2012-03-14 10:29:09 +04:00
|
|
|
|
|
|
|
/* If we want DMA mode and DMA mode is supported, then set
|
|
|
|
knem_dma_flag to KNEM_FLAG_DMA. */
|
|
|
|
mca_btl_sm_component.knem_dma_flag = 0;
|
|
|
|
if (mca_btl_sm_component.knem_dma_min > 0 &&
|
|
|
|
(mca_btl_sm_component.knem_info.features & KNEM_FEATURE_DMA)) {
|
|
|
|
mca_btl_sm_component.knem_dma_flag = KNEM_FLAG_DMA;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the array of statuses from knem if max_simultaneous > 0 */
|
|
|
|
if (mca_btl_sm_component.knem_max_simultaneous > 0) {
|
|
|
|
mca_btl_sm.knem_status_array = mmap(NULL,
|
|
|
|
mca_btl_sm_component.knem_max_simultaneous,
|
|
|
|
(PROT_READ | PROT_WRITE),
|
|
|
|
MAP_SHARED, mca_btl_sm.knem_fd,
|
|
|
|
KNEM_STATUS_ARRAY_FILE_OFFSET);
|
|
|
|
if (MAP_FAILED == mca_btl_sm.knem_status_array) {
|
2013-02-13 01:10:11 +04:00
|
|
|
opal_show_help("help-mpi-btl-sm.txt", "knem mmap fail",
|
2013-01-28 03:25:10 +04:00
|
|
|
true, ompi_process_info.nodename, errno,
|
2012-03-14 10:29:09 +04:00
|
|
|
strerror(errno));
|
|
|
|
goto no_knem;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The first available status index is 0. Make an empty frag
|
|
|
|
array. */
|
|
|
|
mca_btl_sm.knem_frag_array = (mca_btl_sm_frag_t **)
|
|
|
|
malloc(sizeof(mca_btl_sm_frag_t *) *
|
|
|
|
mca_btl_sm_component.knem_max_simultaneous);
|
|
|
|
if (NULL == mca_btl_sm.knem_frag_array) {
|
2013-02-13 01:10:11 +04:00
|
|
|
opal_show_help("help-mpi-btl-sm.txt", "knem init fail",
|
2013-01-28 03:25:10 +04:00
|
|
|
true, ompi_process_info.nodename, "malloc",
|
2012-03-14 10:29:09 +04:00
|
|
|
errno, strerror(errno));
|
|
|
|
goto no_knem;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* Set the BTL get function pointer if we're supporting KNEM;
|
|
|
|
choose between synchronous and asynchronous. */
|
|
|
|
if (mca_btl_sm_component.knem_max_simultaneous > 0) {
|
|
|
|
mca_btl_sm.super.btl_get = mca_btl_sm_get_async;
|
|
|
|
} else {
|
|
|
|
mca_btl_sm.super.btl_get = mca_btl_sm_get_sync;
|
2009-12-16 02:34:09 +03:00
|
|
|
}
|
|
|
|
}
|
2012-03-14 10:29:09 +04:00
|
|
|
#endif /* OMPI_BTL_SM_HAVE_KNEM */
|
|
|
|
|
|
|
|
#if OMPI_BTL_SM_HAVE_CMA
|
|
|
|
if (mca_btl_sm_component.use_cma) {
|
|
|
|
/* Will only ever have either cma or knem enabled at runtime
|
|
|
|
so no problems with accidentally overwriting this set earlier */
|
2009-12-16 02:34:09 +03:00
|
|
|
mca_btl_sm.super.btl_get = mca_btl_sm_get_sync;
|
|
|
|
}
|
2012-03-14 10:29:09 +04:00
|
|
|
#endif /* OMPI_BTL_SM_HAVE_CMA */
|
2005-05-24 02:06:50 +04:00
|
|
|
|
2007-05-23 18:03:52 +04:00
|
|
|
return btls;
|
2009-12-16 02:34:09 +03:00
|
|
|
|
|
|
|
#if OMPI_BTL_SM_HAVE_KNEM
|
|
|
|
no_knem:
|
|
|
|
mca_btl_sm.super.btl_flags &= ~MCA_BTL_FLAGS_GET;
|
|
|
|
|
|
|
|
if (NULL != mca_btl_sm.knem_frag_array) {
|
|
|
|
free(mca_btl_sm.knem_frag_array);
|
|
|
|
mca_btl_sm.knem_frag_array = NULL;
|
|
|
|
}
|
|
|
|
if (NULL != mca_btl_sm.knem_status_array) {
|
|
|
|
munmap(mca_btl_sm.knem_status_array,
|
|
|
|
mca_btl_sm_component.knem_max_simultaneous);
|
|
|
|
mca_btl_sm.knem_status_array = NULL;
|
|
|
|
}
|
|
|
|
if (-1 != mca_btl_sm.knem_fd) {
|
|
|
|
close(mca_btl_sm.knem_fd);
|
|
|
|
mca_btl_sm.knem_fd = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If "use_knem" is positive, then it's an error if knem support
|
|
|
|
is not available -- deactivate the sm btl. */
|
|
|
|
if (mca_btl_sm_component.use_knem > 0) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Otherwise, use_knem was 0 (and we didn't get here) or use_knem
|
|
|
|
was <0, in which case the fact that knem is not available is
|
|
|
|
not an error. */
|
|
|
|
return btls;
|
2013-01-13 20:08:48 +04:00
|
|
|
#endif /* OMPI_BTL_SM_HAVE_KNEM */
|
2005-05-24 02:06:50 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* SM component progress.
|
|
|
|
*/
|
|
|
|
|
Update libevent to the 2.0 series, currently at 2.0.7rc. We will update to their final release when it becomes available. Currently known errors exist in unused portions of the libevent code. This revision passes the IBM test suite on a Linux machine and on a standalone Mac.
This is a fairly intrusive change, but outside of the moving of opal/event to opal/mca/event, the only changes involved (a) changing all calls to opal_event functions to reflect the new framework instead, and (b) ensuring that all opal_event_t objects are properly constructed since they are now true opal_objects.
Note: Shiqing has just returned from vacation and has not yet had a chance to complete the Windows integration. Thus, this commit almost certainly breaks Windows support on the trunk. However, I want this to have a chance to soak for as long as possible before I become less available a week from today (going to be at a class for 5 days, and thus will only be sparingly available) so we can find and fix any problems.
Biggest change is moving the libevent code from opal/event to a new opal/mca/event framework. This was done to make it much easier to update libevent in the future. New versions can be inserted as a new component and tested in parallel with the current version until validated, then we can remove the earlier version if we so choose. This is a statically built framework ala installdirs, so only one component will build at a time. There is no selection logic - the sole compiled component simply loads its function pointers into the opal_event struct.
I have gone thru the code base and converted all the libevent calls I could find. However, I cannot compile nor test every environment. It is therefore quite likely that errors remain in the system. Please keep an eye open for two things:
1. compile-time errors: these will be obvious as calls to the old functions (e.g., opal_evtimer_new) must be replaced by the new framework APIs (e.g., opal_event.evtimer_new)
2. run-time errors: these will likely show up as segfaults due to missing constructors on opal_event_t objects. It appears that it became a typical practice for people to "init" an opal_event_t by simply using memset to zero it out. This will no longer work - you must either OBJ_NEW or OBJ_CONSTRUCT an opal_event_t. I tried to catch these cases, but may have missed some. Believe me, you'll know when you hit it.
There is also the issue of the new libevent "no recursion" behavior. As I described on a recent email, we will have to discuss this and figure out what, if anything, we need to do.
This commit was SVN r23925.
2010-10-24 22:35:54 +04:00
|
|
|
#if OMPI_ENABLE_PROGRESS_THREADS == 1
|
2005-07-03 20:06:07 +04:00
|
|
|
void mca_btl_sm_component_event_thread(opal_object_t* thread)
|
2005-05-24 02:06:50 +04:00
|
|
|
{
|
|
|
|
while(1) {
|
|
|
|
unsigned char cmd;
|
2005-06-30 09:50:55 +04:00
|
|
|
if(read(mca_btl_sm_component.sm_fifo_fd, &cmd, sizeof(cmd)) != sizeof(cmd)) {
|
2005-05-24 02:06:50 +04:00
|
|
|
/* error condition */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if( DONE == cmd ){
|
|
|
|
/* return when done message received */
|
|
|
|
return;
|
2008-03-09 16:17:13 +03:00
|
|
|
}
|
2005-09-12 00:55:22 +04:00
|
|
|
mca_btl_sm_component_progress();
|
2005-05-24 02:06:50 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-06-27 04:12:56 +04:00
|
|
|
void btl_sm_process_pending_sends(struct mca_btl_base_endpoint_t *ep)
|
2008-08-17 23:00:50 +04:00
|
|
|
{
|
|
|
|
btl_sm_pending_send_item_t *si;
|
|
|
|
int rc;
|
|
|
|
|
2009-06-27 04:12:56 +04:00
|
|
|
while ( 0 < opal_list_get_size(&ep->pending_sends) ) {
|
2012-02-08 05:32:36 +04:00
|
|
|
/* Note that we access the size of ep->pending_sends unlocked
|
|
|
|
as it doesn't really matter if the result is wrong as
|
|
|
|
opal_list_remove_first is called with a lock and we handle it
|
|
|
|
not finding an item to process */
|
|
|
|
OPAL_THREAD_LOCK(&ep->endpoint_lock);
|
2009-06-27 04:12:56 +04:00
|
|
|
si = (btl_sm_pending_send_item_t*)opal_list_remove_first(&ep->pending_sends);
|
2012-02-08 05:32:36 +04:00
|
|
|
OPAL_THREAD_UNLOCK(&ep->endpoint_lock);
|
2009-06-27 04:12:56 +04:00
|
|
|
|
2012-02-08 05:32:36 +04:00
|
|
|
if(NULL == si) return; /* Another thread got in before us. Thats ok. */
|
|
|
|
|
2009-06-27 04:12:56 +04:00
|
|
|
OPAL_THREAD_ADD32(&mca_btl_sm_component.num_pending_sends, -1);
|
2008-08-17 23:00:50 +04:00
|
|
|
|
2009-06-27 04:12:56 +04:00
|
|
|
MCA_BTL_SM_FIFO_WRITE(ep, ep->my_smp_rank, ep->peer_smp_rank, si->data,
|
|
|
|
true, false, rc);
|
2008-08-17 23:00:50 +04:00
|
|
|
|
2012-02-08 05:32:36 +04:00
|
|
|
OPAL_FREE_LIST_RETURN(&mca_btl_sm_component.pending_send_fl, (opal_list_item_t*)si);
|
|
|
|
|
2009-06-27 04:12:56 +04:00
|
|
|
if ( OMPI_SUCCESS != rc )
|
|
|
|
return;
|
|
|
|
}
|
2008-08-17 23:00:50 +04:00
|
|
|
}
|
|
|
|
|
2005-06-30 09:50:55 +04:00
|
|
|
int mca_btl_sm_component_progress(void)
|
2005-05-24 02:06:50 +04:00
|
|
|
{
|
|
|
|
/* local variables */
|
2012-06-21 21:09:12 +04:00
|
|
|
mca_btl_base_segment_t seg;
|
2005-06-30 09:50:55 +04:00
|
|
|
mca_btl_sm_frag_t *frag;
|
2007-08-28 01:41:04 +04:00
|
|
|
mca_btl_sm_frag_t Frag;
|
2009-02-17 18:58:15 +03:00
|
|
|
sm_fifo_t *fifo = NULL;
|
2007-03-05 17:17:50 +03:00
|
|
|
mca_btl_sm_hdr_t *hdr;
|
2007-10-22 16:07:22 +04:00
|
|
|
int my_smp_rank = mca_btl_sm_component.my_smp_rank;
|
2009-11-04 06:10:35 +03:00
|
|
|
int peer_smp_rank, j, rc = 0, nevents = 0;
|
2005-05-24 02:06:50 +04:00
|
|
|
|
2009-06-27 04:12:56 +04:00
|
|
|
/* first, deal with any pending sends */
|
|
|
|
/* This check should be fast since we only need to check one variable. */
|
|
|
|
if ( 0 < mca_btl_sm_component.num_pending_sends ) {
|
|
|
|
|
|
|
|
/* perform a loop to find the endpoints that have pending sends */
|
|
|
|
/* This can take a while longer if there are many endpoints to check. */
|
|
|
|
for ( peer_smp_rank = 0; peer_smp_rank < mca_btl_sm_component.num_smp_procs; peer_smp_rank++) {
|
|
|
|
struct mca_btl_base_endpoint_t* endpoint;
|
|
|
|
if ( peer_smp_rank == my_smp_rank )
|
|
|
|
continue;
|
|
|
|
endpoint = mca_btl_sm_component.sm_peers[peer_smp_rank];
|
|
|
|
if ( 0 < opal_list_get_size(&endpoint->pending_sends) )
|
|
|
|
btl_sm_process_pending_sends(endpoint);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-05-24 02:06:50 +04:00
|
|
|
/* poll each fifo */
|
2009-02-17 18:58:15 +03:00
|
|
|
for(j = 0; j < FIFO_MAP_NUM(mca_btl_sm_component.num_smp_procs); j++) {
|
|
|
|
fifo = &(mca_btl_sm_component.fifo[my_smp_rank][j]);
|
2008-06-24 23:01:26 +04:00
|
|
|
recheck_peer:
|
2005-05-24 02:06:50 +04:00
|
|
|
/* aquire thread lock */
|
2007-03-20 11:15:58 +03:00
|
|
|
if(opal_using_threads()) {
|
2009-02-17 18:58:15 +03:00
|
|
|
opal_atomic_lock(&(fifo->tail_lock));
|
2005-05-24 02:06:50 +04:00
|
|
|
}
|
|
|
|
|
2009-02-17 18:58:15 +03:00
|
|
|
hdr = (mca_btl_sm_hdr_t *)sm_fifo_read(fifo);
|
2005-05-24 02:06:50 +04:00
|
|
|
|
|
|
|
/* release thread lock */
|
2007-03-20 11:15:58 +03:00
|
|
|
if(opal_using_threads()) {
|
2009-02-17 18:58:15 +03:00
|
|
|
opal_atomic_unlock(&(fifo->tail_lock));
|
2005-05-24 02:06:50 +04:00
|
|
|
}
|
|
|
|
|
2009-02-17 18:58:15 +03:00
|
|
|
if(SM_FIFO_FREE == hdr) {
|
2006-02-02 20:32:22 +03:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2009-11-04 06:10:35 +03:00
|
|
|
nevents++;
|
2005-06-20 18:51:08 +04:00
|
|
|
/* dispatch fragment by type */
|
2007-03-05 17:24:09 +03:00
|
|
|
switch(((uintptr_t)hdr) & MCA_BTL_SM_FRAG_TYPE_MASK) {
|
2005-06-30 09:50:55 +04:00
|
|
|
case MCA_BTL_SM_FRAG_SEND:
|
2005-06-20 18:51:08 +04:00
|
|
|
{
|
2008-01-15 08:32:53 +03:00
|
|
|
mca_btl_active_message_callback_t* reg;
|
2007-03-05 17:24:09 +03:00
|
|
|
/* change the address from address relative to the shared
|
2007-10-22 16:07:22 +04:00
|
|
|
* memory address, to a true virtual address */
|
2009-02-17 18:58:15 +03:00
|
|
|
hdr = (mca_btl_sm_hdr_t *) RELATIVE2VIRTUAL(hdr);
|
|
|
|
peer_smp_rank = hdr->my_smp_rank;
|
2009-05-07 00:11:28 +04:00
|
|
|
#if OPAL_ENABLE_DEBUG
|
2009-02-20 22:51:57 +03:00
|
|
|
if ( FIFO_MAP(peer_smp_rank) != j ) {
|
2009-02-17 18:58:15 +03:00
|
|
|
opal_output(0, "mca_btl_sm_component_progress: "
|
2009-12-16 02:34:09 +03:00
|
|
|
"rank %d got %d on FIFO %d, but this sender should send to FIFO %d\n",
|
|
|
|
my_smp_rank, peer_smp_rank, j, FIFO_MAP(peer_smp_rank));
|
2009-02-20 22:51:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
2005-06-20 18:51:08 +04:00
|
|
|
/* recv upcall */
|
2008-01-15 08:32:53 +03:00
|
|
|
reg = mca_btl_base_active_message_trigger + hdr->tag;
|
2012-06-21 21:09:12 +04:00
|
|
|
seg.seg_addr.pval = ((char *)hdr) + sizeof(mca_btl_sm_hdr_t);
|
|
|
|
seg.seg_len = hdr->len;
|
2007-08-28 07:08:36 +04:00
|
|
|
Frag.base.des_dst_cnt = 1;
|
2012-06-21 21:09:12 +04:00
|
|
|
Frag.base.des_dst = &seg;
|
2007-08-28 01:41:04 +04:00
|
|
|
reg->cbfunc(&mca_btl_sm.super, hdr->tag, &(Frag.base),
|
2008-06-24 23:01:26 +04:00
|
|
|
reg->cbdata);
|
2009-02-20 22:51:57 +03:00
|
|
|
/* return the fragment */
|
2007-03-05 17:24:09 +03:00
|
|
|
MCA_BTL_SM_FIFO_WRITE(
|
|
|
|
mca_btl_sm_component.sm_peers[peer_smp_rank],
|
2009-06-27 04:12:56 +04:00
|
|
|
my_smp_rank, peer_smp_rank, hdr->frag, false, true, rc);
|
2005-06-20 18:51:08 +04:00
|
|
|
break;
|
|
|
|
}
|
2009-12-16 02:34:09 +03:00
|
|
|
case MCA_BTL_SM_FRAG_ACK:
|
2008-05-30 07:58:39 +04:00
|
|
|
{
|
|
|
|
int status = (uintptr_t)hdr & MCA_BTL_SM_FRAG_STATUS_MASK;
|
|
|
|
int btl_ownership;
|
2008-08-17 23:00:50 +04:00
|
|
|
struct mca_btl_base_endpoint_t* endpoint;
|
2008-05-30 07:58:39 +04:00
|
|
|
|
|
|
|
frag = (mca_btl_sm_frag_t *)((char*)((uintptr_t)hdr &
|
2009-12-16 02:34:09 +03:00
|
|
|
(~(MCA_BTL_SM_FRAG_TYPE_MASK |
|
|
|
|
MCA_BTL_SM_FRAG_STATUS_MASK))));
|
2008-08-06 18:02:12 +04:00
|
|
|
|
2008-08-17 23:00:50 +04:00
|
|
|
endpoint = frag->endpoint;
|
2008-05-30 07:58:39 +04:00
|
|
|
btl_ownership = (frag->base.des_flags & MCA_BTL_DES_FLAGS_BTL_OWNERSHIP);
|
|
|
|
if( MCA_BTL_DES_SEND_ALWAYS_CALLBACK & frag->base.des_flags ) {
|
|
|
|
/* completion callback */
|
|
|
|
frag->base.des_cbfunc(&mca_btl_sm.super, frag->endpoint,
|
|
|
|
&frag->base, status?OMPI_ERROR:OMPI_SUCCESS);
|
|
|
|
}
|
|
|
|
if( btl_ownership ) {
|
|
|
|
MCA_BTL_SM_FRAG_RETURN(frag);
|
|
|
|
}
|
2009-06-27 04:12:56 +04:00
|
|
|
OPAL_THREAD_ADD32(&mca_btl_sm_component.num_outstanding_frags, -1);
|
|
|
|
if ( 0 < opal_list_get_size(&endpoint->pending_sends) ) {
|
|
|
|
btl_sm_process_pending_sends(endpoint);
|
2008-08-17 23:00:50 +04:00
|
|
|
}
|
2008-06-24 23:01:26 +04:00
|
|
|
goto recheck_peer;
|
2008-05-30 07:58:39 +04:00
|
|
|
}
|
2005-06-20 18:51:08 +04:00
|
|
|
default:
|
|
|
|
/* unknown */
|
2009-02-17 18:58:15 +03:00
|
|
|
/*
|
|
|
|
* This code path should presumably never be called.
|
2009-02-20 22:51:57 +03:00
|
|
|
* It's unclear if it should exist or, if so, how it should be written.
|
2009-02-17 18:58:15 +03:00
|
|
|
* If we want to return it to the sending process,
|
|
|
|
* we have to figure out who the sender is.
|
|
|
|
* It seems we need to subtract the mask bits.
|
|
|
|
* Then, hopefully this is an sm header that has an smp_rank field.
|
|
|
|
* Presumably that means the received header was relative.
|
|
|
|
* Or, maybe this code should just be removed.
|
|
|
|
*/
|
|
|
|
opal_output(0, "mca_btl_sm_component_progress read an unknown type of header");
|
|
|
|
hdr = (mca_btl_sm_hdr_t *) RELATIVE2VIRTUAL(hdr);
|
|
|
|
peer_smp_rank = hdr->my_smp_rank;
|
2007-03-05 17:24:09 +03:00
|
|
|
hdr = (mca_btl_sm_hdr_t*)((uintptr_t)hdr->frag |
|
|
|
|
MCA_BTL_SM_FRAG_STATUS_MASK);
|
|
|
|
MCA_BTL_SM_FIFO_WRITE(
|
|
|
|
mca_btl_sm_component.sm_peers[peer_smp_rank],
|
2009-06-27 04:12:56 +04:00
|
|
|
my_smp_rank, peer_smp_rank, hdr, false, true, rc);
|
2005-06-20 18:51:08 +04:00
|
|
|
break;
|
|
|
|
}
|
2007-03-20 11:15:58 +03:00
|
|
|
}
|
2013-08-28 10:36:01 +04:00
|
|
|
(void)rc; /* this is safe to ignore as the message is requeued till success */
|
2009-12-16 02:34:09 +03:00
|
|
|
|
|
|
|
#if OMPI_BTL_SM_HAVE_KNEM
|
|
|
|
/* The sm btl is currently hard-wired for a single module. So
|
|
|
|
we're not breaking anything here by checking that one module
|
|
|
|
for knem specifics.
|
|
|
|
|
|
|
|
Since knem completes requests in order, we can loop around the
|
|
|
|
circular status buffer until:
|
|
|
|
- we find a KNEM_STATUS_PENDING, or
|
|
|
|
- knem_status_num_used == 0
|
|
|
|
|
|
|
|
Note that knem_status_num_used will never be >0 if
|
|
|
|
component.use_knem<0, so we'll never enter the while loop if
|
|
|
|
knem is not being used. It will also never be >0 if
|
|
|
|
max_simultaneous == 0 (because they will all complete
|
|
|
|
synchronously in _get). However, in order to save a jump
|
|
|
|
before the return we should test the use_knem here.
|
|
|
|
*/
|
|
|
|
if( 0 == mca_btl_sm_component.use_knem ) {
|
|
|
|
return nevents;
|
|
|
|
}
|
|
|
|
while (mca_btl_sm.knem_status_num_used > 0 &&
|
|
|
|
KNEM_STATUS_PENDING !=
|
|
|
|
mca_btl_sm.knem_status_array[mca_btl_sm.knem_status_first_used]) {
|
|
|
|
if (KNEM_STATUS_SUCCESS ==
|
|
|
|
mca_btl_sm.knem_status_array[mca_btl_sm.knem_status_first_used]) {
|
|
|
|
int btl_ownership;
|
|
|
|
|
|
|
|
/* Handle the completed fragment */
|
|
|
|
frag =
|
|
|
|
mca_btl_sm.knem_frag_array[mca_btl_sm.knem_status_first_used];
|
|
|
|
btl_ownership = (frag->base.des_flags &
|
|
|
|
MCA_BTL_DES_FLAGS_BTL_OWNERSHIP);
|
|
|
|
if (0 != (MCA_BTL_DES_SEND_ALWAYS_CALLBACK &
|
|
|
|
frag->base.des_flags)) {
|
|
|
|
frag->base.des_cbfunc(&mca_btl_sm.super,
|
|
|
|
frag->endpoint, &frag->base,
|
|
|
|
OMPI_SUCCESS);
|
|
|
|
}
|
|
|
|
if (btl_ownership) {
|
|
|
|
MCA_BTL_SM_FRAG_RETURN(frag);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Bump counters, loop around the circular buffer if
|
|
|
|
necessary */
|
|
|
|
++nevents;
|
|
|
|
--mca_btl_sm.knem_status_num_used;
|
|
|
|
++mca_btl_sm.knem_status_first_used;
|
|
|
|
if (mca_btl_sm.knem_status_first_used >=
|
|
|
|
mca_btl_sm_component.knem_max_simultaneous) {
|
|
|
|
mca_btl_sm.knem_status_first_used = 0;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* JMS knem fail */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2013-01-13 20:08:48 +04:00
|
|
|
#endif /* OMPI_BTL_SM_HAVE_KNEM */
|
2009-11-04 06:10:35 +03:00
|
|
|
return nevents;
|
2005-05-24 02:06:50 +04:00
|
|
|
}
|