|
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
mecej4
Joined: 31 Oct 2006 Posts: 1886
|
Posted: Sat Mar 09, 2024 6:35 pm Post subject: Labelled DO loop and /opt /64 leads to optimisation bug |
|
|
The following is what is left after trimming a 25,000 LOC Fortran 95 program to pin down a suspected optimisation bug.
Code: | program labDObug
implicit none
integer, parameter :: nx = 5, ny = 1, nz = 1
integer i, j, k, ij, ik
integer :: np(nx,ny), ktop(nx)
np(:,1) = (/ (i, i=1,nx) /)
ktop = 0
do j = 1,ny
iLoop: DO i = 1, nx
ij = (j-1)*nx + i
do k = nz, 1, -1
ik = (k-1)*nx + i
if (np(ik,j) /= 0) then
ktop(ij) = k
cycle iLoop
endif
end do !k
end do iLoop
end do !j
print '(1x,10i5)',ktop
end program |
The output when the options /opt /64 are used:
The correct output, which is obtained with /64 alone, or in 32-bit compilations with or without /opt:
In this tiny program, replacing "cycle iLoop" by "exit" makes the bug go away. |
|
Back to top |
|
|
JohnCampbell
Joined: 16 Feb 2006 Posts: 2554 Location: Sydney
|
Posted: Sun Mar 10, 2024 5:31 am Post subject: |
|
|
The following update identifies that ij is not being updated in the do i loop if /opt is selected
Code: | program labDObug
use iso_fortran_env
implicit none
integer, parameter :: nx = 5, ny = 1, nz = 1
integer i, j, k, ij, ik, n
integer :: np(nx,ny), ktop(nx)
write (*,*) 'Vern : ',compiler_version ()
write (*,*) 'Opts : ',compiler_options ()
np(:,1) = (/ (i, i=1,nx) /)
ktop = 0
n = 0
do j = 1,ny
iLoop: DO i = 1, nx
ij = (j-1)*nx + i
do k = nz, 1, -1
n = n+1
ik = (k-1)*nx + i
if (np(ik,j) /= 0) then
ktop(ij) = k
cycle iLoop
endif
end do !k
end do iLoop
end do !j
print '(1x,10i5)',ktop
print '(1x,10i5)',n,ij
end program |
|
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7928 Location: Salford, UK
|
Posted: Mon Mar 18, 2024 10:28 am Post subject: |
|
|
mecej4 and John
Thank you for the feedback. This failure has now been fixed for the next release of FTN95. The optimisation in question is number 30. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|