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 / bench / omc_efficiency / kernels / om2 / branch.om

45 lines · 880 bytes Raw Blame History
1note branch: Collatz steps to reach 1 for every start 1 .. 1000000; prints the total steps and the
2note largest step count. Data-dependent branch in a bounded while.
3note OMC-EFF-2: main writes the nanoseconds between its two monons readings (the computation, without
4note start-up and output) as one decimal line on stderr; stdout is unchanged.
5om2
6global obuf uchar 32
7fn putnum fd int v ulong to void
8put obuf 31 10
9p = ulong 31
10x = v
11while gt x 9
12p = sub p 1
13put obuf p uchar add rem x 10 48
14x = div x 10
15end
16p = sub p 1
17put obuf p uchar add x 48
18w = write fd obuf p sub 32 p
19end
20fn main to int
21t0 = monons
22tot = ulong 0
23mx = ulong 0
24for n ulong 1000000
25x = add n 1
26k = ulong 0
27while ne x 1
28if eq and x 1 0
29x = shr x 1
30else
31x = add mul x 3 1
32end
33k = add k 1
34end
35tot = add tot k
36if gt k mx
37mx = k
38end
39end
40t1 = monons
41putnum 2 ulong sub t1 t0
42putnum 1 tot
43putnum 1 mx
44ret 0
45end