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/CUDApp/blob/main/tests/session_memory_test.om # CUDApp CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `CUDApp / tests / session_memory_test.om` 221 lines · 4969 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 2 note Wolfram: {2^20,4096*2^20,(2^44-1)*2^20,2^64-1,Mod[-2,2^64]} -> 3 note {`1048576`,`4294967296`,`18446744073708503040`,`18446744073709551615`,`18446744073709551614`}; conversion results are bytes. 4 note Concatenate reserve.om, engine/fixture_rest.om, engine/eng.om, api/apish_slot.om, then this file. 5 note Exercises the existing handle and slot decisions unchanged; no second lifetime table. 6 global Mtests ulong 1 7 text MTpass "PASS " 8 text MTfail "FAIL " 9 text MTnl "\n" 10 text MTenv "reserve environment" 11 text MTline "MemAvailable conversion" 12 text MTbytes "reserve byte saturation" 13 text MTdone "SESSION_MEMORY PASS cases=" 14 text MTdouble "double release refused" 15 text MTuse "use after release refused" 16 text MTstale "stale generation refused" 17 text MTunder "pin-count underflow refused" 18 text MTpin "pinned eviction refused and version preserved" 19 text MTunpin "completion unpin permits eviction" 20 text MTcap "allocation at capacity refused" 21 text MTempty "" 22 text MTzero "0" 23 text MTone "1" 24 text MTdef "4096" 25 text MTws " \t+512" 26 text MTminus "-1" 27 text MTneg2 "-2" 28 text MTminus0 "-0" 29 text MTmax "`18446744073709551615`" 30 text MTov "`18446744073709551616`" 31 text MTnegov "-`18446744073709551616`" 32 text MTbad "12x" 33 text MTtrws "1 " 34 text MTspace " \t\n" 35 text MTsign "+" 36 text MTtwo "++1" 37 text MTmem "MemAvailable: 8192 kB\n" 38 text MTmws "MemAvailable:\t+4096" 39 text MTmneg "MemAvailable: -1 kB" 40 text MTmov "MemAvailable: `18446744073709551616` kB" 41 text MTmnot "MemFree: 8192 kB" 42 text MTmnone "MemAvailable: kB" 43 text MTmcase "memAvailable: 1" 44 text MTmshort "MemAvailable" 45 text MTmlead " MemAvailable: 1" 46 text MTmsuff "MemAvailable: 7xyz" 47 text MTmzero "MemAvailable: 0" 48 text MTmbad "MemAvailable: + kB" 49 50 fn tmwrite b view uchar * to void 51 i = ulong 0 52 while lt i len b bound 4096 53 r = write 1 b i sub len b i 54 if le r 0 55 exit 2 56 end 57 i = add i ulong r 58 end 59 end 60 61 fn tmcheck ok bool name view uchar * to void 62 if not ok 63 tmwrite MTfail 64 tmwrite name 65 tmwrite MTnl 66 exit 1 67 end 68 put Mtests 0 add get Mtests 0 1 69 tmwrite MTpass 70 tmwrite name 71 tmwrite MTnl 72 end 73 74 fn tmenv b view uchar * want ulong to void 75 o = new ulong 2 0 76 r = memreserve 0 b 0 o 77 tmcheck eq r want MTenv 78 end 79 80 fn tmline b view uchar * have ulong want ulong to void 81 o = new ulong 2 0 82 r = memreserve 1 b 0 o 83 tmcheck eq r have MTline 84 if ne have 0 85 tmcheck eq get o 0 want MTline 86 end 87 end 88 89 fn tmbytes n ulong want ulong to void 90 b = new uchar 1 0 91 o = new ulong 2 0 92 r = memreserve 2 part b 0 0 n o 93 tmcheck eq r want MTbytes 94 end 95 96 fn tmparses to void 97 longv = new uchar 4096 48 98 longws = new uchar 4096 32 99 tmenv part MTempty 0 0 4096 100 tmenv MTzero 0 101 tmenv MTone 1 102 tmenv MTdef 4096 103 tmenv MTws 512 104 tmenv MTminus `18446744073709551615` 105 tmenv MTneg2 `18446744073709551614` 106 tmenv MTminus0 0 107 tmenv MTmax `18446744073709551615` 108 tmenv MTov `18446744073709551615` 109 tmenv MTnegov `18446744073709551615` 110 tmenv MTbad 4096 111 tmenv MTtrws 4096 112 tmenv MTspace 4096 113 tmenv MTsign 4096 114 tmenv MTtwo 4096 115 put longv 4095 49 116 tmenv longv 1 117 put longws 4095 49 118 tmenv longws 1 119 tmline MTmem 1 8192 120 tmline MTmws 1 4096 121 tmline MTmneg 1 `18446744073709551615` 122 tmline MTmov 1 `18446744073709551615` 123 tmline MTmnot 0 0 124 tmline MTmnone 0 0 125 tmline MTmcase 0 0 126 tmline MTmshort 0 0 127 tmline MTmlead 0 0 128 tmline MTmsuff 1 7 129 tmline MTmzero 1 0 130 tmline MTmbad 0 0 131 tmbytes 0 0 132 tmbytes 1 `1048576` 133 tmbytes 4096 `4294967296` 134 tmbytes `17592186044415` `18446744073708503040` 135 tmbytes `17592186044416` `18446744073709551615` 136 tmbytes `18446744073709551615` `18446744073709551615` 137 end 138 139 fn tmhandles to void 140 m = new ulong 24 0 141 w = new ulong 16 0 142 note A closed handle is refused by the exact hchk decision used for both check and close. 143 put m 2 1 144 put m 3 7 145 put m 4 0 146 put m 5 7 147 put m 6 2 148 put m 7 2 149 hchk m w 150 tmcheck eq get w 0 6 MTdouble 151 hchk m w 152 tmcheck eq get w 0 6 MTuse 153 put m 4 1 154 put m 5 8 155 hchk m w 156 tmcheck eq get w 0 6 MTstale 157 note hopen uses nlive and max_slots; no DMA is requested when the admission returns LIMIT. 158 put m 2 2 159 put m 3 4096 160 put m 4 4096 161 put m 5 4096 162 put m 6 `18446744073709551615` 163 hopen m w 164 tmcheck eq get w 0 11 MTcap 165 end 166 167 fn tmpins to void 168 rec = new ulong 16 0 169 put rec 0 2 170 put rec 3 7 171 put rec 4 8 172 r = apishl 4 7 rec 173 tmcheck and eq r -1 eq get rec 1 0 MTunder 174 r = apishl 3 6 rec 175 tmcheck and eq r -7 eq get rec 1 0 MTstale 176 r = apishl 3 7 rec 177 tmcheck and eq r 0 eq get rec 1 1 MTpin 178 r = apishl 5 0 rec 179 tmcheck and eq r -6 eq get rec 3 7 MTpin 180 r = apishl 7 7 rec 181 tmcheck eq r 0 MTpin 182 r = apishl 4 7 rec 183 tmcheck and eq r 0 eq get rec 1 0 MTunpin 184 r = apishl 4 7 rec 185 tmcheck and eq r -1 eq get rec 14 0 MTunder 186 r = apishl 5 0 rec 187 tmcheck and eq r 0 eq get rec 0 0 MTunpin 188 r = apishl 3 7 rec 189 tmcheck and eq r -7 eq get rec 1 0 MTuse 190 end 191 192 fn tmcount value ulong to void 193 buf = new uchar 32 0 194 v = value 195 n = ulong 0 196 while true bound 32 197 put buf n uchar add rem v 10 48 198 n = add n 1 199 v = div v 10 200 if eq v 0 201 break 202 end 203 end 204 while gt n 0 bound 32 205 n = sub n 1 206 r = write 1 buf n 1 207 if ne r 1 208 exit 2 209 end 210 end 211 end 212 213 fn main to int 214 tmparses 215 tmhandles 216 tmpins 217 tmwrite MTdone 218 tmcount get Mtests 0 219 tmwrite MTnl 220 ret 0 221 end