28 const sycl::range<3> local(1, Tile, Tile);
29 const sycl::range<3> global(
static_cast<size_t>(A.
batch_size()),
30 static_cast<size_t>(((m + Tile - 1) / Tile) * Tile),
31 static_cast<size_t>(((n + Tile - 1) / Tile) * Tile));
33 ctx->submit([&](sycl::handler& h) {
34 sycl::local_accessor<T, 1> tile_a(sycl::range<1>(Tile * Tile), h);
35 sycl::local_accessor<T, 1> tile_b(sycl::range<1>(Tile * Tile), h);
40 const int lda = A.
ld();
41 const int ldb = B.
ld();
42 const int ldc = C.
ld();
43 const int stride_a = A.
stride();
44 const int stride_b = B.
stride();
45 const int stride_c = C.
stride();
48 batchlas::impl::parallel_for<GemmTiledGeneralKernel<T, Tile, OpA, OpB>>(h, sycl::nd_range<3>(global, local), [=](sycl::nd_item<3> item) {
49 const int bid =
static_cast<int>(item.get_group(0));
50 const int local_row =
static_cast<int>(item.get_local_id(1));
51 const int local_col =
static_cast<int>(item.get_local_id(2));
52 const int row =
static_cast<int>(item.get_group(1) * Tile + local_row);
53 const int col =
static_cast<int>(item.get_group(2) * Tile + local_col);
59 const T*
const a_item = a_ptr +
static_cast<std::ptrdiff_t
>(bid) * stride_a;
60 const T*
const b_item = b_ptr +
static_cast<std::ptrdiff_t
>(bid) * stride_b;
61 T*
const c_item = c_ptr +
static_cast<std::ptrdiff_t
>(bid) * stride_c;
62 constexpr int batch_a = 0, batch_b = 0, batch_c = 0;
65 for (
int kk0 = 0; kk0 < k; kk0 += Tile) {
66 const int tile_col = kk0 + local_col;
67 const int tile_row = kk0 + local_row;
68 tile_a[local_row * Tile + local_col] = (row < m && tile_col < k)
71 tile_b[local_row * Tile + local_col] = (col < n && tile_row < k)
75 item.barrier(sycl::access::fence_space::local_space);
76 for (
int t = 0; t < Tile && kk0 + t < k; ++t) {
77 sum += tile_a[local_row * Tile + t] * tile_b[t * Tile + local_col];
79 item.barrier(sycl::access::fence_space::local_space);
82 if (row < m && col < n) {
std::pair< int, int > get_effective_dims(const MatrixView< T, MType > &mat, Transpose trans)
Shape (rows, cols) of op(mat) for trans: swapped unless NoTrans.
Event launch_tiled_general(Queue &ctx, const MatrixView< T, MatrixFormat::Dense > &A, const MatrixView< T, MatrixFormat::Dense > &B, const MatrixView< T, MatrixFormat::Dense > &C, T alpha, T beta, const char *(*kernel_trace_name)(KernelVariant))