Skip to content
Snippets Groups Projects
Commit 34cc0166 authored by Benjamin Cumming's avatar Benjamin Cumming
Browse files

add comments for review of PR68

parent 022bc62e
No related branches found
No related tags found
No related merge requests found
......@@ -84,9 +84,15 @@ public:
}
time_type run(time_type tfinal, time_type dt) {
time_type min_delay = communicator_.min_delay()/2;
// Calculate the size of the largest possible time integration interval
// before communication of spikes is required.
// If spike exchange and cell update are serialized, this is the
// minimum delay of the network, however we use half this period
// to overlap communication and computation.
time_type t_interval = communicator_.min_delay()/2;
while (t_<tfinal) {
auto tuntil = std::min(t_+min_delay, tfinal);
auto tuntil = std::min(t_+t_interval, tfinal);
event_queues_.exchange();
local_spikes_.exchange();
......
......@@ -9,6 +9,7 @@ namespace nest {
namespace mc {
namespace util {
/// double buffer with thread safe exchange/flip operation.
template <typename T>
class double_buffer {
private:
......@@ -26,27 +27,35 @@ public:
index_(0)
{}
/// remove the copy and move constructors which won't work with std::atomic
double_buffer(double_buffer&&) = delete;
double_buffer(const double_buffer&) = delete;
double_buffer& operator=(const double_buffer&) = delete;
double_buffer& operator=(double_buffer&&) = delete;
/// flip the buffers in a thread safe manner
/// n calls to exchange will always result in n flips
void exchange() {
// use operator^= which is overloaded by std::atomic<>
index_ ^= 1;
}
/// get the current/front buffer
value_type& get() {
return buffers_[index_];
}
/// get the current/front buffer
const value_type& get() const {
return buffers_[index_];
}
/// get the back buffer
value_type& other() {
return buffers_[other_index()];
}
/// get the back buffer
const value_type& other() const {
return buffers_[other_index()];
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment