9#ifndef SRC_VECTOR_VECTOR_DIST_CL_PERFORMANCE_TESTS_HPP_
10#define SRC_VECTOR_VECTOR_DIST_CL_PERFORMANCE_TESTS_HPP_
12#include "Vector/vector_dist.hpp"
13#include "data_type/aggregate.hpp"
14#include "Plot/GoogleChart.hpp"
20 boost::property_tree::ptree graphs;
25BOOST_AUTO_TEST_SUITE( celllist_part_reorder_performance_test )
38size_t k_start = 100000;
51template<
unsigned int dim>
void cell_list_part_reorder_random_benchmark(
size_t cl_k_start,
56 std::string str(
"Testing " + std::to_string(dim) +
"D vector, no-order, Cell-list");
61 for (
size_t r = 0; r < cl_r_cutoff.
size(); r++ )
66 float r_cut = cl_r_cutoff.get(r);
68 report_cl_preo.graphs.put(
"performance.celllist.calc_forces_reordered" + std::to_string(dim) +
"D(" + std::to_string(r) +
").rcut",r_cut);
74 size_t k_count = 1 + log2(k/cl_k_min);
79 for (
size_t k_int = k ; k_int >= cl_k_min ; k_int/=2 )
81 BOOST_TEST_CHECKPOINT(
"Testing " << dim <<
"D vector without an Hilbert curve reordering k=" << k_int );
83 report_cl_preo.graphs.put(
"performance.celllist.calc_forces_reordered" + std::to_string(dim) +
"D(" + std::to_string(r) +
").npart(" + std::to_string(c) +
").n",k_int);
85 if (cl_n_particles.
size() < k_count)
86 cl_n_particles.add(k_int);
90 for (
size_t i = 0; i < dim; i++)
99 for (
size_t i = 0; i < dim; i++)
105 vd_initialize<dim>(vd, v_cl);
107 vd.template ghost_get<0>();
111 auto NN = vd.getCellList(r_cut);
112 double sum_fr_mean = 0;
113 double sum_fr_dev = 0;
115 benchmark_get_celllist(NN,vd,r_cut);
121 for ( ; l < N_STAT_TEST; l++)
122 {measures.add(benchmark_calc_forces<dim>(NN,vd,r_cut));}
123 standard_deviation(measures,sum_fr_mean,sum_fr_dev);
125 report_cl_preo.graphs.put(
"performance.celllist.calc_forces_reordered" + std::to_string(dim) +
"D(" + std::to_string(r) +
").npart(" + std::to_string(c) +
").mean",sum_fr_mean);
126 report_cl_preo.graphs.put(
"performance.celllist.calc_forces_reordered" + std::to_string(dim) +
"D(" + std::to_string(r) +
").npart(" + std::to_string(c) +
").dev",sum_fr_dev);
129 {std::cout <<
"Cut-off = " << r_cut <<
", Particles = " << k_int <<
" time to calculate forces: " << sum_fr_mean <<
" dev: " << sum_fr_dev << std::endl;}
141template<
unsigned int dim>
void cell_list_part_reorder_hilbert_benchmark(
size_t cl_k_start,
151 std::string str(
"Testing " + std::to_string(dim) +
"D vector, Hilbert curve reordering, Cell-List");
155 for (
size_t r = 0; r < cl_r_cutoff.
size(); r++ )
160 float r_cut = cl_r_cutoff.get(r);
166 for (
size_t i = 0; i < cl_orders.
size(); i++)
168 size_t m = cl_orders.get(i);
173 for (
size_t k_int = k ; k_int >= cl_k_min ; k_int/=2, part++ )
175 BOOST_TEST_CHECKPOINT(
"Testing " << dim <<
"D vector with an Hilbert curve reordering k=" << k_int );
177 report_cl_preo.graphs.put(
"performance.celllist.calc_forces_hilb(" + std::to_string(m) +
")_reordered" + std::to_string(dim) +
"D(" + std::to_string(r) +
").rcut",r_cut);
178 report_cl_preo.graphs.put(
"performance.celllist.calc_forces_hilb(" + std::to_string(m) +
")_reordered" + std::to_string(dim) +
"D(" + std::to_string(r) +
").npart(" + std::to_string(c) +
").n",k_int);
182 for (
size_t i = 0; i < dim; i++)
191 for (
size_t i = 0; i < dim; i++)
198 vd_initialize<dim>(vd, v_cl);
201 double sum_reorder_mean = 0;
202 double sum_reorder_dev = 0;
205 for (
size_t h = 0 ; h < N_STAT_TEST; h++)
206 {measures.add(benchmark_reorder(vd,m));}
207 standard_deviation(measures,sum_reorder_mean,sum_reorder_dev);
209 vd.template ghost_get<0>();
213 auto NN = vd.getCellList(r_cut);
214 benchmark_get_celllist(NN,vd,r_cut);
218 double sum_fr_mean = 0;
219 double sum_fr_dev = 0;
222 for (
size_t l = 0 ; l < N_STAT_TEST ; l++)
223 {measures.add(benchmark_calc_forces<dim>(NN,vd,r_cut));}
224 standard_deviation(measures,sum_fr_mean,sum_fr_dev);
226 report_cl_preo.graphs.put(
"performance.celllist.calc_forces_hilb(" + std::to_string(m) +
")_reordered" + std::to_string(dim) +
"D(" + std::to_string(r) +
").npart(" + std::to_string(c) +
").mean",sum_fr_mean);
227 report_cl_preo.graphs.put(
"performance.celllist.calc_forces_hilb(" + std::to_string(m) +
")_reordered" + std::to_string(dim) +
"D(" + std::to_string(r) +
").npart(" + std::to_string(c) +
").dev",sum_fr_dev);
230 {std::cout <<
"Cut-off = " << r_cut <<
", Particles = " << k_int <<
". Time to reorder: " << sum_reorder_mean <<
" dev: " << sum_reorder_dev <<
" time calculate forces: " << sum_fr_mean <<
" dev: " << sum_fr_dev << std::endl;}
240BOOST_AUTO_TEST_CASE( vector_dist_cl_random_test )
243 cell_list_part_reorder_random_benchmark<3>(k_start,k_min,r_cutoff,n_particles);
244 cell_list_part_reorder_random_benchmark<2>(k_start,k_min,r_cutoff,n_particles);
247BOOST_AUTO_TEST_CASE( vector_dist_cl_hilbert_test )
250 cell_list_part_reorder_hilbert_benchmark<3>(k_start,
258 cell_list_part_reorder_hilbert_benchmark<2>(k_start,
267BOOST_AUTO_TEST_CASE(vector_dist_cl_performance_write_report)
272 for (
size_t r = 0; r < r_cutoff.size(); r++ )
274 report_cl_preo.graphs.put(
"graphs.graph(" + std::to_string(r) +
").type",
"line");
275 report_cl_preo.graphs.add(
"graphs.graph(" + std::to_string(r) +
").title",
"calc_force 3D with reordered particles performance r_cut=" + std::to_string(r_cutoff.get(r)));
276 report_cl_preo.graphs.add(
"graphs.graph(" + std::to_string(r) +
").x.title",
"number of particles");
277 report_cl_preo.graphs.add(
"graphs.graph(" + std::to_string(r) +
").y.title",
"Time seconds");
278 for (
size_t i = 0 ; i < orders.
size() ; i++)
280 size_t m = orders.get(i);
281 report_cl_preo.graphs.add(
"graphs.graph(" + std::to_string(r) +
").y.data(" + std::to_string(i+1) +
").source",
"performance.celllist.calc_forces_hilb(" + std::to_string(m) +
")_reordered3D(" + std::to_string(r) +
").npart(#).mean");
282 report_cl_preo.graphs.add(
"graphs.graph(" + std::to_string(r) +
").x.data(" + std::to_string(i+1) +
").source",
"performance.celllist.calc_forces_hilb(" + std::to_string(m) +
")_reordered3D(" + std::to_string(r) +
").npart(#).n");
283 report_cl_preo.graphs.add(
"graphs.graph(" + std::to_string(r) +
").y.data(" + std::to_string(i+1) +
").title",
"Hilbert(" + std::to_string(m) +
") reorder");
285 report_cl_preo.graphs.add(
"graphs.graph(" + std::to_string(r) +
").y.data(0).source",
"performance.celllist.calc_forces_reordered3D(" + std::to_string(r) +
").npart(#).mean");
286 report_cl_preo.graphs.add(
"graphs.graph(" + std::to_string(r) +
").x.data(0).source",
"performance.celllist.calc_forces_reordered3D(" + std::to_string(r) +
").npart(#).n");
287 report_cl_preo.graphs.add(
"graphs.graph(" + std::to_string(r) +
").y.data(0).title",
"Random reorder");
288 report_cl_preo.graphs.add(
"graphs.graph(" + std::to_string(r) +
").options.log_y",
"true");
292 for (
size_t r = 0; r < r_cutoff.size(); r++ )
294 report_cl_preo.graphs.put(
"graphs.graph(" + std::to_string(r + r_cutoff.size()) +
").type",
"line");
295 report_cl_preo.graphs.add(
"graphs.graph(" + std::to_string(r + r_cutoff.size()) +
").title",
"calc_force 2D with reordered particles performance r_cut=" + std::to_string(r_cutoff.get(r)));
296 report_cl_preo.graphs.add(
"graphs.graph(" + std::to_string(r + r_cutoff.size()) +
").x.title",
"number of particles");
297 report_cl_preo.graphs.add(
"graphs.graph(" + std::to_string(r + r_cutoff.size()) +
").y.title",
"Time seconds");
298 for (
size_t i = 0 ; i < orders.
size() ; i++)
300 size_t m = orders.get(i);
301 report_cl_preo.graphs.add(
"graphs.graph(" + std::to_string(r + r_cutoff.size()) +
").y.data(" + std::to_string(i+1) +
").source",
"performance.celllist.calc_forces_hilb(" + std::to_string(m) +
")_reordered2D(" + std::to_string(r) +
").npart(#).mean");
302 report_cl_preo.graphs.add(
"graphs.graph(" + std::to_string(r + r_cutoff.size()) +
").x.data(" + std::to_string(i+1) +
").source",
"performance.celllist.calc_forces_hilb(" + std::to_string(m) +
")_reordered2D(" + std::to_string(r) +
").npart(#).n");
303 report_cl_preo.graphs.add(
"graphs.graph(" + std::to_string(r + r_cutoff.size()) +
").y.data(" + std::to_string(i+1) +
").title",
"Hilbert(" + std::to_string(m) +
") reorder");
305 report_cl_preo.graphs.add(
"graphs.graph(" + std::to_string(r + r_cutoff.size()) +
").y.data(0).source",
"performance.celllist.calc_forces_reordered2D(" + std::to_string(r) +
").npart(#).mean");
306 report_cl_preo.graphs.add(
"graphs.graph(" + std::to_string(r + r_cutoff.size()) +
").x.data(0).source",
"performance.celllist.calc_forces_reordered2D(" + std::to_string(r) +
").npart(#).n");
307 report_cl_preo.graphs.add(
"graphs.graph(" + std::to_string(r + r_cutoff.size()) +
").y.data(0).title",
"Random reorder");
308 report_cl_preo.graphs.add(
"graphs.graph(" + std::to_string(r + r_cutoff.size()) +
").options.log_y",
"true");
311 if (create_vcluster().rank() == 0)
313 boost::property_tree::xml_writer_settings<std::string> settings(
' ', 4);
314 boost::property_tree::write_xml(
"celllist_partreo_performance.xml", report_cl_preo.graphs,std::locale(),settings);
316 std::string file_xml_ref(test_dir);
317 file_xml_ref += std::string(
"/openfpm_pdata/celllist_partreo_performance_ref.xml");
321 StandardXMLPerformanceGraph(
"celllist_partreo_performance.xml",file_xml_ref,cg);
323 addUpdateTime(cg,create_vcluster().size(),
"pdata",
"celllist_part_ord");
325 if (create_vcluster().getProcessUnitID() == 0)
326 {cg.
write(
"celllist_part_ord.html");}
330BOOST_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.