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

57 lines · 1076 bytes Raw Blame History
1note sieve: 50 fresh passes of the sieve of Eratosthenes over 0 .. 2000000 in a global byte array;
2note prints the prime count of the last pass and the sum of the counts of all passes.
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
7global fl uchar 2000001
8fn putnum fd int v ulong to void
9put obuf 31 10
10p = ulong 31
11x = v
12while gt x 9
13p = sub p 1
14put obuf p uchar add rem x 10 48
15x = div x 10
16end
17p = sub p 1
18put obuf p uchar add x 48
19w = write fd obuf p sub 32 p
20end
21fn pass to ulong
22for i ulong 2000001
23put fl i 0
24end
25p = ulong 2
26while le mul p p 2000000
27if eq get fl p 0
28m = mul p p
29while le m 2000000
30put fl m 1
31m = add m p
32end
33end
34p = add p 1
35end
36c = ulong 0
37for i ulong 1999999
38if eq get fl add i 2 0
39c = add c 1
40end
41end
42ret c
43end
44fn main to int
45t0 = monons
46sum = ulong 0
47last = ulong 0
48for r ulong 50
49last = pass
50sum = add sum last
51end
52t1 = monons
53putnum 2 ulong sub t1 t0
54putnum 1 last
55putnum 1 sum
56ret 0
57end