[MOAB-dev] r5145 - MOAB/trunk/src/parallel

kraftche at cae.wisc.edu kraftche at cae.wisc.edu
Wed Aug 31 16:53:33 CDT 2011


Author: kraftche
Date: 2011-08-31 16:53:33 -0500 (Wed, 31 Aug 2011)
New Revision: 5145

Modified:
   MOAB/trunk/src/parallel/WriteHDF5Parallel.cpp
Log:
Fix bug in WriteHDF5Parallel:

If no process is writing an element type that the root process is not, but
the root process plans to write an element type that one or more other
processes is not aware of then update the type list on other processes
appropriately.  Fixes problem where write fails if root proccess has mesh
but one or more others do not.



Modified: MOAB/trunk/src/parallel/WriteHDF5Parallel.cpp
===================================================================
--- MOAB/trunk/src/parallel/WriteHDF5Parallel.cpp	2011-08-31 20:58:56 UTC (rev 5144)
+++ MOAB/trunk/src/parallel/WriteHDF5Parallel.cpp	2011-08-31 21:53:33 UTC (rev 5145)
@@ -1179,7 +1179,7 @@
     // Build local list of any types that root did not know about
   typelist non_root_types;
   viter = root_types.begin();
-  for (typelist::iterator iter = my_types.begin(); iter != my_types.end(); ++iter) {
+   for (typelist::iterator iter = my_types.begin(); iter != my_types.end(); ++iter) {
     if (viter == root_types.end() || *viter != *iter)
       non_root_types.push_back( *iter );
     else
@@ -1191,61 +1191,66 @@
   int not_done;
   result = MPI_Allreduce( &non_root_count, &not_done, 1, MPI_INT, MPI_LOR, comm );
   CHECK_MPI(result);
-  if (!not_done)
-    return MB_SUCCESS;
-  
-    // Get number of types each processor has that root does not
-  std::vector<int> counts(myPcomm->proc_config().proc_size());
-  int two_count = 2*non_root_count;
-  result = MPI_Gather( &two_count, 1, MPI_INT, &counts[0], 1, MPI_INT, 0, comm );
-  CHECK_MPI(result);
+  if (not_done) {
+      // Get number of types each processor has that root does not
+    std::vector<int> counts(myPcomm->proc_config().proc_size());
+    int two_count = 2*non_root_count;
+    result = MPI_Gather( &two_count, 1, MPI_INT, &counts[0], 1, MPI_INT, 0, comm );
+    CHECK_MPI(result);
 
-    // Get list of types from each processor
-  std::vector<int> displs(myPcomm->proc_config().proc_size() + 1);
-  VALGRIND_MAKE_VEC_UNDEFINED( displs );
-  displs[0] = 0;
-  for (unsigned long i = 1; i <= myPcomm->proc_config().proc_size(); ++i)
-    displs[i] = displs[i-1] + counts[i-1];
-  int total = displs[myPcomm->proc_config().proc_size()];
-  typelist alltypes(total/2);
-  VALGRIND_MAKE_VEC_UNDEFINED( alltypes );
-  VALGRIND_CHECK_MEM_IS_DEFINED( &non_root_types[0], non_root_types.size()*sizeof(int) );
-  result = MPI_Gatherv( &non_root_types[0], 2*non_root_count, MPI_INT,
-                        &alltypes[0], &counts[0], &displs[0], MPI_INT, 0, comm );
-  CHECK_MPI(result);
-  
-    // Merge type lists.
-    // Prefer O(n) insertions with O(ln n) search time because
-    // we expect data from a potentially large number of processes,
-    // but with a small total number of element types.
-  if (0 == myPcomm->proc_config().proc_rank()) {


More information about the moab-dev mailing list