]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/libs/fiber/performance/fiber/numa/skynet_stealing_detach.cpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / libs / fiber / performance / fiber / numa / skynet_stealing_detach.cpp
index ae06b5976b0bddbeaad3cc3c56980476f9ab062b..5d41b9c76bfbccf47c9c2d6367ab02795d7f5ca3 100644 (file)
@@ -24,7 +24,7 @@
 #include <vector>
 
 #include <boost/fiber/all.hpp>
-#include <boost/fiber/numa/topology.hpp>
+#include <boost/fiber/numa/all.hpp>
 #include <boost/predef.h>
 
 #include "../barrier.hpp"
@@ -69,9 +69,8 @@ void skynet( allocator_type & salloc, channel_type & c, std::size_t num, std::si
     }
 }
 
-void thread( std::uint32_t cpu_id, std::uint32_t node_id, std::vector< boost::fibers::numa::node > const& topo, barrier * b) {
-    boost::fibers::use_scheduling_algorithm< boost::fibers::algo::numa::work_stealing >( cpu_id, node_id, topo);
-    b->wait();
+void thread( std::uint32_t cpu_id, std::uint32_t node_id, std::vector< boost::fibers::numa::node > const& topo) {
+    boost::fibers::use_scheduling_algorithm< boost::fibers::numa::algo::work_stealing >( cpu_id, node_id, topo);
     lock_type lk( mtx);
     cnd.wait( lk, [](){ return done; });
     BOOST_ASSERT( done);
@@ -82,30 +81,21 @@ int main() {
         std::vector< boost::fibers::numa::node > topo = boost::fibers::numa::topology();
         auto node = topo[0];
         auto main_cpu_id = * node.logical_cpus.begin();
-        boost::fibers::use_scheduling_algorithm< boost::fibers::algo::numa::work_stealing >( main_cpu_id, node.id, topo);
-        barrier b{ hardware_concurrency( topo) };
         std::size_t size{ 1000000 };
         std::size_t div{ 10 };
-        // Windows 10 and FreeBSD require a fiber stack of 8kb
-        // otherwise the stack gets exhausted
-        // stack requirements must be checked for other OS too
-#if BOOST_OS_WINDOWS || BOOST_OS_BSD
         allocator_type salloc{ 2*allocator_type::traits_type::page_size() };
-#else
-        allocator_type salloc{ allocator_type::traits_type::page_size() };
-#endif
         std::uint64_t result{ 0 };
         channel_type rc{ 2 };
         std::vector< std::thread > threads;
-        for ( auto & node : topo) {
+        for ( auto && node : topo) {
             for ( std::uint32_t cpu_id : node.logical_cpus) {
                 // exclude main-thread
                 if ( main_cpu_id != cpu_id) {
-                    threads.emplace_back( thread, cpu_id, node.id, std::cref( topo), & b);
+                    threads.emplace_back( thread, cpu_id, node.id, std::cref( topo) );
                 }
             }
         }
-        b.wait();
+        boost::fibers::use_scheduling_algorithm< boost::fibers::numa::algo::work_stealing >( main_cpu_id, node.id, topo);
         time_point_type start{ clock_type::now() };
         skynet( salloc, rc, 0, size, div);
         result = rc.value_pop();