This is an archive of the discontinued LLVM Phabricator instance.

[libc] Enable hermetic floating point tests again.
ClosedPublic

Authored by lntue on Jun 13 2023, 5:45 PM.

Details

Summary

Fixing an issue with LLVM libc's fenv.h defined rounding mode macros
differently from system libc, making get_round() return different values from
fegetround(). Also letting math tests to skip rounding modes that cannot be
set. This should allow math tests to be run on platforms in which fenv.h is not
implemented yet.

This allows us to re-enable hermatic floating point tests in
https://reviews.llvm.org/D151123 and reverting https://reviews.llvm.org/D152742.

Diff Detail

Event Timeline

lntue created this revision.Jun 13 2023, 5:45 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJun 13 2023, 5:45 PM
lntue requested review of this revision.Jun 13 2023, 5:45 PM

With this patch I get the following failures on my AMDGPU machine. I'm not sure if it's something we haven't yet implemented on the GPU or not.

FAILED: libc/test/src/__support/FPUtil/CMakeFiles/libc.test.src.__support.FPUtil.rounding_mode_test.__hermetic__ /home/jhuber/Documents/llvm/llvm-project/build/runtimes/runtimes-bins/libc/test/src/__support/FPUtil/CMakeFiles/libc.test.src.__support.FPUtil.rounding_mode_test.__hermetic__ 
cd /home/jhuber/Documents/llvm/llvm-project/build/runtimes/runtimes-bins/libc/test/src/__support/FPUtil && /home/jhuber/Documents/llvm/llvm-project/build/runtimes/runtimes-bins/libc/utils/gpu/loader/amdgpu/amdhsa_loader /home/jhuber/Documents/llvm/llvm-project/build/runtimes/runtimes-bins/libc/test/src/__support/FPUtil/libc.test.src.__support.FPUtil.rounding_mode_test.__hermetic__.__build__
[ RUN      ] LlvmLibcFEnvImplTest.QuickRoundingUpTest
/home/jhuber/Documents/llvm/llvm-project/libc/test/src/__support/FPUtil/rounding_mode_test.cpp:22: FAILURE
      Expected: (fenv_is_round_up())
      Which is: 0
To be equal to: true
      Which is: 1
[  FAILED  ] LlvmLibcFEnvImplTest.QuickRoundingUpTest
[ RUN      ] LlvmLibcFEnvImplTest.QuickRoundingDownTest
/home/jhuber/Documents/llvm/llvm-project/libc/test/src/__support/FPUtil/rounding_mode_test.cpp:46: FAILURE
      Expected: (fenv_is_round_down())
      Which is: 0
To be equal to: true
      Which is: 1
[  FAILED  ] LlvmLibcFEnvImplTest.QuickRoundingDownTest
[ RUN      ] LlvmLibcFEnvImplTest.QuickRoundingNearestTest
/home/jhuber/Documents/llvm/llvm-project/libc/test/src/__support/FPUtil/rounding_mode_test.cpp:62: FAILURE
      Expected: (fenv_is_round_to_nearest())
      Which is: 1
To be equal to: false
      Which is: 0
[  FAILED  ] LlvmLibcFEnvImplTest.QuickRoundingNearestTest
[ RUN      ] LlvmLibcFEnvImplTest.QuickRoundingTowardZeroTest
/home/jhuber/Documents/llvm/llvm-project/libc/test/src/__support/FPUtil/rounding_mode_test.cpp:94: FAILURE
      Expected: (fenv_is_round_to_zero())
      Which is: 0
To be equal to: true
      Which is: 1
[  FAILED  ] LlvmLibcFEnvImplTest.QuickRoundingTowardZeroTest
[ RUN      ] LlvmLibcFEnvImplTest.QuickGetRoundTest
/home/jhuber/Documents/llvm/llvm-project/libc/test/src/__support/FPUtil/rounding_mode_test.cpp:102: FAILURE
      Expected: quick_get_round()
      Which is: 0
To be equal to: 0x800
      Which is: 2048
[  FAILED  ] LlvmLibcFEnvImplTest.QuickGetRoundTest
Ran 5 tests.  PASS: 0  FAIL: 5
lntue updated this revision to Diff 531164.Jun 13 2023, 8:59 PM

Let math tests skip rounding modes that cannot be set.

lntue edited the summary of this revision. (Show Details)Jun 13 2023, 9:03 PM
jhuber6 accepted this revision.Jun 14 2023, 4:56 AM

Passes on my machine, thanks.

This revision is now accepted and ready to land.Jun 14 2023, 4:56 AM
This revision was automatically updated to reflect the committed changes.