CUDApp
CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit.
Brought by drakestapleton
| 1 | /* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 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 | * BOOTSTRAP REPRESENTATION - NOT PERMANENT SEMANTIC DEFINITION |
| 19 | * This C header is a temporary bootstrap scaffolding for Milestone 4. |
| 20 | * The canonical definition of OMEGA semantics is independent of host language ABIs. |
| 21 | * ========================================================================= */ |
| 22 | |
| 23 | #ifndef OMEGA_TYPES_H |
| 24 | #define OMEGA_TYPES_H |
| 25 | |
| 26 | #include <stdint.h> |
| 27 | #include <stddef.h> |
| 28 | #include <stdbool.h> |
| 29 | |
| 30 | #define OMEGA_MAGIC 0x30474D4F /* "OMG0" in little-endian / network bytes: 0x4F,0x4D,0x47,0x30 */ |
| 31 | #define OMEGA_VERSION 0x01 /* object encoding version of every kind except KIND_EFFECT */ |
| 32 | #define OMEGA_EFFECT_VERSION 0x02 /* object encoding version of KIND_EFFECT (spec/effect-cap64-migration.md) */ |
| 33 | #define OMEGA_ID_BYTES 32 |
| 34 | #define OMEGA_MAX_ATTRIBUTES 32 |
| 35 | #define OMEGA_MAX_RELATIONS 64 |
| 36 | #define OMEGA_MAX_CONSTRAINTS 32 |
| 37 | #define OMEGA_MAX_KEY_LEN 64 |
| 38 | #define OMEGA_MAX_VAL_LEN 512 |
| 39 | #define OMEGA_MAX_PAYLOAD_LEN 1024 |
| 40 | #define OMEGA_MAX_GRAPH_OBJECTS 256 |
| 41 | |
| 42 | typedef struct { |
| 43 | uint8_t bytes[OMEGA_ID_BYTES]; |
| 44 | } SemanticId; |
| 45 | |
| 46 | typedef enum { |
| 47 | KIND_INVALID = 0x00, |
| 48 | KIND_VALUE = 0x01, |
| 49 | KIND_TYPE = 0x02, |
| 50 | KIND_OPERATION = 0x03, |
| 51 | KIND_RELATION = 0x04, |
| 52 | KIND_CONSTRAINT = 0x05, |
| 53 | KIND_MEMORY = 0x06, |
| 54 | KIND_MACHINE = 0x07, |
| 55 | KIND_EFFECT = 0x08, |
| 56 | KIND_REALIZATION = 0x09, |
| 57 | KIND_EVIDENCE = 0x0A, |
| 58 | KIND_PROOF = 0x0B |
| 59 | } SemanticKind; |
| 60 | |
| 61 | typedef enum { |
| 62 | TYPE_INVALID = 0x00, |
| 63 | TYPE_UNIT = 0x01, |
| 64 | TYPE_BOOL = 0x02, |
| 65 | TYPE_UNSIGNED_INT = 0x03, |
| 66 | TYPE_SIGNED_INT = 0x04, |
| 67 | TYPE_BITVECTOR = 0x05, |
| 68 | TYPE_BYTE = 0x06, |
| 69 | TYPE_SEQUENCE = 0x07, |
| 70 | TYPE_TUPLE = 0x08, |
| 71 | TYPE_ADDRESS = 0x09, |
| 72 | TYPE_RESOURCE = 0x0A, |
| 73 | TYPE_CAPABILITY_REF = 0x0B, |
| 74 | TYPE_EFFECT_INTENT_REF = 0x0C, |
| 75 | TYPE_EFFECT_RECEIPT_REF = 0x0D, |
| 76 | TYPE_FP32 = 0x0E /* IEEE 754 binary32, width 32 (spec/program-fp32.md) */ |
| 77 | } TypeTag; |
| 78 | |
| 79 | typedef enum { |
| 80 | OP_INVALID = 0x00, |
| 81 | OP_IDENTITY = 0x01, |
| 82 | OP_CONSTANT = 0x02, |
| 83 | OP_ADD = 0x03, |
| 84 | OP_SUB = 0x04, |
| 85 | OP_MUL = 0x05, |
| 86 | OP_DIV = 0x06, |
| 87 | OP_EQUAL = 0x07, |
| 88 | OP_LESS_THAN = 0x08, |
| 89 | OP_AND = 0x09, |
| 90 | OP_OR = 0x0A, |
| 91 | OP_NOT = 0x0B, |
| 92 | OP_SELECT = 0x0C, |
| 93 | OP_CONCAT = 0x0D, |
| 94 | OP_SLICE = 0x0E, |
| 95 | OP_COMPILE = 0x0F, |
| 96 | OP_CONVERT = 0x10 /* unary, u32 <-> FP32, declared by the operation's input and output types */ |
| 97 | } OpCode; |
| 98 | |
| 99 | typedef enum { |
| 100 | OVERFLOW_DEFAULT = 0x00, |
| 101 | OVERFLOW_WRAP = 0x01, |
| 102 | OVERFLOW_SATURATE = 0x02, |
| 103 | OVERFLOW_FAIL_CLOSED = 0x03 |
| 104 | } OverflowPolicy; |
| 105 | |
| 106 | typedef enum { |
| 107 | REL_INVALID = 0x00, |
| 108 | REL_EQUAL = 0x01, |
| 109 | REL_NOT_EQUAL = 0x02, |
| 110 | REL_LESS_THAN = 0x03, |
| 111 | REL_CONTAINS = 0x04, |
| 112 | REL_SUBSET_OF = 0x05, |
| 113 | REL_DEPENDS_ON = 0x06, |
| 114 | REL_DERIVED_FROM = 0x07, |
| 115 | REL_SATISFIES = 0x08, |
| 116 | REL_EQUIVALENT_TO = 0x09 |
| 117 | } RelationKind; |
| 118 | |
| 119 | typedef enum { |
| 120 | CONST_INVALID = 0x00, |
| 121 | CONST_EQUALITY = 0x01, |
| 122 | CONST_INEQUALITY = 0x02, |
| 123 | CONST_RANGE = 0x03, |
| 124 | CONST_TYPE = 0x04, |
| 125 | CONST_LENGTH = 0x05, |
| 126 | CONST_CONTAINMENT = 0x06, |
| 127 | CONST_PRECONDITION = 0x07, |
| 128 | CONST_POSTCONDITION = 0x08, |
| 129 | CONST_INVARIANT = 0x09 |
| 130 | } ConstraintKind; |
| 131 | |
| 132 | typedef struct { |
| 133 | char key[OMEGA_MAX_KEY_LEN]; |
| 134 | uint8_t value[OMEGA_MAX_VAL_LEN]; |
| 135 | uint16_t val_len; |
| 136 | } OmegaAttribute; |
| 137 | |
| 138 | typedef struct { |
| 139 | uint16_t kind; /* RelationKind */ |
| 140 | SemanticId target_id; |
| 141 | } OmegaRelation; |
| 142 | |
| 143 | typedef struct { |
| 144 | uint16_t kind; /* ConstraintKind */ |
| 145 | uint16_t payload_len; |
| 146 | uint8_t payload[128]; |
| 147 | } OmegaConstraint; |
| 148 | |
| 149 | /* Kind-specific payloads */ |
| 150 | |
| 151 | typedef struct { |
| 152 | TypeTag tag; |
| 153 | uint16_t width; /* for int/bitvector/address */ |
| 154 | uint32_t length; /* for sequence */ |
| 155 | SemanticId elem_type; /* for sequence/pointer */ |
| 156 | } TypePayload; |
| 157 | |
| 158 | typedef struct { |
| 159 | SemanticId type_id; |
| 160 | uint16_t byte_len; |
| 161 | uint8_t bytes[64]; |
| 162 | } ValuePayload; |
| 163 | |
| 164 | typedef struct { |
| 165 | OpCode opcode; |
| 166 | OverflowPolicy overflow; |
| 167 | SemanticId type_id; |
| 168 | uint8_t arity; |
| 169 | SemanticId input_types[4]; |
| 170 | SemanticId output_type; |
| 171 | } OperationPayload; |
| 172 | |
| 173 | typedef struct { |
| 174 | SemanticId op_id; |
| 175 | uint8_t operand_count; |
| 176 | SemanticId operands[4]; |
| 177 | } ApplyPayload; |
| 178 | |
| 179 | /* In-memory view of an effect. It is NOT the canonical payload: the payload |
| 180 | * bytes of a KIND_EFFECT object are the explicit 178-byte big-endian layout |
| 181 | * written by omega_effect_payload_encode and read (strictly) by |
| 182 | * omega_effect_payload_decode (spec/effect-cap64-migration.md). Never memcpy |
| 183 | * this struct into or out of OmegaObject.payload. */ |
| 184 | #define OMEGA_EFFECT_PARAM_MAX 128 |
| 185 | #define OMEGA_EFFECT_PAYLOAD_LEN 178 /* v2 wire length */ |
| 186 | #define OMEGA_EFFECT_LEGACY_V1_LEN 176 /* old host-struct image with a 32-bit generation */ |
| 187 | typedef struct { |
| 188 | uint16_t resource_class; |
| 189 | uint16_t operation_code; |
| 190 | uint32_t capability_slot; |
| 191 | uint64_t capability_generation; /* full AIENOS generation, all 64 bits */ |
| 192 | SemanticId capability_ref; |
| 193 | uint16_t param_len; |
| 194 | uint8_t param_bytes[OMEGA_EFFECT_PARAM_MAX]; |
| 195 | } EffectPayload; |
| 196 | |
| 197 | typedef struct { |
| 198 | SemanticId id; |
| 199 | bool has_id; |
| 200 | SemanticKind kind; |
| 201 | |
| 202 | uint16_t attr_count; |
| 203 | OmegaAttribute attributes[OMEGA_MAX_ATTRIBUTES]; |
| 204 | |
| 205 | uint16_t rel_count; |
| 206 | OmegaRelation relations[OMEGA_MAX_RELATIONS]; |
| 207 | |
| 208 | uint16_t const_count; |
| 209 | OmegaConstraint constraints[OMEGA_MAX_CONSTRAINTS]; |
| 210 | |
| 211 | uint32_t payload_len; |
| 212 | uint8_t payload[OMEGA_MAX_PAYLOAD_LEN]; |
| 213 | } OmegaObject; |
| 214 | |
| 215 | typedef struct { |
| 216 | uint16_t object_count; |
| 217 | OmegaObject objects[OMEGA_MAX_GRAPH_OBJECTS]; |
| 218 | } OmegaGraph; |
| 219 | |
| 220 | #endif /* OMEGA_TYPES_H */ |