Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
ExchangeGhostField.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
24
25template<class T>
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<PatchDataField<T>>(
37 shamsys::instance::get_compute_scheduler_ptr(),
38 std::move(ghost_layer.patchdata_fields),
39 recv_dat,
40 [&](u64 id) {
41 return rank_owner.get_rank_owner(id);
42 },
43 [](PatchDataField<T> &pdat) {
44 shamalgs::SerializeHelper ser(shamsys::instance::get_compute_scheduler_ptr());
45 ser.allocate(pdat.serialize_full_byte_size());
46 pdat.serialize_full(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
52 shamsys::instance::get_compute_scheduler_ptr(),
53 std::forward<sham::DeviceBuffer<u8>>(buf));
55 },
56 cache);
57
58 ghost_layer.patchdata_fields = std::move(recv_dat);
59}
60
61template<class T>
63 std::string tex = R"tex(
64 Exchange ghost field data between distributed processes
65
66 \begin{align}
67 {ghost_layer}_{i \rightarrow \underline{j}} = \text{Sparse comm}({ghost_layer}_{\underline{i} \rightarrow j}) \\
68 \text{where } {rank_owner}_{\underline{j}} = \text{MPI world rank} \\
69 \text{and } {rank_owner}_{\underline{i}} = \text{MPI world rank} \\
70 \text{and } i \in [0, N_{\rm patch}] \\
71 \text{and } j \in [0, N_{\rm patch}] \\
72 \end{align},
73 underlined indices denotes one that currently owned by the local process.
74 )tex";
75
76 replace_edges_tex_symbols(tex);
77
78 return tex;
79}
80
82// Explicitly instantiate all classes in XMAC_LIST_ENABLED_FIELD
84
85#ifndef DOXYGEN
86 #define X(a) template class shamrock::solvergraph::ExchangeGhostField<a>;
87XMAC_LIST_ENABLED_FIELD
88 #undef X
89#endif
90
Solver graph node for exchanging ghost field data between distributed processes.
std::uint64_t u64
64 bit unsigned integer
static PatchDataField deserialize_full(shamalgs::SerializeHelper &serializer)
deserialize a field inverse of serialize_full
A buffer allocated in USM (Unified Shared Memory).
Container for objects shared between two distributed data elements.
virtual std::string _impl_get_tex() const
Returns the TeX representation for this node.
void _impl_evaluate_internal()
Performs the ghost field data exchange computation.
#define __shamrock_stack_entry()
Macro to create a stack entry.