cl_part_performance_graph.hpp 7.45 KB
Newer Older
incardon's avatar
incardon committed
1
2
3
4
5
6
7
8
9
10
/*
 * 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_

incardon's avatar
incardon committed
11
#include "vector_dist_performance_util.hpp"
incardon's avatar
incardon committed
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26

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

incardon's avatar
incardon committed
27
28
	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"));
incardon's avatar
incardon committed
29

incardon's avatar
incardon committed
30
	openfpm::vector<size_t> xp = cl_n_particles;
incardon's avatar
incardon committed
31

incardon's avatar
incardon committed
32
33
	openfpm::vector<openfpm::vector<openfpm::vector<double>>> yp_mean;
	openfpm::vector<openfpm::vector<openfpm::vector<double>>> yp_dev;
incardon's avatar
incardon committed
34

incardon's avatar
incardon committed
35
36
	openfpm::vector<std::string> names;
	openfpm::vector<std::string> gnames;
incardon's avatar
incardon committed
37

incardon's avatar
incardon committed
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
	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);
incardon's avatar
incardon committed
56
			yp_dev.get(i).get(j).get(cl_time_hilb_mean.get(i).get(j).size()) = cl_time_rand_dev.get(i).get(j);
incardon's avatar
incardon committed
57
58
		}
	}
incardon's avatar
incardon committed
59

incardon's avatar
incardon committed
60
	for (size_t i = 0 ; i < cl_orders.size() ; i++)
incardon's avatar
incardon committed
61
62
	{names.add(std::string("Order of: " + std::to_string(cl_orders.get(i))));}
	names.add("No-order");
incardon's avatar
incardon committed
63

incardon's avatar
incardon committed
64
65
	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)));
incardon's avatar
incardon committed
66

incardon's avatar
incardon committed
67
68
	std::string y_string = std::string("Time to calculate forces (s)");
	std::string x_string = std::string("Number of particles");
incardon's avatar
incardon committed
69
70
71
72
73
74

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

incardon's avatar
incardon committed
75
76
77
78
79
80
81
82
83
84
85
	StandardPerformanceGraph(file_mean,
			                 file_var,
							 file_mean_save,
							 file_var_save,
							 cg,
							 xp,
							 yp_mean,
							 yp_dev,
							 names,
							 gnames,
							 x_string,
incardon's avatar
incardon committed
86
87
							 y_string,
							 false);
incardon's avatar
incardon committed
88
89
90
91
92
93
94
95
96
97
98
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
}

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_ */