From b5cbd9687b1bd635f72dca434e3e92634b21a091 Mon Sep 17 00:00:00 2001 From: Sam Yates <sam@quux.dropbear.id.au> Date: Mon, 1 Aug 2016 21:44:58 +0200 Subject: [PATCH] Tell communicator about connections. Turns out this helps when trying to deliver spikes. --- miniapp/miniapp_recipes.cpp | 2 +- src/cell_group.hpp | 8 ++++---- src/communication/communicator.hpp | 4 ++-- src/model.hpp | 12 +++++++++++- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/miniapp/miniapp_recipes.cpp b/miniapp/miniapp_recipes.cpp index f472f60c..c7aefed2 100644 --- a/miniapp/miniapp_recipes.cpp +++ b/miniapp/miniapp_recipes.cpp @@ -112,7 +112,7 @@ protected: cell_gid_type ncell_; basic_recipe_param param_; probe_distribution pdist_; - static constexpr int basic_cell_segments = 3; + static constexpr int basic_cell_segments = 4; using exp_param = std::exponential_distribution<float>::param_type; exp_param delay_distribution_param; diff --git a/src/cell_group.hpp b/src/cell_group.hpp index 37e97d43..f72d14b2 100644 --- a/src/cell_group.hpp +++ b/src/cell_group.hpp @@ -64,11 +64,11 @@ public: PE("sampling"); while (auto m = sample_events_.pop_if_before(cell_time)) { - auto& sampler = samplers_[m->sampler_index]; - EXPECTS((bool)sampler.sample); + auto& sampler_spec = samplers_[m->sampler_index]; + EXPECTS((bool)sampler_spec.sampler); - index_type probe_index = sampler.probe_id.index; - auto next = sampler.sampler(cell_.time(), cell_.probe(probe_index)); + index_type probe_index = sampler_spec.probe_id.index; + auto next = sampler_spec.sampler(cell_.time(), cell_.probe(probe_index)); if (next) { m->time = std::max(*next, cell_time); sample_events_.push(*m); diff --git a/src/communication/communicator.hpp b/src/communication/communicator.hpp index 8f4e0987..42dfa845 100644 --- a/src/communication/communicator.hpp +++ b/src/communication/communicator.hpp @@ -50,7 +50,7 @@ public: void add_connection(connection con) { - EXPECTS(is_local_target(con.destination())); + EXPECTS(is_local_cell(con.destination().gid)); connections_.push_back(con); } @@ -114,11 +114,11 @@ public: // generate an event for each target for (auto it=targets.first; it!=targets.second; ++it) { auto gidx = it->destination().gid - cell_gid_from_; - events_[gidx].push_back(it->make_event(spike)); } } + //profiler_.leave(); // make events //profiler_.leave(); // event generation diff --git a/src/model.hpp b/src/model.hpp index 83ca1298..252691fd 100644 --- a/src/model.hpp +++ b/src/model.hpp @@ -34,7 +34,7 @@ struct model { cell_groups_ = std::vector<cell_group_type>{cell_to_-cell_from_}; threading::parallel_vector<probe_record> probes; - threading::parallel_for::apply(cell_from_, cell_to_, + threading::parallel_for::apply(cell_from_, cell_to_, [&](cell_gid_type i) { PE("setup", "cells"); auto cell = rec.get_cell(i); @@ -50,9 +50,19 @@ struct model { }); probes_.assign(probes.begin(), probes.end()); + communicator_ = communicator_type(cell_from_, cell_to_); + for (cell_gid_type i=cell_from_; i<cell_to_; ++i) { + for (const auto& cc: rec.connections_on(i)) { + // currently cell_connection and connection are basically the same data; + // merge? + communicator_.add_connection(connection{cc.source, cc.dest, cc.weight, cc.delay}); + } + } + communicator_.construct(); } + void reset() { t_ = 0.; for (auto& group: cell_groups_) { -- GitLab