24#include <Cabana_VerletList.hpp>
30template <
class MemorySpace,
class ListAlgorithm,
class Layout,
class BuildTag>
33template <
class MemorySpace,
class AlgorithmTag,
class BuildTag>
41 class BuildTag = Cabana::TeamVectorOpTag>
43 LayoutTag, BuildTag> {
51 Kokkos::View<int *, MemorySpace>
counts;
52 Kokkos::View<int **, Kokkos::LayoutRight, MemorySpace>
neighbors;
65 neighbors = Kokkos::View<int **, Kokkos::LayoutRight, MemorySpace>(
66 Kokkos::view_alloc(
MemorySpace{}, Kokkos::WithoutInitializing,
88 count = Kokkos::atomic_fetch_add(&
counts(pid), 1);
100 auto const count =
counts(pid);
133 Kokkos::parallel_for(
"custom_verlet_list::sort_neighbors",
134 Kokkos::RangePolicy<Kokkos::DefaultHostExecutionSpace>(
135 std::size_t{0},
counts.size()),
136 [&](std::size_t
const i) {
137 auto const count =
counts(i);
139 std::sort(ptr, ptr + count);
150 for (
int pid = 0; pid <
counts.extent(0); ++pid) {
151 auto const count =
static_cast<long>(
counts(pid));
157 if (
counts.extent(0) != 0) {
171 Kokkos::parallel_reduce(
172 "custom_verlet_list::reduce_max",
173 Kokkos::RangePolicy<Kokkos::DefaultHostExecutionSpace>(std::size_t{0},
175 [&](std::size_t
const i,
int &value) {
190template <
class MemorySpace,
class AlgorithmTag,
class BuildTag>
205 for (std::size_t i = 0; i <
num_p; ++i)
228 std::size_t
const count) {
static KOKKOS_INLINE_FUNCTION std::size_t getNeighbor(list_type const &list, std::size_t const particle_index, std::size_t const count)
Get the id for a neighbor for a given particle index and the index of the neighbor relative to the pa...
static KOKKOS_INLINE_FUNCTION std::size_t totalNeighbor(list_type const &list)
Get the total number of neighbors across all particles.
static KOKKOS_INLINE_FUNCTION std::size_t maxNeighbor(list_type const &list)
Get the maximum number of neighbors per particle.
static KOKKOS_INLINE_FUNCTION std::size_t numNeighbor(list_type const &list, std::size_t const particle_index)
Get the number of neighbors for a given particle index.
MemorySpace memory_space
Kokkos memory space.
KOKKOS_INLINE_FUNCTION void addNeighborLB(int pid, int nid)
void initializeData(std::size_t const num_particles, std::size_t const max_neigh)
KOKKOS_INLINE_FUNCTION void sortNeighbors()
KOKKOS_INLINE_FUNCTION auto get_max_counts()
CustomVerletList(std::size_t const begin, std::size_t const end, std::size_t const max_neigh)
void reallocData(std::size_t const num_particles, std::size_t const max_neigh)
KOKKOS_INLINE_FUNCTION void addNeighborAtomicLB(int pid, int nid)
KOKKOS_INLINE_FUNCTION void addNeighbor(int pid, int nid)
CustomVerletList()=default
Kokkos::View< int **, Kokkos::LayoutRight, MemorySpace > neighbors
KOKKOS_INLINE_FUNCTION auto get_variance_max_counts(auto &ostream)
Kokkos::View< int *, MemorySpace > counts
KOKKOS_INLINE_FUNCTION bool hasOverflow() const
cudaStream_t stream[1]
CUDA streams for parallel computing on CPU and GPU.