7#include "util/common.hpp"
9#define BOOST_TEST_DYN_LINK
11#include "util/util_debug.hpp"
12#include <boost/test/unit_test.hpp>
14#include "Operators/Vector/vector_dist_operators.hpp"
15#include "OdeIntegrators/OdeIntegrators.hpp"
29 dxdt.data.get<0>() = x.data.get<0>();
36BOOST_AUTO_TEST_SUITE(odeInt_BASE_tests)
38BOOST_AUTO_TEST_CASE(odeint_base_test_gpu)
40 size_t edgeSemiSize = 512;
41 const size_t sz[2] = {edgeSemiSize,edgeSemiSize };
43 size_t bc[2] = { NON_PERIODIC, NON_PERIODIC };
45 spacing[0] = 1.0 / (sz[0] - 1);
46 spacing[1] = 1.0 / (sz[1] - 1);
47 double rCut = 3.9 * spacing[0];
49 BOOST_TEST_MESSAGE(
"Init vector_dist...");
53 auto it = Particles.getGridIterator(sz);
58 mem_id k0 = key.get(0);
59 double xp0 = k0 * spacing[0];
60 Particles.getLastPos()[0] = xp0;
61 mem_id k1 = key.get(1);
62 double yp0 = k1 * spacing[1];
63 Particles.getLastPos()[1] = yp0;
64 Particles.getLastProp<0>() = xp0*yp0*exp(-5);
65 Particles.getLastProp<1>() = xp0*yp0*exp(5);
70 Particles.ghost_get<0>();
71 Particles.hostToDeviceProp<0,1,2>();
72 auto Init = getV<0,comp_dev>(Particles);
73 auto Sol = getV<1,comp_dev>(Particles);
74 auto OdeSol = getV<2,comp_dev>(Particles);
77 x0.data.get<0>()=Init;
78 x0.data.get<0>().getVector().deviceToHost<0>();
89 size_t steps=boost::numeric::odeint::integrate_const( boost::numeric::odeint::runge_kutta4< state_type, double, state_type, double, boost::numeric::odeint::vector_space_algebra_ofp_gpu,boost::numeric::odeint::ofp_operations>(),ExponentialGPU,x0,t0,tf,dt);
91 OdeSol=x0.data.get<0>();
92 Particles.deviceToHostProp<0,1,2>();
93 auto it2 = Particles.getDomainIterator();
95 while (it2.isNext()) {
97 if (fabs(Particles.getProp<1>(p) - Particles.getProp<2>(p)) > worst) {
98 worst = fabs(Particles.getProp<1>(p) - Particles.getProp<2>(p));
102 std::cout<<
"WCT:"<<tt.
getwct()<<std::endl;
103 std::cout<<
"CPU:"<<tt.
getcputime()<<std::endl;
104 std::cout<<worst<<std::endl;
105 BOOST_REQUIRE(worst < 1e-6);
107BOOST_AUTO_TEST_SUITE_END()
This class represent an N-dimensional box.
Class for cpu time benchmarking.
void stop()
Stop the timer.
double getcputime()
Return the cpu time.
void start()
Start the timer.
double getwct()
Return the elapsed real time.
Main class that encapsulate a vector properties operand to be used for expressions construction.