issue #76: added cds::atomicity::cache_friendly_item_counter to avoid false sharing
[libcds.git] / test / stress / set / set_type_ellen_bintree.h
index 84cbcf1e184d22bad9dca1f2fa63ee2504af07e3..90c01e5432046c610f5c013439fbc1991df16956 100644 (file)
@@ -1,7 +1,7 @@
 /*
     This file is a part of libcds - Concurrent Data Structures library
 
-    (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016
+    (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2017
 
     Source code repo: http://github.com/khizmax/libcds/
     Download: http://sourceforge.net/projects/libcds/files/
@@ -129,11 +129,6 @@ namespace set {
                 typedef cc::ellen_bintree::internal_node< key_type, leaf_node >     internal_node;
                 typedef cc::ellen_bintree::update_desc< leaf_node, internal_node >  update_desc;
             };
-            struct sht {
-                typedef cc::ellen_bintree::node<rcu_sht, key_val>                   leaf_node;
-                typedef cc::ellen_bintree::internal_node< key_type, leaf_node >     internal_node;
-                typedef cc::ellen_bintree::update_desc< leaf_node, internal_node >  update_desc;
-            };
 #endif
         };
 
@@ -141,6 +136,7 @@ namespace set {
             cc::ellen_bintree::key_extractor< typename ellen_bintree_props::key_extractor >
             ,co::less< typename ellen_bintree_props::less >
             ,co::node_allocator< ellen_bintree_pool::internal_node_allocator< int > >
+            ,co::item_counter<cds::atomicity::cache_friendly_item_counter >
         >::type
         {};
 
@@ -180,12 +176,6 @@ namespace set {
             typedef cds::memory::pool_allocator< typename ellen_bintree_props::shb::update_desc, ellen_bintree_pool::update_desc_pool_accessor > update_desc_allocator;
         };
         typedef EllenBinTreeSet< rcu_shb, key_type, key_val, traits_EllenBinTreeSet_shb > EllenBinTreeSet_rcu_shb;
-
-        struct traits_EllenBinTreeSet_sht : public traits_EllenBinTreeSet
-        {
-            typedef cds::memory::pool_allocator< typename ellen_bintree_props::sht::update_desc, ellen_bintree_pool::update_desc_pool_accessor > update_desc_allocator;
-        };
-        typedef EllenBinTreeSet< rcu_sht, key_type, key_val, traits_EllenBinTreeSet_sht > EllenBinTreeSet_rcu_sht;
 #endif
 
         //
@@ -219,6 +209,7 @@ namespace set {
             ,co::less< typename ellen_bintree_props::less >
             ,co::node_allocator< ellen_bintree_pool::internal_node_allocator< int > >
             ,co::stat< cc::ellen_bintree::stat<> >
+            ,co::item_counter<cds::atomicity::cache_friendly_item_counter >
         >::type
         {};
 
@@ -258,12 +249,6 @@ namespace set {
             typedef cds::memory::pool_allocator< typename ellen_bintree_props::shb::update_desc, ellen_bintree_pool::update_desc_pool_accessor > update_desc_allocator;
         };
         typedef EllenBinTreeSet< rcu_shb, key_type, key_val, traits_EllenBinTreeSet_stat_shb > EllenBinTreeSet_rcu_shb_stat;
-
-        struct traits_EllenBinTreeSet_stat_sht : public traits_EllenBinTreeSet_stat
-        {
-            typedef cds::memory::pool_allocator< typename ellen_bintree_props::sht::update_desc, ellen_bintree_pool::update_desc_pool_accessor > update_desc_allocator;
-        };
-        typedef EllenBinTreeSet< rcu_sht, key_type, key_val, traits_EllenBinTreeSet_stat_sht > EllenBinTreeSet_rcu_sht_stat;
 #endif
 
     };
@@ -299,16 +284,6 @@ namespace set {
         //typedef EllenBinTreeSet<GC, Key, T, Traits> set_type;
         GC::force_dispose();
         ellen_bintree_check::check_stat( s.statistics());
-/*
-        bool const threaded_rcu = std::is_same<typename set_type::rcu_tag, cds::urcu::general_threaded_tag >::value
-#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
-            || std::is_same<typename set_type::rcu_tag, signal_threaded_tag >::value
-#endif
-;
-        if ( !threaded_rcu ) {
-            EXPECT_EQ( ellen_bintree_pool::internal_node_counter::m_nAlloc.get(), ellen_bintree_pool::internal_node_counter::m_nFree.get());
-        }
-*/
     }
 
     template <typename GC, typename Key, typename T, typename Traits>
