-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathcudaUtils.h
More file actions
44 lines (34 loc) · 967 Bytes
/
cudaUtils.h
File metadata and controls
44 lines (34 loc) · 967 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#ifndef CUFFTADVISOR_CUDAUTILS_H_
#define CUFFTADVISOR_CUDAUTILS_H_
#include <cuda_runtime.h>
#include "cudaAsserts.h"
#include "utils.h"
namespace cuFFTAdvisor {
static inline int getDeviceCount() {
int deviceCount = 0;
gpuErrchk(cudaGetDeviceCount(&deviceCount));
return deviceCount;
}
static inline size_t getFreeMemory(int dev) {
gpuErrchk(cudaSetDevice(dev));
size_t free, total;
gpuErrchk(cudaMemGetInfo(&free, &total));
return free;
}
static inline size_t getTotalMemory(int dev) {
gpuErrchk(cudaSetDevice(dev));
size_t free, total;
gpuErrchk(cudaMemGetInfo(&free, &total));
return total;
}
static inline cufftHandle createPlan() {
cufftHandle plan;
gpuErrchkFFT(cufftCreate(&plan));
return plan;
}
static inline void resetDevice() { gpuErrchk(cudaDeviceReset()); }
static inline void destroyPlan(cufftHandle &plan) {
gpuErrchkFFT(cufftDestroy(plan));
}
} // namespace cuFFTAdvisor
#endif // CUFFTADVISOR_CUDAUTILS_H_