2004-05-22 00:06:20 +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.
|
2006-08-24 20:38:08 +04:00
|
|
|
* Copyright (c) 2004-2006 The University of Tennessee and The University
|
2005-11-05 22:57:48 +03:00
|
|
|
* of Tennessee Research Foundation. All rights
|
|
|
|
* reserved.
|
2004-11-28 23:09:25 +03:00
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
|
|
* 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.
|
2007-03-27 06:06:42 +04:00
|
|
|
* Copyright (c) 2007 University of Houston. All rights reserved.
|
2004-11-22 04:38:40 +03:00
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
2004-05-22 00:06:20 +04:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
#include "ompi_config.h"
|
2004-05-22 00:06:20 +04:00
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2006-02-12 04:33:29 +03:00
|
|
|
#include "ompi/constants.h"
|
2006-02-07 06:32:36 +03:00
|
|
|
#include "orte/dss/dss.h"
|
2006-02-12 04:33:29 +03:00
|
|
|
#include "ompi/proc/proc.h"
|
2005-07-04 02:45:48 +04:00
|
|
|
#include "opal/threads/mutex.h"
|
2005-07-04 04:13:44 +04:00
|
|
|
#include "opal/util/bit_ops.h"
|
2005-07-04 03:31:27 +04:00
|
|
|
#include "opal/util/output.h"
|
2005-07-04 04:13:44 +04:00
|
|
|
#include "opal/util/convert.h"
|
2006-02-12 04:33:29 +03:00
|
|
|
#include "ompi/mca/topo/topo.h"
|
|
|
|
#include "ompi/mca/topo/base/base.h"
|
|
|
|
#include "orte/mca/ns/ns.h"
|
2004-05-22 00:06:20 +04:00
|
|
|
|
2006-02-12 04:33:29 +03:00
|
|
|
#include "ompi/attribute/attribute.h"
|
|
|
|
#include "ompi/communicator/communicator.h"
|
|
|
|
#include "ompi/mca/pml/pml.h"
|
|
|
|
#include "ompi/request/request.h"
|
2004-09-16 14:07:42 +04:00
|
|
|
|
2004-05-22 00:06:20 +04:00
|
|
|
/*
|
|
|
|
** sort-function for MPI_Comm_split
|
|
|
|
*/
|
|
|
|
static int rankkeycompare(const void *, const void *);
|
|
|
|
|
2004-07-21 02:21:47 +04:00
|
|
|
/**
|
|
|
|
* to fill the rest of the stuff for the communicator when either
|
|
|
|
* MPI_Cart_create or MPI_Graph_create is used
|
|
|
|
*/
|
|
|
|
static int ompi_comm_fill_rest (ompi_communicator_t *comm,
|
|
|
|
int num_procs,
|
|
|
|
ompi_proc_t **proc_pointers,
|
|
|
|
int my_rank,
|
2004-08-05 20:31:30 +04:00
|
|
|
ompi_errhandler_t *errh );
|
2004-06-16 01:29:29 +04:00
|
|
|
/*
|
|
|
|
** typedef for the allgather_intra required in comm_split.
|
|
|
|
** the reason for introducing this abstraction is, that
|
|
|
|
** for Comm_split for inter-coms, we do not have this
|
|
|
|
** functions, so we need to emulate it.
|
|
|
|
*/
|
|
|
|
typedef int ompi_comm_allgatherfct (void* inbuf, int incount, MPI_Datatype intype,
|
|
|
|
void* outbuf, int outcount, MPI_Datatype outtype,
|
|
|
|
ompi_communicator_t *comm);
|
|
|
|
|
|
|
|
static int ompi_comm_allgather_emulate_intra (void* inbuf, int incount, MPI_Datatype intype,
|
|
|
|
void* outbuf, int outcount,
|
|
|
|
MPI_Datatype outtype,
|
|
|
|
ompi_communicator_t *comm);
|
|
|
|
|
2004-10-05 20:32:52 +04:00
|
|
|
static int ompi_comm_copy_topo (ompi_communicator_t *oldcomm,
|
2007-04-06 23:18:31 +04:00
|
|
|
ompi_communicator_t *newcomm);
|
2004-06-16 01:29:29 +04:00
|
|
|
|
2004-05-22 00:06:20 +04:00
|
|
|
/**********************************************************************/
|
|
|
|
/**********************************************************************/
|
|
|
|
/**********************************************************************/
|
|
|
|
/*
|
|
|
|
* This is the function setting all elements of a communicator.
|
|
|
|
* All other routines are just used to determine these elements.
|
|
|
|
*/
|
2004-07-21 02:21:47 +04:00
|
|
|
|
2004-08-04 02:07:45 +04:00
|
|
|
int ompi_comm_set ( ompi_communicator_t *newcomm,
|
|
|
|
ompi_communicator_t* oldcomm,
|
|
|
|
int local_size,
|
|
|
|
ompi_proc_t **local_procs,
|
|
|
|
int remote_size,
|
|
|
|
ompi_proc_t **remote_procs,
|
2005-07-03 20:52:32 +04:00
|
|
|
opal_hash_table_t *attr,
|
2004-08-04 02:07:45 +04:00
|
|
|
ompi_errhandler_t *errh,
|
|
|
|
mca_base_component_t *topocomponent )
|
2004-05-22 00:06:20 +04:00
|
|
|
{
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_proc_t *my_gpointer;
|
2004-05-22 00:06:20 +04:00
|
|
|
int my_grank;
|
2004-10-05 20:32:52 +04:00
|
|
|
int ret;
|
2004-05-22 00:06:20 +04:00
|
|
|
|
|
|
|
/* Set local_group information */
|
|
|
|
memcpy ( newcomm->c_local_group->grp_proc_pointers,
|
2004-06-07 19:33:53 +04:00
|
|
|
local_procs, local_size * sizeof(ompi_proc_t *));
|
|
|
|
ompi_group_increment_proc_count(newcomm->c_local_group);
|
2004-05-22 00:06:20 +04:00
|
|
|
|
|
|
|
/* determine my rank */
|
|
|
|
my_grank = oldcomm->c_local_group->grp_my_rank;
|
|
|
|
my_gpointer = oldcomm->c_local_group->grp_proc_pointers[my_grank];
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_set_group_rank(newcomm->c_local_group, my_gpointer);
|
2004-05-22 00:06:20 +04:00
|
|
|
newcomm->c_my_rank = newcomm->c_local_group->grp_my_rank;
|
|
|
|
|
2007-03-27 06:06:42 +04:00
|
|
|
/* Set remote group and duplicate the local comm, if applicable */
|
2004-05-22 00:06:20 +04:00
|
|
|
if ( 0 < remote_size) {
|
|
|
|
memcpy ( newcomm->c_remote_group->grp_proc_pointers,
|
2004-06-07 19:33:53 +04:00
|
|
|
remote_procs, remote_size * sizeof(ompi_proc_t *));
|
|
|
|
ompi_group_increment_proc_count(newcomm->c_remote_group);
|
|
|
|
newcomm->c_flags |= OMPI_COMM_INTER;
|
2007-04-06 23:18:31 +04:00
|
|
|
if ( OMPI_COMM_IS_INTRA(oldcomm) ) {
|
|
|
|
ompi_comm_dup(oldcomm, &newcomm->c_local_comm,1);
|
|
|
|
} else {
|
|
|
|
ompi_comm_dup(oldcomm->c_local_comm, &newcomm->c_local_comm,1);
|
|
|
|
}
|
2004-05-22 00:06:20 +04:00
|
|
|
}
|
|
|
|
|
2004-10-26 15:37:58 +04:00
|
|
|
/* Check how many different jobids are represented in this communicator.
|
|
|
|
Necessary for the disconnect of dynamic communicators. */
|
|
|
|
ompi_comm_mark_dyncomm (newcomm);
|
|
|
|
|
2004-05-22 00:06:20 +04:00
|
|
|
/* Set error handler */
|
|
|
|
newcomm->error_handler = errh;
|
|
|
|
OBJ_RETAIN ( newcomm->error_handler );
|
|
|
|
|
|
|
|
/* Set Topology, if required */
|
2004-06-18 19:29:50 +04:00
|
|
|
|
2004-08-02 04:24:22 +04:00
|
|
|
if ( NULL != topocomponent ) {
|
2004-07-21 02:21:47 +04:00
|
|
|
/*
|
2004-10-05 20:32:52 +04:00
|
|
|
* This functions is never used to determine the topology
|
2004-08-02 04:24:22 +04:00
|
|
|
* component. The topology component is determined only by the
|
|
|
|
* ompi_cart_create and ompi_comm_create functions. Have to
|
|
|
|
* see what ahppens during MPI_Comm_dup though. During this
|
|
|
|
* the topology information has to be copied into the new
|
|
|
|
* communicator which includes selecting a new topology
|
|
|
|
* component and setting the information which is on that
|
|
|
|
* communicator into this communicator. This probably is
|
|
|
|
* another function in this file.
|
2004-07-21 02:21:47 +04:00
|
|
|
*/
|
2004-10-05 20:32:52 +04:00
|
|
|
|
2007-04-06 23:18:31 +04:00
|
|
|
if (OMPI_COMM_IS_CART ( oldcomm ) ) {
|
2004-06-07 19:33:53 +04:00
|
|
|
newcomm->c_flags |= OMPI_COMM_CART;
|
2007-04-06 23:18:31 +04:00
|
|
|
}
|
|
|
|
if (OMPI_COMM_IS_GRAPH ( oldcomm ) ) {
|
2004-06-07 19:33:53 +04:00
|
|
|
newcomm->c_flags |= OMPI_COMM_GRAPH;
|
2007-04-06 23:18:31 +04:00
|
|
|
}
|
2004-10-05 20:32:52 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Now I have to set the information on the topology from the previous
|
|
|
|
* communicator
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* allocate the data for the common good */
|
2004-10-18 20:55:20 +04:00
|
|
|
newcomm->c_topo_comm = (mca_topo_base_comm_t *)malloc(sizeof(mca_topo_base_comm_t));
|
2004-10-05 20:32:52 +04:00
|
|
|
|
|
|
|
if (NULL == newcomm->c_topo_comm) {
|
|
|
|
OBJ_RELEASE(newcomm);
|
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (OMPI_SUCCESS != (ret = mca_topo_base_comm_select (newcomm,
|
2007-04-06 23:18:31 +04:00
|
|
|
oldcomm->c_topo_component))) {
|
2004-10-05 20:32:52 +04:00
|
|
|
free(newcomm->c_topo_comm);
|
|
|
|
OBJ_RELEASE(newcomm);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Should copy over the information from the previous communicator
|
|
|
|
*/
|
|
|
|
if (OMPI_SUCCESS != (ret = ompi_comm_copy_topo (oldcomm, newcomm))) {
|
|
|
|
OBJ_RELEASE(newcomm);
|
|
|
|
return ret;
|
|
|
|
}
|
2004-05-22 00:06:20 +04:00
|
|
|
}
|
|
|
|
|
2004-10-07 05:26:40 +04:00
|
|
|
/* Copy attributes and call according copy functions, if
|
|
|
|
required */
|
|
|
|
|
|
|
|
if (NULL != oldcomm->c_keyhash) {
|
|
|
|
if (NULL != attr) {
|
|
|
|
ompi_attr_hash_init(&newcomm->c_keyhash);
|
2004-10-26 00:20:07 +04:00
|
|
|
if (OMPI_SUCCESS != (ret = ompi_attr_copy_all (COMM_ATTR, oldcomm,
|
|
|
|
newcomm, attr,
|
|
|
|
newcomm->c_keyhash))) {
|
|
|
|
OBJ_RELEASE(newcomm);
|
|
|
|
return ret;
|
|
|
|
}
|
2004-10-07 05:26:40 +04:00
|
|
|
}
|
2004-05-22 00:06:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Initialize the PML stuff in the newcomm */
|
2005-04-13 07:19:48 +04:00
|
|
|
if ( OMPI_ERROR == MCA_PML_CALL(add_comm(newcomm)) ) {
|
2004-10-26 00:20:07 +04:00
|
|
|
OBJ_RELEASE(newcomm);
|
2004-08-04 02:07:45 +04:00
|
|
|
return OMPI_ERROR;
|
2004-05-22 00:06:20 +04:00
|
|
|
}
|
2005-03-26 04:49:14 +03:00
|
|
|
OMPI_COMM_SET_PML_ADDED(newcomm);
|
2004-08-04 02:07:45 +04:00
|
|
|
return (OMPI_SUCCESS);
|
2004-05-22 00:06:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************/
|
|
|
|
/**********************************************************************/
|
|
|
|
/**********************************************************************/
|
|
|
|
/*
|
2004-06-07 19:33:53 +04:00
|
|
|
** Counterpart to MPI_Comm_group. To be used within OMPI functions.
|
2004-05-22 00:06:20 +04:00
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
int ompi_comm_group ( ompi_communicator_t* comm, ompi_group_t **group )
|
2004-05-22 00:06:20 +04:00
|
|
|
{
|
2004-12-03 17:45:15 +03:00
|
|
|
/* increment reference counters for the group */
|
2004-05-22 00:06:20 +04:00
|
|
|
OBJ_RETAIN(comm->c_local_group);
|
|
|
|
|
2004-12-03 17:45:15 +03:00
|
|
|
/* increase also the reference counter for the procs */
|
|
|
|
ompi_group_increment_proc_count(comm->c_local_group);
|
|
|
|
|
2004-05-22 00:06:20 +04:00
|
|
|
*group = comm->c_local_group;
|
2004-06-07 19:33:53 +04:00
|
|
|
return OMPI_SUCCESS;
|
2004-05-22 00:06:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************/
|
|
|
|
/**********************************************************************/
|
|
|
|
/**********************************************************************/
|
|
|
|
/*
|
2004-06-07 19:33:53 +04:00
|
|
|
** Counterpart to MPI_Comm_create. To be used within OMPI.
|
2004-05-22 00:06:20 +04:00
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
int ompi_comm_create ( ompi_communicator_t *comm, ompi_group_t *group,
|
|
|
|
ompi_communicator_t **newcomm )
|
2004-05-22 00:06:20 +04:00
|
|
|
{
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_communicator_t *newcomp;
|
2004-05-22 00:06:20 +04:00
|
|
|
int rsize;
|
|
|
|
int mode;
|
|
|
|
int *allranks=NULL;
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_proc_t **rprocs=NULL;
|
|
|
|
int rc = OMPI_SUCCESS;
|
2004-05-22 00:06:20 +04:00
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
if ( OMPI_COMM_IS_INTER(comm) ) {
|
2004-05-22 00:06:20 +04:00
|
|
|
int tsize, i, j;
|
|
|
|
|
2004-08-06 02:48:47 +04:00
|
|
|
tsize = ompi_comm_remote_size(comm);
|
2004-05-22 00:06:20 +04:00
|
|
|
allranks = (int *) malloc ( tsize * sizeof(int));
|
|
|
|
if ( NULL == allranks ) {
|
2004-06-07 19:33:53 +04:00
|
|
|
rc = OMPI_ERR_OUT_OF_RESOURCE;
|
2004-05-22 00:06:20 +04:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2004-08-06 02:48:47 +04:00
|
|
|
rc = comm->c_coll.coll_allgather ( &(group->grp_my_rank),
|
|
|
|
1, MPI_INT, allranks,
|
|
|
|
1, MPI_INT, comm );
|
2004-06-07 19:33:53 +04:00
|
|
|
if ( OMPI_SUCCESS != rc ) {
|
2004-05-22 00:06:20 +04:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Count number of procs in future remote group */
|
|
|
|
for (rsize=0, i = 0; i < tsize; i++) {
|
2004-08-06 02:48:47 +04:00
|
|
|
if ( MPI_UNDEFINED != allranks[i] ) {
|
2004-05-22 00:06:20 +04:00
|
|
|
rsize++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If any of those groups is empty, we have to return
|
|
|
|
MPI_COMM_NULL */
|
|
|
|
if ( 0 == rsize || 0 == group->grp_proc_count ) {
|
2004-08-06 02:48:47 +04:00
|
|
|
newcomp = MPI_COMM_NULL;
|
2004-06-07 19:33:53 +04:00
|
|
|
rc = OMPI_SUCCESS;
|
2004-05-22 00:06:20 +04:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set proc-pointers for remote group */
|
2004-08-06 02:48:47 +04:00
|
|
|
rprocs = (ompi_proc_t **) calloc ( rsize, sizeof(ompi_proc_t *));
|
2004-05-22 00:06:20 +04:00
|
|
|
if ( NULL == rprocs ) {
|
2004-06-07 19:33:53 +04:00
|
|
|
rc = OMPI_ERR_OUT_OF_RESOURCE;
|
2004-05-22 00:06:20 +04:00
|
|
|
goto exit;
|
|
|
|
}
|
2004-08-06 02:48:47 +04:00
|
|
|
|
|
|
|
for ( j = 0, i = 0; i < tsize; i++ ) {
|
|
|
|
if ( MPI_UNDEFINED != allranks[i] ) {
|
2004-05-22 00:06:20 +04:00
|
|
|
rprocs[j] = comm->c_remote_group->grp_proc_pointers[i];
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
}
|
2004-06-17 02:37:03 +04:00
|
|
|
mode = OMPI_COMM_CID_INTER;
|
2004-08-06 02:48:47 +04:00
|
|
|
|
2007-04-06 23:18:31 +04:00
|
|
|
} else {
|
2004-05-22 00:06:20 +04:00
|
|
|
rsize = 0;
|
|
|
|
rprocs = NULL;
|
2004-08-04 02:07:45 +04:00
|
|
|
mode = OMPI_COMM_CID_INTRA;
|
2004-05-22 00:06:20 +04:00
|
|
|
}
|
2004-08-06 02:48:47 +04:00
|
|
|
|
2004-08-04 02:07:45 +04:00
|
|
|
newcomp = ompi_comm_allocate (group->grp_proc_count, rsize );
|
|
|
|
if ( NULL == newcomp ) {
|
2004-05-22 00:06:20 +04:00
|
|
|
rc = MPI_ERR_INTERN;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2004-06-16 19:40:52 +04:00
|
|
|
/* Determine context id. It is identical to f_2_c_handle */
|
2004-06-17 02:37:03 +04:00
|
|
|
rc = ompi_comm_nextcid ( newcomp, /* new communicator */
|
|
|
|
comm, /* old comm */
|
|
|
|
NULL, /* bridge comm */
|
|
|
|
NULL, /* local leader */
|
|
|
|
NULL, /* remote_leader */
|
2004-08-05 20:31:30 +04:00
|
|
|
mode, /* mode */
|
|
|
|
-1 ); /* send first */
|
2004-06-16 19:40:52 +04:00
|
|
|
if ( OMPI_SUCCESS != rc ) {
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2004-08-04 02:07:45 +04:00
|
|
|
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 */
|
|
|
|
);
|
|
|
|
if ( OMPI_SUCCESS != rc ) {
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2006-04-16 05:34:34 +04:00
|
|
|
/* Set name for debugging purposes */
|
|
|
|
snprintf(newcomp->c_name, MPI_MAX_OBJECT_NAME, "MPI COMMUNICATOR %d CREATE FROM %d",
|
|
|
|
newcomp->c_contextid, comm->c_contextid );
|
|
|
|
|
2004-08-05 20:31:30 +04:00
|
|
|
/* Activate the communicator and init coll-component */
|
|
|
|
rc = ompi_comm_activate ( newcomp, /* new communicator */
|
2004-08-06 02:48:47 +04:00
|
|
|
comm, /* old comm */
|
|
|
|
NULL, /* bridge comm */
|
|
|
|
NULL, /* local leader */
|
|
|
|
NULL, /* remote_leader */
|
|
|
|
mode, /* mode */
|
|
|
|
-1, /* send first */
|
2007-04-06 23:18:31 +04:00
|
|
|
0, /* sync_flag */
|
2004-08-06 02:48:47 +04:00
|
|
|
NULL ); /* coll component */
|
2004-08-05 20:31:30 +04:00
|
|
|
|
|
|
|
if ( OMPI_SUCCESS != rc ) {
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2004-08-04 02:07:45 +04:00
|
|
|
|
2004-05-22 00:06:20 +04:00
|
|
|
/* Check whether we are part of the new comm.
|
|
|
|
If not, we have to free the structure again.
|
|
|
|
However, we could not avoid the comm_nextcid step, since
|
|
|
|
all processes of the original comm have to participate in
|
|
|
|
that function call. Additionally, all errhandler stuff etc.
|
2004-06-07 19:33:53 +04:00
|
|
|
has to be set to make ompi_comm_free happy */
|
2004-07-16 00:55:15 +04:00
|
|
|
if ( MPI_UNDEFINED == newcomp->c_local_group->grp_my_rank ) {
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_comm_free ( &newcomp );
|
2004-05-22 00:06:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
exit:
|
|
|
|
if ( NULL != allranks ) {
|
|
|
|
free ( allranks );
|
|
|
|
}
|
|
|
|
if ( NULL != rprocs ) {
|
|
|
|
free ( rprocs );
|
|
|
|
}
|
|
|
|
|
2004-08-05 20:31:30 +04:00
|
|
|
*newcomm = newcomp;
|
2004-05-22 00:06:20 +04:00
|
|
|
return ( rc );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************/
|
|
|
|
/**********************************************************************/
|
|
|
|
/**********************************************************************/
|
|
|
|
/*
|
2004-06-07 19:33:53 +04:00
|
|
|
** Counterpart to MPI_Comm_split. To be used within OMPI (e.g. MPI_Cart_sub).
|
2004-05-22 00:06:20 +04:00
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
int ompi_comm_split ( ompi_communicator_t* comm, int color, int key,
|
2004-10-07 23:14:27 +04:00
|
|
|
ompi_communicator_t **newcomm, bool pass_on_topo )
|
2004-05-22 00:06:20 +04:00
|
|
|
{
|
|
|
|
int myinfo[2];
|
|
|
|
int size, my_size;
|
|
|
|
int my_rsize;
|
|
|
|
int mode;
|
|
|
|
int rsize;
|
|
|
|
int i, loc;
|
2004-06-16 01:29:29 +04:00
|
|
|
int inter;
|
2004-05-22 00:06:20 +04:00
|
|
|
int *results=NULL, *sorted=NULL;
|
|
|
|
int *rresults=NULL, *rsorted=NULL;
|
2004-06-07 19:33:53 +04:00
|
|
|
int rc=OMPI_SUCCESS;
|
|
|
|
ompi_proc_t **procs=NULL, **rprocs=NULL;
|
|
|
|
ompi_communicator_t *newcomp;
|
2004-05-22 00:06:20 +04:00
|
|
|
|
2004-08-08 01:15:00 +04:00
|
|
|
ompi_comm_allgatherfct *allgatherfct=NULL;
|
|
|
|
|
2004-05-22 00:06:20 +04:00
|
|
|
/* Step 1: determine all the information for the local group */
|
|
|
|
/* --------------------------------------------------------- */
|
|
|
|
|
|
|
|
/* sort according to color and rank. Gather information from everyone */
|
|
|
|
myinfo[0] = color;
|
|
|
|
myinfo[1] = key;
|
|
|
|
|
2004-06-16 01:29:29 +04:00
|
|
|
size = ompi_comm_size ( comm );
|
|
|
|
inter = OMPI_COMM_IS_INTER(comm);
|
2004-08-08 01:15:00 +04:00
|
|
|
if ( inter ) {
|
|
|
|
allgatherfct = (ompi_comm_allgatherfct *)ompi_comm_allgather_emulate_intra;
|
2007-04-06 23:18:31 +04:00
|
|
|
} else {
|
2004-08-08 01:15:00 +04:00
|
|
|
allgatherfct = (ompi_comm_allgatherfct *)comm->c_coll.coll_allgather;
|
|
|
|
}
|
|
|
|
|
2004-06-16 01:29:29 +04:00
|
|
|
results = (int*) malloc ( 2 * size * sizeof(int));
|
2004-05-22 00:06:20 +04:00
|
|
|
if ( NULL == results ) {
|
2004-06-07 19:33:53 +04:00
|
|
|
return OMPI_ERR_OUT_OF_RESOURCE;
|
2004-05-22 00:06:20 +04:00
|
|
|
}
|
|
|
|
|
2004-08-08 01:15:00 +04:00
|
|
|
rc = allgatherfct( myinfo, 2, MPI_INT, results, 2, MPI_INT, comm );
|
2004-06-07 19:33:53 +04:00
|
|
|
if ( OMPI_SUCCESS != rc ) {
|
2004-05-22 00:06:20 +04:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* how many have the same color like me */
|
|
|
|
for ( my_size = 0, i=0; i < size; i++) {
|
2007-04-06 23:18:31 +04:00
|
|
|
if ( results[(2*i)+0] == color) {
|
|
|
|
my_size++;
|
|
|
|
}
|
2004-05-22 00:06:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
sorted = (int *) malloc ( sizeof( int ) * my_size * 2);
|
|
|
|
if ( NULL == sorted) {
|
2004-06-07 19:33:53 +04:00
|
|
|
rc = OMPI_ERR_OUT_OF_RESOURCE;
|
2004-05-22 00:06:20 +04:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ok we can now fill this info */
|
|
|
|
for( loc = 0, i = 0; i < size; i++ ) {
|
|
|
|
if ( results[(2*i)+0] == color) {
|
|
|
|
sorted[(2*loc)+0] = i; /* copy org rank */
|
|
|
|
sorted[(2*loc)+1] = results[(2*i)+1]; /* copy key */
|
|
|
|
loc++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* the new array needs to be sorted so that it is in 'key' order */
|
|
|
|
/* if two keys are equal then it is sorted in original rank order! */
|
|
|
|
if(my_size>1){
|
|
|
|
qsort ((int*)sorted, my_size, sizeof(int)*2, rankkeycompare);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* put group elements in a list */
|
2004-06-07 19:33:53 +04:00
|
|
|
procs = (ompi_proc_t **) malloc ( sizeof(ompi_proc_t *) * my_size);
|
2004-05-22 00:06:20 +04:00
|
|
|
if ( NULL == procs ) {
|
2004-06-07 19:33:53 +04:00
|
|
|
rc = OMPI_ERR_OUT_OF_RESOURCE;
|
2004-05-22 00:06:20 +04:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
for (i = 0; i < my_size; i++) {
|
|
|
|
procs[i] = comm->c_local_group->grp_proc_pointers[sorted[i*2]];
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Step 2: determine all the information for the remote group */
|
|
|
|
/* --------------------------------------------------------- */
|
2004-06-16 01:29:29 +04:00
|
|
|
if ( inter ) {
|
2004-05-22 00:06:20 +04:00
|
|
|
rsize = comm->c_remote_group->grp_proc_count;
|
|
|
|
rresults = (int *) malloc ( rsize * 2 * sizeof(int));
|
|
|
|
if ( NULL == rresults ) {
|
2004-06-07 19:33:53 +04:00
|
|
|
rc = OMPI_ERR_OUT_OF_RESOURCE;
|
2004-05-22 00:06:20 +04:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2004-08-08 01:15:00 +04:00
|
|
|
/* this is an allgather on an inter-communicator */
|
|
|
|
rc = comm->c_coll.coll_allgather( myinfo, 2, MPI_INT, rresults, 2,
|
|
|
|
MPI_INT, comm );
|
2004-06-07 19:33:53 +04:00
|
|
|
if ( OMPI_SUCCESS != rc ) {
|
2004-05-22 00:06:20 +04:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* how many have the same color like me */
|
|
|
|
for ( my_rsize = 0, i=0; i < rsize; i++) {
|
2007-04-06 23:18:31 +04:00
|
|
|
if ( rresults[(2*i)+0] == color) {
|
|
|
|
my_rsize++;
|
|
|
|
}
|
2004-05-22 00:06:20 +04:00
|
|
|
}
|
|
|
|
rsorted = (int *) malloc ( sizeof( int ) * my_rsize * 2);
|
|
|
|
if ( NULL == rsorted) {
|
2004-06-07 19:33:53 +04:00
|
|
|
rc = OMPI_ERR_OUT_OF_RESOURCE;
|
2004-05-22 00:06:20 +04:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ok we can now fill this info */
|
|
|
|
for( loc = 0, i = 0; i < rsize; i++ ) {
|
|
|
|
if ( rresults[(2*i)+0] == color) {
|
|
|
|
rsorted[(2*loc)+0] = i; /* org rank */
|
|
|
|
rsorted[(2*loc)+1] = rresults[(2*i)+1]; /* key */
|
|
|
|
loc++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* the new array needs to be sorted so that it is in 'key' order */
|
|
|
|
/* if two keys are equal then it is sorted in original rank order! */
|
|
|
|
if(my_rsize>1) {
|
|
|
|
qsort ((int*)rsorted, my_rsize, sizeof(int)*2, rankkeycompare);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* put group elements in a list */
|
2004-06-07 19:33:53 +04:00
|
|
|
rprocs = (ompi_proc_t **) malloc ( sizeof(ompi_proc_t *) * my_rsize);
|
2007-07-30 19:41:41 +04:00
|
|
|
if ( NULL == rprocs ) {
|
2004-06-07 19:33:53 +04:00
|
|
|
rc = OMPI_ERR_OUT_OF_RESOURCE;
|
2004-05-22 00:06:20 +04:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
for (i = 0; i < my_rsize; i++) {
|
|
|
|
rprocs[i] = comm->c_remote_group->grp_proc_pointers[rsorted[i*2]];
|
|
|
|
}
|
2004-06-17 02:37:03 +04:00
|
|
|
mode = OMPI_COMM_CID_INTER;
|
2007-04-06 23:18:31 +04:00
|
|
|
} else {
|
2004-05-22 00:06:20 +04:00
|
|
|
my_rsize = 0;
|
2004-08-08 01:15:00 +04:00
|
|
|
rprocs = NULL;
|
|
|
|
mode = OMPI_COMM_CID_INTRA;
|
2004-05-22 00:06:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Step 3: set up the communicator */
|
|
|
|
/* --------------------------------------------------------- */
|
|
|
|
/* Create the communicator finally */
|
2004-08-04 02:07:45 +04:00
|
|
|
newcomp = ompi_comm_allocate (my_size, my_rsize );
|
|
|
|
if ( NULL == newcomp ) {
|
2004-06-16 19:40:52 +04:00
|
|
|
rc = MPI_ERR_INTERN;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Determine context id. It is identical to f_2_c_handle */
|
2004-06-17 02:37:03 +04:00
|
|
|
rc = ompi_comm_nextcid ( newcomp, /* new communicator */
|
|
|
|
comm, /* old comm */
|
|
|
|
NULL, /* bridge comm */
|
|
|
|
NULL, /* local leader */
|
|
|
|
NULL, /* remote_leader */
|
2004-08-05 20:31:30 +04:00
|
|
|
mode, /* mode */
|
|
|
|
-1 ); /* send first, doesn't matter */
|
2004-06-16 19:40:52 +04:00
|
|
|
if ( OMPI_SUCCESS != rc ) {
|
|
|
|
goto exit;
|
|
|
|
}
|
2004-05-22 00:06:20 +04:00
|
|
|
|
2004-08-04 02:07:45 +04:00
|
|
|
rc = ompi_comm_set ( newcomp, /* new comm */
|
|
|
|
comm, /* old comm */
|
|
|
|
my_size, /* local_size */
|
|
|
|
procs, /* local_procs*/
|
|
|
|
my_rsize, /* remote_size */
|
|
|
|
rprocs, /* remote_procs */
|
|
|
|
NULL, /* attrs */
|
|
|
|
comm->error_handler,/* error handler */
|
2004-10-07 23:14:27 +04:00
|
|
|
(pass_on_topo)?
|
|
|
|
(mca_base_component_t *)comm->c_topo_component:
|
|
|
|
NULL); /* topo component */
|
|
|
|
|
2004-08-04 02:07:45 +04:00
|
|
|
if ( OMPI_SUCCESS != rc ) {
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2006-04-16 05:34:34 +04:00
|
|
|
/* Set name for debugging purposes */
|
|
|
|
snprintf(newcomp->c_name, MPI_MAX_OBJECT_NAME, "MPI COMMUNICATOR %d SPLIT FROM %d",
|
|
|
|
newcomp->c_contextid, comm->c_contextid );
|
|
|
|
|
2004-08-05 20:31:30 +04:00
|
|
|
/* Activate the communicator and init coll-component */
|
|
|
|
rc = ompi_comm_activate ( newcomp, /* new communicator */
|
2007-04-06 23:18:31 +04:00
|
|
|
comm, /* old comm */
|
|
|
|
NULL, /* bridge comm */
|
|
|
|
NULL, /* local leader */
|
|
|
|
NULL, /* remote_leader */
|
|
|
|
mode, /* mode */
|
|
|
|
-1, /* send first */
|
|
|
|
0, /* sync_flag */
|
|
|
|
NULL ); /* coll component */
|
2004-08-05 20:31:30 +04:00
|
|
|
|
|
|
|
if ( OMPI_SUCCESS != rc ) {
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2004-08-04 02:07:45 +04:00
|
|
|
|
2004-05-22 00:06:20 +04:00
|
|
|
exit:
|
|
|
|
if ( NULL != results ) {
|
|
|
|
free ( results );
|
|
|
|
}
|
|
|
|
if ( NULL != sorted ) {
|
|
|
|
free ( sorted );
|
|
|
|
}
|
|
|
|
if ( NULL != rresults) {
|
|
|
|
free ( rresults );
|
|
|
|
}
|
|
|
|
if ( NULL != rsorted ) {
|
|
|
|
free ( rsorted );
|
|
|
|
}
|
|
|
|
if ( NULL != procs ) {
|
|
|
|
free ( procs );
|
|
|
|
}
|
|
|
|
if ( NULL != rprocs ) {
|
|
|
|
free ( rprocs );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Step 4: if we are not part of the comm, free the struct */
|
|
|
|
/* --------------------------------------------------------- */
|
|
|
|
if ( MPI_UNDEFINED == color ) {
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_comm_free ( &newcomp );
|
2004-05-22 00:06:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
*newcomm = newcomp;
|
|
|
|
return ( rc );
|
|
|
|
}
|
2004-06-16 01:29:29 +04:00
|
|
|
/**********************************************************************/
|
|
|
|
/**********************************************************************/
|
|
|
|
/**********************************************************************/
|
2007-03-27 06:06:42 +04:00
|
|
|
int ompi_comm_dup ( ompi_communicator_t * comm, ompi_communicator_t **newcomm,
|
2007-04-06 23:18:31 +04:00
|
|
|
int sync_flag)
|
2005-06-27 12:32:18 +04:00
|
|
|
{
|
|
|
|
ompi_communicator_t *comp=NULL;
|
|
|
|
ompi_communicator_t *newcomp=NULL;
|
|
|
|
int rsize, mode, rc=MPI_SUCCESS;
|
|
|
|
ompi_proc_t **rprocs;
|
|
|
|
|
|
|
|
comp = (ompi_communicator_t *) comm;
|
|
|
|
if ( OMPI_COMM_IS_INTER ( comp ) ){
|
|
|
|
rsize = comp->c_remote_group->grp_proc_count;
|
|
|
|
rprocs = comp->c_remote_group->grp_proc_pointers;
|
|
|
|
mode = OMPI_COMM_CID_INTER;
|
2007-04-06 23:18:31 +04:00
|
|
|
} else {
|
2005-06-27 12:32:18 +04:00
|
|
|
rsize = 0;
|
|
|
|
rprocs = NULL;
|
|
|
|
mode = OMPI_COMM_CID_INTRA;
|
|
|
|
}
|
|
|
|
|
|
|
|
*newcomm = MPI_COMM_NULL;
|
|
|
|
newcomp = ompi_comm_allocate (comp->c_local_group->grp_proc_count, rsize );
|
|
|
|
if ( NULL == newcomp ) {
|
|
|
|
return MPI_ERR_INTERN;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Determine context id. It is identical to f_2_c_handle */
|
|
|
|
rc = ompi_comm_nextcid ( newcomp, /* new communicator */
|
|
|
|
comp, /* old comm */
|
|
|
|
NULL, /* bridge comm */
|
|
|
|
NULL, /* local leader */
|
|
|
|
NULL, /* remote_leader */
|
|
|
|
mode, /* mode */
|
|
|
|
-1 ); /* send_first */
|
|
|
|
if ( MPI_SUCCESS != rc ) {
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
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*/
|
|
|
|
rsize, /* remote_size */
|
|
|
|
rprocs, /* remote_procs */
|
|
|
|
comp->c_keyhash, /* attrs */
|
|
|
|
comp->error_handler, /* error handler */
|
2007-04-06 23:18:31 +04:00
|
|
|
(mca_base_component_t *) comp->c_topo_component /* topo component */
|
2005-06-27 12:32:18 +04:00
|
|
|
);
|
|
|
|
if ( MPI_SUCCESS != rc) {
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2006-04-16 05:34:34 +04:00
|
|
|
/* Set name for debugging purposes */
|
|
|
|
snprintf(newcomp->c_name, MPI_MAX_OBJECT_NAME, "MPI COMMUNICATOR %d DUP FROM %d",
|
|
|
|
newcomp->c_contextid, comm->c_contextid );
|
|
|
|
|
2007-03-27 06:06:42 +04:00
|
|
|
if(0 == sync_flag) {
|
2007-04-06 23:18:31 +04:00
|
|
|
/* activate communicator and init coll-module */
|
|
|
|
rc = ompi_comm_activate (newcomp, /* new communicator */
|
|
|
|
comp, /* old comm */
|
|
|
|
NULL, /* bridge comm */
|
|
|
|
NULL, /* local leader */
|
|
|
|
NULL, /* remote_leader */
|
|
|
|
mode, /* mode */
|
|
|
|
-1, /* send_first */
|
|
|
|
0, /* sync_flag */
|
|
|
|
(mca_base_component_t *) comp->c_coll_selected_component /* coll component */
|
|
|
|
);
|
|
|
|
if ( MPI_SUCCESS != rc ) {
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* activate communicator and init coll-module without synchronizing processes*/
|
|
|
|
rc = ompi_comm_activate (newcomp, /* new communicator */
|
|
|
|
comp, /* old comm */
|
|
|
|
NULL, /* bridge comm */
|
|
|
|
NULL, /* local leader */
|
|
|
|
NULL, /* remote_leader */
|
|
|
|
mode, /* mode */
|
|
|
|
-1, /* send_first */
|
|
|
|
1, /* sync_flag */
|
|
|
|
(mca_base_component_t *) comp->c_coll_selected_component /* coll component */
|
|
|
|
);
|
|
|
|
if ( MPI_SUCCESS != rc ) {
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2005-06-27 12:32:18 +04:00
|
|
|
}
|
|
|
|
|
2005-06-28 02:48:51 +04:00
|
|
|
*newcomm = newcomp;
|
2005-06-27 12:32:18 +04:00
|
|
|
return MPI_SUCCESS;
|
|
|
|
}
|
|
|
|
/**********************************************************************/
|
|
|
|
/**********************************************************************/
|
|
|
|
/**********************************************************************/
|
2004-08-04 23:46:29 +04:00
|
|
|
int ompi_comm_set_name (ompi_communicator_t *comm, char *name )
|
|
|
|
{
|
|
|
|
|
2004-08-04 23:55:45 +04:00
|
|
|
#ifdef USE_MUTEX_FOR_COMMS
|
2005-07-04 02:45:48 +04:00
|
|
|
OPAL_THREAD_LOCK(&(comm->c_lock));
|
2004-08-04 23:55:45 +04:00
|
|
|
#endif
|
2004-08-04 23:46:29 +04:00
|
|
|
memset(comm->c_name, 0, MPI_MAX_OBJECT_NAME);
|
|
|
|
strncpy(comm->c_name, name, MPI_MAX_OBJECT_NAME);
|
|
|
|
comm->c_name[MPI_MAX_OBJECT_NAME - 1] = 0;
|
|
|
|
comm->c_flags |= OMPI_COMM_NAMEISSET;
|
2004-08-04 23:55:45 +04:00
|
|
|
#ifdef USE_MUTEX_FOR_COMMS
|
2005-07-04 02:45:48 +04:00
|
|
|
OPAL_THREAD_UNLOCK(&(comm->c_lock));
|
2004-08-04 23:55:45 +04:00
|
|
|
#endif
|
2004-08-04 23:46:29 +04:00
|
|
|
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
/**********************************************************************/
|
|
|
|
/**********************************************************************/
|
|
|
|
/**********************************************************************/
|
2004-06-16 01:29:29 +04:00
|
|
|
/*
|
|
|
|
* Implementation of MPI_Allgather for the local_group in an inter-comm.
|
|
|
|
* The algorithm consists of two steps:
|
|
|
|
* 1. an inter-gather to rank 0 in remote group
|
|
|
|
* 2. an inter-bcast from rank 0 in remote_group.
|
|
|
|
*/
|
2004-05-22 00:06:20 +04:00
|
|
|
|
2004-06-16 01:29:29 +04:00
|
|
|
static int ompi_comm_allgather_emulate_intra( void *inbuf, int incount,
|
|
|
|
MPI_Datatype intype, void* outbuf,
|
|
|
|
int outcount, MPI_Datatype outtype,
|
|
|
|
ompi_communicator_t *comm)
|
|
|
|
{
|
2006-05-04 01:41:10 +04:00
|
|
|
int rank, size, rsize, i, rc;
|
2004-06-16 01:29:29 +04:00
|
|
|
int *tmpbuf=NULL;
|
|
|
|
MPI_Request *req=NULL, sendreq;
|
|
|
|
|
|
|
|
rsize = ompi_comm_remote_size(comm);
|
2006-05-04 01:41:10 +04:00
|
|
|
size = ompi_comm_size(comm);
|
2004-06-16 01:29:29 +04:00
|
|
|
rank = ompi_comm_rank(comm);
|
|
|
|
|
|
|
|
/* Step 1: the gather-step */
|
|
|
|
if ( 0 == rank ) {
|
|
|
|
tmpbuf = (int *) malloc (rsize*outcount*sizeof(int));
|
|
|
|
req = (MPI_Request *)malloc (rsize*outcount*sizeof(MPI_Request));
|
2004-08-04 02:07:45 +04:00
|
|
|
if ( NULL == tmpbuf || NULL == req ) {
|
2004-06-16 01:29:29 +04:00
|
|
|
return (OMPI_ERR_OUT_OF_RESOURCE);
|
|
|
|
}
|
|
|
|
|
|
|
|
for ( i=0; i<rsize; i++) {
|
2005-04-13 07:19:48 +04:00
|
|
|
rc = MCA_PML_CALL(irecv( &tmpbuf[outcount*i], outcount, outtype, i,
|
|
|
|
OMPI_COMM_ALLGATHER_TAG, comm, &req[i] ));
|
2004-06-16 01:29:29 +04:00
|
|
|
if ( OMPI_SUCCESS != rc ) {
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-04-13 07:19:48 +04:00
|
|
|
rc = MCA_PML_CALL(isend( inbuf, incount, intype, 0, OMPI_COMM_ALLGATHER_TAG,
|
|
|
|
MCA_PML_BASE_SEND_STANDARD, comm, &sendreq ));
|
2004-06-16 01:29:29 +04:00
|
|
|
if ( OMPI_SUCCESS != rc ) {
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( 0 == rank ) {
|
2004-10-12 19:50:01 +04:00
|
|
|
rc = ompi_request_wait_all (rsize, req, MPI_STATUSES_IGNORE);
|
2004-06-16 01:29:29 +04:00
|
|
|
if ( OMPI_SUCCESS != rc ) {
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-10-12 19:50:01 +04:00
|
|
|
rc = ompi_request_wait_all (1, &sendreq, MPI_STATUS_IGNORE);
|
2004-06-16 01:29:29 +04:00
|
|
|
if ( OMPI_SUCCESS != rc ) {
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Step 2: the inter-bcast step */
|
2006-05-04 01:41:10 +04:00
|
|
|
rc = MCA_PML_CALL(irecv (outbuf, size*outcount, outtype, 0,
|
2005-04-13 07:19:48 +04:00
|
|
|
OMPI_COMM_ALLGATHER_TAG, comm, &sendreq));
|
2004-06-16 01:29:29 +04:00
|
|
|
if ( OMPI_SUCCESS != rc ) {
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( 0 == rank ) {
|
|
|
|
for ( i=0; i < rsize; i++ ){
|
2005-04-13 07:19:48 +04:00
|
|
|
rc = MCA_PML_CALL(send (tmpbuf, rsize*outcount, outtype, i,
|
2004-06-16 01:29:29 +04:00
|
|
|
OMPI_COMM_ALLGATHER_TAG,
|
2005-04-13 07:19:48 +04:00
|
|
|
MCA_PML_BASE_SEND_STANDARD, comm));
|
2004-06-16 01:29:29 +04:00
|
|
|
if ( OMPI_SUCCESS != rc ) {
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-10-12 19:50:01 +04:00
|
|
|
rc = ompi_request_wait_all (1, &sendreq, MPI_STATUS_IGNORE );
|
2004-06-16 01:29:29 +04:00
|
|
|
|
|
|
|
exit:
|
|
|
|
if ( NULL != req ) {
|
|
|
|
free ( req );
|
|
|
|
}
|
|
|
|
if ( NULL != tmpbuf ) {
|
|
|
|
free ( tmpbuf );
|
|
|
|
}
|
|
|
|
|
|
|
|
return (rc);
|
|
|
|
}
|
2004-05-22 00:06:20 +04:00
|
|
|
/**********************************************************************/
|
|
|
|
/**********************************************************************/
|
|
|
|
/**********************************************************************/
|
|
|
|
/*
|
2004-06-07 19:33:53 +04:00
|
|
|
** Counterpart to MPI_Comm_free. To be used within OMPI.
|
2004-05-22 00:06:20 +04:00
|
|
|
** The freeing of all attached objects (groups, errhandlers
|
|
|
|
** etc. ) has moved to the destructor.
|
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
int ompi_comm_free ( ompi_communicator_t **comm )
|
2004-05-22 00:06:20 +04:00
|
|
|
{
|
2004-10-21 02:54:34 +04:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* Release attributes. We do this now instead of during the
|
|
|
|
communicator destructor for 2 reasons:
|
|
|
|
|
|
|
|
1. The destructor will only NOT be called immediately during
|
|
|
|
ompi_comm_free() if the reference count is still greater
|
|
|
|
than zero at that point, meaning that there are ongoing
|
|
|
|
communications. However, pending communications will never
|
|
|
|
need attributes, so it's safe to release them directly here.
|
|
|
|
|
|
|
|
2. Releasing attributes in ompi_comm_free() enables us to check
|
|
|
|
the return status of the attribute delete functions. At
|
|
|
|
least one interpretation of the MPI standard (i.e., the one
|
|
|
|
of the Intel test suite) is that if any of the attribute
|
|
|
|
deletion functions fail, then MPI_COMM_FREE /
|
|
|
|
MPI_COMM_DISCONNECT should also fail. We can't do that if
|
|
|
|
we delay releasing the attributes -- we need to release the
|
|
|
|
attributes right away so that we can report the error right
|
|
|
|
away. */
|
2007-03-27 06:06:42 +04:00
|
|
|
if ( OMPI_COMM_IS_INTER(*comm) ) {
|
2007-04-06 23:18:31 +04:00
|
|
|
ompi_comm_free (&(*comm)->c_local_comm);
|
2007-03-27 06:06:42 +04:00
|
|
|
}
|
2004-10-21 02:54:34 +04:00
|
|
|
|
|
|
|
if (NULL != (*comm)->c_keyhash) {
|
|
|
|
ret = ompi_attr_delete_all(COMM_ATTR, *comm, (*comm)->c_keyhash);
|
|
|
|
if (OMPI_SUCCESS != ret) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
OBJ_RELEASE((*comm)->c_keyhash);
|
|
|
|
}
|
|
|
|
|
2004-11-08 08:04:54 +03:00
|
|
|
/* Special case: if we are freeing the parent handle, then we need
|
|
|
|
to set our internal handle to the parent to be equal to
|
|
|
|
COMM_NULL. This is according to MPI-2:88-89. */
|
|
|
|
|
2004-11-08 15:48:57 +03:00
|
|
|
if (*comm == ompi_mpi_comm_parent && comm != &ompi_mpi_comm_parent) {
|
2004-11-08 08:04:54 +03:00
|
|
|
ompi_mpi_comm_parent = &ompi_mpi_comm_null;
|
|
|
|
}
|
|
|
|
|
2004-05-22 00:06:20 +04:00
|
|
|
/* Release the communicator */
|
2005-04-18 22:57:24 +04:00
|
|
|
if ( OMPI_COMM_IS_DYNAMIC (*comm) ) {
|
2007-04-06 23:18:31 +04:00
|
|
|
ompi_comm_num_dyncomm --;
|
2005-04-18 22:57:24 +04:00
|
|
|
}
|
2004-07-14 23:33:07 +04:00
|
|
|
OBJ_RELEASE ( (*comm) );
|
2004-05-22 00:06:20 +04:00
|
|
|
|
|
|
|
*comm = MPI_COMM_NULL;
|
2004-06-07 19:33:53 +04:00
|
|
|
return OMPI_SUCCESS;
|
2004-05-22 00:06:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************/
|
|
|
|
/**********************************************************************/
|
|
|
|
/**********************************************************************/
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_proc_t **ompi_comm_get_rprocs ( ompi_communicator_t *local_comm,
|
2004-08-04 02:07:45 +04:00
|
|
|
ompi_communicator_t *bridge_comm,
|
|
|
|
int local_leader,
|
|
|
|
int remote_leader,
|
2005-03-14 23:57:21 +03:00
|
|
|
orte_rml_tag_t tag,
|
2004-08-04 02:07:45 +04:00
|
|
|
int rsize)
|
2004-05-22 00:06:20 +04:00
|
|
|
{
|
2004-08-04 21:06:33 +04:00
|
|
|
|
|
|
|
MPI_Request req;
|
|
|
|
int rc;
|
2004-05-22 00:06:20 +04:00
|
|
|
int local_rank, local_size;
|
2004-08-04 02:07:45 +04:00
|
|
|
ompi_proc_t **rprocs=NULL;
|
2006-08-15 23:54:10 +04:00
|
|
|
orte_std_cntr_t size_len;
|
In comm.c, one of the few places where OMPI and ORTE interact, we have
a clash of APIs -- MPI requires int's, but the ORTE DPS requires
size_t's. Specifically, we need to orte_dps.unload(), which fills a
size_t. We then need to PML send (i.e., MPI_Send) that value around.
However, there's no such thing as MPI_SIZE_T as a datatype, and that
would hose us in heterogeneous situations, anyway. So the compromise
was to make ompi_sizet2int(), a function what does the [potenial]
downcast. On 32 bit architectures, this is no big deal -- it's a
simple assignment. On 64 bit architectures (or, more specifically,
where sizeof(size_t) > sizeof(int)), it does the dowcast in a
compiler-safe manner, and does a check to see if we truncated. If we
truncated, in a developer build, we'll abort(). If this is not a
developer build, print out a nasty warning.
The rationale here is as followes:
- this is a clash of the API's. There's unfortunately nothing that we
can do about this at the moment.
- hence, we have to do the downcast.
- but we might as well be "safe" about it -- assuming that
orte_dps.unload() never gives us back a value >sizeof(int) (which is
a pretty safe assumption -- if we get that large of a value, we have
other problems, or we're on fundamentally different types of
hardware and I suspect a lot of the rest of the code base will have
problems as well!), we should be able to downcast safely.
- if there is a mistake in code somewhere such that:
- we can't downcast safely (i.e., we legitmately have a size_t value
that is too large for an int)
- we truncate when the value should not have been that large
the conversion function will detect this and print out an error. So
we won't silently introduce any new errors into the code base --
they will be loud and obvious.
- although comm.c is currently the only place where we need this, I
suspect that there will be a small number of other places where
similar situations occur. I intend to bring this right over to the
trunk, so it was simpler to make this functionality be a subroutine
so that we can use it elsewhere if/when necessary.
Final note: src/attribute/attribute.c does something *similar*
(downcasting when sizeof(void*) > sizeof(int), but is different enough
that it would have been painful to make one unified interface. This
does not rule it out for the future, however (especially if we find
more places in the tree that need this kind of functionality).
This commit was SVN r6246.
2005-07-01 01:30:18 +04:00
|
|
|
int int_len, rlen;
|
2005-03-14 23:57:21 +03:00
|
|
|
orte_buffer_t *sbuf=NULL, *rbuf=NULL;
|
2004-09-16 14:07:42 +04:00
|
|
|
void *sendbuf;
|
|
|
|
char *recvbuf;
|
2004-05-22 00:06:20 +04:00
|
|
|
|
2004-08-04 02:07:45 +04:00
|
|
|
local_rank = ompi_comm_rank (local_comm);
|
2004-08-04 21:06:33 +04:00
|
|
|
local_size = ompi_comm_size (local_comm);
|
2004-08-04 02:07:45 +04:00
|
|
|
|
|
|
|
if (local_rank == local_leader) {
|
2005-03-14 23:57:21 +03:00
|
|
|
sbuf = OBJ_NEW(orte_buffer_t);
|
|
|
|
if (NULL == sbuf) {
|
|
|
|
rc = ORTE_ERROR;
|
|
|
|
goto err_exit;
|
|
|
|
}
|
2004-09-16 14:07:42 +04:00
|
|
|
|
Clean up the way procs are added to the global process list after MPI_INIT:
* Do not add new procs to the global list during modex callback or
when sharing orte names during accept/connect. For modex, we
cache the modex info for later, in case that proc ever does get
added to the global proc list. For accept/connect orte name
exchange between the roots, we only need the orte name, so no
need to add a proc structure anyway. The procs will be added
to the global process list during the proc exchange later in
the wireup process
* Rename proc_get_namebuf and proc_get_proclist to proc_pack
and proc_unpack and extend them to include all information
needed to build that proc struct on a remote node (which
includes ORTE name, architecture, and hostname). Change
unpack to call pml_add_procs for the entire list of new
procs at once, rather than one at a time.
* Remove ompi_proc_find_and_add from the public proc
interface and make it a private function. This function
would add a half-created proc to the global proc list, so
making it harder to call is a good thing.
This means that there's only two ways to add new procs into the global proc list at this time: During MPI_INIT via the call to ompi_proc_init, where my job is added to the list and via ompi_proc_unpack using a buffer from a packed proc list sent to us by someone else. Currently, this is enough to implement MPI semantics. We can extend the interface more if we like, but that may require HNP communication to get the remote proc information and I wanted to avoid that if at all possible.
Refs trac:564
This commit was SVN r12798.
The following Trac tickets were found above:
Ticket 564 --> https://svn.open-mpi.org/trac/ompi/ticket/564
2006-12-07 22:56:54 +03:00
|
|
|
rc = ompi_proc_pack(local_comm->c_local_group->grp_proc_pointers,
|
|
|
|
local_size, sbuf);
|
2004-08-04 21:06:33 +04:00
|
|
|
if ( OMPI_SUCCESS != rc ) {
|
2004-08-04 02:07:45 +04:00
|
|
|
goto err_exit;
|
|
|
|
}
|
2006-02-07 06:32:36 +03:00
|
|
|
if (ORTE_SUCCESS != (rc = orte_dss.unload(sbuf, &sendbuf, &size_len))) {
|
2005-03-14 23:57:21 +03:00
|
|
|
goto err_exit;
|
In comm.c, one of the few places where OMPI and ORTE interact, we have
a clash of APIs -- MPI requires int's, but the ORTE DPS requires
size_t's. Specifically, we need to orte_dps.unload(), which fills a
size_t. We then need to PML send (i.e., MPI_Send) that value around.
However, there's no such thing as MPI_SIZE_T as a datatype, and that
would hose us in heterogeneous situations, anyway. So the compromise
was to make ompi_sizet2int(), a function what does the [potenial]
downcast. On 32 bit architectures, this is no big deal -- it's a
simple assignment. On 64 bit architectures (or, more specifically,
where sizeof(size_t) > sizeof(int)), it does the dowcast in a
compiler-safe manner, and does a check to see if we truncated. If we
truncated, in a developer build, we'll abort(). If this is not a
developer build, print out a nasty warning.
The rationale here is as followes:
- this is a clash of the API's. There's unfortunately nothing that we
can do about this at the moment.
- hence, we have to do the downcast.
- but we might as well be "safe" about it -- assuming that
orte_dps.unload() never gives us back a value >sizeof(int) (which is
a pretty safe assumption -- if we get that large of a value, we have
other problems, or we're on fundamentally different types of
hardware and I suspect a lot of the rest of the code base will have
problems as well!), we should be able to downcast safely.
- if there is a mistake in code somewhere such that:
- we can't downcast safely (i.e., we legitmately have a size_t value
that is too large for an int)
- we truncate when the value should not have been that large
the conversion function will detect this and print out an error. So
we won't silently introduce any new errors into the code base --
they will be loud and obvious.
- although comm.c is currently the only place where we need this, I
suspect that there will be a small number of other places where
similar situations occur. I intend to bring this right over to the
trunk, so it was simpler to make this functionality be a subroutine
so that we can use it elsewhere if/when necessary.
Final note: src/attribute/attribute.c does something *similar*
(downcasting when sizeof(void*) > sizeof(int), but is different enough
that it would have been painful to make one unified interface. This
does not rule it out for the future, however (especially if we find
more places in the tree that need this kind of functionality).
This commit was SVN r6246.
2005-07-01 01:30:18 +04:00
|
|
|
}
|
2007-04-06 23:18:31 +04:00
|
|
|
|
2004-08-04 21:06:33 +04:00
|
|
|
/* send the remote_leader the length of the buffer */
|
2005-04-13 07:19:48 +04:00
|
|
|
rc = MCA_PML_CALL(irecv (&rlen, 1, MPI_INT, remote_leader, tag,
|
In comm.c, one of the few places where OMPI and ORTE interact, we have
a clash of APIs -- MPI requires int's, but the ORTE DPS requires
size_t's. Specifically, we need to orte_dps.unload(), which fills a
size_t. We then need to PML send (i.e., MPI_Send) that value around.
However, there's no such thing as MPI_SIZE_T as a datatype, and that
would hose us in heterogeneous situations, anyway. So the compromise
was to make ompi_sizet2int(), a function what does the [potenial]
downcast. On 32 bit architectures, this is no big deal -- it's a
simple assignment. On 64 bit architectures (or, more specifically,
where sizeof(size_t) > sizeof(int)), it does the dowcast in a
compiler-safe manner, and does a check to see if we truncated. If we
truncated, in a developer build, we'll abort(). If this is not a
developer build, print out a nasty warning.
The rationale here is as followes:
- this is a clash of the API's. There's unfortunately nothing that we
can do about this at the moment.
- hence, we have to do the downcast.
- but we might as well be "safe" about it -- assuming that
orte_dps.unload() never gives us back a value >sizeof(int) (which is
a pretty safe assumption -- if we get that large of a value, we have
other problems, or we're on fundamentally different types of
hardware and I suspect a lot of the rest of the code base will have
problems as well!), we should be able to downcast safely.
- if there is a mistake in code somewhere such that:
- we can't downcast safely (i.e., we legitmately have a size_t value
that is too large for an int)
- we truncate when the value should not have been that large
the conversion function will detect this and print out an error. So
we won't silently introduce any new errors into the code base --
they will be loud and obvious.
- although comm.c is currently the only place where we need this, I
suspect that there will be a small number of other places where
similar situations occur. I intend to bring this right over to the
trunk, so it was simpler to make this functionality be a subroutine
so that we can use it elsewhere if/when necessary.
Final note: src/attribute/attribute.c does something *similar*
(downcasting when sizeof(void*) > sizeof(int), but is different enough
that it would have been painful to make one unified interface. This
does not rule it out for the future, however (especially if we find
more places in the tree that need this kind of functionality).
This commit was SVN r6246.
2005-07-01 01:30:18 +04:00
|
|
|
bridge_comm, &req ));
|
2004-08-04 21:06:33 +04:00
|
|
|
if ( OMPI_SUCCESS != rc ) {
|
|
|
|
goto err_exit;
|
|
|
|
}
|
2006-08-15 23:54:10 +04:00
|
|
|
int_len = (int)size_len;
|
2005-07-09 01:57:04 +04:00
|
|
|
|
In comm.c, one of the few places where OMPI and ORTE interact, we have
a clash of APIs -- MPI requires int's, but the ORTE DPS requires
size_t's. Specifically, we need to orte_dps.unload(), which fills a
size_t. We then need to PML send (i.e., MPI_Send) that value around.
However, there's no such thing as MPI_SIZE_T as a datatype, and that
would hose us in heterogeneous situations, anyway. So the compromise
was to make ompi_sizet2int(), a function what does the [potenial]
downcast. On 32 bit architectures, this is no big deal -- it's a
simple assignment. On 64 bit architectures (or, more specifically,
where sizeof(size_t) > sizeof(int)), it does the dowcast in a
compiler-safe manner, and does a check to see if we truncated. If we
truncated, in a developer build, we'll abort(). If this is not a
developer build, print out a nasty warning.
The rationale here is as followes:
- this is a clash of the API's. There's unfortunately nothing that we
can do about this at the moment.
- hence, we have to do the downcast.
- but we might as well be "safe" about it -- assuming that
orte_dps.unload() never gives us back a value >sizeof(int) (which is
a pretty safe assumption -- if we get that large of a value, we have
other problems, or we're on fundamentally different types of
hardware and I suspect a lot of the rest of the code base will have
problems as well!), we should be able to downcast safely.
- if there is a mistake in code somewhere such that:
- we can't downcast safely (i.e., we legitmately have a size_t value
that is too large for an int)
- we truncate when the value should not have been that large
the conversion function will detect this and print out an error. So
we won't silently introduce any new errors into the code base --
they will be loud and obvious.
- although comm.c is currently the only place where we need this, I
suspect that there will be a small number of other places where
similar situations occur. I intend to bring this right over to the
trunk, so it was simpler to make this functionality be a subroutine
so that we can use it elsewhere if/when necessary.
Final note: src/attribute/attribute.c does something *similar*
(downcasting when sizeof(void*) > sizeof(int), but is different enough
that it would have been painful to make one unified interface. This
does not rule it out for the future, however (especially if we find
more places in the tree that need this kind of functionality).
This commit was SVN r6246.
2005-07-01 01:30:18 +04:00
|
|
|
rc = MCA_PML_CALL(send (&int_len, 1, MPI_INT, remote_leader, tag,
|
|
|
|
MCA_PML_BASE_SEND_STANDARD, bridge_comm ));
|
2004-08-04 21:06:33 +04:00
|
|
|
if ( OMPI_SUCCESS != rc ) {
|
|
|
|
goto err_exit;
|
|
|
|
}
|
2004-10-12 19:50:01 +04:00
|
|
|
rc = ompi_request_wait_all ( 1, &req, MPI_STATUS_IGNORE );
|
2004-08-04 21:06:33 +04:00
|
|
|
if ( OMPI_SUCCESS != rc ) {
|
|
|
|
goto err_exit;
|
2004-05-22 00:06:20 +04:00
|
|
|
}
|
|
|
|
|
2004-08-04 21:06:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* broadcast buffer length to all processes in local_comm */
|
|
|
|
rc = local_comm->c_coll.coll_bcast( &rlen, 1, MPI_INT,
|
|
|
|
local_leader, local_comm );
|
|
|
|
if ( OMPI_SUCCESS != rc ) {
|
|
|
|
goto err_exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate temporary buffer */
|
2004-09-16 14:07:42 +04:00
|
|
|
recvbuf = (char *)malloc(rlen);
|
|
|
|
if ( NULL == recvbuf ) {
|
2007-04-06 23:18:31 +04:00
|
|
|
goto err_exit;
|
2004-08-04 21:06:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( local_rank == local_leader ) {
|
|
|
|
/* local leader exchange name lists */
|
2005-04-13 07:19:48 +04:00
|
|
|
rc = MCA_PML_CALL(irecv (recvbuf, rlen, MPI_BYTE, remote_leader, tag,
|
|
|
|
bridge_comm, &req ));
|
2004-08-04 21:06:33 +04:00
|
|
|
if ( OMPI_SUCCESS != rc ) {
|
2004-05-22 00:06:20 +04:00
|
|
|
goto err_exit;
|
|
|
|
}
|
In comm.c, one of the few places where OMPI and ORTE interact, we have
a clash of APIs -- MPI requires int's, but the ORTE DPS requires
size_t's. Specifically, we need to orte_dps.unload(), which fills a
size_t. We then need to PML send (i.e., MPI_Send) that value around.
However, there's no such thing as MPI_SIZE_T as a datatype, and that
would hose us in heterogeneous situations, anyway. So the compromise
was to make ompi_sizet2int(), a function what does the [potenial]
downcast. On 32 bit architectures, this is no big deal -- it's a
simple assignment. On 64 bit architectures (or, more specifically,
where sizeof(size_t) > sizeof(int)), it does the dowcast in a
compiler-safe manner, and does a check to see if we truncated. If we
truncated, in a developer build, we'll abort(). If this is not a
developer build, print out a nasty warning.
The rationale here is as followes:
- this is a clash of the API's. There's unfortunately nothing that we
can do about this at the moment.
- hence, we have to do the downcast.
- but we might as well be "safe" about it -- assuming that
orte_dps.unload() never gives us back a value >sizeof(int) (which is
a pretty safe assumption -- if we get that large of a value, we have
other problems, or we're on fundamentally different types of
hardware and I suspect a lot of the rest of the code base will have
problems as well!), we should be able to downcast safely.
- if there is a mistake in code somewhere such that:
- we can't downcast safely (i.e., we legitmately have a size_t value
that is too large for an int)
- we truncate when the value should not have been that large
the conversion function will detect this and print out an error. So
we won't silently introduce any new errors into the code base --
they will be loud and obvious.
- although comm.c is currently the only place where we need this, I
suspect that there will be a small number of other places where
similar situations occur. I intend to bring this right over to the
trunk, so it was simpler to make this functionality be a subroutine
so that we can use it elsewhere if/when necessary.
Final note: src/attribute/attribute.c does something *similar*
(downcasting when sizeof(void*) > sizeof(int), but is different enough
that it would have been painful to make one unified interface. This
does not rule it out for the future, however (especially if we find
more places in the tree that need this kind of functionality).
This commit was SVN r6246.
2005-07-01 01:30:18 +04:00
|
|
|
rc = MCA_PML_CALL(send(sendbuf, int_len, MPI_BYTE, remote_leader, tag,
|
2005-04-13 07:19:48 +04:00
|
|
|
MCA_PML_BASE_SEND_STANDARD, bridge_comm ));
|
2004-08-04 21:06:33 +04:00
|
|
|
if ( OMPI_SUCCESS != rc ) {
|
2004-05-22 00:06:20 +04:00
|
|
|
goto err_exit;
|
|
|
|
}
|
2004-10-12 19:50:01 +04:00
|
|
|
rc = ompi_request_wait_all ( 1, &req, MPI_STATUS_IGNORE );
|
2004-08-04 21:06:33 +04:00
|
|
|
if ( OMPI_SUCCESS != rc ) {
|
2004-05-22 00:06:20 +04:00
|
|
|
goto err_exit;
|
|
|
|
}
|
2004-08-04 21:06:33 +04:00
|
|
|
|
2007-04-06 23:18:31 +04:00
|
|
|
OBJ_RELEASE(sbuf);
|
2004-05-22 00:06:20 +04:00
|
|
|
}
|
|
|
|
|
2004-08-04 21:06:33 +04:00
|
|
|
/* broadcast name list to all proceses in local_comm */
|
2004-09-16 14:07:42 +04:00
|
|
|
rc = local_comm->c_coll.coll_bcast( recvbuf, rlen, MPI_BYTE,
|
2004-06-29 04:02:25 +04:00
|
|
|
local_leader, local_comm );
|
2004-08-04 21:06:33 +04:00
|
|
|
if ( OMPI_SUCCESS != rc ) {
|
2004-05-22 00:06:20 +04:00
|
|
|
goto err_exit;
|
|
|
|
}
|
2006-12-07 19:19:44 +03:00
|
|
|
|
|
|
|
rbuf = OBJ_NEW(orte_buffer_t);
|
|
|
|
if (NULL == rbuf) {
|
|
|
|
rc = ORTE_ERROR;
|
|
|
|
goto err_exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ORTE_SUCCESS != (rc = orte_dss.load(rbuf, recvbuf, rlen))) {
|
|
|
|
goto err_exit;
|
|
|
|
}
|
2004-05-22 00:06:20 +04:00
|
|
|
|
2004-08-04 21:06:33 +04:00
|
|
|
/* decode the names into a proc-list */
|
Clean up the way procs are added to the global process list after MPI_INIT:
* Do not add new procs to the global list during modex callback or
when sharing orte names during accept/connect. For modex, we
cache the modex info for later, in case that proc ever does get
added to the global proc list. For accept/connect orte name
exchange between the roots, we only need the orte name, so no
need to add a proc structure anyway. The procs will be added
to the global process list during the proc exchange later in
the wireup process
* Rename proc_get_namebuf and proc_get_proclist to proc_pack
and proc_unpack and extend them to include all information
needed to build that proc struct on a remote node (which
includes ORTE name, architecture, and hostname). Change
unpack to call pml_add_procs for the entire list of new
procs at once, rather than one at a time.
* Remove ompi_proc_find_and_add from the public proc
interface and make it a private function. This function
would add a half-created proc to the global proc list, so
making it harder to call is a good thing.
This means that there's only two ways to add new procs into the global proc list at this time: During MPI_INIT via the call to ompi_proc_init, where my job is added to the list and via ompi_proc_unpack using a buffer from a packed proc list sent to us by someone else. Currently, this is enough to implement MPI semantics. We can extend the interface more if we like, but that may require HNP communication to get the remote proc information and I wanted to avoid that if at all possible.
Refs trac:564
This commit was SVN r12798.
The following Trac tickets were found above:
Ticket 564 --> https://svn.open-mpi.org/trac/ompi/ticket/564
2006-12-07 22:56:54 +03:00
|
|
|
rc = ompi_proc_unpack(rbuf, rsize, &rprocs );
|
2005-03-14 23:57:21 +03:00
|
|
|
OBJ_RELEASE(rbuf);
|
2004-08-04 21:06:33 +04:00
|
|
|
|
2004-05-22 00:06:20 +04:00
|
|
|
err_exit:
|
2004-09-16 14:07:42 +04:00
|
|
|
/* rprocs isn't freed unless we have an error,
|
|
|
|
since it is used in the communicator */
|
2004-08-04 02:07:45 +04:00
|
|
|
if ( OMPI_SUCCESS !=rc ) {
|
2005-07-04 03:31:27 +04:00
|
|
|
opal_output(0, "%d: Error in ompi_get_rprocs\n", local_rank);
|
2004-08-04 02:07:45 +04:00
|
|
|
if ( NULL != rprocs ) {
|
2004-08-04 21:06:33 +04:00
|
|
|
free ( rprocs );
|
2004-08-04 02:07:45 +04:00
|
|
|
rprocs=NULL;
|
|
|
|
}
|
|
|
|
}
|
2005-03-14 23:57:21 +03:00
|
|
|
/* make sure the buffers have been released */
|
|
|
|
if (NULL != sbuf) {
|
|
|
|
OBJ_RELEASE(sbuf);
|
|
|
|
}
|
|
|
|
if (NULL != rbuf) {
|
|
|
|
OBJ_RELEASE(rbuf);
|
|
|
|
}
|
2004-08-04 02:07:45 +04:00
|
|
|
|
|
|
|
return rprocs;
|
2004-05-22 00:06:20 +04:00
|
|
|
}
|
|
|
|
/**********************************************************************/
|
|
|
|
/**********************************************************************/
|
2005-02-09 18:43:17 +03:00
|
|
|
/**********************************************************************/
|
2005-04-18 22:57:24 +04:00
|
|
|
/**
|
|
|
|
* This routine verifies, whether local_group and remote group are overlapping
|
|
|
|
* in intercomm_create
|
|
|
|
*/
|
|
|
|
int ompi_comm_overlapping_groups (int size, ompi_proc_t **lprocs,
|
2007-04-06 23:18:31 +04:00
|
|
|
int rsize, ompi_proc_t ** rprocs)
|
2005-02-09 18:43:17 +03:00
|
|
|
|
|
|
|
{
|
|
|
|
int rc=OMPI_SUCCESS;
|
|
|
|
int i,j;
|
|
|
|
|
|
|
|
for (i=0; i<size; i++) {
|
2005-09-13 00:36:04 +04:00
|
|
|
for ( j=0; j<rsize; j++) {
|
|
|
|
if ( lprocs[i] == rprocs[j] ) {
|
|
|
|
rc = MPI_ERR_COMM;
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
}
|
2005-02-09 18:43:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
/**********************************************************************/
|
|
|
|
/**********************************************************************/
|
2004-05-22 00:06:20 +04:00
|
|
|
/**********************************************************************/
|
2004-06-07 19:33:53 +04:00
|
|
|
int ompi_comm_determine_first ( ompi_communicator_t *intercomm, int high )
|
2004-05-22 00:06:20 +04:00
|
|
|
{
|
|
|
|
int flag, rhigh;
|
2004-08-04 02:07:45 +04:00
|
|
|
int rank, rsize;
|
|
|
|
int *rcounts;
|
2004-08-04 21:06:33 +04:00
|
|
|
int *rdisps;
|
2004-08-04 02:07:45 +04:00
|
|
|
int scount=0;
|
|
|
|
int rc;
|
2004-08-04 21:06:33 +04:00
|
|
|
ompi_proc_t *ourproc, *theirproc;
|
2005-03-14 23:57:21 +03:00
|
|
|
orte_ns_cmp_bitmask_t mask;
|
2004-08-04 02:07:45 +04:00
|
|
|
|
|
|
|
rank = ompi_comm_rank (intercomm);
|
|
|
|
rsize= ompi_comm_remote_size (intercomm);
|
|
|
|
|
2004-08-04 21:06:33 +04:00
|
|
|
rdisps = (int *) calloc ( rsize, sizeof(int));
|
|
|
|
rcounts = (int *) calloc ( rsize, sizeof(int));
|
2004-08-04 02:07:45 +04:00
|
|
|
if ( NULL == rdisps || NULL == rcounts ){
|
|
|
|
return OMPI_ERR_OUT_OF_RESOURCE;
|
2004-05-22 00:06:20 +04:00
|
|
|
}
|
2004-08-04 02:07:45 +04:00
|
|
|
|
|
|
|
rcounts[0] = 1;
|
|
|
|
if ( 0 == rank ) {
|
|
|
|
scount = 1;
|
|
|
|
}
|
|
|
|
|
2004-08-04 21:06:33 +04:00
|
|
|
rc = intercomm->c_coll.coll_allgatherv(&high, scount, MPI_INT,
|
2004-08-04 02:07:45 +04:00
|
|
|
&rhigh, rcounts, rdisps,
|
|
|
|
MPI_INT, intercomm);
|
|
|
|
if ( rc != OMPI_SUCCESS ) {
|
2004-08-04 21:06:33 +04:00
|
|
|
flag = MPI_UNDEFINED;
|
2004-05-22 00:06:20 +04:00
|
|
|
}
|
|
|
|
|
2004-08-04 02:07:45 +04:00
|
|
|
if ( NULL != rdisps ) {
|
|
|
|
free ( rdisps );
|
|
|
|
}
|
|
|
|
if ( NULL != rcounts ) {
|
|
|
|
free ( rcounts );
|
|
|
|
}
|
2004-05-22 00:06:20 +04:00
|
|
|
|
|
|
|
/* This is the logic for determining who is first, who is second */
|
|
|
|
if ( high && !rhigh ) {
|
2006-05-03 18:43:52 +04:00
|
|
|
flag = false;
|
2004-05-22 00:06:20 +04:00
|
|
|
}
|
|
|
|
else if ( !high && rhigh ) {
|
2006-05-03 18:43:52 +04:00
|
|
|
flag = true;
|
2004-05-22 00:06:20 +04:00
|
|
|
}
|
|
|
|
else {
|
2004-08-04 21:06:33 +04:00
|
|
|
ourproc = intercomm->c_local_group->grp_proc_pointers[0];
|
|
|
|
theirproc = intercomm->c_remote_group->grp_proc_pointers[0];
|
|
|
|
|
2007-07-20 06:34:29 +04:00
|
|
|
mask = ORTE_NS_CMP_JOBID | ORTE_NS_CMP_VPID;
|
Bring over the update to terminate orteds that are generated by a dynamic spawn such as comm_spawn. This introduces the concept of a job "family" - i.e., jobs that have a parent/child relationship. Comm_spawn'ed jobs have a parent (the one that spawned them). We track that relationship throughout the lineage - i.e., if a comm_spawned job in turn calls comm_spawn, then it has a parent (the one that spawned it) and a "root" job (the original job that started things).
Accordingly, there are new APIs to the name service to support the ability to get a job's parent, root, immediate children, and all its descendants. In addition, the terminate_job, terminate_orted, and signal_job APIs for the PLS have been modified to accept attributes that define the extent of their actions. For example, doing a "terminate_job" with an attribute of ORTE_NS_INCLUDE_DESCENDANTS will terminate the given jobid AND all jobs that descended from it.
I have tested this capability on a MacBook under rsh, Odin under SLURM, and LANL's Flash (bproc). It worked successfully on non-MPI jobs (both simple and including a spawn), and MPI jobs (again, both simple and with a spawn).
This commit was SVN r12597.
2006-11-14 22:34:59 +03:00
|
|
|
rc = orte_ns.compare_fields(mask, &(ourproc->proc_name), &(theirproc->proc_name));
|
2004-08-08 23:19:05 +04:00
|
|
|
if ( 0 > rc ) {
|
2004-05-22 00:06:20 +04:00
|
|
|
flag = true;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
flag = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return flag;
|
|
|
|
}
|
|
|
|
/********************************************************************************/
|
|
|
|
/********************************************************************************/
|
|
|
|
/********************************************************************************/
|
2004-06-07 19:33:53 +04:00
|
|
|
int ompi_comm_dump ( ompi_communicator_t *comm )
|
2004-05-22 00:06:20 +04:00
|
|
|
{
|
2005-07-04 03:31:27 +04:00
|
|
|
opal_output(0, "Dumping information for comm_cid %d\n", comm->c_contextid);
|
|
|
|
opal_output(0," f2c index:%d cube_dim: %d\n", comm->c_f_to_c_index,
|
2004-05-22 00:06:20 +04:00
|
|
|
comm->c_cube_dim);
|
2005-07-04 03:31:27 +04:00
|
|
|
opal_output(0," Local group: size = %d my_rank = %d\n",
|
2004-05-22 00:06:20 +04:00
|
|
|
comm->c_local_group->grp_proc_count,
|
|
|
|
comm->c_local_group->grp_my_rank );
|
|
|
|
|
2005-07-04 03:31:27 +04:00
|
|
|
opal_output(0," Communicator is:");
|
2004-05-22 00:06:20 +04:00
|
|
|
/* Display flags */
|
2004-06-07 19:33:53 +04:00
|
|
|
if ( OMPI_COMM_IS_INTER(comm) )
|
2005-07-04 03:31:27 +04:00
|
|
|
opal_output(0," inter-comm,");
|
2004-06-07 19:33:53 +04:00
|
|
|
if ( OMPI_COMM_IS_CART(comm))
|
2005-07-04 03:31:27 +04:00
|
|
|
opal_output(0," topo-cart,");
|
2004-06-07 19:33:53 +04:00
|
|
|
if ( OMPI_COMM_IS_GRAPH(comm))
|
2005-07-04 03:31:27 +04:00
|
|
|
opal_output(0," topo-graph");
|
|
|
|
opal_output(0,"\n");
|
2004-05-22 00:06:20 +04:00
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
if (OMPI_COMM_IS_INTER(comm)) {
|
2005-07-04 03:31:27 +04:00
|
|
|
opal_output(0," Remote group size:%d\n", comm->c_remote_group->grp_proc_count);
|
2004-05-22 00:06:20 +04:00
|
|
|
}
|
|
|
|
return MPI_SUCCESS;
|
|
|
|
}
|
|
|
|
/********************************************************************************/
|
|
|
|
/********************************************************************************/
|
|
|
|
/********************************************************************************/
|
|
|
|
/* static functions */
|
|
|
|
/*
|
|
|
|
** rankkeygidcompare() compares a tuple of (rank,key,gid) producing
|
|
|
|
** sorted lists that match the rules needed for a MPI_Comm_split
|
|
|
|
*/
|
|
|
|
static int rankkeycompare (const void *p, const void *q)
|
|
|
|
{
|
|
|
|
int *a, *b;
|
|
|
|
|
|
|
|
/* ranks at [0] key at [1] */
|
|
|
|
/* i.e. we cast and just compare the keys and then the original ranks.. */
|
|
|
|
a = (int*)p;
|
|
|
|
b = (int*)q;
|
|
|
|
|
|
|
|
/* simple tests are those where the keys are different */
|
|
|
|
if (a[1] < b[1]) {
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
if (a[1] > b[1]) {
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ok, if the keys are the same then we check the original ranks */
|
|
|
|
if (a[1] == b[1]) {
|
|
|
|
if (a[0] < b[0]) {
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
if (a[0] == b[0]) {
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
if (a[0] > b[0]) {
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ( 0 );
|
|
|
|
}
|
|
|
|
|
2004-07-21 02:21:47 +04:00
|
|
|
|
|
|
|
/*************************************************************************************
|
2004-08-02 04:24:22 +04:00
|
|
|
* Counterpart of MPI_Cart/Graph_create. This will be called from the
|
|
|
|
* top level MPI. The condition for INTER communicator is already
|
|
|
|
* checked by the time this has been invoked. This function should do
|
|
|
|
* somewhat the same things which ompi_comm_create does. It will
|
|
|
|
* however select a component for topology and then call the
|
|
|
|
* cart_create on that component so that it can re-arrange the proc
|
|
|
|
* structure as required (if the reorder flag is true). It will then
|
|
|
|
* use this proc structure to create the communicator using
|
|
|
|
* ompi_comm_set.
|
2004-07-21 02:21:47 +04:00
|
|
|
*/
|
|
|
|
int ompi_topo_create (ompi_communicator_t *old_comm,
|
|
|
|
int ndims_or_nnodes,
|
|
|
|
int *dims_or_index,
|
|
|
|
int *periods_or_edges,
|
|
|
|
bool reorder,
|
|
|
|
ompi_communicator_t **comm_topo,
|
|
|
|
int cart_or_graph){
|
|
|
|
|
|
|
|
ompi_communicator_t *new_comm;
|
|
|
|
int new_rank;
|
|
|
|
ompi_proc_t **topo_procs;
|
|
|
|
int num_procs;
|
|
|
|
int ret;
|
2004-11-15 19:09:08 +03:00
|
|
|
|
|
|
|
/* allocate a new communicator */
|
|
|
|
|
|
|
|
new_comm = ompi_comm_allocate(ompi_comm_size(old_comm), 0);
|
|
|
|
if (NULL == new_comm) {
|
|
|
|
return MPI_ERR_INTERN;
|
|
|
|
}
|
2004-07-21 02:21:47 +04:00
|
|
|
|
|
|
|
/* allocate the data for the common good */
|
|
|
|
|
2006-08-24 20:38:08 +04:00
|
|
|
new_comm->c_topo_comm = (mca_topo_base_comm_t*)malloc(sizeof(mca_topo_base_comm_t));
|
2004-11-15 19:09:08 +03:00
|
|
|
if (NULL == new_comm->c_topo_comm) {
|
2004-07-21 02:21:47 +04:00
|
|
|
OBJ_RELEASE(new_comm);
|
2004-11-15 19:09:08 +03:00
|
|
|
return OMPI_ERR_OUT_OF_RESOURCE;
|
2004-07-21 02:21:47 +04:00
|
|
|
}
|
|
|
|
|
2004-11-15 19:09:08 +03:00
|
|
|
/* select the topology component on the communicator */
|
|
|
|
|
2004-07-21 02:21:47 +04:00
|
|
|
if (OMPI_SUCCESS != (ret = mca_topo_base_comm_select (new_comm, NULL))) {
|
2004-11-15 19:09:08 +03:00
|
|
|
/* OBJ_RELEASE also frees new_comm->c_topo_comm */
|
2004-07-21 02:21:47 +04:00
|
|
|
OBJ_RELEASE(new_comm);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-08-02 04:24:22 +04:00
|
|
|
/* since the topo component has initialised, let us now initialise
|
|
|
|
* the topo comm structure */
|
2004-07-21 02:21:47 +04:00
|
|
|
new_comm->c_flags |= cart_or_graph;
|
|
|
|
|
|
|
|
new_comm->c_topo_comm->mtc_ndims_or_nnodes = ndims_or_nnodes;
|
|
|
|
|
|
|
|
new_comm->c_topo_comm->mtc_dims_or_index = NULL;
|
|
|
|
new_comm->c_topo_comm->mtc_periods_or_edges = NULL;
|
|
|
|
new_comm->c_topo_comm->mtc_reorder = reorder;
|
|
|
|
|
|
|
|
new_comm->c_topo_comm->mtc_coords = NULL;
|
|
|
|
|
2004-10-18 20:55:20 +04:00
|
|
|
new_comm->c_topo_comm->mtc_dims_or_index = (int *)malloc (sizeof(int) * ndims_or_nnodes);
|
2004-07-21 02:21:47 +04:00
|
|
|
if (NULL == new_comm->c_topo_comm->mtc_dims_or_index) {
|
2004-10-06 01:17:14 +04:00
|
|
|
ompi_comm_free (&new_comm);
|
|
|
|
*comm_topo = new_comm;
|
2004-07-21 02:21:47 +04:00
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
|
|
|
memcpy (new_comm->c_topo_comm->mtc_dims_or_index,
|
|
|
|
dims_or_index, ndims_or_nnodes * sizeof(int));
|
|
|
|
|
2004-08-02 04:24:22 +04:00
|
|
|
/* Now the topology component has been selected, let the component
|
|
|
|
* re-arrange the proc ranks if need be. This is a down-call into
|
|
|
|
* the topo component and does not have anything to do with this
|
|
|
|
* level */
|
|
|
|
|
|
|
|
/* first, copy the proc structure from the previous communicator
|
|
|
|
* over to the new one. the topology component can then work on
|
|
|
|
* this and rearrange it as it deems fit.
|
2004-07-21 02:21:47 +04:00
|
|
|
*/
|
|
|
|
num_procs = old_comm->c_local_group->grp_proc_count;
|
|
|
|
topo_procs = (ompi_proc_t **)malloc (num_procs * sizeof(ompi_proc_t *));
|
|
|
|
memcpy (topo_procs,
|
|
|
|
old_comm->c_local_group->grp_proc_pointers,
|
|
|
|
num_procs * sizeof(ompi_proc_t *));
|
|
|
|
new_rank = old_comm->c_local_group->grp_my_rank;
|
|
|
|
|
|
|
|
if (OMPI_COMM_CART == cart_or_graph) {
|
|
|
|
|
|
|
|
/* A cartesian system has been requested. Call the right function */
|
|
|
|
|
2004-08-02 04:24:22 +04:00
|
|
|
/* Note that we fill in the basic information, i.e, copy the
|
|
|
|
* information which was provided to us over into the
|
|
|
|
* structure. The base component functions are free to change
|
|
|
|
* it as they deem fit */
|
2004-07-21 02:21:47 +04:00
|
|
|
|
2004-10-18 20:55:20 +04:00
|
|
|
new_comm->c_topo_comm->mtc_periods_or_edges = (int *)
|
2007-04-06 23:18:31 +04:00
|
|
|
malloc (sizeof(int) * dims_or_index[ndims_or_nnodes - 1]);
|
2004-07-21 02:21:47 +04:00
|
|
|
if (NULL == new_comm->c_topo_comm->mtc_periods_or_edges) {
|
2004-10-06 01:17:14 +04:00
|
|
|
ompi_comm_free (&new_comm);
|
|
|
|
*comm_topo = new_comm;
|
2004-07-21 02:21:47 +04:00
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
|
|
|
memcpy (new_comm->c_topo_comm->mtc_periods_or_edges,
|
2007-04-06 23:18:31 +04:00
|
|
|
periods_or_edges,
|
|
|
|
dims_or_index[ndims_or_nnodes - 1] * sizeof(int));
|
2004-07-21 02:21:47 +04:00
|
|
|
|
2004-10-18 20:55:20 +04:00
|
|
|
new_comm->c_topo_comm->mtc_coords = (int *)malloc (sizeof(int) * ndims_or_nnodes);
|
2004-07-21 02:21:47 +04:00
|
|
|
if (NULL == new_comm->c_topo_comm->mtc_coords) {
|
2004-10-06 01:17:14 +04:00
|
|
|
ompi_comm_free (&new_comm);
|
|
|
|
*comm_topo = new_comm;
|
2004-07-21 02:21:47 +04:00
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (OMPI_SUCCESS !=
|
|
|
|
(ret = new_comm->c_topo->topo_cart_create (new_comm->c_topo_comm,
|
|
|
|
&num_procs,
|
|
|
|
topo_procs,
|
|
|
|
&new_rank,
|
|
|
|
ndims_or_nnodes,
|
|
|
|
dims_or_index,
|
|
|
|
periods_or_edges,
|
|
|
|
reorder))) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (OMPI_COMM_GRAPH == cart_or_graph) {
|
|
|
|
|
|
|
|
/* A graph system has been requested. Call the right function */
|
|
|
|
|
2004-08-02 04:24:22 +04:00
|
|
|
/* Note that we fill in the basic information, i.e, copy the
|
|
|
|
* information which was provided to us over into the
|
|
|
|
* structure. The base component functions are free to change
|
|
|
|
* it as they deem fit */
|
2004-07-21 02:21:47 +04:00
|
|
|
|
2004-10-18 20:55:20 +04:00
|
|
|
new_comm->c_topo_comm->mtc_periods_or_edges = (int *)
|
2004-07-21 02:21:47 +04:00
|
|
|
malloc (sizeof(int) * dims_or_index[ndims_or_nnodes-1]);
|
|
|
|
if (NULL == new_comm->c_topo_comm->mtc_periods_or_edges) {
|
2004-10-06 01:17:14 +04:00
|
|
|
ompi_comm_free (&new_comm);
|
|
|
|
*comm_topo = new_comm;
|
2004-07-21 02:21:47 +04:00
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
|
|
|
memcpy (new_comm->c_topo_comm->mtc_periods_or_edges,
|
|
|
|
periods_or_edges, dims_or_index[ndims_or_nnodes-1] * sizeof(int));
|
|
|
|
|
|
|
|
if (OMPI_SUCCESS !=
|
|
|
|
(ret = new_comm->c_topo->topo_graph_create (new_comm->c_topo_comm,
|
|
|
|
&num_procs,
|
|
|
|
topo_procs,
|
|
|
|
&new_rank,
|
|
|
|
ndims_or_nnodes,
|
|
|
|
dims_or_index,
|
|
|
|
periods_or_edges,
|
|
|
|
reorder))) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Determine context id. It is identical to f_2_c_handle */
|
|
|
|
|
|
|
|
ret = ompi_comm_nextcid ( new_comm, /* new communicator */
|
|
|
|
old_comm, /* old comm */
|
|
|
|
NULL, /* bridge comm */
|
|
|
|
NULL, /* local leader */
|
|
|
|
NULL, /* remote_leader */
|
2004-08-05 20:31:30 +04:00
|
|
|
OMPI_COMM_CID_INTRA, /* mode */
|
|
|
|
-1 ); /* send first, doesn't matter */
|
2004-07-21 02:21:47 +04:00
|
|
|
if (OMPI_SUCCESS != ret) {
|
|
|
|
/* something wrong happened during setting the communicator */
|
2004-10-06 01:17:14 +04:00
|
|
|
ompi_comm_free (&new_comm);
|
|
|
|
*comm_topo = new_comm;
|
2004-07-21 02:21:47 +04:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-10-06 01:17:14 +04:00
|
|
|
|
2004-08-02 04:24:22 +04:00
|
|
|
/* Now, the topology component has been selected and the group
|
|
|
|
* which has the topology information has been created. All we
|
|
|
|
* need to do now is to fill the rest of the information into the
|
|
|
|
* communicator. The following steps are not just similar to
|
|
|
|
* ompi_comm_set, but are actually the same */
|
2004-07-21 02:21:47 +04:00
|
|
|
|
|
|
|
ret = ompi_comm_fill_rest(new_comm, /* the communicator */
|
|
|
|
num_procs, /* local size */
|
|
|
|
topo_procs, /* process structure */
|
|
|
|
new_rank, /* rank of the process */
|
2004-08-05 20:31:30 +04:00
|
|
|
old_comm->error_handler); /* error handler */
|
|
|
|
|
|
|
|
if (OMPI_SUCCESS != ret) {
|
|
|
|
/* something wrong happened during setting the communicator */
|
2004-10-06 01:17:14 +04:00
|
|
|
ompi_comm_free (&new_comm);
|
|
|
|
*comm_topo = new_comm;
|
2004-08-05 20:31:30 +04:00
|
|
|
return ret;
|
|
|
|
}
|
2004-07-21 02:21:47 +04:00
|
|
|
|
2004-08-05 20:31:30 +04:00
|
|
|
ret = ompi_comm_activate ( new_comm, /* new communicator */
|
|
|
|
old_comm, /* old comm */
|
|
|
|
NULL, /* bridge comm */
|
|
|
|
NULL, /* local leader */
|
|
|
|
NULL, /* remote_leader */
|
|
|
|
OMPI_COMM_CID_INTRA, /* mode */
|
|
|
|
-1, /* send first, doesn't matter */
|
2007-04-06 23:18:31 +04:00
|
|
|
0, /* sync_flag */
|
2004-08-05 20:31:30 +04:00
|
|
|
NULL ); /* coll component */
|
2004-10-06 01:17:14 +04:00
|
|
|
|
2004-07-21 02:21:47 +04:00
|
|
|
if (OMPI_SUCCESS != ret) {
|
|
|
|
/* something wrong happened during setting the communicator */
|
2004-10-06 01:17:14 +04:00
|
|
|
ompi_comm_free (&new_comm);
|
|
|
|
*comm_topo = new_comm;
|
2004-07-21 02:21:47 +04:00
|
|
|
return ret;
|
|
|
|
}
|
2004-08-05 20:31:30 +04:00
|
|
|
|
2004-07-21 02:21:47 +04:00
|
|
|
|
|
|
|
/* finally, set the communicator to comm_cart */
|
|
|
|
|
2004-10-06 01:17:14 +04:00
|
|
|
/* if the returned rank is -1, then this process is not in the
|
|
|
|
* new topology, so free everything we have allocated and return */
|
|
|
|
if (MPI_UNDEFINED == new_rank) {
|
|
|
|
ompi_comm_free (&new_comm);
|
|
|
|
*comm_topo = new_comm;
|
|
|
|
} else {
|
|
|
|
*comm_topo = new_comm;
|
|
|
|
}
|
2004-07-21 02:21:47 +04:00
|
|
|
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ompi_comm_fill_rest (ompi_communicator_t *comm,
|
|
|
|
int num_procs,
|
|
|
|
ompi_proc_t **proc_pointers,
|
|
|
|
int my_rank,
|
2004-08-05 20:31:30 +04:00
|
|
|
ompi_errhandler_t *errh )
|
2004-08-02 04:24:22 +04:00
|
|
|
{
|
2004-07-21 02:21:47 +04:00
|
|
|
int ret;
|
2007-04-02 23:06:52 +04:00
|
|
|
|
|
|
|
/* properly decrement the ref counts on the groups.
|
|
|
|
We are doing this because this function is sort of a redo
|
|
|
|
of what is done in comm.c.. No need to decrement the ref
|
|
|
|
count on the proc pointers
|
|
|
|
This is just a quick fix, and will be looking for a
|
|
|
|
better solution */
|
|
|
|
OBJ_RELEASE ( comm->c_local_group );
|
|
|
|
OBJ_RELEASE ( comm->c_local_group );
|
2004-07-21 02:21:47 +04:00
|
|
|
|
|
|
|
/* allocate a group structure for the new communicator */
|
|
|
|
comm->c_local_group = ompi_group_allocate(num_procs);
|
2007-04-02 23:06:52 +04:00
|
|
|
|
2004-07-21 02:21:47 +04:00
|
|
|
/* free the malloced proc pointers */
|
|
|
|
free(comm->c_local_group->grp_proc_pointers);
|
|
|
|
|
|
|
|
/* set the group information */
|
|
|
|
comm->c_local_group->grp_proc_pointers = proc_pointers;
|
|
|
|
|
|
|
|
/* set the remote group to be the same as local group */
|
|
|
|
comm->c_remote_group = comm->c_local_group;
|
2007-04-02 23:06:52 +04:00
|
|
|
OBJ_RETAIN ( comm->c_remote_group );
|
2004-07-21 02:21:47 +04:00
|
|
|
|
|
|
|
/* retain these proc pointers */
|
|
|
|
ompi_group_increment_proc_count(comm->c_local_group);
|
|
|
|
|
|
|
|
/* set the rank information */
|
2005-11-10 00:00:58 +03:00
|
|
|
comm->c_local_group->grp_my_rank = my_rank;
|
|
|
|
comm->c_my_rank = my_rank;
|
2004-07-21 02:21:47 +04:00
|
|
|
|
2004-10-26 15:37:58 +04:00
|
|
|
/* verify whether to set the flag, that this comm
|
|
|
|
contains process from more than one jobid. */
|
|
|
|
ompi_comm_mark_dyncomm (comm);
|
|
|
|
|
2004-07-21 02:21:47 +04:00
|
|
|
/* set the error handler */
|
|
|
|
comm->error_handler = errh;
|
|
|
|
OBJ_RETAIN (comm->error_handler);
|
|
|
|
|
|
|
|
/* set name for debugging purposes */
|
|
|
|
/* there is no cid at this stage ... make this right and make edgars
|
|
|
|
* code call this function and remove dupli cde
|
|
|
|
*/
|
|
|
|
snprintf (comm->c_name, MPI_MAX_OBJECT_NAME, "MPI_COMMUNICATOR %d",
|
|
|
|
comm->c_contextid);
|
|
|
|
|
|
|
|
/* determine the cube dimensions */
|
2005-07-04 04:13:44 +04:00
|
|
|
comm->c_cube_dim = opal_cube_dim(comm->c_local_group->grp_proc_count);
|
2004-07-21 02:21:47 +04:00
|
|
|
|
|
|
|
/* initialize PML stuff on the communicator */
|
2005-04-13 07:19:48 +04:00
|
|
|
if (OMPI_SUCCESS != (ret = MCA_PML_CALL(add_comm(comm)))) {
|
2004-07-21 02:21:47 +04:00
|
|
|
/* some error has happened */
|
|
|
|
return ret;
|
|
|
|
}
|
2005-03-26 04:49:14 +03:00
|
|
|
OMPI_COMM_SET_PML_ADDED(comm);
|
2004-07-21 02:21:47 +04:00
|
|
|
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
2004-10-05 20:32:52 +04:00
|
|
|
|
|
|
|
static int ompi_comm_copy_topo (ompi_communicator_t *oldcomm,
|
|
|
|
ompi_communicator_t *newcomm) {
|
|
|
|
|
|
|
|
|
|
|
|
int index =
|
|
|
|
|
|
|
|
(oldcomm->c_topo_comm->mtc_dims_or_index[oldcomm->c_topo_comm->mtc_ndims_or_nnodes-1] > 0)?
|
|
|
|
oldcomm->c_topo_comm->mtc_dims_or_index[oldcomm->c_topo_comm->mtc_ndims_or_nnodes-1] :
|
|
|
|
-oldcomm->c_topo_comm->mtc_dims_or_index[oldcomm->c_topo_comm->mtc_ndims_or_nnodes-1];
|
|
|
|
|
|
|
|
/* pointers for the rest of the information have been set up .... simply
|
|
|
|
allocate enough space and copy all the information from the previous one */
|
|
|
|
|
|
|
|
newcomm->c_topo_comm->mtc_ndims_or_nnodes = oldcomm->c_topo_comm->mtc_ndims_or_nnodes;
|
|
|
|
newcomm->c_topo_comm->mtc_reorder = oldcomm->c_topo_comm->mtc_reorder;
|
|
|
|
|
2004-10-18 20:55:20 +04:00
|
|
|
newcomm->c_topo_comm->mtc_dims_or_index = (int *)malloc(sizeof(int)*
|
2004-10-05 20:32:52 +04:00
|
|
|
newcomm->c_topo_comm->mtc_ndims_or_nnodes);
|
|
|
|
|
|
|
|
if (NULL == newcomm->c_topo_comm->mtc_dims_or_index) {
|
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy (newcomm->c_topo_comm->mtc_dims_or_index,
|
|
|
|
oldcomm->c_topo_comm->mtc_dims_or_index ,
|
|
|
|
newcomm->c_topo_comm->mtc_ndims_or_nnodes * sizeof(int));
|
|
|
|
|
2004-10-18 20:55:20 +04:00
|
|
|
newcomm->c_topo_comm->mtc_periods_or_edges = (int *)
|
2004-10-05 20:32:52 +04:00
|
|
|
malloc (sizeof(int)*index);
|
|
|
|
if (NULL == newcomm->c_topo_comm->mtc_periods_or_edges) {
|
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy (newcomm->c_topo_comm->mtc_periods_or_edges,
|
|
|
|
oldcomm->c_topo_comm->mtc_periods_or_edges,
|
|
|
|
sizeof(int) * index );
|
|
|
|
|
|
|
|
if (OMPI_COMM_IS_CART(oldcomm)) {
|
2004-10-18 20:55:20 +04:00
|
|
|
newcomm->c_topo_comm->mtc_coords = (int *)malloc(sizeof(int)*
|
2004-10-05 20:32:52 +04:00
|
|
|
newcomm->c_topo_comm->mtc_ndims_or_nnodes);
|
|
|
|
|
|
|
|
if (NULL == newcomm->c_topo_comm->mtc_coords) {
|
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy (newcomm->c_topo_comm->mtc_coords,
|
|
|
|
oldcomm->c_topo_comm->mtc_coords,
|
|
|
|
sizeof(int) * newcomm->c_topo_comm->mtc_ndims_or_nnodes);
|
|
|
|
} else {
|
|
|
|
newcomm->c_topo_comm->mtc_coords = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|