2004-01-21 03:05:46 +03:00
|
|
|
/*
|
|
|
|
* $HEADERS$
|
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
#include "ompi_config.h"
|
2004-01-21 03:05:46 +03:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "mpi.h"
|
2004-03-17 21:45:16 +03:00
|
|
|
#include "mpi/c/bindings.h"
|
2004-06-16 05:41:01 +04:00
|
|
|
#include "runtime/runtime.h"
|
|
|
|
#include "info/info.h"
|
|
|
|
#include "communicator/communicator.h"
|
2004-01-21 03:05:46 +03:00
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
#if OMPI_HAVE_WEAK_SYMBOLS && OMPI_PROFILING_DEFINES
|
2004-01-21 03:05:46 +03:00
|
|
|
#pragma weak MPI_Comm_accept = PMPI_Comm_accept
|
|
|
|
#endif
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
#if OMPI_PROFILING_DEFINES
|
2004-04-20 22:50:43 +04:00
|
|
|
#include "mpi/c/profile/defines.h"
|
|
|
|
#endif
|
|
|
|
|
2004-07-30 06:58:53 +04:00
|
|
|
static const char FUNC_NAME[] = "MPI_Comm_accept";
|
2004-06-23 00:21:35 +04:00
|
|
|
|
|
|
|
|
2004-01-21 03:05:46 +03:00
|
|
|
int MPI_Comm_accept(char *port_name, MPI_Info info, int root,
|
2004-06-16 05:41:01 +04:00
|
|
|
MPI_Comm comm, MPI_Comm *newcomm)
|
|
|
|
{
|
2004-06-17 01:35:31 +04:00
|
|
|
int rank, i, rc;
|
|
|
|
int maxprocs;
|
|
|
|
uint32_t *rprocs=NULL;
|
2004-06-17 02:44:56 +04:00
|
|
|
uint32_t lleader=0, rleader=0; /* OOB contact information of our and other root */
|
2004-06-17 01:35:31 +04:00
|
|
|
ompi_communicator_t *comp, *newcomp;
|
|
|
|
|
|
|
|
comp = (ompi_communicator_t *) comm;
|
2004-06-16 05:41:01 +04:00
|
|
|
|
|
|
|
if ( MPI_PARAM_CHECK ) {
|
2004-06-23 00:21:35 +04:00
|
|
|
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
|
2004-06-18 23:02:52 +04:00
|
|
|
|
2004-07-30 06:58:53 +04:00
|
|
|
if ( MPI_COMM_NULL == comm || ompi_comm_invalid (comm)) {
|
2004-06-16 05:41:01 +04:00
|
|
|
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM,
|
2004-06-23 00:21:35 +04:00
|
|
|
FUNC_NAME);
|
2004-07-30 06:58:53 +04:00
|
|
|
}
|
|
|
|
if ( OMPI_COMM_IS_INTER(comm)) {
|
2004-06-17 01:35:31 +04:00
|
|
|
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_COMM,
|
2004-06-23 00:21:35 +04:00
|
|
|
FUNC_NAME);
|
2004-07-30 06:58:53 +04:00
|
|
|
}
|
|
|
|
if ( 0 > root || ompi_comm_size(comm) < root ) {
|
2004-06-16 05:41:01 +04:00
|
|
|
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG,
|
2004-06-23 00:21:35 +04:00
|
|
|
FUNC_NAME);
|
2004-07-30 06:58:53 +04:00
|
|
|
}
|
|
|
|
if ( NULL == newcomm ) {
|
2004-06-16 05:41:01 +04:00
|
|
|
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG,
|
2004-06-23 00:21:35 +04:00
|
|
|
FUNC_NAME);
|
2004-07-30 06:58:53 +04:00
|
|
|
}
|
2004-06-16 05:41:01 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
rank = ompi_comm_rank ( comm );
|
|
|
|
if ( MPI_PARAM_CHECK ) {
|
|
|
|
if ( rank == root ) {
|
|
|
|
if ( NULL == port_name )
|
|
|
|
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG,
|
2004-06-23 00:21:35 +04:00
|
|
|
FUNC_NAME);
|
2004-06-16 05:41:01 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-06-17 01:35:31 +04:00
|
|
|
if ( rank == root && MPI_INFO_NULL != info ) {
|
|
|
|
/* parse info object. no prefedined values for this function in MPI-2 */
|
|
|
|
|
|
|
|
/* accept connection from other app */
|
|
|
|
|
|
|
|
/* recv number of procs (maxprocs) of other app */
|
|
|
|
rprocs = (uint32_t *)malloc (maxprocs * sizeof(uint32_t));
|
|
|
|
if ( NULL == rprocs ) {
|
|
|
|
rc = MPI_ERR_INTERN;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* recv list of procs of other app */
|
2004-06-16 05:41:01 +04:00
|
|
|
/* send number of procs to other app */
|
|
|
|
/* send list of process to other app */
|
2004-06-17 01:35:31 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* bcast maxprocs to all processes in comm and allocate the rprocs array*/
|
2004-06-29 04:02:25 +04:00
|
|
|
rc = comp->c_coll.coll_bcast ( &maxprocs, 1, MPI_INT, root, comm);
|
2004-06-17 01:35:31 +04:00
|
|
|
if ( OMPI_SUCCESS != rc ) {
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( rank != root ) {
|
|
|
|
rprocs = (uint32_t *)malloc (maxprocs * sizeof(uint32_t));
|
|
|
|
if ( NULL == rprocs ) {
|
|
|
|
rc = MPI_ERR_INTERN;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* bcast list of remote procs to all processes in comm */
|
2004-06-29 04:02:25 +04:00
|
|
|
rc = comp->c_coll.coll_bcast ( &rprocs, maxprocs, MPI_UNSIGNED, root, comm);
|
2004-06-17 01:35:31 +04:00
|
|
|
if ( OMPI_SUCCESS != rc ) {
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* setup the proc-structures for the new processes, which are not yet known */
|
|
|
|
for ( i=0; i<maxprocs; i++ ) {
|
|
|
|
/* if process rprocs[i] not yet in our list, add it. */
|
|
|
|
}
|
|
|
|
|
2004-08-04 02:08:23 +04:00
|
|
|
newcomp = ompi_comm_allocate ( comp->c_local_group->grp_proc_count, maxprocs);
|
|
|
|
if ( NULL == newcomp ) {
|
|
|
|
rc = MPI_ERR_INTERN;
|
2004-06-17 01:35:31 +04:00
|
|
|
goto exit;
|
|
|
|
}
|
2004-08-04 02:08:23 +04:00
|
|
|
|
2004-06-17 01:35:31 +04:00
|
|
|
/* Determine context id. It is identical to f_2_c_handle */
|
2004-06-17 02:44:56 +04:00
|
|
|
rc = ompi_comm_nextcid ( newcomp, /* new comm */
|
|
|
|
comp, /* old comm */
|
|
|
|
NULL, /* bridge comm */
|
|
|
|
&lleader, /* local leader */
|
|
|
|
&rleader, /* remote_leader */
|
|
|
|
OMPI_COMM_CID_INTRA_OOB ); /* mode */
|
2004-06-17 01:35:31 +04:00
|
|
|
if ( OMPI_SUCCESS != rc ) {
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2004-08-04 02:08:23 +04:00
|
|
|
/* setup the intercomm-structure using ompi_comm_set (); */
|
|
|
|
rc = ompi_comm_set ( newcomp, /* new comm */
|
|
|
|
comp, /* old comm */
|
|
|
|
comp->c_local_group->grp_proc_count, /* local_size */
|
|
|
|
comp->c_local_group->grp_proc_pointers, /* local_procs*/
|
|
|
|
maxprocs, /* remote_size */
|
|
|
|
rprocs, /* remote_procs */
|
|
|
|
NULL, /* attrs */
|
|
|
|
comp->error_handler, /* error handler */
|
|
|
|
NULL, /* coll module */
|
|
|
|
NULL /* topo module */
|
|
|
|
);
|
|
|
|
if ( MPI_SUCCESS != rc ) {
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-06-17 01:35:31 +04:00
|
|
|
/* PROBLEM: do we have to re-start some low level stuff
|
|
|
|
to enable the usage of fast communication devices
|
|
|
|
between the two worlds ? */
|
|
|
|
|
|
|
|
exit:
|
|
|
|
if ( NULL != rprocs ) {
|
|
|
|
free ( rprocs );
|
|
|
|
}
|
|
|
|
if ( MPI_SUCCESS != rc ) {
|
|
|
|
*newcomm = MPI_COMM_NULL;
|
2004-06-23 00:21:35 +04:00
|
|
|
return OMPI_ERRHANDLER_INVOKE(comm, rc, FUNC_NAME);
|
2004-06-17 01:35:31 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
*newcomm = newcomp;
|
2004-01-21 03:05:46 +03:00
|
|
|
return MPI_SUCCESS;
|
|
|
|
}
|