Commit 6c3c41c0 authored by incardon's avatar incardon

Refactor performance test

parent 2357647f
......@@ -12,6 +12,7 @@
#include "data_type/aggregate.hpp"
#include "Plot/GoogleChart.hpp"
#include "vector_dist_performance_util.hpp"
#include "cl_comp_performance_graph.hpp"
BOOST_AUTO_TEST_SUITE( celllist_comp_reorder_performance_test )
......@@ -47,6 +48,204 @@ 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
*
*/
template<unsigned int dim> void cell_list_comp_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<openfpm::vector<double>> & cl_time_create_rand_mean,
openfpm::vector<openfpm::vector<double>> & cl_time_create_rand_dev)
{
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);
{
//For different r_cut
for (size_t r = 0; r < cl_r_cutoff.size(); r++ )
{
Vcluster & v_cl = create_vcluster();
//Cut-off radius
float r_cut = cl_r_cutoff.get(r);
//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);
//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 with a random cell list k=" << k_int );
if (cl_n_particles.size() < k_count)
cl_n_particles.add(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>(r_cut));
// Initialize a dist vector
vd_initialize<dim>(vd, v_cl, k_int);
vd.template ghost_get<0>();
//Get a cell list
auto NN = vd.getCellList(r_cut);
double sum_cl_mean = 0;
double sum_cl_dev = 0;
openfpm::vector<double> measures;
for (size_t n = 0 ; n < N_STAT_TEST; n++)
measures.add(benchmark_get_celllist(NN,vd,r_cut));
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);
//Calculate forces
double sum_fr_mean = 0;
double sum_fr_dev = 0;
measures.clear();
for (size_t l = 0 ; l < N_STAT_TEST; l++)
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);
if (v_cl.getProcessUnitID() == 0)
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;
}
}
}
}
/*! \brief Function for hilb cell list test
*
*/
template<unsigned int dim> void cell_list_comp_reorder_hilbert_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)
{
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);
{
//For different r_cut
for (size_t r = 0; r < cl_r_cutoff.size(); r++ )
{
Vcluster & v_cl = create_vcluster();
//Cut-off radius
float r_cut = cl_r_cutoff.get(r);
//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);
//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 with an Hilbert cell list k=" << k_int );
if (cl_n_particles.size() < k_count)
cl_n_particles.add(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>(r_cut));
// Initialize a dist vector
vd_initialize<dim>(vd, v_cl, k_int);
vd.template ghost_get<0>();
//Get a cell list hilb
auto NN = vd.getCellList_hilb(r_cut);
openfpm::vector<double> measures;
double sum_cl_mean = 0;
double sum_cl_dev = 0;
for (size_t n = 0 ; n < N_VERLET_TEST; n++)
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);
//Calculate forces
double sum_fr_mean = 0;
double sum_fr_dev = 0;
measures.clear();
for (size_t l = 0 ; l < N_VERLET_TEST; l++)
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);
if (v_cl.getProcessUnitID() == 0)
std::cout << "Cut-off = " << r_cut << ", Particles = " << k_int << ". Time to create: " << sum_cl_mean << " dev: " << sum_cl_dev << " time to create a Cell-list: " << sum_fr_mean << " dev: " << sum_fr_dev << std::endl;
}
}
}
}
BOOST_AUTO_TEST_CASE( vector_dist_celllist_random_test )
{
......@@ -93,6 +292,44 @@ BOOST_AUTO_TEST_CASE( vector_dist_celllist_hilbert_test )
time_create_hilb_2_dev);
}
/*! \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)
{
GoogleChart cg;
......@@ -140,6 +377,8 @@ BOOST_AUTO_TEST_CASE(vector_dist_cl_performance_write_report)
}
}
BOOST_AUTO_TEST_SUITE_END()
#endif /* SRC_VECTOR_VECTOR_DIST_CL_HILB_PERFORMANCE_TESTS_HPP_ */
......@@ -12,6 +12,7 @@
#include "Vector/vector_dist.hpp"
#include "data_type/aggregate.hpp"
#include "Plot/GoogleChart.hpp"
#include "cl_part_performance_graph.hpp"
#include <functional>
BOOST_AUTO_TEST_SUITE( celllist_part_reorder_performance_test )
......@@ -51,6 +52,267 @@ 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)
*
*/
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)
{
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);
{
//For different r_cut
for (size_t r = 0; r < cl_r_cutoff.size(); r++ )
{
Vcluster & v_cl = create_vcluster();
//Cut-off radius
float r_cut = cl_r_cutoff.get(r);
//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);
//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 );
if (cl_n_particles.size() < k_count)
cl_n_particles.add(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>(r_cut));
// Initialize a dist vector
vd_initialize<dim>(vd, v_cl, k_int);
vd.template ghost_get<0>();
//Get a cell list
auto NN = vd.getCellList(r_cut);
double sum_fr_mean = 0;
double sum_fr_dev = 0;
benchmark_get_celllist(NN,vd,r_cut);
//Calculate forces
size_t l = 0;
openfpm::vector<double> measures;
for ( ; l < N_STAT_TEST; l++)
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);
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;
}
}
}
}
/*! \brief Function for cell list test with an Hilbert curve reordering
*
*/
template<unsigned int dim> void cell_list_part_reorder_hilbert_benchmark(size_t cl_k_start,
size_t cl_k_min,
size_t n_moving,
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)
{
{
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);
// For different r_cut
for (size_t r = 0; r < cl_r_cutoff.size(); r++ )
{
Vcluster & v_cl = create_vcluster();
// Cut-off radius
float r_cut = cl_r_cutoff.get(r);
// Number of particles
size_t k = cl_k_start * v_cl.getProcessingUnits();
//For different curve orders
for ( size_t i = 0; i < cl_orders.size(); i++)
{
size_t m = cl_orders.get(i);
size_t part = 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 );
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>(r_cut));
// Initialize a dist vector
vd_initialize<dim>(vd, v_cl, k_int);
//Reorder a vector
double sum_reorder_mean = 0;
double sum_reorder_dev = 0;
openfpm::vector<double> measures;
for (size_t h = 0 ; h < N_STAT_TEST; h++)
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
auto NN = vd.getCellList(r_cut);
benchmark_get_celllist(NN,vd,r_cut);
//Calculate forces
double sum_fr_mean = 0;
double sum_fr_dev = 0;
measures.clear();
for (size_t l = 0 ; l < N_STAT_TEST ; l++)
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;
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;
}
}
}
}
}
/*! \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
......
......@@ -9,6 +9,7 @@
#define SRC_VECTOR_PERFORMANCE_CL_COMP_PERFORMANCE_GRAPH_HPP_
#include "Plot/GoogleChart.hpp"
#include "vector_dist_performance_util.hpp"
/////////////////////////// COMPUTATIONAL HILBERT CURVE ORDERING ///////////////////////////////////////
......@@ -33,114 +34,53 @@ template<unsigned int dim> void cl_comp_normal_vs_hilbert_force_time(GoogleChart
double & warning_level,
double & norm)
{
// Get the test dir
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"));
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);
openfpm::vector<int> warning_vlevel;
// time 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));
yn.add("Random cell list");
yn.add("Hilbert cell list");
y.resize(cl_time_hilb_mean.size());
y_dev.resize(cl_time_hilb_mean.size());
for (size_t r = 0; r < cl_time_hilb_mean.size(); r++)
{
y.get(r).resize(cl_time_hilb_mean.get(r).size());
y_dev.get(r).resize(cl_time_hilb_mean.get(r).size());