Skip to content

Refactor: extract byte-identical platform headers/sources to common (-1000 lines)#934

Merged
ChaoWao merged 1 commit into
hw-native-sys:mainfrom
hw-native-sys-bot:platform-shared-headers
May 31, 2026
Merged

Refactor: extract byte-identical platform headers/sources to common (-1000 lines)#934
ChaoWao merged 1 commit into
hw-native-sys:mainfrom
hw-native-sys-bot:platform-shared-headers

Conversation

@hw-native-sys-bot
Copy link
Copy Markdown
Collaborator

Summary

Move 9 byte-identical headers from src/{a2a3,a5}/platform/include/ into src/common/platform/include/ and 2 byte-identical sources from src/{a2a3,a5}/platform/src/aicpu/ into src/common/platform/src/aicpu/. Pure mechanical dedup — no semantic changes.

Files moved (single canonical copy now in common)

File Lines
include/aicpu/device_log.h 99
include/aicpu/platform_aicpu_affinity.h 19
include/aicpu/scope_stats_collector_aicpu.h 90
include/common/compile_strategy.h 35
include/common/core_type.h 75
include/common/qualifier.h 38
include/common/scope_stats.h 188
include/host/raii_scope_guard.h 56
include/host/runtime_compile_info.h 37
src/aicpu/scope_stats_collector_aicpu.cpp 331
src/aicpu/unified_log_device.cpp 67
Total per arch 1035

CMakeLists changes

  • 12 platform CMakeLists (a2a3/a5 × onboard/sim × aicore/aicpu/host) add src/common/platform/include/ to CMAKE_CUSTOM_INCLUDE_DIRS, ordered after the per-arch include so arch-specific headers (those that genuinely differ) still take precedence.
  • 4 aicpu CMakeLists (a2a3/a5 × onboard/sim) extend the COMMON_SOURCES glob to pick up the moved .cpp files from common/platform/src/aicpu/.
  • simpler_setup/kernel_compiler.py::get_platform_include_dirs() adds the common include path so orchestration cpp can still resolve e.g. \"common/core_type.h\" (used by orchestration_api.h on both arches).

Test plan

  • Onboard + sim, both arches built clean
  • a2a3sim ST L1+L2 passes (38/38, devices 0,1)
  • a5sim ST L1+L2 passes (22/22, devices 0,1)
  • Spot-checked bgemm (host_build_graph) on a2a3sim — was the first to catch the orchestration include-path miss; passes after the kernel_compiler.py fix
  • CI green

Net: -1008 lines deduped across the repo.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 31, 2026

Warning

Review limit reached

@ChaoWao, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 3 minutes and 11 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: fba83c16-1c11-4844-9da9-5d09fb1792a1

📥 Commits

Reviewing files that changed from the base of the PR and between 0309e78 and 9da6232.

