icl-utk-edu / lapackpp

LAPACK++ is a C++ wrapper around CPU and GPU LAPACK and LAPACK-like linear algebra libraries, developed as part of the SLATE project.
https://icl.utk.edu/slate/
BSD 3-Clause "New" or "Revised" License
50 stars 14 forks source link

oneMKL info #18

Open mgates3 opened 1 year ago

mgates3 commented 1 year ago

oneMKL throws exceptions, which contain the info. We don't currently extract this info. But also, for an async routine, it seems exceptions can't handle info > 0 values generated due to numerical values in the matrices. See https://spec.oneapi.io/versions/latest/elements/oneMKL/source/domains/lapack/getrf.html "Exception is thrown in case of problems during calculations. The info code of the problem can be obtained by info() method of exception object: ... If info = i, U_ii is 0. The factorization has been completed, but is exactly singular."

Also, those are not necessarily errors: getrf with info > 0 is perfectly valid, you just can't do triangular solves with the resulting LU. Therefore, the LAPACK++ convention has been to return those info > 0 codes, not throw an exception. Matlab doesn't report an error for this case:

>> A = rand( 3, 3 );
>> A(:, 2) = 0;
>> [L, U, P] = lu( A );
>> U
U =
    0.7577         0    0.0318
         0         0    0.2457
         0         0    0.0297
>> norm( L*U - P*A )
ans =
     0

See todos in PR #17.

mgates3 commented 1 year ago

Confirmed that this can't be resolved until / unless Intel changes the oneMKL spec to add an info parameter.