public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/38318] New: moving the allocation of temps out of loops.
@ 2008-11-29 16:17 jv244 at cam dot ac dot uk
2008-12-06 20:29 ` [Bug fortran/38318] " tkoenig at gcc dot gnu dot org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: jv244 at cam dot ac dot uk @ 2008-11-29 16:17 UTC (permalink / raw)
To: gcc-bugs
consider the following source and timings, were a natural form of a subroutine
S1, and two hand optimized forms are timed:
> cat test.f90
SUBROUTINE S1(N,A)
REAL :: A(3)
DO I=1,N
CALL S2(-A)
ENDDO
END SUBROUTINE
SUBROUTINE S1_opt1(N,A)
REAL :: A(3)
REAL, ALLOCATABLE :: B(:)
ALLOCATE(B(SIZE(A,1)))
DO I=1,N
B=-A
CALL S2(B)
ENDDO
END SUBROUTINE
SUBROUTINE S1_opt2(N,A)
REAL :: A(3),B(3)
DO I=1,N
B=-A
CALL S2(B)
ENDDO
END SUBROUTINE
> cat main.f90
SUBROUTINE S2(A)
REAL :: A(*),D
COMMON /F/D
D=D+A(1)+A(2)+A(3)
END SUBROUTINE
INTEGER, PARAMETER :: N=100000
REAL :: A(3),T1,T2,T3,T4,D
COMMON /F/D
D=0.0
A=0.0
CALL CPU_TIME(T1)
DO I=1,10000
CALL S1(N,A)
ENDDO
CALL CPU_TIME(T2)
DO I=1,10000
CALL S1_opt1(N,A)
ENDDO
CALL CPU_TIME(T3)
DO I=1,10000
CALL S1_opt2(N,A)
ENDDO
CALL CPU_TIME(T4)
write(6,*) "Default [s]:",T2-T1
write(6,*) "OPT1 [s]:",T3-T2
write(6,*) "OPT2 [s]:",T4-T3
write(6,*) D
END
gfortran-4.4 -O3 test.f90 main.f90
Default [s]: 18.293142
OPT1 [s]: 6.2603912
OPT2 [s]: 6.2563915
ifort -O3 test.f90 main.f90
Default [s]: 6.256391
OPT1 [s]: 6.252390
OPT2 [s]: 6.256390
so, gfortran by default is about 3x slower than ifort, which by default moves
the generation of the temporaries out of the loop.
FYI, allowing for multi file IPO, I hope LTO gets that far...
ifort -O3 -fast test.f90 main.f90 (includes ipo)
Default [s]: 3.752234
OPT1 [s]: 1.276080
OPT2 [s]: 3.752234
--
Summary: moving the allocation of temps out of loops.
Product: gcc
Version: 4.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: jv244 at cam dot ac dot uk
OtherBugsDependingO 36854
nThis:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38318
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug fortran/38318] moving the allocation of temps out of loops.
2008-11-29 16:17 [Bug fortran/38318] New: moving the allocation of temps out of loops jv244 at cam dot ac dot uk
@ 2008-12-06 20:29 ` tkoenig at gcc dot gnu dot org
2010-02-21 9:12 ` jv244 at cam dot ac dot uk
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2008-12-06 20:29 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from tkoenig at gcc dot gnu dot org 2008-12-06 20:25 -------
This could also be useful when done in the middle-end,
see PR 21046.
--
tkoenig at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
BugsThisDependsOn| |21046
Severity|normal |enhancement
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2008-12-06 20:25:54
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38318
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug fortran/38318] moving the allocation of temps out of loops.
2008-11-29 16:17 [Bug fortran/38318] New: moving the allocation of temps out of loops jv244 at cam dot ac dot uk
2008-12-06 20:29 ` [Bug fortran/38318] " tkoenig at gcc dot gnu dot org
@ 2010-02-21 9:12 ` jv244 at cam dot ac dot uk
2010-02-21 11:07 ` burnus at gcc dot gnu dot org
2010-02-21 12:12 ` [Bug middle-end/38318] " jv244 at cam dot ac dot uk
3 siblings, 0 replies; 5+ messages in thread
From: jv244 at cam dot ac dot uk @ 2010-02-21 9:12 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from jv244 at cam dot ac dot uk 2010-02-21 09:12 -------
seemingly being discussed, since useful for tonto
http://gcc.gnu.org/ml/fortran/2010-02/msg00157.html
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38318
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug fortran/38318] moving the allocation of temps out of loops.
2008-11-29 16:17 [Bug fortran/38318] New: moving the allocation of temps out of loops jv244 at cam dot ac dot uk
2008-12-06 20:29 ` [Bug fortran/38318] " tkoenig at gcc dot gnu dot org
2010-02-21 9:12 ` jv244 at cam dot ac dot uk
@ 2010-02-21 11:07 ` burnus at gcc dot gnu dot org
2010-02-21 12:12 ` [Bug middle-end/38318] " jv244 at cam dot ac dot uk
3 siblings, 0 replies; 5+ messages in thread
From: burnus at gcc dot gnu dot org @ 2010-02-21 11:07 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from burnus at gcc dot gnu dot org 2010-02-21 11:06 -------
(In reply to comment #2)
> seemingly being discussed, since useful for tonto
>
> http://gcc.gnu.org/ml/fortran/2010-02/msg00157.html
>
But there: "it's unfortunately not possible to avoid the temporary creation
without serious data-flow analysis work - too late for the frontend"
Thus, this seems to be more a middle-end item.
Regarding the current timing, I get with ifort -O3 -fast (v 11.1) vs.
gfortran -flto -fwhole-program -O3 --fast-math -march=native (today's 4.5) It
is also interesting that gfortran is much faster for the optimized version than
ifort.
gfortran ifort
Default [s]: 24.881554 Default [s]: 5.108319
OPT1 [s]: 1.6641045 OPT1 [s]: 3.280205
OPT2 [s]: 1.6641045 OPT2 [s]: 4.988311
0.0000000 0.0000000E+00
real 0m28.420s real 0m13.400s
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38318
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug middle-end/38318] moving the allocation of temps out of loops.
2008-11-29 16:17 [Bug fortran/38318] New: moving the allocation of temps out of loops jv244 at cam dot ac dot uk
` (2 preceding siblings ...)
2010-02-21 11:07 ` burnus at gcc dot gnu dot org
@ 2010-02-21 12:12 ` jv244 at cam dot ac dot uk
3 siblings, 0 replies; 5+ messages in thread
From: jv244 at cam dot ac dot uk @ 2010-02-21 12:12 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from jv244 at cam dot ac dot uk 2010-02-21 12:11 -------
(In reply to comment #3)
> (In reply to comment #2)
> > seemingly being discussed, since useful for tonto
> >
> > http://gcc.gnu.org/ml/fortran/2010-02/msg00157.html
> >
>
> But there: "it's unfortunately not possible to avoid the temporary creation
> without serious data-flow analysis work - too late for the frontend"
>
> Thus, this seems to be more a middle-end item.
right, changing component as such. This would actually be much more powerful as
a middle-end thing, since it would also capture the case where a programmer
would explicitly allocate/deallocate stuff in a loop.
--
jv244 at cam dot ac dot uk changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|fortran |middle-end
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38318
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-02-21 12:12 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-29 16:17 [Bug fortran/38318] New: moving the allocation of temps out of loops jv244 at cam dot ac dot uk
2008-12-06 20:29 ` [Bug fortran/38318] " tkoenig at gcc dot gnu dot org
2010-02-21 9:12 ` jv244 at cam dot ac dot uk
2010-02-21 11:07 ` burnus at gcc dot gnu dot org
2010-02-21 12:12 ` [Bug middle-end/38318] " jv244 at cam dot ac dot uk
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).