48 std::vector<std::size_t> cell_offsets(local_cells.size(), std::size_t{0});
49 std::exclusive_scan(local_cells.begin(), local_cells.end(),
50 cell_offsets.begin(), std::size_t{0},
51 [](
auto acc,
auto const &cell) {
52 return acc + cell->particles().size();
56 "enumerate_local_particles", std::size_t{0}, local_cells.size(),
58 auto const base_offset = cell_offsets[cell_idx];
59 auto &cell_particles = local_cells[cell_idx]->particles();
60 auto const n_part = cell_particles.size();
61 for (std::size_t p_index{0}; p_index < n_part; ++p_index) {
62 auto global_index = base_offset + p_index;
63 kernel(global_index, *(cell_particles.begin() + p_index));
69 std::size_t index = 0;
virtual std::span< Cell *const > local_cells() const =0
Get pointer to local cells.
ESPRESSO_ATTR_ALWAYS_INLINE void kokkos_parallel_range_for(auto const &name, auto start, auto end, auto const &kernel)
Wrapper for Kokkos::parallel_for that skips fork/join when the number of threads is 1.
void enumerate_local_particles(CellStructure const &cs, Kernel &&kernel)
Run a kernel on all local particles with enumeration.