Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
LeafCellIterator.hpp
Go to the documentation of this file.
1// -------------------------------------------------------//
2//
3// SHAMROCK code for hydrodynamics
4// Copyright (c) 2021-2026 Timothée David--Cléris <tim.shamrock@proton.me>
5// SPDX-License-Identifier: CeCILL Free Software License Agreement v2.1
6// Shamrock is licensed under the CeCILL 2.1 License, see LICENSE for more information
7//
8// -------------------------------------------------------//
9
10#pragma once
11
20#include "shambackends/math.hpp"
21#include "shamcomm/logs.hpp"
22#include <utility>
23
24namespace shamtree {
25
29
40 template<class Functor_iter>
41 inline void for_each_in_leaf_cell(const u32 &cell_id, Functor_iter &&func_it) const {
42 // loop on particle indexes
43 uint min_ids = reduc_index_map[cell_id];
44 uint max_ids = reduc_index_map[cell_id + 1];
45
46 for (unsigned int id_s = min_ids; id_s < max_ids; id_s++) {
47
48 // recover old index before morton sort
49 uint id_b = sort_index_map[id_s];
50
51 // iteration function
52 func_it(id_b);
53 }
54 }
55 };
56
97
100 std::vector<u32> sort_index_map;
101 std::vector<u32> reduc_index_map;
102
104
106 inline acc get_read_access() const {
107 return acc{sort_index_map.data(), reduc_index_map.data()};
108 }
109 };
110
111} // namespace shamtree
std::uint32_t u32
32 bit unsigned integer
A buffer allocated in USM (Unified Shared Memory)
void complete_event_state(sycl::event e) const
Complete the event state of the buffer.
const T * get_read_access(sham::EventList &depends_list, SourceLocation src_loc=SourceLocation{}) const
Get a read-only pointer to the buffer's data.
Class to manage a list of SYCL events.
Definition EventList.hpp:31
const u32 * reduc_index_map
Pointer to the reduction index map.
void for_each_in_leaf_cell(const u32 &cell_id, Functor_iter &&func_it) const
Iterate over all particles in a given cell.
const u32 * sort_index_map
Pointer to the sort index map.
host version of the cell iterator
std::vector< u32 > reduc_index_map
Reduction index map.
std::vector< u32 > sort_index_map
Sort index map.
acc get_read_access() const
get read only accessor
void complete_event_state(sycl::event e) const
Completes the event state for the associated buffers.
const sham::DeviceBuffer< u32 > & buf_sort_index_map
Sort index map buffer.
acc get_read_access(sham::EventList &deps) const
Get a read-only access to the buffers.
const sham::DeviceBuffer< u32 > & buf_reduc_index_map
Reduction index map buffer.