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

nda::algorithms:all (probably fold) silent failure on gcc 12.2 with -Ofast #57

Open
HugoStrand opened this issue Jan 26, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@HugoStrand
Copy link
Member

Description

The nda::algorithms test breaks when using all and any when compiling nda 1.2.x at 6c71ef7 using gcc 12.2 with -Ofast. I suspect that some loop is silently optimised away in the fold algorithm.

Steps to Reproduce

  1. Compile nda with gcc 12.2 and -Ofast
  2. Run the tests

Actual behavior:

> ctest -V -R nda_algorithms
Test project /.../nda/cbuild
Constructing a list of tests
Done constructing a list of tests
Updating test list for fixtures
Added 0 tests to meet fixture requirements
Checking test dependency graph...
Checking test dependency graph end
test 46
    Start 46: nda_algorithms

46: Test command: /.../nda/cbuild/test/c++/nda_algorithms
46: Test timeout computed to be: 10000000
46: [==========] Running 4 tests from 1 test suite.
46: [----------] Global test environment set-up.
46: [----------] 4 tests from NDA
46: [ RUN      ] NDA.any_all
46: /.../nda/test/c++/nda_algorithms.cpp:31: Failure
46: Value of: all(isnan(A))
46:   Actual: false
46: Expected: true
46: 
46: /.../nda/test/c++/nda_algorithms.cpp:37: Failure
46: Value of: any(isnan(A))
46:   Actual: false
46: Expected: true
46: 
46: [  FAILED  ] NDA.any_all (0 ms)
46: [ RUN      ] NDA.any_all_cplx
46: /.../nda/test/c++/nda_algorithms.cpp:51: Failure
46: Value of: all(isnan(A))
46:   Actual: false
46: Expected: true
46: 
46: /.../nda/test/c++/nda_algorithms.cpp:57: Failure
46: Value of: any(isnan(A))
46:   Actual: false
46: Expected: true
46: 
46: [  FAILED  ] NDA.any_all_cplx (0 ms)
46: [ RUN      ] NDA.Algo1
46: [       OK ] NDA.Algo1 (0 ms)
46: [ RUN      ] NDA.AlgoMat
46: [       OK ] NDA.AlgoMat (0 ms)
46: [----------] 4 tests from NDA (0 ms total)
46: 
46: [----------] Global test environment tear-down
46: [==========] 4 tests from 1 test suite ran. (0 ms total)
46: [  PASSED  ] 2 tests.
46: [  FAILED  ] 2 tests, listed below:
46: [  FAILED  ] NDA.any_all
46: [  FAILED  ] NDA.any_all_cplx
46: 
46:  2 FAILED TESTS
1/1 Test #46: nda_algorithms ...................***Failed    0.05 sec

0% tests passed, 1 tests failed out of 1

Total Test time (real) =   0.08 sec

The following tests FAILED:
	 46 - nda_algorithms (Failed)
Errors while running CTest

Versions

nda 1.2.x at 6c71ef7

@HugoStrand HugoStrand added the bug Something isn't working label Jan 26, 2024
@hmenke
Copy link
Member

hmenke commented Jun 24, 2024

This is expected. -Ofast implies -ffast-math which in turn implies -ffinite-math-only, i.e. it assumes that all floating point math is finite and there will never be any inf or nan. Therefore any instance of isnan will simply be optimized out as false. Generally the recommendation is to not use -ffast-math at all, see https://simonbyrne.github.io/notes/fastmath/

@HugoStrand
Copy link
Member Author

This was discussed at the triqs updates meeting 2024-06-27 and the agreement was to catch -Ofast at CMake level and refuse to build.

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

No branches or pull requests

2 participants