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 / bridge / shlib / ampqmd.om

58 lines · 2497 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2note bridge/shlib/ampqmd.om: CUDApp's src/omega_ampere_qmd.c (84b524ca, default build) in Omega: the two C entry
3note points omega_ampere_policy and omega_ampere_build_qmd over the Ampere QMD unit. Composed after
4note gpu/nvidia/om/encoder/amp_runtime.om and amp_qmd.om into one object and built by bridge/shlib/shlib.om from
5note ampqmd.tsv: both are frame exports under the lock row's pthread mutex, because the C pointers are copied
6note through the states (memcpy) and the states are one per process.
7note States (ampqmd.tsv, frame words 8..10): AqM the 16-word request, AqQ the 256 QMD bytes, AqLock the mutex;
8note frame word 11 is the address of the caller's stack arguments (omega_ampere_build_qmd's registers and
9note shared_bytes, AAPCS64 arguments 9 and 10).
10note Results as the C: 0 when amp_qmd accepts, -1 when it refuses or a pointer the C checks is NULL; the QMD is
11note written to q only on acceptance. A trap answers -1 (the TRAP value), as the C does when its bridge call
12note fails.
13extern fn memcpy d ulong s ulong n ulong to ulong
14note amp_qmd op over the request in m; on acceptance the 256 bytes are copied to the C pointer q when it is not
15note NULL; 0 or -1
16fn aq_run fr view ulong 12 op ulong m edit ulong 16 q edit uchar 256 to int
17if ne amp_qmd op m q 1
18ret -1
19end
20d = get fr 1
21if eq op 1
22d = get fr 0
23end
24if ne d 0
25z = memcpy d get fr 9 256
26end
27ret 0
28end
29note int omega_ampere_policy(const uint64_t m[16], uint32_t q[64]): x0 m, x1 q (NULL: the C's scratch)
30export fn omega_ampere_policy fr view ulong 12 m edit ulong 16 q edit uchar 256 to int
31if eq get fr 0 0
32ret -1
33end
34z = memcpy get fr 8 get fr 0 128
35ret aq_run fr 0 m q
36end
37note int omega_ampere_build_qmd(uint32_t q[64], uint64_t code, uint64_t cbank, uint64_t semaphore, uint32_t tx,
38note uint32_t ty, uint32_t gx, uint32_t gy, uint32_t registers, uint32_t shared_bytes): x0 q, x1..x3 the 64-bit
39note words, x4..x7 tx ty gx gy (their low 32 bits), the caller's stack words 0 and 1 registers and shared_bytes
40note (their low 32 bits); a[9..15] zero, as the C's initializer
41export fn omega_ampere_build_qmd fr view ulong 12 m edit ulong 16 q edit uchar 256 to int
42if eq get fr 0 0
43ret -1
44end
45for i ulong 16
46put m i 0
47end
48z = memcpy add get fr 8 56 get fr 11 16
49put m 7 and get m 7 4294967295
50put m 8 and get m 8 4294967295
51for i ulong 3
52put m i get fr add i 1
53end
54for i ulong 4
55put m add i 3 and get fr add i 4 4294967295
56end
57ret aq_run fr 1 m q
58end