@@ -324,39 +299,55 @@ namespace set {
     }
 } // namespace set
 
-#define CDSSTRESS_EllenBinTreeSet_case( fixture, test_case, ellen_set_type, key_type, value_type, level ) \
+#define CDSSTRESS_EllenBinTreeSet_case( fixture, test_case, ellen_set_type, key_type, value_type ) \
     TEST_F( fixture, ellen_set_type ) \
     { \
-        if ( !check_detail_level( level )) return; \
         typedef set::set_type< tag_EllenBinTreeSet, key_type, value_type >::ellen_set_type set_type; \
         test_case<set_type>(); \
     }
 
 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
 #   define CDSSTRESS_EllenBinTreeSet_SHRCU( fixture, test_case, key_type, value_type ) \
-        CDSSTRESS_EllenBinTreeSet_case( fixture, test_case, EllenBinTreeSet_rcu_shb,      key_type, value_type, 0 ) \
-        CDSSTRESS_EllenBinTreeSet_case( fixture, test_case, EllenBinTreeSet_rcu_sht,      key_type, value_type, 0 ) \
-        CDSSTRESS_EllenBinTreeSet_case( fixture, test_case, EllenBinTreeSet_rcu_shb_stat, key_type, value_type, 0 ) \
-        CDSSTRESS_EllenBinTreeSet_case( fixture, test_case, EllenBinTreeSet_rcu_sht_stat, key_type, value_type, 0 )
+        CDSSTRESS_EllenBinTreeSet_case( fixture, test_case, EllenBinTreeSet_rcu_shb,      key_type, value_type ) \
+        CDSSTRESS_EllenBinTreeSet_case( fixture, test_case, EllenBinTreeSet_rcu_shb_stat, key_type, value_type ) \
+
 #else
 #   define CDSSTRESS_EllenBinTreeSet_SHRCU( fixture, test_case, key_type, value_type )
 #endif
 
 
+#if defined(CDS_STRESS_TEST_LEVEL) && CDS_STRESS_TEST_LEVEL > 0
+#   define CDSSTRESS_EllenBinTreeSet_HP_1( fixture, test_case, key_type, value_type ) \
+        CDSSTRESS_EllenBinTreeSet_case( fixture, test_case, EllenBinTreeSet_yield_hp,       key_type, value_type ) \
+        CDSSTRESS_EllenBinTreeSet_case( fixture, test_case, EllenBinTreeSet_yield_dhp,      key_type, value_type ) \
+        CDSSTRESS_EllenBinTreeSet_case( fixture, test_case, EllenBinTreeSet_yield_rcu_gpb,  key_type, value_type ) \
+
+#   define CDSSTRESS_EllenBinTreeSet_RCU_1( fixture, test_case, key_type, value_type ) \
+        CDSSTRESS_EllenBinTreeSet_case( fixture, test_case, EllenBinTreeSet_rcu_gpi,        key_type, value_type ) \
+        CDSSTRESS_EllenBinTreeSet_case( fixture, test_case, EllenBinTreeSet_rcu_gpi_stat,   key_type, value_type ) \
+        CDSSTRESS_EllenBinTreeSet_SHRCU( fixture, test_case, key_type, value_type )
+
+#else
+#   define CDSSTRESS_EllenBinTreeSet_HP_1( fixture, test_case, key_type, value_type )
+#   define CDSSTRESS_EllenBinTreeSet_RCU_1( fixture, test_case, key_type, value_type )
+#endif
+
+#define CDSSTRESS_EllenBinTreeSet_HP( fixture, test_case, key_type, value_type ) \
+    CDSSTRESS_EllenBinTreeSet_case( fixture, test_case, EllenBinTreeSet_hp,             key_type, value_type ) \
+    CDSSTRESS_EllenBinTreeSet_case( fixture, test_case, EllenBinTreeSet_dhp,            key_type, value_type ) \
+    CDSSTRESS_EllenBinTreeSet_case( fixture, test_case, EllenBinTreeSet_hp_stat,        key_type, value_type ) \
+    CDSSTRESS_EllenBinTreeSet_case( fixture, test_case, EllenBinTreeSet_dhp_stat,       key_type, value_type ) \
+    CDSSTRESS_EllenBinTreeSet_HP_1( fixture, test_case, key_type, value_type ) \
+
+#define CDSSTRESS_EllenBinTreeSet_RCU( fixture, test_case, key_type, value_type ) \
+    CDSSTRESS_EllenBinTreeSet_case( fixture, test_case, EllenBinTreeSet_rcu_gpb,        key_type, value_type ) \
+    CDSSTRESS_EllenBinTreeSet_case( fixture, test_case, EllenBinTreeSet_rcu_gpt,        key_type, value_type ) \
+    CDSSTRESS_EllenBinTreeSet_case( fixture, test_case, EllenBinTreeSet_rcu_gpb_stat,   key_type, value_type ) \
+    CDSSTRESS_EllenBinTreeSet_case( fixture, test_case, EllenBinTreeSet_rcu_gpt_stat,   key_type, value_type ) \
+    CDSSTRESS_EllenBinTreeSet_RCU_1( fixture, test_case, key_type, value_type ) \
+
 #define CDSSTRESS_EllenBinTreeSet( fixture, test_case, key_type, value_type ) \
