TheRock : Code Coverage - enable per-project code coverage builds #8598
All Vouch review confidence checks passed
Residual risk 0.33 = Change Risk (0.59) × (1 − Review Confidence (0.45)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.59 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #8598"
general
weight: 0.35
endurthiabhilash
Motivation
GitHub issue: https://github.com/ROCm/TheRock/issues/6572
TheRock configures each rocm-libraries and rocm-systems project as a separate CMake subproject and passes it only the arguments TheRock declares.
Instrumenting a library for code coverage today means knowing that library's own option name and passing it through the per-subproject argument, for example
-DhipDNN_CMAKE_ARGS=-DHIPDNN_ENABLE_COVERAGE=ON. RFC0014 asks for one option name for every project,-D<PROJECT>_ENABLE_COVERAGE=ON, and for group options that let a nightly build instrument every supported library at once. This PR adds both.Design
Split out PR https://github.com/ROCm/TheRock/pull/7783 into six PRs, stacked in this order from the bottom: https://github.com/ROCm/TheRock/pull/9717, https://github.com/ROCm/TheRock/pull/8602, https://github.com/ROCm/TheRock/pull/10334, https://github.com/ROCm/TheRock/pull/8598, https://github.com/ROCm/TheRock/pull/10335 and https://github.com/ROCm/TheRock/pull/8605. This PR doesn't depend on the three below it; it sits on them only because a stack is a single chain.
Below is a modified design of what each PR will do.
PR https://github.com/ROCm/TheRock/pull/8598 - build instrumentation (following https://github.com/ROCm/TheRock/issues/6572)
cmake/therock_subproject.cmake passes -D<PROJECT_NAME>_ENABLE_COVERAGE unchanged to that subproject's configure. The project's own option then turns on instrumentation; a project that doesn't implement the option builds normally. Each project in rocm-libraries and rocm-systems has to implement <PROJECT_NAME>_ENABLE_COVERAGE in its own CMake files. That work is outside these PRs.
CMakeLists.txt adds three group options (THEROCK_COVERAGE_ROCM_LIBRARIES_ALL, THEROCK_COVERAGE_ROCM_SYSTEMS_ALL, THEROCK_COVERAGE_ALL), the project lists, and a loop that sets <PROJECT_NAME>_ENABLE_COVERAGE=ON for the listed projects unless it is already set, so an explicit -D<PROJECT_NAME>_ENABLE_COVERAGE=OFF wins. All three default to OFF, so a normal build is unchanged.
PR https://github.com/ROCm/TheRock/pull/8602 - report script
Adds merge_coverage_report.py, which merges the .profraw files and writes an lcov file, a text summary and an HTML report. The coverage test workflow (test_code_coverage_component.yml) and its installer (install_rocm_code_coverage_build.py) that produce those files already exist on main: the installer installs a baseline ROCm and replaces the project under test with its instrumented build, and the workflow runs the tests and uploads the .profraw files.
PR https://github.com/ROCm/TheRock/pull/9717 - stage build input
Adds an extra_cmake_options input to the Linux and Windows stage builds. The value goes through an environment variable, is split on whitespace, and is appended to the stage's cmake command. It is empty by default. For coverage, https://github.com/ROCm/TheRock/pull/8605 uses it to pass its coverage options to the math-libs build: -DHIPDNN_ENABLE_COVERAGE=ON today, plus any group options.
PR https://github.com/ROCm/TheRock/pull/10334 - test and report workflow
multi_arch_ci_coverage_report.yml runs the coverage test workflow for one project, split across parallel test jobs. It then merges the profiles with https://github.com/ROCm/TheRock/pull/8602's merge_coverage_report.py and uploads the report as a workflow artifact, and to Codecov when a token is configured.
PR https://github.com/ROCm/TheRock/pull/10335 - CI matrix script
configure_coverage_ci.py picks the projects (hipDNN for now) and their coverage options. Three workflow inputs, coverage_rocm_libraries_all, coverage_rocm_systems_all and coverage_all, add https://github.com/ROCm/TheRock/pull/8598's matching group options.
PR https://github.com/ROCm/TheRock/pull/8605 - CI entry workflow
multi_arch_ci_coverage_linux.yml is the entry point, started by a manual dispatch or called by another workflow, such as a nightly. It runs configure_coverage_ci.py, builds compiler-runtime, builds math-libs with the coverage options through https://github.com/ROCm/TheRock/pull/9717's input, and starts one report job per project and GPU family.
Note:-
rocm-libraries projects don't share one coverage option name. hipDNN and hipCCL use <PROJECT_NAME>_ENABLE_COVERAGE (for example HIPDNN_ENABLE_COVERAGE), but most others still use older names such as BUILD_CODE_COVERAGE (rocBLAS, rocSPARSE, rocSOLVER, rocFFT, ...) or CODE_COVERAGE (rocRAND). We plan to move every project to <PROJECT_NAME>_ENABLE_COVERAGE, where <PROJECT_NAME> is TheRock's subproject name in upper case, and we still need to estimate the effort for each project.
So for now, the workflows in all the PRs above are validated with hipDNN. hipCCL also reads HIPCCL_ENABLE_COVERAGE, but its instrumented build doesn't link on the CI build image yet (see Known limitation), so it stays in the group list and the coverage CI turns it off for now.
Technical Details
TheRock forwards the option and adds no compiler or linker flags of its own. Each project decides in its own CMake what instrumentation means.
cmake/therock_subproject.cmake:therock_cmake_subproject_activate()upper-cases the subproject's name, sohipDNNlooks forHIPDNN_ENABLE_COVERAGE. If that variable is set in TheRock's configure, its value (ONorOFF) is added unchanged to hipDNN's configure command.CMakeLists.txt: three options, allOFFby default, set<PROJECT>_ENABLE_COVERAGE=ONfor the subprojects in a fixed list.THEROCK_COVERAGE_ROCM_LIBRARIES_ALLcovers the 16 rocm-libraries subprojects inTHEROCK_COVERAGE_ROCM_LIBRARIES_PROJECTS,THEROCK_COVERAGE_ROCM_SYSTEMS_ALLcovers rccl and rocshmem (THEROCK_COVERAGE_ROCM_SYSTEMS_PROJECTS), andTHEROCK_COVERAGE_ALLcovers both lists. hipBLASLt and hipTensor are left out until their instrumented builds link, and test subprojects aren't listed because they read their library's option. An explicit-D<PROJECT>_ENABLE_COVERAGE=OFFwins over a group option.docs/development/code_coverage.mdcovers local builds, the group options and what a project's option must do; #8605 adds its CI sections and how to add a project.development_guide.mdgets a{PROJECT}_ENABLE_COVERAGEentry, and the docs index links the new page.Known limitation
THEROCK_COVERAGE_ROCM_LIBRARIES_ALLcurrently breaks the math-libs build unless hipCCL is turned off. hipCCL's option makes its bundled rocPRIM add-Xarch_host -fprofile-instr-generateto the link of every target that uses it. That flag links LLVM's profiling runtime, which needslibdlandlibpthreadon the CI build image (glibc 2.28), and hipCCL doesn't add them. In a trial run of this change with all three group options,hipCCL_tests(16 programs) andlibhipcxx(3 programs) failed to link. The hipCCL code involved is unchanged at6b5f0a1.hipCCL needs to link
${CMAKE_DL_LIBS}andThreads::Threadswhen coverage is on, ascode_coverage.mdrequires. Until it does,-DHIPCCL_ENABLE_COVERAGE=OFFkeeps hipCCL out of a group build, and the coverage CI (#10335) passes it whenever the rocm-libraries or all group is on. hipBLASLt and hipTensor are left out of the rocm-libraries list until their instrumented builds link.Changes since the last review
Earlier revisions translated
<PROJECT>_ENABLE_COVERAGEinto each project's own option inside TheRock (cmake/therock_coverage.cmake), using a project registry that CMake ran frombuild_tools/github_actions/configure_coverage_ci.py. The open design questions from review were about that layer: the link flags, the device-code flags, CMake depending onbuild_tools/github_actions/, and the registry's scope. This revision removes it.configure_coverage_ci.pyand its tests leave this PR; they are now in #10335, and only #8605's entry workflow calls the script.Risk
Low (2/5). With no coverage option set, no subproject's configure command changes: the pass-through adds an argument only when
<PROJECT>_ENABLE_COVERAGEis set, and the group options default toOFF.Test Plan
pre-commit runon the changed files, andcmake/tests/therock_subproject_prebuilt_test.py, which loadstherock_subproject.cmakeoutside the super-project.-DTHEROCK_ENABLE_ALL=OFF -DTHEROCK_ENABLE_HIPDNN=ON -DHIPDNN_ENABLE_COVERAGE=ONand built withninja hipDNN+build. hipDNN's tests then run on a GPU, and TheRock'sllvm-profdataandllvm-covmerge and report the profiles.Test Result
Testing locally
therock_subproject_prebuilt_test.pypasses 6 of 6.8f76580), on AlmaLinux 8 with glibc 2.28. The only coverage argument TheRock passed to hipDNN was-DHIPDNN_ENABLE_COVERAGE=ON, and hipDNN's cache showsHIPDNN_ENABLE_COVERAGE:BOOL=ON.-fprofile-instr-generate -fcoverage-mapping, and 59 of 59 link steps carry-fprofile-instr-generate. The build and link succeed..profrawfiles. Using hipDNN's own object list,llvm-covreports 88.2% line coverage.Testing in CI
-DHIPDNN_ENABLE_COVERAGE=ON, the three group options and-DHIPCCL_ENABLE_COVERAGE=OFF, and loggedCoverage: enabling <PROJECT>_ENABLE_COVERAGEfor the other 16 listed projects. The instrumented build passed, and hipDNN's tests and coverage report (83.80% of lines) ran on it.No Windows coverage build has run.
Submission Checklist