Fleet  0.0.9
Inference in the LOT
Public Types | Public Member Functions | Public Attributes | List of all members
ChainPool< HYP, Chain_t > Class Template Reference

#include <ChainPool.h>

Inheritance diagram for ChainPool< HYP, Chain_t >:
Inheritance graph
[legend]
Collaboration diagram for ChainPool< HYP, Chain_t >:
Collaboration graph
[legend]

Public Types

enum  RunningState { RunningState::READY, RunningState::RUNNING, RunningState::DONE }
 

Public Member Functions

 ChainPool ()
 
 ChainPool (HYP &h0, typename HYP::data_t *d, size_t n)
 
void set_data (typename HYP::data_t *d, bool recompute=true)
 Set this data. More...
 
template<typename... ARGS>
void add_chain (ARGS... args)
 Lock and modify the pool. More...
 
size_t nchains () const
 
void show (std::string prefix) const
 
generator< HYP & > run_thread (Control &ctl) override
 This run helper is called internally by multiple different threads, and runs a given pool. More...
 
- Public Member Functions inherited from ThreadedInferenceInterface< HYP >
virtual generator< HYP &> run_thread (Control &ctl, Args... args)=0
 
 ThreadedInferenceInterface ()
 
unsigned long next_index ()
 Return the next index to operate on (in a thread-safe way). More...
 
size_t nthreads ()
 How many threads are currently run in this interface? More...
 
void run_thread_generator_wrapper (size_t thr, Control &ctl, Args... args)
 We have to wrap run_thread in something that manages the sync with main. This really just synchronizes the output of run_thread with run below. NOTE this makes a copy of x into the local next_x, so that when the thread keeps running, it doesn't mess anything up. We may in the future block the thread and return a reference, but its not clear that's faster. More...
 
generator< HYP &> run (Control ctl, Args... args)
 Set up the multiple threads and actually run, calling run_thread_generator_wrapper. More...
 
generator< HYP &> unthreaded_run (Control ctl, Args... args)
 

Public Attributes

std::vector< Chain_t > pool
 
unsigned long steps_before_change = 100
 
std::vector< RunningStaterunning
 
OrderedLock running_lock
 
- Public Attributes inherited from ThreadedInferenceInterface< HYP >
std::atomic< size_t > index
 
size_t __nthreads
 
std::atomic< size_t > __nrunning
 
ConcurrentQueue< HYP > to_yield
 

Detailed Description

template<typename HYP, typename Chain_t = MCMCChain<HYP>>
class ChainPool< HYP, Chain_t >

Author
steven piantadosi
Date
29/01/20

Member Enumeration Documentation

◆ RunningState

template<typename HYP, typename Chain_t = MCMCChain<HYP>>
enum ChainPool::RunningState
strong
Enumerator
READY 
RUNNING 
DONE 

Constructor & Destructor Documentation

◆ ChainPool() [1/2]

template<typename HYP, typename Chain_t = MCMCChain<HYP>>
ChainPool< HYP, Chain_t >::ChainPool ( )
inline

◆ ChainPool() [2/2]

template<typename HYP, typename Chain_t = MCMCChain<HYP>>
ChainPool< HYP, Chain_t >::ChainPool ( HYP &  h0,
typename HYP::data_t *  d,
size_t  n 
)
inline

Member Function Documentation

◆ add_chain()

template<typename HYP, typename Chain_t = MCMCChain<HYP>>
template<typename... ARGS>
void ChainPool< HYP, Chain_t >::add_chain ( ARGS...  args)
inline

Lock and modify the pool.

Parameters
h0
d

◆ nchains()

template<typename HYP, typename Chain_t = MCMCChain<HYP>>
size_t ChainPool< HYP, Chain_t >::nchains ( ) const
inline

◆ run_thread()

template<typename HYP, typename Chain_t = MCMCChain<HYP>>
generator<HYP&> ChainPool< HYP, Chain_t >::run_thread ( Control ctl)
inlineoverride

This run helper is called internally by multiple different threads, and runs a given pool.

Parameters
ctl

figure out how many steps to run

◆ set_data()

template<typename HYP, typename Chain_t = MCMCChain<HYP>>
void ChainPool< HYP, Chain_t >::set_data ( typename HYP::data_t *  d,
bool  recompute = true 
)
inline

Set this data.

Parameters
d– what data to set
recompute– should I recompute all of the posteriors?

◆ show()

template<typename HYP, typename Chain_t = MCMCChain<HYP>>
void ChainPool< HYP, Chain_t >::show ( std::string  prefix) const
inline

Member Data Documentation

◆ pool

template<typename HYP, typename Chain_t = MCMCChain<HYP>>
std::vector<Chain_t> ChainPool< HYP, Chain_t >::pool

◆ running

template<typename HYP, typename Chain_t = MCMCChain<HYP>>
std::vector<RunningState> ChainPool< HYP, Chain_t >::running

◆ running_lock

template<typename HYP, typename Chain_t = MCMCChain<HYP>>
OrderedLock ChainPool< HYP, Chain_t >::running_lock

◆ steps_before_change

template<typename HYP, typename Chain_t = MCMCChain<HYP>>
unsigned long ChainPool< HYP, Chain_t >::steps_before_change = 100

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