2005-05-23 22:06:50 +00:00
|
|
|
/*
|
2007-03-16 23:11:45 +00:00
|
|
|
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
|
2005-11-05 19:57:48 +00:00
|
|
|
* University Research and Technology
|
|
|
|
* Corporation. All rights reserved.
|
2008-02-18 17:39:30 +00:00
|
|
|
* Copyright (c) 2004-2008 The University of Tennessee and The University
|
2005-11-05 19:57:48 +00:00
|
|
|
* of Tennessee Research Foundation. All rights
|
|
|
|
* reserved.
|
2008-03-09 13:17:13 +00:00
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
2005-05-23 22:06:50 +00:00
|
|
|
* University of Stuttgart. All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
2007-10-22 12:07:22 +00:00
|
|
|
* Copyright (c) 2006-2007 Voltaire. All rights reserved.
|
2009-02-13 03:43:29 +00:00
|
|
|
* Copyright (c) 2009 Cisco Systems, Inc. All rights reserved.
|
2005-05-23 22:06:50 +00:00
|
|
|
* $COPYRIGHT$
|
2008-03-09 13:17:13 +00:00
|
|
|
*
|
2005-05-23 22:06:50 +00:00
|
|
|
* Additional copyrights may follow
|
2008-03-09 13:17:13 +00:00
|
|
|
*
|
2005-05-23 22:06:50 +00:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
#include "ompi_config.h"
|
|
|
|
#include <errno.h>
|
2005-12-10 22:04:28 +00:00
|
|
|
#ifdef HAVE_UNISTD_H
|
2005-05-23 22:06:50 +00:00
|
|
|
#include <unistd.h>
|
2005-12-10 22:04:28 +00:00
|
|
|
#endif /* HAVE_UNISTD_H */
|
|
|
|
#ifdef HAVE_STRING_H
|
2005-05-23 22:06:50 +00:00
|
|
|
#include <string.h>
|
2005-12-10 22:04:28 +00:00
|
|
|
#endif /* HAVE_STRING_H */
|
|
|
|
#ifdef HAVE_FCNTL_H
|
2005-05-23 22:06:50 +00:00
|
|
|
#include <fcntl.h>
|
2005-12-10 22:04:28 +00:00
|
|
|
#endif /* HAVE_FCNTL_H */
|
|
|
|
#ifdef HAVE_SYS_TYPES_H
|
2005-05-23 22:06:50 +00:00
|
|
|
#include <sys/types.h>
|
2005-12-10 22:04:28 +00:00
|
|
|
#endif /* HAVE_SYS_TYPES_H */
|
|
|
|
#ifdef HAVE_SYS_MMAN_H
|
2005-05-23 22:06:50 +00:00
|
|
|
#include <sys/mman.h>
|
2005-12-10 22:04:28 +00:00
|
|
|
#endif /* HAVE_SYS_MMAN_H */
|
|
|
|
#ifdef HAVE_SYS_STAT_H
|
2005-05-23 22:06:50 +00:00
|
|
|
#include <sys/stat.h> /* for mkfifo */
|
2005-12-10 22:04:28 +00:00
|
|
|
#endif /* HAVE_SYS_STAT_H */
|
2005-05-23 22:06:50 +00:00
|
|
|
|
2006-02-12 01:33:29 +00:00
|
|
|
#include "ompi/constants.h"
|
|
|
|
#include "opal/sys/cache.h"
|
2005-07-03 23:09:55 +00:00
|
|
|
#include "opal/event/event.h"
|
2009-02-14 02:26:12 +00:00
|
|
|
#include "opal/util/output.h"
|
2006-02-12 01:33:29 +00:00
|
|
|
#include "orte/util/proc_info.h"
|
2008-02-28 01:57:57 +00:00
|
|
|
#include "orte/runtime/orte_globals.h"
|
|
|
|
|
2006-02-12 01:33:29 +00:00
|
|
|
#include "opal/mca/base/mca_base_param.h"
|
|
|
|
#include "ompi/mca/mpool/base/base.h"
|
|
|
|
#include "ompi/mca/common/sm/common_sm_mmap.h"
|
2007-02-13 12:01:36 +00:00
|
|
|
#include "ompi/mca/btl/base/btl_base_error.h"
|
2008-10-16 15:09:00 +00:00
|
|
|
|
|
|
|
#if OPAL_ENABLE_FT == 1
|
|
|
|
#include "opal/runtime/opal_cr.h"
|
|
|
|
#endif
|
|
|
|
|
2005-06-30 05:50:55 +00:00
|
|
|
#include "btl_sm.h"
|
|
|
|
#include "btl_sm_frag.h"
|
2005-07-28 16:25:09 +00:00
|
|
|
#include "btl_sm_fifo.h"
|
|
|
|
|
2005-05-23 22:06:50 +00:00
|
|
|
/*
|
2008-03-09 13:17:13 +00:00
|
|
|
* Shared Memory (SM) component instance.
|
2005-05-23 22:06:50 +00:00
|
|
|
*/
|
2005-06-30 05:50:55 +00:00
|
|
|
mca_btl_sm_component_t mca_btl_sm_component = {
|
2005-05-23 22:06:50 +00:00
|
|
|
{ /* super is being filled in */
|
|
|
|
/* First, the mca_base_component_t struct containing meta information
|
|
|
|
about the component itself */
|
|
|
|
{
|
2008-07-28 22:40:57 +00:00
|
|
|
MCA_BTL_BASE_VERSION_2_0_0,
|
|
|
|
|
2005-05-23 22:06:50 +00: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-04 20:12:36 +00: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 05:50:55 +00:00
|
|
|
mca_btl_sm_component_open, /* component open */
|
|
|
|
mca_btl_sm_component_close /* component close */
|
2005-05-23 22:06:50 +00:00
|
|
|
},
|
|
|
|
{
|
2008-10-16 15:09:00 +00:00
|
|
|
/* The component is checkpoint ready */
|
|
|
|
MCA_BASE_METADATA_PARAM_CHECKPOINT
|
2005-05-23 22:06:50 +00:00
|
|
|
},
|
|
|
|
|
2008-03-09 13:17:13 +00:00
|
|
|
mca_btl_sm_component_init,
|
2005-06-30 05:50:55 +00:00
|
|
|
mca_btl_sm_component_progress,
|
2005-05-23 22:06:50 +00:00
|
|
|
} /* end super */
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* utility routines for parameter registration
|
|
|
|
*/
|
|
|
|
|
2005-06-30 05:50:55 +00:00
|
|
|
static inline char* mca_btl_sm_param_register_string(
|
2008-03-09 13:17:13 +00:00
|
|
|
const char* param_name,
|
2005-05-23 22:06:50 +00:00
|
|
|
const char* default_value)
|
|
|
|
{
|
|
|
|
char *param_value;
|
2005-09-07 13:40:22 +00:00
|
|
|
int id = mca_base_param_register_string("btl","sm",param_name,NULL,default_value);
|
2005-05-23 22:06:50 +00:00
|
|
|
mca_base_param_lookup_string(id, ¶m_value);
|
|
|
|
return param_value;
|
|
|
|
}
|
2008-03-09 13:17:13 +00:00
|
|
|
|
2005-06-30 05:50:55 +00:00
|
|
|
static inline int mca_btl_sm_param_register_int(
|
2008-03-09 13:17:13 +00:00
|
|
|
const char* param_name,
|
2005-05-23 22:06:50 +00:00
|
|
|
int default_value)
|
|
|
|
{
|
2005-09-07 13:40:22 +00:00
|
|
|
int id = mca_base_param_register_int("btl","sm",param_name,NULL,default_value);
|
2005-05-23 22:06:50 +00: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.
|
|
|
|
*/
|
|
|
|
|
2005-06-30 05:50:55 +00:00
|
|
|
int mca_btl_sm_component_open(void)
|
2005-05-23 22:06:50 +00:00
|
|
|
{
|
|
|
|
/* register SM component parameters */
|
2005-06-30 05:50:55 +00:00
|
|
|
mca_btl_sm_component.sm_free_list_num =
|
2005-10-09 18:15:12 +00:00
|
|
|
mca_btl_sm_param_register_int("free_list_num", 8);
|
2005-06-30 05:50:55 +00:00
|
|
|
mca_btl_sm_component.sm_free_list_max =
|
|
|
|
mca_btl_sm_param_register_int("free_list_max", -1);
|
|
|
|
mca_btl_sm_component.sm_free_list_inc =
|
2006-10-06 21:13:49 +00:00
|
|
|
mca_btl_sm_param_register_int("free_list_inc", 64);
|
2005-06-30 05:50:55 +00:00
|
|
|
mca_btl_sm_component.sm_max_procs =
|
|
|
|
mca_btl_sm_param_register_int("max_procs", -1);
|
|
|
|
mca_btl_sm_component.sm_mpool_name =
|
|
|
|
mca_btl_sm_param_register_string("mpool", "sm");
|
2009-02-17 15:58:15 +00:00
|
|
|
mca_btl_sm_component.fifo_size =
|
|
|
|
mca_btl_sm_param_register_int("fifo_size", 4096);
|
|
|
|
mca_btl_sm_component.nfifos =
|
|
|
|
mca_btl_sm_param_register_int("num_fifos", 1);
|
|
|
|
/* make sure the number of fifos is a power of 2 */
|
|
|
|
{
|
|
|
|
int i = 1;
|
|
|
|
while ( i < mca_btl_sm_component.nfifos )
|
|
|
|
i <<= 1;
|
|
|
|
mca_btl_sm_component.nfifos = i;
|
2005-05-23 22:06:50 +00:00
|
|
|
}
|
2009-02-17 15:58:15 +00:00
|
|
|
mca_btl_sm_component.fifo_lazy_free =
|
|
|
|
mca_btl_sm_param_register_int("fifo_lazy_free", 120);
|
|
|
|
|
|
|
|
/* 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-23 22:06:50 +00:00
|
|
|
|
|
|
|
/* default number of extra procs to allow for future growth */
|
2005-06-30 05:50:55 +00:00
|
|
|
mca_btl_sm_component.sm_extra_procs =
|
2009-02-17 15:58:15 +00:00
|
|
|
mca_btl_sm_param_register_int("sm_extra_procs", 0);
|
2005-05-23 22:06:50 +00:00
|
|
|
|
2007-05-17 07:54:27 +00:00
|
|
|
mca_btl_sm.super.btl_exclusivity = MCA_BTL_EXCLUSIVITY_HIGH-1;
|
|
|
|
mca_btl_sm.super.btl_eager_limit = 4*1024;
|
2007-12-16 08:35:17 +00:00
|
|
|
mca_btl_sm.super.btl_rndv_eager_limit = 4*1024;
|
2007-05-17 07:54:27 +00:00
|
|
|
mca_btl_sm.super.btl_max_send_size = 32*1024;
|
2007-06-21 07:12:40 +00:00
|
|
|
mca_btl_sm.super.btl_rdma_pipeline_send_length = 32*1024;
|
2007-05-17 07:54:27 +00:00
|
|
|
mca_btl_sm.super.btl_rdma_pipeline_frag_size = 32*1024;
|
|
|
|
mca_btl_sm.super.btl_min_rdma_pipeline_size = 0;
|
|
|
|
mca_btl_sm.super.btl_flags = MCA_BTL_FLAGS_SEND;
|
|
|
|
mca_btl_sm.super.btl_bandwidth = 900;
|
|
|
|
mca_btl_sm.super.btl_latency = 100;
|
|
|
|
|
2008-03-09 13:17:13 +00:00
|
|
|
mca_btl_base_param_register(&mca_btl_sm_component.super.btl_version,
|
2007-05-17 07:54:27 +00:00
|
|
|
&mca_btl_sm.super);
|
|
|
|
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-23 22:06:50 +00:00
|
|
|
/* initialize objects */
|
2005-07-03 22:45:48 +00:00
|
|
|
OBJ_CONSTRUCT(&mca_btl_sm_component.sm_lock, opal_mutex_t);
|
2008-05-30 03:58:39 +00: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);
|
2007-10-22 12:07:22 +00:00
|
|
|
OBJ_CONSTRUCT(&mca_btl_sm_component.pending_send_fl, opal_free_list_t);
|
2005-05-23 22:06:50 +00:00
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* component cleanup - sanity checking of queue lengths
|
|
|
|
*/
|
|
|
|
|
2005-06-30 05:50:55 +00:00
|
|
|
int mca_btl_sm_component_close(void)
|
2005-05-23 22:06:50 +00:00
|
|
|
{
|
2006-07-12 22:12:07 +00:00
|
|
|
int return_value = OMPI_SUCCESS;
|
2005-05-23 22:06:50 +00:00
|
|
|
|
2005-06-30 05:50:55 +00:00
|
|
|
OBJ_DESTRUCT(&mca_btl_sm_component.sm_lock);
|
2006-07-13 07:42:18 +00:00
|
|
|
/**
|
|
|
|
* We don't have to destroy the fragment lists. They are allocated
|
|
|
|
* directly into the mmapped file, they will auto-magically dissapear
|
|
|
|
* when the file get unmapped.
|
|
|
|
*/
|
2008-05-30 03:58:39 +00:00
|
|
|
/*OBJ_DESTRUCT(&mca_btl_sm_component.sm_frags_eager);*/
|
|
|
|
/*OBJ_DESTRUCT(&mca_btl_sm_component.sm_frags_max);*/
|
2005-05-23 22:06:50 +00:00
|
|
|
|
|
|
|
/* unmap the shared memory control structure */
|
2005-06-30 05:50:55 +00:00
|
|
|
if(mca_btl_sm_component.mmap_file != NULL) {
|
2005-12-31 15:07:48 +00:00
|
|
|
return_value = mca_common_sm_mmap_fini( mca_btl_sm_component.mmap_file );
|
2006-07-12 22:12:07 +00:00
|
|
|
if( OMPI_SUCCESS != return_value ) {
|
2005-05-23 22:06:50 +00:00
|
|
|
return_value=OMPI_ERROR;
|
2008-06-09 14:53:58 +00:00
|
|
|
opal_output(0," munmap failed :: file - %s :: errno - %d \n",
|
2005-06-30 05:50:55 +00:00
|
|
|
mca_btl_sm_component.mmap_file->map_addr,
|
2005-05-23 22:06:50 +00:00
|
|
|
errno);
|
|
|
|
goto CLEANUP;
|
|
|
|
}
|
2008-03-09 13:17:13 +00:00
|
|
|
|
2005-05-23 22:06:50 +00: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 15:07:48 +00:00
|
|
|
* to call this, so that in an abnormal termination scenario,
|
2005-05-23 22:06:50 +00:00
|
|
|
* this file will still get cleaned up */
|
2008-10-16 15:09:00 +00:00
|
|
|
#if OPAL_ENABLE_FT == 1
|
|
|
|
/* 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 ) {
|
|
|
|
unlink(mca_btl_sm_component.mmap_file->map_path);
|
|
|
|
}
|
|
|
|
#else
|
2005-06-30 05:50:55 +00:00
|
|
|
unlink(mca_btl_sm_component.mmap_file->map_path);
|
2008-10-16 15:09:00 +00:00
|
|
|
#endif
|
2006-07-19 20:55:29 +00:00
|
|
|
OBJ_RELEASE(mca_btl_sm_component.mmap_file);
|
2005-05-23 22:06:50 +00:00
|
|
|
}
|
|
|
|
|
2009-05-06 20:11:28 +00:00
|
|
|
#if OPAL_ENABLE_PROGRESS_THREADS == 1
|
2005-05-23 22:06:50 +00:00
|
|
|
/* close/cleanup fifo create for event notification */
|
2005-06-30 05:50:55 +00:00
|
|
|
if(mca_btl_sm_component.sm_fifo_fd > 0) {
|
2005-05-23 22:06:50 +00:00
|
|
|
/* write a done message down the pipe */
|
|
|
|
unsigned char cmd = DONE;
|
2008-03-09 13:17:13 +00:00
|
|
|
if( write(mca_btl_sm_component.sm_fifo_fd,&cmd,sizeof(cmd)) !=
|
2005-05-23 22:06:50 +00:00
|
|
|
sizeof(cmd)){
|
2008-06-09 14:53:58 +00:00
|
|
|
opal_output(0, "mca_btl_sm_component_close: write fifo failed: errno=%d\n",
|
2005-05-23 22:06:50 +00:00
|
|
|
errno);
|
|
|
|
}
|
2005-07-03 22:45:48 +00:00
|
|
|
opal_thread_join(&mca_btl_sm_component.sm_fifo_thread, NULL);
|
2005-06-30 05:50:55 +00:00
|
|
|
close(mca_btl_sm_component.sm_fifo_fd);
|
|
|
|
unlink(mca_btl_sm_component.sm_fifo_path);
|
2005-05-23 22:06:50 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-02-13 03:43:29 +00:00
|
|
|
if (NULL != mca_btl_sm_component.sm_mpool_name) {
|
|
|
|
free(mca_btl_sm_component.sm_mpool_name);
|
|
|
|
}
|
2005-05-23 22:06:50 +00:00
|
|
|
|
|
|
|
CLEANUP:
|
|
|
|
|
|
|
|
/* return */
|
|
|
|
return return_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* SM component initialization
|
|
|
|
*/
|
2005-06-30 05:50:55 +00:00
|
|
|
mca_btl_base_module_t** mca_btl_sm_component_init(
|
2008-03-09 13:17:13 +00:00
|
|
|
int *num_btls,
|
2005-05-23 22:06:50 +00:00
|
|
|
bool enable_progress_threads,
|
|
|
|
bool enable_mpi_threads)
|
|
|
|
{
|
2007-05-23 14:03:52 +00:00
|
|
|
mca_btl_base_module_t **btls = NULL;
|
2005-05-23 22:06:50 +00:00
|
|
|
|
2007-05-23 14:03:52 +00:00
|
|
|
*num_btls = 0;
|
2005-05-23 22:06:50 +00:00
|
|
|
|
|
|
|
/* lookup/create shared memory pool only when used */
|
2005-06-30 05:50:55 +00:00
|
|
|
mca_btl_sm_component.sm_mpool = NULL;
|
|
|
|
mca_btl_sm_component.sm_mpool_base = NULL;
|
2005-05-23 22:06:50 +00:00
|
|
|
|
2009-05-06 20:11:28 +00:00
|
|
|
#if OPAL_ENABLE_PROGRESS_THREADS == 1
|
2005-05-23 22:06:50 +00:00
|
|
|
/* create a named pipe to receive events */
|
2008-03-09 13:17:13 +00:00
|
|
|
sprintf( mca_btl_sm_component.sm_fifo_path,
|
2009-03-05 21:56:03 +00:00
|
|
|
"%s"OPAL_PATH_SEP"sm_fifo.%lu", orte_process_info.job_session_dir,
|
2008-02-28 01:57:57 +00:00
|
|
|
(unsigned long)ORTE_PROC_MY_NAME->vpid );
|
2005-06-30 05:50:55 +00:00
|
|
|
if(mkfifo(mca_btl_sm_component.sm_fifo_path, 0660) < 0) {
|
2008-06-09 14:53:58 +00:00
|
|
|
opal_output(0, "mca_btl_sm_component_init: mkfifo failed with errno=%d\n",errno);
|
2005-05-23 22:06:50 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2005-06-30 05:50:55 +00:00
|
|
|
mca_btl_sm_component.sm_fifo_fd = open(mca_btl_sm_component.sm_fifo_path, O_RDWR);
|
|
|
|
if(mca_btl_sm_component.sm_fifo_fd < 0) {
|
2008-06-09 14:53:58 +00:00
|
|
|
opal_output(0, "mca_btl_sm_component_init: open(%s) failed with errno=%d\n",
|
2005-06-30 05:50:55 +00:00
|
|
|
mca_btl_sm_component.sm_fifo_path, errno);
|
2005-05-23 22:06:50 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2005-07-03 22:45:48 +00:00
|
|
|
OBJ_CONSTRUCT(&mca_btl_sm_component.sm_fifo_thread, opal_thread_t);
|
|
|
|
mca_btl_sm_component.sm_fifo_thread.t_run = (opal_thread_fn_t) mca_btl_sm_component_event_thread;
|
|
|
|
opal_thread_start(&mca_btl_sm_component.sm_fifo_thread);
|
2005-05-23 22:06:50 +00:00
|
|
|
#endif
|
|
|
|
|
2007-05-23 14:03:52 +00:00
|
|
|
/* allocate the Shared Memory BTL */
|
|
|
|
*num_btls = 1;
|
2008-03-09 13:22:12 +00:00
|
|
|
btls = (mca_btl_base_module_t**)malloc(sizeof(mca_btl_base_module_t*));
|
2007-05-23 14:03:52 +00:00
|
|
|
if (NULL == btls) {
|
2005-05-23 22:06:50 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2007-05-23 14:03:52 +00:00
|
|
|
/* get pointer to the btls */
|
|
|
|
btls[0] = (mca_btl_base_module_t *)(&(mca_btl_sm));
|
2005-05-23 22:06:50 +00:00
|
|
|
|
|
|
|
/* initialize some PTL data */
|
|
|
|
/* start with no SM procs */
|
2005-06-30 05:50:55 +00:00
|
|
|
mca_btl_sm_component.num_smp_procs = 0;
|
2007-03-20 08:15:58 +00:00
|
|
|
mca_btl_sm_component.my_smp_rank = -1; /* not defined */
|
2005-05-23 22:06:50 +00:00
|
|
|
|
2007-05-23 14:03:52 +00:00
|
|
|
/* set flag indicating btl not inited */
|
2007-03-20 08:15:58 +00:00
|
|
|
mca_btl_sm.btl_inited=false;
|
2005-05-23 22:06:50 +00:00
|
|
|
|
2007-05-23 14:03:52 +00:00
|
|
|
return btls;
|
2005-05-23 22:06:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* SM component progress.
|
|
|
|
*/
|
|
|
|
|
2009-05-06 20:11:28 +00:00
|
|
|
#if OPAL_ENABLE_PROGRESS_THREADS == 1
|
2005-07-03 16:06:07 +00:00
|
|
|
void mca_btl_sm_component_event_thread(opal_object_t* thread)
|
2005-05-23 22:06:50 +00:00
|
|
|
{
|
|
|
|
while(1) {
|
|
|
|
unsigned char cmd;
|
2005-06-30 05:50:55 +00:00
|
|
|
if(read(mca_btl_sm_component.sm_fifo_fd, &cmd, sizeof(cmd)) != sizeof(cmd)) {
|
2005-05-23 22:06:50 +00:00
|
|
|
/* error condition */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if( DONE == cmd ){
|
|
|
|
/* return when done message received */
|
|
|
|
return;
|
2008-03-09 13:17:13 +00:00
|
|
|
}
|
2005-09-11 20:55:22 +00:00
|
|
|
mca_btl_sm_component_progress();
|
2005-05-23 22:06:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-06-27 00:12:56 +00:00
|
|
|
void btl_sm_process_pending_sends(struct mca_btl_base_endpoint_t *ep)
|
2008-08-17 19:00:50 +00:00
|
|
|
{
|
|
|
|
btl_sm_pending_send_item_t *si;
|
|
|
|
int rc;
|
|
|
|
|
2009-06-27 00:12:56 +00:00
|
|
|
while ( 0 < opal_list_get_size(&ep->pending_sends) ) {
|
|
|
|
|
|
|
|
si = (btl_sm_pending_send_item_t*)opal_list_remove_first(&ep->pending_sends);
|
|
|
|
if(NULL == si) return; /* ??? WHAT DOES THIS CONDITION MEAN? */
|
2008-08-17 19:00:50 +00:00
|
|
|
|
2009-06-27 00:12:56 +00:00
|
|
|
OPAL_FREE_LIST_RETURN(&mca_btl_sm_component.pending_send_fl, (opal_list_item_t*)si);
|
|
|
|
|
|
|
|
OPAL_THREAD_ADD32(&mca_btl_sm_component.num_pending_sends, -1);
|
2008-08-17 19:00:50 +00:00
|
|
|
|
2009-06-27 00:12:56 +00:00
|
|
|
MCA_BTL_SM_FIFO_WRITE(ep, ep->my_smp_rank, ep->peer_smp_rank, si->data,
|
|
|
|
true, false, rc);
|
2008-08-17 19:00:50 +00:00
|
|
|
|
2009-06-27 00:12:56 +00:00
|
|
|
if ( OMPI_SUCCESS != rc )
|
|
|
|
return;
|
|
|
|
}
|
2008-08-17 19:00:50 +00:00
|
|
|
}
|
|
|
|
|
2005-06-30 05:50:55 +00:00
|
|
|
int mca_btl_sm_component_progress(void)
|
2005-05-23 22:06:50 +00:00
|
|
|
{
|
|
|
|
/* local variables */
|
2005-06-30 05:50:55 +00:00
|
|
|
mca_btl_sm_frag_t *frag;
|
2007-08-27 21:41:04 +00:00
|
|
|
mca_btl_sm_frag_t Frag;
|
2009-02-17 15:58:15 +00:00
|
|
|
sm_fifo_t *fifo = NULL;
|
2007-03-05 14:17:50 +00:00
|
|
|
mca_btl_sm_hdr_t *hdr;
|
2007-10-22 12:07:22 +00:00
|
|
|
int my_smp_rank = mca_btl_sm_component.my_smp_rank;
|
2009-02-17 15:58:15 +00:00
|
|
|
int peer_smp_rank, j, rc = 0;
|
2005-05-23 22:06:50 +00:00
|
|
|
|
2009-06-27 00:12:56 +00: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-23 22:06:50 +00:00
|
|
|
/* poll each fifo */
|
2009-02-17 15:58:15 +00: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 19:01:26 +00:00
|
|
|
recheck_peer:
|
2005-05-23 22:06:50 +00:00
|
|
|
/* aquire thread lock */
|
2007-03-20 08:15:58 +00:00
|
|
|
if(opal_using_threads()) {
|
2009-02-17 15:58:15 +00:00
|
|
|
opal_atomic_lock(&(fifo->tail_lock));
|
2005-05-23 22:06:50 +00:00
|
|
|
}
|
|
|
|
|
2009-02-17 15:58:15 +00:00
|
|
|
hdr = (mca_btl_sm_hdr_t *)sm_fifo_read(fifo);
|
2005-05-23 22:06:50 +00:00
|
|
|
|
|
|
|
/* release thread lock */
|
2007-03-20 08:15:58 +00:00
|
|
|
if(opal_using_threads()) {
|
2009-02-17 15:58:15 +00:00
|
|
|
opal_atomic_unlock(&(fifo->tail_lock));
|
2005-05-23 22:06:50 +00:00
|
|
|
}
|
|
|
|
|
2009-02-17 15:58:15 +00:00
|
|
|
if(SM_FIFO_FREE == hdr) {
|
2006-02-02 17:32:22 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2008-05-30 03:58:39 +00:00
|
|
|
rc++;
|
2005-06-20 14:51:08 +00:00
|
|
|
/* dispatch fragment by type */
|
2007-03-05 14:24:09 +00:00
|
|
|
switch(((uintptr_t)hdr) & MCA_BTL_SM_FRAG_TYPE_MASK) {
|
2005-06-30 05:50:55 +00:00
|
|
|
case MCA_BTL_SM_FRAG_SEND:
|
2005-06-20 14:51:08 +00:00
|
|
|
{
|
2008-01-15 05:32:53 +00:00
|
|
|
mca_btl_active_message_callback_t* reg;
|
2007-03-05 14:24:09 +00:00
|
|
|
/* change the address from address relative to the shared
|
2007-10-22 12:07:22 +00:00
|
|
|
* memory address, to a true virtual address */
|
2009-02-17 15:58:15 +00:00
|
|
|
hdr = (mca_btl_sm_hdr_t *) RELATIVE2VIRTUAL(hdr);
|
|
|
|
peer_smp_rank = hdr->my_smp_rank;
|
2009-05-06 20:11:28 +00:00
|
|
|
#if OPAL_ENABLE_DEBUG
|
2009-02-20 19:51:57 +00:00
|
|
|
if ( FIFO_MAP(peer_smp_rank) != j ) {
|
2009-02-17 15:58:15 +00:00
|
|
|
opal_output(0, "mca_btl_sm_component_progress: "
|
|
|
|
"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 19:51:57 +00:00
|
|
|
}
|
|
|
|
#endif
|
2005-06-20 14:51:08 +00:00
|
|
|
/* recv upcall */
|
2008-01-15 05:32:53 +00:00
|
|
|
reg = mca_btl_base_active_message_trigger + hdr->tag;
|
2007-08-27 21:41:04 +00:00
|
|
|
Frag.segment.seg_addr.pval = ((char*)hdr) +
|
|
|
|
sizeof(mca_btl_sm_hdr_t);
|
|
|
|
Frag.segment.seg_len = hdr->len;
|
2007-08-28 03:08:36 +00:00
|
|
|
Frag.base.des_dst_cnt = 1;
|
|
|
|
Frag.base.des_dst = &(Frag.segment);
|
2007-08-27 21:41:04 +00:00
|
|
|
reg->cbfunc(&mca_btl_sm.super, hdr->tag, &(Frag.base),
|
2008-06-24 19:01:26 +00:00
|
|
|
reg->cbdata);
|
2009-02-20 19:51:57 +00:00
|
|
|
/* return the fragment */
|
2007-03-05 14:24:09 +00:00
|
|
|
MCA_BTL_SM_FIFO_WRITE(
|
|
|
|
mca_btl_sm_component.sm_peers[peer_smp_rank],
|
2009-06-27 00:12:56 +00:00
|
|
|
my_smp_rank, peer_smp_rank, hdr->frag, false, true, rc);
|
2005-06-20 14:51:08 +00:00
|
|
|
break;
|
|
|
|
}
|
2008-05-30 03:58:39 +00:00
|
|
|
case MCA_BTL_SM_FRAG_ACK:
|
|
|
|
{
|
|
|
|
int status = (uintptr_t)hdr & MCA_BTL_SM_FRAG_STATUS_MASK;
|
|
|
|
int btl_ownership;
|
2008-08-17 19:00:50 +00:00
|
|
|
struct mca_btl_base_endpoint_t* endpoint;
|
2008-05-30 03:58:39 +00:00
|
|
|
|
|
|
|
frag = (mca_btl_sm_frag_t *)((char*)((uintptr_t)hdr &
|
|
|
|
(~(MCA_BTL_SM_FRAG_TYPE_MASK |
|
|
|
|
MCA_BTL_SM_FRAG_STATUS_MASK))));
|
2008-08-06 14:02:12 +00:00
|
|
|
|
2008-08-17 19:00:50 +00:00
|
|
|
endpoint = frag->endpoint;
|
2008-05-30 03:58:39 +00: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 00:12:56 +00: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 19:00:50 +00:00
|
|
|
}
|
2008-06-24 19:01:26 +00:00
|
|
|
goto recheck_peer;
|
2008-05-30 03:58:39 +00:00
|
|
|
}
|
2005-06-20 14:51:08 +00:00
|
|
|
default:
|
|
|
|
/* unknown */
|
2009-02-17 15:58:15 +00:00
|
|
|
/*
|
|
|
|
* This code path should presumably never be called.
|
2009-02-20 19:51:57 +00:00
|
|
|
* It's unclear if it should exist or, if so, how it should be written.
|
2009-02-17 15:58:15 +00: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 14:24:09 +00: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 00:12:56 +00:00
|
|
|
my_smp_rank, peer_smp_rank, hdr, false, true, rc);
|
2005-06-20 14:51:08 +00:00
|
|
|
break;
|
|
|
|
}
|
2007-03-20 08:15:58 +00:00
|
|
|
}
|
2005-05-23 22:06:50 +00:00
|
|
|
return rc;
|
|
|
|
}
|