OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
vector_dist_performance_util.hpp
1/*
2 * vector_dist_performance_util.hpp
3 *
4 * Created on: Jun 17, 2016
5 * Author: Yaroslav Zaluzhnyi
6 */
7
8#ifndef SRC_VECTOR_VECTOR_DIST_PERFORMANCE_UTIL_HPP_
9#define SRC_VECTOR_VECTOR_DIST_PERFORMANCE_UTIL_HPP_
10
11#include <boost/property_tree/ptree.hpp>
12#include "Plot/GoogleChart.hpp"
13#include "vector_dist_performance_common.hpp"
14
15// Number of tests
16#define N_VERLET_TEST 3
17#define N_STAT_TEST 30
18
19
28template<unsigned int dim, size_t prp = 0, typename T, typename V> double benchmark_calc_forces(T & NN, V & vd, float r_cut)
29{
30 //Timer
31 timer t;
32 t.start();
33
34 calc_forces<dim,prp>(NN,vd,r_cut);
35
36 t.stop();
37
38 return t.getwct();
39}
40
48template<typename V> double benchmark_reorder(V & vd, size_t m)
49{
50 //Timer
51 timer t;
52 t.start();
53
54 //Reorder
55 vd.reorder(m);
56
57 t.stop();
58
59 return t.getwct();
60}
61
70template<typename T, typename V>
71double benchmark_get_celllist(T & NN, V & vd, float r_cut)
72{
73 // Cell list timer
74 timer t;
75 t.start();
76
77 //get cell list
78 NN = vd.getCellList(r_cut);
79
80 t.stop();
81
82 return t.getwct();
83}
84
92template<typename V> double benchmark_get_verlet(V & vd, float r_cut)
93{
95 //Timer
96 timer t;
97 t.start();
98
99 //get verlet
100 auto vr = vd.getVerlet(r_cut);
101
102 t.stop();
103
104 return t.getwct();
105}
106
107
108
117template<unsigned int dim, size_t prp = 0, typename T, typename V> double benchmark_calc_forces_hilb(T & NN, V & vd, float r_cut)
118{
119 //Forces timer
120 timer t;
121 t.start();
122
123 calc_forces_hilb<dim,prp>(NN,vd,r_cut);
124
125 t.stop();
126
127 return t.getwct();
128}
129
138template<typename T, typename V> double benchmark_get_celllist_hilb(T & NN, V & vd, float r_cut)
139{
140 // Cell list timer
141 timer t;
142 t.start();
143
144 //get cell list
145 NN = vd.getCellList_hilb(r_cut);
146
147 t.stop();
148
149 return t.getwct();
150}
151
158template<unsigned int dim, typename v_dist> void move_particles(v_dist & vd, double dist)
159{
160 double phi;
161 double theta;
162 const double pi = 3.14159;
163
164 auto it = vd.getDomainIterator();
165
166 while (it.isNext())
167 {
168 phi = rand()/double(RAND_MAX);
169 theta = rand()/double(RAND_MAX);
170 phi *= 2.0*pi;
171 theta *= pi;
172
173 auto key = it.get();
174
175 if(dim == 1)
176 vd.getPos(key)[0] += dist*sin(theta)*cos(phi);
177 else if(dim == 2)
178 {
179 vd.getPos(key)[0] += dist*sin(theta)*cos(phi);
180 vd.getPos(key)[1] += dist*sin(theta)*sin(phi);
181 }
182 else if(dim == 3)
183 {
184 vd.getPos(key)[0] += dist*sin(theta)*cos(phi);
185 vd.getPos(key)[1] += dist*sin(theta)*sin(phi);
186 vd.getPos(key)[2] += dist*cos(phi);
187 }
188
189 ++it;
190 }
191}
192
194
201extern void StandardPerformanceGraph(std::string file_mean,
202 std::string file_var,
203 std::string file_mean_save,
204 std::string file_var_save,
205 GoogleChart & cg,
211 std::string x_string,
212 std::string y_string,
213 bool use_log);
214
215#endif /* SRC_VECTOR_VECTOR_DIST_PERFORMANCE_UTIL_HPP_ */
Small class to produce graph with Google chart in HTML.
Implementation of 1-D std::vector like structure.
Class for cpu time benchmarking.
Definition timer.hpp:28
void stop()
Stop the timer.
Definition timer.hpp:119
void start()
Start the timer.
Definition timer.hpp:90
double getwct()
Return the elapsed real time.
Definition timer.hpp:130