From 01063412cb52d4fab9c0d001c6153c1e8d17edab Mon Sep 17 00:00:00 2001 From: Pietro Incardona <incardon@mpi-cbg.de> Date: Sun, 28 Jul 2019 16:12:24 +0200 Subject: [PATCH] Fixing performance tests --- openfpm_data | 2 +- .../performance/grid_dist_performance.hpp | 23 +- .../performance/cell_list_comp_reorder.hpp | 229 ++++-------- .../performance/cell_list_part_reorder.hpp | 250 +++++-------- .../performance/cl_comp_performance_graph.hpp | 191 ---------- .../performance/cl_part_performance_graph.hpp | 209 ----------- .../performance/verlet_performance_tests.hpp | 353 +++++------------- 7 files changed, 265 insertions(+), 992 deletions(-) delete mode 100644 src/Vector/performance/cl_comp_performance_graph.hpp delete mode 100644 src/Vector/performance/cl_part_performance_graph.hpp diff --git a/openfpm_data b/openfpm_data index cbef620db..574337495 160000 --- a/openfpm_data +++ b/openfpm_data @@ -1 +1 @@ -Subproject commit cbef620db71cbd6beb13eb11f139f1cdbfce8ae3 +Subproject commit 57433749597405b0f70b9735c149285d5af059fa diff --git a/src/Grid/performance/grid_dist_performance.hpp b/src/Grid/performance/grid_dist_performance.hpp index e157842f3..368c2b9b2 100644 --- a/src/Grid/performance/grid_dist_performance.hpp +++ b/src/Grid/performance/grid_dist_performance.hpp @@ -342,21 +342,24 @@ BOOST_AUTO_TEST_CASE(grid_iterator_performance_write_report_final) report_grid_iterator.graphs.add("graphs.graph(2).x.data(0).source","performance.interpolation.m2p(#).grid.x"); report_grid_iterator.graphs.add("graphs.graph(2).options.log_y","true"); - boost::property_tree::xml_writer_settings<std::string> settings(' ', 4); - boost::property_tree::write_xml("grid_performance.xml", report_grid_iterator.graphs,std::locale(),settings); + if (create_vcluster().rank() == 0) + { + boost::property_tree::xml_writer_settings<std::string> settings(' ', 4); + boost::property_tree::write_xml("grid_performance.xml", report_grid_iterator.graphs,std::locale(),settings); - GoogleChart cg; + GoogleChart cg; - std::string file_xml_ref(test_dir); - file_xml_ref += std::string("/openfpm_pdata/grid_performance_ref.xml"); + std::string file_xml_ref(test_dir); + file_xml_ref += std::string("/openfpm_pdata/grid_performance_ref.xml"); - StandardXMLPerformanceGraph("grid_performance.xml",file_xml_ref,cg); + StandardXMLPerformanceGraph("grid_performance.xml",file_xml_ref,cg); - if (create_vcluster().getProcessUnitID() == 0) - { - addUpdtateTime(cg); + if (create_vcluster().getProcessUnitID() == 0) + { + addUpdtateTime(cg,create_vcluster().size()); - cg.write("grid_performance.html"); + cg.write("grid_performance.html"); + } } } diff --git a/src/Vector/performance/cell_list_comp_reorder.hpp b/src/Vector/performance/cell_list_comp_reorder.hpp index 0f3747423..eb17be9fa 100644 --- a/src/Vector/performance/cell_list_comp_reorder.hpp +++ b/src/Vector/performance/cell_list_comp_reorder.hpp @@ -12,7 +12,6 @@ #include "data_type/aggregate.hpp" #include "Plot/GoogleChart.hpp" #include "vector_dist_performance_util.hpp" -#include "cl_comp_performance_graph.hpp" // Property tree struct report_cell_list_func_tests @@ -38,24 +37,6 @@ size_t k_min = 15000; // Numbers of particles vector openfpm::vector<size_t> n_particles; -// Vectors to store the data for 2D -openfpm::vector<openfpm::vector<double>> time_rand_mean; -openfpm::vector<openfpm::vector<double>> time_hilb_mean; -openfpm::vector<openfpm::vector<double>> time_rand_dev; -openfpm::vector<openfpm::vector<double>> time_hilb_dev; -openfpm::vector<openfpm::vector<double>> time_create_rand_mean; -openfpm::vector<openfpm::vector<double>> time_create_hilb_mean; -openfpm::vector<openfpm::vector<double>> time_create_rand_dev; -openfpm::vector<openfpm::vector<double>> time_create_hilb_dev; -// Vectors to store the data for 3D -openfpm::vector<openfpm::vector<double>> time_rand_2_mean; -openfpm::vector<openfpm::vector<double>> time_hilb_2_mean; -openfpm::vector<openfpm::vector<double>> time_rand_2_dev; -openfpm::vector<openfpm::vector<double>> time_hilb_2_dev; -openfpm::vector<openfpm::vector<double>> time_create_rand_2_mean; -openfpm::vector<openfpm::vector<double>> time_create_hilb_2_mean; -openfpm::vector<openfpm::vector<double>> time_create_rand_2_dev; -openfpm::vector<openfpm::vector<double>> time_create_hilb_2_dev; /*! \brief Function for random cell list test * @@ -63,19 +44,8 @@ openfpm::vector<openfpm::vector<double>> time_create_hilb_2_dev; template<unsigned int dim> void cell_list_getCellList_calc_force_benchmark(size_t cl_k_start, size_t cl_k_min, openfpm::vector<float> & cl_r_cutoff, - openfpm::vector<size_t> & cl_n_particles, - openfpm::vector<openfpm::vector<double>> & cl_time_rand_mean, - openfpm::vector<openfpm::vector<double>> & cl_time_rand_dev, - openfpm::vector<openfpm::vector<double>> & cl_time_create_rand_mean, - openfpm::vector<openfpm::vector<double>> & cl_time_create_rand_dev) + openfpm::vector<size_t> & cl_n_particles) { - report_cl_funcs.graphs.put("performance.celllist.dim",std::to_string(dim)); - - cl_time_rand_mean.resize(cl_r_cutoff.size()); - cl_time_create_rand_mean.resize(cl_r_cutoff.size()); - cl_time_rand_dev.resize(cl_r_cutoff.size()); - cl_time_create_rand_dev.resize(cl_r_cutoff.size()); - std::string str("Testing " + std::to_string(dim) + "D vector, no order, cell-list"); print_test_v(str,0); @@ -104,6 +74,8 @@ template<unsigned int dim> void cell_list_getCellList_calc_force_benchmark(size_ BOOST_TEST_CHECKPOINT( "Testing " << dim << "D vector with a random cell list k=" << k_int ); 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); + 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); + if (cl_n_particles.size() < k_count) cl_n_particles.add(k_int); @@ -143,9 +115,6 @@ template<unsigned int dim> void cell_list_getCellList_calc_force_benchmark(size_ standard_deviation(measures,sum_cl_mean,sum_cl_dev); //Average total time - cl_time_create_rand_mean.get(r).add(sum_cl_mean); - cl_time_create_rand_dev.get(r).add(sum_cl_dev); - 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); 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); @@ -159,9 +128,6 @@ template<unsigned int dim> void cell_list_getCellList_calc_force_benchmark(size_ {measures.add(benchmark_calc_forces<dim>(NN,vd,r_cut));} standard_deviation(measures,sum_fr_mean,sum_fr_dev); - cl_time_rand_mean.get(r).add(sum_fr_mean); - cl_time_rand_dev.get(r).add(sum_fr_dev); - 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); 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); @@ -180,19 +146,10 @@ template<unsigned int dim> void cell_list_getCellList_calc_force_benchmark(size_ template<unsigned int dim> void cell_list_getCellList_hilb_calc_force_benchmark(size_t cl_k_start, size_t cl_k_min, openfpm::vector<float> & cl_r_cutoff, - openfpm::vector<size_t> & cl_n_particles, - openfpm::vector<openfpm::vector<double>> & cl_time_force_mean, - openfpm::vector<openfpm::vector<double>> & cl_time_force_dev, - openfpm::vector<openfpm::vector<double>> & cl_time_create_mean, - openfpm::vector<openfpm::vector<double>> & cl_time_create_dev) + openfpm::vector<size_t> & cl_n_particles) { report_cl_funcs.graphs.put("performance.celllist.dim",std::to_string(dim)); - cl_time_force_mean.resize(cl_r_cutoff.size()); - cl_time_create_mean.resize(cl_r_cutoff.size()); - cl_time_force_dev.resize(cl_r_cutoff.size()); - cl_time_create_dev.resize(cl_r_cutoff.size()); - std::string str("Testing " + std::to_string(dim) + "D vector, Hilbert comp reorder, cell list"); print_test_v(str,0); @@ -221,6 +178,7 @@ template<unsigned int dim> void cell_list_getCellList_hilb_calc_force_benchmark( BOOST_TEST_CHECKPOINT( "Testing " << dim << "D vector with an Hilbert cell list k=" << k_int ); 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); + 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); if (cl_n_particles.size() < k_count) cl_n_particles.add(k_int); @@ -258,8 +216,6 @@ template<unsigned int dim> void cell_list_getCellList_hilb_calc_force_benchmark( {measures.add(benchmark_get_celllist_hilb(NN,vd,r_cut));} standard_deviation(measures,sum_cl_mean,sum_cl_dev); //Average total time - cl_time_create_mean.get(r).add(sum_cl_mean); - cl_time_create_dev.get(r).add(sum_cl_dev); 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); 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); @@ -277,9 +233,6 @@ template<unsigned int dim> void cell_list_getCellList_hilb_calc_force_benchmark( {measures.add(benchmark_calc_forces_hilb<dim>(NN,vd,r_cut));} standard_deviation(measures,sum_fr_mean,sum_fr_dev); - cl_time_force_mean.get(r).add(sum_fr_mean); - cl_time_force_dev.get(r).add(sum_fr_dev); - 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); 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); @@ -300,21 +253,13 @@ BOOST_AUTO_TEST_CASE( vector_dist_celllist_random_test ) cell_list_getCellList_calc_force_benchmark<3>(k_start, k_min, r_cutoff, - n_particles, - time_rand_mean, - time_rand_dev, - time_create_rand_mean, - time_create_rand_dev); + n_particles); cell_list_getCellList_calc_force_benchmark<2>(k_start, k_min, r_cutoff, - n_particles, - time_rand_2_mean, - time_rand_2_dev, - time_create_rand_2_mean, - time_create_rand_2_dev); + n_particles); } BOOST_AUTO_TEST_CASE( vector_dist_celllist_hilbert_test ) @@ -323,69 +268,24 @@ BOOST_AUTO_TEST_CASE( vector_dist_celllist_hilbert_test ) cell_list_getCellList_hilb_calc_force_benchmark<3>(k_start, k_min, r_cutoff, - n_particles, - time_hilb_mean, - time_hilb_dev, - time_create_hilb_mean, - time_create_hilb_dev); + n_particles); cell_list_getCellList_hilb_calc_force_benchmark<2>(k_start, k_min, r_cutoff, - n_particles, - time_hilb_2_mean, - time_hilb_2_dev, - time_create_hilb_2_mean, - time_create_hilb_2_dev); + n_particles); } -/*! \brief Function for cell list hilb performance report - * - */ -template<unsigned int dim> void cell_list_comp_reorder_report(GoogleChart & cg, - openfpm::vector<float> & cl_r_cutoff, - openfpm::vector<size_t> & cl_n_particles, - openfpm::vector<openfpm::vector<double>> & cl_time_hilb_mean, - openfpm::vector<openfpm::vector<double>> & cl_time_rand_mean, - openfpm::vector<openfpm::vector<double>> & cl_time_hilb_dev, - openfpm::vector<openfpm::vector<double>> & cl_time_rand_dev, - openfpm::vector<openfpm::vector<double>> & cl_time_create_hilb_mean, - openfpm::vector<openfpm::vector<double>> & cl_time_create_rand_mean, - openfpm::vector<openfpm::vector<double>> & cl_time_create_hilb_dev, - openfpm::vector<openfpm::vector<double>> & cl_time_create_rand_dev, - double & warning_level, - double & norm) -{ - cl_comp_normal_vs_hilbert_force_time<dim>(cg, - cl_n_particles, - cl_r_cutoff, - cl_time_hilb_mean, - cl_time_rand_mean, - cl_time_hilb_dev, - cl_time_rand_dev, - warning_level, - norm); - - cl_comp_normal_vs_hilbert_create_time<dim>(cg, - cl_n_particles, - cl_r_cutoff, - cl_time_create_hilb_mean, - cl_time_create_rand_mean, - cl_time_create_hilb_dev, - cl_time_create_rand_dev, - warning_level, - norm); -} BOOST_AUTO_TEST_CASE(vector_dist_cl_performance_write_report) { // Create a graphs //For different r_cut -/* for (size_t r = 0; r < r_cutoff.size(); r++ ) + for (size_t r = 0; r < r_cutoff.size(); r++ ) { report_cl_funcs.graphs.put("graphs.graph(" + std::to_string(r) + ").type","line"); - report_cl_funcs.graphs.add("graphs.graph(" + std::to_string(r) + ").title","getCellList performance r_cut=" + std::to_string(r_cutoff.get(r))); + report_cl_funcs.graphs.add("graphs.graph(" + std::to_string(r) + ").title","getCellList 3D performance r_cut=" + std::to_string(r_cutoff.get(r))); report_cl_funcs.graphs.add("graphs.graph(" + std::to_string(r) + ").x.title","number of particles"); report_cl_funcs.graphs.add("graphs.graph(" + std::to_string(r) + ").y.title","Time seconds"); 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"); @@ -397,61 +297,70 @@ BOOST_AUTO_TEST_CASE(vector_dist_cl_performance_write_report) report_cl_funcs.graphs.add("graphs.graph(" + std::to_string(r) + ").options.log_y","true"); } - boost::property_tree::xml_writer_settings<std::string> settings(' ', 4); - boost::property_tree::write_xml("celllist_performance.xml", report_cl_funcs.graphs,std::locale(),settings);*/ + //For different r_cut + for (size_t r = 0; r < r_cutoff.size(); r++ ) + { + report_cl_funcs.graphs.put("graphs.graph(" + std::to_string(r_cutoff.size() + r) + ").type","line"); + 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))); + report_cl_funcs.graphs.add("graphs.graph(" + std::to_string(r_cutoff.size() + r) + ").x.title","number of particles"); + report_cl_funcs.graphs.add("graphs.graph(" + std::to_string(r_cutoff.size() + r) + ").y.title","Time seconds"); + 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"); + 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"); + report_cl_funcs.graphs.add("graphs.graph(" + std::to_string(r_cutoff.size() + r) + ").y.data(0).title","Cell-list hilbert"); + 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"); + 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"); + report_cl_funcs.graphs.add("graphs.graph(" + std::to_string(r_cutoff.size() + r) + ").y.data(1).title","Cell-list normal"); + report_cl_funcs.graphs.add("graphs.graph(" + std::to_string(r_cutoff.size() + r) + ").options.log_y","true"); + } - GoogleChart cg; + //For different r_cut + for (size_t r = 0; r < r_cutoff.size(); r++ ) + { + report_cl_funcs.graphs.put("graphs.graph(" + std::to_string(2*r_cutoff.size() + r) + ").type","line"); + 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))); + report_cl_funcs.graphs.add("graphs.graph(" + std::to_string(2*r_cutoff.size() + r) + ").x.title","number of particles"); + report_cl_funcs.graphs.add("graphs.graph(" + std::to_string(2*r_cutoff.size() + r) + ").y.title","Time seconds"); + 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"); + 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"); + report_cl_funcs.graphs.add("graphs.graph(" + std::to_string(2*r_cutoff.size() + r) + ").y.data(0).title","Cell-list hilbert"); + 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"); + 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"); + report_cl_funcs.graphs.add("graphs.graph(" + std::to_string(2*r_cutoff.size() + r) + ").y.data(1).title","Cell-list normal"); + report_cl_funcs.graphs.add("graphs.graph(" + std::to_string(2*r_cutoff.size() + r) + ").options.log_y","true"); + } - std::string file_xml_ref(test_dir); - file_xml_ref += std::string("/openfpm_pdata/celllist_performance_ref.xml"); + //For different r_cut + for (size_t r = 0; r < r_cutoff.size(); r++ ) + { + report_cl_funcs.graphs.put("graphs.graph(" + std::to_string(3*r_cutoff.size() + r) + ").type","line"); + 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))); + report_cl_funcs.graphs.add("graphs.graph(" + std::to_string(3*r_cutoff.size() + r) + ").x.title","number of particles"); + report_cl_funcs.graphs.add("graphs.graph(" + std::to_string(3*r_cutoff.size() + r) + ").y.title","Time seconds"); + 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"); + 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"); + report_cl_funcs.graphs.add("graphs.graph(" + std::to_string(3*r_cutoff.size() + r) + ").y.data(0).title","Cell-list hilbert"); + 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"); + 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"); + report_cl_funcs.graphs.add("graphs.graph(" + std::to_string(3*r_cutoff.size() + r) + ").y.data(1).title","Cell-list normal"); + report_cl_funcs.graphs.add("graphs.graph(" + std::to_string(3*r_cutoff.size() + r) + ").options.log_y","true"); + } - StandardXMLPerformanceGraph("celllist_performance.xml",file_xml_ref,cg); + if (create_vcluster().rank() == 0) + { + boost::property_tree::xml_writer_settings<std::string> settings(' ', 4); + boost::property_tree::write_xml("celllist_performance.xml", report_cl_funcs.graphs,std::locale(),settings); - addUpdtateTime(cg); + GoogleChart cg; - cg.write("celllist_performance.html"); + std::string file_xml_ref(test_dir); + file_xml_ref += std::string("/openfpm_pdata/celllist_performance_ref.xml"); -/* - GoogleChart cg; - - double warning_level = 0; - double norm = 0; - - //Write report for 2D and 3D - cell_list_comp_reorder_report<3>(cg, - r_cutoff, - n_particles, - time_hilb_mean, - time_rand_mean, - time_hilb_dev, - time_rand_dev, - time_create_hilb_mean, - time_create_rand_mean, - time_create_hilb_dev, - time_create_rand_dev, - warning_level, - norm); - - cell_list_comp_reorder_report<2>(cg, - r_cutoff, - n_particles, - time_hilb_2_mean, - time_rand_2_mean, - time_rand_2_dev, - time_hilb_2_dev, - time_create_hilb_2_mean, - time_create_rand_2_mean, - time_create_hilb_2_dev, - time_create_rand_2_dev, - warning_level, - norm); - - addUpdtateTime(cg); - - if (create_vcluster().getProcessUnitID() == 0) - { - cg.write("Celllist_comp_ord.html"); - }*/ + StandardXMLPerformanceGraph("celllist_performance.xml",file_xml_ref,cg); + + addUpdtateTime(cg,create_vcluster().size()); + + cg.write("celllist_performance.html"); + } } diff --git a/src/Vector/performance/cell_list_part_reorder.hpp b/src/Vector/performance/cell_list_part_reorder.hpp index 07ca16f6d..a8ee37e27 100644 --- a/src/Vector/performance/cell_list_part_reorder.hpp +++ b/src/Vector/performance/cell_list_part_reorder.hpp @@ -12,9 +12,15 @@ #include "Vector/vector_dist.hpp" #include "data_type/aggregate.hpp" #include "Plot/GoogleChart.hpp" -#include "cl_part_performance_graph.hpp" #include <functional> +// Property tree +struct report_cell_list_preord_tests +{ + boost::property_tree::ptree graphs; +}; + +report_cell_list_preord_tests report_cl_preo; BOOST_AUTO_TEST_SUITE( celllist_part_reorder_performance_test ) @@ -37,20 +43,6 @@ size_t k_min = 15000; // Numbers of particles vector openfpm::vector<size_t> n_particles; -// Vectors to store the data for 2D -openfpm::vector<openfpm::vector<double>> time_rand_mean; -openfpm::vector<openfpm::vector<openfpm::vector<double>>> time_hilb_mean; -openfpm::vector<openfpm::vector<double>> time_rand_dev; -openfpm::vector<openfpm::vector<openfpm::vector<double>>> time_hilb_dev; -openfpm::vector<openfpm::vector<openfpm::vector<double>>> time_reorder_mean; -openfpm::vector<openfpm::vector<openfpm::vector<double>>> time_reorder_dev; -// Vectors to store the data for 3D -openfpm::vector<openfpm::vector<double>> time_rand_2_mean; -openfpm::vector<openfpm::vector<openfpm::vector<double>>> time_hilb_2_mean; -openfpm::vector<openfpm::vector<double>> time_rand_2_dev; -openfpm::vector<openfpm::vector<openfpm::vector<double>>> time_hilb_2_dev; -openfpm::vector<openfpm::vector<openfpm::vector<double>>> time_reorder_2_mean; -openfpm::vector<openfpm::vector<openfpm::vector<double>>> time_reorder_2_dev; /*! \brief Function for cell list test without an Hilbert curve reordering (unordered positioning) @@ -59,13 +51,8 @@ openfpm::vector<openfpm::vector<openfpm::vector<double>>> time_reorder_2_dev; template<unsigned int dim> void cell_list_part_reorder_random_benchmark(size_t cl_k_start, size_t cl_k_min, openfpm::vector<float> & cl_r_cutoff, - openfpm::vector<size_t> & cl_n_particles, - openfpm::vector<openfpm::vector<double>> & cl_time_rand_mean, - openfpm::vector<openfpm::vector<double>> & cl_time_rand_dev) + openfpm::vector<size_t> & cl_n_particles) { - cl_time_rand_mean.resize(cl_r_cutoff.size()); - cl_time_rand_dev.resize(cl_r_cutoff.size()); - std::string str("Testing " + std::to_string(dim) + "D vector, no-order, Cell-list"); print_test_v(str,0); @@ -78,17 +65,23 @@ template<unsigned int dim> void cell_list_part_reorder_random_benchmark(size_t c //Cut-off radius float r_cut = cl_r_cutoff.get(r); + report_cl_preo.graphs.put("performance.celllist.calc_forces_reordered" + std::to_string(dim) + "D(" + std::to_string(r) + ").rcut",r_cut); + //Number of particles size_t k = cl_k_start * v_cl.getProcessingUnits(); //Counter number for amounts of particles size_t k_count = 1 + log2(k/cl_k_min); + int c = 0; + //For different number of particles for (size_t k_int = k ; k_int >= cl_k_min ; k_int/=2 ) { BOOST_TEST_CHECKPOINT( "Testing " << dim << "D vector without an Hilbert curve reordering k=" << k_int ); + 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); + if (cl_n_particles.size() < k_count) cl_n_particles.add(k_int); @@ -126,14 +119,16 @@ template<unsigned int dim> void cell_list_part_reorder_random_benchmark(size_t c openfpm::vector<double> measures; for ( ; l < N_STAT_TEST; l++) - measures.add(benchmark_calc_forces<dim>(NN,vd,r_cut)); + {measures.add(benchmark_calc_forces<dim>(NN,vd,r_cut));} standard_deviation(measures,sum_fr_mean,sum_fr_dev); - cl_time_rand_mean.get(r).add(sum_fr_mean); - cl_time_rand_dev.get(r).add(sum_fr_dev); + 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); + 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); if (v_cl.getProcessUnitID() == 0) - std::cout << "Cut-off = " << r_cut << ", Particles = " << k_int << " time to calculate forces: " << sum_fr_mean << " dev: " << sum_fr_dev << std::endl; + {std::cout << "Cut-off = " << r_cut << ", Particles = " << k_int << " time to calculate forces: " << sum_fr_mean << " dev: " << sum_fr_dev << std::endl;} + + c++; } } } @@ -149,40 +144,9 @@ template<unsigned int dim> void cell_list_part_reorder_hilbert_benchmark(size_t double dist, openfpm::vector<float> & cl_r_cutoff, openfpm::vector<size_t> & cl_n_particles, - openfpm::vector<size_t> &cl_orders, - openfpm::vector<openfpm::vector<openfpm::vector<double>>> &cl_time_hilb_mean, - openfpm::vector<openfpm::vector<openfpm::vector<double>>> &cl_time_reorder_hilb_mean, - openfpm::vector<openfpm::vector<openfpm::vector<double>>> &cl_time_hilb_dev, - openfpm::vector<openfpm::vector<openfpm::vector<double>>> &cl_time_reorder_hilb_dev) + openfpm::vector<size_t> &cl_orders) { { - cl_time_hilb_mean.resize(cl_r_cutoff.size()); - cl_time_hilb_dev.resize(cl_r_cutoff.size()); - for (size_t r = 0; r < cl_time_hilb_mean.size(); r++) - { - cl_time_hilb_mean.get(r).resize(cl_n_particles.size()); - cl_time_hilb_dev.get(r).resize(cl_n_particles.size()); - for (size_t k = 0; k < cl_time_hilb_mean.get(r).size(); k++) - { - cl_time_hilb_mean.get(r).get(k).resize(cl_orders.size()); - cl_time_hilb_dev.get(r).get(k).resize(cl_orders.size()); - } - } - - - cl_time_reorder_hilb_mean.resize(cl_r_cutoff.size()); - cl_time_reorder_hilb_dev.resize(cl_r_cutoff.size()); - for (size_t r = 0; r < cl_time_reorder_hilb_mean.size(); r++) - { - cl_time_reorder_hilb_mean.get(r).resize(cl_n_particles.size()); - cl_time_reorder_hilb_dev.get(r).resize(cl_n_particles.size()); - for (size_t k = 0; k < cl_time_reorder_hilb_mean.get(r).size(); k++) - { - cl_time_reorder_hilb_mean.get(r).get(k).resize(cl_orders.size()); - cl_time_reorder_hilb_dev.get(r).get(k).resize(cl_orders.size()); - } - } - // Print test std::string str("Testing " + std::to_string(dim) + "D vector, Hilbert curve reordering, Cell-List"); print_test_v(str,0); @@ -204,10 +168,15 @@ template<unsigned int dim> void cell_list_part_reorder_hilbert_benchmark(size_t size_t m = cl_orders.get(i); size_t part = 0; + int c = 0; + for (size_t k_int = k ; k_int >= cl_k_min ; k_int/=2, part++ ) { BOOST_TEST_CHECKPOINT( "Testing " << dim << "D vector with an Hilbert curve reordering k=" << k_int ); + 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); + 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); + Box<dim,float> box; for (size_t i = 0; i < dim; i++) @@ -220,7 +189,7 @@ template<unsigned int dim> void cell_list_part_reorder_hilbert_benchmark(size_t size_t bc[dim]; for (size_t i = 0; i < dim; i++) - bc[i] = PERIODIC; + {bc[i] = PERIODIC;} vector_dist<dim,float, aggregate<float[dim]> > vd(k_int,box,bc,Ghost<dim,float>(r_cut)); @@ -235,13 +204,9 @@ template<unsigned int dim> void cell_list_part_reorder_hilbert_benchmark(size_t openfpm::vector<double> measures; for (size_t h = 0 ; h < N_STAT_TEST; h++) - measures.add(benchmark_reorder(vd,m)); + {measures.add(benchmark_reorder(vd,m));} standard_deviation(measures,sum_reorder_mean,sum_reorder_dev); - //Average reorder time - cl_time_reorder_hilb_mean.get(r).get(part).get(i) = sum_reorder_mean; - cl_time_reorder_hilb_dev.get(r).get(part).get(i) = sum_reorder_dev; - vd.template ghost_get<0>(); //Get cell list @@ -256,15 +221,16 @@ template<unsigned int dim> void cell_list_part_reorder_hilbert_benchmark(size_t measures.clear(); for (size_t l = 0 ; l < N_STAT_TEST ; l++) - measures.add(benchmark_calc_forces<dim>(NN,vd,r_cut)); + {measures.add(benchmark_calc_forces<dim>(NN,vd,r_cut));} standard_deviation(measures,sum_fr_mean,sum_fr_dev); - cl_time_hilb_mean.get(r).get(part).get(i) = sum_fr_mean; - cl_time_hilb_dev.get(r).get(part).get(i) = sum_fr_dev; - + 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); + 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); if (v_cl.getProcessUnitID() == 0) - 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; + {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;} + + c++; } } } @@ -272,53 +238,11 @@ template<unsigned int dim> void cell_list_part_reorder_hilbert_benchmark(size_t } - -/*! \brief Function for cell list performance report - * - */ -template<unsigned int dim> void cell_list_part_reorder_report(GoogleChart & cg, - size_t n_moving, - openfpm::vector<float> & cl_r_cutoff, - openfpm::vector<size_t> & cl_n_particles, - openfpm::vector<size_t> cl_orders, - openfpm::vector<openfpm::vector<openfpm::vector<double>>> cl_time_hilb_mean, - openfpm::vector<openfpm::vector<double>> cl_time_rand_mean, - openfpm::vector<openfpm::vector<openfpm::vector<double>>> cl_time_reorder_mean, - openfpm::vector<openfpm::vector<openfpm::vector<double>>> cl_time_hilb_dev, - openfpm::vector<openfpm::vector<double>> cl_time_rand_dev, - openfpm::vector<openfpm::vector<openfpm::vector<double>>> cl_time_reorder_dev) -{ - openfpm::vector<size_t> x; - - for (size_t i = 0; i < cl_n_particles.size() ; i++) - x.add(cl_n_particles.get(i)); - - // Speedup graphs data - - cl_part_time<dim>(cg, - cl_n_particles, - cl_r_cutoff, - cl_orders, - cl_time_hilb_mean, - cl_time_rand_mean, - cl_time_hilb_dev, - cl_time_rand_dev); - - cl_part_reorder_time<dim>(cg, - cl_n_particles, - cl_r_cutoff, - cl_orders, - cl_time_reorder_mean, - cl_time_reorder_dev); -} - - - BOOST_AUTO_TEST_CASE( vector_dist_cl_random_test ) { //Benchmark test for 2D and 3D - cell_list_part_reorder_random_benchmark<3>(k_start,k_min,r_cutoff,n_particles,time_rand_mean,time_rand_dev); - cell_list_part_reorder_random_benchmark<2>(k_start,k_min,r_cutoff,n_particles,time_rand_2_mean,time_rand_2_dev); + cell_list_part_reorder_random_benchmark<3>(k_start,k_min,r_cutoff,n_particles); + cell_list_part_reorder_random_benchmark<2>(k_start,k_min,r_cutoff,n_particles); } BOOST_AUTO_TEST_CASE( vector_dist_cl_hilbert_test ) @@ -330,11 +254,7 @@ BOOST_AUTO_TEST_CASE( vector_dist_cl_hilbert_test ) dist, r_cutoff, n_particles, - orders, - time_hilb_mean, - time_reorder_mean, - time_hilb_dev, - time_reorder_dev); + orders); cell_list_part_reorder_hilbert_benchmark<2>(k_start, k_min, @@ -342,46 +262,70 @@ BOOST_AUTO_TEST_CASE( vector_dist_cl_hilbert_test ) dist, r_cutoff, n_particles, - orders, - time_hilb_2_mean, - time_reorder_2_mean, - time_hilb_2_dev, - time_reorder_2_dev); + orders); } BOOST_AUTO_TEST_CASE(vector_dist_cl_performance_write_report) { - GoogleChart cg; - - //Write report for 2D and 3D - cell_list_part_reorder_report<3>(cg, - n_moving, - r_cutoff, - n_particles, - orders, - time_hilb_mean, - time_rand_mean, - time_reorder_mean, - time_hilb_dev, - time_rand_dev, - time_reorder_dev); - - cell_list_part_reorder_report<2>(cg, - n_moving, - r_cutoff, - n_particles, - orders, - time_hilb_2_mean, - time_rand_2_mean, - time_reorder_2_mean, - time_hilb_2_dev, - time_rand_2_dev, - time_reorder_2_dev); - - addUpdtateTime(cg); - - if (create_vcluster().getProcessUnitID() == 0) - cg.write("Celllist_part_ord.html"); + // Create a graphs + + //For different r_cut + for (size_t r = 0; r < r_cutoff.size(); r++ ) + { + report_cl_preo.graphs.put("graphs.graph(" + std::to_string(r) + ").type","line"); + 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))); + report_cl_preo.graphs.add("graphs.graph(" + std::to_string(r) + ").x.title","number of particles"); + report_cl_preo.graphs.add("graphs.graph(" + std::to_string(r) + ").y.title","Time seconds"); + for (size_t i = 0 ; i < orders.size() ; i++) + { + size_t m = orders.get(i); + 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"); + 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"); + 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"); + } + 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"); + 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"); + report_cl_preo.graphs.add("graphs.graph(" + std::to_string(r) + ").y.data(0).title","Random reorder"); + report_cl_preo.graphs.add("graphs.graph(" + std::to_string(r) + ").options.log_y","true"); + } + + //For different r_cut + for (size_t r = 0; r < r_cutoff.size(); r++ ) + { + report_cl_preo.graphs.put("graphs.graph(" + std::to_string(r + r_cutoff.size()) + ").type","line"); + 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))); + report_cl_preo.graphs.add("graphs.graph(" + std::to_string(r + r_cutoff.size()) + ").x.title","number of particles"); + report_cl_preo.graphs.add("graphs.graph(" + std::to_string(r + r_cutoff.size()) + ").y.title","Time seconds"); + for (size_t i = 0 ; i < orders.size() ; i++) + { + size_t m = orders.get(i); + 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"); + 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"); + 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"); + } + 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"); + 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"); + report_cl_preo.graphs.add("graphs.graph(" + std::to_string(r + r_cutoff.size()) + ").y.data(0).title","Random reorder"); + report_cl_preo.graphs.add("graphs.graph(" + std::to_string(r + r_cutoff.size()) + ").options.log_y","true"); + } + + if (create_vcluster().rank() == 0) + { + boost::property_tree::xml_writer_settings<std::string> settings(' ', 4); + boost::property_tree::write_xml("celllist_partreo_performance.xml", report_cl_preo.graphs,std::locale(),settings); + + std::string file_xml_ref(test_dir); + file_xml_ref += std::string("/openfpm_pdata/celllist_partreo_performance_ref.xml"); + + GoogleChart cg; + + StandardXMLPerformanceGraph("celllist_partreo_performance.xml",file_xml_ref,cg); + + addUpdtateTime(cg,create_vcluster().size()); + + if (create_vcluster().getProcessUnitID() == 0) + {cg.write("celllist_part_ord.html");} + } } BOOST_AUTO_TEST_SUITE_END() diff --git a/src/Vector/performance/cl_comp_performance_graph.hpp b/src/Vector/performance/cl_comp_performance_graph.hpp deleted file mode 100644 index feedf4d33..000000000 --- a/src/Vector/performance/cl_comp_performance_graph.hpp +++ /dev/null @@ -1,191 +0,0 @@ -/* - * performance_graph.hpp - * - * Created on: Dec 23, 2016 - * Author: i-bird - */ - -#ifndef SRC_VECTOR_PERFORMANCE_CL_COMP_PERFORMANCE_GRAPH_HPP_ -#define SRC_VECTOR_PERFORMANCE_CL_COMP_PERFORMANCE_GRAPH_HPP_ - -#include "Plot/GoogleChart.hpp" -#include "vector_dist_performance_util.hpp" - -/////////////////////////// COMPUTATIONAL HILBERT CURVE ORDERING /////////////////////////////////////// - -/*! \brief Time to calculate forces using random order or hilber curve compute ordering - * - * \tparam dim dimensionality of the test - * - * \param cg GoogleChart object - * \param cl_n_particles number of particles for each test - * \param cl_r_cutoff cell-list spacing used to construct a cell-list - * \param cl_time_hilb for each particle set, for each cut-off radius time to calculate the forces (Hilbert curve order) - * \param cl_time_rand for each particle set, for each cut-off radius, time to calculate the forces (no order) - * - */ -template<unsigned int dim> void cl_comp_normal_vs_hilbert_force_time(GoogleChart & cg, - openfpm::vector<size_t> & cl_n_particles, - openfpm::vector<float> & cl_r_cutoff, - openfpm::vector<openfpm::vector<double>> & cl_time_hilb_mean, - openfpm::vector<openfpm::vector<double>> & cl_time_rand_mean, - openfpm::vector<openfpm::vector<double>> & cl_time_hilb_dev, - openfpm::vector<openfpm::vector<double>> & cl_time_rand_dev, - double & warning_level, - double & norm) -{ - std::string file_mean(test_dir); - std::string file_var(test_dir); - file_mean += std::string("/openfpm_pdata/cl_comp_norm_hilbert_mean_" + std::to_string(dim) + std::string("_ref")); - file_var += std::string("/openfpm_pdata/cl_comp_norm_hilbert_dev_" + std::to_string(dim) + std::string("_ref")); - - std::string file_mean_save = std::string("cl_comp_norm_hilbert_mean_" + std::to_string(dim) + std::to_string("_ref")); - std::string file_var_save = std::string("cl_comp_norm_hilbert_dev_" + std::to_string(dim) + std::to_string("_ref")); - - openfpm::vector<size_t> xp = cl_n_particles; - - openfpm::vector<openfpm::vector<openfpm::vector<double>>> yp_mean; - openfpm::vector<openfpm::vector<openfpm::vector<double>>> yp_dev; - - openfpm::vector<std::string> names; - openfpm::vector<std::string> gnames; - - yp_mean.resize(cl_time_rand_mean.size()); - yp_dev.resize(cl_time_rand_dev.size()); - for (size_t i = 0 ; i < yp_mean.size() ; i++) - { - yp_mean.get(i).resize(cl_time_rand_mean.get(i).size()); - yp_dev.get(i).resize(cl_time_rand_dev.get(i).size()); - - for (size_t j = 0 ; j < yp_mean.get(i).size() ; j++) - { - yp_mean.get(i).get(j).resize(2); - yp_dev.get(i).get(j).resize(2); - - yp_mean.get(i).get(j).get(0) = cl_time_hilb_mean.get(i).get(j); - yp_dev.get(i).get(j).get(0) = cl_time_hilb_dev.get(i).get(j); - - yp_mean.get(i).get(j).get(1) = cl_time_rand_mean.get(i).get(j); - yp_dev.get(i).get(j).get(1) = cl_time_rand_dev.get(i).get(j); - } - } - - names.add("Hilbert cell list"); - names.add("Random cell list"); - - for (size_t i = 0 ; i < cl_r_cutoff.size() ; i++) - gnames.add("Cell-list performance, cut-off radius: " + std::to_string(cl_r_cutoff.get(i))); - - std::string y_string = std::string("Time to calculate forces"); - std::string x_string = std::string("Number of particles"); - - std::string str("<h1>Cell-list " + std::to_string(dim) + "-D performance test: </h1>"); - str += "<h2> 1) Time to calculate forces</h2>"; - cg.addHTML(str); - - StandardPerformanceGraph(file_mean, - file_var, - file_mean_save, - file_var_save, - cg, - xp, - yp_mean, - yp_dev, - names, - gnames, - x_string, - y_string, - true); -} - -/*! \brief Output the graph normal cell-list vs Hilbert cell-list (Total time) - * - * \tparam dim dimensionality of the test - * - * \param cg GoogleChart object - * \param cl_n_particles number of particles for each test - * \param cl_r_cutoff cell-list spacing used to construct a cell-list - * \param cl_time_force_hilb for each particle set, for each cut-off radius, for each order time to calculate the forces - * \param cl_time_force_rand for each particle set, for each cut-off radius, time to calculate the forces - * - */ -template<unsigned int dim> void cl_comp_normal_vs_hilbert_create_time(GoogleChart & cg, - openfpm::vector<size_t> & cl_n_particles, - openfpm::vector<float> & cl_r_cutoff, - openfpm::vector<openfpm::vector<double>> & cl_time_create_hilb_mean, - openfpm::vector<openfpm::vector<double>> & cl_time_create_rand_mean, - openfpm::vector<openfpm::vector<double>> & cl_time_create_hilb_dev, - openfpm::vector<openfpm::vector<double>> & cl_time_create_rand_dev, - double & warning_level, - double & norm) -{ - std::string file_mean(test_dir); - std::string file_var(test_dir); - file_mean += std::string("/openfpm_pdata/cl_comp_create_norm_hilbert_mean_" + std::to_string(dim) + std::string("_ref")); - file_var += std::string("/openfpm_pdata/cl_comp_create_norm_hilbert_dev_" + std::to_string(dim) + std::string("_ref")); - - std::string file_mean_save = std::string("cl_comp_create_norm_hilbert_mean_" + std::to_string(dim) + std::string("_ref")); - std::string file_var_save = std::string("cl_comp_create_norm_hilbert_dev_" + std::to_string(dim) + std::string("_ref")); - - openfpm::vector<size_t> xp = cl_n_particles; - - openfpm::vector<openfpm::vector<openfpm::vector<double>>> yp_mean; - openfpm::vector<openfpm::vector<openfpm::vector<double>>> yp_dev; - - openfpm::vector<std::string> names; - openfpm::vector<std::string> gnames; - - yp_mean.resize(cl_time_create_rand_mean.size()); - yp_dev.resize(cl_time_create_rand_dev.size()); - for (size_t i = 0 ; i < yp_mean.size() ; i++) - { - yp_mean.get(i).resize(cl_time_create_rand_mean.get(i).size()); - yp_dev.get(i).resize(cl_time_create_rand_dev.get(i).size()); - - for (size_t j = 0 ; j < yp_mean.get(i).size() ; j++) - { - yp_mean.get(i).get(j).resize(2); - yp_dev.get(i).get(j).resize(2); - - yp_mean.get(i).get(j).get(0) = cl_time_create_hilb_mean.get(i).get(j); - yp_dev.get(i).get(j).get(0) = cl_time_create_hilb_dev.get(i).get(j); - - yp_mean.get(i).get(j).get(1) = cl_time_create_rand_mean.get(i).get(j); - yp_dev.get(i).get(j).get(1) = cl_time_create_rand_dev.get(i).get(j); - } - } - - names.add("Hilbert cell list"); - names.add("Random cell list"); - - for (size_t i = 0 ; i < cl_r_cutoff.size() ; i++) - gnames.add("Cell-list performance, cut-off radius: " + std::to_string(cl_r_cutoff.get(i))); - - std::string y_string = std::string("Time to create the cell-list"); - std::string x_string = std::string("Number of particles"); - - std::string str("<h1>Cell-list " + std::to_string(dim) + "-D performance test: </h1>"); - str += "<h2> 1) Time to create the cell-list</h2>"; - cg.addHTML(str); - - StandardPerformanceGraph(file_mean, - file_var, - file_mean_save, - file_var_save, - cg, - xp, - yp_mean, - yp_dev, - names, - gnames, - x_string, - y_string, - true); -} - - -///////////////////////////////// PARTICLE REORDERING ////////////////////////////////////////////////////// - - - -#endif /* SRC_VECTOR_PERFORMANCE_CL_COMP_PERFORMANCE_GRAPH_HPP_ */ diff --git a/src/Vector/performance/cl_part_performance_graph.hpp b/src/Vector/performance/cl_part_performance_graph.hpp deleted file mode 100644 index 3104c696a..000000000 --- a/src/Vector/performance/cl_part_performance_graph.hpp +++ /dev/null @@ -1,209 +0,0 @@ -/* - * cl_part_performance_graph.hpp - * - * Created on: Dec 23, 2016 - * Author: i-bird - */ - -#ifndef SRC_VECTOR_PERFORMANCE_CL_PART_PERFORMANCE_GRAPH_HPP_ -#define SRC_VECTOR_PERFORMANCE_CL_PART_PERFORMANCE_GRAPH_HPP_ - -#include "vector_dist_performance_util.hpp" - -template<unsigned int dim> void cl_part_time(GoogleChart & cg, - openfpm::vector<size_t> & cl_n_particles, - openfpm::vector<float> & cl_r_cutoff, - openfpm::vector<size_t> &cl_orders, - openfpm::vector<openfpm::vector<openfpm::vector<double>>> cl_time_hilb_mean, - openfpm::vector<openfpm::vector<double>> cl_time_rand_mean, - openfpm::vector<openfpm::vector<openfpm::vector<double>>> cl_time_hilb_dev, - openfpm::vector<openfpm::vector<double>> cl_time_rand_dev) -{ - std::string file_mean(test_dir); - std::string file_var(test_dir); - file_mean += std::string("/openfpm_pdata/cl_part_norm_hilbert_mean_" + std::to_string(dim) + std::string("_ref")); - file_var += std::string("/openfpm_pdata/cl_part_norm_hilbert_dev_" + std::to_string(dim) + std::string("_ref")); - - std::string file_mean_save = std::string("cl_part_norm_hilbert_mean_" + std::to_string(dim) + std::to_string("_ref")); - std::string file_var_save = std::string("cl_part_norm_hilbert_dev_" + std::to_string(dim) + std::to_string("_ref")); - - openfpm::vector<size_t> xp = cl_n_particles; - - openfpm::vector<openfpm::vector<openfpm::vector<double>>> yp_mean; - openfpm::vector<openfpm::vector<openfpm::vector<double>>> yp_dev; - - openfpm::vector<std::string> names; - openfpm::vector<std::string> gnames; - - yp_mean.resize(cl_time_rand_mean.size()); - yp_dev.resize(cl_time_rand_dev.size()); - for (size_t i = 0 ; i < yp_mean.size() ; i++) - { - yp_mean.get(i).resize(cl_time_rand_mean.get(i).size()); - yp_dev.get(i).resize(cl_time_rand_dev.get(i).size()); - - for (size_t j = 0 ; j < yp_mean.get(i).size() ; j++) - { - yp_mean.get(i).get(j).resize(1+cl_time_hilb_mean.get(i).get(j).size()); - yp_dev.get(i).get(j).resize(1+cl_time_hilb_dev.get(i).get(j).size()); - - for (size_t k = 0 ; k < cl_time_hilb_mean.get(i).get(j).size() ; k++) - { - yp_mean.get(i).get(j).get(k) = cl_time_hilb_mean.get(i).get(j).get(k); - yp_dev.get(i).get(j).get(k) = cl_time_hilb_dev.get(i).get(j).get(k); - } - yp_mean.get(i).get(j).get(cl_time_hilb_mean.get(i).get(j).size()) = cl_time_rand_mean.get(i).get(j); - yp_dev.get(i).get(j).get(cl_time_hilb_mean.get(i).get(j).size()) = cl_time_rand_dev.get(i).get(j); - } - } - - for (size_t i = 0 ; i < cl_orders.size() ; i++) - {names.add(std::string("Order of: " + std::to_string(cl_orders.get(i))));} - names.add("No-order"); - - for (size_t i = 0 ; i < cl_r_cutoff.size() ; i++) - gnames.add("Cell-list performance, cut-off radius: " + std::to_string(cl_r_cutoff.get(i))); - - std::string y_string = std::string("Time to calculate forces (s)"); - std::string x_string = std::string("Number of particles"); - - std::string str("<h1>Cell-list " + std::to_string(dim) + "-D performance tests: </h1>"); - str += "<h2> 1) Time to calculate forces in the case of particles randomly ordered in a vector of particles, and in the case of particles ordered along an hilbert curve of order N</h2>"; - - cg.addHTML(str); - - StandardPerformanceGraph(file_mean, - file_var, - file_mean_save, - file_var_save, - cg, - xp, - yp_mean, - yp_dev, - names, - gnames, - x_string, - y_string, - false); -} - -template<unsigned int dim> void cl_part_reorder_time(GoogleChart & cg, - openfpm::vector<size_t> & cl_n_particles, - openfpm::vector<float> & cl_r_cutoff, - openfpm::vector<size_t> &cl_orders, - openfpm::vector<openfpm::vector<openfpm::vector<double>>> cl_time_reorder_mean, - openfpm::vector<openfpm::vector<openfpm::vector<double>>> cl_time_reorder_dev) -{ - // Get the test dir - std::string file_mean(test_dir); - std::string file_var(test_dir); - file_mean += std::string("/openfpm_pdata/cl_part_reorder_hilbert_mean_" + std::to_string(dim) + std::string("_ref")); - file_var += std::string("/openfpm_pdata/cl_part_reorder_hilbert_dev_" + std::to_string(dim) + std::string("_ref")); - - openfpm::vector<openfpm::vector<openfpm::vector<double>>> y_ref_mean; - openfpm::vector<openfpm::vector<openfpm::vector<double>>> y_ref_dev; - y_ref_mean.load(file_mean); - y_ref_dev.load(file_var); - - // warning level - openfpm::vector<int> warning_vlevel; - - // graphs data - openfpm::vector<size_t> x; - openfpm::vector<openfpm::vector<openfpm::vector<double>>> y; - openfpm::vector<openfpm::vector<openfpm::vector<double>>> y_dev; - openfpm::vector<std::string> yn; - - for (size_t i = 0; i < cl_n_particles.size() ; i++) - x.add(cl_n_particles.get(i)); - - for (size_t i = 0; i < cl_orders.size(); i++) - yn.add("Order of: " + std::to_string(cl_orders.get(i))); - - // Add reorder time - y.resize(cl_time_reorder_mean.size()); - y_dev.resize(cl_time_reorder_dev.size()); - for (size_t r = 0; r < cl_time_reorder_mean.size(); r++) - { - y.get(r).resize(cl_time_reorder_mean.get(r).size()); - y_dev.get(r).resize(cl_time_reorder_mean.get(r).size()); - for (size_t k = 0; k < cl_time_reorder_mean.get(r).size(); k++) - { - // reorder time - for (size_t m = 0; m < cl_time_reorder_mean.get(r).get(k).size(); m++) - { - // Put time - y.get(r).get(k).add(cl_time_reorder_mean.get(r).get(k).get(m)); - y_dev.get(r).get(k).add(cl_time_reorder_dev.get(r).get(k).get(m)); - } - } - } - - // Save y - y.save("cl_part_reorder_hilbert_mean_" + std::to_string(dim) + std::to_string("_ref")); - y_dev.save("cl_part_reorder_hilbert_dev_" + std::to_string(dim) + std::to_string("_ref")); - - if (y_ref_mean.size() != 0) - { - yn.clear(); - y.clear(); - - size_t i = cl_orders.size()-1; - yn.add("Order of: " + std::to_string(cl_orders.get(i))); - yn.add("interval"); - yn.add("interval"); - - // Add reorder time - y.resize(cl_time_reorder_mean.size()); - for (size_t r = 0; r < cl_time_reorder_mean.size(); r++) - { - int warning_level = -1; - - y.get(r).resize(cl_time_reorder_mean.get(r).size()); - for (size_t k = 0; k < cl_time_reorder_mean.get(r).size(); k++) - { - // reorder time - size_t m = cl_orders.size()-1; - - // Put time - y.get(r).get(k).add(cl_time_reorder_mean.get(r).get(k).get(m)); - y.get(r).get(k).add(y_ref_mean.get(r).get(k).get(m) - 3.0*y_ref_dev.get(r).get(k).get(m) ); - y.get(r).get(k).add(y_ref_mean.get(r).get(k).get(m) + 3.0*y_ref_dev.get(r).get(k).get(m) ); - - warning_set(warning_level,cl_time_reorder_mean.get(r).get(k).get(m),y_ref_mean.get(r).get(k).get(m),y_ref_dev.get(r).get(k).get(m)); - } - - warning_vlevel.add(warning_level); - } - } - - // Speedup graphs report - - // Google charts options - GCoptions options; - - options.yAxis = std::string("Time (s)"); - options.xAxis = std::string("Number of particles"); - options.lineWidth = 2; - options.more = GC_ZOOM; - - //options.more = "hAxis: {logScale: true}"; - - std::string str("<h1>Cell-list " + std::to_string(dim) + "-D performance tests: </h1>"); - str += "<h2> 1) Time to reorder the distributed vector</h2>"; - - cg.addHTML(str); - - for (size_t i = 0; i < cl_r_cutoff.size(); i++) - { - std::string chart_area; - if (warning_vlevel.size() != 0) - addchartarea(chart_area,warning_vlevel.get(i)); - options.more = GC_Y_LOG + "," + GC_ZOOM + chart_area; - - options.title = std::string("Cell-list performance, cut-off radius: " + std::to_string(cl_r_cutoff.get(i))); - cg.AddLinesGraph(x,y.get(i),yn,options); - } -} - -#endif /* SRC_VECTOR_PERFORMANCE_CL_PART_PERFORMANCE_GRAPH_HPP_ */ diff --git a/src/Vector/performance/verlet_performance_tests.hpp b/src/Vector/performance/verlet_performance_tests.hpp index f955031c7..d05562684 100644 --- a/src/Vector/performance/verlet_performance_tests.hpp +++ b/src/Vector/performance/verlet_performance_tests.hpp @@ -10,6 +10,14 @@ #include "util/stat/common_statistics.hpp" +// Property tree +struct report_verlet_tests +{ + boost::property_tree::ptree graphs; +}; + +report_verlet_tests report_vl; + /*! \brief Print a string about the test * * \param test string to print @@ -22,7 +30,7 @@ void print_test_v(std::string test, size_t sz) std::cout << test << " " << sz << "\n"; } -BOOST_AUTO_TEST_SUITE( verletlist_part_reorder_performance_test ) +BOOST_AUTO_TEST_SUITE( verletlist_performance_test ) ///////////////////// INPUT DATA ////////////////////// @@ -39,17 +47,6 @@ size_t k_min = 15000; // Numbers of particles vector openfpm::vector<size_t> n_particles; -// Vectors to store the data for 2D -openfpm::vector<openfpm::vector<double>> time_force_mean; -openfpm::vector<openfpm::vector<double>> time_force_dev; -openfpm::vector<openfpm::vector<double>> time_create_mean; -openfpm::vector<openfpm::vector<double>> time_create_dev; - -// Vectors to store the data for 3D -openfpm::vector<openfpm::vector<double>> time_force_mean_2; -openfpm::vector<openfpm::vector<double>> time_force_dev_2; -openfpm::vector<openfpm::vector<double>> time_create_mean_2; -openfpm::vector<openfpm::vector<double>> time_create_dev_2; /*! \brief Function for verlet test without an Hilbert curve reordering (unordered positioning) * @@ -57,17 +54,8 @@ openfpm::vector<openfpm::vector<double>> time_create_dev_2; template<unsigned int dim> void vd_verlet_random_benchmark(size_t k_start, size_t k_min, openfpm::vector<float> & r_cutoff, - openfpm::vector<size_t> & n_particles, - openfpm::vector<openfpm::vector<double>> & time_force_mean, - openfpm::vector<openfpm::vector<double>> & time_create_mean, - openfpm::vector<openfpm::vector<double>> & time_force_dev, - openfpm::vector<openfpm::vector<double>> & time_create_dev) + openfpm::vector<size_t> & n_particles) { - time_force_mean.resize(r_cutoff.size()); - time_create_mean.resize(r_cutoff.size()); - time_force_dev.resize(r_cutoff.size()); - time_create_dev.resize(r_cutoff.size()); - std::string str("Testing " + std::to_string(dim) + "D vector no-order, Verlet-list"); print_test_v(str,0); @@ -80,16 +68,23 @@ template<unsigned int dim> void vd_verlet_random_benchmark(size_t k_start, //Cut-off radius float r_cut = r_cutoff.get(r); + report_vl.graphs.put("performance.verletlist.getVerletList" + std::to_string(dim) + "D(" + std::to_string(r) + ").rcut",r_cut); + //Number of particles size_t k = k_start * v_cl.getProcessingUnits(); //Counter number for amounts of particles size_t k_count = 1 + log2(k/k_min); + int c = 0; + for (size_t k_int = k ; k_int >= k_min ; k_int/=2 ) { BOOST_TEST_CHECKPOINT( "Testing " << dim << "D vector without an Hilbert curve reordering k=" << k_int ); + report_vl.graphs.put("performance.verletlist.getVerletList" + std::to_string(dim) + "D(" + std::to_string(r) + ").npart(" + std::to_string(c) + ").n",k_int); + report_vl.graphs.put("performance.verletlist.calc_forces" + std::to_string(dim) + "D(" + std::to_string(r) + ").npart(" + std::to_string(c) + ").n",k_int); + if (n_particles.size() < k_count) n_particles.add(k_int); @@ -119,12 +114,11 @@ template<unsigned int dim> void vd_verlet_random_benchmark(size_t k_start, double sum_verlet_mean = 0; double sum_verlet_dev = 0; for (size_t n = 0 ; n < N_STAT_TEST; n++) - measures.add(benchmark_get_verlet(vd,r_cut)); + {measures.add(benchmark_get_verlet(vd,r_cut));} standard_deviation(measures,sum_verlet_mean,sum_verlet_dev); - //Average total time - time_create_mean.get(r).add(sum_verlet_mean); - time_create_dev.get(r).add(sum_verlet_dev); + report_vl.graphs.put("performance.verletlist.getVerletList" + std::to_string(dim) + "D(" + std::to_string(r) + ").npart(" + std::to_string(c) + ").mean",sum_verlet_mean); + report_vl.graphs.put("performance.verletlist.getVerletList" + std::to_string(dim) + "D(" + std::to_string(r) + ").npart(" + std::to_string(c) + ").dev",sum_verlet_dev); //Calculate forces @@ -134,276 +128,99 @@ template<unsigned int dim> void vd_verlet_random_benchmark(size_t k_start, measures.clear(); for (size_t l = 0 ; l < N_STAT_TEST ; l++) - measures.add(benchmark_calc_forces<dim>(NN,vd,r_cut)); + {measures.add(benchmark_calc_forces<dim>(NN,vd,r_cut));} standard_deviation(measures,sum_fr_mean,sum_fr_dev); - time_force_mean.get(r).add(sum_fr_mean); - time_force_dev.get(r).add(sum_fr_dev); + + report_vl.graphs.put("performance.verletlist.calc_forces" + std::to_string(dim) + "D(" + std::to_string(r) + ").npart(" + std::to_string(c) + ").mean",sum_fr_mean); + report_vl.graphs.put("performance.verletlist.calc_forces" + std::to_string(dim) + "D(" + std::to_string(r) + ").npart(" + std::to_string(c) + ").dev",sum_fr_dev); if (v_cl.getProcessUnitID() == 0) - std::cout << "Particles: " << k_int << "," << "cut-off: " << r_cut << " time to construct a Verlet list = " << sum_verlet_mean << " dev: " << sum_verlet_dev << " calculate force = " << sum_fr_mean << " dev: " << sum_fr_dev << std::endl; + {std::cout << "Particles: " << k_int << "," << "cut-off: " << r_cut << " time to construct a Verlet list = " << sum_verlet_mean << " dev: " << sum_verlet_dev << " calculate force = " << sum_fr_mean << " dev: " << sum_fr_dev << std::endl;} + + c++; } } } } -/*! \brief Function for verlet test with an Hilbert curve reordering - * - */ -template<unsigned int dim> void vd_verlet_hilbert_benchmark(size_t k_start, size_t k_min, double ghost_part,openfpm::vector<float> & r_cutoff, openfpm::vector<size_t> & n_particles, openfpm::vector<size_t> &orders, openfpm::vector<openfpm::vector<openfpm::vector<double>>> &time_hilb, openfpm::vector<openfpm::vector<openfpm::vector<double>>> &time_total_hilb) + +BOOST_AUTO_TEST_CASE( vector_dist_verlet_test ) { - time_hilb.resize(r_cutoff.size()); - for (size_t r = 0; r < time_hilb.size(); r++) - { - time_hilb.get(r).resize(n_particles.size()); - for (size_t k = 0; k < time_hilb.get(r).size(); k++) - { - time_hilb.get(r).get(k).resize(orders.size()); - } - } + //Benchmark test for 2D and 3D + vd_verlet_random_benchmark<3>(k_start,k_min,r_cutoff,n_particles); + vd_verlet_random_benchmark<2>(k_start,k_min,r_cutoff,n_particles); +} - time_total_hilb.resize(r_cutoff.size()); - for (size_t r = 0; r < time_total_hilb.size(); r++) +BOOST_AUTO_TEST_CASE(vector_dist_verlet_performance_write_report) +{ + //For different r_cut + for (size_t r = 0; r < r_cutoff.size(); r++ ) { - time_total_hilb.get(r).resize(n_particles.size()); - for (size_t k = 0; k < time_total_hilb.get(r).size(); k++) - { - time_total_hilb.get(r).get(k).resize(orders.size()); - } + report_vl.graphs.put("graphs.graph(" + std::to_string(r) + ").type","line"); + report_vl.graphs.add("graphs.graph(" + std::to_string(r) + ").title","getVerletList 3D performance r_cut=" + std::to_string(r_cutoff.get(r))); + report_vl.graphs.add("graphs.graph(" + std::to_string(r) + ").x.title","number of particles"); + report_vl.graphs.add("graphs.graph(" + std::to_string(r) + ").y.title","Time seconds"); + report_vl.graphs.add("graphs.graph(" + std::to_string(r) + ").y.data(0).source","performance.verletlist.getVerletList3D(" + std::to_string(r) + ").npart(#).mean"); + report_vl.graphs.add("graphs.graph(" + std::to_string(r) + ").x.data(0).source","performance.verletlist.getVerletList3D(" + std::to_string(r) + ").npart(#).n"); + report_vl.graphs.add("graphs.graph(" + std::to_string(r) + ").y.data(0).title","Verlet-list"); + report_vl.graphs.add("graphs.graph(" + std::to_string(r) + ").options.log_y","true"); } - std::string str("Testing " + std::to_string(dim) + "D vector, Hilbert curve reordering, Verlet-list"); - print_test_v(str,0); - - // For different r_cut + //For different r_cut for (size_t r = 0; r < r_cutoff.size(); r++ ) { - Vcluster<> & v_cl = create_vcluster(); - - //Cut-off radius - float r_cut = r_cutoff.get(r); - - // Number of particles - size_t k = k_start * v_cl.getProcessingUnits(); - - //For different curve orders - for ( size_t i = 0; i < orders.size(); i++) - { - size_t m = orders.get(i); - size_t part = 0; - - for (size_t k_int = k ; k_int >= k_min ; k_int/=2, part++ ) - { - BOOST_TEST_CHECKPOINT( "Testing " << dim << "D vector with an Hilbert curve reordering k=" << k_int ); - - Box<dim,float> box; - - for (size_t i = 0; i < dim; i++) - { - box.setLow(i,0.0); - box.setHigh(i,1.0); - } - - // Boundary conditions - size_t bc[dim]; - - for (size_t i = 0; i < dim; i++) - bc[i] = PERIODIC; - - vector_dist<dim,float, aggregate<float[dim]>, CartDecomposition<dim,float> > vd(k_int,box,bc,Ghost<dim,float>(ghost_part)); - - // Initialize a dist vector - vd_initialize<dim>(vd, v_cl, k_int); - - vd.template ghost_get<0>(); - - //Reorder a vector - - double sum_reorder = 0; - for (size_t h = 0 ; h < N_VERLET_TEST; h++) - sum_reorder += benchmark_reorder(vd,m); - sum_reorder /= N_VERLET_TEST; - - //Get verlet list - - double sum_verlet = 0; - - for (size_t n = 0 ; n < N_VERLET_TEST; n++) - sum_verlet += benchmark_get_verlet(vd,r_cut); - sum_verlet /= N_VERLET_TEST; - //Average total time - time_total_hilb.get(r).get(part).get(i) = sum_verlet; - - //Calculate forces - - auto NN = vd.getCellList(r_cut); - double sum_forces = 0; - - for (size_t l = 0 ; l < N_VERLET_TEST; l++) - sum_forces += benchmark_calc_forces<dim>(NN,vd,r_cut); - sum_forces /= N_VERLET_TEST; - time_hilb.get(r).get(part).get(i) = sum_forces; - - if (v_cl.getProcessUnitID() == 0) - std::cout << "Order = " << m << ", Cut-off = " << r_cut << ", Particles = " << k_int << ". Time to reorder: " << sum_reorder << " time to get the verlet-list: " << sum_verlet << " time to calculate forces: " << sum_forces << std::endl; - } - } + report_vl.graphs.put("graphs.graph(" + std::to_string(r_cutoff.size() + r) + ").type","line"); + report_vl.graphs.add("graphs.graph(" + std::to_string(r_cutoff.size() + r) + ").title","calc_force 3D performance r_cut=" + std::to_string(r_cutoff.get(r))); + report_vl.graphs.add("graphs.graph(" + std::to_string(r_cutoff.size() + r) + ").x.title","number of particles"); + report_vl.graphs.add("graphs.graph(" + std::to_string(r_cutoff.size() + r) + ").y.title","Time seconds"); + report_vl.graphs.add("graphs.graph(" + std::to_string(r_cutoff.size() + r) + ").y.data(0).source","performance.verletlist.calc_forces3D(" + std::to_string(r) + ").npart(#).mean"); + report_vl.graphs.add("graphs.graph(" + std::to_string(r_cutoff.size() + r) + ").x.data(0).source","performance.verletlist.calc_forces3D(" + std::to_string(r) + ").npart(#).n"); + report_vl.graphs.add("graphs.graph(" + std::to_string(r_cutoff.size() + r) + ").y.data(0).title","Verlet-list"); + report_vl.graphs.add("graphs.graph(" + std::to_string(r_cutoff.size() + r) + ").options.log_y","true"); } -} - -/*! \brief Function for verlet performance report - * - */ -template<unsigned int dim> void vd_verlet_performance_write_report(GoogleChart & cg, - openfpm::vector<float> & r_cutoff, - openfpm::vector<size_t> & n_particles, - openfpm::vector<openfpm::vector<double>> time_force_mean, - openfpm::vector<openfpm::vector<double>> time_force_dev, - openfpm::vector<openfpm::vector<double>> time_create_mean, - openfpm::vector<openfpm::vector<double>> time_create_dev) -{ - { - std::string file_mean(test_dir); - std::string file_var(test_dir); - file_mean += std::string("/openfpm_pdata/verlet_comp_force_mean_" + std::to_string(dim) + std::string("_ref")); - file_var += std::string("/openfpm_pdata/verlet_comp_force_dev_" + std::to_string(dim) + std::string("_ref")); - - std::string file_mean_save = std::string("verlet_comp_force_mean_" + std::to_string(dim) + std::to_string("_ref")); - std::string file_var_save = std::string("verlet_comp_force_dev_" + std::to_string(dim) + std::to_string("_ref")); - - openfpm::vector<size_t> xp = n_particles; - - openfpm::vector<openfpm::vector<openfpm::vector<double>>> yp_mean; - openfpm::vector<openfpm::vector<openfpm::vector<double>>> yp_dev; - - openfpm::vector<std::string> names; - openfpm::vector<std::string> gnames; - - yp_mean.resize(time_force_mean.size()); - yp_dev.resize(time_force_dev.size()); - for (size_t i = 0 ; i < yp_mean.size() ; i++) + //For different r_cut + for (size_t r = 0; r < r_cutoff.size(); r++ ) { - yp_mean.get(i).resize(time_force_mean.get(i).size()); - yp_dev.get(i).resize(time_force_dev.get(i).size()); - - for (size_t j = 0 ; j < yp_mean.get(i).size() ; j++) - { - yp_mean.get(i).get(j).resize(1); - yp_dev.get(i).get(j).resize(1); - - yp_mean.get(i).get(j).get(0) = time_force_mean.get(i).get(j); - yp_dev.get(i).get(j).get(0) = time_force_dev.get(i).get(j); - } - } - - names.add("Force verlet"); - - for (size_t i = 0 ; i < r_cutoff.size() ; i++) - gnames.add("Verlet-list performance, cut-off radius: " + std::to_string(r_cutoff.get(i))); - - std::string y_string = std::string("Time to calculate forces (s)"); - std::string x_string = std::string("Number of particles"); - - std::string str("<h1>Verlet-list " + std::to_string(dim) + "-D performance test force calculation: </h1>"); - cg.addHTML(str); - - StandardPerformanceGraph(file_mean, - file_var, - file_mean_save, - file_var_save, - cg, - xp, - yp_mean, - yp_dev, - names, - gnames, - x_string, - y_string, - true); + report_vl.graphs.put("graphs.graph(" + std::to_string(2*r_cutoff.size() + r) + ").type","line"); + report_vl.graphs.add("graphs.graph(" + std::to_string(2*r_cutoff.size() + r) + ").title","getVerletList 2D performance r_cut=" + std::to_string(r_cutoff.get(r))); + report_vl.graphs.add("graphs.graph(" + std::to_string(2*r_cutoff.size() + r) + ").x.title","number of particles"); + report_vl.graphs.add("graphs.graph(" + std::to_string(2*r_cutoff.size() + r) + ").y.title","Time seconds"); + report_vl.graphs.add("graphs.graph(" + std::to_string(2*r_cutoff.size() + r) + ").y.data(0).source","performance.verletlist.getVerletList2D(" + std::to_string(r) + ").npart(#).mean"); + report_vl.graphs.add("graphs.graph(" + std::to_string(2*r_cutoff.size() + r) + ").x.data(0).source","performance.verletlist.getVerletList2D(" + std::to_string(r) + ").npart(#).n"); + report_vl.graphs.add("graphs.graph(" + std::to_string(2*r_cutoff.size() + r) + ").y.data(0).title","Verlet-list"); + report_vl.graphs.add("graphs.graph(" + std::to_string(2*r_cutoff.size() + r) + ").options.log_y","true"); } - //////////////////// TIME TO CREATE ////////////////////////// - - { - std::string file_mean(test_dir); - std::string file_var(test_dir); - file_mean += std::string("/openfpm_pdata/verlet_comp_create_mean_" + std::to_string(dim) + std::string("_ref")); - file_var += std::string("/openfpm_pdata/verlet_comp_create_dev_" + std::to_string(dim) + std::string("_ref")); - - std::string file_mean_save = std::string("verlet_comp_create_mean_" + std::to_string(dim) + std::to_string("_ref")); - std::string file_var_save = std::string("verlet_comp_create_dev_" + std::to_string(dim) + std::to_string("_ref")); - openfpm::vector<size_t> xp = n_particles; - - openfpm::vector<openfpm::vector<openfpm::vector<double>>> yp_mean; - openfpm::vector<openfpm::vector<openfpm::vector<double>>> yp_dev; - - openfpm::vector<std::string> names; - openfpm::vector<std::string> gnames; - - yp_mean.resize(time_create_mean.size()); - yp_dev.resize(time_create_dev.size()); - for (size_t i = 0 ; i < yp_mean.size() ; i++) + //For different r_cut + for (size_t r = 0; r < r_cutoff.size(); r++ ) { - yp_mean.get(i).resize(time_create_mean.get(i).size()); - yp_dev.get(i).resize(time_create_dev.get(i).size()); - - for (size_t j = 0 ; j < yp_mean.get(i).size() ; j++) - { - yp_mean.get(i).get(j).resize(1); - yp_dev.get(i).get(j).resize(1); - - yp_mean.get(i).get(j).get(0) = time_create_mean.get(i).get(j); - yp_dev.get(i).get(j).get(0) = time_create_dev.get(i).get(j); - } + report_vl.graphs.put("graphs.graph(" + std::to_string(3*r_cutoff.size() + r) + ").type","line"); + report_vl.graphs.add("graphs.graph(" + std::to_string(3*r_cutoff.size() + r) + ").title","calc_force 2D performance r_cut=" + std::to_string(r_cutoff.get(r))); + report_vl.graphs.add("graphs.graph(" + std::to_string(3*r_cutoff.size() + r) + ").x.title","number of particles"); + report_vl.graphs.add("graphs.graph(" + std::to_string(3*r_cutoff.size() + r) + ").y.title","Time seconds"); + report_vl.graphs.add("graphs.graph(" + std::to_string(3*r_cutoff.size() + r) + ").y.data(0).source","performance.verletlist.calc_forces2D(" + std::to_string(r) + ").npart(#).mean"); + report_vl.graphs.add("graphs.graph(" + std::to_string(3*r_cutoff.size() + r) + ").x.data(0).source","performance.verletlist.calc_forces2D(" + std::to_string(r) + ").npart(#).n"); + report_vl.graphs.add("graphs.graph(" + std::to_string(3*r_cutoff.size() + r) + ").y.data(0).title","Verlet-list"); + report_vl.graphs.add("graphs.graph(" + std::to_string(3*r_cutoff.size() + r) + ").options.log_y","true"); } - names.add("Create verlet"); - - for (size_t i = 0 ; i < r_cutoff.size() ; i++) - gnames.add("Verlet-list performance, cut-off radius: " + std::to_string(r_cutoff.get(i))); - - std::string y_string = std::string("Time to construct a verlet-list (s)"); - std::string x_string = std::string("Number of particles"); - - std::string str("<h1>Verlet-list " + std::to_string(dim) + "-D performance test force calculation: </h1>"); - cg.addHTML(str); - - StandardPerformanceGraph(file_mean, - file_var, - file_mean_save, - file_var_save, - cg, - xp, - yp_mean, - yp_dev, - names, - gnames, - x_string, - y_string, - true); - } -} + if (create_vcluster().rank() == 0) + { + boost::property_tree::xml_writer_settings<std::string> settings(' ', 4); + boost::property_tree::write_xml("verletlist_performance.xml", report_vl.graphs,std::locale(),settings); -BOOST_AUTO_TEST_CASE( vector_dist_verlet_test ) -{ - //Benchmark test for 2D and 3D - vd_verlet_random_benchmark<3>(k_start,k_min,r_cutoff,n_particles,time_force_mean,time_create_mean,time_force_dev,time_create_dev); - vd_verlet_random_benchmark<2>(k_start,k_min,r_cutoff,n_particles,time_force_mean_2,time_create_mean_2,time_force_dev_2,time_create_dev_2); -} + std::string file_xml_ref(test_dir); + file_xml_ref += std::string("/openfpm_pdata/verletlist_performance_ref.xml"); -BOOST_AUTO_TEST_CASE(vector_dist_verlet_performance_write_report) -{ - GoogleChart cg; + GoogleChart cg; - //Write report for 2D and 3D - vd_verlet_performance_write_report<3>(cg,r_cutoff,n_particles,time_force_mean,time_force_dev,time_create_mean,time_create_dev); - vd_verlet_performance_write_report<2>(cg,r_cutoff,n_particles,time_force_mean_2,time_force_dev_2,time_create_mean_2,time_create_dev_2); + StandardXMLPerformanceGraph("verletlist_performance.xml",file_xml_ref,cg); - if (create_vcluster().getProcessUnitID() == 0) - { - addUpdtateTime(cg); + addUpdtateTime(cg,create_vcluster().size()); - cg.write("Verletlist_comp.html"); + if (create_vcluster().getProcessUnitID() == 0) + {cg.write("verletlist_performance.html");} } } -- GitLab