public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "quanhua.liu at noaa dot gov" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/106565] New: Using a transposed matrix in matmul (GCC-10.3.0) is very slow
Date: Mon, 08 Aug 2022 20:04:23 +0000	[thread overview]
Message-ID: <bug-106565-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106565

            Bug ID: 106565
           Summary: Using a transposed matrix in matmul (GCC-10.3.0) is
                    very slow
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: quanhua.liu at noaa dot gov
  Target Milestone: ---

gcc version 10.3.0 (GCC)
linux
Using  (2) BB = transpose(B)
           C = matmul(A, BB)
is 5 times faster than
using  (1) C = matmul(A, transpose(B))

ifort 19 doesn't have the problem.


      PROGRAM test_matrixCal
! ------------------------------------------------------
! This code test
!  (1)   C = matmul(A, transpose(B))        
!  against 
!  (2)   BB = transpose(B)
!        C = matmul(A, BB)
!  (2) is 5 times faster than (1)
!   gfortran -O3 test_matrixCal
!   time a.ot
! ------------------------------------------------------
      INTEGER, PARAMETER :: m = 200, n = 300, nn = 150
      REAL :: A(m,n), B(nn,n), C(m,nn), BB(n,nn)
      INTEGER :: i, j, k, L
      A(:,:) = 3.0
      B(:,:) = 1.7

      iterative_loop: DO L = 1, 1000
         A(:,10) = A(:,10) + 0.0001*L
!         C = matmul(A, transpose(B))
         BB = transpose(B)
         C = matmul(A, BB)
      IF(mod(L,50) == 0)   print *,L, C(10,20)
      END DO iterative_loop
      STOP
      END PROGRAM test_matrixCal

             reply	other threads:[~2022-08-08 20:04 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-08 20:04 quanhua.liu at noaa dot gov [this message]
2022-08-09  7:50 ` [Bug fortran/106565] " rguenth at gcc dot gnu.org
2022-08-09 14:01 ` quanhua.liu at noaa dot gov
2022-08-09 15:07 ` kargl at gcc dot gnu.org
2022-08-09 15:08 ` kargl at gcc dot gnu.org
2022-08-09 17:14 ` quanhua.liu at noaa dot gov
2022-08-09 17:17 ` quanhua.liu at noaa dot gov
2022-08-09 17:51 ` sgk at troutmask dot apl.washington.edu
2022-08-09 17:53 ` sgk at troutmask dot apl.washington.edu
2022-08-09 17:55 ` sgk at troutmask dot apl.washington.edu
2022-08-09 18:20 ` quanhua.liu at noaa dot gov

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-106565-4@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).