Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEATURE: fixed dt #2053

Merged
merged 166 commits into from
Apr 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
166 commits
Select commit Hold shift + click to select a range
515462b
nearly all tests passing
bcumming Mar 25, 2022
df7eae1
mc tests all passing
bcumming Apr 20, 2022
79fc28a
revert changes to ring example
bcumming Apr 20, 2022
8d50cad
merge master
bcumming Apr 20, 2022
a2cf077
update todo
bcumming Apr 30, 2022
30dd0eb
merge master: full working multicore implementation
bcumming May 24, 2022
49b7286
generate gpu mechanisms
bcumming May 24, 2022
812f311
towards gpu implementation
bcumming May 30, 2022
ef92382
wip
bcumming Jun 1, 2022
25f7faa
add cmake checks for non-bundled random123
bcumming Jun 14, 2022
df23b88
improve error messages and fix bug when using bundled random123
bcumming Jun 15, 2022
47a5a93
merge master
bcumming Jun 15, 2022
d40ff73
Merge branch 'fix/random123-without-bundles' into feature/fixed-cable-dt
bcumming Jun 15, 2022
1bf91be
wip towards cuda support for fixed dt
bcumming Jun 16, 2022
89572c6
Merge branch 'master' into feature/fixed-cable-dt
bcumming Jun 21, 2022
6868d12
working gpu implementation
bcumming Jun 27, 2022
f26489a
wip
bcumming Jun 27, 2022
d01c3a8
Merge branch 'master' into busyring
bcumming Jun 27, 2022
6c8b60d
wip
bcumming Jun 27, 2022
a7cf34e
merge and resolve conlficts with diffusion feature
bcumming Jun 28, 2022
a33cc0f
fix performance bug in event delivery
bcumming Jul 1, 2022
b8253f1
wip
bcumming Jul 4, 2022
f50332a
merge master
bcumming Sep 6, 2022
52baa9e
fix last matrix gpu tests
bcumming Sep 6, 2022
b249bb7
Merge remote-tracking branch 'upstream/master' into fixed_dt
boeschf Oct 26, 2022
354339e
Merge remote-tracking branch 'ben/feature/fixed-cable-dt' into fixed_dt
boeschf Oct 26, 2022
acc899c
cleanup
boeschf Oct 26, 2022
5f5e314
Merge remote-tracking branch 'upstream/master' into fixed_dt
boeschf Oct 26, 2022
6642df6
Merge remote-tracking branch 'upstream/master' into fixed_dt
boeschf Oct 27, 2022
84620c5
sde tests pass
boeschf Nov 1, 2022
1e8e2c3
removed include
boeschf Nov 1, 2022
77f4f19
Merge remote-tracking branch 'upstream/master' into fixed_dt
boeschf Nov 22, 2022
50a8bf1
fix test
boeschf Nov 22, 2022
f4519ee
Merge remote-tracking branch 'upstream/master' into fixed_dt
boeschf Nov 22, 2022
9c83346
cleanup
boeschf Nov 23, 2022
faaf10b
cleanup, revert matrix.hpp
boeschf Nov 23, 2022
459b05e
cleanup and removal of functions
boeschf Nov 24, 2022
ac7c2d5
move
boeschf Nov 24, 2022
7e76c3b
simplified
boeschf Nov 24, 2022
d64a0d8
simplified
boeschf Nov 24, 2022
606eaf1
voltage process tests
boeschf Nov 24, 2022
d309213
sde tests
boeschf Nov 24, 2022
aa24945
Merge remote-tracking branch 'upstream/master' into feature/fixed-cab…
boeschf Nov 24, 2022
0030939
macos special
boeschf Nov 24, 2022
45f264c
build busyring
boeschf Nov 24, 2022
1035007
event_map, event_kind, gpu
boeschf Nov 29, 2022
270b866
Merge remote-tracking branch 'upstream/master' into feature/fixed-cab…
boeschf Nov 29, 2022
e1802fd
removed event binning
boeschf Nov 30, 2022
11cbcd3
removed sampling policy
boeschf Nov 30, 2022
4191903
removed comments
boeschf Nov 30, 2022
b77cb83
cleanup
boeschf Nov 30, 2022
3d1893f
revive multi
boeschf Nov 30, 2022
a0cbfac
revive multi gpu
boeschf Nov 30, 2022
bdab15d
cleanup
boeschf Nov 30, 2022
ca3e3f4
gpu event test
boeschf Nov 30, 2022
4227cdb
stable_sort
boeschf Dec 1, 2022
4603132
Merge remote-tracking branch 'upstream/master' into feature/fixed-cab…
boeschf Dec 12, 2022
186057b
updated doc
boeschf Dec 12, 2022
5fa4fa9
Merge remote-tracking branch 'upstream/master' into feature/fixed-cab…
boeschf Dec 13, 2022
9b3414a
Merge remote-tracking branch 'upstream/master' into feature/fixed-cab…
boeschf Dec 20, 2022
bf93c6e
consistent random numbers
boeschf Dec 20, 2022
d3d4369
gpu fix
boeschf Dec 21, 2022
0437cba
Merge remote-tracking branch 'upstream/master' into feature/fixed-cab…
boeschf Dec 21, 2022
2e4e3dd
indentation
boeschf Jan 4, 2023
7367fba
Merge remote-tracking branch 'upstream/master' into feature/fixed-cab…
boeschf Jan 4, 2023
ef9140e
Merge remote-tracking branch 'origin/feature/fixed-cable-dt' into fea…
boeschf Jan 4, 2023
f3c9998
Merge remote-tracking branch 'upstream/master' into feature/fixed-cab…
boeschf Jan 5, 2023
13c2117
Merge remote-tracking branch 'upstream/master' into feature/fixed-cab…
boeschf Jan 5, 2023
a365b9b
more efficient events on gpu
boeschf Jan 10, 2023
3bdec07
epoch
boeschf Jan 12, 2023
1be220d
simpler event_stream
boeschf Jan 14, 2023
14aa1c9
more efficient sorting
boeschf Jan 16, 2023
a641192
bugfix
boeschf Jan 17, 2023
6f7ee56
gpu
boeschf Jan 17, 2023
e4ad676
dedicated stream
boeschf Jan 18, 2023
c7c4903
event stream compression
boeschf Jan 19, 2023
d1bb28c
Re-factor fvm_lowered_cell.
thorstenhater Jan 20, 2023
9c34a15
Add integration_result.
thorstenhater Jan 20, 2023
d7273e5
Fix includes
thorstenhater Jan 20, 2023
5d4e245
Fix epoch setup.
thorstenhater Jan 20, 2023
a554213
Fix GPU memory.
thorstenhater Jan 20, 2023
ae69e3c
API woes begone.
thorstenhater Jan 20, 2023
eb56669
Consistent namings.
thorstenhater Jan 20, 2023
904f804
Make Stack default constructible.
thorstenhater Jan 24, 2023
eb6f8dc
Remove trailing _.
thorstenhater Jan 24, 2023
438e7cf
Extract detector building.
thorstenhater Jan 24, 2023
6625b1d
Shuffle.
thorstenhater Jan 24, 2023
b951ac2
Squash auto-expand.
thorstenhater Jan 24, 2023
60ed556
Polish a bit more.
thorstenhater Jan 24, 2023
ed73a23
Fix the obvious oversights.
thorstenhater Jan 24, 2023
52936b5
Not const!.
thorstenhater Jan 24, 2023
e9063e4
CRTP to the rescue.
thorstenhater Jan 24, 2023
a132d8b
The attachment.
thorstenhater Jan 24, 2023
5c816d6
The Inheritance.
thorstenhater Jan 24, 2023
def840a
The Deduplication.
thorstenhater Jan 24, 2023
7af4763
The Imitation.
thorstenhater Jan 24, 2023
72752d6
The Inclusion.
thorstenhater Jan 24, 2023
042e23a
The Removal.
thorstenhater Jan 24, 2023
a573524
The Removal, part II.
thorstenhater Jan 24, 2023
9861a72
The Solution.
thorstenhater Jan 24, 2023
8cd76f1
The Renaming.
thorstenhater Jan 24, 2023
f69dcb9
The Confusion.
thorstenhater Jan 24, 2023
17d355a
GPU, CPU tests are fine.
thorstenhater Jan 24, 2023
5ca411e
Merge remote-tracking branch 'upstream/master' into feature/fixed-cab…
boeschf Jan 24, 2023
72c0605
Merge branch 'feature/fixed-cable-dt' into feature/fixed-cable-dt-mul…
boeschf Jan 24, 2023
70ec3c5
The Deinfestation.
thorstenhater Jan 24, 2023
c721997
The Reset.
thorstenhater Jan 24, 2023
418f5a1
The Finalisation.
thorstenhater Jan 25, 2023
43dcf80
Clean-up a print statement.
thorstenhater Jan 25, 2023
a712ac0
more efficient copy
boeschf Jan 25, 2023
6c107db
async copy
boeschf Jan 25, 2023
84dde6e
no sort
boeschf Jan 26, 2023
ab75491
gpu copy
boeschf Jan 30, 2023
1d0ba8a
Merge remote-tracking branch 'upstream/master' into feature/fixed-cab…
boeschf Jan 30, 2023
2bc9113
cleanup
boeschf Jan 30, 2023
bc15128
cleanup
boeschf Jan 30, 2023
81a3df0
copy async
boeschf Jan 30, 2023
1d77202
Merge remote-tracking branch 'origin/master' into qa/refactor-fvm-low…
thorstenhater Feb 3, 2023
9969554
Review: re-insert missing line, remove spurious output.
thorstenhater Feb 3, 2023
c499a70
Merge remote-tracking branch 'thorsten/qa/refactor-fvm-lowered' into …
boeschf Feb 6, 2023
d8255d7
Merge remote-tracking branch 'upstream/master' into feature/fixed-cab…
boeschf Feb 6, 2023
82cd19c
Merge branch 'feature/fixed-cable-dt-refactor' into feature/fixed-cab…
boeschf Feb 7, 2023
65c2c18
Merge remote-tracking branch 'thorsten/qa/refactor-fvm-lowered' into …
boeschf Feb 7, 2023
775cd32
Merge remote-tracking branch 'upstream/master' into feature/fixed-cab…
boeschf Feb 7, 2023
29724f7
profiler entries
boeschf Feb 7, 2023
f78e437
kernel launch
boeschf Feb 7, 2023
553849f
Merge remote-tracking branch 'origin/master' into qa/refactor-fvm-low…
thorstenhater Feb 8, 2023
35b741d
Squash erroneous PE/PL.
thorstenhater Feb 8, 2023
6121d33
Add PROFILING to CI so we do not stumble here again.
thorstenhater Feb 8, 2023
8dbaa58
Merge remote-tracking branch 'thorsten/qa/refactor-fvm-lowered' into …
boeschf Feb 8, 2023
53230f4
Merge remote-tracking branch 'upstream/master' into feature/fixed-cab…
boeschf Feb 8, 2023
cd7b5a2
added busyring example to script
boeschf Feb 8, 2023
5be3023
cleanup
boeschf Feb 8, 2023
771bcfd
typo
boeschf Feb 8, 2023
dc5a3d9
gpu launch simplification, device sync after meter checkpoint
boeschf Feb 14, 2023
4757e51
eventsetup with two-pass algo
boeschf Feb 15, 2023
730033f
gpu fix
boeschf Feb 20, 2023
45e5f2e
meter: sync threads
boeschf Feb 20, 2023
195fbdc
more timings, hand-rolled exclusive scan
boeschf Feb 20, 2023
0b6939c
simplifications
boeschf Feb 20, 2023
95b6970
tests
boeschf Feb 21, 2023
01f152e
profiler: eventsetup
boeschf Feb 21, 2023
a6d5499
review: timestep_range
boeschf Feb 21, 2023
5f5c844
review: various small tweaks
boeschf Feb 21, 2023
b08b9d1
in parallel back to the roots
boeschf Feb 23, 2023
3bfc1e2
fixed dt bins
boeschf Mar 6, 2023
5aa8733
fix
boeschf Mar 6, 2023
b9d6677
Merge remote-tracking branch 'upstream/master' into feature/fixed-cab…
boeschf Mar 6, 2023
d8c11e5
removed unnecessary test
boeschf Mar 6, 2023
f2f08ed
Merge remote-tracking branch 'upstream/master' into feature/fixed-cab…
boeschf Mar 6, 2023
00d02db
simplify launch
boeschf Mar 7, 2023
ab77d60
Merge remote-tracking branch 'upstream/master' into feature/fixed-cab…
boeschf Mar 8, 2023
c2f4d0c
Merge remote-tracking branch 'upstream/master' into feature/fixed-cab…
boeschf Mar 13, 2023
5584ecc
check errors when synchronizing device
boeschf Mar 13, 2023
57f0da4
Merge remote-tracking branch 'upstream/master' into feature/fixed-cab…
boeschf Mar 21, 2023
218658a
extended paramters, remove unnecessary files
boeschf Mar 22, 2023
7f065af
fix hwloc bitmap allocation
boeschf Mar 22, 2023
68ed1f4
check
boeschf Mar 22, 2023
045d2ce
Merge branch 'busyring_example' into feature/fixed-cable-dt
boeschf Mar 22, 2023
c90eb43
Merge remote-tracking branch 'upstream/master' into feature/fixed-cab…
boeschf Mar 22, 2023
e85d4b8
busyring: regular generator
boeschf Mar 23, 2023
3a35fe2
adjusted check for changed busyring example
boeschf Mar 24, 2023
d657ad2
busyring paramter
boeschf Mar 24, 2023
f75ad9e
busyring: do not bind threads by default
boeschf Mar 24, 2023
d3e05bf
busyring: explicit generator
boeschf Mar 24, 2023
0c799aa
Merge remote-tracking branch 'upstream/master' into feature/fixed-cab…
boeschf Apr 4, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions arbor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ set(arbor_sources
domain_decomposition.cpp
execution_context.cpp
gpu_context.cpp
event_binner.cpp
fvm_layout.cpp
fvm_lowered_cell_impl.cpp
hardware/memory.cpp
Expand Down Expand Up @@ -76,8 +75,6 @@ if(ARB_WITH_GPU)
backends/gpu/diffusion.cu
backends/gpu/fine.cu
backends/gpu/matrix_solve.cu
backends/gpu/multi_event_stream.cpp
backends/gpu/multi_event_stream.cu
backends/gpu/shared_state.cu
backends/gpu/forest.cpp
backends/gpu/stimulus.cu
Expand Down
35 changes: 15 additions & 20 deletions arbor/backends/event.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#include <arbor/common_types.hpp>
#include <arbor/fvm_types.hpp>
#include <arbor/mechanism_abi.h>
#include <arbor/generic_event.hpp>

// Structures for the representation of event delivery targets and
// staged events.
Expand All @@ -13,11 +15,10 @@ namespace arb {
struct target_handle {
cell_local_size_type mech_id; // mechanism type identifier (per cell group).
cell_local_size_type mech_index; // instance of the mechanism
cell_size_type intdom_index; // which integration domain (acts as index into arrays)

target_handle() = default;
target_handle(cell_local_size_type mech_id, cell_local_size_type mech_index, cell_size_type intdom_index):
mech_id(mech_id), mech_index(mech_index), intdom_index(intdom_index) {}
target_handle(cell_local_size_type mech_id, cell_local_size_type mech_index):
mech_id(mech_id), mech_index(mech_index) {}
};

struct deliverable_event {
Expand All @@ -30,23 +31,23 @@ struct deliverable_event {
time(time), weight(weight), handle(handle) {}
};

template<>
struct has_event_index<deliverable_event> : public std::true_type {};

// Stream index accessor function for multi_event_stream:
inline cell_size_type event_index(const deliverable_event& ev) {
return ev.handle.intdom_index;
inline cell_local_size_type event_index(const arb_deliverable_event_data& ed) {
return ed.mech_index;
}

// Subset of event information required for mechanism delivery.
struct deliverable_event_data {
cell_local_size_type mech_id; // same as target_handle::mech_id
cell_local_size_type mech_index; // same as target_handle::mech_index
float weight;
};

// Delivery data accessor function for multi_event_stream:
inline deliverable_event_data event_data(const deliverable_event& ev) {
return {ev.handle.mech_id, ev.handle.mech_index, ev.weight};
inline arb_deliverable_event_data event_data(const deliverable_event& ev) {
return {ev.handle.mech_index, ev.weight};
}

inline arb_deliverable_event_stream make_event_stream_state(arb_deliverable_event_data* begin,
arb_deliverable_event_data* end) {
return {begin, end};
}

// Sample events (raw values from back-end state).

Expand All @@ -59,17 +60,11 @@ struct raw_probe_info {

struct sample_event {
time_type time;
cell_size_type intdom_index; // which integration domain probe is on
raw_probe_info raw; // event payload: what gets put where on sample
};

inline raw_probe_info event_data(const sample_event& ev) {
return ev.raw;
}

inline cell_size_type event_index(const sample_event& ev) {
return ev.intdom_index;
}


} // namespace arb
85 changes: 34 additions & 51 deletions arbor/backends/event_delivery.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ the lowered cell, and is passed by reference as a parameter to the mechanism

Target handles are used by the lowered cell implementation to identify a particular mechanism
instance that can receive events — ultimately via `net_receive` — and corresponding simulated
cell. The cell information is given as an index into the cell group collection of cells,
and is used to group events by integration domain (we have one domain per cell in each cell
group).
cell. The cell information is given as an index into the cell group collection of cells.

Target handles are represented by the `target_handle` struct, opaque to `mc_cell_group`,
but created in the `fvm_multicell` for each point mechanism (synapse) in the cell group.
Expand All @@ -33,34 +31,38 @@ a `target_handle` describing their destination, and a weight.

### Back-end event streams

`backend::multi_event_stream` represents a set (one per cell/integration domain)
of event streams. There is one `multi_event_stream` per lowered cell.

`backend::multi_event_stream` represents a set of event streams. There is one `multi_event_stream`
per mechanism storage `backend::shared_state::mech_storage`.
From the perspective of the lowered cell, it must support the methods below.
In the following, `time` is a `view` or `const_view` of an array with one
element per stream.

* `void init(const std::vector<deliverable_event>& staged_events)`

Take a copy of the staged events (which must be ordered by increasing event time)
and initialize the streams by gathering the events by cell.
Take a copy of the staged events (which must be partitioned by the event index (a.k.a. the stream
index), and ordered by increasing event time within each partition) and initialize the streams.

* `bool empty() const`

Return true if and only if there are no un-retired events left in any stream.

* `void clear()`
* `size_type n_streams() const`

Retire all events, leaving the `multi_event_stream` in an empty state.
Number of partitions/streams.

* `size_type n_remaining() const`

* `void mark_until_after(const_view time)`
Number of remaining un-retired events among all streams.

* `size_type n_marked() const`

Number of marked events among all streams.

* `void clear()`

For all streams, mark events for delivery in the _i_ th stream with event time ≤ _time[i]_.
Retire all events, leaving the `multi_event_stream` in an empty state.

* `void event_times_if_before(view time) const`
* `void mark_until_after(arb_value_type t_until)`

For each stream, set _time[i]_ to the time of the next event time in the _i_ th stream
if such an event exists and has time less than _time[i]_.
For all streams, mark events for delivery with event time ≤ `t_until`.

* `void drop_marked_events()`

Expand All @@ -72,52 +74,33 @@ element per stream.
Event delivery is performed as part of the integration loop within the lowered
cell implementation. The interface is provided by the `multi_event_stream`
described above, together with the mechanism method that handles the delivery proper,
`mechanism::deliver_events` and a `backend` static method that computes the
integration step end time before considering any pending events.
`mechanism::deliver_events` and `backend` methods
`shared_state::register_events`, `shared_state::mark_events` and `shared_state::deliver_events`.
Events are considered as pending when their event time is within one time step of the current time:
`event_time > time - dt/2 && event_time <= time + dt/2`.

For `fvm_multicell` one integration step comprises:

1. Events for each cell that are due at that cell's corresponding time are
gathered with `events_.mark_events(time_)` where `time_` is a
`const_view` of the cell times and `events_` is a reference to the
`backend::multi_event_stream` object.
gathered with `state_>mark_events(step_midpoint)` where `step_midpoint` is
the current time plus half a time step (upper bound for pending event times). This method, in
turn, calls the `multi_event_stream::mark_until_after(step_midpoint)`.

2. Each mechanism is requested to deliver to itself any marked events that
are associated with that mechanism, via the virtual
`mechanism::apply_events(backend::multi_event_stream&)` method.
are associated with that mechanism, via the
`shared_state::deliver_events(const mechanism&)` method. This method eventually calls the virtual
`mechanism::apply_events(backend::multi_event_stream&)` method and retires the deliverd events
using `multi_event_stream::drop_marked_events`.

This action must precede the computation of mechanism current contributions
with `mechanism::compute_currents()`.

3. Marked events are discarded with `events_.drop_marked_events()`.

4. The upper bound on the integration step stop time `time_to_` is
computed via `backend::update_time_to(time_to_, time_, dt_max_, tfinal_)`,
as the minimum of the per-cell time `time_` plus `dt_max_` and
the final integration stop time `tfinal_`.

5. The integration step stop time `time_to_` is reduced to match any
pending events on each cell with `events_.event_times_if_before(time_to)`.

6. The solver matrix is assembled and solved to compute the voltages, using the
3. The solver matrix is assembled and solved to compute the voltages, using the
newly computed currents and integration step times.

7. The mechanism states are updated with `mechanism::advance_state()`.
4. The mechanism states are updated with `mechanism::advance_state()`.

8. The cell times `time_` are set to the integration step stop times `time_to_`.
5. The cell times `time` are set to the integration step stop times `time_to`.

9. Spike detection for the last integration step is performed via the
6. Spike detection for the last integration step is performed via the
`threshold_watcher_` object.

## Consequences for the integrator

Towards the end of the integration period, an integration step may have a zero _dt_
for one or more cells within the group, and this needs to be handled correctly:

* Generated mechanism `advance_state()` methods should be numerically correct with
zero _dt_; a possibility is to guard the integration step with a _dt_ check.

* Matrix assemble and solve must check for zero _dt_. In the FVM `multicore`
matrix implementation, zero _dt_ sets the diagonal element to zero and the
rhs to the voltage; the solve procedure then ignores cells with a zero
diagonal element.
64 changes: 64 additions & 0 deletions arbor/backends/event_stream_base.hpp
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
31 changes: 31 additions & 0 deletions arbor/backends/event_stream_state.hpp
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;
boeschf marked this conversation as resolved.
Show resolved Hide resolved
}

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
Loading