cl_comp_performance_graph.hpp 7.27 KB
Newer Older
Pietro Incardona's avatar
Pietro Incardona committed
1
2
3
4
5
6
7
8
9
10
11
/*
 * 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"
Pietro Incardona's avatar
Pietro Incardona committed
12
#include "vector_dist_performance_util.hpp"
Pietro Incardona's avatar
Pietro Incardona committed
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41

/////////////////////////// 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"));

Pietro Incardona's avatar
Pietro Incardona committed
42
43
44
45
46
47
48
49
50
51
52
	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;

Pietro Incardona's avatar
Pietro Incardona committed
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
	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);
Pietro Incardona's avatar
Pietro Incardona committed
69
			yp_dev.get(i).get(j).get(1) = cl_time_rand_dev.get(i).get(j);
Pietro Incardona's avatar
Pietro Incardona committed
70
71
		}
	}
Pietro Incardona's avatar
Pietro Incardona committed
72
73

	names.add("Hilbert cell list");
Pietro Incardona's avatar
Pietro Incardona committed
74
	names.add("Random cell list");
Pietro Incardona's avatar
Pietro Incardona committed
75
76
77
78
79
80

	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");
Pietro Incardona's avatar
Pietro Incardona committed
81
82
83
84
85

	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);

Pietro Incardona's avatar
Pietro Incardona committed
86
87
88
89
90
91
92
93
94
95
96
	StandardPerformanceGraph(file_mean,
			                 file_var,
							 file_mean_save,
							 file_var_save,
							 cg,
							 xp,
							 yp_mean,
							 yp_dev,
							 names,
							 gnames,
							 x_string,
97
98
							 y_string,
							 true);
Pietro Incardona's avatar
Pietro Incardona committed
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
}

/*! \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"));

Pietro Incardona's avatar
Pietro Incardona committed
127
128
129
130
131
132
133
134
135
136
137
	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;

Pietro Incardona's avatar
Pietro Incardona committed
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
	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);
Pietro Incardona's avatar
Pietro Incardona committed
154
			yp_dev.get(i).get(j).get(1) = cl_time_create_rand_dev.get(i).get(j);
Pietro Incardona's avatar
Pietro Incardona committed
155
156
		}
	}
Pietro Incardona's avatar
Pietro Incardona committed
157
158

	names.add("Hilbert cell list");
Pietro Incardona's avatar
Pietro Incardona committed
159
	names.add("Random cell list");
Pietro Incardona's avatar
Pietro Incardona committed
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181

	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,
182
183
							 y_string,
							 true);
Pietro Incardona's avatar
Pietro Incardona committed
184
185
186
187
188
189
190
191
}


///////////////////////////////// PARTICLE REORDERING //////////////////////////////////////////////////////



#endif /* SRC_VECTOR_PERFORMANCE_CL_COMP_PERFORMANCE_GRAPH_HPP_ */