Commit 3b7f9445 authored by incardon's avatar incardon

Adding test for sparse_cl

parent 5651520e
......@@ -1243,7 +1243,7 @@ struct execute_cl_test<2>
}
};
template<unsigned int dim, typename T, typename CellS, int impl> void Test_cell_gpu_force(SpaceBox<dim,T> & box, size_t npart, const size_t (& div)[dim])
template<unsigned int dim, typename T, typename CellS, int impl> void Test_cell_gpu_force(SpaceBox<dim,T> & box, size_t npart, const size_t (& div)[dim],int box_nn = 1)
{
// Origin
Point<dim,T> org({0.0,0.0,0.0});
......@@ -1253,6 +1253,8 @@ template<unsigned int dim, typename T, typename CellS, int impl> void Test_cell_
CellList<dim,T,Mem_fast<>,shift<dim,T>> cl_cpu(box,div,2);
cl2.setBoxNN(box_nn);
T radius = (box.getHigh(0) - box.getLow(0))/div[0] * 2.0;
execute_cl_test<impl>::set_radius(cl2,cl_cpu,radius);
......@@ -1457,6 +1459,24 @@ BOOST_AUTO_TEST_CASE( CellList_gpu_use_calc_force_box)
// Test the cell list
}
BOOST_AUTO_TEST_CASE( CellList_gpu_use_calc_force_box_sparse)
{
std::cout << "Test cell list GPU" << "\n";
SpaceBox<3,float> box({0.0f,0.0f,0.0f},{1.0f,1.0f,1.0f});
SpaceBox<3,float> box2({-0.3f,-0.3f,-0.3f},{1.0f,1.0f,1.0f});
Test_cell_gpu_force<3,float,CellList_gpu<3,float,CudaMemory,shift_only<3,float>,unsigned int,int,true>,2>(box,1000,{32,32,32},2);
Test_cell_gpu_force<3,float,CellList_gpu<3,float,CudaMemory,shift_only<3,float>,unsigned int,int,true>,2>(box,10000,{32,32,32},2);
Test_cell_gpu_force<3,float,CellList_gpu<3,float,CudaMemory,shift_only<3,float>,unsigned int,int,true>,2>(box2,1000,{32,32,32},2);
Test_cell_gpu_force<3,float,CellList_gpu<3,float,CudaMemory,shift_only<3,float>,unsigned int,int,true>,2>(box2,10000,{32,32,32},2);
std::cout << "End cell list GPU" << "\n";
// Test the cell list
}
BOOST_AUTO_TEST_CASE( CellList_gpu_use_calc_force_radius)
{
std::cout << "Test cell list GPU" << "\n";
......@@ -1501,10 +1521,10 @@ BOOST_AUTO_TEST_CASE( CellList_gpu_use_calc_force_sparse)
SpaceBox<3,float> box2({-0.3f,-0.3f,-0.3f},{1.0f,1.0f,1.0f});
Test_cell_gpu_force<3,float,CellList_gpu<3,float,CudaMemory,shift_only<3,float>,unsigned int,int,true>,0>(box,1000,{16,16,16});
Test_cell_gpu_force<3,float,CellList_gpu<3,float,CudaMemory,shift_only<3,float>>,0>(box,10000,{16,16,16});
Test_cell_gpu_force<3,float,CellList_gpu<3,float,CudaMemory,shift_only<3,float>,unsigned int,int,true>,0>(box,10000,{16,16,16});
Test_cell_gpu_force<3,float,CellList_gpu<3,float,CudaMemory,shift_only<3,float>>,0>(box2,1000,{16,16,16});
Test_cell_gpu_force<3,float,CellList_gpu<3,float,CudaMemory,shift_only<3,float>>,0>(box2,10000,{16,16,16});
Test_cell_gpu_force<3,float,CellList_gpu<3,float,CudaMemory,shift_only<3,float>,unsigned int,int,true>,0>(box2,1000,{16,16,16});
Test_cell_gpu_force<3,float,CellList_gpu<3,float,CudaMemory,shift_only<3,float>,unsigned int,int,true>,0>(box2,10000,{16,16,16});
std::cout << "End cell list GPU force sparse" << "\n";
......
......@@ -174,7 +174,7 @@ class CellList_gpu : public CellDecomposer_sm<dim,T,transform>
construct_cell_nn_test();
}
void construct_cell_nn_test()
void construct_cell_nn_test(unsigned int box_nn = 1)
{
auto & gs = this->getGrid();
......@@ -185,11 +185,11 @@ class CellList_gpu : public CellDecomposer_sm<dim,T,transform>
for (size_t i = 0 ; i < dim ; i++)
{
start.set_d(i,0);
stop.set_d(i,2);
middle.set_d(i,1);
stop.set_d(i,2*box_nn);
middle.set_d(i,box_nn);
}
cells_nn_test.resize(openfpm::math::pow(3,dim));
cells_nn_test.resize(openfpm::math::pow(2*box_nn+1,dim));
int mid = gs.LinId(middle);
......@@ -445,7 +445,7 @@ public:
/*! \brief Copy constructor
*
*
* \param clg Cell list to copy
*
*/
CellList_gpu(const CellList_gpu<dim,T,Memory,transform,cnt_type,ids_type> & clg)
......@@ -475,6 +475,16 @@ public:
Initialize(box,div,pad);
}
/*! \brief Set the NN box size
*
* \param nn number of NN around
*
*/
void setBoxNN(unsigned int nn)
{
construct_cell_nn_test(nn);
}
/*! Initialize the cell list
*
* \param box Domain where this cell list is living
......
......@@ -513,6 +513,15 @@ public:
return ngi;
}
template<unsigned int r_int = 2>
inline __device__ NN_gpu_it<dim,cnt_type,ids_type,r_int,true>
getNNIteratorBox(decltype(cl_sparse.get_sparse(0)) cid)
{
NN_gpu_it<dim,cnt_type,ids_type,r_int,true> ngi(cid.id,cell_nn,cell_nn_list,srt);
return ngi;
}
inline __device__ openfpm::vector_gpu_ker<aggregate<cnt_type>,memory_traits_inte> & getDomainSortIds()
{
return dprt;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment