Skip to content

[programming-model] Define hosted multi-PE startup and runtime ABI #150

Description

@jiale-wangOwO

Request

Define the hosted multi-PE programming model and runtime ABI required to run a normal hosted musl ELF across four PEs.

The current toolchain emits a normal hosted process entry:

_start -> _start_c -> __libc_start_main -> main -> exit

The specification does not currently define how this entry is used when four PEs execute the same ELF.

Observed failure

In SuperScalarModel#346, the res_on=on hosted multi_thread/matmul ELF is run with four PEs. Cooperative TMATMUL completes, then the hosted close/exit path reports:

ecall warning: close function failed! errno: 9 Bad file descriptor
gfrun: illegal instruction: ASSERTION FAILED:
currentBlock->barg.target != 0 && "Block BARG target"

The compiler review is recorded at SuperScalarModel#346 comment.

Required specification decisions

Define a normative contract for:

Process launch

  • Whether all PEs enter the same ELF entry;
  • PE0 hosted entry and PE1..PE3 worker entry, if applicable;
  • Worker activation and startup ordering;
  • Startup completion synchronization.

Per-PE state

  • Stack base, size, stride, alignment, guard, and lifetime;
  • TLS and libc state ownership;
  • PE identity and leader identity exposure.

Syscalls and file descriptors

  • Guest-to-host fd mapping;
  • Whether fd state is process-shared or PE-local;
  • Which PE may perform open/read/write/close;
  • exit and exit_group ownership and semantics;
  • Behavior when one PE exits or faults.

Synchronization and completion

  • Startup, input-ready, kernel-completion, and exit barriers;
  • Leader/worker participation around cooperative Tile operations;
  • Core-wide completion and error propagation.

Toolchain and ELF contract

  • Startup objects and linker mode;
  • Worker entry symbols;
  • ELF note/ABI identity;
  • Compiler/runtime APIs for leader detection, worker activation, and barriers;
  • A minimal four-PE hosted reference sample.

Acceptance criteria

  • The normative document or ADR defines the complete launch, stack, libc/TLS, fd, synchronization, exit, and ELF ABI contract.
  • The contract assigns implementation requirements to compiler/linker, musl/runtime, gfrun/QEMU, and benchmark runtime.
  • A runtime-only reference sample covers startup, stack isolation, fd lifecycle, barriers, and exit.
  • A four-PE hosted matmul precision-validation sample is defined with an independent golden result.
  • The compiler, runtime, functional models, and benchmark can implement the same contract without private assumptions.

References:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions