2014-05-15 01:15:33 +04:00
|
|
|
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
|
2004-02-05 04:52:56 +03: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.
|
2013-07-01 16:40:08 +04:00
|
|
|
* Copyright (c) 2004-2013 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.
|
2010-01-07 19:26:30 +03:00
|
|
|
* Copyright (c) 2006-2010 University of Houston. All rights reserved.
|
== Highlights ==
1. New mpifort wrapper compiler: you can utilize mpif.h, use mpi, and use mpi_f08 through this one wrapper compiler
1. mpif77 and mpif90 still exist, but are sym links to mpifort and may be removed in a future release
1. The mpi module has been re-implemented and is significantly "mo' bettah"
1. The mpi_f08 module offers many, many improvements over mpif.h and the mpi module
This stuff is coming from a VERY long-lived mercurial branch (3 years!); it'll almost certainly take a few SVN commits and a bunch of testing before I get it correctly committed to the SVN trunk.
== More details ==
Craig Rasmussen and I have been working with the MPI-3 Fortran WG and Fortran J3 committees for a long, long time to make a prototype MPI-3 Fortran bindings implementation. We think we're at a stable enough state to bring this stuff back to the trunk, with the goal of including it in OMPI v1.7.
Special thanks go out to everyone who has been incredibly patient and helpful to us in this journey:
* Rolf Rabenseifner/HLRS (mastermind/genius behind the entire MPI-3 Fortran effort)
* The Fortran J3 committee
* Tobias Burnus/gfortran
* Tony !Goetz/Absoft
* Terry !Donte/Oracle
* ...and probably others whom I'm forgetting :-(
There's still opportunities for optimization in the mpi_f08 implementation, but by and large, it is as far along as it can be until Fortran compilers start implementing the new F08 dimension(..) syntax.
Note that gfortran is currently unsupported for the mpi_f08 module and the new mpi module. gfortran users will a) fall back to the same mpi module implementation that is in OMPI v1.5.x, and b) not get the new mpi_f08 module. The gfortran maintainers are actively working hard to add the necessary features to support both the new mpi_f08 module and the new mpi module implementations. This will take some time.
As mentioned above, ompi/mpi/f77 and ompi/mpi/f90 no longer exist. All the fortran bindings implementations have been collated under ompi/mpi/fortran; each implementation has its own subdirectory:
{{{
ompi/mpi/fortran/
base/ - glue code
mpif-h/ - what used to be ompi/mpi/f77
use-mpi-tkr/ - what used to be ompi/mpi/f90
use-mpi-ignore-tkr/ - new mpi module implementation
use-mpi-f08/ - new mpi_f08 module implementation
}}}
There's also a prototype 6-function-MPI implementation under use-mpi-f08-desc that emulates the new F08 dimension(..) syntax that isn't fully available in Fortran compilers yet. We did that to prove it to ourselves that it could be done once the compilers fully support it. This directory/implementation will likely eventually replace the use-mpi-f08 version.
Other things that were done:
* ompi_info grew a few new output fields to describe what level of Fortran support is included
* Existing Fortran examples in examples/ were renamed; new mpi_f08 examples were added
* The old Fortran MPI libraries were renamed:
* libmpi_f77 -> libmpi_mpifh
* libmpi_f90 -> libmpi_usempi
* The configury for Fortran was consolidated and significantly slimmed down. Note that the F77 env variable is now IGNORED for configure; you should only use FC. Example:
{{{
shell$ ./configure CC=icc CXX=icpc FC=ifort ...
}}}
All of this work was done in a Mercurial branch off the SVN trunk, and hosted at Bitbucket. This branch has got to be one of OMPI's longest-running branches. Its first commit was Tue Apr 07 23:01:46 2009 -0400 -- it's over 3 years old! :-) We think we've pulled in all relevant changes from the OMPI trunk (e.g., Fortran implementations of the new MPI-3 MPROBE stuff for mpif.h, use mpi, and use mpi_f08, and the recent Fujitsu Fortran patches).
I anticipate some instability when we bring this stuff into the trunk, simply because it touches a LOT of code in the MPI layer in the OMPI code base. We'll try our best to make it as pain-free as possible, but please bear with us when it is committed.
This commit was SVN r26283.
2012-04-18 19:57:29 +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.
|
2014-05-15 01:15:33 +04:00
|
|
|
* Copyright (c) 2012-2014 Los Alamos National Security, LLC.
|
2014-05-17 02:23:52 +04:00
|
|
|
* All rights reserved.
|
|
|
|
* Copyright (c) 2011-2013 Inria. All rights reserved.
|
2013-07-01 16:40:08 +04:00
|
|
|
* Copyright (c) 2011-2013 Universite Bordeaux 1
|
2014-05-15 01:15:33 +04:00
|
|
|
* All rights reserved.
|
2004-11-22 04:38:40 +03:00
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
2004-02-05 04:52:56 +03:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
#include "ompi_config.h"
|
2004-02-05 04:52:56 +03:00
|
|
|
|
|
|
|
#include <stdio.h>
|
2004-06-29 04:02:25 +04:00
|
|
|
|
2005-07-04 04:13:44 +04:00
|
|
|
#include "opal/util/bit_ops.h"
|
2006-02-12 04:33:29 +03:00
|
|
|
#include "ompi/constants.h"
|
|
|
|
#include "ompi/mca/pml/pml.h"
|
|
|
|
#include "ompi/mca/coll/base/base.h"
|
|
|
|
#include "ompi/mca/topo/base/base.h"
|
2005-07-03 16:07:29 +04:00
|
|
|
#include "ompi/runtime/params.h"
|
2005-09-13 00:25:01 +04:00
|
|
|
#include "ompi/communicator/communicator.h"
|
2006-02-12 04:33:29 +03:00
|
|
|
#include "ompi/attribute/attribute.h"
|
2008-02-28 04:57:57 +03:00
|
|
|
#include "ompi/mca/dpm/dpm.h"
|
2008-02-12 21:01:17 +03:00
|
|
|
#include "ompi/memchecker.h"
|
2004-02-05 04:52:56 +03:00
|
|
|
|
2004-03-31 20:59:46 +04:00
|
|
|
/*
|
|
|
|
** Table for Fortran <-> C communicator handle conversion
|
|
|
|
** Also used by P2P code to lookup communicator based
|
|
|
|
** on cid.
|
|
|
|
**
|
|
|
|
*/
|
2007-12-21 09:02:00 +03:00
|
|
|
opal_pointer_array_t ompi_mpi_communicators;
|
2013-10-03 05:11:28 +04:00
|
|
|
opal_pointer_array_t ompi_comm_f_to_c_table;
|
2004-05-21 23:36:19 +04:00
|
|
|
|
2009-02-24 20:17:33 +03:00
|
|
|
ompi_predefined_communicator_t ompi_mpi_comm_world;
|
|
|
|
ompi_predefined_communicator_t ompi_mpi_comm_self;
|
|
|
|
ompi_predefined_communicator_t ompi_mpi_comm_null;
|
2004-06-16 19:40:52 +04:00
|
|
|
ompi_communicator_t *ompi_mpi_comm_parent;
|
2004-02-05 04:52:56 +03:00
|
|
|
|
== Highlights ==
1. New mpifort wrapper compiler: you can utilize mpif.h, use mpi, and use mpi_f08 through this one wrapper compiler
1. mpif77 and mpif90 still exist, but are sym links to mpifort and may be removed in a future release
1. The mpi module has been re-implemented and is significantly "mo' bettah"
1. The mpi_f08 module offers many, many improvements over mpif.h and the mpi module
This stuff is coming from a VERY long-lived mercurial branch (3 years!); it'll almost certainly take a few SVN commits and a bunch of testing before I get it correctly committed to the SVN trunk.
== More details ==
Craig Rasmussen and I have been working with the MPI-3 Fortran WG and Fortran J3 committees for a long, long time to make a prototype MPI-3 Fortran bindings implementation. We think we're at a stable enough state to bring this stuff back to the trunk, with the goal of including it in OMPI v1.7.
Special thanks go out to everyone who has been incredibly patient and helpful to us in this journey:
* Rolf Rabenseifner/HLRS (mastermind/genius behind the entire MPI-3 Fortran effort)
* The Fortran J3 committee
* Tobias Burnus/gfortran
* Tony !Goetz/Absoft
* Terry !Donte/Oracle
* ...and probably others whom I'm forgetting :-(
There's still opportunities for optimization in the mpi_f08 implementation, but by and large, it is as far along as it can be until Fortran compilers start implementing the new F08 dimension(..) syntax.
Note that gfortran is currently unsupported for the mpi_f08 module and the new mpi module. gfortran users will a) fall back to the same mpi module implementation that is in OMPI v1.5.x, and b) not get the new mpi_f08 module. The gfortran maintainers are actively working hard to add the necessary features to support both the new mpi_f08 module and the new mpi module implementations. This will take some time.
As mentioned above, ompi/mpi/f77 and ompi/mpi/f90 no longer exist. All the fortran bindings implementations have been collated under ompi/mpi/fortran; each implementation has its own subdirectory:
{{{
ompi/mpi/fortran/
base/ - glue code
mpif-h/ - what used to be ompi/mpi/f77
use-mpi-tkr/ - what used to be ompi/mpi/f90
use-mpi-ignore-tkr/ - new mpi module implementation
use-mpi-f08/ - new mpi_f08 module implementation
}}}
There's also a prototype 6-function-MPI implementation under use-mpi-f08-desc that emulates the new F08 dimension(..) syntax that isn't fully available in Fortran compilers yet. We did that to prove it to ourselves that it could be done once the compilers fully support it. This directory/implementation will likely eventually replace the use-mpi-f08 version.
Other things that were done:
* ompi_info grew a few new output fields to describe what level of Fortran support is included
* Existing Fortran examples in examples/ were renamed; new mpi_f08 examples were added
* The old Fortran MPI libraries were renamed:
* libmpi_f77 -> libmpi_mpifh
* libmpi_f90 -> libmpi_usempi
* The configury for Fortran was consolidated and significantly slimmed down. Note that the F77 env variable is now IGNORED for configure; you should only use FC. Example:
{{{
shell$ ./configure CC=icc CXX=icpc FC=ifort ...
}}}
All of this work was done in a Mercurial branch off the SVN trunk, and hosted at Bitbucket. This branch has got to be one of OMPI's longest-running branches. Its first commit was Tue Apr 07 23:01:46 2009 -0400 -- it's over 3 years old! :-) We think we've pulled in all relevant changes from the OMPI trunk (e.g., Fortran implementations of the new MPI-3 MPROBE stuff for mpif.h, use mpi, and use mpi_f08, and the recent Fujitsu Fortran patches).
I anticipate some instability when we bring this stuff into the trunk, simply because it touches a LOT of code in the MPI layer in the OMPI code base. We'll try our best to make it as pain-free as possible, but please bear with us when it is committed.
This commit was SVN r26283.
2012-04-18 19:57:29 +04:00
|
|
|
ompi_predefined_communicator_t *ompi_mpi_comm_world_addr =
|
|
|
|
&ompi_mpi_comm_world;
|
|
|
|
ompi_predefined_communicator_t *ompi_mpi_comm_self_addr =
|
|
|
|
&ompi_mpi_comm_self;
|
|
|
|
ompi_predefined_communicator_t *ompi_mpi_comm_null_addr =
|
|
|
|
&ompi_mpi_comm_null;
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
static void ompi_comm_construct(ompi_communicator_t* comm);
|
|
|
|
static void ompi_comm_destruct(ompi_communicator_t* comm);
|
2004-02-05 04:52:56 +03:00
|
|
|
|
2013-07-01 16:40:08 +04:00
|
|
|
OBJ_CLASS_INSTANCE(ompi_communicator_t, opal_object_t,
|
|
|
|
ompi_comm_construct,
|
|
|
|
ompi_comm_destruct);
|
2004-02-13 16:56:55 +03:00
|
|
|
|
2004-10-26 15:37:58 +04:00
|
|
|
/* This is the counter for the number of communicators, which contain
|
|
|
|
process with more than one jobid. This counter is a usefull
|
|
|
|
shortcut for finalize and abort. */
|
|
|
|
int ompi_comm_num_dyncomm=0;
|
|
|
|
|
2004-02-05 04:52:56 +03:00
|
|
|
/*
|
2004-06-16 19:40:52 +04:00
|
|
|
* Initialize comm world/self/null/parent.
|
2004-02-05 04:52:56 +03:00
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
int ompi_comm_init(void)
|
2004-02-05 04:52:56 +03:00
|
|
|
{
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_group_t *group;
|
2004-02-13 16:56:55 +03:00
|
|
|
size_t size;
|
|
|
|
|
2004-03-12 01:02:01 +03:00
|
|
|
/* Setup communicator array */
|
2007-12-21 09:02:00 +03:00
|
|
|
OBJ_CONSTRUCT(&ompi_mpi_communicators, opal_pointer_array_t);
|
|
|
|
if( OPAL_SUCCESS != opal_pointer_array_init(&ompi_mpi_communicators, 0,
|
2009-06-01 23:02:34 +04:00
|
|
|
OMPI_FORTRAN_HANDLE_MAX, 64) ) {
|
2007-12-21 09:02:00 +03:00
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
2004-03-12 01:02:01 +03:00
|
|
|
|
2013-10-03 05:11:28 +04:00
|
|
|
/* Setup f to c table (we can no longer use the cid as the fortran handle) */
|
|
|
|
OBJ_CONSTRUCT(&ompi_comm_f_to_c_table, opal_pointer_array_t);
|
|
|
|
if( OPAL_SUCCESS != opal_pointer_array_init(&ompi_comm_f_to_c_table, 0,
|
|
|
|
OMPI_FORTRAN_HANDLE_MAX, 64) ) {
|
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
|
|
|
|
2004-02-13 16:56:55 +03:00
|
|
|
/* Setup MPI_COMM_WORLD */
|
2004-06-07 19:33:53 +04:00
|
|
|
OBJ_CONSTRUCT(&ompi_mpi_comm_world, ompi_communicator_t);
|
2013-10-03 05:11:28 +04:00
|
|
|
assert(ompi_mpi_comm_world.comm.c_f_to_c_index == 0);
|
2004-06-07 19:33:53 +04:00
|
|
|
group = OBJ_NEW(ompi_group_t);
|
|
|
|
group->grp_proc_pointers = ompi_proc_world(&size);
|
2006-10-20 07:57:44 +04:00
|
|
|
group->grp_proc_count = (int)size;
|
2007-08-04 04:41:26 +04:00
|
|
|
OMPI_GROUP_SET_INTRINSIC (group);
|
|
|
|
OMPI_GROUP_SET_DENSE (group);
|
2004-09-10 02:57:53 +04:00
|
|
|
ompi_set_group_rank(group, ompi_proc_local());
|
2004-12-02 16:28:10 +03:00
|
|
|
ompi_group_increment_proc_count (group);
|
2004-02-13 16:56:55 +03:00
|
|
|
|
2009-02-24 20:17:33 +03:00
|
|
|
ompi_mpi_comm_world.comm.c_contextid = 0;
|
|
|
|
ompi_mpi_comm_world.comm.c_id_start_index = 4;
|
|
|
|
ompi_mpi_comm_world.comm.c_id_available = 4;
|
|
|
|
ompi_mpi_comm_world.comm.c_my_rank = group->grp_my_rank;
|
|
|
|
ompi_mpi_comm_world.comm.c_local_group = group;
|
|
|
|
ompi_mpi_comm_world.comm.c_remote_group = group;
|
|
|
|
OBJ_RETAIN(ompi_mpi_comm_world.comm.c_remote_group);
|
|
|
|
ompi_mpi_comm_world.comm.c_cube_dim = opal_cube_dim((int)size);
|
|
|
|
ompi_mpi_comm_world.comm.error_handler = &ompi_mpi_errors_are_fatal.eh;
|
|
|
|
OBJ_RETAIN( &ompi_mpi_errors_are_fatal.eh );
|
|
|
|
OMPI_COMM_SET_PML_ADDED(&ompi_mpi_comm_world.comm);
|
2007-12-21 09:02:00 +03:00
|
|
|
opal_pointer_array_set_item (&ompi_mpi_communicators, 0, &ompi_mpi_comm_world);
|
2004-06-07 19:33:53 +04:00
|
|
|
|
2009-02-24 20:17:33 +03:00
|
|
|
MEMCHECKER (memset (ompi_mpi_comm_world.comm.c_name, 0, MPI_MAX_OBJECT_NAME));
|
|
|
|
strncpy (ompi_mpi_comm_world.comm.c_name, "MPI_COMM_WORLD",
|
2004-03-26 23:02:42 +03:00
|
|
|
strlen("MPI_COMM_WORLD")+1 );
|
2009-02-24 20:17:33 +03:00
|
|
|
ompi_mpi_comm_world.comm.c_flags |= OMPI_COMM_NAMEISSET;
|
|
|
|
ompi_mpi_comm_world.comm.c_flags |= OMPI_COMM_INTRINSIC;
|
2004-10-07 05:26:40 +04:00
|
|
|
|
|
|
|
/* We have to create a hash (although it is legal to leave this
|
|
|
|
filed NULL -- the attribute accessor functions will intepret
|
|
|
|
this as "there are no attributes cached on this object")
|
|
|
|
because MPI_COMM_WORLD has some predefined attributes. */
|
2009-02-24 20:17:33 +03:00
|
|
|
ompi_attr_hash_init(&ompi_mpi_comm_world.comm.c_keyhash);
|
2004-05-08 03:15:10 +04:00
|
|
|
|
2004-02-13 16:56:55 +03:00
|
|
|
/* Setup MPI_COMM_SELF */
|
2004-06-07 19:33:53 +04:00
|
|
|
OBJ_CONSTRUCT(&ompi_mpi_comm_self, ompi_communicator_t);
|
2013-10-03 05:11:28 +04:00
|
|
|
assert(ompi_mpi_comm_self.comm.c_f_to_c_index == 1);
|
2004-06-07 19:33:53 +04:00
|
|
|
group = OBJ_NEW(ompi_group_t);
|
|
|
|
group->grp_proc_pointers = ompi_proc_self(&size);
|
2004-05-21 23:36:19 +04:00
|
|
|
group->grp_my_rank = 0;
|
2006-10-20 07:57:44 +04:00
|
|
|
group->grp_proc_count = (int)size;
|
2007-08-04 04:41:26 +04:00
|
|
|
OMPI_GROUP_SET_INTRINSIC (group);
|
|
|
|
OMPI_GROUP_SET_DENSE (group);
|
2013-10-03 05:11:28 +04:00
|
|
|
|
2009-02-24 20:17:33 +03:00
|
|
|
ompi_mpi_comm_self.comm.c_contextid = 1;
|
|
|
|
ompi_mpi_comm_self.comm.c_id_start_index = 20;
|
|
|
|
ompi_mpi_comm_self.comm.c_id_available = 20;
|
|
|
|
ompi_mpi_comm_self.comm.c_my_rank = group->grp_my_rank;
|
|
|
|
ompi_mpi_comm_self.comm.c_local_group = group;
|
|
|
|
ompi_mpi_comm_self.comm.c_remote_group = group;
|
|
|
|
OBJ_RETAIN(ompi_mpi_comm_self.comm.c_remote_group);
|
|
|
|
ompi_mpi_comm_self.comm.error_handler = &ompi_mpi_errors_are_fatal.eh;
|
|
|
|
OBJ_RETAIN( &ompi_mpi_errors_are_fatal.eh );
|
|
|
|
OMPI_COMM_SET_PML_ADDED(&ompi_mpi_comm_self.comm);
|
2007-12-21 09:02:00 +03:00
|
|
|
opal_pointer_array_set_item (&ompi_mpi_communicators, 1, &ompi_mpi_comm_self);
|
2004-06-07 19:33:53 +04:00
|
|
|
|
2009-02-24 20:17:33 +03:00
|
|
|
MEMCHECKER (memset (ompi_mpi_comm_self.comm.c_name, 0, MPI_MAX_OBJECT_NAME));
|
|
|
|
strncpy(ompi_mpi_comm_self.comm.c_name,"MPI_COMM_SELF",strlen("MPI_COMM_SELF")+1);
|
|
|
|
ompi_mpi_comm_self.comm.c_flags |= OMPI_COMM_NAMEISSET;
|
|
|
|
ompi_mpi_comm_self.comm.c_flags |= OMPI_COMM_INTRINSIC;
|
2004-10-07 05:26:40 +04:00
|
|
|
|
|
|
|
/* We can set MPI_COMM_SELF's keyhash to NULL because it has no
|
|
|
|
predefined attributes. If a user defines an attribute on
|
|
|
|
MPI_COMM_SELF, the keyhash will automatically be created. */
|
2009-02-24 20:17:33 +03:00
|
|
|
ompi_mpi_comm_self.comm.c_keyhash = NULL;
|
2008-02-12 11:46:27 +03:00
|
|
|
|
2004-05-21 23:36:19 +04:00
|
|
|
/* Setup MPI_COMM_NULL */
|
2004-06-07 19:33:53 +04:00
|
|
|
OBJ_CONSTRUCT(&ompi_mpi_comm_null, ompi_communicator_t);
|
2013-10-03 05:11:28 +04:00
|
|
|
assert(ompi_mpi_comm_null.comm.c_f_to_c_index == 2);
|
2009-02-24 20:17:33 +03:00
|
|
|
ompi_mpi_comm_null.comm.c_local_group = &ompi_mpi_group_null.group;
|
|
|
|
ompi_mpi_comm_null.comm.c_remote_group = &ompi_mpi_group_null.group;
|
|
|
|
OBJ_RETAIN(&ompi_mpi_group_null.group);
|
|
|
|
OBJ_RETAIN(&ompi_mpi_group_null.group);
|
2004-05-21 23:36:19 +04:00
|
|
|
|
2009-02-24 20:17:33 +03:00
|
|
|
ompi_mpi_comm_null.comm.c_contextid = 2;
|
|
|
|
ompi_mpi_comm_null.comm.c_my_rank = MPI_PROC_NULL;
|
2004-06-15 04:09:40 +04:00
|
|
|
|
2009-02-24 20:17:33 +03:00
|
|
|
ompi_mpi_comm_null.comm.error_handler = &ompi_mpi_errors_are_fatal.eh;
|
|
|
|
OBJ_RETAIN( &ompi_mpi_errors_are_fatal.eh );
|
2007-12-21 09:02:00 +03:00
|
|
|
opal_pointer_array_set_item (&ompi_mpi_communicators, 2, &ompi_mpi_comm_null);
|
2004-05-21 23:36:19 +04:00
|
|
|
|
2009-02-24 20:17:33 +03:00
|
|
|
MEMCHECKER (memset (ompi_mpi_comm_null.comm.c_name, 0, MPI_MAX_OBJECT_NAME));
|
|
|
|
strncpy(ompi_mpi_comm_null.comm.c_name,"MPI_COMM_NULL",strlen("MPI_COMM_NULL")+1);
|
|
|
|
ompi_mpi_comm_null.comm.c_flags |= OMPI_COMM_NAMEISSET;
|
|
|
|
ompi_mpi_comm_null.comm.c_flags |= OMPI_COMM_INTRINSIC;
|
2004-05-21 23:36:19 +04:00
|
|
|
|
2004-06-16 19:40:52 +04:00
|
|
|
/* Initialize the parent communicator to MPI_COMM_NULL */
|
2009-02-24 20:17:33 +03:00
|
|
|
ompi_mpi_comm_parent = &ompi_mpi_comm_null.comm;
|
2004-06-16 19:40:52 +04:00
|
|
|
OBJ_RETAIN(&ompi_mpi_comm_null);
|
2009-02-24 20:17:33 +03:00
|
|
|
OBJ_RETAIN(&ompi_mpi_group_null.group);
|
|
|
|
OBJ_RETAIN(&ompi_mpi_errors_are_fatal.eh);
|
2004-06-16 19:40:52 +04:00
|
|
|
|
2004-09-21 22:39:06 +04:00
|
|
|
/* initialize the comm_reg stuff for multi-threaded comm_cid
|
|
|
|
allocation */
|
|
|
|
ompi_comm_reg_init();
|
|
|
|
|
2013-10-03 05:11:28 +04:00
|
|
|
/* initialize communicator requests (for ompi_comm_idup) */
|
|
|
|
ompi_comm_request_init ();
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
return OMPI_SUCCESS;
|
2004-03-26 23:02:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_communicator_t *ompi_comm_allocate ( int local_size, int remote_size )
|
2004-03-26 23:02:42 +03:00
|
|
|
{
|
2007-08-23 11:40:40 +04:00
|
|
|
ompi_communicator_t *new_comm;
|
2004-03-26 23:02:42 +03:00
|
|
|
|
|
|
|
/* create new communicator element */
|
2004-06-07 19:33:53 +04:00
|
|
|
new_comm = OBJ_NEW(ompi_communicator_t);
|
|
|
|
new_comm->c_local_group = ompi_group_allocate ( local_size );
|
2004-05-21 23:36:19 +04:00
|
|
|
if ( 0 < remote_size ) {
|
2004-06-07 19:33:53 +04:00
|
|
|
new_comm->c_remote_group = ompi_group_allocate (remote_size);
|
|
|
|
new_comm->c_flags |= OMPI_COMM_INTER;
|
2007-08-23 11:40:40 +04:00
|
|
|
} else {
|
2004-06-04 01:23:42 +04:00
|
|
|
/*
|
|
|
|
* simplifies some operations (e.g. p2p), if
|
|
|
|
* we can always use the remote group
|
2004-05-21 23:36:19 +04:00
|
|
|
*/
|
|
|
|
new_comm->c_remote_group = new_comm->c_local_group;
|
2004-07-16 00:55:15 +04:00
|
|
|
OBJ_RETAIN(new_comm->c_remote_group);
|
2004-03-26 23:02:42 +03:00
|
|
|
}
|
|
|
|
|
2004-05-21 23:36:19 +04:00
|
|
|
/* fill in the inscribing hyper-cube dimensions */
|
2005-07-04 04:13:44 +04:00
|
|
|
new_comm->c_cube_dim = opal_cube_dim(local_size);
|
2004-03-26 23:02:42 +03:00
|
|
|
|
2004-05-21 23:36:19 +04:00
|
|
|
return new_comm;
|
2004-03-26 23:02:42 +03:00
|
|
|
}
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
int ompi_comm_finalize(void)
|
2004-03-26 23:02:42 +03:00
|
|
|
{
|
2004-08-13 22:55:07 +04:00
|
|
|
int max, i;
|
|
|
|
ompi_communicator_t *comm;
|
|
|
|
|
2006-04-13 21:00:36 +04:00
|
|
|
/* Shut down MPI_COMM_SELF */
|
2005-05-06 18:22:59 +04:00
|
|
|
OBJ_DESTRUCT( &ompi_mpi_comm_self );
|
|
|
|
|
2004-10-26 18:54:23 +04:00
|
|
|
/* disconnect all dynamic communicators */
|
2008-02-28 04:57:57 +03:00
|
|
|
ompi_dpm.dyn_finalize();
|
2004-10-26 18:54:23 +04:00
|
|
|
|
2014-05-15 01:15:33 +04:00
|
|
|
/* Free the attributes on comm world. This is not done in the
|
|
|
|
* destructor as we delete attributes in ompi_comm_free (which
|
|
|
|
* is not called for comm world) */
|
|
|
|
if (NULL != ompi_mpi_comm_world.comm.c_keyhash) {
|
|
|
|
/* Ignore errors when deleting attributes on comm_world */
|
|
|
|
(void) ompi_attr_delete_all(COMM_ATTR, &ompi_mpi_comm_world.comm, ompi_mpi_comm_world.comm.c_keyhash);
|
|
|
|
OBJ_RELEASE(ompi_mpi_comm_world.comm.c_keyhash);
|
|
|
|
}
|
|
|
|
|
2006-04-13 21:00:36 +04:00
|
|
|
/* Shut down MPI_COMM_WORLD */
|
2004-06-07 19:33:53 +04:00
|
|
|
OBJ_DESTRUCT( &ompi_mpi_comm_world );
|
2004-06-04 01:23:42 +04:00
|
|
|
|
2006-04-13 21:00:36 +04:00
|
|
|
/* Shut down the parent communicator, if it exists */
|
2009-02-24 20:17:33 +03:00
|
|
|
if( ompi_mpi_comm_parent != &ompi_mpi_comm_null.comm ) {
|
2005-07-02 00:40:56 +04:00
|
|
|
/* Note that we pass ompi_mpi_comm_parent here
|
|
|
|
(vs. &ompi_mpi_comm_parent) because it is of type
|
|
|
|
(ompi_communicator_t*), *NOT* (ompi_communicator_t). This
|
|
|
|
is because a parent communicator is created dynamically
|
|
|
|
during init, and we just set this pointer to it. Hence, we
|
|
|
|
just pass in the pointer here. */
|
2010-10-04 18:54:58 +04:00
|
|
|
OBJ_DESTRUCT (ompi_mpi_comm_parent);
|
|
|
|
|
|
|
|
/* Please note, that the we did increase the reference count
|
|
|
|
for ompi_mpi_comm_null, ompi_mpi_group_null, and
|
|
|
|
ompi_mpi_errors_are_fatal in ompi_comm_init because of
|
|
|
|
ompi_mpi_comm_parent. In case a
|
|
|
|
parent communicator is really created, the ref. counters
|
|
|
|
for these objects are decreased again by one. However, in a
|
|
|
|
static scenario, we should ideally decrease the ref. counter
|
|
|
|
for these objects by one here. The problem just is, that
|
|
|
|
if the app had a parent_comm, and this has been freed/disconnected,
|
|
|
|
ompi_comm_parent points again to ompi_comm_null, the reference count
|
|
|
|
for these objects has not been increased again.
|
|
|
|
So the point is, if ompi_mpi_comm_parent == &ompi_mpi_comm_null
|
|
|
|
we do not know whether we have to decrease the ref count for
|
|
|
|
those three objects or not. Since this is a constant, non-increasing
|
|
|
|
amount of memory, we stick with the current solution for now,
|
|
|
|
namely don't do anything.
|
|
|
|
*/
|
2004-09-19 11:13:58 +04:00
|
|
|
}
|
2004-09-13 19:14:09 +04:00
|
|
|
|
2006-04-13 21:00:36 +04:00
|
|
|
/* Shut down MPI_COMM_NULL */
|
2004-08-13 22:55:07 +04:00
|
|
|
OBJ_DESTRUCT( &ompi_mpi_comm_null );
|
2004-10-26 18:54:23 +04:00
|
|
|
|
2004-08-13 22:55:07 +04:00
|
|
|
/* Check whether we have some communicators left */
|
2007-12-21 09:02:00 +03:00
|
|
|
max = opal_pointer_array_get_size(&ompi_mpi_communicators);
|
2004-08-13 22:55:07 +04:00
|
|
|
for ( i=3; i<max; i++ ) {
|
2007-12-21 09:02:00 +03:00
|
|
|
comm = (ompi_communicator_t *)opal_pointer_array_get_item(&ompi_mpi_communicators, i);
|
2004-08-13 22:55:07 +04:00
|
|
|
if ( NULL != comm ) {
|
|
|
|
/* Communicator has not been freed before finalize */
|
|
|
|
OBJ_RELEASE(comm);
|
2007-12-21 09:02:00 +03:00
|
|
|
comm=(ompi_communicator_t *)opal_pointer_array_get_item(&ompi_mpi_communicators, i);
|
2004-08-13 22:55:07 +04:00
|
|
|
if ( NULL != comm ) {
|
|
|
|
/* Still here ? */
|
2010-10-04 18:54:58 +04:00
|
|
|
if ( !OMPI_COMM_IS_EXTRA_RETAIN(comm)) {
|
|
|
|
|
|
|
|
/* For communicator that have been marked as "extra retain", we do not further
|
|
|
|
* enforce to decrease the reference counter once more. These "extra retain"
|
|
|
|
* communicators created e.g. by the hierarch or inter module did increase
|
|
|
|
* the reference count by one more than other communicators, on order to
|
|
|
|
* allow for deallocation with the parent communicator. Note, that
|
|
|
|
* this only occurs if the cid of the local_comm is lower than of its
|
|
|
|
* parent communicator. Read the comment in comm_activate for
|
|
|
|
* a full explanation.
|
|
|
|
*/
|
|
|
|
if ( ompi_debug_show_handle_leaks && !(OMPI_COMM_IS_FREED(comm)) ){
|
|
|
|
opal_output(0,"WARNING: MPI_Comm still allocated in MPI_Finalize\n");
|
|
|
|
ompi_comm_dump ( comm);
|
|
|
|
OBJ_RELEASE(comm);
|
|
|
|
}
|
|
|
|
}
|
2004-08-13 22:55:07 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
OBJ_DESTRUCT (&ompi_mpi_communicators);
|
2014-05-15 01:15:33 +04:00
|
|
|
OBJ_DESTRUCT (&ompi_comm_f_to_c_table);
|
2004-06-04 01:23:42 +04:00
|
|
|
|
2004-09-21 22:39:06 +04:00
|
|
|
/* finalize the comm_reg stuff */
|
|
|
|
ompi_comm_reg_finalize();
|
|
|
|
|
2013-10-03 05:11:28 +04:00
|
|
|
/* finalize communicator requests */
|
|
|
|
ompi_comm_request_fini ();
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
return OMPI_SUCCESS;
|
2004-02-05 04:52:56 +03:00
|
|
|
}
|
2004-02-13 16:56:55 +03:00
|
|
|
|
2004-03-26 23:02:42 +03:00
|
|
|
/*
|
2004-05-21 23:36:19 +04:00
|
|
|
* For linking only. To be checked.
|
2004-03-26 23:02:42 +03:00
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
int ompi_comm_link_function(void)
|
2004-03-26 23:02:42 +03:00
|
|
|
{
|
2010-10-04 18:54:58 +04:00
|
|
|
return OMPI_SUCCESS;
|
2004-03-26 23:02:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************************************/
|
|
|
|
/********************************************************************************/
|
|
|
|
/********************************************************************************/
|
|
|
|
/* static functions */
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
static void ompi_comm_construct(ompi_communicator_t* comm)
|
2004-03-26 23:02:42 +03:00
|
|
|
{
|
2013-10-03 05:11:28 +04:00
|
|
|
comm->c_f_to_c_index = opal_pointer_array_add(&ompi_comm_f_to_c_table, comm);
|
2004-06-04 01:23:42 +04:00
|
|
|
comm->c_name[0] = '\0';
|
|
|
|
comm->c_contextid = MPI_UNDEFINED;
|
2006-12-13 01:01:39 +03:00
|
|
|
comm->c_id_available = MPI_UNDEFINED;
|
|
|
|
comm->c_id_start_index = MPI_UNDEFINED;
|
2004-06-04 01:23:42 +04:00
|
|
|
comm->c_flags = 0;
|
|
|
|
comm->c_my_rank = 0;
|
|
|
|
comm->c_cube_dim = 0;
|
2004-03-26 23:02:42 +03:00
|
|
|
comm->c_local_group = NULL;
|
|
|
|
comm->c_remote_group = NULL;
|
|
|
|
comm->error_handler = NULL;
|
|
|
|
comm->c_pml_comm = NULL;
|
2004-08-06 02:48:47 +04:00
|
|
|
comm->c_topo = NULL;
|
|
|
|
|
2004-10-07 05:26:40 +04:00
|
|
|
/* A keyhash will be created if/when an attribute is cached on
|
2013-07-01 16:40:08 +04:00
|
|
|
this communicator */
|
|
|
|
comm->c_keyhash = NULL;
|
2004-10-07 05:26:40 +04:00
|
|
|
|
2013-07-01 16:40:08 +04:00
|
|
|
comm->errhandler_type = OMPI_ERRHANDLER_TYPE_COMM;
|
2006-03-23 08:00:55 +03:00
|
|
|
#ifdef OMPI_WANT_PERUSE
|
2013-07-01 16:40:08 +04:00
|
|
|
comm->c_peruse_handles = NULL;
|
2006-03-23 08:00:55 +03:00
|
|
|
#endif
|
|
|
|
|
2007-08-19 07:37:49 +04:00
|
|
|
/* Need to zero out the collectives module because we sometimes
|
|
|
|
call coll_unselect without a matching call to coll_select, and
|
|
|
|
we need an easy way for the coll base code to realize we've
|
|
|
|
done this. */
|
|
|
|
memset(&comm->c_coll, 0, sizeof(mca_coll_base_comm_coll_t));
|
2004-03-26 23:02:42 +03:00
|
|
|
}
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
static void ompi_comm_destruct(ompi_communicator_t* comm)
|
2004-03-26 23:02:42 +03:00
|
|
|
{
|
2004-10-21 02:54:34 +04:00
|
|
|
/* Note that the attributes were already released on this
|
|
|
|
communicator in ompi_comm_free() (i.e., from MPI_COMM_FREE /
|
|
|
|
MPI_COMM_DISCONNECT). See the lengthy comment in
|
|
|
|
communicator/comm.c in ompi_comm_free() for the reasons why. */
|
2004-10-14 22:06:40 +04:00
|
|
|
|
2004-06-29 04:02:25 +04:00
|
|
|
/* Release the collective module */
|
|
|
|
|
2004-12-02 16:28:10 +03:00
|
|
|
if ( MPI_COMM_NULL != comm ) {
|
2005-09-13 00:25:01 +04:00
|
|
|
mca_coll_base_comm_unselect(comm);
|
2004-12-02 16:28:10 +03:00
|
|
|
}
|
2004-06-29 04:02:25 +04:00
|
|
|
|
2004-12-02 16:28:10 +03:00
|
|
|
/* Tell the PML that this communicator is done.
|
2005-04-13 07:19:48 +04:00
|
|
|
MCA_PML_CALL(add_comm()) was called explicitly in
|
2004-12-02 16:28:10 +03:00
|
|
|
ompi_comm_init() when setting up COMM_WORLD and COMM_SELF; it's
|
|
|
|
called in ompi_comm_set() for all others. This means that all
|
2005-03-26 04:49:14 +03:00
|
|
|
communicators must be destroyed before the PML shuts down.
|
|
|
|
|
|
|
|
Also -- do not invoke the pml_del_comm if the corresponding
|
|
|
|
pml_add_comm was never invoked. This can happen in an error
|
|
|
|
situation where, for example, attributes do not copy properly
|
|
|
|
from one communicator to another and we end up destroying the
|
|
|
|
new communication while propagating the error up the stack. We
|
|
|
|
want to make it all the way up the stack to invoke the MPI
|
|
|
|
exception, not cause a seg fault in pml_del_comm because it was
|
|
|
|
never pml_add_com'ed. */
|
|
|
|
|
|
|
|
if ( MPI_COMM_NULL != comm && OMPI_COMM_IS_PML_ADDED(comm) ) {
|
2005-09-13 00:25:01 +04:00
|
|
|
MCA_PML_CALL(del_comm (comm));
|
2004-12-02 16:28:10 +03:00
|
|
|
}
|
|
|
|
|
2013-07-01 16:40:08 +04:00
|
|
|
/* Release topology module */
|
|
|
|
if (NULL != comm->c_topo) {
|
|
|
|
OBJ_RELEASE(comm->c_topo);
|
|
|
|
comm->c_topo = NULL;
|
|
|
|
}
|
2004-09-29 09:34:20 +04:00
|
|
|
|
2004-09-13 19:14:09 +04:00
|
|
|
if (NULL != comm->c_local_group) {
|
2005-09-13 00:25:01 +04:00
|
|
|
ompi_group_decrement_proc_count (comm->c_local_group);
|
2004-09-13 19:14:09 +04:00
|
|
|
OBJ_RELEASE ( comm->c_local_group );
|
2004-09-29 09:34:20 +04:00
|
|
|
comm->c_local_group = NULL;
|
2005-09-13 00:25:01 +04:00
|
|
|
if ( OMPI_COMM_IS_INTRA(comm) ) {
|
2007-04-02 23:06:52 +04:00
|
|
|
/* We have to decrement the ref count on the remote group
|
2013-07-01 16:40:08 +04:00
|
|
|
even if it is identical to the local one in case of
|
|
|
|
intra-comm */
|
2007-04-06 23:18:31 +04:00
|
|
|
OBJ_RELEASE ( comm->c_remote_group );
|
2005-09-13 00:25:01 +04:00
|
|
|
comm->c_remote_group = NULL;
|
|
|
|
}
|
2004-09-29 09:34:20 +04:00
|
|
|
}
|
2004-12-02 16:28:10 +03:00
|
|
|
|
2004-09-29 09:34:20 +04:00
|
|
|
if (NULL != comm->c_remote_group) {
|
2005-09-13 00:25:01 +04:00
|
|
|
ompi_group_decrement_proc_count (comm->c_remote_group);
|
2004-09-29 09:34:20 +04:00
|
|
|
OBJ_RELEASE ( comm->c_remote_group );
|
|
|
|
comm->c_remote_group = NULL;
|
2004-09-13 19:14:09 +04:00
|
|
|
}
|
2006-03-04 16:47:24 +03:00
|
|
|
|
2004-08-10 02:06:07 +04:00
|
|
|
if (NULL != comm->error_handler) {
|
2004-07-21 02:21:47 +04:00
|
|
|
OBJ_RELEASE ( comm->error_handler );
|
2004-09-29 09:34:20 +04:00
|
|
|
comm->error_handler = NULL;
|
2004-07-21 02:21:47 +04:00
|
|
|
}
|
2004-03-26 23:02:42 +03:00
|
|
|
|
2013-10-03 05:11:28 +04:00
|
|
|
/* mark this cid as available */
|
2013-10-03 23:50:10 +04:00
|
|
|
if ( MPI_UNDEFINED != (int)comm->c_contextid &&
|
2013-10-03 05:11:28 +04:00
|
|
|
NULL != opal_pointer_array_get_item(&ompi_mpi_communicators,
|
|
|
|
comm->c_contextid)) {
|
|
|
|
opal_pointer_array_set_item ( &ompi_mpi_communicators,
|
|
|
|
comm->c_contextid, NULL);
|
|
|
|
}
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
/* reset the ompi_comm_f_to_c_table entry */
|
2004-08-13 17:31:26 +04:00
|
|
|
if ( MPI_UNDEFINED != comm->c_f_to_c_index &&
|
2013-10-03 05:11:28 +04:00
|
|
|
NULL != opal_pointer_array_get_item(&ompi_comm_f_to_c_table,
|
|
|
|
comm->c_f_to_c_index)) {
|
2013-10-03 05:46:36 +04:00
|
|
|
opal_pointer_array_set_item ( &ompi_comm_f_to_c_table,
|
2004-07-16 00:55:15 +04:00
|
|
|
comm->c_f_to_c_index, NULL);
|
2004-03-31 20:59:46 +04:00
|
|
|
}
|
2004-03-26 23:02:42 +03:00
|
|
|
}
|