📒 Files selected for processing (36)
  • simpler_setup/kernel_compiler.py
  • src/a2a3/platform/onboard/aicore/CMakeLists.txt
  • src/a2a3/platform/onboard/aicpu/CMakeLists.txt
  • src/a2a3/platform/onboard/host/CMakeLists.txt
  • src/a2a3/platform/sim/aicore/CMakeLists.txt
  • src/a2a3/platform/sim/aicpu/CMakeLists.txt
  • src/a2a3/platform/sim/host/CMakeLists.txt
  • src/a5/platform/include/aicpu/device_log.h
  • src/a5/platform/include/aicpu/platform_aicpu_affinity.h
  • src/a5/platform/include/aicpu/scope_stats_collector_aicpu.h
  • src/a5/platform/include/common/compile_strategy.h
  • src/a5/platform/include/common/core_type.h
  • src/a5/platform/include/common/qualifier.h
  • src/a5/platform/include/common/scope_stats.h
  • src/a5/platform/include/host/raii_scope_guard.h
  • src/a5/platform/include/host/runtime_compile_info.h
  • src/a5/platform/onboard/aicore/CMakeLists.txt
  • src/a5/platform/onboard/aicpu/CMakeLists.txt
  • src/a5/platform/onboard/host/CMakeLists.txt
  • src/a5/platform/sim/aicore/CMakeLists.txt
  • src/a5/platform/sim/aicpu/CMakeLists.txt
  • src/a5/platform/sim/host/CMakeLists.txt
  • src/a5/platform/src/aicpu/scope_stats_collector_aicpu.cpp
  • src/a5/platform/src/aicpu/unified_log_device.cpp
  • src/common/platform/include/aicpu/device_log.h
  • src/common/platform/include/aicpu/platform_aicpu_affinity.h
  • src/common/platform/include/aicpu/scope_stats_collector_aicpu.h
  • src/common/platform/include/common/compile_strategy.h
  • src/common/platform/include/common/core_type.h
  • src/common/platform/include/common/qualifier.h
  • src/common/platform/include/common/scope_stats.h
  • src/common/platform/include/host/raii_scope_guard.h
  • src/common/platform/include/host/runtime_compile_info.h
  • src/common/platform/src/aicpu/scope_stats_collector_aicpu.cpp
  • src/common/platform/src/aicpu/unified_log_device.cpp
  • tests/ut/cpp/CMakeLists.txt

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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 restructures the codebase by moving shared platform headers and source files (such as logging, scope stats, and compile strategies) from architecture-specific directories into a unified common platform directory (src/common/platform). To accommodate this relocation, include paths and source globs are updated across various CMakeLists.txt files for both a2a3 and a5 platforms, and the Python kernel compiler is adjusted. The review feedback highlights a potential issue with CMake's file(GLOB ...) usage in several CMakeLists.txt files, recommending the addition of the CONFIGURE_DEPENDS flag to ensure the build system automatically detects when source files are added or removed.

Comment thread src/a2a3/platform/onboard/aicpu/CMakeLists.txt Outdated
Comment thread src/a2a3/platform/sim/aicpu/CMakeLists.txt Outdated
Comment thread src/a5/platform/onboard/aicpu/CMakeLists.txt Outdated
Comment thread src/a5/platform/sim/aicpu/CMakeLists.txt Outdated
@ChaoWao ChaoWao force-pushed the platform-shared-headers branch from 2f92daa to 981626a Compare May 31, 2026 06:33
ChaoWao added a commit to hw-native-sys-bot/simpler that referenced this pull request May 31, 2026
Move 6 headers + 1 source whose per-arch differences were ONLY:
- Header guards (SRC_A2A3_… vs SRC_A5_…)
- Comments naming the arch ("a2a3" / "a5" — generalized to the
  shared "onboard" / "sim" axis)
- Two log-string tweaks in tensor_dump_aicpu.cpp

into src/common/platform/include/ + src/common/platform/src/aicpu/.
No code-level semantic changes; the per-arch copies were equivalent
modulo doc strings.

Files moved (canonical copy now in common):
- include/common/memory_barrier.h (63)
- include/aicpu/tensor_dump_aicpu.h (305)
- include/aicpu/device_time.h (28)
- include/aicpu/orch_so_file.h (57)
- include/host/function_cache.h (122)
- include/host/platform_compile_info.h (37)
- src/aicpu/tensor_dump_aicpu.cpp (598)
                    Per-arch saved: 1210
Total dedup'd:                       ~1100

Comment cleanups carried with the move:
- device_time.h: "a2a3: Real Ascend hardware" → "onboard: …"
- orch_so_file.h: "a2a3 (onboard): pid-based naming" → "onboard: …"
- function_cache.h: "a2a3: Real hardware" → "onboard: …"
- platform_compile_info.h: "Each platform (a2a3, a2a3sim, ...)" →
  "Each platform (one of a2a3, a2a3sim, a5, a5sim)"
- Header guards normalized to SRC_COMMON_PLATFORM_INCLUDE_…

