ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
device_helpers.h
Go to the documentation of this file.
1#ifndef DEVICE_HELPERS_H_
2#define DEVICE_HELPERS_H_
3
13#include "types.h"
14#include <complex>
15#include <string>
16#include <type_traits>
17
18namespace base_device
19{
20
21// Forward declaration
22class DeviceContext;
23
30template <typename Device>
32{
33 if (std::is_same<Device, DEVICE_CPU>::value) return CpuDevice;
34 else if (std::is_same<Device, DEVICE_GPU>::value) return GpuDevice;
35 else if (std::is_same<Device, DEVICE_DSP>::value) return DspDevice;
36 else return UnKnown;
37}
38
45template <typename T>
46std::string get_current_precision(const T* var);
47
48// Template specialization declarations
49template <>
50std::string get_current_precision<float>(const float* var);
51
52template <>
53std::string get_current_precision<double>(const double* var);
54
55template <>
56std::string get_current_precision<std::complex<float>>(const std::complex<float>* var);
57
58template <>
59std::string get_current_precision<std::complex<double>>(const std::complex<double>* var);
60
61} // end of namespace base_device
62
63#endif // DEVICE_HELPERS_H_
#define T
Definition exp.cpp:237
Definition device.cpp:21
std::string get_current_precision< double >(const double *var)
Definition device_helpers.cpp:14
std::string get_current_precision(const T *var)
Get the precision string for a given numeric type.
std::string get_current_precision< float >(const float *var)
Definition device_helpers.cpp:8
AbacusDevice_t
Definition types.h:12
@ GpuDevice
Definition types.h:15
@ UnKnown
Definition types.h:13
@ CpuDevice
Definition types.h:14
@ DspDevice
Definition types.h:16
AbacusDevice_t get_device_type(const Device *dev)
Get the device type enum for a given device type (compile-time version).
Definition device_helpers.h:31