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

Contains threading and machine OS support. More...

Classes

class  Barrier
 
struct  CacheLineStorage
 
struct  ThreadTopoInfo
 
struct  MachineTopoInfo
 
struct  HWTopoInfo
 
class  PaddedLock
 PaddedLock is a spinlock. More...
 
class  PaddedLock< true >
 
class  PaddedLock< false >
 
class  PerBackend
 
class  PerThreadStorage
 
class  PerSocketStorage
 
class  PtrLock
 PtrLock is a spinlock and a pointer. More...
 
class  DummyPtrLock
 
class  SharedMem
 
class  SimpleLock
 SimpleLock is a spinlock. More...
 
class  DummyLock
 Dummy Lock implements the lock interface without a lock for serial code. More...
 
struct  StaticInstance
 
class  TerminationDetection
 
class  ThreadPool
 
class  ThreadRWlock
 

Typedefs

typedef std::unique_ptr< void,
internal::largeFreer > 
LAptr
 
template<bool Enabled>
using CondLock = typename std::conditional< Enabled, SimpleLock, DummyLock >::type
 
using lock_guard_galois = std::lock_guard< SimpleLock >
 

Functions

void initPTS (unsigned)
 
BarriergetBarrier (unsigned activeThreads)
 Return a reference to system barrier. More...
 
std::unique_ptr< BarriercreatePthreadBarrier (unsigned)
 Create specific types of barriers. More...
 
std::unique_ptr< BarriercreateMCSBarrier (unsigned)
 
std::unique_ptr< BarriercreateTopoBarrier (unsigned)
 
std::unique_ptr< BarriercreateCountingBarrier (unsigned)
 
std::unique_ptr< BarriercreateDisseminationBarrier (unsigned)
 
std::unique_ptr< BarriercreateSimpleBarrier (unsigned int)
 Creates a new simple barrier. More...
 
bool EnvCheck (const char *varName)
 Return true if the Enviroment variable is set. More...
 
bool EnvCheck (const std::string &varName)
 
template<typename T >
bool EnvCheck (const char *varName, T &retVal)
 Return true if Enviroment variable is set, and extract its value into 'retVal' parameter. More...
 
template<typename T >
bool EnvCheck (const std::string &varName, T &retVal)
 
HWTopoInfo getHWTopo ()
 getHWTopo determines the machine topology from the process information exposed in /proc and /dev filesystems. More...
 
std::vector< int > parseCPUList (const std::string &in)
 parseCPUList parses cpuset information in "List format" as described in cpuset(7) and available under /proc/self/status More...
 
bool bindThreadSelf (unsigned osContext)
 bindThreadSelf binds a thread to an osContext as returned by getHWTopo. More...
 
LAptr largeMallocLocal (size_t bytes)
 
LAptr largeMallocFloating (size_t bytes)
 
LAptr largeMallocInterleaved (size_t bytes, unsigned numThreads)
 
LAptr largeMallocBlocked (size_t bytes, unsigned numThreads)
 
template<typename RangeArrayTy >
LAptr largeMallocSpecified (size_t bytes, uint32_t numThreads, RangeArrayTy &threadRanges, size_t elementSize)
 Allocates pages for some specified number of bytes, then does NUMA page faulting based on a specified distribution of elements among threads. More...
 
size_t allocSize ()
 
void * allocPages (unsigned num, bool preFault)
 
void freePages (void *ptr, unsigned num)
 
PerBackendgetPTSBackend ()
 
PerBackendgetPPSBackend ()
 
TerminationDetectiongetSystemTermination (unsigned activeThreads)
 
ThreadPoolgetThreadPool (void)
 return a reference to system thread pool More...
 
template<typename L , typename R , typename W >
void readUpdateProtected (L &rwmutex, R &readAndCheck, W &write)
 readOrUpdate is a generic function to perform reads or writes using a rwmutex More...
 

Variables

constexpr int GALOIS_CACHE_LINE_SIZE = 128
 
thread_local char * ptsBase
 
thread_local char * pssBase
 

Detailed Description

Contains threading and machine OS support.

Typedef Documentation

template<bool Enabled>
using galois::substrate::CondLock = typedef typename std::conditional<Enabled, SimpleLock, DummyLock>::type
typedef std::unique_ptr<void, internal::largeFreer> galois::substrate::LAptr
using galois::substrate::lock_guard_galois = typedef std::lock_guard<SimpleLock>

Function Documentation

void * galois::substrate::allocPages ( unsigned  num,
bool  preFault 
)
size_t galois::substrate::allocSize ( )
bool galois::substrate::bindThreadSelf ( unsigned  osContext)

