1
1

Fix formatting in group and communicator code (- No functionality changes -)

Mostly TAB to spaces changes, though a couple style fixes were included as well.

The tab/space issue was causing problems with off-trunk branch merging.

This commit was SVN r23827.
Этот коммит содержится в:
Josh Hursey 2010-10-04 14:54:58 +00:00
родитель accad16a52
Коммит ee42c673fe
9 изменённых файлов: 627 добавлений и 616 удалений

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

@ -217,7 +217,7 @@ int ompi_comm_set ( ompi_communicator_t **ncomm,
} }
} }
*ncomm = newcomm; *ncomm = newcomm;
return (OMPI_SUCCESS); return (OMPI_SUCCESS);
} }
@ -247,7 +247,7 @@ int ompi_comm_group ( ompi_communicator_t* comm, ompi_group_t **group )
** Counterpart to MPI_Comm_create. To be used within OMPI. ** Counterpart to MPI_Comm_create. To be used within OMPI.
*/ */
int ompi_comm_create ( ompi_communicator_t *comm, ompi_group_t *group, int ompi_comm_create ( ompi_communicator_t *comm, ompi_group_t *group,
ompi_communicator_t **newcomm ) ompi_communicator_t **newcomm )
{ {
ompi_communicator_t *newcomp = NULL; ompi_communicator_t *newcomp = NULL;
int rsize , lsize; int rsize , lsize;
@ -351,12 +351,12 @@ int ompi_comm_create ( ompi_communicator_t *comm, ompi_group_t *group,
/* Activate the communicator and init coll-component */ /* Activate the communicator and init coll-component */
rc = ompi_comm_activate( &newcomp, /* new communicator */ rc = ompi_comm_activate( &newcomp, /* new communicator */
comm, comm,
NULL, NULL,
NULL, NULL,
NULL, NULL,
mode, mode,
-1 ); -1 );
if ( OMPI_SUCCESS != rc ) { if ( OMPI_SUCCESS != rc ) {
goto exit; goto exit;
} }
@ -392,7 +392,7 @@ int ompi_comm_create ( ompi_communicator_t *comm, ompi_group_t *group,
** Counterpart to MPI_Comm_split. To be used within OMPI (e.g. MPI_Cart_sub). ** Counterpart to MPI_Comm_split. To be used within OMPI (e.g. MPI_Cart_sub).
*/ */
int ompi_comm_split ( ompi_communicator_t* comm, int color, int key, int ompi_comm_split ( ompi_communicator_t* comm, int color, int key,
ompi_communicator_t **newcomm, bool pass_on_topo ) ompi_communicator_t **newcomm, bool pass_on_topo )
{ {
int myinfo[2]; int myinfo[2];
int size, my_size; int size, my_size;
@ -552,7 +552,7 @@ int ompi_comm_split ( ompi_communicator_t* comm, int color, int key,
NULL, /* topo component */ NULL, /* topo component */
NULL, /* local group */ NULL, /* local group */
NULL /* remote group */ NULL /* remote group */
); );
if ( NULL == newcomm ) { if ( NULL == newcomm ) {
rc = MPI_ERR_INTERN; rc = MPI_ERR_INTERN;
@ -583,18 +583,18 @@ int ompi_comm_split ( ompi_communicator_t* comm, int color, int key,
* be freed anyway. * be freed anyway.
*/ */
if ( MPI_UNDEFINED == color ) { if ( MPI_UNDEFINED == color ) {
newcomp->c_local_group->grp_my_rank = MPI_UNDEFINED; newcomp->c_local_group->grp_my_rank = MPI_UNDEFINED;
} }
/* Activate the communicator and init coll-component */ /* Activate the communicator and init coll-component */
rc = ompi_comm_activate( &newcomp, /* new communicator */ rc = ompi_comm_activate( &newcomp, /* new communicator */
comm, comm,
NULL, NULL,
NULL, NULL,
NULL, NULL,
mode, mode,
-1 ); -1 );
if ( OMPI_SUCCESS != rc ) { if ( OMPI_SUCCESS != rc ) {
goto exit; goto exit;
} }
@ -610,7 +610,7 @@ int ompi_comm_split ( ompi_communicator_t* comm, int color, int key,
free ( rresults ); free ( rresults );
} }
if ( NULL != rsorted ) { if ( NULL != rsorted ) {
free ( rsorted ); free ( rsorted );
} }
if ( NULL != lranks ) { if ( NULL != lranks ) {
free ( lranks ); free ( lranks );
@ -686,12 +686,12 @@ int ompi_comm_dup ( ompi_communicator_t * comm, ompi_communicator_t **newcomm )
/* activate communicator and init coll-module */ /* activate communicator and init coll-module */
rc = ompi_comm_activate( &newcomp, /* new communicator */ rc = ompi_comm_activate( &newcomp, /* new communicator */
comp, comp,
NULL, NULL,
NULL, NULL,
NULL, NULL,
mode, mode,
-1 ); -1 );
if ( OMPI_SUCCESS != rc ) { if ( OMPI_SUCCESS != rc ) {
return rc; return rc;
} }
@ -768,12 +768,13 @@ int ompi_comm_compare(ompi_communicator_t *comm1, ompi_communicator_t *comm2, in
} }
} }
if ( sameranks && sameorder ) if ( sameranks && sameorder ) {
lresult = MPI_CONGRUENT; lresult = MPI_CONGRUENT;
else if ( sameranks && !sameorder ) } else if ( sameranks && !sameorder ) {
lresult = MPI_SIMILAR; lresult = MPI_SIMILAR;
else } else {
lresult = MPI_UNEQUAL; lresult = MPI_UNEQUAL;
}
if ( rsize1 > 0 ) { if ( rsize1 > 0 ) {
@ -809,12 +810,13 @@ int ompi_comm_compare(ompi_communicator_t *comm1, ompi_communicator_t *comm2, in
} }
} }
if ( sameranks && sameorder ) if ( sameranks && sameorder ) {
rresult = MPI_CONGRUENT; rresult = MPI_CONGRUENT;
else if ( sameranks && !sameorder ) } else if ( sameranks && !sameorder ) {
rresult = MPI_SIMILAR; rresult = MPI_SIMILAR;
else } else {
rresult = MPI_UNEQUAL; rresult = MPI_UNEQUAL;
}
} }
/* determine final results */ /* determine final results */
@ -825,11 +827,13 @@ int ompi_comm_compare(ompi_communicator_t *comm1, ompi_communicator_t *comm2, in
if ( MPI_SIMILAR == lresult || MPI_CONGRUENT == lresult ) { if ( MPI_SIMILAR == lresult || MPI_CONGRUENT == lresult ) {
*result = MPI_SIMILAR; *result = MPI_SIMILAR;
} }
else else {
*result = MPI_UNEQUAL; *result = MPI_UNEQUAL;
}
} }
else if ( MPI_UNEQUAL == rresult ) else if ( MPI_UNEQUAL == rresult ) {
*result = MPI_UNEQUAL; *result = MPI_UNEQUAL;
}
return OMPI_SUCCESS; return OMPI_SUCCESS;
} }
@ -912,7 +916,7 @@ static int ompi_comm_allgather_emulate_intra( void *inbuf, int incount,
/* Step 2: the inter-bcast step */ /* Step 2: the inter-bcast step */
rc = MCA_PML_CALL(irecv (outbuf, size*outcount, outtype, 0, rc = MCA_PML_CALL(irecv (outbuf, size*outcount, outtype, 0,
OMPI_COMM_ALLGATHER_TAG, comm, &sendreq)); OMPI_COMM_ALLGATHER_TAG, comm, &sendreq));
if ( OMPI_SUCCESS != rc ) { if ( OMPI_SUCCESS != rc ) {
goto exit; goto exit;
} }
@ -920,8 +924,8 @@ static int ompi_comm_allgather_emulate_intra( void *inbuf, int incount,
if ( 0 == rank ) { if ( 0 == rank ) {
for ( i=0; i < rsize; i++ ){ for ( i=0; i < rsize; i++ ){
rc = MCA_PML_CALL(send (tmpbuf, rsize*outcount, outtype, i, rc = MCA_PML_CALL(send (tmpbuf, rsize*outcount, outtype, i,
OMPI_COMM_ALLGATHER_TAG, OMPI_COMM_ALLGATHER_TAG,
MCA_PML_BASE_SEND_STANDARD, comm)); MCA_PML_BASE_SEND_STANDARD, comm));
if ( OMPI_SUCCESS != rc ) { if ( OMPI_SUCCESS != rc ) {
goto exit; goto exit;
} }
@ -959,20 +963,20 @@ int ompi_comm_free ( ompi_communicator_t **comm )
communicator destructor for 2 reasons: communicator destructor for 2 reasons:
1. The destructor will only NOT be called immediately during 1. The destructor will only NOT be called immediately during
ompi_comm_free() if the reference count is still greater ompi_comm_free() if the reference count is still greater
than zero at that point, meaning that there are ongoing than zero at that point, meaning that there are ongoing
communications. However, pending communications will never communications. However, pending communications will never
need attributes, so it's safe to release them directly here. need attributes, so it's safe to release them directly here.
2. Releasing attributes in ompi_comm_free() enables us to check 2. Releasing attributes in ompi_comm_free() enables us to check
the return status of the attribute delete functions. At the return status of the attribute delete functions. At
least one interpretation of the MPI standard (i.e., the one least one interpretation of the MPI standard (i.e., the one
of the Intel test suite) is that if any of the attribute of the Intel test suite) is that if any of the attribute
deletion functions fail, then MPI_COMM_FREE / deletion functions fail, then MPI_COMM_FREE /
MPI_COMM_DISCONNECT should also fail. We can't do that if MPI_COMM_DISCONNECT should also fail. We can't do that if
we delay releasing the attributes -- we need to release the we delay releasing the attributes -- we need to release the
attributes right away so that we can report the error right attributes right away so that we can report the error right
away. */ away. */
if ( OMPI_COMM_IS_INTER(*comm) ) { if ( OMPI_COMM_IS_INTER(*comm) ) {
ompi_comm_free (&(*comm)->c_local_comm); ompi_comm_free (&(*comm)->c_local_comm);
} }
@ -1115,7 +1119,7 @@ ompi_proc_t **ompi_comm_get_rprocs ( ompi_communicator_t *local_comm,
if ( local_rank == local_leader ) { if ( local_rank == local_leader ) {
/* local leader exchange name lists */ /* local leader exchange name lists */
rc = MCA_PML_CALL(irecv (recvbuf, rlen, MPI_BYTE, remote_leader, tag, rc = MCA_PML_CALL(irecv (recvbuf, rlen, MPI_BYTE, remote_leader, tag,
bridge_comm, &req )); bridge_comm, &req ));
if ( OMPI_SUCCESS != rc ) { if ( OMPI_SUCCESS != rc ) {
goto err_exit; goto err_exit;
} }
@ -1187,7 +1191,7 @@ ompi_proc_t **ompi_comm_get_rprocs ( ompi_communicator_t *local_comm,
* in intercomm_create * in intercomm_create
*/ */
int ompi_comm_overlapping_groups (int size, ompi_proc_t **lprocs, int ompi_comm_overlapping_groups (int size, ompi_proc_t **lprocs,
int rsize, ompi_proc_t ** rprocs) int rsize, ompi_proc_t ** rprocs)
{ {
int rc=OMPI_SUCCESS; int rc=OMPI_SUCCESS;
@ -1432,8 +1436,9 @@ int ompi_topo_create (ompi_communicator_t *old_comm,
else { else {
proc_list = (ompi_proc_t **) calloc (old_comm->c_local_group->grp_proc_count, proc_list = (ompi_proc_t **) calloc (old_comm->c_local_group->grp_proc_count,
sizeof (ompi_proc_t *)); sizeof (ompi_proc_t *));
for(i=0 ; i<old_comm->c_local_group->grp_proc_count ; i++) for(i=0 ; i<old_comm->c_local_group->grp_proc_count ; i++) {
proc_list[i] = ompi_group_peer_lookup(old_comm->c_local_group,i); proc_list[i] = ompi_group_peer_lookup(old_comm->c_local_group,i);
}
memcpy (topo_procs, memcpy (topo_procs,
proc_list, proc_list,
@ -1496,7 +1501,7 @@ int ompi_topo_create (ompi_communicator_t *old_comm,
* it as they deem fit */ * it as they deem fit */
new_comm->c_topo_comm->mtc_periods_or_edges = (int *) new_comm->c_topo_comm->mtc_periods_or_edges = (int *)
malloc (sizeof(int) * dims_or_index[ndims_or_nnodes-1]); malloc (sizeof(int) * dims_or_index[ndims_or_nnodes-1]);
if (NULL == new_comm->c_topo_comm->mtc_periods_or_edges) { if (NULL == new_comm->c_topo_comm->mtc_periods_or_edges) {
ompi_comm_free (&new_comm); ompi_comm_free (&new_comm);
*comm_topo = new_comm; *comm_topo = new_comm;
@ -1527,7 +1532,7 @@ int ompi_topo_create (ompi_communicator_t *old_comm,
NULL, /* local leader */ NULL, /* local leader */
NULL, /* remote_leader */ NULL, /* remote_leader */
OMPI_COMM_CID_INTRA, /* mode */ OMPI_COMM_CID_INTRA, /* mode */
-1 ); /* send first, doesn't matter */ -1 ); /* send first, doesn't matter */
if (OMPI_SUCCESS != ret) { if (OMPI_SUCCESS != ret) {
/* something wrong happened during setting the communicator */ /* something wrong happened during setting the communicator */
ompi_comm_free (&new_comm); ompi_comm_free (&new_comm);
@ -1561,13 +1566,13 @@ int ompi_topo_create (ompi_communicator_t *old_comm,
NULL, /* local leader */ NULL, /* local leader */
NULL, /* remote_leader */ NULL, /* remote_leader */
OMPI_COMM_CID_INTRA, /* mode */ OMPI_COMM_CID_INTRA, /* mode */
-1 ); /* send first, doesn't matter */ -1 ); /* send first, doesn't matter */
if (OMPI_SUCCESS != ret) { if (OMPI_SUCCESS != ret) {
/* something wrong happened during setting the communicator */ /* something wrong happened during setting the communicator */
*comm_topo = new_comm; *comm_topo = new_comm;
return ret; return ret;
} }
/* if the returned rank is -1, then this process is not in the /* if the returned rank is -1, then this process is not in the
@ -1635,11 +1640,11 @@ static int ompi_comm_fill_rest (ompi_communicator_t *comm,
/* determine the cube dimensions */ /* determine the cube dimensions */
comm->c_cube_dim = opal_cube_dim(comm->c_local_group->grp_proc_count); comm->c_cube_dim = opal_cube_dim(comm->c_local_group->grp_proc_count);
return OMPI_SUCCESS; return OMPI_SUCCESS;
} }
static int ompi_comm_copy_topo (ompi_communicator_t *oldcomm, static int ompi_comm_copy_topo (ompi_communicator_t *oldcomm,
ompi_communicator_t *newcomm) ompi_communicator_t *newcomm)
{ {
mca_topo_base_comm_t *oldt = oldcomm->c_topo_comm; mca_topo_base_comm_t *oldt = oldcomm->c_topo_comm;
mca_topo_base_comm_t *newt = newcomm->c_topo_comm; mca_topo_base_comm_t *newt = newcomm->c_topo_comm;
@ -1703,4 +1708,3 @@ static int ompi_comm_copy_topo (ompi_communicator_t *oldcomm,
return OMPI_SUCCESS; return OMPI_SUCCESS;
} }

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

@ -181,7 +181,7 @@ int ompi_comm_nextcid ( ompi_communicator_t* newcomm,
*/ */
switch (mode) switch (mode)
{ {
case OMPI_COMM_CID_INTRA: case OMPI_COMM_CID_INTRA:
allredfnct=(ompi_comm_cid_allredfct*)ompi_comm_allreduce_intra; allredfnct=(ompi_comm_cid_allredfct*)ompi_comm_allreduce_intra;
break; break;
@ -197,85 +197,83 @@ int ompi_comm_nextcid ( ompi_communicator_t* newcomm,
default: default:
return MPI_UNDEFINED; return MPI_UNDEFINED;
break; break;
} }
do { do {
/* Only one communicator function allowed in same time on the /* Only one communicator function allowed in same time on the
* same communicator. * same communicator.
*/ */
OPAL_THREAD_LOCK(&ompi_cid_lock); OPAL_THREAD_LOCK(&ompi_cid_lock);
response = ompi_comm_register_cid (comm->c_contextid); response = ompi_comm_register_cid (comm->c_contextid);
OPAL_THREAD_UNLOCK(&ompi_cid_lock); OPAL_THREAD_UNLOCK(&ompi_cid_lock);
} while (OMPI_SUCCESS != response ); } while (OMPI_SUCCESS != response );
start = ompi_mpi_communicators.lowest_free; start = ompi_mpi_communicators.lowest_free;
while (!done) { while (!done) {
/** /**
* This is the real algorithm described in the doc * This is the real algorithm described in the doc
*/ */
OPAL_THREAD_LOCK(&ompi_cid_lock);
OPAL_THREAD_LOCK(&ompi_cid_lock); if (comm->c_contextid != ompi_comm_lowest_cid() ) {
if (comm->c_contextid != ompi_comm_lowest_cid() ) { /* if not lowest cid, we do not continue, but sleep and try again */
/* if not lowest cid, we do not continue, but sleep and try again */ OPAL_THREAD_UNLOCK(&ompi_cid_lock);
OPAL_THREAD_UNLOCK(&ompi_cid_lock); continue;
continue; }
} OPAL_THREAD_UNLOCK(&ompi_cid_lock);
OPAL_THREAD_UNLOCK(&ompi_cid_lock);
for (i=start; i < mca_pml.pml_max_contextid ; i++) {
flag=opal_pointer_array_test_and_set_item(&ompi_mpi_communicators,
for (i=start; i < mca_pml.pml_max_contextid ; i++) { i, comm);
flag=opal_pointer_array_test_and_set_item(&ompi_mpi_communicators, if (true == flag) {
i, comm); nextlocal_cid = i;
if (true == flag) { break;
nextlocal_cid = i; }
break; }
}
} (allredfnct)(&nextlocal_cid, &nextcid, 1, MPI_MAX, comm, bridgecomm,
local_leader, remote_leader, send_first );
(allredfnct)(&nextlocal_cid, &nextcid, 1, MPI_MAX, comm, bridgecomm, if (nextcid == nextlocal_cid) {
local_leader, remote_leader, send_first ); response = 1; /* fine with me */
if (nextcid == nextlocal_cid) { }
response = 1; /* fine with me */ else {
} opal_pointer_array_set_item(&ompi_mpi_communicators,
else { nextlocal_cid, NULL);
opal_pointer_array_set_item(&ompi_mpi_communicators,
nextlocal_cid, NULL); flag = opal_pointer_array_test_and_set_item(&ompi_mpi_communicators,
nextcid, comm );
flag = opal_pointer_array_test_and_set_item(&ompi_mpi_communicators, if (true == flag) {
nextcid, comm ); response = 1; /* works as well */
if (true == flag) { }
response = 1; /* works as well */ else {
} response = 0; /* nope, not acceptable */
else { }
response = 0; /* nope, not acceptable */ }
}
} (allredfnct)(&response, &glresponse, 1, MPI_MIN, comm, bridgecomm,
local_leader, remote_leader, send_first );
(allredfnct)(&response, &glresponse, 1, MPI_MIN, comm, bridgecomm, if (1 == glresponse) {
local_leader, remote_leader, send_first ); done = 1; /* we are done */
if (1 == glresponse) { break;
done = 1; /* we are done */ }
break; else if ( 0 == glresponse ) {
} if ( 1 == response ) {
else if ( 0 == glresponse ) { /* we could use that, but other don't agree */
if ( 1 == response ) { opal_pointer_array_set_item(&ompi_mpi_communicators,
/* we could use that, but other don't agree */ nextcid, NULL);
opal_pointer_array_set_item(&ompi_mpi_communicators, }
nextcid, NULL); start = nextcid+1; /* that's where we can start the next round */
} }
start = nextcid+1; /* that's where we can start the next round */
}
} }
/* set the according values to the newcomm */ /* set the according values to the newcomm */
newcomm->c_contextid = nextcid; newcomm->c_contextid = nextcid;
newcomm->c_f_to_c_index = newcomm->c_contextid; newcomm->c_f_to_c_index = newcomm->c_contextid;
opal_pointer_array_set_item (&ompi_mpi_communicators, nextcid, newcomm); opal_pointer_array_set_item (&ompi_mpi_communicators, nextcid, newcomm);
OPAL_THREAD_LOCK(&ompi_cid_lock); OPAL_THREAD_LOCK(&ompi_cid_lock);
ompi_comm_unregister_cid (comm->c_contextid); ompi_comm_unregister_cid (comm->c_contextid);
OPAL_THREAD_UNLOCK(&ompi_cid_lock); OPAL_THREAD_UNLOCK(&ompi_cid_lock);
return (MPI_SUCCESS); return (MPI_SUCCESS);
} }
@ -404,7 +402,7 @@ int ompi_comm_activate ( ompi_communicator_t** newcomm,
* send messages over the new communicator * send messages over the new communicator
*/ */
switch (mode) switch (mode)
{ {
case OMPI_COMM_CID_INTRA: case OMPI_COMM_CID_INTRA:
allredfnct=(ompi_comm_cid_allredfct*)ompi_comm_allreduce_intra; allredfnct=(ompi_comm_cid_allredfct*)ompi_comm_allreduce_intra;
break; break;
@ -420,15 +418,15 @@ int ompi_comm_activate ( ompi_communicator_t** newcomm,
default: default:
return MPI_UNDEFINED; return MPI_UNDEFINED;
break; break;
} }
if (MPI_UNDEFINED != (*newcomm)->c_local_group->grp_my_rank) { if (MPI_UNDEFINED != (*newcomm)->c_local_group->grp_my_rank) {
/* Initialize the PML stuff in the newcomm */ /* Initialize the PML stuff in the newcomm */
if ( OMPI_SUCCESS != (ret = MCA_PML_CALL(add_comm(*newcomm))) ) { if ( OMPI_SUCCESS != (ret = MCA_PML_CALL(add_comm(*newcomm))) ) {
goto bail_on_error; goto bail_on_error;
} }
OMPI_COMM_SET_PML_ADDED(*newcomm); OMPI_COMM_SET_PML_ADDED(*newcomm);
} }
@ -468,7 +466,7 @@ int ompi_comm_activate ( ompi_communicator_t** newcomm,
/* Let the collectives components fight over who will do /* Let the collectives components fight over who will do
collective on this new comm. */ collective on this new comm. */
if (OMPI_SUCCESS != (ret = mca_coll_base_comm_select(*newcomm))) { if (OMPI_SUCCESS != (ret = mca_coll_base_comm_select(*newcomm))) {
goto bail_on_error; goto bail_on_error;
} }
/* For an inter communicator, we have to deal with the potential /* For an inter communicator, we have to deal with the potential
@ -567,7 +565,7 @@ static int ompi_comm_allreduce_inter ( int *inbuf, int *outbuf,
rc = OMPI_ERR_OUT_OF_RESOURCE; rc = OMPI_ERR_OUT_OF_RESOURCE;
goto exit; goto exit;
} }
/* Execute the inter-allreduce: the result of our group will /* Execute the inter-allreduce: the result of our group will
be in the buffer of the remote group */ be in the buffer of the remote group */
rc = intercomm->c_coll.coll_allreduce ( inbuf, tmpbuf, count, MPI_INT, rc = intercomm->c_coll.coll_allreduce ( inbuf, tmpbuf, count, MPI_INT,
@ -605,12 +603,16 @@ static int ompi_comm_allreduce_inter ( int *inbuf, int *outbuf,
if ( &ompi_mpi_op_max.op == op ) { if ( &ompi_mpi_op_max.op == op ) {
for ( i = 0 ; i < count; i++ ) { for ( i = 0 ; i < count; i++ ) {
if (tmpbuf[i] > outbuf[i]) outbuf[i] = tmpbuf[i]; if (tmpbuf[i] > outbuf[i]) {
outbuf[i] = tmpbuf[i];
}
} }
} }
else if ( &ompi_mpi_op_min.op == op ) { else if ( &ompi_mpi_op_min.op == op ) {
for ( i = 0 ; i < count; i++ ) { for ( i = 0 ; i < count; i++ ) {
if (tmpbuf[i] < outbuf[i]) outbuf[i] = tmpbuf[i]; if (tmpbuf[i] < outbuf[i]) {
outbuf[i] = tmpbuf[i];
}
} }
} }
else if ( &ompi_mpi_op_sum.op == op ) { else if ( &ompi_mpi_op_sum.op == op ) {
@ -624,7 +626,7 @@ static int ompi_comm_allreduce_inter ( int *inbuf, int *outbuf,
} }
} }
} }
/* distribute the overall result to all processes in the other group. /* distribute the overall result to all processes in the other group.
Instead of using bcast, we are using here allgatherv, to avoid the Instead of using bcast, we are using here allgatherv, to avoid the
possible deadlock. Else, we need an algorithm to determine, possible deadlock. Else, we need an algorithm to determine,
@ -637,7 +639,7 @@ static int ompi_comm_allreduce_inter ( int *inbuf, int *outbuf,
rcounts, rdisps, MPI_INT, rcounts, rdisps, MPI_INT,
intercomm, intercomm,
intercomm->c_coll.coll_allgatherv_module); intercomm->c_coll.coll_allgatherv_module);
exit: exit:
if ( NULL != tmpbuf ) { if ( NULL != tmpbuf ) {
free ( tmpbuf ); free ( tmpbuf );
@ -667,7 +669,7 @@ static int ompi_comm_allreduce_intra_bridge (int *inbuf, int *outbuf,
int i; int i;
int rc; int rc;
int local_leader, remote_leader; int local_leader, remote_leader;
local_leader = (*((int*)lleader)); local_leader = (*((int*)lleader));
remote_leader = (*((int*)rleader)); remote_leader = (*((int*)rleader));
@ -694,14 +696,14 @@ static int ompi_comm_allreduce_intra_bridge (int *inbuf, int *outbuf,
MPI_Request req; MPI_Request req;
rc = MCA_PML_CALL(irecv ( outbuf, count, MPI_INT, remote_leader, rc = MCA_PML_CALL(irecv ( outbuf, count, MPI_INT, remote_leader,
OMPI_COMM_ALLREDUCE_TAG, OMPI_COMM_ALLREDUCE_TAG,
bcomm, &req)); bcomm, &req));
if ( OMPI_SUCCESS != rc ) { if ( OMPI_SUCCESS != rc ) {
goto exit; goto exit;
} }
rc = MCA_PML_CALL(send (tmpbuf, count, MPI_INT, remote_leader, rc = MCA_PML_CALL(send (tmpbuf, count, MPI_INT, remote_leader,
OMPI_COMM_ALLREDUCE_TAG, OMPI_COMM_ALLREDUCE_TAG,
MCA_PML_BASE_SEND_STANDARD, bcomm)); MCA_PML_BASE_SEND_STANDARD, bcomm));
if ( OMPI_SUCCESS != rc ) { if ( OMPI_SUCCESS != rc ) {
goto exit; goto exit;
} }
@ -712,12 +714,16 @@ static int ompi_comm_allreduce_intra_bridge (int *inbuf, int *outbuf,
if ( &ompi_mpi_op_max.op == op ) { if ( &ompi_mpi_op_max.op == op ) {
for ( i = 0 ; i < count; i++ ) { for ( i = 0 ; i < count; i++ ) {
if (tmpbuf[i] > outbuf[i]) outbuf[i] = tmpbuf[i]; if (tmpbuf[i] > outbuf[i]) {
outbuf[i] = tmpbuf[i];
}
} }
} }
else if ( &ompi_mpi_op_min.op == op ) { else if ( &ompi_mpi_op_min.op == op ) {
for ( i = 0 ; i < count; i++ ) { for ( i = 0 ; i < count; i++ ) {
if (tmpbuf[i] < outbuf[i]) outbuf[i] = tmpbuf[i]; if (tmpbuf[i] < outbuf[i]) {
outbuf[i] = tmpbuf[i];
}
} }
} }
else if ( &ompi_mpi_op_sum.op == op ) { else if ( &ompi_mpi_op_sum.op == op ) {
@ -730,9 +736,8 @@ static int ompi_comm_allreduce_intra_bridge (int *inbuf, int *outbuf,
outbuf[i] *= tmpbuf[i]; outbuf[i] *= tmpbuf[i];
} }
} }
} }
rc = comm->c_coll.coll_bcast ( outbuf, count, MPI_INT, local_leader, rc = comm->c_coll.coll_bcast ( outbuf, count, MPI_INT, local_leader,
comm, comm->c_coll.coll_bcast_module ); comm, comm->c_coll.coll_bcast_module );
@ -764,7 +769,7 @@ static int ompi_comm_allreduce_intra_oob (int *inbuf, int *outbuf,
int local_leader, local_rank; int local_leader, local_rank;
orte_process_name_t *remote_leader=NULL; orte_process_name_t *remote_leader=NULL;
orte_std_cntr_t size_count; orte_std_cntr_t size_count;
local_leader = (*((int*)lleader)); local_leader = (*((int*)lleader));
remote_leader = (orte_process_name_t*)rleader; remote_leader = (orte_process_name_t*)rleader;
size_count = count; size_count = count;
@ -773,8 +778,8 @@ static int ompi_comm_allreduce_intra_oob (int *inbuf, int *outbuf,
&ompi_mpi_op_max.op != op && &ompi_mpi_op_min.op != op ) { &ompi_mpi_op_max.op != op && &ompi_mpi_op_min.op != op ) {
return MPI_ERR_OP; return MPI_ERR_OP;
} }
local_rank = ompi_comm_rank ( comm ); local_rank = ompi_comm_rank ( comm );
tmpbuf = (int *) malloc ( count * sizeof(int)); tmpbuf = (int *) malloc ( count * sizeof(int));
if ( NULL == tmpbuf ) { if ( NULL == tmpbuf ) {
@ -826,12 +831,16 @@ static int ompi_comm_allreduce_intra_oob (int *inbuf, int *outbuf,
if ( &ompi_mpi_op_max.op == op ) { if ( &ompi_mpi_op_max.op == op ) {
for ( i = 0 ; i < count; i++ ) { for ( i = 0 ; i < count; i++ ) {
if (tmpbuf[i] > outbuf[i]) outbuf[i] = tmpbuf[i]; if (tmpbuf[i] > outbuf[i]) {
outbuf[i] = tmpbuf[i];
}
} }
} }
else if ( &ompi_mpi_op_min.op == op ) { else if ( &ompi_mpi_op_min.op == op ) {
for ( i = 0 ; i < count; i++ ) { for ( i = 0 ; i < count; i++ ) {
if (tmpbuf[i] < outbuf[i]) outbuf[i] = tmpbuf[i]; if (tmpbuf[i] < outbuf[i]) {
outbuf[i] = tmpbuf[i];
}
} }
} }
else if ( &ompi_mpi_op_sum.op == op ) { else if ( &ompi_mpi_op_sum.op == op ) {
@ -844,9 +853,8 @@ static int ompi_comm_allreduce_intra_oob (int *inbuf, int *outbuf,
outbuf[i] *= tmpbuf[i]; outbuf[i] *= tmpbuf[i];
} }
} }
} }
rc = comm->c_coll.coll_bcast (outbuf, count, MPI_INT, rc = comm->c_coll.coll_bcast (outbuf, count, MPI_INT,
local_leader, comm, local_leader, comm,
comm->c_coll.coll_bcast_module); comm->c_coll.coll_bcast_module);
@ -860,4 +868,3 @@ static int ompi_comm_allreduce_intra_oob (int *inbuf, int *outbuf,
} }
END_C_DECLS END_C_DECLS

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

@ -222,25 +222,25 @@ int ompi_comm_finalize(void)
is because a parent communicator is created dynamically is because a parent communicator is created dynamically
during init, and we just set this pointer to it. Hence, we during init, and we just set this pointer to it. Hence, we
just pass in the pointer here. */ just pass in the pointer here. */
OBJ_DESTRUCT (ompi_mpi_comm_parent); OBJ_DESTRUCT (ompi_mpi_comm_parent);
/* Please note, that the we did increase the reference count /* Please note, that the we did increase the reference count
for ompi_mpi_comm_null, ompi_mpi_group_null, and for ompi_mpi_comm_null, ompi_mpi_group_null, and
ompi_mpi_errors_are_fatal in ompi_comm_init because of ompi_mpi_errors_are_fatal in ompi_comm_init because of
ompi_mpi_comm_parent. In case a ompi_mpi_comm_parent. In case a
parent communicator is really created, the ref. counters parent communicator is really created, the ref. counters
for these objects are decreased again by one. However, in a for these objects are decreased again by one. However, in a
static scenario, we should ideally decrease the ref. counter static scenario, we should ideally decrease the ref. counter
for these objects by one here. The problem just is, that for these objects by one here. The problem just is, that
if the app had a parent_comm, and this has been freed/disconnected, 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 ompi_comm_parent points again to ompi_comm_null, the reference count
for these objects has not been increased again. for these objects has not been increased again.
So the point is, if ompi_mpi_comm_parent == &ompi_mpi_comm_null 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 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 those three objects or not. Since this is a constant, non-increasing
amount of memory, we stick with the current solution for now, amount of memory, we stick with the current solution for now,
namely don't do anything. namely don't do anything.
*/ */
} }
/* Shut down MPI_COMM_NULL */ /* Shut down MPI_COMM_NULL */
@ -256,23 +256,23 @@ int ompi_comm_finalize(void)
comm=(ompi_communicator_t *)opal_pointer_array_get_item(&ompi_mpi_communicators, i); comm=(ompi_communicator_t *)opal_pointer_array_get_item(&ompi_mpi_communicators, i);
if ( NULL != comm ) { if ( NULL != comm ) {
/* Still here ? */ /* Still here ? */
if ( !OMPI_COMM_IS_EXTRA_RETAIN(comm)) { if ( !OMPI_COMM_IS_EXTRA_RETAIN(comm)) {
/* For communicator that have been marked as "extra retain", we do not further /* For communicator that have been marked as "extra retain", we do not further
* enforce to decrease the reference counter once more. These "extra retain" * enforce to decrease the reference counter once more. These "extra retain"
* communicators created e.g. by the hierarch or inter module did increase * communicators created e.g. by the hierarch or inter module did increase
* the reference count by one more than other communicators, on order to * the reference count by one more than other communicators, on order to
* allow for deallocation with the parent communicator. Note, that * allow for deallocation with the parent communicator. Note, that
* this only occurs if the cid of the local_comm is lower than of its * this only occurs if the cid of the local_comm is lower than of its
* parent communicator. Read the comment in comm_activate for * parent communicator. Read the comment in comm_activate for
* a full explanation. * a full explanation.
*/ */
if ( ompi_debug_show_handle_leaks && !(OMPI_COMM_IS_FREED(comm)) ){ if ( ompi_debug_show_handle_leaks && !(OMPI_COMM_IS_FREED(comm)) ){
opal_output(0,"WARNING: MPI_Comm still allocated in MPI_Finalize\n"); opal_output(0,"WARNING: MPI_Comm still allocated in MPI_Finalize\n");
ompi_comm_dump ( comm); ompi_comm_dump ( comm);
OBJ_RELEASE(comm); OBJ_RELEASE(comm);
} }
} }
} }
} }
} }
@ -291,7 +291,7 @@ int ompi_comm_finalize(void)
*/ */
int ompi_comm_link_function(void) int ompi_comm_link_function(void)
{ {
return OMPI_SUCCESS; return OMPI_SUCCESS;
} }
/********************************************************************************/ /********************************************************************************/

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

@ -46,10 +46,10 @@ int ompi_group_translate_ranks ( ompi_group_t *group1,
struct ompi_proc_t *proc1_pointer, *proc2_pointer; struct ompi_proc_t *proc1_pointer, *proc2_pointer;
if ( MPI_GROUP_EMPTY == group1 || MPI_GROUP_EMPTY == group2 ) { if ( MPI_GROUP_EMPTY == group1 || MPI_GROUP_EMPTY == group2 ) {
for (proc = 0; proc < n_ranks ; proc++) { for (proc = 0; proc < n_ranks ; proc++) {
ranks2[proc] = MPI_UNDEFINED; ranks2[proc] = MPI_UNDEFINED;
} }
return MPI_SUCCESS; return MPI_SUCCESS;
} }
/* /*
@ -60,56 +60,55 @@ int ompi_group_translate_ranks ( ompi_group_t *group1,
* find a match. * find a match.
*/ */
if( group1->grp_parent_group_ptr == group2 ) { /* from child to parent */ if( group1->grp_parent_group_ptr == group2 ) { /* from child to parent */
if(OMPI_GROUP_IS_SPORADIC(group1)) { if(OMPI_GROUP_IS_SPORADIC(group1)) {
return ompi_group_translate_ranks_sporadic_reverse return ompi_group_translate_ranks_sporadic_reverse
(group1,n_ranks,ranks1,group2,ranks2); (group1,n_ranks,ranks1,group2,ranks2);
} }
else if(OMPI_GROUP_IS_STRIDED(group1)) { else if(OMPI_GROUP_IS_STRIDED(group1)) {
return ompi_group_translate_ranks_strided_reverse return ompi_group_translate_ranks_strided_reverse
(group1,n_ranks,ranks1,group2,ranks2); (group1,n_ranks,ranks1,group2,ranks2);
} }
else if(OMPI_GROUP_IS_BITMAP(group1)) { else if(OMPI_GROUP_IS_BITMAP(group1)) {
return ompi_group_translate_ranks_bmap_reverse return ompi_group_translate_ranks_bmap_reverse
(group1,n_ranks,ranks1,group2,ranks2); (group1,n_ranks,ranks1,group2,ranks2);
} }
} }
else if( group2->grp_parent_group_ptr == group1 ) { /* from parent to child*/ else if( group2->grp_parent_group_ptr == group1 ) { /* from parent to child*/
if(OMPI_GROUP_IS_SPORADIC(group2)) { if(OMPI_GROUP_IS_SPORADIC(group2)) {
return ompi_group_translate_ranks_sporadic return ompi_group_translate_ranks_sporadic
(group1,n_ranks,ranks1,group2,ranks2); (group1,n_ranks,ranks1,group2,ranks2);
} }
else if(OMPI_GROUP_IS_STRIDED(group2)) { else if(OMPI_GROUP_IS_STRIDED(group2)) {
return ompi_group_translate_ranks_strided return ompi_group_translate_ranks_strided
(group1,n_ranks,ranks1,group2,ranks2); (group1,n_ranks,ranks1,group2,ranks2);
} }
else if(OMPI_GROUP_IS_BITMAP(group2)) { else if(OMPI_GROUP_IS_BITMAP(group2)) {
return ompi_group_translate_ranks_bmap return ompi_group_translate_ranks_bmap
(group1,n_ranks,ranks1,group2,ranks2); (group1,n_ranks,ranks1,group2,ranks2);
} }
} }
else { else {
/* loop over all ranks */ /* loop over all ranks */
for (proc = 0; proc < n_ranks; proc++) { for (proc = 0; proc < n_ranks; proc++) {
rank=ranks1[proc]; rank=ranks1[proc];
if ( MPI_PROC_NULL == rank) { if ( MPI_PROC_NULL == rank) {
ranks2[proc] = MPI_PROC_NULL; ranks2[proc] = MPI_PROC_NULL;
} }
else { else {
proc1_pointer = ompi_group_peer_lookup(group1 ,rank); proc1_pointer = ompi_group_peer_lookup(group1 ,rank);
/* initialize to no "match" */ /* initialize to no "match" */
ranks2[proc] = MPI_UNDEFINED; ranks2[proc] = MPI_UNDEFINED;
for (proc2 = 0; proc2 < group2->grp_proc_count; proc2++) for (proc2 = 0; proc2 < group2->grp_proc_count; proc2++) {
{ proc2_pointer= ompi_group_peer_lookup(group2 ,proc2);
proc2_pointer= ompi_group_peer_lookup(group2 ,proc2); if ( proc1_pointer == proc2_pointer) {
if ( proc1_pointer == proc2_pointer) { ranks2[proc] = proc2;
ranks2[proc] = proc2; break;
break; }
} } /* end proc2 loop */
} /* end proc2 loop */ } /* end proc loop */
} /* end proc loop */ }
}
} }
return MPI_SUCCESS; return MPI_SUCCESS;
@ -117,49 +116,49 @@ int ompi_group_translate_ranks ( ompi_group_t *group1,
int ompi_group_dump (ompi_group_t* group) int ompi_group_dump (ompi_group_t* group)
{ {
int i; int i;
int new_rank; int new_rank;
i=0; i=0;
printf("Group Proc Count: %d\n",group->grp_proc_count); printf("Group Proc Count: %d\n",group->grp_proc_count);
printf("Group My Rank: %d\n",group->grp_my_rank); printf("Group My Rank: %d\n",group->grp_my_rank);
if (OMPI_GROUP_IS_SPORADIC(group)) { if (OMPI_GROUP_IS_SPORADIC(group)) {
ompi_group_translate_ranks( group,1,&group->grp_my_rank, ompi_group_translate_ranks( group,1,&group->grp_my_rank,
group->grp_parent_group_ptr, group->grp_parent_group_ptr,
&new_rank); &new_rank);
printf("Rank in the parent group: %d\n",new_rank); printf("Rank in the parent group: %d\n",new_rank);
printf("The Sporadic List Length: %d\n", printf("The Sporadic List Length: %d\n",
group->sparse_data.grp_sporadic.grp_sporadic_list_len); group->sparse_data.grp_sporadic.grp_sporadic_list_len);
printf("Rank First Length\n"); printf("Rank First Length\n");
for(i=0 ; i<group->sparse_data.grp_sporadic.grp_sporadic_list_len ; i++) { for(i=0 ; i<group->sparse_data.grp_sporadic.grp_sporadic_list_len ; i++) {
printf("%d %d\n", printf("%d %d\n",
group->sparse_data.grp_sporadic.grp_sporadic_list[i].rank_first, group->sparse_data.grp_sporadic.grp_sporadic_list[i].rank_first,
group->sparse_data.grp_sporadic.grp_sporadic_list[i].length); group->sparse_data.grp_sporadic.grp_sporadic_list[i].length);
} }
} }
else if (OMPI_GROUP_IS_STRIDED(group)) { else if (OMPI_GROUP_IS_STRIDED(group)) {
ompi_group_translate_ranks( group,1,&group->grp_my_rank, ompi_group_translate_ranks( group,1,&group->grp_my_rank,
group->grp_parent_group_ptr, group->grp_parent_group_ptr,
&new_rank); &new_rank);
printf("Rank in the parent group: %d\n",new_rank); printf("Rank in the parent group: %d\n",new_rank);
printf("The Offset is: %d\n",group->sparse_data.grp_strided.grp_strided_offset); printf("The Offset is: %d\n",group->sparse_data.grp_strided.grp_strided_offset);
printf("The Stride is: %d\n",group->sparse_data.grp_strided.grp_strided_stride); printf("The Stride is: %d\n",group->sparse_data.grp_strided.grp_strided_stride);
printf("The Last Element is: %d\n", printf("The Last Element is: %d\n",
group->sparse_data.grp_strided.grp_strided_last_element); group->sparse_data.grp_strided.grp_strided_last_element);
} }
else if (OMPI_GROUP_IS_BITMAP(group)) { else if (OMPI_GROUP_IS_BITMAP(group)) {
ompi_group_translate_ranks( group,1,&group->grp_my_rank, ompi_group_translate_ranks( group,1,&group->grp_my_rank,
group->grp_parent_group_ptr, group->grp_parent_group_ptr,
&new_rank); &new_rank);
printf("Rank in the parent group: %d\n",new_rank); printf("Rank in the parent group: %d\n",new_rank);
printf("The length of the bitmap array is: %d\n", printf("The length of the bitmap array is: %d\n",
group->sparse_data.grp_bitmap.grp_bitmap_array_len); group->sparse_data.grp_bitmap.grp_bitmap_array_len);
for (i=0 ; i<group->sparse_data.grp_bitmap.grp_bitmap_array_len ; i++) { for (i=0 ; i<group->sparse_data.grp_bitmap.grp_bitmap_array_len ; i++) {
printf("%d\t",group->sparse_data.grp_bitmap.grp_bitmap_array[i]); printf("%d\t",group->sparse_data.grp_bitmap.grp_bitmap_array[i]);
} }
} }
printf("*********************************************************\n"); printf("*********************************************************\n");
return OMPI_SUCCESS; return OMPI_SUCCESS;
} }
/* /*
@ -169,17 +168,15 @@ int ompi_group_dump (ompi_group_t* group)
ompi_proc_t* ompi_group_get_proc_ptr (ompi_group_t* group , int rank) ompi_proc_t* ompi_group_get_proc_ptr (ompi_group_t* group , int rank)
{ {
int ranks1,ranks2; int ranks1,ranks2;
do do {
{ if(OMPI_GROUP_IS_DENSE(group)) {
if(OMPI_GROUP_IS_DENSE(group)) return group->grp_proc_pointers[rank];
{
return group->grp_proc_pointers[rank];
} }
ranks1 = rank; ranks1 = rank;
ompi_group_translate_ranks( group, 1, &ranks1, ompi_group_translate_ranks( group, 1, &ranks1,
group->grp_parent_group_ptr,&ranks2); group->grp_parent_group_ptr,&ranks2);
rank = ranks2; rank = ranks2;
group = group->grp_parent_group_ptr; group = group->grp_parent_group_ptr;
} while (1); } while (1);
} }
@ -190,10 +187,10 @@ int ompi_group_minloc ( int list[] , int length )
index = 0; index = 0;
for (i=0 ; i<length ; i++) { for (i=0 ; i<length ; i++) {
if (min > list[i] && list[i] != -1) { if (min > list[i] && list[i] != -1) {
min = list[i]; min = list[i];
index = i; index = i;
} }
} }
return index; return index;
} }
@ -204,8 +201,7 @@ int ompi_group_incl(ompi_group_t* group, int n, int *ranks, ompi_group_t **new_g
method = 0; method = 0;
#if OMPI_GROUP_SPARSE #if OMPI_GROUP_SPARSE
if (ompi_use_sparse_group_storage) if (ompi_use_sparse_group_storage) {
{
int len [4]; int len [4];
len[0] = ompi_group_calc_plist ( n ,ranks ); len[0] = ompi_group_calc_plist ( n ,ranks );
@ -219,20 +215,20 @@ int ompi_group_incl(ompi_group_t* group, int n, int *ranks, ompi_group_t **new_g
#endif #endif
switch (method) switch (method)
{ {
case 0: case 0:
result = ompi_group_incl_plist(group, n, ranks, new_group); result = ompi_group_incl_plist(group, n, ranks, new_group);
break; break;
case 1: case 1:
result = ompi_group_incl_strided(group, n, ranks, new_group); result = ompi_group_incl_strided(group, n, ranks, new_group);
break; break;
case 2: case 2:
result = ompi_group_incl_spor(group, n, ranks, new_group); result = ompi_group_incl_spor(group, n, ranks, new_group);
break; break;
default: default:
result = ompi_group_incl_bmap(group, n, ranks, new_group); result = ompi_group_incl_bmap(group, n, ranks, new_group);
break; break;
} }
return result; return result;
} }
@ -249,7 +245,9 @@ int ompi_group_excl(ompi_group_t* group, int n, int *ranks, ompi_group_t **new_g
for (i=0 ; i<group->grp_proc_count ; i++) { for (i=0 ; i<group->grp_proc_count ; i++) {
for(j=0 ; j<n ; j++) { for(j=0 ; j<n ; j++) {
if(ranks[j] == i) break; if(ranks[j] == i) {
break;
}
} }
if (j==n) { if (j==n) {
ranks_included[k] = i; ranks_included[k] = i;
@ -268,7 +266,7 @@ int ompi_group_excl(ompi_group_t* group, int n, int *ranks, ompi_group_t **new_g
} }
int ompi_group_range_incl(ompi_group_t* group, int n_triplets, int ranges[][3], int ompi_group_range_incl(ompi_group_t* group, int n_triplets, int ranges[][3],
ompi_group_t **new_group) ompi_group_t **new_group)
{ {
int j,k; int j,k;
int *ranks_included=NULL; int *ranks_included=NULL;
@ -281,33 +279,32 @@ int ompi_group_range_incl(ompi_group_t* group, int n_triplets, int ranges[][3],
for(j=0 ; j<n_triplets ; j++) { for(j=0 ; j<n_triplets ; j++) {
first_rank = ranges[j][0]; first_rank = ranges[j][0];
last_rank = ranges[j][1]; last_rank = ranges[j][1];
stride = ranges[j][2]; stride = ranges[j][2];
if (first_rank < last_rank) { if (first_rank < last_rank) {
/* positive stride */ /* positive stride */
index = first_rank; index = first_rank;
while (index <= last_rank) { while (index <= last_rank) {
count ++; count ++;
k++; k++;
index += stride; index += stride;
} /* end while loop */ } /* end while loop */
} }
else if (first_rank > last_rank) { else if (first_rank > last_rank) {
/* negative stride */ /* negative stride */
index = first_rank;
while (index >= last_rank) {
count ++;
k++;
index += stride;
} /* end while loop */
} else { /* first_rank == last_rank */
index = first_rank; index = first_rank;
count ++; while (index >= last_rank) {
k++; count ++;
} k++;
index += stride;
} /* end while loop */
} else { /* first_rank == last_rank */
index = first_rank;
count ++;
k++;
}
} }
if (0 != count) { if (0 != count) {
ranks_included = (int *)malloc( (count)*(sizeof(int))); ranks_included = (int *)malloc( (count)*(sizeof(int)));
@ -317,46 +314,44 @@ int ompi_group_range_incl(ompi_group_t* group, int n_triplets, int ranges[][3],
for(j=0 ; j<n_triplets ; j++) { for(j=0 ; j<n_triplets ; j++) {
first_rank = ranges[j][0]; first_rank = ranges[j][0];
last_rank = ranges[j][1]; last_rank = ranges[j][1];
stride = ranges[j][2]; stride = ranges[j][2];
if (first_rank < last_rank) { if (first_rank < last_rank) {
/* positive stride */ /* positive stride */
index = first_rank; index = first_rank;
while (index <= last_rank) { while (index <= last_rank) {
ranks_included[k] = index; ranks_included[k] = index;
k++; k++;
index += stride; index += stride;
} /* end while loop */ } /* end while loop */
} }
else if (first_rank > last_rank) { else if (first_rank > last_rank) {
/* negative stride */ /* negative stride */
index = first_rank;
while (index >= last_rank) {
ranks_included[k] = index;
k++;
index += stride;
} /* end while loop */
} else { /* first_rank == last_rank */
index = first_rank; index = first_rank;
ranks_included[k] = index; while (index >= last_rank) {
k++; ranks_included[k] = index;
} k++;
index += stride;
} /* end while loop */
} else { /* first_rank == last_rank */
index = first_rank;
ranks_included[k] = index;
k++;
}
} }
result = ompi_group_incl(group, k, ranks_included, new_group); result = ompi_group_incl(group, k, ranks_included, new_group);
if (NULL != ranks_included) if (NULL != ranks_included) {
{
free(ranks_included); free(ranks_included);
} }
return result; return result;
} }
int ompi_group_range_excl(ompi_group_t* group, int n_triplets, int ranges[][3], int ompi_group_range_excl(ompi_group_t* group, int n_triplets, int ranges[][3],
ompi_group_t **new_group) ompi_group_t **new_group)
{ {
int j,k,i; int j,k,i;
@ -368,32 +363,30 @@ int ompi_group_range_excl(ompi_group_t* group, int n_triplets, int ranges[][3],
/* determine the number of excluded processes for the range-excl-method */ /* determine the number of excluded processes for the range-excl-method */
k = 0; k = 0;
for(j=0 ; j<n_triplets ; j++) { for(j=0 ; j<n_triplets ; j++) {
first_rank = ranges[j][0]; first_rank = ranges[j][0];
last_rank = ranges[j][1]; last_rank = ranges[j][1];
stride = ranges[j][2]; stride = ranges[j][2];
if (first_rank < last_rank) { if (first_rank < last_rank) {
/* positive stride */ /* positive stride */
index = first_rank; index = first_rank;
while (index <= last_rank) { while (index <= last_rank) {
count ++; count ++;
index += stride; index += stride;
} /* end while loop */ } /* end while loop */
} }
else if (first_rank > last_rank) { else if (first_rank > last_rank) {
/* negative stride */ /* negative stride */
index = first_rank;
while (index >= last_rank) {
count ++;
index += stride;
} /* end while loop */
} else { /* first_rank == last_rank */
index = first_rank; index = first_rank;
count ++; while (index >= last_rank) {
} count ++;
index += stride;
} /* end while loop */
} else { /* first_rank == last_rank */
index = first_rank;
count ++;
}
} }
if (0 != count) { if (0 != count) {
ranks_excluded = (int *)malloc( (count)*(sizeof(int))); ranks_excluded = (int *)malloc( (count)*(sizeof(int)));
@ -402,64 +395,61 @@ int ompi_group_range_excl(ompi_group_t* group, int n_triplets, int ranges[][3],
k = 0; k = 0;
i = 0; i = 0;
for(j=0 ; j<n_triplets ; j++) { for(j=0 ; j<n_triplets ; j++) {
first_rank = ranges[j][0]; first_rank = ranges[j][0];
last_rank = ranges[j][1]; last_rank = ranges[j][1];
stride = ranges[j][2]; stride = ranges[j][2];
if (first_rank < last_rank) { if (first_rank < last_rank) {
/* positive stride */ /* positive stride */
index = first_rank; index = first_rank;
while (index <= last_rank) { while (index <= last_rank) {
ranks_excluded[i] = index; ranks_excluded[i] = index;
i++; i++;
index += stride; index += stride;
} /* end while loop */ } /* end while loop */
} }
else if (first_rank > last_rank) { else if (first_rank > last_rank) {
/* negative stride */ /* negative stride */
index = first_rank;
while (index >= last_rank) {
ranks_excluded[i] = index;
i++;
index += stride;
} /* end while loop */
} else { /* first_rank == last_rank */
index = first_rank; index = first_rank;
ranks_excluded[i] = index; while (index >= last_rank) {
i++; ranks_excluded[i] = index;
} i++;
index += stride;
} /* end while loop */
} else { /* first_rank == last_rank */
index = first_rank;
ranks_excluded[i] = index;
i++;
}
} }
if (0 != (group->grp_proc_count - count)) { if (0 != (group->grp_proc_count - count)) {
ranks_included = (int *)malloc( (group->grp_proc_count - count)*(sizeof(int))); ranks_included = (int *)malloc( (group->grp_proc_count - count)*(sizeof(int)));
} }
for (j=0 ; j<group->grp_proc_count ; j++) { for (j=0 ; j<group->grp_proc_count ; j++) {
for(index=0 ; index<i ; index++) { for(index=0 ; index<i ; index++) {
if(ranks_excluded[index] == j) break; if(ranks_excluded[index] == j) break;
} }
if (index == i) { if (index == i) {
ranks_included[k] = j; ranks_included[k] = j;
k++; k++;
} }
} }
if (NULL != ranks_excluded) if (NULL != ranks_excluded) {
{
free(ranks_excluded); free(ranks_excluded);
} }
result = ompi_group_incl(group, k, ranks_included, new_group); result = ompi_group_incl(group, k, ranks_included, new_group);
if (NULL != ranks_included) if (NULL != ranks_included) {
{
free(ranks_included); free(ranks_included);
} }
return result; return result;
} }
int ompi_group_intersection(ompi_group_t* group1,ompi_group_t* group2, int ompi_group_intersection(ompi_group_t* group1,ompi_group_t* group2,
ompi_group_t **new_group) ompi_group_t **new_group)
{ {
int proc1,proc2,k, result; int proc1,proc2,k, result;
int *ranks_included=NULL; int *ranks_included=NULL;
@ -469,18 +459,18 @@ int ompi_group_intersection(ompi_group_t* group1,ompi_group_t* group2,
group1_pointer=(ompi_group_t *)group1; group1_pointer=(ompi_group_t *)group1;
group2_pointer=(ompi_group_t *)group2; group2_pointer=(ompi_group_t *)group2;
/* determine the number of included processes for the incl-method */ /* determine the number of included processes for the incl-method */
k = 0; k = 0;
for (proc1 = 0; proc1 < group1_pointer->grp_proc_count; proc1++) { for (proc1 = 0; proc1 < group1_pointer->grp_proc_count; proc1++) {
proc1_pointer = ompi_group_peer_lookup (group1_pointer , proc1); proc1_pointer = ompi_group_peer_lookup (group1_pointer , proc1);
/* check to see if this proc is in group2 */ /* check to see if this proc is in group2 */
for (proc2 = 0; proc2 < group2_pointer->grp_proc_count; proc2++) { for (proc2 = 0; proc2 < group2_pointer->grp_proc_count; proc2++) {
proc2_pointer = ompi_group_peer_lookup (group2_pointer , proc2); proc2_pointer = ompi_group_peer_lookup (group2_pointer , proc2);
if( proc1_pointer == proc2_pointer ) { if( proc1_pointer == proc2_pointer ) {
k++; k++;
break; break;
} }
} /* end proc2 loop */ } /* end proc2 loop */
@ -493,16 +483,16 @@ int ompi_group_intersection(ompi_group_t* group1,ompi_group_t* group2,
/* determine the list of included processes for the incl-method */ /* determine the list of included processes for the incl-method */
k = 0; k = 0;
for (proc1 = 0; proc1 < group1_pointer->grp_proc_count; proc1++) { for (proc1 = 0; proc1 < group1_pointer->grp_proc_count; proc1++) {
proc1_pointer = ompi_group_peer_lookup (group1_pointer , proc1); proc1_pointer = ompi_group_peer_lookup (group1_pointer , proc1);
/* check to see if this proc is in group2 */ /* check to see if this proc is in group2 */
for (proc2 = 0; proc2 < group2_pointer->grp_proc_count; proc2++) { for (proc2 = 0; proc2 < group2_pointer->grp_proc_count; proc2++) {
proc2_pointer = ompi_group_peer_lookup (group2_pointer ,proc2); proc2_pointer = ompi_group_peer_lookup (group2_pointer ,proc2);
if( proc1_pointer == proc2_pointer ) { if( proc1_pointer == proc2_pointer ) {
ranks_included[k] = proc1; ranks_included[k] = proc1;
k++; k++;
break; break;
} }
} /* end proc2 loop */ } /* end proc2 loop */
@ -510,9 +500,9 @@ int ompi_group_intersection(ompi_group_t* group1,ompi_group_t* group2,
result = ompi_group_incl(group1, k, ranks_included, new_group); result = ompi_group_incl(group1, k, ranks_included, new_group);
if (NULL != ranks_included) if (NULL != ranks_included) {
{
free(ranks_included); free(ranks_included);
} }
return result; return result;
} }

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

@ -27,29 +27,29 @@ static bool check_ranks (int, int *);
int ompi_group_calc_bmap ( int n, int orig_size , int *ranks) { int ompi_group_calc_bmap ( int n, int orig_size , int *ranks) {
if (check_ranks(n,ranks)) { if (check_ranks(n,ranks)) {
return ompi_group_div_ceil(orig_size,BSIZE); return ompi_group_div_ceil(orig_size,BSIZE);
} }
else { else {
return -1; return -1;
} }
} }
/* from parent group to child group*/ /* from parent group to child group*/
int ompi_group_translate_ranks_bmap ( ompi_group_t *parent_group, int ompi_group_translate_ranks_bmap ( ompi_group_t *parent_group,
int n_ranks, int *ranks1, int n_ranks, int *ranks1,
ompi_group_t *child_group, ompi_group_t *child_group,
int *ranks2) int *ranks2)
{ {
int i,count,j,k,m; int i,count,j,k,m;
unsigned char tmp, tmp1; unsigned char tmp, tmp1;
for (j=0 ; j<n_ranks ; j++) { for (j=0 ; j<n_ranks ; j++) {
if ( MPI_PROC_NULL == ranks1[j]) { if ( MPI_PROC_NULL == ranks1[j]) {
ranks2[j] = MPI_PROC_NULL; ranks2[j] = MPI_PROC_NULL;
} }
else { else {
ranks2[j] = MPI_UNDEFINED; ranks2[j] = MPI_UNDEFINED;
m = ranks1[j]; m = ranks1[j];
count = 0; count = 0;
tmp = ( 1 << (m % BSIZE) ); tmp = ( 1 << (m % BSIZE) );
/* check if the bit that correponds to the parent rank is set in the bitmap */ /* check if the bit that correponds to the parent rank is set in the bitmap */
if ( tmp == (child_group->sparse_data.grp_bitmap.grp_bitmap_array[(int)(m/BSIZE)] if ( tmp == (child_group->sparse_data.grp_bitmap.grp_bitmap_array[(int)(m/BSIZE)]
@ -60,57 +60,58 @@ int ompi_group_translate_ranks_bmap ( ompi_group_t *parent_group,
* that are set on the way till we get to the correponding bit * that are set on the way till we get to the correponding bit
*/ */
for (i=0 ; i<=(int)(m/BSIZE) ; i++) { for (i=0 ; i<=(int)(m/BSIZE) ; i++) {
for (k=0 ; k<BSIZE ; k++) { for (k=0 ; k<BSIZE ; k++) {
tmp1 = ( 1 << k); tmp1 = ( 1 << k);
if ( tmp1 == ( child_group->sparse_data.grp_bitmap.grp_bitmap_array[i] if ( tmp1 == ( child_group->sparse_data.grp_bitmap.grp_bitmap_array[i]
& (1 << k) ) ) { & (1 << k) ) ) {
count++; count++;
} }
if( i==(int)(m/BSIZE) && k==m % BSIZE ) { if( i==(int)(m/BSIZE) && k==m % BSIZE ) {
ranks2[j] = count-1; ranks2[j] = count-1;
i = (int)(m/BSIZE) + 1; i = (int)(m/BSIZE) + 1;
break; break;
} }
} }
} }
} }
} }
} }
return OMPI_SUCCESS; return OMPI_SUCCESS;
} }
/* from child group to parent group */ /* from child group to parent group */
int ompi_group_translate_ranks_bmap_reverse ( ompi_group_t *child_group, int ompi_group_translate_ranks_bmap_reverse ( ompi_group_t *child_group,
int n_ranks, int *ranks1, int n_ranks, int *ranks1,
ompi_group_t *parent_group, ompi_group_t *parent_group,
int *ranks2) int *ranks2)
{ {
int i,j,count,m,k; int i,j,count,m,k;
unsigned char tmp; unsigned char tmp;
for (j=0 ; j<n_ranks ; j++) { for (j=0 ; j<n_ranks ; j++) {
if ( MPI_PROC_NULL == ranks1[j]) { if ( MPI_PROC_NULL == ranks1[j]) {
ranks2[j] = MPI_PROC_NULL; ranks2[j] = MPI_PROC_NULL;
} }
else { else {
m = ranks1[j]; m = ranks1[j];
count = 0; count = 0;
/* /*
* Go through all the bits set in the bitmap up to the child rank. * Go through all the bits set in the bitmap up to the child rank.
* The parent rank will be the sum of all bits passed (set and unset) * The parent rank will be the sum of all bits passed (set and unset)
*/ */
for (i=0 ; i<child_group->sparse_data.grp_bitmap.grp_bitmap_array_len ; i++) { for (i=0 ; i<child_group->sparse_data.grp_bitmap.grp_bitmap_array_len ; i++) {
for (k=0 ; k<BSIZE ; k++) { for (k=0 ; k<BSIZE ; k++) {
tmp = ( 1 << k); tmp = ( 1 << k);
if ( tmp == ( child_group->sparse_data.grp_bitmap.grp_bitmap_array[i] if ( tmp == ( child_group->sparse_data.grp_bitmap.grp_bitmap_array[i]
& (1 << k) ) ) & (1 << k) ) ) {
count++; count++;
if( m == count-1 ) { }
ranks2[j] = i*BSIZE + k; if( m == count-1 ) {
i = child_group->sparse_data.grp_bitmap.grp_bitmap_array_len + 1; ranks2[j] = i*BSIZE + k;
break; i = child_group->sparse_data.grp_bitmap.grp_bitmap_array_len + 1;
} break;
} }
}
} }
} }
} }
return OMPI_SUCCESS; return OMPI_SUCCESS;
} }
@ -133,7 +134,7 @@ int ompi_group_div_ceil (int num, int den)
static bool check_ranks (int n, int *ranks) { static bool check_ranks (int n, int *ranks) {
int i; int i;
for (i=1 ; i < n ; i++) { for (i=1 ; i < n ; i++) {
if ( ranks[i-1] > ranks [i] ) { if ( ranks[i-1] > ranks [i] ) {
return false; return false;
} }
} }
@ -141,7 +142,7 @@ static bool check_ranks (int n, int *ranks) {
} }
int ompi_group_incl_bmap(ompi_group_t* group, int n, int *ranks, int ompi_group_incl_bmap(ompi_group_t* group, int n, int *ranks,
ompi_group_t **new_group) ompi_group_t **new_group)
{ {
/* local variables */ /* local variables */
int my_group_rank,i,bit_set; int my_group_rank,i,bit_set;
@ -150,24 +151,24 @@ int ompi_group_incl_bmap(ompi_group_t* group, int n, int *ranks,
group_pointer = (ompi_group_t *)group; group_pointer = (ompi_group_t *)group;
if ( 0 == n ) { if ( 0 == n ) {
*new_group = MPI_GROUP_EMPTY; *new_group = MPI_GROUP_EMPTY;
OBJ_RETAIN(MPI_GROUP_EMPTY); OBJ_RETAIN(MPI_GROUP_EMPTY);
return OMPI_SUCCESS; return OMPI_SUCCESS;
} }
new_group_pointer = ompi_group_allocate_bmap(group->grp_proc_count, n); new_group_pointer = ompi_group_allocate_bmap(group->grp_proc_count, n);
if( NULL == new_group_pointer ) { if( NULL == new_group_pointer ) {
return MPI_ERR_GROUP; return MPI_ERR_GROUP;
} }
/* Initialize the bit array to zeros */ /* Initialize the bit array to zeros */
for (i=0 ; i<new_group_pointer->sparse_data.grp_bitmap.grp_bitmap_array_len ; i++) { for (i=0 ; i<new_group_pointer->sparse_data.grp_bitmap.grp_bitmap_array_len ; i++) {
new_group_pointer-> new_group_pointer->
sparse_data.grp_bitmap.grp_bitmap_array[i] = 0; sparse_data.grp_bitmap.grp_bitmap_array[i] = 0;
} }
/* set the bits */ /* set the bits */
for (i=0 ; i<n ; i++) { for (i=0 ; i<n ; i++) {
bit_set = ranks[i] % BSIZE; bit_set = ranks[i] % BSIZE;
new_group_pointer-> new_group_pointer->
sparse_data.grp_bitmap.grp_bitmap_array[(int)(ranks[i]/BSIZE)] |= (1 << bit_set); sparse_data.grp_bitmap.grp_bitmap_array[(int)(ranks[i]/BSIZE)] |= (1 << bit_set);
} }

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

@ -59,8 +59,9 @@ ompi_group_t *ompi_group_allocate(int group_size)
/* create new group group element */ /* create new group group element */
new_group = OBJ_NEW(ompi_group_t); new_group = OBJ_NEW(ompi_group_t);
if (NULL == new_group) if (NULL == new_group) {
goto error_exit; goto error_exit;
}
if (0 > new_group->grp_f_to_c_index) { if (0 > new_group->grp_f_to_c_index) {
OBJ_RELEASE (new_group); OBJ_RELEASE (new_group);
@ -89,7 +90,7 @@ ompi_group_t *ompi_group_allocate(int group_size)
new_group->grp_my_rank = MPI_UNDEFINED; new_group->grp_my_rank = MPI_UNDEFINED;
OMPI_GROUP_SET_DENSE(new_group); OMPI_GROUP_SET_DENSE(new_group);
error_exit: error_exit:
/* return */ /* return */
return new_group; return new_group;
} }
@ -135,7 +136,7 @@ ompi_group_t *ompi_group_allocate_sporadic(int group_size)
new_group->grp_proc_pointers = NULL; new_group->grp_proc_pointers = NULL;
OMPI_GROUP_SET_SPORADIC(new_group); OMPI_GROUP_SET_SPORADIC(new_group);
error_exit: error_exit:
return new_group; return new_group;
} }
@ -160,7 +161,7 @@ ompi_group_t *ompi_group_allocate_strided(void)
new_group->sparse_data.grp_strided.grp_strided_stride = -1; new_group->sparse_data.grp_strided.grp_strided_stride = -1;
new_group->sparse_data.grp_strided.grp_strided_offset = -1; new_group->sparse_data.grp_strided.grp_strided_offset = -1;
new_group->sparse_data.grp_strided.grp_strided_last_element = -1; new_group->sparse_data.grp_strided.grp_strided_last_element = -1;
error_exit: error_exit:
/* return */ /* return */
return new_group; return new_group;
} }
@ -194,7 +195,7 @@ ompi_group_t *ompi_group_allocate_bmap(int orig_group_size , int group_size)
new_group->grp_proc_pointers = NULL; new_group->grp_proc_pointers = NULL;
OMPI_GROUP_SET_BITMAP(new_group); OMPI_GROUP_SET_BITMAP(new_group);
error_exit: error_exit:
/* return */ /* return */
return new_group; return new_group;
} }
@ -207,8 +208,8 @@ void ompi_group_increment_proc_count(ompi_group_t *group)
int proc; int proc;
ompi_proc_t * proc_pointer; ompi_proc_t * proc_pointer;
for (proc = 0; proc < group->grp_proc_count; proc++) { for (proc = 0; proc < group->grp_proc_count; proc++) {
proc_pointer = ompi_group_peer_lookup(group,proc); proc_pointer = ompi_group_peer_lookup(group,proc);
OBJ_RETAIN(proc_pointer); OBJ_RETAIN(proc_pointer);
} }
return; return;
@ -223,8 +224,8 @@ void ompi_group_decrement_proc_count(ompi_group_t *group)
int proc; int proc;
ompi_proc_t * proc_pointer; ompi_proc_t * proc_pointer;
for (proc = 0; proc < group->grp_proc_count; proc++) { for (proc = 0; proc < group->grp_proc_count; proc++) {
proc_pointer = ompi_group_peer_lookup(group,proc); proc_pointer = ompi_group_peer_lookup(group,proc);
OBJ_RELEASE(proc_pointer); OBJ_RELEASE(proc_pointer);
} }
return; return;
@ -290,9 +291,9 @@ static void ompi_group_destruct(ompi_group_t *group)
/* reset the ompi_group_f_to_c_table entry - make sure that the /* reset the ompi_group_f_to_c_table entry - make sure that the
* entry is in the table */ * entry is in the table */
if (NULL != opal_pointer_array_get_item(&ompi_group_f_to_c_table, if (NULL != opal_pointer_array_get_item(&ompi_group_f_to_c_table,
group->grp_f_to_c_index)) { group->grp_f_to_c_index)) {
opal_pointer_array_set_item(&ompi_group_f_to_c_table, opal_pointer_array_set_item(&ompi_group_f_to_c_table,
group->grp_f_to_c_index, NULL); group->grp_f_to_c_index, NULL);
} }
/* return */ /* return */
@ -347,6 +348,3 @@ int ompi_group_finalize(void)
return OMPI_SUCCESS; return OMPI_SUCCESS;
} }
/* LocalWords: grp
*/

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

@ -31,7 +31,7 @@ int ompi_group_calc_plist ( int n , int *ranks ) {
} }
int ompi_group_incl_plist(ompi_group_t* group, int n, int *ranks, int ompi_group_incl_plist(ompi_group_t* group, int n, int *ranks,
ompi_group_t **new_group) ompi_group_t **new_group)
{ {
/* local variables */ /* local variables */
int proc,my_group_rank; int proc,my_group_rank;
@ -41,22 +41,21 @@ int ompi_group_incl_plist(ompi_group_t* group, int n, int *ranks,
group_pointer = (ompi_group_t *)group; group_pointer = (ompi_group_t *)group;
if ( 0 == n ) { if ( 0 == n ) {
*new_group = MPI_GROUP_EMPTY; *new_group = MPI_GROUP_EMPTY;
OBJ_RETAIN(MPI_GROUP_EMPTY); OBJ_RETAIN(MPI_GROUP_EMPTY);
return OMPI_SUCCESS; return OMPI_SUCCESS;
} }
/* get new group struct */ /* get new group struct */
new_group_pointer=ompi_group_allocate(n); new_group_pointer=ompi_group_allocate(n);
if( NULL == new_group_pointer ) { if( NULL == new_group_pointer ) {
return MPI_ERR_GROUP; return MPI_ERR_GROUP;
} }
/* put group elements in the list */ /* put group elements in the list */
for (proc = 0; proc < n; proc++) { for (proc = 0; proc < n; proc++) {
new_group_pointer->grp_proc_pointers[proc] = new_group_pointer->grp_proc_pointers[proc] =
ompi_group_peer_lookup(group_pointer,ranks[proc]); ompi_group_peer_lookup(group_pointer,ranks[proc]);
} /* end proc loop */ } /* end proc loop */
/* increment proc reference counters */ /* increment proc reference counters */
@ -82,7 +81,7 @@ int ompi_group_incl_plist(ompi_group_t* group, int n, int *ranks,
* two parent groups in the group structure and maintain functions * two parent groups in the group structure and maintain functions
*/ */
int ompi_group_union (ompi_group_t* group1, ompi_group_t* group2, int ompi_group_union (ompi_group_t* group1, ompi_group_t* group2,
ompi_group_t **new_group) ompi_group_t **new_group)
{ {
/* local variables */ /* local variables */
int new_group_size, proc1, proc2, found_in_group; int new_group_size, proc1, proc2, found_in_group;
@ -116,16 +115,17 @@ int ompi_group_union (ompi_group_t* group1, ompi_group_t* group2,
} }
} /* end proc1 loop */ } /* end proc1 loop */
if (found_in_group) if (found_in_group) {
continue; continue;
}
new_group_size++; new_group_size++;
} /* end proc loop */ } /* end proc loop */
if ( 0 == new_group_size ) { if ( 0 == new_group_size ) {
*new_group = MPI_GROUP_EMPTY; *new_group = MPI_GROUP_EMPTY;
OBJ_RETAIN(MPI_GROUP_EMPTY); OBJ_RETAIN(MPI_GROUP_EMPTY);
return MPI_SUCCESS; return MPI_SUCCESS;
} }
/* get new group struct */ /* get new group struct */
@ -139,7 +139,7 @@ int ompi_group_union (ompi_group_t* group1, ompi_group_t* group2,
/* put group1 elements in the list */ /* put group1 elements in the list */
for (proc1 = 0; proc1 < group1_pointer->grp_proc_count; proc1++) { for (proc1 = 0; proc1 < group1_pointer->grp_proc_count; proc1++) {
new_group_pointer->grp_proc_pointers[proc1] = new_group_pointer->grp_proc_pointers[proc1] =
ompi_group_peer_lookup(group1_pointer,proc1); ompi_group_peer_lookup(group1_pointer,proc1);
} }
cnt = group1_pointer->grp_proc_count; cnt = group1_pointer->grp_proc_count;
@ -159,11 +159,12 @@ int ompi_group_union (ompi_group_t* group1, ompi_group_t* group2,
} }
} /* end proc1 loop */ } /* end proc1 loop */
if (found_in_group) if (found_in_group) {
continue; continue;
}
new_group_pointer->grp_proc_pointers[cnt] = new_group_pointer->grp_proc_pointers[cnt] =
ompi_group_peer_lookup(group2_pointer,proc2); ompi_group_peer_lookup(group2_pointer,proc2);
cnt++; cnt++;
} /* end proc loop */ } /* end proc loop */
@ -174,18 +175,18 @@ int ompi_group_union (ompi_group_t* group1, ompi_group_t* group2,
my_group_rank = group1_pointer->grp_my_rank; my_group_rank = group1_pointer->grp_my_rank;
if (MPI_UNDEFINED == my_group_rank) { if (MPI_UNDEFINED == my_group_rank) {
my_group_rank = group2_pointer->grp_my_rank; my_group_rank = group2_pointer->grp_my_rank;
if ( MPI_UNDEFINED != my_group_rank) { if ( MPI_UNDEFINED != my_group_rank) {
my_proc_pointer = ompi_group_peer_lookup(group2_pointer,my_group_rank); my_proc_pointer = ompi_group_peer_lookup(group2_pointer,my_group_rank);
} }
} else { } else {
my_proc_pointer = ompi_group_peer_lookup(group1_pointer,my_group_rank); my_proc_pointer = ompi_group_peer_lookup(group1_pointer,my_group_rank);
} }
if ( MPI_UNDEFINED == my_group_rank ) { if ( MPI_UNDEFINED == my_group_rank ) {
new_group_pointer->grp_my_rank = MPI_UNDEFINED; new_group_pointer->grp_my_rank = MPI_UNDEFINED;
} }
else { else {
ompi_set_group_rank(new_group_pointer, my_proc_pointer); ompi_set_group_rank(new_group_pointer, my_proc_pointer);
} }
*new_group = (MPI_Group) new_group_pointer; *new_group = (MPI_Group) new_group_pointer;
@ -199,7 +200,7 @@ int ompi_group_union (ompi_group_t* group1, ompi_group_t* group2,
* two parent groups in the group structure and maintain functions * two parent groups in the group structure and maintain functions
*/ */
int ompi_group_difference(ompi_group_t* group1, ompi_group_t* group2, int ompi_group_difference(ompi_group_t* group1, ompi_group_t* group2,
ompi_group_t **new_group) { ompi_group_t **new_group) {
/* local varibles */ /* local varibles */
int new_group_size, proc1, proc2, found_in_group2, cnt; int new_group_size, proc1, proc2, found_in_group2, cnt;
@ -230,21 +231,22 @@ int ompi_group_difference(ompi_group_t* group1, ompi_group_t* group2,
break; break;
} }
} /* end proc1 loop */ } /* end proc1 loop */
if(found_in_group2) if(found_in_group2) {
continue; continue;
}
new_group_size++; new_group_size++;
} /* end proc loop */ } /* end proc loop */
if ( 0 == new_group_size ) { if ( 0 == new_group_size ) {
*new_group = MPI_GROUP_EMPTY; *new_group = MPI_GROUP_EMPTY;
OBJ_RETAIN(MPI_GROUP_EMPTY); OBJ_RETAIN(MPI_GROUP_EMPTY);
return MPI_SUCCESS; return MPI_SUCCESS;
} }
/* allocate a new ompi_group_t structure */ /* allocate a new ompi_group_t structure */
new_group_pointer=ompi_group_allocate(new_group_size); new_group_pointer=ompi_group_allocate(new_group_size);
if( NULL == new_group_pointer ) { if( NULL == new_group_pointer ) {
return MPI_ERR_GROUP; return MPI_ERR_GROUP;
} }
/* fill in group list */ /* fill in group list */
@ -261,11 +263,12 @@ int ompi_group_difference(ompi_group_t* group1, ompi_group_t* group2,
break; break;
} }
} /* end proc1 loop */ } /* end proc1 loop */
if(found_in_group2) if(found_in_group2) {
continue; continue;
}
new_group_pointer->grp_proc_pointers[cnt] = new_group_pointer->grp_proc_pointers[cnt] =
ompi_group_peer_lookup(group1_pointer,proc1); ompi_group_peer_lookup(group1_pointer,proc1);
cnt++; cnt++;
} /* end proc loop */ } /* end proc loop */
@ -276,24 +279,23 @@ int ompi_group_difference(ompi_group_t* group1, ompi_group_t* group2,
/* find my rank */ /* find my rank */
my_group_rank=group1_pointer->grp_my_rank; my_group_rank=group1_pointer->grp_my_rank;
if ( MPI_UNDEFINED != my_group_rank ) { if ( MPI_UNDEFINED != my_group_rank ) {
my_proc_pointer = ompi_group_peer_lookup(group1_pointer,my_group_rank); my_proc_pointer = ompi_group_peer_lookup(group1_pointer,my_group_rank);
} }
else { else {
my_group_rank=group2_pointer->grp_my_rank; my_group_rank=group2_pointer->grp_my_rank;
if ( MPI_UNDEFINED != my_group_rank ) { if ( MPI_UNDEFINED != my_group_rank ) {
my_proc_pointer = ompi_group_peer_lookup(group2_pointer,my_group_rank); my_proc_pointer = ompi_group_peer_lookup(group2_pointer,my_group_rank);
} }
} }
if ( MPI_UNDEFINED == my_group_rank ) { if ( MPI_UNDEFINED == my_group_rank ) {
new_group_pointer->grp_my_rank = MPI_UNDEFINED; new_group_pointer->grp_my_rank = MPI_UNDEFINED;
} }
else { else {
ompi_set_group_rank(new_group_pointer,my_proc_pointer); ompi_set_group_rank(new_group_pointer,my_proc_pointer);
} }
*new_group = (MPI_Group)new_group_pointer; *new_group = (MPI_Group)new_group_pointer;
return OMPI_SUCCESS; return OMPI_SUCCESS;
} }

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

@ -27,88 +27,92 @@ int ompi_group_calc_sporadic ( int n , int *ranks)
{ {
int i,l=0; int i,l=0;
for (i=0 ; i<n ; i++) { for (i=0 ; i<n ; i++) {
if(ranks[i] == ranks[i-1]+1) { if(ranks[i] == ranks[i-1]+1) {
if(l==0) l++; if(l==0) {
} l++;
else l++; }
}
else {
l++;
}
} }
return sizeof(struct ompi_group_sporadic_list_t ) * l; return sizeof(struct ompi_group_sporadic_list_t ) * l;
} }
/* from parent group to child group*/ /* from parent group to child group*/
int ompi_group_translate_ranks_sporadic ( ompi_group_t *parent_group, int ompi_group_translate_ranks_sporadic ( ompi_group_t *parent_group,
int n_ranks, int *ranks1, int n_ranks, int *ranks1,
ompi_group_t *child_group, ompi_group_t *child_group,
int *ranks2) int *ranks2)
{ {
int i,count,j; int i,count,j;
for (j=0 ; j<n_ranks ; j++) { for (j=0 ; j<n_ranks ; j++) {
if (MPI_PROC_NULL == ranks1[j]) { if (MPI_PROC_NULL == ranks1[j]) {
ranks2[j] = MPI_PROC_NULL; ranks2[j] = MPI_PROC_NULL;
} }
else { else {
/* /*
* if the rank is in the current range of the sporadic list, we calculate * if the rank is in the current range of the sporadic list, we calculate
* the rank in the child by adding the length of all ranges that we passed * the rank in the child by adding the length of all ranges that we passed
* and the position in the current range * and the position in the current range
*/ */
ranks2[j] = MPI_UNDEFINED; ranks2[j] = MPI_UNDEFINED;
count = 0; count = 0;
for(i=0 ; i <child_group->sparse_data.grp_sporadic.grp_sporadic_list_len ; i++) { for(i=0 ; i <child_group->sparse_data.grp_sporadic.grp_sporadic_list_len ; i++) {
if( child_group->sparse_data.grp_sporadic.grp_sporadic_list[i].rank_first if( child_group->sparse_data.grp_sporadic.grp_sporadic_list[i].rank_first
<= ranks1[j] && ranks1[j] <= <= ranks1[j] && ranks1[j] <=
child_group->sparse_data.grp_sporadic.grp_sporadic_list[i].rank_first + child_group->sparse_data.grp_sporadic.grp_sporadic_list[i].rank_first +
child_group->sparse_data.grp_sporadic.grp_sporadic_list[i].length -1 ) { child_group->sparse_data.grp_sporadic.grp_sporadic_list[i].length -1 ) {
ranks2[j] = ranks1[j] - child_group-> ranks2[j] = ranks1[j] - child_group->
sparse_data.grp_sporadic.grp_sporadic_list[i].rank_first + count; sparse_data.grp_sporadic.grp_sporadic_list[i].rank_first + count;
break; break;
} }
else { else {
count = count + child_group->sparse_data.grp_sporadic.grp_sporadic_list[i].length; count = count + child_group->sparse_data.grp_sporadic.grp_sporadic_list[i].length;
} }
} }
} }
} }
return OMPI_SUCCESS; return OMPI_SUCCESS;
} }
/* from child group to parent group*/ /* from child group to parent group*/
int ompi_group_translate_ranks_sporadic_reverse ( ompi_group_t *child_group, int ompi_group_translate_ranks_sporadic_reverse ( ompi_group_t *child_group,
int n_ranks, int *ranks1, int n_ranks, int *ranks1,
ompi_group_t *parent_group, ompi_group_t *parent_group,
int *ranks2) int *ranks2)
{ {
int i,j,count; int i,j,count;
for (j=0 ; j<n_ranks ; j++) { for (j=0 ; j<n_ranks ; j++) {
if (MPI_PROC_NULL == ranks1[j]) { if (MPI_PROC_NULL == ranks1[j]) {
ranks2[j] = MPI_PROC_NULL; ranks2[j] = MPI_PROC_NULL;
} }
else { else {
count = 0; count = 0;
/* /*
* if the rank of the child is in the current range, the rank of the parent will be * if the rank of the child is in the current range, the rank of the parent will be
* the position in the current range of the sporadic list * the position in the current range of the sporadic list
*/ */
for (i=0 ; i<child_group->sparse_data.grp_sporadic.grp_sporadic_list_len ; i++) { for (i=0 ; i<child_group->sparse_data.grp_sporadic.grp_sporadic_list_len ; i++) {
if ( ranks1[j] > ( count + if ( ranks1[j] > ( count +
child_group->sparse_data.grp_sporadic.grp_sporadic_list[i].length child_group->sparse_data.grp_sporadic.grp_sporadic_list[i].length
- 1) ) { - 1) ) {
count = count + child_group->sparse_data.grp_sporadic.grp_sporadic_list[i].length; count = count + child_group->sparse_data.grp_sporadic.grp_sporadic_list[i].length;
} }
else { else {
ranks2[j] = child_group->sparse_data.grp_sporadic.grp_sporadic_list[i].rank_first ranks2[j] = child_group->sparse_data.grp_sporadic.grp_sporadic_list[i].rank_first
+ (ranks1[j] - count); + (ranks1[j] - count);
break; break;
} }
} }
} }
} }
return OMPI_SUCCESS; return OMPI_SUCCESS;
} }
int ompi_group_incl_spor(ompi_group_t* group, int n, int *ranks, int ompi_group_incl_spor(ompi_group_t* group, int n, int *ranks,
ompi_group_t **new_group) ompi_group_t **new_group)
{ {
/* local variables */ /* local variables */
int my_group_rank,l,i,j,proc_count; int my_group_rank,l,i,j,proc_count;
@ -117,9 +121,9 @@ int ompi_group_incl_spor(ompi_group_t* group, int n, int *ranks,
group_pointer = (ompi_group_t *)group; group_pointer = (ompi_group_t *)group;
if (0 == n) { if (0 == n) {
*new_group = MPI_GROUP_EMPTY; *new_group = MPI_GROUP_EMPTY;
OBJ_RETAIN(MPI_GROUP_EMPTY); OBJ_RETAIN(MPI_GROUP_EMPTY);
return OMPI_SUCCESS; return OMPI_SUCCESS;
} }
l=0; l=0;
@ -127,15 +131,19 @@ int ompi_group_incl_spor(ompi_group_t* group, int n, int *ranks,
proc_count = 0; proc_count = 0;
for(i=0 ; i<n ; i++){ for(i=0 ; i<n ; i++){
if(ranks[i] == ranks[i-1]+1) { if(ranks[i] == ranks[i-1]+1) {
if(l==0) l++; if(l==0) {
} l++;
else l++; }
}
else {
l++;
}
} }
new_group_pointer = ompi_group_allocate_sporadic(l); new_group_pointer = ompi_group_allocate_sporadic(l);
if( NULL == new_group_pointer ) { if( NULL == new_group_pointer ) {
return MPI_ERR_GROUP; return MPI_ERR_GROUP;
} }
new_group_pointer -> new_group_pointer ->
@ -144,16 +152,16 @@ int ompi_group_incl_spor(ompi_group_t* group, int n, int *ranks,
sparse_data.grp_sporadic.grp_sporadic_list[j].length = 1; sparse_data.grp_sporadic.grp_sporadic_list[j].length = 1;
for(i=1 ; i<n ; i++){ for(i=1 ; i<n ; i++){
if(ranks[i] == ranks[i-1]+1) { if(ranks[i] == ranks[i-1]+1) {
new_group_pointer -> sparse_data.grp_sporadic.grp_sporadic_list[j].length ++; new_group_pointer -> sparse_data.grp_sporadic.grp_sporadic_list[j].length ++;
} }
else { else {
j++; j++;
new_group_pointer -> new_group_pointer ->
sparse_data.grp_sporadic.grp_sporadic_list[j].rank_first = ranks[i]; sparse_data.grp_sporadic.grp_sporadic_list[j].rank_first = ranks[i];
new_group_pointer -> new_group_pointer ->
sparse_data.grp_sporadic.grp_sporadic_list[j].length = 1; sparse_data.grp_sporadic.grp_sporadic_list[j].length = 1;
} }
} }
new_group_pointer->sparse_data.grp_sporadic.grp_sporadic_list_len = j+1; new_group_pointer->sparse_data.grp_sporadic.grp_sporadic_list_len = j+1;

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

@ -27,54 +27,54 @@ static int check_stride(int[],int);
int ompi_group_calc_strided ( int n , int *ranks ) { int ompi_group_calc_strided ( int n , int *ranks ) {
if(-1 == check_stride(ranks,n)) { if(-1 == check_stride(ranks,n)) {
return -1; return -1;
} }
else { else {
return (sizeof(int)*3); return (sizeof(int)*3);
} }
} }
/* from parent group to child group*/ /* from parent group to child group*/
int ompi_group_translate_ranks_strided (ompi_group_t *parent_group, int ompi_group_translate_ranks_strided (ompi_group_t *parent_group,
int n_ranks, int *ranks1, int n_ranks, int *ranks1,
ompi_group_t *child_group, ompi_group_t *child_group,
int *ranks2) int *ranks2)
{ {
int s,o,l,i; int s,o,l,i;
s = child_group->sparse_data.grp_strided.grp_strided_stride; s = child_group->sparse_data.grp_strided.grp_strided_stride;
o = child_group->sparse_data.grp_strided.grp_strided_offset; o = child_group->sparse_data.grp_strided.grp_strided_offset;
l = child_group->sparse_data.grp_strided.grp_strided_last_element; l = child_group->sparse_data.grp_strided.grp_strided_last_element;
for (i = 0; i < n_ranks; i++) { for (i = 0; i < n_ranks; i++) {
if ( MPI_PROC_NULL == ranks1[i]) { if ( MPI_PROC_NULL == ranks1[i]) {
ranks2[i] = MPI_PROC_NULL; ranks2[i] = MPI_PROC_NULL;
} }
else { else {
ranks2[i] = MPI_UNDEFINED; ranks2[i] = MPI_UNDEFINED;
if ( (ranks1[i]-o) >= 0 && (ranks1[i]-o)%s == 0 && ranks1[i] <= l) { if ( (ranks1[i]-o) >= 0 && (ranks1[i]-o)%s == 0 && ranks1[i] <= l) {
ranks2[i] = (ranks1[i] - o)/s; ranks2[i] = (ranks1[i] - o)/s;
} }
} }
} }
return OMPI_SUCCESS; return OMPI_SUCCESS;
} }
/* from child group to parent group*/ /* from child group to parent group*/
int ompi_group_translate_ranks_strided_reverse (ompi_group_t *child_group, int ompi_group_translate_ranks_strided_reverse (ompi_group_t *child_group,
int n_ranks, int *ranks1, int n_ranks, int *ranks1,
ompi_group_t *parent_group, ompi_group_t *parent_group,
int *ranks2) int *ranks2)
{ {
int s,o,i; int s,o,i;
s = child_group->sparse_data.grp_strided.grp_strided_stride; s = child_group->sparse_data.grp_strided.grp_strided_stride;
o = child_group->sparse_data.grp_strided.grp_strided_offset; o = child_group->sparse_data.grp_strided.grp_strided_offset;
for (i = 0; i < n_ranks; i++) { for (i = 0; i < n_ranks; i++) {
if ( MPI_PROC_NULL == ranks1[i]) { if ( MPI_PROC_NULL == ranks1[i]) {
ranks2[i] = MPI_PROC_NULL; ranks2[i] = MPI_PROC_NULL;
} }
else { else {
ranks2[i] =s*ranks1[i] + o; ranks2[i] =s*ranks1[i] + o;
} }
} }
return OMPI_SUCCESS; return OMPI_SUCCESS;
} }
@ -91,14 +91,15 @@ static int check_stride(int incl[],int incllen) {
return -1; return -1;
} }
for(i=0 ; i < incllen-1 ; i++) { for(i=0 ; i < incllen-1 ; i++) {
if(incl[i+1] - incl[i] != s) if(incl[i+1] - incl[i] != s) {
return -1; return -1;
}
} }
return s; return s;
} }
int ompi_group_incl_strided(ompi_group_t* group, int n, int *ranks, int ompi_group_incl_strided(ompi_group_t* group, int n, int *ranks,
ompi_group_t **new_group) ompi_group_t **new_group)
{ {
/* local variables */ /* local variables */
int my_group_rank,stride; int my_group_rank,stride;
@ -107,9 +108,9 @@ int ompi_group_incl_strided(ompi_group_t* group, int n, int *ranks,
group_pointer = (ompi_group_t *)group; group_pointer = (ompi_group_t *)group;
if ( 0 == n ) { if ( 0 == n ) {
*new_group = MPI_GROUP_EMPTY; *new_group = MPI_GROUP_EMPTY;
OBJ_RETAIN(MPI_GROUP_EMPTY); OBJ_RETAIN(MPI_GROUP_EMPTY);
return OMPI_SUCCESS; return OMPI_SUCCESS;
} }
stride = check_stride(ranks,n); stride = check_stride(ranks,n);
@ -130,9 +131,9 @@ int ompi_group_incl_strided(ompi_group_t* group, int n, int *ranks,
ompi_group_increment_proc_count(new_group_pointer); ompi_group_increment_proc_count(new_group_pointer);
my_group_rank = group_pointer->grp_my_rank; my_group_rank = group_pointer->grp_my_rank;
ompi_group_translate_ranks (new_group_pointer->grp_parent_group_ptr,1,&my_group_rank, ompi_group_translate_ranks (new_group_pointer->grp_parent_group_ptr,1,&my_group_rank,
new_group_pointer,&new_group_pointer->grp_my_rank); new_group_pointer,&new_group_pointer->grp_my_rank);
*new_group = (MPI_Group)new_group_pointer; *new_group = (MPI_Group)new_group_pointer;
return OMPI_SUCCESS; return OMPI_SUCCESS;
} }