omega-mv
Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.
Brought by drakestapleton
omega-mv / src / omega_unwritten_trap.h
| 1 | /* SPDX-License-Identifier: Apache-2.0 |
| 2 | * Copyright 2026 Drake Stapleton (AIEN / aien-dev) |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | /* |
| 18 | * C3 unwritten-output trap: host-only detector (no GPU, no libm). |
| 19 | * |
| 20 | * The caller pre-fills an output buffer with a poison word that the op under |
| 21 | * test cannot emit, runs the work, and calls omega_unwritten_scan. A word that |
| 22 | * still equals the poison was never stored (or its store was not visible). |
| 23 | * Whole-block means every aligned group of `block` words that contains a hit is |
| 24 | * entirely poison (the last group may be short), which is the signature of whole |
| 25 | * missing 64-thread CTAs rather than scattered lost stores. |
| 26 | */ |
| 27 | #ifndef OMEGA_UNWRITTEN_TRAP_H |
| 28 | #define OMEGA_UNWRITTEN_TRAP_H |
| 29 | |
| 30 | #include <stddef.h> |
| 31 | #include <stdint.h> |
| 32 | |
| 33 | #define OMEGA_UNWRITTEN_BLOCK 64u |
| 34 | |
| 35 | typedef struct { |
| 36 | uint64_t count; /* words equal to the poison */ |
| 37 | uint64_t first, last; /* index of first and last hit (valid if count>0) */ |
| 38 | uint64_t runs; /* maximal contiguous runs of hits */ |
| 39 | uint64_t longest_run; /* length of the longest run */ |
| 40 | uint64_t full_blocks; /* aligned blocks that are entirely poison */ |
| 41 | uint64_t partial_blocks; /* aligned blocks with some but not all poison */ |
| 42 | int whole_blocks; /* count>0 and partial_blocks==0 */ |
| 43 | int tail; /* count>0 and hits are exactly [first, n) */ |
| 44 | } OmegaUnwrittenReport; |
| 45 | |
| 46 | /* Scans out[0..n). block must be > 0 (use OMEGA_UNWRITTEN_BLOCK for CTAs). */ |
| 47 | void omega_unwritten_scan(const uint32_t *out, size_t n, uint32_t poison, uint32_t block, |
| 48 | OmegaUnwrittenReport *r); |
| 49 | |
| 50 | #endif |