After glibc maintainers changed "math-vector-fortran.h" install directory, gfortran can no longer use it.
This the old behavior Ubuntu 19.10 gcc-9.2.1 glibc 2.30
$ gfortran -O3 -mavx2 vect_test.f90 -o test.x
$ nm ./test.x | grep sin
U _ZGVdN4v_sin@@GLIBC_2.22
U _ZGVdN8v_sinf@@GLIBC_2.22
After that change : Ubuntu 20.04 gcc-9.3.0 glibc 2.31
$ gfortran -O3 -mavx2 vect_test.f90 -o test.x
$ nm ./test.x | grep sinn
U sin@@GLIBC_2.2.5
U sinf@@GLIBC_2.2.5
$ cat vect_test.f90
program test_vect
implicit none
integer, parameter :: n = 64*1024**2
integer :: i
integer(8) :: t1, t2, t0
real(8) :: tic
!
real, allocatable :: a32(:), b32(:)
real(8), allocatable :: a64(:), b64(:)
!
allocate( a32(n), a64(n))
allocate( b32(n), b64(n))
!
call random_number(a32 )
call random_number(a64 )
!
call system_clock(t0, tic)
!
do i = 1, n
b32(i) = sin(a32(i))
end do
!
call system_clock(t1)
print*, (t1-t0)/tic
!
do i = 1, n
b64(i) = sin(a64(i))
end do
!
call system_clock(t2)
print*, (t2-t1)/tic
!
end program test_vect
As you can see gfortran is not preincluding "math-vector-fortran.h" file on Ubuntu 20.04.
A workaround is to copy "math-vector-fortran.h" to /usr/include/finclude (which is empty!).
After glibc maintainers changed "math-vector- fortran. h" install directory, gfortran can no longer use it.
This the old behavior Ubuntu 19.10 gcc-9.2.1 glibc 2.30 sin@@GLIBC_ 2.22 sinf@@GLIBC_ 2.22
$ gfortran -O3 -mavx2 vect_test.f90 -o test.x
$ nm ./test.x | grep sin
U _ZGVdN4v_
U _ZGVdN8v_
After that change : Ubuntu 20.04 gcc-9.3.0 glibc 2.31
$ gfortran -O3 -mavx2 vect_test.f90 -o test.x
$ nm ./test.x | grep sinn
U sin@@GLIBC_2.2.5
U sinf@@GLIBC_2.2.5
$ cat vect_test.f90
program test_vect
implicit none
integer, parameter :: n = 64*1024**2
integer :: i
integer(8) :: t1, t2, t0
real(8) :: tic
!
real, allocatable :: a32(:), b32(:)
real(8), allocatable :: a64(:), b64(:)
!
allocate( a32(n), a64(n))
allocate( b32(n), b64(n))
!
call random_number(a32 )
call random_number(a64 )
!
call system_clock(t0, tic)
!
do i = 1, n
b32(i) = sin(a32(i))
end do
!
call system_clock(t1)
print*, (t1-t0)/tic
!
do i = 1, n
b64(i) = sin(a64(i))
end do
!
call system_clock(t2)
print*, (t2-t1)/tic
!
end program test_vect
Verbose:
Ubuntu 19.10 gcc/x86_ 64-linux- gnu/9/f951 vect_test.f90 -quiet -dumpbase vect_test.f90 -mavx2 -mtune=generic -march=x86-64 -auxbase vect_test -O3 -version -fintrinsic- modules- path /usr/lib/ gcc/x86_ 64-linux- gnu/9/finclude -fpre-include= /usr/include/ finclude/ math-vector- fortran. h -o /tmp/cc2E2K8s.s
$ gfortran -O3 -mavx2 -v vect_test.f90 -o test.x
...
/usr/lib/
...
Ubuntu 20.04 gcc/x86_ 64-linux- gnu/9/f951 vect_test.f90 -quiet -dumpbase vect_test.f90 -mavx2 -mtune=generic -march=x86-64 -auxbase vect_test -O3 -version -fintrinsic- modules- path /usr/lib/ gcc/x86_ 64-linux- gnu/9/finclude -o /tmp/cc4swJwz.s
$ gfortran -O3 -mavx2 -v vect_test.f90 -o test.x
...
/usr/lib/
...
As you can see gfortran is not preincluding "math-vector- fortran. h" file on Ubuntu 20.04. fortran. h" to /usr/include/ finclude (which is empty!).
A workaround is to copy "math-vector-