interplane.Get Omega
Read in your language

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

branch main Branches Tags History

CUDApp / backend / amd / kfd / cli.om

111 lines · 2218 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2note Shared CLI unsigned parser; append after aql.om, kernarg.om, records.om or ring.om.
3note A uint64 text needs at most 20 decimal digits or 0x plus 16 hexadecimal digits.
4note Buffer 21 permits the extra byte that makes an overlong value refuse, not truncate.
5note WolframLanguageEvaluator: {2^64-1,Quotient[2^64-1,10],Mod[2^64-1,10]} ->
6note {18446744073709551615,1844674407370955161,5} (integer range, dimensionless).
7note Diagnostic number fields: 0 text/read, 1 hex length, 2 hex digit, 3 decimal digit, 4 decimal range, 5 decimal overflow.
8note The fixed label is local so this shared fragment remains valid after a caller main under the original seed.
9fn numberrefuse reason ulong to void
10msg = new uchar 28 0
11put msg 0 79
12put msg 1 77
13put msg 2 69
14put msg 3 71
15put msg 4 65
16put msg 5 32
17put msg 6 114
18put msg 7 101
19put msg 8 102
20put msg 9 117
21put msg 10 115
22put msg 11 101
23put msg 12 32
24put msg 13 110
25put msg 14 117
26put msg 15 109
27put msg 16 98
28put msg 17 101
29put msg 18 114
30put msg 19 32
31put msg 20 102
32put msg 21 105
33put msg 22 101
34put msg 23 108
35put msg 24 100
36put msg 25 61
37put msg 26 48
38put msg 27 10
39put msg 26 uchar add ulong 48 reason
40emitfd 2 msg
41exit 2
42end
43fn argnum i ulong to ulong
44ab = new uchar 21 0
45n = argread i ab 0 21
46if lt n 1
47numberrefuse 0
48end
49k = ulong n
50s = ulong 0
51hex = false
52if gt k 2
53if and eq get ab 0 48 eq get ab 1 120
54hex = true
55s = ulong 2
56end
57end
58m = sub k s
59if hex
60if gt m 16
61numberrefuse 1
62end
63end
64v = ulong 0
65for j ulong m
66d = ulong get ab add j s
67dv = ulong 16
68if and ge d 48 le d 57
69dv = sub d 48
70end
71if hex
72if and ge d 97 le d 102
73dv = sub d 87
74end
75if eq dv 16
76numberrefuse 2
77end
78v = or shl v 4 dv
79else
80if gt dv 9
81numberrefuse 3
82end
83if gt v 1844674407370955161
84numberrefuse 4
85end
86if and eq v 1844674407370955161 gt dv 5
87numberrefuse 5
88end
89v = add mul v 10 dv
90end
91end
92ret v
93end
94note Full write or exit 74. Applies to files and pipes, including partial writes and EINTR.
95fn emitfd fd int b view uchar * to void
96p = ulong 0
97while lt p len b bound 999999
98r = write fd b p sub len b p
99if eq r neg long 4
100continue
101end
102if le r 0
103exit 74
104end
105p = add p ulong r
106end
107end
108
109fn emit b view uchar * to void
110emitfd 1 b
111end