Skip to content

Commit

Permalink
Check number of stages for pipelined kernel
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasfaingnaert committed Nov 14, 2023
1 parent 433aa68 commit da6d101
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/matmul.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ function matmul(conf::Config, a, b, c, d;
error("Requested too much shared memory: The current GPU can use at most $(Base.format_bytes(max_shmem)), while this configuration required $(Base.format_bytes(shmem))")
end

# Check that there are at least two stages for pipelined kernels.
if kernel == Kernel.matmul_pipelined
conf.block_shape.K 2 * conf.compute_op_shape.K || throw(ConfigError("Need at least two stages to use a pipelined kernel, i.e. BLOCK_K ≥ 2 * OPERATOR_K"))
end

hostkernel = @cuda launch=false kernel(args...)
attributes(hostkernel.fun)[CUDA.FUNC_ATTRIBUTE_MAX_DYNAMIC_SHARED_SIZE_BYTES] = shmem
hostkernel(args...; threads, blocks, shmem)
Expand Down

0 comments on commit da6d101

Please sign in to comment.