1
1

adding the routine to handle the proper disconnect of all dynamic communicators in MPI_Finalize (in cases the user did not explicitly disconnect).

This commit was SVN r3338.
Этот коммит содержится в:
Edgar Gabriel 2004-10-26 14:54:23 +00:00
родитель 10ff968ec7
Коммит 22acad7c5c
3 изменённых файлов: 50 добавлений и 6 удалений

Просмотреть файл

@ -436,7 +436,8 @@ int ompi_comm_dyn_init (void)
* now we have to decrease the reference counters to the according
* objects
*/
/* OBJ_RELEASE(&ompi_mpi_comm_null);
/*
OBJ_RELEASE(&ompi_mpi_comm_null);
OBJ_RELEASE(&ompi_mpi_group_null);
OBJ_RELEASE(&ompi_mpi_group_null);
OBJ_RELEASE(&ompi_mpi_errors_are_fatal);
@ -451,12 +452,40 @@ int ompi_comm_dyn_init (void)
/**********************************************************************/
/* this routine runs through the list of communicators and
and does the disconnect for all dynamic communicators */
/*int ompi_comm_dyn_finalize (void)
int ompi_comm_dyn_finalize (void)
{
int i,j=0, max=0;
ompi_comm_disconnect_obj **objs=NULL;
ompi_communicator_t *comm=NULL;
if ( 1 <ompi_comm_num_dyncomm ) {
objs = (ompi_comm_disconnect_obj **)malloc (ompi_comm_num_dyncomm*
sizeof(ompi_comm_disconnect_obj*));
if ( NULL == objs ) {
return OMPI_ERR_OUT_OF_RESOURCE;
}
*/
max = ompi_pointer_array_get_size(&ompi_mpi_communicators);
for ( i=3; i<max; i++ ) {
comm = (ompi_communicator_t*)ompi_pointer_array_get_item(&ompi_mpi_communicators,i);
if ( OMPI_COMM_IS_DYNAMIC(comm)) {
objs[j++]=ompi_comm_disconnect_init(comm);
}
}
if ( j != ompi_comm_num_dyncomm+1 ) {
free (objs);
return OMPI_ERROR;
}
ompi_comm_disconnect_waitall (ompi_comm_num_dyncomm, objs);
free (objs);
}
return OMPI_SUCCESS;
}
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/

Просмотреть файл

@ -184,8 +184,10 @@ int ompi_comm_finalize(void)
int max, i;
ompi_communicator_t *comm;
/* Destroy all predefined communicators */
/* disconnect all dynamic communicators */
ompi_comm_dyn_finalize();
/* Destroy all predefined communicators */
ompi_mpi_comm_world.c_local_group->grp_flags = 0;
ompi_mpi_comm_world.c_flags = 0;
OBJ_DESTRUCT( &ompi_mpi_comm_world );

Просмотреть файл

@ -406,8 +406,21 @@ struct ompi_communicator_t {
int ompi_comm_start_processes (char *command, char **argv, int maxprocs,
MPI_Info info, char *port_name);
/*
* This routine checks, whether an application has been spawned
* by another MPI application, or has been independently started.
* If it has been spawned, it establishes the parent communicator.
* Since the routine has to communicate, it should be among the last
* steps in MPI_Init, to be sure that everything is already set up.
*/
int ompi_comm_dyn_init(void);
/**
* Executes internally a disconnect on all dynamic communicators
* in case the user did not disconnect them.
*/
int ompi_comm_dyn_finalize(void);
/* this routine counts the number of different jobids of the processes
given in a certain communicator. If there is more than one jobid,
we mark the communicator as 'dynamic'. This is especially relevant