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
19
25
28 auto edges = get_edges();
29
30 // outputs
31 auto &ghost_layer = edges.ghost_layer;
32 const shamrock::solvergraph::RankGetter &rank_owner = edges.rank_owner;
33
35
36 shamalgs::collective::serialize_sparse_comm<shamrock::patch::PatchDataLayer>(
37 shamsys::instance::get_compute_scheduler_ptr(),
38 std::move(ghost_layer.patchdatas),
39 recv_dat,
40 [&](u64 id) {
41 return rank_owner.get_rank_owner(id);
42 },
44 shamalgs::SerializeHelper ser(shamsys::instance::get_compute_scheduler_ptr());
45 ser.allocate(pdat.serialize_buf_byte_size());
46 pdat.serialize_buf(ser);
47 return ser.finalize();
48 },
49 [&](sham::DeviceBuffer<u8> &&buf) {
50 // exchange the buffer held by the distrib data and give it to the serializer
51 shamalgs::SerializeHelper ser(
52 shamsys::instance::get_compute_scheduler_ptr(),
53 std::forward<sham::DeviceBuffer<u8>>(buf));
54 return shamrock::patch::PatchDataLayer::deserialize_buf(ser, ghost_layer_layout);
55 },
56 cache);
57
58 ghost_layer.patchdatas = std::move(recv_dat);
59}
60
62 std::string tex = R"tex(
63 Exchange ghost layer data between distributed processes
64
65 \begin{align}
66 {ghost_layer}_{i \rightarrow \underline{j}} = \text{Sparse comm}({ghost_layer}_{\underline{i} \rightarrow j}) \\
67 \text{where } {rank_owner}_{\underline{j}} = \text{MPI world rank} \\
68 \text{and } {rank_owner}_{\underline{i}} = \text{MPI world rank} \\
69 \text{and } i \in [0, N_{\rm patch}] \\
70 \text{and } j \in [0, N_{\rm patch}] \\
71 \end{align},
72 underlined indices denotes one that currently owned by the local process.
73 )tex";
74
75 replace_edges_tex_symbols(tex);
76
77 return tex;
78}
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.
#define __shamrock_stack_entry()
Macro to create a stack entry.