-
Notifications
You must be signed in to change notification settings - Fork 0
/
limits.hpp
51 lines (39 loc) · 1.59 KB
/
limits.hpp
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
45
46
47
48
49
50
51
#ifndef __CUDA_LIMITS_HPP
#define __CUDA_LIMITS_HPP
#if defined(_WIN32)
typedef unsigned short ushort;
typedef unsigned int uint;
#endif
#include <limits.h>
namespace cudahack {
template <class T> struct numeric_limits;
template <> struct numeric_limits<short> {
__device__ __forceinline__ static short min() { return SHRT_MIN; }
__device__ __forceinline__ static short max() { return SHRT_MAX; }
};
template <> struct numeric_limits<ushort> {
__device__ __forceinline__ static ushort min() { return 0; }
__device__ __forceinline__ static ushort max() { return USHRT_MAX; }
};
template <> struct numeric_limits<int> {
__device__ __forceinline__ static int min() { return INT_MIN; }
__device__ __forceinline__ static int max() { return INT_MAX; }
};
template <> struct numeric_limits<uint> {
__device__ __forceinline__ static uint min() { return 0; }
__device__ __forceinline__ static uint max() { return UINT_MAX; }
};
template <> struct numeric_limits<unsigned long long int> {
__device__ __forceinline__ static unsigned long long int min() { return 0; }
__device__ __forceinline__ static unsigned long long int max() { return ULLONG_MAX; }
};
template <> struct numeric_limits<float> {
__device__ __forceinline__ static float min() { return FLT_MIN; }
__device__ __forceinline__ static float max() { return FLT_MAX; }
};
template <> struct numeric_limits<double> {
__device__ __forceinline__ static double min() { return DBL_MIN; }
__device__ __forceinline__ static double max() { return DBL_MAX; }
};
}
#endif