move the implementation of the group creation functions into according back-end
functions. This commit was SVN r9281.
Этот коммит содержится в:
родитель
7ecc505f5c
Коммит
c5a8870f6b
@ -9,6 +9,7 @@
|
|||||||
* University of Stuttgart. All rights reserved.
|
* University of Stuttgart. All rights reserved.
|
||||||
* Copyright (c) 2004-2005 The Regents of the University of California.
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
|
* Copyright (c) 2006 University of Houston. All rights reserved.
|
||||||
* $COPYRIGHT$
|
* $COPYRIGHT$
|
||||||
*
|
*
|
||||||
* Additional copyrights may follow
|
* Additional copyrights may follow
|
||||||
@ -37,12 +38,7 @@ static const char FUNC_NAME[] = "MPI_Group_difference";
|
|||||||
|
|
||||||
int MPI_Group_difference(MPI_Group group1, MPI_Group group2,
|
int MPI_Group_difference(MPI_Group group1, MPI_Group group2,
|
||||||
MPI_Group *new_group) {
|
MPI_Group *new_group) {
|
||||||
|
int err;
|
||||||
/* local varibles */
|
|
||||||
int new_group_size, proc1, proc2, found_in_group2, cnt;
|
|
||||||
int my_group_rank;
|
|
||||||
ompi_group_t *group1_pointer, *group2_pointer, *new_group_pointer;
|
|
||||||
ompi_proc_t *proc1_pointer, *proc2_pointer, *my_proc_pointer = NULL;
|
|
||||||
|
|
||||||
/* error checking */
|
/* error checking */
|
||||||
if( MPI_PARAM_CHECK ) {
|
if( MPI_PARAM_CHECK ) {
|
||||||
@ -54,94 +50,6 @@ int MPI_Group_difference(MPI_Group group1, MPI_Group group2,
|
|||||||
FUNC_NAME);
|
FUNC_NAME);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
err = ompi_group_difference ( group1, group2, new_group );
|
||||||
|
OMPI_ERRHANDLER_RETURN(err, MPI_COMM_WORLD, err, FUNC_NAME );
|
||||||
group1_pointer=(ompi_group_t *)group1;
|
|
||||||
group2_pointer=(ompi_group_t *)group2;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* form union
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* get new group size */
|
|
||||||
new_group_size=0;
|
|
||||||
|
|
||||||
/* 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 */
|
|
||||||
found_in_group2=0;
|
|
||||||
for( proc2=0 ; proc2 < group2_pointer->grp_proc_count ; proc2++ ) {
|
|
||||||
proc2_pointer=group2_pointer->grp_proc_pointers[proc2];
|
|
||||||
if( proc1_pointer == proc2_pointer ) {
|
|
||||||
found_in_group2=true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} /* end proc1 loop */
|
|
||||||
if(found_in_group2)
|
|
||||||
continue;
|
|
||||||
new_group_size++;
|
|
||||||
} /* end proc loop */
|
|
||||||
|
|
||||||
if ( 0 == new_group_size ) {
|
|
||||||
*new_group = MPI_GROUP_EMPTY;
|
|
||||||
OBJ_RETAIN(MPI_GROUP_EMPTY);
|
|
||||||
return MPI_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* allocate a new ompi_group_t structure */
|
|
||||||
new_group_pointer=ompi_group_allocate(new_group_size);
|
|
||||||
if( NULL == new_group_pointer ) {
|
|
||||||
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_GROUP,
|
|
||||||
"MPI_Group_difference - II");
|
|
||||||
}
|
|
||||||
|
|
||||||
/* fill in group list */
|
|
||||||
cnt=0;
|
|
||||||
/* 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 */
|
|
||||||
found_in_group2=0;
|
|
||||||
for( proc2=0 ; proc2 < group2_pointer->grp_proc_count ; proc2++ ) {
|
|
||||||
proc2_pointer=group2_pointer->grp_proc_pointers[proc2];
|
|
||||||
if( proc1_pointer == proc2_pointer ) {
|
|
||||||
found_in_group2=true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} /* end proc1 loop */
|
|
||||||
if(found_in_group2)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
new_group_pointer->grp_proc_pointers[cnt] =
|
|
||||||
group1_pointer->grp_proc_pointers[proc1];
|
|
||||||
|
|
||||||
cnt++;
|
|
||||||
} /* end proc loop */
|
|
||||||
|
|
||||||
/* increment proc reference counters */
|
|
||||||
ompi_group_increment_proc_count(new_group_pointer);
|
|
||||||
|
|
||||||
/* find my rank */
|
|
||||||
my_group_rank=group1_pointer->grp_my_rank;
|
|
||||||
if ( MPI_UNDEFINED != my_group_rank ) {
|
|
||||||
my_proc_pointer=group1_pointer->grp_proc_pointers[my_group_rank];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
my_group_rank=group2_pointer->grp_my_rank;
|
|
||||||
if ( MPI_UNDEFINED != my_group_rank ) {
|
|
||||||
my_proc_pointer=group2_pointer->grp_proc_pointers[my_group_rank];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( MPI_UNDEFINED == my_group_rank ) {
|
|
||||||
new_group_pointer->grp_my_rank = MPI_UNDEFINED;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
ompi_set_group_rank(new_group_pointer,my_proc_pointer);
|
|
||||||
}
|
|
||||||
|
|
||||||
*new_group = (MPI_Group)new_group_pointer;
|
|
||||||
|
|
||||||
return MPI_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
* University of Stuttgart. All rights reserved.
|
* University of Stuttgart. All rights reserved.
|
||||||
* Copyright (c) 2004-2005 The Regents of the University of California.
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
|
* Copyright (c) 2006 University of Houston. All rights reserved.
|
||||||
* $COPYRIGHT$
|
* $COPYRIGHT$
|
||||||
*
|
*
|
||||||
* Additional copyrights may follow
|
* Additional copyrights may follow
|
||||||
@ -36,16 +37,14 @@ static const char FUNC_NAME[] = "MPI_Group_excl";
|
|||||||
|
|
||||||
|
|
||||||
int MPI_Group_excl(MPI_Group group, int n, int *ranks,
|
int MPI_Group_excl(MPI_Group group, int n, int *ranks,
|
||||||
MPI_Group *new_group) {
|
MPI_Group *new_group)
|
||||||
|
{
|
||||||
|
|
||||||
/* local variables */
|
ompi_group_t *group_pointer;
|
||||||
int return_value,proc,i_excl,found,excl_proc,cnt,my_group_rank;
|
|
||||||
ompi_group_t *group_pointer, *new_group_pointer;
|
|
||||||
ompi_proc_t *my_proc_pointer;
|
|
||||||
|
|
||||||
return_value = MPI_SUCCESS;
|
|
||||||
group_pointer = (ompi_group_t *)group;
|
group_pointer = (ompi_group_t *)group;
|
||||||
|
int i, err, group_size;
|
||||||
|
|
||||||
|
group_size = ompi_group_size ( group_pointer);
|
||||||
if( MPI_PARAM_CHECK ) {
|
if( MPI_PARAM_CHECK ) {
|
||||||
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
|
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
|
||||||
|
|
||||||
@ -57,66 +56,29 @@ int MPI_Group_excl(MPI_Group group, int n, int *ranks,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* check that new group is no larger than old group */
|
/* check that new group is no larger than old group */
|
||||||
if ( n > group_pointer->grp_proc_count) {
|
if ( n > group_size) {
|
||||||
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_GROUP,
|
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_GROUP,
|
||||||
FUNC_NAME);
|
FUNC_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* check to see if procs are within range */
|
||||||
|
for( i=0 ; i < n ; i++ ) {
|
||||||
|
if( ( 0 > ranks[i] ) || (ranks[i] >= group_size)){
|
||||||
|
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_RANK,
|
||||||
|
FUNC_NAME );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} /* end if( MPI_CHECK_ARGS) */
|
} /* end if( MPI_CHECK_ARGS) */
|
||||||
|
|
||||||
if ( n == group_pointer->grp_proc_count ) {
|
if ( n == 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
err = ompi_group_excl ( group, n, ranks, new_group );
|
||||||
* pull out elements
|
OMPI_ERRHANDLER_RETURN(err, MPI_COMM_WORLD, err, FUNC_NAME );
|
||||||
*/
|
|
||||||
|
|
||||||
/* get new group struct */
|
|
||||||
new_group_pointer=ompi_group_allocate(group_pointer->grp_proc_count-n);
|
|
||||||
if( NULL == new_group_pointer ) {
|
|
||||||
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_GROUP,
|
|
||||||
FUNC_NAME);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* put group elements in the list */
|
|
||||||
cnt=0;
|
|
||||||
for (proc = 0; proc < group_pointer->grp_proc_count; proc++) {
|
|
||||||
found=0;
|
|
||||||
/* check to see if this proc is in the exclusion list */
|
|
||||||
for( i_excl=0 ; i_excl < n ; ++i_excl ) {
|
|
||||||
excl_proc=ranks[i_excl];
|
|
||||||
/* check to see if this proc is within range */
|
|
||||||
if( ( 0 > excl_proc ) ||
|
|
||||||
(excl_proc >= group_pointer->grp_proc_count)){
|
|
||||||
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_RANK,
|
|
||||||
FUNC_NAME);
|
|
||||||
}
|
|
||||||
if(excl_proc == proc ){
|
|
||||||
found=1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
} /* end i_excl loop */
|
|
||||||
if( !found ) {
|
|
||||||
new_group_pointer->grp_proc_pointers[cnt] =
|
|
||||||
group_pointer->grp_proc_pointers[proc];
|
|
||||||
cnt++;
|
|
||||||
}
|
|
||||||
|
|
||||||
} /* end proc loop */
|
|
||||||
|
|
||||||
/* increment proc reference counters */
|
|
||||||
ompi_group_increment_proc_count(new_group_pointer);
|
|
||||||
|
|
||||||
/* find my rank */
|
|
||||||
my_group_rank=group_pointer->grp_my_rank;
|
|
||||||
my_proc_pointer=group_pointer->grp_proc_pointers[my_group_rank];
|
|
||||||
ompi_set_group_rank(new_group_pointer,my_proc_pointer);
|
|
||||||
|
|
||||||
*new_group = (MPI_Group)new_group_pointer;
|
|
||||||
|
|
||||||
return MPI_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
* University of Stuttgart. All rights reserved.
|
* University of Stuttgart. All rights reserved.
|
||||||
* Copyright (c) 2004-2005 The Regents of the University of California.
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
|
* Copyright (c) 2006 University of Houston. All rights reserved.
|
||||||
* $COPYRIGHT$
|
* $COPYRIGHT$
|
||||||
*
|
*
|
||||||
* Additional copyrights may follow
|
* Additional copyrights may follow
|
||||||
@ -37,12 +38,11 @@ static const char FUNC_NAME[] = "MPI_Group_incl";
|
|||||||
|
|
||||||
int MPI_Group_incl(MPI_Group group, int n, int *ranks, MPI_Group *new_group)
|
int MPI_Group_incl(MPI_Group group, int n, int *ranks, MPI_Group *new_group)
|
||||||
{
|
{
|
||||||
/* local variables */
|
int i, group_size, err;
|
||||||
int proc,my_group_rank;
|
ompi_group_t *group_pointer;
|
||||||
ompi_group_t *group_pointer, *new_group_pointer;
|
|
||||||
ompi_proc_t *my_proc_pointer;
|
|
||||||
|
|
||||||
group_pointer = (ompi_group_t *)group;
|
group_pointer = (ompi_group_t *)group;
|
||||||
|
group_size = ompi_group_size ( group_pointer );
|
||||||
|
|
||||||
if( MPI_PARAM_CHECK ) {
|
if( MPI_PARAM_CHECK ) {
|
||||||
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
|
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
|
||||||
@ -55,49 +55,25 @@ int MPI_Group_incl(MPI_Group group, int n, int *ranks, MPI_Group *new_group)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* check that new group is no larger than old group */
|
/* check that new group is no larger than old group */
|
||||||
if ( n > group_pointer->grp_proc_count) {
|
if ( n > group_size ) {
|
||||||
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_RANK,
|
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_RANK,
|
||||||
FUNC_NAME);
|
FUNC_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < n; i++) {
|
||||||
|
if ((ranks[i] < 0) || (ranks[i] >= group_size)){
|
||||||
|
return OMPI_ERRHANDLER_INVOKE (MPI_COMM_WORLD, MPI_ERR_RANK,
|
||||||
|
FUNC_NAME);
|
||||||
|
}
|
||||||
|
}
|
||||||
} /* end if( MPI_CHECK_ARGS) */
|
} /* end if( MPI_CHECK_ARGS) */
|
||||||
|
|
||||||
|
|
||||||
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 MPI_SUCCESS;
|
return MPI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get new group struct */
|
err = ompi_group_incl(group,n,ranks,new_group);
|
||||||
new_group_pointer=ompi_group_allocate(n);
|
OMPI_ERRHANDLER_RETURN(err, MPI_COMM_WORLD,err,FUNC_NAME);
|
||||||
if( NULL == new_group_pointer ) {
|
|
||||||
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_GROUP,
|
|
||||||
FUNC_NAME);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* put group elements in the list */
|
|
||||||
for (proc = 0; proc < n; proc++) {
|
|
||||||
if ((ranks[proc] < 0) ||
|
|
||||||
(ranks[proc] >= group_pointer->grp_proc_count)){
|
|
||||||
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_RANK,
|
|
||||||
FUNC_NAME);
|
|
||||||
}
|
|
||||||
|
|
||||||
new_group_pointer->grp_proc_pointers[proc] =
|
|
||||||
group_pointer->grp_proc_pointers[ranks[proc]];
|
|
||||||
|
|
||||||
} /* end proc loop */
|
|
||||||
|
|
||||||
/* increment proc reference counters */
|
|
||||||
ompi_group_increment_proc_count(new_group_pointer);
|
|
||||||
|
|
||||||
/* find my rank */
|
|
||||||
my_group_rank=group_pointer->grp_my_rank;
|
|
||||||
my_proc_pointer=group_pointer->grp_proc_pointers[my_group_rank];
|
|
||||||
ompi_set_group_rank(new_group_pointer,my_proc_pointer);
|
|
||||||
|
|
||||||
*new_group = (MPI_Group)new_group_pointer;
|
|
||||||
|
|
||||||
return MPI_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
* University of Stuttgart. All rights reserved.
|
* University of Stuttgart. All rights reserved.
|
||||||
* Copyright (c) 2004-2005 The Regents of the University of California.
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
|
* Copyright (c) 2006 University of Houston. All rights reserved.
|
||||||
* $COPYRIGHT$
|
* $COPYRIGHT$
|
||||||
*
|
*
|
||||||
* Additional copyrights may follow
|
* Additional copyrights may follow
|
||||||
@ -38,11 +39,7 @@ static const char FUNC_NAME[] = "MPI_Group_intersection";
|
|||||||
int MPI_Group_intersection(MPI_Group group1, MPI_Group group2,
|
int MPI_Group_intersection(MPI_Group group1, MPI_Group group2,
|
||||||
MPI_Group *new_group)
|
MPI_Group *new_group)
|
||||||
{
|
{
|
||||||
/* local variables */
|
int err;
|
||||||
int my_group_rank;
|
|
||||||
int group_size,proc1,proc2,cnt;
|
|
||||||
ompi_group_t *group1_pointer, *group2_pointer, *new_group_pointer;
|
|
||||||
ompi_proc_t *proc1_pointer, *proc2_pointer, *my_proc_pointer = NULL;
|
|
||||||
|
|
||||||
if ( MPI_PARAM_CHECK ) {
|
if ( MPI_PARAM_CHECK ) {
|
||||||
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
|
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
|
||||||
@ -55,82 +52,6 @@ int MPI_Group_intersection(MPI_Group group1, MPI_Group group2,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
group1_pointer=(ompi_group_t *)group1;
|
err = ompi_group_intersection ( group1, group2, new_group );
|
||||||
group2_pointer=(ompi_group_t *)group2;
|
OMPI_ERRHANDLER_RETURN(err, MPI_COMM_WORLD, err, FUNC_NAME );
|
||||||
|
|
||||||
/*
|
|
||||||
* form intersection
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* figure out how large the intersection is */
|
|
||||||
group_size = 0;
|
|
||||||
/* 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 ) {
|
|
||||||
group_size++;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} /* end proc2 loop */
|
|
||||||
} /* end proc1 loop */
|
|
||||||
|
|
||||||
if ( 0 == group_size ) {
|
|
||||||
*new_group = MPI_GROUP_EMPTY;
|
|
||||||
OBJ_RETAIN(MPI_GROUP_EMPTY);
|
|
||||||
return MPI_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* fill in new group */
|
|
||||||
new_group_pointer=ompi_group_allocate(group_size);
|
|
||||||
if( NULL == new_group_pointer ) {
|
|
||||||
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_GROUP,
|
|
||||||
FUNC_NAME);
|
|
||||||
}
|
|
||||||
|
|
||||||
cnt = 0;
|
|
||||||
|
|
||||||
/* 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 */
|
|
||||||
|
|
||||||
/* increment proc reference counters */
|
|
||||||
ompi_group_increment_proc_count(new_group_pointer);
|
|
||||||
|
|
||||||
/* find my rank */
|
|
||||||
my_group_rank=group1_pointer->grp_my_rank;
|
|
||||||
if ( MPI_UNDEFINED != my_group_rank ) {
|
|
||||||
my_proc_pointer=group1_pointer->grp_proc_pointers[my_group_rank];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
my_group_rank=group2_pointer->grp_my_rank;
|
|
||||||
if ( MPI_UNDEFINED != my_group_rank ) {
|
|
||||||
my_proc_pointer=group2_pointer->grp_proc_pointers[my_group_rank];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( MPI_UNDEFINED == my_group_rank ) {
|
|
||||||
new_group_pointer->grp_my_rank = MPI_UNDEFINED;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
ompi_set_group_rank(new_group_pointer,my_proc_pointer);
|
|
||||||
}
|
|
||||||
|
|
||||||
*new_group = (MPI_Group)new_group_pointer;
|
|
||||||
|
|
||||||
return MPI_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
* University of Stuttgart. All rights reserved.
|
* University of Stuttgart. All rights reserved.
|
||||||
* Copyright (c) 2004-2005 The Regents of the University of California.
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
|
* Copyright (c) 2006 University of Houston. All rights reserved.
|
||||||
* $COPYRIGHT$
|
* $COPYRIGHT$
|
||||||
*
|
*
|
||||||
* Additional copyrights may follow
|
* Additional copyrights may follow
|
||||||
@ -38,150 +39,43 @@ static const char FUNC_NAME[] = "MPI_Group_range_excl";
|
|||||||
int MPI_Group_range_excl(MPI_Group group, int n_triplets, int ranges[][3],
|
int MPI_Group_range_excl(MPI_Group group, int n_triplets, int ranges[][3],
|
||||||
MPI_Group *new_group)
|
MPI_Group *new_group)
|
||||||
{
|
{
|
||||||
/* local variables */
|
int err, i, group_size;
|
||||||
int new_group_size, proc, first_rank, last_rank;
|
|
||||||
int stride, triplet, index, *elements_int_list, my_group_rank;
|
|
||||||
ompi_group_t *group_pointer, *new_group_pointer;
|
|
||||||
ompi_proc_t *my_proc_pointer;
|
|
||||||
|
|
||||||
group_pointer=(ompi_group_t *)group;
|
|
||||||
|
group_size = ompi_group_size ( group );
|
||||||
|
|
||||||
/* can't act on NULL group */
|
/* can't act on NULL group */
|
||||||
if( MPI_PARAM_CHECK ) {
|
if( MPI_PARAM_CHECK ) {
|
||||||
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
|
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
|
||||||
|
|
||||||
if ( (MPI_GROUP_NULL == group) || (NULL == group) ) {
|
if ( (MPI_GROUP_NULL == group) || (NULL == group) ) {
|
||||||
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_GROUP,
|
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_GROUP,
|
||||||
FUNC_NAME);
|
FUNC_NAME);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
for (i = 0; i < n_triplets; i++) {
|
||||||
* pull out elements
|
if ((0 > ranges[i][0]) || (ranges[i][0] > group_size )) {
|
||||||
*/
|
|
||||||
elements_int_list = (int *)
|
|
||||||
malloc(sizeof(int) * group_pointer->grp_proc_count);
|
|
||||||
if (NULL == elements_int_list) {
|
|
||||||
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_OTHER,
|
|
||||||
FUNC_NAME);
|
|
||||||
}
|
|
||||||
for (proc = 0; proc < group_pointer->grp_proc_count; proc++) {
|
|
||||||
elements_int_list[proc] = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* loop over triplet */
|
|
||||||
new_group_size = 0;
|
|
||||||
for (triplet = 0; triplet < n_triplets; triplet++) {
|
|
||||||
first_rank = ranges[triplet][0];
|
|
||||||
last_rank = ranges[triplet][1];
|
|
||||||
stride = ranges[triplet][2];
|
|
||||||
|
|
||||||
/* check for error conditions */
|
|
||||||
if ((0 > first_rank) || (first_rank > group_pointer->grp_proc_count)) {
|
|
||||||
free(elements_int_list);
|
|
||||||
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_RANK,
|
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_RANK,
|
||||||
FUNC_NAME);
|
FUNC_NAME);
|
||||||
}
|
}
|
||||||
if ((0 > last_rank) || (last_rank > group_pointer->grp_proc_count)) {
|
if ((0 > ranges[i][1]) || (ranges[i][1] > group_size )) {
|
||||||
free(elements_int_list);
|
|
||||||
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_RANK,
|
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_RANK,
|
||||||
FUNC_NAME);
|
FUNC_NAME);
|
||||||
}
|
}
|
||||||
if (stride == 0) {
|
if (ranges[i][2] == 0) {
|
||||||
free(elements_int_list);
|
|
||||||
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_RANK,
|
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_RANK,
|
||||||
FUNC_NAME);
|
FUNC_NAME);
|
||||||
}
|
}
|
||||||
if (first_rank < last_rank) {
|
if ( (ranges[i][0] < ranges[i][1]) && ( ranges[i][2] < 0)) {
|
||||||
if (stride < 0) {
|
|
||||||
free(elements_int_list);
|
|
||||||
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_RANK,
|
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_RANK,
|
||||||
FUNC_NAME);
|
FUNC_NAME);
|
||||||
}
|
}
|
||||||
|
if ( (ranges[i][0] > ranges[i][1]) && (ranges[i][2] > 0)) {
|
||||||
/* positive stride */
|
|
||||||
for (index = first_rank; index <= last_rank; index += stride) {
|
|
||||||
/* make sure rank has not already been selected */
|
|
||||||
if (elements_int_list[index] != -1) {
|
|
||||||
free(elements_int_list);
|
|
||||||
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_RANK,
|
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_RANK,
|
||||||
FUNC_NAME);
|
FUNC_NAME);
|
||||||
}
|
}
|
||||||
elements_int_list[index] = new_group_size;
|
}
|
||||||
new_group_size++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (first_rank > last_rank) {
|
err = ompi_group_range_excl(group,n_triplets,ranges,new_group);
|
||||||
|
OMPI_ERRHANDLER_RETURN(err, MPI_COMM_WORLD,err,FUNC_NAME);
|
||||||
if (stride > 0) {
|
|
||||||
free(elements_int_list);
|
|
||||||
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_RANK,
|
|
||||||
FUNC_NAME);
|
|
||||||
}
|
|
||||||
/* negative stride */
|
|
||||||
for (index = first_rank; index >= last_rank; index += stride) {
|
|
||||||
/* make sure rank has not already been selected */
|
|
||||||
if (elements_int_list[index] != -1) {
|
|
||||||
free(elements_int_list);
|
|
||||||
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_RANK,
|
|
||||||
FUNC_NAME);
|
|
||||||
}
|
|
||||||
elements_int_list[index] = new_group_size;
|
|
||||||
new_group_size++;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
/* first_rank == last_rank */
|
|
||||||
index = first_rank;
|
|
||||||
if (elements_int_list[index] != -1) {
|
|
||||||
free(elements_int_list);
|
|
||||||
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_RANK,
|
|
||||||
FUNC_NAME);
|
|
||||||
}
|
|
||||||
elements_int_list[index] = new_group_size;
|
|
||||||
new_group_size++;
|
|
||||||
}
|
|
||||||
} /* end triplet loop */
|
|
||||||
|
|
||||||
/* we have counted the procs to exclude from the list */
|
|
||||||
new_group_size=group_pointer->grp_proc_count-new_group_size;
|
|
||||||
|
|
||||||
if ( 0 == new_group_size ) {
|
|
||||||
*new_group = MPI_GROUP_EMPTY;
|
|
||||||
OBJ_RETAIN(MPI_GROUP_EMPTY);
|
|
||||||
return MPI_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* allocate a new ompi_group_t structure */
|
|
||||||
new_group_pointer=ompi_group_allocate(new_group_size);
|
|
||||||
if( NULL == new_group_pointer ) {
|
|
||||||
free(elements_int_list);
|
|
||||||
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_GROUP,
|
|
||||||
FUNC_NAME);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* fill in group list */
|
|
||||||
index=0;
|
|
||||||
for (proc = 0; proc < group_pointer->grp_proc_count; proc++) {
|
|
||||||
/* if value == -1, include in the list */
|
|
||||||
if (0 > elements_int_list[proc] ) {
|
|
||||||
new_group_pointer->grp_proc_pointers[index] =
|
|
||||||
group_pointer->grp_proc_pointers[proc];
|
|
||||||
index++;
|
|
||||||
}
|
|
||||||
} /* end of proc loop */
|
|
||||||
|
|
||||||
/* increment proc reference counters */
|
|
||||||
ompi_group_increment_proc_count(new_group_pointer);
|
|
||||||
|
|
||||||
free(elements_int_list);
|
|
||||||
|
|
||||||
/* find my rank */
|
|
||||||
my_group_rank=group_pointer->grp_my_rank;
|
|
||||||
my_proc_pointer=group_pointer->grp_proc_pointers[my_group_rank];
|
|
||||||
ompi_set_group_rank(new_group_pointer,my_proc_pointer);
|
|
||||||
|
|
||||||
*new_group = (MPI_Group)new_group_pointer;
|
|
||||||
|
|
||||||
return MPI_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
* University of Stuttgart. All rights reserved.
|
* University of Stuttgart. All rights reserved.
|
||||||
* Copyright (c) 2004-2005 The Regents of the University of California.
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
|
* Copyright (c) 2006 University of Houston. All rights reserved.
|
||||||
* $COPYRIGHT$
|
* $COPYRIGHT$
|
||||||
*
|
*
|
||||||
* Additional copyrights may follow
|
* Additional copyrights may follow
|
||||||
@ -38,14 +39,10 @@ static const char FUNC_NAME[] = "MPI_Group_range_incl";
|
|||||||
int MPI_Group_range_incl(MPI_Group group, int n_triplets, int ranges[][3],
|
int MPI_Group_range_incl(MPI_Group group, int n_triplets, int ranges[][3],
|
||||||
MPI_Group *new_group)
|
MPI_Group *new_group)
|
||||||
{
|
{
|
||||||
/* local variables */
|
int err, i;
|
||||||
int new_group_size, proc, first_rank, last_rank;
|
int group_size;
|
||||||
int stride, triplet, index, *elements_int_list, my_group_rank;
|
|
||||||
ompi_group_t *group_pointer, *new_group_pointer;
|
|
||||||
ompi_proc_t *my_proc_pointer;
|
|
||||||
|
|
||||||
group_pointer=(ompi_group_t *)group;
|
|
||||||
|
|
||||||
|
group_size = ompi_group_size ( group);
|
||||||
/* can't act on NULL group */
|
/* can't act on NULL group */
|
||||||
if( MPI_PARAM_CHECK ) {
|
if( MPI_PARAM_CHECK ) {
|
||||||
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
|
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
|
||||||
@ -54,134 +51,31 @@ int MPI_Group_range_incl(MPI_Group group, int n_triplets, int ranges[][3],
|
|||||||
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_GROUP,
|
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_GROUP,
|
||||||
FUNC_NAME);
|
FUNC_NAME);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
for ( i=0; i < n_triplets; i++) {
|
||||||
* pull out elements
|
if(( 0 > ranges[i][0] ) || (ranges[i][0] > group_size )) {
|
||||||
*/
|
|
||||||
elements_int_list =
|
|
||||||
(int *) malloc(sizeof(int) * group_pointer->grp_proc_count);
|
|
||||||
if (NULL == elements_int_list) {
|
|
||||||
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_OTHER,
|
|
||||||
FUNC_NAME);
|
|
||||||
}
|
|
||||||
for (proc = 0; proc < group_pointer->grp_proc_count; proc++) {
|
|
||||||
elements_int_list[proc] = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* loop over triplet */
|
|
||||||
new_group_size = 0;
|
|
||||||
for (triplet = 0; triplet < n_triplets; triplet++)
|
|
||||||
{
|
|
||||||
first_rank = ranges[triplet][0];
|
|
||||||
last_rank = ranges[triplet][1];
|
|
||||||
stride = ranges[triplet][2];
|
|
||||||
if(( 0 > first_rank ) || (first_rank > group_pointer->grp_proc_count)) {
|
|
||||||
free(elements_int_list);
|
|
||||||
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_RANK,
|
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_RANK,
|
||||||
FUNC_NAME);
|
FUNC_NAME);
|
||||||
}
|
}
|
||||||
if((0 > last_rank) || (last_rank > group_pointer->grp_proc_count)) {
|
if((0 > ranges[i][1]) || (ranges[i][1] > group_size)) {
|
||||||
free(elements_int_list);
|
|
||||||
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_RANK,
|
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_RANK,
|
||||||
"MPI_Group_range_incl - IV");
|
FUNC_NAME);
|
||||||
}
|
}
|
||||||
if (stride == 0) {
|
if (ranges[i][2] == 0) {
|
||||||
free(elements_int_list);
|
|
||||||
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_RANK,
|
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_RANK,
|
||||||
"MPI_Group_range_incl - V");
|
FUNC_NAME);
|
||||||
}
|
}
|
||||||
if (first_rank < last_rank) {
|
if ( (ranges[i][0] < ranges[i][1]) && (ranges[i][2] < 0)) {
|
||||||
|
|
||||||
if (stride < 0) {
|
|
||||||
free(elements_int_list);
|
|
||||||
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_RANK,
|
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_RANK,
|
||||||
"MPI_Group_range_incl - VI");
|
FUNC_NAME);
|
||||||
}
|
}
|
||||||
|
if ( (ranges[i][0] > ranges[i][1]) && (ranges[i][2] > 0) ){
|
||||||
/* positive stride */
|
|
||||||
index = first_rank;
|
|
||||||
while (index <= last_rank) {
|
|
||||||
/* make sure rank has not already been selected */
|
|
||||||
if (elements_int_list[index] != -1) {
|
|
||||||
free(elements_int_list);
|
|
||||||
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_RANK,
|
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_RANK,
|
||||||
"MPI_Group_range_incl - VII");
|
FUNC_NAME);
|
||||||
}
|
}
|
||||||
elements_int_list[index] = new_group_size;
|
|
||||||
index += stride;
|
|
||||||
new_group_size++;
|
|
||||||
} /* end while loop */
|
|
||||||
|
|
||||||
} else if (first_rank > last_rank) {
|
|
||||||
|
|
||||||
if (stride > 0){
|
|
||||||
free(elements_int_list);
|
|
||||||
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_RANK,
|
|
||||||
"MPI_Group_range_incl - VIII");
|
|
||||||
}
|
|
||||||
|
|
||||||
/* negative stride */
|
|
||||||
index = first_rank;
|
|
||||||
while (index >= last_rank) {
|
|
||||||
/* make sure rank has not already been selected */
|
|
||||||
if (elements_int_list[index] != -1) {
|
|
||||||
free(elements_int_list);
|
|
||||||
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_RANK,
|
|
||||||
"MPI_Group_range_incl - IX");
|
|
||||||
}
|
|
||||||
elements_int_list[index] = new_group_size;
|
|
||||||
index += stride;
|
|
||||||
new_group_size++;
|
|
||||||
} /* end while loop */
|
|
||||||
|
|
||||||
} else { /* first_rank == last_rank */
|
|
||||||
|
|
||||||
index = first_rank;
|
|
||||||
if (elements_int_list[index] != -1) {
|
|
||||||
free(elements_int_list);
|
|
||||||
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_RANK,
|
|
||||||
"MPI_Group_range_incl - X");
|
|
||||||
}
|
|
||||||
elements_int_list[index] = new_group_size;
|
|
||||||
new_group_size++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( 0 == new_group_size ) {
|
err = ompi_group_range_incl ( group, n_triplets, ranges, new_group );
|
||||||
*new_group = MPI_GROUP_EMPTY;
|
OMPI_ERRHANDLER_RETURN(err, MPI_COMM_WORLD, err, FUNC_NAME );
|
||||||
OBJ_RETAIN(MPI_GROUP_EMPTY);
|
|
||||||
return MPI_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* allocate a new ompi_group_t structure */
|
|
||||||
new_group_pointer=ompi_group_allocate(new_group_size);
|
|
||||||
if( NULL == new_group_pointer ) {
|
|
||||||
free(elements_int_list);
|
|
||||||
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_GROUP,
|
|
||||||
"MPI_Group_range_incl - X");
|
|
||||||
}
|
|
||||||
|
|
||||||
/* fill in group list */
|
|
||||||
for (proc = 0; proc < group_pointer->grp_proc_count; proc++) {
|
|
||||||
/* if value >= 0, include in the list */
|
|
||||||
if (0 <= elements_int_list[proc] ) {
|
|
||||||
new_group_pointer->grp_proc_pointers[elements_int_list[proc]] =
|
|
||||||
group_pointer->grp_proc_pointers[proc];
|
|
||||||
}
|
|
||||||
} /* end of proc loop */
|
|
||||||
|
|
||||||
/* increment proc reference counters */
|
|
||||||
ompi_group_increment_proc_count(new_group_pointer);
|
|
||||||
|
|
||||||
free(elements_int_list);
|
|
||||||
|
|
||||||
/* find my rank */
|
|
||||||
my_group_rank=group_pointer->grp_my_rank;
|
|
||||||
my_proc_pointer=group_pointer->grp_proc_pointers[my_group_rank];
|
|
||||||
ompi_set_group_rank(new_group_pointer,my_proc_pointer);
|
|
||||||
|
|
||||||
*new_group = (MPI_Group)new_group_pointer;
|
|
||||||
|
|
||||||
return MPI_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
* University of Stuttgart. All rights reserved.
|
* University of Stuttgart. All rights reserved.
|
||||||
* Copyright (c) 2004-2005 The Regents of the University of California.
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
|
* Copyright (c) 2006 University of Houston. All rights reserved.
|
||||||
* $COPYRIGHT$
|
* $COPYRIGHT$
|
||||||
*
|
*
|
||||||
* Additional copyrights may follow
|
* Additional copyrights may follow
|
||||||
@ -37,11 +38,7 @@ static const char FUNC_NAME[] = "MPI_Group_union";
|
|||||||
|
|
||||||
int MPI_Group_union(MPI_Group group1, MPI_Group group2, MPI_Group *new_group)
|
int MPI_Group_union(MPI_Group group1, MPI_Group group2, MPI_Group *new_group)
|
||||||
{
|
{
|
||||||
/* local variables */
|
int err;
|
||||||
int new_group_size, proc1, proc2, found_in_group;
|
|
||||||
int my_group_rank, cnt;
|
|
||||||
ompi_group_t *group1_pointer, *group2_pointer, *new_group_pointer;
|
|
||||||
ompi_proc_t *proc1_pointer, *proc2_pointer, *my_proc_pointer = NULL;
|
|
||||||
|
|
||||||
/* check for errors */
|
/* check for errors */
|
||||||
if (MPI_PARAM_CHECK) {
|
if (MPI_PARAM_CHECK) {
|
||||||
@ -55,106 +52,6 @@ int MPI_Group_union(MPI_Group group1, MPI_Group group2, MPI_Group *new_group)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
group1_pointer = (ompi_group_t *) group1;
|
err = ompi_group_union ( group1, group2, new_group );
|
||||||
group2_pointer = (ompi_group_t *) group2;
|
OMPI_ERRHANDLER_RETURN(err, MPI_COMM_WORLD, err, FUNC_NAME );
|
||||||
|
|
||||||
/*
|
|
||||||
* form union
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* get new group size */
|
|
||||||
new_group_size = group1_pointer->grp_proc_count;
|
|
||||||
|
|
||||||
/* check group2 elements to see if they need to be included in the list */
|
|
||||||
for (proc2 = 0; proc2 < group2_pointer->grp_proc_count; proc2++) {
|
|
||||||
proc2_pointer = group2_pointer->grp_proc_pointers[proc2];
|
|
||||||
|
|
||||||
/* check to see if this proc2 is alread in the group */
|
|
||||||
found_in_group = 0;
|
|
||||||
for (proc1 = 0; proc1 < group1_pointer->grp_proc_count; proc1++) {
|
|
||||||
proc1_pointer = group1_pointer->grp_proc_pointers[proc1];
|
|
||||||
if (proc1_pointer == proc2_pointer) {
|
|
||||||
/* proc2 is in group1 - don't double count */
|
|
||||||
found_in_group = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} /* end proc1 loop */
|
|
||||||
|
|
||||||
if (found_in_group)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
new_group_size++;
|
|
||||||
} /* end proc loop */
|
|
||||||
|
|
||||||
if ( 0 == new_group_size ) {
|
|
||||||
*new_group = MPI_GROUP_EMPTY;
|
|
||||||
OBJ_RETAIN(MPI_GROUP_EMPTY);
|
|
||||||
return MPI_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* get new group struct */
|
|
||||||
new_group_pointer = ompi_group_allocate(new_group_size);
|
|
||||||
if (NULL == new_group_pointer) {
|
|
||||||
return
|
|
||||||
OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_GROUP,
|
|
||||||
FUNC_NAME);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* fill in the new group list */
|
|
||||||
|
|
||||||
/* put group1 elements in the list */
|
|
||||||
for (proc1 = 0; proc1 < group1_pointer->grp_proc_count; proc1++) {
|
|
||||||
new_group_pointer->grp_proc_pointers[proc1] =
|
|
||||||
group1_pointer->grp_proc_pointers[proc1];
|
|
||||||
}
|
|
||||||
cnt = group1_pointer->grp_proc_count;
|
|
||||||
|
|
||||||
/* check group2 elements to see if they need to be included in the list */
|
|
||||||
for (proc2 = 0; proc2 < group2_pointer->grp_proc_count; proc2++) {
|
|
||||||
proc2_pointer = group2_pointer->grp_proc_pointers[proc2];
|
|
||||||
|
|
||||||
/* check to see if this proc2 is alread in the group */
|
|
||||||
found_in_group = 0;
|
|
||||||
for (proc1 = 0; proc1 < group1_pointer->grp_proc_count; proc1++) {
|
|
||||||
proc1_pointer = group1_pointer->grp_proc_pointers[proc1];
|
|
||||||
if (proc1_pointer == proc2_pointer) {
|
|
||||||
/* proc2 is in group1 - don't double count */
|
|
||||||
found_in_group = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} /* end proc1 loop */
|
|
||||||
|
|
||||||
if (found_in_group)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
new_group_pointer->grp_proc_pointers[cnt] =
|
|
||||||
group2_pointer->grp_proc_pointers[proc2];
|
|
||||||
cnt++;
|
|
||||||
} /* end proc loop */
|
|
||||||
|
|
||||||
/* increment proc reference counters */
|
|
||||||
ompi_group_increment_proc_count(new_group_pointer);
|
|
||||||
|
|
||||||
/* find my rank */
|
|
||||||
my_group_rank = group1_pointer->grp_my_rank;
|
|
||||||
if (MPI_UNDEFINED == my_group_rank) {
|
|
||||||
my_group_rank = group2_pointer->grp_my_rank;
|
|
||||||
if ( MPI_UNDEFINED != my_group_rank) {
|
|
||||||
my_proc_pointer = group2_pointer->grp_proc_pointers[my_group_rank];
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
my_proc_pointer = group1_pointer->grp_proc_pointers[my_group_rank];
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( MPI_UNDEFINED == my_group_rank ) {
|
|
||||||
new_group_pointer->grp_my_rank = MPI_UNDEFINED;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
ompi_set_group_rank(new_group_pointer, my_proc_pointer);
|
|
||||||
}
|
|
||||||
|
|
||||||
*new_group = (MPI_Group) new_group_pointer;
|
|
||||||
|
|
||||||
/* return */
|
|
||||||
return MPI_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user