Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/bench/omc_efficiency/kernels/om2/sieve.om # 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 Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / bench / omc_efficiency / kernels / om2 / sieve.om` 57 lines ยท 1076 bytes Raw Blame History 1 note sieve: 50 fresh passes of the sieve of Eratosthenes over 0 .. `2000000` in a global byte array; 2 note prints the prime count of the last pass and the sum of the counts of all passes. 3 note OMC-EFF-2: main writes the nanoseconds between its two monons readings (the computation, without 4 note start-up and output) as one decimal line on stderr; stdout is unchanged. 5 om2 6 global obuf uchar 32 7 global fl uchar `2000001` 8 fn putnum fd int v ulong to void 9 put obuf 31 10 10 p = ulong 31 11 x = v 12 while gt x 9 13 p = sub p 1 14 put obuf p uchar add rem x 10 48 15 x = div x 10 16 end 17 p = sub p 1 18 put obuf p uchar add x 48 19 w = write fd obuf p sub 32 p 20 end 21 fn pass to ulong 22 for i ulong `2000001` 23 put fl i 0 24 end 25 p = ulong 2 26 while le mul p p `2000000` 27 if eq get fl p 0 28 m = mul p p 29 while le m `2000000` 30 put fl m 1 31 m = add m p 32 end 33 end 34 p = add p 1 35 end 36 c = ulong 0 37 for i ulong `1999999` 38 if eq get fl add i 2 0 39 c = add c 1 40 end 41 end 42 ret c 43 end 44 fn main to int 45 t0 = monons 46 sum = ulong 0 47 last = ulong 0 48 for r ulong 50 49 last = pass 50 sum = add sum last 51 end 52 t1 = monons 53 putnum 2 ulong sub t1 t0 54 putnum 1 last 55 putnum 1 sum 56 ret 0 57 end