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 / src / omega_blackwell_submit.h

96 lines · 4505 bytes Raw Blame History
1/* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */
2#ifndef OMEGA_BLACKWELL_SUBMIT_H
3#define OMEGA_BLACKWELL_SUBMIT_H
4
5#include "omega_types.h"
6#include "omega_vector.h"
7#include "omega_blackwell_realize.h"
8#include "omega_blackwell_matmul.h"
9#include <stdbool.h>
10#include <stddef.h>
11#include <stdint.h>
12
13#define OMEGA_BW_MARKER_COMPLETION_PAYLOAD 0x44444444U
14#define OMEGA_BW_MARKER2_PAYLOAD 0x46464646u /* C3 second release, after the L2 flush */
15/* Shader-cache invalidate, emitted as the first compute method of every launch that
16 * uploads kernel code (cut 1b finding: the SM instruction cache is not coherent with
17 * host writes; after a kernel-cache slot was evicted and its code address reused, the
18 * chip ran stale instructions). Method and bits from NVIDIA open-gpu-doc
19 * classes/compute/clcec0.h (BLACKWELL_COMPUTE_B): NVCEC0_INVALIDATE_SHADER_CACHES 0x021c,
20 * _INSTRUCTION 0:0, _DATA 4:4, _CONSTANT 12:12. The shipped driver tree's clcec0.h is a
21 * 30-line class-id stub and does not list the method; chip-proven by receipt
22 * FB1-CUT1B-4345406 (18/18 parity after the fix). Emit: nvrm_mthd(1, MTHD, 1), ALL. */
23#define OMEGA_BW_MTHD_INVALIDATE_SHADER_CACHES 0x021cu
24#define OMEGA_BW_INVALIDATE_SHADER_CACHES_ALL ((1u << 0) | (1u << 4) | (1u << 12))
25#define OMEGA_BW_SEMAPHORE_INTERMEDIATE_INIT 5U
26#define OMEGA_BW_SEMAPHORE_INTERMEDIATE_DONE 6U
27
28typedef struct {
29 char target_chip[64];
30 uint32_t sm_architecture;
31 uint32_t element_count;
32 uint64_t launch_timestamp_ns;
33 uint64_t completion_timestamp_ns;
34 uint64_t elapsed_ns;
35 uint32_t completion_marker;
36 uint32_t intermediate_semaphore;
37 bool parity_verified;
38 bool zero_libcuda_linkage;
39 bool zero_cuda_symbols;
40 bool zero_libcuda_runtime;
41} OmegaBlackwellVectorExecution;
42
43typedef struct {
44 char target_chip[64];
45 uint32_t sm_architecture;
46 uint32_t m, k, n;
47 uint64_t launch_timestamp_ns;
48 uint64_t completion_timestamp_ns;
49 uint64_t elapsed_ns;
50 uint32_t completion_marker;
51 uint32_t intermediate_semaphore;
52 bool parity_verified;
53 size_t mismatch_count;
54 bool zero_libcuda_linkage;
55 bool zero_cuda_symbols;
56 bool zero_libcuda_runtime;
57} OmegaBlackwellMatMulExecution;
58
59/* Execute vector addition on physical GB10 silicon. Since cut A3b1 (DRAFT, chip-unproven) the
60 * device sequence runs through omega_gpu_execute with the Blackwell backend in
61 * src/omega_blackwell_engine.c; this wrapper keeps the host oracle and the result fields. */
62int omega_blackwell_execute_vector(const OmegaVectorSpec *spec,
63 const OmegaBlackwellRealization *real,
64 const uint32_t *h_a,
65 const uint32_t *h_b,
66 uint32_t *h_c_out,
67 OmegaBlackwellVectorExecution *exec_info);
68
69/* Execute dynamic matrix multiplication on physical GB10 silicon through frozen M16 native submission */
70/* Execute dynamic tensor matrix multiplication on physical GB10 silicon through frozen M16 native submission */
71int omega_blackwell_execute_matmul_tensor(const OmegaMatMulSpec *spec,
72 const OmegaBlackwellKernel *kernel,
73 const void *h_a,
74 const void *h_b,
75 float *h_c_out,
76 OmegaBlackwellMatMulExecution *exec_info,
77 float *out_max_abs_err,
78 float *out_max_rel_err);
79
80int omega_blackwell_execute_matmul(const OmegaMatMulSpec *spec,
81 const OmegaBlackwellKernel *kernel,
82 const uint32_t *h_a,
83 const uint32_t *h_b,
84 uint32_t *h_c_out,
85 OmegaBlackwellMatMulExecution *exec_info);
86
87/* Validate that omegatool binary has zero dynamic linkage to libcuda.so or libcudart.so */
88int omega_blackwell_verify_zero_libcuda_linkage(const char *binary_path);
89
90/* Validate that omegatool binary has zero undefined symbols starting with cu or cuda */
91int omega_blackwell_verify_zero_cuda_symbols(const char *binary_path);
92
93/* Validate that current running process has zero mapped regions of libcuda */
94int omega_blackwell_verify_zero_libcuda_runtime(void);
95
96#endif /* OMEGA_BLACKWELL_SUBMIT_H */