Skip to content

[GPU] Enable clang-tidy for Intel GPU plugin#36570

Open
allnes wants to merge 13 commits into
openvinotoolkit:masterfrom
allnes:an/gpu-clang-tidy-bootstrap
Open

[GPU] Enable clang-tidy for Intel GPU plugin#36570
allnes wants to merge 13 commits into
openvinotoolkit:masterfrom
allnes:an/gpu-clang-tidy-bootstrap

Conversation

@allnes

@allnes allnes commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Bootstrap clang-tidy for the Intel GPU plugin with a single check: modernize-use-override.

Add .clang-tidy config enabling only modernize-use-override, wire the
GPU targets (runtime, kernels, graph, plugin) into the existing
ov_apply_clang_tidy/ADD_CLANG_TIDY flow, and apply the resulting
override fixes across the plugin. Add a Build-GPU clang-tidy CI job and
refactor the shared build steps into a clang_tidy_build composite action.
@github-actions github-actions Bot added category: GPU OpenVINO GPU plugin category: build OpenVINO cmake script / infra category: CI OpenVINO public CI github_actions Pull requests that update GitHub Actions code labels Jun 25, 2026
@allnes
allnes marked this pull request as ready for review June 25, 2026 12:54
@allnes
allnes requested review from a team as code owners June 25, 2026 12:54
allnes added 2 commits June 25, 2026 14:54
Set WarningsAsErrors to '*' in the GPU .clang-tidy so future checks added
to the Checks list are enforced without editing the field, matching the
CPU plugin config. Normalize the copyright headers of two touched
kernel_selector files to the SPDX format required by the copyright_check CI.
@allnes allnes changed the title [GPU] Enable clang-tidy modernize-use-override for Intel GPU plugin [GPU] Enable clang-tidy for Intel GPU plugin Jun 25, 2026
Apply ov_apply_clang_tidy inside ov_gpu_add_backend_target so the
per-backend OBJECT libraries (common, cpu, ocl, ocl_v2, onednn, sycl,
cm) are analyzed; the openvino_intel_gpu_graph STATIC lib excludes those
sources, so they were previously unlinted. This raises clang-tidy
coverage of the plugin build from 793 to 962 sources.

Restrict HeaderFilterRegex to first-party include/src/tests headers and
drop the non-existent src/tests/functional/plugin/gpu path, so thirdparty
headers are no longer diagnosed. Thread openvino-repo/build-dir inputs
into the clang_tidy_build action calls so the job-level env stays
authoritative instead of relying on the action defaults.
@maxnick

maxnick commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

@isanghao , FYI

@p-durandin p-durandin added this to the 2026.3 milestone Jun 26, 2026
allnes added 3 commits June 26, 2026 18:28
… GPU job

Rename the clang-tidy build jobs to a consistent Build-<target> scheme:
Build -> Build-x86_64 and Build-GPU -> Build-gpu (Build-aarch64 and
Build-riscv64 already match), and update Overall_Status.needs.

Temporarily drop --quiet from the GPU job to confirm in CI logs that
clang-tidy actually runs over intel_gpu sources; --quiet will be restored
in a follow-up commit.
Revert the temporary verbose build flag used to verify in CI that
clang-tidy runs over intel_gpu sources. The verbose run confirmed 775
intel_gpu objects (incl. 169 graph/impls) are freshly compiled by the
Build-gpu target; restore '--quiet -k 0' to match the other jobs.
@allnes
allnes force-pushed the an/gpu-clang-tidy-bootstrap branch from 3d74f80 to c38789f Compare June 26, 2026 17:29
@@ -0,0 +1,89 @@
name: 'Clang-tidy build'

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typically we add builds as re-usable workflows, not as composite actions... Was there any particular reason to choose a composite action?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is step-level reuse, not job-level.

The four jobs (Build-x86_64/aarch64/riscv64/gpu) differ only in runs-on, container and env, but share the same step sequence:

sccache setup -> checkout -> cmake configure -> build -> upload compile_commands.json -> sccache stats

A composite action lets each job keep its own runner/container/env and inject only the deltas via inputs (build-target, cmake-extra-args, build-extra-args, compile-commands-artifact).

A workflow_call would pull the runner labels and container definition behind the reusable-workflow boundary and re-expose them as inputs — more indirection for the same result. Composite actions also can't set runs-on/container, so those stay declarative in the caller, which is what we want here.

Can switch to a reusable job_clang_tidy.yml if you'd rather keep it uniform with the rest of CI.

@v-Golubev v-Golubev self-assigned this Jul 3, 2026
Comment thread src/plugins/intel_gpu/.clang-tidy Outdated
WarningsAsErrors: '*'
# Use clang-format for applied fixes.
FormatStyle: file
HeaderFilterRegex: "src/plugins/intel_gpu/(include|src|tests)/.*\\.(h|hpp)$"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't probably enable tidy for tests (as I can see in other components, this is a common practice), otherwise we may spend significant resources on tests refactoring during new tidy checks adding

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@v-Golubev thanks, fixed

allnes added 2 commits July 16, 2026 20:52
…-bootstrap

# Conflicts:
#	.github/workflows/clang_tidy.yml
Drop the 'tests' path from the header filter so clang-tidy only covers
include/ and src/, matching the common practice in other components
(e.g. intel_cpu). This avoids spending resources on test refactoring
when new checks are enabled.
@allnes
allnes requested review from akladiev and v-Golubev July 16, 2026 18:57
allnes added 2 commits July 16, 2026 21:10
The clang-tidy CI job builds with -DENABLE_TESTS=OFF and the tests
path is excluded from HeaderFilterRegex, so test sources are not
checked. Leave them untouched instead of carrying override edits
that clang-tidy does not enforce.
Document the two entry points: ov_add_plugin's ADD_CLANG_TIDY option
for the plugin target, and direct ov_apply_clang_tidy() calls for the
static/object libraries that are not created via ov_add_plugin.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

category: build OpenVINO cmake script / infra category: CI OpenVINO public CI category: GPU OpenVINO GPU plugin github_actions Pull requests that update GitHub Actions code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants