Mallard 0.8.0
Unstructured, GPU accelerated, high-order finite volume CFD solver
Mallard website
Loading...
Searching...
No Matches
halo_exchange.h
Go to the documentation of this file.
1
12#ifndef HALO_EXCHANGE_H
13#define HALO_EXCHANGE_H
14
15#include <cstdint>
16#include <vector>
17
18#include <Kokkos_Core.hpp>
19
20#include "comm.h"
21#include "common_typedef.h"
22#include "distribution.h"
23#include "state.h"
24
31 public:
32 HaloExchange() = default;
34 HaloExchange(const Distribution & dist, bool nccl);
35
37 void exchange(const State & U) {
38 start(U);
39 finish(U);
40 }
41
48 void start(const State & U);
49
54 void finish(const State & U);
55
56 bool active() const { return !ranks.empty(); }
57
58 bool uses_nccl() const { return nccl; }
59
60 private:
61 void allocate_buffers(uint32_t n_values_per_cell);
62
63 std::vector<int> ranks;
64 bool nccl = false;
65 uint32_t n_values = 0; // per cell in the buffers: the flow block, then the species
66 std::vector<uint32_t> send_offsets, recv_offsets; // per neighbor, in cells
67 Kokkos::View<uint32_t *> send_cells, recv_cells;
68 Kokkos::View<rtype *> send_buffer, recv_buffer;
69 Kokkos::View<rtype *>::host_mirror_type h_send_buffer, h_recv_buffer;
70#ifdef Mallard_HAS_MPI
71 std::vector<MPI_Request> requests;
72#endif
73};
74
75#endif // HALO_EXCHANGE_H
Point-to-point exchange of per-cell state following a Distribution's plan. Buffers are packed on the ...
Definition halo_exchange.h:30
bool uses_nccl() const
Definition halo_exchange.h:58
bool active() const
Definition halo_exchange.h:56
void start(const State &U)
Send the owned values of U that neighbors need and post the receives; the halo cells of U stay stale ...
Definition halo_exchange.cpp:67
HaloExchange()=default
void exchange(const State &U)
Overwrite the halo cells of U with the owners' values (collective among neighbors).
Definition halo_exchange.h:37
void finish(const State &U)
Wait for the messages of start() and fill the halo cells of U (with NCCL: enqueue the filling after t...
Definition halo_exchange.cpp:122
Process-level communication: MPI when built with Mallard_ENABLE_MPI, otherwise a single-rank stub wit...
KOKKOS_INLINE_FUNCTION rtype dot(const rtype *a, const rtype *b)
Compute the dot product of two arrays.
Definition common_math.h:32
Typedefs for common types.
A rank's share of a distributed mesh: owned cells, halo layers and the halo exchange plan.
Conservative state: the flow block and the species partial densities.
Local numbering: owned cells first (in global order), then halo layer 1, 2, ... Every local cell keep...
Definition distribution.h:26
Conservative state of every cell: the flow block and the partial densities of a mixture's species....
Definition state.h:56