From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 10A383856DCB; Tue, 9 Aug 2022 17:17:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 10A383856DCB From: "quanhua.liu at noaa dot gov" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/106565] Using a transposed matrix in matmul (GCC-10.3.0) is very slow Date: Tue, 09 Aug 2022 17:17:57 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 10.3.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: quanhua.liu at noaa dot gov X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P4 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Aug 2022 17:17:58 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D106565 --- Comment #5 from Quanhua Liu --- Hi Richard, Using -fexternal-blas for gfortran v10.3.0 is much slower than the method 2: =C2=A0 BB =3D transpose(B) =C2=A0 C =3D matmul(A, BB) How about on your machine? Thanks, Quanhua Liu On 8/9/2022 11:07 AM, kargl at gcc dot gnu.org wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D106565 > > kargl at gcc dot gnu.org changed: > > What |Removed |Added > -------------------------------------------------------------------------= --- > CC| |kargl at gcc dot gnu.org > > --- Comment #3 from kargl at gcc dot gnu.org --- > >> INTEGER, PARAMETER :: m =3D 200, n =3D 300, nn =3D 150 >> REAL :: A(m,n), B(nn,n), C(m,nn), BB(n,nn) >> INTEGER :: i, j, k, L > > If you are doing a problem of this size or larger, you want to use the > -fexternal-blas option and link in OpenBLAS. > > I added timing code and replicated the loop to both in one go. > > % gfcx -o z -O3 -march=3Dnative a.f90 && ./z > 1.16500998 1615.08594 > 5.32258606 1615.08020 > % gfcx -o z -O3 -march=3Dnative a.f90 -fexternal-blas -lopenblas && ./z > 2.44668889 1615.08301 > 1.99379802 1615.08301 >=