[GHC] #6135: Unboxed Booleans
GHC
cvs-ghc at haskell.org
Mon Mar 18 09:24:18 CET 2013
#6135: Unboxed Booleans
---------------------------------+------------------------------------------
Reporter: benl | Owner: jstolarek
Type: feature request | Status: patch
Priority: normal | Milestone: 7.8.1
Component: Compiler | Version: 7.4.1
Keywords: | Os: Unknown/Multiple
Architecture: Unknown/Multiple | Failure: None/Unknown
Difficulty: Unknown | Testcase:
Blockedby: | Blocking:
Related: #605 |
---------------------------------+------------------------------------------
Comment(by jstolarek):
Following Ben's idea I created a proof-of-concept filter function using
the new primops:
{{{
filterN :: Vector Int -> Vector Int
filterN vec = runST $ do
let !size = length vec
fVec <- unsafeNew size
let put i x = do
let !(I# v) = x
inc = I# (v .>=# 0#)
unsafeWrite fVec i x
return $ i + inc
fSize <- foldM' put 0 vec
unsafeFreeze $ unsafeSlice 0 fSize fVec
}}}
Benchmarking 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). Full code available
[http://hackage.haskell.org/trac/ghc/wiki/PrimBool at the wiki page].
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/6135#comment:29>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list