1 /* CUDA Driver API description.
2 Copyright (C) 2017-2022 Free Software Foundation, Inc.
4 This file is part of GCC.
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)
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.
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.
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/>.
25 This header provides parts of the CUDA Driver API, without having to rely on
26 the proprietary CUDA toolkit. */
33 #define CUDA_VERSION 8000
39 typedef void *CUcontext
;
41 #if defined(__LP64__) || defined(_WIN64)
42 typedef unsigned long long CUdeviceptr
;
44 typedef unsigned CUdeviceptr
;
46 typedef void *CUevent
;
47 typedef void *CUfunction
;
48 typedef void *CUlinkState
;
49 typedef void *CUmodule
;
50 typedef size_t (*CUoccupancyB2DSize
)(int);
51 typedef void *CUstream
;
55 CUDA_ERROR_INVALID_VALUE
= 1,
56 CUDA_ERROR_OUT_OF_MEMORY
= 2,
57 CUDA_ERROR_INVALID_CONTEXT
= 201,
58 CUDA_ERROR_NOT_FOUND
= 500,
59 CUDA_ERROR_NOT_READY
= 600,
60 CUDA_ERROR_LAUNCH_FAILED
= 719,
61 CUDA_ERROR_COOPERATIVE_LAUNCH_TOO_LARGE
= 720,
62 CUDA_ERROR_NOT_PERMITTED
= 800,
63 CUDA_ERROR_NOT_SUPPORTED
= 801,
64 CUDA_ERROR_UNKNOWN
= 999
68 CU_DEVICE_ATTRIBUTE_MAX_THREADS_PER_BLOCK
= 1,
69 CU_DEVICE_ATTRIBUTE_WARP_SIZE
= 10,
70 CU_DEVICE_ATTRIBUTE_MAX_REGISTERS_PER_BLOCK
= 12,
71 CU_DEVICE_ATTRIBUTE_CLOCK_RATE
= 13,
72 CU_DEVICE_ATTRIBUTE_GPU_OVERLAP
= 15,
73 CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT
= 16,
74 CU_DEVICE_ATTRIBUTE_INTEGRATED
= 18,
75 CU_DEVICE_ATTRIBUTE_CAN_MAP_HOST_MEMORY
= 19,
76 CU_DEVICE_ATTRIBUTE_COMPUTE_MODE
= 20,
77 CU_DEVICE_ATTRIBUTE_CONCURRENT_KERNELS
= 31,
78 CU_DEVICE_ATTRIBUTE_MAX_THREADS_PER_MULTIPROCESSOR
= 39,
79 CU_DEVICE_ATTRIBUTE_ASYNC_ENGINE_COUNT
= 40,
80 CU_DEVICE_ATTRIBUTE_MAX_REGISTERS_PER_MULTIPROCESSOR
= 82
85 CU_EVENT_DISABLE_TIMING
= 2
89 CU_FUNC_ATTRIBUTE_MAX_THREADS_PER_BLOCK
= 0,
90 CU_FUNC_ATTRIBUTE_NUM_REGS
= 4
91 } CUfunction_attribute
;
95 CU_JIT_INFO_LOG_BUFFER
= 3,
96 CU_JIT_INFO_LOG_BUFFER_SIZE_BYTES
= 4,
97 CU_JIT_ERROR_LOG_BUFFER
= 5,
98 CU_JIT_ERROR_LOG_BUFFER_SIZE_BYTES
= 6,
99 CU_JIT_OPTIMIZATION_LEVEL
= 7,
100 CU_JIT_GENERATE_DEBUG_INFO
= 11,
101 CU_JIT_LOG_VERBOSE
= 12,
102 CU_JIT_GENERATE_LINE_INFO
= 13,
110 CU_CTX_SCHED_AUTO
= 0
113 #define CU_LAUNCH_PARAM_END ((void *) 0)
114 #define CU_LAUNCH_PARAM_BUFFER_POINTER ((void *) 1)
115 #define CU_LAUNCH_PARAM_BUFFER_SIZE ((void *) 2)
118 CU_STREAM_DEFAULT
= 0,
119 CU_STREAM_NON_BLOCKING
= 1
123 CU_LIMIT_STACK_SIZE
= 0x00,
124 CU_LIMIT_MALLOC_HEAP_SIZE
= 0x02,
127 #define cuCtxCreate cuCtxCreate_v2
128 CUresult
cuCtxCreate (CUcontext
*, unsigned, CUdevice
);
129 #define cuCtxDestroy cuCtxDestroy_v2
130 CUresult
cuCtxDestroy (CUcontext
);
131 CUresult
cuCtxGetCurrent (CUcontext
*);
132 CUresult
cuCtxGetDevice (CUdevice
*);
133 #define cuCtxPopCurrent cuCtxPopCurrent_v2
134 CUresult
cuCtxPopCurrent (CUcontext
*);
135 #define cuCtxPushCurrent cuCtxPushCurrent_v2
136 CUresult
cuCtxPushCurrent (CUcontext
);
137 CUresult
cuCtxSynchronize (void);
138 CUresult
cuCtxSetLimit (CUlimit
, size_t);
139 CUresult
cuDeviceGet (CUdevice
*, int);
140 #define cuDeviceTotalMem cuDeviceTotalMem_v2
141 CUresult
cuDeviceTotalMem (size_t *, CUdevice
);
142 CUresult
cuDeviceGetAttribute (int *, CUdevice_attribute
, CUdevice
);
143 CUresult
cuDeviceGetCount (int *);
144 CUresult
cuDeviceGetName (char *, int, CUdevice
);
145 CUresult
cuEventCreate (CUevent
*, unsigned);
146 #define cuEventDestroy cuEventDestroy_v2
147 CUresult
cuEventDestroy (CUevent
);
148 CUresult
cuEventElapsedTime (float *, CUevent
, CUevent
);
149 CUresult
cuEventQuery (CUevent
);
150 CUresult
cuEventRecord (CUevent
, CUstream
);
151 CUresult
cuEventSynchronize (CUevent
);
152 CUresult
cuFuncGetAttribute (int *, CUfunction_attribute
, CUfunction
);
153 CUresult
cuGetErrorString (CUresult
, const char **);
154 CUresult
cuGetErrorName (CUresult
, const char **);
155 CUresult
cuInit (unsigned);
156 CUresult
cuDriverGetVersion (int *);
157 CUresult
cuLaunchKernel (CUfunction
, unsigned, unsigned, unsigned, unsigned,
158 unsigned, unsigned, unsigned, CUstream
, void **, void **);
159 #define cuLinkAddData cuLinkAddData_v2
160 CUresult
cuLinkAddData (CUlinkState
, CUjitInputType
, void *, size_t, const char *,
161 unsigned, CUjit_option
*, void **);
162 CUresult
cuLinkComplete (CUlinkState
, void **, size_t *);
163 #define cuLinkCreate cuLinkCreate_v2
164 CUresult
cuLinkCreate (unsigned, CUjit_option
*, void **, CUlinkState
*);
165 CUresult
cuLinkDestroy (CUlinkState
);
166 #define cuMemGetInfo cuMemGetInfo_v2
167 CUresult
cuMemGetInfo (size_t *, size_t *);
168 #define cuMemAlloc cuMemAlloc_v2
169 CUresult
cuMemAlloc (CUdeviceptr
*, size_t);
170 #define cuMemAllocHost cuMemAllocHost_v2
171 CUresult
cuMemAllocHost (void **, size_t);
172 CUresult
cuMemcpy (CUdeviceptr
, CUdeviceptr
, size_t);
173 #define cuMemcpyDtoDAsync cuMemcpyDtoDAsync_v2
174 CUresult
cuMemcpyDtoDAsync (CUdeviceptr
, CUdeviceptr
, size_t, CUstream
);
175 #define cuMemcpyDtoH cuMemcpyDtoH_v2
176 CUresult
cuMemcpyDtoH (void *, CUdeviceptr
, size_t);
177 #define cuMemcpyDtoHAsync cuMemcpyDtoHAsync_v2
178 CUresult
cuMemcpyDtoHAsync (void *, CUdeviceptr
, size_t, CUstream
);
179 #define cuMemcpyHtoD cuMemcpyHtoD_v2
180 CUresult
cuMemcpyHtoD (CUdeviceptr
, const void *, size_t);
181 #define cuMemcpyHtoDAsync cuMemcpyHtoDAsync_v2
182 CUresult
cuMemcpyHtoDAsync (CUdeviceptr
, const void *, size_t, CUstream
);
183 #define cuMemFree cuMemFree_v2
184 CUresult
cuMemFree (CUdeviceptr
);
185 CUresult
cuMemFreeHost (void *);
186 #define cuMemGetAddressRange cuMemGetAddressRange_v2
187 CUresult
cuMemGetAddressRange (CUdeviceptr
*, size_t *, CUdeviceptr
);
188 #define cuMemHostGetDevicePointer cuMemHostGetDevicePointer_v2
189 CUresult
cuMemHostGetDevicePointer (CUdeviceptr
*, void *, unsigned);
190 CUresult
cuModuleGetFunction (CUfunction
*, CUmodule
, const char *);
191 #define cuModuleGetGlobal cuModuleGetGlobal_v2
192 CUresult
cuModuleGetGlobal (CUdeviceptr
*, size_t *, CUmodule
, const char *);
193 CUresult
cuModuleLoad (CUmodule
*, const char *);
194 CUresult
cuModuleLoadData (CUmodule
*, const void *);
195 CUresult
cuModuleUnload (CUmodule
);
196 CUresult
cuOccupancyMaxPotentialBlockSize(int *, int *, CUfunction
,
197 CUoccupancyB2DSize
, size_t, int);
198 typedef void (*CUstreamCallback
)(CUstream
, CUresult
, void *);
199 CUresult
cuStreamAddCallback(CUstream
, CUstreamCallback
, void *, unsigned int);
200 CUresult
cuStreamCreate (CUstream
*, unsigned);
201 #define cuStreamDestroy cuStreamDestroy_v2
202 CUresult
cuStreamDestroy (CUstream
);
203 CUresult
cuStreamQuery (CUstream
);
204 CUresult
cuStreamSynchronize (CUstream
);
205 CUresult
cuStreamWaitEvent (CUstream
, CUevent
, unsigned);
211 #endif /* GCC_CUDA_H */