[MOAB-dev] r4857 - in MOAB/trunk: src test/perf

tautges at mcs.anl.gov tautges at mcs.anl.gov
Fri May 20 15:01:24 CDT 2011


Author: tautges
Date: 2011-05-20 15:01:23 -0500 (Fri, 20 May 2011)
New Revision: 4857

Modified:
   MOAB/trunk/src/SetIterator.cpp
   MOAB/trunk/test/perf/perf.cpp
Log:
Now I handle check_valid flag to iterator creation, and perf test is restructured
to test performance with and without check_valid.

One of the odd things about this is the timings I get:

100x100x100:
           Iterator   
   Test	   size	   !check_valid	    check_valid
e_to_v	   1	   .17		    .47
	   100	   .13		    .16

v_to_e	   1	   1.03		    .55
	   100	   .19		    .2	

200x200x200:
           Iterator   
   Test	   size	   !check_valid	    check_valid
e_to_v	   1	   2.03		    9.81
	   100	   1.83		    2.04

v_to_e	   1	   9.45		    10.93
	   100	   2.07		    2.35

The odd thing about the above is that the v_to_e query, for iterator size 1, is actually faster
when check_valid is true, then when it's false.  That's not an artifact, either, it's consistent 
across multiple runs.  Otherwise, checking validity seems to cost you about 10% overhead,
which is consistent with past observations.




Modified: MOAB/trunk/src/SetIterator.cpp
===================================================================
--- MOAB/trunk/src/SetIterator.cpp	2011-05-20 18:21:04 UTC (rev 4856)
+++ MOAB/trunk/src/SetIterator.cpp	2011-05-20 20:01:23 UTC (rev 4857)
@@ -67,6 +67,9 @@
   int count;
   const EntityHandle *ptr;
   WriteUtilIface *iface;
+  std::vector<EntityHandle> tmp_arr;
+  std::vector<EntityHandle> *tmp_ptr = &arr;
+  if (checkValid) tmp_ptr = &tmp_arr;
   ErrorCode rval;
   if (!pairPtr) {
     Interface *mbImpl = dynamic_cast<Interface*>(myCore);
@@ -91,9 +94,16 @@
     return MB_SUCCESS;
   }
 
-  if (-1 == entDimension) return get_next_by_type(ptr, count, arr, atend);
-  else return get_next_by_dimension(ptr, count, arr, atend);
+  if (-1 == entDimension) rval = get_next_by_type(ptr, count, *tmp_ptr, atend);
+  else rval = get_next_by_dimension(ptr, count, *tmp_ptr, atend);
+  if (MB_SUCCESS != rval) return rval;
   
+  if (checkValid) {
+    for (std::vector<EntityHandle>::iterator vit = tmp_ptr->begin(); vit != tmp_ptr->end(); vit++) {
+      if (myCore->is_valid(*vit)) arr.push_back(*vit);
+    }
+  }
+    
   return MB_SUCCESS;
 }
 
@@ -219,6 +229,10 @@
     return MB_SUCCESS;
   }
   
+  std::vector<EntityHandle> tmp_arr;
+  std::vector<EntityHandle> *tmp_ptr = &arr;
+  if (checkValid) tmp_ptr = &tmp_arr;
+
     // just get the next chunkSize entities, or as many as you can
   int this_ct = 0;
   while (this_ct < (int)chunkSize && iterPos < count) {
@@ -232,6 +246,12 @@
   
   atend = (iterPos == count);
 
+  if (checkValid) {
+    for (std::vector<EntityHandle>::iterator vit = tmp_ptr->begin(); vit != tmp_ptr->end(); vit++) {
+      if (myCore->is_valid(*vit)) arr.push_back(*vit);


More information about the moab-dev mailing list