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