Re[2]: [Haskell-cafe] How to improve speed? (MersenneTwister is several times slower than C version)

2006-11-03 Thread Bulat Ziganshin
Hello Donald,

Thursday, November 2, 2006, 2:21:31 PM, you wrote:

 10-20 times difference is typical for GHC programs.

 It's really more like 2-4x. Sometimes better than C.

 Where's this huge figure coming from Bulat? If you have code that
 behaves like this, you should report it.

are you analyzed the cases where performance is close or even better?
i does. it's either because C version is limited by memory performance
or just use different, less efficient algorithm

the cases which shows slowness of ghc-generated code is factorial
algorithm and the program attached. despite that Haskell code is far
uglier, C version outperforms it 20 times. run both programs with
arrays of about 10k elements to see the difference:

a.out 1 elements 10 iterations

in February i've written detailed explanation (in ghc-users) of why this
comes and made some suggestions on improving it. of course, main
problem is ghc's own code generator which is far away from gcc or even
ocaml ones

-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

full.c
Description: Binary data


newest.hs
Description: Binary data
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re[2]: [Haskell-cafe] How to improve speed? (MersenneTwister is several times slower than C version)

2006-11-02 Thread Bulat Ziganshin
Hello Lennart,

Thursday, November 2, 2006, 4:34:04 AM, you wrote:

 A big problem with the Mersenne Twister is the shifts.  As has been  
 noted elsewhere, ghc doesn't do such a great job on those.

#ifdef __GLASGOW_HASKELL__

(I# a) # (I# b) = (I# (a `iShiftL#` b))
(I# a) # (I# b) = (I# (a `uncheckedIShiftRL#` b))

#else /* ! __GLASGOW_HASKELL__ */

a # b = a `shiftL` b
a # b = a `shiftR` b

#endif /* ! __GLASGOW_HASKELL__ */



-- 
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] How to improve speed? (MersenneTwister is several times slower than C version)

2006-11-02 Thread Bulat Ziganshin
Hello Lennart,

Thursday, November 2, 2006, 6:04:39 AM, you wrote:

 The whole point of writing the Mersenne Twister was that I wanted to  
 show how a stateful computation could be encapsulated in the ST monad
 and none of it showing up outside.  This aspect of the code is  
 totally gone now when everything is in the IO monad.  Is there some  
 good reason to have it in the IO monad?

i think no. ST computations internally are really the same as IO ones



-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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