Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
arbor
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Analyze
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
arbor-sim
arbor
Commits
34cc0166
Commit
34cc0166
authored
8 years ago
by
Benjamin Cumming
Browse files
Options
Downloads
Patches
Plain Diff
add comments for review of PR68
parent
022bc62e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/model.hpp
+8
-2
8 additions, 2 deletions
src/model.hpp
src/util/double_buffer.hpp
+9
-0
9 additions, 0 deletions
src/util/double_buffer.hpp
with
17 additions
and
2 deletions
src/model.hpp
+
8
−
2
View file @
34cc0166
...
...
@@ -84,9 +84,15 @@ public:
}
time_type
run
(
time_type
tfinal
,
time_type
dt
)
{
time_type
min_delay
=
communicator_
.
min_delay
()
/
2
;
// Calculate the size of the largest possible time integration interval
// before communication of spikes is required.
// If spike exchange and cell update are serialized, this is the
// minimum delay of the network, however we use half this period
// to overlap communication and computation.
time_type
t_interval
=
communicator_
.
min_delay
()
/
2
;
while
(
t_
<
tfinal
)
{
auto
tuntil
=
std
::
min
(
t_
+
min_delay
,
tfinal
);
auto
tuntil
=
std
::
min
(
t_
+
t_interval
,
tfinal
);
event_queues_
.
exchange
();
local_spikes_
.
exchange
();
...
...
This diff is collapsed.
Click to expand it.
src/util/double_buffer.hpp
+
9
−
0
View file @
34cc0166
...
...
@@ -9,6 +9,7 @@ namespace nest {
namespace
mc
{
namespace
util
{
/// double buffer with thread safe exchange/flip operation.
template
<
typename
T
>
class
double_buffer
{
private:
...
...
@@ -26,27 +27,35 @@ public:
index_
(
0
)
{}
/// remove the copy and move constructors which won't work with std::atomic
double_buffer
(
double_buffer
&&
)
=
delete
;
double_buffer
(
const
double_buffer
&
)
=
delete
;
double_buffer
&
operator
=
(
const
double_buffer
&
)
=
delete
;
double_buffer
&
operator
=
(
double_buffer
&&
)
=
delete
;
/// flip the buffers in a thread safe manner
/// n calls to exchange will always result in n flips
void
exchange
()
{
// use operator^= which is overloaded by std::atomic<>
index_
^=
1
;
}
/// get the current/front buffer
value_type
&
get
()
{
return
buffers_
[
index_
];
}
/// get the current/front buffer
const
value_type
&
get
()
const
{
return
buffers_
[
index_
];
}
/// get the back buffer
value_type
&
other
()
{
return
buffers_
[
other_index
()];
}
/// get the back buffer
const
value_type
&
other
()
const
{
return
buffers_
[
other_index
()];
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment