1 /* Minimal declarations for CUDA support. Testing purposes only. */ 2 3 #include <stddef.h> 4 5 // Make this file work with nvcc, for testing compatibility. 6 7 #ifndef __NVCC__ 8 #define __constant__ __attribute__((constant)) 9 #define __device__ __attribute__((device)) 10 #define __global__ __attribute__((global)) 11 #define __host__ __attribute__((host)) 12 #define __shared__ __attribute__((shared)) 13 #define __managed__ __attribute__((managed)) 14 #define __grid_constant__ __attribute__((grid_constant)) 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 #ifdef __HIP__ 23 typedef struct hipStream *hipStream_t; 24 typedef enum hipError {} hipError_t; 25 int hipConfigureCall(dim3 gridSize, dim3 blockSize, size_t sharedSize = 0, 26 hipStream_t stream = 0); 27 extern "C" hipError_t __hipPushCallConfiguration(dim3 gridSize, dim3 blockSize, 28 size_t sharedSize = 0, 29 hipStream_t stream = 0); 30 extern "C" hipError_t hipLaunchKernel(const void *func, dim3 gridDim, 31 dim3 blockDim, void **args, 32 size_t sharedMem, 33 hipStream_t stream); 34 #else 35 typedef struct cudaStream *cudaStream_t; 36 typedef enum cudaError {} cudaError_t; 37 38 extern "C" int cudaConfigureCall(dim3 gridSize, dim3 blockSize, 39 size_t sharedSize = 0, 40 cudaStream_t stream = 0); 41 extern "C" int __cudaPushCallConfiguration(dim3 gridSize, dim3 blockSize, 42 size_t sharedSize = 0, 43 cudaStream_t stream = 0); 44 extern "C" cudaError_t cudaLaunchKernel(const void *func, dim3 gridDim, 45 dim3 blockDim, void **args, 46 size_t sharedMem, cudaStream_t stream); 47 #endif 48 49 // Host- and device-side placement new overloads. 50 void *operator new(__SIZE_TYPE__, void *p) { return p; } 51 void *operator new[](__SIZE_TYPE__, void *p) { return p; } 52 __device__ void *operator new(__SIZE_TYPE__, void *p) { return p; } 53 __device__ void *operator new[](__SIZE_TYPE__, void *p) { return p; } 54 55 #endif // !__NVCC__ 56