30template<
class Tvec,
class Tmorton,
template<
class>
class SPHKernel>
31void shammodels::sph::modules::NeighbourCache<Tvec, Tmorton, SPHKernel>::start_neighbors_cache() {
34 using GhostHandle = sph::BasicSPHGhostHandler<Tvec>;
35 using GhostHandleCache =
typename GhostHandle::CacheMap;
44 auto build_neigh_cache = [&](
u64 patch_id) {
45 shamlog_debug_ln(
"BasicSPH",
"build particle cache id =", patch_id);
49 auto &mfield = storage.merged_xyzh.get().get(patch_id);
55 = storage.rtree_rint_field.get().get(patch_id).buf_field;
57 RTree &tree = storage.merged_pos_trees.get().get(patch_id);
58 auto obj_it = tree.get_object_iterator();
62 sycl::range range_npart{obj_cnt};
64 Tscal h_tolerance = solver_config.htol_up_coarse_cycle;
73 obj_cnt, shamsys::instance::get_compute_scheduler_ptr());
75 shamlog_debug_sycl_ln(
"Cache",
"generate cache for N=", obj_cnt);
83 const Tvec *__restrict
xyz,
84 const Tscal *__restrict
hpart,
85 const Tscal *__restrict rint_tree,
87 u32 *__restrict neigh_cnt) {
88 constexpr Tscal Rker2 = Kernel::Rkern * Kernel::Rkern;
90 Tscal rint_a =
hpart[id_a] * h_tolerance;
92 Tvec xyz_a =
xyz[id_a];
94 Tvec inter_box_a_min = xyz_a - rint_a * Kernel::Rkern;
95 Tvec inter_box_a_max = xyz_a + rint_a * Kernel::Rkern;
99 particle_looper.rtree_for(
101 Tscal int_r_max_cell = rint_tree[node_id] * Kernel::Rkern;
103 using namespace walker::interaction_crit;
105 return sph_radix_cell_crit(
115 Tvec dr = xyz_a -
xyz[id_b];
116 Tscal rab2 = sycl::dot(dr, dr);
117 Tscal rint_b =
hpart[id_b] * h_tolerance;
120 = rab2 > rint_a * rint_a * Rker2 && rab2 > rint_b * rint_b * Rker2;
122 cnt += (no_interact) ? 0 : 1;
125 neigh_cnt[id_a] = cnt;
128 tree::ObjectCache pcache = tree::prepare_object_cache(std::move(neigh_count), obj_cnt);
133 sham::MultiRef{buf_xyz, buf_hpart, tree_field_rint, pcache.scanned_cnt, obj_it},
138 const Tvec *__restrict
xyz,
139 const Tscal *__restrict
hpart,
140 const Tscal *__restrict rint_tree,
141 const u32 *__restrict scanned_neigh_cnt,
142 auto particle_looper,
143 u32 *__restrict neigh) {
144 constexpr Tscal Rker2 = Kernel::Rkern * Kernel::Rkern;
146 Tscal rint_a =
hpart[id_a] * h_tolerance;
148 Tvec xyz_a =
xyz[id_a];
150 Tvec inter_box_a_min = xyz_a - rint_a * Kernel::Rkern;
151 Tvec inter_box_a_max = xyz_a + rint_a * Kernel::Rkern;
153 u32 cnt = scanned_neigh_cnt[id_a];
155 particle_looper.rtree_for(
157 Tscal int_r_max_cell = rint_tree[node_id] * Kernel::Rkern;
159 using namespace walker::interaction_crit;
161 return sph_radix_cell_crit(
171 Tvec dr = xyz_a -
xyz[id_b];
172 Tscal rab2 = sycl::dot(dr, dr);
173 Tscal rint_b =
hpart[id_b] * h_tolerance;
176 = rab2 > rint_a * rint_a * Rker2 && rab2 > rint_b * rint_b * Rker2;
181 cnt += (no_interact) ? 0 : 1;
190 using namespace shamrock::patch;
193 ncache.neigh_cache.add_obj(cur_p.
id_patch, build_neigh_cache(cur_p.
id_patch));
197 storage.timings_details.neighbors += time_neigh.
elapsed_sec();
200template<
class Tvec,
class Tmorton,
template<
class>
class SPHKernel>
205 using GhostHandle = sph::BasicSPHGhostHandler<Tvec>;
206 using GhostHandleCache =
typename GhostHandle::CacheMap;
215 auto build_neigh_cache = [&](
u64 patch_id) {
216 shamlog_debug_ln(
"BasicSPH",
"build particle cache id =", patch_id);
220 auto &mfield = storage.merged_xyzh.get().get(patch_id);
226 = storage.rtree_rint_field.get().get(patch_id).buf_field;
228 RTree &tree = storage.merged_pos_trees.get().get(patch_id);
229 auto obj_it = tree.get_object_iterator();
232 u32 tree_depth = tree.get_exact_tree_depth();
233 u32 stack_size = tree_depth + 1;
239 sycl::range range_npart{obj_cnt};
241 Tscal h_tolerance = solver_config.htol_up_coarse_cycle;
250 obj_cnt, shamsys::instance::get_compute_scheduler_ptr());
252 shamlog_debug_sycl_ln(
"Cache",
"generate cache for N=", obj_cnt);
253 sham::kernel_call_hndl(
258 [h_tolerance, stack_size](
260 const Tvec *__restrict
xyz,
261 const Tscal *__restrict
hpart,
262 const Tscal *__restrict rint_tree,
263 auto particle_looper,
264 u32 *__restrict neigh_cnt) {
265 return [=](sycl::handler &cgh) {
266 constexpr Tscal Rker2 = Kernel::Rkern * Kernel::Rkern;
267 constexpr u32 group_size = 256;
269 sycl::local_accessor<u32, 1> stack_local(stack_size * group_size, cgh);
272 u32 id_a = (
u32) item.get_global_linear_id();
278 u32 group_id = (
u32) item.get_local_id(0);
279 u32 *stack_ptr = &stack_local[group_id * stack_size];
280 auto stack_id = [&stack_ptr](
u32 id) ->
u32 &{
281 return stack_ptr[id];
284 Tscal rint_a =
hpart[id_a] * h_tolerance;
286 Tvec xyz_a =
xyz[id_a];
288 Tvec inter_box_a_min = xyz_a - rint_a * Kernel::Rkern;
289 Tvec inter_box_a_max = xyz_a + rint_a * Kernel::Rkern;
293 particle_looper.rtree_for(
297 Tscal int_r_max_cell = rint_tree[node_id] * Kernel::Rkern;
299 using namespace walker::interaction_crit;
301 return sph_radix_cell_crit(
311 Tvec dr = xyz_a -
xyz[id_b];
312 Tscal rab2 = sycl::dot(dr, dr);
313 Tscal rint_b =
hpart[id_b] * h_tolerance;
315 bool no_interact = rab2 > rint_a * rint_a * Rker2
316 && rab2 > rint_b * rint_b * Rker2;
318 cnt += (no_interact) ? 0 : 1;
321 neigh_cnt[id_a] = cnt;
326 tree::ObjectCache pcache = tree::prepare_object_cache(std::move(neigh_count), obj_cnt);
329 sham::kernel_call_hndl(
331 sham::MultiRef{buf_xyz, buf_hpart, tree_field_rint, pcache.scanned_cnt, obj_it},
334 [h_tolerance, stack_size](
336 const Tvec *__restrict
xyz,
337 const Tscal *__restrict
hpart,
338 const Tscal *__restrict rint_tree,
339 const u32 *__restrict scanned_neigh_cnt,
340 auto particle_looper,
341 u32 *__restrict neigh) {
342 return [=](sycl::handler &cgh) {
343 constexpr Tscal Rker2 = Kernel::Rkern * Kernel::Rkern;
344 constexpr u32 group_size = 256;
346 sycl::local_accessor<u32, 1> stack_local(stack_size * group_size, cgh);
349 u32 id_a = (
u32) item.get_global_linear_id();
355 u32 group_id = (
u32) item.get_local_id(0);
356 u32 *stack_ptr = &stack_local[group_id * stack_size];
357 auto stack_id = [&stack_ptr](
u32 id) ->
u32 &{
358 return stack_ptr[id];
361 Tscal rint_a =
hpart[id_a] * h_tolerance;
363 Tvec xyz_a =
xyz[id_a];
365 Tvec inter_box_a_min = xyz_a - rint_a * Kernel::Rkern;
366 Tvec inter_box_a_max = xyz_a + rint_a * Kernel::Rkern;
368 u32 cnt = scanned_neigh_cnt[id_a];
370 particle_looper.rtree_for(
374 Tscal int_r_max_cell = rint_tree[node_id] * Kernel::Rkern;
376 using namespace walker::interaction_crit;
378 return sph_radix_cell_crit(
388 Tvec dr = xyz_a -
xyz[id_b];
389 Tscal rab2 = sycl::dot(dr, dr);
390 Tscal rint_b =
hpart[id_b] * h_tolerance;
392 bool no_interact = rab2 > rint_a * rint_a * Rker2
393 && rab2 > rint_b * rint_b * Rker2;
398 cnt += (no_interact) ? 0 : 1;
409 using namespace shamrock::patch;
412 ncache.neigh_cache.add_obj(cur_p.
id_patch, build_neigh_cache(cur_p.
id_patch));
416 storage.timings_details.neighbors += time_neigh.
elapsed_sec();
419template<
class Tvec,
class Tmorton,
template<
class>
class SPHKernel>
424 using GhostHandle = sph::BasicSPHGhostHandler<Tvec>;
425 using GhostHandleCache =
typename GhostHandle::CacheMap;
434 auto build_neigh_cache = [&](
u64 patch_id) {
435 shamlog_debug_ln(
"BasicSPH",
"build particle cache id =", patch_id);
439 auto &mfield = storage.merged_xyzh.get().get(patch_id);
445 = storage.rtree_rint_field.get().get(patch_id).buf_field;
447 RTree &tree = storage.merged_pos_trees.get().get(patch_id);
448 auto obj_it = tree.get_object_iterator();
449 auto leaf_it = tree.get_traverser();
451 u32 leaf_cnt = tree.get_leaf_cell_count();
452 u32 intnode_cnt = tree.get_internal_cell_count();
456 sycl::range range_nleaf{leaf_cnt};
457 sycl::range range_nobj{obj_cnt};
462 Tscal h_tolerance = solver_config.htol_up_coarse_cycle;
469 leaf_cnt, shamsys::instance::get_compute_scheduler_ptr());
471 shamlog_debug_sycl_ln(
"Cache",
"generate cache for Nleaf=", leaf_cnt);
480 const Tscal *__restrict rint_tree,
482 u32 *__restrict neigh_cnt) {
483 u32 offset_leaf = intnode_cnt;
485 Tscal leaf_a_rint = rint_tree[offset_leaf + id_a] * Kernel::Rkern;
486 Tvec leaf_a_bmin = leaf_looper.aabb_min[offset_leaf + id_a];
487 Tvec leaf_a_bmax = leaf_looper.aabb_max[offset_leaf + id_a];
488 Tvec leaf_a_bmin_ext = leaf_a_bmin - leaf_a_rint;
489 Tvec leaf_a_bmax_ext = leaf_a_bmax + leaf_a_rint;
493 leaf_looper.rtree_for(
495 Tscal int_r_max_cell = rint_tree[node_id] * Kernel::Rkern;
497 Tvec ext_bmin = node_aabb.
lower - int_r_max_cell;
498 Tvec ext_bmax = node_aabb.
upper + int_r_max_cell;
500 return BBAA::cella_neigh_b(leaf_a_bmin, leaf_a_bmax, ext_bmin, ext_bmax)
501 || BBAA::cella_neigh_b(
511 neigh_cnt[id_a] = cnt;
531 = tree::prepare_object_cache(std::move(neigh_count_leaf), leaf_cnt);
539 sham::MultiRef{tree_field_rint, pleaf_cache.scanned_cnt, leaf_it},
544 const Tscal *__restrict rint_tree,
545 const u32 *__restrict scanned_neigh_cnt,
547 u32 *__restrict neigh) {
548 u32 offset_leaf = intnode_cnt;
550 Tscal leaf_a_rint = rint_tree[offset_leaf + id_a] * Kernel::Rkern;
551 Tvec leaf_a_bmin = leaf_looper.aabb_min[offset_leaf + id_a];
552 Tvec leaf_a_bmax = leaf_looper.aabb_max[offset_leaf + id_a];
553 Tvec leaf_a_bmin_ext = leaf_a_bmin - leaf_a_rint;
554 Tvec leaf_a_bmax_ext = leaf_a_bmax + leaf_a_rint;
556 u32 cnt = scanned_neigh_cnt[id_a];
558 leaf_looper.rtree_for(
560 Tscal int_r_max_cell = rint_tree[node_id] * Kernel::Rkern;
562 Tvec ext_bmin = node_aabb.
lower - int_r_max_cell;
563 Tvec ext_bmax = node_aabb.
upper + int_r_max_cell;
565 return BBAA::cella_neigh_b(leaf_a_bmin, leaf_a_bmax, ext_bmin, ext_bmax)
566 || BBAA::cella_neigh_b(
580 obj_cnt, shamsys::instance::get_compute_scheduler_ptr());
588 u32 id_a,
const Tvec *__restrict
xyz,
auto leaf_looper,
u32 *__restrict found_id) {
589 u32 offset_leaf = intnode_cnt;
591 Tvec r_a =
xyz[id_a];
596 leaf_looper.rtree_for(
598 return BBAA::is_coord_in_range_incl_max(
602 found_id_ = leaf_b - offset_leaf;
607 found_id[id_a] = found_id_;
623 obj_cnt, shamsys::instance::get_compute_scheduler_ptr());
625 shamlog_debug_sycl_ln(
"Cache",
"generate cache for N=", obj_cnt);
629 sham::MultiRef{buf_xyz, buf_hpart, pleaf_cache, obj_it.cell_iterator, leaf_part_id},
632 [intnode_cnt, h_tolerance](
634 const Tvec *__restrict
xyz,
635 const Tscal *__restrict
hpart,
636 auto acc_neigh_leaf_looper,
637 auto particle_looper,
638 const u32 *__restrict leaf_owner,
639 u32 *__restrict neigh_cnt) {
642 u32 offset_leaf = intnode_cnt;
644 constexpr Tscal Rker2 = Kernel::Rkern * Kernel::Rkern;
646 Tscal rint_a =
hpart[id_a] * h_tolerance;
648 Tvec xyz_a =
xyz[id_a];
652 u32 leaf_own_a = leaf_owner[id_a];
654 neigh_leaf_looper.for_each_object(leaf_own_a, [&](
u32 leaf_b) {
657 particle_looper.for_each_in_leaf_cell(leaf_b - offset_leaf, [&](
u32 id_b) {
658 Tvec dr = xyz_a -
xyz[id_b];
659 Tscal rab2 = sycl::dot(dr, dr);
660 Tscal rint_b =
hpart[id_b] * h_tolerance;
663 = rab2 > rint_a * rint_a * Rker2 && rab2 > rint_b * rint_b * Rker2;
665 cnt += (no_interact) ? 0 : 1;
669 neigh_cnt[id_a] = cnt;
672 tree::ObjectCache pcache = tree::prepare_object_cache(std::move(neigh_count), obj_cnt);
683 obj_it.cell_iterator,
687 [intnode_cnt, h_tolerance](
689 const Tvec *__restrict
xyz,
690 const Tscal *__restrict
hpart,
691 auto acc_neigh_leaf_looper,
692 const u32 *__restrict scanned_neigh_cnt,
693 auto particle_looper,
694 const u32 *__restrict leaf_owner,
695 u32 *__restrict neigh) {
698 u32 offset_leaf = intnode_cnt;
700 constexpr Tscal Rker2 = Kernel::Rkern * Kernel::Rkern;
702 Tscal rint_a =
hpart[id_a] * h_tolerance;
704 Tvec xyz_a =
xyz[id_a];
706 u32 cnt = scanned_neigh_cnt[id_a];
708 u32 leaf_own_a = leaf_owner[id_a];
710 neigh_leaf_looper.for_each_object(leaf_own_a, [&](
u32 leaf_b) {
713 particle_looper.for_each_in_leaf_cell(leaf_b - offset_leaf, [&](
u32 id_b) {
714 Tvec dr = xyz_a -
xyz[id_b];
715 Tscal rab2 = sycl::dot(dr, dr);
716 Tscal rint_b =
hpart[id_b] * h_tolerance;
719 = rab2 > rint_a * rint_a * Rker2 && rab2 > rint_b * rint_b * Rker2;
724 cnt += (no_interact) ? 0 : 1;
733 using namespace shamrock::patch;
736 ncache.neigh_cache.add_obj(cur_p.
id_patch, build_neigh_cache(cur_p.
id_patch));
740 storage.timings_details.neighbors += time_neigh.
elapsed_sec();
743template<
class Tvec,
class Tmorton,
template<
class>
class SPHKernel>
748 using GhostHandle = sph::BasicSPHGhostHandler<Tvec>;
749 using GhostHandleCache =
typename GhostHandle::CacheMap;
758 auto build_neigh_cache = [&](
u64 patch_id) {
759 shamlog_debug_ln(
"BasicSPH",
"build particle cache id =", patch_id);
763 auto &mfield = storage.merged_xyzh.get().get(patch_id);
769 = storage.rtree_rint_field.get().get(patch_id).buf_field;
771 RTree &tree = storage.merged_pos_trees.get().get(patch_id);
772 auto obj_it = tree.get_object_iterator();
773 auto leaf_it = tree.get_traverser();
776 u32 tree_depth = tree.get_exact_tree_depth();
777 u32 stack_size = tree_depth + 1;
781 u32 leaf_cnt = tree.get_leaf_cell_count();
782 u32 intnode_cnt = tree.get_internal_cell_count();
786 sycl::range range_nleaf{leaf_cnt};
787 sycl::range range_nobj{obj_cnt};
792 Tscal h_tolerance = solver_config.htol_up_coarse_cycle;
799 leaf_cnt, shamsys::instance::get_compute_scheduler_ptr());
801 shamlog_debug_sycl_ln(
"Cache",
"generate cache for Nleaf=", leaf_cnt);
803 sham::kernel_call_hndl(
808 [intnode_cnt, stack_size](
810 const Tscal *__restrict rint_tree,
812 u32 *__restrict neigh_cnt) {
813 return [=](sycl::handler &cgh) {
814 u32 offset_leaf = intnode_cnt;
815 constexpr u32 group_size = 256;
817 sycl::local_accessor<u32, 1> stack_local(stack_size * group_size, cgh);
820 u32 id_a = (
u32) item.get_global_linear_id();
826 u32 group_id = (
u32) item.get_local_id(0);
827 u32 *stack_ptr = &stack_local[group_id * stack_size];
828 auto stack_id = [&stack_ptr](
u32 id) ->
u32 &{
829 return stack_ptr[id];
832 Tscal leaf_a_rint = rint_tree[offset_leaf + id_a] * Kernel::Rkern;
833 Tvec leaf_a_bmin = leaf_looper.aabb_min[offset_leaf + id_a];
834 Tvec leaf_a_bmax = leaf_looper.aabb_max[offset_leaf + id_a];
835 Tvec leaf_a_bmin_ext = leaf_a_bmin - leaf_a_rint;
836 Tvec leaf_a_bmax_ext = leaf_a_bmax + leaf_a_rint;
840 leaf_looper.rtree_for(
844 Tscal int_r_max_cell = rint_tree[node_id] * Kernel::Rkern;
846 Tvec ext_bmin = node_aabb.
lower - int_r_max_cell;
847 Tvec ext_bmax = node_aabb.
upper + int_r_max_cell;
849 return BBAA::cella_neigh_b(
850 leaf_a_bmin, leaf_a_bmax, ext_bmin, ext_bmax)
851 || BBAA::cella_neigh_b(
861 neigh_cnt[id_a] = cnt;
867 = tree::prepare_object_cache(std::move(neigh_count_leaf), leaf_cnt);
873 sham::kernel_call_hndl(
875 sham::MultiRef{tree_field_rint, pleaf_cache.scanned_cnt, leaf_it},
878 [intnode_cnt, stack_size](
880 const Tscal *__restrict rint_tree,
881 const u32 *__restrict scanned_neigh_cnt,
883 u32 *__restrict neigh) {
884 return [=](sycl::handler &cgh) {
885 u32 offset_leaf = intnode_cnt;
886 constexpr u32 group_size = 256;
888 sycl::local_accessor<u32, 1> stack_local(stack_size * group_size, cgh);
891 u32 id_a = (
u32) item.get_global_linear_id();
897 u32 group_id = (
u32) item.get_local_id(0);
898 u32 *stack_ptr = &stack_local[group_id * stack_size];
899 auto stack_id = [&stack_ptr](
u32 id) ->
u32 &{
900 return stack_ptr[id];
903 Tscal leaf_a_rint = rint_tree[offset_leaf + id_a] * Kernel::Rkern;
904 Tvec leaf_a_bmin = leaf_looper.aabb_min[offset_leaf + id_a];
905 Tvec leaf_a_bmax = leaf_looper.aabb_max[offset_leaf + id_a];
906 Tvec leaf_a_bmin_ext = leaf_a_bmin - leaf_a_rint;
907 Tvec leaf_a_bmax_ext = leaf_a_bmax + leaf_a_rint;
909 u32 cnt = scanned_neigh_cnt[id_a];
911 leaf_looper.rtree_for(
915 Tscal int_r_max_cell = rint_tree[node_id] * Kernel::Rkern;
917 Tvec ext_bmin = node_aabb.
lower - int_r_max_cell;
918 Tvec ext_bmax = node_aabb.
upper + int_r_max_cell;
920 return BBAA::cella_neigh_b(
921 leaf_a_bmin, leaf_a_bmax, ext_bmin, ext_bmax)
922 || BBAA::cella_neigh_b(
938 obj_cnt, shamsys::instance::get_compute_scheduler_ptr());
940 sham::kernel_call_hndl(
945 [intnode_cnt, stack_size](
946 u32 n,
const Tvec *__restrict
xyz,
auto leaf_looper,
u32 *__restrict found_id) {
947 return [=](sycl::handler &cgh) {
948 u32 offset_leaf = intnode_cnt;
949 constexpr u32 group_size = 256;
951 sycl::local_accessor<u32, 1> stack_local(stack_size * group_size, cgh);
954 u32 id_a = (
u32) item.get_global_linear_id();
960 u32 group_id = (
u32) item.get_local_id(0);
961 u32 *stack_ptr = &stack_local[group_id * stack_size];
962 auto stack_id = [&stack_ptr](
u32 id) ->
u32 &{
963 return stack_ptr[id];
966 Tvec r_a =
xyz[id_a];
971 leaf_looper.rtree_for(
975 return BBAA::is_coord_in_range_incl_max(
979 found_id_ = leaf_b - offset_leaf;
984 found_id[id_a] = found_id_;
990 obj_cnt, shamsys::instance::get_compute_scheduler_ptr());
992 shamlog_debug_sycl_ln(
"Cache",
"generate cache for N=", obj_cnt);
996 sham::MultiRef{buf_xyz, buf_hpart, pleaf_cache, obj_it.cell_iterator, leaf_part_id},
999 [intnode_cnt, h_tolerance](
1001 const Tvec *__restrict
xyz,
1002 const Tscal *__restrict
hpart,
1003 auto acc_neigh_leaf_looper,
1004 auto particle_looper,
1005 const u32 *__restrict leaf_owner,
1006 u32 *__restrict neigh_cnt) {
1009 u32 offset_leaf = intnode_cnt;
1011 constexpr Tscal Rker2 = Kernel::Rkern * Kernel::Rkern;
1013 Tscal rint_a =
hpart[id_a] * h_tolerance;
1015 Tvec xyz_a =
xyz[id_a];
1019 u32 leaf_own_a = leaf_owner[id_a];
1021 neigh_leaf_looper.for_each_object(leaf_own_a, [&](
u32 leaf_b) {
1024 particle_looper.for_each_in_leaf_cell(leaf_b - offset_leaf, [&](
u32 id_b) {
1025 Tvec dr = xyz_a -
xyz[id_b];
1026 Tscal rab2 = sycl::dot(dr, dr);
1027 Tscal rint_b =
hpart[id_b] * h_tolerance;
1030 = rab2 > rint_a * rint_a * Rker2 && rab2 > rint_b * rint_b * Rker2;
1032 cnt += (no_interact) ? 0 : 1;
1036 neigh_cnt[id_a] = cnt;
1039 tree::ObjectCache pcache = tree::prepare_object_cache(std::move(neigh_count), obj_cnt);
1050 obj_it.cell_iterator,
1054 [intnode_cnt, h_tolerance](
1056 const Tvec *__restrict
xyz,
1057 const Tscal *__restrict
hpart,
1058 auto acc_neigh_leaf_looper,
1059 const u32 *__restrict scanned_neigh_cnt,
1060 auto particle_looper,
1061 const u32 *__restrict leaf_owner,
1062 u32 *__restrict neigh) {
1065 u32 offset_leaf = intnode_cnt;
1067 constexpr Tscal Rker2 = Kernel::Rkern * Kernel::Rkern;
1069 Tscal rint_a =
hpart[id_a] * h_tolerance;
1071 Tvec xyz_a =
xyz[id_a];
1073 u32 cnt = scanned_neigh_cnt[id_a];
1075 u32 leaf_own_a = leaf_owner[id_a];
1077 neigh_leaf_looper.for_each_object(leaf_own_a, [&](
u32 leaf_b) {
1080 particle_looper.for_each_in_leaf_cell(leaf_b - offset_leaf, [&](
u32 id_b) {
1081 Tvec dr = xyz_a -
xyz[id_b];
1082 Tscal rab2 = sycl::dot(dr, dr);
1083 Tscal rint_b =
hpart[id_b] * h_tolerance;
1086 = rab2 > rint_a * rint_a * Rker2 && rab2 > rint_b * rint_b * Rker2;
1091 cnt += (no_interact) ? 0 : 1;
1100 using namespace shamrock::patch;
1103 ncache.neigh_cache.add_obj(cur_p.
id_patch, build_neigh_cache(cur_p.
id_patch));
1107 storage.timings_details.neighbors += time_neigh.
elapsed_sec();
constexpr const char * xyz
Position field (3D coordinates).
constexpr const char * hpart
Smoothing length field.
std::uint32_t u32
32 bit unsigned integer
std::uint64_t u64
64 bit unsigned integer
Shamrock assertion utility.
#define SHAM_ASSERT(x)
Shorthand for SHAM_ASSERT_NAMED without a message.
A buffer allocated in USM (Unified Shared Memory).
A SYCL queue associated with a device and a context.
Class Timer measures the time elapsed since the timer was started.
f64 elapsed_sec() const
Converts the stored nanosecond time to a floating point representation in seconds.
void start()
Starts the timer.
void stop()
Stops the timer and stores the elapsed time in nanoseconds.
PatchDataLayer container class, the layout is described in patchdata_layout.
A Compressed Leaf Bounding Volume Hierarchy (CLBVH) for neighborhood queries.
sycl::nd_range< 1 > make_ndrange(u32 wg_size, u32 nthread)
void kernel_call(sham::DeviceQueue &q, RefIn in, RefOut in_out, u32 n, Functor &&func, SourceLocation &&callsite=SourceLocation{})
Submit a kernel to a SYCL queue.
T & get_check_ref(const std::unique_ptr< T > &ptr, SourceLocation loc=SourceLocation())
Takes a std::unique_ptr and returns a reference to the object it holds. It throws a std::runtime_erro...
namespace for math utility
namespace for the main framework
constexpr i32 i32_max
i32 max value
shambase::details::NamedBasicStackEntry NamedStackEntry
Alias for shambase::details::NamedBasicStackEntry.
shambase::details::BasicStackEntry StackEntry
Alias for shambase::details::BasicStackEntry.
A class that references multiple buffers or similar objects.
Axis-Aligned bounding box.
T lower
Lower bound of the AABB.
T upper
Upper bound of the AABB.
Patch object that contain generic patch information.
u64 id_patch
unique key that identify the patch