Skip to content

Commit 75e941b

Browse files
committed
[NFC][OpenMP][CUDA] Add test for using -x cuda -fopenmp
This adds a very basic test in `cuda_with_openmp.cu` that just checks whether the CUDA & OpenMP integrated headers do compile, when a CUDA file is compiled with OpenMP (CPU) enabled. Thus this basically adds the missing test for https://reviews.llvm.org/D90415. Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D105322
1 parent 99f0063 commit 75e941b

26 files changed

+195
-2
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// required for __clang_cuda_runtime_wrapper.h tests
2+
#pragma once
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// required for __clang_cuda_runtime_wrapper.h tests
2+
#pragma once
3+
__device__ void __brkpt();
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// required for __clang_cuda_runtime_wrapper.h tests
2+
#pragma once
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// required for __clang_cuda_runtime_wrapper.h tests
2+
#pragma once
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// required for __clang_cuda_runtime_wrapper.h tests
2+
#pragma once
3+
__device__ int __isinff(float);
4+
__device__ int __isinf(double);
5+
__device__ int __finitef(float);
6+
__device__ int __isfinited(double);
7+
__device__ int __isnanf(float);
8+
__device__ int __isnan(double);
9+
__device__ int __signbitf(float);
10+
__device__ int __signbitd(double);
11+
__device__ double max(double, double);
12+
__device__ float max(float, float);
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// required for __clang_cuda_runtime_wrapper.h tests
2+
#pragma once

clang/test/Headers/Inputs/include/cstdlib

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@
55
#if __cplusplus >= 201703L
66
extern int abs (int __x) throw() __attribute__ ((__const__)) ;
77
extern long int labs (long int __x) throw() __attribute__ ((__const__)) ;
8-
extern float fabs (float __x) throw() __attribute__ ((__const__)) ;
98
#else
109
extern int abs (int __x) __attribute__ ((__const__)) ;
1110
extern long int labs (long int __x) __attribute__ ((__const__)) ;
12-
extern float fabs (float __x) __attribute__ ((__const__)) ;
1311
#endif
1412

1513
namespace std
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
/* Minimal declarations for CUDA support. Testing purposes only. */
2+
#pragma once
3+
4+
#include <stddef.h>
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 char2 {
31+
char x, y;
32+
__host__ __device__ char2(char x = 0, char y = 0) : x(x), y(y) {}
33+
};
34+
struct char4 {
35+
char x, y, z, w;
36+
__host__ __device__ char4(char x = 0, char y = 0, char z = 0, char w = 0) : x(x), y(y), z(z), w(w) {}
37+
};
38+
39+
struct uchar2 {
40+
unsigned char x, y;
41+
__host__ __device__ uchar2(unsigned char x = 0, unsigned char y = 0) : x(x), y(y) {}
42+
};
43+
struct uchar4 {
44+
unsigned char x, y, z, w;
45+
__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) {}
46+
};
47+
48+
struct short2 {
49+
short x, y;
50+
__host__ __device__ short2(short x = 0, short y = 0) : x(x), y(y) {}
51+
};
52+
struct short4 {
53+
short x, y, z, w;
54+
__host__ __device__ short4(short x = 0, short y = 0, short z = 0, short w = 0) : x(x), y(y), z(z), w(w) {}
55+
};
56+
57+
struct ushort2 {
58+
unsigned short x, y;
59+
__host__ __device__ ushort2(unsigned short x = 0, unsigned short y = 0) : x(x), y(y) {}
60+
};
61+
struct ushort4 {
62+
unsigned short x, y, z, w;
63+
__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) {}
64+
};
65+
66+
struct int2 {
67+
int x, y;
68+
__host__ __device__ int2(int x = 0, int y = 0) : x(x), y(y) {}
69+
};
70+
struct int4 {
71+
int x, y, z, w;
72+
__host__ __device__ int4(int x = 0, int y = 0, int z = 0, int w = 0) : x(x), y(y), z(z), w(w) {}
73+
};
74+
75+
struct uint2 {
76+
unsigned x, y;
77+
__host__ __device__ uint2(unsigned x = 0, unsigned y = 0) : x(x), y(y) {}
78+
};
79+
struct uint3 {
80+
unsigned x, y, z;
81+
__host__ __device__ uint3(unsigned x = 0, unsigned y = 0, unsigned z = 0) : x(x), y(y), z(z) {}
82+
};
83+
struct uint4 {
84+
unsigned x, y, z, w;
85+
__host__ __device__ uint4(unsigned x = 0, unsigned y = 0, unsigned z = 0, unsigned w = 0) : x(x), y(y), z(z), w(w) {}
86+
};
87+
88+
89+
struct longlong2 {
90+
long long x, y;
91+
__host__ __device__ longlong2(long long x = 0, long long y = 0) : x(x), y(y) {}
92+
};
93+
struct longlong4 {
94+
long long x, y, z, w;
95+
__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) {}
96+
};
97+
98+
struct ulonglong2 {
99+
unsigned long long x, y;
100+
__host__ __device__ ulonglong2(unsigned long long x = 0, unsigned long long y = 0) : x(x), y(y) {}
101+
};
102+
struct ulonglong4 {
103+
unsigned long long x, y, z, w;
104+
__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) {}
105+
};
106+
107+
108+
struct float2 {
109+
float x, y;
110+
__host__ __device__ float2(float x = 0, float y = 0) : x(x), y(y) {}
111+
};
112+
struct float4 {
113+
float x, y, z, w;
114+
__host__ __device__ float4(float x = 0, float y = 0, float z = 0, float w = 0) : x(x), y(y), z(z), w(w) {}
115+
};
116+
117+
struct double2 {
118+
double x, y;
119+
__host__ __device__ double2(double x = 0, double y = 0) : x(x), y(y) {}
120+
};
121+
struct double4 {
122+
double x, y, z, w;
123+
__host__ __device__ double4(double x = 0, double y = 0, double z = 0, double w = 0) : x(x), y(y), z(z), w(w) {}
124+
};
125+
126+
127+
#endif // !__NVCC__
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// required for __clang_cuda_runtime_wrapper.h tests
2+
#pragma once
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// required for __clang_cuda_runtime_wrapper.h tests
2+
#pragma once

0 commit comments

Comments
 (0)