-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Motivation ---------------- So far, multi-compartment cable cells use a variable time step: the user-specified maximum time step $dt$ may be shortened based on incoming events, such as spikes, generators, and (exact) sampling, so that the event delivery is performed exactly at the requested times. All events with time $t_s$ are now delivered at simulation time $t_i = t_0 + i ~dt$ if $t_s \in \left[ t_i , t_i + dt\right).$ Removing exact delivery increases the speed of the simulation due to elimination of small steps, makes the numerics independent of presence of sampling, and also leads to a number of code simplifications. In particular, we have no more need for - integration domains, - event binning, - sampling policies. Main Changes --------------------- The new event delivery logic is mainly implemented in `mc_cell_group::advance` and `fvm_lowered_cell_impl<Backend>::integrate`. Incidental Changes ---------------------------- - `arb_mechanism_ppack` now exposes a scalar time and scalar time step: `t` and `dt` - All cells advance with the same increments, i.e. no separate integration domains - Deliverable events now organized in vector of vector of events. Outermost vector has one element per `mechanism_id`, inner vector has one element per time step interval. - This vector is then used to initialize a `event_stream` for each `shared_state::mech_storage`, while earlier, we had only one `multi_event_stream` per `shared_state`. - Helps with simpler and faster event delivery, and exposes more parallelism on the GPU - GPU `event_stream` is now nearly identical to multi-core implementation (marking etc. is done on CPU) except for optional stable sorting according to `mechanism_index`, which is done in parallel using a `thread_group`. - Less maintenance - `shared_state` gains some responsibility to handle events: `register_events`, `mark_events`, `deliver_events` - Better encapsulation --------- Co-authored-by: bcumming <[email protected]> Co-authored-by: Thorsten Hater <[email protected]>
- Loading branch information
1 parent
ad0b304
commit 2ec4db3
Showing
122 changed files
with
1,995 additions
and
3,154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#pragma once | ||
|
||
#include <type_traits> | ||
#include <vector> | ||
|
||
#include <arbor/generic_event.hpp> | ||
|
||
#include "backends/event.hpp" | ||
#include "backends/event_stream_state.hpp" | ||
|
||
namespace arb { | ||
|
||
template <typename Event, typename Span> | ||
class event_stream_base { | ||
public: // member types | ||
using size_type = std::size_t; | ||
using event_type = Event; | ||
using event_time_type = ::arb::event_time_type<Event>; | ||
using event_data_type = ::arb::event_data_type<Event>; | ||
|
||
protected: // private member types | ||
using span_type = Span; | ||
|
||
static_assert(std::is_same<decltype(std::declval<span_type>().begin()), event_data_type*>::value); | ||
static_assert(std::is_same<decltype(std::declval<span_type>().end()), event_data_type*>::value); | ||
|
||
protected: // members | ||
std::vector<event_data_type> ev_data_; | ||
std::vector<span_type> ev_spans_; | ||
size_type index_ = 0; | ||
|
||
public: | ||
event_stream_base() = default; | ||
|
||
// returns true if the currently marked time step has no events | ||
bool empty() const { | ||
return ev_spans_.empty() || ev_data_.empty() || !index_ || index_ > ev_spans_.size() || | ||
!ev_spans_[index_-1].size(); | ||
} | ||
|
||
void mark() { | ||
index_ += (index_ <= ev_spans_.size() ? 1 : 0); | ||
} | ||
|
||
auto marked_events() { | ||
using std::begin; | ||
using std::end; | ||
if (empty()) { | ||
return make_event_stream_state((event_data_type*)nullptr, (event_data_type*)nullptr); | ||
} else { | ||
return make_event_stream_state(begin(ev_spans_[index_-1]), end(ev_spans_[index_-1])); | ||
} | ||
} | ||
|
||
// clear all previous data | ||
void clear() { | ||
ev_data_.clear(); | ||
ev_spans_.clear(); | ||
index_ = 0; | ||
} | ||
|
||
}; | ||
|
||
} // namespace arb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#pragma once | ||
|
||
#include <arbor/fvm_types.hpp> | ||
|
||
// Pointer representation of event stream marked event state, | ||
// common across CPU and GPU backends. | ||
|
||
namespace arb { | ||
|
||
template <typename EvData> | ||
struct event_stream_state { | ||
using value_type = EvData; | ||
|
||
const value_type* begin_marked; // offset to beginning of marked events | ||
const value_type* end_marked; // offset to one-past-end of marked events | ||
|
||
std::size_t size() const noexcept { | ||
return end_marked - begin_marked; | ||
} | ||
|
||
bool empty() const noexcept { | ||
return (size() == 0u); | ||
} | ||
}; | ||
|
||
template <typename EvData> | ||
inline event_stream_state<EvData> make_event_stream_state(EvData* begin, EvData* end) { | ||
return {begin, end}; | ||
} | ||
|
||
} // namespace arb |
Oops, something went wrong.