annotate src/parallel_execution/helper_cuda.h @ 304:9755206813cb

helper_string.h for ANSI C
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 14 Feb 2017 11:36:41 +0900
parents 1dbaef86593b
children ec0a5b4fba05
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
291
87128b876c63 add test
ikkun
parents:
diff changeset
1 /**
87128b876c63 add test
ikkun
parents:
diff changeset
2 * Copyright 1993-2013 NVIDIA Corporation. All rights reserved.
87128b876c63 add test
ikkun
parents:
diff changeset
3 *
87128b876c63 add test
ikkun
parents:
diff changeset
4 * Please refer to the NVIDIA end user license agreement (EULA) associated
87128b876c63 add test
ikkun
parents:
diff changeset
5 * with this source code for terms and conditions that govern your use of
87128b876c63 add test
ikkun
parents:
diff changeset
6 * this software. Any use, reproduction, disclosure, or distribution of
87128b876c63 add test
ikkun
parents:
diff changeset
7 * this software and related documentation outside the terms of the EULA
87128b876c63 add test
ikkun
parents:
diff changeset
8 * is strictly prohibited.
87128b876c63 add test
ikkun
parents:
diff changeset
9 *
87128b876c63 add test
ikkun
parents:
diff changeset
10 */
87128b876c63 add test
ikkun
parents:
diff changeset
11
87128b876c63 add test
ikkun
parents:
diff changeset
12 ////////////////////////////////////////////////////////////////////////////////
87128b876c63 add test
ikkun
parents:
diff changeset
13 // These are CUDA Helper functions for initialization and error checking
87128b876c63 add test
ikkun
parents:
diff changeset
14
87128b876c63 add test
ikkun
parents:
diff changeset
15 #ifndef HELPER_CUDA_H
87128b876c63 add test
ikkun
parents:
diff changeset
16 #define HELPER_CUDA_H
87128b876c63 add test
ikkun
parents:
diff changeset
17
87128b876c63 add test
ikkun
parents:
diff changeset
18 #pragma once
87128b876c63 add test
ikkun
parents:
diff changeset
19
87128b876c63 add test
ikkun
parents:
diff changeset
20 #include <stdlib.h>
87128b876c63 add test
ikkun
parents:
diff changeset
21 #include <stdio.h>
87128b876c63 add test
ikkun
parents:
diff changeset
22 #include <string.h>
87128b876c63 add test
ikkun
parents:
diff changeset
23
87128b876c63 add test
ikkun
parents:
diff changeset
24 #include "helper_string.h"
87128b876c63 add test
ikkun
parents:
diff changeset
25
87128b876c63 add test
ikkun
parents:
diff changeset
26 #ifndef EXIT_WAIVED
87128b876c63 add test
ikkun
parents:
diff changeset
27 #define EXIT_WAIVED 2
87128b876c63 add test
ikkun
parents:
diff changeset
28 #endif
87128b876c63 add test
ikkun
parents:
diff changeset
29
87128b876c63 add test
ikkun
parents:
diff changeset
30 // Note, it is required that your SDK sample to include the proper header files, please
87128b876c63 add test
ikkun
parents:
diff changeset
31 // refer the CUDA examples for examples of the needed CUDA headers, which may change depending
87128b876c63 add test
ikkun
parents:
diff changeset
32 // on which CUDA functions are used.
87128b876c63 add test
ikkun
parents:
diff changeset
33
87128b876c63 add test
ikkun
parents:
diff changeset
34 // CUDA Runtime error messages
87128b876c63 add test
ikkun
parents:
diff changeset
35 #ifdef __DRIVER_TYPES_H__
87128b876c63 add test
ikkun
parents:
diff changeset
36 static const char *_cudaGetErrorEnum(cudaError_t error)
87128b876c63 add test
ikkun
parents:
diff changeset
37 {
87128b876c63 add test
ikkun
parents:
diff changeset
38 switch (error)
87128b876c63 add test
ikkun
parents:
diff changeset
39 {
87128b876c63 add test
ikkun
parents:
diff changeset
40 case cudaSuccess:
87128b876c63 add test
ikkun
parents:
diff changeset
41 return "cudaSuccess";
87128b876c63 add test
ikkun
parents:
diff changeset
42
87128b876c63 add test
ikkun
parents:
diff changeset
43 case cudaErrorMissingConfiguration:
87128b876c63 add test
ikkun
parents:
diff changeset
44 return "cudaErrorMissingConfiguration";
87128b876c63 add test
ikkun
parents:
diff changeset
45
87128b876c63 add test
ikkun
parents:
diff changeset
46 case cudaErrorMemoryAllocation:
87128b876c63 add test
ikkun
parents:
diff changeset
47 return "cudaErrorMemoryAllocation";
87128b876c63 add test
ikkun
parents:
diff changeset
48
87128b876c63 add test
ikkun
parents:
diff changeset
49 case cudaErrorInitializationError:
87128b876c63 add test
ikkun
parents:
diff changeset
50 return "cudaErrorInitializationError";
87128b876c63 add test
ikkun
parents:
diff changeset
51
87128b876c63 add test
ikkun
parents:
diff changeset
52 case cudaErrorLaunchFailure:
87128b876c63 add test
ikkun
parents:
diff changeset
53 return "cudaErrorLaunchFailure";
87128b876c63 add test
ikkun
parents:
diff changeset
54
87128b876c63 add test
ikkun
parents:
diff changeset
55 case cudaErrorPriorLaunchFailure:
87128b876c63 add test
ikkun
parents:
diff changeset
56 return "cudaErrorPriorLaunchFailure";
87128b876c63 add test
ikkun
parents:
diff changeset
57
87128b876c63 add test
ikkun
parents:
diff changeset
58 case cudaErrorLaunchTimeout:
87128b876c63 add test
ikkun
parents:
diff changeset
59 return "cudaErrorLaunchTimeout";
87128b876c63 add test
ikkun
parents:
diff changeset
60
87128b876c63 add test
ikkun
parents:
diff changeset
61 case cudaErrorLaunchOutOfResources:
87128b876c63 add test
ikkun
parents:
diff changeset
62 return "cudaErrorLaunchOutOfResources";
87128b876c63 add test
ikkun
parents:
diff changeset
63
87128b876c63 add test
ikkun
parents:
diff changeset
64 case cudaErrorInvalidDeviceFunction:
87128b876c63 add test
ikkun
parents:
diff changeset
65 return "cudaErrorInvalidDeviceFunction";
87128b876c63 add test
ikkun
parents:
diff changeset
66
87128b876c63 add test
ikkun
parents:
diff changeset
67 case cudaErrorInvalidConfiguration:
87128b876c63 add test
ikkun
parents:
diff changeset
68 return "cudaErrorInvalidConfiguration";
87128b876c63 add test
ikkun
parents:
diff changeset
69
87128b876c63 add test
ikkun
parents:
diff changeset
70 case cudaErrorInvalidDevice:
87128b876c63 add test
ikkun
parents:
diff changeset
71 return "cudaErrorInvalidDevice";
87128b876c63 add test
ikkun
parents:
diff changeset
72
87128b876c63 add test
ikkun
parents:
diff changeset
73 case cudaErrorInvalidValue:
87128b876c63 add test
ikkun
parents:
diff changeset
74 return "cudaErrorInvalidValue";
87128b876c63 add test
ikkun
parents:
diff changeset
75
87128b876c63 add test
ikkun
parents:
diff changeset
76 case cudaErrorInvalidPitchValue:
87128b876c63 add test
ikkun
parents:
diff changeset
77 return "cudaErrorInvalidPitchValue";
87128b876c63 add test
ikkun
parents:
diff changeset
78
87128b876c63 add test
ikkun
parents:
diff changeset
79 case cudaErrorInvalidSymbol:
87128b876c63 add test
ikkun
parents:
diff changeset
80 return "cudaErrorInvalidSymbol";
87128b876c63 add test
ikkun
parents:
diff changeset
81
87128b876c63 add test
ikkun
parents:
diff changeset
82 case cudaErrorMapBufferObjectFailed:
87128b876c63 add test
ikkun
parents:
diff changeset
83 return "cudaErrorMapBufferObjectFailed";
87128b876c63 add test
ikkun
parents:
diff changeset
84
87128b876c63 add test
ikkun
parents:
diff changeset
85 case cudaErrorUnmapBufferObjectFailed:
87128b876c63 add test
ikkun
parents:
diff changeset
86 return "cudaErrorUnmapBufferObjectFailed";
87128b876c63 add test
ikkun
parents:
diff changeset
87
87128b876c63 add test
ikkun
parents:
diff changeset
88 case cudaErrorInvalidHostPointer:
87128b876c63 add test
ikkun
parents:
diff changeset
89 return "cudaErrorInvalidHostPointer";
87128b876c63 add test
ikkun
parents:
diff changeset
90
87128b876c63 add test
ikkun
parents:
diff changeset
91 case cudaErrorInvalidDevicePointer:
87128b876c63 add test
ikkun
parents:
diff changeset
92 return "cudaErrorInvalidDevicePointer";
87128b876c63 add test
ikkun
parents:
diff changeset
93
87128b876c63 add test
ikkun
parents:
diff changeset
94 case cudaErrorInvalidTexture:
87128b876c63 add test
ikkun
parents:
diff changeset
95 return "cudaErrorInvalidTexture";
87128b876c63 add test
ikkun
parents:
diff changeset
96
87128b876c63 add test
ikkun
parents:
diff changeset
97 case cudaErrorInvalidTextureBinding:
87128b876c63 add test
ikkun
parents:
diff changeset
98 return "cudaErrorInvalidTextureBinding";
87128b876c63 add test
ikkun
parents:
diff changeset
99
87128b876c63 add test
ikkun
parents:
diff changeset
100 case cudaErrorInvalidChannelDescriptor:
87128b876c63 add test
ikkun
parents:
diff changeset
101 return "cudaErrorInvalidChannelDescriptor";
87128b876c63 add test
ikkun
parents:
diff changeset
102
87128b876c63 add test
ikkun
parents:
diff changeset
103 case cudaErrorInvalidMemcpyDirection:
87128b876c63 add test
ikkun
parents:
diff changeset
104 return "cudaErrorInvalidMemcpyDirection";
87128b876c63 add test
ikkun
parents:
diff changeset
105
87128b876c63 add test
ikkun
parents:
diff changeset
106 case cudaErrorAddressOfConstant:
87128b876c63 add test
ikkun
parents:
diff changeset
107 return "cudaErrorAddressOfConstant";
87128b876c63 add test
ikkun
parents:
diff changeset
108
87128b876c63 add test
ikkun
parents:
diff changeset
109 case cudaErrorTextureFetchFailed:
87128b876c63 add test
ikkun
parents:
diff changeset
110 return "cudaErrorTextureFetchFailed";
87128b876c63 add test
ikkun
parents:
diff changeset
111
87128b876c63 add test
ikkun
parents:
diff changeset
112 case cudaErrorTextureNotBound:
87128b876c63 add test
ikkun
parents:
diff changeset
113 return "cudaErrorTextureNotBound";
87128b876c63 add test
ikkun
parents:
diff changeset
114
87128b876c63 add test
ikkun
parents:
diff changeset
115 case cudaErrorSynchronizationError:
87128b876c63 add test
ikkun
parents:
diff changeset
116 return "cudaErrorSynchronizationError";
87128b876c63 add test
ikkun
parents:
diff changeset
117
87128b876c63 add test
ikkun
parents:
diff changeset
118 case cudaErrorInvalidFilterSetting:
87128b876c63 add test
ikkun
parents:
diff changeset
119 return "cudaErrorInvalidFilterSetting";
87128b876c63 add test
ikkun
parents:
diff changeset
120
87128b876c63 add test
ikkun
parents:
diff changeset
121 case cudaErrorInvalidNormSetting:
87128b876c63 add test
ikkun
parents:
diff changeset
122 return "cudaErrorInvalidNormSetting";
87128b876c63 add test
ikkun
parents:
diff changeset
123
87128b876c63 add test
ikkun
parents:
diff changeset
124 case cudaErrorMixedDeviceExecution:
87128b876c63 add test
ikkun
parents:
diff changeset
125 return "cudaErrorMixedDeviceExecution";
87128b876c63 add test
ikkun
parents:
diff changeset
126
87128b876c63 add test
ikkun
parents:
diff changeset
127 case cudaErrorCudartUnloading:
87128b876c63 add test
ikkun
parents:
diff changeset
128 return "cudaErrorCudartUnloading";
87128b876c63 add test
ikkun
parents:
diff changeset
129
87128b876c63 add test
ikkun
parents:
diff changeset
130 case cudaErrorUnknown:
87128b876c63 add test
ikkun
parents:
diff changeset
131 return "cudaErrorUnknown";
87128b876c63 add test
ikkun
parents:
diff changeset
132
87128b876c63 add test
ikkun
parents:
diff changeset
133 case cudaErrorNotYetImplemented:
87128b876c63 add test
ikkun
parents:
diff changeset
134 return "cudaErrorNotYetImplemented";
87128b876c63 add test
ikkun
parents:
diff changeset
135
87128b876c63 add test
ikkun
parents:
diff changeset
136 case cudaErrorMemoryValueTooLarge:
87128b876c63 add test
ikkun
parents:
diff changeset
137 return "cudaErrorMemoryValueTooLarge";
87128b876c63 add test
ikkun
parents:
diff changeset
138
87128b876c63 add test
ikkun
parents:
diff changeset
139 case cudaErrorInvalidResourceHandle:
87128b876c63 add test
ikkun
parents:
diff changeset
140 return "cudaErrorInvalidResourceHandle";
87128b876c63 add test
ikkun
parents:
diff changeset
141
87128b876c63 add test
ikkun
parents:
diff changeset
142 case cudaErrorNotReady:
87128b876c63 add test
ikkun
parents:
diff changeset
143 return "cudaErrorNotReady";
87128b876c63 add test
ikkun
parents:
diff changeset
144
87128b876c63 add test
ikkun
parents:
diff changeset
145 case cudaErrorInsufficientDriver:
87128b876c63 add test
ikkun
parents:
diff changeset
146 return "cudaErrorInsufficientDriver";
87128b876c63 add test
ikkun
parents:
diff changeset
147
87128b876c63 add test
ikkun
parents:
diff changeset
148 case cudaErrorSetOnActiveProcess:
87128b876c63 add test
ikkun
parents:
diff changeset
149 return "cudaErrorSetOnActiveProcess";
87128b876c63 add test
ikkun
parents:
diff changeset
150
87128b876c63 add test
ikkun
parents:
diff changeset
151 case cudaErrorInvalidSurface:
87128b876c63 add test
ikkun
parents:
diff changeset
152 return "cudaErrorInvalidSurface";
87128b876c63 add test
ikkun
parents:
diff changeset
153
87128b876c63 add test
ikkun
parents:
diff changeset
154 case cudaErrorNoDevice:
87128b876c63 add test
ikkun
parents:
diff changeset
155 return "cudaErrorNoDevice";
87128b876c63 add test
ikkun
parents:
diff changeset
156
87128b876c63 add test
ikkun
parents:
diff changeset
157 case cudaErrorECCUncorrectable:
87128b876c63 add test
ikkun
parents:
diff changeset
158 return "cudaErrorECCUncorrectable";
87128b876c63 add test
ikkun
parents:
diff changeset
159
87128b876c63 add test
ikkun
parents:
diff changeset
160 case cudaErrorSharedObjectSymbolNotFound:
87128b876c63 add test
ikkun
parents:
diff changeset
161 return "cudaErrorSharedObjectSymbolNotFound";
87128b876c63 add test
ikkun
parents:
diff changeset
162
87128b876c63 add test
ikkun
parents:
diff changeset
163 case cudaErrorSharedObjectInitFailed:
87128b876c63 add test
ikkun
parents:
diff changeset
164 return "cudaErrorSharedObjectInitFailed";
87128b876c63 add test
ikkun
parents:
diff changeset
165
87128b876c63 add test
ikkun
parents:
diff changeset
166 case cudaErrorUnsupportedLimit:
87128b876c63 add test
ikkun
parents:
diff changeset
167 return "cudaErrorUnsupportedLimit";
87128b876c63 add test
ikkun
parents:
diff changeset
168
87128b876c63 add test
ikkun
parents:
diff changeset
169 case cudaErrorDuplicateVariableName:
87128b876c63 add test
ikkun
parents:
diff changeset
170 return "cudaErrorDuplicateVariableName";
87128b876c63 add test
ikkun
parents:
diff changeset
171
87128b876c63 add test
ikkun
parents:
diff changeset
172 case cudaErrorDuplicateTextureName:
87128b876c63 add test
ikkun
parents:
diff changeset
173 return "cudaErrorDuplicateTextureName";
87128b876c63 add test
ikkun
parents:
diff changeset
174
87128b876c63 add test
ikkun
parents:
diff changeset
175 case cudaErrorDuplicateSurfaceName:
87128b876c63 add test
ikkun
parents:
diff changeset
176 return "cudaErrorDuplicateSurfaceName";
87128b876c63 add test
ikkun
parents:
diff changeset
177
87128b876c63 add test
ikkun
parents:
diff changeset
178 case cudaErrorDevicesUnavailable:
87128b876c63 add test
ikkun
parents:
diff changeset
179 return "cudaErrorDevicesUnavailable";
87128b876c63 add test
ikkun
parents:
diff changeset
180
87128b876c63 add test
ikkun
parents:
diff changeset
181 case cudaErrorInvalidKernelImage:
87128b876c63 add test
ikkun
parents:
diff changeset
182 return "cudaErrorInvalidKernelImage";
87128b876c63 add test
ikkun
parents:
diff changeset
183
87128b876c63 add test
ikkun
parents:
diff changeset
184 case cudaErrorNoKernelImageForDevice:
87128b876c63 add test
ikkun
parents:
diff changeset
185 return "cudaErrorNoKernelImageForDevice";
87128b876c63 add test
ikkun
parents:
diff changeset
186
87128b876c63 add test
ikkun
parents:
diff changeset
187 case cudaErrorIncompatibleDriverContext:
87128b876c63 add test
ikkun
parents:
diff changeset
188 return "cudaErrorIncompatibleDriverContext";
87128b876c63 add test
ikkun
parents:
diff changeset
189
87128b876c63 add test
ikkun
parents:
diff changeset
190 case cudaErrorPeerAccessAlreadyEnabled:
87128b876c63 add test
ikkun
parents:
diff changeset
191 return "cudaErrorPeerAccessAlreadyEnabled";
87128b876c63 add test
ikkun
parents:
diff changeset
192
87128b876c63 add test
ikkun
parents:
diff changeset
193 case cudaErrorPeerAccessNotEnabled:
87128b876c63 add test
ikkun
parents:
diff changeset
194 return "cudaErrorPeerAccessNotEnabled";
87128b876c63 add test
ikkun
parents:
diff changeset
195
87128b876c63 add test
ikkun
parents:
diff changeset
196 case cudaErrorDeviceAlreadyInUse:
87128b876c63 add test
ikkun
parents:
diff changeset
197 return "cudaErrorDeviceAlreadyInUse";
87128b876c63 add test
ikkun
parents:
diff changeset
198
87128b876c63 add test
ikkun
parents:
diff changeset
199 case cudaErrorProfilerDisabled:
87128b876c63 add test
ikkun
parents:
diff changeset
200 return "cudaErrorProfilerDisabled";
87128b876c63 add test
ikkun
parents:
diff changeset
201
87128b876c63 add test
ikkun
parents:
diff changeset
202 case cudaErrorProfilerNotInitialized:
87128b876c63 add test
ikkun
parents:
diff changeset
203 return "cudaErrorProfilerNotInitialized";
87128b876c63 add test
ikkun
parents:
diff changeset
204
87128b876c63 add test
ikkun
parents:
diff changeset
205 case cudaErrorProfilerAlreadyStarted:
87128b876c63 add test
ikkun
parents:
diff changeset
206 return "cudaErrorProfilerAlreadyStarted";
87128b876c63 add test
ikkun
parents:
diff changeset
207
87128b876c63 add test
ikkun
parents:
diff changeset
208 case cudaErrorProfilerAlreadyStopped:
87128b876c63 add test
ikkun
parents:
diff changeset
209 return "cudaErrorProfilerAlreadyStopped";
87128b876c63 add test
ikkun
parents:
diff changeset
210
87128b876c63 add test
ikkun
parents:
diff changeset
211 /* Since CUDA 4.0*/
87128b876c63 add test
ikkun
parents:
diff changeset
212 case cudaErrorAssert:
87128b876c63 add test
ikkun
parents:
diff changeset
213 return "cudaErrorAssert";
87128b876c63 add test
ikkun
parents:
diff changeset
214
87128b876c63 add test
ikkun
parents:
diff changeset
215 case cudaErrorTooManyPeers:
87128b876c63 add test
ikkun
parents:
diff changeset
216 return "cudaErrorTooManyPeers";
87128b876c63 add test
ikkun
parents:
diff changeset
217
87128b876c63 add test
ikkun
parents:
diff changeset
218 case cudaErrorHostMemoryAlreadyRegistered:
87128b876c63 add test
ikkun
parents:
diff changeset
219 return "cudaErrorHostMemoryAlreadyRegistered";
87128b876c63 add test
ikkun
parents:
diff changeset
220
87128b876c63 add test
ikkun
parents:
diff changeset
221 case cudaErrorHostMemoryNotRegistered:
87128b876c63 add test
ikkun
parents:
diff changeset
222 return "cudaErrorHostMemoryNotRegistered";
87128b876c63 add test
ikkun
parents:
diff changeset
223
87128b876c63 add test
ikkun
parents:
diff changeset
224 /* Since CUDA 5.0 */
87128b876c63 add test
ikkun
parents:
diff changeset
225 case cudaErrorOperatingSystem:
87128b876c63 add test
ikkun
parents:
diff changeset
226 return "cudaErrorOperatingSystem";
87128b876c63 add test
ikkun
parents:
diff changeset
227
87128b876c63 add test
ikkun
parents:
diff changeset
228 case cudaErrorPeerAccessUnsupported:
87128b876c63 add test
ikkun
parents:
diff changeset
229 return "cudaErrorPeerAccessUnsupported";
87128b876c63 add test
ikkun
parents:
diff changeset
230
87128b876c63 add test
ikkun
parents:
diff changeset
231 case cudaErrorLaunchMaxDepthExceeded:
87128b876c63 add test
ikkun
parents:
diff changeset
232 return "cudaErrorLaunchMaxDepthExceeded";
87128b876c63 add test
ikkun
parents:
diff changeset
233
87128b876c63 add test
ikkun
parents:
diff changeset
234 case cudaErrorLaunchFileScopedTex:
87128b876c63 add test
ikkun
parents:
diff changeset
235 return "cudaErrorLaunchFileScopedTex";
87128b876c63 add test
ikkun
parents:
diff changeset
236
87128b876c63 add test
ikkun
parents:
diff changeset
237 case cudaErrorLaunchFileScopedSurf:
87128b876c63 add test
ikkun
parents:
diff changeset
238 return "cudaErrorLaunchFileScopedSurf";
87128b876c63 add test
ikkun
parents:
diff changeset
239
87128b876c63 add test
ikkun
parents:
diff changeset
240 case cudaErrorSyncDepthExceeded:
87128b876c63 add test
ikkun
parents:
diff changeset
241 return "cudaErrorSyncDepthExceeded";
87128b876c63 add test
ikkun
parents:
diff changeset
242
87128b876c63 add test
ikkun
parents:
diff changeset
243 case cudaErrorLaunchPendingCountExceeded:
87128b876c63 add test
ikkun
parents:
diff changeset
244 return "cudaErrorLaunchPendingCountExceeded";
87128b876c63 add test
ikkun
parents:
diff changeset
245
87128b876c63 add test
ikkun
parents:
diff changeset
246 case cudaErrorNotPermitted:
87128b876c63 add test
ikkun
parents:
diff changeset
247 return "cudaErrorNotPermitted";
87128b876c63 add test
ikkun
parents:
diff changeset
248
87128b876c63 add test
ikkun
parents:
diff changeset
249 case cudaErrorNotSupported:
87128b876c63 add test
ikkun
parents:
diff changeset
250 return "cudaErrorNotSupported";
87128b876c63 add test
ikkun
parents:
diff changeset
251
87128b876c63 add test
ikkun
parents:
diff changeset
252 /* Since CUDA 6.0 */
87128b876c63 add test
ikkun
parents:
diff changeset
253 case cudaErrorHardwareStackError:
87128b876c63 add test
ikkun
parents:
diff changeset
254 return "cudaErrorHardwareStackError";
87128b876c63 add test
ikkun
parents:
diff changeset
255
87128b876c63 add test
ikkun
parents:
diff changeset
256 case cudaErrorIllegalInstruction:
87128b876c63 add test
ikkun
parents:
diff changeset
257 return "cudaErrorIllegalInstruction";
87128b876c63 add test
ikkun
parents:
diff changeset
258
87128b876c63 add test
ikkun
parents:
diff changeset
259 case cudaErrorMisalignedAddress:
87128b876c63 add test
ikkun
parents:
diff changeset
260 return "cudaErrorMisalignedAddress";
87128b876c63 add test
ikkun
parents:
diff changeset
261
87128b876c63 add test
ikkun
parents:
diff changeset
262 case cudaErrorInvalidAddressSpace:
87128b876c63 add test
ikkun
parents:
diff changeset
263 return "cudaErrorInvalidAddressSpace";
87128b876c63 add test
ikkun
parents:
diff changeset
264
87128b876c63 add test
ikkun
parents:
diff changeset
265 case cudaErrorInvalidPc:
87128b876c63 add test
ikkun
parents:
diff changeset
266 return "cudaErrorInvalidPc";
87128b876c63 add test
ikkun
parents:
diff changeset
267
87128b876c63 add test
ikkun
parents:
diff changeset
268 case cudaErrorIllegalAddress:
87128b876c63 add test
ikkun
parents:
diff changeset
269 return "cudaErrorIllegalAddress";
87128b876c63 add test
ikkun
parents:
diff changeset
270
87128b876c63 add test
ikkun
parents:
diff changeset
271 /* Since CUDA 6.5*/
87128b876c63 add test
ikkun
parents:
diff changeset
272 case cudaErrorInvalidPtx:
87128b876c63 add test
ikkun
parents:
diff changeset
273 return "cudaErrorInvalidPtx";
87128b876c63 add test
ikkun
parents:
diff changeset
274
87128b876c63 add test
ikkun
parents:
diff changeset
275 case cudaErrorInvalidGraphicsContext:
87128b876c63 add test
ikkun
parents:
diff changeset
276 return "cudaErrorInvalidGraphicsContext";
87128b876c63 add test
ikkun
parents:
diff changeset
277
87128b876c63 add test
ikkun
parents:
diff changeset
278 case cudaErrorStartupFailure:
87128b876c63 add test
ikkun
parents:
diff changeset
279 return "cudaErrorStartupFailure";
87128b876c63 add test
ikkun
parents:
diff changeset
280
87128b876c63 add test
ikkun
parents:
diff changeset
281 case cudaErrorApiFailureBase:
87128b876c63 add test
ikkun
parents:
diff changeset
282 return "cudaErrorApiFailureBase";
87128b876c63 add test
ikkun
parents:
diff changeset
283
87128b876c63 add test
ikkun
parents:
diff changeset
284 /* Since CUDA 8.0*/
87128b876c63 add test
ikkun
parents:
diff changeset
285 case cudaErrorNvlinkUncorrectable :
87128b876c63 add test
ikkun
parents:
diff changeset
286 return "cudaErrorNvlinkUncorrectable";
87128b876c63 add test
ikkun
parents:
diff changeset
287 }
87128b876c63 add test
ikkun
parents:
diff changeset
288
87128b876c63 add test
ikkun
parents:
diff changeset
289 return "<unknown>";
87128b876c63 add test
ikkun
parents:
diff changeset
290 }
304
9755206813cb helper_string.h for ANSI C
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 303
diff changeset
291 #else
291
87128b876c63 add test
ikkun
parents:
diff changeset
292 // CUDA Driver API errors
301
609bf62768b9 add -DUSE_CUDA=1 flag to cmake
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
293 const char *_cudaGetErrorEnum(CUresult error)
291
87128b876c63 add test
ikkun
parents:
diff changeset
294 {
87128b876c63 add test
ikkun
parents:
diff changeset
295 switch (error)
87128b876c63 add test
ikkun
parents:
diff changeset
296 {
87128b876c63 add test
ikkun
parents:
diff changeset
297 case CUDA_SUCCESS:
87128b876c63 add test
ikkun
parents:
diff changeset
298 return "CUDA_SUCCESS";
87128b876c63 add test
ikkun
parents:
diff changeset
299
87128b876c63 add test
ikkun
parents:
diff changeset
300 case CUDA_ERROR_INVALID_VALUE:
87128b876c63 add test
ikkun
parents:
diff changeset
301 return "CUDA_ERROR_INVALID_VALUE";
87128b876c63 add test
ikkun
parents:
diff changeset
302
87128b876c63 add test
ikkun
parents:
diff changeset
303 case CUDA_ERROR_OUT_OF_MEMORY:
87128b876c63 add test
ikkun
parents:
diff changeset
304 return "CUDA_ERROR_OUT_OF_MEMORY";
87128b876c63 add test
ikkun
parents:
diff changeset
305
87128b876c63 add test
ikkun
parents:
diff changeset
306 case CUDA_ERROR_NOT_INITIALIZED:
87128b876c63 add test
ikkun
parents:
diff changeset
307 return "CUDA_ERROR_NOT_INITIALIZED";
87128b876c63 add test
ikkun
parents:
diff changeset
308
87128b876c63 add test
ikkun
parents:
diff changeset
309 case CUDA_ERROR_DEINITIALIZED:
87128b876c63 add test
ikkun
parents:
diff changeset
310 return "CUDA_ERROR_DEINITIALIZED";
87128b876c63 add test
ikkun
parents:
diff changeset
311
87128b876c63 add test
ikkun
parents:
diff changeset
312 case CUDA_ERROR_PROFILER_DISABLED:
87128b876c63 add test
ikkun
parents:
diff changeset
313 return "CUDA_ERROR_PROFILER_DISABLED";
87128b876c63 add test
ikkun
parents:
diff changeset
314
87128b876c63 add test
ikkun
parents:
diff changeset
315 case CUDA_ERROR_PROFILER_NOT_INITIALIZED:
87128b876c63 add test
ikkun
parents:
diff changeset
316 return "CUDA_ERROR_PROFILER_NOT_INITIALIZED";
87128b876c63 add test
ikkun
parents:
diff changeset
317
87128b876c63 add test
ikkun
parents:
diff changeset
318 case CUDA_ERROR_PROFILER_ALREADY_STARTED:
87128b876c63 add test
ikkun
parents:
diff changeset
319 return "CUDA_ERROR_PROFILER_ALREADY_STARTED";
87128b876c63 add test
ikkun
parents:
diff changeset
320
87128b876c63 add test
ikkun
parents:
diff changeset
321 case CUDA_ERROR_PROFILER_ALREADY_STOPPED:
87128b876c63 add test
ikkun
parents:
diff changeset
322 return "CUDA_ERROR_PROFILER_ALREADY_STOPPED";
87128b876c63 add test
ikkun
parents:
diff changeset
323
87128b876c63 add test
ikkun
parents:
diff changeset
324 case CUDA_ERROR_NO_DEVICE:
87128b876c63 add test
ikkun
parents:
diff changeset
325 return "CUDA_ERROR_NO_DEVICE";
87128b876c63 add test
ikkun
parents:
diff changeset
326
87128b876c63 add test
ikkun
parents:
diff changeset
327 case CUDA_ERROR_INVALID_DEVICE:
87128b876c63 add test
ikkun
parents:
diff changeset
328 return "CUDA_ERROR_INVALID_DEVICE";
87128b876c63 add test
ikkun
parents:
diff changeset
329
87128b876c63 add test
ikkun
parents:
diff changeset
330 case CUDA_ERROR_INVALID_IMAGE:
87128b876c63 add test
ikkun
parents:
diff changeset
331 return "CUDA_ERROR_INVALID_IMAGE";
87128b876c63 add test
ikkun
parents:
diff changeset
332
87128b876c63 add test
ikkun
parents:
diff changeset
333 case CUDA_ERROR_INVALID_CONTEXT:
87128b876c63 add test
ikkun
parents:
diff changeset
334 return "CUDA_ERROR_INVALID_CONTEXT";
87128b876c63 add test
ikkun
parents:
diff changeset
335
87128b876c63 add test
ikkun
parents:
diff changeset
336 case CUDA_ERROR_CONTEXT_ALREADY_CURRENT:
87128b876c63 add test
ikkun
parents:
diff changeset
337 return "CUDA_ERROR_CONTEXT_ALREADY_CURRENT";
87128b876c63 add test
ikkun
parents:
diff changeset
338
87128b876c63 add test
ikkun
parents:
diff changeset
339 case CUDA_ERROR_MAP_FAILED:
87128b876c63 add test
ikkun
parents:
diff changeset
340 return "CUDA_ERROR_MAP_FAILED";
87128b876c63 add test
ikkun
parents:
diff changeset
341
87128b876c63 add test
ikkun
parents:
diff changeset
342 case CUDA_ERROR_UNMAP_FAILED:
87128b876c63 add test
ikkun
parents:
diff changeset
343 return "CUDA_ERROR_UNMAP_FAILED";
87128b876c63 add test
ikkun
parents:
diff changeset
344
87128b876c63 add test
ikkun
parents:
diff changeset
345 case CUDA_ERROR_ARRAY_IS_MAPPED:
87128b876c63 add test
ikkun
parents:
diff changeset
346 return "CUDA_ERROR_ARRAY_IS_MAPPED";
87128b876c63 add test
ikkun
parents:
diff changeset
347
87128b876c63 add test
ikkun
parents:
diff changeset
348 case CUDA_ERROR_ALREADY_MAPPED:
87128b876c63 add test
ikkun
parents:
diff changeset
349 return "CUDA_ERROR_ALREADY_MAPPED";
87128b876c63 add test
ikkun
parents:
diff changeset
350
87128b876c63 add test
ikkun
parents:
diff changeset
351 case CUDA_ERROR_NO_BINARY_FOR_GPU:
87128b876c63 add test
ikkun
parents:
diff changeset
352 return "CUDA_ERROR_NO_BINARY_FOR_GPU";
87128b876c63 add test
ikkun
parents:
diff changeset
353
87128b876c63 add test
ikkun
parents:
diff changeset
354 case CUDA_ERROR_ALREADY_ACQUIRED:
87128b876c63 add test
ikkun
parents:
diff changeset
355 return "CUDA_ERROR_ALREADY_ACQUIRED";
87128b876c63 add test
ikkun
parents:
diff changeset
356
87128b876c63 add test
ikkun
parents:
diff changeset
357 case CUDA_ERROR_NOT_MAPPED:
87128b876c63 add test
ikkun
parents:
diff changeset
358 return "CUDA_ERROR_NOT_MAPPED";
87128b876c63 add test
ikkun
parents:
diff changeset
359
87128b876c63 add test
ikkun
parents:
diff changeset
360 case CUDA_ERROR_NOT_MAPPED_AS_ARRAY:
87128b876c63 add test
ikkun
parents:
diff changeset
361 return "CUDA_ERROR_NOT_MAPPED_AS_ARRAY";
87128b876c63 add test
ikkun
parents:
diff changeset
362
87128b876c63 add test
ikkun
parents:
diff changeset
363 case CUDA_ERROR_NOT_MAPPED_AS_POINTER:
87128b876c63 add test
ikkun
parents:
diff changeset
364 return "CUDA_ERROR_NOT_MAPPED_AS_POINTER";
87128b876c63 add test
ikkun
parents:
diff changeset
365
87128b876c63 add test
ikkun
parents:
diff changeset
366 case CUDA_ERROR_ECC_UNCORRECTABLE:
87128b876c63 add test
ikkun
parents:
diff changeset
367 return "CUDA_ERROR_ECC_UNCORRECTABLE";
87128b876c63 add test
ikkun
parents:
diff changeset
368
87128b876c63 add test
ikkun
parents:
diff changeset
369 case CUDA_ERROR_UNSUPPORTED_LIMIT:
87128b876c63 add test
ikkun
parents:
diff changeset
370 return "CUDA_ERROR_UNSUPPORTED_LIMIT";
87128b876c63 add test
ikkun
parents:
diff changeset
371
87128b876c63 add test
ikkun
parents:
diff changeset
372 case CUDA_ERROR_CONTEXT_ALREADY_IN_USE:
87128b876c63 add test
ikkun
parents:
diff changeset
373 return "CUDA_ERROR_CONTEXT_ALREADY_IN_USE";
87128b876c63 add test
ikkun
parents:
diff changeset
374
87128b876c63 add test
ikkun
parents:
diff changeset
375 case CUDA_ERROR_PEER_ACCESS_UNSUPPORTED:
87128b876c63 add test
ikkun
parents:
diff changeset
376 return "CUDA_ERROR_PEER_ACCESS_UNSUPPORTED";
87128b876c63 add test
ikkun
parents:
diff changeset
377
87128b876c63 add test
ikkun
parents:
diff changeset
378 case CUDA_ERROR_INVALID_PTX:
87128b876c63 add test
ikkun
parents:
diff changeset
379 return "CUDA_ERROR_INVALID_PTX";
87128b876c63 add test
ikkun
parents:
diff changeset
380
87128b876c63 add test
ikkun
parents:
diff changeset
381 case CUDA_ERROR_INVALID_GRAPHICS_CONTEXT:
87128b876c63 add test
ikkun
parents:
diff changeset
382 return "CUDA_ERROR_INVALID_GRAPHICS_CONTEXT";
87128b876c63 add test
ikkun
parents:
diff changeset
383
87128b876c63 add test
ikkun
parents:
diff changeset
384 case CUDA_ERROR_NVLINK_UNCORRECTABLE:
87128b876c63 add test
ikkun
parents:
diff changeset
385 return "CUDA_ERROR_NVLINK_UNCORRECTABLE";
87128b876c63 add test
ikkun
parents:
diff changeset
386
87128b876c63 add test
ikkun
parents:
diff changeset
387 case CUDA_ERROR_INVALID_SOURCE:
87128b876c63 add test
ikkun
parents:
diff changeset
388 return "CUDA_ERROR_INVALID_SOURCE";
87128b876c63 add test
ikkun
parents:
diff changeset
389
87128b876c63 add test
ikkun
parents:
diff changeset
390 case CUDA_ERROR_FILE_NOT_FOUND:
87128b876c63 add test
ikkun
parents:
diff changeset
391 return "CUDA_ERROR_FILE_NOT_FOUND";
87128b876c63 add test
ikkun
parents:
diff changeset
392
87128b876c63 add test
ikkun
parents:
diff changeset
393 case CUDA_ERROR_SHARED_OBJECT_SYMBOL_NOT_FOUND:
87128b876c63 add test
ikkun
parents:
diff changeset
394 return "CUDA_ERROR_SHARED_OBJECT_SYMBOL_NOT_FOUND";
87128b876c63 add test
ikkun
parents:
diff changeset
395
87128b876c63 add test
ikkun
parents:
diff changeset
396 case CUDA_ERROR_SHARED_OBJECT_INIT_FAILED:
87128b876c63 add test
ikkun
parents:
diff changeset
397 return "CUDA_ERROR_SHARED_OBJECT_INIT_FAILED";
87128b876c63 add test
ikkun
parents:
diff changeset
398
87128b876c63 add test
ikkun
parents:
diff changeset
399 case CUDA_ERROR_OPERATING_SYSTEM:
87128b876c63 add test
ikkun
parents:
diff changeset
400 return "CUDA_ERROR_OPERATING_SYSTEM";
87128b876c63 add test
ikkun
parents:
diff changeset
401
87128b876c63 add test
ikkun
parents:
diff changeset
402 case CUDA_ERROR_INVALID_HANDLE:
87128b876c63 add test
ikkun
parents:
diff changeset
403 return "CUDA_ERROR_INVALID_HANDLE";
87128b876c63 add test
ikkun
parents:
diff changeset
404
87128b876c63 add test
ikkun
parents:
diff changeset
405 case CUDA_ERROR_NOT_FOUND:
87128b876c63 add test
ikkun
parents:
diff changeset
406 return "CUDA_ERROR_NOT_FOUND";
87128b876c63 add test
ikkun
parents:
diff changeset
407
87128b876c63 add test
ikkun
parents:
diff changeset
408 case CUDA_ERROR_NOT_READY:
87128b876c63 add test
ikkun
parents:
diff changeset
409 return "CUDA_ERROR_NOT_READY";
87128b876c63 add test
ikkun
parents:
diff changeset
410
87128b876c63 add test
ikkun
parents:
diff changeset
411 case CUDA_ERROR_ILLEGAL_ADDRESS:
87128b876c63 add test
ikkun
parents:
diff changeset
412 return "CUDA_ERROR_ILLEGAL_ADDRESS";
87128b876c63 add test
ikkun
parents:
diff changeset
413
87128b876c63 add test
ikkun
parents:
diff changeset
414 case CUDA_ERROR_LAUNCH_FAILED:
87128b876c63 add test
ikkun
parents:
diff changeset
415 return "CUDA_ERROR_LAUNCH_FAILED";
87128b876c63 add test
ikkun
parents:
diff changeset
416
87128b876c63 add test
ikkun
parents:
diff changeset
417 case CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES:
87128b876c63 add test
ikkun
parents:
diff changeset
418 return "CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES";
87128b876c63 add test
ikkun
parents:
diff changeset
419
87128b876c63 add test
ikkun
parents:
diff changeset
420 case CUDA_ERROR_LAUNCH_TIMEOUT:
87128b876c63 add test
ikkun
parents:
diff changeset
421 return "CUDA_ERROR_LAUNCH_TIMEOUT";
87128b876c63 add test
ikkun
parents:
diff changeset
422
87128b876c63 add test
ikkun
parents:
diff changeset
423 case CUDA_ERROR_LAUNCH_INCOMPATIBLE_TEXTURING:
87128b876c63 add test
ikkun
parents:
diff changeset
424 return "CUDA_ERROR_LAUNCH_INCOMPATIBLE_TEXTURING";
87128b876c63 add test
ikkun
parents:
diff changeset
425
87128b876c63 add test
ikkun
parents:
diff changeset
426 case CUDA_ERROR_PEER_ACCESS_ALREADY_ENABLED:
87128b876c63 add test
ikkun
parents:
diff changeset
427 return "CUDA_ERROR_PEER_ACCESS_ALREADY_ENABLED";
87128b876c63 add test
ikkun
parents:
diff changeset
428
87128b876c63 add test
ikkun
parents:
diff changeset
429 case CUDA_ERROR_PEER_ACCESS_NOT_ENABLED:
87128b876c63 add test
ikkun
parents:
diff changeset
430 return "CUDA_ERROR_PEER_ACCESS_NOT_ENABLED";
87128b876c63 add test
ikkun
parents:
diff changeset
431
87128b876c63 add test
ikkun
parents:
diff changeset
432 case CUDA_ERROR_PRIMARY_CONTEXT_ACTIVE:
87128b876c63 add test
ikkun
parents:
diff changeset
433 return "CUDA_ERROR_PRIMARY_CONTEXT_ACTIVE";
87128b876c63 add test
ikkun
parents:
diff changeset
434
87128b876c63 add test
ikkun
parents:
diff changeset
435 case CUDA_ERROR_CONTEXT_IS_DESTROYED:
87128b876c63 add test
ikkun
parents:
diff changeset
436 return "CUDA_ERROR_CONTEXT_IS_DESTROYED";
87128b876c63 add test
ikkun
parents:
diff changeset
437
87128b876c63 add test
ikkun
parents:
diff changeset
438 case CUDA_ERROR_ASSERT:
87128b876c63 add test
ikkun
parents:
diff changeset
439 return "CUDA_ERROR_ASSERT";
87128b876c63 add test
ikkun
parents:
diff changeset
440
87128b876c63 add test
ikkun
parents:
diff changeset
441 case CUDA_ERROR_TOO_MANY_PEERS:
87128b876c63 add test
ikkun
parents:
diff changeset
442 return "CUDA_ERROR_TOO_MANY_PEERS";
87128b876c63 add test
ikkun
parents:
diff changeset
443
87128b876c63 add test
ikkun
parents:
diff changeset
444 case CUDA_ERROR_HOST_MEMORY_ALREADY_REGISTERED:
87128b876c63 add test
ikkun
parents:
diff changeset
445 return "CUDA_ERROR_HOST_MEMORY_ALREADY_REGISTERED";
87128b876c63 add test
ikkun
parents:
diff changeset
446
87128b876c63 add test
ikkun
parents:
diff changeset
447 case CUDA_ERROR_HOST_MEMORY_NOT_REGISTERED:
87128b876c63 add test
ikkun
parents:
diff changeset
448 return "CUDA_ERROR_HOST_MEMORY_NOT_REGISTERED";
87128b876c63 add test
ikkun
parents:
diff changeset
449
87128b876c63 add test
ikkun
parents:
diff changeset
450 case CUDA_ERROR_HARDWARE_STACK_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
451 return "CUDA_ERROR_HARDWARE_STACK_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
452
87128b876c63 add test
ikkun
parents:
diff changeset
453 case CUDA_ERROR_ILLEGAL_INSTRUCTION:
87128b876c63 add test
ikkun
parents:
diff changeset
454 return "CUDA_ERROR_ILLEGAL_INSTRUCTION";
87128b876c63 add test
ikkun
parents:
diff changeset
455
87128b876c63 add test
ikkun
parents:
diff changeset
456 case CUDA_ERROR_MISALIGNED_ADDRESS:
87128b876c63 add test
ikkun
parents:
diff changeset
457 return "CUDA_ERROR_MISALIGNED_ADDRESS";
87128b876c63 add test
ikkun
parents:
diff changeset
458
87128b876c63 add test
ikkun
parents:
diff changeset
459 case CUDA_ERROR_INVALID_ADDRESS_SPACE:
87128b876c63 add test
ikkun
parents:
diff changeset
460 return "CUDA_ERROR_INVALID_ADDRESS_SPACE";
87128b876c63 add test
ikkun
parents:
diff changeset
461
87128b876c63 add test
ikkun
parents:
diff changeset
462 case CUDA_ERROR_INVALID_PC:
87128b876c63 add test
ikkun
parents:
diff changeset
463 return "CUDA_ERROR_INVALID_PC";
87128b876c63 add test
ikkun
parents:
diff changeset
464
87128b876c63 add test
ikkun
parents:
diff changeset
465 case CUDA_ERROR_NOT_PERMITTED:
87128b876c63 add test
ikkun
parents:
diff changeset
466 return "CUDA_ERROR_NOT_PERMITTED";
87128b876c63 add test
ikkun
parents:
diff changeset
467
87128b876c63 add test
ikkun
parents:
diff changeset
468 case CUDA_ERROR_NOT_SUPPORTED:
87128b876c63 add test
ikkun
parents:
diff changeset
469 return "CUDA_ERROR_NOT_SUPPORTED";
87128b876c63 add test
ikkun
parents:
diff changeset
470
87128b876c63 add test
ikkun
parents:
diff changeset
471 case CUDA_ERROR_UNKNOWN:
87128b876c63 add test
ikkun
parents:
diff changeset
472 return "CUDA_ERROR_UNKNOWN";
87128b876c63 add test
ikkun
parents:
diff changeset
473 }
87128b876c63 add test
ikkun
parents:
diff changeset
474
87128b876c63 add test
ikkun
parents:
diff changeset
475 return "<unknown>";
87128b876c63 add test
ikkun
parents:
diff changeset
476 }
87128b876c63 add test
ikkun
parents:
diff changeset
477 #endif
87128b876c63 add test
ikkun
parents:
diff changeset
478
87128b876c63 add test
ikkun
parents:
diff changeset
479 #ifdef CUBLAS_API_H_
87128b876c63 add test
ikkun
parents:
diff changeset
480 // cuBLAS API errors
87128b876c63 add test
ikkun
parents:
diff changeset
481 static const char *_cudaGetErrorEnum(cublasStatus_t error)
87128b876c63 add test
ikkun
parents:
diff changeset
482 {
87128b876c63 add test
ikkun
parents:
diff changeset
483 switch (error)
87128b876c63 add test
ikkun
parents:
diff changeset
484 {
87128b876c63 add test
ikkun
parents:
diff changeset
485 case CUBLAS_STATUS_SUCCESS:
87128b876c63 add test
ikkun
parents:
diff changeset
486 return "CUBLAS_STATUS_SUCCESS";
87128b876c63 add test
ikkun
parents:
diff changeset
487
87128b876c63 add test
ikkun
parents:
diff changeset
488 case CUBLAS_STATUS_NOT_INITIALIZED:
87128b876c63 add test
ikkun
parents:
diff changeset
489 return "CUBLAS_STATUS_NOT_INITIALIZED";
87128b876c63 add test
ikkun
parents:
diff changeset
490
87128b876c63 add test
ikkun
parents:
diff changeset
491 case CUBLAS_STATUS_ALLOC_FAILED:
87128b876c63 add test
ikkun
parents:
diff changeset
492 return "CUBLAS_STATUS_ALLOC_FAILED";
87128b876c63 add test
ikkun
parents:
diff changeset
493
87128b876c63 add test
ikkun
parents:
diff changeset
494 case CUBLAS_STATUS_INVALID_VALUE:
87128b876c63 add test
ikkun
parents:
diff changeset
495 return "CUBLAS_STATUS_INVALID_VALUE";
87128b876c63 add test
ikkun
parents:
diff changeset
496
87128b876c63 add test
ikkun
parents:
diff changeset
497 case CUBLAS_STATUS_ARCH_MISMATCH:
87128b876c63 add test
ikkun
parents:
diff changeset
498 return "CUBLAS_STATUS_ARCH_MISMATCH";
87128b876c63 add test
ikkun
parents:
diff changeset
499
87128b876c63 add test
ikkun
parents:
diff changeset
500 case CUBLAS_STATUS_MAPPING_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
501 return "CUBLAS_STATUS_MAPPING_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
502
87128b876c63 add test
ikkun
parents:
diff changeset
503 case CUBLAS_STATUS_EXECUTION_FAILED:
87128b876c63 add test
ikkun
parents:
diff changeset
504 return "CUBLAS_STATUS_EXECUTION_FAILED";
87128b876c63 add test
ikkun
parents:
diff changeset
505
87128b876c63 add test
ikkun
parents:
diff changeset
506 case CUBLAS_STATUS_INTERNAL_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
507 return "CUBLAS_STATUS_INTERNAL_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
508
87128b876c63 add test
ikkun
parents:
diff changeset
509 case CUBLAS_STATUS_NOT_SUPPORTED:
87128b876c63 add test
ikkun
parents:
diff changeset
510 return "CUBLAS_STATUS_NOT_SUPPORTED";
87128b876c63 add test
ikkun
parents:
diff changeset
511
87128b876c63 add test
ikkun
parents:
diff changeset
512 case CUBLAS_STATUS_LICENSE_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
513 return "CUBLAS_STATUS_LICENSE_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
514 }
87128b876c63 add test
ikkun
parents:
diff changeset
515
87128b876c63 add test
ikkun
parents:
diff changeset
516 return "<unknown>";
87128b876c63 add test
ikkun
parents:
diff changeset
517 }
87128b876c63 add test
ikkun
parents:
diff changeset
518 #endif
87128b876c63 add test
ikkun
parents:
diff changeset
519
87128b876c63 add test
ikkun
parents:
diff changeset
520 #ifdef _CUFFT_H_
87128b876c63 add test
ikkun
parents:
diff changeset
521 // cuFFT API errors
87128b876c63 add test
ikkun
parents:
diff changeset
522 static const char *_cudaGetErrorEnum(cufftResult error)
87128b876c63 add test
ikkun
parents:
diff changeset
523 {
87128b876c63 add test
ikkun
parents:
diff changeset
524 switch (error)
87128b876c63 add test
ikkun
parents:
diff changeset
525 {
87128b876c63 add test
ikkun
parents:
diff changeset
526 case CUFFT_SUCCESS:
87128b876c63 add test
ikkun
parents:
diff changeset
527 return "CUFFT_SUCCESS";
87128b876c63 add test
ikkun
parents:
diff changeset
528
87128b876c63 add test
ikkun
parents:
diff changeset
529 case CUFFT_INVALID_PLAN:
87128b876c63 add test
ikkun
parents:
diff changeset
530 return "CUFFT_INVALID_PLAN";
87128b876c63 add test
ikkun
parents:
diff changeset
531
87128b876c63 add test
ikkun
parents:
diff changeset
532 case CUFFT_ALLOC_FAILED:
87128b876c63 add test
ikkun
parents:
diff changeset
533 return "CUFFT_ALLOC_FAILED";
87128b876c63 add test
ikkun
parents:
diff changeset
534
87128b876c63 add test
ikkun
parents:
diff changeset
535 case CUFFT_INVALID_TYPE:
87128b876c63 add test
ikkun
parents:
diff changeset
536 return "CUFFT_INVALID_TYPE";
87128b876c63 add test
ikkun
parents:
diff changeset
537
87128b876c63 add test
ikkun
parents:
diff changeset
538 case CUFFT_INVALID_VALUE:
87128b876c63 add test
ikkun
parents:
diff changeset
539 return "CUFFT_INVALID_VALUE";
87128b876c63 add test
ikkun
parents:
diff changeset
540
87128b876c63 add test
ikkun
parents:
diff changeset
541 case CUFFT_INTERNAL_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
542 return "CUFFT_INTERNAL_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
543
87128b876c63 add test
ikkun
parents:
diff changeset
544 case CUFFT_EXEC_FAILED:
87128b876c63 add test
ikkun
parents:
diff changeset
545 return "CUFFT_EXEC_FAILED";
87128b876c63 add test
ikkun
parents:
diff changeset
546
87128b876c63 add test
ikkun
parents:
diff changeset
547 case CUFFT_SETUP_FAILED:
87128b876c63 add test
ikkun
parents:
diff changeset
548 return "CUFFT_SETUP_FAILED";
87128b876c63 add test
ikkun
parents:
diff changeset
549
87128b876c63 add test
ikkun
parents:
diff changeset
550 case CUFFT_INVALID_SIZE:
87128b876c63 add test
ikkun
parents:
diff changeset
551 return "CUFFT_INVALID_SIZE";
87128b876c63 add test
ikkun
parents:
diff changeset
552
87128b876c63 add test
ikkun
parents:
diff changeset
553 case CUFFT_UNALIGNED_DATA:
87128b876c63 add test
ikkun
parents:
diff changeset
554 return "CUFFT_UNALIGNED_DATA";
87128b876c63 add test
ikkun
parents:
diff changeset
555
87128b876c63 add test
ikkun
parents:
diff changeset
556 case CUFFT_INCOMPLETE_PARAMETER_LIST:
87128b876c63 add test
ikkun
parents:
diff changeset
557 return "CUFFT_INCOMPLETE_PARAMETER_LIST";
87128b876c63 add test
ikkun
parents:
diff changeset
558
87128b876c63 add test
ikkun
parents:
diff changeset
559 case CUFFT_INVALID_DEVICE:
87128b876c63 add test
ikkun
parents:
diff changeset
560 return "CUFFT_INVALID_DEVICE";
87128b876c63 add test
ikkun
parents:
diff changeset
561
87128b876c63 add test
ikkun
parents:
diff changeset
562 case CUFFT_PARSE_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
563 return "CUFFT_PARSE_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
564
87128b876c63 add test
ikkun
parents:
diff changeset
565 case CUFFT_NO_WORKSPACE:
87128b876c63 add test
ikkun
parents:
diff changeset
566 return "CUFFT_NO_WORKSPACE";
87128b876c63 add test
ikkun
parents:
diff changeset
567
87128b876c63 add test
ikkun
parents:
diff changeset
568 case CUFFT_NOT_IMPLEMENTED:
87128b876c63 add test
ikkun
parents:
diff changeset
569 return "CUFFT_NOT_IMPLEMENTED";
87128b876c63 add test
ikkun
parents:
diff changeset
570
87128b876c63 add test
ikkun
parents:
diff changeset
571 case CUFFT_LICENSE_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
572 return "CUFFT_LICENSE_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
573
87128b876c63 add test
ikkun
parents:
diff changeset
574 case CUFFT_NOT_SUPPORTED:
87128b876c63 add test
ikkun
parents:
diff changeset
575 return "CUFFT_NOT_SUPPORTED";
87128b876c63 add test
ikkun
parents:
diff changeset
576 }
87128b876c63 add test
ikkun
parents:
diff changeset
577
87128b876c63 add test
ikkun
parents:
diff changeset
578 return "<unknown>";
87128b876c63 add test
ikkun
parents:
diff changeset
579 }
87128b876c63 add test
ikkun
parents:
diff changeset
580 #endif
87128b876c63 add test
ikkun
parents:
diff changeset
581
87128b876c63 add test
ikkun
parents:
diff changeset
582
87128b876c63 add test
ikkun
parents:
diff changeset
583 #ifdef CUSPARSEAPI
87128b876c63 add test
ikkun
parents:
diff changeset
584 // cuSPARSE API errors
87128b876c63 add test
ikkun
parents:
diff changeset
585 static const char *_cudaGetErrorEnum(cusparseStatus_t error)
87128b876c63 add test
ikkun
parents:
diff changeset
586 {
87128b876c63 add test
ikkun
parents:
diff changeset
587 switch (error)
87128b876c63 add test
ikkun
parents:
diff changeset
588 {
87128b876c63 add test
ikkun
parents:
diff changeset
589 case CUSPARSE_STATUS_SUCCESS:
87128b876c63 add test
ikkun
parents:
diff changeset
590 return "CUSPARSE_STATUS_SUCCESS";
87128b876c63 add test
ikkun
parents:
diff changeset
591
87128b876c63 add test
ikkun
parents:
diff changeset
592 case CUSPARSE_STATUS_NOT_INITIALIZED:
87128b876c63 add test
ikkun
parents:
diff changeset
593 return "CUSPARSE_STATUS_NOT_INITIALIZED";
87128b876c63 add test
ikkun
parents:
diff changeset
594
87128b876c63 add test
ikkun
parents:
diff changeset
595 case CUSPARSE_STATUS_ALLOC_FAILED:
87128b876c63 add test
ikkun
parents:
diff changeset
596 return "CUSPARSE_STATUS_ALLOC_FAILED";
87128b876c63 add test
ikkun
parents:
diff changeset
597
87128b876c63 add test
ikkun
parents:
diff changeset
598 case CUSPARSE_STATUS_INVALID_VALUE:
87128b876c63 add test
ikkun
parents:
diff changeset
599 return "CUSPARSE_STATUS_INVALID_VALUE";
87128b876c63 add test
ikkun
parents:
diff changeset
600
87128b876c63 add test
ikkun
parents:
diff changeset
601 case CUSPARSE_STATUS_ARCH_MISMATCH:
87128b876c63 add test
ikkun
parents:
diff changeset
602 return "CUSPARSE_STATUS_ARCH_MISMATCH";
87128b876c63 add test
ikkun
parents:
diff changeset
603
87128b876c63 add test
ikkun
parents:
diff changeset
604 case CUSPARSE_STATUS_MAPPING_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
605 return "CUSPARSE_STATUS_MAPPING_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
606
87128b876c63 add test
ikkun
parents:
diff changeset
607 case CUSPARSE_STATUS_EXECUTION_FAILED:
87128b876c63 add test
ikkun
parents:
diff changeset
608 return "CUSPARSE_STATUS_EXECUTION_FAILED";
87128b876c63 add test
ikkun
parents:
diff changeset
609
87128b876c63 add test
ikkun
parents:
diff changeset
610 case CUSPARSE_STATUS_INTERNAL_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
611 return "CUSPARSE_STATUS_INTERNAL_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
612
87128b876c63 add test
ikkun
parents:
diff changeset
613 case CUSPARSE_STATUS_MATRIX_TYPE_NOT_SUPPORTED:
87128b876c63 add test
ikkun
parents:
diff changeset
614 return "CUSPARSE_STATUS_MATRIX_TYPE_NOT_SUPPORTED";
87128b876c63 add test
ikkun
parents:
diff changeset
615 }
87128b876c63 add test
ikkun
parents:
diff changeset
616
87128b876c63 add test
ikkun
parents:
diff changeset
617 return "<unknown>";
87128b876c63 add test
ikkun
parents:
diff changeset
618 }
87128b876c63 add test
ikkun
parents:
diff changeset
619 #endif
87128b876c63 add test
ikkun
parents:
diff changeset
620
87128b876c63 add test
ikkun
parents:
diff changeset
621 #ifdef CUSOLVER_COMMON_H_
87128b876c63 add test
ikkun
parents:
diff changeset
622 //cuSOLVER API errors
87128b876c63 add test
ikkun
parents:
diff changeset
623 static const char *_cudaGetErrorEnum(cusolverStatus_t error)
87128b876c63 add test
ikkun
parents:
diff changeset
624 {
87128b876c63 add test
ikkun
parents:
diff changeset
625 switch(error)
87128b876c63 add test
ikkun
parents:
diff changeset
626 {
87128b876c63 add test
ikkun
parents:
diff changeset
627 case CUSOLVER_STATUS_SUCCESS:
87128b876c63 add test
ikkun
parents:
diff changeset
628 return "CUSOLVER_STATUS_SUCCESS";
87128b876c63 add test
ikkun
parents:
diff changeset
629 case CUSOLVER_STATUS_NOT_INITIALIZED:
87128b876c63 add test
ikkun
parents:
diff changeset
630 return "CUSOLVER_STATUS_NOT_INITIALIZED";
87128b876c63 add test
ikkun
parents:
diff changeset
631 case CUSOLVER_STATUS_ALLOC_FAILED:
87128b876c63 add test
ikkun
parents:
diff changeset
632 return "CUSOLVER_STATUS_ALLOC_FAILED";
87128b876c63 add test
ikkun
parents:
diff changeset
633 case CUSOLVER_STATUS_INVALID_VALUE:
87128b876c63 add test
ikkun
parents:
diff changeset
634 return "CUSOLVER_STATUS_INVALID_VALUE";
87128b876c63 add test
ikkun
parents:
diff changeset
635 case CUSOLVER_STATUS_ARCH_MISMATCH:
87128b876c63 add test
ikkun
parents:
diff changeset
636 return "CUSOLVER_STATUS_ARCH_MISMATCH";
87128b876c63 add test
ikkun
parents:
diff changeset
637 case CUSOLVER_STATUS_MAPPING_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
638 return "CUSOLVER_STATUS_MAPPING_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
639 case CUSOLVER_STATUS_EXECUTION_FAILED:
87128b876c63 add test
ikkun
parents:
diff changeset
640 return "CUSOLVER_STATUS_EXECUTION_FAILED";
87128b876c63 add test
ikkun
parents:
diff changeset
641 case CUSOLVER_STATUS_INTERNAL_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
642 return "CUSOLVER_STATUS_INTERNAL_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
643 case CUSOLVER_STATUS_MATRIX_TYPE_NOT_SUPPORTED:
87128b876c63 add test
ikkun
parents:
diff changeset
644 return "CUSOLVER_STATUS_MATRIX_TYPE_NOT_SUPPORTED";
87128b876c63 add test
ikkun
parents:
diff changeset
645 case CUSOLVER_STATUS_NOT_SUPPORTED :
87128b876c63 add test
ikkun
parents:
diff changeset
646 return "CUSOLVER_STATUS_NOT_SUPPORTED ";
87128b876c63 add test
ikkun
parents:
diff changeset
647 case CUSOLVER_STATUS_ZERO_PIVOT:
87128b876c63 add test
ikkun
parents:
diff changeset
648 return "CUSOLVER_STATUS_ZERO_PIVOT";
87128b876c63 add test
ikkun
parents:
diff changeset
649 case CUSOLVER_STATUS_INVALID_LICENSE:
87128b876c63 add test
ikkun
parents:
diff changeset
650 return "CUSOLVER_STATUS_INVALID_LICENSE";
87128b876c63 add test
ikkun
parents:
diff changeset
651 }
87128b876c63 add test
ikkun
parents:
diff changeset
652
87128b876c63 add test
ikkun
parents:
diff changeset
653 return "<unknown>";
87128b876c63 add test
ikkun
parents:
diff changeset
654
87128b876c63 add test
ikkun
parents:
diff changeset
655 }
87128b876c63 add test
ikkun
parents:
diff changeset
656 #endif
87128b876c63 add test
ikkun
parents:
diff changeset
657
87128b876c63 add test
ikkun
parents:
diff changeset
658 #ifdef CURAND_H_
87128b876c63 add test
ikkun
parents:
diff changeset
659 // cuRAND API errors
87128b876c63 add test
ikkun
parents:
diff changeset
660 static const char *_cudaGetErrorEnum(curandStatus_t error)
87128b876c63 add test
ikkun
parents:
diff changeset
661 {
87128b876c63 add test
ikkun
parents:
diff changeset
662 switch (error)
87128b876c63 add test
ikkun
parents:
diff changeset
663 {
87128b876c63 add test
ikkun
parents:
diff changeset
664 case CURAND_STATUS_SUCCESS:
87128b876c63 add test
ikkun
parents:
diff changeset
665 return "CURAND_STATUS_SUCCESS";
87128b876c63 add test
ikkun
parents:
diff changeset
666
87128b876c63 add test
ikkun
parents:
diff changeset
667 case CURAND_STATUS_VERSION_MISMATCH:
87128b876c63 add test
ikkun
parents:
diff changeset
668 return "CURAND_STATUS_VERSION_MISMATCH";
87128b876c63 add test
ikkun
parents:
diff changeset
669
87128b876c63 add test
ikkun
parents:
diff changeset
670 case CURAND_STATUS_NOT_INITIALIZED:
87128b876c63 add test
ikkun
parents:
diff changeset
671 return "CURAND_STATUS_NOT_INITIALIZED";
87128b876c63 add test
ikkun
parents:
diff changeset
672
87128b876c63 add test
ikkun
parents:
diff changeset
673 case CURAND_STATUS_ALLOCATION_FAILED:
87128b876c63 add test
ikkun
parents:
diff changeset
674 return "CURAND_STATUS_ALLOCATION_FAILED";
87128b876c63 add test
ikkun
parents:
diff changeset
675
87128b876c63 add test
ikkun
parents:
diff changeset
676 case CURAND_STATUS_TYPE_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
677 return "CURAND_STATUS_TYPE_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
678
87128b876c63 add test
ikkun
parents:
diff changeset
679 case CURAND_STATUS_OUT_OF_RANGE:
87128b876c63 add test
ikkun
parents:
diff changeset
680 return "CURAND_STATUS_OUT_OF_RANGE";
87128b876c63 add test
ikkun
parents:
diff changeset
681
87128b876c63 add test
ikkun
parents:
diff changeset
682 case CURAND_STATUS_LENGTH_NOT_MULTIPLE:
87128b876c63 add test
ikkun
parents:
diff changeset
683 return "CURAND_STATUS_LENGTH_NOT_MULTIPLE";
87128b876c63 add test
ikkun
parents:
diff changeset
684
87128b876c63 add test
ikkun
parents:
diff changeset
685 case CURAND_STATUS_DOUBLE_PRECISION_REQUIRED:
87128b876c63 add test
ikkun
parents:
diff changeset
686 return "CURAND_STATUS_DOUBLE_PRECISION_REQUIRED";
87128b876c63 add test
ikkun
parents:
diff changeset
687
87128b876c63 add test
ikkun
parents:
diff changeset
688 case CURAND_STATUS_LAUNCH_FAILURE:
87128b876c63 add test
ikkun
parents:
diff changeset
689 return "CURAND_STATUS_LAUNCH_FAILURE";
87128b876c63 add test
ikkun
parents:
diff changeset
690
87128b876c63 add test
ikkun
parents:
diff changeset
691 case CURAND_STATUS_PREEXISTING_FAILURE:
87128b876c63 add test
ikkun
parents:
diff changeset
692 return "CURAND_STATUS_PREEXISTING_FAILURE";
87128b876c63 add test
ikkun
parents:
diff changeset
693
87128b876c63 add test
ikkun
parents:
diff changeset
694 case CURAND_STATUS_INITIALIZATION_FAILED:
87128b876c63 add test
ikkun
parents:
diff changeset
695 return "CURAND_STATUS_INITIALIZATION_FAILED";
87128b876c63 add test
ikkun
parents:
diff changeset
696
87128b876c63 add test
ikkun
parents:
diff changeset
697 case CURAND_STATUS_ARCH_MISMATCH:
87128b876c63 add test
ikkun
parents:
diff changeset
698 return "CURAND_STATUS_ARCH_MISMATCH";
87128b876c63 add test
ikkun
parents:
diff changeset
699
87128b876c63 add test
ikkun
parents:
diff changeset
700 case CURAND_STATUS_INTERNAL_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
701 return "CURAND_STATUS_INTERNAL_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
702 }
87128b876c63 add test
ikkun
parents:
diff changeset
703
87128b876c63 add test
ikkun
parents:
diff changeset
704 return "<unknown>";
87128b876c63 add test
ikkun
parents:
diff changeset
705 }
87128b876c63 add test
ikkun
parents:
diff changeset
706 #endif
87128b876c63 add test
ikkun
parents:
diff changeset
707
87128b876c63 add test
ikkun
parents:
diff changeset
708 #ifdef NV_NPPIDEFS_H
87128b876c63 add test
ikkun
parents:
diff changeset
709 // NPP API errors
87128b876c63 add test
ikkun
parents:
diff changeset
710 static const char *_cudaGetErrorEnum(NppStatus error)
87128b876c63 add test
ikkun
parents:
diff changeset
711 {
87128b876c63 add test
ikkun
parents:
diff changeset
712 switch (error)
87128b876c63 add test
ikkun
parents:
diff changeset
713 {
87128b876c63 add test
ikkun
parents:
diff changeset
714 case NPP_NOT_SUPPORTED_MODE_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
715 return "NPP_NOT_SUPPORTED_MODE_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
716
87128b876c63 add test
ikkun
parents:
diff changeset
717 case NPP_ROUND_MODE_NOT_SUPPORTED_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
718 return "NPP_ROUND_MODE_NOT_SUPPORTED_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
719
87128b876c63 add test
ikkun
parents:
diff changeset
720 case NPP_RESIZE_NO_OPERATION_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
721 return "NPP_RESIZE_NO_OPERATION_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
722
87128b876c63 add test
ikkun
parents:
diff changeset
723 case NPP_NOT_SUFFICIENT_COMPUTE_CAPABILITY:
87128b876c63 add test
ikkun
parents:
diff changeset
724 return "NPP_NOT_SUFFICIENT_COMPUTE_CAPABILITY";
87128b876c63 add test
ikkun
parents:
diff changeset
725
87128b876c63 add test
ikkun
parents:
diff changeset
726 #if ((NPP_VERSION_MAJOR << 12) + (NPP_VERSION_MINOR << 4)) <= 0x5000
87128b876c63 add test
ikkun
parents:
diff changeset
727
87128b876c63 add test
ikkun
parents:
diff changeset
728 case NPP_BAD_ARG_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
729 return "NPP_BAD_ARGUMENT_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
730
87128b876c63 add test
ikkun
parents:
diff changeset
731 case NPP_COEFF_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
732 return "NPP_COEFFICIENT_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
733
87128b876c63 add test
ikkun
parents:
diff changeset
734 case NPP_RECT_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
735 return "NPP_RECTANGLE_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
736
87128b876c63 add test
ikkun
parents:
diff changeset
737 case NPP_QUAD_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
738 return "NPP_QUADRANGLE_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
739
87128b876c63 add test
ikkun
parents:
diff changeset
740 case NPP_MEM_ALLOC_ERR:
87128b876c63 add test
ikkun
parents:
diff changeset
741 return "NPP_MEMORY_ALLOCATION_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
742
87128b876c63 add test
ikkun
parents:
diff changeset
743 case NPP_HISTO_NUMBER_OF_LEVELS_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
744 return "NPP_HISTOGRAM_NUMBER_OF_LEVELS_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
745
87128b876c63 add test
ikkun
parents:
diff changeset
746 case NPP_INVALID_INPUT:
87128b876c63 add test
ikkun
parents:
diff changeset
747 return "NPP_INVALID_INPUT";
87128b876c63 add test
ikkun
parents:
diff changeset
748
87128b876c63 add test
ikkun
parents:
diff changeset
749 case NPP_POINTER_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
750 return "NPP_POINTER_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
751
87128b876c63 add test
ikkun
parents:
diff changeset
752 case NPP_WARNING:
87128b876c63 add test
ikkun
parents:
diff changeset
753 return "NPP_WARNING";
87128b876c63 add test
ikkun
parents:
diff changeset
754
87128b876c63 add test
ikkun
parents:
diff changeset
755 case NPP_ODD_ROI_WARNING:
87128b876c63 add test
ikkun
parents:
diff changeset
756 return "NPP_ODD_ROI_WARNING";
87128b876c63 add test
ikkun
parents:
diff changeset
757 #else
87128b876c63 add test
ikkun
parents:
diff changeset
758
87128b876c63 add test
ikkun
parents:
diff changeset
759 // These are for CUDA 5.5 or higher
87128b876c63 add test
ikkun
parents:
diff changeset
760 case NPP_BAD_ARGUMENT_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
761 return "NPP_BAD_ARGUMENT_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
762
87128b876c63 add test
ikkun
parents:
diff changeset
763 case NPP_COEFFICIENT_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
764 return "NPP_COEFFICIENT_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
765
87128b876c63 add test
ikkun
parents:
diff changeset
766 case NPP_RECTANGLE_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
767 return "NPP_RECTANGLE_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
768
87128b876c63 add test
ikkun
parents:
diff changeset
769 case NPP_QUADRANGLE_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
770 return "NPP_QUADRANGLE_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
771
87128b876c63 add test
ikkun
parents:
diff changeset
772 case NPP_MEMORY_ALLOCATION_ERR:
87128b876c63 add test
ikkun
parents:
diff changeset
773 return "NPP_MEMORY_ALLOCATION_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
774
87128b876c63 add test
ikkun
parents:
diff changeset
775 case NPP_HISTOGRAM_NUMBER_OF_LEVELS_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
776 return "NPP_HISTOGRAM_NUMBER_OF_LEVELS_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
777
87128b876c63 add test
ikkun
parents:
diff changeset
778 case NPP_INVALID_HOST_POINTER_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
779 return "NPP_INVALID_HOST_POINTER_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
780
87128b876c63 add test
ikkun
parents:
diff changeset
781 case NPP_INVALID_DEVICE_POINTER_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
782 return "NPP_INVALID_DEVICE_POINTER_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
783 #endif
87128b876c63 add test
ikkun
parents:
diff changeset
784
87128b876c63 add test
ikkun
parents:
diff changeset
785 case NPP_LUT_NUMBER_OF_LEVELS_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
786 return "NPP_LUT_NUMBER_OF_LEVELS_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
787
87128b876c63 add test
ikkun
parents:
diff changeset
788 case NPP_TEXTURE_BIND_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
789 return "NPP_TEXTURE_BIND_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
790
87128b876c63 add test
ikkun
parents:
diff changeset
791 case NPP_WRONG_INTERSECTION_ROI_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
792 return "NPP_WRONG_INTERSECTION_ROI_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
793
87128b876c63 add test
ikkun
parents:
diff changeset
794 case NPP_NOT_EVEN_STEP_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
795 return "NPP_NOT_EVEN_STEP_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
796
87128b876c63 add test
ikkun
parents:
diff changeset
797 case NPP_INTERPOLATION_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
798 return "NPP_INTERPOLATION_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
799
87128b876c63 add test
ikkun
parents:
diff changeset
800 case NPP_RESIZE_FACTOR_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
801 return "NPP_RESIZE_FACTOR_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
802
87128b876c63 add test
ikkun
parents:
diff changeset
803 case NPP_HAAR_CLASSIFIER_PIXEL_MATCH_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
804 return "NPP_HAAR_CLASSIFIER_PIXEL_MATCH_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
805
87128b876c63 add test
ikkun
parents:
diff changeset
806
87128b876c63 add test
ikkun
parents:
diff changeset
807 #if ((NPP_VERSION_MAJOR << 12) + (NPP_VERSION_MINOR << 4)) <= 0x5000
87128b876c63 add test
ikkun
parents:
diff changeset
808
87128b876c63 add test
ikkun
parents:
diff changeset
809 case NPP_MEMFREE_ERR:
87128b876c63 add test
ikkun
parents:
diff changeset
810 return "NPP_MEMFREE_ERR";
87128b876c63 add test
ikkun
parents:
diff changeset
811
87128b876c63 add test
ikkun
parents:
diff changeset
812 case NPP_MEMSET_ERR:
87128b876c63 add test
ikkun
parents:
diff changeset
813 return "NPP_MEMSET_ERR";
87128b876c63 add test
ikkun
parents:
diff changeset
814
87128b876c63 add test
ikkun
parents:
diff changeset
815 case NPP_MEMCPY_ERR:
87128b876c63 add test
ikkun
parents:
diff changeset
816 return "NPP_MEMCPY_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
817
87128b876c63 add test
ikkun
parents:
diff changeset
818 case NPP_MIRROR_FLIP_ERR:
87128b876c63 add test
ikkun
parents:
diff changeset
819 return "NPP_MIRROR_FLIP_ERR";
87128b876c63 add test
ikkun
parents:
diff changeset
820 #else
87128b876c63 add test
ikkun
parents:
diff changeset
821
87128b876c63 add test
ikkun
parents:
diff changeset
822 case NPP_MEMFREE_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
823 return "NPP_MEMFREE_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
824
87128b876c63 add test
ikkun
parents:
diff changeset
825 case NPP_MEMSET_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
826 return "NPP_MEMSET_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
827
87128b876c63 add test
ikkun
parents:
diff changeset
828 case NPP_MEMCPY_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
829 return "NPP_MEMCPY_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
830
87128b876c63 add test
ikkun
parents:
diff changeset
831 case NPP_MIRROR_FLIP_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
832 return "NPP_MIRROR_FLIP_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
833 #endif
87128b876c63 add test
ikkun
parents:
diff changeset
834
87128b876c63 add test
ikkun
parents:
diff changeset
835 case NPP_ALIGNMENT_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
836 return "NPP_ALIGNMENT_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
837
87128b876c63 add test
ikkun
parents:
diff changeset
838 case NPP_STEP_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
839 return "NPP_STEP_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
840
87128b876c63 add test
ikkun
parents:
diff changeset
841 case NPP_SIZE_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
842 return "NPP_SIZE_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
843
87128b876c63 add test
ikkun
parents:
diff changeset
844 case NPP_NULL_POINTER_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
845 return "NPP_NULL_POINTER_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
846
87128b876c63 add test
ikkun
parents:
diff changeset
847 case NPP_CUDA_KERNEL_EXECUTION_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
848 return "NPP_CUDA_KERNEL_EXECUTION_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
849
87128b876c63 add test
ikkun
parents:
diff changeset
850 case NPP_NOT_IMPLEMENTED_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
851 return "NPP_NOT_IMPLEMENTED_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
852
87128b876c63 add test
ikkun
parents:
diff changeset
853 case NPP_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
854 return "NPP_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
855
87128b876c63 add test
ikkun
parents:
diff changeset
856 case NPP_SUCCESS:
87128b876c63 add test
ikkun
parents:
diff changeset
857 return "NPP_SUCCESS";
87128b876c63 add test
ikkun
parents:
diff changeset
858
87128b876c63 add test
ikkun
parents:
diff changeset
859 case NPP_WRONG_INTERSECTION_QUAD_WARNING:
87128b876c63 add test
ikkun
parents:
diff changeset
860 return "NPP_WRONG_INTERSECTION_QUAD_WARNING";
87128b876c63 add test
ikkun
parents:
diff changeset
861
87128b876c63 add test
ikkun
parents:
diff changeset
862 case NPP_MISALIGNED_DST_ROI_WARNING:
87128b876c63 add test
ikkun
parents:
diff changeset
863 return "NPP_MISALIGNED_DST_ROI_WARNING";
87128b876c63 add test
ikkun
parents:
diff changeset
864
87128b876c63 add test
ikkun
parents:
diff changeset
865 case NPP_AFFINE_QUAD_INCORRECT_WARNING:
87128b876c63 add test
ikkun
parents:
diff changeset
866 return "NPP_AFFINE_QUAD_INCORRECT_WARNING";
87128b876c63 add test
ikkun
parents:
diff changeset
867
87128b876c63 add test
ikkun
parents:
diff changeset
868 case NPP_DOUBLE_SIZE_WARNING:
87128b876c63 add test
ikkun
parents:
diff changeset
869 return "NPP_DOUBLE_SIZE_WARNING";
87128b876c63 add test
ikkun
parents:
diff changeset
870
87128b876c63 add test
ikkun
parents:
diff changeset
871 case NPP_WRONG_INTERSECTION_ROI_WARNING:
87128b876c63 add test
ikkun
parents:
diff changeset
872 return "NPP_WRONG_INTERSECTION_ROI_WARNING";
87128b876c63 add test
ikkun
parents:
diff changeset
873
87128b876c63 add test
ikkun
parents:
diff changeset
874 #if ((NPP_VERSION_MAJOR << 12) + (NPP_VERSION_MINOR << 4)) >= 0x6000
87128b876c63 add test
ikkun
parents:
diff changeset
875 /* These are 6.0 or higher */
87128b876c63 add test
ikkun
parents:
diff changeset
876 case NPP_LUT_PALETTE_BITSIZE_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
877 return "NPP_LUT_PALETTE_BITSIZE_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
878
87128b876c63 add test
ikkun
parents:
diff changeset
879 case NPP_ZC_MODE_NOT_SUPPORTED_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
880 return "NPP_ZC_MODE_NOT_SUPPORTED_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
881
87128b876c63 add test
ikkun
parents:
diff changeset
882 case NPP_QUALITY_INDEX_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
883 return "NPP_QUALITY_INDEX_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
884
87128b876c63 add test
ikkun
parents:
diff changeset
885 case NPP_CHANNEL_ORDER_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
886 return "NPP_CHANNEL_ORDER_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
887
87128b876c63 add test
ikkun
parents:
diff changeset
888 case NPP_ZERO_MASK_VALUE_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
889 return "NPP_ZERO_MASK_VALUE_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
890
87128b876c63 add test
ikkun
parents:
diff changeset
891 case NPP_NUMBER_OF_CHANNELS_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
892 return "NPP_NUMBER_OF_CHANNELS_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
893
87128b876c63 add test
ikkun
parents:
diff changeset
894 case NPP_COI_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
895 return "NPP_COI_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
896
87128b876c63 add test
ikkun
parents:
diff changeset
897 case NPP_DIVISOR_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
898 return "NPP_DIVISOR_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
899
87128b876c63 add test
ikkun
parents:
diff changeset
900 case NPP_CHANNEL_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
901 return "NPP_CHANNEL_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
902
87128b876c63 add test
ikkun
parents:
diff changeset
903 case NPP_STRIDE_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
904 return "NPP_STRIDE_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
905
87128b876c63 add test
ikkun
parents:
diff changeset
906 case NPP_ANCHOR_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
907 return "NPP_ANCHOR_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
908
87128b876c63 add test
ikkun
parents:
diff changeset
909 case NPP_MASK_SIZE_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
910 return "NPP_MASK_SIZE_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
911
87128b876c63 add test
ikkun
parents:
diff changeset
912 case NPP_MOMENT_00_ZERO_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
913 return "NPP_MOMENT_00_ZERO_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
914
87128b876c63 add test
ikkun
parents:
diff changeset
915 case NPP_THRESHOLD_NEGATIVE_LEVEL_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
916 return "NPP_THRESHOLD_NEGATIVE_LEVEL_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
917
87128b876c63 add test
ikkun
parents:
diff changeset
918 case NPP_THRESHOLD_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
919 return "NPP_THRESHOLD_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
920
87128b876c63 add test
ikkun
parents:
diff changeset
921 case NPP_CONTEXT_MATCH_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
922 return "NPP_CONTEXT_MATCH_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
923
87128b876c63 add test
ikkun
parents:
diff changeset
924 case NPP_FFT_FLAG_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
925 return "NPP_FFT_FLAG_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
926
87128b876c63 add test
ikkun
parents:
diff changeset
927 case NPP_FFT_ORDER_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
928 return "NPP_FFT_ORDER_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
929
87128b876c63 add test
ikkun
parents:
diff changeset
930 case NPP_SCALE_RANGE_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
931 return "NPP_SCALE_RANGE_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
932
87128b876c63 add test
ikkun
parents:
diff changeset
933 case NPP_DATA_TYPE_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
934 return "NPP_DATA_TYPE_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
935
87128b876c63 add test
ikkun
parents:
diff changeset
936 case NPP_OUT_OFF_RANGE_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
937 return "NPP_OUT_OFF_RANGE_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
938
87128b876c63 add test
ikkun
parents:
diff changeset
939 case NPP_DIVIDE_BY_ZERO_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
940 return "NPP_DIVIDE_BY_ZERO_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
941
87128b876c63 add test
ikkun
parents:
diff changeset
942 case NPP_RANGE_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
943 return "NPP_RANGE_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
944
87128b876c63 add test
ikkun
parents:
diff changeset
945 case NPP_NO_MEMORY_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
946 return "NPP_NO_MEMORY_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
947
87128b876c63 add test
ikkun
parents:
diff changeset
948 case NPP_ERROR_RESERVED:
87128b876c63 add test
ikkun
parents:
diff changeset
949 return "NPP_ERROR_RESERVED";
87128b876c63 add test
ikkun
parents:
diff changeset
950
87128b876c63 add test
ikkun
parents:
diff changeset
951 case NPP_NO_OPERATION_WARNING:
87128b876c63 add test
ikkun
parents:
diff changeset
952 return "NPP_NO_OPERATION_WARNING";
87128b876c63 add test
ikkun
parents:
diff changeset
953
87128b876c63 add test
ikkun
parents:
diff changeset
954 case NPP_DIVIDE_BY_ZERO_WARNING:
87128b876c63 add test
ikkun
parents:
diff changeset
955 return "NPP_DIVIDE_BY_ZERO_WARNING";
87128b876c63 add test
ikkun
parents:
diff changeset
956 #endif
87128b876c63 add test
ikkun
parents:
diff changeset
957
87128b876c63 add test
ikkun
parents:
diff changeset
958 #if ((NPP_VERSION_MAJOR << 12) + (NPP_VERSION_MINOR << 4)) >= 0x7000
87128b876c63 add test
ikkun
parents:
diff changeset
959 /* These are 7.0 or higher */
87128b876c63 add test
ikkun
parents:
diff changeset
960 case NPP_OVERFLOW_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
961 return "NPP_OVERFLOW_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
962
87128b876c63 add test
ikkun
parents:
diff changeset
963 case NPP_CORRUPTED_DATA_ERROR:
87128b876c63 add test
ikkun
parents:
diff changeset
964 return "NPP_CORRUPTED_DATA_ERROR";
87128b876c63 add test
ikkun
parents:
diff changeset
965 #endif
87128b876c63 add test
ikkun
parents:
diff changeset
966 }
87128b876c63 add test
ikkun
parents:
diff changeset
967
87128b876c63 add test
ikkun
parents:
diff changeset
968 return "<unknown>";
87128b876c63 add test
ikkun
parents:
diff changeset
969 }
87128b876c63 add test
ikkun
parents:
diff changeset
970 #endif
87128b876c63 add test
ikkun
parents:
diff changeset
971
87128b876c63 add test
ikkun
parents:
diff changeset
972 #ifdef __DRIVER_TYPES_H__
87128b876c63 add test
ikkun
parents:
diff changeset
973 #ifndef DEVICE_RESET
87128b876c63 add test
ikkun
parents:
diff changeset
974 #define DEVICE_RESET cudaDeviceReset();
87128b876c63 add test
ikkun
parents:
diff changeset
975 #endif
87128b876c63 add test
ikkun
parents:
diff changeset
976 #else
87128b876c63 add test
ikkun
parents:
diff changeset
977 #ifndef DEVICE_RESET
87128b876c63 add test
ikkun
parents:
diff changeset
978 #define DEVICE_RESET
87128b876c63 add test
ikkun
parents:
diff changeset
979 #endif
87128b876c63 add test
ikkun
parents:
diff changeset
980 #endif
87128b876c63 add test
ikkun
parents:
diff changeset
981
304
9755206813cb helper_string.h for ANSI C
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 303
diff changeset
982 #ifndef __DRIVER_TYPES_H__
9755206813cb helper_string.h for ANSI C
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 303
diff changeset
983 static inline void check(CUresult result, char const *const func, const char *const file, int const line)
291
87128b876c63 add test
ikkun
parents:
diff changeset
984 {
87128b876c63 add test
ikkun
parents:
diff changeset
985 if (result)
87128b876c63 add test
ikkun
parents:
diff changeset
986 {
87128b876c63 add test
ikkun
parents:
diff changeset
987 fprintf(stderr, "CUDA error at %s:%d code=%d(%s) \"%s\" \n",
304
9755206813cb helper_string.h for ANSI C
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 303
diff changeset
988 file, line, (unsigned int)(result), _cudaGetErrorEnum(result), func);
291
87128b876c63 add test
ikkun
parents:
diff changeset
989 DEVICE_RESET
87128b876c63 add test
ikkun
parents:
diff changeset
990 // Make sure we call CUDA Device Reset before exiting
87128b876c63 add test
ikkun
parents:
diff changeset
991 exit(EXIT_FAILURE);
87128b876c63 add test
ikkun
parents:
diff changeset
992 }
87128b876c63 add test
ikkun
parents:
diff changeset
993 }
304
9755206813cb helper_string.h for ANSI C
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 303
diff changeset
994 #else
9755206813cb helper_string.h for ANSI C
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 303
diff changeset
995 static inline void check(cudaError_t result, char const *const func, const char *const file, int const line)
9755206813cb helper_string.h for ANSI C
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 303
diff changeset
996 {
9755206813cb helper_string.h for ANSI C
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 303
diff changeset
997 if (result)
9755206813cb helper_string.h for ANSI C
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 303
diff changeset
998 {
9755206813cb helper_string.h for ANSI C
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 303
diff changeset
999 fprintf(stderr, "CUDA error at %s:%d code=%d(%s) \"%s\" \n",
9755206813cb helper_string.h for ANSI C
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 303
diff changeset
1000 file, line, (unsigned int)(result), _cudaGetErrorEnum(result), func);
9755206813cb helper_string.h for ANSI C
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 303
diff changeset
1001 DEVICE_RESET
9755206813cb helper_string.h for ANSI C
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 303
diff changeset
1002 // Make sure we call CUDA Device Reset before exiting
9755206813cb helper_string.h for ANSI C
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 303
diff changeset
1003 exit(EXIT_FAILURE);
9755206813cb helper_string.h for ANSI C
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 303
diff changeset
1004 }
9755206813cb helper_string.h for ANSI C
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 303
diff changeset
1005 }
9755206813cb helper_string.h for ANSI C
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 303
diff changeset
1006 #endif
291
87128b876c63 add test
ikkun
parents:
diff changeset
1007
87128b876c63 add test
ikkun
parents:
diff changeset
1008 #ifdef __DRIVER_TYPES_H__
87128b876c63 add test
ikkun
parents:
diff changeset
1009 // This will output the proper CUDA error strings in the event that a CUDA host call returns an error
87128b876c63 add test
ikkun
parents:
diff changeset
1010 #define checkCudaErrors(val) check ( (val), #val, __FILE__, __LINE__ )
87128b876c63 add test
ikkun
parents:
diff changeset
1011
87128b876c63 add test
ikkun
parents:
diff changeset
1012 // This will output the proper error string when calling cudaGetLastError
87128b876c63 add test
ikkun
parents:
diff changeset
1013 #define getLastCudaError(msg) __getLastCudaError (msg, __FILE__, __LINE__)
87128b876c63 add test
ikkun
parents:
diff changeset
1014
87128b876c63 add test
ikkun
parents:
diff changeset
1015 inline void __getLastCudaError(const char *errorMessage, const char *file, const int line)
87128b876c63 add test
ikkun
parents:
diff changeset
1016 {
87128b876c63 add test
ikkun
parents:
diff changeset
1017 cudaError_t err = cudaGetLastError();
87128b876c63 add test
ikkun
parents:
diff changeset
1018
87128b876c63 add test
ikkun
parents:
diff changeset
1019 if (cudaSuccess != err)
87128b876c63 add test
ikkun
parents:
diff changeset
1020 {
87128b876c63 add test
ikkun
parents:
diff changeset
1021 fprintf(stderr, "%s(%i) : getLastCudaError() CUDA error : %s : (%d) %s.\n",
87128b876c63 add test
ikkun
parents:
diff changeset
1022 file, line, errorMessage, (int)err, cudaGetErrorString(err));
87128b876c63 add test
ikkun
parents:
diff changeset
1023 DEVICE_RESET
87128b876c63 add test
ikkun
parents:
diff changeset
1024 exit(EXIT_FAILURE);
87128b876c63 add test
ikkun
parents:
diff changeset
1025 }
87128b876c63 add test
ikkun
parents:
diff changeset
1026 }
87128b876c63 add test
ikkun
parents:
diff changeset
1027 #endif
87128b876c63 add test
ikkun
parents:
diff changeset
1028
87128b876c63 add test
ikkun
parents:
diff changeset
1029 #ifndef MAX
87128b876c63 add test
ikkun
parents:
diff changeset
1030 #define MAX(a,b) (a > b ? a : b)
87128b876c63 add test
ikkun
parents:
diff changeset
1031 #endif
87128b876c63 add test
ikkun
parents:
diff changeset
1032
87128b876c63 add test
ikkun
parents:
diff changeset
1033 // Float To Int conversion
87128b876c63 add test
ikkun
parents:
diff changeset
1034 inline int ftoi(float value)
87128b876c63 add test
ikkun
parents:
diff changeset
1035 {
87128b876c63 add test
ikkun
parents:
diff changeset
1036 return (value >= 0 ? (int)(value + 0.5) : (int)(value - 0.5));
87128b876c63 add test
ikkun
parents:
diff changeset
1037 }
87128b876c63 add test
ikkun
parents:
diff changeset
1038
87128b876c63 add test
ikkun
parents:
diff changeset
1039 // Beginning of GPU Architecture definitions
87128b876c63 add test
ikkun
parents:
diff changeset
1040 inline int _ConvertSMVer2Cores(int major, int minor)
87128b876c63 add test
ikkun
parents:
diff changeset
1041 {
87128b876c63 add test
ikkun
parents:
diff changeset
1042 // Defines for GPU Architecture types (using the SM version to determine the # of cores per SM
304
9755206813cb helper_string.h for ANSI C
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 303
diff changeset
1043 typedef struct sSMtoCores
291
87128b876c63 add test
ikkun
parents:
diff changeset
1044 {
87128b876c63 add test
ikkun
parents:
diff changeset
1045 int SM; // 0xMm (hexidecimal notation), M = SM Major version, and m = SM minor version
87128b876c63 add test
ikkun
parents:
diff changeset
1046 int Cores;
87128b876c63 add test
ikkun
parents:
diff changeset
1047 } sSMtoCores;
87128b876c63 add test
ikkun
parents:
diff changeset
1048
87128b876c63 add test
ikkun
parents:
diff changeset
1049 sSMtoCores nGpuArchCoresPerSM[] =
87128b876c63 add test
ikkun
parents:
diff changeset
1050 {
87128b876c63 add test
ikkun
parents:
diff changeset
1051 { 0x20, 32 }, // Fermi Generation (SM 2.0) GF100 class
87128b876c63 add test
ikkun
parents:
diff changeset
1052 { 0x21, 48 }, // Fermi Generation (SM 2.1) GF10x class
87128b876c63 add test
ikkun
parents:
diff changeset
1053 { 0x30, 192}, // Kepler Generation (SM 3.0) GK10x class
87128b876c63 add test
ikkun
parents:
diff changeset
1054 { 0x32, 192}, // Kepler Generation (SM 3.2) GK10x class
87128b876c63 add test
ikkun
parents:
diff changeset
1055 { 0x35, 192}, // Kepler Generation (SM 3.5) GK11x class
87128b876c63 add test
ikkun
parents:
diff changeset
1056 { 0x37, 192}, // Kepler Generation (SM 3.7) GK21x class
87128b876c63 add test
ikkun
parents:
diff changeset
1057 { 0x50, 128}, // Maxwell Generation (SM 5.0) GM10x class
87128b876c63 add test
ikkun
parents:
diff changeset
1058 { 0x52, 128}, // Maxwell Generation (SM 5.2) GM20x class
87128b876c63 add test
ikkun
parents:
diff changeset
1059 { 0x53, 128}, // Maxwell Generation (SM 5.3) GM20x class
87128b876c63 add test
ikkun
parents:
diff changeset
1060 { 0x60, 64 }, // Pascal Generation (SM 6.0) GP100 class
87128b876c63 add test
ikkun
parents:
diff changeset
1061 { 0x61, 128}, // Pascal Generation (SM 6.1) GP10x class
87128b876c63 add test
ikkun
parents:
diff changeset
1062 { 0x62, 128}, // Pascal Generation (SM 6.2) GP10x class
87128b876c63 add test
ikkun
parents:
diff changeset
1063 { -1, -1 }
87128b876c63 add test
ikkun
parents:
diff changeset
1064 };
87128b876c63 add test
ikkun
parents:
diff changeset
1065
87128b876c63 add test
ikkun
parents:
diff changeset
1066 int index = 0;
87128b876c63 add test
ikkun
parents:
diff changeset
1067
87128b876c63 add test
ikkun
parents:
diff changeset
1068 while (nGpuArchCoresPerSM[index].SM != -1)
87128b876c63 add test
ikkun
parents:
diff changeset
1069 {
87128b876c63 add test
ikkun
parents:
diff changeset
1070 if (nGpuArchCoresPerSM[index].SM == ((major << 4) + minor))
87128b876c63 add test
ikkun
parents:
diff changeset
1071 {
87128b876c63 add test
ikkun
parents:
diff changeset
1072 return nGpuArchCoresPerSM[index].Cores;
87128b876c63 add test
ikkun
parents:
diff changeset
1073 }
87128b876c63 add test
ikkun
parents:
diff changeset
1074
87128b876c63 add test
ikkun
parents:
diff changeset
1075 index++;
87128b876c63 add test
ikkun
parents:
diff changeset
1076 }
87128b876c63 add test
ikkun
parents:
diff changeset
1077
87128b876c63 add test
ikkun
parents:
diff changeset
1078 // If we don't find the values, we default use the previous one to run properly
87128b876c63 add test
ikkun
parents:
diff changeset
1079 printf("MapSMtoCores for SM %d.%d is undefined. Default to use %d Cores/SM\n", major, minor, nGpuArchCoresPerSM[index-1].Cores);
87128b876c63 add test
ikkun
parents:
diff changeset
1080 return nGpuArchCoresPerSM[index-1].Cores;
87128b876c63 add test
ikkun
parents:
diff changeset
1081 }
87128b876c63 add test
ikkun
parents:
diff changeset
1082 // end of GPU Architecture definitions
87128b876c63 add test
ikkun
parents:
diff changeset
1083
87128b876c63 add test
ikkun
parents:
diff changeset
1084 #ifdef __CUDA_RUNTIME_H__
87128b876c63 add test
ikkun
parents:
diff changeset
1085 // General GPU Device CUDA Initialization
87128b876c63 add test
ikkun
parents:
diff changeset
1086 inline int gpuDeviceInit(int devID)
87128b876c63 add test
ikkun
parents:
diff changeset
1087 {
87128b876c63 add test
ikkun
parents:
diff changeset
1088 int device_count;
87128b876c63 add test
ikkun
parents:
diff changeset
1089 checkCudaErrors(cudaGetDeviceCount(&device_count));
87128b876c63 add test
ikkun
parents:
diff changeset
1090
87128b876c63 add test
ikkun
parents:
diff changeset
1091 if (device_count == 0)
87128b876c63 add test
ikkun
parents:
diff changeset
1092 {
87128b876c63 add test
ikkun
parents:
diff changeset
1093 fprintf(stderr, "gpuDeviceInit() CUDA error: no devices supporting CUDA.\n");
87128b876c63 add test
ikkun
parents:
diff changeset
1094 exit(EXIT_FAILURE);
87128b876c63 add test
ikkun
parents:
diff changeset
1095 }
87128b876c63 add test
ikkun
parents:
diff changeset
1096
87128b876c63 add test
ikkun
parents:
diff changeset
1097 if (devID < 0)
87128b876c63 add test
ikkun
parents:
diff changeset
1098 {
87128b876c63 add test
ikkun
parents:
diff changeset
1099 devID = 0;
87128b876c63 add test
ikkun
parents:
diff changeset
1100 }
87128b876c63 add test
ikkun
parents:
diff changeset
1101
87128b876c63 add test
ikkun
parents:
diff changeset
1102 if (devID > device_count-1)
87128b876c63 add test
ikkun
parents:
diff changeset
1103 {
87128b876c63 add test
ikkun
parents:
diff changeset
1104 fprintf(stderr, "\n");
87128b876c63 add test
ikkun
parents:
diff changeset
1105 fprintf(stderr, ">> %d CUDA capable GPU device(s) detected. <<\n", device_count);
87128b876c63 add test
ikkun
parents:
diff changeset
1106 fprintf(stderr, ">> gpuDeviceInit (-device=%d) is not a valid GPU device. <<\n", devID);
87128b876c63 add test
ikkun
parents:
diff changeset
1107 fprintf(stderr, "\n");
87128b876c63 add test
ikkun
parents:
diff changeset
1108 return -devID;
87128b876c63 add test
ikkun
parents:
diff changeset
1109 }
87128b876c63 add test
ikkun
parents:
diff changeset
1110
304
9755206813cb helper_string.h for ANSI C
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 303
diff changeset
1111 struct cudaDeviceProp deviceProp;
291
87128b876c63 add test
ikkun
parents:
diff changeset
1112 checkCudaErrors(cudaGetDeviceProperties(&deviceProp, devID));
87128b876c63 add test
ikkun
parents:
diff changeset
1113
87128b876c63 add test
ikkun
parents:
diff changeset
1114 if (deviceProp.computeMode == cudaComputeModeProhibited)
87128b876c63 add test
ikkun
parents:
diff changeset
1115 {
87128b876c63 add test
ikkun
parents:
diff changeset
1116 fprintf(stderr, "Error: device is running in <Compute Mode Prohibited>, no threads can use ::cudaSetDevice().\n");
87128b876c63 add test
ikkun
parents:
diff changeset
1117 return -1;
87128b876c63 add test
ikkun
parents:
diff changeset
1118 }
87128b876c63 add test
ikkun
parents:
diff changeset
1119
87128b876c63 add test
ikkun
parents:
diff changeset
1120 if (deviceProp.major < 1)
87128b876c63 add test
ikkun
parents:
diff changeset
1121 {
87128b876c63 add test
ikkun
parents:
diff changeset
1122 fprintf(stderr, "gpuDeviceInit(): GPU device does not support CUDA.\n");
87128b876c63 add test
ikkun
parents:
diff changeset
1123 exit(EXIT_FAILURE);
87128b876c63 add test
ikkun
parents:
diff changeset
1124 }
87128b876c63 add test
ikkun
parents:
diff changeset
1125
87128b876c63 add test
ikkun
parents:
diff changeset
1126 checkCudaErrors(cudaSetDevice(devID));
87128b876c63 add test
ikkun
parents:
diff changeset
1127 printf("gpuDeviceInit() CUDA Device [%d]: \"%s\n", devID, deviceProp.name);
87128b876c63 add test
ikkun
parents:
diff changeset
1128
87128b876c63 add test
ikkun
parents:
diff changeset
1129 return devID;
87128b876c63 add test
ikkun
parents:
diff changeset
1130 }
87128b876c63 add test
ikkun
parents:
diff changeset
1131
87128b876c63 add test
ikkun
parents:
diff changeset
1132 // This function returns the best GPU (with maximum GFLOPS)
87128b876c63 add test
ikkun
parents:
diff changeset
1133 inline int gpuGetMaxGflopsDeviceId()
87128b876c63 add test
ikkun
parents:
diff changeset
1134 {
87128b876c63 add test
ikkun
parents:
diff changeset
1135 int current_device = 0, sm_per_multiproc = 0;
87128b876c63 add test
ikkun
parents:
diff changeset
1136 int max_perf_device = 0;
87128b876c63 add test
ikkun
parents:
diff changeset
1137 int device_count = 0, best_SM_arch = 0;
87128b876c63 add test
ikkun
parents:
diff changeset
1138 int devices_prohibited = 0;
87128b876c63 add test
ikkun
parents:
diff changeset
1139
87128b876c63 add test
ikkun
parents:
diff changeset
1140 unsigned long long max_compute_perf = 0;
304
9755206813cb helper_string.h for ANSI C
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 303
diff changeset
1141 struct cudaDeviceProp deviceProp;
291
87128b876c63 add test
ikkun
parents:
diff changeset
1142 cudaGetDeviceCount(&device_count);
87128b876c63 add test
ikkun
parents:
diff changeset
1143
87128b876c63 add test
ikkun
parents:
diff changeset
1144 checkCudaErrors(cudaGetDeviceCount(&device_count));
87128b876c63 add test
ikkun
parents:
diff changeset
1145
87128b876c63 add test
ikkun
parents:
diff changeset
1146 if (device_count == 0)
87128b876c63 add test
ikkun
parents:
diff changeset
1147 {
87128b876c63 add test
ikkun
parents:
diff changeset
1148 fprintf(stderr, "gpuGetMaxGflopsDeviceId() CUDA error: no devices supporting CUDA.\n");
87128b876c63 add test
ikkun
parents:
diff changeset
1149 exit(EXIT_FAILURE);
87128b876c63 add test
ikkun
parents:
diff changeset
1150 }
87128b876c63 add test
ikkun
parents:
diff changeset
1151
87128b876c63 add test
ikkun
parents:
diff changeset
1152 // Find the best major SM Architecture GPU device
87128b876c63 add test
ikkun
parents:
diff changeset
1153 while (current_device < device_count)
87128b876c63 add test
ikkun
parents:
diff changeset
1154 {
87128b876c63 add test
ikkun
parents:
diff changeset
1155 cudaGetDeviceProperties(&deviceProp, current_device);
87128b876c63 add test
ikkun
parents:
diff changeset
1156
87128b876c63 add test
ikkun
parents:
diff changeset
1157 // If this GPU is not running on Compute Mode prohibited, then we can add it to the list
87128b876c63 add test
ikkun
parents:
diff changeset
1158 if (deviceProp.computeMode != cudaComputeModeProhibited)
87128b876c63 add test
ikkun
parents:
diff changeset
1159 {
87128b876c63 add test
ikkun
parents:
diff changeset
1160 if (deviceProp.major > 0 && deviceProp.major < 9999)
87128b876c63 add test
ikkun
parents:
diff changeset
1161 {
87128b876c63 add test
ikkun
parents:
diff changeset
1162 best_SM_arch = MAX(best_SM_arch, deviceProp.major);
87128b876c63 add test
ikkun
parents:
diff changeset
1163 }
87128b876c63 add test
ikkun
parents:
diff changeset
1164 }
87128b876c63 add test
ikkun
parents:
diff changeset
1165 else
87128b876c63 add test
ikkun
parents:
diff changeset
1166 {
87128b876c63 add test
ikkun
parents:
diff changeset
1167 devices_prohibited++;
87128b876c63 add test
ikkun
parents:
diff changeset
1168 }
87128b876c63 add test
ikkun
parents:
diff changeset
1169
87128b876c63 add test
ikkun
parents:
diff changeset
1170 current_device++;
87128b876c63 add test
ikkun
parents:
diff changeset
1171 }
87128b876c63 add test
ikkun
parents:
diff changeset
1172
87128b876c63 add test
ikkun
parents:
diff changeset
1173 if (devices_prohibited == device_count)
87128b876c63 add test
ikkun
parents:
diff changeset
1174 {
87128b876c63 add test
ikkun
parents:
diff changeset
1175 fprintf(stderr, "gpuGetMaxGflopsDeviceId() CUDA error: all devices have compute mode prohibited.\n");
87128b876c63 add test
ikkun
parents:
diff changeset
1176 exit(EXIT_FAILURE);
87128b876c63 add test
ikkun
parents:
diff changeset
1177 }
87128b876c63 add test
ikkun
parents:
diff changeset
1178
87128b876c63 add test
ikkun
parents:
diff changeset
1179 // Find the best CUDA capable GPU device
87128b876c63 add test
ikkun
parents:
diff changeset
1180 current_device = 0;
87128b876c63 add test
ikkun
parents:
diff changeset
1181
87128b876c63 add test
ikkun
parents:
diff changeset
1182 while (current_device < device_count)
87128b876c63 add test
ikkun
parents:
diff changeset
1183 {
87128b876c63 add test
ikkun
parents:
diff changeset
1184 cudaGetDeviceProperties(&deviceProp, current_device);
87128b876c63 add test
ikkun
parents:
diff changeset
1185
87128b876c63 add test
ikkun
parents:
diff changeset
1186 // If this GPU is not running on Compute Mode prohibited, then we can add it to the list
87128b876c63 add test
ikkun
parents:
diff changeset
1187 if (deviceProp.computeMode != cudaComputeModeProhibited)
87128b876c63 add test
ikkun
parents:
diff changeset
1188 {
87128b876c63 add test
ikkun
parents:
diff changeset
1189 if (deviceProp.major == 9999 && deviceProp.minor == 9999)
87128b876c63 add test
ikkun
parents:
diff changeset
1190 {
87128b876c63 add test
ikkun
parents:
diff changeset
1191 sm_per_multiproc = 1;
87128b876c63 add test
ikkun
parents:
diff changeset
1192 }
87128b876c63 add test
ikkun
parents:
diff changeset
1193 else
87128b876c63 add test
ikkun
parents:
diff changeset
1194 {
87128b876c63 add test
ikkun
parents:
diff changeset
1195 sm_per_multiproc = _ConvertSMVer2Cores(deviceProp.major, deviceProp.minor);
87128b876c63 add test
ikkun
parents:
diff changeset
1196 }
87128b876c63 add test
ikkun
parents:
diff changeset
1197
87128b876c63 add test
ikkun
parents:
diff changeset
1198 unsigned long long compute_perf = (unsigned long long) deviceProp.multiProcessorCount * sm_per_multiproc * deviceProp.clockRate;
87128b876c63 add test
ikkun
parents:
diff changeset
1199
87128b876c63 add test
ikkun
parents:
diff changeset
1200 if (compute_perf > max_compute_perf)
87128b876c63 add test
ikkun
parents:
diff changeset
1201 {
87128b876c63 add test
ikkun
parents:
diff changeset
1202 // If we find GPU with SM major > 2, search only these
87128b876c63 add test
ikkun
parents:
diff changeset
1203 if (best_SM_arch > 2)
87128b876c63 add test
ikkun
parents:
diff changeset
1204 {
87128b876c63 add test
ikkun
parents:
diff changeset
1205 // If our device==dest_SM_arch, choose this, or else pass
87128b876c63 add test
ikkun
parents:
diff changeset
1206 if (deviceProp.major == best_SM_arch)
87128b876c63 add test
ikkun
parents:
diff changeset
1207 {
87128b876c63 add test
ikkun
parents:
diff changeset
1208 max_compute_perf = compute_perf;
87128b876c63 add test
ikkun
parents:
diff changeset
1209 max_perf_device = current_device;
87128b876c63 add test
ikkun
parents:
diff changeset
1210 }
87128b876c63 add test
ikkun
parents:
diff changeset
1211 }
87128b876c63 add test
ikkun
parents:
diff changeset
1212 else
87128b876c63 add test
ikkun
parents:
diff changeset
1213 {
87128b876c63 add test
ikkun
parents:
diff changeset
1214 max_compute_perf = compute_perf;
87128b876c63 add test
ikkun
parents:
diff changeset
1215 max_perf_device = current_device;
87128b876c63 add test
ikkun
parents:
diff changeset
1216 }
87128b876c63 add test
ikkun
parents:
diff changeset
1217 }
87128b876c63 add test
ikkun
parents:
diff changeset
1218 }
87128b876c63 add test
ikkun
parents:
diff changeset
1219
87128b876c63 add test
ikkun
parents:
diff changeset
1220 ++current_device;
87128b876c63 add test
ikkun
parents:
diff changeset
1221 }
87128b876c63 add test
ikkun
parents:
diff changeset
1222
87128b876c63 add test
ikkun
parents:
diff changeset
1223 return max_perf_device;
87128b876c63 add test
ikkun
parents:
diff changeset
1224 }
87128b876c63 add test
ikkun
parents:
diff changeset
1225
87128b876c63 add test
ikkun
parents:
diff changeset
1226
87128b876c63 add test
ikkun
parents:
diff changeset
1227 // Initialization code to find the best CUDA Device
87128b876c63 add test
ikkun
parents:
diff changeset
1228 inline int findCudaDevice(int argc, const char **argv)
87128b876c63 add test
ikkun
parents:
diff changeset
1229 {
304
9755206813cb helper_string.h for ANSI C
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 303
diff changeset
1230 struct cudaDeviceProp deviceProp;
291
87128b876c63 add test
ikkun
parents:
diff changeset
1231 int devID = 0;
87128b876c63 add test
ikkun
parents:
diff changeset
1232
87128b876c63 add test
ikkun
parents:
diff changeset
1233 // If the command-line has a device number specified, use it
87128b876c63 add test
ikkun
parents:
diff changeset
1234 if (checkCmdLineFlag(argc, argv, "device"))
87128b876c63 add test
ikkun
parents:
diff changeset
1235 {
87128b876c63 add test
ikkun
parents:
diff changeset
1236 devID = getCmdLineArgumentInt(argc, argv, "device=");
87128b876c63 add test
ikkun
parents:
diff changeset
1237
87128b876c63 add test
ikkun
parents:
diff changeset
1238 if (devID < 0)
87128b876c63 add test
ikkun
parents:
diff changeset
1239 {
87128b876c63 add test
ikkun
parents:
diff changeset
1240 printf("Invalid command line parameter\n ");
87128b876c63 add test
ikkun
parents:
diff changeset
1241 exit(EXIT_FAILURE);
87128b876c63 add test
ikkun
parents:
diff changeset
1242 }
87128b876c63 add test
ikkun
parents:
diff changeset
1243 else
87128b876c63 add test
ikkun
parents:
diff changeset
1244 {
87128b876c63 add test
ikkun
parents:
diff changeset
1245 devID = gpuDeviceInit(devID);
87128b876c63 add test
ikkun
parents:
diff changeset
1246
87128b876c63 add test
ikkun
parents:
diff changeset
1247 if (devID < 0)
87128b876c63 add test
ikkun
parents:
diff changeset
1248 {
87128b876c63 add test
ikkun
parents:
diff changeset
1249 printf("exiting...\n");
87128b876c63 add test
ikkun
parents:
diff changeset
1250 exit(EXIT_FAILURE);
87128b876c63 add test
ikkun
parents:
diff changeset
1251 }
87128b876c63 add test
ikkun
parents:
diff changeset
1252 }
87128b876c63 add test
ikkun
parents:
diff changeset
1253 }
87128b876c63 add test
ikkun
parents:
diff changeset
1254 else
87128b876c63 add test
ikkun
parents:
diff changeset
1255 {
87128b876c63 add test
ikkun
parents:
diff changeset
1256 // Otherwise pick the device with highest Gflops/s
87128b876c63 add test
ikkun
parents:
diff changeset
1257 devID = gpuGetMaxGflopsDeviceId();
87128b876c63 add test
ikkun
parents:
diff changeset
1258 checkCudaErrors(cudaSetDevice(devID));
87128b876c63 add test
ikkun
parents:
diff changeset
1259 checkCudaErrors(cudaGetDeviceProperties(&deviceProp, devID));
87128b876c63 add test
ikkun
parents:
diff changeset
1260 printf("GPU Device %d: \"%s\" with compute capability %d.%d\n\n", devID, deviceProp.name, deviceProp.major, deviceProp.minor);
87128b876c63 add test
ikkun
parents:
diff changeset
1261 }
87128b876c63 add test
ikkun
parents:
diff changeset
1262
87128b876c63 add test
ikkun
parents:
diff changeset
1263 return devID;
87128b876c63 add test
ikkun
parents:
diff changeset
1264 }
87128b876c63 add test
ikkun
parents:
diff changeset
1265
87128b876c63 add test
ikkun
parents:
diff changeset
1266 // General check for CUDA GPU SM Capabilities
87128b876c63 add test
ikkun
parents:
diff changeset
1267 inline bool checkCudaCapabilities(int major_version, int minor_version)
87128b876c63 add test
ikkun
parents:
diff changeset
1268 {
304
9755206813cb helper_string.h for ANSI C
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 303
diff changeset
1269 struct cudaDeviceProp deviceProp;
291
87128b876c63 add test
ikkun
parents:
diff changeset
1270 deviceProp.major = 0;
87128b876c63 add test
ikkun
parents:
diff changeset
1271 deviceProp.minor = 0;
87128b876c63 add test
ikkun
parents:
diff changeset
1272 int dev;
87128b876c63 add test
ikkun
parents:
diff changeset
1273
87128b876c63 add test
ikkun
parents:
diff changeset
1274 checkCudaErrors(cudaGetDevice(&dev));
87128b876c63 add test
ikkun
parents:
diff changeset
1275 checkCudaErrors(cudaGetDeviceProperties(&deviceProp, dev));
87128b876c63 add test
ikkun
parents:
diff changeset
1276
87128b876c63 add test
ikkun
parents:
diff changeset
1277 if ((deviceProp.major > major_version) ||
87128b876c63 add test
ikkun
parents:
diff changeset
1278 (deviceProp.major == major_version && deviceProp.minor >= minor_version))
87128b876c63 add test
ikkun
parents:
diff changeset
1279 {
87128b876c63 add test
ikkun
parents:
diff changeset
1280 printf(" Device %d: <%16s >, Compute SM %d.%d detected\n", dev, deviceProp.name, deviceProp.major, deviceProp.minor);
87128b876c63 add test
ikkun
parents:
diff changeset
1281 return true;
87128b876c63 add test
ikkun
parents:
diff changeset
1282 }
87128b876c63 add test
ikkun
parents:
diff changeset
1283 else
87128b876c63 add test
ikkun
parents:
diff changeset
1284 {
87128b876c63 add test
ikkun
parents:
diff changeset
1285 printf(" No GPU device was found that can support CUDA compute capability %d.%d.\n", major_version, minor_version);
87128b876c63 add test
ikkun
parents:
diff changeset
1286 return false;
87128b876c63 add test
ikkun
parents:
diff changeset
1287 }
87128b876c63 add test
ikkun
parents:
diff changeset
1288 }
87128b876c63 add test
ikkun
parents:
diff changeset
1289 #endif
87128b876c63 add test
ikkun
parents:
diff changeset
1290
87128b876c63 add test
ikkun
parents:
diff changeset
1291 // end of CUDA Helper Functions
87128b876c63 add test
ikkun
parents:
diff changeset
1292
87128b876c63 add test
ikkun
parents:
diff changeset
1293
87128b876c63 add test
ikkun
parents:
diff changeset
1294 #endif