interplane.Get Omega
Read in your language

omega-bridge

Omega-first language interoperability: checked conversion backends and native language bindings

Brought by drakestapleton

branch main Branches Tags History

omega-bridge / tests / cabi / fixture.om

343 lines · 8441 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2note omega-bridge cabi-1 fixture: an NVML-class library generated from seeded Omega by tools/bridge-seeded lib-c|lib-h|lib-map.
3note cabi library libombrfx.so.1 header ombrfx.h
4note cabi lock FxLock process mutex
5note cabi status nvmlReturn_t nvmlReturn_enum int32 trap 999
6note cabi value nvmlReturn_t NVML_SUCCESS 0
7note cabi value nvmlReturn_t NVML_ERROR_INVALID_ARGUMENT 2
8note cabi value nvmlReturn_t NVML_ERROR_INSUFFICIENT_SIZE 7
9note cabi value nvmlReturn_t NVML_ERROR_UNKNOWN 999
10note cabi define NVML_DEVICE_NAME_BUFFER_SIZE 64
11note cabi aliasguard NVML_NO_UNVERSIONED_FUNC_DEFS
12note cabi alias nvmlDeviceGetCount nvmlDeviceGetCount_v2
13note cabi alias nvmlDeviceGetHandleByIndex nvmlDeviceGetHandleByIndex_v2
14note cabi handle nvmlDevice_t nvmlDevice_st pool FxDevs count 4 lock FxLock
15note cabi record nvmlMemory_t nvmlMemory_st size 24 align 8
16note cabi field nvmlMemory_t total uint64 0
17note cabi field nvmlMemory_t free uint64 8
18note cabi field nvmlMemory_t used uint64 16
19note cabi record nvmlProcessInfo_v2_t nvmlProcessInfo_v2_st size 24 align 8 alias nvmlProcessInfo_t
20note cabi field nvmlProcessInfo_v2_t pid uint32 0
21note cabi field nvmlProcessInfo_v2_t usedGpuMemory uint64 8
22note cabi field nvmlProcessInfo_v2_t gpuInstanceId uint32 16
23note cabi field nvmlProcessInfo_v2_t computeInstanceId uint32 20
24note cabi state FxState ulong 8 process lock FxLock
25note cabi state FxBytes uchar 512 process lock FxLock
26note cabi state FxTexts uchar 128 process lock FxLock
27note cabi state FxSum ulong 1 process lock FxLock
28note cabi state FxW ulong 3 process lock FxLock
29note cabi state FxV ulong 6 process lock FxLock
30note cabi cstr FxTexts slots 4 width 32 fallback "Unknown Error" lock FxLock
31note cabi export nvmlDeviceGetCount_v2 fx_count status nvmlReturn_t lock FxLock
32note cabi bind nvmlDeviceGetCount_v2 st FxState
33note cabi arg nvmlDeviceGetCount_v2 deviceCount nullable out uint32 commit 0
34note cabi export nvmlDeviceGetHandleByIndex_v2 fx_handle status nvmlReturn_t lock FxLock
35note cabi bind nvmlDeviceGetHandleByIndex_v2 st FxState
36note cabi arg nvmlDeviceGetHandleByIndex_v2 index uint32
37note cabi arg nvmlDeviceGetHandleByIndex_v2 device nullable out nvmlDevice_t commit 0
38note cabi export nvmlDeviceGetName fx_name status nvmlReturn_t lock FxLock
39note cabi bind nvmlDeviceGetName st FxState
40note cabi bind nvmlDeviceGetName b FxBytes
41note cabi arg nvmlDeviceGetName device nvmlDevice_t
42note cabi arg nvmlDeviceGetName name nullable out char length length commit 0 data FxBytes 0
43note cabi arg nvmlDeviceGetName length uint32
44note cabi export nvmlDeviceGetMemoryInfo fx_mem status nvmlReturn_t lock FxLock
45note cabi bind nvmlDeviceGetMemoryInfo st FxState
46note cabi bind nvmlDeviceGetMemoryInfo b FxBytes
47note cabi arg nvmlDeviceGetMemoryInfo device nvmlDevice_t
48note cabi arg nvmlDeviceGetMemoryInfo memory nullable out nvmlMemory_t commit 0 data FxBytes 64
49note cabi export nvmlDeviceGetComputeRunningProcesses_v2 fx_procs status nvmlReturn_t lock FxLock
50note cabi bind nvmlDeviceGetComputeRunningProcesses_v2 st FxState
51note cabi bind nvmlDeviceGetComputeRunningProcesses_v2 b FxBytes
52note cabi arg nvmlDeviceGetComputeRunningProcesses_v2 device nvmlDevice_t
53note cabi arg nvmlDeviceGetComputeRunningProcesses_v2 infoCount nullable inout uint32 commit 1
54note cabi arg nvmlDeviceGetComputeRunningProcesses_v2 infos nullable out nvmlProcessInfo_v2_t count infoCount commit 2 data FxBytes 128
55note cabi export nvmlErrorString fx_err cstr FxTexts lock FxLock
56note cabi bind nvmlErrorString t FxTexts
57note cabi bind nvmlErrorString st FxState
58note cabi arg nvmlErrorString result nvmlReturn_t
59note cabi export ombrFxBump fx_bump status nvmlReturn_t lock FxLock
60note cabi bind ombrFxBump st FxState
61note cabi arg ombrFxBump value nullable out uint64 commit 0
62note cabi export ombrFxSum fx_sumx status nvmlReturn_t lock FxLock
63note cabi bind ombrFxSum b FxBytes
64note cabi bind ombrFxSum r FxSum
65note cabi bind ombrFxSum w FxW
66note cabi bind ombrFxSum v FxV
67note cabi arg ombrFxSum seed uint64
68note cabi arg ombrFxSum sum nullable out uint64 commit 0
69note cabi import fx_ext omega_fx_sum result r span b 0 n value n span w 0 k span v 3 k value k
70
71fn fx_ext r edit ulong 1 b view uchar 512 n ulong w edit ulong 3 v view ulong 6 k ulong to ulong
72ret 0
73end
74
75note State words: 0 device count, 1 count calls, 3 bump counter, 6 texts ready, 7 initialised.
76fn fx_init st edit ulong 8 to void
77if eq get st 7 0
78put st 0 2
79put st 7 1
80end
81end
82
83fn fx_count fr edit ulong 4 st edit ulong 8 to ulong
84fx_init st
85put st 1 add get st 1 1
86if eq get fr 2 0
87put fr 0 2
88ret 0
89end
90put fr 3 get st 0
91put fr 1 1
92put fr 0 0
93ret 0
94end
95
96fn fx_handle fr edit ulong 5 st edit ulong 8 to ulong
97fx_init st
98if eq get fr 3 0
99put fr 0 2
100ret 0
101end
102if ge get fr 2 get st 0
103put fr 0 2
104ret 0
105end
106put fr 4 get fr 2
107put fr 1 1
108put fr 0 0
109ret 0
110end
111
112fn fx_gpu b edit uchar 512 d ulong to ulong
113put b 0 uchar 79
114put b 1 uchar 109
115put b 2 uchar 101
116put b 3 uchar 103
117put b 4 uchar 97
118put b 5 uchar 32
119put b 6 uchar 70
120put b 7 uchar 105
121put b 8 uchar 120
122put b 9 uchar 116
123put b 10 uchar 117
124put b 11 uchar 114
125put b 12 uchar 101
126put b 13 uchar 32
127put b 14 uchar 71
128put b 15 uchar 80
129put b 16 uchar 85
130put b 17 uchar 32
131put b 18 uchar add 48 d
132put b 19 uchar 0
133ret 20
134end
135
136fn fx_name fr edit ulong 6 st edit ulong 8 b edit uchar 512 to ulong
137fx_init st
138if ge get fr 2 get st 0
139put fr 0 2
140ret 0
141end
142if eq get fr 3 0
143put fr 0 2
144ret 0
145end
146n = fx_gpu b get fr 2
147if gt n get fr 5
148put fr 0 7
149ret 0
150end
151put fr 4 n
152put fr 1 1
153put fr 0 0
154ret 0
155end
156
157fn fx_put64 b edit uchar 512 o ulong v ulong to void
158w = v
159for j ulong 8
160put b add o j uchar and w 255
161w = shr w 8
162end
163end
164
165fn fx_put32 b edit uchar 512 o ulong v ulong to void
166w = v
167for j ulong 4
168put b add o j uchar and w 255
169w = shr w 8
170end
171end
172
173fn fx_mem fr edit ulong 4 st edit ulong 8 b edit uchar 512 to ulong
174fx_init st
175if ge get fr 2 get st 0
176put fr 0 2
177ret 0
178end
179if eq get fr 3 0
180put fr 0 2
181ret 0
182end
183t = mul add get fr 2 1 1073741824
184u = mul add get fr 2 1 4096
185fx_put64 b 64 t
186fx_put64 b 72 sub t u
187fx_put64 b 80 u
188put fr 1 1
189put fr 0 0
190ret 0
191end
192
193fn fx_proc b edit uchar 512 i ulong d ulong to void
194o = add 128 mul i 24
195for j ulong 24
196put b add o j uchar 0
197end
198fx_put64 b o add 1000 add mul d 10 i
199fx_put64 b add o 8 mul add i 1 1048576
200fx_put32 b add o 16 7
201fx_put32 b add o 20 9
202end
203
204fn fx_procs fr edit ulong 7 st edit ulong 8 b edit uchar 512 to ulong
205fx_init st
206if ge get fr 2 get st 0
207put fr 0 2
208ret 0
209end
210if eq get fr 3 0
211put fr 0 2
212ret 0
213end
214if lt get fr 4 2
215put fr 4 2
216put fr 1 2
217put fr 0 7
218ret 0
219end
220if eq get fr 5 0
221put fr 0 2
222ret 0
223end
224fx_proc b 0 get fr 2
225fx_proc b 1 get fr 2
226put fr 4 2
227put fr 6 2
228put fr 1 6
229put fr 0 0
230ret 0
231end
232
233fn fx_texts t edit uchar 128 to void
234put t 0 uchar 83
235put t 1 uchar 117
236put t 2 uchar 99
237put t 3 uchar 99
238put t 4 uchar 101
239put t 5 uchar 115
240put t 6 uchar 115
241put t 7 uchar 0
242put t 32 uchar 73
243put t 33 uchar 110
244put t 34 uchar 118
245put t 35 uchar 97
246put t 36 uchar 108
247put t 37 uchar 105
248put t 38 uchar 100
249put t 39 uchar 32
250put t 40 uchar 65
251put t 41 uchar 114
252put t 42 uchar 103
253put t 43 uchar 117
254put t 44 uchar 109
255put t 45 uchar 101
256put t 46 uchar 110
257put t 47 uchar 116
258put t 48 uchar 0
259put t 64 uchar 73
260put t 65 uchar 110
261put t 66 uchar 115
262put t 67 uchar 117
263put t 68 uchar 102
264put t 69 uchar 102
265put t 70 uchar 105
266put t 71 uchar 99
267put t 72 uchar 105
268put t 73 uchar 101
269put t 74 uchar 110
270put t 75 uchar 116
271put t 76 uchar 32
272put t 77 uchar 83
273put t 78 uchar 105
274put t 79 uchar 122
275put t 80 uchar 101
276put t 81 uchar 0
277end
278
279fn fx_err fr edit ulong 3 t edit uchar 128 st edit ulong 8 to ulong
280if eq get st 6 0
281fx_texts t
282put st 6 1
283end
284r = get fr 2
285put fr 0 4
286put fr 1 0
287if eq r 0
288put fr 0 0
289put fr 1 7
290end
291if eq r 2
292put fr 0 1
293put fr 1 16
294end
295if eq r 7
296put fr 0 2
297put fr 1 17
298end
299ret 0
300end
301
302fn fx_bump fr edit ulong 4 st edit ulong 8 to ulong
303if eq get fr 2 0
304put fr 0 2
305ret 0
306end
307v = get st 3
308w = ulong 0
309for j ulong 4096
310w = add w j
311end
312put st 3 add v 1
313put fr 3 add v 1
314put fr 1 1
315put fr 0 0
316ret 0
317end
318
319fn fx_sumx fr edit ulong 5 b edit uchar 512 r edit ulong 1 w edit ulong 3 v edit ulong 6 to ulong
320if eq get fr 3 0
321put fr 0 2
322ret 0
323end
324for j ulong 512
325put b j uchar and j 255
326end
327for k ulong 6
328put v k add k 1
329end
330put r 0 0
331c = fx_ext r b 512 w v 3
332if ne c 0
333ret 1
334end
335s = add get fr 2 get r 0
336s = add s get w 0
337s = add s get w 1
338s = add s get w 2
339put fr 4 s
340put fr 1 1
341put fr 0 0
342ret 0
343end