8#ifndef SRC_VECTOR_VECTOR_DIST_CL_HILB_PERFORMANCE_TESTS_HPP_
9#define SRC_VECTOR_VECTOR_DIST_CL_HILB_PERFORMANCE_TESTS_HPP_
11#include "Vector/vector_dist.hpp"
12#include "data_type/aggregate.hpp"
13#include "Plot/GoogleChart.hpp"
14#include "vector_dist_performance_util.hpp"
19 boost::property_tree::ptree graphs;
24BOOST_AUTO_TEST_SUITE( celllist_getCellList_calc_forces_performance_test )
32size_t k_start = 100000;
44template<
unsigned int dim>
void cell_list_getCellList_calc_force_benchmark(
size_t cl_k_start,
49 std::string str(
"Testing " + std::to_string(dim) +
"D vector, no order, cell-list");
54 for (
size_t r = 0; r < cl_r_cutoff.
size(); r++ )
59 float r_cut = cl_r_cutoff.get(r);
65 size_t k_count = 1 + log2(k/cl_k_min);
67 report_cl_funcs.graphs.put(
"performance.celllist.getCellList" + std::to_string(dim) +
"D(" + std::to_string(r) +
").rcut",r_cut);
72 for (
size_t k_int = k ; k_int >= cl_k_min ; k_int/=2 )
74 BOOST_TEST_CHECKPOINT(
"Testing " << dim <<
"D vector with a random cell list k=" << k_int );
76 report_cl_funcs.graphs.put(
"performance.celllist.getCellList" + std::to_string(dim) +
"D(" + std::to_string(r) +
").npart(" + std::to_string(c) +
").n",k_int);
77 report_cl_funcs.graphs.put(
"performance.celllist.calc_forces" + std::to_string(dim) +
"D(" + std::to_string(r) +
").npart(" + std::to_string(c) +
").n",k_int);
80 if (cl_n_particles.
size() < k_count)
81 cl_n_particles.add(k_int);
85 for (
size_t i = 0; i < dim; i++)
94 for (
size_t i = 0; i < dim; i++)
100 vd_initialize<dim>(vd, v_cl);
102 vd.template ghost_get<0>();
106 auto NN = vd.getCellList(r_cut);
107 double sum_cl_mean = 0;
108 double sum_cl_dev = 0;
111 for (
size_t n = 0 ; n < N_STAT_TEST; n++)
113 measures.add(benchmark_get_celllist(NN,vd,r_cut));
115 standard_deviation(measures,sum_cl_mean,sum_cl_dev);
118 report_cl_funcs.graphs.put(
"performance.celllist.getCellList" + std::to_string(dim) +
"D(" + std::to_string(r) +
").npart(" + std::to_string(c) +
").mean",sum_cl_mean);
119 report_cl_funcs.graphs.put(
"performance.celllist.getCellList" + std::to_string(dim) +
"D(" + std::to_string(r) +
").npart(" + std::to_string(c) +
").dev",sum_cl_dev);
123 double sum_fr_mean = 0;
124 double sum_fr_dev = 0;
127 for (
size_t l = 0 ; l < N_STAT_TEST; l++)
128 {measures.add(benchmark_calc_forces<dim>(NN,vd,r_cut));}
129 standard_deviation(measures,sum_fr_mean,sum_fr_dev);
131 report_cl_funcs.graphs.put(
"performance.celllist.calc_forces" + std::to_string(dim) +
"D(" + std::to_string(r) +
").npart(" + std::to_string(c) +
").mean",sum_fr_mean);
132 report_cl_funcs.graphs.put(
"performance.celllist.calc_forces" + std::to_string(dim) +
"D(" + std::to_string(r) +
").npart(" + std::to_string(c) +
").dev",sum_fr_dev);
135 std::cout <<
"Cut-off = " << r_cut <<
", Particles = " << k_int <<
". Time to create a cell-list: " << sum_cl_mean <<
" dev: " << sum_cl_dev <<
" time to calculate forces: " << sum_fr_mean <<
" dev: " << sum_fr_dev << std::endl;
146template<
unsigned int dim>
void cell_list_getCellList_hilb_calc_force_benchmark(
size_t cl_k_start,
151 report_cl_funcs.graphs.put(
"performance.celllist.dim",std::to_string(dim));
153 std::string str(
"Testing " + std::to_string(dim) +
"D vector, Hilbert comp reorder, cell list");
158 for (
size_t r = 0; r < cl_r_cutoff.
size(); r++ )
163 float r_cut = cl_r_cutoff.get(r);
165 report_cl_funcs.graphs.put(
"performance.celllist.getCellList_hilb" + std::to_string(dim) +
"D(" + std::to_string(r) +
").rcut",r_cut);
171 size_t k_count = 1 + log2(k/cl_k_min);
176 for (
size_t k_int = k ; k_int >= cl_k_min ; k_int/=2 )
178 BOOST_TEST_CHECKPOINT(
"Testing " << dim <<
"D vector with an Hilbert cell list k=" << k_int );
180 report_cl_funcs.graphs.put(
"performance.celllist.getCellList_hilb" + std::to_string(dim) +
"D(" + std::to_string(r) +
").npart(" + std::to_string(c) +
").n",k_int);
181 report_cl_funcs.graphs.put(
"performance.celllist.calc_forces_hilb" + std::to_string(dim) +
"D(" + std::to_string(r) +
").npart(" + std::to_string(c) +
").n",k_int);
183 if (cl_n_particles.
size() < k_count)
184 cl_n_particles.add(k_int);
188 for (
size_t i = 0; i < dim; i++)
197 for (
size_t i = 0; i < dim; i++)
203 vd_initialize<dim>(vd, v_cl);
205 vd.template ghost_get<0>();
209 auto NN = vd.getCellList_hilb(r_cut);
213 double sum_cl_mean = 0;
214 double sum_cl_dev = 0;
215 for (
size_t n = 0 ; n < N_STAT_TEST; n++)
216 {measures.add(benchmark_get_celllist_hilb(NN,vd,r_cut));}
217 standard_deviation(measures,sum_cl_mean,sum_cl_dev);
220 report_cl_funcs.graphs.put(
"performance.celllist.getCellList_hilb" + std::to_string(dim) +
"D(" + std::to_string(r) +
").npart(" + std::to_string(c) +
").mean",sum_cl_mean);
221 report_cl_funcs.graphs.put(
"performance.celllist.getCellList_hilb" + std::to_string(dim) +
"D(" + std::to_string(r) +
").npart(" + std::to_string(c) +
").dev",sum_cl_dev);
225 double sum_fr_mean = 0;
226 double sum_fr_dev = 0;
232 for (
size_t l = 0 ; l < N_STAT_TEST; l++)
233 {measures.add(benchmark_calc_forces_hilb<dim>(NN,vd,r_cut));}
234 standard_deviation(measures,sum_fr_mean,sum_fr_dev);
236 report_cl_funcs.graphs.put(
"performance.celllist.calc_forces_hilb" + std::to_string(dim) +
"D(" + std::to_string(r) +
").npart(" + std::to_string(c) +
").mean",sum_fr_mean);
237 report_cl_funcs.graphs.put(
"performance.celllist.calc_forces_hilb" + std::to_string(dim) +
"D(" + std::to_string(r) +
").npart(" + std::to_string(c) +
").dev",sum_fr_dev);
241 {std::cout <<
"Cut-off = " << r_cut <<
", Particles = " << k_int <<
". Time to create: " << sum_cl_mean <<
" dev: " << sum_cl_dev <<
" time to calculate force: " << sum_fr_mean <<
" dev: " << sum_fr_dev << std::endl;}
250BOOST_AUTO_TEST_CASE( vector_dist_celllist_random_test )
253 cell_list_getCellList_calc_force_benchmark<3>(k_start,
259 cell_list_getCellList_calc_force_benchmark<2>(k_start,
265BOOST_AUTO_TEST_CASE( vector_dist_celllist_hilbert_test )
268 cell_list_getCellList_hilb_calc_force_benchmark<3>(k_start,
273 cell_list_getCellList_hilb_calc_force_benchmark<2>(k_start,
280BOOST_AUTO_TEST_CASE(vector_dist_cl_performance_write_report)
285 for (
size_t r = 0; r < r_cutoff.size(); r++ )
287 report_cl_funcs.graphs.put(
"graphs.graph(" + std::to_string(r) +
").type",
"line");
288 report_cl_funcs.graphs.add(
"graphs.graph(" + std::to_string(r) +
").title",
"getCellList 3D performance r_cut=" + std::to_string(r_cutoff.get(r)));
289 report_cl_funcs.graphs.add(
"graphs.graph(" + std::to_string(r) +
").x.title",
"number of particles");
290 report_cl_funcs.graphs.add(
"graphs.graph(" + std::to_string(r) +
").y.title",
"Time seconds");
291 report_cl_funcs.graphs.add(
"graphs.graph(" + std::to_string(r) +
").y.data(0).source",
"performance.celllist.getCellList_hilb3D(" + std::to_string(r) +
").npart(#).mean");
292 report_cl_funcs.graphs.add(
"graphs.graph(" + std::to_string(r) +
").x.data(0).source",
"performance.celllist.getCellList_hilb3D(" + std::to_string(r) +
").npart(#).n");
293 report_cl_funcs.graphs.add(
"graphs.graph(" + std::to_string(r) +
").y.data(0).title",
"Cell-list hilbert");
294 report_cl_funcs.graphs.add(
"graphs.graph(" + std::to_string(r) +
").y.data(1).source",
"performance.celllist.getCellList3D(" + std::to_string(r) +
").npart(#).mean");
295 report_cl_funcs.graphs.add(
"graphs.graph(" + std::to_string(r) +
").x.data(1).source",
"performance.celllist.getCellList3D(" + std::to_string(r) +
").npart(#).n");
296 report_cl_funcs.graphs.add(
"graphs.graph(" + std::to_string(r) +
").y.data(1).title",
"Cell-list normal");
297 report_cl_funcs.graphs.add(
"graphs.graph(" + std::to_string(r) +
").options.log_y",
"true");
301 for (
size_t r = 0; r < r_cutoff.size(); r++ )
303 report_cl_funcs.graphs.put(
"graphs.graph(" + std::to_string(r_cutoff.size() + r) +
").type",
"line");
304 report_cl_funcs.graphs.add(
"graphs.graph(" + std::to_string(r_cutoff.size() + r) +
").title",
"calc_force 3D performance (Note hilbert require space filling curve pre-calculation) r_cut=" + std::to_string(r_cutoff.get(r)));
305 report_cl_funcs.graphs.add(
"graphs.graph(" + std::to_string(r_cutoff.size() + r) +
").x.title",
"number of particles");
306 report_cl_funcs.graphs.add(
"graphs.graph(" + std::to_string(r_cutoff.size() + r) +
").y.title",
"Time seconds");
307 report_cl_funcs.graphs.add(
"graphs.graph(" + std::to_string(r_cutoff.size() + r) +
").y.data(0).source",
"performance.celllist.calc_forces_hilb3D(" + std::to_string(r) +
").npart(#).mean");
308 report_cl_funcs.graphs.add(
"graphs.graph(" + std::to_string(r_cutoff.size() + r) +
").x.data(0).source",
"performance.celllist.calc_forces_hilb3D(" + std::to_string(r) +
").npart(#).n");
309 report_cl_funcs.graphs.add(
"graphs.graph(" + std::to_string(r_cutoff.size() + r) +
").y.data(0).title",
"Cell-list hilbert");
310 report_cl_funcs.graphs.add(
"graphs.graph(" + std::to_string(r_cutoff.size() + r) +
").y.data(1).source",
"performance.celllist.calc_forces3D(" + std::to_string(r) +
").npart(#).mean");
311 report_cl_funcs.graphs.add(
"graphs.graph(" + std::to_string(r_cutoff.size() + r) +
").x.data(1).source",
"performance.celllist.calc_forces3D(" + std::to_string(r) +
").npart(#).n");
312 report_cl_funcs.graphs.add(
"graphs.graph(" + std::to_string(r_cutoff.size() + r) +
").y.data(1).title",
"Cell-list normal");
313 report_cl_funcs.graphs.add(
"graphs.graph(" + std::to_string(r_cutoff.size() + r) +
").options.log_y",
"true");
317 for (
size_t r = 0; r < r_cutoff.size(); r++ )
319 report_cl_funcs.graphs.put(
"graphs.graph(" + std::to_string(2*r_cutoff.size() + r) +
").type",
"line");
320 report_cl_funcs.graphs.add(
"graphs.graph(" + std::to_string(2*r_cutoff.size() + r) +
").title",
"getCellList 2D performance r_cut=" + std::to_string(r_cutoff.get(r)));
321 report_cl_funcs.graphs.add(
"graphs.graph(" + std::to_string(2*r_cutoff.size() + r) +
").x.title",
"number of particles");
322 report_cl_funcs.graphs.add(
"graphs.graph(" + std::to_string(2*r_cutoff.size() + r) +
").y.title",
"Time seconds");
323 report_cl_funcs.graphs.add(
"graphs.graph(" + std::to_string(2*r_cutoff.size() + r) +
").y.data(0).source",
"performance.celllist.getCellList_hilb2D(" + std::to_string(r) +
").npart(#).mean");
324 report_cl_funcs.graphs.add(
"graphs.graph(" + std::to_string(2*r_cutoff.size() + r) +
").x.data(0).source",
"performance.celllist.getCellList_hilb2D(" + std::to_string(r) +
").npart(#).n");
325 report_cl_funcs.graphs.add(
"graphs.graph(" + std::to_string(2*r_cutoff.size() + r) +
").y.data(0).title",
"Cell-list hilbert");
326 report_cl_funcs.graphs.add(
"graphs.graph(" + std::to_string(2*r_cutoff.size() + r) +
").y.data(1).source",
"performance.celllist.getCellList2D(" + std::to_string(r) +
").npart(#).mean");
327 report_cl_funcs.graphs.add(
"graphs.graph(" + std::to_string(2*r_cutoff.size() + r) +
").x.data(1).source",
"performance.celllist.getCellList2D(" + std::to_string(r) +
").npart(#).n");
328 report_cl_funcs.graphs.add(
"graphs.graph(" + std::to_string(2*r_cutoff.size() + r) +
").y.data(1).title",
"Cell-list normal");
329 report_cl_funcs.graphs.add(
"graphs.graph(" + std::to_string(2*r_cutoff.size() + r) +
").options.log_y",
"true");
333 for (
size_t r = 0; r < r_cutoff.size(); r++ )
335 report_cl_funcs.graphs.put(
"graphs.graph(" + std::to_string(3*r_cutoff.size() + r) +
").type",
"line");
336 report_cl_funcs.graphs.add(
"graphs.graph(" + std::to_string(3*r_cutoff.size() + r) +
").title",
"calc_force 2D performance (Note hilbert require space filling curve pre-calculation) r_cut=" + std::to_string(r_cutoff.get(r)));
337 report_cl_funcs.graphs.add(
"graphs.graph(" + std::to_string(3*r_cutoff.size() + r) +
").x.title",
"number of particles");
338 report_cl_funcs.graphs.add(
"graphs.graph(" + std::to_string(3*r_cutoff.size() + r) +
").y.title",
"Time seconds");
339 report_cl_funcs.graphs.add(
"graphs.graph(" + std::to_string(3*r_cutoff.size() + r) +
").y.data(0).source",
"performance.celllist.calc_forces_hilb2D(" + std::to_string(r) +
").npart(#).mean");
340 report_cl_funcs.graphs.add(
"graphs.graph(" + std::to_string(3*r_cutoff.size() + r) +
").x.data(0).source",
"performance.celllist.calc_forces_hilb2D(" + std::to_string(r) +
").npart(#).n");
341 report_cl_funcs.graphs.add(
"graphs.graph(" + std::to_string(3*r_cutoff.size() + r) +
").y.data(0).title",
"Cell-list hilbert");
342 report_cl_funcs.graphs.add(
"graphs.graph(" + std::to_string(3*r_cutoff.size() + r) +
").y.data(1).source",
"performance.celllist.calc_forces2D(" + std::to_string(r) +
").npart(#).mean");
343 report_cl_funcs.graphs.add(
"graphs.graph(" + std::to_string(3*r_cutoff.size() + r) +
").x.data(1).source",
"performance.celllist.calc_forces2D(" + std::to_string(r) +
").npart(#).n");
344 report_cl_funcs.graphs.add(
"graphs.graph(" + std::to_string(3*r_cutoff.size() + r) +
").y.data(1).title",
"Cell-list normal");
345 report_cl_funcs.graphs.add(
"graphs.graph(" + std::to_string(3*r_cutoff.size() + r) +
").options.log_y",
"true");
348 if (create_vcluster().rank() == 0)
350 boost::property_tree::xml_writer_settings<std::string> settings(
' ', 4);
351 boost::property_tree::write_xml(
"celllist_performance.xml", report_cl_funcs.graphs,std::locale(),settings);
355 std::string file_xml_ref(test_dir);
356 file_xml_ref += std::string(
"/openfpm_pdata/celllist_performance_ref.xml");
358 StandardXMLPerformanceGraph(
"celllist_performance.xml",file_xml_ref,cg);
360 addUpdateTime(cg,create_vcluster().size(),
"pdata",
"celllist_performance");
362 createCommitFile(
"pdata");
364 cg.
write(
"celllist_performance.html");
370BOOST_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
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.
size_t getProcessUnitID()
Get the process unit id.
size_t getProcessingUnits()
Get the total number of processors.
Implementation of VCluster class.
Implementation of 1-D std::vector like structure.