forked from facebookarchive/fbcuda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NumericLimits.cuh
51 lines (41 loc) · 1.11 KB
/
NumericLimits.cuh
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
// Copyright 2004-present Facebook. All Rights Reserved.
#pragma once
#include <math_constants.h>
namespace facebook { namespace cuda {
/// Numeric limits for CUDA
template <typename T>
struct NumericLimits {};
template<>
struct NumericLimits<float> {
/// The minimum possible valid float (i.e., not NaN)
__device__ __forceinline__ static float minPossible() {
return -CUDART_INF_F;
}
/// The maximum possible valid float (i.e., not NaN)
__device__ __forceinline__ static float maxPossible() {
return CUDART_INF_F;
}
};
template<>
struct NumericLimits<int> {
/// The minimum possible int
__device__ __forceinline__ static int minPossible() {
return INT_MIN;
}
/// The maximum possible int
__device__ __forceinline__ static int maxPossible() {
return INT_MAX;
}
};
template<>
struct NumericLimits<unsigned int> {
/// The minimum possible unsigned int
__device__ __forceinline__ static unsigned int minPossible() {
return 0;
}
/// The maximum possible unsigned int
__device__ __forceinline__ static unsigned int maxPossible() {
return UINT_MAX;
}
};
} } // namespace