Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
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
21#include <stdexcept>
22#include <vector>
23
24template<class type>
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)
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)
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};
This header file contains utility functions related to exception handling in the code.
void throw_with_loc(std::string message, SourceLocation loc=SourceLocation{})
Throw an exception and append the source location to it.
header file to manage sycl