[MOAB-dev] commit/MOAB: tautges: Merge branch 'tautges/par-owner-fix'

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Fri Nov 15 11:33:56 CST 2013


1 new commit in MOAB:

https://bitbucket.org/fathomteam/moab/commits/ded02f43e94d/
Changeset:   ded02f43e94d
Branch:      master
User:        tautges
Date:        2013-11-15 18:33:46
Summary:     Merge branch 'tautges/par-owner-fix'

Conflicts:
	test/parallel/parallel_unit_tests.cpp

Affected #:  3 files

diff --git a/src/parallel/ParallelComm.cpp b/src/parallel/ParallelComm.cpp
index 8efc777..d92d9b1 100644
--- a/src/parallel/ParallelComm.cpp
+++ b/src/parallel/ParallelComm.cpp
@@ -2093,7 +2093,19 @@ ErrorCode ParallelComm::recv_entities(std::set<unsigned int>& recv_procs,
 
         if (new_h && store_remote_handles) {
           unsigned char new_pstat = 0x0;
-          if (is_iface) new_pstat = PSTATUS_INTERFACE;
+          if (is_iface) {
+            new_pstat = PSTATUS_INTERFACE;
+              // here, lowest rank proc should be first
+            int idx = std::min_element(&ps[0], &ps[0]+num_ps) - &ps[0];
+            if (idx) {
+              std::swap(ps[0], ps[idx]);
+              std::swap(hs[0], hs[idx]);
+            }
+              // set ownership based on lowest rank; can't be in update_remote_data, because
+              // there we don't know whether it resulted from ghosting or not
+            if ((num_ps > 1 && ps[0] != (int) rank()))
+              new_pstat |= PSTATUS_NOT_OWNED;
+          }
           else if (created_here) {
             if (created_iface) new_pstat = PSTATUS_NOT_OWNED;
             else new_pstat = PSTATUS_GHOST | PSTATUS_NOT_OWNED;
@@ -2542,17 +2554,14 @@ ErrorCode ParallelComm::recv_entities(std::set<unsigned int>& recv_procs,
     }
 
       // add myself, if it isn't there already
-    idx = 0;
-    if (new_ps[0] != (int)rank()) {
-      idx = std::find(&new_ps[0], &new_ps[0] + new_numps, rank()) - &new_ps[0];
-      if (idx == new_numps) {
-        new_ps[new_numps] = rank();
-        new_hs[new_numps] = new_h;
-        new_numps++;
-      }
-      else if (!new_hs[idx] && new_numps > 2)
-        new_hs[idx] = new_h;
+    idx = std::find(&new_ps[0], &new_ps[0] + new_numps, rank()) - &new_ps[0];
+    if (idx == new_numps) {
+      new_ps[new_numps] = rank();
+      new_hs[new_numps] = new_h;
+      new_numps++;
     }
+    else if (!new_hs[idx] && new_numps > 2)
+      new_hs[idx] = new_h;
 
       // proc list is complete; update for shared, multishared
     if (new_numps > 1) {
@@ -2560,18 +2569,6 @@ ErrorCode ParallelComm::recv_entities(std::set<unsigned int>& recv_procs,
       new_pstat |= PSTATUS_SHARED;
     }
 
-      // if multishared, not ghost or interface, and not not_owned, I'm owned, and should be the first proc
-    assert(new_ps[idx] == (int)rank());
-    if ((new_numps > 2 && !(new_pstat&(PSTATUS_INTERFACE|PSTATUS_GHOST|PSTATUS_NOT_OWNED))) ||
-        (new_pstat&PSTATUS_INTERFACE && !(new_pstat&PSTATUS_NOT_OWNED))
-        ) {
-      idx = std::min_element(&new_ps[0], &new_ps[0] + new_numps) - &new_ps[0];
-      std::swap(new_ps[0], new_ps[idx]);
-      std::swap(new_hs[0], new_hs[idx]);
-      if (new_ps[0] != (int)rank())
-        new_pstat |= PSTATUS_NOT_OWNED;
-    }
-
 /*    
     plist("new_ps", new_ps, new_numps);
     plist("new_hs", new_hs, new_numps);
@@ -3723,15 +3720,21 @@ ErrorCode ParallelComm::resolve_shared_ents(EntityHandle this_set,
         return result;
       }
     }
-  
-    // get the entities in the partition sets
-    for (Range::iterator rit = partitionSets.begin(); rit != partitionSets.end(); rit++) {
-      Range tmp_ents;
-      result = mbImpl->get_entities_by_handle(*rit, tmp_ents, true);
+
+    if (0 == this_set) {
+        // get the entities in the partition sets
+      for (Range::iterator rit = partitionSets.begin(); rit != partitionSets.end(); rit++) {
+        Range tmp_ents;
+        result = mbImpl->get_entities_by_handle(*rit, tmp_ents, true);
+        if (MB_SUCCESS != result) return result;
+        proc_ents.merge(tmp_ents);
+      }
+    }
+    else {
+      result = mbImpl->get_entities_by_handle(this_set, proc_ents, true);
       if (MB_SUCCESS != result) return result;
-      proc_ents.merge(tmp_ents);
     }
-
+      
     // resolve dim is maximal dim of entities in proc_ents
     if (-1 == resolve_dim) {
       if (proc_ents.empty()) 
@@ -8414,7 +8417,8 @@ ErrorCode ParallelComm::post_irecv(std::vector<unsigned int>& shared_procs,
         continue;
       }
  
-      if (!shents.empty()) check_my_shared_handles(shents);
+      if (!shents.empty()) 
+        result = check_my_shared_handles(shents);
       done = true;
     }
   
@@ -8586,6 +8590,7 @@ ErrorCode ParallelComm::post_irecv(std::vector<unsigned int>& shared_procs,
 
     Range bad_ents, local_shared;
     std::vector<SharedEntityData>::iterator vit;
+    unsigned char tmp_pstat;
     for (unsigned int i = 0; i < shents.size(); i++) {
       int other_proc = buffProcs[i];
       result = get_shared_entities(other_proc, local_shared);
@@ -8596,6 +8601,11 @@ ErrorCode ParallelComm::post_irecv(std::vector<unsigned int>& shared_procs,
         result = get_remote_handles(true, &localh, &dumh, 1, other_proc, dum_vec);
         if (MB_SUCCESS != result || dumh != remoteh) 
           bad_ents.insert(localh);
+        result = get_pstatus(localh, tmp_pstat);
+        if (MB_SUCCESS != result ||
+            (!tmp_pstat&PSTATUS_NOT_OWNED && vit->owner != rank()) ||
+            (tmp_pstat&PSTATUS_NOT_OWNED && vit->owner == rank()))
+          bad_ents.insert(localh);
       }
 
       if (!local_shared.empty()) 
@@ -8603,10 +8613,9 @@ ErrorCode ParallelComm::post_irecv(std::vector<unsigned int>& shared_procs,
     }
   
     if (!bad_ents.empty()) {
-      if (prefix) {
+      if (prefix)
         std::cout << prefix << std::endl;
-        list_entities(bad_ents);
-      }
+      list_entities(bad_ents);
       return MB_FAILURE;
     }
 

diff --git a/test/parallel/parallel_unit_tests.cpp b/test/parallel/parallel_unit_tests.cpp
index 85cc3b8..d2d4c5b 100644
--- a/test/parallel/parallel_unit_tests.cpp
+++ b/test/parallel/parallel_unit_tests.cpp
@@ -1445,12 +1445,11 @@ template <typename T> ErrorCode check_shared_ents(ParallelComm &pcomm, Tag tagh,
   for (rit = shared_ents.begin(); rit != shared_ents.end(); rit++, i++) {
     rval = pcomm.get_sharing_data(*rit, &shprocs[0], &shhandles[0], pstatus, np); CHKERR(rval);
     if (1 == np && shprocs[0] != (int) pcomm.proc_config().proc_rank()) np++;
+    bool with_root = std::find(&shprocs[0], &shprocs[np], 0)-&shprocs[0] != np || !pcomm.rank();
     if      (mpi_op == MPI_SUM) {if (dum_vals[i] != fact*np) return MB_FAILURE;}
     else if (mpi_op == MPI_PROD) {if (dum_vals[i] != pow(fact, np)) return MB_FAILURE;}
-    else if (mpi_op == MPI_MAX) {if (pcomm.rank() && std::find(&shprocs[0],&shprocs[np], 0) != &shprocs[np] &&
-                                     dum_vals[i] != fact) return MB_FAILURE;}
-    else if (mpi_op == MPI_MIN) {if (pcomm.rank() && std::find(&shprocs[0],&shprocs[np], 0) != &shprocs[np] &&
-                                     dum_vals[i] != fact) return MB_FAILURE;}
+    else if (mpi_op == MPI_MAX) {if (with_root && dum_vals[i] != fact) return MB_FAILURE;}
+    else if (mpi_op == MPI_MIN) {if (with_root && dum_vals[i] != fact) return MB_FAILURE;}
     else return MB_FAILURE;
   }
   

diff --git a/test/parallel/structured3.cpp b/test/parallel/structured3.cpp
index 17ad177..daf065b 100644
--- a/test/parallel/structured3.cpp
+++ b/test/parallel/structured3.cpp
@@ -14,6 +14,12 @@ using namespace moab;
  
   // Number of cells in each direction:
 int NC;
+
+/* This mesh creates a box that is NCxNCxNC in global dimension, partitioned among processors
+ * automatically using ScdInterface's SQIJK algorithm.  It checks to make sure there are enough
+ * procs to support this partition method.  After mesh creation, shared vertex resolution is done,
+ * then ghost exchange is done.
+ */
 const int ITERS = 50;
  
 void create_parallel_mesh();
@@ -60,7 +66,7 @@ void create_parallel_mesh()
   times[0] = MPI_Wtime();
   rval = scdi->construct_box(HomCoord(), HomCoord(), NULL, 0, // no vertex positions
                              new_box, NULL, // not locally periodic
-                             &par_data, true, false); // assign global ids & resolve shared verts
+                             &par_data, true, false); // assign global ids, don't resolve shared verts
   CHECK_ERR(rval);
 
     // get global id tag

Repository URL: https://bitbucket.org/fathomteam/moab/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.


More information about the moab-dev mailing list