Description
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.