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 / aienux / crates / aienos-fpu-probe / fpu_probe_test.om

63 lines · 1504 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note aienux/crates/aienos-fpu-probe/fpu_probe_test.om: Behavioral self-test for aienos-fpu-probe.
3note Compose with: si/directives/om2.om aienux/crates/aienos-fpu-probe/fpu_probe.om aienux/crates/aienos-fpu-probe/fpu_probe_test.om
4
5fn main to int
6note 1. Short output buffer must be refused with -1
7short_buf = new uint 5 0
8if ne aienos_fpu_probe short_buf -1
9ret 1
10end
11
12note 2. Full probe must return 0 and write exact IEEE-754 bit patterns
13res = new uint 6 0
14if ne aienos_fpu_probe res 0
15ret 2
16end
17note 68.0f32 == 0x42880000
18if ne get res 0 uint 0x42880000
19ret 3
20end
21note Lanes: 11.0=0x41300000, 22.0=0x41b00000, 33.0=0x42040000, 44.0=0x42300000
22if ne get res 2 uint 0x41300000
23ret 4
24end
25if ne get res 3 uint 0x41b00000
26ret 5
27end
28if ne get res 4 uint 0x42040000
29ret 6
30end
31if ne get res 5 uint 0x42300000
32ret 7
33end
34
35note 3. exp_approx(0.0) == 1.0 exactly
36e0 = fpu_exp_approx 0.0f32
37if ne e0 1.0f32
38ret 8
39end
40
41note 4. exp_approx(-1.0) within 1e-4 of 1/e (0.36787944)
42em1 = fpu_exp_approx -1.0f32
43d1 = sub em1 0.36787944f32
44if not and lt d1 FPU_PROBE_TOL gt d1 neg FPU_PROBE_TOL
45ret 9
46end
47
48note 5. exp_approx(2.0) within 1e-3 of e^2 (7.3890561)
49e2 = fpu_exp_approx 2.0f32
50d2 = sub e2 7.3890561f32
51if not and lt d2 0.001f32 gt d2 -0.001f32
52ret 10
53end
54
55note 6. exp_approx(-2.5) exercises floor adjustment for negative non-integer t
56em25 = fpu_exp_approx -2.5f32
57d3 = sub em25 0.0820850f32
58if not and lt d3 FPU_PROBE_TOL gt d3 neg FPU_PROBE_TOL
59ret 11
60end
61
62ret 0
63end