| 65 | |
| 66 | template<typename T> |
| 67 | Array<int> lu_inplace(Array<T> &in, const bool convert_pivot) { |
| 68 | dim4 iDims = in.dims(); |
| 69 | dim4 iStrides = in.strides(); |
| 70 | int64_t M = iDims[0]; |
| 71 | int64_t N = iDims[1]; |
| 72 | int64_t MN = std::min(M, N); |
| 73 | int64_t LDA = iStrides[1]; |
| 74 | |
| 75 | std::int64_t scratchpad_size = |
| 76 | ::oneapi::mkl::lapack::getrf_scratchpad_size<T>(getQueue(), M, N, LDA); |
| 77 | |
| 78 | auto ipiv = memAlloc<int64_t>(MN); |
| 79 | auto scratchpad = memAlloc<compute_t<T>>(scratchpad_size); |
| 80 | |
| 81 | sycl::buffer<compute_t<T>> in_buffer = |
| 82 | in.template getBufferWithOffset<compute_t<T>>(); |
| 83 | ::oneapi::mkl::lapack::getrf(getQueue(), M, N, in_buffer, LDA, *ipiv, |
| 84 | *scratchpad, scratchpad->size()); |
| 85 | |
| 86 | Array<int> pivot = convertPivot(*ipiv, MN, M, convert_pivot); |
| 87 | return pivot; |
| 88 | } |
| 89 | |
| 90 | bool isLAPACKAvailable() { return true; } |
| 91 | |