interplane.Get Omega
Read in your language

cortex

aien-dev/cortex

Brought by drakestapleton

branch main Branches Tags History

cortex / tests / fts / t_flog.om

101 lines · 1577 bytes Raw Blame History
1note ===== tests/fts/t_flog.om : flog / flog_fma differential harness =====
2note usage: t_flog l FILE (records f64 x, f64 glibc log(x))
3note t_flog f FILE (records f64 a, b, c, hardware fma(a,b,c))
4note prints counts; exit 0 when every result is bit-identical, 1 otherwise
5global tmode uchar 8
6text tl1 "cases="
7text tl2 " mismatches="
8text tl3 "MISMATCH "
9fn main to int
10flog_init
11n = argread 1 tmode 0 8
12if lt n 1
13exit 94
14end
15md = get tmode 0
16fd = t_open 2
17rs = ulong 16
18if eq md 102
19rs = ulong 32
20end
21tot = ulong 0
22bad = ulong 0
23for blk ulong 64
24dn = false
25for j ulong 999999
26if not t_need fd rs
27dn = true
28break
29end
30tot = add tot 1
31ok = t_one md
32if not ok
33bad = add bad 1
34end
35end
36if dn
37break
38end
39end
40for i ulong len tl1
41t_ch ulong get tl1 i
42end
43t_dec tot
44for i ulong len tl2
45t_ch ulong get tl2 i
46end
47t_dec bad
48t_ch 10
49t_flush
50if eq bad 0
51ret 0
52end
53ret 1
54end
55fn t_one md uchar to bool
56if eq md 108
57x = t_u64
58want = t_u64
59got = bitcast ulong flog bitcast f64 x
60if eq got want
61ret true
62end
63x2 = bitcast f64 x
64if and ne x2 x2 ne bitcast f64 got bitcast f64 got
65ret true
66end
67t_bad x 0 0 want got
68ret false
69end
70a = t_u64
71b = t_u64
72c = t_u64
73want = t_u64
74got = bitcast ulong flog_fma bitcast f64 a bitcast f64 b bitcast f64 c
75if eq got want
76ret true
77end
78t_bad a b c want got
79ret false
80end
81global tnb ulong 1
82fn t_bad a ulong b ulong c ulong want ulong got ulong to void
83k = get tnb 0
84put tnb 0 add k 1
85if ge k 20
86ret
87end
88for i ulong len tl3
89t_ch ulong get tl3 i
90end
91t_hex a 16
92t_ch 32
93t_hex b 16
94t_ch 32
95t_hex c 16
96t_ch 32
97t_hex want 16
98t_ch 32
99t_hex got 16
100t_ch 10
101end