Has been reproduced on
OS/CPU: macOS Tahoe 26.5, M4 and M2 CPU
Compiler: GCC (gfortran) 15.2.0
OpenBLAS 0.3.32 (installed via macports, build formula)
and
OS/CPU: - / M2 CPU
Compiler: GCC (gfortran) 15.2.0
OpenBLAS 0.3.33 (installed via homebrew, build formula)
Minimum test code:
program test_zgetrf
implicit none
integer, parameter :: n = 4
! integer, parameter :: n = 3
integer :: i, j, info
integer :: ipiv(n)
complex(kind=kind(1.0d0)) :: A(n,n), L(n,n), U(n,n), row(n)
do j=1,n
do i=1,n
! this should trigger a divide by zero
! A(i,j) = i+j
! this should be fine
A(i,j) = mod(i+j, n)
end do
end do
! print *, "Original matrix A:"
! do i = 1, n
! print *, A(i,:)
! end do
! LU factorization
call zgetrf(n, n, A, n, ipiv, info)
if (info /= 0) then
print *, "zgetrf failed with info =", info
stop
end if
print *, "LU-factorized matrix A:"
do i = 1, n
print *, A(i,:)
end do
print *, "Pivot indices:"
print *, ipiv
L(:,:) = 0.d0; U(:,:) = 0.d0
do j=1,n
L(j,j) = 1.d0
do i=1,j
U(i,j) = A(i,j)
end do
do i=j+1,n
L(i,j) = A(i,j)
end do
end do
call zgemm('N', 'N', n, n, n, (1.d0, 0.d0), L, n, U, n, (0.d0, 0.d0), A, n)
do i=n,1,-1
row(:) = A(i,:)
A(i,:) = A(ipiv(i),:)
A(ipiv(i),:) = row(:)
end do
print *, "P.L.U="
do i = 1, n
print *, A(i,:)
end do
end program test_zgetrf
When compiled with gfortran (15.2.0)
gfortran -ffpe-trap=zero -L/opt/local/lib -lopenblas test_zgetrf.F90
produces
Program received signal SIGILL: Illegal instruction.
Note that this only happens with -ffpe-trap=zero. Without it, everything works fine.
Switching to apple's accelerate framework then it works.
Has been reproduced on
OS/CPU: macOS Tahoe 26.5, M4 and M2 CPU
Compiler: GCC (gfortran) 15.2.0
OpenBLAS 0.3.32 (installed via macports, build formula)
and
OS/CPU: - / M2 CPU
Compiler: GCC (gfortran) 15.2.0
OpenBLAS 0.3.33 (installed via homebrew, build formula)
Minimum test code:
When compiled with
gfortran(15.2.0)produces
Note that this only happens with
-ffpe-trap=zero. Without it, everything works fine.Switching to apple's accelerate framework then it works.