From cd94a34122a7b45bd0c578646c513f9e2f0f3665 Mon Sep 17 00:00:00 2001 From: jgrusewski Date: Thu, 21 May 2026 01:04:50 +0200 Subject: [PATCH] =?UTF-8?q?feat(gpu-log):=20add=20gpu=5Flog=5Fids.h=20?= =?UTF-8?q?=E2=80=94=20single=20source=20of=20truth=20for=20ring=20IDs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/ml-alpha/cuda/gpu_log_ids.h | 39 ++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 crates/ml-alpha/cuda/gpu_log_ids.h diff --git a/crates/ml-alpha/cuda/gpu_log_ids.h b/crates/ml-alpha/cuda/gpu_log_ids.h new file mode 100644 index 000000000..0bb4d09c5 --- /dev/null +++ b/crates/ml-alpha/cuda/gpu_log_ids.h @@ -0,0 +1,39 @@ +// gpu_log_ids.h — single source of truth for log-ring kernel/record IDs. +// +// Both kernel-side (#include from .cu files) and Rust-side decoder reference +// these symbols. Drift between them is checked by `build.rs` (Task 2). +// +// kernel_id (uint8) — which kernel emitted the record. +// record_type (uint8) — sub-type within the kernel (input/state/output/debug). +// payload layout — defined per (kernel_id, record_type) in decoder. + +#ifndef GPU_LOG_IDS_H +#define GPU_LOG_IDS_H + +#define GPU_LOG_N_KERNELS 8 +#define GPU_LOG_N_RT_PER_KERNEL 4 +#define GPU_LOG_N_RECORDS_PER_STEP (GPU_LOG_N_KERNELS * GPU_LOG_N_RT_PER_KERNEL) +#define GPU_LOG_N_SLOTS 32768 +#define GPU_LOG_RECORD_BYTES 64 +#define GPU_LOG_PAYLOAD_F32 12 +#define GPU_LOG_MAGIC 0xF0F0A710u + +// Kernel IDs (uint8). Add new kernels at the bottom; never reorder. +#define KID_SMOOTHNESS_CONTROLLER 0 +#define KID_OUTPUT_SMOOTHNESS 1 +#define KID_BCE_MULTI_HORIZON 2 +#define KID_HORIZON_LAMBDA 3 +#define KID_HEADS_GRN_FWD 4 +#define KID_HEADS_GRN_BWD 5 +#define KID_CFC_STEP 6 +#define KID_RESERVED_7 7 + +// Record types within a kernel (uint8). Reuse RT_INPUT/STATE/OUTPUT/DEBUG +// across kernels — payload layout differs per (kid, rt) pair but the four +// roles are conventional. +#define RT_INPUT 0 +#define RT_STATE 1 +#define RT_OUTPUT 2 +#define RT_DEBUG 3 + +#endif // GPU_LOG_IDS_H