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