interplane.Get Omega
Read in your language

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

branch main Branches Tags History

omega-mv / src / omega_blackwell_qmd.h

86 lines · 3816 bytes Raw Blame History
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#ifndef OMEGA_BLACKWELL_QMD_H
18#define OMEGA_BLACKWELL_QMD_H
19
20#include <stdbool.h>
21#include <stddef.h>
22#include <stdint.h>
23
24#define OMEGA_BW_QMD_WORDS 96
25#define OMEGA_BW_QMD_BYTES (OMEGA_BW_QMD_WORDS * 4) /* 384 bytes */
26#define OMEGA_BW_CBANK_DRIVER_WORDS 224
27#define OMEGA_BW_CBANK_ARGS_WORDS 7
28#define OMEGA_BW_CBANK_MATMUL_ARGS_WORDS 10
29
30/* Epistemic classifications for QMD fields */
31typedef enum {
32 EPISTEMIC_DOCUMENTED = 1, /* NVIDIA open-gpu-kernel-modules / clcdc0qmd.h */
33 EPISTEMIC_OBSERVED = 2, /* Empirically verified on physical GB10 silicon */
34 EPISTEMIC_REVERSE_ENGINEERED = 3 /* Derived from Blackwell instruction trace */
35} OmegaEpistemicTier;
36
37typedef struct {
38 uint64_t code_va;
39 uint64_t cbank_va;
40 uint64_t scratch_va;
41 uint64_t sem_va;
42 uint64_t qmd0_va;
43 uint64_t qmd1_va;
44 uint32_t num_elements;
45 uint32_t threads_per_block;
46 uint32_t grid_width;
47 uint32_t threads_x;
48 uint32_t threads_y;
49 uint32_t grid_x;
50 uint32_t grid_y;
51 uint32_t gpr_count;
52 /* Shared memory per CTA in bytes (clcec0qmd.h SHARED_MEMORY_SIZE_SHIFTED7, 128-byte units).
53 * 0 keeps the long-standing 1024. Packed by om/gpu/bw_qmd.om: word 36 sets MIN_ and
54 * TARGET_SM_CONFIG_SHARED_MEM_SIZE dynamically from shared_bytes (9 for <= 32 KiB, 17 for
55 * <= 64 KiB, 26 for <= 96 KiB; MAX stays 26 = 100 KB), leaving 4 KiB below GB10's 100 KiB carveout. */
56 uint32_t shared_bytes;
57} OmegaBlackwellQmdConfig;
58#define OMEGA_BW_QMD_MAX_SHARED_BYTES 98304u
59
60/* Build QMD 0: GRID_NULL null-barrier grid with dependence counter 2 */
61int omega_blackwell_build_qmd0(uint32_t *qmd0_words, uint64_t qmd0_va, uint64_t qmd1_va);
62
63/* Build QMD 1: GRID_CTA compute grid for Blackwell sm_121 vector add and matmul */
64int omega_blackwell_build_qmd1(uint32_t *qmd1_words, const OmegaBlackwellQmdConfig *cfg);
65
66/* Build driver constant bank 0 (224 words) with hardware descriptor addresses */
67extern const uint32_t omega_bw_cbank_driver_template[OMEGA_BW_CBANK_DRIVER_WORDS];
68int omega_blackwell_build_cbank_driver(uint32_t *cbank_words, uint64_t cbank_va);
69
70/* Build driver constant bank 0 (224 words) with 2D tile geometry */
71int omega_blackwell_build_cbank_driver_2d(uint32_t *cbank_words, uint64_t cbank_va,
72 uint32_t threads_x, uint32_t threads_y,
73 uint32_t grid_x, uint32_t grid_y);
74
75/* Build kernel argument constant bank buffer (7 words: pointers A, B, C, length N) */
76int omega_blackwell_build_cbank_args(uint32_t *args_words, uint64_t a_va, uint64_t b_va,
77 uint64_t c_va, uint32_t n);
78
79/* Build matrix multiplication kernel argument constant bank buffer (10 words) */
80int omega_blackwell_build_cbank_args_matmul(uint32_t *args_words, uint64_t a_va, uint64_t b_va,
81 uint64_t c_va, uint32_t m, uint32_t k, uint32_t n);
82
83/* Verify QMD structural invariants (SKEDCHECK05, version, alignment, etc.) */
84int omega_blackwell_verify_qmd_invariants(const uint32_t *qmd1_words);
85
86#endif /* OMEGA_BLACKWELL_QMD_H */