ABACUS
develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
source
source_base
module_device
device_helpers.h
Go to the documentation of this file.
1
#ifndef DEVICE_HELPERS_H_
2
#define DEVICE_HELPERS_H_
3
12
13
#include "
types.h
"
14
#include <complex>
15
#include <string>
16
#include <type_traits>
17
18
namespace
base_device
19
{
20
21
// Forward declaration
22
class
DeviceContext
;
23
30
template
<
typename
Device>
31
AbacusDevice_t
get_device_type
(
const
Device* dev)
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
45
template
<
typename
T>
46
std::string
get_current_precision
(
const
T
* var);
47
48
// Template specialization declarations
49
template
<>
50
std::string
get_current_precision<float>
(
const
float
* var);
51
52
template
<>
53
std::string
get_current_precision<double>
(
const
double
* var);
54
55
template
<>
56
std::string
get_current_precision<std::complex<float>
>(
const
std::complex<float>* var);
57
58
template
<>
59
std::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_
base_device::DeviceContext
Singleton class to manage GPU device context and initialization.
Definition
device.h:98
T
#define T
Definition
exp.cpp:237
base_device
Definition
device.cpp:21
base_device::get_current_precision< double >
std::string get_current_precision< double >(const double *var)
Definition
device_helpers.cpp:14
base_device::get_current_precision
std::string get_current_precision(const T *var)
Get the precision string for a given numeric type.
base_device::get_current_precision< float >
std::string get_current_precision< float >(const float *var)
Definition
device_helpers.cpp:8
base_device::AbacusDevice_t
AbacusDevice_t
Definition
types.h:12
base_device::GpuDevice
@ GpuDevice
Definition
types.h:15
base_device::UnKnown
@ UnKnown
Definition
types.h:13
base_device::CpuDevice
@ CpuDevice
Definition
types.h:14
base_device::DspDevice
@ DspDevice
Definition
types.h:16
base_device::get_device_type
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
types.h
Generated by
1.15.0