1 #ifndef CELLLIST_GPU_KER_CUH_
2 #define CELLLIST_GPU_KER_CUH_
4 #include "NN/CellList/cuda/CellDecomposer_gpu_ker.cuh"
7 template<
unsigned int dim,
typename ids_type>
15 int neighborCellIndexAct;
16 int cellPositionIndex;
17 unsigned int boxNeighborCellOffset_i;
18 unsigned int neighborPartIndexStart;
19 unsigned int neighborPartIndexStop;
21 inline __device__
void SelectValid()
23 while (neighborPartIndexStart == neighborPartIndexStop && isNext())
27 if (isNext() ==
false)
break;
29 if (cellPositionIndex+this->neighborCellIndexAct+1 >= numPartInCellPrefixSum.
size() || cellPositionIndex+this->neighborCellIndexAct < 0)
32 neighborPartIndexStart = numPartInCellPrefixSum.template get<0>(cellPositionIndex+this->neighborCellIndexAct);
33 neighborPartIndexStop = numPartInCellPrefixSum.template get<0>(cellPositionIndex+this->neighborCellIndexAct+1);
44 : numPartInCellPrefixSum(numPartInCellPrefixSum),
45 sortedToUnsortedIndex(sortedToUnsortedIndex),
46 neighborCellOffset(neighborCellOffset),
48 boxNeighborCellOffset_i(0),
50 neighborCellIndexAct(neighborCellOffset.template get<0>(0))
52 neighborPartIndexStart = numPartInCellPrefixSum.template get<0>(cellPositionIndex+neighborCellIndexAct);
53 neighborPartIndexStop = numPartInCellPrefixSum.template get<0>(cellPositionIndex+neighborCellIndexAct+1);
65 : numPartInCellPrefixSum(numPartInCellPrefixSum),
66 sortedToUnsortedIndex(sortedToUnsortedIndex),
67 neighborCellOffset(neighborCellOffset),
69 boxNeighborCellOffset_i(0),
71 neighborCellIndexAct(neighborCellOffset.template get<0>(0))
73 neighborPartIndexStart = numPartInCellPrefixSum.template get<0>(cellPositionIndex+neighborCellIndexAct);
74 neighborPartIndexStop = numPartInCellPrefixSum.template get<0>(cellPositionIndex+neighborCellIndexAct+1);
79 inline __device__
unsigned int get_sort()
81 return neighborPartIndexStart;
84 inline __device__
unsigned int get()
86 return sortedToUnsortedIndex.template get<0>(neighborPartIndexStart);
91 ++neighborPartIndexStart; SelectValid();
96 inline __device__
unsigned int get_start(
unsigned int ce_id)
98 return numPartInCellPrefixSum.template get<0>(ce_id);
101 inline __device__
unsigned int get_cid()
103 return cellPositionIndex + neighborCellIndexAct;
106 inline __device__
bool isNext()
108 return boxNeighborCellOffset_i < neighborCellOffset.
size();
111 __device__
inline void nextCell()
113 ++boxNeighborCellOffset_i;
115 if (isNext()) neighborCellIndexAct = neighborCellOffset.template get<0>(boxNeighborCellOffset_i);
121 template<
unsigned int dim,
typename T,
typename ids_type,
typename transform_type,
bool is_sparse>
147 typedef int yes_is_gpu_ker_celllist;
171 :
CellDecomposer_gpu_ker<dim,T,ids_type,transform_type>(
unitCellP2,numCellDim,
cellPadDim,
pointTransform,
cellListSpaceBox,
cellListGrid,
cellShift),
232 inline __device__
unsigned int getNelements(
unsigned int cell_id)
const
247 inline __device__
unsigned int get(
256 inline __device__
unsigned int getGhostMarker()
274 if (pc.
match ==
true)
276 pc.
match_str = std::string(
"Cell index overflow (numPartInCellPrefixSum): ") +
"\n" + pc.
match_str;
282 if (pc.
match ==
true)
290 if (pc.
match ==
true)
292 pc.
match_str = std::string(
"Particle index overflow (sortedToSortedIndexNoGhost): ") +
"\n" + pc.
match_str;
298 if (pc.
match ==
true)
300 pc.
match_str = std::string(
"Particle index overflow (sortedToSortedIndexNoGhost): ") +
"\n" + pc.
match_str;
311 template<
unsigned int dim,
typename ids_type>
314 unsigned int neighborPartIndexStart;
315 unsigned int neighborPartIndexStop;
316 unsigned int neighborCellIndexStart;
317 unsigned int neighborCellIndexStop;
323 __device__
void SelectValid()
325 while ((neighborPartIndexStart == neighborPartIndexStop) && isNext())
327 ++neighborCellIndexStart;
329 if (neighborCellIndexStart < neighborCellIndexStop)
331 neighborPartIndexStart = neighborPartIndexFrom_To.template get<0>(neighborCellIndexStart);
332 neighborPartIndexStop = neighborPartIndexFrom_To.template get<1>(neighborCellIndexStart);
339 unsigned int cellIndex,
343 : sortedToUnsortedIndex(sortedToUnsortedIndex),
344 neighborCellCountPrefixSum(neighborCellCountPrefixSum),
345 neighborPartIndexFrom_To(neighborPartIndexFrom_To)
347 if (cellIndex == (
unsigned int)-1)
349 neighborCellIndexStop = neighborCellIndexStart;
353 neighborCellIndexStart = neighborCellCountPrefixSum.template get<0>(cellIndex);
354 neighborCellIndexStop = neighborCellCountPrefixSum.template get<0>(cellIndex + 1);
356 neighborPartIndexStart = neighborPartIndexFrom_To.template get<0>(neighborCellIndexStart);
357 neighborPartIndexStop = neighborPartIndexFrom_To.template get<1>(neighborCellIndexStart);
362 __device__
unsigned int get_sort()
364 return neighborPartIndexStart;
367 __device__
unsigned int get()
369 return sortedToUnsortedIndex.template get<0>(neighborPartIndexStart);
374 ++neighborPartIndexStart; SelectValid();
379 inline __device__
bool isNext()
381 return neighborCellIndexStart < neighborCellIndexStop;
386 template<
unsigned int dim,
typename T,
typename ids_type,
typename transform_type>
427 :
CellDecomposer_gpu_ker<dim,T,ids_type,transform_type>(
unitCellP2,numCellDim,
cellPadDim,
pointTransform,
cellListSpaceBox,
cellListGrid,
cellShift),
428 neighborCellCountPrefixSum(neighborCellCountPrefixSum),
429 neighborPartIndexFrom_To(neighborPartIndexFrom_To),
432 vecSparseCellIndex_PartIndex(vecSparseCellIndex_PartIndex),
436 inline __device__
auto getCell(
438 const -> decltype(vecSparseCellIndex_PartIndex.
get_sparse(0))
442 return vecSparseCellIndex_PartIndex.
get_sparse(cell);
446 decltype(vecSparseCellIndex_PartIndex.
get_sparse(0)) cId)
465 inline __device__
unsigned int getGhostMarker()
481 pc = neighborCellCountPrefixSum.check_device_pointer(ptr);
483 if (pc.
match ==
true)
489 pc = neighborPartIndexFrom_To.check_device_pointer(ptr);
491 if (pc.
match ==
true)
493 pc.
match_str = std::string(
"Cell particle buffer overflow (neighborPartIndexFrom_To): ") +
"\n" + pc.
match_str;
499 if (pc.
match ==
true)
507 if (pc.
match ==
true)
509 pc.
match_str = std::string(
"Particle index overflow (sortedToSortedIndexNoGhost): ") +
"\n" + pc.
match_str;
This class represent an N-dimensional box.
Box< dim, T > cellListSpaceBox
Unit box of the Cell list.
openfpm::array< ids_type, dim > cellPadDim
cell offset
openfpm::array< T, dim > unitCellP2
Spacing.
transform_type pointTransform
transformation
Point< dim, long int > cellShift
cellShift
grid_sm< dim, void > cellListGrid
Grid structure of the Cell list.
__device__ unsigned int getNCells() const
Get the number of cells this cell-list contain.
int yes_has_check_device_pointer
Indicate this structure has a function to check the device pointer.
openfpm::vector_gpu_ker< aggregate< unsigned int >, memory_traits_inte > numPartInCellPrefixSum
starting point for each cell
unsigned int ghostMarker
Ghost particle marker.
__device__ unsigned int get(unsigned int cell, unsigned int ele)
Get an element in the cell.
openfpm::vector_gpu_ker< aggregate< unsigned int >, memory_traits_inte > sortedToSortedIndexNoGhost
Domain particles ids.
openfpm::vector_gpu_ker< aggregate< int >, memory_traits_inte > boxNeighborCellOffsetSym
Box cells.
openfpm::vector_gpu_ker< aggregate< int >, memory_traits_inte > rcutNeighborCellOffset
radius cells
openfpm::vector_gpu_ker< aggregate< int >, memory_traits_inte > boxNeighborCellOffset
Box cells.
openfpm::vector_gpu_ker< aggregate< unsigned int >, memory_traits_inte > sortedToUnsortedIndex
Sorted to non sorted ids conversion.
__device__ unsigned int getNelements(unsigned int cell_id) const
Return the number of elements in the cell.
grid_key_dx is the key to access any element in the grid
__device__ openfpm::sparse_index< Ti > get_sparse(Ti id) const
Get the sparse index.
KeyT const ValueT ValueT OffsetIteratorT OffsetIteratorT int
[in] The number of segments that comprise the sorting data
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.