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