已合并
fix(pass): Identify sanitizer entry by function type instead of name #6767
fix(pass): Identify sanitizer entry by function type instead of name #6767
已合并
zhengyaoff12创建于 9月29日
zhengyaoff12
zhengyaoff12成员
9月29日

The sanitizer pass identified the kernel entry function by comparing func->name_ with program->name_. When @pl.jit(name=...) differs from the kernel function name (e.g. @pl.jit(sanitizer=True, name="foo") decorating def kern(...)), no function in the program ever matched, and:

  • instrumentation was silently skipped: no block.sanitizer_log records were injected;
  • the hidden sanitizer_log / sanitizer_log_capacity parameters were not appended to the kernel signature, while the launcher still passed them on every launch;
  • every launch then failed with a misleading InvalidType: Expected 2 args, got 4.

Changes:

  • Identify the entry structurally instead: it is the Opaque function the frontend always builds for the kernel body, the same criterion the host side already uses to derive the launch ABI (_get_kernel_ir_function), so the pass and the launch ABI can no longer disagree
  • Add an internal check that rejects programs not carrying exactly one Opaque entry function, so a skipped instrumentation can no longer stay silent
  • Add a regression test (test_named_kernel_sanitizer_instrumented) that launches a named @pl.jit(sanitizer=True) kernel whose name differs from the function name

Verification on Ascend950PR, full python/tests/st/pypto_pro/frontend/sanitizer/test_sanitizer.py:

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 zhengyaoff12 的贡献)
zhengyaoff12zhengyaoff12成员
9月29日 创建了 pull request,commit 0a3d3530
atomgit-bot
atomgit-bot
9月29日 评论:

变更摘要

本 PR 修复 sanitizer pass 对内核入口函数的识别方式。原先 SanitizerInstrumenter::Instrument 通过 func->name_ != program->name_ 判断入口,当 @pl.jit(name=...) 指定的名字与内核函数名不一致时无法匹配任何函数,导致插桩被静默跳过、隐藏的 sanitizer_log 与 sanitizer_log_capacity 参数未追加,而启动侧仍按新 ABI 传参,最终抛出误导性的 InvalidType: Expected 2 args, got 4。改动改为按函数类型结构性识别入口(前端为内核主体构建的 Opaque 函数),并新增入口唯一性校验与回归测试。

主要改动

  • 入口识别改为按函数类型判定: sanitizer_pass.cpp 中将入口条件由 func->name_ != program->name_(并显式排除 SIMT_VF/SIMT_CALLEE)改为 func->funcType_ != FunctionType::OPAQUE,使插桩入口与宿主侧定位内核入口的判据一致,避免因命名不一致而跳过插桩、破坏启动 ABI。
  • 新增入口数量内部校验: 在 Instrument 中累加 entry_count,并通过 PRO_PASS_INTERNAL_CHECK 断言程序必须恰好包含一个 Opaque 入口函数,使插桩被跳过时不再静默。
  • 补充命名内核回归测试: test_sanitizer.py 新增 named_clean_kernel(@pl.jit(sanitizer=True, auto_mutex=True, name="sanitizer_named_entry_kernel"))与 test_named_kernel_sanitizer_instrumented,验证 name= 与函数名不一致时仍能完成插桩并正常启动、结果正确。
likedislike
不准确?
atomgit-bot
atomgit-bot
9月29日 评论:

代码审查

✅ 未发现问题

likedislike
不准确?
CANN-robotCANN-robot成员
9月29日 添加了label:cann-cla/yes
CANN-robot
CANN-robot成员
9月29日 评论:

Thanks for your pull-request.
The full list of commands accepted by me can be found at here.
You can get sig-info at here.
You can self-configure the PR merge rules for this repository. For more details, please refer to Here.
For more, you also can visit HICANN.


PR Approval Progress

✅ Congratulations! All modules have met the lgtm and approve requirements.

Module Approval Details

module lgtm status approve status
9.2.0 ✅ gcw_kUomxQ2l, gaoxiang618 (2/2) ✅ gcw_kUomxQ2l (1/1)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)

CLA Signature Pass

zhengyaoff12, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
此处折叠了42条消息 查看更多
CANN-robotCANN-robot成员
9月30日 添加了label:approved
gaoxiang618
gaoxiang618成员
9月30日 评论:

/approve
/lgtm

likedislike
CANN-robot
CANN-robot成员
9月30日 评论:

The following users do not have permission to comment /lgtm or /approve on any module in this PR:
/approve: gaoxiang618

likedislike
CANN-robotCANN-robot成员
9月30日 添加了label:lgtm
CANN-robotCANN-robot成员
9月30日 合入了pull request