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

35 lines · 1764 bytes Raw Blame History
1/* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */
2#ifndef OMEGA_BW_BIND_H
3#define OMEGA_BW_BIND_H
4/* Spec bytes, the realization binding message, the machine descriptor, matmul dispatch, vector launch geometry,
5 * program padding and the code-digest admission are first-party Omega (om/codegen/cg_bind.om, generated
6 * src/cudapp_om_cg_bind.c, export omega_cg_bind). The C shells own memory, the structs and the SHA-256 calls. The C
7 * kept under CUDAPP_MIGRATION_PENDING_C_BIND (default OFF in both builds; freestanding calls the native
8 * omega2_cg_bind and omega2_bw_id_native below) is the differential oracle of tests/regalloc_om/run.sh. */
9#if defined(OMEGA_GPU_NO_POSIX) || defined(CUDAPP_MIGRATION_PENDING_C_BIND)
10#define BW_BIND_C_PRIMARY 1
11#else
12#include <stdint.h>
13#include "cudapp_native.h"
14/* cg_bind kind a b over the 256-byte wire w; a trap or nonzero status refuses (-1). */
15static inline int64_t omega_bw_bind(uint64_t kind, uint64_t a, uint64_t b, uint8_t w[256]) {
16 uint64_t r = UINT64_MAX;
17 if (omega_cg_bind(&r, kind, a, b, w, 256) != 0) return -1;
18 return (int64_t)r;
19}
20#endif
21/* ham/cubin-qmd-om: checked caller-stack QMD/realization root, no hosted trap runtime. */
22#if defined(OMEGA_GPU_NO_POSIX) && !defined(CUDAPP_MIGRATION_PENDING_C_BIND)
23#undef BW_BIND_C_PRIMARY
24#include "omega_native.h"
25static inline int64_t omega_bw_bind(uint64_t kind, uint64_t a, uint64_t b, uint8_t w[256]) {
26 uint64_t r = UINT64_MAX;
27 if (omega2_cg_bind(&r, kind, a, b, w, 256) != 0) return -1;
28 return (int64_t)r;
29}
30static inline int omega_bw_id(const uint8_t data[256], uint64_t n, uint8_t out[32]) {
31 uint64_t r = UINT64_MAX;
32 return omega2_bw_id_native(&r, data, 256, n, out, 32) == 0 && r == 0 ? 0 : -1;
33}
34#endif
35#endif