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

68 lines · 2772 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#include "omega_blackwell_realize.h"
18#include "sha256.h"
19#include <string.h>
20
21int omega_blackwell_get_machine_id(SemanticId *out_machine_id) {
22 if (!out_machine_id) return -1;
23 sha256_ctx ctx;
24 sha256_init(&ctx);
25 const char *machine_str = "NVIDIA_DGX_SPARK_GB10_SM121";
26 sha256_update(&ctx, (const uint8_t *)machine_str, strlen(machine_str));
27 sha256_final(&ctx, out_machine_id->bytes);
28 return 0;
29}
30
31int omega_blackwell_realization_compute_id(OmegaBlackwellRealization *real) {
32 if (!real) return -1;
33 sha256_ctx ctx;
34 sha256_init(&ctx);
35 sha256_update(&ctx, real->spec_id.bytes, OMEGA_ID_BYTES);
36 sha256_update(&ctx, real->machine_id.bytes, OMEGA_ID_BYTES);
37 sha256_update(&ctx, real->code_digest, sizeof(real->code_digest));
38 sha256_update(&ctx, (const uint8_t *)&real->sm_architecture, sizeof(real->sm_architecture));
39 sha256_final(&ctx, real->realization_digest);
40
41 memcpy(real->realization_id.bytes, real->realization_digest, OMEGA_ID_BYTES);
42 return 0;
43}
44
45int omega_blackwell_realize_vector(const OmegaVectorSpec *spec, OmegaBlackwellRealization *out_real) {
46 if (!spec || !out_real) return -1;
47 memset(out_real, 0, sizeof(*out_real));
48
49 out_real->spec_id = spec->spec_id;
50 if (omega_blackwell_get_machine_id(&out_real->machine_id) != 0) return -1;
51
52 out_real->sm_architecture = OMEGA_BW_SM_ARCH_121;
53 out_real->code_len = OMEGA_BW_VECADD_CODE_SIZE;
54
55 /* Verify and digest generated Blackwell machine code */
56 uint8_t code_buf[OMEGA_BW_VECADD_CODE_SIZE];
57 size_t encoded_len = 0;
58 if (omega_blackwell_encode_vecadd(code_buf, sizeof(code_buf), &encoded_len) != 0) return -1;
59 if (omega_blackwell_compute_code_digest(code_buf, encoded_len, out_real->code_digest) != 0) return -1;
60
61 /* Default launch geometry */
62 out_real->qmd_cfg.num_elements = spec->element_count;
63 out_real->qmd_cfg.threads_per_block = 64;
64 out_real->qmd_cfg.grid_width = (spec->element_count + 63) / 64;
65 if (out_real->qmd_cfg.grid_width == 0) out_real->qmd_cfg.grid_width = 1;
66
67 return omega_blackwell_realization_compute_id(out_real);
68}