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.
|
2011-10-04 18:50:31 +04:00
|
|
|
* Copyright (c) 2004-2011 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.
|
2011-04-01 00:05:45 +04:00
|
|
|
* Copyright (c) 2007-2011 University of Houston. All rights reserved.
|
Per RFC, bring in the following changes:
* Remove paffinity, maffinity, and carto frameworks -- they've been
wholly replaced by hwloc.
* Move ompi_mpi_init() affinity-setting/checking code down to ORTE.
* Update sm, smcuda, wv, and openib components to no longer use carto.
Instead, use hwloc data. There are still optimizations possible in
the sm/smcuda BTLs (i.e., making multiple mpools). Also, the old
carto-based code found out how many NUMA nodes were ''available''
-- not how many were used ''in this job''. The new hwloc-using
code computes the same value -- it was not updated to calculate how
many NUMA nodes are used ''by this job.''
* Note that I cannot compile the smcuda and wv BTLs -- I ''think''
they're right, but they need to be verified by their owners.
* The openib component now does a bunch of stuff to figure out where
"near" OpenFabrics devices are. '''THIS IS A CHANGE IN DEFAULT
BEHAVIOR!!''' and still needs to be verified by OpenFabrics vendors
(I do not have a NUMA machine with an OpenFabrics device that is a
non-uniform distance from multiple different NUMA nodes).
* Completely rewrite the OMPI_Affinity_str() routine from the
"affinity" mpiext extension. This extension now understands
hyperthreads; the output format of it has changed a bit to reflect
this new information.
* Bunches of minor changes around the code base to update names/types
from maffinity/paffinity-based names to hwloc-based names.
* Add some helper functions into the hwloc base, mainly having to do
with the fact that we have the hwloc data reporting ''all''
topology information, but sometimes you really only want the
(online | available) data.
This commit was SVN r26391.
2012-05-07 18:52:54 +04:00
|
|
|
* Copyright (c) 2007-2012 Cisco Systems, Inc. All rights reserved.
|
2009-02-24 20:17:33 +03:00
|
|
|
* Copyright (c) 2009 Sun Microsystems, Inc. All rights reserved.
|
2012-03-09 18:43:00 +04:00
|
|
|
* Copyright (c) 2012 Oak Ridge National Labs. 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"
|
Per RFC, bring in the following changes:
* Remove paffinity, maffinity, and carto frameworks -- they've been
wholly replaced by hwloc.
* Move ompi_mpi_init() affinity-setting/checking code down to ORTE.
* Update sm, smcuda, wv, and openib components to no longer use carto.
Instead, use hwloc data. There are still optimizations possible in
the sm/smcuda BTLs (i.e., making multiple mpools). Also, the old
carto-based code found out how many NUMA nodes were ''available''
-- not how many were used ''in this job''. The new hwloc-using
code computes the same value -- it was not updated to calculate how
many NUMA nodes are used ''by this job.''
* Note that I cannot compile the smcuda and wv BTLs -- I ''think''
they're right, but they need to be verified by their owners.
* The openib component now does a bunch of stuff to figure out where
"near" OpenFabrics devices are. '''THIS IS A CHANGE IN DEFAULT
BEHAVIOR!!''' and still needs to be verified by OpenFabrics vendors
(I do not have a NUMA machine with an OpenFabrics device that is a
non-uniform distance from multiple different NUMA nodes).
* Completely rewrite the OMPI_Affinity_str() routine from the
"affinity" mpiext extension. This extension now understands
hyperthreads; the output format of it has changed a bit to reflect
this new information.
* Bunches of minor changes around the code base to update names/types
from maffinity/paffinity-based names to hwloc-based names.
* Add some helper functions into the hwloc base, mainly having to do
with the fact that we have the hwloc data reporting ''all''
topology information, but sometimes you really only want the
(online | available) data.
This commit was SVN r26391.
2012-05-07 18:52:54 +04:00
|
|
|
#include "opal/mca/hwloc/base/base.h"
|
2008-02-28 04:57:57 +03:00
|
|
|
|
|
|
|
#include "opal/dss/dss.h"
|
2012-06-27 05:28:28 +04:00
|
|
|
#include "orte/util/name_fns.h"
|
|
|
|
#include "orte/mca/rml/rml_types.h"
|
2008-02-28 04:57:57 +03:00
|
|
|
|
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"
|
2009-02-14 05:26:12 +03:00
|
|
|
#include "opal/util/output.h"
|
2006-02-12 04:33:29 +03:00
|
|
|
#include "ompi/mca/topo/topo.h"
|
|
|
|
#include "ompi/mca/topo/base/base.h"
|
2008-02-28 04:57:57 +03:00
|
|
|
#include "ompi/mca/dpm/dpm.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,
|
2007-08-19 07:37:49 +04:00
|
|
|
ompi_communicator_t *comm,
|
2008-07-29 02:40:57 +04:00
|
|
|
mca_coll_base_module_t *data);
|
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,
|
2007-08-19 07:37:49 +04:00
|
|
|
ompi_communicator_t *comm,
|
2008-07-29 02:40:57 +04:00
|
|
|
mca_coll_base_module_t *data);
|
2004-06-16 01:29:29 +04:00
|
|
|
|
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
|
|
|
|
2007-08-04 04:41:26 +04:00
|
|
|
int ompi_comm_set ( ompi_communicator_t **ncomm,
|
2007-08-23 11:40:40 +04:00
|
|
|
ompi_communicator_t *oldcomm,
|
2004-08-04 02:07:45 +04:00
|
|
|
int local_size,
|
2007-08-04 04:41:26 +04:00
|
|
|
int *local_ranks,
|
2004-08-04 02:07:45 +04:00
|
|
|
int remote_size,
|
2007-08-04 04:41:26 +04:00
|
|
|
int *remote_ranks,
|
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,
|
2007-08-04 04:41:26 +04:00
|
|
|
mca_base_component_t *topocomponent,
|
|
|
|
ompi_group_t *local_group,
|
|
|
|
ompi_group_t *remote_group )
|
|
|
|
|
2004-05-22 00:06:20 +04:00
|
|
|
{
|
2007-08-04 04:41:26 +04:00
|
|
|
ompi_communicator_t *newcomm=NULL;
|
2004-10-05 20:32:52 +04:00
|
|
|
int ret;
|
2007-08-04 04:41:26 +04:00
|
|
|
|
|
|
|
/* ompi_comm_allocate */
|
|
|
|
newcomm = OBJ_NEW(ompi_communicator_t);
|
|
|
|
/* fill in the inscribing hyper-cube dimensions */
|
|
|
|
newcomm->c_cube_dim = opal_cube_dim(local_size);
|
2008-11-05 00:58:06 +03:00
|
|
|
newcomm->c_id_available = MPI_UNDEFINED;
|
|
|
|
newcomm->c_id_start_index = MPI_UNDEFINED;
|
2004-05-22 00:06:20 +04:00
|
|
|
|
2007-08-04 04:41:26 +04:00
|
|
|
if (NULL == local_group) {
|
|
|
|
/* determine how the list of local_rank can be stored most
|
|
|
|
efficiently */
|
2007-09-13 18:00:59 +04:00
|
|
|
ret = ompi_group_incl(oldcomm->c_local_group, local_size,
|
2007-08-04 04:41:26 +04:00
|
|
|
local_ranks, &newcomm->c_local_group);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
newcomm->c_local_group = local_group;
|
|
|
|
OBJ_RETAIN(newcomm->c_local_group);
|
|
|
|
ompi_group_increment_proc_count(newcomm->c_local_group);
|
|
|
|
}
|
2004-05-22 00:06:20 +04:00
|
|
|
newcomm->c_my_rank = newcomm->c_local_group->grp_my_rank;
|
2007-08-04 04:41:26 +04:00
|
|
|
|
2007-03-27 06:06:42 +04:00
|
|
|
/* Set remote group and duplicate the local comm, if applicable */
|
2007-08-04 04:41:26 +04:00
|
|
|
if ( 0 < remote_size) {
|
|
|
|
if ( NULL == remote_group ) {
|
|
|
|
ret = ompi_group_incl(oldcomm->c_remote_group, remote_size,
|
|
|
|
remote_ranks, &newcomm->c_remote_group);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
newcomm->c_remote_group = remote_group;
|
|
|
|
OBJ_RETAIN(newcomm->c_remote_group);
|
|
|
|
ompi_group_increment_proc_count(newcomm->c_remote_group);
|
|
|
|
}
|
2004-06-07 19:33:53 +04:00
|
|
|
newcomm->c_flags |= OMPI_COMM_INTER;
|
2007-04-06 23:18:31 +04:00
|
|
|
if ( OMPI_COMM_IS_INTRA(oldcomm) ) {
|
2008-11-05 00:58:06 +03:00
|
|
|
ompi_comm_dup(oldcomm, &newcomm->c_local_comm);
|
2007-04-06 23:18:31 +04:00
|
|
|
} else {
|
2008-11-05 00:58:06 +03:00
|
|
|
ompi_comm_dup(oldcomm->c_local_comm, &newcomm->c_local_comm);
|
2007-04-06 23:18:31 +04:00
|
|
|
}
|
2004-05-22 00:06:20 +04:00
|
|
|
}
|
2007-08-04 04:41:26 +04:00
|
|
|
else {
|
|
|
|
newcomm->c_remote_group = newcomm->c_local_group;
|
|
|
|
OBJ_RETAIN(newcomm->c_remote_group);
|
|
|
|
}
|
|
|
|
|
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. */
|
2011-04-01 00:05:45 +04:00
|
|
|
|
|
|
|
if ( 0 < local_size ) {
|
2011-03-31 23:57:06 +04:00
|
|
|
ompi_dpm.mark_dyncomm (newcomm);
|
|
|
|
}
|
|
|
|
|
2004-05-22 00:06:20 +04:00
|
|
|
/* Set error handler */
|
|
|
|
newcomm->error_handler = errh;
|
|
|
|
OBJ_RETAIN ( newcomm->error_handler );
|
2007-08-04 04:41:26 +04:00
|
|
|
|
2004-05-22 00:06:20 +04:00
|
|
|
/* 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
|
|
|
*/
|
2007-08-04 04:41:26 +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
|
|
|
|
*/
|
2007-08-04 04:41:26 +04:00
|
|
|
|
2004-10-05 20:32:52 +04:00
|
|
|
/* 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));
|
2007-08-04 04:41:26 +04:00
|
|
|
|
2004-10-05 20:32:52 +04:00
|
|
|
if (NULL == newcomm->c_topo_comm) {
|
|
|
|
OBJ_RELEASE(newcomm);
|
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
2007-08-04 04:41:26 +04:00
|
|
|
|
2004-10-05 20:32:52 +04:00
|
|
|
if (OMPI_SUCCESS != (ret = mca_topo_base_comm_select (newcomm,
|
2007-08-04 04:41:26 +04:00
|
|
|
oldcomm->c_topo_component))) {
|
2004-10-05 20:32:52 +04:00
|
|
|
free(newcomm->c_topo_comm);
|
|
|
|
OBJ_RELEASE(newcomm);
|
|
|
|
return ret;
|
|
|
|
}
|
2007-08-04 04:41:26 +04:00
|
|
|
|
2004-10-05 20:32:52 +04:00
|
|
|
/*
|
|
|
|
* Should copy over the information from the previous communicator
|
|
|
|
*/
|
2007-08-04 04:41:26 +04:00
|
|
|
if (OMPI_SUCCESS != (ret = ompi_comm_copy_topo (oldcomm, newcomm))) {
|
|
|
|
OBJ_RELEASE(newcomm);
|
|
|
|
return ret;
|
|
|
|
}
|
2004-05-22 00:06:20 +04:00
|
|
|
}
|
2007-08-04 04:41:26 +04:00
|
|
|
|
2004-10-07 05:26:40 +04:00
|
|
|
/* Copy attributes and call according copy functions, if
|
|
|
|
required */
|
2007-08-04 04:41:26 +04:00
|
|
|
|
2004-10-07 05:26:40 +04:00
|
|
|
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
|
|
|
}
|
2007-08-04 04:41:26 +04:00
|
|
|
|
2010-10-04 18:54:58 +04:00
|
|
|
*ncomm = 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,
|
2010-10-04 18:54:58 +04:00
|
|
|
ompi_communicator_t **newcomm )
|
2004-05-22 00:06:20 +04:00
|
|
|
{
|
2007-08-23 11:40:40 +04:00
|
|
|
ompi_communicator_t *newcomp = NULL;
|
2007-08-04 04:41:26 +04:00
|
|
|
int rsize , lsize;
|
|
|
|
int mode,i,j;
|
2004-05-22 00:06:20 +04:00
|
|
|
int *allranks=NULL;
|
2007-08-04 04:41:26 +04:00
|
|
|
int *rranks=NULL;
|
2004-06-07 19:33:53 +04:00
|
|
|
int rc = OMPI_SUCCESS;
|
2004-05-22 00:06:20 +04:00
|
|
|
|
2007-08-04 04:41:26 +04:00
|
|
|
lsize = group->grp_proc_count;
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
if ( OMPI_COMM_IS_INTER(comm) ) {
|
2007-08-04 04:41:26 +04:00
|
|
|
int tsize;
|
|
|
|
|
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,
|
2007-08-19 07:37:49 +04:00
|
|
|
1, MPI_INT, comm,
|
|
|
|
comm->c_coll.coll_allgather_module);
|
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 */
|
2007-08-04 04:41:26 +04:00
|
|
|
rranks = (int *) malloc ( rsize * sizeof(int));
|
|
|
|
if ( NULL == rranks ) {
|
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] ) {
|
2007-08-04 04:41:26 +04:00
|
|
|
rranks[j] = i;
|
2004-05-22 00:06:20 +04:00
|
|
|
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;
|
2007-08-04 04:41:26 +04:00
|
|
|
rranks = 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
|
|
|
|
2007-08-04 04:41:26 +04:00
|
|
|
rc = ompi_comm_set ( &newcomp, /* new comm */
|
|
|
|
comm, /* old comm */
|
|
|
|
lsize, /* local_size */
|
|
|
|
NULL, /* local_ranks */
|
|
|
|
rsize, /* remote_size */
|
|
|
|
rranks, /* remote_ranks */
|
|
|
|
NULL, /* attrs */
|
|
|
|
comm->error_handler, /* error handler */
|
|
|
|
NULL, /* topo component */
|
|
|
|
group, /* local group */
|
|
|
|
NULL /* remote group */
|
|
|
|
);
|
|
|
|
if ( OMPI_SUCCESS != rc ) {
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( NULL == newcomm ) {
|
|
|
|
rc = MPI_ERR_INTERN;
|
2004-05-22 00:06:20 +04:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
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 */
|
so here is what happens:
in the v1.2 series the cid's could never go above the max. allowed for a
particular pml. Because of that, pml_add_comm never checked for the cid, and
in fact pml_add_comm was called in comm_set, which is *before* we knew the
cid.
in the v1.3 series (and trunk) we check now the cid to detect overflow, and
because of that pml_add_comm has been moved *after* the cid allocation
routine, namely into the comm_activate routine.
in the v1.2 series, the comm_activate contained a synchronization step of the
old communicator in order to prevent incoming fragments on the new
communicator, with the main problem being that the allreduce in the
communicator allocation finished at different times on different processes,
and thus, this scenario could and did really occur.
in the v1.3 series, the comm_activate does not contain the synchronization
step anymore, since we introduced the new queue for fragments with unknown
cid. The problem is however, that whether a fragment is known or not is
decided by using ompi_comm_lookup(), which will return something useful as
soon as the cid allocation finished, even before pml_add_comm has been
called. So there is a small time gap where we will not post a message into
queue for unknown cid's, but we can also not look up the process structure
belonging to the rank in that comm ( that is in pml_ob1_match_recv_frag or
something like that).
The current fix reintroduces the synchronization step in comm_activate, and
ensures that no fragment can be received for a new communicator before the
synchronization occurs , and thus comm_nextcid() and pml_add_comm has been
called. It seems to be the safest and easiest way for now. Welcome back, v1.2.
This commit was SVN r21970.
2009-09-17 18:37:02 +04:00
|
|
|
rc = ompi_comm_activate( &newcomp, /* new communicator */
|
2010-10-04 18:54:58 +04:00
|
|
|
comm,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
mode,
|
|
|
|
-1 );
|
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
|
|
|
}
|
2007-08-04 04:41:26 +04:00
|
|
|
|
2004-05-22 00:06:20 +04:00
|
|
|
exit:
|
|
|
|
if ( NULL != allranks ) {
|
|
|
|
free ( allranks );
|
|
|
|
}
|
2007-08-04 04:41:26 +04:00
|
|
|
if ( NULL != rranks ) {
|
|
|
|
free ( rranks );
|
2004-05-22 00:06:20 +04:00
|
|
|
}
|
|
|
|
|
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,
|
2010-10-04 18:54:58 +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;
|
2008-08-06 16:25:56 +04:00
|
|
|
ompi_communicator_t *newcomp = NULL;
|
2007-08-04 04:41:26 +04:00
|
|
|
int *lranks=NULL, *rranks=NULL;
|
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
|
|
|
}
|
|
|
|
|
2007-08-19 07:37:49 +04:00
|
|
|
rc = allgatherfct( myinfo, 2, MPI_INT, results, 2, MPI_INT, comm, comm->c_coll.coll_allgather_module );
|
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 */
|
2007-08-04 04:41:26 +04:00
|
|
|
lranks = (int *) malloc ( my_size * sizeof(int));
|
|
|
|
if ( NULL == lranks ) {
|
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++) {
|
2007-08-04 04:41:26 +04:00
|
|
|
lranks[i] = sorted[i*2];
|
2004-05-22 00:06:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* 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,
|
2007-08-19 07:37:49 +04:00
|
|
|
MPI_INT, comm,
|
|
|
|
comm->c_coll.coll_allgather_module);
|
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 */
|
2007-08-04 04:41:26 +04:00
|
|
|
rranks = (int *) malloc ( my_rsize * sizeof(int));
|
|
|
|
if ( NULL == rranks) {
|
2004-06-07 19:33:53 +04:00
|
|
|
rc = OMPI_ERR_OUT_OF_RESOURCE;
|
2004-05-22 00:06:20 +04:00
|
|
|
goto exit;
|
|
|
|
}
|
2007-08-04 04:41:26 +04:00
|
|
|
|
2004-05-22 00:06:20 +04:00
|
|
|
for (i = 0; i < my_rsize; i++) {
|
2007-08-04 04:41:26 +04:00
|
|
|
rranks[i] = rsorted[i*2];
|
2004-05-22 00:06:20 +04:00
|
|
|
}
|
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;
|
2007-08-04 04:41:26 +04:00
|
|
|
rranks = NULL;
|
2004-08-08 01:15:00 +04:00
|
|
|
mode = OMPI_COMM_CID_INTRA;
|
2004-05-22 00:06:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Step 3: set up the communicator */
|
|
|
|
/* --------------------------------------------------------- */
|
|
|
|
/* Create the communicator finally */
|
2007-08-04 04:41:26 +04:00
|
|
|
|
|
|
|
rc = ompi_comm_set ( &newcomp, /* new comm */
|
|
|
|
comm, /* old comm */
|
|
|
|
my_size, /* local_size */
|
|
|
|
lranks, /* local_ranks */
|
|
|
|
my_rsize, /* remote_size */
|
|
|
|
rranks, /* remote_ranks */
|
|
|
|
NULL, /* attrs */
|
|
|
|
comm->error_handler,/* error handler */
|
|
|
|
(pass_on_topo)?
|
|
|
|
(mca_base_component_t *)comm->c_topo_component:
|
|
|
|
NULL, /* topo component */
|
|
|
|
NULL, /* local group */
|
|
|
|
NULL /* remote group */
|
2010-10-04 18:54:58 +04:00
|
|
|
);
|
2007-08-04 04:41:26 +04:00
|
|
|
|
|
|
|
if ( NULL == newcomm ) {
|
|
|
|
rc = MPI_ERR_INTERN;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
if ( OMPI_SUCCESS != rc ) {
|
2004-06-16 19:40:52 +04:00
|
|
|
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
|
|
|
|
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 );
|
|
|
|
|
2010-02-20 02:45:30 +03:00
|
|
|
/* set the rank to MPI_UNDEFINED. This prevents in comm_activate
|
|
|
|
* the collective module selection for a communicator that will
|
|
|
|
* be freed anyway.
|
|
|
|
*/
|
|
|
|
if ( MPI_UNDEFINED == color ) {
|
2010-10-04 18:54:58 +04:00
|
|
|
newcomp->c_local_group->grp_my_rank = MPI_UNDEFINED;
|
2010-02-20 02:45:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-08-05 20:31:30 +04:00
|
|
|
/* Activate the communicator and init coll-component */
|
so here is what happens:
in the v1.2 series the cid's could never go above the max. allowed for a
particular pml. Because of that, pml_add_comm never checked for the cid, and
in fact pml_add_comm was called in comm_set, which is *before* we knew the
cid.
in the v1.3 series (and trunk) we check now the cid to detect overflow, and
because of that pml_add_comm has been moved *after* the cid allocation
routine, namely into the comm_activate routine.
in the v1.2 series, the comm_activate contained a synchronization step of the
old communicator in order to prevent incoming fragments on the new
communicator, with the main problem being that the allreduce in the
communicator allocation finished at different times on different processes,
and thus, this scenario could and did really occur.
in the v1.3 series, the comm_activate does not contain the synchronization
step anymore, since we introduced the new queue for fragments with unknown
cid. The problem is however, that whether a fragment is known or not is
decided by using ompi_comm_lookup(), which will return something useful as
soon as the cid allocation finished, even before pml_add_comm has been
called. So there is a small time gap where we will not post a message into
queue for unknown cid's, but we can also not look up the process structure
belonging to the rank in that comm ( that is in pml_ob1_match_recv_frag or
something like that).
The current fix reintroduces the synchronization step in comm_activate, and
ensures that no fragment can be received for a new communicator before the
synchronization occurs , and thus comm_nextcid() and pml_add_comm has been
called. It seems to be the safest and easiest way for now. Welcome back, v1.2.
This commit was SVN r21970.
2009-09-17 18:37:02 +04:00
|
|
|
rc = ompi_comm_activate( &newcomp, /* new communicator */
|
2010-10-04 18:54:58 +04:00
|
|
|
comm,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
mode,
|
|
|
|
-1 );
|
2004-08-05 20:31:30 +04:00
|
|
|
if ( OMPI_SUCCESS != rc ) {
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
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 ) {
|
2010-10-04 18:54:58 +04:00
|
|
|
free ( rsorted );
|
2004-05-22 00:06:20 +04:00
|
|
|
}
|
2007-08-04 04:41:26 +04:00
|
|
|
if ( NULL != lranks ) {
|
|
|
|
free ( lranks );
|
2004-05-22 00:06:20 +04:00
|
|
|
}
|
2007-08-04 04:41:26 +04:00
|
|
|
if ( NULL != rranks ) {
|
|
|
|
free ( rranks );
|
2004-05-22 00:06:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Step 4: if we are not part of the comm, free the struct */
|
|
|
|
/* --------------------------------------------------------- */
|
2008-08-06 16:25:56 +04:00
|
|
|
if ( NULL != newcomp && 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 );
|
|
|
|
}
|
2012-01-19 03:35:21 +04:00
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************/
|
|
|
|
/**********************************************************************/
|
|
|
|
/**********************************************************************/
|
|
|
|
int
|
|
|
|
ompi_comm_split_type(ompi_communicator_t *comm,
|
|
|
|
int split_type, int key,
|
|
|
|
ompi_info_t *info,
|
|
|
|
ompi_communicator_t** newcomm)
|
|
|
|
{
|
|
|
|
int myinfo[2];
|
|
|
|
int size, my_size;
|
|
|
|
int my_rsize;
|
|
|
|
int mode;
|
|
|
|
int rsize;
|
|
|
|
int i, loc;
|
|
|
|
int inter;
|
|
|
|
int *results=NULL, *sorted=NULL;
|
|
|
|
int *rresults=NULL, *rsorted=NULL;
|
|
|
|
int rc=OMPI_SUCCESS;
|
|
|
|
ompi_communicator_t *newcomp = NULL;
|
|
|
|
int *lranks=NULL, *rranks=NULL;
|
|
|
|
|
|
|
|
ompi_comm_allgatherfct *allgatherfct=NULL;
|
|
|
|
|
|
|
|
/* Step 1: determine all the information for the local group */
|
|
|
|
/* --------------------------------------------------------- */
|
|
|
|
|
|
|
|
/* sort according to participation and rank. Gather information from everyone */
|
|
|
|
myinfo[0] = (split_type == MPI_COMM_TYPE_SHARED) ? 1 : 0;
|
|
|
|
myinfo[1] = key;
|
|
|
|
|
|
|
|
size = ompi_comm_size ( comm );
|
|
|
|
inter = OMPI_COMM_IS_INTER(comm);
|
|
|
|
if ( inter ) {
|
|
|
|
allgatherfct = (ompi_comm_allgatherfct *)ompi_comm_allgather_emulate_intra;
|
|
|
|
} else {
|
|
|
|
allgatherfct = (ompi_comm_allgatherfct *)comm->c_coll.coll_allgather;
|
|
|
|
}
|
|
|
|
|
|
|
|
results = (int*) malloc ( 2 * size * sizeof(int));
|
|
|
|
if ( NULL == results ) {
|
|
|
|
return OMPI_ERR_OUT_OF_RESOURCE;
|
|
|
|
}
|
|
|
|
|
|
|
|
rc = allgatherfct( myinfo, 2, MPI_INT, results, 2, MPI_INT, comm, comm->c_coll.coll_allgather_module );
|
|
|
|
if ( OMPI_SUCCESS != rc ) {
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* how many are participating and on my node? */
|
|
|
|
for ( my_size = 0, i=0; i < size; i++) {
|
|
|
|
if ( results[(2*i)+0] == 1) {
|
|
|
|
if (OPAL_PROC_ON_LOCAL_NODE(ompi_group_peer_lookup(comm->c_local_group, i)->proc_flags)) {
|
|
|
|
my_size++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sorted = (int *) malloc ( sizeof( int ) * my_size * 2);
|
|
|
|
if ( NULL == sorted) {
|
|
|
|
rc = OMPI_ERR_OUT_OF_RESOURCE;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ok we can now fill this info */
|
|
|
|
for( loc = 0, i = 0; i < size; i++ ) {
|
|
|
|
if ( results[(2*i)+0] == 1) {
|
|
|
|
if (OPAL_PROC_ON_LOCAL_NODE(ompi_group_peer_lookup(comm->c_local_group, i)->proc_flags)) {
|
|
|
|
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 */
|
|
|
|
lranks = (int *) malloc ( my_size * sizeof(int));
|
|
|
|
if ( NULL == lranks ) {
|
|
|
|
rc = OMPI_ERR_OUT_OF_RESOURCE;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
for (i = 0; i < my_size; i++) {
|
|
|
|
lranks[i] = sorted[i*2];
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Step 2: determine all the information for the remote group */
|
|
|
|
/* --------------------------------------------------------- */
|
|
|
|
if ( inter ) {
|
|
|
|
rsize = comm->c_remote_group->grp_proc_count;
|
|
|
|
rresults = (int *) malloc ( rsize * 2 * sizeof(int));
|
|
|
|
if ( NULL == rresults ) {
|
|
|
|
rc = OMPI_ERR_OUT_OF_RESOURCE;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* this is an allgather on an inter-communicator */
|
|
|
|
rc = comm->c_coll.coll_allgather( myinfo, 2, MPI_INT, rresults, 2,
|
|
|
|
MPI_INT, comm,
|
|
|
|
comm->c_coll.coll_allgather_module);
|
|
|
|
if ( OMPI_SUCCESS != rc ) {
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* how many are participating and on my node? */
|
|
|
|
for ( my_rsize = 0, i=0; i < rsize; i++) {
|
|
|
|
if ( rresults[(2*i)+0] == 1) {
|
|
|
|
if (OPAL_PROC_ON_LOCAL_NODE(ompi_group_peer_lookup(comm->c_remote_group, i)->proc_flags)) {
|
|
|
|
my_rsize++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
rsorted = (int *) malloc ( sizeof( int ) * my_rsize * 2);
|
|
|
|
if ( NULL == rsorted) {
|
|
|
|
rc = OMPI_ERR_OUT_OF_RESOURCE;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ok we can now fill this info */
|
|
|
|
for( loc = 0, i = 0; i < rsize; i++ ) {
|
|
|
|
if ( rresults[(2*i)+0] == 1) {
|
|
|
|
if (OPAL_PROC_ON_LOCAL_NODE(ompi_group_peer_lookup(comm->c_remote_group, i)->proc_flags)) {
|
|
|
|
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 */
|
|
|
|
rranks = (int *) malloc ( my_rsize * sizeof(int));
|
|
|
|
if ( NULL == rranks) {
|
|
|
|
rc = OMPI_ERR_OUT_OF_RESOURCE;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < my_rsize; i++) {
|
|
|
|
rranks[i] = rsorted[i*2];
|
|
|
|
}
|
|
|
|
mode = OMPI_COMM_CID_INTER;
|
|
|
|
} else {
|
|
|
|
my_rsize = 0;
|
|
|
|
rranks = NULL;
|
|
|
|
mode = OMPI_COMM_CID_INTRA;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Step 3: set up the communicator */
|
|
|
|
/* --------------------------------------------------------- */
|
|
|
|
/* Create the communicator finally */
|
|
|
|
|
|
|
|
rc = ompi_comm_set ( &newcomp, /* new comm */
|
|
|
|
comm, /* old comm */
|
|
|
|
my_size, /* local_size */
|
|
|
|
lranks, /* local_ranks */
|
|
|
|
my_rsize, /* remote_size */
|
|
|
|
rranks, /* remote_ranks */
|
|
|
|
NULL, /* attrs */
|
|
|
|
comm->error_handler,/* error handler */
|
|
|
|
NULL, /* topo component */
|
|
|
|
NULL, /* local group */
|
|
|
|
NULL /* remote group */
|
|
|
|
);
|
|
|
|
|
|
|
|
if ( NULL == newcomm ) {
|
|
|
|
rc = MPI_ERR_INTERN;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
if ( OMPI_SUCCESS != rc ) {
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Determine context id. It is identical to f_2_c_handle */
|
|
|
|
rc = ompi_comm_nextcid ( newcomp, /* new communicator */
|
|
|
|
comm, /* old comm */
|
|
|
|
NULL, /* bridge comm */
|
|
|
|
NULL, /* local leader */
|
|
|
|
NULL, /* remote_leader */
|
|
|
|
mode, /* mode */
|
|
|
|
-1 ); /* send first, doesn't matter */
|
|
|
|
if ( OMPI_SUCCESS != rc ) {
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set name for debugging purposes */
|
|
|
|
snprintf(newcomp->c_name, MPI_MAX_OBJECT_NAME, "MPI COMMUNICATOR %d SPLIT_TYPE FROM %d",
|
|
|
|
newcomp->c_contextid, comm->c_contextid );
|
|
|
|
|
|
|
|
/* set the rank to MPI_UNDEFINED. This prevents in comm_activate
|
|
|
|
* the collective module selection for a communicator that will
|
|
|
|
* be freed anyway.
|
|
|
|
*/
|
|
|
|
if ( MPI_UNDEFINED == split_type ) {
|
|
|
|
newcomp->c_local_group->grp_my_rank = MPI_UNDEFINED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Activate the communicator and init coll-component */
|
|
|
|
rc = ompi_comm_activate( &newcomp, /* new communicator */
|
|
|
|
comm,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
mode,
|
|
|
|
-1 );
|
|
|
|
if ( OMPI_SUCCESS != rc ) {
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
exit:
|
|
|
|
if ( NULL != results ) {
|
|
|
|
free ( results );
|
|
|
|
}
|
|
|
|
if ( NULL != sorted ) {
|
|
|
|
free ( sorted );
|
|
|
|
}
|
|
|
|
if ( NULL != rresults) {
|
|
|
|
free ( rresults );
|
|
|
|
}
|
|
|
|
if ( NULL != rsorted ) {
|
|
|
|
free ( rsorted );
|
|
|
|
}
|
|
|
|
if ( NULL != lranks ) {
|
|
|
|
free ( lranks );
|
|
|
|
}
|
|
|
|
if ( NULL != rranks ) {
|
|
|
|
free ( rranks );
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Step 4: if we are not part of the comm, free the struct */
|
|
|
|
/* --------------------------------------------------------- */
|
|
|
|
if ( NULL != newcomp && MPI_UNDEFINED == split_type ) {
|
|
|
|
ompi_comm_free ( &newcomp );
|
|
|
|
}
|
|
|
|
|
|
|
|
*newcomm = newcomp;
|
|
|
|
return ( rc );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2004-06-16 01:29:29 +04:00
|
|
|
/**********************************************************************/
|
|
|
|
/**********************************************************************/
|
|
|
|
/**********************************************************************/
|
2008-11-05 00:58:06 +03:00
|
|
|
int ompi_comm_dup ( ompi_communicator_t * comm, ompi_communicator_t **newcomm )
|
2005-06-27 12:32:18 +04:00
|
|
|
{
|
|
|
|
ompi_communicator_t *comp=NULL;
|
|
|
|
ompi_communicator_t *newcomp=NULL;
|
2007-08-23 11:40:40 +04:00
|
|
|
int rsize, mode, rc=OMPI_SUCCESS;
|
2005-06-27 12:32:18 +04:00
|
|
|
|
|
|
|
comp = (ompi_communicator_t *) comm;
|
|
|
|
if ( OMPI_COMM_IS_INTER ( comp ) ){
|
|
|
|
rsize = comp->c_remote_group->grp_proc_count;
|
|
|
|
mode = OMPI_COMM_CID_INTER;
|
2007-04-06 23:18:31 +04:00
|
|
|
} else {
|
2005-06-27 12:32:18 +04:00
|
|
|
rsize = 0;
|
|
|
|
mode = OMPI_COMM_CID_INTRA;
|
|
|
|
}
|
|
|
|
|
|
|
|
*newcomm = MPI_COMM_NULL;
|
2007-08-04 04:41:26 +04:00
|
|
|
|
|
|
|
rc = ompi_comm_set ( &newcomp, /* new comm */
|
|
|
|
comp, /* old comm */
|
|
|
|
comp->c_local_group->grp_proc_count, /* local_size */
|
|
|
|
NULL, /* local_procs*/
|
|
|
|
rsize, /* remote_size */
|
|
|
|
NULL, /* remote_procs */
|
|
|
|
comp->c_keyhash, /* attrs */
|
|
|
|
comp->error_handler, /* error handler */
|
2013-01-02 22:32:46 +04:00
|
|
|
(mca_base_component_t *) comp->c_topo_component, /* topo component */
|
2007-08-04 04:41:26 +04:00
|
|
|
comp->c_local_group, /* local group */
|
2008-11-05 00:58:06 +03:00
|
|
|
comp ->c_remote_group ); /* remote group */
|
2012-04-04 20:41:55 +04:00
|
|
|
if ( NULL == newcomp ) {
|
2007-08-04 04:41:26 +04:00
|
|
|
rc = MPI_ERR_INTERN;
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
if ( MPI_SUCCESS != rc) {
|
|
|
|
return rc;
|
2005-06-27 12:32:18 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* 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 */
|
2007-08-23 11:40:40 +04:00
|
|
|
if ( OMPI_SUCCESS != rc ) {
|
2005-06-27 12:32:18 +04:00
|
|
|
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 );
|
|
|
|
|
2008-09-01 01:03:39 +04:00
|
|
|
/* activate communicator and init coll-module */
|
so here is what happens:
in the v1.2 series the cid's could never go above the max. allowed for a
particular pml. Because of that, pml_add_comm never checked for the cid, and
in fact pml_add_comm was called in comm_set, which is *before* we knew the
cid.
in the v1.3 series (and trunk) we check now the cid to detect overflow, and
because of that pml_add_comm has been moved *after* the cid allocation
routine, namely into the comm_activate routine.
in the v1.2 series, the comm_activate contained a synchronization step of the
old communicator in order to prevent incoming fragments on the new
communicator, with the main problem being that the allreduce in the
communicator allocation finished at different times on different processes,
and thus, this scenario could and did really occur.
in the v1.3 series, the comm_activate does not contain the synchronization
step anymore, since we introduced the new queue for fragments with unknown
cid. The problem is however, that whether a fragment is known or not is
decided by using ompi_comm_lookup(), which will return something useful as
soon as the cid allocation finished, even before pml_add_comm has been
called. So there is a small time gap where we will not post a message into
queue for unknown cid's, but we can also not look up the process structure
belonging to the rank in that comm ( that is in pml_ob1_match_recv_frag or
something like that).
The current fix reintroduces the synchronization step in comm_activate, and
ensures that no fragment can be received for a new communicator before the
synchronization occurs , and thus comm_nextcid() and pml_add_comm has been
called. It seems to be the safest and easiest way for now. Welcome back, v1.2.
This commit was SVN r21970.
2009-09-17 18:37:02 +04:00
|
|
|
rc = ompi_comm_activate( &newcomp, /* new communicator */
|
2010-10-04 18:54:58 +04:00
|
|
|
comp,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
mode,
|
|
|
|
-1 );
|
2008-09-01 01:03:39 +04:00
|
|
|
if ( OMPI_SUCCESS != rc ) {
|
|
|
|
return rc;
|
2007-08-04 04:41:26 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
*newcomm = newcomp;
|
|
|
|
return MPI_SUCCESS;
|
|
|
|
}
|
|
|
|
/**********************************************************************/
|
|
|
|
/**********************************************************************/
|
|
|
|
/**********************************************************************/
|
|
|
|
int ompi_comm_compare(ompi_communicator_t *comm1, ompi_communicator_t *comm2, int *result) {
|
|
|
|
/* local variables */
|
|
|
|
ompi_communicator_t *comp1, *comp2;
|
|
|
|
int size1, size2, rsize1, rsize2;
|
|
|
|
int lresult, rresult=MPI_CONGRUENT;
|
2012-03-09 18:39:09 +04:00
|
|
|
int cmp_result;
|
|
|
|
|
2007-08-04 04:41:26 +04:00
|
|
|
comp1 = (ompi_communicator_t *) comm1;
|
|
|
|
comp2 = (ompi_communicator_t *) comm2;
|
|
|
|
|
|
|
|
if ( comp1->c_contextid == comp2->c_contextid ) {
|
|
|
|
*result = MPI_IDENT;
|
|
|
|
return MPI_SUCCESS;
|
2005-06-27 12:32:18 +04:00
|
|
|
}
|
|
|
|
|
2007-08-04 04:41:26 +04:00
|
|
|
if ( MPI_COMM_NULL == comm1 || MPI_COMM_NULL == comm2 ) {
|
|
|
|
*result = MPI_UNEQUAL;
|
|
|
|
return MPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compare sizes of local and remote groups */
|
|
|
|
size1 = ompi_comm_size (comp1);
|
|
|
|
size2 = ompi_comm_size (comp2);
|
|
|
|
rsize1 = ompi_comm_remote_size (comp1);
|
|
|
|
rsize2 = ompi_comm_remote_size (comp2);
|
|
|
|
|
|
|
|
if ( size1 != size2 || rsize1 != rsize2 ) {
|
|
|
|
*result = MPI_UNEQUAL;
|
|
|
|
return MPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Compare local groups */
|
2012-03-09 18:39:09 +04:00
|
|
|
ompi_group_compare((ompi_group_t *)comp1->c_local_group,
|
|
|
|
(ompi_group_t *)comp2->c_local_group,
|
|
|
|
&cmp_result);
|
|
|
|
|
|
|
|
/* MPI_IDENT resulting from the group comparison is
|
|
|
|
* MPI_CONGRUENT for communicators.
|
|
|
|
* All others results are the same.
|
|
|
|
*/
|
|
|
|
if( MPI_IDENT == cmp_result ) {
|
2007-08-04 04:41:26 +04:00
|
|
|
lresult = MPI_CONGRUENT;
|
2010-10-04 18:54:58 +04:00
|
|
|
} else {
|
2012-03-09 18:39:09 +04:00
|
|
|
lresult = cmp_result;
|
2010-10-04 18:54:58 +04:00
|
|
|
}
|
2007-08-04 04:41:26 +04:00
|
|
|
|
|
|
|
|
|
|
|
if ( rsize1 > 0 ) {
|
|
|
|
/* Compare remote groups for inter-communicators */
|
2012-03-09 18:39:09 +04:00
|
|
|
ompi_group_compare((ompi_group_t *)comp1->c_remote_group,
|
|
|
|
(ompi_group_t *)comp2->c_remote_group,
|
|
|
|
&cmp_result);
|
2007-08-04 04:41:26 +04:00
|
|
|
|
2012-03-09 18:39:09 +04:00
|
|
|
/* MPI_IDENT resulting from the group comparison is
|
|
|
|
* MPI_CONGRUENT for communicators.
|
|
|
|
* All others results are the same.
|
|
|
|
*/
|
|
|
|
if( MPI_IDENT == cmp_result ) {
|
2007-08-04 04:41:26 +04:00
|
|
|
rresult = MPI_CONGRUENT;
|
2010-10-04 18:54:58 +04:00
|
|
|
} else {
|
2012-03-09 18:39:09 +04:00
|
|
|
rresult = cmp_result;
|
2010-10-04 18:54:58 +04:00
|
|
|
}
|
2007-08-04 04:41:26 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* determine final results */
|
|
|
|
if ( MPI_CONGRUENT == rresult ) {
|
|
|
|
*result = lresult;
|
|
|
|
}
|
|
|
|
else if ( MPI_SIMILAR == rresult ) {
|
|
|
|
if ( MPI_SIMILAR == lresult || MPI_CONGRUENT == lresult ) {
|
|
|
|
*result = MPI_SIMILAR;
|
|
|
|
}
|
2010-10-04 18:54:58 +04:00
|
|
|
else {
|
2007-08-04 04:41:26 +04:00
|
|
|
*result = MPI_UNEQUAL;
|
2010-10-04 18:54:58 +04:00
|
|
|
}
|
2007-08-04 04:41:26 +04:00
|
|
|
}
|
2010-10-04 18:54:58 +04:00
|
|
|
else if ( MPI_UNEQUAL == rresult ) {
|
2007-08-04 04:41:26 +04:00
|
|
|
*result = MPI_UNEQUAL;
|
2010-10-04 18:54:58 +04:00
|
|
|
}
|
2007-08-04 04:41:26 +04:00
|
|
|
|
2007-08-23 11:40:40 +04:00
|
|
|
return OMPI_SUCCESS;
|
2005-06-27 12:32:18 +04:00
|
|
|
}
|
|
|
|
/**********************************************************************/
|
|
|
|
/**********************************************************************/
|
|
|
|
/**********************************************************************/
|
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,
|
2007-08-19 07:37:49 +04:00
|
|
|
ompi_communicator_t *comm,
|
2008-07-29 02:40:57 +04:00
|
|
|
mca_coll_base_module_t *data)
|
2004-06-16 01:29:29 +04:00
|
|
|
{
|
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,
|
2010-10-04 18:54:58 +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,
|
2010-10-04 18:54:58 +04:00
|
|
|
OMPI_COMM_ALLGATHER_TAG,
|
|
|
|
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;
|
2010-02-20 02:45:30 +03:00
|
|
|
int cid = (*comm)->c_contextid;
|
2010-02-24 00:24:07 +03:00
|
|
|
int is_extra_retain = OMPI_COMM_IS_EXTRA_RETAIN(*comm);
|
2010-02-20 02:45:30 +03:00
|
|
|
|
2004-10-21 02:54:34 +04:00
|
|
|
|
|
|
|
/* 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
|
2010-10-04 18:54:58 +04:00
|
|
|
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.
|
2004-10-21 02:54:34 +04:00
|
|
|
|
|
|
|
2. Releasing attributes in ompi_comm_free() enables us to check
|
2010-10-04 18:54:58 +04:00
|
|
|
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) {
|
2009-02-24 20:17:33 +03:00
|
|
|
ompi_mpi_comm_parent = &ompi_mpi_comm_null.comm;
|
2004-11-08 08:04:54 +03:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2010-02-24 00:24:07 +03:00
|
|
|
if ( is_extra_retain) {
|
|
|
|
/* This communicator has been marked as an "extra retain"
|
2010-02-20 02:45:30 +03:00
|
|
|
* communicator. This can happen if a communicator creates
|
|
|
|
* 'dependent' subcommunicators (e.g. for inter
|
|
|
|
* communicators or when using hierarch collective
|
|
|
|
* module *and* the cid of the dependent communicator
|
|
|
|
* turned out to be lower than of the parent one.
|
|
|
|
* In that case, the reference counter has been increased
|
|
|
|
* by one more, in order to handle the scenario,
|
|
|
|
* that the user did not free the communicator.
|
|
|
|
* Note, that if we enter this routine, we can
|
|
|
|
* decrease the counter by one more therefore. However,
|
|
|
|
* in ompi_comm_finalize, we only used OBJ_RELEASE instead
|
|
|
|
* of ompi_comm_free(), and the increased reference counter
|
|
|
|
* makes sure that the pointer to the dependent communicator
|
|
|
|
* still contains a valid object.
|
|
|
|
*/
|
2010-02-20 13:47:37 +03:00
|
|
|
ompi_communicator_t *tmpcomm = (ompi_communicator_t *) opal_pointer_array_get_item(&ompi_mpi_communicators, cid);
|
2010-02-20 02:45:30 +03:00
|
|
|
if ( NULL != tmpcomm ){
|
|
|
|
OBJ_RELEASE (tmpcomm);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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,
|
2011-10-04 18:50:31 +04:00
|
|
|
int 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;
|
2012-06-27 05:28:28 +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;
|
2008-02-28 04:57:57 +03:00
|
|
|
opal_buffer_t *sbuf=NULL, *rbuf=NULL;
|
2004-09-16 14:07:42 +04:00
|
|
|
void *sendbuf;
|
|
|
|
char *recvbuf;
|
2007-08-04 04:41:26 +04:00
|
|
|
ompi_proc_t **proc_list=NULL;
|
|
|
|
int i;
|
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) {
|
2008-02-28 04:57:57 +03:00
|
|
|
sbuf = OBJ_NEW(opal_buffer_t);
|
2005-03-14 23:57:21 +03:00
|
|
|
if (NULL == sbuf) {
|
2011-10-04 18:50:31 +04:00
|
|
|
rc = OMPI_ERROR;
|
2005-03-14 23:57:21 +03:00
|
|
|
goto err_exit;
|
2007-08-04 04:41:26 +04:00
|
|
|
}
|
|
|
|
if(OMPI_GROUP_IS_DENSE(local_comm->c_local_group)) {
|
|
|
|
rc = ompi_proc_pack(local_comm->c_local_group->grp_proc_pointers,
|
|
|
|
local_size, sbuf);
|
|
|
|
}
|
|
|
|
/* get the proc list for the sparse implementations */
|
|
|
|
else {
|
|
|
|
proc_list = (ompi_proc_t **) calloc (local_comm->c_local_group->grp_proc_count,
|
|
|
|
sizeof (ompi_proc_t *));
|
|
|
|
for(i=0 ; i<local_comm->c_local_group->grp_proc_count ; i++)
|
|
|
|
proc_list[i] = ompi_group_peer_lookup(local_comm->c_local_group,i);
|
|
|
|
rc = ompi_proc_pack (proc_list, local_size, sbuf);
|
2005-03-14 23:57:21 +03:00
|
|
|
}
|
2004-08-04 21:06:33 +04:00
|
|
|
if ( OMPI_SUCCESS != rc ) {
|
2004-08-04 02:07:45 +04:00
|
|
|
goto err_exit;
|
|
|
|
}
|
2011-10-04 18:50:31 +04:00
|
|
|
if (OPAL_SUCCESS != (rc = opal_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,
|
2007-08-19 07:37:49 +04:00
|
|
|
local_leader, local_comm,
|
|
|
|
local_comm->c_coll.coll_bcast_module );
|
2004-08-04 21:06:33 +04:00
|
|
|
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-08-04 04:41:26 +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,
|
2010-10-04 18:54:58 +04:00
|
|
|
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-08-04 04:41:26 +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,
|
2007-08-19 07:37:49 +04:00
|
|
|
local_leader, local_comm,
|
|
|
|
local_comm->c_coll.coll_bcast_module);
|
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
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
rbuf = OBJ_NEW(opal_buffer_t);
|
2006-12-07 19:19:44 +03:00
|
|
|
if (NULL == rbuf) {
|
2011-10-04 18:50:31 +04:00
|
|
|
rc = OMPI_ERROR;
|
2006-12-07 19:19:44 +03:00
|
|
|
goto err_exit;
|
|
|
|
}
|
|
|
|
|
2012-06-27 05:28:28 +04:00
|
|
|
if (ORTE_SUCCESS != (rc = opal_dss.load(rbuf, recvbuf, rlen))) {
|
2006-12-07 19:19:44 +03:00
|
|
|
goto err_exit;
|
|
|
|
}
|
2004-05-22 00:06:20 +04:00
|
|
|
|
These changes were mostly captured in a prior RFC (except for #2 below) and are aimed specifically at improving startup performance and setting up the remaining modifications described in that RFC.
The commit has been tested for C/R and Cray operations, and on Odin (SLURM, rsh) and RoadRunner (TM). I tried to update all environments, but obviously could not test them. I know that Windows needs some work, and have highlighted what is know to be needed in the odls process component.
This represents a lot of work by Brian, Tim P, Josh, and myself, with much advice from Jeff and others. For posterity, I have appended a copy of the email describing the work that was done:
As we have repeatedly noted, the modex operation in MPI_Init is the single greatest consumer of time during startup. To-date, we have executed that operation as an ORTE stage gate that held the process until a startup message containing all required modex (and OOB contact info - see #3 below) info could be sent to it. Each process would send its data to the HNP's registry, which assembled and sent the message when all processes had reported in.
In addition, ORTE had taken responsibility for monitoring process status as it progressed through a series of "stage gates". The process reported its status at each gate, and ORTE would then send a "release" message once all procs had reported in.
The incoming changes revamp these procedures in three ways:
1. eliminating the ORTE stage gate system and cleanly delineating responsibility between the OMPI and ORTE layers for MPI init/finalize. The modex stage gate (STG1) has been replaced by a collective operation in the modex itself that performs an allgather on the required modex info. The allgather is implemented using the orte_grpcomm framework since the BTL's are not active at that point. At the moment, the grpcomm framework only has a "basic" component analogous to OMPI's "basic" coll framework - I would recommend that the MPI team create additional, more advanced components to improve performance of this step.
The other stage gates have been replaced by orte_grpcomm barrier functions. We tried to use MPI barriers instead (since the BTL's are active at that point), but - as we discussed on the telecon - these are not currently true barriers so the job would hang when we fell through while messages were still in process. Note that the grpcomm barrier doesn't actually resolve that problem, but Brian has pointed out that we are unlikely to ever see it violated. Again, you might want to spend a little time on an advanced barrier algorithm as the one in "basic" is very simplistic.
Summarizing this change: ORTE no longer tracks process state nor has direct responsibility for synchronizing jobs. This is now done via collective operations within the MPI layer, albeit using ORTE collective communication services. I -strongly- urge the MPI team to implement advanced collective algorithms to improve the performance of this critical procedure.
2. reducing the volume of data exchanged during modex. Data in the modex consisted of the process name, the name of the node where that process is located (expressed as a string), plus a string representation of all contact info. The nodename was required in order for the modex to determine if the process was local or not - in addition, some people like to have it to print pretty error messages when a connection failed.
The size of this data has been reduced in three ways:
(a) reducing the size of the process name itself. The process name consisted of two 32-bit fields for the jobid and vpid. This is far larger than any current system, or system likely to exist in the near future, can support. Accordingly, the default size of these fields has been reduced to 16-bits, which means you can have 32k procs in each of 32k jobs. Since the daemons must have a vpid, and we require one daemon/node, this also restricts the default configuration to 32k nodes.
To support any future "mega-clusters", a configuration option --enable-jumbo-apps has been added. This option increases the jobid and vpid field sizes to 32-bits. Someday, if necessary, someone can add yet another option to increase them to 64-bits, I suppose.
(b) replacing the string nodename with an integer nodeid. Since we have one daemon/node, the nodeid corresponds to the local daemon's vpid. This replaces an often lengthy string with only 2 (or at most 4) bytes, a substantial reduction.
(c) when the mca param requesting that nodenames be sent to support pretty error messages, a second mca param is now used to request FQDN - otherwise, the domain name is stripped (by default) from the message to save space. If someone wants to combine those into a single param somehow (perhaps with an argument?), they are welcome to do so - I didn't want to alter what people are already using.
While these may seem like small savings, they actually amount to a significant impact when aggregated across the entire modex operation. Since every proc must receive the modex data regardless of the collective used to send it, just reducing the size of the process name removes nearly 400MBytes of communication from a 32k proc job (admittedly, much of this comm may occur in parallel). So it does add up pretty quickly.
3. routing RML messages to reduce connections. The default messaging system remains point-to-point - i.e., each proc opens a socket to every proc it communicates with and sends its messages directly. A new option uses the orteds as routers - i.e., each proc only opens a single socket to its local orted. All messages are sent from the proc to the orted, which forwards the message to the orted on the node where the intended recipient proc is located - that orted then forwards the message to its local proc (the recipient). This greatly reduces the connection storm we have encountered during startup.
It also has the benefit of removing the sharing of every proc's OOB contact with every other proc. The orted routing tables are populated during launch since every orted gets a map of where every proc is being placed. Each proc, therefore, only needs to know the contact info for its local daemon, which is passed in via the environment when the proc is fork/exec'd by the daemon. This alone removes ~50 bytes/process of communication that was in the current STG1 startup message - so for our 32k proc job, this saves us roughly 32k*50 = 1.6MBytes sent to 32k procs = 51GBytes of messaging.
Note that you can use the new routing method by specifying -mca routed tree - if you so desire. This mode will become the default at some point in the future.
There are a few minor additional changes in the commit that I'll just note in passing:
* propagation of command line mca params to the orteds - fixes ticket #1073. See note there for details.
* requiring of "finalize" prior to "exit" for MPI procs - fixes ticket #1144. See note there for details.
* cleanup of some stale header files
This commit was SVN r16364.
2007-10-05 23:48:23 +04:00
|
|
|
/* decode the names into a proc-list -- will never add a new proc
|
|
|
|
as the result of this operation, so no need to get the newprocs
|
|
|
|
list or call PML add_procs(). */
|
|
|
|
rc = ompi_proc_unpack(rbuf, rsize, &rprocs, NULL, NULL);
|
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 */
|
2011-10-04 18:50:31 +04:00
|
|
|
if ( OMPI_SUCCESS != rc ) {
|
2008-06-09 18:53:58 +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);
|
|
|
|
}
|
2007-08-04 04:41:26 +04:00
|
|
|
if ( NULL != proc_list ) {
|
|
|
|
free ( proc_list );
|
|
|
|
}
|
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,
|
2010-10-04 18:54:58 +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;
|
2012-06-27 05:28:28 +04: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,
|
2007-08-19 07:37:49 +04:00
|
|
|
MPI_INT, intercomm,
|
|
|
|
intercomm->c_coll.coll_allgatherv_module);
|
2004-08-04 02:07:45 +04:00
|
|
|
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 {
|
2007-08-04 04:41:26 +04:00
|
|
|
ourproc = ompi_group_peer_lookup(intercomm->c_local_group,0);
|
|
|
|
theirproc = ompi_group_peer_lookup(intercomm->c_remote_group,0);
|
2004-08-04 21:06:33 +04:00
|
|
|
|
2012-06-27 05:28:28 +04:00
|
|
|
mask = ORTE_NS_CMP_JOBID | ORTE_NS_CMP_VPID;
|
|
|
|
rc = orte_util_compare_name_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
|
|
|
{
|
2008-06-09 18:53:58 +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,
|
2007-08-04 04:41:26 +04:00
|
|
|
comm->c_cube_dim);
|
2008-06-09 18:53:58 +04:00
|
|
|
opal_output(0," Local group: size = %d my_rank = %d\n",
|
2007-08-04 04:41:26 +04:00
|
|
|
comm->c_local_group->grp_proc_count,
|
|
|
|
comm->c_local_group->grp_my_rank );
|
2004-05-22 00:06:20 +04:00
|
|
|
|
2008-06-09 18:53:58 +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) )
|
2008-06-09 18:53:58 +04:00
|
|
|
opal_output(0," inter-comm,");
|
2004-06-07 19:33:53 +04:00
|
|
|
if ( OMPI_COMM_IS_CART(comm))
|
2008-06-09 18:53:58 +04:00
|
|
|
opal_output(0," topo-cart,");
|
2004-06-07 19:33:53 +04:00
|
|
|
if ( OMPI_COMM_IS_GRAPH(comm))
|
2008-06-09 18:53:58 +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)) {
|
2008-06-09 18:53:58 +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
|
|
|
}
|
2007-08-23 11:40:40 +04:00
|
|
|
return OMPI_SUCCESS;
|
2004-05-22 00:06:20 +04:00
|
|
|
}
|
|
|
|
/********************************************************************************/
|
|
|
|
/********************************************************************************/
|
|
|
|
/********************************************************************************/
|
|
|
|
/* 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;
|
2007-08-04 04:41:26 +04:00
|
|
|
ompi_proc_t **proc_list=NULL;
|
|
|
|
int i;
|
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;
|
|
|
|
|
2008-08-31 23:31:10 +04:00
|
|
|
/* MPI-2.1 allows 0-dimension cartesian communicators, so prevent
|
|
|
|
a 0-byte malloc -- leave dims_or_index as NULL */
|
|
|
|
if (!(OMPI_COMM_CART == cart_or_graph && 0 == ndims_or_nnodes)) {
|
|
|
|
new_comm->c_topo_comm->mtc_dims_or_index =
|
|
|
|
(int *) malloc(sizeof(int) * ndims_or_nnodes);
|
|
|
|
if (NULL == new_comm->c_topo_comm->mtc_dims_or_index) {
|
|
|
|
ompi_comm_free (&new_comm);
|
|
|
|
*comm_topo = new_comm;
|
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
|
|
|
memcpy (new_comm->c_topo_comm->mtc_dims_or_index,
|
|
|
|
dims_or_index, ndims_or_nnodes * sizeof(int));
|
2004-07-21 02:21:47 +04:00
|
|
|
}
|
2008-03-05 15:22:34 +03:00
|
|
|
|
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 *));
|
2007-08-04 04:41:26 +04:00
|
|
|
|
|
|
|
if(OMPI_GROUP_IS_DENSE(old_comm->c_local_group)) {
|
|
|
|
memcpy (topo_procs,
|
|
|
|
old_comm->c_local_group->grp_proc_pointers,
|
|
|
|
num_procs * sizeof(ompi_proc_t *));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
proc_list = (ompi_proc_t **) calloc (old_comm->c_local_group->grp_proc_count,
|
|
|
|
sizeof (ompi_proc_t *));
|
2010-10-04 18:54:58 +04:00
|
|
|
for(i=0 ; i<old_comm->c_local_group->grp_proc_count ; i++) {
|
2007-08-04 04:41:26 +04:00
|
|
|
proc_list[i] = ompi_group_peer_lookup(old_comm->c_local_group,i);
|
2010-10-04 18:54:58 +04:00
|
|
|
}
|
2007-08-04 04:41:26 +04:00
|
|
|
|
|
|
|
memcpy (topo_procs,
|
|
|
|
proc_list,
|
|
|
|
num_procs * sizeof(ompi_proc_t *));
|
|
|
|
|
|
|
|
}
|
|
|
|
if ( NULL != proc_list ) {
|
|
|
|
free ( proc_list );
|
|
|
|
}
|
2004-07-21 02:21:47 +04:00
|
|
|
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
|
|
|
|
2008-08-31 23:31:10 +04:00
|
|
|
if (ndims_or_nnodes > 0) {
|
|
|
|
new_comm->c_topo_comm->mtc_periods_or_edges =
|
|
|
|
(int*) malloc(sizeof(int) * ndims_or_nnodes);
|
|
|
|
if (NULL == new_comm->c_topo_comm->mtc_periods_or_edges) {
|
|
|
|
ompi_comm_free (&new_comm);
|
|
|
|
*comm_topo = new_comm;
|
|
|
|
return OMPI_ERR_OUT_OF_RESOURCE;
|
|
|
|
}
|
|
|
|
memcpy (new_comm->c_topo_comm->mtc_periods_or_edges,
|
|
|
|
periods_or_edges, ndims_or_nnodes * sizeof(int));
|
|
|
|
|
|
|
|
new_comm->c_topo_comm->mtc_coords =
|
|
|
|
(int *) malloc(sizeof(int) * ndims_or_nnodes);
|
|
|
|
if (NULL == new_comm->c_topo_comm->mtc_coords) {
|
|
|
|
ompi_comm_free (&new_comm);
|
|
|
|
*comm_topo = new_comm;
|
|
|
|
return OMPI_ERR_OUT_OF_RESOURCE;
|
|
|
|
}
|
2004-07-21 02:21:47 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
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 *)
|
2010-10-04 18:54:58 +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,
|
|
|
|
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 */
|
2010-10-04 18:54:58 +04:00
|
|
|
-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
|
|
|
|
so here is what happens:
in the v1.2 series the cid's could never go above the max. allowed for a
particular pml. Because of that, pml_add_comm never checked for the cid, and
in fact pml_add_comm was called in comm_set, which is *before* we knew the
cid.
in the v1.3 series (and trunk) we check now the cid to detect overflow, and
because of that pml_add_comm has been moved *after* the cid allocation
routine, namely into the comm_activate routine.
in the v1.2 series, the comm_activate contained a synchronization step of the
old communicator in order to prevent incoming fragments on the new
communicator, with the main problem being that the allreduce in the
communicator allocation finished at different times on different processes,
and thus, this scenario could and did really occur.
in the v1.3 series, the comm_activate does not contain the synchronization
step anymore, since we introduced the new queue for fragments with unknown
cid. The problem is however, that whether a fragment is known or not is
decided by using ompi_comm_lookup(), which will return something useful as
soon as the cid allocation finished, even before pml_add_comm has been
called. So there is a small time gap where we will not post a message into
queue for unknown cid's, but we can also not look up the process structure
belonging to the rank in that comm ( that is in pml_ob1_match_recv_frag or
something like that).
The current fix reintroduces the synchronization step in comm_activate, and
ensures that no fragment can be received for a new communicator before the
synchronization occurs , and thus comm_nextcid() and pml_add_comm has been
called. It seems to be the safest and easiest way for now. Welcome back, v1.2.
This commit was SVN r21970.
2009-09-17 18:37:02 +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 */
|
2010-10-04 18:54:58 +04:00
|
|
|
-1 ); /* send first, doesn't matter */
|
so here is what happens:
in the v1.2 series the cid's could never go above the max. allowed for a
particular pml. Because of that, pml_add_comm never checked for the cid, and
in fact pml_add_comm was called in comm_set, which is *before* we knew the
cid.
in the v1.3 series (and trunk) we check now the cid to detect overflow, and
because of that pml_add_comm has been moved *after* the cid allocation
routine, namely into the comm_activate routine.
in the v1.2 series, the comm_activate contained a synchronization step of the
old communicator in order to prevent incoming fragments on the new
communicator, with the main problem being that the allreduce in the
communicator allocation finished at different times on different processes,
and thus, this scenario could and did really occur.
in the v1.3 series, the comm_activate does not contain the synchronization
step anymore, since we introduced the new queue for fragments with unknown
cid. The problem is however, that whether a fragment is known or not is
decided by using ompi_comm_lookup(), which will return something useful as
soon as the cid allocation finished, even before pml_add_comm has been
called. So there is a small time gap where we will not post a message into
queue for unknown cid's, but we can also not look up the process structure
belonging to the rank in that comm ( that is in pml_ob1_match_recv_frag or
something like that).
The current fix reintroduces the synchronization step in comm_activate, and
ensures that no fragment can be received for a new communicator before the
synchronization occurs , and thus comm_nextcid() and pml_add_comm has been
called. It seems to be the safest and easiest way for now. Welcome back, v1.2.
This commit was SVN r21970.
2009-09-17 18:37:02 +04:00
|
|
|
|
|
|
|
|
2004-07-21 02:21:47 +04:00
|
|
|
if (OMPI_SUCCESS != ret) {
|
2010-10-04 18:54:58 +04:00
|
|
|
/* something wrong happened during setting the communicator */
|
|
|
|
*comm_topo = new_comm;
|
|
|
|
return ret;
|
2004-07-21 02:21:47 +04:00
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
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. */
|
2008-02-28 04:57:57 +03:00
|
|
|
ompi_dpm.mark_dyncomm (comm);
|
2004-10-26 15:37:58 +04:00
|
|
|
|
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
|
|
|
|
2010-10-04 18:54:58 +04:00
|
|
|
return OMPI_SUCCESS;
|
2004-07-21 02:21:47 +04:00
|
|
|
}
|
2004-10-05 20:32:52 +04:00
|
|
|
|
|
|
|
static int ompi_comm_copy_topo (ompi_communicator_t *oldcomm,
|
2010-10-04 18:54:58 +04:00
|
|
|
ompi_communicator_t *newcomm)
|
2008-06-26 20:59:31 +04:00
|
|
|
{
|
|
|
|
mca_topo_base_comm_t *oldt = oldcomm->c_topo_comm;
|
|
|
|
mca_topo_base_comm_t *newt = newcomm->c_topo_comm;
|
|
|
|
|
|
|
|
/* pointers for the rest of the information have been set
|
|
|
|
up.... simply allocate enough space and copy all the
|
2008-08-31 23:31:10 +04:00
|
|
|
information from the previous one. Remember that MPI-2.1
|
|
|
|
allows for 0-dimensional Cartesian communicators. */
|
2008-06-26 20:59:31 +04:00
|
|
|
|
|
|
|
newt->mtc_ndims_or_nnodes = oldt->mtc_ndims_or_nnodes;
|
|
|
|
newt->mtc_reorder = oldt->mtc_reorder;
|
2008-08-31 23:31:10 +04:00
|
|
|
if (OMPI_COMM_IS_CART(oldcomm) && 0 == oldt->mtc_ndims_or_nnodes) {
|
|
|
|
newt->mtc_dims_or_index = NULL;
|
|
|
|
newt->mtc_periods_or_edges = NULL;
|
|
|
|
newt->mtc_coords = NULL;
|
|
|
|
return MPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2008-06-26 20:59:31 +04:00
|
|
|
newt->mtc_dims_or_index =
|
|
|
|
(int *)malloc(sizeof(int) * newt->mtc_ndims_or_nnodes);
|
|
|
|
if (NULL == newt->mtc_dims_or_index) {
|
2008-08-31 23:31:10 +04:00
|
|
|
return OMPI_ERR_OUT_OF_RESOURCE;
|
2004-10-05 20:32:52 +04:00
|
|
|
}
|
2008-06-26 20:59:31 +04:00
|
|
|
memcpy (newt->mtc_dims_or_index, oldt->mtc_dims_or_index,
|
|
|
|
newt->mtc_ndims_or_nnodes * sizeof(int));
|
2004-10-05 20:32:52 +04:00
|
|
|
|
2008-06-26 20:59:31 +04:00
|
|
|
/* Note that the length of the mtc_periods_or_edges array is
|
|
|
|
different depending whether it's a cartesian or graph */
|
2004-10-05 20:32:52 +04:00
|
|
|
if (OMPI_COMM_IS_CART(oldcomm)) {
|
2008-06-26 20:59:31 +04:00
|
|
|
newt->mtc_periods_or_edges =
|
|
|
|
(int*) malloc (sizeof(int) * oldt->mtc_ndims_or_nnodes);
|
|
|
|
if (NULL == newt->mtc_periods_or_edges) {
|
|
|
|
return OMPI_ERR_OUT_OF_RESOURCE;
|
|
|
|
}
|
|
|
|
|
|
|
|
newt->mtc_coords =
|
|
|
|
(int *)malloc(sizeof(int)*
|
|
|
|
newcomm->c_topo_comm->mtc_ndims_or_nnodes);
|
|
|
|
if (NULL == newt->mtc_coords) {
|
2004-10-05 20:32:52 +04:00
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
2008-06-26 20:59:31 +04:00
|
|
|
memcpy(newt->mtc_periods_or_edges, oldt->mtc_periods_or_edges,
|
|
|
|
sizeof(int) * oldt->mtc_ndims_or_nnodes);
|
2004-10-05 20:32:52 +04:00
|
|
|
|
2008-06-26 20:59:31 +04:00
|
|
|
memcpy (newt->mtc_coords, oldt->mtc_coords,
|
|
|
|
sizeof(int) * newt->mtc_ndims_or_nnodes);
|
2004-10-05 20:32:52 +04:00
|
|
|
} else {
|
2008-06-26 20:59:31 +04:00
|
|
|
int index = oldt->mtc_dims_or_index[oldt->mtc_ndims_or_nnodes-1];
|
|
|
|
index = (index > 0) ? index : -index;
|
|
|
|
newt->mtc_periods_or_edges =
|
|
|
|
(int*) malloc (sizeof(int)*index);
|
|
|
|
if (NULL == newt->mtc_periods_or_edges) {
|
|
|
|
return OMPI_ERR_OUT_OF_RESOURCE;
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy(newt->mtc_periods_or_edges, oldt->mtc_periods_or_edges,
|
|
|
|
sizeof(int) * index );
|
|
|
|
|
|
|
|
newt->mtc_coords = NULL;
|
2004-10-05 20:32:52 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|