Skip to content

Commit 4630c40

Browse files
committed
Abstract MPI_Group_compare to an OMPI function for internal use (point the MPI interface to the internal function).
Fix a typo in group_init.c This commit was SVN r26118.
1 parent a595525 commit 4630c40

File tree

4 files changed

+84
-67
lines changed

4 files changed

+84
-67
lines changed

ompi/group/group.c

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
* All rights reserved.
1212
* Copyright (c) 2006-2007 University of Houston. All rights reserved.
1313
* Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
14+
* Copyright (c) 2012 Oak Ridge National Labs. All rights reserved.
1415
* $COPYRIGHT$
1516
*
1617
* Additional copyrights may follow
@@ -506,3 +507,73 @@ int ompi_group_intersection(ompi_group_t* group1,ompi_group_t* group2,
506507

507508
return result;
508509
}
510+
511+
int ompi_group_compare(ompi_group_t *group1,
512+
ompi_group_t *group2,
513+
int *result)
514+
{
515+
int return_value = OMPI_SUCCESS;
516+
int proc1, proc2, match;
517+
bool similar, identical;
518+
ompi_group_t *group1_pointer, *group2_pointer;
519+
ompi_proc_t *proc1_pointer, *proc2_pointer;
520+
521+
/* check for same groups */
522+
if( group1 == group2 ) {
523+
*result=MPI_IDENT;
524+
return return_value;
525+
}
526+
527+
/* check to see if either is MPI_GROUP_NULL or MPI_GROUP_EMPTY */
528+
if( ( MPI_GROUP_EMPTY == group1 ) || ( MPI_GROUP_EMPTY == group2 ) ) {
529+
*result=MPI_UNEQUAL;
530+
return return_value;
531+
}
532+
533+
/* get group pointers */
534+
group1_pointer = (ompi_group_t *)group1;
535+
group2_pointer = (ompi_group_t *)group2;
536+
537+
/* compare sizes */
538+
if( group1_pointer->grp_proc_count != group2_pointer->grp_proc_count ) {
539+
/* if not same size - return */
540+
*result=MPI_UNEQUAL;
541+
return return_value;
542+
}
543+
544+
/* check for similarity */
545+
/* loop over group1 processes */
546+
similar=true;
547+
identical=true;
548+
for(proc1=0 ; proc1 < group1_pointer->grp_proc_count ; proc1++ ) {
549+
proc1_pointer= ompi_group_peer_lookup(group1_pointer,proc1);
550+
/* loop over group2 processes to find "match" */
551+
match=-1;
552+
for(proc2=0 ; proc2 < group2_pointer->grp_proc_count ; proc2++ ) {
553+
proc2_pointer=ompi_group_peer_lookup(group2_pointer,proc2);
554+
if( proc1_pointer == proc2_pointer ) {
555+
if(proc1 != proc2 ) {
556+
identical=false;
557+
}
558+
match=proc2;
559+
break;
560+
}
561+
} /* end proc2 loop */
562+
if( match== -1 ) {
563+
similar=false;
564+
identical=false;
565+
break;
566+
}
567+
} /* end proc1 loop */
568+
569+
/* set comparison result */
570+
if( identical ) {
571+
*result=MPI_IDENT;
572+
} else if( similar ) {
573+
*result=MPI_SIMILAR;
574+
} else {
575+
*result=MPI_UNEQUAL;
576+
}
577+
578+
return return_value;
579+
}

ompi/group/group.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* Copyright (c) 2006-2007 University of Houston. All rights reserved.
1414
* Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
1515
* Copyright (c) 2009 Sun Microsystems, Inc. All rights reserved.
16+
* Copyright (c) 2012 Oak Ridge National Labs. All rights reserved.
1617
* $COPYRIGHT$
1718
*
1819
* Additional copyrights may follow
@@ -233,6 +234,12 @@ OMPI_DECLSPEC int ompi_group_translate_ranks ( ompi_group_t *group1,
233234
ompi_group_t *group2,
234235
int *ranks2);
235236

237+
/**
238+
* Abstracting MPI_Group_compare to an ompi function for internal use
239+
*/
240+
OMPI_DECLSPEC int ompi_group_compare(ompi_group_t *group1,
241+
ompi_group_t *group2,
242+
int *result);
236243

237244
/**
238245
* Abstracting MPI_Group_free, since it is required by some internal functions...

ompi/group/group_init.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* Copyright (c) 2006-2007 University of Houston. All rights reserved.
1414
* Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
1515
* Copyright (c) 2009 Sun Microsystems, Inc. All rights reserved.
16+
* Copyright (c) 2012 Oak Ridge National Labs. All rights reserved.
1617
* $COPYRIGHT$
1718
*
1819
* Additional copyrights may follow
@@ -321,7 +322,7 @@ int ompi_group_init(void)
321322
ompi_mpi_group_null.group.grp_flags |= OMPI_GROUP_DENSE;
322323
ompi_mpi_group_null.group.grp_flags |= OMPI_GROUP_INTRINSIC;
323324

324-
/* add MPI_GROUP_EMPTRY to table */
325+
/* add MPI_GROUP_EMPTY to table */
325326
OBJ_CONSTRUCT(&ompi_mpi_group_empty, ompi_group_t);
326327
ompi_mpi_group_empty.group.grp_proc_count = 0;
327328
ompi_mpi_group_empty.group.grp_my_rank = MPI_UNDEFINED;

ompi/mpi/c/group_compare.c

Lines changed: 4 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
* All rights reserved.
1212
* Copyright (c) 2006 Cisco Systems, Inc. All rights reserved.
1313
* Copyright (c) 2009 University of Houston. All rights reserved.
14+
* Copyright (c) 2012 Oak Ridge National Labs. All rights reserved.
1415
* $COPYRIGHT$
1516
*
1617
* Additional copyrights may follow
@@ -39,17 +40,7 @@ static const char FUNC_NAME[] = "MPI_Group_compare";
3940

4041

4142
int MPI_Group_compare(MPI_Group group1, MPI_Group group2, int *result) {
42-
43-
/* local variables */
44-
int return_value, proc1, proc2, match;
45-
bool similar, identical;
46-
ompi_group_t *group1_pointer, *group2_pointer;
47-
ompi_proc_t *proc1_pointer, *proc2_pointer;
48-
49-
OPAL_CR_NOOP_PROGRESS();
50-
51-
/* initialization */
52-
return_value=MPI_SUCCESS;
43+
int return_value = MPI_SUCCESS;
5344

5445
/* check for errors */
5546
if( MPI_PARAM_CHECK ) {
@@ -65,62 +56,9 @@ int MPI_Group_compare(MPI_Group group1, MPI_Group group2, int *result) {
6556
}
6657
}
6758

68-
/* check for same groups */
69-
if( group1 == group2 ) {
70-
*result=MPI_IDENT;
71-
return return_value;
72-
}
73-
74-
/* check to see if either is MPI_GROUP_NULL or MPI_GROUP_EMPTY */
75-
if( ( MPI_GROUP_EMPTY == group1 ) || ( MPI_GROUP_EMPTY == group2 ) ) {
76-
*result=MPI_UNEQUAL;
77-
return return_value;
78-
}
79-
80-
/* get group pointers */
81-
group1_pointer = (ompi_group_t *)group1;
82-
group2_pointer = (ompi_group_t *)group2;
83-
84-
/* compare sizes */
85-
if( group1_pointer->grp_proc_count != group2_pointer->grp_proc_count ) {
86-
/* if not same size - return */
87-
*result=MPI_UNEQUAL;
88-
return return_value;
89-
}
90-
91-
/* check for similarity */
92-
/* loop over group1 processes */
93-
similar=true;
94-
identical=true;
95-
for(proc1=0 ; proc1 < group1_pointer->grp_proc_count ; proc1++ ) {
96-
proc1_pointer= ompi_group_peer_lookup(group1_pointer,proc1);
97-
/* loop over group2 processes to find "match" */
98-
match=-1;
99-
for(proc2=0 ; proc2 < group2_pointer->grp_proc_count ; proc2++ ) {
100-
proc2_pointer=ompi_group_peer_lookup(group2_pointer,proc2);
101-
if( proc1_pointer == proc2_pointer ) {
102-
if(proc1 != proc2 ) {
103-
identical=false;
104-
}
105-
match=proc2;
106-
break;
107-
}
108-
} /* end proc2 loop */
109-
if( match== -1 ) {
110-
similar=false;
111-
identical=false;
112-
break;
113-
}
114-
} /* end proc1 loop */
59+
OPAL_CR_NOOP_PROGRESS();
11560

116-
/* set comparison result */
117-
if( identical ) {
118-
*result=MPI_IDENT;
119-
} else if( similar ) {
120-
*result=MPI_SIMILAR;
121-
} else {
122-
*result=MPI_UNEQUAL;
123-
}
61+
return_value = ompi_group_compare((ompi_group_t *)group1, (ompi_group_t *)group2, result);
12462

12563
return return_value;
12664
}

0 commit comments

Comments
 (0)