#include <MultiThreadSimEngine.h>
Public Member Functions | |
MultiThreadSimEngine (int ID, int numThreads, ThreadPool &thrPool, SpikeScheduler &scheduler, AnalogMessageDispatcherVector &analogMsgDispatchers, SimNetwork &net) | |
Constructs a MultiThreadSimEngine. | |
virtual | ~MultiThreadSimEngine () |
virtual void | advance (int nSteps=1) |
advances the engine for a specified number of simulation timesteps. | |
virtual void | reset () |
resets the simulation, and returns the simulation clock to time = 0. | |
virtual void | initialize () |
Initializes engine and all of the objects inside it, so that they are ready for simulation. Calls also reset() inside. | |
virtual void | addObject (SimObjectFactory const &objFactory, SimObject::ID &id) |
Adds an advancable object to be advanced by the engine. | |
void | addForAdvanceCycle (AnalogDelayObject *o, SimObject::ID &id) |
virtual void | mount (const SimObjectFactory &objFactory, const SimObject::ID &mountpoint, SimObject::ID &gid) |
virtual void | insert (const SimObjectFactory &objFactory, const SimObject::ID &mountpoint, SimObject::ID &gid) |
virtual SimObject * | getObject (const SimObject::ID &id) |
Gets a pointer of a previously stored sim object in the simulation engine. | |
SimObjectPool * | getPool (engineid_t e) |
Gets a pointer of the sim object pool [used for testing only]. | |
void | advanceSeveralStepsWithinACycle (int steps) |
void | finalizeCycle () |
void | advanceOneFullCycle () |
Advance all elements for one cycle (equal to minDelay time steps). | |
SingleThreadSimEngine & | getSTEngine (engineid_t eng) |
virtual void | seed (vector< uint32 > const &noiseSeed) |
virtual void | seed (uint32 noiseSeed) |
virtual void | noiseRandEngineOutput (vector< uint32 > &r) |
Protected Member Functions | |
void | two_way_link (const SimObject::ID &id1, const SimObject::ID &id2) |
void | one_way_link (const SimObject::ID &id1, const SimObject::ID &id2) |
Protected Attributes | |
int | _numThreads |
Variable holding the number of Threads the MTengine is using. | |
ThreadPool & | thr_pool |
Pool of threads used for advancing the SingleThreadSimEngine-s in separate threads. | |
vector< SimEngineAdvanceJob > | advance_jobs |
jobs executed by the threads in the ThreadPool for advancement of Single thread engines. | |
vector< SimEngineResetJob > | reset_jobs |
jobs executed by the threads in the ThreadPool for reset of Single thread engines. | |
vector< SimEngineInitializeJob > | initialize_jobs |
vector< SingleThreadSimEngine * > | engines |
Array of single thread sim engines this engine employs for performing the actual simulation. | |
boost::barrier * | thr_barrier |
vector< vector < AnalogDelayObject * > > | analogDelayObjects |
vector< CycleAdvanceJob > | mtCycleAdvanceJobs |
int | currentStepWithinCycle |
Spiking Network Simulation engine for performing a multi-threaded simulation. Instantiates multiple Single-Thread engines, and advances them concurrently in multiple threads. Apart from advancing the single thread simulation engines, it also controls the multi-threaded spike scheduler.
Definition at line 103 of file MultiThreadSimEngine.h.
MultiThreadSimEngine::MultiThreadSimEngine | ( | int | ID, | |
int | numThreads, | |||
ThreadPool & | thrPool, | |||
SpikeScheduler & | scheduler, | |||
AnalogMessageDispatcherVector & | analogMsgDispatchers, | |||
SimNetwork & | net | |||
) |
Constructs a MultiThreadSimEngine.
ID | Identifier of the engine (usually 0) | |
thrPool | pool of threads used for multi-thread concurrent processing in the simulation. | |
scheduler | spike scheduler the engine uses for spike scheduling (can be MultiThreadSpikeScheduler or DistributedSpikeScheduler). | |
sp | holds the common parameters of the simulation. |
Definition at line 51 of file MultiThreadSimEngine.cpp.
References _numThreads, advance_jobs, analogDelayObjects, engines, SimNetwork::get_dt(), Time::in_steps(), initialize_jobs, SimParameter::minDelay, mtCycleAdvanceJobs, reset_jobs, SimNetwork::simParameter(), SimEngine::spikeScheduler, and thr_barrier.
MultiThreadSimEngine::~MultiThreadSimEngine | ( | ) | [virtual] |
Definition at line 83 of file MultiThreadSimEngine.cpp.
References _numThreads, engines, and thr_barrier.
void MultiThreadSimEngine::advance | ( | int | nSteps = 1 |
) | [virtual] |
advances the engine for a specified number of simulation timesteps.
Implements SimEngine.
Definition at line 167 of file MultiThreadSimEngine.cpp.
References advanceOneFullCycle(), advanceSeveralStepsWithinACycle(), currentStepWithinCycle, SimEngine::default_steps_per_cycle, and finalizeCycle().
Referenced by MultiThreadNetwork::_advance_().
void MultiThreadSimEngine::reset | ( | ) | [virtual] |
resets the simulation, and returns the simulation clock to time = 0.
Implements SimEngine.
Definition at line 148 of file MultiThreadSimEngine.cpp.
References _numThreads, currentStepWithinCycle, ThreadPool::dispatch(), engines, reset_jobs, thr_pool, and ThreadPool::waitAll().
Referenced by MultiThreadNetwork::_reset_().
void MultiThreadSimEngine::initialize | ( | ) | [virtual] |
Initializes engine and all of the objects inside it, so that they are ready for simulation. Calls also reset() inside.
Implements SimEngine.
Definition at line 157 of file MultiThreadSimEngine.cpp.
References _numThreads, ThreadPool::dispatch(), engines, initialize_jobs, thr_pool, and ThreadPool::waitAll().
Referenced by MultiThreadNetwork::_initialize_().
virtual void MultiThreadSimEngine::addObject | ( | SimObjectFactory const & | objFactory, | |
SimObject::ID & | id | |||
) | [inline, virtual] |
Adds an advancable object to be advanced by the engine.
Implements SimEngine.
Definition at line 139 of file MultiThreadSimEngine.h.
References engines.
Referenced by MultiThreadNetwork::_addObject_(), MTAnalogMessageCreator::addAnalogMessage(), insert(), and mount().
void MultiThreadSimEngine::addForAdvanceCycle | ( | AnalogDelayObject * | o, | |
SimObject::ID & | id | |||
) | [inline] |
Definition at line 144 of file MultiThreadSimEngine.h.
References analogDelayObjects, and AnalogDelayObject::setAddedForAdvanceCycle().
Referenced by MTAnalogMessageCreator::addAnalogMessage().
void MultiThreadSimEngine::mount | ( | const SimObjectFactory & | objFactory, | |
const SimObject::ID & | mountpoint, | |||
SimObject::ID & | gid | |||
) | [virtual] |
Implements SimEngine.
Definition at line 115 of file MultiThreadSimEngine.cpp.
References addObject(), and one_way_link().
Referenced by MultiThreadNetwork::_mount_().
void MultiThreadSimEngine::insert | ( | const SimObjectFactory & | objFactory, | |
const SimObject::ID & | mountpoint, | |||
SimObject::ID & | gid | |||
) | [virtual] |
Implements SimEngine.
Definition at line 121 of file MultiThreadSimEngine.cpp.
References addObject(), and two_way_link().
Referenced by MultiThreadNetwork::_insert_().
virtual SimObject* MultiThreadSimEngine::getObject | ( | const SimObject::ID & | id | ) | [inline, virtual] |
Gets a pointer of a previously stored sim object in the simulation engine.
Implements SimEngine.
Definition at line 154 of file MultiThreadSimEngine.h.
References engines.
Referenced by MultiThreadNetwork::_addSpikeMessage_(), MultiThreadNetwork::_connect_(), MultiThreadNetwork::_getObject_(), and MTAnalogMessageCreator::addAnalogMessage().
SimObjectPool* MultiThreadSimEngine::getPool | ( | engineid_t | e | ) | [inline] |
Gets a pointer of the sim object pool [used for testing only].
Definition at line 160 of file MultiThreadSimEngine.h.
References engines.
void MultiThreadSimEngine::advanceSeveralStepsWithinACycle | ( | int | steps | ) | [virtual] |
Implements SimEngine.
Definition at line 200 of file MultiThreadSimEngine.cpp.
References _numThreads, advance_jobs, ThreadPool::dispatch(), engines, thr_pool, and ThreadPool::waitAll().
Referenced by advance(), and advanceOneFullCycle().
void MultiThreadSimEngine::finalizeCycle | ( | ) | [virtual] |
Implements SimEngine.
Definition at line 213 of file MultiThreadSimEngine.cpp.
References _numThreads, analogDelayObjects, ThreadPool::dispatch(), mtCycleAdvanceJobs, SpikeScheduler::nextCycle(), SimEngine::spikeScheduler, thr_pool, and ThreadPool::waitAll().
Referenced by advance(), and advanceOneFullCycle().
void MultiThreadSimEngine::advanceOneFullCycle | ( | ) | [virtual] |
Advance all elements for one cycle (equal to minDelay time steps).
Implements SimEngine.
Definition at line 228 of file MultiThreadSimEngine.cpp.
References advanceSeveralStepsWithinACycle(), SimEngine::default_steps_per_cycle, and finalizeCycle().
Referenced by advance().
SingleThreadSimEngine & MultiThreadSimEngine::getSTEngine | ( | engineid_t | eng | ) |
void MultiThreadSimEngine::seed | ( | vector< uint32 > const & | noiseSeed | ) | [virtual] |
Implements SimEngine.
Definition at line 98 of file MultiThreadSimEngine.cpp.
References _numThreads, and engines.
Referenced by MultiThreadNetwork::seed_noise_rng().
void MultiThreadSimEngine::seed | ( | uint32 | noiseSeed | ) | [virtual] |
Implements SimEngine.
Definition at line 91 of file MultiThreadSimEngine.cpp.
References _numThreads, and engines.
void MultiThreadSimEngine::noiseRandEngineOutput | ( | vector< uint32 > & | r | ) | [virtual] |
Reimplemented from SimEngine.
Definition at line 105 of file MultiThreadSimEngine.cpp.
References _numThreads, and engines.
void MultiThreadSimEngine::two_way_link | ( | const SimObject::ID & | id1, | |
const SimObject::ID & | id2 | |||
) | [inline, protected] |
Definition at line 127 of file MultiThreadSimEngine.cpp.
References SimObject::ID::eng, engines, SimObject::incoming(), SimEngine::network, and SimObject::outgoing().
Referenced by insert().
void MultiThreadSimEngine::one_way_link | ( | const SimObject::ID & | id1, | |
const SimObject::ID & | id2 | |||
) | [inline, protected] |
Definition at line 139 of file MultiThreadSimEngine.cpp.
References SimObject::ID::eng, engines, SimObject::incoming(), SimEngine::network, and SimObject::outgoing().
Referenced by mount().
int MultiThreadSimEngine::_numThreads [protected] |
Variable holding the number of Threads the MTengine is using.
Definition at line 184 of file MultiThreadSimEngine.h.
Referenced by advanceSeveralStepsWithinACycle(), finalizeCycle(), initialize(), MultiThreadSimEngine(), noiseRandEngineOutput(), reset(), seed(), and ~MultiThreadSimEngine().
ThreadPool& MultiThreadSimEngine::thr_pool [protected] |
Pool of threads used for advancing the SingleThreadSimEngine-s in separate threads.
Definition at line 187 of file MultiThreadSimEngine.h.
Referenced by advanceSeveralStepsWithinACycle(), finalizeCycle(), initialize(), and reset().
vector<SimEngineAdvanceJob> MultiThreadSimEngine::advance_jobs [protected] |
jobs executed by the threads in the ThreadPool for advancement of Single thread engines.
Definition at line 190 of file MultiThreadSimEngine.h.
Referenced by advanceSeveralStepsWithinACycle(), and MultiThreadSimEngine().
vector<SimEngineResetJob> MultiThreadSimEngine::reset_jobs [protected] |
jobs executed by the threads in the ThreadPool for reset of Single thread engines.
Definition at line 193 of file MultiThreadSimEngine.h.
Referenced by MultiThreadSimEngine(), and reset().
vector<SimEngineInitializeJob> MultiThreadSimEngine::initialize_jobs [protected] |
Definition at line 195 of file MultiThreadSimEngine.h.
Referenced by initialize(), and MultiThreadSimEngine().
vector<SingleThreadSimEngine*> MultiThreadSimEngine::engines [protected] |
Array of single thread sim engines this engine employs for performing the actual simulation.
Definition at line 198 of file MultiThreadSimEngine.h.
Referenced by addObject(), advanceSeveralStepsWithinACycle(), getObject(), getPool(), getSTEngine(), initialize(), MultiThreadSimEngine(), noiseRandEngineOutput(), one_way_link(), reset(), seed(), two_way_link(), and ~MultiThreadSimEngine().
boost::barrier* MultiThreadSimEngine::thr_barrier [protected] |
Definition at line 200 of file MultiThreadSimEngine.h.
Referenced by MultiThreadSimEngine(), and ~MultiThreadSimEngine().
vector< vector<AnalogDelayObject *> > MultiThreadSimEngine::analogDelayObjects [protected] |
Definition at line 202 of file MultiThreadSimEngine.h.
Referenced by addForAdvanceCycle(), finalizeCycle(), and MultiThreadSimEngine().
vector< CycleAdvanceJob > MultiThreadSimEngine::mtCycleAdvanceJobs [protected] |
Definition at line 204 of file MultiThreadSimEngine.h.
Referenced by finalizeCycle(), and MultiThreadSimEngine().
int MultiThreadSimEngine::currentStepWithinCycle [protected] |