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 / arith.om

33 lines · 803 bytes Raw Blame History
1note arith: wrapping multiply-add hash h = h*31 + i and s = sum of ((i*i) xor (i >> 3)) rem 1000003,
2note i = 0 .. 39999999, all ulong (unsigned wraps modulo 2^64). Prints h then s.
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.
5global out uchar 32
6fn putnum fd int v ulong to void
7put out 31 10
8p = ulong 31
9x = v
10while gt x 9
11p = sub p 1
12put out p uchar add rem x 10 48
13x = div x 10
14end
15p = sub p 1
16put out p uchar add x 48
17w = write fd out p sub 32 p
18end
19fn main to int
20t0 = monons
21h = ulong 0
22s = ulong 0
23for i ulong 40000000
24h = add mul h 31 i
25t = xor mul i i shr i 3
26s = add s rem t 1000003
27end
28t1 = monons
29putnum 2 ulong sub t1 t0
30putnum 1 h
31putnum 1 s
32ret 0
33end