haskell version of fractal benchmark

i recently saw a (yet-another) benchark comparing various languages: http://www.timestretch.com/FractalBenchmark.html while no haskell example was listed, i thought i would try a naive implementation myself for comparison. it is available here: http://www.b7j0c.org/dev/haskell/misc/time.hs my timing of the compiled code was slightly under three seconds over a few tests, landing sort of where i would expect a naive haskell implementation to place. i am sure people here could greatly improve my attempt. it may be that my solution is not even correct.

clawsie:
i recently saw a (yet-another) benchark comparing various languages:
http://www.timestretch.com/FractalBenchmark.html
while no haskell example was listed, i thought i would try a naive implementation myself for comparison. it is available here:
http://www.b7j0c.org/dev/haskell/misc/time.hs
my timing of the compiled code was slightly under three seconds over a few tests, landing sort of where i would expect a naive haskell implementation to place. i am sure people here could greatly improve my attempt. it may be that my solution is not even correct.
There's also a mandelbrot generator on the shootout, http://shootout.alioth.debian.org/gp4/benchmark.php?test=mandelbrot&lang=ghc&id=4 Some things to remember using Doubles: * {-# OPTIONS -fexcess-precision #-} * -fvia-C * -fbang-patterns * -optc-O2 -optc-mfpmath=sse -optc-msse2 * -optc-march=pentium4 -- Don

