From b88919d210afe15078db3c9cbfa09224933bc25e Mon Sep 17 00:00:00 2001 From: khizmax Date: Tue, 8 Mar 2016 12:46:24 +0300 Subject: [PATCH] Migrated priority queue stress test to gtest framework --- build/Makefile | 21 +- projects/Win/vc14/cds.sln | 39 +- projects/Win/vc14/stress-pqueue.vcxproj | 251 +++++++ .../Win/vc14/stress-pqueue.vcxproj.filters | 39 + projects/Win/vc14/unit-pqueue.vcxproj | 316 --------- projects/source.unit.pqueue.mk | 5 - test/include/cds_test/stat_ellenbintree_out.h | 79 +++ test/include/cds_test/stat_skiplist_out.h | 89 +++ test/include/cds_test/thread.h | 13 +- test/stress/CMakeLists.txt | 1 + test/stress/data/test-debug.conf | 8 +- test/stress/data/test-express.conf | 8 +- test/stress/data/test.conf | 8 +- test/stress/michael_alloc.h | 95 --- test/stress/pqueue/CMakeLists.txt | 25 + .../stress/pqueue/item.h | 43 +- test/stress/pqueue/pop.cpp | 321 +++++++++ test/stress/pqueue/pqueue_type.h | 666 ++++++++++++++++++ test/stress/pqueue/push.cpp | 264 +++++++ test/stress/pqueue/push_pop.cpp | 317 +++++++++ tests/unit/CMakeLists.txt | 1 - tests/unit/pqueue/CMakeLists.txt | 10 - tests/unit/pqueue/ellen_bintree_pqueue.h | 141 ---- tests/unit/pqueue/pop.cpp | 275 -------- tests/unit/pqueue/pqueue_defs.h | 210 ------ tests/unit/pqueue/pqueue_type.h | 358 ---------- tests/unit/pqueue/push.cpp | 226 ------ tests/unit/pqueue/push_pop.cpp | 266 ------- tests/unit/pqueue/skiplist_pqueue.h | 140 ---- tests/unit/pqueue/std_pqueue.h | 125 ---- 30 files changed, 2127 insertions(+), 2233 deletions(-) create mode 100644 projects/Win/vc14/stress-pqueue.vcxproj create mode 100644 projects/Win/vc14/stress-pqueue.vcxproj.filters delete mode 100644 projects/Win/vc14/unit-pqueue.vcxproj delete mode 100644 projects/source.unit.pqueue.mk create mode 100644 test/include/cds_test/stat_ellenbintree_out.h create mode 100644 test/include/cds_test/stat_skiplist_out.h delete mode 100644 test/stress/michael_alloc.h create mode 100644 test/stress/pqueue/CMakeLists.txt rename tests/unit/pqueue/pqueue_item.h => test/stress/pqueue/item.h (69%) create mode 100644 test/stress/pqueue/pop.cpp create mode 100644 test/stress/pqueue/pqueue_type.h create mode 100644 test/stress/pqueue/push.cpp create mode 100644 test/stress/pqueue/push_pop.cpp delete mode 100644 tests/unit/pqueue/CMakeLists.txt delete mode 100644 tests/unit/pqueue/ellen_bintree_pqueue.h delete mode 100644 tests/unit/pqueue/pop.cpp delete mode 100644 tests/unit/pqueue/pqueue_defs.h delete mode 100644 tests/unit/pqueue/pqueue_type.h delete mode 100644 tests/unit/pqueue/push.cpp delete mode 100644 tests/unit/pqueue/push_pop.cpp delete mode 100644 tests/unit/pqueue/skiplist_pqueue.h delete mode 100644 tests/unit/pqueue/std_pqueue.h diff --git a/build/Makefile b/build/Makefile index b20d9eeb..24dd8011 100644 --- a/build/Makefile +++ b/build/Makefile @@ -144,15 +144,11 @@ include ../projects/source.unit.set.mk CDSUNIT_SET_SOURCES := $(CDSUNIT_SET_SOURCES:%.cpp=../%.cpp) CDSUNIT_SET_OBJS := $(CDSUNIT_SET_SOURCES:%.cpp=%.o) -include ../projects/source.unit.pqueue.mk -CDSUNIT_PQUEUE_SOURCES := $(CDSUNIT_PQUEUE_SOURCES:%.cpp=../%.cpp) -CDSUNIT_PQUEUE_OBJS := $(CDSUNIT_PQUEUE_SOURCES:%.cpp=%.o) - include ../projects/source.unit.misc.mk CDSUNIT_MISC_SOURCES := $(CDSUNIT_MISC_SOURCES:%.cpp=../%.cpp) CDSUNIT_MISC_OBJS := $(CDSUNIT_MISC_SOURCES:%.cpp=%.o) -TEST_OBJ_FILE := $(CDSUNIT_COMMON_FILE) $(CDSUNIT_MAP_OBJS) $(CDSUNIT_SET_OBJS) $(CDSUNIT_PQUEUE_OBJS) \ +TEST_OBJ_FILE := $(CDSUNIT_COMMON_FILE) $(CDSUNIT_MAP_OBJS) $(CDSUNIT_SET_OBJS) \ $(CDSUNIT_STACK_OBJS) $(CDSUNIT_MISC_OBJS) TEST_OBJ_FILE_DEPS := $(TEST_OBJ_FILE:%.o=%.d) @@ -162,13 +158,11 @@ $(TEST_OBJ_FILE): %.o: %.cpp CDSUNIT_MAP_EXE=$(BIN_PATH)/cdsu-map CDSUNIT_SET_EXE=$(BIN_PATH)/cdsu-set -CDSUNIT_PQUEUE_EXE=$(BIN_PATH)/cdsu-pqueue CDSUNIT_MISC_EXE=$(BIN_PATH)/cdsu-misc -CDSUNIT_EXE_FILES= $(CDSUNIT_MAP_EXE) $(CDSUNIT_SET_EXE) $(CDSUNIT_PQUEUE_EXE) $(CDSUNIT_MISC_EXE) +CDSUNIT_EXE_FILES= $(CDSUNIT_MAP_EXE) $(CDSUNIT_SET_EXE) $(CDSUNIT_MISC_EXE) unit-map: $(CDSUNIT_MAP_EXE) unit-set: $(CDSUNIT_SET_EXE) -unit-pqueue: $(CDSUNIT_PQUEUE_EXE) ifeq ($(platform),mingw) make_test : $(BIN_PATH)/test-hdr $(CDSUNIT_EXE_FILES) @@ -191,23 +185,17 @@ $(CDSUNIT_MAP_EXE) : $(CDSUNIT_MAP_OBJS) $(CDSUNIT_COMMON_FILE) $(TEST_COMMON_OB $(CDSUNIT_SET_EXE) : $(CDSUNIT_SET_OBJS) $(CDSUNIT_COMMON_FILE) $(TEST_COMMON_OBJS) $(CXX) $(LD_OPTS) -L$(BIN_PATH) $(CDSUNIT_SET_OBJS) $(CDSUNIT_COMMON_FILE) $(TEST_COMMON_OBJS) -o $@ $(LD_BOOST_THREAD_LIB) $(LD_TEST_COMMON_LIBS) $(LDLIBS) -$(CDSUNIT_PQUEUE_EXE) : $(CDSUNIT_PQUEUE_OBJS) $(CDSUNIT_COMMON_FILE) $(TEST_COMMON_OBJS) - $(CXX) $(LD_OPTS) -L$(BIN_PATH) $(CDSUNIT_PQUEUE_OBJS) $(CDSUNIT_COMMON_FILE) $(TEST_COMMON_OBJS) -o $@ $(LD_BOOST_THREAD_LIB) $(LD_TEST_COMMON_LIBS) $(LDLIBS) - $(CDSUNIT_MISC_EXE) : $(CDSUNIT_MISC_OBJS) $(CDSUNIT_COMMON_FILE) $(TEST_COMMON_OBJS) $(CXX) $(LD_OPTS) -L$(BIN_PATH) $(CDSUNIT_MISC_OBJS) $(CDSUNIT_COMMON_FILE) $(TEST_COMMON_OBJS) -o $@ $(LD_BOOST_THREAD_LIB) $(LD_TEST_COMMON_LIBS) $(LDLIBS) CDSUNIT_MAP_EXE_DBG=$(CDSUNIT_MAP_EXE)-d CDSUNIT_SET_EXE_DBG=$(CDSUNIT_SET_EXE)-d -CDSUNIT_PQUEUE_EXE_DBG=$(CDSUNIT_PQUEUE_EXE)-d CDSUNIT_MISC_EXE_DBG=$(CDSUNIT_MISC_EXE)-d -CDSUNIT_EXE_DBG_FILES= $(CDSUNIT_MAP_EXE_DBG) $(CDSUNIT_SET_EXE_DBG) $(CDSUNIT_PQUEUE_EXE_DBG) \ - $(CDSUNIT_MISC_EXE_DBG) +CDSUNIT_EXE_DBG_FILES= $(CDSUNIT_MAP_EXE_DBG) $(CDSUNIT_SET_EXE_DBG) $(CDSUNIT_MISC_EXE_DBG) unit-map-dbg: $(CDSUNIT_MAP_EXE_DBG) unit-set-dbg: $(CDSUNIT_SET_EXE_DBG) -unit-pqueue-dbg: $(CDSUNIT_PQUEUE_EXE_DBG) ifeq ($(platform),mingw) make_debug_test : $(BIN_PATH)/test-hdr-debug $(CDSUNIT_EXE_DBG_FILES) @@ -230,9 +218,6 @@ $(CDSUNIT_MAP_EXE_DBG) : $(CDSUNIT_MAP_OBJS) $(CDSUNIT_COMMON_FILE) $(TEST_COMMO $(CDSUNIT_SET_EXE_DBG) : $(CDSUNIT_SET_OBJS) $(CDSUNIT_COMMON_FILE) $(TEST_COMMON_OBJS) $(CXX) $(LD_OPTS) -L$(BIN_PATH) $(CDSUNIT_SET_OBJS) $(CDSUNIT_COMMON_FILE) $(TEST_COMMON_OBJS) -o $@ $(LD_BOOST_THREAD_LIB) $(LD_TEST_COMMON_DEBUG_LIBS) $(LDLIBS) -$(CDSUNIT_PQUEUE_EXE_DBG) : $(CDSUNIT_PQUEUE_OBJS) $(CDSUNIT_COMMON_FILE) $(TEST_COMMON_OBJS) - $(CXX) $(LD_OPTS) -L$(BIN_PATH) $(CDSUNIT_PQUEUE_OBJS) $(CDSUNIT_COMMON_FILE) $(TEST_COMMON_OBJS) -o $@ $(LD_BOOST_THREAD_LIB) $(LD_TEST_COMMON_DEBUG_LIBS) $(LDLIBS) - $(CDSUNIT_MISC_EXE_DBG) : $(CDSUNIT_MISC_OBJS) $(CDSUNIT_COMMON_FILE) $(TEST_COMMON_OBJS) $(CXX) $(LD_OPTS) -L$(BIN_PATH) $(CDSUNIT_MISC_OBJS) $(CDSUNIT_COMMON_FILE) $(TEST_COMMON_OBJS) -o $@ $(LD_BOOST_THREAD_LIB) $(LD_TEST_COMMON_DEBUG_LIBS) $(LDLIBS) diff --git a/projects/Win/vc14/cds.sln b/projects/Win/vc14/cds.sln index 0cf53c78..a9eb6c86 100644 --- a/projects/Win/vc14/cds.sln +++ b/projects/Win/vc14/cds.sln @@ -129,12 +129,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hdr-test-tree", "hdr-test-t {408FE9BC-44F0-4E6A-89FA-D6F952584239} = {408FE9BC-44F0-4E6A-89FA-D6F952584239} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unit-pqueue", "unit-pqueue.vcxproj", "{20B6C380-E96A-4CFF-BC17-D88AAE581919}" - ProjectSection(ProjectDependencies) = postProject - {61179F2F-07E1-490D-B64D-D85A90B6EF81} = {61179F2F-07E1-490D-B64D-D85A90B6EF81} - {408FE9BC-44F0-4E6A-89FA-D6F952584239} = {408FE9BC-44F0-4E6A-89FA-D6F952584239} - EndProjectSection -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unit-map-insdel-item", "unit-map-insdel-item.vcxproj", "{7521DD92-56FF-4ECA-93E5-CCE50862354B}" ProjectSection(ProjectDependencies) = postProject {61179F2F-07E1-490D-B64D-D85A90B6EF81} = {61179F2F-07E1-490D-B64D-D85A90B6EF81} @@ -164,6 +158,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "cds_test", "cds_test", "{3A ProjectSection(SolutionItems) = preProject ..\..\..\test\include\cds_test\check_size.h = ..\..\..\test\include\cds_test\check_size.h ..\..\..\test\include\cds_test\fixture.h = ..\..\..\test\include\cds_test\fixture.h + ..\..\..\test\include\cds_test\stat_ellenbintree_out.h = ..\..\..\test\include\cds_test\stat_ellenbintree_out.h + ..\..\..\test\include\cds_test\stat_skiplist_out.h = ..\..\..\test\include\cds_test\stat_skiplist_out.h ..\..\..\test\include\cds_test\stress_test.h = ..\..\..\test\include\cds_test\stress_test.h ..\..\..\test\include\cds_test\thread.h = ..\..\..\test\include\cds_test\thread.h EndProjectSection @@ -189,9 +185,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest-list", "gtest-list.vc EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "stress", "stress", "{10E1FAF2-904D-405E-8AB5-6878A1B03346}" - ProjectSection(SolutionItems) = preProject - ..\..\..\test\stress\michael_alloc.h = ..\..\..\test\stress\michael_alloc.h - EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "stress-framework", "stress-framework.vcxproj", "{A34CED07-A442-4FA1-81C4-F8B9CD3C832B}" EndProject @@ -207,6 +200,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "stress-queue", "stress-queu {408FE9BC-44F0-4E6A-89FA-D6F952584239} = {408FE9BC-44F0-4E6A-89FA-D6F952584239} EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "stress-pqueue", "stress-pqueue.vcxproj", "{51AC349E-B365-4FCF-8778-17A1534E4584}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -373,18 +368,6 @@ Global {6F834EAD-7B94-4979-A0F1-A662E3D30145}.Release|Win32.Build.0 = Release|Win32 {6F834EAD-7B94-4979-A0F1-A662E3D30145}.Release|x64.ActiveCfg = Release|x64 {6F834EAD-7B94-4979-A0F1-A662E3D30145}.Release|x64.Build.0 = Release|x64 - {20B6C380-E96A-4CFF-BC17-D88AAE581919}.Debug|Win32.ActiveCfg = Debug|Win32 - {20B6C380-E96A-4CFF-BC17-D88AAE581919}.Debug|Win32.Build.0 = Debug|Win32 - {20B6C380-E96A-4CFF-BC17-D88AAE581919}.Debug|x64.ActiveCfg = Debug|x64 - {20B6C380-E96A-4CFF-BC17-D88AAE581919}.Debug|x64.Build.0 = Debug|x64 - {20B6C380-E96A-4CFF-BC17-D88AAE581919}.DebugVLD|Win32.ActiveCfg = DebugVLD|Win32 - {20B6C380-E96A-4CFF-BC17-D88AAE581919}.DebugVLD|Win32.Build.0 = DebugVLD|Win32 - {20B6C380-E96A-4CFF-BC17-D88AAE581919}.DebugVLD|x64.ActiveCfg = DebugVLD|x64 - {20B6C380-E96A-4CFF-BC17-D88AAE581919}.DebugVLD|x64.Build.0 = DebugVLD|x64 - {20B6C380-E96A-4CFF-BC17-D88AAE581919}.Release|Win32.ActiveCfg = Release|Win32 - {20B6C380-E96A-4CFF-BC17-D88AAE581919}.Release|Win32.Build.0 = Release|Win32 - {20B6C380-E96A-4CFF-BC17-D88AAE581919}.Release|x64.ActiveCfg = Release|x64 - {20B6C380-E96A-4CFF-BC17-D88AAE581919}.Release|x64.Build.0 = Release|x64 {7521DD92-56FF-4ECA-93E5-CCE50862354B}.Debug|Win32.ActiveCfg = Debug|Win32 {7521DD92-56FF-4ECA-93E5-CCE50862354B}.Debug|Win32.Build.0 = Debug|Win32 {7521DD92-56FF-4ECA-93E5-CCE50862354B}.Debug|x64.ActiveCfg = Debug|x64 @@ -517,6 +500,18 @@ Global {50B2EC4B-A118-4E7B-ABC7-2EA8B685A58C}.Release|Win32.Build.0 = Release|Win32 {50B2EC4B-A118-4E7B-ABC7-2EA8B685A58C}.Release|x64.ActiveCfg = Release|x64 {50B2EC4B-A118-4E7B-ABC7-2EA8B685A58C}.Release|x64.Build.0 = Release|x64 + {51AC349E-B365-4FCF-8778-17A1534E4584}.Debug|Win32.ActiveCfg = Debug|Win32 + {51AC349E-B365-4FCF-8778-17A1534E4584}.Debug|Win32.Build.0 = Debug|Win32 + {51AC349E-B365-4FCF-8778-17A1534E4584}.Debug|x64.ActiveCfg = Debug|x64 + {51AC349E-B365-4FCF-8778-17A1534E4584}.Debug|x64.Build.0 = Debug|x64 + {51AC349E-B365-4FCF-8778-17A1534E4584}.DebugVLD|Win32.ActiveCfg = DebugVLD|Win32 + {51AC349E-B365-4FCF-8778-17A1534E4584}.DebugVLD|Win32.Build.0 = DebugVLD|Win32 + {51AC349E-B365-4FCF-8778-17A1534E4584}.DebugVLD|x64.ActiveCfg = DebugVLD|x64 + {51AC349E-B365-4FCF-8778-17A1534E4584}.DebugVLD|x64.Build.0 = DebugVLD|x64 + {51AC349E-B365-4FCF-8778-17A1534E4584}.Release|Win32.ActiveCfg = Release|Win32 + {51AC349E-B365-4FCF-8778-17A1534E4584}.Release|Win32.Build.0 = Release|Win32 + {51AC349E-B365-4FCF-8778-17A1534E4584}.Release|x64.ActiveCfg = Release|x64 + {51AC349E-B365-4FCF-8778-17A1534E4584}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -536,7 +531,6 @@ Global {E5E9DB4A-7816-45D4-A116-6BBBA0EE8EE7} = {B8C24D26-A3BF-4DA6-B64C-142CBA4BFE75} {A38E5597-6916-4480-A343-C9846EF544E4} = {B8C24D26-A3BF-4DA6-B64C-142CBA4BFE75} {6F834EAD-7B94-4979-A0F1-A662E3D30145} = {B8C24D26-A3BF-4DA6-B64C-142CBA4BFE75} - {20B6C380-E96A-4CFF-BC17-D88AAE581919} = {B30CA283-1796-4763-92C3-2E4848D443F7} {7521DD92-56FF-4ECA-93E5-CCE50862354B} = {6BB7A27F-FC59-4267-B6FA-D034176D1459} {CA6F0834-0628-4CD7-8800-AEABCD636360} = {6BB7A27F-FC59-4267-B6FA-D034176D1459} {DE256E91-EE96-412E-82EE-DD7BD1A1130D} = {A64449B7-90FB-4E2B-A686-9EFC0E298644} @@ -548,6 +542,7 @@ Global {A34CED07-A442-4FA1-81C4-F8B9CD3C832B} = {10E1FAF2-904D-405E-8AB5-6878A1B03346} {5E1C3684-9463-4A98-BAFC-9BD51F179BB6} = {10E1FAF2-904D-405E-8AB5-6878A1B03346} {50B2EC4B-A118-4E7B-ABC7-2EA8B685A58C} = {10E1FAF2-904D-405E-8AB5-6878A1B03346} + {51AC349E-B365-4FCF-8778-17A1534E4584} = {10E1FAF2-904D-405E-8AB5-6878A1B03346} EndGlobalSection GlobalSection(DPCodeReviewSolutionGUID) = preSolution DPCodeReviewSolutionGUID = {00000000-0000-0000-0000-000000000000} diff --git a/projects/Win/vc14/stress-pqueue.vcxproj b/projects/Win/vc14/stress-pqueue.vcxproj new file mode 100644 index 00000000..6e5702c5 --- /dev/null +++ b/projects/Win/vc14/stress-pqueue.vcxproj @@ -0,0 +1,251 @@ + + + + + DebugVLD + Win32 + + + DebugVLD + x64 + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + + + + + + CDSUNIT_USE_URCU;%(PreprocessorDefinitions) + CDSUNIT_USE_URCU;%(PreprocessorDefinitions) + CDSUNIT_USE_URCU;%(PreprocessorDefinitions) + CDSUNIT_USE_URCU;%(PreprocessorDefinitions) + CDSUNIT_USE_URCU;%(PreprocessorDefinitions) + CDSUNIT_USE_URCU;%(PreprocessorDefinitions) + + + + + + + {51AC349E-B365-4FCF-8778-17A1534E4584} + Win32Proj + stress_pqueue + 8.1 + stress-pqueue + + + + 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 + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + $(SolutionDir)..\..\..;$(GTEST_ROOT)/include;$(SolutionDir)..\..\..\test\include;$(BOOST_PATH);%(AdditionalIncludeDirectories) + + + 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 + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + $(SolutionDir)..\..\..;$(GTEST_ROOT)/include;$(SolutionDir)..\..\..\test\include;$(BOOST_PATH);%(AdditionalIncludeDirectories) + + + 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 + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + $(SolutionDir)..\..\..;$(GTEST_ROOT)/include;$(SolutionDir)..\..\..\test\include;$(BOOST_PATH);%(AdditionalIncludeDirectories) + + + 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 + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + $(SolutionDir)..\..\..;$(GTEST_ROOT)/include;$(SolutionDir)..\..\..\test\include;$(BOOST_PATH);%(AdditionalIncludeDirectories) + + + 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 + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + $(SolutionDir)..\..\..;$(GTEST_ROOT)/include;$(SolutionDir)..\..\..\test\include;$(BOOST_PATH);%(AdditionalIncludeDirectories) + + + 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;stres-framework.lib;%(AdditionalDependencies) + + + + + Level3 + NotUsing + MaxSpeed + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + $(SolutionDir)..\..\..;$(GTEST_ROOT)/include;$(SolutionDir)..\..\..\test\include;$(BOOST_PATH);%(AdditionalIncludeDirectories) + + + Console + true + true + true + $(GTEST_LIB64);$(GTEST_ROOT)/lib/x64;$(BOOST_PATH)/stage64/lib;$(BOOST_PATH)/bin;%(AdditionalLibraryDirectories);$(OutDir) + gtest.lib;stres-framework.lib;%(AdditionalDependencies) + + + + + + \ No newline at end of file diff --git a/projects/Win/vc14/stress-pqueue.vcxproj.filters b/projects/Win/vc14/stress-pqueue.vcxproj.filters new file mode 100644 index 00000000..aa96454b --- /dev/null +++ b/projects/Win/vc14/stress-pqueue.vcxproj.filters @@ -0,0 +1,39 @@ + + + + + {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 + + + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/projects/Win/vc14/unit-pqueue.vcxproj b/projects/Win/vc14/unit-pqueue.vcxproj deleted file mode 100644 index 5019a431..00000000 --- a/projects/Win/vc14/unit-pqueue.vcxproj +++ /dev/null @@ -1,316 +0,0 @@ - - - - - DebugVLD - Win32 - - - DebugVLD - x64 - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - - - - - - - - - - - - - - {20B6C380-E96A-4cff-BC17-D88AAE581919} - unitpqueue - Win32Proj - 8.1 - - - - Application - Unicode - true - v140 - - - Application - Unicode - v140 - - - Application - Unicode - v140 - - - Application - Unicode - true - v140 - - - Application - Unicode - v140 - - - Application - Unicode - v140 - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.40219.1 - $(SolutionDir)..\..\..\bin\vc.$(PlatformToolset)\$(Platform)\ - $(SolutionDir)..\..\..\bin\vc.$(PlatformToolset)\$(Platform)\ - $(SolutionDir)..\..\..\obj\vc.$(PlatformToolset)\$(Platform)\$(ProjectName)\$(Configuration)\ - $(SolutionDir)..\..\..\obj\vc.$(PlatformToolset)\$(Platform)\$(ProjectName)\$(Configuration)\ - false - false - $(SolutionDir)..\..\..\bin\vc.$(PlatformToolset)\$(Platform)\ - $(SolutionDir)..\..\..\bin\vc.$(PlatformToolset)\$(Platform)\ - $(SolutionDir)..\..\..\obj\vc.$(PlatformToolset)\$(Platform)\$(ProjectName)\$(Configuration)\ - $(SolutionDir)..\..\..\obj\vc.$(PlatformToolset)\$(Platform)\$(ProjectName)\$(Configuration)\ - false - 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)\ - false - AllRules.ruleset - AllRules.ruleset - - - - - AllRules.ruleset - AllRules.ruleset - - - - - AllRules.ruleset - - - AllRules.ruleset - - - $(ProjectName)_d - $(ProjectName)_d - $(ProjectName)_d - $(ProjectName)_d - - - - /bigobj /Zc:inline %(AdditionalOptions) - Disabled - $(SolutionDir)..\..\..;$(SolutionDir)..\..\..\tests\unit;$(SolutionDir)..\..\..\tests;$(BOOST_PATH);%(AdditionalIncludeDirectories) - _SCL_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;_WIN32_WINNT=0x0501;_SCL_SECURE=0;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - EditAndContinue - 4520 - - - unit-prerequisites_d.lib;%(AdditionalDependencies) - $(TargetPath) - $(BOOST_PATH)/stage32/lib;$(BOOST_PATH)/stage/lib;$(BOOST_PATH)/bin;$(OutDir);%(AdditionalLibraryDirectories) - true - Console - MachineX86 - MultiplyDefinedSymbolOnly - - - - - /bigobj /Zc:inline %(AdditionalOptions) - Disabled - $(SolutionDir)..\..\..;$(SolutionDir)..\..\..\tests\unit;$(SolutionDir)..\..\..\tests;$(BOOST_PATH);%(AdditionalIncludeDirectories) - _SCL_SECURE_NO_WARNINGS;CDS_USE_VLD;WIN32;_DEBUG;_CONSOLE;_WIN32_WINNT=0x0501;_SCL_SECURE=0;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - EditAndContinue - 4520 - - - unit-prerequisites_d.lib;%(AdditionalDependencies) - $(TargetPath) - $(BOOST_PATH)/stage32/lib;$(BOOST_PATH)/stage/lib;$(BOOST_PATH)/bin;$(OutDir);%(AdditionalLibraryDirectories) - true - Console - MachineX86 - MultiplyDefinedSymbolOnly - - - - - X64 - - - /bigobj /Zc:inline %(AdditionalOptions) - Disabled - $(SolutionDir)..\..\..;$(SolutionDir)..\..\..\tests\unit;$(SolutionDir)..\..\..\tests;$(BOOST_PATH);%(AdditionalIncludeDirectories) - _SCL_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;_WIN32_WINNT=0x0501;_SCL_SECURE=0;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - ProgramDatabase - 4520 - - - unit-prerequisites_d.lib;%(AdditionalDependencies) - $(TargetPath) - $(BOOST_PATH)/stage64/lib;$(BOOST_PATH)/bin;$(OutDir);%(AdditionalLibraryDirectories) - true - Console - MachineX64 - MultiplyDefinedSymbolOnly - - - - - X64 - - - /bigobj /Zc:inline %(AdditionalOptions) - Disabled - $(SolutionDir)..\..\..;$(SolutionDir)..\..\..\tests\unit;$(SolutionDir)..\..\..\tests;$(BOOST_PATH);%(AdditionalIncludeDirectories) - _SCL_SECURE_NO_WARNINGS;CDS_USE_VLD;WIN32;_DEBUG;_CONSOLE;_WIN32_WINNT=0x0501;_SCL_SECURE=0;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - ProgramDatabase - 4520 - - - unit-prerequisites_d.lib;%(AdditionalDependencies) - $(TargetPath) - $(BOOST_PATH)/stage64/lib;$(BOOST_PATH)/bin;$(OutDir);%(AdditionalLibraryDirectories) - true - Console - MachineX64 - MultiplyDefinedSymbolOnly - - - - - /bigobj /Zc:inline %(AdditionalOptions) - MaxSpeed - AnySuitable - true - Speed - $(SolutionDir)..\..\..;$(SolutionDir)..\..\..\tests\unit;$(SolutionDir)..\..\..\tests;$(BOOST_PATH);%(AdditionalIncludeDirectories) - _SCL_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;_WIN32_WINNT=0x0501;_SCL_SECURE=0;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - ProgramDatabase - 4520 - - - unit-prerequisites.lib;%(AdditionalDependencies) - $(BOOST_PATH)/stage32/lib;$(BOOST_PATH)/stage/lib;$(BOOST_PATH)/bin;$(OutDir);%(AdditionalLibraryDirectories) - true - Console - true - true - MachineX86 - $(TargetPath) - MultiplyDefinedSymbolOnly - - - - - X64 - - - /bigobj /Zc:inline %(AdditionalOptions) - MaxSpeed - AnySuitable - true - Speed - $(SolutionDir)..\..\..;$(SolutionDir)..\..\..\tests\unit;$(SolutionDir)..\..\..\tests;$(BOOST_PATH);%(AdditionalIncludeDirectories) - _SCL_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;_WIN32_WINNT=0x0501;_SCL_SECURE=0;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - ProgramDatabase - 4520 - - - unit-prerequisites.lib;%(AdditionalDependencies) - $(BOOST_PATH)/stage64/lib;$(BOOST_PATH)/bin;$(OutDir);%(AdditionalLibraryDirectories) - true - Console - true - true - MachineX64 - $(TargetPath) - MultiplyDefinedSymbolOnly - - - - - - \ No newline at end of file diff --git a/projects/source.unit.pqueue.mk b/projects/source.unit.pqueue.mk deleted file mode 100644 index 8eddfbb6..00000000 --- a/projects/source.unit.pqueue.mk +++ /dev/null @@ -1,5 +0,0 @@ - -CDSUNIT_PQUEUE_SOURCES= \ - tests/unit/pqueue/pop.cpp \ - tests/unit/pqueue/push.cpp \ - tests/unit/pqueue/push_pop.cpp diff --git a/test/include/cds_test/stat_ellenbintree_out.h b/test/include/cds_test/stat_ellenbintree_out.h new file mode 100644 index 00000000..e9c8657c --- /dev/null +++ b/test/include/cds_test/stat_ellenbintree_out.h @@ -0,0 +1,79 @@ +/* + 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 CDSTEST_STAT_ELLENBINTREE_OUT_H +#define CDSTEST_STAT_ELLENBINTREE_OUT_H + +//#include "ellen_bintree_update_desc_pool.h" +#include +#include + +namespace cds_test { + static inline property_stream& operator <<( property_stream& o, cds::intrusive::ellen_bintree::empty_stat const& /*s*/ ) + { + return o; + } + + static inline property_stream& operator <<( property_stream& o, cds::intrusive::ellen_bintree::stat<> const& s ) + { + return o + //<< "\t\t Internal node allocated: " << ellen_bintree_pool::internal_node_counter::m_nAlloc.get() << "\n" + //<< "\t\t Internal node freed: " << ellen_bintree_pool::internal_node_counter::m_nFree.get() << "\n" + << CDSSTRESS_STAT_OUT( s, m_nInternalNodeCreated ) + << CDSSTRESS_STAT_OUT( s, m_nInternalNodeDeleted ) + << CDSSTRESS_STAT_OUT( s, m_nUpdateDescCreated ) + << CDSSTRESS_STAT_OUT( s, m_nUpdateDescDeleted ) + << CDSSTRESS_STAT_OUT( s, m_nInsertSuccess ) + << CDSSTRESS_STAT_OUT( s, m_nInsertFailed ) + << CDSSTRESS_STAT_OUT( s, m_nInsertRetries ) + << CDSSTRESS_STAT_OUT( s, m_nEnsureExist ) + << CDSSTRESS_STAT_OUT( s, m_nEnsureNew ) + << CDSSTRESS_STAT_OUT( s, m_nEnsureRetries ) + << CDSSTRESS_STAT_OUT( s, m_nEraseSuccess ) + << CDSSTRESS_STAT_OUT( s, m_nEraseFailed ) + << CDSSTRESS_STAT_OUT( s, m_nEraseRetries ) + << CDSSTRESS_STAT_OUT( s, m_nFindSuccess ) + << CDSSTRESS_STAT_OUT( s, m_nFindFailed ) + << CDSSTRESS_STAT_OUT( s, m_nExtractMinSuccess ) + << CDSSTRESS_STAT_OUT( s, m_nExtractMinFailed ) + << CDSSTRESS_STAT_OUT( s, m_nExtractMinRetries ) + << CDSSTRESS_STAT_OUT( s, m_nExtractMaxSuccess ) + << CDSSTRESS_STAT_OUT( s, m_nExtractMaxFailed ) + << CDSSTRESS_STAT_OUT( s, m_nExtractMaxRetries ) + << CDSSTRESS_STAT_OUT( s, m_nSearchRetry ) + << CDSSTRESS_STAT_OUT( s, m_nHelpInsert ) + << CDSSTRESS_STAT_OUT( s, m_nHelpDelete ) + << CDSSTRESS_STAT_OUT( s, m_nHelpMark ) + << CDSSTRESS_STAT_OUT( s, m_nHelpGuardSuccess ) + << CDSSTRESS_STAT_OUT( s, m_nHelpGuardFailed ); + } +} // namespace cds_test + +#endif // #ifndef CDSTEST_STAT_ELLENBINTREE_OUT_H diff --git a/test/include/cds_test/stat_skiplist_out.h b/test/include/cds_test/stat_skiplist_out.h new file mode 100644 index 00000000..69273515 --- /dev/null +++ b/test/include/cds_test/stat_skiplist_out.h @@ -0,0 +1,89 @@ +/* + 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 CDSTEST_STAT_SKIPLIST_OUT_H +#define CDSTEST_STAT_SKIPLIST_OUT_H + +#include + +namespace cds_test { + + static inline property_stream& operator <<( property_stream& o, cds::intrusive::skip_list::empty_stat const& /*s*/ ) + { + return o; + } + + static inline property_stream& operator <<( property_stream& o, cds::intrusive::skip_list::stat<> const& s ) + { + { + std::stringstream stm; + for ( unsigned int i = 0; i < sizeof( s.m_nNodeHeightAdd ) / sizeof( s.m_nNodeHeightAdd[0] ); ++i ) + stm << " +" << s.m_nNodeHeightAdd[i].get() << "/-" << s.m_nNodeHeightDel[i].get(); + o << CDSSTRESS_STAT_OUT_( "stat.level_ins_del", stm.str().substr( 1 ).c_str()); + } + + return o + << CDSSTRESS_STAT_OUT( s, m_nInsertSuccess ) + << CDSSTRESS_STAT_OUT( s, m_nInsertFailed ) + << CDSSTRESS_STAT_OUT( s, m_nInsertRetries ) + << CDSSTRESS_STAT_OUT( s, m_nUpdateExist ) + << CDSSTRESS_STAT_OUT( s, m_nUpdateNew ) + << CDSSTRESS_STAT_OUT( s, m_nUnlinkSuccess ) + << CDSSTRESS_STAT_OUT( s, m_nUnlinkFailed ) + << CDSSTRESS_STAT_OUT( s, m_nExtractSuccess ) + << CDSSTRESS_STAT_OUT( s, m_nExtractFailed ) + << CDSSTRESS_STAT_OUT( s, m_nExtractRetries ) + << CDSSTRESS_STAT_OUT( s, m_nExtractMinSuccess ) + << CDSSTRESS_STAT_OUT( s, m_nExtractMinFailed ) + << CDSSTRESS_STAT_OUT( s, m_nExtractMinRetries ) + << CDSSTRESS_STAT_OUT( s, m_nExtractMaxSuccess ) + << CDSSTRESS_STAT_OUT( s, m_nExtractMaxFailed ) + << CDSSTRESS_STAT_OUT( s, m_nExtractMaxRetries ) + << CDSSTRESS_STAT_OUT( s, m_nEraseSuccess ) + << CDSSTRESS_STAT_OUT( s, m_nEraseFailed ) + << CDSSTRESS_STAT_OUT( s, m_nEraseRetry ) + << CDSSTRESS_STAT_OUT( s, m_nFindFastSuccess ) + << CDSSTRESS_STAT_OUT( s, m_nFindFastFailed ) + << CDSSTRESS_STAT_OUT( s, m_nFindSlowSuccess ) + << CDSSTRESS_STAT_OUT( s, m_nFindSlowFailed ) + << CDSSTRESS_STAT_OUT( s, m_nRenewInsertPosition ) + << CDSSTRESS_STAT_OUT( s, m_nLogicDeleteWhileInsert ) + << CDSSTRESS_STAT_OUT( s, m_nNotFoundWhileInsert ) + << CDSSTRESS_STAT_OUT( s, m_nFastErase ) + << CDSSTRESS_STAT_OUT( s, m_nSlowErase ) + << CDSSTRESS_STAT_OUT( s, m_nFastExtract ) + << CDSSTRESS_STAT_OUT( s, m_nSlowExtract ) + << CDSSTRESS_STAT_OUT( s, m_nEraseWhileFind ) + << CDSSTRESS_STAT_OUT( s, m_nExtractWhileFind ); + } + +} // namespace cds_test + +#endif // #ifndef CDSTEST_STAT_SKIPLIST_OUT_H diff --git a/test/include/cds_test/thread.h b/test/include/cds_test/thread.h index 22a216b7..333c2683 100644 --- a/test/include/cds_test/thread.h +++ b/test/include/cds_test/thread.h @@ -104,8 +104,7 @@ namespace cds_test { ~thread_pool() { - for ( auto t : m_threads ) - delete t; + clear(); } void add( thread * what ) @@ -159,6 +158,16 @@ namespace cds_test { std::chrono::milliseconds duration() const { return m_testDuration; } + void clear() + { + for ( auto t : m_threads ) + delete t; + m_threads.clear(); + m_bRunning = false; + m_bStopped = false; + m_doneCount = 0; + } + protected: // thread interface size_t get_next_id() { diff --git a/test/stress/CMakeLists.txt b/test/stress/CMakeLists.txt index 0ac5aa5b..073dab1a 100644 --- a/test/stress/CMakeLists.txt +++ b/test/stress/CMakeLists.txt @@ -13,6 +13,7 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ) +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/pqueue) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/queue) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/stack) diff --git a/test/stress/data/test-debug.conf b/test/stress/data/test-debug.conf index 19f200b9..f286e370 100644 --- a/test/stress/data/test-debug.conf +++ b/test/stress/data/test-debug.conf @@ -142,11 +142,15 @@ ThreadCount=4 QueueSize=1024 PassCount=100000 -[PQueue_Push] +[pqueue_pop] ThreadCount=4 QueueSize=10000 -[PQueue_PushPop] +[pqueue_push] +ThreadCount=4 +QueueSize=10000 + +[pqueue_push_pop] PushThreadCount=4 PopThreadCount=4 QueueSize=10000 diff --git a/test/stress/data/test-express.conf b/test/stress/data/test-express.conf index 488f71c5..3f576dfa 100644 --- a/test/stress/data/test-express.conf +++ b/test/stress/data/test-express.conf @@ -143,11 +143,15 @@ ThreadCount=4 QueueSize=1024 PassCount=100000 -[PQueue_Push] +[pqueue_pop] ThreadCount=8 QueueSize=1000000 -[PQueue_PushPop] +[pqueue_push] +ThreadCount=8 +QueueSize=1000000 + +[pqueue_push_pop] PushThreadCount=4 PopThreadCount=4 QueueSize=500000 diff --git a/test/stress/data/test.conf b/test/stress/data/test.conf index 3d7f175a..3d7bde4e 100644 --- a/test/stress/data/test.conf +++ b/test/stress/data/test.conf @@ -142,11 +142,15 @@ ThreadCount=8 QueueSize=1024 PassCount=1000000 -[PQueue_Push] +[pqueue_pop] ThreadCount=8 QueueSize=10000000 -[PQueue_PushPop] +[pqueue_push] +ThreadCount=8 +QueueSize=10000000 + +[pqueue_push_pop] PushThreadCount=4 PopThreadCount=4 QueueSize=10000000 diff --git a/test/stress/michael_alloc.h b/test/stress/michael_alloc.h deleted file mode 100644 index ddaed85c..00000000 --- a/test/stress/michael_alloc.h +++ /dev/null @@ -1,95 +0,0 @@ -/* - 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_MICHAEL_ALLOC_H -#define CDSUNIT_MICHAEL_ALLOC_H - -#include -#include - -namespace memory { - - typedef cds::memory::michael::Heap< - cds::memory::michael::opt::check_bounds< cds::memory::michael::debug_bound_checking > - > michael_heap; - extern michael_heap s_MichaelHeap; - - template - class MichaelAllocator - { - typedef std::allocator std_allocator; - public: - // Declare typedefs from std::allocator - typedef typename std_allocator::const_pointer const_pointer; - typedef typename std_allocator::pointer pointer; - typedef typename std_allocator::const_reference const_reference; - typedef typename std_allocator::reference reference; - typedef typename std_allocator::difference_type difference_type; - typedef typename std_allocator::size_type size_type; - typedef typename std_allocator::value_type value_type; - - // Allocation function - pointer allocate( size_type _Count, const void* /*_Hint*/ = nullptr ) - { - return reinterpret_cast( s_MichaelHeap.alloc( sizeof(T) * _Count )); - } - - // Deallocation function - void deallocate( pointer _Ptr, size_type /*_Count*/ ) - { - s_MichaelHeap.free( _Ptr ); - } - - pointer address( reference r ) const - { - return &r; - } - const_pointer address( const_reference r ) const - { - return &r; - } - void construct( pointer p, const T& val ) - { - return new( p ) T( val ); - } - void destroy( pointer p ) - { - p->T::~T(); - } - - // Rebinding allocator to other type - template - struct rebind { - typedef MichaelAllocator other; - }; - }; -} // namespace memory - -#endif // #ifndef CDSUNIT_MICHAEL_ALLOC_H diff --git a/test/stress/pqueue/CMakeLists.txt b/test/stress/pqueue/CMakeLists.txt new file mode 100644 index 00000000..7131a984 --- /dev/null +++ b/test/stress/pqueue/CMakeLists.txt @@ -0,0 +1,25 @@ +set(PACKAGE_NAME stress-pqueue) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCDSUNIT_USE_URCU") + +set(CDSSTRESS_PQUEUE_SOURCES + ../main.cpp + pop.cpp + push.cpp + push_pop.cpp +) + +include_directories( + ${CMAKE_CURRENT_SOURCE_DIR} +) + +add_executable(${PACKAGE_NAME} ${CDSSTRESS_PQUEUE_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/tests/unit/pqueue/pqueue_item.h b/test/stress/pqueue/item.h similarity index 69% rename from tests/unit/pqueue/pqueue_item.h rename to test/stress/pqueue/item.h index 90325933..1a14fba1 100644 --- a/tests/unit/pqueue/pqueue_item.h +++ b/test/stress/pqueue/item.h @@ -28,42 +28,51 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef CDSUNIT_PQUEUE_ITEM_H -#define CDSUNIT_PQUEUE_ITEM_H +#ifndef CDSSTRESS_PQUEUE_ITEM_H +#define CDSSTRESS_PQUEUE_ITEM_H namespace pqueue { - struct SimpleValue { - size_t key; + struct simple_value { typedef size_t key_type; + key_type key; + struct key_extractor { - void operator()( key_type& k, SimpleValue const& s ) const + void operator()( key_type& k, simple_value const& s ) const { k = s.key; } }; - SimpleValue(): key(0) {} - SimpleValue( size_t n ): key(n) {} + simple_value() + : key(0) + {} + + simple_value( key_type n ) + : key(n) + {} }; -} +} // namespace pqueue namespace std { + template struct less; + template struct greater; + template <> - struct less + struct less { - bool operator()( pqueue::SimpleValue const& k1, pqueue::SimpleValue const& k2 ) const + bool operator()( pqueue::simple_value const& k1, pqueue::simple_value const& k2 ) const { return k1.key < k2.key; } - bool operator()( pqueue::SimpleValue const& k1, size_t k2 ) const + bool operator()( pqueue::simple_value const& k1, size_t k2 ) const { return k1.key < k2; } - bool operator()( size_t k1, pqueue::SimpleValue const& k2 ) const + bool operator()( size_t k1, pqueue::simple_value const& k2 ) const { return k1 < k2.key; } @@ -75,19 +84,19 @@ namespace std { }; template <> - struct greater + struct greater { - bool operator()( pqueue::SimpleValue const& k1, pqueue::SimpleValue const& k2 ) const + bool operator()( pqueue::simple_value const& k1, pqueue::simple_value const& k2 ) const { return k1.key > k2.key; } - bool operator()( pqueue::SimpleValue const& k1, size_t k2 ) const + bool operator()( pqueue::simple_value const& k1, size_t k2 ) const { return k1.key > k2; } - bool operator()( size_t k1, pqueue::SimpleValue const& k2 ) const + bool operator()( size_t k1, pqueue::simple_value const& k2 ) const { return k1 > k2.key; } @@ -100,4 +109,4 @@ namespace std { } // namespace std -#endif // #ifndef CDSUNIT_PQUEUE_ITEM_H +#endif // #ifndef CDSSTRESS_PQUEUE_ITEM_H diff --git a/test/stress/pqueue/pop.cpp b/test/stress/pqueue/pop.cpp new file mode 100644 index 00000000..1ac50887 --- /dev/null +++ b/test/stress/pqueue/pop.cpp @@ -0,0 +1,321 @@ +/* + 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 "pqueue_type.h" +#include "item.h" + +namespace { + static size_t s_nThreadCount = 8; + static size_t s_nQueueSize = 2000000; + + class pqueue_pop: public cds_test::stress_fixture + { + typedef cds_test::stress_fixture base_class; + + protected: + template + class Producer: public cds_test::thread + { + typedef cds_test::thread base_class; + + public: + Producer( cds_test::thread_pool& pool, PQueue& queue ) + : base_class( pool ) + , m_Queue( queue ) + {} + + Producer( Producer& src ) + : base_class( src ) + , m_Queue( src.m_Queue ) + {} + + virtual thread * clone() + { + return new Producer( *this ); + } + + virtual void test() + { + typedef typename PQueue::value_type value_type; + for ( array_type::const_iterator it = m_arr.begin(); it != m_arr.end(); ++it ) { + if ( !m_Queue.push( value_type( *it ) )) + ++m_nPushError; + } + } + + void prepare( size_t nStart, size_t nEnd ) + { + m_arr.reserve( nEnd - nStart ); + for ( size_t i = nStart; i < nEnd; ++i ) + m_arr.push_back( i ); + shuffle( m_arr.begin(), m_arr.end() ); + } + + public: + PQueue& m_Queue; + size_t m_nPushError = 0; + + typedef std::vector array_type; + array_type m_arr; + }; + + template + class Consumer: public cds_test::thread + { + typedef cds_test::thread base_class; + + public: + Consumer( cds_test::thread_pool& pool, PQueue& queue ) + : base_class( pool ) + , m_Queue( queue ) + {} + + Consumer( Consumer& src ) + : base_class( src ) + , m_Queue( src.m_Queue ) + {} + + virtual thread * clone() + { + return new Consumer( *this ); + } + + virtual void test() + { + typedef typename PQueue::value_type value_type; + size_t nPrevKey; + value_type val; + if ( m_Queue.pop( val )) { + ++m_nPopSuccess; + nPrevKey = val.key; + + while ( !m_Queue.empty() ) { + if ( m_Queue.pop( val )) { + ++m_nPopSuccess; + if ( val.key > nPrevKey ) + ++m_nPopError; + else if ( val.key == nPrevKey ) + ++m_nPopErrorEq; + nPrevKey = val.key; + } + else + ++m_nPopFailed; + } + } + else + ++m_nPopFailed; + } + + public: + PQueue& m_Queue; + size_t m_nPopError = 0; + size_t m_nPopErrorEq = 0; + size_t m_nPopSuccess = 0; + size_t m_nPopFailed = 0; + }; + + protected: + + template + void test( PQueue& q ) + { + size_t const nThreadItemCount = s_nQueueSize / s_nThreadCount; + s_nQueueSize = nThreadItemCount * s_nThreadCount; + + cds_test::thread_pool& pool = get_pool(); + + propout() << std::make_pair( "thread_count", s_nThreadCount ) + << std::make_pair( "push_count", s_nQueueSize ); + + // push + { + pool.add( new Producer( pool, q ), s_nThreadCount ); + + size_t nStart = 0; + for ( size_t i = 0; i < pool.size(); ++i ) { + static_cast&>( pool.get(i) ).prepare( nStart, nStart + nThreadItemCount ); + nStart += nThreadItemCount; + } + + std::chrono::milliseconds duration = pool.run(); + propout() << std::make_pair( "producer_duration", duration ); + } + + // pop + { + pool.clear(); + pool.add( new Consumer( pool, q ), s_nThreadCount ); + + std::chrono::milliseconds duration = pool.run(); + propout() << std::make_pair( "consumer_duration", duration ); + + // Analyze result + size_t nTotalPopped = 0; + size_t nTotalError = 0; + size_t nTotalErrorEq = 0; + size_t nTotalFailed = 0; + for ( size_t i = 0; i < pool.size(); ++i ) { + Consumer& cons = static_cast&>( pool.get(i)); + + nTotalPopped += cons.m_nPopSuccess; + nTotalError += cons.m_nPopError; + nTotalErrorEq += cons.m_nPopErrorEq; + nTotalFailed += cons.m_nPopFailed; + } + + propout() + << std::make_pair( "total_popped", nTotalPopped ) + << std::make_pair( "error_pop_double", nTotalErrorEq ) + << std::make_pair( "error_priority_violation", nTotalError ); + + EXPECT_EQ( nTotalPopped, s_nQueueSize ); + EXPECT_EQ( nTotalError, 0 ); + EXPECT_EQ( nTotalErrorEq, 0 ); + } + + propout() << q.statistics(); + } + + public: + static void SetUpTestCase() + { + cds_test::config const& cfg = get_config( "pqueue_pop" ); + + s_nThreadCount = cfg.get_size_t( "ThreadCount", s_nThreadCount ); + s_nQueueSize = cfg.get_size_t( "QueueSize", s_nQueueSize ); + + if ( s_nThreadCount == 0 ) + s_nThreadCount = 1; + if ( s_nQueueSize == 0 ) + s_nQueueSize = 1000; + } + + //static void TearDownTestCase(); + }; + +#define CDSSTRESS_MSPriorityQueue( fixture_t, pqueue_t ) \ + TEST_F( fixture_t, pqueue_t ) \ + { \ + typedef pqueue::Types::pqueue_t pqueue_type; \ + pqueue_type pq( s_nQueueSize ); \ + test( pq ); \ + } + CDSSTRESS_MSPriorityQueue( pqueue_pop, MSPriorityQueue_dyn_less ) + CDSSTRESS_MSPriorityQueue( pqueue_pop, MSPriorityQueue_dyn_less_stat ) + CDSSTRESS_MSPriorityQueue( pqueue_pop, MSPriorityQueue_dyn_cmp ) + CDSSTRESS_MSPriorityQueue( pqueue_pop, MSPriorityQueue_dyn_mutex ) + +#define CDSSTRESS_MSPriorityQueue_static( fixture_t, pqueue_t ) \ + TEST_F( fixture_t, pqueue_t ) \ + { \ + typedef pqueue::Types::pqueue_t pqueue_type; \ + std::unique_ptr< pqueue_type > pq( new pqueue_type ); \ + test( *pq.get() ); \ + } + //CDSSTRESS_MSPriorityQueue( pqueue_pop, MSPriorityQueue_static_less ) + //CDSSTRESS_MSPriorityQueue( pqueue_pop, MSPriorityQueue_static_less_stat ) + //CDSSTRESS_MSPriorityQueue( pqueue_pop, MSPriorityQueue_static_cmp ) + //CDSSTRESS_MSPriorityQueue( pqueue_pop, 1MSPriorityQueue_static_mutex ) + + +#define CDSSTRESS_PriorityQueue( fixture_t, pqueue_t ) \ + TEST_F( fixture_t, pqueue_t ) \ + { \ + typedef pqueue::Types::pqueue_t pqueue_type; \ + pqueue_type pq; \ + test( pq ); \ + } + CDSSTRESS_PriorityQueue( pqueue_pop, FCPQueue_vector ) + CDSSTRESS_PriorityQueue( pqueue_pop, FCPQueue_vector_stat ) + CDSSTRESS_PriorityQueue( pqueue_pop, FCPQueue_deque ) + CDSSTRESS_PriorityQueue( pqueue_pop, FCPQueue_deque_stat ) + CDSSTRESS_PriorityQueue( pqueue_pop, FCPQueue_boost_deque ) + CDSSTRESS_PriorityQueue( pqueue_pop, FCPQueue_boost_deque_stat ) + CDSSTRESS_PriorityQueue( pqueue_pop, FCPQueue_boost_stable_vector ) + CDSSTRESS_PriorityQueue( pqueue_pop, FCPQueue_boost_stable_vector_stat ) + + CDSSTRESS_PriorityQueue( pqueue_pop, EllenBinTree_HP_max ) + CDSSTRESS_PriorityQueue( pqueue_pop, EllenBinTree_HP_max_stat ) + CDSSTRESS_PriorityQueue( pqueue_pop, EllenBinTree_HP_min ) + CDSSTRESS_PriorityQueue( pqueue_pop, EllenBinTree_HP_min_stat ) + CDSSTRESS_PriorityQueue( pqueue_pop, EllenBinTree_DHP_max ) + CDSSTRESS_PriorityQueue( pqueue_pop, EllenBinTree_DHP_max_stat ) + CDSSTRESS_PriorityQueue( pqueue_pop, EllenBinTree_DHP_min ) + CDSSTRESS_PriorityQueue( pqueue_pop, EllenBinTree_DHP_min_stat ) + // CDSSTRESS_PriorityQueue( pqueue_pop, EllenBinTree_RCU_gpi_max ) + // CDSSTRESS_PriorityQueue( pqueue_pop, EllenBinTree_RCU_gpi_max_stat ) + // CDSSTRESS_PriorityQueue( pqueue_pop, EllenBinTree_RCU_gpi_min ) + // CDSSTRESS_PriorityQueue( pqueue_pop, EllenBinTree_RCU_gpi_min_stat ) + CDSSTRESS_PriorityQueue( pqueue_pop, EllenBinTree_RCU_gpb_max ) + CDSSTRESS_PriorityQueue( pqueue_pop, EllenBinTree_RCU_gpb_max_stat ) + CDSSTRESS_PriorityQueue( pqueue_pop, EllenBinTree_RCU_gpb_min ) + CDSSTRESS_PriorityQueue( pqueue_pop, EllenBinTree_RCU_gpb_min_stat ) + CDSSTRESS_PriorityQueue( pqueue_pop, EllenBinTree_RCU_gpt_max ) + CDSSTRESS_PriorityQueue( pqueue_pop, EllenBinTree_RCU_gpt_max_stat ) + CDSSTRESS_PriorityQueue( pqueue_pop, EllenBinTree_RCU_gpt_min ) + CDSSTRESS_PriorityQueue( pqueue_pop, EllenBinTree_RCU_gpt_min_stat ) +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + CDSSTRESS_PriorityQueue( pqueue_pop, EllenBinTree_RCU_shb_max ) + CDSSTRESS_PriorityQueue( pqueue_pop, EllenBinTree_RCU_shb_max_stat ) + CDSSTRESS_PriorityQueue( pqueue_pop, EllenBinTree_RCU_shb_min ) + CDSSTRESS_PriorityQueue( pqueue_pop, EllenBinTree_RCU_shb_min_stat ) + CDSSTRESS_PriorityQueue( pqueue_pop, EllenBinTree_RCU_sht_max ) + CDSSTRESS_PriorityQueue( pqueue_pop, EllenBinTree_RCU_sht_max_stat ) + CDSSTRESS_PriorityQueue( pqueue_pop, EllenBinTree_RCU_sht_min ) + CDSSTRESS_PriorityQueue( pqueue_pop, EllenBinTree_RCU_sht_min_stat ) +#endif + + CDSSTRESS_PriorityQueue( pqueue_pop, SkipList_HP_max ) + CDSSTRESS_PriorityQueue( pqueue_pop, SkipList_HP_max_stat ) + CDSSTRESS_PriorityQueue( pqueue_pop, SkipList_HP_min ) + CDSSTRESS_PriorityQueue( pqueue_pop, SkipList_HP_min_stat ) + CDSSTRESS_PriorityQueue( pqueue_pop, SkipList_DHP_max ) + CDSSTRESS_PriorityQueue( pqueue_pop, SkipList_DHP_max_stat ) + CDSSTRESS_PriorityQueue( pqueue_pop, SkipList_DHP_min ) + CDSSTRESS_PriorityQueue( pqueue_pop, SkipList_DHP_min_stat ) + CDSSTRESS_PriorityQueue( pqueue_pop, SkipList_RCU_gpi_max ) + CDSSTRESS_PriorityQueue( pqueue_pop, SkipList_RCU_gpi_min ) + CDSSTRESS_PriorityQueue( pqueue_pop, SkipList_RCU_gpb_max ) + CDSSTRESS_PriorityQueue( pqueue_pop, SkipList_RCU_gpb_min ) + CDSSTRESS_PriorityQueue( pqueue_pop, SkipList_RCU_gpt_max ) + CDSSTRESS_PriorityQueue( pqueue_pop, SkipList_RCU_gpt_min ) +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + CDSSTRESS_PriorityQueue( pqueue_pop, SkipList_RCU_shb_max ) + CDSSTRESS_PriorityQueue( pqueue_pop, SkipList_RCU_shb_min ) + CDSSTRESS_PriorityQueue( pqueue_pop, SkipList_RCU_sht_max ) + CDSSTRESS_PriorityQueue( pqueue_pop, SkipList_RCU_sht_min ) +#endif + + CDSSTRESS_PriorityQueue( pqueue_pop, StdPQueue_vector_spin ) + CDSSTRESS_PriorityQueue( pqueue_pop, StdPQueue_vector_mutex ) + CDSSTRESS_PriorityQueue( pqueue_pop, StdPQueue_deque_spin ) + CDSSTRESS_PriorityQueue( pqueue_pop, StdPQueue_deque_mutex ) + +} // namespace diff --git a/test/stress/pqueue/pqueue_type.h b/test/stress/pqueue/pqueue_type.h new file mode 100644 index 00000000..288132f8 --- /dev/null +++ b/test/stress/pqueue/pqueue_type.h @@ -0,0 +1,666 @@ +/* + 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 CDSSTRESS_PQUEUE_TYPES_H +#define CDSSTRESS_PQUEUE_TYPES_H + +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include + +#include +#include +#include +#include //unique_lock + +#include +#include + +#include +#include +#include + +namespace pqueue { + namespace cc = cds::container; + namespace co = cds::opt; + + namespace details { + template > + class StdPQueue + { + public: + typedef T value_type; + typedef std::priority_queue pqueue_type; + + private: + pqueue_type m_PQueue; + mutable Lock m_Lock; + + typedef std::unique_lock scoped_lock; + + public: + bool push( value_type const& val ) + { + scoped_lock l( m_Lock ); + m_PQueue.push( val ); + return true; + } + + bool pop( value_type& dest ) + { + scoped_lock l( m_Lock ); + if ( !m_PQueue.empty() ) { + dest = m_PQueue.top(); + m_PQueue.pop(); + return true; + } + return false; + } + + template + bool pop_with( Q& dest, MoveFunc f ) + { + scoped_lock l( m_Lock ); + if ( !m_PQueue.empty() ) { + f( dest, m_PQueue.top() ); + m_PQueue.pop(); + return true; + } + return false; + } + + void clear() + { + scoped_lock l( m_Lock ); + while ( !m_PQueue.empty() ) + m_PQueue.pop(); + } + + template + void clear_with( Func f ) + { + scoped_lock l( m_Lock ); + while ( !m_PQueue.empty() ) { + f( m_PQueue.top() ); + m_PQueue.pop(); + } + } + + bool empty() const + { + return m_PQueue.empty(); + } + + size_t size() const + { + return m_PQueue.size(); + } + + cds::opt::none statistics() const + { + return cds::opt::none(); + } + }; + + // EllenBinTree priority queue + template + struct EllenBinTreePQueue_pop_max + { + template + bool operator()( T& dest, Tree& container ) const + { + typename Tree::guarded_ptr gp( container.extract_max() ); + if ( gp ) + dest = *gp; + return !gp.empty(); + } + }; + + template + struct EllenBinTreePQueue_pop_max< cds::urcu::gc > + { + template + bool operator()( T& dest, Tree& container ) const + { + typename Tree::exempt_ptr ep( container.extract_max() ); + if ( ep ) + dest = *ep; + return !ep.empty(); + } + }; + + template + struct EllenBinTreePQueue_pop_min + { + template + bool operator()( T& dest, Tree& container ) const + { + typename Tree::guarded_ptr gp( container.extract_min() ); + if ( gp ) + dest = *gp; + return !gp.empty(); + } + }; + + template + struct EllenBinTreePQueue_pop_min< cds::urcu::gc > + { + template + bool operator()( T& dest, Tree& container ) const + { + typename Tree::exempt_ptr ep( container.extract_min() ); + if ( ep ) + dest = *ep; + return !ep.empty(); + } + }; + + template + class EllenBinTreePQueue : protected cds::container::EllenBinTreeSet< GC, Key, T, Traits > + { + typedef cds::container::EllenBinTreeSet< GC, Key, T, Traits > base_class; + template friend struct EllenBinTreePQueue_pop_max; + template friend struct EllenBinTreePQueue_pop_min; + + public: + typedef T value_type; + + bool push( value_type const& val ) + { + return base_class::insert( val ); + } + + bool pop( value_type& dest ) + { + return Max ? EllenBinTreePQueue_pop_max< typename base_class::gc >()(dest, *this) + : EllenBinTreePQueue_pop_min< typename base_class::gc >()(dest, *this); + } + + void clear() + { + base_class::clear(); + } + + bool empty() const + { + return base_class::empty(); + } + + size_t size() const + { + return base_class::size(); + } + + typename base_class::stat const& statistics() const + { + return base_class::statistics(); + } + }; + + + // SkipList property queue + template + struct SkipListPQueue_pop_max + { + template + bool operator()( T& dest, Set& container ) const + { + typename Set::guarded_ptr gp( container.extract_max() ); + if ( gp ) + dest = *gp; + return !gp.empty(); + } + }; + + template + struct SkipListPQueue_pop_max< cds::urcu::gc > + { + template + bool operator()( T& dest, Set& container ) const + { + typename Set::exempt_ptr ep( container.extract_max() ); + if ( ep ) + dest = *ep; + return !ep.empty(); + } + }; + + template + struct SkipListPQueue_pop_min + { + template + bool operator()( T& dest, Set& container ) const + { + typename Set::guarded_ptr gp( container.extract_min() ); + if ( gp ) + dest = *gp; + return !gp.empty(); + } + }; + + template + struct SkipListPQueue_pop_min< cds::urcu::gc > + { + template + bool operator()( T& dest, Set& container ) const + { + typename Set::exempt_ptr ep( container.extract_min() ); + if ( ep ) + dest = *ep; + return !ep.empty(); + } + }; + + template + class SkipListPQueue : protected cds::container::SkipListSet< GC, T, Traits > + { + typedef cds::container::SkipListSet< GC, T, Traits > base_class; + template friend struct SkipListPQueue_pop_max; + template friend struct SkipListPQueue_pop_min; + + public: + typedef T value_type; + + bool push( value_type const& val ) + { + return base_class::insert( val ); + } + + bool pop( value_type& dest ) + { + return Max ? SkipListPQueue_pop_max< typename base_class::gc >()(dest, *this) + : SkipListPQueue_pop_min< typename base_class::gc >()(dest, *this); + } + + void clear() + { + base_class::clear(); + } + + bool empty() const + { + return base_class::empty(); + } + + size_t size() const + { + return base_class::size(); + } + + typename base_class::stat const& statistics() const + { + return base_class::statistics(); + } + }; + + } // namespace details + + template + struct Types + { + static size_t const c_nBoundedCapacity = 1024 * 1024 * 16; + + typedef std::less less; + + struct cmp { + int operator()( Value const& v1, Value const& v2 ) const + { + return less()( v1, v2 ) ? -1 : less()( v2, v1 ) ? 1 : 0; + } + }; + + typedef cds::urcu::gc< cds::urcu::general_instant<> > rcu_gpi; + typedef cds::urcu::gc< cds::urcu::general_buffered<> > rcu_gpb; + typedef cds::urcu::gc< cds::urcu::general_threaded<> > rcu_gpt; +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + typedef cds::urcu::gc< cds::urcu::signal_buffered<> > rcu_shb; + typedef cds::urcu::gc< cds::urcu::signal_threaded<> > rcu_sht; +#endif + + + // MSPriorityQueue + struct traits_MSPriorityQueue_static_less : public + cc::mspriority_queue::make_traits < + co::buffer < co::v::static_buffer< char, c_nBoundedCapacity > > + > ::type + {}; + typedef cc::MSPriorityQueue< Value, traits_MSPriorityQueue_static_less > MSPriorityQueue_static_less; + + struct traits_MSPriorityQueue_static_less_stat : public cc::mspriority_queue::traits + { + typedef co::v::static_buffer< char, c_nBoundedCapacity > buffer; + typedef cc::mspriority_queue::stat<> stat; + }; + typedef cc::MSPriorityQueue< Value, traits_MSPriorityQueue_static_less_stat > MSPriorityQueue_static_less_stat; + + struct traits_MSPriorityQueue_static_cmp : public + cc::mspriority_queue::make_traits < + co::buffer< co::v::static_buffer< char, c_nBoundedCapacity > > + , co::compare < cmp > + > ::type + {}; + typedef cc::MSPriorityQueue< Value, traits_MSPriorityQueue_static_cmp > MSPriorityQueue_static_cmp; + + struct traits_MSPriorityQueue_static_mutex : public + cc::mspriority_queue::make_traits< + co::buffer< co::v::static_buffer< char, c_nBoundedCapacity > > + , co::lock_type + >::type + {}; + typedef cc::MSPriorityQueue< Value, traits_MSPriorityQueue_static_mutex > MSPriorityQueue_static_mutex; + + struct traits_MSPriorityQueue_dyn_less : public + cc::mspriority_queue::make_traits< + co::buffer< co::v::dynamic_buffer< char > > + >::type + {}; + typedef cc::MSPriorityQueue< Value, traits_MSPriorityQueue_dyn_less > MSPriorityQueue_dyn_less; + + struct traits_MSPriorityQueue_dyn_less_stat : public + cc::mspriority_queue::make_traits < + co::buffer< co::v::dynamic_buffer< char > > + , co::stat < cc::mspriority_queue::stat<> > + > ::type + {}; + typedef cc::MSPriorityQueue< Value, traits_MSPriorityQueue_dyn_less_stat > MSPriorityQueue_dyn_less_stat; + + struct traits_MSPriorityQueue_dyn_cmp : public + cc::mspriority_queue::make_traits < + co::buffer< co::v::dynamic_buffer< char > > + , co::compare < cmp > + > ::type + {}; + typedef cc::MSPriorityQueue< Value, traits_MSPriorityQueue_dyn_cmp > MSPriorityQueue_dyn_cmp; + + struct traits_MSPriorityQueue_dyn_mutex : public + cc::mspriority_queue::make_traits < + co::buffer< co::v::dynamic_buffer< char > > + , co::lock_type < std::mutex > + > ::type + {}; + typedef cc::MSPriorityQueue< Value, traits_MSPriorityQueue_dyn_mutex > MSPriorityQueue_dyn_mutex; + + + // Priority queue based on EllenBinTreeSet + struct traits_EllenBinTree_max : + public cc::ellen_bintree::make_set_traits< + cc::ellen_bintree::key_extractor< typename Value::key_extractor > + ,cc::opt::less< std::less > + ,co::stat< cc::ellen_bintree::stat<> > + >::type + {}; + typedef details::EllenBinTreePQueue< cds::gc::HP, typename Value::key_type, Value, traits_EllenBinTree_max > EllenBinTree_HP_max; + typedef details::EllenBinTreePQueue< cds::gc::DHP, typename Value::key_type, Value, traits_EllenBinTree_max > EllenBinTree_DHP_max; + typedef details::EllenBinTreePQueue< rcu_gpi, typename Value::key_type, Value, traits_EllenBinTree_max > EllenBinTree_RCU_gpi_max; + typedef details::EllenBinTreePQueue< rcu_gpb, typename Value::key_type, Value, traits_EllenBinTree_max > EllenBinTree_RCU_gpb_max; + typedef details::EllenBinTreePQueue< rcu_gpt, typename Value::key_type, Value, traits_EllenBinTree_max > EllenBinTree_RCU_gpt_max; +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + typedef details::EllenBinTreePQueue< rcu_shb, typename Value::key_type, Value, traits_EllenBinTree_max > EllenBinTree_RCU_shb_max; + typedef details::EllenBinTreePQueue< rcu_sht, typename Value::key_type, Value, traits_EllenBinTree_max > EllenBinTree_RCU_sht_max; +#endif + + struct traits_EllenBinTree_max_stat : + public cc::ellen_bintree::make_set_traits< + cc::ellen_bintree::key_extractor< typename Value::key_extractor > + ,cc::opt::less< std::less > + ,co::stat< cc::ellen_bintree::stat<> > + >::type + {}; + typedef details::EllenBinTreePQueue< cds::gc::HP, typename Value::key_type, Value, traits_EllenBinTree_max_stat > EllenBinTree_HP_max_stat; + typedef details::EllenBinTreePQueue< cds::gc::DHP, typename Value::key_type, Value, traits_EllenBinTree_max_stat > EllenBinTree_DHP_max_stat; + typedef details::EllenBinTreePQueue< rcu_gpi, typename Value::key_type, Value, traits_EllenBinTree_max_stat > EllenBinTree_RCU_gpi_max_stat; + typedef details::EllenBinTreePQueue< rcu_gpb, typename Value::key_type, Value, traits_EllenBinTree_max_stat > EllenBinTree_RCU_gpb_max_stat; + typedef details::EllenBinTreePQueue< rcu_gpt, typename Value::key_type, Value, traits_EllenBinTree_max_stat > EllenBinTree_RCU_gpt_max_stat; +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + typedef details::EllenBinTreePQueue< rcu_shb, typename Value::key_type, Value, traits_EllenBinTree_max_stat > EllenBinTree_RCU_shb_max_stat; + typedef details::EllenBinTreePQueue< rcu_sht, typename Value::key_type, Value, traits_EllenBinTree_max_stat > EllenBinTree_RCU_sht_max_stat; +#endif + + struct traits_EllenBinTree_min : + public cc::ellen_bintree::make_set_traits< + cc::ellen_bintree::key_extractor< typename Value::key_extractor > + ,cc::opt::less< std::greater > + >::type + {}; + typedef details::EllenBinTreePQueue< cds::gc::HP, typename Value::key_type, Value, traits_EllenBinTree_min, false > EllenBinTree_HP_min; + typedef details::EllenBinTreePQueue< cds::gc::DHP, typename Value::key_type, Value, traits_EllenBinTree_min, false > EllenBinTree_DHP_min; + typedef details::EllenBinTreePQueue< rcu_gpi, typename Value::key_type, Value, traits_EllenBinTree_min, false > EllenBinTree_RCU_gpi_min; + typedef details::EllenBinTreePQueue< rcu_gpb, typename Value::key_type, Value, traits_EllenBinTree_min, false > EllenBinTree_RCU_gpb_min; + typedef details::EllenBinTreePQueue< rcu_gpt, typename Value::key_type, Value, traits_EllenBinTree_min, false > EllenBinTree_RCU_gpt_min; +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + typedef details::EllenBinTreePQueue< rcu_shb, typename Value::key_type, Value, traits_EllenBinTree_min, false > EllenBinTree_RCU_shb_min; + typedef details::EllenBinTreePQueue< rcu_sht, typename Value::key_type, Value, traits_EllenBinTree_min, false > EllenBinTree_RCU_sht_min; +#endif + + struct traits_EllenBinTree_min_stat : + public cc::ellen_bintree::make_set_traits< + cc::ellen_bintree::key_extractor< typename Value::key_extractor > + ,cc::opt::less< std::greater > + ,co::stat< cc::ellen_bintree::stat<> > + >::type + {}; + typedef details::EllenBinTreePQueue< cds::gc::HP, typename Value::key_type, Value, traits_EllenBinTree_min_stat, false > EllenBinTree_HP_min_stat; + typedef details::EllenBinTreePQueue< cds::gc::DHP, typename Value::key_type, Value, traits_EllenBinTree_min_stat, false > EllenBinTree_DHP_min_stat; + typedef details::EllenBinTreePQueue< rcu_gpi, typename Value::key_type, Value, traits_EllenBinTree_min_stat, false > EllenBinTree_RCU_gpi_min_stat; + typedef details::EllenBinTreePQueue< rcu_gpb, typename Value::key_type, Value, traits_EllenBinTree_min_stat, false > EllenBinTree_RCU_gpb_min_stat; + typedef details::EllenBinTreePQueue< rcu_gpt, typename Value::key_type, Value, traits_EllenBinTree_min_stat, false > EllenBinTree_RCU_gpt_min_stat; +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + typedef details::EllenBinTreePQueue< rcu_shb, typename Value::key_type, Value, traits_EllenBinTree_min_stat, false > EllenBinTree_RCU_shb_min_stat; + typedef details::EllenBinTreePQueue< rcu_sht, typename Value::key_type, Value, traits_EllenBinTree_min_stat, false > EllenBinTree_RCU_sht_min_stat; +#endif + + // Priority queue based on SkipListSet + struct traits_SkipList_max : + public cc::skip_list::make_traits < + cc::opt::less < std::less > + > ::type + {}; + typedef details::SkipListPQueue< cds::gc::HP, Value, traits_SkipList_max > SkipList_HP_max; + typedef details::SkipListPQueue< cds::gc::DHP, Value, traits_SkipList_max > SkipList_DHP_max; + typedef details::SkipListPQueue< rcu_gpi, Value, traits_SkipList_max > SkipList_RCU_gpi_max; + typedef details::SkipListPQueue< rcu_gpb, Value, traits_SkipList_max > SkipList_RCU_gpb_max; + typedef details::SkipListPQueue< rcu_gpt, Value, traits_SkipList_max > SkipList_RCU_gpt_max; +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + typedef details::SkipListPQueue< rcu_shb, Value, traits_SkipList_max > SkipList_RCU_shb_max; + typedef details::SkipListPQueue< rcu_sht, Value, traits_SkipList_max > SkipList_RCU_sht_max; +#endif + + struct traits_SkipList_max_stat : + public cc::skip_list::make_traits< + cc::opt::less< std::less > + ,co::stat< cc::skip_list::stat<> > + >::type + {}; + typedef details::SkipListPQueue< cds::gc::HP, Value, traits_SkipList_max_stat > SkipList_HP_max_stat; + typedef details::SkipListPQueue< cds::gc::DHP, Value, traits_SkipList_max_stat > SkipList_DHP_max_stat; + typedef details::SkipListPQueue< rcu_gpi, Value, traits_SkipList_max_stat > SkipList_RCU_gpi_max_stat; + typedef details::SkipListPQueue< rcu_gpb, Value, traits_SkipList_max_stat > SkipList_RCU_gpb_max_stat; + typedef details::SkipListPQueue< rcu_gpt, Value, traits_SkipList_max_stat > SkipList_RCU_gpt_max_stat; +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + typedef details::SkipListPQueue< rcu_shb, Value, traits_SkipList_max_stat > SkipList_RCU_shb_max_stat; + typedef details::SkipListPQueue< rcu_sht, Value, traits_SkipList_max_stat > SkipList_RCU_sht_max_stat; +#endif + + struct traits_SkipList_min : + public cc::skip_list::make_traits< + cc::opt::less< std::greater > + >::type + {}; + typedef details::SkipListPQueue< cds::gc::HP, Value, traits_SkipList_min, false > SkipList_HP_min; + typedef details::SkipListPQueue< cds::gc::DHP, Value, traits_SkipList_min, false > SkipList_DHP_min; + typedef details::SkipListPQueue< rcu_gpi, Value, traits_SkipList_min, false > SkipList_RCU_gpi_min; + typedef details::SkipListPQueue< rcu_gpb, Value, traits_SkipList_min, false > SkipList_RCU_gpb_min; + typedef details::SkipListPQueue< rcu_gpt, Value, traits_SkipList_min, false > SkipList_RCU_gpt_min; +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + typedef details::SkipListPQueue< rcu_shb, Value, traits_SkipList_min, false > SkipList_RCU_shb_min; + typedef details::SkipListPQueue< rcu_sht, Value, traits_SkipList_min, false > SkipList_RCU_sht_min; +#endif + + struct traits_SkipList_min_stat : + public cc::skip_list::make_traits< + cc::opt::less< std::greater > + ,co::stat< cc::skip_list::stat<> > + >::type + {}; + typedef details::SkipListPQueue< cds::gc::HP, Value, traits_SkipList_min_stat, false > SkipList_HP_min_stat; + typedef details::SkipListPQueue< cds::gc::DHP, Value, traits_SkipList_min_stat, false > SkipList_DHP_min_stat; + typedef details::SkipListPQueue< rcu_gpi, Value, traits_SkipList_min_stat, false > SkipList_RCU_gpi_min_stat; + typedef details::SkipListPQueue< rcu_gpb, Value, traits_SkipList_min_stat, false > SkipList_RCU_gpb_min_stat; + typedef details::SkipListPQueue< rcu_gpt, Value, traits_SkipList_min_stat, false > SkipList_RCU_gpt_min_stat; +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + typedef details::SkipListPQueue< rcu_shb, Value, traits_SkipList_min_stat, false > SkipList_RCU_shb_min_stat; + typedef details::SkipListPQueue< rcu_sht, Value, traits_SkipList_min_stat, false > SkipList_RCU_sht_min_stat; +#endif + + + // FCPriorityQueue + struct traits_FCPQueue_stat : public + cds::container::fcpqueue::make_traits < + cds::opt::stat < cds::container::fcpqueue::stat<> > + > ::type + {}; + + typedef cds::container::FCPriorityQueue< Value > FCPQueue_vector; + typedef cds::container::FCPriorityQueue< Value + ,std::priority_queue + ,traits_FCPQueue_stat + > FCPQueue_vector_stat; + + typedef cds::container::FCPriorityQueue< Value + ,std::priority_queue > + > FCPQueue_deque; + typedef cds::container::FCPriorityQueue< Value + ,std::priority_queue > + ,traits_FCPQueue_stat + > FCPQueue_deque_stat; + + typedef cds::container::FCPriorityQueue< Value + ,std::priority_queue > + > FCPQueue_boost_deque; + typedef cds::container::FCPriorityQueue< Value + ,std::priority_queue > + ,traits_FCPQueue_stat + > FCPQueue_boost_deque_stat; + + typedef cds::container::FCPriorityQueue< Value + ,std::priority_queue > + > FCPQueue_boost_stable_vector; + typedef cds::container::FCPriorityQueue< Value + ,std::priority_queue > + ,traits_FCPQueue_stat + > FCPQueue_boost_stable_vector_stat; + + /// Standard priority_queue + typedef details::StdPQueue< Value, std::vector, cds::sync::spin> StdPQueue_vector_spin; + typedef details::StdPQueue< Value, std::vector, std::mutex > StdPQueue_vector_mutex; + typedef details::StdPQueue< Value, std::deque, cds::sync::spin> StdPQueue_deque_spin; + typedef details::StdPQueue< Value, std::deque, std::mutex > StdPQueue_deque_mutex; + }; + + + //template + //static inline void check_statistics( Stat const& /*s*/ ) + //{} + + //static inline void check_statistics( cds::container::ellen_bintree::stat<> const& s ) + //{ + // CPPUNIT_CHECK_CURRENT( s.m_nInternalNodeCreated.get() == s.m_nInternalNodeDeleted.get() ); + // CPPUNIT_CHECK_CURRENT( s.m_nUpdateDescCreated.get() == s.m_nUpdateDescDeleted.get() ); + //} +} // namespace pqueue + + +// ********************************************* +// Priority queue statistics +namespace cds_test { + + static inline property_stream& operator <<( property_stream& o, cds::opt::none ) + { + return o; + } + + static inline property_stream& operator <<( property_stream& o, cds::container::fcpqueue::empty_stat const& ) + { + return o; + } + + static inline property_stream& operator <<( property_stream& o, cds::container::fcpqueue::stat<> const& s ) + { + return o + << CDSSTRESS_STAT_OUT( s, m_nPush ) + << CDSSTRESS_STAT_OUT( s, m_nPushMove ) + << CDSSTRESS_STAT_OUT( s, m_nPop ) + << CDSSTRESS_STAT_OUT( s, m_nFailedPop ) + << CDSSTRESS_STAT_OUT_( "combining_factor", s.combining_factor() ) + << CDSSTRESS_STAT_OUT( s, m_nOperationCount ) + << CDSSTRESS_STAT_OUT( s, m_nCombiningCount ) + << CDSSTRESS_STAT_OUT( s, m_nCompactPublicationList ) + << CDSSTRESS_STAT_OUT( s, m_nDeactivatePubRecord ) + << CDSSTRESS_STAT_OUT( s, m_nActivatePubRecord ) + << CDSSTRESS_STAT_OUT( s, m_nPubRecordCreated ) + << CDSSTRESS_STAT_OUT( s, m_nPubRecordDeteted ) + << CDSSTRESS_STAT_OUT( s, m_nAcquirePubRecCount ) + << CDSSTRESS_STAT_OUT( s, m_nReleasePubRecCount ); + } + + static inline property_stream& operator <<( property_stream& o, cds::container::mspriority_queue::empty_stat const& /*s*/ ) + { + return o; + } + + static inline property_stream& operator <<( property_stream& o, cds::container::mspriority_queue::stat<> const& s ) + { + return o + << CDSSTRESS_STAT_OUT( s, m_nPushCount ) + << CDSSTRESS_STAT_OUT( s, m_nPopCount ) + << CDSSTRESS_STAT_OUT( s, m_nPushFailCount ) + << CDSSTRESS_STAT_OUT( s, m_nPopFailCount ) + << CDSSTRESS_STAT_OUT( s, m_nPushHeapifySwapCount ) + << CDSSTRESS_STAT_OUT( s, m_nPopHeapifySwapCount ); + } + +} // namespace cds_test + +#endif // #ifndef CDSSTRESS_PQUEUE_TYPES_H diff --git a/test/stress/pqueue/push.cpp b/test/stress/pqueue/push.cpp new file mode 100644 index 00000000..8b122d52 --- /dev/null +++ b/test/stress/pqueue/push.cpp @@ -0,0 +1,264 @@ +/* + 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 "pqueue_type.h" +#include "item.h" + +namespace pqueue { + + static size_t s_nThreadCount = 8; + static size_t s_nQueueSize = 2000000; + + class pqueue_push: public cds_test::stress_fixture + { + typedef cds_test::stress_fixture base_class; + + protected: + template + class Producer: public cds_test::thread + { + typedef cds_test::thread base_class; + + public: + Producer( cds_test::thread_pool& pool, PQueue& queue ) + : base_class( pool ) + , m_Queue( queue ) + {} + + Producer( Producer& src ) + : base_class( src ) + , m_Queue( src.m_Queue ) + {} + + virtual thread * clone() + { + return new Producer( *this ); + } + + virtual void test() + { + typedef typename PQueue::value_type value_type; + + for ( auto it = m_arr.begin(); it != m_arr.end(); ++it ) { + if ( !m_Queue.push( value_type( *it ) )) + ++m_nPushError; + } + } + + void prepare( size_t nStart, size_t nEnd ) + { + m_arr.reserve( nEnd - nStart ); + for ( size_t i = nStart; i < nEnd; ++i ) + m_arr.push_back( i ); + shuffle( m_arr.begin(), m_arr.end() ); + } + + public: + PQueue& m_Queue; + size_t m_nPushError = 0; + std::vector m_arr; + }; + + protected: + template + void analyze( PQueue& q ) + { + cds_test::thread_pool& pool = get_pool(); + + for ( size_t i = 0; i < pool.size(); ++i ) { + Producer& prod = static_cast&>(pool.get( i )); + EXPECT_EQ( prod.m_nPushError, 0 ) << "producer=" << i; + } + EXPECT_FALSE( q.empty()); + + typedef std::vector vector_type; + vector_type arr; + arr.reserve( s_nQueueSize ); + + size_t nPopped = 0; + typename PQueue::value_type val; + while ( q.pop( val )) { + nPopped++; + arr.push_back( val.key ); + } + + EXPECT_EQ( arr.size(), s_nQueueSize ); + auto it = arr.begin(); + size_t nPrev = *it; + ++it; + for ( auto itEnd = arr.end(); it != itEnd; ++it ) { + EXPECT_EQ( nPrev - 1, *it ); + nPrev = *it; + } + } + + template + void test( PQueue& q ) + { + cds_test::thread_pool& pool = get_pool(); + pool.add( new Producer( pool, q ), s_nThreadCount ); + + size_t nStart = 0; + size_t nThreadItemCount = s_nQueueSize / s_nThreadCount; + s_nQueueSize = nThreadItemCount * s_nThreadCount; + + for ( size_t i = 0; i < pool.size(); ++i ) { + static_cast&>(pool.get( i )).prepare( nStart, nStart + nThreadItemCount ); + nStart += nThreadItemCount; + } + + propout() << std::make_pair( "thread_count", s_nThreadCount ) + << std::make_pair( "push_count", s_nQueueSize ); + + std::chrono::milliseconds duration = pool.run(); + propout() << std::make_pair( "duration", duration ); + + analyze( q ); + + propout() << q.statistics(); + } + + public: + static void SetUpTestCase() + { + cds_test::config const& cfg = get_config( "pqueue_push" ); + + s_nThreadCount = cfg.get_size_t( "ThreadCount", s_nThreadCount ); + s_nQueueSize = cfg.get_size_t( "QueueSize", s_nQueueSize ); + + if ( s_nThreadCount == 0 ) + s_nThreadCount = 1; + if ( s_nQueueSize == 0 ) + s_nQueueSize = 1000; + } + + //static void TearDownTestCase(); + }; + +#define CDSSTRESS_MSPriorityQueue( fixture_t, pqueue_t ) \ + TEST_F( fixture_t, pqueue_t ) \ + { \ + typedef pqueue::Types::pqueue_t pqueue_type; \ + pqueue_type pq( s_nQueueSize ); \ + test( pq ); \ + } + CDSSTRESS_MSPriorityQueue( pqueue_push, MSPriorityQueue_dyn_less ) + CDSSTRESS_MSPriorityQueue( pqueue_push, MSPriorityQueue_dyn_less_stat ) + CDSSTRESS_MSPriorityQueue( pqueue_push, MSPriorityQueue_dyn_cmp ) + CDSSTRESS_MSPriorityQueue( pqueue_push, MSPriorityQueue_dyn_mutex ) + +#define CDSSTRESS_MSPriorityQueue_static( fixture_t, pqueue_t ) \ + TEST_F( fixture_t, pqueue_t ) \ + { \ + typedef pqueue::Types::pqueue_t pqueue_type; \ + std::unique_ptr< pqueue_type > pq( new pqueue_type ); \ + test( *pq.get() ); \ + } + //CDSSTRESS_MSPriorityQueue( pqueue_push, MSPriorityQueue_static_less ) + //CDSSTRESS_MSPriorityQueue( pqueue_push, MSPriorityQueue_static_less_stat ) + //CDSSTRESS_MSPriorityQueue( pqueue_push, MSPriorityQueue_static_cmp ) + //CDSSTRESS_MSPriorityQueue( pqueue_push, 1MSPriorityQueue_static_mutex ) + + +#define CDSSTRESS_PriorityQueue( fixture_t, pqueue_t ) \ + TEST_F( fixture_t, pqueue_t ) \ + { \ + typedef pqueue::Types::pqueue_t pqueue_type; \ + pqueue_type pq; \ + test( pq ); \ + } + CDSSTRESS_PriorityQueue( pqueue_push, FCPQueue_vector ) + CDSSTRESS_PriorityQueue( pqueue_push, FCPQueue_vector_stat ) + CDSSTRESS_PriorityQueue( pqueue_push, FCPQueue_deque ) + CDSSTRESS_PriorityQueue( pqueue_push, FCPQueue_deque_stat ) + CDSSTRESS_PriorityQueue( pqueue_push, FCPQueue_boost_deque ) + CDSSTRESS_PriorityQueue( pqueue_push, FCPQueue_boost_deque_stat ) + CDSSTRESS_PriorityQueue( pqueue_push, FCPQueue_boost_stable_vector ) + CDSSTRESS_PriorityQueue( pqueue_push, FCPQueue_boost_stable_vector_stat ) + + CDSSTRESS_PriorityQueue( pqueue_push, EllenBinTree_HP_max ) + CDSSTRESS_PriorityQueue( pqueue_push, EllenBinTree_HP_max_stat ) + CDSSTRESS_PriorityQueue( pqueue_push, EllenBinTree_HP_min ) + CDSSTRESS_PriorityQueue( pqueue_push, EllenBinTree_HP_min_stat ) + CDSSTRESS_PriorityQueue( pqueue_push, EllenBinTree_DHP_max ) + CDSSTRESS_PriorityQueue( pqueue_push, EllenBinTree_DHP_max_stat ) + CDSSTRESS_PriorityQueue( pqueue_push, EllenBinTree_DHP_min ) + CDSSTRESS_PriorityQueue( pqueue_push, EllenBinTree_DHP_min_stat ) + // CDSSTRESS_PriorityQueue( pqueue_push, EllenBinTree_RCU_gpi_max ) + // CDSSTRESS_PriorityQueue( pqueue_push, EllenBinTree_RCU_gpi_max_stat ) + // CDSSTRESS_PriorityQueue( pqueue_push, EllenBinTree_RCU_gpi_min ) + // CDSSTRESS_PriorityQueue( pqueue_push, EllenBinTree_RCU_gpi_min_stat ) + CDSSTRESS_PriorityQueue( pqueue_push, EllenBinTree_RCU_gpb_max ) + CDSSTRESS_PriorityQueue( pqueue_push, EllenBinTree_RCU_gpb_max_stat ) + CDSSTRESS_PriorityQueue( pqueue_push, EllenBinTree_RCU_gpb_min ) + CDSSTRESS_PriorityQueue( pqueue_push, EllenBinTree_RCU_gpb_min_stat ) + CDSSTRESS_PriorityQueue( pqueue_push, EllenBinTree_RCU_gpt_max ) + CDSSTRESS_PriorityQueue( pqueue_push, EllenBinTree_RCU_gpt_max_stat ) + CDSSTRESS_PriorityQueue( pqueue_push, EllenBinTree_RCU_gpt_min ) + CDSSTRESS_PriorityQueue( pqueue_push, EllenBinTree_RCU_gpt_min_stat ) +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + CDSSTRESS_PriorityQueue( pqueue_push, EllenBinTree_RCU_shb_max ) + CDSSTRESS_PriorityQueue( pqueue_push, EllenBinTree_RCU_shb_max_stat ) + CDSSTRESS_PriorityQueue( pqueue_push, EllenBinTree_RCU_shb_min ) + CDSSTRESS_PriorityQueue( pqueue_push, EllenBinTree_RCU_shb_min_stat ) + CDSSTRESS_PriorityQueue( pqueue_push, EllenBinTree_RCU_sht_max ) + CDSSTRESS_PriorityQueue( pqueue_push, EllenBinTree_RCU_sht_max_stat ) + CDSSTRESS_PriorityQueue( pqueue_push, EllenBinTree_RCU_sht_min ) + CDSSTRESS_PriorityQueue( pqueue_push, EllenBinTree_RCU_sht_min_stat ) +#endif + + CDSSTRESS_PriorityQueue( pqueue_push, SkipList_HP_max ) + CDSSTRESS_PriorityQueue( pqueue_push, SkipList_HP_max_stat ) + CDSSTRESS_PriorityQueue( pqueue_push, SkipList_HP_min ) + CDSSTRESS_PriorityQueue( pqueue_push, SkipList_HP_min_stat ) + CDSSTRESS_PriorityQueue( pqueue_push, SkipList_DHP_max ) + CDSSTRESS_PriorityQueue( pqueue_push, SkipList_DHP_max_stat ) + CDSSTRESS_PriorityQueue( pqueue_push, SkipList_DHP_min ) + CDSSTRESS_PriorityQueue( pqueue_push, SkipList_DHP_min_stat ) + CDSSTRESS_PriorityQueue( pqueue_push, SkipList_RCU_gpi_max ) + CDSSTRESS_PriorityQueue( pqueue_push, SkipList_RCU_gpi_min ) + CDSSTRESS_PriorityQueue( pqueue_push, SkipList_RCU_gpb_max ) + CDSSTRESS_PriorityQueue( pqueue_push, SkipList_RCU_gpb_min ) + CDSSTRESS_PriorityQueue( pqueue_push, SkipList_RCU_gpt_max ) + CDSSTRESS_PriorityQueue( pqueue_push, SkipList_RCU_gpt_min ) +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + CDSSTRESS_PriorityQueue( pqueue_push, SkipList_RCU_shb_max ) + CDSSTRESS_PriorityQueue( pqueue_push, SkipList_RCU_shb_min ) + CDSSTRESS_PriorityQueue( pqueue_push, SkipList_RCU_sht_max ) + CDSSTRESS_PriorityQueue( pqueue_push, SkipList_RCU_sht_min ) +#endif + + CDSSTRESS_PriorityQueue( pqueue_push, StdPQueue_vector_spin ) + CDSSTRESS_PriorityQueue( pqueue_push, StdPQueue_vector_mutex ) + CDSSTRESS_PriorityQueue( pqueue_push, StdPQueue_deque_spin ) + CDSSTRESS_PriorityQueue( pqueue_push, StdPQueue_deque_mutex ) + +} // namespace queue + diff --git a/test/stress/pqueue/push_pop.cpp b/test/stress/pqueue/push_pop.cpp new file mode 100644 index 00000000..f9555a43 --- /dev/null +++ b/test/stress/pqueue/push_pop.cpp @@ -0,0 +1,317 @@ +/* + 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 "pqueue_type.h" +#include "item.h" + +namespace { + static size_t s_nPushThreadCount = 4; + static size_t s_nPopThreadCount = 4; + static size_t s_nQueueSize = 2000000; + + atomics::atomic s_nProducerCount(0); + + class pqueue_push_pop: public cds_test::stress_fixture + { + typedef cds_test::stress_fixture base_class; + + public: + enum { + producer_thread, + consumer_thread + }; + + template + class Producer: public cds_test::thread + { + typedef cds_test::thread base_class; + + public: + Producer( cds_test::thread_pool& pool, PQueue& queue ) + : base_class( pool, producer_thread ) + , m_Queue( queue ) + {} + + Producer( Producer& src ) + : base_class( src ) + , m_Queue( src.m_Queue ) + {} + + virtual thread * clone() + { + return new Producer( *this ); + } + + virtual void test() + { + typedef typename PQueue::value_type value_type; + + for ( auto it = m_arr.begin(); it != m_arr.end(); ++it ) { + if ( !m_Queue.push( value_type( *it ))) + ++m_nPushError; + } + + s_nProducerCount.fetch_sub( 1, atomics::memory_order_relaxed ); + } + + void prepare( size_t nStart, size_t nEnd ) + { + m_arr.reserve( nEnd - nStart ); + for ( size_t i = nStart; i < nEnd; ++i ) + m_arr.push_back( i ); + shuffle( m_arr.begin(), m_arr.end() ); + } + + public: + PQueue& m_Queue; + size_t m_nPushError = 0; + + typedef std::vector array_type; + array_type m_arr; + }; + + template + class Consumer: public cds_test::thread + { + typedef cds_test::thread base_class; + + public: + Consumer( cds_test::thread_pool& pool, PQueue& queue ) + : base_class( pool, consumer_thread ) + , m_Queue( queue ) + {} + + Consumer( Consumer& src ) + : base_class( src ) + , m_Queue( src.m_Queue ) + {} + + virtual thread * clone() + { + return new Consumer( *this ); + } + + virtual void test() + { + typename PQueue::value_type val; + while ( s_nProducerCount.load( atomics::memory_order_relaxed ) != 0 || !m_Queue.empty() ) { + if ( m_Queue.pop( val )) + ++m_nPopSuccess; + else + ++m_nPopFailed; + } + } + + public: + PQueue& m_Queue; + size_t m_nPopSuccess = 0; + size_t m_nPopFailed = 0; + + typedef std::vector array_type; + array_type m_arr; + }; + + protected: + + template + void test( PQueue& q ) + { + size_t const nThreadItemCount = s_nQueueSize / s_nPushThreadCount; + s_nQueueSize = nThreadItemCount * s_nPushThreadCount; + + propout() << std::make_pair( "producer_count", s_nPushThreadCount ) + << std::make_pair( "consunmer_count", s_nPopThreadCount ) + << std::make_pair( "queue_size", s_nQueueSize ); + + cds_test::thread_pool& pool = get_pool(); + pool.add( new Producer( pool, q ), s_nPushThreadCount ); + + size_t nStart = 0; + for ( size_t i = 0; i < pool.size(); ++i ) { + static_cast&>(pool.get( i )).prepare( nStart, nStart + nThreadItemCount ); + nStart += nThreadItemCount; + } + + pool.add( new Consumer( pool, q ), s_nPopThreadCount ); + + s_nProducerCount.store( s_nPushThreadCount, atomics::memory_order_release ); + + std::chrono::milliseconds duration = pool.run(); + propout() << std::make_pair( "duration", duration ); + + // Analyze result + size_t nTotalPopped = 0; + size_t nPushFailed = 0; + size_t nPopFailed = 0; + for ( size_t i = 0; i < pool.size(); ++i ) { + cds_test::thread& t = pool.get(i); + if ( t.type() == consumer_thread ) { + Consumer& cons = static_cast&>( t ); + nTotalPopped += cons.m_nPopSuccess; + nPopFailed += cons.m_nPopFailed; + } + else { + assert( t.type() == producer_thread ); + Producer& prod = static_cast&>(t); + nPushFailed += prod.m_nPushError; + EXPECT_EQ( prod.m_nPushError , 0 ) << "producer " << i; + } + } + + propout() << std::make_pair( "total_popped", nTotalPopped ) + << std::make_pair( "empty_pop", nPopFailed ) + << std::make_pair( "push_error", nPushFailed ); + + EXPECT_EQ( nTotalPopped, s_nQueueSize ); + EXPECT_EQ( nPushFailed, 0 ); + + //check_statistics( testQueue.statistics() ); + propout() << q.statistics(); + } + + public: + static void SetUpTestCase() + { + cds_test::config const& cfg = get_config( "pqueue_push_pop" ); + + s_nPushThreadCount = cfg.get_size_t( "PushThreadCount", s_nPushThreadCount ); + s_nPopThreadCount = cfg.get_size_t( "PopThreadCount", s_nPopThreadCount ); + s_nQueueSize = cfg.get_size_t( "QueueSize", s_nQueueSize ); + + if ( s_nPushThreadCount == 0 ) + s_nPushThreadCount = 1; + if ( s_nPopThreadCount == 0 ) + s_nPopThreadCount = 1; + if ( s_nQueueSize == 0 ) + s_nQueueSize = 1000; + } + + //static void TearDownTestCase(); + }; + +#define CDSSTRESS_MSPriorityQueue( fixture_t, pqueue_t ) \ + TEST_F( fixture_t, pqueue_t ) \ + { \ + typedef pqueue::Types::pqueue_t pqueue_type; \ + pqueue_type pq( s_nQueueSize ); \ + test( pq ); \ + } + CDSSTRESS_MSPriorityQueue( pqueue_push_pop, MSPriorityQueue_dyn_less ) + CDSSTRESS_MSPriorityQueue( pqueue_push_pop, MSPriorityQueue_dyn_less_stat ) + CDSSTRESS_MSPriorityQueue( pqueue_push_pop, MSPriorityQueue_dyn_cmp ) + CDSSTRESS_MSPriorityQueue( pqueue_push_pop, MSPriorityQueue_dyn_mutex ) + +#define CDSSTRESS_MSPriorityQueue_static( fixture_t, pqueue_t ) \ + TEST_F( fixture_t, pqueue_t ) \ + { \ + typedef pqueue::Types::pqueue_t pqueue_type; \ + std::unique_ptr< pqueue_type > pq( new pqueue_type ); \ + test( *pq.get() ); \ + } + //CDSSTRESS_MSPriorityQueue( pqueue_push_pop, MSPriorityQueue_static_less ) + //CDSSTRESS_MSPriorityQueue( pqueue_push_pop, MSPriorityQueue_static_less_stat ) + //CDSSTRESS_MSPriorityQueue( pqueue_push_pop, MSPriorityQueue_static_cmp ) + //CDSSTRESS_MSPriorityQueue( pqueue_push_pop, 1MSPriorityQueue_static_mutex ) + + +#define CDSSTRESS_PriorityQueue( fixture_t, pqueue_t ) \ + TEST_F( fixture_t, pqueue_t ) \ + { \ + typedef pqueue::Types::pqueue_t pqueue_type; \ + pqueue_type pq; \ + test( pq ); \ + } + CDSSTRESS_PriorityQueue( pqueue_push_pop, FCPQueue_vector ) + CDSSTRESS_PriorityQueue( pqueue_push_pop, FCPQueue_vector_stat ) + CDSSTRESS_PriorityQueue( pqueue_push_pop, FCPQueue_deque ) + CDSSTRESS_PriorityQueue( pqueue_push_pop, FCPQueue_deque_stat ) + CDSSTRESS_PriorityQueue( pqueue_push_pop, FCPQueue_boost_deque ) + CDSSTRESS_PriorityQueue( pqueue_push_pop, FCPQueue_boost_deque_stat ) + CDSSTRESS_PriorityQueue( pqueue_push_pop, FCPQueue_boost_stable_vector ) + CDSSTRESS_PriorityQueue( pqueue_push_pop, FCPQueue_boost_stable_vector_stat ) + + CDSSTRESS_PriorityQueue( pqueue_push_pop, EllenBinTree_HP_max ) + CDSSTRESS_PriorityQueue( pqueue_push_pop, EllenBinTree_HP_max_stat ) + CDSSTRESS_PriorityQueue( pqueue_push_pop, EllenBinTree_HP_min ) + CDSSTRESS_PriorityQueue( pqueue_push_pop, EllenBinTree_HP_min_stat ) + CDSSTRESS_PriorityQueue( pqueue_push_pop, EllenBinTree_DHP_max ) + CDSSTRESS_PriorityQueue( pqueue_push_pop, EllenBinTree_DHP_max_stat ) + CDSSTRESS_PriorityQueue( pqueue_push_pop, EllenBinTree_DHP_min ) + CDSSTRESS_PriorityQueue( pqueue_push_pop, EllenBinTree_DHP_min_stat ) + // CDSSTRESS_PriorityQueue( pqueue_push_pop, EllenBinTree_RCU_gpi_max ) + // CDSSTRESS_PriorityQueue( pqueue_push_pop, EllenBinTree_RCU_gpi_max_stat ) + // CDSSTRESS_PriorityQueue( pqueue_push_pop, EllenBinTree_RCU_gpi_min ) + // CDSSTRESS_PriorityQueue( pqueue_push_pop, EllenBinTree_RCU_gpi_min_stat ) + CDSSTRESS_PriorityQueue( pqueue_push_pop, EllenBinTree_RCU_gpb_max ) + CDSSTRESS_PriorityQueue( pqueue_push_pop, EllenBinTree_RCU_gpb_max_stat ) + CDSSTRESS_PriorityQueue( pqueue_push_pop, EllenBinTree_RCU_gpb_min ) + CDSSTRESS_PriorityQueue( pqueue_push_pop, EllenBinTree_RCU_gpb_min_stat ) + CDSSTRESS_PriorityQueue( pqueue_push_pop, EllenBinTree_RCU_gpt_max ) + CDSSTRESS_PriorityQueue( pqueue_push_pop, EllenBinTree_RCU_gpt_max_stat ) + CDSSTRESS_PriorityQueue( pqueue_push_pop, EllenBinTree_RCU_gpt_min ) + CDSSTRESS_PriorityQueue( pqueue_push_pop, EllenBinTree_RCU_gpt_min_stat ) +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + CDSSTRESS_PriorityQueue( pqueue_push_pop, EllenBinTree_RCU_shb_max ) + CDSSTRESS_PriorityQueue( pqueue_push_pop, EllenBinTree_RCU_shb_max_stat ) + CDSSTRESS_PriorityQueue( pqueue_push_pop, EllenBinTree_RCU_shb_min ) + CDSSTRESS_PriorityQueue( pqueue_push_pop, EllenBinTree_RCU_shb_min_stat ) + CDSSTRESS_PriorityQueue( pqueue_push_pop, EllenBinTree_RCU_sht_max ) + CDSSTRESS_PriorityQueue( pqueue_push_pop, EllenBinTree_RCU_sht_max_stat ) + CDSSTRESS_PriorityQueue( pqueue_push_pop, EllenBinTree_RCU_sht_min ) + CDSSTRESS_PriorityQueue( pqueue_push_pop, EllenBinTree_RCU_sht_min_stat ) +#endif + + CDSSTRESS_PriorityQueue( pqueue_push_pop, SkipList_HP_max ) + CDSSTRESS_PriorityQueue( pqueue_push_pop, SkipList_HP_max_stat ) + CDSSTRESS_PriorityQueue( pqueue_push_pop, SkipList_HP_min ) + CDSSTRESS_PriorityQueue( pqueue_push_pop, SkipList_HP_min_stat ) + CDSSTRESS_PriorityQueue( pqueue_push_pop, SkipList_DHP_max ) + CDSSTRESS_PriorityQueue( pqueue_push_pop, SkipList_DHP_max_stat ) + CDSSTRESS_PriorityQueue( pqueue_push_pop, SkipList_DHP_min ) + CDSSTRESS_PriorityQueue( pqueue_push_pop, SkipList_DHP_min_stat ) + CDSSTRESS_PriorityQueue( pqueue_push_pop, SkipList_RCU_gpi_max ) + CDSSTRESS_PriorityQueue( pqueue_push_pop, SkipList_RCU_gpi_min ) + CDSSTRESS_PriorityQueue( pqueue_push_pop, SkipList_RCU_gpb_max ) + CDSSTRESS_PriorityQueue( pqueue_push_pop, SkipList_RCU_gpb_min ) + CDSSTRESS_PriorityQueue( pqueue_push_pop, SkipList_RCU_gpt_max ) + CDSSTRESS_PriorityQueue( pqueue_push_pop, SkipList_RCU_gpt_min ) +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + CDSSTRESS_PriorityQueue( pqueue_push_pop, SkipList_RCU_shb_max ) + CDSSTRESS_PriorityQueue( pqueue_push_pop, SkipList_RCU_shb_min ) + CDSSTRESS_PriorityQueue( pqueue_push_pop, SkipList_RCU_sht_max ) + CDSSTRESS_PriorityQueue( pqueue_push_pop, SkipList_RCU_sht_min ) +#endif + + CDSSTRESS_PriorityQueue( pqueue_push_pop, StdPQueue_vector_spin ) + CDSSTRESS_PriorityQueue( pqueue_push_pop, StdPQueue_vector_mutex ) + CDSSTRESS_PriorityQueue( pqueue_push_pop, StdPQueue_deque_spin ) + CDSSTRESS_PriorityQueue( pqueue_push_pop, StdPQueue_deque_mutex ) + +} // namespace diff --git a/tests/unit/CMakeLists.txt b/tests/unit/CMakeLists.txt index fcf80bb2..3efcf921 100644 --- a/tests/unit/CMakeLists.txt +++ b/tests/unit/CMakeLists.txt @@ -15,5 +15,4 @@ target_link_libraries(${PACKAGE_NAME} ${CDS_SHARED_LIBRARY} ${Boost_THREAD_LIBRA add_test(NAME ${PACKAGE_NAME} COMMAND ${PACKAGE_NAME} WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/map2) -add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/pqueue) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/set2) diff --git a/tests/unit/pqueue/CMakeLists.txt b/tests/unit/pqueue/CMakeLists.txt deleted file mode 100644 index ae2a6d8b..00000000 --- a/tests/unit/pqueue/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -set(PACKAGE_NAME cdsu-pqueue) - -set(CDSUNIT_PQUEUE_SOURCES - pop.cpp - push.cpp - push_pop.cpp) - -add_executable(${PACKAGE_NAME} ${CDSUNIT_PQUEUE_SOURCES} $) -target_link_libraries(${PACKAGE_NAME} ${CDS_SHARED_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/tests/unit/pqueue/ellen_bintree_pqueue.h b/tests/unit/pqueue/ellen_bintree_pqueue.h deleted file mode 100644 index f86fa1b3..00000000 --- a/tests/unit/pqueue/ellen_bintree_pqueue.h +++ /dev/null @@ -1,141 +0,0 @@ -/* - 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_STD_ELLEN_BINTREE_PQUEUE_H -#define CDSUNIT_STD_ELLEN_BINTREE_PQUEUE_H - -#include -#include -#include -#include -#include -#include -#include -#include - -namespace pqueue { - - template - struct EllenBinTreePQueue_pop_max - { - template - bool operator()( T& dest, Tree& container ) const - { - typename Tree::guarded_ptr gp( container.extract_max()); - if ( gp ) - dest = *gp; - return !gp.empty(); - } - }; - - template - struct EllenBinTreePQueue_pop_max< cds::urcu::gc > - { - template - bool operator()( T& dest, Tree& container ) const - { - typename Tree::exempt_ptr ep( container.extract_max()); - if ( ep ) - dest = *ep; - return !ep.empty(); - } - }; - - template - struct EllenBinTreePQueue_pop_min - { - template - bool operator()( T& dest, Tree& container ) const - { - typename Tree::guarded_ptr gp( container.extract_min()); - if ( gp ) - dest = *gp; - return !gp.empty(); - } - }; - - template - struct EllenBinTreePQueue_pop_min< cds::urcu::gc > - { - template - bool operator()( T& dest, Tree& container ) const - { - typename Tree::exempt_ptr ep( container.extract_min()); - if ( ep ) - dest = *ep; - return !ep.empty(); - } - }; - - template - class EllenBinTreePQueue: protected cds::container::EllenBinTreeSet< GC, Key, T, Traits > - { - typedef cds::container::EllenBinTreeSet< GC, Key, T, Traits > base_class; - typedef T value_type; - template friend struct EllenBinTreePQueue_pop_max; - template friend struct EllenBinTreePQueue_pop_min; - - public: - bool push( value_type const& val ) - { - return base_class::insert( val ); - } - - bool pop( value_type& dest ) - { - return Max ? EllenBinTreePQueue_pop_max< typename base_class::gc >()( dest, *this ) - : EllenBinTreePQueue_pop_min< typename base_class::gc >()( dest, *this ); - } - - void clear() - { - base_class::clear(); - } - - bool empty() const - { - return base_class::empty(); - } - - size_t size() const - { - return base_class::size(); - } - - typename base_class::stat const& statistics() const - { - return base_class::statistics(); - } - }; - -} // namespace pqueue - - -#endif // #ifndef CDSUNIT_STD_ELLEN_BINTREE_PQUEUE_H diff --git a/tests/unit/pqueue/pop.cpp b/tests/unit/pqueue/pop.cpp deleted file mode 100644 index 1ff6a777..00000000 --- a/tests/unit/pqueue/pop.cpp +++ /dev/null @@ -1,275 +0,0 @@ -/* - 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 "cppunit/thread.h" -#include "pqueue/pqueue_item.h" -#include "pqueue/pqueue_type.h" - -#include -#include - -namespace pqueue { - -#define TEST_CASE( Q ) void Q() { test< Types::Q >(); } -#define TEST_BOUNDED( Q ) void Q() { test_bounded< Types::Q >(); } - - namespace { - static size_t s_nThreadCount = 8; - static size_t s_nQueueSize = 2000000; - } -} // namespace pqueue - -namespace pqueue { - - class PQueue_Pop: public CppUnitMini::TestCase - { - - template - class Pusher: public CppUnitMini::TestThread - { - virtual TestThread * clone() - { - return new Pusher( *this ); - } - public: - PQueue& m_Queue; - size_t m_nPushError; - - typedef std::vector array_type; - array_type m_arr; - - public: - Pusher( CppUnitMini::ThreadPool& pool, PQueue& q ) - : CppUnitMini::TestThread( pool ) - , m_Queue( q ) - {} - Pusher( Pusher& src ) - : CppUnitMini::TestThread( src ) - , m_Queue( src.m_Queue ) - {} - - PQueue_Pop& getTest() - { - return static_cast( m_Pool.m_Test ); - } - - virtual void init() - { - cds::threading::Manager::attachThread(); - } - virtual void fini() - { - cds::threading::Manager::detachThread(); - } - - virtual void test() - { - m_nPushError = 0; - - for ( array_type::const_iterator it = m_arr.begin(); it != m_arr.end(); ++it ) { - if ( !m_Queue.push( SimpleValue( *it ) )) - ++m_nPushError; - } - } - - void prepare( size_t nStart, size_t nEnd ) - { - m_arr.reserve( nEnd - nStart ); - for ( size_t i = nStart; i < nEnd; ++i ) - m_arr.push_back( i ); - shuffle( m_arr.begin(), m_arr.end() ); - } - }; - - template - class Popper: public CppUnitMini::TestThread - { - virtual TestThread * clone() - { - return new Popper( *this ); - } - public: - PQueue& m_Queue; - size_t m_nPopError; - size_t m_nPopErrorEq; - size_t m_nPopSuccess; - size_t m_nPopFailed; - - public: - Popper( CppUnitMini::ThreadPool& pool, PQueue& q ) - : CppUnitMini::TestThread( pool ) - , m_Queue( q ) - {} - Popper( Popper& src ) - : CppUnitMini::TestThread( src ) - , m_Queue( src.m_Queue ) - {} - - PQueue_Pop& getTest() - { - return static_cast( m_Pool.m_Test ); - } - - virtual void init() - { - cds::threading::Manager::attachThread(); - } - virtual void fini() - { - cds::threading::Manager::detachThread(); - } - - virtual void test() - { - m_nPopError = 0; - m_nPopErrorEq = 0; - m_nPopSuccess = 0; - m_nPopFailed = 0; - - size_t nPrevKey; - SimpleValue val; - if ( m_Queue.pop( val )) { - ++m_nPopSuccess; - nPrevKey = val.key; - - while ( !m_Queue.empty() ) { - if ( m_Queue.pop( val )) { - ++m_nPopSuccess; - if ( val.key > nPrevKey ) - ++m_nPopError; - else if ( val.key == nPrevKey ) - ++m_nPopErrorEq; - nPrevKey = val.key; - } - else - ++m_nPopFailed; - } - } - else - ++m_nPopFailed; - } - }; - - protected: - template - void test() - { - PQueue testQueue; - test_with( testQueue ); - } - - template - void test_bounded() - { - std::unique_ptr pq( new PQueue(s_nQueueSize) ); - test_with( *pq.get() ); - } - - template - void test_with( PQueue& testQueue ) - { - size_t const nThreadItemCount = s_nQueueSize / s_nThreadCount; - - // push - { - CppUnitMini::ThreadPool pool( *this ); - pool.add( new Pusher( pool, testQueue ), s_nThreadCount ); - - size_t nStart = 0; - for ( CppUnitMini::ThreadPool::iterator it = pool.begin(); it != pool.end(); ++it ) { - Pusher * pThread = static_cast *>(*it); - pThread->prepare( nStart, nStart + nThreadItemCount ); - nStart += nThreadItemCount; - } - - CPPUNIT_MSG( " Push, thread count=" << s_nThreadCount << ", item count=" << nThreadItemCount * s_nThreadCount << " ..." ); - pool.run(); - CPPUNIT_MSG( " Duration=" << pool.avgDuration() ); - } - - // pop - { - CppUnitMini::ThreadPool pool( *this ); - pool.add( new Popper( pool, testQueue ), s_nThreadCount ); - - CPPUNIT_MSG( " Pop, thread count=" << s_nThreadCount << ", item count=" << nThreadItemCount * s_nThreadCount << " ..." ); - pool.run(); - CPPUNIT_MSG( " Duration=" << pool.avgDuration() ); - - // Analyze result - size_t nTotalPopped = 0; - size_t nTotalError = 0; - size_t nTotalErrorEq = 0; - size_t nTotalFailed = 0; - for ( CppUnitMini::ThreadPool::iterator it = pool.begin(); it != pool.end(); ++it ) { - Popper * pThread = static_cast *>(*it); - - nTotalPopped += pThread->m_nPopSuccess; - nTotalError += pThread->m_nPopError; - nTotalErrorEq += pThread->m_nPopErrorEq; - nTotalFailed += pThread->m_nPopFailed; - } - - CPPUNIT_MSG( " Total: popped=" << nTotalPopped << ", empty pop=" << nTotalFailed - << "\n Errors: pop equal=" << nTotalErrorEq << ", priority violation=" << nTotalError - ); - CPPUNIT_CHECK( nTotalPopped == nThreadItemCount * s_nThreadCount ); - CPPUNIT_CHECK( nTotalError == 0 ); - CPPUNIT_CHECK( nTotalErrorEq == 0 ); - } - - CPPUNIT_MSG( testQueue.statistics() ); - } - - void setUpParams( const CppUnitMini::TestCfg& cfg ) { - s_nThreadCount = cfg.getULong("ThreadCount", (unsigned long) s_nThreadCount ); - s_nQueueSize = cfg.getULong("QueueSize", (unsigned long) s_nQueueSize ); - } - - protected: -#include "pqueue/pqueue_defs.h" - CDSUNIT_DECLARE_MSPriorityQueue - CDSUNIT_DECLARE_EllenBinTree - CDSUNIT_DECLARE_SkipList - CDSUNIT_DECLARE_FCPriorityQueue - CDSUNIT_DECLARE_StdPQueue - - CPPUNIT_TEST_SUITE_(PQueue_Pop, "PQueue_Push") - CDSUNIT_TEST_MSPriorityQueue - CDSUNIT_TEST_EllenBinTree - CDSUNIT_TEST_SkipList - CDSUNIT_TEST_FCPriorityQueue - CDUNIT_TEST_StdPQueue - CPPUNIT_TEST_SUITE_END(); - }; - -} // namespace queue - -CPPUNIT_TEST_SUITE_REGISTRATION(pqueue::PQueue_Pop); diff --git a/tests/unit/pqueue/pqueue_defs.h b/tests/unit/pqueue/pqueue_defs.h deleted file mode 100644 index 26c3f581..00000000 --- a/tests/unit/pqueue/pqueue_defs.h +++ /dev/null @@ -1,210 +0,0 @@ -/* - 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_PQUEUE_PQUEUE_DEFS_H -#define CDSUNIT_PQUEUE_PQUEUE_DEFS_H - -// MSPriorityQueue -#define CDSUNIT_DECLARE_MSPriorityQueue \ - TEST_BOUNDED(MSPriorityQueue_static_less) \ - TEST_BOUNDED(MSPriorityQueue_static_less_stat) \ - TEST_BOUNDED(MSPriorityQueue_static_cmp) \ - TEST_BOUNDED(MSPriorityQueue_static_mutex) \ - TEST_BOUNDED(MSPriorityQueue_dyn_less) \ - TEST_BOUNDED(MSPriorityQueue_dyn_less_stat) \ - TEST_BOUNDED(MSPriorityQueue_dyn_cmp) \ - TEST_BOUNDED(MSPriorityQueue_dyn_mutex) -#define CDSUNIT_TEST_MSPriorityQueue \ - CPPUNIT_TEST(MSPriorityQueue_static_less) \ - CPPUNIT_TEST(MSPriorityQueue_static_less_stat) \ - CPPUNIT_TEST(MSPriorityQueue_static_cmp) \ - CPPUNIT_TEST(MSPriorityQueue_static_mutex) \ - CPPUNIT_TEST(MSPriorityQueue_dyn_less) \ - CPPUNIT_TEST(MSPriorityQueue_dyn_less_stat) \ - CPPUNIT_TEST(MSPriorityQueue_dyn_cmp) \ - CPPUNIT_TEST(MSPriorityQueue_dyn_mutex) - - -// EllenBinTree -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED -# define CDSUNIT_DECLARE_EllenBinTree_RCU_signal \ - TEST_CASE(EllenBinTree_RCU_shb_max) \ - TEST_CASE(EllenBinTree_RCU_shb_max_stat) \ - TEST_CASE(EllenBinTree_RCU_shb_min) \ - TEST_CASE(EllenBinTree_RCU_shb_min_stat) \ - TEST_CASE(EllenBinTree_RCU_sht_max) \ - TEST_CASE(EllenBinTree_RCU_sht_max_stat) \ - TEST_CASE(EllenBinTree_RCU_sht_min) \ - TEST_CASE(EllenBinTree_RCU_sht_min_stat) -# define CDSUNIT_TEST_EllenBinTree_RCU_signal \ - CPPUNIT_TEST(EllenBinTree_RCU_shb_max) \ - CPPUNIT_TEST(EllenBinTree_RCU_shb_max_stat) \ - CPPUNIT_TEST(EllenBinTree_RCU_shb_min) \ - CPPUNIT_TEST(EllenBinTree_RCU_shb_min_stat) \ - CPPUNIT_TEST(EllenBinTree_RCU_sht_max) \ - CPPUNIT_TEST(EllenBinTree_RCU_sht_max_stat) \ - CPPUNIT_TEST(EllenBinTree_RCU_sht_min) \ - CPPUNIT_TEST(EllenBinTree_RCU_sht_min_stat) -#else -# define CDSUNIT_DECLARE_EllenBinTree_RCU_signal -# define CDSUNIT_TEST_EllenBinTree_RCU_signal -#endif - -#define CDSUNIT_DECLARE_EllenBinTree \ - TEST_CASE(EllenBinTree_HP_max) \ - TEST_CASE(EllenBinTree_HP_max_stat) \ - TEST_CASE(EllenBinTree_HP_min) \ - TEST_CASE(EllenBinTree_HP_min_stat) \ - TEST_CASE(EllenBinTree_DHP_max) \ - TEST_CASE(EllenBinTree_DHP_max_stat) \ - TEST_CASE(EllenBinTree_DHP_min) \ - TEST_CASE(EllenBinTree_DHP_min_stat) \ - TEST_CASE(EllenBinTree_RCU_gpi_max) \ - TEST_CASE(EllenBinTree_RCU_gpi_max_stat) \ - TEST_CASE(EllenBinTree_RCU_gpi_min) \ - TEST_CASE(EllenBinTree_RCU_gpi_min_stat) \ - TEST_CASE(EllenBinTree_RCU_gpb_max) \ - TEST_CASE(EllenBinTree_RCU_gpb_max_stat) \ - TEST_CASE(EllenBinTree_RCU_gpb_min) \ - TEST_CASE(EllenBinTree_RCU_gpb_min_stat) \ - TEST_CASE(EllenBinTree_RCU_gpt_max) \ - TEST_CASE(EllenBinTree_RCU_gpt_max_stat) \ - TEST_CASE(EllenBinTree_RCU_gpt_min) \ - TEST_CASE(EllenBinTree_RCU_gpt_min_stat) \ - CDSUNIT_DECLARE_EllenBinTree_RCU_signal -#define CDSUNIT_TEST_EllenBinTree \ - CPPUNIT_TEST(EllenBinTree_HP_max) \ - CPPUNIT_TEST(EllenBinTree_HP_max_stat) \ - CPPUNIT_TEST(EllenBinTree_HP_min) \ - CPPUNIT_TEST(EllenBinTree_HP_min_stat) \ - CPPUNIT_TEST(EllenBinTree_DHP_max) \ - CPPUNIT_TEST(EllenBinTree_DHP_max_stat) \ - CPPUNIT_TEST(EllenBinTree_DHP_min) \ - CPPUNIT_TEST(EllenBinTree_DHP_min_stat) \ - /*CPPUNIT_TEST(EllenBinTree_RCU_gpi_max)*/ \ - /*CPPUNIT_TEST(EllenBinTree_RCU_gpi_max_stat)*/ \ - /*CPPUNIT_TEST(EllenBinTree_RCU_gpi_min)*/ \ - /*CPPUNIT_TEST(EllenBinTree_RCU_gpi_min_stat)*/ \ - CPPUNIT_TEST(EllenBinTree_RCU_gpb_max) \ - CPPUNIT_TEST(EllenBinTree_RCU_gpb_max_stat) \ - CPPUNIT_TEST(EllenBinTree_RCU_gpb_min) \ - CPPUNIT_TEST(EllenBinTree_RCU_gpb_min_stat) \ - CPPUNIT_TEST(EllenBinTree_RCU_gpt_max) \ - CPPUNIT_TEST(EllenBinTree_RCU_gpt_max_stat) \ - CPPUNIT_TEST(EllenBinTree_RCU_gpt_min) \ - CPPUNIT_TEST(EllenBinTree_RCU_gpt_min_stat) \ - CDSUNIT_TEST_EllenBinTree_RCU_signal - - -// SkipList -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED -# define CDSUNIT_DECLARE_SkipList_RCU_signal \ - TEST_CASE(SkipList_RCU_shb_max) \ - TEST_CASE(SkipList_RCU_shb_min) \ - TEST_CASE(SkipList_RCU_sht_max) \ - TEST_CASE(SkipList_RCU_sht_min) -# define CDSUNIT_TEST_SkipList_RCU_signal \ - CPPUNIT_TEST(SkipList_RCU_shb_max) \ - CPPUNIT_TEST(SkipList_RCU_shb_min) \ - CPPUNIT_TEST(SkipList_RCU_sht_max) \ - CPPUNIT_TEST(SkipList_RCU_sht_min) -#else -# define CDSUNIT_DECLARE_SkipList_RCU_signal -# define CDSUNIT_TEST_SkipList_RCU_signal -#endif - -#define CDSUNIT_DECLARE_SkipList \ - TEST_CASE(SkipList_HP_max) \ - TEST_CASE(SkipList_HP_max_stat) \ - TEST_CASE(SkipList_HP_min) \ - TEST_CASE(SkipList_HP_min_stat) \ - TEST_CASE(SkipList_DHP_max) \ - TEST_CASE(SkipList_DHP_max_stat) \ - TEST_CASE(SkipList_DHP_min) \ - TEST_CASE(SkipList_DHP_min_stat) \ - TEST_CASE(SkipList_RCU_gpi_max) \ - TEST_CASE(SkipList_RCU_gpi_min) \ - TEST_CASE(SkipList_RCU_gpb_max) \ - TEST_CASE(SkipList_RCU_gpb_min) \ - TEST_CASE(SkipList_RCU_gpt_max) \ - TEST_CASE(SkipList_RCU_gpt_min) \ - CDSUNIT_DECLARE_SkipList_RCU_signal -#define CDSUNIT_TEST_SkipList \ - CPPUNIT_TEST(SkipList_HP_max) \ - CPPUNIT_TEST(SkipList_HP_max_stat) \ - CPPUNIT_TEST(SkipList_HP_min) \ - CPPUNIT_TEST(SkipList_HP_min_stat) \ - CPPUNIT_TEST(SkipList_DHP_max) \ - CPPUNIT_TEST(SkipList_DHP_max_stat) \ - CPPUNIT_TEST(SkipList_DHP_min) \ - CPPUNIT_TEST(SkipList_DHP_min_stat) \ - CPPUNIT_TEST(SkipList_RCU_gpi_max) \ - CPPUNIT_TEST(SkipList_RCU_gpi_min) \ - CPPUNIT_TEST(SkipList_RCU_gpb_max) \ - CPPUNIT_TEST(SkipList_RCU_gpb_min) \ - CPPUNIT_TEST(SkipList_RCU_gpt_max) \ - CPPUNIT_TEST(SkipList_RCU_gpt_min) \ - CDSUNIT_TEST_SkipList_RCU_signal - -// FCPriorityQueue -#define CDSUNIT_DECLARE_FCPriorityQueue \ - TEST_CASE(FCPQueue_vector) \ - TEST_CASE(FCPQueue_vector_stat) \ - TEST_CASE(FCPQueue_deque) \ - TEST_CASE(FCPQueue_deque_stat) \ - TEST_CASE(FCPQueue_boost_deque) \ - TEST_CASE(FCPQueue_boost_deque_stat) \ - TEST_CASE(FCPQueue_boost_stable_vector) \ - TEST_CASE(FCPQueue_boost_stable_vector_stat) - -#define CDSUNIT_TEST_FCPriorityQueue \ - CPPUNIT_TEST(FCPQueue_vector) \ - CPPUNIT_TEST(FCPQueue_vector_stat) \ - CPPUNIT_TEST(FCPQueue_deque) \ - CPPUNIT_TEST(FCPQueue_deque_stat) \ - CPPUNIT_TEST(FCPQueue_boost_deque) \ - CPPUNIT_TEST(FCPQueue_boost_deque_stat) \ - CPPUNIT_TEST(FCPQueue_boost_stable_vector) \ - CPPUNIT_TEST(FCPQueue_boost_stable_vector_stat) - -// Std::priority_queue -#define CDSUNIT_DECLARE_StdPQueue \ - TEST_CASE(StdPQueue_vector_spin) \ - TEST_CASE(StdPQueue_vector_mutex) \ - TEST_CASE(StdPQueue_deque_spin) \ - TEST_CASE(StdPQueue_deque_mutex) -#define CDUNIT_TEST_StdPQueue \ - CPPUNIT_TEST(StdPQueue_vector_spin) \ - CPPUNIT_TEST(StdPQueue_vector_mutex)\ - CPPUNIT_TEST(StdPQueue_deque_spin) \ - CPPUNIT_TEST(StdPQueue_deque_mutex) - - -#endif // #ifndef CDSUNIT_PQUEUE_PQUEUE_DEFS_H diff --git a/tests/unit/pqueue/pqueue_type.h b/tests/unit/pqueue/pqueue_type.h deleted file mode 100644 index 9e5c6075..00000000 --- a/tests/unit/pqueue/pqueue_type.h +++ /dev/null @@ -1,358 +0,0 @@ -/* - 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_PQUEUE_TYPES_H -#define CDSUNIT_PQUEUE_TYPES_H - -#include -#include - -#include "pqueue/std_pqueue.h" -#include "pqueue/ellen_bintree_pqueue.h" -#include "pqueue/skiplist_pqueue.h" - -#include -#include -#include -#include -#include - -#include "print_ellenbintree_stat.h" -#include "print_skip_list_stat.h" -#include "print_mspriorityqueue_stat.h" - -namespace pqueue { - namespace cc = cds::container; - namespace co = cds::opt; - - template - struct Types - { - static size_t const c_nBoundedCapacity = 1024 * 1024 * 16; - - typedef std::less less; - - struct cmp { - int operator()( Value const& v1, Value const& v2 ) const - { - return less()( v1, v2 ) ? -1 : less()( v2, v1 ) ? 1 : 0; - } - }; - - typedef cds::urcu::gc< cds::urcu::general_instant<> > rcu_gpi; - typedef cds::urcu::gc< cds::urcu::general_buffered<> > rcu_gpb; - typedef cds::urcu::gc< cds::urcu::general_threaded<> > rcu_gpt; -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - typedef cds::urcu::gc< cds::urcu::signal_buffered<> > rcu_shb; - typedef cds::urcu::gc< cds::urcu::signal_threaded<> > rcu_sht; -#endif - - - // MSPriorityQueue - struct traits_MSPriorityQueue_static_less : public - cc::mspriority_queue::make_traits < - co::buffer < co::v::static_buffer< char, c_nBoundedCapacity > > - > ::type - {}; - typedef cc::MSPriorityQueue< Value, traits_MSPriorityQueue_static_less > MSPriorityQueue_static_less; - - struct traits_MSPriorityQueue_static_less_stat : public cc::mspriority_queue::traits - { - typedef co::v::static_buffer< char, c_nBoundedCapacity > buffer; - typedef cc::mspriority_queue::stat<> stat; - }; - typedef cc::MSPriorityQueue< Value, traits_MSPriorityQueue_static_less_stat > MSPriorityQueue_static_less_stat; - - struct traits_MSPriorityQueue_static_cmp : public - cc::mspriority_queue::make_traits < - co::buffer< co::v::static_buffer< char, c_nBoundedCapacity > > - , co::compare < cmp > - > ::type - {}; - typedef cc::MSPriorityQueue< Value, traits_MSPriorityQueue_static_cmp > MSPriorityQueue_static_cmp; - - struct traits_MSPriorityQueue_static_mutex : public - cc::mspriority_queue::make_traits< - co::buffer< co::v::static_buffer< char, c_nBoundedCapacity > > - , co::lock_type - >::type - {}; - typedef cc::MSPriorityQueue< Value, traits_MSPriorityQueue_static_mutex > MSPriorityQueue_static_mutex; - - struct traits_MSPriorityQueue_dyn_less : public - cc::mspriority_queue::make_traits< - co::buffer< co::v::dynamic_buffer< char > > - >::type - {}; - typedef cc::MSPriorityQueue< Value, traits_MSPriorityQueue_dyn_less > MSPriorityQueue_dyn_less; - - struct traits_MSPriorityQueue_dyn_less_stat : public - cc::mspriority_queue::make_traits < - co::buffer< co::v::dynamic_buffer< char > > - , co::stat < cc::mspriority_queue::stat<> > - > ::type - {}; - typedef cc::MSPriorityQueue< Value, traits_MSPriorityQueue_dyn_less_stat > MSPriorityQueue_dyn_less_stat; - - struct traits_MSPriorityQueue_dyn_cmp : public - cc::mspriority_queue::make_traits < - co::buffer< co::v::dynamic_buffer< char > > - , co::compare < cmp > - > ::type - {}; - typedef cc::MSPriorityQueue< Value, traits_MSPriorityQueue_dyn_cmp > MSPriorityQueue_dyn_cmp; - - struct traits_MSPriorityQueue_dyn_mutex : public - cc::mspriority_queue::make_traits < - co::buffer< co::v::dynamic_buffer< char > > - , co::lock_type < std::mutex > - > ::type - {}; - typedef cc::MSPriorityQueue< Value, traits_MSPriorityQueue_dyn_mutex > MSPriorityQueue_dyn_mutex; - - - // Priority queue based on EllenBinTreeSet - struct traits_EllenBinTree_max : - public cc::ellen_bintree::make_set_traits< - cc::ellen_bintree::key_extractor< typename Value::key_extractor > - ,cc::opt::less< std::less > - ,co::stat< cc::ellen_bintree::stat<> > - >::type - {}; - typedef EllenBinTreePQueue< cds::gc::HP, typename Value::key_type, Value, traits_EllenBinTree_max > EllenBinTree_HP_max; - typedef EllenBinTreePQueue< cds::gc::DHP, typename Value::key_type, Value, traits_EllenBinTree_max > EllenBinTree_DHP_max; - typedef EllenBinTreePQueue< rcu_gpi, typename Value::key_type, Value, traits_EllenBinTree_max > EllenBinTree_RCU_gpi_max; - typedef EllenBinTreePQueue< rcu_gpb, typename Value::key_type, Value, traits_EllenBinTree_max > EllenBinTree_RCU_gpb_max; - typedef EllenBinTreePQueue< rcu_gpt, typename Value::key_type, Value, traits_EllenBinTree_max > EllenBinTree_RCU_gpt_max; -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - typedef EllenBinTreePQueue< rcu_shb, typename Value::key_type, Value, traits_EllenBinTree_max > EllenBinTree_RCU_shb_max; - typedef EllenBinTreePQueue< rcu_sht, typename Value::key_type, Value, traits_EllenBinTree_max > EllenBinTree_RCU_sht_max; -#endif - - struct traits_EllenBinTree_max_stat : - public cc::ellen_bintree::make_set_traits< - cc::ellen_bintree::key_extractor< typename Value::key_extractor > - ,cc::opt::less< std::less > - ,co::stat< cc::ellen_bintree::stat<> > - >::type - {}; - typedef EllenBinTreePQueue< cds::gc::HP, typename Value::key_type, Value, traits_EllenBinTree_max_stat > EllenBinTree_HP_max_stat; - typedef EllenBinTreePQueue< cds::gc::DHP, typename Value::key_type, Value, traits_EllenBinTree_max_stat > EllenBinTree_DHP_max_stat; - typedef EllenBinTreePQueue< rcu_gpi, typename Value::key_type, Value, traits_EllenBinTree_max_stat > EllenBinTree_RCU_gpi_max_stat; - typedef EllenBinTreePQueue< rcu_gpb, typename Value::key_type, Value, traits_EllenBinTree_max_stat > EllenBinTree_RCU_gpb_max_stat; - typedef EllenBinTreePQueue< rcu_gpt, typename Value::key_type, Value, traits_EllenBinTree_max_stat > EllenBinTree_RCU_gpt_max_stat; -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - typedef EllenBinTreePQueue< rcu_shb, typename Value::key_type, Value, traits_EllenBinTree_max_stat > EllenBinTree_RCU_shb_max_stat; - typedef EllenBinTreePQueue< rcu_sht, typename Value::key_type, Value, traits_EllenBinTree_max_stat > EllenBinTree_RCU_sht_max_stat; -#endif - - struct traits_EllenBinTree_min : - public cc::ellen_bintree::make_set_traits< - cc::ellen_bintree::key_extractor< typename Value::key_extractor > - ,cc::opt::less< std::greater > - >::type - {}; - typedef EllenBinTreePQueue< cds::gc::HP, typename Value::key_type, Value, traits_EllenBinTree_min, false > EllenBinTree_HP_min; - typedef EllenBinTreePQueue< cds::gc::DHP, typename Value::key_type, Value, traits_EllenBinTree_min, false > EllenBinTree_DHP_min; - typedef EllenBinTreePQueue< rcu_gpi, typename Value::key_type, Value, traits_EllenBinTree_min, false > EllenBinTree_RCU_gpi_min; - typedef EllenBinTreePQueue< rcu_gpb, typename Value::key_type, Value, traits_EllenBinTree_min, false > EllenBinTree_RCU_gpb_min; - typedef EllenBinTreePQueue< rcu_gpt, typename Value::key_type, Value, traits_EllenBinTree_min, false > EllenBinTree_RCU_gpt_min; -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - typedef EllenBinTreePQueue< rcu_shb, typename Value::key_type, Value, traits_EllenBinTree_min, false > EllenBinTree_RCU_shb_min; - typedef EllenBinTreePQueue< rcu_sht, typename Value::key_type, Value, traits_EllenBinTree_min, false > EllenBinTree_RCU_sht_min; -#endif - - struct traits_EllenBinTree_min_stat : - public cc::ellen_bintree::make_set_traits< - cc::ellen_bintree::key_extractor< typename Value::key_extractor > - ,cc::opt::less< std::greater > - ,co::stat< cc::ellen_bintree::stat<> > - >::type - {}; - typedef EllenBinTreePQueue< cds::gc::HP, typename Value::key_type, Value, traits_EllenBinTree_min_stat, false > EllenBinTree_HP_min_stat; - typedef EllenBinTreePQueue< cds::gc::DHP, typename Value::key_type, Value, traits_EllenBinTree_min_stat, false > EllenBinTree_DHP_min_stat; - typedef EllenBinTreePQueue< rcu_gpi, typename Value::key_type, Value, traits_EllenBinTree_min_stat, false > EllenBinTree_RCU_gpi_min_stat; - typedef EllenBinTreePQueue< rcu_gpb, typename Value::key_type, Value, traits_EllenBinTree_min_stat, false > EllenBinTree_RCU_gpb_min_stat; - typedef EllenBinTreePQueue< rcu_gpt, typename Value::key_type, Value, traits_EllenBinTree_min_stat, false > EllenBinTree_RCU_gpt_min_stat; -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - typedef EllenBinTreePQueue< rcu_shb, typename Value::key_type, Value, traits_EllenBinTree_min_stat, false > EllenBinTree_RCU_shb_min_stat; - typedef EllenBinTreePQueue< rcu_sht, typename Value::key_type, Value, traits_EllenBinTree_min_stat, false > EllenBinTree_RCU_sht_min_stat; -#endif - - // Priority queue based on SkipListSet - struct traits_SkipList_max : - public cc::skip_list::make_traits < - cc::opt::less < std::less > - > ::type - {}; - typedef SkipListPQueue< cds::gc::HP, Value, traits_SkipList_max > SkipList_HP_max; - typedef SkipListPQueue< cds::gc::DHP, Value, traits_SkipList_max > SkipList_DHP_max; - typedef SkipListPQueue< rcu_gpi, Value, traits_SkipList_max > SkipList_RCU_gpi_max; - typedef SkipListPQueue< rcu_gpb, Value, traits_SkipList_max > SkipList_RCU_gpb_max; - typedef SkipListPQueue< rcu_gpt, Value, traits_SkipList_max > SkipList_RCU_gpt_max; -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - typedef SkipListPQueue< rcu_shb, Value, traits_SkipList_max > SkipList_RCU_shb_max; - typedef SkipListPQueue< rcu_sht, Value, traits_SkipList_max > SkipList_RCU_sht_max; -#endif - - struct traits_SkipList_max_stat : - public cc::skip_list::make_traits< - cc::opt::less< std::less > - ,co::stat< cc::skip_list::stat<> > - >::type - {}; - typedef SkipListPQueue< cds::gc::HP, Value, traits_SkipList_max_stat > SkipList_HP_max_stat; - typedef SkipListPQueue< cds::gc::DHP, Value, traits_SkipList_max_stat > SkipList_DHP_max_stat; - typedef SkipListPQueue< rcu_gpi, Value, traits_SkipList_max_stat > SkipList_RCU_gpi_max_stat; - typedef SkipListPQueue< rcu_gpb, Value, traits_SkipList_max_stat > SkipList_RCU_gpb_max_stat; - typedef SkipListPQueue< rcu_gpt, Value, traits_SkipList_max_stat > SkipList_RCU_gpt_max_stat; -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - typedef SkipListPQueue< rcu_shb, Value, traits_SkipList_max_stat > SkipList_RCU_shb_max_stat; - typedef SkipListPQueue< rcu_sht, Value, traits_SkipList_max_stat > SkipList_RCU_sht_max_stat; -#endif - - struct traits_SkipList_min : - public cc::skip_list::make_traits< - cc::opt::less< std::greater > - >::type - {}; - typedef SkipListPQueue< cds::gc::HP, Value, traits_SkipList_min, false > SkipList_HP_min; - typedef SkipListPQueue< cds::gc::DHP, Value, traits_SkipList_min, false > SkipList_DHP_min; - typedef SkipListPQueue< rcu_gpi, Value, traits_SkipList_min, false > SkipList_RCU_gpi_min; - typedef SkipListPQueue< rcu_gpb, Value, traits_SkipList_min, false > SkipList_RCU_gpb_min; - typedef SkipListPQueue< rcu_gpt, Value, traits_SkipList_min, false > SkipList_RCU_gpt_min; -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - typedef SkipListPQueue< rcu_shb, Value, traits_SkipList_min, false > SkipList_RCU_shb_min; - typedef SkipListPQueue< rcu_sht, Value, traits_SkipList_min, false > SkipList_RCU_sht_min; -#endif - - struct traits_SkipList_min_stat : - public cc::skip_list::make_traits< - cc::opt::less< std::greater > - ,co::stat< cc::skip_list::stat<> > - >::type - {}; - typedef SkipListPQueue< cds::gc::HP, Value, traits_SkipList_min_stat, false > SkipList_HP_min_stat; - typedef SkipListPQueue< cds::gc::DHP, Value, traits_SkipList_min_stat, false > SkipList_DHP_min_stat; - typedef SkipListPQueue< rcu_gpi, Value, traits_SkipList_min_stat, false > SkipList_RCU_gpi_min_stat; - typedef SkipListPQueue< rcu_gpb, Value, traits_SkipList_min_stat, false > SkipList_RCU_gpb_min_stat; - typedef SkipListPQueue< rcu_gpt, Value, traits_SkipList_min_stat, false > SkipList_RCU_gpt_min_stat; -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - typedef SkipListPQueue< rcu_shb, Value, traits_SkipList_min_stat, false > SkipList_RCU_shb_min_stat; - typedef SkipListPQueue< rcu_sht, Value, traits_SkipList_min_stat, false > SkipList_RCU_sht_min_stat; -#endif - - - // FCPriorityQueue - struct traits_FCPQueue_stat : public - cds::container::fcpqueue::make_traits < - cds::opt::stat < cds::container::fcpqueue::stat<> > - > ::type - {}; - - typedef cds::container::FCPriorityQueue< Value > FCPQueue_vector; - typedef cds::container::FCPriorityQueue< Value - ,std::priority_queue - ,traits_FCPQueue_stat - > FCPQueue_vector_stat; - - typedef cds::container::FCPriorityQueue< Value - ,std::priority_queue > - > FCPQueue_deque; - typedef cds::container::FCPriorityQueue< Value - ,std::priority_queue > - ,traits_FCPQueue_stat - > FCPQueue_deque_stat; - - typedef cds::container::FCPriorityQueue< Value - ,std::priority_queue > - > FCPQueue_boost_deque; - typedef cds::container::FCPriorityQueue< Value - ,std::priority_queue > - ,traits_FCPQueue_stat - > FCPQueue_boost_deque_stat; - - typedef cds::container::FCPriorityQueue< Value - ,std::priority_queue > - > FCPQueue_boost_stable_vector; - typedef cds::container::FCPriorityQueue< Value - ,std::priority_queue > - ,traits_FCPQueue_stat - > FCPQueue_boost_stable_vector_stat; - - /// Standard priority_queue - typedef StdPQueue< Value, std::vector, cds::sync::spin> StdPQueue_vector_spin; - typedef StdPQueue< Value, std::vector, std::mutex > StdPQueue_vector_mutex; - typedef StdPQueue< Value, std::deque, cds::sync::spin> StdPQueue_deque_spin; - typedef StdPQueue< Value, std::deque, std::mutex > StdPQueue_deque_mutex; - }; - - - template - static inline void check_statistics( Stat const& /*s*/ ) - {} - - static inline void check_statistics( cds::container::ellen_bintree::stat<> const& s ) - { - CPPUNIT_CHECK_CURRENT( s.m_nInternalNodeCreated.get() == s.m_nInternalNodeDeleted.get() ); - CPPUNIT_CHECK_CURRENT( s.m_nUpdateDescCreated.get() == s.m_nUpdateDescDeleted.get() ); - } -} // namespace pqueue - -namespace std { - - static inline std::ostream& operator <<( std::ostream& o, cds::container::fcpqueue::empty_stat const& ) - { - return o; - } - - static inline std::ostream& operator <<( std::ostream& o, cds::container::fcpqueue::stat<> const& s ) - { - return o << "\tStatistics:\n" - << "\t Push: " << s.m_nPush.get() << "\n" - << "\t Push move: " << s.m_nPushMove.get() << "\n" - << "\t Pop: " << s.m_nPop.get() << "\n" - << "\t Failed pop: " << s.m_nFailedPop.get() << "\n" - << "\tFlat combining statistics:\n" - << "\t Combining factor: " << s.combining_factor() << "\n" - << "\t Operation count: " << s.m_nOperationCount.get() << "\n" - << "\t Combine call count: " << s.m_nCombiningCount.get() << "\n" - << "\t Compact pub-list: " << s.m_nCompactPublicationList.get() << "\n" - << "\t Deactivate pub-record: " << s.m_nDeactivatePubRecord.get() << "\n" - << "\t Activate pub-record: " << s.m_nActivatePubRecord.get() << "\n" - << "\t Create pub-record: " << s.m_nPubRecordCreated.get() << "\n" - << "\t Delete pub-record: " << s.m_nPubRecordDeteted.get() << "\n" - << "\t Acquire pub-record: " << s.m_nAcquirePubRecCount.get()<< "\n" - << "\t Release pub-record: " << s.m_nReleasePubRecCount.get()<< "\n"; - } - -} // namespace std - -#endif // #ifndef CDSUNIT_PQUEUE_TYPES_H diff --git a/tests/unit/pqueue/push.cpp b/tests/unit/pqueue/push.cpp deleted file mode 100644 index 6305b098..00000000 --- a/tests/unit/pqueue/push.cpp +++ /dev/null @@ -1,226 +0,0 @@ -/* - 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 "cppunit/thread.h" -#include "pqueue/pqueue_item.h" -#include "pqueue/pqueue_type.h" - -#include -#include - -namespace pqueue { - -#define TEST_CASE( Q ) void Q() { test< Types::Q >(); } -#define TEST_BOUNDED( Q ) void Q() { test_bounded< Types::Q >(); } - - namespace { - static size_t s_nThreadCount = 8; - static size_t s_nQueueSize = 2000000; - } -} // namespace pqueue - -namespace pqueue { - - class PQueue_Push: public CppUnitMini::TestCase - { - template - class Pusher: public CppUnitMini::TestThread - { - virtual TestThread * clone() - { - return new Pusher( *this ); - } - public: - PQueue& m_Queue; - size_t m_nPushError; - - typedef std::vector array_type; - array_type m_arr; - - public: - Pusher( CppUnitMini::ThreadPool& pool, PQueue& q ) - : CppUnitMini::TestThread( pool ) - , m_Queue( q ) - {} - Pusher( Pusher& src ) - : CppUnitMini::TestThread( src ) - , m_Queue( src.m_Queue ) - {} - - PQueue_Push& getTest() - { - return static_cast( m_Pool.m_Test ); - } - - virtual void init() - { - cds::threading::Manager::attachThread(); - } - virtual void fini() - { - cds::threading::Manager::detachThread(); - } - - virtual void test() - { - m_nPushError = 0; - - for ( array_type::const_iterator it = m_arr.begin(); it != m_arr.end(); ++it ) { - if ( !m_Queue.push( SimpleValue( *it ) )) - ++m_nPushError; - } - } - - void prepare( size_t nStart, size_t nEnd ) - { - m_arr.reserve( nEnd - nStart ); - for ( size_t i = nStart; i < nEnd; ++i ) - m_arr.push_back( i ); - shuffle( m_arr.begin(), m_arr.end() ); - } - }; - - protected: - template - void analyze( CppUnitMini::ThreadPool& pool, PQueue& testQueue ) - { - size_t nThreadItems = s_nQueueSize / s_nThreadCount; - for ( CppUnitMini::ThreadPool::iterator it = pool.begin(); it != pool.end(); ++it ) { - Pusher * pThread = static_cast *>(*it); - CPPUNIT_CHECK_EX( pThread->m_nPushError == 0, "Thread push error count=" << pThread->m_nPushError ); - } - CPPUNIT_MSG( " Duration=" << pool.avgDuration() ); - CPPUNIT_ASSERT( !testQueue.empty() ); - - typedef std::vector vector_type; - vector_type arr; - arr.reserve( s_nQueueSize ); - - cds::OS::Timer timer; - CPPUNIT_MSG( " Pop (single-threaded)..." ); - size_t nPopped = 0; - SimpleValue val; - while ( testQueue.pop( val )) { - nPopped++; - arr.push_back( val.key ); - } - CPPUNIT_MSG( " Duration=" << timer.duration() ); - - CPPUNIT_CHECK( arr.size() == nThreadItems * s_nThreadCount ); - vector_type::const_iterator it = arr.begin(); - size_t nPrev = *it; - ++it; - size_t nErrCount = 0; - for ( vector_type::const_iterator itEnd = arr.end(); it != itEnd; ++it ) { - if ( nPrev - 1 != *it ) { - if ( ++nErrCount < 10 ) { - CPPUNIT_CHECK_EX( nPrev - 1 == *it, "Expected=" << nPrev - 1 << ", current=" << *it ); - } - } - nPrev = *it; - } - - CPPUNIT_CHECK_EX( nErrCount == 0, "Error count=" << nErrCount ); - } - - template - void test() - { - PQueue testQueue; - - CppUnitMini::ThreadPool pool( *this ); - pool.add( new Pusher( pool, testQueue ), s_nThreadCount ); - - size_t nStart = 0; - size_t nThreadItemCount = s_nQueueSize / s_nThreadCount; - for ( CppUnitMini::ThreadPool::iterator it = pool.begin(); it != pool.end(); ++it ) { - Pusher * pThread = static_cast *>(*it); - pThread->prepare( nStart, nStart + nThreadItemCount ); - nStart += nThreadItemCount; - } - - CPPUNIT_MSG( " Push test, thread count=" << s_nThreadCount << ", item count=" << nThreadItemCount * s_nThreadCount << " ..." ); - pool.run(); - - analyze( pool, testQueue ); - - CPPUNIT_MSG( testQueue.statistics() ); - } - - template - void test_bounded() - { - size_t nStart = 0; - size_t nThreadItemCount = s_nQueueSize / s_nThreadCount; - - std::unique_ptr pq( new PQueue(s_nQueueSize) ); - - CppUnitMini::ThreadPool pool( *this ); - pool.add( new Pusher( pool, *pq ), s_nThreadCount ); - - for ( CppUnitMini::ThreadPool::iterator it = pool.begin(); it != pool.end(); ++it ) { - Pusher * pThread = static_cast *>(*it); - pThread->prepare( nStart, nStart + nThreadItemCount ); - nStart += nThreadItemCount; - } - - CPPUNIT_MSG( " Push test, thread count=" << s_nThreadCount << ", item count=" << nThreadItemCount * s_nThreadCount << " ..." ); - pool.run(); - - analyze( pool, *pq ); - - CPPUNIT_MSG( pq->statistics() ); - } - - void setUpParams( const CppUnitMini::TestCfg& cfg ) { - s_nThreadCount = cfg.getULong("ThreadCount", (unsigned long) s_nThreadCount ); - s_nQueueSize = cfg.getULong("QueueSize", (unsigned long) s_nQueueSize ); - } - - protected: -#include "pqueue/pqueue_defs.h" - CDSUNIT_DECLARE_MSPriorityQueue - CDSUNIT_DECLARE_EllenBinTree - CDSUNIT_DECLARE_SkipList - CDSUNIT_DECLARE_FCPriorityQueue - CDSUNIT_DECLARE_StdPQueue - - CPPUNIT_TEST_SUITE(PQueue_Push) - CDSUNIT_TEST_MSPriorityQueue - CDSUNIT_TEST_EllenBinTree - CDSUNIT_TEST_SkipList - CDSUNIT_TEST_FCPriorityQueue - CDUNIT_TEST_StdPQueue - CPPUNIT_TEST_SUITE_END(); - }; - -} // namespace queue - -CPPUNIT_TEST_SUITE_REGISTRATION(pqueue::PQueue_Push); diff --git a/tests/unit/pqueue/push_pop.cpp b/tests/unit/pqueue/push_pop.cpp deleted file mode 100644 index 10625e30..00000000 --- a/tests/unit/pqueue/push_pop.cpp +++ /dev/null @@ -1,266 +0,0 @@ -/* - 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 "cppunit/thread.h" -#include "pqueue/pqueue_item.h" -#include "pqueue/pqueue_type.h" - -#include -#include - -namespace pqueue { - -#define TEST_CASE( Q ) void Q() { test< Types::Q >(); } -#define TEST_BOUNDED( Q ) void Q() { test_bounded< Types::Q >(); } - - namespace { - static size_t s_nPushThreadCount = 4; - static size_t s_nPopThreadCount = 4; - static size_t s_nQueueSize = 2000000; - } -} // namespace pqueue - -namespace pqueue { - - class PQueue_PushPop: public CppUnitMini::TestCase - { - - template - class Pusher: public CppUnitMini::TestThread - { - virtual TestThread * clone() - { - return new Pusher( *this ); - } - public: - PQueue& m_Queue; - size_t m_nPushError; - - typedef std::vector array_type; - array_type m_arr; - - public: - Pusher( CppUnitMini::ThreadPool& pool, PQueue& q ) - : CppUnitMini::TestThread( pool ) - , m_Queue( q ) - {} - Pusher( Pusher& src ) - : CppUnitMini::TestThread( src ) - , m_Queue( src.m_Queue ) - {} - - PQueue_PushPop& getTest() - { - return static_cast( m_Pool.m_Test ); - } - - virtual void init() - { - cds::threading::Manager::attachThread(); - } - virtual void fini() - { - cds::threading::Manager::detachThread(); - } - - virtual void test() - { - m_nPushError = 0; - - for ( array_type::const_iterator it = m_arr.begin(); it != m_arr.end(); ++it ) { - if ( !m_Queue.push( SimpleValue( *it ) )) - ++m_nPushError; - } - - getTest().end_pusher(); - } - - void prepare( size_t nStart, size_t nEnd ) - { - m_arr.reserve( nEnd - nStart ); - for ( size_t i = nStart; i < nEnd; ++i ) - m_arr.push_back( i ); - shuffle( m_arr.begin(), m_arr.end() ); - } - }; - - template - class Popper: public CppUnitMini::TestThread - { - virtual TestThread * clone() - { - return new Popper( *this ); - } - public: - PQueue& m_Queue; - size_t m_nPopSuccess; - size_t m_nPopFailed; - - typedef std::vector array_type; - array_type m_arr; - - public: - Popper( CppUnitMini::ThreadPool& pool, PQueue& q ) - : CppUnitMini::TestThread( pool ) - , m_Queue( q ) - {} - Popper( Popper& src ) - : CppUnitMini::TestThread( src ) - , m_Queue( src.m_Queue ) - {} - - PQueue_PushPop& getTest() - { - return static_cast( m_Pool.m_Test ); - } - - virtual void init() - { - cds::threading::Manager::attachThread(); - } - virtual void fini() - { - cds::threading::Manager::detachThread(); - } - - virtual void test() - { - m_nPopSuccess = 0; - m_nPopFailed = 0; - - SimpleValue val; - while ( getTest().pushing() || !m_Queue.empty() ) { - if ( m_Queue.pop( val )) - ++m_nPopSuccess; - else - ++m_nPopFailed; - } - } - }; - - atomics::atomic m_nPusherCount; - void end_pusher() - { - m_nPusherCount.fetch_sub( 1, atomics::memory_order_relaxed ); - } - bool pushing() const - { - return m_nPusherCount.load( atomics::memory_order_relaxed ) != 0; - } - - protected: - template - void test() - { - PQueue testQueue; - test_with( testQueue ); - } - - template - void test_bounded() - { - std::unique_ptr pq( new PQueue(s_nQueueSize) ); - test_with( *pq.get() ); - } - - template - void test_with( PQueue& testQueue ) - { - size_t const nThreadItemCount = s_nQueueSize / s_nPushThreadCount; - - CppUnitMini::ThreadPool pool( *this ); - pool.add( new Pusher( pool, testQueue ), s_nPushThreadCount ); - - size_t nStart = 0; - for ( CppUnitMini::ThreadPool::iterator it = pool.begin(); it != pool.end(); ++it ) { - Pusher * pThread = static_cast *>(*it); - pThread->prepare( nStart, nStart + nThreadItemCount ); - nStart += nThreadItemCount; - } - - pool.add( new Popper( pool, testQueue ), s_nPopThreadCount ); - - m_nPusherCount.store( s_nPushThreadCount, atomics::memory_order_release ); - CPPUNIT_MSG( " push thread count=" << s_nPushThreadCount << " pop thread count=" << s_nPopThreadCount - << ", item count=" << nThreadItemCount * s_nPushThreadCount << " ..." ); - pool.run(); - CPPUNIT_MSG( " Duration=" << pool.avgDuration() ); - - // Analyze result - size_t nTotalPopped = 0; - size_t nPushFailed = 0; - size_t nPopFailed = 0; - for ( CppUnitMini::ThreadPool::iterator it = pool.begin(); it != pool.end(); ++it ) { - Popper * pPopper = dynamic_cast *>(*it); - if ( pPopper ) { - nTotalPopped += pPopper->m_nPopSuccess; - nPopFailed += pPopper->m_nPopFailed; - } - else { - Pusher * pPusher = dynamic_cast *>(*it); - assert( pPusher ); - nPushFailed += pPusher->m_nPushError; - } - } - - CPPUNIT_MSG( " Total: popped=" << nTotalPopped << ", empty pop=" << nPopFailed << ", push error=" << nPushFailed ); - CPPUNIT_CHECK( nTotalPopped == nThreadItemCount * s_nPushThreadCount ); - CPPUNIT_CHECK( nPushFailed == 0 ); - - check_statistics( testQueue.statistics() ); - CPPUNIT_MSG( testQueue.statistics() ); - } - - void setUpParams( const CppUnitMini::TestCfg& cfg ) { - s_nPushThreadCount = cfg.getULong("PushThreadCount", (unsigned long) s_nPushThreadCount ); - s_nPopThreadCount = cfg.getULong("PopThreadCount", (unsigned long) s_nPopThreadCount ); - s_nQueueSize = cfg.getULong("QueueSize", (unsigned long) s_nQueueSize ); - } - - protected: -#include "pqueue/pqueue_defs.h" - CDSUNIT_DECLARE_MSPriorityQueue - CDSUNIT_DECLARE_EllenBinTree - CDSUNIT_DECLARE_SkipList - CDSUNIT_DECLARE_FCPriorityQueue - CDSUNIT_DECLARE_StdPQueue - - CPPUNIT_TEST_SUITE(PQueue_PushPop) - CDSUNIT_TEST_MSPriorityQueue - CDSUNIT_TEST_EllenBinTree - CDSUNIT_TEST_SkipList - CDSUNIT_TEST_FCPriorityQueue - CDUNIT_TEST_StdPQueue - CPPUNIT_TEST_SUITE_END(); - }; - -} // namespace queue - -CPPUNIT_TEST_SUITE_REGISTRATION(pqueue::PQueue_PushPop); diff --git a/tests/unit/pqueue/skiplist_pqueue.h b/tests/unit/pqueue/skiplist_pqueue.h deleted file mode 100644 index 93ee15ca..00000000 --- a/tests/unit/pqueue/skiplist_pqueue.h +++ /dev/null @@ -1,140 +0,0 @@ -/* - 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_SKIPLIST_PQUEUE_H -#define CDSUNIT_SKIPLIST_PQUEUE_H - -#include -#include -#include -#include -#include -#include -#include -#include - -namespace pqueue { - - template - struct SkipListPQueue_pop_max - { - template - bool operator()( T& dest, Set& container ) const - { - typename Set::guarded_ptr gp( container.extract_max()); - if ( gp ) - dest = *gp; - return !gp.empty(); - } - }; - - template - struct SkipListPQueue_pop_max< cds::urcu::gc > - { - template - bool operator()( T& dest, Set& container ) const - { - typename Set::exempt_ptr ep( container.extract_max()); - if ( ep ) - dest = *ep; - return !ep.empty(); - } - }; - - template - struct SkipListPQueue_pop_min - { - template - bool operator()( T& dest, Set& container ) const - { - typename Set::guarded_ptr gp( container.extract_min()); - if ( gp ) - dest = *gp; - return !gp.empty(); - } - }; - - template - struct SkipListPQueue_pop_min< cds::urcu::gc > - { - template - bool operator()( T& dest, Set& container ) const - { - typename Set::exempt_ptr ep( container.extract_min()); - if ( ep ) - dest = *ep; - return !ep.empty(); - } - }; - - template - class SkipListPQueue: protected cds::container::SkipListSet< GC, T, Traits > - { - typedef cds::container::SkipListSet< GC, T, Traits > base_class; - typedef T value_type; - template friend struct SkipListPQueue_pop_max; - template friend struct SkipListPQueue_pop_min; - - public: - bool push( value_type const& val ) - { - return base_class::insert( val ); - } - - bool pop( value_type& dest ) - { - return Max ? SkipListPQueue_pop_max< typename base_class::gc >()( dest, *this ) - : SkipListPQueue_pop_min< typename base_class::gc >()( dest, *this ); - } - - void clear() - { - base_class::clear(); - } - - bool empty() const - { - return base_class::empty(); - } - - size_t size() const - { - return base_class::size(); - } - - typename base_class::stat const& statistics() const - { - return base_class::statistics(); - } - }; - -} // namespace pqueue - -#endif // #ifndef CDSUNIT_SKIPLIST_PQUEUE_H diff --git a/tests/unit/pqueue/std_pqueue.h b/tests/unit/pqueue/std_pqueue.h deleted file mode 100644 index 9fe19815..00000000 --- a/tests/unit/pqueue/std_pqueue.h +++ /dev/null @@ -1,125 +0,0 @@ -/* - 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_STD_PQUEUE_H -#define CDSUNIT_STD_PQUEUE_H - -#include -#include //unique_lock - -namespace pqueue { - - struct dummy_stat {}; - - template > - class StdPQueue - { - typedef T value_type; - typedef std::priority_queue pqueue_type; - - pqueue_type m_PQueue; - mutable Lock m_Lock; - - typedef std::unique_lock scoped_lock; - - public: - bool push( value_type const& val ) - { - scoped_lock l( m_Lock ); - m_PQueue.push( val ); - return true; - } - - bool pop( value_type& dest ) - { - scoped_lock l( m_Lock ); - if ( !m_PQueue.empty() ) { - dest = m_PQueue.top(); - m_PQueue.pop(); - return true; - } - return false; - } - - template - bool pop_with( Q& dest, MoveFunc f ) - { - scoped_lock l( m_Lock ); - if ( !m_PQueue.empty() ) { - f( dest, m_PQueue.top()); - m_PQueue.pop(); - return true; - } - return false; - } - - void clear() - { - scoped_lock l( m_Lock ); - while ( !m_PQueue.empty() ) - m_PQueue.pop(); - } - - template - void clear_with( Func f ) - { - scoped_lock l( m_Lock ); - while ( !m_PQueue.empty() ) { - f( m_PQueue.top() ); - m_PQueue.pop(); - } - } - - bool empty() const - { - return m_PQueue.empty(); - } - - size_t size() const - { - return m_PQueue.size(); - } - - dummy_stat statistics() const - { - return dummy_stat(); - } - }; - -} // namespace pqueue - -namespace std { - static inline ostream& operator <<( ostream& o, pqueue::dummy_stat ) - { - return o; - } -} - -#endif // #ifndef CDSUNIT_STD_PQUEUE_H -- 2.34.1