OpenLB 1.7
Loading...
Searching...
No Matches
communicator.h
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2022 Adrian Kummerlaender
4 * E-mail contact: info@openlb.net
5 * The most recent release of OpenLB can be downloaded at
6 * <http://www.openlb.net/>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with this program; if not, write to the Free
20 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22*/
23
24#ifndef PLATFORM_GPU_CUDA_COMMUNICATOR_H
25#define PLATFORM_GPU_CUDA_COMMUNICATOR_H
26
27#include <map>
28#include <set>
29#include <typeindex>
30
31namespace olb {
32
33template <typename T, typename DESCRIPTOR>
34class SuperLattice;
35
36template <typename T, typename DESCRIPTOR, Platform PLATFORM>
37class ConcreteBlockLattice;
38
39template <typename T, typename DESCRIPTOR, Platform SOURCE, Platform TARGET>
40struct HeterogeneousCopyTask;
41
43template <>
45
49 virtual void copy() = 0;
50 virtual void wait() = 0;
51};
52
54template <typename T, typename DESCRIPTOR, Platform SOURCE>
55class HeterogeneousCopyTask<T,DESCRIPTOR,SOURCE,Platform::GPU_CUDA>
56 : public ConcreteBlockCommunicator<ConcreteBlockLattice<T,DESCRIPTOR,Platform::GPU_CUDA>>::CopyTask {
57private:
58 std::unique_ptr<ConcreteHeterogeneousCopyTask> _impl;
59
60public:
62 const std::vector<std::type_index>& fields,
63 const std::vector<CellID>& targetCells, ConcreteBlockLattice<T,DESCRIPTOR,Platform::GPU_CUDA>& target,
64 const std::vector<CellID>& sourceCells, ConcreteBlockLattice<T,DESCRIPTOR,SOURCE>& source);
66 wait();
67 }
68
69 void copy() override;
70 void wait() override;
71
72};
73
75template <typename T, typename DESCRIPTOR, Platform TARGET>
76class HeterogeneousCopyTask<T,DESCRIPTOR,Platform::GPU_CUDA,TARGET>
77 : public ConcreteBlockCommunicator<ConcreteBlockLattice<T,DESCRIPTOR,TARGET>>::CopyTask {
78private:
79 std::unique_ptr<ConcreteHeterogeneousCopyTask> _impl;
80
81public:
83 const std::vector<std::type_index>& fields,
84 const std::vector<CellID>& targetCells, ConcreteBlockLattice<T,DESCRIPTOR,TARGET>& target,
85 const std::vector<CellID>& sourceCells, ConcreteBlockLattice<T,DESCRIPTOR,Platform::GPU_CUDA>& source);
87 wait();
88 }
89
90 void copy() override;
91 void wait() override;
92
93};
94
95template <typename T, typename DESCRIPTOR>
97 final : public BlockCommunicator {
98private:
99 const int _iC;
100#ifdef PARALLEL_MODE_MPI
101 MPI_Comm _mpiCommunicator;
102#endif
103
104#ifdef PARALLEL_MODE_MPI
105 class SendTask;
106 class RecvTask;
107
108 std::vector<std::unique_ptr<SendTask>> _sendTasks;
109 std::vector<std::unique_ptr<RecvTask>> _recvTasks;
110#endif
111
112public:
113 struct CopyTask;
114
116 LoadBalancer<T>& loadBalancer,
117#ifdef PARALLEL_MODE_MPI
119 MPI_Comm comm,
120#endif
121 int iC,
124
125#ifdef PARALLEL_MODE_MPI
126 void receive() override;
127 void send() override;
128 void unpack() override;
129 void wait() override;
130#else
131 void copy() override;
132#endif
133
134private:
135 class HomogeneousCopyTask;
136
137 std::vector<std::unique_ptr<CopyTask>> _copyTasks;
138
139};
140
141
142}
143
144#endif
Configurable overlap communication neighborhood of a block.
Implementation of BlockLattice on a concrete PLATFORM.
Wrapper for a local heterogeneous block communication request.
Base class for all LoadBalancer.
Communication-free negotation of unique tags for inter-cuboid communication.
Super class maintaining block lattices for a cuboid decomposition.
Top level namespace for all of OpenLB.
Platform
OpenLB execution targets.
Definition platform.h:36
@ GPU_CUDA
Vector CPU (AVX2 / AVX-512 collision)
void checkPlatform< Platform::GPU_CUDA >()
Verifies availability of CUDA device and MPI support.
Generic communicator for the overlap neighborhood of a block.
Private implementation of HeterogeneousCopyTask (PIMPL)