Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .github/workflows/benchmark_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
path: plots
- name: Create markdown table from benchmarks
run: |
benchpkgtable ${{ steps.extract-package-name.outputs.package_name }} --rev="${{github.event.repository.default_branch}},${{github.event.pull_request.head.sha}}" --input-dir=results/ --ratio > table.md
benchpkgtable ${{ steps.extract-package-name.outputs.package_name }} --rev="${{github.event.repository.default_branch}},${{github.event.pull_request.head.sha}}" --input-dir=results/ --ratio --mode=time,memory > table.md
echo '### Benchmark Results' > body.md
echo '' >> body.md
echo '<details>' >> body.md
Expand Down
69 changes: 69 additions & 0 deletions benchmark/benchmarks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,72 @@ let default = BenchmarkGroup()
end
SUITE["saxpy"]["default"] = default
end

# Launch overhead: a problem of a single workgroup, so that the time is dominated by the
# host-side work of a launch. The kernel is constructed in the setup and the backend
# synchronized in the teardown, so only the launch itself is measured.
@kernel function scale_kernel!(A, @Const(B))
I = @index(Global)
@inbounds A[I] = 2 * B[I]
end

@kernel function scale_kernel_3d!(A, @Const(B))
i, j, k = @index(Global, NTuple)
@inbounds A[i, j, k] = 2 * B[i, j, k]
end

SUITE["launch"] = BenchmarkGroup()

let launch = BenchmarkGroup(), n = 16, dims = (4, 4, 4)
launch["dynamic workgroup, dynamic ndrange"] = @benchmarkable kernel(A, B, ndrange = $n) setup = (
kernel = scale_kernel!($BACKEND);
A = KernelAbstractions.zeros($BACKEND, Float64, $n);
B = rand!(KernelAbstractions.zeros($BACKEND, Float64, $n))
) teardown = KernelAbstractions.synchronize($BACKEND)

launch["dynamic workgroup, dynamic ndrange, workgroupsize given"] = @benchmarkable kernel(A, B, ndrange = $n, workgroupsize = $n) setup = (
kernel = scale_kernel!($BACKEND);
A = KernelAbstractions.zeros($BACKEND, Float64, $n);
B = rand!(KernelAbstractions.zeros($BACKEND, Float64, $n))
) teardown = KernelAbstractions.synchronize($BACKEND)

launch["static workgroup, dynamic ndrange"] = @benchmarkable kernel(A, B, ndrange = $n) setup = (
kernel = scale_kernel!($BACKEND, $n);
A = KernelAbstractions.zeros($BACKEND, Float64, $n);
B = rand!(KernelAbstractions.zeros($BACKEND, Float64, $n))
) teardown = KernelAbstractions.synchronize($BACKEND)

launch["static workgroup, static ndrange"] = @benchmarkable kernel(A, B) setup = (
kernel = scale_kernel!($BACKEND, $n, $n);
A = KernelAbstractions.zeros($BACKEND, Float64, $n);
B = rand!(KernelAbstractions.zeros($BACKEND, Float64, $n))
) teardown = KernelAbstractions.synchronize($BACKEND)

launch["3D static workgroup, dynamic ndrange"] = @benchmarkable kernel(A, B, ndrange = $dims) setup = (
kernel = scale_kernel_3d!($BACKEND, $dims);
A = KernelAbstractions.zeros($BACKEND, Float64, $dims...);
B = rand!(KernelAbstractions.zeros($BACKEND, Float64, $dims...))
) teardown = KernelAbstractions.synchronize($BACKEND)

launch["3D static workgroup, static ndrange"] = @benchmarkable kernel(A, B) setup = (
kernel = scale_kernel_3d!($BACKEND, $dims, $dims);
A = KernelAbstractions.zeros($BACKEND, Float64, $dims...);
B = rand!(KernelAbstractions.zeros($BACKEND, Float64, $dims...))
) teardown = KernelAbstractions.synchronize($BACKEND)

SUITE["launch"] = launch
end

# Host-side partitioning of the iteration space, independent of the backend.
let partition = BenchmarkGroup(), ndrange = Ref((1024,)), workgroupsize = Ref((16,))
partition["dynamic workgroup, dynamic ndrange"] = @benchmarkable KernelAbstractions.partition(kernel, $ndrange[], $workgroupsize[]) setup = (
kernel = scale_kernel!($BACKEND)
)
partition["static workgroup, dynamic ndrange"] = @benchmarkable KernelAbstractions.partition(kernel, $ndrange[], nothing) setup = (
kernel = scale_kernel!($BACKEND, 16)
)
partition["static workgroup, static ndrange"] = @benchmarkable KernelAbstractions.partition(kernel, nothing, nothing) setup = (
kernel = scale_kernel!($BACKEND, 16, 1024)
)
SUITE["partition"] = partition
end
Loading