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

64 lines · 1423 bytes Raw Blame History
1note matmul: C = A B for 300 x 300 ulong matrices in global arrays, A[i][j] = (i + 2j) rem 13,
2note B[i][j] = (3i + j) rem 11; prints the sum of all elements of C and its trace.
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 ma ulong 90000
8global mb ulong 90000
9global mc ulong 90000
10fn putnum fd int v ulong to void
11put obuf 31 10
12p = ulong 31
13x = v
14while gt x 9
15p = sub p 1
16put obuf p uchar add rem x 10 48
17x = div x 10
18end
19p = sub p 1
20put obuf p uchar add x 48
21w = write fd obuf p sub 32 p
22end
23fn fill to void
24for i ulong 300
25for j ulong 300
26put ma add mul i 300 j rem add i mul j 2 13
27put mb add mul i 300 j rem add mul i 3 j 11
28end
29end
30end
31note mm: the row offset r and the column walk q are kept in names; the direct form
32note add s mul get ma add mul i 300 k get mb add mul k 300 j needs more than the 16 registers (error 12)
33fn mm to void
34for i ulong 300
35r = mul i 300
36for j ulong 300
37s = ulong 0
38q = j
39for k ulong 300
40s = add s mul get ma add r k get mb q
41q = add q 300
42end
43put mc add r j s
44end
45end
46end
47fn main to int
48t0 = monons
49fill
50mm
51tot = ulong 0
52tr = ulong 0
53for i ulong 300
54for j ulong 300
55tot = add tot get mc add mul i 300 j
56end
57tr = add tr get mc add mul i 301 0
58end
59t1 = monons
60putnum 2 ulong sub t1 t0
61putnum 1 tot
62putnum 1 tr
63ret 0
64end