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

Test the Fortran intrinsic ABS and complex divisions and report fails during build #623

Conversation

weslleyspereira
Copy link
Collaborator

@weslleyspereira weslleyspereira commented Sep 22, 2021

Description

After the long discussion in #575, I started testing the intrinsic routines complex ABS and complex division of some Fortran compilers. It is good that the user are aware of the compiler behavior.

This PR puts 2 new tests in LAPACK. The tests run at the build process. The build system reports any failures via command line, and the details are stored in disk inside the INSTALL directory. With this information, the user can better define/configure its Fortran compiler.

Checklist

  • The documentation has been updated.
  • The changes were implemented on the CMake build system.
  • The changes were implemented on the Makefile build system.

@codecov
Copy link

codecov bot commented Sep 22, 2021

Codecov Report

Merging #623 (f461d4f) into master (79aa0f2) will not change coverage.
The diff coverage is n/a.

❗ Current head f461d4f differs from pull request most recent head 1dd9548. Consider uploading reports for the commit 1dd9548 to get more accurate results
Impacted file tree graph

@@           Coverage Diff           @@
##           master     #623   +/-   ##
=======================================
  Coverage    0.00%    0.00%           
=======================================
  Files        1894     1894           
  Lines      184021   184021           
=======================================
  Misses     184021   184021           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 79aa0f2...1dd9548. Read the comment docs.

…g compile time. Currently only working with the CMake build!
@weslleyspereira weslleyspereira force-pushed the try-test-fotrancompiler_abs_div_operations branch from 50ea276 to 19fafd4 Compare September 22, 2021 20:21
@weslleyspereira weslleyspereira marked this pull request as ready for review September 22, 2021 21:01
@weslleyspereira
Copy link
Collaborator Author

I am proposing a short output during the build. For example, when compiling with gfortran 9.3.0 :

./test_zcomplexabs 2> test_zcomplexabs.err
./test_zcomplexdiv 2> test_zcomplexdiv.err
 !! Some (x+x*I)/(x+x*I) differ from 1
 !! Some (x+x*I)/(x-x*I) differ from I
 # Please check the failed divisions in [stderr]

The complete description of the failing tests si in the stderr file:

[ c3] X =  1.7976931348623157E+308 : (x+x*I)/(x+x*I) =                      NaN+0.0000000000000000E+000*I differs from +1.0000000000000000E+000
[ c4] X =  8.9884656743115795E+307 : (x+x*I)/(x+x*I) =                      NaN+0.0000000000000000E+000*I differs from +1.0000000000000000E+000
[ f3] X =  1.7976931348623157E+308 : (x+x*I)/(x-x*I) =  0.0000000000000000E+000                     NaN*I differs from +0.0000000000000000E+000+1.0000000000000000E+000*I
[ f4] X =  8.9884656743115795E+307 : (x+x*I)/(x-x*I) =  0.0000000000000000E+000                     NaN*I differs from +0.0000000000000000E+000+1.0000000000000000E+000*I

The identifiers, e.g., [c3], relate to the failing test 'C' with input data '3'. Please, look at the documentation of each routine to find information about it.

@weslleyspereira
Copy link
Collaborator Author

I have just added tests for the intrinsic MIN, MAX and for the complex multiplication. Interesting, I found that

[i7] MIN(   0.,  NaN) =   NaN
[i7] MAX(   0.,  NaN) =   NaN
[i8] MIN(  NaN,   0.) =    0.
[i8] MAX(  NaN,   0.) =    0.

using gfortran 9.3.0 on a Linux machine (Ubuntu 9.3.0-17ubuntu1~20.04). Following the standard IEEE754-2019, this is "a common way of defining min and max in a high-level language" (See nan_propagation.pdf for instance). Since MIN and MAX are currently used in LAPACK, we should signal these intrinsic functions may not propagate NaNs.

@weslleyspereira
Copy link
Collaborator Author

Personal note about complex multiplications in C and Fortran using GCC:
In GCC 11.2 on a x86-64 machine, the multiplications real*complex and complex*complex generate two different codes when using the C language (see https://godbolt.org/z/r9Esdvnfr). In this code, (1 * (Inf+0*I)) = (Inf+0*I) and ((1+0*I) * (Inf+0*I)) = (Inf+NaN*I). Using the same compiler, but with a code in Fortran, both multiplications return (Inf+NaN*I). (run the code in https://godbolt.org/z/fa839ca14)

@langou langou merged commit def1271 into Reference-LAPACK:master Apr 26, 2022
@weslleyspereira weslleyspereira deleted the try-test-fotrancompiler_abs_div_operations branch July 8, 2022 22:48
@julielangou julielangou added this to the LAPACK 3.10.1 milestone Nov 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants