X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=test%2Fstress%2Fmain.cpp;h=ee8bcf9db370a143edae981e9d1641d7dd651c5e;hb=c29e34421838b0da071e56e7b21033f30e0bf959;hp=ce60231ee997ebdc4a8538dee5594b365ab9c528;hpb=7448008aa977fe42a83738fbbc63ce11d8ab86f9;p=libcds.git diff --git a/test/stress/main.cpp b/test/stress/main.cpp index ce60231e..ee8bcf9d 100644 --- a/test/stress/main.cpp +++ b/test/stress/main.cpp @@ -1,47 +1,52 @@ -/* - 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 - -#include -#include -#include -#ifdef CDSUNIT_USE_URCU -# include -# include -# include -# include -# include -#endif - -int main( int argc, char **argv ) +/* + This file is a part of libcds - Concurrent Data Structures library + + (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2017 + + Source code repo: http://github.com/khizmax/libcds/ + Download: http://sourceforge.net/projects/libcds/files/ + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * 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 + +#include +#include +#include +#ifdef CDSUNIT_USE_URCU +# include +# include +# include +# include +#endif + +#ifdef CDS_ENABLE_HPSTAT +# include +# include +# include +#endif + +int main( int argc, char **argv ) { int result; cds::Initialize(); @@ -49,42 +54,43 @@ int main( int argc, char **argv ) // Read test config file cds_test::init_config( argc, argv ); + std::cout << "Hardware concurrency: " << std::thread::hardware_concurrency() << "\n"; + // Init Google test ::testing::InitGoogleTest( &argc, argv ); cds_test::config const& general_cfg = cds_test::stress_fixture::get_config( "General" ); - // 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 + cds::gc::HP hzpGC( + general_cfg.get_size_t( "hazard_pointer_count", 16 ), + general_cfg.get_size_t( "hp_max_thread_count", 0 ), + general_cfg.get_size_t( "hp_retired_ptr_count", 0 ), + general_cfg.get( "hp_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_init_guard_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 ); +# endif +#endif // CDSUNIT_USE_URCU cds::threading::Manager::attachThread(); @@ -92,6 +98,23 @@ int main( int argc, char **argv ) cds::threading::Manager::detachThread(); } + +#ifdef CDS_ENABLE_HPSTAT + { + cds::gc::HP::stat const& st = cds::gc::HP::postmortem_statistics(); + EXPECT_EQ( st.guard_allocated, st.guard_freed ); + EXPECT_EQ( st.retired_count, st.free_count ); + std::cout << st; + } + { + cds::gc::DHP::stat const& st = cds::gc::DHP::postmortem_statistics(); + EXPECT_EQ( st.guard_allocated, st.guard_freed ); + EXPECT_EQ( st.retired_count, st.free_count ); + std::cout << st; + } +#endif + cds::Terminate(); + return result; -} +}