public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/37131]  New: inline matmul for small matrix sizes
@ 2008-08-15 19:24 tkoenig at gcc dot gnu dot org
  2008-08-16 22:56 ` [Bug fortran/37131] " pinskia at gcc dot gnu dot org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2008-08-15 19:24 UTC (permalink / raw)
  To: gcc-bugs

Ouch.

This is a factor of 20 for this simple test case on my computer.

$ cat foo.f90
program main
  real, dimension(3,3) :: a,b,c
  call random_number(a)
  call random_number(b)
  do i=1,10**8
    c = matmul(a,b)
    a(1,1) = a(1,1) + b(1,1) - c(1,1)
  end do
  print *,c
end program main

$ gfortran -O3 foo.f90
$ time ./a.out
  0.34224379      0.27477881      0.48155165      0.76788843      0.65491939   
   1.2103429      0.38770726      0.38460296      0.87301219

real    0m20.733s
user    0m19.585s
sys     0m0.000s
$ cat bar.f90
program main
  real, dimension(3,3) :: a,b,c
  call random_number(a)
  call random_number(b)
  do i=1,10**8
    forall (i=1:3)
      forall (j=1:3)
        c(i,j) = sum(a(i,:) * b(:,j))
      end forall
    end forall
    a(1,1) = a(1,1) + b(1,1) - c(1,1)
  end do
  print *,c
end program main

$ gfortran -O3 bar.f90
$ time ./a.out
  0.34224379      0.27477881      0.48155165      0.76788843      0.65491939   
   1.2103429      0.38770726      0.38460296      0.87301219

real    0m1.075s
user    0m1.060s
sys     0m0.000s
$


-- 
           Summary: inline matmul for small matrix sizes
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tkoenig at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37131


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

end of thread, other threads:[~2010-06-05 18:27 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-15 19:24 [Bug fortran/37131] New: inline matmul for small matrix sizes tkoenig at gcc dot gnu dot org
2008-08-16 22:56 ` [Bug fortran/37131] " pinskia at gcc dot gnu dot org
2008-08-23 13:20 ` tkoenig at gcc dot gnu dot org
2008-11-29 16:20 ` burnus at gcc dot gnu dot org
2008-12-04 20:00 ` tkoenig at gcc dot gnu dot org
2008-12-09 22:13 ` tkoenig at gcc dot gnu dot org
2010-05-14  9:15 ` tkoenig at gcc dot gnu dot org
2010-06-04 22:32 ` tkoenig at gcc dot gnu dot org
2010-06-05  6:55 ` paul dot richard dot thomas at gmail dot com
2010-06-05  8:49 ` tkoenig at gcc dot gnu dot org
2010-06-05  9:31 ` mikael at gcc dot gnu dot org
2010-06-05 18:27 ` tkoenig at netcologne dot de

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