From d2fd5b26fd086ad8c2cff4fc4d170fbe3aa9e571 Mon Sep 17 00:00:00 2001 From: Sam Yates Date: Thu, 21 Jan 2021 20:07:59 +0100 Subject: [PATCH] Update for Arbor v0.5 (#106) * Modify validation sources for 0.5 decor API. * Replace some tabs with eight spaces in scripts. * Update Arbor branch for download, and in install docs. * Minor comment fix in ring benchmark. * Add #! for install-local.sh and run-bench.sh --- benchmarks/engines/busyring/arbor/ring.cpp | 2 +- docs/install.rst | 2 +- install-local.sh | 24 ++++++++++--------- run-bench.sh | 2 ++ scripts/environment.sh | 4 ++-- .../arbor-cable-steadystate.cpp | 13 +++++----- .../src/arbor-rallpack1/arbor-rallpack1.cpp | 15 ++++++------ .../arbor-rc-exp2syn-spike.cpp | 21 +++++++--------- .../src/arbor-rc-expsyn/arbor-rc-expsyn.cpp | 19 ++++++--------- 9 files changed, 47 insertions(+), 55 deletions(-) diff --git a/benchmarks/engines/busyring/arbor/ring.cpp b/benchmarks/engines/busyring/arbor/ring.cpp index 0474849..d3a0bfa 100644 --- a/benchmarks/engines/busyring/arbor/ring.cpp +++ b/benchmarks/engines/busyring/arbor/ring.cpp @@ -516,7 +516,7 @@ arb::cable_cell branch_cell(arb::cell_gid_type gid, const cell_parameters& param // Add spike threshold detector at the soma. decor.place(arb::mlocation{0,0}, arb::threshold_detector{10}); - // Add a synapse to the mid point of the first dendrite. + // Add a synapse to proximal end of first dendrite. decor.place(arb::mlocation{1, 0}, "expsyn"); // Add additional synapses that will not be connected to anything. diff --git a/docs/install.rst b/docs/install.rst index b5532cd..5e30639 100644 --- a/docs/install.rst +++ b/docs/install.rst @@ -180,7 +180,7 @@ There are Arbor-specific options for checking out Arbor from a Git repository, a Variable Default value Explanation ======================== =========================================== ====================================================== ``ns_arb_git_repo`` ``https://github.com/arbor-sim/arbor.git`` URL or directory for the Git repository to check out Arbor source from. -``ns_arb_branch`` ``v0.2`` The branch/tag/SHA to check out. Master will be used if empty. +``ns_arb_branch`` ``v0.5`` The branch/tag/SHA to check out. Master will be used if empty. ``ns_arb_arch`` ``native`` `The CPU architecture target `_ for Arbor. Must be set when cross compiling. Default ``native`` targets the architecture used to configure NSuite. diff --git a/install-local.sh b/install-local.sh index 6a05ac6..877cbb0 100755 --- a/install-local.sh +++ b/install-local.sh @@ -1,3 +1,5 @@ +#!/usr/bin/env bash + usage() { cat <<'_end_' Usage: install-local.sh [--pyvenv=VENVOPT] [--env=SCRIPT] [--prefix=PATH] TARGET [TARGET...] @@ -64,11 +66,11 @@ do ;; --pyvenv=* ) ns_pyvenv=${1#--pyvenv=} - ;; + ;; --pyvenv ) - shift + shift ns_pyvenv=$1 - ;; + ;; --env=* ) ns_environment=${1#--env=} ;; @@ -175,18 +177,18 @@ if [ "$ns_pyvenv" != disable ]; then msghi "Initializing python virtual environment" ns_pyvenv_opt= if [ "$ns_pyvenv" == inherit ]; then - ns_pyvenv_opt=--system-site-packages + ns_pyvenv_opt=--system-site-packages fi msg "Installing python modules: $ns_pyvenv_modules" ( - exec >> "$ns_build_path/log_pyvenv" 2>&1 - if "$ns_python" -m venv $ns_pyvenv_opt "$ns_pyvenv_path"; then - source "$ns_pyvenv_path/bin/activate" - for pkg in $ns_pyvenv_modules; do - pip install "$pkg" - done - fi + exec >> "$ns_build_path/log_pyvenv" 2>&1 + if "$ns_python" -m venv $ns_pyvenv_opt "$ns_pyvenv_path"; then + source "$ns_pyvenv_path/bin/activate" + for pkg in $ns_pyvenv_modules; do + pip install "$pkg" + done + fi ) fi diff --git a/run-bench.sh b/run-bench.sh index 349d6c6..e701526 100755 --- a/run-bench.sh +++ b/run-bench.sh @@ -1,3 +1,5 @@ +#!/usr/bin/env bash + usage() { cat <<_end_ Usage: run-bench.sh [OPTIONS] SIMULATOR diff --git a/scripts/environment.sh b/scripts/environment.sh index b6ad46b..c92fc63 100644 --- a/scripts/environment.sh +++ b/scripts/environment.sh @@ -67,7 +67,7 @@ default_environment() { # Arbor specific ns_arb_git_repo=https://github.com/arbor-sim/arbor.git - ns_arb_branch=v0.4 + ns_arb_branch=v0.5 ns_arb_arch=native ns_arb_gpu=none @@ -175,7 +175,7 @@ save_environment() { pyvenv_activate=$ns_pyvenv_path/bin/activate source_pyvenv_script= if [ -r "$pyvenv_activate" ]; then - source_pyvenv_script="source '$pyvenv_activate'" + source_pyvenv_script="source '$pyvenv_activate'" fi cat <<_end_ > "$ns_config_path/env_$sim.sh" diff --git a/validation/src/arbor-cable-steadystate/arbor-cable-steadystate.cpp b/validation/src/arbor-cable-steadystate/arbor-cable-steadystate.cpp index 20015ef..d7144ad 100644 --- a/validation/src/arbor-cable-steadystate/arbor-cable-steadystate.cpp +++ b/validation/src/arbor-cable-steadystate/arbor-cable-steadystate.cpp @@ -78,17 +78,16 @@ struct rc_cable_recipe: public arb::recipe { segment_tree tree; tree.append(arb::mnpos, {0., 0., 0., d0/2}, {0., 0., length, d1/2}, 0); - cable_cell c(arb::morphology(tree), {}); - - c.default_parameters.discretization = cv_policy_fixed_per_branch(n); - mechanism_desc pas("pas"); pas["g"] = 1e-4/rm; // [S/cm^2] pas["e"] = 0; // erev=0 - c.paint(reg::all(), pas); - c.place(mlocation{0, 1.}, i_clamp{0, INFINITY, iinj}); - return c; + decor D; + D.paint(reg::all(), pas); + D.place(mlocation{0, 1.}, i_clamp{0, INFINITY, iinj}); + D.set_default(cv_policy_fixed_per_branch(n)); + + return cable_cell(tree, {}, D); } // time constant in [ms] diff --git a/validation/src/arbor-rallpack1/arbor-rallpack1.cpp b/validation/src/arbor-rallpack1/arbor-rallpack1.cpp index 3dc254e..ab35234 100644 --- a/validation/src/arbor-rallpack1/arbor-rallpack1.cpp +++ b/validation/src/arbor-rallpack1/arbor-rallpack1.cpp @@ -71,7 +71,7 @@ struct rc_rallpack1_recipe: public arb::recipe { for (unsigned i = 0; i < num_probes(gid); ++i) { arb::mlocation loc{0, i==0? x0: x1}; probes.push_back(cable_probe_membrane_voltage{loc}); - } + } return probes; } @@ -79,17 +79,16 @@ struct rc_rallpack1_recipe: public arb::recipe { segment_tree tree; tree.append(arb::mnpos, {0., 0., 0., d/2}, {0., 0., length, d/2}, 0); - cable_cell c(arb::morphology(tree), {}); - - c.default_parameters.discretization = cv_policy_fixed_per_branch(n); - mechanism_desc pas("pas"); pas["g"] = 1e-4/rm; // [S/cm^2] pas["e"] = (double)erev; - c.paint(reg::all(), pas); - c.place(mlocation{0, 0}, i_clamp{0, INFINITY, iinj}); - return c; + decor D; + D.paint(reg::all(), pas); + D.place(mlocation{0, 0}, i_clamp{0, INFINITY, iinj}); + D.set_default(cv_policy_fixed_per_branch(n)); + + return cable_cell(tree, {}, D); } }; diff --git a/validation/src/arbor-rc-exp2syn-spike/arbor-rc-exp2syn-spike.cpp b/validation/src/arbor-rc-exp2syn-spike/arbor-rc-exp2syn-spike.cpp index a0fa947..e13c638 100644 --- a/validation/src/arbor-rc-exp2syn-spike/arbor-rc-exp2syn-spike.cpp +++ b/validation/src/arbor-rc-exp2syn-spike/arbor-rc-exp2syn-spike.cpp @@ -49,10 +49,6 @@ struct rc_exp2syn_spike_recipe: public arb::recipe { // Computed values: std::vector delay; // delay[i] is connection delay from gid 0 to gid i - static mlocation soma_centre() { - return {0u, 0.5}; - } - explicit rc_exp2syn_spike_recipe(const paramset& ps): g0(ps.at("g0")), threshold(ps.at("threshold")), mindelay(ps.at("mindelay")), ncell((int)ps.at("ncell")) @@ -88,7 +84,7 @@ struct rc_exp2syn_spike_recipe: public arb::recipe { } std::vector get_probes(cell_gid_type gid) const override { - return {cable_probe_membrane_voltage{soma_centre()}}; + return {cable_probe_membrane_voltage{ls::named("midpoint")}}; } std::vector event_generators(cell_gid_type gid) const override { @@ -117,16 +113,15 @@ struct rc_exp2syn_spike_recipe: public arb::recipe { label_dict labels; labels.set("soma", reg::tagged(1)); - labels.set("centre", soma_centre()); - - cable_cell c(morphology(tree), labels); - c.default_parameters.membrane_capacitance = cm*1e-9/area; // [F/m^2] + labels.set("midpoint", mlocation{0, 0.5}); - c.paint("\"soma\"", pas); - c.place("\"centre\"", exp2syn); - c.place("\"centre\"", threshold_detector{threshold}); + decor D; + D.set_default(membrane_capacitance{cm*1e-9/area}); // [F/m^2] + D.paint("\"soma\"", pas); + D.place("\"midpoint\"", exp2syn); + D.place("\"midpoint\"", threshold_detector{threshold}); - return c; + return cable_cell(tree, labels, D); } std::vector connections_on(cell_gid_type gid) const override { diff --git a/validation/src/arbor-rc-expsyn/arbor-rc-expsyn.cpp b/validation/src/arbor-rc-expsyn/arbor-rc-expsyn.cpp index 116d58a..72573f8 100644 --- a/validation/src/arbor-rc-expsyn/arbor-rc-expsyn.cpp +++ b/validation/src/arbor-rc-expsyn/arbor-rc-expsyn.cpp @@ -39,10 +39,6 @@ struct rc_expsyn_recipe: public arb::recipe { // Customizable parameters: double g0; // synaptic conductance at time 0 [µS] - static mlocation soma_centre() { - return mlocation{0u, 0.5}; - } - explicit rc_expsyn_recipe(const paramset& ps): g0(ps.at("g0")) {} cell_size_type num_cells() const override { return 1; } @@ -63,7 +59,7 @@ struct rc_expsyn_recipe: public arb::recipe { } std::vector get_probes(cell_gid_type gid) const override { - return {cable_probe_membrane_voltage{soma_centre()}}; + return {cable_probe_membrane_voltage{ls::named("midpoint")}}; } std::vector event_generators(cell_gid_type) const override { @@ -89,15 +85,14 @@ struct rc_expsyn_recipe: public arb::recipe { label_dict labels; labels.set("soma", reg::tagged(1)); - labels.set("centre", soma_centre()); - - cable_cell c(morphology(tree), labels); - c.default_parameters.membrane_capacitance = cm*1e-9/area; // [F/m^2] + labels.set("midpoint", mlocation{0, 0.5}); - c.paint("\"soma\"", pas); - c.place("\"centre\"", expsyn); + decor D; + D.set_default(membrane_capacitance{cm*1e-9/area}); // [F/m^2] + D.paint("\"soma\"", pas); + D.place("\"midpoint\"", expsyn); - return c; + return cable_cell(tree, labels, D); } };