From bad10788ff0976b8733b6682a8d682d249238619 Mon Sep 17 00:00:00 2001 From: joaquintides Date: Mon, 12 Feb 2024 12:02:07 +0100 Subject: [PATCH] strengthened erase, relaxed metadata ops --- .../unordered/detail/foa/concurrent_table.hpp | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/include/boost/unordered/detail/foa/concurrent_table.hpp b/include/boost/unordered/detail/foa/concurrent_table.hpp index f7e112bc..0b478063 100644 --- a/include/boost/unordered/detail/foa/concurrent_table.hpp +++ b/include/boost/unordered/detail/foa/concurrent_table.hpp @@ -202,7 +202,7 @@ private: template struct atomic_integral { -#if defined(BOOST_UNORDERED_LATCH_FREE) +#if 0&&defined(BOOST_UNORDERED_LATCH_FREE) operator Integral()const{return n.load(std::memory_order_acquire);} void operator=(Integral m){n.store(m,std::memory_order_release);} void operator|=(Integral m){n.fetch_or(m);} @@ -553,7 +553,7 @@ public: #if defined(BOOST_UNORDERED_LATCH_FREE) ~concurrent_table(){ std::cout - <<"version: 2024/02/10 20:50; " + <<"version: 2024/02/12 12:00; " <<"lf: "<<(double)size()/capacity()<<"; " <<"size: "<reset(n); auto pc=reinterpret_cast*>(pg)+n; - if(pc->exchange(0,std::memory_order_release)!=0){ + if(pc->exchange(0)!=0){ auto& sc=local_size_ctrl(); sc.size.fetch_sub(1,std::memory_order_relaxed); sc.mcos.fetch_add( @@ -1274,8 +1274,9 @@ private: #if defined(BOOST_UNORDERED_LATCH_FREE) static bool is_occupied(group_type* pg,std::size_t pos) { - return reinterpret_cast*>(pg)[pos]. - load(std::memory_order_acquire)>1; + //return reinterpret_cast*>(pg)[pos]. + // load(std::memory_order_acquire)>1; + return true; } #else static bool is_occupied(group_type* pg,std::size_t pos) @@ -1297,14 +1298,14 @@ private: { auto& acnt=access_counter(pos); for(;;){ - auto n=acnt.load(std::memory_order_acquire); - if(n%2==1)continue; + auto n= + acnt.load(std::memory_order_acquire)& + ~boost::uint32_t(1); auto res=f(); std::atomic_thread_fence(std::memory_order_acquire); - if(acnt.load(std::memory_order_acquire)!=n)continue; - else return {res,n}; + if(BOOST_LIKELY(acnt.load(std::memory_order_relaxed)==n))return {res,n}; } } @@ -1328,8 +1329,10 @@ private: { auto &acnt=access_counter(pos); for(;;){ - auto n=acnt.load(std::memory_order_acquire); - if(n%2==1)continue; + auto n= + acnt.load(std::memory_order_acquire)& + ~boost::uint32_t(1); + //if(n%2==1)continue; if(save_access(pos,n,f))return; }