50template<
class Tvec,
template<
class>
class SPHKernel>
51inline std::shared_ptr<shammodels::sph::modules::ISPHSetupNode> shammodels::sph::modules::
52 SPHSetup<Tvec, SPHKernel>::make_generator_lattice_hcp(
53 Tscal dr, std::pair<Tvec, Tvec> box,
bool discontinuous, Tscal init_h_factor) {
55 return std::shared_ptr<ISPHSetupNode>(
56 new GeneratorLatticeHCP<Tvec, true>(context, dr, box, init_h_factor));
58 return std::shared_ptr<ISPHSetupNode>(
59 new GeneratorLatticeHCP<Tvec, false>(context, dr, box, init_h_factor));
63template<
class Tvec,
template<
class>
class SPHKernel>
64inline std::shared_ptr<shammodels::sph::modules::ISPHSetupNode> shammodels::sph::modules::
65 SPHSetup<Tvec, SPHKernel>::make_generator_lattice_fcc(
66 Tscal dr, std::pair<Tvec, Tvec> box,
bool discontinuous, Tscal init_h_factor) {
68 return std::shared_ptr<ISPHSetupNode>(
69 new GeneratorLatticeFCC<Tvec, true>(context, dr, box, init_h_factor));
71 return std::shared_ptr<ISPHSetupNode>(
72 new GeneratorLatticeFCC<Tvec, false>(context, dr, box, init_h_factor));
76template<
class Tvec,
template<
class>
class SPHKernel>
77inline std::shared_ptr<shammodels::sph::modules::ISPHSetupNode> shammodels::sph::modules::
78 SPHSetup<Tvec, SPHKernel>::make_generator_lattice_cubic(Tscal dr, std::pair<Tvec, Tvec> box) {
79 return std::shared_ptr<ISPHSetupNode>(
new GeneratorLatticeCubic<Tvec>(context, dr, box));
82template<
class Tvec,
template<
class>
class SPHKernel>
83inline std::shared_ptr<shammodels::sph::modules::ISPHSetupNode> shammodels::sph::modules::
84 SPHSetup<Tvec, SPHKernel>::make_generator_disc_mc(
89 std::function<Tscal(Tscal)> sigma_profile,
90 std::function<Tscal(Tscal)> H_profile,
91 std::function<Tvec(Tvec)> vel_profile,
92 std::function<Tscal(Tvec)> cs_profile,
94 Tscal init_h_factor) {
95 return std::shared_ptr<ISPHSetupNode>(
new GeneratorMCDisc<Tvec, SPHKernel>(
110template<
class Tvec,
template<
class>
class SPHKernel>
111inline std::shared_ptr<shammodels::sph::modules::ISPHSetupNode> shammodels::sph::modules::
112 SPHSetup<Tvec, SPHKernel>::make_generator_from_context(
ShamrockCtx &context_other) {
113 return std::shared_ptr<ISPHSetupNode>(
114 new GeneratorFromOtherContext<Tvec>(context, context_other));
117template<
class Tvec,
template<
class>
class SPHKernel>
118inline std::shared_ptr<shammodels::sph::modules::ISPHSetupNode> shammodels::sph::modules::
119 SPHSetup<Tvec, SPHKernel>::make_combiner_add(SetupNodePtr parent1, SetupNodePtr parent2) {
120 return std::shared_ptr<ISPHSetupNode>(
new CombinerAdd<Tvec>(context, parent1, parent2));
123template<
class Tvec,
template<
class>
class SPHKernel>
124void shammodels::sph::modules::SPHSetup<Tvec, SPHKernel>::apply_setup(
125 SetupNodePtr setup,
bool part_reordering, std::optional<u32> insert_step) {
137 auto compute_load = [&]() {
138 modules::ComputeLoadBalanceValue<Tvec, SPHKernel>(context, solver_config, storage)
139 .update_load_balancing();
142 auto has_pdat = [&]() {
144 using namespace shamrock::patch;
153 if (
bool(insert_step)) {
154 _insert_step = insert_step.value();
157 while (!setup->is_done()) {
161 if (solver_config.track_particles_id) {
172 &loc_inj, &offset_init, 1, get_mpi_type<u64>(), MPI_SUM, MPI_COMM_WORLD);
179 offset_init += injected_parts;
181 auto dev_sched = shamsys::instance::get_compute_scheduler_ptr();
192 [offset_init](
u32 i,
u64 *__restrict part_ids) {
193 part_ids[i] = i + offset_init;
196 pdat.get_field<
u64>(pdat.pdl().get_field_idx<u64>(
"part_id"))
197 .overwrite(part_ids, loc_inj);
202 = inserter.push_patch_data<Tvec>(pdat,
"xyz", sched.
crit_patch_split * 8, compute_load);
204 injected_parts += injected;
207 u32 final_balancing_steps = 3;
208 for (
u32 i = 0; i < final_balancing_steps; i++) {
211 "SPH setup",
"Final load balancing step", i,
"of", final_balancing_steps));
212 inserter.balance_load(compute_load);
215 if (part_reordering) {
216 modules::ParticleReordering<Tvec, u32, SPHKernel>(context, solver_config, storage)
217 .reorder_particles();
228 std::vector<u64> count_per_rank;
229 std::vector<std::tuple<u32, u32, u64>> msg_list;
232 u64 step_counter = 0;
234 nlohmann::json json_data = nlohmann::json::array();
237 nlohmann::json step_data;
238 step_data[
"step_counter"] = step_counter;
239 step_data[
"count_per_rank"] = state.count_per_rank;
240 step_data[
"msg_list"] = state.msg_list;
241 json_data.push_back(step_data);
245 std::string fname =
"setup_log_step.json";
250 std::ofstream file(fname);
251 file << json_data.dump(4);
257 void update_count_per_rank(
u64 count) {
258 std::vector<u64> tmp{count};
259 std::vector<u64> recv_count_per_rank;
261 state.count_per_rank = recv_count_per_rank;
263 if (step_counter % 20 == 0)
267 void update_msg_list(std::vector<std::tuple<u32, u32, u64>> &msg_list) {
268 state.msg_list = msg_list;
270 if (step_counter % 20 == 0)
275inline constexpr f64 golden_number = 1.61803398874989484820458683436563;
277template<
class Tvec,
template<
class>
class SPHKernel>
278void shammodels::sph::modules::SPHSetup<Tvec, SPHKernel>::apply_setup_new(
280 bool part_reordering,
281 std::optional<u32> gen_count_per_step,
282 std::optional<u32> insert_count_per_step,
283 std::optional<u64> max_msg_count_per_rank_per_step,
284 std::optional<u64> max_data_count_per_rank_per_step,
285 std::optional<u64> max_msg_size,
287 bool speculative_balancing) {
295 std::optional<SetupLog> setup_log
296 = (do_setup_log) ? std::make_optional<SetupLog>() : std::nullopt;
304 if (
bool(insert_count_per_step)) {
305 insert_step = insert_count_per_step.value();
309 if (
bool(gen_count_per_step)) {
310 gen_step = gen_count_per_step.value();
313 u64 msg_limit = 1024;
314 if (
bool(max_msg_count_per_rank_per_step)) {
315 msg_limit = max_msg_count_per_rank_per_step.value();
317 u64 data_count_limit = insert_step;
318 if (
bool(max_data_count_per_rank_per_step)) {
319 data_count_limit = max_data_count_per_rank_per_step.value();
321 u64 max_message_size = std::max(insert_step / 16, 1_u32);
322 if (
bool(max_msg_size)) {
323 max_message_size = max_msg_size.value();
328 u64 speculative_last_npatch = 0;
331 auto compute_load = [&]() {
332 if (speculative_balancing) {
336 auto dev_sched = shamsys::instance::get_compute_scheduler_ptr();
338 u64 npatch = scheduler().patch_list.global.size();
341 if (npatch != speculative_last_npatch) {
348 "number of patches has changed, rebuilding speculative load values");
352 speculative_last_npatch = npatch;
353 speculative_load_values.
reset();
357 std::vector<Tvec> patch_aabb_min(npatch);
358 std::vector<Tvec> patch_aabb_max(npatch);
360 auto &global_patch_list = scheduler().patch_list.global;
364 for (
size_t i = 0; i < global_patch_list.size(); i++) {
368 patch_aabb_min[i] = patch_coord.lower;
369 patch_aabb_max[i] = patch_coord.upper;
376 buf_patch_aabb_min.copy_from_stdvec(patch_aabb_min);
377 buf_patch_aabb_max.copy_from_stdvec(patch_aabb_max);
382 local_load_values.fill(0);
386 if (
xyz.get_obj_cnt() > 0) {
388 shamsys::instance::get_compute_scheduler().get_queue(),
394 const Tvec *__restrict xyz,
395 const Tvec *__restrict patch_aabb_min,
396 const Tvec *__restrict patch_aabb_max,
397 u64 *__restrict local_load_values) {
399 for (
size_t j = 0; j < npatch; j++) {
401 = {patch_aabb_min[j], patch_aabb_max[j]};
402 if (patch_coord.contain_pos(pos)) {
405 sycl::memory_order::relaxed,
406 sycl::memory_scope::device>
407 atomic_local_load_values(local_load_values[j]);
408 atomic_local_load_values++;
416 auto local_load_values_host = local_load_values.copy_to_stdvec();
418 std::vector<u64> reduced_load_values(npatch);
423 local_load_values_host.data(),
424 reduced_load_values.data(),
432 for (
size_t i = 0; i < npatch; i++) {
433 speculative_load_values.
add_obj(
434 global_patch_list[i].id_patch,
u64(reduced_load_values[i]));
439 auto &patch_list = scheduler().patch_list;
441 for (
u64 id : scheduler().owned_patch_id) {
443 = patch_list.local[patch_list.id_patch_to_local_idx[id]];
444 speculative_load_values.
get(
id)
445 += scheduler().patch_data.owned_data.get(
id).get_obj_cnt();
456 modules::ComputeLoadBalanceValue<Tvec, SPHKernel>(context, solver_config, storage)
457 .update_load_balancing();
461 auto has_pdat = [&]() {
463 using namespace shamrock::patch;
471 time_part_gen.
start();
477 while (!setup->is_done()) {
483 if (solver_config.track_particles_id) {
494 &loc_inj, &offset_init, 1, get_mpi_type<u64>(), MPI_SUM, MPI_COMM_WORLD);
501 offset_init += injected_parts;
503 auto dev_sched = shamsys::instance::get_compute_scheduler_ptr();
514 [offset_init](
u32 i,
u64 *__restrict part_ids) {
515 part_ids[i] = i + offset_init;
518 tmp.get_field<
u64>(tmp.pdl().get_field_idx<u64>(
"part_id"))
519 .overwrite(part_ids, loc_inj);
523 to_insert.insert_elements(tmp);
525 u64 sum_push = shamalgs::collective::allreduce_sum<u64>(tmp.
get_obj_cnt());
526 u64 sum_all = shamalgs::collective::allreduce_sum<u64>(to_insert.get_obj_cnt());
528 u64 min_rank = shamalgs::collective::allreduce_min<u64>(to_insert.get_obj_cnt());
529 u64 max_rank = shamalgs::collective::allreduce_max<u64>(to_insert.get_obj_cnt());
538 "Nstep = {} ( {:.1e} ) Ntotal = {} ( {:.1e} rank min = {:.1e} max = {:.1e}) "
539 "rate = {:e} N.s^-1",
550 setup_log.value().update_count_per_rank(to_insert.get_obj_cnt());
553 injected_parts += sum_push;
556 time_part_gen.
stop();
559 "SPH setup",
"the generation step took :", time_part_gen.
elapsed_sec(),
"s");
564 "SPH setup",
"final particle count =", injected_parts,
"beginning injection ...");
573 time_part_inject.
start();
575 auto log_inject_status = [&](std::string log_suffix =
"") {
576 u64 sum_all = shamalgs::collective::allreduce_sum<u64>(to_insert.get_obj_cnt());
578 u32 rank_without_patch
579 = shamalgs::collective::allreduce_sum<u32>(sched.
patch_list.
local.size() == 0 ? 1 : 0);
585 "injected {:12} / {:} => {:5.1f}% | ranks with patchs = {:d} / {:d} {}",
586 injected_parts - sum_all,
588 f64(injected_parts - sum_all) /
f64(injected_parts) * 100.0,
595 setup_log.value().update_count_per_rank(to_insert.get_obj_cnt());
599 auto inject_in_local_domains =
600 [&sched, &inserter, &compute_load, &insert_step, &log_inject_status](
604 bool has_been_limited =
true;
606 auto dev_sched = shamsys::instance::get_compute_scheduler_ptr();
609 while (has_been_limited) {
610 has_been_limited =
false;
611 using namespace shamrock::patch;
620 auto ids =
xyz.get_ids_where_recycle_buffer(
623 Tvec tmp = access[id];
624 return patch_coord.contain_pos(tmp);
628 if (ids.get_size() > insert_step) {
629 ids.resize(insert_step);
630 has_been_limited =
true;
633 if (ids.get_size() > 0) {
634 to_insert.extract_elements(ids, pdat);
638 sched.check_patchdata_locality_correctness();
640 inserter.balance_load(compute_load);
645 if (has_been_limited) {
647 log_inject_status(
" -> local loop <-");
652 auto get_index_per_ranks = [&](
f64 &timer_result) {
656 time_get_index_per_ranks.
start();
664 if (pos_field.get_nvar() != 1) {
668 sycl::buffer<u64> new_id_buf = sptree.compute_patch_owner(
669 shamsys::instance::get_compute_scheduler_ptr(),
671 pos_field.get_obj_cnt());
673 std::unordered_map<i32, std::vector<u32>> index_per_ranks;
674 bool err_id_in_newid =
false;
676 sycl::host_accessor nid{new_id_buf, sycl::read_only};
677 for (
u32 i = 0; i < pos_field.get_obj_cnt(); i++) {
678 u64 patch_id = nid[i];
680 err_id_in_newid = err_id_in_newid || (
err);
682 i32 rank = sched.get_patch_rank_owner(patch_id);
683 index_per_ranks[rank].push_back(i);
687 if (err_id_in_newid) {
689 "a new id could not be computed");
692 time_get_index_per_ranks.
stop();
693 timer_result = time_get_index_per_ranks.
elapsed_sec();
695 return index_per_ranks;
698 f64 total_time_rank_getter = 0;
699 f64 max_time_rank_getter = 0;
708 using namespace shamrock::patch;
710 auto dev_sched = shamsys::instance::get_compute_scheduler_ptr();
712 inject_in_local_domains(to_insert);
714 f64 timer_get_index_per_ranks = 0;
715 std::unordered_map<i32, std::vector<u32>> index_per_ranks
716 = get_index_per_ranks(timer_get_index_per_ranks);
717 total_time_rank_getter += timer_get_index_per_ranks;
718 max_time_rank_getter = std::max(max_time_rank_getter, timer_get_index_per_ranks);
722 std::vector<u64> send_msg;
723 for (
auto &[rank, indices] : index_per_ranks) {
725 send_msg.push_back(indices.size());
729 bool sync_limited =
false;
730 if (send_msg.size() > max_send) {
740 std::vector<tmp> tmp_vec;
741 tmp_vec.reserve(send_msg.size() / 2);
742 for (
u64 i = 0; i < send_msg.size(); i += 2) {
743 tmp_vec.push_back({send_msg[i], send_msg[i + 1]});
748 std::mt19937_64 eng_local_msg(local_seed);
749 std::shuffle(tmp_vec.begin(), tmp_vec.end(), eng_local_msg);
752 std::vector<u64> send_msg_new;
753 send_msg_new.reserve(max_send);
754 for (
auto &t : tmp_vec) {
755 if (send_msg_new.size() >= max_send) {
758 send_msg_new.push_back(t.ranks);
759 send_msg_new.push_back(t.size);
762 send_msg = send_msg_new;
766 std::vector<u64> recv_msg;
769 std::vector<std::tuple<u32, u32, u64>> msg_list;
770 for (
u64 i = 0; i < recv_msg.size(); i += 2) {
771 u32_2 sender_receiver = sham::unpack32(recv_msg[i]);
772 u64 indices_size = recv_msg[i + 1];
774 u32 sender_rank = sender_receiver.x();
775 u32 receiver_rank = sender_receiver.y();
777 if (sender_rank == receiver_rank) {
781 msg_list.push_back(std::make_tuple(sender_rank, receiver_rank, indices_size));
785 setup_log.value().update_msg_list(msg_list);
789 std::mt19937 eng_global_msg(
u64(golden_number * 1000 * step_count));
790 std::shuffle(msg_list.begin(), msg_list.end(), eng_global_msg);
797 std::vector<std::tuple<u32, u32, u64>> rank_msg_list;
799 bool was_count_limited =
false;
800 bool was_size_limited =
false;
801 bool was_msg_size_limited =
false;
803 for (
auto &[sender_rank, receiver_rank, indices_size] : msg_list) {
805 bool msg_count_limit_not_reached = msg_count_rank.at(receiver_rank) < msg_limit
806 && msg_count_rank.at(sender_rank) < msg_limit;
808 bool recv_size_limit_not_reached = comm_size_rank.at(receiver_rank) < data_count_limit
809 && comm_size_rank.at(sender_rank) < data_count_limit;
811 was_count_limited = was_count_limited || !msg_count_limit_not_reached;
812 was_size_limited = was_size_limited || !recv_size_limit_not_reached;
814 bool can_send_recv = msg_count_limit_not_reached && recv_size_limit_not_reached;
816 u64 msg_size = std::min(indices_size, max_message_size);
817 msg_size = std::min(msg_size, data_count_limit);
818 was_msg_size_limited = was_msg_size_limited || (msg_size < indices_size);
824 rank_msg_list.push_back(
825 std::make_tuple(sender_rank, receiver_rank, msg_size));
830 msg_count_rank.at(receiver_rank) += 1;
831 msg_count_rank.at(sender_rank) += 1;
832 comm_size_rank.at(receiver_rank) += msg_size;
833 comm_size_rank.at(sender_rank) += msg_size;
849 for (
auto &[sender_rank, receiver_rank, indices_size] : rank_msg_list) {
851 std::vector<u32> &idx_to_extract = index_per_ranks[receiver_rank];
855 if (_tmp.
get_size() > indices_size) {
856 _tmp.
resize(indices_size);
860 to_insert.append_subset_to(_tmp, _tmp.
get_size(), _tmp_pdat);
864 send_data.
add_obj(sender_rank, receiver_rank, std::move(_tmp_pdat));
868 to_insert.remove_ids(idx_to_rem, idx_to_rem.
get_size());
873 shamalgs::collective::serialize_sparse_comm<PatchDataLayer>(
875 std::move(send_data),
882 ser.allocate(pdat.serialize_buf_byte_size());
883 pdat.serialize_buf(ser);
884 return ser.finalize();
890 return PatchDataLayer::deserialize_buf(ser, sched.get_layout_ptr_old());
896 to_insert.insert_elements(pdat);
905 bool was_sync_limited
908 std::string log_suffix =
"";
909 if (was_count_limited) {
910 log_suffix +=
" (msg count limited)";
912 if (was_size_limited) {
913 log_suffix +=
" (total msg size limited)";
915 if (was_msg_size_limited) {
916 log_suffix +=
" (msg size limited)";
918 if (was_sync_limited) {
919 log_suffix +=
" (sync limited)";
921 log_suffix += sham::format(
" (msg count : {})", recv_msg.size());
922 log_inject_status(
" <- global loop ->" + log_suffix);
924 f64 worst_time_get_index_per_ranks
925 = shamalgs::collective::allreduce_max<f64>(timer_get_index_per_ranks);
931 setup_log.value().dump_state();
935 time_part_inject.
stop();
938 "SPH setup",
"the injection step took :", time_part_inject.
elapsed_sec(),
"s");
951 std::vector<f64> time_rank_getter_all_ranks
952 = shamalgs::collective::gather(total_time_rank_getter);
953 std::vector<f64> max_time_rank_getter_all_ranks
954 = shamalgs::collective::gather(max_time_rank_getter);
955 std::vector<f64> mpi_timer_all_ranks = shamalgs::collective::gather(delta_mpi_timer);
956 std::vector<f64> alloc_time_device_all_ranks = shamalgs::collective::gather(t_dev_alloc);
957 std::vector<f64> alloc_time_host_all_ranks = shamalgs::collective::gather(t_host_alloc);
958 std::vector<size_t> max_mem_device_all_ranks
960 std::vector<size_t> max_mem_host_all_ranks
967 f64 sum_time_rank_getter = std::accumulate(
968 time_rank_getter_all_ranks.begin(), time_rank_getter_all_ranks.end(), 0.0);
969 f64 max_time_rank_getter = *std::max_element(
970 max_time_rank_getter_all_ranks.begin(), max_time_rank_getter_all_ranks.end());
972 = std::accumulate(mpi_timer_all_ranks.begin(), mpi_timer_all_ranks.end(), 0.0);
973 f64 sum_alloc_device = std::accumulate(
974 alloc_time_device_all_ranks.begin(), alloc_time_device_all_ranks.end(), 0.0);
975 f64 sum_alloc_host = std::accumulate(
976 alloc_time_host_all_ranks.begin(), alloc_time_host_all_ranks.end(), 0.0);
977 size_t sum_mem_device_total = std::accumulate(
978 max_mem_device_all_ranks.begin(), max_mem_device_all_ranks.end(), 0_u64);
979 size_t sum_mem_host_total = std::accumulate(
980 max_mem_host_all_ranks.begin(), max_mem_host_all_ranks.end(), 0_u64);
982 static constexpr u32 cols_count = 6;
988 table.add_double_rule();
990 {
"rank",
"rank get (sum/max)",
"MPI",
"alloc d% h%",
"mem (max) d",
"mem (max) h"},
992 table.add_double_rule();
995 {sham::format(
"{:<4}", i),
998 time_rank_getter_all_ranks[i],
999 max_time_rank_getter_all_ranks[i]),
1000 sham::format(
"{:.2f}s", mpi_timer_all_ranks[i]),
1002 "{:>.1f}% {:<.1f}%",
1003 100 * (alloc_time_device_all_ranks[i] / time_part_inject_sec),
1004 100 * (alloc_time_host_all_ranks[i] / time_part_inject_sec)),
1010 table.add_rulled_data({
"",
"<avg> / <max>",
"<avg>",
"<avg>",
"<sum>",
"<sum>"});
1014 "{:.2f}s / {:.2f}s",
1016 max_time_rank_getter),
1019 "{:>.1f}% {:<.1f}%",
1020 100 * (sum_alloc_device / sum_t),
1021 100 * (sum_alloc_host / sum_t)),
1027 logger::info_ln(
"SPH setup",
"injection perf report:" + table.render());
1031 if (part_reordering) {
1032 modules::ParticleReordering<Tvec, u32, SPHKernel>(context, solver_config, storage)
1033 .reorder_particles();
1042template<
class Tvec,
template<
class>
class SPHKernel>
1043inline std::shared_ptr<shammodels::sph::modules::ISPHSetupNode> shammodels::sph::modules::
1044 SPHSetup<Tvec, SPHKernel>::make_modifier_warp_disc(
1045 SetupNodePtr parent, Tscal Rwarp, Tscal Hwarp, Tscal inclination, Tscal posangle) {
1046 return std::shared_ptr<ISPHSetupNode>(
new ModifierApplyDiscWarp<Tvec, SPHKernel>(
1047 context, solver_config, parent, Rwarp, Hwarp, inclination, posangle));
1050template<
class Tvec,
template<
class>
class SPHKernel>
1051inline std::shared_ptr<shammodels::sph::modules::ISPHSetupNode> shammodels::sph::modules::
1052 SPHSetup<Tvec, SPHKernel>::make_modifier_custom_warp(
1053 SetupNodePtr parent,
1054 std::function<Tscal(Tscal)> inc_profile,
1055 std::function<Tscal(Tscal)> psi_profile,
1056 std::function<Tvec(Tscal)> k_profile) {
1057 return std::shared_ptr<ISPHSetupNode>(
new ModifierApplyCustomWarp<Tvec, SPHKernel>(
1058 context, solver_config, parent, inc_profile, psi_profile, k_profile));
1061template<
class Tvec,
template<
class>
class SPHKernel>
1062inline std::shared_ptr<shammodels::sph::modules::ISPHSetupNode> shammodels::sph::modules::
1063 SPHSetup<Tvec, SPHKernel>::make_modifier_add_offset(
1064 SetupNodePtr parent, Tvec offset_postion, Tvec offset_velocity) {
1066 return std::shared_ptr<ISPHSetupNode>(
1067 new ModifierOffset<Tvec>(context, parent, offset_postion, offset_velocity));
1070template<
class Tvec,
template<
class>
class SPHKernel>
1073 SPHKernel>::make_modifier_filter(SetupNodePtr parent, std::function<
bool(Tvec)> filter) {
1075 return std::shared_ptr<ISPHSetupNode>(
1076 new ModifierFilter<Tvec, SPHKernel>(context, parent, filter));
1079template<
class Tvec,
template<
class>
class SPHKernel>
1080inline std::shared_ptr<shammodels::sph::modules::ISPHSetupNode> shammodels::sph::modules::
1081 SPHSetup<Tvec, SPHKernel>::make_modifier_split_part(
1082 SetupNodePtr parent,
u64 n_split,
u64 seed, Tscal h_scaling) {
1083 return std::shared_ptr<ISPHSetupNode>(
1084 new ModifierSplitPart<Tvec>(context, parent, n_split, seed, h_scaling));
constexpr const char * xyz
Position field (3D coordinates).
SPH setup generator placing particles on a cubic lattice.
SPH setup generator placing particles on a HCP lattice.
Header file describing a Node Instance.
double f64
Alias for double.
std::uint32_t u32
32 bit unsigned integer
std::uint64_t u64
64 bit unsigned integer
std::int32_t i32
32 bit integer
Collective boolean reduction to check if all ranks have true as input.
bool are_all_rank_true(bool input, MPI_Comm comm)
return true only if all ranks have true as input
u64 crit_patch_split
splitting limit (if load value > crit_patch_split => patch split)
SchedulerPatchList patch_list
handle the list of the patches of the scheduler
std::vector< shamrock::patch::Patch > local
contain the list of patch owned by the current node
A buffer allocated in USM (Unified Shared Memory).
void copy_from_stdvec(const std::vector< T > &vec)
Copy the content of a std::vector into the buffer.
void resize(size_t new_size, bool keep_data=true)
Resizes the buffer to a given size.
void append(const DeviceBuffer &other)
Append the content of another buffer to this one.
size_t get_size() const
Gets the number of elements in the buffer.
Container for objects shared between two distributed data elements.
void for_each(std::function< void(u64, u64, T &)> &&f)
Apply a function to all stored objects.
iterator add_obj(u64 left_id, u64 right_id, T &&obj)
Add an object associated with a patch pair.
Represents a collection of objects distributed across patches identified by a u64 id.
iterator add_obj(u64 id, T &&obj)
Adds a new object to the collection.
T & get(u64 id)
Returns a reference to an object in the collection.
void reset()
Reset the collection to its initial state.
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.
Class to insert data in the PatchScheduler.
PatchDataLayer container class, the layout is described in patchdata_layout.
u32 get_obj_cnt() const
get the number of objects (particles) stored in this layer
PatchCoordTransform< T > get_patch_transform() const
Get a PatchCoordTransform object that describes the conversion between patch coordinates and domain c...
std::vector< int > vector_allgatherv(const std::vector< T > &send_vec, const MPI_Datatype &send_type, std::vector< T > &recv_vec, const MPI_Datatype &recv_type, const MPI_Comm comm)
allgatherv on vector with size query (size querying variant of vector_allgatherv_ks) //TODO add fault...
MemPerfInfos get_mem_perf_info()
Retrieve the memory performance information.
Boolean reduction algorithm for checking if all elements are non-zero.
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.
std::string readable_sizeof(double size)
given a sizeof value return a readble string Example : readable_sizeof(1e9) -> "1....
void throw_with_loc(std::string message, SourceLocation loc=SourceLocation{})
Throw an exception and append the source location to it.
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...
ExcptTypes make_except_with_loc(std::string message, SourceLocation loc=SourceLocation{})
Create an exception with a message and a location.
void throw_unimplemented(SourceLocation loc=SourceLocation{})
Throw a std::runtime_error saying that the function is unimplemented.
i32 world_rank()
Gives the rank of the current process in the MPI communicator.
i32 world_size()
Gives the size of the MPI communicator.
namespace for math utility
constexpr u64 u64_max
u64 max value
void normal_ln(std::string module_name, Types... var2)
Prints a log message with multiple arguments followed by a newline.
void info_ln(std::string module_name, Types... var2)
Prints a log message with multiple arguments followed by a newline.
void err(std::string module_name, Types... var2)
Prints a log message with multiple arguments.
#define __shamrock_stack_entry()
Macro to create a stack entry.
shambase::details::BasicStackEntry StackEntry
Alias for shambase::details::BasicStackEntry.
Structure to store the performance informations about memory allocation and deallocation.
f64 time_alloc_host
Time spent allocating memory on the host.
size_t max_allocated_byte_host
max bytes allocated on the host
f64 time_free_device
Time spent deallocating memory on the device.
size_t max_allocated_byte_device
max bytes allocated on the device
f64 time_alloc_device
Time spent allocating memory on the device.
f64 time_free_host
Time spent deallocating memory on the host.
A class that references multiple buffers or similar objects.
Patch object that contain generic patch information.
bool is_err_mode() const
check if a patch is in error mode
u64 id_patch
unique key that identify the patch
Functions related to the MPI communicator.
#define ON_RANK_0(x)
Macro to execute code only on rank 0.
void Exscan(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
MPI wrapper for MPI_Exscan.
void Barrier(MPI_Comm comm)
MPI wrapper for MPI_Barrier.
f64 get_timer(std::string timername)
get a timer value
void Allreduce(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
MPI wrapper for MPI_Allreduce.