Skip to content

Commit 212fb1d

Browse files
Merge PoseyDevelopment into SharedDevelopment (#798)
* [issue-745] Refactor where summation is calculated (#777) * Refactor model class to generalize the summation logic method and move implementation into neuron class * Implement new AllVertices method in 911 class * Fix last compile errors * Clean up commented out code * Resolve code format failure * Remove dynamic cast of vertices so model with work with non-neuron models * Add override keyword to integrateVertexInputs declaration * Fix formatting issue * [issue-785] Remove neuro items from gpu model (#789) * Rename edge index map device variable name * Rename method names to remove neuro context * Rename variables both in method signature and implementation * Fix formatting * Remove neuro from GPU model and generalize what we can * Remove summation point operation as it's now done in the neuro vertices base class * Revert formatting that breaks code style * Clean up comments, variable names, and includes * Move edge sum index into all spiking synapses and rename neuro GPU methods in both edges and vertices * Fix style violation * Make corresponding updates to documentation * Re add serialize method to documentation * Fix const representation * Add All911Edges to connections documentation * Update diagram images
1 parent e3b0d1e commit 212fb1d

39 files changed

+962
-2268
lines changed

Simulator/Connections/Connections.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,16 @@ bool Connections::updateConnections(AllVertices &vertices)
8989
}
9090

9191
#if defined(USE_GPU)
92-
void Connections::updateSynapsesWeights(int numVertices, AllVertices &vertices, AllEdges &synapses,
93-
AllSpikingNeuronsDeviceProperties *allVerticesDevice,
94-
AllSpikingSynapsesDeviceProperties *allEdgesDevice,
95-
Layout &layout)
92+
void Connections::updateEdgesWeights(int numVertices, AllVertices &vertices, AllEdges &edges,
93+
AllVerticesDeviceProperties *allVerticesDevice,
94+
AllEdgesDeviceProperties *allEdgesDevice, Layout &layout)
9695
{
9796
}
9897
#else
9998

100-
/// Update the weight of the Synapses in the simulation.
99+
/// Update the weight of the edges in the simulation.
101100
/// Note: Platform Dependent.
102-
void Connections::updateSynapsesWeights()
101+
void Connections::updateEdgesWeights()
103102
{
104103
}
105104
#endif // !USE_GPU

Simulator/Connections/Connections.h

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
#pragma once
2525

2626
#include "AllEdges.h"
27-
#include "AllSpikingNeurons.h"
28-
#include "AllSpikingSynapses.h"
2927
#include "AllVertices.h"
3028
#include "EdgeIndexMap.h"
3129
#include "Layout.h"
@@ -69,7 +67,7 @@ class Connections {
6967

7068
/// Update the connections status in every epoch.
7169
///
72-
/// @param neurons The Neuron list to search from.
70+
/// @param vertices The vertex list to search from.
7371
/// @return true if successful, false otherwise.
7472
virtual bool updateConnections(AllVertices &vertices);
7573

@@ -78,35 +76,36 @@ class Connections {
7876

7977
#if defined(USE_GPU)
8078
public:
81-
/// Update the weight of the Synapses in the simulation.
79+
/// Update the weight of the edges in the simulation.
8280
/// Note: Platform Dependent.
8381
///
8482
/// @param numVertices number of vertices to update.
85-
/// @param neurons the Neuron list to search from.
86-
/// @param synapses the Synapse list to search from.
83+
/// @param vertices the vertex list to search from.
84+
/// @param edges the edge list to search from.
8785
/// @param allVerticesDevice GPU address of the allVertices struct on device memory.
88-
/// @param allEdgesDevice GPU address of the allEdges struct on device memory.
89-
/// @param layout Layout information of the neural network.
90-
virtual void updateSynapsesWeights(int numVertices, AllVertices &vertices, AllEdges &synapses,
91-
AllSpikingNeuronsDeviceProperties *allVerticesDevice,
92-
AllSpikingSynapsesDeviceProperties *allEdgesDevice,
93-
Layout &layout);
86+
/// @param allEdgesDevice GPU address of the allEdges struct on device memory.
87+
/// @param layout Layout information of the graph network.
88+
virtual void updateEdgesWeights(int numVertices, AllVertices &vertices, AllEdges &edges,
89+
AllVerticesDeviceProperties *allVerticesDevice,
90+
AllEdgesDeviceProperties *allEdgesDevice, Layout &layout);
9491
#else
9592
public:
96-
/// Update the weight of the Synapses in the simulation.
93+
/// Update the weight of the edges in the simulation.
9794
/// Note: Platform Dependent.
98-
virtual void updateSynapsesWeights();
95+
virtual void updateEdgesWeights();
9996

10097
#endif // USE_GPU
10198

10299
protected:
103100
unique_ptr<AllEdges> edges_;
101+
/// TODO: Rename to edgeIndexMap_ since this is a base class
104102
unique_ptr<EdgeIndexMap> synapseIndexMap_;
105103

106104
log4cplus::Logger fileLogger_;
107105
log4cplus::Logger edgeLogger_;
108106
};
109107

108+
/// TODO: Rename to synapseIndexMap since this is a base class
110109
/// Cereal serialization method
111110
template <class Archive> void Connections::serialize(Archive &archive)
112111
{

Simulator/Connections/Neuro/ConnGrowth.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ void ConnGrowth::updateOverlap()
240240
/// To be clear, iterates through all source and destination neurons
241241
/// and updates their synaptic strengths from the weight matrix.
242242
/// Note: Platform Dependent.
243-
void ConnGrowth::updateSynapsesWeights()
243+
void ConnGrowth::updateEdgesWeights()
244244
{
245245
int numVertices = Simulator::getInstance().getTotalVertices();
246246
AllNeuroEdges &synapses = dynamic_cast<AllNeuroEdges &>(*edges_);

Simulator/Connections/Neuro/ConnGrowth.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@ class ConnGrowth : public Connections {
103103

104104
/// Update the connections status in every epoch.
105105
///
106-
/// @param neurons The Neuron list to search from.
106+
/// @param vertices The vertex list to search from.
107107
/// @return true if successful, false otherwise.
108-
virtual bool updateConnections(AllVertices &neurons) override;
108+
virtual bool updateConnections(AllVertices &vertices) override;
109109

110110
/// Cereal serialization method
111111
template <class Archive> void serialize(Archive &archive);
@@ -121,20 +121,20 @@ class ConnGrowth : public Connections {
121121
///
122122
/// @param numVertices The number of vertices to update.
123123
/// @param vertices The AllVertices object.
124-
/// @param synapses The AllEdges object.
124+
/// @param edges The AllEdges object.
125125
/// @param allVerticesDevice GPU address of the AllVertices struct in device memory.
126126
/// @param allEdgesDevice GPU address of the AllEdges struct in device memory.
127127
/// @param layout The Layout object.
128-
virtual void updateSynapsesWeights(int numVertices, AllVertices &neurons, AllEdges &synapses,
129-
AllSpikingNeuronsDeviceProperties *allVerticesDevice,
130-
AllSpikingSynapsesDeviceProperties *allEdgesDevice,
131-
Layout &layout) override;
128+
virtual void updateEdgesWeights(int numVertices, AllVertices &vertices, AllEdges &edges,
129+
AllVerticesDeviceProperties *allVerticesDevice,
130+
AllEdgesDeviceProperties *allEdgesDevice,
131+
Layout &layout) override;
132132
#else
133133
/// Update the weights of the Synapses in the simulation. To be clear,
134134
/// iterates through all source and destination neurons and updates their
135135
/// synaptic strengths from the weight matrix.
136136
/// Note: Platform Dependent.
137-
virtual void updateSynapsesWeights() override;
137+
virtual void updateEdgesWeights() override;
138138

139139
#endif
140140
private:

Simulator/Connections/Neuro/ConnGrowth_d.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* @brief Update the weights of the Synapses in the simulation.
88
*/
99

10+
#include "AllSpikingNeurons.h"
1011
#include "AllSpikingSynapses.h"
1112
#include "AllSynapsesDeviceFuncs.h"
1213
#include "Book.h"
@@ -21,15 +22,14 @@
2122
*
2223
* @param numVertices The number of vertices to update.
2324
* @param vertices The AllVertices object.
24-
* @param synapses The AllEdges object.
25+
* @param edges The AllEdges object.
2526
* @param allVerticesDevice GPU address to the AllVertices struct in device memory.
2627
* @param allEdgesDevice GPU address to the AllEdges struct in device memory.
2728
* @param layout The Layout object.
2829
*/
29-
void ConnGrowth::updateSynapsesWeights(int numVertices, AllVertices &vertices, AllEdges &synapses,
30-
AllSpikingNeuronsDeviceProperties *allVerticesDevice,
31-
AllSpikingSynapsesDeviceProperties *allEdgesDevice,
32-
Layout &layout)
30+
void ConnGrowth::updateEdgesWeights(int numVertices, AllVertices &vertices, AllEdges &edges,
31+
AllVerticesDeviceProperties *allVerticesDevice,
32+
AllEdgesDeviceProperties *allEdgesDevice, Layout &layout)
3333
{
3434
Simulator &simulator = Simulator::getInstance();
3535
// For now, we just set the weights to equal the areas. We will later
@@ -66,7 +66,8 @@ void ConnGrowth::updateSynapsesWeights(int numVertices, AllVertices &vertices, A
6666
blocksPerGrid = (simulator.getTotalVertices() + threadsPerBlock - 1) / threadsPerBlock;
6767
updateSynapsesWeightsDevice<<<blocksPerGrid, threadsPerBlock>>>(
6868
simulator.getTotalVertices(), deltaT, W_d, simulator.getMaxEdgesPerVertex(),
69-
allVerticesDevice, allEdgesDevice, neuronTypeMapD);
69+
(AllSpikingNeuronsDeviceProperties *)allVerticesDevice,
70+
(AllSpikingSynapsesDeviceProperties *)allEdgesDevice, neuronTypeMapD);
7071

7172
// free memories
7273
HANDLE_ERROR(cudaFree(W_d));
@@ -75,7 +76,7 @@ void ConnGrowth::updateSynapsesWeights(int numVertices, AllVertices &vertices, A
7576
HANDLE_ERROR(cudaFree(neuronTypeMapD));
7677

7778
// copy device synapse count to host memory
78-
synapses.copyDeviceEdgeCountsToHost(allEdgesDevice);
79+
edges.copyDeviceEdgeCountsToHost(allEdgesDevice);
7980
// copy device synapse summation coordinate to host memory
80-
synapses.copyDeviceEdgeSumIdxToHost(allEdgesDevice);
81+
dynamic_cast<AllSpikingSynapses &>(edges).copyDeviceEdgeSumIdxToHost(allEdgesDevice);
8182
}

Simulator/Core/CPUModel.cpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
*/
88

99
#include "CPUModel.h"
10-
#include "AllDSSynapses.h"
1110
#include "Simulator.h"
1211

1312
#if !defined(USE_GPU)
@@ -23,30 +22,34 @@ void CPUModel::advance()
2322
{
2423
// ToDo: look at pointer v no pointer in params - to change
2524
// dereferencing the ptr, lose late binding -- look into changing!
26-
layout_->getVertices().advanceVertices(connections_->getEdges(),
27-
connections_->getEdgeIndexMap());
28-
connections_->getEdges().advanceEdges(layout_->getVertices(), connections_->getEdgeIndexMap());
25+
AllVertices &vertices = layout_->getVertices();
26+
AllEdges &edges = connections_->getEdges();
27+
EdgeIndexMap &edgeIndexMap = connections_->getEdgeIndexMap();
28+
29+
vertices.advanceVertices(edges, edgeIndexMap);
30+
edges.advanceEdges(vertices, edgeIndexMap);
31+
vertices.integrateVertexInputs(edges, edgeIndexMap);
2932
}
3033

31-
/// Update the connection of all the Neurons and Synapses of the simulation.
34+
/// Update the connection of all the vertices and edges of the simulation.
3235
void CPUModel::updateConnections()
3336
{
3437
// Update Connections data
3538
if (connections_->updateConnections(layout_->getVertices())) {
36-
connections_->updateSynapsesWeights();
37-
// create synapse inverse map
39+
connections_->updateEdgesWeights();
40+
// create edge inverse map
3841
connections_->createEdgeIndexMap();
3942
}
4043
}
4144

42-
/// Copy GPU Synapse data to CPU. (Inheritance, no implem)
45+
/// Copy GPU edge data to CPU. (Inheritance, no implem)
4346
void CPUModel::copyGPUtoCPU()
4447
{
4548
LOG4CPLUS_WARN(fileLogger_, "ERROR: CPUModel::copyGPUtoCPU() was called." << endl);
4649
exit(EXIT_FAILURE);
4750
}
4851

49-
/// Copy CPU Synapse data to GPU. (Inheritance, no implem, GPUModel has implem)
52+
/// Copy CPU edge data to GPU. (Inheritance, no implem, GPUModel has implem)
5053
void CPUModel::copyCPUtoGPU()
5154
{
5255
LOG4CPLUS_WARN(fileLogger_, "ERROR: CPUModel::copyCPUtoGPU() was called." << endl);

Simulator/Core/CPUModel.h

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,14 @@
66
* @brief Implementation of Model for execution on CPU (single core).
77
*
88
* The Model class maintains and manages classes of objects that make up
9-
* essential components of the spiking neural network.
10-
* -# AllVertices: A class to define a list of particular type of neurons.
11-
* -# AllEdges: A class to define a list of particular type of synapses.
12-
* -# Connections: A class to define connections of the neural network.
13-
* -# Layout: A class to define neurons' layout information in the network.
9+
* essential components of the graph network.
10+
* -# AllVertices: A class to define a list of particular type of vertices.
11+
* -# AllEdges: A class to define a list of particular type of edges.
12+
* -# Connections: A class to define connections of the graph network.
13+
* -# Layout: A class to define vertices' layout information in the network.
1414
*
15-
* The network is composed of 3 superimposed 2-d arrays: neurons, synapses, and
16-
* summation points.
17-
*
18-
* Synapses in the synapse map are located at the coordinates of the neuron
19-
* from which they receive output. Each synapse stores a pointer into a
20-
* summation point.
21-
*
22-
* If, during an advance cycle, a neuron \f$A\f$ at coordinates \f$x,y\f$ fires, every synapse
23-
* which receives output is notified of the spike. Those synapses then hold
24-
* the spike until their delay period is completed. At a later advance cycle, once the delay
25-
* period has been completed, the synapses apply their PSRs (Post-Synaptic-Response) to
26-
* the summation points.
27-
*
28-
* Finally, on the next advance cycle, each neuron \f$B\f$ adds the value stored
29-
* in their corresponding summation points to their \f$V_m\f$ and resets the summation points to
30-
* zero.
15+
* Edges in the edge map are located at the coordinates of the vertex
16+
* from which they receive output.
3117
*
3218
* The model runs on a single thread.
3319
*
@@ -54,13 +40,13 @@ class CPUModel : public Model {
5440
/// Advances network state one simulation step.
5541
virtual void advance() override;
5642

57-
/// Modifies connections between neurons based on current state of the network and behavior
43+
/// Modifies connections between vertices based on current state of the network and behavior
5844
/// over the past epoch. Should be called once every epoch.
5945
virtual void updateConnections() override;
6046

61-
/// Copy GPU Synapse data to CPU.
47+
/// Copy GPU edge data to CPU.
6248
virtual void copyGPUtoCPU() override;
6349

64-
/// Copy CPU Synapse data to GPU.
50+
/// Copy CPU edge data to GPU.
6551
virtual void copyCPUtoGPU() override;
6652
};

0 commit comments

Comments
 (0)