Skip to content

Commit

Permalink
Check number of stages for pipelined kernel (#173)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasfaingnaert authored Nov 14, 2023
1 parent 433aa68 commit 912fa05
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/matmul.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ function matmul(conf::Config, a, b, c, d;
shmem = Kernel.shmem_size(conf, kernel)
max_shmem = attribute(device(), CUDA.DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_BLOCK_OPTIN)
if shmem > max_shmem
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))")
throw(ConfigError("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...)
Expand Down

0 comments on commit 912fa05

Please sign in to comment.