brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.3 KiB · 405ef8b Raw
55 lines · c
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 16struct dim3 {17  unsigned x, y, z;18  __host__ __device__ dim3(unsigned x, unsigned y = 1, unsigned z = 1) : x(x), y(y), z(z) {}19};20 21#ifdef __HIP__22typedef struct hipStream *hipStream_t;23typedef enum hipError {} hipError_t;24int hipConfigureCall(dim3 gridSize, dim3 blockSize, size_t sharedSize = 0,25                     hipStream_t stream = 0);26extern "C" hipError_t __hipPushCallConfiguration(dim3 gridSize, dim3 blockSize,27                                                 size_t sharedSize = 0,28                                                 hipStream_t stream = 0);29extern "C" hipError_t hipLaunchKernel(const void *func, dim3 gridDim,30                                      dim3 blockDim, void **args,31                                      size_t sharedMem,32                                      hipStream_t stream);33#else34typedef struct cudaStream *cudaStream_t;35typedef enum cudaError {} cudaError_t;36 37extern "C" int cudaConfigureCall(dim3 gridSize, dim3 blockSize,38                                 size_t sharedSize = 0,39                                 cudaStream_t stream = 0);40extern "C" int __cudaPushCallConfiguration(dim3 gridSize, dim3 blockSize,41                                           size_t sharedSize = 0,42                                           cudaStream_t stream = 0);43extern "C" cudaError_t cudaLaunchKernel(const void *func, dim3 gridDim,44                                        dim3 blockDim, void **args,45                                        size_t sharedMem, cudaStream_t stream);46#endif47 48// Host- and device-side placement new overloads.49void *operator new(__SIZE_TYPE__, void *p) { return p; }50void *operator new[](__SIZE_TYPE__, void *p) { return 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