interplane.Get Omega
Read in your language

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

branch main Branches Tags History

CUDApp / tests / om_bw_realize_oracle.c

60 lines · 2600 bytes Raw Blame History
1#if defined(CUDAPP_MIGRATION_PENDING_BW_MATMUL) && CUDAPP_MIGRATION_PENDING_BW_MATMUL
2/* Frozen b774723 independent verification oracle; never production linked. */
3#define omega_blackwell_get_machine_id oracle_omega_blackwell_get_machine_id
4#define omega_blackwell_realization_compute_id oracle_omega_blackwell_realization_compute_id
5#define omega_blackwell_realize_vector oracle_omega_blackwell_realize_vector
6/* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */
7#include "omega_blackwell_realize.h"
8#include "sha256.h"
9#include <string.h>
10
11int omega_blackwell_get_machine_id(SemanticId *out_machine_id) {
12 if (!out_machine_id) return -1;
13 sha256_ctx ctx;
14 sha256_init(&ctx);
15 const char *machine_str = "NVIDIA_DGX_SPARK_GB10_SM121";
16 sha256_update(&ctx, (const uint8_t *)machine_str, strlen(machine_str));
17 sha256_final(&ctx, out_machine_id->bytes);
18 return 0;
19}
20
21int omega_blackwell_realization_compute_id(OmegaBlackwellRealization *real) {
22 if (!real) return -1;
23 sha256_ctx ctx;
24 sha256_init(&ctx);
25 sha256_update(&ctx, real->spec_id.bytes, OMEGA_ID_BYTES);
26 sha256_update(&ctx, real->machine_id.bytes, OMEGA_ID_BYTES);
27 sha256_update(&ctx, real->code_digest, sizeof(real->code_digest));
28 sha256_update(&ctx, (const uint8_t *)&real->sm_architecture, sizeof(real->sm_architecture));
29 sha256_final(&ctx, real->realization_digest);
30
31 memcpy(real->realization_id.bytes, real->realization_digest, OMEGA_ID_BYTES);
32 return 0;
33}
34
35int omega_blackwell_realize_vector(const OmegaVectorSpec *spec, OmegaBlackwellRealization *out_real) {
36 if (!spec || !out_real) return -1;
37 memset(out_real, 0, sizeof(*out_real));
38
39 out_real->spec_id = spec->spec_id;
40 if (omega_blackwell_get_machine_id(&out_real->machine_id) != 0) return -1;
41
42 out_real->sm_architecture = OMEGA_BW_SM_ARCH_121;
43 out_real->code_len = OMEGA_BW_VECADD_CODE_SIZE;
44
45 /* Verify and digest generated Blackwell machine code */
46 uint8_t code_buf[OMEGA_BW_VECADD_CODE_SIZE];
47 size_t encoded_len = 0;
48 if (omega_blackwell_encode_vecadd(code_buf, sizeof(code_buf), &encoded_len) != 0) return -1;
49 if (omega_blackwell_compute_code_digest(code_buf, encoded_len, out_real->code_digest) != 0) return -1;
50
51 /* Default launch geometry */
52 out_real->qmd_cfg.num_elements = spec->element_count;
53 out_real->qmd_cfg.threads_per_block = 64;
54 out_real->qmd_cfg.grid_width = (spec->element_count + 63) / 64;
55 if (out_real->qmd_cfg.grid_width == 0) out_real->qmd_cfg.grid_width = 1;
56
57 return omega_blackwell_realization_compute_id(out_real);
58}
59
60#endif