28 #if !defined(NDEBUG) && (_MSC_VER > 1929 || __has_builtin(__builtin_FILE))
29 #define __CODELOC_FILE_NAME __builtin_FILE()
31 #define __CODELOC_FILE_NAME nullptr
34 #if _MSC_VER > 1929 || __has_builtin(__builtin_FUNCTION)
35 #define __CODELOC_FUNCTION __builtin_FUNCTION()
37 #define __CODELOC_FUNCTION nullptr
40 #if _MSC_VER > 1929 || __has_builtin(__builtin_LINE)
41 #define __CODELOC_LINE __builtin_LINE()
43 #define __CODELOC_LINE 0
46 #if _MSC_VER > 1929 || __has_builtin(__builtin_COLUMN)
47 #define __CODELOC_COLUMN __builtin_COLUMN()
49 #define __CODELOC_COLUMN 0
63 #undef __CODELOC_FILE_NAME
64 #undef __CODELOC_FUNCTION
66 #undef __CODELOC_COLUMN
70 : MFileName(file), MFunctionName(func), MLineNo(
line), MColumnNo(col) {}
73 : MFileName(
nullptr), MFunctionName(
nullptr), MLineNo(0), MColumnNo(0) {}
75 constexpr
unsigned long lineNumber() const noexcept {
return MLineNo; }
76 constexpr
unsigned long columnNumber() const noexcept {
return MColumnNo; }
77 constexpr
const char *
fileName() const noexcept {
return MFileName; }
78 constexpr
const char *
functionName() const noexcept {
return MFunctionName; }
81 const char *MFileName;
82 const char *MFunctionName;
83 unsigned long MLineNo;
84 unsigned long MColumnNo;
105 #ifdef __SYCL_DEVICE_ONLY__
107 #define __SYCL_ASSERT(x)
109 #define __SYCL_ASSERT(x) assert(x)
110 #endif // #ifdef __SYCL_DEVICE_ONLY__
112 #define __SYCL_PI_ERROR_REPORT \
113 "Native API failed. " \
116 "Native API returns: "
118 #ifndef __SYCL_SUPPRESS_PI_ERROR_REPORT
121 #define __SYCL_REPORT_PI_ERR_TO_STREAM(expr) \
124 if (code != PI_SUCCESS) { \
125 std::cerr << __SYCL_PI_ERROR_REPORT \
126 << cl::sycl::detail::codeToString(code) << std::endl; \
131 #ifndef SYCL_SUPPRESS_EXCEPTIONS
134 #define __SYCL_REPORT_PI_ERR_TO_EXC(expr, exc, str) \
137 if (code != PI_SUCCESS) { \
138 std::string err_str = \
139 str ? "\n" + std::string(str) + "\n" : std::string{}; \
140 throw exc(__SYCL_PI_ERROR_REPORT + \
141 cl::sycl::detail::codeToString(code) + err_str, \
145 #define __SYCL_REPORT_PI_ERR_TO_EXC_THROW(code, exc, str) \
146 __SYCL_REPORT_PI_ERR_TO_EXC(code, exc, str)
147 #define __SYCL_REPORT_PI_ERR_TO_EXC_BASE(code) \
148 __SYCL_REPORT_PI_ERR_TO_EXC(code, cl::sycl::runtime_error, nullptr)
150 #define __SYCL_REPORT_PI_ERR_TO_EXC_BASE(code) \
151 __SYCL_REPORT_PI_ERR_TO_STREAM(code)
154 #define __SYCL_REPORT_ERR_TO_EXC_VIA_ERRC(expr, errc) \
157 if (code != PI_SUCCESS) { \
158 throw sycl::exception(sycl::make_error_code(errc), \
159 __SYCL_PI_ERROR_REPORT + \
160 cl::sycl::detail::codeToString(code)); \
163 #define __SYCL_REPORT_ERR_TO_EXC_THROW_VIA_ERRC(code, errc) \
164 __SYCL_REPORT_ERR_TO_EXC_VIA_ERRC(code, errc)
166 #ifdef __SYCL_SUPPRESS_PI_ERROR_REPORT
168 #define __SYCL_CHECK_OCL_CODE(X) (void)(X)
169 #define __SYCL_CHECK_OCL_CODE_THROW(X, EXC, STR) \
174 #define __SYCL_CHECK_OCL_CODE_NO_EXC(X) (void)(X)
176 #define __SYCL_CHECK_CODE_THROW_VIA_ERRC(X, ERRC) (void)(X)
179 #define __SYCL_CHECK_OCL_CODE(X) __SYCL_REPORT_PI_ERR_TO_EXC_BASE(X)
180 #define __SYCL_CHECK_OCL_CODE_THROW(X, EXC, STR) \
181 __SYCL_REPORT_PI_ERR_TO_EXC_THROW(X, EXC, STR)
182 #define __SYCL_CHECK_OCL_CODE_NO_EXC(X) __SYCL_REPORT_PI_ERR_TO_STREAM(X)
184 #define __SYCL_CHECK_CODE_THROW_VIA_ERRC(X, ERRC) \
185 __SYCL_REPORT_ERR_TO_EXC_THROW_VIA_ERRC(X, ERRC)
205 return SyclObject.impl;
214 return SyclObject.impl.get();
228 template <
int Val>
static T<N>
get();
233 template <
int Val>
static T<1>
get() {
return T<1>{Val}; }
238 template <
int Val>
static T<2>
get() {
return T<2>{Val, Val}; }
243 template <
int Val>
static T<3>
get() {
return T<3>{Val, Val, Val}; }
247 template <
int NDIMS,
int DIM,
template <
int>
class LoopBoundTy,
typename FuncTy,
248 template <
int>
class LoopIndexTy>
251 const LoopBoundTy<NDIMS> &Stride,
252 const LoopBoundTy<NDIMS> &UpperBound, FuncTy f,
253 LoopIndexTy<NDIMS> &Index) {
254 constexpr
size_t AdjIdx = NDIMS - 1 - DIM;
255 for (Index[AdjIdx] = LowerBound[AdjIdx]; Index[AdjIdx] < UpperBound[AdjIdx];
256 Index[AdjIdx] += Stride[AdjIdx]) {
259 LowerBound, Stride, UpperBound, f, Index};
265 template <
int NDIMS,
template <
int>
class LoopBoundTy,
typename FuncTy,
266 template <
int>
class LoopIndexTy>
269 const LoopBoundTy<NDIMS> &Stride,
270 const LoopBoundTy<NDIMS> &UpperBound, FuncTy f,
271 LoopIndexTy<NDIMS> &Index) {
273 constexpr
size_t AdjIdx = NDIMS - 1;
274 for (Index[AdjIdx] = LowerBound[AdjIdx]; Index[AdjIdx] < UpperBound[AdjIdx];
275 Index[AdjIdx] += Stride[AdjIdx]) {
292 template <
template <
int>
class LoopBoundTy,
typename FuncTy,
293 template <
int>
class LoopIndexTy = LoopBoundTy>
296 const LoopIndexTy<NDIMS> LowerBound =
298 const LoopBoundTy<NDIMS> Stride =
300 LoopIndexTy<NDIMS> Index =
304 LowerBound, Stride, UpperBound, f, Index};
310 template <
template <
int>
class LoopBoundTy,
typename FuncTy,
311 template <
int>
class LoopIndexTy = LoopBoundTy>
313 const LoopBoundTy<NDIMS> &Stride,
314 const LoopBoundTy<NDIMS> &UpperBound,
316 LoopIndexTy<NDIMS> Index =
319 LowerBound, Stride, UpperBound, f, Index};
335 template <
int Dims,
template <
int>
class T,
template <
int>
class U>
337 size_t LinearIndex = 0;
338 for (
int I = 0; I < Dims; ++I)
339 LinearIndex = LinearIndex * Range[I] + Index[I];
353 static constexpr T value{};