Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Move group_incl code, to allow use by collective algos or internal calls
authorAugustin Degomme <augustin.degomme@imag.fr>
Fri, 1 Aug 2014 07:36:29 +0000 (09:36 +0200)
committerAugustin Degomme <augustin.degomme@imag.fr>
Fri, 1 Aug 2014 08:51:09 +0000 (10:51 +0200)
src/smpi/private.h
src/smpi/smpi_group.c
src/smpi/smpi_pmpi.c

index 4b3b5f7..b89aa3b 100644 (file)
@@ -232,6 +232,8 @@ int smpi_group_use(MPI_Group group);
 int smpi_group_unuse(MPI_Group group);
 int smpi_group_size(MPI_Group group);
 int smpi_group_compare(MPI_Group group1, MPI_Group group2);
+int smpi_group_incl(MPI_Group group, int n, int* ranks, MPI_Group* newgroup);
+
 
 MPI_Topology smpi_comm_topo(MPI_Comm comm);
 MPI_Comm smpi_comm_new(MPI_Group group, MPI_Topology topo);
index 921f719..e9ab955 100644 (file)
@@ -155,3 +155,25 @@ int smpi_group_compare(MPI_Group group1, MPI_Group group2)
   }
   return result;
 }
+
+int smpi_group_incl(MPI_Group group, int n, int* ranks, MPI_Group* newgroup)
+{
+  int i=0, index=0;
+  if (n == 0) {
+    *newgroup = MPI_GROUP_EMPTY;
+  } else if (n == smpi_group_size(group)) {
+    *newgroup = group;
+    if(group!= smpi_comm_group(MPI_COMM_WORLD)
+              && group != MPI_GROUP_NULL
+              && group != smpi_comm_group(MPI_COMM_SELF)
+              && group != MPI_GROUP_EMPTY)
+    smpi_group_use(group);
+  } else {
+    *newgroup = smpi_group_new(n);
+    for (i = 0; i < n; i++) {
+      index = smpi_group_index(group, ranks[i]);
+      smpi_group_set_mapping(*newgroup, index, i);
+    }
+  }
+  return MPI_SUCCESS;
+}
index d6c2616..9a52cc9 100644 (file)
@@ -478,30 +478,14 @@ int PMPI_Group_difference(MPI_Group group1, MPI_Group group2, MPI_Group * newgro
 
 int PMPI_Group_incl(MPI_Group group, int n, int *ranks, MPI_Group * newgroup)
 {
-  int retval, i, index;
+  int retval;
 
   if (group == MPI_GROUP_NULL) {
     retval = MPI_ERR_GROUP;
   } else if (newgroup == NULL) {
     retval = MPI_ERR_ARG;
   } else {
-    if (n == 0) {
-      *newgroup = MPI_GROUP_EMPTY;
-    } else if (n == smpi_group_size(group)) {
-      *newgroup = group;
-      if(group!= smpi_comm_group(MPI_COMM_WORLD)
-                && group != MPI_GROUP_NULL
-                && group != smpi_comm_group(MPI_COMM_SELF)
-                && group != MPI_GROUP_EMPTY)
-      smpi_group_use(group);
-    } else {
-      *newgroup = smpi_group_new(n);
-      for (i = 0; i < n; i++) {
-        index = smpi_group_index(group, ranks[i]);
-        smpi_group_set_mapping(*newgroup, index, i);
-      }
-    }
-    retval = MPI_SUCCESS;
+    retval = smpi_group_incl(group, n, ranks, newgroup);
   }
   return retval;
 }