Skip to content

Comments

Refactor: unify register access into generic read_reg/write_reg interface#93

Open
ChaoWao wants to merge 1 commit intomainfrom
dispatch-task-by-reg
Open

Refactor: unify register access into generic read_reg/write_reg interface#93
ChaoWao wants to merge 1 commit intomainfrom
dispatch-task-by-reg

Conversation

@ChaoWao
Copy link
Owner

@ChaoWao ChaoWao commented Feb 14, 2026

Replace purpose-specific register functions (read_task_id_by_reg, set_aicore_busy/idle, enable/disable_aicore_register, write_task_id_to_aicore, read_aicore_status) with a generic read_reg/write_reg API parameterized by RegId enum.

Platform layer:

  • Add RegId enum (DATA_MAIN_BASE, COND, FAST_PATH_ENABLE) and reg_offset() mapping in platform_config.h
  • Add SIM_REG_BLOCK_SIZE constant for simulation register memory sizing
  • Rewrite a2a3 aicpu_regs.cpp to use read_reg/write_reg with MMIO pointers
  • Add a2a3sim aicpu_regs.cpp with identical interface over host memory
  • Rewrite a2a3 inner_kernel.h: replace inline asm helpers with read_reg/write_reg dispatching on RegId via switch
  • Add a2a3sim inner_kernel.h register simulation: thread-local g_sim_reg_base, read_reg/write_reg over simulated memory, pipe_barrier macro
  • Update aicpu_regs.h header to declare unified read_reg/write_reg interface

Simulation runner:

  • Allocate per-core simulated register blocks in DeviceRunner::run()
  • Pass physical_core_id through aicore_execute_wrapper to set up thread-local g_sim_reg_base before kernel execution
  • Update function pointer signatures to include physical_core_id

Runtime layer:

  • Add physical_core_id field to Handshake struct (aicpu_build_graph, tensormap_and_ringbuffer)
  • Update aicore_executor.cpp to use write_reg/read_reg instead of set_aicore_idle/busy/read_task_id_by_reg
  • Update aicpu_executor.cpp: replace all register helper calls with read_reg/write_reg, add pre-set COND=BUSY before task dispatch to prevent false completion detection from stale IDLE state

…face

Replace purpose-specific register functions (read_task_id_by_reg,
set_aicore_busy/idle, enable/disable_aicore_register, write_task_id_to_aicore,
read_aicore_status) with a generic read_reg/write_reg API parameterized by
RegId enum.

Platform layer:
- Add RegId enum (DATA_MAIN_BASE, COND, FAST_PATH_ENABLE) and reg_offset()
  mapping in platform_config.h
- Add SIM_REG_BLOCK_SIZE constant for simulation register memory sizing
- Rewrite a2a3 aicpu_regs.cpp to use read_reg/write_reg with MMIO pointers
- Add a2a3sim aicpu_regs.cpp with identical interface over host memory
- Rewrite a2a3 inner_kernel.h: replace inline asm helpers with read_reg/write_reg
  dispatching on RegId via switch
- Add a2a3sim inner_kernel.h register simulation: thread-local g_sim_reg_base,
  read_reg/write_reg over simulated memory, pipe_barrier macro
- Update aicpu_regs.h header to declare unified read_reg/write_reg interface

Simulation runner:
- Allocate per-core simulated register blocks in DeviceRunner::run()
- Pass physical_core_id through aicore_execute_wrapper to set up
  thread-local g_sim_reg_base before kernel execution
- Update function pointer signatures to include physical_core_id

Runtime layer:
- Add physical_core_id field to Handshake struct (aicpu_build_graph,
  tensormap_and_ringbuffer)
- Update aicore_executor.cpp to use write_reg/read_reg instead of
  set_aicore_idle/busy/read_task_id_by_reg
- Update aicpu_executor.cpp: replace all register helper calls with
  read_reg/write_reg, add pre-set COND=BUSY before task dispatch to
  prevent false completion detection from stale IDLE state
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.

1 participant