Skip to content

Use cutlass for a pure julia fallback #88

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions src/blasfallback.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@

function block_matrix_product(state, A, B, C) where {ThreadItemsY, ThreadItemsX}

# Fragments used to store data fetched from SMEM
frag_a = @LocalMemory(state, T, ThreadItemsY)
frag_b = @LocalMemory(state, T, ThreadItemsX)

# Accumulator storage
accumulator = @LocalMemory(state, T, ThreadItemsX, ThreadItemsY)

# GEMM Mainloop - iterates over the entire K dimension - not unrolled
for kblock in Int32(1):BlockItemsK:K_dim
# Load A and B tiles from global memory and store to SMEM
#
# (not shown for brevity - see the CUTLASS source for more detail)

synchronize_threads(state)
# Warp tile structure - iterates over the Thread Block tile
#pragma unroll
for warp_k in Int32(1):WarpItemsK:BlockItemsK
# Fetch frag_a and frag_b from SMEM corresponding to k-index
#
# (not shown for brevity - see CUTLASS source for more detail)

# Thread tile structure - accumulate an outer product
#pragma unroll
for thread_x in Int32(1):ThreadItemsX
#pragma unroll
for thread_y in Int32(1):ThreadItemsY
accumulator[thread_x, thread_y] += frag_a[y] * frag_b[x]
end
end
end
synchronize_threads(state)
end
end