public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "tkoenig at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/37131]  New: inline matmul for small matrix sizes
Date: Fri, 15 Aug 2008 19:24:00 -0000	[thread overview]
Message-ID: <bug-37131-10391@http.gcc.gnu.org/bugzilla/> (raw)

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


             reply	other threads:[~2008-08-15 19:24 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-15 19:24 tkoenig at gcc dot gnu dot org [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-37131-10391@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).