2004-11-22 00:37:56 +00:00
|
|
|
/*
|
2005-11-05 19:57:48 +00:00
|
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
|
|
* University Research and Technology
|
|
|
|
* Corporation. All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The University of Tennessee and The University
|
|
|
|
* of Tennessee Research Foundation. All rights
|
|
|
|
* reserved.
|
2004-11-28 20:09:25 +00:00
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
|
|
* University of Stuttgart. All rights reserved.
|
2005-03-24 12:43:37 +00:00
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
2004-11-22 01:38:40 +00:00
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
2004-11-22 00:37:56 +00:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
2004-11-20 19:12:43 +00:00
|
|
|
#include "ompi_config.h"
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "include/constants.h"
|
2005-10-31 16:21:51 +00:00
|
|
|
#include "opal/threads/condition.h"
|
2005-07-03 23:31:27 +00:00
|
|
|
#include "opal/util/output.h"
|
2004-11-20 19:12:43 +00:00
|
|
|
#include "util/proc_info.h"
|
2005-09-01 01:07:30 +00:00
|
|
|
#include "orte/dps/dps.h"
|
2004-11-20 19:12:43 +00:00
|
|
|
#include "mca/oob/oob.h"
|
|
|
|
#include "mca/oob/base/base.h"
|
2005-03-14 20:57:21 +00:00
|
|
|
#include "mca/ns/ns.h"
|
|
|
|
#include "mca/gpr/gpr.h"
|
|
|
|
#include "mca/errmgr/errmgr.h"
|
2005-03-28 20:54:45 +00:00
|
|
|
#include "mca/soh/base/base.h"
|
2005-03-14 20:57:21 +00:00
|
|
|
#include "runtime/runtime.h"
|
2004-11-20 19:12:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A "broadcast-like" function over the specified set of peers.
|
|
|
|
* @param root The process acting as the root of the broadcast.
|
|
|
|
* @param peers The list of processes receiving the broadcast (excluding root).
|
|
|
|
* @param buffer The data to broadcast - only significant at root.
|
|
|
|
* @param cbfunc Callback function on receipt of data - not significant at root.
|
|
|
|
*
|
|
|
|
* Note that the callback function is provided so that the data can be
|
|
|
|
* received and interpreted by the application prior to the broadcast
|
|
|
|
* continuing to forward data along the distribution tree.
|
|
|
|
*/
|
2005-10-31 16:21:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
struct mca_oob_xcast_t {
|
|
|
|
opal_object_t super;
|
|
|
|
opal_mutex_t mutex;
|
|
|
|
opal_condition_t cond;
|
|
|
|
size_t counter;
|
|
|
|
};
|
|
|
|
typedef struct mca_oob_xcast_t mca_oob_xcast_t;
|
|
|
|
|
|
|
|
static void mca_oob_xcast_construct(mca_oob_xcast_t* xcast)
|
|
|
|
{
|
|
|
|
OBJ_CONSTRUCT(&xcast->mutex, opal_mutex_t);
|
|
|
|
OBJ_CONSTRUCT(&xcast->cond, opal_condition_t);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void mca_oob_xcast_destruct(mca_oob_xcast_t* xcast)
|
|
|
|
{
|
|
|
|
OBJ_DESTRUCT(&xcast->mutex);
|
|
|
|
OBJ_DESTRUCT(&xcast->cond);
|
|
|
|
}
|
|
|
|
|
|
|
|
static OBJ_CLASS_INSTANCE(
|
|
|
|
mca_oob_xcast_t,
|
|
|
|
opal_object_t,
|
|
|
|
mca_oob_xcast_construct,
|
|
|
|
mca_oob_xcast_destruct);
|
|
|
|
|
|
|
|
static void mca_oob_xcast_cb(int status, orte_process_name_t* peer, orte_buffer_t* buffer, int tag, void* cbdata)
|
|
|
|
{
|
|
|
|
mca_oob_xcast_t* xcast = (mca_oob_xcast_t*)cbdata;
|
|
|
|
OPAL_THREAD_LOCK(&xcast->mutex);
|
|
|
|
if(--xcast->counter == 0) {
|
|
|
|
opal_condition_signal(&xcast->cond);
|
|
|
|
}
|
|
|
|
OPAL_THREAD_UNLOCK(&xcast->mutex);
|
|
|
|
}
|
|
|
|
|
2004-11-20 19:12:43 +00:00
|
|
|
|
|
|
|
int mca_oob_xcast(
|
2005-03-14 20:57:21 +00:00
|
|
|
orte_process_name_t* root,
|
|
|
|
orte_process_name_t* peers,
|
|
|
|
size_t num_peers,
|
|
|
|
orte_buffer_t* buffer,
|
2005-09-01 01:07:30 +00:00
|
|
|
orte_gpr_trigger_cb_fn_t cbfunc)
|
2004-11-20 19:12:43 +00:00
|
|
|
{
|
2005-03-14 20:57:21 +00:00
|
|
|
size_t i;
|
2004-11-20 19:12:43 +00:00
|
|
|
int rc;
|
|
|
|
int tag = MCA_OOB_TAG_XCAST;
|
2005-03-14 20:57:21 +00:00
|
|
|
int cmpval;
|
|
|
|
int status;
|
|
|
|
orte_proc_state_t state;
|
|
|
|
|
2004-11-20 19:12:43 +00:00
|
|
|
/* check to see if I am the root process name */
|
2005-03-14 20:57:21 +00:00
|
|
|
cmpval = orte_ns.compare(ORTE_NS_CMP_ALL, root, orte_process_info.my_name);
|
|
|
|
if(NULL != root && 0 == cmpval) {
|
2005-10-31 16:21:51 +00:00
|
|
|
mca_oob_xcast_t *xcast = OBJ_NEW(mca_oob_xcast_t);
|
|
|
|
xcast->counter = num_peers;
|
2005-03-14 20:57:21 +00:00
|
|
|
for(i=0; i<num_peers; i++) {
|
|
|
|
/* check status of peer to ensure they are alive */
|
|
|
|
if (ORTE_SUCCESS != (rc = orte_soh.get_proc_soh(&state, &status, peers+i))) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
2004-11-20 19:12:43 +00:00
|
|
|
return rc;
|
|
|
|
}
|
2005-03-14 20:57:21 +00:00
|
|
|
if (state != ORTE_PROC_STATE_TERMINATED) {
|
2005-10-31 16:21:51 +00:00
|
|
|
rc = mca_oob_send_packed_nb(peers+i, buffer, tag, 0, mca_oob_xcast_cb, xcast);
|
2005-03-14 20:57:21 +00:00
|
|
|
if (rc < 0) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
}
|
2004-11-20 19:12:43 +00:00
|
|
|
}
|
2005-10-31 16:21:51 +00:00
|
|
|
|
|
|
|
/* wait for all non-blocking operations to complete */
|
|
|
|
OPAL_THREAD_LOCK(&xcast->mutex);
|
|
|
|
while(xcast->counter > 0) {
|
|
|
|
opal_condition_wait(&xcast->cond, &xcast->mutex);
|
|
|
|
}
|
|
|
|
OPAL_THREAD_UNLOCK(&xcast->mutex);
|
|
|
|
OBJ_RELEASE(xcast);
|
|
|
|
|
2004-11-20 19:12:43 +00:00
|
|
|
} else {
|
2005-03-14 20:57:21 +00:00
|
|
|
orte_buffer_t rbuf;
|
2005-09-01 01:07:30 +00:00
|
|
|
orte_gpr_notify_message_t *msg;
|
|
|
|
|
2005-03-14 20:57:21 +00:00
|
|
|
OBJ_CONSTRUCT(&rbuf, orte_buffer_t);
|
|
|
|
rc = mca_oob_recv_packed(MCA_OOB_NAME_ANY, &rbuf, tag);
|
2004-11-20 19:12:43 +00:00
|
|
|
if(rc < 0) {
|
2005-03-14 20:57:21 +00:00
|
|
|
OBJ_DESTRUCT(&rbuf);
|
2004-11-20 19:12:43 +00:00
|
|
|
return rc;
|
|
|
|
}
|
2005-09-01 01:07:30 +00:00
|
|
|
if (cbfunc != NULL) {
|
|
|
|
msg = OBJ_NEW(orte_gpr_notify_message_t);
|
|
|
|
if (NULL == msg) {
|
|
|
|
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
|
|
|
|
return ORTE_ERR_OUT_OF_RESOURCE;
|
|
|
|
}
|
|
|
|
i=1;
|
|
|
|
if (ORTE_SUCCESS != (rc = orte_dps.unpack(&rbuf, &msg, &i, ORTE_GPR_NOTIFY_MSG))) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
OBJ_RELEASE(msg);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
cbfunc(msg);
|
|
|
|
OBJ_RELEASE(msg);
|
|
|
|
}
|
2005-03-14 20:57:21 +00:00
|
|
|
OBJ_DESTRUCT(&rbuf);
|
2004-11-20 19:12:43 +00:00
|
|
|
}
|
2005-08-15 18:25:35 +00:00
|
|
|
return ORTE_SUCCESS;
|
2004-11-20 19:12:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|