comparison hello/oclUtils.h @ 0:0e6e76dbdb0f

add file
author Yutaka_Kinjyo
date Tue, 12 Jul 2011 11:12:51 +0900
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:0e6e76dbdb0f
1 #ifndef OCL_UTILS_H
2 #define OCL_UTILS_H
3
4 #include <OpenCL/opencl.h>
5 #include <stdio.h>
6 #include <stdlib.h>
7
8 // SDK Revision #
9 #define OCL_SDKREVISION "6161726"
10
11 // Error and Exit Handling Macros...
12 // *********************************************************************
13 // Full error handling macro with Cleanup() callback (if supplied)...
14 // (Companion Inline Function lower on page)
15 #define oclCheckErrorEX(a, b, c) __oclCheckErrorEX(a, b, c, __FILE__ , __LINE__)
16
17 // Short version without Cleanup() callback pointer
18 // Both Input (a) and Reference (b) are specified as args
19 #define oclCheckError(a, b) oclCheckErrorEX(a, b, 0)
20
21 extern "C" const char* oclErrorString(cl_int error);
22
23 inline void __oclCheckErrorEX(cl_int iSample, cl_int iReference, void (*pCleanup)(int), const char* cFile, const int iLine)
24 {
25 // An error condition is defined by the sample/test value not equal to the reference
26 if (iReference != iSample)
27 {
28 // If the sample/test value isn't equal to the ref, it's an error by defnition, so override 0 sample/test value
29 iSample = (iSample == 0) ? -9999 : iSample;
30
31 // Log the error info
32 //shrLog("\n !!! Error # %i (%s) at line %i , in file %s !!!\n\n", iSample, oclErrorString(iSample), iLine, cFile);
33
34 printf("\n !!! Error # %i (%s) at line %i , in file %s !!!\n\n", iSample, oclErrorString(iSample), iLine, cFile);
35
36 // Cleanup and exit, or just exit if no cleanup function pointer provided. Use iSample (error code in this case) as process exit code.
37 if (pCleanup != NULL)
38 {
39 pCleanup(iSample);
40 }
41 else
42 {
43 //shrLogEx(LOGBOTH | CLOSELOG, 0, "Exiting...\n");
44 exit(iSample);
45 }
46 }
47 }
48
49 #endif
50