4size_t debug_tot_call = 0;
6#define PRINT_STACKTRACE
9#define CHECKFOR_PROPNAN
10#define CHECKFOR_PROPINF
13#include "Graph/CartesianGraphFactory.hpp"
18 std::this_thread::sleep_for (std::chrono::seconds(900));
20 std::cout <<
"Time Out" << std::endl;
25#define BOOST_DISABLE_ASSERTS
31#define BOOST_TEST_DYN_LINK
32#include <boost/test/unit_test.hpp>
33#include "VCluster/VCluster.hpp"
34#include <Vector/vector_dist.hpp>
35#include "Vector/tests/vector_dist_util_unit_tests.hpp"
46int main(
int argc,
char* argv[])
48 openfpm_init(&argc,&argv);
50 return boost::unit_test::unit_test_main( &init_unit_test, argc, argv );
55BOOST_AUTO_TEST_CASE( vector_dist_ghost_put_gpu )
61 long int k = 25*25*25*create_vcluster().getProcessingUnits();
62 k = std::pow(k, 1/3.);
67 BOOST_TEST_CHECKPOINT(
"Testing 3D periodic ghost put k=" << k );
69 long int big_step = k / 30;
70 big_step = (big_step == 0)?1:big_step;
71 long int small_step = 21;
74 for ( ; k >= 2 ; k-= (k > 2*big_step)?big_step:small_step )
76 float r_cut = 1.3 / k;
82 size_t bc[3]={PERIODIC,PERIODIC,PERIODIC};
92 auto it = vd.getGridIterator({(size_t)k,(
size_t)k,(size_t)k});
100 vd.getLastPosWrite()[0] = key.get(0)*it.getSpacing(0);
101 vd.getLastPosWrite()[1] = key.get(1)*it.getSpacing(1);
102 vd.getLastPosWrite()[2] = key.get(2)*it.getSpacing(2);
106 vd.getLastPropWrite<0>() = 0.0;
108 vd.getLastPropWrite<2>() = 0.0;
115 vd.hostToDevicePos();
116 vd.template hostToDeviceProp<0,2>();
118 vd.ghost_get<0,2>(RUN_ON_DEVICE);
119 vd.template deviceToHostProp<0,2>();
120 vd.deviceToHostPos();
123 auto NN = vd.getCellList(r_cut);
128 auto it2 = vd.getDomainIterator();
137 auto Np = NN.getNNIterator<NO_CHECK>(NN.getCell(xp));
149 vd.getPropWrite<0>(q) += a*(-dist*dist+r_cut*r_cut);
150 vd.getPropWrite<2>(q) += a*(-dist*dist+r_cut*r_cut);
159 vd.hostToDevicePos();
160 vd.template hostToDeviceProp<0,2>();
161 vd.template ghost_put<add_atomic_,0,2>(RUN_ON_DEVICE);
162 vd.template deviceToHostProp<0,2>();
163 vd.deviceToHostPos();
166 auto it3 = vd.getDomainIterator();
168 float constant = vd.getProp<0>(it3.get());
173 float constant2 = vd.getProp<0>(it3.get());
174 float constant3 = vd.getProp<2>(it3.get());
175 if (fabs(constant - constant2)/constant > eps || fabs(constant - constant3)/constant > eps)
179 std::cout << p.
toString() <<
" " << constant2 <<
"/" << constant <<
"/" << constant3 <<
" " << v_cl.
getProcessUnitID() << std::endl;
186 BOOST_REQUIRE_EQUAL(ret,
true);
189 auto itp = vd.getDomainAndGhostIterator();
192 auto key = itp.get();
194 vd.getPropWrite<0>(key) = 0.0;
195 vd.getPropWrite<2>(key) = 0.0;
201 auto NN = vd.getCellList(r_cut);
206 auto it2 = vd.getDomainIterator();
215 auto Np = NN.getNNIterator<NO_CHECK>(NN.getCell(xp));
227 vd.getPropWrite<0>(q) += a*(-dist*dist+r_cut*r_cut);
228 vd.getPropWrite<2>(q) += a*(-dist*dist+r_cut*r_cut);
237 vd.hostToDevicePos();
238 vd.template hostToDeviceProp<0,2>();
239 vd.template ghost_put<add_atomic_,0>(RUN_ON_DEVICE);
240 vd.template ghost_put<add_atomic_,2>(RUN_ON_DEVICE);
241 vd.template deviceToHostProp<0,2>();
242 vd.deviceToHostPos();
245 auto it3 = vd.getDomainIterator();
247 float constant = vd.getPropRead<0>(it3.get());
252 float constant2 = vd.getPropRead<0>(it3.get());
253 float constant3 = vd.getPropRead<0>(it3.get());
254 if (fabs(constant - constant2)/constant > eps || fabs(constant - constant3)/constant > eps)
258 std::cout << p.
toString() <<
" " << constant2 <<
"/" << constant <<
"/" << constant3 <<
" " << it3.get().getKey() <<
" " << v_cl.
getProcessUnitID() << std::endl;
265 BOOST_REQUIRE_EQUAL(ret,
true);
This class represent an N-dimensional box.
This class implement the point shape in an N-dimensional space.
__device__ __host__ T distance(const Point< dim, T > &q) const
It calculate the distance between 2 points.
__device__ __host__ const T & get(unsigned int i) const
Get coordinate.
std::string toString() const
Return the string with the point coordinate.
size_t getProcessUnitID()
Get the process unit id.
size_t getProcessingUnits()
Get the total number of processors.
Implementation of VCluster class.
aggregate of properties, from a list of object if create a struct that follow the OPENFPM native stru...