-    CDSSTRESS_EllenBinTreeSet_case( fixture, test_case, EllenBinTreeSet_hp,             key_type, value_type, 0 ) \
-    CDSSTRESS_EllenBinTreeSet_case( fixture, test_case, EllenBinTreeSet_dhp,            key_type, value_type, 0 ) \
-    CDSSTRESS_EllenBinTreeSet_case( fixture, test_case, EllenBinTreeSet_rcu_gpi,        key_type, value_type, 1 ) \
-    CDSSTRESS_EllenBinTreeSet_case( fixture, test_case, EllenBinTreeSet_rcu_gpb,        key_type, value_type, 0 ) \
-    CDSSTRESS_EllenBinTreeSet_case( fixture, test_case, EllenBinTreeSet_rcu_gpt,        key_type, value_type, 0 ) \
-    CDSSTRESS_EllenBinTreeSet_case( fixture, test_case, EllenBinTreeSet_yield_hp,       key_type, value_type, 1 ) \
-    CDSSTRESS_EllenBinTreeSet_case( fixture, test_case, EllenBinTreeSet_yield_dhp,      key_type, value_type, 1 ) \
-    CDSSTRESS_EllenBinTreeSet_case( fixture, test_case, EllenBinTreeSet_yield_rcu_gpb,  key_type, value_type, 1 ) \
-    CDSSTRESS_EllenBinTreeSet_case( fixture, test_case, EllenBinTreeSet_hp_stat,        key_type, value_type, 0 ) \
-    CDSSTRESS_EllenBinTreeSet_case( fixture, test_case, EllenBinTreeSet_dhp_stat,       key_type, value_type, 0 ) \
-    CDSSTRESS_EllenBinTreeSet_case( fixture, test_case, EllenBinTreeSet_rcu_gpi_stat,   key_type, value_type, 1 ) \
-    CDSSTRESS_EllenBinTreeSet_case( fixture, test_case, EllenBinTreeSet_rcu_gpb_stat,   key_type, value_type, 0 ) \
-    CDSSTRESS_EllenBinTreeSet_case( fixture, test_case, EllenBinTreeSet_rcu_gpt_stat,   key_type, value_type, 0 ) \
-    CDSSTRESS_EllenBinTreeSet_SHRCU( fixture, test_case, key_type, value_type )
+    CDSSTRESS_EllenBinTreeSet_HP( fixture, test_case, key_type, value_type ) \
+    CDSSTRESS_EllenBinTreeSet_RCU( fixture, test_case, key_type, value_type ) \
 
 #endif // #ifndef CDSUNIT_SET_TYPE_ELLEN_BINTREE_H