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 __launch_bounds__(...) __attribute__((launch_bounds(__VA_ARGS__)))
15 
16 struct dim3 {
17   unsigned x, y, z;
xdim318   __host__ __device__ dim3(unsigned x, unsigned y = 1, unsigned z = 1) : x(x), y(y), z(z) {}
19 };
20 
21 #ifdef __HIP__
22 typedef struct hipStream *hipStream_t;
23 typedef enum hipError {} hipError_t;
24 int hipConfigureCall(dim3 gridSize, dim3 blockSize, size_t sharedSize = 0,
25                      hipStream_t stream = 0);
26 extern "C" hipError_t __hipPushCallConfiguration(dim3 gridSize, dim3 blockSize,
27                                                  size_t sharedSize = 0,
28                                                  hipStream_t stream = 0);
29 extern "C" hipError_t hipLaunchKernel(const void *func, dim3 gridDim,
30                                       dim3 blockDim, void **args,
31                                       size_t sharedMem,
32                                       hipStream_t stream);
33 #else
34 typedef struct cudaStream *cudaStream_t;
35 typedef enum cudaError {} cudaError_t;
36 
37 extern "C" int cudaConfigureCall(dim3 gridSize, dim3 blockSize,
38                                  size_t sharedSize = 0,
39                                  cudaStream_t stream = 0);
40 extern "C" int __cudaPushCallConfiguration(dim3 gridSize, dim3 blockSize,
41                                            size_t sharedSize = 0,
42                                            cudaStream_t stream = 0);
43 extern "C" cudaError_t cudaLaunchKernel(const void *func, dim3 gridDim,
44                                         dim3 blockDim, void **args,
45                                         size_t sharedMem, cudaStream_t stream);
46 #endif
47 
48 // Host- and device-side placement new overloads.
new(__SIZE_TYPE__,void * p)49 void *operator new(__SIZE_TYPE__, void *p) { return p; }
50 void *operator new[](__SIZE_TYPE__, void *p) { return p; }
new(__SIZE_TYPE__,void * p)51 __device__ void *operator new(__SIZE_TYPE__, void *p) { return p; }
52 __device__ void *operator new[](__SIZE_TYPE__, void *p) { return p; }
53 
54 #endif // !__NVCC__
55