From d85a0c16dbe83867ea0b6432ea5e401ee66b80d2 Mon Sep 17 00:00:00 2001 From: "w.klijn" <nonoice@gmail.com> Date: Tue, 9 Aug 2016 13:23:49 +0200 Subject: [PATCH] Working implemenation, works for both single and multi file output in the miniapp --- src/communication/communicator.hpp | 4 ++-- src/communication/exporter_interface.hpp | 2 +- src/communication/exporter_spike_file.hpp | 4 ++-- src/communication/exporter_spike_single_file.hpp | 3 +-- src/model.hpp | 7 ++++--- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/communication/communicator.hpp b/src/communication/communicator.hpp index 4480f4d7..e59e15f5 100644 --- a/src/communication/communicator.hpp +++ b/src/communication/communicator.hpp @@ -92,14 +92,14 @@ public: /// 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::function<void (std::vector<spike_type>)> export_function) //const std::vector<spike_type>& + std::function<void (const std::vector<spike_type>&)> 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 + export_function(local_spikes); //local_spikes } diff --git a/src/communication/exporter_interface.hpp b/src/communication/exporter_interface.hpp index 579577e3..3fb101a7 100644 --- a/src/communication/exporter_interface.hpp +++ b/src/communication/exporter_interface.hpp @@ -25,7 +25,7 @@ public: virtual void add_data(std::vector<spike_type>) = 0; - virtual void add_and_export() = 0; + virtual void add_and_export(const std::vector<spike_type>&) = 0; // Internal state is ok diff --git a/src/communication/exporter_spike_file.hpp b/src/communication/exporter_spike_file.hpp index 8c313851..580efa56 100644 --- a/src/communication/exporter_spike_file.hpp +++ b/src/communication/exporter_spike_file.hpp @@ -86,9 +86,9 @@ public: } // Add and export data to file in a single function - void add_and_export() override //std::vector<spike_type>spikes + void add_and_export(const std::vector<spike_type>& spikes) override //std::vector<spike_type>spikes { - std::vector<spike_type>spikes; + add_data(spikes); do_export(); } diff --git a/src/communication/exporter_spike_single_file.hpp b/src/communication/exporter_spike_single_file.hpp index c3eaa287..b22d77c0 100644 --- a/src/communication/exporter_spike_single_file.hpp +++ b/src/communication/exporter_spike_single_file.hpp @@ -99,9 +99,8 @@ public: } // Add and export data to file in a single function - void add_and_export() override + void add_and_export(const std::vector<spike_type>& spikes) override { - std::vector<spike_type>spikes; if (!communication_policy_.id() == 0) { return; } diff --git a/src/model.hpp b/src/model.hpp index 02b7b370..f7e22d28 100644 --- a/src/model.hpp +++ b/src/model.hpp @@ -14,6 +14,7 @@ #include <communication/global_policy.hpp> #include <communication/exporter_interface.hpp> #include <communication/exporter_spike_single_file.hpp> +#include <communication/exporter_spike_file.hpp> #include <profiling/profiler.hpp> #include "trace_sampler.hpp" @@ -138,11 +139,11 @@ public: PE("stepping", "exchange"); auto local_spikes = previous_spikes().gather(); future_events() = communicator_.exchange(local_spikes, -// [&] { exporter_->add_and_export(std::vector<spike_type> spikes); }); - [&] { exporter_->add_and_export(std::vector<spike_type> spikes); }); + [&] (const std::vector<spike_type>& spikes){ exporter_->add_and_export(spikes); }); PL(2); }; + // run the tasks, overlapping if the threading model and number of // available threads permits it. threading::task_group g; @@ -194,7 +195,7 @@ private: util::double_buffer< local_spike_store_type > local_spikes_; 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>; + using exporter_spike_single_file_type = nest::mc::communication::exporter_spike_file<time_type, communication::global_policy>; std::unique_ptr<exporter_interface_type> exporter_; // Convenience functions that map the spike buffers and event queues onto -- GitLab