2006-01-28 18:38:37 +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.
|
|
|
|
* 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.
|
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ompi_config.h"
|
|
|
|
|
|
|
|
#include "osc_pt2pt.h"
|
|
|
|
#include "osc_pt2pt_sendreq.h"
|
|
|
|
#include "osc_pt2pt_longreq.h"
|
|
|
|
#include "osc_pt2pt_header.h"
|
|
|
|
#include "osc_pt2pt_data_move.h"
|
|
|
|
|
|
|
|
#include "mpi.h"
|
|
|
|
#include "opal/runtime/opal_progress.h"
|
|
|
|
#include "opal/threads/mutex.h"
|
|
|
|
#include "ompi/communicator/communicator.h"
|
2006-08-17 18:52:20 +04:00
|
|
|
#include "ompi/mca/osc/base/base.h"
|
2006-01-28 18:38:37 +03:00
|
|
|
|
2006-02-01 00:40:12 +03:00
|
|
|
/* should have p2p_lock before calling */
|
2006-01-28 18:38:37 +03:00
|
|
|
static inline void
|
2006-08-03 04:10:19 +04:00
|
|
|
ompi_osc_pt2pt_progress_long(ompi_osc_pt2pt_module_t *module)
|
2006-01-28 18:38:37 +03:00
|
|
|
{
|
2006-02-07 15:16:23 +03:00
|
|
|
if (0 != opal_list_get_size(&(module->p2p_long_msgs))) {
|
2006-01-28 18:38:37 +03:00
|
|
|
opal_list_item_t *item, *next;
|
|
|
|
|
2006-02-07 15:16:23 +03:00
|
|
|
OPAL_THREAD_LOCK(&(module->p2p_lock));
|
|
|
|
|
2006-01-28 18:38:37 +03:00
|
|
|
/* Have to go the convoluted while() route instead of a for()
|
|
|
|
loop because the callback will likely remove the request
|
|
|
|
from the list and free it, and that would lead to much
|
|
|
|
badness. */
|
|
|
|
next = opal_list_get_first(&(module->p2p_long_msgs));
|
|
|
|
while (opal_list_get_end(&(module->p2p_long_msgs)) != (item = next)) {
|
|
|
|
ompi_osc_pt2pt_longreq_t *longreq =
|
|
|
|
(ompi_osc_pt2pt_longreq_t*) item;
|
|
|
|
int ret, completed;
|
|
|
|
next = opal_list_get_next(item);
|
|
|
|
|
2007-01-17 05:30:11 +03:00
|
|
|
ret = ompi_osc_pt2pt_request_test(&(longreq->req_pml_req), &completed, NULL);
|
2006-01-28 18:38:37 +03:00
|
|
|
/* BWB - FIX ME - error handling */
|
|
|
|
if (completed > 0) {
|
|
|
|
longreq->req_comp_cb(longreq);
|
|
|
|
}
|
|
|
|
}
|
2006-02-07 15:16:23 +03:00
|
|
|
|
|
|
|
OPAL_THREAD_UNLOCK(&(module->p2p_lock));
|
2006-01-28 18:38:37 +03:00
|
|
|
}
|
|
|
|
opal_progress();
|
|
|
|
}
|
|
|
|
|
2006-02-07 15:16:23 +03:00
|
|
|
static inline void
|
|
|
|
ompi_osc_pt2pt_flip_sendreqs(ompi_osc_pt2pt_module_t *module)
|
|
|
|
{
|
2006-11-28 00:41:29 +03:00
|
|
|
unsigned int *tmp;
|
2006-02-07 15:16:23 +03:00
|
|
|
|
|
|
|
OPAL_THREAD_LOCK(&(module->p2p_lock));
|
|
|
|
|
|
|
|
tmp = module->p2p_copy_num_pending_sendreqs;
|
|
|
|
module->p2p_copy_num_pending_sendreqs =
|
|
|
|
module->p2p_num_pending_sendreqs;
|
|
|
|
module->p2p_num_pending_sendreqs = tmp;
|
|
|
|
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
|
|
|
|
|
|
|
/* Copy in all the pending requests */
|
|
|
|
opal_list_join(&module->p2p_copy_pending_sendreqs,
|
|
|
|
opal_list_get_end(&module->p2p_copy_pending_sendreqs),
|
|
|
|
&module->p2p_pending_sendreqs);
|
|
|
|
|
|
|
|
OPAL_THREAD_UNLOCK(&(module->p2p_lock));
|
|
|
|
}
|
|
|
|
|
2006-01-28 18:38:37 +03:00
|
|
|
|
|
|
|
int
|
|
|
|
ompi_osc_pt2pt_module_fence(int assert, ompi_win_t *win)
|
|
|
|
{
|
2006-11-28 00:41:29 +03:00
|
|
|
unsigned int incoming_reqs;
|
2006-03-21 17:10:07 +03:00
|
|
|
int ret = OMPI_SUCCESS, i;
|
2006-02-07 15:16:23 +03:00
|
|
|
|
|
|
|
if (0 != (assert & MPI_MODE_NOPRECEDE)) {
|
|
|
|
int num_pending;
|
|
|
|
|
|
|
|
/* check that the user didn't lie to us - since NOPRECEDED
|
|
|
|
must be specified by all processes if it is specified by
|
|
|
|
any process, if we see this it is safe to assume that there
|
|
|
|
are no pending operations anywhere needed to close out this
|
|
|
|
epoch. */
|
|
|
|
OPAL_THREAD_LOCK(&(P2P_MODULE(win)->p2p_lock));
|
|
|
|
num_pending = opal_list_get_size(&(P2P_MODULE(win)->p2p_pending_sendreqs));
|
|
|
|
OPAL_THREAD_UNLOCK(&(P2P_MODULE(win)->p2p_lock));
|
|
|
|
if (0 != num_pending) {
|
|
|
|
return MPI_ERR_RMA_SYNC;
|
|
|
|
}
|
2006-01-28 18:38:37 +03:00
|
|
|
|
2006-02-07 15:16:23 +03:00
|
|
|
} else {
|
|
|
|
opal_list_item_t *item;
|
2006-01-28 18:38:37 +03:00
|
|
|
|
2006-02-07 15:16:23 +03:00
|
|
|
ompi_osc_pt2pt_flip_sendreqs(P2P_MODULE(win));
|
|
|
|
|
2006-03-16 21:40:42 +03:00
|
|
|
/* find out how much data everyone is going to send us. Need
|
|
|
|
to have the lock during this period so that we have a sane
|
|
|
|
view of the number of sendreqs */
|
2006-08-03 04:10:19 +04:00
|
|
|
ret = P2P_MODULE(win)->p2p_comm->
|
|
|
|
c_coll.coll_reduce_scatter(P2P_MODULE(win)->p2p_copy_num_pending_sendreqs,
|
|
|
|
&incoming_reqs,
|
|
|
|
P2P_MODULE(win)->p2p_fence_coll_counts,
|
2006-11-28 00:41:29 +03:00
|
|
|
MPI_UNSIGNED,
|
2006-08-03 04:10:19 +04:00
|
|
|
MPI_SUM,
|
|
|
|
P2P_MODULE(win)->p2p_comm);
|
2006-03-16 21:40:42 +03:00
|
|
|
|
2006-02-07 15:16:23 +03:00
|
|
|
if (OMPI_SUCCESS != ret) {
|
|
|
|
/* put the stupid data back for the user. This is not
|
|
|
|
cheap, but the user lost his data if we don't. */
|
|
|
|
OPAL_THREAD_LOCK(&(P2P_MODULE(win)->p2p_lock));
|
|
|
|
opal_list_join(&P2P_MODULE(win)->p2p_pending_sendreqs,
|
|
|
|
opal_list_get_end(&P2P_MODULE(win)->p2p_pending_sendreqs),
|
|
|
|
&P2P_MODULE(win)->p2p_copy_pending_sendreqs);
|
|
|
|
|
|
|
|
for (i = 0 ; i < ompi_comm_size(P2P_MODULE(win)->p2p_comm) ; ++i) {
|
|
|
|
P2P_MODULE(win)->p2p_num_pending_sendreqs[i] +=
|
|
|
|
P2P_MODULE(win)->p2p_copy_num_pending_sendreqs[i];
|
|
|
|
}
|
2006-01-28 18:38:37 +03:00
|
|
|
|
2006-02-07 15:16:23 +03:00
|
|
|
OPAL_THREAD_UNLOCK(&(P2P_MODULE(win)->p2p_lock));
|
|
|
|
return ret;
|
2006-01-28 18:38:37 +03:00
|
|
|
}
|
|
|
|
|
2006-02-07 15:16:23 +03:00
|
|
|
/* possible we've already received a couple in messages, so
|
|
|
|
atomicall add however many we're going to wait for */
|
|
|
|
OPAL_THREAD_ADD32(&(P2P_MODULE(win)->p2p_num_pending_in), incoming_reqs);
|
|
|
|
OPAL_THREAD_ADD32(&(P2P_MODULE(win)->p2p_num_pending_out),
|
|
|
|
opal_list_get_size(&(P2P_MODULE(win)->p2p_copy_pending_sendreqs)));
|
|
|
|
|
2006-08-17 18:52:20 +04:00
|
|
|
opal_output_verbose(50, ompi_osc_base_output,
|
|
|
|
"fence: waiting on %d in and %d out",
|
|
|
|
P2P_MODULE(win)->p2p_num_pending_in,
|
|
|
|
P2P_MODULE(win)->p2p_num_pending_out);
|
2006-02-22 08:14:34 +03:00
|
|
|
|
2006-02-07 15:16:23 +03:00
|
|
|
/* try to start all the requests. We've copied everything we
|
|
|
|
need out of pending_sendreqs, so don't need the lock
|
|
|
|
here */
|
|
|
|
while (NULL !=
|
|
|
|
(item = opal_list_remove_first(&(P2P_MODULE(win)->p2p_copy_pending_sendreqs)))) {
|
|
|
|
ompi_osc_pt2pt_sendreq_t *req =
|
|
|
|
(ompi_osc_pt2pt_sendreq_t*) item;
|
2006-01-28 18:38:37 +03:00
|
|
|
|
2006-02-07 15:16:23 +03:00
|
|
|
ret = ompi_osc_pt2pt_sendreq_send(P2P_MODULE(win), req);
|
2006-01-28 18:38:37 +03:00
|
|
|
|
2006-02-07 15:16:23 +03:00
|
|
|
if (OMPI_SUCCESS != ret) {
|
2006-08-17 18:52:20 +04:00
|
|
|
opal_output_verbose(5, ompi_osc_base_output,
|
|
|
|
"fence: failure in starting sendreq (%d). Will try later.",
|
|
|
|
ret);
|
2006-02-07 15:16:23 +03:00
|
|
|
opal_list_append(&(P2P_MODULE(win)->p2p_copy_pending_sendreqs), item);
|
2006-01-28 18:38:37 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-07 15:16:23 +03:00
|
|
|
/* now we know how many things we're waiting for - wait for them... */
|
2006-03-24 21:56:59 +03:00
|
|
|
while (P2P_MODULE(win)->p2p_num_pending_in > 0 ||
|
2006-02-07 15:16:23 +03:00
|
|
|
0 != P2P_MODULE(win)->p2p_num_pending_out) {
|
2006-08-03 04:10:19 +04:00
|
|
|
ompi_osc_pt2pt_progress_long(P2P_MODULE(win));
|
2006-01-28 18:38:37 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* all transfers are done - back to the real world we go */
|
|
|
|
if (0 == (assert & MPI_MODE_NOSUCCEED)) {
|
2006-02-24 16:04:15 +03:00
|
|
|
ompi_win_set_mode(win, OMPI_WIN_FENCE);
|
2006-01-28 18:38:37 +03:00
|
|
|
} else {
|
2006-02-01 00:40:12 +03:00
|
|
|
ompi_win_set_mode(win, 0);
|
2006-01-28 18:38:37 +03:00
|
|
|
}
|
|
|
|
|
2006-02-07 15:16:23 +03:00
|
|
|
return OMPI_SUCCESS;
|
2006-01-28 18:38:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
ompi_osc_pt2pt_module_start(ompi_group_t *group,
|
2006-01-31 05:44:08 +03:00
|
|
|
int assert,
|
|
|
|
ompi_win_t *win)
|
2006-01-28 18:38:37 +03:00
|
|
|
{
|
2006-09-22 00:49:15 +04:00
|
|
|
int i;
|
|
|
|
|
2006-01-31 05:44:08 +03:00
|
|
|
OBJ_RETAIN(group);
|
|
|
|
/* BWB - do I need this? */
|
|
|
|
ompi_group_increment_proc_count(group);
|
2006-02-07 15:16:23 +03:00
|
|
|
|
|
|
|
OPAL_THREAD_LOCK(&(P2P_MODULE(win)->p2p_lock));
|
2006-02-24 16:04:15 +03:00
|
|
|
assert(NULL == P2P_MODULE(win)->p2p_sc_group);
|
2006-02-07 15:16:23 +03:00
|
|
|
P2P_MODULE(win)->p2p_sc_group = group;
|
|
|
|
OPAL_THREAD_UNLOCK(&(P2P_MODULE(win)->p2p_lock));
|
2006-01-31 05:44:08 +03:00
|
|
|
|
2006-11-28 00:41:29 +03:00
|
|
|
memset(P2P_MODULE(win)->p2p_sc_remote_active_ranks, 0,
|
|
|
|
sizeof(bool) * ompi_comm_size(P2P_MODULE(win)->p2p_comm));
|
|
|
|
|
2006-09-22 00:49:15 +04:00
|
|
|
/* for each process in the specified group, find it's rank in our
|
|
|
|
communicator, store those indexes, and set the true / false in
|
|
|
|
the active ranks table */
|
|
|
|
for (i = 0 ; i < ompi_group_size(group) ; i++) {
|
|
|
|
int comm_rank = -1, j;
|
|
|
|
|
|
|
|
/* no need to increment ref count - the communicator isn't
|
|
|
|
going anywhere while we're here */
|
|
|
|
ompi_group_t *comm_group = P2P_MODULE(win)->p2p_comm->c_local_group;
|
|
|
|
|
|
|
|
/* find the rank in the communicator associated with this windows */
|
|
|
|
for (j = 0 ;
|
|
|
|
j < ompi_group_size(comm_group) ;
|
|
|
|
++j) {
|
|
|
|
if (P2P_MODULE(win)->p2p_sc_group->grp_proc_pointers[i] ==
|
|
|
|
comm_group->grp_proc_pointers[j]) {
|
|
|
|
comm_rank = j;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (comm_rank == -1) {
|
|
|
|
return MPI_ERR_RMA_SYNC;
|
|
|
|
}
|
|
|
|
|
|
|
|
P2P_MODULE(win)->p2p_sc_remote_active_ranks[comm_rank] = true;
|
|
|
|
P2P_MODULE(win)->p2p_sc_remote_ranks[i] = comm_rank;
|
|
|
|
}
|
|
|
|
|
2006-01-31 05:44:08 +03:00
|
|
|
/* Set our mode to access w/ start */
|
2006-08-26 00:39:33 +04:00
|
|
|
ompi_win_remove_mode(win, OMPI_WIN_FENCE);
|
|
|
|
ompi_win_append_mode(win, OMPI_WIN_ACCESS_EPOCH | OMPI_WIN_STARTED);
|
2006-01-31 05:44:08 +03:00
|
|
|
|
|
|
|
/* possible we've already received a couple in messages, so
|
|
|
|
atomicall add however many we're going to wait for */
|
2006-09-21 23:57:57 +04:00
|
|
|
OPAL_THREAD_ADD32(&(P2P_MODULE(win)->p2p_num_post_msgs),
|
2006-02-07 15:16:23 +03:00
|
|
|
ompi_group_size(P2P_MODULE(win)->p2p_sc_group));
|
2006-01-31 05:44:08 +03:00
|
|
|
|
|
|
|
return OMPI_SUCCESS;
|
2006-01-28 18:38:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
ompi_osc_pt2pt_module_complete(ompi_win_t *win)
|
|
|
|
{
|
2006-01-31 05:44:08 +03:00
|
|
|
int i;
|
|
|
|
int ret = OMPI_SUCCESS;
|
2006-02-07 15:16:23 +03:00
|
|
|
ompi_group_t *group;
|
|
|
|
opal_list_item_t *item;
|
2006-01-31 05:44:08 +03:00
|
|
|
|
|
|
|
/* wait for all the post messages */
|
2006-09-21 23:57:57 +04:00
|
|
|
while (0 != P2P_MODULE(win)->p2p_num_post_msgs) {
|
2006-08-03 04:10:19 +04:00
|
|
|
ompi_osc_pt2pt_progress_long(P2P_MODULE(win));
|
2006-01-31 05:44:08 +03:00
|
|
|
}
|
|
|
|
|
2006-02-07 15:16:23 +03:00
|
|
|
ompi_osc_pt2pt_flip_sendreqs(P2P_MODULE(win));
|
|
|
|
|
2006-01-31 05:44:08 +03:00
|
|
|
/* for each process in group, send a control message with number
|
|
|
|
of updates coming, then start all the requests */
|
2006-02-07 15:16:23 +03:00
|
|
|
for (i = 0 ; i < ompi_group_size(P2P_MODULE(win)->p2p_sc_group) ; ++i) {
|
2006-09-22 00:49:15 +04:00
|
|
|
int comm_rank = P2P_MODULE(win)->p2p_sc_remote_ranks[i];
|
2006-01-31 05:44:08 +03:00
|
|
|
|
2006-02-07 15:16:23 +03:00
|
|
|
OPAL_THREAD_ADD32(&(P2P_MODULE(win)->p2p_num_pending_out),
|
|
|
|
P2P_MODULE(win)->p2p_copy_num_pending_sendreqs[comm_rank]);
|
2006-11-28 00:41:29 +03:00
|
|
|
ret = ompi_osc_pt2pt_control_send(P2P_MODULE(win),
|
|
|
|
P2P_MODULE(win)->p2p_sc_group->grp_proc_pointers[i],
|
|
|
|
OMPI_OSC_PT2PT_HDR_COMPLETE,
|
|
|
|
P2P_MODULE(win)->p2p_copy_num_pending_sendreqs[comm_rank],
|
|
|
|
0);
|
|
|
|
assert(ret == OMPI_SUCCESS);
|
2006-02-07 15:16:23 +03:00
|
|
|
}
|
2006-01-31 05:44:08 +03:00
|
|
|
|
2006-02-07 15:16:23 +03:00
|
|
|
/* try to start all the requests. We've copied everything we
|
|
|
|
need out of pending_sendreqs, so don't need the lock
|
|
|
|
here */
|
|
|
|
while (NULL !=
|
|
|
|
(item = opal_list_remove_first(&(P2P_MODULE(win)->p2p_copy_pending_sendreqs)))) {
|
|
|
|
ompi_osc_pt2pt_sendreq_t *req =
|
|
|
|
(ompi_osc_pt2pt_sendreq_t*) item;
|
2006-01-31 05:44:08 +03:00
|
|
|
|
2006-02-07 15:16:23 +03:00
|
|
|
ret = ompi_osc_pt2pt_sendreq_send(P2P_MODULE(win), req);
|
2006-01-31 05:44:08 +03:00
|
|
|
|
2006-02-07 15:16:23 +03:00
|
|
|
if (OMPI_SUCCESS != ret) {
|
2006-08-17 18:52:20 +04:00
|
|
|
opal_output_verbose(5, ompi_osc_base_output,
|
|
|
|
"complete: failure in starting sendreq (%d). Will try later.",
|
|
|
|
ret);
|
2006-02-07 21:45:18 +03:00
|
|
|
opal_list_append(&(P2P_MODULE(win)->p2p_copy_pending_sendreqs), item);
|
2006-01-31 05:44:08 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* wait for all the requests */
|
|
|
|
while (0 != P2P_MODULE(win)->p2p_num_pending_out) {
|
2006-08-03 04:10:19 +04:00
|
|
|
ompi_osc_pt2pt_progress_long(P2P_MODULE(win));
|
2006-01-31 05:44:08 +03:00
|
|
|
}
|
|
|
|
|
2006-08-26 00:39:33 +04:00
|
|
|
/* remove WIN_POSTED from our mode */
|
|
|
|
ompi_win_remove_mode(win, OMPI_WIN_ACCESS_EPOCH | OMPI_WIN_STARTED);
|
2006-01-31 05:44:08 +03:00
|
|
|
|
2006-02-07 15:16:23 +03:00
|
|
|
OPAL_THREAD_LOCK(&(P2P_MODULE(win)->p2p_lock));
|
2006-02-23 05:42:39 +03:00
|
|
|
group = P2P_MODULE(win)->p2p_sc_group;
|
|
|
|
P2P_MODULE(win)->p2p_sc_group = NULL;
|
2006-01-31 05:44:08 +03:00
|
|
|
OPAL_THREAD_UNLOCK(&(P2P_MODULE(win)->p2p_lock));
|
|
|
|
|
2006-02-07 15:16:23 +03:00
|
|
|
/* BWB - do I need this? */
|
|
|
|
ompi_group_decrement_proc_count(group);
|
|
|
|
OBJ_RELEASE(group);
|
|
|
|
|
2006-01-31 05:44:08 +03:00
|
|
|
return ret;
|
2006-01-28 18:38:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
ompi_osc_pt2pt_module_post(ompi_group_t *group,
|
2006-01-31 05:44:08 +03:00
|
|
|
int assert,
|
|
|
|
ompi_win_t *win)
|
2006-01-28 18:38:37 +03:00
|
|
|
{
|
2006-01-31 05:44:08 +03:00
|
|
|
int i;
|
|
|
|
|
|
|
|
OBJ_RETAIN(group);
|
|
|
|
/* BWB - do I need this? */
|
|
|
|
ompi_group_increment_proc_count(group);
|
2006-02-07 15:16:23 +03:00
|
|
|
|
|
|
|
OPAL_THREAD_LOCK(&(P2P_MODULE(win)->p2p_lock));
|
2006-02-24 16:04:15 +03:00
|
|
|
assert(NULL == P2P_MODULE(win)->p2p_pw_group);
|
2006-02-07 15:16:23 +03:00
|
|
|
P2P_MODULE(win)->p2p_pw_group = group;
|
|
|
|
OPAL_THREAD_UNLOCK(&(P2P_MODULE(win)->p2p_lock));
|
2006-01-31 05:44:08 +03:00
|
|
|
|
|
|
|
/* Set our mode to expose w/ post */
|
2006-08-26 00:39:33 +04:00
|
|
|
ompi_win_remove_mode(win, OMPI_WIN_FENCE);
|
2006-11-27 06:22:44 +03:00
|
|
|
ompi_win_append_mode(win, OMPI_WIN_EXPOSE_EPOCH | OMPI_WIN_POSTED);
|
2006-01-31 05:44:08 +03:00
|
|
|
|
|
|
|
/* list how many complete counters we're still waiting on */
|
2006-09-21 23:57:57 +04:00
|
|
|
OPAL_THREAD_ADD32(&(P2P_MODULE(win)->p2p_num_complete_msgs),
|
2006-02-07 15:16:23 +03:00
|
|
|
ompi_group_size(P2P_MODULE(win)->p2p_pw_group));
|
2006-01-31 05:44:08 +03:00
|
|
|
|
|
|
|
/* send a hello counter to everyone in group */
|
2006-02-07 15:16:23 +03:00
|
|
|
for (i = 0 ; i < ompi_group_size(P2P_MODULE(win)->p2p_pw_group) ; ++i) {
|
2006-01-31 05:44:08 +03:00
|
|
|
ompi_osc_pt2pt_control_send(P2P_MODULE(win),
|
|
|
|
group->grp_proc_pointers[i],
|
2006-02-07 21:45:18 +03:00
|
|
|
OMPI_OSC_PT2PT_HDR_POST, 1, 0);
|
2006-01-31 05:44:08 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return OMPI_SUCCESS;
|
2006-01-28 18:38:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
ompi_osc_pt2pt_module_wait(ompi_win_t *win)
|
|
|
|
{
|
2006-02-07 15:16:23 +03:00
|
|
|
ompi_group_t *group;
|
|
|
|
|
2006-01-31 05:44:08 +03:00
|
|
|
while (0 != (P2P_MODULE(win)->p2p_num_pending_in) ||
|
2006-09-21 23:57:57 +04:00
|
|
|
0 != (P2P_MODULE(win)->p2p_num_complete_msgs)) {
|
2006-08-03 04:10:19 +04:00
|
|
|
ompi_osc_pt2pt_progress_long(P2P_MODULE(win));
|
2006-01-31 05:44:08 +03:00
|
|
|
}
|
|
|
|
|
2006-08-26 00:39:33 +04:00
|
|
|
ompi_win_remove_mode(win, OMPI_WIN_EXPOSE_EPOCH | OMPI_WIN_POSTED);
|
2006-01-31 05:44:08 +03:00
|
|
|
|
2006-02-07 15:16:23 +03:00
|
|
|
OPAL_THREAD_LOCK(&(P2P_MODULE(win)->p2p_lock));
|
|
|
|
group = P2P_MODULE(win)->p2p_pw_group;
|
|
|
|
P2P_MODULE(win)->p2p_pw_group = NULL;
|
2006-01-31 05:44:08 +03:00
|
|
|
OPAL_THREAD_UNLOCK(&(P2P_MODULE(win)->p2p_lock));
|
|
|
|
|
2006-02-07 15:16:23 +03:00
|
|
|
/* BWB - do I need this? */
|
|
|
|
ompi_group_decrement_proc_count(group);
|
|
|
|
OBJ_RELEASE(group);
|
|
|
|
|
2006-01-31 05:44:08 +03:00
|
|
|
return OMPI_SUCCESS;
|
2006-01-28 18:38:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
ompi_osc_pt2pt_module_test(ompi_win_t *win,
|
2006-01-31 05:44:08 +03:00
|
|
|
int *flag)
|
2006-01-28 18:38:37 +03:00
|
|
|
{
|
2006-02-07 15:16:23 +03:00
|
|
|
ompi_group_t *group;
|
|
|
|
|
2006-01-31 05:44:08 +03:00
|
|
|
if (0 != (P2P_MODULE(win)->p2p_num_pending_in) ||
|
2006-09-21 23:57:57 +04:00
|
|
|
0 != (P2P_MODULE(win)->p2p_num_complete_msgs)) {
|
2006-08-03 04:10:19 +04:00
|
|
|
ompi_osc_pt2pt_progress_long(P2P_MODULE(win));
|
2006-01-31 05:44:08 +03:00
|
|
|
if (0 != (P2P_MODULE(win)->p2p_num_pending_in) ||
|
2006-09-21 23:57:57 +04:00
|
|
|
0 != (P2P_MODULE(win)->p2p_num_complete_msgs)) {
|
2006-01-31 05:44:08 +03:00
|
|
|
*flag = 0;
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*flag = 1;
|
|
|
|
|
2006-08-26 00:39:33 +04:00
|
|
|
ompi_win_remove_mode(win, OMPI_WIN_EXPOSE_EPOCH | OMPI_WIN_POSTED);
|
2006-01-31 05:44:08 +03:00
|
|
|
|
2006-02-07 15:16:23 +03:00
|
|
|
OPAL_THREAD_LOCK(&(P2P_MODULE(win)->p2p_lock));
|
|
|
|
group = P2P_MODULE(win)->p2p_pw_group;
|
|
|
|
P2P_MODULE(win)->p2p_pw_group = NULL;
|
2006-01-31 05:44:08 +03:00
|
|
|
OPAL_THREAD_UNLOCK(&(P2P_MODULE(win)->p2p_lock));
|
|
|
|
|
2006-02-07 15:16:23 +03:00
|
|
|
/* BWB - do I need this? */
|
|
|
|
ompi_group_decrement_proc_count(group);
|
|
|
|
OBJ_RELEASE(group);
|
|
|
|
|
2006-01-31 05:44:08 +03:00
|
|
|
return OMPI_SUCCESS;
|
2006-01-28 18:38:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-02-07 21:45:18 +03:00
|
|
|
struct ompi_osc_pt2pt_pending_lock_t {
|
|
|
|
opal_list_item_t super;
|
|
|
|
ompi_proc_t *proc;
|
|
|
|
int32_t lock_type;
|
|
|
|
};
|
|
|
|
typedef struct ompi_osc_pt2pt_pending_lock_t ompi_osc_pt2pt_pending_lock_t;
|
|
|
|
OBJ_CLASS_INSTANCE(ompi_osc_pt2pt_pending_lock_t, opal_list_item_t,
|
|
|
|
NULL, NULL);
|
|
|
|
|
|
|
|
|
2006-01-28 18:38:37 +03:00
|
|
|
int
|
|
|
|
ompi_osc_pt2pt_module_lock(int lock_type,
|
2006-02-01 00:40:12 +03:00
|
|
|
int target,
|
|
|
|
int assert,
|
|
|
|
ompi_win_t *win)
|
2006-01-28 18:38:37 +03:00
|
|
|
{
|
2006-09-21 02:14:46 +04:00
|
|
|
ompi_proc_t *proc = ompi_comm_peer_lookup( P2P_MODULE(win)->p2p_comm, target );
|
2006-02-07 21:45:18 +03:00
|
|
|
|
|
|
|
assert(lock_type != 0);
|
|
|
|
|
|
|
|
/* set our mode on the window */
|
2006-10-13 02:52:13 +04:00
|
|
|
ompi_win_remove_mode(win, OMPI_WIN_FENCE);
|
|
|
|
ompi_win_append_mode(win, OMPI_WIN_ACCESS_EPOCH | OMPI_WIN_LOCK_ACCESS);
|
2006-02-07 21:45:18 +03:00
|
|
|
|
2006-08-17 18:52:20 +04:00
|
|
|
opal_output_verbose(50, ompi_osc_base_output,
|
|
|
|
"%d sending lock request to %d",
|
|
|
|
P2P_MODULE(win)->p2p_comm->c_my_rank, target);
|
2006-02-07 21:45:18 +03:00
|
|
|
/* generate a lock request */
|
|
|
|
ompi_osc_pt2pt_control_send(P2P_MODULE(win),
|
|
|
|
proc,
|
|
|
|
OMPI_OSC_PT2PT_HDR_LOCK_REQ,
|
|
|
|
P2P_MODULE(win)->p2p_comm->c_my_rank,
|
|
|
|
lock_type);
|
|
|
|
|
|
|
|
/* return */
|
|
|
|
return OMPI_SUCCESS;
|
2006-01-28 18:38:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
ompi_osc_pt2pt_module_unlock(int target,
|
2006-02-01 00:40:12 +03:00
|
|
|
ompi_win_t *win)
|
2006-01-28 18:38:37 +03:00
|
|
|
{
|
2006-02-07 21:45:18 +03:00
|
|
|
int32_t out_count;
|
|
|
|
opal_list_item_t *item;
|
|
|
|
int ret;
|
2006-09-21 02:14:46 +04:00
|
|
|
ompi_proc_t *proc = ompi_comm_peer_lookup( P2P_MODULE(win)->p2p_comm, target );
|
2006-02-07 21:45:18 +03:00
|
|
|
|
|
|
|
while (0 == P2P_MODULE(win)->p2p_lock_received_ack) {
|
2006-08-03 04:10:19 +04:00
|
|
|
ompi_osc_pt2pt_progress_long(P2P_MODULE(win));
|
2006-02-07 21:45:18 +03:00
|
|
|
}
|
|
|
|
P2P_MODULE(win)->p2p_lock_received_ack = 0;
|
|
|
|
|
|
|
|
/* start all the requests */
|
|
|
|
ompi_osc_pt2pt_flip_sendreqs(P2P_MODULE(win));
|
|
|
|
|
|
|
|
/* try to start all the requests. We've copied everything we need
|
|
|
|
out of pending_sendreqs, so don't need the lock here */
|
|
|
|
out_count = opal_list_get_size(&(P2P_MODULE(win)->p2p_copy_pending_sendreqs));
|
|
|
|
|
Send the unlock request before starting the requests. We won't unlock until we get an ack from the remote side,
so there's no longer a race there (I used to do the unlock request last, after local completion of all the
requests completed, to try to avoid having the passive side reply to the active side, but I don't do that
anymore). The unlock side will not "unlock" the window until it actually receives the correct number of results,
so we're good there.
This fixes an issue where we would receive data on the remote side we weren't expecting that could cause
us to release a lock before it really should have been released to the requesting peer. It could also
cause a deadlock if one of the processes trying to unlock was "self", as that would result in the active
unlock never sending the unlock request, even though it sent the payload, which could cause a counter
that should always be positive to hit -1, causing an infinite loop that could only be solved by
popping up the stack, which was an impossibility.
Refs trac:785
This commit was SVN r13160.
The following Trac tickets were found above:
Ticket 785 --> https://svn.open-mpi.org/trac/ompi/ticket/785
2007-01-18 00:13:12 +03:00
|
|
|
/* we want to send all the requests, plus we wait for one more
|
|
|
|
completion event for the control message ack from the unlocker
|
|
|
|
saying we're done */
|
|
|
|
OPAL_THREAD_ADD32(&(P2P_MODULE(win)->p2p_num_pending_out), out_count + 1);
|
|
|
|
|
|
|
|
/* send the unlock request */
|
|
|
|
opal_output_verbose(50, ompi_osc_base_output,
|
|
|
|
"%d sending unlock request to %d",
|
|
|
|
P2P_MODULE(win)->p2p_comm->c_my_rank, target);
|
|
|
|
ompi_osc_pt2pt_control_send(P2P_MODULE(win),
|
|
|
|
proc,
|
|
|
|
OMPI_OSC_PT2PT_HDR_UNLOCK_REQ,
|
|
|
|
P2P_MODULE(win)->p2p_comm->c_my_rank,
|
|
|
|
out_count);
|
2006-02-07 21:45:18 +03:00
|
|
|
|
|
|
|
while (NULL !=
|
|
|
|
(item = opal_list_remove_first(&(P2P_MODULE(win)->p2p_copy_pending_sendreqs)))) {
|
|
|
|
ompi_osc_pt2pt_sendreq_t *req =
|
|
|
|
(ompi_osc_pt2pt_sendreq_t*) item;
|
|
|
|
|
|
|
|
ret = ompi_osc_pt2pt_sendreq_send(P2P_MODULE(win), req);
|
|
|
|
|
|
|
|
if (OMPI_SUCCESS != ret) {
|
2006-08-17 18:52:20 +04:00
|
|
|
opal_output_verbose(5, ompi_osc_base_output,
|
|
|
|
"unlock: failure in starting sendreq (%d). Will try later.",
|
|
|
|
ret);
|
2006-02-07 21:45:18 +03:00
|
|
|
opal_list_append(&(P2P_MODULE(win)->p2p_copy_pending_sendreqs), item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* wait for all the requests */
|
|
|
|
while (0 != P2P_MODULE(win)->p2p_num_pending_out) {
|
2006-08-03 04:10:19 +04:00
|
|
|
ompi_osc_pt2pt_progress_long(P2P_MODULE(win));
|
2006-02-07 21:45:18 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* set our mode on the window */
|
2006-10-13 02:52:13 +04:00
|
|
|
ompi_win_remove_mode(win, OMPI_WIN_ACCESS_EPOCH | OMPI_WIN_LOCK_ACCESS);
|
2006-02-07 21:45:18 +03:00
|
|
|
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
ompi_osc_pt2pt_passive_lock(ompi_osc_pt2pt_module_t *module,
|
|
|
|
int32_t origin,
|
|
|
|
int32_t lock_type)
|
|
|
|
{
|
|
|
|
bool send_ack = false;
|
|
|
|
int ret = OMPI_SUCCESS;
|
2006-09-21 02:14:46 +04:00
|
|
|
ompi_proc_t *proc = ompi_comm_peer_lookup( module->p2p_comm, origin );
|
2006-02-07 21:45:18 +03:00
|
|
|
ompi_osc_pt2pt_pending_lock_t *new_pending;
|
|
|
|
|
|
|
|
OPAL_THREAD_LOCK(&(module->p2p_lock));
|
|
|
|
if (lock_type == MPI_LOCK_EXCLUSIVE) {
|
|
|
|
if (module->p2p_lock_status == 0) {
|
|
|
|
module->p2p_lock_status = MPI_LOCK_EXCLUSIVE;
|
2006-10-13 02:52:13 +04:00
|
|
|
ompi_win_append_mode(module->p2p_win, OMPI_WIN_EXPOSE_EPOCH);
|
2006-02-07 21:45:18 +03:00
|
|
|
send_ack = true;
|
|
|
|
} else {
|
2006-08-17 18:52:20 +04:00
|
|
|
opal_output_verbose(50, ompi_osc_base_output,
|
|
|
|
"%d queuing lock request from %d (%d)",
|
|
|
|
module->p2p_comm->c_my_rank, origin, lock_type);
|
2006-02-07 21:45:18 +03:00
|
|
|
new_pending = OBJ_NEW(ompi_osc_pt2pt_pending_lock_t);
|
|
|
|
new_pending->proc = proc;
|
|
|
|
new_pending->lock_type = lock_type;
|
|
|
|
opal_list_append(&(module->p2p_locks_pending), &(new_pending->super));
|
|
|
|
}
|
|
|
|
} else if (lock_type == MPI_LOCK_SHARED) {
|
|
|
|
if (module->p2p_lock_status != MPI_LOCK_EXCLUSIVE) {
|
|
|
|
module->p2p_lock_status = MPI_LOCK_SHARED;
|
|
|
|
module->p2p_shared_count++;
|
2006-10-13 02:52:13 +04:00
|
|
|
ompi_win_append_mode(module->p2p_win, OMPI_WIN_EXPOSE_EPOCH);
|
2006-02-07 21:45:18 +03:00
|
|
|
send_ack = true;
|
|
|
|
} else {
|
2006-08-17 18:52:20 +04:00
|
|
|
opal_output_verbose(50, ompi_osc_base_output,
|
2007-01-30 23:56:31 +03:00
|
|
|
"queuing lock request from %d (%d) lock_type:%d",
|
2006-08-17 18:52:20 +04:00
|
|
|
module->p2p_comm->c_my_rank, origin, lock_type);
|
2006-02-07 21:45:18 +03:00
|
|
|
new_pending = OBJ_NEW(ompi_osc_pt2pt_pending_lock_t);
|
|
|
|
new_pending->proc = proc;
|
|
|
|
new_pending->lock_type = lock_type;
|
|
|
|
opal_list_append(&(module->p2p_locks_pending), &(new_pending->super));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ret = OMPI_ERROR;
|
|
|
|
}
|
|
|
|
OPAL_THREAD_UNLOCK(&(module->p2p_lock));
|
|
|
|
|
|
|
|
if (send_ack) {
|
2006-08-17 18:52:20 +04:00
|
|
|
opal_output_verbose(50, ompi_osc_base_output,
|
|
|
|
"%d sending lock ack to %d",
|
|
|
|
module->p2p_comm->c_my_rank, origin);
|
2006-02-07 21:45:18 +03:00
|
|
|
ompi_osc_pt2pt_control_send(module, proc,
|
|
|
|
OMPI_OSC_PT2PT_HDR_LOCK_REQ,
|
|
|
|
module->p2p_comm->c_my_rank,
|
|
|
|
OMPI_SUCCESS);
|
|
|
|
}
|
|
|
|
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
ompi_osc_pt2pt_passive_unlock(ompi_osc_pt2pt_module_t *module,
|
|
|
|
int32_t origin,
|
|
|
|
int32_t count)
|
|
|
|
{
|
|
|
|
ompi_osc_pt2pt_pending_lock_t *new_pending = NULL;
|
2007-01-15 01:08:38 +03:00
|
|
|
ompi_proc_t *proc = ompi_comm_peer_lookup( module->p2p_comm, origin );
|
2006-02-07 21:45:18 +03:00
|
|
|
|
|
|
|
assert(module->p2p_lock_status != 0);
|
|
|
|
|
|
|
|
OPAL_THREAD_ADD32(&(module->p2p_num_pending_in), count);
|
|
|
|
|
|
|
|
while (0 != module->p2p_num_pending_in) {
|
2006-08-03 04:10:19 +04:00
|
|
|
ompi_osc_pt2pt_progress_long(module);
|
2006-02-07 21:45:18 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
OPAL_THREAD_LOCK(&(module->p2p_lock));
|
|
|
|
if (module->p2p_lock_status == MPI_LOCK_EXCLUSIVE) {
|
2006-10-13 02:52:13 +04:00
|
|
|
ompi_win_remove_mode(module->p2p_win, OMPI_WIN_EXPOSE_EPOCH);
|
2006-02-07 21:45:18 +03:00
|
|
|
module->p2p_lock_status = 0;
|
|
|
|
} else {
|
|
|
|
module->p2p_shared_count--;
|
|
|
|
if (module->p2p_shared_count == 0) {
|
2006-10-13 02:52:13 +04:00
|
|
|
ompi_win_remove_mode(module->p2p_win, OMPI_WIN_EXPOSE_EPOCH);
|
2006-02-07 21:45:18 +03:00
|
|
|
module->p2p_lock_status = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-15 01:08:38 +03:00
|
|
|
ompi_osc_pt2pt_control_send(module, proc,
|
|
|
|
OMPI_OSC_PT2PT_HDR_UNLOCK_REPLY,
|
|
|
|
OMPI_SUCCESS, OMPI_SUCCESS);
|
|
|
|
|
2006-02-07 21:45:18 +03:00
|
|
|
/* if we were really unlocked, see if we have more to process */
|
|
|
|
new_pending = (ompi_osc_pt2pt_pending_lock_t*)
|
|
|
|
opal_list_remove_first(&(module->p2p_locks_pending));
|
|
|
|
OPAL_THREAD_UNLOCK(&(module->p2p_lock));
|
|
|
|
|
|
|
|
if (NULL != new_pending) {
|
2006-08-17 18:52:20 +04:00
|
|
|
opal_output_verbose(50, ompi_osc_base_output,
|
|
|
|
"sending lock request to proc");
|
2006-10-13 02:52:13 +04:00
|
|
|
ompi_win_append_mode(module->p2p_win, OMPI_WIN_EXPOSE_EPOCH);
|
2006-02-21 21:43:28 +03:00
|
|
|
/* set lock state and generate a lock request */
|
|
|
|
module->p2p_lock_status = new_pending->lock_type;
|
2006-02-07 21:45:18 +03:00
|
|
|
ompi_osc_pt2pt_control_send(module,
|
|
|
|
new_pending->proc,
|
|
|
|
OMPI_OSC_PT2PT_HDR_LOCK_REQ,
|
|
|
|
module->p2p_comm->c_my_rank,
|
2006-02-21 21:43:28 +03:00
|
|
|
OMPI_SUCCESS);
|
|
|
|
OBJ_DESTRUCT(new_pending);
|
2006-02-07 21:45:18 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return OMPI_SUCCESS;
|
2006-01-28 18:38:37 +03:00
|
|
|
}
|