#include <MultiThreadNetwork.h>
Public Member Functions | |
MultiThreadNetwork (int nThreads, SimParameter sp=SimParameter::Default) | |
Constructor. | |
MultiThreadNetwork (int nThreads, MPI::Intracomm &comm, SimParameter sp=SimParameter::Default) | |
virtual | ~MultiThreadNetwork () |
Adding objects | |
virtual void | _addObject_ (const SimObjectFactory &objFactory, const SimEngine::ID &loc, SimObject::ID &gid) |
The simulation object is added to the network. | |
virtual void | _addObject_ (const SimObjectFactory &objFactory, SimObject::ID &gid) |
One instance of a simulation object is created and added to the network using the current distribution strategy. The SimObject::ID is returned. | |
Messages | |
virtual void | _addSpikeMessage_ (const SimObject::ID &sender, const port_t out, const SimObject::ID &receiver, const port_t in, const Time &delay) |
Set up a spike message channel with delay in simulation time steps. | |
virtual void | _addAnalogMessage_ (const SimObject::ID &sender, int sender_port, const SimObject::ID &receiver, int recv_port, const Time &delay) |
Setup an analog message channel with delay in simulation time steps. | |
virtual void | _addAnalogMessage_ (const SimObject::ID &sender, int sender_port, const SimObject::ID &receiver, string destfield, const Time &delay) |
virtual void | _addAnalogMessage_ (const SimObject::ID &sender, string srcfield, const SimObject::ID &receiver, int recv_port, const Time &delay) |
virtual void | _addAnalogMessage_ (const SimObject::ID &sender, string srcfield, const SimObject::ID &receiver, string destfield, const Time &delay) |
Converting between local and global engine IDs | |
virtual gl_engineid_t | maxLocalEngineID (void) const |
Return the largest local simulation engine ID at the executing node. | |
Protected Member Functions | |
virtual void | _reset_ () |
Resets the simulation to time = 0. | |
virtual void | _advance_ (int nSteps=1) |
Advances the simulation of the network for a specified number of simulation timesteps. | |
virtual void | _initialize_ () |
Initializes the network for simulation. To be invoked after construction, and before simulation. | |
virtual void | _mount_ (const SimObjectFactory &objFactory, const SimObject::ID &mountpoint, SimObject::ID &gid) |
One instance of a simulation object is "mounted" to the mount simulation object. | |
virtual void | _insert_ (const SimObjectFactory &objFactory, const SimObject::ID &container, SimObject::ID &gid) |
One instance of a simulation object is "inserted" into the container simulation object. The SimObject::ID of the newly created object is returned. | |
virtual void | _connect_ (SimObject::ID const &src, port_t out, const SimObject::ID &dst, port_t in, int delay) |
Make a connection (i.e. spike or analog message) from the src-out port to the dest-in port. | |
virtual SimObject * | _getObject_ (const SimObject::ID &id) |
Get a pointer to a sim object stored in the network. | |
template<typename srcType, typename destType> | |
int | addGenericAnalogMessage (const SimObject::ID &sender, srcType senderPortOrField, const SimObject::ID &receiver, destType recvPortOrField, delay_t delay) |
Adds a spiking connection pathway between two SimObjects, usualy some Neuron and a Synapse. | |
virtual void | seed_noise_rng (uint32 noise_seed) |
Static Protected Member Functions | |
static void | addLocalSpikeMessage (MTSpikeRoutingTables *arg_tables, SimEngine *arg_simEngine, const SimParameter &SP, const SimObject::ID &sender, spike_port_id_t sender_port, const SimObject::ID &receiver, const port_t in_port, step_t delay) |
Protected Attributes | |
int | nThreads |
Number of threads the network utilizes to perform simulation. | |
MTSpikeRoutingTables * | tables |
Tables used for spike routing in the multi-threaded spike exchange case. | |
ThreadPool | thrPool |
ThreadPool holding thread objects used in multi-thread processing. | |
vector< PropagatedSpikeBuffer * > | STBuffers |
Array of Propagated spike buffers, one for each SingleThreadSimEngine. | |
MultiThreadSpikeScheduler * | spikeScheduler |
Spike scheduler used for scheduling the spikes to appropriate propagated spike buffers. | |
MultiThreadSimEngine * | simEngine |
Engine which runs the simulation in multiple threads, advances sim objects and controls the spike scheduler. | |
vector < MultiThreadAnalogMsgDispatcher * > | analogMsgDispatchers |
vector< STAnalogMessageCreator * > | stAnalogMsgCreators |
MTAnalogMessageCreator * | mtAnalogMsgCreator |
AnalogDelayObjectMap * | analogDelayObjectsMap |
Friends | |
class | DistributedSingleThreadNetwork |
class | DistributedMultiThreadNetwork |
Used for setup and running simulations on one multi-processor machine (single-node multi-thread scenario). Contains interfaces for construction of the network, i.e. adding SimObject objects (neurons, synapses, etc.) and connecting them, and also used for simulation control.
Definition at line 32 of file MultiThreadNetwork.h.
MultiThreadNetwork::MultiThreadNetwork | ( | int | nThreads, | |
SimParameter | sp = SimParameter::Default | |||
) |
Constructor.
Constructs a multi-thread (DMT) network object on the local node with specified number of threads.
nThreads | number of threads the local node uses (on each machine different number of threads may be specified) | |
simPar | is a reference to a SimParameter structur |
Definition at line 15 of file MultiThreadNetwork.cpp.
MultiThreadNetwork::MultiThreadNetwork | ( | int | nThreads, | |
MPI::Intracomm & | comm, | |||
SimParameter | sp = SimParameter::Default | |||
) |
Definition at line 22 of file MultiThreadNetwork.cpp.
MultiThreadNetwork::~MultiThreadNetwork | ( | ) | [virtual] |
Definition at line 80 of file MultiThreadNetwork.cpp.
References analogDelayObjectsMap, analogMsgDispatchers, mtAnalogMsgCreator, simEngine, spikeScheduler, stAnalogMsgCreators, STBuffers, and tables.
void MultiThreadNetwork::_addObject_ | ( | const SimObjectFactory & | objFactory, | |
const SimEngine::ID & | loc, | |||
SimObject::ID & | gid | |||
) | [virtual] |
The simulation object is added to the network.
The object is added to the list of advancable objects of the network. The network takes over the ownership of the object, i.e. the network will free the memory occupied by the object if necessary.
obj | pointer to the SimObject simulation object to be added. | |
eng | Specifies the (local) simulation engine to which the object should be added. | |
id | Resulting identifier of the added object. All four elements (node,engine,type,localid) of the identifier are determined by the network itself during addition. One instance of a simulation object is created by the factory and added at specified simulation engine of the network. | |
loc | Specifies the node and local engine where the object should be added to. loc.node is ignored! | |
id | The resulting unique identifier (node,engine,type,localid) of the created object. |
Reimplemented from SimNetwork.
Definition at line 104 of file MultiThreadNetwork.cpp.
References SimNetwork::_mpi_rank, MultiThreadSimEngine::addObject(), SimEngine::ID::engine, SimObject::ID::Invalid, SimEngine::ID::node, and simEngine.
void MultiThreadNetwork::_addObject_ | ( | const SimObjectFactory & | objFactory, | |
SimObject::ID & | gid | |||
) | [virtual] |
One instance of a simulation object is created and added to the network using the current distribution strategy. The SimObject::ID is returned.
Reimplemented from SimNetwork.
Definition at line 129 of file MultiThreadNetwork.cpp.
References SimNetwork::addObject().
void MultiThreadNetwork::_addSpikeMessage_ | ( | const SimObject::ID & | sender, | |
const port_t | out, | |||
const SimObject::ID & | receiver, | |||
const port_t | in, | |||
const Time & | delay | |||
) | [virtual] |
Set up a spike message channel with delay in simulation time steps.
Each spike of the sender is sent to the given port of receiver (after delay simuation steps)
Reimplemented from SimNetwork.
Definition at line 223 of file MultiThreadNetwork.cpp.
References SimNetwork::_nSpikeMessages, addLocalSpikeMessage(), SimObject::ID::eng, SimNetwork::get_dt(), MultiThreadSimEngine::getObject(), SpikeSender::getSpikePort(), SpikeOutputPort::ID(), Time::in_ms(), Time::in_steps(), SimParameter::maxDelay, SimParameter::minDelay, simEngine, SimNetwork::simParam, tables, and SimObject::ID::toString().
void MultiThreadNetwork::_addAnalogMessage_ | ( | const SimObject::ID & | sender, | |
int | sender_port, | |||
const SimObject::ID & | receiver, | |||
int | recv_port, | |||
const Time & | delay | |||
) | [virtual] |
Setup an analog message channel with delay in simulation time steps.
Reimplemented from SimNetwork.
Definition at line 271 of file MultiThreadNetwork.cpp.
References SimNetwork::_nAnalogMessages, addGenericAnalogMessage(), SimNetwork::get_dt(), and Time::in_steps().
void MultiThreadNetwork::_addAnalogMessage_ | ( | const SimObject::ID & | sender, | |
int | sender_port, | |||
const SimObject::ID & | receiver, | |||
string | destfield, | |||
const Time & | delay | |||
) | [virtual] |
Reimplemented from SimNetwork.
Definition at line 277 of file MultiThreadNetwork.cpp.
References SimNetwork::_nAnalogMessages, addGenericAnalogMessage(), SimNetwork::get_dt(), and Time::in_steps().
void MultiThreadNetwork::_addAnalogMessage_ | ( | const SimObject::ID & | sender, | |
string | srcfield, | |||
const SimObject::ID & | receiver, | |||
int | recv_port, | |||
const Time & | delay | |||
) | [virtual] |
Reimplemented from SimNetwork.
Definition at line 283 of file MultiThreadNetwork.cpp.
References SimNetwork::_nAnalogMessages, addGenericAnalogMessage(), SimNetwork::get_dt(), and Time::in_steps().
void MultiThreadNetwork::_addAnalogMessage_ | ( | const SimObject::ID & | sender, | |
string | srcfield, | |||
const SimObject::ID & | receiver, | |||
string | destfield, | |||
const Time & | delay | |||
) | [virtual] |
Reimplemented from SimNetwork.
Definition at line 289 of file MultiThreadNetwork.cpp.
References SimNetwork::_nAnalogMessages, addGenericAnalogMessage(), SimNetwork::get_dt(), and Time::in_steps().
gl_engineid_t MultiThreadNetwork::maxLocalEngineID | ( | void | ) | const [virtual] |
Return the largest local simulation engine ID at the executing node.
Reimplemented from SimNetwork.
Definition at line 297 of file MultiThreadNetwork.cpp.
void MultiThreadNetwork::_reset_ | ( | ) | [protected, virtual] |
Resets the simulation to time = 0.
Discardes the pending spikes and reinitalizes the states of the sim objects.
Reimplemented from SimNetwork.
Definition at line 319 of file MultiThreadNetwork.cpp.
References analogMsgDispatchers, SimNetwork::get_dt(), SimNetwork::initialize(), MultiThreadSimEngine::reset(), MultiThreadSpikeScheduler::reset(), SimNetwork::reseted, simEngine, and spikeScheduler.
void MultiThreadNetwork::_advance_ | ( | int | nSteps = 1 |
) | [protected, virtual] |
Advances the simulation of the network for a specified number of simulation timesteps.
Advancing continues from exactly where the simulation from the previous advance() invocation stopped. reset() should be used to restart the simulation of the network from time = 0.
nSteps | number of timesteps the simulation is advanced. |
Reimplemented from SimNetwork.
Definition at line 331 of file MultiThreadNetwork.cpp.
References MultiThreadSimEngine::advance(), SimNetwork::reset(), SimNetwork::reseted, and simEngine.
void MultiThreadNetwork::_initialize_ | ( | ) | [protected, virtual] |
Initializes the network for simulation. To be invoked after construction, and before simulation.
Reimplemented from SimNetwork.
Definition at line 304 of file MultiThreadNetwork.cpp.
References analogMsgDispatchers, SimParameter::dt, Time::in_steps(), MultiThreadSimEngine::initialize(), SimParameter::minDelay, simEngine, and SimNetwork::simParam.
void MultiThreadNetwork::addLocalSpikeMessage | ( | MTSpikeRoutingTables * | arg_tables, | |
SimEngine * | arg_simEngine, | |||
const SimParameter & | SP, | |||
const SimObject::ID & | sender, | |||
spike_port_id_t | sender_port, | |||
const SimObject::ID & | receiver, | |||
const port_t | in_port, | |||
step_t | delay | |||
) | [static, protected] |
Definition at line 247 of file MultiThreadNetwork.cpp.
References SingleThreadNetwork::addLocalSpikeMessage(), SpikeTargetGroupPool::addSpikeTarget(), SimParameter::dt, SimObject::ID::eng, NodeLocalMultiTargetDelayMap::find(), SimEngine::getObject(), Time::in_ms(), Time::in_steps(), NodeLocalMultiTargetDelayMap::insert(), MTSpikeRoutingTables::localDelayMaps, SimParameter::minDelay, MTSpikeRoutingTables::mTDelayMap, no_spikegroup, and MTSpikeRoutingTables::stgPool.
Referenced by _addSpikeMessage_(), and DistributedMultiThreadNetwork::_addSpikeMessage_().
void MultiThreadNetwork::_mount_ | ( | const SimObjectFactory & | objFactory, | |
const SimObject::ID & | mountpoint, | |||
SimObject::ID & | gid | |||
) | [protected, virtual] |
One instance of a simulation object is "mounted" to the mount simulation object.
Reimplemented from SimNetwork.
Definition at line 136 of file MultiThreadNetwork.cpp.
References SimNetwork::_mpi_rank, SimObject::ID::eng, SimObject::ID::Invalid, MultiThreadSimEngine::mount(), SimObject::ID::node, and simEngine.
void MultiThreadNetwork::_insert_ | ( | const SimObjectFactory & | objFactory, | |
const SimObject::ID & | container, | |||
SimObject::ID & | gid | |||
) | [protected, virtual] |
One instance of a simulation object is "inserted" into the container simulation object. The SimObject::ID of the newly created object is returned.
Reimplemented from SimNetwork.
Definition at line 161 of file MultiThreadNetwork.cpp.
References SimNetwork::_mpi_rank, SimObject::ID::eng, MultiThreadSimEngine::insert(), SimObject::ID::Invalid, SimObject::ID::node, and simEngine.
void MultiThreadNetwork::_connect_ | ( | SimObject::ID const & | src, | |
port_t | out, | |||
const SimObject::ID & | dst, | |||
port_t | in, | |||
int | delay | |||
) | [protected, virtual] |
Make a connection (i.e. spike or analog message) from the src-out port to the dest-in port.
Reimplemented from SimNetwork.
Definition at line 194 of file MultiThreadNetwork.cpp.
References SimNetwork::addAnalogMessage(), SimNetwork::addSpikeMessage(), SimObject::analog, SimNetwork::get_dt(), SimObject::getManagedDelay(), MultiThreadSimEngine::getObject(), SimObject::inputPortType(), SimObject::outputPortType(), Time::sec(), simEngine, SimObject::spiking, Time::steps(), and SimObject::ID::toString().
SimObject * MultiThreadNetwork::_getObject_ | ( | const SimObject::ID & | id | ) | [protected, virtual] |
Get a pointer to a sim object stored in the network.
Objects are uniquely identified in the network by their identifier (node, engine, localid) and their type. Sim objects with different types can have the same identifier, so also the type must be specified.
otype | the type of the object to be retrieved. | |
id | Identifier of the object to be retrieved. |
Reimplemented from SimNetwork.
Definition at line 187 of file MultiThreadNetwork.cpp.
References MultiThreadSimEngine::getObject(), and simEngine.
int MultiThreadNetwork::addGenericAnalogMessage | ( | const SimObject::ID & | sender, | |
srcType | senderPortOrField, | |||
const SimObject::ID & | receiver, | |||
destType | recvPortOrField, | |||
delay_t | delay | |||
) | [inline, protected] |
Adds a spiking connection pathway between two SimObjects, usualy some Neuron and a Synapse.
Connects the output of a SimObject of Spiking <> type to another SimObject capable of receiving spiking inputs. The spiking pathway can also introduce some delay to the signal.
void addIntraNodeSpikeMessage( engineid_t sender_eng, spike_port_id_t sender_port, step_t delay, object_type_t recv_type, engineid_t rec_engine, local_objectid_t rec_oid, int port );
sender_eng id of the engine where sender belongs. sender_port id of the spike port which emmits the spike delay delay of the spiking connection. recv_type Type of the receiving object. rec_engine id of the engine where receiver object belongs. rec_oid local identifier of the receiver sim object. input port where the spikes arrive in the receiver (The receiver can have many input ports).
Definition at line 199 of file MultiThreadNetwork.h.
References MTAnalogMessageCreator::addAnalogMessage(), SimParameter::dt, SimObject::ID::eng, Time::in_ms(), Time::in_steps(), SimParameter::maxDelay, SimParameter::minDelay, mtAnalogMsgCreator, SimNetwork::simParam, and stAnalogMsgCreators.
Referenced by _addAnalogMessage_().
void MultiThreadNetwork::seed_noise_rng | ( | uint32 | noise_seed | ) | [protected, virtual] |
Reimplemented from SimNetwork.
Definition at line 94 of file MultiThreadNetwork.cpp.
References SimParameter::constructionRNGSeed, SimNetwork::fillSeedVector(), SimNetwork::makeSeed(), SimNetwork::objectVariationRNDEngine, RandomEngine::seed(), MultiThreadSimEngine::seed(), simEngine, and SimNetwork::simParam.
friend class DistributedSingleThreadNetwork [friend] |
Definition at line 116 of file MultiThreadNetwork.h.
friend class DistributedMultiThreadNetwork [friend] |
Definition at line 117 of file MultiThreadNetwork.h.
int MultiThreadNetwork::nThreads [protected] |
Number of threads the network utilizes to perform simulation.
Definition at line 229 of file MultiThreadNetwork.h.
MTSpikeRoutingTables* MultiThreadNetwork::tables [protected] |
Tables used for spike routing in the multi-threaded spike exchange case.
Definition at line 232 of file MultiThreadNetwork.h.
Referenced by _addSpikeMessage_(), and ~MultiThreadNetwork().
ThreadPool MultiThreadNetwork::thrPool [protected] |
ThreadPool holding thread objects used in multi-thread processing.
Definition at line 235 of file MultiThreadNetwork.h.
vector<PropagatedSpikeBuffer*> MultiThreadNetwork::STBuffers [protected] |
Array of Propagated spike buffers, one for each SingleThreadSimEngine.
Definition at line 238 of file MultiThreadNetwork.h.
Referenced by ~MultiThreadNetwork().
Spike scheduler used for scheduling the spikes to appropriate propagated spike buffers.
Definition at line 241 of file MultiThreadNetwork.h.
Referenced by _reset_(), and ~MultiThreadNetwork().
MultiThreadSimEngine* MultiThreadNetwork::simEngine [protected] |
Engine which runs the simulation in multiple threads, advances sim objects and controls the spike scheduler.
Uses multiple SingleThreadSimEngine objects for advancing the sim objects, each running concurrently in a separate thread.
Definition at line 247 of file MultiThreadNetwork.h.
Referenced by _addObject_(), _addSpikeMessage_(), _advance_(), _connect_(), _getObject_(), _initialize_(), _insert_(), _mount_(), _reset_(), seed_noise_rng(), and ~MultiThreadNetwork().
vector<MultiThreadAnalogMsgDispatcher*> MultiThreadNetwork::analogMsgDispatchers [protected] |
Definition at line 249 of file MultiThreadNetwork.h.
Referenced by _initialize_(), _reset_(), and ~MultiThreadNetwork().
vector< STAnalogMessageCreator *> MultiThreadNetwork::stAnalogMsgCreators [protected] |
Definition at line 251 of file MultiThreadNetwork.h.
Referenced by addGenericAnalogMessage(), and ~MultiThreadNetwork().
Definition at line 253 of file MultiThreadNetwork.h.
Referenced by addGenericAnalogMessage(), and ~MultiThreadNetwork().