69 comp_min[leaf_offset + leaf_id] = min;
70 comp_max[leaf_offset + leaf_id] = max;
77 auto ker_reduc_hmax = [&](sycl::handler &cgh) {
78 u32 offset_leaf = internal_cell_count;
80 sycl::accessor comp_min{tmp_min_cell, cgh, sycl::read_write};
81 sycl::accessor comp_max{tmp_max_cell, cgh, sycl::read_write};
83 sycl::accessor rchild_id{
85 sycl::accessor lchild_id{
87 sycl::accessor rchild_flag{
89 sycl::accessor lchild_flag{
92 shambase::parallel_for(cgh, internal_cell_count,
"propagate up", [=](
u64 gid) {
93 u32 lid = lchild_id[gid] + offset_leaf * lchild_flag[gid];
94 u32 rid = rchild_id[gid] + offset_leaf * rchild_flag[gid];
96 TgridVec bminl = comp_min[lid];
97 TgridVec bminr = comp_min[rid];
98 TgridVec bmaxl = comp_max[lid];
99 TgridVec bmaxr = comp_max[rid];
101 TgridVec bmin = sham::min(bminl, bminr);
102 TgridVec bmax = sham::max(bmaxl, bmaxr);
104 comp_min[gid] = bmin;
105 comp_max[gid] = bmax;
109 for (
u32 i = 0; i < tree.tree_depth; i++) {
113 sycl::buffer<TgridVec> &tree_bmin
115 sycl::buffer<TgridVec> &tree_bmax
121 u32 leaf_offset = tree.tree_struct.internal_cell_count;
123 sycl::accessor comp_bmin{tmp_min_cell, cgh, sycl::read_only};
124 sycl::accessor comp_bmax{tmp_max_cell, cgh, sycl::read_only};
126 sycl::accessor tree_buf_min{tree_bmin, cgh, sycl::read_write};
127 sycl::accessor tree_buf_max{tree_bmax, cgh, sycl::read_write};
129 shambase::parallel_for(cgh, tot_count,
"write in tree range", [=](
u64 nid) {
130 TgridVec load_min = comp_bmin[nid];
131 TgridVec load_max = comp_bmax[nid];
150 tree_buf_min[nid] = load_min;
151 tree_buf_max[nid] = load_max;
159 template<
class Umorton,
class Tgr
idVec>
161 auto edges = get_edges();
163 auto &block_min = edges.block_min;
164 auto &block_max = edges.block_max;
172 bounds = indexes_dd.template map<shammath::AABB<TgridVec>>([&](
u64 id,
auto &merged) {
173 TgridVec min_bound = block_min.get_field(
id).compute_min();
174 TgridVec max_bound = block_max.get_field(
id).compute_max();
182 = indexes_dd.template map<RTree>([&](
u64 id,
auto &merged) {
183 shamlog_debug_ln(
"AMR",
"compute tree for merged patch",
id);
185 auto aabb = bounds.
get(
id);
187 TgridVec bmin = aabb.lower;
188 TgridVec bmax = aabb.upper;
190 TgridVec diff = bmax - bmin;
196 auto &field_pos = block_min.get_field(
id);
199 shamsys::instance::get_compute_scheduler_ptr(),
202 field_pos.get_obj_cnt(),
209 tree.compute_cell_ibounding_box(shamsys::instance::get_compute_queue());
212 trees.for_each([](
u64 id,
RTree &tree) {
213 tree.convert_bounding_box(shamsys::instance::get_compute_queue());
216 trees.for_each([&](
u64 id,
RTree &tree) {
217 __internal_correct_tree_bb(
218 tree, block_min.get_field(
id).get_buf(), block_max.get_field(
id).get_buf());
221 edges.trees.trees = std::move(trees);
224 template<
class Umorton,
class Tgr
idVec>
227 std::string sizes = get_ro_edge_base(0).get_tex_symbol();
228 std::string block_min = get_ro_edge_base(1).get_tex_symbol();
229 std::string block_max = get_ro_edge_base(2).get_tex_symbol();
230 std::string trees = get_rw_edge_base(0).get_tex_symbol();
232 std::string tex = R
"tex(
236 {trees}_{\rm patch} &= RadixTree(\{{block_min}_{\rm patch}\}_{\Omega_i}, \{{block_max}_{\rm patch}\}_{\Omega_i}) \\
237 {\Omega_i} &= [0, {sizes}_{\rm patch} )