8#ifndef CELLLIST_GPU_KER_CUH_
9#define CELLLIST_GPU_KER_CUH_
11#include "NN/CellList/CellList_def.hpp"
12#include "NN/CellList/cuda/CellDecomposer_gpu_ker.cuh"
14#ifdef USE_LOW_REGISTER_ITERATOR
17__constant__
int cells_striding[126];
20template<
unsigned int dim,
int r_
int,
unsigned int pr_
int,
typename ids_type,
typename cnt_type>
21struct NN_gpu_int_base_lr_impl
35 c_id = ca_lin + cells_striding[ca_pnt];
44 c_id = ca_lin + cells_striding[ca_pnt];
48 __device__
inline bool isNext_impl()
50 return ca_pnt < pr_int;
56template<
unsigned int dim,
int r_
int,
unsigned int pr_
int,
typename ids_type,
typename cnt_type>
68 for (
size_t i = 0 ; i < dim ; i++)
70 cell_start.
set_d(i,cell_pos.
get(i) - r_int);
71 cell_stop.
set_d(i,cell_pos.
get(i) + r_int);
72 cell_act.
set_d(i,cell_pos.
get(i) - r_int);
80 cnt_type
id = cell_act.
get(0);
81 cell_act.
set_d(0,
id+1);
86 for ( ; i < dim-1 ; i++)
88 size_t id = cell_act.
get(i);
89 if ((
int)
id > cell_stop.
get(i))
94 id = cell_act.
get(i+1);
95 cell_act.
set_d(i+1,
id+1);
106 __device__ __host__
inline bool isNext_impl()
108 return cell_act.
get(dim-1) <= cell_stop.
get(dim-1);
112#ifdef USE_LOW_REGISTER_ITERATOR
114template<
unsigned int dim,
int r_
int,
unsigned int pr_
int,
typename ids_type,
typename cnt_type>
118template<
int r_
int,
unsigned int pr_
int,
typename ids_type,
typename cnt_type>
119struct NN_gpu_int_base<2,r_int,pr_int,ids_type,cnt_type>:
public NN_gpu_int_base_lr_impl<2,r_int,pr_int,ids_type,cnt_type>
122template<
int r_
int,
unsigned int pr_
int,
typename ids_type,
typename cnt_type>
123struct NN_gpu_int_base<3,r_int,pr_int,ids_type,cnt_type>:
public NN_gpu_int_base_lr_impl<3,r_int,pr_int,ids_type,cnt_type>
128template<
unsigned int dim,
int r_
int,
unsigned int pr_
int,
typename ids_type,
typename cnt_type>
134template<
unsigned int dim,
typename cnt_type,
typename ids_type,
unsigned int r_
int,
bool is_sparse>
148 inline __device__ __host__
void SelectValid()
150 while (p_id >= p_id_end && isNext())
154 if (isNext() ==
false) {
break;}
156 p_id = starts.template get<0>(this->c_id);
157 p_id_end = starts.template get<0>(this->c_id+1);
169 :starts(starts),srt(srt),div_c(div_c),off(off)
173 this->init_impl(cell_pos,div_c);
175 p_id = starts.template get<0>(this->c_id);
176 p_id_end = starts.template get<0>(this->c_id+1);
181 inline __device__ __host__ cnt_type get_sort()
186 inline __device__ __host__ cnt_type get()
188 return srt.template get<0>(p_id);
200 inline __device__ cnt_type get_start(
unsigned int ce_id)
202 return starts.template get<0>(ce_id);
205 inline __device__ cnt_type get_cid()
210 inline __device__ __host__
bool isNext()
212 return this->isNext_impl();
216template<
unsigned int dim,
typename cnt_type,
typename ids_type,
unsigned int r_
int>
222 cnt_type cells_list_start;
223 cnt_type cells_list_stop;
231 __device__ __host__
void SelectValid()
233 while (p_id >= p_id_end && isNext())
237 if (cells_list_start < cells_list_stop)
240 p_id = cell_nn_list.template get<0>(cells_list_start);
241 p_id_end = cell_nn_list.template get<1>(cells_list_start);
249 __device__
NN_gpu_it(cnt_type c_id_sparse,
253 :srt(srt),cells_nn(cells_nn),cell_nn_list(cell_nn_list)
255 if (c_id_sparse == (cnt_type)-1)
257 cells_list_stop = cells_list_start;
261 cells_list_start = cells_nn.template get<0>(c_id_sparse);
262 cells_list_stop = cells_nn.template get<0>(c_id_sparse + 1);
265 p_id = cell_nn_list.template get<0>(cells_list_start);
266 p_id_end = cell_nn_list.template get<1>(cells_list_start);
271 __device__ cnt_type get_sort()
276 __device__ cnt_type get()
278 return srt.template get<0>(p_id);
290 __device__ __host__
bool isNext()
292 return cells_list_start < cells_list_stop;
296template<
unsigned int dim,
typename cnt_type,
typename ids_type>
316 __device__ __host__
inline void SelectValid()
318 while (isNext() && p_id >= starts.template get<0>(c_id+1))
322 if (act >= cells.
size())
325 c_id = pos + cells.template get<0>(act);
326 p_id = starts.template get<0>(c_id);
339 :act(0),cells(cells),starts(starts),srt(srt),div_c(div_c),off(off)
344 c_id = pos + cells.template get<0>(act);
345 p_id = starts.template get<0>(c_id);
350 __device__ cnt_type get_sort()
355 __device__ cnt_type get()
357 return srt.template get<0>(p_id);
369 __device__ cnt_type get_start(
unsigned int ce_id)
371 return starts.template get<0>(ce_id);
374 __device__ cnt_type get_cid()
379 __device__ __host__
bool isNext()
381 return act < cells.
size();
385template<
unsigned int dim,
typename cnt_type,
typename ids_type,
bool is_sparse>
400template<
unsigned int dim,
typename cnt_type,
typename ids_type>
404 cnt_type c_id_sparse,
418template<
unsigned int dim,
typename T,
typename cnt_type,
typename ids_type,
typename transform,
bool is_sparse>
438 typedef int yes_is_gpu_ker_celllist;
459 :
CellDecomposer_gpu_ker<dim,T,cnt_type,ids_type,transform>(
spacing_c,
div_c,
off,
t,
box_unit,
gr_cell,
cell_shift),
465 template<
unsigned int stub = NO_CHECK>
515 return starts.template get<0>(cell_id+1) -
starts.template get<0>(cell_id);
528 inline __device__ cnt_type
get(
size_t cell,
size_t ele)
530 cnt_type p_id =
starts.template get<0>(cell) +
ele;
531 return srt.template get<0>(p_id);
535 inline __device__
unsigned int get_g_m()
551 pc =
starts.check_device_pointer(ptr);
553 if (pc.
match ==
true)
559 pc =
srt.check_device_pointer(ptr);
561 if (pc.
match ==
true)
567 pc =
dprt.check_device_pointer(ptr);
569 if (pc.
match ==
true)
575 pc =
rad_cells.check_device_pointer(ptr);
577 if (pc.
match ==
true)
590template<
unsigned int dim,
typename T,
typename cnt_type,
typename ids_type,
typename transform>
630 :
CellDecomposer_gpu_ker<dim,T,cnt_type,ids_type,transform>(
spacing_c,
div_c,
off,
t,
box_unit,
gr_cell,
cell_shift),
643 template<
unsigned int stub = NO_CHECK>
651 template<
unsigned int r_
int = 2>
653 getNNIteratorBox(
decltype(cl_sparse.
get_sparse(0)) cid)
672 inline __device__
unsigned int get_g_m()
688 pc = cell_nn.check_device_pointer(ptr);
690 if (pc.
match ==
true)
696 pc = cell_nn_list.check_device_pointer(ptr);
698 if (pc.
match ==
true)
700 pc.
match_str = std::string(
"Cell particle buffer overflow (cell_nn_list): ") +
"\n" + pc.
match_str;
704 pc =
srt.check_device_pointer(ptr);
706 if (pc.
match ==
true)
712 pc =
dprt.check_device_pointer(ptr);
714 if (pc.
match ==
true)
openfpm::array< T, dim, cnt_type > spacing_c
Spacing.
grid_sm< dim, void > gr_cell
Grid structure of the Cell list.
Point< dim, long int > cell_shift
cell_shift
transform t
transformation
openfpm::array< ids_type, dim, cnt_type > div_c
number of sub-divisions in each direction
SpaceBox< dim, T > box_unit
Unit box of the Cell list.
openfpm::array< ids_type, dim, cnt_type > off
cell offset
openfpm::vector_gpu_ker< aggregate< int >, memory_traits_inte > rad_cells
radius cells
__device__ cnt_type get(size_t cell, size_t ele)
Get an element in the cell.
int yes_has_check_device_pointer
Indicate this structure has a function to check the device pointer.
openfpm::vector_gpu_ker< aggregate< cnt_type >, memory_traits_inte > starts
starting point for each cell
openfpm::vector_gpu_ker< aggregate< cnt_type >, memory_traits_inte > srt
Sorted to non sorted ids conversion.
unsigned int g_m
Ghost particle marker.
__device__ cnt_type getNelements(const cnt_type cell_id) const
Return the number of elements in the cell.
__device__ unsigned int getNCells() const
Get the number of cells this cell-list contain.
openfpm::vector_gpu_ker< aggregate< cnt_type >, memory_traits_inte > dprt
Domain particles ids.
This class implement the point shape in an N-dimensional space.
This class represent an N-dimensional box.
grid_key_dx is the key to access any element in the grid
__device__ __host__ void set_d(index_type i, index_type id)
Set the i index.
__device__ __host__ index_type get(index_type i) const
Get the i index.
__device__ openfpm::sparse_index< Ti > get_sparse(Ti id) const
Get the sparse index.
__device__ __host__ void SelectValid_impl(const openfpm::array< ids_type, dim, cnt_type > &div_c)
aggregate of properties, from a list of object if create a struct that follow the OPENFPM native stru...
Transform the boost::fusion::vector into memory specification (memory_traits)
grid interface available when on gpu
__device__ __host__ unsigned int size() const
Return the size of the vector.
std::string match_str
match string
bool match
Indicate if the pointer match.