[Haskell-cafe] Re: speed: ghc vs gcc
Peter Verswyvelen
bugfact at gmail.com
Fri Feb 20 10:18:50 EST 2009
When I change the C++ program into:
int n;
scanf("%d", &n);
for(i=0; i<n;i++)
{
sum += i;
}
GCC need 100 milliseconds on my 3.0GHz new Xeon with loop unrolling
enabled.
Without loop unrolling GCC needs about 635ms
Visual C++ does it in 577 ms, generating the following code:
loop: add rbx,rax
inc rax
cmp rax,rcx
jl loop
GHC with -O2 -fvia-c (the fastest I could make it) needs
13075 for the naive sum
2100 ms with sum0
2018 ms using the stream-fusion
Interesting to see that the stream-fusion was slower when not doing -fvia-c
(more than twice as slow with -O)
So GHC is about 3 to 4 times slower as Visual C++ / GCC without loop
unrolling, which is not too bad since GHC does not perform register
optimization and loop unrolling yet no?
On Fri, Feb 20, 2009 at 3:44 PM, Achim Schneider <barsoap at web.de> wrote:
> Bulat Ziganshin <bulat.ziganshin at gmail.com> wrote:
>
>
> > execution times:
> > sum:
> > ghc 6.6.1 -O2 : 12.433 secs
> > ghc 6.10.1 -O2 : 12.792 secs
> > sum-fast:
> > ghc 6.6.1 -O2 : 1.919 secs
> > ghc 6.10.1 -O2 : 1.856 secs
> > ghc 6.10.1 -O2 -fvia-C : 1.966 secs
> > C++:
> > gcc 3.4.5 -O3 -funroll-loops: 0.062 secs
> >
> Nice! Now we know that gcc can calculate faster than Haskell can
> calculate and print. Next time, use exitWith, please.
>
>
> --
> (c) this sig last receiving data processing entity. Inspect headers
> for copyright history. All rights reserved. Copying, hiring, renting,
> performance and/or quoting of this signature prohibited.
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090220/98360fa8/attachment.htm
More information about the Haskell-Cafe
mailing list