Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
nest-streaming-module
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
LuFG VR VIS
VR-Group
In Situ Pipeline
nest-streaming-module
Commits
d3aad4f8
Commit
d3aad4f8
authored
6 years ago
by
Simon Oehrl
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' into feature/#9_Copy_python_scripts_during_building
parents
105f2136
c870ba70
Branches
Branches containing commit
No related tags found
1 merge request
!6
Copy files during build time
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
demos/brunel_simulation/brunel_example.py
+70
-70
70 additions, 70 deletions
demos/brunel_simulation/brunel_example.py
streaming_recording_backend.cpp
+27
-20
27 additions, 20 deletions
streaming_recording_backend.cpp
streaming_recording_backend.h
+7
-0
7 additions, 0 deletions
streaming_recording_backend.h
with
104 additions
and
90 deletions
demos/brunel_simulation/brunel_example.py
+
70
−
70
View file @
d3aad4f8
...
@@ -11,11 +11,10 @@ is not structured spatially.
...
@@ -11,11 +11,10 @@ is not structured spatially.
from
copy
import
deepcopy
from
copy
import
deepcopy
from
math
import
sqrt
from
math
import
sqrt
import
numpy
as
np
import
numpy
as
np
from
mpl_toolkits.mplot3d
import
Axes3D
#
from mpl_toolkits.mplot3d import Axes3D
import
matplotlib.pyplot
as
plt
#
import matplotlib.pyplot as plt
import
nest
import
nest
import
nest.raster_plot
import
nest.topology
as
tp
import
nest.topology
as
tp
...
@@ -23,6 +22,7 @@ class Brunel3D:
...
@@ -23,6 +22,7 @@ class Brunel3D:
def
__init__
(
self
):
def
__init__
(
self
):
self
.
layer_dict
=
{}
self
.
layer_dict
=
{}
nest
.
SetKernelStatus
({
"
local_num_threads
"
:
1
})
nest
.
Install
(
"
streamingmodule
"
)
nest
.
Install
(
"
streamingmodule
"
)
# nest.SetKernelStatus({'print_time': True})
# nest.SetKernelStatus({'print_time': True})
...
@@ -196,70 +196,70 @@ class Brunel3D:
...
@@ -196,70 +196,70 @@ class Brunel3D:
def
simulate
(
self
):
def
simulate
(
self
):
nest
.
Simulate
(
1000
)
nest
.
Simulate
(
1000
)
def
plot_positions
(
self
):
#
def plot_positions(self):
ex_pos
=
self
.
layers
[
0
][
1
][
'
positions
'
]
#
ex_pos = self.layers[0][1]['positions']
in_pos
=
self
.
layers
[
1
][
1
][
'
positions
'
]
#
in_pos = self.layers[1][1]['positions']
fig
=
plt
.
figure
()
#
fig = plt.figure()
ax
=
Axes3D
(
fig
)
#
ax = Axes3D(fig)
for
c
,
m
,
positions
in
[(
'
b
'
,
'
o
'
,
ex_pos
),
(
'
r
'
,
'
^
'
,
in_pos
)]:
#
for c, m, positions in [('b', 'o', ex_pos), ('r', '^', in_pos)]:
ax
.
scatter
([
x
for
x
,
y
,
z
in
positions
],
#
ax.scatter([x for x, y, z in positions],
[
y
for
x
,
y
,
z
in
positions
],
#
[y for x, y, z in positions],
[
z
for
x
,
y
,
z
in
positions
],
#
[z for x, y, z in positions],
c
=
c
,
marker
=
m
)
#
c=c, marker=m)
def
get_results
(
self
):
#
def get_results(self):
mm
=
(
self
.
layer_dict
[
'
Multimeter
'
][
0
]
+
1
,)
#
mm = (self.layer_dict['Multimeter'][0] + 1,)
sd
=
(
self
.
layer_dict
[
'
SpikeDetector
'
][
0
]
+
1
,)
#
sd = (self.layer_dict['SpikeDetector'][0] + 1,)
mm_status
=
nest
.
GetStatus
(
mm
)[
0
]
#
mm_status = nest.GetStatus(mm)[0]
sd_status
=
nest
.
GetStatus
(
sd
)[
0
]
#
sd_status = nest.GetStatus(sd)[0]
nest
.
raster_plot
.
from_device
(
sd
,
hist
=
True
)
#
nest.raster_plot.from_device(sd, hist=True)
senders
=
mm_status
[
'
events
'
][
'
senders
'
]
#
senders = mm_status['events']['senders']
times
=
mm_status
[
'
events
'
][
'
times
'
]
#
times = mm_status['events']['times']
v_m
=
mm_status
[
'
events
'
][
'
V_m
'
]
#
v_m = mm_status['events']['V_m']
v_th
=
mm_status
[
'
events
'
][
'
V_th
'
]
#
v_th = mm_status['events']['V_th']
step
=
int
(
max
(
senders
)
/
100
+
1
)
# Only plot results from some GIDs
#
step = int(max(senders)/100 + 1) # Only plot results from some GIDs
mm_events
=
[]
#
mm_events = []
for
i
in
range
(
1
,
max
(
senders
)
+
1
,
step
):
#
for i in range(1, max(senders) + 1, step):
if
i
in
senders
:
#
if i in senders:
indices
=
np
.
argwhere
(
senders
==
i
)
#
indices = np.argwhere(senders == i)
mm_events
.
append
({
'
GID
'
:
i
,
#
mm_events.append({'GID': i,
'
times
'
:
[
times
[
n
]
for
n
in
indices
],
#
'times': [times[n] for n in indices],
'
V_m
'
:
[
v_m
[
n
]
for
n
in
indices
],
#
'V_m': [v_m[n] for n in indices],
'
V_th
'
:
[
v_th
[
n
]
for
n
in
indices
]})
#
'V_th': [v_th[n] for n in indices]})
return
{
'
multimeter
'
:
mm_events
,
#
return {'multimeter': mm_events,
'
spike_detector
'
:
nest
.
GetStatus
(
sd
)[
0
]}
#
'spike_detector': nest.GetStatus(sd)[0]}
if
__name__
==
'
__main__
'
:
#
if __name__ == '__main__':
nest
.
ResetKernel
()
#
nest.ResetKernel()
print
(
'
Making specifications
'
)
#
print('Making specifications')
brunel
=
Brunel3D
()
#
brunel = Brunel3D()
brunel
.
make_layer_specs
()
#
brunel.make_layer_specs()
brunel
.
make_connection_specs
()
#
brunel.make_connection_specs()
print
(
'
Making layers
'
)
#
print('Making layers')
brunel
.
make_layers
()
#
brunel.make_layers()
nest
.
topology
.
DumpLayerNodes
([
l
[
0
]
for
l
in
brunel
.
layer_dict
.
values
()][:
2
],
#
nest.topology.DumpLayerNodes([l[0] for l in brunel.layer_dict.values()][:2],
'
brunel_nodes.txt
'
)
#
'brunel_nodes.txt')
print
(
'
Making connections
'
)
#
print('Making connections')
brunel
.
make_connections
()
#
brunel.make_connections()
brunel
.
simulate
()
#
brunel.simulate()
print
(
'
Getting results
'
)
#
print('Getting results')
brunel
.
plot_positions
()
#
brunel.plot_positions()
results
=
brunel
.
get_results
()
#
results = brunel.get_results()
for
value
in
[
'
V_m
'
,
'
V_th
'
]:
#
for value in ['V_m', 'V_th']:
plt
.
figure
()
#
plt.figure()
for
n
in
results
[
'
multimeter
'
][::
20
]:
#
for n in results['multimeter'][::20]:
plt
.
plot
(
n
[
'
times
'
],
n
[
value
],
label
=
'
{}
'
.
format
(
n
[
'
GID
'
]))
#
plt.plot(n['times'], n[value], label='{}'.format(n['GID']))
plt
.
legend
()
#
plt.legend()
plt
.
title
(
value
)
#
plt.title(value)
plt
.
show
()
#
plt.show()
This diff is collapsed.
Click to expand it.
streaming_recording_backend.cpp
+
27
−
20
View file @
d3aad4f8
...
@@ -38,6 +38,19 @@ void StreamingRecordingBackend::initialize() {
...
@@ -38,6 +38,19 @@ void StreamingRecordingBackend::initialize() {
std
::
cout
<<
"initialize()"
<<
std
::
endl
;
std
::
cout
<<
"initialize()"
<<
std
::
endl
;
}
}
void
StreamingRecordingBackend
::
prepare
()
{
std
::
cout
<<
"prepare()"
<<
std
::
endl
;
std
::
cout
<<
"Get the number of nodes"
<<
nest
::
kernel
().
node_manager
.
size
()
<<
std
::
endl
;
}
void
StreamingRecordingBackend
::
cleanup
()
{
std
::
cout
<<
"cleanup()"
<<
std
::
endl
;
}
void
StreamingRecordingBackend
::
post_run_cleanup
()
{
std
::
cout
<<
"post_run_cleanup()"
<<
std
::
endl
;
}
void
StreamingRecordingBackend
::
enroll
(
void
StreamingRecordingBackend
::
enroll
(
const
nest
::
RecordingDevice
&
device
,
const
nest
::
RecordingDevice
&
device
,
const
std
::
vector
<
Name
>
&
double_value_names
,
const
std
::
vector
<
Name
>
&
double_value_names
,
...
@@ -80,32 +93,16 @@ void StreamingRecordingBackend::write(const nest::RecordingDevice &device,
...
@@ -80,32 +93,16 @@ void StreamingRecordingBackend::write(const nest::RecordingDevice &device,
const
nest
::
Event
&
event
,
const
nest
::
Event
&
event
,
const
std
::
vector
<
double
>
&
double_values
,
const
std
::
vector
<
double
>
&
double_values
,
const
std
::
vector
<
long
>
&
long_values
)
{
const
std
::
vector
<
long
>
&
long_values
)
{
// Called per thread
// std::lock_guard<std::mutex> lock_guard(write_mutex_);
// std::cout << std::this_thread::get_id() << ' ';
// std::cout << device.get_name() << ' ';
// std::cout << event.get_sender_gid() << ' ';
// std::cout << event.get_stamp() << ' ';
// for (const auto value : double_values) {
// std::cout << value << ' ';
// }
// std::cout << ' ';
// for (const auto value : long_values) {
// std::cout << value << ' ';
// }
// std::cout << std::endl;
const
auto
thread_devices
=
devices_
.
find
(
std
::
this_thread
::
get_id
());
const
auto
thread_devices
=
devices_
.
find
(
std
::
this_thread
::
get_id
());
if
(
thread_devices
==
devices_
.
end
())
{
if
(
thread_devices
==
devices_
.
end
())
{
//
std::c
out
<< "Error: no devices assigned to this thread!" << std::endl;
std
::
c
err
<<
"Error: no devices assigned to this thread!"
<<
std
::
endl
;
return
;
return
;
}
}
const
auto
thread_device
=
thread_devices
->
second
.
find
(
device
.
get_name
());
const
auto
thread_device
=
thread_devices
->
second
.
find
(
device
.
get_name
());
if
(
thread_device
==
thread_devices
->
second
.
end
())
{
if
(
thread_device
==
thread_devices
->
second
.
end
())
{
// std::cout << "Error: device not found in this thread (device = "
std
::
cerr
<<
"Error: device not found in this thread (device = "
// << device.get_name() << ")" << std::endl;
<<
device
.
get_name
()
<<
")"
<<
std
::
endl
;
return
;
return
;
}
}
...
@@ -121,7 +118,13 @@ void StreamingRecordingBackend::write(const nest::RecordingDevice &device,
...
@@ -121,7 +118,13 @@ void StreamingRecordingBackend::write(const nest::RecordingDevice &device,
void
StreamingRecordingBackend
::
synchronize
()
{
void
StreamingRecordingBackend
::
synchronize
()
{
// Called per thread
// Called per thread
for
(
const
auto
&
device
:
devices_
.
at
(
std
::
this_thread
::
get_id
()))
{
const
auto
thread_devices
=
devices_
.
find
(
std
::
this_thread
::
get_id
());
if
(
thread_devices
==
devices_
.
end
())
{
return
;
}
for
(
const
auto
&
device
:
thread_devices
->
second
)
{
{
{
std
::
lock_guard
<
std
::
mutex
>
lock_guard
(
relay_mutex_
);
std
::
lock_guard
<
std
::
mutex
>
lock_guard
(
relay_mutex_
);
relay_
.
Send
(
device
.
second
->
node
(),
false
);
relay_
.
Send
(
device
.
second
->
node
(),
false
);
...
@@ -131,6 +134,10 @@ void StreamingRecordingBackend::synchronize() {
...
@@ -131,6 +134,10 @@ void StreamingRecordingBackend::synchronize() {
}
}
}
}
void
StreamingRecordingBackend
::
clear
(
const
nest
::
RecordingDevice
&
device
)
{
std
::
cout
<<
"clear("
<<
device
.
get_name
()
<<
")"
<<
std
::
endl
;
}
void
StreamingRecordingBackend
::
finalize
()
{
void
StreamingRecordingBackend
::
finalize
()
{
// Called once
// Called once
std
::
cout
<<
"finalize()"
<<
std
::
endl
;
std
::
cout
<<
"finalize()"
<<
std
::
endl
;
...
...
This diff is collapsed.
Click to expand it.
streaming_recording_backend.h
+
7
−
0
View file @
d3aad4f8
...
@@ -27,6 +27,7 @@
...
@@ -27,6 +27,7 @@
#include
<memory>
#include
<memory>
#include
<mutex>
#include
<mutex>
#include
<string>
#include
<string>
#include
<thread>
#include
<vector>
#include
<vector>
#include
"nest_types.h"
#include
"nest_types.h"
...
@@ -49,9 +50,15 @@ class StreamingRecordingBackend : public nest::RecordingBackend {
...
@@ -49,9 +50,15 @@ class StreamingRecordingBackend : public nest::RecordingBackend {
void
initialize
()
override
;
void
initialize
()
override
;
void
prepare
()
override
;
void
cleanup
()
override
;
void
post_run_cleanup
()
override
;
void
finalize
()
override
;
void
finalize
()
override
;
void
synchronize
()
override
;
void
synchronize
()
override
;
void
clear
(
const
nest
::
RecordingDevice
&
)
override
;
void
write
(
const
nest
::
RecordingDevice
&
,
const
nest
::
Event
&
,
void
write
(
const
nest
::
RecordingDevice
&
,
const
nest
::
Event
&
,
const
std
::
vector
<
double
>
&
,
const
std
::
vector
<
long
>
&
)
override
;
const
std
::
vector
<
double
>
&
,
const
std
::
vector
<
long
>
&
)
override
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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