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 / seed / ng / target / target_desc.om
| 1 | note SPDX-License-Identifier: Apache-2.0 |
| 2 | note seed/ng/target/target_desc.om: Unified 24-field TargetDesc registry (CPU + GPU + NPU + APU + Spark Ring), |
| 3 | note compile-time physical contract checker, target-parameterized tile planner, and proof-gated Realization Cache. |
| 4 | |
| 5 | const TD_FIELDS ulong 24 |
| 6 | const TD_MAX_TARGETS ulong 16 |
| 7 | |
| 8 | note Field indices into tdTable[tid * 24 + field]: |
| 9 | const TDF_ISA ulong 0 |
| 10 | const TDF_EXEC ulong 1 |
| 11 | const TDF_ENDIAN ulong 2 |
| 12 | const TDF_PTRBITS ulong 3 |
| 13 | const TDF_NGPR ulong 4 |
| 14 | const TDF_NVEC ulong 5 |
| 15 | const TDF_NPRED ulong 6 |
| 16 | const TDF_VECBITS ulong 7 |
| 17 | const TDF_SCALABLE ulong 8 |
| 18 | const TDF_TWOADDR ulong 9 |
| 19 | const TDF_SUBGROUP ulong 10 |
| 20 | const TDF_L1D_KB ulong 11 |
| 21 | const TDF_L2_KB ulong 12 |
| 22 | const TDF_LINE ulong 13 |
| 23 | const TDF_SMEM ulong 14 |
| 24 | const TDF_OOO ulong 15 |
| 25 | const TDF_MULLAT ulong 16 |
| 26 | const TDF_DIVLAT ulong 17 |
| 27 | const TDF_BRCOST ulong 18 |
| 28 | const TDF_FEAT ulong 19 |
| 29 | const TDF_MMA ulong 20 |
| 30 | const TDF_MEMDOM ulong 21 |
| 31 | const TDF_COHNS ulong 22 |
| 32 | const TDF_CSAVE ulong 23 |
| 33 | |
| 34 | note ISA IDs: |
| 35 | const ISA_A64 ulong 1 |
| 36 | const ISA_X64 ulong 2 |
| 37 | const ISA_RV64 ulong 3 |
| 38 | const ISA_THUMB2 ulong 4 |
| 39 | const ISA_SM121 ulong 16 |
| 40 | const ISA_ETHOSU ulong 17 |
| 41 | |
| 42 | note Execution models: |
| 43 | const EXEC_SCALAR_SIMD ulong 0 |
| 44 | const EXEC_SIMT_WARP ulong 1 |
| 45 | const EXEC_SYSTOLIC ulong 2 |
| 46 | |
| 47 | note Feature bitmasks: |
| 48 | const FEAT_FMA ulong 1 |
| 49 | const FEAT_DOTPROD ulong 2 |
| 50 | const FEAT_I8MM ulong 4 |
| 51 | const FEAT_BF16 ulong 8 |
| 52 | const FEAT_AVX2 ulong 16 |
| 53 | const FEAT_AVX512 ulong 32 |
| 54 | const FEAT_RVV ulong 64 |
| 55 | const FEAT_SHA ulong 128 |
| 56 | const FEAT_AES ulong 256 |
| 57 | const FEAT_BMI2 ulong 512 |
| 58 | const FEAT_FP8 ulong 1024 |
| 59 | const FEAT_HMMA16816 ulong 2048 |
| 60 | |
| 61 | note MMA shape bitmasks: |
| 62 | const MMA_16816_BF16 ulong 1 |
| 63 | const MMA_16832_FP8 ulong 2 |
| 64 | const MMA_888_I8MM ulong 4 |
| 65 | const MMA_161616_AMX ulong 8 |
| 66 | |
| 67 | note Built-in silicon profile IDs: |
| 68 | const TID_X925 ulong 0 |
| 69 | const TID_A725 ulong 1 |
| 70 | const TID_X64_AVX2 ulong 2 |
| 71 | const TID_X64_AVX512 ulong 3 |
| 72 | const TID_RV64_RVV ulong 4 |
| 73 | const TID_CM55 ulong 5 |
| 74 | const TID_SM121 ulong 6 |
| 75 | const TID_ETHOSU55 ulong 7 |
| 76 | const TID_APU_GB10 ulong 8 |
| 77 | const TID_SPARK_RING ulong 9 |
| 78 | |
| 79 | note Physical contract refusal codes: |
| 80 | const TDK_OK ulong 0 |
| 81 | const TDK_ERR_EXEC ulong 1 |
| 82 | const TDK_ERR_SMEM ulong 2 |
| 83 | const TDK_ERR_REGS ulong 3 |
| 84 | const TDK_ERR_SUBGROUP ulong 4 |
| 85 | const TDK_ERR_MMA ulong 5 |
| 86 | const TDK_ERR_FEAT ulong 6 |
| 87 | |
| 88 | global tdTable ulong 384 |
| 89 | global tdCount ulong 1 |
| 90 | global tdTileOut ulong 8 |
| 91 | |
| 92 | note Realization cache (64 entries): key(sem, tid, feat, shape) -> codePtr + proofMask + version |
| 93 | const RC_CAP ulong 64 |
| 94 | global rcUsed ulong 64 |
| 95 | global rcSem ulong 64 |
| 96 | global rcTid ulong 64 |
| 97 | global rcFeat ulong 64 |
| 98 | global rcShape ulong 64 |
| 99 | global rcPtr ulong 64 |
| 100 | global rcProof ulong 64 |
| 101 | global rcVer ulong 64 |
| 102 | |
| 103 | fn tdSet tid ulong f ulong v ulong to void |
| 104 | put tdTable add mul tid TD_FIELDS f v |
| 105 | end |
| 106 | |
| 107 | fn tdGet tid ulong f ulong to ulong |
| 108 | ret get tdTable add mul tid TD_FIELDS f |
| 109 | end |
| 110 | |
| 111 | fn tdRegIsa tid ulong isa ulong execM ulong ptrB ulong ngpr ulong nvec ulong to void |
| 112 | tdSet tid TDF_ISA isa |
| 113 | tdSet tid TDF_EXEC execM |
| 114 | tdSet tid TDF_ENDIAN 0 |
| 115 | tdSet tid TDF_PTRBITS ptrB |
| 116 | tdSet tid TDF_NGPR ngpr |
| 117 | tdSet tid TDF_NVEC nvec |
| 118 | end |
| 119 | |
| 120 | fn tdRegVec tid ulong npred ulong vbits ulong scal ulong twoA ulong subg ulong to void |
| 121 | tdSet tid TDF_NPRED npred |
| 122 | tdSet tid TDF_VECBITS vbits |
| 123 | tdSet tid TDF_SCALABLE scal |
| 124 | tdSet tid TDF_TWOADDR twoA |
| 125 | tdSet tid TDF_SUBGROUP subg |
| 126 | end |
| 127 | |
| 128 | global tdReq ulong 8 |
| 129 | |
| 130 | fn tdRegCache tid ulong l1 ulong l2 ulong line ulong smem ulong to void |
| 131 | tdSet tid TDF_L1D_KB l1 |
| 132 | tdSet tid TDF_L2_KB l2 |
| 133 | tdSet tid TDF_LINE line |
| 134 | tdSet tid TDF_SMEM smem |
| 135 | end |
| 136 | |
| 137 | fn tdRegLat tid ulong ooo ulong mlat ulong dlat ulong brc ulong to void |
| 138 | tdSet tid TDF_OOO ooo |
| 139 | tdSet tid TDF_MULLAT mlat |
| 140 | tdSet tid TDF_DIVLAT dlat |
| 141 | tdSet tid TDF_BRCOST brc |
| 142 | end |
| 143 | |
| 144 | fn tdRegFeat tid ulong feat ulong mma ulong mdom ulong coh ulong csave ulong to void |
| 145 | tdSet tid TDF_FEAT feat |
| 146 | tdSet tid TDF_MMA mma |
| 147 | tdSet tid TDF_MEMDOM mdom |
| 148 | tdSet tid TDF_COHNS coh |
| 149 | tdSet tid TDF_CSAVE csave |
| 150 | end |
| 151 | |
| 152 | fn tdInitAll to void |
| 153 | put tdCount 0 10 |
| 154 | note 0: Cortex-X925 (DGX Spark big core: 10-wide OOO, NEON/SVE/i8mm/BF16/SHA/AES) |
| 155 | tdRegIsa TID_X925 ISA_A64 EXEC_SCALAR_SIMD 64 30 32 |
| 156 | tdRegVec TID_X925 16 128 1 0 4 |
| 157 | tdRegCache TID_X925 64 2048 64 0 |
| 158 | tdRegLat TID_X925 10 2 8 11 |
| 159 | tdRegFeat TID_X925 399 MMA_888_I8MM 1 0 262143 |
| 160 | |
| 161 | note 1: Cortex-A725 (DGX Spark efficiency core: 5-wide OOO, background metabolic lane) |
| 162 | tdRegIsa TID_A725 ISA_A64 EXEC_SCALAR_SIMD 64 30 32 |
| 163 | tdRegVec TID_A725 16 128 1 0 4 |
| 164 | tdRegCache TID_A725 64 512 64 0 |
| 165 | tdRegLat TID_A725 5 3 12 13 |
| 166 | tdRegFeat TID_A725 399 MMA_888_I8MM 1 0 262143 |
| 167 | |
| 168 | note 2: x86-64 AVX2 + BMI2 + FMA (2-addr, 15 allocatable GPRs) |
| 169 | tdRegIsa TID_X64_AVX2 ISA_X64 EXEC_SCALAR_SIMD 64 15 16 |
| 170 | tdRegVec TID_X64_AVX2 0 256 0 1 8 |
| 171 | tdRegCache TID_X64_AVX2 32 512 64 0 |
| 172 | tdRegLat TID_X64_AVX2 6 3 14 14 |
| 173 | tdRegFeat TID_X64_AVX2 913 0 0 0 1983 |
| 174 | |
| 175 | note 3: x86-64 AVX-512 + AMX (2-addr, 15 GPRs, 32 ZMMs, 8 k-preds) |
| 176 | tdRegIsa TID_X64_AVX512 ISA_X64 EXEC_SCALAR_SIMD 64 15 32 |
| 177 | tdRegVec TID_X64_AVX512 8 512 0 1 16 |
| 178 | tdRegCache TID_X64_AVX512 48 2048 64 0 |
| 179 | tdRegLat TID_X64_AVX512 6 3 14 14 |
| 180 | tdRegFeat TID_X64_AVX512 953 MMA_161616_AMX 0 0 1983 |
| 181 | |
| 182 | note 4: RV64GC + RVV 1.0 (3-addr, 30 allocatable GPRs, scalable VLA) |
| 183 | tdRegIsa TID_RV64_RVV ISA_RV64 EXEC_SCALAR_SIMD 64 30 32 |
| 184 | tdRegVec TID_RV64_RVV 0 256 1 0 8 |
| 185 | tdRegCache TID_RV64_RVV 32 512 64 0 |
| 186 | tdRegLat TID_RV64_RVV 4 3 20 12 |
| 187 | tdRegFeat TID_RV64_RVV 65 0 0 0 1073741823 |
| 188 | |
| 189 | note 5: Cortex-M55 MCU (Thumb-2 32-bit, 12 allocatable GPRs, MVE/Helium) |
| 190 | tdRegIsa TID_CM55 ISA_THUMB2 EXEC_SCALAR_SIMD 32 12 8 |
| 191 | tdRegVec TID_CM55 1 128 0 0 4 |
| 192 | tdRegCache TID_CM55 32 0 32 65536 |
| 193 | tdRegLat TID_CM55 2 2 12 6 |
| 194 | tdRegFeat TID_CM55 3 0 0 0 15 |
| 195 | |
| 196 | note 6: NVIDIA GB10 SM121 Blackwell GPU (SIMT 32-lane warp, 101376 B SMEM, HMMA 16816 + FP8) |
| 197 | tdRegIsa TID_SM121 ISA_SM121 EXEC_SIMT_WARP 64 64 64 |
| 198 | tdRegVec TID_SM121 7 1024 0 0 32 |
| 199 | tdRegCache TID_SM121 128 65536 128 101376 |
| 200 | tdRegLat TID_SM121 4 4 24 20 |
| 201 | tdRegFeat TID_SM121 3081 3 1 80 0 |
| 202 | |
| 203 | note 7: Arm Ethos-U55 NPU (systolic command stream, 64 KiB scratchpad) |
| 204 | tdRegIsa TID_ETHOSU55 ISA_ETHOSU EXEC_SYSTOLIC 32 8 8 |
| 205 | tdRegVec TID_ETHOSU55 0 256 0 0 16 |
| 206 | tdRegCache TID_ETHOSU55 0 0 64 65536 |
| 207 | tdRegLat TID_ETHOSU55 1 1 0 0 |
| 208 | tdRegFeat TID_ETHOSU55 2 0 2 400 0 |
| 209 | |
| 210 | note 8: apu-gb10 coherent superchip view (X925 + A725 + SM121 over NVLink-C2C AMBA CHI) |
| 211 | tdRegIsa TID_APU_GB10 ISA_SM121 EXEC_SIMT_WARP 64 64 64 |
| 212 | tdRegVec TID_APU_GB10 7 1024 0 0 32 |
| 213 | tdRegCache TID_APU_GB10 128 65536 128 101376 |
| 214 | tdRegLat TID_APU_GB10 10 4 24 20 |
| 215 | tdRegFeat TID_APU_GB10 3087 7 1 80 0 |
| 216 | |
| 217 | note 9: Multi-Spark 2-node ring view (2x GB10 over direct NIC ring, 4500 ns sync) |
| 218 | tdRegIsa TID_SPARK_RING ISA_SM121 EXEC_SIMT_WARP 64 64 64 |
| 219 | tdRegVec TID_SPARK_RING 7 1024 0 0 32 |
| 220 | tdRegCache TID_SPARK_RING 128 131072 128 101376 |
| 221 | tdRegLat TID_SPARK_RING 10 4 24 20 |
| 222 | tdRegFeat TID_SPARK_RING 3087 7 3 4500 0 |
| 223 | end |
| 224 | |
| 225 | fn tdSetReq reqExec ulong reqSmem ulong reqRegs ulong reqSubg ulong reqMma ulong reqFeat ulong to void |
| 226 | put tdReq 0 reqExec |
| 227 | put tdReq 1 reqSmem |
| 228 | put tdReq 2 reqRegs |
| 229 | put tdReq 3 reqSubg |
| 230 | put tdReq 4 reqMma |
| 231 | put tdReq 5 reqFeat |
| 232 | end |
| 233 | |
| 234 | note Compile-time Physical Contract Checker: verifies kernel requirements against TargetDesc before emit! |
| 235 | fn tdCheckKernelContract tid ulong to ulong |
| 236 | if ne get tdReq 0 tdGet tid TDF_EXEC |
| 237 | ret TDK_ERR_EXEC |
| 238 | end |
| 239 | if gt get tdReq 1 tdGet tid TDF_SMEM |
| 240 | ret TDK_ERR_SMEM |
| 241 | end |
| 242 | if gt get tdReq 2 tdGet tid TDF_NGPR |
| 243 | ret TDK_ERR_REGS |
| 244 | end |
| 245 | rs = get tdReq 3 |
| 246 | if and ne rs 0 ne rs tdGet tid TDF_SUBGROUP |
| 247 | ret TDK_ERR_SUBGROUP |
| 248 | end |
| 249 | rm = get tdReq 4 |
| 250 | if ne and rm tdGet tid TDF_MMA rm |
| 251 | ret TDK_ERR_MMA |
| 252 | end |
| 253 | rf = get tdReq 5 |
| 254 | if ne and rf tdGet tid TDF_FEAT rf |
| 255 | ret TDK_ERR_FEAT |
| 256 | end |
| 257 | ret TDK_OK |
| 258 | end |
| 259 | |
| 260 | note Target-Parameterized Tile/Blocking Planner: derives (MC, KC, NC, VEC_ELEMS) from TargetDesc! |
| 261 | fn tdDeriveTilePlan tid ulong elemBytes ulong to void |
| 262 | vbits = tdGet tid TDF_VECBITS |
| 263 | ve = div vbits mul elemBytes 8 |
| 264 | if eq ve 0 |
| 265 | ve = ulong 1 |
| 266 | end |
| 267 | ex = tdGet tid TDF_EXEC |
| 268 | if eq ex EXEC_SIMT_WARP |
| 269 | sm = tdGet tid TDF_SMEM |
| 270 | mc = ulong 16 |
| 271 | nc = ulong 64 |
| 272 | kc = ulong 64 |
| 273 | if ge sm 65536 |
| 274 | mc = ulong 64 |
| 275 | nc = ulong 128 |
| 276 | kc = ulong 64 |
| 277 | end |
| 278 | put tdTileOut 0 mc |
| 279 | put tdTileOut 1 kc |
| 280 | put tdTileOut 2 nc |
| 281 | put tdTileOut 3 ve |
| 282 | ret |
| 283 | end |
| 284 | l1b = mul tdGet tid TDF_L1D_KB 1024 |
| 285 | l2b = mul tdGet tid TDF_L2_KB 1024 |
| 286 | kc = div l1b mul mul ve elemBytes 4 |
| 287 | if lt kc 32 |
| 288 | kc = ulong 32 |
| 289 | end |
| 290 | if gt kc 512 |
| 291 | kc = ulong 512 |
| 292 | end |
| 293 | mc = mul ve 4 |
| 294 | nc = div l2b mul mul kc elemBytes 2 |
| 295 | if lt nc 64 |
| 296 | nc = ulong 64 |
| 297 | end |
| 298 | if gt nc 1024 |
| 299 | nc = ulong 1024 |
| 300 | end |
| 301 | put tdTileOut 0 mc |
| 302 | put tdTileOut 1 kc |
| 303 | put tdTileOut 2 nc |
| 304 | put tdTileOut 3 ve |
| 305 | end |
| 306 | |
| 307 | note Proof-Gated Realization Cache (mirrors GPU QDI_WTBL + CPU indirect dispatch table) |
| 308 | fn tdCacheInit to void |
| 309 | for i ulong RC_CAP |
| 310 | put rcUsed i 0 |
| 311 | put rcVer i 0 |
| 312 | end |
| 313 | end |
| 314 | |
| 315 | fn tdCacheLookup semId ulong tid ulong feat ulong shapeSig ulong to ulong |
| 316 | for i ulong RC_CAP |
| 317 | if eq get rcUsed i 1 |
| 318 | if and eq get rcSem i semId eq get rcTid i tid |
| 319 | if and eq get rcFeat i feat eq get rcShape i shapeSig |
| 320 | ret i |
| 321 | end |
| 322 | end |
| 323 | end |
| 324 | end |
| 325 | ret 999999 |
| 326 | end |
| 327 | |
| 328 | note Proof mask required for admission: bit0=ngcheck, bit1=ngrun/kemu, bit2=antibodies (mask == 7) |
| 329 | fn tdCacheInstall semId ulong tid ulong feat ulong shapeSig ulong codePtr ulong proofMask ulong to ulong |
| 330 | if ne and proofMask 7 7 |
| 331 | ret 999999 |
| 332 | end |
| 333 | ex = tdCacheLookup semId tid feat shapeSig |
| 334 | if ne ex 999999 |
| 335 | put rcPtr ex codePtr |
| 336 | put rcProof ex proofMask |
| 337 | put rcVer ex add get rcVer ex 1 |
| 338 | ret ex |
| 339 | end |
| 340 | for i ulong RC_CAP |
| 341 | if eq get rcUsed i 0 |
| 342 | put rcUsed i 1 |
| 343 | put rcSem i semId |
| 344 | put rcTid i tid |
| 345 | put rcFeat i feat |
| 346 | put rcShape i shapeSig |
| 347 | put rcPtr i codePtr |
| 348 | put rcProof i proofMask |
| 349 | put rcVer i 1 |
| 350 | ret i |
| 351 | end |
| 352 | end |
| 353 | ret 999999 |
| 354 | end |