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

63 lines · 1414 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.
5global out uchar 32
6global ma ulong 90000
7global mb ulong 90000
8global mc ulong 90000
9fn putnum fd int v ulong to void
10put out 31 10
11p = ulong 31
12x = v
13while gt x 9
14p = sub p 1
15put out p uchar add rem x 10 48
16x = div x 10
17end
18p = sub p 1
19put out p uchar add x 48
20w = write fd out p sub 32 p
21end
22fn fill to void
23for i ulong 300
24for j ulong 300
25put ma add mul i 300 j rem add i mul j 2 13
26put mb add mul i 300 j rem add mul i 3 j 11
27end
28end
29end
30note mm: the row offset r and the column walk q are kept in names; the direct form
31note 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)
32fn mm to void
33for i ulong 300
34r = mul i 300
35for j ulong 300
36s = ulong 0
37q = j
38for k ulong 300
39s = add s mul get ma add r k get mb q
40q = add q 300
41end
42put mc add r j s
43end
44end
45end
46fn main to int
47t0 = monons
48fill
49mm
50tot = ulong 0
51tr = ulong 0
52for i ulong 300
53for j ulong 300
54tot = add tot get mc add mul i 300 j
55end
56tr = add tr get mc add mul i 301 0
57end
58t1 = monons
59putnum 2 ulong sub t1 t0
60putnum 1 tot
61putnum 1 tr
62ret 0
63end