Include-path follow-up:
- l2_perf_collector_aicpu.h (still per-arch — DIFF) was doing
  `#include "device_time.h"` (no subdirectory prefix), which only
  worked because device_time.h lived alongside it in the same
  `aicpu/` directory. Now that device_time.h moved up to
  common/platform/include/aicpu/, qualify the include as
  `#include "aicpu/device_time.h"` to match the shared search-path
  shape. Both arches' l2_perf_collector_aicpu.h updated.

Builds:
- a2a3sim + a5sim host_runtime.so clean
- a2a3sim ST L1+L2 pass (38/38, devices 0,1)
- a5sim ST L1+L2 pass (22/22, devices 0,1)

Stacked on hw-native-sys#934 (platform-shared-headers).

Co-authored-by: Chao Wang <26245345+ChaoWao@users.noreply.github.com>
ChaoWao added a commit to hw-native-sys-bot/simpler that referenced this pull request May 31, 2026
Move 3 more headers whose per-arch differences were ONLY
arch-name strings in doc comments — same pattern as hw-native-sys#937:

- include/aicore/aicore.h (33 lines)
- include/aicpu/device_malloc.h (53 lines)
- include/host/memory_allocator.h (109 lines)

Per-arch save: ~195 lines deduped (one copy each in common; both
arches' copies were equivalent code modulo doc text).

Comment cleanup carried with the moves:
- aicore.h: "a2a3: Real Ascend hardware" → "onboard: …" and
  "src/a2a3/platform/onboard/aicore/inner_kernel.h" →
  "src/{a2a3,a5}/platform/onboard/aicore/inner_kernel.h"
- device_malloc.h: "On a2a3:" / "On a2a3sim:" → "On onboard:" /
  "On sim:" (function descriptions, not behavior)
- memory_allocator.h: "a2a3: Wraps CANN runtime" / etc. → "onboard:
  Wraps CANN runtime" (4 occurrences)
- Header guards normalized to SRC_COMMON_PLATFORM_INCLUDE_…

Builds:
- a2a3sim + a5sim host_runtime.so clean
- Smoke ST passes on both arches

Stacked on hw-native-sys#937 (which is stacked on hw-native-sys#934).

Co-authored-by: Chao Wang <26245345+ChaoWao@users.noreply.github.com>
@ChaoWao ChaoWao force-pushed the platform-shared-headers branch from 981626a to 17ff7e8 Compare May 31, 2026 06:59
ChaoWao added a commit to hw-native-sys-bot/simpler that referenced this pull request May 31, 2026
Move 6 headers + 1 source whose per-arch differences were ONLY:
- Header guards (SRC_A2A3_… vs SRC_A5_…)
- Comments naming the arch ("a2a3" / "a5" — generalized to the
  shared "onboard" / "sim" axis)
- Two log-string tweaks in tensor_dump_aicpu.cpp

into src/common/platform/include/ + src/common/platform/src/aicpu/.
No code-level semantic changes; the per-arch copies were equivalent
modulo doc strings.

Files moved (canonical copy now in common):
- include/common/memory_barrier.h (63)
- include/aicpu/tensor_dump_aicpu.h (305)
- include/aicpu/device_time.h (28)
- include/aicpu/orch_so_file.h (57)
- include/host/function_cache.h (122)
- include/host/platform_compile_info.h (37)
- src/aicpu/tensor_dump_aicpu.cpp (598)
                    Per-arch saved: 1210
Total dedup'd:                       ~1100

Comment cleanups carried with the move:
- device_time.h: "a2a3: Real Ascend hardware" → "onboard: …"
- orch_so_file.h: "a2a3 (onboard): pid-based naming" → "onboard: …"
- function_cache.h: "a2a3: Real hardware" → "onboard: …"
- platform_compile_info.h: "Each platform (a2a3, a2a3sim, ...)" →
  "Each platform (one of a2a3, a2a3sim, a5, a5sim)"
- Header guards normalized to SRC_COMMON_PLATFORM_INCLUDE_…

Include-path follow-up:
- l2_perf_collector_aicpu.h (still per-arch — DIFF) was doing
  `#include "device_time.h"` (no subdirectory prefix), which only
  worked because device_time.h lived alongside it in the same
  `aicpu/` directory. Now that device_time.h moved up to
  common/platform/include/aicpu/, qualify the include as
  `#include "aicpu/device_time.h"` to match the shared search-path
  shape. Both arches' l2_perf_collector_aicpu.h updated.

Builds:
- a2a3sim + a5sim host_runtime.so clean
- a2a3sim ST L1+L2 pass (38/38, devices 0,1)
- a5sim ST L1+L2 pass (22/22, devices 0,1)

Stacked on hw-native-sys#934 (platform-shared-headers).

Co-authored-by: Chao Wang <26245345+ChaoWao@users.noreply.github.com>
ChaoWao added a commit to hw-native-sys-bot/simpler that referenced this pull request May 31, 2026
Move 3 more headers whose per-arch differences were ONLY
arch-name strings in doc comments — same pattern as hw-native-sys#937:

- include/aicore/aicore.h (33 lines)
- include/aicpu/device_malloc.h (53 lines)
- include/host/memory_allocator.h (109 lines)

Per-arch save: ~195 lines deduped (one copy each in common; both
arches' copies were equivalent code modulo doc text).

Comment cleanup carried with the moves:
- aicore.h: "a2a3: Real Ascend hardware" → "onboard: …" and
  "src/a2a3/platform/onboard/aicore/inner_kernel.h" →
  "src/{a2a3,a5}/platform/onboard/aicore/inner_kernel.h"
- device_malloc.h: "On a2a3:" / "On a2a3sim:" → "On onboard:" /
  "On sim:" (function descriptions, not behavior)
- memory_allocator.h: "a2a3: Wraps CANN runtime" / etc. → "onboard:
  Wraps CANN runtime" (4 occurrences)
- Header guards normalized to SRC_COMMON_PLATFORM_INCLUDE_…

Builds:
- a2a3sim + a5sim host_runtime.so clean
- Smoke ST passes on both arches

Stacked on hw-native-sys#937 (which is stacked on hw-native-sys#934).

Co-authored-by: Chao Wang <26245345+ChaoWao@users.noreply.github.com>
…-1000 lines)

Move 9 byte-identical headers from src/{a2a3,a5}/platform/include/
into src/common/platform/include/ and 2 byte-identical sources from
src/{a2a3,a5}/platform/src/aicpu/ into src/common/platform/src/aicpu/.
Pure mechanical dedup — no semantic changes.

Files moved (single canonical copy now in common):
- include/aicpu/device_log.h (99)
- include/aicpu/platform_aicpu_affinity.h (19)
- include/aicpu/scope_stats_collector_aicpu.h (90)
- include/common/compile_strategy.h (35)
- include/common/core_type.h (75)
- include/common/qualifier.h (38)
- include/common/scope_stats.h (188)
- include/host/raii_scope_guard.h (56)
- include/host/runtime_compile_info.h (37)
- src/aicpu/scope_stats_collector_aicpu.cpp (331)
- src/aicpu/unified_log_device.cpp (67)

CMakeLists changes:
- 12 platform CMakeLists (a2a3/a5 × onboard/sim × aicore/aicpu/host)
  add src/common/platform/include/ to CMAKE_CUSTOM_INCLUDE_DIRS,
  ordered after the per-arch include so arch-specific headers
  (those that genuinely differ) still take precedence.
- 4 aicpu CMakeLists (a2a3/a5 × onboard/sim) extend the COMMON_SOURCES
  glob to pick up the moved .cpp files from common/platform/src/aicpu/.
- simpler_setup/kernel_compiler.py::get_platform_include_dirs() adds
  the common include path so orchestration cpp can still resolve
  e.g. "common/core_type.h" (used by orchestration_api.h on both
  arches).

Onboard + sim, both arches built clean. ST passes:
- a2a3sim L1+L2: 38/38 (devices 0,1)
- a5sim L1+L2: 22/22 (devices 0,1)

Net: -1008 lines deduped across the repo.

Co-authored-by: Chao Wang <26245345+ChaoWao@users.noreply.github.com>
@ChaoWao ChaoWao force-pushed the platform-shared-headers branch from 17ff7e8 to 9da6232 Compare May 31, 2026 07:27
ChaoWao added a commit to hw-native-sys-bot/simpler that referenced this pull request May 31, 2026
Move 6 headers + 1 source whose per-arch differences were ONLY:
- Header guards (SRC_A2A3_… vs SRC_A5_…)
- Comments naming the arch ("a2a3" / "a5" — generalized to the
  shared "onboard" / "sim" axis)
- Two log-string tweaks in tensor_dump_aicpu.cpp

into src/common/platform/include/ + src/common/platform/src/aicpu/.
No code-level semantic changes; the per-arch copies were equivalent
modulo doc strings.

Files moved (canonical copy now in common):
- include/common/memory_barrier.h (63)
- include/aicpu/tensor_dump_aicpu.h (305)
- include/aicpu/device_time.h (28)
- include/aicpu/orch_so_file.h (57)
- include/host/function_cache.h (122)
- include/host/platform_compile_info.h (37)
- src/aicpu/tensor_dump_aicpu.cpp (598)
                    Per-arch saved: 1210
Total dedup'd:                       ~1100

Comment cleanups carried with the move:
- device_time.h: "a2a3: Real Ascend hardware" → "onboard: …"
- orch_so_file.h: "a2a3 (onboard): pid-based naming" → "onboard: …"
- function_cache.h: "a2a3: Real hardware" → "onboard: …"
- platform_compile_info.h: "Each platform (a2a3, a2a3sim, ...)" →
  "Each platform (one of a2a3, a2a3sim, a5, a5sim)"
- Header guards normalized to SRC_COMMON_PLATFORM_INCLUDE_…

Include-path follow-up:
- l2_perf_collector_aicpu.h (still per-arch — DIFF) was doing
  `#include "device_time.h"` (no subdirectory prefix), which only
  worked because device_time.h lived alongside it in the same
  `aicpu/` directory. Now that device_time.h moved up to
  common/platform/include/aicpu/, qualify the include as
  `#include "aicpu/device_time.h"` to match the shared search-path
  shape. Both arches' l2_perf_collector_aicpu.h updated.

Builds:
- a2a3sim + a5sim host_runtime.so clean
- a2a3sim ST L1+L2 pass (38/38, devices 0,1)
- a5sim ST L1+L2 pass (22/22, devices 0,1)

Stacked on hw-native-sys#934 (platform-shared-headers).

Co-authored-by: Chao Wang <26245345+ChaoWao@users.noreply.github.com>
ChaoWao added a commit to hw-native-sys-bot/simpler that referenced this pull request May 31, 2026
Move 3 more headers whose per-arch differences were ONLY
arch-name strings in doc comments — same pattern as hw-native-sys#937:

- include/aicore/aicore.h (33 lines)
- include/aicpu/device_malloc.h (53 lines)
- include/host/memory_allocator.h (109 lines)

Per-arch save: ~195 lines deduped (one copy each in common; both
arches' copies were equivalent code modulo doc text).

Comment cleanup carried with the moves:
- aicore.h: "a2a3: Real Ascend hardware" → "onboard: …" and
  "src/a2a3/platform/onboard/aicore/inner_kernel.h" →
  "src/{a2a3,a5}/platform/onboard/aicore/inner_kernel.h"
- device_malloc.h: "On a2a3:" / "On a2a3sim:" → "On onboard:" /
  "On sim:" (function descriptions, not behavior)
- memory_allocator.h: "a2a3: Wraps CANN runtime" / etc. → "onboard:
  Wraps CANN runtime" (4 occurrences)
- Header guards normalized to SRC_COMMON_PLATFORM_INCLUDE_…

Builds:
- a2a3sim + a5sim host_runtime.so clean
- Smoke ST passes on both arches

Stacked on hw-native-sys#937 (which is stacked on hw-native-sys#934).

Co-authored-by: Chao Wang <26245345+ChaoWao@users.noreply.github.com>
ChaoWao added a commit to hw-native-sys-bot/simpler that referenced this pull request May 31, 2026
….cpp (-250 lines)

Move 3 more headers whose per-arch differences were ONLY arch-name
strings in doc comments (same pattern as hw-native-sys#937):

- include/aicore/aicore.h (33 lines)
- include/aicpu/device_malloc.h (53 lines)
- include/host/memory_allocator.h (109 lines)

Per-arch save from header moves: ~195 lines.

Also collapses the 4 per-arch `platform_compile_info.cpp` files
(byte-identical modulo the platform-name string literal) into a
single shared impl at `src/common/platform/src/host/platform_compile_info.cpp`.
The string is supplied via `target_compile_definitions(host_runtime
PRIVATE SIMPLER_PLATFORM_NAME=\"…\")` on each per-arch host CMakeLists,
matching what `get_platform()` returned before.

- 4 files deleted (a2a3/{onboard,sim}/host/, a5/{onboard,sim}/host/)
- 1 file added (src/common/platform/src/host/platform_compile_info.cpp)
- 4 host CMakeLists: source path moved to the common location +
  `SIMPLER_PLATFORM_NAME` define added with the appropriate string
  ("a2a3" / "a2a3sim" / "a5" / "a5sim")

Header comment cleanups (same shape as hw-native-sys#937):
- `aicore.h`: "a2a3: Real Ascend hardware" → "onboard: …" and
  doc reference generalized to `src/{a2a3,a5}/platform/...`
- `device_malloc.h`: "On a2a3:" / "On a2a3sim:" → "On onboard:" / "On sim:"
- `memory_allocator.h`: "a2a3: Wraps CANN runtime" → "onboard: …"
- Header guards normalized to SRC_COMMON_PLATFORM_INCLUDE_…

Builds:
- a2a3sim + a5sim + a2a3 + a5 host_runtime.so clean
- `get_platform()` returns the right string per variant (verified
  via compile_commands.json + ST smoke run)
- Smoke ST passes on both arches

Stacked on hw-native-sys#937 (which is stacked on hw-native-sys#934).

Co-authored-by: Chao Wang <26245345+ChaoWao@users.noreply.github.com>
@ChaoWao ChaoWao merged commit a536a2a into hw-native-sys:main May 31, 2026
16 checks passed
@ChaoWao ChaoWao deleted the platform-shared-headers branch May 31, 2026 07:48
ChaoWao added a commit to hw-native-sys-bot/simpler that referenced this pull request May 31, 2026
Move 6 headers + 1 source whose per-arch differences were ONLY:
- Header guards (SRC_A2A3_… vs SRC_A5_…)
- Comments naming the arch ("a2a3" / "a5" — generalized to the
  shared "onboard" / "sim" axis)
- Two log-string tweaks in tensor_dump_aicpu.cpp

into src/common/platform/include/ + src/common/platform/src/aicpu/.
No code-level semantic changes; the per-arch copies were equivalent
modulo doc strings.

Files moved (canonical copy now in common):
- include/common/memory_barrier.h (63)
- include/aicpu/tensor_dump_aicpu.h (305)
- include/aicpu/device_time.h (28)
- include/aicpu/orch_so_file.h (57)
- include/host/function_cache.h (122)
- include/host/platform_compile_info.h (37)
- src/aicpu/tensor_dump_aicpu.cpp (598)
                    Per-arch saved: 1210
Total dedup'd:                       ~1100

Comment cleanups carried with the move:
- device_time.h: "a2a3: Real Ascend hardware" → "onboard: …"
- orch_so_file.h: "a2a3 (onboard): pid-based naming" → "onboard: …"
- function_cache.h: "a2a3: Real hardware" → "onboard: …"
- platform_compile_info.h: "Each platform (a2a3, a2a3sim, ...)" →
  "Each platform (one of a2a3, a2a3sim, a5, a5sim)"
- Header guards normalized to SRC_COMMON_PLATFORM_INCLUDE_…

Include-path follow-up:
- l2_perf_collector_aicpu.h (still per-arch — DIFF) was doing
  `#include "device_time.h"` (no subdirectory prefix), which only
  worked because device_time.h lived alongside it in the same
  `aicpu/` directory. Now that device_time.h moved up to
  common/platform/include/aicpu/, qualify the include as
  `#include "aicpu/device_time.h"` to match the shared search-path
  shape. Both arches' l2_perf_collector_aicpu.h updated.

Builds:
- a2a3sim + a5sim host_runtime.so clean
- a2a3sim ST L1+L2 pass (38/38, devices 0,1)
- a5sim ST L1+L2 pass (22/22, devices 0,1)

Stacked on hw-native-sys#934 (platform-shared-headers).

Co-authored-by: Chao Wang <26245345+ChaoWao@users.noreply.github.com>
ChaoWao added a commit that referenced this pull request May 31, 2026
Move 6 headers + 1 source whose per-arch differences were ONLY:
- Header guards (SRC_A2A3_… vs SRC_A5_…)
- Comments naming the arch ("a2a3" / "a5" — generalized to the
  shared "onboard" / "sim" axis)
- Two log-string tweaks in tensor_dump_aicpu.cpp

into src/common/platform/include/ + src/common/platform/src/aicpu/.
No code-level semantic changes; the per-arch copies were equivalent
modulo doc strings.

Files moved (canonical copy now in common):
- include/common/memory_barrier.h (63)
- include/aicpu/tensor_dump_aicpu.h (305)
- include/aicpu/device_time.h (28)
- include/aicpu/orch_so_file.h (57)
- include/host/function_cache.h (122)
- include/host/platform_compile_info.h (37)
- src/aicpu/tensor_dump_aicpu.cpp (598)
                    Per-arch saved: 1210
Total dedup'd:                       ~1100

Comment cleanups carried with the move:
- device_time.h: "a2a3: Real Ascend hardware" → "onboard: …"
- orch_so_file.h: "a2a3 (onboard): pid-based naming" → "onboard: …"
- function_cache.h: "a2a3: Real hardware" → "onboard: …"
- platform_compile_info.h: "Each platform (a2a3, a2a3sim, ...)" →
  "Each platform (one of a2a3, a2a3sim, a5, a5sim)"
- Header guards normalized to SRC_COMMON_PLATFORM_INCLUDE_…

Include-path follow-up:
- l2_perf_collector_aicpu.h (still per-arch — DIFF) was doing
  `#include "device_time.h"` (no subdirectory prefix), which only
  worked because device_time.h lived alongside it in the same
  `aicpu/` directory. Now that device_time.h moved up to
  common/platform/include/aicpu/, qualify the include as
  `#include "aicpu/device_time.h"` to match the shared search-path
  shape. Both arches' l2_perf_collector_aicpu.h updated.

Builds:
- a2a3sim + a5sim host_runtime.so clean
- a2a3sim ST L1+L2 pass (38/38, devices 0,1)
- a5sim ST L1+L2 pass (22/22, devices 0,1)

Stacked on #934 (platform-shared-headers).

Co-authored-by: Chao Wang <26245345+ChaoWao@users.noreply.github.com>
ChaoWao added a commit to hw-native-sys-bot/simpler that referenced this pull request May 31, 2026
….cpp (-250 lines)

Move 3 more headers whose per-arch differences were ONLY arch-name
strings in doc comments (same pattern as hw-native-sys#937):

- include/aicore/aicore.h (33 lines)
- include/aicpu/device_malloc.h (53 lines)
- include/host/memory_allocator.h (109 lines)

Per-arch save from header moves: ~195 lines.

Also collapses the 4 per-arch `platform_compile_info.cpp` files
(byte-identical modulo the platform-name string literal) into a
single shared impl at `src/common/platform/src/host/platform_compile_info.cpp`.
The string is supplied via `target_compile_definitions(host_runtime
PRIVATE SIMPLER_PLATFORM_NAME=\"…\")` on each per-arch host CMakeLists,
matching what `get_platform()` returned before.

- 4 files deleted (a2a3/{onboard,sim}/host/, a5/{onboard,sim}/host/)
- 1 file added (src/common/platform/src/host/platform_compile_info.cpp)
- 4 host CMakeLists: source path moved to the common location +
  `SIMPLER_PLATFORM_NAME` define added with the appropriate string
  ("a2a3" / "a2a3sim" / "a5" / "a5sim")

Header comment cleanups (same shape as hw-native-sys#937):
- `aicore.h`: "a2a3: Real Ascend hardware" → "onboard: …" and
  doc reference generalized to `src/{a2a3,a5}/platform/...`
- `device_malloc.h`: "On a2a3:" / "On a2a3sim:" → "On onboard:" / "On sim:"
- `memory_allocator.h`: "a2a3: Wraps CANN runtime" → "onboard: …"
- Header guards normalized to SRC_COMMON_PLATFORM_INCLUDE_…

Builds:
- a2a3sim + a5sim + a2a3 + a5 host_runtime.so clean
- `get_platform()` returns the right string per variant (verified
  via compile_commands.json + ST smoke run)
- Smoke ST passes on both arches

Stacked on hw-native-sys#937 (which is stacked on hw-native-sys#934).

Co-authored-by: Chao Wang <26245345+ChaoWao@users.noreply.github.com>
ChaoWao added a commit that referenced this pull request May 31, 2026
….cpp (-250 lines) (#938)

Move 3 more headers whose per-arch differences were ONLY arch-name
strings in doc comments (same pattern as #937):

- include/aicore/aicore.h (33 lines)
- include/aicpu/device_malloc.h (53 lines)
- include/host/memory_allocator.h (109 lines)

Per-arch save from header moves: ~195 lines.

Also collapses the 4 per-arch `platform_compile_info.cpp` files
(byte-identical modulo the platform-name string literal) into a
single shared impl at `src/common/platform/src/host/platform_compile_info.cpp`.
The string is supplied via `target_compile_definitions(host_runtime
PRIVATE SIMPLER_PLATFORM_NAME=\"…\")` on each per-arch host CMakeLists,
matching what `get_platform()` returned before.

- 4 files deleted (a2a3/{onboard,sim}/host/, a5/{onboard,sim}/host/)
- 1 file added (src/common/platform/src/host/platform_compile_info.cpp)
- 4 host CMakeLists: source path moved to the common location +
  `SIMPLER_PLATFORM_NAME` define added with the appropriate string
  ("a2a3" / "a2a3sim" / "a5" / "a5sim")

Header comment cleanups (same shape as #937):
- `aicore.h`: "a2a3: Real Ascend hardware" → "onboard: …" and
  doc reference generalized to `src/{a2a3,a5}/platform/...`
- `device_malloc.h`: "On a2a3:" / "On a2a3sim:" → "On onboard:" / "On sim:"
- `memory_allocator.h`: "a2a3: Wraps CANN runtime" → "onboard: …"
- Header guards normalized to SRC_COMMON_PLATFORM_INCLUDE_…

Builds:
- a2a3sim + a5sim + a2a3 + a5 host_runtime.so clean
- `get_platform()` returns the right string per variant (verified
  via compile_commands.json + ST smoke run)
- Smoke ST passes on both arches

Stacked on #937 (which is stacked on #934).

Co-authored-by: Chao Wang <26245345+ChaoWao@users.noreply.github.com>
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