preparing the comm_cid allocation routine for dynamic process management
This commit was SVN r1336.
Этот коммит содержится в:
родитель
5d1574d929
Коммит
deec2c1435
@ -226,7 +226,7 @@ int ompi_comm_create ( ompi_communicator_t *comm, ompi_group_t *group,
|
||||
j++;
|
||||
}
|
||||
}
|
||||
mode = OMPI_COMM_INTER_INTER;
|
||||
mode = OMPI_COMM_CID_INTER;
|
||||
#else
|
||||
return ( MPI_ERR_COMM );
|
||||
#endif
|
||||
@ -234,7 +234,7 @@ int ompi_comm_create ( ompi_communicator_t *comm, ompi_group_t *group,
|
||||
else {
|
||||
rsize = 0;
|
||||
rprocs = NULL;
|
||||
mode = OMPI_COMM_INTRA_INTRA;
|
||||
mode = OMPI_COMM_CID_INTRA;
|
||||
}
|
||||
|
||||
newcomp = ompi_comm_set ( comm, /* old comm */
|
||||
@ -254,12 +254,12 @@ int ompi_comm_create ( ompi_communicator_t *comm, ompi_group_t *group,
|
||||
}
|
||||
|
||||
/* 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 */
|
||||
rc = ompi_comm_nextcid ( newcomp, /* new communicator */
|
||||
comm, /* old comm */
|
||||
NULL, /* bridge comm */
|
||||
NULL, /* local leader */
|
||||
NULL, /* remote_leader */
|
||||
mode ); /* mode */
|
||||
if ( OMPI_SUCCESS != rc ) {
|
||||
goto exit;
|
||||
}
|
||||
@ -432,7 +432,7 @@ int ompi_comm_split ( ompi_communicator_t* comm, int color, int key,
|
||||
rprocs[i] = comm->c_remote_group->grp_proc_pointers[rsorted[i*2]];
|
||||
}
|
||||
|
||||
mode = OMPI_COMM_INTER_INTER;
|
||||
mode = OMPI_COMM_CID_INTER;
|
||||
#else
|
||||
/* creating an inter-communicator using MPI_Comm_create will
|
||||
be supported soon, but not in this version */
|
||||
@ -443,7 +443,7 @@ int ompi_comm_split ( ompi_communicator_t* comm, int color, int key,
|
||||
else {
|
||||
my_rsize = 0;
|
||||
rprocs = NULL;
|
||||
mode = OMPI_COMM_INTRA_INTRA;
|
||||
mode = OMPI_COMM_CID_INTRA;
|
||||
}
|
||||
|
||||
|
||||
@ -466,12 +466,12 @@ int ompi_comm_split ( ompi_communicator_t* comm, int color, int key,
|
||||
}
|
||||
|
||||
/* 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 */
|
||||
rc = ompi_comm_nextcid ( newcomp, /* new communicator */
|
||||
comm, /* old comm */
|
||||
NULL, /* bridge comm */
|
||||
NULL, /* local leader */
|
||||
NULL, /* remote_leader */
|
||||
mode ); /* mode */
|
||||
if ( OMPI_SUCCESS != rc ) {
|
||||
goto exit;
|
||||
}
|
||||
|
@ -25,8 +25,8 @@
|
||||
int ompi_comm_nextcid ( ompi_communicator_t* newcomm,
|
||||
ompi_communicator_t* comm,
|
||||
ompi_communicator_t* bridgecomm,
|
||||
int local_leader,
|
||||
int remote_leader,
|
||||
void* local_leader,
|
||||
void* remote_leader,
|
||||
int mode )
|
||||
{
|
||||
/* set the according values to the newcomm */
|
||||
@ -48,29 +48,34 @@ int ompi_comm_nextcid ( ompi_communicator_t* newcomm,
|
||||
typedef int ompi_comm_cid_allredfct (int *inbuf, int* outbuf, int count,
|
||||
ompi_op_t *op, ompi_communicator_t *comm,
|
||||
ompi_communicator_t *bridgecomm,
|
||||
int lleader, int rleader );
|
||||
|
||||
static int ompi_comm_allreduce_inter (int *inbuf, int *outbuf, int count,
|
||||
ompi_op_t *op, ompi_communicator_t *intercomm,
|
||||
ompi_communicator_t *bridgecomm,
|
||||
int local_leader, int remote_leader );
|
||||
|
||||
static int ompi_comm_allreduce_emulate_inter ( int *inbuf, int* outbuf, int count,
|
||||
ompi_op_t *op, ompi_communicator_t *intercomm,
|
||||
ompi_communicator_t *bridgecomm,
|
||||
int local_leader, int remote_leader );
|
||||
void* lleader, void* rleader );
|
||||
|
||||
static int ompi_comm_allreduce_intra ( int *inbuf, int* outbuf, int count,
|
||||
ompi_op_t *op, ompi_communicator_t *intercomm,
|
||||
ompi_communicator_t *bridgecomm,
|
||||
int local_leader, int remote_ledaer );
|
||||
void* local_leader, void* remote_ledaer );
|
||||
|
||||
static int ompi_comm_allreduce_inter (int *inbuf, int *outbuf, int count,
|
||||
ompi_op_t *op, ompi_communicator_t *intercomm,
|
||||
ompi_communicator_t *bridgecomm,
|
||||
void* local_leader, void* remote_leader );
|
||||
|
||||
static int ompi_comm_allreduce_intra_bridge ( int *inbuf, int* outbuf, int count,
|
||||
ompi_op_t *op, ompi_communicator_t *intercomm,
|
||||
ompi_communicator_t *bridgecomm,
|
||||
void* local_leader, void* remote_leader );
|
||||
|
||||
static int ompi_comm_allreduce_intra_oob ( int *inbuf, int* outbuf, int count,
|
||||
ompi_op_t *op, ompi_communicator_t *intercomm,
|
||||
ompi_communicator_t *bridgecomm,
|
||||
void* local_leader, void* remote_leader );
|
||||
|
||||
|
||||
int ompi_comm_nextcid ( ompi_communicator_t* newcomm,
|
||||
ompi_communicator_t* comm,
|
||||
ompi_communicator_t* bridgecomm,
|
||||
int local_leader,
|
||||
int remote_leader,
|
||||
void* local_leader,
|
||||
void* remote_leader,
|
||||
int mode )
|
||||
{
|
||||
|
||||
@ -90,16 +95,18 @@ int ompi_comm_nextcid ( ompi_communicator_t* newcomm,
|
||||
*/
|
||||
switch (mode)
|
||||
{
|
||||
case OMPI_COMM_INTRA_INTRA:
|
||||
case OMPI_COMM_CID_INTRA:
|
||||
allredfnct = (ompi_comm_cid_allredfct*)ompi_comm_allreduce_intra;
|
||||
break;
|
||||
case OMPI_COMM_INTRA_INTER:
|
||||
allredfnct = (ompi_comm_cid_allredfct*)ompi_comm_allreduce_emulate_inter;
|
||||
break;
|
||||
case OMPI_COMM_INTER_INTER:
|
||||
case OMPI_COMM_INTER_INTRA:
|
||||
case OMPI_COMM_CID_INTER:
|
||||
allredfnct = (ompi_comm_cid_allredfct*)ompi_comm_allreduce_inter;
|
||||
break;
|
||||
case OMPI_COMM_CID_INTRA_BRIDGE:
|
||||
allredfnct = (ompi_comm_cid_allredfct*)ompi_comm_allreduce_intra_bridge;
|
||||
break;
|
||||
case OMPI_COMM_CID_INTRA_OOB:
|
||||
allredfnct = (ompi_comm_cid_allredfct*)ompi_comm_allreduce_intra_oob;
|
||||
break;
|
||||
default:
|
||||
return MPI_UNDEFINED;
|
||||
break;
|
||||
@ -109,7 +116,6 @@ int ompi_comm_nextcid ( ompi_communicator_t* newcomm,
|
||||
* This is the real algorithm described in the doc
|
||||
*/
|
||||
while ( !done ){
|
||||
sleep ( 30 );
|
||||
for (i=start; i<OMPI_MAX_COMM ;i++) {
|
||||
flag = ompi_pointer_array_test_and_set_item (&ompi_mpi_communicators, i, comm);
|
||||
if (true == flag) {
|
||||
@ -155,28 +161,28 @@ int ompi_comm_nextcid ( ompi_communicator_t* newcomm,
|
||||
/********************************************************************************/
|
||||
/********************************************************************************/
|
||||
/* Arguments not used in this implementation:
|
||||
- bridgecomm
|
||||
- local_leader
|
||||
- remote_leader
|
||||
*/
|
||||
* - bridgecomm
|
||||
* - local_leader
|
||||
* - remote_leader
|
||||
*/
|
||||
static int ompi_comm_allreduce_intra ( int *inbuf, int *outbuf, int count,
|
||||
ompi_op_t *op, ompi_communicator_t *comm,
|
||||
ompi_communicator_t *bridgecomm,
|
||||
int local_leader, int remote_leader )
|
||||
void* local_leader, void* remote_leader )
|
||||
{
|
||||
return comm->c_coll.coll_allreduce_intra ( inbuf, outbuf, count, MPI_INT, op,
|
||||
comm );
|
||||
}
|
||||
|
||||
/* Arguments not used in this implementation:
|
||||
- bridgecomm
|
||||
- local_leader
|
||||
- remote_leader
|
||||
*/
|
||||
* - bridgecomm
|
||||
* - local_leader
|
||||
* - remote_leader
|
||||
*/
|
||||
static int ompi_comm_allreduce_inter (int *inbuf, int *outbuf, int count,
|
||||
ompi_op_t *op, ompi_communicator_t *intercomm,
|
||||
ompi_communicator_t *bridgecomm,
|
||||
int local_leader, int remote_leader )
|
||||
void* local_leader, void* remote_leader )
|
||||
{
|
||||
int local_rank;
|
||||
ompi_proc_t *lvpid, *rvpid;
|
||||
@ -293,15 +299,19 @@ static int ompi_comm_allreduce_inter (int *inbuf, int *outbuf, int count,
|
||||
/* Arguments not used in this implementation:
|
||||
all arguments are in use.
|
||||
*/
|
||||
static int ompi_comm_allreduce_emulate_inter (int *inbuf, int *outbuf, int count,
|
||||
static int ompi_comm_allreduce_intra_bridge (int *inbuf, int *outbuf, int count,
|
||||
ompi_op_t *op, ompi_communicator_t *comm,
|
||||
ompi_communicator_t *bridgecomm,
|
||||
int local_leader, int remote_leader )
|
||||
void* lleader, void* rleader )
|
||||
{
|
||||
int *tmpbuf=NULL;
|
||||
int local_rank;
|
||||
int i;
|
||||
int rc;
|
||||
int local_leader, remote_leader;
|
||||
|
||||
local_leader = (*((int*)lleader));
|
||||
remote_leader = (*((int*)rleader));
|
||||
|
||||
if ( &ompi_mpi_op_sum != op && &ompi_mpi_op_prod != op &&
|
||||
&ompi_mpi_op_max != op && &ompi_mpi_op_min != op ) {
|
||||
@ -374,4 +384,86 @@ static int ompi_comm_allreduce_emulate_inter (int *inbuf, int *outbuf, int count
|
||||
return (rc);
|
||||
}
|
||||
|
||||
/* Arguments not used in this implementation:
|
||||
* - bridgecomm
|
||||
*
|
||||
* lleader and rleader are the OOB contact information of the
|
||||
* root processes.
|
||||
*/
|
||||
static int ompi_comm_allreduce_intra_oob (int *inbuf, int *outbuf, int count,
|
||||
ompi_op_t *op, ompi_communicator_t *comm,
|
||||
ompi_communicator_t *bridgecomm,
|
||||
void* lleader, void* rleader )
|
||||
{
|
||||
int *tmpbuf=NULL;
|
||||
int i;
|
||||
int rc;
|
||||
uint32_t local_leader, remote_leader;
|
||||
uint32_t local_rank;
|
||||
|
||||
local_leader = (*((uint32_t*)lleader));
|
||||
remote_leader = (*((uint32_t*)rleader));
|
||||
|
||||
if ( &ompi_mpi_op_sum != op && &ompi_mpi_op_prod != op &&
|
||||
&ompi_mpi_op_max != op && &ompi_mpi_op_min != op ) {
|
||||
return MPI_ERR_OP;
|
||||
}
|
||||
|
||||
/*
|
||||
* To be done: determine my own OOB contact information.
|
||||
* store it in local_rank.
|
||||
*/
|
||||
|
||||
tmpbuf = (int *) malloc ( count * sizeof(int));
|
||||
if ( NULL == tmpbuf ) {
|
||||
return MPI_ERR_INTERN;
|
||||
}
|
||||
|
||||
/* Intercomm_create */
|
||||
rc = comm->c_coll.coll_allreduce_intra ( inbuf, tmpbuf, count, MPI_INT,
|
||||
op, comm );
|
||||
if ( OMPI_SUCCESS != rc ) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (local_rank == local_leader ) {
|
||||
MPI_Request req;
|
||||
MPI_Status status;
|
||||
|
||||
/*
|
||||
* To be done:: OOB sendrecv between the two leaders the local result.
|
||||
*/
|
||||
if ( &ompi_mpi_op_max == op ) {
|
||||
for ( i = 0 ; i < count; i++ ) {
|
||||
if (tmpbuf[i] > outbuf[i]) outbuf[i] = tmpbuf[i];
|
||||
}
|
||||
}
|
||||
else if ( &ompi_mpi_op_min == op ) {
|
||||
for ( i = 0 ; i < count; i++ ) {
|
||||
if (tmpbuf[i] < outbuf[i]) outbuf[i] = tmpbuf[i];
|
||||
}
|
||||
}
|
||||
else if ( &ompi_mpi_op_sum == op ) {
|
||||
for ( i = 0 ; i < count; i++ ) {
|
||||
outbuf[i] += tmpbuf[i];
|
||||
}
|
||||
}
|
||||
else if ( &ompi_mpi_op_prod == op ) {
|
||||
for ( i = 0 ; i < count; i++ ) {
|
||||
outbuf[i] *= tmpbuf[i];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
rc = comm->c_coll.coll_bcast_intra ( outbuf, count, MPI_INT, local_leader, comm);
|
||||
|
||||
exit:
|
||||
if (NULL != tmpbuf ) {
|
||||
free (tmpbuf);
|
||||
}
|
||||
|
||||
return (rc);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -40,10 +40,10 @@ extern ompi_class_t ompi_communicator_t_class;
|
||||
* whether the new communicator will be an inter/intra
|
||||
*comm
|
||||
*/
|
||||
#define OMPI_COMM_INTRA_INTRA 0x00000020
|
||||
#define OMPI_COMM_INTRA_INTER 0x00000040
|
||||
#define OMPI_COMM_INTER_INTRA 0x00000080
|
||||
#define OMPI_COMM_INTER_INTER 0x00000100
|
||||
#define OMPI_COMM_CID_INTRA 0x00000020
|
||||
#define OMPI_COMM_CID_INTER 0x00000040
|
||||
#define OMPI_COMM_CID_INTRA_BRIDGE 0x00000080
|
||||
#define OMPI_COMM_CID_INTRA_OOB 0x00000100
|
||||
|
||||
extern ompi_pointer_array_t ompi_mpi_communicators;
|
||||
|
||||
@ -229,17 +229,24 @@ extern "C" {
|
||||
* @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,
|
||||
* OMPI_COMM_INTER_INTRA, OMPI_COMM_INTER_INTER
|
||||
* @param mode: combination of input
|
||||
* OMPI_COMM_CID_INTRA: intra-comm
|
||||
* OMPI_COMM_CID_INTER: inter-comm
|
||||
* OMPI_COMM_CID_INTRA_BRIDGE: 2 intracomms connected by
|
||||
* a bridge comm. local_leader
|
||||
* and remote leader are in this
|
||||
* case an int (rank in bridge-comm).
|
||||
* OMPI_COMM_CID_INTRA_OOB: 2 intracomms, leaders talk
|
||||
* through OOB. lleader and rleader
|
||||
* are the required contact information.
|
||||
*
|
||||
* This routine has to be thread safe in the final version.
|
||||
*/
|
||||
int ompi_comm_nextcid ( ompi_communicator_t* newcomm,
|
||||
ompi_communicator_t* oldcomm,
|
||||
ompi_communicator_t* bridgecomm,
|
||||
int local_leader,
|
||||
int remote_leader,
|
||||
void* local_leader,
|
||||
void* remote_leader,
|
||||
int mode);
|
||||
|
||||
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user