1 /* CUDA API description. 2 Copyright (C) 2017-2018 Free Software Foundation, Inc. 3 4 This file is part of GCC. 5 6 GCC is free software; you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation; either version 3, or (at your option) 9 any later version. 10 11 GCC is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 Under Section 7 of GPL version 3, you are granted additional 17 permissions described in the GCC Runtime Library Exception, version 18 3.1, as published by the Free Software Foundation. 19 20 You should have received a copy of the GNU General Public License and 21 a copy of the GCC Runtime Library Exception along with this program; 22 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 23 <http://www.gnu.org/licenses/>. 24 25 This header provides the minimum amount of typedefs, enums and function 26 declarations to be able to compile plugin-nvptx.c if cuda.h and 27 libcuda.so.1 are not available. */ 28 29 #ifndef GCC_CUDA_H 30 #define GCC_CUDA_H 31 32 #include <stdlib.h> 33 34 #define CUDA_VERSION 8000 35 36 typedef void *CUcontext; 37 typedef int CUdevice; 38 #if defined(__LP64__) || defined(_WIN64) 39 typedef unsigned long long CUdeviceptr; 40 #else 41 typedef unsigned CUdeviceptr; 42 #endif 43 typedef void *CUevent; 44 typedef void *CUfunction; 45 typedef void *CUlinkState; 46 typedef void *CUmodule; 47 typedef void *CUstream; 48 49 typedef enum { 50 CUDA_SUCCESS = 0, 51 CUDA_ERROR_INVALID_VALUE = 1, 52 CUDA_ERROR_OUT_OF_MEMORY = 2, 53 CUDA_ERROR_INVALID_CONTEXT = 201, 54 CUDA_ERROR_NOT_FOUND = 500, 55 CUDA_ERROR_NOT_READY = 600, 56 CUDA_ERROR_LAUNCH_FAILED = 719 57 } CUresult; 58 59 typedef enum { 60 CU_DEVICE_ATTRIBUTE_MAX_THREADS_PER_BLOCK = 1, 61 CU_DEVICE_ATTRIBUTE_WARP_SIZE = 10, 62 CU_DEVICE_ATTRIBUTE_MAX_REGISTERS_PER_BLOCK = 12, 63 CU_DEVICE_ATTRIBUTE_CLOCK_RATE = 13, 64 CU_DEVICE_ATTRIBUTE_GPU_OVERLAP = 15, 65 CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT = 16, 66 CU_DEVICE_ATTRIBUTE_INTEGRATED = 18, 67 CU_DEVICE_ATTRIBUTE_CAN_MAP_HOST_MEMORY = 19, 68 CU_DEVICE_ATTRIBUTE_COMPUTE_MODE = 20, 69 CU_DEVICE_ATTRIBUTE_CONCURRENT_KERNELS = 31, 70 CU_DEVICE_ATTRIBUTE_MAX_THREADS_PER_MULTIPROCESSOR = 39, 71 CU_DEVICE_ATTRIBUTE_ASYNC_ENGINE_COUNT = 40, 72 CU_DEVICE_ATTRIBUTE_MAX_REGISTERS_PER_MULTIPROCESSOR = 82 73 } CUdevice_attribute; 74 75 enum { 76 CU_EVENT_DEFAULT = 0, 77 CU_EVENT_DISABLE_TIMING = 2 78 }; 79 80 typedef enum { 81 CU_FUNC_ATTRIBUTE_MAX_THREADS_PER_BLOCK = 0, 82 CU_FUNC_ATTRIBUTE_NUM_REGS = 4 83 } CUfunction_attribute; 84 85 typedef enum { 86 CU_JIT_WALL_TIME = 2, 87 CU_JIT_INFO_LOG_BUFFER = 3, 88 CU_JIT_INFO_LOG_BUFFER_SIZE_BYTES = 4, 89 CU_JIT_ERROR_LOG_BUFFER = 5, 90 CU_JIT_ERROR_LOG_BUFFER_SIZE_BYTES = 6, 91 CU_JIT_LOG_VERBOSE = 12 92 } CUjit_option; 93 94 typedef enum { 95 CU_JIT_INPUT_PTX = 1 96 } CUjitInputType; 97 98 enum { 99 CU_CTX_SCHED_AUTO = 0 100 }; 101 102 #define CU_LAUNCH_PARAM_END ((void *) 0) 103 #define CU_LAUNCH_PARAM_BUFFER_POINTER ((void *) 1) 104 #define CU_LAUNCH_PARAM_BUFFER_SIZE ((void *) 2) 105 106 enum { 107 CU_STREAM_DEFAULT = 0, 108 CU_STREAM_NON_BLOCKING = 1 109 }; 110 111 #define cuCtxCreate cuCtxCreate_v2 112 CUresult cuCtxCreate (CUcontext *, unsigned, CUdevice); 113 #define cuCtxDestroy cuCtxDestroy_v2 114 CUresult cuCtxDestroy (CUcontext); 115 CUresult cuCtxGetCurrent (CUcontext *); 116 CUresult cuCtxGetDevice (CUdevice *); 117 #define cuCtxPopCurrent cuCtxPopCurrent_v2 118 CUresult cuCtxPopCurrent (CUcontext *); 119 #define cuCtxPushCurrent cuCtxPushCurrent_v2 120 CUresult cuCtxPushCurrent (CUcontext); 121 CUresult cuCtxSynchronize (void); 122 CUresult cuDeviceGet (CUdevice *, int); 123 CUresult cuDeviceGetAttribute (int *, CUdevice_attribute, CUdevice); 124 CUresult cuDeviceGetCount (int *); 125 CUresult cuEventCreate (CUevent *, unsigned); 126 #define cuEventDestroy cuEventDestroy_v2 127 CUresult cuEventDestroy (CUevent); 128 CUresult cuEventElapsedTime (float *, CUevent, CUevent); 129 CUresult cuEventQuery (CUevent); 130 CUresult cuEventRecord (CUevent, CUstream); 131 CUresult cuEventSynchronize (CUevent); 132 CUresult cuFuncGetAttribute (int *, CUfunction_attribute, CUfunction); 133 CUresult cuGetErrorString (CUresult, const char **); 134 CUresult cuInit (unsigned); 135 CUresult cuLaunchKernel (CUfunction, unsigned, unsigned, unsigned, unsigned, 136 unsigned, unsigned, unsigned, CUstream, void **, void **); 137 #define cuLinkAddData cuLinkAddData_v2 138 CUresult cuLinkAddData (CUlinkState, CUjitInputType, void *, size_t, const char *, 139 unsigned, CUjit_option *, void **); 140 CUresult cuLinkComplete (CUlinkState, void **, size_t *); 141 #define cuLinkCreate cuLinkCreate_v2 142 CUresult cuLinkCreate (unsigned, CUjit_option *, void **, CUlinkState *); 143 CUresult cuLinkDestroy (CUlinkState); 144 #define cuMemAlloc cuMemAlloc_v2 145 CUresult cuMemAlloc (CUdeviceptr *, size_t); 146 #define cuMemAllocHost cuMemAllocHost_v2 147 CUresult cuMemAllocHost (void **, size_t); 148 CUresult cuMemcpy (CUdeviceptr, CUdeviceptr, size_t); 149 #define cuMemcpyDtoDAsync cuMemcpyDtoDAsync_v2 150 CUresult cuMemcpyDtoDAsync (CUdeviceptr, CUdeviceptr, size_t, CUstream); 151 #define cuMemcpyDtoH cuMemcpyDtoH_v2 152 CUresult cuMemcpyDtoH (void *, CUdeviceptr, size_t); 153 #define cuMemcpyDtoHAsync cuMemcpyDtoHAsync_v2 154 CUresult cuMemcpyDtoHAsync (void *, CUdeviceptr, size_t, CUstream); 155 #define cuMemcpyHtoD cuMemcpyHtoD_v2 156 CUresult cuMemcpyHtoD (CUdeviceptr, const void *, size_t); 157 #define cuMemcpyHtoDAsync cuMemcpyHtoDAsync_v2 158 CUresult cuMemcpyHtoDAsync (CUdeviceptr, const void *, size_t, CUstream); 159 #define cuMemFree cuMemFree_v2 160 CUresult cuMemFree (CUdeviceptr); 161 CUresult cuMemFreeHost (void *); 162 #define cuMemGetAddressRange cuMemGetAddressRange_v2 163 CUresult cuMemGetAddressRange (CUdeviceptr *, size_t *, CUdeviceptr); 164 #define cuMemHostGetDevicePointer cuMemHostGetDevicePointer_v2 165 CUresult cuMemHostGetDevicePointer (CUdeviceptr *, void *, unsigned); 166 CUresult cuModuleGetFunction (CUfunction *, CUmodule, const char *); 167 #define cuModuleGetGlobal cuModuleGetGlobal_v2 168 CUresult cuModuleGetGlobal (CUdeviceptr *, size_t *, CUmodule, const char *); 169 CUresult cuModuleLoad (CUmodule *, const char *); 170 CUresult cuModuleLoadData (CUmodule *, const void *); 171 CUresult cuModuleUnload (CUmodule); 172 CUresult cuStreamCreate (CUstream *, unsigned); 173 #define cuStreamDestroy cuStreamDestroy_v2 174 CUresult cuStreamDestroy (CUstream); 175 CUresult cuStreamQuery (CUstream); 176 CUresult cuStreamSynchronize (CUstream); 177 CUresult cuStreamWaitEvent (CUstream, CUevent, unsigned); 178 179 #endif /* GCC_CUDA_H */ 180