DFT-FE 1.1.0-pre
Density Functional Theory With Finite-Elements
Loading...
Searching...
No Matches
DeviceAPICalls.h
Go to the documentation of this file.
1#ifdef DFTFE_WITH_DEVICE
2
3# ifndef dftfeDeviceAPICalls_H
4# define dftfeDeviceAPICalls_H
5
6# include <TypeConfig.h>
7# include <DeviceTypeConfig.h>
8namespace dftfe
9{
10 namespace utils
11 {
13 deviceReset();
14
16 deviceMemGetInfo(std::size_t *free, std::size_t *total);
17
19 getDeviceCount(int *count);
20
22 getDevice(int *deviceId);
23
25 setDevice(int deviceId);
26
28 deviceMalloc(void **devPtr, std::size_t size);
29
31 deviceMemset(void *devPtr, int value, std::size_t count);
32
33 /**
34 * @brief
35 * @param devPtr
36 * @param value
37 * @param size
38 */
39 template <typename ValueType>
40 void
41 deviceSetValue(ValueType *devPtr, ValueType value, std::size_t size);
42
44 deviceFree(void *devPtr);
45
47 deviceHostMalloc(void **hostPtr, std::size_t size);
48
50 deviceHostFree(void *hostPtr);
51
52 /**
53 * @brief Copy array from device to host
54 * @param count The memory size in bytes of the array
55 */
57 deviceMemcpyD2H(void *dst, const void *src, std::size_t count);
58
59 /**
60 * @brief Copy array from device to device
61 * @param count The memory size in bytes of the array
62 */
64 deviceMemcpyD2D(void *dst, const void *src, std::size_t count);
65
66 /**
67 * @brief Copy array from host to device
68 * @param count The memory size in bytes of the array
69 */
71 deviceMemcpyH2D(void *dst, const void *src, std::size_t count);
72
73 /**
74 * @brief Copy 2D array from device to host
75 * @param count The memory size in bytes of the array
76 */
78 deviceMemcpyD2H_2D(void * dst,
79 std::size_t dpitch,
80 const void *src,
81 std::size_t spitch,
82 std::size_t width,
83 std::size_t height);
84
85 /**
86 * @brief Copy 2D array from device to device
87 * @param count The memory size in bytes of the array
88 */
90 deviceMemcpyD2D_2D(void * dst,
91 std::size_t dpitch,
92 const void *src,
93 std::size_t spitch,
94 std::size_t width,
95 std::size_t height);
96
97 /**
98 * @brief Copy 2D array from host to device
99 * @param count The memory size in bytes of the array
100 */
102 deviceMemcpyH2D_2D(void * dst,
103 std::size_t dpitch,
104 const void *src,
105 std::size_t spitch,
106 std::size_t width,
107 std::size_t height);
108
109 /**
110 * @brief HOST-DEVICE synchronization
111 */
113 deviceSynchronize();
114
115 /**
116 * @brief Copy array from device to host
117 * @param count The memory size in bytes of the array
118 */
120 deviceMemcpyAsyncD2H(void * dst,
121 const void * src,
122 std::size_t count,
123 deviceStream_t stream = 0);
124
125 /**
126 * @brief Copy array from device to device
127 * @param count The memory size in bytes of the array
128 */
130 deviceMemcpyAsyncD2D(void * dst,
131 const void * src,
132 std::size_t count,
133 deviceStream_t stream = 0);
134
135 /**
136 * @brief Copy array from host to device
137 * @param count The memory size in bytes of the array
138 */
140 deviceMemcpyAsyncH2D(void * dst,
141 const void * src,
142 std::size_t count,
143 deviceStream_t stream = 0);
144
145
147 deviceStreamCreate(deviceStream_t *pStream, const bool nonBlocking = false);
148
150 deviceStreamDestroy(deviceStream_t stream);
151
153 deviceStreamSynchronize(deviceStream_t stream);
154
156 deviceEventCreate(deviceEvent_t *pEvent);
157
159 deviceEventDestroy(deviceEvent_t event);
160
162 deviceEventRecord(deviceEvent_t event, deviceStream_t stream = 0);
163
165 deviceEventSynchronize(deviceEvent_t event);
166
168 deviceStreamWaitEvent(deviceStream_t stream,
169 deviceEvent_t event,
170 unsigned int flags = 0);
171
172 } // namespace utils
173} // namespace dftfe
174
175# endif // dftfeDeviceAPICalls_H
176#endif // DFTFE_WITH_DEVICE
Definition Cell.h:36
cudaError_t deviceError_t
Definition DeviceTypeConfig.cu.h:26
cudaStream_t deviceStream_t
Definition DeviceTypeConfig.cu.h:27
cudaEvent_t deviceEvent_t
Definition DeviceTypeConfig.cu.h:28
Definition pseudoPotentialToDftfeConverter.cc:34