DPC++ Runtime
Runtime libraries for oneAPI DPC++
common.cpp
Go to the documentation of this file.
1 //==----------- common.cpp -----------------------------------------------==//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
11 
13 namespace sycl {
14 namespace detail {
15 
16 const char *stringifyErrorCode(cl_int error) {
17  switch (error) {
18  case CL_INVALID_ACCELERATOR_INTEL:
19  return "CL_INVALID_ACCELERATOR_INTEL";
20  case CL_INVALID_ACCELERATOR_TYPE_INTEL:
21  return "CL_INVALID_ACCELERATOR_TYPE_INTEL";
22  case CL_INVALID_ACCELERATOR_DESCRIPTOR_INTEL:
23  return "CL_INVALID_ACCELERATOR_DESCRIPTOR_INTEL";
24  case CL_ACCELERATOR_TYPE_NOT_SUPPORTED_INTEL:
25  return "CL_ACCELERATOR_TYPE_NOT_SUPPORTED_INTEL";
26  case CL_PLATFORM_NOT_FOUND_KHR:
27  return "CL_PLATFORM_NOT_FOUND_KHR";
28  case CL_DEVICE_PARTITION_FAILED_EXT:
29  return "CL_DEVICE_PARTITION_FAILED_EXT";
30  case CL_INVALID_PARTITION_COUNT_EXT:
31  return "CL_INVALID_PARTITION_COUNT_EXT";
32  case CL_INVALID_PARTITION_NAME_EXT:
33  return "CL_INVALID_PARTITION_NAME_EXT";
34  /* case CL_INVALID_DX9_DEVICE_INTEL:
35  return "CL_INVALID_DX9_DEVICE_INTEL";
36  case CL_INVALID_DX9_RESOURCE_INTEL:
37  return "CL_INVALID_DX9_RESOURCE_INTEL";
38  case CL_DX9_RESOURCE_ALREADY_ACQUIRED_INTEL:
39  return "CL_DX9_RESOURCE_ALREADY_ACQUIRED_INTEL";
40  case CL_DX9_RESOURCE_NOT_ACQUIRED_INTEL:
41  return "CL_DX9_RESOURCE_NOT_ACQUIRED_INTEL";
42  case CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR:
43  return "CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR";
44  */
45  case CL_SUCCESS:
46  return "CL_SUCCESS";
47  case CL_DEVICE_NOT_FOUND:
48  return "CL_DEVICE_NOT_FOUND";
49  case CL_DEVICE_NOT_AVAILABLE:
50  return "CL_DEVICE_NOT_AVAILABLE";
51  case CL_COMPILER_NOT_AVAILABLE:
52  return "CL_COMPILER_NOT_AVAILABLE";
53  case CL_MEM_OBJECT_ALLOCATION_FAILURE:
54  return "CL_MEM_OBJECT_ALLOCATION_FAILURE";
55  case CL_OUT_OF_RESOURCES:
56  return "CL_OUT_OF_RESOURCES";
57  case CL_OUT_OF_HOST_MEMORY:
58  return "CL_OUT_OF_HOST_MEMORY";
59  case CL_PROFILING_INFO_NOT_AVAILABLE:
60  return "CL_PROFILING_INFO_NOT_AVAILABLE";
61  case CL_MEM_COPY_OVERLAP:
62  return "CL_MEM_COPY_OVERLAP";
63  case CL_IMAGE_FORMAT_MISMATCH:
64  return "CL_IMAGE_FORMAT_MISMATCH";
65  case CL_IMAGE_FORMAT_NOT_SUPPORTED:
66  return "CL_IMAGE_FORMAT_NOT_SUPPORTED";
67  case CL_BUILD_PROGRAM_FAILURE:
68  return "CL_BUILD_PROGRAM_FAILURE";
69  case CL_MAP_FAILURE:
70  return "CL_MAP_FAILURE";
71  case CL_MISALIGNED_SUB_BUFFER_OFFSET:
72  return "CL_MISALIGNED_SUB_BUFFER_OFFSET";
73  case CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST:
74  return "CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST";
75  case CL_COMPILE_PROGRAM_FAILURE:
76  return "CL_COMPILE_PROGRAM_FAILURE";
77  case CL_LINKER_NOT_AVAILABLE:
78  return "CL_LINKER_NOT_AVAILABLE";
79  case CL_LINK_PROGRAM_FAILURE:
80  return "CL_LINK_PROGRAM_FAILURE";
81  case CL_DEVICE_PARTITION_FAILED:
82  return "CL_DEVICE_PARTITION_FAILED";
83  case CL_KERNEL_ARG_INFO_NOT_AVAILABLE:
84  return "CL_KERNEL_ARG_INFO_NOT_AVAILABLE";
85  case CL_INVALID_VALUE:
86  return "CL_INVALID_VALUE";
87  case CL_INVALID_DEVICE_TYPE:
88  return "CL_INVALID_DEVICE_TYPE";
89  case CL_INVALID_PLATFORM:
90  return "CL_INVALID_PLATFORM";
91  case CL_INVALID_DEVICE:
92  return "CL_INVALID_DEVICE";
93  case CL_INVALID_CONTEXT:
94  return "CL_INVALID_CONTEXT";
95  case CL_INVALID_QUEUE_PROPERTIES:
96  return "CL_INVALID_QUEUE_PROPERTIES";
97  case CL_INVALID_COMMAND_QUEUE:
98  return "CL_INVALID_COMMAND_QUEUE";
99  case CL_INVALID_HOST_PTR:
100  return "CL_INVALID_HOST_PTR";
101  case CL_INVALID_MEM_OBJECT:
102  return "CL_INVALID_MEM_OBJECT";
103  case CL_INVALID_IMAGE_FORMAT_DESCRIPTOR:
104  return "CL_INVALID_IMAGE_FORMAT_DESCRIPTOR";
105  case CL_INVALID_IMAGE_SIZE:
106  return "CL_INVALID_IMAGE_SIZE";
107  case CL_INVALID_SAMPLER:
108  return "CL_INVALID_SAMPLER";
109  case CL_INVALID_BINARY:
110  return "CL_INVALID_BINARY";
111  case CL_INVALID_BUILD_OPTIONS:
112  return "CL_INVALID_BUILD_OPTIONS";
113  case CL_INVALID_PROGRAM:
114  return "CL_INVALID_PROGRAM";
115  case CL_INVALID_PROGRAM_EXECUTABLE:
116  return "CL_INVALID_PROGRAM_EXECUTABLE";
117  case CL_INVALID_KERNEL_NAME:
118  return "CL_INVALID_KERNEL_NAME";
119  case CL_INVALID_KERNEL_DEFINITION:
120  return "CL_INVALID_KERNEL_DEFINITION";
121  case CL_INVALID_KERNEL:
122  return "CL_INVALID_KERNEL";
123  case CL_INVALID_ARG_INDEX:
124  return "CL_INVALID_ARG_INDEX";
125  case CL_INVALID_ARG_VALUE:
126  return "CL_INVALID_ARG_VALUE";
127  case CL_INVALID_ARG_SIZE:
128  return "CL_INVALID_ARG_SIZE";
129  case CL_INVALID_KERNEL_ARGS:
130  return "CL_INVALID_KERNEL_ARGS";
131  case CL_INVALID_WORK_DIMENSION:
132  return "CL_INVALID_WORK_DIMENSION";
133  case CL_INVALID_WORK_GROUP_SIZE:
134  return "CL_INVALID_WORK_GROUP_SIZE";
135  case CL_INVALID_WORK_ITEM_SIZE:
136  return "CL_INVALID_WORK_ITEM_SIZE";
137  case CL_INVALID_GLOBAL_OFFSET:
138  return "CL_INVALID_GLOBAL_OFFSET";
139  case CL_INVALID_EVENT_WAIT_LIST:
140  return "CL_INVALID_EVENT_WAIT_LIST";
141  case CL_INVALID_EVENT:
142  return "CL_INVALID_EVENT";
143  case CL_INVALID_OPERATION:
144  return "CL_INVALID_OPERATION";
145  case CL_INVALID_GL_OBJECT:
146  return "CL_INVALID_GL_OBJECT";
147  case CL_INVALID_BUFFER_SIZE:
148  return "CL_INVALID_BUFFER_SIZE";
149  case CL_INVALID_MIP_LEVEL:
150  return "CL_INVALID_MIP_LEVEL";
151  case CL_INVALID_GLOBAL_WORK_SIZE:
152  return "CL_INVALID_GLOBAL_WORK_SIZE";
153  case CL_INVALID_PROPERTY:
154  return "CL_INVALID_PROPERTY";
155  case CL_INVALID_IMAGE_DESCRIPTOR:
156  return "CL_INVALID_IMAGE_DESCRIPTOR";
157  case CL_INVALID_COMPILER_OPTIONS:
158  return "CL_INVALID_COMPILER_OPTIONS";
159  case CL_INVALID_LINKER_OPTIONS:
160  return "CL_INVALID_LINKER_OPTIONS";
161  case CL_INVALID_DEVICE_PARTITION_COUNT:
162  return "CL_INVALID_DEVICE_PARTITION_COUNT";
163 #ifdef CL_VERSION_2_0
164  case CL_INVALID_PIPE_SIZE:
165  return "CL_INVALID_PIPE_SIZE";
166  case CL_INVALID_DEVICE_QUEUE:
167  return "CL_INVALID_DEVICE_QUEUE";
168 #endif
169 #ifdef CL_VERSION_2_2
170  case CL_INVALID_SPEC_ID:
171  return "CL_INVALID_SPEC_ID";
172  case CL_MAX_SIZE_RESTRICTION_EXCEEDED:
173  return "CL_MAX_SIZE_RESTRICTION_EXCEEDED";
174 #endif
175  /*
176  case CL_BUILD_NONE:
177  return "CL_BUILD_NONE";
178  case CL_BUILD_ERROR:
179  return "CL_BUILD_ERROR";
180  case CL_BUILD_IN_PROGRESS:
181  return "CL_BUILD_IN_PROGRESS";
182  case CL_INVALID_VA_API_MEDIA_ADAPTER_INTEL:
183  return "CL_INVALID_VA_API_MEDIA_ADAPTER_INTEL";
184  case CL_INVALID_VA_API_MEDIA_SURFACE_INTEL:
185  return "CL_INVALID_VA_API_MEDIA_SURFACE_INTEL";
186  case CL_VA_API_MEDIA_SURFACE_ALREADY_ACQUIRED_INTEL:
187  return "CL_VA_API_MEDIA_SURFACE_ALREADY_ACQUIRED_INTEL";
188  case CL_VA_API_MEDIA_SURFACE_NOT_ACQUIRED_INTEL:
189  return "CL_VA_API_MEDIA_SURFACE_NOT_ACQUIRED_INTEL";
190  case CL_INVALID_EGL_OBJECT_KHR:
191  return "CL_INVALID_EGL_OBJECT_KHR";
192  case CL_EGL_RESOURCE_NOT_ACQUIRED_KHR:
193  return "CL_EGL_RESOURCE_NOT_ACQUIRED_KHR";
194  case CL_INVALID_D3D11_DEVICE_KHR:
195  return "CL_INVALID_D3D11_DEVICE_KHR";
196  case CL_INVALID_D3D11_RESOURCE_KHR:
197  return "CL_INVALID_D3D11_RESOURCE_KHR";
198  case CL_D3D11_RESOURCE_ALREADY_ACQUIRED_KHR:
199  return "CL_D3D11_RESOURCE_ALREADY_ACQUIRED_KHR";
200  case CL_D3D11_RESOURCE_NOT_ACQUIRED_KHR:
201  return "CL_D3D11_RESOURCE_NOT_ACQUIRED_KHR";
202  case CL_INVALID_D3D10_DEVICE_KHR:
203  return "CL_INVALID_D3D10_DEVICE_KHR";
204  case CL_INVALID_D3D10_RESOURCE_KHR:
205  return "CL_INVALID_D3D10_RESOURCE_KHR";
206  case CL_D3D10_RESOURCE_ALREADY_ACQUIRED_KHR:
207  return "CL_D3D10_RESOURCE_ALREADY_ACQUIRED_KHR";
208  case CL_D3D10_RESOURCE_NOT_ACQUIRED_KHR:
209  return "CL_D3D10_RESOURCE_NOT_ACQUIRED_KHR";
210  case CL_INVALID_DX9_MEDIA_ADAPTER_KHR:
211  return "CL_INVALID_DX9_MEDIA_ADAPTER_KHR";
212  case CL_INVALID_DX9_MEDIA_SURFACE_KHR:
213  return "CL_INVALID_DX9_MEDIA_SURFACE_KHR";
214  case CL_DX9_MEDIA_SURFACE_ALREADY_ACQUIRED_KHR:
215  return "CL_DX9_MEDIA_SURFACE_ALREADY_ACQUIRED_KHR";
216  case CL_DX9_MEDIA_SURFACE_NOT_ACQUIRED_KHR:
217  return "CL_DX9_MEDIA_SURFACE_NOT_ACQUIRED_KHR";
218  */
220  return "Function exists but address is not available";
222  return "The plugin has emitted a backend specific error";
224  return "Command failed to enqueue/execute";
225  default:
226  return "Unknown OpenCL error code";
227  }
228 }
229 
230 std::vector<std::string> split_string(const std::string &str, char delimeter) {
231  std::vector<std::string> result;
232  size_t beg = 0;
233  size_t length = 0;
234  for (const auto &x : str) {
235  if (x == delimeter) {
236  result.push_back(str.substr(beg, length));
237  beg += length + 1;
238  length = 0;
239  continue;
240  }
241  length++;
242  }
243  if (length != 0) {
244  result.push_back(str.substr(beg, length));
245  }
246  return result;
247 }
248 
249 } // namespace detail
250 } // namespace sycl
251 } // __SYCL_INLINE_NAMESPACE(cl)
sycl
Definition: invoke_simd.hpp:68
PI_COMMAND_EXECUTION_FAILURE
@ PI_COMMAND_EXECUTION_FAILURE
PI_COMMAND_EXECUTION_FAILURE indicates an error occurred during command enqueue or execution.
Definition: pi.h:124
cl::sycl::length
float length(T p) __NOEXC
Definition: builtins.hpp:1032
cl
We provide new interfaces for matrix muliply in this patch:
Definition: access.hpp:13
cl::sycl::detail::stringifyErrorCode
const char * stringifyErrorCode(cl_int error)
Definition: common.cpp:16
PI_FUNCTION_ADDRESS_IS_NOT_AVAILABLE
@ PI_FUNCTION_ADDRESS_IS_NOT_AVAILABLE
PI_FUNCTION_ADDRESS_IS_NOT_AVAILABLE indicates a fallback method determines the function exists but i...
Definition: pi.h:127
cl::sycl::detail::split_string
std::vector< std::string > split_string(const std::string &str, char delimeter)
Definition: common.cpp:230
cl::sycl::cl_int
std::int32_t cl_int
Definition: aliases.hpp:82
PI_PLUGIN_SPECIFIC_ERROR
@ PI_PLUGIN_SPECIFIC_ERROR
PI_PLUGIN_SPECIFIC_ERROR indicates that an backend spcific error or warning has been emitted by the p...
Definition: pi.h:121
common.hpp
common_info.hpp
__SYCL_INLINE_NAMESPACE
#define __SYCL_INLINE_NAMESPACE(X)
Definition: defines_elementary.hpp:12