NEST main@caf0ae8
 
Loading...
Searching...
No Matches
target_table_devices_impl.h
Go to the documentation of this file.
1/*
2 * target_table_devices_impl.h
3 *
4 * This file is part of NEST.
5 *
6 * Copyright (C) 2004 The NEST Initiative
7 *
8 * NEST is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * NEST is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with NEST. If not, see <http://www.gnu.org/licenses/>.
20 *
21 */
22
23#ifndef TARGET_TABLE_DEVICES_IMPL_H
24#define TARGET_TABLE_DEVICES_IMPL_H
25
26// Includes from nestkernel:
27#include "connector_base.h"
28#include "kernel_manager.h"
29#include "model_manager.h"
30#include "node.h"
32#include "vp_manager_impl.h"
33
34namespace nest
35{
36
37inline void
39 Node& target,
40 const size_t source_node_id,
41 const size_t tid,
42 const synindex syn_id,
43 const Dictionary& p,
44 const double d,
45 const double w )
46{
47 const size_t lid = kernel().vp_manager.node_id_to_lid( source_node_id );
48 assert( lid < target_to_devices_[ tid ].size() );
49 assert( syn_id < target_to_devices_[ tid ][ lid ].size() );
50
51 kernel()
53 .add_connection( source, target, target_to_devices_[ tid ][ lid ], syn_id, p, d, w );
54}
55
56inline void
58 Node& target,
59 const size_t tid,
60 const synindex syn_id,
61 const Dictionary& p,
62 const double d,
63 const double w )
64{
65 const size_t ldid = source.get_local_device_id();
66 assert( ldid != invalid_index );
67 assert( ldid < target_from_devices_[ tid ].size() );
68 assert( syn_id < target_from_devices_[ tid ][ ldid ].size() );
69
70 kernel()
72 .add_connection( source, target, target_from_devices_[ tid ][ ldid ], syn_id, p, d, w );
73
74 // store node ID of sending device
75 sending_devices_node_ids_[ tid ][ ldid ] = source.get_node_id();
76}
77
78inline void
80 const size_t source_node_id,
81 Event& e,
82 const std::vector< ConnectorModel* >& cm )
83{
84 const size_t lid = kernel().vp_manager.node_id_to_lid( source_node_id );
85 for ( std::vector< ConnectorBase* >::iterator it = target_to_devices_[ tid ][ lid ].begin();
86 it != target_to_devices_[ tid ][ lid ].end();
87 ++it )
88 {
89 if ( *it )
90 {
91 ( *it )->send_to_all( tid, cm, e );
92 }
93 }
94}
95
96inline void
98 const size_t source_node_id,
100 const std::vector< ConnectorModel* >& cm )
101{
102 const size_t lid = kernel().vp_manager.node_id_to_lid( source_node_id );
103 for ( auto& synid : e.get_supported_syn_ids() )
104 {
105 if ( target_to_devices_[ tid ][ lid ][ synid ] )
106 {
107 target_to_devices_[ tid ][ lid ][ synid ]->send_to_all( tid, cm, e );
108 }
109 }
110}
111
112inline void
114 const size_t source_node_id,
115 const synindex syn_id,
116 Dictionary& dict,
117 const size_t lcid ) const
118{
119 const size_t lid = kernel().vp_manager.node_id_to_lid( source_node_id );
120 if ( target_to_devices_[ tid ][ lid ][ syn_id ] )
121 {
122 target_to_devices_[ tid ][ lid ][ syn_id ]->get_synapse_status( tid, lcid, dict );
123 }
124}
125
126inline void
128 const size_t source_node_id,
129 const synindex syn_id,
130 ConnectorModel& cm,
131 const Dictionary& dict,
132 const size_t lcid )
133{
134 const size_t lid = kernel().vp_manager.node_id_to_lid( source_node_id );
135 if ( target_to_devices_[ tid ][ lid ][ syn_id ] )
136 {
137 target_to_devices_[ tid ][ lid ][ syn_id ]->set_synapse_status( lcid, dict, cm );
138 }
139}
140
141} // namespace nest
142
143#endif /* TARGET_TABLE_DEVICES_IMPL_H */
Dictionary class for interface to Python and C++ API.
Definition dictionary.h:213
Definition connector_model.h:69
virtual void add_connection(Node &src, Node &tgt, std::vector< ConnectorBase * > &hetconn, const synindex syn_id, const Dictionary &d, const double delay=NAN, const double weight=NAN)=0
Adds a connection.
Encapsulate information sent between nodes.
Definition event.h:103
ConnectorModel & get_connection_model(synindex syn_id, size_t thread_id)
Return pointer to protoype for given synapse id.
Definition model_manager.h:295
Base class for all NEST network objects.
Definition node.h:99
Base class of secondary events.
Definition secondary_event.h:50
void set_synapse_status_to_device(const size_t tid, const size_t source_node_id, const synindex syn_id, ConnectorModel &cm, const Dictionary &dict, const size_t lcid)
Sets synapse status of connection from neuron to device.
Definition target_table_devices_impl.h:127
void add_connection_to_device(Node &source, Node &target, const size_t s_node_id, const size_t tid, const synindex syn_id, const Dictionary &p, const double d, const double w)
Adds a connection from the neuron source to the device target.
Definition target_table_devices_impl.h:38
void send_to_device(const size_t tid, const size_t s_node_id, Event &e, const std::vector< ConnectorModel * > &cm)
Sends a spike event to all targets of the source neuron.
Definition target_table_devices_impl.h:79
void get_synapse_status_to_device(const size_t tid, const size_t source_node_id, const synindex syn_id, Dictionary &dict, const size_t lcid) const
Returns synapse status of connection from neuron to device.
Definition target_table_devices_impl.h:113
std::vector< std::vector< std::vector< ConnectorBase * > > > target_to_devices_
3d structure storing connections from neurons to devices
Definition target_table_devices.h:54
void add_connection_from_device(Node &source, Node &target, const size_t tid, const synindex syn_id, const Dictionary &p, const double d, const double w)
Adds a connection from the device source to the neuron target.
Definition target_table_devices_impl.h:57
std::vector< std::vector< size_t > > sending_devices_node_ids_
3d structure storing node IDs of sending devices (necessary for get_connections)
Definition target_table_devices.h:61
std::vector< std::vector< std::vector< ConnectorBase * > > > target_from_devices_
3d structure storing connections from devices to neurons
Definition target_table_devices.h:57
size_t node_id_to_lid(const size_t node_id) const
Returns thread local index of a given global node.
Definition vp_manager_impl.h:79
ModelManager model_manager
Definition kernel_manager.h:243
VPManager vp_manager
Definition kernel_manager.h:234
Namespace for the NEST simulation kernel.
Definition beta_normalization_factor.h:33
KernelManager & kernel()
Definition kernel_manager.h:311
size_t synindex
For enumerations of synapse types.
Definition nest_types.h:115
Declarations for base class Node.