Skip to content

Commit 8f3418d

Browse files
committed
Move code to cuda.h, and fix issues that causes
1 parent 1e63674 commit 8f3418d

File tree

6 files changed

+181
-185
lines changed

6 files changed

+181
-185
lines changed

clang/test/CodeGenCUDA/Inputs/cuda.h

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,172 @@ extern "C" cudaError_t cudaLaunchKernel_ptsz(const void *func, dim3 gridDim,
7272
#endif
7373

7474
extern "C" __device__ int printf(const char*, ...);
75+
76+
struct char1 {
77+
char x;
78+
__host__ __device__ char1(char x = 0) : x(x) {}
79+
};
80+
struct char2 {
81+
char x, y;
82+
__host__ __device__ char2(char x = 0, char y = 0) : x(x), y(y) {}
83+
};
84+
struct char4 {
85+
char x, y, z, w;
86+
__host__ __device__ char4(char x = 0, char y = 0, char z = 0, char w = 0) : x(x), y(y), z(z), w(w) {}
87+
};
88+
89+
struct uchar1 {
90+
unsigned char x;
91+
__host__ __device__ uchar1(unsigned char x = 0) : x(x) {}
92+
};
93+
struct uchar2 {
94+
unsigned char x, y;
95+
__host__ __device__ uchar2(unsigned char x = 0, unsigned char y = 0) : x(x), y(y) {}
96+
};
97+
struct uchar4 {
98+
unsigned char x, y, z, w;
99+
__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) {}
100+
};
101+
102+
struct short1 {
103+
short x;
104+
__host__ __device__ short1(short x = 0) : x(x) {}
105+
};
106+
struct short2 {
107+
short x, y;
108+
__host__ __device__ short2(short x = 0, short y = 0) : x(x), y(y) {}
109+
};
110+
struct short4 {
111+
short x, y, z, w;
112+
__host__ __device__ short4(short x = 0, short y = 0, short z = 0, short w = 0) : x(x), y(y), z(z), w(w) {}
113+
};
114+
115+
struct ushort1 {
116+
unsigned short x;
117+
__host__ __device__ ushort1(unsigned short x = 0) : x(x) {}
118+
};
119+
struct ushort2 {
120+
unsigned short x, y;
121+
__host__ __device__ ushort2(unsigned short x = 0, unsigned short y = 0) : x(x), y(y) {}
122+
};
123+
struct ushort4 {
124+
unsigned short x, y, z, w;
125+
__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) {}
126+
};
127+
128+
struct int1 {
129+
int x;
130+
__host__ __device__ int1(int x = 0) : x(x) {}
131+
};
132+
struct int2 {
133+
int x, y;
134+
__host__ __device__ int2(int x = 0, int y = 0) : x(x), y(y) {}
135+
};
136+
struct int4 {
137+
int x, y, z, w;
138+
__host__ __device__ int4(int x = 0, int y = 0, int z = 0, int w = 0) : x(x), y(y), z(z), w(w) {}
139+
};
140+
141+
struct uint1 {
142+
unsigned x;
143+
__host__ __device__ uint1(unsigned x = 0) : x(x) {}
144+
};
145+
struct uint2 {
146+
unsigned x, y;
147+
__host__ __device__ uint2(unsigned x = 0, unsigned y = 0) : x(x), y(y) {}
148+
};
149+
struct uint3 {
150+
unsigned x, y, z;
151+
__host__ __device__ uint3(unsigned x = 0, unsigned y = 0, unsigned z = 0) : x(x), y(y), z(z) {}
152+
};
153+
struct uint4 {
154+
unsigned x, y, z, w;
155+
__host__ __device__ uint4(unsigned x = 0, unsigned y = 0, unsigned z = 0, unsigned w = 0) : x(x), y(y), z(z), w(w) {}
156+
};
157+
158+
struct longlong1 {
159+
long long x;
160+
__host__ __device__ longlong1(long long x = 0) : x(x) {}
161+
};
162+
struct longlong2 {
163+
long long x, y;
164+
__host__ __device__ longlong2(long long x = 0, long long y = 0) : x(x), y(y) {}
165+
};
166+
struct longlong4 {
167+
long long x, y, z, w;
168+
__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) {}
169+
};
170+
171+
struct ulonglong1 {
172+
unsigned long long x;
173+
__host__ __device__ ulonglong1(unsigned long long x = 0) : x(x) {}
174+
};
175+
struct ulonglong2 {
176+
unsigned long long x, y;
177+
__host__ __device__ ulonglong2(unsigned long long x = 0, unsigned long long y = 0) : x(x), y(y) {}
178+
};
179+
struct ulonglong4 {
180+
unsigned long long x, y, z, w;
181+
__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) {}
182+
};
183+
184+
struct float1 {
185+
float x;
186+
__host__ __device__ float1(float x = 0) : x(x) {}
187+
};
188+
struct float2 {
189+
float x, y;
190+
__host__ __device__ float2(float x = 0, float y = 0) : x(x), y(y) {}
191+
};
192+
struct float4 {
193+
float x, y, z, w;
194+
__host__ __device__ float4(float x = 0, float y = 0, float z = 0, float w = 0) : x(x), y(y), z(z), w(w) {}
195+
};
196+
197+
struct double1 {
198+
double x;
199+
__host__ __device__ double1(double x = 0) : x(x) {}
200+
};
201+
struct double2 {
202+
double x, y;
203+
__host__ __device__ double2(double x = 0, double y = 0) : x(x), y(y) {}
204+
};
205+
struct double4 {
206+
double x, y, z, w;
207+
__host__ __device__ double4(double x = 0, double y = 0, double z = 0, double w = 0) : x(x), y(y), z(z), w(w) {}
208+
};
209+
210+
typedef unsigned long long cudaTextureObject_t;
211+
typedef unsigned long long cudaSurfaceObject_t;
212+
213+
enum cudaTextureReadMode {
214+
cudaReadModeNormalizedFloat,
215+
cudaReadModeElementType
216+
};
217+
218+
enum cudaSurfaceBoundaryMode {
219+
cudaBoundaryModeZero,
220+
cudaBoundaryModeClamp,
221+
cudaBoundaryModeTrap
222+
};
223+
224+
enum {
225+
cudaTextureType1D,
226+
cudaTextureType2D,
227+
cudaTextureType3D,
228+
cudaTextureTypeCubemap,
229+
cudaTextureType1DLayered,
230+
cudaTextureType2DLayered,
231+
cudaTextureTypeCubemapLayered
232+
};
233+
234+
struct textureReference { };
235+
template <class T, int texType = cudaTextureType1D,
236+
enum cudaTextureReadMode mode = cudaReadModeElementType>
237+
struct __attribute__((device_builtin_texture_type)) texture
238+
: public textureReference {};
239+
240+
struct surfaceReference { int desc; };
241+
242+
template <typename T, int dim = 1>
243+
struct __attribute__((device_builtin_surface_type)) surface : public surfaceReference {};

clang/test/CodeGenCUDA/correctly-rounded-div.cu

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
#include "Inputs/cuda.h"
1010

11-
typedef __attribute__(( ext_vector_type(4) )) float float4;
11+
typedef __attribute__(( ext_vector_type(4) )) float floatvec4;
1212

1313
// COMMON-LABEL: @_Z11spscalardiv
1414
// COMMON: fdiv{{.*}},
@@ -22,7 +22,7 @@ __device__ float spscalardiv(float a, float b) {
2222
// COMMON: fdiv{{.*}},
2323
// NCRDIV: !fpmath ![[MD]]
2424
// CRDIV-NOT: !fpmath
25-
__device__ float4 spvectordiv(float4 a, float4 b) {
25+
__device__ floatvec4 spvectordiv(floatvec4 a, floatvec4 b) {
2626
return a / b;
2727
}
2828

clang/test/CodeGenCUDA/nvptx-surface.cu

Lines changed: 0 additions & 164 deletions
Original file line numberDiff line numberDiff line change
@@ -2,170 +2,6 @@
22
// RUN: %clang_cc1 -triple nvptx64-unknown-unknown -fcuda-is-device -O3 -o - %s -emit-llvm | FileCheck %s
33
#include "Inputs/cuda.h"
44

5-
struct char1 {
6-
char x;
7-
__host__ __device__ char1(char x = 0) : x(x) {}
8-
};
9-
struct char2 {
10-
char x, y;
11-
__host__ __device__ char2(char x = 0, char y = 0) : x(x), y(y) {}
12-
};
13-
struct char4 {
14-
char x, y, z, w;
15-
__host__ __device__ char4(char x = 0, char y = 0, char z = 0, char w = 0) : x(x), y(y), z(z), w(w) {}
16-
};
17-
18-
struct uchar1 {
19-
unsigned char x;
20-
__host__ __device__ uchar1(unsigned char x = 0) : x(x) {}
21-
};
22-
struct uchar2 {
23-
unsigned char x, y;
24-
__host__ __device__ uchar2(unsigned char x = 0, unsigned char y = 0) : x(x), y(y) {}
25-
};
26-
struct uchar4 {
27-
unsigned char x, y, z, w;
28-
__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) {}
29-
};
30-
31-
struct short1 {
32-
short x;
33-
__host__ __device__ short1(short x = 0) : x(x) {}
34-
};
35-
struct short2 {
36-
short x, y;
37-
__host__ __device__ short2(short x = 0, short y = 0) : x(x), y(y) {}
38-
};
39-
struct short4 {
40-
short x, y, z, w;
41-
__host__ __device__ short4(short x = 0, short y = 0, short z = 0, short w = 0) : x(x), y(y), z(z), w(w) {}
42-
};
43-
44-
struct ushort1 {
45-
unsigned short x;
46-
__host__ __device__ ushort1(unsigned short x = 0) : x(x) {}
47-
};
48-
struct ushort2 {
49-
unsigned short x, y;
50-
__host__ __device__ ushort2(unsigned short x = 0, unsigned short y = 0) : x(x), y(y) {}
51-
};
52-
struct ushort4 {
53-
unsigned short x, y, z, w;
54-
__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) {}
55-
};
56-
57-
struct int1 {
58-
int x;
59-
__host__ __device__ int1(int x = 0) : x(x) {}
60-
};
61-
struct int2 {
62-
int x, y;
63-
__host__ __device__ int2(int x = 0, int y = 0) : x(x), y(y) {}
64-
};
65-
struct int4 {
66-
int x, y, z, w;
67-
__host__ __device__ int4(int x = 0, int y = 0, int z = 0, int w = 0) : x(x), y(y), z(z), w(w) {}
68-
};
69-
70-
struct uint1 {
71-
unsigned x;
72-
__host__ __device__ uint1(unsigned x = 0) : x(x) {}
73-
};
74-
struct uint2 {
75-
unsigned x, y;
76-
__host__ __device__ uint2(unsigned x = 0, unsigned y = 0) : x(x), y(y) {}
77-
};
78-
struct uint3 {
79-
unsigned x, y, z;
80-
__host__ __device__ uint3(unsigned x = 0, unsigned y = 0, unsigned z = 0) : x(x), y(y), z(z) {}
81-
};
82-
struct uint4 {
83-
unsigned x, y, z, w;
84-
__host__ __device__ uint4(unsigned x = 0, unsigned y = 0, unsigned z = 0, unsigned w = 0) : x(x), y(y), z(z), w(w) {}
85-
};
86-
87-
struct longlong1 {
88-
long long x;
89-
__host__ __device__ longlong1(long long x = 0) : x(x) {}
90-
};
91-
struct longlong2 {
92-
long long x, y;
93-
__host__ __device__ longlong2(long long x = 0, long long y = 0) : x(x), y(y) {}
94-
};
95-
struct longlong4 {
96-
long long x, y, z, w;
97-
__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) {}
98-
};
99-
100-
struct ulonglong1 {
101-
unsigned long long x;
102-
__host__ __device__ ulonglong1(unsigned long long x = 0) : x(x) {}
103-
};
104-
struct ulonglong2 {
105-
unsigned long long x, y;
106-
__host__ __device__ ulonglong2(unsigned long long x = 0, unsigned long long y = 0) : x(x), y(y) {}
107-
};
108-
struct ulonglong4 {
109-
unsigned long long x, y, z, w;
110-
__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) {}
111-
};
112-
113-
struct float1 {
114-
float x;
115-
__host__ __device__ float1(float x = 0) : x(x) {}
116-
};
117-
struct float2 {
118-
float x, y;
119-
__host__ __device__ float2(float x = 0, float y = 0) : x(x), y(y) {}
120-
};
121-
struct float4 {
122-
float x, y, z, w;
123-
__host__ __device__ float4(float x = 0, float y = 0, float z = 0, float w = 0) : x(x), y(y), z(z), w(w) {}
124-
};
125-
126-
struct double1 {
127-
double x;
128-
__host__ __device__ double1(double x = 0) : x(x) {}
129-
};
130-
struct double2 {
131-
double x, y;
132-
__host__ __device__ double2(double x = 0, double y = 0) : x(x), y(y) {}
133-
};
134-
struct double4 {
135-
double x, y, z, w;
136-
__host__ __device__ double4(double x = 0, double y = 0, double z = 0, double w = 0) : x(x), y(y), z(z), w(w) {}
137-
};
138-
139-
typedef unsigned long long cudaTextureObject_t;
140-
typedef unsigned long long cudaSurfaceObject_t;
141-
142-
enum cudaTextureReadMode {
143-
cudaReadModeNormalizedFloat,
144-
cudaReadModeElementType
145-
};
146-
147-
enum cudaSurfaceBoundaryMode {
148-
cudaBoundaryModeZero,
149-
cudaBoundaryModeClamp,
150-
cudaBoundaryModeTrap
151-
};
152-
153-
enum {
154-
cudaTextureType1D,
155-
cudaTextureType2D,
156-
cudaTextureType3D,
157-
cudaTextureTypeCubemap,
158-
cudaTextureType1DLayered,
159-
cudaTextureType2DLayered,
160-
cudaTextureTypeCubemapLayered
161-
};
162-
163-
struct textureReference {};
164-
template <class T, int texType = cudaTextureType1D,
165-
enum cudaTextureReadMode mode = cudaReadModeElementType>
166-
struct __attribute__((device_builtin_texture_type)) texture
167-
: public textureReference {};
168-
1695
#include "__clang_cuda_texture_intrinsics.h"
1706

1717
__device__ void surfchar(cudaSurfaceObject_t surf, int x, int y, int z, int layer, int face, int layerface) {

0 commit comments

Comments
 (0)