32 #ifndef HERMES_COMMON_DEFS_H
33 #define HERMES_COMMON_DEFS_H
38 #if defined(ENABLE_CUDA)
40 #include <cuda_runtime.h>
43 #define HERMES_HOST_FUNCTION __host__
45 #define HERMES_DEVICE_CALLABLE __device__ __host__
47 #define HERMES_DEVICE_FUNCTION __device__
49 #define HERMES_DEVICE_ENABLED __CUDA_ARCH__
53 #define HERMES_CUDA_KERNEL(NAME) __global__ void NAME ## _k
55 #define HERMES_CUDA_CODE(CODE) {CODE}
59 #define HERMES_HOST_FUNCTION
60 #define HERMES_DEVICE_CALLABLE
61 #define HERMES_DEVICE_FUNCTION
62 #define HERMES_CUDA_CODE(CODE)
67 #include <type_traits>
72 #ifdef HERMES_USE_DOUBLE_AS_DEFAULT
123 #define MATCH_TYPE(Type) \
124 if((u8)DataType::Type == index) \
125 return DataType::Type;
136 return DataType::CUSTOM;
144 #define MATCH_TYPE(Type, R) \
145 if(std::is_same_v<T, Type>) \
157 return DataType::CUSTOM;
164 #define TYPE_SIZE(Size, Type) \
165 if(DataType::Type == type) \
167 TYPE_SIZE(
sizeof(
i8),
I8)
168 TYPE_SIZE(
sizeof(
i16),
I16)
169 TYPE_SIZE(
sizeof(
i32),
I32)
170 TYPE_SIZE(
sizeof(
i64),
I64)
171 TYPE_SIZE(
sizeof(
u8),
U8)
172 TYPE_SIZE(
sizeof(
u16),
U16)
173 TYPE_SIZE(
sizeof(
u32),
U32)
174 TYPE_SIZE(
sizeof(
u64),
U64)
175 TYPE_SIZE(
sizeof(
f32),
F32)
176 TYPE_SIZE(
sizeof(
f64),
F64)
184 #define DATA_TYPE_NAME(Type) \
185 if(DataType::Type == type) \
200 #undef DATA_TYPE_NAME
213 #define ENUM_NAME(E) \
214 if(MemoryLocation::E == location) \
DataType set of auxiliary functions.
Definition: defs.h:117
static std::string typeName(DataType type)
Gets DataType string name.
Definition: defs.h:183
static u32 typeSize(DataType type)
Computes number of bytes from DataType.
Definition: defs.h:163
static HERMES_DEVICE_CALLABLE DataType typeFrom(u8 index)
Translates DataType from identifier number.
Definition: defs.h:122
static HERMES_DEVICE_CALLABLE DataType typeFrom()
Translates template type T to DataType.
Definition: defs.h:143
std::string memoryLocationName(MemoryLocation location)
Gets MemoryLocation value string name.
Definition: defs.h:212
DataType
Enum class for integral types.
Definition: defs.h:101
@ CUSTOM
unidentified type
MemoryLocation
Specifies where memory is stored.
Definition: defs.h:204
int8_t i8
8 bit size integer type
Definition: defs.h:81
uint64_t u64
64 bit size unsigned integer type
Definition: defs.h:89
float real_t
default floating point type
Definition: defs.h:75
unsigned long ulong
unsigned long type
Definition: defs.h:91
#define HERMES_DEVICE_CALLABLE
Specifies that the function can be called from both host and device sides.
Definition: defs.h:45
unsigned int uint
unsigned int type
Definition: defs.h:92
uint16_t u16
16 bit size unsigned integer type
Definition: defs.h:87
uint32_t u32
32 bit size unsigned integer type
Definition: defs.h:88
int64_t i64
64 bit size integer type
Definition: defs.h:84
int16_t i16
16 bit size integer type
Definition: defs.h:82
uint8_t u8
8 bit size unsigned integer type
Definition: defs.h:86
double f64
64 bit size floating point type
Definition: defs.h:79
float f32
32 bit size floating point type
Definition: defs.h:78
unsigned char uchar
unsigned char type
Definition: defs.h:94
unsigned short ushort
unsigned short type
Definition: defs.h:93
int32_t i32
32 bit size integer type
Definition: defs.h:83
@ location
logs code location