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

88 lines · 2476 bytes Raw Blame History
1/* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */
2/* Dispatch into om/engine/eng.om. Every hosted build links src/cudapp_om_eng.c,
3 * generated by om/units.sh, and that unit answers; the reference is strong, so a
4 * hosted link without the binding fails instead of silently keeping C.
5 *
6 * Each shell keeps its C oracle behind its own default-OFF switch
7 * CUDAPP_MIGRATION_PENDING_C_<PART>. The shell defines ENG_C_PART before this
8 * include when its switch is set, and eng_on() is then 0 for that file. The
9 * freestanding build (OMEGA_GPU_NO_POSIX) has no binding and keeps C.
10 * Syscalls, MMIO, doorbells, pushbuffer stores and hook calls stay in the shell. */
11#ifndef OMEGA_ENG_DEC_H
12#define OMEGA_ENG_DEC_H
13
14#include <stdint.h>
15#include <string.h>
16
17#define ENG_OP_WINIT 0u
18#define ENG_OP_WPOLL 1u
19#define ENG_OP_JOBV 2u
20#define ENG_OP_PHASE 3u
21#define ENG_OP_RESV 4u
22#define ENG_OP_CACHE 5u
23#define ENG_OP_SERVE 6u
24#define ENG_OP_POIS 7u
25#define ENG_OP_WAITED 8u
26#define ENG_OP_CLEAN 9u
27#define ENG_OP_SEQGE 10u
28#define ENG_OP_LIFE 11u
29#define ENG_OP_REQF 12u
30#define ENG_OP_VIS 13u
31#define ENG_OP_BWE 14u
32#define ENG_OP_TOMS 15u
33#define ENG_OP_FCLS 16u
34#define ENG_OP_WENTER 17u
35#define ENG_OP_SCAN 18u
36#define ENG_OP_ROLE 19u
37#define ENG_OP_M16REL 20u
38#define ENG_OP_NEGO 21u
39#define ENG_OP_PCHK 22u
40#define ENG_OP_BUFCK 23u
41#define ENG_OP_HOPEN 24u
42#define ENG_OP_HCHK 25u
43#define ENG_OP_SUBM 26u
44#define ENG_OP_CONC 27u
45#define ENG_OP_COUNT 28u
46
47#if defined(OMEGA_GPU_NO_POSIX)
48
49static inline int eng_on(void) { return 0; }
50
51static inline int eng_ask(uint64_t op, const uint64_t *in, int nin, uint64_t w[16]) {
52 (void)op;
53 (void)in;
54 (void)nin;
55 memset(w, 0, 16u * sizeof w[0]);
56 return 1;
57}
58
59#else
60
61uint32_t omega_eng(uint64_t *result, const void *p0, uint64_t p0_n, void *p1, uint64_t p1_n);
62
63static inline int eng_on(void) {
64#if defined(ENG_C_PART)
65 return 0;
66#else
67 return 1;
68#endif
69}
70
71/* 0 when the unit answered and its int result is 0. Nonzero is a binding
72 * failure; the caller must not invent a decision. */
73static inline int eng_ask(uint64_t op, const uint64_t *in, int nin, uint64_t w[16]) {
74 uint64_t m[24];
75 uint64_t result = 1;
76 uint32_t st;
77 int i;
78 memset(m, 0, sizeof m);
79 memset(w, 0, 16u * sizeof w[0]);
80 m[0] = op;
81 for (i = 0; i < nin && i < 23; i++) m[1 + i] = in[i];
82 st = omega_eng(&result, m, 24, w, 16);
83 if (st != 0 || result != 0) return 1;
84 return 0;
85}
86
87#endif
88#endif