OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
CellDecomposer_gpu_ker_unit_test.cu
1 #include "config.h"
2 #define BOOST_TEST_DYN_LINK
3 #include <boost/test/unit_test.hpp>
4 
5 #include "NN/CellList/cuda/CellDecomposer_gpu_ker.cuh"
6 #include "Space/Shape/Point.hpp"
7 #include "Vector/map_vector.hpp"
8 
9 
10 template<typename vector_type, typename celldec>
11 __global__ void check(vector_type vd, celldec cd, unsigned int id, Point<3,float> p)
12 {
13  vd.template get<0>(id) = cd.getCell(p);
14 }
15 
16 BOOST_AUTO_TEST_SUITE( CellDecomposer_gpu_test_suite )
17 
18 
19 BOOST_AUTO_TEST_CASE( CellDecomposer_gpu_test_use )
20 {
22  openfpm::array<float,3,unsigned int> spacing_c = {0.1,0.1,0.1};
23 
26 
29 
30  Point<3,float> trans({0.0,0.0,0.0});
31 
33 
35 
37 
38  CUDA_LAUNCH_DIM3(check,1,1,output.toKernel(),clk,0,Point<3,float>({0.2,0.2,0.2}));
39  CUDA_LAUNCH_DIM3(check,1,1,output.toKernel(),clk,1,Point<3,float>({0.1,0.2,0.3}));
40  CUDA_LAUNCH_DIM3(check,1,1,output.toKernel(),clk,2,Point<3,float>({0.25,0.55,0.45}));
41  CUDA_LAUNCH_DIM3(check,1,1,output.toKernel(),clk,3,Point<3,float>({0.15,0.15,0.95}));
42  CUDA_LAUNCH_DIM3(check,1,1,output.toKernel(),clk,4,Point<3,float>({1.05,1.05,1.05}));
43  CUDA_LAUNCH_DIM3(check,1,1,output.toKernel(),clk,5,Point<3,float>({1.15,1.15,1.15}));
44  CUDA_LAUNCH_DIM3(check,1,1,output.toKernel(),clk,6,Point<3,float>({-0.05,-0.05,-0.05}));
45  CUDA_LAUNCH_DIM3(check,1,1,output.toKernel(),clk,7,Point<3,float>({-0.15,-0.15,-0.15}));
46 
47  output.template deviceToHost<0>();
48 
49  grid_key_dx<3,unsigned int> k = output.template get<0>(0);
50  BOOST_REQUIRE_EQUAL(k.get(0),4);
51  BOOST_REQUIRE_EQUAL(k.get(1),4);
52  BOOST_REQUIRE_EQUAL(k.get(2),4);
53  k = output.template get<0>(1);
54  BOOST_REQUIRE_EQUAL(k.get(0),3);
55  BOOST_REQUIRE_EQUAL(k.get(1),4);
56  BOOST_REQUIRE_EQUAL(k.get(2),5);
57  k = output.template get<0>(2);
58  BOOST_REQUIRE_EQUAL(k.get(0),4);
59  BOOST_REQUIRE_EQUAL(k.get(1),7);
60  BOOST_REQUIRE_EQUAL(k.get(2),6);
61  k = output.template get<0>(3);
62  BOOST_REQUIRE_EQUAL(k.get(0),3);
63  BOOST_REQUIRE_EQUAL(k.get(1),3);
64  BOOST_REQUIRE_EQUAL(k.get(2),11);
65  k = output.template get<0>(4);
66  BOOST_REQUIRE_EQUAL(k.get(0),12);
67  BOOST_REQUIRE_EQUAL(k.get(1),12);
68  BOOST_REQUIRE_EQUAL(k.get(2),12);
69  k = output.template get<0>(5);
70  BOOST_REQUIRE_EQUAL(k.get(0),13);
71  BOOST_REQUIRE_EQUAL(k.get(1),13);
72  BOOST_REQUIRE_EQUAL(k.get(2),13);
73  k = output.template get<0>(6);
74  BOOST_REQUIRE_EQUAL(k.get(0),1);
75  BOOST_REQUIRE_EQUAL(k.get(1),1);
76  BOOST_REQUIRE_EQUAL(k.get(2),1);
77  k = output.template get<0>(7);
78  BOOST_REQUIRE_EQUAL(k.get(0),0);
79  BOOST_REQUIRE_EQUAL(k.get(1),0);
80  BOOST_REQUIRE_EQUAL(k.get(2),0);
81 }
82 
83 BOOST_AUTO_TEST_SUITE_END()
grid_key_dx is the key to access any element in the grid
Definition: grid_key.hpp:18
This class implement an NxN (dense) matrix.
Definition: Matrix.hpp:32
Distributed vector.
Implementation of 1-D std::vector like structure.
Definition: map_vector.hpp:202