public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/106565] New: Using a transposed matrix in matmul (GCC-10.3.0) is very slow
@ 2022-08-08 20:04 quanhua.liu at noaa dot gov
  2022-08-09  7:50 ` [Bug fortran/106565] " rguenth at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: quanhua.liu at noaa dot gov @ 2022-08-08 20:04 UTC (permalink / raw)
  To: gcc-bugs

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

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

end of thread, other threads:[~2022-08-09 18:20 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-08 20:04 [Bug fortran/106565] New: Using a transposed matrix in matmul (GCC-10.3.0) is very slow quanhua.liu at noaa dot gov
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

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