Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
sort_by_keys.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
20
21namespace shamalgs::primitives {
22
23 template<class Tkey, class Tval>
25 sycl::queue &q, sycl::buffer<Tkey> &buf_key, sycl::buffer<Tval> &buf_values, u32 len) {
26
27 if (len < 5e3) {
28 shamalgs::algorithm::details::sort_by_key_bitonic_fallback(q, buf_key, buf_values, len);
29 } else {
30 shamalgs::algorithm::details::sort_by_key_bitonic_updated<Tkey, Tval, 16>(
31 q, buf_key, buf_values, len);
32 }
33 }
34
35 template<class Tkey, class Tval>
37 const sham::DeviceScheduler_ptr &sched,
39 sham::DeviceBuffer<Tval> &buf_values,
40 u32 len) {
41 shamalgs::algorithm::details::sort_by_key_bitonic_updated_usm<Tkey, Tval, 16>(
42 sched, buf_key, buf_values, len);
43 }
44
45 template void sort_by_key_pow2_len(
46 sycl::queue &q, sycl::buffer<u32> &buf_key, sycl::buffer<u32> &buf_values, u32 len);
47
48 template void sort_by_key_pow2_len(
49 sycl::queue &q, sycl::buffer<u64> &buf_key, sycl::buffer<u32> &buf_values, u32 len);
50
51 template void sort_by_key_pow2_len(
52 const sham::DeviceScheduler_ptr &sched,
54 sham::DeviceBuffer<u32> &buf_values,
55 u32 len);
56
57 template void sort_by_key_pow2_len(
58 const sham::DeviceScheduler_ptr &sched,
60 sham::DeviceBuffer<u32> &buf_values,
61 u32 len);
62
63 template void sort_by_key_pow2_len(
64 const sham::DeviceScheduler_ptr &sched,
66 sham::DeviceBuffer<f64> &buf_values,
67 u32 len);
68
69 template void sort_by_key_pow2_len(
70 const sham::DeviceScheduler_ptr &sched,
72 sham::DeviceBuffer<f32> &buf_values,
73 u32 len);
74
75} // namespace shamalgs::primitives
std::uint32_t u32
32 bit unsigned integer
main include file for the shamalgs algorithms
A buffer allocated in USM (Unified Shared Memory)
namespace for primitive algorithm (e.g. sort, scan, reductions, ...)
void sort_by_key_pow2_len(sycl::queue &q, sycl::buffer< Tkey > &buf_key, sycl::buffer< Tval > &buf_values, u32 len)
Sort key-value pairs using sycl::buffers (power-of-2 optimized)
Sort by keys algorithms.