Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
reduction.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
17
20#include <string>
21#include <vector>
22
23namespace shamalgs::primitives {
24
56 template<class T>
57 T sum(
58 const sham::DeviceScheduler_ptr &sched,
59 const sham::DeviceBuffer<T> &buf1,
60 u32 start_id,
61 u32 end_id);
62
94 template<class T>
95 T min(
96 const sham::DeviceScheduler_ptr &sched,
97 const sham::DeviceBuffer<T> &buf1,
98 u32 start_id,
99 u32 end_id);
100
132 template<class T>
133 T max(
134 const sham::DeviceScheduler_ptr &sched,
135 const sham::DeviceBuffer<T> &buf1,
136 u32 start_id,
137 u32 end_id);
138
140 namespace impl {
141
143 std::vector<std::string> get_default_impl_list_reduction();
144
146 std::string get_current_impl_reduction();
147
150
152 void set_impl_reduction(const std::string &impl);
153
155 void autoselect_impl_reduction(const sham::DeviceScheduler_ptr &dev_sched);
156
157 } // namespace impl
158
159} // namespace shamalgs::primitives
std::uint32_t u32
32 bit unsigned integer
namespace to control implementation behavior
bool is_impl_set_reduction()
Check if an implementation has been selected for reduction.
void autoselect_impl_reduction(const sham::DeviceScheduler_ptr &dev_sched)
Select the default implementation for reduction.
std::string get_current_impl_reduction()
Get the current implementation for reduction, as a config json string.
Definition reduction.cpp:99
std::vector< std::string > get_default_impl_list_reduction()
Get list of available reduction implementations, as config json strings.
Definition reduction.cpp:94
void set_impl_reduction(const std::string &impl)
Set the implementation for reduction, from a config json string.
namespace for primitive algorithm (e.g. sort, scan, reductions, ...)
T sum(const sham::DeviceScheduler_ptr &sched, const sham::DeviceBuffer< T > &buf1, u32 start_id, u32 end_id)
Compute the sum of elements in a device buffer within a specified range.
T min(const sham::DeviceScheduler_ptr &sched, const sham::DeviceBuffer< T > &buf1, u32 start_id, u32 end_id)
Find the minimum element in a device buffer within a specified range.
T max(const sham::DeviceScheduler_ptr &sched, const sham::DeviceBuffer< T > &buf1, u32 start_id, u32 end_id)
Find the maximum element in a device buffer within a specified range.