[MOAB-dev] r1749 - in MOAB/branches/ghosting: . parallel

tautges at mcs.anl.gov tautges at mcs.anl.gov
Mon Apr 7 22:48:29 CDT 2008


Author: tautges
Date: 2008-04-07 22:48:29 -0500 (Mon, 07 Apr 2008)
New Revision: 1749

Modified:
   MOAB/branches/ghosting/mbparallelcomm_test.cpp
   MOAB/branches/ghosting/parallel/MBParallelComm.cpp
   MOAB/branches/ghosting/parallel/WriteHDF5Parallel.cpp
Log:
- better testing of pack_buffer in mbparallelcomm_test (packing all file set ents, not just 3d ones)
- more debug messages for packing/unpacking
- fixed count += error in pack_tags
- removed compile warnings from WriteHDF5Parallel.cpp



Modified: MOAB/branches/ghosting/mbparallelcomm_test.cpp
===================================================================
--- MOAB/branches/ghosting/mbparallelcomm_test.cpp	2008-04-07 21:25:17 UTC (rev 1748)
+++ MOAB/branches/ghosting/mbparallelcomm_test.cpp	2008-04-08 03:48:29 UTC (rev 1749)
@@ -162,7 +162,7 @@
           PRINT_LAST_ERROR
         }
         break;
-        
+
       default:
         std::cerr << "Unrecognized option \"" << this_opt
                   << "\"; skipping." << std::endl;
@@ -712,9 +712,11 @@
   
     // get 3d entities and pack a buffer with them
   MBRange ents, new_ents, whole_range;
-  result = mbImpl->get_entities_by_dimension(0, 3, ents);
+  result = mbImpl->get_entities_by_handle(file_set, ents);
   RRA("Getting 3d ents failed.");
   
+  ents.insert(file_set);
+  
   MBParallelComm *pcomm = new MBParallelComm(mbImpl);
   std::vector<unsigned char> buff(1024);
   int buff_size;

Modified: MOAB/branches/ghosting/parallel/MBParallelComm.cpp
===================================================================
--- MOAB/branches/ghosting/parallel/MBParallelComm.cpp	2008-04-07 21:25:17 UTC (rev 1748)
+++ MOAB/branches/ghosting/parallel/MBParallelComm.cpp	2008-04-08 03:48:29 UTC (rev 1749)
@@ -577,6 +577,7 @@
 
   assert(0 <= buff_size);
   buff.resize(buff_size);
+  int orig_buff_size = buff_size;
   buff_size = 0;
   buff_ptr = &buff[0];
   
@@ -585,12 +586,20 @@
                          buff_size, false, store_remote_handles, to_proc,
                          ent_types, all_ranges, verts_per_entity); 
   RRA("Packing entities (count) failed.");
+#ifdef DEBUG_PACKING
+  std::cerr << "pack_entities buffer space: " << buff_ptr - &buff[0] << " bytes." << std::endl;
+  unsigned char *tmp_buff = buff_ptr;
+#endif  
   
     // sets
   result = pack_sets(orig_ents, rit, final_ents, buff_ptr, buff_size, false,
                      store_remote_handles, to_proc, set_range, set_ranges,
                      set_sizes, options_vec); 
   RRA("Packing sets (count) failed.");
+#ifdef DEBUG_PACKING
+  std::cerr << "pack_sets buffer space: " << buff_ptr - tmp_buff << " bytes." << std::endl;
+  tmp_buff = buff_ptr;
+#endif  
   
     // adjacencies
   if (adjacencies) {
@@ -606,8 +615,19 @@
                        buff_size, false, store_remote_handles, to_proc, all_tags,
                        tag_ranges);
     RRA("Packing tags (count) failed.");
+#ifdef DEBUG_PACKING
+    std::cerr << "pack_tags buffer space: " << buff_ptr - tmp_buff << " bytes." << std::endl;
+    tmp_buff = buff_ptr;
+#endif  
   }
 
+    // original buffer size might be larger, because some
+    // ranges of local handles pack into more compact ranges of
+    // remote handles (because they're expressed using MBMAXTYPE plus
+    // index in new entity range, and that list of entities is likely
+    // to be compact)
+  assert(orig_buff_size >= buff_size);
+
   return result;
 }
  
@@ -618,16 +638,31 @@
 {
   if (myBuffer.capacity() == 0) return MB_FAILURE;
   
+#ifdef DEBUG_PACKING
+    unsigned char *tmp_buff = buff_ptr;
+#endif  
   MBErrorCode result = unpack_entities(buff_ptr, final_ents, 
                                        store_remote_handles,
                                        from_proc);
   RRA("Unpacking entities failed.");
+#ifdef DEBUG_PACKING
+    std::cerr << "unpack_entities buffer space: " << buff_ptr - tmp_buff << " bytes." << std::endl;
+    tmp_buff = buff_ptr;
+#endif  
   result = unpack_sets(buff_ptr, final_ents, store_remote_handles, 
                        from_proc);
   RRA("Unpacking sets failed.");
+#ifdef DEBUG_PACKING
+    std::cerr << "unpack_sets buffer space: " << buff_ptr - tmp_buff << " bytes." << std::endl;
+    tmp_buff = buff_ptr;
+#endif  
   result = unpack_tags(buff_ptr, final_ents, store_remote_handles,
                        from_proc);
   RRA("Unpacking tags failed.");
+#ifdef DEBUG_PACKING
+    std::cerr << "unpack_tags buffer space: " << buff_ptr - tmp_buff << " bytes." << std::endl;
+    tmp_buff = buff_ptr;
+#endif  
 
 #ifdef DEBUG_PACKING
   std::cerr << std::endl;
@@ -1394,8 +1429,7 @@
   MBErrorCode result;
 
   if (just_count) {
-      // num of sets
-    count += sizeof(int);
+    int ranges_size = 0, vecs_size = 0, tot_parch = 0;
     
     for (; start_rit != entities.end(); start_rit++) {
       set_range.insert(*start_rit);
@@ -1405,9 +1439,6 @@
       RR("Failed to get meshset options.");
       options_vec.push_back(options);
 
-        // option
-      count += sizeof(unsigned int);
-    
       if (options & MESHSET_SET) {
           // range-based set; count the subranges
         set_ranges.push_back(MBRange());
@@ -1415,7 +1446,8 @@
         RRA("Failed to get set entities.");
 
           // set range
-        count += 2 * sizeof(MBEntityHandle) * num_subranges(*set_ranges.rbegin()) + sizeof(int);
+        ranges_size += 2 * sizeof(MBEntityHandle) * num_subranges(*set_ranges.rbegin()) + 
+          sizeof(int);
       }
       else if (options & MESHSET_ORDERED) {
           // just get the number of entities in the set
@@ -1425,7 +1457,7 @@
         set_sizes.push_back(num_ents);
 
           // set vec
-        count += sizeof(MBEntityHandle) * num_ents + sizeof(int);
+        vecs_size += sizeof(MBEntityHandle) * num_ents + sizeof(int);
       }
 
         // get numbers of parents/children
@@ -1436,12 +1468,24 @@
       result = mbImpl->num_parent_meshsets(*start_rit, &num_par);
       RR("Failed to get num parents.");
 
-        // set children, parents
-      count += 2*sizeof(int) + (num_par + num_ch) * sizeof(MBEntityHandle);
+      tot_parch += num_ch + num_par;
+      
     }
 
+      // num of sets
+    count += sizeof(int);
+    
+      // options
+    count += set_range.size() * sizeof(unsigned int);
+
+      // range, vector sizes
+    count += ranges_size + vecs_size;
+    
+      // set children, parents
+    count += 2 * set_range.size() * sizeof(int) + tot_parch * sizeof(MBEntityHandle);
+
         // set handles
-    if (!set_range.empty())
+    if (!set_range.empty() && store_remote_handles)
       count += sizeof(int) + 2*sizeof(MBEntityHandle)*num_subranges(set_range);
 
     whole_range.merge(set_range);
@@ -1639,7 +1683,7 @@
         result = mbImpl->add_child_meshset(*rit, mem_ptr[i]);
         RRA("Failed to add child to set in unpack.");
       }
-      mem_ptr += num_par;
+      mem_ptr += num_child;
     }
   }
 
@@ -1818,7 +1862,7 @@
       tr_it++;
     }
 
-    count = buff_ptr - orig_buff_ptr;
+    count += buff_ptr - orig_buff_ptr;
   }
   
   if (debug_packing) std::cerr << std::endl << "Done packing tags." << std::endl;

Modified: MOAB/branches/ghosting/parallel/WriteHDF5Parallel.cpp
===================================================================
--- MOAB/branches/ghosting/parallel/WriteHDF5Parallel.cpp	2008-04-07 21:25:17 UTC (rev 1748)
+++ MOAB/branches/ghosting/parallel/WriteHDF5Parallel.cpp	2008-04-08 03:48:29 UTC (rev 1749)
@@ -1765,9 +1765,6 @@
 MBErrorCode WriteHDF5Parallel::fix_remote_set_ids( RemoteSetData& data, long first_id )
 {
   const id_t id_diff = (id_t)(first_id - 1);
-  id_t file_id;
-  MBErrorCode rval;
-  
   MBRange::const_iterator i;
   std::vector<id_t> ids(data.range.size());
   std::vector<id_t>::iterator j = ids.begin();




More information about the moab-dev mailing list