OpenFPM_pdata  1.1.0
Project that contain the implementation of distributed structures
 All Data Structures Namespaces Functions Variables Typedefs Enumerations Friends Pages
Kernels_unit_tests.hpp
1 /*
2  * Kernels_unit_tests.hpp
3  *
4  * Created on: Feb 17, 2016
5  * Author: i-bird
6  */
7 
8 #ifndef OPENFPM_NUMERICS_SRC_PSE_KERNELS_UNIT_TESTS_HPP_
9 #define OPENFPM_NUMERICS_SRC_PSE_KERNELS_UNIT_TESTS_HPP_
10 
11 #include "PSE/Kernels_test_util.hpp"
12 #ifdef HAVE_LIBQUADMATH
13 #include <boost/multiprecision/float128.hpp>
14 #endif
15 
16 BOOST_AUTO_TEST_SUITE( pse_kernels_unit_tests )
17 
18 BOOST_AUTO_TEST_CASE( pse_ker )
19 {
20  Vcluster & v_cl = create_vcluster();
21 
22  // This test is not made to run in parallel
23  if (v_cl.getProcessingUnits() > 1)
24  return;
25 
28 
29  // Load the result of the test
30 
31 #ifdef HAVE_LIBQUADMATH
32  y_res.load("test/PSE_convergence");
33 #else
34  y_res.load("test/PSE_convergence_osx");
35 #endif
36 
37  // Every time increase the number of particles by 2
38  for (size_t i = 250 ; i <= 2097152000 ; i*=2)
39  {
40  y.add();
41 
42  PSEError err;
43 
45 
46 #ifdef HAVE_LIBQUADMATH
47 
48  PSE_test<boost::multiprecision::float128,Lap_PSE<1,boost::multiprecision::float128,2>>(i,2,err);
49  y.last().add(err.linf_error);
50 
51  PSE_test<boost::multiprecision::float128,Lap_PSE<1,boost::multiprecision::float128,2>>(i,4,err);
52  y.last().add(err.linf_error);
53 #endif
54 
55  PSE_test<double,Lap_PSE<1,double,2>>(i,2,err);
56  y.last().add(err.linf_error);
57 
58  PSE_test<double,Lap_PSE<1,double,2>>(i,4,err);
59  y.last().add(err.linf_error);
60 
61  PSE_test<float,Lap_PSE<1,float,2>>(i,2,err);
62  y.last().add(err.linf_error);
63 
64  PSE_test<float,Lap_PSE<1,float,2>>(i,4,err);
65  y.last().add(err.linf_error);
66 
68 
69 #ifdef HAVE_LIBQUADMATH
70 
71  PSE_test<boost::multiprecision::float128,Lap_PSE<1,boost::multiprecision::float128,4>>(i,2,err);
72  y.last().add(err.linf_error);
73 
74  PSE_test<boost::multiprecision::float128,Lap_PSE<1,boost::multiprecision::float128,4>>(i,4,err);
75  y.last().add(err.linf_error);
76 
78 
79 
80  PSE_test<boost::multiprecision::float128,Lap_PSE<1,boost::multiprecision::float128,6>>(i,2,err);
81  y.last().add(err.linf_error);
82 
83  PSE_test<boost::multiprecision::float128,Lap_PSE<1,boost::multiprecision::float128,6>>(i,4,err);
84  y.last().add(err.linf_error);
85 
86 
88 
89 
90  PSE_test<boost::multiprecision::float128,Lap_PSE<1,boost::multiprecision::float128,8>>(i,8,err);
91  y.last().add(err.linf_error);
92 
93  PSE_test<boost::multiprecision::float128,Lap_PSE<1,boost::multiprecision::float128,8>>(i,16,err);
94  y.last().add(err.linf_error);
95 
96 #endif
97  }
98 
99  // Check the result
100  for (size_t i = 0 ; i < y.size(); i++)
101  {
102  for (size_t j = 0 ; j < y.get(i).size(); j++)
103  {
104  double c1 = y.get(i).get(j);
105  double c2 = y_res.get(i).get(j);
106 
107 #ifdef HAVE_LIBQUADMATH
108 
109  // In divergent mode the system is too sensitive
110  // to compiler/hardware differences disable them
111  if (j != 4 && j != 5)
112  {BOOST_REQUIRE_CLOSE(c1,c2,3.0);}
113 
114 #else
115 
116  // In divergent mode the system is too sensitive
117  // to compiler/hardware differences disable them
118  if (j != 2 && j != 3)
119  {BOOST_REQUIRE_CLOSE(c1,c2,3.0);}
120 
121 #endif
122  }
123  }
124 }
125 
126 BOOST_AUTO_TEST_SUITE_END()
127 
128 #endif /* OPENFPM_NUMERICS_SRC_PSE_KERNELS_UNIT_TESTS_HPP_ */
size_t size()
Stub size.
Definition: map_vector.hpp:70
Implementation of VCluster class.
Definition: VCluster.hpp:36
Implementation of 1-D std::vector like structure.
Definition: map_vector.hpp:61
size_t getProcessingUnits()
Get the total number of processors.