-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommon.cpp
More file actions
129 lines (122 loc) · 5.2 KB
/
common.cpp
File metadata and controls
129 lines (122 loc) · 5.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#include "common.h"
using namespace auglag1gpu;
int auglag1gpu::DIVCEIL(int a, int b) {
if(a % b == 0)
return a/b;
else
return a/b + 1;
}
const std::pair<cl_int, const std::string> messages[] = {
std::pair<cl_int, const std::string>(CL_SUCCESS, "Success"),
std::pair<cl_int, const std::string>(CL_DEVICE_NOT_FOUND,
"Device not found"),
std::pair<cl_int, const std::string>(CL_DEVICE_NOT_AVAILABLE,
"Device not available"),
std::pair<cl_int, const std::string>(CL_COMPILER_NOT_AVAILABLE,
"Compiler not available"),
std::pair<cl_int, const std::string>(CL_MEM_OBJECT_ALLOCATION_FAILURE,
"Memory object allocation error"),
std::pair<cl_int, const std::string>(CL_OUT_OF_RESOURCES,
"Out of resources"),
std::pair<cl_int, const std::string>(CL_OUT_OF_HOST_MEMORY,
"Out of host memory"),
std::pair<cl_int, const std::string>(CL_PROFILING_INFO_NOT_AVAILABLE,
"Profiling info not available"),
std::pair<cl_int, const std::string>(CL_MEM_COPY_OVERLAP,
"Memory copy overlap"),
std::pair<cl_int, const std::string>(CL_IMAGE_FORMAT_MISMATCH,
"Image format mismatch"),
std::pair<cl_int, const std::string>(CL_IMAGE_FORMAT_NOT_SUPPORTED,
"Image format not supported"),
std::pair<cl_int, const std::string>(CL_BUILD_PROGRAM_FAILURE,
"Program build failure"),
std::pair<cl_int, const std::string>(CL_MAP_FAILURE, "Map failure"),
std::pair<cl_int, const std::string>(CL_MISALIGNED_SUB_BUFFER_OFFSET,
"Misaligned sub-buffer offset"),
std::pair<cl_int, const std::string>(
CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST,
"Execution status error for events in wait list"),
std::pair<cl_int, const std::string>(CL_INVALID_VALUE, "Invalid value"),
std::pair<cl_int, const std::string>(CL_INVALID_DEVICE_TYPE,
"Invalid device type"),
std::pair<cl_int, const std::string>(CL_INVALID_PLATFORM,
"Invalid platform"),
std::pair<cl_int, const std::string>(CL_INVALID_DEVICE, "Invalid device"),
std::pair<cl_int, const std::string>(CL_INVALID_CONTEXT,
"Invalid context"),
std::pair<cl_int, const std::string>(CL_INVALID_QUEUE_PROPERTIES,
"Invalid command queue properties"),
std::pair<cl_int, const std::string>(CL_INVALID_COMMAND_QUEUE,
"Invalid command queue"),
std::pair<cl_int, const std::string>(CL_INVALID_HOST_PTR,
"Invalid host memory pointer"),
std::pair<cl_int, const std::string>(CL_INVALID_MEM_OBJECT,
"Invalid device memory object"),
std::pair<cl_int, const std::string>(CL_INVALID_IMAGE_FORMAT_DESCRIPTOR,
"Invalid image format descriptor"),
std::pair<cl_int, const std::string>(CL_INVALID_IMAGE_SIZE,
"Invalid image size"),
std::pair<cl_int, const std::string>(CL_INVALID_SAMPLER,
"Invalid image sampler"),
std::pair<cl_int, const std::string>(CL_INVALID_BINARY,
"Invalid program binary"),
std::pair<cl_int, const std::string>(CL_INVALID_BUILD_OPTIONS,
"Invalid program build options"),
std::pair<cl_int, const std::string>(CL_INVALID_PROGRAM,
"Invalid program object"),
std::pair<cl_int, const std::string>(CL_INVALID_PROGRAM_EXECUTABLE,
"Invalid program executable"),
std::pair<cl_int, const std::string>(CL_INVALID_KERNEL_NAME,
"Invalid kernel name"),
std::pair<cl_int, const std::string>(CL_INVALID_KERNEL_DEFINITION,
"Invalid kernel definition"),
std::pair<cl_int, const std::string>(CL_INVALID_KERNEL, "Invalid kernel"),
std::pair<cl_int, const std::string>(CL_INVALID_ARG_INDEX,
"Invalid kernel argument index"),
std::pair<cl_int, const std::string>(CL_INVALID_ARG_VALUE,
"Invalid kernel argument value"),
std::pair<cl_int, const std::string>(CL_INVALID_ARG_SIZE,
"Invalid kernel argument size"),
std::pair<cl_int, const std::string>(CL_INVALID_KERNEL_ARGS,
"Invalid kernel arguments"),
std::pair<cl_int, const std::string>(CL_INVALID_WORK_DIMENSION,
"Invalid work dimensions"),
std::pair<cl_int, const std::string>(CL_INVALID_WORK_GROUP_SIZE,
"Invalid work group size"),
std::pair<cl_int, const std::string>(CL_INVALID_WORK_ITEM_SIZE,
"Invalid work item size"),
std::pair<cl_int, const std::string>(CL_INVALID_GLOBAL_OFFSET,
"Invalid global offset"),
std::pair<cl_int, const std::string>(CL_INVALID_EVENT_WAIT_LIST,
"Invalid event wait list"),
std::pair<cl_int, const std::string>(CL_INVALID_EVENT, "Invalid event"),
std::pair<cl_int, const std::string>(CL_INVALID_OPERATION,
"Invalid operation"),
std::pair<cl_int, const std::string>(CL_INVALID_GL_OBJECT,
"Invalid OpenGL object"),
std::pair<cl_int, const std::string>(CL_INVALID_BUFFER_SIZE,
"Invalid buffer size"),
std::pair<cl_int, const std::string>(CL_INVALID_MIP_LEVEL,
"Invalid MIP level"),
std::pair<cl_int, const std::string>(CL_INVALID_GLOBAL_WORK_SIZE,
"Invalid global work size"),
std::pair<cl_int, const std::string>(CL_INVALID_PROPERTY,
"Invalid property")
#ifdef CL_PLATFORM_NOT_FOUND_KHR
,std::pair<cl_int, const std::string>(CL_PLATFORM_NOT_FOUND_KHR,
"Platform not found KHR")
#endif
};
std::string auglag1gpu::CLErrorMessage(cl_int code) {
std::string errorMessage = "Unknown error";
for(size_t i = 0;
i < sizeof(messages)/sizeof(std::pair<cl_int, const std::string>);
i++) {
if(messages[i].first == code) {
errorMessage = messages[i].second;
break;
}
}
return "OpenCL error: " + errorMessage + " (Error code: " +
toString(code) + ").";
}