[Haskell-cafe] Floyd Warshall performance (again)

2010-04-16 Thread Mathieu Boespflug
Dear haskell-cafe, I implemented the Floyd Warshall algorithm for finding the shortest path in a dense graph in Haskell, but noted the performance was extremely poor compared to C. Even using mutable unboxed arrays it was running about 30 times slower. I rewrote the program several times, to

Re: [Haskell-cafe] Floyd Warshall performance (again)

2010-04-16 Thread Bulat Ziganshin
Hello Mathieu, Friday, April 16, 2010, 12:06:06 PM, you wrote: actions and then running them using sequence_. But still this program runs 3 times slower than it's C counterpart: ghc low-level code optimization cannot be compared with best modern C compilers that's result of 20 years of

Re: [Haskell-cafe] Floyd Warshall performance (again)

2010-04-16 Thread Mathieu Boespflug
Hi Bulat, ghc low-level code optimization cannot be compared with best modern C compilers that's result of 20 years of optimization. ghc generates machine code in rather simple idiomatic way, so it should be compared to non-optimizing C compiler Sure. But I was curious if to see whether

Re[2]: [Haskell-cafe] Floyd Warshall performance (again)

2010-04-16 Thread Bulat Ziganshin
Hello Mathieu, Friday, April 16, 2010, 12:42:29 PM, you wrote: Sure. But I was curious if to see whether there was some optimization I had missed, seeing as other similarly low level programs, such as the nsieve benchmark of the language shootout, or the word counting program, manage to run

Re: [Haskell-cafe] Floyd Warshall performance (again)

2010-04-16 Thread Max Bolingbroke
For what is is worth: $ ghc -cpp -O2 -ddump-asm Main.hs Main.s $ time ./a.out Allocating ... Allocating ... done real0m39.487s user0m39.258s sys 0m0.150s $ ~/Programming/Checkouts/ghc.llvm/inplace/bin/ghc-stage2 -cpp -fllvm -O2 Main.hs $ time ./a.out Allocating ... Allocating ...

Re: [Haskell-cafe] Floyd Warshall performance (again)

2010-04-16 Thread Roman Leshchinskiy
On 16/04/2010, at 18:06, Mathieu Boespflug wrote: shortestPath :: [(Int, Int, Int)] - UArray Int Int shortestPath g = runSTUArray $ do let mnew = newArray (0, SIZE * SIZE) 1 mread arr i j = unsafeRead arr (i * SIZE + j) mwrite arr i j x = unsafeWrite arr (i * SIZE + j) x

Re: [Haskell-cafe] Floyd Warshall performance (again)

2010-04-16 Thread John Lato
From: Mathieu Boespflug mb...@tweag.net Dear haskell-cafe, I implemented the Floyd Warshall algorithm for finding the shortest path in a dense graph in Haskell, but noted the performance was extremely poor compared to C. Even using mutable unboxed arrays it was running about 30 times

Re: [Haskell-cafe] Floyd Warshall performance (again)

2010-04-16 Thread Mathieu Boespflug
Hi John, your transformation on the original program amounts to replacing all occurrences of a Haskell literal with a Haskell variable. You will therefore end up with something that looks like this : loop sIZE = return () loop j = ... sIZE is now a pattern variable, that is, the pattern of the

Re[2]: [Haskell-cafe] Floyd Warshall performance (again)

2010-04-16 Thread Bulat Ziganshin
Hello John, Friday, April 16, 2010, 7:41:06 PM, you wrote: sIZE = 1500 and all references from SIZE to sIZE, something ... changes. A lot. this one too? :D let loop2 SIZE = return () -- Best regards, Bulatmailto:bulat.zigans...@gmail.com

Re: [Haskell-cafe] Floyd Warshall performance (again)

2010-04-16 Thread Daniel Fischer
Am Freitag 16 April 2010 17:41:06 schrieb John Lato: From: Mathieu Boespflug mb...@tweag.net Dear haskell-cafe, I implemented the Floyd Warshall algorithm for finding the shortest path in a dense graph in Haskell, but noted the performance was extremely poor compared to C. Even using

Re: [Haskell-cafe] Floyd Warshall performance (again)

2010-04-16 Thread John Lato
On Fri, Apr 16, 2010 at 5:02 PM, Daniel Fischer daniel.is.fisc...@web.de wrote: Am Freitag 16 April 2010 17:41:06 schrieb John Lato: From: Mathieu Boespflug mb...@tweag.net Dear haskell-cafe, I implemented the Floyd Warshall algorithm for finding the shortest path in a dense graph in