brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.0 KiB · de6f7fb Raw
65 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 __grid_constant__ __attribute__((grid_constant))15#define __launch_bounds__(...) __attribute__((launch_bounds(__VA_ARGS__)))16#define __cluster_dims__(...) __attribute__((cluster_dims(__VA_ARGS__)))17#define __no_cluster__ __attribute__((no_cluster))18 19struct dim3 {20  unsigned x, y, z;21  __host__ __device__ dim3(unsigned x, unsigned y = 1, unsigned z = 1) : x(x), y(y), z(z) {}22};23 24#ifdef __HIP__25typedef struct hipStream *hipStream_t;26typedef enum hipError {} hipError_t;27int hipConfigureCall(dim3 gridSize, dim3 blockSize, size_t sharedSize = 0,28                     hipStream_t stream = 0);29extern "C" hipError_t __hipPushCallConfiguration(dim3 gridSize, dim3 blockSize,30                                                 size_t sharedSize = 0,31                                                 hipStream_t stream = 0);32extern "C" hipError_t hipLaunchKernel(const void *func, dim3 gridDim,33                                      dim3 blockDim, void **args,34                                      size_t sharedMem,35                                      hipStream_t stream);36#else37typedef struct cudaStream *cudaStream_t;38typedef enum cudaError {} cudaError_t;39 40extern "C" int cudaConfigureCall(dim3 gridSize, dim3 blockSize,41                                 size_t sharedSize = 0,42                                 cudaStream_t stream = 0);43extern "C" int __cudaPushCallConfiguration(dim3 gridSize, dim3 blockSize,44                                           size_t sharedSize = 0,45                                           cudaStream_t stream = 0);46extern "C" cudaError_t cudaLaunchKernel(const void *func, dim3 gridDim,47                                        dim3 blockDim, void **args,48                                        size_t sharedMem, cudaStream_t stream);49extern "C" __device__ cudaError_t cudaLaunchDevice(void *func,50                                                   void *parameterBuffer,51                                                   dim3 gridDim, dim3 blockDim,52                                                   unsigned int sharedMem,53                                                   cudaStream_t stream);54extern "C" __device__ void *cudaGetParameterBuffer(size_t alignment,55                                                   size_t size);56#endif57 58// Host- and device-side placement new overloads.59void *operator new(__SIZE_TYPE__, void *p) { return p; }60void *operator new[](__SIZE_TYPE__, void *p) { return p; }61__device__ void *operator new(__SIZE_TYPE__, void *p) { return p; }62__device__ void *operator new[](__SIZE_TYPE__, void *p) { return p; }63 64#endif // !__NVCC__65