1
1

clean up the group implementation - remove special code for group_empty,

increment proc reference counts, get rank in group using
lam_set_group_rank.

This commit was SVN r857.
Этот коммит содержится в:
Rich Graham 2004-03-16 01:18:47 +00:00
родитель a7dc6bc338
Коммит 8a88d2e150
7 изменённых файлов: 67 добавлений и 131 удалений

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

@ -21,23 +21,18 @@ int MPI_Group_difference(MPI_Group group1, MPI_Group group2,
lam_group_t *group1_pointer, *group2_pointer, *new_group_pointer;
lam_proc_t *proc1_pointer, *proc2_pointer, *my_proc_pointer;
/* error checking */
if( MPI_PARAM_CHECK ) {
if( (MPI_GROUP_NULL == group1) || (MPI_GROUP_NULL == group1) ) {
return MPI_ERR_GROUP;
}
}
return_value=MPI_SUCCESS;
group1_pointer=(lam_group_t *)group1;
group2_pointer=(lam_group_t *)group2;
/* the difference of an empty group and anything is an empty group */
if (MPI_GROUP_EMPTY == group1 ) {
*new_group = MPI_GROUP_EMPTY;
return MPI_SUCCESS;
}
/* the difference of a group with the empty group is the group itself */
if (MPI_GROUP_EMPTY == group2 ) {
*new_group=group1;
OBJ_RETAIN(group1_pointer);
return MPI_SUCCESS;
}
/*
* form union
*/
@ -62,11 +57,6 @@ int MPI_Group_difference(MPI_Group group1, MPI_Group group2,
new_group_size++;
} /* end proc loop */
if (new_group_size == 0) {
*new_group = MPI_GROUP_EMPTY;
return MPI_SUCCESS;
}
/* allocate a new lam_group_t structure */
new_group_pointer=group_allocate(new_group_size);
if( NULL == new_group_pointer ) {
@ -96,6 +86,9 @@ int MPI_Group_difference(MPI_Group group1, MPI_Group group2,
cnt++;
} /* end proc loop */
/* increment proc reference counters */
lam_group_increment_proc_count(new_group_pointer);
/* find my rank */
my_group_rank=group1_pointer->grp_my_rank;
my_proc_pointer=group1_pointer->grp_proc_pointers[my_group_rank];

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

@ -16,21 +16,16 @@ int MPI_Group_excl(MPI_Group group, int n, int *ranks,
MPI_Group *new_group) {
/* local variables */
int return_value,proc,i_excl,found,excl_proc,cnt;
int return_value,proc,i_excl,found,excl_proc,cnt,my_group_rank;
lam_group_t *group_pointer, *new_group_pointer;
lam_proc_t *my_proc_pointer;
return_value = MPI_SUCCESS;
group_pointer = (lam_group_t *)group;
if( MPI_PARAM_CHECK ) {
/* including anything of the empty group is still the empty group */
if ((group == MPI_GROUP_EMPTY) || (n == 0) ) {
*new_group = MPI_GROUP_EMPTY;
return return_value;
}
/* verify that group is valid group */
if ( NULL == group || NULL == ranks ) {
if ( MPI_GROUP_NULL == group || NULL == ranks ) {
return MPI_ERR_GROUP;
}
@ -41,23 +36,6 @@ int MPI_Group_excl(MPI_Group group, int n, int *ranks,
} /* end if( MPI_CHECK_ARGS) */
// special case: nRanks == 0
// return the current group after incrementing the reference count
if ( n == 0) {
*new_group=group_pointer;
OBJ_RETAIN(group_pointer);
return MPI_SUCCESS;
} else if ( n == group_pointer->grp_proc_count) {
/* special case: nRanks == groupSize
* return the empty group -->
* all ranks must be distinct according to standard
*/
*new_group=MPI_GROUP_EMPTY;
return MPI_SUCCESS;
}
/*
* pull out elements
*/
@ -94,17 +72,13 @@ int MPI_Group_excl(MPI_Group group, int n, int *ranks,
} /* end proc loop */
/* increment proc reference counters */
lam_group_increment_proc_count(new_group_pointer);
/* find my rank */
new_group_pointer->grp_my_rank = MPI_PROC_NULL;
if( MPI_PROC_NULL != group_pointer->grp_my_rank) {
for ( proc=0 ; proc < group_pointer->grp_proc_count-n ; proc++ ){
if( new_group_pointer->grp_proc_pointers[proc] ==
group_pointer->grp_proc_pointers
[group_pointer->grp_my_rank]){
new_group_pointer->grp_my_rank = proc;
}
}
}
my_group_rank=group_pointer->grp_my_rank;
my_proc_pointer=group_pointer->grp_proc_pointers[my_group_rank];
lam_set_group_rank(new_group_pointer,my_proc_pointer);
*new_group = (MPI_Group)new_group_pointer;

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

@ -15,21 +15,17 @@
int MPI_Group_incl(MPI_Group group, int n, int *ranks, MPI_Group *new_group)
{
/* local variables */
int return_value,proc;
int return_value,proc,my_group_rank;
lam_group_t *group_pointer, *new_group_pointer;
lam_proc_t *my_proc_pointer;
return_value = MPI_SUCCESS;
group_pointer = (lam_group_t *)group;
if( MPI_PARAM_CHECK ) {
/* including anything of the empty group is still the empty group */
if ((group == MPI_GROUP_EMPTY) || (n == 0)) {
*new_group = MPI_GROUP_EMPTY;
return return_value;
}
/* verify that group is valid group */
if ( NULL == group || NULL == ranks ) {
if ( MPI_GROUP_NULL == group || NULL == ranks ) {
return MPI_ERR_GROUP;
}
@ -59,17 +55,13 @@ int MPI_Group_incl(MPI_Group group, int n, int *ranks, MPI_Group *new_group)
} /* end proc loop */
/* increment proc reference counters */
lam_group_increment_proc_count(new_group_pointer);
/* find my rank */
new_group_pointer->grp_my_rank = MPI_PROC_NULL;
if( MPI_PROC_NULL != group_pointer->grp_my_rank) {
for ( proc=0 ; proc < n ; proc++ ){
if( new_group_pointer->grp_proc_pointers[proc] ==
group_pointer->grp_proc_pointers
[group_pointer->grp_my_rank]){
new_group_pointer->grp_my_rank = proc;
}
}
}
my_group_rank=group_pointer->grp_my_rank;
my_proc_pointer=group_pointer->grp_proc_pointers[my_group_rank];
lam_set_group_rank(new_group_pointer,my_proc_pointer);
*new_group = (MPI_Group)new_group_pointer;

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

@ -16,30 +16,22 @@ int MPI_Group_intersection(MPI_Group group1, MPI_Group group2,
MPI_Group *new_group) {
/* local variables */
int return_value;
int return_value,my_group_rank;
int group_size,proc,proc1,proc2,cnt;
lam_group_t *group1_pointer, *group2_pointer, *new_group_pointer;
lam_proc_t *proc1_pointer, *proc2_pointer;
lam_proc_t *proc1_pointer, *proc2_pointer, *my_proc_pointer;
/* initialize data */
return_value = MPI_SUCCESS;
/* verify that groups are valid */
if ( (NULL == group1) || (NULL == group2) ) {
if ( (MPI_GROUP_NULL == group1) || (MPI_GROUP_NULL == group2) ) {
return MPI_ERR_GROUP;
}
group1_pointer=(lam_group_t *)group1;
group2_pointer=(lam_group_t *)group2;
/*
* Check for empty group
*/
if ((group1_pointer->grp_proc_count == 0) ||
(group2_pointer->grp_proc_count == 0)) {
*new_group = MPI_GROUP_EMPTY;
}
/*
* form intersection
*/
@ -60,45 +52,35 @@ int MPI_Group_intersection(MPI_Group group1, MPI_Group group2,
} /* end proc2 loop */
} /* end proc1 loop */
if (group_size == 0) {
/* empty group */
*new_group = MPI_GROUP_EMPTY;
} else {
/* fill in new group */
new_group_pointer=group_allocate(group_size);
if( NULL == new_group_pointer ) {
return MPI_ERR_GROUP;
}
/* fill in new group */
new_group_pointer=group_allocate(group_size);
if( NULL == new_group_pointer ) {
return MPI_ERR_GROUP;
}
cnt = 0;
cnt = 0;
/* loop over group1 members */
/* loop over group1 members */
for (proc1 = 0; proc1 < group1_pointer->grp_proc_count; proc1++) {
proc1_pointer=group1_pointer->grp_proc_pointers[proc1];
/* check to see if this proc is in group2 */
for (proc2 = 0; proc2 < group2_pointer->grp_proc_count; proc2++) {
proc2_pointer=group2_pointer->grp_proc_pointers[proc2];
if( proc1_pointer == proc2_pointer ) {
new_group_pointer->grp_proc_pointers[cnt]=proc1_pointer;
cnt++;
break;
}
} /* end proc2 loop */
} /* end proc1 loop */
for (proc1 = 0; proc1 < group1_pointer->grp_proc_count; proc1++) {
proc1_pointer=group1_pointer->grp_proc_pointers[proc1];
/* check to see if this proc is in group2 */
for (proc2 = 0; proc2 < group2_pointer->grp_proc_count; proc2++) {
proc2_pointer=group2_pointer->grp_proc_pointers[proc2];
if( proc1_pointer == proc2_pointer ) {
new_group_pointer->grp_proc_pointers[cnt]=proc1_pointer;
cnt++;
break;
}
} /* end proc2 loop */
} /* end proc1 loop */
} /* end else */
/* increment proc reference counters */
lam_group_increment_proc_count(new_group_pointer);
/* find my rank */
new_group_pointer->grp_my_rank = MPI_PROC_NULL;
if( MPI_PROC_NULL != group1_pointer->grp_my_rank) {
for ( proc=0 ; proc < group_size ; proc++ ){
if( new_group_pointer->grp_proc_pointers[proc] ==
group1_pointer->grp_proc_pointers
[group1_pointer->grp_my_rank]){
new_group_pointer->grp_my_rank = proc;
}
}
}
my_group_rank=group1_pointer->grp_my_rank;
my_proc_pointer=group1_pointer->grp_proc_pointers[my_group_rank];
lam_set_group_rank(new_group_pointer,my_proc_pointer);
*new_group = (MPI_Group)new_group_pointer;

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

@ -119,13 +119,6 @@ int MPI_Group_range_excl(MPI_Group group, int n_triplets, int ranges[][3],
}
} /* end triplet loop */
/* check for empty group */
if( 0 == new_group_size ) {
*new_group = MPI_GROUP_EMPTY;
free(elements_int_list);
return MPI_SUCCESS;
}
/* we have counted the procs to exclude from the list */
new_group_size=group_pointer->grp_proc_count-new_group_size;
@ -147,6 +140,9 @@ int MPI_Group_range_excl(MPI_Group group, int n_triplets, int ranges[][3],
}
} /* end of proc loop */
/* increment proc reference counters */
lam_group_increment_proc_count(new_group_pointer);
free(elements_int_list);
/* find my rank */
@ -156,6 +152,5 @@ int MPI_Group_range_excl(MPI_Group group, int n_triplets, int ranges[][3],
*new_group = (MPI_Group)new_group_pointer;
return MPI_SUCCESS;
}

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

@ -113,13 +113,6 @@ int MPI_Group_range_incl(MPI_Group group, int n_triplets, int ranges[][3],
}
}
/* check for empty group */
if( 0 == new_group_size ) {
*new_group = MPI_GROUP_EMPTY;
free(elements_int_list);
return MPI_SUCCESS;
}
/* allocate a new lam_group_t structure */
new_group_pointer=group_allocate(new_group_size);
if( NULL == new_group_pointer ) {
@ -138,6 +131,9 @@ int MPI_Group_range_incl(MPI_Group group, int n_triplets, int ranges[][3],
}
} /* end of proc loop */
/* increment proc reference counters */
lam_group_increment_proc_count(new_group_pointer);
free(elements_int_list);
/* find my rank */

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

@ -27,7 +27,11 @@ int MPI_Group_translate_ranks(MPI_Group group1, int n_ranks, int *ranks1,
if( (MPI_GROUP_NULL == group1) || (MPI_GROUP_NULL == group2 ) ) {
return MPI_ERR_GROUP;
}
if( n_ranks > group1_pointer->grp_proc_count ){
if( (n_ranks > group1_pointer->grp_proc_count) ||
( 0 >= n_ranks ) ){
return MPI_ERR_GROUP;
}
if( (NULL == ranks1) || (NULL == ranks2 ) ) {
return MPI_ERR_GROUP;
}
}