8 #ifndef SRC_VECTOR_VECTOR_DIST_DLB_TEST_HPP_
9 #define SRC_VECTOR_VECTOR_DIST_DLB_TEST_HPP_
11 #include "DLB/LB_Model.hpp"
12 #include "vector_dist.hpp"
14 BOOST_AUTO_TEST_SUITE( vector_dist_dlb_test )
25 for(
size_t i = 0 ; i < 50000 ; i++)
32 vd0.getLastPos()[0] = ((float)rand())/RAND_MAX * 0.3;
33 vd0.getLastPos()[1] = ((float)rand())/RAND_MAX * 0.3;
34 vd0.getLastPos()[2] = ((float)rand())/RAND_MAX * 0.3;
36 vd1.getLastPos()[0] = ((float)rand())/RAND_MAX * 0.3 + 0.1;
37 vd1.getLastPos()[1] = ((float)rand())/RAND_MAX * 0.3 + 0.1;
38 vd1.getLastPos()[2] = ((float)rand())/RAND_MAX * 0.3 + 0.1;
40 vd2.getLastPos()[0] = ((float)rand())/RAND_MAX * 0.3 + 0.2;
41 vd2.getLastPos()[1] = ((float)rand())/RAND_MAX * 0.3 + 0.2;
42 vd2.getLastPos()[2] = ((float)rand())/RAND_MAX * 0.3 + 0.2;
44 vd3.getLastPos()[0] = ((float)rand())/RAND_MAX * 0.3 + 0.3;
45 vd3.getLastPos()[1] = ((float)rand())/RAND_MAX * 0.3 + 0.3;
46 vd3.getLastPos()[2] = ((float)rand())/RAND_MAX * 0.3 + 0.3;
51 vd0.template ghost_get<>();
53 vd1.template ghost_get<>();
55 vd2.template ghost_get<>();
57 vd3.template ghost_get<>();
61 vd0.initializeComputationCosts();
62 vd0.addComputationCosts(vd0,md);
63 vd0.addComputationCosts(vd1,md);
64 vd0.addComputationCosts(vd2,md);
65 vd0.addComputationCosts(vd3,md);
66 vd0.finalizeComputationCosts();
68 vd0.getDecomposition().decompose();
71 vd1.getDecomposition() = vd0.getDecomposition();
72 vd2.getDecomposition() = vd0.getDecomposition();
73 vd3.getDecomposition() = vd0.getDecomposition();
80 vd0.initializeComputationCosts();
81 vd0.addComputationCosts(vd0,md);
82 vd0.addComputationCosts(vd1,md);
83 vd0.addComputationCosts(vd2,md);
84 vd0.addComputationCosts(vd3,md);
85 vd0.finalizeComputationCosts();
88 size_t load = vd0.getDecomposition().getDistribution().getProcessorLoad();
92 for (
size_t i = 0 ; i < loads.
size() ; i++)
95 float load_fc = loads.get(i);
97 BOOST_REQUIRE_CLOSE(load_f,load_fc,7.0);
102 for (
size_t i = 0 ; i < 25 ; i++)
107 auto it = vd0.getDomainIterator();
113 vd0.getPos(p)[0] += v.get(0) * 0.09;
114 vd0.getPos(p)[1] += v.get(1) * 0.09;
115 vd0.getPos(p)[2] += v.get(2) * 0.09;
122 auto it = vd1.getDomainIterator();
127 vd1.getPos(p)[0] += v.get(0) * 0.06;
128 vd1.getPos(p)[1] += v.get(1) * 0.06;
129 vd1.getPos(p)[2] += v.get(2) * 0.06;
136 auto it = vd2.getDomainIterator();
141 vd2.getPos(p)[0] += v.get(0) * 0.06;
142 vd2.getPos(p)[1] += v.get(1) * 0.06;
143 vd2.getPos(p)[2] += v.get(2) * 0.06;
150 auto it = vd3.getDomainIterator();
155 vd3.getPos(p)[0] += v.get(0) * 0.06;
156 vd3.getPos(p)[1] += v.get(1) * 0.06;
157 vd3.getPos(p)[2] += v.get(2) * 0.06;
169 vd0.initializeComputationCosts();
170 vd0.addComputationCosts(vd0,md);
171 vd0.addComputationCosts(vd1,md);
172 vd0.addComputationCosts(vd2,md);
173 vd0.addComputationCosts(vd3,md);
174 vd0.finalizeComputationCosts();
176 vd0.getDecomposition().redecompose(200);
179 vd1.getDecomposition() = vd0.getDecomposition();
180 vd2.getDecomposition() = vd0.getDecomposition();
181 vd3.getDecomposition() = vd0.getDecomposition();
187 vd0.template ghost_get<>();
188 vd1.template ghost_get<>();
189 vd2.template ghost_get<>();
190 vd3.template ghost_get<>();
192 vd0.initializeComputationCosts();
193 vd0.addComputationCosts(vd0,md);
194 vd0.addComputationCosts(vd1,md);
195 vd0.addComputationCosts(vd2,md);
196 vd0.addComputationCosts(vd3,md);
197 vd0.finalizeComputationCosts();
200 size_t load = vd0.getDecomposition().getDistribution().getProcessorLoad();
204 for (
size_t i = 0 ; i < loads.
size() ; i++)
207 float load_fc = loads.get(i);
209 BOOST_REQUIRE_CLOSE(load_f,load_fc,10.0);
214 template<
typename vector_type>
void test_dlb_vector()
216 Vcluster & v_cl = create_vcluster();
223 size_t bc[3] = {PERIODIC,PERIODIC,PERIODIC};
231 for(
size_t i = 0 ; i < 50000 ; i++)
235 vd.getLastPos()[0] = ((float)rand())/RAND_MAX * 0.3;
236 vd.getLastPos()[1] = ((float)rand())/RAND_MAX * 0.3;
237 vd.getLastPos()[2] = ((float)rand())/RAND_MAX * 0.3;
242 vd.template ghost_get<>();
246 vd.addComputationCosts(md);
247 vd.getDecomposition().decompose();
251 vd.addComputationCosts(md);
254 size_t load = vd.getDecomposition().getDistribution().getProcessorLoad();
258 for (
size_t i = 0 ; i < loads.
size() ; i++)
261 float load_fc = loads.get(i);
263 BOOST_REQUIRE_CLOSE(load_f,load_fc,7.0);
266 BOOST_REQUIRE(vd.size_local() != 0);
270 for (
size_t i = 0 ; i < 25 ; i++)
274 auto it = vd.getDomainIterator();
280 vd.getPos(p)[0] += v.get(0) * 0.09;
281 vd.getPos(p)[1] += v.get(1) * 0.09;
282 vd.getPos(p)[2] += v.get(2) * 0.09;
289 vd.addComputationCosts(md);
290 vd.getDecomposition().redecompose(200);
293 BOOST_REQUIRE(vd.size_local() != 0);
295 vd.template ghost_get<>();
297 vd.addComputationCosts(md);
300 size_t load = vd.getDecomposition().getDistribution().getProcessorLoad();
304 for (
size_t i = 0 ; i < loads.
size() ; i++)
307 float load_fc = loads.get(i);
309 BOOST_REQUIRE_CLOSE(load_f,load_fc,10.0);
315 template<
typename vector_type>
void test_dlb_multi_phase_vector()
317 Vcluster & v_cl = create_vcluster();
324 size_t bc[3] = {PERIODIC,PERIODIC,PERIODIC};
331 mp_test_template(vd0,vd1,vd2,vd3);
336 template<
typename vector_type>
void test_dlb_multi_phase_v_vector()
338 Vcluster & v_cl = create_vcluster();
345 size_t bc[3] = {PERIODIC,PERIODIC,PERIODIC};
351 v_phases.add(
vector_type(vd0.getDecomposition(),0));
352 v_phases.add(
vector_type(vd0.getDecomposition(),0));
353 v_phases.add(
vector_type(vd0.getDecomposition(),0));
356 auto & vd0 = v_phases.get(0);
357 auto & vd1 = v_phases.get(1);
358 auto & vd2 = v_phases.get(2);
359 auto & vd3 = v_phases.get(3);
361 mp_test_template(vd0,vd1,vd2,vd3);
364 BOOST_AUTO_TEST_CASE( vector_dist_dlb_test_part )
366 test_dlb_vector<vector_dist<3,float,aggregate<float>>>();
369 BOOST_AUTO_TEST_CASE( vector_dist_dlb_multi_phase_test_part )
371 test_dlb_multi_phase_vector<vector_dist<3,float,aggregate<float>>>();
374 BOOST_AUTO_TEST_CASE( vector_dist_dlb_multi_phase_v_test_part )
376 test_dlb_multi_phase_v_vector<vector_dist<3,float,aggregate<float>>>();
379 BOOST_AUTO_TEST_CASE( vector_dist_dlb_metis_test_part )
389 BOOST_AUTO_TEST_SUITE_END()
Transform the boost::fusion::vector into memory specification (memory_traits)
size_t getProcessUnitID()
Get the process unit id.
void execute()
Execute all the requests.
This class implement the point shape in an N-dimensional space.
Implementation of VCluster class.
This class decompose a space into sub-sub-domains and distribute them across processors.
aggregate of properties, from a list of object if create a struct that follow the OPENFPM native stru...
size_t getProcessingUnits()
Get the total number of processors.
bool allGather(T &send, openfpm::vector< T, Mem, gr > &v)
Gather the data from all processors.