2222#pragma once
2323
2424#include " AllEdges.h"
25+ #include " AllSpikingNeurons.h"
26+ #include " AllSpikingSynapses.h"
2527#include " AllVertices.h"
28+ #include " OperationManager.h"
2629
2730#ifdef VALIDATION_MODE
2831 #include < fstream>
@@ -81,25 +84,33 @@ class GPUModel : public Model {
8184 // / over the past epoch. Should be called once every epoch.
8285 virtual void updateConnections () override ;
8386
84- // / Copy GPU edge data to CPU.
85- virtual void copyGPUtoCPU () override ;
86-
87- // / Copy CPU edge data to GPU .
87+ // / Copies neuron and synapse data from CPU to GPU memory .
88+ // / TODO: Refactor this. Currently, GPUModel handles low-level memory transfer for vertices and edges.
89+ // / Consider moving this responsibility to a more appropriate class, such as a dedicated memory manager
90+ // / or the OperationManager, to better separate concerns and keep the model focused on high-level coordination .
8891 virtual void copyCPUtoGPU () override ;
8992
93+ // GPUModel itself does not have anything to be copied back, this function is a
94+ // dummy function just to make GPUModel non virtual
95+ virtual void copyGPUtoCPU () override
96+ {
97+ }
98+
9099 // / Print out EdgeProps on the GPU.
91100 void printGPUEdgesPropsModel () const ;
92101
102+ // / Getter for edge (synapse) structures in device memory
103+ AllEdgesDeviceProperties *&getAllEdgesDevice ();
104+
105+ // / Getter for vertex (neuron) structures in device memory
106+ AllVerticesDeviceProperties *&getAllVerticesDevice ();
107+
93108protected:
94109 // / Allocates and initializes memories on CUDA device.
95- // / @param[out] allVerticesDevice Memory location of the pointer to the vertices list on device memory.
96- // / @param[out] allEdgesDevice Memory location of the pointer to the edges list on device memory.
97- void allocDeviceStruct (void **allVerticesDevice, void **allEdgesDevice);
110+ void allocDeviceStruct ();
98111
99- // / Copies device memories to host memories and deallocates them.
100- // / @param[out] allVerticesDevice Memory location of the pointer to the vertices list on device memory.
101- // / @param[out] allEdgesDevice Memory location of the pointer to the edges list on device memory.
102- virtual void deleteDeviceStruct (void **allVerticesDevice, void **allEdgesDevice);
112+ // / Deallocates device memories.
113+ virtual void deleteDeviceStruct ();
103114
104115 // / Pointer to device random noise array.
105116 float *randNoise_d;
@@ -118,11 +129,6 @@ class GPUModel : public Model {
118129private:
119130 void allocEdgeIndexMap (int count);
120131
121- void deleteEdgeIndexMap ();
122-
123- public: // 2020/03/14 changed to public for accessing in Core
124- void copyEdgeIndexMapHostToDevice (EdgeIndexMap &edgeIndexMapHost, int numVertices);
125-
126132private:
127133 void updateHistory ();
128134
@@ -144,4 +150,4 @@ void normalMTGPU(float *randNoise_d);
144150void initMTGPU (unsigned int seed, unsigned int blocks, unsigned int threads, unsigned int nPerRng,
145151 unsigned int mt_rng_count);
146152}
147- #endif
153+ #endif
0 commit comments