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 / gpu / nvidia / native / streams / submit.om

41 lines · 1695 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2note C4 streams (CUDApp#115): the effectful GPFIFO submit of nvrm_enqueue / nvrm_chan_submit / nvrm_ring.
3note fifo and bell are owned mapping handles of the client's native context (nvrm/native_client.h), never
4note raw addresses. Every mapset is one aligned store bracketed by DSB SY (AArch64) / MFENCE (x86-64)
5note (omega-mv seed/host/MAPPING.md), the barrier nvrm_cpu_barrier issues in C (nvrm/cpu_barrier.h).
6note GP entry (nvrm_gp_entry): (va & ~3) | nwords << 42 | 1 << 41, nwords 1..0x1fffff.
7om2
8export fn streams_gp_entry va ulong nwords ulong to ulong
9ret or or sub va and va 3 shl nwords 42 shl ulong 1 41
10end
11note Write GP entry `pos rem entries`, then USERD GPPut = ((pos + 1) mod 2^32) rem entries at byte gpput of fifo
12note (pos is the uint32 nvrm put counter; the increment wraps as in C).
13note Value 0, minus errno from the mapping, or -22 for a refused argument (no store issued).
14export fn streams_gp_publish fifo long entries ulong pos ulong gpput ulong va ulong nwords ulong to long
15if lt entries 2
16ret neg long 22
17end
18if or eq nwords 0 gt nwords 2097151
19ret neg long 22
20end
21if or ne and gpput 3 0 gt gpput 65532
22ret neg long 22
23end
24slot = rem pos entries
25r = mapset fifo mul slot 8 8 streams_gp_entry va nwords
26if ne r 0
27ret r
28end
29cpufence
30ret mapset fifo gpput 4 rem and add pos 1 4294967295 entries
31end
32note Doorbell: NVC361_NOTIFY_CHANNEL_PENDING (byte off of the usermode page) <- the channel's work submit token.
33export fn streams_ring bell long off ulong token ulong to long
34if or ne and off 3 0 gt off 65532
35ret neg long 22
36end
37if gt token 4294967295
38ret neg long 22
39end
40ret mapset bell off 4 token
41end