Skip to content

Commit 3115f37

Browse files
author
Divya Kamath
committed
Merge branch 'development' of https://github.com/UWB-Biocomputing/Graphitti into issue-581-serialization-documentation
2 parents e11b4d0 + 095537e commit 3115f37

File tree

195 files changed

+375774
-2444
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

195 files changed

+375774
-2444
lines changed

.github/workflows/tests.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,39 +36,39 @@ jobs:
3636
run: ./cgraphitti -c ../Testing/RegressionTesting/configfiles/test-tiny.xml
3737
- name: verify test-tiny
3838
if: always() && steps.tt.conclusion == 'success'
39-
run: diff ../Testing/RegressionTesting/TestOutput/test-tiny-out.xml ../Testing/RegressionTesting/GoodOutput/test-tiny-out.xml
39+
run: diff ../Testing/RegressionTesting/TestOutput/test-tiny-out.xml ../Testing/RegressionTesting/GoodOutput/Cpu/test-tiny-out.xml
4040

4141
- id: ts
4242
name: run test-small
4343
if: always() && steps.build.conclusion == 'success'
4444
run: ./cgraphitti -c ../Testing/RegressionTesting/configfiles/test-small.xml
4545
- name: verify test-small
4646
if: always() && steps.ts.conclusion == 'success'
47-
run: diff ../Testing/RegressionTesting/TestOutput/test-small-out.xml ../Testing/RegressionTesting/GoodOutput/test-small-out.xml
47+
run: diff ../Testing/RegressionTesting/TestOutput/test-small-out.xml ../Testing/RegressionTesting/GoodOutput/Cpu/test-small-out.xml
4848

4949
- id: tsc
5050
name: run test-small-connected
5151
if: always() && steps.build.conclusion == 'success'
5252
run: ./cgraphitti -c ../Testing/RegressionTesting/configfiles/test-small-connected.xml
5353
- name: verify test-small-connected
5454
if: always() && steps.tsc.conclusion == 'success'
55-
run: diff ../Testing/RegressionTesting/TestOutput/test-small-connected-out.xml ../Testing/RegressionTesting/GoodOutput/test-small-connected-out.xml
55+
run: diff ../Testing/RegressionTesting/TestOutput/test-small-connected-out.xml ../Testing/RegressionTesting/GoodOutput/Cpu/test-small-connected-out.xml
5656

5757
- id: tsl
5858
name: run test-small-long
5959
if: always() && steps.build.conclusion == 'success'
6060
run: ./cgraphitti -c ../Testing/RegressionTesting/configfiles/test-small-long.xml
6161
- name: verify test-small-long
6262
if: always() && steps.tsl.conclusion == 'success'
63-
run: diff ../Testing/RegressionTesting/TestOutput/test-small-long-out.xml ../Testing/RegressionTesting/GoodOutput/test-small-long-out.xml
63+
run: diff ../Testing/RegressionTesting/TestOutput/test-small-long-out.xml ../Testing/RegressionTesting/GoodOutput/Cpu/test-small-long-out.xml
6464

6565
- id: tscl
6666
name: run test-small-connected-long
6767
if: always() && steps.build.conclusion == 'success'
6868
run: ./cgraphitti -c ../Testing/RegressionTesting/configfiles/test-small-connected-long.xml
6969
- name: verify test-small-connected-long
7070
if: always() && steps.tscl.conclusion == 'success'
71-
run: diff ../Testing/RegressionTesting/TestOutput/test-small-connected-long-out.xml ../Testing/RegressionTesting/GoodOutput/test-small-connected-long-out.xml
71+
run: diff ../Testing/RegressionTesting/TestOutput/test-small-connected-long-out.xml ../Testing/RegressionTesting/GoodOutput/Cpu/test-small-connected-long-out.xml
7272

7373
- id: ts911
7474
name: run test-small-911
@@ -84,28 +84,28 @@ jobs:
8484
run: ./cgraphitti -c ../Testing/RegressionTesting/configfiles/test-medium.xml
8585
- name: verify test-medium
8686
if: always() && steps.tm.conclusion == 'success'
87-
run: diff ../Testing/RegressionTesting/TestOutput/test-medium-out.xml ../Testing/RegressionTesting/GoodOutput/test-medium-out.xml
87+
run: diff ../Testing/RegressionTesting/TestOutput/test-medium-out.xml ../Testing/RegressionTesting/GoodOutput/Cpu/test-medium-out.xml
8888

8989
- id: tmc
9090
name: run test-medium-connected
9191
if: always() && steps.build.conclusion == 'success'
9292
run: ./cgraphitti -c ../Testing/RegressionTesting/configfiles/test-medium-connected.xml
9393
- name: verify test-medium-connected
9494
if: always() && steps.tmc.conclusion == 'success'
95-
run: diff ../Testing/RegressionTesting/TestOutput/test-medium-connected-out.xml ../Testing/RegressionTesting/GoodOutput/test-medium-connected-out.xml
95+
run: diff ../Testing/RegressionTesting/TestOutput/test-medium-connected-out.xml ../Testing/RegressionTesting/GoodOutput/Cpu/test-medium-connected-out.xml
9696

9797
- id: tml
9898
name: run test-medium-long
9999
if: always() && steps.build.conclusion == 'success'
100100
run: ./cgraphitti -c ../Testing/RegressionTesting/configfiles/test-medium-long.xml
101101
- name: verify test-medium-long
102102
if: always() && steps.tml.conclusion == 'success'
103-
run: diff ../Testing/RegressionTesting/TestOutput/test-medium-long-out.xml ../Testing/RegressionTesting/GoodOutput/test-medium-long-out.xml
103+
run: diff ../Testing/RegressionTesting/TestOutput/test-medium-long-out.xml ../Testing/RegressionTesting/GoodOutput/Cpu/test-medium-long-out.xml
104104

105105
- id: tmcl
106106
name: run test-medium-connected-long
107107
if: always() && steps.build.conclusion == 'success'
108108
run: ./cgraphitti -c ../Testing/RegressionTesting/configfiles/test-medium-connected-long.xml
109109
- name: verify test-medium-connected-long
110110
if: always() && steps.tmcl.conclusion == 'success'
111-
run: diff ../Testing/RegressionTesting/TestOutput/test-medium-connected-long-out.xml ../Testing/RegressionTesting/GoodOutput/test-medium-connected-long-out.xml
111+
run: diff ../Testing/RegressionTesting/TestOutput/test-medium-connected-long-out.xml ../Testing/RegressionTesting/GoodOutput/Cpu/test-medium-connected-long-out.xml

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,8 @@ add_executable(tests
363363
Testing/UnitTesting/GraphManagerTests.cpp
364364
Testing/Utils/ParameterManagerTests.cpp
365365
Testing/Utils/CircularBufferTests.cpp
366-
Testing/UnitTesting/XmlRecorderTests.cpp)
366+
Testing/UnitTesting/XmlRecorderTests.cpp
367+
Testing/UnitTesting/Hdf5RecorderTests.cpp)
367368

368369
# Links the Googletest framework with the testing executable
369370
target_link_libraries(tests gtest gtest_main)

Contributors.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ Andrzej Dawiec
7474

7575
ChengHao Hsu
7676

77+
Zaina Shaikh
78+
7779
<!-- ---------------------------------------------------------------------------------- -->
7880
# Graduate
7981

Simulator/Connections/Connections.cpp

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -103,31 +103,3 @@ void Connections::updateSynapsesWeights()
103103
{
104104
}
105105
#endif // !USE_GPU
106-
107-
/// Creates synapses from synapse weights saved in the serialization file.
108-
void Connections::createSynapsesFromWeights()
109-
{
110-
int numVertices = Simulator::getInstance().getTotalVertices();
111-
Layout &layout = Simulator::getInstance().getModel().getLayout();
112-
AllVertices &vertices = layout.getVertices();
113-
114-
// for each neuron
115-
for (int i = 0; i < numVertices; i++) {
116-
// for each synapse in the vertex
117-
for (BGSIZE synapseIndex = 0; synapseIndex < Simulator::getInstance().getMaxEdgesPerVertex();
118-
synapseIndex++) {
119-
BGSIZE iEdg = Simulator::getInstance().getMaxEdgesPerVertex() * i + synapseIndex;
120-
// if the synapse weight is not zero (which means there is a connection), create the synapse
121-
if (edges_->W_[iEdg] != 0.0) {
122-
BGFLOAT theW = edges_->W_[iEdg];
123-
int srcVertex = edges_->sourceVertexIndex_[iEdg];
124-
int destVertex = edges_->destVertexIndex_[iEdg];
125-
edgeType type = layout.edgType(srcVertex, destVertex);
126-
edges_->edgeCounts_[i]++;
127-
edges_->createEdge(iEdg, srcVertex, destVertex, Simulator::getInstance().getDeltaT(),
128-
type);
129-
edges_->W_[iEdg] = theW;
130-
}
131-
}
132-
}
133-
}

Simulator/Connections/Connections.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,6 @@ class Connections {
7373
/// @return true if successful, false otherwise.
7474
virtual bool updateConnections(AllVertices &vertices);
7575

76-
/// Creates synapses from synapse weights saved in the serialization file.
77-
void createSynapsesFromWeights();
78-
7976
/// Cereal serialization method
8077
template <class Archive> void serialize(Archive &archive, std::uint32_t const version);
8178

@@ -115,6 +112,6 @@ CEREAL_CLASS_VERSION(Connections, 1);
115112
/// Cereal serialization method
116113
template <class Archive> void Connections::serialize(Archive &archive, std::uint32_t const version)
117114
{
118-
archive(cereal::make_nvp("edges_", edges_),
119-
cereal::make_nvp("synapseIndexMap_", synapseIndexMap_));
115+
archive(cereal::make_nvp("edges", edges_),
116+
cereal::make_nvp("synapseIndexMap", synapseIndexMap_));
120117
}

Simulator/Connections/Neuro/ConnGrowth.cpp

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
#include "ParseParamError.h"
4747

4848
#ifdef USE_HDF5
49-
#include "Hdf5GrowthRecorder.h"
49+
#include "Hdf5Recorder.h"
5050
#endif
5151

5252
ConnGrowth::ConnGrowth()
@@ -67,10 +67,15 @@ void ConnGrowth::setup()
6767
W_ = CompleteMatrix(MATRIX_TYPE, MATRIX_INIT, numVertices, numVertices, 0);
6868
radii_ = VectorMatrix(MATRIX_TYPE, MATRIX_INIT, 1, numVertices, growthParams_.startRadius);
6969
rates_ = VectorMatrix(MATRIX_TYPE, MATRIX_INIT, 1, numVertices, 0);
70+
delta_ = CompleteMatrix(MATRIX_TYPE, MATRIX_INIT, numVertices, numVertices);
7071
area_ = CompleteMatrix(MATRIX_TYPE, MATRIX_INIT, numVertices, numVertices, 0);
7172
outgrowth_ = VectorMatrix(MATRIX_TYPE, MATRIX_INIT, 1, numVertices);
7273
deltaR_ = VectorMatrix(MATRIX_TYPE, MATRIX_INIT, 1, numVertices);
7374

75+
// Initialize connection frontier distance change matrix with the current distances
76+
Layout &layout = Simulator::getInstance().getModel().getLayout();
77+
delta_ = layout.dist_;
78+
7479
// Register VertorMatrix radii_ for Recording if need
7580
// Recorder &recorder = Simulator::getInstance().getModel().getRecorder();
7681
// string variableName = "radii";
@@ -128,6 +133,9 @@ bool ConnGrowth::updateConnections(AllVertices &vertices)
128133
// Update Connections data
129134
updateConns(vertices);
130135

136+
// Updata the distance between forntiers of vertices
137+
updateFrontiers();
138+
131139
// Update the areas of overlap in between vertices
132140
updateOverlap();
133141

@@ -161,10 +169,22 @@ void ConnGrowth::updateConns(AllVertices &vertices)
161169
radii_ += deltaR_;
162170
}
163171

172+
/// Update the distance between frontiers of vertices.
173+
void ConnGrowth::updateFrontiers()
174+
{
175+
LOG4CPLUS_INFO(fileLogger_, "Updating distance between frontiers...");
176+
// Update distance between frontiers
177+
Layout &layout = Simulator::getInstance().getModel().getLayout();
178+
int numVertices = Simulator::getInstance().getTotalVertices();
179+
for (int unit = 0; unit < numVertices - 1; unit++) {
180+
for (int i = unit + 1; i < numVertices; i++) {
181+
delta_(unit, i) = layout.dist_(unit, i) - (radii_[unit] + radii_[i]);
182+
delta_(i, unit) = delta_(unit, i);
183+
}
184+
}
185+
}
186+
164187
/// Update the areas of overlap in between Neurons.
165-
///
166-
/// @param numVertices Number of vertices to update.
167-
/// @param layout Layout information of the neural network.
168188
void ConnGrowth::updateOverlap()
169189
{
170190
int numVertices = Simulator::getInstance().getTotalVertices();
@@ -173,14 +193,11 @@ void ConnGrowth::updateOverlap()
173193
LOG4CPLUS_INFO(fileLogger_, "Computing areas of overlap");
174194

175195
// Compute areas of overlap; this is only done for overlapping units
176-
for (int i = 0; i < numVertices - 1; i++) {
177-
for (int j = i + 1; j < numVertices; j++) {
196+
for (int i = 0; i < numVertices; i++) {
197+
for (int j = 0; j < numVertices; j++) {
178198
area_(i, j) = 0.0;
179199

180-
// Calculate the distance between neuron frontiers
181-
BGFLOAT frontierDelta = layout.dist_(j, i) - (radii_[j] + radii_[i]);
182-
183-
if (frontierDelta < 0) {
200+
if (delta_(i, j) < 0) {
184201
BGFLOAT lenAB = layout.dist_(i, j);
185202
BGFLOAT r1 = radii_[i];
186203
BGFLOAT r2 = radii_[j];

Simulator/Connections/Neuro/ConnGrowth.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,9 @@ class ConnGrowth : public Connections {
143143
/// @param neurons The Neuron list to search from.
144144
void updateConns(AllVertices &neurons);
145145

146+
/// Update the distance between frontiers of Neurons.
147+
void updateFrontiers();
148+
146149
/// Update the areas of overlap in between Neurons.
147150
void updateOverlap();
148151

@@ -182,6 +185,9 @@ class ConnGrowth : public Connections {
182185
/// spiking rate
183186
VectorMatrix rates_;
184187

188+
/// distance between connection frontiers
189+
CompleteMatrix delta_;
190+
185191
/// areas of overlap
186192
CompleteMatrix area_;
187193

@@ -198,8 +204,8 @@ CEREAL_REGISTER_TYPE(ConnGrowth); // to enable polymorphism
198204
template <class Archive> void ConnGrowth::serialize(Archive &archive)
199205
{
200206
archive(cereal::base_class<Connections>(this), cereal::make_nvp("radiiSize", radiiSize_),
201-
cereal::make_nvp("growthParams_", growthParams_), cereal::make_nvp("W_", W_),
202-
cereal::make_nvp("radii_", radii_), cereal::make_nvp("rates_", rates_),
203-
cereal::make_nvp("area_", area_), cereal::make_nvp("outgrowth_", outgrowth_),
204-
cereal::make_nvp("deltaR_", deltaR_));
207+
cereal::make_nvp("growthParams", growthParams_), cereal::make_nvp("W", W_),
208+
cereal::make_nvp("radii", radii_), cereal::make_nvp("rates", rates_),
209+
cereal::make_nvp("delta", delta_), cereal::make_nvp("area", area_),
210+
cereal::make_nvp("outgrowth", outgrowth_), cereal::make_nvp("deltaR", deltaR_));
205211
}

Simulator/Connections/Neuro/ConnStatic.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,12 @@ CEREAL_REGISTER_TYPE(ConnStatic);
137137
template <class Archive> void ConnStatic::serialize(Archive &archive)
138138
{
139139
archive(cereal::base_class<Connections>(this),
140-
cereal::make_nvp("sourceVertexIndexCurrentEpoch_", sourceVertexIndexCurrentEpoch_),
141-
cereal::make_nvp("destVertexIndexCurrentEpoch_", destVertexIndexCurrentEpoch_),
142-
cereal::make_nvp("WCurrentEpoch_", WCurrentEpoch_),
143-
cereal::make_nvp("radiiSize_", radiiSize_),
144-
cereal::make_nvp("connsPerVertex_", connsPerVertex_),
145-
cereal::make_nvp("threshConnsRadius_", threshConnsRadius_),
146-
cereal::make_nvp("rewiringProbability_", rewiringProbability_),
147-
cereal::make_nvp("excWeight_", excWeight_), cereal::make_nvp("inhWeight_", inhWeight_));
148-
}
140+
cereal::make_nvp("sourceVertexIndexCurrentEpoch", sourceVertexIndexCurrentEpoch_),
141+
cereal::make_nvp("destVertexIndexCurrentEpoch", destVertexIndexCurrentEpoch_),
142+
cereal::make_nvp("WCurrentEpoch", WCurrentEpoch_),
143+
cereal::make_nvp("radiiSize", radiiSize_),
144+
cereal::make_nvp("connsPerVertex", connsPerVertex_),
145+
cereal::make_nvp("threshConnsRadius", threshConnsRadius_),
146+
cereal::make_nvp("rewiringProbability", rewiringProbability_),
147+
cereal::make_nvp("excWeight", excWeight_), cereal::make_nvp("inhWeight", inhWeight_));
148+
}

Simulator/Core/Core.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,12 +184,15 @@ int Core::runSimulation(string executableName, string cmdLineArguments)
184184
LOG4CPLUS_TRACE(consoleLogger, "Deserializing state from file.");
185185

186186
// Deserialization
187-
if (!serializer.deserializeSynapses()) {
187+
if (!serializer.deserialize()) {
188188
LOG4CPLUS_FATAL(consoleLogger, "Failed while deserializing objects");
189189
return -1;
190190
}
191191
}
192192

193+
// Helper function for recorder to register spike history variables for all neurons.
194+
simulator.getModel().getLayout().getVertices().registerHistoryVariables();
195+
193196
// Run simulation
194197
LOG4CPLUS_TRACE(consoleLogger, "Starting Simulation");
195198
simulator.simulate();
@@ -211,7 +214,7 @@ int Core::runSimulation(string executableName, string cmdLineArguments)
211214
// Serializes internal state for the current simulation
212215
if (!simulator.getSerializationFileName().empty()) {
213216
LOG4CPLUS_TRACE(consoleLogger, "Serializing current state");
214-
serializer.serializeSynapses();
217+
serializer.serialize();
215218
}
216219

217220
// Tell simulation to clean-up and run any post-simulation logic.

Simulator/Core/EdgeIndexMap.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,12 @@ struct EdgeIndexMapDevice {
111111
/// Cereal serialization method
112112
template <class Archive> void EdgeIndexMap::serialize(Archive &archive)
113113
{
114-
archive(cereal::make_nvp("outgoingEdgeIndexMap_", outgoingEdgeIndexMap_),
115-
cereal::make_nvp("outgoingEdgeBegin_", outgoingEdgeBegin_),
116-
cereal::make_nvp("outgoingEdgeCount_", outgoingEdgeCount_),
117-
cereal::make_nvp("incomingEdgeIndexMap_", incomingEdgeIndexMap_),
118-
cereal::make_nvp("incomingEdgeBegin_", incomingEdgeBegin_),
119-
cereal::make_nvp("incomingEdgeCount_", incomingEdgeCount_),
120-
cereal::make_nvp("numOfVertices_", numOfVertices_),
121-
cereal::make_nvp("numOfEdges_", numOfEdges_));
114+
archive(cereal::make_nvp("outgoingEdgeIndexMap", outgoingEdgeIndexMap_),
115+
cereal::make_nvp("outgoingEdgeBegin", outgoingEdgeBegin_),
116+
cereal::make_nvp("outgoingEdgeCount", outgoingEdgeCount_),
117+
cereal::make_nvp("incomingEdgeIndexMap", incomingEdgeIndexMap_),
118+
cereal::make_nvp("incomingEdgeBegin", incomingEdgeBegin_),
119+
cereal::make_nvp("incomingEdgeCount", incomingEdgeCount_),
120+
cereal::make_nvp("numOfVertices", numOfVertices_),
121+
cereal::make_nvp("numOfEdges", numOfEdges_));
122122
}

0 commit comments

Comments
 (0)