OSDN Git Service

modified: utilsrc/src/Admin/Makefile
[eos/others.git] / utiltools / X86MAC64 / cuda / samples / 6_Advanced / matrixMulDynlinkJIT / drvapi_error_string.h
1 /*
2  * Copyright 1993-2013 NVIDIA Corporation.  All rights reserved.
3  *
4  * Please refer to the NVIDIA end user license agreement (EULA) associated
5  * with this source code for terms and conditions that govern your use of
6  * this software. Any use, reproduction, disclosure, or distribution of
7  * this software and related documentation outside the terms of the EULA
8  * is strictly prohibited.
9  *
10  */
11
12 #ifndef _DRVAPI_ERROR_STRING_H_
13 #define _DRVAPI_ERROR_STRING_H_
14
15 #include <stdio.h>
16 #include <string.h>
17 #include <stdlib.h>
18
19 #ifdef  __cuda_cuda_h__ // check to see if CUDA_H is included above
20
21 // Error Code string definitions here
22 typedef struct
23 {
24     char const *error_string;
25     int  error_id;
26 } s_CudaErrorStr;
27
28 /**
29  * Error codes
30  */
31 static s_CudaErrorStr sCudaDrvErrorString[] =
32 {
33     /**
34      * The API call returned with no errors. In the case of query calls, this
35      * can also mean that the operation being queried is complete (see
36      * ::cuEventQuery() and ::cuStreamQuery()).
37      */
38     { "CUDA_SUCCESS", 0 },
39
40     /**
41      * This indicates that one or more of the parameters passed to the API call
42      * is not within an acceptable range of values.
43      */
44     { "CUDA_ERROR_INVALID_VALUE", 1 },
45
46     /**
47      * The API call failed because it was unable to allocate enough memory to
48      * perform the requested operation.
49      */
50     { "CUDA_ERROR_OUT_OF_MEMORY", 2 },
51
52     /**
53      * This indicates that the CUDA driver has not been initialized with
54      * ::cuInit() or that initialization has failed.
55      */
56     { "CUDA_ERROR_NOT_INITIALIZED", 3 },
57
58     /**
59      * This indicates that the CUDA driver is in the process of shutting down.
60      */
61     { "CUDA_ERROR_DEINITIALIZED", 4 },
62
63     /**
64      * This indicates profiling APIs are called while application is running
65      * in visual profiler mode.
66     */
67     { "CUDA_ERROR_PROFILER_DISABLED", 5 },
68     /**
69      * This indicates profiling has not been initialized for this context.
70      * Call cuProfilerInitialize() to resolve this.
71     */
72     { "CUDA_ERROR_PROFILER_NOT_INITIALIZED", 6 },
73     /**
74      * This indicates profiler has already been started and probably
75      * cuProfilerStart() is incorrectly called.
76     */
77     { "CUDA_ERROR_PROFILER_ALREADY_STARTED", 7 },
78     /**
79      * This indicates profiler has already been stopped and probably
80      * cuProfilerStop() is incorrectly called.
81     */
82     { "CUDA_ERROR_PROFILER_ALREADY_STOPPED", 8 },
83     /**
84      * This indicates that no CUDA-capable devices were detected by the installed
85      * CUDA driver.
86      */
87     { "CUDA_ERROR_NO_DEVICE (no CUDA-capable devices were detected)", 100 },
88
89     /**
90      * This indicates that the device ordinal supplied by the user does not
91      * correspond to a valid CUDA device.
92      */
93     { "CUDA_ERROR_INVALID_DEVICE (device specified is not a valid CUDA device)", 101 },
94
95
96     /**
97      * This indicates that the device kernel image is invalid. This can also
98      * indicate an invalid CUDA module.
99      */
100     { "CUDA_ERROR_INVALID_IMAGE", 200 },
101
102     /**
103      * This most frequently indicates that there is no context bound to the
104      * current thread. This can also be returned if the context passed to an
105      * API call is not a valid handle (such as a context that has had
106      * ::cuCtxDestroy() invoked on it). This can also be returned if a user
107      * mixes different API versions (i.e. 3010 context with 3020 API calls).
108      * See ::cuCtxGetApiVersion() for more details.
109      */
110     { "CUDA_ERROR_INVALID_CONTEXT", 201 },
111
112     /**
113      * This indicated that the context being supplied as a parameter to the
114      * API call was already the active context.
115      * \deprecated
116      * This error return is deprecated as of CUDA 3.2. It is no longer an
117      * error to attempt to push the active context via ::cuCtxPushCurrent().
118      */
119     { "CUDA_ERROR_CONTEXT_ALREADY_CURRENT", 202 },
120
121     /**
122      * This indicates that a map or register operation has failed.
123      */
124     { "CUDA_ERROR_MAP_FAILED", 205 },
125
126     /**
127      * This indicates that an unmap or unregister operation has failed.
128      */
129     { "CUDA_ERROR_UNMAP_FAILED", 206 },
130
131     /**
132      * This indicates that the specified array is currently mapped and thus
133      * cannot be destroyed.
134      */
135     { "CUDA_ERROR_ARRAY_IS_MAPPED", 207 },
136
137     /**
138      * This indicates that the resource is already mapped.
139      */
140     { "CUDA_ERROR_ALREADY_MAPPED", 208 },
141
142     /**
143      * This indicates that there is no kernel image available that is suitable
144      * for the device. This can occur when a user specifies code generation
145      * options for a particular CUDA source file that do not include the
146      * corresponding device configuration.
147      */
148     { "CUDA_ERROR_NO_BINARY_FOR_GPU", 209 },
149
150     /**
151      * This indicates that a resource has already been acquired.
152      */
153     { "CUDA_ERROR_ALREADY_ACQUIRED", 210 },
154
155     /**
156      * This indicates that a resource is not mapped.
157      */
158     { "CUDA_ERROR_NOT_MAPPED", 211 },
159
160     /**
161      * This indicates that a mapped resource is not available for access as an
162      * array.
163      */
164     { "CUDA_ERROR_NOT_MAPPED_AS_ARRAY", 212 },
165
166     /**
167      * This indicates that a mapped resource is not available for access as a
168      * pointer.
169      */
170     { "CUDA_ERROR_NOT_MAPPED_AS_POINTER", 213 },
171
172     /**
173      * This indicates that an uncorrectable ECC error was detected during
174      * execution.
175      */
176     { "CUDA_ERROR_ECC_UNCORRECTABLE", 214 },
177
178     /**
179      * This indicates that the ::CUlimit passed to the API call is not
180      * supported by the active device.
181      */
182     { "CUDA_ERROR_UNSUPPORTED_LIMIT", 215 },
183
184     /**
185      * This indicates that the ::CUcontext passed to the API call can
186      * only be bound to a single CPU thread at a time but is already
187      * bound to a CPU thread.
188      */
189     { "CUDA_ERROR_CONTEXT_ALREADY_IN_USE", 216 },
190
191     /**
192      * This indicates that the device kernel source is invalid.
193      */
194     { "CUDA_ERROR_INVALID_SOURCE", 300 },
195
196     /**
197      * This indicates that the file specified was not found.
198      */
199     { "CUDA_ERROR_FILE_NOT_FOUND", 301 },
200
201     /**
202      * This indicates that a link to a shared object failed to resolve.
203      */
204     { "CUDA_ERROR_SHARED_OBJECT_SYMBOL_NOT_FOUND", 302 },
205
206     /**
207      * This indicates that initialization of a shared object failed.
208      */
209     { "CUDA_ERROR_SHARED_OBJECT_INIT_FAILED", 303 },
210
211     /**
212      * This indicates that an OS call failed.
213      */
214     { "CUDA_ERROR_OPERATING_SYSTEM", 304 },
215
216
217     /**
218      * This indicates that a resource handle passed to the API call was not
219      * valid. Resource handles are opaque types like ::CUstream and ::CUevent.
220      */
221     { "CUDA_ERROR_INVALID_HANDLE", 400 },
222
223
224     /**
225      * This indicates that a named symbol was not found. Examples of symbols
226      * are global/constant variable names, texture names }, and surface names.
227      */
228     { "CUDA_ERROR_NOT_FOUND", 500 },
229
230
231     /**
232      * This indicates that asynchronous operations issued previously have not
233      * completed yet. This result is not actually an error, but must be indicated
234      * differently than ::CUDA_SUCCESS (which indicates completion). Calls that
235      * may return this value include ::cuEventQuery() and ::cuStreamQuery().
236      */
237     { "CUDA_ERROR_NOT_READY", 600 },
238
239
240     /**
241      * An exception occurred on the device while executing a kernel. Common
242      * causes include dereferencing an invalid device pointer and accessing
243      * out of bounds shared memory. The context cannot be used }, so it must
244      * be destroyed (and a new one should be created). All existing device
245      * memory allocations from this context are invalid and must be
246      * reconstructed if the program is to continue using CUDA.
247      */
248     { "CUDA_ERROR_LAUNCH_FAILED", 700 },
249
250     /**
251      * This indicates that a launch did not occur because it did not have
252      * appropriate resources. This error usually indicates that the user has
253      * attempted to pass too many arguments to the device kernel, or the
254      * kernel launch specifies too many threads for the kernel's register
255      * count. Passing arguments of the wrong size (i.e. a 64-bit pointer
256      * when a 32-bit int is expected) is equivalent to passing too many
257      * arguments and can also result in this error.
258      */
259     { "CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES", 701 },
260
261     /**
262      * This indicates that the device kernel took too long to execute. This can
263      * only occur if timeouts are enabled - see the device attribute
264      * ::CU_DEVICE_ATTRIBUTE_KERNEL_EXEC_TIMEOUT for more information. The
265      * context cannot be used (and must be destroyed similar to
266      * ::CUDA_ERROR_LAUNCH_FAILED). All existing device memory allocations from
267      * this context are invalid and must be reconstructed if the program is to
268      * continue using CUDA.
269      */
270     { "CUDA_ERROR_LAUNCH_TIMEOUT", 702 },
271
272     /**
273      * This error indicates a kernel launch that uses an incompatible texturing
274      * mode.
275      */
276     { "CUDA_ERROR_LAUNCH_INCOMPATIBLE_TEXTURING", 703 },
277
278     /**
279      * This error indicates that a call to ::cuCtxEnablePeerAccess() is
280      * trying to re-enable peer access to a context which has already
281      * had peer access to it enabled.
282      */
283     { "CUDA_ERROR_PEER_ACCESS_ALREADY_ENABLED", 704 },
284
285     /**
286      * This error indicates that ::cuCtxDisablePeerAccess() is
287      * trying to disable peer access which has not been enabled yet
288      * via ::cuCtxEnablePeerAccess().
289      */
290     { "CUDA_ERROR_PEER_ACCESS_NOT_ENABLED", 705 },
291
292     /**
293      * This error indicates that the primary context for the specified device
294      * has already been initialized.
295      */
296     { "CUDA_ERROR_PRIMARY_CONTEXT_ACTIVE", 708 },
297
298     /**
299      * This error indicates that the context current to the calling thread
300      * has been destroyed using ::cuCtxDestroy }, or is a primary context which
301      * has not yet been initialized.
302      */
303     { "CUDA_ERROR_CONTEXT_IS_DESTROYED", 709 },
304
305     /**
306      * A device-side assert triggered during kernel execution. The context
307      * cannot be used anymore, and must be destroyed. All existing device
308      * memory allocations from this context are invalid and must be
309      * reconstructed if the program is to continue using CUDA.
310      */
311     { "CUDA_ERROR_ASSERT", 710 },
312
313     /**
314      * This indicates that an unknown internal error has occurred.
315      */
316     { "CUDA_ERROR_UNKNOWN", 999 },
317     { NULL, -1 }
318 };
319
320 // This is just a linear search through the array, since the error_id's are not
321 // always ocurring consecutively
322 inline const char *getCudaDrvErrorString(CUresult error_id)
323 {
324     int index = 0;
325
326     while (sCudaDrvErrorString[index].error_id != error_id &&
327            sCudaDrvErrorString[index].error_id != -1)
328     {
329         index++;
330     }
331
332     if (sCudaDrvErrorString[index].error_id == error_id)
333         return (const char *)sCudaDrvErrorString[index].error_string;
334     else
335         return (const char *)"CUDA_ERROR not found!";
336 }
337
338 #endif // __cuda_cuda_h__
339
340
341 #endif