27 #ifndef bits_gpulog_ttraits_h__
28 #define bits_gpulog_ttraits_h__
30 #if GPULOG_DEBUG && !__CUDACC__
35 #define _USE_MATH_DEFINES
37 #define __alignof__ __alignof
47 template<
typename T>
struct alignment {
static const int value = __alignof__(T); };
51 template<>
struct alignment<float2> {
static const int value = 8; };
52 template<>
struct alignment<float4> {
static const int value = 16; };
53 template<>
struct alignment<char2> {
static const int value = 2; };
54 template<>
struct alignment<char4> {
static const int value = 4; };
55 template<>
struct alignment<uchar2> {
static const int value = 2; };
56 template<>
struct alignment<uchar4> {
static const int value = 4; };
57 template<>
struct alignment<short2> {
static const int value = 4; };
58 template<>
struct alignment<short4> {
static const int value = 8; };
59 template<>
struct alignment<ushort2> {
static const int value = 4; };
60 template<>
struct alignment<ushort4> {
static const int value = 8; };
61 template<>
struct alignment<int2> {
static const int value = 8; };
62 template<>
struct alignment<int4> {
static const int value = 16; };
63 template<>
struct alignment<uint2> {
static const int value = 8; };
64 template<>
struct alignment<uint4> {
static const int value = 16; };
65 template<>
struct alignment<long2> {
static const int value = 2*alignment<long1>::value; };
66 template<>
struct alignment<long4> {
static const int value = 4*alignment<long1>::value; };
67 template<>
struct alignment<ulong2> {
static const int value = 2*alignment<ulong1>::value; };
68 template<>
struct alignment<ulong4> {
static const int value = 4*alignment<ulong1>::value; };
69 template<>
struct alignment<double2> {
static const int value = 16; };
78 static const size_t size =
sizeof(T);
81 static const bool isptr =
false;
83 static const bool isarr =
false;
85 static const bool isunspec =
false;
87 static const size_t dim = 1;
94 static const bool isptr =
true;
98 template<
typename T,
int N>
101 static const size_t dim = N;
108 static const bool isarr =
true;
116 static const bool isunspec =
true;
118 static const size_t size = 0;
119 static const size_t align = 1;
120 static const bool isptr =
false;
121 static const bool isarr =
false;
122 static const size_t dim = 0;
127 #define ALIGNOF(T) (ttrait<T>::align)
130 #define ESIZE(T) (ttrait<T>::size)
133 #define DIMEN(T) (ttrait<T>::dim)
136 #define SIZEOF(T) (ESIZE(T)*DIMEN(T))
139 #define ISARRAY(T) (ttrait<T>::isarr)
142 #define SCALAR(T) typename gpulog::internal::ttrait<T>::scalarT
143 #define ISUNSPEC(T) (ttrait<T>::isunspec)
145 #if GPULOG_DEBUG && !__CUDACC__
147 void dump_ttraits(
const T& obj)
149 std::cerr <<
"align = " <<
ALIGNOF(T) <<
"\n";
150 std::cerr <<
"element size = " <<
ESIZE(T) <<
"\n";
151 std::cerr <<
"dimen = " <<
DIMEN(T) <<
"\n";
152 std::cerr <<
"sizeof = " <<
SIZEOF(T) <<
"\n";
153 std::cerr <<
"isarray = " <<
ISARRAY(T) <<
"\n";
154 std::cerr <<
"isunspec = " << ISUNSPEC(T) <<
"\n";
161 #endif // bits_gpulog_ttraits_h__