0
|
1 #include "oclUtils.h"
|
|
2 #include <fstream>
|
|
3 #include <vector>
|
|
4 #include <iostream>
|
|
5 #include <algorithm>
|
|
6 #include <stdarg.h>
|
|
7
|
|
8 // Helper function to get OpenCL error string from constant
|
|
9 // *********************************************************************
|
|
10 const char* oclErrorString(cl_int error)
|
|
11 {
|
|
12 static const char* errorString[] = {
|
|
13 "CL_SUCCESS",
|
|
14 "CL_DEVICE_NOT_FOUND",
|
|
15 "CL_DEVICE_NOT_AVAILABLE",
|
|
16 "CL_COMPILER_NOT_AVAILABLE",
|
|
17 "CL_MEM_OBJECT_ALLOCATION_FAILURE",
|
|
18 "CL_OUT_OF_RESOURCES",
|
|
19 "CL_OUT_OF_HOST_MEMORY",
|
|
20 "CL_PROFILING_INFO_NOT_AVAILABLE",
|
|
21 "CL_MEM_COPY_OVERLAP",
|
|
22 "CL_IMAGE_FORMAT_MISMATCH",
|
|
23 "CL_IMAGE_FORMAT_NOT_SUPPORTED",
|
|
24 "CL_BUILD_PROGRAM_FAILURE",
|
|
25 "CL_MAP_FAILURE",
|
|
26 "",
|
|
27 "",
|
|
28 "",
|
|
29 "",
|
|
30 "",
|
|
31 "",
|
|
32 "",
|
|
33 "",
|
|
34 "",
|
|
35 "",
|
|
36 "",
|
|
37 "",
|
|
38 "",
|
|
39 "",
|
|
40 "",
|
|
41 "",
|
|
42 "",
|
|
43 "CL_INVALID_VALUE",
|
|
44 "CL_INVALID_DEVICE_TYPE",
|
|
45 "CL_INVALID_PLATFORM",
|
|
46 "CL_INVALID_DEVICE",
|
|
47 "CL_INVALID_CONTEXT",
|
|
48 "CL_INVALID_QUEUE_PROPERTIES",
|
|
49 "CL_INVALID_COMMAND_QUEUE",
|
|
50 "CL_INVALID_HOST_PTR",
|
|
51 "CL_INVALID_MEM_OBJECT",
|
|
52 "CL_INVALID_IMAGE_FORMAT_DESCRIPTOR",
|
|
53 "CL_INVALID_IMAGE_SIZE",
|
|
54 "CL_INVALID_SAMPLER",
|
|
55 "CL_INVALID_BINARY",
|
|
56 "CL_INVALID_BUILD_OPTIONS",
|
|
57 "CL_INVALID_PROGRAM",
|
|
58 "CL_INVALID_PROGRAM_EXECUTABLE",
|
|
59 "CL_INVALID_KERNEL_NAME",
|
|
60 "CL_INVALID_KERNEL_DEFINITION",
|
|
61 "CL_INVALID_KERNEL",
|
|
62 "CL_INVALID_ARG_INDEX",
|
|
63 "CL_INVALID_ARG_VALUE",
|
|
64 "CL_INVALID_ARG_SIZE",
|
|
65 "CL_INVALID_KERNEL_ARGS",
|
|
66 "CL_INVALID_WORK_DIMENSION",
|
|
67 "CL_INVALID_WORK_GROUP_SIZE",
|
|
68 "CL_INVALID_WORK_ITEM_SIZE",
|
|
69 "CL_INVALID_GLOBAL_OFFSET",
|
|
70 "CL_INVALID_EVENT_WAIT_LIST",
|
|
71 "CL_INVALID_EVENT",
|
|
72 "CL_INVALID_OPERATION",
|
|
73 "CL_INVALID_GL_OBJECT",
|
|
74 "CL_INVALID_BUFFER_SIZE",
|
|
75 "CL_INVALID_MIP_LEVEL",
|
|
76 "CL_INVALID_GLOBAL_WORK_SIZE",
|
|
77 };
|
|
78
|
|
79 const int errorCount = sizeof(errorString) / sizeof(errorString[0]);
|
|
80
|
|
81 const int index = -error;
|
|
82
|
|
83 return (index >= 0 && index < errorCount) ? errorString[index] : "Unspecified Error";
|
|
84 }
|
|
85
|
1
|
86 //////////////////////////////////////////////////////////////////////////////
|
|
87 //! Get and log the binary (PTX) from the OpenCL compiler for the requested program & device
|
|
88 //!
|
|
89 //! @param cpProgram OpenCL program
|
|
90 //! @param cdDevice device of interest
|
|
91 //////////////////////////////////////////////////////////////////////////////
|
|
92 void oclLogBuildInfo(cl_program cpProgram, cl_device_id cdDevice)
|
|
93 {
|
|
94 // write out the build log and ptx, then exit
|
|
95 char cBuildLog[10240];
|
|
96 clGetProgramBuildInfo(cpProgram, cdDevice, CL_PROGRAM_BUILD_LOG,
|
|
97 sizeof(cBuildLog), cBuildLog, NULL );
|
|
98 //shrLog("\n%s\nBuild Log:\n%s\n%s\n", HDASHLINE, cBuildLog, HDASHLINE);
|
|
99 printf("Build Log:\n%s\n", cBuildLog);
|
|
100 }
|
|
101
|