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_machine.h

124 lines · 4111 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_MACHINE_H
18#define OMEGA_MACHINE_H
19
20#include "omega_types.h"
21#include "omega_realize.h"
22#include <stdbool.h>
23#include <stddef.h>
24
25#define OMEGA_MACHINE_MAX_UNITS 8
26#define OMEGA_MACHINE_MAX_CACHES 8
27
28typedef enum {
29 UNIT_ALU = 0,
30 UNIT_BRANCH = 1,
31 UNIT_MULTIPLIER = 2,
32 UNIT_DIVIDER = 3,
33 UNIT_LOAD_STORE = 4,
34 UNIT_VECTOR = 5,
35 UNIT_ACCELERATOR_PORT = 6
36} ComputeUnitType;
37
38typedef struct {
39 ComputeUnitType type;
40 uint32_t count;
41 uint32_t latency_cycles;
42 uint32_t throughput_per_cycle;
43} MachineComputeUnit;
44
45typedef struct {
46 uint32_t issue_width;
47 uint32_t max_in_flight;
48 bool out_of_order;
49 size_t unit_count;
50 MachineComputeUnit units[OMEGA_MACHINE_MAX_UNITS];
51} MachinePipeline;
52
53typedef struct {
54 uint32_t gpr_count; /* 31 for AArch64 X0-X30 */
55 uint32_t gpr_width_bits; /* 64-bit */
56 uint32_t vector_count; /* 32 for V0-V31 */
57 uint32_t vector_width_bits; /* 128-bit for NEON / 256+ for SVE */
58} MachineRegisterFile;
59
60typedef struct {
61 uint32_t level; /* 1 = L1, 2 = L2, 3 = L3 */
62 bool is_instruction;
63 uint64_t size_bytes;
64 uint32_t line_size_bytes;
65 uint32_t associativity;
66 uint32_t latency_cycles;
67} MachineCacheLevel;
68
69typedef struct {
70 /* Machine PROFILE digest (one per hardware configuration, the same on every
71 * box of that model). Used inside realization triple ids. Not a machine
72 * identity: that is AienMachineId (src/runtime/aien_machine_id.h). */
73 SemanticId machine_id;
74 char name[64];
75 uint8_t target_profile;
76 MachinePipeline pipeline;
77 MachineRegisterFile registers;
78 size_t cache_count;
79 MachineCacheLevel caches[OMEGA_MACHINE_MAX_CACHES];
80 uint64_t dram_base;
81 uint64_t dram_size;
82 bool is_physics_authorized;
83 uint8_t physics_receipt_seal[32];
84} OmegaMachineGraph;
85
86/* Raw physical machine descriptor packet ingested from Physics */
87typedef struct {
88 uint32_t magic; /* 0x4D414348 = 'MACH' */
89 uint16_t version;
90 uint16_t target_profile;
91 char cpu_name[32];
92 uint32_t issue_width;
93 uint32_t gpr_count;
94 uint32_t vec_count;
95 uint64_t l1d_size;
96 uint64_t l2_size;
97 uint64_t l3_size;
98 uint64_t dram_base;
99 uint64_t dram_size;
100 uint8_t physics_seal[32];
101} PhysicsDescriptor;
102
103/* Initialize empty machine graph */
104void omega_machine_init(OmegaMachineGraph *mg, const char *name, uint8_t target_profile);
105
106/* Compute canonical MACHINE_ID via SHA-256 over canonical hardware encoding */
107int omega_machine_compute_id(OmegaMachineGraph *mg);
108
109/* Construct canonical NVIDIA DGX Spark Grace profile (Neoverse V2, 4-wide dispatch) */
110int omega_machine_build_dgx_spark(OmegaMachineGraph *mg);
111
112/* Construct canonical QEMU virt AArch64 baseline profile (2-wide dispatch) */
113int omega_machine_build_qemu_virt(OmegaMachineGraph *mg);
114
115/* Ingest Physics hardware descriptor and bind Physics authority seal */
116int omega_machine_ingest_physics_descriptor(OmegaMachineGraph *mg, const PhysicsDescriptor *desc);
117
118/* Validate topological consistency (cache ordering, alignment, non-zero capacities) */
119int omega_machine_validate_topology(const OmegaMachineGraph *mg, char *err_msg, size_t err_msg_len);
120
121/* Estimate execution latency in machine cycles for a given realization on target hardware */
122uint32_t omega_machine_estimate_latency(const OmegaMachineGraph *mg, const RealizationObject *real);
123
124#endif /* OMEGA_MACHINE_H */