1
1

extracting the creation of comm_cid from the comm_set routine.

The reason is, that we had to pass four arguments to comm_sdet, which were just passed to comm_cid. However, for the dynamic case, even these four arguments are not enough. So I extracted it. A typical sequence for a comm-creation will therefore be:

 newcomm = ompi_comm_set (...);
 ompi_comm_nextcid (newcomm, oldcomm,...);

This commit was SVN r1312.
Этот коммит содержится в:
Edgar Gabriel 2004-06-16 15:40:52 +00:00
родитель 2eb37a7c43
Коммит f8294ab099
4 изменённых файлов: 113 добавлений и 88 удалений

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

@ -51,9 +51,7 @@ static int ompi_comm_allgather_emulate_intra (void* inbuf, int incount, MPI_Data
* This is the function setting all elements of a communicator.
* All other routines are just used to determine these elements.
*/
ompi_communicator_t * ompi_comm_set ( int mode,
ompi_communicator_t* oldcomm,
ompi_communicator_t* bridgecomm,
ompi_communicator_t * ompi_comm_set ( ompi_communicator_t* oldcomm,
int local_size,
ompi_proc_t **local_procs,
int remote_size,
@ -61,10 +59,7 @@ ompi_communicator_t * ompi_comm_set ( int mode,
ompi_hash_table_t *attr,
ompi_errhandler_t *errh,
mca_base_module_t *collmodule,
mca_base_module_t *topomodule,
int local_leader,
int remote_leader
)
mca_base_module_t *topomodule )
{
ompi_communicator_t *newcomm;
ompi_proc_t *my_gpointer;
@ -93,21 +88,6 @@ ompi_communicator_t * ompi_comm_set ( int mode,
newcomm->c_flags |= OMPI_COMM_INTER;
}
/* Determine context id. It is identical to f_2_c_handle */
#ifdef HAVE_COLLECTIVES
newcomm->c_contextid = ompi_comm_nextcid ( oldcomm,
bridgecomm,
local_leader,
remote_leader,
mode );
#else
/* just for now */
newcomm->c_contextid = oldcomm->c_contextid + 10;
ompi_pointer_array_set_item ( &ompi_mpi_communicators, newcomm->c_contextid,
newcomm );
#endif
newcomm->c_f_to_c_index = newcomm->c_contextid;
/* Set error handler */
newcomm->error_handler = errh;
OBJ_RETAIN ( newcomm->error_handler );
@ -257,9 +237,7 @@ int ompi_comm_create ( ompi_communicator_t *comm, ompi_group_t *group,
mode = OMPI_COMM_INTRA_INTRA;
}
newcomp = ompi_comm_set ( mode, /* mode */
comm, /* old comm */
NULL, /* bridge comm */
newcomp = ompi_comm_set ( comm, /* old comm */
group->grp_proc_count, /* local_size */
group->grp_proc_pointers, /* local_procs*/
rsize, /* remote_size */
@ -267,16 +245,25 @@ int ompi_comm_create ( ompi_communicator_t *comm, ompi_group_t *group,
NULL, /* attrs */
comm->error_handler, /* error handler */
NULL, /* coll module */
NULL, /* topo module */
MPI_UNDEFINED, /* local leader */
MPI_UNDEFINED /* remote leader */
NULL /* topo module */
);
if ( newcomp == MPI_COMM_NULL ) {
if ( MPI_COMM_NULL == newcomp ) {
rc = MPI_ERR_INTERN;
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 */
MPI_UNDEFINED, /* local leader */
MPI_UNDEFINED, /* remote_leader */
mode ); /* mode */
if ( OMPI_SUCCESS != rc ) {
goto exit;
}
/* 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
@ -463,9 +450,7 @@ int ompi_comm_split ( ompi_communicator_t* comm, int color, int key,
/* Step 3: set up the communicator */
/* --------------------------------------------------------- */
/* Create the communicator finally */
newcomp = ompi_comm_set ( mode, /* mode */
comm, /* old comm */
NULL, /* bridge comm */
newcomp = ompi_comm_set ( comm, /* old comm */
my_size, /* local_size */
procs, /* local_procs*/
my_rsize, /* remote_size */
@ -473,11 +458,23 @@ int ompi_comm_split ( ompi_communicator_t* comm, int color, int key,
NULL, /* attrs */
comm->error_handler,/* error handler */
NULL, /* coll module */
NULL, /* topo module */
MPI_UNDEFINED, /* local leader */
MPI_UNDEFINED /* remote leader */
NULL /* topo module */
);
if ( MPI_COMM_NULL == newcomp ) rc = MPI_ERR_INTERN;
if ( MPI_COMM_NULL == newcomp ) {
rc = MPI_ERR_INTERN;
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 */
MPI_UNDEFINED, /* local leader */
MPI_UNDEFINED, /* remote_leader */
mode ); /* mode */
if ( OMPI_SUCCESS != rc ) {
goto exit;
}
exit:
if ( NULL != results ) {

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

@ -21,7 +21,23 @@
#define OMPI_COMM_CID_TAG 1011
#define OMPI_MAX_COMM 32768
#ifndef HAVE_COLLECTIVES
int ompi_comm_nextcid ( ompi_communicator_t* newcomm,
ompi_communicator_t* comm,
ompi_communicator_t* bridgecomm,
int local_leader,
int remote_leader,
int mode )
{
/* set the according values to the newcomm */
newcomm->c_contextid = comm->c_contextid + 10;
ompi_pointer_array_set_item (&ompi_mpi_communicators,
newcomm->c_contextid,
newcomm);
return ( MPI_SUCCESS );
}
#else
/**
* These functions make sure, that we determine the global result over
* an intra communicators (simple), an inter-communicator and a
@ -50,7 +66,8 @@ static int ompi_comm_allreduce_intra ( int *inbuf, int* outbuf, int count,
int local_leader, int remote_ledaer );
int ompi_comm_nextcid ( ompi_communicator_t* comm,
int ompi_comm_nextcid ( ompi_communicator_t* newcomm,
ompi_communicator_t* comm,
ompi_communicator_t* bridgecomm,
int local_leader,
int remote_leader,
@ -127,7 +144,11 @@ int ompi_comm_nextcid ( ompi_communicator_t* comm,
}
}
return (nextcid);
/* set the according values to the newcomm */
newcomm->c_contextid = nextcid;
ompi_pointer_array_set_item (&ompi_mpi_communicators, nextcid, newcomm);
return (MPI_SUCCESS);
}
/********************************************************************************/
@ -353,4 +374,4 @@ static int ompi_comm_allreduce_emulate_inter (int *inbuf, int *outbuf, int count
return (rc);
}
#endif

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

@ -25,6 +25,7 @@ ompi_pointer_array_t ompi_mpi_communicators;
ompi_communicator_t ompi_mpi_comm_world;
ompi_communicator_t ompi_mpi_comm_self;
ompi_communicator_t ompi_mpi_comm_null;
ompi_communicator_t *ompi_mpi_comm_parent;
static void ompi_comm_construct(ompi_communicator_t* comm);
static void ompi_comm_destruct(ompi_communicator_t* comm);
@ -33,7 +34,7 @@ OBJ_CLASS_INSTANCE(ompi_communicator_t, ompi_object_t,ompi_comm_construct, ompi_
/*
* Initialize comm world/self/null.
* Initialize comm world/self/null/parent.
*/
int ompi_comm_init(void)
{
@ -143,6 +144,13 @@ int ompi_comm_init(void)
ompi_mpi_comm_null.bcast_lin_reqs = NULL;
ompi_mpi_comm_null.bcast_log_reqs = NULL;
/* Initialize the parent communicator to MPI_COMM_NULL */
ompi_mpi_comm_parent = &ompi_mpi_comm_null;
OBJ_RETAIN(&ompi_mpi_comm_null);
OBJ_RETAIN(&ompi_mpi_group_null);
OBJ_RETAIN(&ompi_mpi_group_null);
OBJ_RETAIN(&ompi_mpi_errors_are_fatal);
return OMPI_SUCCESS;
}

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

@ -92,6 +92,7 @@ struct ompi_communicator_t {
};
typedef struct ompi_communicator_t ompi_communicator_t;
extern ompi_communicator_t *ompi_mpi_comm_parent;
/**
@ -225,7 +226,8 @@ extern "C" {
/**
* allocate new communicator ID
* @param comm: original comm
* @param newcomm: pointer to the new communicator
* @param oldcomm: original comm
* @param bridgecomm: bridge comm for intercomm_create
* @param mode: combination of input and output communicator
* OMPI_COMM_INTRA_INTRA, OMPI_COMM_INTRA_INTER,
@ -233,7 +235,8 @@ extern "C" {
*
* This routine has to be thread safe in the final version.
*/
int ompi_comm_nextcid ( ompi_communicator_t* comm,
int ompi_comm_nextcid ( ompi_communicator_t* newcomm,
ompi_communicator_t* oldcomm,
ompi_communicator_t* bridgecomm,
int local_leader,
int remote_leader,
@ -249,9 +252,7 @@ extern "C" {
* This is THE routine, where all the communicator stuff
* is really set.
*/
ompi_communicator_t* ompi_comm_set ( int mode,
ompi_communicator_t* oldcomm,
ompi_communicator_t* bridgecomm,
ompi_communicator_t* ompi_comm_set ( ompi_communicator_t* oldcomm,
int local_size,
ompi_proc_t **local_procs,
int remote_size,
@ -259,9 +260,7 @@ extern "C" {
ompi_hash_table_t *attr,
ompi_errhandler_t *errh,
mca_base_module_t *collmodule,
mca_base_module_t *topomodule,
int local_leader,
int remote_leader);
mca_base_module_t *topomodule );
/**
* This is a short-hand routine used in intercomm_create.
* The routine makes sure, that all processes have afterwards