Shamrock
2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
shamrock
include
shamrock
legacy
patch
utility
patch_reduc_tree.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
18
#include "
shambase/exception.hpp
"
19
#include "
shamrock/scheduler/PatchTree.hpp
"
20
#include "
shamsys/legacy/sycl_handler.hpp
"
21
#include <stdexcept>
22
#include <vector>
23
24
template
<
class
type>
25
class
PatchFieldReduction
{
26
public
:
27
std::vector<type> tree_field;
28
sycl::buffer<type> *tree_field_buf =
nullptr
;
29
30
inline
void
attach_buf() {
31
if
(tree_field_buf !=
nullptr
)
32
throw
shambase::make_except_with_loc<std::runtime_error>
(
33
"tree_field_buf is already allocated"
);
34
tree_field_buf =
new
sycl::buffer<type>(tree_field.data(), tree_field.size());
35
}
36
37
inline
void
detach_buf() {
38
if
(tree_field_buf ==
nullptr
)
39
throw
shambase::make_except_with_loc<std::runtime_error>
(
40
"tree_field_buf wasn't allocated"
);
41
delete
tree_field_buf;
42
tree_field_buf =
nullptr
;
43
}
44
45
// inline void octtree_reduction(
46
// sycl::queue & queue,
47
// SerialPatchTree<box_vectype> & sptree,
48
// SchedulerMPI & sched){
49
50
// std::unordered_map<u64,u64> & idp_to_gid = sched.patch_list.id_patch_to_global_idx;
51
52
// sycl::range<1> range{sptree.get_element_count()};
53
54
// for (u32 level = 0; level < sptree.get_level_count(); level ++) {
55
// queue.submit([&](sycl::handler &cgh) {
56
57
// cgh.parallel_for<class OctreeReduction>(range, [=](sycl::item<1> item) {
58
// u64 i = (u64)item.get_id(0);
59
60
// });
61
// });
62
// }
63
64
// }
65
};
PatchTree.hpp
PatchFieldReduction
Definition
patch_reduc_tree.hpp:25
exception.hpp
This header file contains utility functions related to exception handling in the code.
shambase::throw_with_loc
void throw_with_loc(std::string message, SourceLocation loc=SourceLocation{})
Throw an exception and append the source location to it.
Definition
exception.hpp:132
sycl_handler.hpp
header file to manage sycl
Generated on Wed May 13 2026 13:21:49 for Shamrock by
1.9.8