Skip to content

Fix: rename BLK local var to avoid CANN 8.5.1 macro collision#527

Merged
ChaoWao merged 1 commit into
hw-native-sys:mainfrom
ChaoZheng109:fix/issue-517-blk-macro-collision
Apr 13, 2026
Merged

Fix: rename BLK local var to avoid CANN 8.5.1 macro collision#527
ChaoWao merged 1 commit into
hw-native-sys:mainfrom
ChaoZheng109:fix/issue-517-blk-macro-collision

Conversation

@ChaoZheng109

@ChaoZheng109 ChaoZheng109 commented Apr 13, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Rename constexpr uint64_t BLK = 64 to blk_size in fill_initial_value() for both a2a3 and a5 tensor.h
  • CANN 8.5.1 defines #define BLK BLK_Type() in __clang_cce_vector_intrinsics.h:555, causing the device compiler to expand the local variable declaration into invalid code

Testing

  • Simulation tests pass
  • Hardware tests pass (if applicable)

Fixes #517

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

Copy link
Copy Markdown

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 renames the BLK constant to kBlkSize in tensor.h to prevent potential macro collisions. The review feedback suggests propagating this change to other runtime versions for consistency and identifies a pre-existing logic bug where an out-of-bounds write could occur if the buffer size is not a multiple of the element size.

Comment thread src/a5/runtime/tensormap_and_ringbuffer/runtime/tensor.h Outdated
Comment thread src/a5/runtime/tensormap_and_ringbuffer/runtime/tensor.h Outdated
CANN 8.5.1 defines `#define BLK BLK_Type()` in
__clang_cce_vector_intrinsics.h, which causes the device compiler
to expand the local `constexpr uint64_t BLK = 64` declaration into
invalid code. Rename to `blk_size` in both a2a3 and a5 tensor.h.

Fixes hw-native-sys#517
@ChaoZheng109 ChaoZheng109 force-pushed the fix/issue-517-blk-macro-collision branch from 58f9998 to 34be680 Compare April 13, 2026 03:11
@ChaoWao ChaoWao merged commit 83320b4 into hw-native-sys:main Apr 13, 2026
25 of 26 checks passed
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.

[Bug] Build fails with CANN 8.5.1: BLK macro collision in tensor.h

2 participants