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_codegen_tc2.c

58 lines · 2152 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/* omega_blackwell_codegen_tc2.c: tensor-core grouped FP8 GEMM v2 (OWN-30B T3b).
18 * Implementation lives in pure OM-2 (om/gpu/cg_tc2.om); this file is the thin fail-closed C ABI wrapper. */
19#include "omega_blackwell_codegen_tc2.h"
20#include "omega_bw_om_ir.h"
21#include "omega_native.h"
22#include <string.h>
23
24static void tc2_pack_spec(const OmegaTc2Spec *s, uint64_t sp[10]) {
25 sp[0] = s->k;
26 sp[1] = s->rt;
27 sp[2] = s->ct;
28 sp[3] = s->warps;
29 sp[4] = s->aqn;
30 sp[5] = s->epi;
31 sp[6] = s->direct;
32 sp[7] = s->n;
33 sp[8] = (uint64_t)(int64_t)s->mutant;
34 sp[9] = 0;
35}
36
37int omega_tc2_spec_ok(const OmegaTc2Spec *s) {
38 if (!s) return 0;
39 uint64_t sp[10], ok = 0;
40 tc2_pack_spec(s, sp);
41 if (omega2_cg_tc2_spec_ok(&ok, sp, 10u) != 0) return 0;
42 return ok != 0 ? 1 : 0;
43}
44
45uint32_t omega_tc2_shared_bytes(const OmegaTc2Spec *s) { return omega_tc2_spec_ok(s) ? 2u * 16u * s->rt * 128u : 0u; }
46uint32_t omega_tc2_span(const OmegaTc2Spec *s) { return omega_tc2_spec_ok(s) ? s->warps * 8u * s->ct : 0u; }
47
48int omega_blackwell_codegen_tc2_prog(const OmegaTc2Spec *spec, BlackwellIRProgram *prog) {
49 if (!prog) return -1;
50 omega_bw_ir_init(prog);
51 if (!spec) return -1;
52 uint64_t sp[10], ins[8192], meta[512], rc = 1;
53 memset(ins, 0, sizeof ins);
54 memset(meta, 0, sizeof meta);
55 tc2_pack_spec(spec, sp);
56 if (omega2_cg_tc2_emit(&rc, sp, 10u, ins, 8192u, meta, 512u) != 0 || rc != 0) return -1;
57 return omega_bw_ir_from_om(ins, meta, prog);
58}