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-06-16 19:41:36 +04:00
|
|
|
int rsize, mode, rc=MPI_SUCCESS;
|
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-18 23:02:52 +04:00
|
|
|
OMPI_ERR_INIT_FINALIZE;
|
|
|
|
|
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-17 02:44:56 +04:00
|
|
|
mode = OMPI_COMM_CID_INTER;
|
2004-03-26 23:03:38 +03:00
|
|
|
}
|
|
|
|
else {
|
2004-05-21 23:32:18 +04:00
|
|
|
rsize = 0;
|
|
|
|
rprocs = NULL;
|
2004-06-17 02:44:56 +04:00
|
|
|
mode = OMPI_COMM_CID_INTRA;
|
2004-03-26 23:03:38 +03:00
|
|
|
}
|
|
|
|
|
2004-06-16 19:41:36 +04:00
|
|
|
newcomp = ompi_comm_set ( comp, /* old 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,t.b.d */
|
|
|
|
NULL /* topo module, t.b.d */
|
2004-05-21 23:32:18 +04:00
|
|
|
);
|
2004-03-26 23:03:38 +03:00
|
|
|
|
2004-06-16 19:41:36 +04:00
|
|
|
if ( MPI_COMM_NULL == newcomp ) {
|
2004-06-07 19:33:53 +04:00
|
|
|
OMPI_ERRHANDLER_INVOKE (comm, MPI_ERR_INTERN, "MPI_Comm_dup");
|
2004-06-16 19:41:36 +04:00
|
|
|
}
|
2004-03-26 23:03:38 +03:00
|
|
|
|
2004-06-16 19:41:36 +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 communicator */
|
|
|
|
comp, /* old comm */
|
|
|
|
NULL, /* bridge comm */
|
|
|
|
NULL, /* local leader */
|
|
|
|
NULL, /* remote_leader */
|
|
|
|
mode ); /* mode */
|
2004-06-16 19:41:36 +04:00
|
|
|
if ( OMPI_SUCCESS != rc ) {
|
|
|
|
*newcomm = MPI_COMM_NULL;
|
|
|
|
OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_INTERN, "MPI_Comm_dup");
|
|
|
|
}
|
|
|
|
|
2004-05-21 23:32:18 +04:00
|
|
|
*newcomm = newcomp;
|
|
|
|
return ( MPI_SUCCESS );
|
2004-01-21 03:05:46 +03:00
|
|
|
}
|