[MOAB-dev] r3394 - MOAB/trunk/parallel

tautges at mcs.anl.gov tautges at mcs.anl.gov
Thu Dec 3 04:32:19 CST 2009


Author: tautges
Date: 2009-12-03 04:32:18 -0600 (Thu, 03 Dec 2009)
New Revision: 3394

Modified:
   MOAB/trunk/parallel/MBParallelComm.cpp
Log:
Fixing various errors in exchange_tags, most of which I inserted when changing
the buffer implementation.

Filled out body of print_buffer for tag-type messages.

Milad's structured mesh test passes now (haven't checked reported memory leak yet).

Parallel tests all pass except iMeshP tests, which weren't passing before either.

Passes serial make check.



Modified: MOAB/trunk/parallel/MBParallelComm.cpp
===================================================================
--- MOAB/trunk/parallel/MBParallelComm.cpp	2009-12-02 22:29:00 UTC (rev 3393)
+++ MOAB/trunk/parallel/MBParallelComm.cpp	2009-12-03 10:32:18 UTC (rev 3394)
@@ -1609,9 +1609,49 @@
 
   }
   else if (mesg_tag == MB_MESG_TAGS_SIZE || mesg_tag == MB_MESG_TAGS_LARGE) {
-    std::cerr << "Printed as ints: " << std::endl;
-    for (int i = 0; i < msg_length; i+= sizeof(int)) 
-      std::cerr << *((int*)buff_ptr[i]) << std::endl;
+    int num_tags, dum1, num_ents, data_type, tag_size;
+    UNPACK_INT(buff_ptr, num_tags);
+    std::cerr << "Number of tags = " << num_tags << std::endl;
+    for (int i = 0; i < num_tags; i++) {
+      std::cerr << "Tag " << i << ":" << std::endl;
+      UNPACK_INT(buff_ptr, tag_size);
+      UNPACK_INT(buff_ptr, dum1);
+      UNPACK_INT(buff_ptr, data_type);
+      std::cerr << "Tag size, type, data type = " << tag_size << ", " 
+                << dum1 << ", " << data_type << std::endl;
+      UNPACK_INT(buff_ptr, dum1);
+      std::cerr << "Default value size = " << dum1 << std::endl;
+      buff_ptr += dum1;
+      UNPACK_INT(buff_ptr, dum1);
+      std::cerr << "Tag name = " << (char*) buff_ptr << std::endl;
+      buff_ptr += dum1;
+      UNPACK_INT(buff_ptr, num_ents);
+      std::cerr << "Number of ents = " << num_ents << std::endl;
+      unsigned char *tmp_buff = buff_ptr;
+      buff_ptr += num_ents*sizeof(MBEntityHandle);
+      int tot_length = 0;
+      for (int i = 0; i < num_ents; i++) {
+        MBEntityType etype = TYPE_FROM_HANDLE(*((MBEntityHandle*)tmp_buff));
+        std::cerr << MBCN::EntityTypeName(etype) << " " 
+                  << ID_FROM_HANDLE(*((MBEntityHandle*)tmp_buff))
+                  << ", tag = ";
+        if (tag_size == MB_VARIABLE_LENGTH) {
+          UNPACK_INT(buff_ptr, dum1);
+          tot_length += dum1;
+          std::cerr << "(variable, length = " << dum1 << ")" << std::endl;
+        }
+        else if (data_type == MB_TYPE_DOUBLE) std::cerr << *((double*)buff_ptr) << std::endl;
+        else if (data_type == MB_TYPE_INTEGER) std::cerr << *((int*)buff_ptr) << std::endl;
+        else if (data_type == MB_TYPE_OPAQUE) std::cerr << "(opaque)" << std::endl;
+        else if (data_type == MB_TYPE_HANDLE) 
+          std::cerr <<  (MBEntityHandle)*buff_ptr << std::endl;
+        else if (data_type == MB_TYPE_BIT) std::cerr << "(bit)" << std::endl;
+        tmp_buff += sizeof(MBEntityHandle);
+        buff_ptr += tag_size;
+      }
+
+      if (tag_size == MB_VARIABLE_LENGTH) buff_ptr += tot_length;
+    }
   }
   else {
     assert(false);
@@ -2614,10 +2654,15 @@
     int num_ents;
     UNPACK_INT(buff_ptr, num_ents);
     MBEntityHandle *handle_vec = (MBEntityHandle*)buff_ptr;
-    result = get_local_handles(handle_vec, num_ents, entities);
-    RRA("Failed to get local handles for tagged entities.");
     buff_ptr += num_ents * sizeof(MBEntityHandle);
 
+    if (!store_remote_handles) {
+        // in this case handles are indices into new entity range; need to convert
+        // to local handles
+      result = get_local_handles(handle_vec, num_ents, entities);
+      RRA("Unable to convert to local handles.");
+    }
+
       // if it's a handle type, also convert tag vals in-place in buffer
     if (MB_TYPE_HANDLE == tag_type) {
       MBEntityHandle *val_vec = (MBEntityHandle*)buff_ptr;
@@ -4743,6 +4788,10 @@
   MBErrorCode result;
   int success;
 
+#ifdef DEBUG_COMM
+  std::cerr << "Entering exchange_tags" << std::endl; std::cerr.flush();
+#endif
+
     // get all procs interfacing to this proc
   std::set<unsigned int> exch_procs;
   result = get_comm_procs(exch_procs);  
@@ -4765,7 +4814,7 @@
     success = MPI_Irecv(remoteOwnedBuffs[ind]->mem_ptr, INITIAL_BUFF_SIZE,
                         MPI_UNSIGNED_CHAR, *sit,
                         MB_MESG_TAGS_SIZE, procConfig.proc_comm(), 
-                        &recv_tag_reqs[ind]);
+                        &recv_tag_reqs[2*ind]);
     if (success != MPI_SUCCESS) {
       result = MB_FAILURE;
       RRA("Failed to post irecv in ghost exchange.");
@@ -4845,19 +4894,18 @@
     
     bool done = false;
     MBRange dum_range;
-    
     result = recv_buffer(MB_MESG_TAGS_SIZE,
                          status,
                          remoteOwnedBuffs[ind/2],
-                         recv_tag_reqs[ind], recv_tag_reqs[ind+1],
+                         recv_tag_reqs[ind/2 * 2], recv_tag_reqs[ind/2 * 2 + 1],
                          incoming,
-                         localOwnedBuffs[ind/2], sendReqs[ind], sendReqs[ind+1],
+                         localOwnedBuffs[ind/2], sendReqs[ind/2*2], sendReqs[ind/2*2+1],
                          done);
     RRA("Failed to resize recv buffer.");
     if (done) {
-      remoteOwnedBuffs[ind]->reset_ptr(sizeof(int));
-      result = unpack_tags(remoteOwnedBuffs[ind]->buff_ptr,
-                           dum_range, true, buffProcs[ind]);
+      remoteOwnedBuffs[ind/2]->reset_ptr(sizeof(int));
+      result = unpack_tags(remoteOwnedBuffs[ind/2]->buff_ptr,
+                           dum_range, true, buffProcs[ind/2]);
       RRA("Failed to recv-unpack-tag message.");
     }
   }
@@ -4874,6 +4922,10 @@
     RRA("Failure in waitall in tag exchange.");
   }
   
+#ifdef DEBUG_COMM
+  std::cerr << "Exiting exchange_tags" << std::endl; std::cerr.flush();
+#endif
+
   return MB_SUCCESS;
 }
 



More information about the moab-dev mailing list