DPC++ Runtime
Runtime libraries for oneAPI DPC++
exception_list.hpp
Go to the documentation of this file.
1
//==---------------- exception_list.hpp - SYCL exception_list --------------==//
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
#pragma once
10
11
// 4.9.2 Exception Class Interface
12
13
#include <
sycl/detail/defines.hpp
>
14
#include <
sycl/detail/export.hpp
>
15
#include <
sycl/detail/iostream_proxy.hpp
>
16
#include <
sycl/stl.hpp
>
17
18
#include <cstddef>
19
20
namespace
sycl
{
21
__SYCL_INLINE_VER_NAMESPACE
(_V1) {
22
23
// Forward declaration
24
namespace
detail {
25
class
queue_impl;
26
}
27
31
class
__SYCL_EXPORT
exception_list
{
32
public
:
33
using
value_type
= std::exception_ptr;
34
using
reference
=
value_type
&;
35
using
const_reference
=
const
value_type
&;
36
using
size_type
= std::size_t;
37
using
iterator
= std::vector<std::exception_ptr>::const_iterator;
38
using
const_iterator
= std::vector<std::exception_ptr>::const_iterator;
39
40
size_type
size()
const
;
41
// first asynchronous exception
42
iterator
begin()
const
;
43
// refer to past-the-end last asynchronous exception
44
iterator
end()
const
;
45
46
private
:
47
friend
class
detail::queue_impl
;
48
void
PushBack(
const_reference
Value);
49
void
PushBack(
value_type
&&Value);
50
void
Clear() noexcept;
51
std
::vector<
std
::exception_ptr> MList;
52
};
53
54
using
async_handler
=
std
::function<
void
(
sycl
::
exception_list
)>;
55
56
namespace detail {
57
// Default implementation of async_handler used by queue and context when no
58
// user-defined async_handler is specified.
59
inline
void
defaultAsyncHandler
(
exception_list
Exceptions) {
60
std::cerr
<<
"Default async_handler caught exceptions:"
;
61
for
(
auto
&EIt : Exceptions) {
62
try
{
63
if
(EIt) {
64
std::rethrow_exception(EIt);
65
}
66
}
catch
(
const
std::exception &E) {
67
std::cerr
<<
"\n\t"
<< E.what();
68
}
69
}
70
std::cerr
<< std::endl;
71
std::terminate();
72
}
73
}
// namespace detail
74
}
// __SYCL_INLINE_VER_NAMESPACE(_V1)
75
}
// namespace sycl
stl.hpp
sycl::_V1::exception_list::const_reference
const value_type & const_reference
Definition:
exception_list.hpp:35
__SYCL_INLINE_VER_NAMESPACE
#define __SYCL_INLINE_VER_NAMESPACE(X)
Definition:
defines_elementary.hpp:11
sycl
---— Error handling, matching OpenCL plugin semantics.
Definition:
access.hpp:14
sycl::_V1::exception_list
A list of asynchronous exceptions.
Definition:
exception_list.hpp:31
export.hpp
sycl::_V1::exception_list::iterator
std::vector< std::exception_ptr >::const_iterator iterator
Definition:
exception_list.hpp:37
sycl::_V1::exception_list::reference
value_type & reference
Definition:
exception_list.hpp:34
defines.hpp
std::cerr
__SYCL_EXTERN_STREAM_ATTRS ostream cerr
Linked to standard error (unbuffered)
sycl::_V1::detail::queue_impl
Definition:
queue_impl.hpp:59
sycl::_V1::exception_list::size_type
std::size_t size_type
Definition:
exception_list.hpp:36
iostream_proxy.hpp
sycl::_V1::detail::defaultAsyncHandler
void defaultAsyncHandler(exception_list Exceptions)
Definition:
exception_list.hpp:59
sycl::_V1::exception_list::const_iterator
std::vector< std::exception_ptr >::const_iterator const_iterator
Definition:
exception_list.hpp:38
std
Definition:
accessor.hpp:3230
sycl::_V1::async_handler
std::function< void(sycl::exception_list)> async_handler
Definition:
exception_list.hpp:54
sycl::_V1::exception_list::value_type
std::exception_ptr value_type
Definition:
exception_list.hpp:33
include
sycl
exception_list.hpp
Generated by
1.8.17