Skip to content

chore: add clang-tidy configuration#442

Open
zhangstevenunity wants to merge 3 commits intomainfrom
codex/add-clang-tidy-config
Open

chore: add clang-tidy configuration#442
zhangstevenunity wants to merge 3 commits intomainfrom
codex/add-clang-tidy-config

Conversation

@zhangstevenunity
Copy link
Copy Markdown
Collaborator

Summary

  • add a repository-level .clang-tidy based on the configuration used in hw-native-sys/pypto
  • adapt the header filter to this repository's include/ and lib/ layout
  • keep the same enabled/disabled check groups so local and CI static analysis can use a shared baseline

Testing

  • not run (clang-tidy is not installed in the local environment)

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new .clang-tidy configuration file to enforce various coding standards and static analysis checks. The review feedback highlights potential issues with the current configuration: the HeaderFilterRegex is overly broad and may include system headers, the misc-include-cleaner check might be too aggressive for the current state of the codebase, and enabling WarningsAsErrors globally could lead to immediate CI failures before existing issues are resolved.

-portability-template-virtual-member-function

WarningsAsErrors: "*"
HeaderFilterRegex: '.*(include[/\\]|lib[/\\]).*\.(h|hpp)$'
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

The current HeaderFilterRegex is too broad because the leading .* followed by include or lib will match system headers (e.g., /usr/include/stdio.h), causing clang-tidy to report diagnostics for external code. Combined with WarningsAsErrors: "*", this will likely break the build. It is better to use a regex that specifically targets the project's own header directories by including unique path components like PTO or CAPI.

HeaderFilterRegex: '.*(include|lib)[/\\].*(PTO|CAPI|Bindings)[/\\].*\.(h|hpp)$'

modernize-*,
performance-*,
portability-*,
misc-include-cleaner,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The misc-include-cleaner check is very strict and often requires manual annotations (such as // IWYU pragma: keep) to handle false positives where it incorrectly identifies an include as unused or missing. If the codebase has not been prepared for this check, it may generate a large number of errors. Consider disabling it until the initial cleanup is complete.

-performance-inefficient-string-concatenation,
-portability-template-virtual-member-function

WarningsAsErrors: "*"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Enabling WarningsAsErrors: "*" on a new configuration that has not been tested locally (as noted in the PR description) is highly likely to break the CI build. It is recommended to first introduce the configuration with warnings only, fix existing violations, and then enable this option to maintain a clean baseline.

WarningsAsErrors: ""

@zhangstevenunity
Copy link
Copy Markdown
Collaborator Author

/run a5

@reedhecre
Copy link
Copy Markdown

A5 板测失败

  • 触发方式:manual
  • 源码提交:16b53ea5731b
  • 结果汇总:OK 180 / FAIL 34 / SKIP 0
  • 日志:/root/ptoas-board-monitor-a5/logs/20260406_095206_manual_pr442.log
  • 手动指令:/run a5
  • 触发人:zhangstevenunity
  • 触发评论:chore: add clang-tidy configuration #442 (comment)
  • 失败阶段:board-validation / exit=1

失败用例

  • test_if_else_tile_result (run, exit=2)
  • rsqrt (run, exit=2)
  • quant (run, exit=2)
  • quant_asym (run, exit=2)
  • launch (run, exit=1)
  • main (run, exit=1)
  • matmul_vector_mix-pto-sync_kernel (run, exit=1)
  • gqa-pto-sync_kernel (run, exit=1)
  • gqa_qk_kernel (run, exit=1)
  • gqa_softmax_kernel (run, exit=1)
  • gqa_sv_kernel (run, exit=1)
  • launch (run, exit=1)
  • launch_qk (run, exit=1)
  • launch_softmax (run, exit=1)
  • launch_sv (run, exit=1)
  • main (run, exit=1)
  • launch (run, exit=1)
  • launch_qk (run, exit=1)
  • launch_softmax (run, exit=1)
  • launch_sv (run, exit=1)
  • main (run, exit=1)
  • ffn-pto-sync_kernel (run, exit=1)
  • ffn_act_kernel (run, exit=1)
  • ffn_fc1_kernel (run, exit=1)
  • ffn_fc2_kernel (run, exit=1)
  • launch (run, exit=1)
  • launch_act (run, exit=1)
  • launch_fc1 (run, exit=1)
  • launch_fc2 (run, exit=1)
  • main (run, exit=1)
  • control_flow-pto-sync_kernel (run, exit=1)
  • launch (run, exit=1)
  • main (run, exit=1)
  • abs (run, exit=2)

@reedhecre
Copy link
Copy Markdown

A5 板测失败详情:PR #442

test_if_else_tile_result

stage=run info=exit=2

/tmp/ptoas-board-monitor-a5/runs/20260406_095206_manual_pr442/npu_validation/Sync/test_if_else_tile_result/test_if_else_tile_result_kernel.cpp:123:29: error: cannot cast from type 'Tile<TileType::Vec, float, 64, 64, BLayout::RowMajor, 64, 64, SLayout::NoneBox, 512, PadValue::Null>' to pointer type '__ubuf__ float *'
      __ubuf__ float* v28 = (__ubuf__ float*) v14;
                            ^~~~~~~~~~~~~~~~~~~~~
/tmp/ptoas-board-monitor-a5/runs/20260406_095206_manual_pr442/npu_validation/Sync/test_if_else_tile_result/test_if_else_tile_result_kernel.cpp:127:29: error: cannot cast from type 'Tile<TileType::Vec, float, 64, 64, BLayout::RowMajor, 64, 64, SLayout::NoneBox, 512, PadValue::Null>' to pointer type '__ubuf__ float *'
      __ubuf__ float* v29 = (__ubuf__ float*) v15;
                            ^~~~~~~~~~~~~~~~~~~~~
In file included from /tmp/ptoas-board-monitor-a5/runs/20260406_095206_manual_pr442/npu_validation/Sync/test_if_else_tile_result/test_if_else_tile_result_kernel.cpp:32:
In file included from /tmp/ptoas-board-monitor-a5/runs/20260406_095206_manual_pr442/payload/pto-isa/include/pto/pto-inst.hpp:23:
In file included from /tmp/ptoas-board-monitor-a5/runs/20260406_095206_manual_pr442/payload/pto-isa/include/pto/common/pto_instr.hpp:16:
In file included from /tmp/ptoas-board-monitor-a5/runs/20260406_095206_manual_pr442/payload/pto-isa/include/pto/common/pto_instr_impl.hpp:142:
/tmp/ptoas-board-monitor-a5/runs/20260406_095206_manual_pr442/payload/pto-isa/include/pto/npu/a5/TStore.hpp:610:19: error: type '__ubuf__ float *' cannot be used prior to '::' because it has no members
    static_assert(TileData::Loc == pto::TileType::Vec || TileData::Loc == pto::TileType::Acc,
                  ^
/tmp/ptoas-board-monitor-a5/runs/20260406_095206_manual_pr442/payload/pto-isa/include/pto/common/pto_instr.hpp:184:5: note: in instantiation of function template specialization 'pto::TSTORE_IMPL<__ubuf__ float *, pto::GlobalTensor<float, pto::Shape<1, 1, 1, 64, 64>, pto::Stride<4096, 4096, 4096, 64, 1>, pto::Layout::ND>, pto::AtomicType::AtomicNone, pto::STPhase::Unspecified>' requested here
    TSTORE_IMPL<TileData, GlobalData, AtomicType::AtomicNone>(dst, src);
    ^
/tmp/ptoas-board-monitor-a5/runs/20260406_095206_manual_pr442/npu_validation/Sync/test_if_else_tile_result/test_if_else_tile_result_kernel.cpp:137:5: note: in instantiation of function template specialization 'pto::TSTORE<__ubuf__ float *, pto::GlobalTensor<float, pto::Shape<1, 1, 1, 64, 64>, pto::Stride<4096, 4096, 4096, 64, 1>, pto::Layout::ND>>' requested here
    TSTORE(v26, v27);
    ^
3 errors generated.
gmake[2]: *** [CMakeFiles/test_if_else_tile_result_kernel.dir/build.make:76: CMakeFiles/test_if_else_tile_result_kernel.dir/test_if_else_tile_result_kernel.cpp.o] Error 1
gmake[2]: *** Waiting for unfinished jobs....
gmake[1]: *** [CMakeFiles/Makefile2:85: CMakeFiles/test_if_else_tile_result_kernel.dir/all] Error 2
gmake: *** [Makefile:91: all] Error 2
[2026-04-06 10:09:53] ERROR: testcase failed (exit 2): test_if_else_tile_result
rsqrt

stage=run info=exit=2

/tmp/ptoas-board-monitor-a5/runs/20260406_095206_manual_pr442/payload/pto-isa/include/pto/common/event.hpp:141:13: error: no member named 'Wait' in 'pto::Tile<pto::TileType::Vec, float, 32, 32, pto::BLayout::RowMajor, 32, 32, pto::SLayout::NoneBox, 512, pto::PadValue::Null, pto::CompactMode::Null>'
    (events.Wait(), ...);
     ~~~~~~ ^
/tmp/ptoas-board-monitor-a5/runs/20260406_095206_manual_pr442/payload/pto-isa/include/pto/common/pto_instr.hpp:54:5: note: in instantiation of function template specialization 'pto::WaitAllEvents<pto::Tile<pto::TileType::Vec, float, 32, 32, pto::BLayout::RowMajor, 32, 32, pto::SLayout::NoneBox, 512, pto::PadValue::Null, pto::CompactMode::Null>>' requested here
    WaitAllEvents(events...);
    ^
/tmp/ptoas-board-monitor-a5/runs/20260406_095206_manual_pr442/payload/pto-isa/include/pto/common/pto_instr.hpp:1220:5: note: in instantiation of function template specialization 'pto::TSYNC<pto::Tile<pto::TileType::Vec, float, 32, 32, pto::BLayout::RowMajor, 32, 32, pto::SLayout::NoneBox, 512, pto::PadValue::Null, pto::CompactMode::Null>>' requested here
    TSYNC(events...);
    ^
/tmp/ptoas-board-monitor-a5/runs/20260406_095206_manual_pr442/npu_validation/Rsqrt/rsqrt/rsqrt_kernel.cpp:95:3: note: in instantiation of function template specialization 'pto::TRSQRT<pto::Tile<pto::TileType::Vec, float, 32, 32, pto::BLayout::RowMajor, 32, 32, pto::SLayout::NoneBox, 512, pto::PadValue::Null, pto::CompactMode::Null>, pto::Tile<pto::TileType::Vec, float, 32, 32, pto::BLayout::RowMajor, 32, 32, pto::SLayout::NoneBox, 512, pto::PadValue::Null, pto::CompactMode::Null>, pto::Tile<pto::TileType::Vec, float, 32, 32, pto::BLayout::RowMajor, 32, 32, pto::SLayout::NoneBox, 512, pto::PadValue::Null, pto::CompactMode::Null>>' requested here
  TRSQRT(v12, v11, v13);
  ^
1 error generated.
gmake[2]: *** [CMakeFiles/rsqrt_kernel.dir/build.make:76: CMakeFiles/rsqrt_kernel.dir/rsqrt_kernel.cpp.o] Error 1
gmake[2]: *** Waiting for unfinished jobs....
gmake[1]: *** [CMakeFiles/Makefile2:85: CMakeFiles/rsqrt_kernel.dir/all] Error 2
gmake: *** [Makefile:91: all] Error 2
[2026-04-06 11:12:31] ERROR: testcase failed (exit 2): rsqrt
quant

stage=run info=exit=2

[ERROR] Mismatch: golden_v3.bin vs v3.bin, max diff=9.0 at idx=206 (golden=-10, out=-1, dtype=int8)
[ERROR] compare failed
[2026-04-06 11:33:15] ERROR: testcase failed (exit 2): quant
quant_asym

stage=run info=exit=2

[ERROR] Mismatch: golden_v4.bin vs v4.bin, max diff=10.0 at idx=721 (golden=0, out=10, dtype=uint8)
[ERROR] compare failed
[2026-04-06 11:33:57] ERROR: testcase failed (exit 2): quant_asym
launch

stage=run info=exit=1

[2026-04-06 12:51:56] ERROR: testcase failed (exit 1): launch
main

stage=run info=exit=1

[2026-04-06 12:51:56] ERROR: testcase failed (exit 1): main
matmul_vector_mix-pto-sync_kernel

stage=run info=exit=1

[2026-04-06 12:28:32] ERROR: testcase failed (exit 1): matmul_vector_mix-pto-sync_kernel
gqa-pto-sync_kernel

stage=run info=exit=1

[2026-04-06 12:35:27] ERROR: testcase failed (exit 1): gqa-pto-sync_kernel
gqa_qk_kernel

stage=run info=exit=1

[2026-04-06 12:35:28] ERROR: testcase failed (exit 1): gqa_qk_kernel
gqa_softmax_kernel

stage=run info=exit=1

[2026-04-06 12:35:28] ERROR: testcase failed (exit 1): gqa_softmax_kernel
gqa_sv_kernel

stage=run info=exit=1

[2026-04-06 12:35:28] ERROR: testcase failed (exit 1): gqa_sv_kernel
launch

stage=run info=exit=1

[2026-04-06 12:51:56] ERROR: testcase failed (exit 1): launch
launch_qk

stage=run info=exit=1

[2026-04-06 12:41:16] ERROR: testcase failed (exit 1): launch_qk
launch_softmax

stage=run info=exit=1

[2026-04-06 12:41:16] ERROR: testcase failed (exit 1): launch_softmax
launch_sv

stage=run info=exit=1

[2026-04-06 12:41:16] ERROR: testcase failed (exit 1): launch_sv
main

stage=run info=exit=1

[2026-04-06 12:51:56] ERROR: testcase failed (exit 1): main
launch

stage=run info=exit=1

[2026-04-06 12:51:56] ERROR: testcase failed (exit 1): launch
launch_qk

stage=run info=exit=1

[2026-04-06 12:41:16] ERROR: testcase failed (exit 1): launch_qk
launch_softmax

stage=run info=exit=1

[2026-04-06 12:41:16] ERROR: testcase failed (exit 1): launch_softmax
launch_sv

stage=run info=exit=1

[2026-04-06 12:41:16] ERROR: testcase failed (exit 1): launch_sv
main

stage=run info=exit=1

[2026-04-06 12:51:56] ERROR: testcase failed (exit 1): main
ffn-pto-sync_kernel

stage=run info=exit=1

[2026-04-06 12:43:54] ERROR: testcase failed (exit 1): ffn-pto-sync_kernel
ffn_act_kernel

stage=run info=exit=1

[2026-04-06 12:43:54] ERROR: testcase failed (exit 1): ffn_act_kernel
ffn_fc1_kernel

stage=run info=exit=1

[2026-04-06 12:43:54] ERROR: testcase failed (exit 1): ffn_fc1_kernel
ffn_fc2_kernel

stage=run info=exit=1

[2026-04-06 12:43:54] ERROR: testcase failed (exit 1): ffn_fc2_kernel
launch

stage=run info=exit=1

[2026-04-06 12:51:56] ERROR: testcase failed (exit 1): launch
launch_act

stage=run info=exit=1

[2026-04-06 12:43:54] ERROR: testcase failed (exit 1): launch_act
launch_fc1

stage=run info=exit=1

[2026-04-06 12:43:54] ERROR: testcase failed (exit 1): launch_fc1
launch_fc2

stage=run info=exit=1

[2026-04-06 12:43:54] ERROR: testcase failed (exit 1): launch_fc2
main

stage=run info=exit=1

[2026-04-06 12:51:56] ERROR: testcase failed (exit 1): main
control_flow-pto-sync_kernel

stage=run info=exit=1

[2026-04-06 12:51:56] ERROR: testcase failed (exit 1): control_flow-pto-sync_kernel
launch

stage=run info=exit=1

[2026-04-06 12:51:56] ERROR: testcase failed (exit 1): launch
main

stage=run info=exit=1

[2026-04-06 12:51:56] ERROR: testcase failed (exit 1): main
abs

stage=run info=exit=2

[ERROR] Mismatch: golden_v2.bin vs v2.bin, max diff=nan at idx=14 (golden=nan, out=nan, dtype=float32)
[ERROR] compare failed
[2026-04-06 13:19:13] ERROR: testcase failed (exit 2): abs
[2026-04-06 13:19:13] === SUMMARY ===
[2026-04-06 13:19:13] OK=180 FAIL=34 SKIP=0
[2026-04-06 13:19:13] RESULTS_TSV=/tmp/ptoas-board-monitor-a5/runs/20260406_095206_manual_pr442/remote_npu_validation_results.tsv

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants