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_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.
cga_tsqrhr.cu
This example implements batched TSQRHR (tall-skinny QR with Householder reconstruction) for M x N matrices with M >> N using Hopper+ thread block clusters. One thread block cluster processes one batch of the matrix A; each block in the cluster owns one NB x N row tile. The kernel performs leaf QR with cuSolverDx GEQRF, a hierarchical reduction of R factors across cluster blocks, and reconstruction of the compact QR representation. Results are checked against a cuBLAS/cuSolver reference path.
For performance, the example also uses a hybrid memory strategy: each block streams its row tile from global memory into local shared memory for leaf QR and reconstruction, while DSMEM carries inter-block data during the reduction hierarchy (for example, R factors, reduction-Q slices, and the final compact panel broadcast from block 0). Cluster launch and DSMEM mapping are managed manually (similar to cga_blocked_potrf_right_looking.cu), not through the cuSolverDx cluster execution operator.
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.