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
9template<
typename dec_type>
12 pr_id[0] = dec.processorIDBC(p1);
13 pr_id[1] = dec.processorIDBC(p2);
16template<
typename dec_type>
19 ng_id[0] = dec.ghost_processorID_N(p1);
20 ng_id[1] = dec.ghost_processorID_N(p2);
23template<
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);
37BOOST_AUTO_TEST_SUITE( decomposition_to_gpu_test )
39BOOST_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());
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 );
158BOOST_AUTO_TEST_SUITE_END()
This class represent an N-dimensional box.
__device__ __host__ T getLow(int i) const
get the i-coordinate of the low bound interval of the box
__device__ __host__ T getHigh(int i) const
get the high interval of the box
This class decompose a space into sub-sub-domains and distribute them across processors.
virtual void * getDevicePointer()
get a readable pointer with the data
virtual void deviceToHost()
Move memory from device to host.
virtual void * getPointer()
get a readable pointer with the data
virtual bool allocate(size_t sz)
allocate memory
This class implement the point shape in an N-dimensional space.
__device__ __host__ const T & get(unsigned int i) const
Get coordinate.
This class represent an N-dimensional box.
size_t rank()
Get the process unit id.
size_t size()
Get the total number of processors.
Implementation of VCluster class.
Implementation of 1-D std::vector like structure.