DFT-EFE
 
Loading...
Searching...
No Matches
MPICommunicatorP2P.h
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (c) 2021. *
3 * The Regents of the University of Michigan and DFT-EFE developers. *
4 * *
5 * This file is part of the DFT-EFE code. *
6 * *
7 * DFT-EFE is free software: you can redistribute it and/or modify *
8 * it under the terms of the Lesser GNU General Public License as *
9 * published by the Free Software Foundation, either version 3 of *
10 * the License, or (at your option) any later version. *
11 * *
12 * DFT-EFE is distributed in the hope that it will be useful, but *
13 * WITHOUT ANY WARRANTY; without even the implied warranty *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
15 * See the Lesser GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU Lesser General Public *
18 * License at the top level of DFT-EFE distribution. If not, see *
19 * <https://www.gnu.org/licenses/>. *
20 ******************************************************************************/
21
22/*
23 * @author Sambit Das
24 */
25
26#ifndef dftefeMPICommunicatorP2P_h
27#define dftefeMPICommunicatorP2P_h
28
30#include <utils/MPITypes.h>
31#include <utils/MPIPatternP2P.h>
32#include <utils/TypeConfig.h>
33#include <utils/MemoryStorage.h>
35#include <functional>
36
37
38namespace dftefe
39{
40 namespace utils
41 {
42 namespace mpi
43 {
45 {
46 mpiHost,
48 };
49
51 {
52 standard // same as valueType
53 };
54
55 template <typename ValueType, MemorySpace memorySpace>
57 {
58 public:
59 // NOTE: getStream is a type-erased callback (rather than, say, a
60 // LinAlgOpContext&) so that this utils-layer class never has to
61 // depend on linearAlgebra::LinAlgOpContext -- dft-efe-linalg links
62 // dft-efe-utils, not the reverse. Callers (Vector/MultiVector) pass
63 // a lambda that calls linAlgOpContext.getBlasStream(); it's invoked
64 // fresh on every communication call, so LinAlgOpContext's default-
65 // /non-default-stream exclusivity gating still triggers correctly,
66 // instead of being resolved once and going stale.
68 std::shared_ptr<const MPIPatternP2P<memorySpace>> mpiPatternP2P,
69 const size_type blockSize,
70 std::function<utils::deviceStream_t()> getStream);
71
72 void
74 const size_type communicationChannel = 0);
75
76 void
79 const size_type communicationChannel = 0);
80
81
82 void
84 const size_type communicationChannel = 0);
85
86 void
88
89 void
92 const size_type communicationChannel = 0);
93
94 void
97
98 std::shared_ptr<const MPIPatternP2P<memorySpace>>
99 getMPIPatternP2P() const;
100
101 int
102 getBlockSize() const;
103
104 void
106
107 private:
108 std::shared_ptr<const MPIPatternP2P<memorySpace>> d_mpiPatternP2P;
109
111
113
115
117
118
119#ifdef DFTEFE_WITH_DEVICE
121 d_ghostDataCopyHostPinned;
122
124 d_sendRecvBufferHostPinned;
125#endif // DFTEFE_WITH_DEVICE
126
127 std::vector<MPIRequest> d_requestsUpdateGhostValues;
128 std::vector<MPIRequest> d_requestsAccumulateAddLocallyOwned;
130
133 };
134
135 } // namespace mpi
136 } // namespace utils
137} // namespace dftefe
139#endif // dftefeMPICommunicatorP2P_h
Definition: MemoryStorage.h:38
Definition: MPICommunicatorP2P.h:57
std::shared_ptr< const MPIPatternP2P< memorySpace > > getMPIPatternP2P() const
Definition: MPICommunicatorP2P.t.cpp:623
MemoryStorage< ValueType, memorySpace > d_ghostDataBuffer
Definition: MPICommunicatorP2P.h:116
communicationProtocol d_commProtocol
Definition: MPICommunicatorP2P.h:131
std::shared_ptr< const MPIPatternP2P< memorySpace > > d_mpiPatternP2P
Definition: MPICommunicatorP2P.h:108
size_type d_blockSize
Definition: MPICommunicatorP2P.h:110
MPIComm d_mpiCommunicator
Definition: MPICommunicatorP2P.h:129
void setCommunicationPrecision(communicationPrecision precision)
Definition: MPICommunicatorP2P.t.cpp:84
std::function< utils::deviceStream_t()> d_getStream
Definition: MPICommunicatorP2P.h:112
void updateGhostValuesBegin(MemoryStorage< ValueType, memorySpace > &dataArray, const size_type communicationChannel=0)
Definition: MPICommunicatorP2P.t.cpp:147
communicationPrecision d_commPrecision
Definition: MPICommunicatorP2P.h:132
void updateGhostValuesEnd(MemoryStorage< ValueType, memorySpace > &dataArray)
Definition: MPICommunicatorP2P.t.cpp:313
MemoryStorage< ValueType, memorySpace > d_targetDataBuffer
Definition: MPICommunicatorP2P.h:114
int getBlockSize() const
Definition: MPICommunicatorP2P.t.cpp:630
void accumulateAddLocallyOwnedEnd(MemoryStorage< ValueType, memorySpace > &dataArray)
Definition: MPICommunicatorP2P.t.cpp:559
void accumulateAddLocallyOwned(MemoryStorage< ValueType, memorySpace > &dataArray, const size_type communicationChannel=0)
Definition: MPICommunicatorP2P.t.cpp:380
std::vector< MPIRequest > d_requestsUpdateGhostValues
Definition: MPICommunicatorP2P.h:127
std::vector< MPIRequest > d_requestsAccumulateAddLocallyOwned
Definition: MPICommunicatorP2P.h:128
void accumulateAddLocallyOwnedBegin(MemoryStorage< ValueType, memorySpace > &dataArray, const size_type communicationChannel=0)
Definition: MPICommunicatorP2P.t.cpp:391
void updateGhostValues(MemoryStorage< ValueType, memorySpace > &dataArray, const size_type communicationChannel=0)
Definition: MPICommunicatorP2P.t.cpp:135
A class template to store the communication pattern (i.e., which entries/nodes to receive from which ...
Definition: MPIPatternP2P.h:197
communicationPrecision
Definition: MPICommunicatorP2P.h:51
int MPIComm
Definition: MPITypes.h:84
communicationProtocol
Definition: MPICommunicatorP2P.h:45
cudaStream_t deviceStream_t
Definition: DeviceTypeConfig.cu.h:27
dealii includes
Definition: AtomFieldDataSpherical.cpp:31
std::uint64_t size_type
Definition: TypeConfig.h:9