From baa054c46de890b4578f2078f55ed5ca637ebd67 Mon Sep 17 00:00:00 2001 From: khizmax Date: Sat, 21 May 2016 19:04:17 +0300 Subject: [PATCH] Migrated map_find_int stress test to gtest --- projects/Win/vc14/cds.sln | 17 + projects/Win/vc14/stress-map-find_int.vcxproj | 273 ++++++++++++++++ .../vc14/stress-map-find_int.vcxproj.filters | 60 ++++ projects/source.unit.map.mk | 18 -- test/include/cds_test/fixture.h | 7 + test/stress/data/test-debug.conf | 4 +- test/stress/data/test-express.conf | 4 +- test/stress/data/test.conf | 4 +- test/stress/map/CMakeLists.txt | 2 + test/stress/map/find_int/CMakeLists.txt | 31 ++ test/stress/map/find_int/map_find_int.cpp | 132 ++++++++ test/stress/map/find_int/map_find_int.h | 240 +++++++++++++++ .../find_int/map_find_int_bronsonavltree.cpp | 38 +++ .../map/find_int/map_find_int_cuckoo.cpp | 38 +++ .../map/find_int/map_find_int_ellentree.cpp | 38 +++ .../find_int/map_find_int_feldman_hashset.cpp | 38 +++ .../map/find_int/map_find_int_michael.cpp | 39 +++ .../stress/map/find_int/map_find_int_skip.cpp | 39 +++ .../map/find_int/map_find_int_split.cpp | 39 +++ test/stress/map/find_int/map_find_int_std.cpp | 39 +++ .../map/find_int/map_find_int_striped.cpp | 38 +++ test/stress/map/map_type_split_list.h | 2 +- test/stress/map/map_type_std.h | 267 ++++++++++++++++ test/stress/map/map_type_striped.h | 291 ++++++++++++++++++ tests/unit/map2/map_find_int.h | 2 +- 25 files changed, 1674 insertions(+), 26 deletions(-) create mode 100644 projects/Win/vc14/stress-map-find_int.vcxproj create mode 100644 projects/Win/vc14/stress-map-find_int.vcxproj.filters create mode 100644 test/stress/map/find_int/CMakeLists.txt create mode 100644 test/stress/map/find_int/map_find_int.cpp create mode 100644 test/stress/map/find_int/map_find_int.h create mode 100644 test/stress/map/find_int/map_find_int_bronsonavltree.cpp create mode 100644 test/stress/map/find_int/map_find_int_cuckoo.cpp create mode 100644 test/stress/map/find_int/map_find_int_ellentree.cpp create mode 100644 test/stress/map/find_int/map_find_int_feldman_hashset.cpp create mode 100644 test/stress/map/find_int/map_find_int_michael.cpp create mode 100644 test/stress/map/find_int/map_find_int_skip.cpp create mode 100644 test/stress/map/find_int/map_find_int_split.cpp create mode 100644 test/stress/map/find_int/map_find_int_std.cpp create mode 100644 test/stress/map/find_int/map_find_int_striped.cpp create mode 100644 test/stress/map/map_type_std.h create mode 100644 test/stress/map/map_type_striped.h diff --git a/projects/Win/vc14/cds.sln b/projects/Win/vc14/cds.sln index b82ce5cb..a36390d6 100644 --- a/projects/Win/vc14/cds.sln +++ b/projects/Win/vc14/cds.sln @@ -223,10 +223,14 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Header Files", "Header File ..\..\..\test\stress\map\map_type_michael_list.h = ..\..\..\test\stress\map\map_type_michael_list.h ..\..\..\test\stress\map\map_type_skip_list.h = ..\..\..\test\stress\map\map_type_skip_list.h ..\..\..\test\stress\map\map_type_split_list.h = ..\..\..\test\stress\map\map_type_split_list.h + ..\..\..\test\stress\map\map_type_std.h = ..\..\..\test\stress\map\map_type_std.h + ..\..\..\test\stress\map\map_type_striped.h = ..\..\..\test\stress\map\map_type_striped.h EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "stress-map-delodd", "stress-map-delodd.vcxproj", "{DD432BE7-0CA8-47C6-B861-943A036C18EF}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "stress-map-find_int", "stress-map-find_int.vcxproj", "{3F36B97B-8028-4335-ADDD-20B6B81F87AF}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -585,6 +589,18 @@ Global {DD432BE7-0CA8-47C6-B861-943A036C18EF}.Release|Win32.Build.0 = Release|Win32 {DD432BE7-0CA8-47C6-B861-943A036C18EF}.Release|x64.ActiveCfg = Release|x64 {DD432BE7-0CA8-47C6-B861-943A036C18EF}.Release|x64.Build.0 = Release|x64 + {3F36B97B-8028-4335-ADDD-20B6B81F87AF}.Debug|Win32.ActiveCfg = Debug|Win32 + {3F36B97B-8028-4335-ADDD-20B6B81F87AF}.Debug|Win32.Build.0 = Debug|Win32 + {3F36B97B-8028-4335-ADDD-20B6B81F87AF}.Debug|x64.ActiveCfg = Debug|x64 + {3F36B97B-8028-4335-ADDD-20B6B81F87AF}.Debug|x64.Build.0 = Debug|x64 + {3F36B97B-8028-4335-ADDD-20B6B81F87AF}.DebugVLD|Win32.ActiveCfg = DebugVLD|Win32 + {3F36B97B-8028-4335-ADDD-20B6B81F87AF}.DebugVLD|Win32.Build.0 = DebugVLD|Win32 + {3F36B97B-8028-4335-ADDD-20B6B81F87AF}.DebugVLD|x64.ActiveCfg = DebugVLD|x64 + {3F36B97B-8028-4335-ADDD-20B6B81F87AF}.DebugVLD|x64.Build.0 = DebugVLD|x64 + {3F36B97B-8028-4335-ADDD-20B6B81F87AF}.Release|Win32.ActiveCfg = Release|Win32 + {3F36B97B-8028-4335-ADDD-20B6B81F87AF}.Release|Win32.Build.0 = Release|Win32 + {3F36B97B-8028-4335-ADDD-20B6B81F87AF}.Release|x64.ActiveCfg = Release|x64 + {3F36B97B-8028-4335-ADDD-20B6B81F87AF}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -623,6 +639,7 @@ Global {7D3EE35B-185D-40B5-88C2-7F9933426978} = {10E1FAF2-904D-405E-8AB5-6878A1B03346} {2C41747C-6CC6-4AE8-9EB8-EB8B954BBDB4} = {7D3EE35B-185D-40B5-88C2-7F9933426978} {DD432BE7-0CA8-47C6-B861-943A036C18EF} = {7D3EE35B-185D-40B5-88C2-7F9933426978} + {3F36B97B-8028-4335-ADDD-20B6B81F87AF} = {7D3EE35B-185D-40B5-88C2-7F9933426978} EndGlobalSection GlobalSection(DPCodeReviewSolutionGUID) = preSolution DPCodeReviewSolutionGUID = {00000000-0000-0000-0000-000000000000} diff --git a/projects/Win/vc14/stress-map-find_int.vcxproj b/projects/Win/vc14/stress-map-find_int.vcxproj new file mode 100644 index 00000000..65d0f609 --- /dev/null +++ b/projects/Win/vc14/stress-map-find_int.vcxproj @@ -0,0 +1,273 @@ + + + + + DebugVLD + Win32 + + + DebugVLD + x64 + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + + + + + _SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + _SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + _SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + _SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + _SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + _SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + + + + + + + 4503 + 4503 + 4503 + 4503 + 4503 + 4503 + + + + + + + + + + + + {3F36B97B-8028-4335-ADDD-20B6B81F87AF} + Win32Proj + stress_map_find_int + 8.1 + stress-map-find_int + + + + Application + true + v140 + Unicode + + + Application + true + v140 + Unicode + + + Application + false + v140 + true + Unicode + + + Application + true + v140 + Unicode + + + Application + true + v140 + Unicode + + + Application + false + v140 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + + + true + $(SolutionDir)..\..\..\bin\vc.$(PlatformToolset)\$(Platform)\ + $(SolutionDir)..\..\..\obj\vc.$(PlatformToolset)\$(Platform)\$(ProjectName)\$(Configuration)\ + $(ProjectName)_d + + + true + $(SolutionDir)..\..\..\bin\vc.$(PlatformToolset)\$(Platform)\ + $(SolutionDir)..\..\..\obj\vc.$(PlatformToolset)\$(Platform)\$(ProjectName)\$(Configuration)\ + $(ProjectName)_d + + + true + $(SolutionDir)..\..\..\bin\vc.$(PlatformToolset)\$(Platform)\ + $(SolutionDir)..\..\..\obj\vc.$(PlatformToolset)\$(Platform)\$(ProjectName)\$(Configuration)\ + $(ProjectName)_d + + + true + $(SolutionDir)..\..\..\bin\vc.$(PlatformToolset)\$(Platform)\ + $(SolutionDir)..\..\..\obj\vc.$(PlatformToolset)\$(Platform)\$(ProjectName)\$(Configuration)\ + $(ProjectName)_d + + + false + $(SolutionDir)..\..\..\bin\vc.$(PlatformToolset)\$(Platform)-release\ + $(SolutionDir)..\..\..\obj\vc.$(PlatformToolset)\$(Platform)\$(ProjectName)\$(Configuration)\ + + + false + $(SolutionDir)..\..\..\bin\vc.$(PlatformToolset)\$(Platform)-release\ + $(SolutionDir)..\..\..\obj\vc.$(PlatformToolset)\$(Platform)\$(ProjectName)\$(Configuration)\ + + + + NotUsing + Level3 + Disabled + _ENABLE_ATOMIC_ALIGNMENT_FIX;CDSUNIT_USE_URCU;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + $(SolutionDir)..\..\..;$(GTEST_ROOT)/include;$(SolutionDir)..\..\..\test\include;$(SolutionDir)..\..\..\test\stress\map;$(SolutionDir)..\..\..\test\stress\;$(BOOST_PATH);%(AdditionalIncludeDirectories) + /bigobj %(AdditionalOptions) + + + Console + true + $(GTEST_LIB32);$(GTEST_ROOT)/lib/x86;$(BOOST_PATH)/stage32/lib;$(BOOST_PATH)/stage/lib;$(BOOST_PATH)/bin;%(AdditionalLibraryDirectories);$(OutDir) + gtestd.lib;stress-framework_d.lib;%(AdditionalDependencies) + + + + + NotUsing + Level3 + Disabled + _ENABLE_ATOMIC_ALIGNMENT_FIX;CDSUNIT_USE_URCU;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + $(SolutionDir)..\..\..;$(GTEST_ROOT)/include;$(SolutionDir)..\..\..\test\include;$(SolutionDir)..\..\..\test\stress\map;$(SolutionDir)..\..\..\test\stress\;$(BOOST_PATH);%(AdditionalIncludeDirectories) + /bigobj %(AdditionalOptions) + + + Console + true + $(GTEST_LIB32);$(GTEST_ROOT)/lib/x86;$(BOOST_PATH)/stage32/lib;$(BOOST_PATH)/stage/lib;$(BOOST_PATH)/bin;%(AdditionalLibraryDirectories);$(OutDir) + gtestd.lib;stress-framework_d.lib;%(AdditionalDependencies) + + + + + NotUsing + Level3 + Disabled + _ENABLE_ATOMIC_ALIGNMENT_FIX;CDSUNIT_USE_URCU;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + $(SolutionDir)..\..\..;$(GTEST_ROOT)/include;$(SolutionDir)..\..\..\test\include;$(SolutionDir)..\..\..\test\stress\map;$(SolutionDir)..\..\..\test\stress\;$(BOOST_PATH);%(AdditionalIncludeDirectories) + /bigobj %(AdditionalOptions) + + + Console + true + $(GTEST_LIB64);$(GTEST_ROOT)/lib/x64;$(BOOST_PATH)/stage64/lib;$(BOOST_PATH)/bin;%(AdditionalLibraryDirectories);$(OutDir) + gtestd.lib;stress-framework_d.lib;%(AdditionalDependencies) + + + + + NotUsing + Level3 + Disabled + _ENABLE_ATOMIC_ALIGNMENT_FIX;CDSUNIT_USE_URCU;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + $(SolutionDir)..\..\..;$(GTEST_ROOT)/include;$(SolutionDir)..\..\..\test\include;$(SolutionDir)..\..\..\test\stress\map;$(SolutionDir)..\..\..\test\stress\;$(BOOST_PATH);%(AdditionalIncludeDirectories) + /bigobj %(AdditionalOptions) + + + Console + true + $(GTEST_LIB64);$(GTEST_ROOT)/lib/x64;$(BOOST_PATH)/stage64/lib;$(BOOST_PATH)/bin;%(AdditionalLibraryDirectories);$(OutDir) + gtestd.lib;stress-framework_d.lib;%(AdditionalDependencies) + + + + + Level3 + NotUsing + MaxSpeed + true + true + _ENABLE_ATOMIC_ALIGNMENT_FIX;CDSUNIT_USE_URCU;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + $(SolutionDir)..\..\..;$(GTEST_ROOT)/include;$(SolutionDir)..\..\..\test\include;$(SolutionDir)..\..\..\test\stress\map;$(SolutionDir)..\..\..\test\stress\;$(BOOST_PATH);%(AdditionalIncludeDirectories) + /bigobj %(AdditionalOptions) + + + Console + true + true + true + $(GTEST_LIB32);$(GTEST_ROOT)/lib/x86;$(BOOST_PATH)/stage32/lib;$(BOOST_PATH)/stage/lib;$(BOOST_PATH)/bin;%(AdditionalLibraryDirectories);$(OutDir) + gtest.lib;stress-framework.lib;%(AdditionalDependencies) + + + + + Level3 + NotUsing + MaxSpeed + true + true + _ENABLE_ATOMIC_ALIGNMENT_FIX;CDSUNIT_USE_URCU;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + $(SolutionDir)..\..\..;$(GTEST_ROOT)/include;$(SolutionDir)..\..\..\test\include;$(SolutionDir)..\..\..\test\stress\map;$(SolutionDir)..\..\..\test\stress\;$(BOOST_PATH);%(AdditionalIncludeDirectories) + /bigobj %(AdditionalOptions) + + + Console + true + true + true + $(GTEST_LIB64);$(GTEST_ROOT)/lib/x64;$(BOOST_PATH)/stage64/lib;$(BOOST_PATH)/bin;%(AdditionalLibraryDirectories);$(OutDir) + gtest.lib;stress-framework.lib;%(AdditionalDependencies) + + + + + + \ No newline at end of file diff --git a/projects/Win/vc14/stress-map-find_int.vcxproj.filters b/projects/Win/vc14/stress-map-find_int.vcxproj.filters new file mode 100644 index 00000000..86d671df --- /dev/null +++ b/projects/Win/vc14/stress-map-find_int.vcxproj.filters @@ -0,0 +1,60 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + + + + \ No newline at end of file diff --git a/projects/source.unit.map.mk b/projects/source.unit.map.mk index 1db4e0e2..cfe0ed60 100644 --- a/projects/source.unit.map.mk +++ b/projects/source.unit.map.mk @@ -1,15 +1,5 @@ CDSUNIT_MAP_SOURCES := \ - tests/unit/map2/map_find_int.cpp \ - tests/unit/map2/map_find_int_bronsonavltree.cpp \ - tests/unit/map2/map_find_int_cuckoo.cpp \ - tests/unit/map2/map_find_int_ellentree.cpp \ - tests/unit/map2/map_find_int_michael.cpp \ - tests/unit/map2/map_find_int_feldmanhashmap.cpp \ - tests/unit/map2/map_find_int_skip.cpp \ - tests/unit/map2/map_find_int_split.cpp \ - tests/unit/map2/map_find_int_striped.cpp \ - tests/unit/map2/map_find_int_std.cpp \ tests/unit/map2/map_find_string.cpp \ tests/unit/map2/map_find_string_bronsonavltree.cpp \ tests/unit/map2/map_find_string_cuckoo.cpp \ @@ -87,11 +77,3 @@ CDSUNIT_MAP_SOURCES := \ tests/unit/map2/map_insdelfind_split.cpp \ tests/unit/map2/map_insdelfind_striped.cpp \ tests/unit/map2/map_insdelfind_std.cpp \ - tests/unit/map2/map_delodd.cpp \ - tests/unit/map2/map_delodd_bronsonavltree.cpp \ - tests/unit/map2/map_delodd_cuckoo.cpp \ - tests/unit/map2/map_delodd_ellentree.cpp \ - tests/unit/map2/map_delodd_michael.cpp \ - tests/unit/map2/map_delodd_feldmanhashmap.cpp \ - tests/unit/map2/map_delodd_skip.cpp \ - tests/unit/map2/map_delodd_split.cpp \ diff --git a/test/include/cds_test/fixture.h b/test/include/cds_test/fixture.h index f8835e3a..ec56e327 100644 --- a/test/include/cds_test/fixture.h +++ b/test/include/cds_test/fixture.h @@ -52,6 +52,13 @@ namespace cds_test { std::shuffle( first, last, random_gen ); } + + static inline unsigned int rand( unsigned int nMax ) + { + double rnd = double( std::rand() ) / double( RAND_MAX ); + unsigned int n = (unsigned int)(rnd * nMax); + return n < nMax ? n : (n - 1); + } }; } // namespace cds_test diff --git a/test/stress/data/test-debug.conf b/test/stress/data/test-debug.conf index 82fae8db..f49868f9 100644 --- a/test/stress/data/test-debug.conf +++ b/test/stress/data/test-debug.conf @@ -165,13 +165,13 @@ MapSize=1000000 ThreadCount=4 MapSize=1000000 -[Map_find_int] +[map_find_int] ThreadCount=2 MapSize=10000 PercentExists=50 PassCount=2 MaxLoadFactor=4 -PrintGCStateFlag=1 + # *** Cuckoo map properties CuckooInitialSize=256 CuckooProbesetSize=8 diff --git a/test/stress/data/test-express.conf b/test/stress/data/test-express.conf index 04e7a10c..3450eaf5 100644 --- a/test/stress/data/test-express.conf +++ b/test/stress/data/test-express.conf @@ -159,13 +159,13 @@ PushThreadCount=4 PopThreadCount=4 QueueSize=500000 -[Map_find_int] +[map_find_int] ThreadCount=8 MapSize=100000 PercentExists=50 PassCount=2 MaxLoadFactor=4 -PrintGCStateFlag=1 + # *** Cuckoo map properties CuckooInitialSize=1024 CuckooProbesetSize=16 diff --git a/test/stress/data/test.conf b/test/stress/data/test.conf index 50aa398f..0b3d3dcc 100644 --- a/test/stress/data/test.conf +++ b/test/stress/data/test.conf @@ -158,13 +158,13 @@ PushThreadCount=4 PopThreadCount=4 QueueSize=10000000 -[Map_find_int] +[map_find_int] ThreadCount=8 MapSize=2000000 PercentExists=50 PassCount=1 MaxLoadFactor=4 -PrintGCStateFlag=1 + # *** Cuckoo map properties CuckooInitialSize=1024 CuckooProbesetSize=16 diff --git a/test/stress/map/CMakeLists.txt b/test/stress/map/CMakeLists.txt index ff70393f..1f821d07 100644 --- a/test/stress/map/CMakeLists.txt +++ b/test/stress/map/CMakeLists.txt @@ -2,6 +2,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCDSUNIT_USE_URCU") add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/delodd) +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/find_int) #add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/insdel_find) #add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/insdel_func) #add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/insdel_string) @@ -9,4 +10,5 @@ add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/delodd) add_custom_target( stress-map DEPENDS stress-map-delodd + stress-map-find-int ) diff --git a/test/stress/map/find_int/CMakeLists.txt b/test/stress/map/find_int/CMakeLists.txt new file mode 100644 index 00000000..3ec07cea --- /dev/null +++ b/test/stress/map/find_int/CMakeLists.txt @@ -0,0 +1,31 @@ +set(PACKAGE_NAME stress-map-find-int) + +set(CDSSTRESS_MAP_FIND_INT_SOURCES + ../../main.cpp + map_find_int.cpp + map_find_int_bronsonavltree.cpp + map_find_int_cuckoo.cpp + map_find_int_ellentree.cpp + map_find_int_feldman_hashset.cpp + map_find_int_michael.cpp + map_find_int_skip.cpp + map_find_int_split.cpp + map_find_int_std.cpp + map_find_int_striped.cpp +) + +include_directories( + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/.. +) + +add_executable(${PACKAGE_NAME} ${CDSSTRESS_MAP_FIND_INT_SOURCES} $) +target_link_libraries(${PACKAGE_NAME} + ${CDS_SHARED_LIBRARY} + ${GTEST_LIBRARY} + ${Boost_THREAD_LIBRARY} + ${Boost_SYSTEM_LIBRARY} + ${CMAKE_THREAD_LIBS_INIT} +) + +add_test(NAME ${PACKAGE_NAME} COMMAND ${PACKAGE_NAME} WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) \ No newline at end of file diff --git a/test/stress/map/find_int/map_find_int.cpp b/test/stress/map/find_int/map_find_int.cpp new file mode 100644 index 00000000..17b473cb --- /dev/null +++ b/test/stress/map/find_int/map_find_int.cpp @@ -0,0 +1,132 @@ +/* + This file is a part of libcds - Concurrent Data Structures library + + (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016 + + 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: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + 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. +*/ + +#include "map_find_int.h" + +namespace map { + + size_t Map_find_int::s_nThreadCount = 8; + size_t Map_find_int::s_nMapSize = 10000000; + size_t Map_find_int::s_nMaxLoadFactor = 8; + size_t Map_find_int::s_nPercentExists = 50; + size_t Map_find_int::s_nPassCount = 2; + + size_t Map_find_int::s_nCuckooInitialSize = 1024; + size_t Map_find_int::s_nCuckooProbesetSize = 16; + size_t Map_find_int::s_nCuckooProbesetThreshold = 0; + + size_t Map_find_int::s_nFeldmanMap_HeadBits = 10; + size_t Map_find_int::s_nFeldmanMap_ArrayBits = 4; + + + size_t Map_find_int::s_nLoadFactor = 1; + size_t Map_find_int::s_nRealMapSize = 0; + Map_find_int::value_vector Map_find_int::s_Data; + + void Map_find_int::generateSequence() + { + size_t nPercent = s_nPercentExists; + + if ( nPercent > 100 ) + nPercent = 100; + else if ( nPercent < 1 ) + nPercent = 1; + + s_nRealMapSize = 0; + + s_Data.resize( s_nMapSize ); + for ( size_t i = 0; i < s_nMapSize; ++i ) { + s_Data[i].nKey = i * 13; + s_Data[i].bExists = rand( 100 ) <= nPercent; + if ( s_Data[i].bExists ) + ++s_nRealMapSize; + } + shuffle( s_Data.begin(), s_Data.end() ); + } + + void Map_find_int::SetUpTestCase() + { + cds_test::config const& cfg = get_config( "map_find_int" ); + + s_nMapSize = cfg.get_size_t( "MapSize", s_nMapSize ); + if ( s_nMapSize < 1000 ) + s_nMapSize = 1000; + + s_nThreadCount = cfg.get_size_t( "ThreadCount", s_nThreadCount ); + if ( s_nThreadCount == 0 ) + s_nThreadCount = 1; + + s_nMaxLoadFactor = cfg.get_size_t( "MaxLoadFactor", s_nMaxLoadFactor ); + if ( s_nMaxLoadFactor == 0 ) + s_nMaxLoadFactor = 1; + + s_nCuckooInitialSize = cfg.get_size_t( "CuckooInitialSize", s_nCuckooInitialSize ); + if ( s_nCuckooInitialSize < 256 ) + s_nCuckooInitialSize = 256; + + s_nCuckooProbesetSize = cfg.get_size_t( "CuckooProbesetSize", s_nCuckooProbesetSize ); + if ( s_nCuckooProbesetSize < 8 ) + s_nCuckooProbesetSize = 8; + + s_nCuckooProbesetThreshold = cfg.get_size_t( "CuckooProbesetThreshold", s_nCuckooProbesetThreshold ); + + s_nFeldmanMap_HeadBits = cfg.get_size_t( "FeldmanMapHeadBits", s_nFeldmanMap_HeadBits ); + if ( s_nFeldmanMap_HeadBits == 0 ) + s_nFeldmanMap_HeadBits = 2; + + s_nFeldmanMap_ArrayBits = cfg.get_size_t( "FeldmanMapArrayBits", s_nFeldmanMap_ArrayBits ); + if ( s_nFeldmanMap_ArrayBits == 0 ) + s_nFeldmanMap_ArrayBits = 2; + + generateSequence(); + } + + void Map_find_int::TearDownTestCase() + { + s_Data.clear(); + } + + std::vector Map_find_int_LF::get_load_factors() + { + cds_test::config const& cfg = get_config( "map_find_int" ); + + s_nMaxLoadFactor = cfg.get_size_t( "MaxLoadFactor", s_nMaxLoadFactor ); + if ( s_nMaxLoadFactor == 0 ) + s_nMaxLoadFactor = 1; + + std::vector lf; + for ( size_t n = 1; n <= s_nMaxLoadFactor; n *= 2 ) + lf.push_back( n ); + + return lf; + } + + INSTANTIATE_TEST_CASE_P( a, Map_find_int_LF, ::testing::ValuesIn( Map_find_int_LF::get_load_factors() ) ); +} // namespace map diff --git a/test/stress/map/find_int/map_find_int.h b/test/stress/map/find_int/map_find_int.h new file mode 100644 index 00000000..f54c308f --- /dev/null +++ b/test/stress/map/find_int/map_find_int.h @@ -0,0 +1,240 @@ +/* + This file is a part of libcds - Concurrent Data Structures library + + (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016 + + 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: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + 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. +*/ + +#include "map_type.h" + +// find int test in map in mutithreaded mode +namespace map { + + class Map_find_int: public cds_test::stress_fixture + { + public: + static size_t s_nThreadCount; // thread count + static size_t s_nMapSize; // map size (count of searching item) + static size_t s_nPercentExists; // percent of existing keys in searching sequence + static size_t s_nPassCount; + static size_t s_nMaxLoadFactor; // maximum load factor + + static size_t s_nCuckooInitialSize; // initial size for CuckooMap + static size_t s_nCuckooProbesetSize; // CuckooMap probeset size (only for list-based probeset) + static size_t s_nCuckooProbesetThreshold; // CUckooMap probeset threshold (o - use default) + + static size_t s_nFeldmanMap_HeadBits; + static size_t s_nFeldmanMap_ArrayBits; + + static size_t s_nLoadFactor; // current load factor + + typedef size_t key_type; + struct value_type { + key_type nKey; // key + bool bExists; // true - key in map, false - key not in map + }; + + typedef std::vector value_vector; + static value_vector s_Data; + + static void SetUpTestCase(); + static void TearDownTestCase(); + + private: + static size_t s_nRealMapSize; + + static void generateSequence(); + + template + static bool check_result( Iterator const& it, Map const& map ) + { + return it != map.end(); + } + template + static bool check_result( bool b, Map const& ) + { + return b; + } + + template + class Worker: public cds_test::thread + { + typedef cds_test::thread base_class; + Map& m_Map; + + public: + struct Stat { + size_t nSuccess = 0; + size_t nFailed = 0; + }; + + Stat m_KeyExists; + Stat m_KeyNotExists; + + public: + Worker( cds_test::thread_pool& pool, Map& map ) + : base_class( pool ) + , m_Map( map ) + {} + + Worker( Worker& src ) + : base_class( src ) + , m_Map( src.m_Map ) + {} + + virtual thread * clone() + { + return new Worker( *this ); + } + + virtual void test() + { + size_t const nPassCount = s_nPassCount; + + Map& rMap = m_Map; + for ( size_t nPass = 0; nPass < nPassCount; ++nPass ) { + if ( id() & 1 ) { + auto itEnd = s_Data.cend(); + for ( auto it = s_Data.cbegin(); it != itEnd; ++it ) { + auto bFound = rMap.contains( it->nKey ); + if ( it->bExists ) { + if ( check_result( bFound, rMap )) + ++m_KeyExists.nSuccess; + else + ++m_KeyExists.nFailed; + } + else { + if ( check_result( bFound, rMap )) + ++m_KeyNotExists.nFailed; + else + ++m_KeyNotExists.nSuccess; + } + } + } + else { + auto itEnd = s_Data.crend(); + for ( auto it = s_Data.crbegin(); it != itEnd; ++it ) { + auto bFound = rMap.contains( it->nKey ); + if ( it->bExists ) { + if ( check_result( bFound, rMap )) + ++m_KeyExists.nSuccess; + else + ++m_KeyExists.nFailed; + } + else { + if ( check_result( bFound, rMap )) + ++m_KeyNotExists.nFailed; + else + ++m_KeyNotExists.nSuccess; + } + } + } + } + } + }; + + protected: + + template + void test( Map& testMap ) + { + typedef Worker worker; + + // Fill the map + for ( auto const& it: s_Data ) { + if ( it.bExists ) { + EXPECT_TRUE( check_result( testMap.insert( it.nKey, it ), testMap )); + } + } + + propout() << std::make_pair( "thread_count", s_nThreadCount ) + << std::make_pair( "map_size", s_nMapSize ) + << std::make_pair( "percent_exist", s_nPercentExists ) + << std::make_pair( "pass_count", s_nPassCount ); + + cds_test::thread_pool& pool = get_pool(); + pool.add( new worker( pool, testMap ), s_nThreadCount ); + + std::chrono::milliseconds duration = pool.run(); + + propout() << std::make_pair( "duration", duration ); + + size_t nExistSuccess = 0; + size_t nExistFailed = 0; + size_t nMissingSuccess = 0; + size_t nMissingFailed = 0; + + for ( size_t i = 0; i < pool.size(); ++i ) { + worker& w = static_cast( pool.get( i )); + nExistSuccess += w.m_KeyExists.nSuccess; + nExistFailed += w.m_KeyExists.nFailed; + nMissingSuccess += w.m_KeyNotExists.nSuccess; + nMissingFailed += w.m_KeyNotExists.nFailed; + + EXPECT_EQ( w.m_KeyExists.nFailed, 0 ) << "thread " << i; + EXPECT_EQ( w.m_KeyExists.nSuccess, s_nRealMapSize * s_nPassCount ) << "thread " << i; + EXPECT_EQ( w.m_KeyNotExists.nFailed, 0 ) << "thread " << i; + EXPECT_EQ( w.m_KeyNotExists.nSuccess, (s_Data.size() - s_nRealMapSize) * s_nPassCount ) << "thread " << i; + } + + propout() + << std::make_pair( "exist_found", nExistSuccess ) + << std::make_pair( "exist_not_found", nExistFailed ) // must = 0 + << std::make_pair( "missing_not_found", nMissingSuccess ) + << std::make_pair( "missing_found", nMissingFailed ); // must = 0 + + check_before_cleanup( testMap ); + + testMap.clear(); + additional_check( testMap ); + print_stat( propout(), testMap ); + additional_cleanup( testMap ); + } + + template + void run_test() + { + Map testMap( *this ); + test( testMap ); + } + }; + + class Map_find_int_LF: public Map_find_int + , public ::testing::WithParamInterface + { + public: + template + void run_test() + { + s_nLoadFactor = GetParam(); + propout() << std::make_pair( "load_factor", s_nLoadFactor ); + Map_find_int::run_test(); + } + + static std::vector get_load_factors(); + }; + +} // namespace map diff --git a/test/stress/map/find_int/map_find_int_bronsonavltree.cpp b/test/stress/map/find_int/map_find_int_bronsonavltree.cpp new file mode 100644 index 00000000..5fa22a92 --- /dev/null +++ b/test/stress/map/find_int/map_find_int_bronsonavltree.cpp @@ -0,0 +1,38 @@ +/* + This file is a part of libcds - Concurrent Data Structures library + + (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016 + + 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: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + 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. +*/ + +#include "map_find_int.h" +#include "map_type_bronson_avltree.h" + +namespace map { + + CDSSTRESS_BronsonAVLTreeMap( Map_find_int, run_test, size_t, Map_find_int::value_type ) + +} // namespace map diff --git a/test/stress/map/find_int/map_find_int_cuckoo.cpp b/test/stress/map/find_int/map_find_int_cuckoo.cpp new file mode 100644 index 00000000..8c036aa6 --- /dev/null +++ b/test/stress/map/find_int/map_find_int_cuckoo.cpp @@ -0,0 +1,38 @@ +/* + This file is a part of libcds - Concurrent Data Structures library + + (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016 + + 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: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + 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. +*/ + +#include "map_find_int.h" +#include "map_type_cuckoo.h" + +namespace map { + + CDSSTRESS_CuckooMap( Map_find_int, run_test, size_t, Map_find_int::value_type ) + +} // namespace map diff --git a/test/stress/map/find_int/map_find_int_ellentree.cpp b/test/stress/map/find_int/map_find_int_ellentree.cpp new file mode 100644 index 00000000..a820bdc8 --- /dev/null +++ b/test/stress/map/find_int/map_find_int_ellentree.cpp @@ -0,0 +1,38 @@ +/* + This file is a part of libcds - Concurrent Data Structures library + + (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016 + + 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: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + 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. +*/ + +#include "map_find_int.h" +#include "map_type_ellen_bintree.h" + +namespace map { + + CDSSTRESS_EllenBinTreeMap( Map_find_int, run_test, size_t, Map_find_int::value_type ) + +} // namespace map diff --git a/test/stress/map/find_int/map_find_int_feldman_hashset.cpp b/test/stress/map/find_int/map_find_int_feldman_hashset.cpp new file mode 100644 index 00000000..56b9cc4f --- /dev/null +++ b/test/stress/map/find_int/map_find_int_feldman_hashset.cpp @@ -0,0 +1,38 @@ +/* + This file is a part of libcds - Concurrent Data Structures library + + (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016 + + 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: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + 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. +*/ + +#include "map_find_int.h" +#include "map_type_feldman_hashmap.h" + +namespace map { + + CDSSTRESS_FeldmanHashMap_fixed( Map_find_int, run_test, size_t, Map_find_int::value_type ) + +} // namespace map diff --git a/test/stress/map/find_int/map_find_int_michael.cpp b/test/stress/map/find_int/map_find_int_michael.cpp new file mode 100644 index 00000000..8f7a7176 --- /dev/null +++ b/test/stress/map/find_int/map_find_int_michael.cpp @@ -0,0 +1,39 @@ +/* + This file is a part of libcds - Concurrent Data Structures library + + (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016 + + 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: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + 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. +*/ + +#include "map_find_int.h" +#include "map_type_michael.h" + +namespace map { + + CDSSTRESS_MichaelMap( Map_find_int_LF, run_test, size_t, Map_find_int::value_type ) + CDSSTRESS_MichaelMap_nogc( Map_find_int_LF, run_test, size_t, Map_find_int::value_type ) + +} // namespace map diff --git a/test/stress/map/find_int/map_find_int_skip.cpp b/test/stress/map/find_int/map_find_int_skip.cpp new file mode 100644 index 00000000..fe19b436 --- /dev/null +++ b/test/stress/map/find_int/map_find_int_skip.cpp @@ -0,0 +1,39 @@ +/* + This file is a part of libcds - Concurrent Data Structures library + + (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016 + + 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: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + 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. +*/ + +#include "map_find_int.h" +#include "map_type_skip_list.h" + +namespace map { + + CDSSTRESS_SkipListMap( Map_find_int, run_test, size_t, Map_find_int::value_type ) + CDSSTRESS_SkipListMap_nogc( Map_find_int, run_test, size_t, Map_find_int::value_type ) + +} // namespace map diff --git a/test/stress/map/find_int/map_find_int_split.cpp b/test/stress/map/find_int/map_find_int_split.cpp new file mode 100644 index 00000000..59bdd932 --- /dev/null +++ b/test/stress/map/find_int/map_find_int_split.cpp @@ -0,0 +1,39 @@ +/* + This file is a part of libcds - Concurrent Data Structures library + + (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016 + + 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: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + 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. +*/ + +#include "map_find_int.h" +#include "map_type_split_list.h" + +namespace map { + + CDSSTRESS_SplitListMap( Map_find_int_LF, run_test, size_t, Map_find_int::value_type ) + CDSSTRESS_SplitListMap_nogc( Map_find_int_LF, run_test, size_t, Map_find_int::value_type ) + +} // namespace map diff --git a/test/stress/map/find_int/map_find_int_std.cpp b/test/stress/map/find_int/map_find_int_std.cpp new file mode 100644 index 00000000..a3557cd4 --- /dev/null +++ b/test/stress/map/find_int/map_find_int_std.cpp @@ -0,0 +1,39 @@ +/* + This file is a part of libcds - Concurrent Data Structures library + + (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016 + + 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: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + 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. +*/ + +#include "map_find_int.h" +#include "map_type_std.h" + +namespace map { + + CDSSTRESS_StdMap( Map_find_int, run_test, size_t, Map_find_int::value_type ) + CDSSTRESS_StdMap_nolock( Map_find_int, run_test, size_t, Map_find_int::value_type ) + +} // namespace map diff --git a/test/stress/map/find_int/map_find_int_striped.cpp b/test/stress/map/find_int/map_find_int_striped.cpp new file mode 100644 index 00000000..be5c0a13 --- /dev/null +++ b/test/stress/map/find_int/map_find_int_striped.cpp @@ -0,0 +1,38 @@ +/* + This file is a part of libcds - Concurrent Data Structures library + + (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016 + + 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: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + 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. +*/ + +#include "map_find_int.h" +#include "map_type_striped.h" + +namespace map { + + CDSSTRESS_StripedMap( Map_find_int_LF, run_test, size_t, Map_find_int::value_type ) + +} // namespace map diff --git a/test/stress/map/map_type_split_list.h b/test/stress/map/map_type_split_list.h index 10e4d6b6..b419e7bf 100644 --- a/test/stress/map/map_type_split_list.h +++ b/test/stress/map/map_type_split_list.h @@ -74,7 +74,7 @@ namespace map { public: template SplitListMap( Config const& cfg) - : base_class( cfg.c_nMapSize, cfg.c_nLoadFactor ) + : base_class( cfg.s_nMapSize, cfg.s_nLoadFactor ) {} template diff --git a/test/stress/map/map_type_std.h b/test/stress/map/map_type_std.h new file mode 100644 index 00000000..30ce916a --- /dev/null +++ b/test/stress/map/map_type_std.h @@ -0,0 +1,267 @@ +/* + This file is a part of libcds - Concurrent Data Structures library + + (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016 + + 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: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + 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. +*/ + +#ifndef CDSUNIT_MAP_TYPE_STD_H +#define CDSUNIT_MAP_TYPE_STD_H + +#include "map_type.h" + +#include +#include + +namespace map { + + struct empty_lock + { + void lock() {} + void unlock() {} + }; + + template >::other + > + class StdMap: public std::map, Alloc> + { + Lock m_lock; + typedef std::unique_lock scoped_lock; + typedef std::map, Alloc> base_class; + public: + typedef typename base_class::mapped_type value_type; + typedef typename base_class::value_type pair_type; + typedef size_t item_counter; + + StdMap() + {} + + template + StdMap( Config const& ) + {} + + bool contains( const Key& key ) + { + scoped_lock al( m_lock ); + return base_class::find( key ) != base_class::end(); + } + + bool insert( const Key& key, const Value& val ) + { + scoped_lock al( m_lock ); + return base_class::insert( typename base_class::value_type( key, val ) ).second; + } + + template + bool insert( const Key& key, const T& val, Func func ) + { + scoped_lock al( m_lock ); + std::pair pRet = base_class::insert( typename base_class::value_type( key, Value() ) ); + if ( pRet.second ) { + func( pRet.first->second, val ); + return true; + } + return false; + } + + template + std::pair update( const T& key, Func func, bool /*bAllowInsert*/ = true ) + { + scoped_lock al( m_lock ); + std::pair pRet = base_class::insert( typename base_class::value_type( key, Value() ) ); + if ( pRet.second ) { + func( true, *pRet.first ); + return std::make_pair( true, true ); + } + else { + func( false, *pRet.first ); + return std::make_pair( true, false ); + } + } + + bool erase( const Key& key ) + { + scoped_lock al( m_lock ); + return base_class::erase( key ) != 0; + } + + template + bool erase( const T& key, Func func ) + { + scoped_lock al( m_lock ); + typename base_class::iterator it = base_class::find( key ); + if ( it != base_class::end() ) { + func( (*it) ); + base_class::erase( it ); + return true; + } + return false; + } + + std::ostream& dump( std::ostream& stm ) { return stm; } + + + // for testing + static CDS_CONSTEXPR bool const c_bExtractSupported = false; + static CDS_CONSTEXPR bool const c_bLoadFactorDepended = false; + static CDS_CONSTEXPR bool const c_bEraseExactKey = false; + }; + + template >::other + > + class StdHashMap + : public std::unordered_map< + Key, Value + , std::hash + , std::equal_to + , Alloc + > + { + public: + Lock m_lock; + typedef std::unique_lock scoped_lock; + typedef std::unordered_map< + Key, Value + , std::hash + , std::equal_to + , Alloc + > base_class; + public: + typedef typename base_class::mapped_type value_type; + typedef size_t item_counter; + + StdHashMap() + {} + + template + StdHashMap( Config const& ) + {} + + bool contains( const Key& key ) + { + scoped_lock al( m_lock ); + return base_class::find( key ) != base_class::end(); + } + + bool insert( const Key& key, const Value& val ) + { + scoped_lock al( m_lock ); + return base_class::insert( typename base_class::value_type(key, val)).second; + } + + template + bool insert( const Key& key, const T& val, Func func ) + { + scoped_lock al( m_lock ); + std::pair pRet = base_class::insert( typename base_class::value_type(key, Value() )); + if ( pRet.second ) { + func( pRet.first->second, val ); + return true; + } + return false; + } + + template + std::pair update( const T& key, Func func, bool /*bAllowInsert*/ = true ) + { + scoped_lock al( m_lock ); + std::pair pRet = base_class::insert( typename base_class::value_type( key, Value() )); + if ( pRet.second ) { + func( true, *pRet.first ); + return std::make_pair( true, true ); + } + else { + func( false, *pRet.first ); + return std::make_pair( true, false ); + } + } + + bool erase( const Key& key ) + { + scoped_lock al( m_lock ); + return base_class::erase( key ) != 0; + } + + template + bool erase( const T& key, Func func ) + { + scoped_lock al( m_lock ); + typename base_class::iterator it = base_class::find( key ); + if ( it != base_class::end() ) { + func( *it ); + return base_class::erase( key ) != 0; + } + return false; + } + + std::ostream& dump( std::ostream& stm ) { return stm; } + + + // for testing + static CDS_CONSTEXPR bool const c_bExtractSupported = false; + static CDS_CONSTEXPR bool const c_bLoadFactorDepended = false; + static CDS_CONSTEXPR bool const c_bEraseExactKey = false; + }; + + struct tag_StdMap; + + template + struct map_type< tag_StdMap, Key, Value >: public map_type_base< Key, Value > + { + typedef map_type_base< Key, Value > base_class; + typedef typename base_class::key_compare compare; + typedef typename base_class::key_less less; + + typedef StdMap< Key, Value, cds::sync::spin > StdMap_Spin; + typedef StdMap< Key, Value, std::mutex > StdMap_Mutex; + typedef StdMap< Key, Value, empty_lock> StdMap_NoLock; + + typedef StdHashMap< Key, Value, cds::sync::spin > StdHashMap_Spin; + typedef StdHashMap< Key, Value, std::mutex > StdHashMap_Mutex; + typedef StdHashMap< Key, Value, empty_lock > StdHashMap_NoLock; + }; +} // namespace map + +#define CDSSTRESS_StdMap_case( fixture, test_case, std_map_type, key_type, value_type ) \ + TEST_F( fixture, std_map_type ) \ + { \ + typedef map::map_type< tag_StdMap, key_type, value_type >::std_map_type map_type; \ + test_case(); \ + } + +#define CDSSTRESS_StdMap( fixture, test_case, key_type, value_type ) \ + CDSSTRESS_StdMap_case( fixture, test_case, StdMap_Spin, key_type, value_type ) \ + CDSSTRESS_StdMap_case( fixture, test_case, StdMap_Mutex, key_type, value_type ) \ + CDSSTRESS_StdMap_case( fixture, test_case, StdHashMap_Spin, key_type, value_type ) \ + CDSSTRESS_StdMap_case( fixture, test_case, StdHashMap_Mutex, key_type, value_type ) + +#define CDSSTRESS_StdMap_nolock( fixture, test_case, key_type, value_type ) \ + CDSSTRESS_StdMap_case( fixture, test_case, StdMap_NoLock, key_type, value_type ) \ + CDSSTRESS_StdMap_case( fixture, test_case, StdHashMap_NoLock, key_type, value_type ) + +#endif // ifndef CDSUNIT_MAP_TYPE_STD_H diff --git a/test/stress/map/map_type_striped.h b/test/stress/map/map_type_striped.h new file mode 100644 index 00000000..44773db7 --- /dev/null +++ b/test/stress/map/map_type_striped.h @@ -0,0 +1,291 @@ +/* + This file is a part of libcds - Concurrent Data Structures library + + (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016 + + 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: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + 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. +*/ + +#ifndef CDSUNIT_MAP_TYPE_STRIPED_H +#define CDSUNIT_MAP_TYPE_STRIPED_H + +#include "map_type.h" +#include +#include +#include + +#include +#if BOOST_VERSION >= 104800 +# include +# include +# include +# include +#endif +#include +#include + +namespace map { + + struct tag_StripedMap; + + template + struct map_type< tag_StripedMap, Key, Value >: public map_type_base< Key, Value > + { + typedef map_type_base< Key, Value > base_class; + typedef typename base_class::key_compare compare; + typedef typename base_class::key_less less; + typedef typename base_class::equal_to equal_to; + typedef typename base_class::key_hash hash; + typedef typename base_class::hash2 hash2; + + // for sequential containers + template + class StripedHashMap_seq: + public cc::StripedMap< BucketEntry, + co::mutex_policy< cc::striped_set::striping<> > + ,co::resizing_policy > + , Options... + > + { + typedef cc::StripedMap< BucketEntry, + co::mutex_policy< cc::striped_set::striping<> > + ,co::resizing_policy > + , Options... + > base_class; + typedef typename base_class::resizing_policy resizing_policy_t; + + resizing_policy_t m_placeHolder; + public: + template + StripedHashMap_seq( Config const& cfg ) + : base_class( cfg.s_nMapSize / cfg.s_nLoadFactor / 16, *(new(&m_placeHolder) resizing_policy_t( cfg.s_nLoadFactor )) ) + {} + + // for testing + static CDS_CONSTEXPR bool const c_bExtractSupported = false; + static CDS_CONSTEXPR bool const c_bLoadFactorDepended = true; + }; + + // for non-sequential ordered containers + template + class StripedHashMap_ord: + public cc::StripedMap< BucketEntry, + co::resizing_policy > + ,co::mutex_policy< cc::striped_set::striping<> > + , Options... + > + { + typedef cc::StripedMap< BucketEntry, + co::resizing_policy > + ,co::mutex_policy< cc::striped_set::striping<> > + , Options... + > base_class; + typedef typename base_class::resizing_policy resizing_policy_t; + + resizing_policy_t m_placeHolder; + public: + template + StripedHashMap_ord( Config const& cfg ) + : base_class( 0, *(new(&m_placeHolder) resizing_policy_t( cfg.s_nMaxLoadFactor * 1024 )) ) + {} + + // for testing + static CDS_CONSTEXPR bool const c_bExtractSupported = false; + static CDS_CONSTEXPR bool const c_bLoadFactorDepended = false; + }; + + + typedef StripedHashMap_seq< + std::list< std::pair< Key const, Value > > + , co::hash< hash2 > + , co::less< less > + > StripedMap_list; + + typedef StripedHashMap_ord< + std::unordered_map< Key, Value, hash, equal_to > + , co::hash< hash2 > + > StripedMap_hashmap; + + typedef StripedHashMap_ord< + std::map< Key, Value, less > + , co::hash< hash2 > + > StripedMap_map; + + typedef StripedHashMap_ord< + boost::unordered_map< Key, Value, hash, equal_to > + , co::hash< hash2 > + > StripedMap_boost_unordered_map; + +# if BOOST_VERSION >= 104800 + typedef StripedHashMap_seq< + boost::container::slist< std::pair< Key const, Value > > + , co::hash< hash2 > + , co::less< less > + > StripedMap_slist; + + typedef StripedHashMap_seq< + boost::container::list< std::pair< Key const, Value > > + , co::hash< hash2 > + , co::less< less > + > StripedMap_boost_list; + + typedef StripedHashMap_ord< + boost::container::map< Key, Value, less > + , co::hash< hash2 > + > StripedMap_boost_map; + + typedef StripedHashMap_ord< + boost::container::flat_map< Key, Value, less > + , co::hash< hash2 > + > StripedMap_boost_flat_map; +# endif // BOOST_VERSION >= 104800 + + + // *************************************************************************** + // RefinableHashMap + + // for sequential containers + template + class RefinableHashMap_seq: + public cc::StripedMap< BucketEntry, + co::resizing_policy > + ,co::mutex_policy< cc::striped_set::refinable<> > + , Options... + > + { + typedef cc::StripedMap< BucketEntry, + co::resizing_policy > + ,co::mutex_policy< cc::striped_set::refinable<> > + , Options... + > base_class; + typedef typename base_class::resizing_policy resizing_policy_t; + + resizing_policy_t m_placeHolder; + public: + template + RefinableHashMap_seq( Config const& cfg ) + : base_class( cfg.s_nMapSize / cfg.s_nLoadFactor / 16, *(new(&m_placeHolder) resizing_policy_t( cfg.s_nLoadFactor ))) + {} + + // for testing + static CDS_CONSTEXPR bool const c_bExtractSupported = false; + static CDS_CONSTEXPR bool const c_bLoadFactorDepended = true; + }; + + // for non-sequential ordered containers + template + class RefinableHashMap_ord: + public cc::StripedMap< BucketEntry, + co::resizing_policy > + ,co::mutex_policy< cc::striped_set::refinable<> > + , Options... + > + { + typedef cc::StripedMap< BucketEntry, + co::resizing_policy > + ,co::mutex_policy< cc::striped_set::refinable<> > + , Options... + > base_class; + typedef typename base_class::resizing_policy resizing_policy_t; + + resizing_policy_t m_placeHolder; + public: + template + RefinableHashMap_ord( Config const& cfg ) + : base_class( 0, *(new(&m_placeHolder) resizing_policy_t( cfg.s_nMaxLoadFactor * 1024 )) ) + {} + + // for testing + static CDS_CONSTEXPR bool const c_bExtractSupported = false; + static CDS_CONSTEXPR bool const c_bLoadFactorDepended = false; + }; + + + typedef RefinableHashMap_seq< + std::list< std::pair< Key const, Value > > + , co::hash< hash2 > + , co::less< less > + > RefinableMap_list; + +# if BOOST_VERSION >= 104800 + typedef RefinableHashMap_seq< + boost::container::slist< std::pair< Key const, Value > > + , co::hash< hash2 > + , co::less< less > + > RefinableMap_slist; +# endif + + typedef RefinableHashMap_ord< + std::map< Key, Value, less > + , co::hash< hash2 > + > RefinableMap_map; + + typedef RefinableHashMap_ord< + std::unordered_map< Key, Value, hash, equal_to > + , co::hash< hash2 > + > RefinableMap_hashmap; + + typedef RefinableHashMap_ord< + boost::unordered_map< Key, Value, hash, equal_to > + , co::hash< hash2 > + > RefinableMap_boost_unordered_map; + +# if BOOST_VERSION >= 104800 + typedef RefinableHashMap_seq< + boost::container::list< std::pair< Key const, Value > > + , co::hash< hash2 > + , co::less< less > + > RefinableMap_boost_list; + + typedef RefinableHashMap_ord< + boost::container::map< Key, Value, less > + , co::hash< hash2 > + > RefinableMap_boost_map; + + typedef RefinableHashMap_ord< + boost::container::flat_map< Key, Value, less > + , co::hash< hash2 > + > RefinableMap_boost_flat_map; +# endif // #if BOOST_VERSION >= 104800 + + }; +} // namespace map + +#define CDSSTRESS_StripedMap_case( fixture, test_case, striped_map_type, key_type, value_type ) \ + TEST_P( fixture, striped_map_type ) \ + { \ + typedef map::map_type< tag_StripedMap, key_type, value_type >::striped_map_type map_type; \ + test_case(); \ + } + +#define CDSSTRESS_StripedMap( fixture, test_case, key_type, value_type ) \ + CDSSTRESS_StripedMap_case( fixture, test_case, StripedMap_list, key_type, value_type ) \ + CDSSTRESS_StripedMap_case( fixture, test_case, StripedMap_hashmap, key_type, value_type ) \ + CDSSTRESS_StripedMap_case( fixture, test_case, StripedMap_map, key_type, value_type ) \ + CDSSTRESS_StripedMap_case( fixture, test_case, RefinableMap_list, key_type, value_type ) \ + CDSSTRESS_StripedMap_case( fixture, test_case, RefinableMap_map, key_type, value_type ) \ + CDSSTRESS_StripedMap_case( fixture, test_case, RefinableMap_hashmap, key_type, value_type ) \ + +#endif // ifndef CDSUNIT_MAP_TYPE_STRIPED_H diff --git a/tests/unit/map2/map_find_int.h b/tests/unit/map2/map_find_int.h index 0d2887b0..37939aa4 100644 --- a/tests/unit/map2/map_find_int.h +++ b/tests/unit/map2/map_find_int.h @@ -262,7 +262,7 @@ namespace map2 { CDSUNIT_DECLARE_StdMap CDSUNIT_DECLARE_StdMap_NoLock - CPPUNIT_TEST_SUITE(Map_find_int) + CPPUNIT_TEST_SUITE_(Map_find_int, "map_find_int") CDSUNIT_TEST_MichaelMap CDSUNIT_TEST_MichaelMap_nogc CDSUNIT_TEST_SplitList -- 2.34.1