Re: Floating point performance

2001-01-29 Thread Jan Kort

"Julian Seward (Intl Vendor)" wrote:
 
 I tried this, with ghc-4.08.1 -O both with and without
 profiling, on a Sparc box of I believe around 300 MHz,
 and I can't reproduce it at all.  Without profiling,
 it allocates about 505 k of heap and runs in 0.02
 seconds.
 
 Ummm ?
 
 J

I didn't use any optimizations, but I am sure that
passing -O to ghc will make it see that 1*1*... is a
constant expression. I guess turning all optimizations
off is not the right way to test stuff either.

  Jan

___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users



Re: Floating point performance

2001-01-29 Thread Marcin 'Qrczak' Kowalczyk

Mon, 29 Jan 2001 18:15:02 +0100, Jan Kort [EMAIL PROTECTED] pisze:

 I didn't use any optimizations, but I am sure that
 passing -O to ghc will make it see that 1*1*... is a
 constant expression.

It does not, because it's n*1*1*1*... where n is not a constant.
Major advantages seem to be from the strictness analysis.

-- 
 __("  Marcin Kowalczyk * [EMAIL PROTECTED] http://qrczak.ids.net.pl/
 \__/
  ^^  SYGNATURA ZASTPCZA
QRCZAK


___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users



RE: Floating point performance

2001-01-29 Thread Simon Marlow


 Fri, 26 Jan 2001 17:40:17 +0100, Jan Kort [EMAIL PROTECTED] pisze:
 
  I made a profile and it says most of the time (93%) is spent in
  the function bar.
 
 Did you compile with optimization turned on (option -O)?
 I see similar results without -O but quite different with -O.

Without optimisation, you get the native code generator which produces
particularly brain-dead code for floating point on x86 (mainly due to
Intel's brain-dead design of the x86 floating point unit).  With
optimisation, you get gcc.

Cheers,
Simon

___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users



Floating point performance

2001-01-26 Thread Jan Kort

Hi,
I noticed ghc (version 4.08.1) floating point performance is
really slow on my computer: a 270Mhz sun ultra5. The program
below does 1 milion floating point multiplications and takes
2 seconds to run. I made a profile and it says most of the
time (93%) is spent in the function bar. Any idea what is
going on ?

Regards,
  Jan

module Main where

foo :: Double - [Double]
foo 0 = [1]
foo n = bar n:foo (n-1)

bar :: Double - Double
bar n = n*1*1*1*1*1*1*1*1*1*1
 *1*1*1*1*1*1*1*1*1*1
 *1*1*1*1*1*1*1*1*1*1
 *1*1*1*1*1*1*1*1*1*1
 *1*1*1*1*1*1*1*1*1*1
 *1*1*1*1*1*1*1*1*1*1
 *1*1*1*1*1*1*1*1*1*1
 *1*1*1*1*1*1*1*1*1*1
 *1*1*1*1*1*1*1*1*1*1
 *1*1*1*1*1*1*1*1*1*1

foldl'   :: (a - b - a) - a - [b] - a
foldl' _ a [] = a
foldl' f a (x:xs) = (foldl' f $! f a x) xs

main :: IO()
main = putStrLn (show (foldl' (+) 0 (foo 1)))

---
Profile:

total time  =2.60 secs   (130 ticks @ 20 ms)
total alloc =  24,845,828 bytes  (excludes profiling overheads)

COST CENTRE  MODULE %time %alloc

bar  Main93.1   96.1
foo  Main 3.12.4
foldl'   Main 3.11.4


  individual inherited
COST CENTRE  MODULE entries  %time %alloc   %time %alloc

MAIN MAIN 00.0   0.0100.0 100.0
 mainMain 00.0   0.0  0.0   0.0
 CAF PrelShow 10.0   0.0  0.0   0.0
 CAF PrelFloat30.0   0.0  0.0   0.0
 CAF PrelHandle   30.0   0.0  0.0   0.0
 CAF Main 90.0   0.0100.0 100.0
  main   Main 10.8   0.0100.0 100.0
   foo   Main 100013.1   2.4 96.2  98.5
bar  Main 1   93.1  96.1 93.1  96.1
   foldl'Main 100023.1   1.4  3.1   1.4

___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users



Re: Floating point performance

2001-01-26 Thread Marcin 'Qrczak' Kowalczyk

Fri, 26 Jan 2001 17:40:17 +0100, Jan Kort [EMAIL PROTECTED] pisze:

 I made a profile and it says most of the time (93%) is spent in
 the function bar.

Did you compile with optimization turned on (option -O)?
I see similar results without -O but quite different with -O.

-- 
 __("  Marcin Kowalczyk * [EMAIL PROTECTED] http://qrczak.ids.net.pl/
 \__/
  ^^  SYGNATURA ZASTPCZA
QRCZAK


___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users