Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent Rust from constant folding in FPU test #26

Merged
merged 1 commit into from
Mar 13, 2024
Merged

Conversation

hydrolarus
Copy link
Contributor

The operations were done at compile time, so the floating point operations didn't end up in the binary - even debug ones!

This commit wraps all the relevant floating point values in a black_box which prevents the compiler from "seeing" the values, so it emits proper FPU instructions in all cases.

fixes #21

The operations were done at compile time, so the floating point
operations didn't end up in the binary - even debug ones!

This commit wraps all the relevant floating point values in a
`black_box` which prevents the compiler from "seeing" the values,
so it emits proper FPU instructions in all cases.

fixes #21
@hydrolarus hydrolarus added the bug Something isn't working label Mar 13, 2024
@hydrolarus
Copy link
Contributor Author

With those changes and the FPU disabled in the CPU configuration, this is the result of the tests

lara@gronau:~/Projects/clash-vexriscv$ cabal run clash-vexriscv-sim:unittests
VexRiscv Tests
  Debug builds
    Integration test `long_string` (debug):        OK (4.38s)
    Integration test `many_calls` (debug):         OK (0.78s)
    Integration test `hello_world` (debug):        OK (0.33s)
    Integration test `print_numbers` (debug):      OK (3.42s)
    Integration test `dyn_dispatch` (debug):       OK (0.22s)
    Integration test `ebreak_exception` (debug):   OK (1.28s)
    Integration test `loop_write` (debug):         OK (8.73s)
    Integration test `fpu_test` (debug):           FAIL (21.28s)
      tests/tests.hs:53:
      expected: "This test makes sure the FPU works as expected\n79823i32 as f32 = 79823\n1.3 + 5.3 = 6.6000004\n5.3 - 1.3 = 4\n24.65 * 43.2 = 1064.88\n12.6 / 4.2 = 3.0000002\n"
       but got: "This test makes sure the FPU works as expected\n79823i32 as f32 = 79823\n"
      Use -p '/Integration test `fpu_test` (debug)/' to rerun this test only.
    Integration test `single_write` (debug):       OK (0.63s)
  Release builds
    Integration test `long_string` (release):      OK (0.23s)
    Integration test `many_calls` (release):       OK (0.26s)
    Integration test `hello_world` (release):      OK (0.18s)
    Integration test `print_numbers` (release):    OK (0.36s)
    Integration test `dyn_dispatch` (release):     OK (0.16s)
    Integration test `ebreak_exception` (release): OK (0.16s)
    Integration test `loop_write` (release):       OK (0.80s)
    Integration test `fpu_test` (release):         FAIL (21.91s)
      tests/tests.hs:53:
      expected: "This test makes sure the FPU works as expected\n79823i32 as f32 = 79823\n1.3 + 5.3 = 6.6000004\n5.3 - 1.3 = 4\n24.65 * 43.2 = 1064.88\n12.6 / 4.2 = 3.0000002\n"
       but got: "This test makes sure the FPU works as expected\n79823i32 as f32 = 79823\n"
      Use -p '/Integration test `fpu_test` (release)/' to rerun this test only.
    Integration test `single_write` (release):     OK (0.23s)

2 out of 18 tests failed (65.38s)

@hydrolarus hydrolarus merged commit 06bd1d5 into main Mar 13, 2024
7 checks passed
@hydrolarus hydrolarus deleted the fpu-test-blackbox branch March 13, 2024 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FPU tests succeed even if floating point support is disabled
2 participants