public:
/// Default ctor. The initial capacity is 16.
StripedSet()
- : base_class()
+ : base_class()
{}
/// Ctor with initial capacity specified
StripedSet(
size_t nCapacity ///< Initial size of bucket table and lock array. Must be power of two, the minimum is 16.
- ) : base_class( nCapacity )
+ )
+ : base_class( nCapacity )
{}
/// Ctor with resizing policy (copy semantics)
StripedSet(
size_t nCapacity ///< Initial size of bucket table and lock array. Must be power of two, the minimum is 16.
,resizing_policy const& resizingPolicy ///< Resizing policy
- ) : base_class( nCapacity, resizingPolicy )
+ )
+ : base_class( nCapacity, resizingPolicy )
{}
/// Ctor with resizing policy (move semantics)
StripedSet(
size_t nCapacity ///< Initial size of bucket table and lock array. Must be power of two, the minimum is 16.
,resizing_policy&& resizingPolicy ///< Resizing policy
- ) : base_class( nCapacity, std::forward<resizing_policy>(resizingPolicy) )
+ )
+ : base_class( nCapacity, std::forward<resizing_policy>(resizingPolicy) )
{}
/// Destructor destroys internal data
auto it = m_Set.find( val );
if ( it == m_Set.end() )
return std::make_pair( false, false );
- func( false, *it, val );
+ func( false, const_cast<value_type&>(*it), val );
return std::make_pair( true, false );
}
}
}
else {
auto it = m_Set.find( value_type(val));
- if ( it = m_Set.end() )
+ if ( it == m_Set.end() )
return std::make_pair( false, false );
- func( false, *it, val );
+ func( false, const_cast<value_type&>(*it), val );
return std::make_pair( true, false );
}
}
auto it = m_Set.find(value_type(val));
if ( it == m_Set.end() )
return std::make_pair( false, false );
- func( false, *it, val );
+ func( false, const_cast<value_type&>(*it), val );
return std::make_pair( true, false );
}
}
<ClCompile Include="..\..\..\tests\unit\set2\set_insdel_func.cpp" />\r
<ClCompile Include="..\..\..\tests\unit\set2\set_insdel_func_cuckoo.cpp" />\r
<ClCompile Include="..\..\..\tests\unit\set2\set_insdel_func_ellentree.cpp" />\r
- <ClCompile Include="..\..\..\tests\unit\set2\set_insdel_func_refinable.cpp" />\r
+ <ClCompile Include="..\..\..\tests\unit\set2\set_insdel_func_michael.cpp" />\r
<ClCompile Include="..\..\..\tests\unit\set2\set_insdel_func_skip.cpp" />\r
<ClCompile Include="..\..\..\tests\unit\set2\set_insdel_func_split.cpp" />\r
<ClCompile Include="..\..\..\tests\unit\set2\set_insdel_func_striped.cpp" />\r
<ClCompile Include="..\..\..\tests\unit\set2\set_insdel_func_ellentree.cpp">\r
<Filter>set_insdel_func</Filter>\r
</ClCompile>\r
- <ClCompile Include="..\..\..\tests\unit\set2\set_insdel_func_refinable.cpp">\r
- <Filter>set_insdel_func</Filter>\r
- </ClCompile>\r
<ClCompile Include="..\..\..\tests\unit\set2\set_insdel_func_skip.cpp">\r
<Filter>set_insdel_func</Filter>\r
</ClCompile>\r
<ClCompile Include="..\..\..\tests\unit\set2\set_insdel_string_striped.cpp">\r
<Filter>set_insdel_string</Filter>\r
</ClCompile>\r
+ <ClCompile Include="..\..\..\tests\unit\set2\set_insdel_func_michael.cpp">\r
+ <Filter>set_insdel_func</Filter>\r
+ </ClCompile>\r
</ItemGroup>\r
<ItemGroup>\r
<Filter Include="set_insdel_func">\r
tests/unit/set2/set_insdel_func.cpp \
tests/unit/set2/set_insdel_func_cuckoo.cpp \
tests/unit/set2/set_insdel_func_ellentree.cpp \
- tests/unit/set2/set_insdel_func_refinable.cpp \
+ tests/unit/set2/set_insdel_func_michael.cpp \
tests/unit/set2/set_insdel_func_skip.cpp \
tests/unit/set2/set_insdel_func_split.cpp \
tests/unit/set2/set_insdel_func_striped.cpp \
set_insdel_func.cpp
set_insdel_func_cuckoo.cpp
set_insdel_func_ellentree.cpp
- set_insdel_func_refinable.cpp
+ set_insdel_func_michael.cpp
set_insdel_func_skip.cpp
set_insdel_func_split.cpp
set_insdel_func_striped.cpp
#define CDSUNIT_SET_DEFS_H
#define CDSUNIT_DECLARE_StdSet \
- CDSUNIT_DECLARE_TEST(StdSet_Spin) \
- CDSUNIT_DECLARE_TEST(StdHashSet_Spin)
-
-#define CDSUNIT_DEFINE_StdSet(IMPL, C) \
- TEST_SET(IMPL, C, StdSet_Spin) \
- TEST_SET(IMPL, C, StdHashSet_Spin)
+ TEST_CASE(StdSet_Spin) \
+ TEST_CASE(StdHashSet_Spin)
#define CDSUNIT_TEST_StdSet \
CPPUNIT_TEST(StdSet_Spin) \
#define CDSUNIT_DECLARE_StripedSet_common \
- CDSUNIT_DECLARE_TEST(StripedSet_list) \
- CDSUNIT_DECLARE_TEST(StripedSet_vector) \
- CDSUNIT_DECLARE_TEST(StripedSet_set) \
- CDSUNIT_DECLARE_TEST(StripedSet_hashset) \
- CDSUNIT_DECLARE_TEST(StripedSet_boost_unordered_set) \
- CDSUNIT_DECLARE_TEST(StripedSet_rational_list) \
- CDSUNIT_DECLARE_TEST(StripedSet_rational_vector) \
- CDSUNIT_DECLARE_TEST(StripedSet_rational_set) \
- CDSUNIT_DECLARE_TEST(StripedSet_rational_hashset) \
- CDSUNIT_DECLARE_TEST(StripedSet_rational_boost_unordered_set)
+ TEST_CASE( tag_StripedSet, StripedSet_list) \
+ TEST_CASE( tag_StripedSet, StripedSet_vector) \
+ TEST_CASE( tag_StripedSet, StripedSet_set) \
+ TEST_CASE( tag_StripedSet, StripedSet_hashset) \
+ TEST_CASE( tag_StripedSet, StripedSet_boost_unordered_set) \
+ TEST_CASE( tag_StripedSet, StripedSet_rational_list) \
+ TEST_CASE( tag_StripedSet, StripedSet_rational_vector) \
+ TEST_CASE( tag_StripedSet, StripedSet_rational_set) \
+ TEST_CASE( tag_StripedSet, StripedSet_rational_hashset) \
+ TEST_CASE( tag_StripedSet, StripedSet_rational_boost_unordered_set)
#define CDSUNIT_TEST_StripedSet_common \
CPPUNIT_TEST(StripedSet_list) \
#if BOOST_VERSION >= 104800
# define CDSUNIT_DECLARE_StripedSet_boost_container \
- CDSUNIT_DECLARE_TEST(StripedSet_boost_list) \
- CDSUNIT_DECLARE_TEST(StripedSet_boost_slist) \
- CDSUNIT_DECLARE_TEST(StripedSet_boost_vector) \
- CDSUNIT_DECLARE_TEST(StripedSet_boost_stable_vector) \
- CDSUNIT_DECLARE_TEST(StripedSet_boost_set) \
- CDSUNIT_DECLARE_TEST(StripedSet_rational_boost_list) \
- CDSUNIT_DECLARE_TEST(StripedSet_rational_boost_slist) \
- CDSUNIT_DECLARE_TEST(StripedSet_rational_boost_vector) \
- CDSUNIT_DECLARE_TEST(StripedSet_rational_boost_stable_vector) \
- CDSUNIT_DECLARE_TEST(StripedSet_rational_boost_set)
+ TEST_CASE( tag_StripedSet, StripedSet_boost_list) \
+ TEST_CASE( tag_StripedSet, StripedSet_boost_slist) \
+ TEST_CASE( tag_StripedSet, StripedSet_boost_vector) \
+ TEST_CASE( tag_StripedSet, StripedSet_boost_stable_vector) \
+ TEST_CASE( tag_StripedSet, StripedSet_boost_set) \
+ TEST_CASE( tag_StripedSet, StripedSet_rational_boost_list) \
+ TEST_CASE( tag_StripedSet, StripedSet_rational_boost_slist) \
+ TEST_CASE( tag_StripedSet, StripedSet_rational_boost_vector) \
+ TEST_CASE( tag_StripedSet, StripedSet_rational_boost_stable_vector) \
+ TEST_CASE( tag_StripedSet, StripedSet_rational_boost_set)
# define CDSUNIT_TEST_StripedSet_boost_container \
CPPUNIT_TEST(StripedSet_boost_list) \
#if BOOST_VERSION >= 104800 && defined(CDS_UNIT_SET_TYPES_ENABLE_BOOST_FLAT_CONTAINERS)
# define CDSUNIT_DECLARE_StripedSet_boost_flat_container \
- CDSUNIT_DECLARE_TEST(StripedSet_boost_flat_set) \
- CDSUNIT_DECLARE_TEST(StripedSet_rational_boost_flat_set)
+ TEST_CASE( tag_StripedSet, StripedSet_boost_flat_set) \
+ TEST_CASE( tag_StripedSet, StripedSet_rational_boost_flat_set)
# define CDSUNIT_TEST_StripedSet_boost_flat_container \
CPPUNIT_TEST(StripedSet_boost_flat_set) \
#define CDSUNIT_DECLARE_RefinableSet_common \
- CDSUNIT_DECLARE_TEST(RefinableSet_list) \
- CDSUNIT_DECLARE_TEST(RefinableSet_vector) \
- CDSUNIT_DECLARE_TEST(RefinableSet_set) \
- CDSUNIT_DECLARE_TEST(RefinableSet_hashset) \
- CDSUNIT_DECLARE_TEST(RefinableSet_boost_unordered_set) \
- CDSUNIT_DECLARE_TEST(RefinableSet_rational_list) \
- CDSUNIT_DECLARE_TEST(RefinableSet_rational_vector) \
- CDSUNIT_DECLARE_TEST(RefinableSet_rational_set) \
- CDSUNIT_DECLARE_TEST(RefinableSet_rational_hashset) \
- CDSUNIT_DECLARE_TEST(RefinableSet_rational_boost_unordered_set)
+ TEST_CASE( tag_StripedSet, RefinableSet_list) \
+ TEST_CASE( tag_StripedSet, RefinableSet_vector) \
+ TEST_CASE( tag_StripedSet, RefinableSet_set) \
+ TEST_CASE( tag_StripedSet, RefinableSet_hashset) \
+ TEST_CASE( tag_StripedSet, RefinableSet_boost_unordered_set) \
+ TEST_CASE( tag_StripedSet, RefinableSet_rational_list) \
+ TEST_CASE( tag_StripedSet, RefinableSet_rational_vector) \
+ TEST_CASE( tag_StripedSet, RefinableSet_rational_set) \
+ TEST_CASE( tag_StripedSet, RefinableSet_rational_hashset) \
+ TEST_CASE( tag_StripedSet, RefinableSet_rational_boost_unordered_set)
#define CDSUNIT_TEST_RefinableSet_common \
CPPUNIT_TEST(RefinableSet_list) \
#if BOOST_VERSION >= 104800
# define CDSUNIT_DECLARE_RefinableSet_boost_container \
- CDSUNIT_DECLARE_TEST(RefinableSet_boost_list) \
- CDSUNIT_DECLARE_TEST(RefinableSet_boost_slist) \
- CDSUNIT_DECLARE_TEST(RefinableSet_boost_vector) \
- CDSUNIT_DECLARE_TEST(RefinableSet_boost_stable_vector) \
- CDSUNIT_DECLARE_TEST(RefinableSet_boost_set) \
- CDSUNIT_DECLARE_TEST(RefinableSet_rational_boost_list) \
- CDSUNIT_DECLARE_TEST(RefinableSet_rational_boost_slist) \
- CDSUNIT_DECLARE_TEST(RefinableSet_rational_boost_vector) \
- CDSUNIT_DECLARE_TEST(RefinableSet_rational_boost_stable_vector) \
- CDSUNIT_DECLARE_TEST(RefinableSet_rational_boost_set)
+ TEST_CASE( tag_StripedSet, RefinableSet_boost_list) \
+ TEST_CASE( tag_StripedSet, RefinableSet_boost_slist) \
+ TEST_CASE( tag_StripedSet, RefinableSet_boost_vector) \
+ TEST_CASE( tag_StripedSet, RefinableSet_boost_stable_vector) \
+ TEST_CASE( tag_StripedSet, RefinableSet_boost_set) \
+ TEST_CASE( tag_StripedSet, RefinableSet_rational_boost_list) \
+ TEST_CASE( tag_StripedSet, RefinableSet_rational_boost_slist) \
+ TEST_CASE( tag_StripedSet, RefinableSet_rational_boost_vector) \
+ TEST_CASE( tag_StripedSet, RefinableSet_rational_boost_stable_vector) \
+ TEST_CASE( tag_StripedSet, RefinableSet_rational_boost_set)
# define CDSUNIT_TEST_RefinableSet_boost_container \
CPPUNIT_TEST(RefinableSet_boost_list) \
#if BOOST_VERSION >= 104800 && defined(CDS_UNIT_SET_TYPES_ENABLE_BOOST_FLAT_CONTAINERS)
# define CDSUNIT_DECLARE_RefinableSet_boost_flat_container \
- CDSUNIT_DECLARE_TEST(RefinableSet_boost_flat_set) \
- CDSUNIT_DECLARE_TEST(RefinableSet_rational_boost_flat_set)
+ TEST_CASE( tag_StripedSet, RefinableSet_boost_flat_set) \
+ TEST_CASE( tag_StripedSet, RefinableSet_rational_boost_flat_set)
# define CDSUNIT_TEST_RefinableSet_boost_flat_container \
CPPUNIT_TEST(RefinableSet_boost_flat_set) \
CDSUNIT_DECLARE_EllenBinTreeSet
CDSUNIT_DECLARE_CuckooSet
- CPPUNIT_TEST_SUITE(Set_DelOdd)
+ CPPUNIT_TEST_SUITE_(Set_DelOdd, "Map_DelOdd")
CDSUNIT_TEST_MichaelSet
CDSUNIT_TEST_SplitList
CDSUNIT_TEST_SkipListSet
//$$CDS-header$$
#include "set2/set_insdel_func.h"
-#include "set2/set_type_michael.h"
namespace set2 {
-
CPPUNIT_TEST_SUITE_REGISTRATION( Set_InsDel_func );
- size_t Set_InsDel_func::c_nMapSize = 1000000 ; // map size
- size_t Set_InsDel_func::c_nInsertThreadCount = 4; // count of insertion thread
- size_t Set_InsDel_func::c_nDeleteThreadCount = 4; // count of deletion thread
- size_t Set_InsDel_func::c_nEnsureThreadCount = 4; // count of ensure thread
- size_t Set_InsDel_func::c_nThreadPassCount = 4 ; // pass count for each thread
- size_t Set_InsDel_func::c_nMaxLoadFactor = 8 ; // maximum load factor
- bool Set_InsDel_func::c_bPrintGCState = true;
-
- CDSUNIT_DEFINE_MichaelSet( cc::michael_set::implementation_tag, Set_InsDel_func )
+ void Set_InsDel_func::setUpParams( const CppUnitMini::TestCfg& cfg )
+ {
+ c_nSetSize = cfg.getSizeT("MapSize", c_nSetSize );
+ c_nInsertThreadCount = cfg.getSizeT("InsertThreadCount", c_nInsertThreadCount );
+ c_nDeleteThreadCount = cfg.getSizeT("DeleteThreadCount", c_nDeleteThreadCount );
+ c_nUpdateThreadCount = cfg.getSizeT("EnsureThreadCount", c_nUpdateThreadCount );
+ c_nThreadPassCount = cfg.getSizeT("ThreadPassCount", c_nThreadPassCount );
+ c_nMaxLoadFactor = cfg.getSizeT("MaxLoadFactor", c_nMaxLoadFactor );
+ c_bPrintGCState = cfg.getBool("PrintGCStateFlag", c_bPrintGCState );
- CPPUNIT_TEST_SUITE_PART( Set_InsDel_func, run_MichaelSet )
- CDSUNIT_TEST_MichaelSet
- CPPUNIT_TEST_SUITE_END_PART()
+ c_nCuckooInitialSize = cfg.getSizeT("CuckooInitialSize", c_nCuckooInitialSize );
+ c_nCuckooProbesetSize = cfg.getSizeT("CuckooProbesetSize", c_nCuckooProbesetSize );
+ c_nCuckooProbesetThreshold = cfg.getSizeT("CuckooProbesetThreshold", c_nCuckooProbesetThreshold );
+ if ( c_nInsertThreadCount == 0 )
+ c_nInsertThreadCount = std::thread::hardware_concurrency();
+ if ( c_nDeleteThreadCount == 0 )
+ c_nDeleteThreadCount = std::thread::hardware_concurrency();
+ if ( c_nUpdateThreadCount == 0 )
+ c_nUpdateThreadCount = std::thread::hardware_concurrency();
+ }
} // namespace set2
namespace set2 {
-# define TEST_SET(IMPL, C, X) void C::X() { test<set_type<IMPL, key_type, value_type>::X >(); }
-# define TEST_SET_EXTRACT(IMPL, C, X) TEST_SET(IMPL, C, X)
-# define TEST_SET_NOLF(IMPL, C, X) void C::X() { test_nolf<set_type<IMPL, key_type, value_type>::X >(); }
-# define TEST_SET_NOLF_EXTRACT(IMPL, C, X) TEST_SET_NOLF(IMPL, C, X)
+#define TEST_CASE(TAG, X) void X();
class Set_InsDel_func: public CppUnitMini::TestCase
{
- static size_t c_nMapSize ; // map size
- static size_t c_nInsertThreadCount ; // count of insertion thread
- static size_t c_nDeleteThreadCount ; // count of deletion thread
- static size_t c_nEnsureThreadCount ; // count of ensure thread
- static size_t c_nThreadPassCount ; // pass count for each thread
- static size_t c_nMaxLoadFactor ; // maximum load factor
- static bool c_bPrintGCState;
-
+ public:
+ size_t c_nSetSize = 1000000; // set size
+ size_t c_nInsertThreadCount = 4; // count of insertion thread
+ size_t c_nDeleteThreadCount = 4; // count of deletion thread
+ size_t c_nUpdateThreadCount = 4; // count of ensure thread
+ size_t c_nThreadPassCount = 4; // pass count for each thread
+ size_t c_nMaxLoadFactor = 8; // maximum load factor
+ bool c_bPrintGCState;
+
+ size_t c_nCuckooInitialSize = 1024;// initial size for CuckooSet
+ size_t c_nCuckooProbesetSize = 16; // CuckooSet probeset size (only for list-based probeset)
+ size_t c_nCuckooProbesetThreshold = 0; // CUckooSet probeset threshold (0 - use default)
+
+ size_t c_nLoadFactor = 2;
+
+ private:
typedef size_t key_type;
struct value_type {
size_t nKey;
size_t nData;
- atomics::atomic<size_t> nEnsureCall;
+ atomics::atomic<size_t> nUpdateCall;
bool volatile bInitialized;
cds::OS::ThreadId threadId ; // insert thread id
value_type()
: nKey(0)
, nData(0)
- , nEnsureCall(0)
+ , nUpdateCall(0)
, bInitialized( false )
, threadId( cds::OS::get_current_thread_id() )
{}
value_type( value_type const& s )
: nKey(s.nKey)
, nData(s.nData)
- , nEnsureCall(s.nEnsureCall.load(atomics::memory_order_relaxed))
+ , nUpdateCall(s.nUpdateCall.load(atomics::memory_order_relaxed))
, bInitialized( s.bInitialized )
, threadId( cds::OS::get_current_thread_id() )
{}
{
nKey = v.nKey;
nData = v.nData;
- nEnsureCall.store( v.nEnsureCall.load(atomics::memory_order_relaxed), atomics::memory_order_relaxed );
+ nUpdateCall.store( v.nUpdateCall.load(atomics::memory_order_relaxed), atomics::memory_order_relaxed );
bInitialized = v.bInitialized;
return *this;
size_t * pKeyFirst = getTest().m_pKeyFirst;
size_t * pKeyLast = getTest().m_pKeyLast;
+ size_t const nPassCount = getTest().c_nThreadPassCount;
// func is passed by reference
insert_functor func;
if ( m_nThreadNo & 1 ) {
- for ( size_t nPass = 0; nPass < c_nThreadPassCount; ++nPass ) {
+ for ( size_t nPass = 0; nPass < nPassCount; ++nPass ) {
for ( size_t * p = pKeyFirst; p < pKeyLast; ++p ) {
if ( rSet.insert( *p, std::ref(func) ) )
++m_nInsertSuccess;
}
}
else {
- for ( size_t nPass = 0; nPass < c_nThreadPassCount; ++nPass ) {
+ for ( size_t nPass = 0; nPass < nPassCount; ++nPass ) {
for ( size_t * p = pKeyLast - 1; p >= pKeyFirst; --p ) {
if ( rSet.insert( *p, std::ref(func) ) )
++m_nInsertSuccess;
};
template <class Set>
- class Ensurer: public CppUnitMini::TestThread
+ class Updater: public CppUnitMini::TestThread
{
Set& m_Set;
typedef typename Set::value_type keyval_type;
- virtual Ensurer * clone()
+ virtual Updater * clone()
{
- return new Ensurer( *this );
+ return new Updater( *this );
}
- struct ensure_functor {
+ struct update_functor {
size_t nCreated;
size_t nModified;
- ensure_functor()
+ update_functor()
: nCreated(0)
, nModified(0)
{}
++nCreated;
}
else {
- val.val.nEnsureCall.fetch_add( 1, atomics::memory_order_relaxed );
+ val.val.nUpdateCall.fetch_add( 1, atomics::memory_order_relaxed );
++nModified;
}
}
private:
- ensure_functor(const ensure_functor& );
+ update_functor(const update_functor& );
};
public:
- size_t m_nEnsureFailed;
- size_t m_nEnsureCreated;
- size_t m_nEnsureExisted;
+ size_t m_nUpdateFailed;
+ size_t m_nUpdateCreated;
+ size_t m_nUpdateExisted;
size_t m_nFunctorCreated;
size_t m_nFunctorModified;
public:
- Ensurer( CppUnitMini::ThreadPool& pool, Set& rSet )
+ Updater( CppUnitMini::ThreadPool& pool, Set& rSet )
: CppUnitMini::TestThread( pool )
, m_Set( rSet )
{}
- Ensurer( Ensurer& src )
+ Updater( Updater& src )
: CppUnitMini::TestThread( src )
, m_Set( src.m_Set )
{}
{
Set& rSet = m_Set;
- m_nEnsureCreated =
- m_nEnsureExisted =
- m_nEnsureFailed = 0;
+ m_nUpdateCreated =
+ m_nUpdateExisted =
+ m_nUpdateFailed = 0;
size_t * pKeyFirst = getTest().m_pKeyFirst;
size_t * pKeyLast = getTest().m_pKeyLast;
+ size_t const nPassCount = getTest().c_nThreadPassCount;
- ensure_functor func;
+ update_functor func;
if ( m_nThreadNo & 1 ) {
- for ( size_t nPass = 0; nPass < c_nThreadPassCount; ++nPass ) {
+ for ( size_t nPass = 0; nPass < nPassCount; ++nPass ) {
for ( size_t * p = pKeyFirst; p < pKeyLast; ++p ) {
- std::pair<bool, bool> ret = rSet.ensure( *p, std::ref( func ) );
+ std::pair<bool, bool> ret = rSet.update( *p, std::ref( func ), true );
if ( ret.first ) {
if ( ret.second )
- ++m_nEnsureCreated;
+ ++m_nUpdateCreated;
else
- ++m_nEnsureExisted;
+ ++m_nUpdateExisted;
}
else
- ++m_nEnsureFailed;
+ ++m_nUpdateFailed;
}
}
}
else {
- for ( size_t nPass = 0; nPass < c_nThreadPassCount; ++nPass ) {
+ for ( size_t nPass = 0; nPass < nPassCount; ++nPass ) {
for ( size_t * p = pKeyLast - 1 ; p >= pKeyFirst; --p ) {
- std::pair<bool, bool> ret = rSet.ensure( *p, std::ref( func ) );
+ std::pair<bool, bool> ret = rSet.update( *p, std::ref( func ), true );
if ( ret.first ) {
if ( ret.second )
- ++m_nEnsureCreated;
+ ++m_nUpdateCreated;
else
- ++m_nEnsureExisted;
+ ++m_nUpdateExisted;
}
else
- ++m_nEnsureFailed;
+ ++m_nUpdateFailed;
}
}
}
while ( true ) {
bool bBkoff = false;
{
- std::unique_lock< typename value_type::lock_type> ac( item.val.m_access );
+ std::unique_lock< typename value_type::lock_type> ac( item.val.m_access );
if ( item.val.bInitialized ) {
if ( m_cnt.nKeyExpected == item.val.nKey && m_cnt.nKeyExpected * 8 == item.val.nData )
++m_cnt.nSuccessItem;
size_t * pKeyFirst = getTest().m_pKeyFirst;
size_t * pKeyLast = getTest().m_pKeyLast;
+ size_t const nPassCount = getTest().c_nThreadPassCount;
erase_functor func;
if ( m_nThreadNo & 1 ) {
- for ( size_t nPass = 0; nPass < c_nThreadPassCount; ++nPass ) {
+ for ( size_t nPass = 0; nPass < nPassCount; ++nPass ) {
for ( size_t * p = pKeyFirst; p < pKeyLast; ++p ) {
func.m_cnt.nKeyExpected = *p;
if ( rSet.erase( *p, std::ref(func) ))
}
}
else {
- for ( size_t nPass = 0; nPass < c_nThreadPassCount; ++nPass ) {
+ for ( size_t nPass = 0; nPass < nPassCount; ++nPass ) {
for ( size_t * p = pKeyLast - 1; p >= pKeyFirst; --p ) {
func.m_cnt.nKeyExpected = *p;
if ( rSet.erase( *p, std::ref(func) ))
};
protected:
- template <class Set>
- void do_test( size_t nLoadFactor )
- {
- CPPUNIT_MSG( "Load factor=" << nLoadFactor );
-
- Set testSet( c_nMapSize, nLoadFactor );
- do_test_with( testSet );
- }
template <class Set>
- void do_test_with( Set& testSet )
+ void do_test( Set& testSet )
{
typedef Inserter<Set> InserterThread;
typedef Deleter<Set> DeleterThread;
- typedef Ensurer<Set> EnsurerThread;
+ typedef Updater<Set> UpdaterThread;
- m_pKeyArr = new size_t[ c_nMapSize ];
+ m_pKeyArr = new size_t[ c_nSetSize ];
m_pKeyFirst = m_pKeyArr;
- m_pKeyLast = m_pKeyFirst + c_nMapSize;
- for ( size_t i = 0; i < c_nMapSize; ++i )
+ m_pKeyLast = m_pKeyFirst + c_nSetSize;
+ for ( size_t i = 0; i < c_nSetSize; ++i )
m_pKeyArr[i] = i;
shuffle( m_pKeyFirst, m_pKeyLast );
CppUnitMini::ThreadPool pool( *this );
pool.add( new InserterThread( pool, testSet ), c_nInsertThreadCount );
pool.add( new DeleterThread( pool, testSet ), c_nDeleteThreadCount );
- pool.add( new EnsurerThread( pool, testSet ), c_nEnsureThreadCount );
+ pool.add( new UpdaterThread( pool, testSet ), c_nUpdateThreadCount );
pool.run();
CPPUNIT_MSG( " Duration=" << pool.avgDuration() );
size_t nDeleteFailed = 0;
size_t nDelValueSuccess = 0;
size_t nDelValueFailed = 0;
- size_t nEnsureFailed = 0;
- size_t nEnsureCreated = 0;
- size_t nEnsureModified = 0;
+ size_t nUpdateFailed = 0;
+ size_t nUpdateCreated = 0;
+ size_t nUpdateModified = 0;
size_t nEnsFuncCreated = 0;
size_t nEnsFuncModified = 0;
size_t nTestFunctorRef = 0;
nDelValueFailed += p->m_nValueFailed;
}
else {
- EnsurerThread * pEns = static_cast<EnsurerThread *>( *it );
- nEnsureCreated += pEns->m_nEnsureCreated;
- nEnsureModified += pEns->m_nEnsureExisted;
- nEnsureFailed += pEns->m_nEnsureFailed;
+ UpdaterThread * pEns = static_cast<UpdaterThread *>( *it );
+ nUpdateCreated += pEns->m_nUpdateCreated;
+ nUpdateModified += pEns->m_nUpdateExisted;
+ nUpdateFailed += pEns->m_nUpdateFailed;
nEnsFuncCreated += pEns->m_nFunctorCreated;
nEnsFuncModified += pEns->m_nFunctorModified;
}
<< " Del succ=" << nDeleteSuccess << "\n"
<< " : Ins fail=" << nInsertFailed
<< " Del fail=" << nDeleteFailed << "\n"
- << " : Ensure succ=" << (nEnsureCreated + nEnsureModified) << " fail=" << nEnsureFailed
- << " create=" << nEnsureCreated << " modify=" << nEnsureModified << "\n"
+ << " : Update succ=" << (nUpdateCreated + nUpdateModified) << " fail=" << nUpdateFailed
+ << " create=" << nUpdateCreated << " modify=" << nUpdateModified << "\n"
<< " Set size=" << testSet.size()
);
CPPUNIT_CHECK_EX( nDelValueFailed == 0, "Functor del failed=" << nDelValueFailed );
CPPUNIT_CHECK_EX( nDelValueSuccess == nDeleteSuccess, "Delete success=" << nDeleteSuccess << " functor=" << nDelValueSuccess );
- CPPUNIT_CHECK( nEnsureFailed == 0 );
+ CPPUNIT_CHECK( nUpdateFailed == 0 );
- CPPUNIT_CHECK_EX( nEnsureCreated == nEnsFuncCreated, "Ensure created=" << nEnsureCreated << " functor=" << nEnsFuncCreated );
- CPPUNIT_CHECK_EX( nEnsureModified == nEnsFuncModified, "Ensure modified=" << nEnsureModified << " functor=" << nEnsFuncModified );
+ CPPUNIT_CHECK_EX( nUpdateCreated == nEnsFuncCreated, "Update created=" << nUpdateCreated << " functor=" << nEnsFuncCreated );
+ CPPUNIT_CHECK_EX( nUpdateModified == nEnsFuncModified, "Update modified=" << nUpdateModified << " functor=" << nEnsFuncModified );
// nTestFunctorRef is call count of insert functor
CPPUNIT_CHECK_EX( nTestFunctorRef == nInsertSuccess, "nInsertSuccess=" << nInsertSuccess << " functor nTestFunctorRef=" << nTestFunctorRef );
}
template <class Set>
- void test()
+ void run_test()
{
CPPUNIT_MSG( "Thread count: insert=" << c_nInsertThreadCount
<< " delete=" << c_nDeleteThreadCount
- << " ensure=" << c_nEnsureThreadCount
+ << " ensure=" << c_nUpdateThreadCount
<< " pass count=" << c_nThreadPassCount
- << " map size=" << c_nMapSize
+ << " set size=" << c_nSetSize
);
- for ( size_t nLoadFactor = 1; nLoadFactor <= c_nMaxLoadFactor; nLoadFactor *= 2 ) {
- do_test<Set>( nLoadFactor );
+ if ( Set::c_bLoadFactorDepended ) {
+ for ( c_nLoadFactor = 1; c_nLoadFactor <= c_nMaxLoadFactor; c_nLoadFactor *= 2 ) {
+ Set s( *this );
+ do_test( s );
+ if ( c_bPrintGCState )
+ print_gc_state();
+ }
+ }
+ else {
+ Set s( *this );
+ do_test( s );
if ( c_bPrintGCState )
print_gc_state();
}
}
- template <class Set>
- void test_nolf()
- {
- CPPUNIT_MSG( "Thread count: insert=" << c_nInsertThreadCount
- << " delete=" << c_nDeleteThreadCount
- << " ensure=" << c_nEnsureThreadCount
- << " pass count=" << c_nThreadPassCount
- << " map size=" << c_nMapSize
- );
-
- Set s;
- do_test_with( s );
- if ( c_bPrintGCState )
- print_gc_state();
- }
-
- void setUpParams( const CppUnitMini::TestCfg& cfg ) {
- c_nInsertThreadCount = cfg.getULong("InsertThreadCount", 4 );
- c_nDeleteThreadCount = cfg.getULong("DeleteThreadCount", 4 );
- c_nEnsureThreadCount = cfg.getULong("EnsureThreadCount", 4 );
- c_nThreadPassCount = cfg.getULong("ThreadPassCount", 4 );
- c_nMapSize = cfg.getULong("MapSize", 1000000 );
- c_nMaxLoadFactor = cfg.getULong("MaxLoadFactor", 8 );
- c_bPrintGCState = cfg.getBool("PrintGCStateFlag", true );
- }
-
- void run_MichaelSet(const char *in_name, bool invert = false);
- void run_SplitList(const char *in_name, bool invert = false);
- void run_StripedSet(const char *in_name, bool invert = false);
- void run_RefinableSet(const char *in_name, bool invert = false);
- void run_CuckooSet(const char *in_name, bool invert = false);
- void run_SkipListSet(const char *in_name, bool invert = false);
- void run_EllenBinTreeSet(const char *in_name, bool invert = false);
-
- typedef CppUnitMini::TestCase Base;
- virtual void myRun(const char *in_name, bool invert = false)
- {
- setUpParams( m_Cfg.get( "Map_InsDel_func" ));
-
- run_MichaelSet(in_name, invert);
- run_SplitList(in_name, invert);
- run_SkipListSet(in_name, invert);
- run_EllenBinTreeSet(in_name, invert);
- run_StripedSet(in_name, invert);
- run_RefinableSet(in_name, invert);
- run_CuckooSet(in_name, invert);
-
- endTestCase();
- }
-
+ void setUpParams( const CppUnitMini::TestCfg& cfg );
# include "set2/set_defs.h"
CDSUNIT_DECLARE_MichaelSet
+ CDSUNIT_DECLARE_SkipListSet
CDSUNIT_DECLARE_SplitList
CDSUNIT_DECLARE_StripedSet
CDSUNIT_DECLARE_RefinableSet
CDSUNIT_DECLARE_CuckooSet
- CDSUNIT_DECLARE_SkipListSet
CDSUNIT_DECLARE_EllenBinTreeSet
+ CPPUNIT_TEST_SUITE_(Set_InsDel_func, "Map_InsDel_func")
+ CDSUNIT_TEST_MichaelSet
+ CDSUNIT_TEST_SplitList
+ CDSUNIT_TEST_SkipListSet
+ CDSUNIT_TEST_EllenBinTreeSet
+ CDSUNIT_TEST_StripedSet
+ CDSUNIT_TEST_RefinableSet
+ CDSUNIT_TEST_CuckooSet
+
+ //CDSUNIT_TEST_MultiLevelHashSet // the test is not suitable
+ CPPUNIT_TEST_SUITE_END();
+
};
} // namespace set2
#include "set2/set_insdel_func.h"
#include "set2/set_type_cuckoo.h"
-namespace set2 {
- CDSUNIT_DEFINE_CuckooSet( cc::cuckoo::implementation_tag, Set_InsDel_func )
-
- CPPUNIT_TEST_SUITE_PART( Set_InsDel_func, run_CuckooSet )
- CDSUNIT_TEST_CuckooSet
- CPPUNIT_TEST_SUITE_END_PART()
+#undef TEST_CASE
+#define TEST_CASE(TAG, X) void Set_InsDel_func::X() { run_test<typename set_type< TAG, key_type, value_type>::X>(); }
+#include "set2/set_defs.h"
+namespace set2 {
+ CDSUNIT_DECLARE_CuckooSet
} // namespace set2
#include "set2/set_insdel_func.h"
#include "set2/set_type_ellen_bintree.h"
-namespace set2 {
- CDSUNIT_DEFINE_EllenBinTreeSet( cc::ellen_bintree::implementation_tag, Set_InsDel_func )
-
- CPPUNIT_TEST_SUITE_PART( Set_InsDel_func, run_EllenBinTreeSet )
- CDSUNIT_TEST_EllenBinTreeSet
- CPPUNIT_TEST_SUITE_END_PART()
+#undef TEST_CASE
+#define TEST_CASE(TAG, X) void Set_InsDel_func::X() { run_test<typename set_type< TAG, key_type, value_type>::X>(); }
+#include "set2/set_defs.h"
+namespace set2 {
+ CDSUNIT_DECLARE_EllenBinTreeSet
} // namespace set2
--- /dev/null
+//$$CDS-header$$
+
+#include "set2/set_insdel_func.h"
+#include "set2/set_type_michael.h"
+
+#undef TEST_CASE
+#define TEST_CASE(TAG, X) void Set_InsDel_func::X() { run_test<typename set_type< TAG, key_type, value_type>::X>(); }
+#include "set2/set_defs.h"
+
+namespace set2 {
+ CDSUNIT_DECLARE_MichaelSet
+} // namespace set2
+++ /dev/null
-//$$CDS-header$$
-
-#include "set2/set_insdel_func.h"
-#include "set2/set_type_striped.h"
-
-namespace set2 {
- CDSUNIT_DEFINE_RefinableSet( cc::striped_set::implementation_tag, Set_InsDel_func )
-
- CPPUNIT_TEST_SUITE_PART( Set_InsDel_func, run_RefinableSet )
- CDSUNIT_TEST_RefinableSet
- CPPUNIT_TEST_SUITE_END_PART()
-
-} // namespace set2
#include "set2/set_insdel_func.h"
#include "set2/set_type_skip_list.h"
-namespace set2 {
- CDSUNIT_DEFINE_SkipListSet(cc::skip_list::implementation_tag, Set_InsDel_func)
+#undef TEST_CASE
+#define TEST_CASE(TAG, X) void Set_InsDel_func::X() { run_test<typename set_type< TAG, key_type, value_type>::X>(); }
+#include "set2/set_defs.h"
- CPPUNIT_TEST_SUITE_PART( Set_InsDel_func, run_SkipListSet )
- CDSUNIT_TEST_SkipListSet
- CPPUNIT_TEST_SUITE_END_PART()
+namespace set2 {
+ CDSUNIT_DECLARE_SkipListSet
} // namespace set2
#include "set2/set_insdel_func.h"
#include "set2/set_type_split_list.h"
-namespace set2 {
- CDSUNIT_DEFINE_SplitList(cc::split_list::implementation_tag, Set_InsDel_func)
-
- CPPUNIT_TEST_SUITE_PART( Set_InsDel_func, run_SplitList )
- CDSUNIT_TEST_SplitList
- CPPUNIT_TEST_SUITE_END_PART()
+#undef TEST_CASE
+#define TEST_CASE(TAG, X) void Set_InsDel_func::X() { run_test<typename set_type< TAG, key_type, value_type>::X>(); }
+#include "set2/set_defs.h"
+namespace set2 {
+ CDSUNIT_DECLARE_SplitList
} // namespace set2
#include "set2/set_insdel_func.h"
#include "set2/set_type_striped.h"
-namespace set2 {
- CDSUNIT_DEFINE_StripedSet( cc::striped_set::implementation_tag, Set_InsDel_func )
-
- CPPUNIT_TEST_SUITE_PART( Set_InsDel_func, run_StripedSet )
- CDSUNIT_TEST_StripedSet
- CPPUNIT_TEST_SUITE_END_PART()
+#undef TEST_CASE
+#define TEST_CASE(TAG, X) void Set_InsDel_func::X() { run_test<typename set_type< TAG, key_type, value_type>::X>(); }
+#include "set2/set_defs.h"
+namespace set2 {
+ CDSUNIT_DECLARE_StripedSet
+ CDSUNIT_DECLARE_RefinableSet
} // namespace set2
namespace set2 {
+ struct tag_StripedSet;
+
template <typename Key, typename Val>
- struct set_type< cc::striped_set::implementation_tag, Key, Val >: public set_type_base< Key, Val >
+ struct set_type< tag_StripedSet, Key, Val >: public set_type_base< Key, Val >
{
typedef set_type_base< Key, Val > base_class;
typedef typename base_class::key_val key_val;
resizing_policy_t m_placeHolder;
public:
- StripedHashSet_seq( size_t nCapacity, size_t nLoadFactor )
- : base_class( nCapacity / nLoadFactor / 16, *(new(&m_placeHolder) resizing_policy_t( nLoadFactor )) )
+ template <class Config>
+ StripedHashSet_seq( Config const& cfg )
+ : base_class( cfg.c_nSetSize / cfg.c_nLoadFactor / 16, *(new(&m_placeHolder) resizing_policy_t( cfg.c_nLoadFactor )) )
{}
+ /*
template <typename Q, typename Less>
- bool erase_with( Q const& v, Less /*pred*/ )
+ bool erase_with( Q const& v, Less pred )
{
return base_class::erase( v );
}
+ */
+
+ // for testing
+ static CDS_CONSTEXPR bool const c_bExtractSupported = false;
+ static CDS_CONSTEXPR bool const c_bLoadFactorDepended = true;
};
template <class BucketEntry, typename... Options>
resizing_policy_t m_placeHolder;
public:
- StripedHashSet_seq_rational( size_t nCapacity, size_t nDenominator ) // LoadFactor = 1 / nDenominator
- : base_class( nCapacity * nDenominator / 16, *(new(&m_placeHolder) resizing_policy_t( 1, nDenominator )) )
+ template <class Config>
+ StripedHashSet_seq_rational( Config const& cfg ) // LoadFactor = 1 / nDenominator
+ : base_class( cfg.c_nSetSize / cfg.c_nLoadFactor / 16, *(new(&m_placeHolder) resizing_policy_t( 1, cfg.c_nLoadFactor )) )
{}
+ /*
template <typename Q, typename Less>
- bool erase_with( Q const& v, Less /*pred*/ )
+ bool erase_with( Q const& v, Less pred )
{
return base_class::erase( v );
}
+ */
+
+ // for testing
+ static CDS_CONSTEXPR bool const c_bExtractSupported = false;
+ static CDS_CONSTEXPR bool const c_bLoadFactorDepended = true;
};
// for non-sequential ordered containers
resizing_policy_t m_placeHolder;
public:
- StripedHashSet_ord( size_t /*nCapacity*/, size_t nLoadFactor )
- : base_class( 0, *(new(&m_placeHolder) resizing_policy_t( nLoadFactor * 1024 )) )
+ template <class Config>
+ StripedHashSet_ord( Config const& cfg )
+ : base_class( 0, *(new(&m_placeHolder) resizing_policy_t( cfg.c_nMaxLoadFactor * 1024 )) )
{}
+ /*
template <typename Q, typename Less>
- bool erase_with( Q const& v, Less /*pred*/ )
+ bool erase_with( Q const& v, Less pred )
{
return base_class::erase( v );
}
+ */
+
+ // for testing
+ static CDS_CONSTEXPR bool const c_bExtractSupported = false;
+ static CDS_CONSTEXPR bool const c_bLoadFactorDepended = false;
};
template <class BucketEntry, typename... Options>
resizing_policy_t m_placeHolder;
public:
- StripedHashSet_ord_rational( size_t /*nCapacity*/, size_t nDenominator ) // LoadFactor = 1 / nDenominator
- : base_class( 0, *(new(&m_placeHolder) resizing_policy_t( 1024, nDenominator )) )
+ template <class Config>
+ StripedHashSet_ord_rational( Config const& cfg ) // LoadFactor = 1 / nDenominator
+ : base_class( 0, *(new(&m_placeHolder) resizing_policy_t( 1024, cfg.c_nLoadFactor )))
{}
+ /*
template <typename Q, typename Less>
- bool erase_with( Q const& v, Less /*pred*/ )
+ bool erase_with( Q const& v, Less pred )
{
return base_class::erase( v );
}
+ */
+
+ // for testing
+ static CDS_CONSTEXPR bool const c_bExtractSupported = false;
+ static CDS_CONSTEXPR bool const c_bLoadFactorDepended = true;
};
typedef StripedHashSet_seq<
resizing_policy_t m_placeHolder;
public:
- RefinableHashSet_seq( size_t nCapacity, size_t nLoadFactor )
- : base_class( nCapacity / nLoadFactor / 16, *(new(&m_placeHolder) resizing_policy_t( nLoadFactor )) )
+ template <class Config>
+ RefinableHashSet_seq( Config const& cfg )
+ : base_class( cfg.c_nSetSize / cfg.c_nLoadFactor / 16, *(new(&m_placeHolder) resizing_policy_t( cfg.c_nLoadFactor )) )
{}
+ /*
template <typename Q, typename Less>
- bool erase_with( Q const& v, Less /*pred*/ )
+ bool erase_with( Q const& v, Less pred )
{
return base_class::erase( v );
}
+ */
+
+ // for testing
+ static CDS_CONSTEXPR bool const c_bExtractSupported = false;
+ static CDS_CONSTEXPR bool const c_bLoadFactorDepended = true;
};
template <class BucketEntry, typename... Options>
resizing_policy_t m_placeHolder;
public:
- RefinableHashSet_seq_rational( size_t nCapacity, size_t nDenominator ) // LoadFactor = 1 / nDenominator
- : base_class( nCapacity * nDenominator / 16, *(new(&m_placeHolder) resizing_policy_t( 1, nDenominator )) )
+ template <class Config>
+ RefinableHashSet_seq_rational( Config const& cfg ) // LoadFactor = 1 / nDenominator
+ : base_class( cfg.c_nSetSize / cfg.c_nLoadFactor / 16, *(new(&m_placeHolder) resizing_policy_t( 1, cfg.c_nLoadFactor )))
{}
+ /*
template <typename Q, typename Less>
- bool erase_with( Q const& v, Less /*pred*/ )
+ bool erase_with( Q const& v, Less pred )
{
return base_class::erase( v );
}
+ */
+
+ // for testing
+ static CDS_CONSTEXPR bool const c_bExtractSupported = false;
+ static CDS_CONSTEXPR bool const c_bLoadFactorDepended = true;
};
// for non-sequential ordered containers
resizing_policy_t m_placeHolder;
public:
- RefinableHashSet_ord( size_t /*nCapacity*/, size_t nLoadFactor )
- : base_class( 0, *(new(&m_placeHolder) resizing_policy_t( nLoadFactor * 1024 )) )
+ template <class Config>
+ RefinableHashSet_ord( Config const& cfg )
+ : base_class( 0, *(new(&m_placeHolder) resizing_policy_t( cfg.c_nMaxLoadFactor * 1024 )) )
{}
+ /*
template <typename Q, typename Less>
- bool erase_with( Q const& v, Less /*pred*/ )
+ bool erase_with( Q const& v, Less pred )
{
return base_class::erase( v );
}
+ */
+
+ // for testing
+ static CDS_CONSTEXPR bool const c_bExtractSupported = false;
+ static CDS_CONSTEXPR bool const c_bLoadFactorDepended = false;
};
template <class BucketEntry, typename... Options>
resizing_policy_t m_placeHolder;
public:
- RefinableHashSet_ord_rational( size_t /*nCapacity*/, size_t nDenominator ) // LoadFactor = 1 / nDenominator
- : base_class( 0, *(new(&m_placeHolder) resizing_policy_t( 1024, nDenominator )) )
+ template <class Config>
+ RefinableHashSet_ord_rational( Config const& cfg ) // LoadFactor = 1 / nDenominator
+ : base_class( 0, *(new(&m_placeHolder) resizing_policy_t( 1024, cfg.c_nLoadFactor )))
{}
+ /*
template <typename Q, typename Less>
- bool erase_with( Q const& v, Less /*pred*/ )
+ bool erase_with( Q const& v, Less pred )
{
return base_class::erase( v );
}
+ */
+
+ // for testing
+ static CDS_CONSTEXPR bool const c_bExtractSupported = false;
+ static CDS_CONSTEXPR bool const c_bLoadFactorDepended = true;
};
typedef RefinableHashSet_seq<