public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* (a+b)+c should be replaced by a+(b+c)
@ 2004-03-25 12:03 Joost VandeVondele
  2004-03-25 14:45 ` Robert Dewar
  0 siblings, 1 reply; 12+ messages in thread
From: Joost VandeVondele @ 2004-03-25 12:03 UTC (permalink / raw)
  To: gcc

I think there is an obvious need for doing the optimization
(a+b)+c -> a+(b+c) in e.g. many scientific codes.

consider matrix multiply
do k=1,N
 do j=1,N
  do i=1,N
   c(i,j)=c(i,j)+a(i,k)*b(k,j)
  enddo
 enddo
enddo

good compilers (e.g. xlf90) will (at -O4) do higher order transforms of
the loop to introduce blocking, independent FMAs, ... that makes this
little piece of code about 100 times faster at O4 than O2 (what about
LNO/SSA?). This can only be done if you allow (a+b)+c -> a+(b+c). It is
basically what any optimized blas routine will do. Matrix multiply is a
trivial example, if you want blas performance, call blas. There are many
other kernels like this in e.g. scientific code that are not blas. You
can't expect a scientist to hand unroll and block any kernel to the
appropriate depth for any machine. There need to be a compiler option to
do this. This can only be done if you allow (a+b)+c -> a+(b+c).

Joost

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2004-03-25 23:25 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-25 12:03 (a+b)+c should be replaced by a+(b+c) Joost VandeVondele
2004-03-25 14:45 ` Robert Dewar
2004-03-25 15:07   ` Joost VandeVondele
2004-03-25 15:18     ` Robert Dewar
2004-03-25 15:32       ` Joost VandeVondele
2004-03-25 15:59     ` Scott Robert Ladd
2004-03-25 16:18       ` Jakub Jelinek
2004-03-25 16:38         ` Scott Robert Ladd
2004-03-25 19:47           ` Laurent GUERBY
2004-03-25 20:16             ` Scott Robert Ladd
2004-03-26  2:51         ` Gabriel Paubert
2004-03-26  3:17           ` Jakub Jelinek

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).