DFT-FE 1.3.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>
8# include <iostream>
9# include <source_location>
10namespace dftfe
11{
12 namespace utils
13 {
15 deviceReset();
16
18 deviceMemGetInfo(std::size_t *free, std::size_t *total);
19
21 getDeviceCount(int *count);
22
24 getDevice(int *deviceId);
25
27 setDevice(int deviceId);
28
30 deviceMalloc(void **devPtr, std::size_t size);
31
33 deviceMemset(void *devPtr, int value, std::size_t count);
34
35 /**
36 * @brief
37 * @param devPtr
38 * @param value
39 * @param size
40 */
41 template <typename ValueType>
42 void
43 deviceSetValue(ValueType *devPtr, ValueType value, std::size_t size);
44
46 deviceFree(void *devPtr);
47
49 deviceHostMalloc(void **hostPtr, std::size_t size);
50
52 deviceHostFree(void *hostPtr);
53
54 /**
55 * @brief Copy array from device to host
56 * @param count The memory size in bytes of the array
57 */
59 deviceMemcpyD2H(void *dst, const void *src, std::size_t count);
60
61 /**
62 * @brief Copy array from device to device
63 * @param count The memory size in bytes of the array
64 */
66 deviceMemcpyD2D(void *dst, const void *src, std::size_t count);
67
68 /**
69 * @brief Copy array from host to device
70 * @param count The memory size in bytes of the array
71 */
73 deviceMemcpyH2D(void *dst, const void *src, std::size_t count);
74
75 /**
76 * @brief Copy 2D array from device to host
77 * @param count The memory size in bytes of the array
78 */
80 deviceMemcpyD2H_2D(void *dst,
81 std::size_t dpitch,
82 const void *src,
83 std::size_t spitch,
84 std::size_t width,
85 std::size_t height);
86
87 /**
88 * @brief Copy 2D array from device to device
89 * @param count The memory size in bytes of the array
90 */
92 deviceMemcpyD2D_2D(void *dst,
93 std::size_t dpitch,
94 const void *src,
95 std::size_t spitch,
96 std::size_t width,
97 std::size_t height);
98
99 /**
100 * @brief Copy 2D array from host to device
101 * @param count The memory size in bytes of the array
102 */
104 deviceMemcpyH2D_2D(void *dst,
105 std::size_t dpitch,
106 const void *src,
107 std::size_t spitch,
108 std::size_t width,
109 std::size_t height);
110
111 /**
112 * @brief HOST-DEVICE synchronization
113 */
115 deviceSynchronize();
116
117 /**
118 * @brief Copy array from device to host
119 * @param count The memory size in bytes of the array
120 */
122 deviceMemcpyAsyncD2H(void *dst,
123 const void *src,
124 std::size_t count,
126
127 /**
128 * @brief Copy array from device to device
129 * @param count The memory size in bytes of the array
130 */
132 deviceMemcpyAsyncD2D(void *dst,
133 const void *src,
134 std::size_t count,
136
137 /**
138 * @brief Copy array from host to device
139 * @param count The memory size in bytes of the array
140 */
142 deviceMemcpyAsyncH2D(void *dst,
143 const void *src,
144 std::size_t count,
146
147
149 deviceStreamCreate(deviceStream_t &pStream, const bool nonBlocking = false);
150
152 deviceStreamDestroy(deviceStream_t &stream);
153
155 deviceStreamSynchronize(deviceStream_t &stream);
156
158 deviceEventCreate(deviceEvent_t &pEvent);
159
161 deviceEventDestroy(deviceEvent_t &event);
162
164 deviceEventRecord(deviceEvent_t &event,
166
168 deviceEventSynchronize(deviceEvent_t &event);
169
171 deviceStreamWaitEvent(deviceStream_t &stream,
172 deviceEvent_t &event,
173 unsigned int flags = 0);
174
175 } // namespace utils
176} // namespace dftfe
177
178# endif // dftfeDeviceAPICalls_H
179#endif // DFTFE_WITH_DEVICE
Definition Cell.h:36
cudaError_t deviceError_t
Definition DeviceTypeConfig.cu.h:26
cudaEvent_t deviceEvent_t
Definition DeviceTypeConfig.cu.h:28
cudaStream_t deviceStream_t
Definition DeviceTypeConfig.cu.h:27
static cudaStream_t defaultStream
Definition DeviceTypeConfig.cu.h:62
Definition pseudoPotentialToDftfeConverter.cc:34