-/*
- 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 <cds_test/stress_test.h>
-
-#include <cds/init.h>
-#include <cds/gc/hp.h>
-#include <cds/gc/dhp.h>
-#ifdef CDSUNIT_USE_URCU
-# include <cds/urcu/general_instant.h>
-# include <cds/urcu/general_buffered.h>
-# include <cds/urcu/general_threaded.h>
-# include <cds/urcu/signal_buffered.h>
-# include <cds/urcu/signal_threaded.h>
-#endif
-
-int main( int argc, char **argv ) \r
+/*\r
+ This file is a part of libcds - Concurrent Data Structures library\r
+\r
+ (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2017\r
+\r
+ Source code repo: http://github.com/khizmax/libcds/\r
+ Download: http://sourceforge.net/projects/libcds/files/\r
+\r
+ Redistribution and use in source and binary forms, with or without\r
+ modification, are permitted provided that the following conditions are met:\r
+\r
+ * Redistributions of source code must retain the above copyright notice, this\r
+ list of conditions and the following disclaimer.\r
+\r
+ * Redistributions in binary form must reproduce the above copyright notice,\r
+ this list of conditions and the following disclaimer in the documentation\r
+ and/or other materials provided with the distribution.\r
+\r
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\r
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\r
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\r
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+*/\r
+\r
+#include <cds_test/stress_test.h>\r
+\r
+#include <cds/init.h>\r
+#include <cds/gc/hp.h>\r
+#include <cds/gc/dhp.h>\r
+#ifdef CDSUNIT_USE_URCU\r
+# include <cds/urcu/general_instant.h>\r
+# include <cds/urcu/general_buffered.h>\r
+# include <cds/urcu/general_threaded.h>\r
+# include <cds/urcu/signal_buffered.h>\r
+# include <cds/urcu/signal_threaded.h>\r
+#endif\r
+\r
+#ifdef CDS_ENABLE_HPSTAT\r
+# include <cds_test/stat_hp_out.h>\r
+# include <cds_test/stat_dhp_out.h>\r
+# include <iostream>\r
+#endif\r
+\r
+int main( int argc, char **argv )\r
{\r
int result;\r
cds::Initialize();\r
{\r
- ::testing::InitGoogleTest( &argc, argv );\r
-\r
// Read test config file\r
cds_test::init_config( argc, argv );\r
\r
+ // Get detail level for stress test\r
+ cds_test::stress_fixture::init_detail_level( argc, argv );\r
+\r
+ // Init Google test\r
+ ::testing::InitGoogleTest( &argc, argv );\r
+\r
cds_test::config const& general_cfg = cds_test::stress_fixture::get_config( "General" );\r
\r
- // Init SMR
- cds::gc::HP hzpGC( general_cfg.get_size_t( "hazard_pointer_count", 16 ));
- hzpGC.setScanType( general_cfg.get( "HZP_scan_strategy", "inplace" ) == "inplace" ? cds::gc::HP::scan_type::inplace : cds::gc::HP::scan_type::classic );
-
- cds::gc::DHP dhpGC(
- general_cfg.get_size_t( "dhp_liberate_threshold", 1024 ),
- general_cfg.get_size_t( "dhp_init_guard_count", 16 ),
- general_cfg.get_size_t( "dhp_epoch_count", 16 )
- );
-
-#ifdef CDSUNIT_USE_URCU
- size_t rcu_buffer_size = general_cfg.get_size_t( "rcu_buffer_size", 256 );
-
- // RCU varieties
- typedef cds::urcu::gc< cds::urcu::general_instant<> > rcu_gpi;
- rcu_gpi gpiRCU;
-
- typedef cds::urcu::gc< cds::urcu::general_buffered<> > rcu_gpb;
- rcu_gpb gpbRCU( rcu_buffer_size );
-
- typedef cds::urcu::gc< cds::urcu::general_threaded<> > rcu_gpt;
- rcu_gpt gptRCU( rcu_buffer_size );
-
-# ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
- typedef cds::urcu::gc< cds::urcu::signal_buffered<> > rcu_shb;
- rcu_shb shbRCU( rcu_buffer_size, SIGUSR1 );
-
- typedef cds::urcu::gc< cds::urcu::signal_threaded<> > rcu_sht;
- rcu_sht shtRCU( rcu_buffer_size, SIGUSR2 );
-# endif
-#endif // CDSUNIT_USE_URCU
+ // Init SMR\r
+ cds::gc::HP hzpGC( \r
+ general_cfg.get_size_t( "hazard_pointer_count", 16 ),\r
+ general_cfg.get_size_t( "hp_max_thread_count", 0 ),\r
+ general_cfg.get_size_t( "hp_retired_ptr_count", 0 ),\r
+ general_cfg.get( "hp_scan_strategy", "inplace" ) == "inplace" ? cds::gc::HP::scan_type::inplace : cds::gc::HP::scan_type::classic\r
+ );\r
+\r
+ cds::gc::DHP dhpGC(\r
+ general_cfg.get_size_t( "dhp_init_guard_count", 16 )\r
+ );\r
+\r
+#ifdef CDSUNIT_USE_URCU\r
+ size_t rcu_buffer_size = general_cfg.get_size_t( "rcu_buffer_size", 256 );\r
+\r
+ // RCU varieties\r
+ typedef cds::urcu::gc< cds::urcu::general_instant<> > rcu_gpi;\r
+ rcu_gpi gpiRCU;\r
+\r
+ typedef cds::urcu::gc< cds::urcu::general_buffered<> > rcu_gpb;\r
+ rcu_gpb gpbRCU( rcu_buffer_size );\r
+\r
+ typedef cds::urcu::gc< cds::urcu::general_threaded<> > rcu_gpt;\r
+ rcu_gpt gptRCU( rcu_buffer_size );\r
+\r
+# ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED\r
+ typedef cds::urcu::gc< cds::urcu::signal_buffered<> > rcu_shb;\r
+ rcu_shb shbRCU( rcu_buffer_size, SIGUSR1 );\r
+\r
+ typedef cds::urcu::gc< cds::urcu::signal_threaded<> > rcu_sht;\r
+ rcu_sht shtRCU( rcu_buffer_size, SIGUSR2 );\r
+# endif\r
+#endif // CDSUNIT_USE_URCU\r
\r
cds::threading::Manager::attachThread();\r
\r
\r
cds::threading::Manager::detachThread();\r
}\r
+\r
+#ifdef CDS_ENABLE_HPSTAT\r
+ {\r
+ cds::gc::HP::stat const& st = cds::gc::HP::postmortem_statistics();\r
+ EXPECT_EQ( st.guard_allocated, st.guard_freed );\r
+ EXPECT_EQ( st.retired_count, st.free_count );\r
+ std::cout << st;\r
+ }\r
+ {\r
+ cds::gc::DHP::stat const& st = cds::gc::DHP::postmortem_statistics();\r
+ EXPECT_EQ( st.guard_allocated, st.guard_freed );\r
+ EXPECT_EQ( st.retired_count, st.free_count );\r
+ std::cout << st;\r
+ }\r
+#endif\r
+\r
cds::Terminate();\r
+\r
return result;\r
-}
+}\r