195 lines · c
1/* Minimal declarations for CUDA support. Testing purposes only.2 * This should stay in sync with clang/test/CodeGen/include/cuda.h3 */4#pragma once5 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 17struct 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.23void *operator new(__SIZE_TYPE__, void *p) { return p; }24void *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 1010029 30struct char1 {31 char x;32 __host__ __device__ char1(char x = 0) : x(x) {}33};34struct char2 {35 char x, y;36 __host__ __device__ char2(char x = 0, char y = 0) : x(x), y(y) {}37};38struct 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 43struct uchar1 {44 unsigned char x;45 __host__ __device__ uchar1(unsigned char x = 0) : x(x) {}46};47struct uchar2 {48 unsigned char x, y;49 __host__ __device__ uchar2(unsigned char x = 0, unsigned char y = 0) : x(x), y(y) {}50};51struct 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 56struct short1 {57 short x;58 __host__ __device__ short1(short x = 0) : x(x) {}59};60struct short2 {61 short x, y;62 __host__ __device__ short2(short x = 0, short y = 0) : x(x), y(y) {}63};64struct 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 69struct ushort1 {70 unsigned short x;71 __host__ __device__ ushort1(unsigned short x = 0) : x(x) {}72};73struct ushort2 {74 unsigned short x, y;75 __host__ __device__ ushort2(unsigned short x = 0, unsigned short y = 0) : x(x), y(y) {}76};77struct 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 82struct int1 {83 int x;84 __host__ __device__ int1(int x = 0) : x(x) {}85};86struct int2 {87 int x, y;88 __host__ __device__ int2(int x = 0, int y = 0) : x(x), y(y) {}89};90struct 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 95struct uint1 {96 unsigned x;97 __host__ __device__ uint1(unsigned x = 0) : x(x) {}98};99struct uint2 {100 unsigned x, y;101 __host__ __device__ uint2(unsigned x = 0, unsigned y = 0) : x(x), y(y) {}102};103struct 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};107struct 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 112struct longlong1 {113 long long x;114 __host__ __device__ longlong1(long long x = 0) : x(x) {}115};116struct longlong2 {117 long long x, y;118 __host__ __device__ longlong2(long long x = 0, long long y = 0) : x(x), y(y) {}119};120struct 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 125struct ulonglong1 {126 unsigned long long x;127 __host__ __device__ ulonglong1(unsigned long long x = 0) : x(x) {}128};129struct 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};133struct 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 138struct float1 {139 float x;140 __host__ __device__ float1(float x = 0) : x(x) {}141};142struct float2 {143 float x, y;144 __host__ __device__ float2(float x = 0, float y = 0) : x(x), y(y) {}145};146struct 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 151struct double1 {152 double x;153 __host__ __device__ double1(double x = 0) : x(x) {}154};155struct double2 {156 double x, y;157 __host__ __device__ double2(double x = 0, double y = 0) : x(x), y(y) {}158};159struct 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 164typedef unsigned long long cudaTextureObject_t;165typedef unsigned long long cudaSurfaceObject_t;166 167enum cudaTextureReadMode {168 cudaReadModeNormalizedFloat,169 cudaReadModeElementType170};171 172enum cudaSurfaceBoundaryMode {173 cudaBoundaryModeZero,174 cudaBoundaryModeClamp,175 cudaBoundaryModeTrap176};177 178enum {179 cudaTextureType1D,180 cudaTextureType2D,181 cudaTextureType3D,182 cudaTextureTypeCubemap,183 cudaTextureType1DLayered,184 cudaTextureType2DLayered,185 cudaTextureTypeCubemapLayered186};187 188struct textureReference {};189template <class T, int texType = cudaTextureType1D,190 enum cudaTextureReadMode mode = cudaReadModeElementType>191struct __attribute__((device_builtin_texture_type)) texture192 : public textureReference {};193 194#endif // !__NVCC__195