MultiThreadSimEngine Class Reference

Simulation Engine for a multi-thread simulation. More...

#include <MultiThreadSimEngine.h>

Inheritance diagram for MultiThreadSimEngine:

Inheritance graph
[legend]
Collaboration diagram for MultiThreadSimEngine:

Collaboration graph
[legend]

List of all members.

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 SimObjectgetObject (const SimObject::ID &id)
 Gets a pointer of a previously stored sim object in the simulation engine.
SimObjectPoolgetPool (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).
SingleThreadSimEnginegetSTEngine (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.
ThreadPoolthr_pool
 Pool of threads used for advancing the SingleThreadSimEngine-s in separate threads.
vector< SimEngineAdvanceJobadvance_jobs
 jobs executed by the threads in the ThreadPool for advancement of Single thread engines.
vector< SimEngineResetJobreset_jobs
 jobs executed by the threads in the ThreadPool for reset of Single thread engines.
vector< SimEngineInitializeJobinitialize_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< CycleAdvanceJobmtCycleAdvanceJobs
int currentStepWithinCycle


Detailed Description

Simulation Engine for a multi-thread simulation.

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.

See also:
SingleThreadSimEngine

Definition at line 103 of file MultiThreadSimEngine.h.


Constructor & Destructor Documentation

MultiThreadSimEngine::MultiThreadSimEngine ( int  ID,
int  numThreads,
ThreadPool thrPool,
SpikeScheduler scheduler,
AnalogMessageDispatcherVector analogMsgDispatchers,
SimNetwork net 
)

Constructs a MultiThreadSimEngine.

Parameters:
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.

Here is the call graph for this function:

MultiThreadSimEngine::~MultiThreadSimEngine (  )  [virtual]

Definition at line 83 of file MultiThreadSimEngine.cpp.

References _numThreads, engines, and thr_barrier.


Member Function Documentation

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_().

Here is the call graph for this function:

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_().

Here is the call graph for this function:

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_().

Here is the call graph for this function:

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().

Here is the call graph for this function:

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_().

Here is the call graph for this function:

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_().

Here is the call graph for this function:

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().

Here is the call graph for this function:

void MultiThreadSimEngine::finalizeCycle (  )  [virtual]

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().

Here is the call graph for this function:

SingleThreadSimEngine & MultiThreadSimEngine::getSTEngine ( engineid_t  eng  ) 

Definition at line 234 of file MultiThreadSimEngine.cpp.

References engines.

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().

Here is the call graph for this function:

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().

Here is the call graph for this function:


Member Data Documentation

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().

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().

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().

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().

Definition at line 195 of file MultiThreadSimEngine.h.

Referenced by initialize(), and MultiThreadSimEngine().

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().

Definition at line 202 of file MultiThreadSimEngine.h.

Referenced by addForAdvanceCycle(), finalizeCycle(), and MultiThreadSimEngine().

Definition at line 204 of file MultiThreadSimEngine.h.

Referenced by finalizeCycle(), and MultiThreadSimEngine().

Definition at line 206 of file MultiThreadSimEngine.h.

Referenced by advance(), and reset().


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

Generated on Wed Jul 9 16:34:52 2008 for PCSIM by  doxygen 1.5.5