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 / checks / apish-lib.om

124 lines · 2900 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note gpu/nvidia/checks/apish-lib.om: the shared part of the apish checks, the Omega ports of CUDApp
3note tests/api_shells_diff.c. A check is its units, lib.om, lib-om2.om, its port (text t_name, fn aprun) and then
4note this part. The port gives every answer the old test compared to a label: as3 (the test's eq_u32: the low 32
5note bits), asi (eq_i: the low 32 bits as a signed int) or as6 (eq_u64). Each label keeps the count of its answers
6note and their digest in order (FNV-1a over whole words). Rows:
7note LABEL COUNT DIGEST
8note The first row runs the port; then a row passes when its label has that count and that digest, which the table
9note holds for the pending C's answers. The row "total" holds the count of all answers and, as DIGEST, the number of
10note labels, so an answer or a label the table does not have fails too. A label is known by a hash of its text;
11note the labels are kept in run-time pools that grow with their number (exit 2 only if the host refuses memory).
12text t_total "total"
13global ap_hk ulong *
14global ap_hc ulong *
15global ap_hd ulong *
16note ap_hs: 0 the port has run, 1 labels, 2 answers, 3 the place found last
17global ap_hs ulong 4
18fn cname to void
19for i ulong len t_name bound 64
20ckoc ulong get t_name i
21end
22end
23fn ap_ht t view uchar * to ulong
24h = ulong 14695981039346656037
25for i ulong len t bound 64
26h = mul xor h ulong get t i 1099511628211
27end
28if eq h 0
29h = 1
30end
31ret h
32end
33note the place of key k, or the number of labels when it is new
34fn ap_find k ulong to ulong
35n = get ap_hs 1
36c = get ap_hs 3
37if lt c n
38if eq get ap_hk c k
39ret c
40end
41end
42for s ulong n bound 9223372036854775807
43if eq get ap_hk s k
44put ap_hs 3 s
45ret s
46end
47end
48ret n
49end
50note room for one more label
51fn ap_grow n ulong to void
52if lt n len ap_hk
53ret
54end
55g = add mul n 2 64
56r = enlarge ap_hk g
57if lt r 0
58exit 2
59end
60r = enlarge ap_hc g
61if lt r 0
62exit 2
63end
64r = enlarge ap_hd g
65if lt r 0
66exit 2
67end
68end
69fn as6 t view uchar * v ulong to void
70k = ap_ht t
71s = ap_find k
72if eq s get ap_hs 1
73ap_grow s
74put ap_hk s k
75put ap_hc s 0
76put ap_hd s 14695981039346656037
77put ap_hs 1 add s 1
78end
79put ap_hc s add get ap_hc s 1
80put ap_hd s mul xor get ap_hd s v 1099511628211
81put ap_hs 2 add get ap_hs 2 1
82end
83fn as3 t view uchar * v ulong to void
84as6 t and v 0xffffffff
85end
86fn asi t view uchar * v ulong to void
87w = and v 0xffffffff
88if ne and w 0x80000000 0
89w = or w 0xffffffff00000000
90end
91as6 t w
92end
93fn crow to bool
94if ne ckcnt 3
95ckbad
96end
97if ne ckhexn 2 8
98ckbad
99end
100if eq get ap_hs 0 0
101put ap_hs 0 1
102aprun
103end
104cnt = cknum 1
105w = ulong 0
106for k ulong 8
107w = or shl w 8 ckhex 2 k
108end
109if ckis 0 t_total
110ret and eq cnt get ap_hs 2 eq w get ap_hs 1
111end
112h = ulong 14695981039346656037
113for j ulong cklen 0 bound 64
114h = mul xor h ckch 0 j 1099511628211
115end
116if eq h 0
117h = 1
118end
119s = ap_find h
120if eq s get ap_hs 1
121ret false
122end
123ret and eq get ap_hc s cnt eq get ap_hd s w
124end