2006-01-28 18:38:37 +03:00
|
|
|
/*
|
2007-03-17 02:11:45 +03:00
|
|
|
* Copyright (c) 2004-2007 The Trustees of Indiana University.
|
2006-01-28 18:38:37 +03:00
|
|
|
* All rights reserved.
|
2006-08-24 20:38:08 +04:00
|
|
|
* Copyright (c) 2004-2006 The Trustees of the University of Tennessee.
|
2006-01-28 18:38:37 +03:00
|
|
|
* All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
|
|
* University of Stuttgart. All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
2007-05-24 00:31:25 +04:00
|
|
|
* Copyright (c) 2007 Los Alamos National Security, LLC. All rights
|
|
|
|
* reserved.
|
2006-01-28 18:38:37 +03:00
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ompi_config.h"
|
|
|
|
|
2006-02-07 15:16:23 +03:00
|
|
|
#include <string.h>
|
|
|
|
|
2006-01-28 18:38:37 +03:00
|
|
|
#include "osc_pt2pt.h"
|
|
|
|
#include "osc_pt2pt_sendreq.h"
|
|
|
|
#include "osc_pt2pt_replyreq.h"
|
|
|
|
#include "osc_pt2pt_header.h"
|
|
|
|
#include "osc_pt2pt_obj_convert.h"
|
|
|
|
#include "osc_pt2pt_data_move.h"
|
2006-08-03 04:10:19 +04:00
|
|
|
#include "osc_pt2pt_buffer.h"
|
2006-01-28 18:38:37 +03:00
|
|
|
|
|
|
|
#include "opal/threads/mutex.h"
|
|
|
|
#include "ompi/info/info.h"
|
|
|
|
#include "ompi/communicator/communicator.h"
|
|
|
|
#include "ompi/mca/osc/osc.h"
|
2006-08-17 18:52:20 +04:00
|
|
|
#include "ompi/mca/osc/base/base.h"
|
2006-08-03 04:10:19 +04:00
|
|
|
#include "ompi/mca/pml/pml.h"
|
2006-02-27 21:47:00 +03:00
|
|
|
#include "ompi/datatype/dt_arch.h"
|
2006-01-28 18:38:37 +03:00
|
|
|
|
2007-05-21 06:21:25 +04:00
|
|
|
static int component_open(void);
|
|
|
|
static void component_fragment_cb(ompi_osc_pt2pt_mpireq_t *mpireq);
|
|
|
|
#if OMPI_ENABLE_PROGRESS_THREADS
|
2007-05-21 07:23:58 +04:00
|
|
|
static void* component_thread_fn(opal_object_t *obj);
|
2007-05-21 06:21:25 +04:00
|
|
|
#endif
|
2006-03-16 21:40:42 +03:00
|
|
|
|
2006-01-28 18:38:37 +03:00
|
|
|
ompi_osc_pt2pt_component_t mca_osc_pt2pt_component = {
|
|
|
|
{ /* ompi_osc_base_component_t */
|
|
|
|
{ /* ompi_base_component_t */
|
|
|
|
OMPI_OSC_BASE_VERSION_1_0_0,
|
|
|
|
"pt2pt",
|
2006-08-03 04:10:19 +04:00
|
|
|
OMPI_MAJOR_VERSION, /* MCA component major version */
|
|
|
|
OMPI_MINOR_VERSION, /* MCA component minor version */
|
|
|
|
OMPI_RELEASE_VERSION, /* MCA component release version */
|
2007-05-21 06:21:25 +04:00
|
|
|
component_open,
|
2006-01-28 18:38:37 +03:00
|
|
|
NULL
|
|
|
|
},
|
|
|
|
{ /* mca_base_component_data */
|
2007-03-17 02:11:45 +03:00
|
|
|
/* The component is checkpoint ready - JJH Double check this... */
|
|
|
|
MCA_BASE_METADATA_PARAM_CHECKPOINT
|
2006-01-28 18:38:37 +03:00
|
|
|
},
|
|
|
|
ompi_osc_pt2pt_component_init,
|
|
|
|
ompi_osc_pt2pt_component_query,
|
|
|
|
ompi_osc_pt2pt_component_select,
|
|
|
|
ompi_osc_pt2pt_component_finalize
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
ompi_osc_pt2pt_module_t ompi_osc_pt2pt_module_template = {
|
|
|
|
{
|
|
|
|
ompi_osc_pt2pt_module_free,
|
|
|
|
|
|
|
|
ompi_osc_pt2pt_module_put,
|
|
|
|
ompi_osc_pt2pt_module_get,
|
|
|
|
ompi_osc_pt2pt_module_accumulate,
|
|
|
|
|
|
|
|
ompi_osc_pt2pt_module_fence,
|
|
|
|
|
|
|
|
ompi_osc_pt2pt_module_start,
|
|
|
|
ompi_osc_pt2pt_module_complete,
|
|
|
|
ompi_osc_pt2pt_module_post,
|
|
|
|
ompi_osc_pt2pt_module_wait,
|
|
|
|
ompi_osc_pt2pt_module_test,
|
|
|
|
|
|
|
|
ompi_osc_pt2pt_module_lock,
|
|
|
|
ompi_osc_pt2pt_module_unlock,
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2007-05-21 06:21:25 +04:00
|
|
|
|
2006-03-24 21:56:59 +03:00
|
|
|
/* look up parameters for configuring this window. The code first
|
|
|
|
looks in the info structure passed by the user, then through mca
|
|
|
|
parameters. */
|
2006-01-28 18:38:37 +03:00
|
|
|
static bool
|
2006-03-24 21:56:59 +03:00
|
|
|
check_config_value_bool(char *key, ompi_info_t *info)
|
2006-01-28 18:38:37 +03:00
|
|
|
{
|
2006-03-24 21:56:59 +03:00
|
|
|
char *value_string;
|
|
|
|
int value_len, ret, flag, param;
|
|
|
|
bool result;
|
2006-01-28 18:38:37 +03:00
|
|
|
|
2006-03-24 21:56:59 +03:00
|
|
|
ret = ompi_info_get_valuelen(info, key, &value_len, &flag);
|
|
|
|
if (OMPI_SUCCESS != ret) goto info_not_found;
|
|
|
|
if (flag == 0) goto info_not_found;
|
|
|
|
value_len++;
|
2006-01-28 18:38:37 +03:00
|
|
|
|
2006-08-24 20:38:08 +04:00
|
|
|
value_string = (char*)malloc(sizeof(char) * value_len);
|
2006-03-24 21:56:59 +03:00
|
|
|
if (NULL == value_string) goto info_not_found;
|
2006-01-28 18:38:37 +03:00
|
|
|
|
2006-03-24 21:56:59 +03:00
|
|
|
ret = ompi_info_get(info, key, value_len, value_string, &flag);
|
2006-01-28 18:38:37 +03:00
|
|
|
if (OMPI_SUCCESS != ret) {
|
2006-03-24 21:56:59 +03:00
|
|
|
free(value_string);
|
|
|
|
goto info_not_found;
|
2006-01-28 18:38:37 +03:00
|
|
|
}
|
|
|
|
assert(flag != 0);
|
2006-03-24 21:56:59 +03:00
|
|
|
ret = ompi_info_value_to_bool(value_string, &result);
|
|
|
|
free(value_string);
|
|
|
|
if (OMPI_SUCCESS != ret) goto info_not_found;
|
|
|
|
return result;
|
2006-01-28 18:38:37 +03:00
|
|
|
|
2006-03-24 21:56:59 +03:00
|
|
|
info_not_found:
|
|
|
|
param = mca_base_param_find("osc", "pt2pt", key);
|
|
|
|
if (param == OPAL_ERROR) return false;
|
|
|
|
|
|
|
|
ret = mca_base_param_lookup_int(param, &flag);
|
|
|
|
if (OMPI_SUCCESS != ret) return false;
|
|
|
|
|
2006-08-28 22:59:16 +04:00
|
|
|
return OPAL_INT_TO_BOOL(flag);
|
2006-01-28 18:38:37 +03:00
|
|
|
}
|
|
|
|
|
2006-03-24 21:56:59 +03:00
|
|
|
|
2006-03-16 21:40:42 +03:00
|
|
|
static int
|
2007-05-21 06:21:25 +04:00
|
|
|
component_open(void)
|
2006-03-16 21:40:42 +03:00
|
|
|
{
|
2006-08-03 04:10:19 +04:00
|
|
|
int tmp;
|
|
|
|
|
|
|
|
mca_base_param_reg_int(&mca_osc_pt2pt_component.super.osc_version,
|
|
|
|
"no_locks",
|
|
|
|
"Enable optimizations available only if MPI_LOCK is not used.",
|
|
|
|
false, false, 0, NULL);
|
|
|
|
|
|
|
|
mca_base_param_reg_int(&mca_osc_pt2pt_component.super.osc_version,
|
|
|
|
"eager_limit",
|
|
|
|
"Max size of eagerly sent data",
|
|
|
|
false, false, 16 * 1024,
|
|
|
|
&tmp);
|
|
|
|
|
|
|
|
mca_osc_pt2pt_component.p2p_c_eager_size = tmp;
|
2006-03-24 21:56:59 +03:00
|
|
|
|
2006-03-16 21:40:42 +03:00
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2006-01-28 18:38:37 +03:00
|
|
|
|
|
|
|
int
|
|
|
|
ompi_osc_pt2pt_component_init(bool enable_progress_threads,
|
|
|
|
bool enable_mpi_threads)
|
|
|
|
{
|
|
|
|
/* we can run with either threads or not threads (may not be able
|
|
|
|
to do win locks)... */
|
|
|
|
mca_osc_pt2pt_component.p2p_c_have_progress_threads =
|
|
|
|
enable_progress_threads;
|
|
|
|
|
|
|
|
OBJ_CONSTRUCT(&mca_osc_pt2pt_component.p2p_c_lock, opal_mutex_t);
|
|
|
|
|
|
|
|
OBJ_CONSTRUCT(&mca_osc_pt2pt_component.p2p_c_modules,
|
|
|
|
opal_hash_table_t);
|
|
|
|
opal_hash_table_init(&mca_osc_pt2pt_component.p2p_c_modules, 2);
|
|
|
|
|
2007-05-21 06:21:25 +04:00
|
|
|
OBJ_CONSTRUCT(&mca_osc_pt2pt_component.p2p_c_request_lock,
|
|
|
|
opal_mutex_t);
|
|
|
|
OBJ_CONSTRUCT(&mca_osc_pt2pt_component.p2p_c_request_cond,
|
|
|
|
opal_condition_t);
|
|
|
|
|
2006-01-28 18:38:37 +03:00
|
|
|
OBJ_CONSTRUCT(&mca_osc_pt2pt_component.p2p_c_sendreqs, opal_free_list_t);
|
|
|
|
opal_free_list_init(&mca_osc_pt2pt_component.p2p_c_sendreqs,
|
|
|
|
sizeof(ompi_osc_pt2pt_sendreq_t),
|
|
|
|
OBJ_CLASS(ompi_osc_pt2pt_sendreq_t),
|
|
|
|
1, -1, 1);
|
|
|
|
|
|
|
|
OBJ_CONSTRUCT(&mca_osc_pt2pt_component.p2p_c_replyreqs, opal_free_list_t);
|
|
|
|
opal_free_list_init(&mca_osc_pt2pt_component.p2p_c_replyreqs,
|
|
|
|
sizeof(ompi_osc_pt2pt_replyreq_t),
|
|
|
|
OBJ_CLASS(ompi_osc_pt2pt_replyreq_t),
|
|
|
|
1, -1, 1);
|
|
|
|
|
|
|
|
OBJ_CONSTRUCT(&mca_osc_pt2pt_component.p2p_c_longreqs, opal_free_list_t);
|
|
|
|
opal_free_list_init(&mca_osc_pt2pt_component.p2p_c_longreqs,
|
|
|
|
sizeof(ompi_osc_pt2pt_longreq_t),
|
|
|
|
OBJ_CLASS(ompi_osc_pt2pt_longreq_t),
|
|
|
|
1, -1, 1);
|
|
|
|
|
2006-08-03 04:10:19 +04:00
|
|
|
OBJ_CONSTRUCT(&mca_osc_pt2pt_component.p2p_c_buffers, opal_free_list_t);
|
|
|
|
opal_free_list_init(&mca_osc_pt2pt_component.p2p_c_buffers,
|
|
|
|
mca_osc_pt2pt_component.p2p_c_eager_size +
|
|
|
|
sizeof(ompi_osc_pt2pt_buffer_t),
|
|
|
|
OBJ_CLASS(ompi_osc_pt2pt_buffer_t),
|
|
|
|
1, -1, 1);
|
|
|
|
|
2007-05-21 06:21:25 +04:00
|
|
|
OBJ_CONSTRUCT(&mca_osc_pt2pt_component.p2p_c_pending_requests,
|
|
|
|
opal_list_t);
|
|
|
|
|
2007-05-21 20:06:14 +04:00
|
|
|
#if OMPI_ENABLE_PROGRESS_THREADS
|
|
|
|
OBJ_CONSTRUCT(&mca_osc_pt2pt_component.p2p_c_thread, opal_thread_t);
|
|
|
|
mca_osc_pt2pt_component.p2p_c_thread_run = false;
|
|
|
|
#endif
|
|
|
|
|
2006-05-03 22:17:00 +04:00
|
|
|
return OMPI_SUCCESS;
|
2006-01-28 18:38:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
ompi_osc_pt2pt_component_finalize(void)
|
|
|
|
{
|
|
|
|
size_t num_modules;
|
2007-05-21 06:21:25 +04:00
|
|
|
#if OMPI_ENABLE_PROGRESS_THREADS
|
|
|
|
void* ret;
|
|
|
|
#endif
|
2006-01-28 18:38:37 +03:00
|
|
|
|
2006-08-03 04:10:19 +04:00
|
|
|
if (0 !=
|
2006-01-28 18:38:37 +03:00
|
|
|
(num_modules = opal_hash_table_get_size(&mca_osc_pt2pt_component.p2p_c_modules))) {
|
2006-08-17 18:52:20 +04:00
|
|
|
opal_output(ompi_osc_base_output,
|
2006-08-24 20:38:08 +04:00
|
|
|
"WARNING: There were %d Windows created but not freed.",
|
2007-05-21 06:21:25 +04:00
|
|
|
(int) num_modules);
|
|
|
|
#if OMPI_ENABLE_PROGRESS_THREADS
|
|
|
|
mca_osc_pt2pt_component.p2p_c_thread_run = false;
|
|
|
|
opal_condition_broadcast(&ompi_request_cond);
|
|
|
|
opal_thread_join(&mca_osc_pt2pt_component.p2p_c_thread, &ret);
|
|
|
|
#else
|
|
|
|
opal_progress_unregister(ompi_osc_pt2pt_component_progress);
|
|
|
|
#endif
|
2006-01-28 18:38:37 +03:00
|
|
|
}
|
|
|
|
|
2007-05-21 06:21:25 +04:00
|
|
|
OBJ_DESTRUCT(&mca_osc_pt2pt_component.p2p_c_pending_requests);
|
2006-08-03 04:10:19 +04:00
|
|
|
OBJ_DESTRUCT(&mca_osc_pt2pt_component.p2p_c_buffers);
|
2006-01-28 18:38:37 +03:00
|
|
|
OBJ_DESTRUCT(&mca_osc_pt2pt_component.p2p_c_longreqs);
|
|
|
|
OBJ_DESTRUCT(&mca_osc_pt2pt_component.p2p_c_replyreqs);
|
|
|
|
OBJ_DESTRUCT(&mca_osc_pt2pt_component.p2p_c_sendreqs);
|
2007-05-21 06:21:25 +04:00
|
|
|
OBJ_DESTRUCT(&mca_osc_pt2pt_component.p2p_c_request_lock);
|
|
|
|
OBJ_DESTRUCT(&mca_osc_pt2pt_component.p2p_c_request_cond);
|
|
|
|
|
2006-01-28 18:38:37 +03:00
|
|
|
OBJ_DESTRUCT(&mca_osc_pt2pt_component.p2p_c_modules);
|
|
|
|
OBJ_DESTRUCT(&mca_osc_pt2pt_component.p2p_c_lock);
|
|
|
|
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
ompi_osc_pt2pt_component_query(ompi_win_t *win,
|
|
|
|
ompi_info_t *info,
|
|
|
|
ompi_communicator_t *comm)
|
|
|
|
{
|
2006-02-01 00:40:12 +03:00
|
|
|
/* we can always run - return a low priority */
|
2006-08-03 04:10:19 +04:00
|
|
|
return 5;
|
2006-01-28 18:38:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
ompi_osc_pt2pt_component_select(ompi_win_t *win,
|
|
|
|
ompi_info_t *info,
|
|
|
|
ompi_communicator_t *comm)
|
|
|
|
{
|
2007-05-21 06:21:25 +04:00
|
|
|
ompi_osc_pt2pt_module_t *module = NULL;
|
2006-01-28 18:38:37 +03:00
|
|
|
int ret, i;
|
2007-05-21 06:21:25 +04:00
|
|
|
ompi_osc_pt2pt_buffer_t *buffer = NULL;
|
|
|
|
opal_free_list_item_t *item = NULL;
|
2006-03-16 21:40:42 +03:00
|
|
|
|
2006-01-28 18:38:37 +03:00
|
|
|
/* create module structure */
|
2007-05-21 06:21:25 +04:00
|
|
|
module = (ompi_osc_pt2pt_module_t*)
|
|
|
|
calloc(1, sizeof(ompi_osc_pt2pt_module_t));
|
|
|
|
if (NULL == module) return OMPI_ERR_TEMP_OUT_OF_RESOURCE;
|
2006-01-28 18:38:37 +03:00
|
|
|
|
|
|
|
/* fill in the function pointer part */
|
|
|
|
memcpy(module, &ompi_osc_pt2pt_module_template,
|
|
|
|
sizeof(ompi_osc_base_module_t));
|
|
|
|
|
|
|
|
/* initialize the p2p part */
|
|
|
|
OBJ_CONSTRUCT(&(module->p2p_lock), opal_mutex_t);
|
2007-05-21 06:21:25 +04:00
|
|
|
OBJ_CONSTRUCT(&(module->p2p_cond), opal_condition_t);
|
2006-01-28 18:38:37 +03:00
|
|
|
OBJ_CONSTRUCT(&(module->p2p_acc_lock), opal_mutex_t);
|
2007-05-21 06:21:25 +04:00
|
|
|
OBJ_CONSTRUCT(&module->p2p_pending_sendreqs, opal_list_t);
|
|
|
|
OBJ_CONSTRUCT(&(module->p2p_copy_pending_sendreqs), opal_list_t);
|
|
|
|
OBJ_CONSTRUCT(&(module->p2p_locks_pending), opal_list_t);
|
|
|
|
OBJ_CONSTRUCT(&(module->p2p_unlocks_pending), opal_list_t);
|
2006-01-28 18:38:37 +03:00
|
|
|
|
|
|
|
module->p2p_win = win;
|
|
|
|
|
2007-03-27 06:06:42 +04:00
|
|
|
ret = ompi_comm_dup(comm, &(module->p2p_comm), 0);
|
2007-05-21 06:21:25 +04:00
|
|
|
if (ret != OMPI_SUCCESS) goto cleanup;
|
2006-08-03 04:10:19 +04:00
|
|
|
|
2007-05-21 20:06:14 +04:00
|
|
|
opal_output_verbose(1, ompi_osc_base_output,
|
|
|
|
"pt2pt component creating window with id %d",
|
|
|
|
module->p2p_comm->c_contextid);
|
|
|
|
|
2007-05-21 06:21:25 +04:00
|
|
|
module->p2p_num_pending_sendreqs = (unsigned int*)
|
|
|
|
malloc(sizeof(unsigned int) * ompi_comm_size(module->p2p_comm));
|
2007-05-24 00:31:25 +04:00
|
|
|
if (NULL == module->p2p_num_pending_sendreqs) {
|
|
|
|
ret = OMPI_ERR_TEMP_OUT_OF_RESOURCE;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2006-02-07 15:16:23 +03:00
|
|
|
memset(module->p2p_num_pending_sendreqs, 0,
|
2006-11-28 00:41:29 +03:00
|
|
|
sizeof(unsigned int) * ompi_comm_size(module->p2p_comm));
|
2006-01-28 18:38:37 +03:00
|
|
|
|
|
|
|
module->p2p_num_pending_out = 0;
|
|
|
|
module->p2p_num_pending_in = 0;
|
2006-09-21 23:57:57 +04:00
|
|
|
module->p2p_num_post_msgs = 0;
|
|
|
|
module->p2p_num_complete_msgs = 0;
|
2006-01-28 18:38:37 +03:00
|
|
|
module->p2p_tag_counter = 0;
|
|
|
|
|
2007-05-21 06:21:25 +04:00
|
|
|
module->p2p_copy_num_pending_sendreqs = (unsigned int*)
|
|
|
|
malloc(sizeof(unsigned int) * ompi_comm_size(module->p2p_comm));
|
2006-02-07 15:16:23 +03:00
|
|
|
if (NULL == module->p2p_copy_num_pending_sendreqs) {
|
2007-05-21 06:21:25 +04:00
|
|
|
ret = OMPI_ERR_TEMP_OUT_OF_RESOURCE;
|
|
|
|
goto cleanup;
|
2006-02-07 15:16:23 +03:00
|
|
|
}
|
|
|
|
memset(module->p2p_num_pending_sendreqs, 0,
|
2006-11-28 00:41:29 +03:00
|
|
|
sizeof(unsigned int) * ompi_comm_size(module->p2p_comm));
|
2006-02-07 15:16:23 +03:00
|
|
|
|
|
|
|
/* fence data */
|
2007-05-21 06:21:25 +04:00
|
|
|
module->p2p_fence_coll_counts = (int*)
|
|
|
|
malloc(sizeof(int) * ompi_comm_size(module->p2p_comm));
|
2006-02-07 15:16:23 +03:00
|
|
|
if (NULL == module->p2p_fence_coll_counts) {
|
2007-05-21 06:21:25 +04:00
|
|
|
ret = OMPI_ERR_TEMP_OUT_OF_RESOURCE;
|
|
|
|
goto cleanup;
|
2006-02-07 15:16:23 +03:00
|
|
|
}
|
|
|
|
for (i = 0 ; i < ompi_comm_size(module->p2p_comm) ; ++i) {
|
|
|
|
module->p2p_fence_coll_counts[i] = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* pwsc data */
|
|
|
|
module->p2p_pw_group = NULL;
|
|
|
|
module->p2p_sc_group = NULL;
|
2007-05-21 06:21:25 +04:00
|
|
|
module->p2p_sc_remote_active_ranks = (bool*)
|
|
|
|
malloc(sizeof(bool) * ompi_comm_size(module->p2p_comm));
|
2006-09-22 00:49:15 +04:00
|
|
|
if (NULL == module->p2p_sc_remote_active_ranks) {
|
2007-05-21 06:21:25 +04:00
|
|
|
ret = OMPI_ERR_TEMP_OUT_OF_RESOURCE;
|
|
|
|
goto cleanup;
|
2006-09-22 00:49:15 +04:00
|
|
|
}
|
2007-05-21 06:21:25 +04:00
|
|
|
|
|
|
|
module->p2p_sc_remote_ranks = (int*)
|
|
|
|
malloc(sizeof(int) * ompi_comm_size(module->p2p_comm));
|
2006-09-22 00:49:15 +04:00
|
|
|
if (NULL == module->p2p_sc_remote_ranks) {
|
2007-05-21 06:21:25 +04:00
|
|
|
ret = OMPI_ERR_TEMP_OUT_OF_RESOURCE;
|
|
|
|
goto cleanup;
|
2006-09-22 00:49:15 +04:00
|
|
|
}
|
2006-02-07 15:16:23 +03:00
|
|
|
|
|
|
|
/* lock data */
|
2006-02-07 21:45:18 +03:00
|
|
|
module->p2p_lock_status = 0;
|
|
|
|
module->p2p_shared_count = 0;
|
|
|
|
module->p2p_lock_received_ack = 0;
|
2006-01-28 18:38:37 +03:00
|
|
|
|
|
|
|
/* update component data */
|
|
|
|
OPAL_THREAD_LOCK(&mca_osc_pt2pt_component.p2p_c_lock);
|
|
|
|
opal_hash_table_set_value_uint32(&mca_osc_pt2pt_component.p2p_c_modules,
|
|
|
|
module->p2p_comm->c_contextid,
|
|
|
|
module);
|
2007-05-21 06:21:25 +04:00
|
|
|
ret = opal_hash_table_get_size(&mca_osc_pt2pt_component.p2p_c_modules);
|
|
|
|
if (ret == 1) {
|
|
|
|
#if OMPI_ENABLE_PROGRESS_THREADS
|
|
|
|
mca_osc_pt2pt_component.p2p_c_thread_run = true;
|
2007-05-21 07:23:58 +04:00
|
|
|
mca_osc_pt2pt_component.p2p_c_thread.t_run = component_thread_fn;
|
2007-05-21 06:21:25 +04:00
|
|
|
mca_osc_pt2pt_component.p2p_c_thread.t_arg = NULL;
|
|
|
|
ret = opal_thread_start(&mca_osc_pt2pt_component.p2p_c_thread);
|
|
|
|
#else
|
|
|
|
ret = opal_progress_register(ompi_osc_pt2pt_component_progress);
|
|
|
|
#endif
|
2007-05-22 00:53:02 +04:00
|
|
|
} else {
|
|
|
|
ret = OMPI_SUCCESS;
|
2006-08-03 04:10:19 +04:00
|
|
|
}
|
2007-05-21 06:21:25 +04:00
|
|
|
OPAL_THREAD_UNLOCK(&mca_osc_pt2pt_component.p2p_c_lock);
|
2007-05-22 00:53:02 +04:00
|
|
|
if (OMPI_SUCCESS != ret) goto cleanup;
|
2006-02-21 21:43:28 +03:00
|
|
|
|
2006-01-28 18:38:37 +03:00
|
|
|
/* fill in window information */
|
|
|
|
win->w_osc_module = (ompi_osc_base_module_t*) module;
|
2006-03-24 21:56:59 +03:00
|
|
|
if (check_config_value_bool("no_locks", info)) {
|
2006-02-21 21:43:28 +03:00
|
|
|
win->w_flags |= OMPI_WIN_NO_LOCKS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* sync memory - make sure all initialization completed */
|
|
|
|
opal_atomic_mb();
|
2006-01-28 18:38:37 +03:00
|
|
|
|
2006-08-03 04:10:19 +04:00
|
|
|
/* start up receive for protocol headers */
|
2007-05-21 06:21:25 +04:00
|
|
|
OPAL_FREE_LIST_WAIT(&mca_osc_pt2pt_component.p2p_c_buffers,
|
|
|
|
item, ret);
|
|
|
|
if (OMPI_SUCCESS != ret) goto cleanup;
|
|
|
|
|
2006-11-27 06:22:44 +03:00
|
|
|
buffer = (ompi_osc_pt2pt_buffer_t*) item;
|
2007-05-21 06:21:25 +04:00
|
|
|
buffer->mpireq.cbfunc = component_fragment_cb;
|
|
|
|
buffer->mpireq.cbdata = (void*) module;
|
2006-11-27 06:22:44 +03:00
|
|
|
|
|
|
|
ret = MCA_PML_CALL(irecv(buffer->payload,
|
2006-08-03 04:10:19 +04:00
|
|
|
mca_osc_pt2pt_component.p2p_c_eager_size,
|
|
|
|
MPI_BYTE,
|
|
|
|
MPI_ANY_SOURCE,
|
2006-11-27 06:22:44 +03:00
|
|
|
CONTROL_MSG_TAG,
|
2006-08-03 04:10:19 +04:00
|
|
|
module->p2p_comm,
|
2007-05-21 06:21:25 +04:00
|
|
|
&buffer->mpireq.request));
|
|
|
|
if (OMPI_SUCCESS != ret) goto cleanup;
|
|
|
|
|
|
|
|
OPAL_THREAD_LOCK(&mca_osc_pt2pt_component.p2p_c_lock);
|
|
|
|
opal_list_append(&mca_osc_pt2pt_component.p2p_c_pending_requests,
|
|
|
|
&buffer->mpireq.super.super);
|
2007-05-21 20:06:14 +04:00
|
|
|
OPAL_THREAD_UNLOCK(&mca_osc_pt2pt_component.p2p_c_lock);
|
2007-05-21 06:21:25 +04:00
|
|
|
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
OBJ_DESTRUCT(&module->p2p_unlocks_pending);
|
|
|
|
OBJ_DESTRUCT(&module->p2p_locks_pending);
|
|
|
|
OBJ_DESTRUCT(&module->p2p_copy_pending_sendreqs);
|
|
|
|
OBJ_DESTRUCT(&module->p2p_pending_sendreqs);
|
|
|
|
OBJ_DESTRUCT(&module->p2p_acc_lock);
|
|
|
|
OBJ_DESTRUCT(&module->p2p_cond);
|
|
|
|
OBJ_DESTRUCT(&module->p2p_lock);
|
|
|
|
|
|
|
|
if (NULL != buffer) {
|
|
|
|
OPAL_FREE_LIST_RETURN(&mca_osc_pt2pt_component.p2p_c_buffers, item);
|
|
|
|
}
|
|
|
|
if (NULL != module->p2p_sc_remote_ranks) {
|
|
|
|
free(module->p2p_sc_remote_ranks);
|
|
|
|
}
|
|
|
|
if (NULL != module->p2p_sc_remote_active_ranks) {
|
|
|
|
free(module->p2p_sc_remote_active_ranks);
|
|
|
|
}
|
|
|
|
if (NULL != module->p2p_fence_coll_counts) {
|
|
|
|
free(module->p2p_fence_coll_counts);
|
|
|
|
}
|
|
|
|
if (NULL != module->p2p_copy_num_pending_sendreqs) {
|
|
|
|
free(module->p2p_copy_num_pending_sendreqs);
|
|
|
|
}
|
|
|
|
if (NULL != module->p2p_num_pending_sendreqs) {
|
|
|
|
free(module->p2p_num_pending_sendreqs);
|
|
|
|
}
|
|
|
|
if (NULL != module->p2p_comm) ompi_comm_free(&module->p2p_comm);
|
|
|
|
|
|
|
|
#if OMPI_ENABLE_DEBUG
|
|
|
|
memset(module, 0, sizeof(ompi_osc_base_module_t));
|
|
|
|
#endif
|
|
|
|
if (NULL != module) free(module);
|
2006-03-24 21:56:59 +03:00
|
|
|
|
2006-01-28 18:38:37 +03:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* dispatch for callback on message completion */
|
2006-08-03 04:10:19 +04:00
|
|
|
static void
|
2007-05-21 06:21:25 +04:00
|
|
|
component_fragment_cb(ompi_osc_pt2pt_mpireq_t *mpireq)
|
2006-01-28 18:38:37 +03:00
|
|
|
{
|
|
|
|
int ret;
|
2007-05-21 06:21:25 +04:00
|
|
|
ompi_osc_pt2pt_buffer_t *buffer =
|
|
|
|
(ompi_osc_pt2pt_buffer_t*) mpireq;
|
|
|
|
ompi_osc_pt2pt_module_t *module =
|
|
|
|
(ompi_osc_pt2pt_module_t*) mpireq->cbdata;
|
2006-11-27 06:22:44 +03:00
|
|
|
|
|
|
|
|
2007-05-21 06:21:25 +04:00
|
|
|
assert(mpireq->status._count >= (int) sizeof(ompi_osc_pt2pt_base_header_t));
|
2006-01-28 18:38:37 +03:00
|
|
|
|
|
|
|
/* handle message */
|
2007-05-21 06:21:25 +04:00
|
|
|
switch (((ompi_osc_pt2pt_base_header_t*) buffer->payload)->hdr_type) {
|
2006-01-28 18:38:37 +03:00
|
|
|
case OMPI_OSC_PT2PT_HDR_PUT:
|
|
|
|
{
|
|
|
|
/* get our header and payload */
|
2007-05-21 06:21:25 +04:00
|
|
|
ompi_osc_pt2pt_send_header_t *header =
|
|
|
|
(ompi_osc_pt2pt_send_header_t*) buffer->payload;
|
|
|
|
void *payload = (void*) (header + 1);
|
2006-01-28 18:38:37 +03:00
|
|
|
|
2006-02-27 21:47:00 +03:00
|
|
|
#if !defined(WORDS_BIGENDIAN) && OMPI_ENABLE_HETEROGENEOUS_SUPPORT
|
|
|
|
if (header->hdr_base.hdr_flags & OMPI_OSC_PT2PT_HDR_FLAG_NBO) {
|
|
|
|
OMPI_OSC_PT2PT_SEND_HDR_NTOH(*header);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-09-01 01:07:52 +04:00
|
|
|
if (!ompi_win_exposure_epoch(module->p2p_win)) {
|
2006-09-28 19:11:11 +04:00
|
|
|
if (OMPI_WIN_FENCE & ompi_win_get_mode(module->p2p_win)) {
|
|
|
|
ompi_win_set_mode(module->p2p_win,
|
|
|
|
OMPI_WIN_FENCE |
|
|
|
|
OMPI_WIN_ACCESS_EPOCH |
|
|
|
|
OMPI_WIN_EXPOSE_EPOCH);
|
|
|
|
}
|
2006-09-01 01:07:52 +04:00
|
|
|
}
|
|
|
|
|
2006-01-28 18:38:37 +03:00
|
|
|
ret = ompi_osc_pt2pt_sendreq_recv_put(module, header, payload);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case OMPI_OSC_PT2PT_HDR_ACC:
|
|
|
|
{
|
|
|
|
/* get our header and payload */
|
2007-05-21 06:21:25 +04:00
|
|
|
ompi_osc_pt2pt_send_header_t *header =
|
|
|
|
(ompi_osc_pt2pt_send_header_t*) buffer->payload;
|
|
|
|
void *payload = (void*) (header + 1);
|
2006-01-28 18:38:37 +03:00
|
|
|
|
2006-02-27 21:47:00 +03:00
|
|
|
#if !defined(WORDS_BIGENDIAN) && OMPI_ENABLE_HETEROGENEOUS_SUPPORT
|
|
|
|
if (header->hdr_base.hdr_flags & OMPI_OSC_PT2PT_HDR_FLAG_NBO) {
|
|
|
|
OMPI_OSC_PT2PT_SEND_HDR_NTOH(*header);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-09-01 01:07:52 +04:00
|
|
|
if (!ompi_win_exposure_epoch(module->p2p_win)) {
|
2006-09-28 19:11:11 +04:00
|
|
|
if (OMPI_WIN_FENCE & ompi_win_get_mode(module->p2p_win)) {
|
|
|
|
ompi_win_set_mode(module->p2p_win,
|
|
|
|
OMPI_WIN_FENCE |
|
|
|
|
OMPI_WIN_ACCESS_EPOCH |
|
|
|
|
OMPI_WIN_EXPOSE_EPOCH);
|
|
|
|
}
|
2006-09-01 01:07:52 +04:00
|
|
|
}
|
|
|
|
|
2006-01-28 18:38:37 +03:00
|
|
|
/* receive into temporary buffer */
|
|
|
|
ret = ompi_osc_pt2pt_sendreq_recv_accum(module, header, payload);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case OMPI_OSC_PT2PT_HDR_GET:
|
|
|
|
{
|
2007-05-21 06:21:25 +04:00
|
|
|
/* get our header and payload */
|
|
|
|
ompi_osc_pt2pt_send_header_t *header =
|
|
|
|
(ompi_osc_pt2pt_send_header_t*) buffer->payload;
|
|
|
|
void *payload = (void*) (header + 1);
|
2006-01-28 18:38:37 +03:00
|
|
|
ompi_datatype_t *datatype;
|
|
|
|
ompi_osc_pt2pt_replyreq_t *replyreq;
|
2006-02-07 15:16:23 +03:00
|
|
|
ompi_proc_t *proc;
|
2006-01-28 18:38:37 +03:00
|
|
|
|
2006-02-27 21:47:00 +03:00
|
|
|
#if !defined(WORDS_BIGENDIAN) && OMPI_ENABLE_HETEROGENEOUS_SUPPORT
|
|
|
|
if (header->hdr_base.hdr_flags & OMPI_OSC_PT2PT_HDR_FLAG_NBO) {
|
|
|
|
OMPI_OSC_PT2PT_SEND_HDR_NTOH(*header);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-09-01 01:07:52 +04:00
|
|
|
if (!ompi_win_exposure_epoch(module->p2p_win)) {
|
2006-09-28 19:11:11 +04:00
|
|
|
if (OMPI_WIN_FENCE & ompi_win_get_mode(module->p2p_win)) {
|
|
|
|
ompi_win_set_mode(module->p2p_win,
|
|
|
|
OMPI_WIN_FENCE |
|
|
|
|
OMPI_WIN_ACCESS_EPOCH |
|
|
|
|
OMPI_WIN_EXPOSE_EPOCH);
|
|
|
|
}
|
2006-09-01 01:07:52 +04:00
|
|
|
}
|
|
|
|
|
2006-01-28 18:38:37 +03:00
|
|
|
/* create or get a pointer to our datatype */
|
2006-09-21 02:14:46 +04:00
|
|
|
proc = ompi_comm_peer_lookup( module->p2p_comm, header->hdr_origin );
|
2006-02-07 15:16:23 +03:00
|
|
|
datatype = ompi_osc_pt2pt_datatype_create(proc, &payload);
|
2006-01-28 18:38:37 +03:00
|
|
|
|
|
|
|
/* create replyreq sendreq */
|
|
|
|
ret = ompi_osc_pt2pt_replyreq_alloc_init(module,
|
|
|
|
header->hdr_origin,
|
|
|
|
header->hdr_origin_sendreq,
|
|
|
|
header->hdr_target_disp,
|
|
|
|
header->hdr_target_count,
|
|
|
|
datatype,
|
|
|
|
&replyreq);
|
|
|
|
|
|
|
|
/* send replyreq */
|
|
|
|
ompi_osc_pt2pt_replyreq_send(module, replyreq);
|
|
|
|
|
|
|
|
/* sendreq does the right retain, so we can release safely */
|
|
|
|
OBJ_RELEASE(datatype);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case OMPI_OSC_PT2PT_HDR_REPLY:
|
|
|
|
{
|
2007-05-21 06:21:25 +04:00
|
|
|
ompi_osc_pt2pt_reply_header_t *header =
|
|
|
|
(ompi_osc_pt2pt_reply_header_t*) buffer->payload;
|
|
|
|
void *payload = (void*) (header + 1);
|
2006-01-28 18:38:37 +03:00
|
|
|
ompi_osc_pt2pt_sendreq_t *sendreq;
|
|
|
|
|
2006-02-27 21:47:00 +03:00
|
|
|
#if !defined(WORDS_BIGENDIAN) && OMPI_ENABLE_HETEROGENEOUS_SUPPORT
|
|
|
|
if (header->hdr_base.hdr_flags & OMPI_OSC_PT2PT_HDR_FLAG_NBO) {
|
|
|
|
OMPI_OSC_PT2PT_REPLY_HDR_NTOH(*header);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-01-28 18:38:37 +03:00
|
|
|
/* get original sendreq pointer */
|
2007-01-05 01:07:37 +03:00
|
|
|
sendreq = (ompi_osc_pt2pt_sendreq_t*) header->hdr_origin_sendreq.pval;
|
2006-01-28 18:38:37 +03:00
|
|
|
module = sendreq->req_module;
|
|
|
|
|
|
|
|
/* receive data */
|
|
|
|
ompi_osc_pt2pt_replyreq_recv(module, sendreq, header, payload);
|
|
|
|
}
|
|
|
|
break;
|
2007-05-21 06:21:25 +04:00
|
|
|
|
2006-01-31 05:44:08 +03:00
|
|
|
case OMPI_OSC_PT2PT_HDR_POST:
|
|
|
|
{
|
2007-05-21 06:21:25 +04:00
|
|
|
int32_t count;
|
2007-05-22 00:53:02 +04:00
|
|
|
OPAL_THREAD_LOCK(&module->p2p_lock);
|
|
|
|
count = (module->p2p_num_post_msgs -= 1);
|
|
|
|
OPAL_THREAD_UNLOCK(&module->p2p_lock);
|
|
|
|
if (count == 0) opal_condition_broadcast(&module->p2p_cond);
|
2006-01-31 05:44:08 +03:00
|
|
|
}
|
|
|
|
break;
|
2007-05-21 06:21:25 +04:00
|
|
|
|
2006-01-31 05:44:08 +03:00
|
|
|
case OMPI_OSC_PT2PT_HDR_COMPLETE:
|
|
|
|
{
|
|
|
|
ompi_osc_pt2pt_control_header_t *header =
|
2007-05-21 06:21:25 +04:00
|
|
|
(ompi_osc_pt2pt_control_header_t*) buffer->payload;
|
|
|
|
int32_t count;
|
2006-01-31 05:44:08 +03:00
|
|
|
|
2006-02-27 21:47:00 +03:00
|
|
|
#if !defined(WORDS_BIGENDIAN) && OMPI_ENABLE_HETEROGENEOUS_SUPPORT
|
|
|
|
if (header->hdr_base.hdr_flags & OMPI_OSC_PT2PT_HDR_FLAG_NBO) {
|
|
|
|
OMPI_OSC_PT2PT_CONTROL_HDR_NTOH(*header);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-01-31 05:44:08 +03:00
|
|
|
/* we've heard from one more place, and have value reqs to
|
|
|
|
process */
|
2007-05-22 00:53:02 +04:00
|
|
|
OPAL_THREAD_LOCK(&module->p2p_lock);
|
|
|
|
count = (module->p2p_num_complete_msgs -= 1);
|
|
|
|
count += (module->p2p_num_pending_in += header->hdr_value[0]);
|
|
|
|
OPAL_THREAD_UNLOCK(&module->p2p_lock);
|
|
|
|
|
2007-05-21 06:21:25 +04:00
|
|
|
if (count == 0) opal_condition_broadcast(&module->p2p_cond);
|
2006-02-07 21:45:18 +03:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case OMPI_OSC_PT2PT_HDR_LOCK_REQ:
|
|
|
|
{
|
|
|
|
ompi_osc_pt2pt_control_header_t *header =
|
2007-05-21 06:21:25 +04:00
|
|
|
(ompi_osc_pt2pt_control_header_t*) buffer->payload;
|
|
|
|
int32_t count;
|
2006-02-07 21:45:18 +03:00
|
|
|
|
2006-02-27 21:47:00 +03:00
|
|
|
#if !defined(WORDS_BIGENDIAN) && OMPI_ENABLE_HETEROGENEOUS_SUPPORT
|
|
|
|
if (header->hdr_base.hdr_flags & OMPI_OSC_PT2PT_HDR_FLAG_NBO) {
|
|
|
|
OMPI_OSC_PT2PT_CONTROL_HDR_NTOH(*header);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-02-07 21:45:18 +03:00
|
|
|
if (header->hdr_value[1] > 0) {
|
|
|
|
ompi_osc_pt2pt_passive_lock(module, header->hdr_value[0],
|
|
|
|
header->hdr_value[1]);
|
|
|
|
} else {
|
2007-05-22 00:53:02 +04:00
|
|
|
OPAL_THREAD_LOCK(&module->p2p_lock);
|
|
|
|
count = (module->p2p_lock_received_ack += 1);
|
|
|
|
OPAL_THREAD_UNLOCK(&module->p2p_lock);
|
|
|
|
|
2007-05-21 06:21:25 +04:00
|
|
|
if (count != 0) opal_condition_broadcast(&module->p2p_cond);
|
2006-02-07 21:45:18 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case OMPI_OSC_PT2PT_HDR_UNLOCK_REQ:
|
|
|
|
{
|
|
|
|
ompi_osc_pt2pt_control_header_t *header =
|
2007-05-21 06:21:25 +04:00
|
|
|
(ompi_osc_pt2pt_control_header_t*) buffer->payload;
|
2006-02-07 21:45:18 +03:00
|
|
|
|
2006-02-27 21:47:00 +03:00
|
|
|
#if !defined(WORDS_BIGENDIAN) && OMPI_ENABLE_HETEROGENEOUS_SUPPORT
|
|
|
|
if (header->hdr_base.hdr_flags & OMPI_OSC_PT2PT_HDR_FLAG_NBO) {
|
|
|
|
OMPI_OSC_PT2PT_CONTROL_HDR_NTOH(*header);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-02-07 21:45:18 +03:00
|
|
|
ompi_osc_pt2pt_passive_unlock(module, header->hdr_value[0],
|
|
|
|
header->hdr_value[1]);
|
2006-01-31 05:44:08 +03:00
|
|
|
}
|
|
|
|
break;
|
2007-05-21 06:21:25 +04:00
|
|
|
|
2007-01-15 01:08:38 +03:00
|
|
|
case OMPI_OSC_PT2PT_HDR_UNLOCK_REPLY:
|
|
|
|
{
|
2007-05-21 06:21:25 +04:00
|
|
|
int32_t count;
|
2006-01-31 05:44:08 +03:00
|
|
|
|
2007-05-22 00:53:02 +04:00
|
|
|
OPAL_THREAD_LOCK(&module->p2p_lock);
|
|
|
|
count = (module->p2p_num_pending_out -= 1);
|
|
|
|
OPAL_THREAD_UNLOCK(&module->p2p_lock);
|
|
|
|
if (count == 0) opal_condition_broadcast(&module->p2p_cond);
|
2007-01-15 01:08:38 +03:00
|
|
|
}
|
|
|
|
break;
|
2007-05-21 06:21:25 +04:00
|
|
|
|
2006-01-28 18:38:37 +03:00
|
|
|
default:
|
2006-08-17 18:52:20 +04:00
|
|
|
opal_output_verbose(5, ompi_osc_base_output,
|
2007-05-21 06:21:25 +04:00
|
|
|
"received one-sided packet for with unknown type");
|
|
|
|
}
|
2006-11-27 06:22:44 +03:00
|
|
|
|
2007-05-21 06:21:25 +04:00
|
|
|
ret = MCA_PML_CALL(irecv(buffer->payload,
|
|
|
|
mca_osc_pt2pt_component.p2p_c_eager_size,
|
|
|
|
MPI_BYTE,
|
|
|
|
MPI_ANY_SOURCE,
|
|
|
|
CONTROL_MSG_TAG,
|
|
|
|
module->p2p_comm,
|
|
|
|
&buffer->mpireq.request));
|
|
|
|
/* BWB -- FIX ME -- handle irecv errors */
|
|
|
|
OPAL_THREAD_LOCK(&mca_osc_pt2pt_component.p2p_c_lock);
|
|
|
|
opal_list_append(&mca_osc_pt2pt_component.p2p_c_pending_requests,
|
|
|
|
&buffer->mpireq.super.super);
|
|
|
|
OPAL_THREAD_UNLOCK(&mca_osc_pt2pt_component.p2p_c_lock);
|
2006-01-28 18:38:37 +03:00
|
|
|
}
|
2006-08-03 04:10:19 +04:00
|
|
|
|
|
|
|
|
2007-01-17 05:30:11 +03:00
|
|
|
int
|
2007-05-21 06:21:25 +04:00
|
|
|
ompi_osc_pt2pt_component_progress(void)
|
2006-08-03 04:10:19 +04:00
|
|
|
{
|
2007-05-21 06:21:25 +04:00
|
|
|
opal_list_item_t *item;
|
|
|
|
int ret, done = 0;
|
|
|
|
|
2007-05-24 00:31:25 +04:00
|
|
|
#if OMPI_ENABLE_PROGRESS_THREADS
|
|
|
|
ret = OPAL_THREAD_LOCK(&mca_osc_pt2pt_component.p2p_c_lock);
|
|
|
|
#else
|
2007-05-21 06:21:25 +04:00
|
|
|
ret = OPAL_THREAD_TRYLOCK(&mca_osc_pt2pt_component.p2p_c_lock);
|
2007-05-24 00:31:25 +04:00
|
|
|
#endif
|
2007-05-21 06:21:25 +04:00
|
|
|
if (ret != 0) return 0;
|
2006-08-03 04:10:19 +04:00
|
|
|
|
2007-05-21 06:21:25 +04:00
|
|
|
for (item = opal_list_get_first(&mca_osc_pt2pt_component.p2p_c_pending_requests) ;
|
|
|
|
item != opal_list_get_end(&mca_osc_pt2pt_component.p2p_c_pending_requests) ;
|
|
|
|
item = opal_list_get_next(item)) {
|
|
|
|
ompi_osc_pt2pt_mpireq_t *buffer =
|
|
|
|
(ompi_osc_pt2pt_mpireq_t*) item;
|
|
|
|
|
|
|
|
/* BWB - FIX ME */
|
2006-08-03 04:10:19 +04:00
|
|
|
#if OMPI_ENABLE_PROGRESS_THREADS == 0
|
2007-05-21 06:21:25 +04:00
|
|
|
if (buffer->request->req_state == OMPI_REQUEST_INACTIVE ||
|
|
|
|
buffer->request->req_complete) {
|
|
|
|
ret = ompi_request_test(&buffer->request,
|
|
|
|
&done,
|
|
|
|
&buffer->status);
|
|
|
|
} else {
|
|
|
|
done = 0;
|
|
|
|
ret = OMPI_SUCCESS;
|
|
|
|
}
|
2006-08-03 04:10:19 +04:00
|
|
|
#else
|
2007-05-21 06:21:25 +04:00
|
|
|
ret = ompi_request_test(&buffer->request,
|
|
|
|
&done,
|
|
|
|
&buffer->status);
|
2006-08-03 04:10:19 +04:00
|
|
|
#endif
|
2007-05-21 06:21:25 +04:00
|
|
|
if (OMPI_SUCCESS == ret && 0 != done) {
|
|
|
|
opal_list_remove_item(&mca_osc_pt2pt_component.p2p_c_pending_requests,
|
|
|
|
item);
|
|
|
|
OPAL_THREAD_UNLOCK(&mca_osc_pt2pt_component.p2p_c_lock);
|
|
|
|
buffer->cbfunc(buffer);
|
|
|
|
OPAL_THREAD_LOCK(&mca_osc_pt2pt_component.p2p_c_lock);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
OPAL_THREAD_UNLOCK(&mca_osc_pt2pt_component.p2p_c_lock);
|
2006-08-03 04:10:19 +04:00
|
|
|
|
2007-05-21 06:21:25 +04:00
|
|
|
return done;
|
2006-08-03 04:10:19 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-05-21 06:21:25 +04:00
|
|
|
#if OMPI_ENABLE_PROGRESS_THREADS
|
2007-05-21 07:23:58 +04:00
|
|
|
static void*
|
|
|
|
component_thread_fn(opal_object_t *obj)
|
2007-05-21 06:21:25 +04:00
|
|
|
{
|
2007-05-22 00:53:02 +04:00
|
|
|
struct timespec waittime;
|
|
|
|
|
2007-05-21 07:23:58 +04:00
|
|
|
while (mca_osc_pt2pt_component.p2p_c_thread_run) {
|
2007-05-21 06:21:25 +04:00
|
|
|
/* wake up whenever a request completes, to make sure it's not
|
|
|
|
for us */
|
2007-05-22 00:53:02 +04:00
|
|
|
waittime.tv_sec = 1;
|
2007-05-23 16:56:34 +04:00
|
|
|
waittime.tv_nsec = 0;
|
2007-05-21 07:23:58 +04:00
|
|
|
OPAL_THREAD_LOCK(&ompi_request_lock);
|
2007-05-23 16:56:34 +04:00
|
|
|
opal_condition_timedwait(&ompi_request_cond, &ompi_request_lock, &waittime);
|
2007-05-21 07:23:58 +04:00
|
|
|
OPAL_THREAD_UNLOCK(&ompi_request_lock);
|
|
|
|
ompi_osc_pt2pt_component_progress();
|
2007-05-21 06:21:25 +04:00
|
|
|
}
|
2007-05-21 07:23:58 +04:00
|
|
|
|
|
|
|
return NULL;
|
2006-08-03 04:10:19 +04:00
|
|
|
}
|
2007-05-21 06:21:25 +04:00
|
|
|
#endif
|