NEST main@caf0ae8
 
Loading...
Searching...
No Matches
simulation_manager.h
Go to the documentation of this file.
1/*
2 * simulation_manager.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 SIMULATION_MANAGER_H
24#define SIMULATION_MANAGER_H
25
26// C includes:
27#include <sys/time.h>
28
29// C++ includes:
30#include <vector>
31
32// Includes from libnestutil:
33#include "manager_interface.h"
34#include "stopwatch.h"
35
36// Includes from nestkernel:
37#include "cycle_time_log.h"
38#include "nest_time.h"
39#include "nest_types.h"
40
41
42namespace nest
43{
44class Node;
45
47{
48public:
50
51 void initialize( const bool ) override;
52 void finalize( const bool ) override;
53 void set_status( const Dictionary& ) override;
54 void get_status( Dictionary& ) override;
55
61 void assert_valid_simtime( Time const& );
62
68 void prepare() override;
69
77 void run( Time const& );
78
85 void cleanup() override;
86
90 bool use_wfr() const;
91
95 double get_wfr_comm_interval() const;
96
100 double get_wfr_tol() const;
101
105 size_t get_wfr_interpolation_order() const;
106
110 Time const& get_slice_origin() const;
111
115 Time const get_previous_slice_origin() const;
116
123 Time const get_time() const;
124
132 bool has_been_simulated() const;
133
139 bool has_been_prepared() const;
140
145 size_t get_slice() const;
146
148 // TODO: Precisely how defined? Rename!
149 Time const& get_clock() const;
150
154 Time run_duration() const;
155
159 Time run_start_time() const;
160
164 Time run_end_time() const;
165
167 // TODO: rename / precisely how defined?
168 long get_from_step() const;
169
171 // TODO: rename / precisely how defined?
172 long get_to_step() const;
173
175 void update_connection_infrastructure( const size_t tid );
176
180 virtual void reset_timers_for_preparation();
181
185 virtual void reset_timers_for_dynamics();
186
190
191private:
192 void call_update_();
193 void update_();
194 bool wfr_update_( Node* );
195 void advance_time_();
196 void print_progress_();
197
199 long slice_;
200 long to_do_;
203 long to_step_;
205 timeval t_slice_end_;
206 long t_real_;
216 bool use_wfr_;
219 double wfr_tol_;
228
229 // private stop watches for benchmarking purposes
232 // intended for internal core developers, not for use in the public API
239
240#ifdef CYCLE_TIMERS
241 CycleTimeLog cycle_time_log_;
242#endif
243
247};
248
249inline Time const&
251{
252 return clock_;
253}
254
255inline Time const
257{
258 assert( not simulating_ );
259 return clock_ + Time::step( from_step_ );
260}
261
262inline bool
267
268inline bool
273
274inline size_t
276{
277 return slice_;
278}
279
280inline Time const&
282{
283 return clock_;
284}
285
286inline Time
291
292inline Time
294{
295 assert( not simulating_ ); // implicit due to using get_time()
297}
298
299inline Time
301{
302 assert( not simulating_ ); // implicit due to using get_time()
303 return ( get_time().get_steps() + to_do_ ) * Time::get_resolution();
304}
305
306inline long
308{
309 return from_step_;
310}
311
312inline long
314{
315 return to_step_;
316}
317
318inline bool
320{
321 return use_wfr_;
322}
323
324inline double
329
330inline double
332{
333 return wfr_tol_;
334}
335
336inline size_t
341
342inline Time
347
348inline Time
353
354inline bool
359
360}
361
362
363#endif /* #ifndef SIMULATION_MANAGER_H */
Dictionary class for interface to Python and C++ API.
Definition dictionary.h:213
Collect cycle duration and spike-count information for individual update cycles.
Definition cycle_time_log.h:39
Interface for kernel manager classes.
Definition manager_interface.h:46
Base class for all NEST network objects.
Definition node.h:99
Definition simulation_manager.h:47
void update_connection_infrastructure(const size_t tid)
Sorts source table and connections and create new target table.
Definition simulation_manager.cpp:752
Stopwatch< StopwatchGranularity::Detailed, StopwatchParallelism::MasterOnly > sw_gather_spike_data_
Definition simulation_manager.h:233
double wfr_comm_interval_
Desired waveform relaxation communication interval (in ms)
Definition simulation_manager.h:217
Stopwatch< StopwatchGranularity::Normal, StopwatchParallelism::Threaded > sw_communicate_prepare_
Definition simulation_manager.h:231
double update_time_limit_
throw exception if single update cycle takes longer than update_time_limit_ (seconds,...
Definition simulation_manager.h:224
bool simulating_
true if simulation in progress
Definition simulation_manager.h:209
Time get_eprop_update_interval() const
Definition simulation_manager.h:343
bool use_wfr_
Indicates wheter waveform relaxation is used.
Definition simulation_manager.h:216
long get_to_step() const
Return end of current time slice, in steps.
Definition simulation_manager.h:313
timeval t_slice_begin_
Wall-clock time at the begin of a time slice.
Definition simulation_manager.h:204
Time const get_time() const
Precise time of simulation.
Definition simulation_manager.h:256
size_t wfr_interpolation_order_
interpolation order for waveform relaxation method
Definition simulation_manager.h:222
void print_progress_()
TODO: Remove, replace by logging!
Definition simulation_manager.cpp:1228
size_t get_slice() const
Get slice number.
Definition simulation_manager.h:275
Time run_duration() const
Get the simulation duration in the current call to run().
Definition simulation_manager.h:287
void advance_time_()
Update time to next time step.
Definition simulation_manager.cpp:1194
Time const get_previous_slice_origin() const
Get the time at the beginning of the previous time slice.
Definition simulation_manager.cpp:1255
double get_wfr_tol() const
Get the convergence tolerance of the waveform relaxation method.
Definition simulation_manager.h:331
bool has_been_simulated() const
Return true, if the SimulationManager has already been simulated for some time.
Definition simulation_manager.h:263
double wfr_tol_
Convergence tolerance of waveform relaxation method.
Definition simulation_manager.h:219
void update_()
Definition simulation_manager.cpp:844
bool has_been_prepared() const
Return true, if the SimulationManager has been prepared for simulation.
Definition simulation_manager.h:269
Time run_end_time() const
Get the simulation's time at the end of the current call to run().
Definition simulation_manager.h:300
void assert_valid_simtime(Time const &)
Check for errors in time before run.
Definition simulation_manager.cpp:575
SimulationManager()
Definition simulation_manager.cpp:46
virtual void reset_timers_for_dynamics()
Set time measurements for internal profiling to zero (reg.
Definition simulation_manager.cpp:130
Stopwatch< StopwatchGranularity::Detailed, StopwatchParallelism::Threaded > sw_deliver_spike_data_
Definition simulation_manager.h:237
bool get_eprop_reset_neurons_on_update() const
Definition simulation_manager.h:355
long to_do_total_
number of requested steps in current simulation
Definition simulation_manager.h:201
double min_update_time_
shortest update time seen so far (seconds)
Definition simulation_manager.h:226
bool eprop_reset_neurons_on_update_
Definition simulation_manager.h:246
Stopwatch< StopwatchGranularity::Detailed, StopwatchParallelism::Threaded > sw_gather_target_data_
Definition simulation_manager.h:236
bool wfr_update_(Node *)
actually perform simulation
Definition simulation_manager.cpp:838
double eprop_learning_window_
Definition simulation_manager.h:245
virtual void reset_timers_for_preparation()
Set time measurements for internal profiling to zero (reg.
Definition simulation_manager.cpp:123
bool inconsistent_state_
true after exception during update_ simulation must not be resumed
Definition simulation_manager.h:212
Stopwatch< StopwatchGranularity::Normal, StopwatchParallelism::MasterOnly > sw_simulate_
Definition simulation_manager.h:230
Time run_start_time() const
Get the start time of the current call to run().
Definition simulation_manager.h:293
timeval t_slice_end_
Wall-clock time at the end of time slice.
Definition simulation_manager.h:205
double max_update_time_
longest update time seen so far (seconds)
Definition simulation_manager.h:227
long to_step_
update clock_+from_step<=T<clock_+to_step_
Definition simulation_manager.h:203
void finalize(const bool) override
Take down manager after operation.
Definition simulation_manager.cpp:118
double eprop_update_interval_
Definition simulation_manager.h:244
Time clock_
SimulationManager clock, updated once per slice.
Definition simulation_manager.h:198
size_t get_wfr_interpolation_order() const
Get the interpolation order of the waveform relaxation method.
Definition simulation_manager.h:337
void call_update_()
actually run simulation, aka wrap update_
Definition simulation_manager.cpp:696
long t_real_
Accumulated wall-clock time spent simulating (in us)
Definition simulation_manager.h:206
bool print_time_
Indicates whether time should be printed during simulations (or not)
Definition simulation_manager.h:214
long from_step_
update clock_+from_step<=T<clock_+to_step_
Definition simulation_manager.h:202
Time get_eprop_learning_window() const
Definition simulation_manager.h:349
long get_from_step() const
Return start of current time slice, in steps.
Definition simulation_manager.h:307
void set_status(const Dictionary &) override
Set the status of the manager.
Definition simulation_manager.cpp:141
double get_wfr_comm_interval() const
Get the desired communication interval for the waveform relaxation.
Definition simulation_manager.h:325
long slice_
current update slice
Definition simulation_manager.h:199
long to_do_
number of pending steps
Definition simulation_manager.h:200
Time const & get_slice_origin() const
Get the time at the beginning of the current time slice.
Definition simulation_manager.h:250
Stopwatch< StopwatchGranularity::Detailed, StopwatchParallelism::Threaded > sw_update_
Definition simulation_manager.h:235
void initialize(const bool) override
Prepare manager for operation.
Definition simulation_manager.cpp:74
void prepare() override
Initialize simulation for a set of run calls.
Definition simulation_manager.cpp:509
bool use_wfr() const
Returns true if waveform relaxation is used.
Definition simulation_manager.h:319
long wfr_max_iterations_
maximal number of iterations used for waveform relaxation
Definition simulation_manager.h:220
bool prepared_
Indicates whether the SimulationManager is in a prepared state.
Definition simulation_manager.h:207
bool simulated_
indicates whether the SimulationManager has already been simulated for sometime
Definition simulation_manager.h:210
Stopwatch< StopwatchGranularity::Detailed, StopwatchParallelism::MasterOnly > sw_gather_secondary_data_
Definition simulation_manager.h:234
void cleanup() override
Closes a set of runs, doing finalizations such as file closures.
Definition simulation_manager.cpp:676
Time const & get_clock() const
Return current simulation time.
Definition simulation_manager.h:281
Stopwatch< StopwatchGranularity::Detailed, StopwatchParallelism::Threaded > sw_deliver_secondary_data_
Definition simulation_manager.h:238
void run(Time const &)
Run a simulation for another Time.
Definition simulation_manager.cpp:616
void get_status(Dictionary &) override
Retrieve the status of the manager.
Definition simulation_manager.cpp:460
Definition nest_time.h:135
static Time get_resolution()
Definition nest_time.h:325
Namespace for the NEST simulation kernel.
Definition beta_normalization_factor.h:33
Definition nest_time.h:255
Definition nest_time.h:246