|
| 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__ |
0 commit comments