Re: Re[2]: [Haskell-cafe] Haskell performance question

2007-11-09 Thread Dan Piponi
On Nov 8, 2007 10:28 PM, Bulat Ziganshin [EMAIL PROTECTED] wrote:

 just for curiosity, can you try to manually unroll loop and see
 results?

I don't get any noticeable performance change when I unroll the loop
by 2 by hand. I suspect that on a modern CPU loop unrolling probably
isn't that much of a win. I'm more interested in strength reduction,
especially when computing things like indices into multidimensional
arrays. Anyone know how well ghc performs in this area?
--
Dan
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re[2]: [Haskell-cafe] Haskell performance question

2007-11-08 Thread Bulat Ziganshin
Hello Don,

Thursday, November 8, 2007, 10:53:28 PM, you wrote:

a - newArray (0,n-1) 1.0 :: IO (IOUArray Int Double)
forM_ [0..n-2] $ \i - do { x - readArray a i; y - readArray a
 (i+1); writeArray a (i+1) (x+y) }

oh, i was stupid. obviously, first thing you need to do is to use
unsafeRead/unsafeWrite operations. i'm wonder how this code is only
20x slower than C version, may be you need to use gcc -O3 -funroll-loops
and gcc3 (because gcc4 becomes slower)

-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re[2]: [Haskell-cafe] Haskell performance question

2007-11-08 Thread Bulat Ziganshin
Hello Dan,

Thursday, November 8, 2007, 10:12:04 PM, you wrote:

 The strictness gave me something like a 10% performance increase
 making the Haskell code more than 10 times slower than the C. Is this
 the right type of array to use for performance?

yes. but ghc is especially slow doing FP arithmetics. in my own simple
test ( a[i]=b[i]+c[i] ) it's 20x slower than gcc, so your results
aren't surprising

-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re[2]: [Haskell-cafe] Haskell performance question

2007-11-08 Thread Bulat Ziganshin
Hello Xiao-Yong,

Thursday, November 8, 2007, 10:41:11 PM, you wrote:

 forM_ [0..n-2] $ \i - do { return $! i;
 x - readArray a i; return $! x;
 y - readArray a (i+1); return $! y;
 writeArray a (i+1) (x+y) }

 such cycle should be approx. 3-10 times slower than C one

 I didn't know you can do that.  Anyway, I tried OP's C and
 Haskell versions and the one with your strictness
 annotations.  It seems that the `$!' thing doesn't do much,
 or it's not doing anything.

i don't said that it will help, just that it may help. to know
exactly, one should either understand ghc strictness analyzer, or
check asm code

-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re[2]: [Haskell-cafe] Haskell performance question

2007-11-08 Thread Bulat Ziganshin
Hello Dan,

Friday, November 9, 2007, 3:58:42 AM, you wrote:

 HSbase-3.0.0.0.o but I was able to rerun the timings for my code. WIth
 -O2 the run time went from about 1.5s to 0.2s. With unsafeRead and
 unsafeWrite that becomes 0.16s.

cool! seems that small loops now are runs on registers, in 6.6 each
step of such loop was about 50 instructions long, fetching everything
from memory

just for curiosity, can you try to manually unroll loop and see
results?

btw, this still doesn't mean that ghc can be used for
numeric-intensive code - it should be tried on larger code blocks. but
definitely, it's a whole new era in low-level ghc programming


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe