[MOAB-dev] r1952 - in MOAB/trunk: . parallel tools/iMesh

tautges at mcs.anl.gov tautges at mcs.anl.gov
Sun Jun 29 11:19:08 CDT 2008


Author: tautges
Date: 2008-06-29 11:19:07 -0500 (Sun, 29 Jun 2008)
New Revision: 1952

Modified:
   MOAB/trunk/SequenceManager.cpp
   MOAB/trunk/SequenceManager.hpp
   MOAB/trunk/TestTypeSequenceManager.cpp
   MOAB/trunk/TypeSequenceManager.cpp
   MOAB/trunk/TypeSequenceManager.hpp
   MOAB/trunk/parallel/mbparallelcomm_test.cpp
   MOAB/trunk/tools/iMesh/Makefile.am
Log:
Fixing a bug in allocation of sequences.  Before this commit, when:
- Existing sequence starts at one place, e.g. 41686, but its
sequenceData starts earlier, e.g. 41673, and
- You try to allocate a new sequence at a lower handle but with a
range which is more than the room available in the sequenceData,

then
- the code wants to allocate right up against the lower end of the
existing sequence, and sizes the new sequenceData accordingly
(i.e. with a max of 41685).

In this case, that new sequenceData will overlap the existing
sequenceData (which starts at 41673, even though it has an empty chunk
in front).

So, this change passes back a sequence data size from the code which
computes where to put the start handle when allocating the new
sequence.

I'm not sure this is the best way to fix this; in the cases I've
observed, this new sequence size is always the number of elements in
the new range.  It may be that you can set that directly when the
returned sequence data pointer is NULL (indicating a new sequence data
must be allocated).  However, this case may only apply when you're
allocating in front of an existing sequence, which probably isn't
always the case.

Also removing unused variable from mbparallelcomm_test, and commented
out ftest stuff in iMesh which was causing the autotesting to fail.

Passed make check.

Modified: MOAB/trunk/SequenceManager.cpp
===================================================================
--- MOAB/trunk/SequenceManager.cpp	2008-06-29 00:44:33 UTC (rev 1951)
+++ MOAB/trunk/SequenceManager.cpp	2008-06-29 16:19:07 UTC (rev 1952)
@@ -186,7 +186,8 @@
   
   if (seq == typeData[MBVERTEX].end()) {
     SequenceData* seq_data = 0;
-    handle = typeData[MBVERTEX].find_free_sequence( DEFAULT_VERTEX_SEQUENCE_SIZE, start, end, seq_data );
+    MBEntityID seq_data_size = 0;
+    handle = typeData[MBVERTEX].find_free_sequence( DEFAULT_VERTEX_SEQUENCE_SIZE, start, end, seq_data, seq_data_size );
     if (!handle) 
       return MB_FAILURE;
     
@@ -247,8 +248,8 @@
     if (type == MBPOLYGON || type == MBPOLYHEDRON) {
       size = default_poly_sequence_size( conn_len );
     }
-    
-    handle = typeData[type].find_free_sequence( size, start, end, seq_data, conn_len );
+    MBEntityID seq_data_size = 0;
+    handle = typeData[type].find_free_sequence( size, start, end, seq_data, seq_data_size, conn_len );
     if (!handle) 
       return MB_FAILURE;
     
@@ -309,7 +310,8 @@
   
   if (seq == typeData[MBENTITYSET].end()) {
     SequenceData* seq_data = 0;
-    handle = typeData[MBENTITYSET].find_free_sequence( DEFAULT_MESHSET_SEQUENCE_SIZE, start, end, seq_data );
+    MBEntityID seq_data_size = 0;
+    handle = typeData[MBENTITYSET].find_free_sequence( DEFAULT_MESHSET_SEQUENCE_SIZE, start, end, seq_data, seq_data_size );
     if (!handle) 
       return MB_FAILURE;
     
@@ -428,7 +430,8 @@
                                         int size,
                                         MBEntityID start,
                                         int proc,
-                                        SequenceData*& data )
+                                        SequenceData*& data,
+                                        MBEntityID &data_size)
 {
   TypeSequenceManager &tsm = typeData[type];
   data = 0;
@@ -437,7 +440,7 @@
       !tsm.is_free_sequence( handle, count, data, size )) {
     MBEntityHandle pstart = handleUtils.create_handle( type, MB_START_ID, proc );
     MBEntityHandle pend   = handleUtils.create_handle( type, MB_END_ID,  proc );
-    handle = tsm.find_free_sequence( count, pstart, pend, data, size );
+    handle = tsm.find_free_sequence( count, pstart, pend, data, data_size, size);
   }
   return handle;
 }
@@ -478,7 +481,9 @@
     proc = handleUtils.proc_rank();
 
   SequenceData* data = 0;
-  handle = sequence_start_handle( type, count, size, start, proc, data );
+  MBEntityID data_size = 0;
+  handle = sequence_start_handle( type, count, size, start, proc, data, data_size );
+    
   if (!handle)
     return MB_MEMORY_ALLOCATION_FAILED;
   
@@ -493,10 +498,12 @@
 
     if (data)
       sequence = new VertexSequence( handle, count, data );
-    else 
-      sequence = new VertexSequence( handle, count, 
-           new_sequence_size( handle, count, DEFAULT_VERTEX_SEQUENCE_SIZE ) );
-    
+    else {
+      if (!data_size)
+        data_size = new_sequence_size(handle, count, 
+                                      DEFAULT_VERTEX_SEQUENCE_SIZE);
+      sequence = new VertexSequence( handle, count, data_size );
+    }
     break;
   
   case MBPOLYGON:
@@ -506,10 +513,12 @@
 
     if (data)
       sequence = new PolyElementSeq( handle, count, size, data );
-    else 
-      sequence = new PolyElementSeq( handle, count, size, 
-           new_sequence_size( handle, count, default_poly_sequence_size(size) ) );
-
+    else {
+      if (!data_size)
+        data_size = new_sequence_size(handle, count, 
+                                      default_poly_sequence_size(size));
+      sequence = new PolyElementSeq( handle, count, size, data_size );
+    }
     break;
   
   default:
@@ -518,9 +527,12 @@
 
     if (data)
       sequence = new UnstructuredElemSeq( handle, count, size, data );
-    else 
-      sequence = new UnstructuredElemSeq( handle, count, size, 
-           new_sequence_size( handle, count, DEFAULT_ELEMENT_SEQUENCE_SIZE ) );
+    else {
+      if (!data_size)
+        data_size = new_sequence_size(handle, count, 
+                                      DEFAULT_ELEMENT_SEQUENCE_SIZE);
+      sequence = new UnstructuredElemSeq( handle, count, size, data_size );
+    }
       // tjt calling new_sequence_size 'cuz don't have a sequence data;
       // start 41467, count 246
     break;
@@ -552,7 +564,9 @@
     proc = handleUtils.proc_rank();
 
   SequenceData* data = 0;
-  handle = sequence_start_handle( MBENTITYSET, count, 0, start, proc, data );
+  MBEntityID data_size = 0;
+  handle = sequence_start_handle( MBENTITYSET, count, 0, start, proc, data, data_size );
+
   if (!handle)
     return MB_MEMORY_ALLOCATION_FAILED;
   
@@ -589,7 +603,8 @@
     proc = handleUtils.proc_rank();
 
   SequenceData* data = 0;
-  handle = sequence_start_handle( MBENTITYSET, count, 0, start, proc, data );
+  MBEntityID data_size = 0;
+  handle = sequence_start_handle( MBENTITYSET, count, 0, start, proc, data, data_size );
   if (!handle)
     return MB_MEMORY_ALLOCATION_FAILED;
   
@@ -644,7 +659,9 @@
   
     // get a start handle
   SequenceData* data = 0;
-  handle = sequence_start_handle( type, num_ent, -1, start_id_hint, processor_id, data );
+  MBEntityID data_size = 0;
+  handle = sequence_start_handle( type, num_ent, -1, start_id_hint, processor_id, data, data_size );
+
   if (!handle)
     return MB_MEMORY_ALLOCATION_FAILED;
   assert(!data);

Modified: MOAB/trunk/SequenceManager.hpp
===================================================================
--- MOAB/trunk/SequenceManager.hpp	2008-06-29 00:44:33 UTC (rev 1951)
+++ MOAB/trunk/SequenceManager.hpp	2008-06-29 16:19:07 UTC (rev 1952)
@@ -422,7 +422,8 @@
                                                      int values_per_entity,
                                               MBEntityID start_id_hint,
                                                      int processor_rank,
-                                          SequenceData*& data_out );
+                                            SequenceData*& data_out,
+                                            MBEntityID &data_size );
   
     const MBHandleUtils handleUtils;
     TypeSequenceManager typeData[MBMAXTYPE];

Modified: MOAB/trunk/TestTypeSequenceManager.cpp
===================================================================
--- MOAB/trunk/TestTypeSequenceManager.cpp	2008-06-29 00:44:33 UTC (rev 1951)
+++ MOAB/trunk/TestTypeSequenceManager.cpp	2008-06-29 16:19:07 UTC (rev 1952)
@@ -1,6 +1,7 @@
 #include "TypeSequenceManager.hpp"
 #include "EntitySequence.hpp"
 #include "SequenceData.hpp"
+#include "MBEntityHandle.h"
 #include "TestUtil.hpp"
 
 void test_basic();
@@ -762,35 +763,36 @@
 {
   MBEntityHandle start;
   SequenceData* data = 0;
+  MBEntityID data_size = 0;
   TypeSequenceManager seqman;
   make_basic_sequence( seqman ); // { [3,7], [100,111], [1001] }
   SequenceData* expdata = (*seqman.begin())->data();
   
-  start = seqman.find_free_sequence( 2, 1, 3, data );
+  start = seqman.find_free_sequence( 2, 1, 3, data, data_size );
   CHECK_EQUAL( expdata, data );
   CHECK_EQUAL( (MBEntityHandle)1, start );
   
-  start = seqman.find_free_sequence( 3, 1, 7, data );
+  start = seqman.find_free_sequence( 3, 1, 7, data, data_size );
   CHECK_EQUAL( (MBEntityHandle)0, start );
   CHECK_EQUAL( NULL, data );
   
-  start = seqman.find_free_sequence( 30, 1, 120, data );
+  start = seqman.find_free_sequence( 30, 1, 120, data, data_size );
   CHECK_EQUAL( expdata, data );
   CHECK( start == 8 || start == 70 );
   
-  start = seqman.find_free_sequence( 10, 92, 999, data );
+  start = seqman.find_free_sequence( 10, 92, 999, data, data_size );
   CHECK_EQUAL( expdata, data );
   CHECK_EQUAL( (MBEntityHandle)112, start );
   
-  start = seqman.find_free_sequence( 100, 1, 600, data );
+  start = seqman.find_free_sequence( 100, 1, 600, data, data_size );
   CHECK_EQUAL( expdata, data );
   CHECK_EQUAL( (MBEntityHandle)112, start );
   
-  start = seqman.find_free_sequence( 1000, 1, MB_END_ID, data );
+  start = seqman.find_free_sequence( 1000, 1, MB_END_ID, data, data_size );
   CHECK_EQUAL( expdata, data );
   CHECK_EQUAL( (MBEntityHandle)1002, start );
   
-  start = seqman.find_free_sequence( 980, 1, 1800, data );
+  start = seqman.find_free_sequence( 980, 1, 1800, data, data_size );
   CHECK_EQUAL( (MBEntityHandle)0, start );
   CHECK_EQUAL( NULL, data );
 }

Modified: MOAB/trunk/TypeSequenceManager.cpp
===================================================================
--- MOAB/trunk/TypeSequenceManager.cpp	2008-06-29 00:44:33 UTC (rev 1951)
+++ MOAB/trunk/TypeSequenceManager.cpp	2008-06-29 16:19:07 UTC (rev 1952)
@@ -473,7 +473,8 @@
                                                         MBEntityHandle min_start_handle,
                                                         MBEntityHandle max_end_handle,
                                                         SequenceData*& data_out,
-                                                        int num_verts )
+                                                        MBEntityID &data_size,
+                                                        int num_verts)
 {
   if (max_end_handle < min_start_handle + num_entities - 1)
     return 0;
@@ -499,6 +500,9 @@
     d.last = (*i)->data()->start_handle() - 1;
     if (check_range( d, true, result)) {
       data_out = 0;
+        // this will back up against the end of the seq data, so
+        // size the data that way
+      data_size = num_entities;
       return result;
     }
     p = i++;

Modified: MOAB/trunk/TypeSequenceManager.hpp
===================================================================
--- MOAB/trunk/TypeSequenceManager.hpp	2008-06-29 00:44:33 UTC (rev 1951)
+++ MOAB/trunk/TypeSequenceManager.hpp	2008-06-29 16:19:07 UTC (rev 1952)
@@ -247,6 +247,7 @@
                                      MBEntityHandle min_start_handle,
                                      MBEntityHandle max_end_handle,
                                      SequenceData*& sequence_data_out,
+                                     MBEntityID &sequence_data_size,
                                      int values_per_ent = 0 );
 
     /**\brief Check if block of handles is free.

Modified: MOAB/trunk/parallel/mbparallelcomm_test.cpp
===================================================================
--- MOAB/trunk/parallel/mbparallelcomm_test.cpp	2008-06-29 00:44:33 UTC (rev 1951)
+++ MOAB/trunk/parallel/mbparallelcomm_test.cpp	2008-06-29 16:19:07 UTC (rev 1952)
@@ -80,7 +80,6 @@
     // procs on the end
 
     // get N, M from command line
-  int N, M;
   if (argc < 3) {
     if (0 == rank)
       std::cerr 

Modified: MOAB/trunk/tools/iMesh/Makefile.am
===================================================================
--- MOAB/trunk/tools/iMesh/Makefile.am	2008-06-29 00:44:33 UTC (rev 1951)
+++ MOAB/trunk/tools/iMesh/Makefile.am	2008-06-29 16:19:07 UTC (rev 1952)
@@ -39,9 +39,9 @@
   partest_SOURCES = partest.cpp
   partest_DEPENDENCIES = libiMesh.la $(top_builddir)/libMOAB.la 
 
-  check_PROGRAMS += ftest
-  ftest_SOURCES = ftest.F
-  ftest_DEPENDENCIES = libiMesh.la $(top_builddir)/libMOAB.la 
+#  check_PROGRAMS += ftest
+#  ftest_SOURCES = ftest.F
+#  ftest_DEPENDENCIES = libiMesh.la $(top_builddir)/libMOAB.la 
 endif
 
 lib_LTLIBRARIES = libiMesh.la




More information about the moab-dev mailing list