DFT-FE 1.3.0-pre
Density Functional Theory With Finite-Elements
Loading...
Searching...
No Matches
MPICommunicatorP2P.h
Go to the documentation of this file.
1// ---------------------------------------------------------------------
2//
3// Copyright (c) 2017-2025 The Regents of the University of Michigan and DFT-FE
4// authors.
5//
6// This file is part of the DFT-FE code.
7//
8// The DFT-FE code is free software; you can use it, redistribute
9// it, and/or modify it under the terms of the GNU Lesser General
10// Public License as published by the Free Software Foundation; either
11// version 2.1 of the License, or (at your option) any later version.
12// The full text of the license can be found in the file LICENSE at
13// the top level of the DFT-FE distribution.
14//
15// ---------------------------------------------------------------------
16//
17
18/*
19 * @author Sambit Das
20 */
21
22#ifndef dftfeMPICommunicatorP2P_h
23#define dftfeMPICommunicatorP2P_h
24
25#include <MemorySpaceType.h>
26#include <MPIPatternP2P.h>
27#include <TypeConfig.h>
28#include <MemoryStorage.h>
29#include <DataTypeOverloads.h>
30#include <dftfeDataTypes.h>
31#ifdef DFTFE_WITH_DEVICE
32# include <DeviceTypeConfig.h>
33# if defined(DFTFE_WITH_CUDA_NCCL)
34# include <nccl.h>
35# elif defined(DFTFE_WITH_HIP_RCCL)
36# include <rccl.h>
37# endif
38#endif
39
40
41namespace dftfe
42{
43 namespace utils
44 {
45 namespace mpi
46 {
53
55 {
56 half, // explicitly BF16
57 single, // explicitly FP32
58 standard // same as valueType
59 };
60
61 template <typename ValueType, MemorySpace memorySpace>
63 {
64 public:
66 std::shared_ptr<const MPIPatternP2P<memorySpace>> mpiPatternP2P,
67 const dftfe::uInt blockSize);
68
69 void
71 const dftfe::uInt communicationChannel = 0);
72
73 void
76 const dftfe::uInt communicationChannel = 0);
77
78 void
80 const dftfe::uInt communicationChannel = 0);
81
82 void
84
85 void
88 const dftfe::uInt communicationChannel = 0);
89
90 void
93
94 /*
95 * @Brief This function copies the value from the ghost nodes
96 * to its corresponding local node
97 */
98 void
101 const dftfe::uInt communicationChannel = 0);
102
103 void
106 const dftfe::uInt communicationChannel = 0);
107
108 void
111
112 std::shared_ptr<const MPIPatternP2P<memorySpace>>
114
117
118 void
120
121 private:
122 std::shared_ptr<const MPIPatternP2P<memorySpace>> d_mpiPatternP2P;
123
125
127
129
131
134 memorySpace>
136
139 memorySpace>
141
143 memorySpace>
145
147 memorySpace>
149
150#ifdef DFTFE_WITH_DEVICE
151 std::shared_ptr<MemoryStorage<ValueType, MemorySpace::HOST_PINNED>>
152 d_ghostDataCopyHostPinnedPtr;
153
154 std::shared_ptr<MemoryStorage<ValueType, MemorySpace::HOST_PINNED>>
155 d_sendRecvBufferHostPinnedPtr;
156
157 std::shared_ptr<MemoryStorage<
160 d_ghostDataCopySinglePrecHostPinnedPtr;
161
162 std::shared_ptr<MemoryStorage<
165 d_sendRecvBufferSinglePrecHostPinnedPtr;
166
167 std::shared_ptr<MemoryStorage<
170 d_ghostDataCopyHalfPrecHostPinnedPtr;
171
172 std::shared_ptr<MemoryStorage<
175 d_sendRecvBufferHalfPrecHostPinnedPtr;
176
177#endif // DFTFE_WITH_DEVICE
178
179 std::vector<MPI_Request> d_requestsUpdateGhostValues;
180 std::vector<MPI_Request> d_requestsAccumulateAddLocallyOwned;
183
186 };
187 } // namespace mpi
188 } // namespace utils
189} // namespace dftfe
190#endif // dftfeMPICommunicatorP2P_h
Definition MemoryStorage.h:33
void accumulateInsertLocallyOwnedBegin(MemoryStorage< ValueType, memorySpace > &dataArray, const dftfe::uInt communicationChannel=0)
MemoryStorage< typename dftfe::dataTypes::singlePrecType< ValueType >::type, memorySpace > d_ghostDataCopySinglePrec
Definition MPICommunicatorP2P.h:140
MemoryStorage< typename dftfe::dataTypes::halfPrecType< ValueType >::type, memorySpace > d_sendRecvBufferHalfPrec
Definition MPICommunicatorP2P.h:144
std::shared_ptr< const MPIPatternP2P< memorySpace > > getMPIPatternP2P() const
void accumulateAddLocallyOwnedEnd(MemoryStorage< ValueType, memorySpace > &dataArray)
MemoryStorage< ValueType, memorySpace > d_sendRecvBuffer
Definition MPICommunicatorP2P.h:130
dftfe::uInt d_blockSize
Definition MPICommunicatorP2P.h:124
void updateGhostValues(MemoryStorage< ValueType, memorySpace > &dataArray, const dftfe::uInt communicationChannel=0)
void setCommunicationPrecision(communicationPrecision precision)
std::vector< MPI_Request > d_requestsAccumulateAddLocallyOwned
Definition MPICommunicatorP2P.h:180
MPICommunicatorP2P(std::shared_ptr< const MPIPatternP2P< memorySpace > > mpiPatternP2P, const dftfe::uInt blockSize)
MPI_Comm d_mpiCommunicator
Definition MPICommunicatorP2P.h:182
dftfe::uInt d_locallyOwnedSize
Definition MPICommunicatorP2P.h:126
std::shared_ptr< const MPIPatternP2P< memorySpace > > d_mpiPatternP2P
Definition MPICommunicatorP2P.h:122
std::vector< MPI_Request > d_requestsUpdateGhostValues
Definition MPICommunicatorP2P.h:179
void accumulateInsertLocallyOwned(MemoryStorage< ValueType, memorySpace > &dataArray, const dftfe::uInt communicationChannel=0)
MemoryStorage< typename dftfe::dataTypes::singlePrecType< ValueType >::type, memorySpace > d_sendRecvBufferSinglePrec
Definition MPICommunicatorP2P.h:135
MemoryStorage< typename dftfe::dataTypes::halfPrecType< ValueType >::type, memorySpace > d_ghostDataCopyHalfPrec
Definition MPICommunicatorP2P.h:148
void updateGhostValuesBegin(MemoryStorage< ValueType, memorySpace > &dataArray, const dftfe::uInt communicationChannel=0)
void accumulateAddLocallyOwnedBegin(MemoryStorage< ValueType, memorySpace > &dataArray, const dftfe::uInt communicationChannel=0)
void accumulateAddLocallyOwned(MemoryStorage< ValueType, memorySpace > &dataArray, const dftfe::uInt communicationChannel=0)
communicationProtocol d_commProtocol
Definition MPICommunicatorP2P.h:184
std::vector< MPI_Request > d_requestsAccumulateInsertLocallyOwned
Definition MPICommunicatorP2P.h:181
void accumulateInsertLocallyOwnedEnd(MemoryStorage< ValueType, memorySpace > &dataArray)
void updateGhostValuesEnd(MemoryStorage< ValueType, memorySpace > &dataArray)
communicationPrecision d_commPrecision
Definition MPICommunicatorP2P.h:185
dftfe::uInt d_ghostSize
Definition MPICommunicatorP2P.h:128
A class template to store the communication pattern (i.e., which entries/nodes to receive from which ...
Definition MPIPatternP2P.h:57
Definition MPICommunicatorP2P.h:46
communicationPrecision
Definition MPICommunicatorP2P.h:55
@ half
Definition MPICommunicatorP2P.h:56
@ standard
Definition MPICommunicatorP2P.h:58
@ single
Definition MPICommunicatorP2P.h:57
communicationProtocol
Definition MPICommunicatorP2P.h:48
@ nccl
Definition MPICommunicatorP2P.h:51
@ mpiDevice
Definition MPICommunicatorP2P.h:50
@ mpiHost
Definition MPICommunicatorP2P.h:49
Definition Cell.h:36
@ HOST_PINNED
Definition MemorySpaceType.h:35
Definition pseudoPotentialToDftfeConverter.cc:34
std::uint32_t uInt
Definition TypeConfig.h:10
std::int32_t Int
Definition TypeConfig.h:11
T type
Definition dftfeDataTypes.h:130
T type
Definition dftfeDataTypes.h:112