Skip to content
Snippets Groups Projects
Commit 471f8468 authored by w.klijn's avatar w.klijn
Browse files

Building code, missing is the sending of the spikes

parent 7a85f92d
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,7 @@
#include <iostream>
#include <vector>
#include <random>
#include <functional>
#include <spike.hpp>
#include <util/double_buffer.hpp>
......@@ -90,8 +91,17 @@ public:
/// Returns a vector of event queues, with one queue for each local cell group. The
/// events in each queue are all events that must be delivered to targets in that cell
/// group as a result of the global spike exchange.
std::vector<event_queue> exchange(const std::vector<spike_type>& local_spikes) {
std::vector<event_queue> exchange(const std::vector<spike_type>& local_spikes,
std::function<void ()> export_function) //const std::vector<spike_type>&
{
// global all-to-all to gather a local copy of the global spike list on each node.
bool file_per_rank = true;
if (file_per_rank) {
export_function(); //local_spikes
}
auto global_spikes = communication_policy_.gather_spikes( local_spikes );
num_spikes_ += global_spikes.size();
......
......@@ -24,6 +24,10 @@ public:
// Does not do the actual export
virtual void add_data(std::vector<spike_type>) = 0;
virtual void add_and_export() = 0;
// Internal state is ok
// Export might encounter problems in a separate thread.
virtual bool ok() const = 0;
......
......@@ -85,6 +85,14 @@ public:
std::begin(spikes), std::end(spikes));
}
// Add and export data to file in a single function
void add_and_export() override //std::vector<spike_type>spikes
{
std::vector<spike_type>spikes;
add_data(spikes);
do_export();
}
// Internal state is ok
// We are working with fstreams possibly on a seperate thread
// We need a way to assertain the status of the stream
......
......@@ -98,6 +98,18 @@ public:
std::begin(spikes), std::end(spikes));
}
// Add and export data to file in a single function
void add_and_export() override
{
std::vector<spike_type>spikes;
if (!communication_policy_.id() == 0) {
return;
}
add_data(spikes);
do_export();
}
// Internal state is ok
// We are working with fstreams possibly on a seperate thread
// We need a way to assertain the status of the stream
......
......@@ -13,6 +13,7 @@
#include <communication/communicator.hpp>
#include <communication/global_policy.hpp>
#include <communication/exporter_interface.hpp>
#include <communication/exporter_spike_single_file.hpp>
#include <profiling/profiler.hpp>
#include "trace_sampler.hpp"
......@@ -70,6 +71,12 @@ public:
}
communicator_.construct();
bool single_file = true;
if (single_file == true) {
exporter_ = nest::mc::util::make_unique<exporter_spike_single_file_type>(
"file_name", "./","gdf");
}
// Allocate an empty queue buffer for each cell group
// These must be set initially to ensure that a queue is available for each
// cell group for the first time step.
......@@ -130,7 +137,8 @@ public:
auto exchange = [&] () {
PE("stepping", "exchange");
auto local_spikes = previous_spikes().gather();
future_events() = communicator_.exchange(local_spikes);
future_events() = communicator_.exchange(local_spikes,
[&] { exporter_->add_and_export(); });
PL(2);
};
......@@ -184,7 +192,9 @@ private:
using local_spike_store_type = thread_private_spike_store<time_type>;
util::double_buffer< local_spike_store_type > local_spikes_;
using exporter_interface_type = nest::mc::communication::exporter_interface<time_type, communicator_type>;
using exporter_interface_type = nest::mc::communication::exporter_interface<time_type, communication::global_policy>;
using exporter_spike_single_file_type = nest::mc::communication::exporter_spike_single_file<time_type, communication::global_policy>;
std::unique_ptr<exporter_interface_type> exporter_;
// Convenience functions that map the spike buffers and event queues onto
// the appropriate integration interval.
......
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