Skip to main content

Module c_model

Module c_model 

Source
Expand description

The executable device model as C: what the host binary links and calls when it runs on a machine that has no accelerator.

The model is generated from the same objects the device artifact is: each region’s control-flow graph and the lane routines its cells are, at the device’s lane shape. Every lane routine becomes a C function over uint32_t words masked to the lane width (one statement per lane operation, a for per Repeat), and every region becomes a C function that walks its blocks with goto, calls a routine per cell, and returns 0 with the divergence code the moment a cell hands the call back. logos_dev_call is the driver the host’s dispatch calls; it counts what every region did and, at exit, appends one line of accounting to the file LOGOS_ACCEL_STATS names. LOGOS_ACCEL_OFFLOAD=off makes it hand every call back. Neither ever writes to the program’s standard output or standard error.

Functions§

model_c
The model translation unit for regions (each with its host-side region number) on a device whose lanes are shape: every routine the regions use, every region, and the logos_dev_call driver with its accounting. device names the device in the accounting line.
region_c
C for a region at shape: static int <symbol>(const int64_t *args, int64_t *out, uint32_t *fault), returning 1 with *out set, or 0 with *fault the divergence code.
routine_c
C for one lane routine: static void <symbol>(const uint32_t *in, uint32_t *out). Its register file is a local that starts at zero on every call, as the lane interpreter’s does, so a call depends on nothing but its inputs and the model is reentrant.
routine_symbol
The C symbol of op’s routine at shape.