Skip to content

Commit bdff739

Browse files
authored
cuda clang: Clean up test dependency for CUDA surfaces (#134459)
#132883 added support for cuda surfaces but reached into clang/test/Headers/ from clang/test/CodeGen/ to grab the minimal cuda.h. Duplicate that file instead based on comments in the review, to fix remote test runs. Signed-off-by: Austin Schuh <[email protected]>
1 parent e3369a8 commit bdff739

File tree

3 files changed

+198
-2
lines changed

3 files changed

+198
-2
lines changed

clang/test/CodeGen/include/cuda.h

Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
/* Minimal declarations for CUDA support. Testing purposes only.
2+
* This should stay in sync with clang/test/Headers/Inputs/include/cuda.h
3+
*/
4+
#pragma once
5+
6+
// Make this file work with nvcc, for testing compatibility.
7+
8+
#ifndef __NVCC__
9+
#define __constant__ __attribute__((constant))
10+
#define __device__ __attribute__((device))
11+
#define __global__ __attribute__((global))
12+
#define __host__ __attribute__((host))
13+
#define __shared__ __attribute__((shared))
14+
#define __managed__ __attribute__((managed))
15+
#define __launch_bounds__(...) __attribute__((launch_bounds(__VA_ARGS__)))
16+
17+
struct dim3 {
18+
unsigned x, y, z;
19+
__host__ __device__ dim3(unsigned x, unsigned y = 1, unsigned z = 1) : x(x), y(y), z(z) {}
20+
};
21+
22+
// Host- and device-side placement new overloads.
23+
void *operator new(__SIZE_TYPE__, void *p) { return p; }
24+
void *operator new[](__SIZE_TYPE__, void *p) { return p; }
25+
__device__ void *operator new(__SIZE_TYPE__, void *p) { return p; }
26+
__device__ void *operator new[](__SIZE_TYPE__, void *p) { return p; }
27+
28+
#define CUDA_VERSION 10100
29+
30+
struct char1 {
31+
char x;
32+
__host__ __device__ char1(char x = 0) : x(x) {}
33+
};
34+
struct char2 {
35+
char x, y;
36+
__host__ __device__ char2(char x = 0, char y = 0) : x(x), y(y) {}
37+
};
38+
struct char4 {
39+
char x, y, z, w;
40+
__host__ __device__ char4(char x = 0, char y = 0, char z = 0, char w = 0) : x(x), y(y), z(z), w(w) {}
41+
};
42+
43+
struct uchar1 {
44+
unsigned char x;
45+
__host__ __device__ uchar1(unsigned char x = 0) : x(x) {}
46+
};
47+
struct uchar2 {
48+
unsigned char x, y;
49+
__host__ __device__ uchar2(unsigned char x = 0, unsigned char y = 0) : x(x), y(y) {}
50+
};
51+
struct uchar4 {
52+
unsigned char x, y, z, w;
53+
__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) {}
54+
};
55+
56+
struct short1 {
57+
short x;
58+
__host__ __device__ short1(short x = 0) : x(x) {}
59+
};
60+
struct short2 {
61+
short x, y;
62+
__host__ __device__ short2(short x = 0, short y = 0) : x(x), y(y) {}
63+
};
64+
struct short4 {
65+
short x, y, z, w;
66+
__host__ __device__ short4(short x = 0, short y = 0, short z = 0, short w = 0) : x(x), y(y), z(z), w(w) {}
67+
};
68+
69+
struct ushort1 {
70+
unsigned short x;
71+
__host__ __device__ ushort1(unsigned short x = 0) : x(x) {}
72+
};
73+
struct ushort2 {
74+
unsigned short x, y;
75+
__host__ __device__ ushort2(unsigned short x = 0, unsigned short y = 0) : x(x), y(y) {}
76+
};
77+
struct ushort4 {
78+
unsigned short x, y, z, w;
79+
__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) {}
80+
};
81+
82+
struct int1 {
83+
int x;
84+
__host__ __device__ int1(int x = 0) : x(x) {}
85+
};
86+
struct int2 {
87+
int x, y;
88+
__host__ __device__ int2(int x = 0, int y = 0) : x(x), y(y) {}
89+
};
90+
struct int4 {
91+
int x, y, z, w;
92+
__host__ __device__ int4(int x = 0, int y = 0, int z = 0, int w = 0) : x(x), y(y), z(z), w(w) {}
93+
};
94+
95+
struct uint1 {
96+
unsigned x;
97+
__host__ __device__ uint1(unsigned x = 0) : x(x) {}
98+
};
99+
struct uint2 {
100+
unsigned x, y;
101+
__host__ __device__ uint2(unsigned x = 0, unsigned y = 0) : x(x), y(y) {}
102+
};
103+
struct uint3 {
104+
unsigned x, y, z;
105+
__host__ __device__ uint3(unsigned x = 0, unsigned y = 0, unsigned z = 0) : x(x), y(y), z(z) {}
106+
};
107+
struct uint4 {
108+
unsigned x, y, z, w;
109+
__host__ __device__ uint4(unsigned x = 0, unsigned y = 0, unsigned z = 0, unsigned w = 0) : x(x), y(y), z(z), w(w) {}
110+
};
111+
112+
struct longlong1 {
113+
long long x;
114+
__host__ __device__ longlong1(long long x = 0) : x(x) {}
115+
};
116+
struct longlong2 {
117+
long long x, y;
118+
__host__ __device__ longlong2(long long x = 0, long long y = 0) : x(x), y(y) {}
119+
};
120+
struct longlong4 {
121+
long long x, y, z, w;
122+
__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) {}
123+
};
124+
125+
struct ulonglong1 {
126+
unsigned long long x;
127+
__host__ __device__ ulonglong1(unsigned long long x = 0) : x(x) {}
128+
};
129+
struct ulonglong2 {
130+
unsigned long long x, y;
131+
__host__ __device__ ulonglong2(unsigned long long x = 0, unsigned long long y = 0) : x(x), y(y) {}
132+
};
133+
struct ulonglong4 {
134+
unsigned long long x, y, z, w;
135+
__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) {}
136+
};
137+
138+
struct float1 {
139+
float x;
140+
__host__ __device__ float1(float x = 0) : x(x) {}
141+
};
142+
struct float2 {
143+
float x, y;
144+
__host__ __device__ float2(float x = 0, float y = 0) : x(x), y(y) {}
145+
};
146+
struct float4 {
147+
float x, y, z, w;
148+
__host__ __device__ float4(float x = 0, float y = 0, float z = 0, float w = 0) : x(x), y(y), z(z), w(w) {}
149+
};
150+
151+
struct double1 {
152+
double x;
153+
__host__ __device__ double1(double x = 0) : x(x) {}
154+
};
155+
struct double2 {
156+
double x, y;
157+
__host__ __device__ double2(double x = 0, double y = 0) : x(x), y(y) {}
158+
};
159+
struct double4 {
160+
double x, y, z, w;
161+
__host__ __device__ double4(double x = 0, double y = 0, double z = 0, double w = 0) : x(x), y(y), z(z), w(w) {}
162+
};
163+
164+
typedef unsigned long long cudaTextureObject_t;
165+
typedef unsigned long long cudaSurfaceObject_t;
166+
167+
enum cudaTextureReadMode {
168+
cudaReadModeNormalizedFloat,
169+
cudaReadModeElementType
170+
};
171+
172+
enum cudaSurfaceBoundaryMode {
173+
cudaBoundaryModeZero,
174+
cudaBoundaryModeClamp,
175+
cudaBoundaryModeTrap
176+
};
177+
178+
enum {
179+
cudaTextureType1D,
180+
cudaTextureType2D,
181+
cudaTextureType3D,
182+
cudaTextureTypeCubemap,
183+
cudaTextureType1DLayered,
184+
cudaTextureType2DLayered,
185+
cudaTextureTypeCubemapLayered
186+
};
187+
188+
struct textureReference {};
189+
template <class T, int texType = cudaTextureType1D,
190+
enum cudaTextureReadMode mode = cudaReadModeElementType>
191+
struct __attribute__((device_builtin_texture_type)) texture
192+
: public textureReference {};
193+
194+
#endif // !__NVCC__

clang/test/CodeGen/nvptx-surface.cu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// RUN: %clang_cc1 -triple nvptx-unknown-unknown -fcuda-is-device -O3 -o - %s -emit-llvm | FileCheck %s
22
// RUN: %clang_cc1 -triple nvptx64-unknown-unknown -fcuda-is-device -O3 -o - %s -emit-llvm | FileCheck %s
3-
#include "../Headers/Inputs/include/cuda.h"
3+
#include "include/cuda.h"
44

55
#include "__clang_cuda_texture_intrinsics.h"
66

clang/test/Headers/Inputs/include/cuda.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
/* Minimal declarations for CUDA support. Testing purposes only. */
1+
/* Minimal declarations for CUDA support. Testing purposes only.
2+
* This should stay in sync with clang/test/CodeGen/include/cuda.h
3+
*/
24
#pragma once
35

46
// Make this file work with nvcc, for testing compatibility.

0 commit comments

Comments
 (0)