Skip to content

Commit 1b0ce60

Browse files
Add w/a for oneMath to fix test oneMKL interfaces action (#2360)
This PR suggests adding a temporary workaround to a problem in oneMath [#642 ](uxlfoundation/oneMath#642) where exceptions are no longer thrown in `lapack` namespace for `getrf` function as expected. In oneMath develop branch `oneapi::mkl::lapack::computation_error` is not thrown. Instead, `oneapi::mkl::computation_error` from `mkl` namespace is used so existing catch block `mkl_lapack::exception` does not handle singular matrix errors. A workaround has been added to explicitly catch `oneapi::mkl::computation_error` and update `dev_info` ensuring that singular matrices are handled correctly.
1 parent acd33e4 commit 1b0ce60

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

dpnp/backend/extensions/lapack/gesv.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,16 @@ static sycl::event gesv_impl(sycl::queue &exec_q,
144144
is_exception_caught = true;
145145
gesv_utils::handle_lapack_exc(exec_q, lda, a, scratchpad_size,
146146
scratchpad, ipiv, e, error_msg);
147+
} catch (oneapi::mkl::computation_error const &e) {
148+
// TODO: remove this catch when gh-642(oneMath) is fixed
149+
// Workaround for oneMath interfaces
150+
// oneapi::mkl::computation_error is thrown instead of
151+
// oneapi::mkl::lapack::computation_error.
152+
if (scratchpad != nullptr)
153+
sycl_free_noexcept(scratchpad, exec_q);
154+
if (ipiv != nullptr)
155+
sycl_free_noexcept(ipiv, exec_q);
156+
throw LinAlgError("The input coefficient matrix is singular.");
147157
} catch (sycl::exception const &e) {
148158
is_exception_caught = true;
149159
error_msg << "Unexpected SYCL exception caught during getrf() or "

dpnp/backend/extensions/lapack/getrf.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,15 @@ static sycl::event getrf_impl(sycl::queue &exec_q,
120120
"call:\nreason: "
121121
<< e.what() << "\ninfo: " << e.info();
122122
}
123+
} catch (oneapi::mkl::computation_error const &e) {
124+
// TODO: remove this catch when gh-642(oneMath) is fixed
125+
// Workaround for oneMath interfaces
126+
// oneapi::mkl::computation_error is thrown instead of
127+
// oneapi::mkl::lapack::computation_error.
128+
is_exception_caught = false;
129+
// computation_error means the input matrix is singular
130+
// dev_info must be set to any positive value.
131+
dev_info[0] = 2;
123132
} catch (sycl::exception const &e) {
124133
is_exception_caught = true;
125134
error_msg << "Unexpected SYCL exception caught during getrf() call:\n"

0 commit comments

Comments
 (0)