NEST main@caf0ae8
 
Loading...
Searching...
No Matches
target_table_devices.h
Go to the documentation of this file.
1/*
2 * target_table_devices.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_H
24#define TARGET_TABLE_DEVICES_H
25
26// C++ includes:
27#include <cassert>
28#include <map>
29#include <vector>
30
31// Includes from nestkernel:
32#include "connection_id.h"
33#include "connector_base.h"
34#include "event.h"
35#include "nest_types.h"
36
37
38namespace nest
39{
40class Node;
41class ConnectorModel;
42
51{
52private:
54 std::vector< std::vector< std::vector< ConnectorBase* > > > target_to_devices_;
55
57 std::vector< std::vector< std::vector< ConnectorBase* > > > target_from_devices_;
58
61 std::vector< std::vector< size_t > > sending_devices_node_ids_;
62
63public:
66
70 void initialize();
71
75 void finalize();
76
80 void add_connection_to_device( Node& source,
81 Node& target,
82 const size_t s_node_id,
83 const size_t tid,
84 const synindex syn_id,
85 const Dictionary& p,
86 const double d,
87 const double w );
88
92 void add_connection_from_device( Node& source,
93 Node& target,
94 const size_t tid,
95 const synindex syn_id,
96 const Dictionary& p,
97 const double d,
98 const double w );
99
103 void send_to_device( const size_t tid, const size_t s_node_id, Event& e, const std::vector< ConnectorModel* >& cm );
104 void send_to_device( const size_t tid,
105 const size_t s_node_id,
107 const std::vector< ConnectorModel* >& cm );
108
112 void send_from_device( const size_t tid, const size_t ldid, Event& e, const std::vector< ConnectorModel* >& cm );
113
118
123
127 void get_connections_to_devices_( const size_t requested_source_node_id,
128 const size_t requested_target_node_id,
129 const size_t tid,
130 const synindex synapse_id,
131 const long synapse_label,
132 std::deque< ConnectionID >& conns ) const;
133
137 void get_connections_to_device_for_lid_( const size_t lid,
138 const size_t requested_target_node_id,
139 const size_t tid,
140 const synindex syn_id,
141 const long synapse_label,
142 std::deque< ConnectionID >& conns ) const;
143
147 void get_connections_from_devices_( const size_t requested_source_node_id,
148 const size_t requested_target_node_id,
149 const size_t tid,
150 const synindex synapse_id,
151 const long synapse_label,
152 std::deque< ConnectionID >& conns ) const;
153
157 void get_connections( const size_t requested_source_node_id,
158 const size_t requested_target_node_id,
159 const size_t tid,
160 const synindex synapse_id,
161 const long synapse_label,
162 std::deque< ConnectionID >& conns ) const;
163
167 void get_synapse_status_to_device( const size_t tid,
168 const size_t source_node_id,
169 const synindex syn_id,
170 Dictionary& dict,
171 const size_t lcid ) const;
172
176 void get_synapse_status_from_device( const size_t tid,
177 const size_t ldid,
178 const synindex syn_id,
179 Dictionary& dict,
180 const size_t lcid ) const;
181
185 void set_synapse_status_to_device( const size_t tid,
186 const size_t source_node_id,
187 const synindex syn_id,
188 ConnectorModel& cm,
189 const Dictionary& dict,
190 const size_t lcid );
191
195 void set_synapse_status_from_device( const size_t tid,
196 const size_t ldid,
197 const synindex syn_id,
198 ConnectorModel& cm,
199 const Dictionary& dict,
200 const size_t lcid );
201
205 bool is_device_connected( size_t tid, size_t lcid ) const;
206};
207
208inline void
210 const size_t ldid,
211 const synindex syn_id,
212 Dictionary& dict,
213 const size_t lcid ) const
214{
215 target_from_devices_[ tid ][ ldid ][ syn_id ]->get_synapse_status( tid, lcid, dict );
216}
217
218inline void
220 const size_t ldid,
221 const synindex syn_id,
222 ConnectorModel& cm,
223 const Dictionary& dict,
224 const size_t lcid )
225{
226 target_from_devices_[ tid ][ ldid ][ syn_id ]->set_synapse_status( lcid, dict, cm );
227}
228
229inline void
231 const size_t ldid,
232 Event& e,
233 const std::vector< ConnectorModel* >& cm )
234{
235 for ( std::vector< ConnectorBase* >::iterator it = target_from_devices_[ tid ][ ldid ].begin();
236 it != target_from_devices_[ tid ][ ldid ].end();
237 ++it )
238 {
239 if ( *it )
240 {
241 ( *it )->send_to_all( tid, cm, e );
242 }
243 }
244}
245
246inline bool
247TargetTableDevices::is_device_connected( const size_t tid, const size_t lcid ) const
248{
249 for ( auto& synapse : target_from_devices_[ tid ][ lcid ] )
250 {
251 if ( synapse )
252 {
253 std::deque< ConnectionID > conns;
254 synapse->get_all_connections( lcid, 0, tid, UNLABELED_CONNECTION, conns );
255 if ( not conns.empty() )
256 {
257 return true;
258 }
259 }
260 }
261 return false;
262}
263
264} // namespace nest
265
266#endif
Dictionary class for interface to Python and C++ API.
Definition dictionary.h:213
Definition connector_model.h:69
Encapsulate information sent between nodes.
Definition event.h:103
Base class for all NEST network objects.
Definition node.h:99
Base class of secondary events.
Definition secondary_event.h:50
This data structure stores the connections between local neurons and devices.
Definition target_table_devices.h:51
TargetTableDevices()
Definition target_table_devices.cpp:32
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 set_synapse_status_from_device(const size_t tid, const size_t ldid, const synindex syn_id, ConnectorModel &cm, const Dictionary &dict, const size_t lcid)
Sets synapse status of connection from device to neuron.
Definition target_table_devices.h:219
~TargetTableDevices()
Definition target_table_devices.cpp:36
void get_connections_to_device_for_lid_(const size_t lid, const size_t requested_target_node_id, const size_t tid, const synindex syn_id, const long synapse_label, std::deque< ConnectionID > &conns) const
Returns all connections from particular neuron to devices.
Definition target_table_devices.cpp:136
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 get_connections_to_devices_(const size_t requested_source_node_id, const size_t requested_target_node_id, const size_t tid, const synindex synapse_id, const long synapse_label, std::deque< ConnectionID > &conns) const
Returns all connections from neurons to devices.
Definition target_table_devices.cpp:110
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
void get_synapse_status_from_device(const size_t tid, const size_t ldid, const synindex syn_id, Dictionary &dict, const size_t lcid) const
Returns synapse status of connection from device to neuron.
Definition target_table_devices.h:209
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 resize_to_number_of_neurons()
Resizes vectors according to number of local nodes.
Definition target_table_devices.cpp:80
void get_connections(const size_t requested_source_node_id, const size_t requested_target_node_id, const size_t tid, const synindex synapse_id, const long synapse_label, std::deque< ConnectionID > &conns) const
Returns all connections between neurons and devices.
Definition target_table_devices.cpp:187
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
void initialize()
Initialize data structures.
Definition target_table_devices.cpp:41
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
void get_connections_from_devices_(const size_t requested_source_node_id, const size_t requested_target_node_id, const size_t tid, const synindex synapse_id, const long synapse_label, std::deque< ConnectionID > &conns) const
Returns all connections from devices to neurons.
Definition target_table_devices.cpp:156
bool is_device_connected(size_t tid, size_t lcid) const
Checks if the device has any connections in this thread.
Definition target_table_devices.h:247
void resize_to_number_of_synapse_types()
Resizes vectors according to number of available synapse types.
Definition target_table_devices.cpp:92
void send_from_device(const size_t tid, const size_t ldid, Event &e, const std::vector< ConnectorModel * > &cm)
Sends a spike event to all targets of the source device.
Definition target_table_devices.h:230
std::vector< std::vector< std::vector< ConnectorBase * > > > target_from_devices_
3d structure storing connections from devices to neurons
Definition target_table_devices.h:57
void finalize()
Delete data structure.
Definition target_table_devices.cpp:50
Namespace for the NEST simulation kernel.
Definition beta_normalization_factor.h:33
static const long UNLABELED_CONNECTION
Connections are unlabeled by default.
Definition connection_label.h:38
size_t synindex
For enumerations of synapse types.
Definition nest_types.h:115