public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/36241]  New: Executable compiled with -m64 almost three times faster than the one compiled with -m32 on Core2Duo
@ 2008-05-15  8:05 dominiq at lps dot ens dot fr
  2008-05-15  9:07 ` [Bug target/36241] " rguenth at gcc dot gnu dot org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: dominiq at lps dot ens dot fr @ 2008-05-15  8:05 UTC (permalink / raw)
  To: gcc-bugs

The following code (borrowed from
http://gcc.gnu.org/ml/gcc/2008-05/msg00134.html):

integer(8), parameter :: l = z'5fe6eb3be0000000'
integer, parameter :: ni = 3
integer :: i, j, n
integer(8) :: k
real(8) :: a, b, e, m, s
equivalence (b, k)
a = 1.0d0
e = epsilon(1.0)/2.0d0**4
m = 0.0d0
s = 0.0d0
n = 0
do
  n = n + 1
  b = a
  k = l - ishft(k, -1_8)
  do i = 1, ni
    b = b*(1.5-(0.5*a)*b*b)
  end do
  b = b + b*(0.5-(0.5*a)*b*b)
!   b = 1.0d0/sqrt(a)
  m = max(m, abs(a*b*b - 1.0d0))
  s = s + abs(a*b*b - 1.0d0)
  a = a + e
  if (a == 2.0d0) exit
end do
print *, n, m/epsilon(a), s/(n*epsilon(a))
end

gives the following timings:

[ibook-dhum] bug/timing% gfc -m64 -O3 rsqrt_8_nr_v1_s.f90
[ibook-dhum] bug/timing% time a.out
   134217728   2.0000000000000000       0.36966567113995552     
2.662u 0.008s 0:02.67 99.6%     0+0k 0+1io 0pf+0w

[ibook-dhum] bug/timing% gfc -m32 -O3 rsqrt_8_nr_v1_s.f90
[ibook-dhum] bug/timing% time a.out
   134217728   2.0000000000000000       0.36966567113995552     
7.401u 0.023s 0:07.42 100.0%    0+0k 0+0io 0pf+0w

For comparison the following code:

integer :: n
real(8) :: a, b, e, m, s
a = 1.0d0
e = epsilon(1.0)/2.0d0**4
s = 0.0d0
m = 0.0d0
n = 0
do
  n = n + 1
  b = 1.0d0/sqrt(a)
  s = s + abs(a*b*b - 1.0d0)
  m = max(m, abs(a*b*b - 1.0d0))
  a = a + e
  if (a == 2.0d0) exit
end do
print *, n, m/epsilon(a), s/(n*epsilon(a))
end

gives

[ibook-dhum] bug/timing% gfc -m64 -O3 rsqrt_8_s.f90
[ibook-dhum] bug/timing% time a.out
   134217728  1.00000000000000000       0.49419290572404861     
5.469u 0.002s 0:05.47 99.8%     0+0k 0+0io 0pf+0w
[ibook-dhum] bug/timing% gfc -m32 -O3 rsqrt_8_s.f90
[ibook-dhum] bug/timing% time a.out
   134217728  1.00000000000000000       0.49419290572404861     
5.475u 0.020s 0:05.49 100.0%    0+0k 0+0io 0pf+0w

Note that the later code is vectorized, while the former one is not.


-- 
           Summary: Executable compiled with -m64 almost three times faster
                    than the one compiled with -m32 on Core2Duo
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dominiq at lps dot ens dot fr
 GCC build triplet: i686-apple-darwin9
  GCC host triplet: i686-apple-darwin9
GCC target triplet: i686-apple-darwin9


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36241


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

end of thread, other threads:[~2009-06-29  8:47 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-05-15  8:05 [Bug target/36241] New: Executable compiled with -m64 almost three times faster than the one compiled with -m32 on Core2Duo dominiq at lps dot ens dot fr
2008-05-15  9:07 ` [Bug target/36241] " rguenth at gcc dot gnu dot org
2008-05-15  9:22 ` ubizjak at gmail dot com
2009-06-15 18:32 ` fxcoudert at gcc dot gnu dot org
2009-06-15 18:44 ` kargl at gcc dot gnu dot org
2009-06-16 20:30 ` dominiq at lps dot ens dot fr
2009-06-16 21:02 ` kargl at gcc dot gnu dot org
2009-06-17  9:19 ` ubizjak at gmail dot com
2009-06-29  8:47 ` ubizjak at gmail dot com

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