|
28 | 28 |
|
29 | 29 | #include "oneapi/math/types.hpp"
|
30 | 30 | #include "oneapi/math/exceptions.hpp"
|
| 31 | +#include "oneapi/math/lapack/exceptions.hpp" |
31 | 32 |
|
32 | 33 | namespace oneapi {
|
33 | 34 | namespace math {
|
@@ -105,48 +106,88 @@ inline auto get_onemkl_order(oneapi::math::order param) {
|
105 | 106 | return *reinterpret_cast<oneapi::mkl::order*>(¶m);
|
106 | 107 | }
|
107 | 108 |
|
| 109 | +} // namespace detail |
| 110 | +} // namespace math |
| 111 | +} // namespace oneapi |
| 112 | + |
108 | 113 | // Rethrow Intel(R) oneMKL exceptions as oneMath exceptions
|
109 |
| -#define RETHROW_ONEMKL_EXCEPTIONS(EXPRESSION) \ |
110 |
| - do { \ |
111 |
| - try { \ |
112 |
| - EXPRESSION; \ |
113 |
| - } \ |
114 |
| - catch (const oneapi::mkl::unsupported_device& e) { \ |
115 |
| - throw unsupported_device(e.what()); \ |
116 |
| - } \ |
117 |
| - catch (const oneapi::mkl::host_bad_alloc& e) { \ |
118 |
| - throw host_bad_alloc(e.what()); \ |
119 |
| - } \ |
120 |
| - catch (const oneapi::mkl::device_bad_alloc& e) { \ |
121 |
| - throw device_bad_alloc(e.what()); \ |
122 |
| - } \ |
123 |
| - catch (const oneapi::mkl::unimplemented& e) { \ |
124 |
| - throw unimplemented(e.what()); \ |
125 |
| - } \ |
126 |
| - catch (const oneapi::mkl::invalid_argument& e) { \ |
127 |
| - throw invalid_argument(e.what()); \ |
128 |
| - } \ |
129 |
| - catch (const oneapi::mkl::uninitialized& e) { \ |
130 |
| - throw uninitialized(e.what()); \ |
131 |
| - } \ |
132 |
| - catch (const oneapi::mkl::computation_error& e) { \ |
133 |
| - throw computation_error(e.what()); \ |
134 |
| - } \ |
135 |
| - catch (const oneapi::mkl::batch_error& e) { \ |
136 |
| - throw batch_error(e.what()); \ |
137 |
| - } \ |
138 |
| - catch (const oneapi::mkl::exception& e) { \ |
139 |
| - throw exception(e.what()); \ |
140 |
| - } \ |
| 114 | +#define RETHROW_ONEMKL_EXCEPTIONS(EXPRESSION) \ |
| 115 | + do { \ |
| 116 | + try { \ |
| 117 | + EXPRESSION; \ |
| 118 | + } \ |
| 119 | + catch (const oneapi::mkl::unsupported_device& e) { \ |
| 120 | + throw oneapi::math::unsupported_device(e.what()); \ |
| 121 | + } \ |
| 122 | + catch (const oneapi::mkl::host_bad_alloc& e) { \ |
| 123 | + throw oneapi::math::host_bad_alloc(e.what()); \ |
| 124 | + } \ |
| 125 | + catch (const oneapi::mkl::device_bad_alloc& e) { \ |
| 126 | + throw oneapi::math::device_bad_alloc(e.what()); \ |
| 127 | + } \ |
| 128 | + catch (const oneapi::mkl::unimplemented& e) { \ |
| 129 | + throw oneapi::math::unimplemented(e.what()); \ |
| 130 | + } \ |
| 131 | + catch (const oneapi::mkl::invalid_argument& e) { \ |
| 132 | + throw oneapi::math::invalid_argument(e.what()); \ |
| 133 | + } \ |
| 134 | + catch (const oneapi::mkl::uninitialized& e) { \ |
| 135 | + throw oneapi::math::uninitialized(e.what()); \ |
| 136 | + } \ |
| 137 | + catch (const oneapi::mkl::computation_error& e) { \ |
| 138 | + throw oneapi::math::computation_error(e.what()); \ |
| 139 | + } \ |
| 140 | + catch (const oneapi::mkl::batch_error& e) { \ |
| 141 | + throw oneapi::math::batch_error(e.what()); \ |
| 142 | + } \ |
| 143 | + catch (const oneapi::mkl::exception& e) { \ |
| 144 | + throw oneapi::math::exception(e.what()); \ |
| 145 | + } \ |
141 | 146 | } while (0)
|
142 | 147 |
|
143 | 148 | #define RETHROW_ONEMKL_EXCEPTIONS_RET(EXPRESSION) \
|
144 | 149 | do { \
|
145 | 150 | RETHROW_ONEMKL_EXCEPTIONS(return EXPRESSION); \
|
146 | 151 | } while (0)
|
147 | 152 |
|
148 |
| -} // namespace detail |
149 |
| -} // namespace math |
150 |
| -} // namespace oneapi |
| 153 | +// Rethrow Intel(R) oneMKL LAPCK exceptions as oneMath LAPACK exceptions |
| 154 | +#define RETHROW_ONEMKL_LAPACK_EXCEPTIONS(EXPRESSION) \ |
| 155 | + do { \ |
| 156 | + try { \ |
| 157 | + EXPRESSION; \ |
| 158 | + } \ |
| 159 | + catch (const oneapi::mkl::unsupported_device& e) { \ |
| 160 | + throw oneapi::math::unsupported_device(e.what()); \ |
| 161 | + } \ |
| 162 | + catch (const oneapi::mkl::host_bad_alloc& e) { \ |
| 163 | + throw oneapi::math::host_bad_alloc(e.what()); \ |
| 164 | + } \ |
| 165 | + catch (const oneapi::mkl::device_bad_alloc& e) { \ |
| 166 | + throw oneapi::math::device_bad_alloc(e.what()); \ |
| 167 | + } \ |
| 168 | + catch (const oneapi::mkl::unimplemented& e) { \ |
| 169 | + throw oneapi::math::unimplemented(e.what()); \ |
| 170 | + } \ |
| 171 | + catch (const oneapi::mkl::uninitialized& e) { \ |
| 172 | + throw oneapi::math::uninitialized(e.what()); \ |
| 173 | + } \ |
| 174 | + catch (const oneapi::mkl::lapack::invalid_argument& e) { \ |
| 175 | + throw oneapi::math::lapack::invalid_argument(e.what(), e.info(), e.detail()); \ |
| 176 | + } \ |
| 177 | + catch (const oneapi::mkl::lapack::computation_error& e) { \ |
| 178 | + throw oneapi::math::lapack::computation_error(e.what(), e.info()); \ |
| 179 | + } \ |
| 180 | + catch (const oneapi::mkl::lapack::batch_error& e) { \ |
| 181 | + throw oneapi::math::lapack::batch_error(e.what(), e.info(), e.ids(), e.exceptions()); \ |
| 182 | + } \ |
| 183 | + catch (const oneapi::mkl::exception& e) { \ |
| 184 | + throw oneapi::math::exception(e.what()); \ |
| 185 | + } \ |
| 186 | + } while (0) |
| 187 | + |
| 188 | +#define RETHROW_ONEMKL_LAPACK_EXCEPTIONS_RET(EXPRESSION) \ |
| 189 | + do { \ |
| 190 | + RETHROW_ONEMKL_LAPACK_EXCEPTIONS(return EXPRESSION); \ |
| 191 | + } while (0) |
151 | 192 |
|
152 | 193 | #endif // _ONEMATH_SRC_INCLUDE_COMMON_ONEMKL_TYPES_CONVERSION_HPP_
|
0 commit comments