cuBLASDx in Tile#

The cuBLASDx Tile C++ API provides tile-level linear algebra helpers. Include cublasdx_tile.hpp and compile the kernel with CUDA Tile enabled.

Python exposes these routines from Linear Algebra cutile-python API, which combines them with the cuSolverDx factorizations rather than offering a separate cuBLASDx module.

Quick start#

#include "cublasdx_tile.hpp"

namespace ct = cuda::tiles;

__tile_global__ void triangular_solve_kernel(float* triangular, float* rhs, float* solution) {
    using matrix_shape = ct::shape<16, 16>;
    auto a = ct::partition_view { ct::tensor_span { triangular, matrix_shape {} }, matrix_shape {} };
    auto b = ct::partition_view { ct::tensor_span { rhs, matrix_shape {} }, matrix_shape {} };
    auto x = ct::partition_view { ct::tensor_span { solution, matrix_shape {} }, matrix_shape {} };

    x.store(cublasdx::tiles::triangular_solve(
                a.load(0, 0), b.load(0, 0), cublasdx::tiles::lower, cublasdx::tiles::non_unit, cublasdx::tiles::left),
            0,
            0);
}

void launch_triangular_solve(float* triangular, float* rhs, float* solution) {
    triangular_solve_kernel<<<1, 1>>>(triangular, rhs, solution);
}

C++ API reference#

constexpr lower_t cublasdx::tiles::lower = {}#

Lower-triangle tag.

constexpr upper_t cublasdx::tiles::upper = {}#

Upper-triangle tag.

constexpr unit_t cublasdx::tiles::unit = {}#

Unit-diagonal tag.

constexpr non_unit_t cublasdx::tiles::non_unit = {}#

Explicit-diagonal tag.

constexpr left_t cublasdx::tiles::left = {}#

Left-side tag.

constexpr right_t cublasdx::tiles::right = {}#

Right-side tag.

constexpr no_trans_t cublasdx::tiles::no_trans = {}#

No-transpose tag.

constexpr trans_t cublasdx::tiles::trans = {}#

Transpose tag.

template<typename ATile, typename BTile, typename FillTag, typename DiagTag, typename SideTag, typename TransTag = no_trans_t>
auto cublasdx::tiles::triangular_solve(
ATile A,
BTile B,
[[maybe_unused]] FillTag fill,
[[maybe_unused]] DiagTag diag,
[[maybe_unused]] SideTag side,
[[maybe_unused]] TransTag trans = {},
)#

Solve the selected triangular systems, defaulting to no transpose. A has shape (O, O), or (Batch, O, O) to solve Batch independent systems in one tile block, with B batched alongside it.

Parameters:
  • A – Triangular coefficient matrix with shape (O, O) or (Batch, O, O).

  • B – Right-hand sides with shape (O, N) for a left solve or (M, O) for a right solve, optionally prefixed by the common Batch extent.

  • fill – Selects the lower or upper triangle of A.

  • diag – Selects an implicit unit or explicitly stored diagonal.

  • side – Selects whether op(A) acts from the left or right.

  • trans – Selects op(A) as A or A^T.

Returns:

The solution tile with the same shape and element type as B.

template<typename T, size_t M, size_t N>
ct::tile<T, ct::shape<M, N>> cublasdx::tiles::tril(
ct::tile<T, ct::shape<M, N>> A,
)#

Return the lower-triangular part of an unbatched matrix tile.

Parameters:

A – Matrix tile with shape (M, N).

Returns:

Lower-triangular tile with shape (M, N).

template<typename T, size_t M, size_t N>
ct::tile<T, ct::shape<M, N>> cublasdx::tiles::triu(
ct::tile<T, ct::shape<M, N>> A,
)#

Return the upper-triangular part of an unbatched matrix tile.

Parameters:

A – Matrix tile with shape (M, N).

Returns:

Upper-triangular tile with shape (M, N).

template<typename T, size_t B, size_t M, size_t N>
ct::tile<T, ct::shape<B, M, N>> cublasdx::tiles::tril(
ct::tile<T, ct::shape<B, M, N>> A,
)#

Return the lower-triangular part of every matrix in a batched tile.

Parameters:

A – Batched matrix tile with shape (B, M, N).

Returns:

Lower-triangular matrices with shape (B, M, N).

template<typename T, size_t B, size_t M, size_t N>
ct::tile<T, ct::shape<B, M, N>> cublasdx::tiles::triu(
ct::tile<T, ct::shape<B, M, N>> A,
)#

Return the upper-triangular part of every matrix in a batched tile.

Parameters:

A – Batched matrix tile with shape (B, M, N).

Returns:

Upper-triangular matrices with shape (B, M, N).

struct left_t#
#include <cublasdx_tile.hpp>

Apply a triangular matrix from the left.

struct lower_t#
#include <cublasdx_tile.hpp>

Select the lower triangle of a triangular input.

struct no_trans_t#
#include <cublasdx_tile.hpp>

Define op(A) as A.

struct non_unit_t#
#include <cublasdx_tile.hpp>

Read the diagonal entries of a triangular matrix.

struct right_t#
#include <cublasdx_tile.hpp>

Apply a triangular matrix from the right.

struct trans_t#
#include <cublasdx_tile.hpp>

Define op(A) as A^T.

struct unit_t#
#include <cublasdx_tile.hpp>

Treat a triangular matrix as having an implicit unit diagonal.

struct upper_t#
#include <cublasdx_tile.hpp>

Select the upper triangle of a triangular input.