diff --git a/src/shamrock/include/shamrock/legacy/patch/utility/patch_reduc_tree.hpp b/src/shamrock/include/shamrock/legacy/patch/utility/patch_reduc_tree.hpp deleted file mode 100644 index 3f8b6b4b9..000000000 --- a/src/shamrock/include/shamrock/legacy/patch/utility/patch_reduc_tree.hpp +++ /dev/null @@ -1,65 +0,0 @@ -// -------------------------------------------------------// -// -// SHAMROCK code for hydrodynamics -// Copyright (c) 2021-2026 Timothée David--Cléris -// SPDX-License-Identifier: CeCILL Free Software License Agreement v2.1 -// Shamrock is licensed under the CeCILL 2.1 License, see LICENSE for more information -// -// -------------------------------------------------------// - -#pragma once -/** - * @file patch_reduc_tree.hpp - * @author Timothée David--Cléris (tim.shamrock@proton.me) - * @brief - * - */ - -#include "shambase/exception.hpp" -#include "shamrock/scheduler/PatchTree.hpp" -#include "shamsys/legacy/sycl_handler.hpp" -#include -#include - -template -class PatchFieldReduction { - public: - std::vector tree_field; - sycl::buffer *tree_field_buf = nullptr; - - inline void attach_buf() { - if (tree_field_buf != nullptr) - throw shambase::make_except_with_loc( - "tree_field_buf is already allocated"); - tree_field_buf = new sycl::buffer(tree_field.data(), tree_field.size()); - } - - inline void detach_buf() { - if (tree_field_buf == nullptr) - throw shambase::make_except_with_loc( - "tree_field_buf wasn't allocated"); - delete tree_field_buf; - tree_field_buf = nullptr; - } - - // inline void octtree_reduction( - // sycl::queue & queue, - // SerialPatchTree & sptree, - // SchedulerMPI & sched){ - - // std::unordered_map & idp_to_gid = sched.patch_list.id_patch_to_global_idx; - - // sycl::range<1> range{sptree.get_element_count()}; - - // for (u32 level = 0; level < sptree.get_level_count(); level ++) { - // queue.submit([&](sycl::handler &cgh) { - - // cgh.parallel_for(range, [=](sycl::item<1> item) { - // u64 i = (u64)item.get_id(0); - - // }); - // }); - // } - - // } -}; diff --git a/src/shamrock/include/shamrock/scheduler/SerialPatchTree.hpp b/src/shamrock/include/shamrock/scheduler/SerialPatchTree.hpp index 8449755de..c0b753828 100644 --- a/src/shamrock/include/shamrock/scheduler/SerialPatchTree.hpp +++ b/src/shamrock/include/shamrock/scheduler/SerialPatchTree.hpp @@ -21,7 +21,6 @@ #include "shambase/memory.hpp" #include "shambase/stacktrace.hpp" #include "shamrock/legacy/patch/utility/patch_field.hpp" -#include "shamrock/legacy/patch/utility/patch_reduc_tree.hpp" #include "shamrock/patch/PatchField.hpp" #include "shamrock/scheduler/PatchScheduler.hpp" #include "shamrock/scheduler/PatchTree.hpp" @@ -174,95 +173,6 @@ class SerialPatchTree { sched.patch_tree, sched.get_patch_transform()); } - template - inline PatchFieldReduction reduce_field( - sycl::queue &queue, PatchScheduler &sched, legacy::PatchField &pfield) { - - PatchFieldReduction predfield; - - std::cout << "resize to " << get_element_count() << std::endl; - predfield.tree_field.resize(get_element_count()); - - { - sycl::host_accessor lpid{*linked_patch_ids_buf, sycl::read_only}; - - // init reduction - std::unordered_map &idp_to_gid = sched.patch_list.id_patch_to_global_idx; - for (u64 idx = 0; idx < get_element_count(); idx++) { - predfield.tree_field[idx] - = (lpid[idx] != u64_max) ? pfield.global_values[idp_to_gid[lpid[idx]]] : type(); - - // std::cout << " el " << idx << " " << predfield.tree_field[idx] << std::endl; - } - } - - // std::cout << "predfield.attach_buf();" << std::endl; - - predfield.attach_buf(); - - sycl::range<1> range{get_element_count()}; - - u32 end_loop = get_level_count(); - - for (u32 level = 0; level < end_loop; level++) { - - // { - // auto f = predfield.tree_field_buf->template - // get_access(); std::cout << "["; for (u64 idx = 0; idx < - // get_element_count() ; idx ++) { - // std::cout << f[idx] << ","; - // } - // std::cout << std::endl; - // } - - std::cout << "queue submit : " << level << " " << end_loop << " " << (level < end_loop) - << std::endl; - queue.submit([&](sycl::handler &cgh) { - auto tree - = this->serial_tree_buf->template get_access(cgh); - - auto f - = predfield.tree_field_buf->template get_access( - cgh); - - cgh.parallel_for(range, [=](sycl::item<1> item) { - u64 i = (u64) item.get_id(0); - - u64 idx_c0 = tree[i].childs_id0; - u64 idx_c1 = tree[i].childs_id1; - u64 idx_c2 = tree[i].childs_id2; - u64 idx_c3 = tree[i].childs_id3; - u64 idx_c4 = tree[i].childs_id4; - u64 idx_c5 = tree[i].childs_id5; - u64 idx_c6 = tree[i].childs_id6; - u64 idx_c7 = tree[i].childs_id7; - - if (idx_c0 != u64_max) { - f[i] = reduc_func::reduce( - f[idx_c0], - f[idx_c1], - f[idx_c2], - f[idx_c3], - f[idx_c4], - f[idx_c5], - f[idx_c6], - f[idx_c7]); - } - }); - }); - } - // { - // auto f = predfield.tree_field_buf->template get_access(); - // std::cout << "["; - // for (u64 idx = 0; idx < get_element_count() ; idx ++) { - // std::cout << f[idx] << ","; - // } - // std::cout << std::endl; - // } - - return predfield; - } - template inline shamrock::patch::PatchtreeField make_patch_tree_field( PatchScheduler &sched, @@ -445,20 +355,6 @@ sycl::buffer SerialPatchTree::compute_patch_owner( } } - if constexpr (false) { - PtNode cur_node = tnode[current_node]; - if (xyz[0] == 0 && xyz[1] == 0 && xyz[2] == 0) { - logger::raw( - shambase::format( - "{:5} ({}) -> {} [{} {}]\n", - i, - Patch::is_in_patch_converted(xyz, cur_node.box_min, cur_node.box_max), - xyz, - cur_node.box_min, - cur_node.box_max)); - } - } - new_id[i] = result_node; }); });