21#ifndef __PBeFS_SearchUtils
22 #define __PBeFS_SearchUtils
41#include "ADS/concurrent/Backoff.h"
43#include "ADS/dictionary/RandomHashing.h"
45#include "ADS/memory/HugePageAllocator.h"
47#include "ADS/parallel/Affinity.h"
49#include "ADS/parallel/Executor.h"
51#include "ADS/parallel/ThreadPool.h"
79 static const bool pin = [] {
80 const char * v = std::getenv(
"PBEFS_PIN" );
81 return( v && *v && ( v[ 0 ] !=
'0' ) );
84 static_cast< void >( ADS::pinThread( i ) );
120template< ADS::WorkerExecutor Executor ,
class F >
123 const auto body = [ & f ]( std::size_t i ) {
124 if( ! ADS::isRunCaller() )
141 #if defined( __GNUC__ ) || defined( __clang__ )
142 __builtin_prefetch( p , 0 , 1 );
158 return(
double( std::uint64_t( gen() ) >> 11 ) * 0x1.0p-53 );
167 return( std::uint64_t( gen() ) % n );
179 Stopwatch(
void ) : f_start( std::chrono::steady_clock::now() ) {}
183 return( std::chrono::duration< double >(
184 std::chrono::steady_clock::now() - f_start ).count() );
189 std::chrono::steady_clock::time_point f_start;
Stopwatch(void)
Definition SearchUtils.h:179
double seconds(void) const
the seconds elapsed since the construction
Definition SearchUtils.h:182
namespace for the Parallel Best-First Search library
Definition AStar.h:83
constexpr std::size_t cache_line
the size of a cache line, used to keep the data of the workers apart
Definition SearchUtils.h:66
std::uint64_t random_below(Gen &gen, std::uint64_t n)
an integer in [ 0 , n ) from the next word of a 64-bit generator, n > 0
Definition SearchUtils.h:165
void run_workers(Executor *ex, unsigned p, F &&f)
runs the workers f( 0 ) , ... , f( p - 1 ) at once on an Executor
Definition SearchUtils.h:121
double random_unit(Gen &gen)
a real number in [ 0 , 1 ) from the next word of a 64-bit generator
Definition SearchUtils.h:156
void pin_worker(unsigned i) noexcept
pins the calling thread to the i-th CPU it may run on, if PBEFS_PIN is set
Definition SearchUtils.h:77
void prefetch(const void *p) noexcept
hints the processor to bring the cache line of p in, for reading
Definition SearchUtils.h:139
the parameters shared by the parallel searches
Definition SearchUtils.h:94
std::uint64_t seed
seed of the owners
Definition SearchUtils.h:99
std::size_t batch
nodes packed in a message
Definition SearchUtils.h:97
unsigned flush_period
steps between flushes of outboxes
Definition SearchUtils.h:98
unsigned threads
the number of workers
Definition SearchUtils.h:96
void normalize(void) noexcept
sets to 1 any parameter that is 0
Definition SearchUtils.h:102