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 
9 #include <sycl/detail/common.hpp>
11 
12 namespace sycl {
14 namespace detail {
15 
16 const char *stringifyErrorCode(pi_int32 error) {
17  switch (error) {
18 #define _PI_ERRC(NAME, VAL) \
19  case NAME: \
20  return #NAME;
21 #define _PI_ERRC_WITH_MSG(NAME, VAL, MSG) \
22  case NAME: \
23  return MSG;
24 #include <sycl/detail/pi_error.def>
25 #undef _PI_ERRC
26 #undef _PI_ERRC_WITH_MSG
27 
28  default:
29  return "Unknown error code";
30  }
31 }
32 
33 std::vector<std::string> split_string(const std::string &str, char delimeter) {
34  std::vector<std::string> result;
35  size_t beg = 0;
36  size_t length = 0;
37  for (const auto &x : str) {
38  if (x == delimeter) {
39  result.push_back(str.substr(beg, length));
40  beg += length + 1;
41  length = 0;
42  continue;
43  }
44  length++;
45  }
46  if (length != 0) {
47  result.push_back(str.substr(beg, length));
48  }
49  return result;
50 }
51 
52 } // namespace detail
53 } // __SYCL_INLINE_VER_NAMESPACE(_V1)
54 } // namespace sycl
#define __SYCL_INLINE_VER_NAMESPACE(X)
const char * stringifyErrorCode(pi_int32 error)
Definition: common.cpp:16
std::vector< std::string > split_string(const std::string &str, char delimeter)
Definition: common.cpp:33
float length(T p) __NOEXC
Definition: builtins.hpp:1032
---— Error handling, matching OpenCL plugin semantics.
Definition: access.hpp:14
int32_t pi_int32
Definition: pi.h:102