From 994e9169a37261b0ac6b58cae20a1a1b99d4886d Mon Sep 17 00:00:00 2001 From: Sam Yates <halfflat@gmail.com> Date: Thu, 4 Aug 2016 12:32:44 +0200 Subject: [PATCH] Rename catypes.hpp, clarify cell_member_type use. --- miniapp/miniapp.cpp | 2 +- miniapp/trace_sampler.hpp | 2 +- src/CMakeLists.txt | 2 +- src/cell.hpp | 2 +- src/cell_group.hpp | 12 +++++++--- src/cell_tree.hpp | 2 +- src/{catypes.hpp => common_types.hpp} | 25 ++++++++++++++++---- src/{catypes_io.cpp => common_types_io.cpp} | 2 +- src/communication/mpi_global_policy.hpp | 2 +- src/compartment.hpp | 2 +- src/connection.hpp | 2 +- src/event_queue.hpp | 2 +- src/model.hpp | 2 +- src/segment.hpp | 2 +- tests/unit/test_cell_group.cpp | 2 +- tests/unit/test_fvm.cpp | 2 +- tests/unit/test_probe.cpp | 2 +- tests/validation/validate_ball_and_stick.cpp | 2 +- tests/validation/validate_soma.cpp | 2 +- tests/validation/validate_synapses.cpp | 2 +- 20 files changed, 48 insertions(+), 25 deletions(-) rename src/{catypes.hpp => common_types.hpp} (57%) rename src/{catypes_io.cpp => common_types_io.cpp} (83%) diff --git a/miniapp/miniapp.cpp b/miniapp/miniapp.cpp index 00adf7e5..898e478c 100644 --- a/miniapp/miniapp.cpp +++ b/miniapp/miniapp.cpp @@ -6,7 +6,7 @@ #include <json/src/json.hpp> -#include <catypes.hpp> +#include <common_types.hpp> #include <cell.hpp> #include <cell_group.hpp> #include <fvm_cell.hpp> diff --git a/miniapp/trace_sampler.hpp b/miniapp/trace_sampler.hpp index 96ad269a..1e20bea2 100644 --- a/miniapp/trace_sampler.hpp +++ b/miniapp/trace_sampler.hpp @@ -3,7 +3,7 @@ #include <cstdlib> #include <vector> -#include <catypes.hpp> +#include <common_types.hpp> #include <cell.hpp> #include <util/optional.hpp> diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6b6de968..8e0db887 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -2,7 +2,7 @@ set(HEADERS swcio.hpp ) set(BASE_SOURCES - catypes_io.cpp + common_types_io.cpp cell.cpp parameter_list.cpp profiling/profiler.cpp diff --git a/src/cell.hpp b/src/cell.hpp index effdf925..74654928 100644 --- a/src/cell.hpp +++ b/src/cell.hpp @@ -5,7 +5,7 @@ #include <thread> #include <vector> -#include "catypes.hpp" +#include "common_types.hpp" #include "cell_tree.hpp" #include "segment.hpp" #include "stimulus.hpp" diff --git a/src/cell_group.hpp b/src/cell_group.hpp index 0143ce83..e70d4b0b 100644 --- a/src/cell_group.hpp +++ b/src/cell_group.hpp @@ -4,8 +4,8 @@ #include <functional> #include <vector> -#include <catypes.hpp> #include <cell.hpp> +#include <common_types.hpp> #include <event_queue.hpp> #include <spike.hpp> #include <spike_source.hpp> @@ -40,12 +40,18 @@ public: { initialize_cells(); - source_id_type source_id={gid_base_,0}; + // Create spike detectors and associate them with globally unique source ids, + // as specified by cell gid and cell-local zero-based index. + + cell_gid_type source_gid = gid_base_; + cell_lid_type source_lid = 0u; + for (auto& d : c.detectors()) { + cell_member_type source_id{source_gid, source_lid++}; + spike_sources_.push_back({ source_id, spike_detector_type(cell_, d.location, d.threshold, 0.f) }); - ++source_id.index; } } diff --git a/src/cell_tree.hpp b/src/cell_tree.hpp index 3bbcb3ef..ce06d69a 100644 --- a/src/cell_tree.hpp +++ b/src/cell_tree.hpp @@ -11,7 +11,7 @@ #include <vector/include/Vector.hpp> -#include "catypes.hpp" +#include "common_types.hpp" #include "tree.hpp" #include "util.hpp" diff --git a/src/catypes.hpp b/src/common_types.hpp similarity index 57% rename from src/catypes.hpp rename to src/common_types.hpp index e2e9799b..da81ed5d 100644 --- a/src/catypes.hpp +++ b/src/common_types.hpp @@ -13,18 +13,35 @@ namespace nest { namespace mc { -// for identifying cells globally +// For identifying cells globally. + using cell_gid_type = std::uint32_t; -// for sizes of collections of cells +// For sizes of collections of cells. + using cell_size_type = typename std::make_unsigned<cell_gid_type>::type; -// for indexes into cell-local data +// For indexes into cell-local data. +// +// Local indices for items within a particular cell-local collection should be +// zero-based and numbered contiguously. + using cell_lid_type = std::uint32_t; -// for counts of cell-local data +// For counts of cell-local data. + using cell_local_size_type = typename std::make_unsigned<cell_lid_type>::type; +// For global identification of an item of cell local data. +// +// Items of cell_member_type must: +// +// * be associated with a unique cell, identified by the member `gid` +// (see: cell_gid_type); +// +// * identify an item within a cell-local collection by the member `index` +// (see: cell_lid_type). + struct cell_member_type { cell_gid_type gid; cell_lid_type index; diff --git a/src/catypes_io.cpp b/src/common_types_io.cpp similarity index 83% rename from src/catypes_io.cpp rename to src/common_types_io.cpp index 4c9d185f..ad6ca540 100644 --- a/src/catypes_io.cpp +++ b/src/common_types_io.cpp @@ -1,6 +1,6 @@ #include <iostream> -#include <catypes.hpp> +#include <common_types.hpp> std::ostream& operator<<(std::ostream& O, nest::mc::cell_member_type m) { return O << m.gid << ':' << m.index; diff --git a/src/communication/mpi_global_policy.hpp b/src/communication/mpi_global_policy.hpp index 54ded32c..0e9ec333 100644 --- a/src/communication/mpi_global_policy.hpp +++ b/src/communication/mpi_global_policy.hpp @@ -9,7 +9,7 @@ #include <vector> #include <algorithms.hpp> -#include <catypes.hpp> +#include <common_types.hpp> #include <communication/mpi.hpp> #include <spike.hpp> diff --git a/src/compartment.hpp b/src/compartment.hpp index c69f622f..da6bbcf5 100644 --- a/src/compartment.hpp +++ b/src/compartment.hpp @@ -3,7 +3,7 @@ #include <iterator> #include <utility> -#include "catypes.hpp" +#include "common_types.hpp" namespace nest { namespace mc { diff --git a/src/connection.hpp b/src/connection.hpp index 3ef99a9c..b9e40fb5 100644 --- a/src/connection.hpp +++ b/src/connection.hpp @@ -2,7 +2,7 @@ #include <cstdint> -#include <catypes.hpp> +#include <common_types.hpp> #include <event_queue.hpp> #include <spike.hpp> diff --git a/src/event_queue.hpp b/src/event_queue.hpp index b78cc0ca..31f6a5a1 100644 --- a/src/event_queue.hpp +++ b/src/event_queue.hpp @@ -4,7 +4,7 @@ #include <ostream> #include <queue> -#include "catypes.hpp" +#include "common_types.hpp" #include "util/optional.hpp" namespace nest { diff --git a/src/model.hpp b/src/model.hpp index e819ff8b..3b773823 100644 --- a/src/model.hpp +++ b/src/model.hpp @@ -1,7 +1,7 @@ #include <cstdlib> #include <vector> -#include <catypes.hpp> +#include <common_types.hpp> #include <cell.hpp> #include <cell_group.hpp> #include <communication/communicator.hpp> diff --git a/src/segment.hpp b/src/segment.hpp index a7600da9..248306a6 100644 --- a/src/segment.hpp +++ b/src/segment.hpp @@ -4,7 +4,7 @@ #include <vector> #include "algorithms.hpp" -#include "catypes.hpp" +#include "common_types.hpp" #include "compartment.hpp" #include "math.hpp" #include "parameter_list.hpp" diff --git a/tests/unit/test_cell_group.cpp b/tests/unit/test_cell_group.cpp index 1f74cac9..3aed2220 100644 --- a/tests/unit/test_cell_group.cpp +++ b/tests/unit/test_cell_group.cpp @@ -1,6 +1,6 @@ #include "gtest.h" -#include <catypes.hpp> +#include <common_types.hpp> #include <fvm_cell.hpp> #include <cell_group.hpp> diff --git a/tests/unit/test_fvm.cpp b/tests/unit/test_fvm.cpp index ea8cd7da..c0ed438f 100644 --- a/tests/unit/test_fvm.cpp +++ b/tests/unit/test_fvm.cpp @@ -2,7 +2,7 @@ #include "gtest.h" -#include <catypes.hpp> +#include <common_types.hpp> #include <cell.hpp> #include <fvm_cell.hpp> diff --git a/tests/unit/test_probe.cpp b/tests/unit/test_probe.cpp index 888e710e..5af744d2 100644 --- a/tests/unit/test_probe.cpp +++ b/tests/unit/test_probe.cpp @@ -1,6 +1,6 @@ #include "gtest.h" -#include "catypes.hpp" +#include "common_types.hpp" #include "cell.hpp" #include "fvm_cell.hpp" diff --git a/tests/validation/validate_ball_and_stick.cpp b/tests/validation/validate_ball_and_stick.cpp index a819173e..62d06b4d 100644 --- a/tests/validation/validate_ball_and_stick.cpp +++ b/tests/validation/validate_ball_and_stick.cpp @@ -1,7 +1,7 @@ #include <fstream> #include <json/src/json.hpp> -#include <catypes.hpp> +#include <common_types.hpp> #include <cell.hpp> #include <fvm_cell.hpp> diff --git a/tests/validation/validate_soma.cpp b/tests/validation/validate_soma.cpp index 20396701..24a0c1c5 100644 --- a/tests/validation/validate_soma.cpp +++ b/tests/validation/validate_soma.cpp @@ -1,7 +1,7 @@ #include <fstream> #include <json/src/json.hpp> -#include <catypes.hpp> +#include <common_types.hpp> #include <cell.hpp> #include <fvm_cell.hpp> diff --git a/tests/validation/validate_synapses.cpp b/tests/validation/validate_synapses.cpp index 9bc67172..876b24eb 100644 --- a/tests/validation/validate_synapses.cpp +++ b/tests/validation/validate_synapses.cpp @@ -3,7 +3,7 @@ #include <json/src/json.hpp> -#include <catypes.hpp> +#include <common_types.hpp> #include <cell.hpp> #include <cell_group.hpp> #include <fvm_cell.hpp> -- GitLab