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-26 23:03:38 +03:00
|
|
|
#include "runtime/runtime.h"
|
2004-05-21 23:32:18 +04:00
|
|
|
#include "mpi/c/bindings.h"
|
2004-03-26 23:03:38 +03:00
|
|
|
#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_dup = PMPI_Comm_dup
|
|
|
|
#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-01-21 03:05:46 +03:00
|
|
|
int MPI_Comm_dup(MPI_Comm comm, MPI_Comm *newcomm) {
|
2004-03-26 23:03:38 +03:00
|
|
|
|
|
|
|
/* local variables */
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_communicator_t *comp, *newcomp;
|
2004-05-21 23:32:18 +04:00
|
|
|
int rsize, mode;
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_proc_t **rprocs;
|
2004-03-26 23:03:38 +03:00
|
|
|
|
|
|
|
/* argument checking */
|
|
|
|
if ( MPI_PARAM_CHECK ) {
|
2004-06-07 19:33:53 +04:00
|
|
|
if (ompi_mpi_finalized)
|
|
|
|
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_INTERN,
|
2004-03-26 23:03:38 +03:00
|
|
|
"MPI_Comm_dup");
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
if (MPI_COMM_NULL == comm || ompi_comm_invalid (comm))
|
|
|
|
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM,
|
2004-03-26 23:03:38 +03:00
|
|
|
"MPI_Comm_dup");
|
|
|
|
|
|
|
|
if ( NULL == newcomm )
|
2004-06-07 19:33:53 +04:00
|
|
|
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG,
|
2004-03-26 23:03:38 +03:00
|
|
|
"MPI_Comm_dup");
|
|
|
|
}
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
comp = (ompi_communicator_t *) comm;
|
|
|
|
if ( OMPI_COMM_IS_INTER ( comp ) ){
|
2004-05-21 23:32:18 +04:00
|
|
|
rsize = comp->c_remote_group->grp_proc_count;
|
|
|
|
rprocs = comp->c_remote_group->grp_proc_pointers;
|
2004-06-07 19:33:53 +04:00
|
|
|
mode = OMPI_COMM_INTER_INTER;
|
2004-03-26 23:03:38 +03:00
|
|
|
}
|
|
|
|
else {
|
2004-05-21 23:32:18 +04:00
|
|
|
rsize = 0;
|
|
|
|
rprocs = NULL;
|
2004-06-07 19:33:53 +04:00
|
|
|
mode = OMPI_COMM_INTRA_INTRA;
|
2004-03-26 23:03:38 +03:00
|
|
|
}
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
newcomp = ompi_comm_set ( mode, /* mode */
|
2004-05-21 23:32:18 +04:00
|
|
|
comp, /* old comm */
|
|
|
|
NULL, /* bridge comm */
|
|
|
|
comp->c_local_group->grp_proc_count, /* local_size */
|
|
|
|
comp->c_local_group->grp_proc_pointers, /* local_procs*/
|
|
|
|
rsize, /* remote_size */
|
|
|
|
rprocs, /* remote_procs */
|
|
|
|
comp->c_keyhash, /* attrs */
|
|
|
|
comp->error_handler, /* error handler */
|
|
|
|
NULL, /* coll module, to be modified */
|
|
|
|
NULL, /* topo module, to be modified */
|
|
|
|
MPI_UNDEFINED, /* local leader */
|
|
|
|
MPI_UNDEFINED /* remote leader */
|
|
|
|
);
|
2004-03-26 23:03:38 +03:00
|
|
|
|
2004-05-21 23:32:18 +04:00
|
|
|
if ( newcomp == MPI_COMM_NULL )
|
2004-06-07 19:33:53 +04:00
|
|
|
OMPI_ERRHANDLER_INVOKE (comm, MPI_ERR_INTERN, "MPI_Comm_dup");
|
2004-03-26 23:03:38 +03:00
|
|
|
|
2004-05-21 23:32:18 +04:00
|
|
|
*newcomm = newcomp;
|
|
|
|
return ( MPI_SUCCESS );
|
2004-01-21 03:05:46 +03:00
|
|
|
}
|