OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
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/grid_util_test.hpp"
12#include "util/stat/common_statistics.hpp"
13
14// Property tree
16{
17 boost::property_tree::ptree graphs;
18};
19
20report_grid_copy_func_tests report_grid_funcs;
21
22BOOST_AUTO_TEST_SUITE( grid_performance )
23
24BOOST_AUTO_TEST_CASE(grid_performance_set_obj)
25{
26 size_t sz[] = {128,128,128};
27
28 report_grid_funcs.graphs.put("performance.grid.set(0).grid.x",sz[0]);
29 report_grid_funcs.graphs.put("performance.grid.set(0).grid.y",sz[1]);
30 report_grid_funcs.graphs.put("performance.grid.set(0).grid.z",sz[2]);
31
33 c3.setMemory();
34
35 fill_grid<3>(c3);
36
37 Point_test<float> f __attribute__((aligned(16)));
38 f.fill();
39
40 std::vector<double> times(N_STAT + 1);
41
42 for (size_t i = 0 ; i < N_STAT+1 ; i++)
43 {
44 timer t;
45 t.start();
46
47 auto it = c3.getIterator();
48
49 while (it.isNext())
50 {
51 c3.set(it.get(),f);
52
53 ++it;
54 }
55
56 t.stop();
57
58 times[i] = t.getwct();
59 }
60
61 double mean;
62 double dev;
63 standard_deviation(times,mean,dev);
64
65 report_grid_funcs.graphs.put("performance.grid.set(0).x.data.name","Grid_so");
66 report_grid_funcs.graphs.put("performance.grid.set(0).y.data.mean",mean);
67 report_grid_funcs.graphs.put("performance.grid.set(0).y.data.dev",dev);
68}
69
70BOOST_AUTO_TEST_CASE(grid_performance_set_other_grid)
71{
72 size_t sz[] = {128,128,128};
73
74 report_grid_funcs.graphs.put("performance.grid.set(1).grid.x",sz[0]);
75 report_grid_funcs.graphs.put("performance.grid.set(1).grid.y",sz[1]);
76 report_grid_funcs.graphs.put("performance.grid.set(1).grid.z",sz[2]);
77
79 c3.setMemory();
80
81 fill_grid<3>(c3);
83 c1.setMemory();
84
85 std::vector<double> times(N_STAT + 1);
86
87 for (size_t i = 0 ; i < N_STAT+1 ; i++)
88 {
89 timer t;
90 t.start();
91
92 auto it = c3.getIterator();
93
94 while (it.isNext())
95 {
96 c3.set(it.get(),c1,it.get());
97
98 ++it;
99 }
100
101 t.stop();
102
103 times[i] = t.getwct();
104 }
105 std::sort(times.begin(),times.end());
106
107 double mean;
108 double dev;
109 standard_deviation(times,mean,dev);
110
111 report_grid_funcs.graphs.put("performance.grid.set(1).x.data.name","Grid_sog");
112 report_grid_funcs.graphs.put("performance.grid.set(1).y.data.mean",mean);
113 report_grid_funcs.graphs.put("performance.grid.set(1).y.data.dev",dev);
114}
115
116BOOST_AUTO_TEST_CASE(grid_performance_set_other_grid_encap)
117{
118 size_t sz[] = {128,128,128};
119
120 report_grid_funcs.graphs.put("performance.grid.set(2).grid.x",sz[0]);
121 report_grid_funcs.graphs.put("performance.grid.set(2).grid.y",sz[1]);
122 report_grid_funcs.graphs.put("performance.grid.set(2).grid.z",sz[2]);
123
125 c3.setMemory();
126
127 fill_grid<3>(c3);
129 c1.setMemory();
130
131 std::vector<double> times(N_STAT + 1);
132
133 for (size_t i = 0 ; i < N_STAT+1 ; i++)
134 {
135 timer t;
136 t.start();
137
138 auto it = c3.getIterator();
139
140 while (it.isNext())
141 {
142 c3.set(it.get(),c1.get_o(it.get()));
143
144 ++it;
145 }
146
147 t.stop();
148
149 times[i] = t.getwct();
150 }
151
152 double mean;
153 double dev;
154 standard_deviation(times,mean,dev);
155
156 report_grid_funcs.graphs.put("performance.grid.set(2).x.data.name","Grid_soge");
157 report_grid_funcs.graphs.put("performance.grid.set(2).y.data.mean",mean);
158 report_grid_funcs.graphs.put("performance.grid.set(2).y.data.dev",dev);
159}
160
161BOOST_AUTO_TEST_CASE(grid_performance_duplicate)
162{
163 size_t sz[] = {128,128,128};
164
165 report_grid_funcs.graphs.put("performance.grid.set(3).grid.x",sz[0]);
166 report_grid_funcs.graphs.put("performance.grid.set(3).grid.y",sz[1]);
167 report_grid_funcs.graphs.put("performance.grid.set(3).grid.z",sz[2]);
168
170 c3.setMemory();
171
172 fill_grid<3>(c3);
174
175 std::vector<double> times(N_STAT_SMALL + 1);
176
177 for (size_t i = 0 ; i < N_STAT_SMALL+1 ; i++)
178 {
179 timer t;
180 t.start();
181
182 c1 = c3.duplicate();
183
184 t.stop();
185
186 times[i] = t.getwct();
187 }
188
189 double mean;
190 double dev;
191 standard_deviation(times,mean,dev);
192
193 report_grid_funcs.graphs.put("performance.grid.set(3).x.data.name","Grid_dup");
194 report_grid_funcs.graphs.put("performance.grid.set(3).y.data.mean",mean);
195 report_grid_funcs.graphs.put("performance.grid.set(3).y.data.dev",dev);
196}
197
199
200BOOST_AUTO_TEST_CASE(grid_performance_write_report)
201{
202 // Create a graphs
203
204 report_grid_funcs.graphs.put("graphs.graph(0).type","line");
205 report_grid_funcs.graphs.add("graphs.graph(0).title","Grid set functions (so/sog/soge) and duplicate (dup) performance");
206 report_grid_funcs.graphs.add("graphs.graph(0).x.title","Tests");
207 report_grid_funcs.graphs.add("graphs.graph(0).y.title","Time seconds");
208 report_grid_funcs.graphs.add("graphs.graph(0).y.data(0).source","performance.grid.set(#).y.data.mean");
209 report_grid_funcs.graphs.add("graphs.graph(0).x.data(0).source","performance.grid.set(#).x.data.name");
210 report_grid_funcs.graphs.add("graphs.graph(0).y.data(0).title","Actual");
211 report_grid_funcs.graphs.add("graphs.graph(0).interpolation","lines");
212
213 boost::property_tree::xml_writer_settings<std::string> settings(' ', 4);
214 boost::property_tree::write_xml("grid_performance_funcs.xml", report_grid_funcs.graphs,std::locale(),settings);
215
216 GoogleChart cg;
217
218 std::string file_xml_ref(test_dir);
219 file_xml_ref += std::string("/openfpm_data/grid_performance_funcs_ref.xml");
220
221 StandardXMLPerformanceGraph("grid_performance_funcs.xml",file_xml_ref,cg);
222
223 addUpdateTime(cg,1,"data","grid_performance_funcs");
224 createCommitFile("data");
225
226 cg.write("grid_performance_funcs.html");
227}
228
229BOOST_AUTO_TEST_SUITE_END()
230
231#endif /* OPENFPM_DATA_SRC_GRID_GRID_PERFORMANCE_TESTS_HPP_ */
Small class to produce graph with Google chart in HTML.
void write(std::string file)
It write the graphs on file in html format using Google charts.
Test structure used for several test.
Class for cpu time benchmarking.
Definition timer.hpp:28
void stop()
Stop the timer.
Definition timer.hpp:119
void start()
Start the timer.
Definition timer.hpp:90
double getwct()
Return the elapsed real time.
Definition timer.hpp:130