7#define BOOST_TEST_DYN_LINK
8#define DISABLE_MPI_WRITTERS
10#include <boost/test/unit_test.hpp>
11#include "performancePlots.hpp"
13#include "SparseGridGpu/SparseGridGpu.hpp"
14#include "SparseGridGpu/tests/utils/SparseGridGpu_util_test.cuh"
17extern std::string suiteURI;
19extern std::set<std::string> testSet;
22template<
unsigned int blockEdgeSize,
unsigned int gr
idEdgeSize>
23void testGetSingle(std::string testURI,
unsigned int i)
25 auto testName =
"Get single";
26 constexpr unsigned int dim = 2;
31 unsigned int iterations = 10;
34 std::string base(testURI +
"(" + std::to_string(i) +
")");
35 report_sparsegrid_funcs.graphs.put(base +
".test.name",
"Get");
37 report_sparsegrid_funcs.graphs.put(base +
".dim",dim);
38 report_sparsegrid_funcs.graphs.put(base +
".blockSize",blockEdgeSize);
39 report_sparsegrid_funcs.graphs.put(base +
".gridSize.x",gridEdgeSize*blockEdgeSize);
40 report_sparsegrid_funcs.graphs.put(base +
".gridSize.y",gridEdgeSize*blockEdgeSize);
42 dim3 gridSize(gridEdgeSize, gridEdgeSize);
43 dim3 blockSize(blockEdgeSize, blockEdgeSize);
44 dim3 blockSizeBlockedInsert(1, 1);
48 sparseGrid.template setBackgroundValue<0>(0);
52 sparseGrid.setGPUInsertBuffer(gridSize, blockSizeBlockedInsert);
53 insertValues2DBlocked<0, 1, blockEdgeSize> << < gridSize, blockSize >> >
54 (sparseGrid.toKernel(), offset, offset);
55 sparseGrid.template flush < smax_ < 0 >> (ctx, flush_type::FLUSH_ON_DEVICE);
57 unsigned long long numElements = gridEdgeSize*blockEdgeSize*gridEdgeSize*blockEdgeSize;
60 for (
unsigned int iter=0; iter<iterations; ++iter)
64 cudaDeviceSynchronize();
69 getValues2D<0> << < gridSize, blockSize >> > (sparseGrid.toKernel(), offset, offset);
70 cudaDeviceSynchronize();
74 float gElemS = numElements / (1e9 * ts.
getwct());
80 standard_deviation(measures,mean,deviation);
82 report_sparsegrid_funcs.graphs.put(base +
".Gget.mean",mean);
83 report_sparsegrid_funcs.graphs.put(base +
".Gget.dev",deviation);
87 std::cout <<
"Test: " << testName <<
"\n";
88 std::cout <<
"Block: " << blockEdgeSize <<
"x" << blockEdgeSize <<
"\n";
89 std::cout <<
"Grid: " << gridEdgeSize*blockEdgeSize <<
"x" << gridEdgeSize*blockEdgeSize <<
"\n";
90 double dataOccupancyMean, dataOccupancyDev;
91 sparseGrid.deviceToHost();
92 sparseGrid.measureBlockOccupancy(dataOccupancyMean, dataOccupancyDev);std::cout <<
"Data Occupancy: " << dataOccupancyMean <<
" dev:" << dataOccupancyDev << std::endl;
93 report_sparsegrid_funcs.graphs.put(base +
".dataOccupancy.mean",dataOccupancyMean);
94 report_sparsegrid_funcs.graphs.put(base +
".dataOccupancy.dev",dataOccupancyDev);
95 std::cout <<
"Iterations: " << iterations <<
"\n";
96 std::cout <<
"Throughput:\n\t" << mean <<
"GElem/s" <<
"\n";
99BOOST_AUTO_TEST_SUITE(performance)
101BOOST_AUTO_TEST_SUITE(SparseGridGpu_test)
103BOOST_AUTO_TEST_CASE(testGet_gridScaling_2)
105 std::string testURI = suiteURI +
".device.get.dense.single.2D.2.gridScaling";
106 unsigned int counter = 0;
107 testGetSingle<2, 128>(testURI, counter++);
108 testGetSingle<2, 256>(testURI, counter++);
109 testGetSingle<2, 512>(testURI, counter++);
110 testGetSingle<2, 1024>(testURI, counter++);
111 testGetSingle<2, 2048>(testURI, counter++);
112 testGetSingle<2, 4096>(testURI, counter++);
113 testSet.insert(testURI);
116BOOST_AUTO_TEST_CASE(testGet_gridScaling_4)
118 std::string testURI = suiteURI +
".device.get.dense.single.2D.4.gridScaling";
119 unsigned int counter = 0;
120 testGetSingle<4, 64>(testURI, counter++);
121 testGetSingle<4, 128>(testURI, counter++);
122 testGetSingle<4, 256>(testURI, counter++);
123 testGetSingle<4, 512>(testURI, counter++);
124 testGetSingle<4, 1024>(testURI, counter++);
125 testGetSingle<4, 2048>(testURI, counter++);
126 testSet.insert(testURI);
129BOOST_AUTO_TEST_CASE(testGet_gridScaling_8)
131 std::string testURI = suiteURI +
".device.get.dense.single.2D.8.gridScaling";
132 unsigned int counter = 0;
133 testGetSingle<8, 32>(testURI, counter++);
134 testGetSingle<8, 64>(testURI, counter++);
135 testGetSingle<8, 128>(testURI, counter++);
136 testGetSingle<8, 256>(testURI, counter++);
137 testGetSingle<8, 512>(testURI, counter++);
138 testGetSingle<8, 1024>(testURI, counter++);
139 testSet.insert(testURI);
142BOOST_AUTO_TEST_CASE(testGet_gridScaling_16)
144 std::string testURI = suiteURI +
".device.get.dense.single.2D.16.gridScaling";
145 unsigned int counter = 0;
146 testGetSingle<16, 16>(testURI, counter++);
147 testGetSingle<16, 32>(testURI, counter++);
148 testGetSingle<16, 64>(testURI, counter++);
149 testGetSingle<16, 128>(testURI, counter++);
150 testGetSingle<16, 256>(testURI, counter++);
151 testGetSingle<16, 512>(testURI, counter++);
152 testSet.insert(testURI);
155BOOST_AUTO_TEST_CASE(testGet_gridScaling_32)
157 std::string testURI = suiteURI +
".device.get.dense.single.2D.32.gridScaling";
158 unsigned int counter = 0;
159 testGetSingle<32, 8>(testURI, counter++);
160 testGetSingle<32, 16>(testURI, counter++);
161 testGetSingle<32, 32>(testURI, counter++);
162 testGetSingle<32, 64>(testURI, counter++);
163 testGetSingle<32, 128>(testURI, counter++);
164 testGetSingle<32, 256>(testURI, counter++);
165 testSet.insert(testURI);
168BOOST_AUTO_TEST_CASE(testGet_blockScaling)
170 std::string testURI = suiteURI +
".device.get.dense.single.2D.blockScaling";
171 unsigned int counter = 0;
172 testGetSingle<2, 1024>(testURI, counter++);
173 testGetSingle<4, 512>(testURI, counter++);
174 testGetSingle<8, 256>(testURI, counter++);
175 testGetSingle<16, 128>(testURI, counter++);
176 testGetSingle<32, 64>(testURI, counter++);
178 testSet.insert(testURI);
181BOOST_AUTO_TEST_SUITE_END()
183BOOST_AUTO_TEST_SUITE_END()
Implementation of 1-D std::vector like structure.
Class for cpu time benchmarking.
void stop()
Stop the timer.
void start()
Start the timer.
double getwct()
Return the elapsed real time.
aggregate of properties, from a list of object if create a struct that follow the OPENFPM native stru...