Re: [Haskell-cafe] haskell version of fractal benchmark

2007-06-09 Thread Scott Cruzen
* Andrew Coppin [EMAIL PROTECTED] [070608 02:45]:
Bayley, Alistair wrote:
 
 [[1]mailto:[EMAIL PROTECTED] 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 timecompile time
none  46.401   3.136
-O 5.033   4.906
-O24.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).
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] haskell version of fractal benchmark

2007-06-09 Thread Donald Bruce Stewart
dons:
 sic:
  * Andrew Coppin [EMAIL PROTECTED] [070608 02:45]:
  Bayley, Alistair wrote:
   
   [[1]mailto:[EMAIL PROTECTED] 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 timecompile time
  none  46.401   3.136
  -O 5.033   4.906
  -O24.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
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Data polymophism

2007-06-09 Thread Phlex

Thanks to both Christian and Tomasz.
This whole thing seems a bit too hard for the intended purpose.
After much tries and errors, I think i'll go for closures returning 
DbIndex items.


Something like this :

uniqueIndex bkf datas =
 DbIndex{dbiInsertIndex=insertIndex, {- more methods -}}
 where index = UniqueIndex bkf datas
   insertIndex id item = do newIndex - uniqueIndexInsert item index
return $ uniqueIndex bkf $ uiItems newIndex
   -- more functions
   
multiIndex bkf datas =

 DbIndex{dbiInsertIndex=insertIndex, {- more methods -}}
 where index = MultiIndex bkf datas
   insertIndex id item = do newIndex - multiIndexInsert id item index
return $ multiIndex  bkf $ miItems newIndex
   -- more functions

This keeps the definitions related to each index type close together, 
and allows for extention by adding new index types later on. Actually I 
don't even need the MultiIndex and UniqueIndex types anymore, making the 
code even shorter.


Thanks for your time,
Sacha


Tomasz Zielonka wrote:

On Fri, Jun 08, 2007 at 07:49:20PM +0200, Tomasz Zielonka wrote:
  

On Fri, Jun 08, 2007 at 05:23:23PM +0200, Phlex wrote:

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)
  

The compiler probably can't infer higher-ranker types, so you have to
write you type signature explicitly. Try:

liftDbIndex :: Index_ i2 a2 k2 =
   (forall a1 k1 i1. Index_ i1 a1 k1 = i1 - i2) - DbIndex - 
DbIndex



Now I think that this type signature will be too restrictive. Ideally, i2, a2 
and
k2 would be existentially quantified, like

liftDbIndex :: (forall a1 k1 i1. Index_ i1 a1 k1 = i1 - (exists. Index_ i2 a2 
k2 = i2)) -
   DbIndex - DbIndex

AFAIK such type isn't supported by any Haskell compiler, so we have to
use the existential quantification from DbIndex:

liftDbIndex :: (forall a1 k1 i1. Index_ i1 a1 k1 = i1 - DbIndex) - DbIndex 
- DbIndex
liftDbIndex f (DbIndex i) = f i

Best regards
Tomek


  

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