From: Steve Kargl <sgk@troutmask.apl.washington.edu>
To: Thomas Koenig <tkoenig@netcologne.de>
Cc: Richard Biener <richard.guenther@gmail.com>,
Tobias Burnus <tobias@codesourcery.com>,
"fortran@gcc.gnu.org" <fortran@gcc.gnu.org>
Subject: Re: MATMUL broken with frontend optimization.
Date: Thu, 18 Mar 2021 15:07:58 -0700 [thread overview]
Message-ID: <20210318220758.GA26001@troutmask.apl.washington.edu> (raw)
In-Reply-To: <367461e9-72b4-0f8d-d04e-878789595942@netcologne.de>
On Thu, Mar 18, 2021 at 09:55:27PM +0100, Thomas Koenig wrote:
>
> > I haven't checked. If so, how about disabling
> > in-lining MATMUL for 11.1;
>
> Absolutely not for the general case. This would cause a huge regression
> in execution time for 2*2 matrices, and also for small matrix-vector
> multiplications.
>
> What we could do is only to enable the inlining for vector*matrix
> at -O2 or higher. Again, this will mean a penalty for smaller loops,
> but at less than -O2, people probably don't care too much.
>
On my old core2 cpu, a quick test with N=1000 and NxN matrix
suggest a cross over near N=1000 for REAL(4). This cpu doesn't
have any AVX* instruction, so YMMV. Program follows .sig
--
Steve
program t
implicit none
character(len=10) str
integer i, j
integer, parameter :: &
& n(10) = [100, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 10000]
real t0, t1, t3, t4
real, allocatable :: a(:), b(:,:), c(:)
!
! Loop over n(j) array. Run each test 5 times and average.
!
do j = 1, 10
allocate(a(n(j)), b(n(j),n(j)), c(n(j)))
a = 1
b = 1
t3 = 0
do i = 1, 5
call cpu_time(t0)
c = matmul(a, b)
call cpu_time(t1)
t3 = t3 + (t1 - t0)
if (c(1) /= n(j)) stop 1
end do
t4 = 0
do i = 1, 5
call cpu_time(t0)
c = matmul(b, a)
call cpu_time(t1)
t4 = t4 + (t1 - t0)
if (c(1) /= n(j)) stop 2
end do
print '(I5,1X,2(F8.4,1X))', n(j), (t3/5) * 1000, (t4/5) * 1000
deallocate(a, b, c)
end do
end program t
next prev parent reply other threads:[~2021-03-18 22:08 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-18 7:48 Steve Kargl
2021-03-18 12:35 ` Richard Biener
2021-03-18 14:48 ` Tobias Burnus
2021-03-18 15:05 ` Richard Biener
2021-03-18 16:13 ` Steve Kargl
2021-03-18 18:16 ` Thomas Koenig
2021-03-18 18:24 ` Thomas Koenig
2021-03-18 20:22 ` Steve Kargl
2021-03-18 20:55 ` Thomas Koenig
2021-03-18 22:07 ` Steve Kargl [this message]
2021-03-19 6:19 ` Thomas Koenig
2021-03-19 6:36 ` Thomas Koenig
2021-03-19 19:12 ` Steve Kargl
2021-03-19 7:03 ` Steve Kargl
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=20210318220758.GA26001@troutmask.apl.washington.edu \
--to=sgk@troutmask.apl.washington.edu \
--cc=fortran@gcc.gnu.org \
--cc=richard.guenther@gmail.com \
--cc=tkoenig@netcologne.de \
--cc=tobias@codesourcery.com \
/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).