Galois
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
galois::substrate::ThreadPool Class Reference

#include <ThreadPool.h>

Classes

struct  dedicated_ty
 type for setting fastmode More...
 
struct  fastmode_ty
 type for shutting down thread More...
 
struct  per_signal
 type to switch to dedicated mode More...
 
struct  shutdown_ty
 

Public Member Functions

 ~ThreadPool ()
 
 ThreadPool (const ThreadPool &)=delete
 
ThreadPooloperator= (const ThreadPool &)=delete
 
 ThreadPool (ThreadPool &&)=delete
 
ThreadPooloperator= (ThreadPool &&)=delete
 
template<typename... Args>
void run (unsigned num, Args &&...args)
 execute work on all threads a simple wrapper for run More...
 
void runDedicated (std::function< void(void)> &f)
 run function in a dedicated thread until the threadpool exits More...
 
void burnPower (unsigned num)
 
void beKind ()
 
bool isRunning () const
 
unsigned getMaxUsableThreads () const
 return the number of non-reserved threads in the pool More...
 
unsigned getMaxThreads () const
 return the number of threads supported by the thread pool on the current machine More...
 
unsigned getMaxCores () const
 
unsigned getMaxSockets () const
 
unsigned getMaxNumaNodes () const
 
unsigned getLeaderForSocket (unsigned pid) const
 
bool isLeader (unsigned tid) const
 
unsigned getSocket (unsigned tid) const
 
unsigned getLeader (unsigned tid) const
 
unsigned getCumulativeMaxSocket (unsigned tid) const
 
unsigned getNumaNode (unsigned tid) const
 

Static Public Member Functions

static unsigned getTID ()
 
static bool isLeader ()
 
static unsigned getLeader ()
 
static unsigned getSocket ()
 
static unsigned getCumulativeMaxSocket ()
 
static unsigned getNumaNode ()
 

Protected Member Functions

void destroyCommon ()
 destroy all threads More...
 
void initThread (unsigned tid)
 Initialize a thread. More...
 
void threadLoop (unsigned tid)
 main thread loop More...
 
void cascade (bool fastmode)
 spin up for run More...
 
void decascade ()
 spin down after run More...
 
void runInternal (unsigned num)
 execute work on num threads More...
 
 ThreadPool ()
 

Protected Attributes

MachineTopoInfo mi
 
std::vector< per_signal * > signals
 
std::vector< std::thread > threads
 
unsigned reserved
 
unsigned masterFastmode
 
bool running
 
std::function< void(void)> work
 

Static Protected Attributes

static thread_local per_signal my_box
 

Friends

class SharedMem
 

Constructor & Destructor Documentation

ThreadPool::ThreadPool ( )
protected
ThreadPool::~ThreadPool ( )
galois::substrate::ThreadPool::ThreadPool ( const ThreadPool )
delete
galois::substrate::ThreadPool::ThreadPool ( ThreadPool &&  )
delete

Member Function Documentation

void ThreadPool::beKind ( )
void ThreadPool::burnPower ( unsigned  num)
void ThreadPool::cascade ( bool  fastmode)
protected

spin up for run

void ThreadPool::decascade ( )
protected

spin down after run

void ThreadPool::destroyCommon ( )
protected

destroy all threads

unsigned galois::substrate::ThreadPool::getCumulativeMaxSocket ( unsigned  tid) const
inline
static unsigned galois::substrate::ThreadPool::getCumulativeMaxSocket ( )
inlinestatic
unsigned galois::substrate::ThreadPool::getLeader ( unsigned  tid) const
inline
static unsigned galois::substrate::ThreadPool::getLeader ( )
inlinestatic
unsigned galois::substrate::ThreadPool::getLeaderForSocket ( unsigned  pid) const
inline
unsigned galois::substrate::ThreadPool::getMaxCores ( ) const
inline
unsigned galois::substrate::ThreadPool::getMaxNumaNodes ( ) const
inline
unsigned galois::substrate::ThreadPool::getMaxSockets ( ) const
inline
unsigned galois::substrate::ThreadPool::getMaxThreads ( ) const
inline

return the number of threads supported by the thread pool on the current machine

unsigned galois::substrate::ThreadPool::getMaxUsableThreads ( ) const
inline

return the number of non-reserved threads in the pool

unsigned galois::substrate::ThreadPool::getNumaNode ( unsigned  tid) const
inline
static unsigned galois::substrate::ThreadPool::getNumaNode ( )
inlinestatic
unsigned galois::substrate::ThreadPool::getSocket ( unsigned  tid) const
inline
static unsigned galois::substrate::ThreadPool::getSocket ( )
inlinestatic
static unsigned galois::substrate::ThreadPool::getTID ( )
inlinestatic
void ThreadPool::initThread ( unsigned  tid)
protected

Initialize a thread.

bool galois::substrate::ThreadPool::isLeader ( unsigned  tid) const
inline
static bool galois::substrate::ThreadPool::isLeader ( )
inlinestatic
bool galois::substrate::ThreadPool::isRunning ( ) const
inline
ThreadPool& galois::substrate::ThreadPool::operator= ( const ThreadPool )
delete
ThreadPool& galois::substrate::ThreadPool::operator= ( ThreadPool &&  )
delete
template<typename... Args>
void galois::substrate::ThreadPool::run ( unsigned  num,
Args &&...  args 
)
inline

execute work on all threads a simple wrapper for run

void ThreadPool::runDedicated ( std::function< void(void)> &  f)

run function in a dedicated thread until the threadpool exits

void ThreadPool::runInternal ( unsigned  num)
protected

execute work on num threads

void ThreadPool::threadLoop ( unsigned  tid)
protected

main thread loop

Friends And Related Function Documentation

friend class SharedMem
friend

Member Data Documentation

unsigned galois::substrate::ThreadPool::masterFastmode
protected
MachineTopoInfo galois::substrate::ThreadPool::mi
protected
thread_local ThreadPool::per_signal ThreadPool::my_box
staticprotected
unsigned galois::substrate::ThreadPool::reserved
protected
bool galois::substrate::ThreadPool::running
protected
std::vector<per_signal*> galois::substrate::ThreadPool::signals
protected
std::vector<std::thread> galois::substrate::ThreadPool::threads
protected
std::function<void(void)> galois::substrate::ThreadPool::work
protected

The documentation for this class was generated from the following files: