Advanced Examples#
All examples below are in 10_Advanced/ and are built by default when cuBLASDx is available (see example/cusolverdx/CMakeLists.txt).
blocked_potrf.cu
This example implements Cholesky factorization with a blocked left-looking algorithm for large matrices that do not fit in shared memory or are too slow with cuSolverDx’s unblocked Cholesky API due to register and shared memory usage.
The code uses an out-of-core implementation with a single thread block processing each batch of the matrix A. The factorization of the N x N matrix A proceeds in N / NB steps over submatrices of size NB x NB, each step calling the unblocked Cholesky factorization, triangular solve (TRSM), and cuBLASDx GEMM. Results are compared with the cuSolver host API cusolverDnXpotrf.
cga_hybrid_blocked_potrf_right_looking.cu
This example performs blocked Cholesky with a right-looking algorithm using cooperative groups and thread block cluster (Hopper, SM 9.0, or newer). It is not built on the cuSolverDx Cluster operator; instead it orchestrates cuSolverDx block POTRF/TRSM and cuBLASDx GEMM explicitly, combining DSMEM tile pointers with global-memory streaming for trailing tiles.
Compared with left-looking blocked Cholesky, the right-looking phase order is more communication-efficient: each step factors the diagonal tile, applies TRSM to the panel row, then updates the trailing submatrix with GEMM. To scale to larger matrices, the kernel uses a hybrid memory strategy. The active diagonal and panel tiles stay in distributed shared memory (DSMEM), so cluster blocks can share them without repeated global traffic, while trailing tiles are streamed through global memory, loaded to shared memory, updated with GEMM, and stored back to global memory. This keeps DSMEM for the smaller, frequently shared working set and uses global memory for the much larger trailing region.
reg_least_squares.cu
This example solves a batch of regularized least squares problems
with three different approaches:
Using cuBLASDx’s
GEMMand cuSolverDx’sPOTRFandTRSMto build a single fused kernel to solve the normal equations\[(A' A + \lambda I) x = A' b\]Using cuSolverDx’s
GELSfunction to do a Householder QR on A augmented by \(\lambda I\)using cuBLAS and cuSolver host API to solve the normal equations
The comparison of the three approaches illustrates the performance benefit of using MathDx functions in a fused kernel to improve throughput and reduce global memory access.