==> include/mesh/abi/host_pload.h <==1/* @ajax/mesh-abi-host-pload: Program load records (PL_*): GPU share, latency, throughput and CPU cost per slot.
2 *
3 * Part of alpha-c-mesh, a C port of alpha-rust-mesh (README.md says from where). */
4#ifndef MESH_ABI_HOST_PLOAD_H
5#define MESH_ABI_HOST_PLOAD_H
6
7#include <stdbool.h>
8#include <stddef.h>
9#include <stdint.h>
10#include "mesh/abi/fields.h"
11
12/* Per program slot s at pload(s), PLOAD_BYTES (zero for an empty slot). */
13#define MESH_S_PLOAD 0x1800
14#define MESH_PLOAD_BYTES 0x80
15#define MESH_PL_FLAGS 0x00 /* u32 PLF_* */
16#define MESH_PL_LAT_N 0x04 /* u32 trace records behind the latency figures */
17#define MESH_PL_SHARE 0x08 /* f32 (1 s) the GPU share its idle nodes saw (PLF_GPU) */
18#define MESH_PL_SHARE10 0x0c /* f32 (10 s) */
19#define MESH_PL_SLICE_US 0x10 /* f32 (10 s) */
20#define MESH_PL_GAP_US 0x14 /* f32 (10 s) */
21#define MESH_PL_MAX_GAP_US 0x18 /* f32 (1 s) */
22#define MESH_PL_OBS 0x1c /* f32 (1 s) node-seconds observed per second */
23/* f32 task time quantiles and maximum, us, from the trace (end - start of
24 * each record; the last LOAD_WINDOW samples' records, at most TRACE_PER_PROG a sample). */
25#define MESH_PL_P50_US 0x20
26#define MESH_PL_P90_US 0x24
27#define MESH_PL_P99_US 0x28
28#define MESH_PL_MAX_US 0x2c
29/* f32 (10 s) mean node busy time per task, us (N_BUSY_NS / N_TASKS deltas):
30 * a placed program's time per part (`split auto` weighs parts with it). */
31#define MESH_PL_TASK_US 0x30
32#define MESH_PL_TASKS_S 0x34 /* f32 (10 s) tasks completed per second */
33#define MESH_PL_BUSY 0x38 /* f32 (1 s) node occupancy: busy ns / (nodes x wall) */
34#define MESH_PL_QUEUE_US 0x3c /* f32 (10 s) Metal: mean commit -> GPU start */
35/* PL_HOST..PLOAD_BYTES: the CPU executors' cost (wasm lanes: each lane
36 * thread's own CPU time, CLOCK_THREAD_CPUTIME_ID, and its linear memory;
37 * native workers: their processes' CPU time and RSS). PLF_HOST says they
38 * are measured; zero for a GPU slot. */
39#define MESH_PL_HOST 0x40
40#define MESH_PL_CPU_NS 0x40 /* u64 CPU ns since the image's load */
41#define MESH_PL_RSS 0x48 /* u64 resident bytes now (wasm: linear memory; native: the processes' RSS, a retained image's included) */
42#define MESH_PL_CPU 0x50 /* f32 (1 s) CPU seconds per second (1.0: one core busy) */
43#define MESH_PL_CPU10 0x54 /* f32 (10 s) */
44#define MESH_PL_CPU_TASK_US 0x58 /* f32 (10 s) CPU us per completed task (0: no tasks) */
45#define MESH_PL_UNITS 0x5c /* u32 lanes running (wasm) / live worker processes (native) */
46/* 0x60..0x80: free. */
47#define MESH_PLF_LOADED 1u
48#define MESH_PLF_GPU 2u /* the share fields were observed */
49#define MESH_PLF_LAT 4u /* the latency fields have records */
50#define MESH_PLF_TASK 8u /* PL_TASK_US has tasks */
51#define MESH_PLF_HOST 0x10u /* PL_HOST's fields are measured (a wasm or native slot) */
52#define MESH_PLOAD_FIELDS_LEN 22
53extern const mesh_field MESH_PLOAD_FIELDS[22];
54
55/* Slot s's program load record. */
56static inline size_t mesh_pload(uint32_t s) { return MESH_S_PLOAD + MESH_PLOAD_BYTES * (size_t)s; }
57
58/* The Rust const asserts that only involve this package. */
59_Static_assert(MESH_PL_QUEUE_US + 4 <= MESH_PL_HOST, "PL_QUEUE_US + 4 <= PL_HOST");
60_Static_assert(MESH_PL_CPU_NS == MESH_PL_HOST, "PL_CPU_NS == PL_HOST");
61_Static_assert((MESH_PL_CPU_NS % 8 == 0), "PL_CPU_NS.is_multiple_of(8)");
62_Static_assert((MESH_PL_RSS % 8 == 0), "PL_RSS.is_multiple_of(8)");
63_Static_assert(0x1800 <= MESH_S_PLOAD, "0x1800 <= S_PLOAD");
64_Static_assert((MESH_S_PLOAD % 8 == 0), "S_PLOAD.is_multiple_of(8)");
65
66#endif