Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
sort_by_keys.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
27#include "shambase/integer.hpp"
30
31namespace shamalgs::primitives {
32
58 template<class Tkey, class Tval>
60 sycl::queue &q, sycl::buffer<Tkey> &buf_key, sycl::buffer<Tval> &buf_values, u32 len);
61
87 template<class Tkey, class Tval>
89 const sham::DeviceScheduler_ptr &sched,
91 sham::DeviceBuffer<Tval> &buf_values,
92 u32 len);
93
122 template<class Tkey, class Tval>
124 sycl::queue &q, sycl::buffer<Tkey> &buf_key, sycl::buffer<Tval> &buf_values, u32 len) {
125 if (!shambase::is_pow_of_two(len))
126 shambase::throw_with_loc<std::invalid_argument>("Length must be a power of 2");
127 sort_by_key_pow2_len(q, buf_key, buf_values, len);
128 }
129
158 template<class Tkey, class Tval>
160 const sham::DeviceScheduler_ptr &sched,
162 sham::DeviceBuffer<Tval> &buf_values,
163 u32 len) {
164 if (!shambase::is_pow_of_two(len))
165 shambase::throw_with_loc<std::invalid_argument>("Length must be a power of 2");
166 sort_by_key_pow2_len(sched, buf_key, buf_values, len);
167 }
168
169} // namespace shamalgs::primitives
std::uint32_t u32
32 bit unsigned integer
A buffer allocated in USM (Unified Shared Memory)
This header file contains utility functions related to exception handling in the code.
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)
void sort_by_key(sycl::queue &q, sycl::buffer< Tkey > &buf_key, sycl::buffer< Tval > &buf_values, u32 len)
Sort key-value pairs using sycl::buffers.
constexpr bool is_pow_of_two(T v) noexcept
determine if v is a power of two and check if v==0 Source : https://graphics.stanford....
Definition integer.hpp:49
void throw_with_loc(std::string message, SourceLocation loc=SourceLocation{})
Throw an exception and append the source location to it.