1 /* Minimal declarations for CUDA support.  Testing purposes only. */
2 #pragma once
3 
4 // Make this file work with nvcc, for testing compatibility.
5 
6 #ifndef __NVCC__
7 #define __constant__ __attribute__((constant))
8 #define __device__ __attribute__((device))
9 #define __global__ __attribute__((global))
10 #define __host__ __attribute__((host))
11 #define __shared__ __attribute__((shared))
12 #define __managed__ __attribute__((managed))
13 #define __launch_bounds__(...) __attribute__((launch_bounds(__VA_ARGS__)))
14 
15 struct dim3 {
16   unsigned x, y, z;
xdim317   __host__ __device__ dim3(unsigned x, unsigned y = 1, unsigned z = 1) : x(x), y(y), z(z) {}
18 };
19 
20 // Host- and device-side placement new overloads.
new(__SIZE_TYPE__,void * p)21 void *operator new(__SIZE_TYPE__, void *p) { return p; }
22 void *operator new[](__SIZE_TYPE__, void *p) { return p; }
new(__SIZE_TYPE__,void * p)23 __device__ void *operator new(__SIZE_TYPE__, void *p) { return p; }
24 __device__ void *operator new[](__SIZE_TYPE__, void *p) { return p; }
25 
26 #define CUDA_VERSION 10100
27 
28 struct char2 {
29   char x, y;
xchar230   __host__ __device__ char2(char x = 0, char y = 0) : x(x), y(y) {}
31 };
32 struct char4 {
33   char x, y, z, w;
xchar434   __host__ __device__ char4(char x = 0, char y = 0, char z = 0, char w = 0) : x(x), y(y), z(z), w(w) {}
35 };
36 
37 struct uchar2 {
38   unsigned char x, y;
xuchar239   __host__ __device__ uchar2(unsigned char x = 0, unsigned char y = 0) : x(x), y(y) {}
40 };
41 struct uchar4 {
42   unsigned char x, y, z, w;
xuchar443   __host__ __device__ uchar4(unsigned char x = 0, unsigned char y = 0, unsigned char z = 0, unsigned char w = 0) : x(x), y(y), z(z), w(w) {}
44 };
45 
46 struct short2 {
47   short x, y;
xshort248   __host__ __device__ short2(short x = 0, short y = 0) : x(x), y(y) {}
49 };
50 struct short4 {
51   short x, y, z, w;
xshort452   __host__ __device__ short4(short x = 0, short y = 0, short z = 0, short w = 0) : x(x), y(y), z(z), w(w) {}
53 };
54 
55 struct ushort2 {
56   unsigned short x, y;
xushort257   __host__ __device__ ushort2(unsigned short x = 0, unsigned short y = 0) : x(x), y(y) {}
58 };
59 struct ushort4 {
60   unsigned short x, y, z, w;
xushort461   __host__ __device__ ushort4(unsigned short x = 0, unsigned short y = 0, unsigned short z = 0, unsigned short w = 0) : x(x), y(y), z(z), w(w) {}
62 };
63 
64 struct int2 {
65   int x, y;
xint266   __host__ __device__ int2(int x = 0, int y = 0) : x(x), y(y) {}
67 };
68 struct int4 {
69   int x, y, z, w;
xint470   __host__ __device__ int4(int x = 0, int y = 0, int z = 0, int w = 0) : x(x), y(y), z(z), w(w) {}
71 };
72 
73 struct uint2 {
74   unsigned x, y;
xuint275   __host__ __device__ uint2(unsigned x = 0, unsigned y = 0) : x(x), y(y) {}
76 };
77 struct uint3 {
78   unsigned x, y, z;
xuint379   __host__ __device__ uint3(unsigned x = 0, unsigned y = 0, unsigned z = 0) : x(x), y(y), z(z) {}
80 };
81 struct uint4 {
82   unsigned x, y, z, w;
xuint483   __host__ __device__ uint4(unsigned x = 0, unsigned y = 0, unsigned z = 0, unsigned w = 0) : x(x), y(y), z(z), w(w) {}
84 };
85 
86 struct longlong2 {
87   long long x, y;
xlonglong288   __host__ __device__ longlong2(long long x = 0, long long y = 0) : x(x), y(y) {}
89 };
90 struct longlong4 {
91   long long x, y, z, w;
xlonglong492   __host__ __device__ longlong4(long long x = 0, long long y = 0, long long z = 0, long long w = 0) : x(x), y(y), z(z), w(w) {}
93 };
94 
95 struct ulonglong2 {
96   unsigned long long x, y;
xulonglong297   __host__ __device__ ulonglong2(unsigned long long x = 0, unsigned long long y = 0) : x(x), y(y) {}
98 };
99 struct ulonglong4 {
100   unsigned long long x, y, z, w;
xulonglong4101   __host__ __device__ ulonglong4(unsigned long long x = 0, unsigned long long y = 0, unsigned long long z = 0, unsigned long long w = 0) : x(x), y(y), z(z), w(w) {}
102 };
103 
104 struct float2 {
105   float x, y;
xfloat2106   __host__ __device__ float2(float x = 0, float y = 0) : x(x), y(y) {}
107 };
108 struct float4 {
109   float x, y, z, w;
xfloat4110   __host__ __device__ float4(float x = 0, float y = 0, float z = 0, float w = 0) : x(x), y(y), z(z), w(w) {}
111 };
112 
113 struct double2 {
114   double x, y;
xdouble2115   __host__ __device__ double2(double x = 0, double y = 0) : x(x), y(y) {}
116 };
117 struct double4 {
118   double x, y, z, w;
xdouble4119   __host__ __device__ double4(double x = 0, double y = 0, double z = 0, double w = 0) : x(x), y(y), z(z), w(w) {}
120 };
121 
122 typedef unsigned long long cudaTextureObject_t;
123 
124 enum cudaTextureReadMode {
125   cudaReadModeNormalizedFloat,
126   cudaReadModeElementType
127 };
128 
129 enum {
130   cudaTextureType1D,
131   cudaTextureType2D,
132   cudaTextureType3D,
133   cudaTextureTypeCubemap,
134   cudaTextureType1DLayered,
135   cudaTextureType2DLayered,
136   cudaTextureTypeCubemapLayered
137 };
138 
139 struct textureReference {};
140 template <class T, int texType = cudaTextureType1D,
141           enum cudaTextureReadMode mode = cudaReadModeElementType>
142 struct __attribute__((device_builtin_texture_type)) texture
143     : public textureReference {};
144 
145 #endif // !__NVCC__
146