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 / native / arboris / compute-lock.om

56 lines · 1603 bytes Raw Blame History
1note SPDX-License-Identifier: AGPL-3.0-only
2note Share this host lock inode between all Arboris workers on one GB10.
3note Independent open-file descriptions arbitrate CPU queries and GPU queries,
4note including fenced but unsettled outputs. Durable channel state is local.
5note The supervisor owns the mount namespace. Never unlink the live lock.
6text ar_compute_path "/tmp/omega-arboris-compute-v1.lock"
7global ar_compute_fd long 1
8global ar_compute_pid long 1
9global ar_compute_kind ulong 1
10
11fn ar_claim_compute kind ulong to bool
12 if or eq kind 0 ne get ar_compute_kind 0 0
13 ret false
14 end
15 note 559104 is AArch64 Linux O_CLOEXEC|O_NOFOLLOW|O_NONBLOCK|O_RDONLY.
16 note The create retry adds O_CREAT|O_EXCL (559296) and permissions 0444.
17 fd = fopen ar_compute_path 0 len ar_compute_path 559104 0
18 if eq fd long -2
19 fd = fopen ar_compute_path 0 len ar_compute_path 559296 292
20 if eq fd long -17
21 fd = fopen ar_compute_path 0 len ar_compute_path 559104 0
22 end
23 end
24 if lt fd 0
25 ret false
26 end
27 st = new uchar 128 0
28 if ne fstat int fd st 0 128 0
29 closed = fclose int fd
30 ret false
31 end
32 if ne and get st 17 240 128
33 closed = fclose int fd
34 ret false
35 end
36 if ne flock int fd 6 0
37 closed = fclose int fd
38 ret false
39 end
40 put ar_compute_fd 0 fd
41 put ar_compute_pid 0 long getpid
42 put ar_compute_kind 0 kind
43 ret true
44end
45
46fn ar_drop_compute to void
47 if eq get ar_compute_kind 0 0
48 ret
49 end
50 if ne get ar_compute_pid 0 long getpid
51 ret
52 end
53 closed = fclose int get ar_compute_fd 0
54 put ar_compute_kind 0 0
55 put ar_compute_pid 0 0
56end