Add epoch_count parameter in cds::gc::DHP constructor
authorkhizmax <libcds.dev@gmail.com>
Wed, 30 Dec 2015 20:17:10 +0000 (23:17 +0300)
committerkhizmax <libcds.dev@gmail.com>
Wed, 30 Dec 2015 20:17:10 +0000 (23:17 +0300)
Add cds::gc::DHP initialization parameters to test config files

cds/gc/details/dhp.h
cds/gc/impl/dhp_decl.h
src/dhp_gc.cpp
tests/cppunit/test_main.cpp
tests/data/test-debug.conf
tests/data/test-express.conf
tests/data/test.conf

index e18168239e6f9ece3b6476991c66e513d4093bea..6dc9f39428ae715c146de3c9a284e0251d3a5880 100644 (file)
@@ -766,15 +766,13 @@ namespace cds { namespace gc {
                     When the thread terminated its guard pool is backed to common GC's pool.
                 - \p nEpochCount: internally, DHP memory manager uses epoch-based schema to solve
                     ABA problem for internal data. \p nEpochCount specifies the epoch count,
-
                     i.e. the count of simultaneously working threads that remove the elements
-                    of DHP-based concurrent data structure. Default value is 8.
-
+                    of DHP-based concurrent data structure. Default value is 16.
             */
             static void CDS_STDCALL Construct(
                 size_t nLiberateThreshold = 1024
                 , size_t nInitialThreadGuardCount = 8
-                , size_t nEpochCount = 8
+                , size_t nEpochCount = 16
             );
 
             /// Destroys DHP memory manager
index a588db7b03d7f170efc81d18f7fa4968952c26c0..f4f3c5bc8022d0b1d78b0e38b2442ed9233297ea 100644 (file)
@@ -583,16 +583,18 @@ namespace cds { namespace gc {
                 When a thread is initialized the GC allocates local guard pool for the thread from common guard pool.
                 By perforce the local thread's guard pool is grown automatically from common pool.
                 When the thread terminated its guard pool is backed to common GC's pool.
+            - \p nEpochCount: internally, DHP memory manager uses epoch-based schema to solve
+                ABA problem for internal data. \p nEpochCount specifies the epoch count,
+                i.e. the count of simultaneously working threads that remove the elements
+                of DHP-based concurrent data structure. Default value is 16.
         */
         DHP(
             size_t nLiberateThreshold = 1024
             , size_t nInitialThreadGuardCount = 8
+            , size_t nEpochCount = 16
         )
         {
-            dhp::GarbageCollector::Construct(
-                nLiberateThreshold,
-                nInitialThreadGuardCount
-            );
+            dhp::GarbageCollector::Construct( nLiberateThreshold, nInitialThreadGuardCount, nEpochCount );
         }
 
         /// Destroys %DHP memory manager
index a5d22487b2225827ece14c3772acadbaf8c532b2..e21daed89da6b8a003993b15ff0b65baeecdf837 100644 (file)
@@ -157,7 +157,7 @@ namespace cds { namespace gc { namespace dhp {
     GarbageCollector::GarbageCollector( size_t nLiberateThreshold, size_t nInitialThreadGuardCount, size_t nEpochCount )
         : m_nLiberateThreshold( nLiberateThreshold ? nLiberateThreshold : 1024 )
         , m_nInitialThreadGuardCount( nInitialThreadGuardCount ? nInitialThreadGuardCount : 8 )
-        , m_RetiredAllocator( static_cast<unsigned int>(nEpochCount))
+        , m_RetiredAllocator( static_cast<unsigned int>( nEpochCount ? nEpochCount : 16 ))
         , m_bStatEnabled( false )
     {}
 
index b004f8c4f2c28f52bf42896770af80da588edde7..8bc99fa3e0adc61885dbe5dc9ba662c3e60fea46 100644 (file)
@@ -380,14 +380,21 @@ int main(int argc, char** argv)
   int num_errors;
   {
       size_t nHazardPtrCount = 0;
+      size_t dhp_liberateThreshold;
+      size_t dhp_initialThreadGuardCount;
+      size_t dhp_epochCount;
       {
         CppUnitMini::TestCfg& cfg = CppUnitMini::TestCase::m_Cfg.get( "General" );
         nHazardPtrCount = cfg.getULong( "hazard_pointer_count", 0 );
+
+        dhp_liberateThreshold = cfg.getSizeT( "dhp_liberate_threshold", 1024 );
+        dhp_initialThreadGuardCount = cfg.getSizeT( "dhp_init_guard_count", 8 );
+        dhp_epochCount = cfg.getSizeT( "dhp_epoch_count", 16 );
       }
 
       // Safe reclamation schemes
       cds::gc::HP hzpGC( nHazardPtrCount );
-      cds::gc::DHP dhpGC;
+      cds::gc::DHP dhpGC( dhp_liberateThreshold, dhp_initialThreadGuardCount, dhp_epochCount );
 
       // RCU varieties
       typedef cds::urcu::gc< cds::urcu::general_instant<> >    rcu_gpi;
index 7e8ca1b3b2d72b59caf337b2f5fb90f77bfc5ab8..3052e041dfe9b0b1022a1445ac3ce411546fbb40 100644 (file)
@@ -3,6 +3,11 @@
 HZP_scan_strategy=inplace\r
 hazard_pointer_count=72\r
 \r
+# cds::gc::DHP initialization parameters\r
+dhp_liberate_threshold=1024\r
+dhp_init_guard_count=8\r
+dhp_epoch_count=16\r
+\r
 [Atomic_ST]\r
 iterCount=10000\r
 \r
index 3569b3e02405ef9c5270f591fbe4e90eb1ac6b42..fa9b8ee9060a4db22e9d3e5fda2bbc20ea828e50 100644 (file)
@@ -4,6 +4,11 @@ HZP_scan_strategy=inplace
 # Hazard pointer count per thread, for gc::HP\r
 hazard_pointer_count=72\r
 \r
+# cds::gc::DHP initialization parameters\r
+dhp_liberate_threshold=1024\r
+dhp_init_guard_count=16\r
+dhp_epoch_count=16\r
+\r
 [Atomic_ST]\r
 iterCount=1000000\r
 \r
index 702c6bf84a93b8af0d606b471177fa92a01c9728..71e337c4fb8ccc5c865a6b9fc9c5ce7ac43ad22a 100644 (file)
@@ -3,6 +3,11 @@
 HZP_scan_strategy=inplace\r
 hazard_pointer_count=72\r
 \r
+# cds::gc::DHP initialization parameters\r
+dhp_liberate_threshold=1024\r
+dhp_init_guard_count=16\r
+dhp_epoch_count=16\r
+\r
 [Atomic_ST]\r
 iterCount=1000000\r
 \r