diff --git a/miniapp/io.cpp b/miniapp/io.cpp index 66a8bdecb1b35d1b400b6aec8708b4f649a77be8..d7f328e76e587c3ca506a9928738d0369d4c9e0a 100644 --- a/miniapp/io.cpp +++ b/miniapp/io.cpp @@ -113,9 +113,18 @@ static void update_option(util::optional<T>& opt, const nlohmann::json& j, const cl_options read_options(int argc, char** argv) { // Default options: - const cl_options defopts{1000, 500, "expsyn", 100, 100., 0.025, false, - - false, 1.0, "trace_", util::nothing, + const cl_options defopts{ + 1000, // number of cells + 500, // synapses_per_cell + "expsyn", // synapse type + 100, // compartments_per_segment + 100., // tfinal + 0.025, // dt + false, // all_to_all + false, // probe_soma_only + 1.0, // probe_ratio + "trace_", // trace_prefix + util::nothing, // trace_max_gid // spike_output_parameters: false, // no spike output diff --git a/miniapp/miniapp.cpp b/miniapp/miniapp.cpp index 195bfa55813bc47893e0f022cd0a42cabbe57b4c..f77d96be4c0e0e317d679aca057d7f79e71c0c26 100644 --- a/miniapp/miniapp.cpp +++ b/miniapp/miniapp.cpp @@ -17,7 +17,7 @@ #include <profiling/profiler.hpp> #include <communication/communicator.hpp> #include <communication/global_policy.hpp> -#include <communication/exporter_spike_file.hpp> +#include <io/exporter_spike_file.hpp> #include <util/ioutil.hpp> #include <util/optional.hpp> diff --git a/src/communication/exporter_interface.hpp b/src/communication/exporter_interface.hpp deleted file mode 100644 index 58178a9f5234cc62a5c2f33ca0cdd72129b88093..0000000000000000000000000000000000000000 --- a/src/communication/exporter_interface.hpp +++ /dev/null @@ -1,37 +0,0 @@ -#pragma once - -#include <random> -#include <string> - -#include <common_types.hpp> -#include <spike.hpp> - -namespace nest { -namespace mc { -namespace communication { - -// interface for exporters. -// Exposes one virtual functions: -// do_export(vector<type>) receiving a vector of parameters to export - -template <typename Time, typename CommunicationPolicy> -class exporter_interface { - -public: - using time_type = Time; - using spike_type = spike<cell_member_type, time_type>; - - // Performs the export of the data - virtual void do_export(const std::vector<spike_type>&) = 0; - - // Returns the status of the exporter - virtual bool good() const = 0; - - // Static version of the do_export function for NOP callbacks - static void do_nothing(const std::vector<spike_type>&) - {} -}; - -} //communication -} // namespace mc -} // namespace nest diff --git a/src/communication/exporter_spike_file.hpp b/src/communication/exporter_spike_file.hpp deleted file mode 100644 index cad61fbb7774594d234fd3761c740738f12c7bc6..0000000000000000000000000000000000000000 --- a/src/communication/exporter_spike_file.hpp +++ /dev/null @@ -1,101 +0,0 @@ -#pragma once - -#include <cstring> -#include <cstdio> -#include <fstream> -#include <iomanip> -#include <memory> -#include <random> -#include <stdexcept> -#include <vector> - -#include <common_types.hpp> -#include <communication/exporter_interface.hpp> -#include <spike.hpp> -#include <util.hpp> - -namespace nest { -namespace mc { -namespace communication { - -template <typename Time, typename CommunicationPolicy> -class exporter_spike_file : public exporter_interface<Time, CommunicationPolicy> -{ -public: - using time_type = Time; - using spike_type = spike<cell_member_type, time_type>; - using communication_policy_type = CommunicationPolicy; - - // Constructor - // over_write if true will overwrite the specified output file (default = true) - // output_path relative or absolute path - // file_name will be appended with "_x" with x the rank number - // file_extention a seperator will be added automatically - exporter_spike_file(const std::string& file_name, const std::string& path, - const std::string& file_extention, bool over_write=true) - { - auto file_path = - create_output_file_path(file_name, path, file_extention, - communication_policy_.id()); - - //test if the file exist and depending on over_write throw or delete - if (!over_write && file_exists(file_path)) - { - std::string error_string("Tried opening file for writing but it exists and over_write is false: " - + file_path); - throw std::runtime_error(error_string); - } - - file_handle_.open(file_path); - } - - // Performs the a export of the spikes to file - // one id and spike time with 4 decimals after the comma on a - // line space separated - void do_export(const std::vector<spike_type>& spikes) override - { - for (auto spike : spikes) { - char linebuf[45]; - auto n = std::snprintf(linebuf, sizeof(linebuf), "%u %.4f\n", - spike.source.gid, spike.time); - file_handle_.write(linebuf, n); - } - } - - bool good() const override - { - return file_handle_.good(); - } - - // Creates an indexed filename - static std::string create_output_file_path(const std::string& file_name, - const std::string& path, const std::string& file_extention, - unsigned index) - { - std::string file_path = path + file_name + "_" + - std::to_string(index) + "." + file_extention; - // Nest does not produce the indexing for nrank == 0 - // I have the feeling this disrupts consistent output. Id rather - // always put the zero in. it allows a simpler regex when opening - // files - return file_path; - } - -private: - - bool file_exists(const std::string& file_path) - { - std::ifstream fid(file_path); - return fid.good(); - } - - // Handle to opened file handle - std::ofstream file_handle_; - - communication_policy_type communication_policy_; - -}; - -} //communication -} // namespace mc -} // namespace nest diff --git a/src/model.hpp b/src/model.hpp index 1e98bddf74ff7fe2c55264a05f222082cc8f4edc..9c183d6aa10629ef0a463f35dd689c63b386ab2a 100644 --- a/src/model.hpp +++ b/src/model.hpp @@ -23,7 +23,7 @@ template <typename Cell> class model { public: using cell_group_type = cell_group<Cell>; - using time_type = typename cell_group_type::time_type; + using time_type = typename cell_group_type::time_type; using value_type = typename cell_group_type::value_type; using communicator_type = communication::communicator<time_type, communication::global_policy>; using sampler_function = typename cell_group_type::sampler_function; @@ -179,7 +179,7 @@ public: std::size_t num_groups() const { return cell_groups_.size(); } // register a callback that will perform a export of the global - // spike vector + // spike vector void set_global_spike_callback(std::function<void( const std::vector<spike_type>&)> global_export_callback) { @@ -203,7 +203,7 @@ private: std::vector<cell_group_type> cell_groups_; communicator_type communicator_; std::vector<probe_record> probes_; - + using event_queue_type = typename communicator_type::event_queue; util::double_buffer< std::vector<event_queue_type> > event_queues_; diff --git a/tests/performance/io/disk_io.cpp b/tests/performance/io/disk_io.cpp index 6800176ef27def4cff03810d4be60e34c2c825ec..8cec648594eb58533b4c059a336b621128c974ae 100644 --- a/tests/performance/io/disk_io.cpp +++ b/tests/performance/io/disk_io.cpp @@ -13,7 +13,7 @@ #include <communication/communicator.hpp> #include <communication/global_policy.hpp> -#include <communication/exporter_spike_file.hpp> +#include <io/exporter_spike_file.hpp> #include <profiling/profiler.hpp> using namespace nest::mc; @@ -54,7 +54,7 @@ int main(int argc, char** argv) if (nr_repeats == 0) { std::cout << "disk_io <nrspikes>\n"; - std::cout << " nr_repeats should be a valid integer higher then zero\n"; + std::cout << " nr_repeats should be a valid integer higher then zero\n"; return 1; } @@ -67,7 +67,7 @@ int main(int argc, char** argv) } } - // Create the sut + // Create the sut communication::exporter_spike_file<time_type, global_policy> exporter( "spikes", "./", "gdf", true); @@ -82,7 +82,7 @@ int main(int argc, char** argv) // ********************************************************************* // To have a somewhat realworld data set we calculate from the nr of spikes - // (assuming 20 hz average) the number of nr of 'simulated' neurons, + // (assuming 20 hz average) the number of nr of 'simulated' neurons, // and create idxs using this value. The number of chars in the number // influences the size of the output and thus the speed // Also taken that we have only a single second of simulated time @@ -112,7 +112,7 @@ int main(int argc, char** argv) for (auto idx = 0; idx < nr_repeats; ++idx) { timings.push_back(timings_arr[idx]); } - + // Calculate some statistics auto sum = std::accumulate(timings.begin(), timings.end(), 0.0); @@ -135,7 +135,7 @@ int main(int argc, char** argv) // and output if (simple_stats) { - std::cout << time_total<< "," + std::cout << time_total<< "," << mean << "," << stdev << "," << min << ","