GeNN  2.2.3
GPU enhanced Neuronal Networks (GeNN)
simulation_test.h
Go to the documentation of this file.
1 #pragma once
2 
3 // Google test includes
4 #include "gtest/gtest.h"
5 
6 //----------------------------------------------------------------------------
7 // SimulationTest
8 //----------------------------------------------------------------------------
9 class SimulationTest : public ::testing::TestWithParam<bool>
10 {
11 protected:
12  //--------------------------------------------------------------------------
13  // test virtuals
14  //--------------------------------------------------------------------------
15  virtual void SetUp()
16  {
17  // Perform GeNN initialization
18  allocateMem();
19  initialize();
20 
21  Init();
22 
23 #ifndef CPU_ONLY
24  if(GetParam())
25  {
26  copyStateToDevice();
27  }
28 #endif // CPU_ONLY
29  }
30 
31  virtual void TearDown()
32  {
33  freeMem();
34  }
35 
36  //--------------------------------------------------------------------------
37  // Declared virtuals
38  //--------------------------------------------------------------------------
39  virtual void Init() = 0;
40 
41  //--------------------------------------------------------------------------
42  // Protected methods
43  //--------------------------------------------------------------------------
44  void StepGeNN()
45  {
46 #ifndef CPU_ONLY
47  if(GetParam())
48  {
49  stepTimeGPU();
50  copyStateFromDevice();
51  }
52  else
53 #endif // CPU_ONLY
54  {
55  stepTimeCPU();
56  }
57  }
58 };
virtual void SetUp()
Definition: simulation_test.h:15
virtual void Init()=0
Definition: simulation_test.h:9
void StepGeNN()
Definition: simulation_test.h:44
virtual void TearDown()
Definition: simulation_test.h:31