20 #ifndef MIRTK_CudaRuntime_H 21 #define MIRTK_CudaRuntime_H 25 # include <cuda_runtime.h> 36 typedef unsigned char uchar;
37 typedef unsigned int uint;
38 typedef unsigned short ushort;
40 #if defined(__VECTOR_TYPES_H__) 42 #define __vector1_type__(tag, type) using tag 43 #define __vector2_type__(tag, type) using tag 44 #define __vector3_type__(tag, type) using tag 45 #define __vector4_type__(tag, type) using tag 47 #else // __VECTOR_TYPES_H__ 49 #define __vector1_type__(tag, type) \ 50 struct tag { type x; }; \ 51 typedef struct tag tag 52 #define __vector2_type__(tag, type) \ 53 struct tag { type x; type y; }; \ 54 typedef struct tag tag 55 #define __vector3_type__(tag, type) \ 56 struct tag { type x; type y; type z; }; \ 57 typedef struct tag tag 58 #define __vector4_type__(tag, type) \ 59 struct tag { type x; type y; type z; type w; }; \ 60 typedef struct tag tag 62 #endif // __VECTOR_TYPES_H__ 65 #define __vector_type__(type) \ 66 __vector1_type__(type##1, type); \ 67 __vector2_type__(type##2, type); \ 68 __vector3_type__(type##3, type); \ 69 __vector4_type__(type##4, type) 71 __vector_type__(
char);
72 __vector_type__(uchar);
73 __vector_type__(
short);
74 __vector_type__(ushort);
76 __vector_type__(uint);
77 __vector_type__(
float);
78 __vector_type__(
double);
80 #undef __vector_type__ 81 #undef __vector1_type__ 82 #undef __vector2_type__ 83 #undef __vector3_type__ 84 #undef __vector4_type__ 87 #if defined(__VECTOR_TYPES_H__) 93 dim3(uint vx = 1, uint vy = 1, uint vz = 1) : x(vx), y(vy), z(vz) {}
94 dim3(uint3 v) : x(v.x), y(v.y), z(v.z) {}
95 operator uint3() { uint3 t; t.x = x; t.y = y; t.z = z;
return t; }
97 typedef struct dim3 dim3;
98 #endif // !defined(__VECTOR_TYPES_H__) 104 #define __vector1_func__(type) \ 105 inline type##1 make_##type##1(type x) \ 107 type##1 t; t.x = x; return t; \ 110 #define __vector2_func__(type) \ 111 inline type##2 make_##type##2(type x, type y) \ 113 type##2 t; t.x = x, t.y = y; return t; \ 116 #define __vector3_func__(type) \ 117 inline type##3 make_##type##3(type x, type y, type z) \ 119 type##3 t; t.x = x, t.y = y, t.z = z; return t; \ 122 #define __vector4_func__(type) \ 123 inline type##4 make_##type##4(type x, type y, type z, type w) \ 125 type##4 t; t.x = x, t.y = y, t.z = z, t.w = w; return t; \ 128 #define __vector_func__(type) \ 129 __vector1_func__(type); \ 130 __vector2_func__(type); \ 131 __vector3_func__(type); \ 132 __vector4_func__(type) 134 __vector_func__(
char);
135 __vector_func__(uchar);
136 __vector_func__(
short);
137 __vector_func__(ushort);
138 __vector_func__(
int);
139 __vector_func__(uint);
140 __vector_func__(
float);
141 __vector_func__(
double);
143 #undef __vector_func__ 144 #undef __vector1_func__ 145 #undef __vector2_func__ 146 #undef __vector3_func__ 147 #undef __vector4_func__ 152 #endif // MIRTK_CudaRuntime_H