bindThreadSelf binds a thread to an osContext as returned by getHWTopo.

binds current thread to OS HW context "proc"

std::unique_ptr< galois::substrate::Barrier > galois::substrate::createCountingBarrier ( unsigned  activeThreads)
std::unique_ptr< galois::substrate::Barrier > galois::substrate::createDisseminationBarrier ( unsigned  activeThreads)
std::unique_ptr< galois::substrate::Barrier > galois::substrate::createMCSBarrier ( unsigned  activeThreads)
std::unique_ptr< galois::substrate::Barrier > galois::substrate::createPthreadBarrier ( unsigned  )

Create specific types of barriers.

For benchmarking only. Use getBarrier() for all production code

std::unique_ptr< galois::substrate::Barrier > galois::substrate::createSimpleBarrier ( unsigned int  v)

Creates a new simple barrier.

This barrier is not designed to be fast but does gaurantee that all threads have left the barrier before returning control. Useful when the number of active threads is modified to avoid a race in getBarrier(). Client is reponsible for deallocating returned barrier.

std::unique_ptr< galois::substrate::Barrier > galois::substrate::createTopoBarrier ( unsigned  activeThreads)
bool galois::substrate::EnvCheck ( const char *  varName)

Return true if the Enviroment variable is set.

bool galois::substrate::EnvCheck ( const std::string &  varName)
template<typename T >
bool galois::substrate::EnvCheck ( const char *  varName,
T &  retVal 
)

Return true if Enviroment variable is set, and extract its value into 'retVal' parameter.

Parameters
varName,:name of the variable
retVal,:lvalue to store the value of environment variable
Returns
true if environment variable set, false otherwise
template<typename T >
bool galois::substrate::EnvCheck ( const std::string &  varName,
T &  retVal 
)
void galois::substrate::freePages ( void *  ptr,
unsigned  num 
)
galois::substrate::Barrier & galois::substrate::getBarrier ( unsigned  activeThreads)

Return a reference to system barrier.

galois::substrate::HWTopoInfo galois::substrate::getHWTopo ( )

getHWTopo determines the machine topology from the process information exposed in /proc and /dev filesystems.

galois::substrate::PerBackend & galois::substrate::getPPSBackend ( )
galois::substrate::PerBackend & galois::substrate::getPTSBackend ( )
galois::substrate::TerminationDetection & galois::substrate::getSystemTermination ( unsigned  activeThreads)
galois::substrate::ThreadPool & galois::substrate::getThreadPool ( void  )

return a reference to system thread pool

void galois::substrate::initPTS ( unsigned  )
LAptr galois::substrate::largeMallocBlocked ( size_t  bytes,
unsigned  numThreads 
)
LAptr galois::substrate::largeMallocFloating ( size_t  bytes)
LAptr galois::substrate::largeMallocInterleaved ( size_t  bytes,
unsigned  numThreads 
)
LAptr galois::substrate::largeMallocLocal ( size_t  bytes)
template<typename RangeArrayTy >
LAptr galois::substrate::largeMallocSpecified ( size_t  bytes,
uint32_t  numThreads,
RangeArrayTy &  threadRanges,
size_t  elementSize 
)

Allocates pages for some specified number of bytes, then does NUMA page faulting based on a specified distribution of elements among threads.

Template Parameters
RangeArrayTyType of threadRanges array: should either be uint32_t* or uint64_t*
Parameters
bytesNumber of bytes to allocate
numThreadsNumber of threads to page in regions for
threadRangesArray specifying distribution of elements among threads
elementSizeSize of a data element that will be stored in the allocated memory
Returns
The allocated memory along with a freer object
std::vector< int > galois::substrate::parseCPUList ( const std::string &  in)

parseCPUList parses cpuset information in "List format" as described in cpuset(7) and available under /proc/self/status

template<typename L , typename R , typename W >
void galois::substrate::readUpdateProtected ( L &  rwmutex,
R &  readAndCheck,
W &  write 
)

readOrUpdate is a generic function to perform reads or writes using a rwmutex

Parameters
rwmutexis a read/write lock that implements readLock/readUnlock, writeLoack/writeUnlock
readAndCheckis function object to execute when reading. It returns true only if read was successful. Should update state to store read result. Shouldn't use rwmutex internally
writeis function object to perform the write. It should update state to store result after writing. Shouldn't use rwmutex internally

Variable Documentation

constexpr int galois::substrate::GALOIS_CACHE_LINE_SIZE = 128
thread_local char * galois::substrate::pssBase
thread_local char * galois::substrate::ptsBase