Sparse-dense products, ILU(k) and CSR test-matrix generators.
Lower-level functions (algorithm-specific variants, workspace queries, validation and helpers): Sparse: lower-level API.
| ILUKPreconditioner< T > batchlas::iluk_factorize | ( | Queue & | ctx, |
| const MatrixView< T, MatrixFormat::CSR > & | A, | ||
| const ILUKParams< T > & | params = ILUKParams< T >() ) |
Computes the ILU(k) factor of a batch of CSR matrices into owned storage.
Every item of A must share one sparsity pattern; the factor's pattern is the union of what each item kept, so the batch keeps sharing one pattern. Blocking: returns once the factor is complete. The numeric phase runs on the device for large batches and on the host otherwise (BATCHLAS_ILUK_DEVICE forces either).
| B | backend the call is compiled for |
| T | scalar type |
| ctx | queue used for the device phase and allocations |
| A | batch of square CSR matrices; not modified |
| params | fill, drop and pivot controls |
| batchlas::invalid_argument | if A is not square, a parameter is out of range, or the batch items do not share one pattern |
| batchlas::convergence_error | if a pivot is zero and diagonal_shift cannot stabilise it |
| ILUKView< T > batchlas::iluk_factorize | ( | Queue & | ctx, |
| const MatrixView< T, MatrixFormat::CSR > & | A, | ||
| Span< std::byte > | workspace, | ||
| const ILUKParams< T > & | params, | ||
| size_t * | bytes_used = nullptr ) |
Computes the ILU(k) factor into caller-supplied memory instead of allocating.
Same factorization as the owning overload. Lets an iterative solver carve the preconditioner out of a workspace it already holds. The exact footprint is only known after the numeric phase, so it is reported through bytes_used rather than predicted.
| ctx | queue used for the device phase |
| A | batch of square CSR matrices sharing one pattern; not modified |
| workspace | at least iluk_buffer_size bytes of USM the host can write (the level schedule is copied in from the host) |
| params | fill, drop and pivot controls |
| bytes_used | if non-null, receives the bytes of workspace the factor occupies |
| batchlas::invalid_argument,batchlas::convergence_error | as the owning overload |
| Event batchlas::iluk_apply | ( | Queue & | ctx, |
| const ILUKView< T > & | M, | ||
| const MatrixView< T, MatrixFormat::Dense > & | rhs, | ||
| const MatrixView< T, MatrixFormat::Dense > & | out, | ||
| Span< std::byte > | workspace = Span< std::byte >() ) |
Applies the ILU(k) preconditioner: out := \((LU)^{-1}\) rhs.
For every batch item and every column of rhs, solves \(L y = r\) (unit diagonal) and then \(U x = y\) by level-scheduled sparse triangular solves, and writes \(x\) to out. Asynchronous: nothing is waited on, so repeated applications inside an iterative solver stay pipelined.
| ctx | queue the kernel is enqueued on |
| M | factor from iluk_factorize |
| rhs | batch of n x nrhs right-hand sides; not modified |
| out | batch of n x nrhs results |
| workspace | unused; iluk_apply_buffer_size is 0 |
| batchlas::invalid_argument | if rhs / out rows differ from M.n, their column counts differ, their batch size differs from M.batch_size, or M has no level schedule |
| batchlas::convergence_error | if M.u_diagonals_usable is false |
| Event batchlas::iluk_apply | ( | Queue & | ctx, |
| const ILUKPreconditioner< T > & | M, | ||
| const MatrixView< T, MatrixFormat::Dense > & | rhs, | ||
| const MatrixView< T, MatrixFormat::Dense > & | out, | ||
| Span< std::byte > | workspace = Span<std::byte>() ) |
| Event batchlas::spmm | ( | Queue & | ctx, |
| const MatrixView< T, MFormat > & | A, | ||
| const MatrixView< T, MatrixFormat::Dense > & | descrB, | ||
| const MatrixView< T, MatrixFormat::Dense > & | descrC, | ||
| T | alpha, | ||
| T | beta, | ||
| Transpose | transA, | ||
| Transpose | transB, | ||
| Span< std::byte > | workspace ) |
Batched sparse-times-dense matrix multiply.
For every batch item computes
\[ C := \alpha \, \mathrm{op}(A) \, \mathrm{op}(B) + \beta \, C \]
with A sparse (CSR) and B, C dense; \(\mathrm{op}(X)\) is \(X\), \(X^T\) or \(X^H\) according to transA / transB. With \(\mathrm{op}(A)\) m x k and \(\mathrm{op}(B)\) k x n, C is m x n.
Takes a caller-supplied workspace, sized by spmm_buffer_size with the same arguments. Lease it from the queue's arena with ctx.workspace(bytes). Also callable with owning Matrix arguments and without B (taken from ctx.backend()); spell a partial explicit call spmm<Backend::CUDA>(...) and let T and MFormat deduce.
| B | backend the call is compiled for; must match ctx's device |
| T | scalar type: float, double, std::complex<float> or std::complex<double> |
| MFormat | storage format of A; only MatrixFormat::CSR is instantiated |
| ctx | queue the work is enqueued on |
| A | batch of sparse matrices; not modified |
| descrB | batch of dense k x n (NoTrans) or n x k matrices; not modified |
| descrC | batch of dense m x n matrices; input scaled by beta, overwritten with the result |
| alpha | scale of the product |
| beta | scale of the input C |
| transA | op() applied to A |
| transB | op() applied to B |
| workspace | device-accessible scratch of at least spmm_buffer_size bytes |
| batchlas::NoRouteError | in a build without the vendor sparse library for B when the native kernel does not support the call (a heterogeneous batch, or negative extents). |
Topics | |
| Sparse: lower-level API | |
| ILU(k) level scheduling, test-matrix generation and workspace queries. | |
Classes | |
| struct | batchlas::ILUKParams< T > |
| Parameters of an incomplete LU factorization with level-of-fill k, ILU(k). More... | |
| struct | batchlas::ILUKView< T > |
| Non-owning description of a factored ILU(k) preconditioner. More... | |
| struct | batchlas::ILUKPreconditioner< T > |
| Owning ILU(k) factor of a batch of CSR matrices sharing one pattern. More... | |