8#ifndef SRC_GRID_GRID_DIST_PERFORMANCE_HPP_
9#define SRC_GRID_GRID_DIST_PERFORMANCE_HPP_
11#define GRID_ITERATOR_TESTS 30
12#define GRID_INTERPOLATION_TESTS 30
21 boost::property_tree::ptree graphs;
26BOOST_AUTO_TEST_SUITE( grid_iterator_performance_test )
37 boost::property_tree::ptree & interpolation_graph)
39 for (
size_t k = 0 ; k < nk_grid.
size() ; k++)
41 size_t np = nk_grid.get(k);
42 size_t sz[] = {np,np,np};
48 size_t tot_part = np*np*np;
50 std::string base_p2m =
"performance.interpolation.p2m(" + std::to_string(k) +
")";
51 std::string base_m2p =
"performance.interpolation.m2p(" + std::to_string(k) +
")";
53 interpolation_graph.put(base_p2m +
".grid.dim",3);
54 interpolation_graph.put(base_m2p +
".grid.dim",3);
56 interpolation_graph.put(base_p2m +
".grid.x",np);
57 interpolation_graph.put(base_p2m +
".grid.y",np);
58 interpolation_graph.put(base_p2m +
".grid.z",np);
60 interpolation_graph.put(base_m2p +
".grid.x",np);
61 interpolation_graph.put(base_m2p +
".grid.y",np);
62 interpolation_graph.put(base_m2p +
".grid.z",np);
64 interpolation_graph.put(base_p2m +
".particles",tot_part);
65 interpolation_graph.put(base_m2p +
".particles",tot_part);
72 auto vd_it = vd.getDomainIterator();
74 while (vd_it.isNext())
79 vd.getPos(p)[0] = ((float)std::rand()) / RAND_MAX;
80 vd.getPos(p)[1] = ((float)std::rand()) / RAND_MAX;
81 vd.getPos(p)[2] = ((float)std::rand()) / RAND_MAX;
83 vd.template getProp<0>(p) = 1.0;
93 for (
size_t j = 0 ; j < GRID_INTERPOLATION_TESTS ; j++)
101 inte.p2m<0,0>(vd,gd);
104 measures.add(tstl.
getwct());
106 standard_deviation(measures,mean,dev);
108 interpolation_graph.put(base_p2m +
".data.mean",mean);
109 interpolation_graph.put(base_p2m +
".data.dev",dev);
111 std::cout <<
"Time particles to mesh " << mean << std::endl;
114 for (
size_t j = 0 ; j < GRID_INTERPOLATION_TESTS ; j++)
122 inte.m2p<0,0>(gd,vd);
125 measures.add(tstl.
getwct());
127 standard_deviation(measures,mean,dev);
129 interpolation_graph.put(base_m2p +
".data.mean",mean);
130 interpolation_graph.put(base_m2p +
".data.dev",dev);
132 std::cout <<
"Time mesh to particles " << mean << std::endl;
153 auto st_it = g_dist.getDomainIteratorStencil(star_stencil_3D);
155 while (st_it.isNext())
158 total+= 6*g_dist.template get<0>(st_it.getStencil<0>()) -
159 g_dist.template get<0>(st_it.getStencil<1>()) -
160 g_dist.template get<0>(st_it.getStencil<2>()) -
161 g_dist.template get<0>(st_it.getStencil<3>()) -
162 g_dist.template get<0>(st_it.getStencil<4>()) -
163 g_dist.template get<0>(st_it.getStencil<5>()) -
164 g_dist.template get<0>(st_it.getStencil<6>());
178 auto norm_it = g_dist.getDomainIterator();
180 while (norm_it.isNext())
183 auto key = norm_it.get();
185 total+= 6*g_dist.template get<0>(key) -
186 g_dist.template get<0>(key.move(x,-1)) -
187 g_dist.template get<0>(key.move(x,1)) -
188 g_dist.template get<0>(key.move(y,-1)) -
189 g_dist.template get<0>(key.move(y,1)) -
190 g_dist.template get<0>(key.move(z,-1)) -
191 g_dist.template get<0>(key.move(z,1));
204 boost::property_tree::ptree & iterator_graph)
206 std::string str(
"Testing " + std::to_string(dim) +
"D grid iterator stencil and normal");
211 for (
size_t i = 0; i < nk_grid.
size(); i++ )
216 size_t k = nk_grid.get(i);
218 std::string base =
"performance.grid.iterators(" + std::to_string(i) +
")";
219 iterator_graph.put(base +
".grid.dim",3);
221 iterator_graph.put(base +
".grid.x",k);
222 iterator_graph.put(base +
".grid.y",k);
223 iterator_graph.put(base +
".grid.z",k);
225 BOOST_TEST_CHECKPOINT(
"Testing " << dim <<
"D grid iterator performance k=" << k );
229 for (
size_t i = 0; i < dim; i++)
243 auto it = g_dist.getDomainGhostIterator();
248 auto gkey = it.getGKey(p);
250 g_dist.template get<0>(p) = gkey.get(0) + gkey.get(1) + gkey.get(2);
255 g_dist.ghost_get<0>();
263 for (
size_t j = 0 ; j < GRID_ITERATOR_TESTS ; j++)
264 {measures.add(grid_iterator_benchmark_stencil(g_dist,total));}
265 standard_deviation(measures,mean,dev);
267 iterator_graph.put(base +
".stencil.data.mean",mean);
268 iterator_graph.put(base +
".stencil.data.dev",dev);
270 std::cout <<
"Size: " << nk_grid.get(i) <<
" stencil: " << mean << std::endl;
275 for (
size_t j = 0 ; j < GRID_ITERATOR_TESTS ;j++)
276 {measures.add(grid_iterator_benchmark_norm(g_dist,total));}
277 standard_deviation(measures,mean,dev);
279 iterator_graph.put(base +
".normal.data.mean",mean);
280 iterator_graph.put(base +
".normal.data.dev",dev);
282 std::cout <<
"Size: " << nk_grid.get(i) <<
" normal: " << mean << std::endl;
289BOOST_AUTO_TEST_CASE( grid_interpolation_benchmark_test )
292 nk_grid_int.add(128);
293 nk_grid_int.add(192);
296 grid_interpolation_benchmark(nk_grid_int,
297 report_grid_iterator.graphs);
300BOOST_AUTO_TEST_CASE( grid_iterator_benchmark_test )
307 grid_iterator_benchmark<3>(nk_grid_st,
308 report_grid_iterator.graphs);
312BOOST_AUTO_TEST_CASE(grid_iterator_performance_write_report_final)
314 report_grid_iterator.graphs.put(
"graphs.graph(0).type",
"line");
315 report_grid_iterator.graphs.add(
"graphs.graph(0).title",
"Grid iterators performance for stencil");
316 report_grid_iterator.graphs.add(
"graphs.graph(0).x.title",
"Number of grid points");
317 report_grid_iterator.graphs.add(
"graphs.graph(0).y.title",
"Time seconds");
318 report_grid_iterator.graphs.add(
"graphs.graph(0).y.data(0).source",
"performance.grid.iterators(#).normal.data.mean");
319 report_grid_iterator.graphs.add(
"graphs.graph(0).x.data(0).source",
"performance.grid.iterators(#).grid.x");
320 report_grid_iterator.graphs.add(
"graphs.graph(0).y.data(0).title",
"Normal iterator");
321 report_grid_iterator.graphs.add(
"graphs.graph(0).y.data(1).source",
"performance.grid.iterators(#).stencil.data.mean");
322 report_grid_iterator.graphs.add(
"graphs.graph(0).x.data(1).source",
"performance.grid.iterators(#).grid.x");
323 report_grid_iterator.graphs.add(
"graphs.graph(0).y.data(1).title",
"Stencil specialized iterator");
324 report_grid_iterator.graphs.add(
"graphs.graph(0).options.log_y",
"true");
326 report_grid_iterator.graphs.put(
"graphs.graph(1).type",
"line");
327 report_grid_iterator.graphs.add(
"graphs.graph(1).title",
"Grid p2m performance");
328 report_grid_iterator.graphs.add(
"graphs.graph(1).x.title",
"Number of grid points");
329 report_grid_iterator.graphs.add(
"graphs.graph(1).y.title",
"Time seconds");
330 report_grid_iterator.graphs.add(
"graphs.graph(1).y.data(0).source",
"performance.interpolation.p2m(#).data.mean");
331 report_grid_iterator.graphs.add(
"graphs.graph(1).y.data(0).title",
"Interpolation p2m");
332 report_grid_iterator.graphs.add(
"graphs.graph(1).x.data(0).source",
"performance.interpolation.p2m(#).grid.x");
333 report_grid_iterator.graphs.add(
"graphs.graph(1).options.log_y",
"true");
335 report_grid_iterator.graphs.put(
"graphs.graph(2).type",
"line");
336 report_grid_iterator.graphs.add(
"graphs.graph(2).title",
"Grid m2p performance");
337 report_grid_iterator.graphs.add(
"graphs.graph(2).x.title",
"Number of grid points");
338 report_grid_iterator.graphs.add(
"graphs.graph(2).y.title",
"Time seconds");
339 report_grid_iterator.graphs.add(
"graphs.graph(2).x",
"performance.interpolation.m2p(#).grid.x");
340 report_grid_iterator.graphs.add(
"graphs.graph(2).y.data(0).source",
"performance.interpolation.m2p(#).data.mean");
341 report_grid_iterator.graphs.add(
"graphs.graph(2).y.data(0).title",
"Interpolation m2p");
342 report_grid_iterator.graphs.add(
"graphs.graph(2).x.data(0).source",
"performance.interpolation.m2p(#).grid.x");
343 report_grid_iterator.graphs.add(
"graphs.graph(2).options.log_y",
"true");
345 if (create_vcluster().rank() == 0)
347 boost::property_tree::xml_writer_settings<std::string> settings(
' ', 4);
348 boost::property_tree::write_xml(
"grid_performance.xml", report_grid_iterator.graphs,std::locale(),settings);
352 std::string file_xml_ref(test_dir);
353 file_xml_ref += std::string(
"/openfpm_pdata/grid_performance_ref.xml");
355 StandardXMLPerformanceGraph(
"grid_performance.xml",file_xml_ref,cg);
357 if (create_vcluster().getProcessUnitID() == 0)
359 addUpdateTime(cg,create_vcluster().size(),
"pdata",
"grid_performance");
361 cg.
write(
"grid_performance.html");
367BOOST_AUTO_TEST_SUITE_END()
This class represent an N-dimensional box.
__device__ __host__ void setHigh(int i, T val)
set the high interval of the box
__device__ __host__ void setLow(int i, T val)
set the low interval of the box
This class decompose a space into sub-sub-domains and distribute them across processors.
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.
This is a distributed grid.
grid_key_dx is the key to access any element in the grid
Main class for interpolation Particle to mest p2m and Mesh to particle m2p.
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...