Changes between Version 11 and Version 12 of PrimBool


Ignore:
Timestamp:
Mar 18, 2013 8:15:00 AM (13 months ago)
Author:
jstolarek
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • PrimBool

    v11 v12  
    306306  - how to remove the old `Compare` primops (ones of type `T -> T -> Bool`)? 
    307307  - once we have the new primops do we really care about the unboxed `Bool#`? 
     308 
     309=== Benchmarks for the proposed patch === 
     310 
     311Below is a proof-of-concept filter function that demonstrates performance gains possible with the new primops: 
     312 
     313{{{ 
     314filterN :: Vector Int -> Vector Int 
     315filterN vec = runST $ do 
     316  let !size = length vec 
     317  fVec <- unsafeNew size 
     318  let put i x = do 
     319        let !(I# v) = x 
     320            inc     = I# (v .>=# 0#) 
     321        unsafeWrite fVec i x 
     322        return $ i + inc 
     323  fSize <- foldM' put 0 vec 
     324  unsafeFreeze $ unsafeSlice 0 fSize fVec 
     325}}} 
     326 
     327Benchmarking with criterion shows that this function is 60% faster than the filter function based on stream fusion (tested for unboxed vectors containing 10 thousand and 10 million elements).