DFT-FE 1.1.0-pre
Density Functional Theory With Finite-Elements
Loading...
Searching...
No Matches
MemoryTransfer.t.cc
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 * @author Ian C. Lin, Sambit Das.
19 */
20
21#include <algorithm>
22#include <MemoryTransfer.h>
24
25
26namespace dftfe
27{
28 namespace utils
29 {
30 template <typename ValueType>
31 void
33 std::size_t size,
34 ValueType * dst,
35 const ValueType *src)
36 {
37 std::copy(src, src + size, dst);
38 }
39
40#ifdef DFTFE_WITH_DEVICE
41 template <typename ValueType>
42 void
44 std::size_t size,
45 ValueType * dst,
46 const ValueType *src)
47 {
48 std::copy(src, src + size, dst);
49 }
50
51 template <typename ValueType>
52 void
54 std::size_t size,
55 ValueType * dst,
56 const ValueType *src)
57 {
58 memoryTransferKernelsDevice::deviceMemcpyD2H(dst,
59 src,
60 size * sizeof(ValueType));
61 }
62
63 template <typename ValueType>
64 void
66 std::size_t size,
67 ValueType * dst,
68 const ValueType *src)
69 {
70 std::copy(src, src + size, dst);
71 }
72
73 template <typename ValueType>
74 void
76 std::size_t size,
77 ValueType * dst,
78 const ValueType *src)
79 {
80 std::copy(src, src + size, dst);
81 }
82
83 template <typename ValueType>
84 void
86 std::size_t size,
87 ValueType * dst,
88 const ValueType *src)
89 {
90 memoryTransferKernelsDevice::deviceMemcpyD2H(dst,
91 src,
92 size * sizeof(ValueType));
93 }
94
95 template <typename ValueType>
96 void
98 std::size_t size,
99 ValueType * dst,
100 const ValueType *src)
101 {
102 memoryTransferKernelsDevice::deviceMemcpyH2D(dst,
103 src,
104 size * sizeof(ValueType));
105 }
106
107 template <typename ValueType>
108 void
110 std::size_t size,
111 ValueType * dst,
112 const ValueType *src)
113 {
114 memoryTransferKernelsDevice::deviceMemcpyH2D(dst,
115 src,
116 size * sizeof(ValueType));
117 }
118
119 template <typename ValueType>
120 void
122 std::size_t size,
123 ValueType * dst,
124 const ValueType *src)
125 {
126 memoryTransferKernelsDevice::deviceMemcpyD2D(dst,
127 src,
128 size * sizeof(ValueType));
129 }
130#endif // DFTFE_WITH_DEVICE
131 } // namespace utils
132} // namespace dftfe
static void copy(std::size_t size, ValueType *dst, const ValueType *src)
Copy array from the memory space of source to the memory space of destination.
Definition Cell.h:36
Definition pseudoPotentialToDftfeConverter.cc:34