From af9c1a824cf3d58f019d0fcd740df01d7098825c Mon Sep 17 00:00:00 2001 From: Likitha Nanduri Date: Fri, 10 Jul 2026 09:47:34 -0700 Subject: [PATCH 1/4] [issue-779] Populate STDP edge recorder output --- Simulator/Connections/Neuro/ConnStatic.cpp | 22 +++++++++++++++++- Simulator/Connections/Neuro/ConnStatic.h | 3 +++ Simulator/Edges/AllEdges.h | 26 +++++++++++++++++++++- 3 files changed, 49 insertions(+), 2 deletions(-) diff --git a/Simulator/Connections/Neuro/ConnStatic.cpp b/Simulator/Connections/Neuro/ConnStatic.cpp index 3f2f712fa..77e41b32d 100644 --- a/Simulator/Connections/Neuro/ConnStatic.cpp +++ b/Simulator/Connections/Neuro/ConnStatic.cpp @@ -93,7 +93,6 @@ void ConnStatic::printParameters() const void ConnStatic::registerHistoryVariables() { // Register the following variables to be recorded - // Note: There may be potential duplicate weight, source, destination vertices Recorder &recorder = Simulator::getInstance().getModel().getRecorder(); recorder.registerVariable("weight", WCurrentEpoch_, Recorder::UpdatedType::DYNAMIC); recorder.registerVariable("sourceVertex", sourceVertexIndexCurrentEpoch_, @@ -101,3 +100,24 @@ void ConnStatic::registerHistoryVariables() recorder.registerVariable("destinationVertex", destVertexIndexCurrentEpoch_, Recorder::UpdatedType::DYNAMIC); } + +bool ConnStatic::updateConnections() +{ + AllEdges &edges = getEdges(); + const vector &inUse = edges.getInUse(); + const vector &weights = edges.getWeights(); + const vector &sourceVertices = edges.getSourceVertexIndices(); + const vector &destVertices = edges.getDestVertexIndices(); + + // Copy one value per active edge into parallel recorder vectors. + // weight/source/destination entries at the same index describe the same edge. + for (BGSIZE iEdg = 0; iEdg < inUse.size(); iEdg++) { + if (inUse[iEdg]) { + WCurrentEpoch_.push_back(weights[iEdg]); + sourceVertexIndexCurrentEpoch_.push_back(sourceVertices[iEdg]); + destVertexIndexCurrentEpoch_.push_back(destVertices[iEdg]); + } + } + + return false; +} diff --git a/Simulator/Connections/Neuro/ConnStatic.h b/Simulator/Connections/Neuro/ConnStatic.h index 67d0a8fb6..fbb7bbc44 100644 --- a/Simulator/Connections/Neuro/ConnStatic.h +++ b/Simulator/Connections/Neuro/ConnStatic.h @@ -64,6 +64,9 @@ class ConnStatic : public Connections { /// Registers history variables for recording during simulation virtual void registerHistoryVariables() override; + /// Populates edge history variables for recording during the current epoch. + virtual bool updateConnections() override; + /// Get array of vertex weights const vector &getWCurrentEpoch() const { diff --git a/Simulator/Edges/AllEdges.h b/Simulator/Edges/AllEdges.h index ccc49308a..b726cdfec 100644 --- a/Simulator/Edges/AllEdges.h +++ b/Simulator/Edges/AllEdges.h @@ -59,6 +59,30 @@ class AllEdges { /// Populate a edge index map. virtual void createEdgeIndexMap(EdgeIndexMap &edgeIndexMap); + /// Get array of source vertex indices. + const vector &getSourceVertexIndices() const + { + return sourceVertexIndex_; + } + + /// Get array of destination vertex indices. + const vector &getDestVertexIndices() const + { + return destVertexIndex_; + } + + /// Get array of edge weights. + const vector &getWeights() const + { + return W_; + } + + /// Get array of active edge flags. + const vector &getInUse() const + { + return inUse_; + } + /// Cereal serialization method template void serialize(Archive &archive); @@ -253,4 +277,4 @@ template void AllEdges::serialize(Archive &archive) cereal::make_nvp("totalEdgeCount", totalEdgeCount_), cereal::make_nvp("maxEdgesPerVertex", maxEdgesPerVertex_), cereal::make_nvp("countVertices", countVertices_)); -} \ No newline at end of file +} From 4f2df5c1aa3f3fb1744459d0c4d012854c8e96bb Mon Sep 17 00:00:00 2001 From: Likitha Nanduri Date: Mon, 20 Jul 2026 08:54:49 -0700 Subject: [PATCH 2/4] [issue-779] Clear edge recorder data each epoch --- Simulator/Connections/Neuro/ConnStatic.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Simulator/Connections/Neuro/ConnStatic.cpp b/Simulator/Connections/Neuro/ConnStatic.cpp index 77e41b32d..a1ab392cc 100644 --- a/Simulator/Connections/Neuro/ConnStatic.cpp +++ b/Simulator/Connections/Neuro/ConnStatic.cpp @@ -103,6 +103,11 @@ void ConnStatic::registerHistoryVariables() bool ConnStatic::updateConnections() { + // GPU STDP is not implemented, so this only uses the CPU edge data. + WCurrentEpoch_.startNewEpoch(); + sourceVertexIndexCurrentEpoch_.startNewEpoch(); + destVertexIndexCurrentEpoch_.startNewEpoch(); + AllEdges &edges = getEdges(); const vector &inUse = edges.getInUse(); const vector &weights = edges.getWeights(); @@ -110,7 +115,7 @@ bool ConnStatic::updateConnections() const vector &destVertices = edges.getDestVertexIndices(); // Copy one value per active edge into parallel recorder vectors. - // weight/source/destination entries at the same index describe the same edge. + // Entries at the same index describe the same edge. for (BGSIZE iEdg = 0; iEdg < inUse.size(); iEdg++) { if (inUse[iEdg]) { WCurrentEpoch_.push_back(weights[iEdg]); From 6e99c5531b6a2eb2ddbb89648bebb3524ab297b4 Mon Sep 17 00:00:00 2001 From: Likitha Nanduri Date: Wed, 5 Aug 2026 13:07:37 -0700 Subject: [PATCH 3/4] [issue-779] Add ConnStatic edge recording test --- CMakeLists.txt | 1 + Testing/UnitTesting/ConnStaticTests.cpp | 52 +++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 Testing/UnitTesting/ConnStaticTests.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index be871596c..973efffa0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -484,6 +484,7 @@ add_executable(tests Testing/UnitTesting/OperationManagerTestingClass.h Testing/UnitTesting/VerticesFactoryTests.cpp Testing/UnitTesting/ConnectionsFactoryTests.cpp + Testing/UnitTesting/ConnStaticTests.cpp Testing/UnitTesting/EdgesFactoryTests.cpp Testing/UnitTesting/LayoutFactoryTests.cpp Testing/UnitTesting/RecorderFactoryTests.cpp diff --git a/Testing/UnitTesting/ConnStaticTests.cpp b/Testing/UnitTesting/ConnStaticTests.cpp new file mode 100644 index 000000000..2663c42e2 --- /dev/null +++ b/Testing/UnitTesting/ConnStaticTests.cpp @@ -0,0 +1,52 @@ +/** + * @file ConnStaticTests.cpp + * + * @brief Unit tests for ConnStatic. + * + * @ingroup Testing/UnitTesting + */ + +#include "AllSTDPSynapses.h" +#include "ConnStatic.h" +#include "gtest/gtest.h" + +#include +#include + +namespace { + +class TestConnStatic : public ConnStatic { +public: + void setEdges(std::unique_ptr edges) + { + edges_ = std::move(edges); + } +}; + +TEST(ConnStatic, UpdateConnectionsCopiesActiveEdgesWithoutAccumulating) +{ + auto edges = std::make_unique(3, 2); + edges->addEdge(edgeType::EE, 0, 2, 0.001); + edges->addEdge(edgeType::II, 2, 0, 0.001); + + const std::vector expectedSources { 2, 0 }; + const std::vector expectedDestinations { 0, 2 }; + const std::vector expectedWeights { -10.0e-9, 10.0e-9 }; + + TestConnStatic connections; + connections.setEdges(std::move(edges)); + + connections.updateConnections(); + + EXPECT_EQ(expectedSources, connections.getSourceVertexIndexCurrentEpoch()); + EXPECT_EQ(expectedDestinations, connections.getDestVertexIndexCurrentEpoch()); + EXPECT_EQ(expectedWeights, connections.getWCurrentEpoch()); + + connections.updateConnections(); + + EXPECT_EQ(expectedSources, connections.getSourceVertexIndexCurrentEpoch()); + EXPECT_EQ(expectedDestinations, connections.getDestVertexIndexCurrentEpoch()); + EXPECT_EQ(expectedWeights, connections.getWCurrentEpoch()); +} + +} // namespace From d1b19338873a245edad8a9dbfc867959898323eb Mon Sep 17 00:00:00 2001 From: Likitha Nanduri Date: Wed, 5 Aug 2026 13:15:00 -0700 Subject: [PATCH 4/4] [issue-779] Format ConnStatic unit test --- Testing/UnitTesting/ConnStaticTests.cpp | 53 ++++++++++++------------- 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/Testing/UnitTesting/ConnStaticTests.cpp b/Testing/UnitTesting/ConnStaticTests.cpp index 2663c42e2..dfd3d0c3f 100644 --- a/Testing/UnitTesting/ConnStaticTests.cpp +++ b/Testing/UnitTesting/ConnStaticTests.cpp @@ -9,44 +9,43 @@ #include "AllSTDPSynapses.h" #include "ConnStatic.h" #include "gtest/gtest.h" - #include #include namespace { -class TestConnStatic : public ConnStatic { -public: - void setEdges(std::unique_ptr edges) - { - edges_ = std::move(edges); - } -}; + class TestConnStatic : public ConnStatic { + public: + void setEdges(std::unique_ptr edges) + { + edges_ = std::move(edges); + } + }; -TEST(ConnStatic, UpdateConnectionsCopiesActiveEdgesWithoutAccumulating) -{ - auto edges = std::make_unique(3, 2); - edges->addEdge(edgeType::EE, 0, 2, 0.001); - edges->addEdge(edgeType::II, 2, 0, 0.001); + TEST(ConnStatic, UpdateConnectionsCopiesActiveEdgesWithoutAccumulating) + { + auto edges = std::make_unique(3, 2); + edges->addEdge(edgeType::EE, 0, 2, 0.001); + edges->addEdge(edgeType::II, 2, 0, 0.001); - const std::vector expectedSources { 2, 0 }; - const std::vector expectedDestinations { 0, 2 }; - const std::vector expectedWeights { -10.0e-9, 10.0e-9 }; + const std::vector expectedSources {2, 0}; + const std::vector expectedDestinations {0, 2}; + const std::vector expectedWeights {-10.0e-9, 10.0e-9}; - TestConnStatic connections; - connections.setEdges(std::move(edges)); + TestConnStatic connections; + connections.setEdges(std::move(edges)); - connections.updateConnections(); + connections.updateConnections(); - EXPECT_EQ(expectedSources, connections.getSourceVertexIndexCurrentEpoch()); - EXPECT_EQ(expectedDestinations, connections.getDestVertexIndexCurrentEpoch()); - EXPECT_EQ(expectedWeights, connections.getWCurrentEpoch()); + EXPECT_EQ(expectedSources, connections.getSourceVertexIndexCurrentEpoch()); + EXPECT_EQ(expectedDestinations, connections.getDestVertexIndexCurrentEpoch()); + EXPECT_EQ(expectedWeights, connections.getWCurrentEpoch()); - connections.updateConnections(); + connections.updateConnections(); - EXPECT_EQ(expectedSources, connections.getSourceVertexIndexCurrentEpoch()); - EXPECT_EQ(expectedDestinations, connections.getDestVertexIndexCurrentEpoch()); - EXPECT_EQ(expectedWeights, connections.getWCurrentEpoch()); -} + EXPECT_EQ(expectedSources, connections.getSourceVertexIndexCurrentEpoch()); + EXPECT_EQ(expectedDestinations, connections.getDestVertexIndexCurrentEpoch()); + EXPECT_EQ(expectedWeights, connections.getWCurrentEpoch()); + } } // namespace