1 #define BOOST_TEST_DYN_LINK 2 #include <boost/test/unit_test.hpp> 4 #include "VCluster/VCluster.hpp" 5 #include "Decomposition/CartDecomposition.hpp" 7 #define SUB_UNIT_FACTOR 1024 9 template<
typename dec_type>
12 pr_id[0] = dec.processorIDBC(p1);
13 pr_id[1] = dec.processorIDBC(p2);
16 template<
typename dec_type>
19 ng_id[0] = dec.ghost_processorID_N(p1);
20 ng_id[1] = dec.ghost_processorID_N(p2);
23 template<
typename dec_type,
typename output_type>
26 for (
unsigned int i = 0 ; i < ng_id[0] ; i++)
28 dec.ghost_processor_ID(p1,g_id,0,i);
31 for (
unsigned int i = 0 ; i < ng_id[1] ; i++)
33 dec.ghost_processor_ID(p2,g_id,ng_id[0],i);
37 BOOST_AUTO_TEST_SUITE( decomposition_to_gpu_test )
39 BOOST_AUTO_TEST_CASE( CartDecomposition_check_cross_consistency_between_proc_idbc_and_ghost2_gpu )
46 size_t bc[3] = {PERIODIC,PERIODIC,PERIODIC};
53 dec.setGoodParameters(box, bc, g, 512);
59 for (
size_t j = 0 ; j < 3 ; j++ )
61 for (
size_t i = 0 ; i < dec.getNSubDomain() ; i++)
74 auto gpudec = dec.toKernel();
77 mem.
allocate(2*
sizeof(
unsigned int));
79 CUDA_LAUNCH_DIM3((test_proc_idbc<decltype(gpudec)>),1,1,p1,p2,gpudec,(
unsigned int *)mem.
getDevicePointer());
87 mem2.
allocate(2*
sizeof(
unsigned int));
88 CUDA_LAUNCH_DIM3((test_ghost_n<decltype(gpudec)>),1,1,p1,p2,gpudec,(
unsigned int *)mem2.getDevicePointer());
92 unsigned int tot = ((
unsigned int *)mem2.getPointer())[0] + ((
unsigned int *)mem2.getPointer())[1];
96 CUDA_LAUNCH_DIM3((test_ghost<decltype(gpudec),decltype(vd.toKernel())>),1,1,p1,p2,gpudec,(
unsigned int *)mem2.getDevicePointer(),vd.toKernel());
102 BOOST_REQUIRE(((
unsigned int *)mem2.getPointer())[1] != 0);
103 BOOST_REQUIRE(((
unsigned int *)mem2.getPointer())[0] == 0);
108 BOOST_REQUIRE(((
unsigned int *)mem2.getPointer())[1] == 0 );
109 BOOST_REQUIRE(((
unsigned int *)mem2.getPointer())[0] != 0 );
122 CUDA_LAUNCH_DIM3((test_proc_idbc<decltype(gpudec)>),1,1,p1,p2,gpudec,(
unsigned int *)mem.
getDevicePointer());
126 BOOST_REQUIRE(((
unsigned int *)mem.
getPointer())[0] < vcl.
size());
127 BOOST_REQUIRE(((
unsigned int *)mem.
getPointer())[1] < vcl.
size());
129 mem2.allocate(2*
sizeof(
unsigned int));
130 CUDA_LAUNCH_DIM3((test_ghost_n<decltype(gpudec)>),1,1,p1,p2,gpudec,(
unsigned int *)mem2.getDevicePointer());
134 tot = ((
unsigned int *)mem2.getPointer())[0] + ((
unsigned int *)mem2.getPointer())[1];
137 CUDA_LAUNCH_DIM3((test_ghost<decltype(gpudec),decltype(vd.toKernel())>),1,1,p1,p2,gpudec,(
unsigned int *)mem2.getDevicePointer(),vd.toKernel());
143 BOOST_REQUIRE(((
unsigned int *)mem2.getPointer())[1] != 0);
144 BOOST_REQUIRE(((
unsigned int *)mem2.getPointer())[0] == 0);
149 BOOST_REQUIRE(((
unsigned int *)mem2.getPointer())[1] == 0 );
150 BOOST_REQUIRE(((
unsigned int *)mem2.getPointer())[0] != 0 );
158 BOOST_AUTO_TEST_SUITE_END()
This class represent an N-dimensional box.
virtual bool allocate(size_t sz)
allocate memory
virtual void * getPointer()
get a readable pointer with the data
This class implement the point shape in an N-dimensional space.
Implementation of VCluster class.
virtual void * getDevicePointer()
get a readable pointer with the data
This class decompose a space into sub-sub-domains and distribute them across processors.
__device__ __host__ const T & get(unsigned int i) const
Get coordinate.
size_t rank()
Get the process unit id.
This class represent an N-dimensional box.
virtual void deviceToHost()
Move memory from device to host.
size_t size()
Get the total number of processors.
Implementation of 1-D std::vector like structure.