feat(hipcub): use primbench#8534
Conversation
d609ab2 to
dafc68e
Compare
ce4444f to
d5e6827
Compare
|
I've got a TheRock PR up here to make amd_smi available for hipCUB: ROCm/TheRock#6100. |
80632db to
9885258
Compare
|
Rebased to resolve conflicts |
✅ All Policy Checks Passed
📖 Need help? See the Policy FAQ for details on every check and how to fix failures. |
|
🎉 All checks passed! This PR is ready for review. |
|
Hi @Naraenda, @MyNameIsTrez, is this PR ready for review? |
|
Hi @NguyenNhuDi, yes it is. I can't attach the graphs to this PR, but there are basically no regressions and no noise timeouts. There are a handful of small TODOs in the PR's description for missing explanations that I will resolve tomorrow. |
|
Hi @NguyenNhuDi, I have resolved all TODOs in this PR. I'll clean up its commit history tomorrow by squashing a lot of its commits. If anyone has any questions, feel free to leave a comment and I will respond. |
03935e5 to
37e76f8
Compare
|
@NguyenNhuDi I've squashed all commits into one and split that back into 8 commits. Those 8 commits are listed under the |
37e76f8 to
ee2ae71
Compare
|
Resolved conflicts and queued CI. |
ace1a94 to
d07f10f
Compare
Motivation
hipCUB's benchmarks have been updated to use primbench. primbench performs repeated GPU-specific measurement, cache control, warmup handling, and noise analysis that are difficult to express using Google Benchmark.
Because primbench measures cold-cache execution by default, benchmark throughput numbers are generally expected to be lower than previous Google Benchmark results due to cache clearing between measurement batches.
The diff of
benchmark_device_batch_copy.cpprepresents what changes have been made to all benchmarks.JIRA ID : ROCM-27706
Technical Details
Caution
This PR must not be merged before the PR Add hipCUB CCCL 3.0.x support on which it is based has been merged.
After that CCCL PR has been merged, this primbench PR should be rebased onto the develop branch, starting with its first true commit
use primbench in all the benchmarks.Important
AMD should confirm that the HIP benchmarks build and run successfully on Windows, since Stream HPC's Windows CI is currently broken.
Note
If AMD's GPU cooling setup is too weak or too powerful then
--min-gpu-temp(default 50°C) or--max-gpu-temp(default 60°C) will need to be passed to benchmarks by AMD's CI. I recommend holding off on passing these flags until a benchmark actually times out from not reaching the 50°C-60°C temperature range.The easiest way to review this PR is commit-by-commit starting from commit
feat(hipcub): use primbench in benchmark_device_batch_copy.cpp. The commit list below serves as an overview of the changes. To walk through their code I recommend just repeatedly clicking theNextbutton that is shown when viewing a specific commit:Test Plan
The below blocks of commands can be copied directly into a terminal, so you don't need to copy the lines individually.
See the
Test Resultheader in this description for the zip that contains all of the scripts that these reproduction steps use.VS Code dev containers
HIP
Dockerfile+devcontainer.jsonDockerfile:FROM rocm/rocm-terminal:latestdevcontainer.json:{ "build": { "dockerfile": "Dockerfile" }, "name": "hip-minimal", "runArgs": [ "--device=/dev/kfd", "--device=/dev/dri" ] }CUDA
Dockerfile+devcontainer.jsonDockerfile:devcontainer.json:{ "build": { "dockerfile": "Dockerfile" }, "name": "cuda-minimal", "privileged": true, "runArgs": [ "--gpus=all" ] }Reproduction steps
Installing dependencies
sudo apt update && \ sudo apt install -y cmake ninja-buildCloning
Checking out this pull request
git fetch origin pull/8534/head:users/Nemi26/use-primbench-in-hipcub && \ git checkout users/Nemi26/use-primbench-in-hipcubBuilding primbench benchmarks
Setup
HIP
CUDA
Copying run_benchmarks_new.py to a server
Running primbench benchmarks
Copying primbench benchmark results from a server
Checking out the baseline develop commit which this PR is based on
If PR Add hipCUB CCCL 3.0.x support has not been merged yet, you will first need to check it out:
You can then check its last commit out:
# You can change this commit hash to `develop`, once the CCCL 3.0.x PR is merged git checkout e7f31172c14Building develop benchmarks
HIP
CUDA
Copying run_benchmarks_old.py to a server
Running develop benchmarks
Copying develop benchmark results from a server
Converting develop JSON results to primbench CSVs
The script
gbench2primbench.pyconverts a directory of old Google Benchmark JSON files to a directory of new primbench CSV files.--helpoptionsPrinting noisy benchmarks
The script
print_noisy.pytakes the path to a directory of primbench CSV files, and prints CSV file names that contain specializations that timed out due to noise.--helpoptionsGenerating benchmark graphs
The script
visbench.pytakes an old and a new directory of primbench JSON and CSV files and generates an SVG visualization. It automatically matches files between the directories by their filenames, merges the underlying data, and calculates thebytes_per_secondspeedup ratios.The resulting graph displays the percentage distribution of these performance speedups across benchmarks. A legend at the top specifies the color mapping for the speedup ratios, categorizing them into 7 discrete buckets (ranging from
<0.9×to>1.1×).Say a
unique_by_keybenchmark has a large red area comprising 60% of its total bar. This means that 60% of its benchmark specializations fell into the<0.9×speedup bucket. In other words, 60% of those specializations became more than 10% slower.--helpoptionsGenerating specialization graphs
The script
grapher.pytakes primbench JSON and CSV files, and generates a relative or absolute graph.In the previous step
gbench2primbench.pywas used to convert old Google Benchmark JSON files to primbench CSV files.Absolute graphs can be generated by passing
--absolutetographer.py.--helpoptionsTest Result
No meaningful performance regressions and noise timeouts were observed.
I ran all 35 hipCUB benchmarks on an MI300X GPU.
Noisy Benchmarks
Five benchmarks still have more than 1% noise: block_reduce, block_scan, device_segmented_radix_sort, device_segmented_sort, and warp_merge_sort. These have been passed
settings.noise_tolerance_percentvalues of 2 and 3 to prevent timeouts.Paul Kliemann is working on a primbench PR that will significantly lower the noise of benchmark specializations, by calculating entropy instead. rocRAND will automatically benefit from it.
Benchmark Graphs
See the
Generating benchmark graphsreproduction step for how to generate benchmark graphs.primbench its GPU Cache Clearing header explains the difference between the "hot" and "cold" graphs:
Cold mode is what is getting merged, which by its very nature lowers the throughput of benchmarks. Hot mode graphs are included, as they prove that no bugs were introduced when porting benchmarks from Google Benchmark to primbench.
The specialization graphs from
grapher.pyare primarily intended for investigating specific regressions.Submission Checklist