9template <
typename Group>
12 return group.get_group();
30template <
typename Group>
37 return local_size >= 32 ? 32 : 0;
40 return local_size >= 16 ? 16 : 0;
42 if (local_size >= 32) {
45 if (local_size >= 16) {
51template <
typename Tag,
typename Group,
typename T>
62 return tile > 0 && a.
rows() >= tile && a.
cols() >= tile;
66template <
typename Tag,
typename Group>
79 return tile > 0 && rows >= tile && cols >= tile;
83template <
typename Group,
typename T>
91 T* matrix_tile = workspace->matrix;
92 T* x_tile = workspace->x;
95 const int row_extent = a.
rows();
96 const int col_extent = a.
cols();
98 for (
int row_base = 0; row_base < row_extent; row_base += tile) {
99 const int row_tile_extent = std::min(tile, row_extent - row_base);
101 for (
int row = local_id; row < row_tile_extent; row += local_size) {
102 operand.
y(row_base + row) *= operand.
beta;
105 for (
int col_base = 0; col_base < col_extent; col_base += tile) {
106 const int col_tile_extent = std::min(tile, col_extent - col_base);
108 for (
int col = local_id; col < col_tile_extent; col += local_size) {
109 x_tile[col] = operand.
x(col_base + col);
111 for (
int linear_index = local_id; linear_index < row_tile_extent * col_tile_extent; linear_index += local_size) {
112 const int row = linear_index % row_tile_extent;
113 const int col = linear_index / row_tile_extent;
116 sycl::group_barrier(work_group);
118 for (
int row = local_id; row < row_tile_extent; row += local_size) {
120 for (
int col = 0; col < col_tile_extent; ++col) {
123 operand.
y(row_base + row) += operand.
alpha * partial;
125 sycl::group_barrier(work_group);
130template <
typename Tag,
typename Group,
typename T>
131inline constexpr void gemv(
const Group& group,
139 if (inner_extent < local_size) {
140 for (
int output_index = local_id; output_index < outer_extent; output_index += local_size) {
142 for (
int input_index = 0; input_index < inner_extent; ++input_index) {
145 operand.
y(output_index) = operand.
alpha * partial + operand.
beta * operand.
y(output_index);
150 for (
int output_index = 0; output_index < outer_extent; ++output_index) {
152 for (
int input_index = local_id; input_index < inner_extent; input_index += local_size) {
157 operand.
y(output_index) = operand.
alpha * partial + operand.
beta * operand.
y(output_index);
166template <
typename Tag, DeviceBlasPolicy Policy,
typename T>
170 assert(rows >= 0 && cols >= 0 &&
"device::gemv workspace query expects non-negative matrix extents");
177template <
typename Tag, DeviceBlasPolicy Policy,
typename Group,
typename T>
181 T* workspace =
nullptr) {
211template <Transpose TransV = Transpose::NoTrans,
typename Group,
typename T>
212inline constexpr void gemv(
const Group& group,
215 T* workspace =
nullptr) {
224inline constexpr void gemv(
const Group& group,
227 T* workspace =
nullptr) {
237template <
typename T, Transpose TransV = Transpose::NoTrans>
250template <
typename T, DeviceBlasPolicy Policy, Transpose TransV = Transpose::NoTrans>
258template <Transpose TransV = Transpose::NoTrans,
typename Group,
typename T>
259inline constexpr void gemv(
const Group& group,
265 T* workspace =
nullptr) {
274inline constexpr void gemv(
const Group& group,
280 T* workspace =
nullptr) {
Non-owning view of a batch of strided vectors: the vector argument type of the entry points.
Policy
Synchronous or asynchronous execution policy.
constexpr MatrixVectorOperand< T > make_matvec_operand(const VectorView< T > &x, const VectorView< T > &y, T alpha=T(1), T beta=T(0))
Builds a MatrixVectorOperand.
constexpr std::size_t gemv_workspace_elements(const DeviceBlasLaunchInfo &launch, int rows, int cols)
Local memory, in elements of T, that gemv() can use; 0 means pass nullptr.
DeviceBlasPolicy
Which implementation family a device BLAS call may use.
constexpr void gemv(const Group &group, const KernelMatrixView< T, MatrixFormat::Dense > &a, MatrixVectorOperand< T > operand, T *workspace=nullptr)
General matrix-vector product .
@ Subgroup16
fast paths only when the actual sub-group size is 16
@ Auto
any eligible path; the sub-group fast paths accept sub-group size 16 or 32
@ Subgroup32
fast paths only when the actual sub-group size is 32
@ Generic
the portable group-reduction path only; never stages through local memory
Transpose
The operator op() applied to an operand: op(A) = A, A^T or A^H.
constexpr void gemv(const Group &group, const KernelMatrixView< T, MatrixFormat::Dense > &a, MatrixVectorOperand< T > operand)
constexpr auto gemv_work_group(const Group &group)
constexpr int gemv_transpose_tile_index(int row, int col)
constexpr bool can_use_tiled_gemv(const Group &group, const KernelMatrixView< T, MatrixFormat::Dense > &a, DeviceBlasPolicy policy)
void gemv_tiled(const Group &group, const KernelMatrixView< T, MatrixFormat::Dense > &a, MatrixVectorOperand< T > operand, int tile, T *workspace_ptr)
constexpr int gemv_tiled_tile_size(const Group &group, DeviceBlasPolicy policy)
constexpr std::size_t gemv_workspace_elements(const DeviceBlasLaunchInfo &launch, int rows, int cols)
constexpr int output_size(const KernelMatrixView< T, MatrixFormat::Dense > &a, Transpose trans)
constexpr int group_local_linear_id(const Group &group)
constexpr void validate_operand(const KernelMatrixView< T, MatrixFormat::Dense > &a, const MatrixVectorOperand< T > &operand, Transpose trans)
constexpr int input_size(const KernelMatrixView< T, MatrixFormat::Dense > &a, Transpose trans)
constexpr int group_local_linear_range(const Group &group)
constexpr Workspace * workspace_ptr_cast(T *workspace)
void dispatch_gemv(const Group &group, const KernelMatrixView< T, MatrixFormat::Dense > &a, MatrixVectorOperand< T > operand, T *workspace=nullptr)
constexpr T matrix_entry(const KernelMatrixView< T, MatrixFormat::Dense > &a, int row, int col, Transpose trans)
constexpr T reduce_sum_group(const Group &group, const T &value)
constexpr std::size_t workspace_elements_v
constexpr bool group_is_leader(const Group &group)
Trivially copyable view of a MatrixView for use inside a SYCL kernel.
auto rows() const
Row count (the capacity on a heterogeneous batch).
auto cols() const
Column count (the capacity on a heterogeneous batch).
Host-side description of a launch, for the *_workspace_elements queries.
Operands of a matrix-vector operation: .
VectorView< T > x
input vector
T beta
scale of the input y; 0 still reads y
T alpha
scale of the product
VectorView< T > y
output vector; read (scaled by beta) and overwritten
static constexpr int kMaxTile
T matrix[kMaxTile *(kMaxTile+1)]