Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
ExchangeGhostLayer.cpp
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
25
27 auto edges = get_edges();
28
29 // outputs
30 auto &ghost_layer = edges.ghost_layer;
31 const shamrock::solvergraph::RankGetter &rank_owner = edges.rank_owner;
32
34
35 shamalgs::collective::serialize_sparse_comm<shamrock::patch::PatchDataLayer>(
36 shamsys::instance::get_compute_scheduler_ptr(),
37 std::move(ghost_layer.patchdatas),
38 recv_dat,
39 [&](u64 id) {
40 return rank_owner.get_rank_owner(id);
41 },
43 shamalgs::SerializeHelper ser(shamsys::instance::get_compute_scheduler_ptr());
44 ser.allocate(pdat.serialize_buf_byte_size());
45 pdat.serialize_buf(ser);
46 return ser.finalize();
47 },
48 [&](sham::DeviceBuffer<u8> &&buf) {
49 // exchange the buffer held by the distrib data and give it to the serializer
50 shamalgs::SerializeHelper ser(
51 shamsys::instance::get_compute_scheduler_ptr(),
52 std::forward<sham::DeviceBuffer<u8>>(buf));
53 return shamrock::patch::PatchDataLayer::deserialize_buf(ser, ghost_layer_layout);
54 },
55 cache);
56
57 ghost_layer.patchdatas = std::move(recv_dat);
58}
59
61 auto rank_owner = get_ro_edge_base(0).get_tex_symbol();
62 auto ghost_layer = get_rw_edge_base(0).get_tex_symbol();
63
64 std::string tex = R"tex(
65 Exchange ghost layer data between distributed processes
66
67 \begin{align}
68 {ghost_layer}_{i \rightarrow \underline{j}} = \text{Sparse comm}({ghost_layer}_{\underline{i} \rightarrow j}) \\
69 \text{where } {rank_owner}_{\underline{j}} = \text{MPI world rank} \\
70 \text{and } {rank_owner}_{\underline{i}} = \text{MPI world rank} \\
71 \text{and } i \in [0, N_{\rm patch}] \\
72 \text{and } j \in [0, N_{\rm patch}] \\
73 \end{align},
74 underlined indices denotes one that currently owned by the local process.
75 )tex";
76
77 shambase::replace_all(tex, "{rank_owner}", rank_owner);
78 shambase::replace_all(tex, "{ghost_layer}", ghost_layer);
79
80 return tex;
81}
Solver graph node for exchanging ghost layer data between distributed processes.
std::uint64_t u64
64 bit unsigned integer
A buffer allocated in USM (Unified Shared Memory)
Container for objects shared between two distributed data elements.
PatchDataLayer container class, the layout is described in patchdata_layout.
virtual std::string _impl_get_tex() const
Returns the TeX representation for this node.
void _impl_evaluate_internal()
Performs the ghost layer data exchange computation.
void replace_all(std::string &inout, std::string_view what, std::string_view with)
replace all occurence of a search string with another
Definition string.hpp:183