From 88712604cbaf255da093e01f96a3fa585333de93 Mon Sep 17 00:00:00 2001 From: khizmax Date: Wed, 30 Dec 2015 23:17:10 +0300 Subject: [PATCH] Add epoch_count parameter in cds::gc::DHP constructor Add cds::gc::DHP initialization parameters to test config files --- cds/gc/details/dhp.h | 6 ++---- cds/gc/impl/dhp_decl.h | 10 ++++++---- src/dhp_gc.cpp | 2 +- tests/cppunit/test_main.cpp | 9 ++++++++- tests/data/test-debug.conf | 5 +++++ tests/data/test-express.conf | 5 +++++ tests/data/test.conf | 5 +++++ 7 files changed, 32 insertions(+), 10 deletions(-) diff --git a/cds/gc/details/dhp.h b/cds/gc/details/dhp.h index e1816823..6dc9f394 100644 --- a/cds/gc/details/dhp.h +++ b/cds/gc/details/dhp.h @@ -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 diff --git a/cds/gc/impl/dhp_decl.h b/cds/gc/impl/dhp_decl.h index a588db7b..f4f3c5bc 100644 --- a/cds/gc/impl/dhp_decl.h +++ b/cds/gc/impl/dhp_decl.h @@ -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 diff --git a/src/dhp_gc.cpp b/src/dhp_gc.cpp index a5d22487..e21daed8 100644 --- a/src/dhp_gc.cpp +++ b/src/dhp_gc.cpp @@ -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(nEpochCount)) + , m_RetiredAllocator( static_cast( nEpochCount ? nEpochCount : 16 )) , m_bStatEnabled( false ) {} diff --git a/tests/cppunit/test_main.cpp b/tests/cppunit/test_main.cpp index b004f8c4..8bc99fa3 100644 --- a/tests/cppunit/test_main.cpp +++ b/tests/cppunit/test_main.cpp @@ -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; diff --git a/tests/data/test-debug.conf b/tests/data/test-debug.conf index 7e8ca1b3..3052e041 100644 --- a/tests/data/test-debug.conf +++ b/tests/data/test-debug.conf @@ -3,6 +3,11 @@ HZP_scan_strategy=inplace hazard_pointer_count=72 +# cds::gc::DHP initialization parameters +dhp_liberate_threshold=1024 +dhp_init_guard_count=8 +dhp_epoch_count=16 + [Atomic_ST] iterCount=10000 diff --git a/tests/data/test-express.conf b/tests/data/test-express.conf index 3569b3e0..fa9b8ee9 100644 --- a/tests/data/test-express.conf +++ b/tests/data/test-express.conf @@ -4,6 +4,11 @@ HZP_scan_strategy=inplace # Hazard pointer count per thread, for gc::HP hazard_pointer_count=72 +# cds::gc::DHP initialization parameters +dhp_liberate_threshold=1024 +dhp_init_guard_count=16 +dhp_epoch_count=16 + [Atomic_ST] iterCount=1000000 diff --git a/tests/data/test.conf b/tests/data/test.conf index 702c6bf8..71e337c4 100644 --- a/tests/data/test.conf +++ b/tests/data/test.conf @@ -3,6 +3,11 @@ HZP_scan_strategy=inplace hazard_pointer_count=72 +# cds::gc::DHP initialization parameters +dhp_liberate_threshold=1024 +dhp_init_guard_count=16 +dhp_epoch_count=16 + [Atomic_ST] iterCount=1000000 -- 2.34.1