[mailto:haskell-cafe-bounces@haskell.org] On Behalf Of Andrew Coppin
Donald Bruce Stewart wrote:
Some things to remember using Doubles:
* {-# OPTIONS -fexcess-precision #-} * -fvia-C * -fbang-patterns * -optc-O2 -optc-mfpmath=sse -optc-msse2 * -optc-march=pentium4
1. What do all those things do? 2. Is the effect actually that large?
Large? Depends what you mean by large, but adding a few flags to get just a 10-20% speedup isn't to be ignored: http://www.haskell.org/haskellwiki/Performance/GHC#Crank_up_the_gcc_flag s http://www.haskell.org/haskellwiki/Performance/Floating_Point Alistair ***************************************************************** Confidentiality Note: The information contained in this message, and any attachments, may contain confidential and/or privileged material. It is intended solely for the person(s) or entity to which it is addressed. Any review, retransmission, dissemination, or taking of any action in reliance upon this information by persons or entities other than the intended recipient(s) is prohibited. If you received this in error, please contact the sender and delete the material from any computer. *****************************************************************

* Andrew Coppin
Bayley, Alistair wrote:
[[1]mailto:haskell-cafe-bounces@haskell.org] On Behalf Of Andrew Coppin
Donald Bruce Stewart wrote:
Some things to remember using Doubles:
* {-# OPTIONS -fexcess-precision #-} * -fvia-C * -fbang-patterns * -optc-O2 -optc-mfpmath=sse -optc-msse2 * -optc-march=pentium4
1. What do all those things do? 2. Is the effect actually that large?
Large? Depends what you mean by large, but adding a few flags to get just a 10-20% speedup isn't to be ignored:
Sure - if it really is 10-20%. (And not, say, 0.001 - 0.002%.)
A single data point for all of this, I have a program that calculates: P^1_i = S_i/sum_k S_k P^m_i = sum_{k!=i} P^1_k*P^m-1_i(S_~k) Here's timings for the different options: options run time compile time none 46.401 3.136 -O 5.033 4.906 -O2 4.967 6.755 -O2 -fexcess-precision 3.710 6.396 all listed options 3.602 6.344 Results with -fexcess-precision are very insignificantly different (1.0 e-7).

sic:
* Andrew Coppin
[070608 02:45]: Bayley, Alistair wrote:
[[1]mailto:haskell-cafe-bounces@haskell.org] On Behalf Of Andrew Coppin
Donald Bruce Stewart wrote:
Some things to remember using Doubles:
* {-# OPTIONS -fexcess-precision #-} * -fvia-C * -fbang-patterns * -optc-O2 -optc-mfpmath=sse -optc-msse2 * -optc-march=pentium4
1. What do all those things do? 2. Is the effect actually that large?
Large? Depends what you mean by large, but adding a few flags to get just a 10-20% speedup isn't to be ignored:
Sure - if it really is 10-20%. (And not, say, 0.001 - 0.002%.)
A single data point for all of this, I have a program that calculates:
P^1_i = S_i/sum_k S_k P^m_i = sum_{k!=i} P^1_k*P^m-1_i(S_~k)
Here's timings for the different options:
options run time compile time none 46.401 3.136 -O 5.033 4.906 -O2 4.967 6.755 -O2 -fexcess-precision 3.710 6.396 all listed options 3.602 6.344
Due to a (now fixed in 6.6.1 I think) bug in GHC 6.6, -fexcess-precision *must* be inserted in a pragma. Did you do that? {-# OPTIONS -fexcess-precision #-} See the bug report here, http://hackage.haskell.org/trac/ghc/ticket/1138 -- Don

dons:
sic:
* Andrew Coppin
[070608 02:45]: Bayley, Alistair wrote:
[[1]mailto:haskell-cafe-bounces@haskell.org] On Behalf Of Andrew Coppin
Donald Bruce Stewart wrote:
Some things to remember using Doubles:
* {-# OPTIONS -fexcess-precision #-} * -fvia-C * -fbang-patterns * -optc-O2 -optc-mfpmath=sse -optc-msse2 * -optc-march=pentium4
1. What do all those things do? 2. Is the effect actually that large?
Large? Depends what you mean by large, but adding a few flags to get just a 10-20% speedup isn't to be ignored:
Sure - if it really is 10-20%. (And not, say, 0.001 - 0.002%.)
A single data point for all of this, I have a program that calculates:
P^1_i = S_i/sum_k S_k P^m_i = sum_{k!=i} P^1_k*P^m-1_i(S_~k)
Here's timings for the different options:
options run time compile time none 46.401 3.136 -O 5.033 4.906 -O2 4.967 6.755 -O2 -fexcess-precision 3.710 6.396 all listed options 3.602 6.344
My apologies. Misread that last line. /me drinks more tea. -- Don

andrewcoppin:
Donald Bruce Stewart wrote:
Some things to remember using Doubles:
* {-# OPTIONS -fexcess-precision #-} * -fvia-C * -fbang-patterns * -optc-O2 -optc-mfpmath=sse -optc-msse2 * -optc-march=pentium4
1. What do all those things do?
Check the GHC user's guide.
2. Is the effect actually that large?
1) {-# OPTIONS -fexcess-precision #- I've had this halved runtimes for runtimes for numeric-intensive programs. 2) -fvia-C Probably still worth 10% for Double-based stuff (maybe more). 3) -fbang-patterns Better than `seq` 4) -optc-O2 -optc-mfpmath=sse -optc-msse2 -optc-march=pentium4 Can be worth 0 to hmm, quite a few, percent, depending on the code. This is all assuming you've written low level code anyway, so that the effects of, say, using SSE instructions are actually apparent. -- Don

[mailto:haskell-cafe-bounces@haskell.org] On Behalf Of Donald Bruce Stewart
3) -fbang-patterns
Better than `seq`
Better in the "more convenient to write" sense, right? AFAIUI, seq and bang patterns should be equivalent. Alistair ***************************************************************** Confidentiality Note: The information contained in this message, and any attachments, may contain confidential and/or privileged material. It is intended solely for the person(s) or entity to which it is addressed. Any review, retransmission, dissemination, or taking of any action in reliance upon this information by persons or entities other than the intended recipient(s) is prohibited. If you received this in error, please contact the sender and delete the material from any computer. *****************************************************************

Alistair_Bayley:
[mailto:haskell-cafe-bounces@haskell.org] On Behalf Of Donald Bruce Stewart
3) -fbang-patterns
Better than `seq`
Better in the "more convenient to write" sense, right? AFAIUI, seq and bang patterns should be equivalent.
Yes, in the 'more convenient' sense. Adding strictness speculatively, while trying to debug a leak, is easier when inserting !, than to insert `seq`'s. It also doesn't obfuscate the code as much as the seq tricks do. -- Don

3) -fbang-patterns Better than `seq` Do you mean "more convenient than" or "generates better code than". I don't think the latter should be true; send a counterexample if you find one! Simon

Hello all, I have this class which gives a common interface to (UniqueIndex a k) and (MultiIndex a k) : class (Show a, Key_ k) => Index_ i a k | i -> k, k -> a where buildKey :: (a -> k) insertIndex :: Id -> a -> i -> Maybe i deleteIndex :: Id -> a -> i -> i updateIndex :: Id -> a -> a -> i -> Maybe i updateIndex id oldItem newItem index = insertIndex id newItem $ deleteIndex id oldItem index Now i need to have these indexes in a list, so i declared that type : data DbIndex = forall a k i. (Show a, Key_ k, Index_ i a k) => DbIndex i Up to this point everything is fine, I can create concrete Indexes and put these different index types in the same list, after wrapping them in a DbIndex. But i don't seem to find a way to get out of this DbIndex type to actually work on the enclosed index. for instance, this doesn't work: liftDbIndex (DbIndex index) fun = DbIndex (fun index) this doesn't work either : dbIndexBuildKey (DbIndex index) value = (buildKey index) value How can i access the enclosed concrete index, via its Index_ class ? Maybe am I totally on the wrong track ? Thanks in advance, Sacha
participants (7)
-
Andrew Coppin
-
Bayley, Alistair
-
brad clawsie
-
dons@cse.unsw.edu.au
-
Phlex
-
Scott Cruzen
-
Simon Peyton-Jones