OpenFPM_pdata  1.1.0
Project that contain the implementation of distributed structures
 All Data Structures Namespaces Functions Variables Typedefs Enumerations Friends Pages
grid_performance_tests.hpp
1 /*
2  * grid_performance_tests.hpp
3  *
4  * Created on: Nov 1, 2015
5  * Author: i-bird
6  */
7 
8 #ifndef OPENFPM_DATA_SRC_GRID_GRID_PERFORMANCE_TESTS_HPP_
9 #define OPENFPM_DATA_SRC_GRID_GRID_PERFORMANCE_TESTS_HPP_
10 
11 #include "grid_util_test.hpp"
12 
14 openfpm::vector<float> per_timesg;
15 
16 BOOST_AUTO_TEST_CASE(grid_performance_set_obj)
17 {
18  size_t sz[] = {128,128,128};
19 
21  c3.setMemory();
22 
23  fill_grid<3>(c3);
24 
25  Point_test<float> f __attribute__((aligned(16)));
26  f.fill();
27 
28  std::vector<double> times(N_STAT + 1);
29  times[0] = 1000;
30 
31  for (size_t j = 0 ; j < 8 ; j++)
32  {
33  for (size_t i = 1 ; i < N_STAT+1 ; i++)
34  {
35  timer t;
36  t.start();
37 
38  auto it = c3.getIterator();
39 
40  while (it.isNext())
41  {
42  c3.set(it.get(),f);
43 
44  ++it;
45  }
46 
47  t.stop();
48 
49  times[i] = t.getwct();
50  }
51  std::sort(times.begin(),times.end());
52  sleep(5);
53  }
54 
55  testsg.add("Grid so");
56  per_timesg.add(times[0]);
57 
58 }
59 
60 BOOST_AUTO_TEST_CASE(grid_performance_set_other_grid)
61 {
62  size_t sz[] = {128,128,128};
63 
65  c3.setMemory();
66 
67  fill_grid<3>(c3);
69  c1.setMemory();
70 
71  std::vector<double> times(N_STAT + 1);
72  times[0] = 1000;
73 
74  for (size_t j = 0 ; j < 8 ; j++)
75  {
76  for (size_t i = 1 ; i < N_STAT+1 ; i++)
77  {
78  timer t;
79  t.start();
80 
81  auto it = c3.getIterator();
82 
83  while (it.isNext())
84  {
85  c3.set(it.get(),c1,it.get());
86 
87  ++it;
88  }
89 
90  t.stop();
91 
92  times[i] = t.getwct();
93  }
94  std::sort(times.begin(),times.end());
95  sleep(5);
96  }
97 
98  testsg.add("Grid sog");
99  per_timesg.add(times[0]);
100 
101 }
102 
103 BOOST_AUTO_TEST_CASE(grid_performance_set_other_grid_encap)
104 {
105  size_t sz[] = {128,128,128};
106 
108  c3.setMemory();
109 
110  fill_grid<3>(c3);
112  c1.setMemory();
113 
114  std::vector<double> times(N_STAT + 1);
115  times[0] = 1000;
116 
117  for (size_t j = 0 ; j < 8 ; j++)
118  {
119  for (size_t i = 1 ; i < N_STAT+1 ; i++)
120  {
121  timer t;
122  t.start();
123 
124  auto it = c3.getIterator();
125 
126  while (it.isNext())
127  {
128  c3.set(it.get(),c1.get_o(it.get()));
129 
130  ++it;
131  }
132 
133  t.stop();
134 
135  times[i] = t.getwct();
136  }
137  std::sort(times.begin(),times.end());
138  sleep(5);
139  }
140 
141  testsg.add("Grid soge");
142  per_timesg.add(times[0]);
143 }
144 
145 BOOST_AUTO_TEST_CASE(grid_performance_duplicate)
146 {
147  size_t sz[] = {128,128,128};
148 
150  c3.setMemory();
151 
152  fill_grid<3>(c3);
154 
155  std::vector<double> times(N_STAT_SMALL + 1);
156  times[0] = 1000;
157 
158  for (size_t j = 0 ; j < 8 ; j++)
159  {
160  for (size_t i = 1 ; i < N_STAT_SMALL+1 ; i++)
161  {
162  timer t;
163  t.start();
164 
165  c1 = c3.duplicate();
166 
167  t.stop();
168 
169  times[i] = t.getwct();
170  }
171  std::sort(times.begin(),times.end());
172  sleep(5);
173  }
174 
175  testsg.add("Grid dup");
176  per_timesg.add(times[0]);
177 }
178 
180 
181 BOOST_AUTO_TEST_CASE(grid_performance_write_report)
182 {
185 
186  // Get the directory of the performance test files
187  std::string per_dir(test_dir);
188 
189  // Reference time
191  y_ref.load(per_dir + std::string("/openfpm_data/ref_timesg"));
192 
193  load_and_combine(per_dir + std::string("/openfpm_data/previous_measureg"),y,per_timesg);
194 
195  // Adding the dataset names
196  if (y.size() != 0)
197  {
198  for (size_t j = 0; j < y.get(0).size(); j++)
199  yn.add("config " + std::to_string(j));
200  }
201 
202  // Google charts options
203  GCoptions options;
204 
205  options.title = std::string("Grid Performances");
206  options.yAxis = std::string("Time (seconds)");
207  options.xAxis = std::string("Benchmark");
208  options.stype = std::string("bars");
209 
210  std::stringstream g_test_desc;
211  g_test_desc << "<h2>Grid performance test</h2>\n";
212  g_test_desc << "<strong>128x128x128 Grid containing a Point_test<float></strong><br>";
213  g_test_desc << "<strong>Grid so:</strong> Initialize each element of the grid<br>";
214  g_test_desc << "<strong>Grid sog:</strong> Manual copy of two grids<br>";
215  g_test_desc << "<strong>Grid soge:</strong> Manual copy of two grids in a different way<br>";
216  g_test_desc << "<strong>Grid dup:</strong> Duplication of the grid (Duplication include grid creation time)<br>";
217 
218 
219  cg.addHTML(g_test_desc.str());
220  cg.AddHistGraph(testsg,y,yn,options);
221 
222  // compare the reference times with the actual times
223 
224  // calculate speed-up
226 
227  speedup_calculate(y_ref_sup,y,y_ref,yn);
228 
229  std::stringstream g_test_spdesc;
230  g_test_spdesc << "<h2>Grid speedup</h2>\n";
231  g_test_spdesc << "The previous tests are compared with the best performances ever registered, ";
232  g_test_spdesc << "the banded area indicate the upper and lower bounds of the best registrered performances.<br>";
233  g_test_spdesc << "The lines are the latest 5 tests<br>";
234  g_test_spdesc << "<strong>Line inside the area</strong>: The tested configuration has no improvement or degradation in performance<br>";
235  g_test_spdesc << "<strong>Line break the upper bound</strong>: The tested configuration has improvement in performance<br>";
236  g_test_spdesc << "<strong>Line break the lower bound</strong>: The tested configuration has degradation in performance<br>";
237  g_test_spdesc << "<strong>Y axis:</strong> Performance change in percentage from the average of the best registered performances<br>";
238 
239 
240  cg.addHTML(g_test_spdesc.str());
241  cg.AddLinesGraph(testsg,y_ref_sup,yn,options);
242 }
243 
244 #endif /* OPENFPM_DATA_SRC_GRID_GRID_PERFORMANCE_TESTS_HPP_ */
std::string title
Title of the chart.
Definition: GoogleChart.hpp:27
size_t size()
Stub size.
Definition: map_vector.hpp:70
double getwct()
Return the elapsed real time.
Definition: timer.hpp:108
std::string yAxis
Y axis name.
Definition: GoogleChart.hpp:29
void start()
Start the timer.
Definition: timer.hpp:73
std::string stype
Definition: GoogleChart.hpp:37
Test structure used for several test.
Definition: Point_test.hpp:105
std::string xAxis
X axis name.
Definition: GoogleChart.hpp:31
Google chart options.
Definition: GoogleChart.hpp:24
Class for cpu time benchmarking.
Definition: timer.hpp:25
void stop()
Stop the timer.
Definition: timer.hpp:97