DFT-EFE
 
Loading...
Searching...
No Matches
DiscontiguousDataOperations.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 Bikash Kanungo
24 */
25
26#ifndef dftefeDiscontiguousDataOperations_h
27#define dftefeDiscontiguousDataOperations_h
28
30#include <utils/MemoryStorage.h>
31#include <utils/TypeConfig.h>
33
34namespace dftefe
35{
36 namespace utils
37 {
38 template <typename ValueType, dftefe::utils::MemorySpace memorySpace>
40 {
41 public:
43
71 // NOTE: streamId is accepted (and ignored) here too, even though HOST
72 // has no stream concept, purely so callers (e.g. MPICommunicatorP2P,
73 // templated over memorySpace) can use one uniform call site for both
74 // HOST and DEVICE instead of branching with `if constexpr`.
75 static void
76 copyFromDiscontiguousMemory(const ValueType * src,
77 ValueType * dst,
78 const size_type * discontIds,
79 const size_type N,
80 const size_type nComponents,
81 utils::deviceStream_t streamId);
82
111 static void
112 copyToDiscontiguousMemory(const ValueType * src,
113 ValueType * dst,
114 const size_type * discontIds,
115 const size_type N,
116 const size_type nComponents,
117 utils::deviceStream_t streamId);
118
147 static void
148 addToDiscontiguousMemory(const ValueType * src,
149 ValueType * dst,
150 const size_type * discontIds,
151 const size_type N,
152 const size_type nComponents,
153 utils::deviceStream_t streamId);
154 }; // end of class DiscontiguousDataOperations
155
156
157// partial template specialization for DEVICE
158// NOTE: streamId has no default value on purpose -- callers must always be
159// explicit about which stream this runs on (see LinAlgOpContext's default-
160// vs-non-default-stream exclusivity, which relies on every SYCL submission
161// going through a real accessor rather than an implicit stream 0).
162#ifdef DFTEFE_WITH_DEVICE
163 template <typename ValueType>
164 class DiscontiguousDataOperations<ValueType, utils::MemorySpace::DEVICE>
165 {
166 public:
167 using SizeTypeVector =
169
198 static void
199 copyFromDiscontiguousMemory(const ValueType * src,
200 ValueType * dst,
201 const size_type * discontIds,
202 const size_type N,
203 const size_type nComponents,
204 utils::deviceStream_t streamId);
205
234 static void
235 copyToDiscontiguousMemory(const ValueType * src,
236 ValueType * dst,
237 const size_type * discontIds,
238 const size_type N,
239 const size_type nComponents,
240 utils::deviceStream_t streamId);
241
270 static void
271 addToDiscontiguousMemory(const ValueType * src,
272 ValueType * dst,
273 const size_type * discontIds,
274 const size_type N,
275 const size_type nComponents,
276 utils::deviceStream_t streamId);
277 }; // end of class DiscontiguousDataOperations for DEVICE
278#endif // DFTEFE_WITH_DEVICE
279
280 } // end of namespace utils
281} // namespace dftefe
282#endif // dftefeDiscontiguousDataOperations_h
Definition: DiscontiguousDataOperations.h:40
static void copyFromDiscontiguousMemory(const ValueType *src, ValueType *dst, const size_type *discontIds, const size_type N, const size_type nComponents, utils::deviceStream_t streamId)
Function to copy a source array x to a destination array y, where the source is accessed discontiguou...
Definition: DiscontiguousDataOperations.cpp:39
utils::MemoryStorage< size_type, memorySpace > SizeTypeVector
Definition: DiscontiguousDataOperations.h:42
static void addToDiscontiguousMemory(const ValueType *src, ValueType *dst, const size_type *discontIds, const size_type N, const size_type nComponents, utils::deviceStream_t streamId)
Function to add a source array x to a destination array y, where the source is accessed contiguously ...
Definition: DiscontiguousDataOperations.cpp:79
static void copyToDiscontiguousMemory(const ValueType *src, ValueType *dst, const size_type *discontIds, const size_type N, const size_type nComponents, utils::deviceStream_t streamId)
Function to copy a source array x to a destination array y, where the source is accessed contiguously...
Definition: DiscontiguousDataOperations.cpp:59
cudaStream_t deviceStream_t
Definition: DeviceTypeConfig.cu.h:27
dealii includes
Definition: AtomFieldDataSpherical.cpp:31
std::uint64_t size_type
Definition: TypeConfig.h:9