[Bug fortran/89204] New: -floop-interchange has no effect on Fortran code
chinoune.mehdi at hotmail dot com
gcc-bugzilla@gcc.gnu.org
Tue Feb 5 10:24:00 GMT 2019
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89204
Bug ID: 89204
Summary: -floop-interchange has no effect on Fortran code
Product: gcc
Version: 8.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: chinoune.mehdi at hotmail dot com
Target Milestone: ---
On 7 Dec 2017 Bin Cheng had introduced a better implementation of
-floop-interchange
https://gcc.gnu.org/ml/gcc-patches/2017-12/msg00360.html
bou it looks like it doesn't affect Fortran
#define M 2048
int a[M][M], b[M][M], c[M][M];
void matrix_mul (int n)
{
for (int k = 0; k < n; k++)
for (int j = 0; j < n; j++)
for (int i = 0; i < n; i++)
c[i][j] = c[i][j] + a[i][k]*b[k][j];
}
static void init (int i)
{
for (int j = 0; j < M; j++)
{
a[i][j] = i;
b[i][j] = j;
c[i][j] = 0;
}
}
int main (void)
{
for (int i = 0; i < M; ++i)
init (i);
matrix_mul (M);
return 0;
}
gcc-8 -O2 -floop-interchange -fopt-info loop-interchange-7.c -o test
loop-interchange-7.c:11:7: note: loops interchanged in loop nest
time ./test
real
0m7.759s
user 0m7.656s
sys 0m0.031s
module mod_
implicit none
integer, parameter :: m = 2048
integer :: a(m,m), b(m,m), c(m,m)
contains
subroutine matrix_mul(n)
integer, intent(in) :: n
integer :: i, j, k
do i = 1, n
do j = 1, n
do k = 1, n
c(i,j) = c(i,j) + a(i,k)*b(k,j)
end do
end do
end do
end subroutine matrix_mul
subroutine init(i)
integer, intent(in) :: i
integer :: j
a(i,:) = i
do j = 1, m
b(i,j) = j
end do
end subroutine init
end module mod_
program main
use mod_
implicit none
integer :: i
c = 0
do i = 1, m
call init(i)
end do
call matrix_mul(m)
end program main
gfortran-8 -O2 -floop-interchange -fopt-info loop-interchange-7.f90 -o test
time ./test
real
1m30.447s
user
1m30.266s
sys 0m0.063s
More information about the Gcc-bugs
mailing list