DFT-FE 1.3.0-pre
Density Functional Theory With Finite-Elements
Loading...
Searching...
No Matches
MPICommunicatorP2PKernels.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 dftfeMPICommunicatorP2PKernels_h
23#define dftfeMPICommunicatorP2PKernels_h
24
25#include <MemorySpaceType.h>
26#include <MemoryStorage.h>
27#include <TypeConfig.h>
28#include <DataTypeOverloads.h>
29#include <dftfeDataTypes.h>
30#ifdef DFTFE_WITH_DEVICE
31# include <DeviceTypeConfig.h>
32#endif
33namespace dftfe
34{
35 namespace utils
36 {
37 template <typename ValueType, dftfe::utils::MemorySpace memorySpace>
39 {
40 public:
42
43 /**
44 * @brief Function template for architecture adaptable gather kernel to send buffer
45 * @tparam ValueType the type of the number
46 * @tparam memorySpace
47 * @param[in] dataArray data array with locally owned entries
48 * @param[in] ownedLocalIndicesForTargetProcs
49 * @param[in] blockSize
50 * @param[out] sendBuffer
51 */
52 template <typename ValueTypeComm>
53 static void
56 const SizeTypeVector &ownedLocalIndicesForTargetProcs,
57 const dftfe::uInt blockSize,
59
60 /**
61 * @brief Function template for architecture adaptable accumulate add kernel from recv buffer
62 * @tparam ValueType the type of the number
63 * @tparam memorySpace
64 * @param[in] recvBuffer
65 * @param[in] ownedLocalIndicesForTargetProcs
66 * @param[in] blockSize
67 * @param[out] dataArray
68 */
69 template <typename ValueTypeComm>
70 static void
73 const SizeTypeVector &ownedLocalIndicesForTargetProcs,
74 const dftfe::uInt blockSize,
75 const dftfe::uInt locallyOwnedSize,
76 const dftfe::uInt ghostSize,
78
79 /**
80 * @brief Function template for architecture adaptable accumulate insert kernel from recv buffer
81 * @tparam ValueType the type of the number
82 * @tparam memorySpace
83 * @param[in] recvBuffer
84 * @param[in] ownedLocalIndicesForTargetProcs
85 * @param[in] blockSize
86 * @param[out] dataArray
87 */
88 template <typename ValueTypeComm>
89 static void
92 const SizeTypeVector &ownedLocalIndicesForTargetProcs,
93 const dftfe::uInt blockSize,
94 const dftfe::uInt locallyOwnedSize,
95 const dftfe::uInt ghostSize,
97
98 /**
99 * @brief Function template for copying type1 to type2
100 * @param[in] blockSize
101 * @param[in] type1Array
102 * @param[out] type2Array
103 */
104 template <typename ValueType1, typename ValueType2>
105 static void
107 const ValueType1 *type1Array,
108 ValueType2 *type2Array);
109 };
110
111#ifdef DFTFE_WITH_DEVICE
112 template <typename ValueType>
113 class MPICommunicatorP2PKernels<ValueType,
115 {
116 public:
117 template <typename ValueTypeComm>
118 static void
121 &dataArray,
123 &ownedLocalIndicesForTargetProcs,
124 const dftfe::uInt blockSize,
126 &sendBuffer,
127 dftfe::utils::deviceStream_t deviceCommStream);
128
129 template <typename ValueTypeComm>
130 static void
133 &recvBuffer,
135 &ownedLocalIndicesForTargetProcs,
136 const dftfe::uInt blockSize,
137 const dftfe::uInt locallyOwnedSize,
138 const dftfe::uInt ghostSize,
140 dftfe::utils::deviceStream_t deviceCommStream);
141
142 /**
143 * @brief Function template for architecture adaptable accumulate insert kernel from recv buffer
144 * @tparam ValueType the type of the number
145 * @tparam memorySpace
146 * @param[in] recvBuffer
147 * @param[in] ownedLocalIndicesForTargetProcs
148 * @param[in] blockSize
149 * @param[out] dataArray
150 */
151 template <typename ValueTypeComm>
152 static void
155 &recvBuffer,
157 &ownedLocalIndicesForTargetProcs,
158 const dftfe::uInt blockSize,
159 const dftfe::uInt locallyOwnedSize,
160 const dftfe::uInt ghostSize,
162 dftfe::utils::deviceStream_t deviceCommStream);
163
164 static void
165 gatherLocallyOwnedEntriesSendBufferToTargetProcsHalfPrec(
167 &dataArray,
169 &ownedLocalIndicesForTargetProcs,
170 const dftfe::uInt blockSize,
173 dftfe::utils::deviceStream_t deviceCommStream);
174
175
176 static void
177 accumAddLocallyOwnedContrRecvBufferFromTargetProcsHalfPrec(
178 const MemoryStorage<
182 &ownedLocalIndicesForTargetProcs,
183 const dftfe::uInt blockSize,
184 const dftfe::uInt locallyOwnedSize,
185 const dftfe::uInt ghostSize,
187 dftfe::utils::deviceStream_t deviceCommStream);
188
189
190 /**
191 * @brief Function template for copying type1 to type2
192 * @param[in] blockSize
193 * @param[in] type1Array
194 * @param[out] type2Array
195 */
196 template <typename ValueType1, typename ValueType2>
197 static void
199 const dftfe::uInt blockSize,
200 const ValueType1 *type1Array,
201 ValueType2 *type2Array,
202 dftfe::utils::deviceStream_t deviceCommStream);
203
204 static void
205 copyHalfPrecArrToValueTypeArr(
206 const dftfe::uInt blockSize,
208 *halfPrecArray,
209 ValueType *valueTypeArray,
210 dftfe::utils::deviceStream_t deviceCommStream);
211
212 static void
213 copyValueTypeArrToHalfPrecArr(
214 const dftfe::uInt blockSize,
215 const ValueType *valueTypeArray,
217 dftfe::utils::deviceStream_t deviceCommStream);
218 };
219#endif
220 } // namespace utils
221} // namespace dftfe
222
223
224#endif
Definition MPICommunicatorP2PKernels.h:39
static void gatherLocallyOwnedEntriesSendBufferToTargetProcs(const MemoryStorage< ValueType, memorySpace > &dataArray, const SizeTypeVector &ownedLocalIndicesForTargetProcs, const dftfe::uInt blockSize, MemoryStorage< ValueTypeComm, memorySpace > &sendBuffer)
Function template for architecture adaptable gather kernel to send buffer.
utils::MemoryStorage< dftfe::uInt, memorySpace > SizeTypeVector
Definition MPICommunicatorP2PKernels.h:41
static void accumInsertLocallyOwnedContrRecvBufferFromTargetProcs(const MemoryStorage< ValueTypeComm, memorySpace > &recvBuffer, const SizeTypeVector &ownedLocalIndicesForTargetProcs, const dftfe::uInt blockSize, const dftfe::uInt locallyOwnedSize, const dftfe::uInt ghostSize, MemoryStorage< ValueType, memorySpace > &dataArray)
Function template for architecture adaptable accumulate insert kernel from recv buffer.
static void copyValueType1ArrToValueType2Arr(const dftfe::uInt blockSize, const ValueType1 *type1Array, ValueType2 *type2Array)
Function template for copying type1 to type2.
static void accumAddLocallyOwnedContrRecvBufferFromTargetProcs(const MemoryStorage< ValueTypeComm, memorySpace > &recvBuffer, const SizeTypeVector &ownedLocalIndicesForTargetProcs, const dftfe::uInt blockSize, const dftfe::uInt locallyOwnedSize, const dftfe::uInt ghostSize, MemoryStorage< ValueType, memorySpace > &dataArray)
Function template for architecture adaptable accumulate add kernel from recv buffer.
Definition MemoryStorage.h:33
Definition Cell.h:36
cudaStream_t deviceStream_t
Definition DeviceTypeConfig.cu.h:27
@ DEVICE
Definition MemorySpaceType.h:36
Definition pseudoPotentialToDftfeConverter.cc:34
std::uint32_t uInt
Definition TypeConfig.h:10
T type
Definition dftfeDataTypes.h:130