Added different bit_reversal algo to SplitListSet/Map stress test
[libcds.git] / test / stress / map / map_type_skip_list.h
index 959cfe2484f75813b4549f29b9c73cfe3bcb672f..a916133c4eba44f7a9c94fd43a2ad2968aa6cc11 100644 (file)
@@ -1,11 +1,11 @@
 /*
     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/
-    
+
     Redistribution and use in source and binary forms, with or without
     modification, are permitted provided that the following conditions are met:
 
@@ -25,7 +25,7 @@
     SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
     CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
     OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.     
+    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
 #ifndef CDSUNIT_MAP_TYPE_SKIP_LIST_H
@@ -52,6 +52,22 @@ namespace map {
             : base_class()
         {}
 
+        std::pair<Key, bool> extract_min_key()
+        {
+            auto xp = base_class::extract_min();
+            if ( xp )
+                return std::make_pair( xp->first, true );
+            return std::make_pair( Key(), false );
+        }
+
+        std::pair<Key, bool> extract_max_key()
+        {
+            auto xp = base_class::extract_max();
+            if ( xp )
+                return std::make_pair( xp->first, true );
+            return std::make_pair( Key(), false );
+        }
+
         // for testing
         static CDS_CONSTEXPR bool const c_bExtractSupported = true;
         static CDS_CONSTEXPR bool const c_bLoadFactorDepended = false;
@@ -243,77 +259,136 @@ namespace map {
     }
 
 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
-#   define CDSSTRESS_SkipListMap_SHRCU( fixture, test_case, key_type, value_type ) \
-        CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_shb_less_pascal,        key_type, value_type ) \
-        CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_sht_less_pascal,        key_type, value_type ) \
+
+#if defined(CDS_STRESS_TEST_LEVEL) && CDS_STRESS_TEST_LEVEL > 1
+#   define CDSSTRESS_SkipListMap_SHRCU_2( fixture, test_case, key_type, value_type ) \
         CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_shb_less_pascal_seqcst, key_type, value_type ) \
         CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_sht_less_pascal_seqcst, key_type, value_type ) \
+
+#else
+#   define CDSSTRESS_SkipListMap_SHRCU_2( fixture, test_case, key_type, value_type )
+#endif
+
+#if defined(CDS_STRESS_TEST_LEVEL) && CDS_STRESS_TEST_LEVEL == 1
+#   define CDSSTRESS_SkipListMap_SHRCU_1( fixture, test_case, key_type, value_type ) \
+        CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_sht_less_pascal,        key_type, value_type ) \
         CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_shb_less_pascal_stat,   key_type, value_type ) \
-        CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_sht_less_pascal_stat,   key_type, value_type ) \
         CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_shb_cmp_pascal,         key_type, value_type ) \
-        CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_sht_cmp_pascal,         key_type, value_type ) \
         CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_shb_cmp_pascal_stat,    key_type, value_type ) \
-        CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_sht_cmp_pascal_stat,    key_type, value_type ) \
-        CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_shb_less_xorshift,      key_type, value_type ) \
         CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_sht_less_xorshift,      key_type, value_type ) \
         CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_shb_less_xorshift_stat, key_type, value_type ) \
-        CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_sht_less_xorshift_stat, key_type, value_type ) \
         CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_shb_cmp_xorshift,       key_type, value_type ) \
+        CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_sht_cmp_xorshift_stat,  key_type, value_type ) \
+
+#else
+#   define CDSSTRESS_SkipListMap_SHRCU_1( fixture, test_case, key_type, value_type )
+#endif
+
+
+#   define CDSSTRESS_SkipListMap_SHRCU( fixture, test_case, key_type, value_type ) \
+        CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_shb_less_pascal,        key_type, value_type ) \
+        CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_sht_less_pascal_stat,   key_type, value_type ) \
+        CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_sht_cmp_pascal,         key_type, value_type ) \
+        CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_sht_cmp_pascal_stat,    key_type, value_type ) \
+        CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_shb_less_xorshift,      key_type, value_type ) \
+        CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_sht_less_xorshift_stat, key_type, value_type ) \
         CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_sht_cmp_xorshift,       key_type, value_type ) \
         CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_shb_cmp_xorshift_stat,  key_type, value_type ) \
-        CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_sht_cmp_xorshift_stat,  key_type, value_type ) \
+        CDSSTRESS_SkipListMap_SHRCU_1( fixture, test_case, key_type, value_type ) \
+        CDSSTRESS_SkipListMap_SHRCU_2( fixture, test_case, key_type, value_type ) \
 
 #else
 #   define CDSSTRESS_SkipListMap_SHRCU( fixture, test_case, key_type, value_type )
 #endif
 
-#define CDSSTRESS_SkipListMap( fixture, test_case, key_type, value_type ) \
+#if defined(CDS_STRESS_TEST_LEVEL) && CDS_STRESS_TEST_LEVEL > 1
+#   define CDSSTRESS_SkipListMap_HP_2( fixture, test_case, key_type, value_type ) \
+        CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_hp_less_pascal_seqcst,      key_type, value_type ) \
+        CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_dhp_less_pascal_seqcst,     key_type, value_type ) \
+
+#   define CDSSTRESS_SkipListMap_RCU_2( fixture, test_case, key_type, value_type ) \
+        CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_gpi_less_pascal_seqcst, key_type, value_type ) \
+        CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_gpb_less_pascal_seqcst, key_type, value_type ) \
+        CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_gpt_less_pascal_seqcst, key_type, value_type ) \
+
+#   define CDSSTRESS_SkipListMap_2( fixture, test_case, key_type, value_type ) \
+        CDSSTRESS_SkipListMap_HP_2( fixture, test_case, key_type, value_type ) \
+        CDSSTRESS_SkipListMap_RCU_2( fixture, test_case, key_type, value_type ) \
+
+#else
+#   define CDSSTRESS_SkipListMap_HP_2( fixture, test_case, key_type, value_type )
+#   define CDSSTRESS_SkipListMap_RCU_2( fixture, test_case, key_type, value_type )
+#   define CDSSTRESS_SkipListMap_2( fixture, test_case, key_type, value_type )
+#endif
+
+#if defined(CDS_STRESS_TEST_LEVEL) && CDS_STRESS_TEST_LEVEL == 1
+#   define CDSSTRESS_SkipListMap_HP_1( fixture, test_case, key_type, value_type ) \
+        CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_dhp_less_pascal,            key_type, value_type ) \
+        CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_hp_less_pascal_stat,        key_type, value_type ) \
+        CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_hp_cmp_pascal,              key_type, value_type ) \
+        CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_dhp_cmp_pascal_stat,        key_type, value_type ) \
+        CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_dhp_less_xorshift,          key_type, value_type ) \
+        CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_hp_less_xorshift_stat,      key_type, value_type ) \
+        CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_hp_cmp_xorshift,            key_type, value_type ) \
+        CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_dhp_cmp_xorshift_stat,      key_type, value_type ) \
+
+#   define CDSSTRESS_SkipListMap_RCU_1( fixture, test_case, key_type, value_type ) \
+        CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_gpb_less_pascal,        key_type, value_type ) \
+        CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_gpi_less_pascal_stat,   key_type, value_type ) \
+        CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_gpt_less_pascal_stat,   key_type, value_type ) \
+        CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_gpi_cmp_pascal,         key_type, value_type ) \
+        CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_gpt_cmp_pascal,         key_type, value_type ) \
+        CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_gpb_cmp_pascal_stat,    key_type, value_type ) \
+        CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_gpb_less_xorshift,      key_type, value_type ) \
+        CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_gpi_less_xorshift_stat, key_type, value_type ) \
+        CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_gpt_less_xorshift_stat, key_type, value_type ) \
+        CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_gpi_cmp_xorshift,       key_type, value_type ) \
+        CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_gpt_cmp_xorshift,       key_type, value_type ) \
+        CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_gpb_cmp_xorshift_stat,  key_type, value_type ) \
+        CDSSTRESS_SkipListMap_SHRCU( fixture, test_case, key_type, value_type )
+
+#   define CDSSTRESS_SkipListMap_1( fixture, test_case, key_type, value_type ) \
+        CDSSTRESS_SkipListMap_HP_1( fixture, test_case, key_type, value_type ) \
+        CDSSTRESS_SkipListMap_RCU_1( fixture, test_case, key_type, value_type ) \
+
+#else
+#   define CDSSTRESS_SkipListMap_HP_1( fixture, test_case, key_type, value_type )
+#   define CDSSTRESS_SkipListMap_RCU_1( fixture, test_case, key_type, value_type )
+#   define CDSSTRESS_SkipListMap_1( fixture, test_case, key_type, value_type )
+#endif
+
+
+#define CDSSTRESS_SkipListMap_HP( fixture, test_case, key_type, value_type ) \
     CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_hp_less_pascal,             key_type, value_type ) \
-    CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_dhp_less_pascal,            key_type, value_type ) \
+    CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_dhp_less_pascal_stat,       key_type, value_type ) \
+    CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_dhp_cmp_pascal,             key_type, value_type ) \
+    CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_hp_cmp_pascal_stat,         key_type, value_type ) \
+    CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_hp_less_xorshift,           key_type, value_type ) \
+    CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_dhp_less_xorshift_stat,     key_type, value_type ) \
+    CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_dhp_cmp_xorshift,           key_type, value_type ) \
+    CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_hp_cmp_xorshift_stat,       key_type, value_type ) \
+    CDSSTRESS_SkipListMap_HP_1( fixture, test_case, key_type, value_type ) \
+    CDSSTRESS_SkipListMap_HP_2( fixture, test_case, key_type, value_type ) \
+
+#define CDSSTRESS_SkipListMap_RCU( fixture, test_case, key_type, value_type ) \
     CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_gpi_less_pascal,        key_type, value_type ) \
-    CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_gpb_less_pascal,        key_type, value_type ) \
     CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_gpt_less_pascal,        key_type, value_type ) \
-    CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_hp_less_pascal_seqcst,      key_type, value_type ) \
-    CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_dhp_less_pascal_seqcst,     key_type, value_type ) \
-    CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_gpi_less_pascal_seqcst, key_type, value_type ) \
-    CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_gpb_less_pascal_seqcst, key_type, value_type ) \
-    CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_gpt_less_pascal_seqcst, key_type, value_type ) \
-    CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_hp_less_pascal_stat,        key_type, value_type ) \
-    CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_dhp_less_pascal_stat,       key_type, value_type ) \
-    CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_gpi_less_pascal_stat,   key_type, value_type ) \
     CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_gpb_less_pascal_stat,   key_type, value_type ) \
-    CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_gpt_less_pascal_stat,   key_type, value_type ) \
-    CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_hp_cmp_pascal,              key_type, value_type ) \
-    CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_dhp_cmp_pascal,             key_type, value_type ) \
-    CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_gpi_cmp_pascal,         key_type, value_type ) \
     CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_gpb_cmp_pascal,         key_type, value_type ) \
-    CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_gpt_cmp_pascal,         key_type, value_type ) \
-    CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_hp_cmp_pascal_stat,         key_type, value_type ) \
-    CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_dhp_cmp_pascal_stat,        key_type, value_type ) \
     CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_gpi_cmp_pascal_stat,    key_type, value_type ) \
-    CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_gpb_cmp_pascal_stat,    key_type, value_type ) \
     CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_gpt_cmp_pascal_stat,    key_type, value_type ) \
-    CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_hp_less_xorshift,           key_type, value_type ) \
-    CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_dhp_less_xorshift,          key_type, value_type ) \
     CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_gpi_less_xorshift,      key_type, value_type ) \
-    CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_gpb_less_xorshift,      key_type, value_type ) \
     CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_gpt_less_xorshift,      key_type, value_type ) \
-    CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_hp_less_xorshift_stat,      key_type, value_type ) \
-    CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_dhp_less_xorshift_stat,     key_type, value_type ) \
-    CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_gpi_less_xorshift_stat, key_type, value_type ) \
     CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_gpb_less_xorshift_stat, key_type, value_type ) \
-    CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_gpt_less_xorshift_stat, key_type, value_type ) \
-    CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_hp_cmp_xorshift,            key_type, value_type ) \
-    CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_dhp_cmp_xorshift,           key_type, value_type ) \
-    CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_gpi_cmp_xorshift,       key_type, value_type ) \
     CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_gpb_cmp_xorshift,       key_type, value_type ) \
-    CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_gpt_cmp_xorshift,       key_type, value_type ) \
-    CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_hp_cmp_xorshift_stat,       key_type, value_type ) \
-    CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_dhp_cmp_xorshift_stat,      key_type, value_type ) \
     CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_gpi_cmp_xorshift_stat,  key_type, value_type ) \
-    CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_gpb_cmp_xorshift_stat,  key_type, value_type ) \
     CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_rcu_gpt_cmp_xorshift_stat,  key_type, value_type ) \
-    CDSSTRESS_SkipListMap_SHRCU( fixture, test_case, key_type, value_type )
+    CDSSTRESS_SkipListMap_RCU_1( fixture, test_case, key_type, value_type ) \
+    CDSSTRESS_SkipListMap_RCU_2( fixture, test_case, key_type, value_type ) \
+
+#define CDSSTRESS_SkipListMap( fixture, test_case, key_type, value_type ) \
+    CDSSTRESS_SkipListMap_HP( fixture, test_case, key_type, value_type ) \
+    CDSSTRESS_SkipListMap_RCU( fixture, test_case, key_type, value_type ) \
 
 #define CDSSTRESS_SkipListMap_nogc( fixture, test_case, key_type, value_type ) \
     CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_nogc_less_pascal,           key_type, value_type ) \
@@ -326,5 +401,4 @@ namespace map {
     CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_nogc_cmp_xorshift,          key_type, value_type ) \
     CDSSTRESS_SkipListMap_case( fixture, test_case, SkipListMap_nogc_cmp_xorshift_stat,     key_type, value_type ) \
 
-
 #endif // ifndef CDSUNIT_MAP_TYPE_SKIP_LIST_H