[vector] #75: Pack unboxed Bool vectors tightly

vector vector at projects.haskell.org
Thu Jan 26 22:33:44 GMT 2012


#75: Pack unboxed Bool vectors tightly
------------------------+---------------------------------------------------
Reporter:  ds           |        Owner:         
    Type:  enhancement  |       Status:  closed 
Priority:  major        |    Milestone:         
 Version:               |   Resolution:  wontfix
Keywords:               |  
------------------------+---------------------------------------------------
Changes (by rl):

  * status:  new => closed
  * resolution:  => wontfix


Comment:

 Yes, this is quite deliberate. There two reasons for this.

 Firstly, most vector operations are implemented in terms of reading and
 writing individual elements. This would be horrendously slow to do for
 individual bits (it's already quite slow for bytes). There is some work
 being done on this but that'll take a while. But even if/when this is
 solved, something like `zipWith (&&)` would still be very slow, you'd have
 to use specialised collective operations. In general a bit-packed
 representation uses less memory but provides much slower access to
 individual elements. This is not the trade-off that unboxed and storable
 vectors make in general so doing this just for `Bool` would be quite
 inconsistent, IMO.

 Secondly, a bit-packed representation doesn't allow parallel access to
 individual elements, for obvious reasons. AFAIK, on all platforms that GHC
 runs on (basically x86 and Sparc), byte and half-word writes are
 essentially atomic so concurrent writes to different elements of an
 unboxed or storable vector don't interfere with each other. This is a very
 nice property to have and DPH, for instance, relies on it.

 That said, a separate generic packed vector type would be very nice to
 have.

-- 
Ticket URL: <http://trac.haskell.org/vector/ticket/75#comment:1>
vector <http://trac.haskell.org/vector>
Package vector


More information about the vector mailing list