52 #define MGPU_MIN(x, y) (((x) <= (y)) ? (x) : (y))
53 #define MGPU_MAX(x, y) (((x) >= (y)) ? (x) : (y))
54 #define MGPU_MAX0(x) (((x) >= 0) ? (x) : 0)
55 #define MGPU_ABS(x) (((x) >= 0) ? (x) : (-x))
57 #define MGPU_DIV_UP(x, y) (((x) + (y) - 1) / (y))
58 #define MGPU_DIV_ROUND(x, y) (((x) + (y) / 2) / (y))
59 #define MGPU_ROUND_UP(x, y) ((y) * MGPU_DIV_UP(x, y))
60 #define MGPU_SHIFT_DIV_UP(x, y) (((x) + ((1<< (y)) - 1))>> y)
61 #define MGPU_ROUND_UP_POW2(x, y) (((x) + (y) - 1) & ~((y) - 1))
62 #define MGPU_ROUND_DOWN_POW2(x, y) ((x) & ~((y) - 1))
63 #define MGPU_IS_POW_2(x) (0 == ((x) & ((x) - 1)))
70 typedef unsigned char byte;
83 enum {
value = 0 == (X & (X - 1)) };
87 template<
int X,
bool roundUp = true>
struct sLogPow2 {
92 template<
bool roundUp>
struct sLogPow2<0, roundUp> {
96 template<
bool roundUp>
struct sLogPow2<1, roundUp> {
101 template<
int X,
int Y>
113 template<
int X,
int Y>
122 template<
int X,
int Y>
124 enum { rem = X % Y };
125 enum {
value = X + (rem ? (Y - rem) : 0) };
128 template<
int X,
int Y>
130 enum { rem = X % Y };
138 template<
int X,
int Y>
140 enum {
value = X / (Y ? Y : (X + 1)) };
143 template<
int X,
int Y>
147 template<
int X,
int Y>
160 enum { shifted = X >> 1 };
177 enum { count = NT * X };