Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
MortonCodeSortedSet.cpp
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
19#include <utility>
20
21namespace shamtree {
22
23 template<class Tmorton, class Tvec, u32 dim>
25 const sham::DeviceScheduler_ptr &dev_sched,
26 MortonCodeSet<Tmorton, Tvec, dim> &&morton_codes_set,
27 sham::DeviceBuffer<u32> &&cached_map_morton_id_to_obj_id) {
28
29 shammath::AABB<Tvec> bounding_box = std::move(morton_codes_set.bounding_box);
30 u32 cnt_obj = std::move(morton_codes_set.cnt_obj);
31 u32 morton_count = std::move(morton_codes_set.morton_count);
32 sham::DeviceBuffer<Tmorton> morton_codes_to_sort = std::move(morton_codes_set.morton_codes);
33
34 auto map_morton_id_to_obj_id
35 = std::forward<sham::DeviceBuffer<u32>>(cached_map_morton_id_to_obj_id);
36
37 map_morton_id_to_obj_id.resize(morton_count);
38 shamalgs::primitives::fill_buffer_index(map_morton_id_to_obj_id, morton_count);
39
41 dev_sched, morton_codes_to_sort, map_morton_id_to_obj_id, morton_count);
42
44 std::move(bounding_box),
45 std::move(cnt_obj),
46 std::move(morton_count),
47 std::move(morton_codes_to_sort),
48 std::move(map_morton_id_to_obj_id));
49 }
50
51 template<class Tmorton, class Tvec, u32 dim>
53 const sham::DeviceScheduler_ptr &dev_sched,
54 MortonCodeSet<Tmorton, Tvec, dim> &&morton_codes_set) {
55
56 auto map_morton_id_to_obj_id
57 = sham::DeviceBuffer<u32>(morton_codes_set.morton_count, dev_sched);
58
59 return sort_morton_set<Tmorton, Tvec, dim>(
60 dev_sched,
61 std::forward<MortonCodeSet<Tmorton, Tvec, dim>>(morton_codes_set),
62 std::move(map_morton_id_to_obj_id));
63 }
64
65} // namespace shamtree
66
69
70template shamtree::MortonCodeSortedSet<u32, f64_3, 3> shamtree::sort_morton_set<u32, f64_3, 3>(
71 const sham::DeviceScheduler_ptr &dev_sched,
73template shamtree::MortonCodeSortedSet<u64, f64_3, 3> shamtree::sort_morton_set<u64, f64_3, 3>(
74 const sham::DeviceScheduler_ptr &dev_sched,
76
77template shamtree::MortonCodeSortedSet<u32, f64_3, 3> shamtree::sort_morton_set<u32, f64_3, 3>(
78 const sham::DeviceScheduler_ptr &dev_sched,
80 sham::DeviceBuffer<u32> &&cached_map_morton_id_to_obj_id);
81template shamtree::MortonCodeSortedSet<u64, f64_3, 3> shamtree::sort_morton_set<u64, f64_3, 3>(
82 const sham::DeviceScheduler_ptr &dev_sched,
84 sham::DeviceBuffer<u32> &&cached_map_morton_id_to_obj_id);
MortonCodeSortedSet< Tmorton, Tvec, dim > sort_morton_set(const sham::DeviceScheduler_ptr &dev_sched, MortonCodeSet< Tmorton, Tvec, dim > &&morton_codes_set)
Sorts a set of Morton codes and creates a new MortonCodeSortedSet object with the sorted codes and th...
std::uint32_t u32
32 bit unsigned integer
A buffer allocated in USM (Unified Shared Memory)
Class representing a set of Morton codes with associated bounding box and position data.
Class representing a set of Morton codes with associated bounding box and position data.
main include file for the shamalgs algorithms
Provides functions to generate and fill buffers with sequential indices.
void sort_by_key(sycl::queue &q, sycl::buffer< Tkey > &buf_key, sycl::buffer< Tval > &buf_values, u32 len)
Sort the buffer according to the key order.
Definition algorithm.hpp:41
void fill_buffer_index(sham::DeviceBuffer< u32 > &buf, u32 len)
Fills a buffer with sequential indices, such that buf[i] = i.
Axis-Aligned bounding box.
Definition AABB.hpp:99