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

FPE in zrotg with g++-13 -O3 #4909

Closed
shardest opened this issue Sep 30, 2024 · 6 comments
Closed

FPE in zrotg with g++-13 -O3 #4909

shardest opened this issue Sep 30, 2024 · 6 comments

Comments

@shardest
Copy link

shardest commented Sep 30, 2024

I have a simple test program that worked on Ubuntu 22.04 and now fails after upgrading to 24.04. I filed an Ubuntu bug report and then realized that I can reproduce the issue without using Ubuntu's OpenBLAS package but rather building from source. For reference, here's the bug report:

https://bugs.launchpad.net/ubuntu/+source/openblas/+bug/2083157

This is the test program (g++ -o test_blas test_blas.cpp -lopenblas):

#include
#include

#include <fenv.h>

typedef std::complex dcomp;

extern "C" {
void zrotg_(dcomp*, dcomp*, double*, dcomp*);
}

int main(void) {
feenableexcept(FE_INVALID |
FE_DIVBYZERO |
FE_OVERFLOW |
FE_UNDERFLOW);

dcomp ain(0.28048120941867205058,0.028460086243503417841), bin(0.018279187257355982571,0);
double c(0.0);
dcomp s(0.0);

dcomp a=ain, b=bin;
zrotg_(&a, &b, &c, &s);
std::cout << a << " " << b << " " << c << " " << s << std::endl;

return 0;

}

Expected output (get this with -O0):

(0.28107,0.101469) (0.0182792,0) 0.997905 (0.0643715,0.0065317)

Output with -O1, -O2, -O3:
Floating point exception (core dumped)

Output with -O3 but FPE turned off:
(0.28107,inf) (0.0182792,0) 0.997905 (0.0643715,0.0065317)

Additional notes:

  • Also fails with the Intel compiler and OpenBLAS
  • Works with the Intel compiler and MKL BLAS

Here are some results for different OpenBLAS versions:

  • 0.3.20 (version in Ubuntu 22.04, where my program used to work): works
  • 0.3.23: works
  • 0.3.24: fails
  • 0.3.26 (version in Ubuntu 24.04): fails

It seems this may be related to the implementation of "safe scaling" that went in for 0.3.24, possibly from #4130.

@martin-frbg
Copy link
Collaborator

What architecture/cpu do you see this with ?

@shardest
Copy link
Author

My system is a dual Xeon e5-2630v4.

@martin-frbg
Copy link
Collaborator

So a fairly common Haswell-generation x86_64... I cannot reproduce this with the current 0.3.28 and gcc 13.2 or 14.2 here

@shardest
Copy link
Author

I can try with 0.3.28 but I won't have time to get to it until this evening. Did you try with 0.3.26?

@martin-frbg
Copy link
Collaborator

This (a typo leading to uninitialized data being used as denominator) was fixed in the context of #4499 (released as 0.3.27)

@shardest
Copy link
Author

Thanks - I confirmed that it works on my system with 0.3.27. I will mention it on the Ubuntu bug report.

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

No branches or pull requests

2 participants