Coder Social home page Coder Social logo

equipez / infnan Goto Github PK

View Code? Open in Web Editor NEW
8.0 1.0 1.0 474 KB

Fortran functions for checking Inf/NaN. They should work even if the compilers are invoked with aggressive optimization flags such as `gfortran -Ofast`.

License: GNU Lesser General Public License v3.0

Makefile 23.42% Fortran 76.58%
floating-point fortran numerical inf nan

infnan's People

Contributors

dependabot[bot] avatar zaikunzhang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

wcdawn

infnan's Issues

`is_nan` does not work with `gfortran-8 -O3 -ffast-math -Ofast -flto` on Kunpeng Platform with Ubuntu 18.04 Linux 4.15.0-166-generic

On Kunpeng Platform with Ubuntu 18.04 Linux 4.15.0-166-generic, is_nan fails to identify NaN when compiled with gfortran-8 -O3 -ffast-math -Ofast -flto (ieee_is_nan does not work either).

The details are as follows.

$ lscpu
Architecture:        aarch64
Byte Order:          Little Endian
CPU(s):              2
On-line CPU(s) list: 0,1
Thread(s) per core:  1
Core(s) per socket:  2
Socket(s):           1
NUMA node(s):        1
Vendor ID:           0x48
Model:               0
Stepping:            0x1
BogoMIPS:            200.00
L1d cache:           64K
L1i cache:           64K
L2 cache:            512K
L3 cache:            32768K
NUMA node0 CPU(s):   0,1
Flags:               fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma dcpop asimddp asimdfhm

$ uname -a 
Linux kunpeng-0001 4.15.0-166-generic #174-Ubuntu SMP Wed Dec 8 19:08:37 UTC 2021 aarch64 aarch64 aarch64 GNU/Linux

$ gfortran --version
GNU Fortran (Ubuntu/Linaro 8.4.0-1ubuntu1~18.04) 8.4.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ cd test && make clean && make gtest
rm -f *.o *.mod *.dbg *test
gfortran -O3 -ffast-math -Ofast -flto -o gtest ../consts.f90 ../infnan.f90 ieee_infnan.f90 testinfnan.f90 test.f90
./gtest

Single-precision tests:
 IS_NAN:  F F F F F F F F F F F F F F F F F F F
 IEEE_IS_NAN:  F F F F F F F F F F F F F F F F F F F
Some tests failed. The data is
Infinity    -Inf     NaN     NaN  4.E+01 -4.E+01  0.E+00 -0.E+00  0.E+00 -0.E+00  3.E+38 -3.E+38  1.E-07 -1.E-07  1.E-38 -1.E-38  0.E+00  1.E+00 -1.E+00

Double-precision tests:
 IS_NAN:  F F F F F F F F F F F F F F F F F F F
 IEEE_IS_NAN:  F F F F F F F F F F F F F F F F F F F
Some tests failed. The data is
Infinity    -Inf     NaN     NaN  4.D+01 -4.D+01  1.D+00 -1.D+00  0.D+00 -0.D+00  2.+308 -2.+308  2.D-16 -2.D-16  2.-308 -2.-308  0.D+00  1.D+00 -1.D+00
 
Note: The following floating-point exceptions are signalling: IEEE_INVALID_FLAG IEEE_OVERFLOW_FLAG
STOP 1
Makefile:65: recipe for target 'gtest' failed
make: *** [gtest] Error 1

add topics

I suggest adding the topics floating-point, fortran, numerical in the About section.

add topic nan

I suggest adding the topic nan in the About section.

`is_nan` does not work with `flang -Ofast` of `flang -ffast-math`

$ uname -a
Linux  5.15.0-56-generic #62-Ubuntu SMP Tue Nov 22 19:54:14 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

$ flang --version
flang version 15.0.3
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/zaikunzhang/local/flang/bin

$flang -O3 -Ofast -ffast-math   -o ftest ../consts.f90 ../infnan.f90 ieee_infnan.f90 testinfnan.f90 test.f90
$./ftest

Single-precision tests:
 IS_NAN:   F  F  F  F  F  F  F  F  F  F  F  F  F  F  F  F  F  F  F
 IEEE_IS_NAN:   F  F  T  T  F  F  F  F  F  F  F  F  F  F  F  F  F  F  F
Some tests failed. The data is
     Inf    -Inf     NaN     NaN  1.E+00 -1.E+00  0.E+00 -0.E+00  0.E+00 -0.E+00  3.E+38 -3.E+38  1.E-07 -1.E-07  1.E-38 -1.E-38  0.E+00  1.E+00 -1.E+00

Double-precision tests:
 IS_NAN:   F  F  F  F  F  F  F  F  F  F  F  F  F  F  F  F  F  F  F
 IEEE_IS_NAN:   F  F  T  T  F  F  F  F  F  F  F  F  F  F  F  F  F  F  F
Some tests failed. The data is
     Inf    -Inf     NaN     NaN  1.D+00 -1.D+00  0.D+00 -0.D+00  0.D+00 -0.D+00  2.+308 -2.+308  2.D-16 -2.D-16  2.-308 -2.-308  0.D+00  1.D+00 -1.D+00
 
Warning: ieee_invalid is signaling
Warning: ieee_inexact is signaling

`is_nan` does not work with `ifx -fast`

is_nan does not work with ifx -fast, the version of ifx being ifx (IFORT) 2022.1.0 20220316. The system is Ubuntu 20.04.

Here is the error information.

cd test && ifx -fast -o xtest ../consts.f90 ../infnan.f90 ieee_infnan.f90 testinfnan.f90 test.f90 && ./xtest

Single-precision tests:
 IS_NAN:  F F F F F F F F F F F F F F F F F F F
 IEEE_IS_NAN:  F F T T F F F F F F F F F F F F F F F
Some tests failed. The data is
Infinity    -Inf     NaN     NaN  1.E+00 -1.E+00  1.E-38 -1.E-38  0.E+00  0.E+00  3.E+38 -3.E+38  1.E-07 -1.E-07  1.E-38 -1.E-38  0.E+00  1.E+00 -1.E+00

Double-precision tests:
 IS_NAN:  F F F F F F F F F F F F F F F F F F F
 IEEE_IS_NAN:  F F T T F F F F F F F F F F F F F F F
Some tests failed. The data is
Infinity    -Inf     NaN     NaN  1.D+00 -1.D+00  2.-308 -2.-308  0.D+00  0.D+00  2.+308 -2.+308  2.D-16 -2.D-16  2.-308 -2.-308  0.D+00  1.D+00 -1.D+00
 
1

Note that ieee_is_nan works in this case.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.