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

56 lines · 1067 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.
5global out uchar 32
6global fl uchar 2000001
7fn putnum fd int v ulong to void
8put out 31 10
9p = ulong 31
10x = v
11while gt x 9
12p = sub p 1
13put out p uchar add rem x 10 48
14x = div x 10
15end
16p = sub p 1
17put out p uchar add x 48
18w = write fd out p sub 32 p
19end
20fn pass to ulong
21for i ulong 2000001
22put fl i 0
23end
24p = ulong 2
25while le mul p p 2000000
26if eq get fl p 0
27m = mul p p
28while le m 2000000
29put fl m 1
30m = add m p
31end
32end
33p = add p 1
34end
35c = ulong 0
36for i ulong 1999999
37if eq get fl add i 2 0
38c = add c 1
39end
40end
41ret c
42end
43fn main to int
44t0 = monons
45sum = ulong 0
46last = ulong 0
47for r ulong 50
48last = pass
49sum = add sum last
50end
51t1 = monons
52putnum 2 ulong sub t1 t0
53putnum 1 last
54putnum 1 sum
55ret 0
56end