2004-06-04 02:13:01 +04:00
|
|
|
/*
|
2004-11-22 04:38:40 +03:00
|
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University.
|
|
|
|
* All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
|
|
|
|
* All rights reserved.
|
2004-11-28 23:09:25 +03:00
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
|
|
* University of Stuttgart. All rights reserved.
|
2005-03-24 15:43:37 +03:00
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
2004-11-22 04:38:40 +03:00
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
2004-06-04 02:13:01 +04:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
2004-10-20 05:03:09 +04:00
|
|
|
#include "ompi_config.h"
|
2004-06-04 02:13:01 +04:00
|
|
|
#include <errno.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/mman.h>
|
2004-12-10 07:32:49 +03:00
|
|
|
#include <sys/stat.h> /* for mkfifo */
|
2004-06-04 02:13:01 +04:00
|
|
|
|
2005-08-13 01:42:07 +04:00
|
|
|
#include "ompi/include/constants.h"
|
2004-09-04 02:34:52 +04:00
|
|
|
#include "include/sys/cache.h"
|
2005-07-04 03:09:55 +04:00
|
|
|
#include "opal/event/event.h"
|
2005-07-04 05:36:20 +04:00
|
|
|
#include "opal/util/if.h"
|
2005-07-04 04:13:44 +04:00
|
|
|
#include "opal/util/argv.h"
|
2005-07-04 03:31:27 +04:00
|
|
|
#include "opal/util/output.h"
|
2004-06-12 00:42:01 +04:00
|
|
|
#include "util/sys_info.h"
|
2004-12-07 18:38:01 +03:00
|
|
|
#include "util/proc_info.h"
|
2004-06-04 02:13:01 +04:00
|
|
|
#include "mca/pml/pml.h"
|
|
|
|
#include "mca/ptl/ptl.h"
|
2004-06-24 23:28:30 +04:00
|
|
|
#include "mca/pml/base/pml_base_sendreq.h"
|
2004-06-04 02:13:01 +04:00
|
|
|
#include "mca/base/mca_base_param.h"
|
2004-06-12 00:42:01 +04:00
|
|
|
#include "mca/ptl/sm/src/ptl_sm.h"
|
2004-06-18 00:57:47 +04:00
|
|
|
#include "mca/mpool/base/base.h"
|
2004-12-07 18:38:01 +03:00
|
|
|
#include "mca/oob/base/base.h"
|
2004-06-04 02:13:01 +04:00
|
|
|
#include "ptl_sm.h"
|
|
|
|
#include "ptl_sm_sendreq.h"
|
|
|
|
#include "ptl_sm_sendfrag.h"
|
|
|
|
#include "ptl_sm_recvfrag.h"
|
2004-08-11 20:06:14 +04:00
|
|
|
#include "mca/common/sm/common_sm_mmap.h"
|
2004-06-04 02:13:01 +04:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
2004-08-02 04:24:22 +04:00
|
|
|
* Shared Memory (SM) component instance.
|
2004-06-04 02:13:01 +04:00
|
|
|
*/
|
|
|
|
|
2004-08-02 04:24:22 +04:00
|
|
|
mca_ptl_sm_component_t mca_ptl_sm_component = {
|
2004-08-28 20:45:14 +04:00
|
|
|
{ /* super is being filled in */
|
2004-08-06 01:59:24 +04:00
|
|
|
/* First, the mca_base_component_t struct containing meta information
|
|
|
|
about the component itself */
|
|
|
|
{
|
|
|
|
/* Indicate that we are a pml v1.0.0 component (which also implies a
|
|
|
|
specific MCA version) */
|
|
|
|
MCA_PTL_BASE_VERSION_1_0_0,
|
|
|
|
"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 */
|
2004-08-06 01:59:24 +04:00
|
|
|
mca_ptl_sm_component_open, /* component open */
|
|
|
|
mca_ptl_sm_component_close /* component close */
|
|
|
|
},
|
|
|
|
|
|
|
|
/* Next the MCA v1.0.0 component meta data */
|
|
|
|
{
|
|
|
|
/* Whether the component is checkpointable or not */
|
|
|
|
false
|
|
|
|
},
|
2004-08-04 21:23:34 +04:00
|
|
|
|
2004-08-06 01:59:24 +04:00
|
|
|
mca_ptl_sm_component_init,
|
|
|
|
mca_ptl_sm_component_control,
|
|
|
|
mca_ptl_sm_component_progress,
|
2004-08-28 20:45:14 +04:00
|
|
|
} /* end super */
|
2004-06-04 02:13:01 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* utility routines for parameter registration
|
|
|
|
*/
|
|
|
|
|
|
|
|
static inline char* mca_ptl_sm_param_register_string(
|
|
|
|
const char* param_name,
|
|
|
|
const char* default_value)
|
|
|
|
{
|
|
|
|
char *param_value;
|
|
|
|
int id = mca_base_param_register_string("ptl","sm",param_name,NULL,default_value);
|
|
|
|
mca_base_param_lookup_string(id, ¶m_value);
|
|
|
|
return param_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int mca_ptl_sm_param_register_int(
|
|
|
|
const char* param_name,
|
|
|
|
int default_value)
|
|
|
|
{
|
|
|
|
int id = mca_base_param_register_int("ptl","sm",param_name,NULL,default_value);
|
|
|
|
int param_value = default_value;
|
|
|
|
mca_base_param_lookup_int(id,¶m_value);
|
|
|
|
return param_value;
|
|
|
|
}
|
2004-08-06 23:35:57 +04:00
|
|
|
|
|
|
|
|
2004-06-04 02:13:01 +04:00
|
|
|
/*
|
2004-08-02 04:24:22 +04:00
|
|
|
* Called by MCA framework to open the component, registers
|
|
|
|
* component parameters.
|
2004-06-04 02:13:01 +04:00
|
|
|
*/
|
|
|
|
|
2004-08-02 04:24:22 +04:00
|
|
|
int mca_ptl_sm_component_open(void)
|
2004-06-04 02:13:01 +04:00
|
|
|
{
|
2004-08-02 04:24:22 +04:00
|
|
|
/* register SM component parameters */
|
2004-09-14 16:28:33 +04:00
|
|
|
mca_ptl_sm_component.sm_first_frag_free_list_num =
|
|
|
|
mca_ptl_sm_param_register_int("first_frag_free_list_num", 256);
|
|
|
|
mca_ptl_sm_component.sm_first_frag_free_list_max =
|
|
|
|
mca_ptl_sm_param_register_int("first_frag_free_list_max", -1);
|
|
|
|
mca_ptl_sm_component.sm_first_frag_free_list_inc =
|
|
|
|
mca_ptl_sm_param_register_int("first_frag_free_list_inc", 256);
|
|
|
|
mca_ptl_sm_component.sm_second_frag_free_list_num =
|
|
|
|
mca_ptl_sm_param_register_int("second_frag_free_list_num", 256);
|
|
|
|
mca_ptl_sm_component.sm_second_frag_free_list_max =
|
|
|
|
mca_ptl_sm_param_register_int("second_frag_free_list_max", -1);
|
|
|
|
mca_ptl_sm_component.sm_second_frag_free_list_inc =
|
|
|
|
mca_ptl_sm_param_register_int("second_frag_free_list_inc", 256);
|
2004-08-02 04:24:22 +04:00
|
|
|
mca_ptl_sm_component.sm_max_procs =
|
2004-06-12 00:42:01 +04:00
|
|
|
mca_ptl_sm_param_register_int("max_procs", -1);
|
2004-10-22 02:40:25 +04:00
|
|
|
mca_ptl_sm_component.sm_extra_procs =
|
|
|
|
mca_ptl_sm_param_register_int("sm_extra_procs", -1);
|
2004-08-02 04:24:22 +04:00
|
|
|
mca_ptl_sm_component.sm_mpool_name =
|
2004-06-18 00:57:47 +04:00
|
|
|
mca_ptl_sm_param_register_string("mpool", "sm");
|
2004-09-13 17:52:43 +04:00
|
|
|
mca_ptl_sm_component.first_fragment_size =
|
|
|
|
mca_ptl_sm_param_register_int("first_fragment_size", 1024);
|
|
|
|
mca_ptl_sm_component.max_fragment_size =
|
|
|
|
mca_ptl_sm_param_register_int("max_fragment_size", 8*1024);
|
2004-09-04 02:34:52 +04:00
|
|
|
mca_ptl_sm_component.fragment_alignment =
|
|
|
|
mca_ptl_sm_param_register_int("fragment_alignment",
|
|
|
|
CACHE_LINE_SIZE);
|
2004-09-16 19:40:24 +04:00
|
|
|
mca_ptl_sm_component.size_of_cb_queue =
|
|
|
|
mca_ptl_sm_param_register_int("size_of_cb_queue", 128);
|
|
|
|
mca_ptl_sm_component.cb_lazy_free_freq =
|
2004-11-04 07:03:32 +03:00
|
|
|
mca_ptl_sm_param_register_int("cb_lazy_free_freq", 120);
|
2004-09-16 19:40:24 +04:00
|
|
|
/* make sure that queue size and lazy free frequency are consistent -
|
|
|
|
* want to make sure that slots are freed at a rate they can be
|
|
|
|
* reused, w/o allocating extra new circular buffer fifo arrays */
|
|
|
|
if( (float)(mca_ptl_sm_component.cb_lazy_free_freq) >=
|
|
|
|
0.95*(float)(mca_ptl_sm_component.size_of_cb_queue) ) {
|
|
|
|
/* upper limit */
|
|
|
|
mca_ptl_sm_component.cb_lazy_free_freq=
|
|
|
|
(int)(0.95*(float)(mca_ptl_sm_component.size_of_cb_queue));
|
|
|
|
/* lower limit */
|
|
|
|
if( 0>= mca_ptl_sm_component.cb_lazy_free_freq ) {
|
|
|
|
mca_ptl_sm_component.cb_lazy_free_freq=1;
|
|
|
|
}
|
|
|
|
}
|
2004-06-04 02:13:01 +04:00
|
|
|
|
2004-08-28 20:45:14 +04:00
|
|
|
/* default number of extra procs to allow for future growth */
|
|
|
|
mca_ptl_sm_component.sm_extra_procs =
|
|
|
|
mca_ptl_sm_param_register_int("sm_extra_procs", 2);
|
|
|
|
|
2004-06-04 02:13:01 +04:00
|
|
|
/* initialize objects */
|
2005-07-04 02:45:48 +04:00
|
|
|
OBJ_CONSTRUCT(&mca_ptl_sm_component.sm_lock, opal_mutex_t);
|
2004-11-04 07:03:32 +03:00
|
|
|
OBJ_CONSTRUCT(&mca_ptl_sm_component.sm_send_requests, ompi_free_list_t);
|
|
|
|
OBJ_CONSTRUCT(&mca_ptl_sm_component.sm_first_frags, ompi_free_list_t);
|
|
|
|
OBJ_CONSTRUCT(&mca_ptl_sm_component.sm_second_frags, ompi_free_list_t);
|
2005-07-04 02:45:48 +04:00
|
|
|
OBJ_CONSTRUCT(&mca_ptl_sm_component.sm_pending_ack_lock, opal_mutex_t);
|
2005-07-03 20:22:16 +04:00
|
|
|
OBJ_CONSTRUCT(&mca_ptl_sm_component.sm_pending_ack, opal_list_t);
|
2004-10-24 04:26:03 +04:00
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
return OMPI_SUCCESS;
|
2004-06-04 02:13:01 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2004-08-02 04:24:22 +04:00
|
|
|
* component cleanup - sanity checking of queue lengths
|
2004-06-04 02:13:01 +04:00
|
|
|
*/
|
|
|
|
|
2004-08-02 04:24:22 +04:00
|
|
|
int mca_ptl_sm_component_close(void)
|
2004-06-04 02:13:01 +04:00
|
|
|
{
|
2004-11-18 07:18:33 +03:00
|
|
|
int return_value=OMPI_SUCCESS;
|
|
|
|
|
2004-08-02 04:24:22 +04:00
|
|
|
OBJ_DESTRUCT(&mca_ptl_sm_component.sm_lock);
|
2004-11-04 07:03:32 +03:00
|
|
|
OBJ_DESTRUCT(&mca_ptl_sm_component.sm_send_requests);
|
|
|
|
OBJ_DESTRUCT(&mca_ptl_sm_component.sm_first_frags);
|
|
|
|
OBJ_DESTRUCT(&mca_ptl_sm_component.sm_second_frags);
|
|
|
|
OBJ_DESTRUCT(&mca_ptl_sm_component.sm_pending_ack_lock);
|
|
|
|
OBJ_DESTRUCT(&mca_ptl_sm_component.sm_pending_ack);
|
2004-11-18 07:18:33 +03:00
|
|
|
|
|
|
|
/* unmap the shared memory control structure */
|
2004-12-06 22:41:11 +03:00
|
|
|
if(mca_ptl_sm_component.mmap_file != NULL) {
|
|
|
|
return_value=munmap(mca_ptl_sm_component.mmap_file->map_addr,
|
|
|
|
mca_ptl_sm_component.mmap_file->map_size);
|
|
|
|
if(-1 == return_value) {
|
|
|
|
return_value=OMPI_ERROR;
|
2005-07-04 03:31:27 +04:00
|
|
|
opal_output(0," munmap failed :: file - %s :: errno - %d \n",
|
2004-12-06 22:41:11 +03:00
|
|
|
mca_ptl_sm_component.mmap_file->map_addr,
|
|
|
|
errno);
|
|
|
|
goto CLEANUP;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* unlink file, so that it will be deleted when all references
|
|
|
|
* to it are gone - no error checking, since we want all procs
|
|
|
|
* to call this, so that in an abnormal termination scanario,
|
|
|
|
* this file will still get cleaned up */
|
|
|
|
unlink(mca_ptl_sm_component.mmap_file->map_path);
|
2004-11-18 07:18:33 +03:00
|
|
|
}
|
|
|
|
|
2005-02-16 20:42:07 +03:00
|
|
|
#if OMPI_ENABLE_PROGRESS_THREADS == 1
|
2004-12-07 18:38:01 +03:00
|
|
|
/* close/cleanup fifo create for event notification */
|
2005-03-26 21:49:16 +03:00
|
|
|
if(mca_ptl_sm_component.sm_fifo_fd > 0) {
|
2004-12-12 02:29:47 +03:00
|
|
|
/* write a done message down the pipe */
|
|
|
|
unsigned char cmd = DONE;
|
|
|
|
if( write(mca_ptl_sm_component.sm_fifo_fd,&cmd,sizeof(cmd)) !=
|
|
|
|
sizeof(cmd)){
|
2005-07-04 03:31:27 +04:00
|
|
|
opal_output(0, "mca_ptl_sm_component_close: write fifo failed: errno=%d\n",
|
2004-12-12 02:29:47 +03:00
|
|
|
errno);
|
|
|
|
}
|
2005-07-04 02:45:48 +04:00
|
|
|
opal_thread_join(&mca_ptl_sm_component.sm_fifo_thread, NULL);
|
2004-12-07 18:38:01 +03:00
|
|
|
close(mca_ptl_sm_component.sm_fifo_fd);
|
|
|
|
unlink(mca_ptl_sm_component.sm_fifo_path);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2004-11-18 07:18:33 +03:00
|
|
|
CLEANUP:
|
|
|
|
|
|
|
|
/* return */
|
|
|
|
return return_value;
|
2004-06-04 02:13:01 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2004-08-02 04:24:22 +04:00
|
|
|
* SM component initialization
|
2004-06-04 02:13:01 +04:00
|
|
|
*/
|
2004-08-02 04:24:22 +04:00
|
|
|
mca_ptl_base_module_t** mca_ptl_sm_component_init(
|
2004-08-04 21:23:34 +04:00
|
|
|
int *num_ptls,
|
2005-03-27 17:05:23 +04:00
|
|
|
bool enable_progress_threads,
|
|
|
|
bool enable_mpi_threads)
|
2004-06-04 02:13:01 +04:00
|
|
|
{
|
2004-08-02 04:24:22 +04:00
|
|
|
mca_ptl_base_module_t **ptls = NULL;
|
2004-11-04 07:03:32 +03:00
|
|
|
int i;
|
2004-06-04 02:13:01 +04:00
|
|
|
|
2004-08-04 21:23:34 +04:00
|
|
|
*num_ptls = 0;
|
2004-06-04 02:13:01 +04:00
|
|
|
|
2005-04-22 20:18:41 +04:00
|
|
|
/* lookup/create shared memory pool only when used */
|
|
|
|
mca_ptl_sm_component.sm_mpool = NULL;
|
|
|
|
mca_ptl_sm_component.sm_mpool_base = NULL;
|
2004-06-18 00:57:47 +04:00
|
|
|
|
2005-02-16 20:42:07 +03:00
|
|
|
#if OMPI_ENABLE_PROGRESS_THREADS == 1
|
2004-12-07 18:38:01 +03:00
|
|
|
/* create a named pipe to receive events */
|
|
|
|
sprintf(mca_ptl_sm_component.sm_fifo_path,
|
2005-04-09 23:34:32 +04:00
|
|
|
"%s/sm_fifo.%d", orte_process_info.job_session_dir,
|
|
|
|
orte_process_info.my_name->vpid);
|
2004-12-07 18:38:01 +03:00
|
|
|
if(mkfifo(mca_ptl_sm_component.sm_fifo_path, 0660) < 0) {
|
2005-07-04 03:31:27 +04:00
|
|
|
opal_output(0, "mca_ptl_sm_component_init: mkfifo failed with errno=%d\n",errno);
|
2004-12-07 18:38:01 +03:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
mca_ptl_sm_component.sm_fifo_fd = open(mca_ptl_sm_component.sm_fifo_path, O_RDWR);
|
|
|
|
if(mca_ptl_sm_component.sm_fifo_fd < 0) {
|
2005-07-04 03:31:27 +04:00
|
|
|
opal_output(0, "mca_ptl_sm_component_init: open(%s) failed with errno=%d\n",
|
2004-12-07 18:38:01 +03:00
|
|
|
mca_ptl_sm_component.sm_fifo_path, errno);
|
|
|
|
return NULL;
|
|
|
|
}
|
2004-06-04 02:13:01 +04:00
|
|
|
|
2005-07-04 02:45:48 +04:00
|
|
|
OBJ_CONSTRUCT(&mca_ptl_sm_component.sm_fifo_thread, opal_thread_t);
|
|
|
|
mca_ptl_sm_component.sm_fifo_thread.t_run = (opal_thread_fn_t) mca_ptl_sm_component_event_thread;
|
|
|
|
opal_thread_start(&mca_ptl_sm_component.sm_fifo_thread);
|
2004-12-07 18:38:01 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* allocate the Shared Memory PTL */
|
2004-11-04 07:03:32 +03:00
|
|
|
*num_ptls = 2;
|
|
|
|
ptls = malloc((*num_ptls)*sizeof(mca_ptl_base_module_t*));
|
2005-02-22 17:30:26 +03:00
|
|
|
if (NULL == ptls) {
|
2004-06-04 02:13:01 +04:00
|
|
|
return NULL;
|
2005-02-22 17:30:26 +03:00
|
|
|
}
|
2004-06-04 02:13:01 +04:00
|
|
|
|
2004-11-04 07:03:32 +03:00
|
|
|
/* get pointer to the ptls */
|
|
|
|
ptls[0] = (mca_ptl_base_module_t *)(&(mca_ptl_sm[0]));
|
|
|
|
ptls[1] = (mca_ptl_base_module_t *)(&(mca_ptl_sm[1]));
|
2004-07-15 22:42:02 +04:00
|
|
|
|
2004-09-14 16:28:33 +04:00
|
|
|
/* set scheduling parameters */
|
2004-11-04 07:03:32 +03:00
|
|
|
for( i=0 ; i < 2 ; i++ ) {
|
|
|
|
mca_ptl_sm[i].super.ptl_cache_size=mca_ptl_sm_component.sm_first_frag_free_list_max;
|
|
|
|
mca_ptl_sm[i].super.ptl_cache_bytes=sizeof(mca_ptl_sm_send_request_t) -
|
2005-05-09 23:37:10 +04:00
|
|
|
sizeof(mca_ptl_base_send_request_t);
|
2004-11-04 07:03:32 +03:00
|
|
|
mca_ptl_sm[i].super.ptl_first_frag_size=mca_ptl_sm_component.first_fragment_size;
|
|
|
|
mca_ptl_sm[i].super.ptl_min_frag_size=mca_ptl_sm_component.max_fragment_size;
|
|
|
|
mca_ptl_sm[i].super.ptl_max_frag_size=mca_ptl_sm_component.max_fragment_size;
|
|
|
|
mca_ptl_sm[i].super.ptl_exclusivity=100; /* always use this ptl */
|
|
|
|
mca_ptl_sm[i].super.ptl_latency=100; /* lowest latency */
|
|
|
|
mca_ptl_sm[i].super.ptl_bandwidth=900; /* not really used now since
|
2004-09-14 16:28:33 +04:00
|
|
|
exclusivity is set to 100 */
|
2004-11-04 07:03:32 +03:00
|
|
|
}
|
2004-09-14 16:28:33 +04:00
|
|
|
|
2004-07-15 22:42:02 +04:00
|
|
|
/* initialize some PTL data */
|
|
|
|
/* start with no SM procs */
|
2005-01-18 00:37:56 +03:00
|
|
|
mca_ptl_sm_component.num_smp_procs = 0;
|
|
|
|
mca_ptl_sm_component.my_smp_rank = 0xFFFFFFFF; /* not defined */
|
2004-07-15 22:42:02 +04:00
|
|
|
|
2004-10-22 02:40:25 +04:00
|
|
|
/* set flag indicating ptl not inited */
|
2004-11-04 07:03:32 +03:00
|
|
|
mca_ptl_sm[0].ptl_inited=false;
|
|
|
|
mca_ptl_sm[1].ptl_inited=false;
|
2004-10-22 02:40:25 +04:00
|
|
|
|
2004-06-04 02:13:01 +04:00
|
|
|
return ptls;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2004-08-02 04:24:22 +04:00
|
|
|
* SM component control
|
2004-06-04 02:13:01 +04:00
|
|
|
*/
|
|
|
|
|
2004-08-02 04:24:22 +04:00
|
|
|
int mca_ptl_sm_component_control(int param, void* value, size_t size)
|
2004-06-04 02:13:01 +04:00
|
|
|
{
|
|
|
|
switch(param) {
|
|
|
|
case MCA_PTL_ENABLE:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2004-06-07 19:33:53 +04:00
|
|
|
return OMPI_SUCCESS;
|
2004-06-04 02:13:01 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2004-08-02 04:24:22 +04:00
|
|
|
* SM component progress.
|
2004-06-04 02:13:01 +04:00
|
|
|
*/
|
|
|
|
|
2005-02-16 20:42:07 +03:00
|
|
|
#if OMPI_ENABLE_PROGRESS_THREADS == 1
|
2005-07-03 20:06:07 +04:00
|
|
|
void mca_ptl_sm_component_event_thread(opal_object_t* thread)
|
2004-12-07 18:38:01 +03:00
|
|
|
{
|
2004-12-08 02:43:24 +03:00
|
|
|
while(1) {
|
|
|
|
unsigned char cmd;
|
|
|
|
if(read(mca_ptl_sm_component.sm_fifo_fd, &cmd, sizeof(cmd)) != sizeof(cmd)) {
|
2004-12-12 02:29:47 +03:00
|
|
|
/* error condition */
|
2004-12-08 02:43:24 +03:00
|
|
|
return;
|
|
|
|
}
|
2004-12-12 02:29:47 +03:00
|
|
|
if( DONE == cmd ){
|
|
|
|
/* return when done message received */
|
|
|
|
return;
|
|
|
|
}
|
2004-12-08 02:43:24 +03:00
|
|
|
mca_ptl_sm_component_progress(0);
|
2004-12-07 18:38:01 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2004-08-02 04:24:22 +04:00
|
|
|
int mca_ptl_sm_component_progress(mca_ptl_tstamp_t tstamp)
|
2004-06-04 02:13:01 +04:00
|
|
|
{
|
2004-10-12 02:56:46 +04:00
|
|
|
/* local variables */
|
2004-11-18 04:58:30 +03:00
|
|
|
int my_local_smp_rank, proc;
|
2004-10-19 03:24:53 +04:00
|
|
|
unsigned int peer_local_smp_rank ;
|
2004-10-12 02:56:46 +04:00
|
|
|
mca_ptl_sm_frag_t *header_ptr;
|
2005-01-26 03:18:19 +03:00
|
|
|
ompi_fifo_t *send_fifo = NULL;
|
2004-10-12 02:56:46 +04:00
|
|
|
bool frag_matched;
|
|
|
|
mca_ptl_base_match_header_t *matching_header;
|
2005-05-09 23:37:10 +04:00
|
|
|
mca_ptl_base_send_request_t *base_send_req;
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_item_t *item;
|
2004-11-18 04:58:30 +03:00
|
|
|
int return_status = 0;
|
2004-10-12 02:56:46 +04:00
|
|
|
|
|
|
|
my_local_smp_rank=mca_ptl_sm_component.my_smp_rank;
|
|
|
|
|
|
|
|
/* send progress is made by the PML */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* receive progress
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* poll each fifo */
|
|
|
|
|
2004-11-04 07:03:32 +03:00
|
|
|
/* loop over fifo's - procs with same base shared memory
|
|
|
|
* virtual address as this process */
|
|
|
|
for( proc=0 ; proc < mca_ptl_sm_component.num_smp_procs_same_base_addr
|
|
|
|
; proc++ )
|
2004-10-12 02:56:46 +04:00
|
|
|
{
|
2004-11-04 07:03:32 +03:00
|
|
|
peer_local_smp_rank=
|
|
|
|
mca_ptl_sm_component.list_smp_procs_same_base_addr[proc];
|
|
|
|
|
|
|
|
send_fifo=&(mca_ptl_sm_component.fifo
|
|
|
|
[peer_local_smp_rank][my_local_smp_rank]);
|
2004-10-12 02:56:46 +04:00
|
|
|
|
2004-11-04 07:03:32 +03:00
|
|
|
/* if fifo is not yet setup - continue - not data has been sent*/
|
|
|
|
if(OMPI_CB_FREE == send_fifo->tail){
|
2004-10-12 02:56:46 +04:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2004-11-04 07:03:32 +03:00
|
|
|
/* aquire thread lock */
|
2005-07-04 02:45:48 +04:00
|
|
|
if( opal_using_threads() ) {
|
2005-07-04 01:38:51 +04:00
|
|
|
opal_atomic_lock( &(send_fifo->tail_lock) );
|
2004-11-04 07:03:32 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* get pointer - pass in offset to change queue pointer
|
|
|
|
* addressing from that of the sender */
|
2005-01-18 00:37:56 +03:00
|
|
|
header_ptr = (mca_ptl_sm_frag_t *)
|
|
|
|
ompi_fifo_read_from_tail_same_base_addr( send_fifo );
|
2004-11-04 07:03:32 +03:00
|
|
|
if( OMPI_CB_FREE == header_ptr ) {
|
|
|
|
/* release thread lock */
|
2005-07-04 02:45:48 +04:00
|
|
|
if( opal_using_threads() ) {
|
2005-07-04 01:38:51 +04:00
|
|
|
opal_atomic_unlock(&(send_fifo->tail_lock));
|
2004-11-04 07:03:32 +03:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* release thread lock */
|
2005-07-04 02:45:48 +04:00
|
|
|
if( opal_using_threads() ) {
|
2005-07-04 01:38:51 +04:00
|
|
|
opal_atomic_unlock(&(send_fifo->tail_lock));
|
2004-11-04 07:03:32 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* figure out what type of message this is */
|
2004-11-18 04:58:30 +03:00
|
|
|
return_status++;
|
2004-11-04 07:03:32 +03:00
|
|
|
switch
|
|
|
|
(header_ptr->super.frag_base.frag_header.hdr_common.hdr_type)
|
|
|
|
{
|
|
|
|
|
|
|
|
case MCA_PTL_HDR_TYPE_MATCH:
|
|
|
|
/* set the owning ptl */
|
|
|
|
header_ptr->super.frag_base.frag_owner=
|
2005-06-23 22:46:57 +04:00
|
|
|
(mca_ptl_base_module_t *) (&mca_ptl_sm[0]);
|
2004-11-04 07:03:32 +03:00
|
|
|
/* attempt match */
|
2005-06-23 22:46:57 +04:00
|
|
|
matching_header= &(header_ptr->super.frag_base.frag_header.hdr_match);
|
|
|
|
frag_matched = header_ptr->super.frag_base.frag_owner->ptl_match(
|
|
|
|
header_ptr->super.frag_base.frag_owner, &(header_ptr->super),
|
|
|
|
matching_header );
|
2004-11-04 07:03:32 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MCA_PTL_HDR_TYPE_FRAG:
|
|
|
|
/* set the owning ptl */
|
|
|
|
header_ptr->super.frag_base.frag_owner=
|
2005-06-23 22:46:57 +04:00
|
|
|
(mca_ptl_base_module_t *) (&mca_ptl_sm[0]);
|
2004-11-04 07:03:32 +03:00
|
|
|
/* second and beyond fragment - just need to deliver
|
|
|
|
* the data, and ack */
|
|
|
|
mca_ptl_sm_matched_same_base_addr(
|
|
|
|
(mca_ptl_base_module_t *)&mca_ptl_sm,
|
|
|
|
(mca_ptl_base_recv_frag_t *)header_ptr);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MCA_PTL_HDR_TYPE_ACK:
|
|
|
|
/* ack */
|
|
|
|
/* update the send statistics */
|
|
|
|
/* NOTE !!! : need to change the update stats,
|
|
|
|
* so that MPI_Wait/Test on the send can complete
|
|
|
|
* as soon as the data is copied intially into
|
|
|
|
* the shared memory buffers */
|
|
|
|
|
|
|
|
header_ptr->send_ptl->ptl_send_progress(
|
|
|
|
(mca_ptl_base_module_t *)&mca_ptl_sm,
|
2004-11-18 01:47:08 +03:00
|
|
|
header_ptr->send_req,
|
2004-11-04 07:03:32 +03:00
|
|
|
header_ptr->super.frag_base.frag_size);
|
|
|
|
|
|
|
|
/* if this is not the first fragment, recycle
|
|
|
|
* resources. The first fragment is handled by
|
|
|
|
* the PML */
|
2004-11-18 01:47:08 +03:00
|
|
|
if( 0 < header_ptr->send_offset ) {
|
2004-11-04 07:03:32 +03:00
|
|
|
OMPI_FREE_LIST_RETURN(&mca_ptl_sm_component.sm_second_frags,
|
2005-07-03 20:22:16 +04:00
|
|
|
(opal_list_item_t *)header_ptr);
|
2004-11-04 07:03:32 +03:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
fprintf(stderr," Warnning: mca_ptl_sm_component_progress - unrecognized fragment type \n");
|
|
|
|
fflush(stderr);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} /* end peer_local_smp_rank loop */
|
|
|
|
|
|
|
|
/* loop over fifo's - procs with different base shared memory
|
|
|
|
* virtual address as this process */
|
|
|
|
for( proc=0 ; proc < mca_ptl_sm_component.num_smp_procs_different_base_addr
|
|
|
|
; proc++ )
|
|
|
|
{
|
|
|
|
peer_local_smp_rank=
|
|
|
|
mca_ptl_sm_component.list_smp_procs_different_base_addr[proc];
|
|
|
|
|
2004-10-12 02:56:46 +04:00
|
|
|
send_fifo=&(mca_ptl_sm_component.fifo
|
2004-10-25 21:22:47 +04:00
|
|
|
[peer_local_smp_rank][my_local_smp_rank]);
|
2004-10-12 02:56:46 +04:00
|
|
|
|
|
|
|
/* if fifo is not yet setup - continue - not data has been sent*/
|
|
|
|
if(OMPI_CB_FREE == send_fifo->tail){
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* aquire thread lock */
|
2005-07-04 02:45:48 +04:00
|
|
|
if( opal_using_threads() ) {
|
2005-07-04 01:38:51 +04:00
|
|
|
opal_atomic_lock(&(send_fifo->tail_lock));
|
2004-10-12 02:56:46 +04:00
|
|
|
}
|
|
|
|
|
2004-11-04 07:03:32 +03:00
|
|
|
/* get pointer - pass in offset to change queue pointer
|
|
|
|
* addressing from that of the sender */
|
2004-10-12 02:56:46 +04:00
|
|
|
header_ptr=(mca_ptl_sm_frag_t *)ompi_fifo_read_from_tail( send_fifo,
|
2004-11-04 07:03:32 +03:00
|
|
|
mca_ptl_sm_component.sm_offset[peer_local_smp_rank]);
|
2004-10-12 02:56:46 +04:00
|
|
|
if( OMPI_CB_FREE == header_ptr ) {
|
2004-10-20 03:37:30 +04:00
|
|
|
/* release thread lock */
|
2005-07-04 02:45:48 +04:00
|
|
|
if( opal_using_threads() ) {
|
2005-07-04 01:38:51 +04:00
|
|
|
opal_atomic_unlock(&(send_fifo->tail_lock));
|
2004-10-20 03:37:30 +04:00
|
|
|
}
|
2004-10-12 02:56:46 +04:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* release thread lock */
|
2005-07-04 02:45:48 +04:00
|
|
|
if( opal_using_threads() ) {
|
2005-07-04 01:38:51 +04:00
|
|
|
opal_atomic_unlock(&(send_fifo->tail_lock));
|
2004-10-12 02:56:46 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* change the address from address relative to the shared
|
|
|
|
* memory address, to a true virtual address */
|
|
|
|
header_ptr = (mca_ptl_sm_frag_t *)( (char *)header_ptr+
|
2004-11-04 07:03:32 +03:00
|
|
|
mca_ptl_sm_component.sm_offset[peer_local_smp_rank]);
|
2004-10-25 21:22:47 +04:00
|
|
|
|
2004-10-12 02:56:46 +04:00
|
|
|
|
|
|
|
/* figure out what type of message this is */
|
2004-11-18 04:58:30 +03:00
|
|
|
return_status++;
|
2004-10-12 02:56:46 +04:00
|
|
|
switch
|
|
|
|
(header_ptr->super.frag_base.frag_header.hdr_common.hdr_type)
|
|
|
|
{
|
|
|
|
|
|
|
|
case MCA_PTL_HDR_TYPE_MATCH:
|
2004-10-25 22:02:46 +04:00
|
|
|
/* set the owning ptl */
|
|
|
|
header_ptr->super.frag_base.frag_owner=
|
2005-06-23 22:46:57 +04:00
|
|
|
(mca_ptl_base_module_t *) (&mca_ptl_sm[1]);
|
2004-10-12 02:56:46 +04:00
|
|
|
/* attempt match */
|
2005-06-23 22:46:57 +04:00
|
|
|
matching_header= &(header_ptr->super.frag_base.frag_header.hdr_match);
|
|
|
|
frag_matched = header_ptr->super.frag_base.frag_owner->ptl_match(
|
|
|
|
header_ptr->super.frag_base.frag_owner, &(header_ptr->super),
|
|
|
|
matching_header );
|
2004-10-12 02:56:46 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MCA_PTL_HDR_TYPE_FRAG:
|
2004-10-25 22:02:46 +04:00
|
|
|
/* set the owning ptl */
|
|
|
|
header_ptr->super.frag_base.frag_owner=
|
2005-06-23 22:46:57 +04:00
|
|
|
(mca_ptl_base_module_t *) (&mca_ptl_sm[1]);
|
2004-10-12 02:56:46 +04:00
|
|
|
/* second and beyond fragment - just need to deliver
|
|
|
|
* the data, and ack */
|
2004-10-19 03:24:53 +04:00
|
|
|
mca_ptl_sm_matched((mca_ptl_base_module_t *)&mca_ptl_sm,
|
|
|
|
(mca_ptl_base_recv_frag_t *)header_ptr);
|
2004-10-12 02:56:46 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MCA_PTL_HDR_TYPE_ACK:
|
|
|
|
/* ack */
|
2004-10-19 03:24:53 +04:00
|
|
|
/* update the send statistics */
|
|
|
|
/* NOTE !!! : need to change the update stats,
|
|
|
|
* so that MPI_Wait/Test on the send can complete
|
|
|
|
* as soon as the data is copied intially into
|
|
|
|
* the shared memory buffers */
|
|
|
|
base_send_req=header_ptr->super.frag_base.frag_header.
|
2004-11-18 01:47:08 +03:00
|
|
|
hdr_rndv.hdr_src_ptr.pval;
|
2004-10-26 07:33:02 +04:00
|
|
|
|
2004-10-25 22:02:46 +04:00
|
|
|
header_ptr->send_ptl->ptl_send_progress(
|
2004-10-19 03:24:53 +04:00
|
|
|
(mca_ptl_base_module_t *)&mca_ptl_sm,
|
|
|
|
base_send_req,
|
|
|
|
header_ptr->super.frag_base.frag_size);
|
|
|
|
|
|
|
|
/* if this is not the first fragment, recycle
|
|
|
|
* resources. The first fragment is handled by
|
|
|
|
* the PML */
|
2004-11-18 01:47:08 +03:00
|
|
|
if( 0 < header_ptr->send_offset ) {
|
2004-11-04 07:03:32 +03:00
|
|
|
OMPI_FREE_LIST_RETURN(&mca_ptl_sm_component.sm_second_frags,
|
2005-07-03 20:22:16 +04:00
|
|
|
(opal_list_item_t *)header_ptr);
|
2004-10-26 07:33:02 +04:00
|
|
|
}
|
2004-10-12 02:56:46 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2004-11-04 07:03:32 +03:00
|
|
|
fprintf(stderr," Warnning: mca_ptl_sm_component_progress - unrecognized fragment type \n");
|
|
|
|
fflush(stderr);
|
2004-10-12 02:56:46 +04:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} /* end peer_local_smp_rank loop */
|
|
|
|
|
2004-11-04 07:03:32 +03:00
|
|
|
|
2004-10-19 03:24:53 +04:00
|
|
|
/* progress acks */
|
2005-07-03 20:22:16 +04:00
|
|
|
if( !opal_list_is_empty(&(mca_ptl_sm_component.sm_pending_ack)) ) {
|
2004-10-19 03:24:53 +04:00
|
|
|
|
2005-07-04 02:45:48 +04:00
|
|
|
OPAL_THREAD_LOCK(&(mca_ptl_sm_component.sm_pending_ack_lock));
|
2004-10-19 03:24:53 +04:00
|
|
|
|
|
|
|
/* remove ack from list - need to remove from list before
|
|
|
|
* sending the ack, so that when the ack is recieved,
|
|
|
|
* manipulated, and put on a new list, it is not also
|
|
|
|
* on a different list */
|
2005-07-03 20:22:16 +04:00
|
|
|
item = opal_list_remove_first(&(mca_ptl_sm_component.sm_pending_ack));
|
|
|
|
while ( item != opal_list_get_end(&(mca_ptl_sm_component.sm_pending_ack)) ) {
|
2004-11-18 04:58:30 +03:00
|
|
|
int rc;
|
2004-10-19 03:24:53 +04:00
|
|
|
/* get fragment pointer */
|
|
|
|
header_ptr = (mca_ptl_sm_frag_t *)item;
|
|
|
|
|
2004-10-25 21:22:47 +04:00
|
|
|
/* try and send an ack - no need to check and see if a send
|
|
|
|
* queue has been allocated, since entries are put here only
|
|
|
|
* if the queue was previously full */
|
|
|
|
|
|
|
|
/* fragment already marked as an ack */
|
|
|
|
|
2004-11-18 04:58:30 +03:00
|
|
|
rc=ompi_fifo_write_to_head_same_base_addr(header_ptr,
|
2004-11-04 07:03:32 +03:00
|
|
|
send_fifo, mca_ptl_sm_component.sm_mpool);
|
2004-10-19 03:24:53 +04:00
|
|
|
|
|
|
|
/* if ack failed, break */
|
2004-11-18 04:58:30 +03:00
|
|
|
if( 0 > rc ) {
|
2004-10-19 03:24:53 +04:00
|
|
|
/* put the descriptor back on the list */
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_prepend(&(mca_ptl_sm_component.sm_pending_ack),item);
|
2004-10-19 03:24:53 +04:00
|
|
|
break;
|
|
|
|
}
|
2004-12-07 18:38:01 +03:00
|
|
|
MCA_PTL_SM_SIGNAL_PEER(mca_ptl_sm_component.sm_peers[header_ptr->queue_index]);
|
2004-10-19 03:24:53 +04:00
|
|
|
|
|
|
|
/* get next fragment to ack */
|
2005-07-03 20:22:16 +04:00
|
|
|
item = opal_list_remove_first(&(mca_ptl_sm_component.sm_pending_ack));
|
2004-10-19 03:24:53 +04:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2005-07-04 02:45:48 +04:00
|
|
|
OPAL_THREAD_UNLOCK(&(mca_ptl_sm_component.sm_pending_ack_lock));
|
2004-10-19 03:24:53 +04:00
|
|
|
}
|
2004-11-18 04:58:30 +03:00
|
|
|
return return_status;
|
2004-06-04 02:13:01 +04:00
|
|
|
}
|