2004-08-05 20:31:30 +04:00
|
|
|
/*
|
2005-11-05 22:57:48 +03: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.
|
2006-02-07 06:32:36 +03:00
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
2004-11-28 23:09:25 +03:00
|
|
|
* 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$
|
2006-02-07 06:32:36 +03:00
|
|
|
*
|
2004-11-22 04:38:40 +03:00
|
|
|
* Additional copyrights may follow
|
2006-02-07 06:32:36 +03:00
|
|
|
*
|
2004-08-05 20:31:30 +04:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ompi_config.h"
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
2004-10-20 05:03:09 +04:00
|
|
|
#ifdef HAVE_SYS_UIO_H
|
2004-08-05 20:31:30 +04:00
|
|
|
#include <sys/uio.h>
|
2004-10-20 05:03:09 +04:00
|
|
|
#endif
|
2005-05-22 19:46:40 +04:00
|
|
|
#ifdef HAVE_UNISTD_H
|
2005-05-20 04:16:48 +04:00
|
|
|
#include <unistd.h>
|
2005-05-22 19:46:40 +04:00
|
|
|
#endif
|
2004-08-05 20:31:30 +04:00
|
|
|
|
2006-02-08 20:40:11 +03:00
|
|
|
#include "opal/util/printf.h"
|
|
|
|
#include "opal/util/convert.h"
|
|
|
|
#include "opal/threads/mutex.h"
|
|
|
|
#include "opal/util/bit_ops.h"
|
|
|
|
#include "opal/util/argv.h"
|
|
|
|
|
2005-09-13 00:36:04 +04:00
|
|
|
#include "ompi/communicator/communicator.h"
|
|
|
|
#include "ompi/request/request.h"
|
2006-02-12 04:33:29 +03:00
|
|
|
#include "ompi/errhandler/errhandler.h"
|
|
|
|
#include "ompi/proc/proc.h"
|
|
|
|
#include "ompi/info/info.h"
|
|
|
|
#include "ompi/constants.h"
|
2006-02-08 20:40:11 +03:00
|
|
|
#include "ompi/mca/pml/pml.h"
|
2004-08-05 20:31:30 +04:00
|
|
|
|
2006-02-08 20:40:11 +03:00
|
|
|
#include "orte/util/proc_info.h"
|
|
|
|
#include "orte/dss/dss.h"
|
|
|
|
#include "orte/mca/ns/ns.h"
|
|
|
|
#include "orte/mca/gpr/gpr.h"
|
|
|
|
#include "orte/mca/errmgr/errmgr.h"
|
|
|
|
#include "orte/mca/rmgr/rmgr.h"
|
2006-08-10 00:48:51 +04:00
|
|
|
#include "orte/mca/rmgr/base/base.h"
|
2006-02-08 20:40:11 +03:00
|
|
|
#include "orte/mca/soh/soh_types.h"
|
|
|
|
#include "orte/mca/rml/rml.h"
|
2004-08-05 20:31:30 +04:00
|
|
|
|
2006-02-12 04:33:29 +03:00
|
|
|
#include "orte/runtime/runtime.h"
|
2004-09-29 16:41:55 +04:00
|
|
|
|
2005-11-17 11:19:47 +03:00
|
|
|
extern char **environ;
|
|
|
|
|
2004-08-05 20:31:30 +04:00
|
|
|
int ompi_comm_connect_accept ( ompi_communicator_t *comm, int root,
|
2005-03-14 23:57:21 +03:00
|
|
|
orte_process_name_t *port, int send_first,
|
|
|
|
ompi_communicator_t **newcomm, orte_rml_tag_t tag )
|
2004-08-05 20:31:30 +04:00
|
|
|
{
|
2005-04-13 01:59:13 +04:00
|
|
|
int size, rsize, rank, rc;
|
2006-08-15 23:54:10 +04:00
|
|
|
orte_std_cntr_t num_vals;
|
|
|
|
orte_std_cntr_t rnamebuflen = 0;
|
2005-09-29 03:50:42 +04:00
|
|
|
int rnamebuflen_int = 0;
|
2005-04-13 01:59:13 +04:00
|
|
|
void *rnamebuf=NULL;
|
2004-08-05 20:31:30 +04:00
|
|
|
|
|
|
|
ompi_communicator_t *newcomp=MPI_COMM_NULL;
|
|
|
|
ompi_proc_t **rprocs=NULL;
|
|
|
|
ompi_group_t *group=comm->c_local_group;
|
2005-03-14 23:57:21 +03:00
|
|
|
orte_process_name_t *rport=NULL;
|
2005-04-18 22:57:24 +04:00
|
|
|
orte_buffer_t *nbuf=NULL, *nrbuf=NULL;
|
2004-08-05 20:31:30 +04:00
|
|
|
|
|
|
|
size = ompi_comm_size ( comm );
|
|
|
|
rank = ompi_comm_rank ( comm );
|
|
|
|
|
2005-09-29 03:50:42 +04:00
|
|
|
/* tell the progress engine to tick the event library more
|
|
|
|
often, to make sure that the OOB messages get sent */
|
|
|
|
opal_progress_event_increment();
|
|
|
|
|
2004-08-05 20:31:30 +04:00
|
|
|
if ( rank == root ) {
|
2006-02-07 06:32:36 +03:00
|
|
|
/* The process receiving first does not have yet the contact
|
2004-08-05 20:31:30 +04:00
|
|
|
information of the remote process. Therefore, we have to
|
|
|
|
exchange that.
|
|
|
|
*/
|
2006-02-07 06:32:36 +03:00
|
|
|
if ( OMPI_COMM_JOIN_TAG != (int)tag ) {
|
|
|
|
rport = ompi_comm_get_rport( port,send_first,
|
2005-09-13 00:36:04 +04:00
|
|
|
group->grp_proc_pointers[rank], tag);
|
2006-02-07 06:32:36 +03:00
|
|
|
} else {
|
|
|
|
rport = port;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Generate the message buffer containing the number of processes and the list of
|
|
|
|
participating processes */
|
|
|
|
nbuf = OBJ_NEW(orte_buffer_t);
|
|
|
|
if (NULL == nbuf) {
|
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ORTE_SUCCESS != (rc = orte_dss.pack(nbuf, &size, 1, ORTE_INT))) {
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
ompi_proc_get_namebuf (group->grp_proc_pointers, size, nbuf);
|
|
|
|
|
|
|
|
nrbuf = OBJ_NEW(orte_buffer_t);
|
|
|
|
if (NULL == nrbuf ) {
|
|
|
|
rc = OMPI_ERROR;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Exchange the number and the list of processes in the groups */
|
|
|
|
if ( send_first ) {
|
|
|
|
rc = orte_rml.send_buffer(rport, nbuf, tag, 0);
|
|
|
|
rc = orte_rml.recv_buffer(rport, nrbuf, tag);
|
|
|
|
} else {
|
|
|
|
rc = orte_rml.recv_buffer(rport, nrbuf, tag);
|
|
|
|
rc = orte_rml.send_buffer(rport, nbuf, tag, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ORTE_SUCCESS != (rc = orte_dss.unload(nrbuf, &rnamebuf, &rnamebuflen))) {
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-09-29 03:50:42 +04:00
|
|
|
/* First convert the size_t to an int so we can cast in the bcast to a void *
|
2006-08-15 23:54:10 +04:00
|
|
|
* if we don't then we will get badness when using big vs little endian
|
|
|
|
* THIS IS NO LONGER REQUIRED AS THE LENGTH IS NOW A STD_CNTR_T, WHICH
|
|
|
|
* CORRELATES TO AN INT32
|
|
|
|
*/
|
|
|
|
rnamebuflen = (int)rnamebuflen;
|
2005-09-29 03:50:42 +04:00
|
|
|
|
2005-04-13 01:59:13 +04:00
|
|
|
/* bcast the buffer-length to all processes in the local comm */
|
2005-09-29 03:50:42 +04:00
|
|
|
rc = comm->c_coll.coll_bcast (&rnamebuflen_int, 1, MPI_INT, root, comm );
|
2004-08-05 20:31:30 +04:00
|
|
|
if ( OMPI_SUCCESS != rc ) {
|
|
|
|
goto exit;
|
|
|
|
}
|
2005-09-29 03:50:42 +04:00
|
|
|
rnamebuflen = (size_t)rnamebuflen_int;
|
2004-08-05 20:31:30 +04:00
|
|
|
|
2005-04-13 01:59:13 +04:00
|
|
|
if ( rank != root ) {
|
2006-02-07 06:32:36 +03:00
|
|
|
/* non root processes need to allocate the buffer manually */
|
|
|
|
rnamebuf = (char *) malloc(rnamebuflen);
|
|
|
|
if ( NULL == rnamebuf ) {
|
|
|
|
rc = OMPI_ERR_OUT_OF_RESOURCE;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* bcast list of processes to all procs in local group
|
2004-08-05 20:31:30 +04:00
|
|
|
and reconstruct the data. Note that proc_get_proclist
|
|
|
|
adds processes, which were not known yet to our
|
|
|
|
process pool.
|
|
|
|
*/
|
2005-09-29 03:50:42 +04:00
|
|
|
rc = comm->c_coll.coll_bcast (rnamebuf, rnamebuflen_int, MPI_BYTE, root, comm );
|
2004-08-05 20:31:30 +04:00
|
|
|
if ( OMPI_SUCCESS != rc ) {
|
2006-02-07 06:32:36 +03:00
|
|
|
goto exit;
|
2005-04-13 01:59:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nrbuf = OBJ_NEW(orte_buffer_t);
|
|
|
|
if (NULL == nrbuf) {
|
2006-02-07 06:32:36 +03:00
|
|
|
goto exit;
|
2005-04-13 01:59:13 +04:00
|
|
|
}
|
2006-02-07 06:32:36 +03:00
|
|
|
if ( ORTE_SUCCESS != ( rc = orte_dss.load(nrbuf, rnamebuf, rnamebuflen))) {
|
|
|
|
goto exit;
|
2005-04-13 01:59:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
num_vals = 1;
|
2006-02-07 06:32:36 +03:00
|
|
|
if (ORTE_SUCCESS != (rc = orte_dss.unpack(nrbuf, &rsize, &num_vals, ORTE_INT))) {
|
|
|
|
goto exit;
|
2004-08-05 20:31:30 +04:00
|
|
|
}
|
2005-04-13 01:59:13 +04:00
|
|
|
|
2004-09-16 14:07:42 +04:00
|
|
|
rc = ompi_proc_get_proclist (nrbuf, rsize, &rprocs);
|
2004-08-05 20:31:30 +04:00
|
|
|
if ( OMPI_SUCCESS != rc ) {
|
2006-02-07 06:32:36 +03:00
|
|
|
goto exit;
|
2004-08-05 20:31:30 +04:00
|
|
|
}
|
2006-02-07 06:32:36 +03:00
|
|
|
|
2005-03-14 23:57:21 +03:00
|
|
|
OBJ_RELEASE(nrbuf);
|
2004-09-16 14:07:42 +04:00
|
|
|
if ( rank == root ) {
|
2006-02-07 06:32:36 +03:00
|
|
|
OBJ_RELEASE(nbuf);
|
2004-09-16 14:07:42 +04:00
|
|
|
}
|
2006-02-07 06:32:36 +03:00
|
|
|
|
2004-08-05 20:31:30 +04:00
|
|
|
/* allocate comm-structure */
|
|
|
|
newcomp = ompi_comm_allocate ( size, rsize );
|
|
|
|
if ( NULL == newcomp ) {
|
2006-02-07 06:32:36 +03:00
|
|
|
rc = OMPI_ERR_OUT_OF_RESOURCE;
|
|
|
|
goto exit;
|
2004-08-05 20:31:30 +04:00
|
|
|
}
|
2006-02-07 06:32:36 +03:00
|
|
|
|
2004-08-05 20:31:30 +04:00
|
|
|
/* allocate comm_cid */
|
|
|
|
rc = ompi_comm_nextcid ( newcomp, /* new communicator */
|
|
|
|
comm, /* old communicator */
|
|
|
|
NULL, /* bridge comm */
|
|
|
|
&root, /* local leader */
|
|
|
|
rport, /* remote leader */
|
|
|
|
OMPI_COMM_CID_INTRA_OOB, /* mode */
|
|
|
|
send_first ); /* send or recv first */
|
|
|
|
if ( OMPI_SUCCESS != rc ) {
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set up communicator structure */
|
|
|
|
rc = ompi_comm_set ( newcomp, /* new comm */
|
|
|
|
comm, /* old comm */
|
|
|
|
group->grp_proc_count, /* local_size */
|
|
|
|
group->grp_proc_pointers, /* local_procs*/
|
|
|
|
rsize, /* remote_size */
|
|
|
|
rprocs, /* remote_procs */
|
|
|
|
NULL, /* attrs */
|
|
|
|
comm->error_handler, /* error handler */
|
|
|
|
NULL /* topo component */
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
/* activate comm and init coll-component */
|
|
|
|
rc = ompi_comm_activate ( newcomp, /* new communicator */
|
|
|
|
comm, /* old communicator */
|
|
|
|
NULL, /* bridge comm */
|
|
|
|
&root, /* local leader */
|
|
|
|
rport, /* remote leader */
|
|
|
|
OMPI_COMM_CID_INTRA_OOB, /* mode */
|
|
|
|
send_first, /* send or recv first */
|
|
|
|
NULL ); /* coll component */
|
|
|
|
if ( OMPI_SUCCESS != rc ) {
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Question: do we have to re-start some low level stuff
|
|
|
|
to enable the usage of fast communication devices
|
2006-02-07 06:32:36 +03:00
|
|
|
between the two worlds ?
|
2004-08-05 20:31:30 +04:00
|
|
|
*/
|
2006-02-07 06:32:36 +03:00
|
|
|
|
|
|
|
|
2004-08-05 20:31:30 +04:00
|
|
|
exit:
|
2005-04-21 18:58:25 +04:00
|
|
|
/* done with OOB and such - slow our tick rate again */
|
2005-07-04 01:57:43 +04:00
|
|
|
opal_progress();
|
|
|
|
opal_progress_event_decrement();
|
2005-04-21 18:58:25 +04:00
|
|
|
|
2004-09-16 14:07:42 +04:00
|
|
|
|
2004-08-05 20:31:30 +04:00
|
|
|
if ( NULL != rprocs ) {
|
|
|
|
free ( rprocs );
|
|
|
|
}
|
|
|
|
if ( OMPI_SUCCESS != rc ) {
|
|
|
|
if ( MPI_COMM_NULL != newcomp ) {
|
|
|
|
OBJ_RETAIN(newcomp);
|
|
|
|
newcomp = MPI_COMM_NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*newcomm = newcomp;
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2004-10-26 15:37:58 +04:00
|
|
|
/**********************************************************************/
|
|
|
|
/**********************************************************************/
|
|
|
|
/**********************************************************************/
|
2004-08-05 20:31:30 +04:00
|
|
|
/*
|
|
|
|
* This routine is necessary, since in the connect/accept case, the processes
|
|
|
|
* executing the connect operation have the OOB contact information of the
|
2006-02-07 06:32:36 +03:00
|
|
|
* leader of the remote group, however, the processes executing the
|
|
|
|
* accept get their own port_name = OOB contact information passed in as
|
2004-08-05 20:31:30 +04:00
|
|
|
* an argument. This is however useless.
|
2006-02-07 06:32:36 +03:00
|
|
|
*
|
2004-08-05 20:31:30 +04:00
|
|
|
* Therefore, the two root processes exchange this information at this point.
|
|
|
|
*
|
|
|
|
*/
|
2006-02-07 06:32:36 +03:00
|
|
|
orte_process_name_t *ompi_comm_get_rport (orte_process_name_t *port, int send_first,
|
2005-03-14 23:57:21 +03:00
|
|
|
ompi_proc_t *proc, orte_rml_tag_t tag)
|
2004-08-05 20:31:30 +04:00
|
|
|
{
|
2004-09-16 14:07:42 +04:00
|
|
|
int rc;
|
2006-08-15 23:54:10 +04:00
|
|
|
orte_std_cntr_t num_vals;
|
2005-03-14 23:57:21 +03:00
|
|
|
orte_process_name_t *rport, tbuf;
|
2004-09-16 14:07:42 +04:00
|
|
|
ompi_proc_t *rproc=NULL;
|
2004-10-25 23:52:37 +04:00
|
|
|
bool isnew = false;
|
2004-08-05 20:31:30 +04:00
|
|
|
|
|
|
|
if ( send_first ) {
|
2005-03-14 23:57:21 +03:00
|
|
|
orte_buffer_t *sbuf;
|
2004-08-05 20:31:30 +04:00
|
|
|
|
2004-10-25 23:52:37 +04:00
|
|
|
rproc = ompi_proc_find_and_add(port, &isnew);
|
2005-03-14 23:57:21 +03:00
|
|
|
sbuf = OBJ_NEW(orte_buffer_t);
|
|
|
|
if (NULL == sbuf) {
|
|
|
|
return NULL;
|
|
|
|
}
|
2006-02-07 06:32:36 +03:00
|
|
|
if (ORTE_SUCCESS != orte_dss.pack(sbuf, &(proc->proc_name), 1, ORTE_NAME)) {
|
2005-03-14 23:57:21 +03:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
rc = orte_rml.send_buffer(port, sbuf, tag, 0);
|
|
|
|
OBJ_RELEASE(sbuf);
|
2004-08-13 02:41:42 +04:00
|
|
|
|
2004-08-05 20:31:30 +04:00
|
|
|
rport = port;
|
|
|
|
}
|
|
|
|
else {
|
2005-03-14 23:57:21 +03:00
|
|
|
orte_buffer_t *rbuf;
|
2004-08-05 20:31:30 +04:00
|
|
|
|
2005-03-14 23:57:21 +03:00
|
|
|
rbuf = OBJ_NEW(orte_buffer_t);
|
|
|
|
if (NULL == rbuf) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
rc = orte_rml.recv_buffer(ORTE_RML_NAME_ANY, rbuf, tag);
|
|
|
|
num_vals = 1;
|
2006-02-07 06:32:36 +03:00
|
|
|
if (ORTE_SUCCESS != orte_dss.unpack(rbuf, &tbuf, &num_vals, ORTE_NAME)) {
|
2005-03-14 23:57:21 +03:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
OBJ_RELEASE(rbuf);
|
2004-10-25 23:52:37 +04:00
|
|
|
rproc = ompi_proc_find_and_add(&tbuf, &isnew);
|
2004-09-16 14:07:42 +04:00
|
|
|
rport = &(rproc->proc_name);
|
2004-10-25 23:52:37 +04:00
|
|
|
|
2004-08-05 20:31:30 +04:00
|
|
|
}
|
2004-12-02 16:28:10 +03:00
|
|
|
if (isnew) {
|
2005-04-13 07:19:48 +04:00
|
|
|
MCA_PML_CALL(add_procs(&rproc, 1));
|
2004-12-02 16:28:10 +03:00
|
|
|
}
|
|
|
|
|
2004-08-05 20:31:30 +04:00
|
|
|
return rport;
|
|
|
|
}
|
2004-09-29 16:41:55 +04:00
|
|
|
|
|
|
|
|
2004-10-26 15:37:58 +04:00
|
|
|
/**********************************************************************/
|
|
|
|
/**********************************************************************/
|
|
|
|
/**********************************************************************/
|
2004-12-16 18:42:02 +03:00
|
|
|
int
|
|
|
|
ompi_comm_start_processes(int count, char **array_of_commands,
|
2006-02-07 06:32:36 +03:00
|
|
|
char ***array_of_argv,
|
|
|
|
int *array_of_maxprocs,
|
|
|
|
MPI_Info *array_of_info,
|
2004-12-16 18:42:02 +03:00
|
|
|
char *port_name)
|
2004-09-29 16:41:55 +04:00
|
|
|
{
|
2006-02-07 06:32:36 +03:00
|
|
|
int rc, i, j, counter;
|
2004-12-23 16:04:58 +03:00
|
|
|
int have_wdir=0;
|
2006-08-10 00:48:51 +04:00
|
|
|
bool have_prefix;
|
2005-04-14 20:05:17 +04:00
|
|
|
int valuelen=OMPI_PATH_MAX, flag=0;
|
|
|
|
char cwd[OMPI_PATH_MAX];
|
2006-07-28 03:45:33 +04:00
|
|
|
char host[OMPI_PATH_MAX]; /*** should define OMPI_HOST_MAX ***/
|
2006-08-10 00:48:51 +04:00
|
|
|
char prefix[OMPI_PATH_MAX];
|
|
|
|
char *base_prefix;
|
2005-04-14 20:05:17 +04:00
|
|
|
|
2006-08-15 23:54:10 +04:00
|
|
|
orte_std_cntr_t num_apps, ai;
|
2005-04-14 20:05:17 +04:00
|
|
|
orte_jobid_t new_jobid;
|
|
|
|
orte_app_context_t **apps=NULL;
|
|
|
|
|
2004-12-07 22:38:42 +03:00
|
|
|
|
2004-09-29 16:41:55 +04:00
|
|
|
/* parse the info object */
|
2006-02-07 06:32:36 +03:00
|
|
|
/* check potentially for:
|
2004-09-29 16:41:55 +04:00
|
|
|
- "host": desired host where to spawn the processes
|
2006-08-10 00:48:51 +04:00
|
|
|
- "prefix": the path to the root of the directory tree where ompi
|
|
|
|
executables and libraries can be found
|
2004-09-29 16:41:55 +04:00
|
|
|
- "arch": desired architecture
|
|
|
|
- "wdir": directory, where executable can be found
|
|
|
|
- "path": list of directories where to look for the executable
|
|
|
|
- "file": filename, where additional information is provided.
|
|
|
|
- "soft": see page 92 of MPI-2.
|
|
|
|
*/
|
|
|
|
|
2005-04-21 18:58:25 +04:00
|
|
|
/* make sure the progress engine properly trips the event library */
|
2005-07-04 01:57:43 +04:00
|
|
|
opal_progress_event_increment();
|
2006-08-10 00:48:51 +04:00
|
|
|
|
|
|
|
/* we want to be able to default the prefix to the one used for this job
|
|
|
|
* so that the ompi executables and libraries can be found. the user can
|
|
|
|
* later override this value by providing an MPI_Info value. for now, though,
|
|
|
|
* let's get the default value off the registry
|
|
|
|
*/
|
|
|
|
if (ORTE_SUCCESS != (rc = orte_rmgr_base_get_app_context(orte_process_info.my_name->jobid, &apps, &num_apps))) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
/* we'll just use the prefix from the first member of the app_context array.
|
|
|
|
* this shouldn't matter as they all should be the same. it could be NULL, of
|
|
|
|
* course (user might not have specified it), so we need to protect against that.
|
|
|
|
*/
|
|
|
|
if (NULL != apps[0]->prefix_dir) {
|
|
|
|
base_prefix = strdup(apps[0]->prefix_dir);
|
|
|
|
} else {
|
|
|
|
base_prefix = NULL;
|
|
|
|
}
|
|
|
|
/* cleanup the memory we used */
|
|
|
|
for (ai = 0; ai < num_apps; ai++) {
|
|
|
|
OBJ_RELEASE(apps[ai]);
|
|
|
|
}
|
|
|
|
if (NULL != apps) free(apps);
|
2004-09-29 16:41:55 +04:00
|
|
|
|
2005-04-11 16:59:43 +04:00
|
|
|
/* Convert the list of commands to an array of orte_app_context_t
|
|
|
|
pointers */
|
|
|
|
apps = (orte_app_context_t**)malloc(count * sizeof(orte_app_context_t *));
|
|
|
|
if (NULL == apps) {
|
|
|
|
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
|
|
|
|
return ORTE_ERR_OUT_OF_RESOURCE;
|
2004-09-29 16:41:55 +04:00
|
|
|
}
|
2005-04-11 16:59:43 +04:00
|
|
|
for (i = 0; i < count; ++i) {
|
|
|
|
apps[i] = OBJ_NEW(orte_app_context_t);
|
|
|
|
if (NULL == apps[i]) {
|
|
|
|
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
|
|
|
|
/* rollback what was already done */
|
|
|
|
for (j=0; j < i; j++) OBJ_RELEASE(apps[j]);
|
2005-07-04 01:57:43 +04:00
|
|
|
opal_progress_event_decrement();
|
2005-04-11 16:59:43 +04:00
|
|
|
return ORTE_ERR_OUT_OF_RESOURCE;
|
2004-12-16 18:42:02 +03:00
|
|
|
}
|
2005-04-11 16:59:43 +04:00
|
|
|
/* copy over the name of the executable */
|
|
|
|
apps[i]->app = strdup(array_of_commands[i]);
|
|
|
|
if (NULL == apps[i]->app) {
|
|
|
|
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
|
|
|
|
/* rollback what was already done */
|
|
|
|
for (j=0; j < i; j++) OBJ_RELEASE(apps[j]);
|
2005-07-04 01:57:43 +04:00
|
|
|
opal_progress_event_decrement();
|
2005-04-11 16:59:43 +04:00
|
|
|
return ORTE_ERR_OUT_OF_RESOURCE;
|
2004-12-16 18:42:02 +03:00
|
|
|
}
|
2005-04-11 16:59:43 +04:00
|
|
|
/* record the number of procs to be generated */
|
|
|
|
apps[i]->num_procs = array_of_maxprocs[i];
|
2005-04-18 22:57:24 +04:00
|
|
|
|
2005-04-11 16:59:43 +04:00
|
|
|
/* copy over the argv array */
|
2006-07-28 19:47:16 +04:00
|
|
|
counter = 1;
|
2005-04-18 22:57:24 +04:00
|
|
|
|
2005-04-11 16:59:43 +04:00
|
|
|
if (MPI_ARGVS_NULL != array_of_argv &&
|
|
|
|
MPI_ARGV_NULL != array_of_argv[i]) {
|
|
|
|
/* first need to find out how many entries there are */
|
|
|
|
j=0;
|
|
|
|
while (NULL != array_of_argv[i][j]) {
|
|
|
|
j++;
|
|
|
|
}
|
2006-02-07 06:32:36 +03:00
|
|
|
counter += j;
|
|
|
|
}
|
2006-07-28 19:47:16 +04:00
|
|
|
|
|
|
|
/* now copy them over, ensuring to NULL terminate the array */
|
|
|
|
apps[i]->argv = (char**)malloc((1 + counter) * sizeof(char*));
|
|
|
|
if (NULL == apps[i]->argv) {
|
|
|
|
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
|
|
|
|
/* rollback what was already done */
|
|
|
|
for (j=0; j < i; j++) {
|
|
|
|
OBJ_RELEASE(apps[j]);
|
|
|
|
}
|
2005-07-04 01:57:43 +04:00
|
|
|
opal_progress_event_decrement();
|
2006-07-28 19:47:16 +04:00
|
|
|
return ORTE_ERR_OUT_OF_RESOURCE;
|
|
|
|
}
|
|
|
|
apps[i]->argv[0] = strdup(array_of_commands[i]);
|
|
|
|
for (j=1; j < counter; j++) {
|
|
|
|
apps[i]->argv[j] = strdup(array_of_argv[i][j-1]);
|
|
|
|
}
|
|
|
|
apps[i]->argv[counter] = NULL;
|
2006-02-07 06:32:36 +03:00
|
|
|
|
|
|
|
|
2005-04-11 16:59:43 +04:00
|
|
|
/* the environment gets set by the launcher
|
|
|
|
* all we need to do is add the specific values
|
|
|
|
* needed for comm_spawn
|
|
|
|
*/
|
2006-02-07 06:32:36 +03:00
|
|
|
/* Add environment variable with the contact information for the
|
|
|
|
child processes.
|
2006-07-28 19:47:16 +04:00
|
|
|
*/
|
2006-02-07 06:32:36 +03:00
|
|
|
counter = 1;
|
|
|
|
apps[i]->env = (char**)malloc((1+counter) * sizeof(char*));
|
2005-04-11 16:59:43 +04:00
|
|
|
if (NULL == apps[i]->env) {
|
|
|
|
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
|
|
|
|
/* rollback what was already done */
|
|
|
|
for (j=0; j < i; j++) OBJ_RELEASE(apps[j]);
|
2005-07-04 01:57:43 +04:00
|
|
|
opal_progress_event_decrement();
|
2005-04-11 16:59:43 +04:00
|
|
|
return ORTE_ERR_OUT_OF_RESOURCE;
|
|
|
|
}
|
2005-04-14 20:28:15 +04:00
|
|
|
asprintf(&(apps[i]->env[0]), "OMPI_PARENT_PORT=%s", port_name);
|
2005-04-11 16:59:43 +04:00
|
|
|
apps[i]->env[1] = NULL;
|
2005-11-17 01:20:33 +03:00
|
|
|
for (j = 0; NULL != environ[j]; ++j) {
|
|
|
|
if (0 == strncmp("OMPI_", environ[j], 5)) {
|
2006-02-07 06:32:36 +03:00
|
|
|
opal_argv_append_nosize(&apps[i]->env, environ[j]);
|
2005-11-17 01:20:33 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-07-28 03:45:33 +04:00
|
|
|
/* Check for well-known info keys */
|
2006-02-07 06:32:36 +03:00
|
|
|
have_wdir = 0;
|
2006-08-10 00:48:51 +04:00
|
|
|
have_prefix = false;
|
2005-04-11 16:59:43 +04:00
|
|
|
if ( array_of_info != NULL && array_of_info[i] != MPI_INFO_NULL ) {
|
2006-07-28 03:45:33 +04:00
|
|
|
|
|
|
|
/* check for 'wdir' */
|
2005-04-11 16:59:43 +04:00
|
|
|
ompi_info_get (array_of_info[i], "wdir", valuelen, cwd, &flag);
|
|
|
|
if ( flag ) {
|
|
|
|
apps[i]->cwd = cwd;
|
|
|
|
have_wdir = 1;
|
|
|
|
}
|
2006-07-28 03:45:33 +04:00
|
|
|
|
|
|
|
/* check for 'host' */
|
|
|
|
ompi_info_get (array_of_info[i], "host", sizeof(host), host, &flag);
|
|
|
|
if ( flag ) {
|
|
|
|
apps[i]->num_map = 1;
|
|
|
|
apps[i]->map_data = (orte_app_context_map_t **) malloc(sizeof(orte_app_context_map_t *));
|
|
|
|
apps[i]->map_data[0] = OBJ_NEW(orte_app_context_map_t);
|
|
|
|
apps[i]->map_data[0]->map_type = ORTE_APP_CONTEXT_MAP_HOSTNAME;
|
|
|
|
apps[i]->map_data[0]->map_data = strdup(host);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 'path', 'arch', 'file', 'soft' -- to be implemented */
|
2006-08-10 00:48:51 +04:00
|
|
|
|
|
|
|
/* check for 'ompi_prefix' (OMPI-specific -- to effect the same
|
|
|
|
* behavior as --prefix option to orterun)
|
|
|
|
*/
|
|
|
|
ompi_info_get (array_of_info[i], "ompi_prefix", sizeof(prefix), prefix, &flag);
|
|
|
|
if ( flag ) {
|
|
|
|
apps[i]->prefix_dir = strdup(prefix);
|
|
|
|
have_prefix = true;
|
|
|
|
}
|
2005-04-11 16:59:43 +04:00
|
|
|
}
|
2006-02-07 06:32:36 +03:00
|
|
|
|
|
|
|
/* default value: If the user did not tell us where to look for the
|
2005-04-11 16:59:43 +04:00
|
|
|
executable, we assume the current working directory */
|
|
|
|
if ( !have_wdir ) {
|
|
|
|
getcwd(cwd, OMPI_PATH_MAX);
|
|
|
|
apps[i]->cwd = strdup(cwd);
|
2004-12-16 18:42:02 +03:00
|
|
|
}
|
2006-08-10 00:48:51 +04:00
|
|
|
|
|
|
|
/* if the user told us a new prefix, then we leave it alone. otherwise, if
|
|
|
|
* a prefix had been provided before, copy that one into the new app_context
|
|
|
|
* for use by the spawned children
|
|
|
|
*/
|
|
|
|
if ( !have_prefix && NULL != base_prefix) {
|
|
|
|
apps[i]->prefix_dir = strdup(base_prefix);
|
|
|
|
}
|
|
|
|
|
2005-04-11 16:59:43 +04:00
|
|
|
/* leave the map info alone - the launcher will
|
|
|
|
* decide where to put things
|
|
|
|
*/
|
2004-12-16 18:42:02 +03:00
|
|
|
} /* for (i = 0 ; i < count ; ++i) */
|
2004-09-29 16:41:55 +04:00
|
|
|
|
2006-08-10 00:48:51 +04:00
|
|
|
/* cleanup */
|
|
|
|
if (NULL != base_prefix) free(base_prefix);
|
2004-09-29 16:41:55 +04:00
|
|
|
|
2005-04-11 16:59:43 +04:00
|
|
|
/* spawn procs */
|
2006-02-08 20:40:11 +03:00
|
|
|
if (ORTE_SUCCESS != (rc = orte_rmgr.spawn(apps, count, &new_jobid, NULL, ORTE_PROC_STATE_NONE))) {
|
2006-02-07 06:32:36 +03:00
|
|
|
ORTE_ERROR_LOG(rc);
|
2005-07-04 01:57:43 +04:00
|
|
|
opal_progress_event_decrement();
|
2005-04-21 18:58:25 +04:00
|
|
|
return MPI_ERR_SPAWN;
|
2004-09-29 16:41:55 +04:00
|
|
|
}
|
2006-02-07 06:32:36 +03:00
|
|
|
|
2005-04-14 20:05:17 +04:00
|
|
|
/* clean up */
|
2005-07-04 01:57:43 +04:00
|
|
|
opal_progress_event_decrement();
|
2005-04-14 20:05:17 +04:00
|
|
|
for ( i=0; i<count; i++) {
|
2006-02-07 06:32:36 +03:00
|
|
|
OBJ_RELEASE(apps[i]);
|
2004-12-16 18:42:02 +03:00
|
|
|
}
|
2005-04-14 20:05:17 +04:00
|
|
|
free (apps);
|
|
|
|
|
2004-09-29 16:41:55 +04:00
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
2006-02-07 06:32:36 +03:00
|
|
|
|
2004-10-26 15:37:58 +04:00
|
|
|
/**********************************************************************/
|
|
|
|
/**********************************************************************/
|
|
|
|
/**********************************************************************/
|
2004-09-29 16:41:55 +04:00
|
|
|
int ompi_comm_dyn_init (void)
|
|
|
|
{
|
2004-10-01 18:06:23 +04:00
|
|
|
char *envvarname=NULL, *port_name=NULL;
|
2004-09-29 16:41:55 +04:00
|
|
|
char *oob_port=NULL;
|
2005-03-14 23:57:21 +03:00
|
|
|
int root=0, send_first=1, rc;
|
|
|
|
orte_rml_tag_t tag;
|
2004-10-01 18:06:23 +04:00
|
|
|
ompi_communicator_t *newcomm=NULL;
|
2005-03-14 23:57:21 +03:00
|
|
|
orte_process_name_t *port_proc_name=NULL;
|
2004-11-05 15:58:14 +03:00
|
|
|
ompi_group_t *group = NULL;
|
|
|
|
ompi_errhandler_t *errhandler = NULL;
|
2004-09-29 16:41:55 +04:00
|
|
|
|
|
|
|
/* check for appropriate env variable */
|
2005-04-14 20:05:17 +04:00
|
|
|
asprintf(&envvarname, "OMPI_PARENT_PORT");
|
2004-09-29 16:41:55 +04:00
|
|
|
port_name = getenv(envvarname);
|
|
|
|
free (envvarname);
|
2006-02-07 06:32:36 +03:00
|
|
|
|
2004-09-29 16:41:55 +04:00
|
|
|
/* if env-variable is set, parse port and call comm_connect_accept */
|
|
|
|
if (NULL != port_name ) {
|
2006-02-07 06:32:36 +03:00
|
|
|
ompi_communicator_t *oldcomm;
|
2004-10-29 22:39:01 +04:00
|
|
|
|
2006-02-07 06:32:36 +03:00
|
|
|
/* split the content of the environment variable into
|
|
|
|
its pieces, which are : port_name and tag */
|
|
|
|
oob_port = ompi_parse_port (port_name, &tag);
|
|
|
|
if (ORTE_SUCCESS != (rc = orte_ns.convert_string_to_process_name(&port_proc_name, oob_port))) {
|
2005-03-14 23:57:21 +03:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2006-02-07 06:32:36 +03:00
|
|
|
rc = ompi_comm_connect_accept (MPI_COMM_WORLD, root, port_proc_name,
|
|
|
|
send_first, &newcomm, tag );
|
2005-09-28 10:13:51 +04:00
|
|
|
if (ORTE_SUCCESS != rc) {
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2006-02-07 06:32:36 +03:00
|
|
|
/* Set the parent communicator */
|
|
|
|
ompi_mpi_comm_parent = newcomm;
|
2004-09-29 16:41:55 +04:00
|
|
|
|
2006-02-07 06:32:36 +03:00
|
|
|
/* originally, we set comm_parent to comm_null (in comm_init),
|
|
|
|
* now we have to decrease the reference counters to the according
|
|
|
|
* objects
|
|
|
|
*/
|
2004-11-05 15:58:14 +03:00
|
|
|
|
2006-02-07 06:32:36 +03:00
|
|
|
oldcomm = &ompi_mpi_comm_null;
|
|
|
|
OBJ_RELEASE(oldcomm);
|
2004-11-05 15:58:14 +03:00
|
|
|
group = &ompi_mpi_group_null;
|
2006-02-07 06:32:36 +03:00
|
|
|
OBJ_RELEASE(group);
|
|
|
|
errhandler = &ompi_mpi_errors_are_fatal;
|
|
|
|
OBJ_RELEASE(errhandler);
|
2004-10-26 21:25:49 +04:00
|
|
|
|
2006-02-07 06:32:36 +03:00
|
|
|
/* Set name for debugging purposes */
|
|
|
|
snprintf(newcomm->c_name, MPI_MAX_OBJECT_NAME, "MPI_COMM_PARENT");
|
2004-09-29 16:41:55 +04:00
|
|
|
}
|
2006-02-07 06:32:36 +03:00
|
|
|
|
2004-09-29 16:41:55 +04:00
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
2004-10-26 15:37:58 +04:00
|
|
|
|
|
|
|
/**********************************************************************/
|
|
|
|
/**********************************************************************/
|
|
|
|
/**********************************************************************/
|
|
|
|
/* this routine runs through the list of communicators and
|
|
|
|
and does the disconnect for all dynamic communicators */
|
2004-10-26 18:54:23 +04:00
|
|
|
int ompi_comm_dyn_finalize (void)
|
2004-10-26 15:37:58 +04:00
|
|
|
{
|
2004-10-26 18:54:23 +04:00
|
|
|
int i,j=0, max=0;
|
|
|
|
ompi_comm_disconnect_obj **objs=NULL;
|
|
|
|
ompi_communicator_t *comm=NULL;
|
|
|
|
|
|
|
|
if ( 1 <ompi_comm_num_dyncomm ) {
|
2006-02-07 06:32:36 +03:00
|
|
|
objs = (ompi_comm_disconnect_obj **)malloc (ompi_comm_num_dyncomm*
|
|
|
|
sizeof(ompi_comm_disconnect_obj*));
|
|
|
|
if ( NULL == objs ) {
|
|
|
|
return OMPI_ERR_OUT_OF_RESOURCE;
|
|
|
|
}
|
|
|
|
|
|
|
|
max = ompi_pointer_array_get_size(&ompi_mpi_communicators);
|
|
|
|
for ( i=3; i<max; i++ ) {
|
|
|
|
comm = (ompi_communicator_t*)ompi_pointer_array_get_item(&ompi_mpi_communicators,i);
|
|
|
|
if ( OMPI_COMM_IS_DYNAMIC(comm)) {
|
|
|
|
objs[j++]=ompi_comm_disconnect_init(comm);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( j != ompi_comm_num_dyncomm+1 ) {
|
|
|
|
free (objs);
|
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
ompi_comm_disconnect_waitall (ompi_comm_num_dyncomm, objs);
|
|
|
|
free (objs);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-26 18:54:23 +04:00
|
|
|
return OMPI_SUCCESS;
|
2004-10-26 15:37:58 +04:00
|
|
|
}
|
2004-10-26 18:54:23 +04:00
|
|
|
|
2004-10-26 15:37:58 +04:00
|
|
|
/**********************************************************************/
|
|
|
|
/**********************************************************************/
|
|
|
|
/**********************************************************************/
|
|
|
|
|
|
|
|
ompi_comm_disconnect_obj *ompi_comm_disconnect_init ( ompi_communicator_t *comm)
|
|
|
|
{
|
|
|
|
ompi_comm_disconnect_obj *obj=NULL;
|
|
|
|
int ret;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
obj = (ompi_comm_disconnect_obj *) calloc(1,sizeof(ompi_comm_disconnect_obj));
|
|
|
|
if ( NULL == obj ) {
|
2006-02-07 06:32:36 +03:00
|
|
|
return NULL;
|
2004-10-26 15:37:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( OMPI_COMM_IS_INTER(comm) ) {
|
2006-02-07 06:32:36 +03:00
|
|
|
obj->size = ompi_comm_remote_size (comm);
|
2004-10-26 15:37:58 +04:00
|
|
|
}
|
|
|
|
else {
|
2006-02-07 06:32:36 +03:00
|
|
|
obj->size = ompi_comm_size (comm);
|
2004-10-26 15:37:58 +04:00
|
|
|
}
|
2006-02-07 06:32:36 +03:00
|
|
|
|
2004-10-26 15:37:58 +04:00
|
|
|
obj->comm = comm;
|
|
|
|
obj->reqs = (ompi_request_t **) malloc(2*obj->size*sizeof(ompi_request_t *));
|
|
|
|
if ( NULL == obj->reqs ) {
|
2006-02-07 06:32:36 +03:00
|
|
|
free (obj);
|
|
|
|
return NULL;
|
2004-10-26 15:37:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* initiate all isend_irecvs. We use a dummy buffer stored on
|
|
|
|
the object, since we are sending zero size messages anyway. */
|
|
|
|
for ( i=0; i < obj->size; i++ ) {
|
2006-02-07 06:32:36 +03:00
|
|
|
ret = MCA_PML_CALL(irecv (&(obj->buf), 0, MPI_INT, i,
|
|
|
|
OMPI_COMM_BARRIER_TAG, comm,
|
|
|
|
&(obj->reqs[2*i])));
|
|
|
|
|
|
|
|
if ( OMPI_SUCCESS != ret ) {
|
|
|
|
free (obj->reqs);
|
|
|
|
free (obj);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = MCA_PML_CALL(isend (&(obj->buf), 0, MPI_INT, i,
|
|
|
|
OMPI_COMM_BARRIER_TAG,
|
|
|
|
MCA_PML_BASE_SEND_SYNCHRONOUS,
|
|
|
|
comm, &(obj->reqs[2*i+1])));
|
|
|
|
|
|
|
|
if ( OMPI_SUCCESS != ret ) {
|
|
|
|
free (obj->reqs);
|
|
|
|
free (obj);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2004-10-26 15:37:58 +04:00
|
|
|
/* return handle */
|
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
/**********************************************************************/
|
|
|
|
/**********************************************************************/
|
|
|
|
/**********************************************************************/
|
|
|
|
/* - count how many requests are active
|
|
|
|
* - generate a request array large enough to hold
|
|
|
|
all active requests
|
|
|
|
* - call waitall on the overall request array
|
|
|
|
* - free the objects
|
|
|
|
*/
|
|
|
|
void ompi_comm_disconnect_waitall (int count, ompi_comm_disconnect_obj **objs)
|
|
|
|
{
|
2006-02-07 06:32:36 +03:00
|
|
|
|
2004-10-26 15:37:58 +04:00
|
|
|
ompi_request_t **reqs=NULL;
|
|
|
|
char *treq=NULL;
|
|
|
|
int totalcount = 0;
|
|
|
|
int i;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
for (i=0; i<count; i++) {
|
2006-02-07 06:32:36 +03:00
|
|
|
if (NULL == objs[i]) {
|
|
|
|
printf("Error in comm_disconnect_waitall\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
totalcount += objs[i]->size;
|
|
|
|
}
|
|
|
|
|
2004-10-26 15:37:58 +04:00
|
|
|
reqs = (ompi_request_t **) malloc (2*totalcount*sizeof(ompi_request_t *));
|
|
|
|
if ( NULL == reqs ) {
|
2006-02-07 06:32:36 +03:00
|
|
|
printf("ompi_comm_disconnect_waitall: error allocating memory\n");
|
|
|
|
return;
|
2004-10-26 15:37:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* generate a single, large array of pending requests */
|
|
|
|
treq = (char *)reqs;
|
|
|
|
for (i=0; i<count; i++) {
|
2006-02-07 06:32:36 +03:00
|
|
|
memcpy (treq, objs[i]->reqs, 2*objs[i]->size * sizeof(ompi_request_t *));
|
|
|
|
treq += 2*objs[i]->size * sizeof(ompi_request_t *);
|
2004-10-26 15:37:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* force all non-blocking all-to-alls to finish */
|
|
|
|
ret = ompi_request_wait_all (2*totalcount, reqs, MPI_STATUSES_IGNORE);
|
|
|
|
|
|
|
|
/* Finally, free everything */
|
|
|
|
for (i=0; i< count; i++ ) {
|
2006-02-07 06:32:36 +03:00
|
|
|
if (NULL != objs[i]->reqs ) {
|
|
|
|
free (objs[i]->reqs );
|
|
|
|
free (objs[i]);
|
2004-10-26 15:37:58 +04:00
|
|
|
}
|
2006-02-07 06:32:36 +03:00
|
|
|
}
|
|
|
|
|
2004-10-26 15:37:58 +04:00
|
|
|
free (reqs);
|
|
|
|
|
|
|
|
/* decrease the counter for dynamic communicators by 'count'.
|
|
|
|
Attention, this approach now requires, that we are just using
|
|
|
|
these routines for communicators which have been flagged dynamic */
|
|
|
|
ompi_comm_num_dyncomm -=count;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************/
|
|
|
|
/**********************************************************************/
|
|
|
|
/**********************************************************************/
|
|
|
|
#define OMPI_COMM_MAXJOBIDS 64
|
|
|
|
void ompi_comm_mark_dyncomm (ompi_communicator_t *comm)
|
|
|
|
{
|
|
|
|
int i, j, numjobids=0;
|
|
|
|
int size, rsize;
|
|
|
|
int found;
|
2005-03-14 23:57:21 +03:00
|
|
|
orte_jobid_t jobids[OMPI_COMM_MAXJOBIDS], thisjobid;
|
2004-10-26 15:37:58 +04:00
|
|
|
ompi_group_t *grp=NULL;
|
|
|
|
|
|
|
|
/* special case for MPI_COMM_NULL */
|
|
|
|
if ( comm == MPI_COMM_NULL ) {
|
2006-02-07 06:32:36 +03:00
|
|
|
return;
|
2004-10-26 15:37:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
size = ompi_comm_size (comm);
|
|
|
|
rsize = ompi_comm_remote_size(comm);
|
|
|
|
|
|
|
|
/* loop over all processes in local group and count number
|
|
|
|
of different jobids. */
|
|
|
|
grp = comm->c_local_group;
|
|
|
|
for (i=0; i< size; i++) {
|
2006-02-07 06:32:36 +03:00
|
|
|
if (ORTE_SUCCESS != orte_ns.get_jobid(&thisjobid, &(grp->grp_proc_pointers[i]->proc_name))) {
|
2005-03-14 23:57:21 +03:00
|
|
|
return;
|
|
|
|
}
|
2006-02-07 06:32:36 +03:00
|
|
|
found = 0;
|
|
|
|
for ( j=0; j<numjobids; j++) {
|
|
|
|
if ( thisjobid == jobids[j]) {
|
|
|
|
found = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!found ) {
|
|
|
|
jobids[numjobids++] = thisjobid;
|
|
|
|
}
|
2004-10-26 15:37:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* if inter-comm, loop over all processes in remote_group
|
|
|
|
and count number of different jobids */
|
|
|
|
grp = comm->c_remote_group;
|
|
|
|
for (i=0; i< rsize; i++) {
|
2005-03-14 23:57:21 +03:00
|
|
|
if (ORTE_SUCCESS != orte_ns.get_jobid(&thisjobid, &(grp->grp_proc_pointers[i]->proc_name))) {
|
|
|
|
return;
|
|
|
|
}
|
2006-02-07 06:32:36 +03:00
|
|
|
found = 0;
|
|
|
|
for ( j=0; j<numjobids; j++) {
|
|
|
|
if ( thisjobid == jobids[j]) {
|
|
|
|
found = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!found ) {
|
|
|
|
jobids[numjobids++] = thisjobid;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-10-26 15:37:58 +04:00
|
|
|
/* if number of joibds larger than one, set the disconnect flag*/
|
|
|
|
if ( numjobids > 1 ) {
|
2006-02-07 06:32:36 +03:00
|
|
|
ompi_comm_num_dyncomm++;
|
|
|
|
OMPI_COMM_SET_DYNAMIC(comm);
|
2004-10-26 15:37:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|